// Code generated by Wire. DO NOT EDIT.

//go:generate go run github.com/google/wire/cmd/wire
//go:build !wireinject
// +build !wireinject

package analytic

import (
	"github.com/authgear/authgear-server/pkg/lib/analytic"
	"github.com/authgear/authgear-server/pkg/lib/config"
	"github.com/authgear/authgear-server/pkg/lib/infra/db"
	"github.com/authgear/authgear-server/pkg/lib/infra/db/appdb"
	"github.com/authgear/authgear-server/pkg/lib/infra/db/auditdb"
	"github.com/authgear/authgear-server/pkg/lib/infra/db/globaldb"
	"github.com/authgear/authgear-server/pkg/lib/infra/redis"
	"github.com/authgear/authgear-server/pkg/lib/infra/redis/analyticredis"
	"github.com/authgear/authgear-server/pkg/lib/meter"
	"github.com/authgear/authgear-server/pkg/util/clock"
	"github.com/authgear/authgear-server/pkg/util/periodical"
)

// Injectors from wire.go:

func NewUserWeeklyReport(pool *db.Pool, databaseCredentials *config.DatabaseCredentials) *analytic.UserWeeklyReport {
	globalDatabaseCredentialsEnvironmentConfig := NewGlobalDatabaseCredentials(databaseCredentials)
	databaseEnvironmentConfig := config.NewDefaultDatabaseEnvironmentConfig()
	handle := globaldb.NewHandle(pool, globalDatabaseCredentialsEnvironmentConfig, databaseEnvironmentConfig)
	sqlBuilder := globaldb.NewSQLBuilder(globalDatabaseCredentialsEnvironmentConfig)
	sqlExecutor := globaldb.NewSQLExecutor(handle)
	globalDBStore := &analytic.GlobalDBStore{
		SQLBuilder:  sqlBuilder,
		SQLExecutor: sqlExecutor,
	}
	appdbHandle := appdb.NewHandle(pool, databaseEnvironmentConfig, databaseCredentials)
	appdbSQLBuilder := appdb.NewSQLBuilder(databaseCredentials)
	appdbSQLExecutor := appdb.NewSQLExecutor(appdbHandle)
	appDBStore := &analytic.AppDBStore{
		SQLBuilder:  appdbSQLBuilder,
		SQLExecutor: appdbSQLExecutor,
	}
	userWeeklyReport := &analytic.UserWeeklyReport{
		GlobalHandle:  handle,
		GlobalDBStore: globalDBStore,
		AppDBHandle:   appdbHandle,
		AppDBStore:    appDBStore,
	}
	return userWeeklyReport
}

func NewProjectHourlyReport(pool *db.Pool, databaseCredentials *config.DatabaseCredentials, auditDatabaseCredentials *config.AuditDatabaseCredentials) *analytic.ProjectHourlyReport {
	globalDatabaseCredentialsEnvironmentConfig := NewGlobalDatabaseCredentials(databaseCredentials)
	databaseEnvironmentConfig := config.NewDefaultDatabaseEnvironmentConfig()
	handle := globaldb.NewHandle(pool, globalDatabaseCredentialsEnvironmentConfig, databaseEnvironmentConfig)
	sqlBuilder := globaldb.NewSQLBuilder(globalDatabaseCredentialsEnvironmentConfig)
	sqlExecutor := globaldb.NewSQLExecutor(handle)
	globalDBStore := &analytic.GlobalDBStore{
		SQLBuilder:  sqlBuilder,
		SQLExecutor: sqlExecutor,
	}
	appdbHandle := appdb.NewHandle(pool, databaseEnvironmentConfig, databaseCredentials)
	appdbSQLBuilder := appdb.NewSQLBuilder(databaseCredentials)
	appdbSQLExecutor := appdb.NewSQLExecutor(appdbHandle)
	appDBStore := &analytic.AppDBStore{
		SQLBuilder:  appdbSQLBuilder,
		SQLExecutor: appdbSQLExecutor,
	}
	projectHourlyReport := &analytic.ProjectHourlyReport{
		GlobalHandle:  handle,
		GlobalDBStore: globalDBStore,
		AppDBHandle:   appdbHandle,
		AppDBStore:    appDBStore,
	}
	return projectHourlyReport
}

