// Copyright IBM Corp. 2020, 2026
// SPDX-License-Identifier: MPL-2.0

package decoder

import (
	"github.com/hashicorp/hcl-lang/schema"
	"github.com/hashicorp/terraform-ls/internal/features/policy/state"
	tfschema "github.com/hashicorp/terraform-schema/schema"
	policySchema "github.com/hashicorp/terraform-schema/schema/policy"
)

func functionsForPolicy(policy *state.PolicyRecord, stateReader CombinedReader) (map[string]schema.FunctionSignature, error) {
	resolvedVersion := tfschema.ResolveVersion(stateReader.TerraformVersion(policy.Path()), policy.Meta.CoreRequirements)
	return policySchema.FunctionsForVersion(resolvedVersion)
}
