{
  "schemaVersion": "1.0",
  "id": "schedule-preferences",
  "title": "Nhịp của cả nhà",
  "purpose": "Weekday household effort budget, không budget từng persona/member.",
  "roles": [
    "adult"
  ],
  "group": "calendar-scheduling",
  "variantOf": null,
  "layout": {
    "canvas": {
      "width": 390,
      "height": 844
    },
    "responsive": {
      "minimumWidth": 360,
      "maximumWidth": 430,
      "scroll": "vertical",
      "safeAreaBottom": true,
      "fontScale": "native dynamic type; reflow without clipping",
      "keyboard": "composer sticky within resized viewport; dialog scrolls; no fixed keyboard overlay"
    },
    "regions": [
      {
        "id": "header",
        "order": 0,
        "type": "safe-area/header",
        "height": "intrinsic"
      },
      {
        "id": "content",
        "order": 1,
        "type": "purpose-specific preferences",
        "componentIds": [
          "screen-header",
          "schedule-preferences-0",
          "schedule-preferences-1",
          "schedule-preferences-2",
          "schedule-preferences-3",
          "schedule-preferences-4",
          "schedule-preferences-5",
          "schedule-preferences-6",
          "schedule-preferences-7",
          "schedule-preferences-8",
          "screen-actions"
        ]
      },
      {
        "id": "actions",
        "order": 2,
        "type": "one primary + secondary controls"
      },
      {
        "id": "navigation",
        "order": 3,
        "type": "none"
      }
    ]
  },
  "components": [
    {
      "id": "screen-header",
      "type": "Header",
      "props": {
        "homeLabel": "Nhà Lá",
        "scopeGate": "E (preferences); E+Pro (preview)",
        "backTarget": "calendar-list",
        "settingsTarget": "settings"
      },
      "tokens": {
        "foreground": "{semantic.light.fg}",
        "darkForeground": "{semantic.dark.fg}"
      },
      "accessibility": {
        "label": "Thanh đầu màn hình",
        "readingOrder": 0,
        "focusOrder": "back then settings"
      }
    },
    {
      "id": "schedule-preferences-0",
      "type": "Notice",
      "props": {
        "text": "Xếp lịch tự động cần quyền Pro đã xác minh. Bản thiết kế này không mở khóa gói.",
        "tone": ""
      },
      "tokens": {
        "background": "{semantic.light.surface}",
        "foreground": "{semantic.light.fg}",
        "darkBackground": "{semantic.dark.surface}",
        "darkForeground": "{semantic.dark.fg}",
        "bodySize": "{primitive.type.body}",
        "touchTarget": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Nhịp của cả nhà · Notice",
        "readingOrder": 1,
        "colorOnly": false,
        "fontScaling": true,
        "minimumTouchTarget": 48,
        "instructions": "Đọc theo thứ tự; công bố nhãn trạng thái và lỗi, không chỉ màu."
      }
    },
    {
      "id": "schedule-preferences-1",
      "type": "Field",
      "props": {
        "name": "budget_1",
        "label": "Thứ hai · công sức cả nhà",
        "type": "number",
        "value": 4,
        "required": true,
        "min": 0,
        "max": null,
        "options": null,
        "hint": null,
        "pattern": null
      },
      "tokens": {
        "background": "{semantic.light.surface}",
        "foreground": "{semantic.light.fg}",
        "darkBackground": "{semantic.dark.surface}",
        "darkForeground": "{semantic.dark.fg}",
        "bodySize": "{primitive.type.body}",
        "touchTarget": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Thứ hai · công sức cả nhà",
        "readingOrder": 2,
        "colorOnly": false,
        "fontScaling": true,
        "minimumTouchTarget": 48,
        "instructions": "Đọc theo thứ tự; công bố nhãn trạng thái và lỗi, không chỉ màu."
      }
    },
    {
      "id": "schedule-preferences-2",
      "type": "Field",
      "props": {
        "name": "budget_2",
        "label": "Thứ ba · công sức cả nhà",
        "type": "number",
        "value": 4,
        "required": true,
        "min": 0,
        "max": null,
        "options": null,
        "hint": null,
        "pattern": null
      },
      "tokens": {
        "background": "{semantic.light.surface}",
        "foreground": "{semantic.light.fg}",
        "darkBackground": "{semantic.dark.surface}",
        "darkForeground": "{semantic.dark.fg}",
        "bodySize": "{primitive.type.body}",
        "touchTarget": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Thứ ba · công sức cả nhà",
        "readingOrder": 3,
        "colorOnly": false,
        "fontScaling": true,
        "minimumTouchTarget": 48,
        "instructions": "Đọc theo thứ tự; công bố nhãn trạng thái và lỗi, không chỉ màu."
      }
    },
    {
      "id": "schedule-preferences-3",
      "type": "Field",
      "props": {
        "name": "budget_3",
        "label": "Thứ tư · công sức cả nhà",
        "type": "number",
        "value": 4,
        "required": true,
        "min": 0,
        "max": null,
        "options": null,
        "hint": null,
        "pattern": null
      },
      "tokens": {
        "background": "{semantic.light.surface}",
        "foreground": "{semantic.light.fg}",
        "darkBackground": "{semantic.dark.surface}",
        "darkForeground": "{semantic.dark.fg}",
        "bodySize": "{primitive.type.body}",
        "touchTarget": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Thứ tư · công sức cả nhà",
        "readingOrder": 4,
        "colorOnly": false,
        "fontScaling": true,
        "minimumTouchTarget": 48,
        "instructions": "Đọc theo thứ tự; công bố nhãn trạng thái và lỗi, không chỉ màu."
      }
    },
    {
      "id": "schedule-preferences-4",
      "type": "Field",
      "props": {
        "name": "budget_4",
        "label": "Thứ năm · công sức cả nhà",
        "type": "number",
        "value": 4,
        "required": true,
        "min": 0,
        "max": null,
        "options": null,
        "hint": null,
        "pattern": null
      },
      "tokens": {
        "background": "{semantic.light.surface}",
        "foreground": "{semantic.light.fg}",
        "darkBackground": "{semantic.dark.surface}",
        "darkForeground": "{semantic.dark.fg}",
        "bodySize": "{primitive.type.body}",
        "touchTarget": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Thứ năm · công sức cả nhà",
        "readingOrder": 5,
        "colorOnly": false,
        "fontScaling": true,
        "minimumTouchTarget": 48,
        "instructions": "Đọc theo thứ tự; công bố nhãn trạng thái và lỗi, không chỉ màu."
      }
    },
    {
      "id": "schedule-preferences-5",
      "type": "Field",
      "props": {
        "name": "budget_5",
        "label": "Thứ sáu · công sức cả nhà",
        "type": "number",
        "value": 4,
        "required": true,
        "min": 0,
        "max": null,
        "options": null,
        "hint": null,
        "pattern": null
      },
      "tokens": {
        "background": "{semantic.light.surface}",
        "foreground": "{semantic.light.fg}",
        "darkBackground": "{semantic.dark.surface}",
        "darkForeground": "{semantic.dark.fg}",
        "bodySize": "{primitive.type.body}",
        "touchTarget": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Thứ sáu · công sức cả nhà",
        "readingOrder": 6,
        "colorOnly": false,
        "fontScaling": true,
        "minimumTouchTarget": 48,
        "instructions": "Đọc theo thứ tự; công bố nhãn trạng thái và lỗi, không chỉ màu."
      }
    },
    {
      "id": "schedule-preferences-6",
      "type": "Field",
      "props": {
        "name": "budget_6",
        "label": "Thứ bảy · công sức cả nhà",
        "type": "number",
        "value": 6,
        "required": true,
        "min": 0,
        "max": null,
        "options": null,
        "hint": null,
        "pattern": null
      },
      "tokens": {
        "background": "{semantic.light.surface}",
        "foreground": "{semantic.light.fg}",
        "darkBackground": "{semantic.dark.surface}",
        "darkForeground": "{semantic.dark.fg}",
        "bodySize": "{primitive.type.body}",
        "touchTarget": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Thứ bảy · công sức cả nhà",
        "readingOrder": 7,
        "colorOnly": false,
        "fontScaling": true,
        "minimumTouchTarget": 48,
        "instructions": "Đọc theo thứ tự; công bố nhãn trạng thái và lỗi, không chỉ màu."
      }
    },
    {
      "id": "schedule-preferences-7",
      "type": "Field",
      "props": {
        "name": "budget_7",
        "label": "Chủ nhật · công sức cả nhà",
        "type": "number",
        "value": 6,
        "required": true,
        "min": 0,
        "max": null,
        "options": null,
        "hint": null,
        "pattern": null
      },
      "tokens": {
        "background": "{semantic.light.surface}",
        "foreground": "{semantic.light.fg}",
        "darkBackground": "{semantic.dark.surface}",
        "darkForeground": "{semantic.dark.fg}",
        "bodySize": "{primitive.type.body}",
        "touchTarget": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Chủ nhật · công sức cả nhà",
        "readingOrder": 8,
        "colorOnly": false,
        "fontScaling": true,
        "minimumTouchTarget": 48,
        "instructions": "Đọc theo thứ tự; công bố nhãn trạng thái và lỗi, không chỉ màu."
      }
    },
    {
      "id": "schedule-preferences-8",
      "type": "Notice",
      "props": {
        "text": "Việc cố định và chờ duyệt giữ nguyên. Ngân sách không cấm bạn làm thêm.",
        "tone": ""
      },
      "tokens": {
        "background": "{semantic.light.surface}",
        "foreground": "{semantic.light.fg}",
        "darkBackground": "{semantic.dark.surface}",
        "darkForeground": "{semantic.dark.fg}",
        "bodySize": "{primitive.type.body}",
        "touchTarget": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Nhịp của cả nhà · Notice",
        "readingOrder": 9,
        "colorOnly": false,
        "fontScaling": true,
        "minimumTouchTarget": 48,
        "instructions": "Đọc theo thứ tự; công bố nhãn trạng thái và lỗi, không chỉ màu."
      }
    },
    {
      "id": "screen-actions",
      "type": "ActionGroup",
      "props": {
        "actions": [
          {
            "id": "navigate-0",
            "label": "Xem đề xuất mẫu",
            "kind": "submit",
            "target": "schedule-preview",
            "confirmationRequired": false
          },
          {
            "id": "navigate-1",
            "label": "Xem quyền Pro",
            "kind": "navigate",
            "target": "pro-benefits",
            "confirmationRequired": false
          },
          {
            "id": "link-calendar-list",
            "label": "Lịch chung",
            "kind": "navigate",
            "target": "calendar-list",
            "confirmationRequired": false
          },
          {
            "id": "link-settings",
            "label": "Cài đặt",
            "kind": "navigate",
            "target": "settings",
            "confirmationRequired": false
          }
        ],
        "primaryCount": 1
      },
      "tokens": {
        "lightBackground": "{component.light.button.background}",
        "lightForeground": "{component.light.button.foreground}",
        "darkBackground": "{component.dark.button.background}",
        "darkForeground": "{component.dark.button.foreground}",
        "height": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Hành động của màn hình",
        "keyboard": true,
        "focusVisible": true,
        "disabledOnlyLowContrast": true
      }
    }
  ],
  "fields": [
    {
      "id": "budget_1",
      "label": "Thứ hai · công sức cả nhà",
      "control": "number",
      "default": 4,
      "options": null,
      "validation": {
        "required": true,
        "trim": false,
        "type": "number",
        "min": 0,
        "max": null,
        "pattern": null,
        "serverAuthoritative": true,
        "errorMessage": "Kiểm tra thứ hai · công sức cả nhà."
      },
      "binding": "budget_1",
      "keyboard": "numeric",
      "accessibleErrorAssociation": "form error summary via role alert; native bind field-specific error ID"
    },
    {
      "id": "budget_2",
      "label": "Thứ ba · công sức cả nhà",
      "control": "number",
      "default": 4,
      "options": null,
      "validation": {
        "required": true,
        "trim": false,
        "type": "number",
        "min": 0,
        "max": null,
        "pattern": null,
        "serverAuthoritative": true,
        "errorMessage": "Kiểm tra thứ ba · công sức cả nhà."
      },
      "binding": "budget_2",
      "keyboard": "numeric",
      "accessibleErrorAssociation": "form error summary via role alert; native bind field-specific error ID"
    },
    {
      "id": "budget_3",
      "label": "Thứ tư · công sức cả nhà",
      "control": "number",
      "default": 4,
      "options": null,
      "validation": {
        "required": true,
        "trim": false,
        "type": "number",
        "min": 0,
        "max": null,
        "pattern": null,
        "serverAuthoritative": true,
        "errorMessage": "Kiểm tra thứ tư · công sức cả nhà."
      },
      "binding": "budget_3",
      "keyboard": "numeric",
      "accessibleErrorAssociation": "form error summary via role alert; native bind field-specific error ID"
    },
    {
      "id": "budget_4",
      "label": "Thứ năm · công sức cả nhà",
      "control": "number",
      "default": 4,
      "options": null,
      "validation": {
        "required": true,
        "trim": false,
        "type": "number",
        "min": 0,
        "max": null,
        "pattern": null,
        "serverAuthoritative": true,
        "errorMessage": "Kiểm tra thứ năm · công sức cả nhà."
      },
      "binding": "budget_4",
      "keyboard": "numeric",
      "accessibleErrorAssociation": "form error summary via role alert; native bind field-specific error ID"
    },
    {
      "id": "budget_5",
      "label": "Thứ sáu · công sức cả nhà",
      "control": "number",
      "default": 4,
      "options": null,
      "validation": {
        "required": true,
        "trim": false,
        "type": "number",
        "min": 0,
        "max": null,
        "pattern": null,
        "serverAuthoritative": true,
        "errorMessage": "Kiểm tra thứ sáu · công sức cả nhà."
      },
      "binding": "budget_5",
      "keyboard": "numeric",
      "accessibleErrorAssociation": "form error summary via role alert; native bind field-specific error ID"
    },
    {
      "id": "budget_6",
      "label": "Thứ bảy · công sức cả nhà",
      "control": "number",
      "default": 6,
      "options": null,
      "validation": {
        "required": true,
        "trim": false,
        "type": "number",
        "min": 0,
        "max": null,
        "pattern": null,
        "serverAuthoritative": true,
        "errorMessage": "Kiểm tra thứ bảy · công sức cả nhà."
      },
      "binding": "budget_6",
      "keyboard": "numeric",
      "accessibleErrorAssociation": "form error summary via role alert; native bind field-specific error ID"
    },
    {
      "id": "budget_7",
      "label": "Chủ nhật · công sức cả nhà",
      "control": "number",
      "default": 6,
      "options": null,
      "validation": {
        "required": true,
        "trim": false,
        "type": "number",
        "min": 0,
        "max": null,
        "pattern": null,
        "serverAuthoritative": true,
        "errorMessage": "Kiểm tra chủ nhật · công sức cả nhà."
      },
      "binding": "budget_7",
      "keyboard": "numeric",
      "accessibleErrorAssociation": "form error summary via role alert; native bind field-specific error ID"
    }
  ],
  "states": [
    {
      "id": "preferences",
      "when": "Weekday budgets version hiện tại",
      "visibleUI": "7 budget integer của hộ",
      "availableActions": [
        "navigate-0",
        "navigate-1",
        "link-calendar-list",
        "link-settings"
      ],
      "mutationPolicy": "Actor, exact capability and current versions must still pass; this state never grants rights."
    },
    {
      "id": "no-pro",
      "when": "FEATURE_REQUIRED",
      "visibleUI": "Không gọi preview; giữ lịch thủ công",
      "availableActions": [
        "navigate-1",
        "link-calendar-list",
        "link-settings"
      ],
      "mutationPolicy": "Actor, exact capability and current versions must still pass; this state never grants rights."
    },
    {
      "id": "offline",
      "when": "Không kết nối",
      "visibleUI": "Không apply prefs online",
      "availableActions": [
        "navigate-1",
        "link-calendar-list",
        "link-settings"
      ],
      "mutationPolicy": "Actor, exact capability and current versions must still pass; this state never grants rights."
    }
  ],
  "actions": [
    {
      "id": "navigate-0",
      "label": "Xem đề xuất mẫu",
      "kind": "submit",
      "targetScreenId": "schedule-preview",
      "permission": "E (preferences); E+Pro (preview)",
      "confirmationRequired": false,
      "contractRef": "local draft/navigation",
      "localBehavior": "Only validated draft/local domain where supported; remote adapters never report success.",
      "idempotency": null
    },
    {
      "id": "navigate-1",
      "label": "Xem quyền Pro",
      "kind": "navigate",
      "targetScreenId": "pro-benefits",
      "permission": "E (preferences); E+Pro (preview)",
      "confirmationRequired": false,
      "contractRef": "local draft/navigation",
      "localBehavior": "Only validated draft/local domain where supported; remote adapters never report success.",
      "idempotency": null
    },
    {
      "id": "link-calendar-list",
      "label": "Lịch chung",
      "kind": "navigate",
      "targetScreenId": "calendar-list",
      "permission": "E (preferences); E+Pro (preview)",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    },
    {
      "id": "link-settings",
      "label": "Cài đặt",
      "kind": "navigate",
      "targetScreenId": "settings",
      "permission": "E (preferences); E+Pro (preview)",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    }
  ],
  "dataBindings": [
    {
      "source": "PATCH /v1/households/{hid}/schedule/preferences",
      "shape": {
        "version": "integer",
        "weekday_budgets": "{weekday:1..7,effort_budget:integer}[] (SchedulePreferencesDto, schedule screens only)",
        "notifications": "NotificationPreferencesDto {locale:vi|en, enabled, quiet_start_local HH:mm|null, quiet_end_local HH:mm|null, version}",
        "theme": "device-local light|dark|system; not an API field"
      },
      "sample": {
        "version": 1,
        "weekday_budgets": [
          {
            "weekday": 1,
            "effort_budget": 4
          },
          {
            "weekday": 2,
            "effort_budget": 4
          },
          {
            "weekday": 3,
            "effort_budget": 4
          },
          {
            "weekday": 4,
            "effort_budget": 4
          },
          {
            "weekday": 5,
            "effort_budget": 4
          },
          {
            "weekday": 6,
            "effort_budget": 6
          },
          {
            "weekday": 7,
            "effort_budget": 6
          }
        ],
        "notifications": {
          "locale": "vi",
          "enabled": true,
          "quiet_start_local": "21:00",
          "quiet_end_local": "07:00",
          "version": 1
        },
        "theme": "light"
      },
      "sampleOnly": true,
      "actorConstraint": "exact actor allowlist",
      "envelope": "API refs use CommandEnvelope; local review context is not an API property."
    }
  ],
  "copy": {
    "heading": "Nhịp của cả nhà",
    "primary": "Xem đề xuất mẫu",
    "empty": null,
    "notices": [
      "Xếp lịch tự động cần quyền Pro đã xác minh. Bản thiết kế này không mở khóa gói.",
      "Việc cố định và chờ duyệt giữ nguyên. Ngân sách không cấm bạn làm thêm."
    ],
    "locale": "vi",
    "demoLabel": "Bản thiết kế · dữ liệu mẫu · không kết nối dịch vụ"
  },
  "implementation": {
    "nativeRoute": "/design/schedule-preferences",
    "nativeRouteStatus": "proposed mapping, verify against implementing native navigator",
    "apiRefs": [
      "PATCH /v1/households/{hid}/schedule/preferences",
      "POST /v1/households/{hid}/schedule/preview"
    ],
    "newContractRefs": [],
    "notes": [
      "Tất cả ví dụ là dữ liệu thiết kế, không bằng chứng native/API/store đã chạy.",
      "Native route dưới đây là đề xuất mapping cho agent, không tuyên bố route source đã tồn tại.",
      "Mọi mutation dùng envelope {data,version,household_revision,replayed}, stable Idempotency-Key và expected_version khi sửa."
    ],
    "integrationStatus": "design complete; local static/draft interactions; native/API adapters pending",
    "sourceAuthority": [
      "docs/product-brief.md",
      "plans/261013-1409-sweepy-vietnam-mobile/mobile-flows.md",
      "plans/261013-1409-sweepy-vietnam-mobile/api-contracts.md",
      "packages/domain/src/contracts/phase2.ts",
      "packages/domain/src/index.ts",
      "packages/domain/src/contracts/phase3.ts",
      "packages/domain/src/contracts/billing.ts",
      "apps/mobile/src/lib/api.ts"
    ],
    "capability": "E (preferences); E+Pro (preview)",
    "errors": {
      "401": "Stop queue; adult login or child re-pair without parent account.",
      "403": "Do not retry lost capability. FEATURE_REQUIRED never grants Pro.",
      "409": "Fetch canonical scoped state; review/reconfirm new intent, do not rewrite old replay payload.",
      "422": "Field error with retained draft.",
      "429": "Respect Retry-After.",
      "503": "Backoff only retryable commands with original key."
    }
  }
}
