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, useAnnotation } from '@embedpdf/react/annotation';
import { localEngine } from '@embedpdf/engine';
import './custom-tools.css';
const engine = localEngine();
// A blue pen, an arrow, and three tools of your own. `meta` is yours: the toolbar reads its label.
const plugins = [
stagePlugin(),
renderPlugin(),
interactionPlugin(),
annotationPlugin({
tools: [
{ id: 'ink', defaults: { color: '#1e90ff', strokeWidth: 3 }, meta: { label: 'Blue pen' } },
{
id: 'arrow',
extends: 'line',
defaults: { lineEndings: { start: 'none', end: 'closed-arrow' } },
meta: { label: 'Arrow' },
},
{
id: 'red-pen',
extends: 'ink',
defaults: { color: '#ff0000', strokeWidth: 2 },
meta: { label: 'Red pen' },
},
{
id: 'marker',
extends: 'ink-highlight',
defaults: { color: '#ffa500' },
meta: { label: 'Marker' },
},
{
id: 'todo',
extends: 'note',
defaults: { icon: 'key', contents: 'TODO' },
meta: { label: 'To do' },
},
],
}),
];
// [!doc-source sketch]
const sketch = async (): Promise