@researai/deepscientist 1.5.15 → 1.5.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +385 -104
- package/bin/ds.js +1241 -110
- package/docs/en/00_QUICK_START.md +100 -19
- package/docs/en/01_SETTINGS_REFERENCE.md +34 -1
- package/docs/en/02_START_RESEARCH_GUIDE.md +7 -0
- package/docs/en/05_TUI_GUIDE.md +6 -0
- package/docs/en/06_RUNTIME_AND_CANVAS.md +4 -3
- package/docs/en/09_DOCTOR.md +25 -8
- package/docs/en/14_PROMPT_SKILLS_AND_MCP_GUIDE.md +63 -13
- package/docs/en/15_CODEX_PROVIDER_SETUP.md +37 -11
- package/docs/en/19_EXTERNAL_CONTROLLER_GUIDE.md +226 -0
- package/docs/en/19_LOCAL_BROWSER_AUTH.md +70 -0
- package/docs/en/20_WORKSPACE_MODES_GUIDE.md +250 -0
- package/docs/en/21_LOCAL_MODEL_BACKENDS_GUIDE.md +283 -0
- package/docs/en/91_DEVELOPMENT.md +237 -0
- package/docs/en/README.md +24 -2
- package/docs/zh/00_QUICK_START.md +89 -19
- package/docs/zh/01_SETTINGS_REFERENCE.md +34 -1
- package/docs/zh/02_START_RESEARCH_GUIDE.md +7 -0
- package/docs/zh/05_TUI_GUIDE.md +6 -0
- package/docs/zh/09_DOCTOR.md +26 -9
- package/docs/zh/14_PROMPT_SKILLS_AND_MCP_GUIDE.md +63 -13
- package/docs/zh/15_CODEX_PROVIDER_SETUP.md +37 -11
- package/docs/zh/19_EXTERNAL_CONTROLLER_GUIDE.md +226 -0
- package/docs/zh/19_LOCAL_BROWSER_AUTH.md +68 -0
- package/docs/zh/20_WORKSPACE_MODES_GUIDE.md +251 -0
- package/docs/zh/21_LOCAL_MODEL_BACKENDS_GUIDE.md +281 -0
- package/docs/zh/README.md +24 -2
- package/install.sh +46 -4
- package/package.json +2 -1
- package/pyproject.toml +1 -1
- package/src/deepscientist/__init__.py +1 -1
- package/src/deepscientist/acp/envelope.py +6 -0
- package/src/deepscientist/artifact/service.py +647 -22
- package/src/deepscientist/bash_exec/service.py +234 -9
- package/src/deepscientist/bridges/connectors.py +8 -2
- package/src/deepscientist/cli.py +115 -19
- package/src/deepscientist/codex_cli_compat.py +367 -22
- package/src/deepscientist/config/models.py +2 -1
- package/src/deepscientist/config/service.py +183 -13
- package/src/deepscientist/daemon/api/handlers.py +255 -31
- package/src/deepscientist/daemon/api/router.py +9 -0
- package/src/deepscientist/daemon/app.py +1146 -105
- package/src/deepscientist/diagnostics/__init__.py +6 -0
- package/src/deepscientist/diagnostics/runner_failures.py +130 -0
- package/src/deepscientist/doctor.py +207 -3
- package/src/deepscientist/gitops/__init__.py +10 -1
- package/src/deepscientist/gitops/diff.py +129 -0
- package/src/deepscientist/gitops/service.py +4 -1
- package/src/deepscientist/mcp/server.py +39 -0
- package/src/deepscientist/prompts/builder.py +275 -34
- package/src/deepscientist/quest/layout.py +15 -2
- package/src/deepscientist/quest/service.py +707 -55
- package/src/deepscientist/quest/stage_views.py +6 -1
- package/src/deepscientist/runners/codex.py +143 -43
- package/src/deepscientist/shared.py +19 -0
- package/src/deepscientist/skills/__init__.py +2 -2
- package/src/deepscientist/skills/installer.py +196 -5
- package/src/deepscientist/skills/registry.py +66 -0
- package/src/prompts/connectors/qq.md +18 -8
- package/src/prompts/connectors/weixin.md +16 -6
- package/src/prompts/contracts/shared_interaction.md +14 -2
- package/src/prompts/system.md +23 -5
- package/src/prompts/system_copilot.md +56 -0
- package/src/skills/analysis-campaign/SKILL.md +1 -0
- package/src/skills/baseline/SKILL.md +8 -0
- package/src/skills/decision/SKILL.md +8 -0
- package/src/skills/experiment/SKILL.md +8 -0
- package/src/skills/figure-polish/SKILL.md +1 -0
- package/src/skills/finalize/SKILL.md +1 -0
- package/src/skills/idea/SKILL.md +1 -0
- package/src/skills/intake-audit/SKILL.md +8 -0
- package/src/skills/mentor/SKILL.md +217 -0
- package/src/skills/mentor/references/correction-rules.md +210 -0
- package/src/skills/mentor/references/knowledge-profile.md +91 -0
- package/src/skills/mentor/references/persona-profile.md +138 -0
- package/src/skills/mentor/references/taste-profile.md +128 -0
- package/src/skills/mentor/references/thought-style-profile.md +138 -0
- package/src/skills/mentor/references/work-profile.md +289 -0
- package/src/skills/mentor/references/workflow-profile.md +240 -0
- package/src/skills/optimize/SKILL.md +1 -0
- package/src/skills/rebuttal/SKILL.md +1 -0
- package/src/skills/review/SKILL.md +1 -0
- package/src/skills/scout/SKILL.md +8 -0
- package/src/skills/write/SKILL.md +1 -0
- package/src/tui/dist/app/AppContainer.js +19 -11
- package/src/tui/dist/index.js +4 -1
- package/src/tui/dist/lib/api.js +33 -3
- package/src/tui/package.json +1 -1
- package/src/ui/dist/assets/AiManusChatView-Bv-Z8YpU.js +204 -0
- package/src/ui/dist/assets/AnalysisPlugin-BCKAfjba.js +1 -0
- package/src/ui/dist/assets/CliPlugin-BCKcpc35.js +109 -0
- package/src/ui/dist/assets/CodeEditorPlugin-DbOfSJ8K.js +2 -0
- package/src/ui/dist/assets/CodeViewerPlugin-CbaFRrUU.js +270 -0
- package/src/ui/dist/assets/DocViewerPlugin-DAjLVeQD.js +7 -0
- package/src/ui/dist/assets/GitCommitViewerPlugin-CIUqbUDO.js +1 -0
- package/src/ui/dist/assets/GitDiffViewerPlugin-CQACjoAA.js +6 -0
- package/src/ui/dist/assets/GitSnapshotViewer-0r4nLPke.js +30 -0
- package/src/ui/dist/assets/ImageViewerPlugin-nBOmI2v_.js +26 -0
- package/src/ui/dist/assets/LabCopilotPanel-BHxOxF4z.js +14 -0
- package/src/ui/dist/assets/LabPlugin-BKoZGs95.js +22 -0
- package/src/ui/dist/assets/LatexPlugin-ZwtV8pIp.js +25 -0
- package/src/ui/dist/assets/MarkdownViewerPlugin-DKqVfKyW.js +128 -0
- package/src/ui/dist/assets/MarketplacePlugin-BwxStZ9D.js +13 -0
- package/src/ui/dist/assets/NotebookEditor-BEQhaQbt.js +81 -0
- package/src/ui/dist/assets/{NotebookEditor-CccQYZjX.css → NotebookEditor-BHH8rdGj.css} +1 -1
- package/src/ui/dist/assets/NotebookEditor-BOr3x3Ej.css +1 -0
- package/src/ui/dist/assets/NotebookEditor-DB9N_T9q.js +361 -0
- package/src/ui/dist/assets/PdfLoader-Cy5jtWrr.css +1 -0
- package/src/ui/dist/assets/PdfLoader-eWBONbQP.js +16 -0
- package/src/ui/dist/assets/PdfMarkdownPlugin-D22YOZL3.js +1 -0
- package/src/ui/dist/assets/PdfViewerPlugin-c-RK9DLM.js +17 -0
- package/src/ui/dist/assets/PdfViewerPlugin-nwwE-fjJ.css +1 -0
- package/src/ui/dist/assets/SearchPlugin-CxF9ytAx.js +16 -0
- package/src/ui/dist/assets/SearchPlugin-DA4en4hK.css +1 -0
- package/src/ui/dist/assets/TextViewerPlugin-C5xqeeUH.js +54 -0
- package/src/ui/dist/assets/VNCViewer-BoLGLnHz.js +11 -0
- package/src/ui/dist/assets/bot-DREQOxzP.js +6 -0
- package/src/ui/dist/assets/browser-CTB2jwNe.js +8 -0
- package/src/ui/dist/assets/chevron-up-C9Qpx4DE.js +6 -0
- package/src/ui/dist/assets/code-WlFHE7z_.js +6 -0
- package/src/ui/dist/assets/file-content-BZMz3RYp.js +1 -0
- package/src/ui/dist/assets/file-diff-panel-CQhw0jS2.js +1 -0
- package/src/ui/dist/assets/file-jump-queue-DA-SdG__.js +1 -0
- package/src/ui/dist/assets/file-socket-CfQPKQKj.js +1 -0
- package/src/ui/dist/assets/git-commit-horizontal-DxZ8DCZh.js +6 -0
- package/src/ui/dist/assets/image-Bgl4VIyx.js +6 -0
- package/src/ui/dist/assets/index-BpV6lusQ.css +33 -0
- package/src/ui/dist/assets/index-CBNVuWcP.js +2496 -0
- package/src/ui/dist/assets/index-CwNu1aH4.js +11 -0
- package/src/ui/dist/assets/index-DrUnlf6K.js +1 -0
- package/src/ui/dist/assets/index-NW-h8VzN.js +1 -0
- package/src/ui/dist/assets/monaco-CiHMMNH_.js +1 -0
- package/src/ui/dist/assets/pdf-effect-queue-J8OnM0jE.js +6 -0
- package/src/ui/dist/assets/plugin-monaco-C8UgLomw.js +19 -0
- package/src/ui/dist/assets/plugin-notebook-HbW2K-1c.js +169 -0
- package/src/ui/dist/assets/plugin-pdf-CR8hgQBV.js +357 -0
- package/src/ui/dist/assets/plugin-terminal-MXFIPun8.js +227 -0
- package/src/ui/dist/assets/popover-CLc0pPP8.js +1 -0
- package/src/ui/dist/assets/project-sync-C9IdzdZW.js +1 -0
- package/src/ui/dist/assets/select-Cs2PmzwL.js +11 -0
- package/src/ui/dist/assets/sigma-ClKcHAXm.js +6 -0
- package/src/ui/dist/assets/trash-DwpbFr3w.js +11 -0
- package/src/ui/dist/assets/useCliAccess-NQ8m0Let.js +1 -0
- package/src/ui/dist/assets/useFileDiffOverlay-FuhcnKiw.js +1 -0
- package/src/ui/dist/assets/wrap-text-BC-Hltpd.js +11 -0
- package/src/ui/dist/assets/zoom-out-E_gaeAxL.js +11 -0
- package/src/ui/dist/index.html +5 -2
- package/src/ui/dist/assets/AiManusChatView-DDjbFnbt.js +0 -26597
- package/src/ui/dist/assets/AnalysisPlugin-Yb5IdmaU.js +0 -123
- package/src/ui/dist/assets/CliPlugin-e64sreyu.js +0 -31037
- package/src/ui/dist/assets/CodeEditorPlugin-C4D2TIkU.js +0 -427
- package/src/ui/dist/assets/CodeViewerPlugin-BVoNZIvC.js +0 -905
- package/src/ui/dist/assets/DocViewerPlugin-CLChbllo.js +0 -278
- package/src/ui/dist/assets/GitDiffViewerPlugin-C4xeFyFQ.js +0 -2661
- package/src/ui/dist/assets/ImageViewerPlugin-OiMUAcLi.js +0 -500
- package/src/ui/dist/assets/LabCopilotPanel-BjD2ThQF.js +0 -4104
- package/src/ui/dist/assets/LabPlugin-DQPg-NrB.js +0 -2677
- package/src/ui/dist/assets/LatexPlugin-CI05XAV9.js +0 -1792
- package/src/ui/dist/assets/MarkdownViewerPlugin-DpeBLYZf.js +0 -308
- package/src/ui/dist/assets/MarketplacePlugin-DolE58Q2.js +0 -413
- package/src/ui/dist/assets/NotebookEditor-7Qm2rSWD.js +0 -4214
- package/src/ui/dist/assets/NotebookEditor-C1kWaxKi.js +0 -84873
- package/src/ui/dist/assets/NotebookEditor-C3VQ7ylN.css +0 -1405
- package/src/ui/dist/assets/PdfLoader-BfOHw8Zw.js +0 -25468
- package/src/ui/dist/assets/PdfLoader-C-Y707R3.css +0 -49
- package/src/ui/dist/assets/PdfMarkdownPlugin-BulDREv1.js +0 -409
- package/src/ui/dist/assets/PdfViewerPlugin-C-daaOaL.js +0 -3095
- package/src/ui/dist/assets/PdfViewerPlugin-DQ11QcSf.css +0 -3627
- package/src/ui/dist/assets/SearchPlugin-CjpaiJ3A.js +0 -741
- package/src/ui/dist/assets/SearchPlugin-DDMrGDkh.css +0 -379
- package/src/ui/dist/assets/TextViewerPlugin-BxIyqPQC.js +0 -472
- package/src/ui/dist/assets/VNCViewer-HAg9mF7M.js +0 -18821
- package/src/ui/dist/assets/awareness-C0NPR2Dj.js +0 -292
- package/src/ui/dist/assets/bot-0DYntytV.js +0 -21
- package/src/ui/dist/assets/browser-BAcuE0Xj.js +0 -2895
- package/src/ui/dist/assets/code-B20Slj_w.js +0 -17
- package/src/ui/dist/assets/file-content-DT24KFma.js +0 -377
- package/src/ui/dist/assets/file-diff-panel-DK13YPql.js +0 -92
- package/src/ui/dist/assets/file-jump-queue-r5XKgJEV.js +0 -16
- package/src/ui/dist/assets/file-socket-B4T2o4nR.js +0 -58
- package/src/ui/dist/assets/function-B5QZkkHC.js +0 -1895
- package/src/ui/dist/assets/image-DSeR_sDS.js +0 -18
- package/src/ui/dist/assets/index-BrFje2Uk.js +0 -120
- package/src/ui/dist/assets/index-BwRJaoTl.js +0 -25
- package/src/ui/dist/assets/index-D_E4281X.js +0 -221322
- package/src/ui/dist/assets/index-DnYB3xb1.js +0 -159
- package/src/ui/dist/assets/index-G7AcWcMu.css +0 -12594
- package/src/ui/dist/assets/monaco-LExaAN3Y.js +0 -623
- package/src/ui/dist/assets/pdf-effect-queue-BJk5okWJ.js +0 -47
- package/src/ui/dist/assets/pdf_viewer-e0g1is2C.js +0 -8206
- package/src/ui/dist/assets/popover-D3Gg_FoV.js +0 -476
- package/src/ui/dist/assets/project-sync-C_ygLlVU.js +0 -297
- package/src/ui/dist/assets/select-CpAK6uWm.js +0 -1690
- package/src/ui/dist/assets/sigma-DEccaSgk.js +0 -22
- package/src/ui/dist/assets/square-check-big-uUfyVsbD.js +0 -17
- package/src/ui/dist/assets/trash-CXvwwSe8.js +0 -32
- package/src/ui/dist/assets/useCliAccess-Bnop4mgR.js +0 -957
- package/src/ui/dist/assets/useFileDiffOverlay-B8eUAX0I.js +0 -53
- package/src/ui/dist/assets/wrap-text-9vbOBpkW.js +0 -35
- package/src/ui/dist/assets/yjs-DncrqiZ8.js +0 -11243
- package/src/ui/dist/assets/zoom-out-BgVMmOW4.js +0 -34
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
const _h="/ui/assets/pdf.worker.min-yatZIOMy.mjs";var pe={};pe.d=(l,t)=>{for(var e in t)pe.o(t,e)&&!pe.o(l,e)&&Object.defineProperty(l,e,{enumerable:!0,get:t[e]})};pe.o=(l,t)=>Object.prototype.hasOwnProperty.call(l,t);var F=globalThis.pdfjsLib={};pe.d(F,{AbortException:()=>Ut,AnnotationEditorLayer:()=>Va,AnnotationEditorParamsType:()=>V,AnnotationEditorType:()=>B,AnnotationEditorUIManager:()=>ve,AnnotationLayer:()=>Fa,AnnotationMode:()=>Vt,ColorPicker:()=>Tn,DOMSVGFactory:()=>Gi,DrawLayer:()=>$a,FeatureTest:()=>ct,GlobalWorkerOptions:()=>me,ImageKind:()=>je,InvalidPDFException:()=>Ai,MissingPDFException:()=>_e,OPS:()=>St,OutputScale:()=>_i,PDFDataRangeTransport:()=>yn,PDFDateString:()=>Js,PDFWorker:()=>He,PasswordResponses:()=>Wn,PermissionFlag:()=>zn,PixelsPerInch:()=>ne,RenderingCancelledException:()=>Oi,TextLayer:()=>xi,TouchManager:()=>tn,UnexpectedResponseException:()=>Ve,Util:()=>M,VerbosityLevel:()=>Ge,XfaLayer:()=>An,build:()=>ma,createValidAbsoluteUrl:()=>Yn,fetchData:()=>Ke,getDocument:()=>oa,getFilenameFromUrl:()=>nr,getPdfFilenameFromUrl:()=>rr,getXfaPageViewport:()=>ar,isDataScheme:()=>Qe,isPdfFile:()=>Bi,noContextMenu:()=>xt,normalizeUnicode:()=>er,setLayerDimensions:()=>qt,shadow:()=>H,stopEvent:()=>wt,version:()=>ga});const lt=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),Qs=[1,0,0,1,0,0],wi=[.001,0,0,.001,0,0],$n=1e7,ni=1.35,yt={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},Vt={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Un="pdfjs_internal_editor_",B={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},V={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35,DRAW_STEP:41},zn={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},rt={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},je={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},it={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,WIDGET:20},oe={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},Ge={ERRORS:0,WARNINGS:1,INFOS:5},St={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93},Wn={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Xe=Ge.WARNINGS;function Gn(l){Number.isInteger(l)&&(Xe=l)}function Xn(){return Xe}function qe(l){Xe>=Ge.INFOS&&console.log(`Info: ${l}`)}function j(l){Xe>=Ge.WARNINGS&&console.log(`Warning: ${l}`)}function z(l){throw new Error(l)}function Z(l,t){l||z(t)}function qn(l){switch(l?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function Yn(l,t=null,e=null){if(!l)return null;try{if(e&&typeof l=="string"&&(e.addDefaultProtocol&&l.startsWith("www.")&&l.match(/\./g)?.length>=2&&(l=`http://${l}`),e.tryConvertEncoding))try{l=tr(l)}catch{}const i=t?new URL(l,t):new URL(l);if(qn(i))return i}catch{}return null}function H(l,t,e,i=!1){return Object.defineProperty(l,t,{value:e,enumerable:!i,configurable:!0,writable:!1}),e}const zt=function(){function t(e,i){this.message=e,this.name=i}return t.prototype=new Error,t.constructor=t,t}();class Ji extends zt{constructor(t,e){super(t,"PasswordException"),this.code=e}}class ri extends zt{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}let Ai=class extends zt{constructor(t){super(t,"InvalidPDFException")}},_e=class extends zt{constructor(t){super(t,"MissingPDFException")}},Ve=class extends zt{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}};class Kn extends zt{constructor(t){super(t,"FormatError")}}let Ut=class extends zt{constructor(t){super(t,"AbortException")}};function Zs(l){(typeof l!="object"||l?.length===void 0)&&z("Invalid argument for bytesToString");const t=l.length,e=8192;if(t<e)return String.fromCharCode.apply(null,l);const i=[];for(let s=0;s<t;s+=e){const n=Math.min(s+e,t),r=l.subarray(s,n);i.push(String.fromCharCode.apply(null,r))}return i.join("")}function Ye(l){typeof l!="string"&&z("Invalid argument for stringToBytes");const t=l.length,e=new Uint8Array(t);for(let i=0;i<t;++i)e[i]=l.charCodeAt(i)&255;return e}function Qn(l){return String.fromCharCode(l>>24&255,l>>16&255,l>>8&255,l&255)}function Di(l){const t=Object.create(null);for(const[e,i]of l)t[e]=i;return t}function Zn(){const l=new Uint8Array(4);return l[0]=1,new Uint32Array(l.buffer,0,1)[0]===1}function Jn(){try{return new Function(""),!0}catch{return!1}}class ct{static get isLittleEndian(){return H(this,"isLittleEndian",Zn())}static get isEvalSupported(){return H(this,"isEvalSupported",Jn())}static get isOffscreenCanvasSupported(){return H(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return H(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get platform(){return typeof navigator<"u"&&typeof navigator?.platform=="string"?H(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:typeof navigator?.userAgent=="string"&&navigator.userAgent.includes("Firefox")}):H(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){return H(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const ai=Array.from(Array(256).keys(),l=>l.toString(16).padStart(2,"0"));let M=class{static makeHexColor(t,e,i){return`#${ai[t]}${ai[e]}${ai[i]}`}static scaleMinMax(t,e){let i;t[0]?(t[0]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[3],e[3]*=t[3]):(i=e[0],e[0]=e[1],e[1]=i,i=e[2],e[2]=e[3],e[3]=i,t[1]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static applyTransform(t,e){const i=t[0]*e[0]+t[1]*e[2]+e[4],s=t[0]*e[1]+t[1]*e[3]+e[5];return[i,s]}static applyInverseTransform(t,e){const i=e[0]*e[3]-e[1]*e[2],s=(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/i,n=(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/i;return[s,n]}static getAxialAlignedBoundingBox(t,e){const i=this.applyTransform(t,e),s=this.applyTransform(t.slice(2,4),e),n=this.applyTransform([t[0],t[3]],e),r=this.applyTransform([t[2],t[1]],e);return[Math.min(i[0],s[0],n[0],r[0]),Math.min(i[1],s[1],n[1],r[1]),Math.max(i[0],s[0],n[0],r[0]),Math.max(i[1],s[1],n[1],r[1])]}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t){const e=[t[0],t[2],t[1],t[3]],i=t[0]*e[0]+t[1]*e[2],s=t[0]*e[1]+t[1]*e[3],n=t[2]*e[0]+t[3]*e[2],r=t[2]*e[1]+t[3]*e[3],a=(i+r)/2,o=Math.sqrt((i+r)**2-4*(i*r-n*s))/2,h=a+o||1,c=a-o||1;return[Math.sqrt(h),Math.sqrt(c)]}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const i=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),s=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(i>s)return null;const n=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),r=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return n>r?null:[i,n,s,r]}static#t(t,e,i,s,n,r,a,o,h,c){if(h<=0||h>=1)return;const d=1-h,u=h*h,f=u*h,p=d*(d*(d*t+3*h*e)+3*u*i)+f*s,g=d*(d*(d*n+3*h*r)+3*u*a)+f*o;c[0]=Math.min(c[0],p),c[1]=Math.min(c[1],g),c[2]=Math.max(c[2],p),c[3]=Math.max(c[3],g)}static#e(t,e,i,s,n,r,a,o,h,c,d,u){if(Math.abs(h)<1e-12){Math.abs(c)>=1e-12&&this.#t(t,e,i,s,n,r,a,o,-d/c,u);return}const f=c**2-4*d*h;if(f<0)return;const p=Math.sqrt(f),g=2*h;this.#t(t,e,i,s,n,r,a,o,(-c+p)/g,u),this.#t(t,e,i,s,n,r,a,o,(-c-p)/g,u)}static bezierBoundingBox(t,e,i,s,n,r,a,o,h){return h?(h[0]=Math.min(h[0],t,a),h[1]=Math.min(h[1],e,o),h[2]=Math.max(h[2],t,a),h[3]=Math.max(h[3],e,o)):h=[Math.min(t,a),Math.min(e,o),Math.max(t,a),Math.max(e,o)],this.#e(t,i,n,a,e,s,r,o,3*(-t+3*(i-n)+a),6*(t-2*i+n),3*(i-t),h),this.#e(t,i,n,a,e,s,r,o,3*(-e+3*(s-r)+o),6*(e-2*s+r),3*(s-e),h),h}};function tr(l){return decodeURIComponent(escape(l))}let oi=null,ts=null;function er(l){return oi||(oi=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,ts=new Map([["ſt","ſt"]])),l.replaceAll(oi,(t,e,i)=>e?e.normalize("NFKC"):ts.get(i))}function ir(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const l=new Uint8Array(32);return crypto.getRandomValues(l),Zs(l)}const Fi="pdfjs_internal_id_";function sr(l){return Uint8Array.prototype.toBase64?l.toBase64():btoa(Zs(l))}typeof Promise.try!="function"&&(Promise.try=function(l,...t){return new Promise(e=>{e(l(...t))})});const Nt="http://www.w3.org/2000/svg";let ne=class{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF};async function Ke(l,t="text"){if(ue(l,document.baseURI)){const e=await fetch(l);if(!e.ok)throw new Error(e.statusText);switch(t){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"json":return e.json()}return e.text()}return new Promise((e,i)=>{const s=new XMLHttpRequest;s.open("GET",l,!0),s.responseType=t,s.onreadystatechange=()=>{if(s.readyState===XMLHttpRequest.DONE){if(s.status===200||s.status===0){switch(t){case"arraybuffer":case"blob":case"json":e(s.response);return}e(s.responseText);return}i(new Error(s.statusText))}},s.send(null)})}class Pe{constructor({viewBox:t,userUnit:e,scale:i,rotation:s,offsetX:n=0,offsetY:r=0,dontFlip:a=!1}){this.viewBox=t,this.userUnit=e,this.scale=i,this.rotation=s,this.offsetX=n,this.offsetY=r,i*=e;const o=(t[2]+t[0])/2,h=(t[3]+t[1])/2;let c,d,u,f;switch(s%=360,s<0&&(s+=360),s){case 180:c=-1,d=0,u=0,f=1;break;case 90:c=0,d=1,u=1,f=0;break;case 270:c=0,d=-1,u=-1,f=0;break;case 0:c=1,d=0,u=0,f=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(u=-u,f=-f);let p,g,b,m;c===0?(p=Math.abs(h-t[1])*i+n,g=Math.abs(o-t[0])*i+r,b=(t[3]-t[1])*i,m=(t[2]-t[0])*i):(p=Math.abs(o-t[0])*i+n,g=Math.abs(h-t[1])*i+r,b=(t[2]-t[0])*i,m=(t[3]-t[1])*i),this.transform=[c*i,d*i,u*i,f*i,p-c*i*o-u*i*h,g-d*i*o-f*i*h],this.width=b,this.height=m}get rawDims(){const{userUnit:t,viewBox:e}=this,i=e.map(s=>s*t);return H(this,"rawDims",{pageWidth:i[2]-i[0],pageHeight:i[3]-i[1],pageX:i[0],pageY:i[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:i=this.offsetX,offsetY:s=this.offsetY,dontFlip:n=!1}={}){return new Pe({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}convertToViewportPoint(t,e){return M.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=M.applyTransform([t[0],t[1]],this.transform),i=M.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],i[0],i[1]]}convertToPdfPoint(t,e){return M.applyInverseTransform([t,e],this.transform)}}let Oi=class extends zt{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}};function Qe(l){const t=l.length;let e=0;for(;e<t&&l[e].trim()==="";)e++;return l.substring(e,e+5).toLowerCase()==="data:"}function Bi(l){return typeof l=="string"&&/\.pdf$/i.test(l)}function nr(l){return[l]=l.split(/[#?]/,1),l.substring(l.lastIndexOf("/")+1)}function rr(l,t="document.pdf"){if(typeof l!="string")return t;if(Qe(l))return j('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const e=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,i=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,s=e.exec(l);let n=i.exec(s[1])||i.exec(s[2])||i.exec(s[3]);if(n&&(n=n[0],n.includes("%")))try{n=i.exec(decodeURIComponent(n))[0]}catch{}return n||t}class es{started=Object.create(null);times=[];time(t){t in this.started&&j(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||j(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let e=0;for(const{name:i}of this.times)e=Math.max(i.length,e);for(const{name:i,start:s,end:n}of this.times)t.push(`${i.padEnd(e)} ${n-s}ms
|
|
2
|
+
`);return t.join("")}}function ue(l,t){try{const{protocol:e}=t?new URL(l,t):new URL(l);return e==="http:"||e==="https:"}catch{return!1}}function xt(l){l.preventDefault()}function wt(l){l.preventDefault(),l.stopPropagation()}let Js=class{static#t;static toDateObject(t){if(!t||typeof t!="string")return null;this.#t||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");const e=this.#t.exec(t);if(!e)return null;const i=parseInt(e[1],10);let s=parseInt(e[2],10);s=s>=1&&s<=12?s-1:0;let n=parseInt(e[3],10);n=n>=1&&n<=31?n:1;let r=parseInt(e[4],10);r=r>=0&&r<=23?r:0;let a=parseInt(e[5],10);a=a>=0&&a<=59?a:0;let o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;const h=e[7]||"Z";let c=parseInt(e[8],10);c=c>=0&&c<=23?c:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,h==="-"?(r+=c,a+=d):h==="+"&&(r-=c,a-=d),new Date(Date.UTC(i,s,n,r,a,o))}};function ar(l,{scale:t=1,rotation:e=0}){const{width:i,height:s}=l.attributes.style,n=[0,0,parseInt(i),parseInt(s)];return new Pe({viewBox:n,userUnit:1,scale:t,rotation:e})}function ji(l){if(l.startsWith("#")){const t=parseInt(l.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return l.startsWith("rgb(")?l.slice(4,-1).split(",").map(t=>parseInt(t)):l.startsWith("rgba(")?l.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(j(`Not a valid color format: "${l}"`),[0,0,0])}function or(l){const t=document.createElement("span");t.style.visibility="hidden",document.body.append(t);for(const e of l.keys()){t.style.color=e;const i=window.getComputedStyle(t).color;l.set(e,ji(i))}t.remove()}function G(l){const{a:t,b:e,c:i,d:s,e:n,f:r}=l.getTransform();return[t,e,i,s,n,r]}function Ct(l){const{a:t,b:e,c:i,d:s,e:n,f:r}=l.getTransform().invertSelf();return[t,e,i,s,n,r]}function qt(l,t,e=!1,i=!0){if(t instanceof Pe){const{pageWidth:s,pageHeight:n}=t.rawDims,{style:r}=l,a=ct.isCSSRoundSupported,o=`var(--scale-factor) * ${s}px`,h=`var(--scale-factor) * ${n}px`,c=a?`round(down, ${o}, var(--scale-round-x, 1px))`:`calc(${o})`,d=a?`round(down, ${h}, var(--scale-round-y, 1px))`:`calc(${h})`;!e||t.rotation%180===0?(r.width=c,r.height=d):(r.width=d,r.height=c)}i&&l.setAttribute("data-main-rotation",t.rotation)}let _i=class{constructor(){const t=window.devicePixelRatio||1;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}};class ge{#t=null;#e=null;#i;#s=null;#r=null;static#n=null;constructor(t){this.#i=t,ge.#n||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button"})}render(){const t=this.#t=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=this.#i._uiManager._signal;t.addEventListener("contextmenu",xt,{signal:e}),t.addEventListener("pointerdown",ge.#a,{signal:e});const i=this.#s=document.createElement("div");i.className="buttons",t.append(i);const s=this.#i.toolbarPosition;if(s){const{style:n}=t,r=this.#i._uiManager.direction==="ltr"?1-s[0]:s[0];n.insetInlineEnd=`${100*r}%`,n.top=`calc(${100*s[1]}% + var(--editor-toolbar-vert-offset))`}return this.#u(),t}get div(){return this.#t}static#a(t){t.stopPropagation()}#l(t){this.#i._focusEventsAllowed=!1,wt(t)}#c(t){this.#i._focusEventsAllowed=!0,wt(t)}#h(t){const e=this.#i._uiManager._signal;t.addEventListener("focusin",this.#l.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#c.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",xt,{signal:e})}hide(){this.#t.classList.add("hidden"),this.#e?.hideDropdown()}show(){this.#t.classList.remove("hidden"),this.#r?.shown()}#u(){const{editorType:t,_uiManager:e}=this.#i,i=document.createElement("button");i.className="delete",i.tabIndex=0,i.setAttribute("data-l10n-id",ge.#n[t]),this.#h(i),i.addEventListener("click",s=>{e.delete()},{signal:e._signal}),this.#s.append(i)}get#d(){const t=document.createElement("div");return t.className="divider",t}async addAltText(t){const e=await t.render();this.#h(e),this.#s.prepend(e,this.#d),this.#r=t}addColorPicker(t){this.#e=t;const e=t.renderButton();this.#h(e),this.#s.prepend(e,this.#d)}remove(){this.#t.remove(),this.#e?.destroy(),this.#e=null}}class lr{#t=null;#e=null;#i;constructor(t){this.#i=t}#s(){const t=this.#e=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",xt,{signal:this.#i._signal});const e=this.#t=document.createElement("div");return e.className="buttons",t.append(e),this.#n(),t}#r(t,e){let i=0,s=0;for(const n of t){const r=n.y+n.height;if(r<i)continue;const a=n.x+(e?n.width:0);if(r>i){s=a,i=r;continue}e?a>s&&(s=a):a<s&&(s=a)}return[e?1-s:s,i]}show(t,e,i){const[s,n]=this.#r(e,i),{style:r}=this.#e||=this.#s();t.append(this.#e),r.insetInlineEnd=`${100*s}%`,r.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){this.#e.remove()}#n(){const t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const i=this.#i._signal;t.addEventListener("contextmenu",xt,{signal:i}),t.addEventListener("click",()=>{this.#i.highlightSelection("floating_button")},{signal:i}),this.#t.append(t)}}function $e(l,t,e){for(const i of e)t.addEventListener(i,l[i].bind(l))}class hr{#t=0;get id(){return`${Un}${this.#t++}`}}class Hi{#t=ir();#e=0;#i=null;static get _isSVGFittingCanvas(){const t='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',i=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),s=new Image;s.src=t;const n=s.decode().then(()=>(i.drawImage(s,0,0,1,1,0,0,1,3),new Uint32Array(i.getImageData(0,0,1,1).data.buffer)[0]===0));return H(this,"_isSVGFittingCanvas",n)}async#s(t,e){this.#i||=new Map;let i=this.#i.get(t);if(i===null)return null;if(i?.bitmap)return i.refCounter+=1,i;try{i||={bitmap:null,id:`image_${this.#t}_${this.#e++}`,refCounter:0,isSvg:!1};let s;if(typeof e=="string"?(i.url=e,s=await Ke(e,"blob")):e instanceof File?s=i.file=e:e instanceof Blob&&(s=e),s.type==="image/svg+xml"){const n=Hi._isSVGFittingCanvas,r=new FileReader,a=new Image,o=new Promise((h,c)=>{a.onload=()=>{i.bitmap=a,i.isSvg=!0,h()},r.onload=async()=>{const d=i.svgUrl=r.result;a.src=await n?`${d}#svgView(preserveAspectRatio(none))`:d},a.onerror=r.onerror=c});r.readAsDataURL(s),await o}else i.bitmap=await createImageBitmap(s);i.refCounter=1}catch(s){j(s),i=null}return this.#i.set(t,i),i&&this.#i.set(i.id,i),i}async getFromFile(t){const{lastModified:e,name:i,size:s,type:n}=t;return this.#s(`${e}_${i}_${s}_${n}`,t)}async getFromUrl(t){return this.#s(t,t)}async getFromBlob(t,e){const i=await e;return this.#s(t,i)}async getFromId(t){this.#i||=new Map;const e=this.#i.get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){const{blobPromise:i}=e;return delete e.blobPromise,this.getFromBlob(e.id,i)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#i||=new Map;let i=this.#i.get(t);if(i?.bitmap)return i.refCounter+=1,i;const s=new OffscreenCanvas(e.width,e.height);return s.getContext("2d").drawImage(e,0,0),i={bitmap:s.transferToImageBitmap(),id:`image_${this.#t}_${this.#e++}`,refCounter:1,isSvg:!1},this.#i.set(t,i),this.#i.set(i.id,i),i}getSvgUrl(t){const e=this.#i.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#i||=new Map;const e=this.#i.get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;const{bitmap:i}=e;if(!e.url&&!e.file){const s=new OffscreenCanvas(i.width,i.height);s.getContext("bitmaprenderer").transferFromImageBitmap(i),e.blobPromise=s.convertToBlob()}i.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#t}_`)}}class cr{#t=[];#e=!1;#i;#s=-1;constructor(t=128){this.#i=t}add({cmd:t,undo:e,post:i,mustExec:s,type:n=NaN,overwriteIfSameType:r=!1,keepUndo:a=!1}){if(s&&t(),this.#e)return;const o={cmd:t,undo:e,post:i,type:n};if(this.#s===-1){this.#t.length>0&&(this.#t.length=0),this.#s=0,this.#t.push(o);return}if(r&&this.#t[this.#s].type===n){a&&(o.undo=this.#t[this.#s].undo),this.#t[this.#s]=o;return}const h=this.#s+1;h===this.#i?this.#t.splice(0,1):(this.#s=h,h<this.#t.length&&this.#t.splice(h)),this.#t.push(o)}undo(){if(this.#s===-1)return;this.#e=!0;const{undo:t,post:e}=this.#t[this.#s];t(),e?.(),this.#e=!1,this.#s-=1}redo(){if(this.#s<this.#t.length-1){this.#s+=1,this.#e=!0;const{cmd:t,post:e}=this.#t[this.#s];t(),e?.(),this.#e=!1}}hasSomethingToUndo(){return this.#s!==-1}hasSomethingToRedo(){return this.#s<this.#t.length-1}cleanType(t){if(this.#s!==-1){for(let e=this.#s;e>=0;e--)if(this.#t[e].type!==t){this.#t.splice(e+1,this.#s-e),this.#s=e;return}this.#t.length=0,this.#s=-1}}destroy(){this.#t=null}}class Ce{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=ct.platform;for(const[i,s,n={}]of t)for(const r of i){const a=r.startsWith("mac+");e&&a?(this.callbacks.set(r.slice(4),{callback:s,options:n}),this.allKeys.add(r.split("+").at(-1))):!e&&!a&&(this.callbacks.set(r,{callback:s,options:n}),this.allKeys.add(r.split("+").at(-1)))}}#t(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);const e=this.buffer.join("+");return this.buffer.length=0,e}exec(t,e){if(!this.allKeys.has(e.key))return;const i=this.callbacks.get(this.#t(e));if(!i)return;const{callback:s,options:{bubbles:n=!1,args:r=[],checker:a=null}}=i;a&&!a(t,e)||(s.bind(t,...r,e)(),n||wt(e))}}class Vi{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return or(t),H(this,"_colors",t)}convert(t){const e=ji(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[i,s]of this._colors)if(s.every((n,r)=>n===e[r]))return Vi._colorsMapping.get(i);return e}getHexCode(t){const e=this._colors.get(t);return e?M.makeHexColor(...e):t}}let ve=class vi{#t=new AbortController;#e=null;#i=new Map;#s=new Map;#r=null;#n=null;#a=null;#l=new cr;#c=null;#h=null;#u=0;#d=new Set;#f=null;#o=null;#p=new Set;_editorUndoBar=null;#m=!1;#g=!1;#b=!1;#y=null;#w=null;#A=null;#v=null;#S=!1;#x=null;#L=new hr;#E=!1;#T=!1;#P=null;#I=null;#M=null;#D=null;#C=B.NONE;#_=new Set;#F=null;#k=null;#H=null;#U={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#j=[0,0];#O=null;#B=null;#z=null;#R=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const t=vi.prototype,e=r=>r.#B.contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&r.hasSomethingToControl(),i=(r,{target:a})=>{if(a instanceof HTMLInputElement){const{type:o}=a;return o!=="text"&&o!=="number"}return!0},s=this.TRANSLATE_SMALL,n=this.TRANSLATE_BIG;return H(this,"_keyboardManager",new Ce([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:i}],[["ctrl+z","mac+meta+z"],t.undo,{checker:i}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:i}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:i}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&r.#B.contains(a)&&!r.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&r.#B.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-s,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}]]))}constructor(t,e,i,s,n,r,a,o,h,c,d,u,f){const p=this._signal=this.#t.signal;this.#B=t,this.#z=e,this.#r=i,this._eventBus=s,s._on("editingaction",this.onEditingAction.bind(this),{signal:p}),s._on("pagechanging",this.onPageChanging.bind(this),{signal:p}),s._on("scalechanging",this.onScaleChanging.bind(this),{signal:p}),s._on("rotationchanging",this.onRotationChanging.bind(this),{signal:p}),s._on("setpreference",this.onSetPreference.bind(this),{signal:p}),s._on("switchannotationeditorparams",g=>this.updateParams(g.type,g.value),{signal:p}),this.#et(),this.#rt(),this.#q(),this.#n=n.annotationStorage,this.#y=n.filterFactory,this.#k=r,this.#v=a||null,this.#m=o,this.#g=h,this.#b=c,this.#D=d||null,this.viewParameters={realScale:ne.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=u||null,this._supportsPinchToZoom=f!==!1}destroy(){this.#R?.resolve(),this.#R=null,this.#t?.abort(),this.#t=null,this._signal=null;for(const t of this.#s.values())t.destroy();this.#s.clear(),this.#i.clear(),this.#p.clear(),this.#e=null,this.#_.clear(),this.#l.destroy(),this.#r?.destroy(),this.#x?.hide(),this.#x=null,this.#w&&(clearTimeout(this.#w),this.#w=null),this.#O&&(clearTimeout(this.#O),this.#O=null),this._editorUndoBar?.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#D}get useNewAltTextFlow(){return this.#g}get useNewAltTextWhenAddingImage(){return this.#b}get hcmFilter(){return H(this,"hcmFilter",this.#k?this.#y.addHCMFilter(this.#k.foreground,this.#k.background):"none")}get direction(){return H(this,"direction",getComputedStyle(this.#B).direction)}get highlightColors(){return H(this,"highlightColors",this.#v?new Map(this.#v.split(",").map(t=>t.split("=").map(e=>e.trim()))):null)}get highlightColorNames(){return H(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#h=t}setMainHighlightColorPicker(t){this.#M=t}editAltText(t,e=!1){this.#r?.editAltText(this,t,e)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){switch(t){case"enableNewAltTextWhenAddingImage":this.#b=e;break}}onPageChanging({pageNumber:t}){this.#u=t-1}focusMainContainer(){this.#B.focus()}findParent(t,e){for(const i of this.#s.values()){const{x:s,y:n,width:r,height:a}=i.div.getBoundingClientRect();if(t>=s&&t<=s+r&&e>=n&&e<=n+a)return i}return null}disableUserSelect(t=!1){this.#z.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#p.add(t)}removeShouldRescale(t){this.#p.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*ne.PDF_TO_CSS_UNITS;for(const e of this.#p)e.onScaleChanging();this.#h?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#V({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#X(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const i of this.#s.values())if(i.hasTextLayer(t))return i;return null}highlightSelection(t=""){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:i,anchorOffset:s,focusNode:n,focusOffset:r}=e,a=e.toString(),h=this.#V(e).closest(".textLayer"),c=this.getSelectionBoxes(h);if(!c)return;e.empty();const d=this.#X(h),u=this.#C===B.NONE,f=()=>{d?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:c,anchorNode:i,anchorOffset:s,focusNode:n,focusOffset:r,text:a}),u&&this.showAllEditors("highlight",!0,!0)};if(u){this.switchToMode(B.HIGHLIGHT,f);return}f()}#J(){const t=document.getSelection();if(!t||t.isCollapsed)return;const i=this.#V(t).closest(".textLayer"),s=this.getSelectionBoxes(i);s&&(this.#x||=new lr(this),this.#x.show(i,s,this.direction==="ltr"))}addToAnnotationStorage(t){!t.isEmpty()&&this.#n&&!this.#n.has(t.id)&&this.#n.setValue(t.id,t)}#tt(){const t=document.getSelection();if(!t||t.isCollapsed){this.#F&&(this.#x?.hide(),this.#F=null,this.#N({hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===this.#F)return;const s=this.#V(t).closest(".textLayer");if(!s){this.#F&&(this.#x?.hide(),this.#F=null,this.#N({hasSelectedText:!1}));return}if(this.#x?.hide(),this.#F=e,this.#N({hasSelectedText:!0}),!(this.#C!==B.HIGHLIGHT&&this.#C!==B.NONE)&&(this.#C===B.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#S=this.isShiftKeyDown,!this.isShiftKeyDown)){const n=this.#C===B.HIGHLIGHT?this.#X(s):null;n?.toggleDrawing();const r=new AbortController,a=this.combinedSignal(r),o=h=>{h.type==="pointerup"&&h.button!==0||(r.abort(),n?.toggleDrawing(!0),h.type==="pointerup"&&this.#G("main_toolbar"))};window.addEventListener("pointerup",o,{signal:a}),window.addEventListener("blur",o,{signal:a})}}#G(t=""){this.#C===B.HIGHLIGHT?this.highlightSelection(t):this.#m&&this.#J()}#et(){document.addEventListener("selectionchange",this.#tt.bind(this),{signal:this._signal})}#it(){if(this.#A)return;this.#A=new AbortController;const t=this.combinedSignal(this.#A);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#st(){this.#A?.abort(),this.#A=null}blur(){if(this.isShiftKeyDown=!1,this.#S&&(this.#S=!1,this.#G("main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of this.#_)if(e.div.contains(t)){this.#I=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#I)return;const[t,e]=this.#I;this.#I=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#q(){if(this.#P)return;this.#P=new AbortController;const t=this.combinedSignal(this.#P);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#nt(){this.#P?.abort(),this.#P=null}#Y(){if(this.#c)return;this.#c=new AbortController;const t=this.combinedSignal(this.#c);document.addEventListener("copy",this.copy.bind(this),{signal:t}),document.addEventListener("cut",this.cut.bind(this),{signal:t}),document.addEventListener("paste",this.paste.bind(this),{signal:t})}#K(){this.#c?.abort(),this.#c=null}#rt(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#q(),this.#Y()}removeEditListeners(){this.#nt(),this.#K()}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const i of this.#o)if(i.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const e of t.dataTransfer.items)for(const i of this.#o)if(i.isHandlingMimeForPasting(e.type)){i.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),this.#e?.commitOrRemove(),!this.hasSelection)return;const e=[];for(const i of this.#_){const s=i.serialize(!0);s&&e.push(s)}e.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();const{clipboardData:e}=t;for(const n of e.items)for(const r of this.#o)if(r.isHandlingMimeForPasting(n.type)){r.paste(n,this.currentLayer);return}let i=e.getData("application/pdfjs");if(!i)return;try{i=JSON.parse(i)}catch(n){j(`paste: "${n.message}".`);return}if(!Array.isArray(i))return;this.unselectAll();const s=this.currentLayer;try{const n=[];for(const o of i){const h=await s.deserialize(o);if(!h)return;n.push(h)}const r=()=>{for(const o of n)this.#Q(o);this.#Z(n)},a=()=>{for(const o of n)o.remove()};this.addCommands({cmd:r,undo:a,mustExec:!0})}catch(n){j(`paste: "${n.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),this.#C!==B.NONE&&!this.isEditorHandlingKeyboard&&vi._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,this.#S&&(this.#S=!1,this.#G("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break}}#N(t){Object.entries(t).some(([i,s])=>this.#U[i]!==s)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#U,t)}),this.#C===B.HIGHLIGHT&&t.hasSelectedEditor===!1&&this.#$([[V.HIGHLIGHT_FREE,!0]]))}#$(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#it(),this.#Y(),this.#N({isEditing:this.#C!==B.NONE,isEmpty:this.#W(),hasSomethingToUndo:this.#l.hasSomethingToUndo(),hasSomethingToRedo:this.#l.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#st(),this.#K(),this.#N({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#o){this.#o=t;for(const e of this.#o)this.#$(e.defaultPropertiesToUpdate)}}getId(){return this.#L.id}get currentLayer(){return this.#s.get(this.#u)}getLayer(t){return this.#s.get(t)}get currentPageIndex(){return this.#u}addLayer(t){this.#s.set(t.pageIndex,t),this.#E?t.enable():t.disable()}removeLayer(t){this.#s.delete(t.pageIndex)}async updateMode(t,e=null,i=!1){if(this.#C!==t&&!(this.#R&&(await this.#R.promise,!this.#R))){if(this.#R=Promise.withResolvers(),this.#C=t,t===B.NONE){this.setEditingState(!1),this.#ot(),this._editorUndoBar?.hide(),this.#R.resolve();return}this.setEditingState(!0),await this.#at(),this.unselectAll();for(const s of this.#s.values())s.updateMode(t);if(!e){i&&this.addNewEditorFromKeyboard(),this.#R.resolve();return}for(const s of this.#i.values())s.annotationElementId===e?(this.setSelected(s),s.enterInEditMode()):s.unselect();this.#R.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==this.#C&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){if(this.#o){switch(t){case V.CREATE:this.currentLayer.addNewEditor();return;case V.HIGHLIGHT_DEFAULT_COLOR:this.#M?.updateColor(e);break;case V.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#H||=new Map).set(t,e),this.showAllEditors("highlight",e);break}for(const i of this.#_)i.updateParams(t,e);for(const i of this.#o)i.updateDefaultParams(t,e)}}showAllEditors(t,e,i=!1){for(const n of this.#i.values())n.editorType===t&&n.show(e);(this.#H?.get(V.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#$([[V.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#T!==t){this.#T=t;for(const e of this.#s.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}async#at(){if(!this.#E){this.#E=!0;const t=[];for(const e of this.#s.values())t.push(e.enable());await Promise.all(t);for(const e of this.#i.values())e.enable()}}#ot(){if(this.unselectAll(),this.#E){this.#E=!1;for(const t of this.#s.values())t.disable();for(const t of this.#i.values())t.disable()}}getEditors(t){const e=[];for(const i of this.#i.values())i.pageIndex===t&&e.push(i);return e}getEditor(t){return this.#i.get(t)}addEditor(t){this.#i.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#w&&clearTimeout(this.#w),this.#w=setTimeout(()=>{this.focusMainContainer(),this.#w=null},0)),this.#i.delete(t.id),this.unselect(t),(!t.annotationElementId||!this.#d.has(t.annotationElementId))&&this.#n?.remove(t.id)}addDeletedAnnotationElement(t){this.#d.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#d.has(t)}removeDeletedAnnotationElement(t){this.#d.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#Q(t){const e=this.#s.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#e!==t&&(this.#e=t,t&&this.#$(t.propertiesToUpdate))}get#lt(){let t=null;for(t of this.#_);return t}updateUI(t){this.#lt===t&&this.#$(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#$(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#_.has(t)){this.#_.delete(t),t.unselect(),this.#N({hasSelectedEditor:this.hasSelection});return}this.#_.add(t),t.select(),this.#$(t.propertiesToUpdate),this.#N({hasSelectedEditor:!0})}setSelected(t){this.#h?.commitOrRemove();for(const e of this.#_)e!==t&&e.unselect();this.#_.clear(),this.#_.add(t),t.select(),this.#$(t.propertiesToUpdate),this.#N({hasSelectedEditor:!0})}isSelected(t){return this.#_.has(t)}get firstSelectedEditor(){return this.#_.values().next().value}unselect(t){t.unselect(),this.#_.delete(t),this.#N({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#_.size!==0}get isEnterHandled(){return this.#_.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#l.undo(),this.#N({hasSomethingToUndo:this.#l.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#W()}),this._editorUndoBar?.hide()}redo(){this.#l.redo(),this.#N({hasSomethingToUndo:!0,hasSomethingToRedo:this.#l.hasSomethingToRedo(),isEmpty:this.#W()})}addCommands(t){this.#l.add(t),this.#N({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#W()})}cleanUndoStack(t){this.#l.cleanType(t)}#W(){if(this.#i.size===0)return!0;if(this.#i.size===1)for(const t of this.#i.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();const t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const e=t?[t]:[...this.#_],i=()=>{this._editorUndoBar?.show(s,e.length===1?e[0].editorType:e.length);for(const n of e)n.remove()},s=()=>{for(const n of e)this.#Q(n)};this.addCommands({cmd:i,undo:s,mustExec:!0})}commitOrRemove(){this.#e?.commitOrRemove()}hasSomethingToControl(){return this.#e||this.hasSelection}#Z(t){for(const e of this.#_)e.unselect();this.#_.clear();for(const e of t)e.isEmpty()||(this.#_.add(e),e.select());this.#N({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#_)t.commit();this.#Z(this.#i.values())}unselectAll(){if(!(this.#e&&(this.#e.commitOrRemove(),this.#C!==B.NONE))&&!this.#h?.commitOrRemove()&&this.hasSelection){for(const t of this.#_)t.unselect();this.#_.clear(),this.#N({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;this.#j[0]+=t,this.#j[1]+=e;const[s,n]=this.#j,r=[...this.#_],a=1e3;this.#O&&clearTimeout(this.#O),this.#O=setTimeout(()=>{this.#O=null,this.#j[0]=this.#j[1]=0,this.addCommands({cmd:()=>{for(const o of r)this.#i.has(o.id)&&o.translateInPage(s,n)},undo:()=>{for(const o of r)this.#i.has(o.id)&&o.translateInPage(-s,-n)},mustExec:!1})},a);for(const o of r)o.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#f=new Map;for(const t of this.#_)this.#f.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#f)return!1;this.disableUserSelect(!1);const t=this.#f;this.#f=null;let e=!1;for(const[{x:s,y:n,pageIndex:r},a]of t)a.newX=s,a.newY=n,a.newPageIndex=r,e||=s!==a.savedX||n!==a.savedY||r!==a.savedPageIndex;if(!e)return!1;const i=(s,n,r,a)=>{if(this.#i.has(s.id)){const o=this.#s.get(a);o?s._setParentAndPosition(o,n,r):(s.pageIndex=a,s.x=n,s.y=r)}};return this.addCommands({cmd:()=>{for(const[s,{newX:n,newY:r,newPageIndex:a}]of t)i(s,n,r,a)},undo:()=>{for(const[s,{savedX:n,savedY:r,savedPageIndex:a}]of t)i(s,n,r,a)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#f)for(const i of this.#f.keys())i.drag(t,e)}rebuild(t){if(t.parent===null){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||this.#_.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#e===t}getActive(){return this.#e}getMode(){return this.#C}get imageManager(){return H(this,"imageManager",new Hi)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let h=0,c=e.rangeCount;h<c;h++)if(!t.contains(e.getRangeAt(h).commonAncestorContainer))return null;const{x:i,y:s,width:n,height:r}=t.getBoundingClientRect();let a;switch(t.getAttribute("data-main-rotation")){case"90":a=(h,c,d,u)=>({x:(c-s)/r,y:1-(h+d-i)/n,width:u/r,height:d/n});break;case"180":a=(h,c,d,u)=>({x:1-(h+d-i)/n,y:1-(c+u-s)/r,width:d/n,height:u/r});break;case"270":a=(h,c,d,u)=>({x:1-(c+u-s)/r,y:(h-i)/n,width:u/r,height:d/n});break;default:a=(h,c,d,u)=>({x:(h-i)/n,y:(c-s)/r,width:d/n,height:u/r});break}const o=[];for(let h=0,c=e.rangeCount;h<c;h++){const d=e.getRangeAt(h);if(!d.collapsed)for(const{x:u,y:f,width:p,height:g}of d.getClientRects())p===0||g===0||o.push(a(u,f,p,g))}return o.length===0?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#a||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#a?.delete(t)}renderAnnotationElement(t){const e=this.#a?.get(t.data.id);if(!e)return;const i=this.#n.getRawValue(e);i&&(this.#C===B.NONE&&!i.hasBeenModified||i.renderAnnotationElement(t))}};class Rt{#t=null;#e=!1;#i=null;#s=null;#r=null;#n=null;#a=!1;#l=null;#c=null;#h=null;#u=null;#d=!1;static#f=null;static _l10n=null;constructor(t){this.#c=t,this.#d=t._uiManager.useNewAltTextFlow,Rt.#f||=Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"})}static initialize(t){Rt._l10n??=t}async render(){const t=this.#i=document.createElement("button");t.className="altText",t.tabIndex="0";const e=this.#s=document.createElement("span");t.append(e),this.#d?(t.classList.add("new"),t.setAttribute("data-l10n-id",Rt.#f.missing),e.setAttribute("data-l10n-id",Rt.#f["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const i=this.#c._uiManager._signal;t.addEventListener("contextmenu",xt,{signal:i}),t.addEventListener("pointerdown",n=>n.stopPropagation(),{signal:i});const s=n=>{n.preventDefault(),this.#c._uiManager.editAltText(this.#c),this.#d&&this.#c._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#o}})};return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",n=>{n.target===t&&n.key==="Enter"&&(this.#a=!0,s(n))},{signal:i}),await this.#p(),t}get#o(){return this.#t&&"added"||this.#t===null&&this.guessedText&&"review"||"missing"}finish(){this.#i&&(this.#i.focus({focusVisible:this.#a}),this.#a=!1)}isEmpty(){return this.#d?this.#t===null:!this.#t&&!this.#e}hasData(){return this.#d?this.#t!==null||!!this.#h:this.isEmpty()}get guessedText(){return this.#h}async setGuessedText(t){this.#t===null&&(this.#h=t,this.#u=await Rt._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#p())}toggleAltTextBadge(t=!1){if(!this.#d||this.#t){this.#l?.remove(),this.#l=null;return}if(!this.#l){const e=this.#l=document.createElement("div");e.className="noAltTextBadge",this.#c.div.append(e)}this.#l.classList.toggle("hidden",!t)}serialize(t){let e=this.#t;return!t&&this.#h===e&&(e=this.#u),{altText:e,decorative:this.#e,guessedText:this.#h,textWithDisclaimer:this.#u}}get data(){return{altText:this.#t,decorative:this.#e}}set data({altText:t,decorative:e,guessedText:i,textWithDisclaimer:s,cancel:n=!1}){i&&(this.#h=i,this.#u=s),!(this.#t===t&&this.#e===e)&&(n||(this.#t=t,this.#e=e),this.#p())}toggle(t=!1){this.#i&&(!t&&this.#n&&(clearTimeout(this.#n),this.#n=null),this.#i.disabled=!t)}shown(){this.#c._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#o}})}destroy(){this.#i?.remove(),this.#i=null,this.#s=null,this.#r=null,this.#l?.remove(),this.#l=null}async#p(){const t=this.#i;if(!t)return;if(this.#d){if(t.classList.toggle("done",!!this.#t),t.setAttribute("data-l10n-id",Rt.#f[this.#o]),this.#s?.setAttribute("data-l10n-id",Rt.#f[`${this.#o}-label`]),!this.#t){this.#r?.remove();return}}else{if(!this.#t&&!this.#e){t.classList.remove("done"),this.#r?.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#r;if(!e){this.#r=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#c.id}`;const s=100,n=this.#c._uiManager._signal;n.addEventListener("abort",()=>{clearTimeout(this.#n),this.#n=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#n=setTimeout(()=>{this.#n=null,this.#r.classList.add("show"),this.#c._reportTelemetry({action:"alt_text_tooltip"})},s)},{signal:n}),t.addEventListener("mouseleave",()=>{this.#n&&(clearTimeout(this.#n),this.#n=null),this.#r?.classList.remove("show")},{signal:n})}this.#e?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#t),e.parentNode||t.append(e),this.#c.getImageForAltText()?.setAttribute("aria-describedby",e.id)}}let tn=class en{#t;#e=!1;#i=null;#s;#r;#n;#a;#l;#c=null;#h;#u=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:i=null,onPinchStart:s=null,onPinching:n=null,onPinchEnd:r=null,signal:a}){this.#t=t,this.#i=i,this.#s=e,this.#r=s,this.#n=n,this.#a=r,this.#h=new AbortController,this.#l=AbortSignal.any([a,this.#h.signal]),t.addEventListener("touchstart",this.#d.bind(this),{passive:!1,signal:this.#l})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return H(this,"MIN_TOUCH_DISTANCE_TO_PINCH",35/(window.devicePixelRatio||1))}#d(t){if(this.#s?.()||t.touches.length<2)return;if(!this.#u){this.#u=new AbortController;const s=AbortSignal.any([this.#l,this.#u.signal]),n=this.#t,r={signal:s,passive:!1};n.addEventListener("touchmove",this.#f.bind(this),r),n.addEventListener("touchend",this.#o.bind(this),r),n.addEventListener("touchcancel",this.#o.bind(this),r),this.#r?.()}if(wt(t),t.touches.length!==2||this.#i?.()){this.#c=null;return}let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]),this.#c={touch0X:e.screenX,touch0Y:e.screenY,touch1X:i.screenX,touch1Y:i.screenY}}#f(t){if(!this.#c||t.touches.length!==2)return;let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]);const{screenX:s,screenY:n}=e,{screenX:r,screenY:a}=i,o=this.#c,{touch0X:h,touch0Y:c,touch1X:d,touch1Y:u}=o,f=d-h,p=u-c,g=r-s,b=a-n,m=Math.hypot(g,b)||1,w=Math.hypot(f,p)||1;if(!this.#e&&Math.abs(w-m)<=en.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(o.touch0X=s,o.touch0Y=n,o.touch1X=r,o.touch1Y=a,t.preventDefault(),!this.#e){this.#e=!0;return}const y=[(s+r)/2,(n+a)/2];this.#n?.(y,w,m)}#o(t){this.#u.abort(),this.#u=null,this.#a?.(),this.#c&&(t.preventDefault(),this.#c=null,this.#e=!1)}destroy(){this.#h?.abort(),this.#h=null}};class D{#t=null;#e=null;#i=null;#s=!1;#r=null;#n="";#a=!1;#l=null;#c=null;#h=null;#u=null;#d="";#f=!1;#o=null;#p=!1;#m=!1;#g=!1;#b=null;#y=0;#w=0;#A=null;#v=null;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#S=!1;#x=D._zIndex++;static _borderLineWidth=-1;static _colorManager=new Vi;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=D.prototype._resizeWithKeyboard,e=ve.TRANSLATE_SMALL,i=ve.TRANSLATE_BIG;return H(this,"_resizerKeyboardManager",new Ce([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-i,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[i,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-i]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,i]}],[["Escape","mac+Escape"],D.prototype._stopResizingWithKeyboard]]))}constructor(t){this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null;const{rotation:e,rawDims:{pageWidth:i,pageHeight:s,pageX:n,pageY:r}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,s],this.pageTranslation=[n,r];const[a,o]=this.parentDimensions;this.x=t.x/a,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return H(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new dr({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(D._l10n??=t,D._l10nResizer||=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"}),D._borderLineWidth!==-1)return;const i=getComputedStyle(document.documentElement);D._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){z("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#S}set _isDraggable(t){this.#S=t,this.div?.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(t*2),this.y+=this.width*t/(e*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(t*2),this.y-=this.width*t/(e*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#x}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):this.#V(),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#f?this.#f=!1:this.parent.setSelected(this))}focusout(t){!this._focusEventsAllowed||!this.isAttachedToDOM||t.relatedTarget?.closest(`#${this.id}`)||(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,i,s){const[n,r]=this.parentDimensions;[i,s]=this.screenToPageTranslation(i,s),this.x=(t+i)/n,this.y=(e+s)/r,this.fixAndSetPosition()}#L([t,e],i,s){[i,s]=this.screenToPageTranslation(i,s),this.x+=i/t,this.y+=s/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#L(this.parentDimensions,t,e)}translateInPage(t,e){this.#o||=[this.x,this.y,this.width,this.height],this.#L(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){this.#o||=[this.x,this.y,this.width,this.height];const{div:i,parentDimensions:[s,n]}=this;if(this.x+=t/s,this.y+=e/n,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:d,y:u}=this.div.getBoundingClientRect();this.parent.findNewParent(this,d,u)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:r,y:a}=this;const[o,h]=this.getBaseTranslation();r+=o,a+=h;const{style:c}=i;c.left=`${(100*r).toFixed(2)}%`,c.top=`${(100*a).toFixed(2)}%`,this._onTranslating(r,a),i.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#o&&(this.#o[0]!==this.x||this.#o[1]!==this.y)}get _hasBeenResized(){return!!this.#o&&(this.#o[2]!==this.width||this.#o[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:i}=D,s=i/t,n=i/e;switch(this.rotation){case 90:return[-s,n];case 180:return[s,n];case 270:return[s,-n];default:return[-s,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[i,s]}=this;let{x:n,y:r,width:a,height:o}=this;if(a*=i,o*=s,n*=i,r*=s,this._mustFixPosition)switch(t){case 0:n=Math.max(0,Math.min(i-a,n)),r=Math.max(0,Math.min(s-o,r));break;case 90:n=Math.max(0,Math.min(i-o,n)),r=Math.min(s,Math.max(a,r));break;case 180:n=Math.min(i,Math.max(a,n)),r=Math.min(s,Math.max(o,r));break;case 270:n=Math.min(i,Math.max(o,n)),r=Math.max(0,Math.min(s-a,r));break}this.x=n/=i,this.y=r/=s;const[h,c]=this.getBaseTranslation();n+=h,r+=c,e.left=`${(100*n).toFixed(2)}%`,e.top=`${(100*r).toFixed(2)}%`,this.moveInDOM()}static#E(t,e,i){switch(i){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return D.#E(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return D.#E(t,e,360-this.parentRotation)}#T(t){switch(t){case 90:{const[e,i]=this.pageDimensions;return[0,-e/i,i/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,i]=this.pageDimensions;return[0,e/i,-i/e,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,i]}=this;return[e*t,i*t]}setDims(t,e){const[i,s]=this.parentDimensions,{style:n}=this.div;n.width=`${(100*t/i).toFixed(2)}%`,this.#a||(n.height=`${(100*e/s).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:i}=t,s=i.endsWith("%"),n=!this.#a&&e.endsWith("%");if(s&&n)return;const[r,a]=this.parentDimensions;s||(t.width=`${(100*parseFloat(i)/r).toFixed(2)}%`),!this.#a&&!n&&(t.height=`${(100*parseFloat(e)/a).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#P(){if(this.#l)return;this.#l=document.createElement("div"),this.#l.classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const i of t){const s=document.createElement("div");this.#l.append(s),s.classList.add("resizer",i),s.setAttribute("data-resizer-name",i),s.addEventListener("pointerdown",this.#I.bind(this,i),{signal:e}),s.addEventListener("contextmenu",xt,{signal:e}),s.tabIndex=-1}this.div.prepend(this.#l)}#I(t,e){e.preventDefault();const{isMac:i}=ct.platform;if(e.button!==0||e.ctrlKey&&i)return;this.#i?.toggle(!1);const s=this._isDraggable;this._isDraggable=!1,this.#c=[e.screenX,e.screenY];const n=new AbortController,r=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#C.bind(this,t),{passive:!0,capture:!0,signal:r}),window.addEventListener("touchmove",wt,{passive:!1,signal:r}),window.addEventListener("contextmenu",xt,{signal:r}),this.#h={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const a=this.parent.div.style.cursor,o=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const h=()=>{n.abort(),this.parent.togglePointerEvents(!0),this.#i?.toggle(!0),this._isDraggable=s,this.parent.div.style.cursor=a,this.div.style.cursor=o,this.#D()};window.addEventListener("pointerup",h,{signal:r}),window.addEventListener("blur",h,{signal:r})}#M(t,e,i,s){this.width=i,this.height=s,this.x=t,this.y=e;const[n,r]=this.parentDimensions;this.setDims(n*i,r*s),this.fixAndSetPosition(),this._onResized()}_onResized(){}#D(){if(!this.#h)return;const{savedX:t,savedY:e,savedWidth:i,savedHeight:s}=this.#h;this.#h=null;const n=this.x,r=this.y,a=this.width,o=this.height;n===t&&r===e&&a===i&&o===s||this.addCommands({cmd:this.#M.bind(this,n,r,a,o),undo:this.#M.bind(this,t,e,i,s),mustExec:!0})}static _round(t){return Math.round(t*1e4)/1e4}#C(t,e){const[i,s]=this.parentDimensions,n=this.x,r=this.y,a=this.width,o=this.height,h=D.MIN_SIZE/i,c=D.MIN_SIZE/s,d=this.#T(this.rotation),u=(L,k)=>[d[0]*L+d[2]*k,d[1]*L+d[3]*k],f=this.#T(360-this.rotation),p=(L,k)=>[f[0]*L+f[2]*k,f[1]*L+f[3]*k];let g,b,m=!1,w=!1;switch(t){case"topLeft":m=!0,g=(L,k)=>[0,0],b=(L,k)=>[L,k];break;case"topMiddle":g=(L,k)=>[L/2,0],b=(L,k)=>[L/2,k];break;case"topRight":m=!0,g=(L,k)=>[L,0],b=(L,k)=>[0,k];break;case"middleRight":w=!0,g=(L,k)=>[L,k/2],b=(L,k)=>[0,k/2];break;case"bottomRight":m=!0,g=(L,k)=>[L,k],b=(L,k)=>[0,0];break;case"bottomMiddle":g=(L,k)=>[L/2,k],b=(L,k)=>[L/2,0];break;case"bottomLeft":m=!0,g=(L,k)=>[0,k],b=(L,k)=>[L,0];break;case"middleLeft":w=!0,g=(L,k)=>[0,k/2],b=(L,k)=>[L,k/2];break}const y=g(a,o),A=b(a,o);let v=u(...A);const C=D._round(n+v[0]),x=D._round(r+v[1]);let T=1,_=1,S,P;if(e.fromKeyboard)({deltaX:S,deltaY:P}=e);else{const{screenX:L,screenY:k}=e,[ht,Pt]=this.#c;[S,P]=this.screenToPageTranslation(L-ht,k-Pt),this.#c[0]=L,this.#c[1]=k}if([S,P]=p(S/i,P/s),m){const L=Math.hypot(a,o);T=_=Math.max(Math.min(Math.hypot(A[0]-y[0]-S,A[1]-y[1]-P)/L,1/a,1/o),h/a,c/o)}else w?T=Math.max(h,Math.min(1,Math.abs(A[0]-y[0]-S)))/a:_=Math.max(c,Math.min(1,Math.abs(A[1]-y[1]-P)))/o;const I=D._round(a*T),$=D._round(o*_);v=u(...b(I,$));const O=C-v[0],tt=x-v[1];this.#o||=[this.x,this.y,this.width,this.height],this.width=I,this.height=$,this.x=O,this.y=tt,this.setDims(i*I,s*$),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#i?.finish()}async addEditToolbar(){return this._editToolbar||this.#m?this._editToolbar:(this._editToolbar=new ge(this),this.div.append(this._editToolbar.render()),this.#i&&await this._editToolbar.addAltText(this.#i),this._editToolbar)}removeEditToolbar(){this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,this.#i?.destroy())}addContainer(t){const e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#i||(Rt.initialize(D._l10n),this.#i=new Rt(this),this.#t&&(this.#i.data=this.#t,this.#t=null),await this.addEditToolbar())}get altTextData(){return this.#i?.data}set altTextData(t){this.#i&&(this.#i.data=t)}get guessedAltText(){return this.#i?.guessedText}async setGuessedAltText(t){await this.#i?.setGuessedText(t)}serializeAltText(t){return this.#i?.serialize(t)}hasAltText(){return!!this.#i&&!this.#i.isEmpty()}hasAltTextData(){return this.#i?.hasData()??!1}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=this.#s?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),this.#j();const[t,e]=this.parentDimensions;this.parentRotation%180!==0&&(this.div.style.maxWidth=`${(100*e/t).toFixed(2)}%`,this.div.style.maxHeight=`${(100*t/e).toFixed(2)}%`);const[i,s]=this.getInitialTranslation();return this.translate(i,s),$e(this,this.div,["pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#v||=new tn({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#_.bind(this),onPinching:this.#F.bind(this),onPinchEnd:this.#k.bind(this),signal:this._uiManager._signal})),this._uiManager._editorUndoBar?.hide(),this.div}#_(){this.#h={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#i?.toggle(!1),this.parent.togglePointerEvents(!1)}#F(t,e,i){let n=.7*(i/e)+1-.7;if(n===1)return;const r=this.#T(this.rotation),a=(C,x)=>[r[0]*C+r[2]*x,r[1]*C+r[3]*x],[o,h]=this.parentDimensions,c=this.x,d=this.y,u=this.width,f=this.height,p=D.MIN_SIZE/o,g=D.MIN_SIZE/h;n=Math.max(Math.min(n,1/u,1/f),p/u,g/f);const b=D._round(u*n),m=D._round(f*n);if(b===u&&m===f)return;this.#o||=[c,d,u,f];const w=a(u/2,f/2),y=D._round(c+w[0]),A=D._round(d+w[1]),v=a(b/2,m/2);this.x=y-v[0],this.y=A-v[1],this.width=b,this.height=m,this.setDims(o*b,h*m),this.fixAndSetPosition(),this._onResizing()}#k(){this.#i?.toggle(!0),this.parent.togglePointerEvents(!0),this.#D()}pointerdown(t){const{isMac:e}=ct.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(this.#f=!0,this._isDraggable){this.#U(t);return}this.#H(t)}get isSelected(){return this._uiManager.isSelected(this)}#H(t){const{isMac:e}=ct.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#U(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let i=!1;const s=new AbortController,n=this._uiManager.combinedSignal(s),r={capture:!0,passive:!1,signal:n},a=h=>{s.abort(),this.#r=null,this.#f=!1,this._uiManager.endDragSession()||this.#H(h),i&&this._onStopDragging()};e&&(this.#y=t.clientX,this.#w=t.clientY,this.#r=t.pointerId,this.#n=t.pointerType,window.addEventListener("pointermove",h=>{i||(i=!0,this._onStartDragging());const{clientX:c,clientY:d,pointerId:u}=h;if(u!==this.#r){wt(h);return}const[f,p]=this.screenToPageTranslation(c-this.#y,d-this.#w);this.#y=c,this.#w=d,this._uiManager.dragSelectedEditors(f,p)},r),window.addEventListener("touchmove",wt,r),window.addEventListener("pointerdown",h=>{h.pointerType===this.#n&&(this.#v||h.isPrimary)&&a(h),wt(h)},r));const o=h=>{if(!this.#r||this.#r===h.pointerId){a(h);return}wt(h)};window.addEventListener("pointerup",o,{signal:n}),window.addEventListener("blur",o,{signal:n})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#b&&clearTimeout(this.#b),this.#b=setTimeout(()=>{this.#b=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(t,e,i){t.changeParent(this),this.x=e,this.y=i,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,i=this.rotation){const s=this.parentScale,[n,r]=this.pageDimensions,[a,o]=this.pageTranslation,h=t/s,c=e/s,d=this.x*n,u=this.y*r,f=this.width*n,p=this.height*r;switch(i){case 0:return[d+h+a,r-u-c-p+o,d+h+f+a,r-u-c+o];case 90:return[d+c+a,r-u+h+o,d+c+p+a,r-u+h+f+o];case 180:return[d-h-f+a,r-u+c+o,d-h+a,r-u+c+p+o];case 270:return[d-c-p+a,r-u-h-f+o,d-c+a,r-u-h+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[i,s,n,r]=t,a=n-i,o=r-s;switch(this.rotation){case 0:return[i,e-r,a,o];case 90:return[i,e-s,o,a];case 180:return[n,e-s,a,o];case 270:return[n,e-r,o,a];default:throw new Error("Invalid rotation")}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){this.#m=!0}disableEditMode(){this.#m=!1}isInEditMode(){return this.#m}shouldGetKeyboardEvents(){return this.#g}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:i,right:s}=this.getClientDimensions(),{innerHeight:n,innerWidth:r}=window;return e<r&&s>0&&t<n&&i>0}#j(){if(this.#u||!this.div)return;this.#u=new AbortController;const t=this._uiManager.combinedSignal(this.#u);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#j()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){z("An editor must be serializable")}static async deserialize(t,e,i){const s=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:i});s.rotation=t.rotation,s.#t=t.accessibilityData;const[n,r]=s.pageDimensions,[a,o,h,c]=s.getRectInCurrentCoords(t.rect,r);return s.x=a/n,s.y=o/r,s.width=h/n,s.height=c/r,s}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.#u?.abort(),this.#u=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#b&&(clearTimeout(this.#b),this.#b=null),this.#V(),this.removeEditToolbar(),this.#A){for(const t of this.#A.values())clearTimeout(t);this.#A=null}this.parent=null,this.#v?.destroy(),this.#v=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#P(),this.#l.classList.remove("hidden"),$e(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),this.#h={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#l.children;if(!this.#e){this.#e=Array.from(e);const r=this.#O.bind(this),a=this.#B.bind(this),o=this._uiManager._signal;for(const h of this.#e){const c=h.getAttribute("data-resizer-name");h.setAttribute("role","spinbutton"),h.addEventListener("keydown",r,{signal:o}),h.addEventListener("blur",a,{signal:o}),h.addEventListener("focus",this.#z.bind(this,c),{signal:o}),h.setAttribute("data-l10n-id",D._l10nResizer[c])}}const i=this.#e[0];let s=0;for(const r of e){if(r===i)break;s++}const n=(360-this.rotation+this.parentRotation)%360/90*(this.#e.length/4);if(n!==s){if(n<s)for(let a=0;a<s-n;a++)this.#l.append(this.#l.firstChild);else if(n>s)for(let a=0;a<n-s;a++)this.#l.firstChild.before(this.#l.lastChild);let r=0;for(const a of e){const h=this.#e[r++].getAttribute("data-resizer-name");a.setAttribute("data-l10n-id",D._l10nResizer[h])}}this.#R(0),this.#g=!0,this.#l.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#O(t){D._resizerKeyboardManager.exec(this,t)}#B(t){this.#g&&t.relatedTarget?.parentNode!==this.#l&&this.#V()}#z(t){this.#d=this.#g?t:""}#R(t){if(this.#e)for(const e of this.#e)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#g&&this.#C(this.#d,{deltaX:t,deltaY:e,fromKeyboard:!0})}#V(){this.#g=!1,this.#R(-1),this.#D()}_stopResizingWithKeyboard(){this.#V(),this.div.focus()}select(){if(this.makeResizable(),this.div?.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()});return}this._editToolbar?.show(),this.#i?.toggleAltTextBadge(!1)}unselect(){this.#l?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#i?.toggleAltTextBadge(!0)}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#p}set isEditing(t){this.#p=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){this.#a=!0;const i=t/e,{style:s}=this.div;s.aspectRatio=i,s.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,e=!1){if(e){this.#A||=new Map;const{action:i}=t;let s=this.#A.get(i);s&&clearTimeout(s),s=setTimeout(()=>{this._reportTelemetry(t),this.#A.delete(i),this.#A.size===0&&(this.#A=null)},D._telemetryTimeout),this.#A.set(i,s);return}t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),this.#s=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#s=!0}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent");if(!e)e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);else if(e.nodeName==="CANVAS"){const i=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),i.before(e)}return e}resetAnnotationElement(t){const{firstChild:e}=t.container;e?.nodeName==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}}class dr extends D{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const is=3285377520,_t=4294901760,Tt=65535;class sn{constructor(t){this.h1=t?t&4294967295:is,this.h2=t?t&4294967295:is}update(t){let e,i;if(typeof t=="string"){e=new Uint8Array(t.length*2),i=0;for(let g=0,b=t.length;g<b;g++){const m=t.charCodeAt(g);m<=255?e[i++]=m:(e[i++]=m>>>8,e[i++]=m&255)}}else if(ArrayBuffer.isView(t))e=t.slice(),i=e.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const s=i>>2,n=i-s*4,r=new Uint32Array(e.buffer,0,s);let a=0,o=0,h=this.h1,c=this.h2;const d=3432918353,u=461845907,f=d&Tt,p=u&Tt;for(let g=0;g<s;g++)g&1?(a=r[g],a=a*d&_t|a*f&Tt,a=a<<15|a>>>17,a=a*u&_t|a*p&Tt,h^=a,h=h<<13|h>>>19,h=h*5+3864292196):(o=r[g],o=o*d&_t|o*f&Tt,o=o<<15|o>>>17,o=o*u&_t|o*p&Tt,c^=o,c=c<<13|c>>>19,c=c*5+3864292196);switch(a=0,n){case 3:a^=e[s*4+2]<<16;case 2:a^=e[s*4+1]<<8;case 1:a^=e[s*4],a=a*d&_t|a*f&Tt,a=a<<15|a>>>17,a=a*u&_t|a*p&Tt,s&1?h^=a:c^=a}this.h1=h,this.h2=c}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&_t|t*36045&Tt,e=e*4283543511&_t|((e<<16|t>>>16)*2950163797&_t)>>>16,t^=e>>>1,t=t*444984403&_t|t*60499&Tt,e=e*3301882366&_t|((e<<16|t>>>16)*3120437893&_t)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const Ei=Object.freeze({map:null,hash:"",transfer:void 0});class $i{#t=!1;#e=null;#i=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const i=this.#i.get(t);return i===void 0?e:Object.assign(e,i)}getRawValue(t){return this.#i.get(t)}remove(t){if(this.#i.delete(t),this.#i.size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const e of this.#i.values())if(e instanceof D)return;this.onAnnotationEditor(null)}}setValue(t,e){const i=this.#i.get(t);let s=!1;if(i!==void 0)for(const[n,r]of Object.entries(e))i[n]!==r&&(s=!0,i[n]=r);else s=!0,this.#i.set(t,e);s&&this.#s(),e instanceof D&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type)}has(t){return this.#i.has(t)}getAll(){return this.#i.size>0?Di(this.#i):null}setAll(t){for(const[e,i]of Object.entries(t))this.setValue(e,i)}get size(){return this.#i.size}#s(){this.#t||(this.#t=!0,typeof this.onSetModified=="function"&&this.onSetModified())}resetModified(){this.#t&&(this.#t=!1,typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new nn(this)}get serializable(){if(this.#i.size===0)return Ei;const t=new Map,e=new sn,i=[],s=Object.create(null);let n=!1;for(const[r,a]of this.#i){const o=a instanceof D?a.serialize(!1,s):a;o&&(t.set(r,o),e.update(`${r}:${JSON.stringify(o)}`),n||=!!o.bitmap)}if(n)for(const r of t.values())r.bitmap&&i.push(r.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:i}:Ei}get editorStats(){let t=null;const e=new Map;for(const i of this.#i.values()){if(!(i instanceof D))continue;const s=i.telemetryFinalData;if(!s)continue;const{type:n}=s;e.has(n)||e.set(n,Object.getPrototypeOf(i).constructor),t||=Object.create(null);const r=t[n]||=new Map;for(const[a,o]of Object.entries(s)){if(a==="type")continue;let h=r.get(a);h||(h=new Map,r.set(a,h));const c=h.get(o)??0;h.set(o,c+1)}}for(const[i,s]of e)t[i]=s.computeTelemetryFinalData(t[i]);return t}resetModifiedIds(){this.#e=null}get modifiedIds(){if(this.#e)return this.#e;const t=[];for(const e of this.#i.values())!(e instanceof D)||!e.annotationElementId||!e.serialize()||t.push(e.annotationElementId);return this.#e={ids:new Set(t),hash:t.join(",")}}}class nn extends $i{#t;constructor(t){super();const{map:e,hash:i,transfer:s}=t.serializable,n=structuredClone(e,s?{transfer:s}:null);this.#t={map:n,hash:i,transfer:s}}get print(){z("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#t}get modifiedIds(){return H(this,"modifiedIds",{ids:new Set,hash:""})}}class ur{#t=new Set;constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),this.#t.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(!(!t||this.#t.has(t.loadedName))){if(Z(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:i,src:s,style:n}=t,r=new FontFace(i,s,n);this.addNativeFontFace(r);try{await r.load(),this.#t.add(i),e?.(t)}catch{j(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(r)}return}z("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){const i=t.createNativeFontFace();if(i){this.addNativeFontFace(i);try{await i.loaded}catch(s){throw j(`Failed to load font '${i.family}': '${s}'.`),t.disableFontFace=!0,s}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(i=>{const s=this._queueLoadingCallback(i);this._prepareFontLoadEvent(t,s)})}}get isFontLoadingAPISupported(){const t=!!this._document?.fonts;return H(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){let t=!1;return(lt||typeof navigator<"u"&&typeof navigator?.userAgent=="string"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),H(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){function e(){for(Z(!s.done,"completeRequest() cannot be called twice."),s.done=!0;i.length>0&&i[0].done;){const n=i.shift();setTimeout(n.callback,0)}}const{loadingRequests:i}=this,s={done:!1,complete:e,callback:t};return i.push(s),s}get _loadTestFont(){const t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return H(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function i(A,v){return A.charCodeAt(v)<<24|A.charCodeAt(v+1)<<16|A.charCodeAt(v+2)<<8|A.charCodeAt(v+3)&255}function s(A,v,C,x){const T=A.substring(0,v),_=A.substring(v+C);return T+x+_}let n,r;const a=this._document.createElement("canvas");a.width=1,a.height=1;const o=a.getContext("2d");let h=0;function c(A,v){if(++h>30){j("Load test font never loaded."),v();return}if(o.font="30px "+A,o.fillText(".",0,20),o.getImageData(0,0,1,1).data[3]>0){v();return}setTimeout(c.bind(null,A,v))}const d=`lt${Date.now()}${this.loadTestFontId++}`;let u=this._loadTestFont;u=s(u,976,d.length,d);const p=16,g=1482184792;let b=i(u,p);for(n=0,r=d.length-3;n<r;n+=4)b=b-g+i(d,n)|0;n<d.length&&(b=b-g+i(d+"XXX",n)|0),u=s(u,p,4,Qn(b));const m=`url(data:font/opentype;base64,${btoa(u)});`,w=`@font-face {font-family:"${d}";src:${m}}`;this.insertRule(w);const y=this._document.createElement("div");y.style.visibility="hidden",y.style.width=y.style.height="10px",y.style.position="absolute",y.style.top=y.style.left="0px";for(const A of[t.loadedName,d]){const v=this._document.createElement("span");v.textContent="Hi",v.style.fontFamily=A,y.append(v)}this._document.body.append(y),c(d,()=>{y.remove(),e.complete()})}}class fr{constructor(t,{disableFontFace:e=!1,fontExtraProperties:i=!1,inspectFont:s=null}){this.compiledGlyphs=Object.create(null);for(const n in t)this[n]=t[n];this.disableFontFace=e===!0,this.fontExtraProperties=i===!0,this._inspectFont=s}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{const e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}return this._inspectFont?.(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${sr(this.data)});`;let e;if(!this.cssFontInfo)e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${t}}`}return this._inspectFont?.(this,t),e}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];const i=this.loadedName+"_path_"+e;let s;try{s=t.get(i)}catch(r){j(`getPathGenerator - ignoring character: "${r}".`)}const n=new Path2D(s||"");return this.fontExtraProperties||t.delete(i),this.compiledGlyphs[e]=n}}const Le={DATA:1,ERROR:2},Q={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function ss(){}function gt(l){if(l instanceof Ut||l instanceof Ai||l instanceof _e||l instanceof Ji||l instanceof Ve||l instanceof ri)return l;switch(l instanceof Error||typeof l=="object"&&l!==null||z('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),l.name){case"AbortException":return new Ut(l.message);case"InvalidPDFException":return new Ai(l.message);case"MissingPDFException":return new _e(l.message);case"PasswordException":return new Ji(l.message,l.code);case"UnexpectedResponseException":return new Ve(l.message,l.status);case"UnknownErrorException":return new ri(l.message,l.details)}return new ri(l.message,l.toString())}class fe{#t=new AbortController;constructor(t,e,i){this.sourceName=t,this.targetName=e,this.comObj=i,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),i.addEventListener("message",this.#e.bind(this),{signal:this.#t.signal})}#e({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){this.#s(t);return}if(t.callback){const i=t.callbackId,s=this.callbackCapabilities[i];if(!s)throw new Error(`Cannot resolve callback ${i}`);if(delete this.callbackCapabilities[i],t.callback===Le.DATA)s.resolve(t.data);else if(t.callback===Le.ERROR)s.reject(gt(t.reason));else throw new Error("Unexpected callback case");return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const i=this.sourceName,s=t.sourceName,n=this.comObj;Promise.try(e,t.data).then(function(r){n.postMessage({sourceName:i,targetName:s,callback:Le.DATA,callbackId:t.callbackId,data:r})},function(r){n.postMessage({sourceName:i,targetName:s,callback:Le.ERROR,callbackId:t.callbackId,reason:gt(r)})});return}if(t.streamId){this.#i(t);return}e(t.data)}on(t,e){const i=this.actionHandler;if(i[t])throw new Error(`There is already an actionName called "${t}"`);i[t]=e}send(t,e,i){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},i)}sendWithPromise(t,e,i){const s=this.callbackId++,n=Promise.withResolvers();this.callbackCapabilities[s]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:s,data:e},i)}catch(r){n.reject(r)}return n.promise}sendWithStream(t,e,i,s){const n=this.streamId++,r=this.sourceName,a=this.targetName,o=this.comObj;return new ReadableStream({start:h=>{const c=Promise.withResolvers();return this.streamControllers[n]={controller:h,startCall:c,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:r,targetName:a,action:t,streamId:n,data:e,desiredSize:h.desiredSize},s),c.promise},pull:h=>{const c=Promise.withResolvers();return this.streamControllers[n].pullCall=c,o.postMessage({sourceName:r,targetName:a,stream:Q.PULL,streamId:n,desiredSize:h.desiredSize}),c.promise},cancel:h=>{Z(h instanceof Error,"cancel must have a valid reason");const c=Promise.withResolvers();return this.streamControllers[n].cancelCall=c,this.streamControllers[n].isClosed=!0,o.postMessage({sourceName:r,targetName:a,stream:Q.CANCEL,streamId:n,reason:gt(h)}),c.promise}},i)}#i(t){const e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,r=this,a=this.actionHandler[t.action],o={enqueue(h,c=1,d){if(this.isCancelled)return;const u=this.desiredSize;this.desiredSize-=c,u>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:i,targetName:s,stream:Q.ENQUEUE,streamId:e,chunk:h},d)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:Q.CLOSE,streamId:e}),delete r.streamSinks[e])},error(h){Z(h instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:Q.ERROR,streamId:e,reason:gt(h)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,Promise.try(a,t.data,o).then(function(){n.postMessage({sourceName:i,targetName:s,stream:Q.START_COMPLETE,streamId:e,success:!0})},function(h){n.postMessage({sourceName:i,targetName:s,stream:Q.START_COMPLETE,streamId:e,reason:gt(h)})})}#s(t){const e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,r=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case Q.START_COMPLETE:t.success?r.startCall.resolve():r.startCall.reject(gt(t.reason));break;case Q.PULL_COMPLETE:t.success?r.pullCall.resolve():r.pullCall.reject(gt(t.reason));break;case Q.PULL:if(!a){n.postMessage({sourceName:i,targetName:s,stream:Q.PULL_COMPLETE,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,Promise.try(a.onPull||ss).then(function(){n.postMessage({sourceName:i,targetName:s,stream:Q.PULL_COMPLETE,streamId:e,success:!0})},function(h){n.postMessage({sourceName:i,targetName:s,stream:Q.PULL_COMPLETE,streamId:e,reason:gt(h)})});break;case Q.ENQUEUE:if(Z(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case Q.CLOSE:if(Z(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#r(r,e);break;case Q.ERROR:Z(r,"error should have stream controller"),r.controller.error(gt(t.reason)),this.#r(r,e);break;case Q.CANCEL_COMPLETE:t.success?r.cancelCall.resolve():r.cancelCall.reject(gt(t.reason)),this.#r(r,e);break;case Q.CANCEL:if(!a)break;const o=gt(t.reason);Promise.try(a.onCancel||ss,o).then(function(){n.postMessage({sourceName:i,targetName:s,stream:Q.CANCEL_COMPLETE,streamId:e,success:!0})},function(h){n.postMessage({sourceName:i,targetName:s,stream:Q.CANCEL_COMPLETE,streamId:e,reason:gt(h)})}),a.sinkCapability.reject(o),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#r(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#t?.abort(),this.#t=null}}class rn{#t=!1;constructor({enableHWA:t=!1}){this.#t=t}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const i=this._createCanvas(t,e);return{canvas:i,context:i.getContext("2d",{willReadFrequently:!this.#t})}}reset(t,e,i){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||i<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=i}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){z("Abstract method `_createCanvas` called.")}}class pr extends rn{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const i=this._document.createElement("canvas");return i.width=t,i.height=e,i}}class an{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!t)throw new Error("CMap name must be specified.");const e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(e).then(i=>({cMapData:i,isCompressed:this.isCompressed})).catch(i=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}async _fetch(t){z("Abstract method `_fetch` called.")}}class on extends an{async _fetch(t){const e=await Ke(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):Ye(e)}}class ln{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,i,s,n){return"none"}destroy(t=!1){}}class gr extends ln{#t;#e;#i;#s;#r;#n;#a=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#s=t,this.#r=e}get#l(){return this.#e||=new Map}get#c(){return this.#n||=new Map}get#h(){if(!this.#i){const t=this.#r.createElement("div"),{style:e}=t;e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;const i=this.#r.createElementNS(Nt,"svg");i.setAttribute("width",0),i.setAttribute("height",0),this.#i=this.#r.createElementNS(Nt,"defs"),t.append(i),i.append(this.#i),this.#r.body.append(t)}return this.#i}#u(t){if(t.length===1){const o=t[0],h=new Array(256);for(let d=0;d<256;d++)h[d]=o[d]/255;const c=h.join(",");return[c,c,c]}const[e,i,s]=t,n=new Array(256),r=new Array(256),a=new Array(256);for(let o=0;o<256;o++)n[o]=e[o]/255,r[o]=i[o]/255,a[o]=s[o]/255;return[n.join(","),r.join(","),a.join(",")]}#d(t){if(this.#t===void 0){this.#t="";const e=this.#r.URL;e!==this.#r.baseURI&&(Qe(e)?j('#createUrl: ignore "data:"-URL for performance reasons.'):this.#t=e.split("#",1)[0])}return`url(${this.#t}#${t})`}addFilter(t){if(!t)return"none";let e=this.#l.get(t);if(e)return e;const[i,s,n]=this.#u(t),r=t.length===1?i:`${i}${s}${n}`;if(e=this.#l.get(r),e)return this.#l.set(t,e),e;const a=`g_${this.#s}_transfer_map_${this.#a++}`,o=this.#d(a);this.#l.set(t,o),this.#l.set(r,o);const h=this.#p(a);return this.#g(i,s,n,h),o}addHCMFilter(t,e){const i=`${t}-${e}`,s="base";let n=this.#c.get(s);if(n?.key===i||(n?(n.filter?.remove(),n.key=i,n.url="none",n.filter=null):(n={key:i,url:"none",filter:null},this.#c.set(s,n)),!t||!e))return n.url;const r=this.#y(t);t=M.makeHexColor(...r);const a=this.#y(e);if(e=M.makeHexColor(...a),this.#h.style.color="",t==="#000000"&&e==="#ffffff"||t===e)return n.url;const o=new Array(256);for(let f=0;f<=255;f++){const p=f/255;o[f]=p<=.03928?p/12.92:((p+.055)/1.055)**2.4}const h=o.join(","),c=`g_${this.#s}_hcm_filter`,d=n.filter=this.#p(c);this.#g(h,h,h,d),this.#o(d);const u=(f,p)=>{const g=r[f]/255,b=a[f]/255,m=new Array(p+1);for(let w=0;w<=p;w++)m[w]=g+w/p*(b-g);return m.join(",")};return this.#g(u(0,5),u(1,5),u(2,5),d),n.url=this.#d(c),n.url}addAlphaFilter(t){let e=this.#l.get(t);if(e)return e;const[i]=this.#u([t]),s=`alpha_${i}`;if(e=this.#l.get(s),e)return this.#l.set(t,e),e;const n=`g_${this.#s}_alpha_map_${this.#a++}`,r=this.#d(n);this.#l.set(t,r),this.#l.set(s,r);const a=this.#p(n);return this.#b(i,a),r}addLuminosityFilter(t){let e=this.#l.get(t||"luminosity");if(e)return e;let i,s;if(t?([i]=this.#u([t]),s=`luminosity_${i}`):s="luminosity",e=this.#l.get(s),e)return this.#l.set(t,e),e;const n=`g_${this.#s}_luminosity_map_${this.#a++}`,r=this.#d(n);this.#l.set(t,r),this.#l.set(s,r);const a=this.#p(n);return this.#f(a),t&&this.#b(i,a),r}addHighlightHCMFilter(t,e,i,s,n){const r=`${e}-${i}-${s}-${n}`;let a=this.#c.get(t);if(a?.key===r||(a?(a.filter?.remove(),a.key=r,a.url="none",a.filter=null):(a={key:r,url:"none",filter:null},this.#c.set(t,a)),!e||!i))return a.url;const[o,h]=[e,i].map(this.#y.bind(this));let c=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),d=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),[u,f]=[s,n].map(this.#y.bind(this));d<c&&([c,d,u,f]=[d,c,f,u]),this.#h.style.color="";const p=(m,w,y)=>{const A=new Array(256),v=(d-c)/y,C=m/255,x=(w-m)/(255*y);let T=0;for(let _=0;_<=y;_++){const S=Math.round(c+_*v),P=C+_*x;for(let I=T;I<=S;I++)A[I]=P;T=S+1}for(let _=T;_<256;_++)A[_]=A[T-1];return A.join(",")},g=`g_${this.#s}_hcm_${t}_filter`,b=a.filter=this.#p(g);return this.#o(b),this.#g(p(u[0],f[0],5),p(u[1],f[1],5),p(u[2],f[2],5),b),a.url=this.#d(g),a.url}destroy(t=!1){t&&this.#n?.size||(this.#i?.parentNode.parentNode.remove(),this.#i=null,this.#e?.clear(),this.#e=null,this.#n?.clear(),this.#n=null,this.#a=0)}#f(t){const e=this.#r.createElementNS(Nt,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),t.append(e)}#o(t){const e=this.#r.createElementNS(Nt,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),t.append(e)}#p(t){const e=this.#r.createElementNS(Nt,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#h.append(e),e}#m(t,e,i){const s=this.#r.createElementNS(Nt,e);s.setAttribute("type","discrete"),s.setAttribute("tableValues",i),t.append(s)}#g(t,e,i,s){const n=this.#r.createElementNS(Nt,"feComponentTransfer");s.append(n),this.#m(n,"feFuncR",t),this.#m(n,"feFuncG",e),this.#m(n,"feFuncB",i)}#b(t,e){const i=this.#r.createElementNS(Nt,"feComponentTransfer");e.append(i),this.#m(i,"feFuncA",t)}#y(t){return this.#h.style.color=t,ji(getComputedStyle(this.#h).getPropertyValue("color"))}}class hn{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!t)throw new Error("Font filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch(i=>{throw new Error(`Unable to load font data at: ${e}`)})}async _fetch(t){z("Abstract method `_fetch` called.")}}class cn extends hn{async _fetch(t){const e=await Ke(t,"arraybuffer");return new Uint8Array(e)}}lt&&j("Please use the `legacy` build in Node.js environments.");async function dn(l){const e=await process.getBuiltinModule("fs").promises.readFile(l);return new Uint8Array(e)}class mr extends ln{}class br extends rn{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class yr extends an{async _fetch(t){return dn(t)}}class wr extends hn{async _fetch(t){return dn(t)}}const ot={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function Si(l,t){if(!t)return;const e=t[2]-t[0],i=t[3]-t[1],s=new Path2D;s.rect(t[0],t[1],e,i),l.clip(s)}class Ui{getPattern(){z("Abstract method `getPattern` called.")}}class Ar extends Ui{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){let e;this._type==="axial"?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const i of this._colorStops)e.addColorStop(i[0],i[1]);return e}getPattern(t,e,i,s){let n;if(s===ot.STROKE||s===ot.FILL){const r=e.current.getClippedPathBoundingBox(s,G(t))||[0,0,0,0],a=Math.ceil(r[2]-r[0])||1,o=Math.ceil(r[3]-r[1])||1,h=e.cachedCanvases.getCanvas("pattern",a,o),c=h.context;c.clearRect(0,0,c.canvas.width,c.canvas.height),c.beginPath(),c.rect(0,0,c.canvas.width,c.canvas.height),c.translate(-r[0],-r[1]),i=M.transform(i,[1,0,0,1,r[0],r[1]]),c.transform(...e.baseTransform),this.matrix&&c.transform(...this.matrix),Si(c,this._bbox),c.fillStyle=this._createGradient(c),c.fill(),n=t.createPattern(h.canvas,"no-repeat");const d=new DOMMatrix(i);n.setTransform(d)}else Si(t,this._bbox),n=this._createGradient(t);return n}}function li(l,t,e,i,s,n,r,a){const o=t.coords,h=t.colors,c=l.data,d=l.width*4;let u;o[e+1]>o[i+1]&&(u=e,e=i,i=u,u=n,n=r,r=u),o[i+1]>o[s+1]&&(u=i,i=s,s=u,u=r,r=a,a=u),o[e+1]>o[i+1]&&(u=e,e=i,i=u,u=n,n=r,r=u);const f=(o[e]+t.offsetX)*t.scaleX,p=(o[e+1]+t.offsetY)*t.scaleY,g=(o[i]+t.offsetX)*t.scaleX,b=(o[i+1]+t.offsetY)*t.scaleY,m=(o[s]+t.offsetX)*t.scaleX,w=(o[s+1]+t.offsetY)*t.scaleY;if(p>=w)return;const y=h[n],A=h[n+1],v=h[n+2],C=h[r],x=h[r+1],T=h[r+2],_=h[a],S=h[a+1],P=h[a+2],I=Math.round(p),$=Math.round(w);let O,tt,L,k,ht,Pt,kt,At;for(let nt=I;nt<=$;nt++){if(nt<b){const W=nt<p?0:(p-nt)/(p-b);O=f-(f-g)*W,tt=y-(y-C)*W,L=A-(A-x)*W,k=v-(v-T)*W}else{let W;nt>w?W=1:b===w?W=0:W=(b-nt)/(b-w),O=g-(g-m)*W,tt=C-(C-_)*W,L=x-(x-S)*W,k=T-(T-P)*W}let et;nt<p?et=0:nt>w?et=1:et=(p-nt)/(p-w),ht=f-(f-m)*et,Pt=y-(y-_)*et,kt=A-(A-S)*et,At=v-(v-P)*et;const Qt=Math.round(Math.min(O,ht)),ae=Math.round(Math.max(O,ht));let dt=d*nt+Qt*4;for(let W=Qt;W<=ae;W++)et=(O-W)/(O-ht),et<0?et=0:et>1&&(et=1),c[dt++]=tt-(tt-Pt)*et|0,c[dt++]=L-(L-kt)*et|0,c[dt++]=k-(k-At)*et|0,c[dt++]=255}}function _r(l,t,e){const i=t.coords,s=t.colors;let n,r;switch(t.type){case"lattice":const a=t.verticesPerRow,o=Math.floor(i.length/a)-1,h=a-1;for(n=0;n<o;n++){let c=n*a;for(let d=0;d<h;d++,c++)li(l,e,i[c],i[c+1],i[c+a],s[c],s[c+1],s[c+a]),li(l,e,i[c+a+1],i[c+1],i[c+a],s[c+a+1],s[c+1],s[c+a])}break;case"triangles":for(n=0,r=i.length;n<r;n+=3)li(l,e,i[n],i[n+1],i[n+2],s[n],s[n+1],s[n+2]);break;default:throw new Error("illegal figure")}}class vr extends Ui{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[7],this._background=t[8],this.matrix=null}_createMeshCanvas(t,e,i){const a=Math.floor(this._bounds[0]),o=Math.floor(this._bounds[1]),h=Math.ceil(this._bounds[2])-a,c=Math.ceil(this._bounds[3])-o,d=Math.min(Math.ceil(Math.abs(h*t[0]*1.1)),3e3),u=Math.min(Math.ceil(Math.abs(c*t[1]*1.1)),3e3),f=h/d,p=c/u,g={coords:this._coords,colors:this._colors,offsetX:-a,offsetY:-o,scaleX:1/f,scaleY:1/p},b=d+2*2,m=u+2*2,w=i.getCanvas("mesh",b,m),y=w.context,A=y.createImageData(d,u);if(e){const C=A.data;for(let x=0,T=C.length;x<T;x+=4)C[x]=e[0],C[x+1]=e[1],C[x+2]=e[2],C[x+3]=255}for(const C of this._figures)_r(A,C,g);return y.putImageData(A,2,2),{canvas:w.canvas,offsetX:a-2*f,offsetY:o-2*p,scaleX:f,scaleY:p}}getPattern(t,e,i,s){Si(t,this._bbox);let n;if(s===ot.SHADING)n=M.singularValueDecompose2dScale(G(t));else if(n=M.singularValueDecompose2dScale(e.baseTransform),this.matrix){const a=M.singularValueDecompose2dScale(this.matrix);n=[n[0]*a[0],n[1]*a[1]]}const r=this._createMeshCanvas(n,s===ot.SHADING?null:this._background,e.cachedCanvases);return s!==ot.SHADING&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(r.offsetX,r.offsetY),t.scale(r.scaleX,r.scaleY),t.createPattern(r.canvas,"no-repeat")}}class Er extends Ui{getPattern(){return"hotpink"}}function Sr(l){switch(l[0]){case"RadialAxial":return new Ar(l);case"Mesh":return new vr(l);case"Dummy":return new Er}throw new Error(`Unknown IR type: ${l[0]}`)}const ns={COLORED:1,UNCOLORED:2};class zi{static MAX_PATTERN_SIZE=3e3;constructor(t,e,i,s,n){this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.color=e,this.ctx=i,this.canvasGraphicsFactory=s,this.baseTransform=n}createPatternCanvas(t){const{bbox:e,operatorList:i,paintType:s,tilingType:n,color:r,canvasGraphicsFactory:a}=this;let{xstep:o,ystep:h}=this;o=Math.abs(o),h=Math.abs(h),qe("TilingType: "+n);const c=e[0],d=e[1],u=e[2],f=e[3],p=u-c,g=f-d,b=M.singularValueDecompose2dScale(this.matrix),m=M.singularValueDecompose2dScale(this.baseTransform),w=b[0]*m[0],y=b[1]*m[1];let A=p,v=g,C=!1,x=!1;const T=Math.ceil(o*w),_=Math.ceil(h*y),S=Math.ceil(p*w),P=Math.ceil(g*y);T>=S?A=o:C=!0,_>=P?v=h:x=!0;const I=this.getSizeAndScale(A,this.ctx.canvas.width,w),$=this.getSizeAndScale(v,this.ctx.canvas.height,y),O=t.cachedCanvases.getCanvas("pattern",I.size,$.size),tt=O.context,L=a.createCanvasGraphics(tt);if(L.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(L,s,r),tt.translate(-I.scale*c,-$.scale*d),L.transform(I.scale,0,0,$.scale,0,0),tt.save(),this.clipBbox(L,c,d,u,f),L.baseTransform=G(L.ctx),L.executeOperatorList(i),L.endDrawing(),tt.restore(),C||x){const k=O.canvas;C&&(A=o),x&&(v=h);const ht=this.getSizeAndScale(A,this.ctx.canvas.width,w),Pt=this.getSizeAndScale(v,this.ctx.canvas.height,y),kt=ht.size,At=Pt.size,nt=t.cachedCanvases.getCanvas("pattern-workaround",kt,At),et=nt.context,Qt=C?Math.floor(p/o):0,ae=x?Math.floor(g/h):0;for(let dt=0;dt<=Qt;dt++)for(let W=0;W<=ae;W++)et.drawImage(k,kt*dt,At*W,kt,At,0,0,kt,At);return{canvas:nt.canvas,scaleX:ht.scale,scaleY:Pt.scale,offsetX:c,offsetY:d}}return{canvas:O.canvas,scaleX:I.scale,scaleY:$.scale,offsetX:c,offsetY:d}}getSizeAndScale(t,e,i){const s=Math.max(zi.MAX_PATTERN_SIZE,e);let n=Math.ceil(t*i);return n>=s?n=s:i=n/t,{scale:i,size:n}}clipBbox(t,e,i,s,n){const r=s-e,a=n-i;t.ctx.rect(e,i,r,a),t.current.updateRectMinMax(G(t.ctx),[e,i,s,n]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,i){const s=t.ctx,n=t.current;switch(e){case ns.COLORED:const r=this.ctx;s.fillStyle=r.fillStyle,s.strokeStyle=r.strokeStyle,n.fillColor=r.fillStyle,n.strokeColor=r.strokeStyle;break;case ns.UNCOLORED:const a=M.makeHexColor(i[0],i[1],i[2]);s.fillStyle=a,s.strokeStyle=a,n.fillColor=a,n.strokeColor=a;break;default:throw new Kn(`Unsupported paint type: ${e}`)}}getPattern(t,e,i,s){let n=i;s!==ot.SHADING&&(n=M.transform(n,e.baseTransform),this.matrix&&(n=M.transform(n,this.matrix)));const r=this.createPatternCanvas(e);let a=new DOMMatrix(n);a=a.translate(r.offsetX,r.offsetY),a=a.scale(1/r.scaleX,1/r.scaleY);const o=t.createPattern(r.canvas,"repeat");return o.setTransform(a),o}}function xr({src:l,srcPos:t=0,dest:e,width:i,height:s,nonBlackColor:n=4294967295,inverseDecode:r=!1}){const a=ct.isLittleEndian?4278190080:255,[o,h]=r?[n,a]:[a,n],c=i>>3,d=i&7,u=l.length;e=new Uint32Array(e.buffer);let f=0;for(let p=0;p<s;p++){for(const b=t+c;t<b;t++){const m=t<u?l[t]:255;e[f++]=m&128?h:o,e[f++]=m&64?h:o,e[f++]=m&32?h:o,e[f++]=m&16?h:o,e[f++]=m&8?h:o,e[f++]=m&4?h:o,e[f++]=m&2?h:o,e[f++]=m&1?h:o}if(d===0)continue;const g=t<u?l[t++]:255;for(let b=0;b<d;b++)e[f++]=g&1<<7-b?h:o}return{srcPos:t,destPos:f}}const rs=16,as=100,Pr=15,os=10,ls=1e3,mt=16;function Cr(l,t){if(l._removeMirroring)throw new Error("Context is already forwarding operations.");l.__originalSave=l.save,l.__originalRestore=l.restore,l.__originalRotate=l.rotate,l.__originalScale=l.scale,l.__originalTranslate=l.translate,l.__originalTransform=l.transform,l.__originalSetTransform=l.setTransform,l.__originalResetTransform=l.resetTransform,l.__originalClip=l.clip,l.__originalMoveTo=l.moveTo,l.__originalLineTo=l.lineTo,l.__originalBezierCurveTo=l.bezierCurveTo,l.__originalRect=l.rect,l.__originalClosePath=l.closePath,l.__originalBeginPath=l.beginPath,l._removeMirroring=()=>{l.save=l.__originalSave,l.restore=l.__originalRestore,l.rotate=l.__originalRotate,l.scale=l.__originalScale,l.translate=l.__originalTranslate,l.transform=l.__originalTransform,l.setTransform=l.__originalSetTransform,l.resetTransform=l.__originalResetTransform,l.clip=l.__originalClip,l.moveTo=l.__originalMoveTo,l.lineTo=l.__originalLineTo,l.bezierCurveTo=l.__originalBezierCurveTo,l.rect=l.__originalRect,l.closePath=l.__originalClosePath,l.beginPath=l.__originalBeginPath,delete l._removeMirroring},l.save=function(){t.save(),this.__originalSave()},l.restore=function(){t.restore(),this.__originalRestore()},l.translate=function(i,s){t.translate(i,s),this.__originalTranslate(i,s)},l.scale=function(i,s){t.scale(i,s),this.__originalScale(i,s)},l.transform=function(i,s,n,r,a,o){t.transform(i,s,n,r,a,o),this.__originalTransform(i,s,n,r,a,o)},l.setTransform=function(i,s,n,r,a,o){t.setTransform(i,s,n,r,a,o),this.__originalSetTransform(i,s,n,r,a,o)},l.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},l.rotate=function(i){t.rotate(i),this.__originalRotate(i)},l.clip=function(i){t.clip(i),this.__originalClip(i)},l.moveTo=function(e,i){t.moveTo(e,i),this.__originalMoveTo(e,i)},l.lineTo=function(e,i){t.lineTo(e,i),this.__originalLineTo(e,i)},l.bezierCurveTo=function(e,i,s,n,r,a){t.bezierCurveTo(e,i,s,n,r,a),this.__originalBezierCurveTo(e,i,s,n,r,a)},l.rect=function(e,i,s,n){t.rect(e,i,s,n),this.__originalRect(e,i,s,n)},l.closePath=function(){t.closePath(),this.__originalClosePath()},l.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}class Tr{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,i){let s;return this.cache[t]!==void 0?(s=this.cache[t],this.canvasFactory.reset(s,e,i)):(s=this.canvasFactory.create(e,i),this.cache[t]=s),s}delete(t){delete this.cache[t]}clear(){for(const t in this.cache){const e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function Re(l,t,e,i,s,n,r,a,o,h){const[c,d,u,f,p,g]=G(l);if(d===0&&u===0){const w=r*c+p,y=Math.round(w),A=a*f+g,v=Math.round(A),C=(r+o)*c+p,x=Math.abs(Math.round(C)-y)||1,T=(a+h)*f+g,_=Math.abs(Math.round(T)-v)||1;return l.setTransform(Math.sign(c),0,0,Math.sign(f),y,v),l.drawImage(t,e,i,s,n,0,0,x,_),l.setTransform(c,d,u,f,p,g),[x,_]}if(c===0&&f===0){const w=a*u+p,y=Math.round(w),A=r*d+g,v=Math.round(A),C=(a+h)*u+p,x=Math.abs(Math.round(C)-y)||1,T=(r+o)*d+g,_=Math.abs(Math.round(T)-v)||1;return l.setTransform(0,Math.sign(d),Math.sign(u),0,y,v),l.drawImage(t,e,i,s,n,0,0,_,x),l.setTransform(c,d,u,f,p,g),[_,x]}l.drawImage(t,e,i,s,n,r,a,o,h);const b=Math.hypot(c,d),m=Math.hypot(u,f);return[b*o,m*h]}function Lr(l){const{width:t,height:e}=l;if(t>ls||e>ls)return null;const i=1e3,s=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),n=t+1;let r=new Uint8Array(n*(e+1)),a,o,h;const c=t+7&-8;let d=new Uint8Array(c*e),u=0;for(const m of l.data){let w=128;for(;w>0;)d[u++]=m&w?0:255,w>>=1}let f=0;for(u=0,d[u]!==0&&(r[0]=1,++f),o=1;o<t;o++)d[u]!==d[u+1]&&(r[o]=d[u]?2:1,++f),u++;for(d[u]!==0&&(r[o]=2,++f),a=1;a<e;a++){u=a*c,h=a*n,d[u-c]!==d[u]&&(r[h]=d[u]?1:8,++f);let m=(d[u]?4:0)+(d[u-c]?8:0);for(o=1;o<t;o++)m=(m>>2)+(d[u+1]?4:0)+(d[u-c+1]?8:0),s[m]&&(r[h+o]=s[m],++f),u++;if(d[u-c]!==d[u]&&(r[h+o]=d[u]?2:4,++f),f>i)return null}for(u=c*(e-1),h=a*n,d[u]!==0&&(r[h]=8,++f),o=1;o<t;o++)d[u]!==d[u+1]&&(r[h+o]=d[u]?4:8,++f),u++;if(d[u]!==0&&(r[h+o]=4,++f),f>i)return null;const p=new Int32Array([0,n,-1,0,-n,0,0,0,1]),g=new Path2D;for(a=0;f&&a<=e;a++){let m=a*n;const w=m+t;for(;m<w&&!r[m];)m++;if(m===w)continue;g.moveTo(m%n,a);const y=m;let A=r[m];do{const v=p[A];do m+=v;while(!r[m]);const C=r[m];C!==5&&C!==10?(A=C,r[m]=0):(A=C&51*A>>4,r[m]&=A>>2|A<<2),g.lineTo(m%n,m/n|0),r[m]||--f}while(y!==m);--a}return d=null,r=null,function(m){m.save(),m.scale(1/t,-1/e),m.translate(0,-e),m.fill(g),m.beginPath(),m.restore()}}class hs{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=Qs,this.textMatrixScale=1,this.fontMatrix=wi,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=rt.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.patternStroke=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,t,e])}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,e){this.x=t,this.y=e}updatePathMinMax(t,e,i){[e,i]=M.applyTransform([e,i],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,i),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,i)}updateRectMinMax(t,e){const i=M.applyTransform(e,t),s=M.applyTransform(e.slice(2),t),n=M.applyTransform([e[0],e[3]],t),r=M.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,i[0],s[0],n[0],r[0]),this.minY=Math.min(this.minY,i[1],s[1],n[1],r[1]),this.maxX=Math.max(this.maxX,i[0],s[0],n[0],r[0]),this.maxY=Math.max(this.maxY,i[1],s[1],n[1],r[1])}updateScalingPathMinMax(t,e){M.scaleMinMax(t,e),this.minX=Math.min(this.minX,e[0]),this.minY=Math.min(this.minY,e[1]),this.maxX=Math.max(this.maxX,e[2]),this.maxY=Math.max(this.maxY,e[3])}updateCurvePathMinMax(t,e,i,s,n,r,a,o,h,c){const d=M.bezierBoundingBox(e,i,s,n,r,a,o,h,c);c||this.updateRectMinMax(t,d)}getPathBoundingBox(t=ot.FILL,e=null){const i=[this.minX,this.minY,this.maxX,this.maxY];if(t===ot.STROKE){e||z("Stroke bounding box must include transform.");const s=M.singularValueDecompose2dScale(e),n=s[0]*this.lineWidth/2,r=s[1]*this.lineWidth/2;i[0]-=n,i[1]-=r,i[2]+=n,i[3]+=r}return i}updateClipFromPath(){const t=M.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(t){this.clipBox=t,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(t=ot.FILL,e=null){return M.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function cs(l,t){if(t instanceof ImageData){l.putImageData(t,0,0);return}const e=t.height,i=t.width,s=e%mt,n=(e-s)/mt,r=s===0?n:n+1,a=l.createImageData(i,mt);let o=0,h;const c=t.data,d=a.data;let u,f,p,g;if(t.kind===je.GRAYSCALE_1BPP){const b=c.byteLength,m=new Uint32Array(d.buffer,0,d.byteLength>>2),w=m.length,y=i+7>>3,A=4294967295,v=ct.isLittleEndian?4278190080:255;for(u=0;u<r;u++){for(p=u<n?mt:s,h=0,f=0;f<p;f++){const C=b-o;let x=0;const T=C>y?i:C*8-7,_=T&-8;let S=0,P=0;for(;x<_;x+=8)P=c[o++],m[h++]=P&128?A:v,m[h++]=P&64?A:v,m[h++]=P&32?A:v,m[h++]=P&16?A:v,m[h++]=P&8?A:v,m[h++]=P&4?A:v,m[h++]=P&2?A:v,m[h++]=P&1?A:v;for(;x<T;x++)S===0&&(P=c[o++],S=128),m[h++]=P&S?A:v,S>>=1}for(;h<w;)m[h++]=0;l.putImageData(a,0,u*mt)}}else if(t.kind===je.RGBA_32BPP){for(f=0,g=i*mt*4,u=0;u<n;u++)d.set(c.subarray(o,o+g)),o+=g,l.putImageData(a,0,f),f+=mt;u<r&&(g=i*s*4,d.set(c.subarray(o,o+g)),l.putImageData(a,0,f))}else if(t.kind===je.RGB_24BPP)for(p=mt,g=i*p,u=0;u<r;u++){for(u>=n&&(p=s,g=i*p),h=0,f=g;f--;)d[h++]=c[o++],d[h++]=c[o++],d[h++]=c[o++],d[h++]=255;l.putImageData(a,0,u*mt)}else throw new Error(`bad image kind: ${t.kind}`)}function ds(l,t){if(t.bitmap){l.drawImage(t.bitmap,0,0);return}const e=t.height,i=t.width,s=e%mt,n=(e-s)/mt,r=s===0?n:n+1,a=l.createImageData(i,mt);let o=0;const h=t.data,c=a.data;for(let d=0;d<r;d++){const u=d<n?mt:s;({srcPos:o}=xr({src:h,srcPos:o,dest:c,width:i,height:u,nonBlackColor:0})),l.putImageData(a,0,d*mt)}}function le(l,t){const e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const i of e)l[i]!==void 0&&(t[i]=l[i]);l.setLineDash!==void 0&&(t.setLineDash(l.getLineDash()),t.lineDashOffset=l.lineDashOffset)}function Ie(l){if(l.strokeStyle=l.fillStyle="#000000",l.fillRule="nonzero",l.globalAlpha=1,l.lineWidth=1,l.lineCap="butt",l.lineJoin="miter",l.miterLimit=10,l.globalCompositeOperation="source-over",l.font="10px sans-serif",l.setLineDash!==void 0&&(l.setLineDash([]),l.lineDashOffset=0),!lt){const{filter:t}=l;t!=="none"&&t!==""&&(l.filter="none")}}function us(l,t){if(t)return!0;const e=M.singularValueDecompose2dScale(l);e[0]=Math.fround(e[0]),e[1]=Math.fround(e[1]);const i=Math.fround((globalThis.devicePixelRatio||1)*ne.PDF_TO_CSS_UNITS);return e[0]<=i&&e[1]<=i}const Rr=["butt","round","square"],Ir=["miter","round","bevel"],Mr={},fs={};class ee{constructor(t,e,i,s,n,{optionalContentConfig:r,markedContentStack:a=null},o,h){this.ctx=t,this.current=new hs(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=i,this.canvasFactory=s,this.filterFactory=n,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=a||[],this.optionalContentConfig=r,this.cachedCanvases=new Tr(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=o,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=h,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t,e=null){return typeof t=="string"?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:i=!1,background:s=null}){const n=this.ctx.canvas.width,r=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=s||"#ffffff",this.ctx.fillRect(0,0,n,r),this.ctx.fillStyle=a,i){const o=this.cachedCanvases.getCanvas("transparent",n,r);this.compositeCtx=this.ctx,this.transparentCanvas=o.canvas,this.ctx=o.context,this.ctx.save(),this.ctx.transform(...G(this.compositeCtx))}this.ctx.save(),Ie(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[0]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=G(this.ctx)}executeOperatorList(t,e,i,s){const n=t.argsArray,r=t.fnArray;let a=e||0;const o=n.length;if(o===a)return a;const h=o-a>os&&typeof i=="function",c=h?Date.now()+Pr:0;let d=0;const u=this.commonObjs,f=this.objs;let p;for(;;){if(s!==void 0&&a===s.nextBreakPoint)return s.breakIt(a,i),a;if(p=r[a],p!==St.dependency)this[p].apply(this,n[a]);else for(const g of n[a]){const b=g.startsWith("g_")?u:f;if(!b.has(g))return b.get(g,i),a}if(a++,a===o)return a;if(h&&++d>os){if(Date.now()>c)return i(),a;d=0}}}#t(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)}endDrawing(){this.#t(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#e()}#e(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){const i=t.width??t.displayWidth,s=t.height??t.displayHeight;let n=Math.max(Math.hypot(e[0],e[1]),1),r=Math.max(Math.hypot(e[2],e[3]),1),a=i,o=s,h="prescale1",c,d;for(;n>2&&a>1||r>2&&o>1;){let u=a,f=o;n>2&&a>1&&(u=a>=16384?Math.floor(a/2)-1||1:Math.ceil(a/2),n/=a/u),r>2&&o>1&&(f=o>=16384?Math.floor(o/2)-1||1:Math.ceil(o)/2,r/=o/f),c=this.cachedCanvases.getCanvas(h,u,f),d=c.context,d.clearRect(0,0,u,f),d.drawImage(t,0,0,a,o,0,0,u,f),t=c.canvas,a=u,o=f,h=h==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:a,paintHeight:o}}_createMaskCanvas(t){const e=this.ctx,{width:i,height:s}=t,n=this.current.fillColor,r=this.current.patternFill,a=G(e);let o,h,c,d;if((t.bitmap||t.data)&&t.count>1){const T=t.bitmap||t.data.buffer;h=JSON.stringify(r?a:[a.slice(0,4),n]),o=this._cachedBitmapsMap.get(T),o||(o=new Map,this._cachedBitmapsMap.set(T,o));const _=o.get(h);if(_&&!r){const S=Math.round(Math.min(a[0],a[2])+a[4]),P=Math.round(Math.min(a[1],a[3])+a[5]);return{canvas:_,offsetX:S,offsetY:P}}c=_}c||(d=this.cachedCanvases.getCanvas("maskCanvas",i,s),ds(d.context,t));let u=M.transform(a,[1/i,0,0,-1/s,0,0]);u=M.transform(u,[1,0,0,1,0,-s]);const[f,p,g,b]=M.getAxialAlignedBoundingBox([0,0,i,s],u),m=Math.round(g-f)||1,w=Math.round(b-p)||1,y=this.cachedCanvases.getCanvas("fillCanvas",m,w),A=y.context,v=f,C=p;A.translate(-v,-C),A.transform(...u),c||(c=this._scaleImage(d.canvas,Ct(A)),c=c.img,o&&r&&o.set(h,c)),A.imageSmoothingEnabled=us(G(A),t.interpolate),Re(A,c,0,0,c.width,c.height,0,0,i,s),A.globalCompositeOperation="source-in";const x=M.transform(Ct(A),[1,0,0,1,-v,-C]);return A.fillStyle=r?n.getPattern(e,this,x,ot.FILL):n,A.fillRect(0,0,i,s),o&&!r&&(this.cachedCanvases.delete("fillCanvas"),o.set(h,y.canvas)),{canvas:y.canvas,offsetX:Math.round(v),offsetY:Math.round(C)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=Rr[t]}setLineJoin(t){this.ctx.lineJoin=Ir[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const i=this.ctx;i.setLineDash!==void 0&&(i.setLineDash(t),i.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[e,i]of t)switch(e){case"LW":this.setLineWidth(i);break;case"LC":this.setLineCap(i);break;case"LJ":this.setLineJoin(i);break;case"ML":this.setMiterLimit(i);break;case"D":this.setDash(i[0],i[1]);break;case"RI":this.setRenderingIntent(i);break;case"FL":this.setFlatness(i);break;case"Font":this.setFont(i[0],i[1]);break;case"CA":this.current.strokeAlpha=i;break;case"ca":this.current.fillAlpha=i,this.ctx.globalAlpha=i;break;case"BM":this.ctx.globalCompositeOperation=i;break;case"SMask":this.current.activeSMask=i?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(i);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const t=this.ctx.canvas.width,e=this.ctx.canvas.height,i="smaskGroupAt"+this.groupLevel,s=this.cachedCanvases.getCanvas(i,t,e);this.suspendedCtx=this.ctx,this.ctx=s.context;const n=this.ctx;n.setTransform(...G(this.suspendedCtx)),le(this.suspendedCtx,n),Cr(n,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),le(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,i=this.suspendedCtx;this.composeSMask(i,e,this.ctx,t),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(t,e,i,s){const n=s[0],r=s[1],a=s[2]-n,o=s[3]-r;a===0||o===0||(this.genericComposeSMask(e.context,i,a,o,e.subtype,e.backdrop,e.transferMap,n,r,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(i.canvas,0,0),t.restore())}genericComposeSMask(t,e,i,s,n,r,a,o,h,c,d){let u=t.canvas,f=o-c,p=h-d;if(r){const b=M.makeHexColor(...r);if(f<0||p<0||f+i>u.width||p+s>u.height){const m=this.cachedCanvases.getCanvas("maskExtension",i,s),w=m.context;w.drawImage(u,-f,-p),w.globalCompositeOperation="destination-atop",w.fillStyle=b,w.fillRect(0,0,i,s),w.globalCompositeOperation="source-over",u=m.canvas,f=p=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const m=new Path2D;m.rect(f,p,i,s),t.clip(m),t.globalCompositeOperation="destination-atop",t.fillStyle=b,t.fillRect(f,p,i,s),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),n==="Alpha"&&a?e.filter=this.filterFactory.addAlphaFilter(a):n==="Luminosity"&&(e.filter=this.filterFactory.addLuminosityFilter(a));const g=new Path2D;g.rect(o,h,i,s),e.clip(g),e.globalCompositeOperation="destination-in",e.drawImage(u,f,p,i,s,o,h,i,s),e.restore()}save(){this.inSMaskMode?(le(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){this.stateStack.length===0&&this.inSMaskMode&&this.endSMaskMode(),this.stateStack.length!==0&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),le(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,i,s,n,r){this.ctx.transform(t,e,i,s,n,r),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,i){const s=this.ctx,n=this.current;let r=n.x,a=n.y,o,h;const c=G(s),d=c[0]===0&&c[3]===0||c[1]===0&&c[2]===0,u=d?i.slice(0):null;for(let f=0,p=0,g=t.length;f<g;f++)switch(t[f]|0){case St.rectangle:r=e[p++],a=e[p++];const b=e[p++],m=e[p++],w=r+b,y=a+m;s.moveTo(r,a),b===0||m===0?s.lineTo(w,y):(s.lineTo(w,a),s.lineTo(w,y),s.lineTo(r,y)),d||n.updateRectMinMax(c,[r,a,w,y]),s.closePath();break;case St.moveTo:r=e[p++],a=e[p++],s.moveTo(r,a),d||n.updatePathMinMax(c,r,a);break;case St.lineTo:r=e[p++],a=e[p++],s.lineTo(r,a),d||n.updatePathMinMax(c,r,a);break;case St.curveTo:o=r,h=a,r=e[p+4],a=e[p+5],s.bezierCurveTo(e[p],e[p+1],e[p+2],e[p+3],r,a),n.updateCurvePathMinMax(c,o,h,e[p],e[p+1],e[p+2],e[p+3],r,a,u),p+=6;break;case St.curveTo2:o=r,h=a,s.bezierCurveTo(r,a,e[p],e[p+1],e[p+2],e[p+3]),n.updateCurvePathMinMax(c,o,h,r,a,e[p],e[p+1],e[p+2],e[p+3],u),r=e[p+2],a=e[p+3],p+=4;break;case St.curveTo3:o=r,h=a,r=e[p+2],a=e[p+3],s.bezierCurveTo(e[p],e[p+1],r,a,r,a),n.updateCurvePathMinMax(c,o,h,e[p],e[p+1],r,a,r,a,u),p+=4;break;case St.closePath:s.closePath();break}d&&n.updateScalingPathMinMax(c,u),n.setCurrentPoint(r,a)}closePath(){this.ctx.closePath()}stroke(t=!0){const e=this.ctx,i=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof i=="object"&&i?.getPattern?(e.save(),e.strokeStyle=i.getPattern(e,this,Ct(e),ot.STROKE),this.rescaleAndStroke(!1),e.restore()):this.rescaleAndStroke(!0)),t&&this.consumePath(this.current.getClippedPathBoundingBox()),e.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(t=!0){const e=this.ctx,i=this.current.fillColor,s=this.current.patternFill;let n=!1;s&&(e.save(),e.fillStyle=i.getPattern(e,this,Ct(e),ot.FILL),n=!0);const r=this.current.getClippedPathBoundingBox();this.contentVisible&&r!==null&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),n&&e.restore(),t&&this.consumePath(r)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=Mr}eoClip(){this.pendingClip=fs}beginText(){this.current.textMatrix=Qs,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const t=this.pendingTextPaths,e=this.ctx;if(t===void 0){e.beginPath();return}const i=new Path2D,s=e.getTransform().invertSelf();for(const{transform:n,x:r,y:a,fontSize:o,path:h}of t)i.addPath(h,new DOMMatrix(n).preMultiplySelf(s).translate(r,a).scale(o,-o));e.clip(i),e.beginPath(),delete this.pendingTextPaths}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){const i=this.commonObjs.get(t),s=this.current;if(!i)throw new Error(`Can't find font for ${t}`);if(s.fontMatrix=i.fontMatrix||wi,(s.fontMatrix[0]===0||s.fontMatrix[3]===0)&&j("Invalid font matrix for font "+t),e<0?(e=-e,s.fontDirection=-1):s.fontDirection=1,this.current.font=i,this.current.fontSize=e,i.isType3Font)return;const n=i.loadedName||"sans-serif",r=i.systemFontInfo?.css||`"${n}", ${i.fallbackName}`;let a="normal";i.black?a="900":i.bold&&(a="bold");const o=i.italic?"italic":"normal";let h=e;e<rs?h=rs:e>as&&(h=as),this.current.fontSizeScale=e/h,this.ctx.font=`${o} ${a} ${h}px ${r}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t,e,i,s,n,r){this.current.textMatrix=[t,e,i,s,n,r],this.current.textMatrixScale=Math.hypot(t,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}#i(t,e,i){const s=new Path2D;return s.addPath(t,new DOMMatrix(i).invertSelf().multiplySelf(e)),s}paintChar(t,e,i,s,n){const r=this.ctx,a=this.current,o=a.font,h=a.textRenderingMode,c=a.fontSize/a.fontSizeScale,d=h&rt.FILL_STROKE_MASK,u=!!(h&rt.ADD_TO_PATH_FLAG),f=a.patternFill&&!o.missingFile,p=a.patternStroke&&!o.missingFile;let g;if((o.disableFontFace||u||f||p)&&(g=o.getPathGenerator(this.commonObjs,t)),o.disableFontFace||f||p){if(r.save(),r.translate(e,i),r.scale(c,-c),d===rt.FILL||d===rt.FILL_STROKE)if(s){const b=r.getTransform();r.setTransform(...s),r.fill(this.#i(g,b,s))}else r.fill(g);if(d===rt.STROKE||d===rt.FILL_STROKE)if(n){const b=r.getTransform();r.setTransform(...n),r.stroke(this.#i(g,b,n))}else r.lineWidth/=c,r.stroke(g);r.restore()}else(d===rt.FILL||d===rt.FILL_STROKE)&&r.fillText(t,e,i),(d===rt.STROKE||d===rt.FILL_STROKE)&&r.strokeText(t,e,i);u&&(this.pendingTextPaths||=[]).push({transform:G(r),x:e,y:i,fontSize:c,path:g})}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let i=!1;for(let s=3;s<e.length;s+=4)if(e[s]>0&&e[s]<255){i=!0;break}return H(this,"isFontSubpixelAAEnabled",i)}showText(t){const e=this.current,i=e.font;if(i.isType3Font)return this.showType3Text(t);const s=e.fontSize;if(s===0)return;const n=this.ctx,r=e.fontSizeScale,a=e.charSpacing,o=e.wordSpacing,h=e.fontDirection,c=e.textHScale*h,d=t.length,u=i.vertical,f=u?1:-1,p=i.defaultVMetrics,g=s*e.fontMatrix[0],b=e.textRenderingMode===rt.FILL&&!i.disableFontFace&&!e.patternFill;n.save(),n.transform(...e.textMatrix),n.translate(e.x,e.y+e.textRise),h>0?n.scale(c,-1):n.scale(c,1);let m,w;if(e.patternFill){n.save();const x=e.fillColor.getPattern(n,this,Ct(n),ot.FILL);m=G(n),n.restore(),n.fillStyle=x}if(e.patternStroke){n.save();const x=e.strokeColor.getPattern(n,this,Ct(n),ot.STROKE);w=G(n),n.restore(),n.strokeStyle=x}let y=e.lineWidth;const A=e.textMatrixScale;if(A===0||y===0){const x=e.textRenderingMode&rt.FILL_STROKE_MASK;(x===rt.STROKE||x===rt.FILL_STROKE)&&(y=this.getSinglePixelWidth())}else y/=A;if(r!==1&&(n.scale(r,r),y/=r),n.lineWidth=y,i.isInvalidPDFjsFont){const x=[];let T=0;for(const _ of t)x.push(_.unicode),T+=_.width;n.fillText(x.join(""),0,0),e.x+=T*g*c,n.restore(),this.compose();return}let v=0,C;for(C=0;C<d;++C){const x=t[C];if(typeof x=="number"){v+=f*x*s/1e3;continue}let T=!1;const _=(x.isSpace?o:0)+a,S=x.fontChar,P=x.accent;let I,$,O=x.width;if(u){const L=x.vmetric||p,k=-(x.vmetric?L[1]:O*.5)*g,ht=L[2]*g;O=L?-L[0]:O,I=k/r,$=(v+ht)/r}else I=v/r,$=0;if(i.remeasure&&O>0){const L=n.measureText(S).width*1e3/s*r;if(O<L&&this.isFontSubpixelAAEnabled){const k=O/L;T=!0,n.save(),n.scale(k,1),I/=k}else O!==L&&(I+=(O-L)/2e3*s/r)}if(this.contentVisible&&(x.isInFont||i.missingFile)){if(b&&!P)n.fillText(S,I,$);else if(this.paintChar(S,I,$,m,w),P){const L=I+s*P.offset.x/r,k=$-s*P.offset.y/r;this.paintChar(P.fontChar,L,k,m,w)}}const tt=u?O*g-_*h:O*g+_*h;v+=tt,T&&n.restore()}u?e.y-=v:e.x+=v*c,n.restore(),this.compose()}showType3Text(t){const e=this.ctx,i=this.current,s=i.font,n=i.fontSize,r=i.fontDirection,a=s.vertical?1:-1,o=i.charSpacing,h=i.wordSpacing,c=i.textHScale*r,d=i.fontMatrix||wi,u=t.length,f=i.textRenderingMode===rt.INVISIBLE;let p,g,b,m;if(!(f||n===0)){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),e.transform(...i.textMatrix),e.translate(i.x,i.y),e.scale(c,r),p=0;p<u;++p){if(g=t[p],typeof g=="number"){m=a*g*n/1e3,this.ctx.translate(m,0),i.x+=m*c;continue}const w=(g.isSpace?h:0)+o,y=s.charProcOperatorList[g.operatorListId];if(!y){j(`Type3 character "${g.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=g,this.save(),e.scale(n,n),e.transform(...d),this.executeOperatorList(y),this.restore()),b=M.applyTransform([g.width,0],d)[0]*n+w,e.translate(b,0),i.x+=b*c}e.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,i,s,n,r){this.ctx.rect(i,s,n-i,r-s),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if(t[0]==="TilingPattern"){const i=t[1],s=this.baseTransform||G(this.ctx),n={createCanvasGraphics:r=>new ee(r,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new zi(t,i,this.ctx,n,s)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,i){this.ctx.strokeStyle=this.current.strokeColor=M.makeHexColor(t,e,i),this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e,i){this.ctx.fillStyle=this.current.fillColor=M.makeHexColor(t,e,i),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e=null){let i;return this.cachedPatterns.has(t)?i=this.cachedPatterns.get(t):(i=Sr(this.getObject(t)),this.cachedPatterns.set(t,i)),e&&(i.matrix=e),i}shadingFill(t){if(!this.contentVisible)return;const e=this.ctx;this.save();const i=this._getPattern(t);e.fillStyle=i.getPattern(e,this,Ct(e),ot.SHADING);const s=Ct(e);if(s){const{width:n,height:r}=e.canvas,[a,o,h,c]=M.getAxialAlignedBoundingBox([0,0,n,r],s);this.ctx.fillRect(a,o,h-a,c-o)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){z("Should not call beginInlineImage")}beginImageData(){z("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=G(this.ctx),e)){const i=e[2]-e[0],s=e[3]-e[1];this.ctx.rect(e[0],e[1],i,s),this.current.updateRectMinMax(G(this.ctx),e),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const e=this.ctx;t.isolated||qe("TODO: Support non-isolated groups."),t.knockout&&j("Knockout groups not supported.");const i=G(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let s=M.getAxialAlignedBoundingBox(t.bbox,G(e));const n=[0,0,e.canvas.width,e.canvas.height];s=M.intersect(s,n)||[0,0,0,0];const r=Math.floor(s[0]),a=Math.floor(s[1]),o=Math.max(Math.ceil(s[2])-r,1),h=Math.max(Math.ceil(s[3])-a,1);this.current.startNewPathAndClipBox([0,0,o,h]);let c="groupAt"+this.groupLevel;t.smask&&(c+="_smask_"+this.smaskCounter++%2);const d=this.cachedCanvases.getCanvas(c,o,h),u=d.context;u.translate(-r,-a),u.transform(...i),t.smask?this.smaskStack.push({canvas:d.canvas,context:u,offsetX:r,offsetY:a,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(r,a),e.save()),le(e,u),this.ctx=u,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;const e=this.ctx,i=this.groupStack.pop();if(this.ctx=i,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const s=G(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...s);const n=M.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],s);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(n)}}beginAnnotation(t,e,i,s,n){if(this.#t(),Ie(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const r=e[2]-e[0],a=e[3]-e[1];if(n&&this.annotationCanvasMap){i=i.slice(),i[4]-=e[0],i[5]-=e[1],e=e.slice(),e[0]=e[1]=0,e[2]=r,e[3]=a;const[o,h]=M.singularValueDecompose2dScale(G(this.ctx)),{viewportScale:c}=this,d=Math.ceil(r*this.outputScaleX*c),u=Math.ceil(a*this.outputScaleY*c);this.annotationCanvas=this.canvasFactory.create(d,u);const{canvas:f,context:p}=this.annotationCanvas;this.annotationCanvasMap.set(t,f),this.annotationCanvas.savedCtx=this.ctx,this.ctx=p,this.ctx.save(),this.ctx.setTransform(o,0,0,-h,0,a*h),Ie(this.ctx)}else Ie(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],r,a),this.ctx.clip(),this.ctx.beginPath()}this.current=new hs(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...i),this.transform(...s)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#e(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;const e=t.count;t=this.getObject(t.data,t),t.count=e;const i=this.ctx,s=this.processingType3;if(s&&(s.compiled===void 0&&(s.compiled=Lr(t)),s.compiled)){s.compiled(i);return}const n=this._createMaskCanvas(t),r=n.canvas;i.save(),i.setTransform(1,0,0,1,0,0),i.drawImage(r,n.offsetX,n.offsetY),i.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,i=0,s=0,n,r){if(!this.contentVisible)return;t=this.getObject(t.data,t);const a=this.ctx;a.save();const o=G(a);a.transform(e,i,s,n,0,0);const h=this._createMaskCanvas(t);a.setTransform(1,0,0,1,h.offsetX-o[4],h.offsetY-o[5]);for(let c=0,d=r.length;c<d;c+=2){const u=M.transform(o,[e,i,s,n,r[c],r[c+1]]),[f,p]=M.applyTransform([0,0],u);a.drawImage(h.canvas,f,p)}a.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const e=this.ctx,i=this.current.fillColor,s=this.current.patternFill;for(const n of t){const{data:r,width:a,height:o,transform:h}=n,c=this.cachedCanvases.getCanvas("maskCanvas",a,o),d=c.context;d.save();const u=this.getObject(r,n);ds(d,u),d.globalCompositeOperation="source-in",d.fillStyle=s?i.getPattern(d,this,Ct(e),ot.FILL):i,d.fillRect(0,0,a,o),d.restore(),e.save(),e.transform(...h),e.scale(1,-1),Re(e,c.canvas,0,0,a,o,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=this.getObject(t);if(!e){j("Dependent image isn't ready yet");return}this.paintInlineImageXObject(e)}paintImageXObjectRepeat(t,e,i,s){if(!this.contentVisible)return;const n=this.getObject(t);if(!n){j("Dependent image isn't ready yet");return}const r=n.width,a=n.height,o=[];for(let h=0,c=s.length;h<c;h+=2)o.push({transform:[e,0,0,i,s[h],s[h+1]],x:0,y:0,w:r,h:a});this.paintInlineImageXObjectGroup(n,o)}applyTransferMapsToCanvas(t){return this.current.transferMaps!=="none"&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if(this.current.transferMaps==="none")return t.bitmap;const{bitmap:e,width:i,height:s}=t,n=this.cachedCanvases.getCanvas("inlineImage",i,s),r=n.context;return r.filter=this.current.transferMaps,r.drawImage(e,0,0),r.filter="none",n.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,i=t.height,s=this.ctx;if(this.save(),!lt){const{filter:a}=s;a!=="none"&&a!==""&&(s.filter="none")}s.scale(1/e,-1/i);let n;if(t.bitmap)n=this.applyTransferMapsToBitmap(t);else if(typeof HTMLElement=="function"&&t instanceof HTMLElement||!t.data)n=t;else{const o=this.cachedCanvases.getCanvas("inlineImage",e,i).context;cs(o,t),n=this.applyTransferMapsToCanvas(o)}const r=this._scaleImage(n,Ct(s));s.imageSmoothingEnabled=us(G(s),t.interpolate),Re(s,r.img,0,0,r.paintWidth,r.paintHeight,0,-i,e,i),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;const i=this.ctx;let s;if(t.bitmap)s=t.bitmap;else{const n=t.width,r=t.height,o=this.cachedCanvases.getCanvas("inlineImage",n,r).context;cs(o,t),s=this.applyTransferMapsToCanvas(o)}for(const n of e)i.save(),i.transform(...n.transform),i.scale(1,-1),Re(i,s,n.x,n.y,n.w,n.h,0,-1,1,1),i.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,e){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e){t==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(e)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t){const e=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);const i=this.ctx;this.pendingClip&&(e||(this.pendingClip===fs?i.clip("evenodd"):i.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),i.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=G(this.ctx);if(t[1]===0&&t[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),i=Math.hypot(t[0],t[2]),s=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(i,s)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:t}=this.current,{a:e,b:i,c:s,d:n}=this.ctx.getTransform();let r,a;if(i===0&&s===0){const o=Math.abs(e),h=Math.abs(n);if(o===h)if(t===0)r=a=1/o;else{const c=o*t;r=a=c<1?1/c:1}else if(t===0)r=1/o,a=1/h;else{const c=o*t,d=h*t;r=c<1?1/c:1,a=d<1?1/d:1}}else{const o=Math.abs(e*n-i*s),h=Math.hypot(e,i),c=Math.hypot(s,n);if(t===0)r=c/o,a=h/o;else{const d=t*o;r=c>d?c/d:1,a=h>d?h/d:1}}this._cachedScaleForStroking[0]=r,this._cachedScaleForStroking[1]=a}return this._cachedScaleForStroking}rescaleAndStroke(t){const{ctx:e}=this,{lineWidth:i}=this.current,[s,n]=this.getScaleForStroking();if(e.lineWidth=i||1,s===1&&n===1){e.stroke();return}const r=e.getLineDash();if(t&&e.save(),e.scale(s,n),r.length>0){const a=Math.max(s,n);e.setLineDash(r.map(o=>o/a)),e.lineDashOffset/=a}e.stroke(),t&&e.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(const l in St)ee.prototype[l]!==void 0&&(ee.prototype[St[l]]=ee.prototype[l]);let me=class{static#t=null;static#e="";static get workerPort(){return this.#t}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");this.#t=t}static get workerSrc(){return this.#e}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");this.#e=t}};class kr{#t;#e;constructor({parsedData:t,rawData:e}){this.#t=t,this.#e=e}getRaw(){return this.#e}get(t){return this.#t.get(t)??null}getAll(){return Di(this.#t)}has(t){return this.#t.has(t)}}const Jt=Symbol("INTERNAL");class Nr{#t=!1;#e=!1;#i=!1;#s=!0;constructor(t,{name:e,intent:i,usage:s,rbGroups:n}){this.#t=!!(t&yt.DISPLAY),this.#e=!!(t&yt.PRINT),this.name=e,this.intent=i,this.usage=s,this.rbGroups=n}get visible(){if(this.#i)return this.#s;if(!this.#s)return!1;const{print:t,view:e}=this.usage;return this.#t?e?.viewState!=="OFF":this.#e?t?.printState!=="OFF":!0}_setVisible(t,e,i=!1){t!==Jt&&z("Internal method `_setVisible` called."),this.#i=i,this.#s=e}}class Dr{#t=null;#e=new Map;#i=null;#s=null;constructor(t,e=yt.DISPLAY){if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,this.#s=t.order;for(const i of t.groups)this.#e.set(i.id,new Nr(e,i));if(t.baseState==="OFF")for(const i of this.#e.values())i._setVisible(Jt,!1);for(const i of t.on)this.#e.get(i)._setVisible(Jt,!0);for(const i of t.off)this.#e.get(i)._setVisible(Jt,!1);this.#i=this.getHash()}}#r(t){const e=t.length;if(e<2)return!0;const i=t[0];for(let s=1;s<e;s++){const n=t[s];let r;if(Array.isArray(n))r=this.#r(n);else if(this.#e.has(n))r=this.#e.get(n).visible;else return j(`Optional content group not found: ${n}`),!0;switch(i){case"And":if(!r)return!1;break;case"Or":if(r)return!0;break;case"Not":return!r;default:return!0}}return i==="And"}isVisible(t){if(this.#e.size===0)return!0;if(!t)return qe("Optional content group not defined."),!0;if(t.type==="OCG")return this.#e.has(t.id)?this.#e.get(t.id).visible:(j(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return this.#r(t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!this.#e.has(e))return j(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!this.#e.has(e))return j(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!this.#e.has(e))return j(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!this.#e.has(e))return j(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!1}return!0}return j(`Unknown optional content policy ${t.policy}.`),!0}return j(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,i=!0){const s=this.#e.get(t);if(!s){j(`Optional content group not found: ${t}`);return}if(i&&e&&s.rbGroups.length)for(const n of s.rbGroups)for(const r of n)r!==t&&this.#e.get(r)?._setVisible(Jt,!1,!0);s._setVisible(Jt,!!e,!0),this.#t=null}setOCGState({state:t,preserveRB:e}){let i;for(const s of t){switch(s){case"ON":case"OFF":case"Toggle":i=s;continue}const n=this.#e.get(s);if(n)switch(i){case"ON":this.setVisibility(s,!0,e);break;case"OFF":this.setVisibility(s,!1,e);break;case"Toggle":this.setVisibility(s,!n.visible,e);break}}this.#t=null}get hasInitialVisibility(){return this.#i===null||this.getHash()===this.#i}getOrder(){return this.#e.size?this.#s?this.#s.slice():[...this.#e.keys()]:null}getGroups(){return this.#e.size>0?Di(this.#e):null}getGroup(t){return this.#e.get(t)||null}getHash(){if(this.#t!==null)return this.#t;const t=new sn;for(const[e,i]of this.#e)t.update(`${e}:${i.visible}`);return this.#t=t.hexdigest()}}class Fr{constructor(t,{disableRange:e=!1,disableStream:i=!1}){Z(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:s,initialData:n,progressiveDone:r,contentDispositionFilename:a}=t;if(this._queuedChunks=[],this._progressiveDone=r,this._contentDispositionFilename=a,n?.length>0){const o=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;this._queuedChunks.push(o)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!i,this._isRangeSupported=!e,this._contentLength=s,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((o,h)=>{this._onReceiveData({begin:o,chunk:h})}),t.addProgressListener((o,h)=>{this._onProgress({loaded:o,total:h})}),t.addProgressiveReadListener(o=>{this._onReceiveData({chunk:o})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const i=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(t===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(i):this._queuedChunks.push(i);else{const s=this._rangeReaders.some(function(n){return n._begin!==t?!1:(n._enqueue(i),!0)});Z(s,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){t.total===void 0?this._rangeReaders[0]?.onProgress?.({loaded:t.loaded}):this._fullRequestReader?.onProgress?.({loaded:t.loaded,total:t.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){Z(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new Or(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new Br(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeReaders.slice(0))e.cancel(t);this._pdfDataRangeTransport.abort()}}class Or{constructor(t,e,i=!1,s=null){this._stream=t,this._done=i||!1,this._filename=Bi(s)?s:null,this._queuedChunks=e||[],this._loaded=0;for(const n of this._queuedChunks)this._loaded+=n.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class Br{constructor(t,e,i){this._stream=t,this._begin=e,this._end=i,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length===0)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const i of this._requests)i.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function jr(l){let t=!0,e=i("filename\\*","i").exec(l);if(e){e=e[1];let c=a(e);return c=unescape(c),c=o(c),c=h(c),n(c)}if(e=r(l),e){const c=h(e);return n(c)}if(e=i("filename","i").exec(l),e){e=e[1];let c=a(e);return c=h(c),n(c)}function i(c,d){return new RegExp("(?:^|;)\\s*"+c+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',d)}function s(c,d){if(c){if(!/^[\x00-\xFF]+$/.test(d))return d;try{const u=new TextDecoder(c,{fatal:!0}),f=Ye(d);d=u.decode(f),t=!1}catch{}}return d}function n(c){return t&&/[\x80-\xff]/.test(c)&&(c=s("utf-8",c),t&&(c=s("iso-8859-1",c))),c}function r(c){const d=[];let u;const f=i("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(u=f.exec(c))!==null;){let[,g,b,m]=u;if(g=parseInt(g,10),g in d){if(g===0)break;continue}d[g]=[b,m]}const p=[];for(let g=0;g<d.length&&g in d;++g){let[b,m]=d[g];m=a(m),b&&(m=unescape(m),g===0&&(m=o(m))),p.push(m)}return p.join("")}function a(c){if(c.startsWith('"')){const d=c.slice(1).split('\\"');for(let u=0;u<d.length;++u){const f=d[u].indexOf('"');f!==-1&&(d[u]=d[u].slice(0,f),d.length=u+1),d[u]=d[u].replaceAll(/\\(.)/g,"$1")}c=d.join('"')}return c}function o(c){const d=c.indexOf("'");if(d===-1)return c;const u=c.slice(0,d),p=c.slice(d+1).replace(/^[^']*'/,"");return s(u,p)}function h(c){return!c.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(c)?c:c.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(d,u,f,p){if(f==="q"||f==="Q")return p=p.replaceAll("_"," "),p=p.replaceAll(/=([0-9a-fA-F]{2})/g,function(g,b){return String.fromCharCode(parseInt(b,16))}),s(u,p);try{p=atob(p)}catch{}return s(u,p)})}return""}function un(l,t){const e=new Headers;if(!l||!t||typeof t!="object")return e;for(const i in t){const s=t[i];s!==void 0&&e.append(i,s)}return e}function Ze(l){try{return new URL(l).origin}catch{}return null}function fn({responseHeaders:l,isHttp:t,rangeChunkSize:e,disableRange:i}){const s={allowRangeRequests:!1,suggestedLength:void 0},n=parseInt(l.get("Content-Length"),10);return!Number.isInteger(n)||(s.suggestedLength=n,n<=2*e)||i||!t||l.get("Accept-Ranges")!=="bytes"||(l.get("Content-Encoding")||"identity")!=="identity"||(s.allowRangeRequests=!0),s}function pn(l){const t=l.get("Content-Disposition");if(t){let e=jr(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(Bi(e))return e}return null}function Je(l,t){return l===404||l===0&&t.startsWith("file:")?new _e('Missing PDF "'+t+'".'):new Ve(`Unexpected server response (${l}) while retrieving PDF "${t}".`,l)}function gn(l){return l===200||l===206}function mn(l,t,e){return{method:"GET",headers:l,signal:e.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function bn(l){return l instanceof Uint8Array?l.buffer:l instanceof ArrayBuffer?l:(j(`getArrayBuffer - unexpected data format: ${l}`),new Uint8Array(l).buffer)}class ps{_responseOrigin=null;constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=un(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return Z(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new Hr(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new Vr(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Hr{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;const i=new Headers(t.headers),s=e.url;fetch(s,mn(i,this._withCredentials,this._abortController)).then(n=>{if(t._responseOrigin=Ze(n.url),!gn(n.status))throw Je(n.status,s);this._reader=n.body.getReader(),this._headersCapability.resolve();const r=n.headers,{allowRangeRequests:a,suggestedLength:o}=fn({responseHeaders:r,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=a,this._contentLength=o||this._contentLength,this._filename=pn(r),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Ut("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:bn(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Vr{constructor(t,e,i){this._stream=t,this._reader=null,this._loaded=0;const s=t.source;this._withCredentials=s.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!s.disableStream,this._abortController=new AbortController;const n=new Headers(t.headers);n.append("Range",`bytes=${e}-${i-1}`);const r=s.url;fetch(r,mn(n,this._withCredentials,this._abortController)).then(a=>{const o=Ze(a.url);if(o!==t._responseOrigin)throw new Error(`Expected range response-origin "${o}" to match "${t._responseOrigin}".`);if(!gn(a.status))throw Je(a.status,r);this._readCapability.resolve(),this._reader=a.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded}),{value:bn(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}const hi=200,ci=206;function $r(l){const t=l.response;return typeof t!="string"?t:Ye(t).buffer}class Ur{_responseOrigin=null;constructor({url:t,httpHeaders:e,withCredentials:i}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=un(this.isHttp,e),this.withCredentials=i||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){const e=new XMLHttpRequest,i=this.currXhrId++,s=this.pendingRequests[i]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const[n,r]of this.headers)e.setRequestHeader(n,r);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),s.expectedStatus=ci):s.expectedStatus=hi,e.responseType="arraybuffer",Z(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,i),e.onprogress=this.onProgress.bind(this,i),s.onHeadersReceived=t.onHeadersReceived,s.onDone=t.onDone,s.onError=t.onError,s.onProgress=t.onProgress,e.send(null),i}onProgress(t,e){const i=this.pendingRequests[t];i&&i.onProgress?.(e)}onStateChange(t,e){const i=this.pendingRequests[t];if(!i)return;const s=i.xhr;if(s.readyState>=2&&i.onHeadersReceived&&(i.onHeadersReceived(),delete i.onHeadersReceived),s.readyState!==4||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],s.status===0&&this.isHttp){i.onError(s.status);return}const n=s.status||hi;if(!(n===hi&&i.expectedStatus===ci)&&n!==i.expectedStatus){i.onError(s.status);return}const a=$r(s);if(n===ci){const o=s.getResponseHeader("Content-Range"),h=/bytes (\d+)-(\d+)\/(\d+)/.exec(o);h?i.onDone({begin:parseInt(h[1],10),chunk:a}):(j('Missing or invalid "Content-Range" header.'),i.onError(0))}else a?i.onDone({begin:0,chunk:a}):i.onError(s.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class zr{constructor(t){this._source=t,this._manager=new Ur(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){const e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return Z(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new Wr(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const i=new Gr(this._manager,t,e);return i.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Wr{constructor(t,e){this._manager=t,this._url=e.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const t=this._fullRequestId,e=this._manager.getRequestXhr(t);this._manager._responseOrigin=Ze(e.responseURL);const i=e.getAllResponseHeaders(),s=new Headers(i?i.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(a=>{const[o,...h]=a.split(": ");return[o,h.join(": ")]}):[]),{allowRangeRequests:n,suggestedLength:r}=fn({responseHeaders:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});n&&(this._isRangeSupported=!0),this._contentLength=r||this._contentLength,this._filename=pn(s),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=Je(t,this._url),this._headersCapability.reject(this._storedError);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t);for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class Gr{constructor(t,e,i){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:i,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){const t=Ze(this._manager.getRequestXhr(this._requestId)?.responseURL);t!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){this.onClosed?.(this)}_onDone(t){const e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0;for(const i of this._requests)i.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError??=Je(t,this._url);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){this.isStreamingSupported||this.onProgress?.({loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const Xr=/^[a-z][a-z0-9\-+.]+:/i;function qr(l){if(Xr.test(l))return new URL(l);const t=process.getBuiltinModule("url");return new URL(t.pathToFileURL(l))}class Yr{constructor(t){this.source=t,this.url=qr(t.url),Z(this.url.protocol==="file:","PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return Z(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new Kr(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new Qr(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Kr{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const i=process.getBuiltinModule("fs");i.promises.lstat(this._url).then(s=>{this._contentLength=s.size,this._setReadableStream(i.createReadStream(this._url)),this._headersCapability.resolve()},s=>{s.code==="ENOENT"&&(s=new _e(`Missing PDF "${this._url}".`)),this._storedError=s,this._headersCapability.reject(s)})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new Ut("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class Qr{constructor(t,e,i){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const s=t.source;this._isStreamingSupported=!s.disableStream;const n=process.getBuiltinModule("fs");this._setReadableStream(n.createReadStream(this._url,{start:e,end:i-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),this._storedError&&this._readableStream.destroy(this._storedError)}}const Zr=1e5,ut=30,Jr=.8;let xi=class vt{#t=Promise.withResolvers();#e=null;#i=!1;#s=!!globalThis.FontInspector?.enabled;#r=null;#n=null;#a=0;#l=0;#c=null;#h=null;#u=0;#d=0;#f=Object.create(null);#o=[];#p=null;#m=[];#g=new WeakMap;#b=null;static#y=new Map;static#w=new Map;static#A=new WeakMap;static#v=null;static#S=new Set;constructor({textContentSource:t,container:e,viewport:i}){if(t instanceof ReadableStream)this.#p=t;else if(typeof t=="object")this.#p=new ReadableStream({start(o){o.enqueue(t),o.close()}});else throw new Error('No "textContentSource" parameter specified.');this.#e=this.#h=e,this.#d=i.scale*(globalThis.devicePixelRatio||1),this.#u=i.rotation,this.#n={div:null,properties:null,ctx:null};const{pageWidth:s,pageHeight:n,pageX:r,pageY:a}=i.rawDims;this.#b=[1,0,0,-1,-r,a+n],this.#l=s,this.#a=n,vt.#I(),qt(e,i),this.#t.promise.finally(()=>{vt.#S.delete(this),this.#n=null,this.#f=null}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=ct.platform;return H(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){const t=()=>{this.#c.read().then(({value:e,done:i})=>{if(i){this.#t.resolve();return}this.#r??=e.lang,Object.assign(this.#f,e.styles),this.#x(e.items),t()},this.#t.reject)};return this.#c=this.#p.getReader(),vt.#S.add(this),t(),this.#t.promise}update({viewport:t,onBefore:e=null}){const i=t.scale*(globalThis.devicePixelRatio||1),s=t.rotation;if(s!==this.#u&&(e?.(),this.#u=s,qt(this.#h,{rotation:s})),i!==this.#d){e?.(),this.#d=i;const n={div:null,properties:null,ctx:vt.#T(this.#r)};for(const r of this.#m)n.properties=this.#g.get(r),n.div=r,this.#E(n)}}cancel(){const t=new Ut("TextLayer task cancelled.");this.#c?.cancel(t).catch(()=>{}),this.#c=null,this.#t.reject(t)}get textDivs(){return this.#m}get textContentItemsStr(){return this.#o}#x(t){if(this.#i)return;this.#n.ctx??=vt.#T(this.#r);const e=this.#m,i=this.#o;for(const s of t){if(e.length>Zr){j("Ignoring additional textDivs for performance reasons."),this.#i=!0;return}if(s.str===void 0){if(s.type==="beginMarkedContentProps"||s.type==="beginMarkedContent"){const n=this.#e;this.#e=document.createElement("span"),this.#e.classList.add("markedContent"),s.id!==null&&this.#e.setAttribute("id",`${s.id}`),n.append(this.#e)}else s.type==="endMarkedContent"&&(this.#e=this.#e.parentNode);continue}i.push(s.str),this.#L(s)}}#L(t){const e=document.createElement("span"),i={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};this.#m.push(e);const s=M.transform(this.#b,t.transform);let n=Math.atan2(s[1],s[0]);const r=this.#f[t.fontName];r.vertical&&(n+=Math.PI/2);let a=this.#s&&r.fontSubstitution||r.fontFamily;a=vt.fontFamilyMap.get(a)||a;const o=Math.hypot(s[2],s[3]),h=o*vt.#M(a,this.#r);let c,d;n===0?(c=s[4],d=s[5]-h):(c=s[4]+h*Math.sin(n),d=s[5]-h*Math.cos(n));const u="calc(var(--scale-factor)*",f=e.style;this.#e===this.#h?(f.left=`${(100*c/this.#l).toFixed(2)}%`,f.top=`${(100*d/this.#a).toFixed(2)}%`):(f.left=`${u}${c.toFixed(2)}px)`,f.top=`${u}${d.toFixed(2)}px)`),f.fontSize=`${u}${(vt.#v*o).toFixed(2)}px)`,f.fontFamily=a,i.fontSize=o,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,this.#s&&(e.dataset.fontName=r.fontSubstitutionLoadedName||t.fontName),n!==0&&(i.angle=n*(180/Math.PI));let p=!1;if(t.str.length>1)p=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const g=Math.abs(t.transform[0]),b=Math.abs(t.transform[3]);g!==b&&Math.max(g,b)/Math.min(g,b)>1.5&&(p=!0)}if(p&&(i.canvasWidth=r.vertical?t.height:t.width),this.#g.set(e,i),this.#n.div=e,this.#n.properties=i,this.#E(this.#n),i.hasText&&this.#e.append(e),i.hasEOL){const g=document.createElement("br");g.setAttribute("role","presentation"),this.#e.append(g)}}#E(t){const{div:e,properties:i,ctx:s}=t,{style:n}=e;let r="";if(vt.#v>1&&(r=`scale(${1/vt.#v})`),i.canvasWidth!==0&&i.hasText){const{fontFamily:a}=n,{canvasWidth:o,fontSize:h}=i;vt.#P(s,h*this.#d,a);const{width:c}=s.measureText(e.textContent);c>0&&(r=`scaleX(${o*this.#d/c}) ${r}`)}i.angle!==0&&(r=`rotate(${i.angle}deg) ${r}`),r.length>0&&(n.transform=r)}static cleanup(){if(!(this.#S.size>0)){this.#y.clear();for(const{canvas:t}of this.#w.values())t.remove();this.#w.clear()}}static#T(t=null){let e=this.#w.get(t||="");if(!e){const i=document.createElement("canvas");i.className="hiddenCanvasElement",i.lang=t,document.body.append(i),e=i.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#w.set(t,e),this.#A.set(e,{size:0,family:""})}return e}static#P(t,e,i){const s=this.#A.get(t);e===s.size&&i===s.family||(t.font=`${e}px ${i}`,s.size=e,s.family=i)}static#I(){if(this.#v!==null)return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),this.#v=t.getBoundingClientRect().height,t.remove()}static#M(t,e){const i=this.#y.get(t);if(i)return i;const s=this.#T(e);s.canvas.width=s.canvas.height=ut,this.#P(s,ut,t);const n=s.measureText("");let r=n.fontBoundingBoxAscent,a=Math.abs(n.fontBoundingBoxDescent);if(r){const c=r/(r+a);return this.#y.set(t,c),s.canvas.width=s.canvas.height=0,c}s.strokeStyle="red",s.clearRect(0,0,ut,ut),s.strokeText("g",0,0);let o=s.getImageData(0,0,ut,ut).data;a=0;for(let c=o.length-1-3;c>=0;c-=4)if(o[c]>0){a=Math.ceil(c/4/ut);break}s.clearRect(0,0,ut,ut),s.strokeText("A",0,ut),o=s.getImageData(0,0,ut,ut).data,r=0;for(let c=0,d=o.length;c<d;c+=4)if(o[c]>0){r=ut-Math.floor(c/4/ut);break}s.canvas.width=s.canvas.height=0;const h=r?r/(r+a):Jr;return this.#y.set(t,h),h}};class Ee{static textContent(t){const e=[],i={items:e,styles:Object.create(null)};function s(n){if(!n)return;let r=null;const a=n.name;if(a==="#text")r=n.value;else if(Ee.shouldBuildText(a))n?.attributes?.textContent?r=n.attributes.textContent:n.value&&(r=n.value);else return;if(r!==null&&e.push({str:r}),!!n.children)for(const o of n.children)s(o)}return s(t),i}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}const ta=65536,ea=100,ia=5e3,sa=lt?br:pr,na=lt?yr:on,ra=lt?mr:gr,aa=lt?wr:cn;function oa(l={}){typeof l=="string"||l instanceof URL?l={url:l}:(l instanceof ArrayBuffer||ArrayBuffer.isView(l))&&(l={data:l});const t=new Wi,{docId:e}=t,i=l.url?la(l.url):null,s=l.data?ha(l.data):null,n=l.httpHeaders||null,r=l.withCredentials===!0,a=l.password??null,o=l.range instanceof yn?l.range:null,h=Number.isInteger(l.rangeChunkSize)&&l.rangeChunkSize>0?l.rangeChunkSize:ta;let c=l.worker instanceof He?l.worker:null;const d=l.verbosity,u=typeof l.docBaseUrl=="string"&&!Qe(l.docBaseUrl)?l.docBaseUrl:null,f=typeof l.cMapUrl=="string"?l.cMapUrl:null,p=l.cMapPacked!==!1,g=l.CMapReaderFactory||na,b=typeof l.standardFontDataUrl=="string"?l.standardFontDataUrl:null,m=l.StandardFontDataFactory||aa,w=l.stopAtErrors!==!0,y=Number.isInteger(l.maxImageSize)&&l.maxImageSize>-1?l.maxImageSize:-1,A=l.isEvalSupported!==!1,v=typeof l.isOffscreenCanvasSupported=="boolean"?l.isOffscreenCanvasSupported:!lt,C=typeof l.isImageDecoderSupported=="boolean"?l.isImageDecoderSupported:!lt&&(ct.platform.isFirefox||!globalThis.chrome),x=Number.isInteger(l.canvasMaxAreaInBytes)?l.canvasMaxAreaInBytes:-1,T=typeof l.disableFontFace=="boolean"?l.disableFontFace:lt,_=l.fontExtraProperties===!0,S=l.enableXfa===!0,P=l.ownerDocument||globalThis.document,I=l.disableRange===!0,$=l.disableStream===!0,O=l.disableAutoFetch===!0,tt=l.pdfBug===!0,L=l.CanvasFactory||sa,k=l.FilterFactory||ra,ht=l.enableHWA===!0,Pt=o?o.length:l.length??NaN,kt=typeof l.useSystemFonts=="boolean"?l.useSystemFonts:!lt&&!T,At=typeof l.useWorkerFetch=="boolean"?l.useWorkerFetch:g===on&&m===cn&&f&&b&&ue(f,document.baseURI)&&ue(b,document.baseURI),nt=null;Gn(d);const et={canvasFactory:new L({ownerDocument:P,enableHWA:ht}),filterFactory:new k({docId:e,ownerDocument:P}),cMapReaderFactory:At?null:new g({baseUrl:f,isCompressed:p}),standardFontDataFactory:At?null:new m({baseUrl:b})};if(!c){const dt={verbosity:d,port:me.workerPort};c=dt.port?He.fromPort(dt):new He(dt),t._worker=c}const Qt={docId:e,apiVersion:"4.10.38",data:s,password:a,disableAutoFetch:O,rangeChunkSize:h,length:Pt,docBaseUrl:u,enableXfa:S,evaluatorOptions:{maxImageSize:y,disableFontFace:T,ignoreErrors:w,isEvalSupported:A,isOffscreenCanvasSupported:v,isImageDecoderSupported:C,canvasMaxAreaInBytes:x,fontExtraProperties:_,useSystemFonts:kt,cMapUrl:At?f:null,standardFontDataUrl:At?b:null}},ae={disableFontFace:T,fontExtraProperties:_,ownerDocument:P,pdfBug:tt,styleElement:nt,loadingParams:{disableAutoFetch:O,enableXfa:S}};return c.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const dt=c.messageHandler.sendWithPromise("GetDocRequest",Qt,s?[s.buffer]:null);let W;if(o)W=new Fr(o,{disableRange:I,disableStream:$});else if(!s){if(!i)throw new Error("getDocument - no `url` parameter provided.");let Zt;if(lt)if(ue(i)){if(typeof fetch>"u"||typeof Response>"u"||!("body"in Response.prototype))throw new Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");Zt=ps}else Zt=Yr;else Zt=ue(i)?ps:zr;W=new Zt({url:i,length:Pt,httpHeaders:n,withCredentials:r,rangeChunkSize:h,disableRange:I,disableStream:$})}return dt.then(Zt=>{if(t.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const Zi=new fe(e,Zt,c.port),Vn=new fa(Zi,t,W,ae,et);t._transport=Vn,Zi.send("Ready",null)})}).catch(t._capability.reject),t}function la(l){if(l instanceof URL)return l.href;try{return new URL(l,window.location).href}catch{if(lt&&typeof l=="string")return l}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function ha(l){if(lt&&typeof Buffer<"u"&&l instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(l instanceof Uint8Array&&l.byteLength===l.buffer.byteLength)return l;if(typeof l=="string")return Ye(l);if(l instanceof ArrayBuffer||ArrayBuffer.isView(l)||typeof l=="object"&&!isNaN(l?.length))return new Uint8Array(l);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function gs(l){return typeof l=="object"&&Number.isInteger(l?.num)&&l.num>=0&&Number.isInteger(l?.gen)&&l.gen>=0}class Wi{static#t=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${Wi.#t++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await this._transport?.destroy()}catch(t){throw this._worker?.port&&delete this._worker._pendingDestroy,t}this._transport=null,this._worker?.destroy(),this._worker=null}}let yn=class{constructor(t,e,i=!1,s=null){this.length=t,this.initialData=e,this.progressiveDone=i,this.contentDispositionFilename=s,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(t){this._rangeListeners.push(t)}addProgressListener(t){this._progressListeners.push(t)}addProgressiveReadListener(t){this._progressiveReadListeners.push(t)}addProgressiveDoneListener(t){this._progressiveDoneListeners.push(t)}onDataRange(t,e){for(const i of this._rangeListeners)i(t,e)}onDataProgress(t,e){this._readyCapability.promise.then(()=>{for(const i of this._progressListeners)i(t,e)})}onDataProgressiveRead(t){this._readyCapability.promise.then(()=>{for(const e of this._progressiveReadListeners)e(t)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(const t of this._progressiveDoneListeners)t()})}transportReady(){this._readyCapability.resolve()}requestDataRange(t,e){z("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}};class ca{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return H(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class da{#t=null;#e=!1;constructor(t,e,i,s=!1){this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=s?new es:null,this._pdfBug=s,this.commonObjs=i.commonObjs,this.objs=new wn,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:i=0,offsetY:s=0,dontFlip:n=!1}={}){return new Pe({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return H(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,viewport:e,intent:i="display",annotationMode:s=Vt.ENABLE,transform:n=null,background:r=null,optionalContentConfigPromise:a=null,annotationCanvasMap:o=null,pageColors:h=null,printAnnotationStorage:c=null,isEditing:d=!1}){this._stats?.time("Overall");const u=this._transport.getRenderingIntent(i,s,c,d),{renderingIntent:f,cacheKey:p}=u;this.#e=!1,this.#s(),a||=this._transport.getOptionalContentConfig(f);let g=this._intentStates.get(p);g||(g=Object.create(null),this._intentStates.set(p,g)),g.streamReaderCancelTimeout&&(clearTimeout(g.streamReaderCancelTimeout),g.streamReaderCancelTimeout=null);const b=!!(f&yt.PRINT);g.displayReadyCapability||(g.displayReadyCapability=Promise.withResolvers(),g.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(u));const m=A=>{g.renderTasks.delete(w),(this._maybeCleanupAfterRender||b)&&(this.#e=!0),this.#i(!b),A?(w.capability.reject(A),this._abortOperatorList({intentState:g,reason:A instanceof Error?A:new Error(A)})):w.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},w=new te({callback:m,params:{canvasContext:t,viewport:e,transform:n,background:r},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:o,operatorList:g.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!b,pdfBug:this._pdfBug,pageColors:h});(g.renderTasks||=new Set).add(w);const y=w.task;return Promise.all([g.displayReadyCapability.promise,a]).then(([A,v])=>{if(this.destroyed){m();return}if(this._stats?.time("Rendering"),!(v.renderingIntent&f))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");w.initializeGraphics({transparency:A,optionalContentConfig:v}),w.operatorListChanged()}).catch(m),y}getOperatorList({intent:t="display",annotationMode:e=Vt.ENABLE,printAnnotationStorage:i=null,isEditing:s=!1}={}){function n(){a.operatorList.lastChunk&&(a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(o))}const r=this._transport.getRenderingIntent(t,e,i,s,!0);let a=this._intentStates.get(r.cacheKey);a||(a=Object.create(null),this._intentStates.set(r.cacheKey,a));let o;return a.opListReadCapability||(o=Object.create(null),o.operatorListChanged=n,a.opListReadCapability=Promise.withResolvers(),(a.renderTasks||=new Set).add(o),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(r)),a.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size(s){return s.items.length}})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(i=>Ee.textContent(i));const e=this.streamTextContent(t);return new Promise(function(i,s){function n(){r.read().then(function({value:o,done:h}){if(h){i(a);return}a.lang??=o.lang,Object.assign(a.styles,o.styles),a.items.push(...o.items),n()},s)}const r=e.getReader(),a={items:[],styles:Object.create(null),lang:null};n()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const i of e.renderTasks)t.push(i.completed),i.cancel();return this.objs.clear(),this.#e=!1,this.#s(),Promise.all(t)}cleanup(t=!1){this.#e=!0;const e=this.#i(!1);return t&&e&&(this._stats&&=new es),e}#i(t=!1){if(this.#s(),!this.#e||this.destroyed)return!1;if(t)return this.#t=setTimeout(()=>{this.#t=null,this.#i(!1)},ia),!1;for(const{renderTasks:e,operatorList:i}of this._intentStates.values())if(e.size>0||!i.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#e=!1,!0}#s(){this.#t&&(clearTimeout(this.#t),this.#t=null)}_startRenderPage(t,e){const i=this._intentStates.get(e);i&&(this._stats?.timeEnd("Page Request"),i.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let i=0,s=t.length;i<s;i++)e.operatorList.fnArray.push(t.fnArray[i]),e.operatorList.argsArray.push(t.argsArray[i]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const i of e.renderTasks)i.operatorListChanged();t.lastChunk&&this.#i(!0)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:i,modifiedIds:s}){const{map:n,transfer:r}=i,o=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:n,modifiedIds:s},r).getReader(),h=this._intentStates.get(e);h.streamReader=o;const c=()=>{o.read().then(({value:d,done:u})=>{if(u){h.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(d,h),c())},d=>{if(h.streamReader=null,!this._transport.destroyed){if(h.operatorList){h.operatorList.lastChunk=!0;for(const u of h.renderTasks)u.operatorListChanged();this.#i(!0)}if(h.displayReadyCapability)h.displayReadyCapability.reject(d);else if(h.opListReadCapability)h.opListReadCapability.reject(d);else throw d}})};c()}_abortOperatorList({intentState:t,reason:e,force:i=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!i){if(t.renderTasks.size>0)return;if(e instanceof Oi){let s=ea;e.extraDelay>0&&e.extraDelay<1e3&&(s+=e.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},s);return}}if(t.streamReader.cancel(new Ut(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[s,n]of this._intentStates)if(n===t){this._intentStates.delete(s);break}this.cleanup()}}}get stats(){return this._stats}}class ua{#t=new Map;#e=Promise.resolve();postMessage(t,e){const i={data:structuredClone(t,e?{transfer:e}:null)};this.#e.then(()=>{for(const[s]of this.#t)s.call(this,i)})}addEventListener(t,e,i=null){let s=null;if(i?.signal instanceof AbortSignal){const{signal:n}=i;if(n.aborted){j("LoopbackPort - cannot use an `aborted` signal.");return}const r=()=>this.removeEventListener(t,e);s=()=>n.removeEventListener("abort",r),n.addEventListener("abort",r)}this.#t.set(e,s)}removeEventListener(t,e){this.#t.get(e)?.(),this.#t.delete(e)}terminate(){for(const[,t]of this.#t)t?.();this.#t.clear()}}let He=class ft{static#t=0;static#e=!1;static#i;static{lt&&(this.#e=!0,me.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{let i;try{if(i=new URL(t),!i.origin||i.origin==="null")return!1}catch{return!1}const s=new URL(e,i);return i.origin===s.origin},this._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))}}constructor({name:t=null,port:e=null,verbosity:i=Xn()}={}){if(this.name=t,this.destroyed=!1,this.verbosity=i,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,e){if(ft.#i?.has(e))throw new Error("Cannot use more than one PDFWorker per port.");(ft.#i||=new WeakMap).set(e,this),this._initializeFromPort(e);return}this._initialize()}get promise(){return this._readyCapability.promise}#s(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new fe("main","worker",t),this._messageHandler.on("ready",function(){}),this.#s()}_initialize(){if(ft.#e||ft.#r){this._setupFakeWorker();return}let{workerSrc:t}=ft;try{ft._isSameOrigin(window.location.href,t)||(t=ft._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),i=new fe("main","worker",e),s=()=>{n.abort(),i.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},n=new AbortController;e.addEventListener("error",()=>{this._webWorker||s()},{signal:n.signal}),i.on("test",a=>{if(n.abort(),this.destroyed||!a){s();return}this._messageHandler=i,this._port=e,this._webWorker=e,this.#s()}),i.on("ready",a=>{if(n.abort(),this.destroyed){s();return}try{r()}catch{this._setupFakeWorker()}});const r=()=>{const a=new Uint8Array;i.send("test",a,[a.buffer])};r();return}catch{qe("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){ft.#e||(j("Setting up fake worker."),ft.#e=!0),ft._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const e=new ua;this._port=e;const i=`fake${ft.#t++}`,s=new fe(i+"_worker",i,e);t.setup(s,e),this._messageHandler=new fe(i,i+"_worker",e),this.#s()}).catch(t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){this.destroyed=!0,this._webWorker?.terminate(),this._webWorker=null,ft.#i?.delete(this._port),this._port=null,this._messageHandler?.destroy(),this._messageHandler=null}static fromPort(t){if(!t?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");const e=this.#i?.get(t.port);if(e){if(e._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new ft(t)}static get workerSrc(){if(me.workerSrc)return me.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#r(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return H(this,"_setupFakeWorkerGlobal",(async()=>this.#r?this.#r:(await import(this.workerSrc)).WorkerMessageHandler)())}};class fa{#t=new Map;#e=new Map;#i=new Map;#s=new Map;#r=null;constructor(t,e,i,s,n){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new wn,this.fontLoader=new ur({ownerDocument:s.ownerDocument,styleElement:s.styleElement}),this.loadingParams=s.loadingParams,this._params=s,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.cMapReaderFactory=n.cMapReaderFactory,this.standardFontDataFactory=n.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=i,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#n(t,e=null){const i=this.#t.get(t);if(i)return i;const s=this.messageHandler.sendWithPromise(t,e);return this.#t.set(t,s),s}get annotationStorage(){return H(this,"annotationStorage",new $i)}getRenderingIntent(t,e=Vt.ENABLE,i=null,s=!1,n=!1){let r=yt.DISPLAY,a=Ei;switch(t){case"any":r=yt.ANY;break;case"display":break;case"print":r=yt.PRINT;break;default:j(`getRenderingIntent - invalid intent: ${t}`)}const o=r&yt.PRINT&&i instanceof nn?i:this.annotationStorage;switch(e){case Vt.DISABLE:r+=yt.ANNOTATIONS_DISABLE;break;case Vt.ENABLE:break;case Vt.ENABLE_FORMS:r+=yt.ANNOTATIONS_FORMS;break;case Vt.ENABLE_STORAGE:r+=yt.ANNOTATIONS_STORAGE,a=o.serializable;break;default:j(`getRenderingIntent - invalid annotationMode: ${e}`)}s&&(r+=yt.IS_EDITING),n&&(r+=yt.OPLIST);const{ids:h,hash:c}=o.modifiedIds,d=[r,a.hash,c];return{renderingIntent:r,cacheKey:d.join("_"),annotationStorageSerializable:a,modifiedIds:h}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#r?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const i of this.#e.values())t.push(i._destroy());this.#e.clear(),this.#i.clear(),this.#s.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#t.clear(),this.filterFactory.destroy(),xi.cleanup(),this._networkStream?.cancelAllRequests(new Ut("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(i,s)=>{Z(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=n=>{this._lastProgress={loaded:n.loaded,total:n.total}},s.onPull=()=>{this._fullReader.read().then(function({value:n,done:r}){if(r){s.close();return}Z(n instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),s.enqueue(new Uint8Array(n),1,[n])}).catch(n=>{s.error(n)})},s.onCancel=n=>{this._fullReader.cancel(n),s.ready.catch(r=>{if(!this.destroyed)throw r})}}),t.on("ReaderHeadersReady",async i=>{await this._fullReader.headersReady;const{isStreamingSupported:s,isRangeSupported:n,contentLength:r}=this._fullReader;return(!s||!n)&&(this._lastProgress&&e.onProgress?.(this._lastProgress),this._fullReader.onProgress=a=>{e.onProgress?.({loaded:a.loaded,total:a.total})}),{isStreamingSupported:s,isRangeSupported:n,contentLength:r}}),t.on("GetRangeReader",(i,s)=>{Z(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const n=this._networkStream.getRangeReader(i.begin,i.end);if(!n){s.close();return}s.onPull=()=>{n.read().then(function({value:r,done:a}){if(a){s.close();return}Z(r instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),s.enqueue(new Uint8Array(r),1,[r])}).catch(r=>{s.error(r)})},s.onCancel=r=>{n.cancel(r),s.ready.catch(a=>{if(!this.destroyed)throw a})}}),t.on("GetDoc",({pdfInfo:i})=>{this._numPages=i.numPages,this._htmlForXfa=i.htmlForXfa,delete i.htmlForXfa,e._capability.resolve(new ca(i,this))}),t.on("DocException",i=>{e._capability.reject(gt(i))}),t.on("PasswordRequest",i=>{this.#r=Promise.withResolvers();try{if(!e.onPassword)throw gt(i);const s=n=>{n instanceof Error?this.#r.reject(n):this.#r.resolve({password:n})};e.onPassword(s,i.code)}catch(s){this.#r.reject(s)}return this.#r.promise}),t.on("DataLoaded",i=>{e.onProgress?.({loaded:i.length,total:i.length}),this.downloadInfoCapability.resolve(i)}),t.on("StartRenderPage",i=>{if(this.destroyed)return;this.#e.get(i.pageIndex)._startRenderPage(i.transparency,i.cacheKey)}),t.on("commonobj",([i,s,n])=>{if(this.destroyed||this.commonObjs.has(i))return null;switch(s){case"Font":const{disableFontFace:r,fontExtraProperties:a,pdfBug:o}=this._params;if("error"in n){const u=n.error;j(`Error during font loading: ${u}`),this.commonObjs.resolve(i,u);break}const h=o&&globalThis.FontInspector?.enabled?(u,f)=>globalThis.FontInspector.fontAdded(u,f):null,c=new fr(n,{disableFontFace:r,fontExtraProperties:a,inspectFont:h});this.fontLoader.bind(c).catch(()=>t.sendWithPromise("FontFallback",{id:i})).finally(()=>{!a&&c.data&&(c.data=null),this.commonObjs.resolve(i,c)});break;case"CopyLocalImage":const{imageRef:d}=n;Z(d,"The imageRef must be defined.");for(const u of this.#e.values())for(const[,f]of u.objs)if(f?.ref===d)return f.dataLen?(this.commonObjs.resolve(i,structuredClone(f)),f.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(i,n);break;default:throw new Error(`Got unknown common object type ${s}`)}return null}),t.on("obj",([i,s,n,r])=>{if(this.destroyed)return;const a=this.#e.get(s);if(!a.objs.has(i)){if(a._intentStates.size===0){r?.bitmap?.close();return}switch(n){case"Image":a.objs.resolve(i,r),r?.dataLen>$n&&(a._maybeCleanupAfterRender=!0);break;case"Pattern":a.objs.resolve(i,r);break;default:throw new Error(`Got unknown object type ${n}`)}}}),t.on("DocProgress",i=>{this.destroyed||e.onProgress?.({loaded:i.loaded,total:i.total})}),t.on("FetchBuiltInCMap",async i=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.cMapReaderFactory)throw new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return this.cMapReaderFactory.fetch(i)}),t.on("FetchStandardFontData",async i=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.standardFontDataFactory)throw new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return this.standardFontDataFactory.fetch(i)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&j("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this._fullReader?.filename??null},e).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=t-1,i=this.#i.get(e);if(i)return i;const s=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(n=>{if(this.destroyed)throw new Error("Transport destroyed");n.refStr&&this.#s.set(n.refStr,t);const r=new da(e,n,this,this._params.pdfBug);return this.#e.set(e,r),r});return this.#i.set(e,s),s}getPageIndex(t){return gs(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return this.#n("GetFieldObjects")}hasJSActions(){return this.#n("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return typeof t!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return this.#n("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#n("GetOptionalContentConfig").then(e=>new Dr(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=this.#t.get(t);if(e)return e;const i=this.messageHandler.sendWithPromise(t,null).then(s=>({info:s[0],metadata:s[1]?new kr(s[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return this.#t.set(t,i),i}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of this.#e.values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#t.clear(),this.filterFactory.destroy(!0),xi.cleanup()}}cachedPageNumber(t){if(!gs(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return this.#s.get(e)??null}}const he=Symbol("INITIAL_DATA");class wn{#t=Object.create(null);#e(t){return this.#t[t]||={...Promise.withResolvers(),data:he}}get(t,e=null){if(e){const s=this.#e(t);return s.promise.then(()=>e(s.data)),null}const i=this.#t[t];if(!i||i.data===he)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){const e=this.#t[t];return!!e&&e.data!==he}delete(t){const e=this.#t[t];return!e||e.data===he?!1:(delete this.#t[t],!0)}resolve(t,e=null){const i=this.#e(t);i.data=e,i.resolve()}clear(){for(const t in this.#t){const{data:e}=this.#t[t];e?.bitmap?.close()}this.#t=Object.create(null)}*[Symbol.iterator](){for(const t in this.#t){const{data:e}=this.#t[t];e!==he&&(yield[t,e])}}}class pa{#t=null;constructor(t){this.#t=t,this.onContinue=null}get promise(){return this.#t.capability.promise}cancel(t=0){this.#t.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this.#t.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this.#t;return t.form||t.canvas&&e?.size>0}}class te{#t=null;static#e=new WeakSet;constructor({callback:t,params:e,objs:i,commonObjs:s,annotationCanvasMap:n,operatorList:r,pageIndex:a,canvasFactory:o,filterFactory:h,useRequestAnimationFrame:c=!1,pdfBug:d=!1,pageColors:u=null}){this.callback=t,this.params=e,this.objs=i,this.commonObjs=s,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=a,this.canvasFactory=o,this.filterFactory=h,this._pdfBug=d,this.pageColors=u,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=c===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new pa(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(te.#e.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");te.#e.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:i,viewport:s,transform:n,background:r}=this.params;this.gfx=new ee(i,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:n,viewport:s,transparency:t,background:r}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#t&&(window.cancelAnimationFrame(this.#t),this.#t=null),te.#e.delete(this._canvas),this.callback(t||new Oi(`Rendering cancelled, page ${this._pageIndex+1}`,e))}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}this.stepper?.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#t=window.requestAnimationFrame(()=>{this.#t=null,this._nextBound().catch(this._cancelBound)}):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),te.#e.delete(this._canvas),this.callback())))}}const ga="4.10.38",ma="f9bea397f";function ms(l){return Math.floor(Math.max(0,Math.min(1,l))*255).toString(16).padStart(2,"0")}function ce(l){return Math.max(0,Math.min(255,255*l))}class bs{static CMYK_G([t,e,i,s]){return["G",1-Math.min(1,.3*t+.59*i+.11*e+s)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return t=ce(t),[t,t,t]}static G_HTML([t]){const e=ms(t);return`#${e}${e}${e}`}static RGB_G([t,e,i]){return["G",.3*t+.59*e+.11*i]}static RGB_rgb(t){return t.map(ce)}static RGB_HTML(t){return`#${t.map(ms).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,i,s]){return["RGB",1-Math.min(1,t+s),1-Math.min(1,i+s),1-Math.min(1,e+s)]}static CMYK_rgb([t,e,i,s]){return[ce(1-Math.min(1,t+s)),ce(1-Math.min(1,i+s)),ce(1-Math.min(1,e+s))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,i]){const s=1-t,n=1-e,r=1-i,a=Math.min(s,n,r);return["CMYK",s,n,r,a]}}class ba{create(t,e,i=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const s=this._createSVG("svg:svg");return s.setAttribute("version","1.1"),i||(s.setAttribute("width",`${t}px`),s.setAttribute("height",`${e}px`)),s.setAttribute("preserveAspectRatio","none"),s.setAttribute("viewBox",`0 0 ${t} ${e}`),s}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){z("Abstract method `_createSVG` called.")}}let Gi=class extends ba{_createSVG(t){return document.createElementNS(Nt,t)}},An=class{static setupStorage(t,e,i,s,n){const r=s.getValue(e,{value:null});switch(i.name){case"textarea":if(r.value!==null&&(t.textContent=r.value),n==="print")break;t.addEventListener("input",a=>{s.setValue(e,{value:a.target.value})});break;case"input":if(i.attributes.type==="radio"||i.attributes.type==="checkbox"){if(r.value===i.attributes.xfaOn?t.setAttribute("checked",!0):r.value===i.attributes.xfaOff&&t.removeAttribute("checked"),n==="print")break;t.addEventListener("change",a=>{s.setValue(e,{value:a.target.checked?a.target.getAttribute("xfaOn"):a.target.getAttribute("xfaOff")})})}else{if(r.value!==null&&t.setAttribute("value",r.value),n==="print")break;t.addEventListener("input",a=>{s.setValue(e,{value:a.target.value})})}break;case"select":if(r.value!==null){t.setAttribute("value",r.value);for(const a of i.children)a.attributes.value===r.value?a.attributes.selected=!0:a.attributes.hasOwnProperty("selected")&&delete a.attributes.selected}t.addEventListener("input",a=>{const o=a.target.options,h=o.selectedIndex===-1?"":o[o.selectedIndex].value;s.setValue(e,{value:h})});break}}static setAttributes({html:t,element:e,storage:i=null,intent:s,linkService:n}){const{attributes:r}=e,a=t instanceof HTMLAnchorElement;r.type==="radio"&&(r.name=`${r.name}-${s}`);for(const[o,h]of Object.entries(r))if(h!=null)switch(o){case"class":h.length&&t.setAttribute(o,h.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",h);break;case"style":Object.assign(t.style,h);break;case"textContent":t.textContent=h;break;default:(!a||o!=="href"&&o!=="newWindow")&&t.setAttribute(o,h)}a&&n.addLinkAttributes(t,r.href,r.newWindow),i&&r.dataId&&this.setupStorage(t,r.dataId,e,i)}static render(t){const e=t.annotationStorage,i=t.linkService,s=t.xfaHtml,n=t.intent||"display",r=document.createElement(s.name);s.attributes&&this.setAttributes({html:r,element:s,intent:n,linkService:i});const a=n!=="richText",o=t.div;if(o.append(r),t.viewport){const d=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=d}a&&o.setAttribute("class","xfaLayer xfaFont");const h=[];if(s.children.length===0){if(s.value){const d=document.createTextNode(s.value);r.append(d),a&&Ee.shouldBuildText(s.name)&&h.push(d)}return{textDivs:h}}const c=[[s,-1,r]];for(;c.length>0;){const[d,u,f]=c.at(-1);if(u+1===d.children.length){c.pop();continue}const p=d.children[++c.at(-1)[1]];if(p===null)continue;const{name:g}=p;if(g==="#text"){const m=document.createTextNode(p.value);h.push(m),f.append(m);continue}const b=p?.attributes?.xmlns?document.createElementNS(p.attributes.xmlns,g):document.createElement(g);if(f.append(b),p.attributes&&this.setAttributes({html:b,element:p,storage:e,intent:n,linkService:i}),p.children?.length>0)c.push([p,-1,b]);else if(p.value){const m=document.createTextNode(p.value);a&&Ee.shouldBuildText(g)&&h.push(m),b.append(m)}}for(const d of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))d.setAttribute("readOnly",!0);return{textDivs:h}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}};const Te=1e3,ya=9,Yt=new WeakSet;function $t(l){return{width:l[2]-l[0],height:l[3]-l[1]}}class wa{static create(t){switch(t.data.annotationType){case it.LINK:return new _n(t);case it.TEXT:return new Aa(t);case it.WIDGET:switch(t.data.fieldType){case"Tx":return new _a(t);case"Btn":return t.data.radioButton?new vn(t):t.data.checkBox?new Ea(t):new Sa(t);case"Ch":return new xa(t);case"Sig":return new va(t)}return new Kt(t);case it.POPUP:return new Pi(t);case it.FREETEXT:return new En(t);case it.LINE:return new Ca(t);case it.SQUARE:return new Ta(t);case it.CIRCLE:return new La(t);case it.POLYLINE:return new Sn(t);case it.CARET:return new Ia(t);case it.INK:return new Xi(t);case it.POLYGON:return new Ra(t);case it.HIGHLIGHT:return new xn(t);case it.UNDERLINE:return new Ma(t);case it.SQUIGGLY:return new ka(t);case it.STRIKEOUT:return new Na(t);case it.STAMP:return new Pn(t);case it.FILEATTACHMENT:return new Da(t);default:return new K(t)}}}class K{#t=null;#e=!1;#i=null;constructor(t,{isRenderable:e=!1,ignoreBorder:i=!1,createQuadrilaterals:s=!1}={}){this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(i)),s&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:i}){return!!(t?.str||e?.str||i?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return K._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;this.#t||={rect:this.data.rect.slice(0)};const{rect:e}=t;e&&this.#s(e),this.#i?.popup.updateEdited(t)}resetEdited(){this.#t&&(this.#s(this.#t.rect),this.#i?.popup.resetEdited(),this.#t=null)}#s(t){const{container:{style:e},data:{rect:i,rotation:s},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:r,pageX:a,pageY:o}}}}=this;i?.splice(0,4,...t);const{width:h,height:c}=$t(t);e.left=`${100*(t[0]-a)/n}%`,e.top=`${100*(r-t[3]+o)/r}%`,s===0?(e.width=`${100*h/n}%`,e.height=`${100*c/r}%`):this.setRotation(s)}_createContainer(t){const{data:e,parent:{page:i,viewport:s}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",e.id),this instanceof Kt||(n.tabIndex=Te);const{style:r}=n;if(r.zIndex=this.parent.zIndex++,e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof Pi){const{rotation:g}=e;return!e.hasOwnCanvas&&g!==0&&this.setRotation(g,n),n}const{width:a,height:o}=$t(e.rect);if(!t&&e.borderStyle.width>0){r.borderWidth=`${e.borderStyle.width}px`;const g=e.borderStyle.horizontalCornerRadius,b=e.borderStyle.verticalCornerRadius;if(g>0||b>0){const w=`calc(${g}px * var(--scale-factor)) / calc(${b}px * var(--scale-factor))`;r.borderRadius=w}else if(this instanceof vn){const w=`calc(${a}px * var(--scale-factor)) / calc(${o}px * var(--scale-factor))`;r.borderRadius=w}switch(e.borderStyle.style){case oe.SOLID:r.borderStyle="solid";break;case oe.DASHED:r.borderStyle="dashed";break;case oe.BEVELED:j("Unimplemented border style: beveled");break;case oe.INSET:j("Unimplemented border style: inset");break;case oe.UNDERLINE:r.borderBottomStyle="solid";break}const m=e.borderColor||null;m?(this.#e=!0,r.borderColor=M.makeHexColor(m[0]|0,m[1]|0,m[2]|0)):r.borderWidth=0}const h=M.normalizeRect([e.rect[0],i.view[3]-e.rect[1]+i.view[1],e.rect[2],i.view[3]-e.rect[3]+i.view[1]]),{pageWidth:c,pageHeight:d,pageX:u,pageY:f}=s.rawDims;r.left=`${100*(h[0]-u)/c}%`,r.top=`${100*(h[1]-f)/d}%`;const{rotation:p}=e;return e.hasOwnCanvas||p===0?(r.width=`${100*a/c}%`,r.height=`${100*o/d}%`):this.setRotation(p,n),n}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:i,pageHeight:s}=this.parent.viewport.rawDims,{width:n,height:r}=$t(this.data.rect);let a,o;t%180===0?(a=100*n/i,o=100*r/s):(a=100*r/i,o=100*n/s),e.style.width=`${a}%`,e.style.height=`${o}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,i,s)=>{const n=s.detail[e],r=n[0],a=n.slice(1);s.target.style[i]=bs[`${r}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[i]:bs[`${r}_rgb`](a)})};return H(this,"_commonActions",{display:e=>{const{display:i}=e.detail,s=i%2===1;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:s,noPrint:i===1||i===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:i}=e.detail;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:i,noView:i})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:e=>{const i=e.detail.rotation;this.setRotation(i),this.annotationStorage.setValue(this.data.id,{rotation:i})}})}_dispatchEventFromSandbox(t,e){const i=this._commonActions;for(const s of Object.keys(e.detail))(t[s]||i[s])?.(e)}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const i=this._commonActions;for(const[s,n]of Object.entries(e)){const r=i[s];if(r){const a={detail:{[s]:n},target:t};r(a),delete e[s]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,i,s,n]=this.data.rect.map(g=>Math.fround(g));if(t.length===8){const[g,b,m,w]=t.subarray(2,6);if(s===g&&n===b&&e===m&&i===w)return}const{style:r}=this.container;let a;if(this.#e){const{borderColor:g,borderWidth:b}=r;r.borderWidth=0,a=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${g}" stroke-width="${b}">`],this.container.classList.add("hasBorder")}const o=s-e,h=n-i,{svgFactory:c}=this,d=c.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0);const u=c.createElement("defs");d.append(u);const f=c.createElement("clipPath"),p=`clippath_${this.data.id}`;f.setAttribute("id",p),f.setAttribute("clipPathUnits","objectBoundingBox"),u.append(f);for(let g=2,b=t.length;g<b;g+=8){const m=t[g],w=t[g+1],y=t[g+2],A=t[g+3],v=c.createElement("rect"),C=(y-e)/o,x=(n-w)/h,T=(m-y)/o,_=(w-A)/h;v.setAttribute("x",C),v.setAttribute("y",x),v.setAttribute("width",T),v.setAttribute("height",_),f.append(v),a?.push(`<rect vector-effect="non-scaling-stroke" x="${C}" y="${x}" width="${T}" height="${_}"/>`)}this.#e&&(a.push("</g></svg>')"),r.backgroundImage=a.join("")),this.container.append(d),this.container.style.clipPath=`url(#${p})`}_createPopup(){const{data:t}=this,e=this.#i=new Pi({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]});this.parent.div.append(e.render())}render(){z("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const i=[];if(this._fieldObjects){const s=this._fieldObjects[t];if(s)for(const{page:n,id:r,exportValues:a}of s){if(n===-1||r===e)continue;const o=typeof a=="string"?a:null,h=document.querySelector(`[data-element-id="${r}"]`);if(h&&!Yt.has(h)){j(`_getElementsByName - element not allowed: ${r}`);continue}i.push({id:r,exportValue:o,domElement:h})}return i}for(const s of document.getElementsByName(t)){const{exportValue:n}=s,r=s.getAttribute("data-element-id");r!==e&&Yt.has(s)&&i.push({id:r,exportValue:n,domElement:s})}return i}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e})})}}class _n extends K{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){const{data:t,linkService:e}=this,i=document.createElement("a");i.setAttribute("data-element-id",t.id);let s=!1;return t.url?(e.addLinkAttributes(i,t.url,t.newWindow),s=!0):t.action?(this._bindNamedAction(i,t.action),s=!0):t.attachment?(this.#e(i,t.attachment,t.attachmentDest),s=!0):t.setOCGState?(this.#i(i,t.setOCGState),s=!0):t.dest?(this._bindLink(i,t.dest),s=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,t),s=!0),t.resetForm?(this._bindResetFormAction(i,t.resetForm),s=!0):this.isTooltipOnly&&!s&&(this._bindLink(i,""),s=!0)),this.container.classList.add("linkAnnotation"),s&&this.container.append(i),this.container}#t(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||e==="")&&this.#t()}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),this.#t()}#e(t,e,i=null){t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,i),!1),this.#t()}#i(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),this.#t()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const s of Object.keys(e.actions)){const n=i.get(s);n&&(t[n]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:s}}),!1))}t.onclick||(t.onclick=()=>!1),this.#t()}_bindResetFormAction(t,e){const i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),this.#t(),!this._fieldObjects){j('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(t.onclick=()=>!1);return}t.onclick=()=>{i?.();const{fields:s,refs:n,include:r}=e,a=[];if(s.length!==0||n.length!==0){const c=new Set(n);for(const d of s){const u=this._fieldObjects[d]||[];for(const{id:f}of u)c.add(f)}for(const d of Object.values(this._fieldObjects))for(const u of d)c.has(u.id)===r&&a.push(u)}else for(const c of Object.values(this._fieldObjects))a.push(...c);const o=this.annotationStorage,h=[];for(const c of a){const{id:d}=c;switch(h.push(d),c.type){case"text":{const f=c.defaultValue||"";o.setValue(d,{value:f});break}case"checkbox":case"radiobutton":{const f=c.defaultValue===c.exportValues;o.setValue(d,{value:f});break}case"combobox":case"listbox":{const f=c.defaultValue||"";o.setValue(d,{value:f});break}default:continue}const u=document.querySelector(`[data-element-id="${d}"]`);if(u){if(!Yt.has(u)){j(`_bindResetFormAction - element not allowed: ${d}`);continue}}else continue;u.dispatchEvent(new Event("resetform"))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:h,name:"ResetForm"}}),!1}}}class Aa extends K{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(t),this.container}}class Kt extends K{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&(t.previousSibling?.nodeName==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return ct.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,i,s,n){i.includes("mouse")?t.addEventListener(i,r=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(r),shift:r.shiftKey,modifier:this._getKeyModifier(r)}})}):t.addEventListener(i,r=>{if(i==="blur"){if(!e.focused||!r.relatedTarget)return;e.focused=!1}else if(i==="focus"){if(e.focused)return;e.focused=!0}n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(r)}})})}_setEventListeners(t,e,i,s){for(const[n,r]of i)(r==="Action"||this.data.actions?.[r])&&((r==="Focus"||r==="Blur")&&(e||={focused:!1}),this._setEventListener(t,e,n,r,s),r==="Focus"&&!this.data.actions?.Blur?this._setEventListener(t,e,"blur","Blur",null):r==="Blur"&&!this.data.actions?.Focus&&this._setEventListener(t,e,"focus","Focus",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":M.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:i}=this.data.defaultAppearanceData,s=this.data.defaultAppearanceData.fontSize||ya,n=t.style;let r;const a=2,o=h=>Math.round(10*h)/10;if(this.data.multiLine){const h=Math.abs(this.data.rect[3]-this.data.rect[1]-a),c=Math.round(h/(ni*s))||1,d=h/c;r=Math.min(s,o(d/ni))}else{const h=Math.abs(this.data.rect[3]-this.data.rect[1]-a);r=Math.min(s,o(h/ni))}n.fontSize=`calc(${r}px * var(--scale-factor))`,n.color=M.makeHexColor(i[0],i[1],i[2]),this.data.textAlignment!==null&&(n.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class _a extends Kt{constructor(t){const e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,i,s){const n=this.annotationStorage;for(const r of this._getElementsByName(t.name,t.id))r.domElement&&(r.domElement[e]=i),n.setValue(r.id,{[s]:i})}render(){const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){const s=t.getValue(e,{value:this.data.fieldValue});let n=s.value||"";const r=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;r&&n.length>r&&(n=n.slice(0,r));let a=s.formattedValue||this.data.textContent?.join(`
|
|
3
|
+
`)||null;a&&this.data.comb&&(a=a.replaceAll(/\s+/g,""));const o={userValue:n,formattedValue:a,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(i=document.createElement("textarea"),i.textContent=a??n,this.data.doNotScroll&&(i.style.overflowY="hidden")):(i=document.createElement("input"),i.type="text",i.setAttribute("value",a??n),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(i.hidden=!0),Yt.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=Te,this._setRequired(i,this.data.required),r&&(i.maxLength=r),i.addEventListener("input",c=>{t.setValue(e,{value:c.target.value}),this.setPropertyOnSiblings(i,"value",c.target.value,"value"),o.formattedValue=null}),i.addEventListener("resetform",c=>{const d=this.data.defaultFieldValue??"";i.value=o.userValue=d,o.formattedValue=null});let h=c=>{const{formattedValue:d}=o;d!=null&&(c.target.value=d),c.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){i.addEventListener("focus",d=>{if(o.focused)return;const{target:u}=d;o.userValue&&(u.value=o.userValue),o.lastCommittedValue=u.value,o.commitKey=1,this.data.actions?.Focus||(o.focused=!0)}),i.addEventListener("updatefromsandbox",d=>{this.showElementAndHideCanvas(d.target);const u={value(f){o.userValue=f.detail.value??"",t.setValue(e,{value:o.userValue.toString()}),f.target.value=o.userValue},formattedValue(f){const{formattedValue:p}=f.detail;o.formattedValue=p,p!=null&&f.target!==document.activeElement&&(f.target.value=p),t.setValue(e,{formattedValue:p})},selRange(f){f.target.setSelectionRange(...f.detail.selRange)},charLimit:f=>{const{charLimit:p}=f.detail,{target:g}=f;if(p===0){g.removeAttribute("maxLength");return}g.setAttribute("maxLength",p);let b=o.userValue;!b||b.length<=p||(b=b.slice(0,p),g.value=o.userValue=b,t.setValue(e,{value:b}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:b,willCommit:!0,commitKey:1,selStart:g.selectionStart,selEnd:g.selectionEnd}}))}};this._dispatchEventFromSandbox(u,d)}),i.addEventListener("keydown",d=>{o.commitKey=1;let u=-1;if(d.key==="Escape"?u=0:d.key==="Enter"&&!this.data.multiLine?u=2:d.key==="Tab"&&(o.commitKey=3),u===-1)return;const{value:f}=d.target;o.lastCommittedValue!==f&&(o.lastCommittedValue=f,o.userValue=f,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:f,willCommit:!0,commitKey:u,selStart:d.target.selectionStart,selEnd:d.target.selectionEnd}}))});const c=h;h=null,i.addEventListener("blur",d=>{if(!o.focused||!d.relatedTarget)return;this.data.actions?.Blur||(o.focused=!1);const{value:u}=d.target;o.userValue=u,o.lastCommittedValue!==u&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:u,willCommit:!0,commitKey:o.commitKey,selStart:d.target.selectionStart,selEnd:d.target.selectionEnd}}),c(d)}),this.data.actions?.Keystroke&&i.addEventListener("beforeinput",d=>{o.lastCommittedValue=null;const{data:u,target:f}=d,{value:p,selectionStart:g,selectionEnd:b}=f;let m=g,w=b;switch(d.inputType){case"deleteWordBackward":{const y=p.substring(0,g).match(/\w*[^\w]*$/);y&&(m-=y[0].length);break}case"deleteWordForward":{const y=p.substring(g).match(/^[^\w]*\w*/);y&&(w+=y[0].length);break}case"deleteContentBackward":g===b&&(m-=1);break;case"deleteContentForward":g===b&&(w+=1);break}d.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:p,change:u||"",willCommit:!1,selStart:m,selEnd:w}})}),this._setEventListeners(i,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],d=>d.target.value)}if(h&&i.addEventListener("blur",h),this.data.comb){const d=(this.data.rect[2]-this.data.rect[0])/r;i.classList.add("comb"),i.style.letterSpacing=`calc(${d}px * var(--scale-factor) - 1ch)`}}else i=document.createElement("div"),i.textContent=this.data.fieldValue,i.style.verticalAlign="middle",i.style.display="table-cell",this.data.hasOwnCanvas&&(i.hidden=!0);return this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class va extends Kt{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class Ea extends Kt{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,i=e.id;let s=t.getValue(i,{value:e.exportValue===e.fieldValue}).value;typeof s=="string"&&(s=s!=="Off",t.setValue(i,{value:s})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const n=document.createElement("input");return Yt.add(n),n.setAttribute("data-element-id",i),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="checkbox",n.name=e.fieldName,s&&n.setAttribute("checked",!0),n.setAttribute("exportValue",e.exportValue),n.tabIndex=Te,n.addEventListener("change",r=>{const{name:a,checked:o}=r.target;for(const h of this._getElementsByName(a,i)){const c=o&&h.exportValue===e.exportValue;h.domElement&&(h.domElement.checked=c),t.setValue(h.id,{value:c})}t.setValue(i,{value:o})}),n.addEventListener("resetform",r=>{const a=e.defaultFieldValue||"Off";r.target.checked=a===e.exportValue}),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",r=>{const a={value(o){o.target.checked=o.detail.value!=="Off",t.setValue(i,{value:o.target.checked})}};this._dispatchEventFromSandbox(a,r)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],r=>r.target.checked)),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class vn extends Kt{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,i=e.id;let s=t.getValue(i,{value:e.fieldValue===e.buttonValue}).value;if(typeof s=="string"&&(s=s!==e.buttonValue,t.setValue(i,{value:s})),s)for(const r of this._getElementsByName(e.fieldName,i))t.setValue(r.id,{value:!1});const n=document.createElement("input");if(Yt.add(n),n.setAttribute("data-element-id",i),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="radio",n.name=e.fieldName,s&&n.setAttribute("checked",!0),n.tabIndex=Te,n.addEventListener("change",r=>{const{name:a,checked:o}=r.target;for(const h of this._getElementsByName(a,i))t.setValue(h.id,{value:!1});t.setValue(i,{value:o})}),n.addEventListener("resetform",r=>{const a=e.defaultFieldValue;r.target.checked=a!=null&&a===e.buttonValue}),this.enableScripting&&this.hasJSActions){const r=e.buttonValue;n.addEventListener("updatefromsandbox",a=>{const o={value:h=>{const c=r===h.detail.value;for(const d of this._getElementsByName(h.target.name)){const u=c&&d.id===i;d.domElement&&(d.domElement.checked=u),t.setValue(d.id,{value:u})}}};this._dispatchEventFromSandbox(o,a)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],a=>a.target.checked)}return this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Sa extends _n{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",i=>{this._dispatchEventFromSandbox({},i)})),t}}class xa extends Kt{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,i=t.getValue(e,{value:this.data.fieldValue}),s=document.createElement("select");Yt.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,this._setRequired(s,this.data.required),s.name=this.data.fieldName,s.tabIndex=Te;let n=this.data.combo&&this.data.options.length>0;this.data.combo||(s.size=this.data.options.length,this.data.multiSelect&&(s.multiple=!0)),s.addEventListener("resetform",c=>{const d=this.data.defaultFieldValue;for(const u of s.options)u.selected=u.value===d});for(const c of this.data.options){const d=document.createElement("option");d.textContent=c.displayValue,d.value=c.exportValue,i.value.includes(c.exportValue)&&(d.setAttribute("selected",!0),n=!1),s.append(d)}let r=null;if(n){const c=document.createElement("option");c.value=" ",c.setAttribute("hidden",!0),c.setAttribute("selected",!0),s.prepend(c),r=()=>{c.remove(),s.removeEventListener("input",r),r=null},s.addEventListener("input",r)}const a=c=>{const d=c?"value":"textContent",{options:u,multiple:f}=s;return f?Array.prototype.filter.call(u,p=>p.selected).map(p=>p[d]):u.selectedIndex===-1?null:u[u.selectedIndex][d]};let o=a(!1);const h=c=>{const d=c.target.options;return Array.prototype.map.call(d,u=>({displayValue:u.textContent,exportValue:u.value}))};return this.enableScripting&&this.hasJSActions?(s.addEventListener("updatefromsandbox",c=>{const d={value(u){r?.();const f=u.detail.value,p=new Set(Array.isArray(f)?f:[f]);for(const g of s.options)g.selected=p.has(g.value);t.setValue(e,{value:a(!0)}),o=a(!1)},multipleSelection(u){s.multiple=!0},remove(u){const f=s.options,p=u.detail.remove;f[p].selected=!1,s.remove(p),f.length>0&&Array.prototype.findIndex.call(f,b=>b.selected)===-1&&(f[0].selected=!0),t.setValue(e,{value:a(!0),items:h(u)}),o=a(!1)},clear(u){for(;s.length!==0;)s.remove(0);t.setValue(e,{value:null,items:[]}),o=a(!1)},insert(u){const{index:f,displayValue:p,exportValue:g}=u.detail.insert,b=s.children[f],m=document.createElement("option");m.textContent=p,m.value=g,b?b.before(m):s.append(m),t.setValue(e,{value:a(!0),items:h(u)}),o=a(!1)},items(u){const{items:f}=u.detail;for(;s.length!==0;)s.remove(0);for(const p of f){const{displayValue:g,exportValue:b}=p,m=document.createElement("option");m.textContent=g,m.value=b,s.append(m)}s.options.length>0&&(s.options[0].selected=!0),t.setValue(e,{value:a(!0),items:h(u)}),o=a(!1)},indices(u){const f=new Set(u.detail.indices);for(const p of u.target.options)p.selected=f.has(p.index);t.setValue(e,{value:a(!0)}),o=a(!1)},editable(u){u.target.disabled=!u.detail.editable}};this._dispatchEventFromSandbox(d,c)}),s.addEventListener("input",c=>{const d=a(!0),u=a(!1);t.setValue(e,{value:d}),c.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:o,change:u,changeEx:d,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(s,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],c=>c.target.value)):s.addEventListener("input",function(c){t.setValue(e,{value:a(!0)})}),this.data.combo&&this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class Pi extends K{constructor(t){const{data:e,elements:i}=t;super(t,{isRenderable:K._hasPopupData(e)}),this.elements=i,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new Pa({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),e=[];for(const i of this.elements)i.popup=t,i.container.ariaHasPopup="dialog",e.push(i.data.id),i.addHighlightArea();return this.container.setAttribute("aria-controls",e.map(i=>`${Fi}${i}`).join(",")),this.container}}class Pa{#t=this.#x.bind(this);#e=this.#P.bind(this);#i=this.#T.bind(this);#s=this.#E.bind(this);#r=null;#n=null;#a=null;#l=null;#c=null;#h=null;#u=null;#d=!1;#f=null;#o=null;#p=null;#m=null;#g=null;#b=null;#y=!1;constructor({container:t,color:e,elements:i,titleObj:s,modificationDate:n,contentsObj:r,richText:a,parent:o,rect:h,parentRect:c,open:d}){this.#n=t,this.#g=s,this.#a=r,this.#m=a,this.#h=o,this.#r=e,this.#p=h,this.#u=c,this.#c=i,this.#l=Js.toDateObject(n),this.trigger=i.flatMap(u=>u.getElementsToTriggerPopup());for(const u of this.trigger)u.addEventListener("click",this.#s),u.addEventListener("mouseenter",this.#i),u.addEventListener("mouseleave",this.#e),u.classList.add("popupTriggerArea");for(const u of i)u.container?.addEventListener("keydown",this.#t);this.#n.hidden=!0,d&&this.#E()}render(){if(this.#f)return;const t=this.#f=document.createElement("div");if(t.className="popup",this.#r){const n=t.style.outlineColor=M.makeHexColor(...this.#r);CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?t.style.backgroundColor=`color-mix(in srgb, ${n} 30%, white)`:t.style.backgroundColor=M.makeHexColor(...this.#r.map(a=>Math.floor(.7*(255-a)+a)))}const e=document.createElement("span");e.className="header";const i=document.createElement("h1");if(e.append(i),{dir:i.dir,str:i.textContent}=this.#g,t.append(e),this.#l){const n=document.createElement("span");n.classList.add("popupDate"),n.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),n.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#l.valueOf()})),e.append(n)}const s=this.#w;if(s)An.render({xfaHtml:s,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const n=this._formatContents(this.#a);t.append(n)}this.#n.append(t)}get#w(){const t=this.#m,e=this.#a;return t?.str&&(!e?.str||e.str===t.str)&&this.#m.html||null}get#A(){return this.#w?.attributes?.style?.fontSize||0}get#v(){return this.#w?.attributes?.style?.color||null}#S(t){const e=[],i={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},s={style:{color:this.#v,fontSize:this.#A?`calc(${this.#A}px * var(--scale-factor))`:""}};for(const n of t.split(`
|
|
4
|
+
`))e.push({name:"span",value:n,attributes:s});return i}_formatContents({str:t,dir:e}){const i=document.createElement("p");i.classList.add("popupContent"),i.dir=e;const s=t.split(/(?:\r\n?|\n)/);for(let n=0,r=s.length;n<r;++n){const a=s[n];i.append(document.createTextNode(a)),n<r-1&&i.append(document.createElement("br"))}return i}#x(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&this.#d)&&this.#E()}updateEdited({rect:t,popupContent:e}){this.#b||={contentsObj:this.#a,richText:this.#m},t&&(this.#o=null),e&&(this.#m=this.#S(e),this.#a=null),this.#f?.remove(),this.#f=null}resetEdited(){this.#b&&({contentsObj:this.#a,richText:this.#m}=this.#b,this.#b=null,this.#f?.remove(),this.#f=null,this.#o=null)}#L(){if(this.#o!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:s,pageY:n}}}=this.#h;let r=!!this.#u,a=r?this.#u:this.#p;for(const p of this.#c)if(!a||M.intersect(p.data.rect,a)!==null){a=p.data.rect,r=!0;break}const o=M.normalizeRect([a[0],t[3]-a[1]+t[1],a[2],t[3]-a[3]+t[1]]),c=r?a[2]-a[0]+5:0,d=o[0]+c,u=o[1];this.#o=[100*(d-s)/e,100*(u-n)/i];const{style:f}=this.#n;f.left=`${this.#o[0]}%`,f.top=`${this.#o[1]}%`}#E(){this.#d=!this.#d,this.#d?(this.#T(),this.#n.addEventListener("click",this.#s),this.#n.addEventListener("keydown",this.#t)):(this.#P(),this.#n.removeEventListener("click",this.#s),this.#n.removeEventListener("keydown",this.#t))}#T(){this.#f||this.render(),this.isVisible?this.#d&&this.#n.classList.add("focused"):(this.#L(),this.#n.hidden=!1,this.#n.style.zIndex=parseInt(this.#n.style.zIndex)+1e3)}#P(){this.#n.classList.remove("focused"),!(this.#d||!this.isVisible)&&(this.#n.hidden=!0,this.#n.style.zIndex=parseInt(this.#n.style.zIndex)-1e3)}forceHide(){this.#y=this.isVisible,this.#y&&(this.#n.hidden=!0)}maybeShow(){this.#y&&(this.#f||this.#T(),this.#y=!1,this.#n.hidden=!1)}get isVisible(){return this.#n.hidden===!1}}class En extends K{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=B.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const e of this.textContent){const i=document.createElement("span");i.textContent=e,t.append(i)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class Ca extends K{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const t=this.data,{width:e,height:i}=$t(t.rect),s=this.svgFactory.create(e,i,!0),n=this.#t=this.svgFactory.createElement("svg:line");return n.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),n.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),n.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),n.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),n.setAttribute("stroke-width",t.borderStyle.width||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),s.append(n),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Ta extends K{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const t=this.data,{width:e,height:i}=$t(t.rect),s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,r=this.#t=this.svgFactory.createElement("svg:rect");return r.setAttribute("x",n/2),r.setAttribute("y",n/2),r.setAttribute("width",e-n),r.setAttribute("height",i-n),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class La extends K{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const t=this.data,{width:e,height:i}=$t(t.rect),s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,r=this.#t=this.svgFactory.createElement("svg:ellipse");return r.setAttribute("cx",e/2),r.setAttribute("cy",i/2),r.setAttribute("rx",e/2-n/2),r.setAttribute("ry",i/2-n/2),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Sn extends K{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,vertices:e,borderStyle:i,popupRef:s}}=this;if(!e)return this.container;const{width:n,height:r}=$t(t),a=this.svgFactory.create(n,r,!0);let o=[];for(let c=0,d=e.length;c<d;c+=2){const u=e[c]-t[0],f=t[3]-e[c+1];o.push(`${u},${f}`)}o=o.join(" ");const h=this.#t=this.svgFactory.createElement(this.svgElementName);return h.setAttribute("points",o),h.setAttribute("stroke-width",i.width||1),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),a.append(h),this.container.append(a),!s&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Ra extends Sn{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class Ia extends K{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class Xi extends K{#t=null;#e=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?B.HIGHLIGHT:B.INK}#i(t,e){switch(t){case 90:return{transform:`rotate(90) translate(${-e[0]},${e[1]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:`rotate(180) translate(${-e[2]},${e[1]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:`rotate(270) translate(${-e[2]},${e[3]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:`translate(${-e[0]},${e[3]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]}}}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,rotation:e,inkLists:i,borderStyle:s,popupRef:n}}=this,{transform:r,width:a,height:o}=this.#i(e,t),h=this.svgFactory.create(a,o,!0),c=this.#t=this.svgFactory.createElement("svg:g");h.append(c),c.setAttribute("stroke-width",s.width||1),c.setAttribute("stroke-linecap","round"),c.setAttribute("stroke-linejoin","round"),c.setAttribute("stroke-miterlimit",10),c.setAttribute("stroke","transparent"),c.setAttribute("fill","transparent"),c.setAttribute("transform",r);for(let d=0,u=i.length;d<u;d++){const f=this.svgFactory.createElement(this.svgElementName);this.#e.push(f),f.setAttribute("points",i[d].join(",")),c.append(f)}return!n&&this.hasPopupData&&this._createPopup(),this.container.append(h),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);const{thickness:e,points:i,rect:s}=t,n=this.#t;if(e>=0&&n.setAttribute("stroke-width",e||1),i)for(let r=0,a=this.#e.length;r<a;r++)this.#e[r].setAttribute("points",i[r].join(","));if(s){const{transform:r,width:a,height:o}=this.#i(this.data.rotation,s);n.parentElement.setAttribute("viewBox",`0 0 ${a} ${o}`),n.setAttribute("transform",r)}}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add("highlightArea")}}class xn extends K{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=B.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}class Ma extends K{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class ka extends K{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class Na extends K{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class Pn extends K{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=B.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class Da extends K{#t=null;constructor(t){super(t,{isRenderable:!0});const{file:e}=this.data;this.filename=e.filename,this.content=e.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...e})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:t,data:e}=this;let i;e.hasAppearance||e.fillAlpha===0?i=document.createElement("div"):(i=document.createElement("img"),i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(e.fillAlpha*100)}%);`)),i.addEventListener("dblclick",this.#e.bind(this)),this.#t=i;const{isMac:s}=ct.platform;return t.addEventListener("keydown",n=>{n.key==="Enter"&&(s?n.metaKey:n.ctrlKey)&&this.#e()}),!e.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),t.append(i),t}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}#e(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}let Fa=class{#t=null;#e=null;#i=new Map;#s=null;constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:s,page:n,viewport:r,structTreeLayer:a}){this.div=t,this.#t=e,this.#e=i,this.#s=a||null,this.page=n,this.viewport=r,this.zIndex=0,this._annotationEditorUIManager=s}hasEditableAnnotations(){return this.#i.size>0}async#r(t,e){const i=t.firstChild||t,s=i.id=`${Fi}${e}`,n=await this.#s?.getAriaAttributes(s);if(n)for(const[r,a]of n)i.setAttribute(r,a);this.div.append(t),this.#t?.moveElementInDOM(this.div,t,i,!1)}async render(t){const{annotations:e}=t,i=this.div;qt(i,this.viewport);const s=new Map,n={data:null,layer:i,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new Gi,annotationStorage:t.annotationStorage||new $i,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const r of e){if(r.noHTML)continue;const a=r.annotationType===it.POPUP;if(a){const c=s.get(r.id);if(!c)continue;n.elements=c}else{const{width:c,height:d}=$t(r.rect);if(c<=0||d<=0)continue}n.data=r;const o=wa.create(n);if(!o.isRenderable)continue;if(!a&&r.popupRef){const c=s.get(r.popupRef);c?c.push(o):s.set(r.popupRef,[o])}const h=o.render();r.hidden&&(h.style.visibility="hidden"),await this.#r(h,r.id),o._isEditable&&(this.#i.set(o.data.id,o),this._annotationEditorUIManager?.renderAnnotationElement(o))}this.#n()}update({viewport:t}){const e=this.div;this.viewport=t,qt(e,{rotation:t.rotation}),this.#n(),e.hidden=!1}#n(){if(!this.#e)return;const t=this.div;for(const[e,i]of this.#e){const s=t.querySelector(`[data-annotation-id="${e}"]`);if(!s)continue;i.className="annotationContent";const{firstChild:n}=s;n?n.nodeName==="CANVAS"?n.replaceWith(i):n.classList.contains("annotationContent")?n.after(i):n.before(i):s.append(i)}this.#e.clear()}getEditableAnnotations(){return Array.from(this.#i.values())}getEditableAnnotation(t){return this.#i.get(t)}};const Me=/\r\n?|\n/g;class st extends D{#t;#e="";#i=`${this.id}-editor`;#s=null;#r;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=st.prototype,e=n=>n.isEmpty(),i=ve.TRANSLATE_SMALL,s=ve.TRANSLATE_BIG;return H(this,"_keyboardManager",new Ce([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],t.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-s,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}]]))}static _type="freetext";static _editorType=B.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.#t=t.color||st._defaultColor||D._defaultLineColor,this.#r=t.fontSize||st._defaultFontSize}static initialize(t,e){D.initialize(t,e);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case V.FREETEXT_SIZE:st._defaultFontSize=e;break;case V.FREETEXT_COLOR:st._defaultColor=e;break}}updateParams(t,e){switch(t){case V.FREETEXT_SIZE:this.#n(e);break;case V.FREETEXT_COLOR:this.#a(e);break}}static get defaultPropertiesToUpdate(){return[[V.FREETEXT_SIZE,st._defaultFontSize],[V.FREETEXT_COLOR,st._defaultColor||D._defaultLineColor]]}get propertiesToUpdate(){return[[V.FREETEXT_SIZE,this.#r],[V.FREETEXT_COLOR,this.#t]]}#n(t){const e=s=>{this.editorDiv.style.fontSize=`calc(${s}px * var(--scale-factor))`,this.translate(0,-(s-this.#r)*this.parentScale),this.#r=s,this.#c()},i=this.#r;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:V.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#a(t){const e=s=>{this.#t=this.editorDiv.style.color=s},i=this.#t;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:V.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-st._internalPadding*t,-(st._internalPadding+this.#r)*t]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(B.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#s=new AbortController;const t=this._uiManager.combinedSignal(this.#s);this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t})}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#i),this._isDraggable=!0,this.#s?.abort(),this.#s=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){this.width||(this.enableEditMode(),t&&this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}#l(){const t=[];this.editorDiv.normalize();let e=null;for(const i of this.editorDiv.childNodes)e?.nodeType===Node.TEXT_NODE&&i.nodeName==="BR"||(t.push(st.#h(i)),e=i);return t.join(`
|
|
5
|
+
`)}#c(){const[t,e]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:s,div:n}=this,r=n.style.display,a=n.classList.contains("hidden");n.classList.remove("hidden"),n.style.display="hidden",s.div.append(this.div),i=n.getBoundingClientRect(),n.remove(),n.style.display=r,n.classList.toggle("hidden",a)}this.rotation%180===this.parentRotation%180?(this.width=i.width/t,this.height=i.height/e):(this.width=i.height/t,this.height=i.width/e),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=this.#e,e=this.#e=this.#l().trimEnd();if(t===e)return;const i=s=>{if(this.#e=s,!s){this.remove();return}this.#u(),this._uiManager.rebuild(this),this.#c()};this.addCommands({cmd:()=>{i(e)},undo:()=>{i(t)},mustExec:!1}),this.#c()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(t){this.enterInEditMode()}keydown(t){t.target===this.div&&t.key==="Enter"&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){st._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let t,e;this.width&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#i),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:i}=this.editorDiv;if(i.fontSize=`calc(${this.#r}px * var(--scale-factor))`,i.color=this.#t,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),$e(this,this.div,["dblclick","keydown"]),this.width){const[s,n]=this.parentDimensions;if(this.annotationElementId){const{position:r}=this._initialData;let[a,o]=this.getInitialTranslation();[a,o]=this.pageTranslationToScreen(a,o);const[h,c]=this.pageDimensions,[d,u]=this.pageTranslation;let f,p;switch(this.rotation){case 0:f=t+(r[0]-d)/h,p=e+this.height-(r[1]-u)/c;break;case 90:f=t+(r[0]-d)/h,p=e-(r[1]-u)/c,[a,o]=[o,-a];break;case 180:f=t-this.width+(r[0]-d)/h,p=e-(r[1]-u)/c,[a,o]=[-a,-o];break;case 270:f=t+(r[0]-d-this.height*c)/h,p=e+(r[1]-u-this.width*h)/c,[a,o]=[-o,a];break}this.setAt(f*s,p*n,a,o)}else this.setAt(t*s,e*n,this.width*s,this.height*n);this.#u(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#h(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(Me,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:i}=e;if(i.length===1&&i[0]==="text/plain")return;t.preventDefault();const s=st.#f(e.getData("text")||"").replaceAll(Me,`
|
|
6
|
+
`);if(!s)return;const n=window.getSelection();if(!n.rangeCount)return;this.editorDiv.normalize(),n.deleteFromDocument();const r=n.getRangeAt(0);if(!s.includes(`
|
|
7
|
+
`)){r.insertNode(document.createTextNode(s)),this.editorDiv.normalize(),n.collapseToStart();return}const{startContainer:a,startOffset:o}=r,h=[],c=[];if(a.nodeType===Node.TEXT_NODE){const f=a.parentElement;if(c.push(a.nodeValue.slice(o).replaceAll(Me,"")),f!==this.editorDiv){let p=h;for(const g of this.editorDiv.childNodes){if(g===f){p=c;continue}p.push(st.#h(g))}}h.push(a.nodeValue.slice(0,o).replaceAll(Me,""))}else if(a===this.editorDiv){let f=h,p=0;for(const g of this.editorDiv.childNodes)p++===o&&(f=c),f.push(st.#h(g))}this.#e=`${h.join(`
|
|
8
|
+
`)}${s}${c.join(`
|
|
9
|
+
`)}`,this.#u();const d=new Range;let u=h.reduce((f,p)=>f+p.length,0);for(const{firstChild:f}of this.editorDiv.childNodes)if(f.nodeType===Node.TEXT_NODE){const p=f.nodeValue.length;if(u<=p){d.setStart(f,u),d.setEnd(f,u);break}u-=p}n.removeAllRanges(),n.addRange(d)}#u(){if(this.editorDiv.replaceChildren(),!!this.#e)for(const t of this.#e.split(`
|
|
10
|
+
`)){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#d(){return this.#e.replaceAll(" "," ")}static#f(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}static async deserialize(t,e,i){let s=null;if(t instanceof En){const{data:{defaultAppearanceData:{fontSize:r,fontColor:a},rect:o,rotation:h,id:c,popupRef:d},textContent:u,textPosition:f,parent:{page:{pageNumber:p}}}=t;if(!u||u.length===0)return null;s=t={annotationType:B.FREETEXT,color:Array.from(a),fontSize:r,value:u.join(`
|
|
11
|
+
`),position:f,pageIndex:p-1,rect:o.slice(0),rotation:h,id:c,deleted:!1,popupRef:d}}const n=await super.deserialize(t,e,i);return n.#r=t.fontSize,n.#t=M.makeHexColor(...t.color),n.#e=st.#f(t.value),n.annotationElementId=t.id||null,n._initialData=s,n}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const e=st._internalPadding*this.parentScale,i=this.getRect(e,e),s=D._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#t),n={annotationType:B.FREETEXT,color:s,fontSize:this.#r,value:this.#d(),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?n:this.annotationElementId&&!this.#o(n)?null:(n.id=this.annotationElementId,n)}#o(t){const{value:e,fontSize:i,color:s,pageIndex:n}=this._initialData;return this._hasBeenMoved||t.value!==e||t.fontSize!==i||t.color.some((r,a)=>r!==s[a])||t.pageIndex!==n}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(this.deleted)return e;const{style:i}=e;i.fontSize=`calc(${this.#r}px * var(--scale-factor))`,i.color=this.#t,e.replaceChildren();for(const n of this.#e.split(`
|
|
12
|
+
`)){const r=document.createElement("div");r.append(n?document.createTextNode(n):document.createElement("br")),e.append(r)}const s=st._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(s,s),popupContent:this.#e}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class R{static PRECISION=1e-4;toSVGPath(){z("Abstract method `toSVGPath` must be implemented.")}get box(){z("Abstract getter `box` must be implemented.")}serialize(t,e){z("Abstract method `serialize` must be implemented.")}static _rescale(t,e,i,s,n,r){r||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a]*s,r[a+1]=i+t[a+1]*n;return r}static _rescaleAndSwap(t,e,i,s,n,r){r||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a+1]*s,r[a+1]=i+t[a]*n;return r}static _translate(t,e,i,s){s||=new Float32Array(t.length);for(let n=0,r=t.length;n<r;n+=2)s[n]=e+t[n],s[n+1]=i+t[n+1];return s}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,i,s,n){switch(n){case 90:return[1-e/i,t/s];case 180:return[1-t/i,1-e/s];case 270:return[e/i,1-t/s];default:return[t/i,e/s]}}static _normalizePagePoint(t,e,i){switch(i){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,i,s,n,r){return[(t+5*i)/6,(e+5*s)/6,(5*i+n)/6,(5*s+r)/6,(i+n)/2,(s+r)/2]}}class Xt{#t;#e=[];#i;#s;#r=[];#n=new Float32Array(18);#a;#l;#c;#h;#u;#d;#f=[];static#o=8;static#p=2;static#m=Xt.#o+Xt.#p;constructor({x:t,y:e},i,s,n,r,a=0){this.#t=i,this.#d=n*s,this.#s=r,this.#n.set([NaN,NaN,NaN,NaN,t,e],6),this.#i=a,this.#h=Xt.#o*s,this.#c=Xt.#m*s,this.#u=s,this.#f.push(t,e)}isEmpty(){return isNaN(this.#n[8])}#g(){const t=this.#n.subarray(4,6),e=this.#n.subarray(16,18),[i,s,n,r]=this.#t;return[(this.#a+(t[0]-e[0])/2-i)/n,(this.#l+(t[1]-e[1])/2-s)/r,(this.#a+(e[0]-t[0])/2-i)/n,(this.#l+(e[1]-t[1])/2-s)/r]}add({x:t,y:e}){this.#a=t,this.#l=e;const[i,s,n,r]=this.#t;let[a,o,h,c]=this.#n.subarray(8,12);const d=t-h,u=e-c,f=Math.hypot(d,u);if(f<this.#c)return!1;const p=f-this.#h,g=p/f,b=g*d,m=g*u;let w=a,y=o;a=h,o=c,h+=b,c+=m,this.#f?.push(t,e);const A=-m/p,v=b/p,C=A*this.#d,x=v*this.#d;return this.#n.set(this.#n.subarray(2,8),0),this.#n.set([h+C,c+x],4),this.#n.set(this.#n.subarray(14,18),12),this.#n.set([h-C,c-x],16),isNaN(this.#n[6])?(this.#r.length===0&&(this.#n.set([a+C,o+x],2),this.#r.push(NaN,NaN,NaN,NaN,(a+C-i)/n,(o+x-s)/r),this.#n.set([a-C,o-x],14),this.#e.push(NaN,NaN,NaN,NaN,(a-C-i)/n,(o-x-s)/r)),this.#n.set([w,y,a,o,h,c],6),!this.isEmpty()):(this.#n.set([w,y,a,o,h,c],6),Math.abs(Math.atan2(y-o,w-a)-Math.atan2(m,b))<Math.PI/2?([a,o,h,c]=this.#n.subarray(2,6),this.#r.push(NaN,NaN,NaN,NaN,((a+h)/2-i)/n,((o+c)/2-s)/r),[a,o,w,y]=this.#n.subarray(14,18),this.#e.push(NaN,NaN,NaN,NaN,((w+a)/2-i)/n,((y+o)/2-s)/r),!0):([w,y,a,o,h,c]=this.#n.subarray(0,6),this.#r.push(((w+5*a)/6-i)/n,((y+5*o)/6-s)/r,((5*a+h)/6-i)/n,((5*o+c)/6-s)/r,((a+h)/2-i)/n,((o+c)/2-s)/r),[h,c,a,o,w,y]=this.#n.subarray(12,18),this.#e.push(((w+5*a)/6-i)/n,((y+5*o)/6-s)/r,((5*a+h)/6-i)/n,((5*o+c)/6-s)/r,((a+h)/2-i)/n,((o+c)/2-s)/r),!0))}toSVGPath(){if(this.isEmpty())return"";const t=this.#r,e=this.#e;if(isNaN(this.#n[6])&&!this.isEmpty())return this.#b();const i=[];i.push(`M${t[4]} ${t[5]}`);for(let s=6;s<t.length;s+=6)isNaN(t[s])?i.push(`L${t[s+4]} ${t[s+5]}`):i.push(`C${t[s]} ${t[s+1]} ${t[s+2]} ${t[s+3]} ${t[s+4]} ${t[s+5]}`);this.#w(i);for(let s=e.length-6;s>=6;s-=6)isNaN(e[s])?i.push(`L${e[s+4]} ${e[s+5]}`):i.push(`C${e[s]} ${e[s+1]} ${e[s+2]} ${e[s+3]} ${e[s+4]} ${e[s+5]}`);return this.#y(i),i.join(" ")}#b(){const[t,e,i,s]=this.#t,[n,r,a,o]=this.#g();return`M${(this.#n[2]-t)/i} ${(this.#n[3]-e)/s} L${(this.#n[4]-t)/i} ${(this.#n[5]-e)/s} L${n} ${r} L${a} ${o} L${(this.#n[16]-t)/i} ${(this.#n[17]-e)/s} L${(this.#n[14]-t)/i} ${(this.#n[15]-e)/s} Z`}#y(t){const e=this.#e;t.push(`L${e[4]} ${e[5]} Z`)}#w(t){const[e,i,s,n]=this.#t,r=this.#n.subarray(4,6),a=this.#n.subarray(16,18),[o,h,c,d]=this.#g();t.push(`L${(r[0]-e)/s} ${(r[1]-i)/n} L${o} ${h} L${c} ${d} L${(a[0]-e)/s} ${(a[1]-i)/n}`)}newFreeDrawOutline(t,e,i,s,n,r){return new Cn(t,e,i,s,n,r)}getOutlines(){const t=this.#r,e=this.#e,i=this.#n,[s,n,r,a]=this.#t,o=new Float32Array((this.#f?.length??0)+2);for(let d=0,u=o.length-2;d<u;d+=2)o[d]=(this.#f[d]-s)/r,o[d+1]=(this.#f[d+1]-n)/a;if(o[o.length-2]=(this.#a-s)/r,o[o.length-1]=(this.#l-n)/a,isNaN(i[6])&&!this.isEmpty())return this.#A(o);const h=new Float32Array(this.#r.length+24+this.#e.length);let c=t.length;for(let d=0;d<c;d+=2){if(isNaN(t[d])){h[d]=h[d+1]=NaN;continue}h[d]=t[d],h[d+1]=t[d+1]}c=this.#S(h,c);for(let d=e.length-6;d>=6;d-=6)for(let u=0;u<6;u+=2){if(isNaN(e[d+u])){h[c]=h[c+1]=NaN,c+=2;continue}h[c]=e[d+u],h[c+1]=e[d+u+1],c+=2}return this.#v(h,c),this.newFreeDrawOutline(h,o,this.#t,this.#u,this.#i,this.#s)}#A(t){const e=this.#n,[i,s,n,r]=this.#t,[a,o,h,c]=this.#g(),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-i)/n,(e[3]-s)/r,NaN,NaN,NaN,NaN,(e[4]-i)/n,(e[5]-s)/r,NaN,NaN,NaN,NaN,a,o,NaN,NaN,NaN,NaN,h,c,NaN,NaN,NaN,NaN,(e[16]-i)/n,(e[17]-s)/r,NaN,NaN,NaN,NaN,(e[14]-i)/n,(e[15]-s)/r],0),this.newFreeDrawOutline(d,t,this.#t,this.#u,this.#i,this.#s)}#v(t,e){const i=this.#e;return t.set([NaN,NaN,NaN,NaN,i[4],i[5]],e),e+=6}#S(t,e){const i=this.#n.subarray(4,6),s=this.#n.subarray(16,18),[n,r,a,o]=this.#t,[h,c,d,u]=this.#g();return t.set([NaN,NaN,NaN,NaN,(i[0]-n)/a,(i[1]-r)/o,NaN,NaN,NaN,NaN,h,c,NaN,NaN,NaN,NaN,d,u,NaN,NaN,NaN,NaN,(s[0]-n)/a,(s[1]-r)/o],e),e+=24}}class Cn extends R{#t;#e=new Float32Array(4);#i;#s;#r;#n;#a;constructor(t,e,i,s,n,r){super(),this.#a=t,this.#r=e,this.#t=i,this.#n=s,this.#i=n,this.#s=r,this.lastPoint=[NaN,NaN],this.#l(r);const[a,o,h,c]=this.#e;for(let d=0,u=t.length;d<u;d+=2)t[d]=(t[d]-a)/h,t[d+1]=(t[d+1]-o)/c;for(let d=0,u=e.length;d<u;d+=2)e[d]=(e[d]-a)/h,e[d+1]=(e[d+1]-o)/c}toSVGPath(){const t=[`M${this.#a[4]} ${this.#a[5]}`];for(let e=6,i=this.#a.length;e<i;e+=6){if(isNaN(this.#a[e])){t.push(`L${this.#a[e+4]} ${this.#a[e+5]}`);continue}t.push(`C${this.#a[e]} ${this.#a[e+1]} ${this.#a[e+2]} ${this.#a[e+3]} ${this.#a[e+4]} ${this.#a[e+5]}`)}return t.push("Z"),t.join(" ")}serialize([t,e,i,s],n){const r=i-t,a=s-e;let o,h;switch(n){case 0:o=R._rescale(this.#a,t,s,r,-a),h=R._rescale(this.#r,t,s,r,-a);break;case 90:o=R._rescaleAndSwap(this.#a,t,e,r,a),h=R._rescaleAndSwap(this.#r,t,e,r,a);break;case 180:o=R._rescale(this.#a,i,e,-r,a),h=R._rescale(this.#r,i,e,-r,a);break;case 270:o=R._rescaleAndSwap(this.#a,i,s,-r,-a),h=R._rescaleAndSwap(this.#r,i,s,-r,-a);break}return{outline:Array.from(o),points:[Array.from(h)]}}#l(t){const e=this.#a;let i=e[4],s=e[5],n=i,r=s,a=i,o=s,h=i,c=s;const d=t?Math.max:Math.min;for(let f=6,p=e.length;f<p;f+=6){if(isNaN(e[f]))n=Math.min(n,e[f+4]),r=Math.min(r,e[f+5]),a=Math.max(a,e[f+4]),o=Math.max(o,e[f+5]),c<e[f+5]?(h=e[f+4],c=e[f+5]):c===e[f+5]&&(h=d(h,e[f+4]));else{const g=M.bezierBoundingBox(i,s,...e.slice(f,f+6));n=Math.min(n,g[0]),r=Math.min(r,g[1]),a=Math.max(a,g[2]),o=Math.max(o,g[3]),c<g[3]?(h=g[2],c=g[3]):c===g[3]&&(h=d(h,g[2]))}i=e[f+4],s=e[f+5]}const u=this.#e;u[0]=n-this.#i,u[1]=r-this.#i,u[2]=a-n+2*this.#i,u[3]=o-r+2*this.#i,this.lastPoint=[h,c]}get box(){return this.#e}newOutliner(t,e,i,s,n,r=0){return new Xt(t,e,i,s,n,r)}getNewOutline(t,e){const[i,s,n,r]=this.#e,[a,o,h,c]=this.#t,d=n*h,u=r*c,f=i*h+a,p=s*c+o,g=this.newOutliner({x:this.#r[0]*d+f,y:this.#r[1]*u+p},this.#t,this.#n,t,this.#s,e??this.#i);for(let b=2;b<this.#r.length;b+=2)g.add({x:this.#r[b]*d+f,y:this.#r[b+1]*u+p});return g.getOutlines()}}class Ci{#t;#e;#i=[];#s=[];constructor(t,e=0,i=0,s=!0){let n=1/0,r=-1/0,a=1/0,o=-1/0;const h=10**-4;for(const{x:b,y:m,width:w,height:y}of t){const A=Math.floor((b-e)/h)*h,v=Math.ceil((b+w+e)/h)*h,C=Math.floor((m-e)/h)*h,x=Math.ceil((m+y+e)/h)*h,T=[A,C,x,!0],_=[v,C,x,!1];this.#i.push(T,_),n=Math.min(n,A),r=Math.max(r,v),a=Math.min(a,C),o=Math.max(o,x)}const c=r-n+2*i,d=o-a+2*i,u=n-i,f=a-i,p=this.#i.at(s?-1:-2),g=[p[0],p[2]];for(const b of this.#i){const[m,w,y]=b;b[0]=(m-u)/c,b[1]=(w-f)/d,b[2]=(y-f)/d}this.#t=new Float32Array([u,f,c,d]),this.#e=g}getOutlines(){this.#i.sort((e,i)=>e[0]-i[0]||e[1]-i[1]||e[2]-i[2]);const t=[];for(const e of this.#i)e[3]?(t.push(...this.#c(e)),this.#a(e)):(this.#l(e),t.push(...this.#c(e)));return this.#r(t)}#r(t){const e=[],i=new Set;for(const r of t){const[a,o,h]=r;e.push([a,o,r],[a,h,r])}e.sort((r,a)=>r[1]-a[1]||r[0]-a[0]);for(let r=0,a=e.length;r<a;r+=2){const o=e[r][2],h=e[r+1][2];o.push(h),h.push(o),i.add(o),i.add(h)}const s=[];let n;for(;i.size>0;){const r=i.values().next().value;let[a,o,h,c,d]=r;i.delete(r);let u=a,f=o;for(n=[a,h],s.push(n);;){let p;if(i.has(c))p=c;else if(i.has(d))p=d;else break;i.delete(p),[a,o,h,c,d]=p,u!==a&&(n.push(u,f,a,f===o?o:h),u=a),f=f===o?h:o}n.push(u,f)}return new Oa(s,this.#t,this.#e)}#n(t){const e=this.#s;let i=0,s=e.length-1;for(;i<=s;){const n=i+s>>1,r=e[n][0];if(r===t)return n;r<t?i=n+1:s=n-1}return s+1}#a([,t,e]){const i=this.#n(t);this.#s.splice(i,0,[t,e])}#l([,t,e]){const i=this.#n(t);for(let s=i;s<this.#s.length;s++){const[n,r]=this.#s[s];if(n!==t)break;if(n===t&&r===e){this.#s.splice(s,1);return}}for(let s=i-1;s>=0;s--){const[n,r]=this.#s[s];if(n!==t)break;if(n===t&&r===e){this.#s.splice(s,1);return}}}#c(t){const[e,i,s]=t,n=[[e,i,s]],r=this.#n(s);for(let a=0;a<r;a++){const[o,h]=this.#s[a];for(let c=0,d=n.length;c<d;c++){const[,u,f]=n[c];if(!(h<=u||f<=o)){if(u>=o){if(f>h)n[c][1]=h;else{if(d===1)return[];n.splice(c,1),c--,d--}continue}n[c][2]=o,f>h&&n.push([e,h,f])}}}return n}}class Oa extends R{#t;#e;constructor(t,e,i){super(),this.#e=t,this.#t=e,this.lastPoint=i}toSVGPath(){const t=[];for(const e of this.#e){let[i,s]=e;t.push(`M${i} ${s}`);for(let n=2;n<e.length;n+=2){const r=e[n],a=e[n+1];r===i?(t.push(`V${a}`),s=a):a===s&&(t.push(`H${r}`),i=r)}t.push("Z")}return t.join(" ")}serialize([t,e,i,s],n){const r=[],a=i-t,o=s-e;for(const h of this.#e){const c=new Array(h.length);for(let d=0;d<h.length;d+=2)c[d]=t+h[d]*a,c[d+1]=s-h[d+1]*o;r.push(c)}return r}get box(){return this.#t}get classNamesForOutlining(){return["highlightOutline"]}}class Ti extends Xt{newFreeDrawOutline(t,e,i,s,n,r){return new Ba(t,e,i,s,n,r)}}class Ba extends Cn{newOutliner(t,e,i,s,n,r=0){return new Ti(t,e,i,s,n,r)}}let Tn=class Lt{#t=null;#e=null;#i;#s=null;#r=!1;#n=!1;#a=null;#l;#c=null;#h=null;#u;static#d=null;static get _keyboardManager(){return H(this,"_keyboardManager",new Ce([[["Escape","mac+Escape"],Lt.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],Lt.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],Lt.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],Lt.prototype._moveToPrevious],[["Home","mac+Home"],Lt.prototype._moveToBeginning],[["End","mac+End"],Lt.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){t?(this.#n=!1,this.#u=V.HIGHLIGHT_COLOR,this.#a=t):(this.#n=!0,this.#u=V.HIGHLIGHT_DEFAULT_COLOR),this.#h=t?._uiManager||e,this.#l=this.#h._eventBus,this.#i=t?.color||this.#h?.highlightColors.values().next().value||"#FFFF98",Lt.#d||=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"})}renderButton(){const t=this.#t=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);const e=this.#h._signal;t.addEventListener("click",this.#m.bind(this),{signal:e}),t.addEventListener("keydown",this.#p.bind(this),{signal:e});const i=this.#e=document.createElement("span");return i.className="swatch",i.setAttribute("aria-hidden",!0),i.style.backgroundColor=this.#i,t.append(i),t}renderMainDropdown(){const t=this.#s=this.#f();return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}#f(){const t=document.createElement("div"),e=this.#h._signal;t.addEventListener("contextmenu",xt,{signal:e}),t.className="dropdown",t.role="listbox",t.setAttribute("aria-multiselectable",!1),t.setAttribute("aria-orientation","vertical"),t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(const[i,s]of this.#h.highlightColors){const n=document.createElement("button");n.tabIndex="0",n.role="option",n.setAttribute("data-color",s),n.title=i,n.setAttribute("data-l10n-id",Lt.#d[i]);const r=document.createElement("span");n.append(r),r.className="swatch",r.style.backgroundColor=s,n.setAttribute("aria-selected",s===this.#i),n.addEventListener("click",this.#o.bind(this,s),{signal:e}),t.append(n)}return t.addEventListener("keydown",this.#p.bind(this),{signal:e}),t}#o(t,e){e.stopPropagation(),this.#l.dispatch("switchannotationeditorparams",{source:this,type:this.#u,value:t})}_colorSelectFromKeyboard(t){if(t.target===this.#t){this.#m(t);return}const e=t.target.getAttribute("data-color");e&&this.#o(e,t)}_moveToNext(t){if(!this.#b){this.#m(t);return}if(t.target===this.#t){this.#s.firstChild?.focus();return}t.target.nextSibling?.focus()}_moveToPrevious(t){if(t.target===this.#s?.firstChild||t.target===this.#t){this.#b&&this._hideDropdownFromKeyboard();return}this.#b||this.#m(t),t.target.previousSibling?.focus()}_moveToBeginning(t){if(!this.#b){this.#m(t);return}this.#s.firstChild?.focus()}_moveToEnd(t){if(!this.#b){this.#m(t);return}this.#s.lastChild?.focus()}#p(t){Lt._keyboardManager.exec(this,t)}#m(t){if(this.#b){this.hideDropdown();return}if(this.#r=t.detail===0,this.#c||(this.#c=new AbortController,window.addEventListener("pointerdown",this.#g.bind(this),{signal:this.#h.combinedSignal(this.#c)})),this.#s){this.#s.classList.remove("hidden");return}const e=this.#s=this.#f();this.#t.append(e)}#g(t){this.#s?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#s?.classList.add("hidden"),this.#c?.abort(),this.#c=null}get#b(){return this.#s&&!this.#s.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(!this.#n){if(!this.#b){this.#a?.unselect();return}this.hideDropdown(),this.#t.focus({preventScroll:!0,focusVisible:this.#r})}}updateColor(t){if(this.#e&&(this.#e.style.backgroundColor=t),!this.#s)return;const e=this.#h.highlightColors.values();for(const i of this.#s.children)i.setAttribute("aria-selected",e.next().value===t)}destroy(){this.#t?.remove(),this.#t=null,this.#e=null,this.#s?.remove(),this.#s=null}};class Y extends D{#t=null;#e=0;#i;#s=null;#r=null;#n=null;#a=null;#l=0;#c=null;#h=null;#u=null;#d=!1;#f=null;#o;#p=null;#m="";#g;#b="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=B.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const t=Y.prototype;return H(this,"_keyboardManager",new Ce([[["ArrowLeft","mac+ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super({...t,name:"highlightEditor"}),this.color=t.color||Y._defaultColor,this.#g=t.thickness||Y._defaultThickness,this.#o=t.opacity||Y._defaultOpacity,this.#i=t.boxes||null,this.#b=t.methodOfCreation||"",this.#m=t.text||"",this._isDraggable=!1,t.highlightId>-1?(this.#d=!0,this.#w(t),this.#L()):this.#i&&(this.#t=t.anchorNode,this.#e=t.anchorOffset,this.#a=t.focusNode,this.#l=t.focusOffset,this.#y(),this.#L(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#d?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#g,methodOfCreation:this.#b}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#y(){const t=new Ci(this.#i,.001);this.#h=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#h.box;const e=new Ci(this.#i,.0025,.001,this._uiManager.direction==="ltr");this.#n=e.getOutlines();const{lastPoint:i}=this.#n;this.#f=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]}#w({highlightOutlines:t,highlightId:e,clipPathId:i}){this.#h=t;const s=1.5;if(this.#n=t.getNewOutline(this.#g/2+s,.0025),e>=0)this.#u=e,this.#s=i,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#p=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#n.box,path:{d:this.#n.toSVGPath()}},!0);else if(this.parent){const c=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#u,{bbox:Y.#E(this.#h.box,(c-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#p,{bbox:Y.#E(this.#n.box,c),path:{d:this.#n.toSVGPath()}})}const[n,r,a,o]=t.box;switch(this.rotation){case 0:this.x=n,this.y=r,this.width=a,this.height=o;break;case 90:{const[c,d]=this.parentDimensions;this.x=r,this.y=1-n,this.width=a*d/c,this.height=o*c/d;break}case 180:this.x=1-n,this.y=1-r,this.width=a,this.height=o;break;case 270:{const[c,d]=this.parentDimensions;this.x=1-r,this.y=n,this.width=a*d/c,this.height=o*c/d;break}}const{lastPoint:h}=this.#n;this.#f=[(h[0]-n)/a,(h[1]-r)/o]}static initialize(t,e){D.initialize(t,e),Y._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case V.HIGHLIGHT_DEFAULT_COLOR:Y._defaultColor=e;break;case V.HIGHLIGHT_THICKNESS:Y._defaultThickness=e;break}}translateInPage(t,e){}get toolbarPosition(){return this.#f}updateParams(t,e){switch(t){case V.HIGHLIGHT_COLOR:this.#A(e);break;case V.HIGHLIGHT_THICKNESS:this.#v(e);break}}static get defaultPropertiesToUpdate(){return[[V.HIGHLIGHT_DEFAULT_COLOR,Y._defaultColor],[V.HIGHLIGHT_THICKNESS,Y._defaultThickness]]}get propertiesToUpdate(){return[[V.HIGHLIGHT_COLOR,this.color||Y._defaultColor],[V.HIGHLIGHT_THICKNESS,this.#g||Y._defaultThickness],[V.HIGHLIGHT_FREE,this.#d]]}#A(t){const e=(n,r)=>{this.color=n,this.#o=r,this.parent?.drawLayer.updateProperties(this.#u,{root:{fill:n,"fill-opacity":r}}),this.#r?.updateColor(n)},i=this.color,s=this.#o;this.addCommands({cmd:e.bind(this,t,Y._defaultOpacity),undo:e.bind(this,i,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:V.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}#v(t){const e=this.#g,i=s=>{this.#g=s,this.#S(s)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:V.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}async addEditToolbar(){const t=await super.addEditToolbar();return t?(this._uiManager.highlightColors&&(this.#r=new Tn({editor:this}),t.addColorPicker(this.#r)),t):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#I())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#I())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#x(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#L(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#x():t&&(this.#L(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#S(t){if(!this.#d)return;this.#w({highlightOutlines:this.#h.getNewOutline(t/2)}),this.fixAndSetPosition();const[e,i]=this.parentDimensions;this.setDims(this.width*e,this.height*i)}#x(){this.#u===null||!this.parent||(this.parent.drawLayer.remove(this.#u),this.#u=null,this.parent.drawLayer.remove(this.#p),this.#p=null)}#L(t=this.parent){this.#u===null&&({id:this.#u,clipPathId:this.#s}=t.drawLayer.draw({bbox:this.#h.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.#o},rootClass:{highlight:!0,free:this.#d},path:{d:this.#h.toSVGPath()}},!1,!0),this.#p=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#d},bbox:this.#n.box,path:{d:this.#n.toSVGPath()}},this.#d),this.#c&&(this.#c.style.clipPath=this.#s))}static#E([t,e,i,s],n){switch(n){case 90:return[1-e-s,t,s,i];case 180:return[1-t-i,1-e-s,i,s];case 270:return[e,1-t-i,s,i]}return[t,e,i,s]}rotate(t){const{drawLayer:e}=this.parent;let i;this.#d?(t=(t-this.rotation+360)%360,i=Y.#E(this.#h.box,t)):i=Y.#E([this.x,this.y,this.width,this.height],t),e.updateProperties(this.#u,{bbox:i,root:{"data-main-rotation":t}}),e.updateProperties(this.#p,{bbox:Y.#E(this.#n.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;const t=super.render();this.#m&&(t.setAttribute("aria-label",this.#m),t.setAttribute("role","mark")),this.#d?t.classList.add("free"):this.div.addEventListener("keydown",this.#T.bind(this),{signal:this._uiManager._signal});const e=this.#c=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#s;const[i,s]=this.parentDimensions;return this.setDims(this.width*i,this.height*s),$e(this,this.#c,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{hovered:!1}})}#T(t){Y._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#P(!0);break;case 1:case 3:this.#P(!1);break}}#P(t){if(!this.#t)return;const e=window.getSelection();t?e.setPosition(this.#t,this.#e):e.setPosition(this.#a,this.#l)}select(){super.select(),this.#p&&this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#p&&(this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{selected:!1}}),this.#d||this.#P(!1))}get _mustFixPosition(){return!this.#d}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#u,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#p,{rootClass:{hidden:!t}}))}#I(){return this.#d?this.rotation:0}#M(){if(this.#d)return null;const[t,e]=this.pageDimensions,[i,s]=this.pageTranslation,n=this.#i,r=new Float32Array(n.length*8);let a=0;for(const{x:o,y:h,width:c,height:d}of n){const u=o*t+i,f=(1-h)*e+s;r[a]=r[a+4]=u,r[a+1]=r[a+3]=f,r[a+2]=r[a+6]=u+c*t,r[a+5]=r[a+7]=f-d*e,a+=8}return r}#D(t){return this.#h.serialize(t,this.#I())}static startHighlighting(t,e,{target:i,x:s,y:n}){const{x:r,y:a,width:o,height:h}=i.getBoundingClientRect(),c=new AbortController,d=t.combinedSignal(c),u=f=>{c.abort(),this.#_(t,f)};window.addEventListener("blur",u,{signal:d}),window.addEventListener("pointerup",u,{signal:d}),window.addEventListener("pointerdown",wt,{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",xt,{signal:d}),i.addEventListener("pointermove",this.#C.bind(this,t),{signal:d}),this._freeHighlight=new Ti({x:s,y:n},[r,a,o,h],t.scale,this._defaultThickness/2,e,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static#C(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#_(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static async deserialize(t,e,i){let s=null;if(t instanceof xn){const{data:{quadPoints:p,rect:g,rotation:b,id:m,color:w,opacity:y,popupRef:A},parent:{page:{pageNumber:v}}}=t;s=t={annotationType:B.HIGHLIGHT,color:Array.from(w),opacity:y,quadPoints:p,boxes:null,pageIndex:v-1,rect:g.slice(0),rotation:b,id:m,deleted:!1,popupRef:A}}else if(t instanceof Xi){const{data:{inkLists:p,rect:g,rotation:b,id:m,color:w,borderStyle:{rawWidth:y},popupRef:A},parent:{page:{pageNumber:v}}}=t;s=t={annotationType:B.HIGHLIGHT,color:Array.from(w),thickness:y,inkLists:p,boxes:null,pageIndex:v-1,rect:g.slice(0),rotation:b,id:m,deleted:!1,popupRef:A}}const{color:n,quadPoints:r,inkLists:a,opacity:o}=t,h=await super.deserialize(t,e,i);h.color=M.makeHexColor(...n),h.#o=o||1,a&&(h.#g=t.thickness),h.annotationElementId=t.id||null,h._initialData=s;const[c,d]=h.pageDimensions,[u,f]=h.pageTranslation;if(r){const p=h.#i=[];for(let g=0;g<r.length;g+=8)p.push({x:(r[g]-u)/c,y:1-(r[g+1]-f)/d,width:(r[g+2]-r[g])/c,height:(r[g+1]-r[g+5])/d});h.#y(),h.#L(),h.rotate(h.rotation)}else if(a){h.#d=!0;const p=a[0],g={x:p[0]-u,y:d-(p[1]-f)},b=new Ti(g,[0,0,c,d],1,h.#g/2,!0,.001);for(let y=0,A=p.length;y<A;y+=2)g.x=p[y]-u,g.y=d-(p[y+1]-f),b.add(g);const{id:m,clipPathId:w}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:h.color,"fill-opacity":h._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:b.toSVGPath()}},!0,!0);h.#w({highlightOutlines:b.getOutlines(),highlightId:m,clipPathId:w}),h.#L()}return h}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=this.getRect(0,0),i=D._colorManager.convert(this.color),s={annotationType:B.HIGHLIGHT,color:i,opacity:this.#o,thickness:this.#g,quadPoints:this.#M(),outlines:this.#D(e),pageIndex:this.pageIndex,rect:e,rotation:this.#I(),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!this.#F(s)?null:(s.id=this.annotationElementId,s)}#F(t){const{color:e}=this._initialData;return t.color.some((i,s)=>i!==e[s])}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class ja{#t=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,i]of Object.entries(t))this.updateProperty(e,i)}updateSVGProperty(t,e){this.#t[t]=e}toSVGProperties(){const t=this.#t;return this.#t=Object.create(null),{root:t}}reset(){this.#t=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){z("Not implemented")}}class N extends D{#t=null;#e;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#i=null;static#s=null;static#r=null;static#n=NaN;static#a=null;static#l=null;static#c=NaN;static _INNER_MARGIN=3;constructor(t){super(t),this.#e=t.mustBeCommitted||!1,t.drawOutlines&&(this.#h(t),this.#f())}#h({drawOutlines:t,drawId:e,drawingOptions:i}){this.#t=t,this._drawingOptions||=i,e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#u(t,this.parent),this.#m(t.box)}#u(t,e){const{id:i}=e.drawLayer.draw(N._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return i}static _mergeSVGProperties(t,e){const i=new Set(Object.keys(t));for(const[s,n]of Object.entries(e))i.has(s)?Object.assign(t[s],n):t[s]=n;return t}static getDefaultDrawingOptions(t){z("Not implemented")}static get typesMap(){z("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){const i=this.typesMap.get(t);i&&this._defaultDrawingOptions.updateProperty(i,e),this._currentParent&&(N.#i.updateProperty(i,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){const i=this.constructor.typesMap.get(t);i&&this._updateProperty(t,i,e)}static get defaultPropertiesToUpdate(){const t=[],e=this._defaultDrawingOptions;for(const[i,s]of this.typesMap)t.push([i,e[s]]);return t}get propertiesToUpdate(){const t=[],{_drawingOptions:e}=this;for(const[i,s]of this.constructor.typesMap)t.push([i,e[s]]);return t}_updateProperty(t,e,i){const s=this._drawingOptions,n=s[e],r=a=>{s.updateProperty(e,a);const o=this.#t.updateProperty(e,a);o&&this.#m(o),this.parent?.drawLayer.updateProperties(this._drawId,s.toSVGProperties())};this.addCommands({cmd:r.bind(this,i),undo:r.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,N._mergeSVGProperties(this.#t.getPathResizingSVGProperties(this.#p()),{bbox:this.#g()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,N._mergeSVGProperties(this.#t.getPathResizedSVGProperties(this.#p()),{bbox:this.#g()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#g(t,e)})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,N._mergeSVGProperties(this.#t.getPathTranslatedSVGProperties(this.#p(),this.parentDimensions),{bbox:this.#g()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#e&&(this.#e=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#d(),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#f(),this.#m(this.#t.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#d()):t&&(this._uiManager.addShouldRescale(this),this.#f(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#d(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#f(t=this.parent){if(!(this._drawId!==null&&this.parent===t)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,t.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=this.#u(this.#t,t)}}#o([t,e,i,s]){const{parentDimensions:[n,r],rotation:a}=this;switch(a){case 90:return[e,1-t,i*(r/n),s*(n/r)];case 180:return[1-t,1-e,i,s];case 270:return[1-e,t,i*(r/n),s*(n/r)];default:return[t,e,i,s]}}#p(){const{x:t,y:e,width:i,height:s,parentDimensions:[n,r],rotation:a}=this;switch(a){case 90:return[1-e,t,i*(n/r),s*(r/n)];case 180:return[1-t,1-e,i,s];case 270:return[e,1-t,i*(n/r),s*(r/n)];default:return[t,e,i,s]}}#m(t){if([this.x,this.y,this.width,this.height]=this.#o(t),this.div){this.fixAndSetPosition();const[e,i]=this.parentDimensions;this.setDims(this.width*e,this.height*i)}this._onResized()}#g(){const{x:t,y:e,width:i,height:s,rotation:n,parentRotation:r,parentDimensions:[a,o]}=this;switch((n*4+r)/90){case 1:return[1-e-s,t,s,i];case 2:return[1-t-i,1-e-s,i,s];case 3:return[e,1-t-i,s,i];case 4:return[t,e-i*(a/o),s*(o/a),i*(a/o)];case 5:return[1-e,t,i*(a/o),s*(o/a)];case 6:return[1-t-s*(o/a),1-e,s*(o/a),i*(a/o)];case 7:return[e-i*(a/o),1-t-s*(o/a),i*(a/o),s*(o/a)];case 8:return[t-i,e-s,i,s];case 9:return[1-e,t-i,s,i];case 10:return[1-t,1-e,i,s];case 11:return[e-s,1-t,s,i];case 12:return[t-s*(o/a),e,s*(o/a),i*(a/o)];case 13:return[1-e-i*(a/o),t-s*(o/a),i*(a/o),s*(o/a)];case 14:return[1-t,1-e-i*(a/o),s*(o/a),i*(a/o)];case 15:return[e,1-t,i*(a/o),s*(o/a)];default:return[t,e,i,s]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,N._mergeSVGProperties({bbox:this.#g()},this.#t.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#m(this.#t.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;const t=super.render();t.classList.add("draw");const e=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal";const[i,s]=this.parentDimensions;return this.setDims(this.width*i,this.height*s),this._uiManager.addShouldRescale(this),this.disableEditing(),t}static createDrawerInstance(t,e,i,s,n){z("Not implemented")}static startDrawing(t,e,i,s){const{target:n,offsetX:r,offsetY:a,pointerId:o,pointerType:h}=s;if(N.#a&&N.#a!==h)return;const{viewport:{rotation:c}}=t,{width:d,height:u}=n.getBoundingClientRect(),f=N.#s=new AbortController,p=t.combinedSignal(f);if(N.#n||=o,N.#a??=h,window.addEventListener("pointerup",g=>{N.#n===g.pointerId?this._endDraw(g):N.#l?.delete(g.pointerId)},{signal:p}),window.addEventListener("pointercancel",g=>{N.#n===g.pointerId?this._currentParent.endDrawingSession():N.#l?.delete(g.pointerId)},{signal:p}),window.addEventListener("pointerdown",g=>{N.#a===g.pointerType&&((N.#l||=new Set).add(g.pointerId),N.#i.isCancellable()&&(N.#i.removeLastElement(),N.#i.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",xt,{signal:p}),n.addEventListener("pointermove",this._drawMove.bind(this),{signal:p}),n.addEventListener("touchmove",g=>{g.timeStamp===N.#c&&wt(g)},{signal:p}),t.toggleDrawing(),e._editorUndoBar?.hide(),N.#i){t.drawLayer.updateProperties(this._currentDrawId,N.#i.startNew(r,a,d,u,c));return}e.updateUIForDefaultProperties(this),N.#i=this.createDrawerInstance(r,a,d,u,c),N.#r=this.getDefaultDrawingOptions(),this._currentParent=t,{id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(N.#r.toSVGProperties(),N.#i.defaultSVGProperties),!0,!1)}static _drawMove(t){if(N.#c=-1,!N.#i)return;const{offsetX:e,offsetY:i,pointerId:s}=t;if(N.#n===s){if(N.#l?.size>=1){this._endDraw(t);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,N.#i.add(e,i)),N.#c=t.timeStamp,wt(t)}}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,N.#i=null,N.#r=null,N.#a=null,N.#c=NaN),N.#s&&(N.#s.abort(),N.#s=null,N.#n=NaN,N.#l=null)}static _endDraw(t){const e=this._currentParent;if(e){if(e.toggleDrawing(!0),this._cleanup(!1),t&&e.drawLayer.updateProperties(this._currentDrawId,N.#i.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){const i=N.#i,s=this._currentDrawId,n=i.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(s,i.setLastElement(n))},undo:()=>{e.drawLayer.updateProperties(s,i.removeLastElement())},mustExec:!1,type:V.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(t){const e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(V.DRAW_STEP),!N.#i.isEmpty()){const{pageDimensions:[i,s],scale:n}=e,r=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:N.#i.getOutlines(i*n,s*n,n,this._INNER_MARGIN),drawingOptions:N.#r,mustBeCommitted:!t});return this._cleanup(!0),r}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,i,s,n,r){z("Not implemented")}static async deserialize(t,e,i){const{rawDims:{pageWidth:s,pageHeight:n,pageX:r,pageY:a}}=e.viewport,o=this.deserializeDraw(r,a,s,n,this._INNER_MARGIN,t),h=await super.deserialize(t,e,i);return h.createDrawingOptions(t),h.#h({drawOutlines:o}),h.#f(),h.onScaleChanging(),h.rotate(),h}serializeDraw(t){const[e,i]=this.pageTranslation,[s,n]=this.pageDimensions;return this.#t.serialize([e,i,s,n],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class Ha{#t=new Float64Array(6);#e;#i;#s;#r;#n;#a="";#l=0;#c=new ti;#h;#u;constructor(t,e,i,s,n,r){this.#h=i,this.#u=s,this.#s=n,this.#r=r,[t,e]=this.#d(t,e);const a=this.#e=[NaN,NaN,NaN,NaN,t,e];this.#n=[t,e],this.#i=[{line:a,points:this.#n}],this.#t.set(a,0)}updateProperty(t,e){t==="stroke-width"&&(this.#r=e)}#d(t,e){return R._normalizePoint(t,e,this.#h,this.#u,this.#s)}isEmpty(){return!this.#i||this.#i.length===0}isCancellable(){return this.#n.length<=10}add(t,e){[t,e]=this.#d(t,e);const[i,s,n,r]=this.#t.subarray(2,6),a=t-n,o=e-r;return Math.hypot(this.#h*a,this.#u*o)<=2?null:(this.#n.push(t,e),isNaN(i)?(this.#t.set([n,r,t,e],2),this.#e.push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(this.#t[0])&&this.#e.splice(6,6),this.#t.set([i,s,n,r,t,e],0),this.#e.push(...R.createBezierPoints(i,s,n,r,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const i=this.add(t,e);return i||(this.#n.length===2?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,i,s,n){this.#h=i,this.#u=s,this.#s=n,[t,e]=this.#d(t,e);const r=this.#e=[NaN,NaN,NaN,NaN,t,e];this.#n=[t,e];const a=this.#i.at(-1);return a&&(a.line=new Float32Array(a.line),a.points=new Float32Array(a.points)),this.#i.push({line:r,points:this.#n}),this.#t.set(r,0),this.#l=0,this.toSVGPath(),null}getLastElement(){return this.#i.at(-1)}setLastElement(t){return this.#i?(this.#i.push(t),this.#e=t.line,this.#n=t.points,this.#l=0,{path:{d:this.toSVGPath()}}):this.#c.setLastElement(t)}removeLastElement(){if(!this.#i)return this.#c.removeLastElement();this.#i.pop(),this.#a="";for(let t=0,e=this.#i.length;t<e;t++){const{line:i,points:s}=this.#i[t];this.#e=i,this.#n=s,this.#l=0,this.toSVGPath()}return{path:{d:this.#a}}}toSVGPath(){const t=R.svgRound(this.#e[4]),e=R.svgRound(this.#e[5]);if(this.#n.length===2)return this.#a=`${this.#a} M ${t} ${e} Z`,this.#a;if(this.#n.length<=6){const s=this.#a.lastIndexOf("M");this.#a=`${this.#a.slice(0,s)} M ${t} ${e}`,this.#l=6}if(this.#n.length===4){const s=R.svgRound(this.#e[10]),n=R.svgRound(this.#e[11]);return this.#a=`${this.#a} L ${s} ${n}`,this.#l=12,this.#a}const i=[];this.#l===0&&(i.push(`M ${t} ${e}`),this.#l=6);for(let s=this.#l,n=this.#e.length;s<n;s+=6){const[r,a,o,h,c,d]=this.#e.slice(s,s+6).map(R.svgRound);i.push(`C${r} ${a} ${o} ${h} ${c} ${d}`)}return this.#a+=i.join(" "),this.#l=this.#e.length,this.#a}getOutlines(t,e,i,s){const n=this.#i.at(-1);return n.line=new Float32Array(n.line),n.points=new Float32Array(n.points),this.#c.build(this.#i,t,e,i,this.#s,this.#r,s),this.#t=null,this.#e=null,this.#i=null,this.#a=null,this.#c}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class ti extends R{#t;#e=0;#i;#s;#r;#n;#a;#l;#c;build(t,e,i,s,n,r,a){this.#r=e,this.#n=i,this.#a=s,this.#l=n,this.#c=r,this.#i=a??0,this.#s=t,this.#d()}setLastElement(t){return this.#s.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#s.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of this.#s){if(t.push(`M${R.svgRound(e[4])} ${R.svgRound(e[5])}`),e.length===6){t.push("Z");continue}if(e.length===12){t.push(`L${R.svgRound(e[10])} ${R.svgRound(e[11])}`);continue}for(let i=6,s=e.length;i<s;i+=6){const[n,r,a,o,h,c]=e.subarray(i,i+6).map(R.svgRound);t.push(`C${n} ${r} ${a} ${o} ${h} ${c}`)}}return t.join("")}serialize([t,e,i,s],n){const r=[],a=[],[o,h,c,d]=this.#u();let u,f,p,g,b,m,w,y,A;switch(this.#l){case 0:A=R._rescale,u=t,f=e+s,p=i,g=-s,b=t+o*i,m=e+(1-h-d)*s,w=t+(o+c)*i,y=e+(1-h)*s;break;case 90:A=R._rescaleAndSwap,u=t,f=e,p=i,g=s,b=t+h*i,m=e+o*s,w=t+(h+d)*i,y=e+(o+c)*s;break;case 180:A=R._rescale,u=t+i,f=e,p=-i,g=s,b=t+(1-o-c)*i,m=e+h*s,w=t+(1-o)*i,y=e+(h+d)*s;break;case 270:A=R._rescaleAndSwap,u=t+i,f=e+s,p=-i,g=-s,b=t+(1-h-d)*i,m=e+(1-o-c)*s,w=t+(1-h)*i,y=e+(1-o)*s;break}for(const{line:v,points:C}of this.#s)r.push(A(v,u,f,p,g,n?new Array(v.length):null)),a.push(A(C,u,f,p,g,n?new Array(C.length):null));return{lines:r,points:a,rect:[b,m,w,y]}}static deserialize(t,e,i,s,n,{paths:{lines:r,points:a},rotation:o,thickness:h}){const c=[];let d,u,f,p,g;switch(o){case 0:g=R._rescale,d=-t/i,u=e/s+1,f=1/i,p=-1/s;break;case 90:g=R._rescaleAndSwap,d=-e/s,u=-t/i,f=1/s,p=1/i;break;case 180:g=R._rescale,d=t/i+1,u=-e/s,f=-1/i,p=1/s;break;case 270:g=R._rescaleAndSwap,d=e/s+1,u=t/i+1,f=-1/s,p=-1/i;break}if(!r){r=[];for(const m of a){const w=m.length;if(w===2){r.push(new Float32Array([NaN,NaN,NaN,NaN,m[0],m[1]]));continue}if(w===4){r.push(new Float32Array([NaN,NaN,NaN,NaN,m[0],m[1],NaN,NaN,NaN,NaN,m[2],m[3]]));continue}const y=new Float32Array(3*(w-2));r.push(y);let[A,v,C,x]=m.subarray(0,4);y.set([NaN,NaN,NaN,NaN,A,v],0);for(let T=4;T<w;T+=2){const _=m[T],S=m[T+1];y.set(R.createBezierPoints(A,v,C,x,_,S),(T-2)*3),[A,v,C,x]=[C,x,_,S]}}}for(let m=0,w=r.length;m<w;m++)c.push({line:g(r[m].map(y=>y??NaN),d,u,f,p),points:g(a[m].map(y=>y??NaN),d,u,f,p)});const b=new ti;return b.build(c,i,s,1,o,h,n),b}#h(t=this.#c){const e=this.#i+t/2*this.#a;return this.#l%180===0?[e/this.#r,e/this.#n]:[e/this.#n,e/this.#r]}#u(){const[t,e,i,s]=this.#t,[n,r]=this.#h(0);return[t+n,e+r,i-2*n,s-2*r]}#d(){const t=this.#t=new Float32Array([1/0,1/0,-1/0,-1/0]);for(const{line:s}of this.#s){if(s.length<=12){for(let a=4,o=s.length;a<o;a+=6){const[h,c]=s.subarray(a,a+2);t[0]=Math.min(t[0],h),t[1]=Math.min(t[1],c),t[2]=Math.max(t[2],h),t[3]=Math.max(t[3],c)}continue}let n=s[4],r=s[5];for(let a=6,o=s.length;a<o;a+=6){const[h,c,d,u,f,p]=s.subarray(a,a+6);M.bezierBoundingBox(n,r,h,c,d,u,f,p,t),n=f,r=p}}const[e,i]=this.#h();t[0]=Math.min(1,Math.max(0,t[0]-e)),t[1]=Math.min(1,Math.max(0,t[1]-i)),t[2]=Math.min(1,Math.max(0,t[2]+e)),t[3]=Math.min(1,Math.max(0,t[3]+i)),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#t}updateProperty(t,e){return t==="stroke-width"?this.#f(e):null}#f(t){const[e,i]=this.#h();this.#c=t;const[s,n]=this.#h(),[r,a]=[s-e,n-i],o=this.#t;return o[0]-=r,o[1]-=a,o[2]+=2*r,o[3]+=2*a,o}updateParentDimensions([t,e],i){const[s,n]=this.#h();this.#r=t,this.#n=e,this.#a=i;const[r,a]=this.#h(),o=r-s,h=a-n,c=this.#t;return c[0]-=o,c[1]-=h,c[2]+=2*o,c[3]+=2*h,c}updateRotation(t){return this.#e=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#t.map(R.svgRound).join(" ")}get defaultProperties(){const[t,e]=this.#t;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${R.svgRound(t)} ${R.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=this.#t;let i=0,s=0,n=0,r=0,a=0,o=0;switch(this.#e){case 90:s=e/t,n=-t/e,a=t;break;case 180:i=-1,r=-1,a=t,o=e;break;case 270:s=-e/t,n=t/e,o=e;break;default:return""}return`matrix(${i} ${s} ${n} ${r} ${R.svgRound(a)} ${R.svgRound(o)})`}getPathResizingSVGProperties([t,e,i,s]){const[n,r]=this.#h(),[a,o,h,c]=this.#t;if(Math.abs(h-n)<=R.PRECISION||Math.abs(c-r)<=R.PRECISION){const g=t+i/2-(a+h/2),b=e+s/2-(o+c/2);return{path:{"transform-origin":`${R.svgRound(t)} ${R.svgRound(e)}`,transform:`${this.rotationTransform} translate(${g} ${b})`}}}const d=(i-2*n)/(h-2*n),u=(s-2*r)/(c-2*r),f=h/i,p=c/s;return{path:{"transform-origin":`${R.svgRound(a)} ${R.svgRound(o)}`,transform:`${this.rotationTransform} scale(${f} ${p}) translate(${R.svgRound(n)} ${R.svgRound(r)}) scale(${d} ${u}) translate(${R.svgRound(-n)} ${R.svgRound(-r)})`}}}getPathResizedSVGProperties([t,e,i,s]){const[n,r]=this.#h(),a=this.#t,[o,h,c,d]=a;if(a[0]=t,a[1]=e,a[2]=i,a[3]=s,Math.abs(c-n)<=R.PRECISION||Math.abs(d-r)<=R.PRECISION){const b=t+i/2-(o+c/2),m=e+s/2-(h+d/2);for(const{line:w,points:y}of this.#s)R._translate(w,b,m,w),R._translate(y,b,m,y);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${R.svgRound(t)} ${R.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const u=(i-2*n)/(c-2*n),f=(s-2*r)/(d-2*r),p=-u*(o+n)+t+n,g=-f*(h+r)+e+r;if(u!==1||f!==1||p!==0||g!==0)for(const{line:b,points:m}of this.#s)R._rescale(b,p,g,u,f,b),R._rescale(m,p,g,u,f,m);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${R.svgRound(t)} ${R.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],i){const[s,n]=i,r=this.#t,a=t-r[0],o=e-r[1];if(this.#r===s&&this.#n===n)for(const{line:h,points:c}of this.#s)R._translate(h,a,o,h),R._translate(c,a,o,c);else{const h=this.#r/s,c=this.#n/n;this.#r=s,this.#n=n;for(const{line:d,points:u}of this.#s)R._rescale(d,a,o,h,c,d),R._rescale(u,a,o,h,c,u);r[2]*=h,r[3]*=c}return r[0]=t,r[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${R.svgRound(t)} ${R.svgRound(e)}`}}}get defaultSVGProperties(){const t=this.#t;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${R.svgRound(t[0])} ${R.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class qi extends ja{#t;constructor(t){super(),this.#t=t,super.updateProperties({fill:"none",stroke:D._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){t==="stroke-width"&&(e??=this["stroke-width"],e*=this.#t.realScale),super.updateSVGProperty(t,e)}clone(){const t=new qi(this.#t);return t.updateAll(this),t}}class Yi extends N{static _type="ink";static _editorType=B.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0}static initialize(t,e){D.initialize(t,e),this._defaultDrawingOptions=new qi(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return H(this,"typesMap",new Map([[V.INK_THICKNESS,"stroke-width"],[V.INK_COLOR,"stroke"],[V.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,i,s,n){return new Ha(t,e,i,s,n,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,i,s,n,r){return ti.deserialize(t,e,i,s,n,r)}static async deserialize(t,e,i){let s=null;if(t instanceof Xi){const{data:{inkLists:r,rect:a,rotation:o,id:h,color:c,opacity:d,borderStyle:{rawWidth:u},popupRef:f},parent:{page:{pageNumber:p}}}=t;s=t={annotationType:B.INK,color:Array.from(c),thickness:u,opacity:d,paths:{points:r},boxes:null,pageIndex:p-1,rect:a.slice(0),rotation:o,id:h,deleted:!1,popupRef:f}}const n=await super.deserialize(t,e,i);return n.annotationElementId=t.id||null,n._initialData=s,n}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:t,_drawingOptions:e,parent:i}=this;e.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){const t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:t,thickness:e,opacity:i}){this._drawingOptions=Yi.getDefaultDrawingOptions({stroke:M.makeHexColor(...t),"stroke-width":e,"stroke-opacity":i})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:e,points:i,rect:s}=this.serializeDraw(t),{_drawingOptions:{stroke:n,"stroke-opacity":r,"stroke-width":a}}=this,o={annotationType:B.INK,color:D._colorManager.convert(n),opacity:r,thickness:a,paths:{lines:e,points:i},pageIndex:this.pageIndex,rect:s,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?o:this.annotationElementId&&!this.#t(o)?null:(o.id=this.annotationElementId,o)}#t(t){const{color:e,thickness:i,opacity:s,pageIndex:n}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||t.color.some((r,a)=>r!==e[a])||t.thickness!==i||t.opacity!==s||t.pageIndex!==n}renderAnnotationElement(t){const{points:e,rect:i}=this.serializeDraw(!1);return t.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:e}),null}}class Ki extends D{#t=null;#e=null;#i=null;#s=null;#r=null;#n="";#a=null;#l=null;#c=!1;#h=!1;static _type="stamp";static _editorType=B.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#s=t.bitmapUrl,this.#r=t.bitmapFile}static initialize(t,e){D.initialize(t,e)}static get supportedTypes(){return H(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(e=>`image/${e}`))}static get supportedTypesStr(){return H(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,e){e.pasteEditor(B.STAMP,{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){const e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#u(t,e=!1){if(!t){this.remove();return}this.#t=t.bitmap,e||(this.#e=t.id,this.#c=t.isSvg),t.file&&(this.#n=t.file.name),this.#o()}#d(){if(this.#i=null,this._uiManager.enableWaiting(!1),!!this.#a){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#t){this._editToolbar.hide(),this._uiManager.editAltText(this,!0);return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#t){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}async mlGuessAltText(t=null,e=!0){if(this.hasAltTextData())return null;const{mlManager:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!await i.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:s,width:n,height:r}=t||this.copyCanvas(null,null,!0).imageData,a=await i.guess({name:"altText",request:{data:s,width:n,height:r,channels:s.length/(n*r)}});if(!a)throw new Error("No response from the AI service.");if(a.error)throw new Error("Error from the AI service.");if(a.cancel)return null;if(!a.output)throw new Error("No valid response from the AI service.");const o=a.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}#f(){if(this.#e){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#e).then(i=>this.#u(i,!0)).finally(()=>this.#d());return}if(this.#s){const i=this.#s;this.#s=null,this._uiManager.enableWaiting(!0),this.#i=this._uiManager.imageManager.getFromUrl(i).then(s=>this.#u(s)).finally(()=>this.#d());return}if(this.#r){const i=this.#r;this.#r=null,this._uiManager.enableWaiting(!0),this.#i=this._uiManager.imageManager.getFromFile(i).then(s=>this.#u(s)).finally(()=>this.#d());return}const t=document.createElement("input");t.type="file",t.accept=Ki.supportedTypesStr;const e=this._uiManager._signal;this.#i=new Promise(i=>{t.addEventListener("change",async()=>{if(!t.files||t.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const s=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#u(s)}i()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),i()},{signal:e})}).finally(()=>this.#d()),t.click()}remove(){this.#e&&(this.#t=null,this._uiManager.imageManager.deleteId(this.#e),this.#a?.remove(),this.#a=null,this.#l&&(clearTimeout(this.#l),this.#l=null)),super.remove()}rebuild(){if(!this.parent){this.#e&&this.#f();return}super.rebuild(),this.div!==null&&(this.#e&&this.#a===null&&this.#f(),this.isAttachedToDOM||this.parent.add(this))}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#i||this.#t||this.#s||this.#r||this.#e)}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;if(this.width&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),this.#t?this.#o():this.#f(),this.width&&!this.annotationElementId){const[i,s]=this.parentDimensions;this.setAt(t*i,e*s,this.width*i,this.height*s)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;this.#l!==null&&clearTimeout(this.#l);const t=200;this.#l=setTimeout(()=>{this.#l=null,this.#m()},t)}#o(){const{div:t}=this;let{width:e,height:i}=this.#t;const[s,n]=this.pageDimensions,r=.75;if(this.width)e=this.width*s,i=this.height*n;else if(e>r*s||i>r*n){const c=Math.min(r*s/e,r*n/i);e*=c,i*=c}const[a,o]=this.parentDimensions;this.setDims(e*a/s,i*o/n),this._uiManager.enableWaiting(!1);const h=this.#a=document.createElement("canvas");h.setAttribute("role","img"),this.addContainer(h),this.width=e/s,this.height=i/n,this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(t.hidden=!1),this.#m(),this.#h||(this.parent.addUndoableEditor(this),this.#h=!0),this._reportTelemetry({action:"inserted_image"}),this.#n&&h.setAttribute("aria-label",this.#n)}copyCanvas(t,e,i=!1){t||(t=224);const{width:s,height:n}=this.#t,r=new _i;let a=this.#t,o=s,h=n,c=null;if(e){if(s>e||n>e){const C=Math.min(e/s,e/n);o=Math.floor(s*C),h=Math.floor(n*C)}c=document.createElement("canvas");const u=c.width=Math.ceil(o*r.sx),f=c.height=Math.ceil(h*r.sy);this.#c||(a=this.#p(u,f));const p=c.getContext("2d");p.filter=this._uiManager.hcmFilter;let g="white",b="#cfcfd8";this._uiManager.hcmFilter!=="none"?b="black":window.matchMedia?.("(prefers-color-scheme: dark)").matches&&(g="#8f8f9d",b="#42414d");const m=15,w=m*r.sx,y=m*r.sy,A=new OffscreenCanvas(w*2,y*2),v=A.getContext("2d");v.fillStyle=g,v.fillRect(0,0,w*2,y*2),v.fillStyle=b,v.fillRect(0,0,w,y),v.fillRect(w,y,w,y),p.fillStyle=p.createPattern(A,"repeat"),p.fillRect(0,0,u,f),p.drawImage(a,0,0,a.width,a.height,0,0,u,f)}let d=null;if(i){let u,f;if(r.symmetric&&a.width<t&&a.height<t)u=a.width,f=a.height;else if(a=this.#t,s>t||n>t){const b=Math.min(t/s,t/n);u=Math.floor(s*b),f=Math.floor(n*b),this.#c||(a=this.#p(u,f))}const g=new OffscreenCanvas(u,f).getContext("2d",{willReadFrequently:!0});g.drawImage(a,0,0,a.width,a.height,0,0,u,f),d={width:u,height:f,data:g.getImageData(0,0,u,f).data}}return{canvas:c,width:o,height:h,imageData:d}}#p(t,e){const{width:i,height:s}=this.#t;let n=i,r=s,a=this.#t;for(;n>2*t||r>2*e;){const o=n,h=r;n>2*t&&(n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2)),r>2*e&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2));const c=new OffscreenCanvas(n,r);c.getContext("2d").drawImage(a,0,0,o,h,0,0,n,r),a=c.transferToImageBitmap()}return a}#m(){const[t,e]=this.parentDimensions,{width:i,height:s}=this,n=new _i,r=Math.ceil(i*t*n.sx),a=Math.ceil(s*e*n.sy),o=this.#a;if(!o||o.width===r&&o.height===a)return;o.width=r,o.height=a;const h=this.#c?this.#t:this.#p(r,a),c=o.getContext("2d");c.filter=this._uiManager.hcmFilter,c.drawImage(h,0,0,h.width,h.height,0,0,r,a)}getImageForAltText(){return this.#a}#g(t){if(t){if(this.#c){const s=this._uiManager.imageManager.getSvgUrl(this.#e);if(s)return s}const e=document.createElement("canvas");return{width:e.width,height:e.height}=this.#t,e.getContext("2d").drawImage(this.#t,0,0),e.toDataURL()}if(this.#c){const[e,i]=this.pageDimensions,s=Math.round(this.width*e*ne.PDF_TO_CSS_UNITS),n=Math.round(this.height*i*ne.PDF_TO_CSS_UNITS),r=new OffscreenCanvas(s,n);return r.getContext("2d").drawImage(this.#t,0,0,this.#t.width,this.#t.height,0,0,s,n),r.transferToImageBitmap()}return structuredClone(this.#t)}static async deserialize(t,e,i){let s=null;if(t instanceof Pn){const{data:{rect:p,rotation:g,id:b,structParent:m,popupRef:w},container:y,parent:{page:{pageNumber:A}}}=t,v=y.querySelector("canvas"),C=i.imageManager.getFromCanvas(y.id,v);v.remove();const x=(await e._structTree.getAriaAttributes(`${Fi}${b}`))?.get("aria-label")||"";s=t={annotationType:B.STAMP,bitmapId:C.id,bitmap:C.bitmap,pageIndex:A-1,rect:p.slice(0),rotation:g,id:b,deleted:!1,accessibilityData:{decorative:!1,altText:x},isSvg:!1,structParent:m,popupRef:w}}const n=await super.deserialize(t,e,i),{rect:r,bitmap:a,bitmapUrl:o,bitmapId:h,isSvg:c,accessibilityData:d}=t;h&&i.imageManager.isValidId(h)?(n.#e=h,a&&(n.#t=a)):n.#s=o,n.#c=c;const[u,f]=n.pageDimensions;return n.width=(r[2]-r[0])/u,n.height=(r[3]-r[1])/f,n.annotationElementId=t.id||null,d&&(n.altTextData=d),n._initialData=s,n.#h=!!s,n}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i={annotationType:B.STAMP,bitmapId:this.#e,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#c,structTreeParentId:this._structTreeParentId};if(t)return i.bitmapUrl=this.#g(!0),i.accessibilityData=this.serializeAltText(!0),i;const{decorative:s,altText:n}=this.serializeAltText(!1);if(!s&&n&&(i.accessibilityData={type:"Figure",alt:n}),this.annotationElementId){const a=this.#b(i);if(a.isSame)return null;a.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1}if(i.id=this.annotationElementId,e===null)return i;e.stamps||=new Map;const r=this.#c?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(!e.stamps.has(this.#e))e.stamps.set(this.#e,{area:r,serialized:i}),i.bitmap=this.#g(!1);else if(this.#c){const a=e.stamps.get(this.#e);r>a.area&&(a.area=r,a.serialized.bitmap.close(),a.serialized.bitmap=this.#g(!1))}return i}#b(t){const{pageIndex:e,accessibilityData:{altText:i}}=this._initialData,s=t.pageIndex===e,n=(t.accessibilityData?.alt||"")===i;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&s&&n,isSameAltText:n}}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}}let Va=class jt{#t;#e=!1;#i=null;#s=null;#r=null;#n=new Map;#a=!1;#l=!1;#c=!1;#h=null;#u=null;#d=null;#f=null;#o;static _initialized=!1;static#p=new Map([st,Yi,Ki,Y].map(t=>[t._editorType,t]));constructor({uiManager:t,pageIndex:e,div:i,structTreeLayer:s,accessibilityManager:n,annotationLayer:r,drawLayer:a,textLayer:o,viewport:h,l10n:c}){const d=[...jt.#p.values()];if(!jt._initialized){jt._initialized=!0;for(const u of d)u.initialize(c,t)}t.registerEditorTypes(d),this.#o=t,this.pageIndex=e,this.div=i,this.#t=n,this.#i=r,this.viewport=h,this.#d=o,this.drawLayer=a,this._structTree=s,this.#o.addLayer(this)}get isEmpty(){return this.#n.size===0}get isInvisible(){return this.isEmpty&&this.#o.getMode()===B.NONE}updateToolbar(t){this.#o.updateToolbar(t)}updateMode(t=this.#o.getMode()){switch(this.#w(),t){case B.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case B.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case B.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;for(const i of jt.#p.values())e.toggle(`${i._type}Editing`,t===i._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#d?.div}setEditingState(t){this.#o.setEditingState(t)}addCommands(t){this.#o.addCommands(t)}cleanUndoStack(t){this.#o.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#i?.div.classList.toggle("disabled",!t)}async enable(){this.#c=!0,this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const i of this.#n.values())i.enableEditing(),i.show(!0),i.annotationElementId&&(this.#o.removeChangedExistingAnnotation(i),t.add(i.annotationElementId));if(!this.#i){this.#c=!1;return}const e=this.#i.getEditableAnnotations();for(const i of e){if(i.hide(),this.#o.isDeletedAnnotationElement(i.data.id)||t.has(i.data.id))continue;const s=await this.deserialize(i);s&&(this.addOrRebuild(s),s.enableEditing())}this.#c=!1}disable(){this.#l=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);const t=new Map,e=new Map;for(const s of this.#n.values())if(s.disableEditing(),!!s.annotationElementId){if(s.serialize()!==null){t.set(s.annotationElementId,s);continue}else e.set(s.annotationElementId,s);this.getEditableAnnotation(s.annotationElementId)?.show(),s.remove()}if(this.#i){const s=this.#i.getEditableAnnotations();for(const n of s){const{id:r}=n.data;if(this.#o.isDeletedAnnotationElement(r))continue;let a=e.get(r);if(a){a.resetAnnotationElement(n),a.show(!1),n.show();continue}a=t.get(r),a&&(this.#o.addChangedExistingAnnotation(a),a.renderAnnotationElement(n)&&a.show(!1)),n.show()}}this.#w(),this.isEmpty&&(this.div.hidden=!0);const{classList:i}=this.div;for(const s of jt.#p.values())i.remove(`${s._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#l=!1}getEditableAnnotation(t){return this.#i?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#o.getActive()!==t&&this.#o.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#d?.div&&!this.#f){this.#f=new AbortController;const t=this.#o.combinedSignal(this.#f);this.#d.div.addEventListener("pointerdown",this.#m.bind(this),{signal:t}),this.#d.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#d?.div&&this.#f&&(this.#f.abort(),this.#f=null,this.#d.div.classList.remove("highlighting"))}#m(t){this.#o.unselectAll();const{target:e}=t;if(e===this.#d.div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent"))&&this.#d.div.contains(e)){const{isMac:i}=ct.platform;if(t.button!==0||t.ctrlKey&&i)return;this.#o.showAllEditors("highlight",!0,!0),this.#d.div.classList.add("free"),this.toggleDrawing(),Y.startHighlighting(this,this.#o.direction==="ltr",{target:this.#d.div,x:t.x,y:t.y}),this.#d.div.addEventListener("pointerup",()=>{this.#d.div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:this.#o._signal}),t.preventDefault()}}enableClick(){if(this.#s)return;this.#s=new AbortController;const t=this.#o.combinedSignal(this.#s);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){this.#s?.abort(),this.#s=null}attach(t){this.#n.set(t.id,t);const{annotationElementId:e}=t;e&&this.#o.isDeletedAnnotationElement(e)&&this.#o.removeDeletedAnnotationElement(t)}detach(t){this.#n.delete(t.id),this.#t?.removePointerInTextLayer(t.contentDiv),!this.#l&&t.annotationElementId&&this.#o.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#o.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#o.addDeletedAnnotationElement(t.annotationElementId),D.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),t.parent?.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(!(t.parent===this&&t.isAttachedToDOM)){if(this.changeParent(t),this.#o.addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#c),this.#o.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!this.#r&&(t._focusEventsAllowed=!1,this.#r=setTimeout(()=>{this.#r=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#o._signal}),e.focus())},0)),t._structTreeParentId=this.#t?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){const e=()=>t._uiManager.rebuild(t),i=()=>{t.remove()};this.addCommands({cmd:e,undo:i,mustExec:!1})}getNextId(){return this.#o.getId()}get#g(){return jt.#p.get(this.#o.getMode())}combinedSignal(t){return this.#o.combinedSignal(t)}#b(t){const e=this.#g;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#g?.canCreateNewEmptyEditor()}pasteEditor(t,e){this.#o.updateToolbar(t),this.#o.updateMode(t);const{offsetX:i,offsetY:s}=this.#y(),n=this.getNextId(),r=this.#b({parent:this,id:n,x:i,y:s,uiManager:this.#o,isCentered:!0,...e});r&&this.add(r)}async deserialize(t){return await jt.#p.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#o)||null}createAndAddNewEditor(t,e,i={}){const s=this.getNextId(),n=this.#b({parent:this,id:s,x:t.offsetX,y:t.offsetY,uiManager:this.#o,isCentered:e,...i});return n&&this.add(n),n}#y(){const{x:t,y:e,width:i,height:s}=this.div.getBoundingClientRect(),n=Math.max(0,t),r=Math.max(0,e),a=Math.min(window.innerWidth,t+i),o=Math.min(window.innerHeight,e+s),h=(n+a)/2-t,c=(r+o)/2-e,[d,u]=this.viewport.rotation%180===0?[h,c]:[c,h];return{offsetX:d,offsetY:u}}addNewEditor(){this.createAndAddNewEditor(this.#y(),!0)}setSelected(t){this.#o.setSelected(t)}toggleSelected(t){this.#o.toggleSelected(t)}unselect(t){this.#o.unselect(t)}pointerup(t){const{isMac:e}=ct.platform;if(!(t.button!==0||t.ctrlKey&&e)&&t.target===this.div&&this.#a&&(this.#a=!1,!(this.#g?.isDrawer&&this.#g.supportMultipleDrawings))){if(!this.#e){this.#e=!0;return}if(this.#o.getMode()===B.STAMP){this.#o.unselectAll();return}this.createAndAddNewEditor(t,!1)}}pointerdown(t){if(this.#o.getMode()===B.HIGHLIGHT&&this.enableTextSelection(),this.#a){this.#a=!1;return}const{isMac:e}=ct.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(this.#a=!0,this.#g?.isDrawer){this.startDrawingSession(t);return}const i=this.#o.getActive();this.#e=!i||i.isEmpty()}startDrawingSession(t){if(this.div.focus(),this.#h){this.#g.startDrawing(this,this.#o,!1,t);return}this.#o.setCurrentDrawingSession(this),this.#h=new AbortController;const e=this.#o.combinedSignal(this.#h);this.div.addEventListener("blur",({relatedTarget:i})=>{i&&!this.div.contains(i)&&(this.#u=null,this.commitOrRemove())},{signal:e}),this.#g.startDrawing(this,this.#o,!1,t)}pause(t){if(t){const{activeElement:e}=document;this.div.contains(e)&&(this.#u=e);return}this.#u&&setTimeout(()=>{this.#u?.focus(),this.#u=null},0)}endDrawingSession(t=!1){return this.#h?(this.#o.setCurrentDrawingSession(null),this.#h.abort(),this.#h=null,this.#u=null,this.#g.endDrawing(t)):null}findNewParent(t,e,i){const s=this.#o.findParent(e,i);return s===null||s===this?!1:(s.changeParent(t),!0)}commitOrRemove(){return this.#h?(this.endDrawingSession(),!0):!1}onScaleChanging(){this.#h&&this.#g.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#o.getActive()?.parent===this&&(this.#o.commitOrRemove(),this.#o.setActiveEditor(null)),this.#r&&(clearTimeout(this.#r),this.#r=null);for(const t of this.#n.values())this.#t?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#n.clear(),this.#o.removeLayer(this)}#w(){for(const t of this.#n.values())t.isEmpty()&&t.remove()}render({viewport:t}){this.viewport=t,qt(this.div,t);for(const e of this.#o.getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){this.#o.commitOrRemove(),this.#w();const e=this.viewport.rotation,i=t.rotation;if(this.viewport=t,qt(this.div,{rotation:i}),e!==i)for(const s of this.#n.values())s.rotate(i)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#o.viewParameters.realScale}},$a=class pt{#t=null;#e=0;#i=new Map;#s=new Map;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(!this.#t){this.#t=t;return}if(this.#t!==t){if(this.#i.size>0)for(const e of this.#i.values())e.remove(),t.append(e);this.#t=t}}static get _svgFactory(){return H(this,"_svgFactory",new Gi)}static#r(t,[e,i,s,n]){const{style:r}=t;r.top=`${100*i}%`,r.left=`${100*e}%`,r.width=`${100*s}%`,r.height=`${100*n}%`}#n(){const t=pt._svgFactory.create(1,1,!0);return this.#t.append(t),t.setAttribute("aria-hidden",!0),t}#a(t,e){const i=pt._svgFactory.createElement("clipPath");t.append(i);const s=`clip_${e}`;i.setAttribute("id",s),i.setAttribute("clipPathUnits","objectBoundingBox");const n=pt._svgFactory.createElement("use");return i.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),s}#l(t,e){for(const[i,s]of Object.entries(e))s===null?t.removeAttribute(i):t.setAttribute(i,s)}draw(t,e=!1,i=!1){const s=this.#e++,n=this.#n(),r=pt._svgFactory.createElement("defs");n.append(r);const a=pt._svgFactory.createElement("path");r.append(a);const o=`path_p${this.pageIndex}_${s}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),e&&this.#s.set(s,a);const h=i?this.#a(r,o):null,c=pt._svgFactory.createElement("use");return n.append(c),c.setAttribute("href",`#${o}`),this.updateProperties(n,t),this.#i.set(s,n),{id:s,clipPathId:`url(#${h})`}}drawOutline(t,e){const i=this.#e++,s=this.#n(),n=pt._svgFactory.createElement("defs");s.append(n);const r=pt._svgFactory.createElement("path");n.append(r);const a=`path_p${this.pageIndex}_${i}`;r.setAttribute("id",a),r.setAttribute("vector-effect","non-scaling-stroke");let o;if(e){const d=pt._svgFactory.createElement("mask");n.append(d),o=`mask_p${this.pageIndex}_${i}`,d.setAttribute("id",o),d.setAttribute("maskUnits","objectBoundingBox");const u=pt._svgFactory.createElement("rect");d.append(u),u.setAttribute("width","1"),u.setAttribute("height","1"),u.setAttribute("fill","white");const f=pt._svgFactory.createElement("use");d.append(f),f.setAttribute("href",`#${a}`),f.setAttribute("stroke","none"),f.setAttribute("fill","black"),f.setAttribute("fill-rule","nonzero"),f.classList.add("mask")}const h=pt._svgFactory.createElement("use");s.append(h),h.setAttribute("href",`#${a}`),o&&h.setAttribute("mask",`url(#${o})`);const c=h.cloneNode();return s.append(c),h.classList.add("mainOutline"),c.classList.add("secondaryOutline"),this.updateProperties(s,t),this.#i.set(i,s),i}finalizeDraw(t,e){this.#s.delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;const{root:i,bbox:s,rootClass:n,path:r}=e,a=typeof t=="number"?this.#i.get(t):t;if(a){if(i&&this.#l(a,i),s&&pt.#r(a,s),n){const{classList:o}=a;for(const[h,c]of Object.entries(n))o.toggle(h,c)}if(r){const h=a.firstChild.firstChild;this.#l(h,r)}}}updateParent(t,e){if(e===this)return;const i=this.#i.get(t);i&&(e.#t.append(i),this.#i.delete(t),e.#i.set(t,i))}remove(t){this.#s.delete(t),this.#t!==null&&(this.#i.get(t).remove(),this.#i.delete(t))}destroy(){this.#t=null;for(const t of this.#i.values())t.remove();this.#i.clear(),this.#s.clear()}};globalThis.pdfjsTestingUtils={HighlightOutliner:Ci};F.AbortException;F.AnnotationEditorLayer;F.AnnotationEditorParamsType;F.AnnotationEditorType;F.AnnotationEditorUIManager;F.AnnotationLayer;F.AnnotationMode;F.ColorPicker;F.DOMSVGFactory;F.DrawLayer;F.FeatureTest;var Fh=F.GlobalWorkerOptions;F.ImageKind;F.InvalidPDFException;F.MissingPDFException;F.OPS;F.OutputScale;F.PDFDataRangeTransport;F.PDFDateString;F.PDFWorker;F.PasswordResponses;F.PermissionFlag;F.PixelsPerInch;F.RenderingCancelledException;F.TextLayer;F.TouchManager;F.UnexpectedResponseException;F.Util;F.VerbosityLevel;F.XfaLayer;F.build;F.createValidAbsoluteUrl;F.fetchData;var Oh=F.getDocument;F.getFilenameFromUrl;F.getPdfFilenameFromUrl;F.getXfaPageViewport;F.isDataScheme;F.isPdfFile;F.noContextMenu;F.normalizeUnicode;F.setLayerDimensions;F.shadow;F.stopEvent;F.version;var be={};be.d=(l,t)=>{for(var e in t)be.o(t,e)&&!be.o(l,e)&&Object.defineProperty(l,e,{enumerable:!0,get:t[e]})};be.o=(l,t)=>Object.prototype.hasOwnProperty.call(l,t);var X=globalThis.pdfjsViewer={};be.d(X,{AnnotationLayerBuilder:()=>Mn,DownloadManager:()=>Bo,EventBus:()=>kn,FindState:()=>Ht,GenericL10n:()=>Ot,LinkTarget:()=>Wt,PDFFindController:()=>So,PDFHistory:()=>Dl,PDFLinkService:()=>ii,PDFPageView:()=>jn,PDFScriptingManager:()=>ql,PDFSinglePageViewer:()=>Zl,PDFViewer:()=>Hn,ProgressBar:()=>to,RenderingStates:()=>q,ScrollMode:()=>U,SimpleLinkService:()=>Qi,SpreadMode:()=>at,StructTreeLayerBuilder:()=>On,TextLayerBuilder:()=>se,XfaLayerBuilder:()=>Bn,parseQueryString:()=>ei});const Ua="auto",Ln=1,ys=1.1,za=.1,Wa=10,di=0,Ga=1.25,ws=40,As=5,q={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3},ie={UNKNOWN:0,NORMAL:1,CHANGING:2,FULLSCREEN:3},It={DISABLE:0,ENABLE:1,ENABLE_PERMISSIONS:2},U={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2,PAGE:3},at={UNKNOWN:-1,NONE:0,ODD:1,EVEN:2};function Rn(l,t,e=!1){let i=l.offsetParent;if(!i){console.error("offsetParent is not set -- cannot scroll");return}let s=l.offsetTop+l.clientTop,n=l.offsetLeft+l.clientLeft;for(;i.clientHeight===i.scrollHeight&&i.clientWidth===i.scrollWidth||e&&(i.classList.contains("markedContent")||getComputedStyle(i).overflow==="hidden");)if(s+=i.offsetTop,n+=i.offsetLeft,i=i.offsetParent,!i)return;t&&(t.top!==void 0&&(s+=t.top),t.left!==void 0&&(n+=t.left,i.scrollLeft=n)),i.scrollTop=s}function Xa(l,t,e=void 0){const i=function(r){n||(n=window.requestAnimationFrame(function(){n=null;const o=l.scrollLeft,h=s.lastX;o!==h&&(s.right=o>h),s.lastX=o;const c=l.scrollTop,d=s.lastY;c!==d&&(s.down=c>d),s.lastY=c,t(s)}))},s={right:!0,down:!0,lastX:l.scrollLeft,lastY:l.scrollTop,_eventHandler:i};let n=null;return l.addEventListener("scroll",i,{useCapture:!0,signal:e}),e?.addEventListener("abort",()=>window.cancelAnimationFrame(n),{once:!0}),s}function ei(l){const t=new Map;for(const[e,i]of new URLSearchParams(l))t.set(e.toLowerCase(),i);return t}const _s=/[\x00-\x1F]/g;function ye(l,t=!1){return _s.test(l)?t?l.replaceAll(_s,e=>e==="\0"?"":" "):l.replaceAll("\0",""):l}function Se(l,t,e=0){let i=e,s=l.length-1;if(s<0||!t(l[s]))return l.length;if(t(l[i]))return i;for(;i<s;){const n=i+s>>1,r=l[n];t(r)?s=n:i=n+1}return i}function vs(l){if(Math.floor(l)===l)return[l,1];const t=1/l,e=8;if(t>e)return[1,e];if(Math.floor(t)===t)return[1,t];const i=l>1?t:l;let s=0,n=1,r=1,a=1;for(;;){const h=s+r,c=n+a;if(c>e)break;i<=h/c?(r=h,a=c):(s=h,n=c)}let o;return i-s/n<r/a-i?o=i===l?[s,n]:[n,s]:o=i===l?[r,a]:[a,r],o}function ke(l,t){return l-l%t}function qa(l,t,e){if(l<2)return l;let i=t[l].div,s=i.offsetTop+i.clientTop;s>=e&&(i=t[l-1].div,s=i.offsetTop+i.clientTop);for(let n=l-2;n>=0&&(i=t[n].div,!(i.offsetTop+i.clientTop+i.clientHeight<=s));--n)l=n;return l}function Ya({scrollEl:l,views:t,sortByVisibility:e=!1,horizontal:i=!1,rtl:s=!1}){const n=l.scrollTop,r=n+l.clientHeight,a=l.scrollLeft,o=a+l.clientWidth;function h(w){const y=w.div;return y.offsetTop+y.clientTop+y.clientHeight>n}function c(w){const y=w.div,A=y.offsetLeft+y.clientLeft,v=A+y.clientWidth;return s?A<o:v>a}const d=[],u=new Set,f=t.length;let p=Se(t,i?c:h);p>0&&p<f&&!i&&(p=qa(p,t,n));let g=i?o:-1;for(let w=p;w<f;w++){const y=t[w],A=y.div,v=A.offsetLeft+A.clientLeft,C=A.offsetTop+A.clientTop,x=A.clientWidth,T=A.clientHeight,_=v+x,S=C+T;if(g===-1)S>=r&&(g=S);else if((i?v:C)>g)break;if(S<=n||C>=r||_<=a||v>=o)continue;const P=Math.max(0,n-C)+Math.max(0,S-r),I=Math.max(0,a-v)+Math.max(0,_-o),$=(T-P)/T,O=(x-I)/x,tt=$*O*100|0;d.push({id:y.id,x:v,y:C,view:y,percent:tt,widthPercent:O*100|0}),u.add(y.id)}const b=d[0],m=d.at(-1);return e&&d.sort(function(w,y){const A=w.percent-y.percent;return Math.abs(A)>.001?-A:w.id-y.id}),{first:b,last:m,views:d,ids:u}}function In(l){return Number.isInteger(l)&&l%90===0}function Ka(l){return Number.isInteger(l)&&Object.values(U).includes(l)&&l!==U.UNKNOWN}function Qa(l){return Number.isInteger(l)&&Object.values(at).includes(l)&&l!==at.UNKNOWN}function Es(l){return l.width<=l.height}new Promise(function(l){window.requestAnimationFrame(l)});const Za=document.documentElement.style;function Ja(l,t,e){return Math.min(Math.max(l,t),e)}class to{#t=null;#e=null;#i=0;#s=null;#r=!0;constructor(t){this.#t=t.classList,this.#s=t.style}get percent(){return this.#i}set percent(t){if(this.#i=Ja(t,0,100),isNaN(t)){this.#t.add("indeterminate");return}this.#t.remove("indeterminate"),this.#s.setProperty("--progressBar-percent",`${this.#i}%`)}setWidth(t){if(!t)return;const i=t.parentNode.offsetWidth-t.offsetWidth;i>0&&this.#s.setProperty("--progressBar-end-offset",`${i}px`)}setDisableAutoFetch(t=5e3){this.#i===100||isNaN(this.#i)||(this.#e&&clearTimeout(this.#e),this.show(),this.#e=setTimeout(()=>{this.#e=null,this.hide()},t))}hide(){this.#r&&(this.#r=!1,this.#t.add("hidden"))}show(){this.#r||(this.#r=!0,this.#t.remove("hidden"))}}function eo(l){let t=U.VERTICAL,e=at.NONE;switch(l){case"SinglePage":t=U.PAGE;break;case"OneColumn":break;case"TwoPageLeft":t=U.PAGE;case"TwoColumnLeft":e=at.ODD;break;case"TwoPageRight":t=U.PAGE;case"TwoColumnRight":e=at.EVEN;break}return{scrollMode:t,spreadMode:e}}const Ne=function(){const l=document.createElement("div");return l.style.width="round(down, calc(1.6666666666666665 * 792px), 1px)",l.style.width==="calc(1320px)"?Math.fround:t=>t}(),Et={SPACE:0,ALPHA_LETTER:1,PUNCT:2,HAN_LETTER:3,KATAKANA_LETTER:4,HIRAGANA_LETTER:5,HALFWIDTH_KATAKANA_LETTER:6,THAI_LETTER:7};function io(l){return l<11904}function so(l){return(l&65408)===0}function no(l){return l>=97&&l<=122||l>=65&&l<=90}function ro(l){return l>=48&&l<=57}function ao(l){return l===32||l===9||l===13||l===10}function oo(l){return l>=13312&&l<=40959||l>=63744&&l<=64255}function lo(l){return l>=12448&&l<=12543}function ho(l){return l>=12352&&l<=12447}function co(l){return l>=65376&&l<=65439}function uo(l){return(l&65408)===3584}function De(l){return io(l)?so(l)?ao(l)?Et.SPACE:no(l)||ro(l)||l===95?Et.ALPHA_LETTER:Et.PUNCT:uo(l)?Et.THAI_LETTER:l===160?Et.SPACE:Et.ALPHA_LETTER:oo(l)?Et.HAN_LETTER:lo(l)?Et.KATAKANA_LETTER:ho(l)?Et.HIRAGANA_LETTER:co(l)?Et.HALFWIDTH_KATAKANA_LETTER:Et.ALPHA_LETTER}let Ss;function fo(){return Ss||=" ¨ª¯²-µ¸-º¼-¾IJ-ijĿ-ŀʼnſDŽ-njDZ-dzʰ-ʸ˘-˝ˠ-ˤʹͺ;΄-΅·ϐ-ϖϰ-ϲϴ-ϵϹևٵ-ٸक़-य़ড়-ঢ়য়ਲ਼ਸ਼ਖ਼-ਜ਼ਫ਼ଡ଼-ଢ଼ำຳໜ-ໝ༌གྷཌྷདྷབྷཛྷཀྵჼᴬ-ᴮᴰ-ᴺᴼ-ᵍᵏ-ᵪᵸᶛ-ᶿẚ-ẛάέήίόύώΆ᾽-῁ΈΉ῍-῏ΐΊ῝-῟ΰΎ῭-`ΌΏ´-῾ - ‑‗․-… ″-‴‶-‷‼‾⁇-⁉⁗ ⁰-ⁱ⁴-₎ₐ-ₜ₨℀-℃℅-ℇ℉-ℓℕ-№ℙ-ℝ℠-™ℤΩℨK-ℭℯ-ℱℳ-ℹ℻-⅀ⅅ-ⅉ⅐-ⅿ↉∬-∭∯-∰〈-〉①-⓪⨌⩴-⩶⫝̸ⱼ-ⱽⵯ⺟⻳⼀-⿕ 〶〸-〺゛-゜ゟヿㄱ-ㆎ㆒-㆟㈀-㈞㈠-㉇㉐-㉾㊀-㏿ꚜ-ꚝꝰꟲ-ꟴꟸ-ꟹꭜ-ꭟꭩ豈-嗀塚晴凞-羽蘒諸逸-都飯-舘並-龎ff-stﬓ-ﬗיִײַ-זּטּ-לּמּנּ-סּףּ-פּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-﷼︐-︙︰-﹄﹇-﹒﹔-﹦﹨-﹫ﹰ-ﹲﹴﹶ-ﻼ!-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ¢-₩",Ss}const Ht={FOUND:0,NOT_FOUND:1,WRAPPED:2,PENDING:3},po=250,go=-50,mo=-400,xs={"‐":"-","‘":"'","’":"'","‚":"'","‛":"'","“":'"',"”":'"',"„":'"',"‟":'"',"¼":"1/4","½":"1/2","¾":"3/4"},Ps=new Set([12441,12442,2381,2509,2637,2765,2893,3021,3149,3277,3387,3388,3405,3530,3642,3770,3972,4153,4154,5908,5940,6098,6752,6980,7082,7083,7154,7155,11647,43014,43052,43204,43347,43456,43766,44013,3158,3953,3954,3962,3963,3964,3965,3968,3956]);let Cs;const bo=/\p{M}+/gu,yo=/([.*+?^${}()|[\]\\])|(\p{P})|(\s+)|(\p{M})|(\p{L})/gu,wo=/([^\p{M}])\p{M}*$/u,Ao=/^\p{M}*([^\p{M}])/u,_o=/[\uAC00-\uD7AF\uFA6C\uFACF-\uFAD1\uFAD5-\uFAD7]+/g,Ts=new Map,vo="[\\u1100-\\u1112\\ud7a4-\\ud7af\\ud84a\\ud84c\\ud850\\ud854\\ud857\\ud85f]",Ls=new Map;let ui=null,fi=null;function pi(l){const t=[];let e;for(;(e=_o.exec(l))!==null;){let{index:g}=e;for(const b of e[0]){let m=Ts.get(b);m||(m=b.normalize("NFD").length,Ts.set(b,m)),t.push([m,g++])}}let i;if(t.length===0&&ui)i=ui;else if(t.length>0&&fi)i=fi;else{const g=Object.keys(xs).join(""),b=fo(),A=`([${g}])|([${b}])|((?:゙|゚)\\n)|(\\p{M}+(?:-\\n)?)|(\\p{Ll}-\\n\\p{Lu})|(\\S-\\n)|((?:\\p{Ideographic}|[-ヿ])\\n)|(\\n)`;t.length===0?i=ui=new RegExp(A+"|(\\u0000)","gum"):i=fi=new RegExp(A+`|(${vo})`,"gum")}const s=[];for(;(e=bo.exec(l))!==null;)s.push([e[0].length,e.index]);let n=l.normalize("NFD");const r=[0,0];let a=0,o=0,h=0,c=0,d=0,u=!1;n=n.replace(i,(g,b,m,w,y,A,v,C,x,T,_)=>{if(_-=c,b){const S=xs[b],P=S.length;for(let I=1;I<P;I++)r.push(_-h+I,h-I);return h-=P-1,S}if(m){let S=Ls.get(m);S||(S=m.normalize("NFKC"),Ls.set(m,S));const P=S.length;for(let I=1;I<P;I++)r.push(_-h+I,h-I);return h-=P-1,S}if(w)return u=!0,_+d===s[a]?.[1]?++a:(r.push(_-1-h+1,h-1),h-=1,c+=1),r.push(_-h+1,h),c+=1,d+=1,w.charAt(0);if(y){const S=y.endsWith(`
|
|
13
|
+
`),P=S?y.length-2:y.length;u=!0;let I=P;_+d===s[a]?.[1]&&(I-=s[a][0],++a);for(let $=1;$<=I;$++)r.push(_-1-h+$,h-$);return h-=I,c+=I,S?(_+=P-1,r.push(_-h+1,1+h),h+=1,c+=1,d+=1,y.slice(0,P)):y}if(A)return c+=1,d+=1,A.replace(`
|
|
14
|
+
`,"");if(v){const S=v.length-2;return r.push(_-h+S,1+h),h+=1,c+=1,d+=1,v.slice(0,-2)}if(C){const S=C.length-1;return r.push(_-h+S,h),c+=1,d+=1,C.slice(0,-1)}if(x)return r.push(_-h+1,h-1),h-=1,c+=1,d+=1," ";if(_+d===t[o]?.[1]){const S=t[o][0]-1;++o;for(let P=1;P<=S;P++)r.push(_-(h-P),h-P);h-=S,c+=S}return T}),r.push(n.length,h);const f=new Uint32Array(r.length>>1),p=new Int32Array(r.length>>1);for(let g=0,b=r.length;g<b;g+=2)f[g>>1]=r[g],p[g>>1]=r[g+1];return[n,[f,p],u]}function Eo(l,t,e){if(!l)return[t,e];const[i,s]=l,n=t,r=t+e-1;let a=Se(i,u=>u>=n);i[a]>n&&--a;let o=Se(i,u=>u>=r,a);i[o]>r&&--o;const h=n+s[a],d=r+s[o]+1-h;return[h,d]}class So{#t=null;#e=!0;#i=0;constructor({linkService:t,eventBus:e,updateMatchesCountOnProgress:i=!0}){this._linkService=t,this._eventBus=e,this.#e=i,this.onIsPageVisible=null,this.#r(),e._on("find",this.#s.bind(this)),e._on("findbarclose",this.#y.bind(this))}get highlightMatches(){return this._highlightMatches}get pageMatches(){return this._pageMatches}get pageMatchesLength(){return this._pageMatchesLength}get selected(){return this._selected}get state(){return this.#t}setDocument(t){this._pdfDocument&&this.#r(),t&&(this._pdfDocument=t,this._firstPageCapability.resolve())}#s(t){if(!t)return;const e=this._pdfDocument,{type:i}=t;(this.#t===null||this.#a(t))&&(this._dirtyMatch=!0),this.#t=t,i!=="highlightallchange"&&this.#v(Ht.PENDING),this._firstPageCapability.promise.then(()=>{if(!this._pdfDocument||e&&this._pdfDocument!==e)return;this.#u();const s=!this._highlightMatches,n=!!this._findTimeout;this._findTimeout&&(clearTimeout(this._findTimeout),this._findTimeout=null),i?this._dirtyMatch?this.#o():i==="again"?(this.#o(),s&&this.#t.highlightAll&&this.#f()):i==="highlightallchange"?(n?this.#o():this._highlightMatches=!0,this.#f()):this.#o():this._findTimeout=setTimeout(()=>{this.#o(),this._findTimeout=null},po)})}scrollMatchIntoView({element:t=null,selectedLeft:e=0,pageIndex:i=-1,matchIndex:s=-1}){if(!this._scrollMatches||!t)return;if(s===-1||s!==this._selected.matchIdx)return;if(i===-1||i!==this._selected.pageIdx)return;this._scrollMatches=!1;const n={top:go,left:e+mo};Rn(t,n,!0)}#r(){this._highlightMatches=!1,this._scrollMatches=!1,this._pdfDocument=null,this._pageMatches=[],this._pageMatchesLength=[],this.#i=0,this.#t=null,this._selected={pageIdx:-1,matchIdx:-1},this._offset={pageIdx:null,matchIdx:null,wrapped:!1},this._extractTextPromises=[],this._pageContents=[],this._pageDiffs=[],this._hasDiacritics=[],this._matchesCountTotal=0,this._pagesToSearch=null,this._pendingFindMatches=new Set,this._resumePageIdx=null,this._dirtyMatch=!1,clearTimeout(this._findTimeout),this._findTimeout=null,this._firstPageCapability=Promise.withResolvers()}get#n(){const{query:t}=this.#t;return typeof t=="string"?(t!==this._rawQuery&&(this._rawQuery=t,[this._normalizedQuery]=pi(t)),this._normalizedQuery):(t||[]).filter(e=>!!e).map(e=>pi(e)[0])}#a(t){const e=t.query,i=this.#t.query,s=typeof e;if(s!==typeof i)return!0;if(s==="string"){if(e!==i)return!0}else if(JSON.stringify(e)!==JSON.stringify(i))return!0;switch(t.type){case"again":const r=this._selected.pageIdx+1,a=this._linkService;return r>=1&&r<=a.pagesCount&&r!==a.page&&!(this.onIsPageVisible?.(r)??!0);case"highlightallchange":return!1}return!0}#l(t,e,i){let s=t.slice(0,e).match(wo);if(s){const n=t.charCodeAt(e),r=s[1].charCodeAt(0);if(De(n)===De(r))return!1}if(s=t.slice(e+i).match(Ao),s){const n=t.charCodeAt(e+i-1),r=s[1].charCodeAt(0);if(De(n)===De(r))return!1}return!0}#c(t,e){const{matchDiacritics:i}=this.#t;let s=!1;t=t.replaceAll(yo,(r,a,o,h,c,d)=>a?`[ ]*\\${a}[ ]*`:o?`[ ]*${o}[ ]*`:h?"[ ]+":i?c||d:c?Ps.has(c.charCodeAt(0))?c:"":e?(s=!0,`${d}\\p{M}*`):d);const n="[ ]*";return t.endsWith(n)&&(t=t.slice(0,t.length-n.length)),i&&e&&(Cs||=String.fromCharCode(...Ps),s=!0,t=`${t}(?=[${Cs}]|[^\\p{M}]|$)`),[s,t]}#h(t){const e=this.#n;if(e.length===0)return;const i=this._pageContents[t],s=this.match(e,i,t),n=this._pageMatches[t]=[],r=this._pageMatchesLength[t]=[],a=this._pageDiffs[t];s?.forEach(({index:h,length:c})=>{const[d,u]=Eo(a,h,c);u&&(n.push(d),r.push(u))}),this.#t.highlightAll&&this.#d(t),this._resumePageIdx===t&&(this._resumePageIdx=null,this.#m());const o=n.length;this._matchesCountTotal+=o,this.#e?o>0&&this.#A():++this.#i===this._linkService.pagesCount&&this.#A()}match(t,e,i){const s=this._hasDiacritics[i];let n=!1;if(typeof t=="string"?[n,t]=this.#c(t,s):t=t.sort().reverse().map(d=>{const[u,f]=this.#c(d,s);return n||=u,`(${f})`}).join("|"),!t)return;const{caseSensitive:r,entireWord:a}=this.#t,o=`g${n?"u":""}${r?"":"i"}`;t=new RegExp(t,o);const h=[];let c;for(;(c=t.exec(e))!==null;)a&&!this.#l(e,c.index,c[0].length)||h.push({index:c.index,length:c[0].length});return h}#u(){if(this._extractTextPromises.length>0)return;let t=Promise.resolve();const e={disableNormalization:!0};for(let i=0,s=this._linkService.pagesCount;i<s;i++){const{promise:n,resolve:r}=Promise.withResolvers();this._extractTextPromises[i]=n,t=t.then(()=>this._pdfDocument.getPage(i+1).then(a=>a.getTextContent(e)).then(a=>{const o=[];for(const h of a.items)o.push(h.str),h.hasEOL&&o.push(`
|
|
15
|
+
`);[this._pageContents[i],this._pageDiffs[i],this._hasDiacritics[i]]=pi(o.join("")),r()},a=>{console.error(`Unable to get text content for page ${i+1}`,a),this._pageContents[i]="",this._pageDiffs[i]=null,this._hasDiacritics[i]=!1,r()}))}}#d(t){this._scrollMatches&&this._selected.pageIdx===t&&(this._linkService.page=t+1),this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:t})}#f(){this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:-1})}#o(){const t=this.#t.findPrevious,e=this._linkService.page-1,i=this._linkService.pagesCount;if(this._highlightMatches=!0,this._dirtyMatch){this._dirtyMatch=!1,this._selected.pageIdx=this._selected.matchIdx=-1,this._offset.pageIdx=e,this._offset.matchIdx=null,this._offset.wrapped=!1,this._resumePageIdx=null,this._pageMatches.length=0,this._pageMatchesLength.length=0,this.#i=0,this._matchesCountTotal=0,this.#f();for(let r=0;r<i;r++)this._pendingFindMatches.has(r)||(this._pendingFindMatches.add(r),this._extractTextPromises[r].then(()=>{this._pendingFindMatches.delete(r),this.#h(r)}))}if(this.#n.length===0){this.#v(Ht.FOUND);return}if(this._resumePageIdx)return;const n=this._offset;if(this._pagesToSearch=i,n.matchIdx!==null){const r=this._pageMatches[n.pageIdx].length;if(!t&&n.matchIdx+1<r||t&&n.matchIdx>0){n.matchIdx=t?n.matchIdx-1:n.matchIdx+1,this.#b(!0);return}this.#g(t)}this.#m()}#p(t){const e=this._offset,i=t.length,s=this.#t.findPrevious;return i?(e.matchIdx=s?i-1:0,this.#b(!0),!0):(this.#g(s),e.wrapped&&(e.matchIdx=null,this._pagesToSearch<0)?(this.#b(!1),!0):!1)}#m(){this._resumePageIdx!==null&&console.error("There can only be one pending page.");let t=null;do{const e=this._offset.pageIdx;if(t=this._pageMatches[e],!t){this._resumePageIdx=e;break}}while(!this.#p(t))}#g(t){const e=this._offset,i=this._linkService.pagesCount;e.pageIdx=t?e.pageIdx-1:e.pageIdx+1,e.matchIdx=null,this._pagesToSearch--,(e.pageIdx>=i||e.pageIdx<0)&&(e.pageIdx=t?i-1:0,e.wrapped=!0)}#b(t=!1){let e=Ht.NOT_FOUND;const i=this._offset.wrapped;if(this._offset.wrapped=!1,t){const s=this._selected.pageIdx;this._selected.pageIdx=this._offset.pageIdx,this._selected.matchIdx=this._offset.matchIdx,e=i?Ht.WRAPPED:Ht.FOUND,s!==-1&&s!==this._selected.pageIdx&&this.#d(s)}this.#v(e,this.#t.findPrevious),this._selected.pageIdx!==-1&&(this._scrollMatches=!0,this.#d(this._selected.pageIdx))}#y(t){const e=this._pdfDocument;this._firstPageCapability.promise.then(()=>{!this._pdfDocument||e&&this._pdfDocument!==e||(this._findTimeout&&(clearTimeout(this._findTimeout),this._findTimeout=null),this._resumePageIdx&&(this._resumePageIdx=null,this._dirtyMatch=!0),this.#v(Ht.FOUND),this._highlightMatches=!1,this.#f())})}#w(){const{pageIdx:t,matchIdx:e}=this._selected;let i=0,s=this._matchesCountTotal;if(e!==-1){for(let n=0;n<t;n++)i+=this._pageMatches[n]?.length||0;i+=e+1}return(i<1||i>s)&&(i=s=0),{current:i,total:s}}#A(){this._eventBus.dispatch("updatefindmatchescount",{source:this,matchesCount:this.#w()})}#v(t,e=!1){!this.#e&&(this.#i!==this._linkService.pagesCount||t===Ht.PENDING)||this._eventBus.dispatch("updatefindcontrolstate",{source:this,state:t,previous:e,entireWord:this.#t?.entireWord??null,matchesCount:this.#w(),rawQuery:this.#t?.query??null})}}const xo="noopener noreferrer nofollow",Wt={NONE:0,SELF:1,BLANK:2,PARENT:3,TOP:4};class ii{externalLinkEnabled=!0;constructor({eventBus:t,externalLinkTarget:e=null,externalLinkRel:i=null,ignoreDestinationZoom:s=!1}={}){this.eventBus=t,this.externalLinkTarget=e,this.externalLinkRel=i,this._ignoreDestinationZoom=s,this.baseUrl=null,this.pdfDocument=null,this.pdfViewer=null,this.pdfHistory=null}setDocument(t,e=null){this.baseUrl=e,this.pdfDocument=t}setViewer(t){this.pdfViewer=t}setHistory(t){this.pdfHistory=t}get pagesCount(){return this.pdfDocument?this.pdfDocument.numPages:0}get page(){return this.pdfDocument?this.pdfViewer.currentPageNumber:1}set page(t){this.pdfDocument&&(this.pdfViewer.currentPageNumber=t)}get rotation(){return this.pdfDocument?this.pdfViewer.pagesRotation:0}set rotation(t){this.pdfDocument&&(this.pdfViewer.pagesRotation=t)}get isInPresentationMode(){return this.pdfDocument?this.pdfViewer.isInPresentationMode:!1}async goToDestination(t){if(!this.pdfDocument)return;let e,i,s;if(typeof t=="string"?(e=t,i=await this.pdfDocument.getDestination(t)):(e=null,i=await t),!Array.isArray(i)){console.error(`goToDestination: "${i}" is not a valid destination array, for dest="${t}".`);return}const[n]=i;if(n&&typeof n=="object"){if(s=this.pdfDocument.cachedPageNumber(n),!s)try{s=await this.pdfDocument.getPageIndex(n)+1}catch{console.error(`goToDestination: "${n}" is not a valid page reference, for dest="${t}".`);return}}else Number.isInteger(n)&&(s=n+1);if(!s||s<1||s>this.pagesCount){console.error(`goToDestination: "${s}" is not a valid page number, for dest="${t}".`);return}this.pdfHistory&&(this.pdfHistory.pushCurrentPosition(),this.pdfHistory.push({namedDest:e,explicitDest:i,pageNumber:s})),this.pdfViewer.scrollPageIntoView({pageNumber:s,destArray:i,ignoreDestinationZoom:this._ignoreDestinationZoom})}goToPage(t){if(!this.pdfDocument)return;const e=typeof t=="string"&&this.pdfViewer.pageLabelToPageNumber(t)||t|0;if(!(Number.isInteger(e)&&e>0&&e<=this.pagesCount)){console.error(`PDFLinkService.goToPage: "${t}" is not a valid page.`);return}this.pdfHistory&&(this.pdfHistory.pushCurrentPosition(),this.pdfHistory.pushPage(e)),this.pdfViewer.scrollPageIntoView({pageNumber:e})}addLinkAttributes(t,e,i=!1){if(!e||typeof e!="string")throw new Error('A valid "url" parameter must provided.');const s=i?Wt.BLANK:this.externalLinkTarget,n=this.externalLinkRel;this.externalLinkEnabled?t.href=t.title=e:(t.href="",t.title=`Disabled: ${e}`,t.onclick=()=>!1);let r="";switch(s){case Wt.NONE:break;case Wt.SELF:r="_self";break;case Wt.BLANK:r="_blank";break;case Wt.PARENT:r="_parent";break;case Wt.TOP:r="_top";break}t.target=r,t.rel=typeof n=="string"?n:xo}getDestinationHash(t){if(typeof t=="string"){if(t.length>0)return this.getAnchorUrl("#"+escape(t))}else if(Array.isArray(t)){const e=JSON.stringify(t);if(e.length>0)return this.getAnchorUrl("#"+escape(e))}return this.getAnchorUrl("")}getAnchorUrl(t){return this.baseUrl?this.baseUrl+t:t}setHash(t){if(!this.pdfDocument)return;let e,i;if(t.includes("=")){const s=ei(t);if(s.has("search")){const n=s.get("search").replaceAll('"',""),r=s.get("phrase")==="true";this.eventBus.dispatch("findfromurlhash",{source:this,query:r?n:n.match(/\S+/g)})}if(s.has("page")&&(e=s.get("page")|0||1),s.has("zoom")){const n=s.get("zoom").split(","),r=n[0],a=parseFloat(r);r.includes("Fit")?r==="Fit"||r==="FitB"?i=[null,{name:r}]:r==="FitH"||r==="FitBH"||r==="FitV"||r==="FitBV"?i=[null,{name:r},n.length>1?n[1]|0:null]:r==="FitR"?n.length!==5?console.error('PDFLinkService.setHash: Not enough parameters for "FitR".'):i=[null,{name:r},n[1]|0,n[2]|0,n[3]|0,n[4]|0]:console.error(`PDFLinkService.setHash: "${r}" is not a valid zoom value.`):i=[null,{name:"XYZ"},n.length>1?n[1]|0:null,n.length>2?n[2]|0:null,a?a/100:r]}i?this.pdfViewer.scrollPageIntoView({pageNumber:e||this.page,destArray:i,allowNegativeOffset:!0}):e&&(this.page=e),s.has("pagemode")&&this.eventBus.dispatch("pagemode",{source:this,mode:s.get("pagemode")}),s.has("nameddest")&&this.goToDestination(s.get("nameddest"));return}i=unescape(t);try{i=JSON.parse(i),Array.isArray(i)||(i=i.toString())}catch{}if(typeof i=="string"||ii.#t(i)){this.goToDestination(i);return}console.error(`PDFLinkService.setHash: "${unescape(t)}" is not a valid destination.`)}executeNamedAction(t){if(this.pdfDocument){switch(t){case"GoBack":this.pdfHistory?.back();break;case"GoForward":this.pdfHistory?.forward();break;case"NextPage":this.pdfViewer.nextPage();break;case"PrevPage":this.pdfViewer.previousPage();break;case"LastPage":this.page=this.pagesCount;break;case"FirstPage":this.page=1;break}this.eventBus.dispatch("namedaction",{source:this,action:t})}}async executeSetOCGState(t){if(!this.pdfDocument)return;const e=this.pdfDocument,i=await this.pdfViewer.optionalContentConfigPromise;e===this.pdfDocument&&(i.setOCGState(t),this.pdfViewer.optionalContentConfigPromise=Promise.resolve(i))}static#t(t){if(!Array.isArray(t)||t.length<2)return!1;const[e,i,...s]=t;if(!(typeof e=="object"&&Number.isInteger(e?.num)&&Number.isInteger(e?.gen))&&!Number.isInteger(e)||!(typeof i=="object"&&typeof i?.name=="string"))return!1;const n=s.length;let r=!0;switch(i.name){case"XYZ":if(n<2||n>3)return!1;break;case"Fit":case"FitB":return n===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(n>1)return!1;break;case"FitR":if(n!==4)return!1;r=!1;break;default:return!1}for(const a of s)if(!(typeof a=="number"||r&&a===null))return!1;return!0}}class Qi extends ii{setDocument(t,e=null){}}const{AbortException:Po,AnnotationEditorLayer:Co,AnnotationEditorParamsType:Bh,AnnotationEditorType:bt,AnnotationEditorUIManager:To,AnnotationLayer:Lo,AnnotationMode:Ft,build:jh,ColorPicker:Hh,createValidAbsoluteUrl:Ro,DOMSVGFactory:Vh,DrawLayer:Io,FeatureTest:$h,fetchData:Rs,getDocument:Uh,getFilenameFromUrl:zh,getPdfFilenameFromUrl:Mo,getXfaPageViewport:Wh,GlobalWorkerOptions:Gh,ImageKind:Xh,InvalidPDFException:qh,isDataScheme:Yh,isPdfFile:ko,MissingPDFException:Kh,noContextMenu:Qh,normalizeUnicode:No,OPS:Zh,OutputScale:Do,PasswordResponses:Jh,PDFDataRangeTransport:tc,PDFDateString:ec,PDFWorker:ic,PermissionFlag:Fe,PixelsPerInch:Dt,RenderingCancelledException:Li,setLayerDimensions:Fo,shadow:Ue,stopEvent:Ri,TextLayer:Oo,TouchManager:sc,UnexpectedResponseException:nc,Util:rc,VerbosityLevel:ac,version:Is,XfaLayer:gi}=globalThis.pdfjsLib;class Mn{#t=null;#e=null;constructor({pdfPage:t,linkService:e,downloadManager:i,annotationStorage:s=null,imageResourcesPath:n="",renderForms:r=!0,enableScripting:a=!1,hasJSActionsPromise:o=null,fieldObjectsPromise:h=null,annotationCanvasMap:c=null,accessibilityManager:d=null,annotationEditorUIManager:u=null,onAppend:f=null}){this.pdfPage=t,this.linkService=e,this.downloadManager=i,this.imageResourcesPath=n,this.renderForms=r,this.annotationStorage=s,this.enableScripting=a,this._hasJSActionsPromise=o||Promise.resolve(!1),this._fieldObjectsPromise=h||Promise.resolve(null),this._annotationCanvasMap=c,this._accessibilityManager=d,this._annotationEditorUIManager=u,this.#t=f,this.annotationLayer=null,this.div=null,this._cancelled=!1,this._eventBus=e.eventBus}async render(t,e,i="display"){if(this.div){if(this._cancelled||!this.annotationLayer)return;this.annotationLayer.update({viewport:t.clone({dontFlip:!0})});return}const[s,n,r]=await Promise.all([this.pdfPage.getAnnotations({intent:i}),this._hasJSActionsPromise,this._fieldObjectsPromise]);if(this._cancelled)return;const a=this.div=document.createElement("div");if(a.className="annotationLayer",this.#t?.(a),s.length===0){this.hide();return}this.annotationLayer=new Lo({div:a,accessibilityManager:this._accessibilityManager,annotationCanvasMap:this._annotationCanvasMap,annotationEditorUIManager:this._annotationEditorUIManager,page:this.pdfPage,viewport:t.clone({dontFlip:!0}),structTreeLayer:e?.structTreeLayer||null}),await this.annotationLayer.render({annotations:s,imageResourcesPath:this.imageResourcesPath,renderForms:this.renderForms,linkService:this.linkService,downloadManager:this.downloadManager,annotationStorage:this.annotationStorage,enableScripting:this.enableScripting,hasJSActions:n,fieldObjects:r}),this.linkService.isInPresentationMode&&this.#i(ie.FULLSCREEN),this.#e||(this.#e=new AbortController,this._eventBus?._on("presentationmodechanged",o=>{this.#i(o.state)},{signal:this.#e.signal}))}cancel(){this._cancelled=!0,this.#e?.abort(),this.#e=null}hide(){this.div&&(this.div.hidden=!0)}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}#i(t){if(!this.div)return;let e=!1;switch(t){case ie.FULLSCREEN:e=!0;break;case ie.NORMAL:break;default:return}for(const i of this.div.childNodes)i.hasAttribute("data-internal-link")||(i.inert=e)}}function Ms(l,t){const e=document.createElement("a");if(!e.click)throw new Error('DownloadManager: "a.click()" is not supported.');e.href=l,e.target="_parent","download"in e&&(e.download=t),(document.body||document.documentElement).append(e),e.click(),e.remove()}class Bo{#t=new WeakMap;downloadData(t,e,i){const s=URL.createObjectURL(new Blob([t],{type:i}));Ms(s,e)}openOrDownloadData(t,e,i=null){const n=ko(e)?"application/pdf":"";return this.downloadData(t,e,n),!1}download(t,e,i){let s;if(t)s=URL.createObjectURL(new Blob([t],{type:"application/pdf"}));else{if(!Ro(e,"http://example.com")){console.error(`download - not a valid URL: ${e}`);return}s=e+"#pdfjs.action=download"}Ms(s,i)}}const ks={EVENT:"event",TIMEOUT:"timeout"};async function jo({target:l,name:t,delay:e=0}){if(typeof l!="object"||!(Number.isInteger(e)&&e>=0))throw new Error("waitOnEventOrTimeout - invalid parameters.");const{promise:i,resolve:s}=Promise.withResolvers(),n=new AbortController;function r(h){n.abort(),clearTimeout(o),s(h)}const a=l instanceof kn?"_on":"addEventListener";l[a](t,r.bind(null,ks.EVENT),{signal:n.signal});const o=setTimeout(r.bind(null,ks.TIMEOUT),e);return i}class kn{#t=Object.create(null);on(t,e,i=null){this._on(t,e,{external:!0,once:i?.once,signal:i?.signal})}off(t,e,i=null){this._off(t,e)}dispatch(t,e){const i=this.#t[t];if(!i||i.length===0)return;let s;for(const{listener:n,external:r,once:a}of i.slice(0)){if(a&&this._off(t,n),r){(s||=[]).push(n);continue}n(e)}if(s){for(const n of s)n(e);s=null}}_on(t,e,i=null){let s=null;if(i?.signal instanceof AbortSignal){const{signal:r}=i;if(r.aborted){console.error("Cannot use an `aborted` signal.");return}const a=()=>this._off(t,e);s=()=>r.removeEventListener("abort",a),r.addEventListener("abort",a)}(this.#t[t]||=[]).push({listener:e,external:i?.external===!0,once:i?.once===!0,rmAbort:s})}_off(t,e,i=null){const s=this.#t[t];if(s)for(let n=0,r=s.length;n<r;n++){const a=s[n];if(a.listener===e){a.rmAbort?.(),s.splice(n,1);return}}}}class si{constructor(t){this.value=t}valueOf(){return this.value}}class J extends si{constructor(t="???"){super(t)}toString(t){return`{${this.value}}`}}class Bt extends si{constructor(t,e={}){super(t),this.opts=e}toString(t){try{return t.memoizeIntlObject(Intl.NumberFormat,this.opts).format(this.value)}catch(e){return t.reportError(e),this.value.toString(10)}}}class we extends si{constructor(t,e={}){super(t),this.opts=e}toString(t){try{return t.memoizeIntlObject(Intl.DateTimeFormat,this.opts).format(this.value)}catch(e){return t.reportError(e),new Date(this.value).toISOString()}}}const Ns=100,Ho="",Vo="";function $o(l,t,e){if(e===t||e instanceof Bt&&t instanceof Bt&&e.value===t.value)return!0;if(t instanceof Bt&&typeof e=="string"){let i=l.memoizeIntlObject(Intl.PluralRules,t.opts).select(t.value);if(e===i)return!0}return!1}function Ds(l,t,e){return t[e]?re(l,t[e].value):(l.reportError(new RangeError("No default")),new J)}function Ii(l,t){const e=[],i=Object.create(null);for(const s of t)s.type==="narg"?i[s.name]=xe(l,s.value):e.push(xe(l,s));return{positional:e,named:i}}function xe(l,t){switch(t.type){case"str":return t.value;case"num":return new Bt(t.value,{minimumFractionDigits:t.precision});case"var":return Uo(l,t);case"mesg":return zo(l,t);case"term":return Wo(l,t);case"func":return Go(l,t);case"select":return Xo(l,t);default:return new J}}function Uo(l,{name:t}){let e;if(l.params)if(Object.prototype.hasOwnProperty.call(l.params,t))e=l.params[t];else return new J(`$${t}`);else if(l.args&&Object.prototype.hasOwnProperty.call(l.args,t))e=l.args[t];else return l.reportError(new ReferenceError(`Unknown variable: $${t}`)),new J(`$${t}`);if(e instanceof si)return e;switch(typeof e){case"string":return e;case"number":return new Bt(e);case"object":if(e instanceof Date)return new we(e.getTime());default:return l.reportError(new TypeError(`Variable type not supported: $${t}, ${typeof e}`)),new J(`$${t}`)}}function zo(l,{name:t,attr:e}){const i=l.bundle._messages.get(t);if(!i)return l.reportError(new ReferenceError(`Unknown message: ${t}`)),new J(t);if(e){const s=i.attributes[e];return s?re(l,s):(l.reportError(new ReferenceError(`Unknown attribute: ${e}`)),new J(`${t}.${e}`))}return i.value?re(l,i.value):(l.reportError(new ReferenceError(`No value: ${t}`)),new J(t))}function Wo(l,{name:t,attr:e,args:i}){const s=`-${t}`,n=l.bundle._terms.get(s);if(!n)return l.reportError(new ReferenceError(`Unknown term: ${s}`)),new J(s);if(e){const a=n.attributes[e];if(a){l.params=Ii(l,i).named;const o=re(l,a);return l.params=null,o}return l.reportError(new ReferenceError(`Unknown attribute: ${e}`)),new J(`${s}.${e}`)}l.params=Ii(l,i).named;const r=re(l,n.value);return l.params=null,r}function Go(l,{name:t,args:e}){let i=l.bundle._functions[t];if(!i)return l.reportError(new ReferenceError(`Unknown function: ${t}()`)),new J(`${t}()`);if(typeof i!="function")return l.reportError(new TypeError(`Function ${t}() is not callable`)),new J(`${t}()`);try{let s=Ii(l,e);return i(s.positional,s.named)}catch(s){return l.reportError(s),new J(`${t}()`)}}function Xo(l,{selector:t,variants:e,star:i}){let s=xe(l,t);if(s instanceof J)return Ds(l,e,i);for(const n of e){const r=xe(l,n.key);if($o(l,s,r))return re(l,n.value)}return Ds(l,e,i)}function Nn(l,t){if(l.dirty.has(t))return l.reportError(new RangeError("Cyclic reference")),new J;l.dirty.add(t);const e=[],i=l.bundle._useIsolating&&t.length>1;for(const s of t){if(typeof s=="string"){e.push(l.bundle._transform(s));continue}if(l.placeables++,l.placeables>Ns)throw l.dirty.delete(t),new RangeError(`Too many placeables expanded: ${l.placeables}, max allowed is ${Ns}`);i&&e.push(Ho),e.push(xe(l,s).toString(l)),i&&e.push(Vo)}return l.dirty.delete(t),e.join("")}function re(l,t){return typeof t=="string"?l.bundle._transform(t):Nn(l,t)}class qo{constructor(t,e,i){this.dirty=new WeakSet,this.params=null,this.placeables=0,this.bundle=t,this.errors=e,this.args=i}reportError(t){if(!this.errors||!(t instanceof Error))throw t;this.errors.push(t)}memoizeIntlObject(t,e){let i=this.bundle._intls.get(t);i||(i={},this.bundle._intls.set(t,i));let s=JSON.stringify(e);return i[s]||(i[s]=new t(this.bundle.locales,e)),i[s]}}function ze(l,t){const e=Object.create(null);for(const[i,s]of Object.entries(l))t.includes(i)&&(e[i]=s.valueOf());return e}const Fs=["unitDisplay","currencyDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits"];function Yo(l,t){let e=l[0];if(e instanceof J)return new J(`NUMBER(${e.valueOf()})`);if(e instanceof Bt)return new Bt(e.valueOf(),{...e.opts,...ze(t,Fs)});if(e instanceof we)return new Bt(e.valueOf(),{...ze(t,Fs)});throw new TypeError("Invalid argument to NUMBER")}const Os=["dateStyle","timeStyle","fractionalSecondDigits","dayPeriod","hour12","weekday","era","year","month","day","hour","minute","second","timeZoneName"];function Ko(l,t){let e=l[0];if(e instanceof J)return new J(`DATETIME(${e.valueOf()})`);if(e instanceof we)return new we(e.valueOf(),{...e.opts,...ze(t,Os)});if(e instanceof Bt)return new we(e.valueOf(),{...ze(t,Os)});throw new TypeError("Invalid argument to DATETIME")}const Bs=new Map;function Qo(l){const t=Array.isArray(l)?l.join(" "):l;let e=Bs.get(t);return e===void 0&&(e=new Map,Bs.set(t,e)),e}class Zo{constructor(t,{functions:e,useIsolating:i=!0,transform:s=n=>n}={}){this._terms=new Map,this._messages=new Map,this.locales=Array.isArray(t)?t:[t],this._functions={NUMBER:Yo,DATETIME:Ko,...e},this._useIsolating=i,this._transform=s,this._intls=Qo(t)}hasMessage(t){return this._messages.has(t)}getMessage(t){return this._messages.get(t)}addResource(t,{allowOverrides:e=!1}={}){const i=[];for(let s=0;s<t.body.length;s++){let n=t.body[s];if(n.id.startsWith("-")){if(e===!1&&this._terms.has(n.id)){i.push(new Error(`Attempt to override an existing term: "${n.id}"`));continue}this._terms.set(n.id,n)}else{if(e===!1&&this._messages.has(n.id)){i.push(new Error(`Attempt to override an existing message: "${n.id}"`));continue}this._messages.set(n.id,n)}}return i}formatPattern(t,e=null,i=null){if(typeof t=="string")return this._transform(t);let s=new qo(this,i,e);try{return Nn(s,t).toString(s)}catch(n){if(s.errors&&n instanceof Error)return s.errors.push(n),new J().toString(s);throw n}}}const mi=/^(-?[a-zA-Z][\w-]*) *= */gm,js=/\.([a-zA-Z][\w-]*) *= */y,Jo=/\*?\[/y,bi=/(-?[0-9]+(?:\.([0-9]+))?)/y,tl=/([a-zA-Z][\w-]*)/y,Hs=/([$-])?([a-zA-Z][\w-]*)(?:\.([a-zA-Z][\w-]*))?/y,el=/^[A-Z][A-Z0-9_-]*$/,Oe=/([^{}\n\r]+)/y,il=/([^\\"\n\r]*)/y,Vs=/\\([\\"])/y,$s=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{6})/y,sl=/^\n+/,Us=/ +$/,nl=/ *\r?\n/g,rl=/( *)$/,al=/{\s*/y,zs=/\s*}/y,ol=/\[\s*/y,ll=/\s*] */y,hl=/\s*\(\s*/y,cl=/\s*->\s*/y,dl=/\s*:\s*/y,ul=/\s*,?\s*/y,fl=/\s+/y;class pl{constructor(t){this.body=[],mi.lastIndex=0;let e=0;for(;;){let _=mi.exec(t);if(_===null)break;e=mi.lastIndex;try{this.body.push(o(_[1]))}catch(S){if(S instanceof SyntaxError)continue;throw S}}function i(_){return _.lastIndex=e,_.test(t)}function s(_,S){if(t[e]===_)return e++,!0;if(S)throw new S(`Expected ${_}`);return!1}function n(_,S){if(i(_))return e=_.lastIndex,!0;if(S)throw new S(`Expected ${_.toString()}`);return!1}function r(_){_.lastIndex=e;let S=_.exec(t);if(S===null)throw new SyntaxError(`Expected ${_.toString()}`);return e=_.lastIndex,S}function a(_){return r(_)[1]}function o(_){let S=c(),P=h();if(S===null&&Object.keys(P).length===0)throw new SyntaxError("Expected message value or attributes");return{id:_,value:S,attributes:P}}function h(){let _=Object.create(null);for(;i(js);){let S=a(js),P=c();if(P===null)throw new SyntaxError("Expected attribute value");_[S]=P}return _}function c(){let _;if(i(Oe)&&(_=a(Oe)),t[e]==="{"||t[e]==="}")return d(_?[_]:[],1/0);let S=C();return S?_?d([_,S],S.length):(S.value=x(S.value,sl),d([S],S.length)):_?x(_,Us):null}function d(_=[],S){for(;;){if(i(Oe)){_.push(a(Oe));continue}if(t[e]==="{"){_.push(u());continue}if(t[e]==="}")throw new SyntaxError("Unbalanced closing brace");let O=C();if(O){_.push(O),S=Math.min(S,O.length);continue}break}let P=_.length-1,I=_[P];typeof I=="string"&&(_[P]=x(I,Us));let $=[];for(let O of _)O instanceof Ws&&(O=O.value.slice(0,O.value.length-S)),O&&$.push(O);return $}function u(){n(al,SyntaxError);let _=f();if(n(zs))return _;if(n(cl)){let S=b();return n(zs,SyntaxError),{type:"select",selector:_,...S}}throw new SyntaxError("Unclosed placeable")}function f(){if(t[e]==="{")return u();if(i(Hs)){let[,_,S,P=null]=r(Hs);if(_==="$")return{type:"var",name:S};if(n(hl)){let I=p();if(_==="-")return{type:"term",name:S,attr:P,args:I};if(el.test(S))return{type:"func",name:S,args:I};throw new SyntaxError("Function names must be all upper-case")}return _==="-"?{type:"term",name:S,attr:P,args:[]}:{type:"mesg",name:S,attr:P}}return w()}function p(){let _=[];for(;;){switch(t[e]){case")":return e++,_;case void 0:throw new SyntaxError("Unclosed argument list")}_.push(g()),n(ul)}}function g(){let _=f();return _.type!=="mesg"?_:n(dl)?{type:"narg",name:_.name,value:w()}:_}function b(){let _=[],S=0,P;for(;i(Jo);){s("*")&&(P=S);let I=m(),$=c();if($===null)throw new SyntaxError("Expected variant value");_[S++]={key:I,value:$}}if(S===0)return null;if(P===void 0)throw new SyntaxError("Expected default variant");return{variants:_,star:P}}function m(){n(ol,SyntaxError);let _;return i(bi)?_=y():_={type:"str",value:a(tl)},n(ll,SyntaxError),_}function w(){if(i(bi))return y();if(t[e]==='"')return A();throw new SyntaxError("Invalid expression")}function y(){let[,_,S=""]=r(bi),P=S.length;return{type:"num",value:parseFloat(_),precision:P}}function A(){s('"',SyntaxError);let _="";for(;;){if(_+=a(il),t[e]==="\\"){_+=v();continue}if(s('"'))return{type:"str",value:_};throw new SyntaxError("Unclosed string literal")}}function v(){if(i(Vs))return a(Vs);if(i($s)){let[,_,S]=r($s),P=parseInt(_||S,16);return P<=55295||57344<=P?String.fromCodePoint(P):"�"}throw new SyntaxError("Unknown escape sequence")}function C(){let _=e;switch(n(fl),t[e]){case".":case"[":case"*":case"}":case void 0:return!1;case"{":return T(t.slice(_,e))}return t[e-1]===" "?T(t.slice(_,e)):!1}function x(_,S){return _.replace(S,"")}function T(_){let S=_.replace(nl,`
|
|
16
|
+
`),P=rl.exec(_)[1].length;return new Ws(S,P)}}}class Ws{constructor(t,e){this.value=t,this.length=e}}const gl=/<|&#?\w+;/,ml={"http://www.w3.org/1999/xhtml":["em","strong","small","s","cite","q","dfn","abbr","data","time","code","var","samp","kbd","sub","sup","i","b","u","mark","bdi","bdo","span","br","wbr"]},bl={"http://www.w3.org/1999/xhtml":{global:["title","aria-label","aria-valuetext"],a:["download"],area:["download","alt"],input:["alt","placeholder"],menuitem:["label"],menu:["label"],optgroup:["label"],option:["label"],track:["label"],img:["alt"],textarea:["placeholder"],th:["abbr"]},"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul":{global:["accesskey","aria-label","aria-valuetext","label","title","tooltiptext"],description:["value"],key:["key","keycode"],label:["value"],textbox:["placeholder","value"]}};function yl(l,t){const{value:e}=t;if(typeof e=="string")if(l.localName==="title"&&l.namespaceURI==="http://www.w3.org/1999/xhtml")l.textContent=e;else if(!gl.test(e))l.textContent=e;else{const i=l.ownerDocument.createElementNS("http://www.w3.org/1999/xhtml","template");i.innerHTML=e,wl(i.content,l)}Dn(t,l)}function wl(l,t){for(const e of l.childNodes)if(e.nodeType!==e.TEXT_NODE){if(e.hasAttribute("data-l10n-name")){const i=_l(t,e);l.replaceChild(i,e);continue}if(El(e)){const i=vl(e);l.replaceChild(i,e);continue}console.warn(`An element of forbidden type "${e.localName}" was found in the translation. Only safe text-level elements and elements with data-l10n-name are allowed.`),l.replaceChild(Mi(e),e)}t.textContent="",t.appendChild(l)}function Al(l,t){if(!l)return!1;for(let e of l)if(e.name===t)return!0;return!1}function Dn(l,t){const e=t.hasAttribute("data-l10n-attrs")?t.getAttribute("data-l10n-attrs").split(",").map(i=>i.trim()):null;for(const i of Array.from(t.attributes))Gs(i.name,t,e)&&!Al(l.attributes,i.name)&&t.removeAttribute(i.name);if(l.attributes)for(const i of Array.from(l.attributes))Gs(i.name,t,e)&&t.getAttribute(i.name)!==i.value&&t.setAttribute(i.name,i.value)}function _l(l,t){const e=t.getAttribute("data-l10n-name"),i=l.querySelector(`[data-l10n-name="${e}"]`);if(!i)return console.warn(`An element named "${e}" wasn't found in the source.`),Mi(t);if(i.localName!==t.localName)return console.warn(`An element named "${e}" was found in the translation but its type ${t.localName} didn't match the element found in the source (${i.localName}).`),Mi(t);l.removeChild(i);const s=i.cloneNode(!1);return Fn(t,s)}function vl(l){const t=l.ownerDocument.createElement(l.localName);return Fn(l,t)}function Mi(l){return l.ownerDocument.createTextNode(l.textContent)}function El(l){const t=ml[l.namespaceURI];return t&&t.includes(l.localName)}function Gs(l,t,e=null){if(e&&e.includes(l))return!0;const i=bl[t.namespaceURI];if(!i)return!1;const s=l.toLowerCase(),n=t.localName;if(i.global.includes(s))return!0;if(!i[n])return!1;if(i[n].includes(s))return!0;if(t.namespaceURI==="http://www.w3.org/1999/xhtml"&&n==="input"&&s==="value"){const r=t.type.toLowerCase();if(r==="submit"||r==="button"||r==="reset")return!0}return!1}function Fn(l,t){return t.textContent=l.textContent,Dn(l,t),t}class Sl extends Array{static from(t){return t instanceof this?t:new this(t)}}class xl extends Sl{constructor(t){if(super(),Symbol.asyncIterator in Object(t))this.iterator=t[Symbol.asyncIterator]();else if(Symbol.iterator in Object(t))this.iterator=t[Symbol.iterator]();else throw new TypeError("Argument must implement the iteration protocol.")}[Symbol.asyncIterator](){const t=this;let e=0;return{async next(){return t.length<=e&&t.push(t.iterator.next()),t[e++]}}}async touchNext(t=1){let e=0;for(;e++<t;){const i=this[this.length-1];if(i&&(await i).done)break;this.push(this.iterator.next())}return this[this.length-1]}}class Pl{constructor(t=[],e){this.resourceIds=t,this.generateBundles=e,this.onChange(!0)}addResourceIds(t,e=!1){return this.resourceIds.push(...t),this.onChange(e),this.resourceIds.length}removeResourceIds(t){return this.resourceIds=this.resourceIds.filter(e=>!t.includes(e)),this.onChange(),this.resourceIds.length}async formatWithFallback(t,e){const i=[];let s=!1;for await(const n of this.bundles){s=!0;const r=Ll(e,n,t,i);if(r.size===0)break;if(typeof console<"u"){const a=n.locales[0],o=Array.from(r).join(", ");console.warn(`[fluent] Missing translations in ${a}: ${o}`)}}return!s&&typeof console<"u"&&console.warn(`[fluent] Request for keys failed because no resource bundles got generated.
|
|
17
|
+
keys: ${JSON.stringify(t)}.
|
|
18
|
+
resourceIds: ${JSON.stringify(this.resourceIds)}.`),i}formatMessages(t){return this.formatWithFallback(t,Tl)}formatValues(t){return this.formatWithFallback(t,Cl)}async formatValue(t,e){const[i]=await this.formatValues([{id:t,args:e}]);return i}handleEvent(){this.onChange()}onChange(t=!1){this.bundles=xl.from(this.generateBundles(this.resourceIds)),t&&this.bundles.touchNext(2)}}function Cl(l,t,e,i){return e.value?l.formatPattern(e.value,i,t):null}function Tl(l,t,e,i){const s={value:null,attributes:null};e.value&&(s.value=l.formatPattern(e.value,i,t));let n=Object.keys(e.attributes);if(n.length>0){s.attributes=new Array(n.length);for(let[r,a]of n.entries()){let o=l.formatPattern(e.attributes[a],i,t);s.attributes[r]={name:a,value:o}}}return s}function Ll(l,t,e,i){const s=[],n=new Set;return e.forEach(({id:r,args:a},o)=>{if(i[o]!==void 0)return;let h=t.getMessage(r);if(h){if(s.length=0,i[o]=l(t,s,h,a),s.length>0&&typeof console<"u"){const c=t.locales[0],d=s.join(", ");console.warn(`[fluent][resolver] errors in ${c}/${r}: ${d}.`)}}else n.add(r)}),n}const Gt="data-l10n-id",de="data-l10n-args",Rl=`[${Gt}]`;class Il extends Pl{constructor(t,e){super(t,e),this.roots=new Set,this.pendingrAF=null,this.pendingElements=new Set,this.windowElement=null,this.mutationObserver=null,this.observerConfig={attributes:!0,characterData:!1,childList:!0,subtree:!0,attributeFilter:[Gt,de]}}onChange(t=!1){super.onChange(t),this.roots&&this.translateRoots()}setAttributes(t,e,i){return t.setAttribute(Gt,e),i?t.setAttribute(de,JSON.stringify(i)):t.removeAttribute(de),t}getAttributes(t){return{id:t.getAttribute(Gt),args:JSON.parse(t.getAttribute(de)||null)}}connectRoot(t){for(const e of this.roots)if(e===t||e.contains(t)||t.contains(e))throw new Error("Cannot add a root that overlaps with existing root.");if(this.windowElement){if(this.windowElement!==t.ownerDocument.defaultView)throw new Error(`Cannot connect a root:
|
|
19
|
+
DOMLocalization already has a root from a different window.`)}else this.windowElement=t.ownerDocument.defaultView,this.mutationObserver=new this.windowElement.MutationObserver(e=>this.translateMutations(e));this.roots.add(t),this.mutationObserver.observe(t,this.observerConfig)}disconnectRoot(t){return this.roots.delete(t),this.pauseObserving(),this.roots.size===0?(this.mutationObserver=null,this.windowElement&&this.pendingrAF&&this.windowElement.cancelAnimationFrame(this.pendingrAF),this.windowElement=null,this.pendingrAF=null,this.pendingElements.clear(),!0):(this.resumeObserving(),!1)}translateRoots(){const t=Array.from(this.roots);return Promise.all(t.map(e=>this.translateFragment(e)))}pauseObserving(){this.mutationObserver&&(this.translateMutations(this.mutationObserver.takeRecords()),this.mutationObserver.disconnect())}resumeObserving(){if(this.mutationObserver)for(const t of this.roots)this.mutationObserver.observe(t,this.observerConfig)}translateMutations(t){for(const e of t)switch(e.type){case"attributes":e.target.hasAttribute("data-l10n-id")&&this.pendingElements.add(e.target);break;case"childList":for(const i of e.addedNodes)if(i.nodeType===i.ELEMENT_NODE)if(i.childElementCount)for(const s of this.getTranslatables(i))this.pendingElements.add(s);else i.hasAttribute(Gt)&&this.pendingElements.add(i);break}this.pendingElements.size>0&&this.pendingrAF===null&&(this.pendingrAF=this.windowElement.requestAnimationFrame(()=>{this.translateElements(Array.from(this.pendingElements)),this.pendingElements.clear(),this.pendingrAF=null}))}translateFragment(t){return this.translateElements(this.getTranslatables(t))}async translateElements(t){if(!t.length)return;const e=t.map(this.getKeysForElement),i=await this.formatMessages(e);return this.applyTranslations(t,i)}applyTranslations(t,e){this.pauseObserving();for(let i=0;i<t.length;i++)e[i]!==void 0&&yl(t[i],e[i]);this.resumeObserving()}getTranslatables(t){const e=Array.from(t.querySelectorAll(Rl));return typeof t.hasAttribute=="function"&&t.hasAttribute(Gt)&&e.push(t),e}getKeysForElement(t){return{id:t.getAttribute(Gt),args:JSON.parse(t.getAttribute(de)||null)}}}class We{#t;#e;#i;#s;constructor({lang:t,isRTL:e},i=null){this.#i=We.#r(t),this.#s=i,this.#t=e??We.#n(this.#i)?"rtl":"ltr"}_setL10n(t){this.#s=t}getLanguage(){return this.#i}getDirection(){return this.#t}async get(t,e=null,i){return Array.isArray(t)?(t=t.map(r=>({id:r})),(await this.#s.formatMessages(t)).map(r=>r.value)):(await this.#s.formatMessages([{id:t,args:e}]))[0]?.value||i}async translate(t){(this.#e||=new Set).add(t);try{this.#s.connectRoot(t),await this.#s.translateRoots()}catch{}}async translateOnce(t){try{await this.#s.translateElements([t])}catch(e){console.error("translateOnce:",e)}}async destroy(){if(this.#e){for(const t of this.#e)this.#s.disconnectRoot(t);this.#e.clear(),this.#e=null}this.#s.pauseObserving()}pause(){this.#s.pauseObserving()}resume(){this.#s.resumeObserving()}static#r(t){return t=t?.toLowerCase()||"en-us",{en:"en-us",es:"es-es",fy:"fy-nl",ga:"ga-ie",gu:"gu-in",hi:"hi-in",hy:"hy-am",nb:"nb-no",ne:"ne-np",nn:"nn-no",pa:"pa-in",pt:"pt-pt",sv:"sv-se",zh:"zh-cn"}[t]||t}static#n(t){const e=t.split("-",1)[0];return["ar","he","fa","ps","ur"].includes(e)}}function Xs(l,t){const e=new pl(t),i=new Zo(l),s=i.addResource(e);return s.length&&console.error("L10n errors",s),i}class Ot extends We{constructor(t){super({lang:t});const e=t?Ot.#t.bind(Ot,"en-us",this.getLanguage()):Ot.#s.bind(Ot,this.getLanguage());this._setL10n(new Il([],e))}static async*#t(t,e){const{baseURL:i,paths:s}=await this.#i(),n=[e];if(t!==e){const r=e.split("-",1)[0];r!==e&&n.push(r),n.push(t)}for(const r of n){const a=await this.#e(r,i,s);a?yield a:r==="en-us"&&(yield this.#r(r))}}static async#e(t,e,i){const s=i[t];if(!s)return null;const n=new URL(s,e),r=await Rs(n,"text");return Xs(t,r)}static async#i(){try{const{href:t}=document.querySelector('link[type="application/l10n"]'),e=await Rs(t,"json");return{baseURL:t.replace(/[^/]*$/,"")||"./",paths:e}}catch{}return{baseURL:"./",paths:Object.create(null)}}static async*#s(t){yield this.#r(t)}static async#r(t){return Xs(t,`pdfjs-previous-button =
|
|
20
|
+
.title = Previous Page
|
|
21
|
+
pdfjs-previous-button-label = Previous
|
|
22
|
+
pdfjs-next-button =
|
|
23
|
+
.title = Next Page
|
|
24
|
+
pdfjs-next-button-label = Next
|
|
25
|
+
pdfjs-page-input =
|
|
26
|
+
.title = Page
|
|
27
|
+
pdfjs-of-pages = of { $pagesCount }
|
|
28
|
+
pdfjs-page-of-pages = ({ $pageNumber } of { $pagesCount })
|
|
29
|
+
pdfjs-zoom-out-button =
|
|
30
|
+
.title = Zoom Out
|
|
31
|
+
pdfjs-zoom-out-button-label = Zoom Out
|
|
32
|
+
pdfjs-zoom-in-button =
|
|
33
|
+
.title = Zoom In
|
|
34
|
+
pdfjs-zoom-in-button-label = Zoom In
|
|
35
|
+
pdfjs-zoom-select =
|
|
36
|
+
.title = Zoom
|
|
37
|
+
pdfjs-presentation-mode-button =
|
|
38
|
+
.title = Switch to Presentation Mode
|
|
39
|
+
pdfjs-presentation-mode-button-label = Presentation Mode
|
|
40
|
+
pdfjs-open-file-button =
|
|
41
|
+
.title = Open File
|
|
42
|
+
pdfjs-open-file-button-label = Open
|
|
43
|
+
pdfjs-print-button =
|
|
44
|
+
.title = Print
|
|
45
|
+
pdfjs-print-button-label = Print
|
|
46
|
+
pdfjs-save-button =
|
|
47
|
+
.title = Save
|
|
48
|
+
pdfjs-save-button-label = Save
|
|
49
|
+
pdfjs-download-button =
|
|
50
|
+
.title = Download
|
|
51
|
+
pdfjs-download-button-label = Download
|
|
52
|
+
pdfjs-bookmark-button =
|
|
53
|
+
.title = Current Page (View URL from Current Page)
|
|
54
|
+
pdfjs-bookmark-button-label = Current Page
|
|
55
|
+
pdfjs-tools-button =
|
|
56
|
+
.title = Tools
|
|
57
|
+
pdfjs-tools-button-label = Tools
|
|
58
|
+
pdfjs-first-page-button =
|
|
59
|
+
.title = Go to First Page
|
|
60
|
+
pdfjs-first-page-button-label = Go to First Page
|
|
61
|
+
pdfjs-last-page-button =
|
|
62
|
+
.title = Go to Last Page
|
|
63
|
+
pdfjs-last-page-button-label = Go to Last Page
|
|
64
|
+
pdfjs-page-rotate-cw-button =
|
|
65
|
+
.title = Rotate Clockwise
|
|
66
|
+
pdfjs-page-rotate-cw-button-label = Rotate Clockwise
|
|
67
|
+
pdfjs-page-rotate-ccw-button =
|
|
68
|
+
.title = Rotate Counterclockwise
|
|
69
|
+
pdfjs-page-rotate-ccw-button-label = Rotate Counterclockwise
|
|
70
|
+
pdfjs-cursor-text-select-tool-button =
|
|
71
|
+
.title = Enable Text Selection Tool
|
|
72
|
+
pdfjs-cursor-text-select-tool-button-label = Text Selection Tool
|
|
73
|
+
pdfjs-cursor-hand-tool-button =
|
|
74
|
+
.title = Enable Hand Tool
|
|
75
|
+
pdfjs-cursor-hand-tool-button-label = Hand Tool
|
|
76
|
+
pdfjs-scroll-page-button =
|
|
77
|
+
.title = Use Page Scrolling
|
|
78
|
+
pdfjs-scroll-page-button-label = Page Scrolling
|
|
79
|
+
pdfjs-scroll-vertical-button =
|
|
80
|
+
.title = Use Vertical Scrolling
|
|
81
|
+
pdfjs-scroll-vertical-button-label = Vertical Scrolling
|
|
82
|
+
pdfjs-scroll-horizontal-button =
|
|
83
|
+
.title = Use Horizontal Scrolling
|
|
84
|
+
pdfjs-scroll-horizontal-button-label = Horizontal Scrolling
|
|
85
|
+
pdfjs-scroll-wrapped-button =
|
|
86
|
+
.title = Use Wrapped Scrolling
|
|
87
|
+
pdfjs-scroll-wrapped-button-label = Wrapped Scrolling
|
|
88
|
+
pdfjs-spread-none-button =
|
|
89
|
+
.title = Do not join page spreads
|
|
90
|
+
pdfjs-spread-none-button-label = No Spreads
|
|
91
|
+
pdfjs-spread-odd-button =
|
|
92
|
+
.title = Join page spreads starting with odd-numbered pages
|
|
93
|
+
pdfjs-spread-odd-button-label = Odd Spreads
|
|
94
|
+
pdfjs-spread-even-button =
|
|
95
|
+
.title = Join page spreads starting with even-numbered pages
|
|
96
|
+
pdfjs-spread-even-button-label = Even Spreads
|
|
97
|
+
pdfjs-document-properties-button =
|
|
98
|
+
.title = Document Properties…
|
|
99
|
+
pdfjs-document-properties-button-label = Document Properties…
|
|
100
|
+
pdfjs-document-properties-file-name = File name:
|
|
101
|
+
pdfjs-document-properties-file-size = File size:
|
|
102
|
+
pdfjs-document-properties-size-kb = { NUMBER($kb, maximumSignificantDigits: 3) } KB ({ $b } bytes)
|
|
103
|
+
pdfjs-document-properties-size-mb = { NUMBER($mb, maximumSignificantDigits: 3) } MB ({ $b } bytes)
|
|
104
|
+
pdfjs-document-properties-title = Title:
|
|
105
|
+
pdfjs-document-properties-author = Author:
|
|
106
|
+
pdfjs-document-properties-subject = Subject:
|
|
107
|
+
pdfjs-document-properties-keywords = Keywords:
|
|
108
|
+
pdfjs-document-properties-creation-date = Creation Date:
|
|
109
|
+
pdfjs-document-properties-modification-date = Modification Date:
|
|
110
|
+
pdfjs-document-properties-date-time-string = { DATETIME($dateObj, dateStyle: "short", timeStyle: "medium") }
|
|
111
|
+
pdfjs-document-properties-creator = Creator:
|
|
112
|
+
pdfjs-document-properties-producer = PDF Producer:
|
|
113
|
+
pdfjs-document-properties-version = PDF Version:
|
|
114
|
+
pdfjs-document-properties-page-count = Page Count:
|
|
115
|
+
pdfjs-document-properties-page-size = Page Size:
|
|
116
|
+
pdfjs-document-properties-page-size-unit-inches = in
|
|
117
|
+
pdfjs-document-properties-page-size-unit-millimeters = mm
|
|
118
|
+
pdfjs-document-properties-page-size-orientation-portrait = portrait
|
|
119
|
+
pdfjs-document-properties-page-size-orientation-landscape = landscape
|
|
120
|
+
pdfjs-document-properties-page-size-name-a-three = A3
|
|
121
|
+
pdfjs-document-properties-page-size-name-a-four = A4
|
|
122
|
+
pdfjs-document-properties-page-size-name-letter = Letter
|
|
123
|
+
pdfjs-document-properties-page-size-name-legal = Legal
|
|
124
|
+
pdfjs-document-properties-page-size-dimension-string = { $width } × { $height } { $unit } ({ $orientation })
|
|
125
|
+
pdfjs-document-properties-page-size-dimension-name-string = { $width } × { $height } { $unit } ({ $name }, { $orientation })
|
|
126
|
+
pdfjs-document-properties-linearized = Fast Web View:
|
|
127
|
+
pdfjs-document-properties-linearized-yes = Yes
|
|
128
|
+
pdfjs-document-properties-linearized-no = No
|
|
129
|
+
pdfjs-document-properties-close-button = Close
|
|
130
|
+
pdfjs-print-progress-message = Preparing document for printing…
|
|
131
|
+
pdfjs-print-progress-percent = { $progress }%
|
|
132
|
+
pdfjs-print-progress-close-button = Cancel
|
|
133
|
+
pdfjs-printing-not-supported = Warning: Printing is not fully supported by this browser.
|
|
134
|
+
pdfjs-printing-not-ready = Warning: The PDF is not fully loaded for printing.
|
|
135
|
+
pdfjs-toggle-sidebar-button =
|
|
136
|
+
.title = Toggle Sidebar
|
|
137
|
+
pdfjs-toggle-sidebar-notification-button =
|
|
138
|
+
.title = Toggle Sidebar (document contains outline/attachments/layers)
|
|
139
|
+
pdfjs-toggle-sidebar-button-label = Toggle Sidebar
|
|
140
|
+
pdfjs-document-outline-button =
|
|
141
|
+
.title = Show Document Outline (double-click to expand/collapse all items)
|
|
142
|
+
pdfjs-document-outline-button-label = Document Outline
|
|
143
|
+
pdfjs-attachments-button =
|
|
144
|
+
.title = Show Attachments
|
|
145
|
+
pdfjs-attachments-button-label = Attachments
|
|
146
|
+
pdfjs-layers-button =
|
|
147
|
+
.title = Show Layers (double-click to reset all layers to the default state)
|
|
148
|
+
pdfjs-layers-button-label = Layers
|
|
149
|
+
pdfjs-thumbs-button =
|
|
150
|
+
.title = Show Thumbnails
|
|
151
|
+
pdfjs-thumbs-button-label = Thumbnails
|
|
152
|
+
pdfjs-current-outline-item-button =
|
|
153
|
+
.title = Find Current Outline Item
|
|
154
|
+
pdfjs-current-outline-item-button-label = Current Outline Item
|
|
155
|
+
pdfjs-findbar-button =
|
|
156
|
+
.title = Find in Document
|
|
157
|
+
pdfjs-findbar-button-label = Find
|
|
158
|
+
pdfjs-additional-layers = Additional Layers
|
|
159
|
+
pdfjs-thumb-page-title =
|
|
160
|
+
.title = Page { $page }
|
|
161
|
+
pdfjs-thumb-page-canvas =
|
|
162
|
+
.aria-label = Thumbnail of Page { $page }
|
|
163
|
+
pdfjs-find-input =
|
|
164
|
+
.title = Find
|
|
165
|
+
.placeholder = Find in document…
|
|
166
|
+
pdfjs-find-previous-button =
|
|
167
|
+
.title = Find the previous occurrence of the phrase
|
|
168
|
+
pdfjs-find-previous-button-label = Previous
|
|
169
|
+
pdfjs-find-next-button =
|
|
170
|
+
.title = Find the next occurrence of the phrase
|
|
171
|
+
pdfjs-find-next-button-label = Next
|
|
172
|
+
pdfjs-find-highlight-checkbox = Highlight All
|
|
173
|
+
pdfjs-find-match-case-checkbox-label = Match Case
|
|
174
|
+
pdfjs-find-match-diacritics-checkbox-label = Match Diacritics
|
|
175
|
+
pdfjs-find-entire-word-checkbox-label = Whole Words
|
|
176
|
+
pdfjs-find-reached-top = Reached top of document, continued from bottom
|
|
177
|
+
pdfjs-find-reached-bottom = Reached end of document, continued from top
|
|
178
|
+
pdfjs-find-match-count =
|
|
179
|
+
{ $total ->
|
|
180
|
+
[one] { $current } of { $total } match
|
|
181
|
+
*[other] { $current } of { $total } matches
|
|
182
|
+
}
|
|
183
|
+
pdfjs-find-match-count-limit =
|
|
184
|
+
{ $limit ->
|
|
185
|
+
[one] More than { $limit } match
|
|
186
|
+
*[other] More than { $limit } matches
|
|
187
|
+
}
|
|
188
|
+
pdfjs-find-not-found = Phrase not found
|
|
189
|
+
pdfjs-page-scale-width = Page Width
|
|
190
|
+
pdfjs-page-scale-fit = Page Fit
|
|
191
|
+
pdfjs-page-scale-auto = Automatic Zoom
|
|
192
|
+
pdfjs-page-scale-actual = Actual Size
|
|
193
|
+
pdfjs-page-scale-percent = { $scale }%
|
|
194
|
+
pdfjs-page-landmark =
|
|
195
|
+
.aria-label = Page { $page }
|
|
196
|
+
pdfjs-loading-error = An error occurred while loading the PDF.
|
|
197
|
+
pdfjs-invalid-file-error = Invalid or corrupted PDF file.
|
|
198
|
+
pdfjs-missing-file-error = Missing PDF file.
|
|
199
|
+
pdfjs-unexpected-response-error = Unexpected server response.
|
|
200
|
+
pdfjs-rendering-error = An error occurred while rendering the page.
|
|
201
|
+
pdfjs-annotation-date-time-string = { DATETIME($dateObj, dateStyle: "short", timeStyle: "medium") }
|
|
202
|
+
pdfjs-text-annotation-type =
|
|
203
|
+
.alt = [{ $type } Annotation]
|
|
204
|
+
pdfjs-password-label = Enter the password to open this PDF file.
|
|
205
|
+
pdfjs-password-invalid = Invalid password. Please try again.
|
|
206
|
+
pdfjs-password-ok-button = OK
|
|
207
|
+
pdfjs-password-cancel-button = Cancel
|
|
208
|
+
pdfjs-web-fonts-disabled = Web fonts are disabled: unable to use embedded PDF fonts.
|
|
209
|
+
pdfjs-editor-free-text-button =
|
|
210
|
+
.title = Text
|
|
211
|
+
pdfjs-editor-free-text-button-label = Text
|
|
212
|
+
pdfjs-editor-ink-button =
|
|
213
|
+
.title = Draw
|
|
214
|
+
pdfjs-editor-ink-button-label = Draw
|
|
215
|
+
pdfjs-editor-stamp-button =
|
|
216
|
+
.title = Add or edit images
|
|
217
|
+
pdfjs-editor-stamp-button-label = Add or edit images
|
|
218
|
+
pdfjs-editor-highlight-button =
|
|
219
|
+
.title = Highlight
|
|
220
|
+
pdfjs-editor-highlight-button-label = Highlight
|
|
221
|
+
pdfjs-highlight-floating-button1 =
|
|
222
|
+
.title = Highlight
|
|
223
|
+
.aria-label = Highlight
|
|
224
|
+
pdfjs-highlight-floating-button-label = Highlight
|
|
225
|
+
pdfjs-editor-remove-ink-button =
|
|
226
|
+
.title = Remove drawing
|
|
227
|
+
pdfjs-editor-remove-freetext-button =
|
|
228
|
+
.title = Remove text
|
|
229
|
+
pdfjs-editor-remove-stamp-button =
|
|
230
|
+
.title = Remove image
|
|
231
|
+
pdfjs-editor-remove-highlight-button =
|
|
232
|
+
.title = Remove highlight
|
|
233
|
+
pdfjs-editor-free-text-color-input = Color
|
|
234
|
+
pdfjs-editor-free-text-size-input = Size
|
|
235
|
+
pdfjs-editor-ink-color-input = Color
|
|
236
|
+
pdfjs-editor-ink-thickness-input = Thickness
|
|
237
|
+
pdfjs-editor-ink-opacity-input = Opacity
|
|
238
|
+
pdfjs-editor-stamp-add-image-button =
|
|
239
|
+
.title = Add image
|
|
240
|
+
pdfjs-editor-stamp-add-image-button-label = Add image
|
|
241
|
+
pdfjs-editor-free-highlight-thickness-input = Thickness
|
|
242
|
+
pdfjs-editor-free-highlight-thickness-title =
|
|
243
|
+
.title = Change thickness when highlighting items other than text
|
|
244
|
+
pdfjs-free-text2 =
|
|
245
|
+
.aria-label = Text Editor
|
|
246
|
+
.default-content = Start typing…
|
|
247
|
+
pdfjs-ink =
|
|
248
|
+
.aria-label = Draw Editor
|
|
249
|
+
pdfjs-ink-canvas =
|
|
250
|
+
.aria-label = User-created image
|
|
251
|
+
pdfjs-editor-alt-text-button =
|
|
252
|
+
.aria-label = Alt text
|
|
253
|
+
pdfjs-editor-alt-text-button-label = Alt text
|
|
254
|
+
pdfjs-editor-alt-text-edit-button =
|
|
255
|
+
.aria-label = Edit alt text
|
|
256
|
+
pdfjs-editor-alt-text-dialog-label = Choose an option
|
|
257
|
+
pdfjs-editor-alt-text-dialog-description = Alt text (alternative text) helps when people can’t see the image or when it doesn’t load.
|
|
258
|
+
pdfjs-editor-alt-text-add-description-label = Add a description
|
|
259
|
+
pdfjs-editor-alt-text-add-description-description = Aim for 1-2 sentences that describe the subject, setting, or actions.
|
|
260
|
+
pdfjs-editor-alt-text-mark-decorative-label = Mark as decorative
|
|
261
|
+
pdfjs-editor-alt-text-mark-decorative-description = This is used for ornamental images, like borders or watermarks.
|
|
262
|
+
pdfjs-editor-alt-text-cancel-button = Cancel
|
|
263
|
+
pdfjs-editor-alt-text-save-button = Save
|
|
264
|
+
pdfjs-editor-alt-text-decorative-tooltip = Marked as decorative
|
|
265
|
+
pdfjs-editor-alt-text-textarea =
|
|
266
|
+
.placeholder = For example, “A young man sits down at a table to eat a meal”
|
|
267
|
+
pdfjs-editor-resizer-top-left =
|
|
268
|
+
.aria-label = Top left corner — resize
|
|
269
|
+
pdfjs-editor-resizer-top-middle =
|
|
270
|
+
.aria-label = Top middle — resize
|
|
271
|
+
pdfjs-editor-resizer-top-right =
|
|
272
|
+
.aria-label = Top right corner — resize
|
|
273
|
+
pdfjs-editor-resizer-middle-right =
|
|
274
|
+
.aria-label = Middle right — resize
|
|
275
|
+
pdfjs-editor-resizer-bottom-right =
|
|
276
|
+
.aria-label = Bottom right corner — resize
|
|
277
|
+
pdfjs-editor-resizer-bottom-middle =
|
|
278
|
+
.aria-label = Bottom middle — resize
|
|
279
|
+
pdfjs-editor-resizer-bottom-left =
|
|
280
|
+
.aria-label = Bottom left corner — resize
|
|
281
|
+
pdfjs-editor-resizer-middle-left =
|
|
282
|
+
.aria-label = Middle left — resize
|
|
283
|
+
pdfjs-editor-highlight-colorpicker-label = Highlight color
|
|
284
|
+
pdfjs-editor-colorpicker-button =
|
|
285
|
+
.title = Change color
|
|
286
|
+
pdfjs-editor-colorpicker-dropdown =
|
|
287
|
+
.aria-label = Color choices
|
|
288
|
+
pdfjs-editor-colorpicker-yellow =
|
|
289
|
+
.title = Yellow
|
|
290
|
+
pdfjs-editor-colorpicker-green =
|
|
291
|
+
.title = Green
|
|
292
|
+
pdfjs-editor-colorpicker-blue =
|
|
293
|
+
.title = Blue
|
|
294
|
+
pdfjs-editor-colorpicker-pink =
|
|
295
|
+
.title = Pink
|
|
296
|
+
pdfjs-editor-colorpicker-red =
|
|
297
|
+
.title = Red
|
|
298
|
+
pdfjs-editor-highlight-show-all-button-label = Show all
|
|
299
|
+
pdfjs-editor-highlight-show-all-button =
|
|
300
|
+
.title = Show all
|
|
301
|
+
pdfjs-editor-new-alt-text-dialog-edit-label = Edit alt text (image description)
|
|
302
|
+
pdfjs-editor-new-alt-text-dialog-add-label = Add alt text (image description)
|
|
303
|
+
pdfjs-editor-new-alt-text-textarea =
|
|
304
|
+
.placeholder = Write your description here…
|
|
305
|
+
pdfjs-editor-new-alt-text-description = Short description for people who can’t see the image or when the image doesn’t load.
|
|
306
|
+
pdfjs-editor-new-alt-text-disclaimer1 = This alt text was created automatically and may be inaccurate.
|
|
307
|
+
pdfjs-editor-new-alt-text-disclaimer-learn-more-url = Learn more
|
|
308
|
+
pdfjs-editor-new-alt-text-create-automatically-button-label = Create alt text automatically
|
|
309
|
+
pdfjs-editor-new-alt-text-not-now-button = Not now
|
|
310
|
+
pdfjs-editor-new-alt-text-error-title = Couldn’t create alt text automatically
|
|
311
|
+
pdfjs-editor-new-alt-text-error-description = Please write your own alt text or try again later.
|
|
312
|
+
pdfjs-editor-new-alt-text-error-close-button = Close
|
|
313
|
+
pdfjs-editor-new-alt-text-ai-model-downloading-progress = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)
|
|
314
|
+
.aria-valuetext = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)
|
|
315
|
+
pdfjs-editor-new-alt-text-added-button =
|
|
316
|
+
.aria-label = Alt text added
|
|
317
|
+
pdfjs-editor-new-alt-text-added-button-label = Alt text added
|
|
318
|
+
pdfjs-editor-new-alt-text-missing-button =
|
|
319
|
+
.aria-label = Missing alt text
|
|
320
|
+
pdfjs-editor-new-alt-text-missing-button-label = Missing alt text
|
|
321
|
+
pdfjs-editor-new-alt-text-to-review-button =
|
|
322
|
+
.aria-label = Review alt text
|
|
323
|
+
pdfjs-editor-new-alt-text-to-review-button-label = Review alt text
|
|
324
|
+
pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer = Created automatically: { $generatedAltText }
|
|
325
|
+
pdfjs-image-alt-text-settings-button =
|
|
326
|
+
.title = Image alt text settings
|
|
327
|
+
pdfjs-image-alt-text-settings-button-label = Image alt text settings
|
|
328
|
+
pdfjs-editor-alt-text-settings-dialog-label = Image alt text settings
|
|
329
|
+
pdfjs-editor-alt-text-settings-automatic-title = Automatic alt text
|
|
330
|
+
pdfjs-editor-alt-text-settings-create-model-button-label = Create alt text automatically
|
|
331
|
+
pdfjs-editor-alt-text-settings-create-model-description = Suggests descriptions to help people who can’t see the image or when the image doesn’t load.
|
|
332
|
+
pdfjs-editor-alt-text-settings-download-model-label = Alt text AI model ({ $totalSize } MB)
|
|
333
|
+
pdfjs-editor-alt-text-settings-ai-model-description = Runs locally on your device so your data stays private. Required for automatic alt text.
|
|
334
|
+
pdfjs-editor-alt-text-settings-delete-model-button = Delete
|
|
335
|
+
pdfjs-editor-alt-text-settings-download-model-button = Download
|
|
336
|
+
pdfjs-editor-alt-text-settings-downloading-model-button = Downloading…
|
|
337
|
+
pdfjs-editor-alt-text-settings-editor-title = Alt text editor
|
|
338
|
+
pdfjs-editor-alt-text-settings-show-dialog-button-label = Show alt text editor right away when adding an image
|
|
339
|
+
pdfjs-editor-alt-text-settings-show-dialog-description = Helps you make sure all your images have alt text.
|
|
340
|
+
pdfjs-editor-alt-text-settings-close-button = Close
|
|
341
|
+
pdfjs-editor-undo-bar-message-highlight = Highlight removed
|
|
342
|
+
pdfjs-editor-undo-bar-message-freetext = Text removed
|
|
343
|
+
pdfjs-editor-undo-bar-message-ink = Drawing removed
|
|
344
|
+
pdfjs-editor-undo-bar-message-stamp = Image removed
|
|
345
|
+
pdfjs-editor-undo-bar-message-multiple =
|
|
346
|
+
{ $count ->
|
|
347
|
+
[one] { $count } annotation removed
|
|
348
|
+
*[other] { $count } annotations removed
|
|
349
|
+
}
|
|
350
|
+
pdfjs-editor-undo-bar-undo-button =
|
|
351
|
+
.title = Undo
|
|
352
|
+
pdfjs-editor-undo-bar-undo-button-label = Undo
|
|
353
|
+
pdfjs-editor-undo-bar-close-button =
|
|
354
|
+
.title = Close
|
|
355
|
+
pdfjs-editor-undo-bar-close-button-label = Close`)}}const Ml=1e3,kl=50,Nl=1e3;function yi(){return document.location.hash}class Dl{#t=null;constructor({linkService:t,eventBus:e}){this.linkService=t,this.eventBus=e,this._initialized=!1,this._fingerprint="",this.reset(),this.eventBus._on("pagesinit",()=>{this._isPagesLoaded=!1,this.eventBus._on("pagesloaded",i=>{this._isPagesLoaded=!!i.pagesCount},{once:!0})})}initialize({fingerprint:t,resetHistory:e=!1,updateUrl:i=!1}){if(!t||typeof t!="string"){console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');return}this._initialized&&this.reset();const s=this._fingerprint!==""&&this._fingerprint!==t;this._fingerprint=t,this._updateUrl=i===!0,this._initialized=!0,this.#u();const n=window.history.state;if(this._popStateInProgress=!1,this._blockHashChange=0,this._currentHash=yi(),this._numPositionUpdates=0,this._uid=this._maxUid=0,this._destination=null,this._position=null,!this.#r(n,!0)||e){const{hash:a,page:o,rotation:h}=this.#a(!0);if(!a||s||e){this.#e(null,!0);return}this.#e({hash:a,page:o,rotation:h},!0);return}const r=n.destination;this.#n(r,n.uid,!0),r.rotation!==void 0&&(this._initialRotation=r.rotation),r.dest?(this._initialBookmark=JSON.stringify(r.dest),this._destination.page=null):r.hash?this._initialBookmark=r.hash:r.page&&(this._initialBookmark=`page=${r.page}`)}reset(){this._initialized&&(this.#h(),this._initialized=!1,this.#d()),this._updateViewareaTimeout&&(clearTimeout(this._updateViewareaTimeout),this._updateViewareaTimeout=null),this._initialBookmark=null,this._initialRotation=null}push({namedDest:t=null,explicitDest:e,pageNumber:i}){if(!this._initialized)return;if(t&&typeof t!="string"){console.error(`PDFHistory.push: "${t}" is not a valid namedDest parameter.`);return}else if(Array.isArray(e)){if(!this.#s(i)&&(i!==null||this._destination)){console.error(`PDFHistory.push: "${i}" is not a valid pageNumber parameter.`);return}}else{console.error(`PDFHistory.push: "${e}" is not a valid explicitDest parameter.`);return}const s=t||JSON.stringify(e);if(!s)return;let n=!1;if(this._destination&&(Fl(this._destination.hash,s)||Ol(this._destination.dest,e))){if(this._destination.page)return;n=!0}this._popStateInProgress&&!n||(this.#e({dest:e,hash:s,page:i,rotation:this.linkService.rotation},n),this._popStateInProgress||(this._popStateInProgress=!0,Promise.resolve().then(()=>{this._popStateInProgress=!1})))}pushPage(t){if(this._initialized){if(!this.#s(t)){console.error(`PDFHistory.pushPage: "${t}" is not a valid page number.`);return}this._destination?.page!==t&&(this._popStateInProgress||(this.#e({dest:null,hash:`page=${t}`,page:t,rotation:this.linkService.rotation}),this._popStateInProgress||(this._popStateInProgress=!0,Promise.resolve().then(()=>{this._popStateInProgress=!1}))))}}pushCurrentPosition(){!this._initialized||this._popStateInProgress||this.#i()}back(){if(!this._initialized||this._popStateInProgress)return;const t=window.history.state;this.#r(t)&&t.uid>0&&window.history.back()}forward(){if(!this._initialized||this._popStateInProgress)return;const t=window.history.state;this.#r(t)&&t.uid<this._maxUid&&window.history.forward()}get popStateInProgress(){return this._initialized&&(this._popStateInProgress||this._blockHashChange>0)}get initialBookmark(){return this._initialized?this._initialBookmark:null}get initialRotation(){return this._initialized?this._initialRotation:null}#e(t,e=!1){const i=e||!this._destination,s={fingerprint:this._fingerprint,uid:i?this._uid:this._uid+1,destination:t};this.#n(t,s.uid);let n;if(this._updateUrl&&t?.hash){const r=document.location.href.split("#",1)[0];r.startsWith("file://")||(n=`${r}#${t.hash}`)}i?window.history.replaceState(s,"",n):window.history.pushState(s,"",n)}#i(t=!1){if(!this._position)return;let e=this._position;if(t&&(e=Object.assign(Object.create(null),this._position),e.temporary=!0),!this._destination){this.#e(e);return}if(this._destination.temporary){this.#e(e,!0);return}if(this._destination.hash===e.hash||!this._destination.page&&this._numPositionUpdates<=kl)return;let i=!1;if(this._destination.page>=e.first&&this._destination.page<=e.page){if(this._destination.dest!==void 0||!this._destination.first)return;i=!0}this.#e(e,i)}#s(t){return Number.isInteger(t)&&t>0&&t<=this.linkService.pagesCount}#r(t,e=!1){if(!t)return!1;if(t.fingerprint!==this._fingerprint)if(e){if(typeof t.fingerprint!="string"||t.fingerprint.length!==this._fingerprint.length)return!1;const[i]=performance.getEntriesByType("navigation");if(i?.type!=="reload")return!1}else return!1;return!(!Number.isInteger(t.uid)||t.uid<0||t.destination===null||typeof t.destination!="object")}#n(t,e,i=!1){this._updateViewareaTimeout&&(clearTimeout(this._updateViewareaTimeout),this._updateViewareaTimeout=null),i&&t?.temporary&&delete t.temporary,this._destination=t,this._uid=e,this._maxUid=Math.max(this._maxUid,e),this._numPositionUpdates=0}#a(t=!1){const e=unescape(yi()).substring(1),i=ei(e),s=i.get("nameddest")||"";let n=i.get("page")|0;return(!this.#s(n)||t&&s.length>0)&&(n=null),{hash:e,page:n,rotation:this.linkService.rotation}}#l({location:t}){this._updateViewareaTimeout&&(clearTimeout(this._updateViewareaTimeout),this._updateViewareaTimeout=null),this._position={hash:t.pdfOpenParams.substring(1),page:this.linkService.page,first:t.pageNumber,rotation:t.rotation},!this._popStateInProgress&&(this._isPagesLoaded&&this._destination&&!this._destination.page&&this._numPositionUpdates++,this._updateViewareaTimeout=setTimeout(()=>{this._popStateInProgress||this.#i(!0),this._updateViewareaTimeout=null},Nl))}#c({state:t}){const e=yi(),i=this._currentHash!==e;if(this._currentHash=e,!t){this._uid++;const{hash:n,page:r,rotation:a}=this.#a();this.#e({hash:n,page:r,rotation:a},!0);return}if(!this.#r(t))return;this._popStateInProgress=!0,i&&(this._blockHashChange++,jo({target:window,name:"hashchange",delay:Ml}).then(()=>{this._blockHashChange--}));const s=t.destination;this.#n(s,t.uid,!0),In(s.rotation)&&(this.linkService.rotation=s.rotation),s.dest?this.linkService.goToDestination(s.dest):s.hash?this.linkService.setHash(s.hash):s.page&&(this.linkService.page=s.page),Promise.resolve().then(()=>{this._popStateInProgress=!1})}#h(){(!this._destination||this._destination.temporary)&&this.#i()}#u(){if(this.#t)return;this.#t=new AbortController;const{signal:t}=this.#t;this.eventBus._on("updateviewarea",this.#l.bind(this),{signal:t}),window.addEventListener("popstate",this.#c.bind(this),{signal:t}),window.addEventListener("pagehide",this.#h.bind(this),{signal:t})}#d(){this.#t?.abort(),this.#t=null}}function Fl(l,t){return typeof l!="string"||typeof t!="string"?!1:l===t||ei(l).get("nameddest")===t}function Ol(l,t){function e(i,s){if(typeof i!=typeof s||Array.isArray(i)||Array.isArray(s))return!1;if(i!==null&&typeof i=="object"&&s!==null){if(Object.keys(i).length!==Object.keys(s).length)return!1;for(const n in i)if(!e(i[n],s[n]))return!1;return!0}return i===s||Number.isNaN(i)&&Number.isNaN(s)}if(!(Array.isArray(l)&&Array.isArray(t))||l.length!==t.length)return!1;for(let i=0,s=l.length;i<s;i++)if(!e(l[i],t[i]))return!1;return!0}class Bl{#t=null;#e=null;#i=null;#s=null;#r=null;#n;constructor(t){this.pdfPage=t.pdfPage,this.accessibilityManager=t.accessibilityManager,this.l10n=t.l10n,this.l10n||=new Ot,this.annotationEditorLayer=null,this.div=null,this._cancelled=!1,this.#n=t.uiManager,this.#t=t.annotationLayer||null,this.#r=t.textLayer||null,this.#e=t.drawLayer||null,this.#i=t.onAppend||null,this.#s=t.structTreeLayer||null}async render(t,e="display"){if(e!=="display"||this._cancelled)return;const i=t.clone({dontFlip:!0});if(this.div){this.annotationEditorLayer.update({viewport:i}),this.show();return}const s=this.div=document.createElement("div");s.className="annotationEditorLayer",s.hidden=!0,s.dir=this.#n.direction,this.#i?.(s),this.annotationEditorLayer=new Co({uiManager:this.#n,div:s,structTreeLayer:this.#s,accessibilityManager:this.accessibilityManager,pageIndex:this.pdfPage.pageNumber-1,l10n:this.l10n,viewport:i,annotationLayer:this.#t,textLayer:this.#r,drawLayer:this.#e});const n={viewport:i,div:s,annotations:null,intent:e};this.annotationEditorLayer.render(n),this.show()}cancel(){this._cancelled=!0,this.div&&this.annotationEditorLayer.destroy()}hide(){this.div&&(this.annotationEditorLayer.pause(!0),this.div.hidden=!0)}show(){!this.div||this.annotationEditorLayer.isInvisible||(this.div.hidden=!1,this.annotationEditorLayer.pause(!1))}}{var ki=new Map;const l=navigator.userAgent||"",t=navigator.platform||"",e=navigator.maxTouchPoints||1,i=/Android/.test(l),s=/\b(iPad|iPhone|iPod)(?=;)/.test(l)||t==="MacIntel"&&e>1;(function(){(s||i)&&ki.set("maxCanvasPixels",5242880)})(),function(){i&&ki.set("useSystemFonts",!1)}()}const E={BROWSER:1,VIEWER:2,API:4,WORKER:8,EVENT_DISPATCH:16,PREFERENCE:128},Ni={BOOLEAN:1,NUMBER:2,OBJECT:4,STRING:8,UNDEFINED:16},Mt={allowedGlobalEvents:{value:null,kind:E.BROWSER},canvasMaxAreaInBytes:{value:-1,kind:E.BROWSER+E.API},isInAutomation:{value:!1,kind:E.BROWSER},localeProperties:{value:{lang:navigator.language||"en-US"},kind:E.BROWSER},nimbusDataStr:{value:"",kind:E.BROWSER},supportsCaretBrowsingMode:{value:!1,kind:E.BROWSER},supportsDocumentFonts:{value:!0,kind:E.BROWSER},supportsIntegratedFind:{value:!1,kind:E.BROWSER},supportsMouseWheelZoomCtrlKey:{value:!0,kind:E.BROWSER},supportsMouseWheelZoomMetaKey:{value:!0,kind:E.BROWSER},supportsPinchToZoom:{value:!0,kind:E.BROWSER},toolbarDensity:{value:0,kind:E.BROWSER+E.EVENT_DISPATCH},altTextLearnMoreUrl:{value:"",kind:E.VIEWER+E.PREFERENCE},annotationEditorMode:{value:0,kind:E.VIEWER+E.PREFERENCE},annotationMode:{value:2,kind:E.VIEWER+E.PREFERENCE},cursorToolOnLoad:{value:0,kind:E.VIEWER+E.PREFERENCE},debuggerSrc:{value:"./debugger.mjs",kind:E.VIEWER},defaultZoomDelay:{value:400,kind:E.VIEWER+E.PREFERENCE},defaultZoomValue:{value:"",kind:E.VIEWER+E.PREFERENCE},disableHistory:{value:!1,kind:E.VIEWER},disablePageLabels:{value:!1,kind:E.VIEWER+E.PREFERENCE},enableAltText:{value:!1,kind:E.VIEWER+E.PREFERENCE},enableAltTextModelDownload:{value:!0,kind:E.VIEWER+E.PREFERENCE+E.EVENT_DISPATCH},enableGuessAltText:{value:!0,kind:E.VIEWER+E.PREFERENCE+E.EVENT_DISPATCH},enableHighlightFloatingButton:{value:!1,kind:E.VIEWER+E.PREFERENCE},enableNewAltTextWhenAddingImage:{value:!0,kind:E.VIEWER+E.PREFERENCE},enablePermissions:{value:!1,kind:E.VIEWER+E.PREFERENCE},enablePrintAutoRotate:{value:!0,kind:E.VIEWER+E.PREFERENCE},enableScripting:{value:!0,kind:E.VIEWER+E.PREFERENCE},enableUpdatedAddImage:{value:!1,kind:E.VIEWER+E.PREFERENCE},externalLinkRel:{value:"noopener noreferrer nofollow",kind:E.VIEWER},externalLinkTarget:{value:0,kind:E.VIEWER+E.PREFERENCE},highlightEditorColors:{value:"yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F",kind:E.VIEWER+E.PREFERENCE},historyUpdateUrl:{value:!1,kind:E.VIEWER+E.PREFERENCE},ignoreDestinationZoom:{value:!1,kind:E.VIEWER+E.PREFERENCE},imageResourcesPath:{value:"./images/",kind:E.VIEWER},maxCanvasPixels:{value:2**25,kind:E.VIEWER},forcePageColors:{value:!1,kind:E.VIEWER+E.PREFERENCE},pageColorsBackground:{value:"Canvas",kind:E.VIEWER+E.PREFERENCE},pageColorsForeground:{value:"CanvasText",kind:E.VIEWER+E.PREFERENCE},pdfBugEnabled:{value:!1,kind:E.VIEWER+E.PREFERENCE},printResolution:{value:150,kind:E.VIEWER},sidebarViewOnLoad:{value:-1,kind:E.VIEWER+E.PREFERENCE},scrollModeOnLoad:{value:-1,kind:E.VIEWER+E.PREFERENCE},spreadModeOnLoad:{value:-1,kind:E.VIEWER+E.PREFERENCE},textLayerMode:{value:1,kind:E.VIEWER+E.PREFERENCE},viewOnLoad:{value:0,kind:E.VIEWER+E.PREFERENCE},cMapPacked:{value:!0,kind:E.API},cMapUrl:{value:"../web/cmaps/",kind:E.API},disableAutoFetch:{value:!1,kind:E.API+E.PREFERENCE},disableFontFace:{value:!1,kind:E.API+E.PREFERENCE},disableRange:{value:!1,kind:E.API+E.PREFERENCE},disableStream:{value:!1,kind:E.API+E.PREFERENCE},docBaseUrl:{value:"",kind:E.API},enableHWA:{value:!0,kind:E.API+E.VIEWER+E.PREFERENCE},enableXfa:{value:!0,kind:E.API+E.PREFERENCE},fontExtraProperties:{value:!1,kind:E.API},isEvalSupported:{value:!0,kind:E.API},isOffscreenCanvasSupported:{value:!0,kind:E.API},maxImageSize:{value:-1,kind:E.API},pdfBug:{value:!1,kind:E.API},standardFontDataUrl:{value:"../web/standard_fonts/",kind:E.API},useSystemFonts:{value:void 0,kind:E.API,type:Ni.BOOLEAN+Ni.UNDEFINED},verbosity:{value:1,kind:E.API},workerPort:{value:null,kind:E.WORKER},workerSrc:{value:"../build/pdf.worker.mjs",kind:E.WORKER}};Mt.defaultUrl={value:"compressed.tracemonkey-pldi-09.pdf",kind:E.VIEWER},Mt.sandboxBundleSrc={value:"../build/pdf.sandbox.mjs",kind:E.VIEWER},Mt.viewerCssTheme={value:0,kind:E.VIEWER+E.PREFERENCE},Mt.enableFakeMLManager={value:!0,kind:E.VIEWER};Mt.disablePreferences={value:!1,kind:E.VIEWER};class jl{static eventBus;static#t=new Map;static{for(const t in Mt)this.#t.set(t,Mt[t].value);for(const[t,e]of ki)this.#t.set(t,e);this._hasInvokedSet=!1,this._checkDisablePreferences=()=>this.get("disablePreferences")?!0:(this._hasInvokedSet&&console.warn('The Preferences may override manually set AppOptions; please use the "disablePreferences"-option to prevent that.'),!1)}static get(t){return this.#t.get(t)}static getAll(t=null,e=!1){const i=Object.create(null);for(const s in Mt){const n=Mt[s];t&&!(t&n.kind)||(i[s]=e?n.value:this.#t.get(s))}return i}static set(t,e){this.setAll({[t]:e})}static setAll(t,e=!1){this._hasInvokedSet||=!0;let i;for(const s in t){const n=Mt[s],r=t[s];if(!n||!(typeof r==typeof n.value||Ni[(typeof r).toUpperCase()]&n.type))continue;const{kind:a}=n;e&&!(a&E.BROWSER||a&E.PREFERENCE)||(this.eventBus&&a&E.EVENT_DISPATCH&&(i||=new Map).set(s,r),this.#t.set(s,r))}if(i)for(const[s,n]of i)this.eventBus.dispatch(s.toLowerCase(),{source:this,value:n})}}class Hl{#t=null;constructor(t){this.pageIndex=t.pageIndex}async render(t="display"){t!=="display"||this.#t||this._cancelled||(this.#t=new Io({pageIndex:this.pageIndex}))}cancel(){this._cancelled=!0,this.#t&&(this.#t.destroy(),this.#t=null)}setParent(t){this.#t?.setParent(t)}getDrawLayer(){return this.#t}}const qs={Document:null,DocumentFragment:null,Part:"group",Sect:"group",Div:"group",Aside:"note",NonStruct:"none",P:null,H:"heading",Title:null,FENote:"note",Sub:"group",Lbl:null,Span:null,Em:null,Strong:null,Link:"link",Annot:"note",Form:"form",Ruby:null,RB:null,RT:null,RP:null,Warichu:null,WT:null,WP:null,L:"list",LI:"listitem",LBody:null,Table:"table",TR:"row",TH:"columnheader",TD:"cell",THead:"columnheader",TBody:null,TFoot:null,Caption:null,Figure:"figure",Formula:null,Artifact:null},Vl=/^H(\d+)$/;class On{#t;#e=null;#i;#s=new Map;#r;#n=null;constructor(t,e){this.#t=t.getStructTree(),this.#r=e}async render(){if(this.#i)return this.#i;const{promise:t,resolve:e,reject:i}=Promise.withResolvers();this.#i=t;try{this.#e=this.#c(await this.#t)}catch(s){i(s)}return this.#t=null,this.#e?.classList.add("structTree"),e(this.#e),t}async getAriaAttributes(t){try{return await this.render(),this.#s.get(t)}catch{}return null}hide(){this.#e&&!this.#e.hidden&&(this.#e.hidden=!0)}show(){this.#e?.hidden&&(this.#e.hidden=!1)}#a(t,e){const{alt:i,id:s,lang:n}=t;if(i!==void 0){let r=!1;const a=ye(i);for(const o of t.children)if(o.type==="annotation"){let h=this.#s.get(o.id);h||(h=new Map,this.#s.set(o.id,h)),h.set("aria-label",a),r=!0}r||e.setAttribute("aria-label",a)}s!==void 0&&e.setAttribute("aria-owns",s),n!==void 0&&e.setAttribute("lang",ye(n,!0))}#l(t,e){const{alt:i,bbox:s,children:n}=t,r=n?.[0];if(!this.#r||!i||!s||r?.type!=="content")return!1;const{id:a}=r;if(!a)return!1;e.setAttribute("aria-owns",a);const o=document.createElement("span");(this.#n||=new Map).set(a,o),o.setAttribute("role","img"),o.setAttribute("aria-label",ye(i));const{pageHeight:h,pageX:c,pageY:d}=this.#r,u="calc(var(--scale-factor)*",{style:f}=o;return f.width=`${u}${s[2]-s[0]}px)`,f.height=`${u}${s[3]-s[1]}px)`,f.left=`${u}${s[0]-c}px)`,f.top=`${u}${h-s[3]+d}px)`,!0}addElementsToTextLayer(){if(this.#n){for(const[t,e]of this.#n)document.getElementById(t)?.append(e);this.#n.clear(),this.#n=null}}#c(t){if(!t)return null;const e=document.createElement("span");if("role"in t){const{role:i}=t,s=i.match(Vl);if(s?(e.setAttribute("role","heading"),e.setAttribute("aria-level",s[1])):qs[i]&&e.setAttribute("role",qs[i]),i==="Figure"&&this.#l(t,e))return e}if(this.#a(t,e),t.children)if(t.children.length===1&&"id"in t.children[0])this.#a(t.children[0],e);else for(const i of t.children)e.append(this.#c(i));return e}}class Ae{#t=!1;#e=null;#i=new Map;#s=new Map;setTextMapping(t){this.#e=t}static#r(t,e){const i=t.getBoundingClientRect(),s=e.getBoundingClientRect();if(i.width===0&&i.height===0)return 1;if(s.width===0&&s.height===0)return-1;const n=i.y,r=i.y+i.height,a=i.y+i.height/2,o=s.y,h=s.y+s.height,c=s.y+s.height/2;if(a<=o&&c>=r)return-1;if(c<=n&&a>=h)return 1;const d=i.x+i.width/2,u=s.x+s.width/2;return d-u}enable(){if(this.#t)throw new Error("TextAccessibilityManager is already enabled.");if(!this.#e)throw new Error("Text divs and strings have not been set.");if(this.#t=!0,this.#e=this.#e.slice(),this.#e.sort(Ae.#r),this.#i.size>0){const t=this.#e;for(const[e,i]of this.#i){if(!document.getElementById(e)){this.#i.delete(e);continue}this.#n(e,t[i])}}for(const[t,e]of this.#s)this.addPointerInTextLayer(t,e);this.#s.clear()}disable(){this.#t&&(this.#s.clear(),this.#e=null,this.#t=!1)}removePointerInTextLayer(t){if(!this.#t){this.#s.delete(t);return}const e=this.#e;if(!e||e.length===0)return;const{id:i}=t,s=this.#i.get(i);if(s===void 0)return;const n=e[s];this.#i.delete(i);let r=n.getAttribute("aria-owns");r?.includes(i)&&(r=r.split(" ").filter(a=>a!==i).join(" "),r?n.setAttribute("aria-owns",r):(n.removeAttribute("aria-owns"),n.setAttribute("role","presentation")))}#n(t,e){const i=e.getAttribute("aria-owns");i?.includes(t)||e.setAttribute("aria-owns",i?`${i} ${t}`:t),e.removeAttribute("role")}addPointerInTextLayer(t,e){const{id:i}=t;if(!i)return null;if(!this.#t)return this.#s.set(t,e),null;e&&this.removePointerInTextLayer(t);const s=this.#e;if(!s||s.length===0)return null;const n=Se(s,h=>Ae.#r(t,h)<0),r=Math.max(0,n-1),a=s[r];this.#n(i,a),this.#i.set(i,r);const o=a.parentNode;return o?.classList.contains("markedContent")?o.id:null}moveElementInDOM(t,e,i,s){const n=this.addPointerInTextLayer(i,s);if(!t.hasChildNodes())return t.append(e),n;const r=Array.from(t.childNodes).filter(h=>h!==e);if(r.length===0)return n;const a=i||e,o=Se(r,h=>Ae.#r(a,h)<0);return o===0?r[0].before(e):r[o-1].after(e),n}}class $l{#t=null;constructor({findController:t,eventBus:e,pageIndex:i}){this.findController=t,this.matches=[],this.eventBus=e,this.pageIdx=i,this.textDivs=null,this.textContentItemsStr=null,this.enabled=!1}setTextMapping(t,e){this.textDivs=t,this.textContentItemsStr=e}enable(){if(!this.textDivs||!this.textContentItemsStr)throw new Error("Text divs and strings have not been set.");if(this.enabled)throw new Error("TextHighlighter is already enabled.");this.enabled=!0,this.#t||(this.#t=new AbortController,this.eventBus._on("updatetextlayermatches",t=>{(t.pageIndex===this.pageIdx||t.pageIndex===-1)&&this._updateMatches()},{signal:this.#t.signal})),this._updateMatches()}disable(){this.enabled&&(this.enabled=!1,this.#t?.abort(),this.#t=null,this._updateMatches(!0))}_convertMatches(t,e){if(!t)return[];const{textContentItemsStr:i}=this;let s=0,n=0;const r=i.length-1,a=[];for(let o=0,h=t.length;o<h;o++){let c=t[o];for(;s!==r&&c>=n+i[s].length;)n+=i[s].length,s++;s===i.length&&console.error("Could not find a matching mapping");const d={begin:{divIdx:s,offset:c-n}};for(c+=e[o];s!==r&&c>n+i[s].length;)n+=i[s].length,s++;d.end={divIdx:s,offset:c-n},a.push(d)}return a}_renderMatches(t){if(t.length===0)return;const{findController:e,pageIdx:i}=this,{textContentItemsStr:s,textDivs:n}=this,r=i===e.selected.pageIdx,a=e.selected.matchIdx,o=e.state.highlightAll;let h=null;const c={offset:void 0};function d(m,w){const y=m.divIdx;return n[y].textContent="",u(y,0,m.offset,w)}function u(m,w,y,A){let v=n[m];if(v.nodeType===Node.TEXT_NODE){const T=document.createElement("span");v.before(T),T.append(v),n[m]=T,v=T}const C=s[m].substring(w,y),x=document.createTextNode(C);if(A){const T=document.createElement("span");if(T.className=`${A} appended`,T.append(x),v.append(T),A.includes("selected")){const{left:_}=T.getClientRects()[0],S=v.getBoundingClientRect().left;return _-S}return 0}return v.append(x),0}let f=a,p=f+1;if(o)f=0,p=t.length;else if(!r)return;let g=-1,b=-1;for(let m=f;m<p;m++){const w=t[m],y=w.begin;if(y.divIdx===g&&y.offset===b)continue;g=y.divIdx,b=y.offset;const A=w.end,v=r&&m===a,C=v?" selected":"";let x=0;if(!h||y.divIdx!==h.divIdx?(h!==null&&u(h.divIdx,h.offset,c.offset),d(y)):u(h.divIdx,h.offset,y.offset),y.divIdx===A.divIdx)x=u(y.divIdx,y.offset,A.offset,"highlight"+C);else{x=u(y.divIdx,y.offset,c.offset,"highlight begin"+C);for(let T=y.divIdx+1,_=A.divIdx;T<_;T++)n[T].className="highlight middle"+C;d(A,"highlight end"+C)}h=A,v&&e.scrollMatchIntoView({element:n[y.divIdx],selectedLeft:x,pageIndex:i,matchIndex:a})}h&&u(h.divIdx,h.offset,c.offset)}_updateMatches(t=!1){if(!this.enabled&&!t)return;const{findController:e,matches:i,pageIdx:s}=this,{textContentItemsStr:n,textDivs:r}=this;let a=-1;for(const c of i){const d=Math.max(a,c.begin.divIdx);for(let u=d,f=c.end.divIdx;u<=f;u++){const p=r[u];p.textContent=n[u],p.className=""}a=c.end.divIdx+1}if(!e?.highlightMatches||t)return;const o=e.pageMatches[s]||null,h=e.pageMatchesLength[s]||null;this.matches=this._convertMatches(o,h),this._renderMatches(this.matches)}}class se{#t=!1;#e=null;#i=!1;#s=null;static#r=new Map;static#n=null;constructor({pdfPage:t,highlighter:e=null,accessibilityManager:i=null,enablePermissions:s=!1,onAppend:n=null}){this.pdfPage=t,this.highlighter=e,this.accessibilityManager=i,this.#t=s===!0,this.#e=n,this.div=document.createElement("div"),this.div.tabIndex=0,this.div.className="textLayer"}async render(t,e=null){if(this.#i&&this.#s){this.#s.update({viewport:t,onBefore:this.hide.bind(this)}),this.show();return}this.cancel(),this.#s=new Oo({textContentSource:this.pdfPage.streamTextContent(e||{includeMarkedContent:!0,disableNormalization:!0}),container:this.div,viewport:t});const{textDivs:i,textContentItemsStr:s}=this.#s;this.highlighter?.setTextMapping(i,s),this.accessibilityManager?.setTextMapping(i),await this.#s.render(),this.#i=!0;const n=document.createElement("div");n.className="endOfContent",this.div.append(n),this.#a(n),this.#e?.(this.div),this.highlighter?.enable(),this.accessibilityManager?.enable()}hide(){!this.div.hidden&&this.#i&&(this.highlighter?.disable(),this.div.hidden=!0)}show(){this.div.hidden&&this.#i&&(this.div.hidden=!1,this.highlighter?.enable())}cancel(){this.#s?.cancel(),this.#s=null,this.highlighter?.disable(),this.accessibilityManager?.disable(),se.#l(this.div)}#a(t){const{div:e}=this;e.addEventListener("mousedown",()=>{e.classList.add("selecting")}),e.addEventListener("copy",i=>{if(!this.#t){const s=document.getSelection();i.clipboardData.setData("text/plain",ye(No(s.toString())))}Ri(i)}),se.#r.set(e,t),se.#c()}static#l(t){this.#r.delete(t),this.#r.size===0&&(this.#n?.abort(),this.#n=null)}static#c(){if(this.#n)return;this.#n=new AbortController;const{signal:t}=this.#n,e=(r,a)=>{a.append(r),r.style.width="",r.style.height="",a.classList.remove("selecting")};let i=!1;document.addEventListener("pointerdown",()=>{i=!0},{signal:t}),document.addEventListener("pointerup",()=>{i=!1,this.#r.forEach(e)},{signal:t}),window.addEventListener("blur",()=>{i=!1,this.#r.forEach(e)},{signal:t}),document.addEventListener("keyup",()=>{i||this.#r.forEach(e)},{signal:t});var s,n;document.addEventListener("selectionchange",()=>{const r=document.getSelection();if(r.rangeCount===0){this.#r.forEach(e);return}const a=new Set;for(let f=0;f<r.rangeCount;f++){const p=r.getRangeAt(f);for(const g of this.#r.keys())!a.has(g)&&p.intersectsNode(g)&&a.add(g)}for(const[f,p]of this.#r)a.has(f)?f.classList.add("selecting"):e(p,f);if(s??=getComputedStyle(this.#r.values().next().value).getPropertyValue("-moz-user-select")==="none",s)return;const o=r.getRangeAt(0),h=n&&(o.compareBoundaryPoints(Range.END_TO_END,n)===0||o.compareBoundaryPoints(Range.START_TO_END,n)===0);let c=h?o.startContainer:o.endContainer;c.nodeType===Node.TEXT_NODE&&(c=c.parentNode);const d=c.parentElement?.closest(".textLayer"),u=this.#r.get(d);u&&(u.style.width=d.style.width,u.style.height=d.style.height,c.parentElement.insertBefore(u,h?c:c.nextSibling)),n=o.cloneRange()},{signal:t})}}class Bn{constructor({pdfPage:t,annotationStorage:e=null,linkService:i,xfaHtml:s=null}){this.pdfPage=t,this.annotationStorage=e,this.linkService=i,this.xfaHtml=s,this.div=null,this._cancelled=!1}async render(t,e="display"){if(e==="print"){const n={viewport:t.clone({dontFlip:!0}),div:this.div,xfaHtml:this.xfaHtml,annotationStorage:this.annotationStorage,linkService:this.linkService,intent:e};return this.div=document.createElement("div"),n.div=this.div,gi.render(n)}const i=await this.pdfPage.getXfa();if(this._cancelled||!i)return{textDivs:[]};const s={viewport:t.clone({dontFlip:!0}),div:this.div,xfaHtml:i,annotationStorage:this.annotationStorage,linkService:this.linkService,intent:e};return this.div?gi.update(s):(this.div=document.createElement("div"),s.div=this.div,gi.render(s))}cancel(){this._cancelled=!0}hide(){this.div&&(this.div.hidden=!0)}}const Ul={annotationEditorUIManager:null,annotationStorage:null,downloadManager:null,enableScripting:!1,fieldObjectsPromise:null,findController:null,hasJSActionsPromise:null,get linkService(){return new Qi}},zl=new Map([["canvasWrapper",0],["textLayer",1],["annotationLayer",2],["annotationEditorLayer",3],["xfaLayer",3]]);class jn{#t=Ft.ENABLE_FORMS;#e=null;#i=!1;#s=!1;#r=!1;#n=null;#a=null;#l=null;#c=null;#h=1;#u=1;#d=null;#f=q.INITIAL;#o=It.ENABLE;#p={directDrawing:!0,initialOptionalContent:!0,regularAnnotations:!0};#m=[null,null,null,null];constructor(t){const e=t.container,i=t.defaultViewport;this.id=t.id,this.renderingId="page"+this.id,this.#n=t.layerProperties||Ul,this.pdfPage=null,this.pageLabel=null,this.rotation=0,this.scale=t.scale||Ln,this.viewport=i,this.pdfPageRotate=i.rotation,this._optionalContentConfigPromise=t.optionalContentConfigPromise||null,this.#o=t.textLayerMode??It.ENABLE,this.#t=t.annotationMode??Ft.ENABLE_FORMS,this.imageResourcesPath=t.imageResourcesPath||"",this.maxCanvasPixels=t.maxCanvasPixels??jl.get("maxCanvasPixels"),this.pageColors=t.pageColors||null,this.#i=t.enableHWA||!1,this.eventBus=t.eventBus,this.renderingQueue=t.renderingQueue,this.l10n=t.l10n,this.l10n||=new Ot,this.renderTask=null,this.resume=null,this._isStandalone=!this.renderingQueue?.hasViewer(),this._container=e,this._annotationCanvasMap=null,this.annotationLayer=null,this.annotationEditorLayer=null,this.textLayer=null,this.xfaLayer=null,this.structTreeLayer=null,this.drawLayer=null;const s=document.createElement("div");if(s.className="page",s.setAttribute("data-page-number",this.id),s.setAttribute("role","region"),s.setAttribute("data-l10n-id","pdfjs-page-landmark"),s.setAttribute("data-l10n-args",JSON.stringify({page:this.id})),this.div=s,this.#b(),e?.append(s),this._isStandalone){e?.style.setProperty("--scale-factor",this.scale*Dt.PDF_TO_CSS_UNITS),this.pageColors?.background&&e?.style.setProperty("--page-bg-color",this.pageColors.background);const{optionalContentConfigPromise:n}=t;n&&n.then(r=>{n===this._optionalContentConfigPromise&&(this.#p.initialOptionalContent=r.hasInitialVisibility)}),t.l10n||this.l10n.translate(this.div)}}#g(t,e){const i=zl.get(e),s=this.#m[i];if(this.#m[i]=t,s){s.replaceWith(t);return}for(let n=i-1;n>=0;n--){const r=this.#m[n];if(r){r.after(t);return}}this.div.prepend(t)}get renderingState(){return this.#f}set renderingState(t){if(t!==this.#f)switch(this.#f=t,this.#a&&(clearTimeout(this.#a),this.#a=null),t){case q.PAUSED:this.div.classList.remove("loading");break;case q.RUNNING:this.div.classList.add("loadingIcon"),this.#a=setTimeout(()=>{this.div.classList.add("loading"),this.#a=null},0);break;case q.INITIAL:case q.FINISHED:this.div.classList.remove("loadingIcon","loading");break}}#b(){const{viewport:t}=this;if(this.pdfPage){if(this.#c===t.rotation)return;this.#c=t.rotation}Fo(this.div,t,!0,!1)}setPdfPage(t){this._isStandalone&&(this.pageColors?.foreground==="CanvasText"||this.pageColors?.background==="Canvas")&&(this._container?.style.setProperty("--hcm-highlight-filter",t.filterFactory.addHighlightHCMFilter("highlight","CanvasText","Canvas","HighlightText","Highlight")),this._container?.style.setProperty("--hcm-highlight-selected-filter",t.filterFactory.addHighlightHCMFilter("highlight_selected","CanvasText","Canvas","HighlightText","Highlight"))),this.pdfPage=t,this.pdfPageRotate=t.rotate;const e=(this.rotation+this.pdfPageRotate)%360;this.viewport=t.getViewport({scale:this.scale*Dt.PDF_TO_CSS_UNITS,rotation:e}),this.#b(),this.reset()}destroy(){this.reset(),this.pdfPage?.cleanup()}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}get _textHighlighter(){return Ue(this,"_textHighlighter",new $l({pageIndex:this.id-1,eventBus:this.eventBus,findController:this.#n.findController}))}#y(t,e){this.eventBus.dispatch(t,{source:this,pageNumber:this.id,error:e})}async#w(){let t=null;try{await this.annotationLayer.render(this.viewport,{structTreeLayer:this.structTreeLayer},"display")}catch(e){console.error("#renderAnnotationLayer:",e),t=e}finally{this.#y("annotationlayerrendered",t)}}async#A(){let t=null;try{await this.annotationEditorLayer.render(this.viewport,"display")}catch(e){console.error("#renderAnnotationEditorLayer:",e),t=e}finally{this.#y("annotationeditorlayerrendered",t)}}async#v(){try{await this.drawLayer.render("display")}catch(t){console.error("#renderDrawLayer:",t)}}async#S(){let t=null;try{const e=await this.xfaLayer.render(this.viewport,"display");e?.textDivs&&this._textHighlighter&&this.#E(e.textDivs)}catch(e){console.error("#renderXfaLayer:",e),t=e}finally{this.xfaLayer?.div&&(this.l10n.pause(),this.#g(this.xfaLayer.div,"xfaLayer"),this.l10n.resume()),this.#y("xfalayerrendered",t)}}async#x(){if(!this.textLayer)return;let t=null;try{await this.textLayer.render(this.viewport)}catch(e){if(e instanceof Po)return;console.error("#renderTextLayer:",e),t=e}this.#y("textlayerrendered",t),this.#L()}async#L(){if(!this.textLayer)return;const t=await this.structTreeLayer?.render();t&&(this.l10n.pause(),this.structTreeLayer?.addElementsToTextLayer(),this.canvas&&t.parentNode!==this.canvas&&this.canvas.append(t),this.l10n.resume()),this.structTreeLayer?.show()}async#E(t){const e=await this.pdfPage.getTextContent(),i=[];for(const s of e.items)i.push(s.str);this._textHighlighter.setTextMapping(t,i),this._textHighlighter.enable()}#T(){const{canvas:t}=this;t&&(t.remove(),t.width=t.height=0,this.canvas=null,this.#l=null)}reset({keepAnnotationLayer:t=!1,keepAnnotationEditorLayer:e=!1,keepXfaLayer:i=!1,keepTextLayer:s=!1,keepCanvasWrapper:n=!1}={}){this.cancelRendering({keepAnnotationLayer:t,keepAnnotationEditorLayer:e,keepXfaLayer:i,keepTextLayer:s}),this.renderingState=q.INITIAL;const r=this.div,a=r.childNodes,o=t&&this.annotationLayer?.div||null,h=e&&this.annotationEditorLayer?.div||null,c=i&&this.xfaLayer?.div||null,d=s&&this.textLayer?.div||null,u=n&&this.#e||null;for(let f=a.length-1;f>=0;f--){const p=a[f];switch(p){case o:case h:case c:case d:case u:continue}p.remove();const g=this.#m.indexOf(p);g>=0&&(this.#m[g]=null)}r.removeAttribute("data-loaded"),o&&this.annotationLayer.hide(),h&&this.annotationEditorLayer.hide(),c&&this.xfaLayer.hide(),d&&this.textLayer.hide(),this.structTreeLayer?.hide(),!n&&this.#e&&(this.#e=null,this.#T())}toggleEditingMode(t){this.hasEditableAnnotations()&&(this.#r=t,this.reset({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,keepCanvasWrapper:!0}))}update({scale:t=0,rotation:e=null,optionalContentConfigPromise:i=null,drawingDelay:s=-1}){this.scale=t||this.scale,typeof e=="number"&&(this.rotation=e),i instanceof Promise&&(this._optionalContentConfigPromise=i,i.then(r=>{i===this._optionalContentConfigPromise&&(this.#p.initialOptionalContent=r.hasInitialVisibility)})),this.#p.directDrawing=!0;const n=(this.rotation+this.pdfPageRotate)%360;if(this.viewport=this.viewport.clone({scale:this.scale*Dt.PDF_TO_CSS_UNITS,rotation:n}),this.#b(),this._isStandalone&&this._container?.style.setProperty("--scale-factor",this.viewport.scale),this.canvas){let r=!1;if(this.#s){if(this.maxCanvasPixels===0)r=!0;else if(this.maxCanvasPixels>0){const{width:o,height:h}=this.viewport,{sx:c,sy:d}=this.outputScale;r=(Math.floor(o)*c|0)*(Math.floor(h)*d|0)>this.maxCanvasPixels}}const a=s>=0&&s<1e3;if(a||r){if(a&&!r&&this.renderingState!==q.FINISHED&&(this.cancelRendering({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,cancelExtraDelay:s}),this.renderingState=q.FINISHED,this.#p.directDrawing=!1),this.cssTransform({redrawAnnotationLayer:!0,redrawAnnotationEditorLayer:!0,redrawXfaLayer:!0,redrawTextLayer:!a,hideTextLayer:a}),a)return;this.eventBus.dispatch("pagerendered",{source:this,pageNumber:this.id,cssTransform:!0,timestamp:performance.now(),error:this.#d});return}}this.cssTransform({}),this.reset({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,keepCanvasWrapper:!0})}cancelRendering({keepAnnotationLayer:t=!1,keepAnnotationEditorLayer:e=!1,keepXfaLayer:i=!1,keepTextLayer:s=!1,cancelExtraDelay:n=0}={}){this.renderTask&&(this.renderTask.cancel(n),this.renderTask=null),this.resume=null,this.textLayer&&(!s||!this.textLayer.div)&&(this.textLayer.cancel(),this.textLayer=null),this.annotationLayer&&(!t||!this.annotationLayer.div)&&(this.annotationLayer.cancel(),this.annotationLayer=null,this._annotationCanvasMap=null),this.structTreeLayer&&!this.textLayer&&(this.structTreeLayer=null),this.annotationEditorLayer&&(!e||!this.annotationEditorLayer.div)&&(this.drawLayer&&(this.drawLayer.cancel(),this.drawLayer=null),this.annotationEditorLayer.cancel(),this.annotationEditorLayer=null),this.xfaLayer&&(!i||!this.xfaLayer.div)&&(this.xfaLayer.cancel(),this.xfaLayer=null,this._textHighlighter?.disable())}cssTransform({redrawAnnotationLayer:t=!1,redrawAnnotationEditorLayer:e=!1,redrawXfaLayer:i=!1,redrawTextLayer:s=!1,hideTextLayer:n=!1}){const{canvas:r}=this;if(!r)return;const a=this.#l;if(this.viewport!==a){const o=(360+this.viewport.rotation-a.rotation)%360;if(o===90||o===270){const{width:h,height:c}=this.viewport,d=c/h,u=h/c;r.style.transform=`rotate(${o}deg) scale(${d},${u})`}else r.style.transform=o===0?"":`rotate(${o}deg)`}t&&this.annotationLayer&&this.#w(),e&&this.annotationEditorLayer&&(this.drawLayer&&this.#v(),this.#A()),i&&this.xfaLayer&&this.#S(),this.textLayer&&(n?(this.textLayer.hide(),this.structTreeLayer?.hide()):s&&this.#x())}get width(){return this.viewport.width}get height(){return this.viewport.height}getPagePoint(t,e){return this.viewport.convertToPdfPoint(t,e)}async#P(t,e=null){if(t===this.renderTask&&(this.renderTask=null),e instanceof Li){this.#d=null;return}if(this.#d=e,this.renderingState=q.FINISHED,this.#p.regularAnnotations=!t.separateAnnots,this.eventBus.dispatch("pagerendered",{source:this,pageNumber:this.id,cssTransform:!1,timestamp:performance.now(),error:this.#d}),e)throw e}async draw(){this.renderingState!==q.INITIAL&&(console.error("Must be in new state before drawing"),this.reset());const{div:t,l10n:e,pageColors:i,pdfPage:s,viewport:n}=this;if(!s)throw this.renderingState=q.FINISHED,new Error("pdfPage is not loaded");this.renderingState=q.RUNNING;let r=this.#e;if(r||(r=this.#e=document.createElement("div"),r.classList.add("canvasWrapper"),this.#g(r,"canvasWrapper")),!this.textLayer&&this.#o!==It.DISABLE&&!s.isPureXfa&&(this._accessibilityManager||=new Ae,this.textLayer=new se({pdfPage:s,highlighter:this._textHighlighter,accessibilityManager:this._accessibilityManager,enablePermissions:this.#o===It.ENABLE_PERMISSIONS,onAppend:P=>{this.l10n.pause(),this.#g(P,"textLayer"),this.l10n.resume()}})),!this.annotationLayer&&this.#t!==Ft.DISABLE){const{annotationStorage:P,annotationEditorUIManager:I,downloadManager:$,enableScripting:O,fieldObjectsPromise:tt,hasJSActionsPromise:L,linkService:k}=this.#n;this._annotationCanvasMap||=new Map,this.annotationLayer=new Mn({pdfPage:s,annotationStorage:P,imageResourcesPath:this.imageResourcesPath,renderForms:this.#t===Ft.ENABLE_FORMS,linkService:k,downloadManager:$,enableScripting:O,hasJSActionsPromise:L,fieldObjectsPromise:tt,annotationCanvasMap:this._annotationCanvasMap,accessibilityManager:this._accessibilityManager,annotationEditorUIManager:I,onAppend:ht=>{this.#g(ht,"annotationLayer")}})}const a=P=>{if(p?.(!1),this.renderingQueue&&!this.renderingQueue.isHighestPriority(this)){this.renderingState=q.PAUSED,this.resume=()=>{this.renderingState=q.RUNNING,P()};return}P()},{width:o,height:h}=n,c=document.createElement("canvas");c.setAttribute("role","presentation");const d=!!(i?.background&&i?.foreground),u=this.canvas,f=!u&&!d;this.canvas=c,this.#l=n;let p=P=>{if(f){r.prepend(c),p=null;return}P&&(u?(u.replaceWith(c),u.width=u.height=0):r.prepend(c),p=null)};const g=c.getContext("2d",{alpha:!1,willReadFrequently:!this.#i}),b=this.outputScale=new Do;if(this.maxCanvasPixels===0){const P=1/this.scale;b.sx*=P,b.sy*=P,this.#s=!0}else if(this.maxCanvasPixels>0){const P=o*h,I=Math.sqrt(this.maxCanvasPixels/P);b.sx>I||b.sy>I?(b.sx=I,b.sy=I,this.#s=!0):this.#s=!1}const m=vs(b.sx),w=vs(b.sy),y=c.width=ke(Ne(o*b.sx),m[0]),A=c.height=ke(Ne(h*b.sy),w[0]),v=ke(Ne(o),m[1]),C=ke(Ne(h),w[1]);b.sx=y/v,b.sy=A/C,this.#h!==m[1]&&(t.style.setProperty("--scale-round-x",`${m[1]}px`),this.#h=m[1]),this.#u!==w[1]&&(t.style.setProperty("--scale-round-y",`${w[1]}px`),this.#u=w[1]);const x=b.scaled?[b.sx,0,0,b.sy,0,0]:null,T={canvasContext:g,transform:x,viewport:n,annotationMode:this.#t,optionalContentConfigPromise:this._optionalContentConfigPromise,annotationCanvasMap:this._annotationCanvasMap,pageColors:i,isEditing:this.#r},_=this.renderTask=s.render(T);_.onContinue=a;const S=_.promise.then(async()=>{p?.(!0),await this.#P(_),this.structTreeLayer||=new On(s,n.rawDims),this.#x(),this.annotationLayer&&await this.#w();const{annotationEditorUIManager:P}=this.#n;P&&(this.drawLayer||=new Hl({pageIndex:this.id}),await this.#v(),this.drawLayer.setParent(r),this.annotationEditorLayer||=new Bl({uiManager:P,pdfPage:s,l10n:e,structTreeLayer:this.structTreeLayer,accessibilityManager:this._accessibilityManager,annotationLayer:this.annotationLayer?.annotationLayer,textLayer:this.textLayer,drawLayer:this.drawLayer.getDrawLayer(),onAppend:I=>{this.#g(I,"annotationEditorLayer")}}),this.#A())},P=>(P instanceof Li?(u?.remove(),this.#T()):p?.(!0),this.#P(_,P)));if(s.isPureXfa){if(!this.xfaLayer){const{annotationStorage:P,linkService:I}=this.#n;this.xfaLayer=new Bn({pdfPage:s,annotationStorage:P,linkService:I})}this.#S()}return t.setAttribute("data-loaded",!0),this.eventBus.dispatch("pagerender",{source:this,pageNumber:this.id}),S}setPageLabel(t){this.pageLabel=typeof t=="string"?t:null,this.div.setAttribute("data-l10n-args",JSON.stringify({page:this.pageLabel??this.id})),this.pageLabel!==null?this.div.setAttribute("data-page-label",this.pageLabel):this.div.removeAttribute("data-page-label")}get thumbnailCanvas(){const{directDrawing:t,initialOptionalContent:e,regularAnnotations:i}=this.#p;return t&&e&&i?this.canvas:null}}async function Wl(l){const t="",e=t.split("#",1)[0];let{info:i,metadata:s,contentDispositionFilename:n,contentLength:r}=await l.getMetadata();if(!r){const{length:a}=await l.getDownloadInfo();r=a}return{...i,baseURL:e,filesize:r,filename:n||Mo(t),metadata:s?.getRaw(),authors:s?.get("dc:creator"),numPages:l.numPages,URL:t}}class Gl{constructor(t){this._ready=new Promise((e,i)=>{import(t).then(n=>{e(n.QuickJSSandbox())}).catch(i)})}async createSandbox(t){(await this._ready).create(t)}async dispatchEventInSandbox(t){const e=await this._ready;setTimeout(()=>e.dispatchEvent(t),0)}async destroySandbox(){(await this._ready).nukeSandbox()}}class Xl{#t=null;#e=null;#i=null;#s=null;#r=null;#n=null;#a=null;#l=null;#c=!1;#h=null;#u=null;constructor({eventBus:t,externalServices:e=null,docProperties:i=null}){this.#r=t,this.#n=e,this.#i=i}setViewer(t){this.#l=t}async setDocument(t){if(this.#a&&await this.#m(),this.#a=t,!t)return;const[e,i,s]=await Promise.all([t.getFieldObjects(),t.getCalculationOrderIds(),t.getJSActions()]);if(!e&&!s){await this.#m();return}if(t!==this.#a)return;try{this.#h=this.#p()}catch(a){console.error("setDocument:",a),await this.#m();return}const n=this.#r;this.#s=new AbortController;const{signal:r}=this.#s;n._on("updatefromsandbox",a=>{a?.source===window&&this.#d(a.detail)},{signal:r}),n._on("dispatcheventinsandbox",a=>{this.#h?.dispatchEventInSandbox(a.detail)},{signal:r}),n._on("pagechanging",({pageNumber:a,previous:o})=>{a!==o&&(this.#o(o),this.#f(a))},{signal:r}),n._on("pagerendered",({pageNumber:a})=>{this._pageOpenPending.has(a)&&a===this.#l.currentPageNumber&&this.#f(a)},{signal:r}),n._on("pagesdestroy",async()=>{await this.#o(this.#l.currentPageNumber),await this.#h?.dispatchEventInSandbox({id:"doc",name:"WillClose"}),this.#t?.resolve()},{signal:r});try{const a=await this.#i(t);if(t!==this.#a)return;await this.#h.createSandbox({objects:e,calculationOrder:i,appInfo:{platform:navigator.platform,language:navigator.language},docInfo:{...a,actions:s}}),n.dispatch("sandboxcreated",{source:this})}catch(a){console.error("setDocument:",a),await this.#m();return}await this.#h?.dispatchEventInSandbox({id:"doc",name:"Open"}),await this.#f(this.#l.currentPageNumber,!0),Promise.resolve().then(()=>{t===this.#a&&(this.#c=!0)})}async dispatchWillSave(){return this.#h?.dispatchEventInSandbox({id:"doc",name:"WillSave"})}async dispatchDidSave(){return this.#h?.dispatchEventInSandbox({id:"doc",name:"DidSave"})}async dispatchWillPrint(){if(this.#h){await this.#u?.promise,this.#u=Promise.withResolvers();try{await this.#h.dispatchEventInSandbox({id:"doc",name:"WillPrint"})}catch(t){throw this.#u.resolve(),this.#u=null,t}await this.#u.promise}}async dispatchDidPrint(){return this.#h?.dispatchEventInSandbox({id:"doc",name:"DidPrint"})}get destroyPromise(){return this.#e?.promise||null}get ready(){return this.#c}get _pageOpenPending(){return Ue(this,"_pageOpenPending",new Set)}get _visitedPages(){return Ue(this,"_visitedPages",new Map)}async#d(t){const e=this.#l,i=e.isInPresentationMode||e.isChangingPresentationMode,{id:s,siblings:n,command:r,value:a}=t;if(!s){switch(r){case"clear":console.clear();break;case"error":console.error(a);break;case"layout":if(!i){const h=eo(a);e.spreadMode=h.spreadMode}break;case"page-num":e.currentPageNumber=a+1;break;case"print":await e.pagesPromise,this.#r.dispatch("print",{source:this});break;case"println":console.log(a);break;case"zoom":i||(e.currentScaleValue=a);break;case"SaveAs":this.#r.dispatch("download",{source:this});break;case"FirstPage":e.currentPageNumber=1;break;case"LastPage":e.currentPageNumber=e.pagesCount;break;case"NextPage":e.nextPage();break;case"PrevPage":e.previousPage();break;case"ZoomViewIn":i||e.increaseScale();break;case"ZoomViewOut":i||e.decreaseScale();break;case"WillPrintFinished":this.#u?.resolve(),this.#u=null;break}return}if(i&&t.focus)return;delete t.id,delete t.siblings;const o=n?[s,...n]:[s];for(const h of o){const c=document.querySelector(`[data-element-id="${h}"]`);c?c.dispatchEvent(new CustomEvent("updatefromsandbox",{detail:t})):this.#a?.annotationStorage.setValue(h,t)}}async#f(t,e=!1){const i=this.#a,s=this._visitedPages;if(e&&(this.#t=Promise.withResolvers()),!this.#t)return;const n=this.#l.getPageView(t-1);if(n?.renderingState!==q.FINISHED){this._pageOpenPending.add(t);return}this._pageOpenPending.delete(t);const r=(async()=>{const a=await(s.has(t)?null:n.pdfPage?.getJSActions());i===this.#a&&await this.#h?.dispatchEventInSandbox({id:"page",name:"PageOpen",pageNumber:t,actions:a})})();s.set(t,r)}async#o(t){const e=this.#a,i=this._visitedPages;if(!this.#t||this._pageOpenPending.has(t))return;const s=i.get(t);s&&(i.set(t,null),await s,e===this.#a&&await this.#h?.dispatchEventInSandbox({id:"page",name:"PageClose",pageNumber:t}))}#p(){if(this.#e=Promise.withResolvers(),this.#h)throw new Error("#initScripting: Scripting already exists.");return this.#n.createScripting()}async#m(){if(!this.#h){this.#a=null,this.#e?.resolve();return}this.#t&&(await Promise.race([this.#t.promise,new Promise(t=>{setTimeout(t,1e3)})]).catch(()=>{}),this.#t=null),this.#a=null;try{await this.#h.destroySandbox()}catch{}this.#u?.reject(new Error("Scripting destroyed.")),this.#u=null,this.#s?.abort(),this.#s=null,this._pageOpenPending.clear(),this._visitedPages.clear(),this.#h=null,this.#c=!1,this.#e?.resolve()}}class ql extends Xl{constructor(t){t.externalServices||window.addEventListener("updatefromsandbox",e=>{t.eventBus.dispatch("updatefromsandbox",{source:window,detail:e.detail})}),t.externalServices||={createScripting:()=>new Gl(t.sandboxBundleSrc)},t.docProperties||=e=>Wl(e),super(t)}}const Yl=3e4;class Kl{constructor(){this.pdfViewer=null,this.pdfThumbnailViewer=null,this.onIdle=null,this.highestPriorityPage=null,this.idleTimeout=null,this.printing=!1,this.isThumbnailViewEnabled=!1,Object.defineProperty(this,"hasViewer",{value:()=>!!this.pdfViewer})}setViewer(t){this.pdfViewer=t}setThumbnailViewer(t){this.pdfThumbnailViewer=t}isHighestPriority(t){return this.highestPriorityPage===t.renderingId}renderHighestPriority(t){this.idleTimeout&&(clearTimeout(this.idleTimeout),this.idleTimeout=null),!this.pdfViewer.forceRendering(t)&&(this.isThumbnailViewEnabled&&this.pdfThumbnailViewer?.forceRendering()||this.printing||this.onIdle&&(this.idleTimeout=setTimeout(this.onIdle.bind(this),Yl)))}getHighestPriority(t,e,i,s=!1){const n=t.views,r=n.length;if(r===0)return null;for(let d=0;d<r;d++){const u=n[d].view;if(!this.isViewFinished(u))return u}const a=t.first.id,o=t.last.id;if(o-a+1>r){const d=t.ids;for(let u=1,f=o-a;u<f;u++){const p=i?a+u:o-u;if(d.has(p))continue;const g=e[p-1];if(!this.isViewFinished(g))return g}}let h=i?o:a-2,c=e[h];return c&&!this.isViewFinished(c)||s&&(h+=i?1:-1,c=e[h],c&&!this.isViewFinished(c))?c:null}isViewFinished(t){return t.renderingState===q.FINISHED}renderView(t){switch(t.renderingState){case q.FINISHED:return!1;case q.PAUSED:this.highestPriorityPage=t.renderingId,t.resume();break;case q.RUNNING:this.highestPriorityPage=t.renderingId;break;case q.INITIAL:this.highestPriorityPage=t.renderingId,t.draw().finally(()=>{this.renderHighestPriority()}).catch(e=>{e instanceof Li||console.error("renderView:",e)});break}return!0}}const Ys=10,Be={FORCE_SCROLL_MODE_PAGE:1e4,FORCE_LAZY_PAGE_INIT:5e3,PAUSE_EAGER_PAGE_INIT:250};function Ks(l){return Object.values(bt).includes(l)&&l!==bt.DISABLE}class Ql{#t=new Set;#e=0;constructor(t){this.#e=t}push(t){const e=this.#t;e.has(t)&&e.delete(t),e.add(t),e.size>this.#e&&this.#i()}resize(t,e=null){this.#e=t;const i=this.#t;if(e){const s=i.size;let n=1;for(const r of i)if(e.has(r.id)&&(i.delete(r),i.add(r)),++n>s)break}for(;i.size>this.#e;)this.#i()}has(t){return this.#t.has(t)}[Symbol.iterator](){return this.#t.keys()}#i(){const t=this.#t.keys().next().value;t?.destroy(),this.#t.delete(t)}}class Hn{#t=null;#e=null;#i=null;#s=bt.NONE;#r=null;#n=Ft.ENABLE_FORMS;#a=null;#l=null;#c=!1;#h=!1;#u=!1;#d=!1;#f=!1;#o=null;#p=null;#m=null;#g=null;#b=!1;#y=null;#w=!1;#A=0;#v=new ResizeObserver(this.#z.bind(this));#S=null;#x=null;#L=!0;#E=It.ENABLE;constructor(t){const e="4.10.38";if(Is!==e)throw new Error(`The API version "${Is}" does not match the Viewer version "${e}".`);if(this.container=t.container,this.viewer=t.viewer||t.container.firstElementChild,this.container?.tagName!=="DIV"||this.viewer?.tagName!=="DIV")throw new Error("Invalid `container` and/or `viewer` option.");if(this.container.offsetParent&&getComputedStyle(this.container).position!=="absolute")throw new Error("The `container` must be absolutely positioned.");this.#v.observe(this.container),this.eventBus=t.eventBus,this.linkService=t.linkService||new Qi,this.downloadManager=t.downloadManager||null,this.findController=t.findController||null,this.#e=t.altTextManager||null,this.#l=t.editorUndoBar||null,this.findController&&(this.findController.onIsPageVisible=s=>this._getVisiblePages().ids.has(s)),this._scriptingManager=t.scriptingManager||null,this.#E=t.textLayerMode??It.ENABLE,this.#n=t.annotationMode??Ft.ENABLE_FORMS,this.#s=t.annotationEditorMode??bt.NONE,this.#i=t.annotationEditorHighlightColors||null,this.#h=t.enableHighlightFloatingButton===!0,this.#d=t.enableUpdatedAddImage===!0,this.#f=t.enableNewAltTextWhenAddingImage===!0,this.imageResourcesPath=t.imageResourcesPath||"",this.enablePrintAutoRotate=t.enablePrintAutoRotate||!1,this.removePageBorders=t.removePageBorders||!1,this.maxCanvasPixels=t.maxCanvasPixels,this.l10n=t.l10n,this.l10n||=new Ot,this.#u=t.enablePermissions||!1,this.pageColors=t.pageColors||null,this.#p=t.mlManager||null,this.#c=t.enableHWA||!1,this.#L=t.supportsPinchToZoom!==!1,this.defaultRenderingQueue=!t.renderingQueue,this.defaultRenderingQueue?(this.renderingQueue=new Kl,this.renderingQueue.setViewer(this)):this.renderingQueue=t.renderingQueue;const{abortSignal:i}=t;i?.addEventListener("abort",()=>{this.#v.disconnect(),this.#v=null},{once:!0}),this.scroll=Xa(this.container,this._scrollUpdate.bind(this),i),this.presentationModeState=ie.UNKNOWN,this._resetView(),this.removePageBorders&&this.viewer.classList.add("removePageBorders"),this.#B(),this.eventBus._on("thumbnailrendered",({pageNumber:s,pdfPage:n})=>{const r=this._pages[s-1];this.#t.has(r)||n?.cleanup()}),t.l10n||this.l10n.translate(this.container)}get pagesCount(){return this._pages.length}getPageView(t){return this._pages[t]}getCachedPageViews(){return new Set(this.#t)}get pageViewsReady(){return this._pages.every(t=>t?.pdfPage)}get renderForms(){return this.#n===Ft.ENABLE_FORMS}get enableScripting(){return!!this._scriptingManager}get currentPageNumber(){return this._currentPageNumber}set currentPageNumber(t){if(!Number.isInteger(t))throw new Error("Invalid page number.");this.pdfDocument&&(this._setCurrentPageNumber(t,!0)||console.error(`currentPageNumber: "${t}" is not a valid page.`))}_setCurrentPageNumber(t,e=!1){if(this._currentPageNumber===t)return e&&this.#H(),!0;if(!(0<t&&t<=this.pagesCount))return!1;const i=this._currentPageNumber;return this._currentPageNumber=t,this.eventBus.dispatch("pagechanging",{source:this,pageNumber:t,pageLabel:this._pageLabels?.[t-1]??null,previous:i}),e&&this.#H(),!0}get currentPageLabel(){return this._pageLabels?.[this._currentPageNumber-1]??null}set currentPageLabel(t){if(!this.pdfDocument)return;let e=t|0;if(this._pageLabels){const i=this._pageLabels.indexOf(t);i>=0&&(e=i+1)}this._setCurrentPageNumber(e,!0)||console.error(`currentPageLabel: "${t}" is not a valid page.`)}get currentScale(){return this._currentScale!==di?this._currentScale:Ln}set currentScale(t){if(isNaN(t))throw new Error("Invalid numeric scale.");this.pdfDocument&&this.#k(t,{noScroll:!1})}get currentScaleValue(){return this._currentScaleValue}set currentScaleValue(t){this.pdfDocument&&this.#k(t,{noScroll:!1})}get pagesRotation(){return this._pagesRotation}set pagesRotation(t){if(!In(t))throw new Error("Invalid pages rotation angle.");if(!this.pdfDocument||(t%=360,t<0&&(t+=360),this._pagesRotation===t))return;this._pagesRotation=t;const e=this._currentPageNumber;this.refresh(!0,{rotation:t}),this._currentScaleValue&&this.#k(this._currentScaleValue,{noScroll:!0}),this.eventBus.dispatch("rotationchanging",{source:this,pagesRotation:t,pageNumber:e}),this.defaultRenderingQueue&&this.update()}get firstPagePromise(){return this.pdfDocument?this._firstPageCapability.promise:null}get onePageRendered(){return this.pdfDocument?this._onePageRenderedCapability.promise:null}get pagesPromise(){return this.pdfDocument?this._pagesCapability.promise:null}get _layerProperties(){const t=this;return Ue(this,"_layerProperties",{get annotationEditorUIManager(){return t.#r},get annotationStorage(){return t.pdfDocument?.annotationStorage},get downloadManager(){return t.downloadManager},get enableScripting(){return!!t._scriptingManager},get fieldObjectsPromise(){return t.pdfDocument?.getFieldObjects()},get findController(){return t.findController},get hasJSActionsPromise(){return t.pdfDocument?.hasJSActions()},get linkService(){return t.linkService}})}#T(t){const e={annotationEditorMode:this.#s,annotationMode:this.#n,textLayerMode:this.#E};return t&&(!t.includes(Fe.COPY)&&this.#E===It.ENABLE&&(e.textLayerMode=It.ENABLE_PERMISSIONS),t.includes(Fe.MODIFY_CONTENTS)||(e.annotationEditorMode=bt.DISABLE),!t.includes(Fe.MODIFY_ANNOTATIONS)&&!t.includes(Fe.FILL_INTERACTIVE_FORMS)&&this.#n===Ft.ENABLE_FORMS&&(e.annotationMode=Ft.ENABLE)),e}async#P(t){if(document.visibilityState==="hidden"||!this.container.offsetParent||this._getVisiblePages().views.length===0)return;const e=Promise.withResolvers(),i=new AbortController;document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&e.resolve()},{signal:typeof AbortSignal.any=="function"?AbortSignal.any([t,i.signal]):t}),await Promise.race([this._onePageRenderedCapability.promise,e.promise]),i.abort()}async getAllText(){const t=[],e=[];for(let i=1,s=this.pdfDocument.numPages;i<=s;++i){if(this.#w)return null;e.length=0;const n=await this.pdfDocument.getPage(i),{items:r}=await n.getTextContent();for(const a of r)a.str&&e.push(a.str),a.hasEOL&&e.push(`
|
|
356
|
+
`);t.push(ye(e.join("")))}return t.join(`
|
|
357
|
+
`)}#I(t,e){const i=document.getSelection(),{focusNode:s,anchorNode:n}=i;if(n&&s&&i.containsNode(this.#y)){if(this.#b||t===It.ENABLE_PERMISSIONS){Ri(e);return}this.#b=!0;const{classList:r}=this.viewer;r.add("copyAll");const a=new AbortController;window.addEventListener("keydown",o=>this.#w=o.key==="Escape",{signal:a.signal}),this.getAllText().then(async o=>{o!==null&&await navigator.clipboard.writeText(o)}).catch(o=>{console.warn(`Something goes wrong when extracting the text: ${o.message}`)}).finally(()=>{this.#b=!1,this.#w=!1,a.abort(),r.remove("copyAll")}),Ri(e)}}setDocument(t){if(this.pdfDocument&&(this.eventBus.dispatch("pagesdestroy",{source:this}),this._cancelRendering(),this._resetView(),this.findController?.setDocument(null),this._scriptingManager?.setDocument(null),this.#r?.destroy(),this.#r=null),this.pdfDocument=t,!t)return;const e=t.numPages,i=t.getPage(1),s=t.getOptionalContentConfig({intent:"display"}),n=this.#u?t.getPermissions():Promise.resolve(),{eventBus:r,pageColors:a,viewer:o}=this;this.#o=new AbortController;const{signal:h}=this.#o;if(e>Be.FORCE_SCROLL_MODE_PAGE){console.warn("Forcing PAGE-scrolling for performance reasons, given the length of the document.");const u=this._scrollMode=U.PAGE;r.dispatch("scrollmodechanged",{source:this,mode:u})}this._pagesCapability.promise.then(()=>{r.dispatch("pagesloaded",{source:this,pagesCount:e})},()=>{});const c=u=>{const f=this._pages[u.pageNumber-1];f&&this.#t.push(f)};r._on("pagerender",c,{signal:h});const d=u=>{u.cssTransform||(this._onePageRenderedCapability.resolve({timestamp:u.timestamp}),r._off("pagerendered",d))};r._on("pagerendered",d,{signal:h}),Promise.all([i,n]).then(([u,f])=>{if(t!==this.pdfDocument)return;this._firstPageCapability.resolve(u),this._optionalContentConfigPromise=s;const{annotationEditorMode:p,annotationMode:g,textLayerMode:b}=this.#T(f);if(b!==It.DISABLE){const A=this.#y=document.createElement("div");A.id="hiddenCopyElement",o.before(A)}if(typeof AbortSignal.any=="function"&&p!==bt.DISABLE){const A=p;t.isPureXfa?console.warn("Warning: XFA-editing is not implemented."):Ks(A)?(this.#r=new To(this.container,o,this.#e,r,t,a,this.#i,this.#h,this.#d,this.#f,this.#p,this.#l,this.#L),r.dispatch("annotationeditoruimanager",{source:this,uiManager:this.#r}),A!==bt.NONE&&(A===bt.STAMP&&this.#p?.loadModel("altText"),this.#r.updateMode(A))):console.error(`Invalid AnnotationEditor mode: ${A}`)}const m=this._scrollMode===U.PAGE?null:o,w=this.currentScale,y=u.getViewport({scale:w*Dt.PDF_TO_CSS_UNITS});o.style.setProperty("--scale-factor",y.scale),a?.background&&o.style.setProperty("--page-bg-color",a.background),(a?.foreground==="CanvasText"||a?.background==="Canvas")&&(o.style.setProperty("--hcm-highlight-filter",t.filterFactory.addHighlightHCMFilter("highlight","CanvasText","Canvas","HighlightText","Highlight")),o.style.setProperty("--hcm-highlight-selected-filter",t.filterFactory.addHighlightHCMFilter("highlight_selected","CanvasText","Canvas","HighlightText","ButtonText")));for(let A=1;A<=e;++A){const v=new jn({container:m,eventBus:r,id:A,scale:w,defaultViewport:y.clone(),optionalContentConfigPromise:s,renderingQueue:this.renderingQueue,textLayerMode:b,annotationMode:g,imageResourcesPath:this.imageResourcesPath,maxCanvasPixels:this.maxCanvasPixels,pageColors:a,l10n:this.l10n,layerProperties:this._layerProperties,enableHWA:this.#c});this._pages.push(v)}this._pages[0]?.setPdfPage(u),this._scrollMode===U.PAGE?this.#M():this._spreadMode!==at.NONE&&this._updateSpreadMode(),this.#P(h).then(async()=>{if(t!==this.pdfDocument)return;if(this.findController?.setDocument(t),this._scriptingManager?.setDocument(t),this.#y&&document.addEventListener("copy",this.#I.bind(this,b),{signal:h}),this.#r&&r.dispatch("annotationeditormodechanged",{source:this,mode:this.#s}),t.loadingParams.disableAutoFetch||e>Be.FORCE_LAZY_PAGE_INIT){this._pagesCapability.resolve();return}let A=e-1;if(A<=0){this._pagesCapability.resolve();return}for(let v=2;v<=e;++v){const C=t.getPage(v).then(x=>{const T=this._pages[v-1];T.pdfPage||T.setPdfPage(x),--A===0&&this._pagesCapability.resolve()},x=>{console.error(`Unable to get page ${v} to initialize viewer`,x),--A===0&&this._pagesCapability.resolve()});v%Be.PAUSE_EAGER_PAGE_INIT===0&&await C}}),r.dispatch("pagesinit",{source:this}),t.getMetadata().then(({info:A})=>{t===this.pdfDocument&&A.Language&&(o.lang=A.Language)}),this.defaultRenderingQueue&&this.update()}).catch(u=>{console.error("Unable to initialize viewer",u),this._pagesCapability.reject(u)})}setPageLabels(t){if(this.pdfDocument){t?Array.isArray(t)&&this.pdfDocument.numPages===t.length?this._pageLabels=t:(this._pageLabels=null,console.error("setPageLabels: Invalid page labels.")):this._pageLabels=null;for(let e=0,i=this._pages.length;e<i;e++)this._pages[e].setPageLabel(this._pageLabels?.[e]??null)}}_resetView(){this._pages=[],this._currentPageNumber=1,this._currentScale=di,this._currentScaleValue=null,this._pageLabels=null,this.#t=new Ql(Ys),this._location=null,this._pagesRotation=0,this._optionalContentConfigPromise=null,this._firstPageCapability=Promise.withResolvers(),this._onePageRenderedCapability=Promise.withResolvers(),this._pagesCapability=Promise.withResolvers(),this._scrollMode=U.VERTICAL,this._previousScrollMode=U.UNKNOWN,this._spreadMode=at.NONE,this.#S={previousPageNumber:1,scrollDown:!0,pages:[]},this.#o?.abort(),this.#o=null,this.viewer.textContent="",this._updateScrollMode(),this.viewer.removeAttribute("lang"),this.#y?.remove(),this.#y=null,this.#R()}#M(){if(this._scrollMode!==U.PAGE)throw new Error("#ensurePageViewVisible: Invalid scrollMode value.");const t=this._currentPageNumber,e=this.#S,i=this.viewer;if(i.textContent="",e.pages.length=0,this._spreadMode===at.NONE&&!this.isInPresentationMode){const s=this._pages[t-1];i.append(s.div),e.pages.push(s)}else{const s=new Set,n=this._spreadMode-1;n===-1?s.add(t-1):t%2!==n?(s.add(t-1),s.add(t)):(s.add(t-2),s.add(t-1));const r=document.createElement("div");if(r.className="spread",this.isInPresentationMode){const a=document.createElement("div");a.className="dummyPage",r.append(a)}for(const a of s){const o=this._pages[a];o&&(r.append(o.div),e.pages.push(o))}i.append(r)}e.scrollDown=t>=e.previousPageNumber,e.previousPageNumber=t}_scrollUpdate(){this.pagesCount!==0&&this.update()}#D(t,e=null){const{div:i,id:s}=t;if(this._currentPageNumber!==s&&this._setCurrentPageNumber(s),this._scrollMode===U.PAGE&&(this.#M(),this.update()),!e&&!this.isInPresentationMode){const n=i.offsetLeft+i.clientLeft,r=n+i.clientWidth,{scrollLeft:a,clientWidth:o}=this.container;(this._scrollMode===U.HORIZONTAL||n<a||r>a+o)&&(e={left:0,top:0})}Rn(i,e),!this._currentScaleValue&&this._location&&(this._location=null)}#C(t){return t===this._currentScale||Math.abs(t-this._currentScale)<1e-15}#_(t,e,{noScroll:i=!1,preset:s=!1,drawingDelay:n=-1,origin:r=null}){if(this._currentScaleValue=e.toString(),this.#C(t)){s&&this.eventBus.dispatch("scalechanging",{source:this,scale:t,presetValue:e});return}this.viewer.style.setProperty("--scale-factor",t*Dt.PDF_TO_CSS_UNITS);const a=n>=0&&n<1e3;this.refresh(!0,{scale:t,drawingDelay:a?n:-1}),a&&(this.#x=setTimeout(()=>{this.#x=null,this.refresh()},n));const o=this._currentScale;if(this._currentScale=t,!i){let h=this._currentPageNumber,c;if(this._location&&!(this.isInPresentationMode||this.isChangingPresentationMode)&&(h=this._location.pageNumber,c=[null,{name:"XYZ"},this._location.left,this._location.top,null]),this.scrollPageIntoView({pageNumber:h,destArray:c,allowNegativeOffset:!0}),Array.isArray(r)){const d=t/o-1,[u,f]=this.containerTopLeft;this.container.scrollLeft+=(r[0]-f)*d,this.container.scrollTop+=(r[1]-u)*d}}this.eventBus.dispatch("scalechanging",{source:this,scale:t,presetValue:s?e:void 0}),this.defaultRenderingQueue&&this.update()}get#F(){return this._spreadMode!==at.NONE&&this._scrollMode!==U.HORIZONTAL?2:1}#k(t,e){let i=parseFloat(t);if(i>0)e.preset=!1,this.#_(i,t,e);else{const s=this._pages[this._currentPageNumber-1];if(!s)return;let n=ws,r=As;this.isInPresentationMode?(n=r=4,this._spreadMode!==at.NONE&&(n*=2)):this.removePageBorders?n=r=0:this._scrollMode===U.HORIZONTAL&&([n,r]=[r,n]);const a=(this.container.clientWidth-n)/s.width*s.scale/this.#F,o=(this.container.clientHeight-r)/s.height*s.scale;switch(t){case"page-actual":i=1;break;case"page-width":i=a;break;case"page-height":i=o;break;case"page-fit":i=Math.min(a,o);break;case"auto":const h=Es(s)?a:Math.min(o,a);i=Math.min(Ga,h);break;default:console.error(`#setScale: "${t}" is an unknown zoom value.`);return}e.preset=!0,this.#_(i,t,e)}}#H(){const t=this._pages[this._currentPageNumber-1];this.isInPresentationMode&&this.#k(this._currentScaleValue,{noScroll:!0}),this.#D(t)}pageLabelToPageNumber(t){if(!this._pageLabels)return null;const e=this._pageLabels.indexOf(t);return e<0?null:e+1}scrollPageIntoView({pageNumber:t,destArray:e=null,allowNegativeOffset:i=!1,ignoreDestinationZoom:s=!1}){if(!this.pdfDocument)return;const n=Number.isInteger(t)&&this._pages[t-1];if(!n){console.error(`scrollPageIntoView: "${t}" is not a valid pageNumber parameter.`);return}if(this.isInPresentationMode||!e){this._setCurrentPageNumber(t,!0);return}let r=0,a=0,o=0,h=0,c,d;const u=n.rotation%180!==0,f=(u?n.height:n.width)/n.scale/Dt.PDF_TO_CSS_UNITS,p=(u?n.width:n.height)/n.scale/Dt.PDF_TO_CSS_UNITS;let g=0;switch(e[1].name){case"XYZ":r=e[2],a=e[3],g=e[4],r=r!==null?r:0,a=a!==null?a:p;break;case"Fit":case"FitB":g="page-fit";break;case"FitH":case"FitBH":a=e[2],g="page-width",a===null&&this._location?(r=this._location.left,a=this._location.top):(typeof a!="number"||a<0)&&(a=p);break;case"FitV":case"FitBV":r=e[2],o=f,h=p,g="page-height";break;case"FitR":r=e[2],a=e[3],o=e[4]-r,h=e[5]-a;let y=ws,A=As;this.removePageBorders&&(y=A=0),c=(this.container.clientWidth-y)/o/Dt.PDF_TO_CSS_UNITS,d=(this.container.clientHeight-A)/h/Dt.PDF_TO_CSS_UNITS,g=Math.min(Math.abs(c),Math.abs(d));break;default:console.error(`scrollPageIntoView: "${e[1].name}" is not a valid destination type.`);return}if(s||(g&&g!==this._currentScale?this.currentScaleValue=g:this._currentScale===di&&(this.currentScaleValue=Ua)),g==="page-fit"&&!e[4]){this.#D(n);return}const b=[n.viewport.convertToViewportPoint(r,a),n.viewport.convertToViewportPoint(r+o,a+h)];let m=Math.min(b[0][0],b[1][0]),w=Math.min(b[0][1],b[1][1]);i||(m=Math.max(m,0),w=Math.max(w,0)),this.#D(n,{left:m,top:w})}_updateLocation(t){const e=this._currentScale,i=this._currentScaleValue,s=parseFloat(i)===e?Math.round(e*1e4)/100:i,n=t.id,r=this._pages[n-1],a=this.container,o=r.getPagePoint(a.scrollLeft-t.x,a.scrollTop-t.y),h=Math.round(o[0]),c=Math.round(o[1]);let d=`#page=${n}`;this.isInPresentationMode||(d+=`&zoom=${s},${h},${c}`),this._location={pageNumber:n,scale:s,top:c,left:h,rotation:this._pagesRotation,pdfOpenParams:d}}update(){const t=this._getVisiblePages(),e=t.views,i=e.length;if(i===0)return;const s=Math.max(Ys,2*i+1);this.#t.resize(s,t.ids),this.renderingQueue.renderHighestPriority(t);const n=this._spreadMode===at.NONE&&(this._scrollMode===U.PAGE||this._scrollMode===U.VERTICAL),r=this._currentPageNumber;let a=!1;for(const o of e){if(o.percent<100)break;if(o.id===r&&n){a=!0;break}}this._setCurrentPageNumber(a?r:e[0].id),this._updateLocation(t.first),this.eventBus.dispatch("updateviewarea",{source:this,location:this._location})}#U(){const t=this._getVisiblePages(),e=[],{ids:i,views:s}=t;for(const n of s){const{view:r}=n;if(!r.hasEditableAnnotations()){i.delete(r.id);continue}e.push(n)}return e.length===0?null:(this.renderingQueue.renderHighestPriority({first:e[0],last:e.at(-1),views:e,ids:i}),i)}containsElement(t){return this.container.contains(t)}focus(){this.container.focus()}get _isContainerRtl(){return getComputedStyle(this.container).direction==="rtl"}get isInPresentationMode(){return this.presentationModeState===ie.FULLSCREEN}get isChangingPresentationMode(){return this.presentationModeState===ie.CHANGING}get isHorizontalScrollbarEnabled(){return this.isInPresentationMode?!1:this.container.scrollWidth>this.container.clientWidth}get isVerticalScrollbarEnabled(){return this.isInPresentationMode?!1:this.container.scrollHeight>this.container.clientHeight}_getVisiblePages(){const t=this._scrollMode===U.PAGE?this.#S.pages:this._pages,e=this._scrollMode===U.HORIZONTAL,i=e&&this._isContainerRtl;return Ya({scrollEl:this.container,views:t,sortByVisibility:!0,horizontal:e,rtl:i})}cleanup(){for(const t of this._pages)t.renderingState!==q.FINISHED&&t.reset()}_cancelRendering(){for(const t of this._pages)t.cancelRendering()}async#j(t){if(t.pdfPage)return t.pdfPage;try{const e=await this.pdfDocument.getPage(t.id);return t.pdfPage||t.setPdfPage(e),e}catch(e){return console.error("Unable to get page for page view",e),null}}#O(t){if(t.first?.id===1)return!0;if(t.last?.id===this.pagesCount)return!1;switch(this._scrollMode){case U.PAGE:return this.#S.scrollDown;case U.HORIZONTAL:return this.scroll.right}return this.scroll.down}forceRendering(t){const e=t||this._getVisiblePages(),i=this.#O(e),s=this._spreadMode!==at.NONE&&this._scrollMode!==U.HORIZONTAL,n=this.renderingQueue.getHighestPriority(e,this._pages,i,s);return n?(this.#j(n).then(()=>{this.renderingQueue.renderView(n)}),!0):!1}get hasEqualPageSizes(){const t=this._pages[0];for(let e=1,i=this._pages.length;e<i;++e){const s=this._pages[e];if(s.width!==t.width||s.height!==t.height)return!1}return!0}getPagesOverview(){let t;return this._pages.map(e=>{const i=e.pdfPage.getViewport({scale:1}),s=Es(i);if(t===void 0)t=s;else if(this.enablePrintAutoRotate&&s!==t)return{width:i.height,height:i.width,rotation:(i.rotation-90)%360};return{width:i.width,height:i.height,rotation:i.rotation}})}get optionalContentConfigPromise(){return this.pdfDocument?this._optionalContentConfigPromise?this._optionalContentConfigPromise:(console.error("optionalContentConfigPromise: Not initialized yet."),this.pdfDocument.getOptionalContentConfig({intent:"display"})):Promise.resolve(null)}set optionalContentConfigPromise(t){if(!(t instanceof Promise))throw new Error(`Invalid optionalContentConfigPromise: ${t}`);this.pdfDocument&&this._optionalContentConfigPromise&&(this._optionalContentConfigPromise=t,this.refresh(!1,{optionalContentConfigPromise:t}),this.eventBus.dispatch("optionalcontentconfigchanged",{source:this,promise:t}))}get scrollMode(){return this._scrollMode}set scrollMode(t){if(this._scrollMode!==t){if(!Ka(t))throw new Error(`Invalid scroll mode: ${t}`);this.pagesCount>Be.FORCE_SCROLL_MODE_PAGE||(this._previousScrollMode=this._scrollMode,this._scrollMode=t,this.eventBus.dispatch("scrollmodechanged",{source:this,mode:t}),this._updateScrollMode(this._currentPageNumber))}}_updateScrollMode(t=null){const e=this._scrollMode,i=this.viewer;i.classList.toggle("scrollHorizontal",e===U.HORIZONTAL),i.classList.toggle("scrollWrapped",e===U.WRAPPED),!(!this.pdfDocument||!t)&&(e===U.PAGE?this.#M():this._previousScrollMode===U.PAGE&&this._updateSpreadMode(),this._currentScaleValue&&isNaN(this._currentScaleValue)&&this.#k(this._currentScaleValue,{noScroll:!0}),this._setCurrentPageNumber(t,!0),this.update())}get spreadMode(){return this._spreadMode}set spreadMode(t){if(this._spreadMode!==t){if(!Qa(t))throw new Error(`Invalid spread mode: ${t}`);this._spreadMode=t,this.eventBus.dispatch("spreadmodechanged",{source:this,mode:t}),this._updateSpreadMode(this._currentPageNumber)}}_updateSpreadMode(t=null){if(!this.pdfDocument)return;const e=this.viewer,i=this._pages;if(this._scrollMode===U.PAGE)this.#M();else if(e.textContent="",this._spreadMode===at.NONE)for(const s of this._pages)e.append(s.div);else{const s=this._spreadMode-1;let n=null;for(let r=0,a=i.length;r<a;++r)n===null?(n=document.createElement("div"),n.className="spread",e.append(n)):r%2===s&&(n=n.cloneNode(!1),e.append(n)),n.append(i[r].div)}t&&(this._currentScaleValue&&isNaN(this._currentScaleValue)&&this.#k(this._currentScaleValue,{noScroll:!0}),this._setCurrentPageNumber(t,!0),this.update())}_getPageAdvance(t,e=!1){switch(this._scrollMode){case U.WRAPPED:{const{views:i}=this._getVisiblePages(),s=new Map;for(const{id:n,y:r,percent:a,widthPercent:o}of i){if(a===0||o<100)continue;let h=s.get(r);h||s.set(r,h||=[]),h.push(n)}for(const n of s.values()){const r=n.indexOf(t);if(r===-1)continue;const a=n.length;if(a===1)break;if(e)for(let o=r-1,h=0;o>=h;o--){const c=n[o],d=n[o+1]-1;if(c<d)return t-d}else for(let o=r+1,h=a;o<h;o++){const c=n[o],d=n[o-1]+1;if(c>d)return d-t}if(e){const o=n[0];if(o<t)return t-o+1}else{const o=n[a-1];if(o>t)return o-t+1}break}break}case U.HORIZONTAL:break;case U.PAGE:case U.VERTICAL:{if(this._spreadMode===at.NONE)break;const i=this._spreadMode-1;if(e&&t%2!==i)break;if(!e&&t%2===i)break;const{views:s}=this._getVisiblePages(),n=e?t-1:t+1;for(const{id:r,percent:a,widthPercent:o}of s)if(r===n){if(a>0&&o===100)return 2;break}break}}return 1}nextPage(){const t=this._currentPageNumber,e=this.pagesCount;if(t>=e)return!1;const i=this._getPageAdvance(t,!1)||1;return this.currentPageNumber=Math.min(t+i,e),!0}previousPage(){const t=this._currentPageNumber;if(t<=1)return!1;const e=this._getPageAdvance(t,!0)||1;return this.currentPageNumber=Math.max(t-e,1),!0}updateScale({drawingDelay:t,scaleFactor:e=null,steps:i=null,origin:s}){if(i===null&&e===null)throw new Error("Invalid updateScale options: either `steps` or `scaleFactor` must be provided.");if(!this.pdfDocument)return;let n=this._currentScale;if(e>0&&e!==1)n=Math.round(n*e*100)/100;else if(i){const r=i>0?ys:1/ys,a=i>0?Math.ceil:Math.floor;i=Math.abs(i);do n=a((n*r).toFixed(2)*10)/10;while(--i>0)}n=Math.max(za,Math.min(Wa,n)),this.#k(n,{noScroll:!1,drawingDelay:t,origin:s})}increaseScale(t={}){this.updateScale({...t,steps:t.steps??1})}decreaseScale(t={}){this.updateScale({...t,steps:-(t.steps??1)})}#B(t=this.container.clientHeight){t!==this.#A&&(this.#A=t,Za.setProperty("--viewer-container-height",`${t}px`))}#z(t){for(const e of t)if(e.target===this.container){this.#B(Math.floor(e.borderBoxSize[0].blockSize)),this.#a=null;break}}get containerTopLeft(){return this.#a||=[this.container.offsetTop,this.container.offsetLeft]}#R(){this.#m?.abort(),this.#m=null,this.#g!==null&&(clearTimeout(this.#g),this.#g=null)}get annotationEditorMode(){return this.#r?this.#s:bt.DISABLE}set annotationEditorMode({mode:t,editId:e=null,isFromKeyboard:i=!1}){if(!this.#r)throw new Error("The AnnotationEditor is not enabled.");if(this.#s===t)return;if(!Ks(t))throw new Error(`Invalid AnnotationEditor mode: ${t}`);if(!this.pdfDocument)return;t===bt.STAMP&&this.#p?.loadModel("altText");const{eventBus:s}=this,n=()=>{this.#R(),this.#s=t,this.#r.updateMode(t,e,i),s.dispatch("annotationeditormodechanged",{source:this,mode:t})};if(t===bt.NONE||this.#s===bt.NONE){const r=t!==bt.NONE;r||this.pdfDocument.annotationStorage.resetModifiedIds();for(const o of this._pages)o.toggleEditingMode(r);const a=this.#U();if(r&&a){this.#R(),this.#m=new AbortController;const o=AbortSignal.any([this.#o.signal,this.#m.signal]);s._on("pagerendered",({pageNumber:h})=>{a.delete(h),a.size===0&&(this.#g=setTimeout(n,0))},{signal:o});return}}n()}refresh(t=!1,e=Object.create(null)){if(this.pdfDocument){for(const i of this._pages)i.update(e);this.#x!==null&&(clearTimeout(this.#x),this.#x=null),t||this.update()}}}class Zl extends Hn{_resetView(){super._resetView(),this._scrollMode=U.PAGE,this._spreadMode=at.NONE}set scrollMode(t){}_updateScrollMode(){}set spreadMode(t){}_updateSpreadMode(){}}var Jl=X.AnnotationLayerBuilder,th=X.DownloadManager,eh=X.EventBus,ih=X.FindState,sh=X.GenericL10n,nh=X.LinkTarget,rh=X.PDFFindController,ah=X.PDFHistory,oh=X.PDFLinkService,lh=X.PDFPageView,hh=X.PDFScriptingManager,ch=X.PDFSinglePageViewer,dh=X.PDFViewer,uh=X.ProgressBar,fh=X.RenderingStates,ph=X.ScrollMode,gh=X.SimpleLinkService,mh=X.SpreadMode,bh=X.StructTreeLayerBuilder,yh=X.TextLayerBuilder,wh=X.XfaLayerBuilder,Ah=X.parseQueryString;const oc=Object.freeze(Object.defineProperty({__proto__:null,AnnotationLayerBuilder:Jl,DownloadManager:th,EventBus:eh,FindState:ih,GenericL10n:sh,LinkTarget:nh,PDFFindController:rh,PDFHistory:ah,PDFLinkService:oh,PDFPageView:lh,PDFScriptingManager:hh,PDFSinglePageViewer:ch,PDFViewer:dh,ProgressBar:uh,RenderingStates:fh,ScrollMode:ph,SimpleLinkService:gh,SpreadMode:mh,StructTreeLayerBuilder:bh,TextLayerBuilder:yh,XfaLayerBuilder:wh,parseQueryString:Ah},Symbol.toStringTag,{value:"Module"}));export{Fh as _,Oh as a,oc as b,_h as p};
|