import { useState } from 'react';
import { Viewer, DocumentGate } from '@embedpdf/react/runtime';
import type { OpenInput } from '@embedpdf/react/runtime';
import { Stage, stagePlugin } from '@embedpdf/react/stage';
import { RenderLayer, renderPlugin } from '@embedpdf/react/render';
import { interactionPlugin } from '@embedpdf/react/interaction';
import { actionsPlugin } from '@embedpdf/react/actions';
import {
FormLayer,
formPlugin,
toFieldRef,
useFormEvent,
useFormValue,
} from '@embedpdf/react/form';
import { cloudEngine } from '@cloudpdf/engine';
import './scripts.css';
const engine = cloudEngine();
// The form's scripts run with JavaScript on in the actions plugin.
const plugins = [
stagePlugin(),
renderPlugin(),
interactionPlugin(),
formPlugin(),
actionsPlugin({ javascript: { enabled: true } }),
];
const invoice: OpenInput = { kind: 'grant', grant: 'shr_NCOaGzAKFsdI2r-UaVUJG7zL' };
// The amounts and the total are calculated by the form's scripts.
function InvoiceBar() {
const total = useFormValue(toFieldRef('invoice.total'));
const [refused, setRefused] = useState