{"ast":null,"code":"import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport _toConsumableArray from \"@babel/runtime/helpers/toConsumableArray\";\nimport _classCallCheck from \"@babel/runtime/helpers/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/createClass\";\nimport _regeneratorRuntime from \"@babel/runtime/regenerator\";\n\nfunction _createForOfIteratorHelperLoose(o, allowArrayLike) { var it; if (typeof Symbol === \"undefined\" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } it = o[Symbol.iterator](); return it.next.bind(it); }\n\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\n\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\n\nimport _babelRuntimeHelpersEsmExtends from \"@babel/runtime/helpers/esm/extends\";\nimport _react, { useMemo, useRef } from \"react\";\n\nfunction $e92117d6e5313ef8e7c10fac1de193ce$var$Item(props) {\n  return null;\n}\n\n$e92117d6e5313ef8e7c10fac1de193ce$var$Item.getCollectionNode = _regeneratorRuntime.mark(function getCollectionNode(props) {\n  var childItems, title, children, rendered, textValue;\n  return _regeneratorRuntime.wrap(function getCollectionNode$(_context2) {\n    while (1) {\n      switch (_context2.prev = _context2.next) {\n        case 0:\n          childItems = props.childItems, title = props.title, children = props.children;\n          rendered = props.title || props.children;\n          textValue = props.textValue || (typeof rendered === 'string' ? rendered : '') || props['aria-label'] || '';\n\n          if (!textValue) {\n            console.warn('<Item> with non-plain text contents is unsupported by type to select for accessibility. Please add a `textValue` prop.');\n          }\n\n          _context2.next = 6;\n          return {\n            type: 'item',\n            props: props,\n            rendered: rendered,\n            textValue: textValue,\n            'aria-label': props['aria-label'],\n            hasChildNodes: $e92117d6e5313ef8e7c10fac1de193ce$var$hasChildItems(props),\n            childNodes: _regeneratorRuntime.mark(function childNodes() {\n              var _iterator, _step, child, items;\n\n              return _regeneratorRuntime.wrap(function childNodes$(_context) {\n                while (1) {\n                  switch (_context.prev = _context.next) {\n                    case 0:\n                      if (!childItems) {\n                        _context.next = 10;\n                        break;\n                      }\n\n                      _iterator = _createForOfIteratorHelperLoose(childItems);\n\n                    case 2:\n                      if ((_step = _iterator()).done) {\n                        _context.next = 8;\n                        break;\n                      }\n\n                      child = _step.value;\n                      _context.next = 6;\n                      return {\n                        type: 'item',\n                        value: child\n                      };\n\n                    case 6:\n                      _context.next = 2;\n                      break;\n\n                    case 8:\n                      _context.next = 14;\n                      break;\n\n                    case 10:\n                      if (!title) {\n                        _context.next = 14;\n                        break;\n                      }\n\n                      items = [];\n\n                      _react.Children.forEach(children, function (child) {\n                        items.push({\n                          type: 'item',\n                          element: child\n                        });\n                      });\n\n                      return _context.delegateYield(items, \"t0\", 14);\n\n                    case 14:\n                    case \"end\":\n                      return _context.stop();\n                  }\n                }\n              }, childNodes);\n            })\n          };\n\n        case 6:\n        case \"end\":\n          return _context2.stop();\n      }\n    }\n  }, getCollectionNode);\n});\n\nfunction $e92117d6e5313ef8e7c10fac1de193ce$var$hasChildItems(props) {\n  if (props.hasChildItems != null) {\n    return props.hasChildItems;\n  }\n\n  if (props.childItems) {\n    return true;\n  }\n\n  if (props.title && _react.Children.count(props.children) > 0) {\n    return true;\n  }\n\n  return false;\n}\n\nexport var Item = $e92117d6e5313ef8e7c10fac1de193ce$var$Item;\n\nfunction $b2e76f05d3356a2e1df6ac80570fcd9$var$Section(props) {\n  return null;\n}\n\n$b2e76f05d3356a2e1df6ac80570fcd9$var$Section.getCollectionNode = _regeneratorRuntime.mark(function getCollectionNode(props) {\n  var children, title, items;\n  return _regeneratorRuntime.wrap(function getCollectionNode$(_context4) {\n    while (1) {\n      switch (_context4.prev = _context4.next) {\n        case 0:\n          children = props.children, title = props.title, items = props.items;\n          _context4.next = 3;\n          return {\n            type: 'section',\n            hasChildNodes: true,\n            rendered: title,\n            'aria-label': props['aria-label'],\n            childNodes: _regeneratorRuntime.mark(function childNodes() {\n              var _iterator2, _step2, item, _items;\n\n              return _regeneratorRuntime.wrap(function childNodes$(_context3) {\n                while (1) {\n                  switch (_context3.prev = _context3.next) {\n                    case 0:\n                      if (!(typeof children === 'function')) {\n                        _context3.next = 12;\n                        break;\n                      }\n\n                      if (items) {\n                        _context3.next = 3;\n                        break;\n                      }\n\n                      throw new Error('props.children was a function but props.items is missing');\n\n                    case 3:\n                      _iterator2 = _createForOfIteratorHelperLoose(items);\n\n                    case 4:\n                      if ((_step2 = _iterator2()).done) {\n                        _context3.next = 10;\n                        break;\n                      }\n\n                      item = _step2.value;\n                      _context3.next = 8;\n                      return {\n                        type: 'item',\n                        value: item,\n                        renderer: children\n                      };\n\n                    case 8:\n                      _context3.next = 4;\n                      break;\n\n                    case 10:\n                      _context3.next = 15;\n                      break;\n\n                    case 12:\n                      _items = [];\n\n                      _react.Children.forEach(children, function (child) {\n                        _items.push({\n                          type: 'item',\n                          element: child\n                        });\n                      });\n\n                      return _context3.delegateYield(_items, \"t0\", 15);\n\n                    case 15:\n                    case \"end\":\n                      return _context3.stop();\n                  }\n                }\n              }, childNodes);\n            })\n          };\n\n        case 3:\n        case \"end\":\n          return _context4.stop();\n      }\n    }\n  }, getCollectionNode);\n});\nexport var Section = $b2e76f05d3356a2e1df6ac80570fcd9$var$Section;\n\nvar $f8429209754fda4b9142d514065f4$export$CollectionBuilder = function () {\n  function $f8429209754fda4b9142d514065f4$export$CollectionBuilder() {\n    _classCallCheck(this, $f8429209754fda4b9142d514065f4$export$CollectionBuilder);\n\n    this.context = void 0;\n    this.cache = new WeakMap();\n  }\n\n  _createClass($f8429209754fda4b9142d514065f4$export$CollectionBuilder, [{\n    key: \"build\",\n    value: function build(props, context) {\n      var _this = this;\n\n      this.context = context;\n      return $f8429209754fda4b9142d514065f4$var$iterable(function () {\n        return _this.iterateCollection(props);\n      });\n    }\n  }, {\n    key: \"iterateCollection\",\n    value: _regeneratorRuntime.mark(function iterateCollection(props) {\n      var children, items, _iterator3, _step3, item, _items2, index, _i, _items3, _item, nodes, _iterator4, _step4, node;\n\n      return _regeneratorRuntime.wrap(function iterateCollection$(_context5) {\n        while (1) {\n          switch (_context5.prev = _context5.next) {\n            case 0:\n              children = props.children, items = props.items;\n\n              if (!(typeof children === 'function')) {\n                _context5.next = 12;\n                break;\n              }\n\n              if (items) {\n                _context5.next = 4;\n                break;\n              }\n\n              throw new Error('props.children was a function but props.items is missing');\n\n            case 4:\n              _iterator3 = _createForOfIteratorHelperLoose(props.items);\n\n            case 5:\n              if ((_step3 = _iterator3()).done) {\n                _context5.next = 10;\n                break;\n              }\n\n              item = _step3.value;\n              return _context5.delegateYield(this.getFullNode({\n                value: item\n              }, {\n                renderer: children\n              }), \"t0\", 8);\n\n            case 8:\n              _context5.next = 5;\n              break;\n\n            case 10:\n              _context5.next = 30;\n              break;\n\n            case 12:\n              _items2 = [];\n\n              _react.Children.forEach(children, function (child) {\n                _items2.push(child);\n              });\n\n              index = 0;\n              _i = 0, _items3 = _items2;\n\n            case 16:\n              if (!(_i < _items3.length)) {\n                _context5.next = 30;\n                break;\n              }\n\n              _item = _items3[_i];\n              nodes = this.getFullNode({\n                element: _item,\n                index: index\n              }, {});\n              _iterator4 = _createForOfIteratorHelperLoose(nodes);\n\n            case 20:\n              if ((_step4 = _iterator4()).done) {\n                _context5.next = 27;\n                break;\n              }\n\n              node = _step4.value;\n              index++;\n              _context5.next = 25;\n              return node;\n\n            case 25:\n              _context5.next = 20;\n              break;\n\n            case 27:\n              _i++;\n              _context5.next = 16;\n              break;\n\n            case 30:\n            case \"end\":\n              return _context5.stop();\n          }\n        }\n      }, iterateCollection, this);\n    })\n  }, {\n    key: \"getKey\",\n    value: function getKey(item, partialNode, state, parentKey) {\n      if (item.key != null) {\n        return item.key;\n      }\n\n      if (partialNode.type === 'cell' && partialNode.key != null) {\n        return \"\" + parentKey + partialNode.key;\n      }\n\n      var v = partialNode.value;\n\n      if (v != null) {\n        var _v$key;\n\n        var key = (_v$key = v.key) != null ? _v$key : v.id;\n\n        if (key == null) {\n          throw new Error('No key found for item');\n        }\n\n        return key;\n      }\n\n      return parentKey ? parentKey + \".\" + partialNode.index : \"$.\" + partialNode.index;\n    }\n  }, {\n    key: \"getChildState\",\n    value: function getChildState(state, partialNode) {\n      return {\n        renderer: partialNode.renderer || state.renderer\n      };\n    }\n  }, {\n    key: \"getFullNode\",\n    value: _regeneratorRuntime.mark(function getFullNode(partialNode, state, parentKey, parentNode) {\n      var element, cached, type, name, _childNodes, index, result, childNode, nodes, children, _iterator5, _step5, _node, builder, node;\n\n      return _regeneratorRuntime.wrap(function getFullNode$(_context7) {\n        while (1) {\n          switch (_context7.prev = _context7.next) {\n            case 0:\n              element = partialNode.element;\n\n              if (!(!element && partialNode.value && state && state.renderer)) {\n                _context7.next = 9;\n                break;\n              }\n\n              cached = this.cache.get(partialNode.value);\n\n              if (!(cached && (!cached.shouldInvalidate || !cached.shouldInvalidate(this.context)))) {\n                _context7.next = 8;\n                break;\n              }\n\n              cached.index = partialNode.index;\n              _context7.next = 7;\n              return cached;\n\n            case 7:\n              return _context7.abrupt(\"return\");\n\n            case 8:\n              element = state.renderer(partialNode.value);\n\n            case 9:\n              if (!_react.isValidElement(element)) {\n                _context7.next = 38;\n                break;\n              }\n\n              type = element.type;\n\n              if (!(typeof type !== 'function' || typeof type.getCollectionNode !== 'function')) {\n                _context7.next = 14;\n                break;\n              }\n\n              name = typeof element.type === 'function' ? element.type.name : element.type;\n              throw new Error(\"Unknown element <\" + name + \"> in collection.\");\n\n            case 14:\n              _childNodes = type.getCollectionNode(element.props, this.context);\n              index = partialNode.index;\n              result = _childNodes.next();\n\n            case 17:\n              if (!(!result.done && result.value)) {\n                _context7.next = 37;\n                break;\n              }\n\n              childNode = result.value;\n              partialNode.index = index;\n              nodes = this.getFullNode(_babelRuntimeHelpersEsmExtends({}, childNode, {\n                key: childNode.element ? null : this.getKey(element, partialNode, state, parentKey),\n                index: index,\n                wrapper: $f8429209754fda4b9142d514065f4$var$compose(partialNode.wrapper, childNode.wrapper)\n              }), this.getChildState(state, childNode), parentKey ? \"\" + parentKey + element.key : element.key, parentNode);\n              children = _toConsumableArray(nodes);\n              _iterator5 = _createForOfIteratorHelperLoose(children);\n\n            case 23:\n              if ((_step5 = _iterator5()).done) {\n                _context7.next = 34;\n                break;\n              }\n\n              _node = _step5.value;\n              _node.value = childNode.value || partialNode.value;\n\n              if (_node.value) {\n                this.cache.set(_node.value, _node);\n              }\n\n              if (!(partialNode.type && _node.type !== partialNode.type)) {\n                _context7.next = 29;\n                break;\n              }\n\n              throw new Error(\"Unsupported type <\" + $f8429209754fda4b9142d514065f4$var$capitalize(_node.type) + \"> in <\" + $f8429209754fda4b9142d514065f4$var$capitalize(parentNode.type) + \">. Only <\" + $f8429209754fda4b9142d514065f4$var$capitalize(partialNode.type) + \"> is supported.\");\n\n            case 29:\n              index++;\n              _context7.next = 32;\n              return _node;\n\n            case 32:\n              _context7.next = 23;\n              break;\n\n            case 34:\n              result = _childNodes.next(children);\n              _context7.next = 17;\n              break;\n\n            case 37:\n              return _context7.abrupt(\"return\");\n\n            case 38:\n              if (!(partialNode.key == null)) {\n                _context7.next = 40;\n                break;\n              }\n\n              return _context7.abrupt(\"return\");\n\n            case 40:\n              builder = this;\n              node = {\n                type: partialNode.type,\n                props: partialNode.props,\n                key: partialNode.key,\n                parentKey: parentNode ? parentNode.key : null,\n                value: partialNode.value,\n                level: parentNode ? parentNode.level + 1 : 0,\n                index: partialNode.index,\n                rendered: partialNode.rendered,\n                textValue: partialNode.textValue,\n                'aria-label': partialNode['aria-label'],\n                wrapper: partialNode.wrapper,\n                shouldInvalidate: partialNode.shouldInvalidate,\n                hasChildNodes: partialNode.hasChildNodes,\n                childNodes: $f8429209754fda4b9142d514065f4$var$iterable(_regeneratorRuntime.mark(function _callee() {\n                  var index, _iterator6, _step6, child, _nodes, _iterator7, _step7, _node2;\n\n                  return _regeneratorRuntime.wrap(function _callee$(_context6) {\n                    while (1) {\n                      switch (_context6.prev = _context6.next) {\n                        case 0:\n                          if (partialNode.hasChildNodes) {\n                            _context6.next = 2;\n                            break;\n                          }\n\n                          return _context6.abrupt(\"return\");\n\n                        case 2:\n                          index = 0;\n                          _iterator6 = _createForOfIteratorHelperLoose(partialNode.childNodes());\n\n                        case 4:\n                          if ((_step6 = _iterator6()).done) {\n                            _context6.next = 19;\n                            break;\n                          }\n\n                          child = _step6.value;\n\n                          if (child.key != null) {\n                            child.key = \"\" + node.key + child.key;\n                          }\n\n                          child.index = index;\n                          _nodes = builder.getFullNode(child, builder.getChildState(state, child), node.key, node);\n                          _iterator7 = _createForOfIteratorHelperLoose(_nodes);\n\n                        case 10:\n                          if ((_step7 = _iterator7()).done) {\n                            _context6.next = 17;\n                            break;\n                          }\n\n                          _node2 = _step7.value;\n                          index++;\n                          _context6.next = 15;\n                          return _node2;\n\n                        case 15:\n                          _context6.next = 10;\n                          break;\n\n                        case 17:\n                          _context6.next = 4;\n                          break;\n\n                        case 19:\n                        case \"end\":\n                          return _context6.stop();\n                      }\n                    }\n                  }, _callee);\n                }))\n              };\n              _context7.next = 44;\n              return node;\n\n            case 44:\n            case \"end\":\n              return _context7.stop();\n          }\n        }\n      }, getFullNode, this);\n    })\n  }]);\n\n  return $f8429209754fda4b9142d514065f4$export$CollectionBuilder;\n}();\n\nfunction $f8429209754fda4b9142d514065f4$var$iterable(iterator) {\n  var cache = [];\n  var iterable = null;\n  return _defineProperty({}, Symbol.iterator, _regeneratorRuntime.mark(function _callee2() {\n    var _iterator8, _step8, item, _iterator9, _step9, _item2;\n\n    return _regeneratorRuntime.wrap(function _callee2$(_context8) {\n      while (1) {\n        switch (_context8.prev = _context8.next) {\n          case 0:\n            _iterator8 = _createForOfIteratorHelperLoose(cache);\n\n          case 1:\n            if ((_step8 = _iterator8()).done) {\n              _context8.next = 7;\n              break;\n            }\n\n            item = _step8.value;\n            _context8.next = 5;\n            return item;\n\n          case 5:\n            _context8.next = 1;\n            break;\n\n          case 7:\n            if (!iterable) {\n              iterable = iterator();\n            }\n\n            _iterator9 = _createForOfIteratorHelperLoose(iterable);\n\n          case 9:\n            if ((_step9 = _iterator9()).done) {\n              _context8.next = 16;\n              break;\n            }\n\n            _item2 = _step9.value;\n            cache.push(_item2);\n            _context8.next = 14;\n            return _item2;\n\n          case 14:\n            _context8.next = 9;\n            break;\n\n          case 16:\n          case \"end\":\n            return _context8.stop();\n        }\n      }\n    }, _callee2);\n  }));\n}\n\nfunction $f8429209754fda4b9142d514065f4$var$compose(outer, inner) {\n  if (outer && inner) {\n    return function (element) {\n      return outer(inner(element));\n    };\n  }\n\n  if (outer) {\n    return outer;\n  }\n\n  if (inner) {\n    return inner;\n  }\n}\n\nfunction $f8429209754fda4b9142d514065f4$var$capitalize(str) {\n  return str[0].toUpperCase() + str.slice(1);\n}\n\nexport function useCollection(props, factory, context, invalidators) {\n  if (invalidators === void 0) {\n    invalidators = [];\n  }\n\n  var builder = useMemo(function () {\n    return new $f8429209754fda4b9142d514065f4$export$CollectionBuilder();\n  }, []);\n  var prev = useRef(null);\n  return useMemo(function () {\n    var nodes = builder.build(props, context);\n    prev.current = factory(nodes, prev.current);\n    return prev.current;\n  }, [builder, props.children, props.items, context].concat(_toConsumableArray(invalidators)));\n}\nvar $c10674539d06c96e1a2fbb6a54340$var$cache = new WeakMap();\nexport function getItemCount(collection) {\n  var count = $c10674539d06c96e1a2fbb6a54340$var$cache.get(collection);\n\n  if (count != null) {\n    return count;\n  }\n\n  count = 0;\n\n  for (var _iterator10 = _createForOfIteratorHelperLoose(collection), _step10; !(_step10 = _iterator10()).done;) {\n    var item = _step10.value;\n\n    if (item.type === 'section') {\n      count += getItemCount(item.childNodes);\n    } else {\n      count++;\n    }\n  }\n\n  $c10674539d06c96e1a2fbb6a54340$var$cache.set(collection, count);\n  return count;\n}","map":{"version":3,"sources":["packages/@react-stately/collections/src/Item.ts","packages/@react-stately/collections/src/Section.ts","packages/@react-stately/collections/src/CollectionBuilder.ts","packages/@react-stately/collections/src/useCollection.ts","packages/@react-stately/collections/src/getItemCount.ts"],"names":["Item","children","rendered","props","textValue","console","type","hasChildNodes","hasChildItems","value","child","items","React","element","_Item","Section","renderer","_Section","iterable","item","index","nodes","partialNode","v","key","parentKey","state","cached","name","childNodes","result","childNode","wrapper","compose","node","capitalize","parentNode","builder","level","shouldInvalidate","cache","Symbol","iterator","outer","inner","str","invalidators","useMemo","prev","useRef","factory","count","getItemCount"],"mappings":";;;;;;;;;;;;;;;AAgBA,SAAA,0CAAA,CAAA,KAAA,EAAoD;AAClD,SAAA,IAAA;AACD;;AAEDA,0CAAI,CAAJA,iBAAAA,4BAAyB,SAAA,iBAAA,CAAA,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACnB,UAAA,UADmB,GACvB,KADuB,CACnB,UADmB,EACnB,KADmB,GACvB,KADuB,CACnB,KADmB,EACCC,QADD,GACvB,KADuB,CACCA,QADD;AAGnBC,UAAAA,QAHmB,GAGRC,KAAK,CAALA,KAAAA,IAAeA,KAAK,CAAnC,QAHuB;AAInBC,UAAAA,SAJmB,GAIPD,KAAK,CAALA,SAAAA,KAAoB,OAAA,QAAA,KAAA,QAAA,GAAA,QAAA,GAApBA,EAAAA,KAAqEA,KAAK,CAA1EA,YAA0E,CAA1EA,IAAhB,EAJuB;;AAKvB,cAAI,CAAJ,SAAA,EAAgB;AACdE,YAAAA,OAAO,CA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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 {ItemElement, ItemProps} from '@react-types/shared';\nimport {PartialNode} from './types';\nimport React, {ReactElement} from 'react';\n\nfunction Item<T>(props: ItemProps<T>): ReactElement { // eslint-disable-line @typescript-eslint/no-unused-vars\n  return null;\n}\n\nItem.getCollectionNode = function* getCollectionNode<T>(props: ItemProps<T>): Generator<PartialNode<T>> {\n  let {childItems, title, children} = props;\n\n  let rendered = props.title || props.children;\n  let textValue = props.textValue || (typeof rendered === 'string' ? rendered : '') || props['aria-label'] || '';\n  if (!textValue) {\n    console.warn('<Item> with non-plain text contents is unsupported by type to select for accessibility. Please add a `textValue` prop.');\n  }\n\n  yield {\n    type: 'item',\n    props: props,\n    rendered,\n    textValue,\n    'aria-label': props['aria-label'],\n    hasChildNodes: hasChildItems(props),\n    *childNodes() {\n      if (childItems) {\n        for (let child of childItems) {\n          yield {\n            type: 'item',\n            value: child\n          };\n        }\n      } else if (title) {\n        let items: PartialNode<T>[] = [];\n        React.Children.forEach(children, child => {\n          items.push({\n            type: 'item',\n            element: child as ItemElement<T>\n          });\n        });\n\n        yield* items;\n      }\n    }\n  };\n};\n\nfunction hasChildItems<T>(props: ItemProps<T>) {\n  if (props.hasChildItems != null) {\n    return props.hasChildItems;\n  }\n\n  if (props.childItems) {\n    return true;\n  }\n\n  if (props.title && React.Children.count(props.children) > 0) {\n    return true;\n  }\n\n  return false;\n}\n\n// We don't want getCollectionNode to show up in the type definition\nlet _Item = Item as <T>(props: ItemProps<T>) => JSX.Element;\nexport {_Item as Item};\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 {PartialNode} from './types';\nimport React, {ReactElement} from 'react';\nimport {SectionProps} from '@react-types/shared';\n\nfunction Section<T>(props: SectionProps<T>): ReactElement { // eslint-disable-line @typescript-eslint/no-unused-vars\n  return null;\n}\n\nSection.getCollectionNode = function* getCollectionNode<T>(props: SectionProps<T>): Generator<PartialNode<T>> {\n  let {children, title, items} = props;\n  yield {\n    type: 'section',\n    hasChildNodes: true,\n    rendered: title,\n    'aria-label': props['aria-label'],\n    *childNodes() {\n      if (typeof children === 'function') {\n        if (!items) {\n          throw new Error('props.children was a function but props.items is missing');\n        }\n    \n        for (let item of items) {\n          yield {\n            type: 'item',\n            value: item,\n            renderer: children\n          };\n        }\n      } else {\n        let items: PartialNode<T>[] = [];\n        React.Children.forEach(children, child => {\n          items.push({\n            type: 'item',\n            element: child\n          });\n        });\n\n        yield* items;\n      }\n    }\n  };\n};\n\n// We don't want getCollectionNode to show up in the type definition\nlet _Section = Section as <T>(props: SectionProps<T>) => JSX.Element;\nexport {_Section as Section};\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 {CollectionBase, CollectionElement, Node} from '@react-types/shared';\nimport {PartialNode} from './types';\nimport React, {Key, ReactElement} from 'react';\n\ninterface CollectionBuilderState {\n  renderer?: (value: any) => ReactElement\n}\n\nexport class CollectionBuilder<T extends object> {\n  private context?: unknown;\n  private cache: WeakMap<T, Node<T>> = new WeakMap();\n\n  build(props: CollectionBase<T>, context?: unknown) {\n    this.context = context;\n    return iterable(() => this.iterateCollection(props));\n  }\n\n  private *iterateCollection(props: CollectionBase<T>) {\n    let {children, items} = props;\n\n    if (typeof children === 'function') {\n      if (!items) {\n        throw new Error('props.children was a function but props.items is missing');\n      }\n\n      for (let item of props.items) {\n        yield* this.getFullNode({\n          value: item\n        }, {renderer: children});\n      }\n    } else {\n      let items: CollectionElement<T>[] = [];\n      React.Children.forEach(children, child => {\n        items.push(child);\n      });\n\n      let index = 0;\n      for (let item of items) {\n        let nodes = this.getFullNode({\n          element: item,\n          index: index\n        }, {});\n\n        for (let node of nodes) {\n          index++;\n          yield node;\n        }\n      }\n    }\n  }\n\n  private getKey(item: CollectionElement<T>, partialNode: PartialNode<T>, state: CollectionBuilderState, parentKey?: Key): Key {\n    if (item.key != null) {\n      return item.key;\n    }\n\n    if (partialNode.type === 'cell' && partialNode.key != null) {\n      return `${parentKey}${partialNode.key}`;\n    }\n\n    let v = partialNode.value as any;\n    if (v != null) {\n      let key = v.key ?? v.id;\n      if (key == null) {\n        throw new Error('No key found for item');\n      }\n\n      return key;\n    }\n\n    return parentKey ? `${parentKey}.${partialNode.index}` : `$.${partialNode.index}`;\n  }\n\n  private getChildState(state: CollectionBuilderState, partialNode: PartialNode<T>) {\n    return {\n      renderer: partialNode.renderer || state.renderer\n    };\n  }\n\n  private *getFullNode(partialNode: PartialNode<T>, state: CollectionBuilderState, parentKey?: Key, parentNode?: Node<T>): Generator<Node<T>> {\n    // If there's a value instead of an element on the node, and a parent renderer function is available,\n    // use it to render an element for the value.\n    let element = partialNode.element;\n    if (!element && partialNode.value && state && state.renderer) {\n      let cached = this.cache.get(partialNode.value);\n      if (cached && (!cached.shouldInvalidate || !cached.shouldInvalidate(this.context))) {\n        cached.index = partialNode.index;\n        yield cached;\n        return;\n      }\n\n      element = state.renderer(partialNode.value);\n    }\n\n    // If there's an element with a getCollectionNode function on its type, then it's a supported component.\n    // Call this function to get a partial node, and recursively build a full node from there.\n    if (React.isValidElement(element)) {\n      let type = element.type as any;\n      if (typeof type !== 'function' || typeof type.getCollectionNode !== 'function') {\n        let name = typeof element.type === 'function' ? element.type.name : element.type;\n        throw new Error(`Unknown element <${name}> in collection.`);\n      }\n\n      let childNodes = type.getCollectionNode(element.props, this.context) as Generator<PartialNode<T>, void, Node<T>[]>;\n      let index = partialNode.index;\n      let result = childNodes.next();\n      while (!result.done && result.value) {\n        let childNode = result.value;\n\n        partialNode.index = index;\n        let nodes = this.getFullNode({\n          ...childNode,\n          key: childNode.element ? null : this.getKey(element as CollectionElement<T>, partialNode, state, parentKey),\n          index,\n          wrapper: compose(partialNode.wrapper, childNode.wrapper)\n        }, this.getChildState(state, childNode), parentKey ? `${parentKey}${element.key}` : element.key, parentNode);\n\n        let children = [...nodes];\n        for (let node of children) {\n          // Cache the node based on its value\n          node.value = childNode.value || partialNode.value;\n          if (node.value) {\n            this.cache.set(node.value, node);\n          }\n\n          // The partial node may have specified a type for the child in order to specify a constraint.\n          // Verify that the full node that was built recursively matches this type.\n          if (partialNode.type && node.type !== partialNode.type) {\n            throw new Error(`Unsupported type <${capitalize(node.type)}> in <${capitalize(parentNode.type)}>. Only <${capitalize(partialNode.type)}> is supported.`);\n          }\n\n          index++;\n          yield node;\n        }\n\n        result = childNodes.next(children);\n      }\n\n      return;\n    }\n\n    // Ignore invalid elements\n    if (partialNode.key == null) {\n      return;\n    }\n\n    // Create full node\n    let builder = this;\n    let node: Node<T> = {\n      type: partialNode.type,\n      props: partialNode.props,\n      key: partialNode.key,\n      parentKey: parentNode ? parentNode.key : null,\n      value: partialNode.value,\n      level: parentNode ? parentNode.level + 1 : 0,\n      index: partialNode.index,\n      rendered: partialNode.rendered,\n      textValue: partialNode.textValue,\n      'aria-label': partialNode['aria-label'],\n      wrapper: partialNode.wrapper,\n      shouldInvalidate: partialNode.shouldInvalidate,\n      hasChildNodes: partialNode.hasChildNodes,\n      childNodes: iterable(function *() {\n        if (!partialNode.hasChildNodes) {\n          return;\n        }\n\n        let index = 0;\n        for (let child of partialNode.childNodes()) {\n          // Ensure child keys are globally unique by prepending the parent node's key\n          if (child.key != null) {\n            child.key = `${node.key}${child.key}`;\n          }\n\n          child.index = index;\n          let nodes = builder.getFullNode(child, builder.getChildState(state, child), node.key, node);\n          for (let node of nodes) {\n            index++;\n            yield node;\n          }\n        }\n      })\n    };\n\n    yield node;\n  }\n}\n\n// Wraps an iterator function as an iterable object, and caches the results.\nfunction iterable<T>(iterator: () => IterableIterator<Node<T>>): Iterable<Node<T>> {\n  let cache = [];\n  let iterable = null;\n  return {\n    *[Symbol.iterator]() {\n      for (let item of cache) {\n        yield item;\n      }\n\n      if (!iterable) {\n        iterable = iterator();\n      }\n\n      for (let item of iterable) {\n        cache.push(item);\n        yield item;\n      }\n    }\n  };\n}\n\ntype Wrapper = (element: ReactElement) => ReactElement;\nfunction compose(outer: Wrapper | void, inner: Wrapper | void): Wrapper {\n  if (outer && inner) {\n    return (element) => outer(inner(element));\n  }\n\n  if (outer) {\n    return outer;\n  }\n\n  if (inner) {\n    return inner;\n  }\n}\n\nfunction capitalize(str: string) {\n  return str[0].toUpperCase() + str.slice(1);\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 {Collection, CollectionBase, Node} from '@react-types/shared';\nimport {CollectionBuilder} from './CollectionBuilder';\nimport {useMemo, useRef} from 'react';\n\ntype CollectionFactory<T, C extends Collection<Node<T>>> = (node: Iterable<Node<T>>, prev: C | null) => C;\n\nexport function useCollection<T extends object, C extends Collection<Node<T>> = Collection<Node<T>>>(props: CollectionBase<T>, factory: CollectionFactory<T, C>, context?: unknown, invalidators: Array<any> = []): C {\n  let builder = useMemo(() => new CollectionBuilder<T>(), []);\n\n  let prev = useRef<C>(null);\n  return useMemo(() => {\n    let nodes = builder.build(props, context);\n    prev.current = factory(nodes, prev.current);\n    return prev.current;\n  // Don't invalidate when any prop changes, just the two we care about.\n  // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [builder, props.children, props.items, context, ...invalidators]);\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 {Node} from '@react-types/shared';\n\nconst cache = new WeakMap<Iterable<unknown>, number>();\n\nexport function getItemCount<T>(collection: Iterable<Node<T>>): number {\n  let count = cache.get(collection);\n  if (count != null) {\n    return count;\n  }\n\n  count = 0;\n  for (let item of collection) {\n    if (item.type === 'section') {\n      count += getItemCount(item.childNodes);\n    } else {\n      count++;\n    }\n  }\n\n  cache.set(collection, count);\n  return count;\n}\n"]},"metadata":{},"sourceType":"module"}