{"ast":null,"code":"'use client';\n\nimport React, { useEffect, useMemo, useRef } from 'react';\nimport makeCancellable from 'make-cancellable-promise';\nimport clsx from 'clsx';\nimport invariant from 'tiny-invariant';\nimport warning from 'warning';\nimport pdfjs from '../pdfjs.js';\nimport useDocumentContext from '../shared/hooks/useDocumentContext.js';\nimport usePageContext from '../shared/hooks/usePageContext.js';\nimport useResolver from '../shared/hooks/useResolver.js';\nimport { cancelRunningTask } from '../shared/utils.js';\nexport default function AnnotationLayer() {\n  const documentContext = useDocumentContext();\n  const pageContext = usePageContext();\n  invariant(pageContext, 'Unable to find Page context.');\n  const mergedProps = Object.assign(Object.assign({}, documentContext), pageContext);\n  const {\n    imageResourcesPath,\n    linkService,\n    onGetAnnotationsError: onGetAnnotationsErrorProps,\n    onGetAnnotationsSuccess: onGetAnnotationsSuccessProps,\n    onRenderAnnotationLayerError: onRenderAnnotationLayerErrorProps,\n    onRenderAnnotationLayerSuccess: onRenderAnnotationLayerSuccessProps,\n    page,\n    pdf,\n    renderForms,\n    rotate,\n    scale = 1\n  } = mergedProps;\n  invariant(pdf, 'Attempted to load page annotations, but no document was specified. Wrap <Page /> in a <Document /> or pass explicit `pdf` prop.');\n  invariant(page, 'Attempted to load page annotations, but no page was specified.');\n  invariant(linkService, 'Attempted to load page annotations, but no linkService was specified.');\n  const [annotationsState, annotationsDispatch] = useResolver();\n  const {\n    value: annotations,\n    error: annotationsError\n  } = annotationsState;\n  const layerElement = useRef(null);\n  warning(parseInt(window.getComputedStyle(document.body).getPropertyValue('--react-pdf-annotation-layer'), 10) === 1, 'AnnotationLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-annotations');\n  function onLoadSuccess() {\n    if (!annotations) {\n      // Impossible, but TypeScript doesn't know that\n      return;\n    }\n    if (onGetAnnotationsSuccessProps) {\n      onGetAnnotationsSuccessProps(annotations);\n    }\n  }\n  function onLoadError() {\n    if (!annotationsError) {\n      // Impossible, but TypeScript doesn't know that\n      return;\n    }\n    warning(false, annotationsError.toString());\n    if (onGetAnnotationsErrorProps) {\n      onGetAnnotationsErrorProps(annotationsError);\n    }\n  }\n  function resetAnnotations() {\n    annotationsDispatch({\n      type: 'RESET'\n    });\n  }\n  useEffect(resetAnnotations, [annotationsDispatch, page]);\n  function loadAnnotations() {\n    if (!page) {\n      return;\n    }\n    const cancellable = makeCancellable(page.getAnnotations());\n    const runningTask = cancellable;\n    cancellable.promise.then(nextAnnotations => {\n      annotationsDispatch({\n        type: 'RESOLVE',\n        value: nextAnnotations\n      });\n    }).catch(error => {\n      annotationsDispatch({\n        type: 'REJECT',\n        error\n      });\n    });\n    return () => {\n      cancelRunningTask(runningTask);\n    };\n  }\n  useEffect(loadAnnotations, [annotationsDispatch, page, renderForms]);\n  useEffect(() => {\n    if (annotations === undefined) {\n      return;\n    }\n    if (annotations === false) {\n      onLoadError();\n      return;\n    }\n    onLoadSuccess();\n  },\n  // Ommitted callbacks so they are not called every time they change\n  // eslint-disable-next-line react-hooks/exhaustive-deps\n  [annotations]);\n  function onRenderSuccess() {\n    if (onRenderAnnotationLayerSuccessProps) {\n      onRenderAnnotationLayerSuccessProps();\n    }\n  }\n  function onRenderError(error) {\n    warning(false, `${error}`);\n    if (onRenderAnnotationLayerErrorProps) {\n      onRenderAnnotationLayerErrorProps(error);\n    }\n  }\n  const viewport = useMemo(() => page.getViewport({\n    scale,\n    rotation: rotate\n  }), [page, rotate, scale]);\n  function renderAnnotationLayer() {\n    if (!pdf || !page || !linkService || !annotations) {\n      return;\n    }\n    const {\n      current: layer\n    } = layerElement;\n    if (!layer) {\n      return;\n    }\n    const clonedViewport = viewport.clone({\n      dontFlip: true\n    });\n    const annotationLayerParameters = {\n      accessibilityManager: null,\n      // TODO: Implement this\n      annotationCanvasMap: null,\n      // TODO: Implement this\n      div: layer,\n      l10n: null,\n      // TODO: Implement this\n      page,\n      viewport: clonedViewport\n    };\n    const renderParameters = {\n      annotations,\n      annotationStorage: pdf.annotationStorage,\n      div: layer,\n      // See https://github.com/mozilla/pdf.js/issues/17029\n      downloadManager: null,\n      imageResourcesPath,\n      linkService,\n      page,\n      renderForms,\n      viewport: clonedViewport\n    };\n    layer.innerHTML = '';\n    try {\n      new pdfjs.AnnotationLayer(annotationLayerParameters).render(renderParameters);\n      // Intentional immediate callback\n      onRenderSuccess();\n    } catch (error) {\n      onRenderError(error);\n    }\n    return () => {\n      // TODO: Cancel running task?\n    };\n  }\n  useEffect(renderAnnotationLayer,\n  // Ommitted callbacks so they are not called every time they change\n  // eslint-disable-next-line react-hooks/exhaustive-deps\n  [annotations, imageResourcesPath, linkService, page, renderForms, viewport]);\n  return React.createElement(\"div\", {\n    className: clsx('react-pdf__Page__annotations', 'annotationLayer'),\n    ref: layerElement\n  });\n}","map":{"version":3,"names":["React","useEffect","useMemo","useRef","makeCancellable","clsx","invariant","warning","pdfjs","useDocumentContext","usePageContext","useResolver","cancelRunningTask","AnnotationLayer","documentContext","pageContext","mergedProps","Object","assign","imageResourcesPath","linkService","onGetAnnotationsError","onGetAnnotationsErrorProps","onGetAnnotationsSuccess","onGetAnnotationsSuccessProps","onRenderAnnotationLayerError","onRenderAnnotationLayerErrorProps","onRenderAnnotationLayerSuccess","onRenderAnnotationLayerSuccessProps","page","pdf","renderForms","rotate","scale","annotationsState","annotationsDispatch","value","annotations","error","annotationsError","layerElement","parseInt","window","getComputedStyle","document","body","getPropertyValue","onLoadSuccess","onLoadError","toString","resetAnnotations","type","loadAnnotations","cancellable","getAnnotations","runningTask","promise","then","nextAnnotations","catch","undefined","onRenderSuccess","onRenderError","viewport","getViewport","rotation","renderAnnotationLayer","current","layer","clonedViewport","clone","dontFlip","annotationLayerParameters","accessibilityManager","annotationCanvasMap","div","l10n","renderParameters","annotationStorage","downloadManager","innerHTML","render","createElement","className","ref"],"sources":["/Users/chrishaack/UC_Trains_Voice/react-demo/node_modules/react-pdf/dist/esm/Page/AnnotationLayer.js"],"sourcesContent":["'use client';\nimport React, { useEffect, useMemo, useRef } from 'react';\nimport makeCancellable from 'make-cancellable-promise';\nimport clsx from 'clsx';\nimport invariant from 'tiny-invariant';\nimport warning from 'warning';\nimport pdfjs from '../pdfjs.js';\nimport useDocumentContext from '../shared/hooks/useDocumentContext.js';\nimport usePageContext from '../shared/hooks/usePageContext.js';\nimport useResolver from '../shared/hooks/useResolver.js';\nimport { cancelRunningTask } from '../shared/utils.js';\nexport default function AnnotationLayer() {\n    const documentContext = useDocumentContext();\n    const pageContext = usePageContext();\n    invariant(pageContext, 'Unable to find Page context.');\n    const mergedProps = Object.assign(Object.assign({}, documentContext), pageContext);\n    const { imageResourcesPath, linkService, onGetAnnotationsError: onGetAnnotationsErrorProps, onGetAnnotationsSuccess: onGetAnnotationsSuccessProps, onRenderAnnotationLayerError: onRenderAnnotationLayerErrorProps, onRenderAnnotationLayerSuccess: onRenderAnnotationLayerSuccessProps, page, pdf, renderForms, rotate, scale = 1, } = mergedProps;\n    invariant(pdf, 'Attempted to load page annotations, but no document was specified. Wrap <Page /> in a <Document /> or pass explicit `pdf` prop.');\n    invariant(page, 'Attempted to load page annotations, but no page was specified.');\n    invariant(linkService, 'Attempted to load page annotations, but no linkService was specified.');\n    const [annotationsState, annotationsDispatch] = useResolver();\n    const { value: annotations, error: annotationsError } = annotationsState;\n    const layerElement = useRef(null);\n    warning(parseInt(window.getComputedStyle(document.body).getPropertyValue('--react-pdf-annotation-layer'), 10) === 1, 'AnnotationLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-annotations');\n    function onLoadSuccess() {\n        if (!annotations) {\n            // Impossible, but TypeScript doesn't know that\n            return;\n        }\n        if (onGetAnnotationsSuccessProps) {\n            onGetAnnotationsSuccessProps(annotations);\n        }\n    }\n    function onLoadError() {\n        if (!annotationsError) {\n            // Impossible, but TypeScript doesn't know that\n            return;\n        }\n        warning(false, annotationsError.toString());\n        if (onGetAnnotationsErrorProps) {\n            onGetAnnotationsErrorProps(annotationsError);\n        }\n    }\n    function resetAnnotations() {\n        annotationsDispatch({ type: 'RESET' });\n    }\n    useEffect(resetAnnotations, [annotationsDispatch, page]);\n    function loadAnnotations() {\n        if (!page) {\n            return;\n        }\n        const cancellable = makeCancellable(page.getAnnotations());\n        const runningTask = cancellable;\n        cancellable.promise\n            .then((nextAnnotations) => {\n            annotationsDispatch({ type: 'RESOLVE', value: nextAnnotations });\n        })\n            .catch((error) => {\n            annotationsDispatch({ type: 'REJECT', error });\n        });\n        return () => {\n            cancelRunningTask(runningTask);\n        };\n    }\n    useEffect(loadAnnotations, [annotationsDispatch, page, renderForms]);\n    useEffect(() => {\n        if (annotations === undefined) {\n            return;\n        }\n        if (annotations === false) {\n            onLoadError();\n            return;\n        }\n        onLoadSuccess();\n    }, \n    // Ommitted callbacks so they are not called every time they change\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n    [annotations]);\n    function onRenderSuccess() {\n        if (onRenderAnnotationLayerSuccessProps) {\n            onRenderAnnotationLayerSuccessProps();\n        }\n    }\n    function onRenderError(error) {\n        warning(false, `${error}`);\n        if (onRenderAnnotationLayerErrorProps) {\n            onRenderAnnotationLayerErrorProps(error);\n        }\n    }\n    const viewport = useMemo(() => page.getViewport({ scale, rotation: rotate }), [page, rotate, scale]);\n    function renderAnnotationLayer() {\n        if (!pdf || !page || !linkService || !annotations) {\n            return;\n        }\n        const { current: layer } = layerElement;\n        if (!layer) {\n            return;\n        }\n        const clonedViewport = viewport.clone({ dontFlip: true });\n        const annotationLayerParameters = {\n            accessibilityManager: null, // TODO: Implement this\n            annotationCanvasMap: null, // TODO: Implement this\n            div: layer,\n            l10n: null, // TODO: Implement this\n            page,\n            viewport: clonedViewport,\n        };\n        const renderParameters = {\n            annotations,\n            annotationStorage: pdf.annotationStorage,\n            div: layer,\n            // See https://github.com/mozilla/pdf.js/issues/17029\n            downloadManager: null,\n            imageResourcesPath,\n            linkService,\n            page,\n            renderForms,\n            viewport: clonedViewport,\n        };\n        layer.innerHTML = '';\n        try {\n            new pdfjs.AnnotationLayer(annotationLayerParameters).render(renderParameters);\n            // Intentional immediate callback\n            onRenderSuccess();\n        }\n        catch (error) {\n            onRenderError(error);\n        }\n        return () => {\n            // TODO: Cancel running task?\n        };\n    }\n    useEffect(renderAnnotationLayer, \n    // Ommitted callbacks so they are not called every time they change\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n    [annotations, imageResourcesPath, linkService, page, renderForms, viewport]);\n    return (React.createElement(\"div\", { className: clsx('react-pdf__Page__annotations', 'annotationLayer'), ref: layerElement }));\n}\n"],"mappings":"AAAA,YAAY;;AACZ,OAAOA,KAAK,IAAIC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AACzD,OAAOC,eAAe,MAAM,0BAA0B;AACtD,OAAOC,IAAI,MAAM,MAAM;AACvB,OAAOC,SAAS,MAAM,gBAAgB;AACtC,OAAOC,OAAO,MAAM,SAAS;AAC7B,OAAOC,KAAK,MAAM,aAAa;AAC/B,OAAOC,kBAAkB,MAAM,uCAAuC;AACtE,OAAOC,cAAc,MAAM,mCAAmC;AAC9D,OAAOC,WAAW,MAAM,gCAAgC;AACxD,SAASC,iBAAiB,QAAQ,oBAAoB;AACtD,eAAe,SAASC,eAAeA,CAAA,EAAG;EACtC,MAAMC,eAAe,GAAGL,kBAAkB,CAAC,CAAC;EAC5C,MAAMM,WAAW,GAAGL,cAAc,CAAC,CAAC;EACpCJ,SAAS,CAACS,WAAW,EAAE,8BAA8B,CAAC;EACtD,MAAMC,WAAW,GAAGC,MAAM,CAACC,MAAM,CAACD,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAEJ,eAAe,CAAC,EAAEC,WAAW,CAAC;EAClF,MAAM;IAAEI,kBAAkB;IAAEC,WAAW;IAAEC,qBAAqB,EAAEC,0BAA0B;IAAEC,uBAAuB,EAAEC,4BAA4B;IAAEC,4BAA4B,EAAEC,iCAAiC;IAAEC,8BAA8B,EAAEC,mCAAmC;IAAEC,IAAI;IAAEC,GAAG;IAAEC,WAAW;IAAEC,MAAM;IAAEC,KAAK,GAAG;E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