# domain/converters/structure.converter.ts

> 87 lines of code and 6 definitions.

Tree: Site tree
Language: typescript
Layer: processing
Canonical: https://banes-lab.com/anatomy/tree#file-domain-converters-structure-converter-ts
Source text: https://banes-lab.com/source/tree/domain/converters/structure.converter.ts.txt

Listed in [domain/converters](https://banes-lab.com/api/source/tree/domain/converters.md), after [domain/converters/source.link.converter.ts](https://banes-lab.com/source/tree/domain/converters/source.link.converter.ts.md) and before [domain/converters/tension.converter.ts](https://banes-lab.com/source/tree/domain/converters/tension.converter.ts.md).

## Definitions

- `overview` (lexical_declaration, line 24)
- `mapSection` (lexical_declaration, line 51)
- `structureSections` (lexical_declaration, line 90, exported)
- `cellSection` (lexical_declaration, line 33)
- `edgeSection` (lexical_declaration, line 70)
- `{ maps }` (lexical_declaration, line 52)

## Uses

- [domain/converters/ontology.converter.ts](https://banes-lab.com/source/tree/domain/converters/ontology.converter.ts.md)

## Used by

- [domain/converters/catalog.converter.ts](https://banes-lab.com/source/tree/domain/converters/catalog.converter.ts.md)

## Source

```typescript
import {
    CELL_INTRO,
    CELL_JOIN,
    CELL_TITLE,
    EDGE_INTRO,
    EDGE_LABEL,
    EDGE_TITLE,
    FOUNDATION_LAYERS_TITLE,
    FOUNDATION_SEQUENCE_TITLE,
    INVARIANT_GROUPS_TITLE,
    MAP_INTRO,
    MAP_TITLE,
    MEMBERS_LABEL,
    PATTERN_OPERATIONS_TITLE,
    TARGET_LABEL,
} from "#configuration/strings/reason.strings";
import { EDGE_SECTION_ID, MAP_SECTION_ID, UNCOVERED_SECTION_ID } from "#core/ids/ontology.ids";
import type { Section, Subsection } from "#types/document.types";
import { glossary, labeled, linkList, linkOf, linked, row } from "#domain/converters/ontology.converter";
import { FLOW_ARROW } from "#configuration/strings/ontology.strings";
import { REASON_SECTION_ICON } from "#configuration/icons/ontology.icons";
import type { ReasonView } from "#types/reason.types";

const overview = function overview(
    id: string,
    title: string,
    intro: string,
    subsections: readonly Subsection[],
): Section {
    return { icon: REASON_SECTION_ICON, id, intro, subsections, title };
};

const cellSection = function cellSection(reason: ReasonView): Section {
    return overview(UNCOVERED_SECTION_ID, CELL_TITLE, CELL_INTRO, [
        {
            blocks: [
                glossary(
                    reason.uncoveredCells.map((cell) =>
                        row(
                            cell.dimension.label + CELL_JOIN + cell.lens.label,
                            linkOf(cell.dimension) + CELL_JOIN + linkOf(cell.lens),
                        ),
                    ),
                ),
            ],
            title: CELL_TITLE,
        },
    ]);
};

const mapSection = function mapSection(reason: ReasonView): Section {
    const { maps } = reason;
    return overview(MAP_SECTION_ID, MAP_TITLE, MAP_INTRO, [
        {
            blocks: [glossary([row(FOUNDATION_SEQUENCE_TITLE, maps.foundationSequence.map(linkOf).join(FLOW_ARROW))])],
            title: FOUNDATION_SEQUENCE_TITLE,
        },
        {
            blocks: [glossary(maps.foundationLayers.map((layer) => row(layer.layer, linkList(layer.mathTypes))))],
            title: FOUNDATION_LAYERS_TITLE,
        },
        {
            blocks: [glossary(maps.invariantGroups.map((group) => row(group.group, linkList(group.members))))],
            title: INVARIANT_GROUPS_TITLE,
        },
        { blocks: [glossary([row(MEMBERS_LABEL, linkList(maps.patternOperations))])], title: PATTERN_OPERATIONS_TITLE },
    ]);
};

const edgeSection = function edgeSection(reason: ReasonView): Section {
    return overview(EDGE_SECTION_ID, EDGE_TITLE, EDGE_INTRO, [
        {
            blocks: [
                glossary(
                    reason.edges.map((edge) =>
                        row(
                            edge.from.label,
                            [linkOf(edge.from), linked(TARGET_LABEL, edge.to), labeled(EDGE_LABEL, edge.label)]
                                .filter((part): part is string => part !== null)
                                .join(FLOW_ARROW),
                        ),
                    ),
                ),
            ],
            title: EDGE_TITLE,
        },
    ]);
};

export const structureSections = function structureSections(reason: ReasonView): readonly Section[] {
    return [cellSection(reason), mapSection(reason), edgeSection(reason)];
};
```