func NewProjectWeeklyReport(pool *db.Pool, databaseCredentials *config.DatabaseCredentials, auditDatabaseCredentials *config.AuditDatabaseCredentials) *analytic.ProjectWeeklyReport {
	globalDatabaseCredentialsEnvironmentConfig := NewGlobalDatabaseCredentials(databaseCredentials)
	databaseEnvironmentConfig := config.NewDefaultDatabaseEnvironmentConfig()
	handle := globaldb.NewHandle(pool, globalDatabaseCredentialsEnvironmentConfig, databaseEnvironmentConfig)
	sqlBuilder := globaldb.NewSQLBuilder(globalDatabaseCredentialsEnvironmentConfig)
	sqlExecutor := globaldb.NewSQLExecutor(handle)
	globalDBStore := &analytic.GlobalDBStore{
		SQLBuilder:  sqlBuilder,
		SQLExecutor: sqlExecutor,
	}
	appdbHandle := appdb.NewHandle(pool, databaseEnvironmentConfig, databaseCredentials)
	appdbSQLBuilder := appdb.NewSQLBuilder(databaseCredentials)
	appdbSQLExecutor := appdb.NewSQLExecutor(appdbHandle)
	appDBStore := &analytic.AppDBStore{
		SQLBuilder:  appdbSQLBuilder,
		SQLExecutor: appdbSQLExecutor,
	}
	readHandle := auditdb.NewReadHandle(pool, databaseEnvironmentConfig, auditDatabaseCredentials)
	auditdbSQLBuilder := auditdb.NewSQLBuilder(auditDatabaseCredentials)
	readSQLExecutor := auditdb.NewReadSQLExecutor(readHandle)
	auditDBReadStore := &meter.AuditDBReadStore{
		SQLBuilder:  auditdbSQLBuilder,
		SQLExecutor: readSQLExecutor,
	}
	analyticAuditDBReadStore := &analytic.AuditDBReadStore{
		SQLBuilder:  auditdbSQLBuilder,
		SQLExecutor: readSQLExecutor,
	}
	projectWeeklyReport := &analytic.ProjectWeeklyReport{
		GlobalHandle:      handle,
		GlobalDBStore:     globalDBStore,
		AppDBHandle:       appdbHandle,
		AppDBStore:        appDBStore,
		AuditDBHandle:     readHandle,
		MeterAuditDBStore: auditDBReadStore,
		AuditDBStore:      analyticAuditDBReadStore,
	}
	return projectWeeklyReport
}

func NewProjectMonthlyReport(pool *db.Pool, databaseCredentials *config.DatabaseCredentials, auditDatabaseCredentials *config.AuditDatabaseCredentials) *analytic.ProjectMonthlyReport {
	globalDatabaseCredentialsEnvironmentConfig := NewGlobalDatabaseCredentials(databaseCredentials)
	databaseEnvironmentConfig := config.NewDefaultDatabaseEnvironmentConfig()
	handle := globaldb.NewHandle(pool, globalDatabaseCredentialsEnvironmentConfig, databaseEnvironmentConfig)
	sqlBuilder := globaldb.NewSQLBuilder(globalDatabaseCredentialsEnvironmentConfig)
	sqlExecutor := globaldb.NewSQLExecutor(handle)
	globalDBStore := &analytic.GlobalDBStore{
		SQLBuilder:  sqlBuilder,
		SQLExecutor: sqlExecutor,
	}
	readHandle := auditdb.NewReadHandle(pool, databaseEnvironmentConfig, auditDatabaseCredentials)
	auditdbSQLBuilder := auditdb.NewSQLBuilder(auditDatabaseCredentials)
	readSQLExecutor := auditdb.NewReadSQLExecutor(readHandle)
	auditDBReadStore := &analytic.AuditDBReadStore{
		SQLBuilder:  auditdbSQLBuilder,
		SQLExecutor: readSQLExecutor,
	}
	projectMonthlyReport := &analytic.ProjectMonthlyReport{
		GlobalHandle:  handle,
		GlobalDBStore: globalDBStore,
		AuditDBHandle: readHandle,
		AuditDBStore:  auditDBReadStore,
	}
	return projectMonthlyReport
}

func NewCountCollector(pool *db.Pool, databaseCredentials *config.DatabaseCredentials, auditDatabaseCredentials *config.AuditDatabaseCredentials, redisPool *redis.Pool, credentials *config.AnalyticRedisCredentials) *analytic.CountCollector {
	globalDatabaseCredentialsEnvironmentConfig := NewGlobalDatabaseCredentials(databaseCredentials)
	databaseEnvironmentConfig := config.NewDefaultDatabaseEnvironmentConfig()
	handle := globaldb.NewHandle(pool, globalDatabaseCredentialsEnvironmentConfig, databaseEnvironmentConfig)
	sqlBuilder := globaldb.NewSQLBuilder(globalDatabaseCredentialsEnvironmentConfig)
	sqlExecutor := globaldb.NewSQLExecutor(handle)
	globalDBStore := &analytic.GlobalDBStore{
		SQLBuilder:  sqlBuilder,
		SQLExecutor: sqlExecutor,
	}
	appdbHandle := appdb.NewHandle(pool, databaseEnvironmentConfig, databaseCredentials)
	appdbSQLBuilder := appdb.NewSQLBuilder(databaseCredentials)
	appdbSQLExecutor := appdb.NewSQLExecutor(appdbHandle)
	appDBStore := &analytic.AppDBStore{
		SQLBuilder:  appdbSQLBuilder,
		SQLExecutor: appdbSQLExecutor,
	}
	readHandle := auditdb.NewReadHandle(pool, databaseEnvironmentConfig, auditDatabaseCredentials)
	auditdbSQLBuilder := auditdb.NewSQLBuilder(auditDatabaseCredentials)
	readSQLExecutor := auditdb.NewReadSQLExecutor(readHandle)
	auditDBReadStore := &analytic.AuditDBReadStore{
		SQLBuilder:  auditdbSQLBuilder,
		SQLExecutor: readSQLExecutor,
	}
	writeHandle := auditdb.NewWriteHandle(pool, databaseEnvironmentConfig, auditDatabaseCredentials)
	meterAuditDBReadStore := &meter.AuditDBReadStore{
		SQLBuilder:  auditdbSQLBuilder,
		SQLExecutor: readSQLExecutor,
	}
	writeSQLExecutor := auditdb.NewWriteSQLExecutor(writeHandle)
	auditDBWriteStore := &analytic.AuditDBWriteStore{
		SQLBuilder:  auditdbSQLBuilder,
		SQLExecutor: writeSQLExecutor,
	}
	redisEnvironmentConfig := config.NewDefaultRedisEnvironmentConfig()
	analyticredisHandle := analyticredis.NewHandle(redisPool, redisEnvironmentConfig, credentials)
	readStoreRedis := &meter.ReadStoreRedis{
		Redis: analyticredisHandle,
	}
	service := &analytic.Service{
		ReadCounter: readStoreRedis,
	}
	countCollector := &analytic.CountCollector{
		GlobalHandle:       handle,
		GlobalDBStore:      globalDBStore,
		AppDBHandle:        appdbHandle,
		AppDBStore:         appDBStore,
		AuditDBReadHandle:  readHandle,
		AuditDBReadStore:   auditDBReadStore,
		AuditDBWriteHandle: writeHandle,
		MeterAuditDBStore:  meterAuditDBReadStore,
		AuditDBWriteStore:  auditDBWriteStore,
		AnalyticService:    service,
	}
	return countCollector
}

