package http

import (
	"net/http"

	"hyapp/services/gateway-service/internal/auth"
	"hyapp/services/gateway-service/internal/transport/http/httproutes"
)

// Routes 把 Handler 的私有方法适配成独立路由包需要的显式 handler 表。
// 路径注册集中在 httproutes，gateway 依赖装配和鉴权 wrapper 仍留在 transport 入口层。
func (h *Handler) Routes(jwtVerifier *auth.Verifier) http.Handler {
	return httproutes.New(httproutes.Config{
		PublicWrap: h.publicAPIHandler,
		AuthWrap: func(handler http.HandlerFunc) http.Handler {
			return h.apiHandler(jwtVerifier, handler)
		},
		ProfileWrap: func(handler http.HandlerFunc) http.Handler {
			return h.profileAPIHandler(jwtVerifier, handler)
		},
		Auth: httproutes.AuthHandlers{
			LoginPassword:   h.loginPassword,
			SetPassword:     h.setPassword,
			LoginThirdParty: h.loginThirdParty,
			RefreshToken:    h.refreshToken,
			Logout:          h.logout,
		},
		App: httproutes.AppHandlers{
			ListRegistrationCountries: h.listRegistrationCountries,
			GetAppBootstrap:           h.getAppBootstrap,
			ListH5Links:               h.listH5Links,
			ListAppBanners:            h.listAppBanners,
			GetAppVersion:             h.getAppVersion,
			ListResources:             h.listResources,
			GetResourceGroup:          h.getResourceGroup,
			ListGifts:                 h.listGifts,
			IssueTencentIMUserSig:     h.issueTencentIMUserSig,
			IssueTencentRTCToken:      h.issueTencentRTCToken,
			HandleTencentIMCallback:   h.handleTencentIMCallback,
			HandleTencentRTCCallback:  h.handleTencentRTCCallback,
			UploadFile:                h.uploadFile,
			UploadAvatar:              h.uploadAvatar,
			HandlePushToken:           h.handlePushToken,
		},
		User: httproutes.UserHandlers{
			ResolveDisplayUserID:       h.resolveDisplayUserID,
			BatchUserProfiles:          h.batchUserProfiles,
			BatchRoomDisplayProfiles:   h.batchRoomDisplayProfiles,
			GetMyOverview:              h.getMyOverview,
			GetMyIdentity:              h.getMyIdentity,
			GetMyHostIdentity:          h.getMyHostIdentity,
			GetMyRoleSummary:           h.getMyRoleSummary,
			CompleteMyOnboarding:       h.completeMyOnboarding,
			UpdateMyProfile:            h.updateMyProfile,
			ChangeMyCountry:            h.changeMyCountry,
			ChangeMyDisplayUserID:      h.changeMyDisplayUserID,
			ApplyMyPrettyDisplayUserID: h.applyMyPrettyDisplayUserID,
			ListMyProfileVisitors:      h.listMyProfileVisitors,
			ListMyFollowing:            h.listMyFollowing,
			ListMyFriends:              h.listMyFriends,
			ListMyFriendApplications:   h.listMyFriendApplications,
			GetMyProfile:               h.getMyProfile,
			ListMyResources:            h.listMyResources,
			EquipMyResource:            h.equipMyResource,
			UserSocialAction:           h.userSocialAction,
		},
		Manager: httproutes.ManagerHandlers{
			ListManagerGrantResources: h.listManagerGrantResources,
			GrantManagerResource:      h.grantManagerResource,
			LookupBusinessUsers:       h.lookupBusinessUsers,
		},
		Room: httproutes.RoomHandlers{
			GetMyRoom:            h.getMyRoom,
			ListRoomFeeds:        h.listRoomFeeds,
			ListRooms:            h.listRooms,
			GetCurrentRoom:       h.getCurrentRoom,
			GetRoomSnapshot:      h.getRoomSnapshot,
			GetRoomDetail:        h.getRoomDetail,
			ListRoomOnlineUsers:  h.listRoomOnlineUsers,
			GetRoomGiftPanel:     h.getRoomGiftPanel,
			CreateRoom:           h.createRoom,
			UpdateRoomProfile:    h.updateRoomProfile,
			JoinRoom:             h.joinRoom,
			RoomHeartbeat:        h.roomHeartbeat,
			LeaveRoom:            h.leaveRoom,
			CloseRoom:            h.closeRoom,
			MicUp:                h.micUp,
			MicDown:              h.micDown,
			ChangeMicSeat:        h.changeMicSeat,
			ConfirmMicPublishing: h.confirmMicPublishing,
			SetMicMute:           h.setMicMute,
			SetMicSeatLock:       h.setMicSeatLock,
			SetChatEnabled:       h.setChatEnabled,
			SetRoomAdmin:         h.setRoomAdmin,
			MuteUser:             h.muteUser,
			KickUser:             h.kickUser,
			UnbanUser:            h.unbanUser,
			SendGift:             h.sendGift,
		},
		Message: httproutes.MessageHandlers{
			ListMessageTabs:          h.listMessageTabs,
			MarkInboxSectionRead:     h.markInboxSectionRead,
			MarkInboxMessageReadPath: h.markInboxMessageReadByPath,
			DeleteInboxMessagePath:   h.deleteInboxMessageByPath,
			ListInboxMessages:        h.listInboxMessages,
		},
		Task: httproutes.TaskHandlers{
			ListTaskTabs:                     h.listTaskTabs,
			ClaimTaskReward:                  h.claimTaskReward,
			GetRegistrationRewardEligibility: h.getRegistrationRewardEligibility,
		},
		Wallet: httproutes.WalletHandlers{
			GetWalletOverview:        h.getWalletOverview,
			GetMyBalances:            h.getMyBalances,
			ListRechargeProducts:     h.listRechargeProducts,
			GetDiamondExchangeConfig: h.getDiamondExchangeConfig,
			ApplyWithdrawal:          h.applyWithdrawal,
			ListCoinTransactions:     h.listCoinTransactions,
			ListWalletTransactions:   h.listWalletTransactions,
			TransferCoinFromSeller:   h.transferCoinFromSeller,
		},
		VIP: httproutes.VIPHandlers{
			GetMyVIP:        h.getMyVIP,
			ListVIPPackages: h.listVIPPackages,
			PurchaseVIP:     h.purchaseVIP,
		},
		Game: httproutes.GameHandlers{
			ListGames:      h.listGames,
			LaunchGame:     h.launchGame,
			HandleCallback: h.handleGameCallback,
		},
	})
}
