(function (global) {
  "use strict";

  const nav = {
    entries: [
      { key: "market", title: "行情数据", subtitle: "情绪 · 梯队 · 题材 · 龙虎榜", icon: "bar-chart-3" },
      { key: "tools", title: "智能工具", subtitle: "智能选股 · 策略跟踪 · 问师", icon: "wand-2" },
      { key: "review", title: "我的复盘", subtitle: "自选 · 交易 · 复盘 · 笔记 · 提醒", icon: "notebook-pen" },
      { key: "assistant", title: "复盘助手", subtitle: "AI 对话复盘", icon: "message-square" },
      { key: "system", title: "系统管理", subtitle: "账号 · 密码 · 会员 · 设置", icon: "settings" }
    ],

    hubs: {
      market: {
        title: "行情数据",
        items: [
          { key: "market/sentiment", label: "情绪周期", icon: "activity" },
          { key: "market/limit-up", label: "涨停池", icon: "trending-up" },
          { key: "market/broken", label: "炸板池", icon: "zap" },
          { key: "market/limit-down", label: "跌停池", icon: "trending-down" },
          { key: "market/yesterday", label: "昨日涨停", icon: "history" },
          { key: "market/performance", label: "涨停表现", icon: "chart-line" },
          { key: "market/ladder", label: "市场天梯", icon: "layers" },
          { key: "market/rotation", label: "主题轮动", icon: "refresh-cw" },
          { key: "market/auction", label: "竞价", icon: "gavel" },
          { key: "market/themes", label: "题材库", icon: "book-open" },
          { key: "market/popularity", label: "人气榜", icon: "flame" },
          { key: "market/dragon", label: "龙虎榜", icon: "crown" }
        ]
      },
      tools: {
        title: "智能工具",
        items: [
          { key: "tools/screener", label: "智能选股", icon: "filter" },
          { key: "tools/tracking", label: "策略跟踪", icon: "target" },
          { key: "tools/mentor", label: "问师", icon: "bot" }
        ]
      },
      review: {
        title: "我的复盘",
        items: [
          { key: "review/watchlist", label: "自选股", icon: "star" },
          { key: "review/trades", label: "交易日志", icon: "scroll-text" },
          { key: "review/daily", label: "每日复盘", icon: "calendar-check" },
          { key: "review/notes", label: "个股笔记", icon: "sticky-note" },
          { key: "review/alerts", label: "提醒中心", icon: "bell" }
        ]
      },
      system: {
        title: "系统管理",
        items: [
          { key: "system/profile", label: "账号资料", icon: "user" },
          { key: "system/password", label: "修改密码", icon: "lock" },
          { key: "system/membership", label: "会员状态", icon: "gem" },
          { key: "system/admin", label: "系统设置", icon: "sliders-horizontal", adminOnly: true },
          { key: "system/members", label: "会员管理", icon: "users", adminOnly: true }
        ]
      }
    },

    tableDefaults: {
      frozenColumns: ["name", "code"],
      primaryColumns: [],
      scrollColumns: []
    },

    tableColumns: {
      "market/limit-up": {
        summary: "limit",
        frozenColumns: [
          { key: "stock", label: "股票", type: "stock", width: 96 }
        ],
        primaryColumns: [
          { key: "streak", label: "连板", type: "streak" },
          { key: "change", label: "涨幅%", type: "change" },
          { key: "price", label: "价格", type: "price" }
        ],
        scrollColumns: [
          { key: "sector", label: "所属板块", type: "text" },
          { key: "first_time", label: "首封", type: "text" },
          { key: "last_time", label: "最后封板", type: "text" },
          { key: "open_times", label: "开板", type: "int" },
          { key: "turnover_rate", label: "换手%", type: "rate" },
          { key: "amount_billion", label: "成交额亿", type: "money" },
          { key: "seal_amount_million", label: "封单额万", type: "int", hideZero: true },
          { key: "reason", label: "涨停原因", type: "text", wide: true }
        ]
      },

      "market/broken": {
        summary: "broken",
        frozenColumns: [
          { key: "stock", label: "股票", type: "stock", width: 96 }
        ],
        primaryColumns: [
          { key: "change", label: "现价涨幅%", type: "change" },
          { key: "limitGap", label: "距涨停%", type: "gap" },
          { key: "price", label: "价格", type: "price" }
        ],
        scrollColumns: [
          { key: "sector", label: "所属板块", type: "text" },
          { key: "first_time", label: "首次触板", type: "text" },
          { key: "open_times", label: "开板", type: "int" },
          { key: "turnover_rate", label: "换手%", type: "rate" },
          { key: "amount_billion", label: "成交额亿", type: "money" },
          { key: "reason", label: "炸板原因", type: "text", wide: true }
        ]
      },

      "market/limit-down": {
        summary: "down",
        frozenColumns: [
          { key: "stock", label: "股票", type: "stock", width: 96 }
        ],
        primaryColumns: [
          { key: "change", label: "跌幅%", type: "change" },
          { key: "price", label: "价格", type: "price" }
        ],
        scrollColumns: [
          { key: "sector", label: "所属板块", type: "text" },
          { key: "turnover_rate", label: "换手%", type: "rate" },
          { key: "amount_billion", label: "成交额亿", type: "money" },
          { key: "streak", label: "连续跌停", type: "int", hideZero: true },
          { key: "reason", label: "风险线索", type: "text", wide: true }
        ]
      },

      "market/yesterday": {
        summary: "yesterday",
        frozenColumns: [
          { key: "stock", label: "股票", type: "stock", width: 96 }
        ],
        primaryColumns: [
          { key: "current_change", label: "今日涨幅%", type: "change" },
          { key: "outcome", label: "今日结果", type: "outcome" },
          { key: "prior_streak", label: "昨日高度", type: "int" }
        ],
        scrollColumns: [
          { key: "current_streak", label: "当前高度", type: "height" },
          { key: "sector", label: "所属板块", type: "text" },
          { key: "reason", label: "涨停逻辑", type: "text", wide: true }
        ]
      },

      "market/performance": {
        summary: "performance",
        frozenColumns: [
          { key: "label", label: "梯队", type: "text", width: 96 }
        ],
        primaryColumns: [
          { key: "advance_rate", label: "晋级率%", type: "advance" },
          { key: "advanced", label: "晋级", type: "int" },
          { key: "positive_rate", label: "收红率%", type: "rate" }
        ],
        scrollColumns: [
          { key: "count", label: "样本", type: "int" },
          { key: "average_change", label: "平均涨幅%", type: "change" }
        ]
      },

      "market/popularity": {
        summary: "popularity",
        sources: ["combined", "ths", "dc"],
        columns: {
          combined: {
            frozenColumns: [
              { key: "rank", label: "#", type: "rank", width: 40 },
              { key: "stock", label: "股票", type: "stock", width: 96 }
            ],
            primaryColumns: [
              { key: "price", label: "最新价", type: "price" },
              { key: "change", label: "涨跌幅%", type: "change" }
            ],
            scrollColumns: [
              { key: "ths_rank", label: "同花顺", type: "int", hideZero: true },
              { key: "dc_rank", label: "东方财富", type: "int", hideZero: true },
              { key: "rank_change", label: "排名变化", type: "move" },
              { key: "concepts", label: "热门概念", type: "concepts" }
            ]
          },
          ths: {
            frozenColumns: [
              { key: "rank", label: "#", type: "rank", width: 40 },
              { key: "stock", label: "股票", type: "stock", width: 96 }
            ],
            primaryColumns: [
              { key: "price", label: "最新价", type: "price" },
              { key: "change", label: "涨跌幅%", type: "change" }
            ],
            scrollColumns: [
              { key: "dc_rank", label: "东方财富", type: "int", hideZero: true },
              { key: "rank_change", label: "排名变化", type: "move" },
              { key: "concepts", label: "热门概念", type: "concepts" },
              { key: "dual_source", label: "榜单状态", type: "dual" }
            ]
          },
          dc: {
            frozenColumns: [
              { key: "rank", label: "#", type: "rank", width: 40 },
              { key: "stock", label: "股票", type: "stock", width: 96 }
            ],
            primaryColumns: [
              { key: "price", label: "最新价", type: "price" },
              { key: "change", label: "涨跌幅%", type: "change" }
            ],
            scrollColumns: [
              { key: "ths_rank", label: "同花顺", type: "int", hideZero: true },
              { key: "rank_change", label: "排名变化", type: "move" },
              { key: "concepts", label: "热门概念", type: "concepts" },
              { key: "dual_source", label: "榜单状态", type: "dual" }
            ]
          }
        }
      },

      "market/sentiment/history": {
        frozenColumns: [
          { key: "trade_date", label: "日期", type: "text", width: 88 }
        ],
        primaryColumns: [
          { key: "score", label: "温度", type: "int" },
          { key: "phase", label: "阶段", type: "text" },
          { key: "direction", label: "方向", type: "text" }
        ],
        scrollColumns: [
          { key: "limit_up_count", label: "涨停", type: "int" },
          { key: "first_board_count", label: "首板", type: "int" },
          { key: "second_board_count", label: "二板", type: "int" },
          { key: "three_plus_count", label: "三板+", type: "int" },
          { key: "max_height", label: "高度", type: "int" },
          { key: "broken_count", label: "炸板", type: "int" },
          { key: "limit_down_count", label: "跌停", type: "int" },
          { key: "seal_rate", label: "封板率%", type: "rate" },
          { key: "previous_limit_count", label: "昨涨停", type: "int" },
          { key: "previous_positive_rate", label: "昨红率%", type: "rate" }
        ]
      },

      "market/auction": {
        frozenColumns: [
          { key: "stock", label: "股票", type: "stock", width: 96 }
        ],
        primaryColumns: [
          { key: "attention_score", label: "关注分", type: "score" },
          { key: "change", label: "竞价涨幅%", type: "change" },
          { key: "expectation", label: "预期", type: "expectation" }
        ],
        scrollColumns: [
          { key: "sector", label: "方向", type: "text" },
          { key: "amount_million", label: "竞价额百万", type: "money" },
          { key: "volume_ratio", label: "量比", type: "rate" }
        ]
      },

      "market/rotation/members": {
        frozenColumns: [
          { key: "stock", label: "股票", type: "stock", width: 96 }
        ],
        primaryColumns: [
          { key: "change", label: "涨跌幅%", type: "change" },
          { key: "close", label: "收盘", type: "price" }
        ],
        scrollColumns: [
          { key: "open", label: "开盘", type: "price" },
          { key: "amount_billion", label: "成交额亿", type: "money" }
        ]
      },

      "market/themes/members": {
        frozenColumns: [
          { key: "stock", label: "股票", type: "stock", width: 96 }
        ],
        primaryColumns: [
          { key: "change", label: "涨跌幅%", type: "change" },
          { key: "price", label: "现价", type: "price" }
        ],
        scrollColumns: [
          { key: "amount_billion", label: "成交额亿", type: "money" }
        ]
      },

      "market/dragon/operations": {
        frozenColumns: [
          { key: "stock", label: "股票", type: "stock", width: 96 }
        ],
        primaryColumns: [
          { key: "direction", label: "方向", type: "direction" },
          { key: "change", label: "涨幅%", type: "change" }
        ],
        scrollColumns: [
          { key: "buy_million", label: "买入百万", type: "money" },
          { key: "sell_million", label: "卖出百万", type: "money" },
          { key: "net_buy_million", label: "净额百万", type: "change" },
          { key: "seat_name", label: "席位", type: "text", wide: true },
          { key: "reason", label: "上榜原因", type: "text", wide: true }
        ]
      }
    }
  };

  global.MobileNav = nav;
})(window);
