export module BusinessEnum {
	export enum BusinessType {
		Type1 = "LP1",
		Type2 = "LP2"
	}

	export enum ServerType {
		/** 外版 */
		Out = 2,
		/** 內版開發(內網&4G) */
		Internal_Dev = 5,
		/** 外部商業DEMO(B2B) */
		Out_B2B = 6,
		/** QA */
		QA = 7,
		/** Test */
		Test = 8
	}

	export class ComponyType {
		/** 外版 */
		public static Out: number = 1;
		/** 內版開發(內網&4G) */
		public static Internal_Dev: number = 2;
		/** 外部商業DEMO(B2B) */
		public static Out_B2B: number = 2;
		/** QA */
		public static QA: number = 1;
		/** Test */
		public static Test: number = 1;
	}

	export enum LogoType {
		/** 完美(目前只有WEB) */
		// WM = 1
	}
}

/**
產品商業類別設定檔
@explain 讀不同表就代表不同商業類別.要多開GIT並設定新測試環境
@explain 遊戲一定都一樣不能改動介面
 */
export default class BusinessTypeSetting {
	/** 產品商業類別字串(組合判斷用) */
	public static readonly TYPE_BUSINESS: string = BusinessEnum.BusinessType.Type1;

	/** 必要JSON載入結束 */
	public static GetLoadInitEnd(): boolean {
		return this.SetLoadInitEnd;
	}

	public static SetLoadInitEnd: boolean = false;

	/**
	 * 執行環境ProductEnum.ServerType
	 * @description 請統一從Cocos掛載Loading的面板去設定ServerType
	 */
	public static UseServerType: BusinessEnum.ServerType = BusinessEnum.ServerType[import.meta.env.VITE_Deploy] as unknown as BusinessEnum.ServerType;

	/** 連線IP(網頁版會接網址參數所以要多開變數直接指定) */
	public static UseHost: string = BusinessTypeSetting.GetHostUrl(BusinessTypeSetting.UseServerType);

	/** 連接阜(網頁版會接網址參數所以要多開變數直接指定) */
	public static UsePort: number = BusinessTypeSetting.GetPortNum(BusinessTypeSetting.UseServerType);

	/** 資源伺服器網址 */
	public static UsePatch: string = BusinessTypeSetting.GetPatchUrl(BusinessTypeSetting.UseServerType);

	/** 靜態伺服器網址 */
	public static UseDownloadUrl: string = BusinessTypeSetting.GetDownloadUrl(BusinessTypeSetting.UseServerType);

	/** Line Liff */
	public static UseLiffID: string = BusinessTypeSetting.GetLiffID(BusinessTypeSetting.UseServerType);

	/** Line Liff */
	public static UseLineID: string = BusinessTypeSetting.GetLineID(BusinessTypeSetting.UseServerType);

	/** 編譯版本 */
	public static get COMPILE_VERSION(): string {
		return BusinessTypeSetting.SET_COMPILE_VERSION;
	}

	public static SET_COMPILE_VERSION: string = null;

	// =======================================================================================
	/** 網頁測試讀取對應資源的位置 */
	public static readonly FolderUrl: string = "shared/";
	public static readonly FolderUrlImg: string = "shared/img/";
	public static readonly FolderUrlBg: string = "shared/bg/";
	public static readonly FolderUrlJson: string = "shared/jsons/";
	public static readonly FolderUrlTxt: string = "shared/txt/";
	public static readonly FolderUrlLoading: string = "shared/loading/";
	public static readonly FolderUrlMp3: string = "shared/";

	/** Line */
	public static readonly LineFriendUrl: string = "https://line.me/R/ti/p/@";
	/** 原始Liff開啟方式(電腦也支援) */
	public static readonly LiffUrl: string = "https://liff.line.me/";
	/** 電腦開會導向Line官網 */
	public static readonly LiffUrlTypeA: string = "https://line.me/R/app/";
	/** 電腦無法打開 */
	public static readonly LiffUrlTypeB: string = "line://app/";

