@seqyuan/annovibe 0.8.13 → 0.8.15
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/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +5 -4
- package/.next/build-manifest.json +3 -3
- package/.next/prerender-manifest.json +3 -3
- package/.next/react-loadable-manifest.json +6 -6
- package/.next/required-server-files.js +1 -1
- package/.next/required-server-files.json +1 -1
- package/.next/routes-manifest.json +6 -0
- package/.next/server/app/_global-error/page.js +3 -3
- package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page.js +2 -2
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +1 -1
- package/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/api/agent/[id]/events/route.js +2 -2
- package/.next/server/app/api/agent/[id]/route.js +1 -1
- package/.next/server/app/api/agent/new/route.js +1 -1
- package/.next/server/app/api/auth/all-providers/route.js +1 -1
- package/.next/server/app/api/auth/api-key/[provider]/route.js +1 -1
- package/.next/server/app/api/auth/login/[provider]/route.js +2 -2
- package/.next/server/app/api/auth/login/route.js +1 -1
- package/.next/server/app/api/auth/logout/[provider]/route.js +1 -1
- package/.next/server/app/api/auth/providers/route.js +1 -1
- package/.next/server/app/api/auth/status/route.js +1 -1
- package/.next/server/app/api/default-cwd/route.js +1 -1
- package/.next/server/app/api/files/[...path]/route.js +2 -2
- package/.next/server/app/api/harness/route.js +1 -1
- package/.next/server/app/api/home/route.js +1 -1
- package/.next/server/app/api/internal/runtime/route.js +1 -0
- package/.next/server/app/api/internal/runtime/route.js.nft.json +1 -0
- package/.next/server/app/api/internal/runtime/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/models/route.js +1 -1
- package/.next/server/app/api/models-config/discover/route.js +1 -1
- package/.next/server/app/api/models-config/route.js +1 -1
- package/.next/server/app/api/models-config/test/route.js +1 -1
- package/.next/server/app/api/plot-kernels/route.js +1 -1
- package/.next/server/app/api/plot-kernels/status/route.js +1 -1
- package/.next/server/app/api/plot-kernels/stop/route.js +1 -1
- package/.next/server/app/api/projects/browse/route.js +1 -1
- package/.next/server/app/api/projects/route.js +2 -2
- package/.next/server/app/api/reports/[id]/route.js +7 -4
- package/.next/server/app/api/search/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/context/route.js +2 -2
- package/.next/server/app/api/sessions/[id]/route.js +1 -1
- package/.next/server/app/api/sessions/new/route.js +1 -1
- package/.next/server/app/api/sessions/route.js +2 -2
- package/.next/server/app/api/settings/route.js +1 -1
- package/.next/server/app/api/skills/install/route.js +1 -1
- package/.next/server/app/api/skills/route.js +2 -2
- package/.next/server/app/api/skills/search/route.js +1 -1
- package/.next/server/app/api/soul/route.js +1 -1
- package/.next/server/app/api/version/route.js +1 -1
- package/.next/server/app/favicon.ico/route.js +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +2 -2
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/index.segments/_full.segment.rsc +2 -2
- package/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/login/page.js +2 -2
- package/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/.next/server/app/login.html +1 -1
- package/.next/server/app/login.rsc +1 -1
- package/.next/server/app/login.segments/_full.segment.rsc +1 -1
- package/.next/server/app/login.segments/_head.segment.rsc +1 -1
- package/.next/server/app/login.segments/_index.segment.rsc +1 -1
- package/.next/server/app/login.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/login.segments/login/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/login.segments/login.segment.rsc +1 -1
- package/.next/server/app/page.js +13 -13
- package/.next/server/app/page.js.nft.json +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +5 -4
- package/.next/server/chunks/1688.js +45 -0
- package/.next/server/chunks/7601.js +18 -9
- package/.next/server/chunks/static/media/pdf.worker.min.c476e1a0.mjs +6 -0
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/51fb665c.9f0b013f33bf4f6d.js +45 -0
- package/.next/static/chunks/8771-3e14b6810486df1f.js +1 -0
- package/.next/static/chunks/app/_global-error/page-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/agent/[id]/events/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/agent/[id]/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/agent/new/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/auth/all-providers/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/auth/api-key/[provider]/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/auth/login/[provider]/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/auth/login/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/auth/logout/[provider]/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/auth/providers/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/auth/status/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/default-cwd/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/files/[...path]/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/harness/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/home/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/internal/runtime/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/models/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/models-config/discover/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/models-config/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/models-config/test/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/plot-kernels/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/plot-kernels/status/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/plot-kernels/stop/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/projects/browse/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/projects/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/reports/[id]/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/search/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/context/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/sessions/new/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/sessions/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/settings/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/skills/install/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/skills/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/skills/search/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/soul/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/api/version/route-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/app/page-2b9d326c910bfdb1.js +270 -0
- package/.next/static/chunks/next/dist/client/components/builtin/app-error-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/forbidden-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/not-found-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-7222ee8be0d45596.js +1 -0
- package/.next/static/chunks/{webpack-5e677f60fa366b60.js → webpack-c223a77d0c5e1b9e.js} +1 -1
- package/.next/static/media/pdf.worker.min.29aaf158.mjs +6 -0
- package/.next/static/sll--ryodjD6y3JTZNo1d/_buildManifest.js +1 -0
- package/.next/trace +75 -74
- package/.next/trace-build +1 -1
- package/.next/types/app/api/internal/runtime/route.ts +351 -0
- package/.next/types/routes.d.ts +2 -1
- package/.next/types/validator.ts +9 -0
- package/README.md +2 -0
- package/bin/pi-web.js +293 -16
- package/package.json +1 -1
- package/.next/server/chunks/7270.js +0 -45
- package/.next/server/chunks/static/media/pdf.worker.min.9df6854a.mjs +0 -6
- package/.next/static/Vs4orkHEELAXCLtGxeeGM/_buildManifest.js +0 -1
- package/.next/static/chunks/7355-29eaa714eb390050.js +0 -1
- package/.next/static/chunks/9b0008ae.2918095672924572.js +0 -45
- package/.next/static/chunks/app/_global-error/page-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/agent/[id]/events/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/agent/[id]/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/agent/new/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/auth/all-providers/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/auth/api-key/[provider]/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/auth/login/[provider]/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/auth/login/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/auth/logout/[provider]/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/auth/providers/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/auth/status/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/default-cwd/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/files/[...path]/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/harness/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/home/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/models/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/models-config/discover/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/models-config/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/models-config/test/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/plot-kernels/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/plot-kernels/status/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/plot-kernels/stop/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/projects/browse/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/projects/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/reports/[id]/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/search/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/sessions/[id]/context/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/sessions/[id]/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/sessions/new/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/sessions/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/settings/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/skills/install/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/skills/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/skills/search/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/soul/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/api/version/route-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/app/page-7d26edc81d575249.js +0 -270
- package/.next/static/chunks/next/dist/client/components/builtin/app-error-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/forbidden-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/not-found-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-be3bd0fd0e2e6ad6.js +0 -1
- package/.next/static/media/pdf.worker.min.5f98222a.mjs +0 -6
- /package/.next/static/{Vs4orkHEELAXCLtGxeeGM → sll--ryodjD6y3JTZNo1d}/_ssgManifest.js +0 -0
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2084],{66898:(t,e,i)=>{i.r(e),i.d(e,{AbortException:()=>L,AnnotationEditorLayer:()=>sN,AnnotationEditorParamsType:()=>p,AnnotationEditorType:()=>u,AnnotationEditorUIManager:()=>tN,AnnotationLayer:()=>sm,AnnotationMode:()=>d,AnnotationType:()=>f,CSSConstants:()=>tv,ColorPicker:()=>i$,DOMSVGFactory:()=>iq,DrawLayer:()=>sU,FeatureTest:()=>O,GlobalWorkerOptions:()=>ix,ImageKind:()=>m,InvalidPDFException:()=>I,MathClamp:()=>X,OPS:()=>y,OutputScale:()=>tf,PDFDataRangeTransport:()=>iB,PDFDateString:()=>th,PDFWorker:()=>iR,PasswordResponses:()=>v,PermissionFlag:()=>g,PixelsPerInch:()=>Q,RenderingCancelledException:()=>tt,ResponseException:()=>B,SignatureExtractor:()=>sB,SupportedImageMimeTypes:()=>tb,TextLayer:()=>ik,TextLayerImages:()=>sz,TouchManager:()=>tz,Util:()=>N,VerbosityLevel:()=>b,XfaLayer:()=>K,applyOpacity:()=>tA,build:()=>iz,createValidAbsoluteUrl:()=>T,fetchData:()=>J,findContrastColor:()=>tS,getDocument:()=>iD,getFilenameFromUrl:()=>ts,getPdfFilenameFromUrl:()=>tr,getRGB:()=>tu,getRGBA:()=>tc,getUuid:()=>$,getXfaPageViewport:()=>td,isDataScheme:()=>te,isPdfFile:()=>ti,isValidExplicitDest:()=>em,makeArr:()=>j,makeMap:()=>V,makeObj:()=>W,noContextMenu:()=>to,normalizeUnicode:()=>z,renderRichText:()=>tE,setLayerDimensions:()=>tm,shadow:()=>M,stopEvent:()=>tl,updateUrlHash:()=>S,version:()=>iH});var s=i(41463),r=i(92619).Buffer,a={};a.d=(t,e)=>{for(var i in e)a.o(e,i)&&!a.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},a.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let n="object"==typeof s&&s+""=="[object process]"&&!s.versions.nw&&!(s.versions.electron&&s.type&&"browser"!==s.type),o=[1/0,1/0,-1/0,-1/0],l=new Float32Array(o),h=[.001,0,0,.001,0,0],d={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},c="pdfjs_internal_editor_",u={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},p={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,INK_COLOR_AND_OPACITY:24,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},g={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},m={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},f={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,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26},b={ERRORS:0,WARNINGS:1,INFOS:5},y={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,rawFillPath:94},v={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},A=b.WARNINGS;function x(t){A>=b.INFOS&&console.info(`Info: ${t}`)}function w(t){A>=b.WARNINGS&&console.warn(`Warning: ${t}`)}function _(t){throw Error(t)}function C(t,e){t||_(e)}function T(t,e=null,i=null){if(!t)return null;if(i&&"string"==typeof t){if(i.addDefaultProtocol&&t.startsWith("www.")){let e=t.match(/\./g);e?.length>=2&&(t=`http://${t}`)}if(i.tryConvertEncoding)try{var s;s=t,t=decodeURIComponent(escape(s))}catch{}}let r=e?URL.parse(t,e):URL.parse(t);return!function(t){switch(t?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(r)?null:r}function S(t,e,i=!1){let s=URL.parse(t);return s?(s.hash=e,s.href):i&&T(t,"http://example.com")?t.split("#",1)[0]+`${e?`#${e}`:""}`:""}function E(t){return t.substring(t.lastIndexOf("/")+1)}function M(t,e,i,s=!1){return Object.defineProperty(t,e,{value:i,enumerable:!s,configurable:!0,writable:!1}),i}let P=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=Error(),t.constructor=t,t}();class k extends P{constructor(t,e){super(t,"PasswordException"),this.code=e}}class D extends P{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class I extends P{constructor(t){super(t,"InvalidPDFException")}}class B extends P{constructor(t,e,i){super(t,"ResponseException"),this.status=e,this.missing=i}}class F extends P{constructor(t){super(t,"FormatError")}}class L extends P{constructor(t){super(t,"AbortException")}}function R(t){"string"!=typeof t&&_("Invalid argument for stringToBytes");let e=t.length,i=new Uint8Array(e);for(let s=0;s<e;++s)i[s]=255&t.charCodeAt(s);return i}class O{static get isLittleEndian(){let t;return M(this,"isLittleEndian",((t=new Uint8Array(4))[0]=1,1===new Uint32Array(t.buffer,0,1)[0]))}static get isOffscreenCanvasSupported(){return M(this,"isOffscreenCanvasSupported","u">typeof OffscreenCanvas)}static get isImageDecoderSupported(){return M(this,"isImageDecoderSupported","u">typeof ImageDecoder)}static get isFloat16ArraySupported(){return M(this,"isFloat16ArraySupported","u">typeof Float16Array)}static get isSanitizerSupported(){return M(this,"isSanitizerSupported","u">typeof Sanitizer)}static get platform(){let{platform:t,userAgent:e}=navigator;return M(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCSSRoundSupported(){return M(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}static get isAlphaColorInputSupported(){return M(this,"isAlphaColorInputSupported",(()=>{if("u"<typeof document)return!1;let t=document.createElement("input");return t.type="color",t.setAttribute("alpha",""),t.value="#ff000080","#ff0000"!==t.value})())}}class N{static get hexNums(){return M(this,"hexNums",Array.from(Array(256).keys(),t=>t.toString(16).padStart(2,"0")))}static makeHexColor(t,e,i){return`#${this.hexNums[t]}${this.hexNums[e]}${this.hexNums[i]}`}static domMatrixToTransform(t){return[t.a,t.b,t.c,t.d,t.e,t.f]}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 multiplyByDOMMatrix(t,e){return[t[0]*e.a+t[2]*e.b,t[1]*e.a+t[3]*e.b,t[0]*e.c+t[2]*e.d,t[1]*e.c+t[3]*e.d,t[0]*e.e+t[2]*e.f+t[4],t[1]*e.e+t[3]*e.f+t[5]]}static applyTransform(t,e,i=0){let s=t[i],r=t[i+1];t[i]=s*e[0]+r*e[2]+e[4],t[i+1]=s*e[1]+r*e[3]+e[5]}static applyTransformToBezier(t,e,i=0){let s=e[0],r=e[1],a=e[2],n=e[3],o=e[4],l=e[5];for(let e=0;e<6;e+=2){let h=t[i+e],d=t[i+e+1];t[i+e]=h*s+d*a+o,t[i+e+1]=h*r+d*n+l}}static applyInverseTransform(t,e){let i=t[0],s=t[1],r=e[0]*e[3]-e[1]*e[2];t[0]=(i*e[3]-s*e[2]+e[2]*e[5]-e[4]*e[3])/r,t[1]=(-i*e[1]+s*e[0]+e[4]*e[1]-e[5]*e[0])/r}static axialAlignedBoundingBox(t,e,i){let s=e[0],r=e[1],a=e[2],n=e[3],o=e[4],l=e[5],h=t[0],d=t[1],c=t[2],u=t[3],p=s*h+o,g=p,m=s*c+o,f=m,b=n*d+l,y=b,v=n*u+l,A=v;if(0!==r||0!==a){let t=r*h,e=r*c,i=a*d,s=a*u;p+=i,f+=i,m+=s,g+=s,b+=t,A+=t,v+=e,y+=e}i[0]=Math.min(i[0],p,m,g,f),i[1]=Math.min(i[1],b,v,y,A),i[2]=Math.max(i[2],p,m,g,f),i[3]=Math.max(i[3],b,v,y,A)}static inverseTransform(t){let 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,e){let i=t[0],s=t[1],r=t[2],a=t[3],n=i**2+s**2,o=r**2+a**2,l=(n+o)/2,h=Math.sqrt(l**2-(n*o-(i*r+s*a)**2));e[0]=Math.sqrt(l+h||1),e[1]=Math.sqrt(l-h||1)}static normalizeRect(t){let 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){let 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;let r=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),a=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return r>a?null:[i,r,s,a]}static pointBoundingBox(t,e,i){i[0]=Math.min(i[0],t),i[1]=Math.min(i[1],e),i[2]=Math.max(i[2],t),i[3]=Math.max(i[3],e)}static rectBoundingBox(t,e,i,s,r){r[0]=Math.min(r[0],t,i),r[1]=Math.min(r[1],e,s),r[2]=Math.max(r[2],t,i),r[3]=Math.max(r[3],e,s)}static #t(t,e,i,s,r,a,n,o,l,h){if(l<=0||l>=1)return;let d=1-l,c=l*l,u=c*l,p=d*(d*(d*t+3*l*e)+3*c*i)+u*s,g=d*(d*(d*r+3*l*a)+3*c*n)+u*o;h[0]=Math.min(h[0],p),h[1]=Math.min(h[1],g),h[2]=Math.max(h[2],p),h[3]=Math.max(h[3],g)}static #e(t,e,i,s,r,a,n,o,l,h,d,c){if(1e-12>Math.abs(l)){Math.abs(h)>=1e-12&&this.#t(t,e,i,s,r,a,n,o,-d/h,c);return}let u=h**2-4*d*l;if(u<0)return;let p=Math.sqrt(u),g=2*l;this.#t(t,e,i,s,r,a,n,o,(-h+p)/g,c),this.#t(t,e,i,s,r,a,n,o,(-h-p)/g,c)}static bezierBoundingBox(t,e,i,s,r,a,n,o,l){l[0]=Math.min(l[0],t,n),l[1]=Math.min(l[1],e,o),l[2]=Math.max(l[2],t,n),l[3]=Math.max(l[3],e,o),this.#e(t,i,r,n,e,s,a,o,3*(-t+3*(i-r)+n),6*(t-2*i+r),3*(i-t),l),this.#e(t,i,r,n,e,s,a,o,3*(-e+3*(s-a)+o),6*(e-2*s+a),3*(s-e),l)}}let U=null,H=null;function z(t){return U||(U=/([\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,H=new Map([["ſt","ſt"]])),t.replaceAll(U,(t,e,i)=>e?e.normalize("NFKC"):H.get(i))}function $(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();let t=new Uint8Array(32);return crypto.getRandomValues(t),function(t){("object"!=typeof t||t?.length===void 0)&&_("Invalid argument for bytesToString");let e=t.length;if(e<8192)return String.fromCharCode.apply(null,t);let i=[];for(let s=0;s<e;s+=8192){let r=Math.min(s+8192,e),a=t.subarray(s,r);i.push(String.fromCharCode.apply(null,a))}return i.join("")}(t)}let G="pdfjs_internal_id_",j=()=>[],V=()=>new Map,W=()=>Object.create(null);function X(t,e,i){return Math.min(Math.max(t,e),i)}class q{static textContent(t){let e=[],i={items:e,styles:Object.create(null)};return!function t(i){if(!i)return;let s=null,r=i.name;if("#text"===r)s=i.value;else{if(!q.shouldBuildText(r))return;i?.attributes?.textContent?s=i.attributes.textContent:i.value&&(s=i.value)}if(null!==s&&e.push({str:s}),i.children)for(let e of i.children)t(e)}(t),i}static shouldBuildText(t){return"textarea"!==t&&"input"!==t&&"option"!==t&&"select"!==t}}class K{static setupStorage(t,e,i,s,r){let a=s.getValue(e,{value:null});switch(i.name){case"textarea":if(null!==a.value&&(t.textContent=a.value),"print"===r)break;t.addEventListener("input",t=>{s.setValue(e,{value:t.target.value})});break;case"input":if("radio"===i.attributes.type||"checkbox"===i.attributes.type){if(a.value===i.attributes.xfaOn?t.setAttribute("checked",!0):a.value===i.attributes.xfaOff&&t.removeAttribute("checked"),"print"===r)break;t.addEventListener("change",t=>{s.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})})}else{if(null!==a.value&&t.setAttribute("value",a.value),"print"===r)break;t.addEventListener("input",t=>{s.setValue(e,{value:t.target.value})})}break;case"select":if(null!==a.value)for(let e of(t.setAttribute("value",a.value),i.children))e.attributes.value===a.value?e.attributes.selected=!0:Object.hasOwn(e.attributes,"selected")&&delete e.attributes.selected;t.addEventListener("input",t=>{let i=t.target.options,r=-1===i.selectedIndex?"":i[i.selectedIndex].value;s.setValue(e,{value:r})})}}static setAttributes({html:t,element:e,storage:i=null,intent:s,linkService:r}){let{attributes:a}=e,n=t instanceof HTMLAnchorElement;for(let[e,i]of("radio"===a.type&&(a.name=`${a.name}-${s}`),Object.entries(a)))if(null!=i)switch(e){case"class":i.length&&t.setAttribute(e,i.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",i);break;case"style":Object.assign(t.style,i);break;case"textContent":t.textContent=i;break;default:n&&("href"===e||"newWindow"===e)||t.setAttribute(e,i)}n&&r.addLinkAttributes(t,a.href,a.newWindow),i&&a.dataId&&this.setupStorage(t,a.dataId,e,i)}static render(t){let e=t.annotationStorage,i=t.linkService,s=t.xfaHtml,r=t.intent||"display",a=document.createElement(s.name);s.attributes&&this.setAttributes({html:a,element:s,intent:r,linkService:i});let n="richText"!==r,o=t.div;if(o.append(a),t.viewport){let e=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=e}n&&o.setAttribute("class","xfaLayer xfaFont");let l=[];if(0===s.children.length){if(s.value){let t=document.createTextNode(s.value);a.append(t),n&&q.shouldBuildText(s.name)&&l.push(t)}return{textDivs:l}}let h=[[s,-1,a]];for(;h.length>0;){let[t,s,a]=h.at(-1);if(s+1===t.children.length){h.pop();continue}let o=t.children[++h.at(-1)[1]];if(null===o)continue;let{name:d}=o;if("#text"===d){let t=document.createTextNode(o.value);l.push(t),a.append(t);continue}let c=o?.attributes?.xmlns?document.createElementNS(o.attributes.xmlns,d):document.createElement(d);if(a.append(c),o.attributes&&this.setAttributes({html:c,element:o,storage:e,intent:r,linkService:i}),o.children?.length>0)h.push([o,-1,c]);else if(o.value){let t=document.createTextNode(o.value);n&&q.shouldBuildText(d)&&l.push(t),c.append(t)}}for(let t of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))t.setAttribute("readOnly",!0);return{textDivs:l}}static update(t){let e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}let Y="http://www.w3.org/2000/svg";class Q{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function J(t,e="text"){if(tn(t,document.baseURI)){let i=await fetch(t);if(!i.ok)throw Error(i.statusText);switch(e){case"blob":return i.blob();case"bytes":return i.bytes();case"json":return i.json()}return i.text()}return new Promise((i,s)=>{let r=new XMLHttpRequest;r.open("GET",t,!0),r.responseType="bytes"===e?"arraybuffer":e,r.onreadystatechange=()=>{if(r.readyState===XMLHttpRequest.DONE){if(200===r.status||0===r.status){switch(e){case"bytes":i(new Uint8Array(r.response));return;case"blob":case"json":i(r.response);return}i(r.responseText);return}s(Error(r.statusText))}},r.send(null)})}class Z{constructor({viewBox:t,userUnit:e,scale:i,rotation:s,offsetX:r=0,offsetY:a=0,dontFlip:n=!1}){let o,l,h,d,c,u,p,g;this.viewBox=t,this.userUnit=e,this.scale=i,this.rotation=s,this.offsetX=r,this.offsetY=a,i*=e;const m=(t[2]+t[0])/2,f=(t[3]+t[1])/2;switch((s%=360)<0&&(s+=360),s){case 180:o=-1,l=0,h=0,d=1;break;case 90:o=0,l=1,h=1,d=0;break;case 270:o=0,l=-1,h=-1,d=0;break;case 0:o=1,l=0,h=0,d=-1;break;default:throw Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}n&&(h=-h,d=-d),0===o?(c=Math.abs(f-t[1])*i+r,u=Math.abs(m-t[0])*i+a,p=(t[3]-t[1])*i,g=(t[2]-t[0])*i):(c=Math.abs(m-t[0])*i+r,u=Math.abs(f-t[1])*i+a,p=(t[2]-t[0])*i,g=(t[3]-t[1])*i),this.transform=[o*i,l*i,h*i,d*i,c-o*i*m-h*i*f,u-l*i*m-d*i*f],this.width=p,this.height=g}get rawDims(){let t=this.viewBox;return M(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:i=this.offsetX,offsetY:s=this.offsetY,dontFlip:r=!1}={}){return new Z({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:r})}convertToViewportPoint(t,e){let i=[t,e];return N.applyTransform(i,this.transform),i}convertToViewportRectangle(t){let e=[t[0],t[1]];N.applyTransform(e,this.transform);let i=[t[2],t[3]];return N.applyTransform(i,this.transform),[e[0],e[1],i[0],i[1]]}convertToPdfPoint(t,e){let i=[t,e];return N.applyInverseTransform(i,this.transform),i}}class tt extends P{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function te(t){let e=t.length,i=0;for(;i<e&&""===t[i].trim();)i++;return"data:"===t.substring(i,i+5).toLowerCase()}function ti(t){return"string"==typeof t&&/\.pdf$/i.test(t)}function ts(t){return[t]=t.split(/[#?]/,1),E(t)}function tr(t,e="document.pdf"){if("string"!=typeof t)return e;if(te(t))return w('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;let i=(t=>{try{return new URL(t)}catch{try{return new URL(decodeURIComponent(t))}catch{try{return new URL(t,"https://foo.bar")}catch{try{return new URL(decodeURIComponent(t),"https://foo.bar")}catch{return null}}}}})(t);if(!i)return e;let s=t=>{try{let e=decodeURIComponent(t);if(e.includes("/")&&(e=E(e),/^\.pdf$/i.test(e)))return t;return e}catch{return t}},r=/\.pdf$/i,a=E(i.pathname);if(r.test(a))return s(a);if(i.searchParams.size>0){let t=t=>[...t].findLast(t=>r.test(t)),e=t(i.searchParams.values())??t(i.searchParams.keys());if(e)return s(e)}if(i.hash){let t=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(i.hash);if(t)return s(t[0])}return e}class ta{#i=new Map;times=[];time(t){this.#i.has(t)&&w(`Timer is already running for ${t}`),this.#i.set(t,Date.now())}timeEnd(t){this.#i.has(t)||w(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.#i.get(t),end:Date.now()}),this.#i.delete(t)}toString(){let t=Math.max(...this.times.map(t=>t.name.length));return this.times.map(e=>`${e.name.padEnd(t)} ${e.end-e.start}ms
|
|
2
|
-
`).join("")}}function tn(t,e){let i=e?URL.parse(t,e):URL.parse(t);return/https?:/.test(i?.protocol??"")}function to(t){t.preventDefault()}function tl(t){t.preventDefault(),t.stopPropagation()}class th{static #s;static toDateObject(t){if(t instanceof Date)return t;if(!t||"string"!=typeof t)return null;this.#s||=RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");let e=this.#s.exec(t);if(!e)return null;let i=parseInt(e[1],10),s=parseInt(e[2],10);s=s>=1&&s<=12?s-1:0;let r=parseInt(e[3],10);r=r>=1&&r<=31?r:1;let a=parseInt(e[4],10);a=a>=0&&a<=23?a:0;let n=parseInt(e[5],10);n=n>=0&&n<=59?n:0;let o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;let l=e[7]||"Z",h=parseInt(e[8],10);h=h>=0&&h<=23?h:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,"-"===l?(a+=h,n+=d):"+"===l&&(a-=h,n-=d),new Date(Date.UTC(i,s,r,a,n,o))}}function td(t,{scale:e=1,rotation:i=0}){let{width:s,height:r}=t.attributes.style;return new Z({viewBox:[0,0,parseInt(s,10),parseInt(r,10)],userUnit:1,scale:e,rotation:i})}function tc(t){if(t.startsWith("#")){let e=t.slice(1);return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16),e.length>=8?parseInt(e.slice(6,8),16)/255:1]}if(t.startsWith("rgb(")){let[e,i,s]=t.slice(4,-1).split(",").map(t=>parseInt(t,10));return[e,i,s,1]}if(t.startsWith("rgba(")){let e=t.slice(5,-1).split(",");return[parseInt(e[0],10),parseInt(e[1],10),parseInt(e[2],10),parseFloat(e[3])]}let e=t.match(/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*([\d.]+|none))?\)$/);return e?[Math.round(255*parseFloat(e[1])),Math.round(255*parseFloat(e[2])),Math.round(255*parseFloat(e[3])),void 0!==e[4]&&"none"!==e[4]?parseFloat(e[4]):1]:null}function tu(t){let e=tc(t);return e?e.slice(0,3):(w(`Not a valid color format: "${t}"`),[0,0,0])}function tp(t){let{a:e,b:i,c:s,d:r,e:a,f:n}=t.getTransform();return[e,i,s,r,a,n]}function tg(t){let{a:e,b:i,c:s,d:r,e:a,f:n}=t.getTransform().invertSelf();return[e,i,s,r,a,n]}function tm(t,e,i=!1,s=!0){if(e instanceof Z){let{pageWidth:s,pageHeight:r}=e.rawDims,{style:a}=t,n=O.isCSSRoundSupported,o=`var(--total-scale-factor) * ${s}px`,l=`var(--total-scale-factor) * ${r}px`,h=n?`round(down, ${o}, var(--scale-round-x))`:`calc(${o})`,d=n?`round(down, ${l}, var(--scale-round-y))`:`calc(${l})`;i&&e.rotation%180!=0?(a.width=d,a.height=h):(a.width=h,a.height=d)}s&&t.setAttribute("data-main-rotation",e.rotation)}class tf{constructor(){const{pixelRatio:t}=tf;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,i,s,r=-1){let a=1/0,n=1/0,o=1/0;(i=tf.capPixels(i,r))>0&&(a=Math.sqrt(i/(t*e))),-1!==s&&(n=s/t,o=s/e);let l=Math.min(a,n,o);return(this.sx>l||this.sy>l)&&(this.sx=l,this.sy=l,!0)}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){let i=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,i):i}return t}}let tb=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class ty{static get isDarkMode(){return M(this,"isDarkMode",!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches)}}class tv{static get commentForegroundColor(){let t=document.createElement("span");t.classList.add("comment","sidebar");let{style:e}=t;e.width=e.height="0",e.display="none",e.color="var(--comment-fg-color)",document.body.append(t);let{color:i}=window.getComputedStyle(t);return t.remove(),M(this,"commentForegroundColor",tu(i))}}function tA(t,e){let i=255*(1-(e=X(e??1,0,1)));return t.map(t=>Math.round(t*e+i))}function tx(t,e){let i=t[0]/255,s=t[1]/255,r=t[2]/255,a=Math.max(i,s,r),n=Math.min(i,s,r),o=(a+n)/2;if(a===n)e[0]=e[1]=0;else{let t=a-n;switch(e[1]=o<.5?t/(a+n):t/(2-a-n),a){case i:e[0]=((s-r)/t+6*(s<r))*60;break;case s:e[0]=((r-i)/t+2)*60;break;case r:e[0]=((i-s)/t+4)*60}}e[2]=o}function tw(t,e){let i=t[0],s=t[1],r=t[2],a=(1-Math.abs(2*r-1))*s,n=a*(1-Math.abs(i/60%2-1)),o=r-a/2;switch(Math.floor(i/60)){case 0:e[0]=a+o,e[1]=n+o,e[2]=o;break;case 1:e[0]=n+o,e[1]=a+o,e[2]=o;break;case 2:e[0]=o,e[1]=a+o,e[2]=n+o;break;case 3:e[0]=o,e[1]=n+o,e[2]=a+o;break;case 4:e[0]=n+o,e[1]=o,e[2]=a+o;break;case 5:case 6:e[0]=a+o,e[1]=o,e[2]=n+o}}function t_(t){return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function tC(t,e,i){tw(t,i),i.map(t_);let s=.2126*i[0]+.7152*i[1]+.0722*i[2];tw(e,i),i.map(t_);let r=.2126*i[0]+.7152*i[1]+.0722*i[2];return s>r?(s+.05)/(r+.05):(r+.05)/(s+.05)}let tT=new Map;function tS(t,e){let i=t[0]+256*t[1]+65536*t[2]+0x1000000*e[0]+0x100000000*e[1]+0x10000000000*e[2],s=tT.get(i);if(s)return s;let r=new Float32Array(9),a=r.subarray(0,3),n=r.subarray(3,6);tx(t,n);let o=r.subarray(6,9);tx(e,o);let l=o[2]<.5,h=l?12:4.5;if(n[2]=l?Math.sqrt(n[2]):1-Math.sqrt(1-n[2]),tC(n,o,a)<h){let t,e;for(l?(t=n[2],e=1):(t=0,e=n[2]);e-t>.005;){let i=n[2]=(t+e)/2;l===tC(n,o,a)<h?t=i:e=i}n[2]=l?e:t}return tw(n,a),s=N.makeHexColor(Math.round(255*a[0]),Math.round(255*a[1]),Math.round(255*a[2])),tT.set(i,s),s}function tE({html:t,dir:e,className:i},s){let r=document.createDocumentFragment();if("string"==typeof t){let i=document.createElement("p");i.dir=e||"auto";let s=t.split(/(?:\r\n?|\n)/);for(let t=0,e=s.length;t<e;++t){let r=s[t];i.append(document.createTextNode(r)),t<e-1&&i.append(document.createElement("br"))}r.append(i)}else K.render({xfaHtml:t,div:r,intent:"richText"});r.firstElementChild.classList.add("richText",i),s.append(r)}function tM(t){let e=new Path2D;if(!t)return e;for(let i=0,s=t.length;i<s;)switch(t[i++]){case 0:e.moveTo(t[i++],t[i++]);break;case 1:e.lineTo(t[i++],t[i++]);break;case 2:e.bezierCurveTo(t[i++],t[i++],t[i++],t[i++],t[i++],t[i++]);break;case 3:e.quadraticCurveTo(t[i++],t[i++],t[i++],t[i++]);break;case 4:e.closePath();break;default:w(`Unrecognized drawing path operator: ${t[i-1]}`)}return e}class tP{#r=null;#a=null;#n;#o=null;#l=null;#h=null;#d=null;#c=null;static #u=null;constructor(t){this.#n=t,tP.#u||=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",signature:"pdfjs-editor-remove-signature-button"})}render(){let t=this.#r=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");let e=this.#n._uiManager._signal;e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("contextmenu",to,{signal:e}),t.addEventListener("pointerdown",tP.#p,{signal:e}));let i=this.#o=document.createElement("div");i.className="buttons",t.append(i);let s=this.#n.toolbarPosition;if(s){let{style:e}=t,i="ltr"===this.#n._uiManager.direction?1-s[0]:s[0];e.insetInlineEnd=`${100*i}%`,e.top=`calc(${100*s[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return this.#r}static #p(t){t.stopPropagation()}#g(t){this.#n._focusEventsAllowed=!1,tl(t)}#m(t){this.#n._focusEventsAllowed=!0,tl(t)}#f(t){let e=this.#n._uiManager._signal;return e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("focusin",this.#g.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#m.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",to,{signal:e}),!0)}hide(){this.#r.classList.add("hidden"),this.#a?.hideDropdown()}show(){this.#r.classList.remove("hidden"),this.#l?.shown(),this.#h?.shown()}addDeleteButton(){let{editorType:t,_uiManager:e}=this.#n,i=document.createElement("button");i.classList.add("basic","deleteButton"),i.tabIndex=0,i.setAttribute("data-l10n-id",tP.#u[t]),this.#f(i)&&i.addEventListener("click",t=>{e.delete()},{signal:e._signal}),this.#o.append(i)}get #b(){let t=document.createElement("div");return t.className="divider",t}async addAltText(t){let e=await t.render();this.#f(e),this.#o.append(e,this.#b),this.#l=t}addComment(t,e=null){if(this.#h)return;let i=t.renderForToolbar();if(!i)return;this.#f(i);let s=this.#d=this.#b;e?(this.#o.insertBefore(i,e),this.#o.insertBefore(s,e)):this.#o.append(i,s),this.#h=t,t.toolbar=this}addColorPicker(t){if(this.#a)return;this.#a=t;let e=t.renderButton();this.#f(e),this.#o.append(e,this.#b)}async addEditSignatureButton(t){let e=this.#c=await t.renderEditButton(this.#n);this.#f(e),this.#o.append(e,this.#b)}removeButton(t){"comment"===t&&(this.#h?.removeToolbarCommentButton(),this.#h=null,this.#d?.remove(),this.#d=null)}async addButton(t,e){switch(t){case"colorPicker":e&&this.addColorPicker(e);break;case"altText":e&&await this.addAltText(e);break;case"editSignature":e&&await this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":e&&this.addComment(e)}}async addButtonBefore(t,e,i){if(!e&&"comment"===t)return;let s=this.#o.querySelector(i);s&&"comment"===t&&this.addComment(e,s)}updateEditSignatureButton(t){this.#c&&(this.#c.title=t)}remove(){this.#r.remove(),this.#a?.destroy(),this.#a=null}}class tk{#o=null;#r=null;#y;constructor(t){this.#y=t}#v(){let t=this.#r=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar");let e=this.#y._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",to,{signal:e});let i=this.#o=document.createElement("div");return i.className="buttons",t.append(i),this.#y.hasCommentManager()&&this.#A("commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{this.#y.commentSelection("floating_button")}),this.#A("highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{this.#y.highlightSelection("floating_button")}),t}#x(t,e){let i=0,s=0;for(let r of t){let t=r.y+r.height;if(t<i)continue;let a=r.x+(e?r.width:0);if(t>i){s=a,i=t;continue}e?a>s&&(s=a):a<s&&(s=a)}return[e?1-s:s,i]}show(t,e,i){let[s,r]=this.#x(e,i),{style:a}=this.#r||=this.#v();t.append(this.#r),a.insetInlineEnd=`${100*s}%`,a.top=`calc(${100*r}% + var(--editor-toolbar-vert-offset))`}hide(){this.#r.remove()}#A(t,e,i,s){let r=document.createElement("button");r.classList.add("basic",t),r.tabIndex=0,r.setAttribute("data-l10n-id",e);let a=document.createElement("span");r.append(a),a.className="visuallyHidden",a.setAttribute("data-l10n-id",i);let n=this.#y._signal;n instanceof AbortSignal&&!n.aborted&&(r.addEventListener("contextmenu",to,{signal:n}),r.addEventListener("click",s,{signal:n})),this.#o.append(r)}}function tD(t,e,i){for(let s of i)e.addEventListener(s,t[s].bind(t))}class tI{static #w=NaN;static #_=null;static #C=NaN;static #T=null;static initializeAndAddPointerId(t){(tI.#_||=new Set).add(t)}static setPointer(t,e){tI.#w||=e,tI.#T??=t}static setTimeStamp(t){tI.#C=t}static isSamePointerId(t){return tI.#w===t}static isSamePointerIdOrRemove(t){return tI.#w===t||(tI.#_?.delete(t),!1)}static isSamePointerType(t){return tI.#T===t}static isInitializedAndDifferentPointerType(t){return null!==tI.#T&&!tI.isSamePointerType(t)}static isSameTimeStamp(t){return tI.#C===t}static isUsingMultiplePointers(){return tI.#_?.size>=1}static clearPointerType(){tI.#T=null}static clearPointerIds(){tI.#w=NaN,tI.#_=null}static clearTimeStamp(){tI.#C=NaN}}class tB{#S=0;get id(){return`${c}${this.#S++}`}}class tF{#E=$();#S=0;#M=null;static get _isSVGFittingCanvas(){let t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),e=new Image;return e.src='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>',M(this,"_isSVGFittingCanvas",e.decode().then(()=>(t.drawImage(e,0,0,1,1,0,0,1,3),0===new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0])))}async #P(t,e){this.#M||=new Map;let i=this.#M.get(t);if(null===i)return null;if(i?.bitmap)return i.refCounter+=1,i;try{let t;if(i||={bitmap:null,id:`image_${this.#E}_${this.#S++}`,refCounter:0,isSvg:!1},"string"==typeof e?(i.url=e,t=await J(e,"blob")):e instanceof File?t=i.file=e:e instanceof Blob&&(t=e),"image/svg+xml"===t.type){let e=tF._isSVGFittingCanvas,s=new FileReader,r=new Image,a=new Promise((t,a)=>{r.onload=()=>{i.bitmap=r,i.isSvg=!0,t()},s.onload=async()=>{let t=i.svgUrl=s.result;r.src=await e?`${t}#svgView(preserveAspectRatio(none))`:t},r.onerror=s.onerror=a});s.readAsDataURL(t),await a}else i.bitmap=await createImageBitmap(t);i.refCounter=1}catch(t){w(t),i=null}return this.#M.set(t,i),i&&this.#M.set(i.id,i),i}async getFromFile(t){let{lastModified:e,name:i,size:s,type:r}=t;return this.#P(`${e}_${i}_${s}_${r}`,t)}async getFromUrl(t){return this.#P(t,t)}async getFromBlob(t,e){let i=await e;return this.#P(t,i)}async getFromId(t){this.#M||=new Map;let e=this.#M.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){let{blobPromise:t}=e;return delete e.blobPromise,this.getFromBlob(e.id,t)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#M||=new Map;let i=this.#M.get(t);if(i?.bitmap)return i.refCounter+=1,i;let s=new OffscreenCanvas(e.width,e.height);return s.getContext("2d").drawImage(e,0,0),i={bitmap:s.transferToImageBitmap(),id:`image_${this.#E}_${this.#S++}`,refCounter:1,isSvg:!1},this.#M.set(t,i),this.#M.set(i.id,i),i}getSvgUrl(t){let e=this.#M.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#M||=new Map;let e=this.#M.get(t);if(!e||(e.refCounter-=1,0!==e.refCounter))return;let{bitmap:i}=e;if(!e.url&&!e.file){let t=new OffscreenCanvas(i.width,i.height);t.getContext("bitmaprenderer").transferFromImageBitmap(i),e.blobPromise=t.convertToBlob()}i.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#E}_`)}}class tL{#k=[];#D=!1;#I;#B=-1;constructor(t=128){this.#I=t}add({cmd:t,undo:e,post:i,mustExec:s,type:r=NaN,overwriteIfSameType:a=!1,keepUndo:n=!1}){if(s&&t(),this.#D)return;let o={cmd:t,undo:e,post:i,type:r};if(-1===this.#B){this.#k.length>0&&(this.#k.length=0),this.#B=0,this.#k.push(o);return}if(a&&this.#k[this.#B].type===r){n&&(o.undo=this.#k[this.#B].undo),this.#k[this.#B]=o;return}let l=this.#B+1;l===this.#I?this.#k.splice(0,1):(this.#B=l,l<this.#k.length&&this.#k.splice(l)),this.#k.push(o)}undo(){if(-1===this.#B)return;this.#D=!0;let{undo:t,post:e}=this.#k[this.#B];t(),e?.(),this.#D=!1,this.#B-=1}redo(){if(this.#B<this.#k.length-1){this.#B+=1,this.#D=!0;let{cmd:t,post:e}=this.#k[this.#B];t(),e?.(),this.#D=!1}}hasSomethingToUndo(){return -1!==this.#B}hasSomethingToRedo(){return this.#B<this.#k.length-1}cleanType(t){if(-1!==this.#B){for(let e=this.#B;e>=0;e--)if(this.#k[e].type!==t){this.#k.splice(e+1,this.#B-e),this.#B=e;return}this.#k.length=0,this.#B=-1}}destroy(){this.#k=null}}class tR{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=O.platform;for(const[i,s,r={}]of t)for(const t of i){const i=t.startsWith("mac+");e&&i?(this.callbacks.set(t.slice(4),{callback:s,options:r}),this.allKeys.add(t.split("+").at(-1))):e||i||(this.callbacks.set(t,{callback:s,options:r}),this.allKeys.add(t.split("+").at(-1)))}}#F(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);let e=this.buffer.join("+");return this.buffer.length=0,e}exec(t,e){if(!this.allKeys.has(e.key))return;let i=this.callbacks.get(this.#F(e));if(!i)return;let{callback:s,options:{bubbles:r=!1,args:a=[],checker:n=null}}=i;(!n||n(t,e))&&(s.bind(t,...a,e)(),r||tl(e))}}class tO{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){let t=new Map([["CanvasText",null],["Canvas",null]]),e=document.createElement("span");for(let i of(e.style.visibility="hidden",e.style.colorScheme="only light",document.body.append(e),t.keys())){e.style.color=i;let s=window.getComputedStyle(e).color;t.set(i,tu(s))}return e.remove(),M(this,"_colors",t)}convert(t){let e=tu(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(let[t,i]of this._colors)if(i.every((t,i)=>t===e[i]))return tO._colorsMapping.get(t);return e}getHexCode(t){let e=this._colors.get(t);return e?N.makeHexColor(...e):t}}class tN{#L=new AbortController;#R=null;#O=null;#N=new Map;#U=new Map;#H=null;#z=null;#$=null;#G=null;#j=new tL;#V=null;#W=null;#X=null;#q=0;#K=new Set;#Y=null;#Q=null;#J=new Set;_editorUndoBar=null;#Z=!1;#tt=!1;#te=!1;#ti=null;#ts=null;#tr=null;#ta=null;#tn=!1;#to=null;#tl=new tB;#th=!1;#td=!1;#tc=!1;#tu=null;#tp=null;#tg=null;#tm=null;#tf=null;#tb=u.NONE;#ty=new Set;#tv=null;#tA=null;#tx=null;#tw=null;#t_=null;#tC={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#tT=[0,0];#tS=null;#tE=null;#tM=null;#tP=null;#tk=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){let t=tN.prototype,e=t=>t.#tE.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),i=(t,{target:e})=>{if(e instanceof HTMLInputElement){let{type:t}=e;return"text"!==t&&"number"!==t}return!0},s=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return M(this,"_keyboardManager",new tR([[["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:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#tE.contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#tE.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:[-r,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[r,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-r],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,r],checker:e}]]))}constructor(t,e,i,s,r,a,n,o,l,h,d,c,u,p,g,m){const f=this._signal=this.#L.signal;this.#tE=t,this.#tM=e,this.#tP=i,this.#z=s,this.#V=r,this.#tA=a,this.#t_=o,this._eventBus=n,n._on("editingaction",this.onEditingAction.bind(this),{signal:f}),n._on("pagechanging",this.onPageChanging.bind(this),{signal:f}),n._on("scalechanging",this.onScaleChanging.bind(this),{signal:f}),n._on("rotationchanging",this.onRotationChanging.bind(this),{signal:f}),n._on("setpreference",this.onSetPreference.bind(this),{signal:f}),n._on("switchannotationeditorparams",t=>this.updateParams(t.type,t.value),{signal:f}),window.addEventListener("pointerdown",()=>{this.#td=!0},{capture:!0,signal:f}),window.addEventListener("pointerup",()=>{this.#td=!1},{capture:!0,signal:f}),window.addEventListener("beforeunload",this.#tD.bind(this),{capture:!0,signal:f}),this.#tI(),this.#tB(),this.#tF(),this.#$=o.annotationStorage,this.#ti=o.filterFactory,this.#tx=l,this.#ta=h||null,this.#Z=d,this.#tt=c,this.#te=u,this.#tf=p||null,this.viewParameters={realScale:Q.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=g||null,this._supportsPinchToZoom=!1!==m,r?.setSidebarUiManager(this)}destroy(){for(let t of(this.#tk?.resolve(),this.#tk=null,this.#L?.abort(),this.#L=null,this._signal=null,this.#U.values()))t.destroy();this.#U.clear(),this.#N.clear(),this.#J.clear(),this.#tm?.clear(),this.#R=null,this.#ty.clear(),this.#j.destroy(),this.#z?.destroy(),this.#V?.destroy(),this.#tA?.destroy(),this.#to?.hide(),this.#to=null,this.#tg?.destroy(),this.#tg=null,this.#O=null,this.#ts&&(clearTimeout(this.#ts),this.#ts=null),this.#tS&&(clearTimeout(this.#tS),this.#tS=null),this._editorUndoBar?.destroy(),this.#t_=null}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#tf}get useNewAltTextFlow(){return this.#tt}get useNewAltTextWhenAddingImage(){return this.#te}get hcmFilter(){return M(this,"hcmFilter",this.#tx?this.#ti.addHCMFilter(this.#tx.foreground,this.#tx.background):"none")}get direction(){return M(this,"direction",getComputedStyle(this.#tE).direction)}get _highlightColors(){return M(this,"_highlightColors",this.#ta?new Map(this.#ta.split(",").map(t=>((t=t.split("=").map(t=>t.trim()))[1]=t[1].toUpperCase(),t))):null)}get highlightColors(){let{_highlightColors:t}=this;if(!t)return M(this,"highlightColors",null);let e=new Map,i=!!this.#tx;for(let[s,r]of t){let t=s.endsWith("_HCM");if(i&&t){e.set(s.replace("_HCM",""),r);continue}i||t||e.set(s,r)}return M(this,"highlightColors",e)}get highlightColorNames(){return M(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}getNonHCMColor(t){if(!this._highlightColors)return t;let e=this.highlightColorNames.get(t);return this._highlightColors.get(e)||t}getNonHCMColorName(t){return this.highlightColorNames.get(t)||t}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#X=t}setMainHighlightColorPicker(t){this.#tg=t}editAltText(t,e=!1){this.#z?.editAltText(this,t,e)}hasCommentManager(){return!!this.#V}editComment(t,e,i,s){this.#V?.showDialog(this,t,e,i,s)}selectComment(t,e){let i=this.#U.get(t),s=i?.getEditorByUID(e);s?.toggleComment(!0,!0)}updateComment(t){this.#V?.updateComment(t.getData())}updatePopupColor(t){this.#V?.updatePopupColor(t)}removeComment(t){this.#V?.removeComments([t.uid])}deleteComment(t,e){let i=()=>{t.comment=e},s=()=>{this._editorUndoBar?.show(i,"comment"),this.toggleComment(null),t.comment=null};this.addCommands({cmd:s,undo:i,mustExec:!0})}toggleComment(t,e,i){this.#V?.toggleCommentPopup(t,e,i)}makeCommentColor(t,e){return t&&this.#V?.makeCommentColor(t,e)||null}getCommentDialogElement(){return this.#V?.dialogElement||null}async waitForEditorsRendered(t){if(this.#U.has(t-1))return;let{resolve:e,promise:i}=Promise.withResolvers(),s=i=>{i.pageNumber===t&&(this._eventBus._off("editorsrendered",s),e())};this._eventBus.on("editorsrendered",s),await i}getSignature(t){this.#tA?.getSignature({uiManager:this,editor:t})}get signatureManager(){return this.#tA}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}){"enableNewAltTextWhenAddingImage"===t&&(this.#te=e)}onPageChanging({pageNumber:t}){this.#q=t-1}deletePage(t){for(let e of this.getEditors(t))e.remove();this.#U.delete(t),this.#q===t&&(this.#q=0)}focusMainContainer(){this.#tE.focus()}findParent(t,e){for(let i of this.#U.values()){let{x:s,y:r,width:a,height:n}=i.div.getBoundingClientRect();if(t>=s&&t<=s+a&&e>=r&&e<=r+n)return i}return null}disableUserSelect(t=!1){this.#tM.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#J.add(t)}removeShouldRescale(t){this.#J.delete(t)}onScaleChanging({scale:t}){for(let e of(this.commitOrRemove(),this.viewParameters.realScale=t*Q.PDF_TO_CSS_UNITS,this.#J))e.onScaleChanging();this.#X?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#tL({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#tR(t){let{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(let e of this.#U.values())if(e.hasTextLayer(t))return e;return null}highlightSelection(t="",e=!1){let i=document.getSelection();if(!i||i.isCollapsed)return;let{anchorNode:s,anchorOffset:r,focusNode:a,focusOffset:n}=i,o=i.toString(),l=this.#tL(i).closest(".textLayer"),h=this.getSelectionBoxes(l);if(!h)return;i.empty();let d=this.#tR(l),c=this.#tb===u.NONE,p=()=>{let i=d?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:h,anchorNode:s,anchorOffset:r,focusNode:a,focusOffset:n,text:o});c&&this.showAllEditors("highlight",!0,!0),e&&i?.editComment()};c?this.switchToMode(u.HIGHLIGHT,p):p()}commentSelection(t=""){this.highlightSelection(t,!0)}#tD(t){this.commitOrRemove(),this.currentLayer?.endDrawingSession(!1)}#tO(){let t=document.getSelection();if(!t||t.isCollapsed)return;let e=this.#tL(t).closest(".textLayer"),i=this.getSelectionBoxes(e);i&&(this.#to||=new tk(this),this.#to.show(e,i,"ltr"===this.direction))}getAndRemoveDataFromAnnotationStorage(t){if(!this.#$)return null;let e=`${c}${t}`,i=this.#$.getRawValue(e);return i&&this.#$.remove(e),i}addToAnnotationStorage(t){t.isEmpty()||!this.#$||this.#$.has(t.id)||this.#$.setValue(t.id,t)}a11yAlert(t,e=null){let i=this.#tP;i&&(i.setAttribute("data-l10n-id",t),e?i.setAttribute("data-l10n-args",JSON.stringify(e)):i.removeAttribute("data-l10n-args"))}#tN(){let t=document.getSelection();if(!t||t.isCollapsed){this.#tv&&(this.#to?.hide(),this.#tv=null,this.#tU({hasSelectedText:!1}));return}let{anchorNode:e}=t;if(e===this.#tv)return;let i=this.#tL(t).closest(".textLayer");if(!i){this.#tv&&(this.#to?.hide(),this.#tv=null,this.#tU({hasSelectedText:!1}));return}if(this.#to?.hide(),this.#tv=e,this.#tU({hasSelectedText:!0}),(this.#tb===u.HIGHLIGHT||this.#tb===u.NONE)&&(this.#tb===u.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#tn=this.isShiftKeyDown,!this.isShiftKeyDown)){let t=this.#tb===u.HIGHLIGHT?this.#tR(i):null;if(t?.toggleDrawing(),this.#td){let e=new AbortController,i=this.combinedSignal(e),s=i=>{("pointerup"!==i.type||0===i.button)&&(e.abort(),t?.toggleDrawing(!0),"pointerup"===i.type&&this.#tH("main_toolbar"))};window.addEventListener("pointerup",s,{signal:i}),window.addEventListener("blur",s,{signal:i})}else t?.toggleDrawing(!0),this.#tH("main_toolbar")}}#tH(t=""){this.#tb===u.HIGHLIGHT?this.highlightSelection(t):this.#Z&&this.#tO()}#tI(){document.addEventListener("selectionchange",this.#tN.bind(this),{signal:this._signal})}#tz(){if(this.#tr)return;this.#tr=new AbortController;let t=this.combinedSignal(this.#tr);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#t$(){this.#tr?.abort(),this.#tr=null}blur(){if(this.isShiftKeyDown=!1,this.#tn&&(this.#tn=!1,this.#tH("main_toolbar")),!this.hasSelection)return;let{activeElement:t}=document;for(let e of this.#ty)if(e.div.contains(t)){this.#tp=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#tp)return;let[t,e]=this.#tp;this.#tp=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#tF(){if(this.#tu)return;this.#tu=new AbortController;let t=this.combinedSignal(this.#tu);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#tG(){this.#tu?.abort(),this.#tu=null}#tj(){if(this.#W)return;this.#W=new AbortController;let t=this.combinedSignal(this.#W);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})}#tV(){this.#W?.abort(),this.#W=null}#tB(){let t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#tF(),this.setEditingState(!0)}removeEditListeners(){this.#tG(),this.setEditingState(!1)}dragOver(t){for(let{type:e}of t.dataTransfer.items)for(let i of this.#Q)if(i.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(let e of t.dataTransfer.items)for(let i of this.#Q)if(i.isHandlingMimeForPasting(e.type)){i.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),this.#R?.commitOrRemove(),!this.hasSelection)return;let e=[];for(let t of this.#ty){let i=t.serialize(!0);i&&e.push(i)}0!==e.length&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();let{clipboardData:e}=t;for(let t of e.items)for(let e of this.#Q)if(e.isHandlingMimeForPasting(t.type))return void e.paste(t,this.currentLayer);let i=e.getData("application/pdfjs");if(!i)return;try{i=JSON.parse(i)}catch(t){w(`paste: "${t.message}".`);return}if(!Array.isArray(i))return;this.unselectAll();let s=this.currentLayer;try{let t=[];for(let e of i){let i=await s.deserialize(e);if(!i)return;t.push(i)}let e=()=>{for(let e of t)this.#tW(e);this.#tX(t)};this.addCommands({cmd:e,undo:()=>{for(let e of t)e.remove()},mustExec:!0})}catch(t){w(`paste: "${t.message}".`)}}keydown(t){this.isShiftKeyDown||"Shift"!==t.key||(this.isShiftKeyDown=!0),this.#tb===u.NONE||this.isEditorHandlingKeyboard||tN._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,this.#tn&&(this.#tn=!1,this.#tH("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;case"commentSelection":this.commentSelection("context_menu")}}updatePageIndex(t,e){for(let i of this.getEditors(t))i.pageIndex=e;let i=this.#H.get(t);i&&(i.pageIndex=e,this.#U.set(e,i),this.#th?i.enable():i.disable())}startUpdatePages(){this.#H=new Map(this.#U),this.#U.clear()}endUpdatePages(){this.#H=null}clonePage(t,e){for(let i of this.getEditors(t)){let t=i.serialize(i.mode!==u.HIGHLIGHT);t&&(t.pageIndex=e,t.id=this.getId(),t.isClone=!0,delete t.popupRef,this.#$.setValue(t.id,t))}}findClonesForPage(t){let e=[],{pageIndex:i}=t;for(let[s,r]of this.#$)r.pageIndex===i&&r.isClone&&(this.#$.remove(s),e.push(t.deserialize(r).then(e=>{e&&(e.isClone=!0,t.addOrRebuild(e))})));return Promise.all(e)}#tU(t){Object.entries(t).some(([t,e])=>this.#tC[t]!==e)&&(this._eventBus.dispatch("editingstateschanged",{source:this,details:Object.assign(this.#tC,t)}),this.#tb===u.HIGHLIGHT&&!1===t.hasSelectedEditor&&this.#tq([[p.HIGHLIGHT_FREE,!0]]))}#tq(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#tz(),this.#tj(),this.#tU({isEditing:this.#tb!==u.NONE,isEmpty:this.#tK(),hasSomethingToUndo:this.#j.hasSomethingToUndo(),hasSomethingToRedo:this.#j.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#t$(),this.#tV(),this.#tU({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#Q)for(let e of(this.#Q=t,this.#Q))this.#tq(e.defaultPropertiesToUpdate)}getId(){return this.#tl.id}get currentLayer(){return this.#U.get(this.#q)}getLayer(t){return this.#U.get(t)}get currentPageIndex(){return this.#q}addLayer(t){this.#U.set(t.pageIndex,t),this.#th?t.enable():t.disable()}removeLayer(t){this.#U.delete(t.pageIndex)}async updateMode(t,e=null,i=!1,s=!1,r=!1,a=!1){if(this.#tb!==t&&(!this.#tk||(await this.#tk.promise,this.#tk))){if(this.#tk=Promise.withResolvers(),this.#X?.commitOrRemove(),this.#tb===u.POPUP&&this.#V?.hideSidebar(),this.#V?.destroyPopup(),this.#tb=t,t===u.NONE){for(let t of(this.setEditingState(!1),this.#tY(),this.#N.values()))t.hideStandaloneCommentButton();this._editorUndoBar?.hide(),this.toggleComment(null),this.#tk.resolve();return}for(let t of this.#N.values())t.addStandaloneCommentButton();for(let e of(t===u.SIGNATURE&&await this.#tA?.loadSignatures(),i&&tI.clearPointerType(),this.setEditingState(!0),await this.#tQ(),this.unselectAll(),this.#U.values()))e.updateMode(t);if(t===u.POPUP){this.#O||=await this.#t_.getAnnotationsByType(new Set(this.#Q.map(t=>t._editorType)));let t=new Set,e=[];for(let i of this.#N.values()){let{annotationElementId:s,hasComment:r,deleted:a}=i;s&&t.add(s),r&&!a&&e.push(i.getData())}for(let i of this.#O){let{id:s,popupRef:r,contentsObj:a}=i;r&&a?.str&&!t.has(s)&&!this.#K.has(s)&&e.push(i)}this.#V?.showSidebar(e)}if(!e){s&&this.addNewEditorFromKeyboard(),this.#tk.resolve();return}for(let t of this.#N.values())t.uid===e?(this.setSelected(t),a?t.editComment():r?t.enterInEditMode():t.focus()):t.unselect();this.#tk.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==this.#tb&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(this.#Q){switch(t){case p.CREATE:this.currentLayer.addNewEditor(e);return;case p.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#tw||=new Map).set(t,e),this.showAllEditors("highlight",e)}if(this.hasSelection)for(let i of this.#ty)i.updateParams(t,e);else for(let i of this.#Q)i.updateDefaultParams(t,e)}}showAllEditors(t,e,i=!1){for(let i of this.#N.values())i.editorType===t&&i.show(e);(this.#tw?.get(p.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#tq([[p.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#tc!==t)for(let e of(this.#tc=t,this.#U.values()))t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}async #tQ(){if(!this.#th){this.#th=!0;let t=[];for(let e of this.#U.values())t.push(e.enable());for(let e of(await Promise.all(t),this.#N.values()))e.enable()}}#tY(){if(this.unselectAll(),this.#th){for(let t of(this.#th=!1,this.#U.values()))t.disable();for(let t of this.#N.values())t.disable()}}*getEditors(t){for(let e of this.#N.values())e.pageIndex===t&&(yield e)}getEditor(t){return this.#N.get(t)}addEditor(t){this.#N.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#ts&&clearTimeout(this.#ts),this.#ts=setTimeout(()=>{this.focusMainContainer(),this.#ts=null},0)),this.#N.delete(t.id),t.annotationElementId&&this.#tm?.delete(t.annotationElementId),this.unselect(t),t.annotationElementId&&this.#K.has(t.annotationElementId)||this.#$?.remove(t.id)}addDeletedAnnotationElement(t){this.#K.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#K.has(t)}removeDeletedAnnotationElement(t){this.#K.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#tW(t){let e=this.#U.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#R!==t&&(this.#R=t,t&&this.#tq(t.propertiesToUpdate))}get #tJ(){let t=null;for(t of this.#ty);return t}updateUI(t){this.#tJ===t&&this.#tq(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#tq(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#ty.has(t)){this.#ty.delete(t),t.unselect(),this.#tU({hasSelectedEditor:this.hasSelection});return}this.#ty.add(t),t.select(),this.#tq(t.propertiesToUpdate),this.#tU({hasSelectedEditor:!0})}setSelected(t){for(let e of(this.updateToolbar({mode:t.mode,editId:t.uid}),this.#X?.commitOrRemove(),this.#ty))e!==t&&e.unselect();this.#V?.destroyPopup(),this.#ty.clear(),this.#ty.add(t),t.select(),this.#tq(t.propertiesToUpdate),this.#tU({hasSelectedEditor:!0})}isSelected(t){return this.#ty.has(t)}get firstSelectedEditor(){return this.#ty.values().next().value}unselect(t){t.unselect(),this.#ty.delete(t),this.#tU({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#ty.size}get isEnterHandled(){return 1===this.#ty.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#j.undo(),this.#tU({hasSomethingToUndo:this.#j.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#tK()}),this._editorUndoBar?.hide()}redo(){this.#j.redo(),this.#tU({hasSomethingToUndo:!0,hasSomethingToRedo:this.#j.hasSomethingToRedo(),isEmpty:this.#tK()})}addCommands(t){this.#j.add(t),this.#tU({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#tK()})}cleanUndoStack(t){this.#j.cleanType(t)}#tK(){if(0===this.#N.size)return!0;if(1===this.#N.size)for(let t of this.#N.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();let t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;let e=t?[t]:[...this.#ty],i=()=>{for(let t of(this._editorUndoBar?.show(s,1===e.length?e[0].editorType:e.length),e))t.remove()},s=()=>{for(let t of e)this.#tW(t)};this.addCommands({cmd:i,undo:s,mustExec:!0})}commitOrRemove(){this.#R?.commitOrRemove()}hasSomethingToControl(){return this.#R||this.hasSelection}#tX(t){for(let t of this.#ty)t.unselect();for(let e of(this.#ty.clear(),t))e.isEmpty()||(this.#ty.add(e),e.select());this.#tU({hasSelectedEditor:this.hasSelection})}selectAll(){for(let t of this.#ty)t.commit();this.#tX(this.#N.values())}unselectAll(){if(!this.#R||(this.#R.commitOrRemove(),this.#tb===u.NONE)){if(!this.#X?.commitOrRemove()&&(this.#V?.destroyPopup(),this.hasSelection)){for(let t of this.#ty)t.unselect();this.#ty.clear(),this.#tU({hasSelectedEditor:!1})}}}translateSelectedEditors(t,e,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;this.#tT[0]+=t,this.#tT[1]+=e;let[s,r]=this.#tT,a=[...this.#ty];for(let i of(this.#tS&&clearTimeout(this.#tS),this.#tS=setTimeout(()=>{this.#tS=null,this.#tT[0]=this.#tT[1]=0,this.addCommands({cmd:()=>{for(let t of a)this.#N.has(t.id)&&(t.translateInPage(s,r),t.translationDone())},undo:()=>{for(let t of a)this.#N.has(t.id)&&(t.translateInPage(-s,-r),t.translationDone())},mustExec:!1})},1e3),a))i.translateInPage(t,e),i.translationDone()}setUpDragSession(){if(this.hasSelection)for(let t of(this.disableUserSelect(!0),this.#Y=new Map,this.#ty))this.#Y.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}endDragSession(){if(!this.#Y)return!1;this.disableUserSelect(!1);let t=this.#Y;this.#Y=null;let e=!1;for(let[{x:i,y:s,pageIndex:r},a]of t)a.newX=i,a.newY=s,a.newPageIndex=r,e||=i!==a.savedX||s!==a.savedY||r!==a.savedPageIndex;if(!e)return!1;let i=(t,e,i,s)=>{if(this.#N.has(t.id)){let r=this.#U.get(s);r?t._setParentAndPosition(r,e,i):(t.pageIndex=s,t.x=e,t.y=i)}};return this.addCommands({cmd:()=>{for(let[e,{newX:s,newY:r,newPageIndex:a}]of t)i(e,s,r,a)},undo:()=>{for(let[e,{savedX:s,savedY:r,savedPageIndex:a}]of t)i(e,s,r,a)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#Y)for(let i of this.#Y.keys())i.drag(t,e)}rebuild(t){if(null===t.parent){let 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()||1===this.#ty.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#R===t}getActive(){return this.#R}getMode(){return this.#tb}isEditingMode(){return this.#tb!==u.NONE}get imageManager(){return M(this,"imageManager",new tF)}getSelectionBoxes(t){let e;if(!t)return null;let i=document.getSelection();for(let e=0,s=i.rangeCount;e<s;e++)if(!t.contains(i.getRangeAt(e).commonAncestorContainer))return null;let{x:s,y:r,width:a,height:n}=t.getBoundingClientRect();switch(t.getAttribute("data-main-rotation")){case"90":e=(t,e,i,o)=>({x:(e-r)/n,y:1-(t+i-s)/a,width:o/n,height:i/a});break;case"180":e=(t,e,i,o)=>({x:1-(t+i-s)/a,y:1-(e+o-r)/n,width:i/a,height:o/n});break;case"270":e=(t,e,i,o)=>({x:1-(e+o-r)/n,y:(t-s)/a,width:o/n,height:i/a});break;default:e=(t,e,i,o)=>({x:(t-s)/a,y:(e-r)/n,width:i/a,height:o/n})}let o=[];for(let t=0,s=i.rangeCount;t<s;t++){let s=i.getRangeAt(t);if(!s.collapsed)for(let{x:t,y:i,width:r,height:a}of s.getClientRects())0!==r&&0!==a&&o.push(e(t,i,r,a))}return 0===o.length?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#G||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#G?.delete(t)}renderAnnotationElement(t){let e=this.#G?.get(t.data.id);if(!e)return;let i=this.#$.getRawValue(e);!i||(this.#tb!==u.NONE||i.hasBeenModified)&&i.renderAnnotationElement(t)}setMissingCanvas(t,e,i){let s=this.#tm?.get(t);s&&(s.setCanvas(e,i),this.#tm.delete(t))}addMissingCanvas(t,e){(this.#tm||=new Map).set(t,e)}}class tU{#l=null;#tZ=!1;#t0=null;#t1=null;#t2=null;#t3=null;#t5=!1;#t6=null;#n=null;#t4=null;#t8=null;#t7=!1;static #t9=null;static _l10n=null;constructor(t){this.#n=t,this.#t7=t._uiManager.useNewAltTextFlow,tU.#t9||=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){tU._l10n??=t}async render(){let t=this.#t0=document.createElement("button");t.className="altText",t.tabIndex="0";let e=this.#t1=document.createElement("span");t.append(e),this.#t7?(t.classList.add("new"),t.setAttribute("data-l10n-id",tU.#t9.missing),e.setAttribute("data-l10n-id",tU.#t9["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));let i=this.#n._uiManager._signal;t.addEventListener("contextmenu",to,{signal:i}),t.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:i});let s=t=>{t.preventDefault(),this.#n._uiManager.editAltText(this.#n),this.#t7&&this.#n._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#et}})};return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",e=>{e.target===t&&"Enter"===e.key&&(this.#t5=!0,s(e))},{signal:i}),await this.#ee(),t}get #et(){return this.#l&&"added"||null===this.#l&&this.guessedText&&"review"||"missing"}finish(){this.#t0&&(this.#t0.focus({focusVisible:this.#t5}),this.#t5=!1)}isEmpty(){return this.#t7?null===this.#l:!this.#l&&!this.#tZ}hasData(){return this.#t7?null!==this.#l||!!this.#t4:this.isEmpty()}get guessedText(){return this.#t4}async setGuessedText(t){null===this.#l&&(this.#t4=t,this.#t8=await tU._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#ee())}toggleAltTextBadge(t=!1){if(!this.#t7||this.#l){this.#t6?.remove(),this.#t6=null;return}if(!this.#t6){let t=this.#t6=document.createElement("div");t.className="noAltTextBadge",this.#n.div.append(t)}this.#t6.classList.toggle("hidden",!t)}serialize(t){let e=this.#l;return t||this.#t4!==e||(e=this.#t8),{altText:e,decorative:this.#tZ,guessedText:this.#t4,textWithDisclaimer:this.#t8}}get data(){return{altText:this.#l,decorative:this.#tZ}}set data({altText:t,decorative:e,guessedText:i,textWithDisclaimer:s,cancel:r=!1}){i&&(this.#t4=i,this.#t8=s),(this.#l!==t||this.#tZ!==e)&&(r||(this.#l=t,this.#tZ=e),this.#ee())}toggle(t=!1){this.#t0&&(!t&&this.#t3&&(clearTimeout(this.#t3),this.#t3=null),this.#t0.disabled=!t)}shown(){this.#n._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#et}})}destroy(){this.#t0?.remove(),this.#t0=null,this.#t1=null,this.#t2=null,this.#t6?.remove(),this.#t6=null}async #ee(){let t=this.#t0;if(!t)return;if(this.#t7){if(t.classList.toggle("done",!!this.#l),t.setAttribute("data-l10n-id",tU.#t9[this.#et]),this.#t1?.setAttribute("data-l10n-id",tU.#t9[`${this.#et}-label`]),!this.#l)return void this.#t2?.remove()}else{if(!this.#l&&!this.#tZ){t.classList.remove("done"),this.#t2?.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#t2;if(!e){this.#t2=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#n.id}`;let i=this.#n._uiManager._signal;i.addEventListener("abort",()=>{clearTimeout(this.#t3),this.#t3=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#t3=setTimeout(()=>{this.#t3=null,this.#t2.classList.add("show"),this.#n._reportTelemetry({action:"alt_text_tooltip"})},100)},{signal:i}),t.addEventListener("mouseleave",()=>{this.#t3&&(clearTimeout(this.#t3),this.#t3=null),this.#t2?.classList.remove("show")},{signal:i})}this.#tZ?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#l),e.parentNode||t.append(e);let i=this.#n.getElementForAltText();i?.setAttribute("aria-describedby",e.id)}}class tH{#ei=null;#es=null;#er=!1;#n=null;#ea=null;#en=null;#eo=null;#el=null;#eh=!1;#ed=null;constructor(t){this.#n=t}renderForToolbar(){let t=this.#es=document.createElement("button");return t.className="comment",this.#v(t,!1)}renderForStandalone(){let t=this.#ei=document.createElement("button");t.className="annotationCommentButton";let e=this.#n.commentButtonPosition;if(e){let{style:i}=t;i.insetInlineEnd=`calc(${100*("ltr"===this.#n._uiManager.direction?1-e[0]:e[0])}% - var(--comment-button-dim))`,i.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;let s=this.#n.commentButtonColor;s&&(i.backgroundColor=s)}return this.#v(t,!0)}focusButton(){setTimeout(()=>{(this.#ei??this.#es)?.focus()},0)}onUpdatedColor(){if(!this.#ei)return;let t=this.#n.commentButtonColor;t&&(this.#ei.style.backgroundColor=t),this.#n._uiManager.updatePopupColor(this.#n)}get commentButtonWidth(){return(this.#ei?.getBoundingClientRect().width??0)/this.#n.parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(this.#ed)return this.#ed;if(!this.#ei)return null;let{x:t,y:e,height:i}=this.#ei.getBoundingClientRect(),{x:s,y:r,width:a,height:n}=this.#n.parent.boundingClientRect;return[(t-s)/a,(e+i-r)/n]}set commentPopupPositionInLayer(t){this.#ed=t}hasDefaultPopupPosition(){return null===this.#ed}removeStandaloneCommentButton(){this.#ei?.remove(),this.#ei=null}removeToolbarCommentButton(){this.#es?.remove(),this.#es=null}setCommentButtonStates({selected:t,hasPopup:e}){this.#ei&&(this.#ei.classList.toggle("selected",t),this.#ei.ariaExpanded=e)}#v(t,e){if(!this.#n._uiManager.hasCommentManager())return null;t.tabIndex="0",t.ariaHasPopup="dialog",e?(t.ariaControls="commentPopup",t.setAttribute("data-l10n-id","pdfjs-show-comment-button")):(t.ariaControlsElements=[this.#n._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button"));let i=this.#n._uiManager._signal;if(!(i instanceof AbortSignal)||i.aborted)return t;t.addEventListener("contextmenu",to,{signal:i}),e&&(t.addEventListener("focusin",t=>{this.#n._focusEventsAllowed=!1,tl(t)},{capture:!0,signal:i}),t.addEventListener("focusout",t=>{this.#n._focusEventsAllowed=!0,tl(t)},{capture:!0,signal:i})),t.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:i});let s=e=>{e.preventDefault(),t===this.#es?this.edit():this.#n.toggleComment(!0)};return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",e=>{e.target===t&&"Enter"===e.key&&(this.#er=!0,s(e))},{signal:i}),t.addEventListener("pointerenter",()=>{this.#n.toggleComment(!1,!0)},{signal:i}),t.addEventListener("pointerleave",()=>{this.#n.toggleComment(!1,!1)},{signal:i}),t}edit(t){let e,i,s=this.commentPopupPositionInLayer;if(s)[e,i]=s;else{[e,i]=this.#n.commentButtonPosition;let{width:t,height:s,x:r,y:a}=this.#n;e=r+e*t,i=a+i*s}let r=this.#n.parent.boundingClientRect,{x:a,y:n,width:o,height:l}=r;this.#n._uiManager.editComment(this.#n,a+e*o,n+i*l,{...t,parentDimensions:r})}finish(){this.#es&&(this.#es.focus({focusVisible:this.#er}),this.#er=!1)}isDeleted(){return this.#eh||""===this.#eo}isEmpty(){return null===this.#eo}hasBeenEdited(){return this.isDeleted()||this.#eo!==this.#ea}serialize(){return this.data}get data(){return{text:this.#eo,richText:this.#en,date:this.#el,deleted:this.isDeleted()}}set data(t){if(t!==this.#eo&&(this.#en=null),null===t){this.#eo="",this.#eh=!0;return}this.#eo=t,this.#el=new Date,this.#eh=!1}restoreData({text:t,richText:e,date:i}){this.#eo=t,this.#en=e,this.#el=i,this.#eh=!1}setInitialText(t,e=null){this.#ea=t,this.data=t,this.#el=null,this.#en=e}shown(){}destroy(){this.#es?.remove(),this.#es=null,this.#ei?.remove(),this.#ei=null,this.#eo="",this.#en=null,this.#el=null,this.#n=null,this.#er=!1,this.#eh=!1}}class tz{#tE;#ec=!1;#eu=null;#ep;#eg;#em;#ef;#eb=null;#ey;#ev=null;#eA;#ex=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:i=null,onPinchStart:s=null,onPinching:r=null,onPinchEnd:a=null,signal:n}){this.#tE=t,this.#eu=i,this.#ep=e,this.#eg=s,this.#em=r,this.#ef=a,this.#eA=new AbortController,this.#ey=AbortSignal.any([n,this.#eA.signal]),t.addEventListener("touchstart",this.#ew.bind(this),{passive:!1,signal:this.#ey})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/tf.pixelRatio}#ew(t){if(this.#ep?.())return;if(1===t.touches.length){if(this.#eb)return;let t=this.#eb=new AbortController,e=AbortSignal.any([this.#ey,t.signal]),i=this.#tE,s={capture:!0,signal:e,passive:!1},r=t=>{"touch"===t.pointerType&&(this.#eb?.abort(),this.#eb=null)};i.addEventListener("pointerdown",t=>{"touch"===t.pointerType&&(tl(t),r(t))},s),i.addEventListener("pointerup",r,s),i.addEventListener("pointercancel",r,s);return}if(!this.#ex){this.#ex=new AbortController;let t=AbortSignal.any([this.#ey,this.#ex.signal]),e=this.#tE,i={signal:t,capture:!1,passive:!1};e.addEventListener("touchmove",this.#e_.bind(this),i);let s=this.#eC.bind(this);e.addEventListener("touchend",s,i),e.addEventListener("touchcancel",s,i),i.capture=!0,e.addEventListener("pointerdown",tl,i),e.addEventListener("pointermove",tl,i),e.addEventListener("pointercancel",tl,i),e.addEventListener("pointerup",tl,i),this.#eg?.()}if(tl(t),2!==t.touches.length||this.#eu?.()){this.#ev=null;return}let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]),this.#ev={touch0X:e.screenX,touch0Y:e.screenY,touch1X:i.screenX,touch1Y:i.screenY}}#e_(t){if(!this.#ev||2!==t.touches.length)return;tl(t);let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]);let{screenX:s,screenY:r}=e,{screenX:a,screenY:n}=i,o=this.#ev,{touch0X:l,touch0Y:h,touch1X:d,touch1Y:c}=o,u=Math.hypot(a-s,n-r)||1,p=Math.hypot(d-l,c-h)||1;if(!this.#ec&&Math.abs(p-u)<=tz.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(o.touch0X=s,o.touch0Y=r,o.touch1X=a,o.touch1Y=n,!this.#ec){this.#ec=!0;return}let g=[(s+a)/2,(r+n)/2];this.#em?.(g,p,u)}#eC(t){t.touches.length>=2||(this.#ex&&(this.#ex.abort(),this.#ex=null,this.#ef?.()),this.#ev&&(tl(t),this.#ev=null,this.#ec=!1))}destroy(){this.#eA?.abort(),this.#eA=null,this.#eb?.abort(),this.#eb=null}}class t${#eT=null;#eS=null;#l=null;#h=null;#ei=null;#eE=!1;#eM=null;#eP="";#ek=null;#eD=null;#eI=null;#eB=null;#eF=null;#eL="";#eR=!1;#eO=null;#eN=!1;#eU=!1;#eH=!1;#ez=null;#e$=0;#eG=0;#ej=null;#eV=null;isSelected=!1;_isCopy=!1;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#eW=!1;#eX=t$._zIndex++;static _borderLineWidth=-1;static _colorManager=new tO;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){let t=t$.prototype._resizeWithKeyboard,e=tN.TRANSLATE_SMALL,i=tN.TRANSLATE_BIG;return M(this,"_resizerKeyboardManager",new tR([[["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"],t$.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,this.annotationElementId=t.annotationElementId||null,this.creationDate=t.creationDate||new Date,this.modificationDate=t.modificationDate||null,this.canAddComment=!0;const{rotation:e,rawDims:{pageWidth:i,pageHeight:s,pageX:r,pageY:a}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,s],this.pageTranslation=[r,a];const[n,o]=this.parentDimensions;this.x=t.x/n,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}updatePageIndex(t){this.pageIndex=t}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return M(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){let e=new tG({id:t._uiManager.getId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(t$._l10n??=t,t$._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"}),-1!==t$._borderLineWidth)return;let i=getComputedStyle(document.documentElement);t$._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){_("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#eW}set _isDraggable(t){this.#eW=t,this.div?.classList.toggle("draggable",t)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){let[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(2*t),this.y+=this.width*t/(2*e);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(2*t),this.y-=this.width*t/(2*e);break;default:this.x-=this.width/2,this.y-=this.height/2}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.#eX}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(this.#eq(),this.#eB?.remove(),this.#eB=null),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#eR?this.#eR=!1:this.parent.setSelected(this))}focusout(t){if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;let e=t.relatedTarget;!e?.closest(`#${this.id}`)&&(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,i,s){let[r,a]=this.parentDimensions;[i,s]=this.screenToPageTranslation(i,s),this.x=(t+i)/r,this.y=(e+s)/a,this.fixAndSetPosition()}_moveAfterPaste(t,e){if(this.isClone)return void delete this.isClone;let[i,s]=this.parentDimensions;this.setAt(t*i,e*s,this.width*i,this.height*s),this._onTranslated()}#eK([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.#eK(this.parentDimensions,t,e)}translateInPage(t,e){this.#eO||=[this.x,this.y,this.width,this.height],this.#eK(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){this.#eO||=[this.x,this.y,this.width,this.height];let{div:i,parentDimensions:[s,r]}=this;if(this.x+=t/s,this.y+=e/r,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{x:t,y:e}=this.div.getBoundingClientRect();this.parent.findNewParent(this,t,e)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:a,y:n}=this,[o,l]=this.getBaseTranslation();a+=o,n+=l;let{style:h}=i;h.left=`${(100*a).toFixed(2)}%`,h.top=`${(100*n).toFixed(2)}%`,this._onTranslating(a,n),i.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#eO&&(this.#eO[0]!==this.x||this.#eO[1]!==this.y)}get _hasBeenResized(){return!!this.#eO&&(this.#eO[2]!==this.width||this.#eO[3]!==this.height)}getBaseTranslation(){let[t,e]=this.parentDimensions,{_borderLineWidth:i}=t$,s=i/t,r=i/e;switch(this.rotation){case 90:return[-s,r];case 180:return[s,r];case 270:return[s,-r];default:return[-s,-r]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){let{div:{style:e},pageDimensions:[i,s]}=this,{x:r,y:a,width:n,height:o}=this;if(n*=i,o*=s,r*=i,a*=s,this._mustFixPosition)switch(t){case 0:r=X(r,0,i-n),a=X(a,0,s-o);break;case 90:r=X(r,0,i-o),a=X(a,n,s);break;case 180:r=X(r,n,i),a=X(a,o,s);break;case 270:r=X(r,o,i),a=X(a,0,s-n)}this.x=r/=i,this.y=a/=s;let[l,h]=this.getBaseTranslation();r+=l,a+=h,e.left=`${(100*r).toFixed(2)}%`,e.top=`${(100*a).toFixed(2)}%`,this.moveInDOM()}static #eY(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 t$.#eY(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return t$.#eY(t,e,360-this.parentRotation)}#eQ(t){switch(t){case 90:{let[t,e]=this.pageDimensions;return[0,-t/e,e/t,0]}case 180:return[-1,0,0,-1];case 270:{let[t,e]=this.pageDimensions;return[0,t/e,-e/t,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(){let{parentScale:t,pageDimensions:[e,i]}=this;return[e*t,i*t]}setDims(){let{div:{style:t},width:e,height:i}=this;t.width=`${(100*e).toFixed(2)}%`,t.height=`${(100*i).toFixed(2)}%`}getInitialTranslation(){return[0,0]}#eJ(){if(this.#ek)return;this.#ek=document.createElement("div"),this.#ek.classList.add("resizers");let t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(let i of t){let t=document.createElement("div");this.#ek.append(t),t.classList.add("resizer",i),t.setAttribute("data-resizer-name",i),t.addEventListener("pointerdown",this.#eZ.bind(this,i),{signal:e}),t.addEventListener("contextmenu",to,{signal:e}),t.tabIndex=-1}this.div.prepend(this.#ek)}#eZ(t,e){e.preventDefault();let{isMac:i}=O.platform;if(0!==e.button||e.ctrlKey&&i)return;this.#l?.toggle(!1);let s=this._isDraggable;this._isDraggable=!1,this.#eD=[e.screenX,e.screenY];let r=new AbortController,a=this._uiManager.combinedSignal(r);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#e0.bind(this,t),{passive:!0,capture:!0,signal:a}),window.addEventListener("touchmove",tl,{passive:!1,signal:a}),window.addEventListener("contextmenu",to,{signal:a}),this.#eI={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let n=this.parent.div.style.cursor,o=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;let l=()=>{r.abort(),this.parent.togglePointerEvents(!0),this.#l?.toggle(!0),this._isDraggable=s,this.parent.div.style.cursor=n,this.div.style.cursor=o,this.#e1()};window.addEventListener("pointerup",l,{signal:a}),window.addEventListener("blur",l,{signal:a})}#e2(t,e,i,s){this.width=i,this.height=s,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()}_onResized(){}#e1(){if(!this.#eI)return;let{savedX:t,savedY:e,savedWidth:i,savedHeight:s}=this.#eI;this.#eI=null;let r=this.x,a=this.y,n=this.width,o=this.height;(r!==t||a!==e||n!==i||o!==s)&&this.addCommands({cmd:this.#e2.bind(this,r,a,n,o),undo:this.#e2.bind(this,t,e,i,s),mustExec:!0})}static _round(t){return Math.round(1e4*t)/1e4}#e0(t,e){let i,s,r,a,n,o,[l,h]=this.parentDimensions,d=this.x,c=this.y,u=this.width,p=this.height,g=t$.MIN_SIZE/l,m=t$.MIN_SIZE/h,f=this.#eQ(this.rotation),b=(t,e)=>[f[0]*t+f[2]*e,f[1]*t+f[3]*e],y=this.#eQ(360-this.rotation),v=!1,A=!1;switch(t){case"topLeft":v=!0,i=(t,e)=>[0,0],s=(t,e)=>[t,e];break;case"topMiddle":i=(t,e)=>[t/2,0],s=(t,e)=>[t/2,e];break;case"topRight":v=!0,i=(t,e)=>[t,0],s=(t,e)=>[0,e];break;case"middleRight":A=!0,i=(t,e)=>[t,e/2],s=(t,e)=>[0,e/2];break;case"bottomRight":v=!0,i=(t,e)=>[t,e],s=(t,e)=>[0,0];break;case"bottomMiddle":i=(t,e)=>[t/2,e],s=(t,e)=>[t/2,0];break;case"bottomLeft":v=!0,i=(t,e)=>[0,e],s=(t,e)=>[t,0];break;case"middleLeft":A=!0,i=(t,e)=>[0,e/2],s=(t,e)=>[t,e/2]}let x=i(u,p),w=s(u,p),_=b(...w),C=t$._round(d+_[0]),T=t$._round(c+_[1]),S=1,E=1;if(e.fromKeyboard)({deltaX:r,deltaY:a}=e);else{let{screenX:t,screenY:i}=e,[s,n]=this.#eD;[r,a]=this.screenToPageTranslation(t-s,i-n),this.#eD[0]=t,this.#eD[1]=i}if([r,a]=(n=r/l,o=a/h,[y[0]*n+y[2]*o,y[1]*n+y[3]*o]),v){let t=Math.hypot(u,p);S=E=Math.max(Math.min(Math.hypot(w[0]-x[0]-r,w[1]-x[1]-a)/t,1/u,1/p),g/u,m/p)}else A?S=X(Math.abs(w[0]-x[0]-r),g,1)/u:E=X(Math.abs(w[1]-x[1]-a),m,1)/p;let M=t$._round(u*S),P=t$._round(p*E),k=C-(_=b(...s(M,P)))[0],D=T-_[1];this.#eO||=[this.x,this.y,this.width,this.height],this.width=M,this.height=P,this.x=k,this.y=D,this.setDims(),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#l?.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||this.#eU)return this._editToolbar;this._editToolbar=new tP(this),this.div.append(this._editToolbar.render());let{toolbarButtons:t}=this;if(t)for(let[e,i]of t)await this._editToolbar.addButton(e,i);return this.hasComment||this._editToolbar.addButton("comment",this.addCommentButton()),this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){this._editToolbar?.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){this._editToolbar?.removeButton("comment")}removeEditToolbar(){this._editToolbar?.remove(),this._editToolbar=null,this.#l?.destroy()}addContainer(t){let e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return!this.#l&&(tU.initialize(t$._l10n),this.#l=new tU(this),this.#eT&&(this.#l.data=this.#eT,this.#eT=null)),this.#l}get altTextData(){return this.#l?.data}set altTextData(t){this.#l&&(this.#l.data=t)}get guessedAltText(){return this.#l?.guessedText}async setGuessedAltText(t){await this.#l?.setGuessedText(t)}serializeAltText(t){return this.#l?.serialize(t)}hasAltText(){return!!this.#l&&!this.#l.isEmpty()}hasAltTextData(){return this.#l?.hasData()??!1}focusCommentButton(){this.#h?.focusButton()}addCommentButton(){return this.canAddComment?this.#h||=new tH(this):null}addStandaloneCommentButton(){if(this._uiManager.hasCommentManager()){if(this.#ei){this._uiManager.isEditingMode()&&this.#ei.classList.remove("hidden");return}this.hasComment&&(this.#ei=this.#h.renderForStandalone(),this.div.append(this.#ei))}}removeStandaloneCommentButton(){this.#h.removeStandaloneCommentButton(),this.#ei=null}hideStandaloneCommentButton(){this.#ei?.classList.add("hidden")}get comment(){if(!this.#h)return null;let{data:{richText:t,text:e,date:i,deleted:s}}=this.#h;return{text:e,richText:t,date:i,deleted:s,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){this.#h||=new tH(this),"object"==typeof t&&null!==t?this.#h.restoreData(t):this.#h.data=t,this.hasComment?(this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this)):(this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this))}setCommentData({comment:t,popupRef:e,richText:i}){if(!e||(this.#h||=new tH(this),this.#h.setInitialText(t,i),!this.annotationElementId))return;let s=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);s&&this.updateFromAnnotationLayer(s)}get hasEditedComment(){return this.#h?.hasBeenEdited()}get hasDeletedComment(){return this.#h?.isDeleted()}get hasComment(){return!!this.#h&&!this.#h.isEmpty()&&!this.#h.isDeleted()}async editComment(t){this.#h||=new tH(this),this.#h.edit(t)}toggleComment(t,e){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){this.#h.setSelectedButton(t)}addComment(t){if(this.hasEditedComment){let[,,,e]=t.rect,[i]=this.pageDimensions,[s]=this.pageTranslation,r=s+i+1;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[r,e-100,r+180,e]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){this.#h.data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){let t=this.div=document.createElement("div");t.setAttribute("data-editor-rotation",(360-this.rotation)%360),t.className=this.name,t.setAttribute("id",this.id),t.tabIndex=this.#eE?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),this.#e3();let[e,i]=this.parentDimensions;this.parentRotation%180!=0&&(t.style.maxWidth=`${(100*i/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/i).toFixed(2)}%`);let[s,r]=this.getInitialTranslation();return this.translate(s,r),tD(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#eV||=new tz({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#e5.bind(this),onPinching:this.#e6.bind(this),onPinchEnd:this.#e4.bind(this),signal:this._uiManager._signal})),this.addStandaloneCommentButton(),this._uiManager._editorUndoBar?.hide(),t}#e5(){this.#eI={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#l?.toggle(!1),this.parent.togglePointerEvents(!1)}#e6(t,e,i){let s=i/e*.7+1-.7;if(1===s)return;let r=this.#eQ(this.rotation),a=(t,e)=>[r[0]*t+r[2]*e,r[1]*t+r[3]*e],[n,o]=this.parentDimensions,l=this.x,h=this.y,d=this.width,c=this.height;s=Math.max(Math.min(s,1/d,1/c),t$.MIN_SIZE/n/d,t$.MIN_SIZE/o/c);let u=t$._round(d*s),p=t$._round(c*s);if(u===d&&p===c)return;this.#eO||=[l,h,d,c];let g=a(d/2,c/2),m=t$._round(l+g[0]),f=t$._round(h+g[1]),b=a(u/2,p/2);this.x=m-b[0],this.y=f-b[1],this.width=u,this.height=p,this.setDims(),this.fixAndSetPosition(),this._onResizing()}#e4(){this.#l?.toggle(!0),this.parent.togglePointerEvents(!0),this.#e1()}pointerdown(t){let{isMac:e}=O.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(this.#eR=!0,this._isDraggable)?this.#e8(t):this.#e7(t)}#e7(t){let{isMac:e}=O.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#e8(t){let{isSelected:e}=this;this._uiManager.setUpDragSession();let i=!1,s=new AbortController,r=this._uiManager.combinedSignal(s),a={capture:!0,passive:!1,signal:r},n=t=>{s.abort(),this.#eM=null,this.#eR=!1,this._uiManager.endDragSession()||this.#e7(t),i&&this._onStopDragging()};e&&(this.#e$=t.clientX,this.#eG=t.clientY,this.#eM=t.pointerId,this.#eP=t.pointerType,window.addEventListener("pointermove",t=>{i||(i=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());let{clientX:e,clientY:s,pointerId:r}=t;if(r!==this.#eM)return void tl(t);let[a,n]=this.screenToPageTranslation(e-this.#e$,s-this.#eG);this.#e$=e,this.#eG=s,this._uiManager.dragSelectedEditors(a,n)},a),window.addEventListener("touchmove",tl,a),window.addEventListener("pointerdown",t=>{t.pointerType===this.#eP&&(this.#eV||t.isPrimary)&&n(t),tl(t)},a));let o=t=>{this.#eM&&this.#eM!==t.pointerId?tl(t):n(t)};window.addEventListener("pointerup",o,{signal:r}),window.addEventListener("blur",o,{signal:r})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#ez&&clearTimeout(this.#ez),this.#ez=setTimeout(()=>{this.#ez=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){let s=this.parentScale,[r,a]=this.pageDimensions,[n,o]=this.pageTranslation,l=t/s,h=e/s,d=this.x*r,c=this.y*a,u=this.width*r,p=this.height*a;switch(i){case 0:return[d+l+n,a-c-h-p+o,d+l+u+n,a-c-h+o];case 90:return[d+h+n,a-c+l+o,d+h+p+n,a-c+l+u+o];case 180:return[d-l-u+n,a-c+h+o,d-l+n,a-c+h+p+o];case 270:return[d-h-p+n,a-c-l-u+o,d-h+n,a-c-l+o];default:throw Error("Invalid rotation")}}getRectInCurrentCoords(t,e){let[i,s,r,a]=t,n=r-i,o=a-s;switch(this.rotation){case 0:return[i,e-a,n,o];case 90:return[i,e-s,o,n];case 180:return[r,e-s,n,o];case 270:return[r,e-a,o,n];default:throw Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&t$._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){this.#h?.onUpdatedColor()}getData(){let{comment:{text:t,color:e,date:i,opacity:s,deleted:r,richText:a},uid:n,pageIndex:o,creationDate:l,modificationDate:h}=this;return{id:n,pageIndex:o,rect:this.getPDFRect(),richText:a,contentsObj:{str:t},creationDate:l,modificationDate:i||h,popupRef:!r,color:e,opacity:s}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return!this.isInEditMode()&&(this.parent.setEditingState(!1),this.#eU=!0,!0)}disableEditMode(){return!!this.isInEditMode()&&(this.parent.setEditingState(!0),this.#eU=!1,!0)}isInEditMode(){return this.#eU}shouldGetKeyboardEvents(){return this.#eH}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){let{top:t,left:e,bottom:i,right:s}=this.getClientDimensions(),{innerHeight:r,innerWidth:a}=window;return e<a&&s>0&&t<r&&i>0}#e3(){if(this.#eF||!this.div)return;this.#eF=new AbortController;let t=this._uiManager.combinedSignal(this.#eF);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#e3()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:this._initialData?.popupRef||""}}static async deserialize(t,e,i){let s=new this.prototype.constructor({parent:e,id:i.getId(),uiManager:i,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});s.rotation=t.rotation,s.#eT=t.accessibilityData,s._isCopy=t.isCopy||!1;let[r,a]=s.pageDimensions,[n,o,l,h]=s.getRectInCurrentCoords(t.rect,a);return s.x=n/r,s.y=o/a,s.width=l/r,s.height=h/a,s}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.#eF?.abort(),this.#eF=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),this.#ez&&(clearTimeout(this.#ez),this.#ez=null),this.#eq(),this.removeEditToolbar(),this.#ej){for(let t of this.#ej.values())clearTimeout(t);this.#ej=null}this.parent=null,this.#eV?.destroy(),this.#eV=null,this.#eB?.remove(),this.#eB=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#eJ(),this.#ek.classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return"ltr"===this._uiManager.direction?[1,0]:[0,0]}get commentButtonPositionInPage(){let{commentButtonPosition:[t,e]}=this,[i,s,r,a]=this.getPDFRect();return[t$._round(i+(r-i)*t),t$._round(s+(a-s)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return this.#h.commentPopupPositionInLayer}set commentPopupPosition(t){this.#h.commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return this.#h.hasDefaultPopupPosition()}get commentButtonWidth(){return this.#h.commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){this.#h?.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||"Enter"!==t.key)return;this._uiManager.setSelected(this),this.#eI={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let e=this.#ek.children;if(!this.#eS){this.#eS=Array.from(e);let t=this.#e9.bind(this),i=this.#it.bind(this),s=this._uiManager._signal;for(let e of this.#eS){let r=e.getAttribute("data-resizer-name");e.setAttribute("role","spinbutton"),e.addEventListener("keydown",t,{signal:s}),e.addEventListener("blur",i,{signal:s}),e.addEventListener("focus",this.#ie.bind(this,r),{signal:s}),e.setAttribute("data-l10n-id",t$._l10nResizer[r])}}let i=this.#eS[0],s=0;for(let t of e){if(t===i)break;s++}let r=(360-this.rotation+this.parentRotation)%360/90*(this.#eS.length/4);if(r!==s){if(r<s)for(let t=0;t<s-r;t++)this.#ek.append(this.#ek.firstElementChild);else if(r>s)for(let t=0;t<r-s;t++)this.#ek.firstElementChild.before(this.#ek.lastElementChild);let t=0;for(let i of e){let e=this.#eS[t++].getAttribute("data-resizer-name");i.setAttribute("data-l10n-id",t$._l10nResizer[e])}}this.#ii(0),this.#eH=!0,this.#ek.firstElementChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#e9(t){t$._resizerKeyboardManager.exec(this,t)}#it(t){this.#eH&&t.relatedTarget?.parentNode!==this.#ek&&this.#eq()}#ie(t){this.#eL=this.#eH?t:""}#ii(t){if(this.#eS)for(let e of this.#eS)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#eH&&this.#e0(this.#eL,{deltaX:t,deltaY:e,fromKeyboard:!0})}#eq(){this.#eH=!1,this.#ii(-1),this.#e1()}_stopResizingWithKeyboard(){this.#eq(),this.div.focus()}select(){this.isSelected&&this._editToolbar?this._editToolbar.show():(this.isSelected=!0,this.makeResizable(),this.div?.classList.add("selectedEditor"),this._editToolbar)?(this._editToolbar?.show(),this.#l?.toggleAltTextBadge(!1)):this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()})}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>this.div?.focus({preventScroll:!0}),0)}unselect(){this.isSelected&&(this.isSelected=!1,this.#ek?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#l?.toggleAltTextBadge(!0),this.hideCommentPopup())}hideCommentPopup(){this.hasComment&&this._uiManager.toggleComment(null)}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){"BUTTON"!==t.target.nodeName&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return this.#eN}set isEditing(t){this.#eN=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}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.#ej||=new Map;let{action:e}=t,i=this.#ej.get(e);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),this.#ej.delete(e),0===this.#ej.size&&(this.#ej=null)},t$._telemetryTimeout),this.#ej.set(e,i);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.#eE=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#eE=!0}updateFakeAnnotationElement(t){if(!this.#eB&&!this.deleted){this.#eB=t.addFakeAnnotation(this);return}if(this.deleted){this.#eB.remove(),this.#eB=null;return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&this.#eB.updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let e=t.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){let t=e;(e=document.createElement("div")).classList.add("annotationContent",this.editorType),t.before(e)}}else(e=document.createElement("div")).classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){let{firstElementChild:e}=t.container;e?.nodeName==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}}class tG extends t${constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}class tj{constructor(t){this.h1=t?0|t:0xc3d2e1f0,this.h2=t?0|t:0xc3d2e1f0}update(t){let e,i;if("string"==typeof t){e=new Uint8Array(2*t.length),i=0;for(let s=0,r=t.length;s<r;s++){let r=t.charCodeAt(s);r<=255?e[i++]=r:(e[i++]=r>>>8,e[i++]=255&r)}}else if(ArrayBuffer.isView(t))i=(e=t.slice()).byteLength;else throw Error("Invalid data format, must be a string or TypedArray.");let s=i>>2,r=i-4*s,a=new Uint32Array(e.buffer,0,s),n=0,o=0,l=this.h1,h=this.h2;for(let t=0;t<s;t++)1&t?(l^=n=0x1b873593*(n=(n=0xcc9e2d51*(n=a[t])&0xffff0000|11601*n&65535)<<15|n>>>17)&0xffff0000|13715*n&65535,l=5*(l=l<<13|l>>>19)+0xe6546b64):(h^=o=0x1b873593*(o=(o=0xcc9e2d51*(o=a[t])&0xffff0000|11601*o&65535)<<15|o>>>17)&0xffff0000|13715*o&65535,h=5*(h=h<<13|h>>>19)+0xe6546b64);switch(n=0,r){case 3:n^=e[4*s+2]<<16;case 2:n^=e[4*s+1]<<8;case 1:n^=e[4*s],n=0x1b873593*(n=(n=0xcc9e2d51*n&0xffff0000|11601*n&65535)<<15|n>>>17)&0xffff0000|13715*n&65535,1&s?l^=n:h^=n}this.h1=l,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,e=0xff51afd7*e&0xffff0000|((e<<16|(t=0xed558ccd*t&0xffff0000|36045*t&65535)>>>16)*0xafd7ed55&0xffff0000)>>>16,t^=e>>>1,e=0xc4ceb9fe*e&0xffff0000|((e<<16|(t=0x1a85ec53*t&0xffff0000|60499*t&65535)>>>16)*0xb9fe1a85&0xffff0000)>>>16,((t^=e>>>1)>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}let tV=Object.freeze({map:null,hash:"",transfer:void 0});class tW{#is=!1;#ir=null;#ia=null;#io=new Map;onSetModified=null;onResetModified=null;onAnnotationEditor=null;getValue(t,e){let i=this.#io.get(t);return void 0===i?e:Object.assign(e,i)}getRawValue(t){return this.#io.get(t)}remove(t){let e=this.#io.get(t);void 0===e||(e instanceof t$&&this.#ia.delete(e.annotationElementId),this.#io.delete(t),0===this.#io.size&&this.resetModified(),this.#io.values().some(t=>t instanceof t$)||this.onAnnotationEditor?.(null))}setValue(t,e){let i=this.#io.get(t),s=!1;if(void 0!==i)for(let[t,r]of Object.entries(e))i[t]!==r&&(s=!0,i[t]=r);else s=!0,this.#io.set(t,e);s&&this.#il(),e instanceof t$&&((this.#ia||=new Map).set(e.annotationElementId,e),this.onAnnotationEditor?.(e.constructor._type))}has(t){return this.#io.has(t)}get size(){return this.#io.size}#il(){this.#is||(this.#is=!0,this.onSetModified?.())}resetModified(){this.#is&&(this.#is=!1,this.onResetModified?.())}get print(){return new tX(this)}get serializable(){if(0===this.#io.size)return tV;let t=new Map,e=new tj,i=[],s=Object.create(null),r=!1;for(let[i,a]of this.#io){let n=a instanceof t$?a.serialize(!1,s):a;a.page&&(a.pageIndex=a.page._pageIndex,delete a.page),n&&(t.set(i,n),e.update(`${i}:${JSON.stringify(n)}`),r||=!!n.bitmap)}if(r)for(let e of t.values())e.bitmap&&i.push(e.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:i}:tV}get editorStats(){let t=null,e=new Map,i=0,s=0;for(let r of this.#io.values()){if(!(r instanceof t$)){r.popup&&(r.popup.deleted?s+=1:i+=1);continue}r.isCommentDeleted?s+=1:r.hasEditedComment&&(i+=1);let a=r.telemetryFinalData;if(!a)continue;let{type:n}=a;e.has(n)||e.set(n,Object.getPrototypeOf(r).constructor),t||=Object.create(null);let o=t[n]||=new Map;for(let[t,e]of Object.entries(a)){if("type"===t)continue;let i=o.getOrInsertComputed(t,V);i.set(e,(i.get(e)??0)+1)}}if((s>0||i>0)&&((t||=Object.create(null)).comments={deleted:s,edited:i}),!t)return null;for(let[i,s]of e)t[i]=s.computeTelemetryFinalData(t[i]);return t}resetModifiedIds(){this.#ir=null}updateEditor(t,e){let i=this.#ia?.get(t);return!!i&&(i.updateFromAnnotationLayer(e),!0)}getEditor(t){return this.#ia?.get(t)||null}get modifiedIds(){if(this.#ir)return this.#ir;let t=[];if(this.#ia)for(let e of this.#ia.values())e.serialize()&&t.push(e.annotationElementId);let e="";if(t.length){let i=new tj;i.update(t.join(",")),e=i.hexdigest()}return this.#ir={ids:new Set(t),hash:e}}[Symbol.iterator](){return this.#io.entries()}}class tX extends tW{#ih=tV;constructor(t){super();const{serializable:e}=t;if(e===tV)return;const{map:i,hash:s,transfer:r}=e,a=structuredClone(i,r?{transfer:r}:null);this.#ih={map:a,hash:s,transfer:[]}}get print(){_("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#ih}get modifiedIds(){return M(this,"modifiedIds",{ids:new Set,hash:""})}}let tq="__forcedDependency",{floor:tK,ceil:tY}=Math;function tQ(t,e,i,s,r,a){t[4*e+0]=Math.min(t[4*e+0],i),t[4*e+1]=Math.min(t[4*e+1],s),t[4*e+2]=Math.max(t[4*e+2],r),t[4*e+3]=Math.max(t[4*e+3],a)}let tJ=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class tZ{#id;#ic;constructor(t,e){this.#id=t,this.#ic=e}get length(){return this.#id.length}isEmpty(t){return this.#id[t]===tJ}minX(t){return this.#ic[4*t+0]/256}minY(t){return this.#ic[4*t+1]/256}maxX(t){return(this.#ic[4*t+2]+1)/256}maxY(t){return(this.#ic[4*t+3]+1)/256}}let t0=(t,e)=>t?.getOrInsertComputed(e,()=>({dependencies:new Set,isRenderingOperation:!1}));class t1{#iu=[[1,0,0,1,0,0]];#ip=[-1/0,-1/0,1/0,1/0];#ig=new Float64Array(o);_pendingBBoxIdx=-1;#im;#ib;#iy;#id;_savesStack=[];_markedContentStack=[];constructor(t,e){this.#im=t.width,this.#ib=t.height,this.#iv(e)}growOperationsCount(t){t>=this.#id.length&&this.#iv(t,this.#id)}#iv(t,e){let i=new ArrayBuffer(4*t);this.#iy=new Uint8ClampedArray(i),this.#id=new Uint32Array(i),e&&e.length>0?(this.#id.set(e),this.#id.fill(tJ,e.length)):this.#id.fill(tJ)}get clipBox(){return this.#ip}save(t){return this.#ip={__proto__:this.#ip},this._savesStack.push(t),this}restore(t,e){let i=Object.getPrototypeOf(this.#ip);if(null===i)return this;this.#ip=i;let s=this._savesStack.pop();return void 0!==s&&(e?.(s,t),this.#id[t]=this.#id[s]),this}recordOpenMarker(t){return this._savesStack.push(t),this}getOpenMarker(){return 0===this._savesStack.length?null:this._savesStack.at(-1)}recordCloseMarker(t,e){let i=this._savesStack.pop();return void 0!==i&&(e?.(i,t),this.#id[t]=this.#id[i]),this}beginMarkedContent(t){return this._markedContentStack.push(t),this}endMarkedContent(t,e){let i=this._markedContentStack.pop();return void 0!==i&&(e?.(i,t),this.#id[t]=this.#id[i]),this}pushBaseTransform(t){return this.#iu.push(N.multiplyByDOMMatrix(this.#iu.at(-1),t.getTransform())),this}popBaseTransform(){return this.#iu.length>1&&this.#iu.pop(),this}resetBBox(t){return this._pendingBBoxIdx!==t&&(this._pendingBBoxIdx=t,this.#ig.set(o,0)),this}recordClipBox(t,e,i,s,r,a){let n=N.multiplyByDOMMatrix(this.#iu.at(-1),e.getTransform()),l=o.slice();N.axialAlignedBoundingBox([i,r,s,a],n,l);let h=N.intersect(this.#ip,l);return h?(this.#ip[0]=h[0],this.#ip[1]=h[1],this.#ip[2]=h[2],this.#ip[3]=h[3]):(this.#ip[0]=this.#ip[1]=1/0,this.#ip[2]=this.#ip[3]=-1/0),this}recordBBox(t,e,i,s,r,a){let n=this.#ip;if(n[0]===1/0)return this;let l=N.multiplyByDOMMatrix(this.#iu.at(-1),e.getTransform());if(n[0]===-1/0)return N.axialAlignedBoundingBox([i,r,s,a],l,this.#ig),this;let h=o.slice();return N.axialAlignedBoundingBox([i,r,s,a],l,h),this.#ig[0]=X(h[0],n[0],this.#ig[0]),this.#ig[1]=X(h[1],n[1],this.#ig[1]),this.#ig[2]=X(h[2],this.#ig[2],n[2]),this.#ig[3]=X(h[3],this.#ig[3],n[3]),this}recordFullPageBBox(t){return this.#ig[0]=Math.max(0,this.#ip[0]),this.#ig[1]=Math.max(0,this.#ip[1]),this.#ig[2]=Math.min(this.#im,this.#ip[2]),this.#ig[3]=Math.min(this.#ib,this.#ip[3]),this}recordOperation(t,e=!1,i){if(this._pendingBBoxIdx!==t)return this;let s=tK(256*this.#ig[0]/this.#im),r=tK(256*this.#ig[1]/this.#ib),a=tY(256*this.#ig[2]/this.#im),n=tY(256*this.#ig[3]/this.#ib);if(tQ(this.#iy,t,s,r,a,n),i)for(let e of i)for(let i of e)i!==t&&tQ(this.#iy,i,s,r,a,n);return e||(this._pendingBBoxIdx=-1),this}bboxToClipBoxDropOperation(t){return this._pendingBBoxIdx===t&&(this._pendingBBoxIdx=-1,this.#ip[0]=Math.max(this.#ip[0],this.#ig[0]),this.#ip[1]=Math.max(this.#ip[1],this.#ig[1]),this.#ip[2]=Math.min(this.#ip[2],this.#ig[2]),this.#ip[3]=Math.min(this.#ip[3],this.#ig[3])),this}take(){return new tZ(this.#id,this.#iy)}takeDebugMetadata(){throw Error("Unreachable")}recordSimpleData(t,e){return this}recordIncrementalData(t,e){return this}resetIncrementalData(t,e){return this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,i){return this}recordFutureForcedDependency(t,e){return this}inheritSimpleDataAsFutureForcedDependencies(t){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(t,e,i,s=1,r=0,a=0,n){return this}getSimpleIndex(t){}recordDependencies(t,e){return this}recordNamedDependency(t,e){return this}recordShowTextOperation(t,e=!1){return this}}class t2{#iA={__proto__:null};#ix={__proto__:null,transform:[],moveText:[],sameLineText:[],[tq]:[]};#iw=new Map;#i_=new Set;#iC=new Map;#iT;#iS;#iE;constructor(t,e=!1){this.#iE=t,e&&(this.#iT=new Map,this.#iS=(t,e)=>{t0(this.#iT,e).dependencies.add(t)})}get clipBox(){return this.#iE.clipBox}growOperationsCount(t){this.#iE.growOperationsCount(t)}save(t){return this.#iA={__proto__:this.#iA},this.#ix={__proto__:this.#ix,transform:{__proto__:this.#ix.transform},moveText:{__proto__:this.#ix.moveText},sameLineText:{__proto__:this.#ix.sameLineText},[tq]:{__proto__:this.#ix[tq]}},this.#iE.save(t),this}restore(t){this.#iE.restore(t,this.#iS);let e=Object.getPrototypeOf(this.#iA);return null===e||(this.#iA=e,this.#ix=Object.getPrototypeOf(this.#ix)),this}recordOpenMarker(t){return this.#iE.recordOpenMarker(t,this.#iS),this}getOpenMarker(){return this.#iE.getOpenMarker()}recordCloseMarker(t){return this.#iE.recordCloseMarker(t,this.#iS),this}beginMarkedContent(t){return this.#iE.beginMarkedContent(t),this}endMarkedContent(t){return this.#iE.endMarkedContent(t,this.#iS),this}pushBaseTransform(t){return this.#iE.pushBaseTransform(t),this}popBaseTransform(){return this.#iE.popBaseTransform(),this}recordSimpleData(t,e){return this.#iA[t]=e,this}recordIncrementalData(t,e){return this.#ix[t].push(e),this}resetIncrementalData(t,e){return this.#ix[t].length=0,this}recordNamedData(t,e){return this.#iw.set(t,e),this}recordSimpleDataFromNamed(t,e,i){this.#iA[t]=this.#iw.get(e)??i}recordFutureForcedDependency(t,e){return this.recordIncrementalData(tq,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(let e of t)e in this.#iA&&this.recordFutureForcedDependency(e,this.#iA[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(let t of this.#i_)this.recordFutureForcedDependency(tq,t);return this}resetBBox(t){return this.#iE.resetBBox(t),this}recordClipBox(t,e,i,s,r,a){return this.#iE.recordClipBox(t,e,i,s,r,a),this}recordBBox(t,e,i,s,r,a){return this.#iE.recordBBox(t,e,i,s,r,a),this}recordCharacterBBox(t,e,i,s=1,r=0,a=0,n){let o,l,h=i.bbox;if(h&&!1!==(o=h[2]!==h[0]&&h[3]!==h[1]&&this.#iC.get(i))&&(l=[0,0,0,0],N.axialAlignedBoundingBox(h,i.fontMatrix,l),(1!==s||0!==r||0!==a)&&N.scaleMinMax([s,0,0,-s,r,a],l),o))return this.recordBBox(t,e,l[0],l[2],l[1],l[3]);if(!n)return this.recordFullPageBBox(t);let d=n();return h&&l&&void 0===o&&(o=l[0]<=r-d.actualBoundingBoxLeft&&l[2]>=r+d.actualBoundingBoxRight&&l[1]<=a-d.actualBoundingBoxAscent&&l[3]>=a+d.actualBoundingBoxDescent,this.#iC.set(i,o),o)?this.recordBBox(t,e,l[0],l[2],l[1],l[3]):this.recordBBox(t,e,r-d.actualBoundingBoxLeft,r+d.actualBoundingBoxRight,a-d.actualBoundingBoxAscent,a+d.actualBoundingBoxDescent)}recordFullPageBBox(t){return this.#iE.recordFullPageBBox(t),this}getSimpleIndex(t){return this.#iA[t]}recordDependencies(t,e){let i=this.#i_,s=this.#iA,r=this.#ix;for(let t of e)t in this.#iA?i.add(s[t]):t in r&&r[t].forEach(i.add,i);return this}recordNamedDependency(t,e){return this.#iw.has(e)&&this.#i_.add(this.#iw.get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[tq]),this.#iT){let e=t0(this.#iT,t),{dependencies:i}=e;this.#i_.forEach(i.add,i),this.#iE._savesStack.forEach(i.add,i),this.#iE._markedContentStack.forEach(i.add,i),i.delete(t),e.isRenderingOperation=!0}let i=!e&&t===this.#iE._pendingBBoxIdx;return this.#iE.recordOperation(t,e,[this.#i_,this.#iE._savesStack,this.#iE._markedContentStack]),i&&this.#i_.clear(),this}recordShowTextOperation(t,e=!1){let i=Array.from(this.#i_);for(let s of(this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t),i))this.recordIncrementalData("sameLineText",s);return this}bboxToClipBoxDropOperation(t,e=!1){let i=!e&&t===this.#iE._pendingBBoxIdx;return this.#iE.bboxToClipBoxDropOperation(t),i&&this.#i_.clear(),this}take(){return this.#iC.clear(),this.#iE.take()}takeDebugMetadata(){return this.#iT}}class t3{#iM;#iP;#ik;#iD=0;#iI=0;constructor(t,e,i){if(t instanceof t3&&!!i===t.#ik)return t;this.#iM=t,this.#iP=e,this.#ik=!!i}get clipBox(){return this.#iM.clipBox}growOperationsCount(){throw Error("Unreachable")}save(t){return this.#iI++,this.#iM.save(this.#iP),this}restore(t){return this.#iI>0&&(this.#iM.restore(this.#iP),this.#iI--),this}recordOpenMarker(t){return this.#iD++,this}getOpenMarker(){return this.#iD>0?this.#iP:this.#iM.getOpenMarker()}recordCloseMarker(t){return this.#iD--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return this.#iM.pushBaseTransform(t),this}popBaseTransform(){return this.#iM.popBaseTransform(),this}recordSimpleData(t,e){return this.#iM.recordSimpleData(t,this.#iP),this}recordIncrementalData(t,e){return this.#iM.recordIncrementalData(t,this.#iP),this}resetIncrementalData(t,e){return this.#iM.resetIncrementalData(t,this.#iP),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,i){return this.#iM.recordSimpleDataFromNamed(t,e,this.#iP),this}recordFutureForcedDependency(t,e){return this.#iM.recordFutureForcedDependency(t,this.#iP),this}inheritSimpleDataAsFutureForcedDependencies(t){return this.#iM.inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return this.#iM.inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return this.#ik||this.#iM.resetBBox(this.#iP),this}recordClipBox(t,e,i,s,r,a){return this.#ik||this.#iM.recordClipBox(this.#iP,e,i,s,r,a),this}recordBBox(t,e,i,s,r,a){return this.#ik||this.#iM.recordBBox(this.#iP,e,i,s,r,a),this}recordCharacterBBox(t,e,i,s,r,a,n){return this.#ik||this.#iM.recordCharacterBBox(this.#iP,e,i,s,r,a,n),this}recordFullPageBBox(t){return this.#ik||this.#iM.recordFullPageBBox(this.#iP),this}getSimpleIndex(t){return this.#iM.getSimpleIndex(t)}recordDependencies(t,e){return this.#iM.recordDependencies(this.#iP,e),this}recordNamedDependency(t,e){return this.#iM.recordNamedDependency(this.#iP,e),this}recordOperation(t){return this.#iM.recordOperation(this.#iP,!0),this}recordShowTextOperation(t){return this.#iM.recordShowTextOperation(this.#iP,!0),this}bboxToClipBoxDropOperation(t){return this.#ik||this.#iM.bboxToClipBoxDropOperation(this.#iP,!0),this}take(){throw Error("Unreachable")}takeDebugMetadata(){throw Error("Unreachable")}}let t5=["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],t6=["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],t4=["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],t8=["filter","fillColor","fillAlpha"],t7=["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],t9=["transform"],et=["transform","fillColor"];class ee{#im;#ib;#iB=4;#iF=0;#ic=new ee.#iL(6*this.#iB);static #iL=O.isFloat16ArraySupported?Float16Array:Float32Array;constructor(t){this.#im=t.width,this.#ib=t.height}record(t,e,i,s){let r;if(this.#iF===this.#iB){this.#iB*=2;let t=new ee.#iL(6*this.#iB);t.set(this.#ic),this.#ic=t}let a=N.domMatrixToTransform(t.getTransform());if(s[0]!==1/0){let t=o.slice();N.axialAlignedBoundingBox([0,-i,e,0],a,t);let n=N.intersect(s,t);if(!n)return;let[l,h,d,c]=n;if(l!==t[0]||h!==t[1]||d!==t[2]||c!==t[3]){let t=Math.atan2(a[1],a[0]),e=Math.abs(Math.sin(t)),i=Math.abs(Math.cos(t));if(e<1e-6||i<1e-6||1e-6>Math.abs(e-i))r=[l,h,l,c,d,h];else{let t=d-l,s=c-h,a=e*e,n=i*i,o=i*e,u=n-a,p=(s*n-t*o)/u;r=[l+(s*o-t*a)/u,h,l,h+p,d,c-p]}}}r||(r=[0,-i,0,0,e,-i],N.applyTransform(r,a,0),N.applyTransform(r,a,2),N.applyTransform(r,a,4)),r[0]/=this.#im,r[1]/=this.#ib,r[2]/=this.#im,r[3]/=this.#ib,r[4]/=this.#im,r[5]/=this.#ib,this.#ic.set(r,6*this.#iF),this.#iF++}take(){return this.#ic.subarray(0,6*this.#iF)}}class ei{#iR=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));let e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(let t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),this.#iR.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:i}){if(!(!t||this.#iR.has(t.loadedName))){if(C(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:e,src:s,style:r}=t,a=new FontFace(e,s,r);this.addNativeFontFace(a);try{await a.load(),this.#iR.add(e),i?.(t)}catch{w(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}return}_("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)return void await this.loadSystemFont(t);if(this.isFontLoadingAPISupported){let e=t.createNativeFontFace();if(e){this.addNativeFontFace(e);try{await e.loaded}catch(i){throw w(`Failed to load font '${e.family}': '${i}'.`),t.disableFontFace=!0,i}}return}let e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(e=>{let i=this._queueLoadingCallback(e);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){return M(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){return M(this,"isSyncFontLoadingSupported",n||O.platform.isFirefox)}_queueLoadingCallback(t){let{loadingRequests:e}=this,i={done:!1,complete:function(){for(C(!i.done,"completeRequest() cannot be called twice."),i.done=!0;e.length>0&&e[0].done;)setTimeout(e.shift().callback,0)},callback:t};return e.push(i),i}get _loadTestFont(){return M(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){var i;let s,r;function a(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function n(t,e,i,s){return t.substring(0,e)+s+t.substring(e+i)}let o=this._document.createElement("canvas");o.width=1,o.height=1;let l=o.getContext("2d"),h=0,d=`lt${Date.now()}${this.loadTestFontId++}`,c=this._loadTestFont,u=a(c=n(c,976,d.length,d),16);for(s=0,r=d.length-3;s<r;s+=4)u=u-0x58585858+a(d,s)|0;s<d.length&&(u=u-0x58585858+a(d+"XXX",s)|0),c=n(c,16,4,String.fromCharCode((i=u)>>24&255,i>>16&255,i>>8&255,255&i));let p=`url(data:font/opentype;base64,${btoa(c)});`,g=`@font-face {font-family:"${d}";src:${p}}`;this.insertRule(g);let m=this._document.createElement("div");for(let e of(m.style.visibility="hidden",m.style.width=m.style.height="10px",m.style.position="absolute",m.style.top=m.style.left="0px",[t.loadedName,d])){let t=this._document.createElement("span");t.textContent="Hi",t.style.fontFamily=e,m.append(t)}this._document.body.append(m),function t(e,i){if(++h>30){w("Load test font never loaded."),i();return}(l.font="30px "+e,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0)?i():setTimeout(t.bind(null,e,i))}(d,()=>{m.remove(),e.complete()})}}class es{compiledGlyphs=Object.create(null);#iO;constructor(t,e=null,i,s){this.#iO=t,this._inspectFont=e,i&&(this.charProcOperatorList=i),s&&Object.assign(this,s)}createNativeFontFace(){let t;if(!this.data||this.disableFontFace)return null;if(this.cssFontInfo){let e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}else t=new FontFace(this.loadedName,this.data,{});return this._inspectFont?.(this),t}createFontFaceRule(){let t;if(!this.data||this.disableFontFace)return null;let e=`url(data:${this.mimetype};base64,${this.data.toBase64()});`;if(this.cssFontInfo){let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),t=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${e}}`}else t=`@font-face {font-family:"${this.loadedName}";src:${e}}`;return this._inspectFont?.(this,e),t}getPathGenerator(t,e){let i;if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];let s=this.loadedName+"_path_"+e;try{i=t.get(s)}catch(t){w(`getPathGenerator - ignoring character: "${t}".`)}let r=tM(i?.path);return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=r}get black(){return this.#iO.black}get bold(){return this.#iO.bold}get disableFontFace(){return this.#iO.disableFontFace}set disableFontFace(t){M(this,"disableFontFace",!!t)}get fontExtraProperties(){return this.#iO.fontExtraProperties}get isInvalidPDFjsFont(){return this.#iO.isInvalidPDFjsFont}get isType3Font(){return this.#iO.isType3Font}get italic(){return this.#iO.italic}get missingFile(){return this.#iO.missingFile}get remeasure(){return this.#iO.remeasure}get vertical(){return this.#iO.vertical}get ascent(){return this.#iO.ascent}get defaultWidth(){return this.#iO.defaultWidth}get descent(){return this.#iO.descent}get bbox(){return this.#iO.bbox}get fontMatrix(){return this.#iO.fontMatrix}get fallbackName(){return this.#iO.fallbackName}get loadedName(){return this.#iO.loadedName}get mimetype(){return this.#iO.mimetype}get name(){return this.#iO.name}get data(){return this.#iO.data}clearData(){this.#iO.clearData()}get cssFontInfo(){return this.#iO.cssFontInfo}get systemFontInfo(){return this.#iO.systemFontInfo}get defaultVMetrics(){return this.#iO.defaultVMetrics}}class er{static strings=["fontFamily","fontWeight","italicAngle"]}class ea{static strings=["css","loadedName","baseFontName","src"]}class en{static bools=["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"];static numbers=["ascent","defaultWidth","descent"];static strings=["fallbackName","loadedName","mimetype","name"];static OFFSET_NUMBERS=Math.ceil(2*this.bools.length/8);static OFFSET_BBOX=this.OFFSET_NUMBERS+8*this.numbers.length;static OFFSET_FONT_MATRIX=this.OFFSET_BBOX+1+8;static OFFSET_DEFAULT_VMETRICS=this.OFFSET_FONT_MATRIX+1+48;static OFFSET_STRINGS=this.OFFSET_DEFAULT_VMETRICS+1+6}class eo{static KIND=0;static HAS_BBOX=1;static HAS_BACKGROUND=2;static SHADING_TYPE=3;static N_COORD=4;static N_COLOR=8;static N_STOP=12;static N_FIGURES=16}class el{#iN;#iU=new TextDecoder;#iH;constructor(t){this.#iN=t,this.#iH=new DataView(t)}#iz(t){C(t<er.strings.length,"Invalid string index");let e=0;for(let i=0;i<t;i++)e+=this.#iH.getUint32(e)+4;let i=this.#iH.getUint32(e);return this.#iU.decode(new Uint8Array(this.#iN,e+4,i))}get fontFamily(){return this.#iz(0)}get fontWeight(){return this.#iz(1)}get italicAngle(){return this.#iz(2)}}class eh{#iN;#iU=new TextDecoder;#iH;constructor(t){this.#iN=t,this.#iH=new DataView(t)}get guessFallback(){return 0!==this.#iH.getUint8(0)}#iz(t){C(t<ea.strings.length,"Invalid string index");let e=5;for(let i=0;i<t;i++)e+=this.#iH.getUint32(e)+4;let i=this.#iH.getUint32(e);return this.#iU.decode(new Uint8Array(this.#iN,e+4,i))}get css(){return this.#iz(0)}get loadedName(){return this.#iz(1)}get baseFontName(){return this.#iz(2)}get src(){return this.#iz(3)}get style(){let t=1;t+=4+this.#iH.getUint32(t);let e=this.#iH.getUint32(t),i=this.#iU.decode(new Uint8Array(this.#iN,t+4,e));t+=4+e;let s=this.#iH.getUint32(t),r=this.#iU.decode(new Uint8Array(this.#iN,t+4,s));return{style:i,weight:r}}}class ed{#iN;#iU=new TextDecoder;#iH;constructor({buffer:t,extra:e}){this.#iN=t,this.#iH=new DataView(t),e&&Object.assign(this,e)}#i$(t){C(t<en.bools.length,"Invalid boolean index");let e=Math.floor(t/4),i=this.#iH.getUint8(e)>>2*t%8&3;return 0===i?void 0:2===i}get black(){return this.#i$(0)}get bold(){return this.#i$(1)}get disableFontFace(){return this.#i$(2)}get fontExtraProperties(){return this.#i$(3)}get isInvalidPDFjsFont(){return this.#i$(4)}get isType3Font(){return this.#i$(5)}get italic(){return this.#i$(6)}get missingFile(){return this.#i$(7)}get remeasure(){return this.#i$(8)}get vertical(){return this.#i$(9)}#iG(t){return C(t<en.numbers.length,"Invalid number index"),this.#iH.getFloat64(en.OFFSET_NUMBERS+8*t)}get ascent(){return this.#iG(0)}get defaultWidth(){return this.#iG(1)}get descent(){return this.#iG(2)}#ij(t,e,i,s){let r=this.#iH.getUint8(t);if(0===r)return;C(r===e,"Invalid array length."),t+=1;let a=Array(r);for(let e=0;e<r;e++)a[e]=this.#iH[i](t,!0),t+=s;return a}get bbox(){return this.#ij(en.OFFSET_BBOX,4,"getInt16",2)}get fontMatrix(){return this.#ij(en.OFFSET_FONT_MATRIX,6,"getFloat64",8)}get defaultVMetrics(){return this.#ij(en.OFFSET_DEFAULT_VMETRICS,3,"getInt16",2)}#iz(t){C(t<en.strings.length,"Invalid string index");let e=en.OFFSET_STRINGS+4;for(let i=0;i<t;i++)e+=this.#iH.getUint32(e)+4;let i=this.#iH.getUint32(e);return this.#iU.decode(new Uint8Array(this.#iN,e+4,i))}get fallbackName(){return this.#iz(0)}get loadedName(){return this.#iz(1)}get mimetype(){return this.#iz(2)}get name(){return this.#iz(3)}#iV(){let t=en.OFFSET_STRINGS,e=this.#iH.getUint32(t);t+=4+e;let i=this.#iH.getUint32(t);t+=4+i;let s=this.#iH.getUint32(t);t+=4+s;let r=this.#iH.getUint32(t);return{offset:t,length:r}}get data(){let{offset:t,length:e}=this.#iV();return 0===e?void 0:new Uint8Array(this.#iN,t+4,e)}clearData(){let{offset:t,length:e}=this.#iV();0!==e&&(this.#iH.setUint32(t,0),this.#iN=new Uint8Array(this.#iN,0,t+4).slice().buffer,this.#iH=new DataView(this.#iN))}get cssFontInfo(){let t=en.OFFSET_STRINGS,e=this.#iH.getUint32(t);t+=4+e;let i=this.#iH.getUint32(t);t+=4+i;let s=this.#iH.getUint32(t);if(0===s)return null;let r=new Uint8Array(s);return r.set(new Uint8Array(this.#iN,t+4,s)),new el(r.buffer)}get systemFontInfo(){let t=en.OFFSET_STRINGS,e=this.#iH.getUint32(t);t+=4+e;let i=this.#iH.getUint32(t);if(0===i)return null;let s=new Uint8Array(i);return s.set(new Uint8Array(this.#iN,t+4,i)),new eh(s.buffer)}}class ec{constructor(t){this.buffer=t,this.view=new DataView(t),this.data=new Uint8Array(t)}getIR(){let t=this.view,e=this.data[eo.KIND],i=!!this.data[eo.HAS_BBOX],s=!!this.data[eo.HAS_BACKGROUND],r=t.getUint32(eo.N_COORD,!0),a=t.getUint32(eo.N_COLOR,!0),n=t.getUint32(eo.N_STOP,!0),l=20,h=new Float32Array(this.buffer,l,2*r);l+=8*r;let d=new Uint8Array(this.buffer,l,4*a);l+=4*a;let c=[];for(let e=0;e<n;++e){let e=t.getFloat32(l,!0);l+=4;let i=t.getUint32(l,!0);l+=4,c.push([e,`#${i.toString(16).padStart(6,"0")}`])}let u=null;if(i){u=[];for(let e=0;e<4;++e)u.push(t.getFloat32(l,!0)),l+=4}let p=null;if(s&&(p=new Uint8Array(this.buffer,l,3),l+=3),1===e)return["RadialAxial","axial",u,c,Array.from(h.slice(0,2)),Array.from(h.slice(2,4)),null,null];if(2===e)return["RadialAxial","radial",u,c,[h[0],h[1]],[h[3],h[4]],h[2],h[5]];if(3===e){let t=this.data[eo.SHADING_TYPE],e=null;if(h.length>0){e=o.slice();for(let t=0,i=h.length;t<i;t+=2)N.pointBoundingBox(h[t],h[t+1],e)}return["Mesh",t,h,d,r,e,u,p]}throw Error(`Unsupported pattern kind: ${e}`)}}class eu{#iN;constructor(t){this.#iN=t}get path(){return O.isFloat16ArraySupported?new Float16Array(this.#iN):new Float32Array(this.#iN)}}function ep(t){if("string"!=typeof t)return null;if(t.endsWith("/"))return t;throw Error(`Invalid factory url: "${t}" must include trailing slash.`)}let eg=t=>"object"==typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0,em=(function(t,e,i){if(!Array.isArray(i)||i.length<2)return!1;let[s,r,...a]=i;if(!t(s)&&!Number.isInteger(s)||!e(r))return!1;let n=a.length,o=!0;switch(r.name){case"XYZ":if(n<2||n>3)return!1;break;case"Fit":case"FitB":return 0===n;case"FitH":case"FitBH":case"FitV":case"FitBV":if(n>1)return!1;break;case"FitR":if(4!==n)return!1;o=!1;break;default:return!1}for(let t of a)if("number"!=typeof t&&(!o||null!==t))return!1;return!0}).bind(null,eg,t=>"object"==typeof t&&"string"==typeof t?.name);class ef{#iW=new Map;#iX=Promise.resolve();postMessage(t,e){let i={data:structuredClone(t,e?{transfer:e}:null)};this.#iX.then(()=>{for(let[t]of this.#iW)t.call(this,i)})}addEventListener(t,e,i=null){let s=null;if(i?.signal instanceof AbortSignal){let{signal:r}=i;if(r.aborted)return void w("LoopbackPort - cannot use an `aborted` signal.");let a=()=>this.removeEventListener(t,e);s=()=>r.removeEventListener("abort",a),r.addEventListener("abort",a)}this.#iW.set(e,s)}removeEventListener(t,e){let i=this.#iW.get(e);i?.(),this.#iW.delete(e)}terminate(){for(let[,t]of this.#iW)t?.();this.#iW.clear()}}function eb(){}function ey(t){if(t instanceof L||t instanceof I||t instanceof k||t instanceof B||t instanceof D)return t;switch(!(t instanceof Error||"object"==typeof t&&null!==t)&&_('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new L(t.message);case"InvalidPDFException":return new I(t.message);case"PasswordException":return new k(t.message,t.code);case"ResponseException":return new B(t.message,t.status,t.missing);case"UnknownErrorException":return new D(t.message,t.details)}return new D(t.message,t.toString())}class ev{#iq=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.#iK.bind(this),{signal:this.#iq.signal})}#iK({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream)return void this.#iY(t);if(t.callback){let e=t.callbackId,i=this.callbackCapabilities[e];if(!i)throw Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],1===t.callback)i.resolve(t.data);else if(2===t.callback)i.reject(ey(t.reason));else throw Error("Unexpected callback case");return}let e=this.actionHandler[t.action];if(!e)throw Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){let i=this.sourceName,s=t.sourceName,r=this.comObj;Promise.try(e,t.data).then(function(e){r.postMessage({sourceName:i,targetName:s,callback:1,callbackId:t.callbackId,data:e})},function(e){r.postMessage({sourceName:i,targetName:s,callback:2,callbackId:t.callbackId,reason:ey(e)})});return}t.streamId?this.#iQ(t):e(t.data)}on(t,e){let i=this.actionHandler;if(i[t])throw 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){let s=this.callbackId++,r=Promise.withResolvers();this.callbackCapabilities[s]=r;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:s,data:e},i)}catch(t){r.reject(t)}return r.promise}sendWithStream(t,e,i,s){let r=this.streamId++,a=this.sourceName,n=this.targetName,o=this.comObj;return new ReadableStream({start:i=>{let l=Promise.withResolvers();return this.streamControllers[r]={controller:i,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:a,targetName:n,action:t,streamId:r,data:e,desiredSize:i.desiredSize},s),l.promise},pull:t=>{let e=Promise.withResolvers();return this.streamControllers[r].pullCall=e,o.postMessage({sourceName:a,targetName:n,stream:6,streamId:r,desiredSize:t.desiredSize}),e.promise},cancel:t=>{C(t instanceof Error,"cancel must have a valid reason");let e=Promise.withResolvers();return this.streamControllers[r].cancelCall=e,this.streamControllers[r].isClosed=!0,o.postMessage({sourceName:a,targetName:n,stream:1,streamId:r,reason:ey(t)}),e.promise}},i)}#iQ(t){let e=t.streamId,i=this.sourceName,s=t.sourceName,r=this.comObj,a=this,n=this.actionHandler[t.action],o={enqueue(t,a=1,n){if(this.isCancelled)return;let o=this.desiredSize;this.desiredSize-=a,o>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),r.postMessage({sourceName:i,targetName:s,stream:4,streamId:e,chunk:t},n)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:i,targetName:s,stream:3,streamId:e}),delete a.streamSinks[e])},error(t){C(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:i,targetName:s,stream:5,streamId:e,reason:ey(t)}))},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(n,t.data,o).then(function(){r.postMessage({sourceName:i,targetName:s,stream:8,streamId:e,success:!0})},function(t){r.postMessage({sourceName:i,targetName:s,stream:8,streamId:e,reason:ey(t)})})}#iY(t){let e=t.streamId,i=this.sourceName,s=t.sourceName,r=this.comObj,a=this.streamControllers[e],n=this.streamSinks[e];switch(t.stream){case 8:t.success?a.startCall.resolve():a.startCall.reject(ey(t.reason));break;case 7:t.success?a.pullCall.resolve():a.pullCall.reject(ey(t.reason));break;case 6:if(!n){r.postMessage({sourceName:i,targetName:s,stream:7,streamId:e,success:!0});break}n.desiredSize<=0&&t.desiredSize>0&&n.sinkCapability.resolve(),n.desiredSize=t.desiredSize,Promise.try(n.onPull||eb).then(function(){r.postMessage({sourceName:i,targetName:s,stream:7,streamId:e,success:!0})},function(t){r.postMessage({sourceName:i,targetName:s,stream:7,streamId:e,reason:ey(t)})});break;case 4:if(C(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case 3:if(C(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),this.#iJ(a,e);break;case 5:C(a,"error should have stream controller"),a.controller.error(ey(t.reason)),this.#iJ(a,e);break;case 2:t.success?a.cancelCall.resolve():a.cancelCall.reject(ey(t.reason)),this.#iJ(a,e);break;case 1:if(!n)break;let o=ey(t.reason);Promise.try(n.onCancel||eb,o).then(function(){r.postMessage({sourceName:i,targetName:s,stream:2,streamId:e,success:!0})},function(t){r.postMessage({sourceName:i,targetName:s,stream:2,streamId:e,reason:ey(t)})}),n.sinkCapability.reject(o),n.isCancelled=!0,delete this.streamSinks[e];break;default:throw Error("Unexpected stream case")}}async #iJ(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#iq?.abort(),this.#iq=null}}class eA{#iZ=Object.freeze({cMapUrl:"CMap",standardFontDataUrl:"font",wasmUrl:"wasm"});constructor({cMapUrl:t=null,standardFontDataUrl:e=null,wasmUrl:i=null}){this.cMapUrl=t,this.standardFontDataUrl=e,this.wasmUrl=i}async fetch({kind:t,filename:e}){switch(t){case"cMapUrl":case"standardFontDataUrl":case"wasmUrl":break;default:_(`Not implemented: ${t}`)}let i=this[t];if(!i)throw Error(`Ensure that the \`${t}\` API parameter is provided.`);let s=`${i}${e}`;return this._fetch(s,t).catch(e=>{throw Error(`Unable to load ${this.#iZ[t]} data at: ${s}`)})}async _fetch(t,e){_("Abstract method `_fetch` called.")}}class ex extends eA{async _fetch(t,e){let i="cMapUrl"!==e||t.endsWith(".bcmap")?"bytes":"text",s=await J(t,i);return s instanceof Uint8Array?s:R(s)}}class ew{#i0=!1;constructor({enableHWA:t=!1}){this.#i0=t}create(t,e){if(t<=0||e<=0)throw Error("Invalid canvas size");let i=this._createCanvas(t,e);return{canvas:i,context:i.getContext("2d",{willReadFrequently:!this.#i0})}}reset({canvas:t},e,i){if(!t)throw Error("Canvas is not specified");if(e<=0||i<=0)throw Error("Invalid canvas size");t.width=e,t.height=i}destroy(t){let{canvas:e}=t;if(!e)throw Error("Canvas is not specified");e.width=e.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){_("Abstract method `_createCanvas` called.")}}class e_ extends ew{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){let i=this._document.createElement("canvas");return i.width=t,i.height=e,i}}class eC{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,i,s,r){return"none"}destroy(t=!1){}}class eT extends eC{#i1;#i2;#i3;#i5;#i6;#i4;#S=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#i5=t,this.#i6=e}get #M(){return this.#i2||=new Map}get #i8(){return this.#i4||=new Map}get #i7(){if(!this.#i3){let t=this.#i6.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;let i=this.#i6.createElementNS(Y,"svg");i.setAttribute("width",0),i.setAttribute("height",0),this.#i3=this.#i6.createElementNS(Y,"defs"),t.append(i),i.append(this.#i3),this.#i6.body.append(t)}return this.#i3}#i9(t){if(1===t.length){let e=t[0],i=Array(256);for(let t=0;t<256;t++)i[t]=e[t]/255;let s=i.join(",");return[s,s,s]}let[e,i,s]=t,r=Array(256),a=Array(256),n=Array(256);for(let t=0;t<256;t++)r[t]=e[t]/255,a[t]=i[t]/255,n[t]=s[t]/255;return[r.join(","),a.join(","),n.join(",")]}#st(t){if(void 0===this.#i1){this.#i1="";let t=this.#i6.URL;t!==this.#i6.baseURI&&(te(t)?w('#createUrl: ignore "data:"-URL for performance reasons.'):this.#i1=S(t,""))}return`url(${this.#i1}#${t})`}addFilter(t){if(!t)return"none";let e=this.#M.get(t);if(e)return e;let[i,s,r]=this.#i9(t),a=1===t.length?i:`${i}${s}${r}`;if(e=this.#M.get(a))return this.#M.set(t,e),e;let n=`g_${this.#i5}_transfer_map_${this.#S++}`,o=this.#st(n);this.#M.set(t,o),this.#M.set(a,o);let l=this.#se(n);return this.#si(i,s,r,l),o}addHCMFilter(t,e){let i=`${t}-${e}`,s="base",r=this.#i8.get(s);if(r?.key===i||(r?(r.filter?.remove(),r.key=i,r.url="none",r.filter=null):(r={key:i,url:"none",filter:null},this.#i8.set(s,r)),!t||!e))return r.url;let a=this.#ss(t);t=N.makeHexColor(...a);let n=this.#ss(e);if(e=N.makeHexColor(...n),this.#i7.style.color="","#000000"===t&&"#ffffff"===e||t===e)return r.url;let o=Array(256);for(let t=0;t<=255;t++){let e=t/255;o[t]=e<=.03928?e/12.92:((e+.055)/1.055)**2.4}let l=o.join(","),h=`g_${this.#i5}_hcm_filter`,d=r.filter=this.#se(h);this.#si(l,l,l,d),this.#sr(d);let c=(t,e)=>{let i=a[t]/255,s=n[t]/255,r=Array(e+1);for(let t=0;t<=e;t++)r[t]=i+t/e*(s-i);return r.join(",")};return this.#si(c(0,5),c(1,5),c(2,5),d),r.url=this.#st(h),r.url}addAlphaFilter(t){let e=this.#M.get(t);if(e)return e;let[i]=this.#i9([t]),s=`alpha_${i}`;if(e=this.#M.get(s))return this.#M.set(t,e),e;let r=`g_${this.#i5}_alpha_map_${this.#S++}`,a=this.#st(r);this.#M.set(t,a),this.#M.set(s,a);let n=this.#se(r);return this.#sa(i,n),a}addLuminosityFilter(t){let e,i,s=this.#M.get(t||"luminosity");if(s)return s;if(t?([e]=this.#i9([t]),i=`luminosity_${e}`):i="luminosity",s=this.#M.get(i))return this.#M.set(t,s),s;let r=`g_${this.#i5}_luminosity_map_${this.#S++}`,a=this.#st(r);this.#M.set(t,a),this.#M.set(i,a);let n=this.#se(r);return this.#sn(n),t&&this.#sa(e,n),a}addHighlightHCMFilter(t,e,i,s,r){let a=`${e}-${i}-${s}-${r}`,n=this.#i8.get(t);if(n?.key===a||(n?(n.filter?.remove(),n.key=a,n.url="none",n.filter=null):(n={key:a,url:"none",filter:null},this.#i8.set(t,n)),!e||!i))return n.url;let[o,l]=[e,i].map(this.#ss.bind(this)),h=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),d=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[c,u]=[s,r].map(this.#ss.bind(this));d<h&&([h,d,c,u]=[d,h,u,c]),this.#i7.style.color="";let p=(t,e,i)=>{let s=Array(256),r=(d-h)/i,a=t/255,n=(e-t)/(255*i),o=0;for(let t=0;t<=i;t++){let e=Math.round(h+t*r),i=a+t*n;for(let t=o;t<=e;t++)s[t]=i;o=e+1}for(let t=o;t<256;t++)s[t]=s[o-1];return s.join(",")},g=`g_${this.#i5}_hcm_${t}_filter`,m=n.filter=this.#se(g);return this.#sr(m),this.#si(p(c[0],u[0],5),p(c[1],u[1],5),p(c[2],u[2],5),m),n.url=this.#st(g),n.url}destroy(t=!1){t&&this.#i4?.size||(this.#i3?.parentNode.parentNode.remove(),this.#i3=null,this.#i2?.clear(),this.#i2=null,this.#i4?.clear(),this.#i4=null,this.#S=0)}#sn(t){let e=this.#i6.createElementNS(Y,"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)}#sr(t){let e=this.#i6.createElementNS(Y,"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)}#se(t){let e=this.#i6.createElementNS(Y,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#i7.append(e),e}#so(t,e,i){let s=this.#i6.createElementNS(Y,e);s.setAttribute("type","discrete"),s.setAttribute("tableValues",i),t.append(s)}#si(t,e,i,s){let r=this.#i6.createElementNS(Y,"feComponentTransfer");s.append(r),this.#so(r,"feFuncR",t),this.#so(r,"feFuncG",e),this.#so(r,"feFuncB",i)}#sa(t,e){let i=this.#i6.createElementNS(Y,"feComponentTransfer");e.append(i),this.#so(i,"feFuncA",t)}#ss(t){return this.#i7.style.color=t,tu(getComputedStyle(this.#i7).getPropertyValue("color"))}}async function eS(t){let e=s.getBuiltinModule("fs/promises");return new Uint8Array(await e.readFile(t))}n&&w("Please use the `legacy` build in Node.js environments.");class eE extends eC{}class eM extends ew{_createCanvas(t,e){return s.getBuiltinModule("module").createRequire("file:///home/runner/work/pidex/pidex/node_modules/pdfjs-dist/build/pdf.mjs")("@napi-rs/canvas").createCanvas(t,e)}}class eP extends eA{async _fetch(t,e){return eS(t)}}let ek=`
|
|
3
|
-
struct Uniforms {
|
|
4
|
-
offsetX : f32,
|
|
5
|
-
offsetY : f32,
|
|
6
|
-
scaleX : f32,
|
|
7
|
-
scaleY : f32,
|
|
8
|
-
paddedWidth : f32,
|
|
9
|
-
paddedHeight : f32,
|
|
10
|
-
borderSize : f32,
|
|
11
|
-
_pad : f32,
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
@group(0) @binding(0) var<uniform> u : Uniforms;
|
|
15
|
-
|
|
16
|
-
struct VertexInput {
|
|
17
|
-
@location(0) position : vec2<f32>,
|
|
18
|
-
@location(1) color : vec4<f32>,
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
struct VertexOutput {
|
|
22
|
-
@builtin(position) position : vec4<f32>,
|
|
23
|
-
@location(0) color : vec3<f32>,
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
@vertex
|
|
27
|
-
fn vs_main(in : VertexInput) -> VertexOutput {
|
|
28
|
-
var out : VertexOutput;
|
|
29
|
-
let cx = (in.position.x + u.offsetX) * u.scaleX;
|
|
30
|
-
let cy = (in.position.y + u.offsetY) * u.scaleY;
|
|
31
|
-
out.position = vec4<f32>(
|
|
32
|
-
((cx + u.borderSize) / u.paddedWidth) * 2.0 - 1.0,
|
|
33
|
-
1.0 - ((cy + u.borderSize) / u.paddedHeight) * 2.0,
|
|
34
|
-
0.0,
|
|
35
|
-
1.0
|
|
36
|
-
);
|
|
37
|
-
out.color = in.color.rgb;
|
|
38
|
-
return out;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
@fragment
|
|
42
|
-
fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
|
|
43
|
-
return vec4<f32>(in.color, 1.0);
|
|
44
|
-
}
|
|
45
|
-
`;class eD{#sl=null;#sh=null;#sd=null;#sc=null;async #su(){if(!globalThis.navigator?.gpu)return!1;try{let t=await navigator.gpu.requestAdapter();if(!t)return!1;return this.#sc=navigator.gpu.getPreferredCanvasFormat(),this.#sh=await t.requestDevice(),!0}catch{return!1}}init(){return this.#sl||=this.#su()}get isReady(){return null!==this.#sh}loadMeshShader(){if(!this.#sh||this.#sd)return;let t=this.#sh.createShaderModule({code:ek});this.#sd=this.#sh.createRenderPipeline({layout:"auto",vertex:{module:t,entryPoint:"vs_main",buffers:[{arrayStride:8,attributes:[{shaderLocation:0,offset:0,format:"float32x2"}]},{arrayStride:4,attributes:[{shaderLocation:1,offset:0,format:"unorm8x4"}]}]},fragment:{module:t,entryPoint:"fs_main",targets:[{format:this.#sc}]},primitive:{topology:"triangle-list"}})}draw(t,e,i,s,r,a,n,o){this.loadMeshShader();let l=this.#sh,{offsetX:h,offsetY:d,scaleX:c,scaleY:u}=s,p=l.createBuffer({size:Math.max(t.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});t.byteLength>0&&l.queue.writeBuffer(p,0,t);let g=l.createBuffer({size:Math.max(e.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});e.byteLength>0&&l.queue.writeBuffer(g,0,e);let m=l.createBuffer({size:32,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});l.queue.writeBuffer(m,0,new Float32Array([h,d,c,u,a,n,o,0]));let f=l.createBindGroup({layout:this.#sd.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:m}}]}),b=new OffscreenCanvas(a,n),y=b.getContext("webgpu");y.configure({device:l,format:this.#sc,alphaMode:r?"opaque":"premultiplied"});let v=r?{r:r[0]/255,g:r[1]/255,b:r[2]/255,a:1}:{r:0,g:0,b:0,a:0},A=l.createCommandEncoder(),x=A.beginRenderPass({colorAttachments:[{view:y.getCurrentTexture().createView(),clearValue:v,loadOp:"clear",storeOp:"store"}]});return i>0&&(x.setPipeline(this.#sd),x.setBindGroup(0,f),x.setVertexBuffer(0,p),x.setVertexBuffer(1,g),x.draw(i)),x.end(),l.queue.submit([A.finish()]),p.destroy(),g.destroy(),m.destroy(),b.transferToImageBitmap()}}let eI=new eD,eB="Fill",eF="Stroke",eL="Shading";function eR(t,e){if(!e)return;let i=e[2]-e[0],s=e[3]-e[1],r=new Path2D;r.rect(e[0],e[1],i,s),t.clip(r)}class eO{isModifyingCurrentTransform(){return!1}getPattern(){_("Abstract method `getPattern` called.")}}class eN extends eO{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}isOriginBased(){return 0===this._p0[0]&&0===this._p0[1]&&(!this.isRadial()||0===this._p1[0]&&0===this._p1[1])}isRadial(){return"radial"===this._type}areConic(){if(!this.isRadial())return!1;let t=Math.hypot(this._p0[0]-this._p1[0],this._p0[1]-this._p1[1]);return t+this._r1>this._r0&&t+this._r0>this._r1}_createGradient(t,e=null){let i,s=this._p0,r=this._p1;if(e&&(s=s.slice(),r=r.slice(),N.applyTransform(s,e),N.applyTransform(r,e)),"axial"===this._type)i=t.createLinearGradient(s[0],s[1],r[0],r[1]);else if("radial"===this._type){let a=this._r0,n=this._r1;if(e){let t=new Float32Array(2);N.singularValueDecompose2dScale(e,t),a*=t[0],n*=t[0]}i=t.createRadialGradient(s[0],s[1],a,r[0],r[1],n)}for(let t of this._colorStops)i.addColorStop(t[0],t[1]);return i}_createReversedGradient(t,e=null){let i=this._p1,s=this._p0;e&&(i=i.slice(),s=s.slice(),N.applyTransform(i,e),N.applyTransform(s,e));let r=this._r1,a=this._r0;if(e){let t=new Float32Array(2);N.singularValueDecompose2dScale(e,t),r*=t[0],a*=t[0]}let n=t.createRadialGradient(i[0],i[1],r,s[0],s[1],a);for(let[t,e]of this._colorStops.map(([t,e])=>[1-t,e]).reverse())n.addColorStop(t,e);return n}getPattern(t,e,i,s){let r;if(s===eF||s===eB){if(this.isOriginBased()){let s=N.transform(i,e.baseTransform);this.matrix&&(s=N.transform(s,this.matrix));let r=Math.hypot(s[0],s[1]),a=Math.hypot(s[2],s[3]);if(.001>Math.abs((s[0]*s[2]+s[1]*s[3])/(r*a))){if(!this.isRadial())return this._createGradient(t,s);else if(.001>Math.abs(r-a))return this._createGradient(t,s)}}let a=e.current.getClippedPathBoundingBox(s,tp(t))||[0,0,0,0],n=Math.ceil(a[2]-a[0])||1,o=Math.ceil(a[3]-a[1])||1,l=e.canvasFactory.create(n,o),h=l.context;h.clearRect(0,0,h.canvas.width,h.canvas.height),h.beginPath(),h.rect(0,0,h.canvas.width,h.canvas.height),h.translate(-a[0],-a[1]),i=N.transform(i,[1,0,0,1,a[0],a[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),eR(h,this._bbox),this.areConic()&&(h.fillStyle=this._createReversedGradient(h),h.fill()),h.fillStyle=this._createGradient(h),h.fill(),r=t.createPattern(l.canvas,"no-repeat"),e.canvasFactory.destroy(l);let d=new DOMMatrix(i);r.setTransform(d)}else this.areConic()&&(t.save(),eR(t,this._bbox),t.fillStyle=this._createReversedGradient(t),t.fillRect(-1e10,-1e10,2e10,2e10),t.restore()),eR(t,this._bbox),r=this._createGradient(t);return r}}class eU extends eO{constructor(t){super(),this._posData=t[2],this._colData=t[3],this._vertexCount=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],this.matrix=null,eI.loadMeshShader()}_createMeshCanvas(t,e,i){let s=Math.floor(this._bounds[0]),r=Math.floor(this._bounds[1]),a=Math.ceil(this._bounds[2])-s,n=Math.ceil(this._bounds[3])-r,o=Math.min(Math.ceil(Math.abs(a*t[0]*1.1)),3e3)||1,l=Math.min(Math.ceil(Math.abs(n*t[1]*1.1)),3e3)||1,h=a?a/o:1,d=n?n/l:1,c={coords:this._posData,colors:this._colData,offsetX:-s,offsetY:-r,scaleX:1/h,scaleY:1/d},u=o+4,p=l+4,g=i.create(u,p);if(eI.isReady&&this._vertexCount>48){var m,f,b;g.context.drawImage((m=this._posData,f=this._colData,b=this._vertexCount,eI.draw(m,f,b,c,e,u,p,2)),0,0)}else{let t=g.context.createImageData(o,l);if(e){let i=t.data;for(let t=0,s=i.length;t<s;t+=4)i[t]=e[0],i[t+1]=e[1],i[t+2]=e[2],i[t+3]=255}for(let e=0,i=this._vertexCount;e<i;e+=3)!function(t,e,i,s,r,a,n,o){let l,h,d,c,u,p,g,m,f,b=e.coords,y=e.colors,v=t.data,A=4*t.width;b[2*i+1]>b[2*s+1]&&(l=i,i=s,s=l,l=a,a=n,n=l),b[2*s+1]>b[2*r+1]&&(l=s,s=r,r=l,l=n,n=o,o=l),b[2*i+1]>b[2*s+1]&&(l=i,i=s,s=l,l=a,a=n,n=l);let x=(b[2*i]+e.offsetX)*e.scaleX,w=(b[2*i+1]+e.offsetY)*e.scaleY,_=(b[2*s]+e.offsetX)*e.scaleX,C=(b[2*s+1]+e.offsetY)*e.scaleY,T=(b[2*r]+e.offsetX)*e.scaleX,S=(b[2*r+1]+e.offsetY)*e.scaleY;if(w>=S)return;let E=y[4*a],M=y[4*a+1],P=y[4*a+2],k=y[4*n],D=y[4*n+1],I=y[4*n+2],B=y[4*o],F=y[4*o+1],L=y[4*o+2],R=Math.round(w),O=Math.round(S);for(let t=R;t<=O;t++){let e;if(t<C){let e=t<w?0:(w-t)/(w-C);h=x-(x-_)*e,d=E-(E-k)*e,c=M-(M-D)*e,u=P-(P-I)*e}else{let e;h=_-(_-T)*(e=t>S?1:C===S?0:(C-t)/(C-S)),d=k-(k-B)*e,c=D-(D-F)*e,u=I-(I-L)*e}p=x-(x-T)*(e=t<w?0:t>S?1:(w-t)/(w-S)),g=E-(E-B)*e,m=M-(M-F)*e,f=P-(P-L)*e;let i=Math.round(Math.min(h,p)),s=Math.round(Math.max(h,p)),r=A*t+4*i;for(let t=i;t<=s;t++)(e=(h-t)/(h-p))<0?e=0:e>1&&(e=1),v[r++]=d-(d-g)*e|0,v[r++]=c-(c-m)*e|0,v[r++]=u-(u-f)*e|0,v[r++]=255}}(t,c,e,e+1,e+2,e,e+1,e+2);g.context.putImageData(t,2,2)}return{canvas:g.canvas,offsetX:s-2*h,offsetY:r-2*d,scaleX:h,scaleY:d}}isModifyingCurrentTransform(){return!0}getPattern(t,e,i,s){eR(t,this._bbox);let r=new Float32Array(2);if(s===eL)N.singularValueDecompose2dScale(tp(t),r);else if(this.matrix){N.singularValueDecompose2dScale(this.matrix,r);let[t,i]=r;N.singularValueDecompose2dScale(e.baseTransform,r),r[0]*=t,r[1]*=i}else N.singularValueDecompose2dScale(e.baseTransform,r);let a=this._createMeshCanvas(r,s===eL?null:this._background,e.canvasFactory);s!==eL&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(a.offsetX,a.offsetY),t.scale(a.scaleX,a.scaleY);let n=t.createPattern(a.canvas,"no-repeat");return e.canvasFactory.destroy(a),n}}class eH extends eO{getPattern(){return"hotpink"}}class ez{static MAX_PATTERN_SIZE=3e3;constructor(t,e,i,s){this.color=t[1],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.needsIsolation=t[9]??!0,this.ctx=e,this.canvasGraphicsFactory=i,this.baseTransform=s,this.patternBaseMatrix=this.matrix?N.transform(s,this.matrix):s}canSkipPatternCanvas([t,e,i,s]){let[r,a,n,o]=this.bbox,l=Math.abs(this.xstep),h=Math.abs(this.ystep);if(t>l+1e-6||e>h+1e-6)return null;let d=Math.floor((i-n)/l)+1,c=Math.floor((s-o)/h)+1,u=Math.ceil((s+e-a)/h)-1;return Math.ceil((i+t-r)/l)-1<=d&&u<=c?[d,c]:null}updatePatternDims(t,e){let i=N.inverseTransform(this.patternBaseMatrix),s=[t[0],t[1]],r=[t[2],t[3]];N.applyTransform(s,i),N.applyTransform(r,i),e[0]=Math.abs(r[0]-s[0]),e[1]=Math.abs(r[1]-s[1]),e[2]=Math.min(s[0],r[0]),e[3]=Math.min(s[1],r[1])}_renderTileCanvas(t,e,i,s){let[r,a,n,o]=this.bbox,l=t.canvasFactory.create(i.size,s.size),h=l.context,d=this.canvasGraphicsFactory.createCanvasGraphics(h,e);return d.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(d,this.paintType,this.color),h.translate(-i.scale*r,-s.scale*a),d.transform(0,i.scale,0,0,s.scale,0,0),h.save(),d.dependencyTracker?.save(),this.clipBbox(d,r,a,n,o),d.baseTransform=tp(d.ctx),d.executeOperatorList(this.operatorList),d.endDrawing(),d.dependencyTracker?.restore(),h.restore(),l}_getCombinedScales(){let t=new Float32Array(2);N.singularValueDecompose2dScale(this.matrix,t);let[e,i]=t;return N.singularValueDecompose2dScale(this.baseTransform,t),[e*t[0],i*t[1]]}drawPattern(t,e,i=!1,[s,r],a){let[n,o,l,h]=this.bbox,d=t.dependencyTracker;if(d&&(t.dependencyTracker=new t3(d,a)),t.save(),i?t.ctx.clip(e,"evenodd"):t.ctx.clip(e),t.ctx.setTransform(...this.patternBaseMatrix),t.ctx.translate(s*this.xstep,r*this.ystep),this.needsIsolation||1!==t.ctx.globalAlpha||"source-over"!==t.ctx.globalCompositeOperation||t.inSMaskMode){let e=l-n,i=h-o,[s,r]=this._getCombinedScales(),d=this.getSizeAndScale(e,this.ctx.canvas.width,s),c=this.getSizeAndScale(i,this.ctx.canvas.height,r),u=this._renderTileCanvas(t,a,d,c);t.ctx.drawImage(u.canvas,n,o,e,i),t.canvasFactory.destroy(u)}else this.setFillAndStrokeStyleToContext(t,this.paintType,this.color),this.clipBbox(t,n,o,l,h),t.baseTransformStack.push(t.baseTransform),t.baseTransform=tp(t.ctx),t.executeOperatorList(this.operatorList),t.baseTransform=t.baseTransformStack.pop();t.restore(),d&&(t.dependencyTracker=d)}createPatternCanvas(t,e){let[i,s,r,a]=this.bbox,n=r-i,o=a-s,{xstep:l,ystep:h}=this;l=Math.abs(l),h=Math.abs(h),x("TilingType: "+this.tilingType);let[d,c]=this._getCombinedScales(),u=n,p=o,g=!1,m=!1;Math.ceil(l*d)>=Math.ceil(n*d)?u=l:g=!0,Math.ceil(h*c)>=Math.ceil(o*c)?p=h:m=!0;let f=this.getSizeAndScale(u,this.ctx.canvas.width,d),b=this.getSizeAndScale(p,this.ctx.canvas.height,c),y=this._renderTileCanvas(t,e,f,b);if(g||m){let e=y.canvas;g&&(u=l),m&&(p=h);let r=this.getSizeAndScale(u,this.ctx.canvas.width,d),a=this.getSizeAndScale(p,this.ctx.canvas.height,c),f=r.size,b=a.size,v=t.canvasFactory.create(f,b),A=v.context,x=g?Math.floor(n/l):0,w=m?Math.floor(o/h):0;for(let t=0;t<=x;t++)for(let i=0;i<=w;i++)A.drawImage(e,f*t,b*i,f,b,0,0,f,b);return t.canvasFactory.destroy(y),{canvas:v.canvas,canvasEntry:v,scaleX:r.scale,scaleY:a.scale,offsetX:i,offsetY:s}}return{canvas:y.canvas,canvasEntry:y,scaleX:f.scale,scaleY:b.scale,offsetX:i,offsetY:s}}getSizeAndScale(t,e,i){let s=Math.max(ez.MAX_PATTERN_SIZE,e),r=Math.ceil(t*i);return r>=s?r=s:i=r/t,{scale:i,size:r}}clipBbox(t,e,i,s,r){let a=s-e,n=r-i,o=new Path2D;o.rect(e,i,a,n),N.axialAlignedBoundingBox([e,i,s,r],tp(t.ctx),t.current.minMax),t.ctx.clip(o),t.current.updateClipFromPath()}setFillAndStrokeStyleToContext(t,e,i){let s=t.ctx,r=t.current;switch(r.patternFill=r.patternStroke=!1,e){case 1:let{fillStyle:a,strokeStyle:n}=this.ctx;s.fillStyle=r.fillColor=a,s.strokeStyle=r.strokeColor=n;break;case 2:s.fillStyle=s.strokeStyle=i,r.fillColor=r.strokeColor=i;break;default:throw new F(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,i,s,r){let a=s!==eL?N.transform(i,this.patternBaseMatrix):i,n=this.createPatternCanvas(e,r),o=new DOMMatrix(a);o=(o=o.translate(n.offsetX,n.offsetY)).scale(1/n.scaleX,1/n.scaleY);let l=t.createPattern(n.canvas,"repeat");return e.canvasFactory.destroy(n.canvasEntry),l.setTransform(o),l}}let e$=new DOMMatrix,eG=new Float32Array(2);function ej(t,e,i,s,r,a,n,o,l,h){let[d,c,u,p,g,m]=tp(t);if(0===c&&0===u){let f=Math.round(n*d+g),b=Math.round(o*p+m),y=Math.abs(Math.round((n+l)*d+g)-f)||1,v=Math.abs(Math.round((o+h)*p+m)-b)||1;return t.setTransform(Math.sign(d),0,0,Math.sign(p),f,b),t.drawImage(e,i,s,r,a,0,0,y,v),t.setTransform(d,c,u,p,g,m),[y,v]}if(0===d&&0===p){let f=Math.round(o*u+g),b=Math.round(n*c+m),y=Math.abs(Math.round((o+h)*u+g)-f)||1,v=Math.abs(Math.round((n+l)*c+m)-b)||1;return t.setTransform(0,Math.sign(c),Math.sign(u),0,f,b),t.drawImage(e,i,s,r,a,0,0,v,y),t.setTransform(d,c,u,p,g,m),[v,y]}return t.drawImage(e,i,s,r,a,n,o,l,h),[Math.hypot(d,c)*l,Math.hypot(u,p)*h]}class eV{alphaIsShape=!1;fontSize=0;fontSizeScale=1;textMatrix=null;textMatrixScale=1;fontMatrix=h;leading=0;x=0;y=0;lineX=0;lineY=0;charSpacing=0;wordSpacing=0;textHScale=1;textRenderingMode=0;textRise=0;fillColor="#000000";strokeColor="#000000";tilingPatternDims=null;patternFill=!1;patternStroke=!1;fillAlpha=1;strokeAlpha=1;lineWidth=1;activeSMask=null;transferMaps="none";minMax=l.slice();constructor(t,e){this.clipBox=new Float32Array([0,0,t,e])}clone(){let t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t.tilingPatternDims=this.tilingPatternDims?.slice(),t}getPathBoundingBox(t=eB,e=null){let i=this.minMax.slice();if(t===eF){e||_("Stroke bounding box must include transform."),N.singularValueDecompose2dScale(e,eG);let t=eG[0]*this.lineWidth/2,s=eG[1]*this.lineWidth/2;i[0]-=t,i[1]-=s,i[2]+=t,i[3]+=s}return i}updateClipFromPath(){let t=N.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(t){this.clipBox.set(t,0),this.minMax.set(l,0)}getClippedPathBoundingBox(t=eB,e=null){return N.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function eW(t,e){let i,s,r,a;if(e instanceof ImageData)return void t.putImageData(e,0,0);let n=e.height,o=e.width,l=n%16,h=(n-l)/16,d=0===l?h:h+1,c=t.createImageData(o,16),u=0,p,g=e.data,f=c.data;if(e.kind===m.GRAYSCALE_1BPP){let e=g.byteLength,a=new Uint32Array(f.buffer,0,f.byteLength>>2),n=a.length,m=o+7>>3,b=O.isLittleEndian?0xff000000:255;for(i=0;i<d;i++){for(s=0,r=i<h?16:l,p=0;s<r;s++){let t=e-u,i=0,s=t>m?o:8*t-7,r=-8&s,n=0,l=0;for(;i<r;i+=8)l=g[u++],a[p++]=128&l?0xffffffff:b,a[p++]=64&l?0xffffffff:b,a[p++]=32&l?0xffffffff:b,a[p++]=16&l?0xffffffff:b,a[p++]=8&l?0xffffffff:b,a[p++]=4&l?0xffffffff:b,a[p++]=2&l?0xffffffff:b,a[p++]=1&l?0xffffffff:b;for(;i<s;i++)0===n&&(l=g[u++],n=128),a[p++]=l&n?0xffffffff:b,n>>=1}for(;p<n;)a[p++]=0;t.putImageData(c,0,16*i)}}else if(e.kind===m.RGBA_32BPP){for(i=0,s=0,a=16*o*4;i<h;i++)f.set(g.subarray(u,u+a)),u+=a,t.putImageData(c,0,s),s+=16;i<d&&(a=o*l*4,f.set(g.subarray(u,u+a)),t.putImageData(c,0,s))}else if(e.kind===m.RGB_24BPP)for(i=0,a=o*(r=16);i<d;i++){for(i>=h&&(a=o*(r=l)),p=0,s=a;s--;)f[p++]=g[u++],f[p++]=g[u++],f[p++]=g[u++],f[p++]=255;t.putImageData(c,0,16*i)}else throw Error(`bad image kind: ${e.kind}`)}function eX(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);let i=e.height,s=e.width,r=i%16,a=(i-r)/16,n=0===r?a:a+1,o=t.createImageData(s,16),l=0,h=e.data,d=o.data;for(let e=0;e<n;e++){let i=e<a?16:r;({srcPos:l}=function({src:t,srcPos:e=0,dest:i,width:s,height:r,nonBlackColor:a=0xffffffff,inverseDecode:n=!1}){let o=O.isLittleEndian?0xff000000:255,[l,h]=n?[a,o]:[o,a],d=s>>3,c=7&s,u=l^h,p=t.length;i=new Uint32Array(i.buffer);let g=0;for(let s=0;s<r;++s){for(let s=e+d;e<s;++e,g+=8){let s=t[e];i[g]=l^-(s>>7&1)&u,i[g+1]=l^-(s>>6&1)&u,i[g+2]=l^-(s>>5&1)&u,i[g+3]=l^-(s>>4&1)&u,i[g+4]=l^-(s>>3&1)&u,i[g+5]=l^-(s>>2&1)&u,i[g+6]=l^-(s>>1&1)&u,i[g+7]=l^-(1&s)&u}if(0===c)continue;let s=e<p?t[e++]:255;for(let t=0;t<c;++t,++g)i[g]=l^-(s>>7-t&1)&u}return{srcPos:e,destPos:g}}({src:h,srcPos:l,dest:d,width:s,height:i,nonBlackColor:0})),t.putImageData(o,0,16*e)}}function eq(t,e){for(let i of["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"])void 0!==t[i]&&(e[i]=t[i]);void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function eK(t){t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",void 0!==t.setLineDash&&(t.setLineDash([]),t.lineDashOffset=0);let{filter:e}=t;"none"!==e&&""!==e&&(t.filter="none")}function eY(t,e){if(e)return!0;N.singularValueDecompose2dScale(t,eG);let i=Math.fround(tf.pixelRatio*Q.PDF_TO_CSS_UNITS);return eG[0]<=i&&eG[1]<=i}let eQ=["butt","round","square"],eJ=["miter","round","bevel"],eZ={},e0={};class e1{constructor(t,e,i,s,r,{optionalContentConfig:a,markedContentStack:n=null},o,l,h,d){this.ctx=t,this.current=new eV(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.commonObjs=e,this.objs=i,this.canvasFactory=s,this.filterFactory=r,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.tempSMask=null,this.smaskGroupCanvases=[],this.smaskPreparedEntry=null,this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=n||[],this.optionalContentConfig=a,this.cachedPatterns=new Map,this.annotationCanvasMap=o,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=l,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map,this.dependencyTracker=h??null,this.imagesTracker=d??null}getObject(t,e,i=null){return"string"==typeof e?(this.dependencyTracker?.recordNamedDependency(t,e),e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e)):i}beginDrawing({transform:t,viewport:e,transparency:i=!1,background:s=null}){let r=this.ctx.canvas.width,a=this.ctx.canvas.height,n=this.ctx.fillStyle;if(this.ctx.fillStyle=s||"#ffffff",this.ctx.fillRect(0,0,r,a),this.ctx.fillStyle=n,i){let t=this.transparentCanvasEntry=this.canvasFactory.create(r,a);this.compositeCtx=this.ctx,({canvas:this.transparentCanvas,context:this.ctx}=t),this.ctx.save(),this.ctx.transform(...tp(this.compositeCtx))}this.ctx.save(),eK(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[3]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=tp(this.ctx)}executeOperatorList(t,e,i,s,r){let a,n,o=t.argsArray,l=t.fnArray,h=e||0,d=o.length;if(d===h)return h;let c=d-h>10&&"function"==typeof i,u=c?Date.now()+15:0,p=0,g=this.commonObjs,m=this.objs;for(;;){if(void 0!==s){if(h===s.nextBreakPoint)return s.breakIt(h,i),h;if(s.shouldSkip(h)){if(++h===d)return h;continue}}if(!r||r(h))if(a=l[h],n=o[h]??null,a!==y.dependency)null===n?this[a](h):this[a](h,...n);else for(let t of n){this.dependencyTracker?.recordNamedData(t,h);let e=t.startsWith("g_")?g:m;if(!e.has(t))return e.get(t,i),h}if(++h===d)return h;if(c&&++p>10){if(Date.now()>u)return i(),h;p=0}}}#sp(){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.canvasFactory.destroy(this.transparentCanvasEntry),this.transparentCanvas=null,this.transparentCanvasEntry=null)}endDrawing(){for(let t of(this.#sp(),this.smaskGroupCanvases))this.canvasFactory.destroy(t);for(let t of(this.smaskGroupCanvases.length=0,this._clearPreparedSMask(),this.tempSMask=null,this.smaskStack.length=0,this.cachedPatterns.clear(),this._cachedBitmapsMap.values())){for(let e of t.values())"u">typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#sg()}#sg(){if(this.pageColors){let t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){let e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){let i=t.width??t.displayWidth,s=t.height??t.displayHeight,r=Math.max(Math.hypot(e[0],e[1]),1),a=Math.max(Math.hypot(e[2],e[3]),1),n=[],o=r,l=a,h=i,d=s;for(;o>2&&h>1||l>2&&d>1;){let t=h,e=d;o>2&&h>1&&(t=Math.ceil(h/2),o/=h/t),l>2&&d>1&&(e=Math.ceil(d/2),l/=d/e),n.push({newWidth:t,newHeight:e}),h=t,d=e}if(0===n.length)return{img:t,paintWidth:i,paintHeight:s,tmpCanvas:null};if(1===n.length){let{newWidth:e,newHeight:r}=n[0],a=this.canvasFactory.create(e,r);return a.context.drawImage(t,0,0,i,s,0,0,e,r),{img:a.canvas,paintWidth:e,paintHeight:r,tmpCanvas:a}}let c=this.canvasFactory.create(1,1),u=this.canvasFactory.create(1,1),p=i,g=s,m=t;for(let{newWidth:t,newHeight:e}of n)this.canvasFactory.reset(u,t,e),u.context.drawImage(m,0,0,p,g,0,0,t,e),[c,u]=[u,c],m=c.canvas,p=t,g=e;return this.canvasFactory.destroy(u),{img:c.canvas,paintWidth:p,paintHeight:g,tmpCanvas:c}}_createMaskCanvas(t,e){let i,s,r,a,n=this.ctx,{width:o,height:h}=e,d=this.current.fillColor,c=this.current.patternFill,u=tp(n);if((e.bitmap||e.data)&&e.count>1){let a=e.bitmap||e.data.buffer;s=JSON.stringify(c?u:[u.slice(0,4),d]);let n=(i=this._cachedBitmapsMap.getOrInsertComputed(a,V)).get(s);if(n&&!c){let e=Math.round(Math.min(u[0],u[2])+u[4]),i=Math.round(Math.min(u[1],u[3])+u[5]);return this.dependencyTracker?.recordDependencies(t,et),{canvas:n,offsetX:e,offsetY:i}}r=n}r||eX((a=this.canvasFactory.create(o,h)).context,e);let p=N.transform(u,[1/o,0,0,-1/h,0,0]);p=N.transform(p,[1,0,0,1,0,-h]);let g=l.slice();N.axialAlignedBoundingBox([0,0,o,h],p,g);let[m,f,b,y]=g,v=Math.round(b-m)||1,A=Math.round(y-f)||1,x=this.canvasFactory.create(v,A),w=x.context;w.translate(-m,-f),w.transform(...p);let _=null;if(!r){let t=this._scaleImage(a.canvas,tg(w));r=t.img,_=t.tmpCanvas,r!==a.canvas&&(this.canvasFactory.destroy(a),a=null),i&&c&&(i.set(s,r),_=null,a=null)}w.imageSmoothingEnabled=eY(tp(w),e.interpolate),ej(w,r,0,0,r.width,r.height,0,0,o,h),_&&this.canvasFactory.destroy(_),a&&this.canvasFactory.destroy(a),w.globalCompositeOperation="source-in";let C=N.transform(tg(w),[1,0,0,1,-m,-f]);return w.fillStyle=c?d.getPattern(n,this,C,eB,t):d,w.fillRect(0,0,o,h),i&&!c&&i.set(s,x.canvas),this.dependencyTracker?.recordDependencies(t,et),{canvas:x.canvas,canvasEntry:i&&!c?null:x,offsetX:Math.round(m),offsetY:Math.round(f)}}setLineWidth(t,e){this.dependencyTracker?.recordSimpleData("lineWidth",t),e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(t,e){this.dependencyTracker?.recordSimpleData("lineCap",t),this.ctx.lineCap=eQ[e]}setLineJoin(t,e){this.dependencyTracker?.recordSimpleData("lineJoin",t),this.ctx.lineJoin=eJ[e]}setMiterLimit(t,e){this.dependencyTracker?.recordSimpleData("miterLimit",t),this.ctx.miterLimit=e}setDash(t,e,i){this.dependencyTracker?.recordSimpleData("dash",t);let s=this.ctx;void 0!==s.setLineDash&&(s.setLineDash(e),s.lineDashOffset=i)}setRenderingIntent(t,e){}setFlatness(t,e){}setGState(t,e){for(let[i,s]of e)switch(i){case"LW":this.setLineWidth(t,s);break;case"LC":this.setLineCap(t,s);break;case"LJ":this.setLineJoin(t,s);break;case"ML":this.setMiterLimit(t,s);break;case"D":this.setDash(t,s[0],s[1]);break;case"RI":this.setRenderingIntent(t,s);break;case"FL":this.setFlatness(t,s);break;case"Font":this.setFont(t,s[0],s[1]);break;case"CA":this.dependencyTracker?.recordSimpleData("strokeAlpha",t),this.current.strokeAlpha=s;break;case"ca":this.dependencyTracker?.recordSimpleData("fillAlpha",t),this.ctx.globalAlpha=this.current.fillAlpha=s;break;case"BM":this.dependencyTracker?.recordSimpleData("globalCompositeOperation",t),this.ctx.globalCompositeOperation=s;break;case"SMask":this.dependencyTracker?.recordSimpleData("SMask",t),this.current.activeSMask=s?this.tempSMask:null,this.current.activeSMask&&(this.current.activeSMask.blendMode=this.ctx.globalCompositeOperation),this.tempSMask=null,this.checkSMaskState(t);break;case"TR":this.dependencyTracker?.recordSimpleData("filter",t),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(s)}}get inSMaskMode(){return!!this.suspendedCtx}_clearPreparedSMask(){this.smaskPreparedEntry&&(this.canvasFactory.destroy(this.smaskPreparedEntry),this.smaskPreparedEntry=null),this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0}_ensurePreparedSMask(t,e,i){t!==this.smaskPreparedFor&&(this._clearPreparedSMask(),this._prepareSMaskCanvas(t,e,i))}checkSMaskState(t){let e=this.inSMaskMode;this.current.activeSMask&&!e?this.beginSMaskMode(t):!this.current.activeSMask&&e?this.endSMaskMode():this.current.activeSMask&&e&&this._ensurePreparedSMask(this.current.activeSMask,this.ctx.canvas.width,this.ctx.canvas.height)}_prepareSMaskCanvas(t,e,i){let s,r,a,{canvas:n,subtype:o,backdrop:l,transferMap:h}=t,d="Luminosity"===o||"Alpha"===o&&h;if(!l&&!d){this.smaskPreparedFor=t;return}if(l&&d){let d=this.canvasFactory.create(e,i),c=d.context;c.drawImage(n,t.offsetX,t.offsetY),c.globalCompositeOperation="destination-atop",c.fillStyle=l,c.fillRect(0,0,e,i),c.globalCompositeOperation="source-over";let u=(s=this.canvasFactory.create(e,i)).context;u.filter="Alpha"===o?this.filterFactory.addAlphaFilter(h):this.filterFactory.addLuminosityFilter(h),u.drawImage(d.canvas,0,0),u.filter="none",this.canvasFactory.destroy(d),r=a=0}else if(d){let e=(s=this.canvasFactory.create(n.width,n.height)).context;e.filter="Alpha"===o?this.filterFactory.addAlphaFilter(h):this.filterFactory.addLuminosityFilter(h),e.drawImage(n,0,0),e.filter="none",{offsetX:r,offsetY:a}=t}else{let o=(s=this.canvasFactory.create(e,i)).context;o.drawImage(n,t.offsetX,t.offsetY),o.globalCompositeOperation="destination-atop",o.fillStyle=l,o.fillRect(0,0,e,i),o.globalCompositeOperation="source-over",r=a=0}this.smaskPreparedEntry=s,this.smaskPreparedFor=t,this.smaskPreparedOffsetX=r,this.smaskPreparedOffsetY=a}beginSMaskMode(t){if(this.inSMaskMode)throw Error("beginSMaskMode called while already in smask mode");let{width:e,height:i}=this.ctx.canvas,s=this.canvasFactory.create(e,i);this.smaskScratchCanvas=s,this.suspendedCtx=this.ctx;let r=this.ctx=s.context;r.setTransform(this.suspendedCtx.getTransform()),eq(this.suspendedCtx,r);var a=this.suspendedCtx;if(r._removeMirroring)throw Error("Context is already forwarding operations.");r.__originalSave=r.save,r.__originalRestore=r.restore,r.__originalRotate=r.rotate,r.__originalScale=r.scale,r.__originalTranslate=r.translate,r.__originalTransform=r.transform,r.__originalSetTransform=r.setTransform,r.__originalResetTransform=r.resetTransform,r.__originalClip=r.clip,r.__originalMoveTo=r.moveTo,r.__originalLineTo=r.lineTo,r.__originalBezierCurveTo=r.bezierCurveTo,r.__originalRect=r.rect,r.__originalClosePath=r.closePath,r.__originalBeginPath=r.beginPath,r._removeMirroring=()=>{r.save=r.__originalSave,r.restore=r.__originalRestore,r.rotate=r.__originalRotate,r.scale=r.__originalScale,r.translate=r.__originalTranslate,r.transform=r.__originalTransform,r.setTransform=r.__originalSetTransform,r.resetTransform=r.__originalResetTransform,r.clip=r.__originalClip,r.moveTo=r.__originalMoveTo,r.lineTo=r.__originalLineTo,r.bezierCurveTo=r.__originalBezierCurveTo,r.rect=r.__originalRect,r.closePath=r.__originalClosePath,r.beginPath=r.__originalBeginPath,delete r._removeMirroring},r.save=function(){a.save(),this.__originalSave()},r.restore=function(){a.restore(),this.__originalRestore()},r.translate=function(t,e){a.translate(t,e),this.__originalTranslate(t,e)},r.scale=function(t,e){a.scale(t,e),this.__originalScale(t,e)},r.transform=function(t,e,i,s,r,n){a.transform(t,e,i,s,r,n),this.__originalTransform(t,e,i,s,r,n)},r.setTransform=function(t,e,i,s,r,n){void 0===e?(a.setTransform(t),this.__originalSetTransform(t)):(a.setTransform(t,e,i,s,r,n),this.__originalSetTransform(t,e,i,s,r,n))},r.resetTransform=function(){a.resetTransform(),this.__originalResetTransform()},r.rotate=function(t){a.rotate(t),this.__originalRotate(t)},r.clip=function(t){a.clip(t),this.__originalClip(t)},r.moveTo=function(t,e){a.moveTo(t,e),this.__originalMoveTo(t,e)},r.lineTo=function(t,e){a.lineTo(t,e),this.__originalLineTo(t,e)},r.bezierCurveTo=function(t,e,i,s,r,n){a.bezierCurveTo(t,e,i,s,r,n),this.__originalBezierCurveTo(t,e,i,s,r,n)},r.rect=function(t,e,i,s){a.rect(t,e,i,s),this.__originalRect(t,e,i,s)},r.closePath=function(){a.closePath(),this.__originalClosePath()},r.beginPath=function(){a.beginPath(),this.__originalBeginPath()},this._ensurePreparedSMask(this.current.activeSMask,e,i),this.setGState(t,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),eq(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null,this.canvasFactory.destroy(this.smaskScratchCanvas),this.smaskScratchCanvas=null,this._clearPreparedSMask()}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];let 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(t[0],t[1],t[2]-t[0],t[3]-t[1]),this.ctx.restore()}composeSMask(t,e,i,s){let r=s[0],a=s[1],n=s[2]-r,o=s[3]-a;if(0===n||0===o)return;let l=this.smaskPreparedEntry;if(l){let t=r-this.smaskPreparedOffsetX,e=a-this.smaskPreparedOffsetY;i.save(),i.globalAlpha=1,i.setTransform(1,0,0,1,0,0);let s=new Path2D;s.rect(r,a,n,o),i.clip(s),i.globalCompositeOperation="destination-in",i.drawImage(l.canvas,t,e,n,o,r,a,n,o),i.restore()}else this.genericComposeSMask(e.context,i,n,o,r,a,e.offsetX,e.offsetY);t.save(),t.globalAlpha=1,t.globalCompositeOperation=e.blendMode||"source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(i.canvas,r,a,n,o,r,a,n,o),t.restore()}genericComposeSMask(t,e,i,s,r,a,n,o){let l=t.canvas,h=r-n,d=a-o;e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);let c=new Path2D;c.rect(r,a,i,s),e.clip(c),e.globalCompositeOperation="destination-in",e.drawImage(l,h,d,i,s,r,a,i,s),e.restore()}save(t){this.inSMaskMode&&eq(this.ctx,this.suspendedCtx),this.ctx.save();let e=this.current;this.stateStack.push(e),this.current=e.clone(),this.dependencyTracker?.save(t)}restore(t){if(this.dependencyTracker?.restore(t),0===this.stateStack.length){this.inSMaskMode&&this.endSMaskMode();return}this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&(eq(this.suspendedCtx,this.ctx),this.ctx.setTransform(this.suspendedCtx.getTransform())),this.checkSMaskState(t),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}transform(t,e,i,s,r,a,n){this.dependencyTracker?.recordIncrementalData("transform",t),this.ctx.transform(e,i,s,r,a,n),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,i,s){let[r]=i;if(!s){r||=i[0]=new Path2D,e!==y.stroke&&e!==y.closeStroke&&(this.current.tilingPatternDims=null),this[e](t,r);return}if(null!==this.dependencyTracker){let i=e===y.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,s[0]-i,s[2]+i,s[1]-i,s[3]+i).recordDependencies(t,["transform"])}r instanceof Path2D||(r=i[0]=tM(r)),N.axialAlignedBoundingBox(s,tp(this.ctx),this.current.minMax);let a=this.current.tilingPatternDims;if(a&&e!==y.stroke&&e!==y.closeStroke&&this.current.fillColor instanceof ez){let t=N.intersect(this.current.clipBox,this.current.minMax);t?this.current.fillColor.updatePatternDims(t,a):this.current.tilingPatternDims=null}this[e](t,r),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,i=!0){let s=this.ctx,r=this.current.strokeColor;if(s.globalAlpha=this.current.strokeAlpha,this.contentVisible)if("object"==typeof r&&r?.getPattern){let i=r.isModifyingCurrentTransform()?s.getTransform():null;if(s.save(),s.strokeStyle=r.getPattern(s,this,tg(s),eF,t),i){let t=new Path2D;t.addPath(e,s.getTransform().invertSelf().multiplySelf(i)),e=t}this.rescaleAndStroke(e,!1),s.restore()}else this.rescaleAndStroke(e,!0);this.dependencyTracker?.recordDependencies(t,t5),i&&this.consumePath(t,e,this.current.getClippedPathBoundingBox(eF,tp(this.ctx))),s.globalAlpha=this.current.fillAlpha}closeStroke(t,e){this.stroke(t,e)}fill(t,e,i=!0){let s=this.ctx,r=this.current.fillColor,a=this.current.patternFill,n=!1,o=this.current.getClippedPathBoundingBox();if(this.dependencyTracker?.recordDependencies(t,t6),a){let a=this.current.tilingPatternDims,l=a&&r.canSkipPatternCanvas(a);if(l){r.drawPattern(this,e,this.pendingEOFill,l,t),this.pendingEOFill=!1,i&&this.consumePath(t,e,o),this.current.tilingPatternDims=null;return}let h=r.isModifyingCurrentTransform()?s.getTransform():null;if(this.dependencyTracker?.save(t),s.save(),s.fillStyle=r.getPattern(s,this,tg(s),eB,t),h){let t=new Path2D;t.addPath(e,s.getTransform().invertSelf().multiplySelf(h)),e=t}n=!0}this.contentVisible&&null!==o&&(this.pendingEOFill?(s.fill(e,"evenodd"),this.pendingEOFill=!1):s.fill(e)),n&&(s.restore(),this.dependencyTracker?.restore(t)),i&&this.consumePath(t,e,o)}eoFill(t,e){this.pendingEOFill=!0,this.fill(t,e)}fillStroke(t,e){this.fill(t,e,!1),this.stroke(t,e,!1),this.consumePath(t,e)}eoFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}closeFillStroke(t,e){this.fillStroke(t,e)}closeEOFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}endPath(t,e){this.consumePath(t,e)}rawFillPath(t,e){this.ctx.fill(e),this.dependencyTracker?.recordDependencies(t,t8).recordOperation(t)}clip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=eZ}eoClip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=e0}beginText(t){this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,this.dependencyTracker?.recordOpenMarker(t).resetIncrementalData("sameLineText").resetIncrementalData("moveText",t)}endText(t){let e=this.pendingTextPaths,i=this.ctx;if(this.dependencyTracker){let{dependencyTracker:i}=this;void 0!==e&&i.recordFutureForcedDependency("textClip",i.getOpenMarker()).recordFutureForcedDependency("textClip",t),i.recordCloseMarker(t)}if(void 0!==e){let t=new Path2D,s=i.getTransform().invertSelf();for(let{transform:i,x:r,y:a,fontSize:n,path:o}of e)o&&t.addPath(o,new DOMMatrix(i).preMultiplySelf(s).translate(r,a).scale(n,-n));i.clip(t)}delete this.pendingTextPaths}setCharSpacing(t,e){this.dependencyTracker?.recordSimpleData("charSpacing",t),this.current.charSpacing=e}setWordSpacing(t,e){this.dependencyTracker?.recordSimpleData("wordSpacing",t),this.current.wordSpacing=e}setHScale(t,e){this.dependencyTracker?.recordSimpleData("hScale",t),this.current.textHScale=e/100}setLeading(t,e){this.dependencyTracker?.recordSimpleData("leading",t),this.current.leading=-e}setFont(t,e,i){this.dependencyTracker?.recordSimpleData("font",t).recordSimpleDataFromNamed("fontObj",e,t);let s=this.commonObjs.get(e),r=this.current;if(!s)throw Error(`Can't find font for ${e}`);if(r.fontMatrix=s.fontMatrix||h,(0===r.fontMatrix[0]||0===r.fontMatrix[3])&&w("Invalid font matrix for font "+e),i<0?(i=-i,r.fontDirection=-1):r.fontDirection=1,this.current.font=s,this.current.fontSize=i,s.isType3Font)return;let a=s.loadedName||"sans-serif",n=s.systemFontInfo?.css||`"${a}", ${s.fallbackName}`,o="normal";s.black?o="900":s.bold&&(o="bold");let l=s.italic?"italic":"normal",d=i;i<16?d=16:i>100&&(d=100),this.current.fontSizeScale=i/d,this.ctx.font=`${l} ${o} ${d}px ${n}`}setTextRenderingMode(t,e){this.dependencyTracker?.recordSimpleData("textRenderingMode",t),this.current.textRenderingMode=e}setTextRise(t,e){this.dependencyTracker?.recordSimpleData("textRise",t),this.current.textRise=e}moveText(t,e,i){this.dependencyTracker?.resetIncrementalData("sameLineText").recordIncrementalData("moveText",t),this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=i}setLeadingMoveText(t,e,i){this.setLeading(t,-i),this.moveText(t,e,i)}setTextMatrix(t,e){this.dependencyTracker?.resetIncrementalData("sameLineText").recordSimpleData("textMatrix",t);let{current:i}=this;i.textMatrix=e,i.textMatrixScale=Math.hypot(e[0],e[1]),i.x=i.lineX=0,i.y=i.lineY=0}nextLine(t){this.moveText(t,0,this.current.leading),this.dependencyTracker?.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??t)}#sm(t,e,i){let s=new Path2D;return s.addPath(t,new DOMMatrix(i).invertSelf().multiplySelf(e)),s}paintChar(t,e,i,s,r,a){let n,o=this.ctx,l=this.current,h=l.font,d=l.textRenderingMode,c=l.fontSize/l.fontSizeScale,u=3&d,p=!!(4&d),g=l.patternFill&&!h.missingFile,m=l.patternStroke&&!h.missingFile;if((h.disableFontFace||p||g||m)&&!h.missingFile&&(n=h.getPathGenerator(this.commonObjs,e)),n&&(h.disableFontFace||g||m)){let e;if(o.save(),o.translate(i,s),o.scale(c,-c),this.dependencyTracker?.recordCharacterBBox(t,o,h),0===u||2===u)if(r){e=o.getTransform(),o.setTransform(...r);let t=this.#sm(n,e,r);o.fill(t)}else o.fill(n);if(1===u||2===u)if(a){e||=o.getTransform(),o.setTransform(...a);let{a:t,b:i,c:s,d:r}=e,l=N.inverseTransform(a),h=N.transform([t,i,s,r,0,0],l);N.singularValueDecompose2dScale(h,eG),o.lineWidth*=Math.max(eG[0],eG[1])/c,o.stroke(this.#sm(n,e,a))}else o.lineWidth/=c,o.stroke(n);o.restore()}else(0===u||2===u)&&(o.fillText(e,i,s),this.dependencyTracker?.recordCharacterBBox(t,o,h,c,i,s,()=>o.measureText(e))),(1===u||2===u)&&(this.dependencyTracker&&this.dependencyTracker?.recordCharacterBBox(t,o,h,c,i,s,()=>o.measureText(e)).recordDependencies(t,t5),o.strokeText(e,i,s));p&&((this.pendingTextPaths||=[]).push({transform:tp(o),x:i,y:s,fontSize:c,path:n}),this.dependencyTracker?.recordCharacterBBox(t,o,h,c,i,s))}get isFontSubpixelAAEnabled(){let t=this.canvasFactory.create(10,10),e=t.context;e.scale(1.5,1),e.fillText("I",0,10);let i=e.getImageData(0,0,10,10).data;this.canvasFactory.destroy(t);let s=!1;for(let t=3;t<i.length;t+=4)if(i[t]>0&&i[t]<255){s=!0;break}return M(this,"isFontSubpixelAAEnabled",s)}showText(t,e){let i,s;this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,t7).resetBBox(t),4&this.current.textRenderingMode&&this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies());let r=this.current,a=r.font;if(a.isType3Font){this.showType3Text(t,e),this.dependencyTracker?.recordShowTextOperation(t);return}let n=r.fontSize;if(0===n)return void this.dependencyTracker?.recordOperation(t);let o=this.ctx,l=r.fontSizeScale,h=r.charSpacing,d=r.wordSpacing,c=r.fontDirection,u=r.textHScale*c,p=e.length,g=a.vertical,m=g?1:-1,f=a.defaultVMetrics,b=n*r.fontMatrix[0],y=0===r.textRenderingMode&&!a.disableFontFace&&!r.patternFill;o.save(),r.textMatrix&&o.transform(...r.textMatrix),o.translate(r.x,r.y+r.textRise),c>0?o.scale(u,-1):o.scale(u,1);let v=3&r.textRenderingMode,A=1===v||2===v,x=r.lineWidth,w=r.textMatrixScale;if(0===w||0===x?A&&(x=this.getSinglePixelWidth()):x/=w,1!==l&&(o.scale(l,l),x/=l),o.lineWidth=x,(0===v||2===v)&&r.patternFill){o.save();let e=r.fillColor.getPattern(o,this,tg(o),eB,t);i=tp(o),o.restore(),o.fillStyle=e}if(A&&r.patternStroke){o.save();let e=r.strokeColor.getPattern(o,this,tg(o),eF,t);s=tp(o),o.restore(),o.strokeStyle=e}if(a.isInvalidPDFjsFont){let i=[],s=0;for(let t of e)i.push(t.unicode),s+=t.width;let a=i.join("");if(o.fillText(a,0,0),null!==this.dependencyTracker){let e=o.measureText(a);this.dependencyTracker.recordBBox(t,this.ctx,-e.actualBoundingBoxLeft,e.actualBoundingBoxRight,-e.actualBoundingBoxAscent,e.actualBoundingBoxDescent).recordShowTextOperation(t)}r.x+=s*b*u,o.restore(),this.compose();return}let _=0,C;for(C=0;C<p;++C){let r,u,p,v=e[C];if("number"==typeof v){_+=m*v*n/1e3;continue}let A=!1,x=(v.isSpace?d:0)+h,w=v.fontChar,T=v.accent,S=v.width;if(g){let t=v.vmetric||f,e=-(v.vmetric?t[1]:.5*S)*b,i=t[2]*b;S=t?-t[0]:S,r=e/l,u=(_+i)/l}else r=_/l,u=0;if(a.remeasure&&S>0){let t=1e3*(p=o.measureText(w)).width/n*l;if(S<t&&this.isFontSubpixelAAEnabled){let e=S/t;A=!0,o.save(),o.scale(e,1),r/=e}else S!==t&&(r+=(S-t)/2e3*n/l)}if(this.contentVisible&&(v.isInFont||a.missingFile)){if(y&&!T)o.fillText(w,r,u),this.dependencyTracker?.recordCharacterBBox(t,o,p?{bbox:null}:a,n/l,r,u,()=>p??o.measureText(w));else if(this.paintChar(t,w,r,u,i,s),T){let e=r+n*T.offset.x/l,a=u-n*T.offset.y/l;this.paintChar(t,T.fontChar,e,a,i,s)}}_+=g?S*b-x*c:S*b+x*c,A&&o.restore()}g?r.y-=_:r.x+=_*u,o.restore(),this.compose(),this.dependencyTracker?.recordShowTextOperation(t)}showType3Text(t,e){let i,s,r,a,n=this.ctx,o=this.current,l=o.font,d=o.fontSize,c=o.fontDirection,u=l.vertical?1:-1,p=o.charSpacing,g=o.wordSpacing,m=o.textHScale*c,f=o.fontMatrix||h,b=e.length;if(3===o.textRenderingMode||0===d)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,n.save(),o.textMatrix&&n.transform(...o.textMatrix),n.translate(o.x,o.y+o.textRise),n.scale(m,c);let y=this.dependencyTracker;for(i=0,this.dependencyTracker=y?new t3(y,t):null;i<b;++i){if("number"==typeof(s=e[i])){a=u*s*d/1e3,this.ctx.translate(a,0),o.x+=a*m;continue}let t=(s.isSpace?g:0)+p,h=l.charProcOperatorList[s.operatorListId];h?this.contentVisible&&(this.save(),n.scale(d,d),n.transform(...f),this.executeOperatorList(h),this.restore()):w(`Type3 character "${s.operatorListId}" is not available.`);let c=[s.width,0];N.applyTransform(c,f),r=c[0]*d+t,n.translate(r,0),o.x+=r*m}n.restore(),y&&(this.dependencyTracker=y)}setCharWidth(t,e,i){}setCharWidthAndBounds(t,e,i,s,r,a,n){let o=new Path2D;o.rect(s,r,a-s,n-r),this.ctx.clip(o),this.dependencyTracker?.recordBBox(t,this.ctx,s,a,r,n).recordClipBox(t,this.ctx,s,a,r,n),this.endPath(t)}getColorN_Pattern(t,e){let i;if("TilingPattern"===e[0]){let t=this.baseTransform||tp(this.ctx);i=new ez(e,this.ctx,{createCanvasGraphics:(t,e)=>new e1(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new t3(this.dependencyTracker,e,!0):null)},t)}else i=this._getPattern(t,e[1],e[2]);return i}setStrokeColorN(t,...e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.current.strokeColor=this.getColorN_Pattern(t,e),this.current.patternStroke=!0}setFillColorN(t,...e){this.dependencyTracker?.recordSimpleData("fillColor",t);let i=this.current.fillColor=this.getColorN_Pattern(t,e);this.current.patternFill=!0,this.current.tilingPatternDims=i instanceof ez?[0,0,0,0]:null}setStrokeRGBColor(t,e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor=e,this.current.patternStroke=!1}setStrokeTransparent(t){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor=e,this.current.patternFill=!1,this.current.tilingPatternDims=null}setFillTransparent(t){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1,this.current.tilingPatternDims=null}_getPattern(t,e,i=null){let s;return this.cachedPatterns.has(e)?s=this.cachedPatterns.get(e):(s=function(t){switch(t[0]){case"RadialAxial":return new eN(t);case"Mesh":return new eU(t);case"Dummy":return new eH}throw Error(`Unknown IR type: ${t[0]}`)}(this.getObject(t,e)),this.cachedPatterns.set(e,s)),i&&(s.matrix=i),s}shadingFill(t,e){if(!this.contentVisible)return;let i=this.ctx;this.save(t),i.fillStyle=this._getPattern(t,e).getPattern(i,this,tg(i),eL,t);let s=tg(i);if(s){let{width:t,height:e}=i.canvas,r=l.slice();N.axialAlignedBoundingBox([0,0,t,e],s,r);let[a,n,o,h]=r;this.ctx.fillRect(a,n,o-a,h-n)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.dependencyTracker?.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,t9).recordDependencies(t,t6).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t)}beginInlineImage(){_("Should not call beginInlineImage")}beginImageData(){_("Should not call beginImageData")}paintFormXObjectBegin(t,e,i){if(this.contentVisible&&(this.save(t),this.baseTransformStack.push(this.baseTransform),e&&this.transform(t,...e),this.baseTransform=tp(this.ctx),i)){N.axialAlignedBoundingBox(i,this.baseTransform,this.current.minMax);let[e,s,r,a]=i,n=new Path2D;n.rect(e,s,r-e,a-s),this.ctx.clip(n),this.dependencyTracker?.recordClipBox(t,this.ctx,e,r,s,a),this.endPath(t)}}paintFormXObjectEnd(t){this.contentVisible&&(this.restore(t),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t,e){let i;if(!this.contentVisible)return;this.save(t);let{inSMaskMode:s}=this;s&&(this.endSMaskMode(),this.current.activeSMask=null);let r=this.ctx;if(e.isolated||x("TODO: Support non-isolated groups."),e.knockout&&w("Knockout groups not supported."),!e.needsIsolation&&1===r.globalAlpha&&"source-over"===r.globalCompositeOperation&&!s){if(e.bbox){let t=new Path2D,[i,s,a,n]=e.bbox;if(t.rect(i,s,a-i,n-s),e.matrix){let i=new Path2D;i.addPath(t,new DOMMatrix(e.matrix)),t=i}r.clip(t)}this.groupStack.push(null),this.groupLevel++;return}let a=tp(r);e.matrix&&r.transform(...e.matrix);let n=[0,0,r.canvas.width,r.canvas.height];e.bbox?(i=l.slice(),N.axialAlignedBoundingBox(e.bbox,tp(r),i),i=N.intersect(i,n)||[0,0,0,0]):i=n;let o=Math.floor(i[0]),h=Math.floor(i[1]),d=Math.max(Math.ceil(i[2])-o,1),c=Math.max(Math.ceil(i[3])-h,1);this.current.startNewPathAndClipBox([0,0,d,c]);let u=this.canvasFactory.create(d,c);e.smask&&this.smaskGroupCanvases.push(u);let p=u.context;if(p.translate(-o,-h),p.transform(...a),!e.isolated&&!e.smask&&s&&e.needsIsolation&&(p.save(),p.setTransform(1,0,0,1,0,0),p.drawImage(r.canvas,-o,-h),p.restore()),e.bbox){let t=new Path2D,[i,s,r,a]=e.bbox;if(t.rect(i,s,r-i,a-s),e.matrix){let i=new Path2D;i.addPath(t,new DOMMatrix(e.matrix)),t=i}p.clip(t)}e.smask&&this.smaskStack.push({canvas:u.canvas,context:p,offsetX:o,offsetY:h,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null}),(!e.smask||this.dependencyTracker)&&(r.setTransform(1,0,0,1,0,0),r.translate(o,h),r.save()),eq(r,p),this.ctx=p,this.dependencyTracker?.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(r),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1],["TR",null]]),this.groupStack.push(r),this.groupLevel++}endGroup(t,e){if(!this.contentVisible)return;this.groupLevel--;let i=this.ctx,s=this.groupStack.pop();if(null===s)return void this.restore(t);if(this.ctx=s,this.ctx.imageSmoothingEnabled=!1,this.dependencyTracker?.popBaseTransform(),e.smask)this.tempSMask=this.smaskStack.pop(),this.restore(t),this.dependencyTracker&&(this.ctx.restore(),this.inSMaskMode&&this.ctx.setTransform(this.suspendedCtx.getTransform()));else{this.ctx.restore();let e=tp(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...e);let s=l.slice();N.axialAlignedBoundingBox([0,0,i.canvas.width,i.canvas.height],e,s),this.ctx.drawImage(i.canvas,0,0),this.ctx.restore(),this.canvasFactory.destroy({canvas:i.canvas,context:i}),this.compose(s)}}beginAnnotation(t,e,i,s,r,a){if(this.#sp(),eK(this.ctx),this.ctx.save(),this.save(t),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),i){let r=i[2]-i[0],n=i[3]-i[1];if(a&&this.annotationCanvasMap){s=s.slice(),s[4]-=i[0],s[5]-=i[1],(i=i.slice())[0]=i[1]=0,i[2]=r,i[3]=n,N.singularValueDecompose2dScale(tp(this.ctx),eG);let{viewportScale:t}=this,a=Math.ceil(r*this.outputScaleX*t),o=Math.ceil(n*this.outputScaleY*t);this.annotationCanvas=this.canvasFactory.create(a,o);let{canvas:l,context:h}=this.annotationCanvas;this.annotationCanvasMap.set(e,l),this.annotationCanvas.savedCtx=this.ctx,this.ctx=h,this.ctx.save(),this.ctx.setTransform(eG[0],0,0,-eG[1],0,n*eG[1]),eK(this.ctx)}else{eK(this.ctx),this.endPath(t);let e=new Path2D;e.rect(i[0],i[1],r,n),this.ctx.clip(e)}}this.current=new eV(this.ctx.canvas.width,this.ctx.canvas.height),this.baseTransformStack.push(this.baseTransform),this.transform(t,...s),this.transform(t,...r),this.baseTransform=tp(this.ctx)}endAnnotation(t){this.annotationCanvas&&(this.ctx.restore(),this.#sg(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas),this.baseTransform=this.baseTransformStack.pop()}paintImageMaskXObject(t,e){if(!this.contentVisible)return;let i=e.count;(e=this.getObject(t,e.data,e)).count=i;let s=this.ctx,r=this._createMaskCanvas(t,e),a=r.canvas;s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(a,r.offsetX,r.offsetY),this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,r.offsetX,r.offsetX+a.width,r.offsetY,r.offsetY+a.height).recordOperation(t),s.restore(),r.canvasEntry&&this.canvasFactory.destroy(r.canvasEntry),this.compose()}paintImageMaskXObjectRepeat(t,e,i,s=0,r=0,a,n){if(!this.contentVisible)return;e=this.getObject(t,e.data,e);let o=this.ctx;o.save();let l=tp(o);o.transform(i,s,r,a,0,0);let h=this._createMaskCanvas(t,e);o.setTransform(1,0,0,1,h.offsetX-l[4],h.offsetY-l[5]),this.dependencyTracker?.resetBBox(t);for(let e=0,d=n.length;e<d;e+=2){let d=N.transform(l,[i,s,r,a,n[e],n[e+1]]);o.drawImage(h.canvas,d[4],d[5]),this.dependencyTracker?.recordBBox(t,this.ctx,d[4],d[4]+h.canvas.width,d[5],d[5]+h.canvas.height)}o.restore(),h.canvasEntry&&this.canvasFactory.destroy(h.canvasEntry),this.compose(),this.dependencyTracker?.recordOperation(t)}paintImageMaskXObjectGroup(t,e){if(!this.contentVisible)return;let i=this.ctx,s=this.current.fillColor,r=this.current.patternFill;for(let a of(this.dependencyTracker?.resetBBox(t).recordDependencies(t,et),e)){let{data:e,width:n,height:o,transform:l}=a,h=this.canvasFactory.create(n,o),d=h.context;d.save(),eX(d,this.getObject(t,e,a)),d.globalCompositeOperation="source-in",d.fillStyle=r?s.getPattern(d,this,tg(i),eB,t):s,d.fillRect(0,0,n,o),d.restore(),i.save(),i.transform(...l),i.scale(1,-1),ej(i,h.canvas,0,0,n,o,0,-1,1,1),this.canvasFactory.destroy(h),this.dependencyTracker?.recordBBox(t,i,0,n,0,o),i.restore()}this.compose(),this.dependencyTracker?.recordOperation(t)}paintImageXObject(t,e){if(!this.contentVisible)return;let i=this.getObject(t,e);i?this.paintInlineImageXObject(t,i):w("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,i,s,r){if(!this.contentVisible)return;let a=this.getObject(t,e);if(!a)return void w("Dependent image isn't ready yet");let n=a.width,o=a.height,l=[];for(let t=0,e=r.length;t<e;t+=2)l.push({transform:[i,0,0,s,r[t],r[t+1]],x:0,y:0,w:n,h:o});this.paintInlineImageXObjectGroup(t,a,l)}applyTransferMapsToCanvas(t){return"none"!==this.current.transferMaps&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if("none"===this.current.transferMaps)return{img:t.bitmap,canvasEntry:null};let{bitmap:e,width:i,height:s}=t,r=this.canvasFactory.create(i,s),a=r.context;return a.filter=this.current.transferMaps,a.drawImage(e,0,0),a.filter="none",{img:r.canvas,canvasEntry:r}}paintInlineImageXObject(t,e){let i;if(!this.contentVisible)return;let s=e.width,r=e.height,a=this.ctx;this.save(t);let{filter:n}=a;"none"!==n&&""!==n&&(a.filter="none"),a.scale(1/s,-1/r);let o=null;if(e.bitmap){let t=this.applyTransferMapsToBitmap(e);i=t.img,o=t.canvasEntry}else if("function"==typeof HTMLElement&&e instanceof HTMLElement||!e.data)i=e;else{let t=this.canvasFactory.create(s,r);eW(t.context,e),i=this.applyTransferMapsToCanvas(t.context),o=t}let l=this._scaleImage(i,tg(a));a.imageSmoothingEnabled=eY(tp(a),e.interpolate),this.dependencyTracker&&(this.dependencyTracker.resetBBox(t).recordBBox(t,a,0,s,-r,0).recordDependencies(t,t4).recordOperation(t),this.imagesTracker?.record(a,s,r,this.dependencyTracker.clipBox)),ej(a,l.img,0,0,l.paintWidth,l.paintHeight,0,-r,s,r),l.tmpCanvas&&this.canvasFactory.destroy(l.tmpCanvas),o&&this.canvasFactory.destroy(o),this.compose(),this.restore(t)}paintInlineImageXObjectGroup(t,e,i){let s;if(!this.contentVisible)return;let r=this.ctx,a=null;if(e.bitmap)s=e.bitmap;else{let t=e.width,i=e.height,r=this.canvasFactory.create(t,i);eW(r.context,e),s=this.applyTransferMapsToCanvas(r.context),a=r}for(let e of(this.dependencyTracker?.resetBBox(t),i))r.save(),r.transform(...e.transform),r.scale(1,-1),ej(r,s,e.x,e.y,e.w,e.h,0,-1,1,1),this.dependencyTracker?.recordBBox(t,r,0,1,-1,0),r.restore();a&&this.canvasFactory.destroy(a),this.dependencyTracker?.recordOperation(t),this.compose()}paintSolidColorImageMask(t){this.contentVisible&&(this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,t6).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t,e){}markPointProps(t,e,i){}beginMarkedContent(t,e){this.dependencyTracker?.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e,i){this.dependencyTracker?.beginMarkedContent(t),"OC"===e?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(i)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(t){this.dependencyTracker?.endMarkedContent(t),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(t){}endCompat(t){}consumePath(t,e,i){let s=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(i);let r=this.ctx;this.pendingClip?(s||(this.pendingClip===e0?r.clip(e,"evenodd"):r.clip(e)),this.pendingClip=null,this.dependencyTracker?.bboxToClipBoxDropOperation(t).recordFutureForcedDependency("clipPath",t)):this.dependencyTracker?.recordOperation(t),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){let t=tp(this.ctx);if(0===t[1]&&0===t[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{let 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(-1===this._cachedScaleForStroking[0]){let t,e,{lineWidth:i}=this.current,{a:s,b:r,c:a,d:n}=this.ctx.getTransform();if(0===r&&0===a){let r=Math.abs(s),a=Math.abs(n);if(r===a)if(0===i)t=e=1/r;else{let s=r*i;t=e=s<1?1/s:1}else if(0===i)t=1/r,e=1/a;else{let s=r*i,n=a*i;t=s<1?1/s:1,e=n<1?1/n:1}}else{let o=Math.abs(s*n-r*a),l=Math.hypot(s,r),h=Math.hypot(a,n);if(0===i)t=h/o,e=l/o;else{let s=i*o;t=h>s?h/s:1,e=l>s?l/s:1}}this._cachedScaleForStroking[0]=t,this._cachedScaleForStroking[1]=e}return this._cachedScaleForStroking}rescaleAndStroke(t,e){let{ctx:i,current:{lineWidth:s}}=this,[r,a]=this.getScaleForStroking();if(r===a){i.lineWidth=(s||1)*r,i.stroke(t);return}let n=i.getLineDash();e&&i.save(),i.scale(r,a),e$.a=1/r,e$.d=1/a;let o=new Path2D;if(o.addPath(t,e$),n.length>0){let t=Math.max(r,a);i.setLineDash(n.map(e=>e/t)),i.lineDashOffset/=t}i.lineWidth=s||1,i.stroke(o),e&&i.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(let t in y)void 0!==e1.prototype[t]&&(e1.prototype[y[t]]=e1.prototype[t]);class e2{#sf=null;#sb=null;_fullReader=null;_rangeReaders=new Set;_source=null;constructor(t,e,i){this._source=t,this.#sf=e,this.#sb=i}get _progressiveDataLength(){return this._fullReader?._loaded??0}getFullReader(){return C(!this._fullReader,"BasePDFStream.getFullReader can only be called once."),this._fullReader=new this.#sf(this)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let i=new this.#sb(this,t,e);return this._rangeReaders.add(i),i}cancelAllRequests(t){for(let e of(this._fullReader?.cancel(t),new Set(this._rangeReaders)))e.cancel(t)}}class e3{onProgress=null;_contentLength=0;_filename=null;_headersCapability=Promise.withResolvers();_isRangeSupported=!1;_isStreamingSupported=!1;_loaded=0;_stream=null;constructor(t){this._stream=t}_callOnProgress(){this.onProgress?.({loaded:this._loaded,total:this._contentLength})}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(){_("Abstract method `read` called")}cancel(t){_("Abstract method `cancel` called")}}class e5{_stream=null;constructor(t,e,i){this._stream=t}async read(){_("Abstract method `read` called")}cancel(t){_("Abstract method `cancel` called")}}function e6(t,e){let i=new Headers;if(!t||!e||"object"!=typeof e)return i;for(let t in e){let s=e[t];void 0!==s&&i.append(t,s)}return i}function e4(t){return URL.parse(t)?.origin??null}function e8({responseHeaders:t,isHttp:e,rangeChunkSize:i,disableRange:s}){let r={contentLength:0,isRangeSupported:!1},a=parseInt(t.get("Content-Length"),10);return Number.isInteger(a)&&(r.contentLength=a,a<=2*i||s||!e||"bytes"!==t.get("Accept-Ranges")||"identity"===(t.get("Content-Encoding")||"identity")&&(r.isRangeSupported=!0)),r}function e7(t){let e=t.get("Content-Disposition");if(e){let t=function(t){let e=!0,i=s("filename\\*","i").exec(t);if(i){let t=n(i=i[1]);return a(t=l(t=o(t=unescape(t))))}if(i=function(t){let e,i=[],r=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(e=r.exec(t));){let[,t,s,r]=e;if((t=parseInt(t,10))in i){if(0===t)break;continue}i[t]=[s,r]}let a=[];for(let t=0;t<i.length&&t in i;++t){let[e,s]=i[t];s=n(s),e&&(s=unescape(s),0===t&&(s=o(s))),a.push(s)}return a.join("")}(t))return a(l(i));if(i=s("filename","i").exec(t)){let t=n(i=i[1]);return a(t=l(t))}function s(t,e){return RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function r(t,i){if(t){if(!/^[\x00-\xFF]+$/.test(i))return i;try{let s=new TextDecoder(t,{fatal:!0}),r=R(i);i=s.decode(r),e=!1}catch{}}return i}function a(t){return e&&/[\x80-\xff]/.test(t)&&(t=r("utf-8",t),e&&(t=r("iso-8859-1",t))),t}function n(t){if(t.startsWith('"')){let e=t.slice(1).split('\\"');for(let t=0;t<e.length;++t){let i=e[t].indexOf('"');-1!==i&&(e[t]=e[t].slice(0,i),e.length=t+1),e[t]=e[t].replaceAll(/\\(.)/g,"$1")}t=e.join('"')}return t}function o(t){let e=t.indexOf("'");return -1===e?t:r(t.slice(0,e),t.slice(e+1).replace(/^[^']*'/,""))}function l(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(t,e,i,s){if("q"===i||"Q"===i)return r(e,s=(s=s.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,function(t,e){return String.fromCharCode(parseInt(e,16))}));try{s=atob(s)}catch{}return r(e,s)})}return""}(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch{}if(ti(t))return t}return null}function e9(t,e){return new B(`Unexpected server response (${t}) while retrieving PDF "${e.href}".`,t,404===t||0===t&&"file:"===e.protocol)}function it(t,e){if(t!==e)throw Error(`Expected range response-origin "${t}" to match "${e}".`)}function ie(t,e,i,s){return fetch(t,{method:"GET",headers:e,signal:s.signal,mode:"cors",credentials:i?"include":"same-origin",redirect:"follow"})}function ii(t,e){if(200!==t&&206!==t)throw e9(t,e)}function is(t){if(t instanceof Uint8Array)return t.buffer;if(t instanceof ArrayBuffer)return t;throw Error(`getArrayBuffer - unexpected data: ${t}`)}class ir extends e2{_responseOrigin=null;constructor(t){super(t,ia,io);const{httpHeaders:e,url:i}=t;C(/https?:/.test(i.protocol),"PDFFetchStream only supports http(s):// URLs."),this.headers=e6(!0,e)}}class ia extends e3{_abortController=new AbortController;_reader=null;constructor(t){super(t);const{disableRange:e,disableStream:i,rangeChunkSize:s,url:r,withCredentials:a}=t._source;this._isStreamingSupported=!i,ie(r,new Headers(t.headers),a,this._abortController).then(i=>{t._responseOrigin=e4(i.url),ii(i.status,r),this._reader=i.body.getReader();let a=i.headers,{contentLength:n,isRangeSupported:o}=e8({responseHeaders:a,isHttp:!0,rangeChunkSize:s,disableRange:e});this._contentLength=n,this._isRangeSupported=o,this._filename=e7(a),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new L("Streaming is disabled.")),this._headersCapability.resolve()}).catch(this._headersCapability.reject)}async read(){await this._headersCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this._callOnProgress(),{value:is(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class io extends e5{_abortController=new AbortController;_readCapability=Promise.withResolvers();_reader=null;constructor(t,e,i){super(t,e,i);const{url:s,withCredentials:r}=t._source,a=new Headers(t.headers);a.append("Range",`bytes=${e}-${i-1}`),ie(s,a,r,this._abortController).then(e=>{it(e4(e.url),t._responseOrigin),ii(e.status,s),this._reader=e.body.getReader(),this._readCapability.resolve()}).catch(this._readCapability.reject)}async read(){await this._readCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:{value:is(t),done:!1}}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}function il(t){return t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t).buffer}function ih(){for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}class id extends e2{_progressiveDone=!1;_queuedChunks=[];constructor(t){super(t,ic,iu);const{pdfDataRangeTransport:e}=t,{initialData:i,progressiveDone:s}=e;if(i?.length>0){const t=il(i);this._queuedChunks.push(t)}this._progressiveDone=s;const r=t=>{switch(t.type){case"range":case"progressiveRead":this.#sy(t.begin,t.chunk);break;case"progressiveDone":this._fullReader?.progressiveDone(),this._progressiveDone=!0}};e.transportReady(r)}#sy(t,e){let i=il(e);if(void 0===t)this._fullReader?this._fullReader._enqueue(i):this._queuedChunks.push(i);else{let e=this._rangeReaders.keys().find(e=>e._begin===t);C(e,"#onReceiveData - no `PDFDataTransportStreamRangeReader` instance found."),e._enqueue(i)}}getFullReader(){let t=super.getFullReader();return this._queuedChunks=null,t}getRangeReader(t,e){let i=super.getRangeReader(t,e);return i&&(i.onDone=()=>this._rangeReaders.delete(i),this._source.pdfDataRangeTransport.requestDataRange(t,e)),i}cancelAllRequests(t){super.cancelAllRequests(t),this._source.pdfDataRangeTransport.abort()}}class ic extends e3{#sv=ih.bind(this);_done=!1;_queuedChunks=null;_requests=[];constructor(t){super(t);const{pdfDataRangeTransport:e,disableRange:i,disableStream:s}=t._source,{length:r,contentDispositionFilename:a}=e;for(const e of(this._queuedChunks=t._queuedChunks||[],this._queuedChunks))this._loaded+=e.byteLength;this._done=t._progressiveDone,this._contentLength=r,this._isStreamingSupported=!s,this._isRangeSupported=!i,ti(a)&&(this._filename=a),this._headersCapability.resolve();const n=this._loaded;Promise.resolve().then(()=>{n>0&&this._loaded===n&&this._callOnProgress()})}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.byteLength,this._callOnProgress())}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this.#sv()}progressiveDone(){this._done||=!0,0===this._queuedChunks.length&&this.#sv()}}class iu extends e5{#sv=ih.bind(this);onDone=null;_begin=-1;_done=!1;_queuedChunk=null;_requests=[];constructor(t,e,i){super(t,e,i),this._begin=e}_enqueue(t){this._done||(0===this._requests.length?this._queuedChunk=t:(this._requests.shift().resolve({value:t,done:!1}),this.#sv()),this._done=!0,this.onDone?.())}async read(){if(this._queuedChunk){let t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this.#sv(),this.onDone?.()}}class ip extends e2{#sA=new WeakMap;_responseOrigin=null;constructor(t){super(t,ig,im);const{httpHeaders:e,url:i}=t;this.url=i,this.isHttp=/https?:/.test(i.protocol),this.headers=e6(this.isHttp,e)}_request(t){let e=new XMLHttpRequest,i={validateStatus:null,onHeadersReceived:t.onHeadersReceived,onDone:t.onDone,onError:t.onError,onProgress:t.onProgress};for(let[t,s]of(this.#sA.set(e,i),e.open("GET",this.url),e.withCredentials=this._source.withCredentials,this.headers))e.setRequestHeader(t,s);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),i.validateStatus=t=>206===t||200===t):i.validateStatus=t=>200===t,e.responseType="arraybuffer",C(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>t.onError(e.status),e.onreadystatechange=this.#sx.bind(this,e),e.onprogress=this.#sw.bind(this,e),e.send(null),e}#sw(t,e){let i=this.#sA.get(t);i?.onProgress?.(e)}#sx(t,e){var i;let s=this.#sA.get(t);if(!s||(t.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),4!==t.readyState||!this.#sA.has(t)))return;if(this.#sA.delete(t),0===t.status&&this.isHttp)return void s.onError(t.status);let r=t.status||200;if(!s.validateStatus(r))return void s.onError(t.status);let a="string"!=typeof(i=t.response)?i:R(i).buffer;if(206===r){let e=t.getResponseHeader("Content-Range");/bytes (\d+)-(\d+)\/(\d+)/.test(e)?s.onDone(a):(w('Missing or invalid "Content-Range" header.'),s.onError(0))}else a?s.onDone(a):s.onError(t.status)}_abortRequest(t){this.#sA.has(t)&&(this.#sA.delete(t),t.abort())}getRangeReader(t,e){let i=super.getRangeReader(t,e);return i&&(i.onClosed=()=>this._rangeReaders.delete(i)),i}}class ig extends e3{#sv=ih.bind(this);_cachedChunks=[];_done=!1;_requests=[];_storedError=null;constructor(t){super(t),this._fullRequestXhr=t._request({onHeadersReceived:this.#s_.bind(this),onDone:this.#sC.bind(this),onError:this.#sT.bind(this),onProgress:this.#sw.bind(this)})}#s_(){let t=this._stream,{disableRange:e,rangeChunkSize:i}=t._source,s=this._fullRequestXhr;t._responseOrigin=e4(s.responseURL);let r=s.getAllResponseHeaders(),a=new Headers(r?r.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(t=>{let[e,...i]=t.split(": ");return[e,i.join(": ")]}):[]),{contentLength:n,isRangeSupported:o}=e8({responseHeaders:a,isHttp:t.isHttp,rangeChunkSize:i,disableRange:e});this._contentLength=n,this._isRangeSupported=o,this._filename=e7(a),this._isRangeSupported&&t._abortRequest(s),this._headersCapability.resolve()}#sC(t){this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._cachedChunks.push(t),this._done=!0,0===this._cachedChunks.length&&this.#sv()}#sT(t){for(let e of(this._storedError=e9(t,this._stream.url),this._headersCapability.reject(this._storedError),this._requests))e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}#sw(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}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};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t),this.#sv(),this._stream._abortRequest(this._fullRequestXhr),this._fullRequestXhr=null}}class im extends e5{#sv=ih.bind(this);onClosed=null;_done=!1;_queuedChunk=null;_requests=[];_storedError=null;constructor(t,e,i){super(t,e,i),this._requestXhr=t._request({begin:e,end:i,onHeadersReceived:this.#s_.bind(this),onDone:this.#sC.bind(this),onError:this.#sT.bind(this),onProgress:null})}#s_(){let t=e4(this._requestXhr?.responseURL);try{it(t,this._stream._responseOrigin)}catch(t){this._storedError=t,this.#sT(0)}}#sC(t){this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunk=t,this._done=!0,this.#sv(),this.onClosed?.()}#sT(t){for(let e of(this._storedError??=e9(t,this._stream.url),this._requests))e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){let t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this.#sv(),this._stream._abortRequest(this._requestXhr),this.onClosed?.()}}function ib(t,e=null){let i=s.getBuiltinModule("fs"),{Readable:r}=s.getBuiltinModule("stream"),a=i.createReadStream(t,e);return r.toWeb(a)}class iy extends e2{constructor(t){super(t,iv,iA);const{url:e}=t;C("file:"===e.protocol,"PDFNodeStream only supports file:// URLs.")}}class iv extends e3{_reader=null;constructor(t){super(t);const{disableRange:e,disableStream:i,rangeChunkSize:r,url:a}=t._source;this._isStreamingSupported=!i,s.getBuiltinModule("fs/promises").lstat(a).then(t=>{let i=ib(a);this._reader=i.getReader();let{size:s}=t;this._contentLength=s,this._isRangeSupported=!e&&s>2*r,!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new L("Streaming is disabled.")),this._headersCapability.resolve()}).catch(t=>{"ENOENT"===t.code&&(t=e9(0,a)),this._headersCapability.reject(t)})}async read(){await this._headersCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this._callOnProgress(),{value:is(t),done:!1})}cancel(t){this._reader?.cancel(t)}}class iA extends e5{_readCapability=Promise.withResolvers();_reader=null;constructor(t,e,i){super(t,e,i);const{url:s}=t._source;try{const t=ib(s,{start:e,end:i-1});this._reader=t.getReader(),this._readCapability.resolve()}catch(t){this._readCapability.reject(t)}}async read(){await this._readCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:{value:is(t),done:!1}}cancel(t){this._reader?.cancel(t)}}class ix{static #sS=null;static #sE="";static get workerPort(){return this.#sS}static set workerPort(t){if(!("u">typeof Worker&&t instanceof Worker)&&null!==t)throw Error("Invalid `workerPort` type.");this.#sS=t}static get workerSrc(){return this.#sE}static set workerSrc(t){if("string"!=typeof t)throw Error("Invalid `workerSrc` type.");this.#sE=t}}class iw{#sM;#sP;constructor({parsedData:t,rawData:e}){this.#sM=t,this.#sP=e}getRaw(){return this.#sP}get(t){return this.#sM.get(t)??null}[Symbol.iterator](){return this.#sM.entries()}}let i_=Symbol("INTERNAL");class iC{#sk=!1;#sD=!1;#sI=!1;#sB=!0;constructor(t,{name:e,intent:i,usage:s,rbGroups:r}){this.#sk=!!(2&t),this.#sD=!!(4&t),this.name=e,this.intent=i,this.usage=s,this.rbGroups=r}get visible(){if(this.#sI)return this.#sB;if(!this.#sB)return!1;let{print:t,view:e}=this.usage;return this.#sk?e?.viewState!=="OFF":!this.#sD||t?.printState!=="OFF"}_setVisible(t,e,i=!1){t!==i_&&_("Internal method `_setVisible` called."),this.#sI=i,this.#sB=e}}class iT{#sF=null;#sL=new Map;#sR=null;#sO=null;constructor(t,e=2){if(this.renderingIntent=e,this.name=null,this.creator=null,null===t)return;for(const i of(this.name=t.name,this.creator=t.creator,this.#sO=t.order,t.groups))this.#sL.set(i.id,new iC(e,i));if("OFF"===t.baseState)for(const t of this.#sL.values())t._setVisible(i_,!1);for(const e of t.on)this.#sL.get(e)._setVisible(i_,!0);for(const e of t.off)this.#sL.get(e)._setVisible(i_,!1);this.#sR=this.getHash()}#sN(t){let e=t.length;if(e<2)return!0;let i=t[0];for(let s=1;s<e;s++){let e,r=t[s];if(Array.isArray(r))e=this.#sN(r);else{if(!this.#sL.has(r))return w(`Optional content group not found: ${r}`),!0;e=this.#sL.get(r).visible}switch(i){case"And":if(!e)return!1;break;case"Or":if(e)return!0;break;case"Not":return!e;default:return!0}}return"And"===i}isVisible(t){if(0===this.#sL.size)return!0;if(!t)return x("Optional content group not defined."),!0;if("OCG"===t.type)return this.#sL.has(t.id)?this.#sL.get(t.id).visible:(w(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return this.#sN(t.expression);if(t.policy&&"AnyOn"!==t.policy){if("AllOn"===t.policy){for(let e of t.ids){if(!this.#sL.has(e)){w(`Optional content group not found: ${e}`);break}if(!this.#sL.get(e).visible)return!1}return!0}else if("AnyOff"===t.policy){for(let e of t.ids){if(!this.#sL.has(e))return w(`Optional content group not found: ${e}`),!0;if(!this.#sL.get(e).visible)return!0}return!1}else if("AllOff"===t.policy){for(let e of t.ids){if(!this.#sL.has(e)){w(`Optional content group not found: ${e}`);break}if(this.#sL.get(e).visible)return!1}return!0}}else{for(let e of t.ids){if(!this.#sL.has(e))return w(`Optional content group not found: ${e}`),!0;if(this.#sL.get(e).visible)return!0}return!1}return w(`Unknown optional content policy ${t.policy}.`),!0}return w(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,i=!0){let s=this.#sL.get(t);if(!s)return void w(`Optional content group not found: ${t}`);if(i&&e&&s.rbGroups.length)for(let e of s.rbGroups)for(let i of e)i!==t&&this.#sL.get(i)?._setVisible(i_,!1,!0);s._setVisible(i_,!!e,!0),this.#sF=null}setOCGState({state:t,preserveRB:e}){let i;for(let s of t){switch(s){case"ON":case"OFF":case"Toggle":i=s;continue}let t=this.#sL.get(s);if(t)switch(i){case"ON":this.setVisibility(s,!0,e);break;case"OFF":this.setVisibility(s,!1,e);break;case"Toggle":this.setVisibility(s,!t.visible,e)}}this.#sF=null}get hasInitialVisibility(){return null===this.#sR||this.getHash()===this.#sR}getOrder(){return this.#sL.size?this.#sO?this.#sO.slice():[...this.#sL.keys()]:null}getGroup(t){return this.#sL.get(t)||null}getHash(){if(null!==this.#sF)return this.#sF;let t=new tj;for(let[e,i]of this.#sL)t.update(`${e}:${i.visible}`);return this.#sF=t.hexdigest()}[Symbol.iterator](){return this.#sL.entries()}}class iS{#sU=null;#sH=null;#sz=0;#s$=null;#sG=null;get pagesNumber(){return this.#sz}set pagesNumber(t){this.#sz!==t&&(this.#sz=t,this.#sU=null,this.#sH=null)}#sj(){if(this.#sU)return;let t=this.#sz,e=this.#sU=new Uint32Array(t);for(let i=0;i<t;i++)e[i]=i+1;this.#sH=new Int32Array(e)}#sV(){let t=new Map,e=this.#sU;for(let i=0,s=this.#sz;i<s;i++){let s=e[i],r=t.get(s);r?r.push(i+1):t.set(s,[i+1])}return t}movePages(t,e,i){this.#sj();let s=this.#sU,r=this.#sV(),a=e.length,n=new Uint32Array(a),o=0;for(let t=0;t<a;t++){let r=e[t]-1;n[t]=s[r],r<i&&o++}let l=this.#sz,h=l-a,d=X(i-o,0,h);for(let e=0,i=0;e<l;e++)t.has(e+1)||(s[i++]=s[e]);s.copyWithin(d+a,d,h),s.set(n,d),this.#sW(r),s.every((t,e)=>t===e+1)&&(this.#sU=null)}deletePages(t){this.#sj();let e=this.#sU,i=this.#sV();this.#sG={pageNumberToId:e.slice(),pagesNumber:this.#sz,prevPageNumbers:this.#sH.slice()};let s=this.#sz-t.length;this.#sz=s;let r=this.#sU=new Uint32Array(s);this.#sH=new Int32Array(s);let a=0,n=0;for(let i of t){let t=i-1;t!==a&&(r.set(e.subarray(a,t),n),n+=t-a),a=t+1}a<e.length&&r.set(e.subarray(a),n),this.#sW(i,new Set(t))}cancelDelete(){this.#sG&&(this.#sU=this.#sG.pageNumberToId,this.#sz=this.#sG.pagesNumber,this.#sH=this.#sG.prevPageNumbers,this.#sG=null)}cleanSavedData(){this.#sG=null}copyPages(t){this.#sj(),this.#s$={pageNumbers:t,pageIds:t.map(t=>this.#sU[t-1])}}cancelCopy(){this.#s$=null}pastePages(t){this.#sj();let e=this.#sU,i=this.#sV(),{pageNumbers:s,pageIds:r}=this.#s$,a=this.#sz+s.length;this.#sz=a;let n=this.#sU=new Uint32Array(a);this.#sH=new Int32Array(a),n.set(e.subarray(0,t),0),n.set(r,t),n.set(e.subarray(t),t+s.length),this.#sW(i,null,t,s),this.#s$=null}#sW(t,e=null,i=-1,s=null){let r=this.#sH,a=this.#sU,n=i+(s?.length??0),o=new Map;for(let l=0,h=this.#sz;l<h;l++){if(l>=i&&l<n){r[l]=-s[l-i];continue}let h=a[l],d=t.get(h),c=o.get(h)||0;if(e&&d)for(;c<d.length&&e.has(d[c]);)c++;r[l]=d?.[c],o.set(h,c+1)}}hasBeenAltered(){return null!==this.#sU}getPageMappingForSaving(t=null){t??=this.#sV();let e=0;for(let i of t.values())e=Math.max(e,i.length);let i=Array(e);for(let t=0;t<e;t++)i[t]={document:null,pageIndices:[],includePages:[]};for(let[e,s]of t)for(let t=0,r=s.length;t<r;t++)i[t].includePages.push([e-1,s[t]-1]);for(let{includePages:t,pageIndices:e}of i){t.sort((t,e)=>t[0]-e[0]);for(let i=0,s=t.length;i<s;i++)e.push(t[i][1]),t[i]=t[i][0]}return i}extractPages(t){t=Array.from(t).sort((t,e)=>t-e);let e=new Map;for(let i=0,s=t.length;i<s;i++){let s=this.getPageId(t[i]);e.getOrInsertComputed(s,j).push(i+1)}return this.getPageMappingForSaving(e)}getPrevPageNumber(t){return this.#sH?.[t-1]??0}getPageNumber(t){if(!this.#sU)return t;let e=this.#sU;for(let i=0,s=this.#sz;i<s;i++)if(e[i]===t)return i+1;return 0}getPageId(t){return this.#sU?.[t-1]??t}getMapping(){return this.#sU?.subarray(0,this.pagesNumber)}}let iE=Symbol("INITIAL_DATA"),iM=()=>({...Promise.withResolvers(),data:iE});class iP{#sX=new Map;get(t,e=null){if(e){let i=this.#sX.getOrInsertComputed(t,iM);return i.promise.then(()=>e(i.data)),null}let i=this.#sX.get(t);if(!i||i.data===iE)throw Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){let e=this.#sX.get(t);return!!e&&e.data!==iE}delete(t){let e=this.#sX.get(t);return!!e&&e.data!==iE&&(this.#sX.delete(t),!0)}resolve(t,e=null){let i=this.#sX.getOrInsertComputed(t,iM);if(i.data!==iE)throw Error(`Object already resolved ${t}.`);i.data=e,i.resolve()}clear(){for(let{data:t}of this.#sX.values())t?.bitmap?.close();this.#sX.clear()}*[Symbol.iterator](){for(let[t,{data:e}]of this.#sX)e!==iE&&(yield[t,e])}}class ik{#sq=Promise.withResolvers();#tE=null;#sK=!1;#sY=!!globalThis.FontInspector?.enabled;#sQ=null;#sJ=null;#sZ=null;#s0=0;#s1=0;#s2=null;#s3=null;#s5=0;#s6=0;#s4=Object.create(null);#s8=[];#s7=null;#s9=[];#rt=new WeakMap;#re=null;static #ri=new Map;static #rs=new Map;static #rr=new WeakMap;static #ra=null;static #rn=new Set;constructor({textContentSource:t,images:e,container:i,viewport:s}){if(t instanceof ReadableStream)this.#s7=t;else if("object"==typeof t)this.#s7=new ReadableStream({start(e){e.enqueue(t),e.close()}});else throw Error('No "textContentSource" parameter specified.');this.#tE=this.#s3=i,this.#sQ=e,this.#s6=s.scale*tf.pixelRatio,this.#s5=s.rotation,this.#sZ={div:null,properties:null,ctx:null};const{pageWidth:r,pageHeight:a,pageX:n,pageY:o}=s.rawDims;this.#re=[1,0,0,-1,-n,o+a],this.#s1=r,this.#s0=a,ik.#ro(),i.style.setProperty("--min-font-size",ik.#ra),tm(i,s),this.#sq.promise.finally(()=>{ik.#rn.delete(this),this.#sZ=null,this.#s4=null}).catch(()=>{})}static get fontFamilyMap(){let{isWindows:t,isFirefox:e}=O.platform;return M(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){this.#sQ&&this.#tE.append(this.#sQ.render());let t=()=>{this.#s2.read().then(({value:e,done:i})=>{i?this.#sq.resolve():(this.#sJ??=e.lang,Object.assign(this.#s4,e.styles),this.#rl(e.items),t())},this.#sq.reject)};return this.#s2=this.#s7.getReader(),ik.#rn.add(this),t(),this.#sq.promise}update({viewport:t,onBefore:e=null}){let i=t.scale*tf.pixelRatio,s=t.rotation;if(s!==this.#s5&&(e?.(),this.#s5=s,tm(this.#s3,{rotation:s})),i!==this.#s6){e?.(),this.#s6=i;let t={div:null,properties:null,ctx:ik.#rh(this.#sJ)};for(let e of this.#s9)t.properties=this.#rt.get(e),t.div=e,this.#rd(t)}}cancel(){let t=new L("TextLayer task cancelled.");this.#s2?.cancel(t).catch(()=>{}),this.#s2=null,this.#sq.reject(t)}get textDivs(){return this.#s9}get textContentItemsStr(){return this.#s8}#rl(t){if(this.#sK)return;this.#sZ.ctx??=ik.#rh(this.#sJ);let e=this.#s9,i=this.#s8;for(let s of t){if(e.length>1e5){w("Ignoring additional textDivs for performance reasons."),this.#sK=!0;return}if(void 0===s.str){if("beginMarkedContentProps"===s.type||"beginMarkedContent"===s.type){let t=this.#tE;this.#tE=document.createElement("span"),this.#tE.classList.add("markedContent"),s.id&&this.#tE.setAttribute("id",`${s.id}`),"Artifact"===s.tag&&(this.#tE.ariaHidden=!0),t.append(this.#tE)}else"endMarkedContent"===s.type&&(this.#tE=this.#tE.parentNode);continue}i.push(s.str),this.#rc(s)}}#rc(t){let e,i,s=document.createElement("span"),r={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};this.#s9.push(s);let a=N.transform(this.#re,t.transform),n=Math.atan2(a[1],a[0]),o=this.#s4[t.fontName];o.vertical&&(n+=Math.PI/2);let l=this.#sY&&o.fontSubstitution||o.fontFamily;l=ik.fontFamilyMap.get(l)||l;let h=Math.hypot(a[2],a[3]),d=h*ik.#ru(l,o,this.#sJ);0===n?(e=a[4],i=a[5]-d):(e=a[4]+d*Math.sin(n),i=a[5]-d*Math.cos(n));let c=s.style;c.left=`${(100*e/this.#s1).toFixed(2)}%`,c.top=`${(100*i/this.#s0).toFixed(2)}%`,c.setProperty("--font-height",`${h.toFixed(2)}px`),c.fontFamily=l,r.fontSize=h,s.setAttribute("role","presentation"),s.textContent=t.str,s.dir=t.dir,this.#sY&&(s.dataset.fontName=o.fontSubstitutionLoadedName||t.fontName),0!==n&&(r.angle=180/Math.PI*n);let u=!1;if(t.str.length>1)u=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){let e=Math.abs(t.transform[0]),i=Math.abs(t.transform[3]);e!==i&&Math.max(e,i)/Math.min(e,i)>1.5&&(u=!0)}if(u&&(r.canvasWidth=o.vertical?t.height:t.width),this.#rt.set(s,r),this.#sZ.div=s,this.#sZ.properties=r,this.#rd(this.#sZ),r.hasText&&this.#tE.append(s),r.hasEOL){let t=document.createElement("br");t.setAttribute("role","presentation"),this.#tE.append(t)}}#rd(t){let{div:e,properties:i,ctx:s}=t,{style:r}=e;if(0!==i.canvasWidth&&i.hasText){let{fontFamily:t}=r,{canvasWidth:a,fontSize:n}=i;ik.#rp(s,n*this.#s6,t);let{width:o}=s.measureText(e.textContent);o>0&&r.setProperty("--scale-x",a*this.#s6/o)}0!==i.angle&&r.setProperty("--rotate",`${i.angle}deg`)}static cleanup(){if(!(this.#rn.size>0)){for(let{canvas:t}of(this.#ri.clear(),this.#rs.values()))t.remove();this.#rs.clear()}}static #rh(t=null){let e=this.#rs.get(t||="");if(!e){let i=document.createElement("canvas");i.className="hiddenCanvasElement",i.lang=t,document.body.append(i),e=i.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#rs.set(t,e),this.#rr.set(e,{size:0,family:""})}return e}static #rp(t,e,i){let s=this.#rr.get(t);(e!==s.size||i!==s.family)&&(t.font=`${e}px ${i}`,s.size=e,s.family=i)}static #ro(){if(null!==this.#ra)return;let 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.#ra=t.getBoundingClientRect().height,t.remove()}static #ru(t,e,i){let s=this.#ri.get(t);if(s)return s;let r=this.#rh(i);r.canvas.width=r.canvas.height=30,this.#rp(r,30,t);let a=r.measureText(""),n=a.fontBoundingBoxAscent,o=Math.abs(a.fontBoundingBoxDescent);r.canvas.width=r.canvas.height=0;let l=.8;return n?l=n/(n+o):(O.platform.isFirefox&&w("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?l=e.ascent:e.descent&&(l=1+e.descent)),this.#ri.set(t,l),l}}function iD(t={}){"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});let e=new iI,{docId:i}=e,a=t.url?function(t){if(t instanceof URL)return t;if("string"==typeof t){if(n)return new URL(/^[a-z][a-z0-9\-+.]+:/i.test(t)?t:s.getBuiltinModule("url").pathToFileURL(t));let e=URL.parse(t,window.location);if(e)return e}throw Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(t.url):null,o=t.data?function(t){if(n&&void 0!==r&&t instanceof r)throw Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if("string"==typeof t)return R(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(t?.length))return new Uint8Array(t);throw Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(t.data):null,l=t.httpHeaders||null,h=!0===t.withCredentials,d=t.password??null,c=t.range instanceof iB?t.range:null,u=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:65536,p=t.worker instanceof iR?t.worker:null,g=t.verbosity,m="string"!=typeof t.docBaseUrl||te(t.docBaseUrl)?null:t.docBaseUrl,f=ep(t.cMapUrl),b=!1!==t.cMapPacked,y=ep(t.iccUrl),v=ep(t.standardFontDataUrl),x=ep(t.wasmUrl),w=!0!==t.stopAtErrors,_=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,C="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!n,T="boolean"==typeof t.isImageDecoderSupported?t.isImageDecoderSupported:!n&&(O.platform.isFirefox||!globalThis.chrome),S=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,E="boolean"==typeof t.disableFontFace?t.disableFontFace:n,M=!0===t.fontExtraProperties,P=!0===t.enableXfa,k=t.ownerDocument||globalThis.document,D=!0===t.disableRange,I=!0===t.disableStream,B=!0===t.disableAutoFetch,F=!0===t.pdfBug,L=t.CanvasFactory||(n?eM:e_),N=t.FilterFactory||(n?eE:eT),U=t.BinaryDataFactory||(n?eP:ex),H=!0===t.enableHWA,z=!0===t.enableWebGPU?eI.init():Promise.resolve(!1),$=!1!==t.useWasm,G=t.pagesMapper||new iS,j="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!n&&!E,V="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:!!(U===ex&&f&&b&&v&&x&&tn(f,document.baseURI)&&tn(v,document.baseURI)&&tn(x,document.baseURI));Number.isInteger(g)&&(A=g);let W={canvasFactory:new L({ownerDocument:k,enableHWA:H}),filterFactory:new N({docId:i,ownerDocument:k}),binaryDataFactory:V?null:new U({cMapUrl:f,standardFontDataUrl:v,wasmUrl:x})};p||(e._worker=p=iR.create({verbosity:g,port:ix.workerPort}));let X={docId:i,apiVersion:"5.7.284",data:o,password:d,disableAutoFetch:B,rangeChunkSize:u,docBaseUrl:m,enableXfa:P,evaluatorOptions:{maxImageSize:_,disableFontFace:E,ignoreErrors:w,isOffscreenCanvasSupported:C,isImageDecoderSupported:T,canvasMaxAreaInBytes:S,fontExtraProperties:M,useSystemFonts:j,useWasm:$,useWorkerFetch:V,cMapUrl:f,cMapPacked:b,iccUrl:y,standardFontDataUrl:v,wasmUrl:x,hasGPU:!1}},q={ownerDocument:k,pdfBug:F,styleElement:null,enableHWA:H,loadingParams:{disableAutoFetch:B,enableXfa:P}};return Promise.all([p.promise,z]).then(function([,t]){let s;if(e.destroyed)throw Error("Loading aborted");if(p.destroyed)throw Error("Worker was destroyed");X.evaluatorOptions.hasGPU=t;let r=p.messageHandler.sendWithPromise("GetDocRequest",X,o?[o.buffer]:null);if(o);else if(c)s=new id({pdfDataRangeTransport:c,disableRange:D,disableStream:I});else if(a)s=new(tn(a)?ir:n?iy:ip)({url:a,httpHeaders:l,withCredentials:h,rangeChunkSize:u,disableRange:D,disableStream:I});else throw Error("getDocument - expected either `data`, `range`, or `url` parameter.");return r.then(t=>{if(e.destroyed)throw Error("Loading aborted");if(p.destroyed)throw Error("Worker was destroyed");let r=new ev(i,t,p.port),a=new iO(r,e,s,q,W,G);e._transport=a,r.send("Ready",null)})}).catch(e._capability.reject),e}class iI{static #i5=0;_capability=Promise.withResolvers();_transport=null;_worker=null;docId=`d${iI.#i5++}`;destroyed=!1;onPassword=null;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}async getData(){return this._transport.getData()}}class iB{#sq=Promise.withResolvers();#rg=null;constructor(t,e,i=!1,s=null){this.length=t,this.initialData=e,this.progressiveDone=i,this.contentDispositionFilename=s,Object.defineProperty(this,"onDataProgress",{value:()=>{console.log("Deprecated API usage: `PDFDataRangeTransport.prototype.onDataProgress` - method was removed, since loading progress is now reported automatically through the `PDFDataTransportStream` class (and related code).")}})}onDataRange(t,e){this.#rg({type:"range",begin:t,chunk:e})}onDataProgressiveRead(t){this.#sq.promise.then(()=>{this.#rg({type:"progressiveRead",chunk:t})})}onDataProgressiveDone(){this.#sq.promise.then(()=>{this.#rg({type:"progressiveDone"})})}transportReady(t){this.#rg=t,this.#sq.resolve()}requestDataRange(t,e){_("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class iF{constructor(t,e){this._pdfInfo=t,this._transport=e}get pagesMapper(){return this._transport.pagesMapper}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 M(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()}getAnnotationsByType(t,e){return this._transport.getAnnotationsByType(t,e)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){let{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()}extractPages(t){return this._transport.extractPages(t)}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}getRawData(t){return this._transport.getRawData(t)}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 iL{#rm=!1;#rf=null;constructor(t,e,i,s,r=!1){this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=r?new ta:null,this._pdfBug=r,this.commonObjs=i.commonObjs,this.objs=new iP,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null,this.#rf=s,this.imageCoordinates=null}clone(t){let e=new iL(t,this._pageInfo,this._transport,this.#rf,this._pdfBug);return e.clonedFromIndex=this.clonedFromIndex??this._pageIndex,this._transport.updatePage(e),e}get pageNumber(){return this._pageIndex+1}set pageNumber(t){this._pageIndex=t-1,this._transport.updatePage(this)}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:r=!1}={}){return new Z({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:r})}getAnnotations({intent:t="display"}={}){let{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 M(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,canvas:e=t.canvas,viewport:i,intent:s="display",annotationMode:r=d.ENABLE,transform:a=null,background:n=null,optionalContentConfigPromise:o=null,annotationCanvasMap:l=null,pageColors:h=null,printAnnotationStorage:c=null,isEditing:u=!1,recordImages:p=!1,recordOperations:g=!1,operationsFilter:m=null}){this._stats?.time("Overall");let f=this._transport.getRenderingIntent(s,r,c,u),{renderingIntent:b,cacheKey:y}=f;this.#rm=!1,o||=this._transport.getOptionalContentConfig(b);let v=this._intentStates.getOrInsertComputed(y,W);v.streamReaderCancelTimeout&&(clearTimeout(v.streamReaderCancelTimeout),v.streamReaderCancelTimeout=null);let A=!!(4&b);v.displayReadyCapability||(v.displayReadyCapability=Promise.withResolvers(),v.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(f));let x=!!(this._pdfBug&&globalThis.StepperManager?.enabled),w=!!e&&!this.recordedBBoxes&&(g||x),_=!!e&&!this.imageCoordinates&&p,C=t=>{if(v.renderTasks.delete(E),w){let t=E.gfx?.dependencyTracker.take();t&&(E.stepper?.setOperatorBBoxes(t,E.gfx.dependencyTracker.takeDebugMetadata()),g&&(this.recordedBBoxes=t))}_&&!t&&(this.imageCoordinates=E.gfx?.imagesTracker.take()),A&&(this.#rm=!0),this.#rb(),t?(E.capability.reject(t),this._abortOperatorList({intentState:v,reason:t instanceof Error?t:Error(t)})):E.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},T=null,S=null;(w||_)&&(S=new t1(e,v.operatorList.length)),w&&(T=new t2(S,x));let E=new iU({callback:C,params:{canvas:e,canvasContext:t,dependencyTracker:T??S,imagesTracker:_?new ee(e):null,viewport:i,transform:a,background:n},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:l,operatorList:v.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!A,pdfBug:this._pdfBug,pageColors:h,enableHWA:this._transport.enableHWA,operationsFilter:m});(v.renderTasks||=new Set).add(E);let M=E.task;return Promise.all([v.displayReadyCapability.promise,o]).then(([t,e])=>{if(this.destroyed)return void C();if(this._stats?.time("Rendering"),!(e.renderingIntent&b))throw Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");E.initializeGraphics({transparency:t,optionalContentConfig:e}),E.operatorListChanged()}).catch(C),M}getOperatorList({intent:t="display",annotationMode:e=d.ENABLE,printAnnotationStorage:i=null,isEditing:s=!1}={}){let r,a=this._transport.getRenderingIntent(t,e,i,s,!0),n=this._intentStates.getOrInsertComputed(a.cacheKey,W);return n.opListReadCapability||((r=Object.create(null)).operatorListChanged=function(){n.operatorList.lastChunk&&(n.opListReadCapability.resolve(n.operatorList),n.renderTasks.delete(r))},n.opListReadCapability=Promise.withResolvers(),(n.renderTasks||=new Set).add(r),n.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(a)),n.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageId:this.#rf.getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}async getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(t=>q.textContent(t));let e=this.streamTextContent(t),i={items:[],styles:Object.create(null),lang:null};for await(let t of e)i.lang??=t.lang,Object.assign(i.styles,t.styles),i.items.push(...t.items);return i}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;let t=[];for(let e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(let i of e.renderTasks)t.push(i.completed),i.cancel();return this.objs.clear(),this.#rm=!1,Promise.all(t)}cleanup(t=!1){this.#rm=!0;let e=this.#rb();return t&&e&&(this._stats&&=new ta),e}#rb(){if(!this.#rm||this.destroyed)return!1;for(let{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#rm=!1,!0}_startRenderPage(t,e){let 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]);for(let i of(e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots,e.renderTasks))i.operatorListChanged();t.lastChunk&&this.#rb()}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:i,modifiedIds:s}){let{map:r,transfer:a}=i,n=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageId:this.#rf.getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:r,modifiedIds:s},void 0,a).getReader(),o=this._intentStates.get(e);o.streamReader=n;let l=()=>{n.read().then(({value:t,done:e})=>{if(e){o.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(t,o),l())},t=>{if(o.streamReader=null,!this._transport.destroyed){if(o.operatorList){for(let t of(o.operatorList.lastChunk=!0,o.renderTasks))t.operatorListChanged();this.#rb()}if(o.displayReadyCapability)o.displayReadyCapability.reject(t);else if(o.opListReadCapability)o.opListReadCapability.reject(t);else throw t}})};l()}_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 tt){let i=100;e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},i);return}}if(t.streamReader.cancel(new L(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(let[e,i]of this._intentStates)if(i===t){this._intentStates.delete(e);break}this.cleanup()}}}get stats(){return this._stats}}class iR{#sq=Promise.withResolvers();#ry=null;#sS=null;#rv=null;static #rA=0;static #rx=!1;static #rw=new WeakMap;static{n&&(this.#rx=!0,ix.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{let i=URL.parse(t);if(!i?.origin||"null"===i.origin)return!1;let s=new URL(e,i);return i.origin===s.origin},this._createCDNWrapper=t=>{let e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))}}constructor({name:t=null,port:e=null,verbosity:i=A}={}){if(this.name=t,this.destroyed=!1,this.verbosity=i,e){if(iR.#rw.has(e))throw Error("Cannot use more than one PDFWorker per port.");iR.#rw.set(e,this),this.#r_(e)}else this.#rC()}get promise(){return this.#sq.promise}#rT(){this.#sq.resolve(),this.#ry.send("configure",{verbosity:this.verbosity})}get port(){return this.#sS}get messageHandler(){return this.#ry}#r_(t){this.#sS=t,this.#ry=new ev("main","worker",t),this.#ry.on("ready",()=>{}),this.#rT()}#rC(){if(iR.#rx||iR.#rS)return void this.#rE();let{workerSrc:t}=iR;try{iR._isSameOrigin(window.location,t)||(t=iR._createCDNWrapper(new URL(t,window.location).href));let e=new Worker(t,{type:"module"}),i=new ev("main","worker",e),s=()=>{r.abort(),i.destroy(),e.terminate(),this.destroyed?this.#sq.reject(Error("Worker was destroyed")):this.#rE()},r=new AbortController;e.addEventListener("error",()=>{this.#rv||s()},{signal:r.signal}),i.on("test",t=>{(r.abort(),this.destroyed||!t)?s():(this.#ry=i,this.#sS=e,this.#rv=e,this.#rT())}),i.on("ready",t=>{if(r.abort(),this.destroyed)return void s();try{a()}catch{this.#rE()}});let a=()=>{let t=new Uint8Array;i.send("test",t,[t.buffer])};a();return}catch{x("The worker has been disabled.")}this.#rE()}#rE(){iR.#rx||(w("Setting up fake worker."),iR.#rx=!0),iR._setupFakeWorkerGlobal.then(t=>{if(this.destroyed)return void this.#sq.reject(Error("Worker was destroyed"));let e=new ef;this.#sS=e;let i=`fake${iR.#rA++}`,s=new ev(i+"_worker",i,e);t.setup(s,e),this.#ry=new ev(i,i+"_worker",e),this.#rT()}).catch(t=>{this.#sq.reject(Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){this.destroyed=!0,this.#rv?.terminate(),this.#rv=null,iR.#rw.delete(this.#sS),this.#sS=null,this.#ry?.destroy(),this.#ry=null}static create(t){let e=this.#rw.get(t?.port);if(e){if(e._pendingDestroy)throw Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new iR(t)}static get workerSrc(){if(ix.workerSrc)return ix.workerSrc;throw Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get #rS(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return M(this,"_setupFakeWorkerGlobal",(async()=>this.#rS?this.#rS:(await import(this.workerSrc)).WorkerMessageHandler)())}}class iO{downloadInfoCapability=Promise.withResolvers();#rM=null;#rP=new Map;#rk=null;#rD=new Map;#rI=new Map;#rB=new Map;#rF=null;constructor(t,e,i,s,r,a){this.messageHandler=t,this.loadingTask=e,this.#rk=i,this.commonObjs=new iP,this.fontLoader=new ei({ownerDocument:s.ownerDocument,styleElement:s.styleElement}),this.enableHWA=s.enableHWA,this.loadingParams=s.loadingParams,this._params=s,this.canvasFactory=r.canvasFactory,this.filterFactory=r.filterFactory,this.binaryDataFactory=r.binaryDataFactory,this.pagesMapper=a,this.destroyed=!1,this.destroyCapability=null,this.setupMessageHandler()}updatePage(t){let{_pageIndex:e}=t;this.#rD.set(e,t),this.#rI.set(e,Promise.resolve(t))}#rL(t,e=null){return this.#rP.getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,e))}#sw({loaded:t,total:e}){this.loadingTask.onProgress?.({loaded:t,total:e,percent:e?X(Math.round(t/e*100),0,100):NaN})}get annotationStorage(){return M(this,"annotationStorage",new tW)}getRenderingIntent(t,e=d.ENABLE,i=null,s=!1,r=!1){let a=2,n=tV;switch(t){case"any":a=1;break;case"display":break;case"print":a=4;break;default:w(`getRenderingIntent - invalid intent: ${t}`)}let o=4&a&&i instanceof tX?i:this.annotationStorage;switch(e){case d.DISABLE:a+=64;break;case d.ENABLE:break;case d.ENABLE_FORMS:a+=16;break;case d.ENABLE_STORAGE:a+=32,n=o.serializable;break;default:w(`getRenderingIntent - invalid annotationMode: ${e}`)}s&&(a+=128),r&&(a+=256);let{ids:l,hash:h}=o.modifiedIds,c=[a,n.hash,h];return{renderingIntent:a,cacheKey:c.join("_"),annotationStorageSerializable:n,modifiedIds:l}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#rF?.reject(Error("Worker was destroyed during onPassword callback"));let t=[];for(let e of this.#rD.values())t.push(e._destroy());this.#rD.clear(),this.#rI.clear(),this.#rB.clear(),Object.hasOwn(this,"annotationStorage")&&this.annotationStorage.resetModified();let e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#rP.clear(),this.filterFactory.destroy(),ik.cleanup(),this.#rk?.cancelAllRequests(new L("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){let{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(t,e)=>{C(this.#rk,"GetReader - no `BasePDFStream` instance available."),this.#rM=this.#rk.getFullReader(),this.#rM.onProgress=t=>this.#sw(t),e.onPull=()=>{this.#rM.read().then(function({value:t,done:i}){i?e.close():(C(t instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))}).catch(t=>{e.error(t)})},e.onCancel=t=>{this.#rM.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}}),t.on("ReaderHeadersReady",async t=>{await this.#rM.headersReady;let{isStreamingSupported:e,isRangeSupported:i,contentLength:s}=this.#rM;return e&&i&&(this.#rM.onProgress=null),{isStreamingSupported:e,isRangeSupported:i,contentLength:s}}),t.on("GetRangeReader",(t,e)=>{C(this.#rk,"GetRangeReader - no `BasePDFStream` instance available.");let i=this.#rk.getRangeReader(t.begin,t.end);i?(e.onPull=()=>{i.read().then(function({value:t,done:i}){i?e.close():(C(t instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))}).catch(t=>{e.error(t)})},e.onCancel=t=>{i.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}):e.close()}),t.on("GetDoc",({pdfInfo:t})=>{this.pagesMapper.pagesNumber=t.numPages,this._numPages=t.numPages,this._htmlForXfa=t.htmlForXfa,delete t.htmlForXfa,e._capability.resolve(new iF(t,this))}),t.on("DocException",t=>{e._capability.reject(ey(t))}),t.on("PasswordRequest",t=>{this.#rF=Promise.withResolvers();try{if(!e.onPassword)throw ey(t);let i=t=>{t instanceof Error?this.#rF.reject(t):this.#rF.resolve({password:t})};e.onPassword(i,t.code)}catch(t){this.#rF.reject(t)}return this.#rF.promise}),t.on("DataLoaded",t=>{this.#sw({loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)}),t.on("StartRenderPage",t=>{this.destroyed||this.#rD.get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)}),t.on("commonobj",([e,i,s])=>{if(this.destroyed||this.commonObjs.has(e))return null;switch(i){case"Font":if("error"in s){let t=s.error;w(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}let r=new es(new ed(s),this._params.pdfBug&&globalThis.FontInspector?.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,s.charProcOperatorList,s.extra);this.fontLoader.bind(r).catch(()=>t.sendWithPromise("FontFallback",{id:e})).finally(()=>{r.fontExtraProperties||r.clearData(),this.commonObjs.resolve(e,r)});break;case"CopyLocalImage":let{imageRef:a}=s;for(let t of(C(a,"The imageRef must be defined."),this.#rD.values()))for(let[,i]of t.objs){if(i?.ref!==a)continue;if(!i.dataLen)return null;let t=structuredClone(i);return this.commonObjs.resolve(e,t),i.dataLen}break;case"FontPath":this.commonObjs.resolve(e,new eu(s));break;case"Image":this.commonObjs.resolve(e,s);break;case"Pattern":let n=new ec(s);this.commonObjs.resolve(e,n.getIR());break;default:throw Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([t,e,i,s])=>{if(this.destroyed)return;let r=this.#rD.get(e);if(!r.objs.has(t)){if(0===r._intentStates.size)return void s?.bitmap?.close();switch(i){case"Image":case"Pattern":r.objs.resolve(t,s);break;default:throw Error(`Got unknown object type ${i}`)}}}),t.on("DocProgress",t=>{this.destroyed||this.#sw(t)}),t.on("FetchBinaryData",async t=>{if(this.destroyed)throw Error("Worker was destroyed.");if(!this.binaryDataFactory)throw Error("`BinaryDataFactory` not initialized, see the `useWorkerFetch` parameter.");return this.binaryDataFactory.fetch(t)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&w("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");let{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this.#rM?.filename??null},e).finally(()=>{this.annotationStorage.resetModified()})}extractPages(t){let e,i={pageInfos:t};if(this.annotationStorage.size>0){let{map:t,transfer:s}=this.annotationStorage.serializable;i.annotationStorage=t,e=s}return this.messageHandler.sendWithPromise("ExtractPages",i,e).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this.pagesMapper.pagesNumber)return Promise.reject(Error("Invalid page request."));let e=t-1,i=this.pagesMapper.getPageId(t)-1,s=this.#rI.get(e);if(s)return s;let r=this.messageHandler.sendWithPromise("GetPage",{pageIndex:i}).then(t=>{if(this.destroyed)throw Error("Transport destroyed");t.refStr&&this.#rB.set(t.refStr,i);let s=new iL(e,t,this,this.pagesMapper,this._params.pdfBug);return this.#rD.set(e,s),s});return this.#rI.set(e,r),r}async getPageIndex(t){if(!eg(t))throw Error("Invalid pageIndex request.");let e=await this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}),i=this.pagesMapper.getPageNumber(e+1);if(0===i)throw Error("GetPageIndex: page has been removed.");return i-1}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:this.pagesMapper.getPageId(t+1)-1,intent:e})}getFieldObjects(){return this.#rL("GetFieldObjects")}hasJSActions(){return this.#rL("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(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)}getAnnotationsByType(t,e){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:t,pageIndexesToSkip:e})}getDocJSActions(){return this.#rL("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:this.pagesMapper.getPageId(t+1)-1})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:this.pagesMapper.getPageId(t+1)-1})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#rL("GetOptionalContentConfig").then(e=>new iT(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){let t="GetMetadata";return this.#rP.getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,null).then(t=>({info:t[0],metadata:t[1]?new iw(t[1]):null,contentDispositionFilename:this.#rM?.filename??null,contentLength:this.#rM?.contentLength??null,hasStructTree:t[2]})))}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}getRawData(t){return this.messageHandler.sendWithPromise("GetRawData",t)}async startCleanup(t=!1){if(!this.destroyed){for(let t of(await this.messageHandler.sendWithPromise("Cleanup",null),this.#rD.values()))if(!t.cleanup())throw Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#rP.clear(),this.filterFactory.destroy(!0),ik.cleanup()}}cachedPageNumber(t){if(!eg(t))return null;let e=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`,i=this.#rB.get(e);if(i>=0){let t=this.pagesMapper.getPageNumber(i+1);if(0!==t)return t}return null}}class iN{_internalRenderTask=null;onContinue=null;onError=null;constructor(t){this._internalRenderTask=t}get promise(){return this._internalRenderTask.capability.promise}cancel(t=0){this._internalRenderTask.cancel(null,t)}get separateAnnots(){let{separateAnnots:t}=this._internalRenderTask.operatorList;if(!t)return!1;let{annotationCanvasMap:e}=this._internalRenderTask;return t.form||t.canvas&&e?.size>0}get imageCoordinates(){return this._internalRenderTask.imageCoordinates||null}}class iU{#rR=null;static #rO=new WeakSet;constructor({callback:t,params:e,objs:i,commonObjs:s,annotationCanvasMap:r,operatorList:a,pageIndex:n,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:h=!1,pdfBug:d=!1,pageColors:c=null,enableHWA:u=!1,operationsFilter:p=null}){this.callback=t,this.params=e,this.objs=i,this.commonObjs=s,this.annotationCanvasMap=r,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=n,this.canvasFactory=o,this.filterFactory=l,this._pdfBug=d,this.pageColors=c,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===h&&"u">typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new iN(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.canvas,this._canvasContext=e.canvas?null:e.canvasContext,this._enableHWA=u,this._dependencyTracker=e.dependencyTracker,this._imagesTracker=e.imagesTracker,this._operationsFilter=p}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(iU.#rO.has(this._canvas))throw Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");iU.#rO.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());let{viewport:i,transform:s,background:r,dependencyTracker:a,imagesTracker:n}=this.params,o=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new e1(o,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors,a,n),this.gfx.beginDrawing({transform:s,viewport:i,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.#rR&&(window.cancelAnimationFrame(this.#rR),this.#rR=null),iU.#rO.delete(this._canvas),t||=new tt(`Rendering cancelled, page ${this._pageIndex+1}`,e),this.callback(t),this.task.onError?.(t)}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}this.gfx.dependencyTracker?.growOperationsCount(this.operatorList.fnArray.length),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.#rR=window.requestAnimationFrame(()=>{this.#rR=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._operationsFilter),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),iU.#rO.delete(this._canvas),this.callback())))}}let iH="5.7.284",iz="7e5b36c2d";class i${#rN=null;#rU=null;#rH;#rz=null;#r$=!1;#rG=!1;#n=null;#rj;#rV=null;#y=null;static #rW=null;static get _keyboardManager(){return M(this,"_keyboardManager",new tR([[["Escape","mac+Escape"],i$.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],i$.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],i$.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],i$.prototype._moveToPrevious],[["Home","mac+Home"],i$.prototype._moveToBeginning],[["End","mac+End"],i$.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){t?(this.#rG=!1,this.#n=t):this.#rG=!0,this.#y=t?._uiManager||e,this.#rj=this.#y._eventBus,this.#rH=t?.color?.toUpperCase()||this.#y?.highlightColors.values().next().value||"#FFFF98",i$.#rW||=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(){let t=this.#rN=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",this.#n&&(t.ariaControls=`${this.#n.id}_colorpicker_dropdown`);let e=this.#y._signal;t.addEventListener("click",this.#rX.bind(this),{signal:e}),t.addEventListener("keydown",this.#rq.bind(this),{signal:e});let i=this.#rU=document.createElement("span");return i.className="swatch",i.ariaHidden="true",i.style.backgroundColor=this.#rH,t.append(i),t}renderMainDropdown(){let t=this.#rz=this.#rK();return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}#rK(){let t=document.createElement("div"),e=this.#y._signal;for(let[i,s]of(t.addEventListener("contextmenu",to,{signal:e}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),this.#n&&(t.id=`${this.#n.id}_colorpicker_dropdown`),this.#y.highlightColors)){let r=document.createElement("button");r.tabIndex="0",r.role="option",r.setAttribute("data-color",s),r.title=i,r.setAttribute("data-l10n-id",i$.#rW[i]);let a=document.createElement("span");r.append(a),a.className="swatch",a.style.backgroundColor=s,r.ariaSelected=s===this.#rH,r.addEventListener("click",this.#rY.bind(this,s),{signal:e}),t.append(r)}return t.addEventListener("keydown",this.#rq.bind(this),{signal:e}),t}#rY(t,e){e.stopPropagation(),this.#rj.dispatch("switchannotationeditorparams",{source:this,type:p.HIGHLIGHT_COLOR,value:t}),this.updateColor(t)}_colorSelectFromKeyboard(t){if(t.target===this.#rN)return void this.#rX(t);let e=t.target.getAttribute("data-color");e&&this.#rY(e,t)}_moveToNext(t){this.#rQ?t.target===this.#rN?this.#rz.firstElementChild?.focus():t.target.nextSibling?.focus():this.#rX(t)}_moveToPrevious(t){if(t.target===this.#rz?.firstElementChild||t.target===this.#rN){this.#rQ&&this._hideDropdownFromKeyboard();return}this.#rQ||this.#rX(t),t.target.previousSibling?.focus()}_moveToBeginning(t){this.#rQ?this.#rz.firstElementChild?.focus():this.#rX(t)}_moveToEnd(t){this.#rQ?this.#rz.lastElementChild?.focus():this.#rX(t)}#rq(t){i$._keyboardManager.exec(this,t)}#rX(t){if(this.#rQ)return void this.hideDropdown();if(this.#r$=0===t.detail,this.#rV||(this.#rV=new AbortController,window.addEventListener("pointerdown",this.#p.bind(this),{signal:this.#y.combinedSignal(this.#rV)})),this.#rN.ariaExpanded="true",this.#rz)return void this.#rz.classList.remove("hidden");let e=this.#rz=this.#rK();this.#rN.append(e)}#p(t){this.#rz?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#rz?.classList.add("hidden"),this.#rN.ariaExpanded="false",this.#rV?.abort(),this.#rV=null}get #rQ(){return this.#rz&&!this.#rz.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(!this.#rG){if(!this.#rQ)return void this.#n?.unselect();this.hideDropdown(),this.#rN.focus({preventScroll:!0,focusVisible:this.#r$})}}updateColor(t){if(this.#rU&&(this.#rU.style.backgroundColor=t),!this.#rz)return;let e=this.#y.highlightColors.values();for(let i of this.#rz.children)i.ariaSelected=e.next().value===t.toUpperCase()}destroy(){this.#rN?.remove(),this.#rN=null,this.#rU=null,this.#rz?.remove(),this.#rz=null}}class iG{#rJ=null;#rZ=!1;#n=null;#y=null;static #rW=null;constructor(t){this.#n=t,this.#y=t._uiManager,iG.#rW||=Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"})}renderButton(){if(this.#rJ)return this.#rJ;let{editorType:t,colorType:e,colorAndOpacityType:i,opacityType:s,color:r,opacity:a}=this.#n,n=this.#rZ=O.isAlphaColorInputSupported&&void 0!==s,o=this.#rJ=document.createElement("input");return o.type="color",n?(o.setAttribute("alpha",""),o.value=(r||"#000000")+N.hexNums[Math.round((a??1)*255)]):o.value=r||"#000000",o.className="basicColorPicker",o.tabIndex=0,o.setAttribute("data-l10n-id",iG.#rW[t]),o.addEventListener("input",()=>{if(n){let t=tc(o.value);if(!t)return;let[r,a,n,l]=t,h=N.makeHexColor(r,a,n);void 0!==i?this.#y.updateParams(i,{color:h,opacity:l}):(this.#y.updateParams(e,h),this.#y.updateParams(s,l))}else this.#y.updateParams(e,o.value)},{signal:this.#y._signal}),o}update(t){if(this.#rJ)if(this.#rZ){let e=N.hexNums[Math.round(255*this.#n.opacity)];this.#rJ.value=t+e}else this.#rJ.value=t}updateOpacity(t){if(!this.#rJ||!this.#rZ)return;let e=N.hexNums[Math.round(255*t)];this.#rJ.value=this.#n.color+e}destroy(){this.#rJ?.remove(),this.#rJ=null}hideDropdown(){}}function ij(t){return Math.floor(255*X(t,0,1)).toString(16).padStart(2,"0")}function iV(t){return 255*X(t,0,1)}class iW{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=iV(t),t,t]}static G_HTML([t]){let e=ij(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(iV)}static RGB_HTML(t){return`#${t.map(ij).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[iV(1-Math.min(1,t+s)),iV(1-Math.min(1,i+s)),iV(1-Math.min(1,e+s))]}static CMYK_HTML(t){let e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,i]){let s=1-t,r=1-e,a=1-i,n=Math.min(s,r,a);return["CMYK",s,r,a,n]}}class iX{create(t,e,i=!1){if(t<=0||e<=0)throw Error("Invalid SVG dimensions");let 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("string"!=typeof t)throw Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){_("Abstract method `_createSVG` called.")}}class iq extends iX{_createSVG(t){return document.createElementNS(Y,t)}}let iK=new WeakSet,iY=60*new Date().getTimezoneOffset()*1e3;class iQ{static create(t){switch(t.data.annotationType){case f.LINK:return new i0(t);case f.TEXT:return new i1(t);case f.WIDGET:switch(t.data.fieldType){case"Tx":return new i3(t);case"Btn":if(t.data.radioButton)return new i4(t);if(t.data.checkBox)return new i6(t);return new i8(t);case"Ch":return new i7(t);case"Sig":return new i5(t)}return new i2(t);case f.POPUP:return new i9(t);case f.FREETEXT:return new se(t);case f.LINE:return new si(t);case f.SQUARE:return new ss(t);case f.CIRCLE:return new sr(t);case f.POLYLINE:return new sa(t);case f.CARET:return new so(t);case f.INK:return new sl(t);case f.POLYGON:return new sn(t);case f.HIGHLIGHT:return new sh(t);case f.UNDERLINE:return new sd(t);case f.SQUIGGLY:return new sc(t);case f.STRIKEOUT:return new su(t);case f.STAMP:return new sp(t);case f.FILEATTACHMENT:return new sg(t);default:return new iJ(t)}}}class iJ{#r0=null;#r1=!1;#r2=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.enableComment=t.enableComment,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,this.hasOwnCommentButton=!1,e&&(this.contentElement=this.container=this._createContainer(i)),s&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:e}){return!!(t?.str||e?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return iJ._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){let{data:t}=this,e=this.annotationStorage?.getEditor(t.id);return e?e.getData():t}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){let t=this.annotationStorage?.getEditor(this.data.id);if(t)return t.commentButtonPositionInPage;let{quadPoints:e,inkLists:i,rect:s}=this.data,r=-1/0,a=-1/0;if(e?.length>=8){for(let t=0;t<e.length;t+=8)e[t+1]>a?(a=e[t+1],r=e[t+2]):e[t+1]===a&&(r=Math.max(r,e[t+2]));return[r,a]}if(i?.length>=1){for(let t of i)for(let e=0,i=t.length;e<i;e+=2)t[e+1]>a?(a=t[e+1],r=t[e]):t[e+1]===a&&(r=Math.max(r,t[e]));if(r!==1/0)return[r,a]}return s?[s[2],s[3]]:null}_normalizePoint(t){let{page:{view:e},viewport:{rawDims:{pageWidth:i,pageHeight:s,pageX:r,pageY:a}}}=this.parent;return t[1]=e[3]-t[1]+e[1],t[0]=100*(t[0]-r)/i,t[1]=100*(t[1]-a)/s,t}get commentText(){let{data:t}=this;return this.annotationStorage.getRawValue(`${c}${t.id}`)?.popup?.contents||t.contentsObj?.str||""}set commentText(t){let{data:e}=this,i={deleted:!t,contents:t||""};this.annotationStorage.updateEditor(e.id,{popup:i})||this.annotationStorage.setValue(`${c}${e.id}`,{id:e.id,annotationType:e.annotationType,page:this.parent.page,popup:i,popupRef:e.popupRef,modificationDate:new Date}),t||this.removePopup()}removePopup(){(this.#r2?.popup||this.popup)?.remove(),this.#r2=this.popup=null}updateEdited(t){if(!this.container)return;t.rect&&(this.#r0||={rect:this.data.rect.slice(0)});let{rect:e,popup:i}=t;e&&this.#r3(e);let s=this.#r2?.popup||this.popup;!s&&i?.text&&(this._createPopup(i),s=this.#r2.popup),s&&(s.updateEdited(t),i?.deleted&&(s.remove(),this.#r2=null,this.popup=null))}resetEdited(){this.#r0&&(this.#r3(this.#r0.rect),this.#r2?.popup.resetEdited(),this.#r0=null)}#r3(t){let{container:{style:e},data:{rect:i,rotation:s},parent:{viewport:{rawDims:{pageWidth:r,pageHeight:a,pageX:n,pageY:o}}}}=this;i?.splice(0,4,...t),e.left=`${100*(t[0]-n)/r}%`,e.top=`${100*(a-t[3]+o)/a}%`,0===s?(e.width=`${100*(t[2]-t[0])/r}%`,e.height=`${100*(t[3]-t[1])/a}%`):this.setRotation(s)}_createContainer(t){let{data:e,parent:{page:i,viewport:s}}=this,r=document.createElement("section");r.setAttribute("data-annotation-id",e.id),this instanceof i2||this instanceof i0||(r.tabIndex=0);let{style:a}=r;if(a.zIndex=this.parent.zIndex,this.parent.zIndex+=2,e.alternativeText&&(r.title=e.alternativeText),e.noRotate&&r.classList.add("norotate"),!e.rect||this instanceof i9){let{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,r),r}let{width:n,height:o}=this;if(!t&&e.borderStyle.width>0){a.borderWidth=`${e.borderStyle.width}px`;let t=e.borderStyle.horizontalCornerRadius,i=e.borderStyle.verticalCornerRadius;switch(t>0||i>0?a.borderRadius=`calc(${t}px * var(--total-scale-factor)) / calc(${i}px * var(--total-scale-factor))`:this instanceof i4&&(a.borderRadius=`calc(${n}px * var(--total-scale-factor)) / calc(${o}px * var(--total-scale-factor))`),e.borderStyle.style){case 1:a.borderStyle="solid";break;case 2:a.borderStyle="dashed";break;case 3:w("Unimplemented border style: beveled");break;case 4:w("Unimplemented border style: inset");break;case 5:a.borderBottomStyle="solid"}let s=e.borderColor||null;s?(this.#r1=!0,a.borderColor=N.makeHexColor(...s)):a.borderWidth=0}let l=N.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:h,pageHeight:d,pageX:c,pageY:u}=s.rawDims;a.left=`${100*(l[0]-c)/h}%`,a.top=`${100*(l[1]-u)/d}%`;let{rotation:p}=e;return e.hasOwnCanvas||0===p?(a.width=`${100*n/h}%`,a.height=`${100*o/d}%`):this.setRotation(p,r),r}setRotation(t,e=this.container){if(!this.data.rect)return;let{pageWidth:i,pageHeight:s}=this.parent.viewport.rawDims,{width:r,height:a}=this;t%180!=0&&([r,a]=[a,r]),e.style.width=`${100*r/i}%`,e.style.height=`${100*a/s}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){let t=(t,e,i)=>{let s=i.detail[t],r=s[0],a=s.slice(1);i.target.style[e]=iW[`${r}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[e]:iW[`${r}_rgb`](a)})};return M(this,"_commonActions",{display:t=>{let{display:e}=t.detail,i=e%2==1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:1===e||2===e})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{let{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout(()=>t.target.focus({preventScroll:!1}),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.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:t=>{let e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){let i=this._commonActions;for(let s of Object.keys(e.detail)){let r=t[s]||i[s];r?.(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;let e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;let i=this._commonActions;for(let[s,r]of Object.entries(e)){let a=i[s];a&&(a({detail:{[s]:r},target:t}),delete e[s])}}_createQuadrilaterals(){let t;if(!this.container)return;let{quadPoints:e}=this.data;if(!e)return;let[i,s,r,a]=this.data.rect.map(t=>Math.fround(t));if(8===e.length){let[t,n,o,l]=e.subarray(2,6);if(r===t&&a===n&&i===o&&s===l)return}let{style:n}=this.container;if(this.#r1){let{borderColor:e,borderWidth:i}=n;n.borderWidth=0,t=["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="${e}" stroke-width="${i}">`],this.container.classList.add("hasBorder")}let o=r-i,l=a-s,{svgFactory:h}=this,d=h.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0),d.role="none";let c=h.createElement("defs");d.append(c);let u=h.createElement("clipPath"),p=`clippath_${this.data.id}`;u.setAttribute("id",p),u.setAttribute("clipPathUnits","objectBoundingBox"),c.append(u);for(let s=2,r=e.length;s<r;s+=8){let r=e[s],n=e[s+1],d=e[s+2],c=e[s+3],p=h.createElement("rect"),g=(d-i)/o,m=(a-n)/l,f=(r-d)/o,b=(n-c)/l;p.setAttribute("x",g),p.setAttribute("y",m),p.setAttribute("width",f),p.setAttribute("height",b),u.append(p),t?.push(`<rect vector-effect="non-scaling-stroke" x="${g}" y="${m}" width="${f}" height="${b}"/>`)}this.#r1&&(t.push("</g></svg>')"),n.backgroundImage=t.join("")),this.container.append(d),this.container.style.clipPath=`url(#${p})`}_createPopup(t=null){let e,i,{data:s}=this;t?(e={str:t.text},i=t.date):(e=s.contentsObj,i=s.modificationDate),this.#r2=new i9({data:{color:s.color,titleObj:s.titleObj,modificationDate:i,contentsObj:e,richText:s.richText,parentRect:s.rect,borderStyle:0,id:`popup_${s.id}`,rotation:s.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]})}get hasPopupElement(){return!!(this.#r2||this.popup||this.data.popupRef)}get extraPopupElement(){return this.#r2}render(){_("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){let i=[];if(this._fieldObjects){let s=this._fieldObjects[t];if(s)for(let{page:t,id:r,exportValues:a}of s){if(-1===t||r===e)continue;let s="string"==typeof a?a:null,n=document.querySelector(`[data-element-id="${r}"]`);if(n&&!iK.has(n)){w(`_getElementsByName - element not allowed: ${r}`);continue}i.push({id:r,exportValue:s,domElement:n})}return i}for(let s of document.getElementsByName(t)){let{exportValue:t}=s,r=s.getAttribute("data-element-id");r!==e&&iK.has(s)&&i.push({id:r,exportValue:t,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(){let t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(let e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;let{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e,mustEnterInEditMode:!0})})}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}}class iZ extends iJ{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.editor=t.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){let{editor:t}=this;t.hasComment&&this._createPopup(t.comment)}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(t){this.editor.comment=t,t||this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.parent.removeAnnotation(this.data.id),this.container.remove(),this.container=null,this.removePopup()}}class i0 extends iJ{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){let{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,t.overlaidText),s=!0):t.attachment?(this.#r5(i,t.attachment,t.overlaidText,t.attachmentDest),s=!0):t.setOCGState?(this.#r6(i,t.setOCGState,t.overlaidText),s=!0):t.dest?(this._bindLink(i,t.dest,t.overlaidText),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.contentElement=i,this.container.append(i)),this.container}#r4(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e,i=""){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&this.#r4(),i&&(t.title=i)}_bindNamedAction(t,e,i=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),i&&(t.title=i),this.#r4()}#r5(t,e,i="",s=null){t.href=this.linkService.getAnchorUrl(""),e.description?t.title=e.description:i&&(t.title=i),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,s),!1),this.#r4()}#r6(t,e,i=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),i&&(t.title=i),this.#r4()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");let i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(let s of Object.keys(e.actions)){let r=i.get(s);r&&(t[r]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:s}}),!1))}e.overlaidText&&(t.title=e.overlaidText),t.onclick||(t.onclick=()=>!1),this.#r4()}_bindResetFormAction(t,e){let i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),this.#r4(),!this._fieldObjects){w('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(t.onclick=()=>!1);return}t.onclick=()=>{i?.();let{fields:t,refs:s,include:r}=e,a=[];if(0!==t.length||0!==s.length){let e=new Set(s);for(let i of t)for(let{id:t}of this._fieldObjects[i]||[])e.add(t);for(let t of Object.values(this._fieldObjects))for(let i of t)e.has(i.id)===r&&a.push(i)}else for(let t of Object.values(this._fieldObjects))a.push(...t);let n=this.annotationStorage,o=[];for(let t of a){let{id:e}=t;switch(o.push(e),t.type){case"text":{let i=t.defaultValue||"";n.setValue(e,{value:i});break}case"checkbox":case"radiobutton":{let i=t.defaultValue===t.exportValues;n.setValue(e,{value:i});break}case"combobox":case"listbox":{let i=t.defaultValue||"";n.setValue(e,{value:i});break}default:continue}let i=document.querySelector(`[data-element-id="${e}"]`);if(i){if(!iK.has(i)){w(`_bindResetFormAction - element not allowed: ${e}`);continue}i.dispatchEvent(new Event("resetform"))}}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:o,name:"ResetForm"}}),!1}}}class i1 extends iJ{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");let 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.hasOwnCommentButton=!0,this._createPopup()),this.container.append(t),this.container}}class i2 extends iJ{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&(t.previousSibling?.nodeName==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return O.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,i,s,r){i.includes("mouse")?t.addEventListener(i,t=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:r(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})}):t.addEventListener(i,t=>{if("blur"===i){if(!e.focused||!t.relatedTarget)return;e.focused=!1}else if("focus"===i){if(e.focused)return;e.focused=!0}r&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:r(t)}})})}_setEventListeners(t,e,i,s){for(let[r,a]of i)("Action"===a||this.data.actions?.[a])&&(("Focus"===a||"Blur"===a)&&(e||={focused:!1}),this._setEventListener(t,e,r,a,s),"Focus"!==a||this.data.actions?.Blur?"Blur"!==a||this.data.actions?.Focus||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null))}_setBackgroundColor(t){let e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":N.makeHexColor(...e)}_setTextStyle(t){let e,{fontColor:i}=this.data.defaultAppearanceData,s=this.data.defaultAppearanceData.fontSize||9,r=t.style,a=t=>Math.round(10*t)/10;if(this.data.multiLine){let t=Math.abs(this.data.rect[3]-this.data.rect[1]-2),i=Math.round(t/(1.35*s))||1;e=Math.min(s,a(t/i/1.35))}else e=Math.min(s,a(Math.abs(this.data.rect[3]-this.data.rect[1]-2)/1.35));r.fontSize=`calc(${e}px * var(--total-scale-factor))`,r.color=N.makeHexColor(...i),null!==this.data.textAlignment&&(r.textAlign=["left","center","right"][this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class i3 extends i2{constructor(t){const e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,i,s){let r=this.annotationStorage;for(let a of this._getElementsByName(t.name,t.id))a.domElement&&(a.domElement[e]=i),r.setValue(a.id,{[s]:i})}render(){let t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){let s=t.getValue(e,{value:this.data.fieldValue}),r=s.value||"",a=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;a&&r.length>a&&(r=r.slice(0,a));let n=s.formattedValue||this.data.textContent?.join("\n")||null;n&&this.data.comb&&(n=n.replaceAll(/\s+/g,""));let o={userValue:r,formattedValue:n,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?((i=document.createElement("textarea")).textContent=n??r,this.data.doNotScroll&&(i.style.overflowY="hidden")):((i=document.createElement("input")).type=this.data.password?"password":"text",i.setAttribute("value",n??r),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(i.hidden=!0),iK.add(i),this.contentElement=i,i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=0;let{datetimeFormat:l,datetimeType:h,timeStep:d}=this.data,c=!!h&&this.enableScripting;l&&(i.title=l),this._setRequired(i,this.data.required),a&&(i.maxLength=a),i.addEventListener("input",s=>{t.setValue(e,{value:s.target.value}),this.setPropertyOnSiblings(i,"value",s.target.value,"value"),o.formattedValue=null}),i.addEventListener("resetform",t=>{let e=this.data.defaultFieldValue??"";i.value=o.userValue=e,o.formattedValue=null});let u=t=>{let{formattedValue:e}=o;null!=e&&(t.target.value=e),t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){i.addEventListener("focus",t=>{if(o.focused)return;let{target:e}=t;if(c&&(e.type=h,d&&(e.step=d)),o.userValue){let t=o.userValue;if(c)if("time"===h){let i=new Date(t);e.value=[i.getHours(),i.getMinutes(),i.getSeconds()].map(t=>t.toString().padStart(2,"0")).join(":")}else e.value=new Date(t-iY).toISOString().split("date"===h?"T":".",1)[0];else e.value=t}o.lastCommittedValue=e.value,o.commitKey=1,this.data.actions?.Focus||(o.focused=!0)}),i.addEventListener("updatefromsandbox",i=>{this.showElementAndHideCanvas(i.target),this._dispatchEventFromSandbox({value(i){o.userValue=i.detail.value??"",c||t.setValue(e,{value:o.userValue.toString()}),i.target.value=o.userValue},formattedValue(i){let{formattedValue:s}=i.detail;o.formattedValue=s,null!=s&&i.target!==document.activeElement&&(i.target.value=s);let r={formattedValue:s};c&&(r.value=s),t.setValue(e,r)},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:i=>{let{charLimit:s}=i.detail,{target:r}=i;if(0===s)return void r.removeAttribute("maxLength");r.setAttribute("maxLength",s);let a=o.userValue;a&&!(a.length<=s)&&(r.value=o.userValue=a=a.slice(0,s),t.setValue(e,{value:a}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:a,willCommit:!0,commitKey:1,selStart:r.selectionStart,selEnd:r.selectionEnd}}))}},i)}),i.addEventListener("keydown",t=>{o.commitKey=1;let i=-1;if("Escape"===t.key?i=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(o.commitKey=3):i=2,-1===i)return;let{value:s}=t.target;o.lastCommittedValue!==s&&(o.lastCommittedValue=s,o.userValue=s,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:s,willCommit:!0,commitKey:i,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))});let s=u;u=null,i.addEventListener("blur",t=>{if(!o.focused||!t.relatedTarget)return;this.data.actions?.Blur||(o.focused=!1);let{target:i}=t,{value:r}=i;if(c){if(r&&"time"===h){let t=r.split(":").map(t=>parseInt(t,10));r=new Date(2e3,0,1,t[0],t[1],t[2]||0).valueOf(),i.step=""}else r.includes("T")||(r=`${r}T00:00`),r=new Date(r).valueOf();i.type="text"}o.userValue=r,o.lastCommittedValue!==r&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:r,willCommit:!0,commitKey:o.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}),s(t)}),this.data.actions?.Keystroke&&i.addEventListener("beforeinput",t=>{o.lastCommittedValue=null;let{data:i,target:s}=t,{value:r,selectionStart:a,selectionEnd:n}=s,l=a,h=n;switch(t.inputType){case"deleteWordBackward":{let t=r.substring(0,a).match(/\w*[^\w]*$/);t&&(l-=t[0].length);break}case"deleteWordForward":{let t=r.substring(a).match(/^[^\w]*\w*/);t&&(h+=t[0].length);break}case"deleteContentBackward":a===n&&(l-=1);break;case"deleteContentForward":a===n&&(h+=1)}t.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:r,change:i||"",willCommit:!1,selStart:l,selEnd:h}})}),this._setEventListeners(i,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.value)}if(u&&i.addEventListener("blur",u),this.data.comb){let t=(this.data.rect[2]-this.data.rect[0])/a;i.classList.add("comb"),i.style.letterSpacing=`calc(${t}px * var(--total-scale-factor) - 1ch)`}}else(i=document.createElement("div")).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 i5 extends i2{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class i6 extends i2{constructor(t){super(t,{isRenderable:t.renderForms})}render(){let t=this.annotationStorage,e=this.data,i=e.id,s=t.getValue(i,{value:e.exportValue===e.fieldValue}).value;"string"==typeof s&&(s="Off"!==s,t.setValue(i,{value:s})),this.container.classList.add("buttonWidgetAnnotation","checkBox");let r=document.createElement("input");return iK.add(r),r.setAttribute("data-element-id",i),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="checkbox",r.name=e.fieldName,s&&r.setAttribute("checked",!0),r.setAttribute("exportValue",e.exportValue),r.tabIndex=0,r.addEventListener("change",s=>{let{name:r,checked:a}=s.target;for(let s of this._getElementsByName(r,i)){let i=a&&s.exportValue===e.exportValue;s.domElement&&(s.domElement.checked=i),t.setValue(s.id,{value:i})}t.setValue(i,{value:a})}),r.addEventListener("resetform",t=>{let i=e.defaultFieldValue||"Off";t.target.checked=i===e.exportValue}),this.enableScripting&&this.hasJSActions&&(r.addEventListener("updatefromsandbox",e=>{this._dispatchEventFromSandbox({value(e){e.target.checked="Off"!==e.detail.value,t.setValue(i,{value:e.target.checked})}},e)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.checked)),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class i4 extends i2{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");let t=this.annotationStorage,e=this.data,i=e.id,s=t.getValue(i,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof s&&(s=s!==e.buttonValue,t.setValue(i,{value:s})),s)for(let s of this._getElementsByName(e.fieldName,i))t.setValue(s.id,{value:!1});let r=document.createElement("input");if(iK.add(r),r.setAttribute("data-element-id",i),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="radio",r.name=e.fieldName,s&&r.setAttribute("checked",!0),r.tabIndex=0,r.addEventListener("change",e=>{let{name:s,checked:r}=e.target;for(let e of this._getElementsByName(s,i))t.setValue(e.id,{value:!1});t.setValue(i,{value:r})}),r.addEventListener("resetform",t=>{let i=e.defaultFieldValue;t.target.checked=null!=i&&i===e.buttonValue}),this.enableScripting&&this.hasJSActions){let s=e.buttonValue;r.addEventListener("updatefromsandbox",e=>{this._dispatchEventFromSandbox({value:e=>{let r=s===e.detail.value;for(let s of this._getElementsByName(e.target.name)){let e=r&&s.id===i;s.domElement&&(s.domElement.checked=e),t.setValue(s.id,{value:e})}}},e)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.checked)}return this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class i8 extends i0{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){let t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");let e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",t=>{this._dispatchEventFromSandbox({},t)})),t}}class i7 extends i2{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");let t=this.annotationStorage,e=this.data.id,i=t.getValue(e,{value:this.data.fieldValue}),s=document.createElement("select");iK.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=0;let r=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",t=>{let e=this.data.defaultFieldValue;for(let t of s.options)t.selected=t.value===e});let a=(t,e)=>{let i=e.replaceAll(" ","\xa0");t.textContent=i,i!==e&&t.setAttribute("display-value",e)};for(let t of this.data.options){let e=document.createElement("option");a(e,t.displayValue),e.value=t.exportValue,i.value.includes(t.exportValue)&&(e.setAttribute("selected",!0),r=!1),s.append(e)}let n=null;if(r){let t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),s.prepend(t),n=()=>{t.remove(),s.removeEventListener("input",n),n=null},s.addEventListener("input",n)}let o=t=>{let e=t?"value":"textContent",{options:i,multiple:r}=s;return r?Array.prototype.filter.call(i,t=>t.selected).map(t=>t[e]):-1===i.selectedIndex?null:i[i.selectedIndex][e]},l=o(!1),h=t=>{let e=t.target.options;return Array.prototype.map.call(e,t=>({displayValue:t.getAttribute("display-value")||t.textContent,exportValue:t.value}))};return this.enableScripting&&this.hasJSActions?(s.addEventListener("updatefromsandbox",i=>{this._dispatchEventFromSandbox({value(i){n?.();let r=i.detail.value,a=new Set(Array.isArray(r)?r:[r]);for(let t of s.options)t.selected=a.has(t.value);t.setValue(e,{value:o(!0)}),l=o(!1)},multipleSelection(t){s.multiple=!0},remove(i){let r=s.options,a=i.detail.remove;r[a].selected=!1,s.remove(a),r.length>0&&-1===Array.prototype.findIndex.call(r,t=>t.selected)&&(r[0].selected=!0),t.setValue(e,{value:o(!0),items:h(i)}),l=o(!1)},clear(i){for(;0!==s.length;)s.remove(0);t.setValue(e,{value:null,items:[]}),l=o(!1)},insert(i){let{index:r,displayValue:n,exportValue:d}=i.detail.insert,c=s.children[r],u=document.createElement("option");a(u,n),u.value=d,c?c.before(u):s.append(u),t.setValue(e,{value:o(!0),items:h(i)}),l=o(!1)},items(i){let{items:r}=i.detail;for(;0!==s.length;)s.remove(0);for(let t of r){let{displayValue:e,exportValue:i}=t,r=document.createElement("option");a(r,e),r.value=i,s.append(r)}s.options.length>0&&(s.options[0].selected=!0),t.setValue(e,{value:o(!0),items:h(i)}),l=o(!1)},indices(i){let s=new Set(i.detail.indices);for(let t of i.target.options)t.selected=s.has(t.index);t.setValue(e,{value:o(!0)}),l=o(!1)},editable(t){t.target.disabled=!t.detail.editable}},i)}),s.addEventListener("input",i=>{let s=o(!0),r=o(!1);t.setValue(e,{value:s}),i.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:l,change:r,changeEx:s,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"]],t=>t.target.value)):s.addEventListener("input",function(i){t.setValue(e,{value:o(!0)})}),this.data.combo&&this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class i9 extends iJ{constructor(t){const{data:e,elements:i,parent:s}=t,r=!!s._commentManager;if(super(t,{isRenderable:!r&&iJ._hasPopupData(e)}),this.elements=i,r&&iJ._hasPopupData(e)){const t=this.popup=this.#r8();for(const e of i)e.popup=t}else this.popup=null}#r8(){return new st({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,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,commentManager:this.parent._commentManager})}render(){let{container:t}=this;t.classList.add("popupAnnotation"),t.role="comment";let e=this.popup=this.#r8(),i=[];for(let t of this.elements)t.popup=e,t.container.ariaHasPopup="dialog",i.push(t.data.id),t.addHighlightArea();return this.container.setAttribute("aria-controls",i.map(t=>`${G}${t}`).join(",")),this.container}}class st{#V=null;#r7=this.#rq.bind(this);#r9=this.#at.bind(this);#ae=this.#ai.bind(this);#as=this.#ar.bind(this);#aa=null;#tE=null;#an=null;#ao=null;#al=null;#ah=null;#ad=null;#ac=!1;#au=null;#ap=null;#B=null;#ag=null;#am=null;#ed=null;#af=null;#en=null;#ab=null;#r0=null;#ay=!1;#av=null;#aA=null;constructor({container:t,color:e,elements:i,titleObj:s,modificationDate:r,contentsObj:a,richText:n,parent:o,rect:l,parentRect:h,open:d,commentManager:c=null}){this.#tE=t,this.#ab=s,this.#an=a,this.#en=n,this.#ah=o,this.#aa=e,this.#af=l,this.#ad=h,this.#al=i,this.#V=c,this.#av=i[0],this.#ao=th.toDateObject(r),this.trigger=i.flatMap(t=>t.getElementsToTriggerPopup()),!c&&(this.#ax(),this.#tE.hidden=!0,d&&this.#ar())}#ax(){if(this.#ap)return;this.#ap=new AbortController;let{signal:t}=this.#ap;for(let e of this.trigger)e.addEventListener("click",this.#as,{signal:t}),e.addEventListener("pointerenter",this.#ae,{signal:t}),e.addEventListener("pointerleave",this.#r9,{signal:t}),e.classList.add("popupTriggerArea");for(let e of this.#al)e.container?.addEventListener("keydown",this.#r7,{signal:t})}#aw(){let t=this.#al.find(t=>t.hasCommentButton);t&&(this.#am=t._normalizePoint(t.commentButtonPosition))}renderCommentButton(){if(this.#ag){this.#ag.parentNode||this.#av.container.after(this.#ag);return}if(this.#am||this.#aw(),!this.#am)return;let{signal:t}=this.#ap=new AbortController,e=this.#av.hasOwnCommentButton,i=()=>{this.#V.toggleCommentPopup(this,!0,void 0,!e)},s=()=>{this.#V.toggleCommentPopup(this,!1,!0,!e)},r=()=>{this.#V.toggleCommentPopup(this,!1,!1)};if(e)for(let e of(this.#ag=this.#av.container,this.trigger))e.ariaHasPopup="dialog",e.ariaControls="commentPopup",e.addEventListener("keydown",this.#r7,{signal:t}),e.addEventListener("click",i,{signal:t}),e.addEventListener("pointerenter",s,{signal:t}),e.addEventListener("pointerleave",r,{signal:t}),e.classList.add("popupTriggerArea");else{let e=this.#ag=document.createElement("button");e.className="annotationCommentButton";let a=this.#av.container;e.style.zIndex=parseInt(a.style.zIndex,10)+1,e.tabIndex=0,e.ariaHasPopup="dialog",e.ariaControls="commentPopup",e.setAttribute("data-l10n-id","pdfjs-show-comment-button"),this.#a_(),this.#aC(),e.addEventListener("keydown",this.#r7,{signal:t}),e.addEventListener("click",i,{signal:t}),e.addEventListener("pointerenter",s,{signal:t}),e.addEventListener("pointerleave",r,{signal:t}),a.after(e)}}#aC(){if(this.#av.extraPopupElement&&!this.#av.editor)return;this.#ag||this.renderCommentButton();let[t,e]=this.#am,{style:i}=this.#ag;i.left=`calc(${t}%)`,i.top=`calc(${e}% - var(--comment-button-dim))`}#a_(){this.#av.extraPopupElement||(this.#ag||this.renderCommentButton(),this.#ag.style.backgroundColor=this.commentButtonColor||"")}get commentButtonColor(){let{color:t,opacity:e}=this.#av.commentData;return t?this.#ah._commentManager.makeCommentColor(t,e):null}focusCommentButton(){setTimeout(()=>{this.#ag?.focus()},0)}getData(){let{richText:t,color:e,opacity:i,creationDate:s,modificationDate:r}=this.#av.commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:i,creationDate:s,modificationDate:r}}get elementBeforePopup(){return this.#ag}get comment(){return this.#aA||=this.#av.commentText,this.#aA}set comment(t){t!==this.comment&&(this.#av.commentText=this.#aA=t)}focus(){this.#av.container?.focus()}get parentBoundingClientRect(){return this.#av.layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){this.#ag&&(this.#ag.classList.toggle("selected",t),this.#ag.ariaExpanded=e)}setSelectedCommentButton(t){this.#ag.classList.toggle("selected",t)}get commentPopupPosition(){if(this.#ed)return this.#ed;let{x:t,y:e,height:i}=this.#ag.getBoundingClientRect(),{x:s,y:r,width:a,height:n}=this.#av.layer.getBoundingClientRect();return[(t-s)/a,(e+i-r)/n]}set commentPopupPosition(t){this.#ed=t}hasDefaultPopupPosition(){return null===this.#ed}get commentButtonPosition(){return this.#am}get commentButtonWidth(){return this.#ag.getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){let[e,i]=this.#ed||this.commentButtonPosition.map(t=>t/100),s=this.parentBoundingClientRect,{x:r,y:a,width:n,height:o}=s;this.#V.showDialog(null,this,r+e*n,a+i*o,{...t,parentDimensions:s})}render(){if(this.#au)return;let t=this.#au=document.createElement("div");if(t.className="popup",this.#aa){let e=t.style.outlineColor=N.makeHexColor(...this.#aa);t.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`}let e=document.createElement("span");if(e.className="header",this.#ab?.str){let t=document.createElement("span");t.className="title",e.append(t),{dir:t.dir,str:t.textContent}=this.#ab}if(t.append(e),this.#ao){let t=document.createElement("time");t.className="popupDate",t.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),t.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#ao.valueOf()})),t.dateTime=this.#ao.toISOString(),e.append(t)}tE({html:this.#aT||this.#an.str,dir:this.#an?.dir,className:"popupContent"},t),this.#tE.append(t)}get #aT(){let t=this.#en,e=this.#an;return t?.str&&(!e?.str||e.str===t.str)&&this.#en.html||null}get #aS(){return this.#aT?.attributes?.style?.fontSize||0}get #aE(){return this.#aT?.attributes?.style?.color||null}#aM(t){let e=[],i={style:{color:this.#aE,fontSize:this.#aS?`calc(${this.#aS}px * var(--total-scale-factor))`:""}};for(let s of t.split("\n"))e.push({name:"span",value:s,attributes:i});return{str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}}}#rq(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&this.#ac)&&this.#ar()}updateEdited({rect:t,popup:e,deleted:i}){if(this.#V){i?(this.remove(),this.#aA=null):e&&(e.deleted?this.remove():(this.#a_(),this.#aA=e.text)),t&&(this.#am=null,this.#aw(),this.#aC());return}i||e?.deleted?this.remove():(this.#ax(),this.#r0||={contentsObj:this.#an,richText:this.#en},t&&(this.#B=null),e&&e.text&&(this.#en=this.#aM(e.text),this.#ao=th.toDateObject(e.date),this.#an=null),this.#au?.remove(),this.#au=null)}resetEdited(){this.#r0&&({contentsObj:this.#an,richText:this.#en}=this.#r0,this.#r0=null,this.#au?.remove(),this.#au=null,this.#B=null)}remove(){if(this.#ap?.abort(),this.#ap=null,this.#au?.remove(),this.#au=null,this.#ay=!1,this.#ac=!1,this.#ag?.remove(),this.#ag=null,this.trigger)for(let t of this.trigger)t.classList.remove("popupTriggerArea")}#aP(){if(null!==this.#B)return;let{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:s,pageY:r}}}=this.#ah,a=!!this.#ad,n=a?this.#ad:this.#af;for(let t of this.#al)if(!n||null!==N.intersect(t.data.rect,n)){n=t.data.rect,a=!0;break}let o=N.normalizeRect([n[0],t[3]-n[1]+t[1],n[2],t[3]-n[3]+t[1]]),l=a?n[2]-n[0]+5:0,h=o[0]+l,d=o[1];this.#B=[100*(h-s)/e,100*(d-r)/i];let{style:c}=this.#tE;c.left=`${this.#B[0]}%`,c.top=`${this.#B[1]}%`}#ar(){this.#V?this.#V.toggleCommentPopup(this,!1):(this.#ac=!this.#ac,this.#ac?(this.#ai(),this.#tE.addEventListener("click",this.#as),this.#tE.addEventListener("keydown",this.#r7)):(this.#at(),this.#tE.removeEventListener("click",this.#as),this.#tE.removeEventListener("keydown",this.#r7)))}#ai(){this.#au||this.render(),this.isVisible?this.#ac&&this.#tE.classList.add("focused"):(this.#aP(),this.#tE.hidden=!1,this.#tE.style.zIndex=parseInt(this.#tE.style.zIndex,10)+1e3)}#at(){this.#tE.classList.remove("focused"),!this.#ac&&this.isVisible&&(this.#tE.hidden=!0,this.#tE.style.zIndex=parseInt(this.#tE.style.zIndex,10)-1e3)}forceHide(){this.#ay=this.isVisible,this.#ay&&(this.#tE.hidden=!0)}maybeShow(){this.#V||(this.#ax(),this.#ay&&(this.#au||this.#ai(),this.#ay=!1,this.#tE.hidden=!1))}get isVisible(){return!this.#V&&!1===this.#tE.hidden}}class se extends iJ{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=u.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){let t=this.contentElement=document.createElement("div");for(let e of(t.classList.add("annotationTextContent"),t.setAttribute("role","comment"),this.textContent)){let i=document.createElement("span");i.textContent=e,t.append(i)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}class si extends iJ{#ak=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");let{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),r=this.#ak=this.svgFactory.createElement("svg:line");return r.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),r.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),r.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),r.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),r.setAttribute("stroke-width",t.borderStyle.width||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!t.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#ak}addHighlightArea(){this.container.classList.add("highlightArea")}}class ss extends iJ{#aD=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");let{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),r=t.borderStyle.width,a=this.#aD=this.svgFactory.createElement("svg:rect");return a.setAttribute("x",r/2),a.setAttribute("y",r/2),a.setAttribute("width",e-r),a.setAttribute("height",i-r),a.setAttribute("stroke-width",r||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),s.append(a),this.container.append(s),!t.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#aD}addHighlightArea(){this.container.classList.add("highlightArea")}}class sr extends iJ{#aI=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");let{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),r=t.borderStyle.width,a=this.#aI=this.svgFactory.createElement("svg:ellipse");return a.setAttribute("cx",e/2),a.setAttribute("cy",i/2),a.setAttribute("rx",e/2-r/2),a.setAttribute("ry",i/2-r/2),a.setAttribute("stroke-width",r||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),s.append(a),this.container.append(s),!t.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#aI}addHighlightArea(){this.container.classList.add("highlightArea")}}class sa extends iJ{#aB=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);let{data:{rect:t,vertices:e,borderStyle:i,popupRef:s},width:r,height:a}=this;if(!e)return this.container;let n=this.svgFactory.create(r,a,!0),o=[];for(let i=0,s=e.length;i<s;i+=2){let s=e[i]-t[0],r=t[3]-e[i+1];o.push(`${s},${r}`)}o=o.join(" ");let l=this.#aB=this.svgFactory.createElement(this.svgElementName);return l.setAttribute("points",o),l.setAttribute("stroke-width",i.width||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),n.append(l),this.container.append(n),!s&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#aB}addHighlightArea(){this.container.classList.add("highlightArea")}}class sn extends sa{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class so extends iJ{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}}class sl extends iJ{#aF=null;#aL=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?u.HIGHLIGHT:u.INK}#aR(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);let{data:{rect:t,rotation:e,inkLists:i,borderStyle:s,popupRef:r}}=this,{transform:a,width:n,height:o}=this.#aR(e,t),l=this.svgFactory.create(n,o,!0),h=this.#aF=this.svgFactory.createElement("svg:g");l.append(h),h.setAttribute("stroke-width",s.width||1),h.setAttribute("stroke-linecap","round"),h.setAttribute("stroke-linejoin","round"),h.setAttribute("stroke-miterlimit",10),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),h.setAttribute("transform",a);for(let t=0,e=i.length;t<e;t++){let e=this.svgFactory.createElement(this.svgElementName);this.#aL.push(e),e.setAttribute("points",i[t].join(",")),h.append(e)}return!r&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(l),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);let{thickness:e,points:i,rect:s}=t,r=this.#aF;if(e>=0&&r.setAttribute("stroke-width",e||1),i)for(let t=0,e=this.#aL.length;t<e;t++)this.#aL[t].setAttribute("points",i[t].join(","));if(s){let{transform:t,width:e,height:i}=this.#aR(this.data.rotation,s);r.parentElement.setAttribute("viewBox",`0 0 ${e} ${i}`),r.setAttribute("transform",t)}}getElementsToTriggerPopup(){return this.#aL}addHighlightArea(){this.container.classList.add("highlightArea")}}class sh extends iJ{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=u.HIGHLIGHT}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),t){let e=document.createElement("mark");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class sd extends iJ{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("underlineAnnotation"),t){let e=document.createElement("u");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class sc extends iJ{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("squigglyAnnotation"),t){let e=document.createElement("u");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class su extends iJ{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("strikeoutAnnotation"),t){let e=document.createElement("s");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class sp extends iJ{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=u.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}class sg extends iJ{#aO=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(){let t;this.container.classList.add("fileAttachmentAnnotation");let{container:e,data:i}=this;i.hasAppearance||0===i.fillAlpha?t=document.createElement("div"):((t=document.createElement("img")).src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(i.name)?"paperclip":"pushpin"}.svg`,i.fillAlpha&&i.fillAlpha<1&&(t.style=`filter: opacity(${Math.round(100*i.fillAlpha)}%);`)),t.addEventListener("dblclick",this.#aN.bind(this)),this.#aO=t;let{isMac:s}=O.platform;return e.addEventListener("keydown",t=>{"Enter"===t.key&&(s?t.metaKey:t.ctrlKey)&&this.#aN()}),!i.popupRef&&this.hasPopupData?(this.hasOwnCommentButton=!0,this._createPopup()):t.classList.add("popupTriggerArea"),e.append(t),e}getElementsToTriggerPopup(){return this.#aO}addHighlightArea(){this.container.classList.add("highlightArea")}#aN(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class sm{#aU=null;#aH=null;#$=null;#az=new Map;#a$=null;#aG=null;#al=[];#aj=!1;zIndex=0;constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:s,page:r,viewport:a,structTreeLayer:n,commentManager:o,linkService:l,annotationStorage:h}){this.div=t,this.#aU=e,this.#aH=i,this.#a$=n||null,this.#aG=l||null,this.#$=h||new tW,this.page=r,this.viewport=a,this._annotationEditorUIManager=s,this._commentManager=o||null}hasEditableAnnotations(){return this.#az.size>0}async render(t){let{annotations:e}=t,i=this.div;tm(i,this.viewport);let s=new Map,r=[],a={data:null,layer:i,linkService:this.#aG,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new iq,annotationStorage:this.#$,enableComment:!0===t.enableComment,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(let t of e){if(t.noHTML)continue;let e=t.annotationType===f.POPUP;if(e){let e=s.get(t.id);if(!e)continue;if(!this._commentManager){r.push(t);continue}a.elements=e}else if(t.rect[2]===t.rect[0]||t.rect[3]===t.rect[1])continue;a.data=t;let i=iQ.create(a);if(!i.isRenderable)continue;!e&&(this.#al.push(i),t.popupRef&&s.getOrInsertComputed(t.popupRef,j).push(i));let n=i.render();t.hidden&&(n.style.visibility="hidden"),i._isEditable&&(this.#az.set(i.data.id,i),this._annotationEditorUIManager?.renderAnnotationElement(i))}for(let t of(await this.#aV(),r)){let e=a.elements=s.get(t.id);a.data=t;let i=iQ.create(a);if(!i.isRenderable)continue;let r=i.render();i.contentElement.id=`${G}${t.id}`,t.hidden&&(r.style.visibility="hidden"),e.at(-1).container.after(r)}this.#aW()}async #aV(){if(0===this.#al.length)return;this.div.replaceChildren();let t=[];if(!this.#aj)for(let{contentElement:e,data:{id:i}}of(this.#aj=!0,this.#al)){let s=e.id=`${G}${i}`;t.push(this.#a$?.getAriaAttributes(s).then(t=>{if(t)for(let[i,s]of t)e.setAttribute(i,s)}))}this.#al.sort(({data:{rect:[t,e,i,s]}},{data:{rect:[r,a,n,o]}})=>{if(t===i&&e===s)return 1;if(r===n&&a===o)return -1;let l=(e+s)/2,h=(a+o)/2;return l>=o&&h<=e?-1:h>=s&&l<=a?1:(t+i)/2-(r+n)/2});let e=document.createDocumentFragment();for(let t of this.#al)e.append(t.container),this._commentManager?(t.extraPopupElement?.popup||t.popup)?.renderCommentButton():t.extraPopupElement&&e.append(t.extraPopupElement.render());if(this.div.append(e),await Promise.all(t),this.#aU)for(let t of this.#al)this.#aU.addPointerInTextLayer(t.contentElement,!1)}async addLinkAnnotations(t){let e={data:null,layer:this.div,linkService:this.#aG,svgFactory:new iq,parent:this};for(let i of t){i.borderStyle||=sm._defaultBorderStyle,e.data=i;let t=iQ.create(e);t.isRenderable&&(t.render(),t.contentElement.id=`${G}${i.id}`,this.#al.push(t))}await this.#aV()}update({viewport:t}){let e=this.div;this.viewport=t,tm(e,{rotation:t.rotation}),this.#aW(),e.hidden=!1}#aW(){if(!this.#aH)return;let t=this.div;for(let[e,i]of this.#aH){let s=t.querySelector(`[data-annotation-id="${e}"]`);if(!s)continue;i.className="annotationContent";let{firstChild:r}=s;r?"CANVAS"===r.nodeName?r.replaceWith(i):r.classList.contains("annotationContent")?r.after(i):r.before(i):s.append(i);let a=this.#az.get(e);a&&(a._hasNoCanvas?(this._annotationEditorUIManager?.setMissingCanvas(e,s.id,i),a._hasNoCanvas=!1):a.canvas=i)}this.#aH.clear()}getEditableAnnotations(){return this.#az.values()}getEditableAnnotation(t){return this.#az.get(t)}addFakeAnnotation(t){let{div:e}=this,{id:i,rotation:s}=t,r=new iZ({data:{id:i,rect:t.getPDFRect(),rotation:s},editor:t,layer:e,parent:this,enableComment:!!this._commentManager,linkService:this.#aG,annotationStorage:this.#$});return r.render(),r.contentElement.id=`${G}${i}`,r.createOrUpdatePopup(),this.#al.push(r),r}removeAnnotation(t){let e=this.#al.findIndex(e=>e.data.id===t);if(e<0)return;let[i]=this.#al.splice(e,1);this.#aU?.removePointerInTextLayer(i.contentElement)}updateFakeAnnotations(t){if(0!==t.length){for(let e of t)e.updateFakeAnnotationElement(this);this.#aV()}}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}static get _defaultBorderStyle(){return M(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:1,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}}let sf=/\r\n?|\n/g;class sb extends t${#aX="";#aq=`${this.id}-editor`;#aK=null;#aS;_colorPicker=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){let t=sb.prototype,e=t=>t.isEmpty(),i=tN.TRANSLATE_SMALL,s=tN.TRANSLATE_BIG;return M(this,"_keyboardManager",new tR([[["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=u.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.color=t.color||sb._defaultColor||t$._defaultLineColor,this.#aS=t.fontSize||sb._defaultFontSize,this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-freetext-added-alert"),this.canAddComment=!1}static initialize(t,e){t$.initialize(t,e);let i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case p.FREETEXT_SIZE:sb._defaultFontSize=e;break;case p.FREETEXT_COLOR:sb._defaultColor=e}}updateParams(t,e){switch(t){case p.FREETEXT_SIZE:this.#aY(e);break;case p.FREETEXT_COLOR:this.#a_(e)}}static get defaultPropertiesToUpdate(){return[[p.FREETEXT_SIZE,sb._defaultFontSize],[p.FREETEXT_COLOR,sb._defaultColor||t$._defaultLineColor]]}get propertiesToUpdate(){return[[p.FREETEXT_SIZE,this.#aS],[p.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||=new iG(this),[["colorPicker",this._colorPicker]]}get colorType(){return p.FREETEXT_COLOR}#aY(t){let e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--total-scale-factor))`,this.translate(0,-(t-this.#aS)*this.parentScale),this.#aS=t,this.#aQ()},i=this.#aS;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:p.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}onUpdatedColor(){this.editorDiv.style.color=this.color,this._colorPicker?.update(this.color),super.onUpdatedColor()}#a_(t){let e=t=>{this.color=t,this.onUpdatedColor()},i=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:p.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){let t=this.parentScale;return[-sb._internalPadding*t,-(sb._internalPadding+this.#aS)*t]}rebuild(){!this.parent||(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#aK=new AbortController;let t=this._uiManager.combinedSignal(this.#aK);return 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}),!0}disableEditMode(){return!!super.disableEditMode()&&(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#aq),this._isDraggable=!0,this.#aK?.abort(),this.#aK=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0)}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()}#aJ(){let t=[];this.editorDiv.normalize();let e=null;for(let i of this.editorDiv.childNodes)(e?.nodeType!==Node.TEXT_NODE||"BR"!==i.nodeName)&&(t.push(sb.#aZ(i)),e=i);return t.join("\n")}#aQ(){let t,[e,i]=this.parentDimensions;if(this.isAttachedToDOM)t=this.div.getBoundingClientRect();else{let{currentLayer:e,div:i}=this,s=i.style.display,r=i.classList.contains("hidden");i.classList.remove("hidden"),i.style.display="hidden",e.div.append(this.div),t=i.getBoundingClientRect(),i.remove(),i.style.display=s,i.classList.toggle("hidden",r)}this.rotation%180==this.parentRotation%180?(this.width=t.width/e,this.height=t.height/i):(this.width=t.height/e,this.height=t.width/i),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let t=this.#aX,e=this.#aX=this.#aJ().trimEnd();if(t===e)return;let i=t=>{(this.#aX=t,t)?(this.#a0(),this._uiManager.rebuild(this),this.#aQ()):this.remove()};this.addCommands({cmd:()=>{i(e)},undo:()=>{i(t)},mustExec:!1}),this.#aQ()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){sb._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)}get canChangeContent(){return!0}render(){let t,e;if(this.div)return this.div;(this._isCopy||this.annotationElementId)&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#aq),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;let{style:i}=this.editorDiv;if(i.fontSize=`calc(${this.#aS}px * var(--total-scale-factor))`,i.color=this.color,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){let[i,s]=this.parentDimensions;if(this.annotationElementId){let r,a,{position:n}=this._initialData,[o,l]=this.getInitialTranslation();[o,l]=this.pageTranslationToScreen(o,l);let[h,d]=this.pageDimensions,[c,u]=this.pageTranslation;switch(this.rotation){case 0:r=t+(n[0]-c)/h,a=e+this.height-(n[1]-u)/d;break;case 90:r=t+(n[0]-c)/h,a=e-(n[1]-u)/d,[o,l]=[l,-o];break;case 180:r=t-this.width+(n[0]-c)/h,a=e-(n[1]-u)/d,[o,l]=[-o,-l];break;case 270:r=t+(n[0]-c-this.height*d)/h,a=e+(n[1]-u-this.width*h)/d,[o,l]=[-l,o]}this.setAt(r*i,a*s,o,l)}else this._moveAfterPaste(t,e);this.#a0(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static #aZ(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(sf,"")}editorDivPaste(t){let e=t.clipboardData||window.clipboardData,{types:i}=e;if(1===i.length&&"text/plain"===i[0])return;t.preventDefault();let s=sb.#a1(e.getData("text")||"").replaceAll(sf,"\n");if(!s)return;let r=window.getSelection();if(!r.rangeCount)return;this.editorDiv.normalize(),r.deleteFromDocument();let a=r.getRangeAt(0);if(!s.includes("\n")){a.insertNode(document.createTextNode(s)),this.editorDiv.normalize(),r.collapseToStart();return}let{startContainer:n,startOffset:o}=a,l=[],h=[];if(n.nodeType===Node.TEXT_NODE){let t=n.parentElement;if(h.push(n.nodeValue.slice(o).replaceAll(sf,"")),t!==this.editorDiv){let e=l;for(let i of this.editorDiv.childNodes){if(i===t){e=h;continue}e.push(sb.#aZ(i))}}l.push(n.nodeValue.slice(0,o).replaceAll(sf,""))}else if(n===this.editorDiv){let t=l,e=0;for(let i of this.editorDiv.childNodes)e++===o&&(t=h),t.push(sb.#aZ(i))}this.#aX=`${l.join("\n")}${s}${h.join("\n")}`,this.#a0();let d=new Range,c=Math.sumPrecise(l.map(t=>t.length));for(let{firstChild:t}of this.editorDiv.childNodes)if(t.nodeType===Node.TEXT_NODE){let e=t.nodeValue.length;if(c<=e){d.setStart(t,c),d.setEnd(t,c);break}c-=e}r.removeAllRanges(),r.addRange(d)}#a0(){if(this.editorDiv.replaceChildren(),this.#aX)for(let t of this.#aX.split("\n")){let e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#a2(){return this.#aX.replaceAll("\xa0"," ")}static #a1(t){return t.replaceAll(" ","\xa0")}get contentDiv(){return this.editorDiv}getPDFRect(){let t=sb._internalPadding*this.parentScale;return this.getRect(t,t)}static async deserialize(t,e,i){let s=null;if(t instanceof se){let{data:{defaultAppearanceData:{fontSize:e,fontColor:i},rect:r,rotation:a,id:n,popupRef:o,richText:l,contentsObj:h,creationDate:d,modificationDate:c},textContent:p,textPosition:g,parent:{page:{pageNumber:m}}}=t;if(!p||0===p.length)return null;s=t={annotationType:u.FREETEXT,color:Array.from(i),fontSize:e,value:p.join("\n"),position:g,pageIndex:m-1,rect:r.slice(0),rotation:a,annotationElementId:n,id:n,deleted:!1,popupRef:o,comment:h?.str||null,richText:l,creationDate:d,modificationDate:c}}let r=await super.deserialize(t,e,i);return r.#aS=t.fontSize,r.color=N.makeHexColor(...t.color),r.#aX=sb.#a1(t.value),r._initialData=s,t.comment&&r.setCommentData(t),r}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let e=t$._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),i=Object.assign(super.serialize(t),{color:e,fontSize:this.#aS,value:this.#a2()});return(this.addComment(i),t)?(i.isCopy=!0,i):this.annotationElementId&&!this.#a3(i)?null:(i.id=this.annotationElementId,i)}#a3(t){let{value:e,fontSize:i,color:s,pageIndex:r}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||t.value!==e||t.fontSize!==i||t.color.some((t,e)=>t!==s[e])||t.pageIndex!==r}renderAnnotationElement(t){let e=super.renderAnnotationElement(t);if(!e)return null;let{style:i}=e;for(let t of(i.fontSize=`calc(${this.#aS}px * var(--total-scale-factor))`,i.color=this.color,e.replaceChildren(),this.#aX.split("\n"))){let i=document.createElement("div");i.append(t?document.createTextNode(t):document.createElement("br")),e.append(i)}return t.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:this.#aX}}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class sy{static PRECISION=1e-4;toSVGPath(){_("Abstract method `toSVGPath` must be implemented.")}get box(){_("Abstract getter `box` must be implemented.")}serialize(t,e){_("Abstract method `serialize` must be implemented.")}static _rescale(t,e,i,s,r,a){a||=new Float32Array(t.length);for(let n=0,o=t.length;n<o;n+=2)a[n]=e+t[n]*s,a[n+1]=i+t[n+1]*r;return a}static _rescaleAndSwap(t,e,i,s,r,a){a||=new Float32Array(t.length);for(let n=0,o=t.length;n<o;n+=2)a[n]=e+t[n+1]*s,a[n+1]=i+t[n]*r;return a}static _translate(t,e,i,s){s||=new Float32Array(t.length);for(let r=0,a=t.length;r<a;r+=2)s[r]=e+t[r],s[r+1]=i+t[r+1];return s}static svgRound(t){return Math.round(1e4*t)}static _normalizePoint(t,e,i,s,r){switch(r){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,r,a){return[(t+5*i)/6,(e+5*s)/6,(5*i+r)/6,(5*s+a)/6,(i+r)/2,(s+a)/2]}}class sv{#a5;#a6=[];#a4;#a8;#a7=[];#a9=new Float32Array(18);#nt;#ne;#ni;#ns;#nr;#na;#nn=[];static #no=8;static #nl=2;static #nh=sv.#no+sv.#nl;constructor({x:t,y:e},i,s,r,a,n=0){this.#a5=i,this.#na=r*s,this.#a8=a,this.#a9.set([NaN,NaN,NaN,NaN,t,e],6),this.#a4=n,this.#ns=sv.#no*s,this.#ni=sv.#nh*s,this.#nr=s,this.#nn.push(t,e)}isEmpty(){return isNaN(this.#a9[8])}#nd(){let t=this.#a9.subarray(4,6),e=this.#a9.subarray(16,18),[i,s,r,a]=this.#a5;return[(this.#nt+(t[0]-e[0])/2-i)/r,(this.#ne+(t[1]-e[1])/2-s)/a,(this.#nt+(e[0]-t[0])/2-i)/r,(this.#ne+(e[1]-t[1])/2-s)/a]}add({x:t,y:e}){this.#nt=t,this.#ne=e;let[i,s,r,a]=this.#a5,[n,o,l,h]=this.#a9.subarray(8,12),d=t-l,c=e-h,u=Math.hypot(d,c);if(u<this.#ni)return!1;let p=u-this.#ns,g=p/u,m=g*d,f=g*c,b=n,y=o;n=l,o=h,l+=m,h+=f,this.#nn?.push(t,e);let v=-f/p*this.#na,A=m/p*this.#na;return(this.#a9.set(this.#a9.subarray(2,8),0),this.#a9.set([l+v,h+A],4),this.#a9.set(this.#a9.subarray(14,18),12),this.#a9.set([l-v,h-A],16),isNaN(this.#a9[6]))?(0===this.#a7.length&&(this.#a9.set([n+v,o+A],2),this.#a7.push(NaN,NaN,NaN,NaN,(n+v-i)/r,(o+A-s)/a),this.#a9.set([n-v,o-A],14),this.#a6.push(NaN,NaN,NaN,NaN,(n-v-i)/r,(o-A-s)/a)),this.#a9.set([b,y,n,o,l,h],6),!this.isEmpty()):((this.#a9.set([b,y,n,o,l,h],6),Math.abs(Math.atan2(y-o,b-n)-Math.atan2(f,m))<Math.PI/2)?([n,o,l,h]=this.#a9.subarray(2,6),this.#a7.push(NaN,NaN,NaN,NaN,((n+l)/2-i)/r,((o+h)/2-s)/a),[n,o,b,y]=this.#a9.subarray(14,18),this.#a6.push(NaN,NaN,NaN,NaN,((b+n)/2-i)/r,((y+o)/2-s)/a)):([b,y,n,o,l,h]=this.#a9.subarray(0,6),this.#a7.push(((b+5*n)/6-i)/r,((y+5*o)/6-s)/a,((5*n+l)/6-i)/r,((5*o+h)/6-s)/a,((n+l)/2-i)/r,((o+h)/2-s)/a),[l,h,n,o,b,y]=this.#a9.subarray(12,18),this.#a6.push(((b+5*n)/6-i)/r,((y+5*o)/6-s)/a,((5*n+l)/6-i)/r,((5*o+h)/6-s)/a,((n+l)/2-i)/r,((o+h)/2-s)/a)),!0)}toSVGPath(){if(this.isEmpty())return"";let t=this.#a7,e=this.#a6;if(isNaN(this.#a9[6])&&!this.isEmpty())return this.#nc();let i=[];i.push(`M${t[4]} ${t[5]}`);for(let e=6;e<t.length;e+=6)isNaN(t[e])?i.push(`L${t[e+4]} ${t[e+5]}`):i.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);this.#nu(i);for(let t=e.length-6;t>=6;t-=6)isNaN(e[t])?i.push(`L${e[t+4]} ${e[t+5]}`):i.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);return this.#np(i),i.join(" ")}#nc(){let[t,e,i,s]=this.#a5,[r,a,n,o]=this.#nd();return`M${(this.#a9[2]-t)/i} ${(this.#a9[3]-e)/s} L${(this.#a9[4]-t)/i} ${(this.#a9[5]-e)/s} L${r} ${a} L${n} ${o} L${(this.#a9[16]-t)/i} ${(this.#a9[17]-e)/s} L${(this.#a9[14]-t)/i} ${(this.#a9[15]-e)/s} Z`}#np(t){let e=this.#a6;t.push(`L${e[4]} ${e[5]} Z`)}#nu(t){let[e,i,s,r]=this.#a5,a=this.#a9.subarray(4,6),n=this.#a9.subarray(16,18),[o,l,h,d]=this.#nd();t.push(`L${(a[0]-e)/s} ${(a[1]-i)/r} L${o} ${l} L${h} ${d} L${(n[0]-e)/s} ${(n[1]-i)/r}`)}newFreeDrawOutline(t,e,i,s,r,a){return new sA(t,e,i,s,r,a)}getOutlines(){let t=this.#a7,e=this.#a6,i=this.#a9,[s,r,a,n]=this.#a5,o=new Float32Array((this.#nn?.length??0)+2);for(let t=0,e=o.length-2;t<e;t+=2)o[t]=(this.#nn[t]-s)/a,o[t+1]=(this.#nn[t+1]-r)/n;if(o[o.length-2]=(this.#nt-s)/a,o[o.length-1]=(this.#ne-r)/n,isNaN(i[6])&&!this.isEmpty())return this.#ng(o);let l=new Float32Array(this.#a7.length+24+this.#a6.length),h=t.length;for(let e=0;e<h;e+=2){if(isNaN(t[e])){l[e]=l[e+1]=NaN;continue}l[e]=t[e],l[e+1]=t[e+1]}h=this.#nm(l,h);for(let t=e.length-6;t>=6;t-=6)for(let i=0;i<6;i+=2){if(isNaN(e[t+i])){l[h]=l[h+1]=NaN,h+=2;continue}l[h]=e[t+i],l[h+1]=e[t+i+1],h+=2}return this.#nf(l,h),this.newFreeDrawOutline(l,o,this.#a5,this.#nr,this.#a4,this.#a8)}#ng(t){let e=this.#a9,[i,s,r,a]=this.#a5,[n,o,l,h]=this.#nd(),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-i)/r,(e[3]-s)/a,NaN,NaN,NaN,NaN,(e[4]-i)/r,(e[5]-s)/a,NaN,NaN,NaN,NaN,n,o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,(e[16]-i)/r,(e[17]-s)/a,NaN,NaN,NaN,NaN,(e[14]-i)/r,(e[15]-s)/a],0),this.newFreeDrawOutline(d,t,this.#a5,this.#nr,this.#a4,this.#a8)}#nf(t,e){let i=this.#a6;return t.set([NaN,NaN,NaN,NaN,i[4],i[5]],e),e+=6}#nm(t,e){let i=this.#a9.subarray(4,6),s=this.#a9.subarray(16,18),[r,a,n,o]=this.#a5,[l,h,d,c]=this.#nd();return t.set([NaN,NaN,NaN,NaN,(i[0]-r)/n,(i[1]-a)/o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,d,c,NaN,NaN,NaN,NaN,(s[0]-r)/n,(s[1]-a)/o],e),e+=24}}class sA extends sy{#a5;#nb=new Float32Array(4);#a4;#a8;#nn;#nr;#ny;constructor(t,e,i,s,r,a){super(),this.#ny=t,this.#nn=e,this.#a5=i,this.#nr=s,this.#a4=r,this.#a8=a,this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],this.#nv(a);const[n,o,l,h]=this.#nb;for(let e=0,i=t.length;e<i;e+=2)t[e]=(t[e]-n)/l,t[e+1]=(t[e+1]-o)/h;for(let t=0,i=e.length;t<i;t+=2)e[t]=(e[t]-n)/l,e[t+1]=(e[t+1]-o)/h}toSVGPath(){let t=[`M${this.#ny[4]} ${this.#ny[5]}`];for(let e=6,i=this.#ny.length;e<i;e+=6){if(isNaN(this.#ny[e])){t.push(`L${this.#ny[e+4]} ${this.#ny[e+5]}`);continue}t.push(`C${this.#ny[e]} ${this.#ny[e+1]} ${this.#ny[e+2]} ${this.#ny[e+3]} ${this.#ny[e+4]} ${this.#ny[e+5]}`)}return t.push("Z"),t.join(" ")}serialize([t,e,i,s],r){let a,n,o=i-t,l=s-e;switch(r){case 0:a=sy._rescale(this.#ny,t,s,o,-l),n=sy._rescale(this.#nn,t,s,o,-l);break;case 90:a=sy._rescaleAndSwap(this.#ny,t,e,o,l),n=sy._rescaleAndSwap(this.#nn,t,e,o,l);break;case 180:a=sy._rescale(this.#ny,i,e,-o,l),n=sy._rescale(this.#nn,i,e,-o,l);break;case 270:a=sy._rescaleAndSwap(this.#ny,i,s,-o,-l),n=sy._rescaleAndSwap(this.#nn,i,s,-o,-l)}return{outline:Array.from(a),points:[Array.from(n)]}}#nv(t){let e=this.#ny,i=e[4],s=e[5],r=[i,s,i,s],a=i,n=s,l=i,h=s,d=t?Math.max:Math.min,c=new Float32Array(4);for(let t=6,u=e.length;t<u;t+=6){let u=e[t+4],p=e[t+5];isNaN(e[t])?(N.pointBoundingBox(u,p,r),n>p?(a=u,n=p):n===p&&(a=d(a,u)),h<p?(l=u,h=p):h===p&&(l=d(l,u))):(c.set(o,0),N.bezierBoundingBox(i,s,...e.slice(t,t+6),c),N.rectBoundingBox(...c,r),n>c[1]?(a=c[0],n=c[1]):n===c[1]&&(a=d(a,c[0])),h<c[3]?(l=c[2],h=c[3]):h===c[3]&&(l=d(l,c[2]))),i=u,s=p}let u=this.#nb;u[0]=r[0]-this.#a4,u[1]=r[1]-this.#a4,u[2]=r[2]-r[0]+2*this.#a4,u[3]=r[3]-r[1]+2*this.#a4,this.firstPoint=[a,n],this.lastPoint=[l,h]}get box(){return this.#nb}newOutliner(t,e,i,s,r,a=0){return new sv(t,e,i,s,r,a)}getNewOutline(t,e){let[i,s,r,a]=this.#nb,[n,o,l,h]=this.#a5,d=r*l,c=a*h,u=i*l+n,p=s*h+o,g=this.newOutliner({x:this.#nn[0]*d+u,y:this.#nn[1]*c+p},this.#a5,this.#nr,t,this.#a8,e??this.#a4);for(let t=2;t<this.#nn.length;t+=2)g.add({x:this.#nn[t]*d+u,y:this.#nn[t+1]*c+p});return g.getOutlines()}}class sx{#a5;#nA;#nx;#nw=[];#n_=[];constructor(t,e=0,i=0,s=!0){const r=o.slice();for(const{x:i,y:s,width:a,height:n}of t){const t=1e-4*Math.floor((i-e)/1e-4),o=1e-4*Math.ceil((i+a+e)/1e-4),l=1e-4*Math.floor((s-e)/1e-4),h=1e-4*Math.ceil((s+n+e)/1e-4),d=[t,l,h,!0],c=[o,l,h,!1];this.#nw.push(d,c),N.rectBoundingBox(t,l,o,h,r)}const a=r[2]-r[0]+2*i,n=r[3]-r[1]+2*i,l=r[0]-i,h=r[1]-i;let d=s?-1/0:1/0,c=1/0;const u=this.#nw.at(s?-1:-2),p=[u[0],u[2]];for(const t of this.#nw){const[e,i,r,o]=t;!o&&s?i<c?(c=i,d=e):i===c&&(d=Math.max(d,e)):o&&!s&&(i<c?(c=i,d=e):i===c&&(d=Math.min(d,e))),t[0]=(e-l)/a,t[1]=(i-h)/n,t[2]=(r-h)/n}this.#a5=new Float32Array([l,h,a,n]),this.#nA=[d,c],this.#nx=p}getOutlines(){this.#nw.sort((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]);let t=[];for(let e of this.#nw)e[3]?(t.push(...this.#nC(e)),this.#nT(e)):(this.#nS(e),t.push(...this.#nC(e)));return this.#nE(t)}#nE(t){let e,i=[],s=new Set;for(let e of t){let[t,s,r]=e;i.push([t,s,e],[t,r,e])}i.sort((t,e)=>t[1]-e[1]||t[0]-e[0]);for(let t=0,e=i.length;t<e;t+=2){let e=i[t][2],r=i[t+1][2];e.push(r),r.push(e),s.add(e),s.add(r)}let r=[];for(;s.size>0;){let t=s.values().next().value,[i,a,n,o,l]=t;s.delete(t);let h=i,d=a;for(e=[i,n],r.push(e);;){let t;if(s.has(o))t=o;else if(s.has(l))t=l;else break;s.delete(t),[i,a,n,o,l]=t,h!==i&&(e.push(h,d,i,d===a?a:n),h=i),d=d===a?n:a}e.push(h,d)}return new sw(r,this.#a5,this.#nA,this.#nx)}#nM(t){let e=this.#n_,i=0,s=e.length-1;for(;i<=s;){let r=i+s>>1,a=e[r][0];if(a===t)return r;a<t?i=r+1:s=r-1}return s+1}#nT([,t,e]){let i=this.#nM(t);this.#n_.splice(i,0,[t,e])}#nS([,t,e]){let i=this.#nM(t);for(let s=i;s<this.#n_.length;s++){let[i,r]=this.#n_[s];if(i!==t)break;if(i===t&&r===e)return void this.#n_.splice(s,1)}for(let s=i-1;s>=0;s--){let[i,r]=this.#n_[s];if(i!==t)break;if(i===t&&r===e)return void this.#n_.splice(s,1)}}#nC(t){let[e,i,s]=t,r=[[e,i,s]],a=this.#nM(s);for(let t=0;t<a;t++){let[i,s]=this.#n_[t];for(let t=0,a=r.length;t<a;t++){let[,n,o]=r[t];if(!(s<=n)&&!(o<=i)){if(n>=i){if(o>s)r[t][1]=s;else{if(1===a)return[];r.splice(t,1),t--,a--}continue}r[t][2]=i,o>s&&r.push([e,s,o])}}}return r}}class sw extends sy{#a5;#nP;constructor(t,e,i,s){super(),this.#nP=t,this.#a5=e,this.firstPoint=i,this.lastPoint=s}toSVGPath(){let t=[];for(let e of this.#nP){let[i,s]=e;t.push(`M${i} ${s}`);for(let r=2;r<e.length;r+=2){let a=e[r],n=e[r+1];a===i?(t.push(`V${n}`),s=n):n===s&&(t.push(`H${a}`),i=a)}t.push("Z")}return t.join(" ")}serialize([t,e,i,s],r){let a=[],n=i-t,o=s-e;for(let e of this.#nP){let i=Array(e.length);for(let r=0;r<e.length;r+=2)i[r]=t+e[r]*n,i[r+1]=s-e[r+1]*o;a.push(i)}return a}get box(){return this.#a5}get classNamesForOutlining(){return["highlightOutline"]}}class s_ extends sv{newFreeDrawOutline(t,e,i,s,r,a){return new sC(t,e,i,s,r,a)}}class sC extends sA{newOutliner(t,e,i,s,r,a=0){return new s_(t,e,i,s,r,a)}}class sT extends t${#nk=null;#nD=0;#nI;#nB=null;#a=null;#nF=null;#nL=null;#nR=0;#nO=null;#nN=null;#S=null;#nU=!1;#nA=null;#nx=null;#nH=null;#eo="";#na;#nz="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=u.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){let t=sT.prototype;return M(this,"_keyboardManager",new tR([[["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||sT._defaultColor,this.#na=t.thickness||sT._defaultThickness,this.opacity=t.opacity||sT._defaultOpacity,this.#nI=t.boxes||null,this.#nz=t.methodOfCreation||"",this.#eo=t.text||"",this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",t.highlightId>-1?(this.#nU=!0,this.#n$(t),this.#nG()):this.#nI&&(this.#nk=t.anchorNode,this.#nD=t.anchorOffset,this.#nL=t.focusNode,this.#nR=t.focusOffset,this.#nj(),this.#nG(),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}get telemetryInitialData(){return{action:"added",type:this.#nU?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:this.#na,methodOfCreation:this.#nz}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#nj(){let t=new sx(this.#nI,.001);this.#nN=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#nN.box;let e=new sx(this.#nI,.0025,.001,"ltr"===this._uiManager.direction);this.#nF=e.getOutlines();let{firstPoint:i}=this.#nN;this.#nA=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height];let{lastPoint:s}=this.#nF;this.#nx=[(s[0]-this.x)/this.width,(s[1]-this.y)/this.height]}#n$({highlightOutlines:t,highlightId:e,clipPathId:i}){if(this.#nN=t,this.#nF=t.getNewOutline(this.#na/2+1.5,.0025),e>=0)this.#S=e,this.#nB=i,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#nH=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#nF.box,path:{d:this.#nF.toSVGPath()}},!0);else if(this.parent){let e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#S,{bbox:sT.#nV(this.#nN.box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#nH,{bbox:sT.#nV(this.#nF.box,e),path:{d:this.#nF.toSVGPath()}})}let[s,r,a,n]=t.box;switch(this.rotation){case 0:this.x=s,this.y=r,this.width=a,this.height=n;break;case 90:{let[t,e]=this.parentDimensions;this.x=r,this.y=1-s,this.width=a*e/t,this.height=n*t/e;break}case 180:this.x=1-s,this.y=1-r,this.width=a,this.height=n;break;case 270:{let[t,e]=this.parentDimensions;this.x=1-r,this.y=s,this.width=a*e/t,this.height=n*t/e}}let{firstPoint:o}=t;this.#nA=[(o[0]-s)/a,(o[1]-r)/n];let{lastPoint:l}=this.#nF;this.#nx=[(l[0]-s)/a,(l[1]-r)/n]}static initialize(t,e){t$.initialize(t,e),sT._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case p.HIGHLIGHT_COLOR:sT._defaultColor=e;break;case p.HIGHLIGHT_THICKNESS:sT._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#nx}get commentButtonPosition(){return this.#nA}updateParams(t,e){switch(t){case p.HIGHLIGHT_COLOR:this.#a_(e);break;case p.HIGHLIGHT_THICKNESS:this.#nW(e)}}static get defaultPropertiesToUpdate(){return[[p.HIGHLIGHT_COLOR,sT._defaultColor],[p.HIGHLIGHT_THICKNESS,sT._defaultThickness]]}get propertiesToUpdate(){return[[p.HIGHLIGHT_COLOR,this.color||sT._defaultColor],[p.HIGHLIGHT_THICKNESS,this.#na||sT._defaultThickness],[p.HIGHLIGHT_FREE,this.#nU]]}onUpdatedColor(){this.parent?.drawLayer.updateProperties(this.#S,{root:{fill:this.color,"fill-opacity":this.opacity}}),this.#a?.updateColor(this.color),super.onUpdatedColor()}#a_(t){let e=(t,e)=>{this.color=t,this.opacity=e,this.onUpdatedColor()},i=this.color,s=this.opacity;this.addCommands({cmd:e.bind(this,t,sT._defaultOpacity),undo:e.bind(this,i,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:p.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(t)},!0)}#nW(t){let e=this.#na,i=t=>{this.#na=t,this.#nX(t)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:p.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",this.#a=new i$({editor:this})]]:super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#nq())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#nq())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#nK(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){!this.parent||(super.rebuild(),null!==this.div&&(this.#nG(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#nK():t&&(this.#nG(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#nX(t){this.#nU&&(this.#n$({highlightOutlines:this.#nN.getNewOutline(t/2)}),this.fixAndSetPosition(),this.setDims())}#nK(){null!==this.#S&&this.parent&&(this.parent.drawLayer.remove(this.#S),this.#S=null,this.parent.drawLayer.remove(this.#nH),this.#nH=null)}#nG(t=this.parent){null===this.#S&&({id:this.#S,clipPathId:this.#nB}=t.drawLayer.draw({bbox:this.#nN.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:this.#nU},path:{d:this.#nN.toSVGPath()}},!1,!0),this.#nH=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#nU},bbox:this.#nF.box,path:{d:this.#nF.toSVGPath()}},this.#nU),this.#nO&&(this.#nO.style.clipPath=this.#nB))}static #nV([t,e,i,s],r){switch(r){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){let e,{drawLayer:i}=this.parent;this.#nU?(t=(t-this.rotation+360)%360,e=sT.#nV(this.#nN.box,t)):e=sT.#nV([this.x,this.y,this.width,this.height],t),i.updateProperties(this.#S,{bbox:e,root:{"data-main-rotation":t}}),i.updateProperties(this.#nH,{bbox:sT.#nV(this.#nF.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;let t=super.render();this.#eo&&(t.setAttribute("aria-label",this.#eo),t.setAttribute("role","mark")),this.#nU?t.classList.add("free"):this.div.addEventListener("keydown",this.#nY.bind(this),{signal:this._uiManager._signal});let e=this.#nO=document.createElement("div");return t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#nB,this.setDims(),tD(this,this.#nO,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#nH,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#nH,{rootClass:{hovered:!1}})}#nY(t){sT._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#nQ(!0);break;case 1:case 3:this.#nQ(!1)}}#nQ(t){if(!this.#nk)return;let e=window.getSelection();t?e.setPosition(this.#nk,this.#nD):e.setPosition(this.#nL,this.#nR)}select(){super.select(),this.#nH&&this.parent?.drawLayer.updateProperties(this.#nH,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#nH&&(this.parent?.drawLayer.updateProperties(this.#nH,{rootClass:{selected:!1}}),this.#nU||this.#nQ(!1))}get _mustFixPosition(){return!this.#nU}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#S,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#nH,{rootClass:{hidden:!t}}))}#nq(){return this.#nU?this.rotation:0}#nJ(){if(this.#nU)return null;let[t,e]=this.pageDimensions,[i,s]=this.pageTranslation,r=this.#nI,a=new Float32Array(8*r.length),n=0;for(let{x:o,y:l,width:h,height:d}of r){let r=o*t+i,c=(1-l)*e+s;a[n]=a[n+4]=r,a[n+1]=a[n+3]=c,a[n+2]=a[n+6]=r+h*t,a[n+5]=a[n+7]=c-d*e,n+=8}return a}#nZ(t){return this.#nN.serialize(t,this.#nq())}static startHighlighting(t,e,{target:i,x:s,y:r}){let{x:a,y:n,width:o,height:l}=i.getBoundingClientRect(),h=new AbortController,d=t.combinedSignal(h),c=e=>{h.abort(),this.#n0(t,e)};window.addEventListener("blur",c,{signal:d}),window.addEventListener("pointerup",c,{signal:d}),window.addEventListener("pointerdown",tl,{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",to,{signal:d}),i.addEventListener("pointermove",this.#n1.bind(this,t),{signal:d}),this._freeHighlight=new s_({x:s,y:r},[a,n,o,l],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 #n1(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static #n0(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 sh){let{data:{quadPoints:e,rect:i,rotation:r,id:a,color:n,opacity:o,popupRef:l,richText:h,contentsObj:d,creationDate:c,modificationDate:p},parent:{page:{pageNumber:g}}}=t;s=t={annotationType:u.HIGHLIGHT,color:Array.from(n),opacity:o,quadPoints:e,boxes:null,pageIndex:g-1,rect:i.slice(0),rotation:r,annotationElementId:a,id:a,deleted:!1,popupRef:l,richText:h,comment:d?.str||null,creationDate:c,modificationDate:p}}else if(t instanceof sl){let{data:{inkLists:e,rect:i,rotation:r,id:a,color:n,borderStyle:{rawWidth:o},popupRef:l,richText:h,contentsObj:d,creationDate:c,modificationDate:p},parent:{page:{pageNumber:g}}}=t;s=t={annotationType:u.HIGHLIGHT,color:Array.from(n),thickness:o,inkLists:e,boxes:null,pageIndex:g-1,rect:i.slice(0),rotation:r,annotationElementId:a,id:a,deleted:!1,popupRef:l,richText:h,comment:d?.str||null,creationDate:c,modificationDate:p}}let{color:r,quadPoints:a,inkLists:n,outlines:o,opacity:l}=t,h=await super.deserialize(t,e,i);h.color=N.makeHexColor(...r),h.opacity=l||1,n&&(h.#na=t.thickness),h._initialData=s,t.comment&&h.setCommentData(t);let[d,c]=h.pageDimensions,[p,g]=h.pageTranslation;if(a){let t=h.#nI=[];for(let e=0;e<a.length;e+=8)t.push({x:(a[e]-p)/d,y:1-(a[e+1]-g)/c,width:(a[e+2]-a[e])/d,height:(a[e+1]-a[e+5])/c});h.#nj(),h.#nG(),h.rotate(h.rotation)}else if(n||o){h.#nU=!0;let t=(n||o.points)[0],i={x:t[0]-p,y:c-(t[1]-g)},s=new s_(i,[0,0,d,c],1,h.#na/2,!0,.001);for(let e=0,r=t.length;e<r;e+=2)i.x=t[e]-p,i.y=c-(t[e+1]-g),s.add(i);let{id:r,clipPathId:a}=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:s.toSVGPath()}},!0,!0);h.#n$({highlightOutlines:s.getOutlines(),highlightId:r,clipPathId:a}),h.#nG(),h.rotate(h.parentRotation)}return h}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();let e=t$._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),i=super.serialize(t);return(Object.assign(i,{color:e,opacity:this.opacity,thickness:this.#na,quadPoints:this.#nJ(),outlines:this.#nZ(i.rect)}),this.addComment(i),this.annotationElementId&&!this.#a3(i))?null:(i.id=this.annotationElementId,i)}#a3(t){let{color:e}=this._initialData;return this.hasEditedComment||t.color.some((t,i)=>t!==e[i])}renderAnnotationElement(t){return this.deleted?t.hide():t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null}static canCreateNewEmptyEditor(){return!1}}class sS{#n2=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(let[e,i]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,i)}updateSVGProperty(t,e){this.#n2[t]=e}toSVGProperties(){let t=this.#n2;return this.#n2=Object.create(null),{root:t}}reset(){this.#n2=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){_("Not implemented")}}class sE extends t${#n3=null;#n5;_colorPicker=null;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static #n6=null;static #n4=null;static #n8=null;static _INNER_MARGIN=3;constructor(t){super(t),this.#n5=t.mustBeCommitted||!1,this._addOutlines(t)}onUpdatedColor(){this._colorPicker?.update(this.color),super.onUpdatedColor()}onUpdatedOpacity(){this._colorPicker?.updateOpacity?.(this.opacity)}_addOutlines(t){t.drawOutlines&&(this.#n7(t),this.#nG())}#n7({drawOutlines:t,drawId:e,drawingOptions:i}){this.#n3=t,this._drawingOptions||=i,this.annotationElementId||this._uiManager.a11yAlert(`pdfjs-editor-${this.editorType}-added-alert`),e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#n9(t,this.parent),this.#ot(t.box)}#n9(t,e){let{id:i}=e.drawLayer.draw(sE._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return i}static _mergeSVGProperties(t,e){let i=new Set(Object.keys(t));for(let[s,r]of Object.entries(e))i.has(s)?Object.assign(t[s],r):t[s]=r;return t}static getDefaultDrawingOptions(t){_("Not implemented")}static get typesMap(){_("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){let i=this.typesMap.get(t);i&&this._defaultDrawingOptions.updateProperty(i,e),this._currentParent&&(sE.#n6.updateProperty(i,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){let i=this.constructor.typesMap.get(t);i&&this._updateProperty(t,i,e)}static get defaultPropertiesToUpdate(){let t=[],e=this._defaultDrawingOptions;for(let[i,s]of this.typesMap)t.push([i,e[s]]);return t}get propertiesToUpdate(){let t=[],{_drawingOptions:e}=this;for(let[i,s]of this.constructor.typesMap)t.push([i,e[s]]);return t}_updateProperty(t,e,i){let s=this._drawingOptions,r=s[e],a=i=>{s.updateProperty(e,i);let r=this.#n3.updateProperty(e,i);r&&this.#ot(r),this.parent?.drawLayer.updateProperties(this._drawId,s.toSVGProperties()),t===this.colorType?this.onUpdatedColor():t===this.opacityType&&this.onUpdatedOpacity()};this.addCommands({cmd:a.bind(this,i),undo:a.bind(this,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(t,e){let i=this.constructor.typesMap.get(this.colorType),s=this.constructor.typesMap.get(this.opacityType),r=this._drawingOptions,a=r[i],n=r[s],o=(t,e)=>{r.updateProperty(i,t),r.updateProperty(s,e),this.#n3.updateProperty(i,t),this.#n3.updateProperty(s,e),this.parent?.drawLayer.updateProperties(this._drawId,r.toSVGProperties()),this.onUpdatedColor(),this.onUpdatedOpacity()};this.addCommands({cmd:o.bind(this,t,e),undo:o.bind(this,a,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:p.INK_COLOR_AND_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,sE._mergeSVGProperties(this.#n3.getPathResizingSVGProperties(this.#oe()),{bbox:this.#oi()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,sE._mergeSVGProperties(this.#n3.getPathResizedSVGProperties(this.#oe()),{bbox:this.#oi()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#oi()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,sE._mergeSVGProperties(this.#n3.getPathTranslatedSVGProperties(this.#oe(),this.parentDimensions),{bbox:this.#oi()}))}_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.#n5&&(this.#n5=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#nK(),super.remove()}rebuild(){!this.parent||(super.rebuild(),null!==this.div&&(this.#nG(),this.#ot(this.#n3.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#nK()):t&&(this._uiManager.addShouldRescale(this),this.#nG(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#nK(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#nG(t=this.parent){if(null===this._drawId||this.parent!==t){if(null!==this._drawId)return void this.parent.drawLayer.updateParent(this._drawId,t.drawLayer);this._drawingOptions.updateAll(),this._drawId=this.#n9(this.#n3,t)}}#os([t,e,i,s]){let{parentDimensions:[r,a],rotation:n}=this;switch(n){case 90:return[e,1-t,a/r*i,r/a*s];case 180:return[1-t,1-e,i,s];case 270:return[1-e,t,a/r*i,r/a*s];default:return[t,e,i,s]}}#oe(){let{x:t,y:e,width:i,height:s,parentDimensions:[r,a],rotation:n}=this;switch(n){case 90:return[1-e,t,r/a*i,a/r*s];case 180:return[1-t,1-e,i,s];case 270:return[e,1-t,r/a*i,a/r*s];default:return[t,e,i,s]}}#ot(t){[this.x,this.y,this.width,this.height]=this.#os(t),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()}#oi(){let{x:t,y:e,width:i,height:s,rotation:r,parentRotation:a,parentDimensions:[n,o]}=this;switch((4*r+a)/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-n/o*i,o/n*s,n/o*i];case 5:return[1-e,t,n/o*i,o/n*s];case 6:return[1-t-o/n*s,1-e,o/n*s,n/o*i];case 7:return[e-n/o*i,1-t-o/n*s,n/o*i,o/n*s];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-o/n*s,e,o/n*s,n/o*i];case 13:return[1-e-n/o*i,t-o/n*s,n/o*i,o/n*s];case 14:return[1-t,1-e-n/o*i,o/n*s,n/o*i];case 15:return[e,1-t,n/o*i,o/n*s];default:return[t,e,i,s]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,sE._mergeSVGProperties({bbox:this.#oi()},this.#n3.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#ot(this.#n3.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){let t,e;if(this.div)return this.div;this._isCopy&&(t=this.x,e=this.y);let i=super.render();i.classList.add("draw");let s=document.createElement("div");return i.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(t,e),i}static createDrawerInstance(t,e,i,s,r){_("Not implemented")}static startDrawing(t,e,i,s){let{target:r,offsetX:a,offsetY:n,pointerId:o,pointerType:l}=s;if(tI.isInitializedAndDifferentPointerType(l))return;let{viewport:{rotation:h}}=t,{width:d,height:c}=r.getBoundingClientRect(),u=sE.#n4=new AbortController,p=t.combinedSignal(u);(tI.setPointer(l,o),window.addEventListener("pointerup",t=>{tI.isSamePointerIdOrRemove(t.pointerId)&&this._endDraw(t)},{signal:p}),window.addEventListener("pointercancel",t=>{tI.isSamePointerIdOrRemove(t.pointerId)&&this._currentParent.endDrawingSession()},{signal:p}),window.addEventListener("pointerdown",t=>{tI.isSamePointerType(t.pointerType)&&(tI.initializeAndAddPointerId(t.pointerId),sE.#n6.isCancellable()&&(sE.#n6.removeLastElement(),sE.#n6.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",to,{signal:p}),r.addEventListener("pointermove",this._drawMove.bind(this),{signal:p}),r.addEventListener("touchmove",t=>{tI.isSameTimeStamp(t.timeStamp)&&tl(t)},{signal:p}),t.toggleDrawing(),e._editorUndoBar?.hide(),sE.#n6)?t.drawLayer.updateProperties(this._currentDrawId,sE.#n6.startNew(a,n,d,c,h)):(e.updateUIForDefaultProperties(this),sE.#n6=this.createDrawerInstance(a,n,d,c,h),sE.#n8=this.getDefaultDrawingOptions(),this._currentParent=t,{id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(sE.#n8.toSVGProperties(),sE.#n6.defaultSVGProperties),!0,!1))}static _drawMove(t){if(tI.isSameTimeStamp(t.timeStamp),!sE.#n6)return;let{offsetX:e,offsetY:i,pointerId:s}=t;if(tI.isSamePointerId(s)){if(tI.isUsingMultiplePointers())return void this._endDraw(t);this._currentParent.drawLayer.updateProperties(this._currentDrawId,sE.#n6.add(e,i)),tI.setTimeStamp(t.timeStamp),tl(t)}}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,sE.#n6=null,sE.#n8=null,tI.clearTimeStamp()),sE.#n4&&(sE.#n4.abort(),sE.#n4=null,tI.clearPointerIds())}static _endDraw(t){let e=this._currentParent;if(e){if(e.toggleDrawing(!0),this._cleanup(!1),t?.target===e.div&&e.drawLayer.updateProperties(this._currentDrawId,sE.#n6.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){let t=sE.#n6,i=this._currentDrawId,s=t.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(i,t.setLastElement(s))},undo:()=>{e.drawLayer.updateProperties(i,t.removeLastElement())},mustExec:!1,type:p.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(t){let e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(p.DRAW_STEP),!sE.#n6.isEmpty()){let{pageDimensions:[i,s],scale:r}=e,a=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:sE.#n6.getOutlines(i*r,s*r,r,this._INNER_MARGIN),drawingOptions:sE.#n8,mustBeCommitted:!t});return this._cleanup(!0),a}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,i,s,r,a){_("Not implemented")}static async deserialize(t,e,i){let{rawDims:{pageWidth:s,pageHeight:r,pageX:a,pageY:n}}=e.viewport,o=this.deserializeDraw(a,n,s,r,this._INNER_MARGIN,t),l=await super.deserialize(t,e,i);return l.createDrawingOptions(t),l.#n7({drawOutlines:o}),l.#nG(),l.onScaleChanging(),l.rotate(),l}serializeDraw(t){let[e,i]=this.pageTranslation,[s,r]=this.pageDimensions;return this.#n3.serialize([e,i,s,r],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}}class sM{#a9=new Float64Array(6);#ak;#or;#s5;#na;#nn;#oa="";#on=0;#nP=new sP;#oo;#ol;constructor(t,e,i,s,r,a){this.#oo=i,this.#ol=s,this.#s5=r,this.#na=a,[t,e]=this.#oh(t,e);const n=this.#ak=[NaN,NaN,NaN,NaN,t,e];this.#nn=[t,e],this.#or=[{line:n,points:this.#nn}],this.#a9.set(n,0)}updateProperty(t,e){"stroke-width"===t&&(this.#na=e)}#oh(t,e){return sy._normalizePoint(t,e,this.#oo,this.#ol,this.#s5)}isEmpty(){return!this.#or||0===this.#or.length}isCancellable(){return this.#nn.length<=10}add(t,e){[t,e]=this.#oh(t,e);let[i,s,r,a]=this.#a9.subarray(2,6),n=t-r,o=e-a;return 2>=Math.hypot(this.#oo*n,this.#ol*o)?null:((this.#nn.push(t,e),isNaN(i))?(this.#a9.set([r,a,t,e],2),this.#ak.push(NaN,NaN,NaN,NaN,t,e)):(isNaN(this.#a9[0])&&this.#ak.splice(6,6),this.#a9.set([i,s,r,a,t,e],0),this.#ak.push(...sy.createBezierPoints(i,s,r,a,t,e))),{path:{d:this.toSVGPath()}})}end(t,e){let i=this.add(t,e);return i||(2===this.#nn.length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,i,s,r){this.#oo=i,this.#ol=s,this.#s5=r,[t,e]=this.#oh(t,e);let a=this.#ak=[NaN,NaN,NaN,NaN,t,e];this.#nn=[t,e];let n=this.#or.at(-1);return n&&(n.line=new Float32Array(n.line),n.points=new Float32Array(n.points)),this.#or.push({line:a,points:this.#nn}),this.#a9.set(a,0),this.#on=0,this.toSVGPath(),null}getLastElement(){return this.#or.at(-1)}setLastElement(t){return this.#or?(this.#or.push(t),this.#ak=t.line,this.#nn=t.points,this.#on=0,{path:{d:this.toSVGPath()}}):this.#nP.setLastElement(t)}removeLastElement(){if(!this.#or)return this.#nP.removeLastElement();this.#or.pop(),this.#oa="";for(let t=0,e=this.#or.length;t<e;t++){let{line:e,points:i}=this.#or[t];this.#ak=e,this.#nn=i,this.#on=0,this.toSVGPath()}return{path:{d:this.#oa}}}toSVGPath(){let t=sy.svgRound(this.#ak[4]),e=sy.svgRound(this.#ak[5]);if(2===this.#nn.length)return this.#oa=`${this.#oa} M ${t} ${e} Z`,this.#oa;if(this.#nn.length<=6){let i=this.#oa.lastIndexOf("M");this.#oa=`${this.#oa.slice(0,i)} M ${t} ${e}`,this.#on=6}if(4===this.#nn.length){let t=sy.svgRound(this.#ak[10]),e=sy.svgRound(this.#ak[11]);return this.#oa=`${this.#oa} L ${t} ${e}`,this.#on=12,this.#oa}let i=[];0===this.#on&&(i.push(`M ${t} ${e}`),this.#on=6);for(let t=this.#on,e=this.#ak.length;t<e;t+=6){let[e,s,r,a,n,o]=this.#ak.slice(t,t+6).map(sy.svgRound);i.push(`C${e} ${s} ${r} ${a} ${n} ${o}`)}return this.#oa+=i.join(" "),this.#on=this.#ak.length,this.#oa}getOutlines(t,e,i,s){let r=this.#or.at(-1);return r.line=new Float32Array(r.line),r.points=new Float32Array(r.points),this.#nP.build(this.#or,t,e,i,this.#s5,this.#na,s),this.#a9=null,this.#ak=null,this.#or=null,this.#oa=null,this.#nP}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class sP extends sy{#nb;#od=0;#a4;#or;#oo;#ol;#oc;#s5;#na;build(t,e,i,s,r,a,n){this.#oo=e,this.#ol=i,this.#oc=s,this.#s5=r,this.#na=a,this.#a4=n??0,this.#or=t,this.#ou()}get thickness(){return this.#na}setLastElement(t){return this.#or.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#or.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){let t=[];for(let{line:e}of this.#or){if(t.push(`M${sy.svgRound(e[4])} ${sy.svgRound(e[5])}`),6===e.length){t.push("Z");continue}if(12===e.length&&isNaN(e[6])){t.push(`L${sy.svgRound(e[10])} ${sy.svgRound(e[11])}`);continue}for(let i=6,s=e.length;i<s;i+=6){let[s,r,a,n,o,l]=e.subarray(i,i+6).map(sy.svgRound);t.push(`C${s} ${r} ${a} ${n} ${o} ${l}`)}}return t.join("")}serialize([t,e,i,s],r){let a,n,o,l,h,d,c,u,p,g=[],m=[],[f,b,y,v]=this.#op();switch(this.#s5){case 0:p=sy._rescale,a=t,n=e+s,o=i,l=-s,h=t+f*i,d=e+(1-b-v)*s,c=t+(f+y)*i,u=e+(1-b)*s;break;case 90:p=sy._rescaleAndSwap,a=t,n=e,o=i,l=s,h=t+b*i,d=e+f*s,c=t+(b+v)*i,u=e+(f+y)*s;break;case 180:p=sy._rescale,a=t+i,n=e,o=-i,l=s,h=t+(1-f-y)*i,d=e+b*s,c=t+(1-f)*i,u=e+(b+v)*s;break;case 270:p=sy._rescaleAndSwap,a=t+i,n=e+s,o=-i,l=-s,h=t+(1-b-v)*i,d=e+(1-f-y)*s,c=t+(1-b)*i,u=e+(1-f)*s}for(let{line:t,points:e}of this.#or)g.push(p(t,a,n,o,l,r?Array(t.length):null)),m.push(p(e,a,n,o,l,r?Array(e.length):null));return{lines:g,points:m,rect:[h,d,c,u]}}static deserialize(t,e,i,s,r,{paths:{lines:a,points:n},rotation:o,thickness:l}){let h,d,c,u,p,g=[];switch(o){case 0:p=sy._rescale,h=-t/i,d=e/s+1,c=1/i,u=-1/s;break;case 90:p=sy._rescaleAndSwap,h=-e/s,d=-t/i,c=1/s,u=1/i;break;case 180:p=sy._rescale,h=t/i+1,d=-e/s,c=-1/i,u=1/s;break;case 270:p=sy._rescaleAndSwap,h=e/s+1,d=t/i+1,c=-1/s,u=-1/i}if(!a)for(let t of(a=[],n)){let e=t.length;if(2===e){a.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1]]));continue}if(4===e){a.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1],NaN,NaN,NaN,NaN,t[2],t[3]]));continue}let i=new Float32Array(3*(e-2));a.push(i);let[s,r,n,o]=t.subarray(0,4);i.set([NaN,NaN,NaN,NaN,s,r],0);for(let a=4;a<e;a+=2){let e=t[a],l=t[a+1];i.set(sy.createBezierPoints(s,r,n,o,e,l),(a-2)*3),[s,r,n,o]=[n,o,e,l]}}for(let t=0,e=a.length;t<e;t++)g.push({line:p(a[t].map(t=>t??NaN),h,d,c,u),points:p(n[t].map(t=>t??NaN),h,d,c,u)});let m=new this.prototype.constructor;return m.build(g,i,s,1,o,l,r),m}#og(t=this.#na){let e=this.#a4+t/2*this.#oc;return this.#s5%180==0?[e/this.#oo,e/this.#ol]:[e/this.#ol,e/this.#oo]}#op(){let[t,e,i,s]=this.#nb,[r,a]=this.#og(0);return[t+r,e+a,i-2*r,s-2*a]}#ou(){let t=this.#nb=l.slice();for(let{line:e}of this.#or){if(e.length<=12){for(let i=4,s=e.length;i<s;i+=6)N.pointBoundingBox(e[i],e[i+1],t);continue}let i=e[4],s=e[5];for(let r=6,a=e.length;r<a;r+=6){let[a,n,o,l,h,d]=e.subarray(r,r+6);N.bezierBoundingBox(i,s,a,n,o,l,h,d,t),i=h,s=d}}let[e,i]=this.#og();t[0]=X(t[0]-e,0,1),t[1]=X(t[1]-i,0,1),t[2]=X(t[2]+e,0,1),t[3]=X(t[3]+i,0,1),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#nb}updateProperty(t,e){return"stroke-width"===t?this.#nW(e):null}#nW(t){let[e,i]=this.#og();this.#na=t;let[s,r]=this.#og(),[a,n]=[s-e,r-i],o=this.#nb;return o[0]-=a,o[1]-=n,o[2]+=2*a,o[3]+=2*n,o}updateParentDimensions([t,e],i){let[s,r]=this.#og();this.#oo=t,this.#ol=e,this.#oc=i;let[a,n]=this.#og(),o=a-s,l=n-r,h=this.#nb;return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h}updateRotation(t){return this.#od=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#nb.map(sy.svgRound).join(" ")}get defaultProperties(){let[t,e]=this.#nb;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${sy.svgRound(t)} ${sy.svgRound(e)}`}}}get rotationTransform(){let[,,t,e]=this.#nb,i=0,s=0,r=0,a=0,n=0,o=0;switch(this.#od){case 90:s=e/t,r=-t/e,n=t;break;case 180:i=-1,a=-1,n=t,o=e;break;case 270:s=-e/t,r=t/e,o=e;break;default:return""}return`matrix(${i} ${s} ${r} ${a} ${sy.svgRound(n)} ${sy.svgRound(o)})`}getPathResizingSVGProperties([t,e,i,s]){let[r,a]=this.#og(),[n,o,l,h]=this.#nb;if(Math.abs(l-r)<=sy.PRECISION||Math.abs(h-a)<=sy.PRECISION){let r=t+i/2-(n+l/2),a=e+s/2-(o+h/2);return{path:{"transform-origin":`${sy.svgRound(t)} ${sy.svgRound(e)}`,transform:`${this.rotationTransform} translate(${r} ${a})`}}}let d=(i-2*r)/(l-2*r),c=(s-2*a)/(h-2*a);return{path:{"transform-origin":`${sy.svgRound(n)} ${sy.svgRound(o)}`,transform:`${this.rotationTransform} scale(${l/i} ${h/s}) translate(${sy.svgRound(r)} ${sy.svgRound(a)}) scale(${d} ${c}) translate(${sy.svgRound(-r)} ${sy.svgRound(-a)})`}}}getPathResizedSVGProperties([t,e,i,s]){let[r,a]=this.#og(),n=this.#nb,[o,l,h,d]=n;if(n[0]=t,n[1]=e,n[2]=i,n[3]=s,Math.abs(h-r)<=sy.PRECISION||Math.abs(d-a)<=sy.PRECISION){let r=t+i/2-(o+h/2),a=e+s/2-(l+d/2);for(let{line:t,points:e}of this.#or)sy._translate(t,r,a,t),sy._translate(e,r,a,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${sy.svgRound(t)} ${sy.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}let c=(i-2*r)/(h-2*r),u=(s-2*a)/(d-2*a),p=-c*(o+r)+t+r,g=-u*(l+a)+e+a;if(1!==c||1!==u||0!==p||0!==g)for(let{line:t,points:e}of this.#or)sy._rescale(t,p,g,c,u,t),sy._rescale(e,p,g,c,u,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${sy.svgRound(t)} ${sy.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],i){let[s,r]=i,a=this.#nb,n=t-a[0],o=e-a[1];if(this.#oo===s&&this.#ol===r)for(let{line:t,points:e}of this.#or)sy._translate(t,n,o,t),sy._translate(e,n,o,e);else{let t=this.#oo/s,e=this.#ol/r;for(let{line:i,points:a}of(this.#oo=s,this.#ol=r,this.#or))sy._rescale(i,n,o,t,e,i),sy._rescale(a,n,o,t,e,a);a[2]*=t,a[3]*=e}return a[0]=t,a[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${sy.svgRound(t)} ${sy.svgRound(e)}`}}}get defaultSVGProperties(){let t=this.#nb;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${sy.svgRound(t[0])} ${sy.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class sk extends sS{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:t$._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){"stroke-width"===t&&(e??=this["stroke-width"],e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){let t=new sk(this._viewParameters);return t.updateAll(this),t}}class sD extends sE{static _type="ink";static _editorType=u.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){t$.initialize(t,e),this._defaultDrawingOptions=new sk(e.viewParameters)}static getDefaultDrawingOptions(t){let e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return M(this,"typesMap",new Map([[p.INK_THICKNESS,"stroke-width"],[p.INK_COLOR,"stroke"],[p.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,i,s,r){return new sM(t,e,i,s,r,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,i,s,r,a){return sP.deserialize(t,e,i,s,r,a)}static async deserialize(t,e,i){let s=null;if(t instanceof sl){let{data:{inkLists:e,rect:i,rotation:r,id:a,color:n,opacity:o,borderStyle:{rawWidth:l},popupRef:h,richText:d,contentsObj:c,creationDate:p,modificationDate:g},parent:{page:{pageNumber:m}}}=t;s=t={annotationType:u.INK,color:Array.from(n),thickness:l,opacity:o,paths:{points:e},boxes:null,pageIndex:m-1,rect:i.slice(0),rotation:r,annotationElementId:a,id:a,deleted:!1,popupRef:h,richText:d,comment:c?.str||null,creationDate:p,modificationDate:g}}let r=await super.deserialize(t,e,i);return r._initialData=s,t.comment&&r.setCommentData(t),r}get toolbarButtons(){return this._colorPicker||=new iG(this),[["colorPicker",this._colorPicker]]}get colorType(){return p.INK_COLOR}get colorAndOpacityType(){return p.INK_COLOR_AND_OPACITY}get opacityType(){return p.INK_OPACITY}updateParams(t,e){t===p.INK_COLOR_AND_OPACITY?this._updateColorAndOpacity(e.color,e.opacity):super.updateParams(t,e)}static updateDefaultParams(t,e){if(t===p.INK_COLOR_AND_OPACITY){super.updateDefaultParams(p.INK_COLOR,e.color),super.updateDefaultParams(p.INK_OPACITY,e.opacity);return}super.updateDefaultParams(t,e)}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();let{_drawId:t,_drawingOptions:e,parent:i}=this;e.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){let 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=sD.getDefaultDrawingOptions({stroke:N.makeHexColor(...t),"stroke-width":e,"stroke-opacity":i})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let{lines:e,points:i}=this.serializeDraw(t),{_drawingOptions:{stroke:s,"stroke-opacity":r,"stroke-width":a}}=this,n=Object.assign(super.serialize(t),{color:t$._colorManager.convert(s),opacity:r,thickness:a,paths:{lines:e,points:i}});return(this.addComment(n),t)?(n.isCopy=!0,n):this.annotationElementId&&!this.#a3(n)?null:(n.id=this.annotationElementId,n)}#a3(t){let{color:e,thickness:i,opacity:s,pageIndex:r}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||t.color.some((t,i)=>t!==e[i])||t.thickness!==i||t.opacity!==s||t.pageIndex!==r}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let{points:e,rect:i}=this.serializeDraw(!1);return t.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:e,popup:this.comment}),null}}class sI extends sP{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}class sB{static #om={maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16};static #of(t,e,i,s){return(i-=t,s-=e,0===i)?s>0?0:4:1===i?s+6:2-s}static #ob=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static #oy(t,e,i,s,r,a,n){let o=this.#of(i,s,r,a);for(let r=0;r<8;r++){let a=(-r+o-n+16)%8;if(0!==t[(i+this.#ob[2*a])*e+(s+this.#ob[2*a+1])])return a}return -1}static #ov(t,e,i,s,r,a,n){let o=this.#of(i,s,r,a);for(let r=0;r<8;r++){let a=(r+o+n+16)%8;if(0!==t[(i+this.#ob[2*a])*e+(s+this.#ob[2*a+1])])return a}return -1}static #oA(t,e,i,s){let r,a=t.length,n=new Int32Array(a);for(let e=0;e<a;e++)n[e]=+(t[e]<=s);for(let t=1;t<i-1;t++)n[t*e]=n[t*e+e-1]=0;for(let t=0;t<e;t++)n[t]=n[e*i-1-t]=0;let o=1,l=[];for(let t=1;t<i-1;t++){r=1;for(let i=1;i<e-1;i++){let s,a=t*e+i,h=n[a];if(0===h)continue;let d=t,c=i;if(1===h&&0===n[a-1])o+=1,c-=1;else if(h>=1&&0===n[a+1])o+=1,c+=1,h>1&&(r=h);else{1!==h&&(r=Math.abs(h));continue}let u=[i,t],p=c===i+1,g={isHole:p,points:u,id:o,parent:0};for(let t of(l.push(g),l))if(t.id===r){s=t;break}s?s.isHole?g.parent=p?s.parent:r:g.parent=p?r:s.parent:g.parent=p?r:0;let m=this.#oy(n,e,t,i,d,c,0);if(-1===m){n[a]=-o,1!==n[a]&&(r=Math.abs(n[a]));continue}let f=this.#ob[2*m],b=this.#ob[2*m+1],y=t+f,v=i+b;d=y,c=v;let A=t,x=i;for(;;){let s=this.#ov(n,e,A,x,d,c,1);f=this.#ob[2*s],b=this.#ob[2*s+1];let l=A+f,h=x+b;u.push(h,l);let p=A*e+x;if(0===n[p+1]?n[p]=-o:1===n[p]&&(n[p]=o),l===t&&h===i&&A===y&&x===v){1!==n[a]&&(r=Math.abs(n[a]));break}d=A,c=x,A=l,x=h}}}return l}static #ox(t,e,i,s){if(i-e<=4){for(let r=e;r<i-2;r+=2)s.push(t[r],t[r+1]);return}let r=t[e],a=t[e+1],n=t[i-4]-r,o=t[i-3]-a,l=Math.hypot(n,o),h=n/l,d=o/l,c=h*a-d*r,u=1/l,p=Math.atan(o/n),g=Math.cos(p),m=Math.sin(p),f=u*(Math.abs(g)+Math.abs(m)),b=u*(1-f+f**2),y=Math.max(Math.atan(Math.abs(m+g)*b),Math.atan(Math.abs(m-g)*b)),v=0,A=e;for(let s=e+2;s<i-2;s+=2){let e=Math.abs(c-h*t[s+1]+d*t[s]);e>v&&(A=s,v=e)}v>(l*y)**2?(this.#ox(t,e,A+2,s),this.#ox(t,A,i,s)):s.push(r,a)}static #ow(t){let e=[],i=t.length;return this.#ox(t,0,i,e),e.push(t[i-2],t[i-1]),e.length<=4?null:e}static #o_(t,e,i,s,r,a){let n=new Float32Array(a**2),o=-2*s**2,l=a>>1;for(let t=0;t<a;t++){let e=(t-l)**2;for(let i=0;i<a;i++)n[t*a+i]=Math.exp((e+(i-l)**2)/o)}let h=new Float32Array(256),d=-2*r**2;for(let t=0;t<256;t++)h[t]=Math.exp(t**2/d);let c=new Uint8Array(t.length),u=new Uint32Array(256);for(let s=0;s<i;s++)for(let r=0;r<e;r++){let o=s*e+r,d=t[o],p=0,g=0;for(let o=0;o<a;o++){let c=s+o-l;if(!(c<0)&&!(c>=i))for(let i=0;i<a;i++){let s=r+i-l;if(s<0||s>=e)continue;let u=t[c*e+s],m=n[o*a+i]*h[Math.abs(u-d)];p+=u*m,g+=m}}let m=c[o]=Math.round(p/g);u[m]++}return[c,u]}static #oC(t){let e=new Uint32Array(256);for(let i of t)e[i]++;return e}static #oT(t){let e=new Uint8ClampedArray(t.length>>2),i=-1/0,s=1/0;for(let r=0,a=e.length;r<a;r++){let a=e[r]=t[r<<2];i=Math.max(i,a),s=Math.min(s,a)}let r=255/(i-s);for(let t=0,i=e.length;t<i;t++)e[t]=(e[t]-s)*r;return e}static #oS(t){let e,i=-1/0,s=-1/0,r=t.findIndex(t=>0!==t),a=r,n=r;for(e=r;e<256;e++){let r=t[e];r>i&&(e-a>s&&(s=e-a,n=e-1),i=r,a=e)}for(e=n-1;e>=0&&!(t[e]>t[e+1]);e--);return e}static #oE(t){let e=t,{width:i,height:s}=t,{maxDim:r}=this.#om,a=i,n=s;if(i>r||s>r){let o=i,l=s,h=Math.log2(Math.max(i,s)/r),d=Math.floor(h);h=h===d?d-1:d;for(let i=0;i<h;i++){let i=new OffscreenCanvas(a=Math.ceil(o/2),n=Math.ceil(l/2));i.getContext("2d").drawImage(t,0,0,o,l,0,0,a,n),o=a,l=n,t!==e&&t.close(),t=i.transferToImageBitmap()}let c=Math.min(r/a,r/n);a=Math.round(a*c),n=Math.round(n*c)}let o=new OffscreenCanvas(a,n).getContext("2d",{willReadFrequently:!0});o.fillStyle="white",o.fillRect(0,0,a,n),o.filter="grayscale(1)",o.drawImage(t,0,0,t.width,t.height,0,0,a,n);let l=o.getImageData(0,0,a,n).data;return[this.#oT(l),a,n]}static extractContoursFromText(t,{fontFamily:e,fontStyle:i,fontWeight:s},r,a,n,o){let l=new OffscreenCanvas(1,1),h=l.getContext("2d",{alpha:!1}),d=h.font=`${i} ${s} 200px ${e}`,{actualBoundingBoxLeft:c,actualBoundingBoxRight:u,actualBoundingBoxAscent:p,actualBoundingBoxDescent:g,fontBoundingBoxAscent:m,fontBoundingBoxDescent:f,width:b}=h.measureText(t),y=Math.ceil(1.5*Math.max(Math.abs(c)+Math.abs(u)||0,b)),v=Math.ceil(1.5*Math.max(Math.abs(p)+Math.abs(g)||200,Math.abs(m)+Math.abs(f)||200));(h=(l=new OffscreenCanvas(y,v)).getContext("2d",{alpha:!0,willReadFrequently:!0})).font=d,h.filter="grayscale(1)",h.fillStyle="white",h.fillRect(0,0,y,v),h.fillStyle="black",h.fillText(t,.5*y/2,1.5*v/2);let A=this.#oT(h.getImageData(0,0,y,v).data),x=this.#oC(A),w=this.#oS(x),_=this.#oA(A,y,v,w);return this.processDrawnLines({lines:{curves:_,width:y,height:v},pageWidth:r,pageHeight:a,rotation:n,innerMargin:o,mustSmooth:!0,areContours:!0})}static process(t,e,i,s,r){let[a,n,o]=this.#oE(t),[l,h]=this.#o_(a,n,o,Math.hypot(n,o)*this.#om.sigmaSFactor,this.#om.sigmaR,this.#om.kernelSize),d=this.#oS(h),c=this.#oA(l,n,o,d);return this.processDrawnLines({lines:{curves:c,width:n,height:o},pageWidth:e,pageHeight:i,rotation:s,innerMargin:r,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:s,innerMargin:r,mustSmooth:a,areContours:n}){s%180!=0&&([e,i]=[i,e]);let{curves:o,width:l,height:h}=t,d=t.thickness??0,c=[],u=Math.min(e/l,i/h),p=u/e,g=u/i,m=[];for(let{points:t}of o){let e=a?this.#ow(t):t;if(!e)continue;m.push(e);let i=e.length,s=new Float32Array(i),r=new Float32Array(3*(2===i?2:i-2));if(c.push({line:r,points:s}),2===i){s[0]=e[0]*p,s[1]=e[1]*g,r.set([NaN,NaN,NaN,NaN,s[0],s[1]],0);continue}let[n,o,l,h]=e;n*=p,o*=g,l*=p,h*=g,s.set([n,o,l,h],0),r.set([NaN,NaN,NaN,NaN,n,o],0);for(let t=4;t<i;t+=2){let i=s[t]=e[t]*p,a=s[t+1]=e[t+1]*g;r.set(sy.createBezierPoints(n,o,l,h,i,a),(t-2)*3),[n,o,l,h]=[l,h,i,a]}}if(0===c.length)return null;let f=n?new sI:new sP;return f.build(c,e,i,1,s,n?0:d,r),{outline:f,newCurves:m,areContours:n,thickness:d,width:l,height:h}}static async compressSignature({outlines:t,areContours:e,thickness:i,width:s,height:r}){let a,n=1/0,o=-1/0,l=0;for(let e of t){l+=e.length;for(let t=2,i=e.length;t<i;t++){let i=e[t]-e[t-2];n=Math.min(n,i),o=Math.max(o,i)}}a=n>=-128&&o<=127?Int8Array:n>=-32768&&o<=32767?Int16Array:Int32Array;let h=t.length,d=8+3*h,c=new Uint32Array(d),u=0;for(let n of(c[u++]=d*Uint32Array.BYTES_PER_ELEMENT+(l-2*h)*a.BYTES_PER_ELEMENT,c[u++]=0,c[u++]=s,c[u++]=r,c[u++]=+!e,c[u++]=Math.max(0,Math.floor(i??0)),c[u++]=h,c[u++]=a.BYTES_PER_ELEMENT,t))c[u++]=n.length-2,c[u++]=n[0],c[u++]=n[1];let p=new CompressionStream("deflate-raw"),g=p.writable.getWriter();await g.ready,g.write(c);let m=a.prototype.constructor;for(let e of t){let t=new m(e.length-2);for(let i=2,s=e.length;i<s;i++)t[i-2]=e[i]-e[i-2];g.write(t)}return g.close(),(await new Response(p.readable).bytes()).toBase64()}static async decompressSignature(t){try{let e,i=Uint8Array.fromBase64(t),{readable:s,writable:r}=new DecompressionStream("deflate-raw"),a=r.getWriter();await a.ready,a.write(i).then(async()=>{await a.ready,await a.close()}).catch(()=>{});let n=null,o=0;for await(let t of s)(n||=new Uint8Array(new Uint32Array(t.buffer,0,4)[0])).set(t,o),o+=t.length;let l=new Uint32Array(n.buffer,0,n.length>>2),h=l[1];if(0!==h)throw Error(`Invalid version: ${h}`);let d=l[2],c=l[3],u=0===l[4],p=l[5],g=l[6],m=l[7],f=[],b=(8+3*g)*Uint32Array.BYTES_PER_ELEMENT;switch(m){case Int8Array.BYTES_PER_ELEMENT:e=new Int8Array(n.buffer,b);break;case Int16Array.BYTES_PER_ELEMENT:e=new Int16Array(n.buffer,b);break;case Int32Array.BYTES_PER_ELEMENT:e=new Int32Array(n.buffer,b)}o=0;for(let t=0;t<g;t++){let i=l[3*t+8],s=new Float32Array(i+2);f.push(s);for(let e=0;e<2;e++)s[e]=l[3*t+8+e+1];for(let t=0;t<i;t++)s[t+2]=s[t]+e[o++]}return{areContours:u,thickness:p,outlines:f,width:d,height:c}}catch(t){return w(`decompressSignature: ${t}`),null}}}class sF extends sS{constructor(){super(),super.updateProperties({fill:t$._defaultLineColor,"stroke-width":0})}clone(){let t=new sF;return t.updateAll(this),t}}class sL extends sk{constructor(t){super(t),super.updateProperties({stroke:t$._defaultLineColor,"stroke-width":1})}clone(){let t=new sL(this._viewParameters);return t.updateAll(this),t}}class sR extends sE{#oM=!1;#oP=null;#ok=null;#oD=null;static _type="signature";static _editorType=u.SIGNATURE;static _defaultDrawingOptions=null;constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"}),this._willKeepAspectRatio=!0,this.#ok=t.signatureData||null,this.#oP=null,this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){t$.initialize(t,e),this._defaultDrawingOptions=new sF,this._defaultDrawnSignatureOptions=new sL(e.viewParameters)}static getDefaultDrawingOptions(t){let e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return M(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!this.#oP}}static computeTelemetryFinalData(t){let e=t.get("hasDescription");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){null!==this._drawId&&super.onScaleChanging()}render(){let t,e;if(this.div)return this.div;let{_isCopy:i}=this;if(i&&(this._isCopy=!1,t=this.x,e=this.y),super.render(),null===this._drawId)if(this.#ok){let{lines:t,mustSmooth:e,areContours:i,description:s,uuid:r,heightInPage:a}=this.#ok,{rawDims:{pageWidth:n,pageHeight:o},rotation:l}=this.parent.viewport,h=sB.processDrawnLines({lines:t,pageWidth:n,pageHeight:o,rotation:l,innerMargin:sR._INNER_MARGIN,mustSmooth:e,areContours:i});this.addSignature(h,a,s,r)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute("data-l10n-args",JSON.stringify({description:this.#oP||""}));return i&&(this._isCopy=!0,this._moveAfterPaste(t,e)),this.div}setUuid(t){this.#oD=t,this.addEditToolbar()}getUuid(){return this.#oD}get description(){return this.#oP}set description(t){this.#oP=t,this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:t})),super.addEditToolbar().then(e=>{e?.updateEditSignatureButton(t)}))}getSignaturePreview(){let{newCurves:t,areContours:e,thickness:i,width:s,height:r}=this.#ok,a=Math.max(s,r),n=sB.processDrawnLines({lines:{curves:t.map(t=>({points:t})),thickness:i,width:s,height:r},pageWidth:a,pageHeight:a,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e});return{areContours:e,outline:n.outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(t,e,i,s){let r,{x:a,y:n}=this,{outline:o}=this.#ok=t;this.#oM=o instanceof sI,this.description=i,this.#oM?r=sR.getDefaultDrawingOptions():(r=sR._defaultDrawnSignatureOptions.clone()).updateProperties({"stroke-width":o.thickness}),this._addOutlines({drawOutlines:o,drawingOptions:r});let[,l]=this.pageDimensions,h=e/l;h=h>=1?.5:h,this.width*=h/this.height,this.width>=1&&(h*=.9/this.width,this.width=.9),this.height=h,this.setDims(),this.x=a,this.y=n,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(s),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!s,hasDescription:!!i}}),this.div.hidden=!1}getFromImage(t){let{rawDims:{pageWidth:e,pageHeight:i},rotation:s}=this.parent.viewport;return sB.process(t,e,i,s,sR._INNER_MARGIN)}getFromText(t,e){let{rawDims:{pageWidth:i,pageHeight:s},rotation:r}=this.parent.viewport;return sB.extractContoursFromText(t,e,i,s,r,sR._INNER_MARGIN)}getDrawnSignature(t){let{rawDims:{pageWidth:e,pageHeight:i},rotation:s}=this.parent.viewport;return sB.processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:s,innerMargin:sR._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:e}){t?this._drawingOptions=sR.getDefaultDrawingOptions():(this._drawingOptions=sR._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":e}))}serialize(t=!1){if(this.isEmpty())return null;let{lines:e,points:i}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":s}}=this,r=Object.assign(super.serialize(t),{isSignature:!0,areContours:this.#oM,color:[0,0,0],thickness:this.#oM?0:s});return this.addComment(r),t?(r.paths={lines:e,points:i},r.uuid=this.#oD,r.isCopy=!0):r.lines=e,this.#oP&&(r.accessibilityData={type:"Figure",alt:this.#oP}),r}static deserializeDraw(t,e,i,s,r,a){return a.areContours?sI.deserialize(t,e,i,s,r,a):sP.deserialize(t,e,i,s,r,a)}static async deserialize(t,e,i){let s=await super.deserialize(t,e,i);return s.#oM=t.areContours,s.description=t.accessibilityData?.alt||"",s.#oD=t.uuid,s}}class sO extends t${#oI=null;#oB=null;#oF=null;#oL=null;#oR=null;#oO="";#oN=null;#oU=!1;#oH=null;#oz=!1;#o$=!1;static _type="stamp";static _editorType=u.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#oL=t.bitmapUrl,this.#oR=t.bitmapFile,this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){t$.initialize(t,e)}static isHandlingMimeForPasting(t){return tb.includes(t)}static paste(t,e){e.pasteEditor({mode:u.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){let e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#oG(t,e=!1){t?(this.#oI=t.bitmap,e||(this.#oB=t.id,this.#oz=t.isSvg),t.file&&(this.#oO=t.file.name),this.#oj()):this.remove()}#oV(){if(this.#oF=null,this._uiManager.enableWaiting(!1),this.#oN){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#oI)return void this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#oI){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;let{mlManager:i}=this._uiManager;if(!i)throw Error("No ML.");if(!await i.isEnabledFor("altText"))throw Error("ML isn't enabled for alt text.");let{data:s,width:r,height:a}=t||this.copyCanvas(null,null,!0).imageData,n=await i.guess({name:"altText",request:{data:s,width:r,height:a,channels:s.length/(r*a)}});if(!n)throw Error("No response from the AI service.");if(n.error)throw Error("Error from the AI service.");if(n.cancel)return null;if(!n.output)throw Error("No valid response from the AI service.");let o=n.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}#oW(){if(this.#oB){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#oB).then(t=>this.#oG(t,!0)).finally(()=>this.#oV());return}if(this.#oL){let t=this.#oL;this.#oL=null,this._uiManager.enableWaiting(!0),this.#oF=this._uiManager.imageManager.getFromUrl(t).then(t=>this.#oG(t)).finally(()=>this.#oV());return}if(this.#oR){let t=this.#oR;this.#oR=null,this._uiManager.enableWaiting(!0),this.#oF=this._uiManager.imageManager.getFromFile(t).then(t=>this.#oG(t)).finally(()=>this.#oV());return}let t=document.createElement("input");t.type="file",t.accept=tb.join(",");let e=this._uiManager._signal;this.#oF=new Promise(i=>{t.addEventListener("change",async()=>{if(t.files&&0!==t.files.length){this._uiManager.enableWaiting(!0);let e=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#oG(e)}else this.remove();i()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),i()},{signal:e})}).finally(()=>this.#oV()),t.click()}remove(){this.#oB&&(this.#oI=null,this._uiManager.imageManager.deleteId(this.#oB),this.#oN?.remove(),this.#oN=null,this.#oH&&(clearTimeout(this.#oH),this.#oH=null)),super.remove()}rebuild(){if(!this.parent){this.#oB&&this.#oW();return}super.rebuild(),null!==this.div&&(this.#oB&&null===this.#oN&&this.#oW(),this.isAttachedToDOM||this.parent.add(this))}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#oF||this.#oI||this.#oL||this.#oR||this.#oB||this.#oU)}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){let t,e;return this.div||(this._isCopy&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.createAltText(),this.#oU||(this.#oI?this.#oj():this.#oW()),this._isCopy&&this._moveAfterPaste(t,e),this._uiManager.addShouldRescale(this)),this.div}setCanvas(t,e){let{id:i,bitmap:s}=this._uiManager.imageManager.getFromCanvas(t,e);e.remove(),i&&this._uiManager.imageManager.isValidId(i)&&(this.#oB=i,s&&(this.#oI=s),this.#oU=!1,this.#oj())}_onResized(){this.onScaleChanging()}onScaleChanging(){this.parent&&(null!==this.#oH&&clearTimeout(this.#oH),this.#oH=setTimeout(()=>{this.#oH=null,this.#oX()},200))}#oj(){let{div:t}=this,{width:e,height:i}=this.#oI,[s,r]=this.pageDimensions;if(this.width)e=this.width*s,i=this.height*r;else if(e>.75*s||i>.75*r){let t=Math.min(.75*s/e,.75*r/i);e*=t,i*=t}this._uiManager.enableWaiting(!1);let a=this.#oN=document.createElement("canvas");a.setAttribute("role","img"),this.addContainer(a),this.width=e/s,this.height=i/r,this.setDims(),this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(t.hidden=!1),this.#oX(),this.#o$||(this.parent.addUndoableEditor(this),this.#o$=!0),this._reportTelemetry({action:"inserted_image"}),this.#oO&&this.div.setAttribute("aria-description",this.#oO),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")}copyCanvas(t,e,i=!1){t||(t=224);let{width:s,height:r}=this.#oI,a=new tf,n=this.#oI,o=s,l=r,h=null;if(e){if(s>e||r>e){let t=Math.min(e/s,e/r);o=Math.floor(s*t),l=Math.floor(r*t)}let t=(h=document.createElement("canvas")).width=Math.ceil(o*a.sx),i=h.height=Math.ceil(l*a.sy);this.#oz||(n=this.#oq(t,i));let d=h.getContext("2d");d.filter=this._uiManager.hcmFilter;let c="white",u="#cfcfd8";"none"!==this._uiManager.hcmFilter?u="black":ty.isDarkMode&&(c="#8f8f9d",u="#42414d");let p=15*a.sx,g=15*a.sy,m=new OffscreenCanvas(2*p,2*g),f=m.getContext("2d");f.fillStyle=c,f.fillRect(0,0,2*p,2*g),f.fillStyle=u,f.fillRect(0,0,p,g),f.fillRect(p,g,p,g),d.fillStyle=d.createPattern(m,"repeat"),d.fillRect(0,0,t,i),d.drawImage(n,0,0,n.width,n.height,0,0,t,i)}let d=null;if(i){let e,i;if(a.symmetric&&n.width<t&&n.height<t)e=n.width,i=n.height;else if(n=this.#oI,s>t||r>t){let a=Math.min(t/s,t/r);e=Math.floor(s*a),i=Math.floor(r*a),this.#oz||(n=this.#oq(e,i))}let o=new OffscreenCanvas(e,i).getContext("2d",{willReadFrequently:!0});o.drawImage(n,0,0,n.width,n.height,0,0,e,i),d={width:e,height:i,data:o.getImageData(0,0,e,i).data}}return{canvas:h,width:o,height:l,imageData:d}}#oq(t,e){let{width:i,height:s}=this.#oI,r=i,a=s,n=this.#oI;for(;r>2*t||a>2*e;){let i=r,s=a;r>2*t&&(r=Math.ceil(r/2)),a>2*e&&(a=Math.ceil(a/2));let o=new OffscreenCanvas(r,a);o.getContext("2d").drawImage(n,0,0,i,s,0,0,r,a),n=o.transferToImageBitmap()}return n}#oX(){let[t,e]=this.parentDimensions,{width:i,height:s}=this,r=new tf,a=Math.ceil(i*t*r.sx),n=Math.ceil(s*e*r.sy),o=this.#oN;if(!o||o.width===a&&o.height===n)return;o.width=a,o.height=n;let l=this.#oz?this.#oI:this.#oq(a,n),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,a,n)}#oK(t){if(t){if(this.#oz){let t=this._uiManager.imageManager.getSvgUrl(this.#oB);if(t)return t}let t=document.createElement("canvas");return{width:t.width,height:t.height}=this.#oI,t.getContext("2d").drawImage(this.#oI,0,0),t.toDataURL()}if(this.#oz){let[t,e]=this.pageDimensions,i=Math.round(this.width*t*Q.PDF_TO_CSS_UNITS),s=Math.round(this.height*e*Q.PDF_TO_CSS_UNITS),r=new OffscreenCanvas(i,s);return r.getContext("2d").drawImage(this.#oI,0,0,this.#oI.width,this.#oI.height,0,0,i,s),r.transferToImageBitmap()}return structuredClone(this.#oI)}static async deserialize(t,e,i){let s=null,r=!1;if(t instanceof sp){let a,n,{data:{rect:o,rotation:l,id:h,structParent:d,popupRef:c,richText:p,contentsObj:g,creationDate:m,modificationDate:f},container:b,parent:{page:{pageNumber:y}},canvas:v}=t;v?(delete t.canvas,{id:a,bitmap:n}=i.imageManager.getFromCanvas(b.id,v),v.remove()):(r=!0,t._hasNoCanvas=!0);let A=(await e._structTree.getAriaAttributes(`${G}${h}`))?.get("aria-label")||"";s=t={annotationType:u.STAMP,bitmapId:a,bitmap:n,pageIndex:y-1,rect:o.slice(0),rotation:l,annotationElementId:h,id:h,deleted:!1,accessibilityData:{decorative:!1,altText:A},isSvg:!1,structParent:d,popupRef:c,richText:p,comment:g?.str||null,creationDate:m,modificationDate:f}}let a=await super.deserialize(t,e,i),{rect:n,bitmap:o,bitmapUrl:l,bitmapId:h,isSvg:d,accessibilityData:c}=t;r?(i.addMissingCanvas(t.id,a),a.#oU=!0):h&&i.imageManager.isValidId(h)?(a.#oB=h,o&&(a.#oI=o)):a.#oL=l,a.#oz=d;let[p,g]=a.pageDimensions;return a.width=(n[2]-n[0])/p,a.height=(n[3]-n[1])/g,c&&(a.altTextData=c),a._initialData=s,t.comment&&a.setCommentData(t),a.#o$=!!s,a}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let i=Object.assign(super.serialize(t),{bitmapId:this.#oB,isSvg:this.#oz});if(this.addComment(i),t)return i.bitmapUrl=this.#oK(!0),i.accessibilityData=this.serializeAltText(!0),i.isCopy=!0,i;let{decorative:s,altText:r}=this.serializeAltText(!1);if(!s&&r&&(i.accessibilityData={type:"Figure",alt:r}),this.annotationElementId){let t=this.#a3(i);return t.isSame?null:(t.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1,i.id=this.annotationElementId,delete i.bitmapId,i)}if(null===e)return i;e.stamps||=new Map;let a=this.#oz?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(e.stamps.has(this.#oB)){if(this.#oz){let t=e.stamps.get(this.#oB);a>t.area&&(t.area=a,t.serialized.bitmap.close(),t.serialized.bitmap=this.#oK(!1))}}else e.stamps.set(this.#oB,{area:a,serialized:i}),i.bitmap=this.#oK(!1);return i}#a3(t){let{pageIndex:e,accessibilityData:{altText:i}}=this._initialData,s=t.pageIndex===e,r=(t.accessibilityData?.alt||"")===i;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&s&&r,isSameAltText:r}}renderAnnotationElement(t){return this.deleted?t.hide():t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null}}class sN{#aU;#oY=!1;#oQ=null;#oJ=null;#oZ=null;#o0=new Map;#o1=!1;#o2=!1;#o3=!1;#o5=null;#o6=null;#o4=null;#o8=null;#o7=null;#o9=-1;#y;static _initialized=!1;static #Q=new Map([sb,sD,sO,sT,sR].map(t=>[t._editorType,t]));constructor({uiManager:t,pageIndex:e,div:i,structTreeLayer:s,accessibilityManager:r,annotationLayer:a,drawLayer:n,textLayer:o,viewport:l,l10n:h}){const d=[...sN.#Q.values()];if(!sN._initialized)for(const e of(sN._initialized=!0,d))e.initialize(h,t);t.registerEditorTypes(d),this.#y=t,this.pageIndex=e,this.div=i,this.#aU=r,this.#oQ=a,this.viewport=l,this.#o4=o,this.drawLayer=n,this._structTree=s,this.#y.addLayer(this)}get isEmpty(){return 0===this.#o0.size}get isInvisible(){return this.isEmpty&&this.#y.getMode()===u.NONE}updateToolbar(t){this.#y.updateToolbar(t)}updateMode(t=this.#y.getMode()){switch(this.#lt(),t){case u.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case u.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case u.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);let{classList:e}=this.div;if(e.toggle("nonEditing",!1),t===u.POPUP)e.toggle("commentEditing",!0);else for(let i of(e.toggle("commentEditing",!1),sN.#Q.values()))e.toggle(`${i._type}Editing`,t===i._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#o4?.div}setEditingState(t){this.#y.setEditingState(t)}addCommands(t){this.#y.addCommands(t)}cleanUndoStack(t){this.#y.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#oQ?.togglePointerEvents(t)}get #le(){return 0!==this.#o0.size?this.#o0.values():this.#y.getEditors(this.pageIndex)}async enable(){this.#o3=!0,this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),this.#o7?.abort(),this.#o7=null;let t=new Set;for(let e of this.#le)e.enableEditing(),e.show(!0),e.annotationElementId&&(this.#y.removeChangedExistingAnnotation(e),t.add(e.annotationElementId));let e=this.#oQ;if(e)for(let i of e.getEditableAnnotations()){if(i.hide(),this.#y.isDeletedAnnotationElement(i.data.id)||t.has(i.data.id))continue;let e=await this.deserialize(i);e&&(this.addOrRebuild(e),e.enableEditing())}this.#o3=!1,this.#y._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){if(this.#o2=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),this.#o4&&!this.#o7){this.#o7=new AbortController;let t=this.#y.combinedSignal(this.#o7);this.#o4.div.addEventListener("pointerdown",t=>{let e,{clientX:i,clientY:s,timeStamp:r}=t;if(r-this.#o9>500){this.#o9=r;return}this.#o9=-1;let{classList:a}=this.div;a.toggle("getElements",!0);let n=document.elementsFromPoint(i,s);if(a.toggle("getElements",!1),!this.div.contains(n[0]))return;let o=RegExp(`^${c}[0-9]+$`);for(let t of n)if(o.test(t.id)){e=t.id;break}if(!e)return;let l=this.#o0.get(e);l?.annotationElementId===null&&(tl(t),l.dblclick(t))},{signal:t,capture:!0})}let t=this.#oQ,e=[];if(t){let i=new Map,s=new Map;for(let t of this.#le){if(t.disableEditing(),!t.annotationElementId){e.push(t);continue}if(null!==t.serialize()){i.set(t.annotationElementId,t);continue}s.set(t.annotationElementId,t),this.getEditableAnnotation(t.annotationElementId)?.show(),t.remove()}for(let e of t.getEditableAnnotations()){let{id:t}=e.data;if(this.#y.isDeletedAnnotationElement(t)){e.updateEdited({deleted:!0});continue}let r=s.get(t);if(r){r.resetAnnotationElement(e),r.show(!1),e.show();continue}(r=i.get(t))&&(this.#y.addChangedExistingAnnotation(r),r.renderAnnotationElement(e)&&r.show(!1)),e.show()}}this.#lt(),this.isEmpty&&(this.div.hidden=!0);let{classList:i}=this.div;for(let t of sN.#Q.values())i.remove(`${t._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),t?.updateFakeAnnotations(e),this.#o2=!1}getEditableAnnotation(t){return this.#oQ?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#y.getActive()!==t&&this.#y.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#o4?.div&&!this.#o8){this.#o8=new AbortController;let t=this.#y.combinedSignal(this.#o8);this.#o4.div.addEventListener("pointerdown",this.#li.bind(this),{signal:t}),this.#o4.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#o4?.div&&this.#o8&&(this.#o8.abort(),this.#o8=null,this.#o4.div.classList.remove("highlighting"))}#li(t){this.#y.unselectAll();let{target:e}=t;if(e===this.#o4.div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent")||e.classList.contains("textLayerImagePlaceholder"))&&this.#o4.div.contains(e)){let{isMac:e}=O.platform;if(0!==t.button||t.ctrlKey&&e)return;this.#y.showAllEditors("highlight",!0,!0),this.#o4.div.classList.add("free"),this.toggleDrawing(),sT.startHighlighting(this,"ltr"===this.#y.direction,{target:this.#o4.div,x:t.x,y:t.y}),this.#o4.div.addEventListener("pointerup",()=>{this.#o4.div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:this.#y._signal}),t.preventDefault()}}enableClick(){if(this.#oJ)return;this.#oJ=new AbortController;let t=this.#y.combinedSignal(this.#oJ);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});let e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){this.#oJ?.abort(),this.#oJ=null}attach(t){this.#o0.set(t.id,t);let{annotationElementId:e}=t;e&&this.#y.isDeletedAnnotationElement(e)&&this.#y.removeDeletedAnnotationElement(t)}detach(t){this.#o0.delete(t.id),this.#aU?.removePointerInTextLayer(t.contentDiv),!this.#o2&&t.annotationElementId&&this.#y.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#y.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#y.addDeletedAnnotationElement(t),t$.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.#y.addEditor(t),this.attach(t),!t.isAttachedToDOM){let e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#o3),this.#y.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;let{activeElement:e}=document;t.div.contains(e)&&!this.#oZ&&(t._focusEventsAllowed=!1,this.#oZ=setTimeout(()=>{this.#oZ=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#y._signal}),e.focus())},0)),t._structTreeParentId=this.#aU?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getEditorByUID(t){for(let e of this.#o0.values())if(e.uid===t)return e;return null}get #ls(){return sN.#Q.get(this.#y.getMode())}combinedSignal(t){return this.#y.combinedSignal(t)}#lr(t){let e=this.#ls;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#ls?.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await this.#y.updateMode(t.mode);let{offsetX:i,offsetY:s}=this.#la(),r=this.#y.getId(),a=this.#lr({parent:this,id:r,x:i,y:s,uiManager:this.#y,isCentered:!0,...e});a&&this.add(a)}async deserialize(t){return await sN.#Q.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#y)||null}createAndAddNewEditor(t,e,i={}){let s=this.#y.getId(),r=this.#lr({parent:this,id:s,x:t.offsetX,y:t.offsetY,uiManager:this.#y,isCentered:e,...i});return r&&this.add(r),r}get boundingClientRect(){return this.div.getBoundingClientRect()}#la(){let{x:t,y:e,width:i,height:s}=this.boundingClientRect,r=Math.max(0,t),a=Math.max(0,e),n=Math.min(window.innerWidth,t+i),o=Math.min(window.innerHeight,e+s),l=(r+n)/2-t,h=(a+o)/2-e,[d,c]=this.viewport.rotation%180==0?[l,h]:[h,l];return{offsetX:d,offsetY:c}}addNewEditor(t={}){this.createAndAddNewEditor(this.#la(),!0,t)}setSelected(t){this.#y.setSelected(t)}toggleSelected(t){this.#y.toggleSelected(t)}unselect(t){this.#y.unselect(t)}pointerup(t){let{isMac:e}=O.platform;if(0!==t.button||t.ctrlKey&&e||t.target!==this.div||!this.#o1||(this.#o1=!1,this.#ls?.isDrawer&&this.#ls.supportMultipleDrawings))return;if(!this.#oY){this.#oY=!0;return}let i=this.#y.getMode();i===u.STAMP||i===u.POPUP||i===u.SIGNATURE?this.#y.unselectAll():this.createAndAddNewEditor(t,!1)}pointerdown(t){if(this.#y.getMode()===u.HIGHLIGHT&&this.enableTextSelection(),this.#o1){this.#o1=!1;return}let{isMac:e}=O.platform;if(0!==t.button||t.ctrlKey&&e||t.target!==this.div)return;if(this.#o1=!0,this.#ls?.isDrawer)return void this.startDrawingSession(t);let i=this.#y.getActive();this.#oY=!i||i.isEmpty()}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),this.#o5)return void this.#ls.startDrawing(this,this.#y,!1,t);this.#y.setCurrentDrawingSession(this),this.#o5=new AbortController;let e=this.#y.combinedSignal(this.#o5);this.div.addEventListener("blur",({relatedTarget:t})=>{t&&!this.div.contains(t)&&(this.#o6=null,this.commitOrRemove())},{signal:e}),this.#ls.startDrawing(this,this.#y,!1,t)}pause(t){if(t){let{activeElement:t}=document;this.div.contains(t)&&(this.#o6=t);return}this.#o6&&setTimeout(()=>{this.#o6?.focus(),this.#o6=null},0)}endDrawingSession(t=!1){return this.#o5?(this.#y.setCurrentDrawingSession(null),this.#o5.abort(),this.#o5=null,this.#o6=null,this.#ls.endDrawing(t)):null}findNewParent(t,e,i){let s=this.#y.findParent(e,i);return null!==s&&s!==this&&(s.changeParent(t),!0)}commitOrRemove(){return!!this.#o5&&(this.endDrawingSession(),!0)}onScaleChanging(){this.#o5&&this.#ls.onScaleChangingWhenDrawing(this)}destroy(){for(let t of(this.commitOrRemove(),this.#y.getActive()?.parent===this&&(this.#y.commitOrRemove(),this.#y.setActiveEditor(null)),this.#oZ&&(clearTimeout(this.#oZ),this.#oZ=null),this.#o0.values()))this.#aU?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#o0.clear(),this.#y.removeLayer(this)}#lt(){for(let t of this.#o0.values())t.isEmpty()&&t.remove()}async render({viewport:t}){for(let e of(this.viewport=t,tm(this.div,t),this.#y.getEditors(this.pageIndex)))this.add(e),e.rebuild();await this.#y.findClonesForPage(this),this.div.hidden=this.isEmpty,this.updateMode()}update({viewport:t}){this.#y.commitOrRemove(),this.#lt();let e=this.viewport.rotation,i=t.rotation;if(this.viewport=t,tm(this.div,{rotation:i}),e!==i)for(let t of this.#o0.values())t.rotate(i)}get pageDimensions(){let{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#y.viewParameters.realScale}}class sU{#ah=null;#ln=new Map;#lo=new Map;static #S=0;setParent(t){if(!this.#ah){this.#ah=t;return}if(this.#ah!==t){if(this.#ln.size>0)for(let e of this.#ln.values())e.remove(),t.append(e);this.#ah=t}}static get _svgFactory(){return M(this,"_svgFactory",new iq)}static #ll(t,[e,i,s,r]){let{style:a}=t;a.top=`${100*i}%`,a.left=`${100*e}%`,a.width=`${100*s}%`,a.height=`${100*r}%`}#lh(){let t=sU._svgFactory.create(1,1,!0);return this.#ah.append(t),t.setAttribute("aria-hidden",!0),t}#ld(t,e){let i=sU._svgFactory.createElement("clipPath");t.append(i);let s=`clip_${e}`;i.setAttribute("id",s),i.setAttribute("clipPathUnits","objectBoundingBox");let r=sU._svgFactory.createElement("use");return i.append(r),r.setAttribute("href",`#${e}`),r.classList.add("clip"),s}#lc(t,e){for(let[i,s]of Object.entries(e))null===s?t.removeAttribute(i):t.setAttribute(i,s)}draw(t,e=!1,i=!1){let s=sU.#S++,r=this.#lh(),a=sU._svgFactory.createElement("defs");r.append(a);let n=sU._svgFactory.createElement("path");a.append(n);let o=`path_${s}`;n.setAttribute("id",o),n.setAttribute("vector-effect","non-scaling-stroke"),e&&this.#lo.set(s,n);let l=i?this.#ld(a,o):null,h=sU._svgFactory.createElement("use");return r.append(h),h.setAttribute("href",`#${o}`),this.updateProperties(r,t),this.#ln.set(s,r),{id:s,clipPathId:`url(#${l})`}}drawOutline(t,e){let i,s=sU.#S++,r=this.#lh(),a=sU._svgFactory.createElement("defs");r.append(a);let n=sU._svgFactory.createElement("path");a.append(n);let o=`path_${s}`;if(n.setAttribute("id",o),n.setAttribute("vector-effect","non-scaling-stroke"),e){let t=sU._svgFactory.createElement("mask");a.append(t),i=`mask_${s}`,t.setAttribute("id",i),t.setAttribute("maskUnits","objectBoundingBox");let e=sU._svgFactory.createElement("rect");t.append(e),e.setAttribute("width","1"),e.setAttribute("height","1"),e.setAttribute("fill","white");let r=sU._svgFactory.createElement("use");t.append(r),r.setAttribute("href",`#${o}`),r.setAttribute("stroke","none"),r.setAttribute("fill","black"),r.setAttribute("fill-rule","nonzero"),r.classList.add("mask")}let l=sU._svgFactory.createElement("use");r.append(l),l.setAttribute("href",`#${o}`),i&&l.setAttribute("mask",`url(#${i})`);let h=l.cloneNode();return r.append(h),l.classList.add("mainOutline"),h.classList.add("secondaryOutline"),this.updateProperties(r,t),this.#ln.set(s,r),s}finalizeDraw(t,e){this.#lo.delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;let{root:i,bbox:s,rootClass:r,path:a}=e,n="number"==typeof t?this.#ln.get(t):t;if(n){if(i&&this.#lc(n,i),s&&sU.#ll(n,s),r){let{classList:t}=n;for(let[e,i]of Object.entries(r))t.toggle(e,i)}if(a){let t=n.firstElementChild.firstElementChild;this.#lc(t,a)}}}updateParent(t,e){if(e===this)return;let i=this.#ln.get(t);i&&(e.#ah.append(i),this.#ln.delete(t),e.#ln.set(t,i))}remove(t){this.#lo.delete(t),null!==this.#ah&&(this.#ln.get(t).remove(),this.#ln.delete(t))}destroy(){for(let t of(this.#ah=null,this.#ln.values()))t.remove();this.#ln.clear(),this.#lo.clear()}}function sH(t){return`${(100*t).toFixed(2)}%`}class sz{#lu=[];#lp=new Map;#lg=null;#lm=0;#s1=0;#s0=0;static #lf=null;constructor(t,e,i,s){this.#lm=t,this.#lu=e,this.#s1=i.rawDims.pageWidth,this.#s0=i.rawDims.pageHeight,this.#lg=s}render(){let t=document.createElement("div");t.className="textLayerImages";for(let e=0;e<this.#lu.length;e+=6){let i=this.#lb(this.#lu.subarray(e,e+6));i&&t.append(i)}return t.addEventListener("contextmenu",t=>{if(!(t.target instanceof HTMLCanvasElement))return;let e=t.target,i=this.#lp.get(e);if(!i)return;let s=sz.#lf?.deref();if(s===e)return;s&&(s.width=0,s.height=0),sz.#lf=new WeakRef(e);let{inverseTransform:r,x1:a,y1:n,width:o,height:l}=i,h=this.#lg(),d=Math.ceil(a*h.width),c=Math.ceil(n*h.height),u=Math.floor((a+o/this.#s1)*h.width),p=Math.floor((n+l/this.#s0)*h.height);e.width=u-d,e.height=p-c;let g=e.getContext("2d");g.setTransform(...r),g.translate(-d,-c),g.drawImage(h,0,0)}),t}#lb([t,e,i,s,r,a]){let n=Math.hypot((r-t)*this.#s1,(a-e)*this.#s0),o=Math.hypot((i-t)*this.#s1,(s-e)*this.#s0);if(n<this.#lm||o<this.#lm)return null;let l=[(r-t)*this.#s1/n,(a-e)*this.#s0/n,(i-t)*this.#s1/o,(s-e)*this.#s0/o,0,0],h=N.inverseTransform(l),d=document.createElement("canvas");return d.className="textLayerImagePlaceholder",d.width=0,d.height=0,Object.assign(d.style,{opacity:0,position:"absolute",left:sH(t),top:sH(e),width:sH(n/this.#s1),height:sH(o/this.#s0),transformOrigin:"0% 0%",transform:`matrix(${l.join(",")})`}),this.#lp.set(d,{inverseTransform:h,width:n,height:o,x1:t,y1:e}),d}}globalThis._pdfjsTestingUtils={HighlightOutliner:sx},globalThis.pdfjsLib={AbortException:L,AnnotationEditorLayer:sN,AnnotationEditorParamsType:p,AnnotationEditorType:u,AnnotationEditorUIManager:tN,AnnotationLayer:sm,AnnotationMode:d,AnnotationType:f,applyOpacity:tA,build:iz,ColorPicker:i$,createValidAbsoluteUrl:T,CSSConstants:tv,DOMSVGFactory:iq,DrawLayer:sU,FeatureTest:O,fetchData:J,findContrastColor:tS,getDocument:iD,getFilenameFromUrl:ts,getPdfFilenameFromUrl:tr,getRGB:tu,getRGBA:tc,getUuid:$,getXfaPageViewport:td,GlobalWorkerOptions:ix,ImageKind:m,InvalidPDFException:I,isDataScheme:te,isPdfFile:ti,isValidExplicitDest:em,makeArr:j,makeMap:V,makeObj:W,MathClamp:X,noContextMenu:to,normalizeUnicode:z,OPS:y,OutputScale:tf,PasswordResponses:v,PDFDataRangeTransport:iB,PDFDateString:th,PDFWorker:iR,PermissionFlag:g,PixelsPerInch:Q,RenderingCancelledException:tt,renderRichText:tE,ResponseException:B,setLayerDimensions:tm,shadow:M,SignatureExtractor:sB,stopEvent:tl,SupportedImageMimeTypes:tb,TextLayer:ik,TextLayerImages:sz,TouchManager:tz,updateUrlHash:S,Util:N,VerbosityLevel:b,version:iH,XfaLayer:K}}}]);
|