stimulus-rails 1.1.1 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"version":3,"file":"stimulus.min.js","sources":["../src/core/event_listener.ts","../src/core/dispatcher.ts","../src/core/action_descriptor.ts","../src/core/string_helpers.ts","../src/core/action.ts","../src/core/binding.ts","../src/mutation-observers/element_observer.ts","../src/mutation-observers/attribute_observer.ts","../src/mutation-observers/string_map_observer.ts","../src/multimap/set_operations.ts","../src/multimap/multimap.ts","../src/multimap/indexed_multimap.ts","../src/mutation-observers/token_list_observer.ts","../src/mutation-observers/value_list_observer.ts","../src/core/binding_observer.ts","../src/core/value_observer.ts","../src/core/target_observer.ts","../src/core/context.ts","../src/core/inheritable_statics.ts","../src/core/blessing.ts","../src/core/module.ts","../src/core/definition.ts","../src/core/class_map.ts","../src/core/data_map.ts","../src/core/guide.ts","../src/core/selectors.ts","../src/core/target_set.ts","../src/core/scope.ts","../src/core/scope_observer.ts","../src/core/router.ts","../src/core/schema.ts","../src/core/application.ts","../src/core/value_properties.ts","../src/core/controller.ts","../src/core/class_properties.ts","../src/core/target_properties.ts"],"sourcesContent":["import { Binding } from \"./binding\"\n\nexport class EventListener implements EventListenerObject {\n readonly eventTarget: EventTarget\n readonly eventName: string\n readonly eventOptions: AddEventListenerOptions\n private unorderedBindings: Set<Binding>\n\n constructor(eventTarget: EventTarget, eventName: string, eventOptions: AddEventListenerOptions) {\n this.eventTarget = eventTarget\n this.eventName = eventName\n this.eventOptions = eventOptions\n this.unorderedBindings = new Set()\n }\n\n connect() {\n this.eventTarget.addEventListener(this.eventName, this, this.eventOptions)\n }\n\n disconnect() {\n this.eventTarget.removeEventListener(this.eventName, this, this.eventOptions)\n }\n\n // Binding observer delegate\n\n bindingConnected(binding: Binding) {\n this.unorderedBindings.add(binding)\n }\n\n bindingDisconnected(binding: Binding) {\n this.unorderedBindings.delete(binding)\n }\n\n handleEvent(event: Event) {\n // FIXME: Determine why TS won't recognize that the extended event has immediatePropagationStopped\n const extendedEvent = extendEvent(event) as any\n for (const binding of this.bindings) {\n if (extendedEvent.immediatePropagationStopped) {\n break\n } else {\n binding.handleEvent(extendedEvent)\n }\n }\n }\n\n hasBindings() {\n return this.unorderedBindings.size > 0\n }\n\n get bindings(): Binding[] {\n return Array.from(this.unorderedBindings).sort((left, right) => {\n const leftIndex = left.index,\n rightIndex = right.index\n return leftIndex < rightIndex ? -1 : leftIndex > rightIndex ? 1 : 0\n })\n }\n}\n\nfunction extendEvent(event: Event) {\n if (\"immediatePropagationStopped\" in event) {\n return event\n } else {\n const { stopImmediatePropagation } = event\n return Object.assign(event, {\n immediatePropagationStopped: false,\n stopImmediatePropagation() {\n this.immediatePropagationStopped = true\n stopImmediatePropagation.call(this)\n },\n })\n }\n}\n","import { Application } from \"./application\"\nimport { Binding } from \"./binding\"\nimport { BindingObserverDelegate } from \"./binding_observer\"\nimport { EventListener } from \"./event_listener\"\n\nexport class Dispatcher implements BindingObserverDelegate {\n readonly application: Application\n private eventListenerMaps: Map<EventTarget, Map<string, EventListener>>\n private started: boolean\n\n constructor(application: Application) {\n this.application = application\n this.eventListenerMaps = new Map()\n this.started = false\n }\n\n start() {\n if (!this.started) {\n this.started = true\n this.eventListeners.forEach((eventListener) => eventListener.connect())\n }\n }\n\n stop() {\n if (this.started) {\n this.started = false\n this.eventListeners.forEach((eventListener) => eventListener.disconnect())\n }\n }\n\n get eventListeners(): EventListener[] {\n return Array.from(this.eventListenerMaps.values()).reduce(\n (listeners, map) => listeners.concat(Array.from(map.values())),\n [] as EventListener[]\n )\n }\n\n // Binding observer delegate\n\n bindingConnected(binding: Binding) {\n this.fetchEventListenerForBinding(binding).bindingConnected(binding)\n }\n\n bindingDisconnected(binding: Binding, clearEventListeners: boolean = false) {\n this.fetchEventListenerForBinding(binding).bindingDisconnected(binding)\n if (clearEventListeners) this.clearEventListenersForBinding(binding)\n }\n\n // Error handling\n\n handleError(error: Error, message: string, detail: object = {}) {\n this.application.handleError(error, `Error ${message}`, detail)\n }\n\n private clearEventListenersForBinding(binding: Binding) {\n const eventListener = this.fetchEventListenerForBinding(binding)\n if (!eventListener.hasBindings()) {\n eventListener.disconnect()\n this.removeMappedEventListenerFor(binding)\n }\n }\n\n private removeMappedEventListenerFor(binding: Binding) {\n const { eventTarget, eventName, eventOptions } = binding\n const eventListenerMap = this.fetchEventListenerMapForEventTarget(eventTarget)\n const cacheKey = this.cacheKey(eventName, eventOptions)\n\n eventListenerMap.delete(cacheKey)\n if (eventListenerMap.size == 0) this.eventListenerMaps.delete(eventTarget)\n }\n\n private fetchEventListenerForBinding(binding: Binding): EventListener {\n const { eventTarget, eventName, eventOptions } = binding\n return this.fetchEventListener(eventTarget, eventName, eventOptions)\n }\n\n private fetchEventListener(\n eventTarget: EventTarget,\n eventName: string,\n eventOptions: AddEventListenerOptions\n ): EventListener {\n const eventListenerMap = this.fetchEventListenerMapForEventTarget(eventTarget)\n const cacheKey = this.cacheKey(eventName, eventOptions)\n let eventListener = eventListenerMap.get(cacheKey)\n if (!eventListener) {\n eventListener = this.createEventListener(eventTarget, eventName, eventOptions)\n eventListenerMap.set(cacheKey, eventListener)\n }\n return eventListener\n }\n\n private createEventListener(\n eventTarget: EventTarget,\n eventName: string,\n eventOptions: AddEventListenerOptions\n ): EventListener {\n const eventListener = new EventListener(eventTarget, eventName, eventOptions)\n if (this.started) {\n eventListener.connect()\n }\n return eventListener\n }\n\n private fetchEventListenerMapForEventTarget(eventTarget: EventTarget): Map<string, EventListener> {\n let eventListenerMap = this.eventListenerMaps.get(eventTarget)\n if (!eventListenerMap) {\n eventListenerMap = new Map()\n this.eventListenerMaps.set(eventTarget, eventListenerMap)\n }\n return eventListenerMap\n }\n\n private cacheKey(eventName: string, eventOptions: any): string {\n const parts = [eventName]\n Object.keys(eventOptions)\n .sort()\n .forEach((key) => {\n parts.push(`${eventOptions[key] ? \"\" : \"!\"}${key}`)\n })\n return parts.join(\":\")\n }\n}\n","export interface ActionDescriptor {\n eventTarget: EventTarget\n eventOptions: AddEventListenerOptions\n eventName: string\n identifier: string\n methodName: string\n}\n\nexport type ActionDescriptorFilters = Record<string, ActionDescriptorFilter>\nexport type ActionDescriptorFilter = (options: ActionDescriptorFilterOptions) => boolean\ntype ActionDescriptorFilterOptions = {\n name: string\n value: boolean\n event: Event\n element: Element\n}\n\nexport const defaultActionDescriptorFilters: ActionDescriptorFilters = {\n stop({ event, value }) {\n if (value) event.stopPropagation()\n\n return true\n },\n\n prevent({ event, value }) {\n if (value) event.preventDefault()\n\n return true\n },\n\n self({ event, value, element }) {\n if (value) {\n return element === event.target\n } else {\n return true\n }\n },\n}\n\n// capture nos.: 12 23 4 43 1 5 56 7 768 9 98\nconst descriptorPattern = /^((.+?)(@(window|document))?->)?(.+?)(#([^:]+?))(:(.+))?$/\n\nexport function parseActionDescriptorString(descriptorString: string): Partial<ActionDescriptor> {\n const source = descriptorString.trim()\n const matches = source.match(descriptorPattern) || []\n return {\n eventTarget: parseEventTarget(matches[4]),\n eventName: matches[2],\n eventOptions: matches[9] ? parseEventOptions(matches[9]) : {},\n identifier: matches[5],\n methodName: matches[7],\n }\n}\n\nfunction parseEventTarget(eventTargetName: string): EventTarget | undefined {\n if (eventTargetName == \"window\") {\n return window\n } else if (eventTargetName == \"document\") {\n return document\n }\n}\n\nfunction parseEventOptions(eventOptions: string): AddEventListenerOptions {\n return eventOptions\n .split(\":\")\n .reduce((options, token) => Object.assign(options, { [token.replace(/^!/, \"\")]: !/^!/.test(token) }), {})\n}\n\nexport function stringifyEventTarget(eventTarget: EventTarget) {\n if (eventTarget == window) {\n return \"window\"\n } else if (eventTarget == document) {\n return \"document\"\n }\n}\n","export function camelize(value: string) {\n return value.replace(/(?:[_-])([a-z0-9])/g, (_, char) => char.toUpperCase())\n}\n\nexport function capitalize(value: string) {\n return value.charAt(0).toUpperCase() + value.slice(1)\n}\n\nexport function dasherize(value: string) {\n return value.replace(/([A-Z])/g, (_, char) => `-${char.toLowerCase()}`)\n}\n\nexport function tokenize(value: string) {\n return value.match(/[^\\s]+/g) || []\n}\n","import { ActionDescriptor, parseActionDescriptorString, stringifyEventTarget } from \"./action_descriptor\"\nimport { Token } from \"../mutation-observers\"\nimport { camelize } from \"./string_helpers\"\nexport class Action {\n readonly element: Element\n readonly index: number\n readonly eventTarget: EventTarget\n readonly eventName: string\n readonly eventOptions: AddEventListenerOptions\n readonly identifier: string\n readonly methodName: string\n\n static forToken(token: Token) {\n return new this(token.element, token.index, parseActionDescriptorString(token.content))\n }\n\n constructor(element: Element, index: number, descriptor: Partial<ActionDescriptor>) {\n this.element = element\n this.index = index\n this.eventTarget = descriptor.eventTarget || element\n this.eventName = descriptor.eventName || getDefaultEventNameForElement(element) || error(\"missing event name\")\n this.eventOptions = descriptor.eventOptions || {}\n this.identifier = descriptor.identifier || error(\"missing identifier\")\n this.methodName = descriptor.methodName || error(\"missing method name\")\n }\n\n toString() {\n const eventNameSuffix = this.eventTargetName ? `@${this.eventTargetName}` : \"\"\n return `${this.eventName}${eventNameSuffix}->${this.identifier}#${this.methodName}`\n }\n\n get params() {\n const params: { [key: string]: any } = {}\n const pattern = new RegExp(`^data-${this.identifier}-(.+)-param$`, \"i\")\n\n for (const { name, value } of Array.from(this.element.attributes)) {\n const match = name.match(pattern)\n const key = match && match[1]\n if (key) {\n params[camelize(key)] = typecast(value)\n }\n }\n return params\n }\n\n private get eventTargetName() {\n return stringifyEventTarget(this.eventTarget)\n }\n}\n\nconst defaultEventNames: { [tagName: string]: (element: Element) => string } = {\n a: () => \"click\",\n button: () => \"click\",\n form: () => \"submit\",\n details: () => \"toggle\",\n input: (e) => (e.getAttribute(\"type\") == \"submit\" ? \"click\" : \"input\"),\n select: () => \"change\",\n textarea: () => \"input\",\n}\n\nexport function getDefaultEventNameForElement(element: Element): string | undefined {\n const tagName = element.tagName.toLowerCase()\n if (tagName in defaultEventNames) {\n return defaultEventNames[tagName](element)\n }\n}\n\nfunction error(message: string): never {\n throw new Error(message)\n}\n\nfunction typecast(value: any): any {\n try {\n return JSON.parse(value)\n } catch (o_O) {\n return value\n }\n}\n","import { Action } from \"./action\"\nimport { ActionEvent } from \"./action_event\"\nimport { Context } from \"./context\"\nimport { Controller } from \"./controller\"\nimport { Scope } from \"./scope\"\nexport class Binding {\n readonly context: Context\n readonly action: Action\n\n constructor(context: Context, action: Action) {\n this.context = context\n this.action = action\n }\n\n get index(): number {\n return this.action.index\n }\n\n get eventTarget(): EventTarget {\n return this.action.eventTarget\n }\n\n get eventOptions(): AddEventListenerOptions {\n return this.action.eventOptions\n }\n\n get identifier(): string {\n return this.context.identifier\n }\n\n handleEvent(event: Event) {\n if (this.willBeInvokedByEvent(event) && this.applyEventModifiers(event)) {\n this.invokeWithEvent(event)\n }\n }\n\n get eventName(): string {\n return this.action.eventName\n }\n\n get method(): Function {\n const method = (this.controller as any)[this.methodName]\n if (typeof method == \"function\") {\n return method\n }\n throw new Error(`Action \"${this.action}\" references undefined method \"${this.methodName}\"`)\n }\n\n private applyEventModifiers(event: Event): boolean {\n const { element } = this.action\n const { actionDescriptorFilters } = this.context.application\n\n let passes = true\n\n for (const [name, value] of Object.entries(this.eventOptions)) {\n if (name in actionDescriptorFilters) {\n const filter = actionDescriptorFilters[name]\n\n passes = passes && filter({ name, value, event, element })\n } else {\n continue\n }\n }\n\n return passes\n }\n\n private invokeWithEvent(event: Event) {\n const { target, currentTarget } = event\n try {\n const { params } = this.action\n const actionEvent: ActionEvent = Object.assign(event, { params })\n this.method.call(this.controller, actionEvent)\n this.context.logDebugActivity(this.methodName, { event, target, currentTarget, action: this.methodName })\n } catch (error: any) {\n const { identifier, controller, element, index } = this\n const detail = { identifier, controller, element, index, event }\n this.context.handleError(error, `invoking action \"${this.action}\"`, detail)\n }\n }\n\n private willBeInvokedByEvent(event: Event): boolean {\n const eventTarget = event.target\n if (this.element === eventTarget) {\n return true\n } else if (eventTarget instanceof Element && this.element.contains(eventTarget)) {\n return this.scope.containsElement(eventTarget)\n } else {\n return this.scope.containsElement(this.action.element)\n }\n }\n\n private get controller(): Controller {\n return this.context.controller\n }\n\n private get methodName(): string {\n return this.action.methodName\n }\n\n private get element(): Element {\n return this.scope.element\n }\n\n private get scope(): Scope {\n return this.context.scope\n }\n}\n","export interface ElementObserverDelegate {\n matchElement(element: Element): boolean\n matchElementsInTree(tree: Element): Element[]\n\n elementMatched?(element: Element): void\n elementUnmatched?(element: Element): void\n elementAttributeChanged?(element: Element, attributeName: string): void\n}\n\nexport class ElementObserver {\n element: Element\n started: boolean\n private delegate: ElementObserverDelegate\n\n private elements: Set<Element>\n private mutationObserver: MutationObserver\n private mutationObserverInit = { attributes: true, childList: true, subtree: true }\n\n constructor(element: Element, delegate: ElementObserverDelegate) {\n this.element = element\n this.started = false\n this.delegate = delegate\n\n this.elements = new Set()\n this.mutationObserver = new MutationObserver((mutations) => this.processMutations(mutations))\n }\n\n start() {\n if (!this.started) {\n this.started = true\n this.mutationObserver.observe(this.element, this.mutationObserverInit)\n this.refresh()\n }\n }\n\n pause(callback: () => void) {\n if (this.started) {\n this.mutationObserver.disconnect()\n this.started = false\n }\n\n callback()\n\n if (!this.started) {\n this.mutationObserver.observe(this.element, this.mutationObserverInit)\n this.started = true\n }\n }\n\n stop() {\n if (this.started) {\n this.mutationObserver.takeRecords()\n this.mutationObserver.disconnect()\n this.started = false\n }\n }\n\n refresh() {\n if (this.started) {\n const matches = new Set(this.matchElementsInTree())\n\n for (const element of Array.from(this.elements)) {\n if (!matches.has(element)) {\n this.removeElement(element)\n }\n }\n\n for (const element of Array.from(matches)) {\n this.addElement(element)\n }\n }\n }\n\n // Mutation record processing\n\n private processMutations(mutations: MutationRecord[]) {\n if (this.started) {\n for (const mutation of mutations) {\n this.processMutation(mutation)\n }\n }\n }\n\n private processMutation(mutation: MutationRecord) {\n if (mutation.type == \"attributes\") {\n this.processAttributeChange(mutation.target, mutation.attributeName!)\n } else if (mutation.type == \"childList\") {\n this.processRemovedNodes(mutation.removedNodes)\n this.processAddedNodes(mutation.addedNodes)\n }\n }\n\n private processAttributeChange(node: Node, attributeName: string) {\n const element = node as Element\n if (this.elements.has(element)) {\n if (this.delegate.elementAttributeChanged && this.matchElement(element)) {\n this.delegate.elementAttributeChanged(element, attributeName)\n } else {\n this.removeElement(element)\n }\n } else if (this.matchElement(element)) {\n this.addElement(element)\n }\n }\n\n private processRemovedNodes(nodes: NodeList) {\n for (const node of Array.from(nodes)) {\n const element = this.elementFromNode(node)\n if (element) {\n this.processTree(element, this.removeElement)\n }\n }\n }\n\n private processAddedNodes(nodes: NodeList) {\n for (const node of Array.from(nodes)) {\n const element = this.elementFromNode(node)\n if (element && this.elementIsActive(element)) {\n this.processTree(element, this.addElement)\n }\n }\n }\n\n // Element matching\n\n private matchElement(element: Element): boolean {\n return this.delegate.matchElement(element)\n }\n\n private matchElementsInTree(tree: Element = this.element): Element[] {\n return this.delegate.matchElementsInTree(tree)\n }\n\n private processTree(tree: Element, processor: (element: Element) => void) {\n for (const element of this.matchElementsInTree(tree)) {\n processor.call(this, element)\n }\n }\n\n private elementFromNode(node: Node): Element | undefined {\n if (node.nodeType == Node.ELEMENT_NODE) {\n return node as Element\n }\n }\n\n private elementIsActive(element: Element): boolean {\n if (element.isConnected != this.element.isConnected) {\n return false\n } else {\n return this.element.contains(element)\n }\n }\n\n // Element tracking\n\n private addElement(element: Element) {\n if (!this.elements.has(element)) {\n if (this.elementIsActive(element)) {\n this.elements.add(element)\n if (this.delegate.elementMatched) {\n this.delegate.elementMatched(element)\n }\n }\n }\n }\n\n private removeElement(element: Element) {\n if (this.elements.has(element)) {\n this.elements.delete(element)\n if (this.delegate.elementUnmatched) {\n this.delegate.elementUnmatched(element)\n }\n }\n }\n}\n","import { ElementObserver, ElementObserverDelegate } from \"./element_observer\"\n\nexport interface AttributeObserverDelegate {\n elementMatchedAttribute?(element: Element, attributeName: string): void\n elementAttributeValueChanged?(element: Element, attributeName: string): void\n elementUnmatchedAttribute?(element: Element, attributeName: string): void\n}\n\nexport class AttributeObserver implements ElementObserverDelegate {\n attributeName: string\n private delegate: AttributeObserverDelegate\n\n private elementObserver: ElementObserver\n\n constructor(element: Element, attributeName: string, delegate: AttributeObserverDelegate) {\n this.attributeName = attributeName\n this.delegate = delegate\n\n this.elementObserver = new ElementObserver(element, this)\n }\n\n get element(): Element {\n return this.elementObserver.element\n }\n\n get selector(): string {\n return `[${this.attributeName}]`\n }\n\n start() {\n this.elementObserver.start()\n }\n\n pause(callback: () => void) {\n this.elementObserver.pause(callback)\n }\n\n stop() {\n this.elementObserver.stop()\n }\n\n refresh() {\n this.elementObserver.refresh()\n }\n\n get started(): boolean {\n return this.elementObserver.started\n }\n\n // Element observer delegate\n\n matchElement(element: Element): boolean {\n return element.hasAttribute(this.attributeName)\n }\n\n matchElementsInTree(tree: Element): Element[] {\n const match = this.matchElement(tree) ? [tree] : []\n const matches = Array.from(tree.querySelectorAll(this.selector))\n return match.concat(matches)\n }\n\n elementMatched(element: Element) {\n if (this.delegate.elementMatchedAttribute) {\n this.delegate.elementMatchedAttribute(element, this.attributeName)\n }\n }\n\n elementUnmatched(element: Element) {\n if (this.delegate.elementUnmatchedAttribute) {\n this.delegate.elementUnmatchedAttribute(element, this.attributeName)\n }\n }\n\n elementAttributeChanged(element: Element, attributeName: string) {\n if (this.delegate.elementAttributeValueChanged && this.attributeName == attributeName) {\n this.delegate.elementAttributeValueChanged(element, attributeName)\n }\n }\n}\n","export interface StringMapObserverDelegate {\n getStringMapKeyForAttribute(attributeName: string): string | undefined\n stringMapKeyAdded?(key: string, attributeName: string): void\n stringMapValueChanged?(value: string | null, key: string, oldValue: string | null): void\n stringMapKeyRemoved?(key: string, attributeName: string, oldValue: string | null): void\n}\n\nexport class StringMapObserver {\n readonly element: Element\n readonly delegate: StringMapObserverDelegate\n private started: boolean\n private stringMap: Map<string, string>\n private mutationObserver: MutationObserver\n\n constructor(element: Element, delegate: StringMapObserverDelegate) {\n this.element = element\n this.delegate = delegate\n this.started = false\n this.stringMap = new Map()\n this.mutationObserver = new MutationObserver((mutations) => this.processMutations(mutations))\n }\n\n start() {\n if (!this.started) {\n this.started = true\n this.mutationObserver.observe(this.element, { attributes: true, attributeOldValue: true })\n this.refresh()\n }\n }\n\n stop() {\n if (this.started) {\n this.mutationObserver.takeRecords()\n this.mutationObserver.disconnect()\n this.started = false\n }\n }\n\n refresh() {\n if (this.started) {\n for (const attributeName of this.knownAttributeNames) {\n this.refreshAttribute(attributeName, null)\n }\n }\n }\n\n // Mutation record processing\n\n private processMutations(mutations: MutationRecord[]) {\n if (this.started) {\n for (const mutation of mutations) {\n this.processMutation(mutation)\n }\n }\n }\n\n private processMutation(mutation: MutationRecord) {\n const attributeName = mutation.attributeName\n if (attributeName) {\n this.refreshAttribute(attributeName, mutation.oldValue)\n }\n }\n\n // State tracking\n\n private refreshAttribute(attributeName: string, oldValue: string | null) {\n const key = this.delegate.getStringMapKeyForAttribute(attributeName)\n if (key != null) {\n if (!this.stringMap.has(attributeName)) {\n this.stringMapKeyAdded(key, attributeName)\n }\n\n const value = this.element.getAttribute(attributeName)\n if (this.stringMap.get(attributeName) != value) {\n this.stringMapValueChanged(value, key, oldValue)\n }\n\n if (value == null) {\n const oldValue = this.stringMap.get(attributeName)\n this.stringMap.delete(attributeName)\n if (oldValue) this.stringMapKeyRemoved(key, attributeName, oldValue)\n } else {\n this.stringMap.set(attributeName, value)\n }\n }\n }\n\n private stringMapKeyAdded(key: string, attributeName: string) {\n if (this.delegate.stringMapKeyAdded) {\n this.delegate.stringMapKeyAdded(key, attributeName)\n }\n }\n\n private stringMapValueChanged(value: string | null, key: string, oldValue: string | null) {\n if (this.delegate.stringMapValueChanged) {\n this.delegate.stringMapValueChanged(value, key, oldValue)\n }\n }\n\n private stringMapKeyRemoved(key: string, attributeName: string, oldValue: string | null) {\n if (this.delegate.stringMapKeyRemoved) {\n this.delegate.stringMapKeyRemoved(key, attributeName, oldValue)\n }\n }\n\n private get knownAttributeNames() {\n return Array.from(new Set(this.currentAttributeNames.concat(this.recordedAttributeNames)))\n }\n\n private get currentAttributeNames() {\n return Array.from(this.element.attributes).map((attribute) => attribute.name)\n }\n\n private get recordedAttributeNames() {\n return Array.from(this.stringMap.keys())\n }\n}\n","export function add<K, V>(map: Map<K, Set<V>>, key: K, value: V) {\n fetch(map, key).add(value)\n}\n\nexport function del<K, V>(map: Map<K, Set<V>>, key: K, value: V) {\n fetch(map, key).delete(value)\n prune(map, key)\n}\n\nexport function fetch<K, V>(map: Map<K, Set<V>>, key: K): Set<V> {\n let values = map.get(key)\n if (!values) {\n values = new Set()\n map.set(key, values)\n }\n return values\n}\n\nexport function prune<K, V>(map: Map<K, Set<V>>, key: K) {\n const values = map.get(key)\n if (values != null && values.size == 0) {\n map.delete(key)\n }\n}\n","import { add, del } from \"./set_operations\"\n\nexport class Multimap<K, V> {\n private valuesByKey: Map<K, Set<V>>\n\n constructor() {\n this.valuesByKey = new Map<K, Set<V>>()\n }\n\n get keys() {\n return Array.from(this.valuesByKey.keys())\n }\n\n get values(): V[] {\n const sets = Array.from(this.valuesByKey.values())\n return sets.reduce((values, set) => values.concat(Array.from(set)), <V[]>[])\n }\n\n get size(): number {\n const sets = Array.from(this.valuesByKey.values())\n return sets.reduce((size, set) => size + set.size, 0)\n }\n\n add(key: K, value: V) {\n add(this.valuesByKey, key, value)\n }\n\n delete(key: K, value: V) {\n del(this.valuesByKey, key, value)\n }\n\n has(key: K, value: V): boolean {\n const values = this.valuesByKey.get(key)\n return values != null && values.has(value)\n }\n\n hasKey(key: K): boolean {\n return this.valuesByKey.has(key)\n }\n\n hasValue(value: V): boolean {\n const sets = Array.from(this.valuesByKey.values())\n return sets.some((set) => set.has(value))\n }\n\n getValuesForKey(key: K): V[] {\n const values = this.valuesByKey.get(key)\n return values ? Array.from(values) : []\n }\n\n getKeysForValue(value: V): K[] {\n return Array.from(this.valuesByKey)\n .filter(([_key, values]) => values.has(value))\n .map(([key, _values]) => key)\n }\n}\n","import { Multimap } from \"./multimap\"\nimport { add, del } from \"./set_operations\"\n\nexport class IndexedMultimap<K, V> extends Multimap<K, V> {\n private keysByValue: Map<V, Set<K>>\n\n constructor() {\n super()\n this.keysByValue = new Map()\n }\n\n get values(): V[] {\n return Array.from(this.keysByValue.keys())\n }\n\n add(key: K, value: V) {\n super.add(key, value)\n add(this.keysByValue, value, key)\n }\n\n delete(key: K, value: V) {\n super.delete(key, value)\n del(this.keysByValue, value, key)\n }\n\n hasValue(value: V): boolean {\n return this.keysByValue.has(value)\n }\n\n getKeysForValue(value: V): K[] {\n const set = this.keysByValue.get(value)\n return set ? Array.from(set) : []\n }\n}\n","import { AttributeObserver, AttributeObserverDelegate } from \"./attribute_observer\"\nimport { Multimap } from \"../multimap\"\n\nexport interface Token {\n element: Element\n attributeName: string\n index: number\n content: string\n}\n\nexport interface TokenListObserverDelegate {\n tokenMatched(token: Token): void\n tokenUnmatched(token: Token): void\n}\n\nexport class TokenListObserver implements AttributeObserverDelegate {\n private attributeObserver: AttributeObserver\n private delegate: TokenListObserverDelegate\n private tokensByElement: Multimap<Element, Token>\n\n constructor(element: Element, attributeName: string, delegate: TokenListObserverDelegate) {\n this.attributeObserver = new AttributeObserver(element, attributeName, this)\n this.delegate = delegate\n this.tokensByElement = new Multimap()\n }\n\n get started(): boolean {\n return this.attributeObserver.started\n }\n\n start() {\n this.attributeObserver.start()\n }\n\n pause(callback: () => void) {\n this.attributeObserver.pause(callback)\n }\n\n stop() {\n this.attributeObserver.stop()\n }\n\n refresh() {\n this.attributeObserver.refresh()\n }\n\n get element(): Element {\n return this.attributeObserver.element\n }\n\n get attributeName(): string {\n return this.attributeObserver.attributeName\n }\n\n // Attribute observer delegate\n\n elementMatchedAttribute(element: Element) {\n this.tokensMatched(this.readTokensForElement(element))\n }\n\n elementAttributeValueChanged(element: Element) {\n const [unmatchedTokens, matchedTokens] = this.refreshTokensForElement(element)\n this.tokensUnmatched(unmatchedTokens)\n this.tokensMatched(matchedTokens)\n }\n\n elementUnmatchedAttribute(element: Element) {\n this.tokensUnmatched(this.tokensByElement.getValuesForKey(element))\n }\n\n private tokensMatched(tokens: Token[]) {\n tokens.forEach((token) => this.tokenMatched(token))\n }\n\n private tokensUnmatched(tokens: Token[]) {\n tokens.forEach((token) => this.tokenUnmatched(token))\n }\n\n private tokenMatched(token: Token) {\n this.delegate.tokenMatched(token)\n this.tokensByElement.add(token.element, token)\n }\n\n private tokenUnmatched(token: Token) {\n this.delegate.tokenUnmatched(token)\n this.tokensByElement.delete(token.element, token)\n }\n\n private refreshTokensForElement(element: Element): [Token[], Token[]] {\n const previousTokens = this.tokensByElement.getValuesForKey(element)\n const currentTokens = this.readTokensForElement(element)\n const firstDifferingIndex = zip(previousTokens, currentTokens).findIndex(\n ([previousToken, currentToken]) => !tokensAreEqual(previousToken, currentToken)\n )\n\n if (firstDifferingIndex == -1) {\n return [[], []]\n } else {\n return [previousTokens.slice(firstDifferingIndex), currentTokens.slice(firstDifferingIndex)]\n }\n }\n\n private readTokensForElement(element: Element): Token[] {\n const attributeName = this.attributeName\n const tokenString = element.getAttribute(attributeName) || \"\"\n return parseTokenString(tokenString, element, attributeName)\n }\n}\n\nfunction parseTokenString(tokenString: string, element: Element, attributeName: string): Token[] {\n return tokenString\n .trim()\n .split(/\\s+/)\n .filter((content) => content.length)\n .map((content, index) => ({ element, attributeName, content, index }))\n}\n\nfunction zip<L, R>(left: L[], right: R[]): [L | undefined, R | undefined][] {\n const length = Math.max(left.length, right.length)\n return Array.from({ length }, (_, index) => [left[index], right[index]] as [L, R])\n}\n\nfunction tokensAreEqual(left?: Token, right?: Token) {\n return left && right && left.index == right.index && left.content == right.content\n}\n","import { Token, TokenListObserver, TokenListObserverDelegate } from \"./token_list_observer\"\n\nexport interface ValueListObserverDelegate<T> {\n parseValueForToken(token: Token): T | undefined\n elementMatchedValue(element: Element, value: T): void\n elementUnmatchedValue(element: Element, value: T): void\n}\n\ninterface ParseResult<T> {\n value?: T\n error?: Error\n}\n\nexport class ValueListObserver<T> implements TokenListObserverDelegate {\n private tokenListObserver: TokenListObserver\n private delegate: ValueListObserverDelegate<T>\n private parseResultsByToken: WeakMap<Token, ParseResult<T>>\n private valuesByTokenByElement: WeakMap<Element, Map<Token, T>>\n\n constructor(element: Element, attributeName: string, delegate: ValueListObserverDelegate<T>) {\n this.tokenListObserver = new TokenListObserver(element, attributeName, this)\n this.delegate = delegate\n this.parseResultsByToken = new WeakMap()\n this.valuesByTokenByElement = new WeakMap()\n }\n\n get started(): boolean {\n return this.tokenListObserver.started\n }\n\n start() {\n this.tokenListObserver.start()\n }\n\n stop() {\n this.tokenListObserver.stop()\n }\n\n refresh() {\n this.tokenListObserver.refresh()\n }\n\n get element(): Element {\n return this.tokenListObserver.element\n }\n\n get attributeName(): string {\n return this.tokenListObserver.attributeName\n }\n\n tokenMatched(token: Token) {\n const { element } = token\n const { value } = this.fetchParseResultForToken(token)\n if (value) {\n this.fetchValuesByTokenForElement(element).set(token, value)\n this.delegate.elementMatchedValue(element, value)\n }\n }\n\n tokenUnmatched(token: Token) {\n const { element } = token\n const { value } = this.fetchParseResultForToken(token)\n if (value) {\n this.fetchValuesByTokenForElement(element).delete(token)\n this.delegate.elementUnmatchedValue(element, value)\n }\n }\n\n private fetchParseResultForToken(token: Token) {\n let parseResult = this.parseResultsByToken.get(token)\n if (!parseResult) {\n parseResult = this.parseToken(token)\n this.parseResultsByToken.set(token, parseResult)\n }\n return parseResult\n }\n\n private fetchValuesByTokenForElement(element: Element) {\n let valuesByToken = this.valuesByTokenByElement.get(element)\n if (!valuesByToken) {\n valuesByToken = new Map()\n this.valuesByTokenByElement.set(element, valuesByToken)\n }\n return valuesByToken\n }\n\n private parseToken(token: Token): ParseResult<T> {\n try {\n const value = this.delegate.parseValueForToken(token)\n return { value }\n } catch (error: any) {\n return { error }\n }\n }\n}\n","import { Action } from \"./action\"\nimport { Binding } from \"./binding\"\nimport { Context } from \"./context\"\nimport { ErrorHandler } from \"./error_handler\"\nimport { Schema } from \"./schema\"\nimport { Token, ValueListObserver, ValueListObserverDelegate } from \"../mutation-observers\"\n\nexport interface BindingObserverDelegate extends ErrorHandler {\n bindingConnected(binding: Binding): void\n bindingDisconnected(binding: Binding, clearEventListeners?: boolean): void\n}\n\nexport class BindingObserver implements ValueListObserverDelegate<Action> {\n readonly context: Context\n private delegate: BindingObserverDelegate\n private valueListObserver?: ValueListObserver<Action>\n private bindingsByAction: Map<Action, Binding>\n\n constructor(context: Context, delegate: BindingObserverDelegate) {\n this.context = context\n this.delegate = delegate\n this.bindingsByAction = new Map()\n }\n\n start() {\n if (!this.valueListObserver) {\n this.valueListObserver = new ValueListObserver(this.element, this.actionAttribute, this)\n this.valueListObserver.start()\n }\n }\n\n stop() {\n if (this.valueListObserver) {\n this.valueListObserver.stop()\n delete this.valueListObserver\n this.disconnectAllActions()\n }\n }\n\n get element() {\n return this.context.element\n }\n\n get identifier() {\n return this.context.identifier\n }\n\n get actionAttribute() {\n return this.schema.actionAttribute\n }\n\n get schema(): Schema {\n return this.context.schema\n }\n\n get bindings(): Binding[] {\n return Array.from(this.bindingsByAction.values())\n }\n\n private connectAction(action: Action) {\n const binding = new Binding(this.context, action)\n this.bindingsByAction.set(action, binding)\n this.delegate.bindingConnected(binding)\n }\n\n private disconnectAction(action: Action) {\n const binding = this.bindingsByAction.get(action)\n if (binding) {\n this.bindingsByAction.delete(action)\n this.delegate.bindingDisconnected(binding)\n }\n }\n\n private disconnectAllActions() {\n this.bindings.forEach((binding) => this.delegate.bindingDisconnected(binding, true))\n this.bindingsByAction.clear()\n }\n\n // Value observer delegate\n\n parseValueForToken(token: Token): Action | undefined {\n const action = Action.forToken(token)\n if (action.identifier == this.identifier) {\n return action\n }\n }\n\n elementMatchedValue(element: Element, action: Action) {\n this.connectAction(action)\n }\n\n elementUnmatchedValue(element: Element, action: Action) {\n this.disconnectAction(action)\n }\n}\n","import { Context } from \"./context\"\nimport { StringMapObserver, StringMapObserverDelegate } from \"../mutation-observers\"\nimport { ValueDescriptor } from \"./value_properties\"\nimport { capitalize } from \"./string_helpers\"\n\nexport class ValueObserver implements StringMapObserverDelegate {\n readonly context: Context\n readonly receiver: any\n private stringMapObserver: StringMapObserver\n private valueDescriptorMap: { [attributeName: string]: ValueDescriptor }\n\n constructor(context: Context, receiver: any) {\n this.context = context\n this.receiver = receiver\n this.stringMapObserver = new StringMapObserver(this.element, this)\n this.valueDescriptorMap = (this.controller as any).valueDescriptorMap\n }\n\n start() {\n this.stringMapObserver.start()\n this.invokeChangedCallbacksForDefaultValues()\n }\n\n stop() {\n this.stringMapObserver.stop()\n }\n\n get element() {\n return this.context.element\n }\n\n get controller() {\n return this.context.controller\n }\n\n // String map observer delegate\n\n getStringMapKeyForAttribute(attributeName: string) {\n if (attributeName in this.valueDescriptorMap) {\n return this.valueDescriptorMap[attributeName].name\n }\n }\n\n stringMapKeyAdded(key: string, attributeName: string) {\n const descriptor = this.valueDescriptorMap[attributeName]\n\n if (!this.hasValue(key)) {\n this.invokeChangedCallback(key, descriptor.writer(this.receiver[key]), descriptor.writer(descriptor.defaultValue))\n }\n }\n\n stringMapValueChanged(value: string, name: string, oldValue: string) {\n const descriptor = this.valueDescriptorNameMap[name]\n\n if (value === null) return\n\n if (oldValue === null) {\n oldValue = descriptor.writer(descriptor.defaultValue)\n }\n\n this.invokeChangedCallback(name, value, oldValue)\n }\n\n stringMapKeyRemoved(key: string, attributeName: string, oldValue: string) {\n const descriptor = this.valueDescriptorNameMap[key]\n\n if (this.hasValue(key)) {\n this.invokeChangedCallback(key, descriptor.writer(this.receiver[key]), oldValue)\n } else {\n this.invokeChangedCallback(key, descriptor.writer(descriptor.defaultValue), oldValue)\n }\n }\n\n private invokeChangedCallbacksForDefaultValues() {\n for (const { key, name, defaultValue, writer } of this.valueDescriptors) {\n if (defaultValue != undefined && !this.controller.data.has(key)) {\n this.invokeChangedCallback(name, writer(defaultValue), undefined)\n }\n }\n }\n\n private invokeChangedCallback(name: string, rawValue: string, rawOldValue: string | undefined) {\n const changedMethodName = `${name}Changed`\n const changedMethod = this.receiver[changedMethodName]\n\n if (typeof changedMethod == \"function\") {\n const descriptor = this.valueDescriptorNameMap[name]\n\n try {\n const value = descriptor.reader(rawValue)\n let oldValue = rawOldValue\n\n if (rawOldValue) {\n oldValue = descriptor.reader(rawOldValue)\n }\n\n changedMethod.call(this.receiver, value, oldValue)\n } catch (error) {\n if (error instanceof TypeError) {\n error.message = `Stimulus Value \"${this.context.identifier}.${descriptor.name}\" - ${error.message}`\n }\n\n throw error\n }\n }\n }\n\n private get valueDescriptors() {\n const { valueDescriptorMap } = this\n return Object.keys(valueDescriptorMap).map((key) => valueDescriptorMap[key])\n }\n\n private get valueDescriptorNameMap() {\n const descriptors: { [type: string]: ValueDescriptor } = {}\n\n Object.keys(this.valueDescriptorMap).forEach((key) => {\n const descriptor = this.valueDescriptorMap[key]\n descriptors[descriptor.name] = descriptor\n })\n\n return descriptors\n }\n\n private hasValue(attributeName: string) {\n const descriptor = this.valueDescriptorNameMap[attributeName]\n const hasMethodName = `has${capitalize(descriptor.name)}`\n\n return this.receiver[hasMethodName]\n }\n}\n","import { Multimap } from \"../multimap\"\nimport { Token, TokenListObserver, TokenListObserverDelegate } from \"../mutation-observers\"\nimport { Context } from \"./context\"\n\nexport interface TargetObserverDelegate {\n targetConnected(element: Element, name: string): void\n targetDisconnected(element: Element, name: string): void\n}\n\nexport class TargetObserver implements TokenListObserverDelegate {\n readonly context: Context\n readonly delegate: TargetObserverDelegate\n readonly targetsByName: Multimap<string, Element>\n private tokenListObserver?: TokenListObserver\n\n constructor(context: Context, delegate: TargetObserverDelegate) {\n this.context = context\n this.delegate = delegate\n this.targetsByName = new Multimap()\n }\n\n start() {\n if (!this.tokenListObserver) {\n this.tokenListObserver = new TokenListObserver(this.element, this.attributeName, this)\n this.tokenListObserver.start()\n }\n }\n\n stop() {\n if (this.tokenListObserver) {\n this.disconnectAllTargets()\n this.tokenListObserver.stop()\n delete this.tokenListObserver\n }\n }\n\n // Token list observer delegate\n\n tokenMatched({ element, content: name }: Token) {\n if (this.scope.containsElement(element)) {\n this.connectTarget(element, name)\n }\n }\n\n tokenUnmatched({ element, content: name }: Token) {\n this.disconnectTarget(element, name)\n }\n\n // Target management\n\n connectTarget(element: Element, name: string) {\n if (!this.targetsByName.has(name, element)) {\n this.targetsByName.add(name, element)\n this.tokenListObserver?.pause(() => this.delegate.targetConnected(element, name))\n }\n }\n\n disconnectTarget(element: Element, name: string) {\n if (this.targetsByName.has(name, element)) {\n this.targetsByName.delete(name, element)\n this.tokenListObserver?.pause(() => this.delegate.targetDisconnected(element, name))\n }\n }\n\n disconnectAllTargets() {\n for (const name of this.targetsByName.keys) {\n for (const element of this.targetsByName.getValuesForKey(name)) {\n this.disconnectTarget(element, name)\n }\n }\n }\n\n // Private\n\n private get attributeName() {\n return `data-${this.context.identifier}-target`\n }\n\n private get element() {\n return this.context.element\n }\n\n private get scope() {\n return this.context.scope\n }\n}\n","import { Application } from \"./application\"\nimport { BindingObserver } from \"./binding_observer\"\nimport { Controller } from \"./controller\"\nimport { Dispatcher } from \"./dispatcher\"\nimport { ErrorHandler } from \"./error_handler\"\nimport { Module } from \"./module\"\nimport { Schema } from \"./schema\"\nimport { Scope } from \"./scope\"\nimport { ValueObserver } from \"./value_observer\"\nimport { TargetObserver, TargetObserverDelegate } from \"./target_observer\"\n\nexport class Context implements ErrorHandler, TargetObserverDelegate {\n readonly module: Module\n readonly scope: Scope\n readonly controller: Controller\n private bindingObserver: BindingObserver\n private valueObserver: ValueObserver\n private targetObserver: TargetObserver\n\n constructor(module: Module, scope: Scope) {\n this.module = module\n this.scope = scope\n this.controller = new module.controllerConstructor(this)\n this.bindingObserver = new BindingObserver(this, this.dispatcher)\n this.valueObserver = new ValueObserver(this, this.controller)\n this.targetObserver = new TargetObserver(this, this)\n\n try {\n this.controller.initialize()\n this.logDebugActivity(\"initialize\")\n } catch (error: any) {\n this.handleError(error, \"initializing controller\")\n }\n }\n\n connect() {\n this.bindingObserver.start()\n this.valueObserver.start()\n this.targetObserver.start()\n\n try {\n this.controller.connect()\n this.logDebugActivity(\"connect\")\n } catch (error: any) {\n this.handleError(error, \"connecting controller\")\n }\n }\n\n disconnect() {\n try {\n this.controller.disconnect()\n this.logDebugActivity(\"disconnect\")\n } catch (error: any) {\n this.handleError(error, \"disconnecting controller\")\n }\n\n this.targetObserver.stop()\n this.valueObserver.stop()\n this.bindingObserver.stop()\n }\n\n get application(): Application {\n return this.module.application\n }\n\n get identifier(): string {\n return this.module.identifier\n }\n\n get schema(): Schema {\n return this.application.schema\n }\n\n get dispatcher(): Dispatcher {\n return this.application.dispatcher\n }\n\n get element(): Element {\n return this.scope.element\n }\n\n get parentElement(): Element | null {\n return this.element.parentElement\n }\n\n // Error handling\n\n handleError(error: Error, message: string, detail: object = {}) {\n const { identifier, controller, element } = this\n detail = Object.assign({ identifier, controller, element }, detail)\n this.application.handleError(error, `Error ${message}`, detail)\n }\n\n // Debug logging\n\n logDebugActivity = (functionName: string, detail: object = {}): void => {\n const { identifier, controller, element } = this\n detail = Object.assign({ identifier, controller, element }, detail)\n this.application.logDebugActivity(this.identifier, functionName, detail)\n }\n\n // Target observer delegate\n\n targetConnected(element: Element, name: string) {\n this.invokeControllerMethod(`${name}TargetConnected`, element)\n }\n\n targetDisconnected(element: Element, name: string) {\n this.invokeControllerMethod(`${name}TargetDisconnected`, element)\n }\n\n // Private\n\n invokeControllerMethod(methodName: string, ...args: any[]) {\n const controller: any = this.controller\n if (typeof controller[methodName] == \"function\") {\n controller[methodName](...args)\n }\n }\n}\n","import { Constructor } from \"./constructor\"\n\nexport function readInheritableStaticArrayValues<T, U = string>(constructor: Constructor<T>, propertyName: string) {\n const ancestors = getAncestorsForConstructor(constructor)\n return Array.from(\n ancestors.reduce((values, constructor) => {\n getOwnStaticArrayValues(constructor, propertyName).forEach((name) => values.add(name))\n return values\n }, new Set() as Set<U>)\n )\n}\n\nexport function readInheritableStaticObjectPairs<T, U>(constructor: Constructor<T>, propertyName: string) {\n const ancestors = getAncestorsForConstructor(constructor)\n return ancestors.reduce((pairs, constructor) => {\n pairs.push(...(getOwnStaticObjectPairs(constructor, propertyName) as any))\n return pairs\n }, [] as [string, U][])\n}\n\nfunction getAncestorsForConstructor<T>(constructor: Constructor<T>) {\n const ancestors: Constructor<any>[] = []\n while (constructor) {\n ancestors.push(constructor)\n constructor = Object.getPrototypeOf(constructor)\n }\n return ancestors.reverse()\n}\n\nfunction getOwnStaticArrayValues<T>(constructor: Constructor<T>, propertyName: string) {\n const definition = (constructor as any)[propertyName]\n return Array.isArray(definition) ? definition : []\n}\n\nfunction getOwnStaticObjectPairs<T, U>(constructor: Constructor<T>, propertyName: string) {\n const definition = (constructor as any)[propertyName]\n return definition ? Object.keys(definition).map((key) => [key, definition[key]] as [string, U]) : []\n}\n","import { Constructor } from \"./constructor\"\nimport { readInheritableStaticArrayValues } from \"./inheritable_statics\"\n\nexport type Blessing<T> = (constructor: Constructor<T>) => PropertyDescriptorMap\n\nexport interface Blessable<T> extends Constructor<T> {\n readonly blessings?: Blessing<T>[]\n}\n\nexport function bless<T>(constructor: Blessable<T>): Constructor<T> {\n return shadow(constructor, getBlessedProperties(constructor))\n}\n\nfunction shadow<T>(constructor: Constructor<T>, properties: PropertyDescriptorMap) {\n const shadowConstructor = extend(constructor)\n const shadowProperties = getShadowProperties(constructor.prototype, properties)\n Object.defineProperties(shadowConstructor.prototype, shadowProperties)\n return shadowConstructor\n}\n\nfunction getBlessedProperties<T>(constructor: Constructor<T>) {\n const blessings = readInheritableStaticArrayValues(constructor, \"blessings\") as Blessing<T>[]\n return blessings.reduce((blessedProperties, blessing) => {\n const properties = blessing(constructor)\n for (const key in properties) {\n const descriptor = blessedProperties[key] || ({} as PropertyDescriptor)\n blessedProperties[key] = Object.assign(descriptor, properties[key])\n }\n return blessedProperties\n }, {} as PropertyDescriptorMap)\n}\n\nfunction getShadowProperties(prototype: any, properties: PropertyDescriptorMap) {\n return getOwnKeys(properties).reduce((shadowProperties, key) => {\n const descriptor = getShadowedDescriptor(prototype, properties, key)\n if (descriptor) {\n Object.assign(shadowProperties, { [key]: descriptor })\n }\n return shadowProperties\n }, {} as PropertyDescriptorMap)\n}\n\nfunction getShadowedDescriptor(prototype: any, properties: PropertyDescriptorMap, key: string | symbol) {\n const shadowingDescriptor = Object.getOwnPropertyDescriptor(prototype, key)\n const shadowedByValue = shadowingDescriptor && \"value\" in shadowingDescriptor\n if (!shadowedByValue) {\n const descriptor = Object.getOwnPropertyDescriptor(properties, key)!.value\n if (shadowingDescriptor) {\n descriptor.get = shadowingDescriptor.get || descriptor.get\n descriptor.set = shadowingDescriptor.set || descriptor.set\n }\n return descriptor\n }\n}\n\nconst getOwnKeys = (() => {\n if (typeof Object.getOwnPropertySymbols == \"function\") {\n return (object: any) => [...Object.getOwnPropertyNames(object), ...Object.getOwnPropertySymbols(object)]\n } else {\n return Object.getOwnPropertyNames\n }\n})()\n\nconst extend = (() => {\n function extendWithReflect<T extends Constructor<any>>(constructor: T): T {\n function extended() {\n return Reflect.construct(constructor, arguments, new.target)\n }\n\n extended.prototype = Object.create(constructor.prototype, {\n constructor: { value: extended },\n })\n\n Reflect.setPrototypeOf(extended, constructor)\n return extended as any\n }\n\n function testReflectExtension() {\n const a = function (this: any) {\n this.a.call(this)\n } as any\n const b = extendWithReflect(a)\n b.prototype.a = function () {}\n return new b()\n }\n\n try {\n testReflectExtension()\n return extendWithReflect\n } catch (error: any) {\n return <T extends Constructor<any>>(constructor: T) => class extended extends constructor {}\n }\n})()\n","import { Application } from \"./application\"\nimport { Context } from \"./context\"\nimport { ControllerConstructor } from \"./controller\"\nimport { Definition, blessDefinition } from \"./definition\"\nimport { Scope } from \"./scope\"\n\nexport class Module {\n readonly application: Application\n readonly definition: Definition\n private contextsByScope: WeakMap<Scope, Context>\n private connectedContexts: Set<Context>\n\n constructor(application: Application, definition: Definition) {\n this.application = application\n this.definition = blessDefinition(definition)\n this.contextsByScope = new WeakMap()\n this.connectedContexts = new Set()\n }\n\n get identifier(): string {\n return this.definition.identifier\n }\n\n get controllerConstructor(): ControllerConstructor {\n return this.definition.controllerConstructor\n }\n\n get contexts(): Context[] {\n return Array.from(this.connectedContexts)\n }\n\n connectContextForScope(scope: Scope) {\n const context = this.fetchContextForScope(scope)\n this.connectedContexts.add(context)\n context.connect()\n }\n\n disconnectContextForScope(scope: Scope) {\n const context = this.contextsByScope.get(scope)\n if (context) {\n this.connectedContexts.delete(context)\n context.disconnect()\n }\n }\n\n private fetchContextForScope(scope: Scope): Context {\n let context = this.contextsByScope.get(scope)\n if (!context) {\n context = new Context(this, scope)\n this.contextsByScope.set(scope, context)\n }\n return context\n }\n}\n","import { bless } from \"./blessing\"\nimport { ControllerConstructor } from \"./controller\"\n\nexport interface Definition {\n identifier: string\n controllerConstructor: ControllerConstructor\n}\n\nexport function blessDefinition(definition: Definition): Definition {\n return {\n identifier: definition.identifier,\n controllerConstructor: bless(definition.controllerConstructor),\n }\n}\n","import { Scope } from \"./scope\"\nimport { tokenize } from \"./string_helpers\"\n\nexport class ClassMap {\n readonly scope: Scope\n\n constructor(scope: Scope) {\n this.scope = scope\n }\n\n has(name: string) {\n return this.data.has(this.getDataKey(name))\n }\n\n get(name: string): string | undefined {\n return this.getAll(name)[0]\n }\n\n getAll(name: string) {\n const tokenString = this.data.get(this.getDataKey(name)) || \"\"\n return tokenize(tokenString)\n }\n\n getAttributeName(name: string) {\n return this.data.getAttributeNameForKey(this.getDataKey(name))\n }\n\n getDataKey(name: string) {\n return `${name}-class`\n }\n\n get data() {\n return this.scope.data\n }\n}\n","import { Scope } from \"./scope\"\nimport { dasherize } from \"./string_helpers\"\n\nexport class DataMap {\n readonly scope: Scope\n\n constructor(scope: Scope) {\n this.scope = scope\n }\n\n get element(): Element {\n return this.scope.element\n }\n\n get identifier(): string {\n return this.scope.identifier\n }\n\n get(key: string): string | null {\n const name = this.getAttributeNameForKey(key)\n return this.element.getAttribute(name)\n }\n\n set(key: string, value: string): string | null {\n const name = this.getAttributeNameForKey(key)\n this.element.setAttribute(name, value)\n return this.get(key)\n }\n\n has(key: string): boolean {\n const name = this.getAttributeNameForKey(key)\n return this.element.hasAttribute(name)\n }\n\n delete(key: string): boolean {\n if (this.has(key)) {\n const name = this.getAttributeNameForKey(key)\n this.element.removeAttribute(name)\n return true\n } else {\n return false\n }\n }\n\n getAttributeNameForKey(key: string): string {\n return `data-${this.identifier}-${dasherize(key)}`\n }\n}\n","import { Logger } from \"./logger\"\n\nexport class Guide {\n readonly logger: Logger\n readonly warnedKeysByObject: WeakMap<any, Set<string>> = new WeakMap()\n\n constructor(logger: Logger) {\n this.logger = logger\n }\n\n warn(object: any, key: string, message: string) {\n let warnedKeys: Set<string> | undefined = this.warnedKeysByObject.get(object)\n\n if (!warnedKeys) {\n warnedKeys = new Set()\n this.warnedKeysByObject.set(object, warnedKeys)\n }\n\n if (!warnedKeys.has(key)) {\n warnedKeys.add(key)\n this.logger.warn(message, object)\n }\n }\n}\n","export function attributeValueContainsToken(attributeName: string, token: string) {\n return `[${attributeName}~=\"${token}\"]`\n}\n","import { Scope } from \"./scope\"\nimport { attributeValueContainsToken } from \"./selectors\"\n\nexport class TargetSet {\n readonly scope: Scope\n\n constructor(scope: Scope) {\n this.scope = scope\n }\n\n get element() {\n return this.scope.element\n }\n\n get identifier() {\n return this.scope.identifier\n }\n\n get schema() {\n return this.scope.schema\n }\n\n has(targetName: string) {\n return this.find(targetName) != null\n }\n\n find(...targetNames: string[]) {\n return targetNames.reduce(\n (target, targetName) => target || this.findTarget(targetName) || this.findLegacyTarget(targetName),\n undefined as Element | undefined\n )\n }\n\n findAll(...targetNames: string[]) {\n return targetNames.reduce(\n (targets, targetName) => [\n ...targets,\n ...this.findAllTargets(targetName),\n ...this.findAllLegacyTargets(targetName),\n ],\n [] as Element[]\n )\n }\n\n private findTarget(targetName: string) {\n const selector = this.getSelectorForTargetName(targetName)\n return this.scope.findElement(selector)\n }\n\n private findAllTargets(targetName: string) {\n const selector = this.getSelectorForTargetName(targetName)\n return this.scope.findAllElements(selector)\n }\n\n private getSelectorForTargetName(targetName: string) {\n const attributeName = this.schema.targetAttributeForScope(this.identifier)\n return attributeValueContainsToken(attributeName, targetName)\n }\n\n private findLegacyTarget(targetName: string) {\n const selector = this.getLegacySelectorForTargetName(targetName)\n return this.deprecate(this.scope.findElement(selector), targetName)\n }\n\n private findAllLegacyTargets(targetName: string) {\n const selector = this.getLegacySelectorForTargetName(targetName)\n return this.scope.findAllElements(selector).map((element) => this.deprecate(element, targetName))\n }\n\n private getLegacySelectorForTargetName(targetName: string) {\n const targetDescriptor = `${this.identifier}.${targetName}`\n return attributeValueContainsToken(this.schema.targetAttribute, targetDescriptor)\n }\n\n private deprecate<T>(element: T, targetName: string) {\n if (element) {\n const { identifier } = this\n const attributeName = this.schema.targetAttribute\n const revisedAttributeName = this.schema.targetAttributeForScope(identifier)\n this.guide.warn(\n element,\n `target:${targetName}`,\n `Please replace ${attributeName}=\"${identifier}.${targetName}\" with ${revisedAttributeName}=\"${targetName}\". ` +\n `The ${attributeName} attribute is deprecated and will be removed in a future version of Stimulus.`\n )\n }\n return element\n }\n\n private get guide() {\n return this.scope.guide\n }\n}\n","import { ClassMap } from \"./class_map\"\nimport { DataMap } from \"./data_map\"\nimport { Guide } from \"./guide\"\nimport { Logger } from \"./logger\"\nimport { Schema } from \"./schema\"\nimport { attributeValueContainsToken } from \"./selectors\"\nimport { TargetSet } from \"./target_set\"\n\nexport class Scope {\n readonly schema: Schema\n readonly element: Element\n readonly identifier: string\n readonly guide: Guide\n readonly targets = new TargetSet(this)\n readonly classes = new ClassMap(this)\n readonly data = new DataMap(this)\n\n constructor(schema: Schema, element: Element, identifier: string, logger: Logger) {\n this.schema = schema\n this.element = element\n this.identifier = identifier\n this.guide = new Guide(logger)\n }\n\n findElement(selector: string): Element | undefined {\n return this.element.matches(selector) ? this.element : this.queryElements(selector).find(this.containsElement)\n }\n\n findAllElements(selector: string): Element[] {\n return [\n ...(this.element.matches(selector) ? [this.element] : []),\n ...this.queryElements(selector).filter(this.containsElement),\n ]\n }\n\n containsElement = (element: Element): boolean => {\n return element.closest(this.controllerSelector) === this.element\n }\n\n private queryElements(selector: string): Element[] {\n return Array.from(this.element.querySelectorAll(selector))\n }\n\n private get controllerSelector(): string {\n return attributeValueContainsToken(this.schema.controllerAttribute, this.identifier)\n }\n}\n","import { ErrorHandler } from \"./error_handler\"\nimport { Schema } from \"./schema\"\nimport { Scope } from \"./scope\"\nimport { Token, ValueListObserver, ValueListObserverDelegate } from \"../mutation-observers\"\n\nexport interface ScopeObserverDelegate extends ErrorHandler {\n createScopeForElementAndIdentifier(element: Element, identifier: string): Scope\n scopeConnected(scope: Scope): void\n scopeDisconnected(scope: Scope): void\n}\n\nexport class ScopeObserver implements ValueListObserverDelegate<Scope> {\n readonly element: Element\n readonly schema: Schema\n private delegate: ScopeObserverDelegate\n private valueListObserver: ValueListObserver<Scope>\n private scopesByIdentifierByElement: WeakMap<Element, Map<string, Scope>>\n private scopeReferenceCounts: WeakMap<Scope, number>\n\n constructor(element: Element, schema: Schema, delegate: ScopeObserverDelegate) {\n this.element = element\n this.schema = schema\n this.delegate = delegate\n this.valueListObserver = new ValueListObserver(this.element, this.controllerAttribute, this)\n this.scopesByIdentifierByElement = new WeakMap()\n this.scopeReferenceCounts = new WeakMap()\n }\n\n start() {\n this.valueListObserver.start()\n }\n\n stop() {\n this.valueListObserver.stop()\n }\n\n get controllerAttribute() {\n return this.schema.controllerAttribute\n }\n\n // Value observer delegate\n\n parseValueForToken(token: Token): Scope | undefined {\n const { element, content: identifier } = token\n const scopesByIdentifier = this.fetchScopesByIdentifierForElement(element)\n\n let scope = scopesByIdentifier.get(identifier)\n if (!scope) {\n scope = this.delegate.createScopeForElementAndIdentifier(element, identifier)\n scopesByIdentifier.set(identifier, scope)\n }\n\n return scope\n }\n\n elementMatchedValue(element: Element, value: Scope) {\n const referenceCount = (this.scopeReferenceCounts.get(value) || 0) + 1\n this.scopeReferenceCounts.set(value, referenceCount)\n if (referenceCount == 1) {\n this.delegate.scopeConnected(value)\n }\n }\n\n elementUnmatchedValue(element: Element, value: Scope) {\n const referenceCount = this.scopeReferenceCounts.get(value)\n if (referenceCount) {\n this.scopeReferenceCounts.set(value, referenceCount - 1)\n if (referenceCount == 1) {\n this.delegate.scopeDisconnected(value)\n }\n }\n }\n\n private fetchScopesByIdentifierForElement(element: Element) {\n let scopesByIdentifier = this.scopesByIdentifierByElement.get(element)\n if (!scopesByIdentifier) {\n scopesByIdentifier = new Map()\n this.scopesByIdentifierByElement.set(element, scopesByIdentifier)\n }\n return scopesByIdentifier\n }\n}\n","import { Application } from \"./application\"\nimport { Context } from \"./context\"\nimport { Definition } from \"./definition\"\nimport { Module } from \"./module\"\nimport { Multimap } from \"../multimap\"\nimport { Scope } from \"./scope\"\nimport { ScopeObserver, ScopeObserverDelegate } from \"./scope_observer\"\n\nexport class Router implements ScopeObserverDelegate {\n readonly application: Application\n private scopeObserver: ScopeObserver\n private scopesByIdentifier: Multimap<string, Scope>\n private modulesByIdentifier: Map<string, Module>\n\n constructor(application: Application) {\n this.application = application\n this.scopeObserver = new ScopeObserver(this.element, this.schema, this)\n this.scopesByIdentifier = new Multimap()\n this.modulesByIdentifier = new Map()\n }\n\n get element() {\n return this.application.element\n }\n\n get schema() {\n return this.application.schema\n }\n\n get logger() {\n return this.application.logger\n }\n\n get controllerAttribute(): string {\n return this.schema.controllerAttribute\n }\n\n get modules() {\n return Array.from(this.modulesByIdentifier.values())\n }\n\n get contexts() {\n return this.modules.reduce((contexts, module) => contexts.concat(module.contexts), [] as Context[])\n }\n\n start() {\n this.scopeObserver.start()\n }\n\n stop() {\n this.scopeObserver.stop()\n }\n\n loadDefinition(definition: Definition) {\n this.unloadIdentifier(definition.identifier)\n const module = new Module(this.application, definition)\n this.connectModule(module)\n }\n\n unloadIdentifier(identifier: string) {\n const module = this.modulesByIdentifier.get(identifier)\n if (module) {\n this.disconnectModule(module)\n }\n }\n\n getContextForElementAndIdentifier(element: Element, identifier: string) {\n const module = this.modulesByIdentifier.get(identifier)\n if (module) {\n return module.contexts.find((context) => context.element == element)\n }\n }\n\n // Error handler delegate\n\n handleError(error: Error, message: string, detail: any) {\n this.application.handleError(error, message, detail)\n }\n\n // Scope observer delegate\n\n createScopeForElementAndIdentifier(element: Element, identifier: string) {\n return new Scope(this.schema, element, identifier, this.logger)\n }\n\n scopeConnected(scope: Scope) {\n this.scopesByIdentifier.add(scope.identifier, scope)\n const module = this.modulesByIdentifier.get(scope.identifier)\n if (module) {\n module.connectContextForScope(scope)\n }\n }\n\n scopeDisconnected(scope: Scope) {\n this.scopesByIdentifier.delete(scope.identifier, scope)\n const module = this.modulesByIdentifier.get(scope.identifier)\n if (module) {\n module.disconnectContextForScope(scope)\n }\n }\n\n // Modules\n\n private connectModule(module: Module) {\n this.modulesByIdentifier.set(module.identifier, module)\n const scopes = this.scopesByIdentifier.getValuesForKey(module.identifier)\n scopes.forEach((scope) => module.connectContextForScope(scope))\n }\n\n private disconnectModule(module: Module) {\n this.modulesByIdentifier.delete(module.identifier)\n const scopes = this.scopesByIdentifier.getValuesForKey(module.identifier)\n scopes.forEach((scope) => module.disconnectContextForScope(scope))\n }\n}\n","export interface Schema {\n controllerAttribute: string\n actionAttribute: string\n targetAttribute: string\n targetAttributeForScope(identifier: string): string\n}\n\nexport const defaultSchema: Schema = {\n controllerAttribute: \"data-controller\",\n actionAttribute: \"data-action\",\n targetAttribute: \"data-target\",\n targetAttributeForScope: (identifier) => `data-${identifier}-target`,\n}\n","import { Controller, ControllerConstructor } from \"./controller\"\nimport { Definition } from \"./definition\"\nimport { Dispatcher } from \"./dispatcher\"\nimport { ErrorHandler } from \"./error_handler\"\nimport { Logger } from \"./logger\"\nimport { Router } from \"./router\"\nimport { Schema, defaultSchema } from \"./schema\"\nimport { ActionDescriptorFilter, ActionDescriptorFilters, defaultActionDescriptorFilters } from \"./action_descriptor\"\n\nexport class Application implements ErrorHandler {\n readonly element: Element\n readonly schema: Schema\n readonly dispatcher: Dispatcher\n readonly router: Router\n readonly actionDescriptorFilters: ActionDescriptorFilters\n logger: Logger = console\n debug = false\n\n static start(element?: Element, schema?: Schema): Application {\n const application = new Application(element, schema)\n application.start()\n return application\n }\n\n constructor(element: Element = document.documentElement, schema: Schema = defaultSchema) {\n this.element = element\n this.schema = schema\n this.dispatcher = new Dispatcher(this)\n this.router = new Router(this)\n this.actionDescriptorFilters = { ...defaultActionDescriptorFilters }\n }\n\n async start() {\n await domReady()\n this.logDebugActivity(\"application\", \"starting\")\n this.dispatcher.start()\n this.router.start()\n this.logDebugActivity(\"application\", \"start\")\n }\n\n stop() {\n this.logDebugActivity(\"application\", \"stopping\")\n this.dispatcher.stop()\n this.router.stop()\n this.logDebugActivity(\"application\", \"stop\")\n }\n\n register(identifier: string, controllerConstructor: ControllerConstructor) {\n this.load({ identifier, controllerConstructor })\n }\n\n registerActionOption(name: string, filter: ActionDescriptorFilter) {\n this.actionDescriptorFilters[name] = filter\n }\n\n load(...definitions: Definition[]): void\n load(definitions: Definition[]): void\n load(head: Definition | Definition[], ...rest: Definition[]) {\n const definitions = Array.isArray(head) ? head : [head, ...rest]\n definitions.forEach((definition) => {\n if ((definition.controllerConstructor as any).shouldLoad) {\n this.router.loadDefinition(definition)\n }\n })\n }\n\n unload(...identifiers: string[]): void\n unload(identifiers: string[]): void\n unload(head: string | string[], ...rest: string[]) {\n const identifiers = Array.isArray(head) ? head : [head, ...rest]\n identifiers.forEach((identifier) => this.router.unloadIdentifier(identifier))\n }\n\n // Controllers\n\n get controllers(): Controller[] {\n return this.router.contexts.map((context) => context.controller)\n }\n\n getControllerForElementAndIdentifier(element: Element, identifier: string): Controller | null {\n const context = this.router.getContextForElementAndIdentifier(element, identifier)\n return context ? context.controller : null\n }\n\n // Error handling\n\n handleError(error: Error, message: string, detail: object) {\n this.logger.error(`%s\\n\\n%o\\n\\n%o`, message, error, detail)\n\n window.onerror?.(message, \"\", 0, 0, error)\n }\n\n // Debug logging\n\n logDebugActivity = (identifier: string, functionName: string, detail: object = {}): void => {\n if (this.debug) {\n this.logFormattedMessage(identifier, functionName, detail)\n }\n }\n\n private logFormattedMessage(identifier: string, functionName: string, detail: object = {}) {\n detail = Object.assign({ application: this }, detail)\n\n this.logger.groupCollapsed(`${identifier} #${functionName}`)\n this.logger.log(\"details:\", { ...detail })\n this.logger.groupEnd()\n }\n}\n\nfunction domReady() {\n return new Promise<void>((resolve) => {\n if (document.readyState == \"loading\") {\n document.addEventListener(\"DOMContentLoaded\", () => resolve())\n } else {\n resolve()\n }\n })\n}\n","import { Constructor } from \"./constructor\"\nimport { Controller } from \"./controller\"\nimport { readInheritableStaticObjectPairs } from \"./inheritable_statics\"\nimport { camelize, capitalize, dasherize } from \"./string_helpers\"\n\nexport function ValuePropertiesBlessing<T>(constructor: Constructor<T>) {\n const valueDefinitionPairs = readInheritableStaticObjectPairs<T, ValueTypeDefinition>(constructor, \"values\")\n const propertyDescriptorMap: PropertyDescriptorMap = {\n valueDescriptorMap: {\n get(this: Controller) {\n return valueDefinitionPairs.reduce((result, valueDefinitionPair) => {\n const valueDescriptor = parseValueDefinitionPair(valueDefinitionPair, this.identifier)\n const attributeName = this.data.getAttributeNameForKey(valueDescriptor.key)\n return Object.assign(result, { [attributeName]: valueDescriptor })\n }, {} as ValueDescriptorMap)\n },\n },\n }\n\n return valueDefinitionPairs.reduce((properties, valueDefinitionPair) => {\n return Object.assign(properties, propertiesForValueDefinitionPair(valueDefinitionPair))\n }, propertyDescriptorMap)\n}\n\nexport function propertiesForValueDefinitionPair<T>(\n valueDefinitionPair: ValueDefinitionPair,\n controller?: string\n): PropertyDescriptorMap {\n const definition = parseValueDefinitionPair(valueDefinitionPair, controller)\n const { key, name, reader: read, writer: write } = definition\n\n return {\n [name]: {\n get(this: Controller) {\n const value = this.data.get(key)\n if (value !== null) {\n return read(value)\n } else {\n return definition.defaultValue\n }\n },\n\n set(this: Controller, value: T | undefined) {\n if (value === undefined) {\n this.data.delete(key)\n } else {\n this.data.set(key, write(value))\n }\n },\n },\n\n [`has${capitalize(name)}`]: {\n get(this: Controller): boolean {\n return this.data.has(key) || definition.hasCustomDefaultValue\n },\n },\n }\n}\n\nexport type ValueDescriptor = {\n type: ValueType\n key: string\n name: string\n defaultValue: ValueTypeDefault\n hasCustomDefaultValue: boolean\n reader: Reader\n writer: Writer\n}\n\nexport type ValueDescriptorMap = { [attributeName: string]: ValueDescriptor }\n\nexport type ValueDefinitionMap = { [token: string]: ValueTypeDefinition }\n\nexport type ValueDefinitionPair = [string, ValueTypeDefinition]\n\nexport type ValueTypeConstant = typeof Array | typeof Boolean | typeof Number | typeof Object | typeof String\n\nexport type ValueTypeDefault = Array<any> | boolean | number | Object | string\n\nexport type ValueTypeObject = { type: ValueTypeConstant; default: ValueTypeDefault }\n\nexport type ValueTypeDefinition = ValueTypeConstant | ValueTypeDefault | ValueTypeObject\n\nexport type ValueType = \"array\" | \"boolean\" | \"number\" | \"object\" | \"string\"\n\nfunction parseValueDefinitionPair([token, typeDefinition]: ValueDefinitionPair, controller?: string): ValueDescriptor {\n return valueDescriptorForTokenAndTypeDefinition({\n controller,\n token,\n typeDefinition,\n })\n}\n\nfunction parseValueTypeConstant(constant: ValueTypeConstant) {\n switch (constant) {\n case Array:\n return \"array\"\n case Boolean:\n return \"boolean\"\n case Number:\n return \"number\"\n case Object:\n return \"object\"\n case String:\n return \"string\"\n }\n}\n\nfunction parseValueTypeDefault(defaultValue: ValueTypeDefault) {\n switch (typeof defaultValue) {\n case \"boolean\":\n return \"boolean\"\n case \"number\":\n return \"number\"\n case \"string\":\n return \"string\"\n }\n\n if (Array.isArray(defaultValue)) return \"array\"\n if (Object.prototype.toString.call(defaultValue) === \"[object Object]\") return \"object\"\n}\n\nfunction parseValueTypeObject(payload: { controller?: string; token: string; typeObject: ValueTypeObject }) {\n const typeFromObject = parseValueTypeConstant(payload.typeObject.type)\n\n if (!typeFromObject) return\n\n const defaultValueType = parseValueTypeDefault(payload.typeObject.default)\n\n if (typeFromObject !== defaultValueType) {\n const propertyPath = payload.controller ? `${payload.controller}.${payload.token}` : payload.token\n\n throw new Error(\n `The specified default value for the Stimulus Value \"${propertyPath}\" must match the defined type \"${typeFromObject}\". The provided default value of \"${payload.typeObject.default}\" is of type \"${defaultValueType}\".`\n )\n }\n\n return typeFromObject\n}\n\nfunction parseValueTypeDefinition(payload: {\n controller?: string\n token: string\n typeDefinition: ValueTypeDefinition\n}): ValueType {\n const typeFromObject = parseValueTypeObject({\n controller: payload.controller,\n token: payload.token,\n typeObject: payload.typeDefinition as ValueTypeObject,\n })\n const typeFromDefaultValue = parseValueTypeDefault(payload.typeDefinition as ValueTypeDefault)\n const typeFromConstant = parseValueTypeConstant(payload.typeDefinition as ValueTypeConstant)\n\n const type = typeFromObject || typeFromDefaultValue || typeFromConstant\n\n if (type) return type\n\n const propertyPath = payload.controller ? `${payload.controller}.${payload.typeDefinition}` : payload.token\n\n throw new Error(`Unknown value type \"${propertyPath}\" for \"${payload.token}\" value`)\n}\n\nfunction defaultValueForDefinition(typeDefinition: ValueTypeDefinition): ValueTypeDefault {\n const constant = parseValueTypeConstant(typeDefinition as ValueTypeConstant)\n\n if (constant) return defaultValuesByType[constant]\n\n const defaultValue = (typeDefinition as ValueTypeObject).default\n if (defaultValue !== undefined) return defaultValue\n\n return typeDefinition\n}\n\nfunction valueDescriptorForTokenAndTypeDefinition(payload: {\n token: string\n typeDefinition: ValueTypeDefinition\n controller?: string\n}) {\n const key = `${dasherize(payload.token)}-value`\n const type = parseValueTypeDefinition(payload)\n return {\n type,\n key,\n name: camelize(key),\n get defaultValue() {\n return defaultValueForDefinition(payload.typeDefinition)\n },\n get hasCustomDefaultValue() {\n return parseValueTypeDefault(payload.typeDefinition) !== undefined\n },\n reader: readers[type],\n writer: writers[type] || writers.default,\n }\n}\n\nconst defaultValuesByType = {\n get array() {\n return []\n },\n boolean: false,\n number: 0,\n get object() {\n return {}\n },\n string: \"\",\n}\n\ntype Reader = (value: string) => any\n\nconst readers: { [type: string]: Reader } = {\n array(value: string): any[] {\n const array = JSON.parse(value)\n if (!Array.isArray(array)) {\n throw new TypeError(\n `expected value of type \"array\" but instead got value \"${value}\" of type \"${parseValueTypeDefault(array)}\"`\n )\n }\n return array\n },\n\n boolean(value: string): boolean {\n return !(value == \"0\" || String(value).toLowerCase() == \"false\")\n },\n\n number(value: string): number {\n return Number(value)\n },\n\n object(value: string): object {\n const object = JSON.parse(value)\n if (object === null || typeof object != \"object\" || Array.isArray(object)) {\n throw new TypeError(\n `expected value of type \"object\" but instead got value \"${value}\" of type \"${parseValueTypeDefault(object)}\"`\n )\n }\n return object\n },\n\n string(value: string): string {\n return value\n },\n}\n\ntype Writer = (value: any) => string\n\nconst writers: { [type: string]: Writer } = {\n default: writeString,\n array: writeJSON,\n object: writeJSON,\n}\n\nfunction writeJSON(value: any) {\n return JSON.stringify(value)\n}\n\nfunction writeString(value: any) {\n return `${value}`\n}\n","import { ClassPropertiesBlessing } from \"./class_properties\"\nimport { Constructor } from \"./constructor\"\nimport { Context } from \"./context\"\nimport { TargetPropertiesBlessing } from \"./target_properties\"\nimport { ValuePropertiesBlessing, ValueDefinitionMap } from \"./value_properties\"\n\nexport type ControllerConstructor = Constructor<Controller>\n\nexport class Controller<ElementType extends Element = Element> {\n static blessings = [ClassPropertiesBlessing, TargetPropertiesBlessing, ValuePropertiesBlessing]\n static targets: string[] = []\n static values: ValueDefinitionMap = {}\n\n static get shouldLoad() {\n return true\n }\n\n readonly context: Context\n\n constructor(context: Context) {\n this.context = context\n }\n\n get application() {\n return this.context.application\n }\n\n get scope() {\n return this.context.scope\n }\n\n get element() {\n return this.scope.element as ElementType\n }\n\n get identifier() {\n return this.scope.identifier\n }\n\n get targets() {\n return this.scope.targets\n }\n\n get classes() {\n return this.scope.classes\n }\n\n get data() {\n return this.scope.data\n }\n\n initialize() {\n // Override in your subclass to set up initial controller state\n }\n\n connect() {\n // Override in your subclass to respond when the controller is connected to the DOM\n }\n\n disconnect() {\n // Override in your subclass to respond when the controller is disconnected from the DOM\n }\n\n dispatch(\n eventName: string,\n { target = this.element, detail = {}, prefix = this.identifier, bubbles = true, cancelable = true } = {}\n ) {\n const type = prefix ? `${prefix}:${eventName}` : eventName\n const event = new CustomEvent(type, { detail, bubbles, cancelable })\n target.dispatchEvent(event)\n return event\n }\n}\n","import { Constructor } from \"./constructor\"\nimport { Controller } from \"./controller\"\nimport { readInheritableStaticArrayValues } from \"./inheritable_statics\"\nimport { capitalize } from \"./string_helpers\"\n\nexport function ClassPropertiesBlessing<T>(constructor: Constructor<T>) {\n const classes = readInheritableStaticArrayValues(constructor, \"classes\")\n return classes.reduce((properties, classDefinition) => {\n return Object.assign(properties, propertiesForClassDefinition(classDefinition))\n }, {} as PropertyDescriptorMap)\n}\n\nfunction propertiesForClassDefinition(key: string) {\n return {\n [`${key}Class`]: {\n get(this: Controller) {\n const { classes } = this\n if (classes.has(key)) {\n return classes.get(key)\n } else {\n const attribute = classes.getAttributeName(key)\n throw new Error(`Missing attribute \"${attribute}\"`)\n }\n },\n },\n\n [`${key}Classes`]: {\n get(this: Controller) {\n return this.classes.getAll(key)\n },\n },\n\n [`has${capitalize(key)}Class`]: {\n get(this: Controller) {\n return this.classes.has(key)\n },\n },\n }\n}\n","import { Constructor } from \"./constructor\"\nimport { Controller } from \"./controller\"\nimport { readInheritableStaticArrayValues } from \"./inheritable_statics\"\nimport { capitalize } from \"./string_helpers\"\n\nexport function TargetPropertiesBlessing<T>(constructor: Constructor<T>) {\n const targets = readInheritableStaticArrayValues(constructor, \"targets\")\n return targets.reduce((properties, targetDefinition) => {\n return Object.assign(properties, propertiesForTargetDefinition(targetDefinition))\n }, {} as PropertyDescriptorMap)\n}\n\nfunction propertiesForTargetDefinition(name: string) {\n return {\n [`${name}Target`]: {\n get(this: Controller) {\n const target = this.targets.find(name)\n if (target) {\n return target\n } else {\n throw new Error(`Missing target element \"${name}\" for \"${this.identifier}\" controller`)\n }\n },\n },\n\n [`${name}Targets`]: {\n get(this: Controller) {\n return this.targets.findAll(name)\n },\n },\n\n [`has${capitalize(name)}Target`]: {\n get(this: Controller) {\n return this.targets.has(name)\n },\n },\n }\n}\n"],"names":["EventListener","constructor","eventTarget","eventName","eventOptions","this","unorderedBindings","Set","connect","addEventListener","disconnect","removeEventListener","bindingConnected","binding","add","bindingDisconnected","delete","handleEvent","event","extendedEvent","stopImmediatePropagation","Object","assign","immediatePropagationStopped","call","extendEvent","bindings","hasBindings","size","Array","from","sort","left","right","leftIndex","index","rightIndex","Dispatcher","application","eventListenerMaps","Map","started","start","eventListeners","forEach","eventListener","stop","values","reduce","listeners","map","concat","fetchEventListenerForBinding","clearEventListeners","clearEventListenersForBinding","handleError","error","message","detail","removeMappedEventListenerFor","eventListenerMap","fetchEventListenerMapForEventTarget","cacheKey","fetchEventListener","get","createEventListener","set","parts","keys","key","push","join","defaultActionDescriptorFilters","value","stopPropagation","prevent","preventDefault","self","element","target","descriptorPattern","parseEventTarget","eventTargetName","window","document","camelize","replace","_","char","toUpperCase","capitalize","charAt","slice","dasherize","toLowerCase","defaultEventNames","a","button","form","details","input","e","getAttribute","select","textarea","Error","typecast","JSON","parse","o_O","Binding","context","action","identifier","willBeInvokedByEvent","applyEventModifiers","invokeWithEvent","method","controller","methodName","actionDescriptorFilters","passes","name","entries","filter","currentTarget","params","actionEvent","logDebugActivity","Element","contains","scope","containsElement","ElementObserver","delegate","attributes","childList","subtree","elements","mutationObserver","MutationObserver","mutations","processMutations","observe","mutationObserverInit","refresh","pause","callback","takeRecords","matches","matchElementsInTree","has","removeElement","addElement","mutation","processMutation","type","processAttributeChange","attributeName","processRemovedNodes","removedNodes","processAddedNodes","addedNodes","node","elementAttributeChanged","matchElement","nodes","elementFromNode","processTree","elementIsActive","tree","processor","nodeType","Node","ELEMENT_NODE","isConnected","elementMatched","elementUnmatched","AttributeObserver","elementObserver","selector","hasAttribute","match","querySelectorAll","elementMatchedAttribute","elementUnmatchedAttribute","elementAttributeValueChanged","StringMapObserver","stringMap","attributeOldValue","knownAttributeNames","refreshAttribute","oldValue","getStringMapKeyForAttribute","stringMapKeyAdded","stringMapValueChanged","stringMapKeyRemoved","currentAttributeNames","recordedAttributeNames","attribute","fetch","del","prune","Multimap","valuesByKey","hasKey","hasValue","some","getValuesForKey","getKeysForValue","_key","_values","IndexedMultimap","super","keysByValue","TokenListObserver","attributeObserver","tokensByElement","tokensMatched","readTokensForElement","unmatchedTokens","matchedTokens","refreshTokensForElement","tokensUnmatched","tokens","token","tokenMatched","tokenUnmatched","previousTokens","currentTokens","firstDifferingIndex","length","Math","max","zip","findIndex","previousToken","currentToken","content","tokenString","trim","split","parseTokenString","ValueListObserver","tokenListObserver","parseResultsByToken","WeakMap","valuesByTokenByElement","fetchParseResultForToken","fetchValuesByTokenForElement","elementMatchedValue","elementUnmatchedValue","parseResult","parseToken","valuesByToken","parseValueForToken","BindingObserver","bindingsByAction","valueListObserver","actionAttribute","disconnectAllActions","schema","connectAction","disconnectAction","clear","descriptor","tagName","getDefaultEventNameForElement","forToken","descriptorString","options","test","parseActionDescriptorString","toString","eventNameSuffix","pattern","RegExp","ValueObserver","receiver","stringMapObserver","valueDescriptorMap","invokeChangedCallbacksForDefaultValues","invokeChangedCallback","writer","defaultValue","valueDescriptorNameMap","valueDescriptors","undefined","data","rawValue","rawOldValue","changedMethodName","changedMethod","reader","TypeError","descriptors","hasMethodName","TargetObserver","targetsByName","disconnectAllTargets","connectTarget","disconnectTarget","targetConnected","targetDisconnected","Context","module","functionName","controllerConstructor","bindingObserver","dispatcher","valueObserver","targetObserver","initialize","parentElement","invokeControllerMethod","args","readInheritableStaticArrayValues","propertyName","ancestors","getAncestorsForConstructor","definition","isArray","getOwnStaticArrayValues","readInheritableStaticObjectPairs","pairs","getOwnStaticObjectPairs","getPrototypeOf","reverse","bless","properties","shadowConstructor","extend","shadowProperties","prototype","getOwnKeys","shadowingDescriptor","getOwnPropertyDescriptor","getShadowedDescriptor","getShadowProperties","defineProperties","shadow","blessedProperties","blessing","getBlessedProperties","getOwnPropertySymbols","object","getOwnPropertyNames","extendWithReflect","extended","Reflect","construct","arguments","create","setPrototypeOf","b","testReflectExtension","Module","blessDefinition","contextsByScope","connectedContexts","contexts","connectContextForScope","fetchContextForScope","disconnectContextForScope","ClassMap","getDataKey","getAll","getAttributeName","getAttributeNameForKey","DataMap","setAttribute","removeAttribute","Guide","logger","warn","warnedKeys","warnedKeysByObject","attributeValueContainsToken","TargetSet","targetName","find","targetNames","findTarget","findLegacyTarget","findAll","targets","findAllTargets","findAllLegacyTargets","getSelectorForTargetName","findElement","findAllElements","targetAttributeForScope","getLegacySelectorForTargetName","deprecate","targetDescriptor","targetAttribute","revisedAttributeName","guide","Scope","closest","controllerSelector","queryElements","controllerAttribute","ScopeObserver","scopesByIdentifierByElement","scopeReferenceCounts","scopesByIdentifier","fetchScopesByIdentifierForElement","createScopeForElementAndIdentifier","referenceCount","scopeConnected","scopeDisconnected","Router","scopeObserver","modulesByIdentifier","modules","loadDefinition","unloadIdentifier","connectModule","disconnectModule","getContextForElementAndIdentifier","defaultSchema","Application","documentElement","console","debug","logFormattedMessage","router","Promise","resolve","readyState","register","load","registerActionOption","head","rest","shouldLoad","unload","controllers","getControllerForElementAndIdentifier","onerror","groupCollapsed","log","groupEnd","parseValueDefinitionPair","typeDefinition","payload","typeFromObject","parseValueTypeConstant","typeObject","defaultValueType","parseValueTypeDefault","default","propertyPath","parseValueTypeObject","typeFromDefaultValue","typeFromConstant","parseValueTypeDefinition","constant","defaultValuesByType","defaultValueForDefinition","hasCustomDefaultValue","readers","writers","valueDescriptorForTokenAndTypeDefinition","Boolean","Number","String","array","boolean","number","string","writeJSON","stringify","Controller","classes","dispatch","prefix","bubbles","cancelable","CustomEvent","dispatchEvent","classDefinition","targetDefinition","valueDefinitionPairs","propertyDescriptorMap","result","valueDefinitionPair","valueDescriptor","read","write","propertiesForValueDefinitionPair"],"mappings":"MAEaA,EAMXC,YAAYC,EAA0BC,EAAmBC,GACvDC,KAAKH,YAAcA,EACnBG,KAAKF,UAAYA,EACjBE,KAAKD,aAAeA,EACpBC,KAAKC,kBAAoB,IAAIC,IAG/BC,UACEH,KAAKH,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YAAgB,CAChC1D,MACE,OAAO3D,KAAK4X,QAAQ1O,IAAI7B,OArBhC,IAAuCA,IAHlC,cHJsCzH,GACzC,MAAMme,EAAuBjK,EAAyDlU,EAAa,UAC7Foe,EAA+C,CACnD7M,mBAAoB,CAClBxN,MACE,OAAOoa,EAAqBpb,QAAO,CAACsb,EAAQC,KAC1C,MAAMC,EAAkB5C,EAAyB2C,EAAqBle,KAAK4G,YACrE6C,EAAgBzJ,KAAK2R,KAAKgF,uBAAuBwH,EAAgBna,KACvE,OAAOhD,OAAOC,OAAOgd,EAAQ,CAAExU,CAACA,GAAgB0U,MAC/C,OAKT,OAAOJ,EAAqBpb,QAAO,CAACyR,EAAY8J,IACvCld,OAAOC,OAAOmT,WAKvB8J,EACAjX,GAEA,MAAM0M,EAAa4H,EAAyB2C,EAAqBjX,IAC3DjD,IAAEA,EAAGqD,KAAEA,EAAM2K,OAAQoM,EAAM9M,OAAQ+M,GAAU1K,EAEnD,MAAO,CACLtM,CAACA,GAAO,CACN1D,MACE,MAAMS,EAAQpE,KAAK2R,KAAKhO,IAAIK,GAC5B,OAAc,OAAVI,EACKga,EAAKha,GAELuP,EAAWpC,cAItB1N,IAAsBO,QACNsN,IAAVtN,EACFpE,KAAK2R,KAAKhR,OAAOqD,GAEjBhE,KAAK2R,KAAK9N,IAAIG,EAAKqa,EAAMja,MAK/B,CAAC,MAAMiB,EAAWgC,MAAU,CAC1B1D,MACE,OAAO3D,KAAK2R,KAAKzI,IAAIlF,IAAQ2P,EAAW6I,yBAjCX8B,CAAiCJ,KACjEF,KCXIX,UAAoB,GACpBA,SAA6B"}
1
+ {"version":3,"file":"stimulus.min.js","sources":["../src/core/event_listener.ts","../src/core/dispatcher.ts","../src/core/action_descriptor.ts","../src/core/string_helpers.ts","../src/core/action.ts","../src/core/binding.ts","../src/mutation-observers/element_observer.ts","../src/mutation-observers/attribute_observer.ts","../src/multimap/set_operations.ts","../src/multimap/multimap.ts","../src/multimap/indexed_multimap.ts","../src/mutation-observers/selector_observer.ts","../src/mutation-observers/string_map_observer.ts","../src/mutation-observers/token_list_observer.ts","../src/mutation-observers/value_list_observer.ts","../src/core/binding_observer.ts","../src/core/value_observer.ts","../src/core/target_observer.ts","../src/core/inheritable_statics.ts","../src/core/outlet_observer.ts","../src/core/context.ts","../src/core/blessing.ts","../src/core/module.ts","../src/core/definition.ts","../src/core/class_map.ts","../src/core/data_map.ts","../src/core/guide.ts","../src/core/selectors.ts","../src/core/target_set.ts","../src/core/outlet_set.ts","../src/core/scope.ts","../src/core/scope_observer.ts","../src/core/router.ts","../src/core/schema.ts","../src/core/application.ts","../src/core/value_properties.ts","../src/core/controller.ts","../src/core/class_properties.ts","../src/core/target_properties.ts","../src/core/outlet_properties.ts"],"sourcesContent":["import { Binding } from \"./binding\"\n\nexport class EventListener implements EventListenerObject {\n readonly eventTarget: EventTarget\n readonly eventName: string\n readonly eventOptions: AddEventListenerOptions\n private unorderedBindings: Set<Binding>\n\n constructor(eventTarget: EventTarget, eventName: string, eventOptions: AddEventListenerOptions) {\n this.eventTarget = eventTarget\n this.eventName = eventName\n this.eventOptions = eventOptions\n this.unorderedBindings = new Set()\n }\n\n connect() {\n this.eventTarget.addEventListener(this.eventName, this, this.eventOptions)\n }\n\n disconnect() {\n this.eventTarget.removeEventListener(this.eventName, this, this.eventOptions)\n }\n\n // Binding observer delegate\n\n bindingConnected(binding: Binding) {\n this.unorderedBindings.add(binding)\n }\n\n bindingDisconnected(binding: Binding) {\n this.unorderedBindings.delete(binding)\n }\n\n handleEvent(event: Event) {\n // FIXME: Determine why TS won't recognize that the extended event has immediatePropagationStopped\n const extendedEvent = extendEvent(event) as any\n for (const binding of this.bindings) {\n if (extendedEvent.immediatePropagationStopped) {\n break\n } else {\n binding.handleEvent(extendedEvent)\n }\n }\n }\n\n hasBindings() {\n return this.unorderedBindings.size > 0\n }\n\n get bindings(): Binding[] {\n return Array.from(this.unorderedBindings).sort((left, right) => {\n const leftIndex = left.index,\n rightIndex = right.index\n return leftIndex < rightIndex ? -1 : leftIndex > rightIndex ? 1 : 0\n })\n }\n}\n\nfunction extendEvent(event: Event) {\n if (\"immediatePropagationStopped\" in event) {\n return event\n } else {\n const { stopImmediatePropagation } = event\n return Object.assign(event, {\n immediatePropagationStopped: false,\n stopImmediatePropagation() {\n this.immediatePropagationStopped = true\n stopImmediatePropagation.call(this)\n },\n })\n }\n}\n","import { Application } from \"./application\"\nimport { Binding } from \"./binding\"\nimport { BindingObserverDelegate } from \"./binding_observer\"\nimport { EventListener } from \"./event_listener\"\n\nexport class Dispatcher implements BindingObserverDelegate {\n readonly application: Application\n private eventListenerMaps: Map<EventTarget, Map<string, EventListener>>\n private started: boolean\n\n constructor(application: Application) {\n this.application = application\n this.eventListenerMaps = new Map()\n this.started = false\n }\n\n start() {\n if (!this.started) {\n this.started = true\n this.eventListeners.forEach((eventListener) => eventListener.connect())\n }\n }\n\n stop() {\n if (this.started) {\n this.started = false\n this.eventListeners.forEach((eventListener) => eventListener.disconnect())\n }\n }\n\n get eventListeners(): EventListener[] {\n return Array.from(this.eventListenerMaps.values()).reduce(\n (listeners, map) => listeners.concat(Array.from(map.values())),\n [] as EventListener[]\n )\n }\n\n // Binding observer delegate\n\n bindingConnected(binding: Binding) {\n this.fetchEventListenerForBinding(binding).bindingConnected(binding)\n }\n\n bindingDisconnected(binding: Binding, clearEventListeners = false) {\n this.fetchEventListenerForBinding(binding).bindingDisconnected(binding)\n if (clearEventListeners) this.clearEventListenersForBinding(binding)\n }\n\n // Error handling\n\n handleError(error: Error, message: string, detail: object = {}) {\n this.application.handleError(error, `Error ${message}`, detail)\n }\n\n private clearEventListenersForBinding(binding: Binding) {\n const eventListener = this.fetchEventListenerForBinding(binding)\n if (!eventListener.hasBindings()) {\n eventListener.disconnect()\n this.removeMappedEventListenerFor(binding)\n }\n }\n\n private removeMappedEventListenerFor(binding: Binding) {\n const { eventTarget, eventName, eventOptions } = binding\n const eventListenerMap = this.fetchEventListenerMapForEventTarget(eventTarget)\n const cacheKey = this.cacheKey(eventName, eventOptions)\n\n eventListenerMap.delete(cacheKey)\n if (eventListenerMap.size == 0) this.eventListenerMaps.delete(eventTarget)\n }\n\n private fetchEventListenerForBinding(binding: Binding): EventListener {\n const { eventTarget, eventName, eventOptions } = binding\n return this.fetchEventListener(eventTarget, eventName, eventOptions)\n }\n\n private fetchEventListener(\n eventTarget: EventTarget,\n eventName: string,\n eventOptions: AddEventListenerOptions\n ): EventListener {\n const eventListenerMap = this.fetchEventListenerMapForEventTarget(eventTarget)\n const cacheKey = this.cacheKey(eventName, eventOptions)\n let eventListener = eventListenerMap.get(cacheKey)\n if (!eventListener) {\n eventListener = this.createEventListener(eventTarget, eventName, eventOptions)\n eventListenerMap.set(cacheKey, eventListener)\n }\n return eventListener\n }\n\n private createEventListener(\n eventTarget: EventTarget,\n eventName: string,\n eventOptions: AddEventListenerOptions\n ): EventListener {\n const eventListener = new EventListener(eventTarget, eventName, eventOptions)\n if (this.started) {\n eventListener.connect()\n }\n return eventListener\n }\n\n private fetchEventListenerMapForEventTarget(eventTarget: EventTarget): Map<string, EventListener> {\n let eventListenerMap = this.eventListenerMaps.get(eventTarget)\n if (!eventListenerMap) {\n eventListenerMap = new Map()\n this.eventListenerMaps.set(eventTarget, eventListenerMap)\n }\n return eventListenerMap\n }\n\n private cacheKey(eventName: string, eventOptions: any): string {\n const parts = [eventName]\n Object.keys(eventOptions)\n .sort()\n .forEach((key) => {\n parts.push(`${eventOptions[key] ? \"\" : \"!\"}${key}`)\n })\n return parts.join(\":\")\n }\n}\n","export type ActionDescriptorFilters = Record<string, ActionDescriptorFilter>\nexport type ActionDescriptorFilter = (options: ActionDescriptorFilterOptions) => boolean\ntype ActionDescriptorFilterOptions = {\n name: string\n value: boolean\n event: Event\n element: Element\n}\n\nexport const defaultActionDescriptorFilters: ActionDescriptorFilters = {\n stop({ event, value }) {\n if (value) event.stopPropagation()\n\n return true\n },\n\n prevent({ event, value }) {\n if (value) event.preventDefault()\n\n return true\n },\n\n self({ event, value, element }) {\n if (value) {\n return element === event.target\n } else {\n return true\n }\n },\n}\n\nexport interface ActionDescriptor {\n eventTarget: EventTarget\n eventOptions: AddEventListenerOptions\n eventName: string\n identifier: string\n methodName: string\n keyFilter: string\n}\n\n// capture nos.: 1 1 2 2 3 3 4 4 5 5 6 6\nconst descriptorPattern = /^(?:(.+?)(?:\\.(.+?))?(?:@(window|document))?->)?(.+?)(?:#([^:]+?))(?::(.+))?$/\n\nexport function parseActionDescriptorString(descriptorString: string): Partial<ActionDescriptor> {\n const source = descriptorString.trim()\n const matches = source.match(descriptorPattern) || []\n let eventName = matches[1]\n let keyFilter = matches[2]\n\n if (keyFilter && ![\"keydown\", \"keyup\", \"keypress\"].includes(eventName)) {\n eventName += `.${keyFilter}`\n keyFilter = \"\"\n }\n\n return {\n eventTarget: parseEventTarget(matches[3]),\n eventName,\n eventOptions: matches[6] ? parseEventOptions(matches[6]) : {},\n identifier: matches[4],\n methodName: matches[5],\n keyFilter,\n }\n}\n\nfunction parseEventTarget(eventTargetName: string): EventTarget | undefined {\n if (eventTargetName == \"window\") {\n return window\n } else if (eventTargetName == \"document\") {\n return document\n }\n}\n\nfunction parseEventOptions(eventOptions: string): AddEventListenerOptions {\n return eventOptions\n .split(\":\")\n .reduce((options, token) => Object.assign(options, { [token.replace(/^!/, \"\")]: !/^!/.test(token) }), {})\n}\n\nexport function stringifyEventTarget(eventTarget: EventTarget) {\n if (eventTarget == window) {\n return \"window\"\n } else if (eventTarget == document) {\n return \"document\"\n }\n}\n","export function camelize(value: string) {\n return value.replace(/(?:[_-])([a-z0-9])/g, (_, char) => char.toUpperCase())\n}\n\nexport function namespaceCamelize(value: string) {\n return camelize(value.replace(/--/g, \"-\").replace(/__/g, \"_\"))\n}\n\nexport function capitalize(value: string) {\n return value.charAt(0).toUpperCase() + value.slice(1)\n}\n\nexport function dasherize(value: string) {\n return value.replace(/([A-Z])/g, (_, char) => `-${char.toLowerCase()}`)\n}\n\nexport function tokenize(value: string) {\n return value.match(/[^\\s]+/g) || []\n}\n","import { ActionDescriptor, parseActionDescriptorString, stringifyEventTarget } from \"./action_descriptor\"\nimport { Token } from \"../mutation-observers\"\nimport { Schema } from \"./schema\"\nimport { camelize } from \"./string_helpers\"\nexport class Action {\n readonly element: Element\n readonly index: number\n readonly eventTarget: EventTarget\n readonly eventName: string\n readonly eventOptions: AddEventListenerOptions\n readonly identifier: string\n readonly methodName: string\n readonly keyFilter: string\n readonly schema: Schema\n\n static forToken(token: Token, schema: Schema) {\n return new this(token.element, token.index, parseActionDescriptorString(token.content), schema)\n }\n\n constructor(element: Element, index: number, descriptor: Partial<ActionDescriptor>, schema: Schema) {\n this.element = element\n this.index = index\n this.eventTarget = descriptor.eventTarget || element\n this.eventName = descriptor.eventName || getDefaultEventNameForElement(element) || error(\"missing event name\")\n this.eventOptions = descriptor.eventOptions || {}\n this.identifier = descriptor.identifier || error(\"missing identifier\")\n this.methodName = descriptor.methodName || error(\"missing method name\")\n this.keyFilter = descriptor.keyFilter || \"\"\n this.schema = schema\n }\n\n toString() {\n const eventFilter = this.keyFilter ? `.${this.keyFilter}` : \"\"\n const eventTarget = this.eventTargetName ? `@${this.eventTargetName}` : \"\"\n return `${this.eventName}${eventFilter}${eventTarget}->${this.identifier}#${this.methodName}`\n }\n\n isFilterTarget(event: KeyboardEvent): boolean {\n if (!this.keyFilter) {\n return false\n }\n\n const filteres = this.keyFilter.split(\"+\")\n const modifiers = [\"meta\", \"ctrl\", \"alt\", \"shift\"]\n const [meta, ctrl, alt, shift] = modifiers.map((modifier) => filteres.includes(modifier))\n\n if (event.metaKey !== meta || event.ctrlKey !== ctrl || event.altKey !== alt || event.shiftKey !== shift) {\n return true\n }\n\n const standardFilter = filteres.filter((key) => !modifiers.includes(key))[0]\n if (!standardFilter) {\n // missing non modifier key\n return false\n }\n\n if (!Object.prototype.hasOwnProperty.call(this.keyMappings, standardFilter)) {\n error(`contains unknown key filter: ${this.keyFilter}`)\n }\n\n return this.keyMappings[standardFilter].toLowerCase() !== event.key.toLowerCase()\n }\n\n get params() {\n const params: { [key: string]: any } = {}\n const pattern = new RegExp(`^data-${this.identifier}-(.+)-param$`, \"i\")\n\n for (const { name, value } of Array.from(this.element.attributes)) {\n const match = name.match(pattern)\n const key = match && match[1]\n if (key) {\n params[camelize(key)] = typecast(value)\n }\n }\n return params\n }\n\n private get eventTargetName() {\n return stringifyEventTarget(this.eventTarget)\n }\n\n private get keyMappings() {\n return this.schema.keyMappings\n }\n}\n\nconst defaultEventNames: { [tagName: string]: (element: Element) => string } = {\n a: () => \"click\",\n button: () => \"click\",\n form: () => \"submit\",\n details: () => \"toggle\",\n input: (e) => (e.getAttribute(\"type\") == \"submit\" ? \"click\" : \"input\"),\n select: () => \"change\",\n textarea: () => \"input\",\n}\n\nexport function getDefaultEventNameForElement(element: Element): string | undefined {\n const tagName = element.tagName.toLowerCase()\n if (tagName in defaultEventNames) {\n return defaultEventNames[tagName](element)\n }\n}\n\nfunction error(message: string): never {\n throw new Error(message)\n}\n\nfunction typecast(value: any): any {\n try {\n return JSON.parse(value)\n } catch (o_O) {\n return value\n }\n}\n","import { Action } from \"./action\"\nimport { ActionEvent } from \"./action_event\"\nimport { Context } from \"./context\"\nimport { Controller } from \"./controller\"\nimport { Scope } from \"./scope\"\nexport class Binding {\n readonly context: Context\n readonly action: Action\n\n constructor(context: Context, action: Action) {\n this.context = context\n this.action = action\n }\n\n get index(): number {\n return this.action.index\n }\n\n get eventTarget(): EventTarget {\n return this.action.eventTarget\n }\n\n get eventOptions(): AddEventListenerOptions {\n return this.action.eventOptions\n }\n\n get identifier(): string {\n return this.context.identifier\n }\n\n handleEvent(event: Event) {\n if (this.willBeInvokedByEvent(event) && this.applyEventModifiers(event)) {\n this.invokeWithEvent(event)\n }\n }\n\n get eventName(): string {\n return this.action.eventName\n }\n\n get method(): Function {\n const method = (this.controller as any)[this.methodName]\n if (typeof method == \"function\") {\n return method\n }\n throw new Error(`Action \"${this.action}\" references undefined method \"${this.methodName}\"`)\n }\n\n private applyEventModifiers(event: Event): boolean {\n const { element } = this.action\n const { actionDescriptorFilters } = this.context.application\n\n let passes = true\n\n for (const [name, value] of Object.entries(this.eventOptions)) {\n if (name in actionDescriptorFilters) {\n const filter = actionDescriptorFilters[name]\n\n passes = passes && filter({ name, value, event, element })\n } else {\n continue\n }\n }\n\n return passes\n }\n\n private invokeWithEvent(event: Event) {\n const { target, currentTarget } = event\n try {\n const { params } = this.action\n const actionEvent: ActionEvent = Object.assign(event, { params })\n this.method.call(this.controller, actionEvent)\n this.context.logDebugActivity(this.methodName, { event, target, currentTarget, action: this.methodName })\n } catch (error: any) {\n const { identifier, controller, element, index } = this\n const detail = { identifier, controller, element, index, event }\n this.context.handleError(error, `invoking action \"${this.action}\"`, detail)\n }\n }\n\n private willBeInvokedByEvent(event: Event): boolean {\n const eventTarget = event.target\n\n if (event instanceof KeyboardEvent && this.action.isFilterTarget(event)) {\n return false\n }\n\n if (this.element === eventTarget) {\n return true\n } else if (eventTarget instanceof Element && this.element.contains(eventTarget)) {\n return this.scope.containsElement(eventTarget)\n } else {\n return this.scope.containsElement(this.action.element)\n }\n }\n\n private get controller(): Controller {\n return this.context.controller\n }\n\n private get methodName(): string {\n return this.action.methodName\n }\n\n private get element(): Element {\n return this.scope.element\n }\n\n private get scope(): Scope {\n return this.context.scope\n }\n}\n","export interface ElementObserverDelegate {\n matchElement(element: Element): boolean\n matchElementsInTree(tree: Element): Element[]\n\n elementMatched?(element: Element): void\n elementUnmatched?(element: Element): void\n elementAttributeChanged?(element: Element, attributeName: string): void\n}\n\nexport class ElementObserver {\n element: Element\n started: boolean\n private delegate: ElementObserverDelegate\n\n private elements: Set<Element>\n private mutationObserver: MutationObserver\n private mutationObserverInit = { attributes: true, childList: true, subtree: true }\n\n constructor(element: Element, delegate: ElementObserverDelegate) {\n this.element = element\n this.started = false\n this.delegate = delegate\n\n this.elements = new Set()\n this.mutationObserver = new MutationObserver((mutations) => this.processMutations(mutations))\n }\n\n start() {\n if (!this.started) {\n this.started = true\n this.mutationObserver.observe(this.element, this.mutationObserverInit)\n this.refresh()\n }\n }\n\n pause(callback: () => void) {\n if (this.started) {\n this.mutationObserver.disconnect()\n this.started = false\n }\n\n callback()\n\n if (!this.started) {\n this.mutationObserver.observe(this.element, this.mutationObserverInit)\n this.started = true\n }\n }\n\n stop() {\n if (this.started) {\n this.mutationObserver.takeRecords()\n this.mutationObserver.disconnect()\n this.started = false\n }\n }\n\n refresh() {\n if (this.started) {\n const matches = new Set(this.matchElementsInTree())\n\n for (const element of Array.from(this.elements)) {\n if (!matches.has(element)) {\n this.removeElement(element)\n }\n }\n\n for (const element of Array.from(matches)) {\n this.addElement(element)\n }\n }\n }\n\n // Mutation record processing\n\n private processMutations(mutations: MutationRecord[]) {\n if (this.started) {\n for (const mutation of mutations) {\n this.processMutation(mutation)\n }\n }\n }\n\n private processMutation(mutation: MutationRecord) {\n if (mutation.type == \"attributes\") {\n this.processAttributeChange(mutation.target, mutation.attributeName!)\n } else if (mutation.type == \"childList\") {\n this.processRemovedNodes(mutation.removedNodes)\n this.processAddedNodes(mutation.addedNodes)\n }\n }\n\n private processAttributeChange(node: Node, attributeName: string) {\n const element = node as Element\n if (this.elements.has(element)) {\n if (this.delegate.elementAttributeChanged && this.matchElement(element)) {\n this.delegate.elementAttributeChanged(element, attributeName)\n } else {\n this.removeElement(element)\n }\n } else if (this.matchElement(element)) {\n this.addElement(element)\n }\n }\n\n private processRemovedNodes(nodes: NodeList) {\n for (const node of Array.from(nodes)) {\n const element = this.elementFromNode(node)\n if (element) {\n this.processTree(element, this.removeElement)\n }\n }\n }\n\n private processAddedNodes(nodes: NodeList) {\n for (const node of Array.from(nodes)) {\n const element = this.elementFromNode(node)\n if (element && this.elementIsActive(element)) {\n this.processTree(element, this.addElement)\n }\n }\n }\n\n // Element matching\n\n private matchElement(element: Element): boolean {\n return this.delegate.matchElement(element)\n }\n\n private matchElementsInTree(tree: Element = this.element): Element[] {\n return this.delegate.matchElementsInTree(tree)\n }\n\n private processTree(tree: Element, processor: (element: Element) => void) {\n for (const element of this.matchElementsInTree(tree)) {\n processor.call(this, element)\n }\n }\n\n private elementFromNode(node: Node): Element | undefined {\n if (node.nodeType == Node.ELEMENT_NODE) {\n return node as Element\n }\n }\n\n private elementIsActive(element: Element): boolean {\n if (element.isConnected != this.element.isConnected) {\n return false\n } else {\n return this.element.contains(element)\n }\n }\n\n // Element tracking\n\n private addElement(element: Element) {\n if (!this.elements.has(element)) {\n if (this.elementIsActive(element)) {\n this.elements.add(element)\n if (this.delegate.elementMatched) {\n this.delegate.elementMatched(element)\n }\n }\n }\n }\n\n private removeElement(element: Element) {\n if (this.elements.has(element)) {\n this.elements.delete(element)\n if (this.delegate.elementUnmatched) {\n this.delegate.elementUnmatched(element)\n }\n }\n }\n}\n","import { ElementObserver, ElementObserverDelegate } from \"./element_observer\"\n\nexport interface AttributeObserverDelegate {\n elementMatchedAttribute?(element: Element, attributeName: string): void\n elementAttributeValueChanged?(element: Element, attributeName: string): void\n elementUnmatchedAttribute?(element: Element, attributeName: string): void\n}\n\nexport class AttributeObserver implements ElementObserverDelegate {\n attributeName: string\n private delegate: AttributeObserverDelegate\n\n private elementObserver: ElementObserver\n\n constructor(element: Element, attributeName: string, delegate: AttributeObserverDelegate) {\n this.attributeName = attributeName\n this.delegate = delegate\n\n this.elementObserver = new ElementObserver(element, this)\n }\n\n get element(): Element {\n return this.elementObserver.element\n }\n\n get selector(): string {\n return `[${this.attributeName}]`\n }\n\n start() {\n this.elementObserver.start()\n }\n\n pause(callback: () => void) {\n this.elementObserver.pause(callback)\n }\n\n stop() {\n this.elementObserver.stop()\n }\n\n refresh() {\n this.elementObserver.refresh()\n }\n\n get started(): boolean {\n return this.elementObserver.started\n }\n\n // Element observer delegate\n\n matchElement(element: Element): boolean {\n return element.hasAttribute(this.attributeName)\n }\n\n matchElementsInTree(tree: Element): Element[] {\n const match = this.matchElement(tree) ? [tree] : []\n const matches = Array.from(tree.querySelectorAll(this.selector))\n return match.concat(matches)\n }\n\n elementMatched(element: Element) {\n if (this.delegate.elementMatchedAttribute) {\n this.delegate.elementMatchedAttribute(element, this.attributeName)\n }\n }\n\n elementUnmatched(element: Element) {\n if (this.delegate.elementUnmatchedAttribute) {\n this.delegate.elementUnmatchedAttribute(element, this.attributeName)\n }\n }\n\n elementAttributeChanged(element: Element, attributeName: string) {\n if (this.delegate.elementAttributeValueChanged && this.attributeName == attributeName) {\n this.delegate.elementAttributeValueChanged(element, attributeName)\n }\n }\n}\n","export function add<K, V>(map: Map<K, Set<V>>, key: K, value: V) {\n fetch(map, key).add(value)\n}\n\nexport function del<K, V>(map: Map<K, Set<V>>, key: K, value: V) {\n fetch(map, key).delete(value)\n prune(map, key)\n}\n\nexport function fetch<K, V>(map: Map<K, Set<V>>, key: K): Set<V> {\n let values = map.get(key)\n if (!values) {\n values = new Set()\n map.set(key, values)\n }\n return values\n}\n\nexport function prune<K, V>(map: Map<K, Set<V>>, key: K) {\n const values = map.get(key)\n if (values != null && values.size == 0) {\n map.delete(key)\n }\n}\n","import { add, del } from \"./set_operations\"\n\nexport class Multimap<K, V> {\n private valuesByKey: Map<K, Set<V>>\n\n constructor() {\n this.valuesByKey = new Map<K, Set<V>>()\n }\n\n get keys() {\n return Array.from(this.valuesByKey.keys())\n }\n\n get values(): V[] {\n const sets = Array.from(this.valuesByKey.values())\n return sets.reduce((values, set) => values.concat(Array.from(set)), <V[]>[])\n }\n\n get size(): number {\n const sets = Array.from(this.valuesByKey.values())\n return sets.reduce((size, set) => size + set.size, 0)\n }\n\n add(key: K, value: V) {\n add(this.valuesByKey, key, value)\n }\n\n delete(key: K, value: V) {\n del(this.valuesByKey, key, value)\n }\n\n has(key: K, value: V): boolean {\n const values = this.valuesByKey.get(key)\n return values != null && values.has(value)\n }\n\n hasKey(key: K): boolean {\n return this.valuesByKey.has(key)\n }\n\n hasValue(value: V): boolean {\n const sets = Array.from(this.valuesByKey.values())\n return sets.some((set) => set.has(value))\n }\n\n getValuesForKey(key: K): V[] {\n const values = this.valuesByKey.get(key)\n return values ? Array.from(values) : []\n }\n\n getKeysForValue(value: V): K[] {\n return Array.from(this.valuesByKey)\n .filter(([_key, values]) => values.has(value))\n .map(([key, _values]) => key)\n }\n}\n","import { Multimap } from \"./multimap\"\nimport { add, del } from \"./set_operations\"\n\nexport class IndexedMultimap<K, V> extends Multimap<K, V> {\n private keysByValue: Map<V, Set<K>>\n\n constructor() {\n super()\n this.keysByValue = new Map()\n }\n\n get values(): V[] {\n return Array.from(this.keysByValue.keys())\n }\n\n add(key: K, value: V) {\n super.add(key, value)\n add(this.keysByValue, value, key)\n }\n\n delete(key: K, value: V) {\n super.delete(key, value)\n del(this.keysByValue, value, key)\n }\n\n hasValue(value: V): boolean {\n return this.keysByValue.has(value)\n }\n\n getKeysForValue(value: V): K[] {\n const set = this.keysByValue.get(value)\n return set ? Array.from(set) : []\n }\n}\n","import { ElementObserver, ElementObserverDelegate } from \"./element_observer\"\nimport { Multimap } from \"../multimap\"\n\nexport interface SelectorObserverDelegate {\n selectorMatched(element: Element, selector: string, details: object): void\n selectorUnmatched(element: Element, selector: string, details: object): void\n selectorMatchElement?(element: Element, details: object): boolean\n}\n\nexport class SelectorObserver implements ElementObserverDelegate {\n private selector: string\n private elementObserver: ElementObserver\n private delegate: SelectorObserverDelegate\n private matchesByElement: Multimap<string, Element>\n private details: object\n\n constructor(element: Element, selector: string, delegate: SelectorObserverDelegate, details: object = {}) {\n this.selector = selector\n this.details = details\n this.elementObserver = new ElementObserver(element, this)\n this.delegate = delegate\n this.matchesByElement = new Multimap()\n }\n\n get started(): boolean {\n return this.elementObserver.started\n }\n\n start() {\n this.elementObserver.start()\n }\n\n pause(callback: () => void) {\n this.elementObserver.pause(callback)\n }\n\n stop() {\n this.elementObserver.stop()\n }\n\n refresh() {\n this.elementObserver.refresh()\n }\n\n get element(): Element {\n return this.elementObserver.element\n }\n\n // Element observer delegate\n\n matchElement(element: Element): boolean {\n const matches = element.matches(this.selector)\n\n if (this.delegate.selectorMatchElement) {\n return matches && this.delegate.selectorMatchElement(element, this.details)\n }\n\n return matches\n }\n\n matchElementsInTree(tree: Element): Element[] {\n const match = this.matchElement(tree) ? [tree] : []\n const matches = Array.from(tree.querySelectorAll(this.selector)).filter((match) => this.matchElement(match))\n return match.concat(matches)\n }\n\n elementMatched(element: Element) {\n this.selectorMatched(element)\n }\n\n elementUnmatched(element: Element) {\n this.selectorUnmatched(element)\n }\n\n elementAttributeChanged(element: Element, _attributeName: string) {\n const matches = this.matchElement(element)\n const matchedBefore = this.matchesByElement.has(this.selector, element)\n\n if (!matches && matchedBefore) {\n this.selectorUnmatched(element)\n }\n }\n\n private selectorMatched(element: Element) {\n if (this.delegate.selectorMatched) {\n this.delegate.selectorMatched(element, this.selector, this.details)\n this.matchesByElement.add(this.selector, element)\n }\n }\n\n private selectorUnmatched(element: Element) {\n this.delegate.selectorUnmatched(element, this.selector, this.details)\n this.matchesByElement.delete(this.selector, element)\n }\n}\n","export interface StringMapObserverDelegate {\n getStringMapKeyForAttribute(attributeName: string): string | undefined\n stringMapKeyAdded?(key: string, attributeName: string): void\n stringMapValueChanged?(value: string | null, key: string, oldValue: string | null): void\n stringMapKeyRemoved?(key: string, attributeName: string, oldValue: string | null): void\n}\n\nexport class StringMapObserver {\n readonly element: Element\n readonly delegate: StringMapObserverDelegate\n private started: boolean\n private stringMap: Map<string, string>\n private mutationObserver: MutationObserver\n\n constructor(element: Element, delegate: StringMapObserverDelegate) {\n this.element = element\n this.delegate = delegate\n this.started = false\n this.stringMap = new Map()\n this.mutationObserver = new MutationObserver((mutations) => this.processMutations(mutations))\n }\n\n start() {\n if (!this.started) {\n this.started = true\n this.mutationObserver.observe(this.element, { attributes: true, attributeOldValue: true })\n this.refresh()\n }\n }\n\n stop() {\n if (this.started) {\n this.mutationObserver.takeRecords()\n this.mutationObserver.disconnect()\n this.started = false\n }\n }\n\n refresh() {\n if (this.started) {\n for (const attributeName of this.knownAttributeNames) {\n this.refreshAttribute(attributeName, null)\n }\n }\n }\n\n // Mutation record processing\n\n private processMutations(mutations: MutationRecord[]) {\n if (this.started) {\n for (const mutation of mutations) {\n this.processMutation(mutation)\n }\n }\n }\n\n private processMutation(mutation: MutationRecord) {\n const attributeName = mutation.attributeName\n if (attributeName) {\n this.refreshAttribute(attributeName, mutation.oldValue)\n }\n }\n\n // State tracking\n\n private refreshAttribute(attributeName: string, oldValue: string | null) {\n const key = this.delegate.getStringMapKeyForAttribute(attributeName)\n if (key != null) {\n if (!this.stringMap.has(attributeName)) {\n this.stringMapKeyAdded(key, attributeName)\n }\n\n const value = this.element.getAttribute(attributeName)\n if (this.stringMap.get(attributeName) != value) {\n this.stringMapValueChanged(value, key, oldValue)\n }\n\n if (value == null) {\n const oldValue = this.stringMap.get(attributeName)\n this.stringMap.delete(attributeName)\n if (oldValue) this.stringMapKeyRemoved(key, attributeName, oldValue)\n } else {\n this.stringMap.set(attributeName, value)\n }\n }\n }\n\n private stringMapKeyAdded(key: string, attributeName: string) {\n if (this.delegate.stringMapKeyAdded) {\n this.delegate.stringMapKeyAdded(key, attributeName)\n }\n }\n\n private stringMapValueChanged(value: string | null, key: string, oldValue: string | null) {\n if (this.delegate.stringMapValueChanged) {\n this.delegate.stringMapValueChanged(value, key, oldValue)\n }\n }\n\n private stringMapKeyRemoved(key: string, attributeName: string, oldValue: string | null) {\n if (this.delegate.stringMapKeyRemoved) {\n this.delegate.stringMapKeyRemoved(key, attributeName, oldValue)\n }\n }\n\n private get knownAttributeNames() {\n return Array.from(new Set(this.currentAttributeNames.concat(this.recordedAttributeNames)))\n }\n\n private get currentAttributeNames() {\n return Array.from(this.element.attributes).map((attribute) => attribute.name)\n }\n\n private get recordedAttributeNames() {\n return Array.from(this.stringMap.keys())\n }\n}\n","import { AttributeObserver, AttributeObserverDelegate } from \"./attribute_observer\"\nimport { Multimap } from \"../multimap\"\n\nexport interface Token {\n element: Element\n attributeName: string\n index: number\n content: string\n}\n\nexport interface TokenListObserverDelegate {\n tokenMatched(token: Token): void\n tokenUnmatched(token: Token): void\n}\n\nexport class TokenListObserver implements AttributeObserverDelegate {\n private attributeObserver: AttributeObserver\n private delegate: TokenListObserverDelegate\n private tokensByElement: Multimap<Element, Token>\n\n constructor(element: Element, attributeName: string, delegate: TokenListObserverDelegate) {\n this.attributeObserver = new AttributeObserver(element, attributeName, this)\n this.delegate = delegate\n this.tokensByElement = new Multimap()\n }\n\n get started(): boolean {\n return this.attributeObserver.started\n }\n\n start() {\n this.attributeObserver.start()\n }\n\n pause(callback: () => void) {\n this.attributeObserver.pause(callback)\n }\n\n stop() {\n this.attributeObserver.stop()\n }\n\n refresh() {\n this.attributeObserver.refresh()\n }\n\n get element(): Element {\n return this.attributeObserver.element\n }\n\n get attributeName(): string {\n return this.attributeObserver.attributeName\n }\n\n // Attribute observer delegate\n\n elementMatchedAttribute(element: Element) {\n this.tokensMatched(this.readTokensForElement(element))\n }\n\n elementAttributeValueChanged(element: Element) {\n const [unmatchedTokens, matchedTokens] = this.refreshTokensForElement(element)\n this.tokensUnmatched(unmatchedTokens)\n this.tokensMatched(matchedTokens)\n }\n\n elementUnmatchedAttribute(element: Element) {\n this.tokensUnmatched(this.tokensByElement.getValuesForKey(element))\n }\n\n private tokensMatched(tokens: Token[]) {\n tokens.forEach((token) => this.tokenMatched(token))\n }\n\n private tokensUnmatched(tokens: Token[]) {\n tokens.forEach((token) => this.tokenUnmatched(token))\n }\n\n private tokenMatched(token: Token) {\n this.delegate.tokenMatched(token)\n this.tokensByElement.add(token.element, token)\n }\n\n private tokenUnmatched(token: Token) {\n this.delegate.tokenUnmatched(token)\n this.tokensByElement.delete(token.element, token)\n }\n\n private refreshTokensForElement(element: Element): [Token[], Token[]] {\n const previousTokens = this.tokensByElement.getValuesForKey(element)\n const currentTokens = this.readTokensForElement(element)\n const firstDifferingIndex = zip(previousTokens, currentTokens).findIndex(\n ([previousToken, currentToken]) => !tokensAreEqual(previousToken, currentToken)\n )\n\n if (firstDifferingIndex == -1) {\n return [[], []]\n } else {\n return [previousTokens.slice(firstDifferingIndex), currentTokens.slice(firstDifferingIndex)]\n }\n }\n\n private readTokensForElement(element: Element): Token[] {\n const attributeName = this.attributeName\n const tokenString = element.getAttribute(attributeName) || \"\"\n return parseTokenString(tokenString, element, attributeName)\n }\n}\n\nfunction parseTokenString(tokenString: string, element: Element, attributeName: string): Token[] {\n return tokenString\n .trim()\n .split(/\\s+/)\n .filter((content) => content.length)\n .map((content, index) => ({ element, attributeName, content, index }))\n}\n\nfunction zip<L, R>(left: L[], right: R[]): [L | undefined, R | undefined][] {\n const length = Math.max(left.length, right.length)\n return Array.from({ length }, (_, index) => [left[index], right[index]] as [L, R])\n}\n\nfunction tokensAreEqual(left?: Token, right?: Token) {\n return left && right && left.index == right.index && left.content == right.content\n}\n","import { Token, TokenListObserver, TokenListObserverDelegate } from \"./token_list_observer\"\n\nexport interface ValueListObserverDelegate<T> {\n parseValueForToken(token: Token): T | undefined\n elementMatchedValue(element: Element, value: T): void\n elementUnmatchedValue(element: Element, value: T): void\n}\n\ninterface ParseResult<T> {\n value?: T\n error?: Error\n}\n\nexport class ValueListObserver<T> implements TokenListObserverDelegate {\n private tokenListObserver: TokenListObserver\n private delegate: ValueListObserverDelegate<T>\n private parseResultsByToken: WeakMap<Token, ParseResult<T>>\n private valuesByTokenByElement: WeakMap<Element, Map<Token, T>>\n\n constructor(element: Element, attributeName: string, delegate: ValueListObserverDelegate<T>) {\n this.tokenListObserver = new TokenListObserver(element, attributeName, this)\n this.delegate = delegate\n this.parseResultsByToken = new WeakMap()\n this.valuesByTokenByElement = new WeakMap()\n }\n\n get started(): boolean {\n return this.tokenListObserver.started\n }\n\n start() {\n this.tokenListObserver.start()\n }\n\n stop() {\n this.tokenListObserver.stop()\n }\n\n refresh() {\n this.tokenListObserver.refresh()\n }\n\n get element(): Element {\n return this.tokenListObserver.element\n }\n\n get attributeName(): string {\n return this.tokenListObserver.attributeName\n }\n\n tokenMatched(token: Token) {\n const { element } = token\n const { value } = this.fetchParseResultForToken(token)\n if (value) {\n this.fetchValuesByTokenForElement(element).set(token, value)\n this.delegate.elementMatchedValue(element, value)\n }\n }\n\n tokenUnmatched(token: Token) {\n const { element } = token\n const { value } = this.fetchParseResultForToken(token)\n if (value) {\n this.fetchValuesByTokenForElement(element).delete(token)\n this.delegate.elementUnmatchedValue(element, value)\n }\n }\n\n private fetchParseResultForToken(token: Token) {\n let parseResult = this.parseResultsByToken.get(token)\n if (!parseResult) {\n parseResult = this.parseToken(token)\n this.parseResultsByToken.set(token, parseResult)\n }\n return parseResult\n }\n\n private fetchValuesByTokenForElement(element: Element) {\n let valuesByToken = this.valuesByTokenByElement.get(element)\n if (!valuesByToken) {\n valuesByToken = new Map()\n this.valuesByTokenByElement.set(element, valuesByToken)\n }\n return valuesByToken\n }\n\n private parseToken(token: Token): ParseResult<T> {\n try {\n const value = this.delegate.parseValueForToken(token)\n return { value }\n } catch (error: any) {\n return { error }\n }\n }\n}\n","import { Action } from \"./action\"\nimport { Binding } from \"./binding\"\nimport { Context } from \"./context\"\nimport { ErrorHandler } from \"./error_handler\"\nimport { Schema } from \"./schema\"\nimport { Token, ValueListObserver, ValueListObserverDelegate } from \"../mutation-observers\"\n\nexport interface BindingObserverDelegate extends ErrorHandler {\n bindingConnected(binding: Binding): void\n bindingDisconnected(binding: Binding, clearEventListeners?: boolean): void\n}\n\nexport class BindingObserver implements ValueListObserverDelegate<Action> {\n readonly context: Context\n private delegate: BindingObserverDelegate\n private valueListObserver?: ValueListObserver<Action>\n private bindingsByAction: Map<Action, Binding>\n\n constructor(context: Context, delegate: BindingObserverDelegate) {\n this.context = context\n this.delegate = delegate\n this.bindingsByAction = new Map()\n }\n\n start() {\n if (!this.valueListObserver) {\n this.valueListObserver = new ValueListObserver(this.element, this.actionAttribute, this)\n this.valueListObserver.start()\n }\n }\n\n stop() {\n if (this.valueListObserver) {\n this.valueListObserver.stop()\n delete this.valueListObserver\n this.disconnectAllActions()\n }\n }\n\n get element() {\n return this.context.element\n }\n\n get identifier() {\n return this.context.identifier\n }\n\n get actionAttribute() {\n return this.schema.actionAttribute\n }\n\n get schema(): Schema {\n return this.context.schema\n }\n\n get bindings(): Binding[] {\n return Array.from(this.bindingsByAction.values())\n }\n\n private connectAction(action: Action) {\n const binding = new Binding(this.context, action)\n this.bindingsByAction.set(action, binding)\n this.delegate.bindingConnected(binding)\n }\n\n private disconnectAction(action: Action) {\n const binding = this.bindingsByAction.get(action)\n if (binding) {\n this.bindingsByAction.delete(action)\n this.delegate.bindingDisconnected(binding)\n }\n }\n\n private disconnectAllActions() {\n this.bindings.forEach((binding) => this.delegate.bindingDisconnected(binding, true))\n this.bindingsByAction.clear()\n }\n\n // Value observer delegate\n\n parseValueForToken(token: Token): Action | undefined {\n const action = Action.forToken(token, this.schema)\n if (action.identifier == this.identifier) {\n return action\n }\n }\n\n elementMatchedValue(element: Element, action: Action) {\n this.connectAction(action)\n }\n\n elementUnmatchedValue(element: Element, action: Action) {\n this.disconnectAction(action)\n }\n}\n","import { Context } from \"./context\"\nimport { StringMapObserver, StringMapObserverDelegate } from \"../mutation-observers\"\nimport { ValueDescriptor } from \"./value_properties\"\nimport { capitalize } from \"./string_helpers\"\n\nexport class ValueObserver implements StringMapObserverDelegate {\n readonly context: Context\n readonly receiver: any\n private stringMapObserver: StringMapObserver\n private valueDescriptorMap: { [attributeName: string]: ValueDescriptor }\n\n constructor(context: Context, receiver: any) {\n this.context = context\n this.receiver = receiver\n this.stringMapObserver = new StringMapObserver(this.element, this)\n this.valueDescriptorMap = (this.controller as any).valueDescriptorMap\n }\n\n start() {\n this.stringMapObserver.start()\n this.invokeChangedCallbacksForDefaultValues()\n }\n\n stop() {\n this.stringMapObserver.stop()\n }\n\n get element() {\n return this.context.element\n }\n\n get controller() {\n return this.context.controller\n }\n\n // String map observer delegate\n\n getStringMapKeyForAttribute(attributeName: string) {\n if (attributeName in this.valueDescriptorMap) {\n return this.valueDescriptorMap[attributeName].name\n }\n }\n\n stringMapKeyAdded(key: string, attributeName: string) {\n const descriptor = this.valueDescriptorMap[attributeName]\n\n if (!this.hasValue(key)) {\n this.invokeChangedCallback(key, descriptor.writer(this.receiver[key]), descriptor.writer(descriptor.defaultValue))\n }\n }\n\n stringMapValueChanged(value: string, name: string, oldValue: string) {\n const descriptor = this.valueDescriptorNameMap[name]\n\n if (value === null) return\n\n if (oldValue === null) {\n oldValue = descriptor.writer(descriptor.defaultValue)\n }\n\n this.invokeChangedCallback(name, value, oldValue)\n }\n\n stringMapKeyRemoved(key: string, attributeName: string, oldValue: string) {\n const descriptor = this.valueDescriptorNameMap[key]\n\n if (this.hasValue(key)) {\n this.invokeChangedCallback(key, descriptor.writer(this.receiver[key]), oldValue)\n } else {\n this.invokeChangedCallback(key, descriptor.writer(descriptor.defaultValue), oldValue)\n }\n }\n\n private invokeChangedCallbacksForDefaultValues() {\n for (const { key, name, defaultValue, writer } of this.valueDescriptors) {\n if (defaultValue != undefined && !this.controller.data.has(key)) {\n this.invokeChangedCallback(name, writer(defaultValue), undefined)\n }\n }\n }\n\n private invokeChangedCallback(name: string, rawValue: string, rawOldValue: string | undefined) {\n const changedMethodName = `${name}Changed`\n const changedMethod = this.receiver[changedMethodName]\n\n if (typeof changedMethod == \"function\") {\n const descriptor = this.valueDescriptorNameMap[name]\n\n try {\n const value = descriptor.reader(rawValue)\n let oldValue = rawOldValue\n\n if (rawOldValue) {\n oldValue = descriptor.reader(rawOldValue)\n }\n\n changedMethod.call(this.receiver, value, oldValue)\n } catch (error) {\n if (error instanceof TypeError) {\n error.message = `Stimulus Value \"${this.context.identifier}.${descriptor.name}\" - ${error.message}`\n }\n\n throw error\n }\n }\n }\n\n private get valueDescriptors() {\n const { valueDescriptorMap } = this\n return Object.keys(valueDescriptorMap).map((key) => valueDescriptorMap[key])\n }\n\n private get valueDescriptorNameMap() {\n const descriptors: { [type: string]: ValueDescriptor } = {}\n\n Object.keys(this.valueDescriptorMap).forEach((key) => {\n const descriptor = this.valueDescriptorMap[key]\n descriptors[descriptor.name] = descriptor\n })\n\n return descriptors\n }\n\n private hasValue(attributeName: string) {\n const descriptor = this.valueDescriptorNameMap[attributeName]\n const hasMethodName = `has${capitalize(descriptor.name)}`\n\n return this.receiver[hasMethodName]\n }\n}\n","import { Multimap } from \"../multimap\"\nimport { Token, TokenListObserver, TokenListObserverDelegate } from \"../mutation-observers\"\nimport { Context } from \"./context\"\n\nexport interface TargetObserverDelegate {\n targetConnected(element: Element, name: string): void\n targetDisconnected(element: Element, name: string): void\n}\n\nexport class TargetObserver implements TokenListObserverDelegate {\n readonly context: Context\n readonly delegate: TargetObserverDelegate\n readonly targetsByName: Multimap<string, Element>\n private tokenListObserver?: TokenListObserver\n\n constructor(context: Context, delegate: TargetObserverDelegate) {\n this.context = context\n this.delegate = delegate\n this.targetsByName = new Multimap()\n }\n\n start() {\n if (!this.tokenListObserver) {\n this.tokenListObserver = new TokenListObserver(this.element, this.attributeName, this)\n this.tokenListObserver.start()\n }\n }\n\n stop() {\n if (this.tokenListObserver) {\n this.disconnectAllTargets()\n this.tokenListObserver.stop()\n delete this.tokenListObserver\n }\n }\n\n // Token list observer delegate\n\n tokenMatched({ element, content: name }: Token) {\n if (this.scope.containsElement(element)) {\n this.connectTarget(element, name)\n }\n }\n\n tokenUnmatched({ element, content: name }: Token) {\n this.disconnectTarget(element, name)\n }\n\n // Target management\n\n connectTarget(element: Element, name: string) {\n if (!this.targetsByName.has(name, element)) {\n this.targetsByName.add(name, element)\n this.tokenListObserver?.pause(() => this.delegate.targetConnected(element, name))\n }\n }\n\n disconnectTarget(element: Element, name: string) {\n if (this.targetsByName.has(name, element)) {\n this.targetsByName.delete(name, element)\n this.tokenListObserver?.pause(() => this.delegate.targetDisconnected(element, name))\n }\n }\n\n disconnectAllTargets() {\n for (const name of this.targetsByName.keys) {\n for (const element of this.targetsByName.getValuesForKey(name)) {\n this.disconnectTarget(element, name)\n }\n }\n }\n\n // Private\n\n private get attributeName() {\n return `data-${this.context.identifier}-target`\n }\n\n private get element() {\n return this.context.element\n }\n\n private get scope() {\n return this.context.scope\n }\n}\n","import { Constructor } from \"./constructor\"\n\nexport function readInheritableStaticArrayValues<T, U = string>(constructor: Constructor<T>, propertyName: string) {\n const ancestors = getAncestorsForConstructor(constructor)\n return Array.from(\n ancestors.reduce((values, constructor) => {\n getOwnStaticArrayValues(constructor, propertyName).forEach((name) => values.add(name))\n return values\n }, new Set() as Set<U>)\n )\n}\n\nexport function readInheritableStaticObjectPairs<T, U>(constructor: Constructor<T>, propertyName: string) {\n const ancestors = getAncestorsForConstructor(constructor)\n return ancestors.reduce((pairs, constructor) => {\n pairs.push(...(getOwnStaticObjectPairs(constructor, propertyName) as any))\n return pairs\n }, [] as [string, U][])\n}\n\nfunction getAncestorsForConstructor<T>(constructor: Constructor<T>) {\n const ancestors: Constructor<any>[] = []\n while (constructor) {\n ancestors.push(constructor)\n constructor = Object.getPrototypeOf(constructor)\n }\n return ancestors.reverse()\n}\n\nfunction getOwnStaticArrayValues<T>(constructor: Constructor<T>, propertyName: string) {\n const definition = (constructor as any)[propertyName]\n return Array.isArray(definition) ? definition : []\n}\n\nfunction getOwnStaticObjectPairs<T, U>(constructor: Constructor<T>, propertyName: string) {\n const definition = (constructor as any)[propertyName]\n return definition ? Object.keys(definition).map((key) => [key, definition[key]] as [string, U]) : []\n}\n","import { Multimap } from \"../multimap\"\nimport { SelectorObserver, SelectorObserverDelegate } from \"../mutation-observers\"\nimport { Context } from \"./context\"\nimport { Controller } from \"./controller\"\n\nimport { readInheritableStaticArrayValues } from \"./inheritable_statics\"\n\ntype SelectorObserverDetails = { outletName: string }\n\nexport interface OutletObserverDelegate {\n outletConnected(outlet: Controller, element: Element, outletName: string): void\n outletDisconnected(outlet: Controller, element: Element, outletName: string): void\n}\n\nexport class OutletObserver implements SelectorObserverDelegate {\n readonly context: Context\n readonly delegate: OutletObserverDelegate\n readonly outletsByName: Multimap<string, Controller>\n readonly outletElementsByName: Multimap<string, Element>\n private selectorObserverMap: Map<string, SelectorObserver>\n\n constructor(context: Context, delegate: OutletObserverDelegate) {\n this.context = context\n this.delegate = delegate\n this.outletsByName = new Multimap()\n this.outletElementsByName = new Multimap()\n this.selectorObserverMap = new Map()\n }\n\n start() {\n if (this.selectorObserverMap.size === 0) {\n this.outletDefinitions.forEach((outletName) => {\n const selector = this.selector(outletName)\n const details: SelectorObserverDetails = { outletName }\n\n if (selector) {\n this.selectorObserverMap.set(outletName, new SelectorObserver(document.body, selector, this, details))\n }\n })\n\n this.selectorObserverMap.forEach((observer) => observer.start())\n }\n\n this.dependentContexts.forEach((context) => context.refresh())\n }\n\n stop() {\n if (this.selectorObserverMap.size > 0) {\n this.disconnectAllOutlets()\n this.selectorObserverMap.forEach((observer) => observer.stop())\n this.selectorObserverMap.clear()\n }\n }\n\n refresh() {\n this.selectorObserverMap.forEach((observer) => observer.refresh())\n }\n\n // Selector observer delegate\n\n selectorMatched(element: Element, _selector: string, { outletName }: SelectorObserverDetails) {\n const outlet = this.getOutlet(element, outletName)\n\n if (outlet) {\n this.connectOutlet(outlet, element, outletName)\n }\n }\n\n selectorUnmatched(element: Element, _selector: string, { outletName }: SelectorObserverDetails) {\n const outlet = this.getOutletFromMap(element, outletName)\n\n if (outlet) {\n this.disconnectOutlet(outlet, element, outletName)\n }\n }\n\n selectorMatchElement(element: Element, { outletName }: SelectorObserverDetails) {\n return (\n this.hasOutlet(element, outletName) &&\n element.matches(`[${this.context.application.schema.controllerAttribute}~=${outletName}]`)\n )\n }\n\n // Outlet management\n\n connectOutlet(outlet: Controller, element: Element, outletName: string) {\n if (!this.outletElementsByName.has(outletName, element)) {\n this.outletsByName.add(outletName, outlet)\n this.outletElementsByName.add(outletName, element)\n this.selectorObserverMap.get(outletName)?.pause(() => this.delegate.outletConnected(outlet, element, outletName))\n }\n }\n\n disconnectOutlet(outlet: Controller, element: Element, outletName: string) {\n if (this.outletElementsByName.has(outletName, element)) {\n this.outletsByName.delete(outletName, outlet)\n this.outletElementsByName.delete(outletName, element)\n this.selectorObserverMap\n .get(outletName)\n ?.pause(() => this.delegate.outletDisconnected(outlet, element, outletName))\n }\n }\n\n disconnectAllOutlets() {\n for (const outletName of this.outletElementsByName.keys) {\n for (const element of this.outletElementsByName.getValuesForKey(outletName)) {\n for (const outlet of this.outletsByName.getValuesForKey(outletName)) {\n this.disconnectOutlet(outlet, element, outletName)\n }\n }\n }\n }\n\n // Private\n\n private selector(outletName: string) {\n return this.scope.outlets.getSelectorForOutletName(outletName)\n }\n\n private get outletDependencies() {\n const dependencies = new Multimap<string, string>()\n\n this.router.modules.forEach((module) => {\n const constructor = module.definition.controllerConstructor\n const outlets = readInheritableStaticArrayValues(constructor, \"outlets\")\n\n outlets.forEach((outlet) => dependencies.add(outlet, module.identifier))\n })\n\n return dependencies\n }\n\n private get outletDefinitions() {\n return this.outletDependencies.getKeysForValue(this.identifier)\n }\n\n private get dependentControllerIdentifiers() {\n return this.outletDependencies.getValuesForKey(this.identifier)\n }\n\n private get dependentContexts() {\n const identifiers = this.dependentControllerIdentifiers\n return this.router.contexts.filter((context) => identifiers.includes(context.identifier))\n }\n\n private hasOutlet(element: Element, outletName: string) {\n return !!this.getOutlet(element, outletName) || !!this.getOutletFromMap(element, outletName)\n }\n\n private getOutlet(element: Element, outletName: string) {\n return this.application.getControllerForElementAndIdentifier(element, outletName)\n }\n\n private getOutletFromMap(element: Element, outletName: string) {\n return this.outletsByName.getValuesForKey(outletName).find((outlet) => outlet.element === element)\n }\n\n private get scope() {\n return this.context.scope\n }\n\n private get identifier() {\n return this.context.identifier\n }\n\n private get application() {\n return this.context.application\n }\n\n private get router() {\n return this.application.router\n }\n}\n","import { Application } from \"./application\"\nimport { BindingObserver } from \"./binding_observer\"\nimport { Controller } from \"./controller\"\nimport { Dispatcher } from \"./dispatcher\"\nimport { ErrorHandler } from \"./error_handler\"\nimport { Module } from \"./module\"\nimport { Schema } from \"./schema\"\nimport { Scope } from \"./scope\"\nimport { ValueObserver } from \"./value_observer\"\nimport { TargetObserver, TargetObserverDelegate } from \"./target_observer\"\nimport { OutletObserver, OutletObserverDelegate } from \"./outlet_observer\"\nimport { namespaceCamelize } from \"./string_helpers\"\n\nexport class Context implements ErrorHandler, TargetObserverDelegate, OutletObserverDelegate {\n readonly module: Module\n readonly scope: Scope\n readonly controller: Controller\n private bindingObserver: BindingObserver\n private valueObserver: ValueObserver\n private targetObserver: TargetObserver\n private outletObserver: OutletObserver\n\n constructor(module: Module, scope: Scope) {\n this.module = module\n this.scope = scope\n this.controller = new module.controllerConstructor(this)\n this.bindingObserver = new BindingObserver(this, this.dispatcher)\n this.valueObserver = new ValueObserver(this, this.controller)\n this.targetObserver = new TargetObserver(this, this)\n this.outletObserver = new OutletObserver(this, this)\n\n try {\n this.controller.initialize()\n this.logDebugActivity(\"initialize\")\n } catch (error: any) {\n this.handleError(error, \"initializing controller\")\n }\n }\n\n connect() {\n this.bindingObserver.start()\n this.valueObserver.start()\n this.targetObserver.start()\n this.outletObserver.start()\n\n try {\n this.controller.connect()\n this.logDebugActivity(\"connect\")\n } catch (error: any) {\n this.handleError(error, \"connecting controller\")\n }\n }\n\n refresh() {\n this.outletObserver.refresh()\n }\n\n disconnect() {\n try {\n this.controller.disconnect()\n this.logDebugActivity(\"disconnect\")\n } catch (error: any) {\n this.handleError(error, \"disconnecting controller\")\n }\n\n this.outletObserver.stop()\n this.targetObserver.stop()\n this.valueObserver.stop()\n this.bindingObserver.stop()\n }\n\n get application(): Application {\n return this.module.application\n }\n\n get identifier(): string {\n return this.module.identifier\n }\n\n get schema(): Schema {\n return this.application.schema\n }\n\n get dispatcher(): Dispatcher {\n return this.application.dispatcher\n }\n\n get element(): Element {\n return this.scope.element\n }\n\n get parentElement(): Element | null {\n return this.element.parentElement\n }\n\n // Error handling\n\n handleError(error: Error, message: string, detail: object = {}) {\n const { identifier, controller, element } = this\n detail = Object.assign({ identifier, controller, element }, detail)\n this.application.handleError(error, `Error ${message}`, detail)\n }\n\n // Debug logging\n\n logDebugActivity = (functionName: string, detail: object = {}): void => {\n const { identifier, controller, element } = this\n detail = Object.assign({ identifier, controller, element }, detail)\n this.application.logDebugActivity(this.identifier, functionName, detail)\n }\n\n // Target observer delegate\n\n targetConnected(element: Element, name: string) {\n this.invokeControllerMethod(`${name}TargetConnected`, element)\n }\n\n targetDisconnected(element: Element, name: string) {\n this.invokeControllerMethod(`${name}TargetDisconnected`, element)\n }\n\n // Outlet observer delegate\n\n outletConnected(outlet: Controller, element: Element, name: string) {\n this.invokeControllerMethod(`${namespaceCamelize(name)}OutletConnected`, outlet, element)\n }\n\n outletDisconnected(outlet: Controller, element: Element, name: string) {\n this.invokeControllerMethod(`${namespaceCamelize(name)}OutletDisconnected`, outlet, element)\n }\n\n // Private\n\n invokeControllerMethod(methodName: string, ...args: any[]) {\n const controller: any = this.controller\n if (typeof controller[methodName] == \"function\") {\n controller[methodName](...args)\n }\n }\n}\n","import { Constructor } from \"./constructor\"\nimport { readInheritableStaticArrayValues } from \"./inheritable_statics\"\n\nexport type Blessing<T> = (constructor: Constructor<T>) => PropertyDescriptorMap\n\nexport interface Blessable<T> extends Constructor<T> {\n readonly blessings?: Blessing<T>[]\n}\n\nexport function bless<T>(constructor: Blessable<T>): Constructor<T> {\n return shadow(constructor, getBlessedProperties(constructor))\n}\n\nfunction shadow<T>(constructor: Constructor<T>, properties: PropertyDescriptorMap) {\n const shadowConstructor = extend(constructor)\n const shadowProperties = getShadowProperties(constructor.prototype, properties)\n Object.defineProperties(shadowConstructor.prototype, shadowProperties)\n return shadowConstructor\n}\n\nfunction getBlessedProperties<T>(constructor: Constructor<T>) {\n const blessings = readInheritableStaticArrayValues(constructor, \"blessings\") as Blessing<T>[]\n return blessings.reduce((blessedProperties, blessing) => {\n const properties = blessing(constructor)\n for (const key in properties) {\n const descriptor = blessedProperties[key] || ({} as PropertyDescriptor)\n blessedProperties[key] = Object.assign(descriptor, properties[key])\n }\n return blessedProperties\n }, {} as PropertyDescriptorMap)\n}\n\nfunction getShadowProperties(prototype: any, properties: PropertyDescriptorMap) {\n return getOwnKeys(properties).reduce((shadowProperties, key) => {\n const descriptor = getShadowedDescriptor(prototype, properties, key)\n if (descriptor) {\n Object.assign(shadowProperties, { [key]: descriptor })\n }\n return shadowProperties\n }, {} as PropertyDescriptorMap)\n}\n\nfunction getShadowedDescriptor(prototype: any, properties: PropertyDescriptorMap, key: string | symbol) {\n const shadowingDescriptor = Object.getOwnPropertyDescriptor(prototype, key)\n const shadowedByValue = shadowingDescriptor && \"value\" in shadowingDescriptor\n if (!shadowedByValue) {\n const descriptor = Object.getOwnPropertyDescriptor(properties, key)!.value\n if (shadowingDescriptor) {\n descriptor.get = shadowingDescriptor.get || descriptor.get\n descriptor.set = shadowingDescriptor.set || descriptor.set\n }\n return descriptor\n }\n}\n\nconst getOwnKeys = (() => {\n if (typeof Object.getOwnPropertySymbols == \"function\") {\n return (object: any) => [...Object.getOwnPropertyNames(object), ...Object.getOwnPropertySymbols(object)]\n } else {\n return Object.getOwnPropertyNames\n }\n})()\n\nconst extend = (() => {\n function extendWithReflect<T extends Constructor<any>>(constructor: T): T {\n function extended() {\n return Reflect.construct(constructor, arguments, new.target)\n }\n\n extended.prototype = Object.create(constructor.prototype, {\n constructor: { value: extended },\n })\n\n Reflect.setPrototypeOf(extended, constructor)\n return extended as any\n }\n\n function testReflectExtension() {\n const a = function (this: any) {\n this.a.call(this)\n } as any\n const b = extendWithReflect(a)\n b.prototype.a = function () {}\n return new b()\n }\n\n try {\n testReflectExtension()\n return extendWithReflect\n } catch (error: any) {\n return <T extends Constructor<any>>(constructor: T) => class extended extends constructor {}\n }\n})()\n","import { Application } from \"./application\"\nimport { Context } from \"./context\"\nimport { ControllerConstructor } from \"./controller\"\nimport { Definition, blessDefinition } from \"./definition\"\nimport { Scope } from \"./scope\"\n\nexport class Module {\n readonly application: Application\n readonly definition: Definition\n private contextsByScope: WeakMap<Scope, Context>\n private connectedContexts: Set<Context>\n\n constructor(application: Application, definition: Definition) {\n this.application = application\n this.definition = blessDefinition(definition)\n this.contextsByScope = new WeakMap()\n this.connectedContexts = new Set()\n }\n\n get identifier(): string {\n return this.definition.identifier\n }\n\n get controllerConstructor(): ControllerConstructor {\n return this.definition.controllerConstructor\n }\n\n get contexts(): Context[] {\n return Array.from(this.connectedContexts)\n }\n\n connectContextForScope(scope: Scope) {\n const context = this.fetchContextForScope(scope)\n this.connectedContexts.add(context)\n context.connect()\n }\n\n disconnectContextForScope(scope: Scope) {\n const context = this.contextsByScope.get(scope)\n if (context) {\n this.connectedContexts.delete(context)\n context.disconnect()\n }\n }\n\n private fetchContextForScope(scope: Scope): Context {\n let context = this.contextsByScope.get(scope)\n if (!context) {\n context = new Context(this, scope)\n this.contextsByScope.set(scope, context)\n }\n return context\n }\n}\n","import { bless } from \"./blessing\"\nimport { ControllerConstructor } from \"./controller\"\n\nexport interface Definition {\n identifier: string\n controllerConstructor: ControllerConstructor\n}\n\nexport function blessDefinition(definition: Definition): Definition {\n return {\n identifier: definition.identifier,\n controllerConstructor: bless(definition.controllerConstructor),\n }\n}\n","import { Scope } from \"./scope\"\nimport { tokenize } from \"./string_helpers\"\n\nexport class ClassMap {\n readonly scope: Scope\n\n constructor(scope: Scope) {\n this.scope = scope\n }\n\n has(name: string) {\n return this.data.has(this.getDataKey(name))\n }\n\n get(name: string): string | undefined {\n return this.getAll(name)[0]\n }\n\n getAll(name: string) {\n const tokenString = this.data.get(this.getDataKey(name)) || \"\"\n return tokenize(tokenString)\n }\n\n getAttributeName(name: string) {\n return this.data.getAttributeNameForKey(this.getDataKey(name))\n }\n\n getDataKey(name: string) {\n return `${name}-class`\n }\n\n get data() {\n return this.scope.data\n }\n}\n","import { Scope } from \"./scope\"\nimport { dasherize } from \"./string_helpers\"\n\nexport class DataMap {\n readonly scope: Scope\n\n constructor(scope: Scope) {\n this.scope = scope\n }\n\n get element(): Element {\n return this.scope.element\n }\n\n get identifier(): string {\n return this.scope.identifier\n }\n\n get(key: string): string | null {\n const name = this.getAttributeNameForKey(key)\n return this.element.getAttribute(name)\n }\n\n set(key: string, value: string): string | null {\n const name = this.getAttributeNameForKey(key)\n this.element.setAttribute(name, value)\n return this.get(key)\n }\n\n has(key: string): boolean {\n const name = this.getAttributeNameForKey(key)\n return this.element.hasAttribute(name)\n }\n\n delete(key: string): boolean {\n if (this.has(key)) {\n const name = this.getAttributeNameForKey(key)\n this.element.removeAttribute(name)\n return true\n } else {\n return false\n }\n }\n\n getAttributeNameForKey(key: string): string {\n return `data-${this.identifier}-${dasherize(key)}`\n }\n}\n","import { Logger } from \"./logger\"\n\nexport class Guide {\n readonly logger: Logger\n readonly warnedKeysByObject: WeakMap<any, Set<string>> = new WeakMap()\n\n constructor(logger: Logger) {\n this.logger = logger\n }\n\n warn(object: any, key: string, message: string) {\n let warnedKeys: Set<string> | undefined = this.warnedKeysByObject.get(object)\n\n if (!warnedKeys) {\n warnedKeys = new Set()\n this.warnedKeysByObject.set(object, warnedKeys)\n }\n\n if (!warnedKeys.has(key)) {\n warnedKeys.add(key)\n this.logger.warn(message, object)\n }\n }\n}\n","export function attributeValueContainsToken(attributeName: string, token: string) {\n return `[${attributeName}~=\"${token}\"]`\n}\n","import { Scope } from \"./scope\"\nimport { attributeValueContainsToken } from \"./selectors\"\n\nexport class TargetSet {\n readonly scope: Scope\n\n constructor(scope: Scope) {\n this.scope = scope\n }\n\n get element() {\n return this.scope.element\n }\n\n get identifier() {\n return this.scope.identifier\n }\n\n get schema() {\n return this.scope.schema\n }\n\n has(targetName: string) {\n return this.find(targetName) != null\n }\n\n find(...targetNames: string[]) {\n return targetNames.reduce(\n (target, targetName) => target || this.findTarget(targetName) || this.findLegacyTarget(targetName),\n undefined as Element | undefined\n )\n }\n\n findAll(...targetNames: string[]) {\n return targetNames.reduce(\n (targets, targetName) => [\n ...targets,\n ...this.findAllTargets(targetName),\n ...this.findAllLegacyTargets(targetName),\n ],\n [] as Element[]\n )\n }\n\n private findTarget(targetName: string) {\n const selector = this.getSelectorForTargetName(targetName)\n return this.scope.findElement(selector)\n }\n\n private findAllTargets(targetName: string) {\n const selector = this.getSelectorForTargetName(targetName)\n return this.scope.findAllElements(selector)\n }\n\n private getSelectorForTargetName(targetName: string) {\n const attributeName = this.schema.targetAttributeForScope(this.identifier)\n return attributeValueContainsToken(attributeName, targetName)\n }\n\n private findLegacyTarget(targetName: string) {\n const selector = this.getLegacySelectorForTargetName(targetName)\n return this.deprecate(this.scope.findElement(selector), targetName)\n }\n\n private findAllLegacyTargets(targetName: string) {\n const selector = this.getLegacySelectorForTargetName(targetName)\n return this.scope.findAllElements(selector).map((element) => this.deprecate(element, targetName))\n }\n\n private getLegacySelectorForTargetName(targetName: string) {\n const targetDescriptor = `${this.identifier}.${targetName}`\n return attributeValueContainsToken(this.schema.targetAttribute, targetDescriptor)\n }\n\n private deprecate<T>(element: T, targetName: string) {\n if (element) {\n const { identifier } = this\n const attributeName = this.schema.targetAttribute\n const revisedAttributeName = this.schema.targetAttributeForScope(identifier)\n this.guide.warn(\n element,\n `target:${targetName}`,\n `Please replace ${attributeName}=\"${identifier}.${targetName}\" with ${revisedAttributeName}=\"${targetName}\". ` +\n `The ${attributeName} attribute is deprecated and will be removed in a future version of Stimulus.`\n )\n }\n return element\n }\n\n private get guide() {\n return this.scope.guide\n }\n}\n","import { Scope } from \"./scope\"\n\nexport class OutletSet {\n readonly scope: Scope\n readonly controllerElement: Element\n\n constructor(scope: Scope, controllerElement: Element) {\n this.scope = scope\n this.controllerElement = controllerElement\n }\n\n get element() {\n return this.scope.element\n }\n\n get identifier() {\n return this.scope.identifier\n }\n\n get schema() {\n return this.scope.schema\n }\n\n has(outletName: string) {\n return this.find(outletName) != null\n }\n\n find(...outletNames: string[]) {\n return outletNames.reduce(\n (outlet, outletName) => outlet || this.findOutlet(outletName),\n undefined as Element | undefined\n )\n }\n\n findAll(...outletNames: string[]) {\n return outletNames.reduce(\n (outlets, outletName) => [...outlets, ...this.findAllOutlets(outletName)],\n [] as Element[]\n )\n }\n\n getSelectorForOutletName(outletName: string) {\n const attributeName = this.schema.outletAttributeForScope(this.identifier, outletName)\n return this.controllerElement.getAttribute(attributeName)\n }\n\n private findOutlet(outletName: string) {\n const selector = this.getSelectorForOutletName(outletName)\n if (selector) return this.findElement(selector, outletName)\n }\n\n private findAllOutlets(outletName: string) {\n const selector = this.getSelectorForOutletName(outletName)\n return selector ? this.findAllElements(selector, outletName) : []\n }\n\n private findElement(selector: string, outletName: string): Element | undefined {\n const elements = this.scope.queryElements(selector)\n return elements.filter((element) => this.matchesElement(element, selector, outletName))[0]\n }\n\n private findAllElements(selector: string, outletName: string): Element[] {\n const elements = this.scope.queryElements(selector)\n return elements.filter((element) => this.matchesElement(element, selector, outletName))\n }\n\n private matchesElement(element: Element, selector: string, outletName: string): boolean {\n const controllerAttribute = element.getAttribute(this.scope.schema.controllerAttribute) || \"\"\n return element.matches(selector) && controllerAttribute.split(\" \").includes(outletName)\n }\n}\n","import { ClassMap } from \"./class_map\"\nimport { DataMap } from \"./data_map\"\nimport { Guide } from \"./guide\"\nimport { Logger } from \"./logger\"\nimport { Schema } from \"./schema\"\nimport { attributeValueContainsToken } from \"./selectors\"\nimport { TargetSet } from \"./target_set\"\nimport { OutletSet } from \"./outlet_set\"\n\nexport class Scope {\n readonly schema: Schema\n readonly element: Element\n readonly identifier: string\n readonly guide: Guide\n readonly outlets: OutletSet\n readonly targets = new TargetSet(this)\n readonly classes = new ClassMap(this)\n readonly data = new DataMap(this)\n\n constructor(schema: Schema, element: Element, identifier: string, logger: Logger) {\n this.schema = schema\n this.element = element\n this.identifier = identifier\n this.guide = new Guide(logger)\n this.outlets = new OutletSet(this.documentScope, element)\n }\n\n findElement(selector: string): Element | undefined {\n return this.element.matches(selector) ? this.element : this.queryElements(selector).find(this.containsElement)\n }\n\n findAllElements(selector: string): Element[] {\n return [\n ...(this.element.matches(selector) ? [this.element] : []),\n ...this.queryElements(selector).filter(this.containsElement),\n ]\n }\n\n containsElement = (element: Element): boolean => {\n return element.closest(this.controllerSelector) === this.element\n }\n\n queryElements(selector: string): Element[] {\n return Array.from(this.element.querySelectorAll(selector))\n }\n\n private get controllerSelector(): string {\n return attributeValueContainsToken(this.schema.controllerAttribute, this.identifier)\n }\n\n private get isDocumentScope() {\n return this.element === document.documentElement\n }\n\n private get documentScope(): Scope {\n return this.isDocumentScope\n ? this\n : new Scope(this.schema, document.documentElement, this.identifier, this.guide.logger)\n }\n}\n","import { ErrorHandler } from \"./error_handler\"\nimport { Schema } from \"./schema\"\nimport { Scope } from \"./scope\"\nimport { Token, ValueListObserver, ValueListObserverDelegate } from \"../mutation-observers\"\n\nexport interface ScopeObserverDelegate extends ErrorHandler {\n createScopeForElementAndIdentifier(element: Element, identifier: string): Scope\n scopeConnected(scope: Scope): void\n scopeDisconnected(scope: Scope): void\n}\n\nexport class ScopeObserver implements ValueListObserverDelegate<Scope> {\n readonly element: Element\n readonly schema: Schema\n private delegate: ScopeObserverDelegate\n private valueListObserver: ValueListObserver<Scope>\n private scopesByIdentifierByElement: WeakMap<Element, Map<string, Scope>>\n private scopeReferenceCounts: WeakMap<Scope, number>\n\n constructor(element: Element, schema: Schema, delegate: ScopeObserverDelegate) {\n this.element = element\n this.schema = schema\n this.delegate = delegate\n this.valueListObserver = new ValueListObserver(this.element, this.controllerAttribute, this)\n this.scopesByIdentifierByElement = new WeakMap()\n this.scopeReferenceCounts = new WeakMap()\n }\n\n start() {\n this.valueListObserver.start()\n }\n\n stop() {\n this.valueListObserver.stop()\n }\n\n get controllerAttribute() {\n return this.schema.controllerAttribute\n }\n\n // Value observer delegate\n\n parseValueForToken(token: Token): Scope | undefined {\n const { element, content: identifier } = token\n const scopesByIdentifier = this.fetchScopesByIdentifierForElement(element)\n\n let scope = scopesByIdentifier.get(identifier)\n if (!scope) {\n scope = this.delegate.createScopeForElementAndIdentifier(element, identifier)\n scopesByIdentifier.set(identifier, scope)\n }\n\n return scope\n }\n\n elementMatchedValue(element: Element, value: Scope) {\n const referenceCount = (this.scopeReferenceCounts.get(value) || 0) + 1\n this.scopeReferenceCounts.set(value, referenceCount)\n if (referenceCount == 1) {\n this.delegate.scopeConnected(value)\n }\n }\n\n elementUnmatchedValue(element: Element, value: Scope) {\n const referenceCount = this.scopeReferenceCounts.get(value)\n if (referenceCount) {\n this.scopeReferenceCounts.set(value, referenceCount - 1)\n if (referenceCount == 1) {\n this.delegate.scopeDisconnected(value)\n }\n }\n }\n\n private fetchScopesByIdentifierForElement(element: Element) {\n let scopesByIdentifier = this.scopesByIdentifierByElement.get(element)\n if (!scopesByIdentifier) {\n scopesByIdentifier = new Map()\n this.scopesByIdentifierByElement.set(element, scopesByIdentifier)\n }\n return scopesByIdentifier\n }\n}\n","import { Application } from \"./application\"\nimport { Context } from \"./context\"\nimport { Definition } from \"./definition\"\nimport { Module } from \"./module\"\nimport { Multimap } from \"../multimap\"\nimport { Scope } from \"./scope\"\nimport { ScopeObserver, ScopeObserverDelegate } from \"./scope_observer\"\n\nexport class Router implements ScopeObserverDelegate {\n readonly application: Application\n private scopeObserver: ScopeObserver\n private scopesByIdentifier: Multimap<string, Scope>\n private modulesByIdentifier: Map<string, Module>\n\n constructor(application: Application) {\n this.application = application\n this.scopeObserver = new ScopeObserver(this.element, this.schema, this)\n this.scopesByIdentifier = new Multimap()\n this.modulesByIdentifier = new Map()\n }\n\n get element() {\n return this.application.element\n }\n\n get schema() {\n return this.application.schema\n }\n\n get logger() {\n return this.application.logger\n }\n\n get controllerAttribute(): string {\n return this.schema.controllerAttribute\n }\n\n get modules() {\n return Array.from(this.modulesByIdentifier.values())\n }\n\n get contexts() {\n return this.modules.reduce((contexts, module) => contexts.concat(module.contexts), [] as Context[])\n }\n\n start() {\n this.scopeObserver.start()\n }\n\n stop() {\n this.scopeObserver.stop()\n }\n\n loadDefinition(definition: Definition) {\n this.unloadIdentifier(definition.identifier)\n const module = new Module(this.application, definition)\n this.connectModule(module)\n const afterLoad = (definition.controllerConstructor as any).afterLoad\n if (afterLoad) {\n afterLoad(definition.identifier, this.application)\n }\n }\n\n unloadIdentifier(identifier: string) {\n const module = this.modulesByIdentifier.get(identifier)\n if (module) {\n this.disconnectModule(module)\n }\n }\n\n getContextForElementAndIdentifier(element: Element, identifier: string) {\n const module = this.modulesByIdentifier.get(identifier)\n if (module) {\n return module.contexts.find((context) => context.element == element)\n }\n }\n\n // Error handler delegate\n\n handleError(error: Error, message: string, detail: any) {\n this.application.handleError(error, message, detail)\n }\n\n // Scope observer delegate\n\n createScopeForElementAndIdentifier(element: Element, identifier: string) {\n return new Scope(this.schema, element, identifier, this.logger)\n }\n\n scopeConnected(scope: Scope) {\n this.scopesByIdentifier.add(scope.identifier, scope)\n const module = this.modulesByIdentifier.get(scope.identifier)\n if (module) {\n module.connectContextForScope(scope)\n }\n }\n\n scopeDisconnected(scope: Scope) {\n this.scopesByIdentifier.delete(scope.identifier, scope)\n const module = this.modulesByIdentifier.get(scope.identifier)\n if (module) {\n module.disconnectContextForScope(scope)\n }\n }\n\n // Modules\n\n private connectModule(module: Module) {\n this.modulesByIdentifier.set(module.identifier, module)\n const scopes = this.scopesByIdentifier.getValuesForKey(module.identifier)\n scopes.forEach((scope) => module.connectContextForScope(scope))\n }\n\n private disconnectModule(module: Module) {\n this.modulesByIdentifier.delete(module.identifier)\n const scopes = this.scopesByIdentifier.getValuesForKey(module.identifier)\n scopes.forEach((scope) => module.disconnectContextForScope(scope))\n }\n}\n","export interface Schema {\n controllerAttribute: string\n actionAttribute: string\n targetAttribute: string\n targetAttributeForScope(identifier: string): string\n outletAttributeForScope(identifier: string, outlet: string): string\n keyMappings: { [key: string]: string }\n}\n\nexport const defaultSchema: Schema = {\n controllerAttribute: \"data-controller\",\n actionAttribute: \"data-action\",\n targetAttribute: \"data-target\",\n targetAttributeForScope: (identifier) => `data-${identifier}-target`,\n outletAttributeForScope: (identifier, outlet) => `data-${identifier}-${outlet}-outlet`,\n keyMappings: {\n enter: \"Enter\",\n tab: \"Tab\",\n esc: \"Escape\",\n space: \" \",\n up: \"ArrowUp\",\n down: \"ArrowDown\",\n left: \"ArrowLeft\",\n right: \"ArrowRight\",\n home: \"Home\",\n end: \"End\",\n // [a-z]\n ...objectFromEntries(\"abcdefghijklmnopqrstuvwxyz\".split(\"\").map((c) => [c, c])),\n // [0-9]\n ...objectFromEntries(\"0123456789\".split(\"\").map((n) => [n, n])),\n },\n}\n\nfunction objectFromEntries(array: [string, any][]): object {\n // polyfill\n return array.reduce((memo, [k, v]) => ({ ...memo, [k]: v }), {})\n}\n","import { Controller, ControllerConstructor } from \"./controller\"\nimport { Definition } from \"./definition\"\nimport { Dispatcher } from \"./dispatcher\"\nimport { ErrorHandler } from \"./error_handler\"\nimport { Logger } from \"./logger\"\nimport { Router } from \"./router\"\nimport { Schema, defaultSchema } from \"./schema\"\nimport { ActionDescriptorFilter, ActionDescriptorFilters, defaultActionDescriptorFilters } from \"./action_descriptor\"\n\nexport class Application implements ErrorHandler {\n readonly element: Element\n readonly schema: Schema\n readonly dispatcher: Dispatcher\n readonly router: Router\n readonly actionDescriptorFilters: ActionDescriptorFilters\n logger: Logger = console\n debug = false\n\n static start(element?: Element, schema?: Schema): Application {\n const application = new this(element, schema)\n application.start()\n return application\n }\n\n constructor(element: Element = document.documentElement, schema: Schema = defaultSchema) {\n this.element = element\n this.schema = schema\n this.dispatcher = new Dispatcher(this)\n this.router = new Router(this)\n this.actionDescriptorFilters = { ...defaultActionDescriptorFilters }\n }\n\n async start() {\n await domReady()\n this.logDebugActivity(\"application\", \"starting\")\n this.dispatcher.start()\n this.router.start()\n this.logDebugActivity(\"application\", \"start\")\n }\n\n stop() {\n this.logDebugActivity(\"application\", \"stopping\")\n this.dispatcher.stop()\n this.router.stop()\n this.logDebugActivity(\"application\", \"stop\")\n }\n\n register(identifier: string, controllerConstructor: ControllerConstructor) {\n this.load({ identifier, controllerConstructor })\n }\n\n registerActionOption(name: string, filter: ActionDescriptorFilter) {\n this.actionDescriptorFilters[name] = filter\n }\n\n load(...definitions: Definition[]): void\n load(definitions: Definition[]): void\n load(head: Definition | Definition[], ...rest: Definition[]) {\n const definitions = Array.isArray(head) ? head : [head, ...rest]\n definitions.forEach((definition) => {\n if ((definition.controllerConstructor as any).shouldLoad) {\n this.router.loadDefinition(definition)\n }\n })\n }\n\n unload(...identifiers: string[]): void\n unload(identifiers: string[]): void\n unload(head: string | string[], ...rest: string[]) {\n const identifiers = Array.isArray(head) ? head : [head, ...rest]\n identifiers.forEach((identifier) => this.router.unloadIdentifier(identifier))\n }\n\n // Controllers\n\n get controllers(): Controller[] {\n return this.router.contexts.map((context) => context.controller)\n }\n\n getControllerForElementAndIdentifier(element: Element, identifier: string): Controller | null {\n const context = this.router.getContextForElementAndIdentifier(element, identifier)\n return context ? context.controller : null\n }\n\n // Error handling\n\n handleError(error: Error, message: string, detail: object) {\n this.logger.error(`%s\\n\\n%o\\n\\n%o`, message, error, detail)\n\n window.onerror?.(message, \"\", 0, 0, error)\n }\n\n // Debug logging\n\n logDebugActivity = (identifier: string, functionName: string, detail: object = {}): void => {\n if (this.debug) {\n this.logFormattedMessage(identifier, functionName, detail)\n }\n }\n\n private logFormattedMessage(identifier: string, functionName: string, detail: object = {}) {\n detail = Object.assign({ application: this }, detail)\n\n this.logger.groupCollapsed(`${identifier} #${functionName}`)\n this.logger.log(\"details:\", { ...detail })\n this.logger.groupEnd()\n }\n}\n\nfunction domReady() {\n return new Promise<void>((resolve) => {\n if (document.readyState == \"loading\") {\n document.addEventListener(\"DOMContentLoaded\", () => resolve())\n } else {\n resolve()\n }\n })\n}\n","import { Constructor } from \"./constructor\"\nimport { Controller } from \"./controller\"\nimport { readInheritableStaticObjectPairs } from \"./inheritable_statics\"\nimport { camelize, capitalize, dasherize } from \"./string_helpers\"\n\nexport function ValuePropertiesBlessing<T>(constructor: Constructor<T>) {\n const valueDefinitionPairs = readInheritableStaticObjectPairs<T, ValueTypeDefinition>(constructor, \"values\")\n const propertyDescriptorMap: PropertyDescriptorMap = {\n valueDescriptorMap: {\n get(this: Controller) {\n return valueDefinitionPairs.reduce((result, valueDefinitionPair) => {\n const valueDescriptor = parseValueDefinitionPair(valueDefinitionPair, this.identifier)\n const attributeName = this.data.getAttributeNameForKey(valueDescriptor.key)\n return Object.assign(result, { [attributeName]: valueDescriptor })\n }, {} as ValueDescriptorMap)\n },\n },\n }\n\n return valueDefinitionPairs.reduce((properties, valueDefinitionPair) => {\n return Object.assign(properties, propertiesForValueDefinitionPair(valueDefinitionPair))\n }, propertyDescriptorMap)\n}\n\nexport function propertiesForValueDefinitionPair<T>(\n valueDefinitionPair: ValueDefinitionPair,\n controller?: string\n): PropertyDescriptorMap {\n const definition = parseValueDefinitionPair(valueDefinitionPair, controller)\n const { key, name, reader: read, writer: write } = definition\n\n return {\n [name]: {\n get(this: Controller) {\n const value = this.data.get(key)\n if (value !== null) {\n return read(value)\n } else {\n return definition.defaultValue\n }\n },\n\n set(this: Controller, value: T | undefined) {\n if (value === undefined) {\n this.data.delete(key)\n } else {\n this.data.set(key, write(value))\n }\n },\n },\n\n [`has${capitalize(name)}`]: {\n get(this: Controller): boolean {\n return this.data.has(key) || definition.hasCustomDefaultValue\n },\n },\n }\n}\n\nexport type ValueDescriptor = {\n type: ValueType\n key: string\n name: string\n defaultValue: ValueTypeDefault\n hasCustomDefaultValue: boolean\n reader: Reader\n writer: Writer\n}\n\nexport type ValueDescriptorMap = { [attributeName: string]: ValueDescriptor }\n\nexport type ValueDefinitionMap = { [token: string]: ValueTypeDefinition }\n\nexport type ValueDefinitionPair = [string, ValueTypeDefinition]\n\nexport type ValueTypeConstant = typeof Array | typeof Boolean | typeof Number | typeof Object | typeof String\n\nexport type ValueTypeDefault = Array<any> | boolean | number | Object | string\n\nexport type ValueTypeObject = { type: ValueTypeConstant; default: ValueTypeDefault }\n\nexport type ValueTypeDefinition = ValueTypeConstant | ValueTypeDefault | ValueTypeObject\n\nexport type ValueType = \"array\" | \"boolean\" | \"number\" | \"object\" | \"string\"\n\nfunction parseValueDefinitionPair([token, typeDefinition]: ValueDefinitionPair, controller?: string): ValueDescriptor {\n return valueDescriptorForTokenAndTypeDefinition({\n controller,\n token,\n typeDefinition,\n })\n}\n\nfunction parseValueTypeConstant(constant: ValueTypeConstant) {\n switch (constant) {\n case Array:\n return \"array\"\n case Boolean:\n return \"boolean\"\n case Number:\n return \"number\"\n case Object:\n return \"object\"\n case String:\n return \"string\"\n }\n}\n\nfunction parseValueTypeDefault(defaultValue: ValueTypeDefault) {\n switch (typeof defaultValue) {\n case \"boolean\":\n return \"boolean\"\n case \"number\":\n return \"number\"\n case \"string\":\n return \"string\"\n }\n\n if (Array.isArray(defaultValue)) return \"array\"\n if (Object.prototype.toString.call(defaultValue) === \"[object Object]\") return \"object\"\n}\n\nfunction parseValueTypeObject(payload: { controller?: string; token: string; typeObject: ValueTypeObject }) {\n const typeFromObject = parseValueTypeConstant(payload.typeObject.type)\n\n if (!typeFromObject) return\n\n const defaultValueType = parseValueTypeDefault(payload.typeObject.default)\n\n if (typeFromObject !== defaultValueType) {\n const propertyPath = payload.controller ? `${payload.controller}.${payload.token}` : payload.token\n\n throw new Error(\n `The specified default value for the Stimulus Value \"${propertyPath}\" must match the defined type \"${typeFromObject}\". The provided default value of \"${payload.typeObject.default}\" is of type \"${defaultValueType}\".`\n )\n }\n\n return typeFromObject\n}\n\nfunction parseValueTypeDefinition(payload: {\n controller?: string\n token: string\n typeDefinition: ValueTypeDefinition\n}): ValueType {\n const typeFromObject = parseValueTypeObject({\n controller: payload.controller,\n token: payload.token,\n typeObject: payload.typeDefinition as ValueTypeObject,\n })\n const typeFromDefaultValue = parseValueTypeDefault(payload.typeDefinition as ValueTypeDefault)\n const typeFromConstant = parseValueTypeConstant(payload.typeDefinition as ValueTypeConstant)\n\n const type = typeFromObject || typeFromDefaultValue || typeFromConstant\n\n if (type) return type\n\n const propertyPath = payload.controller ? `${payload.controller}.${payload.typeDefinition}` : payload.token\n\n throw new Error(`Unknown value type \"${propertyPath}\" for \"${payload.token}\" value`)\n}\n\nfunction defaultValueForDefinition(typeDefinition: ValueTypeDefinition): ValueTypeDefault {\n const constant = parseValueTypeConstant(typeDefinition as ValueTypeConstant)\n\n if (constant) return defaultValuesByType[constant]\n\n const defaultValue = (typeDefinition as ValueTypeObject).default\n if (defaultValue !== undefined) return defaultValue\n\n return typeDefinition\n}\n\nfunction valueDescriptorForTokenAndTypeDefinition(payload: {\n token: string\n typeDefinition: ValueTypeDefinition\n controller?: string\n}) {\n const key = `${dasherize(payload.token)}-value`\n const type = parseValueTypeDefinition(payload)\n return {\n type,\n key,\n name: camelize(key),\n get defaultValue() {\n return defaultValueForDefinition(payload.typeDefinition)\n },\n get hasCustomDefaultValue() {\n return parseValueTypeDefault(payload.typeDefinition) !== undefined\n },\n reader: readers[type],\n writer: writers[type] || writers.default,\n }\n}\n\nconst defaultValuesByType = {\n get array() {\n return []\n },\n boolean: false,\n number: 0,\n get object() {\n return {}\n },\n string: \"\",\n}\n\ntype Reader = (value: string) => any\n\nconst readers: { [type: string]: Reader } = {\n array(value: string): any[] {\n const array = JSON.parse(value)\n if (!Array.isArray(array)) {\n throw new TypeError(\n `expected value of type \"array\" but instead got value \"${value}\" of type \"${parseValueTypeDefault(array)}\"`\n )\n }\n return array\n },\n\n boolean(value: string): boolean {\n return !(value == \"0\" || String(value).toLowerCase() == \"false\")\n },\n\n number(value: string): number {\n return Number(value)\n },\n\n object(value: string): object {\n const object = JSON.parse(value)\n if (object === null || typeof object != \"object\" || Array.isArray(object)) {\n throw new TypeError(\n `expected value of type \"object\" but instead got value \"${value}\" of type \"${parseValueTypeDefault(object)}\"`\n )\n }\n return object\n },\n\n string(value: string): string {\n return value\n },\n}\n\ntype Writer = (value: any) => string\n\nconst writers: { [type: string]: Writer } = {\n default: writeString,\n array: writeJSON,\n object: writeJSON,\n}\n\nfunction writeJSON(value: any) {\n return JSON.stringify(value)\n}\n\nfunction writeString(value: any) {\n return `${value}`\n}\n","import { Application } from \"./application\"\nimport { ClassPropertiesBlessing } from \"./class_properties\"\nimport { Constructor } from \"./constructor\"\nimport { Context } from \"./context\"\nimport { OutletPropertiesBlessing } from \"./outlet_properties\"\nimport { TargetPropertiesBlessing } from \"./target_properties\"\nimport { ValuePropertiesBlessing, ValueDefinitionMap } from \"./value_properties\"\n\nexport type ControllerConstructor = Constructor<Controller>\n\nexport class Controller<ElementType extends Element = Element> {\n static blessings = [\n ClassPropertiesBlessing,\n TargetPropertiesBlessing,\n ValuePropertiesBlessing,\n OutletPropertiesBlessing,\n ]\n static targets: string[] = []\n static outlets: string[] = []\n static values: ValueDefinitionMap = {}\n\n static get shouldLoad() {\n return true\n }\n\n static afterLoad(_identifier: string, _application: Application) {\n return\n }\n\n readonly context: Context\n\n constructor(context: Context) {\n this.context = context\n }\n\n get application() {\n return this.context.application\n }\n\n get scope() {\n return this.context.scope\n }\n\n get element() {\n return this.scope.element as ElementType\n }\n\n get identifier() {\n return this.scope.identifier\n }\n\n get targets() {\n return this.scope.targets\n }\n\n get outlets() {\n return this.scope.outlets\n }\n\n get classes() {\n return this.scope.classes\n }\n\n get data() {\n return this.scope.data\n }\n\n initialize() {\n // Override in your subclass to set up initial controller state\n }\n\n connect() {\n // Override in your subclass to respond when the controller is connected to the DOM\n }\n\n disconnect() {\n // Override in your subclass to respond when the controller is disconnected from the DOM\n }\n\n dispatch(\n eventName: string,\n { target = this.element, detail = {}, prefix = this.identifier, bubbles = true, cancelable = true } = {}\n ) {\n const type = prefix ? `${prefix}:${eventName}` : eventName\n const event = new CustomEvent(type, { detail, bubbles, cancelable })\n target.dispatchEvent(event)\n return event\n }\n}\n","import { Constructor } from \"./constructor\"\nimport { Controller } from \"./controller\"\nimport { readInheritableStaticArrayValues } from \"./inheritable_statics\"\nimport { capitalize } from \"./string_helpers\"\n\nexport function ClassPropertiesBlessing<T>(constructor: Constructor<T>) {\n const classes = readInheritableStaticArrayValues(constructor, \"classes\")\n return classes.reduce((properties, classDefinition) => {\n return Object.assign(properties, propertiesForClassDefinition(classDefinition))\n }, {} as PropertyDescriptorMap)\n}\n\nfunction propertiesForClassDefinition(key: string) {\n return {\n [`${key}Class`]: {\n get(this: Controller) {\n const { classes } = this\n if (classes.has(key)) {\n return classes.get(key)\n } else {\n const attribute = classes.getAttributeName(key)\n throw new Error(`Missing attribute \"${attribute}\"`)\n }\n },\n },\n\n [`${key}Classes`]: {\n get(this: Controller) {\n return this.classes.getAll(key)\n },\n },\n\n [`has${capitalize(key)}Class`]: {\n get(this: Controller) {\n return this.classes.has(key)\n },\n },\n }\n}\n","import { Constructor } from \"./constructor\"\nimport { Controller } from \"./controller\"\nimport { readInheritableStaticArrayValues } from \"./inheritable_statics\"\nimport { capitalize } from \"./string_helpers\"\n\nexport function TargetPropertiesBlessing<T>(constructor: Constructor<T>) {\n const targets = readInheritableStaticArrayValues(constructor, \"targets\")\n return targets.reduce((properties, targetDefinition) => {\n return Object.assign(properties, propertiesForTargetDefinition(targetDefinition))\n }, {} as PropertyDescriptorMap)\n}\n\nfunction propertiesForTargetDefinition(name: string) {\n return {\n [`${name}Target`]: {\n get(this: Controller) {\n const target = this.targets.find(name)\n if (target) {\n return target\n } else {\n throw new Error(`Missing target element \"${name}\" for \"${this.identifier}\" controller`)\n }\n },\n },\n\n [`${name}Targets`]: {\n get(this: Controller) {\n return this.targets.findAll(name)\n },\n },\n\n [`has${capitalize(name)}Target`]: {\n get(this: Controller) {\n return this.targets.has(name)\n },\n },\n }\n}\n","import { Constructor } from \"./constructor\"\nimport { Controller } from \"./controller\"\nimport { readInheritableStaticArrayValues } from \"./inheritable_statics\"\nimport { capitalize, namespaceCamelize } from \"./string_helpers\"\n\nexport function OutletPropertiesBlessing<T>(constructor: Constructor<T>) {\n const outlets = readInheritableStaticArrayValues(constructor, \"outlets\")\n return outlets.reduce((properties: any, outletDefinition: any) => {\n return Object.assign(properties, propertiesForOutletDefinition(outletDefinition))\n }, {} as PropertyDescriptorMap)\n}\n\nfunction propertiesForOutletDefinition(name: string) {\n const camelizedName = namespaceCamelize(name)\n\n return {\n [`${camelizedName}Outlet`]: {\n get(this: Controller) {\n const outlet = this.outlets.find(name)\n\n if (outlet) {\n const outletController = this.application.getControllerForElementAndIdentifier(outlet, name)\n if (outletController) {\n return outletController\n } else {\n throw new Error(\n `Missing \"data-controller=${name}\" attribute on outlet element for \"${this.identifier}\" controller`\n )\n }\n }\n\n throw new Error(`Missing outlet element \"${name}\" for \"${this.identifier}\" controller`)\n },\n },\n\n [`${camelizedName}Outlets`]: {\n get(this: Controller) {\n const outlets = this.outlets.findAll(name)\n\n if (outlets.length > 0) {\n return outlets\n .map((outlet: Element) => {\n const controller = this.application.getControllerForElementAndIdentifier(outlet, name)\n if (controller) {\n return controller\n } else {\n console.warn(\n `The provided outlet element is missing the outlet controller \"${name}\" for \"${this.identifier}\"`,\n outlet\n )\n }\n })\n .filter((controller) => controller) as Controller[]\n }\n\n return []\n },\n },\n\n [`${camelizedName}OutletElement`]: {\n get(this: Controller) {\n const outlet = this.outlets.find(name)\n if (outlet) {\n return outlet\n } else {\n throw new Error(`Missing outlet element \"${name}\" for \"${this.identifier}\" controller`)\n }\n },\n },\n\n [`${camelizedName}OutletElements`]: {\n get(this: Controller) {\n return this.outlets.findAll(name)\n },\n },\n\n [`has${capitalize(camelizedName)}Outlet`]: {\n get(this: Controller) {\n return this.outlets.has(name)\n },\n },\n }\n}\n"],"names":["EventListener","constructor","eventTarget","eventName","eventOptions","this","unorderedBindings","Set","connect","addEventListener","disconnect","removeEventListener","bindingConnected","binding","add","bindingDisconnected","delete","handleEvent","event","extendedEvent","stopImmediatePropagation","Object","assign","immediatePropagationStopped","call","extendEvent","bindings","hasBindings","size","Array","from","sort","left","right","leftIndex","index","rightIndex","Dispatcher","application","eventListenerMaps","Map","started","start","eventListeners","forEach","eventListener","stop","values","reduce","listeners","map","concat","fetchEventListenerForBinding","clearEventListeners","clearEventListenersForBinding","handleError","error","message","detail","removeMappedEventListenerFor","eventListenerMap","fetchEventListenerMapForEventTarget","cacheKey","fetchEventListener","get","createEventListener","set","parts","keys","key","push","join","defaultActionDescriptorFilters","value","stopPropagation","prevent","preventDefault","self","element","target","descriptorPattern","parseEventTarget","eventTargetName","window","document","camelize","replace","_","char","toUpperCase","namespaceCamelize","capitalize","charAt","slice","dasherize","toLowerCase","defaultEventNames","a","button","form","details","input","e","getAttribute","select","textarea","Error","typecast","JSON","parse","o_O","Binding","context","action","identifier","willBeInvokedByEvent","applyEventModifiers","invokeWithEvent","method","controller","methodName","actionDescriptorFilters","passes","name","entries","filter","currentTarget","params","actionEvent","logDebugActivity","KeyboardEvent","isFilterTarget","Element","contains","scope","containsElement","ElementObserver","delegate","attributes","childList","subtree","elements","mutationObserver","MutationObserver","mutations","processMutations","observe","mutationObserverInit","refresh","pause","callback","takeRecords","matches","matchElementsInTree","has","removeElement","addElement","mutation","processMutation","type","processAttributeChange","attributeName","processRemovedNodes","removedNodes","processAddedNodes","addedNodes","node","elementAttributeChanged","matchElement","nodes","elementFromNode","processTree","elementIsActive","tree","processor","nodeType","Node","ELEMENT_NODE","isConnected","elementMatched","elementUnmatched","AttributeObserver","elementObserver","selector","hasAttribute","match","querySelectorAll","elementMatchedAttribute","elementUnmatchedAttribute","elementAttributeValueChanged","fetch","del","prune","Multimap","valuesByKey","hasKey","hasValue","some","getValuesForKey","getKeysForValue","_key","_values","IndexedMultimap","super","keysByValue","SelectorObserver","matchesByElement","selectorMatchElement","selectorMatched","selectorUnmatched","_attributeName","matchedBefore","StringMapObserver","stringMap","attributeOldValue","knownAttributeNames","refreshAttribute","oldValue","getStringMapKeyForAttribute","stringMapKeyAdded","stringMapValueChanged","stringMapKeyRemoved","currentAttributeNames","recordedAttributeNames","attribute","TokenListObserver","attributeObserver","tokensByElement","tokensMatched","readTokensForElement","unmatchedTokens","matchedTokens","refreshTokensForElement","tokensUnmatched","tokens","token","tokenMatched","tokenUnmatched","previousTokens","currentTokens","firstDifferingIndex","length","Math","max","zip","findIndex","previousToken","currentToken","content","tokenString","trim","split","parseTokenString","ValueListObserver","tokenListObserver","parseResultsByToken","WeakMap","valuesByTokenByElement","fetchParseResultForToken","fetchValuesByTokenForElement","elementMatchedValue","elementUnmatchedValue","parseResult","parseToken","valuesByToken","parseValueForToken","BindingObserver","bindingsByAction","valueListObserver","actionAttribute","disconnectAllActions","schema","connectAction","disconnectAction","clear","descriptor","tagName","getDefaultEventNameForElement","keyFilter","forToken","descriptorString","includes","options","test","parseActionDescriptorString","toString","eventFilter","filteres","modifiers","meta","ctrl","alt","shift","modifier","metaKey","ctrlKey","altKey","shiftKey","standardFilter","prototype","hasOwnProperty","keyMappings","pattern","RegExp","ValueObserver","receiver","stringMapObserver","valueDescriptorMap","invokeChangedCallbacksForDefaultValues","invokeChangedCallback","writer","defaultValue","valueDescriptorNameMap","valueDescriptors","undefined","data","rawValue","rawOldValue","changedMethodName","changedMethod","reader","TypeError","descriptors","hasMethodName","TargetObserver","targetsByName","disconnectAllTargets","connectTarget","disconnectTarget","targetConnected","targetDisconnected","readInheritableStaticArrayValues","propertyName","ancestors","getAncestorsForConstructor","definition","isArray","getOwnStaticArrayValues","readInheritableStaticObjectPairs","pairs","getOwnStaticObjectPairs","getPrototypeOf","reverse","OutletObserver","outletsByName","outletElementsByName","selectorObserverMap","outletDefinitions","outletName","body","observer","dependentContexts","disconnectAllOutlets","_selector","outlet","getOutlet","connectOutlet","getOutletFromMap","disconnectOutlet","hasOutlet","controllerAttribute","outletConnected","outletDisconnected","outlets","getSelectorForOutletName","outletDependencies","dependencies","router","modules","module","controllerConstructor","dependentControllerIdentifiers","identifiers","contexts","getControllerForElementAndIdentifier","find","Context","functionName","bindingObserver","dispatcher","valueObserver","targetObserver","outletObserver","initialize","parentElement","invokeControllerMethod","args","bless","properties","shadowConstructor","extend","shadowProperties","getOwnKeys","shadowingDescriptor","getOwnPropertyDescriptor","getShadowedDescriptor","getShadowProperties","defineProperties","shadow","blessedProperties","blessing","getBlessedProperties","getOwnPropertySymbols","object","getOwnPropertyNames","extendWithReflect","extended","Reflect","construct","arguments","create","setPrototypeOf","b","testReflectExtension","Module","blessDefinition","contextsByScope","connectedContexts","connectContextForScope","fetchContextForScope","disconnectContextForScope","ClassMap","getDataKey","getAll","getAttributeName","getAttributeNameForKey","DataMap","setAttribute","removeAttribute","Guide","logger","warn","warnedKeys","warnedKeysByObject","attributeValueContainsToken","TargetSet","targetName","targetNames","findTarget","findLegacyTarget","findAll","targets","findAllTargets","findAllLegacyTargets","getSelectorForTargetName","findElement","findAllElements","targetAttributeForScope","getLegacySelectorForTargetName","deprecate","targetDescriptor","targetAttribute","revisedAttributeName","guide","OutletSet","controllerElement","outletNames","findOutlet","findAllOutlets","outletAttributeForScope","queryElements","matchesElement","Scope","closest","controllerSelector","documentScope","isDocumentScope","documentElement","ScopeObserver","scopesByIdentifierByElement","scopeReferenceCounts","scopesByIdentifier","fetchScopesByIdentifierForElement","createScopeForElementAndIdentifier","referenceCount","scopeConnected","scopeDisconnected","Router","scopeObserver","modulesByIdentifier","loadDefinition","unloadIdentifier","connectModule","afterLoad","disconnectModule","getContextForElementAndIdentifier","defaultSchema","enter","tab","esc","space","up","down","home","end","objectFromEntries","c","n","array","memo","k","v","Application","console","debug","logFormattedMessage","Promise","resolve","readyState","register","load","registerActionOption","head","rest","shouldLoad","unload","controllers","onerror","groupCollapsed","log","groupEnd","parseValueDefinitionPair","typeDefinition","payload","typeFromObject","parseValueTypeConstant","typeObject","defaultValueType","parseValueTypeDefault","default","propertyPath","parseValueTypeObject","typeFromDefaultValue","typeFromConstant","parseValueTypeDefinition","constant","defaultValuesByType","defaultValueForDefinition","hasCustomDefaultValue","readers","writers","valueDescriptorForTokenAndTypeDefinition","Boolean","Number","String","boolean","number","string","writeJSON","stringify","Controller","_identifier","_application","classes","dispatch","prefix","bubbles","cancelable","CustomEvent","dispatchEvent","classDefinition","targetDefinition","valueDefinitionPairs","propertyDescriptorMap","result","valueDefinitionPair","valueDescriptor","read","write","propertiesForValueDefinitionPair","outletDefinition","camelizedName","outletController","propertiesForOutletDefinition"],"mappings":"MAEaA,EAMXC,YAAYC,EAA0BC,EAAmBC,GACvDC,KAAKH,YAAcA,EACnBG,KAAK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