import { Html, debug_render } from "./html.ts"; import { Component } from "./jsx/jsx-runtime.ts"; type DOption = [Html, Dialogue]; type Dialogue = Html | [Html, ...DOption[]]; function not_empty(arr: T[]): arr is [T, ...T[]] { return arr.length > 0; } function reify_dialogue(d: Dialogue): Html { if (!Array.isArray(d)) return d; const [r, ...rest] = d; if (rest.length == 0) { return r; } else { return (
{r} {...rest.map(([r, d]) => { return (
{r}
{reify_dialogue(d)}
); })}
); } } const rd = reify_dialogue([ "Hi!", ["Hello!", "How are you!"], [ "Bye", [ ":(", ["Sorry", :D], ["Not sorry", D:], ], ], ]); debug_render(rd);