# Path: pandasdmx/model.py
# PACKAGE = dict()
# 
# class MaintainableArtefact(VersionableArtefact):
#     #: True if the object is final; otherwise it is in a draft state.
#     is_final: Optional[bool] = None
#     #: :obj:`True` if the content of the object is held externally; i.e., not
#     #: the current :class:`Message`.
#     is_external_reference: Optional[bool] = None
#     #: URL of an SDMX-compliant web service from which the object can be
#     #: retrieved.
#     service_url: Optional[str] = None
#     #: URL of an SDMX-ML document containing the object.
#     structure_url: Optional[str] = None
#     #: Association to the Agency responsible for maintaining the object.
#     maintainer: Optional["Agency"] = None
# 
#     def __init__(self, **kwargs):
#         super().__init__(**kwargs)
#         try:
#             if self.maintainer and self.maintainer.id != self.urn_group["agency"]:
#                 raise ValueError(
#                     f"Maintainer {self.maintainer} does not match URN {self.urn}"
#                 )
#             else:
#                 self.maintainer = Agency(id=self.urn_group["agency"])
#         except KeyError:
#             pass
# 
#     def compare(self, other, strict=True):
#         """Return :obj:`True` if `self` is the same as `other`.
# 
#         Two MaintainableArtefacts are the same if:
# 
#         - :meth:`.VersionableArtefact.compare` is :obj:`True`, and
#         - they have the same :attr:`maintainer`.
# 
#         Parameters
#         ----------
#         strict : bool, optional
#             Passed to :func:`.compare` and :meth:`.VersionableArtefact.compare`.
#         """
#         return super().compare(other, strict) and compare(
#             "maintainer", self, other, strict
#         )
# 
#     def _repr_kw(self):
#         return ChainMap(
#             super()._repr_kw(),
#             dict(maint=f"{self.maintainer}:" if self.maintainer else ""),
#         )
# 
#     def __repr__(self):
#         return "<{cls} {maint}{id}{version}{name}>".format(**self._repr_kw())


import re
from typing import Dict
from pandasdmx.model import PACKAGE, MaintainableArtefact


# Regular expression for URNs
URN = re.compile(
    r"urn:sdmx:org\.sdmx\.infomodel"
    r"\.(?P<package>[^\.]*)"
    r"\.(?P<class>[^=]*)=((?P<agency>[^:]*):)?"
    r"(?P<id>[^\(\.]*)(\((?P<version>[\d\.]*)\))?"
    r"(\.(?P<item_id>.*))?"
)

_BASE = (
    "urn:sdmx:org.sdmx.infomodel.{package}.{obj.__class__.__name__}="
    "{ma.maintainer.id}:{ma.id}({ma.version}){extra_id}"
)


def make(obj, maintainable_parent=None, strict=False):
    """Create an SDMX URN for `obj`.

    If `obj` is not :class:`.MaintainableArtefact`, then `maintainable_parent`
    must be supplied in order to construct the URN.
    """

# Path: pandasdmx/model.py
# PACKAGE = dict()
# 
# class MaintainableArtefact(VersionableArtefact):
#     #: True if the object is final; otherwise it is in a draft state.
#     is_final: Optional[bool] = None
#     #: :obj:`True` if the content of the object is held externally; i.e., not
#     #: the current :class:`Message`.
#     is_external_reference: Optional[bool] = None
#     #: URL of an SDMX-compliant web service from which the object can be
#     #: retrieved.
#     service_url: Optional[str] = None
#     #: URL of an SDMX-ML document containing the object.
#     structure_url: Optional[str] = None
#     #: Association to the Agency responsible for maintaining the object.
#     maintainer: Optional["Agency"] = None
# 
#     def __init__(self, **kwargs):
#         super().__init__(**kwargs)
#         try:
#             if self.maintainer and self.maintainer.id != self.urn_group["agency"]:
#                 raise ValueError(
#                     f"Maintainer {self.maintainer} does not match URN {self.urn}"
#                 )
#             else:
#                 self.maintainer = Agency(id=self.urn_group["agency"])
#         except KeyError:
#             pass
# 
#     def compare(self, other, strict=True):
#         """Return :obj:`True` if `self` is the same as `other`.
# 
#         Two MaintainableArtefacts are the same if:
# 
#         - :meth:`.VersionableArtefact.compare` is :obj:`True`, and
#         - they have the same :attr:`maintainer`.
# 
#         Parameters
#         ----------
#         strict : bool, optional
#             Passed to :func:`.compare` and :meth:`.VersionableArtefact.compare`.
#         """
#         return super().compare(other, strict) and compare(
#             "maintainer", self, other, strict
#         )
# 
#     def _repr_kw(self):
#         return ChainMap(
#             super()._repr_kw(),
#             dict(maint=f"{self.maintainer}:" if self.maintainer else ""),
#         )
# 
#     def __repr__(self):
#         return "<{cls} {maint}{id}{version}{name}>".format(**self._repr_kw())


# Path: pandasdmx/urn.py
import re
from typing import Dict
from pandasdmx.model import PACKAGE, MaintainableArtefact



# Regular expression for URNs
URN = re.compile(
    r"urn:sdmx:org\.sdmx\.infomodel"
    r"\.(?P<package>[^\.]*)"
    r"\.(?P<class>[^=]*)=((?P<agency>[^:]*):)?"
    r"(?P<id>[^\(\.]*)(\((?P<version>[\d\.]*)\))?"
    r"(\.(?P<item_id>.*))?"
)

_BASE = (
    "urn:sdmx:org.sdmx.infomodel.{package}.{obj.__class__.__name__}="
    "{ma.maintainer.id}:{ma.id}({ma.version}){extra_id}"
)


def make(obj, maintainable_parent=None, strict=False):
    """Create an SDMX URN for `obj`.

    If `obj` is not :class:`.MaintainableArtefact`, then `maintainable_parent`
    must be supplied in order to construct the URN.
    """

    if not isinstance(obj, MaintainableArtefact):