{"version":3,"file":"useEntityListSubTree.cjs","sources":["../../../../../packages/react-binding/src/accessorPropagation/useEntityListSubTree.ts"],"sourcesContent":["import { useCallback } from 'react'\nimport type { EntityListAccessor } from '@contember/binding'\nimport type { Alias, SugaredQualifiedEntityList, SugaredUnconstrainedQualifiedEntityList } from '@contember/binding'\nimport { useAccessorUpdateSubscription } from './useAccessorUpdateSubscription'\nimport { useEntityListSubTreeParameters } from './useEntityListSubTreeParameters'\nimport { useGetEntityListSubTree } from './useGetEntityListSubTree'\nimport { TreeRootId } from '@contember/binding'\n\nexport const useEntityListSubTree = (\n\tqualifiedEntityList: Alias | SugaredQualifiedEntityList | SugaredUnconstrainedQualifiedEntityList,\n\t...treeId: [TreeRootId | undefined] | []\n): EntityListAccessor => {\n\tconst getSubTree = useGetEntityListSubTree()\n\tconst parameters = useEntityListSubTreeParameters(qualifiedEntityList)\n\tconst hasTreeId = treeId.length > 0\n\tconst treeIdVal = treeId[0]\n\tconst getAccessor = useCallback(\n\t\t() => getSubTree(parameters, ...(hasTreeId ? [treeIdVal] : [])),\n\t\t[getSubTree, hasTreeId, parameters, treeIdVal],\n\t)\n\n\t// if (typeof parameters !== 'string' && parameters.value.hasOneRelationPath.length) {\n\t// \tthrow new BindingError(`useEntityListSubTree: cannot use hasOneRelationPath!`)\n\t// }\n\n\treturn useAccessorUpdateSubscription(getAccessor)[0]\n}\n"],"names":["useGetEntityListSubTree","useEntityListSubTreeParameters","useCallback","useAccessorUpdateSubscription"],"mappings":";;;;;;AAQa,MAAA,uBAAuB,CACnC,wBACG,WACqB;AACxB,QAAM,aAAaA,wBAAAA,wBAAwB;AACrC,QAAA,aAAaC,8DAA+B,mBAAmB;AAC/D,QAAA,YAAY,OAAO,SAAS;AAC5B,QAAA,YAAY,OAAO,CAAC;AAC1B,QAAM,cAAcC,MAAA;AAAA,IACnB,MAAM,WAAW,YAAY,GAAI,YAAY,CAAC,SAAS,IAAI,EAAG;AAAA,IAC9D,CAAC,YAAY,WAAW,YAAY,SAAS;AAAA,EAC9C;AAMO,SAAAC,8BAAA,8BAA8B,WAAW,EAAE,CAAC;AACpD;;"}