File size: 72,346 Bytes
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
8dd46ff
 
11794cc
d3f8066
83e76e6
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
ae518b8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11794cc
ae518b8
 
11794cc
ae518b8
11794cc
 
 
d3f8066
11794cc
d3f8066
11794cc
d3f8066
 
 
 
 
 
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
2cac7a0
11794cc
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
2cac7a0
 
 
 
d3f8066
2cac7a0
 
3fb6171
 
 
 
11794cc
 
2cac7a0
11794cc
2cac7a0
11794cc
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
 
d3f8066
 
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
d3f8066
8dd46ff
11794cc
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
8dd46ff
 
11794cc
 
d3f8066
 
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
59c1a86
11794cc
d3f8066
11794cc
 
d3f8066
 
59c1a86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
2cac7a0
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
2cac7a0
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
59c1a86
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
 
d3f8066
 
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
59c1a86
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
 
d3f8066
 
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
 
d3f8066
 
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
 
d3f8066
 
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
 
d3f8066
 
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
59c1a86
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
59c1a86
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
 
 
d3f8066
 
 
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
 
d3f8066
 
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
 
d3f8066
 
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
 
d3f8066
 
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
 
 
d3f8066
 
 
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
59c1a86
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
59c1a86
0411044
7953467
 
d9dfa71
7953467
0411044
d9dfa71
 
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
7953467
d3f8066
7953467
 
11794cc
 
 
d3f8066
d9dfa71
 
 
 
11794cc
 
 
7953467
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
 
 
d3f8066
 
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
83e76e6
11794cc
d3f8066
 
11794cc
d3f8066
11794cc
d3f8066
11794cc
d3f8066
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
# Standard library imports

import asyncio

import json

import logging

import os

import time

import uuid

from io import StringIO

from typing import List, Optional

import ast

import markdown

from bs4 import BeautifulSoup

import pandas as pd

from datetime import datetime, UTC

# Third-party imports

import uvicorn

from dotenv import load_dotenv

from fastapi import (

    Depends, 

    FastAPI, 

    File, 

    Form, 

    HTTPException, 

    Request, 

    UploadFile

)

from fastapi.middleware.cors import CORSMiddleware

from fastapi.responses import JSONResponse, StreamingResponse

from fastapi.security import APIKeyHeader

from llama_index.core import Document, VectorStoreIndex

from pydantic import BaseModel



# Local application imports

from scripts.format_response import format_response_to_markdown

from src.agents.agents import *

from src.agents.retrievers.retrievers import *

from src.managers.ai_manager import AI_Manager

from src.managers.session_manager import SessionManager

from src.managers.app_manager import AppState

from src.routes.analytics_routes import router as analytics_router

from src.routes.blog_routes import router as blog_router

from src.routes.chat_routes import router as chat_router

from src.routes.code_routes import router as code_router

from src.routes.feedback_routes import router as feedback_router

from src.routes.session_routes import router as session_router, get_session_id_dependency

from src.routes.deep_analysis_routes import router as deep_analysis_router

from src.routes.templates_routes import router as templates_router

from src.schemas.query_schema import QueryRequest

from src.utils.logger import Logger



# Import deep analysis components directly

# from src.agents.try_deep_agents import deep_analysis_module

from src.agents.deep_agents import deep_analysis_module

from src.utils.generate_report import generate_html_report



from src.utils.model_registry import MODEL_OBJECTS



logger = Logger("app", see_time=True, console_log=True)

load_dotenv()



# Request models

class DeepAnalysisRequest(BaseModel):

    goal: str

    

class DeepAnalysisResponse(BaseModel):

    goal: str

    deep_questions: str

    deep_plan: str

    summaries: List[str]

    code: str

    plotly_figs: List

    synthesis: List[str]

    final_conclusion: str

    html_report: Optional[str] = None



styling_instructions =  [
    {
        "category": "line_charts",
        "description": "Used to visualize trends and changes over time, often with multiple series.",
        "styling": {
            "template": "plotly_white",
            "axes_line_width": 0.2,
            "grid_width": 1,
            "title": {
                "bold_html": True,
                "include": True
            },
            "colors": "use multiple colors if more than one line",
            "annotations": ["min", "max"],
            "number_format": {
                "apply_k_m": True,
                "thresholds": {"K": 1000, "M": 100000},
                "percentage_decimals": 2,
                "percentage_sign": True
            },
            "default_size": {"height": 1200, "width": 1000}
        }
    },
    {
        "category": "bar_charts",
        "description": "Useful for comparing discrete categories or groups with bars representing values.",
        "styling": {
            "template": "plotly_white",
            "axes_line_width": 0.2,
            "grid_width": 1,
            "title": {"bold_html": True, "include": True},
            "annotations": ["bar values"],
            "number_format": {
                "apply_k_m": True,
                "thresholds": {"K": 1000, "M": 100000},
                "percentage_decimals": 2,
                "percentage_sign": True
            },
            "default_size": {"height": 1200, "width": 1000}
        }
    },
    {
        "category": "histograms",
        "description": "Display the distribution of a data set, useful for returns or frequency distributions.",
        "styling": {
            "template": "plotly_white",
            "bin_size": 50,
            "axes_line_width": 0.2,
            "grid_width": 1,
            "title": {"bold_html": True, "include": True},
            "annotations": ["x values"],
            "number_format": {
                "apply_k_m": True,
                "thresholds": {"K": 1000, "M": 100000},
                "percentage_decimals": 2,
                "percentage_sign": True
            },
            "default_size": {"height": 1200, "width": 1000}
        }
    },
    {
        "category": "pie_charts",
        "description": "Show composition or parts of a whole with slices representing categories.",
        "styling": {
            "template": "plotly_white",
            "top_categories_to_show": 10,
            "bundle_rest_as": "Others",
            "axes_line_width": 0.2,
            "grid_width": 1,
            "title": {"bold_html": True, "include": True},
            "annotations": ["x values"],
            "number_format": {
                "apply_k_m": True,
                "thresholds": {"K": 1000, "M": 100000},
                "percentage_decimals": 2,
                "percentage_sign": True
            },
            "default_size": {"height": 1200, "width": 1000}
        }
    },
    {
        "category": "tabular_and_generic_charts",
        "description": "Applies to charts where number formatting needs flexibility, including mixed or raw data.",
        "styling": {
            "template": "plotly_white",
            "axes_line_width": 0.2,
            "grid_width": 1,
            "title": {"bold_html": True, "include": True},
            "annotations": ["x values"],
            "number_format": {
                "apply_k_m": True,
                "thresholds": {"K": 1000, "M": 100000},
                "exclude_if_commas_present": True,
                "exclude_if_not_numeric": True,
                "percentage_decimals": 2,
                "percentage_sign": True
            },
            "default_size": {"height": 1200, "width": 1000}
        }
    },
    {
        "category": "heat_maps",
        "description": "Show data density or intensity using color scales on a matrix or grid.",
        "styling": {
            "template": "plotly_white",
            "axes_styles": {
                "line_color": "black",
                "line_width": 0.2,
                "grid_width": 1,
                "format_numbers_as_k_m": True,
                "exclude_non_numeric_formatting": True
            },
            "title": {"bold_html": True, "include": True},
            "default_size": {"height": 1200, "width": 1000}
        }
    },
    {
        "category": "histogram_distribution",
        "description": "Specialized histogram for return distributions with opacity control.",
        "styling": {
            "template": "plotly_white",
            "opacity": 0.75,
            "axes_styles": {
                "grid_width": 1,
                "format_numbers_as_k_m": True,
                "exclude_non_numeric_formatting": True
            },
            "title": {"bold_html": True, "include": True},
            "default_size": {"height": 1200, "width": 1000}
        }
    }
]

