import { AI_HOST } from '@constants';
import { useAIConsentStore } from '@shared/state/ai-consent';
import { useImageGenerationStore } from '@shared/state/generate-images.js';
import { __ } from '@wordpress/i18n';
// Additional data to send with requests
const { showAIConsent, userGaveConsent } = useAIConsentStore.getState();
Object.entries(window.extSharedData).filter(([key]) =>
export const completion = async (
const response = await fetch(`${AI_HOST}/api/draft/completion`, {
headers: { 'Content-Type': 'application/json' },
globalState: useImageGenerationStore.getState(),
throw new Error(__('Service temporarily unavailable', 'extendify-local'));