import { useEffect } 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,
useInteraction,
useInteractionState,
} from '@embedpdf/react/interaction';
import { AnnotationLayer, annotationPlugin } from '@embedpdf/react/annotation';
import { localEngine } from '@embedpdf/engine';
import './click-create.css';
const engine = localEngine();
// What one click makes: a 120 × 80 rectangle, an arrow pointing down at the click, and no circle.
const plugins = [
stagePlugin(),
renderPlugin(),
interactionPlugin(),
annotationPlugin({
tools: [
{ id: 'square', clickCreate: { width: 120, height: 80 } },
{
id: 'arrow',
extends: 'line',
defaults: { lineEndings: { start: 'none', end: 'closed-arrow' } },
clickCreate: { length: 80, rotation: 90, anchor: 'end' },
},
{ id: 'circle', clickCreate: false }, // drag only
],
}),
];
// [!doc-source sketch]
const sketch = async (): Promise {active?.hint ?? 'Pick a tool, then click the page'}