# Convert to list of JSON strings
styling_instructions = [str(chart_dict) for chart_dict in styling_instructions]

# Output (just show first 2 for readability)




# Add near the top of the file, after imports

DEFAULT_MODEL_CONFIG = {

    "provider": os.getenv("MODEL_PROVIDER", "openai"),

    "model": os.getenv("MODEL_NAME", "gpt-5-mini"),

    "api_key": os.getenv("OPENAI_API_KEY"),

    "temperature": float(os.getenv("TEMPERATURE", 1.0)),

    "max_tokens": int(os.getenv("MAX_TOKENS", 6000)), "cache": False

}



# Create default LM config but don't set it globally



default_lm = MODEL_OBJECTS[DEFAULT_MODEL_CONFIG['model']]

    



    

# lm = dspy.LM('openai/gpt-4o-mini', api_key=os.getenv("OPENAI_API_KEY"))

dspy.configure(lm=default_lm, async_max_workers=1000)



# Function to get model config from session or use default

def get_session_lm(session_state):

    """Get the appropriate LM instance for a session, or default if not configured"""

    # First check if we have a valid session-specific model config 

    if session_state and isinstance(session_state, dict) and "model_config" in session_state:

        model_config = session_state["model_config"]

        if model_config and isinstance(model_config, dict) and "model" in model_config:

            # Found valid session-specific model config, use it

            provider = model_config.get("provider", "openai").lower()

            model_name = model_config.get("model", DEFAULT_MODEL_CONFIG["model"])

            # Get temperature and clamp to valid range for Anthropic (0..1)
            temp = model_config.get("temperature", DEFAULT_MODEL_CONFIG["temperature"])
            if provider == "anthropic":
                temp = min(1.0, max(0.0, float(temp)))

            # Handle special OpenAI models (gpt-5 and o1 series)
            if ('gpt-5' in model_name or 'o1' in model_name) and provider == 'openai':
                if 'gpt-5' in model_name:
                    MODEL_OBJECTS[model_name].__dict__['kwargs']['max_tokens'] = 16_000
                if 'o1' in model_name:
                    MODEL_OBJECTS[model_name].__dict__['kwargs']['max_tokens'] = 20_000
                MODEL_OBJECTS[model_name].__dict__['kwargs']['temperature'] = 1.0
            else:
                # All other models
                MODEL_OBJECTS[model_name].__dict__['kwargs']['max_tokens'] = model_config.get("max_tokens", DEFAULT_MODEL_CONFIG["max_tokens"])
                MODEL_OBJECTS[model_name].__dict__['kwargs']['temperature'] = temp



    

    # If no valid session config, use default

    return MODEL_OBJECTS[model_name]



# Initialize retrievers with empty data first



# clear console

def clear_console():

    os.system('cls' if os.name == 'nt' else 'clear')





# Check for Housing.csv

housing_csv_path = "Housing.csv"

if not os.path.exists(housing_csv_path):

    logger.log_message(f"Housing.csv not found at {os.path.abspath(housing_csv_path)}", level=logging.ERROR)

    raise FileNotFoundError(f"Housing.csv not found at {os.path.abspath(housing_csv_path)}")



# All agents are now loaded from database - no hardcoded dictionaries needed



# Add session header

X_SESSION_ID = APIKeyHeader(name="X-Session-ID", auto_error=False)



# Update AppState class to use SessionManager

# The AppState class is now in src.managers.app_manager



# Initialize FastAPI app with state

app = FastAPI(title="AI Analytics API", version="1.0")

# Pass required parameters to AppState
app.state = AppState(styling_instructions, chat_history_name_agent, DEFAULT_MODEL_CONFIG)





# Configure middleware

# Use a wildcard for local development or read from environment

is_development = os.getenv("ENVIRONMENT", "development").lower() == "development"



allowed_origins = []

frontend_url = os.getenv("FRONTEND_URL", "").strip()

print(f"FRONTEND_URL: {frontend_url}")

if is_development:

    allowed_origins = ["*"]

elif frontend_url:

    allowed_origins = [frontend_url]

else:

    logger.log_message("CORS misconfigured: FRONTEND_URL not set", level=logging.ERROR)

    allowed_origins = []  # or set a default safe origin



# Add a strict origin verification middleware

@app.middleware("http")

async def verify_origin_middleware(request: Request, call_next):

    # Skip origin check in development mode

    if is_development:

        return await call_next(request)

    

    # Get the origin from the request headers

    origin = request.headers.get("origin")

    

    # Log the origin for debugging

    if origin:

        print(f"Request from origin: {origin}")

    

    # If no origin header or origin not in allowed list, reject the request

    if origin and frontend_url and origin != frontend_url:

        print(f"Blocked request from unauthorized origin: {origin}")

        return JSONResponse(

            status_code=403,

            content={"detail": "Not authorized"}

        )

    

    # Continue processing the request if origin is allowed

    return await call_next(request)



# CORS middleware (still needed for browser preflight)

app.add_middleware(

    CORSMiddleware,

    allow_origins=allowed_origins,

    allow_origin_regex=None,

    allow_credentials=True,

    allow_methods=["*"],

    allow_headers=["*"],

    expose_headers=["*"],

    max_age=600  # Cache preflight requests for 10 minutes (for performance)

)



# Add these constants at the top of the file with other imports/constants

RESPONSE_ERROR_INVALID_QUERY = "Please provide a valid query..."

RESPONSE_ERROR_NO_DATASET = "No dataset is currently loaded. Please link a dataset before proceeding with your analysis."

DEFAULT_TOKEN_RATIO = 1.5

REQUEST_TIMEOUT_SECONDS = 30  # Timeout for LLM requests

MAX_RECENT_MESSAGES = 5

DB_BATCH_SIZE = 10  # For future batch DB operations



@app.post("/chat/{agent_name}", response_model=dict)

