'''
Created on 12-Jul-2021

@author: rishi_priyansh
'''
import inspect
import traceback
import random

from sympy import (latex, Symbol, UnevaluatedExpr as ueval,
                   )
import sympy as sp
from xv.km.util import SympyUnitSystem

# _base_circuit_helper
# BaseCircuitHelper

from xv.util import UtilClass

class BaseCircuitHelper(UtilClass):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self._ss = SympyUnitSystem(verbose = self.verbose)
        
        self._kwargs = kwargs
        
        self._gauss_law_helper = None
        self._lcr_circuit_helper = None
        self._vr_circuit_helper = None
        self._r_circuit_helper = None
        self._vc_circuit_helper = None
        self._c_circuit_helper = None
        pass

    def _convert_d_to_svg_str(self, d):
        image_bytes = d.get_imagedata('svg')
        svg_str = image_bytes.decode('ascii', 'ignore')
        
        from xv.km.ui import SvgHelper  
        svg_helper = SvgHelper(verbose = self.verbose)
        svg_str = svg_helper.remove_unwanted_defs(svg_str)
        return svg_str


    def get_lcr_circuit_helper(self):
        if self._lcr_circuit_helper is None:
            self._init_lcr_circuit_helper(**self._kwargs)
        return self._lcr_circuit_helper
        pass

    def _init_lcr_circuit_helper(self, **kwargs):  
        from ._lcr_circuit_helper import LcrCircuitHelper
        self._lcr_circuit_helper = LcrCircuitHelper(verbose = self.verbose)
        pass
    
    def get_vr_circuit_helper(self):
        if self._vr_circuit_helper is None:
            self._init_vr_circuit_helper(**self._kwargs)
        return self._vr_circuit_helper
        pass

    def _init_vr_circuit_helper(self, **kwargs):  
        from ._vr_circuit_helper import VrCircuitHelper
        self._vr_circuit_helper = VrCircuitHelper(verbose = self.verbose)
        pass

    def get_r_circuit_helper(self):
        if self._r_circuit_helper is None:
            self._init_r_circuit_helper(**self._kwargs)
        return self._r_circuit_helper
        pass

    def _init_r_circuit_helper(self, **kwargs):  
        from ._r_circuit_helper import RCircuitHelper
        self._r_circuit_helper = RCircuitHelper(verbose = self.verbose)
        pass

    def get_vc_circuit_helper(self):
        if self._vc_circuit_helper is None:
            self._init_vc_circuit_helper(**self._kwargs)
        return self._vc_circuit_helper
        pass

    def _init_vc_circuit_helper(self, **kwargs):  
        from ._vc_circuit_helper import VcCircuitHelper
        self._vc_circuit_helper = VcCircuitHelper(verbose = self.verbose)
        pass

    def get_c_circuit_helper(self):
        if self._c_circuit_helper is None:
            self._init_c_circuit_helper(**self._kwargs)
        return self._c_circuit_helper
        pass

    def _init_c_circuit_helper(self, **kwargs):  
        from ._c_circuit_helper import CCircuitHelper
        self._c_circuit_helper = CCircuitHelper(verbose = self.verbose)
        pass

    pass
#class BaseCircuitHelper:

    