# Path: sanskrit_parser/base/sanskrit_base.py
# class SanskritImmutableString(SanskritString):
#     """ Immutable version of SanskritString
#     """
#     def __init__(self, thing=None, encoding=None, unicode_encoding='utf-8'):
#         super().__init__(thing, encoding, unicode_encoding)
# 
#     def __hash__(self):
#         return hash(str(self))
# 
#     def __eq__(self, other):
#         return str(self) == str(other)
# 
#     def __ne__(self, other):
#         return str(self) != str(other)
# 
# SLP1 = sanscript.SLP1
# 
# Path: sanskrit_parser/generator/operations.py
# def adesha(a, f, t):
#     p = str(f).find(str(a))
#     if p != -1:
#         return str(t)[p]
#     else:
#         return a
# 
# Path: sanskrit_parser/generator/maheshvara.py
# def isInPratyahara(p, s):
# def isSavarna(p, s):


from sanskrit_parser.base.sanskrit_base import SanskritImmutableString, SLP1
from .operations import adesha
from .maheshvara import ms, isInPratyahara, isSavarna
from sanskrit_parser.generator.pratipadika import *  # noqa: F403
    return adi(s, "d")


def ekAcDAtu(s):
    ac_count = len([x for x in s if isInPratyahara("ac", x)])
    return ac_count == 1


def baSoBaz(s):
    for j in range(len(s)):
        if isInPratyahara("baS", s[j]):  # Backwards
            break
    return s[0:j]+adesha(s[j], "bgwd", "BGWD")+s[j+1:]


def druhAdi(ss):
    s = str(ss)
    return ((s == "druh") or (s == "muh") or (s == "snih") or (s == "snuh"))


def notnull(s):
    return ((s is not None) and (s != ""))


def null(s):
    return ((s is None) or (s == ""))


# sUtra: adeN guRaH
def is_guna(s: str):

# Path: sanskrit_parser/base/sanskrit_base.py
# class SanskritImmutableString(SanskritString):
#     """ Immutable version of SanskritString
#     """
#     def __init__(self, thing=None, encoding=None, unicode_encoding='utf-8'):
#         super().__init__(thing, encoding, unicode_encoding)
# 
#     def __hash__(self):
#         return hash(str(self))
# 
#     def __eq__(self, other):
#         return str(self) == str(other)
# 
#     def __ne__(self, other):
#         return str(self) != str(other)
# 
# SLP1 = sanscript.SLP1
# 
# Path: sanskrit_parser/generator/operations.py
# def adesha(a, f, t):
#     p = str(f).find(str(a))
#     if p != -1:
#         return str(t)[p]
#     else:
#         return a
# 
# Path: sanskrit_parser/generator/maheshvara.py
# def isInPratyahara(p, s):
# def isSavarna(p, s):


# Path: sanskrit_parser/generator/paribhasha.py
from sanskrit_parser.base.sanskrit_base import SanskritImmutableString, SLP1
from .operations import adesha
from .maheshvara import ms, isInPratyahara, isSavarna
from sanskrit_parser.generator.pratipadika import *  # noqa: F403

    return adi(s, "d")


def ekAcDAtu(s):
    ac_count = len([x for x in s if isInPratyahara("ac", x)])
    return ac_count == 1


def baSoBaz(s):
    for j in range(len(s)):
        if isInPratyahara("baS", s[j]):  # Backwards
            break
    return s[0:j]+adesha(s[j], "bgwd", "BGWD")+s[j+1:]


def druhAdi(ss):
    s = str(ss)
    return ((s == "druh") or (s == "muh") or (s == "snih") or (s == "snuh"))


def notnull(s):
    return ((s is not None) and (s != ""))


def null(s):
    return ((s is None) or (s == ""))


# sUtra: adeN guRaH
def is_guna(s: str):

    so = SanskritImmutableString(s, encoding=SLP1)