{
  "schemaVersion": "1.0",
  "id": "subscription-status",
  "title": "Gói của nhà",
  "purpose": "View grant/expiry/buyer binding without child store identifiers.",
  "roles": [
    "adult"
  ],
  "group": "history-pro",
  "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 entitlement",
        "componentIds": [
          "screen-header",
          "subscription-status-0",
          "subscription-status-1",
          "subscription-status-2",
          "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": "A",
        "backTarget": "settings",
        "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": "subscription-status-0",
      "type": "DetailList",
      "props": {
        "items": [
          [
            "Nhà được liên kết",
            "Nhà Lá · mẫu"
          ],
          [
            "Quyền hiện tại",
            "Free trong bản thử"
          ],
          [
            "Giao dịch cửa hàng",
            "Chưa tích hợp"
          ],
          [
            "Ngày xác minh",
            "Chưa có"
          ]
        ]
      },
      "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": "Gói của nhà · DetailList",
        "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": "subscription-status-1",
      "type": "Notice",
      "props": {
        "text": "Khi Pro hết hạn, lịch đã tạo và duyệt trẻ vẫn dùng được. Chỉ dừng tạo tính năng Pro mớ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": "Gói của nhà · Notice",
        "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": "subscription-status-2",
      "type": "SettingsGroup",
      "props": {
        "items": [
          {
            "label": "Lợi ích Pro",
            "description": "Tự xếp lịch, mẫu lịch và thống kê",
            "target": "pro-benefits"
          },
          {
            "label": "Khôi phục giao dịch",
            "description": "Không mua lại",
            "target": "restore-purchases"
          }
        ]
      },
      "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": "Gói của nhà · SettingsGroup",
        "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": "screen-actions",
      "type": "ActionGroup",
      "props": {
        "actions": [
          {
            "id": "manage-subscription",
            "label": "Mở quản lý ở cửa hàng",
            "kind": "mutate",
            "target": null,
            "confirmationRequired": false
          },
          {
            "id": "link-settings",
            "label": "Cài đặt",
            "kind": "navigate",
            "target": "settings",
            "confirmationRequired": false
          },
          {
            "id": "link-pro-benefits",
            "label": "Thêm nhịp cho cả nhà",
            "kind": "navigate",
            "target": "pro-benefits",
            "confirmationRequired": false
          },
          {
            "id": "link-restore-purchases",
            "label": "Khôi phục gói đã mua",
            "kind": "navigate",
            "target": "restore-purchases",
            "confirmationRequired": false
          }
        ],
        "primaryCount": 0
      },
      "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": [],
  "states": [
    {
      "id": "free",
      "when": "No valid grant",
      "visibleUI": "No premium creation",
      "availableActions": [
        "manage-subscription",
        "link-settings",
        "link-pro-benefits",
        "link-restore-purchases"
      ],
      "mutationPolicy": "Actor, exact capability and current versions must still pass; this state never grants rights."
    },
    {
      "id": "active",
      "when": "Verified grant current household",
      "visibleUI": "Bindings valid_until/verified_at",
      "availableActions": [
        "manage-subscription",
        "link-settings",
        "link-pro-benefits",
        "link-restore-purchases"
      ],
      "mutationPolicy": "Actor, exact capability and current versions must still pass; this state never grants rights."
    },
    {
      "id": "expired",
      "when": "Grant expired",
      "visibleUI": "Existing schedule/manual work remain",
      "availableActions": [
        "link-settings",
        "link-pro-benefits",
        "link-restore-purchases"
      ],
      "mutationPolicy": "Actor, exact capability and current versions must still pass; this state never grants rights."
    },
    {
      "id": "buyer-only",
      "when": "Rebind intent",
      "visibleUI": "Only verified B can rebind",
      "availableActions": [
        "manage-subscription",
        "link-settings",
        "link-pro-benefits",
        "link-restore-purchases"
      ],
      "mutationPolicy": "Actor, exact capability and current versions must still pass; this state never grants rights."
    }
  ],
  "actions": [
    {
      "id": "manage-subscription",
      "label": "Mở quản lý ở cửa hàng",
      "kind": "mutate",
      "targetScreenId": null,
      "permission": "A buyer native adapter",
      "confirmationRequired": false,
      "contractRef": "Native subscription management adapter",
      "localBehavior": "Only validated draft/local domain where supported; remote adapters never report success.",
      "idempotency": "Stable actor/household/command key and canonical body; changed payload is a new confirmed intent."
    },
    {
      "id": "link-settings",
      "label": "Cài đặt",
      "kind": "navigate",
      "targetScreenId": "settings",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    },
    {
      "id": "link-pro-benefits",
      "label": "Thêm nhịp cho cả nhà",
      "kind": "navigate",
      "targetScreenId": "pro-benefits",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    },
    {
      "id": "link-restore-purchases",
      "label": "Khôi phục gói đã mua",
      "kind": "navigate",
      "targetScreenId": "restore-purchases",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    }
  ],
  "dataBindings": [
    {
      "source": "GET /v1/households/{hid}/entitlement",
      "shape": {
        "features": "{auto_schedule,advanced_stats,saved_templates:boolean}",
        "verified_at": "UTC|null",
        "valid_until": "UTC|null",
        "storeOffering": "localized price/period/trial/policy nullable; native not API grant"
      },
      "sample": {
        "features": {
          "auto_schedule": false,
          "advanced_stats": false,
          "saved_templates": false
        },
        "verified_at": null,
        "valid_until": null,
        "storeOffering": null
      },
      "sampleOnly": true,
      "actorConstraint": "exact actor allowlist",
      "envelope": "API refs use CommandEnvelope; local review context is not an API property."
    }
  ],
  "copy": {
    "heading": "Gói của nhà",
    "primary": null,
    "empty": null,
    "notices": [
      "Khi Pro hết hạn, lịch đã tạo và duyệt trẻ vẫn dùng được. Chỉ dừng tạo tính năng Pro mới."
    ],
    "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/subscription-status",
    "nativeRouteStatus": "proposed mapping, verify against implementing native navigator",
    "apiRefs": [
      "GET /v1/households/{hid}/entitlement"
    ],
    "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": "A",
    "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."
    }
  }
}
