NativeBridgeDataSource.getCollaborationJoinFlg = function () {
  if (typeof android != "undefined") {
    return android.getCollaborationJoinFlg();
  } else {
    return callNativeApp(NATIVE_KEY_IOS.getCollaborationJoinFlg, {});
  }
};

var CoviewUserInfo = class {
  sid;
  loginId;
  roomId;
  shopName;
  collaborationType;
  joinType;
  isLeaved;
  meetingID;

  constructor(sid, loginId, roomId, shopName) {
    this.sid = sid;
    this.loginId = loginId;
    this.roomId = roomId;
    this.shopName = shopName;
    const unwrappedType = NativeBridgeDataSource.getJoinCollaborationType();
    this.collaborationType = this.parseNumberToCoworkType(unwrappedType);
    this.joinType = NativeBridgeDataSource.getCollaborationJoinFlg();
    
    this.isLeaved = false;
    this.meetingID = 0;
  }

  get coWorkType() {
    switch (this.collaborationType) {
      case COLLABORATION_TYPE.AUDIO:
        return COLLABORATION_TYPE.AUDIO;
      case COLLABORATION_TYPE.CAMERA:
        return COLLABORATION_TYPE.CAMERA;
      case COLLABORATION_TYPE.VIDEO:
        return COLLABORATION_TYPE.VIDEO;
      case COLLABORATION_TYPE.DOCUMENT:
        return COLLABORATION_TYPE.AUDIO;
      case COLLABORATION_TYPE.BOARD:
        return COLLABORATION_TYPE.AUDIO;
    }
  }

  isInvited() {
    this.joinType == COLLABORATION_JOIN_TYPE.INVITED;
  }

  parseNumberToCoworkType(type) {
    switch (type) {
      case COLLABORATION_TYPE_NUMBER.AUDIO:
        return COLLABORATION_TYPE.AUDIO;
      case COLLABORATION_TYPE_NUMBER.CAMERA:
        return COLLABORATION_TYPE.CAMERA;
      case COLLABORATION_TYPE_NUMBER.VIDEO:
        return COLLABORATION_TYPE.VIDEO;
      case COLLABORATION_TYPE_NUMBER.DOCUMENT:
        return COLLABORATION_TYPE.DOCUMENT;
      case COLLABORATION_TYPE_NUMBER.BOARD:
        return COLLABORATION_TYPE.BOARD;
      default:
        return 0;
    }
  }

  getCollaborarionTypeAsNumber() {
    return this.parseCoworkTypeToNumber(this.collaborationType);
  }

  parseCoworkTypeToNumber(type) {
    switch (type) {
      case COLLABORATION_TYPE.AUDIO:
        return COLLABORATION_TYPE_NUMBER.AUDIO;
      case COLLABORATION_TYPE.CAMERA:
        return COLLABORATION_TYPE_NUMBER.CAMERA;
      case COLLABORATION_TYPE.VIDEO:
        return COLLABORATION_TYPE_NUMBER.VIDEO;
      case COLLABORATION_TYPE.DOCUMENT:
        return COLLABORATION_TYPE_NUMBER.DOCUMENT;
      case COLLABORATION_TYPE.BOARD:
        return COLLABORATION_TYPE_NUMBER.BOARD;
      default:
        return 0;
    }
  }
};

// variable name for legacy connection to agent_app.js in coview library
var globalUserInfo = new CoviewUserInfo(
  currentUserInfo.sid,
  currentUserInfo.loginID,
  roomInfo.roomID,
  currentUserInfo.shopName
);
