{"ast":null,"code":"import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nimport { filterDOMProps as $frWMC$filterDOMProps, useId as $frWMC$useId, mergeProps as $frWMC$mergeProps, useSlotId as $frWMC$useSlotId, isMac as $frWMC$isMac, isWebKit as $frWMC$isWebKit } from \"@react-aria/utils\";\nimport { useFocusWithin as $frWMC$useFocusWithin, useHover as $frWMC$useHover, isFocusVisible as $frWMC$isFocusVisible } from \"@react-aria/interactions\";\nimport { useLabel as $frWMC$useLabel } from \"@react-aria/label\";\nimport { useSelectableList as $frWMC$useSelectableList, useSelectableItem as $frWMC$useSelectableItem } from \"@react-aria/selection\";\nimport { getItemCount as $frWMC$getItemCount } from \"@react-stately/collections\";\nvar $b1f0cad8af73213b$export$3585ede4d035bf14 = new WeakMap();\nfunction $b1f0cad8af73213b$var$normalizeKey(key) {\n  if (typeof key === \"string\") return key.replace(/\\s*/g, \"\");\n  return \"\" + key;\n}\nfunction $b1f0cad8af73213b$export$9145995848b05025(state, itemKey) {\n  var data = $b1f0cad8af73213b$export$3585ede4d035bf14.get(state);\n  if (!data) throw new Error(\"Unknown list\");\n  return data.id + \"-option-\" + $b1f0cad8af73213b$var$normalizeKey(itemKey);\n}\nfunction $c132121280ec012d$export$50eacbbf140a3141(props, state, ref) {\n  var domProps = (0, $frWMC$filterDOMProps)(props, {\n    labelable: true\n  });\n  var _ref = (0, $frWMC$useSelectableList)(_objectSpread(_objectSpread({}, props), {}, {\n      ref: ref,\n      selectionManager: state.selectionManager,\n      collection: state.collection,\n      disabledKeys: state.disabledKeys\n    })),\n    listProps = _ref.listProps;\n  var _ref2 = (0, $frWMC$useFocusWithin)({\n      onFocusWithin: props.onFocus,\n      onBlurWithin: props.onBlur,\n      onFocusWithinChange: props.onFocusChange\n    }),\n    focusWithinProps = _ref2.focusWithinProps;\n  var id = (0, $frWMC$useId)(props.id);\n  (0, $b1f0cad8af73213b$export$3585ede4d035bf14).set(state, {\n    id: id,\n    shouldUseVirtualFocus: props.shouldUseVirtualFocus,\n    shouldSelectOnPressUp: props.shouldSelectOnPressUp,\n    shouldFocusOnHover: props.shouldFocusOnHover,\n    isVirtualized: props.isVirtualized,\n    onAction: props.onAction\n  });\n  var _ref3 = (0, $frWMC$useLabel)(_objectSpread(_objectSpread({}, props), {}, {\n      id: id,\n      labelElementType: \"span\"\n    })),\n    labelProps = _ref3.labelProps,\n    fieldProps = _ref3.fieldProps;\n  return {\n    labelProps: labelProps,\n    listBoxProps: (0, $frWMC$mergeProps)(domProps, focusWithinProps, state.selectionManager.selectionMode === \"multiple\" ? {\n      \"aria-multiselectable\": \"true\"\n    } : {}, _objectSpread({\n      role: \"listbox\"\n    }, (0, $frWMC$mergeProps)(fieldProps, listProps)))\n  };\n}\nfunction $293f70390ea03370$export$497855f14858aa34(props, state, ref) {\n  var key = props.key;\n  var data = (0, $b1f0cad8af73213b$export$3585ede4d035bf14).get(state);\n  var _props_isDisabled;\n  var isDisabled = (_props_isDisabled = props.isDisabled) !== null && _props_isDisabled !== void 0 ? _props_isDisabled : state.disabledKeys.has(key);\n  var _props_isSelected;\n  var isSelected = (_props_isSelected = props.isSelected) !== null && _props_isSelected !== void 0 ? _props_isSelected : state.selectionManager.isSelected(key);\n  var isFocused = state.selectionManager.focusedKey === key;\n  var _props_shouldSelectOnPressUp;\n  var shouldSelectOnPressUp = (_props_shouldSelectOnPressUp = props.shouldSelectOnPressUp) !== null && _props_shouldSelectOnPressUp !== void 0 ? _props_shouldSelectOnPressUp : data.shouldSelectOnPressUp;\n  var _props_shouldFocusOnHover;\n  var shouldFocusOnHover = (_props_shouldFocusOnHover = props.shouldFocusOnHover) !== null && _props_shouldFocusOnHover !== void 0 ? _props_shouldFocusOnHover : data.shouldFocusOnHover;\n  var _props_shouldUseVirtualFocus;\n  var shouldUseVirtualFocus = (_props_shouldUseVirtualFocus = props.shouldUseVirtualFocus) !== null && _props_shouldUseVirtualFocus !== void 0 ? _props_shouldUseVirtualFocus : data.shouldUseVirtualFocus;\n  var _props_isVirtualized;\n  var isVirtualized = (_props_isVirtualized = props.isVirtualized) !== null && _props_isVirtualized !== void 0 ? _props_isVirtualized : data.isVirtualized;\n  var labelId = (0, $frWMC$useSlotId)();\n  var descriptionId = (0, $frWMC$useSlotId)();\n  var optionProps = {\n    role: \"option\",\n    \"aria-disabled\": isDisabled,\n    \"aria-selected\": state.selectionManager.selectionMode !== \"none\" ? isSelected : undefined\n  };\n  if (!((0, $frWMC$isMac)() && (0, $frWMC$isWebKit)())) {\n    optionProps[\"aria-label\"] = props[\"aria-label\"];\n    optionProps[\"aria-labelledby\"] = labelId;\n    optionProps[\"aria-describedby\"] = descriptionId;\n  }\n  if (isVirtualized) {\n    optionProps[\"aria-posinset\"] = state.collection.getItem(key).index + 1;\n    optionProps[\"aria-setsize\"] = (0, $frWMC$getItemCount)(state.collection);\n  }\n  var _ref4 = (0, $frWMC$useSelectableItem)({\n      selectionManager: state.selectionManager,\n      key: key,\n      ref: ref,\n      shouldSelectOnPressUp: shouldSelectOnPressUp,\n      allowsDifferentPressOrigin: shouldSelectOnPressUp && shouldFocusOnHover,\n      isVirtualized: isVirtualized,\n      shouldUseVirtualFocus: shouldUseVirtualFocus,\n      isDisabled: isDisabled,\n      onAction: data.onAction ? function () {\n        return data.onAction(key);\n      } : undefined\n    }),\n    itemProps = _ref4.itemProps,\n    isPressed = _ref4.isPressed,\n    hasAction = _ref4.hasAction,\n    allowsSelection = _ref4.allowsSelection;\n  var _ref5 = (0, $frWMC$useHover)({\n      isDisabled: isDisabled || !shouldFocusOnHover,\n      onHoverStart: function onHoverStart() {\n        if (!(0, $frWMC$isFocusVisible)()) {\n          state.selectionManager.setFocused(true);\n          state.selectionManager.setFocusedKey(key);\n        }\n      }\n    }),\n    hoverProps = _ref5.hoverProps;\n  return {\n    optionProps: _objectSpread(_objectSpread(_objectSpread({}, optionProps), (0, $frWMC$mergeProps)(itemProps, hoverProps)), {}, {\n      id: (0, $b1f0cad8af73213b$export$9145995848b05025)(state, key)\n    }),\n    labelProps: {\n      id: labelId\n    },\n    descriptionProps: {\n      id: descriptionId\n    },\n    isFocused: isFocused,\n    isSelected: isSelected,\n    isDisabled: isDisabled,\n    isPressed: isPressed,\n    allowsSelection: allowsSelection,\n    hasAction: hasAction\n  };\n}\nfunction $af383d3bef1cfdc9$export$c3f9f39876e4bc7(props) {\n  var heading = props.heading,\n    ariaLabel = props[\"aria-label\"];\n  var headingId = (0, $frWMC$useId)();\n  return {\n    itemProps: {\n      role: \"presentation\"\n    },\n    headingProps: heading ? {\n      id: headingId,\n      \"aria-hidden\": true\n    } : {},\n    groupProps: {\n      role: \"group\",\n      \"aria-label\": ariaLabel,\n      \"aria-labelledby\": heading ? headingId : undefined\n    }\n  };\n}\nexport { $c132121280ec012d$export$50eacbbf140a3141 as useListBox, $293f70390ea03370$export$497855f14858aa34 as useOption, $af383d3bef1cfdc9$export$c3f9f39876e4bc7 as useListBoxSection, $b1f0cad8af73213b$export$3585ede4d035bf14 as listData, $b1f0cad8af73213b$export$9145995848b05025 as getItemId };","map":{"version":3,"sources":["packages/@react-aria/listbox/src/useListBox.ts","packages/@react-aria/listbox/src/utils.ts","packages/@react-aria/listbox/src/useOption.ts","packages/@react-aria/listbox/src/useListBoxSection.ts"],"names":[],"mappings":";;;;;;;;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,KAAA,CAAD,UAAA;EAUJ,OAAO;IACL,WAAA,EAAA,aAAA,CAAA,aAAA,CAAA,aAAA,KACK,WAAW,GACX,CAAA,CAAA,EAAA,iBAAU,EAAC,SAAA,EAAW,UAAA,CAAW;MACpC,EAAA,EAAI,CAAA,CAAA,EAAA,yCAAS,EAAC,KAAA,EAAO,GAAA;IAAA,EACvB;IACA,UAAA,EAAY;MACV,EAAA,EAAI;IACN,CAAA;IACA,gBAAA,EAAkB;MAChB,EAAA,EAAI;IACN,CAAA;eACA,SAAA;gBACA,UAAA;gBACA,UAAA;eACA,SAAA;qBACA,eAAA;eACA;EACF,CAAA;AACF;AC7HO,SAAS,wCAAA,CAAkB,KAA8B,EAAsB;EACpF,IAAK,OAAA,GAAoC,KAAA,CAArC,OAAA;IAAwB,SAAA,GAAa,KAAA,CAA3B,YAAA;EACd,IAAI,SAAA,GAAY,CAAA,CAAA,EAAA,YAAK,EAAA,CAAA;EAErB,OAAO;IACL,SAAA,EAAW;MACT,IAAA,EAAM;IACR,CAAA;IACA,YAAA,EAAc,OAAA,GAAU;MAItB,EAAA,EAAI,SAAA;MACJ,aAAA,EAAe;IACjB,CAAA,GAAI,CAAC,CAAC;IACN,UAAA,EAAY;MACV,IAAA,EAAM,OAAA;MACN,YAAA,EAAc,SAAA;MACd,iBAAA,EAAmB,OAAA,GAAU,SAAA,GAAY;IAC3C;EACF,CAAA;AACF","sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaListBoxProps} from '@react-types/listbox';\nimport {DOMAttributes, KeyboardDelegate} from '@react-types/shared';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {listData} from './utils';\nimport {ListState} from '@react-stately/list';\nimport {RefObject} from 'react';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useId} from '@react-aria/utils';\nimport {useLabel} from '@react-aria/label';\nimport {useSelectableList} from '@react-aria/selection';\n\nexport interface ListBoxAria {\n  /** Props for the listbox element. */\n  listBoxProps: DOMAttributes,\n  /** Props for the listbox's visual label element (if any). */\n  labelProps: DOMAttributes\n}\n\nexport interface AriaListBoxOptions<T> extends Omit<AriaListBoxProps<T>, 'children'> {\n  /** Whether the listbox uses virtual scrolling. */\n  isVirtualized?: boolean,\n\n  /**\n   * An optional keyboard delegate implementation for type to select,\n   * to override the default.\n   */\n  keyboardDelegate?: KeyboardDelegate,\n\n  /**\n   * Whether the listbox items should use virtual focus instead of being focused directly.\n   */\n  shouldUseVirtualFocus?: boolean,\n\n  /** Whether selection should occur on press up instead of press down. */\n  shouldSelectOnPressUp?: boolean,\n\n  /** Whether options should be focused when the user hovers over them. */\n  shouldFocusOnHover?: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for a listbox component.\n * A listbox displays a list of options and allows a user to select one or more of them.\n * @param props - Props for the listbox.\n * @param state - State for the listbox, as returned by `useListState`.\n */\nexport function useListBox<T>(props: AriaListBoxOptions<T>, state: ListState<T>, ref: RefObject<HTMLElement>): ListBoxAria {\n  let domProps = filterDOMProps(props, {labelable: true});\n  let {listProps} = useSelectableList({\n    ...props,\n    ref,\n    selectionManager: state.selectionManager,\n    collection: state.collection,\n    disabledKeys: state.disabledKeys\n  });\n\n  let {focusWithinProps} = useFocusWithin({\n    onFocusWithin: props.onFocus,\n    onBlurWithin: props.onBlur,\n    onFocusWithinChange: props.onFocusChange\n  });\n\n  // Share list id and some props with child options.\n  let id = useId(props.id);\n  listData.set(state, {\n    id,\n    shouldUseVirtualFocus: props.shouldUseVirtualFocus,\n    shouldSelectOnPressUp: props.shouldSelectOnPressUp,\n    shouldFocusOnHover: props.shouldFocusOnHover,\n    isVirtualized: props.isVirtualized,\n    onAction: props.onAction\n  });\n\n  let {labelProps, fieldProps} = useLabel({\n    ...props,\n    id,\n    // listbox is not an HTML input element so it\n    // shouldn't be labeled by a <label> element.\n    labelElementType: 'span'\n  });\n\n  return {\n    labelProps,\n    listBoxProps: mergeProps(domProps, focusWithinProps, state.selectionManager.selectionMode === 'multiple' ? {\n      'aria-multiselectable': 'true'\n    } : {}, {\n      role: 'listbox',\n      ...mergeProps(fieldProps, listProps)\n    })\n  };\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Key} from 'react';\nimport {ListState} from '@react-stately/list';\n\ninterface ListData {\n  id: string,\n  shouldSelectOnPressUp?: boolean,\n  shouldFocusOnHover?: boolean,\n  shouldUseVirtualFocus?: boolean,\n  isVirtualized?: boolean,\n  onAction?: (key: Key) => void\n}\n\nexport const listData = new WeakMap<ListState<unknown>, ListData>();\n\nfunction normalizeKey(key: Key): string {\n  if (typeof key === 'string') {\n    return key.replace(/\\s*/g, '');\n  }\n\n  return '' + key;\n}\n\nexport function getItemId<T>(state: ListState<T>, itemKey: Key): string {\n  let data = listData.get(state);\n\n  if (!data) {\n    throw new Error('Unknown list');\n  }\n\n  return `${data.id}-option-${normalizeKey(itemKey)}`;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {getItemCount} from '@react-stately/collections';\nimport {getItemId, listData} from './utils';\nimport {isFocusVisible, useHover} from '@react-aria/interactions';\nimport {isMac, isWebKit, mergeProps, useSlotId} from '@react-aria/utils';\nimport {Key, RefObject} from 'react';\nimport {ListState} from '@react-stately/list';\nimport {SelectableItemStates, useSelectableItem} from '@react-aria/selection';\n\nexport interface OptionAria extends SelectableItemStates {\n  /** Props for the option element. */\n  optionProps: DOMAttributes,\n\n  /** Props for the main text element inside the option. */\n  labelProps: DOMAttributes,\n\n  /** Props for the description text element inside the option, if any. */\n  descriptionProps: DOMAttributes,\n\n  /** Whether the option is currently focused. */\n  isFocused: boolean\n}\n\nexport interface AriaOptionProps {\n  /**\n   * Whether the option is disabled.\n   * @deprecated\n   */\n  isDisabled?: boolean,\n\n  /**\n   * Whether the option is selected.\n   * @deprecated\n   */\n  isSelected?: boolean,\n\n  /** A screen reader only label for the option. */\n  'aria-label'?: string,\n\n  /** The unique key for the option. */\n  key: Key,\n\n  /**\n   * Whether selection should occur on press up instead of press down.\n   * @deprecated\n   */\n  shouldSelectOnPressUp?: boolean,\n\n  /**\n   * Whether the option should be focused when the user hovers over it.\n   * @deprecated\n   */\n  shouldFocusOnHover?: boolean,\n\n  /**\n   * Whether the option is contained in a virtual scrolling listbox.\n   * @deprecated\n   */\n  isVirtualized?: boolean,\n\n  /**\n   * Whether the option should use virtual focus instead of being focused directly.\n   * @deprecated\n   */\n  shouldUseVirtualFocus?: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for an option in a listbox.\n * See `useListBox` for more details about listboxes.\n * @param props - Props for the option.\n * @param state - State for the listbox, as returned by `useListState`.\n */\nexport function useOption<T>(props: AriaOptionProps, state: ListState<T>, ref: RefObject<FocusableElement>): OptionAria {\n  let {\n    key\n  } = props;\n\n  let data = listData.get(state);\n\n  let isDisabled = props.isDisabled ?? state.disabledKeys.has(key);\n  let isSelected = props.isSelected ?? state.selectionManager.isSelected(key);\n  let isFocused = state.selectionManager.focusedKey === key;\n  let shouldSelectOnPressUp = props.shouldSelectOnPressUp ?? data.shouldSelectOnPressUp;\n  let shouldFocusOnHover = props.shouldFocusOnHover ?? data.shouldFocusOnHover;\n  let shouldUseVirtualFocus = props.shouldUseVirtualFocus ?? data.shouldUseVirtualFocus;\n  let isVirtualized = props.isVirtualized ?? data.isVirtualized;\n\n  let labelId = useSlotId();\n  let descriptionId = useSlotId();\n\n  let optionProps = {\n    role: 'option',\n    'aria-disabled': isDisabled,\n    'aria-selected': state.selectionManager.selectionMode !== 'none' ? isSelected : undefined\n  };\n\n  // Safari with VoiceOver on macOS misreads options with aria-labelledby or aria-label as simply \"text\".\n  // We should not map slots to the label and description on Safari and instead just have VoiceOver read the textContent.\n  // https://bugs.webkit.org/show_bug.cgi?id=209279\n  if (!(isMac() && isWebKit())) {\n    optionProps['aria-label'] = props['aria-label'];\n    optionProps['aria-labelledby'] = labelId;\n    optionProps['aria-describedby'] = descriptionId;\n  }\n\n  if (isVirtualized) {\n    optionProps['aria-posinset'] = state.collection.getItem(key).index + 1;\n    optionProps['aria-setsize'] = getItemCount(state.collection);\n  }\n\n  let {itemProps, isPressed, hasAction, allowsSelection} = useSelectableItem({\n    selectionManager: state.selectionManager,\n    key,\n    ref,\n    shouldSelectOnPressUp,\n    allowsDifferentPressOrigin: shouldSelectOnPressUp && shouldFocusOnHover,\n    isVirtualized,\n    shouldUseVirtualFocus,\n    isDisabled,\n    onAction: data.onAction ? () => data.onAction(key) : undefined\n  });\n\n  let {hoverProps} = useHover({\n    isDisabled: isDisabled || !shouldFocusOnHover,\n    onHoverStart() {\n      if (!isFocusVisible()) {\n        state.selectionManager.setFocused(true);\n        state.selectionManager.setFocusedKey(key);\n      }\n    }\n  });\n\n  return {\n    optionProps: {\n      ...optionProps,\n      ...mergeProps(itemProps, hoverProps),\n      id: getItemId(state, key)\n    },\n    labelProps: {\n      id: labelId\n    },\n    descriptionProps: {\n      id: descriptionId\n    },\n    isFocused,\n    isSelected,\n    isDisabled,\n    isPressed,\n    allowsSelection,\n    hasAction\n  };\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DOMAttributes} from '@react-types/shared';\nimport {ReactNode} from 'react';\nimport {useId} from '@react-aria/utils';\n\nexport interface AriaListBoxSectionProps {\n  /** The heading for the section. */\n  heading?: ReactNode,\n  /** An accessibility label for the section. Required if `heading` is not present. */\n  'aria-label'?: string\n}\n\nexport interface ListBoxSectionAria {\n  /** Props for the wrapper list item. */\n  itemProps: DOMAttributes,\n\n  /** Props for the heading element, if any. */\n  headingProps: DOMAttributes,\n\n  /** Props for the group element. */\n  groupProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a section in a listbox.\n * See `useListBox` for more details about listboxes.\n * @param props - Props for the section.\n */\nexport function useListBoxSection(props: AriaListBoxSectionProps): ListBoxSectionAria {\n  let {heading, 'aria-label': ariaLabel} = props;\n  let headingId = useId();\n\n  return {\n    itemProps: {\n      role: 'presentation'\n    },\n    headingProps: heading ? {\n      // Techincally, listbox cannot contain headings according to ARIA.\n      // We hide the heading from assistive technology, and only use it\n      // as a label for the nested group.\n      id: headingId,\n      'aria-hidden': true\n    } : {},\n    groupProps: {\n      role: 'group',\n      'aria-label': ariaLabel,\n      'aria-labelledby': heading ? headingId : undefined\n    }\n  };\n}\n"]},"metadata":{},"sourceType":"module"}