import { useState } from 'react';
import { Viewer, DocumentGate, usePageList } from '@embedpdf/react/runtime';
import type { OpenInput } from '@embedpdf/react/runtime';
import { Stage, stagePlugin, useStage } from '@embedpdf/react/stage';
import { RenderLayer, renderPlugin } from '@embedpdf/react/render';
import { SelectionLayer, selectionPlugin } from '@embedpdf/react/selection';
import { interactionPlugin } from '@embedpdf/react/interaction';
import {
AnnotationLayer,
annotationPlugin,
useAnnotation,
useAnnotationList,
type AnnotationRef,
} from '@embedpdf/react/annotation';
import { cloudEngine } from '@cloudpdf/engine';
import './create-update.css';
const engine = cloudEngine();
const plugins = [
stagePlugin(),
renderPlugin(),
interactionPlugin(),
selectionPlugin(),
annotationPlugin(),
];
const report: OpenInput = { kind: 'grant', grant: 'shr__TWhIGdJtaKlcnVgJdg--bcm' };
// Create a rectangle, then change, move and delete it, all from code.
function SquareControls() {
const annotation = useAnnotation();
const stage = useStage();
const page = usePageList()[1]?.ref; // page 2, which has room at the bottom
const [ref, setRef] = useState