{"version":3,"sources":["systemOfUnits.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,qBAAa,aAAc,YAAW,cAAc,CAAC,aAAa,CAAC;IACjE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC;IAC9B,QAAQ,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC;IAChC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAE/B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAgD;IAC9E,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CACiB;gBAGjD,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,UAAU,EAAE,EACpB,YAAY,CAAC,EAAE,MAAM,EACrB,YAAY,CAAC,EAAE,MAAM,EAAE;IAQzB,MAAM,CAAC,KAAK,CAAC,EAAE,aAAa,GAAG,OAAO;IAI/B,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO;IAIhC,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO;CAgBvC","file":"systemOfUnits.d.ts","sourcesContent":["import { SupportsEquals } from \"./baseTypes.js\";\nimport { LangString } from \"./langString.js\";\nimport { Unit } from \"./unit.js\";\nimport { QudtNamespaces } from \"./qudtNamespaces.js\";\n\nexport class SystemOfUnits implements SupportsEquals<SystemOfUnits> {\n  readonly iri: string;\n  readonly labels: LangString[];\n  readonly baseUnitIris: string[];\n  readonly abbreviation?: string;\n\n  private static readonly GM_iri = QudtNamespaces.unit.makeIriInNamespace(\"GM\");\n  private static readonly KiloGM_iri =\n    QudtNamespaces.unit.makeIriInNamespace(\"KiloGM\");\n\n  constructor(\n    iri: string,\n    labels: LangString[],\n    abbreviation?: string,\n    baseUnitIris?: string[]\n  ) {\n    this.iri = iri;\n    this.labels = labels;\n    this.baseUnitIris = baseUnitIris || [];\n    this.abbreviation = abbreviation;\n  }\n\n  equals(other?: SystemOfUnits): boolean {\n    return !!other && this.iri === other.iri;\n  }\n\n  public hasBaseUnit(unit: Unit): boolean {\n    return this.baseUnitIris.includes(unit.iri);\n  }\n\n  public allowsUnit(unit: Unit): boolean {\n    if (this.hasBaseUnit(unit)) {\n      return true;\n    }\n    if (unit.unitOfSystemIris.includes(this.iri)) {\n      return true;\n    }\n    if (unit.iri === SystemOfUnits.GM_iri) {\n      // we use gram as the base unit, but SI uses KiloGM, so if we fail for GM, try KiloGM\n      return this.baseUnitIris.includes(SystemOfUnits.KiloGM_iri);\n    }\n    if (unit.scalingOf && unit.prefix) {\n      return this.allowsUnit(unit.scalingOf);\n    }\n    return false;\n  }\n}\n"]}