async def chat_with_agent(

    agent_name: str, 

    request: QueryRequest,

    request_obj: Request,

    session_id: str = Depends(get_session_id_dependency)

):

    session_state = app.state.get_session_state(session_id)

    logger.log_message(f"[DEBUG] chat_with_agent called with agent: '{agent_name}', query: '{request.query[:100]}...'", level=logging.DEBUG)

    

    try:

        # Extract and validate query parameters

        logger.log_message(f"[DEBUG] Updating session from query params", level=logging.DEBUG)

        _update_session_from_query_params(request_obj, session_state)

        logger.log_message(f"[DEBUG] Session state after query params: user_id={session_state.get('user_id')}, chat_id={session_state.get('chat_id')}", level=logging.DEBUG)

        

        # Validate dataset and agent name

        if session_state["datasets"] is None:
            logger.log_message(f"[DEBUG] No dataset loaded", level=logging.DEBUG)

            raise HTTPException(status_code=400, detail=RESPONSE_ERROR_NO_DATASET)



        # Log the dataset being used for analysis with detailed information
        datasets = session_state["datasets"]
        dataset_names = list(datasets.keys())
        if dataset_names:
            current_dataset_name = dataset_names[-1]  # Get the last (most recent) dataset
            dataset_shape = datasets[current_dataset_name].shape
            
            # Check if this is the default dataset and explain why
            session_name = session_state.get("name", "")
            is_default_dataset = (current_dataset_name == "df" and session_name == "Housing.csv") or current_dataset_name == "Housing.csv"
            
            if is_default_dataset:
                logger.log_message(f"[ANALYSIS] Using DEFAULT dataset 'Housing.csv' for analysis (shape: {dataset_shape[0]} rows, {dataset_shape[1]} columns)", level=logging.INFO)
                logger.log_message(f"[ANALYSIS] Reason: No custom dataset uploaded yet - using default Housing.csv dataset", level=logging.INFO)
            else:
                logger.log_message(f"[ANALYSIS] Using CUSTOM dataset '{current_dataset_name}' for analysis (shape: {dataset_shape[0]} rows, {dataset_shape[1]} columns)", level=logging.INFO)
                logger.log_message(f"[ANALYSIS] This is a user-uploaded dataset, not the default", level=logging.INFO)
        else:
            logger.log_message(f"[ANALYSIS] No datasets available in session {session_id}", level=logging.WARNING)

        logger.log_message(f"[DEBUG] About to validate agent name: '{agent_name}'", level=logging.DEBUG)

        _validate_agent_name(agent_name, session_state)

        logger.log_message(f"[DEBUG] Agent validation completed successfully", level=logging.DEBUG)

        

        # Record start time for timing

        start_time = time.time()

        

        # Get chat context and prepare query

        logger.log_message(f"[DEBUG] Preparing query with context", level=logging.DEBUG)

        enhanced_query = _prepare_query_with_context(request.query, session_state)

        logger.log_message(f"[DEBUG] Enhanced query length: {len(enhanced_query)}", level=logging.DEBUG)

        

        # Initialize agent - handle standard, template, and custom agents

        if "," in agent_name:

            logger.log_message(f"[DEBUG] Processing multiple agents: {agent_name}", level=logging.DEBUG)

            # Multiple agents case

            agent_list = [agent.strip() for agent in agent_name.split(",")]

            

            # Categorize agents

            standard_agents = [agent for agent in agent_list if _is_standard_agent(agent)]

            template_agents = [agent for agent in agent_list if _is_template_agent(agent)]

            custom_agents = [agent for agent in agent_list if not _is_standard_agent(agent) and not _is_template_agent(agent)]

            

            logger.log_message(f"[DEBUG] Agent categorization - standard: {standard_agents}, template: {template_agents}, custom: {custom_agents}", level=logging.DEBUG)

            

            if custom_agents:

                # If any custom agents, use session AI system for all

                ai_system = session_state["ai_system"]

                session_lm = get_session_lm(session_state)

                logger.log_message(f"[DEBUG] Using custom agent execution path", level=logging.DEBUG)

                with dspy.context(lm=session_lm):

                    response = await asyncio.wait_for(

                        _execute_custom_agents(ai_system, agent_list, enhanced_query),

                        timeout=REQUEST_TIMEOUT_SECONDS

                    )

                    logger.log_message(f"[DEBUG] Custom agents response type: {type(response)}, keys: {list(response.keys()) if isinstance(response, dict) else 'not a dict'}", level=logging.DEBUG)

            else:

                # All standard/template agents - use auto_analyst_ind which loads from DB

                user_id = session_state.get("user_id")

                logger.log_message(f"[DEBUG] Using auto_analyst_ind for multiple standard/template agents with user_id: {user_id}", level=logging.DEBUG)

        

                # Create database session for agent loading

                from src.db.init_db import session_factory

                db_session = session_factory()

                try:

                    # auto_analyst_ind will load all agents from database

                    logger.log_message(f"[DEBUG] Creating auto_analyst_ind instance", level=logging.DEBUG)

                    agent = auto_analyst_ind(agents=[], retrievers=session_state["retrievers"], user_id=user_id, db_session=db_session)

                    session_lm = get_session_lm(session_state)

                    logger.log_message(f"[DEBUG] About to call agent.forward with query and agent list", level=logging.DEBUG)

                    with dspy.context(lm=session_lm):

                        response = await asyncio.wait_for(

                            agent(enhanced_query, ",".join(agent_list)),

                            timeout=REQUEST_TIMEOUT_SECONDS

                        )

                        logger.log_message(f"[DEBUG] auto_analyst_ind response type: {type(response)}, content: {str(response)[:200]}...", level=logging.DEBUG)

                finally:

                    db_session.close()

        else:

            logger.log_message(f"[DEBUG] Processing single agent: {agent_name}", level=logging.DEBUG)

            # Single agent case

            if _is_standard_agent(agent_name) or _is_template_agent(agent_name):

                # Standard or template agent - use auto_analyst_ind which loads from DB

                user_id = session_state.get("user_id")

                logger.log_message(f"[DEBUG] Using auto_analyst_ind for single standard/template agent '{agent_name}' with user_id: {user_id}", level=logging.DEBUG)

                

                # Create database session for agent loading

                from src.db.init_db import session_factory

                db_session = session_factory()

                try:

                    # auto_analyst_ind will load all agents from database

                    logger.log_message(f"[DEBUG] Creating auto_analyst_ind instance for single agent", level=logging.DEBUG)

                    agent = auto_analyst_ind(agents=[], retrievers=session_state["retrievers"], user_id=user_id, db_session=db_session)

                    session_lm = get_session_lm(session_state)

                    logger.log_message(f"[DEBUG] About to call agent.forward for single agent '{agent_name}'", level=logging.DEBUG)

                    with dspy.context(lm=session_lm):

                        response = await asyncio.wait_for(

                            agent(enhanced_query, agent_name),

                            timeout=REQUEST_TIMEOUT_SECONDS

                        )

                        logger.log_message(f"[DEBUG] Single agent response type: {type(response)}, content: {str(response)[:200]}...", level=logging.DEBUG)

                finally:

                    db_session.close()

            else:

                # Custom agent - use session AI system

                ai_system = session_state["ai_system"]

                session_lm = get_session_lm(session_state)

                logger.log_message(f"[DEBUG] Using custom agent execution for '{agent_name}'", level=logging.DEBUG)

                with dspy.context(lm=session_lm):

                    response = await asyncio.wait_for(

                        _execute_custom_agents(ai_system, [agent_name], enhanced_query),

                        timeout=REQUEST_TIMEOUT_SECONDS

                    )

                    logger.log_message(f"[DEBUG] Custom single agent response type: {type(response)}, content: {str(response)[:200]}...", level=logging.DEBUG)

        

        logger.log_message(f"[DEBUG] About to format response to markdown. Response type: {type(response)}", level=logging.DEBUG)

        formatted_response = format_response_to_markdown(response, agent_name, session_state["datasets"])
        logger.log_message(f"[DEBUG] Formatted response type: {type(formatted_response)}, length: {len(str(formatted_response))}", level=logging.DEBUG)

        

        if formatted_response == RESPONSE_ERROR_INVALID_QUERY:

            logger.log_message(f"[DEBUG] Response was invalid query error", level=logging.DEBUG)

            return {

                "agent_name": agent_name,

                "query": request.query,

                "response": formatted_response,

                "session_id": session_id

            }

        

        # Track usage statistics

        if session_state.get("user_id"):

            logger.log_message(f"[DEBUG] Tracking model usage", level=logging.DEBUG)

            _track_model_usage(

                session_state=session_state,

                enhanced_query=enhanced_query,

                response=response,

                processing_time_ms=int((time.time() - start_time) * 1000)

            )

        

        logger.log_message(f"[DEBUG] chat_with_agent completed successfully", level=logging.DEBUG)

        return {

            "agent_name": agent_name,

            "query": request.query,  # Return original query without context

            "response": formatted_response,

            "session_id": session_id

        }

    except HTTPException:

        # Re-raise HTTP exceptions to preserve status codes

        logger.log_message(f"[DEBUG] HTTPException caught and re-raised", level=logging.DEBUG)

        raise

    except asyncio.TimeoutError:

        logger.log_message(f"[ERROR] Timeout error in chat_with_agent", level=logging.ERROR)

        raise HTTPException(status_code=504, detail="Request timed out. Please try a simpler query.")

    except Exception as e:

        logger.log_message(f"[ERROR] Unexpected error in chat_with_agent: {str(e)}", level=logging.ERROR)

        logger.log_message(f"[ERROR] Exception type: {type(e)}, traceback: {str(e)}", level=logging.ERROR)

        import traceback

        logger.log_message(f"[ERROR] Full traceback: {traceback.format_exc()}", level=logging.ERROR)

        raise HTTPException(status_code=500, detail="An unexpected error occurred. Please try again later.")





