// packages/block-library/src/post-terms/use-post-terms.js
import { store as coreStore } from "@wordpress/core-data";
import { useSelect } from "@wordpress/data";
var EMPTY_ARRAY = [];
function usePostTerms({ postId, term }) {
  const { slug } = term;
  return useSelect(
    (select) => {
      const visible = term?.visibility?.publicly_queryable;
      if (!visible) {
        return {
          postTerms: EMPTY_ARRAY,
          isLoading: false,
          hasPostTerms: false
        };
      }
      const { getEntityRecords, isResolving } = select(coreStore);
      const taxonomyArgs = [
        "taxonomy",
        slug,
        {
          post: postId,
          per_page: -1,
          context: "view"
        }
      ];
      const terms = getEntityRecords(...taxonomyArgs);
      return {
        postTerms: terms,
        isLoading: isResolving("getEntityRecords", taxonomyArgs),
        hasPostTerms: !!terms?.length
      };
    },
    [postId, term?.visibility?.publicly_queryable, slug]
  );
}
export {
  usePostTerms as default
};
//# sourceMappingURL=use-post-terms.js.map
