'''
Created on 14-Oct-2024
@author: bthakur
'''

import random
import inspect
import traceback


from xv.km.util import latex_fraction

        
from ..helper import BaseHelper
from xv.km.managers import BaseManager
from xv.km.kelements import KProblemTemplate

from xv.km.util import KmTemplateUtil



# _trigonometry_manager
# TrigonometryManager
        
        
class TrigonometryManager(BaseManager):
    '''
    TrigonometryManager



    Examples
    --------
    ke = TrigonometryManager()
    ke 
    
    ke.printProblemTypes()
    ke.helpProblemType(0)
    
    ke.getRandomProblem()
    ke.getRandomProblem(problem_type = 0)


    ke.printAnswer()
    ke.printSolution()
    

    doc_style: xv_doc
    ''' 

    
    
    def __new__(cls, *args, **kwargs):
        instance = super(TrigonometryManager, cls).__new__(cls, *args, **kwargs)
        for base_class in TrigonometryManager.__bases__:
            base_class.__init__(instance, *args, **kwargs)
        return instance
    
    def __init__(self, *args, **kwargs):
        self.base_helper = BaseHelper(**kwargs)
        pass
    

    def _init_problem_types(self, *args, **kwargs):
        self._append_problem_types([
            '_problem_euler_number_manager',
            '_problem_trig_identity_manager',
            ])
        pass


    def _problem_euler_number_manager(self, *args, **kwargs):
        """
        @generate_notebook: Default True

        doc_style: xv_doc
        """

        sInfo = f"""Processing {self.__class__.__name__}.{inspect.stack()[0][3]}: 
        creating notebook and getting problem from EulerNumberManager
        """
        self._log(sInfo.strip())
        
        
        #create notebook
        generate_notebook = kwargs.get('generate_notebook', True)
        
        if generate_notebook:
            saveToFolder = f"trigonometry"
            KmTemplateUtil.CREATE_MANAGER_NOTEBOOK("xv.math.trigonometry", 
                                                   "EulerNumberManager", 
                                                   saveToFolder = saveToFolder,
                                                   overwrite = False, 
                                                   verbose = self.verbose)

        #get a problem        
        from ._euler_number_manager import EulerNumberManager
        kwargs['manager_class'] = EulerNumberManager
        kwargs['problem_type'] = None
        kwargs['generate_notebook'] = False
        problemTemplate = self._get_problem_from_a_manager(*args, **kwargs)
        return problemTemplate

        pass


    def _problem_trig_identity_manager(self, *args, **kwargs):
        """
        @generate_notebook: Default True

        doc_style: xv_doc
        """

        sInfo = f"""Processing {self.__class__.__name__}.{inspect.stack()[0][3]}: 
        creating notebook and getting problem from TrigIdentityManager
        """
        self._log(sInfo.strip())
        
        
        #create notebook
        generate_notebook = kwargs.get('generate_notebook', True)
        
        if generate_notebook:
            saveToFolder = f"trigonometry"
            KmTemplateUtil.CREATE_MANAGER_NOTEBOOK("xv.math.trigonometry", 
                                                   "TrigIdentityManager", 
                                                   saveToFolder = saveToFolder,
                                                   overwrite = False, 
                                                   verbose = self.verbose)

        #get a problem        
        from ._trig_identity_manager import TrigIdentityManager
        kwargs['manager_class'] = TrigIdentityManager
        kwargs['problem_type'] = None
        kwargs['generate_notebook'] = False
        problemTemplate = self._get_problem_from_a_manager(*args, **kwargs)
        return problemTemplate

        pass

