// Copyright F3 Authors
// SPDX-License-Identifier: MIT

package generic

import (
	"context"

	"code.forgejo.org/f3/gof3/v3/f3"
	"code.forgejo.org/f3/gof3/v3/id"
	"code.forgejo.org/f3/gof3/v3/kind"
	"code.forgejo.org/f3/gof3/v3/logger"
)

type NodeAccessorsInterface interface {
	SetIsNil(bool)
	GetIsNil() bool

	SetImmutable(bool)
	GetImmutable() bool

	SetIsSync(bool)
	GetIsSync() bool

	GetParent() NodeInterface
	SetParent(NodeInterface)

	GetKind() kind.Kind
	SetKind(kind.Kind)

	GetID() id.NodeID
	SetID(id.NodeID)

	GetTree() TreeInterface
	SetTree(TreeInterface)

	GetChildrenOrder() []id.NodeID
	SetChildrenOrder([]id.NodeID)

	GetNodeChildren() NodeChildren
	SetNodeChildren(NodeChildren)

	GetSupportedListOptions() SupportedListOptions
	GetChildrenList() ChildrenList

	GetDriver() NodeDriverInterface
	SetDriver(NodeDriverInterface)
}

type NodeTreeInterface interface {
	GetChild(id.NodeID) NodeInterface
	GetIDFromName(context.Context, string) id.NodeID
	SetChild(NodeInterface) NodeInterface
	DeleteChild(id.NodeID) NodeInterface
	CreateChild(context.Context) NodeInterface

	GetCurrentPath() Path
}

type NodeDriverProxyInterface interface {
	MapIDInterface
	GetIDFromName(context.Context, string) id.NodeID
	GetChildByIDOrName(context.Context, NodeInterface) NodeInterface

	Get(context.Context) NodeInterface
	Upsert(context.Context) NodeInterface
	Delete(context.Context) NodeInterface

	NewFormat() f3.Interface
	FromFormat(f3.Interface) NodeInterface
	ToFormat() f3.Interface
	GetName() string
	IsUpToDate(f3.Interface) bool

	LookupMappedID(context.Context, id.NodeID, f3.Interface) id.NodeID
}

type MapIDInterface interface {
	GetMappedID() id.NodeID
	SetMappedID(id.NodeID)
}

type NodeInterface interface {
	logger.MessageInterface
	NodeAccessorsInterface
	NodeTreeInterface
	NodeDriverProxyInterface

	Init()

	String() string
}