func NewPeriodicalArgumentParser() *periodical.ArgumentParser {
	clock := _wireSystemClockValue
	argumentParser := &periodical.ArgumentParser{
		Clock: clock,
	}
	return argumentParser
}

var (
	_wireSystemClockValue = clock.NewSystemClock()
)

func NewPosthogIntegration(pool *db.Pool, databaseCredentials *config.DatabaseCredentials, auditDatabaseCredentials *config.AuditDatabaseCredentials, redisPool *redis.Pool, credentials *config.AnalyticRedisCredentials, posthogCredentials *analytic.PosthogCredentials) *analytic.PosthogIntegration {
	posthogHTTPClient := analytic.NewPosthogHTTPClient()
	posthogService := analytic.PosthogService{
		PosthogCredentials: posthogCredentials,
		HTTPClient:         posthogHTTPClient,
	}
	clockClock := _wireSystemClockValue
	globalDatabaseCredentialsEnvironmentConfig := NewGlobalDatabaseCredentials(databaseCredentials)
	databaseEnvironmentConfig := config.NewDefaultDatabaseEnvironmentConfig()
	handle := globaldb.NewHandle(pool, globalDatabaseCredentialsEnvironmentConfig, databaseEnvironmentConfig)
	sqlBuilder := globaldb.NewSQLBuilder(globalDatabaseCredentialsEnvironmentConfig)
	sqlExecutor := globaldb.NewSQLExecutor(handle)
	globalDBStore := &analytic.GlobalDBStore{
		SQLBuilder:  sqlBuilder,
		SQLExecutor: sqlExecutor,
	}
	appdbHandle := appdb.NewHandle(pool, databaseEnvironmentConfig, databaseCredentials)
	appdbSQLBuilder := appdb.NewSQLBuilder(databaseCredentials)
	appdbSQLExecutor := appdb.NewSQLExecutor(appdbHandle)
	appDBStore := &analytic.AppDBStore{
		SQLBuilder:  appdbSQLBuilder,
		SQLExecutor: appdbSQLExecutor,
	}
	redisEnvironmentConfig := config.NewDefaultRedisEnvironmentConfig()
	analyticredisHandle := analyticredis.NewHandle(redisPool, redisEnvironmentConfig, credentials)
	readStoreRedis := &meter.ReadStoreRedis{
		Redis: analyticredisHandle,
	}
	auditdbSQLBuilder := auditdb.NewSQLBuilder(auditDatabaseCredentials)
	readHandle := auditdb.NewReadHandle(pool, databaseEnvironmentConfig, auditDatabaseCredentials)
	readSQLExecutor := auditdb.NewReadSQLExecutor(readHandle)
	auditDBReadStore := &meter.AuditDBReadStore{
		SQLBuilder:  auditdbSQLBuilder,
		SQLExecutor: readSQLExecutor,
	}
	posthogIntegration := &analytic.PosthogIntegration{
		PosthogService:        posthogService,
		PosthogCredentials:    posthogCredentials,
		Clock:                 clockClock,
		GlobalHandle:          handle,
		GlobalDBStore:         globalDBStore,
		AppDBHandle:           appdbHandle,
		AppDBStore:            appDBStore,
		HTTPClient:            posthogHTTPClient,
		ReadCounterStore:      readStoreRedis,
		MeterAuditDBReadStore: auditDBReadStore,
		AuditDBReadHandle:     readHandle,
	}
	return posthogIntegration
}
