// Code generated by Wire. DO NOT EDIT.

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

package service

import (
	"github.com/authgear/authgear-server/pkg/lib/audit"
	"github.com/authgear/authgear-server/pkg/lib/config"
	"github.com/authgear/authgear-server/pkg/lib/deps"
	"github.com/authgear/authgear-server/pkg/lib/hook"
	"github.com/authgear/authgear-server/pkg/lib/infra/db"
	"github.com/authgear/authgear-server/pkg/lib/infra/db/auditdb"
	"github.com/authgear/authgear-server/pkg/portal/model"
	"github.com/authgear/authgear-server/pkg/util/clock"
)

// Injectors from wire.go:

func newAuditSink(app *model.App, pool *db.Pool, cfg *config.DatabaseEnvironmentConfig) *audit.Sink {
	appContext := app.Context
	configConfig := appContext.Config
	secretConfig := configConfig.SecretConfig
	auditDatabaseCredentials := deps.ProvideAuditDatabaseCredentials(secretConfig)
	writeHandle := auditdb.NewWriteHandle(pool, cfg, auditDatabaseCredentials)
	appConfig := configConfig.AppConfig
	appID := appConfig.ID
	sqlBuilderApp := auditdb.NewSQLBuilderApp(auditDatabaseCredentials, appID)
	writeSQLExecutor := auditdb.NewWriteSQLExecutor(writeHandle)
	writeStore := &audit.WriteStore{
		SQLBuilder:  sqlBuilderApp,
		SQLExecutor: writeSQLExecutor,
	}
	sink := &audit.Sink{
		Database: writeHandle,
		Store:    writeStore,
	}
	return sink
}

func newHookSink(app *model.App, denoEndpoint config.DenoEndpoint) *hook.Sink {
	appContext := app.Context
	configConfig := appContext.Config
	appConfig := configConfig.AppConfig
	hookConfig := appConfig.Hook
	clock := _wireSystemClockValue
	secretConfig := configConfig.SecretConfig
	webhookKeyMaterials := deps.ProvideWebhookKeyMaterials(secretConfig)
	webHookImpl := hook.WebHookImpl{
		Secret: webhookKeyMaterials,
	}
	syncHTTPClient := hook.NewSyncHTTPClient(hookConfig)
	asyncHTTPClient := hook.NewAsyncHTTPClient()
	eventWebHookImpl := &hook.EventWebHookImpl{
		WebHookImpl: webHookImpl,
		SyncHTTP:    syncHTTPClient,
		AsyncHTTP:   asyncHTTPClient,
	}
	manager := appContext.Resources
	denoHook := hook.DenoHook{
		ResourceManager: manager,
	}
	syncDenoClient := hook.NewSyncDenoClient(denoEndpoint, hookConfig)
	asyncDenoClient := hook.NewAsyncDenoClient(denoEndpoint)
	eventDenoHookImpl := &hook.EventDenoHookImpl{
		DenoHook:        denoHook,
		SyncDenoClient:  syncDenoClient,
		AsyncDenoClient: asyncDenoClient,
	}
	noopAttributesService := _wireNoopAttributesServiceValue
	noopRolesAndGroupsService := _wireNoopRolesAndGroupsServiceValue
	sink := &hook.Sink{
		Config:             hookConfig,
		Clock:              clock,
		EventWebHook:       eventWebHookImpl,
		EventDenoHook:      eventDenoHookImpl,
		StandardAttributes: noopAttributesService,
		CustomAttributes:   noopAttributesService,
		RolesAndGroups:     noopRolesAndGroupsService,
	}
	return sink
}

var (
	_wireSystemClockValue               = clock.NewSystemClock()
	_wireNoopAttributesServiceValue     = &NoopAttributesService{}
	_wireNoopRolesAndGroupsServiceValue = &NoopRolesAndGroupsService{}
)
