"""Read the API start coordinate without GetStart fallback or zero substitution."""
import argparse
import json
from resolve_api_connection import connect
from resolve_api_timecode import read_clock


def main():
    p = argparse.ArgumentParser(description=__doc__)
    p.add_argument("--absolute", type=int, help="Optional integer API coordinate for offset calculation")
    a = p.parse_args()
    state = read_clock(connect())
    result = {"state": state, "operation": "read_only"}
    if a.absolute is not None:
        result["absolute_timeline_frame"] = a.absolute
        result["offset_frames"] = a.absolute - state["start_frame"]
        result["inside_conservative_bounds"] = state["start_frame"] <= a.absolute < state["end_frame"]
    print(json.dumps(result, ensure_ascii=False, indent=2))


if __name__ == "__main__":
    main()
