local context = require("./context") local show = require("./show") local switch = require("./switch") local indexes = require("./indexes") local values = require("./values") type Context = context.Context type Case = { match: any, children: () -> any, } local function Fragment(props: { children: any }) return props.children end local function For(props: { each: () -> { [K]: VI }, children: (VI, () -> K) -> VO, }): () -> { VO } return values(props.each, props.children) end local function Index(props: { each: () -> { [K]: VI }, children: (() -> VI, K) -> VO, }): () -> { VO } return indexes(props.each, props.children) end local function Switch(props: { condition: () -> any, children: { Case }, }) local children = props.children :: { [any]: any } local map = {} if children.match then map[children.match] = children.children else for _, node in children do map[node.match] = node.children end end return switch(props.condition)(map) end local function Case(props: Case): Case return props end local function Show(props: { when: any, children: () -> any, fallback: () -> any, }) return show(props.when, props.children, props.fallback) end local function Provider(props: { context: Context, value: T, children: () -> any, }) return props.context(props.value, props.children) end return { Fragment = Fragment, Switch = Switch, Case = Case, For = For, Index = Index, Show = Show, Provider = Provider, }