@app.post("/chat", response_model=dict)

async def chat_with_all(

    request: QueryRequest,

    request_obj: Request,

    session_id: str = Depends(get_session_id_dependency)

):

    session_state = app.state.get_session_state(session_id)



    try:

        # Extract and validate query parameters

        _update_session_from_query_params(request_obj, session_state)

        

        # Validate dataset

        if session_state["datasets"] is None:
            raise HTTPException(status_code=400, detail=RESPONSE_ERROR_NO_DATASET)

        

        if session_state["ai_system"] is None:

            raise HTTPException(status_code=500, detail="AI system not properly initialized.")



        # Get session-specific model

        session_lm = get_session_lm(session_state)



        # Create streaming response

        return StreamingResponse(

            _generate_streaming_responses(session_state, request.query, session_lm),

            media_type='text/event-stream',

            headers={

                'Cache-Control': 'no-cache',

                'Connection': 'keep-alive',

                'Content-Type': 'text/event-stream',

                'Access-Control-Allow-Origin': '*',

                'X-Accel-Buffering': 'no'

            }

        )

    except HTTPException:

        # Re-raise HTTP exceptions to preserve status codes

        raise

    except Exception as e:

        raise HTTPException(status_code=500, detail="An unexpected error occurred. Please try again later.")





# Helper functions to reduce duplication and improve modularity

def _update_session_from_query_params(request_obj: Request, session_state: dict):

    """Extract and validate chat_id and user_id from query parameters"""

    # Check for chat_id in query parameters

    if "chat_id" in request_obj.query_params:

        try:

            chat_id_param = int(request_obj.query_params.get("chat_id"))

            # Update session state with this chat ID

            session_state["chat_id"] = chat_id_param

        except (ValueError, TypeError):

            logger.log_message("Invalid chat_id parameter", level=logging.WARNING)

            # Continue without updating chat_id



    # Check for user_id in query parameters

    if "user_id" in request_obj.query_params:

        try:

            user_id = int(request_obj.query_params["user_id"])

            session_state["user_id"] = user_id

        except (ValueError, TypeError):

            raise HTTPException(

                status_code=400,

                detail="Invalid user_id in query params. Please provide a valid integer."

            )





def _validate_agent_name(agent_name: str, session_state: dict = None):

    """Validate that the agent name(s) are available"""

    logger.log_message(f"[DEBUG] Validating agent name: '{agent_name}'", level=logging.DEBUG)

    

    if "," in agent_name:

        # Multiple agents

        agent_list = [agent.strip() for agent in agent_name.split(",")]

        logger.log_message(f"[DEBUG] Multiple agents detected: {agent_list}", level=logging.DEBUG)

        for agent in agent_list:

            is_available = _is_agent_available(agent, session_state)

            logger.log_message(f"[DEBUG] Agent '{agent}' availability: {is_available}", level=logging.DEBUG)

            if not is_available:

                available_agents = _get_available_agents_list(session_state)

                logger.log_message(f"[DEBUG] Agent '{agent}' not found. Available: {available_agents}", level=logging.DEBUG)

                raise HTTPException(

                    status_code=400, 

                    detail=f"Agent '{agent}' not found. Available agents: {available_agents}"

                )

    else:

        # Single agent

        is_available = _is_agent_available(agent_name, session_state)

        logger.log_message(f"[DEBUG] Single agent '{agent_name}' availability: {is_available}", level=logging.DEBUG)

        if not is_available:

            available_agents = _get_available_agents_list(session_state)

            logger.log_message(f"[DEBUG] Agent '{agent_name}' not found. Available: {available_agents}", level=logging.DEBUG)

            raise HTTPException(

                status_code=400, 

                detail=f"Agent '{agent_name}' not found. Available agents: {available_agents}"

            )

    

    logger.log_message(f"[DEBUG] Agent validation passed for: '{agent_name}'", level=logging.DEBUG)



def _is_agent_available(agent_name: str, session_state: dict = None) -> bool:

    """Check if an agent is available (standard, template, or custom)"""

    # Check if it's a standard agent

    if _is_standard_agent(agent_name):

        return True

    

    # Check if it's a template agent

    if _is_template_agent(agent_name):

        return True

    

    # Check if it's a custom agent in session

    if session_state and "ai_system" in session_state:

        ai_system = session_state["ai_system"]

        if hasattr(ai_system, 'agents') and agent_name in ai_system.agents:

            return True

    

    return False



def _get_available_agents_list(session_state: dict = None) -> list:

    """Get list of all available agents from database"""

    from src.db.init_db import session_factory

    from src.agents.agents import load_all_available_templates_from_db

    

    # Core agents (always available)

    available = ["preprocessing_agent", "statistical_analytics_agent", "sk_learn_agent", "data_viz_agent"]

    

    # Add template agents from database

    db_session = session_factory()

    try:

        template_agents_dict = load_all_available_templates_from_db(db_session)

        # template_agents_dict is a dict with template_name as keys

        template_names = [template_name for template_name in template_agents_dict.keys() 

                         if template_name not in available and template_name != 'basic_qa_agent']

        available.extend(template_names)

    except Exception as e:

        logger.log_message(f"Error loading template agents: {str(e)}", level=logging.ERROR)

    finally:

        db_session.close()

    

    return available



def _is_standard_agent(agent_name: str) -> bool:

    """Check if agent is one of the 4 core standard agents"""

    standard_agents = ["preprocessing_agent", "statistical_analytics_agent", "sk_learn_agent", "data_viz_agent"]

    return agent_name in standard_agents



def _is_template_agent(agent_name: str) -> bool:

    """Check if agent is a template agent"""

    try:

        from src.db.init_db import session_factory

        from src.db.schemas.models import AgentTemplate

        

        db_session = session_factory()

        try:

            template = db_session.query(AgentTemplate).filter(

                AgentTemplate.template_name == agent_name,

                AgentTemplate.is_active == True

            ).first()

            return template is not None

        finally:

            db_session.close()

    except Exception as e:

        logger.log_message(f"Error checking if {agent_name} is template: {str(e)}", level=logging.ERROR)

        return False



async def _execute_custom_agents(ai_system, agent_names: list, query: str):

    """Execute custom agents using the session's AI system"""

    try:

        # For custom agents, we need to use the AI system's execute_agent method



        agent_results = [ai_system]

        if len(agent_names) == 1:

            # Single custom agent

            agent_name = agent_names[0]

            # Prepare inputs for the custom agent (similar to standard agents like data_viz_agent)

            dict_ = {}

            dict_['dataset'] = ai_system.dataset.retrieve(query)[0].text

            dict_['styling_index'] = ai_system.styling_index.retrieve(query)[0].text

            dict_['goal'] = query

            dict_['Agent_desc'] = str(ai_system.agent_desc)



            # Get input fields for this agent

            if agent_name in ai_system.agent_inputs:

                inputs = {x: dict_[x] for x in ai_system.agent_inputs[agent_name] if x in dict_}

                

                # Execute the custom agent

                agent_name_result, result_dict = await ai_system.agents[agent_name](**inputs)

                return {agent_name_result: result_dict}

            else:

                logger.log_message(f"Agent '{agent_name}' not found in ai_system.agent_inputs", level=logging.ERROR)

                return {"error": f"Agent '{agent_name}' input configuration not found"}

        else:

            # Multiple agents - execute sequentially

            results = {}

            for agent_name in agent_names:

                single_result = await _execute_custom_agents(ai_system, [agent_name], query)

                results.update(single_result)

            return results

            

    except Exception as e:

        logger.log_message(f"Error in _execute_custom_agents: {str(e)}", level=logging.ERROR)

        return {"error": f"Error executing custom agents: {str(e)}"}



