(function (global) {
    'use strict';
    if (global.tablesApp) {
        return;
    }
    global.tablesApp = {
        context: null,
        state: {
            rows: [],
            sort: [],
            filter: {},
            // Editor-mode state (Phase 1):
            //   selected: {row: rowId, col: field} | null — currently
            //     focused cell. row is the row's id (or rowsRel for the
            //     row file path); col is the column's `field`.
            //   editing: bool — whether a cell-editor input is mounted.
            //   drafts:  {rowId: {field: value, ...}, ...} — uncommitted
            //     edits, displayed in lieu of row.data while present.
            //     Cleared per-row when that row's PUT succeeds (Phase 3).
            //   range:   {anchor: {row, col}, focus: {row, col}} | null
            //     — multi-cell range selection (Phase 5).
            selected: null,
            editing: false,
            range: null,
            drafts: {}
        },
        modules: {}
    };
})(window);
