o
    ki	                     @  sR   d dl mZ d dlmZ d dlmZ ddlmZmZ ddl	m
Z
 G dd dZd	S )
    )annotations)Path)Any   )	read_json
write_json)now_isoc                   @  s   e Zd ZdZd	ddZdS )
TimelineServicez?Generates a timeline summary from processed evidence artifacts.applicant_baser   returndict[str, Any]c                 C  sN  g }t |dD ]Q}t|i dpi }t|dpd }|dv r#q	|jd d d }| s1q	t|i dp8i }|d	}|d
}	|di dg }
|d d| |	|
d q	t	 |ddgd}|d }t
|d | g d}|r|D ]}|d|d  d|d
  d qwn|d |g d |d jd|d dd |S )Nzmeta/manifest.json)defaultstatus >   ignoredarchived	duplicate   	extractedzentities.jsondoc_idcategoryentitiesdetected_keywordszDocument processed: )datelabelr   source_keywordsz&No date normalization implemented yet.z7Manual validation required for chronology completeness.)generated_atevents	gap_flags	generatedztimeline.json)z# Applicant Timeliner   zJThis output is workflow support only. It does not determine visa approval.r   z	## Eventsz- r   z []z- No processed documents found.)r   z## Gap Flagsz(- No date normalization implemented yet.z9- Manual validation required for chronology completeness.ztimeline.md
zutf-8)encoding)sortedrglobr   strgetlowerparentsexistsappendr   r   extend
write_textjoin)selfr
   r   manifest_pathmanifestr   entities_pathpayloadr   r   keywordstimeline_jsongenerated_dirmd_linesevent r8   <apps/migration_evidence_builder/services/timeline_service.pybuild_timeline   sN   


	"
zTimelineService.build_timelineN)r
   r   r   r   )__name__
__module____qualname____doc__r:   r8   r8   r8   r9   r	   
   s    r	   N)
__future__r   pathlibr   typingr   utils.json_utilsr   r   utils.time_utilsr   r	   r8   r8   r8   r9   <module>   s    