def _prepare_query_with_context(query: str, session_state: dict) -> str:

    """Prepare the query with chat context from previous messages"""

    chat_id = session_state.get("chat_id")

    if not chat_id:

        return query

        

    # Get chat manager from app state

    chat_manager = app.state._session_manager.chat_manager

    # Get recent messages

    recent_messages = chat_manager.get_recent_chat_history(chat_id, limit=MAX_RECENT_MESSAGES)

    # Extract response history

    chat_context = chat_manager.extract_response_history(recent_messages)

    

    # Append context to the query if available

    if chat_context:

        return f"### Current Query:\n{query}\n\n{chat_context}"

    return query





def _track_model_usage(session_state: dict, enhanced_query: str, response, processing_time_ms: int):

    """Track model usage statistics in the database"""

    try:

        ai_manager = app.state.get_ai_manager()

        

        # Get model configuration

        model_config = session_state.get("model_config", DEFAULT_MODEL_CONFIG)

        model_name = model_config.get("model", DEFAULT_MODEL_CONFIG["model"])

        provider = ai_manager.get_provider_for_model(model_name)

        

        # Calculate token usage

        try:

            # Try exact tokenization

            prompt_tokens = len(ai_manager.tokenizer.encode(enhanced_query))

            completion_tokens = len(ai_manager.tokenizer.encode(str(response)))

            total_tokens = prompt_tokens + completion_tokens

        except Exception as token_error:

            # Fall back to estimation

            logger.log_message(f"Tokenization error: {str(token_error)}", level=logging.WARNING)

            prompt_words = len(enhanced_query.split())

            completion_words = len(str(response).split())

            prompt_tokens = int(prompt_words * DEFAULT_TOKEN_RATIO)

            completion_tokens = int(completion_words * DEFAULT_TOKEN_RATIO)

            total_tokens = prompt_tokens + completion_tokens

        

        # Calculate cost

        cost = ai_manager.calculate_cost(model_name, prompt_tokens, completion_tokens)

        

        # Save usage to database

        ai_manager.save_usage_to_db(

            user_id=session_state.get("user_id"),

            chat_id=session_state.get("chat_id"),

            model_name=model_name,

            provider=provider,

            prompt_tokens=int(prompt_tokens),

            completion_tokens=int(completion_tokens),

            total_tokens=int(total_tokens),

            query_size=len(enhanced_query),

            response_size=len(str(response)),

            cost=round(cost, 7),

            request_time_ms=processing_time_ms,

            is_streaming=False

        )

    except Exception as e:

        # Log but don't fail the request if usage tracking fails

        logger.log_message(f"Failed to track model usage: {str(e)}", level=logging.ERROR)





async def _generate_streaming_responses(session_state: dict, query: str, session_lm):

    """Generate streaming responses for chat_with_all endpoint"""

    overall_start_time = time.time()

    total_response = ""

    total_inputs = ""

    usage_records = []



    # Add chat context from previous messages

    enhanced_query = _prepare_query_with_context(query, session_state)

    

    # try:

        # Get the plan - planner is now async, so we need to await it

    plan_response = await session_state["ai_system"].get_plan(enhanced_query)

    

    plan_description = format_response_to_markdown(

        {"analytical_planner": plan_response}, 

        datasets=session_state["datasets"]
    )

    

    # Check if plan is valid

    if plan_description == RESPONSE_ERROR_INVALID_QUERY:

        yield json.dumps({

            "agent": "Analytical Planner",

            "content": plan_description,

            "status": "error"

        }) + "\n"

        return

    

    yield json.dumps({

        "agent": "Analytical Planner",

        "content": plan_description,

        "status": "success" if plan_description else "error"

    }) + "\n"

    

    # Track planner usage

    if session_state.get("user_id"):

        planner_tokens = _estimate_tokens(ai_manager=app.state.ai_manager, 

                                        input_text=enhanced_query, 

                                        output_text=plan_description)

        

        usage_records.append(_create_usage_record(

            session_state=session_state,

            model_name=session_state.get("model_config", DEFAULT_MODEL_CONFIG)["model"],

            prompt_tokens=planner_tokens["prompt"],

            completion_tokens=planner_tokens["completion"],

            query_size=len(enhanced_query),

            response_size=len(plan_description),

            processing_time_ms=int((time.time() - overall_start_time) * 1000),

            is_streaming=False

        ))

    

    logger.log_message(f"Plan response: {plan_response}", level=logging.INFO)

    logger.log_message(f"Plan response type: {type(plan_response)}", level=logging.INFO)



    # Check if plan_response is valid

    # if not plan_response or not isinstance(plan_response, dict):

    #     yield json.dumps({

    #         "agent": "Analytical Planner",

    #         "content": "**Error: Invalid plan response**\n\nResponse: " + str(plan_response),

    #         "status": "error"

    #     }) + "\n"

    #     return

    

    # Execute the plan with well-managed concurrency

    with dspy.context(lm = session_lm):

        # try:

            

        async for agent_name, inputs, response in session_state["ai_system"].execute_plan(enhanced_query, plan_response):

            

            if agent_name == "plan_not_found":

                yield json.dumps({

                    "agent": "Analytical Planner",

                    "content": "**No plan found**\n\nPlease try again with a different query or try using a different model.",

                    "status": "error"

                }) + "\n"

                return

                

            if agent_name == "plan_not_formated_correctly":

                yield json.dumps({

                    "agent": "Analytical Planner",

                    "content": "**Something went wrong with formatting, retry the query!**",

                    "status": "error"

                }) + "\n"

                return

            



            formatted_response = format_response_to_markdown(

                {agent_name: response}, 

                datasets=session_state["datasets"]
            ) 



            yield json.dumps({

                "agent": agent_name.split("__")[0] if "__" in agent_name else agent_name,

                "content": formatted_response,

                "status": "success" if response else "error"

            }) + "\n"



            # Handle agent errors

            if isinstance(response, dict) and "error" in response:

                yield json.dumps({

                    "agent": agent_name,

                    "content": f"**Error in {agent_name}**: {response['error']}",

                    "status": "error"

                }) + "\n"

                continue  # Continue with next agent instead of returning







            if formatted_response == RESPONSE_ERROR_INVALID_QUERY:

                yield json.dumps({

                    "agent": agent_name,

                    "content": formatted_response,

                    "status": "error"

                }) + "\n"

                continue  # Continue with next agent instead of returning



            # Send response chunk



            

            # Track agent usage for future batch DB write

            if session_state.get("user_id"):

                agent_tokens = _estimate_tokens(

                    ai_manager=app.state.ai_manager,

                    input_text=str(inputs),

                    output_text=str(response)

                )

                

                # Get appropriate model name for code combiner

                if "code_combiner_agent" in agent_name and "__" in agent_name:

                    provider = agent_name.split("__")[1]

                    model_name = _get_model_name_for_provider(provider)

                else:

                    model_name = session_state.get("model_config", DEFAULT_MODEL_CONFIG)["model"]



                usage_records.append(_create_usage_record(

                    session_state=session_state,

                    model_name=model_name,

                    prompt_tokens=agent_tokens["prompt"],

                    completion_tokens=agent_tokens["completion"],

                    query_size=len(str(inputs)),

                    response_size=len(str(response)),

                    processing_time_ms=int((time.time() - overall_start_time) * 1000),

                    is_streaming=True

                ))

                    

        # except asyncio.TimeoutError:

        #     yield json.dumps({

        #         "agent": "planner",

        #         "content": "The request timed out. Please try a simpler query.",

        #         "status": "error"

        #     }) + "\n"

        #     return

            

        # except Exception as e:

        #     logger.log_message(f"Error executing plan: {str(e)}", level=logging.ERROR)

        #     yield json.dumps({

        #         "agent": "planner",

        #         "content": f"An error occurred while executing the plan: {str(e)}",

        #         "status": "error"

        #     }) + "\n"

        #     return

                

    # except Exception as e:

    #         logger.log_message(f"Error in streaming response: {str(e)}", level=logging.ERROR)

    #         yield json.dumps({

    #             "agent": "planner",

    #             "content": "An error occurred while generating responses. Please try again!" + str(e) + str({k: v for k, v in session_lm.__dict__['kwargs'].items() if k != 'api_key'}),

    #             "status": "error"

    #         }) + "\n"





