import {
    Board2dTabData,
    Board3dTabData,
    CategoryTabData,
    ComponentPinoutDisplayMode,
    ComponentTabData,
    DeviceTabData,
    EditorTool,
    FeatureState,
    GridStyle,
    Int64,
    LengthUnit,
    LibraryData,
    LibraryInfoData,
    LibraryListData,
    LibraryTabData,
    LibraryTreeViewItemType,
    NotificationData,
    NotificationType,
    OrganizationTabData,
    PackageTabData,
    PanelPage,
    ProjectData,
    RuleCheckData,
    RuleCheckState,
    RuleCheckType,
    SchematicTabData,
    SymbolTabData,
    TabData,
    TabType,
    TreeViewItemData,
    WindowSectionData,
} from "types.slint";

export global Data {
    // Preview mode: True for preview, set to false by the backend
    in property <bool> preview-mode: true;

    // Window data
    in property <int> window-id: 1;
    in property <string> window-title: "LibrePCB 1.2.0-unstable";

    // Detailed app version information etc.
    in property <string> about-librepcb-details: "LibrePCB Version: 1.2.0\nGit Revision:     f079fa97b\nBuild Date:       2024-12-02T19:12:08\nQt Version:       6.2.4 (built against 6.2.4)\nCPU Architecture: x86_64\nOperating System: Ubuntu Core 22\nPlatform Plugin:  xcb\nTLS Library:      OpenSSL 3.0.2 15 Mar 2022\nOCC Library:      OCCT 7.7.2\nRuntime:          Snap";

    // Current side panel page
    in property <PanelPage> panel-page: PanelPage.home;

    // Overlay "New Board"
    in property <int> new-board-overlay-project-index: -1;
    in property <bool> new-board-overlay-expanded: false;
    //in property <string> new-board-overlay-name;

    // Window sections
    in-out property <[WindowSectionData]> sections: [
        {
            tabs: [
                {
                    type: TabType.home,
                },
                {
                    type: TabType.create-library,
                    title: "New Lib",
                },
                {
                    type: TabType.download-library,
                    title: "Download Lib",
                },
                {
                    type: TabType.schematic,
                    title: "Schematic",
                    features: {
                        grid: FeatureState.enabled,
                        zoom: FeatureState.enabled,
                        export-graphics: FeatureState.enabled,
                        select: FeatureState.enabled,
                        save: FeatureState.enabled,
                        undo: FeatureState.enabled,
                        redo: FeatureState.enabled,
                        cut: FeatureState.enabled,
                        copy: FeatureState.enabled,
                        paste: FeatureState.enabled,
                        remove: FeatureState.enabled,
                        rotate: FeatureState.enabled,
                        mirror: FeatureState.enabled,
                        move-align: FeatureState.enabled,
                        snap-to-grid: FeatureState.enabled,
                        reset-texts: FeatureState.enabled,
                        lock: FeatureState.enabled,
                        unlock: FeatureState.enabled,
                        edit-properties: FeatureState.enabled,
                        find: FeatureState.enabled,
                    },
                    read-only: true,
                },
                {
                    type: TabType.board-2d,
                    title: "Board",
                    features: {
                        grid: FeatureState.enabled,
                        zoom: FeatureState.enabled,
                        export-graphics: FeatureState.enabled,
                        select: FeatureState.enabled,
                        save: FeatureState.enabled,
                        undo: FeatureState.enabled,
                        redo: FeatureState.enabled,
                        cut: FeatureState.enabled,
                        copy: FeatureState.enabled,
                        paste: FeatureState.enabled,
                        remove: FeatureState.enabled,
                        rotate: FeatureState.enabled,
                        mirror: FeatureState.enabled,
                        flip: FeatureState.enabled,
                        move-align: FeatureState.enabled,
                        snap-to-grid: FeatureState.enabled,
                        reset-texts: FeatureState.enabled,
                        lock: FeatureState.enabled,
                        unlock: FeatureState.enabled,
                        modify-line-width: FeatureState.enabled,
                        edit-properties: FeatureState.enabled,
                        find: FeatureState.enabled,
                    },
                    unsaved-changes: true,
                    find-autocompletions: ["C1", "C2", "C20", "U15"],
                    layers: [
                        {
                            name: "Top Copper",
                            color: #500000,
                            color-highlighted: #ff0000,
                            visible: true,
                        },
                        {
                            name: "Bottom Copper",
                            color: #000050,
                            color-highlighted: #0000ff,
                            visible: false,
                        },
                    ],
                },
                {
                    type: TabType.board-3d,
                    title: "3D",
                    features: {
                        save: FeatureState.enabled,
                        undo: FeatureState.enabled,
                        redo: FeatureState.enabled,
                    },
                },
            ],
            create-library-tabs: [
                { },
                {
                    name: "My Library",
                    name-error: "Name error",
                    description: "",
                    author: "",
                    author-default: "Me",
                    version: "",
                    version-default: "0.1",
                    version-error: "Version error",
                    url: "",
                    url-error: "URL error",
                    cc0: false,
                    directory: "",
                    directory-default: "My_Library.lplib",
                    directory-error: "Directory error",
                    valid: true,
                    creation-error: "Creation error",
                },
            ],
            download-library-tabs: [
                { },
                { },
                {
                    url: "",
                    url-error: "URL error",
                    url-suggestion: "https://example.com/library.zip",
                    directory: "",
                    directory-default: "My_Library.lplib",
                    directory-error: "Directory error",
                    valid: true,
                    download-running: true,
                    download-progress: 42,
                    download-status: "Download status",
                },
            ],
            schematic-tabs: [
                { },
                { },
                { },
                {
                    project-index: 0,
                    background-color: #ffffff,
                    foreground-color: #555555,
                    overlay-color: #dddddd78,
                    overlay-text-color: Colors.black,
                    grid-style: GridStyle.none,
                    unit: LengthUnit.millimeters,
                    show-pin-numbers: true,
                    install-libraries-msg: {
                        visible: true,
                        supports-dont-show-again: true,
                    },
                    add-drawing-frame-msg: {
                        visible: true,
                        supports-dont-show-again: true,
                    },
                    tool: EditorTool.select,
                    tool-overlay-text: "X0:   123.4567 mm\nY0:   123.4567 mm\nX1:   123.4567 mm\nY1:   123.4567 mm\n\ndX:   123.4567 mm\ndY:   123.4567 mm\n\nL:    123.4567 mm\na:     90.0000 °",
                    tool-layer: {
                        items: ["Layer 1", "Layer 2", "Layer with long name"],
                        current-index: 1,
                    },
                    tool-line-width: {
                        can-increase: true,
                        can-decrease: true,
                    },
                    tool-value: {
                        text: "{{PROJECT}}",
                        suggestions: ["{{Foo}}", "{{PROJECT}}", "{{Bar}}"],
                    },
                    tool-attribute-value: {
                        enabled: true,
                        text: "42",
                        placeholder: "CAPACITANCE",
                    },
                    tool-attribute-unit: {
                        items: ["mV", "V", "kV"],
                        current-index: 1,
                    },
                },
            ],
            board-2d-tabs: [
                { },
                { },
                { },
                { },
                {
                    project-index: 1,
                    background-color: #000000,
                    foreground-color: #999999,
                    overlay-color: Colors.gray,
                    overlay-text-color: Colors.white,
                    grid-style: GridStyle.none,
                    unit: LengthUnit.millimeters,
                    refreshing: false,
                    empty-schematics-msg: {
                        visible: true,
                        supports-dont-show-again: true,
                    },
                    setup-design-rules-msg: {
                        visible: true,
                        supports-dont-show-again: true,
                    },
                    place-devices-msg: {
                        visible: true,
                        supports-dont-show-again: true,
                    },
                    unplaced-components: ["C5: 100nF 50V", "U1: NE555"],
                    unplaced-components-index: 0,
                    unplaced-components-devices: ["C-0603", "C-0805", "3", "4", "5", "6", "7", "8", "end"],
                    unplaced-components-devices-index: 0,
                    unplaced-components-footprints: ["Density Level A", "Density Level B"],
                    unplaced-components-footprints-index: 0,
                    tool: EditorTool.select,
                    tool-overlay-text: "X0:   123.4567 mm\nY0:   123.4567 mm\nX1:   123.4567 mm\nY1:   123.4567 mm\n\ndX:   123.4567 mm\ndY:   123.4567 mm\n\nL:    123.4567 mm\na:     90.0000 °",
                    tool-net: {
                        items: ["Net 1", "Net 2", "Net 3"],
                        current-index: 1,
                    },
                    tool-netclass-name: "Netclass",
                    tool-layer: {
                        items: ["Layer 1", "Layer 2", "Layer with long name"],
                        current-index: 1,
                    },
                    tool-line-width: {
                        can-increase: true,
                    },
                    tool-size: {
                        can-increase: true,
                    },
                    tool-value: {
                        text: "{{PROJECT}}",
                        suggestions: ["{{Foo}}", "{{Bar}}"],
                    },
                },
            ],
            board-3d-tabs: [
                { },
                { },
                { },
                { },
                { },
                {
                    project-index: 0,
                    background-color: #e6f2ff,
                    foreground-color: Colors.black,
                    refreshing: false,
                    error: "Some error message here...",
                }
            ],
            current-tab-index: 3,
        },
        {
            tabs: [
                {
                    type: TabType.library,
                    title: "Library",
                    features: {
                        save: FeatureState.enabled,
                        undo: FeatureState.enabled,
                        redo: FeatureState.enabled,
                    },
                },
                {
                    type: TabType.component-category,
                    title: "Cmp Category",
                    features: {
                        save: FeatureState.enabled,
                        undo: FeatureState.enabled,
                        redo: FeatureState.enabled,
                    },
                },
                {
                    type: TabType.package-category,
                    title: "Pkg Category",
                    features: { },
                },
                {
                    type: TabType.symbol,
                    title: "Symbol",
                    features: {
                        save: FeatureState.enabled,
                        undo: FeatureState.enabled,
                        redo: FeatureState.enabled,
                        grid: FeatureState.enabled,
                        zoom: FeatureState.enabled,
                    },
                    read-only: true,
                },
                {
                    type: TabType.package,
                    title: "Package",
                    features: {
                        save: FeatureState.enabled,
                        undo: FeatureState.enabled,
                        redo: FeatureState.enabled,
                        grid: FeatureState.enabled,
                        zoom: FeatureState.enabled,
                        background-image: FeatureState.enabled,
                    },
                },
                {
                    type: TabType.component,
                    title: "Component",
                    features: {
                        save: FeatureState.enabled,
                        undo: FeatureState.enabled,
                        redo: FeatureState.enabled,
                    },
                },
                {
                    type: TabType.device,
                    title: "Device",
                    features: {
                        save: FeatureState.enabled,
                        undo: FeatureState.enabled,
                        redo: FeatureState.enabled,
                    },
                },
                {
                    type: TabType.organization,
                    title: "Organization",
                    features: {
                        save: FeatureState.enabled,
                        undo: FeatureState.enabled,
                        redo: FeatureState.enabled,
                    },
                },
            ],
            library-tabs: [
                {
                    library-index: 0,
                    wizard-mode: false,
                    page-index: 2,
                    icon: @image-url("../../../../../img/app/librepcb.svg"),
                    name: "Library",
                    description: "Foo Bar\nMultiline\nBlabla",
                    keywords: "Foo,Bar,Hello World",
                    author: "Somebody",
                    version: "0.1",
                    deprecated: false,
                    dependencies: [
                        {
                            icon: @image-url("../../../../../img/app/librepcb.svg"),
                            name: "LibrePCB Base",
                            checked: true,
                        },
                        {
                            icon: @image-url("../../../../../img/app/librepcb.svg"),
                            name: "LibrePCB Integrated Circuits",
                            checked: true,
                        },
                        {
                            icon: @image-url("../../../../../img/app/librepcb.svg"),
                            name: "Foo",
                            checked: false,
                        },
                        {
                            icon: @image-url("../../../../../img/app/librepcb.svg"),
                            name: "Bar",
                            checked: false,
                        },
                    ],
                    categories: [
                        {
                            type: LibraryTreeViewItemType.all,
                            elements: 1234,
                        },
                        {
                            type: LibraryTreeViewItemType.uncategorized,
                            elements: 99,
                        },
                        {
                            type: LibraryTreeViewItemType.component-category,
                        },
                        {
                            type: LibraryTreeViewItemType.component-category,
                            level: 1,
                            name: "Integrated Circuits",
                            elements: 42,
                        },
                        {
                            type: LibraryTreeViewItemType.component-category,
                            level: 2,
                            name: "Data Aquisition",
                            is-external: true,
                        },
                        {
                            type: LibraryTreeViewItemType.component-category,
                            level: 3,
                            name: "Analog-to-Digital Converters",
                            elements: 123,
                        },
                        {
                            type: LibraryTreeViewItemType.component-category,
                            level: 1,
                            name: "Miscallenous",
                            elements: 3,
                        },
                        {
                            type: LibraryTreeViewItemType.package-category,
                        },
                        {
                            type: LibraryTreeViewItemType.package-category,
                            level: 1,
                            name: "Capacitor",
                            elements: 42,
                        },
                        {
                            type: LibraryTreeViewItemType.package-category,
                            level: 2,
                            name: "Chip Capacitor",
                            is-external: true,
                        },
                        {
                            type: LibraryTreeViewItemType.organization,
                        },
                    ],
                    filtered-elements: [
                        {
                            type: LibraryTreeViewItemType.device,
                        },
                        {
                            type: LibraryTreeViewItemType.component,
                        },
                        {
                            type: LibraryTreeViewItemType.symbol,
                        },
                        {
                            type: LibraryTreeViewItemType.package,
                        },
                        {
                            type: LibraryTreeViewItemType.symbol,
                            level: 1,
                            name: "NE555",
                            summary: "Foo bar very long text bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla",
                        },
                    ],
                    checks: {
                        type: RuleCheckType.library-check,
                        state: RuleCheckState.up-to-date,
                        unapproved: 2,
                    },
                },
            ],
            component-category-tabs: [
                { },
                {
                    library-index: 0,
                    path: "cmpcat1",
                    name: "Component Category",
                    name-error: "Invalid",
                    description: "Foo Bar\nMultiline\nBlabla",
                    keywords: "Foo,Bar,Hello World",
                    author: "Somebody",
                    version: "0.1",
                    version-error: "Invalid",
                    deprecated: false,
                    parents: ["Root category", "Integrated Circuits", "Timers"],
                    parents-tree: [
                        {
                            level: 0,
                            icon: @image-url("../../../../bootstrap-icons/icons/folder.svg"),
                            text: "Root Category",
                        },
                        {
                            level: 1,
                            icon: @image-url("../../../../bootstrap-icons/icons/folder.svg"),
                            text: "Integrated Circuits",
                        },
                        {
                            level: 2,
                            icon: @image-url("../../../../bootstrap-icons/icons/folder.svg"),
                            text: "Data Aquisition",
                        },
                        {
                            level: 1,
                            icon: @image-url("../../../../bootstrap-icons/icons/folder.svg"),
                            text: "Passive Elements",
                        },
                    ],
                    checks: {
                        type: RuleCheckType.component-category-check,
                        state: RuleCheckState.up-to-date,
                        messages: [
                            {
                                severity: NotificationType.info,
                                message: "Hint message",
                                description: "Hint description.",
                                approved: false,
                                supports-autofix: true,
                            },
                        ],
                        unapproved: 0,
                    },
                },
            ],
            package-category-tabs: [
                { },
                { },
                {
                    library-index: 0,
                    path: "pkgcat1",
                    name: "Package Category",
                    name-error: "Invalid",
                    description: "Foo Bar\nMultiline\nBlabla",
                    keywords: "Foo,Bar,Hello World",
                    author: "Somebody",
                    version: "0.1",
                    version-error: "Invalid",
                    deprecated: false,
                    parents: ["Root category", "Integrated Circuits", "Timers"],
                    parents-tree: [
                        {
                            level: 0,
                            icon: @image-url("../../../../bootstrap-icons/icons/folder.svg"),
                            text: "Root Category",
                        },
                        {
                            level: 1,
                            icon: @image-url("../../../../bootstrap-icons/icons/folder.svg"),
                            text: "Integrated Circuits",
                        },
                        {
                            level: 2,
                            icon: @image-url("../../../../bootstrap-icons/icons/folder.svg"),
                            text: "Data Aquisition",
                        },
                        {
                            level: 1,
                            icon: @image-url("../../../../bootstrap-icons/icons/folder.svg"),
                            text: "Passive Elements",
                        },
                    ],
                    checks: {
                        type: RuleCheckType.package-category-check,
                        state: RuleCheckState.up-to-date,
                        unapproved: 0,
                    },
                },
            ],
            symbol-tabs: [
                { },
                { },
                { },
                {
                    library-index: 0,
                    path: "symbol1",
                    wizard-mode: false,
                    page-index: 1,
                    name: "Symbol",
                    description: "Foo Bar\nMultiline\nBlabla",
                    keywords: "Foo,Bar,Hello World",
                    author: "Somebody",
                    version: "0.1",
                    deprecated: false,
                    categories: [
                        {
                            uuid: "1",
                            names: ["Integrated Circuit", "Timers"],
                        },
                        {
                            uuid: "2",
                            names: ["Foo", "Bar", "Foobar"],
                        },
                        {
                            uuid: "3",
                            names: ["Miscallenous"],
                        },
                    ],
                    categories-tree: [
                        {
                            level: 0,
                            icon: @image-url("../../../../bootstrap-icons/icons/folder.svg"),
                            text: "Root Category",
                        },
                        {
                            level: 1,
                            icon: @image-url("../../../../bootstrap-icons/icons/folder.svg"),
                            text: "Integrated Circuits",
                        },
                        {
                            level: 2,
                            icon: @image-url("../../../../bootstrap-icons/icons/folder.svg"),
                            text: "Data Aquisition",
                        },
                        {
                            level: 1,
                            icon: @image-url("../../../../bootstrap-icons/icons/folder.svg"),
                            text: "Passive Elements",
                        },
                    ],
                    checks: {
                        type: RuleCheckType.symbol-check,
                        state: RuleCheckState.up-to-date,
                        unapproved: 2,
                        errors: 1,
                    },
                    background-color: #ffffff,
                    foreground-color: #555555,
                    overlay-color: #dddddd78,
                    overlay-text-color: Colors.black,
                    files-modified: true,
                    interface-broken-msg: true,
                    import-pins-msg: {
                        visible: true,
                        supports-dont-show-again: false,
                    },
                    tool: EditorTool.select,
                    tool-overlay-text: "X0:   123.4567 mm\nY0:   123.4567 mm\nX1:   123.4567 mm\nY1:   123.4567 mm\n\ndX:   123.4567 mm\ndY:   123.4567 mm\n\nL:    123.4567 mm\na:     90.0000 °",
                    tool-layer: {
                        items: ["Layer 1", "Layer 2", "Layer with long name"],
                        current-index: 1,
                    },
                    tool-line-width: {
                        can-increase: true,
                        can-decrease: true,
                    },
                    tool-value: {
                        text: "{{PROJECT}}",
                        suggestions: ["{{Foo}}", "{{PROJECT}}", "{{Bar}}"],
                    },
                },
            ],
            package-tabs: [
                { },
                { },
                { },
                { },
                {
                    library-index: 0,
                    path: "package1",
                    wizard-mode: false,
                    page-index: 2,
                    view-3d: false,
                    name: "Package",
                    description: "Foo Bar\nMultiline\nBlabla",
                    keywords: "Foo,Bar,Hello World",
                    author: "Somebody",
                    version: "0.1",
                    deprecated: false,
                    categories: [
                        {
                            uuid: "1",
                            names: ["Integrated Circuit", "Timers"],
                        },
                        {
                            uuid: "2",
                            names: ["Foo", "Bar", "Foobar"],
                        },
                        {
                            uuid: "3",
                            names: ["Miscallenous"],
                        },
                    ],
                    categories-tree: [
                        {
                            level: 0,
                            text: "Root Category",
                        },
                        {
                            level: 1,
                            text: "Integrated Circuits",
                        },
                    ],
                    pads: [
                        {
                            id: "deadbeef",
                            name: "1",
                        },
                        {
                            id: "12345678",
                            name: "2",
                        },
                        {
                            id: "dead1234",
                            name: "SHIELD",
                            name-error: "Invalid",
                        },
                    ],
                    new-pad-name-error: "Invalid",
                    footprints: [
                        {
                            id: "deadbeef",
                            name: "default",
                            models: [true, true, true],
                        },
                        {
                            id: "12345678",
                            name: "large",
                            models: [false, true, false],
                        },
                        {
                            id: "dead1234",
                            name: "small",
                            models: [true, false, false],
                        },
                    ],
                    models: [
                        {
                            id: "step1234",
                            name: "FooBar.step",
                        },
                        {
                            id: "1234step",
                            name: "Hello World.step",
                        },
                        {
                            id: "deadstep",
                            name: "foobar.step",
                        },
                    ],
                    checks: {
                        type: RuleCheckType.package-check,
                        state: RuleCheckState.up-to-date,
                        unapproved: 2,
                        errors: 1,
                    },
                    background-color: #000000,
                    foreground-color: #999999,
                    overlay-color: Colors.gray,
                    overlay-text-color: Colors.white,
                    grid-style: GridStyle.none,
                    unit: LengthUnit.millimeters,
                    background-image-set: false,
                    refreshing: false,
                    opengl-error: "Foo bar failed!\nNo worries...",
                    interface-broken-msg: true,
                    tool: EditorTool.select,
                    tool-overlay-text: "X0:   123.4567 mm\nY0:   123.4567 mm\nX1:   123.4567 mm\nY1:   123.4567 mm\n\ndX:   123.4567 mm\ndY:   123.4567 mm\n\nL:    123.4567 mm\na:     90.0000 °",
                    tool-layer: {
                        items: ["Layer 1", "Layer 2", "Layer with long name"],
                        current-index: 1,
                    },
                    tool-line-width: {
                        can-increase: true,
                        can-decrease: true,
                    },
                    tool-value: {
                        text: "{{PROJECT}}",
                        suggestions: ["{{Foo}}", "{{PROJECT}}", "{{Bar}}"],
                    },
                    tool-package-pad: {
                        items: ["(unconnected)", "Pad 1", "Pad 2"],
                        current-index: 1,
                    },
                },
            ],
            component-tabs: [
                { },
                { },
                { },
                { },
                { },
                {
                    library-index: 0,
                    path: "component1",
                    wizard-mode: false,
                    page-index: 2,
                    name: "Component",
                    description: "Foo Bar\nMultiline\nBlabla",
                    keywords: "Foo,Bar,Hello World",
                    author: "Somebody",
                    version: "0.1",
                    deprecated: false,
                    categories: [
                        {
                            uuid: "1",
                            names: ["Integrated Circuit", "Timers"],
                        },
                        {
                            uuid: "2",
                            names: ["Foo", "Bar", "Foobar"],
                        },
                        {
                            uuid: "3",
                            names: ["Miscallenous"],
                        },
                    ],
                    categories-tree: [
                        {
                            level: 0,
                            text: "Root Category",
                        },
                        {
                            level: 1,
                            text: "Integrated Circuits",
                        },
                    ],
                    prefix-error: "Recommended",
                    default-value-error: "Recommended",
                    attributes: [
                        {
                            key: "FOO",
                            type: 1,
                            value: "100",
                            unit: 0,
                        },
                        {
                            key: "FOO",
                            key-error: "Duplicate",
                            type: 1,
                            value: "100",
                            value-valid: true,
                            unit: 0,
                        },
                        { },
                    ],
                    cmp-signals: [
                        {
                            id: "8402bf9a",
                            name: "GND",
                            forced-net-name: "",
                            required: true,
                        },
                        {
                            id: "23485b92",
                            name: "3V3",
                            name-error: "Invalid",
                            forced-net-name: "",
                            required: false,
                        },
                        {
                            id: "9a09e67c",
                            name: "5V",
                            forced-net-name: "FORCED",
                            required: true,
                        },
                    ],
                    signal-names: ["(unconnected)", "GND", "3V3", "5V"],
                    variants: [
                        {
                            id: "9a09e67c",
                            name: "default",
                            description: "The default variant",
                            norm: "ISO1234",
                            gates: [
                                {
                                    id: "8402bf9a",
                                    symbol-name: "Power",
                                    symbol-x: { },
                                    symbol-y: { },
                                    symbol-rotation: 0,
                                    required: true,
                                    suffix: "A",
                                    pinout: [
                                        {
                                            pin-name: "1",
                                            signal-index: 1,
                                            display-mode: ComponentPinoutDisplayMode.none,
                                        },
                                        {
                                            pin-name: "2",
                                            signal-index: 2,
                                            display-mode: ComponentPinoutDisplayMode.net-name,
                                        },
                                    ],
                                },
                                {
                                    id: "23485b92",
                                    symbol-name: "Logic",
                                    symbol-x: { },
                                    symbol-y: { },
                                    symbol-rotation: 0,
                                    required: true,
                                    suffix: "B",
                                    pinout: [
                                        {
                                            pin-name: "3",
                                        },
                                        {
                                            pin-name: "4",
                                        },
                                    ],
                                },
                            ],
                            has-unassigned-signals: true,
                        }
                    ],
                    checks: {
                        type: RuleCheckType.component-check,
                        state: RuleCheckState.up-to-date,
                        unapproved: 2,
                        errors: 0,
                    },
                },
            ],
            device-tabs: [
                { },
                { },
                { },
                { },
                { },
                { },
                {
                    library-index: 0,
                    path: "device1",
                    wizard-mode: false,
                    page-index: 1,
                    name: "Device",
                    description: "Foo Bar\nMultiline\nBlabla",
                    keywords: "Foo,Bar,Hello World",
                    author: "Somebody",
                    version: "0.1",
                    deprecated: false,
                    categories: [
                        {
                            uuid: "1",
                            names: ["Integrated Circuit", "Timers"],
                        },
                        {
                            uuid: "2",
                            names: ["Foo", "Bar", "Foobar"],
                        },
                        {
                            uuid: "3",
                            names: ["Miscallenous"],
                        },
                    ],
                    categories-tree: [
                        {
                            level: 0,
                            icon: @image-url("../../../../bootstrap-icons/icons/folder.svg"),
                            text: "Root Category",
                        },
                        {
                            level: 1,
                            icon: @image-url("../../../../bootstrap-icons/icons/folder.svg"),
                            text: "Integrated Circuits",
                        },
                        {
                            level: 2,
                            icon: @image-url("../../../../bootstrap-icons/icons/folder.svg"),
                            text: "Data Aquisition",
                        },
                        {
                            level: 1,
                            icon: @image-url("../../../../bootstrap-icons/icons/folder.svg"),
                            text: "Passive Elements",
                        },
                    ],
                    datasheet-url: "https://librepcb.org",
                    attributes: [
                        {
                            key: "FOO",
                            type: 1,
                            value: "100",
                            unit: 0,
                        },
                        { },
                    ],
                    component-error: false,
                    component-name: "Resistor",
                    component-description: "Standard resistor\nBlabla...",
                    package-error: true,
                    package-name: "",
                    package-description: "SMT 0805 resistor\nBlabla",
                    signal-names: ["(unconnected)", "GND", "3V3", "5V"],
                    pinout: [
                        {
                            pad-name: "1",
                            signal-uuid: "deadbeef",
                            signal-index: 0,
                        },
                        {
                            pad-name: "2",
                            signal-uuid: "12345678",
                            signal-index: -1,
                        },
                        {
                            pad-name: "3",
                            signal-uuid: "1234beef",
                            signal-index: 1,
                        },
                    ],
                    parts: [
                        {
                            mpn: "R0805FOOBAR",
                            manufacturer: "Any Company",
                            attributes: [
                                {
                                    key: "FOO",
                                    type: 1,
                                    value: "100",
                                    unit: 0,
                                },
                                {
                                    key: "BAR",
                                    type: 0,
                                    value: "hello",
                                    unit: -1,
                                },
                                { },
                            ],
                        },
                        {
                            mpn: "R0805FOOBARTR",
                            manufacturer: "Any Company",
                            attributes: [{ }],
                        },
                        { },
                    ],
                    checks: {
                        type: RuleCheckType.device-check,
                        state: RuleCheckState.up-to-date,
                        unapproved: 2,
                        errors: 0,
                    },
                    has-unconnected-pads: true,
                    has-auto-connectable-pads: true,
                    all-pads-unconnected: true,
                    interactive-pinout-number: 0,
                    interactive-pinout-pad: "!FOO",
                    interactive-pinout-filter: "",
                    interactive-pinout-signals: [
                        {
                            name: "",  // Unconnected
                            used: false,
                        },
                        {
                            name: "Foo",
                            used: false,
                        },
                        {
                            name: "!BAR",
                            used: true,
                        },
                    ],
                    interactive-pinout-signal-index: 2,
                },
            ],
            organization-tabs: [
                { },
                { },
                { },
                { },
                { },
                { },
                { },
                {
                    library-index: 0,
                    path: "corp1",
                    name: "Organization",
                    name-error: "Invalid",
                    description: "Foo Bar\nMultiline\nBlabla",
                    keywords: "Foo,Bar,Hello World",
                    author: "Somebody",
                    version: "0.1",
                    version-error: "Invalid",
                    deprecated: false,
                    priority: 42,
                    pcb-design-rules: [
                        { name: "Standard" },
                        { name: "Advanced" },
                    ],
                    pcb-output-jobs: 3,
                    assembly-output-jobs: 0,
                    checks: {
                        type: RuleCheckType.organization-check,
                        state: RuleCheckState.up-to-date,
                        messages: [],
                        unapproved: 0,
                    },
                },
            ],
            current-tab-index: 4,
        },
    ];

    // Which section currently has focus
    in-out property <int> current-section-index: 0;

    // Static status bar message
    in property <string> status-bar-message;

    // Temporary status tip when hovering interactive UI elements
    in property <string> status-tip;

    // Current cursor coordinates to be shown in status bar
    in property <string> cursor-coordinates: "123.456, 123.456";

    // Workspace: Folder path
    in property <string> workspace-path: "/path/to/workspace";

    // Workspace: Folder tree
    in property <[TreeViewItemData]> workspace-folder-tree: [
        {
            icon: @image-url("../../../../../img/places/project_folder.png"),
            text: "folder-1",
            user-data: "folder-1",
            has-children: true,
            expanded: false,
        },
        {
            icon: @image-url("../../../../../img/places/project_folder.png"),
            text: "folder-2",
            user-data: "folder-2",
            is-project-file-or-folder: true,
            has-children: true,
            expanded: true,
        },
        {
            level: 1,
            icon: @image-url("../../../../../img/app/librepcb.svg"),
            text: "project-1.lpp",
            user-data: "project-1.lpp",
            is-project-file-or-folder: true,
            supports-pinning: true,
            pinned: true,
        },
        {
            level: 1,
            icon: @image-url("../../../../../img/app/librepcb.svg"),
            text: "project-2.lpp",
            user-data: "project-2.lpp",
            is-project-file-or-folder: true,
            supports-pinning: true,
            pinned: false,
        },
    ];

    // Workspace contains standard components (resistor etc) from Base library
    in property <bool> workspace-contains-standard-components: true;

    // Quick access items
    in property <[TreeViewItemData]> quick-access-items: [
        {
            icon: @image-url("../../../../../img/app/librepcb.svg"),
            text: "project-1.lpp",
            hint: "foo/bar/project-1.lpp",
            user-data: "foo/bar/project-1.lpp",
            supports-pinning: true,
            pinned: false,
        },
        {
            icon: @image-url("../../../../../img/app/librepcb.svg"),
            text: "project-2.lpp",
            hint: "fooooooooooo/baaaaaaaaaaaaaaaaaaaaaaaar/project-2.lpp",
            user-data: "fooooooooooo/baaaaaaaaaaaaaaaaaaaaaaaar/project-2.lpp",
            supports-pinning: true,
            pinned: false,
        },
        {
            icon: @image-url("../../../../../img/app/librepcb.svg"),
            text: "project-3.lpp",
            hint: "foo/bar/project-3.lpp",
            user-data: "foo/bar/project-3.lpp",
            supports-pinning: true,
            pinned: true,
        },
    ];

    // Project preview: Project file path
    in property <string> project-preview-path;

    // Project preview: Rendering in progress
    in property <bool> project-preview-rendering: false;

    // Project preview: Preview image result
    in property <image> project-preview-image;

    // Notifications: Data model
    in property <[NotificationData]> notifications: [
        {
            type: NotificationType.tip,
            title: "Tip",
            description: "This is a tip notification",
            button-text: "Do Something",
            supports-dont-show-again: true,
            unread: true,
        },
        {
            type: NotificationType.info,
            title: "Info",
            description: "This is an info notification",
            unread: true,
        },
        {
            type: NotificationType.warning,
            title: "Warning",
            description: "This is a warning notification",
        },
        {
            type: NotificationType.critical,
            title: "Critical",
            description: "This is a critical notification",
        },
        {
            type: NotificationType.progress,
            title: "Progress",
            description: "This is a progress notification",
            progress: 50,
        },
    ];

    // Notifications: Unread messages count
    in property <int> notifications-unread: 2;

    // Notifications: Index of current progress notification (-1 if none)
    in property <int> notifications-progress-index: 4;

    // Notifications: Popup shown status
    in property <bool> notifications-shown: false;

    // Locally installed libraries (may be filtered)
    in property <[LibraryInfoData]> local-libraries: [
        {
            path: "/foo/bar",
            icon: @image-url("../../../../../img/app/librepcb.svg"),
            name: "My Library",
            installed-version: "1.0",
            highlight: true,
        },
        {
            path: "/foo/bar",
            icon: @image-url("../../../../../img/app/librepcb.svg"),
            name: "LibrePCB Base",
            description: "Official LibrePCB Base Library.",
            installed-version: "1.0",
            online-version: "1.1",
            outdated: true,
        },
        {
            path: "/foo/bar",
            icon: @image-url("../../../../../img/app/librepcb.svg"),
            name: "LibrePCB Base",
            description: "Official LibrePCB Base Library.",
            installed-version: "1.1",
            online-version: "1.1",
        },
    ];

    // Metadata about local-libraries
    in property <LibraryListData> local-libraries-data: {
        refreshing-error: "Local error!",
        count: 3,
    };

    // Remote libraries, either installed or not (may be filtered)
    in property <[LibraryInfoData]> remote-libraries: [
        {
            uuid: "x",
            icon: @image-url("../../../../../img/app/librepcb.svg"),
            name: "Microchip Technology / Atmel",
            description: "Integrated circuits and more (unofficial).",
            installed-version: "0.5",
            online-version: "0.7",
            outdated: true,
            checked: true,
        },
        {
            uuid: "x",
            icon: @image-url("../../../../../img/app/librepcb.svg"),
            name: "LibrePCB Base",
            description: "Official LibrePCB Base Library.",
            installed-version: "1.2.3",
            online-version: "1.2.3",
            checked: false,
        },
        {
            uuid: "x",
            icon: @image-url("../../../../../img/app/librepcb.svg"),
            name: "LibrePCB Connectors",
            description: "Official LibrePCB Connectors Library.",
            installed-version: "1.2.3",
            online-version: "1.2.3",
            checked: true,
        },
        {
            icon: @image-url("../../../../../img/app/librepcb.svg"),
            name: "LibrePCB Connectors",
            description: "Official LibrePCB Connectors Library.",
            installed-version: "1.2.3",
            online-version: "1.2.3",
        },
        {
            uuid: "x",
            icon: @image-url("../../../../../img/app/librepcb.svg"),
            name: "LibrePCB Integrated Circuits",
            description: "Official LibrePCB Integrated Circuits Library",
            online-version: "0.7",
            checked: true,
        },
        {
            uuid: "x",
            icon: @image-url("../../../../../img/app/librepcb.svg"),
            name: "Microchip Technology / Atmel",
            description: "Integrated circuits and more (unofficial).",
            online-version: "0.8",
            recommended: true,
            progress: 42,
        },
    ];

    // Metadata about remote-libraries
    in property <LibraryListData> remote-libraries-data: {
        refreshing-error: "Some error occurred.\nFoo bar...",
        count: 5,
        installed: 3,
        outdated: 2,
        pending-installs: 1,
        pending-updates: 2,
        pending-uninstalls: 3,
        pending-oneway-uninstalls: 1,
        operation-in-progress: false,
    };

    // Filter applied to both local libraries and remote libraries
    in property <string> libraries-panel-filter: "Foo";

    // Flag if the background library scan is currently running
    in property <bool> libraries-rescan-in-progress: false;

    // All opened libraries (editors)
    in property <[LibraryData]> libraries: [
        {
            valid: true,
            path: "/path/to/library-1.lplib",
            name: "Library 1",
        },
        {
            valid: true,
            path: "/path/to/library-2.lplib",
            name: "Library 2",
        },
    ];

    // Currently active library editor index
    out property <int> current-library-index: -1;

    // All currently opened projects
    in property <[ProjectData]> projects: [
        {
            valid: true,
            path: "/path/to/project-1.lpp",
            name: "Project 1",
            schematics: [
                { name:"Power" },
                { name:"Logic" },
            ],
            boards: [
                {
                    name:"Default",
                    drc: {
                        type: RuleCheckType.drc,
                        state: RuleCheckState.up-to-date,
                        messages: [
                            {
                                severity: NotificationType.info,
                                message: "Hint message",
                                description: "Hint description.",
                                approved: false,
                                autofixed: false,
                                supports-autofix: true,
                            },
                            {
                                severity: NotificationType.warning,
                                message: "Warning message",
                                description: "Warning description.",
                                approved: true,
                                autofixed: false,
                                supports-autofix: false,
                            },
                            {
                                severity: NotificationType.critical,
                                message: "Error message fixed",
                                description: "Error description.",
                                approved: false,
                                autofixed: true,
                                supports-autofix: true,
                            },
                            {
                                severity: NotificationType.critical,
                                message: "Error message",
                                description: "Error description.",
                                approved: false,
                                autofixed: false,
                                supports-autofix: true,
                            },
                        ],
                        unapproved: 0,
                        execution-error: "",
                    },
                    order-info-url: "https://api.librepcb.org/api/info/",
                    order-status: "Success! Continue in the web browser:",
                    order-upload-progress: -1,
                    order-upload-url: "https://fab.librepcb.org/fooobaaaar",
                },
                { name:"Experiment" },
            ],
            writable: true,
            unsaved-changes: true,
            buses: [
                {
                    name: "SPI1",
                },
                {
                    name: "SPI2",
                },
            ],
            erc: {
                type: RuleCheckType.erc,
                state: RuleCheckState.outdated,
                messages: [
                    {
                        severity: NotificationType.info,
                        message: "Hint message",
                        description: "Hint description.",
                        approved: false,
                        autofixed: false,
                        supports-autofix: true,
                    },
                    {
                        severity: NotificationType.warning,
                        message: "Warning message",
                        description: "Warning description.",
                        approved: true,
                        autofixed: false,
                        supports-autofix: false,
                    },
                    {
                        severity: NotificationType.critical,
                        message: "Error message",
                        description: "Error description.",
                        approved: false,
                        autofixed: false,
                        supports-autofix: true,
                    },
                ],
                unapproved: 42,
                execution-error: "",
            },
        },
        {
            valid: true,
            path: "/path/to/project-2.lpp",
            name: "Project 2",
            schematics: [
                { name:"Power" },
                { name:"Logic" },
            ],
            boards: [
                {
                    name:"Default",
                    drc: {
                        type: RuleCheckType.drc,
                    },
                    order-status: "Uploading...",
                    order-info-url: "https://api.librepcb.org/api/info/",
                    order-upload-progress: 30,
                },
                {
                    name:"Experiment",
                    drc: {
                        type: RuleCheckType.drc,
                    },
                },
            ],
            writable: false,
            erc: {
                type: RuleCheckType.erc,
            },
        },
    ];

    // Currently active project index
    out property <int> current-project-index: 0;

    // Min/max values
    in property <Int64> min-length;

    // All available norms
    in property <[string]> norms: ["IEC 60617", "IEEE 315"];

    // All available attribute types and their units
    // Attention: The types order corresponds to AttributeType::getAllTypes()
    // and the units order to AttributeType::getAvailableUnits()!
    in property <[string]> attribute-types: ["String", "Capacitance", "Power"];
    in property <[[string]]> attribute-units: [[], ["nF", "F"], ["mW", "W", "kW"]];

    // Rule check panel: Checked state of the "zoom to location" feature
    in property <bool> erc-zoom-to-location: true;
    in property <bool> drc-zoom-to-location: true;

    // Order PCB panel: Checked state of the "open web browser after upload" feature
    in property <bool> order-pcb-open-web-browser: true;

    // CALCULATED, DO NET SET IN BACKEND
    in-out property <WindowSectionData> current-section: sections[current-section-index];
    in-out property <TabData> current-tab: current-section.tabs[current-section.current-tab-index];
    out property <int> remote-libraries-pending-operations: remote-libraries-data.pending-installs + remote-libraries-data.pending-updates + remote-libraries-data.pending-uninstalls;
    out property <bool> libraries-operation-in-progress: local-libraries-data.operation-in-progress || remote-libraries-data.operation-in-progress;
    out property <LibraryData> current-library: libraries[current-library-index];
    out property <ProjectData> current-project: projects[current-project-index];
    out property <LibraryTabData> current-library-tab: current-section.library-tabs[current-section.current-tab-index];
    out property <CategoryTabData> current-component-category-tab: current-section.component-category-tabs[current-section.current-tab-index];
    out property <CategoryTabData> current-package-category-tab: current-section.package-category-tabs[current-section.current-tab-index];
    out property <SymbolTabData> current-symbol-tab: current-section.symbol-tabs[current-section.current-tab-index];
    out property <PackageTabData> current-package-tab: current-section.package-tabs[current-section.current-tab-index];
    out property <ComponentTabData> current-component-tab: current-section.component-tabs[current-section.current-tab-index];
    out property <DeviceTabData> current-device-tab: current-section.device-tabs[current-section.current-tab-index];
    out property <OrganizationTabData> current-organization-tab: current-section.organization-tabs[current-section.current-tab-index];
    out property <SchematicTabData> current-schematic-tab: current-section.schematic-tabs[current-section.current-tab-index];
    out property <Board2dTabData> current-board-2d-tab: current-section.board-2d-tabs[current-section.current-tab-index];
    out property <Board3dTabData> current-board-3d-tab: current-section.board-3d-tabs[current-section.current-tab-index];
    in-out property <int> current-rule-check-project-index: 0;
    in-out property <int> current-rule-check-board-index: 0;
    out property <RuleCheckData> current-rule-check: {
        if (current-rule-check-project-index >= 0) && (current-rule-check-project-index < projects.length) {
            if (current-rule-check-board-index >= 0) && (current-rule-check-board-index < projects[current-rule-check-project-index].boards.length) {
                projects[current-rule-check-project-index].boards[current-rule-check-board-index].drc
            } else {
                projects[current-rule-check-project-index].erc
            }
        } else if current-tab.type == TabType.library {
            current-library-tab.checks
        } else if current-tab.type == TabType.component-category {
            current-component-category-tab.checks
        } else if current-tab.type == TabType.package-category {
            current-package-category-tab.checks
        } else if current-tab.type == TabType.symbol {
            current-symbol-tab.checks
        } else if current-tab.type == TabType.package {
            current-package-tab.checks
        } else if current-tab.type == TabType.component {
            current-component-tab.checks
        } else if current-tab.type == TabType.device {
            current-device-tab.checks
        } else if current-tab.type == TabType.organization {
            current-organization-tab.checks
        } else {
            projects[-1].erc  // Not nice, but avoids compiler warning
        }
    };

    public function current-tab-changed() {
        if current-tab.type == TabType.library {
            current-project-index = -1;
            current-rule-check-project-index = -1;
            current-rule-check-board-index = -1;
            current-library-index = current-library-tab.library-index;
        } else if current-tab.type == TabType.component-category {
            current-project-index = -1;
            current-rule-check-project-index = -1;
            current-rule-check-board-index = -1;
            current-library-index = current-component-category-tab.library-index;
        } else if current-tab.type == TabType.package-category {
            current-project-index = -1;
            current-rule-check-project-index = -1;
            current-rule-check-board-index = -1;
            current-library-index = current-package-category-tab.library-index;
        } else if current-tab.type == TabType.symbol {
            current-project-index = -1;
            current-rule-check-project-index = -1;
            current-rule-check-board-index = -1;
            current-library-index = current-symbol-tab.library-index;
        } else if current-tab.type == TabType.package {
            current-project-index = -1;
            current-rule-check-project-index = -1;
            current-rule-check-board-index = -1;
            current-library-index = current-package-tab.library-index;
        } else if current-tab.type == TabType.component {
            current-project-index = -1;
            current-rule-check-project-index = -1;
            current-rule-check-board-index = -1;
            current-library-index = current-component-tab.library-index;
        } else if current-tab.type == TabType.device {
            current-project-index = -1;
            current-rule-check-project-index = -1;
            current-rule-check-board-index = -1;
        } else if current-tab.type == TabType.organization {
            current-project-index = -1;
            current-rule-check-project-index = -1;
            current-rule-check-board-index = -1;
        } else if current-tab.type == TabType.schematic {
            current-library-index = -1;
            current-project-index = current-schematic-tab.project-index;
            current-rule-check-project-index = current-project-index;
            current-rule-check-board-index = -1;
        } else if current-tab.type == TabType.board-2d {
            current-library-index = -1;
            current-project-index = current-board-2d-tab.project-index;
            current-rule-check-project-index = current-project-index;
            current-rule-check-board-index = current-board-2d-tab.board-index;
        } else if current-tab.type == TabType.board-3d {
            current-library-index = -1;
            current-project-index = current-board-3d-tab.project-index;
            current-rule-check-project-index = current-project-index;
            current-rule-check-board-index = current-board-3d-tab.board-index;
        } else if current-tab.type != TabType.home {
            current-library-index = -1;
            current-project-index = -1;
            current-rule-check-project-index = current-project-index;
            current-rule-check-board-index = -1;
        }
    }

    public function set-current-tab(section: int, tab: int) {
        current-section-index = section;
        sections[section].current-tab-index = tab;
        current-tab-changed();
    }

    public function set-current-library(index: int) {
        current-project-index = -1;
        current-rule-check-project-index = -1;
        current-rule-check-board-index = -1;
        current-library-index = index;
    }

    public function set-current-project(index: int) {
        current-library-index = -1;
        current-project-index = index;
        current-rule-check-project-index = index;
        current-rule-check-board-index = -1;
    }
}
