var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var metrics_exports = {};
__export(metrics_exports, {
  AggregationTemporality: () => AggregationTemporality,
  DataPointFlags: () => DataPointFlags,
  Exemplar: () => Exemplar,
  ExponentialHistogram: () => ExponentialHistogram,
  ExponentialHistogramDataPoint: () => ExponentialHistogramDataPoint,
  ExponentialHistogramDataPoint_Buckets: () => ExponentialHistogramDataPoint_Buckets,
  Gauge: () => Gauge,
  Histogram: () => Histogram,
  HistogramDataPoint: () => HistogramDataPoint,
  Metric: () => Metric,
  MetricsData: () => MetricsData,
  NumberDataPoint: () => NumberDataPoint,
  ResourceMetrics: () => ResourceMetrics,
  ScopeMetrics: () => ScopeMetrics,
  Sum: () => Sum,
  Summary: () => Summary,
  SummaryDataPoint: () => SummaryDataPoint,
  SummaryDataPoint_ValueAtQuantile: () => SummaryDataPoint_ValueAtQuantile,
  aggregationTemporalityFromJSON: () => aggregationTemporalityFromJSON,
  aggregationTemporalityToJSON: () => aggregationTemporalityToJSON,
  dataPointFlagsFromJSON: () => dataPointFlagsFromJSON,
  dataPointFlagsToJSON: () => dataPointFlagsToJSON,
  protobufPackage: () => protobufPackage
});
module.exports = __toCommonJS(metrics_exports);
var import_global_this = __toESM(require("@babel/runtime-corejs3/core-js/global-this"));
var import_map = __toESM(require("@babel/runtime-corejs3/core-js/instance/map"));
var import_bind = __toESM(require("@babel/runtime-corejs3/core-js/instance/bind"));
var import_flags = __toESM(require("@babel/runtime-corejs3/core-js/instance/flags"));
var import_for_each = __toESM(require("@babel/runtime-corejs3/core-js/instance/for-each"));
var import_long = __toESM(require("long"));
var import_minimal = __toESM(require("protobufjs/minimal.js"));
var import_common = require("../../common/v1/common.js");
var import_resource = require("../../resource/v1/resource.js");
const protobufPackage = "opentelemetry.proto.metrics.v1";
let AggregationTemporality = /* @__PURE__ */ function(AggregationTemporality2) {
  AggregationTemporality2[AggregationTemporality2["AGGREGATION_TEMPORALITY_UNSPECIFIED"] = 0] = "AGGREGATION_TEMPORALITY_UNSPECIFIED";
  AggregationTemporality2[AggregationTemporality2["AGGREGATION_TEMPORALITY_DELTA"] = 1] = "AGGREGATION_TEMPORALITY_DELTA";
  AggregationTemporality2[AggregationTemporality2["AGGREGATION_TEMPORALITY_CUMULATIVE"] = 2] = "AGGREGATION_TEMPORALITY_CUMULATIVE";
  AggregationTemporality2[AggregationTemporality2["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
  return AggregationTemporality2;
}({});
function aggregationTemporalityFromJSON(object) {
  switch (object) {
    case 0:
    case "AGGREGATION_TEMPORALITY_UNSPECIFIED":
      return AggregationTemporality.AGGREGATION_TEMPORALITY_UNSPECIFIED;
    case 1:
    case "AGGREGATION_TEMPORALITY_DELTA":
      return AggregationTemporality.AGGREGATION_TEMPORALITY_DELTA;
    case 2:
    case "AGGREGATION_TEMPORALITY_CUMULATIVE":
      return AggregationTemporality.AGGREGATION_TEMPORALITY_CUMULATIVE;
    case -1:
    case "UNRECOGNIZED":
    default:
      return AggregationTemporality.UNRECOGNIZED;
  }
}
function aggregationTemporalityToJSON(object) {
  switch (object) {
    case AggregationTemporality.AGGREGATION_TEMPORALITY_UNSPECIFIED:
      return "AGGREGATION_TEMPORALITY_UNSPECIFIED";
    case AggregationTemporality.AGGREGATION_TEMPORALITY_DELTA:
      return "AGGREGATION_TEMPORALITY_DELTA";
    case AggregationTemporality.AGGREGATION_TEMPORALITY_CUMULATIVE:
      return "AGGREGATION_TEMPORALITY_CUMULATIVE";
    case AggregationTemporality.UNRECOGNIZED:
    default:
      return "UNRECOGNIZED";
  }
}
let DataPointFlags = /* @__PURE__ */ function(DataPointFlags2) {
  DataPointFlags2[DataPointFlags2["DATA_POINT_FLAGS_DO_NOT_USE"] = 0] = "DATA_POINT_FLAGS_DO_NOT_USE";
  DataPointFlags2[DataPointFlags2["DATA_POINT_FLAGS_NO_RECORDED_VALUE_MASK"] = 1] = "DATA_POINT_FLAGS_NO_RECORDED_VALUE_MASK";
  DataPointFlags2[DataPointFlags2["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
  return DataPointFlags2;
}({});
function dataPointFlagsFromJSON(object) {
  switch (object) {
    case 0:
    case "DATA_POINT_FLAGS_DO_NOT_USE":
      return DataPointFlags.DATA_POINT_FLAGS_DO_NOT_USE;
    case 1:
    case "DATA_POINT_FLAGS_NO_RECORDED_VALUE_MASK":
      return DataPointFlags.DATA_POINT_FLAGS_NO_RECORDED_VALUE_MASK;
    case -1:
    case "UNRECOGNIZED":
    default:
      return DataPointFlags.UNRECOGNIZED;
  }
}
function dataPointFlagsToJSON(object) {
  switch (object) {
    case DataPointFlags.DATA_POINT_FLAGS_DO_NOT_USE:
      return "DATA_POINT_FLAGS_DO_NOT_USE";
    case DataPointFlags.DATA_POINT_FLAGS_NO_RECORDED_VALUE_MASK:
      return "DATA_POINT_FLAGS_NO_RECORDED_VALUE_MASK";
    case DataPointFlags.UNRECOGNIZED:
    default:
      return "UNRECOGNIZED";
  }
}
function createBaseMetricsData() {
  return {
    resourceMetrics: []
  };
}
const MetricsData = {
  encode(message, writer = import_minimal.default.Writer.create()) {
    for (const v of message.resourceMetrics) {
      ResourceMetrics.encode(v, writer.uint32(10).fork()).ldelim();
    }
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof import_minimal.default.Reader ? input : import_minimal.default.Reader.create(input);
    let end = length === void 0 ? reader.len : reader.pos + length;
    const message = createBaseMetricsData();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }
          message.resourceMetrics.push(ResourceMetrics.decode(reader, reader.uint32()));
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },
  fromJSON(object) {
    var _context;
    return {
      resourceMetrics: import_global_this.default.Array.isArray(object?.resourceMetrics) ? (0, import_map.default)(_context = object.resourceMetrics).call(_context, (e) => ResourceMetrics.fromJSON(e)) : []
    };
  },
  toJSON(message) {
    const obj = {};
    if (message.resourceMetrics?.length) {
      var _context2;
      obj.resourceMetrics = (0, import_map.default)(_context2 = message.resourceMetrics).call(_context2, (e) => ResourceMetrics.toJSON(e));
    }
    return obj;
  },
  create(base) {
    return MetricsData.fromPartial(base ?? {});
  },
  fromPartial(object) {
    var _context3, _context4;
    const message = createBaseMetricsData();
    message.resourceMetrics = ((_context3 = object.resourceMetrics) == null ? void 0 : (0, import_bind.default)(_context4 = Function.call).call(_context4, (0, import_map.default)(_context3), _context3))?.((e) => ResourceMetrics.fromPartial(e)) || [];
    return message;
  }
};
function createBaseResourceMetrics() {
  return {
    resource: void 0,
    scopeMetrics: [],
    schemaUrl: ""
  };
}
const ResourceMetrics = {
  encode(message, writer = import_minimal.default.Writer.create()) {
    if (message.resource !== void 0) {
      import_resource.Resource.encode(message.resource, writer.uint32(10).fork()).ldelim();
    }
    for (const v of message.scopeMetrics) {
      ScopeMetrics.encode(v, writer.uint32(18).fork()).ldelim();
    }
    if (message.schemaUrl !== "") {
      writer.uint32(26).string(message.schemaUrl);
    }
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof import_minimal.default.Reader ? input : import_minimal.default.Reader.create(input);
    let end = length === void 0 ? reader.len : reader.pos + length;
    const message = createBaseResourceMetrics();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }
          message.resource = import_resource.Resource.decode(reader, reader.uint32());
          continue;
        case 2:
          if (tag !== 18) {
            break;
          }
          message.scopeMetrics.push(ScopeMetrics.decode(reader, reader.uint32()));
          continue;
        case 3:
          if (tag !== 26) {
            break;
          }
          message.schemaUrl = reader.string();
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },
  fromJSON(object) {
    var _context5;
    return {
      resource: isSet(object.resource) ? import_resource.Resource.fromJSON(object.resource) : void 0,
      scopeMetrics: import_global_this.default.Array.isArray(object?.scopeMetrics) ? (0, import_map.default)(_context5 = object.scopeMetrics).call(_context5, (e) => ScopeMetrics.fromJSON(e)) : [],
      schemaUrl: isSet(object.schemaUrl) ? import_global_this.default.String(object.schemaUrl) : ""
    };
  },
  toJSON(message) {
    const obj = {};
    if (message.resource !== void 0) {
      obj.resource = import_resource.Resource.toJSON(message.resource);
    }
    if (message.scopeMetrics?.length) {
      var _context6;
      obj.scopeMetrics = (0, import_map.default)(_context6 = message.scopeMetrics).call(_context6, (e) => ScopeMetrics.toJSON(e));
    }
    if (message.schemaUrl !== "") {
      obj.schemaUrl = message.schemaUrl;
    }
    return obj;
  },
  create(base) {
    return ResourceMetrics.fromPartial(base ?? {});
  },
  fromPartial(object) {
    var _context7, _context8;
    const message = createBaseResourceMetrics();
    message.resource = object.resource !== void 0 && object.resource !== null ? import_resource.Resource.fromPartial(object.resource) : void 0;
    message.scopeMetrics = ((_context7 = object.scopeMetrics) == null ? void 0 : (0, import_bind.default)(_context8 = Function.call).call(_context8, (0, import_map.default)(_context7), _context7))?.((e) => ScopeMetrics.fromPartial(e)) || [];
    message.schemaUrl = object.schemaUrl ?? "";
    return message;
  }
};
function createBaseScopeMetrics() {
  return {
    scope: void 0,
    metrics: [],
    schemaUrl: ""
  };
}
const ScopeMetrics = {
  encode(message, writer = import_minimal.default.Writer.create()) {
    if (message.scope !== void 0) {
      import_common.InstrumentationScope.encode(message.scope, writer.uint32(10).fork()).ldelim();
    }
    for (const v of message.metrics) {
      Metric.encode(v, writer.uint32(18).fork()).ldelim();
    }
    if (message.schemaUrl !== "") {
      writer.uint32(26).string(message.schemaUrl);
    }
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof import_minimal.default.Reader ? input : import_minimal.default.Reader.create(input);
    let end = length === void 0 ? reader.len : reader.pos + length;
    const message = createBaseScopeMetrics();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }
          message.scope = import_common.InstrumentationScope.decode(reader, reader.uint32());
          continue;
        case 2:
          if (tag !== 18) {
            break;
          }
          message.metrics.push(Metric.decode(reader, reader.uint32()));
          continue;
        case 3:
          if (tag !== 26) {
            break;
          }
          message.schemaUrl = reader.string();
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },
  fromJSON(object) {
    var _context9;
    return {
      scope: isSet(object.scope) ? import_common.InstrumentationScope.fromJSON(object.scope) : void 0,
      metrics: import_global_this.default.Array.isArray(object?.metrics) ? (0, import_map.default)(_context9 = object.metrics).call(_context9, (e) => Metric.fromJSON(e)) : [],
      schemaUrl: isSet(object.schemaUrl) ? import_global_this.default.String(object.schemaUrl) : ""
    };
  },
  toJSON(message) {
    const obj = {};
    if (message.scope !== void 0) {
      obj.scope = import_common.InstrumentationScope.toJSON(message.scope);
    }
    if (message.metrics?.length) {
      var _context0;
      obj.metrics = (0, import_map.default)(_context0 = message.metrics).call(_context0, (e) => Metric.toJSON(e));
    }
    if (message.schemaUrl !== "") {
      obj.schemaUrl = message.schemaUrl;
    }
    return obj;
  },
  create(base) {
    return ScopeMetrics.fromPartial(base ?? {});
  },
  fromPartial(object) {
    var _context1, _context10;
    const message = createBaseScopeMetrics();
    message.scope = object.scope !== void 0 && object.scope !== null ? import_common.InstrumentationScope.fromPartial(object.scope) : void 0;
    message.metrics = ((_context1 = object.metrics) == null ? void 0 : (0, import_bind.default)(_context10 = Function.call).call(_context10, (0, import_map.default)(_context1), _context1))?.((e) => Metric.fromPartial(e)) || [];
    message.schemaUrl = object.schemaUrl ?? "";
    return message;
  }
};
function createBaseMetric() {
  return {
    name: "",
    description: "",
    unit: "",
    gauge: void 0,
    sum: void 0,
    histogram: void 0,
    exponentialHistogram: void 0,
    summary: void 0
  };
}
const Metric = {
  encode(message, writer = import_minimal.default.Writer.create()) {
    if (message.name !== "") {
      writer.uint32(10).string(message.name);
    }
    if (message.description !== "") {
      writer.uint32(18).string(message.description);
    }
    if (message.unit !== "") {
      writer.uint32(26).string(message.unit);
    }
    if (message.gauge !== void 0) {
      Gauge.encode(message.gauge, writer.uint32(42).fork()).ldelim();
    }
    if (message.sum !== void 0) {
      Sum.encode(message.sum, writer.uint32(58).fork()).ldelim();
    }
    if (message.histogram !== void 0) {
      Histogram.encode(message.histogram, writer.uint32(74).fork()).ldelim();
    }
    if (message.exponentialHistogram !== void 0) {
      ExponentialHistogram.encode(message.exponentialHistogram, writer.uint32(82).fork()).ldelim();
    }
    if (message.summary !== void 0) {
      Summary.encode(message.summary, writer.uint32(90).fork()).ldelim();
    }
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof import_minimal.default.Reader ? input : import_minimal.default.Reader.create(input);
    let end = length === void 0 ? reader.len : reader.pos + length;
    const message = createBaseMetric();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }
          message.name = reader.string();
          continue;
        case 2:
          if (tag !== 18) {
            break;
          }
          message.description = reader.string();
          continue;
        case 3:
          if (tag !== 26) {
            break;
          }
          message.unit = reader.string();
          continue;
        case 5:
          if (tag !== 42) {
            break;
          }
          message.gauge = Gauge.decode(reader, reader.uint32());
          continue;
        case 7:
          if (tag !== 58) {
            break;
          }
          message.sum = Sum.decode(reader, reader.uint32());
          continue;
        case 9:
          if (tag !== 74) {
            break;
          }
          message.histogram = Histogram.decode(reader, reader.uint32());
          continue;
        case 10:
          if (tag !== 82) {
            break;
          }
          message.exponentialHistogram = ExponentialHistogram.decode(reader, reader.uint32());
          continue;
        case 11:
          if (tag !== 90) {
            break;
          }
          message.summary = Summary.decode(reader, reader.uint32());
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },
  fromJSON(object) {
    return {
      name: isSet(object.name) ? import_global_this.default.String(object.name) : "",
      description: isSet(object.description) ? import_global_this.default.String(object.description) : "",
      unit: isSet(object.unit) ? import_global_this.default.String(object.unit) : "",
      gauge: isSet(object.gauge) ? Gauge.fromJSON(object.gauge) : void 0,
      sum: isSet(object.sum) ? Sum.fromJSON(object.sum) : void 0,
      histogram: isSet(object.histogram) ? Histogram.fromJSON(object.histogram) : void 0,
      exponentialHistogram: isSet(object.exponentialHistogram) ? ExponentialHistogram.fromJSON(object.exponentialHistogram) : void 0,
      summary: isSet(object.summary) ? Summary.fromJSON(object.summary) : void 0
    };
  },
  toJSON(message) {
    const obj = {};
    if (message.name !== "") {
      obj.name = message.name;
    }
    if (message.description !== "") {
      obj.description = message.description;
    }
    if (message.unit !== "") {
      obj.unit = message.unit;
    }
    if (message.gauge !== void 0) {
      obj.gauge = Gauge.toJSON(message.gauge);
    }
    if (message.sum !== void 0) {
      obj.sum = Sum.toJSON(message.sum);
    }
    if (message.histogram !== void 0) {
      obj.histogram = Histogram.toJSON(message.histogram);
    }
    if (message.exponentialHistogram !== void 0) {
      obj.exponentialHistogram = ExponentialHistogram.toJSON(message.exponentialHistogram);
    }
    if (message.summary !== void 0) {
      obj.summary = Summary.toJSON(message.summary);
    }
    return obj;
  },
  create(base) {
    return Metric.fromPartial(base ?? {});
  },
  fromPartial(object) {
    const message = createBaseMetric();
    message.name = object.name ?? "";
    message.description = object.description ?? "";
    message.unit = object.unit ?? "";
    message.gauge = object.gauge !== void 0 && object.gauge !== null ? Gauge.fromPartial(object.gauge) : void 0;
    message.sum = object.sum !== void 0 && object.sum !== null ? Sum.fromPartial(object.sum) : void 0;
    message.histogram = object.histogram !== void 0 && object.histogram !== null ? Histogram.fromPartial(object.histogram) : void 0;
    message.exponentialHistogram = object.exponentialHistogram !== void 0 && object.exponentialHistogram !== null ? ExponentialHistogram.fromPartial(object.exponentialHistogram) : void 0;
    message.summary = object.summary !== void 0 && object.summary !== null ? Summary.fromPartial(object.summary) : void 0;
    return message;
  }
};
function createBaseGauge() {
  return {
    dataPoints: []
  };
}
const Gauge = {
  encode(message, writer = import_minimal.default.Writer.create()) {
    for (const v of message.dataPoints) {
      NumberDataPoint.encode(v, writer.uint32(10).fork()).ldelim();
    }
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof import_minimal.default.Reader ? input : import_minimal.default.Reader.create(input);
    let end = length === void 0 ? reader.len : reader.pos + length;
    const message = createBaseGauge();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }
          message.dataPoints.push(NumberDataPoint.decode(reader, reader.uint32()));
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },
  fromJSON(object) {
    var _context11;
    return {
      dataPoints: import_global_this.default.Array.isArray(object?.dataPoints) ? (0, import_map.default)(_context11 = object.dataPoints).call(_context11, (e) => NumberDataPoint.fromJSON(e)) : []
    };
  },
  toJSON(message) {
    const obj = {};
    if (message.dataPoints?.length) {
      var _context12;
      obj.dataPoints = (0, import_map.default)(_context12 = message.dataPoints).call(_context12, (e) => NumberDataPoint.toJSON(e));
    }
    return obj;
  },
  create(base) {
    return Gauge.fromPartial(base ?? {});
  },
  fromPartial(object) {
    var _context13, _context14;
    const message = createBaseGauge();
    message.dataPoints = ((_context13 = object.dataPoints) == null ? void 0 : (0, import_bind.default)(_context14 = Function.call).call(_context14, (0, import_map.default)(_context13), _context13))?.((e) => NumberDataPoint.fromPartial(e)) || [];
    return message;
  }
};
function createBaseSum() {
  return {
    dataPoints: [],
    aggregationTemporality: 0,
    isMonotonic: false
  };
}
const Sum = {
  encode(message, writer = import_minimal.default.Writer.create()) {
    for (const v of message.dataPoints) {
      NumberDataPoint.encode(v, writer.uint32(10).fork()).ldelim();
    }
    if (message.aggregationTemporality !== 0) {
      writer.uint32(16).int32(message.aggregationTemporality);
    }
    if (message.isMonotonic === true) {
      writer.uint32(24).bool(message.isMonotonic);
    }
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof import_minimal.default.Reader ? input : import_minimal.default.Reader.create(input);
    let end = length === void 0 ? reader.len : reader.pos + length;
    const message = createBaseSum();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }
          message.dataPoints.push(NumberDataPoint.decode(reader, reader.uint32()));
          continue;
        case 2:
          if (tag !== 16) {
            break;
          }
          message.aggregationTemporality = reader.int32();
          continue;
        case 3:
          if (tag !== 24) {
            break;
          }
          message.isMonotonic = reader.bool();
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },
  fromJSON(object) {
    var _context15;
    return {
      dataPoints: import_global_this.default.Array.isArray(object?.dataPoints) ? (0, import_map.default)(_context15 = object.dataPoints).call(_context15, (e) => NumberDataPoint.fromJSON(e)) : [],
      aggregationTemporality: isSet(object.aggregationTemporality) ? aggregationTemporalityFromJSON(object.aggregationTemporality) : 0,
      isMonotonic: isSet(object.isMonotonic) ? import_global_this.default.Boolean(object.isMonotonic) : false
    };
  },
  toJSON(message) {
    const obj = {};
    if (message.dataPoints?.length) {
      var _context16;
      obj.dataPoints = (0, import_map.default)(_context16 = message.dataPoints).call(_context16, (e) => NumberDataPoint.toJSON(e));
    }
    if (message.aggregationTemporality !== 0) {
      obj.aggregationTemporality = aggregationTemporalityToJSON(message.aggregationTemporality);
    }
    if (message.isMonotonic === true) {
      obj.isMonotonic = message.isMonotonic;
    }
    return obj;
  },
  create(base) {
    return Sum.fromPartial(base ?? {});
  },
  fromPartial(object) {
    var _context17, _context18;
    const message = createBaseSum();
    message.dataPoints = ((_context17 = object.dataPoints) == null ? void 0 : (0, import_bind.default)(_context18 = Function.call).call(_context18, (0, import_map.default)(_context17), _context17))?.((e) => NumberDataPoint.fromPartial(e)) || [];
    message.aggregationTemporality = object.aggregationTemporality ?? 0;
    message.isMonotonic = object.isMonotonic ?? false;
    return message;
  }
};
function createBaseHistogram() {
  return {
    dataPoints: [],
    aggregationTemporality: 0
  };
}
const Histogram = {
  encode(message, writer = import_minimal.default.Writer.create()) {
    for (const v of message.dataPoints) {
      HistogramDataPoint.encode(v, writer.uint32(10).fork()).ldelim();
    }
    if (message.aggregationTemporality !== 0) {
      writer.uint32(16).int32(message.aggregationTemporality);
    }
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof import_minimal.default.Reader ? input : import_minimal.default.Reader.create(input);
    let end = length === void 0 ? reader.len : reader.pos + length;
    const message = createBaseHistogram();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }
          message.dataPoints.push(HistogramDataPoint.decode(reader, reader.uint32()));
          continue;
        case 2:
          if (tag !== 16) {
            break;
          }
          message.aggregationTemporality = reader.int32();
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },
  fromJSON(object) {
    var _context19;
    return {
      dataPoints: import_global_this.default.Array.isArray(object?.dataPoints) ? (0, import_map.default)(_context19 = object.dataPoints).call(_context19, (e) => HistogramDataPoint.fromJSON(e)) : [],
      aggregationTemporality: isSet(object.aggregationTemporality) ? aggregationTemporalityFromJSON(object.aggregationTemporality) : 0
    };
  },
  toJSON(message) {
    const obj = {};
    if (message.dataPoints?.length) {
      var _context20;
      obj.dataPoints = (0, import_map.default)(_context20 = message.dataPoints).call(_context20, (e) => HistogramDataPoint.toJSON(e));
    }
    if (message.aggregationTemporality !== 0) {
      obj.aggregationTemporality = aggregationTemporalityToJSON(message.aggregationTemporality);
    }
    return obj;
  },
  create(base) {
    return Histogram.fromPartial(base ?? {});
  },
  fromPartial(object) {
    var _context21, _context22;
    const message = createBaseHistogram();
    message.dataPoints = ((_context21 = object.dataPoints) == null ? void 0 : (0, import_bind.default)(_context22 = Function.call).call(_context22, (0, import_map.default)(_context21), _context21))?.((e) => HistogramDataPoint.fromPartial(e)) || [];
    message.aggregationTemporality = object.aggregationTemporality ?? 0;
    return message;
  }
};
function createBaseExponentialHistogram() {
  return {
    dataPoints: [],
    aggregationTemporality: 0
  };
}
const ExponentialHistogram = {
  encode(message, writer = import_minimal.default.Writer.create()) {
    for (const v of message.dataPoints) {
      ExponentialHistogramDataPoint.encode(v, writer.uint32(10).fork()).ldelim();
    }
    if (message.aggregationTemporality !== 0) {
      writer.uint32(16).int32(message.aggregationTemporality);
    }
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof import_minimal.default.Reader ? input : import_minimal.default.Reader.create(input);
    let end = length === void 0 ? reader.len : reader.pos + length;
    const message = createBaseExponentialHistogram();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }
          message.dataPoints.push(ExponentialHistogramDataPoint.decode(reader, reader.uint32()));
          continue;
        case 2:
          if (tag !== 16) {
            break;
          }
          message.aggregationTemporality = reader.int32();
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },
  fromJSON(object) {
    var _context23;
    return {
      dataPoints: import_global_this.default.Array.isArray(object?.dataPoints) ? (0, import_map.default)(_context23 = object.dataPoints).call(_context23, (e) => ExponentialHistogramDataPoint.fromJSON(e)) : [],
      aggregationTemporality: isSet(object.aggregationTemporality) ? aggregationTemporalityFromJSON(object.aggregationTemporality) : 0
    };
  },
  toJSON(message) {
    const obj = {};
    if (message.dataPoints?.length) {
      var _context24;
      obj.dataPoints = (0, import_map.default)(_context24 = message.dataPoints).call(_context24, (e) => ExponentialHistogramDataPoint.toJSON(e));
    }
    if (message.aggregationTemporality !== 0) {
      obj.aggregationTemporality = aggregationTemporalityToJSON(message.aggregationTemporality);
    }
    return obj;
  },
  create(base) {
    return ExponentialHistogram.fromPartial(base ?? {});
  },
  fromPartial(object) {
    var _context25, _context26;
    const message = createBaseExponentialHistogram();
    message.dataPoints = ((_context25 = object.dataPoints) == null ? void 0 : (0, import_bind.default)(_context26 = Function.call).call(_context26, (0, import_map.default)(_context25), _context25))?.((e) => ExponentialHistogramDataPoint.fromPartial(e)) || [];
    message.aggregationTemporality = object.aggregationTemporality ?? 0;
    return message;
  }
};
function createBaseSummary() {
  return {
    dataPoints: []
  };
}
const Summary = {
  encode(message, writer = import_minimal.default.Writer.create()) {
    for (const v of message.dataPoints) {
      SummaryDataPoint.encode(v, writer.uint32(10).fork()).ldelim();
    }
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof import_minimal.default.Reader ? input : import_minimal.default.Reader.create(input);
    let end = length === void 0 ? reader.len : reader.pos + length;
    const message = createBaseSummary();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }
          message.dataPoints.push(SummaryDataPoint.decode(reader, reader.uint32()));
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },
  fromJSON(object) {
    var _context27;
    return {
      dataPoints: import_global_this.default.Array.isArray(object?.dataPoints) ? (0, import_map.default)(_context27 = object.dataPoints).call(_context27, (e) => SummaryDataPoint.fromJSON(e)) : []
    };
  },
  toJSON(message) {
    const obj = {};
    if (message.dataPoints?.length) {
      var _context28;
      obj.dataPoints = (0, import_map.default)(_context28 = message.dataPoints).call(_context28, (e) => SummaryDataPoint.toJSON(e));
    }
    return obj;
  },
  create(base) {
    return Summary.fromPartial(base ?? {});
  },
  fromPartial(object) {
    var _context29, _context30;
    const message = createBaseSummary();
    message.dataPoints = ((_context29 = object.dataPoints) == null ? void 0 : (0, import_bind.default)(_context30 = Function.call).call(_context30, (0, import_map.default)(_context29), _context29))?.((e) => SummaryDataPoint.fromPartial(e)) || [];
    return message;
  }
};
function createBaseNumberDataPoint() {
  return {
    attributes: [],
    startTimeUnixNano: 0,
    timeUnixNano: 0,
    asDouble: void 0,
    asInt: void 0,
    exemplars: [],
    flags: 0
  };
}
const NumberDataPoint = {
  encode(message, writer = import_minimal.default.Writer.create()) {
    for (const v of message.attributes) {
      import_common.KeyValue.encode(v, writer.uint32(58).fork()).ldelim();
    }
    if (message.startTimeUnixNano !== 0) {
      writer.uint32(17).fixed64(message.startTimeUnixNano);
    }
    if (message.timeUnixNano !== 0) {
      writer.uint32(25).fixed64(message.timeUnixNano);
    }
    if (message.asDouble !== void 0) {
      writer.uint32(33).double(message.asDouble);
    }
    if (message.asInt !== void 0) {
      writer.uint32(49).sfixed64(message.asInt);
    }
    for (const v of message.exemplars) {
      Exemplar.encode(v, writer.uint32(42).fork()).ldelim();
    }
    if ((0, import_flags.default)(message) !== 0) {
      writer.uint32(64).uint32((0, import_flags.default)(message));
    }
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof import_minimal.default.Reader ? input : import_minimal.default.Reader.create(input);
    let end = length === void 0 ? reader.len : reader.pos + length;
    const message = createBaseNumberDataPoint();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 7:
          if (tag !== 58) {
            break;
          }
          message.attributes.push(import_common.KeyValue.decode(reader, reader.uint32()));
          continue;
        case 2:
          if (tag !== 17) {
            break;
          }
          message.startTimeUnixNano = longToNumber(reader.fixed64());
          continue;
        case 3:
          if (tag !== 25) {
            break;
          }
          message.timeUnixNano = longToNumber(reader.fixed64());
          continue;
        case 4:
          if (tag !== 33) {
            break;
          }
          message.asDouble = reader.double();
          continue;
        case 6:
          if (tag !== 49) {
            break;
          }
          message.asInt = longToNumber(reader.sfixed64());
          continue;
        case 5:
          if (tag !== 42) {
            break;
          }
          message.exemplars.push(Exemplar.decode(reader, reader.uint32()));
          continue;
        case 8:
          if (tag !== 64) {
            break;
          }
          message.flags = reader.uint32();
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },
  fromJSON(object) {
    var _context31, _context32;
    return {
      attributes: import_global_this.default.Array.isArray(object?.attributes) ? (0, import_map.default)(_context31 = object.attributes).call(_context31, (e) => import_common.KeyValue.fromJSON(e)) : [],
      startTimeUnixNano: isSet(object.startTimeUnixNano) ? import_global_this.default.Number(object.startTimeUnixNano) : 0,
      timeUnixNano: isSet(object.timeUnixNano) ? import_global_this.default.Number(object.timeUnixNano) : 0,
      asDouble: isSet(object.asDouble) ? import_global_this.default.Number(object.asDouble) : void 0,
      asInt: isSet(object.asInt) ? import_global_this.default.Number(object.asInt) : void 0,
      exemplars: import_global_this.default.Array.isArray(object?.exemplars) ? (0, import_map.default)(_context32 = object.exemplars).call(_context32, (e) => Exemplar.fromJSON(e)) : [],
      flags: isSet((0, import_flags.default)(object)) ? import_global_this.default.Number((0, import_flags.default)(object)) : 0
    };
  },
  toJSON(message) {
    const obj = {};
    if (message.attributes?.length) {
      var _context33;
      obj.attributes = (0, import_map.default)(_context33 = message.attributes).call(_context33, (e) => import_common.KeyValue.toJSON(e));
    }
    if (message.startTimeUnixNano !== 0) {
      obj.startTimeUnixNano = Math.round(message.startTimeUnixNano);
    }
    if (message.timeUnixNano !== 0) {
      obj.timeUnixNano = Math.round(message.timeUnixNano);
    }
    if (message.asDouble !== void 0) {
      obj.asDouble = message.asDouble;
    }
    if (message.asInt !== void 0) {
      obj.asInt = Math.round(message.asInt);
    }
    if (message.exemplars?.length) {
      var _context34;
      obj.exemplars = (0, import_map.default)(_context34 = message.exemplars).call(_context34, (e) => Exemplar.toJSON(e));
    }
    if ((0, import_flags.default)(message) !== 0) {
      obj.flags = Math.round((0, import_flags.default)(message));
    }
    return obj;
  },
  create(base) {
    return NumberDataPoint.fromPartial(base ?? {});
  },
  fromPartial(object) {
    var _context35, _context36, _context37, _context38;
    const message = createBaseNumberDataPoint();
    message.attributes = ((_context35 = object.attributes) == null ? void 0 : (0, import_bind.default)(_context36 = Function.call).call(_context36, (0, import_map.default)(_context35), _context35))?.((e) => import_common.KeyValue.fromPartial(e)) || [];
    message.startTimeUnixNano = object.startTimeUnixNano ?? 0;
    message.timeUnixNano = object.timeUnixNano ?? 0;
    message.asDouble = object.asDouble ?? void 0;
    message.asInt = object.asInt ?? void 0;
    message.exemplars = ((_context37 = object.exemplars) == null ? void 0 : (0, import_bind.default)(_context38 = Function.call).call(_context38, (0, import_map.default)(_context37), _context37))?.((e) => Exemplar.fromPartial(e)) || [];
    message.flags = (0, import_flags.default)(object) ?? 0;
    return message;
  }
};
function createBaseHistogramDataPoint() {
  return {
    attributes: [],
    startTimeUnixNano: 0,
    timeUnixNano: 0,
    count: 0,
    sum: void 0,
    bucketCounts: [],
    explicitBounds: [],
    exemplars: [],
    flags: 0,
    min: void 0,
    max: void 0
  };
}
const HistogramDataPoint = {
  encode(message, writer = import_minimal.default.Writer.create()) {
    for (const v of message.attributes) {
      import_common.KeyValue.encode(v, writer.uint32(74).fork()).ldelim();
    }
    if (message.startTimeUnixNano !== 0) {
      writer.uint32(17).fixed64(message.startTimeUnixNano);
    }
    if (message.timeUnixNano !== 0) {
      writer.uint32(25).fixed64(message.timeUnixNano);
    }
    if (message.count !== 0) {
      writer.uint32(33).fixed64(message.count);
    }
    if (message.sum !== void 0) {
      writer.uint32(41).double(message.sum);
    }
    writer.uint32(50).fork();
    for (const v of message.bucketCounts) {
      writer.fixed64(v);
    }
    writer.ldelim();
    writer.uint32(58).fork();
    for (const v of message.explicitBounds) {
      writer.double(v);
    }
    writer.ldelim();
    for (const v of message.exemplars) {
      Exemplar.encode(v, writer.uint32(66).fork()).ldelim();
    }
    if ((0, import_flags.default)(message) !== 0) {
      writer.uint32(80).uint32((0, import_flags.default)(message));
    }
    if (message.min !== void 0) {
      writer.uint32(89).double(message.min);
    }
    if (message.max !== void 0) {
      writer.uint32(97).double(message.max);
    }
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof import_minimal.default.Reader ? input : import_minimal.default.Reader.create(input);
    let end = length === void 0 ? reader.len : reader.pos + length;
    const message = createBaseHistogramDataPoint();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 9:
          if (tag !== 74) {
            break;
          }
          message.attributes.push(import_common.KeyValue.decode(reader, reader.uint32()));
          continue;
        case 2:
          if (tag !== 17) {
            break;
          }
          message.startTimeUnixNano = longToNumber(reader.fixed64());
          continue;
        case 3:
          if (tag !== 25) {
            break;
          }
          message.timeUnixNano = longToNumber(reader.fixed64());
          continue;
        case 4:
          if (tag !== 33) {
            break;
          }
          message.count = longToNumber(reader.fixed64());
          continue;
        case 5:
          if (tag !== 41) {
            break;
          }
          message.sum = reader.double();
          continue;
        case 6:
          if (tag === 49) {
            message.bucketCounts.push(longToNumber(reader.fixed64()));
            continue;
          }
          if (tag === 50) {
            const end2 = reader.uint32() + reader.pos;
            while (reader.pos < end2) {
              message.bucketCounts.push(longToNumber(reader.fixed64()));
            }
            continue;
          }
          break;
        case 7:
          if (tag === 57) {
            message.explicitBounds.push(reader.double());
            continue;
          }
          if (tag === 58) {
            const end2 = reader.uint32() + reader.pos;
            while (reader.pos < end2) {
              message.explicitBounds.push(reader.double());
            }
            continue;
          }
          break;
        case 8:
          if (tag !== 66) {
            break;
          }
          message.exemplars.push(Exemplar.decode(reader, reader.uint32()));
          continue;
        case 10:
          if (tag !== 80) {
            break;
          }
          message.flags = reader.uint32();
          continue;
        case 11:
          if (tag !== 89) {
            break;
          }
          message.min = reader.double();
          continue;
        case 12:
          if (tag !== 97) {
            break;
          }
          message.max = reader.double();
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },
  fromJSON(object) {
    var _context39, _context40, _context41, _context42;
    return {
      attributes: import_global_this.default.Array.isArray(object?.attributes) ? (0, import_map.default)(_context39 = object.attributes).call(_context39, (e) => import_common.KeyValue.fromJSON(e)) : [],
      startTimeUnixNano: isSet(object.startTimeUnixNano) ? import_global_this.default.Number(object.startTimeUnixNano) : 0,
      timeUnixNano: isSet(object.timeUnixNano) ? import_global_this.default.Number(object.timeUnixNano) : 0,
      count: isSet(object.count) ? import_global_this.default.Number(object.count) : 0,
      sum: isSet(object.sum) ? import_global_this.default.Number(object.sum) : void 0,
      bucketCounts: import_global_this.default.Array.isArray(object?.bucketCounts) ? (0, import_map.default)(_context40 = object.bucketCounts).call(_context40, (e) => import_global_this.default.Number(e)) : [],
      explicitBounds: import_global_this.default.Array.isArray(object?.explicitBounds) ? (0, import_map.default)(_context41 = object.explicitBounds).call(_context41, (e) => import_global_this.default.Number(e)) : [],
      exemplars: import_global_this.default.Array.isArray(object?.exemplars) ? (0, import_map.default)(_context42 = object.exemplars).call(_context42, (e) => Exemplar.fromJSON(e)) : [],
      flags: isSet((0, import_flags.default)(object)) ? import_global_this.default.Number((0, import_flags.default)(object)) : 0,
      min: isSet(object.min) ? import_global_this.default.Number(object.min) : void 0,
      max: isSet(object.max) ? import_global_this.default.Number(object.max) : void 0
    };
  },
  toJSON(message) {
    const obj = {};
    if (message.attributes?.length) {
      var _context43;
      obj.attributes = (0, import_map.default)(_context43 = message.attributes).call(_context43, (e) => import_common.KeyValue.toJSON(e));
    }
    if (message.startTimeUnixNano !== 0) {
      obj.startTimeUnixNano = Math.round(message.startTimeUnixNano);
    }
    if (message.timeUnixNano !== 0) {
      obj.timeUnixNano = Math.round(message.timeUnixNano);
    }
    if (message.count !== 0) {
      obj.count = Math.round(message.count);
    }
    if (message.sum !== void 0) {
      obj.sum = message.sum;
    }
    if (message.bucketCounts?.length) {
      var _context44;
      obj.bucketCounts = (0, import_map.default)(_context44 = message.bucketCounts).call(_context44, (e) => Math.round(e));
    }
    if (message.explicitBounds?.length) {
      obj.explicitBounds = message.explicitBounds;
    }
    if (message.exemplars?.length) {
      var _context45;
      obj.exemplars = (0, import_map.default)(_context45 = message.exemplars).call(_context45, (e) => Exemplar.toJSON(e));
    }
    if ((0, import_flags.default)(message) !== 0) {
      obj.flags = Math.round((0, import_flags.default)(message));
    }
    if (message.min !== void 0) {
      obj.min = message.min;
    }
    if (message.max !== void 0) {
      obj.max = message.max;
    }
    return obj;
  },
  create(base) {
    return HistogramDataPoint.fromPartial(base ?? {});
  },
  fromPartial(object) {
    var _context46, _context47, _context48, _context49, _context50, _context51, _context52, _context53;
    const message = createBaseHistogramDataPoint();
    message.attributes = ((_context46 = object.attributes) == null ? void 0 : (0, import_bind.default)(_context47 = Function.call).call(_context47, (0, import_map.default)(_context46), _context46))?.((e) => import_common.KeyValue.fromPartial(e)) || [];
    message.startTimeUnixNano = object.startTimeUnixNano ?? 0;
    message.timeUnixNano = object.timeUnixNano ?? 0;
    message.count = object.count ?? 0;
    message.sum = object.sum ?? void 0;
    message.bucketCounts = ((_context48 = object.bucketCounts) == null ? void 0 : (0, import_bind.default)(_context49 = Function.call).call(_context49, (0, import_map.default)(_context48), _context48))?.((e) => e) || [];
    message.explicitBounds = ((_context50 = object.explicitBounds) == null ? void 0 : (0, import_bind.default)(_context51 = Function.call).call(_context51, (0, import_map.default)(_context50), _context50))?.((e) => e) || [];
    message.exemplars = ((_context52 = object.exemplars) == null ? void 0 : (0, import_bind.default)(_context53 = Function.call).call(_context53, (0, import_map.default)(_context52), _context52))?.((e) => Exemplar.fromPartial(e)) || [];
    message.flags = (0, import_flags.default)(object) ?? 0;
    message.min = object.min ?? void 0;
    message.max = object.max ?? void 0;
    return message;
  }
};
function createBaseExponentialHistogramDataPoint() {
  return {
    attributes: [],
    startTimeUnixNano: 0,
    timeUnixNano: 0,
    count: 0,
    sum: void 0,
    scale: 0,
    zeroCount: 0,
    positive: void 0,
    negative: void 0,
    flags: 0,
    exemplars: [],
    min: void 0,
    max: void 0,
    zeroThreshold: 0
  };
}
const ExponentialHistogramDataPoint = {
  encode(message, writer = import_minimal.default.Writer.create()) {
    for (const v of message.attributes) {
      import_common.KeyValue.encode(v, writer.uint32(10).fork()).ldelim();
    }
    if (message.startTimeUnixNano !== 0) {
      writer.uint32(17).fixed64(message.startTimeUnixNano);
    }
    if (message.timeUnixNano !== 0) {
      writer.uint32(25).fixed64(message.timeUnixNano);
    }
    if (message.count !== 0) {
      writer.uint32(33).fixed64(message.count);
    }
    if (message.sum !== void 0) {
      writer.uint32(41).double(message.sum);
    }
    if (message.scale !== 0) {
      writer.uint32(48).sint32(message.scale);
    }
    if (message.zeroCount !== 0) {
      writer.uint32(57).fixed64(message.zeroCount);
    }
    if (message.positive !== void 0) {
      ExponentialHistogramDataPoint_Buckets.encode(message.positive, writer.uint32(66).fork()).ldelim();
    }
    if (message.negative !== void 0) {
      ExponentialHistogramDataPoint_Buckets.encode(message.negative, writer.uint32(74).fork()).ldelim();
    }
    if ((0, import_flags.default)(message) !== 0) {
      writer.uint32(80).uint32((0, import_flags.default)(message));
    }
    for (const v of message.exemplars) {
      Exemplar.encode(v, writer.uint32(90).fork()).ldelim();
    }
    if (message.min !== void 0) {
      writer.uint32(97).double(message.min);
    }
    if (message.max !== void 0) {
      writer.uint32(105).double(message.max);
    }
    if (message.zeroThreshold !== 0) {
      writer.uint32(113).double(message.zeroThreshold);
    }
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof import_minimal.default.Reader ? input : import_minimal.default.Reader.create(input);
    let end = length === void 0 ? reader.len : reader.pos + length;
    const message = createBaseExponentialHistogramDataPoint();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }
          message.attributes.push(import_common.KeyValue.decode(reader, reader.uint32()));
          continue;
        case 2:
          if (tag !== 17) {
            break;
          }
          message.startTimeUnixNano = longToNumber(reader.fixed64());
          continue;
        case 3:
          if (tag !== 25) {
            break;
          }
          message.timeUnixNano = longToNumber(reader.fixed64());
          continue;
        case 4:
          if (tag !== 33) {
            break;
          }
          message.count = longToNumber(reader.fixed64());
          continue;
        case 5:
          if (tag !== 41) {
            break;
          }
          message.sum = reader.double();
          continue;
        case 6:
          if (tag !== 48) {
            break;
          }
          message.scale = reader.sint32();
          continue;
        case 7:
          if (tag !== 57) {
            break;
          }
          message.zeroCount = longToNumber(reader.fixed64());
          continue;
        case 8:
          if (tag !== 66) {
            break;
          }
          message.positive = ExponentialHistogramDataPoint_Buckets.decode(reader, reader.uint32());
          continue;
        case 9:
          if (tag !== 74) {
            break;
          }
          message.negative = ExponentialHistogramDataPoint_Buckets.decode(reader, reader.uint32());
          continue;
        case 10:
          if (tag !== 80) {
            break;
          }
          message.flags = reader.uint32();
          continue;
        case 11:
          if (tag !== 90) {
            break;
          }
          message.exemplars.push(Exemplar.decode(reader, reader.uint32()));
          continue;
        case 12:
          if (tag !== 97) {
            break;
          }
          message.min = reader.double();
          continue;
        case 13:
          if (tag !== 105) {
            break;
          }
          message.max = reader.double();
          continue;
        case 14:
          if (tag !== 113) {
            break;
          }
          message.zeroThreshold = reader.double();
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },
  fromJSON(object) {
    var _context54, _context55;
    return {
      attributes: import_global_this.default.Array.isArray(object?.attributes) ? (0, import_map.default)(_context54 = object.attributes).call(_context54, (e) => import_common.KeyValue.fromJSON(e)) : [],
      startTimeUnixNano: isSet(object.startTimeUnixNano) ? import_global_this.default.Number(object.startTimeUnixNano) : 0,
      timeUnixNano: isSet(object.timeUnixNano) ? import_global_this.default.Number(object.timeUnixNano) : 0,
      count: isSet(object.count) ? import_global_this.default.Number(object.count) : 0,
      sum: isSet(object.sum) ? import_global_this.default.Number(object.sum) : void 0,
      scale: isSet(object.scale) ? import_global_this.default.Number(object.scale) : 0,
      zeroCount: isSet(object.zeroCount) ? import_global_this.default.Number(object.zeroCount) : 0,
      positive: isSet(object.positive) ? ExponentialHistogramDataPoint_Buckets.fromJSON(object.positive) : void 0,
      negative: isSet(object.negative) ? ExponentialHistogramDataPoint_Buckets.fromJSON(object.negative) : void 0,
      flags: isSet((0, import_flags.default)(object)) ? import_global_this.default.Number((0, import_flags.default)(object)) : 0,
      exemplars: import_global_this.default.Array.isArray(object?.exemplars) ? (0, import_map.default)(_context55 = object.exemplars).call(_context55, (e) => Exemplar.fromJSON(e)) : [],
      min: isSet(object.min) ? import_global_this.default.Number(object.min) : void 0,
      max: isSet(object.max) ? import_global_this.default.Number(object.max) : void 0,
      zeroThreshold: isSet(object.zeroThreshold) ? import_global_this.default.Number(object.zeroThreshold) : 0
    };
  },
  toJSON(message) {
    const obj = {};
    if (message.attributes?.length) {
      var _context56;
      obj.attributes = (0, import_map.default)(_context56 = message.attributes).call(_context56, (e) => import_common.KeyValue.toJSON(e));
    }
    if (message.startTimeUnixNano !== 0) {
      obj.startTimeUnixNano = Math.round(message.startTimeUnixNano);
    }
    if (message.timeUnixNano !== 0) {
      obj.timeUnixNano = Math.round(message.timeUnixNano);
    }
    if (message.count !== 0) {
      obj.count = Math.round(message.count);
    }
    if (message.sum !== void 0) {
      obj.sum = message.sum;
    }
    if (message.scale !== 0) {
      obj.scale = Math.round(message.scale);
    }
    if (message.zeroCount !== 0) {
      obj.zeroCount = Math.round(message.zeroCount);
    }
    if (message.positive !== void 0) {
      obj.positive = ExponentialHistogramDataPoint_Buckets.toJSON(message.positive);
    }
    if (message.negative !== void 0) {
      obj.negative = ExponentialHistogramDataPoint_Buckets.toJSON(message.negative);
    }
    if ((0, import_flags.default)(message) !== 0) {
      obj.flags = Math.round((0, import_flags.default)(message));
    }
    if (message.exemplars?.length) {
      var _context57;
      obj.exemplars = (0, import_map.default)(_context57 = message.exemplars).call(_context57, (e) => Exemplar.toJSON(e));
    }
    if (message.min !== void 0) {
      obj.min = message.min;
    }
    if (message.max !== void 0) {
      obj.max = message.max;
    }
    if (message.zeroThreshold !== 0) {
      obj.zeroThreshold = message.zeroThreshold;
    }
    return obj;
  },
  create(base) {
    return ExponentialHistogramDataPoint.fromPartial(base ?? {});
  },
  fromPartial(object) {
    var _context58, _context59, _context60, _context61;
    const message = createBaseExponentialHistogramDataPoint();
    message.attributes = ((_context58 = object.attributes) == null ? void 0 : (0, import_bind.default)(_context59 = Function.call).call(_context59, (0, import_map.default)(_context58), _context58))?.((e) => import_common.KeyValue.fromPartial(e)) || [];
    message.startTimeUnixNano = object.startTimeUnixNano ?? 0;
    message.timeUnixNano = object.timeUnixNano ?? 0;
    message.count = object.count ?? 0;
    message.sum = object.sum ?? void 0;
    message.scale = object.scale ?? 0;
    message.zeroCount = object.zeroCount ?? 0;
    message.positive = object.positive !== void 0 && object.positive !== null ? ExponentialHistogramDataPoint_Buckets.fromPartial(object.positive) : void 0;
    message.negative = object.negative !== void 0 && object.negative !== null ? ExponentialHistogramDataPoint_Buckets.fromPartial(object.negative) : void 0;
    message.flags = (0, import_flags.default)(object) ?? 0;
    message.exemplars = ((_context60 = object.exemplars) == null ? void 0 : (0, import_bind.default)(_context61 = Function.call).call(_context61, (0, import_map.default)(_context60), _context60))?.((e) => Exemplar.fromPartial(e)) || [];
    message.min = object.min ?? void 0;
    message.max = object.max ?? void 0;
    message.zeroThreshold = object.zeroThreshold ?? 0;
    return message;
  }
};
function createBaseExponentialHistogramDataPoint_Buckets() {
  return {
    offset: 0,
    bucketCounts: []
  };
}
const ExponentialHistogramDataPoint_Buckets = {
  encode(message, writer = import_minimal.default.Writer.create()) {
    if (message.offset !== 0) {
      writer.uint32(8).sint32(message.offset);
    }
    writer.uint32(18).fork();
    for (const v of message.bucketCounts) {
      writer.uint64(v);
    }
    writer.ldelim();
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof import_minimal.default.Reader ? input : import_minimal.default.Reader.create(input);
    let end = length === void 0 ? reader.len : reader.pos + length;
    const message = createBaseExponentialHistogramDataPoint_Buckets();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 8) {
            break;
          }
          message.offset = reader.sint32();
          continue;
        case 2:
          if (tag === 16) {
            message.bucketCounts.push(longToNumber(reader.uint64()));
            continue;
          }
          if (tag === 18) {
            const end2 = reader.uint32() + reader.pos;
            while (reader.pos < end2) {
              message.bucketCounts.push(longToNumber(reader.uint64()));
            }
            continue;
          }
          break;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },
  fromJSON(object) {
    var _context62;
    return {
      offset: isSet(object.offset) ? import_global_this.default.Number(object.offset) : 0,
      bucketCounts: import_global_this.default.Array.isArray(object?.bucketCounts) ? (0, import_map.default)(_context62 = object.bucketCounts).call(_context62, (e) => import_global_this.default.Number(e)) : []
    };
  },
  toJSON(message) {
    const obj = {};
    if (message.offset !== 0) {
      obj.offset = Math.round(message.offset);
    }
    if (message.bucketCounts?.length) {
      var _context63;
      obj.bucketCounts = (0, import_map.default)(_context63 = message.bucketCounts).call(_context63, (e) => Math.round(e));
    }
    return obj;
  },
  create(base) {
    return ExponentialHistogramDataPoint_Buckets.fromPartial(base ?? {});
  },
  fromPartial(object) {
    var _context64, _context65;
    const message = createBaseExponentialHistogramDataPoint_Buckets();
    message.offset = object.offset ?? 0;
    message.bucketCounts = ((_context64 = object.bucketCounts) == null ? void 0 : (0, import_bind.default)(_context65 = Function.call).call(_context65, (0, import_map.default)(_context64), _context64))?.((e) => e) || [];
    return message;
  }
};
function createBaseSummaryDataPoint() {
  return {
    attributes: [],
    startTimeUnixNano: 0,
    timeUnixNano: 0,
    count: 0,
    sum: 0,
    quantileValues: [],
    flags: 0
  };
}
const SummaryDataPoint = {
  encode(message, writer = import_minimal.default.Writer.create()) {
    for (const v of message.attributes) {
      import_common.KeyValue.encode(v, writer.uint32(58).fork()).ldelim();
    }
    if (message.startTimeUnixNano !== 0) {
      writer.uint32(17).fixed64(message.startTimeUnixNano);
    }
    if (message.timeUnixNano !== 0) {
      writer.uint32(25).fixed64(message.timeUnixNano);
    }
    if (message.count !== 0) {
      writer.uint32(33).fixed64(message.count);
    }
    if (message.sum !== 0) {
      writer.uint32(41).double(message.sum);
    }
    for (const v of message.quantileValues) {
      SummaryDataPoint_ValueAtQuantile.encode(v, writer.uint32(50).fork()).ldelim();
    }
    if ((0, import_flags.default)(message) !== 0) {
      writer.uint32(64).uint32((0, import_flags.default)(message));
    }
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof import_minimal.default.Reader ? input : import_minimal.default.Reader.create(input);
    let end = length === void 0 ? reader.len : reader.pos + length;
    const message = createBaseSummaryDataPoint();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 7:
          if (tag !== 58) {
            break;
          }
          message.attributes.push(import_common.KeyValue.decode(reader, reader.uint32()));
          continue;
        case 2:
          if (tag !== 17) {
            break;
          }
          message.startTimeUnixNano = longToNumber(reader.fixed64());
          continue;
        case 3:
          if (tag !== 25) {
            break;
          }
          message.timeUnixNano = longToNumber(reader.fixed64());
          continue;
        case 4:
          if (tag !== 33) {
            break;
          }
          message.count = longToNumber(reader.fixed64());
          continue;
        case 5:
          if (tag !== 41) {
            break;
          }
          message.sum = reader.double();
          continue;
        case 6:
          if (tag !== 50) {
            break;
          }
          message.quantileValues.push(SummaryDataPoint_ValueAtQuantile.decode(reader, reader.uint32()));
          continue;
        case 8:
          if (tag !== 64) {
            break;
          }
          message.flags = reader.uint32();
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },
  fromJSON(object) {
    var _context66, _context67;
    return {
      attributes: import_global_this.default.Array.isArray(object?.attributes) ? (0, import_map.default)(_context66 = object.attributes).call(_context66, (e) => import_common.KeyValue.fromJSON(e)) : [],
      startTimeUnixNano: isSet(object.startTimeUnixNano) ? import_global_this.default.Number(object.startTimeUnixNano) : 0,
      timeUnixNano: isSet(object.timeUnixNano) ? import_global_this.default.Number(object.timeUnixNano) : 0,
      count: isSet(object.count) ? import_global_this.default.Number(object.count) : 0,
      sum: isSet(object.sum) ? import_global_this.default.Number(object.sum) : 0,
      quantileValues: import_global_this.default.Array.isArray(object?.quantileValues) ? (0, import_map.default)(_context67 = object.quantileValues).call(_context67, (e) => SummaryDataPoint_ValueAtQuantile.fromJSON(e)) : [],
      flags: isSet((0, import_flags.default)(object)) ? import_global_this.default.Number((0, import_flags.default)(object)) : 0
    };
  },
  toJSON(message) {
    const obj = {};
    if (message.attributes?.length) {
      var _context68;
      obj.attributes = (0, import_map.default)(_context68 = message.attributes).call(_context68, (e) => import_common.KeyValue.toJSON(e));
    }
    if (message.startTimeUnixNano !== 0) {
      obj.startTimeUnixNano = Math.round(message.startTimeUnixNano);
    }
    if (message.timeUnixNano !== 0) {
      obj.timeUnixNano = Math.round(message.timeUnixNano);
    }
    if (message.count !== 0) {
      obj.count = Math.round(message.count);
    }
    if (message.sum !== 0) {
      obj.sum = message.sum;
    }
    if (message.quantileValues?.length) {
      var _context69;
      obj.quantileValues = (0, import_map.default)(_context69 = message.quantileValues).call(_context69, (e) => SummaryDataPoint_ValueAtQuantile.toJSON(e));
    }
    if ((0, import_flags.default)(message) !== 0) {
      obj.flags = Math.round((0, import_flags.default)(message));
    }
    return obj;
  },
  create(base) {
    return SummaryDataPoint.fromPartial(base ?? {});
  },
  fromPartial(object) {
    var _context70, _context71, _context72, _context73;
    const message = createBaseSummaryDataPoint();
    message.attributes = ((_context70 = object.attributes) == null ? void 0 : (0, import_bind.default)(_context71 = Function.call).call(_context71, (0, import_map.default)(_context70), _context70))?.((e) => import_common.KeyValue.fromPartial(e)) || [];
    message.startTimeUnixNano = object.startTimeUnixNano ?? 0;
    message.timeUnixNano = object.timeUnixNano ?? 0;
    message.count = object.count ?? 0;
    message.sum = object.sum ?? 0;
    message.quantileValues = ((_context72 = object.quantileValues) == null ? void 0 : (0, import_bind.default)(_context73 = Function.call).call(_context73, (0, import_map.default)(_context72), _context72))?.((e) => SummaryDataPoint_ValueAtQuantile.fromPartial(e)) || [];
    message.flags = (0, import_flags.default)(object) ?? 0;
    return message;
  }
};
function createBaseSummaryDataPoint_ValueAtQuantile() {
  return {
    quantile: 0,
    value: 0
  };
}
const SummaryDataPoint_ValueAtQuantile = {
  encode(message, writer = import_minimal.default.Writer.create()) {
    if (message.quantile !== 0) {
      writer.uint32(9).double(message.quantile);
    }
    if (message.value !== 0) {
      writer.uint32(17).double(message.value);
    }
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof import_minimal.default.Reader ? input : import_minimal.default.Reader.create(input);
    let end = length === void 0 ? reader.len : reader.pos + length;
    const message = createBaseSummaryDataPoint_ValueAtQuantile();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 9) {
            break;
          }
          message.quantile = reader.double();
          continue;
        case 2:
          if (tag !== 17) {
            break;
          }
          message.value = reader.double();
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },
  fromJSON(object) {
    return {
      quantile: isSet(object.quantile) ? import_global_this.default.Number(object.quantile) : 0,
      value: isSet(object.value) ? import_global_this.default.Number(object.value) : 0
    };
  },
  toJSON(message) {
    const obj = {};
    if (message.quantile !== 0) {
      obj.quantile = message.quantile;
    }
    if (message.value !== 0) {
      obj.value = message.value;
    }
    return obj;
  },
  create(base) {
    return SummaryDataPoint_ValueAtQuantile.fromPartial(base ?? {});
  },
  fromPartial(object) {
    const message = createBaseSummaryDataPoint_ValueAtQuantile();
    message.quantile = object.quantile ?? 0;
    message.value = object.value ?? 0;
    return message;
  }
};
function createBaseExemplar() {
  return {
    filteredAttributes: [],
    timeUnixNano: 0,
    asDouble: void 0,
    asInt: void 0,
    spanId: new Uint8Array(0),
    traceId: new Uint8Array(0)
  };
}
const Exemplar = {
  encode(message, writer = import_minimal.default.Writer.create()) {
    for (const v of message.filteredAttributes) {
      import_common.KeyValue.encode(v, writer.uint32(58).fork()).ldelim();
    }
    if (message.timeUnixNano !== 0) {
      writer.uint32(17).fixed64(message.timeUnixNano);
    }
    if (message.asDouble !== void 0) {
      writer.uint32(25).double(message.asDouble);
    }
    if (message.asInt !== void 0) {
      writer.uint32(49).sfixed64(message.asInt);
    }
    if (message.spanId.length !== 0) {
      writer.uint32(34).bytes(message.spanId);
    }
    if (message.traceId.length !== 0) {
      writer.uint32(42).bytes(message.traceId);
    }
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof import_minimal.default.Reader ? input : import_minimal.default.Reader.create(input);
    let end = length === void 0 ? reader.len : reader.pos + length;
    const message = createBaseExemplar();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 7:
          if (tag !== 58) {
            break;
          }
          message.filteredAttributes.push(import_common.KeyValue.decode(reader, reader.uint32()));
          continue;
        case 2:
          if (tag !== 17) {
            break;
          }
          message.timeUnixNano = longToNumber(reader.fixed64());
          continue;
        case 3:
          if (tag !== 25) {
            break;
          }
          message.asDouble = reader.double();
          continue;
        case 6:
          if (tag !== 49) {
            break;
          }
          message.asInt = longToNumber(reader.sfixed64());
          continue;
        case 4:
          if (tag !== 34) {
            break;
          }
          message.spanId = reader.bytes();
          continue;
        case 5:
          if (tag !== 42) {
            break;
          }
          message.traceId = reader.bytes();
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },
  fromJSON(object) {
    var _context74;
    return {
      filteredAttributes: import_global_this.default.Array.isArray(object?.filteredAttributes) ? (0, import_map.default)(_context74 = object.filteredAttributes).call(_context74, (e) => import_common.KeyValue.fromJSON(e)) : [],
      timeUnixNano: isSet(object.timeUnixNano) ? import_global_this.default.Number(object.timeUnixNano) : 0,
      asDouble: isSet(object.asDouble) ? import_global_this.default.Number(object.asDouble) : void 0,
      asInt: isSet(object.asInt) ? import_global_this.default.Number(object.asInt) : void 0,
      spanId: isSet(object.spanId) ? bytesFromBase64(object.spanId) : new Uint8Array(0),
      traceId: isSet(object.traceId) ? bytesFromBase64(object.traceId) : new Uint8Array(0)
    };
  },
  toJSON(message) {
    const obj = {};
    if (message.filteredAttributes?.length) {
      var _context75;
      obj.filteredAttributes = (0, import_map.default)(_context75 = message.filteredAttributes).call(_context75, (e) => import_common.KeyValue.toJSON(e));
    }
    if (message.timeUnixNano !== 0) {
      obj.timeUnixNano = Math.round(message.timeUnixNano);
    }
    if (message.asDouble !== void 0) {
      obj.asDouble = message.asDouble;
    }
    if (message.asInt !== void 0) {
      obj.asInt = Math.round(message.asInt);
    }
    if (message.spanId.length !== 0) {
      obj.spanId = base64FromBytes(message.spanId);
    }
    if (message.traceId.length !== 0) {
      obj.traceId = base64FromBytes(message.traceId);
    }
    return obj;
  },
  create(base) {
    return Exemplar.fromPartial(base ?? {});
  },
  fromPartial(object) {
    var _context76, _context77;
    const message = createBaseExemplar();
    message.filteredAttributes = ((_context76 = object.filteredAttributes) == null ? void 0 : (0, import_bind.default)(_context77 = Function.call).call(_context77, (0, import_map.default)(_context76), _context76))?.((e) => import_common.KeyValue.fromPartial(e)) || [];
    message.timeUnixNano = object.timeUnixNano ?? 0;
    message.asDouble = object.asDouble ?? void 0;
    message.asInt = object.asInt ?? void 0;
    message.spanId = object.spanId ?? new Uint8Array(0);
    message.traceId = object.traceId ?? new Uint8Array(0);
    return message;
  }
};
function bytesFromBase64(b64) {
  if (import_global_this.default.Buffer) {
    return Uint8Array.from(import_global_this.default.Buffer.from(b64, "base64"));
  } else {
    const bin = import_global_this.default.atob(b64);
    const arr = new Uint8Array(bin.length);
    for (let i = 0; i < bin.length; ++i) {
      arr[i] = bin.charCodeAt(i);
    }
    return arr;
  }
}
function base64FromBytes(arr) {
  if (import_global_this.default.Buffer) {
    return import_global_this.default.Buffer.from(arr).toString("base64");
  } else {
    const bin = [];
    (0, import_for_each.default)(arr).call(arr, (byte) => {
      bin.push(import_global_this.default.String.fromCharCode(byte));
    });
    return import_global_this.default.btoa(bin.join(""));
  }
}
function longToNumber(long) {
  if (long.gt(import_global_this.default.Number.MAX_SAFE_INTEGER)) {
    throw new import_global_this.default.Error("Value is larger than Number.MAX_SAFE_INTEGER");
  }
  return long.toNumber();
}
if (import_minimal.default.util.Long !== import_long.default) {
  import_minimal.default.util.Long = import_long.default;
  import_minimal.default.configure();
}
function isSet(value) {
  return value !== null && value !== void 0;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  AggregationTemporality,
  DataPointFlags,
  Exemplar,
  ExponentialHistogram,
  ExponentialHistogramDataPoint,
  ExponentialHistogramDataPoint_Buckets,
  Gauge,
  Histogram,
  HistogramDataPoint,
  Metric,
  MetricsData,
  NumberDataPoint,
  ResourceMetrics,
  ScopeMetrics,
  Sum,
  Summary,
  SummaryDataPoint,
  SummaryDataPoint_ValueAtQuantile,
  aggregationTemporalityFromJSON,
  aggregationTemporalityToJSON,
  dataPointFlagsFromJSON,
  dataPointFlagsToJSON,
  protobufPackage
});
//# sourceMappingURL=metrics.js.map