def _estimate_tokens(ai_manager, input_text: str, output_text: str) -> dict:

    """Estimate token counts, with fallback for tokenization errors"""

    try:

        # Try exact tokenization

        prompt_tokens = len(ai_manager.tokenizer.encode(input_text))

        completion_tokens = len(ai_manager.tokenizer.encode(output_text))

    except Exception:

        # Fall back to estimation

        prompt_words = len(input_text.split())

        completion_words = len(output_text.split())

        prompt_tokens = int(prompt_words * DEFAULT_TOKEN_RATIO)

        completion_tokens = int(completion_words * DEFAULT_TOKEN_RATIO)

    

    return {

        "prompt": prompt_tokens,

        "completion": completion_tokens,

        "total": prompt_tokens + completion_tokens

    }





def _create_usage_record(session_state: dict, model_name: str, prompt_tokens: int, 

                        completion_tokens: int, query_size: int, response_size: int,

                        processing_time_ms: int, is_streaming: bool) -> dict:

    """Create a usage record for the database"""

    ai_manager = app.state.get_ai_manager()

    provider = ai_manager.get_provider_for_model(model_name)

    cost = ai_manager.calculate_cost(model_name, prompt_tokens, completion_tokens)

    

    return {

        "user_id": session_state.get("user_id"),

        "chat_id": session_state.get("chat_id"),

        "model_name": model_name,

        "provider": provider,

        "prompt_tokens": int(prompt_tokens),

        "completion_tokens": int(completion_tokens),

        "total_tokens": int(prompt_tokens + completion_tokens),

        "query_size": query_size,

        "response_size": response_size,

        "cost": round(cost, 7),

        "request_time_ms": processing_time_ms,

        "is_streaming": is_streaming

    }





def _get_model_name_for_provider(provider: str) -> str:

    """Get the model name for a provider"""

    provider_model_map = {

        "openai": "o3-mini",

        "anthropic": "claude-3-7-sonnet-latest",

        "gemini": "gemini-2.5-pro-preview-03-25"

    }

    return provider_model_map.get(provider, "o3-mini")







# Add an endpoint to list available agents

@app.get("/agents", response_model=dict)

async def list_agents(request: Request, session_id: str = Depends(get_session_id_dependency)):

    """Get all available agents (standard, template, and custom)"""

    session_state = app.state.get_session_state(session_id)

    

    try:

        # Get all available agents from database and session

        available_agents_list = _get_available_agents_list(session_state)

        

        # Categorize agents

        standard_agents = ["preprocessing_agent", "statistical_analytics_agent", "sk_learn_agent", "data_viz_agent"]

        

        # Get template agents from database

        from src.db.init_db import session_factory

        from src.agents.agents import load_all_available_templates_from_db

        

        db_session = session_factory()

        try:

            template_agents_dict = load_all_available_templates_from_db(db_session)

            # template_agents_dict is a dict with template_name as keys

            template_agents = [template_name for template_name in template_agents_dict.keys() 

                             if template_name not in standard_agents and template_name != 'basic_qa_agent']

        except Exception as e:

            logger.log_message(f"Error loading template agents in /agents endpoint: {str(e)}", level=logging.ERROR)

            template_agents = []

        finally:

            db_session.close()

        

        # Get custom agents from session

        custom_agents = []

        if session_state and "ai_system" in session_state:

            ai_system = session_state["ai_system"]

            if hasattr(ai_system, 'agents'):

                custom_agents = [agent for agent in available_agents_list

                               if agent not in standard_agents and agent not in template_agents]

        

        # Ensure template agents are in the available list

        for template_agent in template_agents:

            if template_agent not in available_agents_list:

                available_agents_list.append(template_agent)

        

        return {

            "available_agents": available_agents_list,

            "standard_agents": standard_agents,

            "template_agents": template_agents,

            "custom_agents": custom_agents

        }

    except Exception as e:

        logger.log_message(f"Error getting agents list: {str(e)}", level=logging.ERROR)

        raise HTTPException(status_code=500, detail=f"Error getting agents list: {str(e)}")



@app.get("/health", response_model=dict)

async def health():

    return {"message": "API is healthy and running"}



@app.get("/")

async def index():

    return {

        "title": "Welcome to the AI Analytics API",

        "message": "Explore our API for advanced analytics and visualization tools designed to empower your data-driven decisions.",

        "description": "Utilize our powerful agents and models to gain insights from your data effortlessly.",

        "colors": {

            "primary": "#007bff",

            "secondary": "#6c757d",

            "success": "#28a745",

            "danger": "#dc3545",

        },

        "features": [

            "Real-time data processing",

            "Customizable visualizations",

            "Seamless integration with various data sources",

            "User-friendly interface for easy navigation",

            "Custom Analytics",

        ],

    }



@app.post("/chat_history_name")

async def chat_history_name(request: dict, session_id: str = Depends(get_session_id_dependency)):

    query = request.get("query")

    name = None

    

    lm = dspy.LM(model="gpt-4o-mini", max_tokens=300, temperature=0.5)

    

    with dspy.context(lm=lm):

        name = app.state.get_chat_history_name_agent()(query=str(query))

        

    return {"name": name.name if name else "New Chat"}



@app.post("/deep_analysis_streaming")