	/**
	 * 取得PATH資原路徑
	 * @param type 執行環境()
	 * @returns
	 */
	public static GetPatchUrl(type: BusinessEnum.ServerType): string {
		switch (type) {
			case BusinessEnum.ServerType.Out:
				return "https://patch.lybobet.com/";

			case BusinessEnum.ServerType.Internal_Dev:
				return "https://patch-dev.lybobet.com/";

			case BusinessEnum.ServerType.Out_B2B:
				return "https://patch-game-b2b.lybobet.com/";

			case BusinessEnum.ServerType.QA:
				return "https://patch-qa.lybobet.com/";

			case BusinessEnum.ServerType.Test:
				return "https://patch-testing.lybobet.com/";
		}
	}

	/**
	 * 取得連線伺服器IP
	 * @param type 執行環境
	 * @returns
	 */
	public static GetHostUrl(type: BusinessEnum.ServerType): string {
		switch (type) {
			case BusinessEnum.ServerType.Out:
				return "https://game.lybobet.com";

			case BusinessEnum.ServerType.Internal_Dev:
				return "https://dev.lybobet.com";

			case BusinessEnum.ServerType.QA:
				return "https://qa.lybobet.com";

			case BusinessEnum.ServerType.Test:
				return "https://testing.lybobet.com";

			case BusinessEnum.ServerType.Out_B2B:
				return "https://game-b2b.lybobet.com";
		}
	}

	/**
	 * 取得伺服器連接端口
	 * @param type 執行環境
	 * @returns
	 */
	public static GetPortNum(type: BusinessEnum.ServerType): number {
		switch (type) {
			case BusinessEnum.ServerType.Out:
				return 9005;

			case BusinessEnum.ServerType.Internal_Dev:
				return 9005;

			case BusinessEnum.ServerType.QA:
				return 9005;

			case BusinessEnum.ServerType.Test:
				return 9005;

			case BusinessEnum.ServerType.Out_B2B:
				return 9005;

		}
	}

	public static GetDownloadUrl(type: BusinessEnum.ServerType): string {
		switch (type) {
			case BusinessEnum.ServerType.Out:
				return "https://static.lybobet.com/";

			case BusinessEnum.ServerType.Internal_Dev:
				return "https://static-dev.lybobet.com/";

			case BusinessEnum.ServerType.QA:
				return "https://static-qa.lybobet.com/";

			case BusinessEnum.ServerType.Test:
				return "https://static-testing.lybobet.com/";

			case BusinessEnum.ServerType.Out_B2B:
				return "https://static-b2b.lybobet.com/";
		}
	}

	public static GetUploadUrl(type: BusinessEnum.ServerType): string {
		let port: string = ":9080";
		switch (type) {
			case BusinessEnum.ServerType.Internal_Dev: {
				let url: string = this.GetHostUrl(type);
				url = url.replace("http://", "");
				url = url.replace("https://", "");
				return "https://static-" + url + port;
			}
			default:
				return this.GetHostUrl(type) + port;
		}
	}

	public static GetLiffID(type: BusinessEnum.ServerType): string {
		switch (type) {
			case BusinessEnum.ServerType.Out:
				return "1657864491-kA7gnVMp";

			case BusinessEnum.ServerType.Internal_Dev:
				return "1657713613-we8Gk929";

			case BusinessEnum.ServerType.QA:
				return "1657864462-xM7dgPGK";

			case BusinessEnum.ServerType.Test:
				return "1657864500-N3YEgz6p";

			case BusinessEnum.ServerType.Out_B2B:
				return "1657864484-YeqWEV9O";
		}
	}

	public static GetLineID(type: BusinessEnum.ServerType): string {
		switch (type) {
			case BusinessEnum.ServerType.QA:
			case BusinessEnum.ServerType.Test:
			case BusinessEnum.ServerType.Out:
				return "070hdlum";

			case BusinessEnum.ServerType.Internal_Dev:
				return "349pbusa";

			case BusinessEnum.ServerType.Out_B2B:
				return "114pcwux";
		}
	}

	// =======================================================================================

}

export enum FileType {
	PNG = ".png",
	JPG = ".jpg",
	MP3 = ".mp3",
	TXT = ".txt",
}

export enum FolderName {
	Logo = "Logo/",
	SlotImg = "SlotImg/",
	Avatar = "Avatar/",
	Report = "report/",
	PA = "pa/",
	LobbyAd = "lobby_ad/",
	CoverAd = "inter_ad/",
	Activity = "Activity/",
	Game = "game/",
	Dlygo = "dlygo/",
	Event = "event/",
}