"""Run from either checkout: python3 seed-f2.py 2026-11-11T06:27:00Z.
Inject controlled provider input at the coordinator boundary; production snapshot,
publication, native widget rendering, and expiry code remain unchanged.
Start Metro after applying. Nothing is committed.
"""
import datetime
import pathlib
import sys

anchor = int(datetime.datetime.fromisoformat(sys.argv[1].replace('Z', '+00:00')).timestamp() * 1000)
root = pathlib.Path('apps/mobile/src/widgets')
fixture = '''const ANCHOR = %d;
const iso = (minutes: number) => new Date(ANCHOR + minutes * 60_000).toISOString();
export function widgetFixture22973<T>(): T {
  return new Map([["env", { entry: { target: { label: "Remote" } }, serverConfig: { providers: [{
    instanceId: "codex", driver: "codex", enabled: true, installed: true,
    version: null, status: "ready", auth: { status: "authenticated", email: "a@example.com" },
    checkedAt: iso(0), models: [], slashCommands: [], skills: [],
    usageLimits: { checkedAt: iso(0), windows: [
      { id: "primary", kind: "session", label: "5 hours", usedPercent: 0,
        resetsAt: iso(-15), windowDurationMins: 300 },
      { id: "secondary", kind: "weekly", label: "Weekly", usedPercent: 30,
        resetsAt: iso(10080), windowDurationMins: 10080 },
    ] },
  }] } }]]) as T;
}
''' % anchor
(root / 'widgetFixture22973.ts').write_text(fixture)
p = root / 'SubscriptionUsageCoordinator.tsx'
s = p.read_text()
s = s.replace('get(environmentPresentations.presentationsWithProvidersAtom),',
              'widgetFixture22973<Parameters<typeof buildSubscriptionUsageSnapshot>[0]>(),')
imp = 'import { widgetFixture22973 } from "./widgetFixture22973";'
if imp not in s:
    s = s.replace('import { createWidgetTheme } from "./widgetTheme";',
                  'import { createWidgetTheme } from "./widgetTheme";\n' + imp)
p.write_text(s)
print('F2 provider observation:', sys.argv[1])