async def deep_analysis_streaming(

    request: DeepAnalysisRequest,

    request_obj: Request,

    session_id: str = Depends(get_session_id_dependency)

):

    """Perform streaming deep analysis with real-time updates"""

    session_state = app.state.get_session_state(session_id)

    

    try:

        # Extract and validate query parameters

        _update_session_from_query_params(request_obj, session_state)

        

        # Validate dataset

        if session_state["datasets"] is None:
            raise HTTPException(status_code=400, detail=RESPONSE_ERROR_NO_DATASET)

        

        # Get user_id from session state (if available)

        user_id = session_state.get("user_id")

        

        # Generate a UUID for this report

        import uuid

        report_uuid = str(uuid.uuid4())

        

        # Create initial pending report in the database

        try:

            from src.db.init_db import session_factory

            from src.db.schemas.models import DeepAnalysisReport

            

            db_session = session_factory()

            

            try:

                # Create a pending report entry

                new_report = DeepAnalysisReport(

                    report_uuid=report_uuid,

                    user_id=user_id,

                    goal=request.goal,

                    status="pending",

                    start_time=datetime.now(UTC),

                    progress_percentage=0

                )

                

                db_session.add(new_report)

                db_session.commit()

                db_session.refresh(new_report)

                

                # Store the report ID in session state for later updates

                session_state["current_deep_analysis_id"] = new_report.report_id

                session_state["current_deep_analysis_uuid"] = report_uuid

                

            except Exception as e:

                logger.log_message(f"Error creating initial deep analysis report: {str(e)}", level=logging.ERROR)

                # Continue even if DB storage fails

            finally:

                db_session.close()

                

        except Exception as e:

            logger.log_message(f"Database operation failed: {str(e)}", level=logging.ERROR)

            # Continue even if DB operation fails

        

        # Get session-specific model

        # session_lm = get_session_lm(session_state)

        session_lm = dspy.LM(model="anthropic/claude-sonnet-4-20250514", max_tokens=7000, temperature=0.5)

        

        return StreamingResponse(

            _generate_deep_analysis_stream(session_state, request.goal, session_lm, session_id),

            media_type='text/event-stream',

            headers={

                'Cache-Control': 'no-cache',

                'Connection': 'keep-alive',

                'Content-Type': 'text/event-stream',

                'Access-Control-Allow-Origin': '*',

                'X-Accel-Buffering': 'no'

            }

        )

        

    except HTTPException:

        raise

    except Exception as e:

        logger.log_message(f"Streaming deep analysis failed: {str(e)}", level=logging.ERROR)

        raise HTTPException(status_code=500, detail=f"Streaming deep analysis failed: {str(e)}")



async def _generate_deep_analysis_stream(session_state: dict, goal: str, session_lm, session_id: str):

    """Generate streaming responses for deep analysis"""

    # Track the start time for duration calculation

    start_time = datetime.now(UTC)

    

    try:

        # Get dataset info
        datasets = session_state["datasets"]
        desc = session_state['description']
        
        # Generate dataset info for all datasets
        logger.log_message(f"πŸ” DEEP ANALYSIS START - datasets type: {type(datasets)}, keys: {list(datasets.keys()) if datasets else 'None'}", level=logging.DEBUG)
        
        dataset_info = desc
        logger.log_message(f"πŸ” DEEP ANALYSIS - dataset_info type: {type(dataset_info)}, length: {len(dataset_info) if isinstance(dataset_info, str) else 'N/A'}", level=logging.DEBUG)
        logger.log_message(f"πŸ” DEEP ANALYSIS - dataset_info content: {dataset_info[:200]}...", level=logging.DEBUG)

        

        # Get report info from session state

        report_id = session_state.get("current_deep_analysis_id")

        report_uuid = session_state.get("current_deep_analysis_uuid")

        user_id = session_state.get("user_id")

        

        # Helper function to update report in database

        async def update_report_in_db(status, progress, step=None, content=None):

            if not report_id:

                return

                

            try:

                from src.db.init_db import session_factory

                from src.db.schemas.models import DeepAnalysisReport

                

                db_session = session_factory()

                

                try:

                    report = db_session.query(DeepAnalysisReport).filter(DeepAnalysisReport.report_id == report_id).first()

                    

                    if report:

                        report.status = status

                        report.progress_percentage = progress

                        

                        # Update step-specific fields if provided

                        if step == "questions" and content:

                            report.deep_questions = content

                        elif step == "planning" and content:

                            report.deep_plan = content

                        elif step == "analysis" and content:

                            # For analysis step, we get the full object with multiple fields

                            if isinstance(content, dict):

                                # Update fields from content if they exist

                                if "deep_questions" in content and content["deep_questions"]:

                                    report.deep_questions = content["deep_questions"]

                                if "deep_plan" in content and content["deep_plan"]:

                                    report.deep_plan = content["deep_plan"]

                                if "code" in content and content["code"]:

                                    report.analysis_code = content["code"]

                                if "final_conclusion" in content and content["final_conclusion"]:

                                    report.final_conclusion = content["final_conclusion"]

                                    # Also update summary from conclusion

                                    conclusion = content["final_conclusion"]

                                    conclusion = conclusion.replace("**Conclusion**", "")

                                    report.report_summary = conclusion[:200] + "..." if len(conclusion) > 200 else conclusion

                                

                                # Handle JSON fields

                                if "summaries" in content and content["summaries"]:

                                    report.summaries = json.dumps(content["summaries"])

                                if "plotly_figs" in content and content["plotly_figs"]:

                                    report.plotly_figures = json.dumps(content["plotly_figs"])

                                if "synthesis" in content and content["synthesis"]:

                                    report.synthesis = json.dumps(content["synthesis"])

                        

                        # For the final step, update the HTML report

                        if step == "completed":

                            if content:

                                report.html_report = content

                            else:

                                logger.log_message("No HTML content provided for completed step", level=logging.WARNING)

                                

                            report.end_time = datetime.now(UTC)

                            # Ensure start_time is timezone-aware before calculating duration

                            if report.start_time.tzinfo is None:

                                start_time_utc = report.start_time.replace(tzinfo=UTC)

                            else:

                                start_time_utc = report.start_time

                            report.duration_seconds = int((report.end_time - start_time_utc).total_seconds())

                            

                        report.updated_at = datetime.now(UTC)

                        db_session.commit()

                        

                except Exception as e:

                    db_session.rollback()

                    logger.log_message(f"Error updating deep analysis report: {str(e)}", level=logging.ERROR)

                finally:

                    db_session.close()

            except Exception as e:

                logger.log_message(f"Database operation failed: {str(e)}", level=logging.ERROR)

        

        # Use session model for this request

        with dspy.context(lm=session_lm):

            # Send initial status

            yield json.dumps({

                "step": "initialization",

                "status": "starting",

                "message": "Initializing deep analysis...",

                "progress": 5

            }) + "\n"

            

            # Update DB status to running

            await update_report_in_db("running", 5)

            

            # Get deep analyzer - use the correct session_id from the session_state

            logger.log_message(f"Getting deep analyzer for session_id: {session_id}, user_id: {user_id}", level=logging.INFO)

            deep_analyzer = app.state.get_deep_analyzer(session_id)

            

            # Make all datasets available globally for code execution

            for dataset_name, dataset_df in datasets.items():
                globals()[dataset_name] = dataset_df
            
            # Use the new streaming method and forward all progress updates
            final_result = None

            logger.log_message(f"πŸ” CALLING DEEP ANALYSIS - goal: {goal[:100]}...", level=logging.DEBUG)
            logger.log_message(f"πŸ” CALLING DEEP ANALYSIS - dataset_info type: {type(dataset_info)}, length: {len(dataset_info) if isinstance(dataset_info, str) else 'N/A'}", level=logging.DEBUG)
            logger.log_message(f"πŸ” CALLING DEEP ANALYSIS - session_datasets type: {type(datasets)}, keys: {list(datasets.keys()) if datasets else 'None'}", level=logging.DEBUG)
            
            async for update in deep_analyzer.execute_deep_analysis_streaming(
                goal=goal,
                dataset_info=dataset_info,
                session_datasets=datasets  # Pass all datasets instead of single df
            ):

                # Convert the update to the expected format and yield it

                if update.get("step") == "questions" and update.get("status") == "completed":

                    # Update DB with questions

                    await update_report_in_db("running", update.get("progress", 0), "questions", update.get("content"))

                elif update.get("step") == "planning" and update.get("status") == "completed":

                    # Update DB with planning

                    await update_report_in_db("running", update.get("progress", 0), "planning", update.get("content"))

                elif update.get("step") == "conclusion" and update.get("status") == "completed":

                    # Store the final result for later processing

                    final_result = update.get("final_result")

                    

                    # Convert Plotly figures to JSON format for network transmission

                    if final_result:

                        import plotly.io

                        serialized_return_dict = final_result.copy()

                        

                        # Convert plotly_figs to JSON format

                        if 'plotly_figs' in serialized_return_dict and serialized_return_dict['plotly_figs']:

                            json_figs = []

                            for fig_list in serialized_return_dict['plotly_figs']:

                                if isinstance(fig_list, list):

                                    json_fig_list = []

                                    for fig in fig_list:

                                        if hasattr(fig, 'to_json'):  # Check if it's a Plotly figure

                                            json_fig_list.append(plotly.io.to_json(fig))

                                        else:

                                            json_fig_list.append(fig)  # Already JSON or other format

                                    json_figs.append(json_fig_list)

                                else:

                                    # Single figure case

                                    if hasattr(fig_list, 'to_json'):

                                        json_figs.append(plotly.io.to_json(fig_list))

                                    else:

                                        json_figs.append(fig_list)

                            serialized_return_dict['plotly_figs'] = json_figs

                        

                        # Update DB with analysis results

                        await update_report_in_db("running", update.get("progress", 0), "analysis", serialized_return_dict)

                        

                        # Generate HTML report using the original final_result with Figure objects

                        html_report = None

                        try:

                            html_report = generate_html_report(final_result)

                        except Exception as e:

                            logger.log_message(f"Error generating HTML report: {str(e)}", level=logging.ERROR)

                            # Continue even if HTML generation fails

                        

                        # Send the analysis results

                        yield json.dumps({

                            "step": "analysis",

                            "status": "completed",

                            "content": serialized_return_dict,

                            "progress": 90

                        }) + "\n"

                        

                        # Send report generation status

                        yield json.dumps({

                            "step": "report",

                            "status": "processing",

                            "message": "Generating final report...",

                            "progress": 95

                        }) + "\n"

                        

                        # Send final completion

                        yield json.dumps({

                            "step": "completed",

                            "status": "success",

                            "analysis": serialized_return_dict,

                            "html_report": html_report,

                            "progress": 100

                        }) + "\n"

                        

                        # Update DB with completed report (with HTML if generated)

                        if html_report:

                            logger.log_message(f"Saving HTML report to database, length: {len(html_report)}", level=logging.INFO)

                        else:

                            logger.log_message("No HTML report to save to database", level=logging.WARNING)

                        await update_report_in_db("completed", 100, "completed", html_report)

                elif update.get("step") == "error":

                    # Forward error directly

                    yield json.dumps(update) + "\n"

                    await update_report_in_db("failed", 0)

                    return

                else:

                    # Forward all other progress updates

                    yield json.dumps(update) + "\n"

            

            # If we somehow exit the loop without getting a final result, that's an error

            if not final_result:

                yield json.dumps({

                    "step": "error",

                    "status": "failed",

                    "message": "Deep analysis completed without final result",

                    "progress": 0

                }) + "\n"

                await update_report_in_db("failed", 0)

        

    except Exception as e:

        logger.log_message(f"Error in deep analysis stream: {str(e)}", level=logging.ERROR)

        yield json.dumps({

            "step": "error",

            "status": "failed",

            "message": f"Deep analysis failed: {str(e)}",

            "progress": 0

        }) + "\n"

        

        # Update DB with error status

        if 'update_report_in_db' in locals() and session_state.get("current_deep_analysis_id"):

            await update_report_in_db("failed", 0)



