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 common_exports = {};
__export(common_exports, {
  AnyValue: () => AnyValue,
  ArrayValue: () => ArrayValue,
  InstrumentationScope: () => InstrumentationScope,
  KeyValue: () => KeyValue,
  KeyValueList: () => KeyValueList,
  protobufPackage: () => protobufPackage
});
module.exports = __toCommonJS(common_exports);
var import_global_this = __toESM(require("@babel/runtime-corejs3/core-js/global-this"));
var import_values = __toESM(require("@babel/runtime-corejs3/core-js/instance/values"));
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_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"));
const protobufPackage = "opentelemetry.proto.common.v1";
function createBaseAnyValue() {
  return {
    stringValue: void 0,
    boolValue: void 0,
    intValue: void 0,
    doubleValue: void 0,
    arrayValue: void 0,
    kvlistValue: void 0,
    bytesValue: void 0
  };
}
const AnyValue = {
  encode(message, writer = import_minimal.default.Writer.create()) {
    if (message.stringValue !== void 0) {
      writer.uint32(10).string(message.stringValue);
    }
    if (message.boolValue !== void 0) {
      writer.uint32(16).bool(message.boolValue);
    }
    if (message.intValue !== void 0) {
      writer.uint32(24).int64(message.intValue);
    }
    if (message.doubleValue !== void 0) {
      writer.uint32(33).double(message.doubleValue);
    }
    if (message.arrayValue !== void 0) {
      ArrayValue.encode(message.arrayValue, writer.uint32(42).fork()).ldelim();
    }
    if (message.kvlistValue !== void 0) {
      KeyValueList.encode(message.kvlistValue, writer.uint32(50).fork()).ldelim();
    }
    if (message.bytesValue !== void 0) {
      writer.uint32(58).bytes(message.bytesValue);
    }
    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 = createBaseAnyValue();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }
          message.stringValue = reader.string();
          continue;
        case 2:
          if (tag !== 16) {
            break;
          }
          message.boolValue = reader.bool();
          continue;
        case 3:
          if (tag !== 24) {
            break;
          }
          message.intValue = longToNumber(reader.int64());
          continue;
        case 4:
          if (tag !== 33) {
            break;
          }
          message.doubleValue = reader.double();
          continue;
        case 5:
          if (tag !== 42) {
            break;
          }
          message.arrayValue = ArrayValue.decode(reader, reader.uint32());
          continue;
        case 6:
          if (tag !== 50) {
            break;
          }
          message.kvlistValue = KeyValueList.decode(reader, reader.uint32());
          continue;
        case 7:
          if (tag !== 58) {
            break;
          }
          message.bytesValue = reader.bytes();
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },
  fromJSON(object) {
    return {
      stringValue: isSet(object.stringValue) ? import_global_this.default.String(object.stringValue) : void 0,
      boolValue: isSet(object.boolValue) ? import_global_this.default.Boolean(object.boolValue) : void 0,
      intValue: isSet(object.intValue) ? import_global_this.default.Number(object.intValue) : void 0,
      doubleValue: isSet(object.doubleValue) ? import_global_this.default.Number(object.doubleValue) : void 0,
      arrayValue: isSet(object.arrayValue) ? ArrayValue.fromJSON(object.arrayValue) : void 0,
      kvlistValue: isSet(object.kvlistValue) ? KeyValueList.fromJSON(object.kvlistValue) : void 0,
      bytesValue: isSet(object.bytesValue) ? bytesFromBase64(object.bytesValue) : void 0
    };
  },
  toJSON(message) {
    const obj = {};
    if (message.stringValue !== void 0) {
      obj.stringValue = message.stringValue;
    }
    if (message.boolValue !== void 0) {
      obj.boolValue = message.boolValue;
    }
    if (message.intValue !== void 0) {
      obj.intValue = Math.round(message.intValue);
    }
    if (message.doubleValue !== void 0) {
      obj.doubleValue = message.doubleValue;
    }
    if (message.arrayValue !== void 0) {
      obj.arrayValue = ArrayValue.toJSON(message.arrayValue);
    }
    if (message.kvlistValue !== void 0) {
      obj.kvlistValue = KeyValueList.toJSON(message.kvlistValue);
    }
    if (message.bytesValue !== void 0) {
      obj.bytesValue = base64FromBytes(message.bytesValue);
    }
    return obj;
  },
  create(base) {
    return AnyValue.fromPartial(base ?? {});
  },
  fromPartial(object) {
    const message = createBaseAnyValue();
    message.stringValue = object.stringValue ?? void 0;
    message.boolValue = object.boolValue ?? void 0;
    message.intValue = object.intValue ?? void 0;
    message.doubleValue = object.doubleValue ?? void 0;
    message.arrayValue = object.arrayValue !== void 0 && object.arrayValue !== null ? ArrayValue.fromPartial(object.arrayValue) : void 0;
    message.kvlistValue = object.kvlistValue !== void 0 && object.kvlistValue !== null ? KeyValueList.fromPartial(object.kvlistValue) : void 0;
    message.bytesValue = object.bytesValue ?? void 0;
    return message;
  }
};
function createBaseArrayValue() {
  return {
    values: []
  };
}
const ArrayValue = {
  encode(message, writer = import_minimal.default.Writer.create()) {
    for (const v of (0, import_values.default)(message)) {
      AnyValue.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 = createBaseArrayValue();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }
          (0, import_values.default)(message).push(AnyValue.decode(reader, reader.uint32()));
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },
  fromJSON(object) {
    var _context, _context2;
    return {
      values: import_global_this.default.Array.isArray((_context = object) == null ? void 0 : (0, import_values.default)(_context)) ? (0, import_map.default)(_context2 = (0, import_values.default)(object)).call(_context2, (e) => AnyValue.fromJSON(e)) : []
    };
  },
  toJSON(message) {
    const obj = {};
    if ((0, import_values.default)(message)?.length) {
      var _context3;
      obj.values = (0, import_map.default)(_context3 = (0, import_values.default)(message)).call(_context3, (e) => AnyValue.toJSON(e));
    }
    return obj;
  },
  create(base) {
    return ArrayValue.fromPartial(base ?? {});
  },
  fromPartial(object) {
    var _context4, _context5;
    const message = createBaseArrayValue();
    message.values = ((_context4 = (0, import_values.default)(object)) == null ? void 0 : (0, import_bind.default)(_context5 = Function.call).call(_context5, (0, import_map.default)(_context4), _context4))?.((e) => AnyValue.fromPartial(e)) || [];
    return message;
  }
};
function createBaseKeyValueList() {
  return {
    values: []
  };
}
const KeyValueList = {
  encode(message, writer = import_minimal.default.Writer.create()) {
    for (const v of (0, import_values.default)(message)) {
      KeyValue.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 = createBaseKeyValueList();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }
          (0, import_values.default)(message).push(KeyValue.decode(reader, reader.uint32()));
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },
  fromJSON(object) {
    var _context6, _context7;
    return {
      values: import_global_this.default.Array.isArray((_context6 = object) == null ? void 0 : (0, import_values.default)(_context6)) ? (0, import_map.default)(_context7 = (0, import_values.default)(object)).call(_context7, (e) => KeyValue.fromJSON(e)) : []
    };
  },
  toJSON(message) {
    const obj = {};
    if ((0, import_values.default)(message)?.length) {
      var _context8;
      obj.values = (0, import_map.default)(_context8 = (0, import_values.default)(message)).call(_context8, (e) => KeyValue.toJSON(e));
    }
    return obj;
  },
  create(base) {
    return KeyValueList.fromPartial(base ?? {});
  },
  fromPartial(object) {
    var _context9, _context0;
    const message = createBaseKeyValueList();
    message.values = ((_context9 = (0, import_values.default)(object)) == null ? void 0 : (0, import_bind.default)(_context0 = Function.call).call(_context0, (0, import_map.default)(_context9), _context9))?.((e) => KeyValue.fromPartial(e)) || [];
    return message;
  }
};
function createBaseKeyValue() {
  return {
    key: "",
    value: void 0
  };
}
const KeyValue = {
  encode(message, writer = import_minimal.default.Writer.create()) {
    if (message.key !== "") {
      writer.uint32(10).string(message.key);
    }
    if (message.value !== void 0) {
      AnyValue.encode(message.value, writer.uint32(18).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 = createBaseKeyValue();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }
          message.key = reader.string();
          continue;
        case 2:
          if (tag !== 18) {
            break;
          }
          message.value = AnyValue.decode(reader, reader.uint32());
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },
  fromJSON(object) {
    return {
      key: isSet(object.key) ? import_global_this.default.String(object.key) : "",
      value: isSet(object.value) ? AnyValue.fromJSON(object.value) : void 0
    };
  },
  toJSON(message) {
    const obj = {};
    if (message.key !== "") {
      obj.key = message.key;
    }
    if (message.value !== void 0) {
      obj.value = AnyValue.toJSON(message.value);
    }
    return obj;
  },
  create(base) {
    return KeyValue.fromPartial(base ?? {});
  },
  fromPartial(object) {
    const message = createBaseKeyValue();
    message.key = object.key ?? "";
    message.value = object.value !== void 0 && object.value !== null ? AnyValue.fromPartial(object.value) : void 0;
    return message;
  }
};
function createBaseInstrumentationScope() {
  return {
    name: "",
    version: "",
    attributes: [],
    droppedAttributesCount: 0
  };
}
const InstrumentationScope = {
  encode(message, writer = import_minimal.default.Writer.create()) {
    if (message.name !== "") {
      writer.uint32(10).string(message.name);
    }
    if (message.version !== "") {
      writer.uint32(18).string(message.version);
    }
    for (const v of message.attributes) {
      KeyValue.encode(v, writer.uint32(26).fork()).ldelim();
    }
    if (message.droppedAttributesCount !== 0) {
      writer.uint32(32).uint32(message.droppedAttributesCount);
    }
    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 = createBaseInstrumentationScope();
    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.version = reader.string();
          continue;
        case 3:
          if (tag !== 26) {
            break;
          }
          message.attributes.push(KeyValue.decode(reader, reader.uint32()));
          continue;
        case 4:
          if (tag !== 32) {
            break;
          }
          message.droppedAttributesCount = reader.uint32();
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },
  fromJSON(object) {
    var _context1;
    return {
      name: isSet(object.name) ? import_global_this.default.String(object.name) : "",
      version: isSet(object.version) ? import_global_this.default.String(object.version) : "",
      attributes: import_global_this.default.Array.isArray(object?.attributes) ? (0, import_map.default)(_context1 = object.attributes).call(_context1, (e) => KeyValue.fromJSON(e)) : [],
      droppedAttributesCount: isSet(object.droppedAttributesCount) ? import_global_this.default.Number(object.droppedAttributesCount) : 0
    };
  },
  toJSON(message) {
    const obj = {};
    if (message.name !== "") {
      obj.name = message.name;
    }
    if (message.version !== "") {
      obj.version = message.version;
    }
    if (message.attributes?.length) {
      var _context10;
      obj.attributes = (0, import_map.default)(_context10 = message.attributes).call(_context10, (e) => KeyValue.toJSON(e));
    }
    if (message.droppedAttributesCount !== 0) {
      obj.droppedAttributesCount = Math.round(message.droppedAttributesCount);
    }
    return obj;
  },
  create(base) {
    return InstrumentationScope.fromPartial(base ?? {});
  },
  fromPartial(object) {
    var _context11, _context12;
    const message = createBaseInstrumentationScope();
    message.name = object.name ?? "";
    message.version = object.version ?? "";
    message.attributes = ((_context11 = object.attributes) == null ? void 0 : (0, import_bind.default)(_context12 = Function.call).call(_context12, (0, import_map.default)(_context11), _context11))?.((e) => KeyValue.fromPartial(e)) || [];
    message.droppedAttributesCount = object.droppedAttributesCount ?? 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 = {
  AnyValue,
  ArrayValue,
  InstrumentationScope,
  KeyValue,
  KeyValueList,
  protobufPackage
});
//# sourceMappingURL=common.js.map
