"""Actual browser acceptance for the new class-K locked namespace only."""
from pathlib import Path
import sys

PROJECT=Path(__file__).resolve().parents[1];sys.path.insert(0,str(PROJECT));sys.path.insert(0,str(PROJECT/'scripts'))
from scripts import check_mask_model_requests_ui as checks
from pallet.mask_class_keypoint_review import ClassKeypointGallery
from pallet.pose_review_geometry import canonical


if __name__=='__main__':
    import argparse
    parser=argparse.ArgumentParser(description=__doc__);parser.add_argument('--output',type=Path,default=PROJECT/'outputs/pallet_mask_class_keypoint_ui_v2');args=parser.parse_args()
    checks.ROOT=PROJECT/'outputs/pallet_mask_model_requests_v3';checks.REVIEWS=PROJECT/'outputs/pallet_mask_model_reviews_v3';checks.OUT=args.output.resolve()
    if checks.OUT.parent!=PROJECT/'outputs' or not checks.OUT.name.startswith('pallet_mask_class_keypoint_ui_'):raise ValueError('Fresh UI evidence directory required')
    try:checks.check(ClassKeypointGallery,keypoint_mode=True)
    except Exception as error:
        if checks.OUT.exists() and not (checks.OUT/'failure.json').exists() and not (checks.OUT/'ui_acceptance.json').exists():
            with (checks.OUT/'failure.json').open('xb') as stream:stream.write(canonical(dict(state='failed_class_keypoint_UI_not_release',error=type(error).__name__+': '+str(error),
                production_annotation_writes=0,all_successful_saves_in_temporary_simulation_only=True))+b'\n')
        raise