@app.post("/deep_analysis/download_report")

async def download_html_report(

    request: dict,

    session_id: str = Depends(get_session_id_dependency)

):

    """Download HTML report from previous deep analysis"""

    try:

        analysis_data = request.get("analysis_data")

        if not analysis_data:

            raise HTTPException(status_code=400, detail="No analysis data provided")

        

        # Get report UUID from request if available (for saving to DB)

        report_uuid = request.get("report_uuid")

        session_state = app.state.get_session_state(session_id)

        

        # If no report_uuid in request, try to get it from session state

        if not report_uuid and session_state.get("current_deep_analysis_uuid"):

            report_uuid = session_state.get("current_deep_analysis_uuid")

            

        # Convert JSON-serialized Plotly figures back to Figure objects for HTML generation

        processed_data = analysis_data.copy()

        

        if 'plotly_figs' in processed_data and processed_data['plotly_figs']:

            import plotly.io

            import plotly.graph_objects as go

            

            figure_objects = []

            for fig_list in processed_data['plotly_figs']:

                if isinstance(fig_list, list):

                    fig_obj_list = []

                    for fig_json in fig_list:

                        if isinstance(fig_json, str):

                            # Convert JSON string back to Figure object

                            try:

                                fig_obj = plotly.io.from_json(fig_json)

                                fig_obj_list.append(fig_obj)

                            except Exception as e:

                                logger.log_message(f"Error parsing Plotly JSON: {str(e)}", level=logging.WARNING)

                                continue

                        elif hasattr(fig_json, 'to_html'):

                            # Already a Figure object

                            fig_obj_list.append(fig_json)

                    figure_objects.append(fig_obj_list)

                else:

                    # Single figure case

                    if isinstance(fig_list, str):

                        try:

                            fig_obj = plotly.io.from_json(fig_list)

                            figure_objects.append(fig_obj)

                        except Exception as e:

                            logger.log_message(f"Error parsing Plotly JSON: {str(e)}", level=logging.WARNING)

                            continue

                    elif hasattr(fig_list, 'to_html'):

                        figure_objects.append(fig_list)

            

            processed_data['plotly_figs'] = figure_objects

        

        # Generate HTML report

        html_report = generate_html_report(processed_data)

        

        # Save report to database if we have a UUID

        if report_uuid:

            try:

                from src.db.init_db import session_factory

                from src.db.schemas.models import DeepAnalysisReport

                

                db_session = session_factory()

                try:

                    # Try to find existing report by UUID

                    report = db_session.query(DeepAnalysisReport).filter(DeepAnalysisReport.report_uuid == report_uuid).first()

                    

                    if report:

                        # Update existing report with HTML content

                        report.html_report = html_report

                        report.updated_at = datetime.now(UTC)

                        db_session.commit()

                except Exception as e:

                    db_session.rollback()

                finally:

                    db_session.close()

            except Exception as e:

                logger.log_message(f"Database operation failed when storing HTML report: {str(e)}", level=logging.ERROR)

                # Continue even if DB storage fails

        

        # Create a filename with timestamp

        timestamp = datetime.now(UTC).strftime("%Y%m%d_%H%M%S")

        filename = f"deep_analysis_report_{timestamp}.html"

        

        # Return as downloadable file

        return StreamingResponse(

            iter([html_report.encode('utf-8')]),

            media_type='text/html',

            headers={

                'Content-Disposition': f'attachment; filename="{filename}"',

                'Content-Type': 'text/html; charset=utf-8'

            }

        )

        

    except Exception as e:

        logger.log_message(f"Failed to generate HTML report: {str(e)}", level=logging.ERROR)

        raise HTTPException(status_code=500, detail=f"Failed to generate report: {str(e)}")





# In the section where routers are included, add the session_router

app.include_router(chat_router)

app.include_router(analytics_router)

app.include_router(code_router)

app.include_router(session_router)

app.include_router(feedback_router)

app.include_router(deep_analysis_router)

app.include_router(templates_router)

app.include_router(blog_router)



if __name__ == "__main__":

    port = int(os.environ.get("PORT", 8000))

    uvicorn.run(app, host="0.0.0.0", port=port)