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ationFrame: any;\r\n\r\nexport type HTMLAnchorElementTarget = '_self' | '_blank' | '_parent' | '_top';\r\n\r\nexport type ButtonColor = 'default' | 'berry';\r\n\r\nexport function getCopy(): string {\r\n return `Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.\r\n Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.\r\n Cras mattis consectetur purus sit amet fermentum. Lorem ipsum dolor sit amet, consectetur adipiscing elit.\r\n Nullam quis risus eget urna mollis ornare vel eu leo.

\r\n Cras mattis consectetur purus sit amet fermentum. Nullam id dolor id nibh ultricies vehicula ut id elit.\r\n Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.\r\n Donec id elit non mi porta gravida at eget metus. Integer posuere erat a ante venenatis dapibus posuere velit aliquet.\r\n Aenean lacinia bibendum nulla sed consectetur.\r\n `;\r\n}\r\n\r\nexport const hasShadowDom = (el: HTMLElement) => {\r\n return !!el.shadowRoot && !!(el as any).attachShadow;\r\n};\r\n\r\n/**\r\n * This method is used to add a hidden input to a host element that contains\r\n * a Shadow DOM. It does not add the input inside of the Shadow root which\r\n * allows it to be picked up inside of forms. It should contain the same\r\n * values as the host element.\r\n *\r\n * @param always Add a hidden input even if the container does not use Shadow\r\n * @param container The element where the input will be added\r\n * @param name The name of the input\r\n * @param value The value of the input\r\n * @param disabled If true, the input is disabled\r\n */\r\nexport const renderHiddenInput = (always: boolean, container: HTMLElement, name: string, value: string | undefined | null, disabled: boolean) => {\r\n if (always || hasShadowDom(container)) {\r\n let input = container.querySelector('input.aux-input') as HTMLInputElement | null;\r\n if (!input) {\r\n input = container.ownerDocument!.createElement('input');\r\n input.type = 'hidden';\r\n input.classList.add('aux-input');\r\n container.appendChild(input);\r\n }\r\n input.disabled = disabled;\r\n input.name = name;\r\n input.value = value || '';\r\n }\r\n};\r\n\r\n\r\n/**\r\n * This method is used for Vitesco's input components that use Shadow DOM. In\r\n * order to properly label the inputs to work with screen readers, we need\r\n * to get the text content of the label outside of the shadow root and pass\r\n * it to the input inside of the shadow root.\r\n *\r\n * Referencing label elements by id from outside of the component is\r\n * impossible due to the shadow boundary, read more here:\r\n * https://developer.salesforce.com/blogs/2020/01/accessibility-for-web-components.html\r\n *\r\n * @param componentEl The shadow element that needs the aria label\r\n * @param inputId The unique identifier for the input\r\n */\r\n export const getAriaLabel = (componentEl: HTMLElement, inputId: string, labelText: string): { label: Element | null, labelId: string, labelText: string | null | undefined } => {\r\n // let labelText;\r\n\r\n // If the user provides their own label via the aria-labelledby attr\r\n // we should use that instead of looking for an ion-label\r\n const labelledBy = componentEl.getAttribute('aria-labelledby');\r\n\r\n // Grab the id off of the component in case they are using\r\n // a custom label using the label element\r\n const componentId = componentEl.id;\r\n\r\n let labelId = labelledBy !== null && labelledBy.trim() !== ''\r\n ? labelledBy\r\n : inputId + '-lbl';\r\n\r\n let label = labelledBy !== null && labelledBy.trim() !== ''\r\n ? document.getElementById(labelledBy)\r\n : null;\r\n\r\n if (label) {\r\n if (labelledBy === null) {\r\n label.id = labelId;\r\n }\r\n\r\n labelText = label.textContent;\r\n label.setAttribute('aria-hidden', 'true');\r\n\r\n // if there is no label, check to see if the user has provided\r\n // one by setting an id on the component and using the label element\r\n } else if (componentId.trim() !== '') {\r\n label = document.querySelector(`label[for=\"${componentId}\"]`);\r\n\r\n if (label) {\r\n if (label.id !== '') {\r\n labelId = label.id;\r\n } else {\r\n label.id = labelId = `${componentId}-lbl`;\r\n }\r\n\r\n labelText = label.textContent;\r\n }\r\n }\r\n\r\n return { label, labelId, labelText };\r\n};\r\n\r\nexport type Attributes = { [key: string]: any };\r\n\r\nexport const debounceEvent = (event: EventEmitter, wait: number): EventEmitter => {\r\n const original = (event as any)._original || event;\r\n return {\r\n _original: event,\r\n emit: debounce(original.emit.bind(original), wait)\r\n } as EventEmitter;\r\n};\r\n\r\nexport const debounce = (func: (...args: any[]) => void, wait = 0) => {\r\n let timer: any;\r\n return (...args: any[]): any => {\r\n clearTimeout(timer);\r\n timer = setTimeout(func, wait, ...args);\r\n };\r\n};\r\n\r\nexport const simpleDebounce = (fn: Function, ms = 300) => {\r\n let timeoutId: ReturnType;\r\n return function (this: any, ...args: any[]) {\r\n clearTimeout(timeoutId);\r\n timeoutId = setTimeout(() => fn.apply(this, args), ms);\r\n };\r\n};\r\n\r\n/**\r\n * Elements inside of web components sometimes need to inherit global attributes\r\n * set on the host. For example, the inner input in `vds-input` should inherit\r\n * the `title` attribute that developers set directly on `vds-input`. This\r\n * helper function should be called in componentWillLoad and assigned to a variable\r\n * that is later used in the render function.\r\n *\r\n * This does not need to be reactive as changing attributes on the host element\r\n * does not trigger a re-render.\r\n */\r\n export const inheritAttributes = (el: HTMLElement, attributes: string[] = []) => {\r\n const attributeObject: Attributes = {};\r\n\r\n attributes.forEach(attr => {\r\n if (el.hasAttribute(attr)) {\r\n const value = el.getAttribute(attr);\r\n if (value !== null) {\r\n attributeObject[attr] = el.getAttribute(attr);\r\n }\r\n el.removeAttribute(attr);\r\n }\r\n });\r\n\r\n return attributeObject;\r\n}\r\n\r\n/**\r\n * Patched version of requestAnimationFrame that avoids ngzone\r\n * Use only when you know ngzone should not run\r\n */\r\n export const raf = (h: any) => {\r\n if (typeof __zone_symbol__requestAnimationFrame === 'function') {\r\n return __zone_symbol__requestAnimationFrame(h);\r\n }\r\n if (typeof requestAnimationFrame === 'function') {\r\n return requestAnimationFrame(h);\r\n }\r\n return setTimeout(h);\r\n};\r\n\r\n/**\r\n * Parse a resource into a JSON object or a URL string\r\n */\r\n export function parseSrc(src: string | object): string | object {\r\n if (typeof src === 'object') {\r\n return src;\r\n }\r\n\r\n try {\r\n return JSON.parse(src);\r\n } catch (e) {\r\n // Try construct an absolute URL from the src URL\r\n const srcUrl: URL = new URL(src, window.location.href);\r\n\r\n return srcUrl.toString();\r\n }\r\n}\r\n\r\nexport const addEventListener = (el: any, eventName: string, callback: any, opts?: any) => {\r\n if (typeof (window as any) !== 'undefined') {\r\n const win = window as any;\r\n const config = win && win.Ionic && win.Ionic.config;\r\n if (config) {\r\n const ael = config.get('_ael');\r\n if (ael) {\r\n return ael(el, eventName, callback, opts);\r\n } else if (config._ael) {\r\n return config._ael(el, eventName, callback, opts);\r\n }\r\n }\r\n }\r\n\r\n return el.addEventListener(eventName, callback, opts);\r\n};\r\n\r\nexport const removeEventListener = (el: any, eventName: string, callback: any, opts?: any) => {\r\n if (typeof (window as any) !== 'undefined') {\r\n const win = window as any;\r\n const config = win && win.Ionic && win.Ionic.config;\r\n if (config) {\r\n const rel = config.get('_rel');\r\n if (rel) {\r\n return rel(el, eventName, callback, opts);\r\n } else if (config._rel) {\r\n return config._rel(el, eventName, callback, opts);\r\n }\r\n }\r\n }\r\n\r\n return el.removeEventListener(eventName, callback, opts);\r\n};\r\n\r\nexport const getParentForm = (el: HTMLElement): HTMLFormElement | null => {\r\n return el.closest('form');\r\n}\r\n\r\n/**\r\n * Waits for a component to be ready for\r\n * both custom element and non-custom element builds.\r\n * If non-custom element build, el.componentOnReady\r\n * will be used.\r\n * For custom element builds, we wait a frame\r\n * so that the inner contents of the component\r\n * have a chance to render.\r\n *\r\n * Use this utility rather than calling\r\n * el.componentOnReady yourself.\r\n */\r\n export const componentOnReady = (el: any, callback: any) => {\r\n if (el.componentOnReady) {\r\n el.componentOnReady().then((resolvedEl: any) => callback(resolvedEl));\r\n } else {\r\n raf(() => callback(el));\r\n }\r\n};\r\n\r\nexport const functionalLayoutDecorator = ((story: any, options?: { showHeader: boolean, showBreadcrumbs: boolean }) => {\r\n return `\r\n
\r\n \r\n ${story()}\r\n \r\n
`;\r\n});\r\n\r\nexport const emotionalLayoutDecorator = ((story: any, options?: { showHeader: boolean, showBreadcrumbs: boolean }) => {\r\n return `\r\n
\r\n \r\n ${story()}\r\n \r\n
\r\n `;\r\n});\r\n\r\nexport const layoutWrapperDecorator = ((story: any) => {\r\n return `\r\n
\r\n ${story()}\r\n
\r\n `;\r\n});\r\n\r\nexport const paddedLayoutDecorator = ((story: any) => {\r\n return `\r\n
\r\n ${story()}\r\n
`;\r\n});\r\n\r\nexport function closestElement(selector: string, base: Element = this) {\r\n function __closestFrom(el: Element | Window | Document): Element {\r\n if (!el || el === document || el === window) return null;\r\n if ((el as Slottable).assignedSlot) el = (el as Slottable).assignedSlot;\r\n let found = (el as Element).closest(selector);\r\n return found\r\n ? found\r\n : __closestFrom(((el as Element).getRootNode() as ShadowRoot).host);\r\n }\r\n return __closestFrom(base);\r\n}\r\n\r\nexport function stringTruncate(str: string, length: number): string {\r\n var dots = str.length > length ? '...' : '';\r\n return str.substring(0, length) + dots;\r\n}\r\n"],"version":3}