{"version":3,"file":"Collection-C75Ca86W.js","sources":["../../node_modules/reka-ui/dist/Primitive/usePrimitiveElement.js","../../node_modules/reka-ui/dist/Collection/Collection.js"],"sourcesContent":["import { unrefElement } from '@vueuse/core';\nimport { ref, computed } from 'vue';\n\nfunction usePrimitiveElement() {\n const primitiveElement = ref();\n const currentElement = computed(() => [\"#text\", \"#comment\"].includes(primitiveElement.value?.$el.nodeName) ? primitiveElement.value?.$el.nextElementSibling : unrefElement(primitiveElement));\n return {\n primitiveElement,\n currentElement\n };\n}\n\nexport { usePrimitiveElement as u };\n//# sourceMappingURL=usePrimitiveElement.js.map\n","import { ref, provide, inject, defineComponent, watch, h, watchEffect, markRaw, computed } from 'vue';\nimport { u as usePrimitiveElement } from '../Primitive/usePrimitiveElement.js';\nimport { S as Slot } from '../Primitive/Slot.js';\n\nconst ITEM_DATA_ATTR = \"data-reka-collection-item\";\nfunction useCollection(options = {}) {\n const { key = \"\", isProvider = false } = options;\n const injectionKey = `${key}CollectionProvider`;\n let context;\n if (isProvider) {\n const itemMap = ref(/* @__PURE__ */ new Map());\n const collectionRef = ref();\n context = {\n collectionRef,\n itemMap\n };\n provide(injectionKey, context);\n } else {\n context = inject(injectionKey);\n }\n const getItems = (includeDisabledItem = false) => {\n const collectionNode = context.collectionRef.value;\n if (!collectionNode)\n return [];\n const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));\n const items = Array.from(context.itemMap.value.values());\n const orderedItems = items.sort(\n (a, b) => orderedNodes.indexOf(a.ref) - orderedNodes.indexOf(b.ref)\n );\n if (includeDisabledItem)\n return orderedItems;\n else\n return orderedItems.filter((i) => i.ref.dataset.disabled !== \"\");\n };\n const CollectionSlot = defineComponent({\n name: \"CollectionSlot\",\n setup(_, { slots }) {\n const { primitiveElement, currentElement } = usePrimitiveElement();\n watch(currentElement, () => {\n context.collectionRef.value = currentElement.value;\n });\n return () => h(Slot, { ref: primitiveElement }, slots);\n }\n });\n const CollectionItem = defineComponent({\n name: \"CollectionItem\",\n inheritAttrs: false,\n props: {\n value: {\n // It accepts any value\n validator: () => true\n }\n },\n setup(props, { slots, attrs }) {\n const { primitiveElement, currentElement } = usePrimitiveElement();\n watchEffect((cleanupFn) => {\n if (currentElement.value) {\n const key2 = markRaw(currentElement.value);\n context.itemMap.value.set(key2, { ref: currentElement.value, value: props.value });\n cleanupFn(() => context.itemMap.value.delete(key2));\n }\n });\n return () => h(Slot, { ...attrs, [ITEM_DATA_ATTR]: \"\", ref: primitiveElement }, slots);\n }\n });\n const reactiveItems = computed(() => Array.from(context.itemMap.value.values()));\n const itemMapSize = computed(() => context.itemMap.value.size);\n return { getItems, reactiveItems, itemMapSize, CollectionSlot, CollectionItem };\n}\n\nexport { useCollection as u };\n//# sourceMappingURL=Collection.js.map\n"],"names":["usePrimitiveElement","primitiveElement","ref","currentElement","computed","includes","_a","value","$el","nodeName","_b","nextElementSibling","unrefElement","ITEM_DATA_ATTR","useCollection","options","key","isProvider","injectionKey","context","itemMap","Map","collectionRef","provide","inject","CollectionSlot","defineComponent","name","setup","_","slots","watch","h","Slot","CollectionItem","inheritAttrs","props","validator","attrs","watchEffect","cleanupFn","key2","markRaw","set","delete","getItems","includeDisabledItem","collectionNode","orderedNodes","Array","from","querySelectorAll","orderedItems","values","sort","a","b","indexOf","filter","i","dataset","disabled","reactiveItems","itemMapSize","size"],"mappings":"qeAGA,SAASA,IACP,MAAMC,EAAmBC,IACnBC,EAAiBC,GAAS,aAAM,MAAA,CAAC,QAAS,YAAYC,SAAS,OAAAC,EAAAL,EAAiBM,YAAO,EAAAD,EAAAE,IAAIC,UAAY,OAAAC,IAAiBH,YAAjB,EAAAG,EAAwBF,IAAIG,mBAAqBC,EAAaX,EAAgB,IACpL,MAAA,CACLA,mBACAE,iBAEJ,CCNA,MAAMU,EAAiB,4BACvB,SAASC,EAAcC,EAAU,IAC/B,MAAMC,IAAEA,EAAM,GAAIC,WAAAA,GAAa,GAAUF,EACnCG,EAAe,GAAGF,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