//go:build wireinject
// +build wireinject

// The build tag makes sure the stub is not built in the final build.

package main

import (
	"log/slog"

	"kra/internal/app"
	"kra/internal/biz"
	"kra/internal/conf"
	"kra/internal/data"
	"kra/internal/initialize"
	"kra/internal/integration"
	"kra/internal/integration/cache"
	"kra/internal/server"
	"kra/internal/server/handler"
	"kra/internal/server/router"
	"kra/internal/service"
	"kra/internal/worker"
	"kra/pkg/logging"
	platformtask "kra/pkg/task"

	"github.com/go-kratos/kratos/v3"
	"github.com/google/wire"
)

// wireApp init kratos application.
func wireApp(*conf.Server, *conf.Runtime, *slog.Logger, *logging.ReloadableLogger, string) (*kratos.App, func(), error) {
	panic(wire.Build(
		server.ProviderSet,
		handler.ProviderSet,
		router.ProviderSet,
		worker.ProviderSet,
		app.Catalog,
		app.TaskRegistry,
		app.Runtime,
		data.ProviderSet,
		integration.ProviderSet,
		initialize.ProviderSet,
		wire.Bind(new(initialize.Backend), new(*data.Data)),
		wire.Bind(new(cache.RedisProvider), new(*data.Data)),
		wire.Bind(new(biz.TaskMethodRegistry), new(*platformtask.Registry)),
		biz.ProviderSet,
		service.ProviderSet,
		newApp,
	))
}
