@zeniai/web-app-ui 5.0.85-qa → 5.0.86-dev

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.
Files changed (139) hide show
  1. package/dist/assets/AddressRoutes-CGo30rdJ.js +1 -0
  2. package/dist/assets/{AddressScreen-BtcayE54.js → AddressScreen-DqNplF9n.js} +2 -2
  3. package/dist/assets/AiCfoScreen-DY2bTh5X.js +22 -0
  4. package/dist/assets/BillPayApprovalRoutes-BcGyYnYz.js +1 -0
  5. package/dist/assets/{BillPayRoutes-DsFE6diU.js → BillPayRoutes-Dksq93Nt.js} +18 -18
  6. package/dist/assets/{BusinessVerificationPageScreen-DyDPvAa7.js → BusinessVerificationPageScreen-YDSaAbpW.js} +2 -2
  7. package/dist/assets/{ChargeCardRoutes-CSRXXtJq.js → ChargeCardRoutes-o064oMRW.js} +9 -9
  8. package/dist/assets/CompanyPassportScreen-BLW99zDL.js +1 -0
  9. package/dist/assets/ConnectionAuthScreen-Bd0F-_VJ.js +11 -0
  10. package/dist/assets/CustomerOnboardingAuthScreen-Cb43qCFz.js +1 -0
  11. package/dist/assets/{CustomerOnboardingRoutes-l2IJ6Hus.js → CustomerOnboardingRoutes-DJIij8xf.js} +4 -4
  12. package/dist/assets/DashboardRoutes-CS6nJI2P.js +20 -0
  13. package/dist/assets/{DefaultTenantHome-BhXvYXq9.js → DefaultTenantHome-Bl9eDQpG.js} +1 -1
  14. package/dist/assets/DomesticWireDetailScreen-CQO9Kbrv.js +18 -0
  15. package/dist/assets/DrawerScreen-E9PcStEO.js +1 -0
  16. package/dist/assets/EntityDetailRoutes-zw7M1lwQ.js +1 -0
  17. package/dist/assets/ExpenseAutomationRoutes-BHuRnA1t.js +25 -0
  18. package/dist/assets/FeaturePreviewScreen-DtxT93sy.js +1 -0
  19. package/dist/assets/HubSpotOAuthCallbackScreen-DvdLNXNC.js +1 -0
  20. package/dist/assets/{MagicLinkRoutes-g2y4CG2P.js → MagicLinkRoutes-BszO-d0K.js} +21 -21
  21. package/dist/assets/MagicLinkSignInScreen-C_x0l97F.js +12 -0
  22. package/dist/assets/{MobileAppDrawer-CQBNZVi-.js → MobileAppDrawer-D8M7VXe9.js} +1 -1
  23. package/dist/assets/NotFoundScreen-BHqd2QHQ.js +1 -0
  24. package/dist/assets/{NotificationRoutes-CvOb5_M_.js → NotificationRoutes-BF1vgjUU.js} +1 -1
  25. package/dist/assets/OAuthConsentScreen-BR0rJGBP.js +1 -0
  26. package/dist/assets/PandLWithForecastRoutes-DY76dKM1.js +1 -0
  27. package/dist/assets/PeopleRoutes-BtQrBjKV.js +22 -0
  28. package/dist/assets/PerformanceRoutes-DMpi0fOi.js +1 -0
  29. package/dist/assets/{Preview-C8WOe1SB.js → Preview-C8bsUUOu.js} +1 -1
  30. package/dist/assets/{QBOConnectionScreen-DaV5GdQG.js → QBOConnectionScreen-vJXVqwWm.js} +1 -1
  31. package/dist/assets/{ReferralListScreen-Bls1S21T.js → ReferralListScreen-DMiRiZiL.js} +2 -2
  32. package/dist/assets/ReimbursementApprovalRoutes-CkwYBtEW.js +1 -0
  33. package/dist/assets/{ReimbursementApprovalRuleDetailScreen-DbnieOyX.js → ReimbursementApprovalRuleDetailScreen-CmXeAJ2V.js} +1 -1
  34. package/dist/assets/ReimbursementRoutes-C8zQyJK2.js +68 -0
  35. package/dist/assets/ReportsRoutes-BexYmhra.js +1 -0
  36. package/dist/assets/RewardsRoutes-DjXjgRiO.js +1 -0
  37. package/dist/assets/ScreenRoutes-BoNP2LIP.js +2 -0
  38. package/dist/assets/{SettingsRoutes-C6LVb3V1.js → SettingsRoutes-DNp9Aol7.js} +7 -7
  39. package/dist/assets/{SetupPagesScreen-BbYqHHxm.js → SetupPagesScreen-D1bk7eBP.js} +5 -5
  40. package/dist/assets/SignInScreen-Cgfdytgb.js +1 -0
  41. package/dist/assets/SignOutScreen-kKi84Hfg.js +9 -0
  42. package/dist/assets/TaskListScreen-BVNYZTXx.js +9 -0
  43. package/dist/assets/TaskRoutes-BrThx6o_.js +9 -0
  44. package/dist/assets/TransactionDetailRoutes-6MCXCmqq.js +1 -0
  45. package/dist/assets/TransactionDetailScreen-DWs7y2E7.js +5 -0
  46. package/dist/assets/TransactionListRoutes-Y2-dK5Nn.js +1 -0
  47. package/dist/assets/TreasuryRoutes-DlQvHZ4w.js +37 -0
  48. package/dist/assets/{VendorsRoutes-CiiYmal_.js → VendorsRoutes-HIQQTQSi.js} +28 -28
  49. package/dist/assets/WiseConfirmationScreen-C646Mco3.js +12 -0
  50. package/dist/assets/{ZeniAccountRoutes-H-lyZt2Y.js → ZeniAccountRoutes-Kwn8sr_a.js} +12 -12
  51. package/dist/assets/ZeniAccountStatementScreen-BmEJTL09.js +9 -0
  52. package/dist/assets/{accountMappingHelper-CXzOuSqF.js → accountMappingHelper-5LvFlOj7.js} +1 -1
  53. package/dist/assets/{analytics-CRD_Mcgv.js → analytics-BE9oUBzD.js} +1 -1
  54. package/dist/assets/{analyticsHelper-BpXMyiZT.js → analyticsHelper-BEEOw1D6.js} +1 -1
  55. package/dist/assets/{core-BZAtj_dP.js → core-D1cXuJMi.js} +1 -1
  56. package/dist/assets/{decodeURIComponentSafe-K7ukqtFq.js → decodeURIComponentSafe-Did0aZyt.js} +1 -1
  57. package/dist/assets/{dnd-CYktLE_1.js → dnd-DbPPTppj.js} +1 -1
  58. package/dist/assets/{empty-DDhd2rI6.js → empty-BHW5kDnt.js} +1 -1
  59. package/dist/assets/{empty-BtWrOCqn.js → empty-CfqAKA3M.js} +1 -1
  60. package/dist/assets/{emptyVideoElement-Bspjk9Ta.js → emptyVideoElement-BofOruLs.js} +1 -1
  61. package/dist/assets/epic-CUqueK5i.js +2 -0
  62. package/dist/assets/getLocaleForTenant-Dc-_DzRm.js +1 -0
  63. package/dist/assets/{index-DvtTYnxY.js → index-3aBFjHPN.js} +1 -1
  64. package/dist/assets/{index-3xpE1-f9.js → index-B4eiJr7Z.js} +1 -1
  65. package/dist/assets/{index-5Uhv29OT.js → index-BSfz3Hzd.js} +1 -1
  66. package/dist/assets/{index-BOpWIlV0.js → index-CRe2wmI_.js} +1 -1
  67. package/dist/assets/{index-DvJe2aYX.js → index-DF3os92T.js} +2 -2
  68. package/dist/assets/{index-fjLnhDUD.js → index-DjDfMTxy.js} +1 -1
  69. package/dist/assets/{index-l0jEAtpj.js → index-Dr8ZNfvJ.js} +15411 -15406
  70. package/dist/assets/{index-rFU-5LRD.js → index-n6IrYjfy.js} +1 -1
  71. package/dist/assets/{lexical-CtWr-ANo.js → lexical-Du70nM1B.js} +1 -1
  72. package/dist/assets/{liveblocks-B381bPI5.js → liveblocks-Hyy2O23M.js} +1 -1
  73. package/dist/assets/{lottie-M6FrlJUx.js → lottie-qu8VyEpw.js} +1 -1
  74. package/dist/assets/{mui-Ded5Lnjo.js → mui-B2prtfNk.js} +1 -1
  75. package/dist/assets/{pathToGoBack-itTyzDhS.js → pathToGoBack-C7gPpVBh.js} +1 -1
  76. package/dist/assets/{pdf-CXxzr_OL.js → pdf-Cvwxd6W6.js} +4 -4
  77. package/dist/assets/{pdf-lib-BOf1Mpdf.js → pdf-lib-D1w2Ub95.js} +1 -1
  78. package/dist/assets/{plaid-CigRTw2w.js → plaid-4w70Yh4I.js} +1 -1
  79. package/dist/assets/{pusher-DD87NXN7.js → pusher-Bvm9V4qD.js} +1 -1
  80. package/dist/assets/{react-CeRpBRgM.js → react-B4GuIedn.js} +1 -1
  81. package/dist/assets/{react-Ct2u64kQ.js → react-BCjBqrrm.js} +1 -1
  82. package/dist/assets/{react-5meyD7ty.js → react-BZq53fCf.js} +1 -1
  83. package/dist/assets/{react-0OYfftd4.js → react-BfNTrsTo.js} +1 -1
  84. package/dist/assets/{react-TqMAXqlI.js → react-CBBEPwWt.js} +1 -1
  85. package/dist/assets/{react-D4qnCHni.js → react-CUSCkthZ.js} +1 -1
  86. package/dist/assets/{recharts-CxMFTRT8.js → recharts-CrZf7bKF.js} +1 -1
  87. package/dist/assets/routePaths-Dx_nnKk7.js +1 -0
  88. package/dist/assets/{sentry-N_eviIZg.js → sentry-BTyPPF0t.js} +1 -1
  89. package/dist/assets/{url-giMXuS4f.js → url-CsQlFR2d.js} +1 -1
  90. package/dist/assets/{url-tPbFjbci.js → url-Dq7O3gKi.js} +1 -1
  91. package/dist/assets/useAskAiCfoHostNavButtonProps-BxShjiqA.js +1 -0
  92. package/dist/assets/{useDeviceId-DesiQfLG.js → useDeviceId-D81NtSvK.js} +1 -1
  93. package/dist/assets/useFetchSuggestedQuestionsWhenReady-DWTRn_Lu.js +1 -0
  94. package/dist/assets/{useInitialThreadRequest-rt9wsjsl.js → useInitialThreadRequest-WHG7gHcH.js} +1 -1
  95. package/dist/assets/{utils-DvZFRPln.js → utils-C_-saZ2j.js} +1 -1
  96. package/dist/assets/withTransactionSidePanel-DcRhIgzv.js +21 -0
  97. package/dist/assets/{zeni-epic-state-BYztznIU.js → zeni-epic-state-CbUjX_b3.js} +6 -6
  98. package/dist/index.html +1 -1
  99. package/package.json +4 -4
  100. package/dist/assets/AddressRoutes-ByNvllYO.js +0 -1
  101. package/dist/assets/AiCfoScreen-DGB9zDPa.js +0 -22
  102. package/dist/assets/BillPayApprovalRoutes-DNR93njT.js +0 -1
  103. package/dist/assets/CompanyPassportScreen-Bz4mLFh7.js +0 -1
  104. package/dist/assets/ConnectionAuthScreen-ByV6Tmro.js +0 -11
  105. package/dist/assets/CustomerOnboardingAuthScreen-DjBElWhF.js +0 -1
  106. package/dist/assets/DashboardRoutes-BQXZD2Lg.js +0 -20
  107. package/dist/assets/DomesticWireDetailScreen-S8pB6QMG.js +0 -18
  108. package/dist/assets/DrawerScreen-NjKnf1YY.js +0 -1
  109. package/dist/assets/EntityDetailRoutes-zm-3jflF.js +0 -1
  110. package/dist/assets/ExpenseAutomationRoutes-be35OPw4.js +0 -25
  111. package/dist/assets/FeaturePreviewScreen-Bt2H4Z6l.js +0 -1
  112. package/dist/assets/HubSpotOAuthCallbackScreen-C_xNoer0.js +0 -1
  113. package/dist/assets/MagicLinkSignInScreen-Hncas8bE.js +0 -12
  114. package/dist/assets/NotFoundScreen-B-5op0jc.js +0 -1
  115. package/dist/assets/OAuthConsentScreen-BOhp2ut-.js +0 -1
  116. package/dist/assets/PandLWithForecastRoutes-2AFcv1lQ.js +0 -1
  117. package/dist/assets/PeopleRoutes-CokVmeNh.js +0 -22
  118. package/dist/assets/PerformanceRoutes-DFdim8gz.js +0 -1
  119. package/dist/assets/ReimbursementApprovalRoutes-Uulp1bt3.js +0 -1
  120. package/dist/assets/ReimbursementRoutes-CfyEG0Oh.js +0 -68
  121. package/dist/assets/ReportsRoutes-DGF8a5_O.js +0 -1
  122. package/dist/assets/RewardsRoutes-CR3jZvlK.js +0 -1
  123. package/dist/assets/ScreenRoutes-BlUphh6q.js +0 -2
  124. package/dist/assets/SignInScreen-C5U7E7kj.js +0 -1
  125. package/dist/assets/SignOutScreen-f_wBxqm6.js +0 -9
  126. package/dist/assets/TaskListScreen-Jne3kBc1.js +0 -9
  127. package/dist/assets/TaskRoutes-FcXfZbsF.js +0 -9
  128. package/dist/assets/TransactionDetailRoutes-C3foecuN.js +0 -1
  129. package/dist/assets/TransactionDetailScreen-CmMgSwsr.js +0 -5
  130. package/dist/assets/TransactionListRoutes-YIOk2iJl.js +0 -1
  131. package/dist/assets/TreasuryRoutes-CMvaheZZ.js +0 -37
  132. package/dist/assets/WiseConfirmationScreen-B3VNahBo.js +0 -12
  133. package/dist/assets/ZeniAccountStatementScreen-dZ9YFFOZ.js +0 -9
  134. package/dist/assets/epic-CvldkuU3.js +0 -2
  135. package/dist/assets/getLocaleForTenant-B6DiABoj.js +0 -1
  136. package/dist/assets/routePaths-ChRahAmw.js +0 -1
  137. package/dist/assets/useAskAiCfoHostNavButtonProps-DCgVyLJS.js +0 -1
  138. package/dist/assets/useFetchSuggestedQuestionsWhenReady-DhDRKto8.js +0 -1
  139. package/dist/assets/withTransactionSidePanel-D9xxZEyy.js +0 -21
@@ -1,6 +1,6 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/empty-DDhd2rI6.js","assets/sentry-N_eviIZg.js","assets/empty-BtWrOCqn.js","assets/index-5Uhv29OT.js","assets/index-rFU-5LRD.js","assets/zeni-epic-state-BYztznIU.js","assets/core-BZAtj_dP.js","assets/utils-DvZFRPln.js","assets/url-giMXuS4f.js","assets/index-3xpE1-f9.js","assets/index-DvtTYnxY.js","assets/url-tPbFjbci.js"])))=>i.map(i=>d[i]);
2
- import{L as Ns,_ as _e}from"./zeni-epic-state-BYztznIU.js";import{p as Zt,g as fn,a as x}from"./sentry-N_eviIZg.js";import{j as G}from"./liveblocks-B381bPI5.js";import{i as $,c as re}from"./recharts-CxMFTRT8.js";(function(){try{var l=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new l.Error().stack;t&&(l._sentryDebugIds=l._sentryDebugIds||{},l._sentryDebugIds[t]="c91e772f-dc99-45fb-80da-49444f1a3603",l._sentryDebugIdIdentifier="sentry-dbid-c91e772f-dc99-45fb-80da-49444f1a3603")}catch{}})();var is={d:(l,t)=>{for(var e in t)is.o(t,e)&&!is.o(l,e)&&Object.defineProperty(l,e,{enumerable:!0,get:t[e]})},o:(l,t)=>Object.prototype.hasOwnProperty.call(l,t)},T=globalThis.pdfjsLib={};is.d(T,{AbortException:()=>Xt,AnnotationEditorLayer:()=>Pt,AnnotationEditorParamsType:()=>L,AnnotationEditorType:()=>j,AnnotationEditorUIManager:()=>jt,AnnotationLayer:()=>xa,AnnotationMode:()=>Nt,CMapCompressionType:()=>rs,ColorPicker:()=>St,DOMSVGFactory:()=>_s,DrawLayer:()=>ct,FeatureTest:()=>pt,GlobalWorkerOptions:()=>ge,ImageKind:()=>Re,InvalidPDFException:()=>yi,MissingPDFException:()=>Wt,OPS:()=>wt,Outliner:()=>gs,PDFDataRangeTransport:()=>Ni,PDFDateString:()=>Ci,PDFWorker:()=>bt,PasswordResponses:()=>qn,PermissionFlag:()=>wn,PixelsPerInch:()=>ae,RenderingCancelledException:()=>xs,TextLayer:()=>Fe,UnexpectedResponseException:()=>He,Util:()=>k,VerbosityLevel:()=>Ne,XfaLayer:()=>Bi,build:()=>na,createValidAbsoluteUrl:()=>Kn,fetchData:()=>Ge,getDocument:()=>Qr,getFilenameFromUrl:()=>or,getPdfFilenameFromUrl:()=>hr,getXfaPageViewport:()=>lr,isDataScheme:()=>Es,isPdfFile:()=>Ss,noContextMenu:()=>gt,normalizeUnicode:()=>Qn,renderTextLayer:()=>Gr,setLayerDimensions:()=>Gt,shadow:()=>z,updateTextLayer:()=>Ur,version:()=>ia});const dt=!(typeof Zt!="object"||Zt+""!="[object process]"||Zt.versions.nw||Zt.versions.electron&&Zt.type&&Zt.type!=="browser"),bi=[1,0,0,1,0,0],ns=[.001,0,0,.001,0,0],Ke=1.35,mn=1,As=2,Te=4,vn=16,bn=32,An=64,yn=256,Nt={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},j={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},L={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35},wn={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Me=0,Ye=1,he=2,_n=3,js=3,xn=4,Re={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},En=1,Sn=2,Cn=3,kn=4,Mn=5,Rn=6,Tn=7,Pn=8,Ln=9,In=10,Dn=11,Fn=12,On=13,Nn=14,jn=15,Ai=16,Bn=17,Hn=20,$n=1,zn=2,Vn=3,Gn=4,Un=5,Ne={ERRORS:0,WARNINGS:1,INFOS:5},rs={NONE:0,BINARY:1},wt={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},qn={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let je=Ne.WARNINGS;function Wn(l){Number.isInteger(l)&&(je=l)}function Xn(){return je}function Be(l){je>=Ne.INFOS&&console.log(`Info: ${l}`)}function O(l){je>=Ne.WARNINGS&&console.log(`Warning: ${l}`)}function q(l){throw new Error(l)}function nt(l,t){l||q(t)}function Kn(l,t=null,e=null){if(!l)return null;try{if(e&&typeof l=="string"&&(e.addDefaultProtocol&&l.startsWith("www.")&&l.match(/\./g)?.length>=2&&(l=`http://${l}`),e.tryConvertEncoding))try{l=decodeURIComponent(escape(l))}catch{}const s=t?new URL(l,t):new URL(l);if(function(i){switch(i?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(s))return s}catch{}return null}function z(l,t,e,s=!1){return Object.defineProperty(l,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const Ht=function(){function l(t,e){this.constructor===l&&q("Cannot initialize BaseException."),this.message=t,this.name=e}return l.prototype=new Error,l.constructor=l,l}();class as extends Ht{constructor(t,e){super(t,"PasswordException"),this.code=e}}class os extends Ht{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class yi extends Ht{constructor(t){super(t,"InvalidPDFException")}}class Wt extends Ht{constructor(t){super(t,"MissingPDFException")}}class He extends Ht{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}}class Yn extends Ht{constructor(t){super(t,"FormatError")}}class Xt extends Ht{constructor(t){super(t,"AbortException")}}function wi(l){typeof l=="object"&&l?.length!==void 0||q("Invalid argument for bytesToString");const t=l.length,e=8192;if(t<e)return String.fromCharCode.apply(null,l);const s=[];for(let i=0;i<t;i+=e){const n=Math.min(i+e,t),r=l.subarray(i,n);s.push(String.fromCharCode.apply(null,r))}return s.join("")}function $e(l){typeof l!="string"&&q("Invalid argument for stringToBytes");const t=l.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=255&l.charCodeAt(s);return e}function ys(l){const t=Object.create(null);for(const[e,s]of l)t[e]=s;return t}class pt{static get isLittleEndian(){return z(this,"isLittleEndian",function(){const t=new Uint8Array(4);return t[0]=1,new Uint32Array(t.buffer,0,1)[0]===1}())}static get isEvalSupported(){return z(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return z(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get platform(){return typeof navigator<"u"&&typeof navigator?.platform=="string"?z(this,"platform",{isMac:navigator.platform.includes("Mac")}):z(this,"platform",{isMac:!1})}static get isCSSRoundSupported(){return z(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const Qe=Array.from(Array(256).keys(),l=>l.toString(16).padStart(2,"0"));class k{static makeHexColor(t,e,s){return`#${Qe[t]}${Qe[e]}${Qe[s]}`}static scaleMinMax(t,e){let s;t[0]?(t[0]<0&&(s=e[0],e[0]=e[2],e[2]=s),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[3],e[3]*=t[3]):(s=e[0],e[0]=e[1],e[1]=s,s=e[2],e[2]=e[3],e[3]=s,t[1]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(s=e[0],e[0]=e[2],e[2]=s),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static applyTransform(t,e){return[t[0]*e[0]+t[1]*e[2]+e[4],t[0]*e[1]+t[1]*e[3]+e[5]]}static applyInverseTransform(t,e){const s=e[0]*e[3]-e[1]*e[2];return[(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/s,(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/s]}static getAxialAlignedBoundingBox(t,e){const s=this.applyTransform(t,e),i=this.applyTransform(t.slice(2,4),e),n=this.applyTransform([t[0],t[3]],e),r=this.applyTransform([t[2],t[1]],e);return[Math.min(s[0],i[0],n[0],r[0]),Math.min(s[1],i[1],n[1],r[1]),Math.max(s[0],i[0],n[0],r[0]),Math.max(s[1],i[1],n[1],r[1])]}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t){const e=[t[0],t[2],t[1],t[3]],s=t[0]*e[0]+t[1]*e[2],i=t[0]*e[1]+t[1]*e[3],n=t[2]*e[0]+t[3]*e[2],r=t[2]*e[1]+t[3]*e[3],a=(s+r)/2,o=Math.sqrt((s+r)**2-4*(s*r-n*i))/2,h=a+o||1,c=a-o||1;return[Math.sqrt(h),Math.sqrt(c)]}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),i=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>i)return null;const n=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),r=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return n>r?null:[s,n,i,r]}static#t(t,e,s,i,n,r,a,o,h,c){if(h<=0||h>=1)return;const d=1-h,u=h*h,p=u*h,g=d*(d*(d*t+3*h*e)+3*u*s)+p*i,f=d*(d*(d*n+3*h*r)+3*u*a)+p*o;c[0]=Math.min(c[0],g),c[1]=Math.min(c[1],f),c[2]=Math.max(c[2],g),c[3]=Math.max(c[3],f)}static#e(t,e,s,i,n,r,a,o,h,c,d,u){if(Math.abs(h)<1e-12)return void(Math.abs(c)>=1e-12&&this.#t(t,e,s,i,n,r,a,o,-d/c,u));const p=c**2-4*d*h;if(p<0)return;const g=Math.sqrt(p),f=2*h;this.#t(t,e,s,i,n,r,a,o,(-c+g)/f,u),this.#t(t,e,s,i,n,r,a,o,(-c-g)/f,u)}static bezierBoundingBox(t,e,s,i,n,r,a,o,h){return h?(h[0]=Math.min(h[0],t,a),h[1]=Math.min(h[1],e,o),h[2]=Math.max(h[2],t,a),h[3]=Math.max(h[3],e,o)):h=[Math.min(t,a),Math.min(e,o),Math.max(t,a),Math.max(e,o)],this.#e(t,s,n,a,e,i,r,o,3*(3*(s-n)-t+a),6*(t-2*s+n),3*(s-t),h),this.#e(t,s,n,a,e,i,r,o,3*(3*(i-r)-e+o),6*(e-2*i+r),3*(i-e),h),h}}let Je=null,Bs=null;function Qn(l){return Je||(Je=/([\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,Bs=new Map([["ſt","ſt"]])),l.replaceAll(Je,(t,e,s)=>e?e.normalize("NFKC"):Bs.get(s))}const _i="pdfjs_internal_id_",Jn=0,Zn=1,tr=2,er=3,sr=4,ir=5,nr=6,rr=7,ar=8;class Pe{constructor(){this.constructor===Pe&&q("Cannot initialize BaseFilterFactory.")}addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,s,i,n){return"none"}destroy(t=!1){}}class Le{#t=!1;constructor({enableHWA:t=!1}={}){this.constructor===Le&&q("Cannot initialize BaseCanvasFactory."),this.#t=t}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!this.#t})}}reset(t,e,s){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||s<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=s}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){q("Abstract method `_createCanvas` called.")}}class ze{constructor({baseUrl:t=null,isCompressed:e=!0}){this.constructor===ze&&q("Cannot initialize BaseCMapReaderFactory."),this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error('The CMap "baseUrl" parameter must be specified, ensure that the "cMapUrl" and "cMapPacked" API parameters are provided.');if(!t)throw new Error("CMap name must be specified.");const e=this.baseUrl+t+(this.isCompressed?".bcmap":""),s=this.isCompressed?rs.BINARY:rs.NONE;return this._fetchData(e,s).catch(i=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}_fetchData(t,e){q("Abstract method `_fetchData` called.")}}class Ve{constructor({baseUrl:t=null}){this.constructor===Ve&&q("Cannot initialize BaseStandardFontDataFactory."),this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error('The standard font "baseUrl" parameter must be specified, ensure that the "standardFontDataUrl" API parameter is provided.');if(!t)throw new Error("Font filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetchData(e).catch(s=>{throw new Error(`Unable to load font data at: ${e}`)})}_fetchData(t){q("Abstract method `_fetchData` called.")}}class ws{constructor(){this.constructor===ws&&q("Cannot initialize BaseSVGFactory.")}create(t,e,s=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const i=this._createSVG("svg:svg");return i.setAttribute("version","1.1"),s||(i.setAttribute("width",`${t}px`),i.setAttribute("height",`${e}px`)),i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${t} ${e}`),i}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){q("Abstract method `_createSVG` called.")}}const Tt="http://www.w3.org/2000/svg";class ae{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function Ge(l,t="text"){if(de(l,document.baseURI)){const e=await fetch(l);if(!e.ok)throw new Error(e.statusText);switch(t){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"json":return e.json()}return e.text()}return new Promise((e,s)=>{const i=new XMLHttpRequest;i.open("GET",l,!0),i.responseType=t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE)if(i.status!==200&&i.status!==0)s(new Error(i.statusText));else{switch(t){case"arraybuffer":case"blob":case"json":return void e(i.response)}e(i.responseText)}},i.send(null)})}class xi extends ze{_fetchData(t,e){return Ge(t,this.isCompressed?"arraybuffer":"text").then(s=>({cMapData:s instanceof ArrayBuffer?new Uint8Array(s):$e(s),compressionType:e}))}}class Ei extends Ve{_fetchData(t){return Ge(t,"arraybuffer").then(e=>new Uint8Array(e))}}class _s extends ws{_createSVG(t){return document.createElementNS(Tt,t)}}class me{constructor({viewBox:t,scale:e,rotation:s,offsetX:i=0,offsetY:n=0,dontFlip:r=!1}){this.viewBox=t,this.scale=e,this.rotation=s,this.offsetX=i,this.offsetY=n;const a=(t[2]+t[0])/2,o=(t[3]+t[1])/2;let h,c,d,u,p,g,f,v;switch((s%=360)<0&&(s+=360),s){case 180:h=-1,c=0,d=0,u=1;break;case 90:h=0,c=1,d=1,u=0;break;case 270:h=0,c=-1,d=-1,u=0;break;case 0:h=1,c=0,d=0,u=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}r&&(d=-d,u=-u),h===0?(p=Math.abs(o-t[1])*e+i,g=Math.abs(a-t[0])*e+n,f=(t[3]-t[1])*e,v=(t[2]-t[0])*e):(p=Math.abs(a-t[0])*e+i,g=Math.abs(o-t[1])*e+n,f=(t[2]-t[0])*e,v=(t[3]-t[1])*e),this.transform=[h*e,c*e,d*e,u*e,p-h*e*a-d*e*o,g-c*e*a-u*e*o],this.width=f,this.height=v}get rawDims(){const{viewBox:t}=this;return z(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:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:n=!1}={}){return new me({viewBox:this.viewBox.slice(),scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}convertToViewportPoint(t,e){return k.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=k.applyTransform([t[0],t[1]],this.transform),s=k.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){return k.applyInverseTransform([t,e],this.transform)}}class xs extends Ht{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function Es(l){const t=l.length;let e=0;for(;e<t&&l[e].trim()==="";)e++;return l.substring(e,e+5).toLowerCase()==="data:"}function Ss(l){return typeof l=="string"&&/\.pdf$/i.test(l)}function or(l){return[l]=l.split(/[#?]/,1),l.substring(l.lastIndexOf("/")+1)}function hr(l,t="document.pdf"){if(typeof l!="string")return t;if(Es(l))return O('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const e=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,s=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(l);let i=e.exec(s[1])||e.exec(s[2])||e.exec(s[3]);if(i&&(i=i[0],i.includes("%")))try{i=e.exec(decodeURIComponent(i))[0]}catch{}return i||t}class Hs{started=Object.create(null);times=[];time(t){t in this.started&&O(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||O(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let e=0;for(const{name:s}of this.times)e=Math.max(s.length,e);for(const{name:s,start:i,end:n}of this.times)t.push(`${s.padEnd(e)} ${n-i}ms
3
- `);return t.join("")}}function de(l,t){try{const{protocol:e}=t?new URL(l,t):new URL(l);return e==="http:"||e==="https:"}catch{return!1}}function gt(l){l.preventDefault()}function Si(l){console.log("Deprecated API usage: "+l)}let $s;class Ci{static toDateObject(t){if(!t||typeof t!="string")return null;$s||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");const e=$s.exec(t);if(!e)return null;const s=parseInt(e[1],10);let i=parseInt(e[2],10);i=i>=1&&i<=12?i-1:0;let n=parseInt(e[3],10);n=n>=1&&n<=31?n:1;let r=parseInt(e[4],10);r=r>=0&&r<=23?r:0;let a=parseInt(e[5],10);a=a>=0&&a<=59?a:0;let o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;const h=e[7]||"Z";let c=parseInt(e[8],10);c=c>=0&&c<=23?c:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,h==="-"?(r+=c,a+=d):h==="+"&&(r-=c,a-=d),new Date(Date.UTC(s,i,n,r,a,o))}}function lr(l,{scale:t=1,rotation:e=0}){const{width:s,height:i}=l.attributes.style,n=[0,0,parseInt(s),parseInt(i)];return new me({viewBox:n,scale:t,rotation:e})}function hs(l){if(l.startsWith("#")){const t=parseInt(l.slice(1),16);return[(16711680&t)>>16,(65280&t)>>8,255&t]}return l.startsWith("rgb(")?l.slice(4,-1).split(",").map(t=>parseInt(t)):l.startsWith("rgba(")?l.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(O(`Not a valid color format: "${l}"`),[0,0,0])}function K(l){const{a:t,b:e,c:s,d:i,e:n,f:r}=l.getTransform();return[t,e,s,i,n,r]}function Rt(l){const{a:t,b:e,c:s,d:i,e:n,f:r}=l.getTransform().invertSelf();return[t,e,s,i,n,r]}function Gt(l,t,e=!1,s=!0){if(t instanceof me){const{pageWidth:i,pageHeight:n}=t.rawDims,{style:r}=l,a=pt.isCSSRoundSupported,o=`var(--scale-factor) * ${i}px`,h=`var(--scale-factor) * ${n}px`,c=a?`round(${o}, 1px)`:`calc(${o})`,d=a?`round(${h}, 1px)`:`calc(${h})`;e&&t.rotation%180!=0?(r.width=d,r.height=c):(r.width=c,r.height=d)}s&&l.setAttribute("data-main-rotation",t.rotation)}class Cs{#t=null;#e=null;#s;#n=null;constructor(t){this.#s=t}render(){const t=this.#t=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar");const e=this.#s._uiManager._signal;t.addEventListener("contextmenu",gt,{signal:e}),t.addEventListener("pointerdown",Cs.#o,{signal:e});const s=this.#n=document.createElement("div");s.className="buttons",t.append(s);const i=this.#s.toolbarPosition;if(i){const{style:n}=t,r=this.#s._uiManager.direction==="ltr"?1-i[0]:i[0];n.insetInlineEnd=100*r+"%",n.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return this.#c(),t}static#o(t){t.stopPropagation()}#i(t){this.#s._focusEventsAllowed=!1,t.preventDefault(),t.stopPropagation()}#r(t){this.#s._focusEventsAllowed=!0,t.preventDefault(),t.stopPropagation()}#h(t){const e=this.#s._uiManager._signal;t.addEventListener("focusin",this.#i.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#r.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",gt,{signal:e})}hide(){this.#t.classList.add("hidden"),this.#e?.hideDropdown()}show(){this.#t.classList.remove("hidden")}#c(){const t=document.createElement("button");t.className="delete",t.tabIndex=0,t.setAttribute("data-l10n-id",`pdfjs-editor-remove-${this.#s.editorType}-button`),this.#h(t),t.addEventListener("click",e=>{this.#s._uiManager.delete()},{signal:this.#s._uiManager._signal}),this.#n.append(t)}get#d(){const t=document.createElement("div");return t.className="divider",t}addAltTextButton(t){this.#h(t),this.#n.prepend(t,this.#d)}addColorPicker(t){this.#e=t;const e=t.renderButton();this.#h(e),this.#n.prepend(e,this.#d)}remove(){this.#t.remove(),this.#e?.destroy(),this.#e=null}}class cr{#t=null;#e=null;#s;constructor(t){this.#s=t}#n(){const t=this.#e=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",gt,{signal:this.#s._signal});const e=this.#t=document.createElement("div");return e.className="buttons",t.append(e),this.#i(),t}#o(t,e){let s=0,i=0;for(const n of t){const r=n.y+n.height;if(r<s)continue;const a=n.x+(e?n.width:0);r>s?(i=a,s=r):e?a>i&&(i=a):a<i&&(i=a)}return[e?1-i:i,s]}show(t,e,s){const[i,n]=this.#o(e,s),{style:r}=this.#e||=this.#n();t.append(this.#e),r.insetInlineEnd=100*i+"%",r.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){this.#e.remove()}#i(){const t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const s=this.#s._signal;t.addEventListener("contextmenu",gt,{signal:s}),t.addEventListener("click",()=>{this.#s.highlightSelection("floating_button")},{signal:s}),this.#t.append(t)}}function Ie(l,t,e){for(const s of e)t.addEventListener(s,l[s].bind(l))}class dr{#t=0;get id(){return"pdfjs_internal_editor_"+this.#t++}}class ks{#t=function(){if(typeof crypto<"u"&&typeof crypto?.randomUUID=="function")return crypto.randomUUID();const t=new Uint8Array(32);if(typeof crypto<"u"&&typeof crypto?.getRandomValues=="function")crypto.getRandomValues(t);else for(let e=0;e<32;e++)t[e]=Math.floor(255*Math.random());return wi(t)}();#e=0;#s=null;static get _isSVGFittingCanvas(){const 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>',z(this,"_isSVGFittingCanvas",e.decode().then(()=>(t.drawImage(e,0,0,1,1,0,0,1,3),new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0]===0)))}async#n(t,e){this.#s||=new Map;let s=this.#s.get(t);if(s===null)return null;if(s?.bitmap)return s.refCounter+=1,s;try{let i;if(s||={bitmap:null,id:`image_${this.#t}_${this.#e++}`,refCounter:0,isSvg:!1},typeof e=="string"?(s.url=e,i=await Ge(e,"blob")):i=s.file=e,i.type==="image/svg+xml"){const n=ks._isSVGFittingCanvas,r=new FileReader,a=new Image,o=new Promise((h,c)=>{a.onload=()=>{s.bitmap=a,s.isSvg=!0,h()},r.onload=async()=>{const d=s.svgUrl=r.result;a.src=await n?`${d}#svgView(preserveAspectRatio(none))`:d},a.onerror=r.onerror=c});r.readAsDataURL(i),await o}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){console.error(i),s=null}return this.#s.set(t,s),s&&this.#s.set(s.id,s),s}async getFromFile(t){const{lastModified:e,name:s,size:i,type:n}=t;return this.#n(`${e}_${s}_${i}_${n}`,t)}async getFromUrl(t){return this.#n(t,t)}async getFromId(t){this.#s||=new Map;const e=this.#s.get(t);return e?e.bitmap?(e.refCounter+=1,e):e.file?this.getFromFile(e.file):this.getFromUrl(e.url):null}getSvgUrl(t){const e=this.#s.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#s||=new Map;const e=this.#s.get(t);e&&(e.refCounter-=1,e.refCounter===0&&(e.bitmap=null))}isValidId(t){return t.startsWith(`image_${this.#t}_`)}}class ur{#t=[];#e=!1;#s;#n=-1;constructor(t=128){this.#s=t}add({cmd:t,undo:e,post:s,mustExec:i,type:n=NaN,overwriteIfSameType:r=!1,keepUndo:a=!1}){if(i&&t(),this.#e)return;const o={cmd:t,undo:e,post:s,type:n};if(this.#n===-1)return this.#t.length>0&&(this.#t.length=0),this.#n=0,void this.#t.push(o);if(r&&this.#t[this.#n].type===n)return a&&(o.undo=this.#t[this.#n].undo),void(this.#t[this.#n]=o);const h=this.#n+1;h===this.#s?this.#t.splice(0,1):(this.#n=h,h<this.#t.length&&this.#t.splice(h)),this.#t.push(o)}undo(){if(this.#n===-1)return;this.#e=!0;const{undo:t,post:e}=this.#t[this.#n];t(),e?.(),this.#e=!1,this.#n-=1}redo(){if(this.#n<this.#t.length-1){this.#n+=1,this.#e=!0;const{cmd:t,post:e}=this.#t[this.#n];t(),e?.(),this.#e=!1}}hasSomethingToUndo(){return this.#n!==-1}hasSomethingToRedo(){return this.#n<this.#t.length-1}destroy(){this.#t=null}}class ve{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=pt.platform;for(const[s,i,n={}]of t)for(const r of s){const a=r.startsWith("mac+");e&&a?(this.callbacks.set(r.slice(4),{callback:i,options:n}),this.allKeys.add(r.split("+").at(-1))):e||a||(this.callbacks.set(r,{callback:i,options:n}),this.allKeys.add(r.split("+").at(-1)))}}#t(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);const e=this.buffer.join("+");return this.buffer.length=0,e}exec(t,e){if(!this.allKeys.has(e.key))return;const s=this.callbacks.get(this.#t(e));if(!s)return;const{callback:i,options:{bubbles:n=!1,args:r=[],checker:a=null}}=s;a&&!a(t,e)||(i.bind(t,...r,e)(),n||(e.stopPropagation(),e.preventDefault()))}}class Ms{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return function(e){const s=document.createElement("span");s.style.visibility="hidden",document.body.append(s);for(const i of e.keys()){s.style.color=i;const n=window.getComputedStyle(s).color;e.set(i,hs(n))}s.remove()}(t),z(this,"_colors",t)}convert(t){const e=hs(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[s,i]of this._colors)if(i.every((n,r)=>n===e[r]))return Ms._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?k.makeHexColor(...e):t}}class jt{#t=new AbortController;#e=null;#s=new Map;#n=new Map;#o=null;#i=null;#r=null;#h=new ur;#c=0;#d=new Set;#p=null;#l=null;#a=new Set;#g=!1;#m=null;#u=null;#b=null;#f=!1;#A=null;#w=new dr;#x=!1;#S=!1;#C=null;#T=null;#E=null;#y=j.NONE;#v=new Set;#_=null;#k=null;#M=null;#L=this.blur.bind(this);#P=this.focus.bind(this);#F=this.copy.bind(this);#I=this.cut.bind(this);#O=this.paste.bind(this);#D=this.keydown.bind(this);#G=this.keyup.bind(this);#U=this.onEditingAction.bind(this);#z=this.onPageChanging.bind(this);#H=this.onScaleChanging.bind(this);#N=this.onRotationChanging.bind(this);#K={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#V=[0,0];#j=null;#$=null;#Y=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const t=jt.prototype,e=r=>r.#$.contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&r.hasSomethingToControl(),s=(r,{target:a})=>{if(a instanceof HTMLInputElement){const{type:o}=a;return o!=="text"&&o!=="number"}return!0},i=this.TRANSLATE_SMALL,n=this.TRANSLATE_BIG;return z(this,"_keyboardManager",new ve([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],t.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:s}],[["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:s}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&r.#$.contains(a)&&!r.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&r.#$.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}]]))}constructor(t,e,s,i,n,r,a,o,h){this._signal=this.#t.signal,this.#$=t,this.#Y=e,this.#o=s,this._eventBus=i,this._eventBus._on("editingaction",this.#U),this._eventBus._on("pagechanging",this.#z),this._eventBus._on("scalechanging",this.#H),this._eventBus._on("rotationchanging",this.#N),this.#nt(),this.#ht(),this.#Q(),this.#i=n.annotationStorage,this.#m=n.filterFactory,this.#k=r,this.#b=a||null,this.#g=o,this.#E=h||null,this.viewParameters={realScale:ae.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1}destroy(){this.#t?.abort(),this.#t=null,this._signal=null,this._eventBus._off("editingaction",this.#U),this._eventBus._off("pagechanging",this.#z),this._eventBus._off("scalechanging",this.#H),this._eventBus._off("rotationchanging",this.#N);for(const t of this.#n.values())t.destroy();this.#n.clear(),this.#s.clear(),this.#a.clear(),this.#e=null,this.#v.clear(),this.#h.destroy(),this.#o?.destroy(),this.#A?.hide(),this.#A=null,this.#u&&(clearTimeout(this.#u),this.#u=null),this.#j&&(clearTimeout(this.#j),this.#j=null)}async mlGuess(t){return this.#E?.guess(t)||null}get hasMLManager(){return!!this.#E}get hcmFilter(){return z(this,"hcmFilter",this.#k?this.#m.addHCMFilter(this.#k.foreground,this.#k.background):"none")}get direction(){return z(this,"direction",getComputedStyle(this.#$).direction)}get highlightColors(){return z(this,"highlightColors",this.#b?new Map(this.#b.split(",").map(t=>t.split("=").map(e=>e.trim()))):null)}get highlightColorNames(){return z(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}setMainHighlightColorPicker(t){this.#T=t}editAltText(t){this.#o?.editAltText(this,t)}onPageChanging({pageNumber:t}){this.#c=t-1}focusMainContainer(){this.#$.focus()}findParent(t,e){for(const s of this.#n.values()){const{x:i,y:n,width:r,height:a}=s.div.getBoundingClientRect();if(t>=i&&t<=i+r&&e>=n&&e<=n+a)return s}return null}disableUserSelect(t=!1){this.#Y.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#a.add(t)}removeShouldRescale(t){this.#a.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*ae.PDF_TO_CSS_UNITS;for(const e of this.#a)e.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#W({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}highlightSelection(t=""){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:s,anchorOffset:i,focusNode:n,focusOffset:r}=e,a=e.toString(),o=this.#W(e).closest(".textLayer"),h=this.getSelectionBoxes(o);if(h){e.empty(),this.#y===j.NONE&&(this._eventBus.dispatch("showannotationeditorui",{source:this,mode:j.HIGHLIGHT}),this.showAllEditors("highlight",!0,!0));for(const c of this.#n.values())if(c.hasTextLayer(o)){c.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:h,anchorNode:s,anchorOffset:i,focusNode:n,focusOffset:r,text:a});break}}}#st(){const t=document.getSelection();if(!t||t.isCollapsed)return;const e=this.#W(t).closest(".textLayer"),s=this.getSelectionBoxes(e);s&&(this.#A||=new cr(this),this.#A.show(e,s,this.direction==="ltr"))}addToAnnotationStorage(t){t.isEmpty()||!this.#i||this.#i.has(t.id)||this.#i.setValue(t.id,t)}#it(){const t=document.getSelection();if(!t||t.isCollapsed)return void(this.#_&&(this.#A?.hide(),this.#_=null,this.#R({hasSelectedText:!1})));const{anchorNode:e}=t;if(e!==this.#_)if(this.#W(t).closest(".textLayer")){if(this.#A?.hide(),this.#_=e,this.#R({hasSelectedText:!0}),(this.#y===j.HIGHLIGHT||this.#y===j.NONE)&&(this.#y===j.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#f=this.isShiftKeyDown,!this.isShiftKeyDown)){const s=this._signal,i=n=>{n.type==="pointerup"&&n.button!==0||(window.removeEventListener("pointerup",i),window.removeEventListener("blur",i),n.type==="pointerup"&&this.#X("main_toolbar"))};window.addEventListener("pointerup",i,{signal:s}),window.addEventListener("blur",i,{signal:s})}}else this.#_&&(this.#A?.hide(),this.#_=null,this.#R({hasSelectedText:!1}))}#X(t=""){this.#y===j.HIGHLIGHT?this.highlightSelection(t):this.#g&&this.#st()}#nt(){document.addEventListener("selectionchange",this.#it.bind(this),{signal:this._signal})}#rt(){const t=this._signal;window.addEventListener("focus",this.#P,{signal:t}),window.addEventListener("blur",this.#L,{signal:t})}#at(){window.removeEventListener("focus",this.#P),window.removeEventListener("blur",this.#L)}blur(){if(this.isShiftKeyDown=!1,this.#f&&(this.#f=!1,this.#X("main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of this.#v)if(e.div.contains(t)){this.#C=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#C)return;const[t,e]=this.#C;this.#C=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#Q(){const t=this._signal;window.addEventListener("keydown",this.#D,{signal:t}),window.addEventListener("keyup",this.#G,{signal:t})}#ot(){window.removeEventListener("keydown",this.#D),window.removeEventListener("keyup",this.#G)}#J(){const t=this._signal;document.addEventListener("copy",this.#F,{signal:t}),document.addEventListener("cut",this.#I,{signal:t}),document.addEventListener("paste",this.#O,{signal:t})}#Z(){document.removeEventListener("copy",this.#F),document.removeEventListener("cut",this.#I),document.removeEventListener("paste",this.#O)}#ht(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#Q(),this.#J()}removeEditListeners(){this.#ot(),this.#Z()}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of this.#l)if(s.isHandlingMimeForPasting(e))return t.dataTransfer.dropEffect="copy",void t.preventDefault()}drop(t){for(const e of t.dataTransfer.items)for(const s of this.#l)if(s.isHandlingMimeForPasting(e.type))return s.paste(e,this.currentLayer),void t.preventDefault()}copy(t){if(t.preventDefault(),this.#e?.commitOrRemove(),!this.hasSelection)return;const e=[];for(const s of this.#v){const i=s.serialize(!0);i&&e.push(i)}e.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}paste(t){t.preventDefault();const{clipboardData:e}=t;for(const n of e.items)for(const r of this.#l)if(r.isHandlingMimeForPasting(n.type))return void r.paste(n,this.currentLayer);let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(n){return void O(`paste: "${n.message}".`)}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const n=[];for(const o of s){const h=i.deserialize(o);if(!h)return;n.push(h)}const r=()=>{for(const o of n)this.#tt(o);this.#et(n)},a=()=>{for(const o of n)o.remove()};this.addCommands({cmd:r,undo:a,mustExec:!0})}catch(n){O(`paste: "${n.message}".`)}}keydown(t){this.isShiftKeyDown||t.key!=="Shift"||(this.isShiftKeyDown=!0),this.#y===j.NONE||this.isEditorHandlingKeyboard||jt._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,this.#f&&(this.#f=!1,this.#X("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu")}}#R(t){Object.entries(t).some(([e,s])=>this.#K[e]!==s)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#K,t)}),this.#y===j.HIGHLIGHT&&t.hasSelectedEditor===!1&&this.#B([[L.HIGHLIGHT_FREE,!0]]))}#B(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#rt(),this.#J(),this.#R({isEditing:this.#y!==j.NONE,isEmpty:this.#q(),hasSomethingToUndo:this.#h.hasSomethingToUndo(),hasSomethingToRedo:this.#h.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#at(),this.#Z(),this.#R({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#l){this.#l=t;for(const e of this.#l)this.#B(e.defaultPropertiesToUpdate)}}getId(){return this.#w.id}get currentLayer(){return this.#n.get(this.#c)}getLayer(t){return this.#n.get(t)}get currentPageIndex(){return this.#c}addLayer(t){this.#n.set(t.pageIndex,t),this.#x?t.enable():t.disable()}removeLayer(t){this.#n.delete(t.pageIndex)}updateMode(t,e=null,s=!1){if(this.#y!==t){if(this.#y=t,t===j.NONE)return this.setEditingState(!1),void this.#ct();this.setEditingState(!0),this.#lt(),this.unselectAll();for(const i of this.#n.values())i.updateMode(t);if(e||!s){if(e){for(const i of this.#s.values())if(i.annotationElementId===e){this.setSelected(i),i.enterInEditMode();break}}}else this.addNewEditorFromKeyboard()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==this.#y&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){if(this.#l){switch(t){case L.CREATE:return void this.currentLayer.addNewEditor();case L.HIGHLIGHT_DEFAULT_COLOR:this.#T?.updateColor(e);break;case L.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#M||=new Map).set(t,e),this.showAllEditors("highlight",e)}for(const s of this.#v)s.updateParams(t,e);for(const s of this.#l)s.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){for(const i of this.#s.values())i.editorType===t&&i.show(e);(this.#M?.get(L.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#B([[L.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#S!==t){this.#S=t;for(const e of this.#n.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}#lt(){if(!this.#x){this.#x=!0;for(const t of this.#n.values())t.enable();for(const t of this.#s.values())t.enable()}}#ct(){if(this.unselectAll(),this.#x){this.#x=!1;for(const t of this.#n.values())t.disable();for(const t of this.#s.values())t.disable()}}getEditors(t){const e=[];for(const s of this.#s.values())s.pageIndex===t&&e.push(s);return e}getEditor(t){return this.#s.get(t)}addEditor(t){this.#s.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#u&&clearTimeout(this.#u),this.#u=setTimeout(()=>{this.focusMainContainer(),this.#u=null},0)),this.#s.delete(t.id),this.unselect(t),t.annotationElementId&&this.#d.has(t.annotationElementId)||this.#i?.remove(t.id)}addDeletedAnnotationElement(t){this.#d.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#d.has(t)}removeDeletedAnnotationElement(t){this.#d.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#tt(t){const e=this.#n.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#e!==t&&(this.#e=t,t&&this.#B(t.propertiesToUpdate))}get#dt(){let t=null;for(t of this.#v);return t}updateUI(t){this.#dt===t&&this.#B(t.propertiesToUpdate)}toggleSelected(t){if(this.#v.has(t))return this.#v.delete(t),t.unselect(),void this.#R({hasSelectedEditor:this.hasSelection});this.#v.add(t),t.select(),this.#B(t.propertiesToUpdate),this.#R({hasSelectedEditor:!0})}setSelected(t){for(const e of this.#v)e!==t&&e.unselect();this.#v.clear(),this.#v.add(t),t.select(),this.#B(t.propertiesToUpdate),this.#R({hasSelectedEditor:!0})}isSelected(t){return this.#v.has(t)}get firstSelectedEditor(){return this.#v.values().next().value}unselect(t){t.unselect(),this.#v.delete(t),this.#R({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#v.size!==0}get isEnterHandled(){return this.#v.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#h.undo(),this.#R({hasSomethingToUndo:this.#h.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#q()})}redo(){this.#h.redo(),this.#R({hasSomethingToUndo:!0,hasSomethingToRedo:this.#h.hasSomethingToRedo(),isEmpty:this.#q()})}addCommands(t){this.#h.add(t),this.#R({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#q()})}#q(){if(this.#s.size===0)return!0;if(this.#s.size===1)for(const t of this.#s.values())return t.isEmpty();return!1}delete(){if(this.commitOrRemove(),!this.hasSelection)return;const t=[...this.#v];this.addCommands({cmd:()=>{for(const e of t)e.remove()},undo:()=>{for(const e of t)this.#tt(e)},mustExec:!0})}commitOrRemove(){this.#e?.commitOrRemove()}hasSomethingToControl(){return this.#e||this.hasSelection}#et(t){for(const e of this.#v)e.unselect();this.#v.clear();for(const e of t)e.isEmpty()||(this.#v.add(e),e.select());this.#R({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#v)t.commit();this.#et(this.#s.values())}unselectAll(){if((!this.#e||(this.#e.commitOrRemove(),this.#y===j.NONE))&&this.hasSelection){for(const t of this.#v)t.unselect();this.#v.clear(),this.#R({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;this.#V[0]+=t,this.#V[1]+=e;const[i,n]=this.#V,r=[...this.#v];this.#j&&clearTimeout(this.#j),this.#j=setTimeout(()=>{this.#j=null,this.#V[0]=this.#V[1]=0,this.addCommands({cmd:()=>{for(const a of r)this.#s.has(a.id)&&a.translateInPage(i,n)},undo:()=>{for(const a of r)this.#s.has(a.id)&&a.translateInPage(-i,-n)},mustExec:!1})},1e3);for(const a of r)a.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#p=new Map;for(const t of this.#v)this.#p.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#p)return!1;this.disableUserSelect(!1);const t=this.#p;this.#p=null;let e=!1;for(const[{x:i,y:n,pageIndex:r},a]of t)a.newX=i,a.newY=n,a.newPageIndex=r,e||=i!==a.savedX||n!==a.savedY||r!==a.savedPageIndex;if(!e)return!1;const s=(i,n,r,a)=>{if(this.#s.has(i.id)){const o=this.#n.get(a);o?i._setParentAndPosition(o,n,r):(i.pageIndex=a,i.x=n,i.y=r)}};return this.addCommands({cmd:()=>{for(const[i,{newX:n,newY:r,newPageIndex:a}]of t)s(i,n,r,a)},undo:()=>{for(const[i,{savedX:n,savedY:r,savedPageIndex:a}]of t)s(i,n,r,a)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#p)for(const s of this.#p.keys())s.drag(t,e)}rebuild(t){if(t.parent===null){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||this.#v.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#e===t}getActive(){return this.#e}getMode(){return this.#y}get imageManager(){return z(this,"imageManager",new ks)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let h=0,c=e.rangeCount;h<c;h++)if(!t.contains(e.getRangeAt(h).commonAncestorContainer))return null;const{x:s,y:i,width:n,height:r}=t.getBoundingClientRect();let a;switch(t.getAttribute("data-main-rotation")){case"90":a=(h,c,d,u)=>({x:(c-i)/r,y:1-(h+d-s)/n,width:u/r,height:d/n});break;case"180":a=(h,c,d,u)=>({x:1-(h+d-s)/n,y:1-(c+u-i)/r,width:d/n,height:u/r});break;case"270":a=(h,c,d,u)=>({x:1-(c+u-i)/r,y:(h-s)/n,width:u/r,height:d/n});break;default:a=(h,c,d,u)=>({x:(h-s)/n,y:(c-i)/r,width:d/n,height:u/r})}const o=[];for(let h=0,c=e.rangeCount;h<c;h++){const d=e.getRangeAt(h);if(!d.collapsed)for(const{x:u,y:p,width:g,height:f}of d.getClientRects())g!==0&&f!==0&&o.push(a(u,p,g,f))}return o.length===0?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#r||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#r?.delete(t)}renderAnnotationElement(t){const e=this.#r?.get(t.data.id);if(!e)return;const s=this.#i.getRawValue(e);s&&(this.#y!==j.NONE||s.hasBeenModified)&&s.renderAnnotationElement(t)}}class $t{#t="";#e=!1;#s=null;#n=null;#o=null;#i=!1;#r=null;static _l10nPromise=null;constructor(t){this.#r=t}static initialize(t){$t._l10nPromise||=t}async render(){const t=this.#s=document.createElement("button");t.className="altText";const e=await $t._l10nPromise.get("pdfjs-editor-alt-text-button-label");t.textContent=e,t.setAttribute("aria-label",e),t.tabIndex="0";const s=this.#r._uiManager._signal;t.addEventListener("contextmenu",gt,{signal:s}),t.addEventListener("pointerdown",n=>n.stopPropagation(),{signal:s});const i=n=>{n.preventDefault(),this.#r._uiManager.editAltText(this.#r)};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",n=>{n.target===t&&n.key==="Enter"&&(this.#i=!0,i(n))},{signal:s}),await this.#h(),t}finish(){this.#s&&(this.#s.focus({focusVisible:this.#i}),this.#i=!1)}isEmpty(){return!this.#t&&!this.#e}get data(){return{altText:this.#t,decorative:this.#e}}set data({altText:t,decorative:e}){this.#t===t&&this.#e===e||(this.#t=t,this.#e=e,this.#h())}toggle(t=!1){this.#s&&(!t&&this.#o&&(clearTimeout(this.#o),this.#o=null),this.#s.disabled=!t)}destroy(){this.#s?.remove(),this.#s=null,this.#n=null}async#h(){const t=this.#s;if(!t)return;if(!this.#t&&!this.#e)return t.classList.remove("done"),void this.#n?.remove();t.classList.add("done"),$t._l10nPromise.get("pdfjs-editor-alt-text-edit-button-label").then(i=>{t.setAttribute("aria-label",i)});let e=this.#n;if(!e){this.#n=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip");const i=e.id=`alt-text-tooltip-${this.#r.id}`;t.setAttribute("aria-describedby",i);const n=100,r=this.#r._uiManager._signal;r.addEventListener("abort",()=>{clearTimeout(this.#o),this.#o=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#o=setTimeout(()=>{this.#o=null,this.#n.classList.add("show"),this.#r._reportTelemetry({action:"alt_text_tooltip"})},n)},{signal:r}),t.addEventListener("mouseleave",()=>{this.#o&&(clearTimeout(this.#o),this.#o=null),this.#n?.classList.remove("show")},{signal:r})}e.innerText=this.#e?await $t._l10nPromise.get("pdfjs-editor-alt-text-decorative-tooltip"):this.#t,e.parentNode||t.append(e),this.#r.getImageForAltText()?.setAttribute("aria-describedby",e.id)}}class P{#t=null;#e=null;#s=null;#n=!1;#o=!1;#i=null;#r=null;#h=this.focusin.bind(this);#c=this.focusout.bind(this);#d=null;#p="";#l=!1;#a=null;#g=!1;#m=!1;#u=!1;#b=null;#f=0;#A=0;#w=null;_initialOptions=Object.create(null);_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;_l10nPromise=null;#x=!1;#S=P._zIndex++;static _borderLineWidth=-1;static _colorManager=new Ms;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=P.prototype._resizeWithKeyboard,e=jt.TRANSLATE_SMALL,s=jt.TRANSLATE_BIG;return z(this,"_resizerKeyboardManager",new ve([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-s,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[s,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-s]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,s]}],[["Escape","mac+Escape"],P.prototype._stopResizingWithKeyboard]]))}constructor(t){this.constructor===P&&q("Cannot initialize AnnotationEditor."),this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null;const{rotation:e,rawDims:{pageWidth:s,pageHeight:i,pageX:n,pageY:r}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[n,r];const[a,o]=this.parentDimensions;this.x=t.x/a,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return z(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new pr({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e,s){if(P._l10nPromise||=new Map(["pdfjs-editor-alt-text-button-label","pdfjs-editor-alt-text-edit-button-label","pdfjs-editor-alt-text-decorative-tooltip","pdfjs-editor-resizer-label-topLeft","pdfjs-editor-resizer-label-topMiddle","pdfjs-editor-resizer-label-topRight","pdfjs-editor-resizer-label-middleRight","pdfjs-editor-resizer-label-bottomRight","pdfjs-editor-resizer-label-bottomMiddle","pdfjs-editor-resizer-label-bottomLeft","pdfjs-editor-resizer-label-middleLeft"].map(n=>[n,t.get(n.replaceAll(/([A-Z])/g,r=>`-${r.toLowerCase()}`))])),s?.strings)for(const n of s.strings)P._l10nPromise.set(n,t.get(n));if(P._borderLineWidth!==-1)return;const i=getComputedStyle(document.documentElement);P._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){q("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#x}set _isDraggable(t){this.#x=t,this.div?.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(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.#S}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):this.#D(),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#l?this.#l=!1:this.parent.setSelected(this))}focusout(t){if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;t.relatedTarget?.closest(`#${this.id}`)||(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,s,i){const[n,r]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/n,this.y=(e+i)/r,this.fixAndSetPosition()}#C([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this.fixAndSetPosition()}translate(t,e){this.#C(this.parentDimensions,t,e)}translateInPage(t,e){this.#a||=[this.x,this.y],this.#C(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){this.#a||=[this.x,this.y];const[s,i]=this.parentDimensions;if(this.x+=t/s,this.y+=e/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:h,y:c}=this.div.getBoundingClientRect();this.parent.findNewParent(this,h,c)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:n,y:r}=this;const[a,o]=this.getBaseTranslation();n+=a,r+=o,this.div.style.left=`${(100*n).toFixed(2)}%`,this.div.style.top=`${(100*r).toFixed(2)}%`,this.div.scrollIntoView({block:"nearest"})}get _hasBeenMoved(){return!!this.#a&&(this.#a[0]!==this.x||this.#a[1]!==this.y)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=P,i=s/t,n=s/e;switch(this.rotation){case 90:return[-i,n];case 180:return[i,n];case 270:return[i,-n];default:return[-i,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const[e,s]=this.pageDimensions;let{x:i,y:n,width:r,height:a}=this;if(r*=e,a*=s,i*=e,n*=s,this._mustFixPosition)switch(t){case 0:i=Math.max(0,Math.min(e-r,i)),n=Math.max(0,Math.min(s-a,n));break;case 90:i=Math.max(0,Math.min(e-a,i)),n=Math.min(s,Math.max(r,n));break;case 180:i=Math.min(e,Math.max(r,i)),n=Math.min(s,Math.max(a,n));break;case 270:i=Math.min(e,Math.max(a,i)),n=Math.max(0,Math.min(s-r,n))}this.x=i/=e,this.y=n/=s;const[o,h]=this.getBaseTranslation();i+=o,n+=h;const{style:c}=this.div;c.left=`${(100*i).toFixed(2)}%`,c.top=`${(100*n).toFixed(2)}%`,this.moveInDOM()}static#T(t,e,s){switch(s){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return P.#T(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return P.#T(t,e,360-this.parentRotation)}#E(t){switch(t){case 90:{const[e,s]=this.pageDimensions;return[0,-e/s,s/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,s]=this.pageDimensions;return[0,e/s,-s/e,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,s]}=this,i=e*t,n=s*t;return pt.isCSSRoundSupported?[Math.round(i),Math.round(n)]:[i,n]}setDims(t,e){const[s,i]=this.parentDimensions;this.div.style.width=`${(100*t/s).toFixed(2)}%`,this.#o||(this.div.style.height=`${(100*e/i).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:s}=t,i=s.endsWith("%"),n=!this.#o&&e.endsWith("%");if(i&&n)return;const[r,a]=this.parentDimensions;i||(t.width=`${(100*parseFloat(s)/r).toFixed(2)}%`),this.#o||n||(t.height=`${(100*parseFloat(e)/a).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#y(){if(this.#i)return;this.#i=document.createElement("div"),this.#i.classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const s of t){const i=document.createElement("div");this.#i.append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",this.#v.bind(this,s),{signal:e}),i.addEventListener("contextmenu",gt,{signal:e}),i.tabIndex=-1}this.div.prepend(this.#i)}#v(t,e){e.preventDefault();const{isMac:s}=pt.platform;if(e.button!==0||e.ctrlKey&&s)return;this.#s?.toggle(!1);const i=this.#k.bind(this,t),n=this._isDraggable;this._isDraggable=!1;const r=this._uiManager._signal,a={passive:!0,capture:!0,signal:r};this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",i,a),window.addEventListener("contextmenu",gt,{signal:r});const o=this.x,h=this.y,c=this.width,d=this.height,u=this.parent.div.style.cursor,p=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const g=()=>{this.parent.togglePointerEvents(!0),this.#s?.toggle(!0),this._isDraggable=n,window.removeEventListener("pointerup",g),window.removeEventListener("blur",g),window.removeEventListener("pointermove",i,a),window.removeEventListener("contextmenu",gt),this.parent.div.style.cursor=u,this.div.style.cursor=p,this.#_(o,h,c,d)};window.addEventListener("pointerup",g,{signal:r}),window.addEventListener("blur",g,{signal:r})}#_(t,e,s,i){const n=this.x,r=this.y,a=this.width,o=this.height;n===t&&r===e&&a===s&&o===i||this.addCommands({cmd:()=>{this.width=a,this.height=o,this.x=n,this.y=r;const[h,c]=this.parentDimensions;this.setDims(h*a,c*o),this.fixAndSetPosition()},undo:()=>{this.width=s,this.height=i,this.x=t,this.y=e;const[h,c]=this.parentDimensions;this.setDims(h*s,c*i),this.fixAndSetPosition()},mustExec:!0})}#k(t,e){const[s,i]=this.parentDimensions,n=this.x,r=this.y,a=this.width,o=this.height,h=P.MIN_SIZE/s,c=P.MIN_SIZE/i,d=R=>Math.round(1e4*R)/1e4,u=this.#E(this.rotation),p=(R,F)=>[u[0]*R+u[2]*F,u[1]*R+u[3]*F],g=this.#E(360-this.rotation);let f,v,m=!1,b=!1;switch(t){case"topLeft":m=!0,f=(R,F)=>[0,0],v=(R,F)=>[R,F];break;case"topMiddle":f=(R,F)=>[R/2,0],v=(R,F)=>[R/2,F];break;case"topRight":m=!0,f=(R,F)=>[R,0],v=(R,F)=>[0,F];break;case"middleRight":b=!0,f=(R,F)=>[R,F/2],v=(R,F)=>[0,F/2];break;case"bottomRight":m=!0,f=(R,F)=>[R,F],v=(R,F)=>[0,0];break;case"bottomMiddle":f=(R,F)=>[R/2,F],v=(R,F)=>[R/2,0];break;case"bottomLeft":m=!0,f=(R,F)=>[0,F],v=(R,F)=>[R,0];break;case"middleLeft":b=!0,f=(R,F)=>[0,F/2],v=(R,F)=>[R,F/2]}const A=f(a,o),w=v(a,o);let _=p(...w);const y=d(n+_[0]),E=d(r+_[1]);let S=1,C=1,[I,M]=this.screenToPageTranslation(e.movementX,e.movementY);var W,D;if([I,M]=(W=I/s,D=M/i,[g[0]*W+g[2]*D,g[1]*W+g[3]*D]),m){const R=Math.hypot(a,o);S=C=Math.max(Math.min(Math.hypot(w[0]-A[0]-I,w[1]-A[1]-M)/R,1/a,1/o),h/a,c/o)}else b?S=Math.max(h,Math.min(1,Math.abs(w[0]-A[0]-I)))/a:C=Math.max(c,Math.min(1,Math.abs(w[1]-A[1]-M)))/o;const B=d(a*S),U=d(o*C);_=p(...v(B,U));const Y=y-_[0],J=E-_[1];this.width=B,this.height=U,this.x=Y,this.y=J,this.setDims(s*B,i*U),this.fixAndSetPosition()}altTextFinish(){this.#s?.finish()}async addEditToolbar(){return this.#d||this.#m||(this.#d=new Cs(this),this.div.append(this.#d.render()),this.#s&&this.#d.addAltTextButton(await this.#s.render())),this.#d}removeEditToolbar(){this.#d&&(this.#d.remove(),this.#d=null,this.#s?.destroy())}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#s||($t.initialize(P._l10nPromise),this.#s=new $t(this),this.#t&&(this.#s.data=this.#t,this.#t=null),await this.addEditToolbar())}get altTextData(){return this.#s?.data}set altTextData(t){this.#s&&(this.#s.data=t)}hasAltText(){return!this.#s?.isEmpty()}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=this.#n?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground();const t=this._uiManager._signal;this.div.addEventListener("focusin",this.#h,{signal:t}),this.div.addEventListener("focusout",this.#c,{signal:t});const[e,s]=this.parentDimensions;this.parentRotation%180!=0&&(this.div.style.maxWidth=`${(100*s/e).toFixed(2)}%`,this.div.style.maxHeight=`${(100*e/s).toFixed(2)}%`);const[i,n]=this.getInitialTranslation();return this.translate(i,n),Ie(this,this.div,["pointerdown"]),this.div}pointerdown(t){const{isMac:e}=pt.platform;t.button!==0||t.ctrlKey&&e?t.preventDefault():(this.#l=!0,this._isDraggable?this.#L(t):this.#M(t))}#M(t){const{isMac:e}=pt.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#L(t){const e=this._uiManager.isSelected(this);let s,i;this._uiManager.setUpDragSession();const n=this._uiManager._signal;e&&(this.div.classList.add("moving"),s={passive:!0,capture:!0,signal:n},this.#f=t.clientX,this.#A=t.clientY,i=a=>{const{clientX:o,clientY:h}=a,[c,d]=this.screenToPageTranslation(o-this.#f,h-this.#A);this.#f=o,this.#A=h,this._uiManager.dragSelectedEditors(c,d)},window.addEventListener("pointermove",i,s));const r=()=>{window.removeEventListener("pointerup",r),window.removeEventListener("blur",r),e&&(this.div.classList.remove("moving"),window.removeEventListener("pointermove",i,s)),this.#l=!1,this._uiManager.endDragSession()||this.#M(t)};window.addEventListener("pointerup",r,{signal:n}),window.addEventListener("blur",r,{signal:n})}moveInDOM(){this.#b&&clearTimeout(this.#b),this.#b=setTimeout(()=>{this.#b=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition()}getRect(t,e,s=this.rotation){const i=this.parentScale,[n,r]=this.pageDimensions,[a,o]=this.pageTranslation,h=t/i,c=e/i,d=this.x*n,u=this.y*r,p=this.width*n,g=this.height*r;switch(s){case 0:return[d+h+a,r-u-c-g+o,d+h+p+a,r-u-c+o];case 90:return[d+c+a,r-u+h+o,d+c+g+a,r-u+h+p+o];case 180:return[d-h-p+a,r-u+c+o,d-h+a,r-u+c+g+o];case 270:return[d-c-g+a,r-u-h-p+o,d-c+a,r-u-h+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,i,n,r]=t,a=n-s,o=r-i;switch(this.rotation){case 0:return[s,e-r,a,o];case 90:return[s,e-i,o,a];case 180:return[n,e-i,a,o];case 270:return[n,e-r,o,a];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){this.#m=!0}disableEditMode(){this.#m=!1}isInEditMode(){return this.#m}shouldGetKeyboardEvents(){return this.#u}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){const t=this._uiManager._signal;this.div?.addEventListener("focusin",this.#h,{signal:t}),this.div?.addEventListener("focusout",this.#c,{signal:t})}rotate(t){}serialize(t=!1,e=null){q("An editor must be serializable")}static deserialize(t,e,s){const i=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:s});i.rotation=t.rotation,i.#t=t.accessibilityData;const[n,r]=i.pageDimensions,[a,o,h,c]=i.getRectInCurrentCoords(t.rect,r);return i.x=a/n,i.y=o/r,i.width=h/n,i.height=c/r,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.div.removeEventListener("focusin",this.#h),this.div.removeEventListener("focusout",this.#c),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#b&&(clearTimeout(this.#b),this.#b=null),this.#D(),this.removeEditToolbar(),this.#w){for(const t of this.#w.values())clearTimeout(t);this.#w=null}this.parent=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#y(),this.#i.classList.remove("hidden"),Ie(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),this.#r={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#i.children;if(!this.#e){this.#e=Array.from(e);const r=this.#P.bind(this),a=this.#F.bind(this),o=this._uiManager._signal;for(const h of this.#e){const c=h.getAttribute("data-resizer-name");h.setAttribute("role","spinbutton"),h.addEventListener("keydown",r,{signal:o}),h.addEventListener("blur",a,{signal:o}),h.addEventListener("focus",this.#I.bind(this,c),{signal:o}),P._l10nPromise.get(`pdfjs-editor-resizer-label-${c}`).then(d=>h.setAttribute("aria-label",d))}}const s=this.#e[0];let i=0;for(const r of e){if(r===s)break;i++}const n=(360-this.rotation+this.parentRotation)%360/90*(this.#e.length/4);if(n!==i){if(n<i)for(let a=0;a<i-n;a++)this.#i.append(this.#i.firstChild);else if(n>i)for(let a=0;a<n-i;a++)this.#i.firstChild.before(this.#i.lastChild);let r=0;for(const a of e){const o=this.#e[r++].getAttribute("data-resizer-name");P._l10nPromise.get(`pdfjs-editor-resizer-label-${o}`).then(h=>a.setAttribute("aria-label",h))}}this.#O(0),this.#u=!0,this.#i.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#P(t){P._resizerKeyboardManager.exec(this,t)}#F(t){this.#u&&t.relatedTarget?.parentNode!==this.#i&&this.#D()}#I(t){this.#p=this.#u?t:""}#O(t){if(this.#e)for(const e of this.#e)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#u&&this.#k(this.#p,{movementX:t,movementY:e})}#D(){if(this.#u=!1,this.#O(-1),this.#r){const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=this.#r;this.#_(t,e,s,i),this.#r=null}}_stopResizingWithKeyboard(){this.#D(),this.div.focus()}select(){this.makeResizable(),this.div?.classList.add("selectedEditor"),this.#d?this.#d?.show():this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this.#d?.show()})}unselect(){this.#i?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this.#d?.hide()}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#g}set isEditing(t){this.#g=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){this.#o=!0;const s=t/e,{style:i}=this.div;i.aspectRatio=s,i.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,e=!1){if(e){this.#w||=new Map;const{action:s}=t;let i=this.#w.get(s);return i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),this.#w.delete(s),this.#w.size===0&&(this.#w=null)},P._telemetryTimeout),void this.#w.set(s,i)}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.#n=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#n=!0}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent");if(e){if(e.nodeName==="CANVAS"){const s=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),s.before(e)}}else e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){const{firstChild:e}=t.container;e.nodeName==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}}class pr extends P{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex}}}const zs=3285377520,vt=4294901760,Ft=65535;class ki{constructor(t){this.h1=t?4294967295&t:zs,this.h2=t?4294967295&t:zs}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(2*t.length),s=0;for(let f=0,v=t.length;f<v;f++){const m=t.charCodeAt(f);m<=255?e[s++]=m:(e[s++]=m>>>8,e[s++]=255&m)}}else{if(!ArrayBuffer.isView(t))throw new Error("Invalid data format, must be a string or TypedArray.");e=t.slice(),s=e.byteLength}const i=s>>2,n=s-4*i,r=new Uint32Array(e.buffer,0,i);let a=0,o=0,h=this.h1,c=this.h2;const d=3432918353,u=461845907,p=11601,g=13715;for(let f=0;f<i;f++)1&f?(a=r[f],a=a*d&vt|a*p&Ft,a=a<<15|a>>>17,a=a*u&vt|a*g&Ft,h^=a,h=h<<13|h>>>19,h=5*h+3864292196):(o=r[f],o=o*d&vt|o*p&Ft,o=o<<15|o>>>17,o=o*u&vt|o*g&Ft,c^=o,c=c<<13|c>>>19,c=5*c+3864292196);switch(a=0,n){case 3:a^=e[4*i+2]<<16;case 2:a^=e[4*i+1]<<8;case 1:a^=e[4*i],a=a*d&vt|a*p&Ft,a=a<<15|a>>>17,a=a*u&vt|a*g&Ft,1&i?h^=a:c^=a}this.h1=h,this.h2=c}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=3981806797*t&vt|36045*t&Ft,e=4283543511*e&vt|(2950163797*(e<<16|t>>>16)&vt)>>>16,t^=e>>>1,t=444984403*t&vt|60499*t&Ft,e=3301882366*e&vt|(3120437893*(e<<16|t>>>16)&vt)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const ls=Object.freeze({map:null,hash:"",transfer:void 0});class Rs{#t=!1;#e=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const s=this.#e.get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return this.#e.get(t)}remove(t){if(this.#e.delete(t),this.#e.size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const e of this.#e.values())if(e instanceof P)return;this.onAnnotationEditor(null)}}setValue(t,e){const s=this.#e.get(t);let i=!1;if(s!==void 0)for(const[n,r]of Object.entries(e))s[n]!==r&&(i=!0,s[n]=r);else i=!0,this.#e.set(t,e);i&&this.#s(),e instanceof P&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type)}has(t){return this.#e.has(t)}getAll(){return this.#e.size>0?ys(this.#e):null}setAll(t){for(const[e,s]of Object.entries(t))this.setValue(e,s)}get size(){return this.#e.size}#s(){this.#t||(this.#t=!0,typeof this.onSetModified=="function"&&this.onSetModified())}resetModified(){this.#t&&(this.#t=!1,typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new Mi(this)}get serializable(){if(this.#e.size===0)return ls;const t=new Map,e=new ki,s=[],i=Object.create(null);let n=!1;for(const[r,a]of this.#e){const o=a instanceof P?a.serialize(!1,i):a;o&&(t.set(r,o),e.update(`${r}:${JSON.stringify(o)}`),n||=!!o.bitmap)}if(n)for(const r of t.values())r.bitmap&&s.push(r.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:ls}get editorStats(){let t=null;const e=new Map;for(const s of this.#e.values()){if(!(s instanceof P))continue;const i=s.telemetryFinalData;if(!i)continue;const{type:n}=i;e.has(n)||e.set(n,Object.getPrototypeOf(s).constructor),t||=Object.create(null);const r=t[n]||=new Map;for(const[a,o]of Object.entries(i)){if(a==="type")continue;let h=r.get(a);h||(h=new Map,r.set(a,h));const c=h.get(o)??0;h.set(o,c+1)}}for(const[s,i]of e)t[s]=i.computeTelemetryFinalData(t[s]);return t}}class Mi extends Rs{#t;constructor(t){super();const{map:e,hash:s,transfer:i}=t.serializable,n=structuredClone(e,i?{transfer:i}:null);this.#t={map:n,hash:s,transfer:i}}get print(){q("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#t}}class gr{#t=new Set;constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),this.#t.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(t&&!this.#t.has(t.loadedName))if(nt(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:s,src:i,style:n}=t,r=new FontFace(s,i,n);this.addNativeFontFace(r);try{await r.load(),this.#t.add(s),e?.(t)}catch{O(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(r)}}else q("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){const s=t.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(i){throw O(`Failed to load font '${s.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(s=>{const i=this._queueLoadingCallback(s);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){return z(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){let t=!1;return(dt||typeof navigator<"u"&&typeof navigator?.userAgent=="string"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),z(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){const{loadingRequests:e}=this,s={done:!1,complete:function(){for(nt(!s.done,"completeRequest() cannot be called twice."),s.done=!0;e.length>0&&e[0].done;){const i=e.shift();setTimeout(i.callback,0)}},callback:t};return e.push(s),s}get _loadTestFont(){return z(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){function s(m,b){return m.charCodeAt(b)<<24|m.charCodeAt(b+1)<<16|m.charCodeAt(b+2)<<8|255&m.charCodeAt(b+3)}function i(m,b,A,w){return m.substring(0,b)+w+m.substring(b+A)}let n,r;const a=this._document.createElement("canvas");a.width=1,a.height=1;const o=a.getContext("2d");let h=0;const c=`lt${Date.now()}${this.loadTestFontId++}`;let d=this._loadTestFont;d=i(d,976,c.length,c);const u=1482184792;let p=s(d,16);for(n=0,r=c.length-3;n<r;n+=4)p=p-u+s(c,n)|0;var g;n<c.length&&(p=p-u+s(c+"XXX",n)|0),d=i(d,16,4,(g=p,String.fromCharCode(g>>24&255,g>>16&255,g>>8&255,255&g)));const f=`@font-face {font-family:"${c}";src:${`url(data:font/opentype;base64,${btoa(d)});`}}`;this.insertRule(f);const v=this._document.createElement("div");v.style.visibility="hidden",v.style.width=v.style.height="10px",v.style.position="absolute",v.style.top=v.style.left="0px";for(const m of[t.loadedName,c]){const b=this._document.createElement("span");b.textContent="Hi",b.style.fontFamily=m,v.append(b)}this._document.body.append(v),function m(b,A){if(++h>30)return O("Load test font never loaded."),void A();o.font="30px "+b,o.fillText(".",0,20),o.getImageData(0,0,1,1).data[3]>0?A():setTimeout(m.bind(null,b,A))}(c,()=>{v.remove(),e.complete()})}}class fr{constructor(t,{disableFontFace:e=!1,inspectFont:s=null}){this.compiledGlyphs=Object.create(null);for(const i in t)this[i]=t[i];this.disableFontFace=e===!0,this._inspectFont=s}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(this.cssFontInfo){const e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}else t=new FontFace(this.loadedName,this.data,{});return this._inspectFont?.(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const t=wi(this.data),e=`url(data:${this.mimetype};base64,${btoa(t)});`;let s;if(this.cssFontInfo){let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),s=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${e}}`}else s=`@font-face {font-family:"${this.loadedName}";src:${e}}`;return this._inspectFont?.(this,e),s}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];let s;try{s=t.get(this.loadedName+"_path_"+e)}catch(n){O(`getPathGenerator - ignoring character: "${n}".`)}if(!Array.isArray(s)||s.length===0)return this.compiledGlyphs[e]=function(n,r){};const i=[];for(let n=0,r=s.length;n<r;)switch(s[n++]){case Jn:{const[a,o,h,c,d,u]=s.slice(n,n+6);i.push(p=>p.bezierCurveTo(a,o,h,c,d,u)),n+=6}break;case Zn:{const[a,o]=s.slice(n,n+2);i.push(h=>h.moveTo(a,o)),n+=2}break;case tr:{const[a,o]=s.slice(n,n+2);i.push(h=>h.lineTo(a,o)),n+=2}break;case er:{const[a,o,h,c]=s.slice(n,n+4);i.push(d=>d.quadraticCurveTo(a,o,h,c)),n+=4}break;case sr:i.push(a=>a.restore());break;case ir:i.push(a=>a.save());break;case nr:nt(i.length===2,"Scale command is only valid at the third position.");break;case rr:{const[a,o,h,c,d,u]=s.slice(n,n+6);i.push(p=>p.transform(a,o,h,c,d,u)),n+=6}break;case ar:{const[a,o]=s.slice(n,n+2);i.push(h=>h.translate(a,o)),n+=2}}return this.compiledGlyphs[e]=function(n,r){i[0](n),i[1](n),n.scale(r,-r);for(let a=2,o=i.length;a<o;a++)i[a](n)}}}if(dt){var cs=Promise.withResolvers(),ds=null;(async()=>{const l=await _e(()=>import("./empty-DDhd2rI6.js").then(i=>i.e),__vite__mapDeps([0,1,2])),t=await _e(()=>import("./index-5Uhv29OT.js").then(i=>i.i),__vite__mapDeps([3,1,4,5,6,7,8])),e=await _e(()=>import("./index-3xpE1-f9.js").then(i=>i.i),__vite__mapDeps([9,1,10,4,5,6,7,8])),s=await _e(()=>import("./url-tPbFjbci.js").then(i=>i.u),__vite__mapDeps([11,1,8,7,5,6]));return new Map(Object.entries({fs:l,http:t,https:e,url:s,canvas:void 0,path2d:void 0}))})().then(l=>{ds=l,cs.resolve()},l=>{O(`loadPackages: ${l}`),ds=new Map,cs.resolve()})}class kt{static get promise(){return cs.promise}static get(t){return ds?.get(t)}}const Ri=function(l){return kt.get("fs").promises.readFile(l).then(t=>new Uint8Array(t))},zt="Fill",Ts="Stroke",pe="Shading";function us(l,t){if(!t)return;const e=t[2]-t[0],s=t[3]-t[1],i=new Path2D;i.rect(t[0],t[1],e,s),l.clip(i)}class be{constructor(){this.constructor===be&&q("Cannot initialize BaseShadingPattern.")}getPattern(){q("Abstract method `getPattern` called.")}}class mr extends be{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){let e;this._type==="axial"?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const s of this._colorStops)e.addColorStop(s[0],s[1]);return e}getPattern(t,e,s,i){let n;if(i===Ts||i===zt){const r=e.current.getClippedPathBoundingBox(i,K(t))||[0,0,0,0],a=Math.ceil(r[2]-r[0])||1,o=Math.ceil(r[3]-r[1])||1,h=e.cachedCanvases.getCanvas("pattern",a,o,!0),c=h.context;c.clearRect(0,0,c.canvas.width,c.canvas.height),c.beginPath(),c.rect(0,0,c.canvas.width,c.canvas.height),c.translate(-r[0],-r[1]),s=k.transform(s,[1,0,0,1,r[0],r[1]]),c.transform(...e.baseTransform),this.matrix&&c.transform(...this.matrix),us(c,this._bbox),c.fillStyle=this._createGradient(c),c.fill(),n=t.createPattern(h.canvas,"no-repeat");const d=new DOMMatrix(s);n.setTransform(d)}else us(t,this._bbox),n=this._createGradient(t);return n}}function Ze(l,t,e,s,i,n,r,a){const o=t.coords,h=t.colors,c=l.data,d=4*l.width;let u;o[e+1]>o[s+1]&&(u=e,e=s,s=u,u=n,n=r,r=u),o[s+1]>o[i+1]&&(u=s,s=i,i=u,u=r,r=a,a=u),o[e+1]>o[s+1]&&(u=e,e=s,s=u,u=n,n=r,r=u);const p=(o[e]+t.offsetX)*t.scaleX,g=(o[e+1]+t.offsetY)*t.scaleY,f=(o[s]+t.offsetX)*t.scaleX,v=(o[s+1]+t.offsetY)*t.scaleY,m=(o[i]+t.offsetX)*t.scaleX,b=(o[i+1]+t.offsetY)*t.scaleY;if(g>=b)return;const A=h[n],w=h[n+1],_=h[n+2],y=h[r],E=h[r+1],S=h[r+2],C=h[a],I=h[a+1],M=h[a+2],W=Math.round(g),D=Math.round(b);let B,U,Y,J,R,F,_t,At;for(let tt=W;tt<=D;tt++){if(tt<v){const V=tt<g?0:(g-tt)/(g-v);B=p-(p-f)*V,U=A-(A-y)*V,Y=w-(w-E)*V,J=_-(_-S)*V}else{let V;V=tt>b?1:v===b?0:(v-tt)/(v-b),B=f-(f-m)*V,U=y-(y-C)*V,Y=E-(E-I)*V,J=S-(S-M)*V}let et;et=tt<g?0:tt>b?1:(g-tt)/(g-b),R=p-(p-m)*et,F=A-(A-C)*et,_t=w-(w-I)*et,At=_-(_-M)*et;const H=Math.round(Math.min(B,R)),X=Math.round(Math.max(B,R));let N=d*tt+4*H;for(let V=H;V<=X;V++)et=(B-V)/(B-R),et<0?et=0:et>1&&(et=1),c[N++]=U-(U-F)*et|0,c[N++]=Y-(Y-_t)*et|0,c[N++]=J-(J-At)*et|0,c[N++]=255}}function vr(l,t,e){const s=t.coords,i=t.colors;let n,r;switch(t.type){case"lattice":const a=t.verticesPerRow,o=Math.floor(s.length/a)-1,h=a-1;for(n=0;n<o;n++){let c=n*a;for(let d=0;d<h;d++,c++)Ze(l,e,s[c],s[c+1],s[c+a],i[c],i[c+1],i[c+a]),Ze(l,e,s[c+a+1],s[c+1],s[c+a],i[c+a+1],i[c+1],i[c+a])}break;case"triangles":for(n=0,r=s.length;n<r;n+=3)Ze(l,e,s[n],s[n+1],s[n+2],i[n],i[n+1],i[n+2]);break;default:throw new Error("illegal figure")}}class br extends be{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[7],this._background=t[8],this.matrix=null}_createMeshCanvas(t,e,s){const i=Math.floor(this._bounds[0]),n=Math.floor(this._bounds[1]),r=Math.ceil(this._bounds[2])-i,a=Math.ceil(this._bounds[3])-n,o=Math.min(Math.ceil(Math.abs(r*t[0]*1.1)),3e3),h=Math.min(Math.ceil(Math.abs(a*t[1]*1.1)),3e3),c=r/o,d=a/h,u={coords:this._coords,colors:this._colors,offsetX:-i,offsetY:-n,scaleX:1/c,scaleY:1/d},p=o+4,g=h+4,f=s.getCanvas("mesh",p,g,!1),v=f.context,m=v.createImageData(o,h);if(e){const b=m.data;for(let A=0,w=b.length;A<w;A+=4)b[A]=e[0],b[A+1]=e[1],b[A+2]=e[2],b[A+3]=255}for(const b of this._figures)vr(m,b,u);return v.putImageData(m,2,2),{canvas:f.canvas,offsetX:i-2*c,offsetY:n-2*d,scaleX:c,scaleY:d}}getPattern(t,e,s,i){let n;if(us(t,this._bbox),i===pe)n=k.singularValueDecompose2dScale(K(t));else if(n=k.singularValueDecompose2dScale(e.baseTransform),this.matrix){const a=k.singularValueDecompose2dScale(this.matrix);n=[n[0]*a[0],n[1]*a[1]]}const r=this._createMeshCanvas(n,i===pe?null:this._background,e.cachedCanvases);return i!==pe&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(r.offsetX,r.offsetY),t.scale(r.scaleX,r.scaleY),t.createPattern(r.canvas,"no-repeat")}}class Ar extends be{getPattern(){return"hotpink"}}const yr=1,wr=2;class Ps{static MAX_PATTERN_SIZE=3e3;constructor(t,e,s,i,n){this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.color=e,this.ctx=s,this.canvasGraphicsFactory=i,this.baseTransform=n}createPatternCanvas(t){const e=this.operatorList,s=this.bbox,i=this.xstep,n=this.ystep,r=this.paintType,a=this.tilingType,o=this.color,h=this.canvasGraphicsFactory;Be("TilingType: "+a);const c=s[0],d=s[1],u=s[2],p=s[3],g=k.singularValueDecompose2dScale(this.matrix),f=k.singularValueDecompose2dScale(this.baseTransform),v=[g[0]*f[0],g[1]*f[1]],m=this.getSizeAndScale(i,this.ctx.canvas.width,v[0]),b=this.getSizeAndScale(n,this.ctx.canvas.height,v[1]),A=t.cachedCanvases.getCanvas("pattern",m.size,b.size,!0),w=A.context,_=h.createCanvasGraphics(w);_.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(_,r,o);let y=c,E=d,S=u,C=p;return c<0&&(y=0,S+=Math.abs(c)),d<0&&(E=0,C+=Math.abs(d)),w.translate(-m.scale*y,-b.scale*E),_.transform(m.scale,0,0,b.scale,0,0),w.save(),this.clipBbox(_,y,E,S,C),_.baseTransform=K(_.ctx),_.executeOperatorList(e),_.endDrawing(),{canvas:A.canvas,scaleX:m.scale,scaleY:b.scale,offsetX:y,offsetY:E}}getSizeAndScale(t,e,s){t=Math.abs(t);const i=Math.max(Ps.MAX_PATTERN_SIZE,e);let n=Math.ceil(t*s);return n>=i?n=i:s=n/t,{scale:s,size:n}}clipBbox(t,e,s,i,n){const r=i-e,a=n-s;t.ctx.rect(e,s,r,a),t.current.updateRectMinMax(K(t.ctx),[e,s,i,n]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,s){const i=t.ctx,n=t.current;switch(e){case yr:const r=this.ctx;i.fillStyle=r.fillStyle,i.strokeStyle=r.strokeStyle,n.fillColor=r.fillStyle,n.strokeColor=r.strokeStyle;break;case wr:const a=k.makeHexColor(s[0],s[1],s[2]);i.fillStyle=a,i.strokeStyle=a,n.fillColor=a,n.strokeColor=a;break;default:throw new Yn(`Unsupported paint type: ${e}`)}}getPattern(t,e,s,i){let n=s;i!==pe&&(n=k.transform(n,e.baseTransform),this.matrix&&(n=k.transform(n,this.matrix)));const r=this.createPatternCanvas(e);let a=new DOMMatrix(n);a=a.translate(r.offsetX,r.offsetY),a=a.scale(1/r.scaleX,1/r.scaleY);const o=t.createPattern(r.canvas,"repeat");return o.setTransform(a),o}}function _r({src:l,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:n=4294967295,inverseDecode:r=!1}){const a=pt.isLittleEndian?4278190080:255,[o,h]=r?[n,a]:[a,n],c=s>>3,d=7&s,u=l.length;e=new Uint32Array(e.buffer);let p=0;for(let g=0;g<i;g++){for(const v=t+c;t<v;t++){const m=t<u?l[t]:255;e[p++]=128&m?h:o,e[p++]=64&m?h:o,e[p++]=32&m?h:o,e[p++]=16&m?h:o,e[p++]=8&m?h:o,e[p++]=4&m?h:o,e[p++]=2&m?h:o,e[p++]=1&m?h:o}if(d===0)continue;const f=t<u?l[t++]:255;for(let v=0;v<d;v++)e[p++]=f&1<<7-v?h:o}return{srcPos:t,destPos:p}}const ut=16;class xr{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,s){let i;return this.cache[t]!==void 0?(i=this.cache[t],this.canvasFactory.reset(i,e,s)):(i=this.canvasFactory.create(e,s),this.cache[t]=i),i}delete(t){delete this.cache[t]}clear(){for(const t in this.cache){const e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function xe(l,t,e,s,i,n,r,a,o,h){const[c,d,u,p,g,f]=K(l);if(d===0&&u===0){const v=r*c+g,m=Math.round(v),b=a*p+f,A=Math.round(b),w=(r+o)*c+g,_=Math.abs(Math.round(w)-m)||1,y=(a+h)*p+f,E=Math.abs(Math.round(y)-A)||1;return l.setTransform(Math.sign(c),0,0,Math.sign(p),m,A),l.drawImage(t,e,s,i,n,0,0,_,E),l.setTransform(c,d,u,p,g,f),[_,E]}if(c===0&&p===0){const v=a*u+g,m=Math.round(v),b=r*d+f,A=Math.round(b),w=(a+h)*u+g,_=Math.abs(Math.round(w)-m)||1,y=(r+o)*d+f,E=Math.abs(Math.round(y)-A)||1;return l.setTransform(0,Math.sign(d),Math.sign(u),0,m,A),l.drawImage(t,e,s,i,n,0,0,E,_),l.setTransform(c,d,u,p,g,f),[E,_]}return l.drawImage(t,e,s,i,n,r,a,o,h),[Math.hypot(c,d)*o,Math.hypot(u,p)*h]}class Vs{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=bi,this.textMatrixScale=1,this.fontMatrix=ns,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=Me,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,t,e])}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,e){this.x=t,this.y=e}updatePathMinMax(t,e,s){[e,s]=k.applyTransform([e,s],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,s),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,s)}updateRectMinMax(t,e){const s=k.applyTransform(e,t),i=k.applyTransform(e.slice(2),t),n=k.applyTransform([e[0],e[3]],t),r=k.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,s[0],i[0],n[0],r[0]),this.minY=Math.min(this.minY,s[1],i[1],n[1],r[1]),this.maxX=Math.max(this.maxX,s[0],i[0],n[0],r[0]),this.maxY=Math.max(this.maxY,s[1],i[1],n[1],r[1])}updateScalingPathMinMax(t,e){k.scaleMinMax(t,e),this.minX=Math.min(this.minX,e[0]),this.minY=Math.min(this.minY,e[1]),this.maxX=Math.max(this.maxX,e[2]),this.maxY=Math.max(this.maxY,e[3])}updateCurvePathMinMax(t,e,s,i,n,r,a,o,h,c){const d=k.bezierBoundingBox(e,s,i,n,r,a,o,h,c);c||this.updateRectMinMax(t,d)}getPathBoundingBox(t=zt,e=null){const s=[this.minX,this.minY,this.maxX,this.maxY];if(t===Ts){e||q("Stroke bounding box must include transform.");const i=k.singularValueDecompose2dScale(e),n=i[0]*this.lineWidth/2,r=i[1]*this.lineWidth/2;s[0]-=n,s[1]-=r,s[2]+=n,s[3]+=r}return s}updateClipFromPath(){const t=k.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(t){this.clipBox=t,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(t=zt,e=null){return k.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Gs(l,t){if(typeof ImageData<"u"&&t instanceof ImageData)return void l.putImageData(t,0,0);const e=t.height,s=t.width,i=e%ut,n=(e-i)/ut,r=i===0?n:n+1,a=l.createImageData(s,ut);let o,h=0;const c=t.data,d=a.data;let u,p,g,f;if(t.kind===Re.GRAYSCALE_1BPP){const v=c.byteLength,m=new Uint32Array(d.buffer,0,d.byteLength>>2),b=m.length,A=s+7>>3,w=4294967295,_=pt.isLittleEndian?4278190080:255;for(u=0;u<r;u++){for(g=u<n?ut:i,o=0,p=0;p<g;p++){const y=v-h;let E=0;const S=y>A?s:8*y-7,C=-8&S;let I=0,M=0;for(;E<C;E+=8)M=c[h++],m[o++]=128&M?w:_,m[o++]=64&M?w:_,m[o++]=32&M?w:_,m[o++]=16&M?w:_,m[o++]=8&M?w:_,m[o++]=4&M?w:_,m[o++]=2&M?w:_,m[o++]=1&M?w:_;for(;E<S;E++)I===0&&(M=c[h++],I=128),m[o++]=M&I?w:_,I>>=1}for(;o<b;)m[o++]=0;l.putImageData(a,0,u*ut)}}else if(t.kind===Re.RGBA_32BPP){for(p=0,f=s*ut*4,u=0;u<n;u++)d.set(c.subarray(h,h+f)),h+=f,l.putImageData(a,0,p),p+=ut;u<r&&(f=s*i*4,d.set(c.subarray(h,h+f)),l.putImageData(a,0,p))}else{if(t.kind!==Re.RGB_24BPP)throw new Error(`bad image kind: ${t.kind}`);for(g=ut,f=s*g,u=0;u<r;u++){for(u>=n&&(g=i,f=s*g),o=0,p=f;p--;)d[o++]=c[h++],d[o++]=c[h++],d[o++]=c[h++],d[o++]=255;l.putImageData(a,0,u*ut)}}}function Us(l,t){if(t.bitmap)return void l.drawImage(t.bitmap,0,0);const e=t.height,s=t.width,i=e%ut,n=(e-i)/ut,r=i===0?n:n+1,a=l.createImageData(s,ut);let o=0;const h=t.data,c=a.data;for(let d=0;d<r;d++){const u=d<n?ut:i;({srcPos:o}=_r({src:h,srcPos:o,dest:c,width:s,height:u,nonBlackColor:0})),l.putImageData(a,0,d*ut)}}function le(l,t){const e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of e)l[s]!==void 0&&(t[s]=l[s]);l.setLineDash!==void 0&&(t.setLineDash(l.getLineDash()),t.lineDashOffset=l.lineDashOffset)}function Ee(l){if(l.strokeStyle=l.fillStyle="#000000",l.fillRule="nonzero",l.globalAlpha=1,l.lineWidth=1,l.lineCap="butt",l.lineJoin="miter",l.miterLimit=10,l.globalCompositeOperation="source-over",l.font="10px sans-serif",l.setLineDash!==void 0&&(l.setLineDash([]),l.lineDashOffset=0),!dt){const{filter:t}=l;t!=="none"&&t!==""&&(l.filter="none")}}function qs(l,t){if(t)return!0;const e=k.singularValueDecompose2dScale(l);e[0]=Math.fround(e[0]),e[1]=Math.fround(e[1]);const s=Math.fround((globalThis.devicePixelRatio||1)*ae.PDF_TO_CSS_UNITS);return e[0]<=s&&e[1]<=s}const Er=["butt","round","square"],Sr=["miter","round","bevel"],Cr={},Ws={};class ee{constructor(t,e,s,i,n,{optionalContentConfig:r,markedContentStack:a=null},o,h){this.ctx=t,this.current=new Vs(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=s,this.canvasFactory=i,this.filterFactory=n,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=a||[],this.optionalContentConfig=r,this.cachedCanvases=new xr(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=o,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=h,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t,e=null){return typeof t=="string"?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:i=null}){const n=this.ctx.canvas.width,r=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,n,r),this.ctx.fillStyle=a,s){const o=this.cachedCanvases.getCanvas("transparent",n,r);this.compositeCtx=this.ctx,this.transparentCanvas=o.canvas,this.ctx=o.context,this.ctx.save(),this.ctx.transform(...K(this.compositeCtx))}this.ctx.save(),Ee(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[0]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=K(this.ctx)}executeOperatorList(t,e,s,i){const n=t.argsArray,r=t.fnArray;let a=e||0;const o=n.length;if(o===a)return a;const h=o-a>10&&typeof s=="function",c=h?Date.now()+15:0;let d=0;const u=this.commonObjs,p=this.objs;let g;for(;;){if(i!==void 0&&a===i.nextBreakPoint)return i.breakIt(a,s),a;if(g=r[a],g!==wt.dependency)this[g].apply(this,n[a]);else for(const f of n[a]){const v=f.startsWith("g_")?u:p;if(!v.has(f))return v.get(f,s),a}if(a++,a===o)return a;if(h&&++d>10){if(Date.now()>c)return s(),a;d=0}}}#t(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)}endDrawing(){this.#t(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#e()}#e(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){const s=t.width,i=t.height;let n,r,a=Math.max(Math.hypot(e[0],e[1]),1),o=Math.max(Math.hypot(e[2],e[3]),1),h=s,c=i,d="prescale1";for(;a>2&&h>1||o>2&&c>1;){let u=h,p=c;a>2&&h>1&&(u=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h/2),a/=h/u),o>2&&c>1&&(p=c>=16384?Math.floor(c/2)-1||1:Math.ceil(c)/2,o/=c/p),n=this.cachedCanvases.getCanvas(d,u,p),r=n.context,r.clearRect(0,0,u,p),r.drawImage(t,0,0,h,c,0,0,u,p),t=n.canvas,h=u,c=p,d=d==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:h,paintHeight:c}}_createMaskCanvas(t){const e=this.ctx,{width:s,height:i}=t,n=this.current.fillColor,r=this.current.patternFill,a=K(e);let o,h,c,d;if((t.bitmap||t.data)&&t.count>1){const S=t.bitmap||t.data.buffer;h=JSON.stringify(r?a:[a.slice(0,4),n]),o=this._cachedBitmapsMap.get(S),o||(o=new Map,this._cachedBitmapsMap.set(S,o));const C=o.get(h);if(C&&!r)return{canvas:C,offsetX:Math.round(Math.min(a[0],a[2])+a[4]),offsetY:Math.round(Math.min(a[1],a[3])+a[5])};c=C}c||(d=this.cachedCanvases.getCanvas("maskCanvas",s,i),Us(d.context,t));let u=k.transform(a,[1/s,0,0,-1/i,0,0]);u=k.transform(u,[1,0,0,1,0,-i]);const[p,g,f,v]=k.getAxialAlignedBoundingBox([0,0,s,i],u),m=Math.round(f-p)||1,b=Math.round(v-g)||1,A=this.cachedCanvases.getCanvas("fillCanvas",m,b),w=A.context,_=p,y=g;w.translate(-_,-y),w.transform(...u),c||(c=this._scaleImage(d.canvas,Rt(w)),c=c.img,o&&r&&o.set(h,c)),w.imageSmoothingEnabled=qs(K(w),t.interpolate),xe(w,c,0,0,c.width,c.height,0,0,s,i),w.globalCompositeOperation="source-in";const E=k.transform(Rt(w),[1,0,0,1,-_,-y]);return w.fillStyle=r?n.getPattern(e,this,E,zt):n,w.fillRect(0,0,s,i),o&&!r&&(this.cachedCanvases.delete("fillCanvas"),o.set(h,A.canvas)),{canvas:A.canvas,offsetX:Math.round(_),offsetY:Math.round(y)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=Er[t]}setLineJoin(t){this.ctx.lineJoin=Sr[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const s=this.ctx;s.setLineDash!==void 0&&(s.setLineDash(t),s.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[e,s]of t)switch(e){case"LW":this.setLineWidth(s);break;case"LC":this.setLineCap(s);break;case"LJ":this.setLineJoin(s);break;case"ML":this.setMiterLimit(s);break;case"D":this.setDash(s[0],s[1]);break;case"RI":this.setRenderingIntent(s);break;case"FL":this.setFlatness(s);break;case"Font":this.setFont(s[0],s[1]);break;case"CA":this.current.strokeAlpha=s;break;case"ca":this.current.fillAlpha=s,this.ctx.globalAlpha=s;break;case"BM":this.ctx.globalCompositeOperation=s;break;case"SMask":this.current.activeSMask=s?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(s)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const t=this.ctx.canvas.width,e=this.ctx.canvas.height,s="smaskGroupAt"+this.groupLevel,i=this.cachedCanvases.getCanvas(s,t,e);this.suspendedCtx=this.ctx,this.ctx=i.context;const n=this.ctx;n.setTransform(...K(this.suspendedCtx)),le(this.suspendedCtx,n),function(r,a){if(r._removeMirroring)throw new 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(o,h){a.translate(o,h),this.__originalTranslate(o,h)},r.scale=function(o,h){a.scale(o,h),this.__originalScale(o,h)},r.transform=function(o,h,c,d,u,p){a.transform(o,h,c,d,u,p),this.__originalTransform(o,h,c,d,u,p)},r.setTransform=function(o,h,c,d,u,p){a.setTransform(o,h,c,d,u,p),this.__originalSetTransform(o,h,c,d,u,p)},r.resetTransform=function(){a.resetTransform(),this.__originalResetTransform()},r.rotate=function(o){a.rotate(o),this.__originalRotate(o)},r.clip=function(o){a.clip(o),this.__originalClip(o)},r.moveTo=function(o,h){a.moveTo(o,h),this.__originalMoveTo(o,h)},r.lineTo=function(o,h){a.lineTo(o,h),this.__originalLineTo(o,h)},r.bezierCurveTo=function(o,h,c,d,u,p){a.bezierCurveTo(o,h,c,d,u,p),this.__originalBezierCurveTo(o,h,c,d,u,p)},r.rect=function(o,h,c,d){a.rect(o,h,c,d),this.__originalRect(o,h,c,d)},r.closePath=function(){a.closePath(),this.__originalClosePath()},r.beginPath=function(){a.beginPath(),this.__originalBeginPath()}}(n,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),le(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,s=this.suspendedCtx;this.composeSMask(s,e,this.ctx,t),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(t,e,s,i){const n=i[0],r=i[1],a=i[2]-n,o=i[3]-r;a!==0&&o!==0&&(this.genericComposeSMask(e.context,s,a,o,e.subtype,e.backdrop,e.transferMap,n,r,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(s.canvas,0,0),t.restore())}genericComposeSMask(t,e,s,i,n,r,a,o,h,c,d){let u=t.canvas,p=o-c,g=h-d;if(r){if(p<0||g<0||p+s>u.width||g+i>u.height){const v=this.cachedCanvases.getCanvas("maskExtension",s,i),m=v.context;m.drawImage(u,-p,-g),r.some(b=>b!==0)&&(m.globalCompositeOperation="destination-atop",m.fillStyle=k.makeHexColor(...r),m.fillRect(0,0,s,i),m.globalCompositeOperation="source-over"),u=v.canvas,p=g=0}else if(r.some(v=>v!==0)){t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const v=new Path2D;v.rect(p,g,s,i),t.clip(v),t.globalCompositeOperation="destination-atop",t.fillStyle=k.makeHexColor(...r),t.fillRect(p,g,s,i),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),n==="Alpha"&&a?e.filter=this.filterFactory.addAlphaFilter(a):n==="Luminosity"&&(e.filter=this.filterFactory.addLuminosityFilter(a));const f=new Path2D;f.rect(o,h,s,i),e.clip(f),e.globalCompositeOperation="destination-in",e.drawImage(u,p,g,s,i,o,h,s,i),e.restore()}save(){this.inSMaskMode?(le(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){this.stateStack.length===0&&this.inSMaskMode&&this.endSMaskMode(),this.stateStack.length!==0&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),le(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,s,i,n,r){this.ctx.transform(t,e,s,i,n,r),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,s){const i=this.ctx,n=this.current;let r,a,o=n.x,h=n.y;const c=K(i),d=c[0]===0&&c[3]===0||c[1]===0&&c[2]===0,u=d?s.slice(0):null;for(let p=0,g=0,f=t.length;p<f;p++)switch(0|t[p]){case wt.rectangle:o=e[g++],h=e[g++];const v=e[g++],m=e[g++],b=o+v,A=h+m;i.moveTo(o,h),v===0||m===0?i.lineTo(b,A):(i.lineTo(b,h),i.lineTo(b,A),i.lineTo(o,A)),d||n.updateRectMinMax(c,[o,h,b,A]),i.closePath();break;case wt.moveTo:o=e[g++],h=e[g++],i.moveTo(o,h),d||n.updatePathMinMax(c,o,h);break;case wt.lineTo:o=e[g++],h=e[g++],i.lineTo(o,h),d||n.updatePathMinMax(c,o,h);break;case wt.curveTo:r=o,a=h,o=e[g+4],h=e[g+5],i.bezierCurveTo(e[g],e[g+1],e[g+2],e[g+3],o,h),n.updateCurvePathMinMax(c,r,a,e[g],e[g+1],e[g+2],e[g+3],o,h,u),g+=6;break;case wt.curveTo2:r=o,a=h,i.bezierCurveTo(o,h,e[g],e[g+1],e[g+2],e[g+3]),n.updateCurvePathMinMax(c,r,a,o,h,e[g],e[g+1],e[g+2],e[g+3],u),o=e[g+2],h=e[g+3],g+=4;break;case wt.curveTo3:r=o,a=h,o=e[g+2],h=e[g+3],i.bezierCurveTo(e[g],e[g+1],o,h,o,h),n.updateCurvePathMinMax(c,r,a,e[g],e[g+1],o,h,o,h,u),g+=4;break;case wt.closePath:i.closePath()}d&&n.updateScalingPathMinMax(c,u),n.setCurrentPoint(o,h)}closePath(){this.ctx.closePath()}stroke(t=!0){const e=this.ctx,s=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof s=="object"&&s?.getPattern?(e.save(),e.strokeStyle=s.getPattern(e,this,Rt(e),Ts),this.rescaleAndStroke(!1),e.restore()):this.rescaleAndStroke(!0)),t&&this.consumePath(this.current.getClippedPathBoundingBox()),e.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(t=!0){const e=this.ctx,s=this.current.fillColor;let i=!1;this.current.patternFill&&(e.save(),e.fillStyle=s.getPattern(e,this,Rt(e),zt),i=!0);const n=this.current.getClippedPathBoundingBox();this.contentVisible&&n!==null&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),i&&e.restore(),t&&this.consumePath(n)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=Cr}eoClip(){this.pendingClip=Ws}beginText(){this.current.textMatrix=bi,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const t=this.pendingTextPaths,e=this.ctx;if(t!==void 0){e.save(),e.beginPath();for(const s of t)e.setTransform(...s.transform),e.translate(s.x,s.y),s.addToPath(e,s.fontSize);e.restore(),e.clip(),e.beginPath(),delete this.pendingTextPaths}else e.beginPath()}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){const s=this.commonObjs.get(t),i=this.current;if(!s)throw new Error(`Can't find font for ${t}`);if(i.fontMatrix=s.fontMatrix||ns,i.fontMatrix[0]!==0&&i.fontMatrix[3]!==0||O("Invalid font matrix for font "+t),e<0?(e=-e,i.fontDirection=-1):i.fontDirection=1,this.current.font=s,this.current.fontSize=e,s.isType3Font)return;const n=s.loadedName||"sans-serif",r=s.systemFontInfo?.css||`"${n}", ${s.fallbackName}`;let a="normal";s.black?a="900":s.bold&&(a="bold");const o=s.italic?"italic":"normal";let h=e;e<16?h=16:e>100&&(h=100),this.current.fontSizeScale=e/h,this.ctx.font=`${o} ${a} ${h}px ${r}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t,e,s,i,n,r){this.current.textMatrix=[t,e,s,i,n,r],this.current.textMatrixScale=Math.hypot(t,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(t,e,s,i){const n=this.ctx,r=this.current,a=r.font,o=r.textRenderingMode,h=r.fontSize/r.fontSizeScale,c=o&js,d=!!(o&xn),u=r.patternFill&&!a.missingFile;let p;(a.disableFontFace||d||u)&&(p=a.getPathGenerator(this.commonObjs,t)),a.disableFontFace||u?(n.save(),n.translate(e,s),n.beginPath(),p(n,h),i&&n.setTransform(...i),c!==Me&&c!==he||n.fill(),c!==Ye&&c!==he||n.stroke(),n.restore()):(c!==Me&&c!==he||n.fillText(t,e,s),c!==Ye&&c!==he||n.strokeText(t,e,s)),d&&(this.pendingTextPaths||=[]).push({transform:K(n),x:e,y:s,fontSize:h,addToPath:p})}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let s=!1;for(let i=3;i<e.length;i+=4)if(e[i]>0&&e[i]<255){s=!0;break}return z(this,"isFontSubpixelAAEnabled",s)}showText(t){const e=this.current,s=e.font;if(s.isType3Font)return this.showType3Text(t);const i=e.fontSize;if(i===0)return;const n=this.ctx,r=e.fontSizeScale,a=e.charSpacing,o=e.wordSpacing,h=e.fontDirection,c=e.textHScale*h,d=t.length,u=s.vertical,p=u?1:-1,g=s.defaultVMetrics,f=i*e.fontMatrix[0],v=e.textRenderingMode===Me&&!s.disableFontFace&&!e.patternFill;let m;if(n.save(),n.transform(...e.textMatrix),n.translate(e.x,e.y+e.textRise),h>0?n.scale(c,-1):n.scale(c,1),e.patternFill){n.save();const y=e.fillColor.getPattern(n,this,Rt(n),zt);m=K(n),n.restore(),n.fillStyle=y}let b=e.lineWidth;const A=e.textMatrixScale;if(A===0||b===0){const y=e.textRenderingMode&js;y!==Ye&&y!==he||(b=this.getSinglePixelWidth())}else b/=A;if(r!==1&&(n.scale(r,r),b/=r),n.lineWidth=b,s.isInvalidPDFjsFont){const y=[];let E=0;for(const S of t)y.push(S.unicode),E+=S.width;return n.fillText(y.join(""),0,0),e.x+=E*f*c,n.restore(),void this.compose()}let w,_=0;for(w=0;w<d;++w){const y=t[w];if(typeof y=="number"){_+=p*y*i/1e3;continue}let E=!1;const S=(y.isSpace?o:0)+a,C=y.fontChar,I=y.accent;let M,W,D=y.width;if(u){const B=y.vmetric||g,U=-(y.vmetric?B[1]:.5*D)*f,Y=B[2]*f;D=B?-B[0]:D,M=U/r,W=(_+Y)/r}else M=_/r,W=0;if(s.remeasure&&D>0){const B=1e3*n.measureText(C).width/i*r;if(D<B&&this.isFontSubpixelAAEnabled){const U=D/B;E=!0,n.save(),n.scale(U,1),M/=U}else D!==B&&(M+=(D-B)/2e3*i/r)}if(this.contentVisible&&(y.isInFont||s.missingFile)){if(v&&!I)n.fillText(C,M,W);else if(this.paintChar(C,M,W,m),I){const B=M+i*I.offset.x/r,U=W-i*I.offset.y/r;this.paintChar(I.fontChar,B,U,m)}}_+=u?D*f-S*h:D*f+S*h,E&&n.restore()}u?e.y-=_:e.x+=_*c,n.restore(),this.compose()}showType3Text(t){const e=this.ctx,s=this.current,i=s.font,n=s.fontSize,r=s.fontDirection,a=i.vertical?1:-1,o=s.charSpacing,h=s.wordSpacing,c=s.textHScale*r,d=s.fontMatrix||ns,u=t.length;let p,g,f,v;if(s.textRenderingMode!==_n&&n!==0){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),e.transform(...s.textMatrix),e.translate(s.x,s.y),e.scale(c,r),p=0;p<u;++p){if(g=t[p],typeof g=="number"){v=a*g*n/1e3,this.ctx.translate(v,0),s.x+=v*c;continue}const m=(g.isSpace?h:0)+o,b=i.charProcOperatorList[g.operatorListId];if(!b){O(`Type3 character "${g.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=g,this.save(),e.scale(n,n),e.transform(...d),this.executeOperatorList(b),this.restore()),f=k.applyTransform([g.width,0],d)[0]*n+m,e.translate(f,0),s.x+=f*c}e.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,s,i,n,r){this.ctx.rect(s,i,n-s,r-i),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if(t[0]==="TilingPattern"){const s=t[1],i=this.baseTransform||K(this.ctx),n={createCanvasGraphics:r=>new ee(r,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new Ps(t,s,this.ctx,n,i)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,s){const i=k.makeHexColor(t,e,s);this.ctx.strokeStyle=i,this.current.strokeColor=i}setFillRGBColor(t,e,s){const i=k.makeHexColor(t,e,s);this.ctx.fillStyle=i,this.current.fillColor=i,this.current.patternFill=!1}_getPattern(t,e=null){let s;return this.cachedPatterns.has(t)?s=this.cachedPatterns.get(t):(s=function(i){switch(i[0]){case"RadialAxial":return new mr(i);case"Mesh":return new br(i);case"Dummy":return new Ar}throw new Error(`Unknown IR type: ${i[0]}`)}(this.getObject(t)),this.cachedPatterns.set(t,s)),e&&(s.matrix=e),s}shadingFill(t){if(!this.contentVisible)return;const e=this.ctx;this.save();const s=this._getPattern(t);e.fillStyle=s.getPattern(e,this,Rt(e),pe);const i=Rt(e);if(i){const{width:n,height:r}=e.canvas,[a,o,h,c]=k.getAxialAlignedBoundingBox([0,0,n,r],i);this.ctx.fillRect(a,o,h-a,c-o)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){q("Should not call beginInlineImage")}beginImageData(){q("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=K(this.ctx),e)){const s=e[2]-e[0],i=e[3]-e[1];this.ctx.rect(e[0],e[1],s,i),this.current.updateRectMinMax(K(this.ctx),e),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const e=this.ctx;t.isolated||Be("TODO: Support non-isolated groups."),t.knockout&&O("Knockout groups not supported.");const s=K(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let i=k.getAxialAlignedBoundingBox(t.bbox,K(e));const n=[0,0,e.canvas.width,e.canvas.height];i=k.intersect(i,n)||[0,0,0,0];const r=Math.floor(i[0]),a=Math.floor(i[1]),o=Math.max(Math.ceil(i[2])-r,1),h=Math.max(Math.ceil(i[3])-a,1);this.current.startNewPathAndClipBox([0,0,o,h]);let c="groupAt"+this.groupLevel;t.smask&&(c+="_smask_"+this.smaskCounter++%2);const d=this.cachedCanvases.getCanvas(c,o,h),u=d.context;u.translate(-r,-a),u.transform(...s),t.smask?this.smaskStack.push({canvas:d.canvas,context:u,offsetX:r,offsetY:a,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(r,a),e.save()),le(e,u),this.ctx=u,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;const e=this.ctx,s=this.groupStack.pop();if(this.ctx=s,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const i=K(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...i);const n=k.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],i);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(n)}}beginAnnotation(t,e,s,i,n){if(this.#t(),Ee(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const r=e[2]-e[0],a=e[3]-e[1];if(n&&this.annotationCanvasMap){(s=s.slice())[4]-=e[0],s[5]-=e[1],(e=e.slice())[0]=e[1]=0,e[2]=r,e[3]=a;const[o,h]=k.singularValueDecompose2dScale(K(this.ctx)),{viewportScale:c}=this,d=Math.ceil(r*this.outputScaleX*c),u=Math.ceil(a*this.outputScaleY*c);this.annotationCanvas=this.canvasFactory.create(d,u);const{canvas:p,context:g}=this.annotationCanvas;this.annotationCanvasMap.set(t,p),this.annotationCanvas.savedCtx=this.ctx,this.ctx=g,this.ctx.save(),this.ctx.setTransform(o,0,0,-h,0,a*h),Ee(this.ctx)}else Ee(this.ctx),this.ctx.rect(e[0],e[1],r,a),this.ctx.clip(),this.endPath()}this.current=new Vs(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...s),this.transform(...i)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#e(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;const e=t.count;(t=this.getObject(t.data,t)).count=e;const s=this.ctx,i=this.processingType3;if(i&&(i.compiled===void 0&&(i.compiled=function(a){const{width:o,height:h}=a;if(o>1e3||h>1e3)return null;const c=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),d=o+1;let u,p,g,f=new Uint8Array(d*(h+1));const v=o+7&-8;let m=new Uint8Array(v*h),b=0;for(const y of a.data){let E=128;for(;E>0;)m[b++]=y&E?0:255,E>>=1}let A=0;for(b=0,m[b]!==0&&(f[0]=1,++A),p=1;p<o;p++)m[b]!==m[b+1]&&(f[p]=m[b]?2:1,++A),b++;for(m[b]!==0&&(f[p]=2,++A),u=1;u<h;u++){b=u*v,g=u*d,m[b-v]!==m[b]&&(f[g]=m[b]?1:8,++A);let y=(m[b]?4:0)+(m[b-v]?8:0);for(p=1;p<o;p++)y=(y>>2)+(m[b+1]?4:0)+(m[b-v+1]?8:0),c[y]&&(f[g+p]=c[y],++A),b++;if(m[b-v]!==m[b]&&(f[g+p]=m[b]?2:4,++A),A>1e3)return null}for(b=v*(h-1),g=u*d,m[b]!==0&&(f[g]=8,++A),p=1;p<o;p++)m[b]!==m[b+1]&&(f[g+p]=m[b]?4:8,++A),b++;if(m[b]!==0&&(f[g+p]=4,++A),A>1e3)return null;const w=new Int32Array([0,d,-1,0,-d,0,0,0,1]),_=new Path2D;for(u=0;A&&u<=h;u++){let y=u*d;const E=y+o;for(;y<E&&!f[y];)y++;if(y===E)continue;_.moveTo(y%d,u);const S=y;let C=f[y];do{const I=w[C];do y+=I;while(!f[y]);const M=f[y];M!==5&&M!==10?(C=M,f[y]=0):(C=M&51*C>>4,f[y]&=C>>2|C<<2),_.lineTo(y%d,y/d|0),f[y]||--A}while(S!==y);--u}return m=null,f=null,function(y){y.save(),y.scale(1/o,-1/h),y.translate(0,-h),y.fill(_),y.beginPath(),y.restore()}}(t)),i.compiled))return void i.compiled(s);const n=this._createMaskCanvas(t),r=n.canvas;s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(r,n.offsetX,n.offsetY),s.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,s=0,i=0,n,r){if(!this.contentVisible)return;t=this.getObject(t.data,t);const a=this.ctx;a.save();const o=K(a);a.transform(e,s,i,n,0,0);const h=this._createMaskCanvas(t);a.setTransform(1,0,0,1,h.offsetX-o[4],h.offsetY-o[5]);for(let c=0,d=r.length;c<d;c+=2){const u=k.transform(o,[e,s,i,n,r[c],r[c+1]]),[p,g]=k.applyTransform([0,0],u);a.drawImage(h.canvas,p,g)}a.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const e=this.ctx,s=this.current.fillColor,i=this.current.patternFill;for(const n of t){const{data:r,width:a,height:o,transform:h}=n,c=this.cachedCanvases.getCanvas("maskCanvas",a,o),d=c.context;d.save(),Us(d,this.getObject(r,n)),d.globalCompositeOperation="source-in",d.fillStyle=i?s.getPattern(d,this,Rt(e),zt):s,d.fillRect(0,0,a,o),d.restore(),e.save(),e.transform(...h),e.scale(1,-1),xe(e,c.canvas,0,0,a,o,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=this.getObject(t);e?this.paintInlineImageXObject(e):O("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,s,i){if(!this.contentVisible)return;const n=this.getObject(t);if(!n)return void O("Dependent image isn't ready yet");const r=n.width,a=n.height,o=[];for(let h=0,c=i.length;h<c;h+=2)o.push({transform:[e,0,0,s,i[h],i[h+1]],x:0,y:0,w:r,h:a});this.paintInlineImageXObjectGroup(n,o)}applyTransferMapsToCanvas(t){return this.current.transferMaps!=="none"&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if(this.current.transferMaps==="none")return t.bitmap;const{bitmap:e,width:s,height:i}=t,n=this.cachedCanvases.getCanvas("inlineImage",s,i),r=n.context;return r.filter=this.current.transferMaps,r.drawImage(e,0,0),r.filter="none",n.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,s=t.height,i=this.ctx;if(this.save(),!dt){const{filter:a}=i;a!=="none"&&a!==""&&(i.filter="none")}let n;if(i.scale(1/e,-1/s),t.bitmap)n=this.applyTransferMapsToBitmap(t);else if(typeof HTMLElement=="function"&&t instanceof HTMLElement||!t.data)n=t;else{const a=this.cachedCanvases.getCanvas("inlineImage",e,s).context;Gs(a,t),n=this.applyTransferMapsToCanvas(a)}const r=this._scaleImage(n,Rt(i));i.imageSmoothingEnabled=qs(K(i),t.interpolate),xe(i,r.img,0,0,r.paintWidth,r.paintHeight,0,-s,e,s),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;const s=this.ctx;let i;if(t.bitmap)i=t.bitmap;else{const n=t.width,r=t.height,a=this.cachedCanvases.getCanvas("inlineImage",n,r).context;Gs(a,t),i=this.applyTransferMapsToCanvas(a)}for(const n of e)s.save(),s.transform(...n.transform),s.scale(1,-1),xe(s,i,n.x,n.y,n.w,n.h,0,-1,1,1),s.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,e){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e){t==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(e)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t){const e=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);const s=this.ctx;this.pendingClip&&(e||(this.pendingClip===Ws?s.clip("evenodd"):s.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),s.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=K(this.ctx);if(t[1]===0&&t[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),s=Math.hypot(t[0],t[2]),i=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(s,i)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:t}=this.current,{a:e,b:s,c:i,d:n}=this.ctx.getTransform();let r,a;if(s===0&&i===0){const o=Math.abs(e),h=Math.abs(n);if(o===h)if(t===0)r=a=1/o;else{const c=o*t;r=a=c<1?1/c:1}else if(t===0)r=1/o,a=1/h;else{const c=o*t,d=h*t;r=c<1?1/c:1,a=d<1?1/d:1}}else{const o=Math.abs(e*n-s*i),h=Math.hypot(e,s),c=Math.hypot(i,n);if(t===0)r=c/o,a=h/o;else{const d=t*o;r=c>d?c/d:1,a=h>d?h/d:1}}this._cachedScaleForStroking[0]=r,this._cachedScaleForStroking[1]=a}return this._cachedScaleForStroking}rescaleAndStroke(t){const{ctx:e}=this,{lineWidth:s}=this.current,[i,n]=this.getScaleForStroking();if(e.lineWidth=s||1,i===1&&n===1)return void e.stroke();const r=e.getLineDash();if(t&&e.save(),e.scale(i,n),r.length>0){const a=Math.max(i,n);e.setLineDash(r.map(o=>o/a)),e.lineDashOffset/=a}e.stroke(),t&&e.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(const l in wt)ee.prototype[l]!==void 0&&(ee.prototype[wt[l]]=ee.prototype[l]);class ge{static#t=null;static#e="";static get workerPort(){return this.#t}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");this.#t=t}static get workerSrc(){return this.#e}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");this.#e=t}}const Xs=1,Ks=2,Ys=1,ts=2,Qs=3,Js=4,Zs=5,ti=6,Se=7,es=8;function ft(l){switch(l instanceof Error||typeof l=="object"&&l!==null||q('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),l.name){case"AbortException":return new Xt(l.message);case"MissingPDFException":return new Wt(l.message);case"PasswordException":return new as(l.message,l.code);case"UnexpectedResponseException":return new He(l.message,l.status);case"UnknownErrorException":return new os(l.message,l.details);default:return new os(l.message,l.toString())}}class ue{constructor(t,e,s){this.sourceName=t,this.targetName=e,this.comObj=s,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),this._onComObjOnMessage=i=>{const n=i.data;if(n.targetName!==this.sourceName)return;if(n.stream)return void this.#e(n);if(n.callback){const a=n.callbackId,o=this.callbackCapabilities[a];if(!o)throw new Error(`Cannot resolve callback ${a}`);if(delete this.callbackCapabilities[a],n.callback===Xs)o.resolve(n.data);else{if(n.callback!==Ks)throw new Error("Unexpected callback case");o.reject(ft(n.reason))}return}const r=this.actionHandler[n.action];if(!r)throw new Error(`Unknown action from worker: ${n.action}`);if(n.callbackId){const a=this.sourceName,o=n.sourceName;new Promise(function(h){h(r(n.data))}).then(function(h){s.postMessage({sourceName:a,targetName:o,callback:Xs,callbackId:n.callbackId,data:h})},function(h){s.postMessage({sourceName:a,targetName:o,callback:Ks,callbackId:n.callbackId,reason:ft(h)})})}else n.streamId?this.#t(n):r(n.data)},s.addEventListener("message",this._onComObjOnMessage)}on(t,e){const s=this.actionHandler;if(s[t])throw new Error(`There is already an actionName called "${t}"`);s[t]=e}send(t,e,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},s)}sendWithPromise(t,e,s){const i=this.callbackId++,n=Promise.withResolvers();this.callbackCapabilities[i]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:i,data:e},s)}catch(r){n.reject(r)}return n.promise}sendWithStream(t,e,s,i){const n=this.streamId++,r=this.sourceName,a=this.targetName,o=this.comObj;return new ReadableStream({start:h=>{const c=Promise.withResolvers();return this.streamControllers[n]={controller:h,startCall:c,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:r,targetName:a,action:t,streamId:n,data:e,desiredSize:h.desiredSize},i),c.promise},pull:h=>{const c=Promise.withResolvers();return this.streamControllers[n].pullCall=c,o.postMessage({sourceName:r,targetName:a,stream:ti,streamId:n,desiredSize:h.desiredSize}),c.promise},cancel:h=>{nt(h instanceof Error,"cancel must have a valid reason");const c=Promise.withResolvers();return this.streamControllers[n].cancelCall=c,this.streamControllers[n].isClosed=!0,o.postMessage({sourceName:r,targetName:a,stream:Ys,streamId:n,reason:ft(h)}),c.promise}},s)}#t(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,r=this,a=this.actionHandler[t.action],o={enqueue(h,c=1,d){if(this.isCancelled)return;const u=this.desiredSize;this.desiredSize-=c,u>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:s,targetName:i,stream:Js,streamId:e,chunk:h},d)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:Qs,streamId:e}),delete r.streamSinks[e])},error(h){nt(h instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:Zs,streamId:e,reason:ft(h)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,new Promise(function(h){h(a(t.data,o))}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:es,streamId:e,success:!0})},function(h){n.postMessage({sourceName:s,targetName:i,stream:es,streamId:e,reason:ft(h)})})}#e(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,r=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case es:t.success?r.startCall.resolve():r.startCall.reject(ft(t.reason));break;case Se:t.success?r.pullCall.resolve():r.pullCall.reject(ft(t.reason));break;case ti:if(!a){n.postMessage({sourceName:s,targetName:i,stream:Se,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,new Promise(function(o){o(a.onPull?.())}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:Se,streamId:e,success:!0})},function(o){n.postMessage({sourceName:s,targetName:i,stream:Se,streamId:e,reason:ft(o)})});break;case Js:if(nt(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case Qs:if(nt(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#s(r,e);break;case Zs:nt(r,"error should have stream controller"),r.controller.error(ft(t.reason)),this.#s(r,e);break;case ts:t.success?r.cancelCall.resolve():r.cancelCall.reject(ft(t.reason)),this.#s(r,e);break;case Ys:if(!a)break;new Promise(function(o){o(a.onCancel?.(ft(t.reason)))}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:ts,streamId:e,success:!0})},function(o){n.postMessage({sourceName:s,targetName:i,stream:ts,streamId:e,reason:ft(o)})}),a.sinkCapability.reject(ft(t.reason)),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#s(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}class kr{#t;#e;constructor({parsedData:t,rawData:e}){this.#t=t,this.#e=e}getRaw(){return this.#e}get(t){return this.#t.get(t)??null}getAll(){return ys(this.#t)}has(t){return this.#t.has(t)}}const Ot=Symbol("INTERNAL");class Mr{#t=!1;#e=!1;#s=!1;#n=!0;constructor(t,{name:e,intent:s,usage:i}){this.#t=!!(t&As),this.#e=!!(t&Te),this.name=e,this.intent=s,this.usage=i}get visible(){if(this.#s)return this.#n;if(!this.#n)return!1;const{print:t,view:e}=this.usage;return this.#t?e?.viewState!=="OFF":!this.#e||t?.printState!=="OFF"}_setVisible(t,e,s=!1){t!==Ot&&q("Internal method `_setVisible` called."),this.#s=s,this.#n=e}}class Rr{#t=null;#e=new Map;#s=null;#n=null;constructor(t,e=As){if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,this.#n=t.order;for(const s of t.groups)this.#e.set(s.id,new Mr(e,s));if(t.baseState==="OFF")for(const s of this.#e.values())s._setVisible(Ot,!1);for(const s of t.on)this.#e.get(s)._setVisible(Ot,!0);for(const s of t.off)this.#e.get(s)._setVisible(Ot,!1);this.#s=this.getHash()}}#o(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let i=1;i<e;i++){const n=t[i];let r;if(Array.isArray(n))r=this.#o(n);else{if(!this.#e.has(n))return O(`Optional content group not found: ${n}`),!0;r=this.#e.get(n).visible}switch(s){case"And":if(!r)return!1;break;case"Or":if(r)return!0;break;case"Not":return!r;default:return!0}}return s==="And"}isVisible(t){if(this.#e.size===0)return!0;if(!t)return Be("Optional content group not defined."),!0;if(t.type==="OCG")return this.#e.has(t.id)?this.#e.get(t.id).visible:(O(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return this.#o(t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!this.#e.has(e))return O(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!0}return!1}if(t.policy==="AllOn"){for(const e of t.ids){if(!this.#e.has(e))return O(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!1}return!0}if(t.policy==="AnyOff"){for(const e of t.ids){if(!this.#e.has(e))return O(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!0}return!1}if(t.policy==="AllOff"){for(const e of t.ids){if(!this.#e.has(e))return O(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!1}return!0}return O(`Unknown optional content policy ${t.policy}.`),!0}return O(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0){const s=this.#e.get(t);s?(s._setVisible(Ot,!!e,!0),this.#t=null):O(`Optional content group not found: ${t}`)}setOCGState({state:t,preserveRB:e}){let s;for(const i of t){switch(i){case"ON":case"OFF":case"Toggle":s=i;continue}const n=this.#e.get(i);if(n)switch(s){case"ON":n._setVisible(Ot,!0);break;case"OFF":n._setVisible(Ot,!1);break;case"Toggle":n._setVisible(Ot,!n.visible)}}this.#t=null}get hasInitialVisibility(){return this.#s===null||this.getHash()===this.#s}getOrder(){return this.#e.size?this.#n?this.#n.slice():[...this.#e.keys()]:null}getGroups(){return this.#e.size>0?ys(this.#e):null}getGroup(t){return this.#e.get(t)||null}getHash(){if(this.#t!==null)return this.#t;const t=new ki;for(const[e,s]of this.#e)t.update(`${e}:${s.visible}`);return this.#t=t.hexdigest()}}class Tr{constructor(t,{disableRange:e=!1,disableStream:s=!1}){nt(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:i,initialData:n,progressiveDone:r,contentDispositionFilename:a}=t;if(this._queuedChunks=[],this._progressiveDone=r,this._contentDispositionFilename=a,n?.length>0){const o=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;this._queuedChunks.push(o)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!s,this._isRangeSupported=!e,this._contentLength=i,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((o,h)=>{this._onReceiveData({begin:o,chunk:h})}),t.addProgressListener((o,h)=>{this._onProgress({loaded:o,total:h})}),t.addProgressiveReadListener(o=>{this._onReceiveData({chunk:o})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const s=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;t===void 0?this._fullRequestReader?this._fullRequestReader._enqueue(s):this._queuedChunks.push(s):nt(this._rangeReaders.some(function(i){return i._begin===t&&(i._enqueue(s),!0)}),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){t.total===void 0?this._rangeReaders[0]?.onProgress?.({loaded:t.loaded}):this._fullRequestReader?.onProgress?.({loaded:t.loaded,total:t.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){nt(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new Pr(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new Lr(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeReaders.slice(0))e.cancel(t);this._pdfDataRangeTransport.abort()}}class Pr{constructor(t,e,s=!1,i=null){this._stream=t,this._done=s||!1,this._filename=Ss(i)?i:null,this._queuedChunks=e||[],this._loaded=0;for(const n of this._queuedChunks)this._loaded+=n.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class Lr{constructor(t,e,s){this._stream=t,this._begin=e,this._end=s,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length===0)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function Ls({getResponseHeader:l,isHttp:t,rangeChunkSize:e,disableRange:s}){const i={allowRangeRequests:!1,suggestedLength:void 0},n=parseInt(l("Content-Length"),10);return!Number.isInteger(n)||(i.suggestedLength=n,n<=2*e)||s||!t||l("Accept-Ranges")!=="bytes"||(l("Content-Encoding")||"identity")!=="identity"||(i.allowRangeRequests=!0),i}function Is(l){const t=l("Content-Disposition");if(t){let e=function(s){let i=!0,n=r("filename\\*","i").exec(s);if(n){n=n[1];let u=h(n);return u=unescape(u),u=c(u),u=d(u),o(u)}if(n=function(u){const p=[];let g;const f=r("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(g=f.exec(u))!==null;){let[,m,b,A]=g;if(m=parseInt(m,10),m in p){if(m===0)break}else p[m]=[b,A]}const v=[];for(let m=0;m<p.length&&m in p;++m){let[b,A]=p[m];A=h(A),b&&(A=unescape(A),m===0&&(A=c(A))),v.push(A)}return v.join("")}(s),n)return o(d(n));if(n=r("filename","i").exec(s),n){n=n[1];let u=h(n);return u=d(u),o(u)}function r(u,p){return new RegExp("(?:^|;)\\s*"+u+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',p)}function a(u,p){if(u){if(!/^[\x00-\xFF]+$/.test(p))return p;try{const g=new TextDecoder(u,{fatal:!0}),f=$e(p);p=g.decode(f),i=!1}catch{}}return p}function o(u){return i&&/[\x80-\xff]/.test(u)&&(u=a("utf-8",u),i&&(u=a("iso-8859-1",u))),u}function h(u){if(u.startsWith('"')){const p=u.slice(1).split('\\"');for(let g=0;g<p.length;++g){const f=p[g].indexOf('"');f!==-1&&(p[g]=p[g].slice(0,f),p.length=g+1),p[g]=p[g].replaceAll(/\\(.)/g,"$1")}u=p.join('"')}return u}function c(u){const p=u.indexOf("'");return p===-1?u:a(u.slice(0,p),u.slice(p+1).replace(/^[^']*'/,""))}function d(u){return!u.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(u)?u:u.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(p,g,f,v){if(f==="q"||f==="Q")return a(g,v=(v=v.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,function(m,b){return String.fromCharCode(parseInt(b,16))}));try{v=atob(v)}catch{}return a(g,v)})}return""}(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(Ss(e))return e}return null}function Ue(l,t){return l===404||l===0&&t.startsWith("file:")?new Wt('Missing PDF "'+t+'".'):new He(`Unexpected server response (${l}) while retrieving PDF "${t}".`,l)}function Ti(l){return l===200||l===206}function Pi(l,t,e){return{method:"GET",headers:l,signal:e.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function Li(l){const t=new Headers;for(const e in l){const s=l[e];s!==void 0&&t.append(e,s)}return t}function Ii(l){return l instanceof Uint8Array?l.buffer:l instanceof ArrayBuffer?l:(O(`getArrayBuffer - unexpected data format: ${l}`),new Uint8Array(l).buffer)}class ei{constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.httpHeaders=this.isHttp&&t.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return nt(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new Ir(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new Dr(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Ir{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._headers=Li(this._stream.httpHeaders);const s=e.url;fetch(s,Pi(this._headers,this._withCredentials,this._abortController)).then(i=>{if(!Ti(i.status))throw Ue(i.status,s);this._reader=i.body.getReader(),this._headersCapability.resolve();const n=o=>i.headers.get(o),{allowRangeRequests:r,suggestedLength:a}=Ls({getResponseHeader:n,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=r,this._contentLength=a||this._contentLength,this._filename=Is(n),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Xt("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:Ii(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Dr{constructor(t,e,s){this._stream=t,this._reader=null,this._loaded=0;const i=t.source;this._withCredentials=i.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!i.disableStream,this._abortController=new AbortController,this._headers=Li(this._stream.httpHeaders),this._headers.append("Range",`bytes=${e}-${s-1}`);const n=i.url;fetch(n,Pi(this._headers,this._withCredentials,this._abortController)).then(r=>{if(!Ti(r.status))throw Ue(r.status,n);this._readCapability.resolve(),this._reader=r.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded}),{value:Ii(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Fr{constructor(t,e={}){this.url=t,this.isHttp=/^https?:/i.test(t),this.httpHeaders=this.isHttp&&e.httpHeaders||Object.create(null),this.withCredentials=e.withCredentials||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(t,e,s){const i={begin:t,end:e};for(const n in s)i[n]=s[n];return this.request(i)}requestFull(t){return this.request(t)}request(t){const e=new XMLHttpRequest,s=this.currXhrId++,i=this.pendingRequests[s]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const n in this.httpHeaders){const r=this.httpHeaders[n];r!==void 0&&e.setRequestHeader(n,r)}return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),i.expectedStatus=206):i.expectedStatus=200,e.responseType="arraybuffer",t.onError&&(e.onerror=function(n){t.onError(e.status)}),e.onreadystatechange=this.onStateChange.bind(this,s),e.onprogress=this.onProgress.bind(this,s),i.onHeadersReceived=t.onHeadersReceived,i.onDone=t.onDone,i.onError=t.onError,i.onProgress=t.onProgress,e.send(null),s}onProgress(t,e){const s=this.pendingRequests[t];s&&s.onProgress?.(e)}onStateChange(t,e){const s=this.pendingRequests[t];if(!s)return;const i=s.xhr;if(i.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),i.readyState!==4||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],i.status===0&&this.isHttp)return void s.onError?.(i.status);const n=i.status||200;if(!(n===200&&s.expectedStatus===206)&&n!==s.expectedStatus)return void s.onError?.(i.status);const r=function(a){const o=a.response;return typeof o!="string"?o:$e(o).buffer}(i);if(n===206){const a=i.getResponseHeader("Content-Range"),o=/bytes (\d+)-(\d+)\/(\d+)/.exec(a);s.onDone({begin:parseInt(o[1],10),chunk:r})}else r?s.onDone({begin:0,chunk:r}):s.onError?.(i.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class Or{constructor(t){this._source=t,this._manager=new Fr(t.url,{httpHeaders:t.httpHeaders,withCredentials:t.withCredentials}),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){const e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return nt(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new Nr(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const s=new jr(this._manager,t,e);return s.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Nr{constructor(t,e){this._manager=t;const s={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=e.url,this._fullRequestId=t.requestFull(s),this._headersReceivedCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const t=this._fullRequestId,e=this._manager.getRequestXhr(t),s=r=>e.getResponseHeader(r),{allowRangeRequests:i,suggestedLength:n}=Ls({getResponseHeader:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=n||this._contentLength,this._filename=Is(s),this._isRangeSupported&&this._manager.abortRequest(t),this._headersReceivedCapability.resolve()}_onDone(t){if(t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=Ue(t,this._url),this._headersReceivedCapability.reject(this._storedError);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersReceivedCapability.promise}async read(){if(this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersReceivedCapability.reject(t);for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class jr{constructor(t,e,s){this._manager=t;const i={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=t.url,this._requestId=t.requestRange(e,s,i),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_close(){this.onClosed?.(this)}_onDone(t){const e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0;for(const s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError=Ue(t,this._url);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){this.isStreamingSupported||this.onProgress?.({loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const Di=/^file:\/\/\/[a-zA-Z]:\//;class Br{constructor(t){this.source=t,this.url=function(e){const s=kt.get("url"),i=s.parse(e);return i.protocol==="file:"||i.host?i:/^[a-z]:[/\\]/i.test(e)?s.parse(`file:///${e}`):(i.host||(i.protocol="file:"),i)}(t.url),this.isHttp=this.url.protocol==="http:"||this.url.protocol==="https:",this.isFsUrl=this.url.protocol==="file:",this.httpHeaders=this.isHttp&&t.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return nt(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new zr(this):new Hr(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=this.isFsUrl?new Vr(this,t,e):new $r(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Fi{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers()}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new Xt("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class Oi{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const e=t.source;this._isStreamingSupported=!e.disableStream}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),this._storedError&&this._readableStream.destroy(this._storedError)}}function De(l,t){return{protocol:l.protocol,auth:l.auth,host:l.hostname,port:l.port,path:l.path,method:"GET",headers:t}}class Hr extends Fi{constructor(t){super(t);const e=s=>{if(s.statusCode===404){const a=new Wt(`Missing PDF "${this._url}".`);return this._storedError=a,void this._headersCapability.reject(a)}this._headersCapability.resolve(),this._setReadableStream(s);const i=a=>this._readableStream.headers[a.toLowerCase()],{allowRangeRequests:n,suggestedLength:r}=Ls({getResponseHeader:i,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=n,this._contentLength=r||this._contentLength,this._filename=Is(i)};if(this._request=null,this._url.protocol==="http:"){const s=kt.get("http");this._request=s.request(De(this._url,t.httpHeaders),e)}else{const s=kt.get("https");this._request=s.request(De(this._url,t.httpHeaders),e)}this._request.on("error",s=>{this._storedError=s,this._headersCapability.reject(s)}),this._request.end()}}class $r extends Oi{constructor(t,e,s){super(t),this._httpHeaders={};for(const n in t.httpHeaders){const r=t.httpHeaders[n];r!==void 0&&(this._httpHeaders[n]=r)}this._httpHeaders.Range=`bytes=${e}-${s-1}`;const i=n=>{if(n.statusCode!==404)this._setReadableStream(n);else{const r=new Wt(`Missing PDF "${this._url}".`);this._storedError=r}};if(this._request=null,this._url.protocol==="http:"){const n=kt.get("http");this._request=n.request(De(this._url,this._httpHeaders),i)}else{const n=kt.get("https");this._request=n.request(De(this._url,this._httpHeaders),i)}this._request.on("error",n=>{this._storedError=n}),this._request.end()}}class zr extends Fi{constructor(t){super(t);let e=decodeURIComponent(this._url.path);Di.test(this._url.href)&&(e=e.replace(/^\//,""));const s=kt.get("fs");s.promises.lstat(e).then(i=>{this._contentLength=i.size,this._setReadableStream(s.createReadStream(e)),this._headersCapability.resolve()},i=>{i.code==="ENOENT"&&(i=new Wt(`Missing PDF "${e}".`)),this._storedError=i,this._headersCapability.reject(i)})}}class Vr extends Oi{constructor(t,e,s){super(t);let i=decodeURIComponent(this._url.path);Di.test(this._url.href)&&(i=i.replace(/^\//,""));const n=kt.get("fs");this._setReadableStream(n.createReadStream(i,{start:e,end:s-1}))}}const mt=30;let Fe=class Et{#t=Promise.withResolvers();#e=null;#s=!1;#n=!!globalThis.FontInspector?.enabled;#o=null;#i=null;#r=0;#h=0;#c=null;#d=null;#p=0;#l=0;#a=Object.create(null);#g=[];#m=null;#u=[];#b=new WeakMap;#f=null;static#A=new Map;static#w=new Map;static#x=null;static#S=new Set;constructor({textContentSource:t,container:e,viewport:s}){if(t instanceof ReadableStream)this.#m=t;else{if(typeof t!="object")throw new Error('No "textContentSource" parameter specified.');this.#m=new ReadableStream({start(o){o.enqueue(t),o.close()}})}this.#e=this.#d=e,this.#l=s.scale*(globalThis.devicePixelRatio||1),this.#p=s.rotation,this.#i={prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:null};const{pageWidth:i,pageHeight:n,pageX:r,pageY:a}=s.rawDims;this.#f=[1,0,0,-1,-r,a+n],this.#h=i,this.#r=n,Et.#v(),Gt(e,s),this.#t.promise.catch(()=>{}).then(()=>{Et.#S.delete(this),this.#i=null,this.#a=null})}render(){const t=()=>{this.#c.read().then(({value:e,done:s})=>{s?this.#t.resolve():(this.#o??=e.lang,Object.assign(this.#a,e.styles),this.#C(e.items),t())},this.#t.reject)};return this.#c=this.#m.getReader(),Et.#S.add(this),t(),this.#t.promise}update({viewport:t,onBefore:e=null}){const s=t.scale*(globalThis.devicePixelRatio||1),i=t.rotation;if(i!==this.#p&&(e?.(),this.#p=i,Gt(this.#d,{rotation:i})),s!==this.#l){e?.(),this.#l=s;const n={prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:Et.#y(this.#o)};for(const r of this.#u)n.properties=this.#b.get(r),n.div=r,this.#E(n)}}cancel(){const t=new Xt("TextLayer task cancelled.");this.#c?.cancel(t).catch(()=>{}),this.#c=null,this.#t.reject(t)}get textDivs(){return this.#u}get textContentItemsStr(){return this.#g}#C(t){if(this.#s)return;this.#i.ctx??=Et.#y(this.#o);const e=this.#u,s=this.#g;for(const i of t){if(e.length>1e5)return O("Ignoring additional textDivs for performance reasons."),void(this.#s=!0);if(i.str!==void 0)s.push(i.str),this.#T(i);else if(i.type==="beginMarkedContentProps"||i.type==="beginMarkedContent"){const n=this.#e;this.#e=document.createElement("span"),this.#e.classList.add("markedContent"),i.id!==null&&this.#e.setAttribute("id",`${i.id}`),n.append(this.#e)}else i.type==="endMarkedContent"&&(this.#e=this.#e.parentNode)}}#T(t){const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};this.#u.push(e);const i=k.transform(this.#f,t.transform);let n=Math.atan2(i[1],i[0]);const r=this.#a[t.fontName];r.vertical&&(n+=Math.PI/2);const a=this.#n&&r.fontSubstitution||r.fontFamily,o=Math.hypot(i[2],i[3]),h=o*Et.#_(a,this.#o);let c,d;n===0?(c=i[4],d=i[5]-h):(c=i[4]+h*Math.sin(n),d=i[5]-h*Math.cos(n));const u="calc(var(--scale-factor)*",p=e.style;this.#e===this.#d?(p.left=`${(100*c/this.#h).toFixed(2)}%`,p.top=`${(100*d/this.#r).toFixed(2)}%`):(p.left=`${u}${c.toFixed(2)}px)`,p.top=`${u}${d.toFixed(2)}px)`),p.fontSize=`${u}${(Et.#x*o).toFixed(2)}px)`,p.fontFamily=a,s.fontSize=o,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,this.#n&&(e.dataset.fontName=r.fontSubstitutionLoadedName||t.fontName),n!==0&&(s.angle=n*(180/Math.PI));let g=!1;if(t.str.length>1)g=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const f=Math.abs(t.transform[0]),v=Math.abs(t.transform[3]);f!==v&&Math.max(f,v)/Math.min(f,v)>1.5&&(g=!0)}if(g&&(s.canvasWidth=r.vertical?t.height:t.width),this.#b.set(e,s),this.#i.div=e,this.#i.properties=s,this.#E(this.#i),s.hasText&&this.#e.append(e),s.hasEOL){const f=document.createElement("br");f.setAttribute("role","presentation"),this.#e.append(f)}}#E(t){const{div:e,properties:s,ctx:i,prevFontSize:n,prevFontFamily:r}=t,{style:a}=e;let o="";if(Et.#x>1&&(o=`scale(${1/Et.#x})`),s.canvasWidth!==0&&s.hasText){const{fontFamily:h}=a,{canvasWidth:c,fontSize:d}=s;n===d&&r===h||(i.font=`${d*this.#l}px ${h}`,t.prevFontSize=d,t.prevFontFamily=h);const{width:u}=i.measureText(e.textContent);u>0&&(o=`scaleX(${c*this.#l/u}) ${o}`)}s.angle!==0&&(o=`rotate(${s.angle}deg) ${o}`),o.length>0&&(a.transform=o)}static cleanup(){if(!(this.#S.size>0)){this.#A.clear();for(const{canvas:t}of this.#w.values())t.remove();this.#w.clear()}}static#y(t=null){let e=this.#w.get(t||="");if(!e){const s=document.createElement("canvas");s.className="hiddenCanvasElement",s.lang=t,document.body.append(s),e=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#w.set(t,e)}return e}static#v(){if(this.#x!==null)return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.textContent="X",document.body.append(t),this.#x=t.getBoundingClientRect().height,t.remove()}static#_(t,e){const s=this.#A.get(t);if(s)return s;const i=this.#y(e),n=i.font;i.canvas.width=i.canvas.height=mt,i.font=`30px ${t}`;const r=i.measureText("");let a=r.fontBoundingBoxAscent,o=Math.abs(r.fontBoundingBoxDescent);if(a){const d=a/(a+o);return this.#A.set(t,d),i.canvas.width=i.canvas.height=0,i.font=n,d}i.strokeStyle="red",i.clearRect(0,0,mt,mt),i.strokeText("g",0,0);let h=i.getImageData(0,0,mt,mt).data;o=0;for(let d=h.length-1-3;d>=0;d-=4)if(h[d]>0){o=Math.ceil(d/4/mt);break}i.clearRect(0,0,mt,mt),i.strokeText("A",0,mt),h=i.getImageData(0,0,mt,mt).data,a=0;for(let d=0,u=h.length;d<u;d+=4)if(h[d]>0){a=mt-Math.floor(d/4/mt);break}i.canvas.width=i.canvas.height=0,i.font=n;const c=a?a/(a+o):.8;return this.#A.set(t,c),c}};function Gr(){Si("`renderTextLayer`, please use `TextLayer` instead.");const{textContentSource:l,container:t,viewport:e,...s}=arguments[0],i=Object.keys(s);i.length>0&&O("Ignoring `renderTextLayer` parameters: "+i.join(", "));const n=new Fe({textContentSource:l,container:t,viewport:e}),{textDivs:r,textContentItemsStr:a}=n;return{promise:n.render(),textDivs:r,textContentItemsStr:a}}function Ur(){Si("`updateTextLayer`, please use `TextLayer` instead.")}class fe{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};return function i(n){if(!n)return;let r=null;const a=n.name;if(a==="#text")r=n.value;else{if(!fe.shouldBuildText(a))return;n?.attributes?.textContent?r=n.attributes.textContent:n.value&&(r=n.value)}if(r!==null&&e.push({str:r}),n.children)for(const o of n.children)i(o)}(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}const qr=65536,Wr=dt?class extends Le{_createCanvas(l,t){return kt.get("canvas").createCanvas(l,t)}}:class extends Le{constructor({ownerDocument:l=globalThis.document,enableHWA:t=!1}={}){super({enableHWA:t}),this._document=l}_createCanvas(l,t){const e=this._document.createElement("canvas");return e.width=l,e.height=t,e}},Xr=dt?class extends ze{_fetchData(l,t){return Ri(l).then(e=>({cMapData:e,compressionType:t}))}}:xi,Kr=dt?class extends Pe{}:class extends Pe{#t;#e;#s;#n;#o;#i=0;constructor({docId:l,ownerDocument:t=globalThis.document}={}){super(),this.#s=l,this.#n=t}get#r(){return this.#t||=new Map}get#h(){return this.#o||=new Map}get#c(){if(!this.#e){const l=this.#n.createElement("div"),{style:t}=l;t.visibility="hidden",t.contain="strict",t.width=t.height=0,t.position="absolute",t.top=t.left=0,t.zIndex=-1;const e=this.#n.createElementNS(Tt,"svg");e.setAttribute("width",0),e.setAttribute("height",0),this.#e=this.#n.createElementNS(Tt,"defs"),l.append(e),e.append(this.#e),this.#n.body.append(l)}return this.#e}#d(l){if(l.length===1){const a=l[0],o=new Array(256);for(let c=0;c<256;c++)o[c]=a[c]/255;const h=o.join(",");return[h,h,h]}const[t,e,s]=l,i=new Array(256),n=new Array(256),r=new Array(256);for(let a=0;a<256;a++)i[a]=t[a]/255,n[a]=e[a]/255,r[a]=s[a]/255;return[i.join(","),n.join(","),r.join(",")]}addFilter(l){if(!l)return"none";let t=this.#r.get(l);if(t)return t;const[e,s,i]=this.#d(l),n=l.length===1?e:`${e}${s}${i}`;if(t=this.#r.get(n),t)return this.#r.set(l,t),t;const r=`g_${this.#s}_transfer_map_${this.#i++}`,a=`url(#${r})`;this.#r.set(l,a),this.#r.set(n,a);const o=this.#a(r);return this.#m(e,s,i,o),a}addHCMFilter(l,t){const e=`${l}-${t}`,s="base";let i=this.#h.get(s);if(i?.key===e||(i?(i.filter?.remove(),i.key=e,i.url="none",i.filter=null):(i={key:e,url:"none",filter:null},this.#h.set(s,i)),!l||!t))return i.url;const n=this.#b(l);l=k.makeHexColor(...n);const r=this.#b(t);if(t=k.makeHexColor(...r),this.#c.style.color="",l==="#000000"&&t==="#ffffff"||l===t)return i.url;const a=new Array(256);for(let u=0;u<=255;u++){const p=u/255;a[u]=p<=.03928?p/12.92:((p+.055)/1.055)**2.4}const o=a.join(","),h=`g_${this.#s}_hcm_filter`,c=i.filter=this.#a(h);this.#m(o,o,o,c),this.#l(c);const d=(u,p)=>{const g=n[u]/255,f=r[u]/255,v=new Array(p+1);for(let m=0;m<=p;m++)v[m]=g+m/p*(f-g);return v.join(",")};return this.#m(d(0,5),d(1,5),d(2,5),c),i.url=`url(#${h})`,i.url}addAlphaFilter(l){let t=this.#r.get(l);if(t)return t;const[e]=this.#d([l]),s=`alpha_${e}`;if(t=this.#r.get(s),t)return this.#r.set(l,t),t;const i=`g_${this.#s}_alpha_map_${this.#i++}`,n=`url(#${i})`;this.#r.set(l,n),this.#r.set(s,n);const r=this.#a(i);return this.#u(e,r),n}addLuminosityFilter(l){let t,e,s=this.#r.get(l||"luminosity");if(s)return s;if(l?([t]=this.#d([l]),e=`luminosity_${t}`):e="luminosity",s=this.#r.get(e),s)return this.#r.set(l,s),s;const i=`g_${this.#s}_luminosity_map_${this.#i++}`,n=`url(#${i})`;this.#r.set(l,n),this.#r.set(e,n);const r=this.#a(i);return this.#p(r),l&&this.#u(t,r),n}addHighlightHCMFilter(l,t,e,s,i){const n=`${t}-${e}-${s}-${i}`;let r=this.#h.get(l);if(r?.key===n||(r?(r.filter?.remove(),r.key=n,r.url="none",r.filter=null):(r={key:n,url:"none",filter:null},this.#h.set(l,r)),!t||!e))return r.url;const[a,o]=[t,e].map(this.#b.bind(this));let h=Math.round(.2126*a[0]+.7152*a[1]+.0722*a[2]),c=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),[d,u]=[s,i].map(this.#b.bind(this));c<h&&([h,c,d,u]=[c,h,u,d]),this.#c.style.color="";const p=(v,m,b)=>{const A=new Array(256),w=(c-h)/b,_=v/255,y=(m-v)/(255*b);let E=0;for(let S=0;S<=b;S++){const C=Math.round(h+S*w),I=_+S*y;for(let M=E;M<=C;M++)A[M]=I;E=C+1}for(let S=E;S<256;S++)A[S]=A[E-1];return A.join(",")},g=`g_${this.#s}_hcm_${l}_filter`,f=r.filter=this.#a(g);return this.#l(f),this.#m(p(d[0],u[0],5),p(d[1],u[1],5),p(d[2],u[2],5),f),r.url=`url(#${g})`,r.url}destroy(l=!1){l&&this.#h.size!==0||(this.#e&&(this.#e.parentNode.parentNode.remove(),this.#e=null),this.#t&&(this.#t.clear(),this.#t=null),this.#i=0)}#p(l){const t=this.#n.createElementNS(Tt,"feColorMatrix");t.setAttribute("type","matrix"),t.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"),l.append(t)}#l(l){const t=this.#n.createElementNS(Tt,"feColorMatrix");t.setAttribute("type","matrix"),t.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"),l.append(t)}#a(l){const t=this.#n.createElementNS(Tt,"filter");return t.setAttribute("color-interpolation-filters","sRGB"),t.setAttribute("id",l),this.#c.append(t),t}#g(l,t,e){const s=this.#n.createElementNS(Tt,t);s.setAttribute("type","discrete"),s.setAttribute("tableValues",e),l.append(s)}#m(l,t,e,s){const i=this.#n.createElementNS(Tt,"feComponentTransfer");s.append(i),this.#g(i,"feFuncR",l),this.#g(i,"feFuncG",t),this.#g(i,"feFuncB",e)}#u(l,t){const e=this.#n.createElementNS(Tt,"feComponentTransfer");t.append(e),this.#g(e,"feFuncA",l)}#b(l){return this.#c.style.color=l,hs(getComputedStyle(this.#c).getPropertyValue("color"))}},Yr=dt?class extends Ve{_fetchData(l){return Ri(l)}}:Ei;function Qr(l={}){typeof l=="string"||l instanceof URL?l={url:l}:(l instanceof ArrayBuffer||ArrayBuffer.isView(l))&&(l={data:l});const t=new Ds,{docId:e}=t,s=l.url?function(H){if(H instanceof URL)return H.href;try{return new URL(H,window.location).href}catch{if(dt&&typeof H=="string")return H}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(l.url):null,i=l.data?function(H){if(dt&&Ns!==void 0&&H instanceof Ns)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(H instanceof Uint8Array&&H.byteLength===H.buffer.byteLength)return H;if(typeof H=="string")return $e(H);if(H instanceof ArrayBuffer||ArrayBuffer.isView(H)||typeof H=="object"&&!isNaN(H?.length))return new Uint8Array(H);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(l.data):null,n=l.httpHeaders||null,r=l.withCredentials===!0,a=l.password??null,o=l.range instanceof Ni?l.range:null,h=Number.isInteger(l.rangeChunkSize)&&l.rangeChunkSize>0?l.rangeChunkSize:qr;let c=l.worker instanceof bt?l.worker:null;const d=l.verbosity,u=typeof l.docBaseUrl!="string"||Es(l.docBaseUrl)?null:l.docBaseUrl,p=typeof l.cMapUrl=="string"?l.cMapUrl:null,g=l.cMapPacked!==!1,f=l.CMapReaderFactory||Xr,v=typeof l.standardFontDataUrl=="string"?l.standardFontDataUrl:null,m=l.StandardFontDataFactory||Yr,b=l.stopAtErrors!==!0,A=Number.isInteger(l.maxImageSize)&&l.maxImageSize>-1?l.maxImageSize:-1,w=l.isEvalSupported!==!1,_=typeof l.isOffscreenCanvasSupported=="boolean"?l.isOffscreenCanvasSupported:!dt,y=Number.isInteger(l.canvasMaxAreaInBytes)?l.canvasMaxAreaInBytes:-1,E=typeof l.disableFontFace=="boolean"?l.disableFontFace:dt,S=l.fontExtraProperties===!0,C=l.enableXfa===!0,I=l.ownerDocument||globalThis.document,M=l.disableRange===!0,W=l.disableStream===!0,D=l.disableAutoFetch===!0,B=l.pdfBug===!0,U=l.enableHWA===!0,Y=o?o.length:l.length??NaN,J=typeof l.useSystemFonts=="boolean"?l.useSystemFonts:!dt&&!E,R=typeof l.useWorkerFetch=="boolean"?l.useWorkerFetch:f===xi&&m===Ei&&p&&v&&de(p,document.baseURI)&&de(v,document.baseURI),F=l.canvasFactory||new Wr({ownerDocument:I,enableHWA:U}),_t=l.filterFactory||new Kr({docId:e,ownerDocument:I});Wn(d);const At={canvasFactory:F,filterFactory:_t};if(R||(At.cMapReaderFactory=new f({baseUrl:p,isCompressed:g}),At.standardFontDataFactory=new m({baseUrl:v})),!c){const H={verbosity:d,port:ge.workerPort};c=H.port?bt.fromPort(H):new bt(H),t._worker=c}const tt={docId:e,apiVersion:"4.4.168",data:i,password:a,disableAutoFetch:D,rangeChunkSize:h,length:Y,docBaseUrl:u,enableXfa:C,evaluatorOptions:{maxImageSize:A,disableFontFace:E,ignoreErrors:b,isEvalSupported:w,isOffscreenCanvasSupported:_,canvasMaxAreaInBytes:y,fontExtraProperties:S,useSystemFonts:J,cMapUrl:R?p:null,standardFontDataUrl:R?v:null}},et={disableFontFace:E,fontExtraProperties:S,ownerDocument:I,pdfBug:B,styleElement:null,loadingParams:{disableAutoFetch:D,enableXfa:C}};return c.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const H=c.messageHandler.sendWithPromise("GetDocRequest",tt,i?[i.buffer]:null);let X;if(o)X=new Tr(o,{disableRange:M,disableStream:W});else if(!i){if(!s)throw new Error("getDocument - no `url` parameter provided.");X=(N=>dt?function(){return typeof fetch<"u"&&typeof Response<"u"&&"body"in Response.prototype}()&&de(N.url)?new ei(N):new Br(N):de(N.url)?new ei(N):new Or(N))({url:s,length:Y,httpHeaders:n,withCredentials:r,rangeChunkSize:h,disableRange:M,disableStream:W})}return H.then(N=>{if(t.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const V=new ue(e,N,c.port),lt=new ea(V,t,X,et,At);t._transport=lt,V.send("Ready",null)})}).catch(t._capability.reject),t}function si(l){return typeof l=="object"&&Number.isInteger(l?.num)&&l.num>=0&&Number.isInteger(l?.gen)&&l.gen>=0}class Ds{static#t=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId="d"+Ds.#t++,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await this._transport?.destroy()}catch(t){throw this._worker?.port&&delete this._worker._pendingDestroy,t}this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)}}let Ni=class{constructor(l,t,e=!1,s=null){this.length=l,this.initialData=t,this.progressiveDone=e,this.contentDispositionFilename=s,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(l){this._rangeListeners.push(l)}addProgressListener(l){this._progressListeners.push(l)}addProgressiveReadListener(l){this._progressiveReadListeners.push(l)}addProgressiveDoneListener(l){this._progressiveDoneListeners.push(l)}onDataRange(l,t){for(const e of this._rangeListeners)e(l,t)}onDataProgress(l,t){this._readyCapability.promise.then(()=>{for(const e of this._progressListeners)e(l,t)})}onDataProgressiveRead(l){this._readyCapability.promise.then(()=>{for(const t of this._progressiveReadListeners)t(l)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(const l of this._progressiveDoneListeners)l()})}transportReady(){this._readyCapability.resolve()}requestDataRange(l,t){q("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}};class Jr{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return z(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class Zr{#t=null;#e=!1;constructor(t,e,s,i=!1){this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=i?new Hs:null,this._pdfBug=i,this.commonObjs=s.commonObjs,this.objs=new ji,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:s=0,offsetY:i=0,dontFlip:n=!1}={}){return new me({viewBox:this.view,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return z(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,viewport:e,intent:s="display",annotationMode:i=Nt.ENABLE,transform:n=null,background:r=null,optionalContentConfigPromise:a=null,annotationCanvasMap:o=null,pageColors:h=null,printAnnotationStorage:c=null}){this._stats?.time("Overall");const d=this._transport.getRenderingIntent(s,i,c),{renderingIntent:u,cacheKey:p}=d;this.#e=!1,this.#n(),a||=this._transport.getOptionalContentConfig(u);let g=this._intentStates.get(p);g||(g=Object.create(null),this._intentStates.set(p,g)),g.streamReaderCancelTimeout&&(clearTimeout(g.streamReaderCancelTimeout),g.streamReaderCancelTimeout=null);const f=!!(u&Te);g.displayReadyCapability||(g.displayReadyCapability=Promise.withResolvers(),g.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(d));const v=A=>{g.renderTasks.delete(m),(this._maybeCleanupAfterRender||f)&&(this.#e=!0),this.#s(!f),A?(m.capability.reject(A),this._abortOperatorList({intentState:g,reason:A instanceof Error?A:new Error(A)})):m.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},m=new te({callback:v,params:{canvasContext:t,viewport:e,transform:n,background:r},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:o,operatorList:g.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!f,pdfBug:this._pdfBug,pageColors:h});(g.renderTasks||=new Set).add(m);const b=m.task;return Promise.all([g.displayReadyCapability.promise,a]).then(([A,w])=>{if(this.destroyed)v();else{if(this._stats?.time("Rendering"),!(w.renderingIntent&u))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");m.initializeGraphics({transparency:A,optionalContentConfig:w}),m.operatorListChanged()}}).catch(v),b}getOperatorList({intent:t="display",annotationMode:e=Nt.ENABLE,printAnnotationStorage:s=null}={}){const i=this._transport.getRenderingIntent(t,e,s,!0);let n,r=this._intentStates.get(i.cacheKey);return r||(r=Object.create(null),this._intentStates.set(i.cacheKey,r)),r.opListReadCapability||(n=Object.create(null),n.operatorListChanged=function(){r.operatorList.lastChunk&&(r.opListReadCapability.resolve(r.operatorList),r.renderTasks.delete(n))},r.opListReadCapability=Promise.withResolvers(),(r.renderTasks||=new Set).add(n),r.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(i)),r.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size:s=>s.items.length})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(s=>fe.textContent(s));const e=this.streamTextContent(t);return new Promise(function(s,i){const n=e.getReader(),r={items:[],styles:Object.create(null),lang:null};(function a(){n.read().then(function({value:o,done:h}){h?s(r):(r.lang??=o.lang,Object.assign(r.styles,o.styles),r.items.push(...o.items),a())},i)})()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const s of e.renderTasks)t.push(s.completed),s.cancel();return this.objs.clear(),this.#e=!1,this.#n(),Promise.all(t)}cleanup(t=!1){this.#e=!0;const e=this.#s(!1);return t&&e&&(this._stats&&=new Hs),e}#s(t=!1){if(this.#n(),!this.#e||this.destroyed)return!1;if(t)return this.#t=setTimeout(()=>{this.#t=null,this.#s(!1)},5e3),!1;for(const{renderTasks:e,operatorList:s}of this._intentStates.values())if(e.size>0||!s.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#e=!1,!0}#n(){this.#t&&(clearTimeout(this.#t),this.#t=null)}_startRenderPage(t,e){const s=this._intentStates.get(e);s&&(this._stats?.timeEnd("Page Request"),s.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let s=0,i=t.length;s<i;s++)e.operatorList.fnArray.push(t.fnArray[s]),e.operatorList.argsArray.push(t.argsArray[s]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const s of e.renderTasks)s.operatorListChanged();t.lastChunk&&this.#s(!0)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s}){const{map:i,transfer:n}=s,r=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:i},n).getReader(),a=this._intentStates.get(e);a.streamReader=r;const o=()=>{r.read().then(({value:h,done:c})=>{c?a.streamReader=null:this._transport.destroyed||(this._renderPageChunk(h,a),o())},h=>{if(a.streamReader=null,!this._transport.destroyed){if(a.operatorList){a.operatorList.lastChunk=!0;for(const c of a.renderTasks)c.operatorListChanged();this.#s(!0)}if(a.displayReadyCapability)a.displayReadyCapability.reject(h);else{if(!a.opListReadCapability)throw h;a.opListReadCapability.reject(h)}}})};o()}_abortOperatorList({intentState:t,reason:e,force:s=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!s){if(t.renderTasks.size>0)return;if(e instanceof xs){let i=100;return e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay),void(t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},i))}}if(t.streamReader.cancel(new Xt(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[i,n]of this._intentStates)if(n===t){this._intentStates.delete(i);break}this.cleanup()}}}get stats(){return this._stats}}class ta{#t=new Set;#e=Promise.resolve();postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};this.#e.then(()=>{for(const i of this.#t)i.call(this,s)})}addEventListener(t,e){this.#t.add(e)}removeEventListener(t,e){this.#t.delete(e)}terminate(){this.#t.clear()}}const Lt={isWorkerDisabled:!1,fakeWorkerId:0};dt&&(Lt.isWorkerDisabled=!0,ge.workerSrc||="./pdf.worker.mjs"),Lt.isSameOrigin=function(l,t){let e;try{if(e=new URL(l),!e.origin||e.origin==="null")return!1}catch{return!1}const s=new URL(t,e);return e.origin===s.origin},Lt.createCDNWrapper=function(l){const t=`await import("${l}");`;return URL.createObjectURL(new Blob([t],{type:"text/javascript"}))};class bt{static#t;constructor({name:t=null,port:e=null,verbosity:s=Xn()}={}){if(this.name=t,this.destroyed=!1,this.verbosity=s,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,e){if(bt.#t?.has(e))throw new Error("Cannot use more than one PDFWorker per port.");return(bt.#t||=new WeakMap).set(e,this),void this._initializeFromPort(e)}this._initialize()}get promise(){return dt?Promise.all([kt.promise,this._readyCapability.promise]):this._readyCapability.promise}#e(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new ue("main","worker",t),this._messageHandler.on("ready",function(){}),this.#e()}_initialize(){if(Lt.isWorkerDisabled||bt.#s)return void this._setupFakeWorker();let{workerSrc:t}=bt;try{Lt.isSameOrigin(window.location.href,t)||(t=Lt.createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new ue("main","worker",e),i=()=>{n.abort(),s.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},n=new AbortController;e.addEventListener("error",()=>{this._webWorker||i()},{signal:n.signal}),s.on("test",a=>{n.abort(),!this.destroyed&&a?(this._messageHandler=s,this._port=e,this._webWorker=e,this.#e()):i()}),s.on("ready",a=>{if(n.abort(),this.destroyed)i();else try{r()}catch{this._setupFakeWorker()}});const r=()=>{const a=new Uint8Array;s.send("test",a,[a.buffer])};return void r()}catch{Be("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){Lt.isWorkerDisabled||(O("Setting up fake worker."),Lt.isWorkerDisabled=!0),bt._setupFakeWorkerGlobal.then(t=>{if(this.destroyed)return void this._readyCapability.reject(new Error("Worker was destroyed"));const e=new ta;this._port=e;const s="fake"+Lt.fakeWorkerId++,i=new ue(s+"_worker",s,e);t.setup(i,e),this._messageHandler=new ue(s,s+"_worker",e),this.#e()}).catch(t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),bt.#t?.delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(t){if(!t?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");const e=this.#t?.get(t.port);if(e){if(e._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new bt(t)}static get workerSrc(){if(ge.workerSrc)return ge.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#s(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return z(this,"_setupFakeWorkerGlobal",(async()=>this.#s?this.#s:(await import(this.workerSrc)).WorkerMessageHandler)())}}class ea{#t=new Map;#e=new Map;#s=new Map;#n=new Map;#o=null;constructor(t,e,s,i,n){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new ji,this.fontLoader=new gr({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.cMapReaderFactory=n.cMapReaderFactory,this.standardFontDataFactory=n.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=s,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#i(t,e=null){const s=this.#t.get(t);if(s)return s;const i=this.messageHandler.sendWithPromise(t,e);return this.#t.set(t,i),i}get annotationStorage(){return z(this,"annotationStorage",new Rs)}getRenderingIntent(t,e=Nt.ENABLE,s=null,i=!1){let n=As,r=ls;switch(t){case"any":n=mn;break;case"display":break;case"print":n=Te;break;default:O(`getRenderingIntent - invalid intent: ${t}`)}switch(e){case Nt.DISABLE:n+=An;break;case Nt.ENABLE:break;case Nt.ENABLE_FORMS:n+=vn;break;case Nt.ENABLE_STORAGE:n+=bn,r=(n&Te&&s instanceof Mi?s:this.annotationStorage).serializable;break;default:O(`getRenderingIntent - invalid annotationMode: ${e}`)}return i&&(n+=yn),{renderingIntent:n,cacheKey:`${n}_${r.hash}`,annotationStorageSerializable:r}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#o?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const s of this.#e.values())t.push(s._destroy());this.#e.clear(),this.#s.clear(),this.#n.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#t.clear(),this.filterFactory.destroy(),Fe.cleanup(),this._networkStream?.cancelAllRequests(new Xt("Worker was terminated.")),this.messageHandler&&(this.messageHandler.destroy(),this.messageHandler=null),this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(s,i)=>{nt(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=n=>{this._lastProgress={loaded:n.loaded,total:n.total}},i.onPull=()=>{this._fullReader.read().then(function({value:n,done:r}){r?i.close():(nt(n instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(n),1,[n]))}).catch(n=>{i.error(n)})},i.onCancel=n=>{this._fullReader.cancel(n),i.ready.catch(r=>{if(!this.destroyed)throw r})}}),t.on("ReaderHeadersReady",s=>{const i=Promise.withResolvers(),n=this._fullReader;return n.headersReady.then(()=>{n.isStreamingSupported&&n.isRangeSupported||(this._lastProgress&&e.onProgress?.(this._lastProgress),n.onProgress=r=>{e.onProgress?.({loaded:r.loaded,total:r.total})}),i.resolve({isStreamingSupported:n.isStreamingSupported,isRangeSupported:n.isRangeSupported,contentLength:n.contentLength})},i.reject),i.promise}),t.on("GetRangeReader",(s,i)=>{nt(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const n=this._networkStream.getRangeReader(s.begin,s.end);n?(i.onPull=()=>{n.read().then(function({value:r,done:a}){a?i.close():(nt(r instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(r),1,[r]))}).catch(r=>{i.error(r)})},i.onCancel=r=>{n.cancel(r),i.ready.catch(a=>{if(!this.destroyed)throw a})}):i.close()}),t.on("GetDoc",({pdfInfo:s})=>{this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,e._capability.resolve(new Jr(s,this))}),t.on("DocException",function(s){let i;switch(s.name){case"PasswordException":i=new as(s.message,s.code);break;case"InvalidPDFException":i=new yi(s.message);break;case"MissingPDFException":i=new Wt(s.message);break;case"UnexpectedResponseException":i=new He(s.message,s.status);break;case"UnknownErrorException":i=new os(s.message,s.details);break;default:q("DocException - expected a valid Error.")}e._capability.reject(i)}),t.on("PasswordRequest",s=>{if(this.#o=Promise.withResolvers(),e.onPassword){const i=n=>{n instanceof Error?this.#o.reject(n):this.#o.resolve({password:n})};try{e.onPassword(i,s.code)}catch(n){this.#o.reject(n)}}else this.#o.reject(new as(s.message,s.code));return this.#o.promise}),t.on("DataLoaded",s=>{e.onProgress?.({loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",s=>{this.destroyed||this.#e.get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,i,n])=>{if(this.destroyed||this.commonObjs.has(s))return null;switch(i){case"Font":const{disableFontFace:r,fontExtraProperties:a,pdfBug:o}=this._params;if("error"in n){const u=n.error;O(`Error during font loading: ${u}`),this.commonObjs.resolve(s,u);break}const h=o&&globalThis.FontInspector?.enabled?(u,p)=>globalThis.FontInspector.fontAdded(u,p):null,c=new fr(n,{disableFontFace:r,inspectFont:h});this.fontLoader.bind(c).catch(()=>t.sendWithPromise("FontFallback",{id:s})).finally(()=>{!a&&c.data&&(c.data=null),this.commonObjs.resolve(s,c)});break;case"CopyLocalImage":const{imageRef:d}=n;nt(d,"The imageRef must be defined.");for(const u of this.#e.values())for(const[,p]of u.objs)if(p?.ref===d)return p.dataLen?(this.commonObjs.resolve(s,structuredClone(p)),p.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(s,n);break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([s,i,n,r])=>{if(this.destroyed)return;const a=this.#e.get(i);if(!a.objs.has(s))if(a._intentStates.size!==0)switch(n){case"Image":a.objs.resolve(s,r),r?.dataLen>1e7&&(a._maybeCleanupAfterRender=!0);break;case"Pattern":a.objs.resolve(s,r);break;default:throw new Error(`Got unknown object type ${n}`)}else r?.bitmap?.close()}),t.on("DocProgress",s=>{this.destroyed||e.onProgress?.({loaded:s.loaded,total:s.total})}),t.on("FetchBuiltInCMap",s=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.cMapReaderFactory?this.cMapReaderFactory.fetch(s):Promise.reject(new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter."))),t.on("FetchStandardFontData",s=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.standardFontDataFactory?this.standardFontDataFactory.fetch(s):Promise.reject(new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.")))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&O("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this._fullReader?.filename??null},e).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=t-1,s=this.#s.get(e);if(s)return s;const i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(n=>{if(this.destroyed)throw new Error("Transport destroyed");n.refStr&&this.#n.set(n.refStr,t);const r=new Zr(e,n,this,this._params.pdfBug);return this.#e.set(e,r),r});return this.#s.set(e,i),i}getPageIndex(t){return si(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return this.#i("GetFieldObjects")}hasJSActions(){return this.#i("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return typeof t!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return this.#i("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#i("GetOptionalContentConfig").then(e=>new Rr(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=this.#t.get(t);if(e)return e;const s=this.messageHandler.sendWithPromise(t,null).then(i=>({info:i[0],metadata:i[1]?new kr(i[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return this.#t.set(t,s),s}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of this.#e.values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#t.clear(),this.filterFactory.destroy(!0),Fe.cleanup()}}cachedPageNumber(t){if(!si(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return this.#n.get(e)??null}}const Ce=Symbol("INITIAL_DATA");class ji{#t=Object.create(null);#e(t){return this.#t[t]||={...Promise.withResolvers(),data:Ce}}get(t,e=null){if(e){const i=this.#e(t);return i.promise.then(()=>e(i.data)),null}const s=this.#t[t];if(!s||s.data===Ce)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=this.#t[t];return!!e&&e.data!==Ce}resolve(t,e=null){const s=this.#e(t);s.data=e,s.resolve()}clear(){for(const t in this.#t){const{data:e}=this.#t[t];e?.bitmap?.close()}this.#t=Object.create(null)}*[Symbol.iterator](){for(const t in this.#t){const{data:e}=this.#t[t];e!==Ce&&(yield[t,e])}}}class sa{#t=null;constructor(t){this.#t=t,this.onContinue=null}get promise(){return this.#t.capability.promise}cancel(t=0){this.#t.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this.#t.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this.#t;return t.form||t.canvas&&e?.size>0}}class te{#t=null;static#e=new WeakSet;constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:n,operatorList:r,pageIndex:a,canvasFactory:o,filterFactory:h,useRequestAnimationFrame:c=!1,pdfBug:d=!1,pageColors:u=null}){this.callback=t,this.params=e,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=a,this.canvasFactory=o,this.filterFactory=h,this._pdfBug=d,this.pageColors=u,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=c===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new sa(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(te.#e.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");te.#e.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:s,viewport:i,transform:n,background:r}=this.params;this.gfx=new ee(s,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:n,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.#t&&(window.cancelAnimationFrame(this.#t),this.#t=null),te.#e.delete(this._canvas),this.callback(t||new xs(`Rendering cancelled, page ${this._pageIndex+1}`,e))}operatorListChanged(){this.graphicsReady?(this.stepper?.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||=this._continueBound}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#t=window.requestAnimationFrame(()=>{this.#t=null,this._nextBound().catch(this._cancelBound)}):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),te.#e.delete(this._canvas),this.callback())))}}const ia="4.4.168",na="19fbc8998";function ii(l){return Math.floor(255*Math.max(0,Math.min(1,l))).toString(16).padStart(2,"0")}function ce(l){return Math.max(0,Math.min(255,255*l))}class ni{static CMYK_G([t,e,s,i]){return["G",1-Math.min(1,.3*t+.59*s+.11*e+i)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return[t=ce(t),t,t]}static G_HTML([t]){const e=ii(t);return`#${e}${e}${e}`}static RGB_G([t,e,s]){return["G",.3*t+.59*e+.11*s]}static RGB_rgb(t){return t.map(ce)}static RGB_HTML(t){return`#${t.map(ii).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,s,i]){return["RGB",1-Math.min(1,t+i),1-Math.min(1,s+i),1-Math.min(1,e+i)]}static CMYK_rgb([t,e,s,i]){return[ce(1-Math.min(1,t+i)),ce(1-Math.min(1,s+i)),ce(1-Math.min(1,e+i))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,s]){const i=1-t,n=1-e,r=1-s;return["CMYK",i,n,r,Math.min(i,n,r)]}}class Bi{static setupStorage(t,e,s,i,n){const r=i.getValue(e,{value:null});switch(s.name){case"textarea":if(r.value!==null&&(t.textContent=r.value),n==="print")break;t.addEventListener("input",a=>{i.setValue(e,{value:a.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(r.value===s.attributes.xfaOn?t.setAttribute("checked",!0):r.value===s.attributes.xfaOff&&t.removeAttribute("checked"),n==="print")break;t.addEventListener("change",a=>{i.setValue(e,{value:a.target.checked?a.target.getAttribute("xfaOn"):a.target.getAttribute("xfaOff")})})}else{if(r.value!==null&&t.setAttribute("value",r.value),n==="print")break;t.addEventListener("input",a=>{i.setValue(e,{value:a.target.value})})}break;case"select":if(r.value!==null){t.setAttribute("value",r.value);for(const a of s.children)a.attributes.value===r.value?a.attributes.selected=!0:a.attributes.hasOwnProperty("selected")&&delete a.attributes.selected}t.addEventListener("input",a=>{const o=a.target.options,h=o.selectedIndex===-1?"":o[o.selectedIndex].value;i.setValue(e,{value:h})})}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:n}){const{attributes:r}=e,a=t instanceof HTMLAnchorElement;r.type==="radio"&&(r.name=`${r.name}-${i}`);for(const[o,h]of Object.entries(r))if(h!=null)switch(o){case"class":h.length&&t.setAttribute(o,h.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",h);break;case"style":Object.assign(t.style,h);break;case"textContent":t.textContent=h;break;default:(!a||o!=="href"&&o!=="newWindow")&&t.setAttribute(o,h)}a&&n.addLinkAttributes(t,r.href,r.newWindow),s&&r.dataId&&this.setupStorage(t,r.dataId,e,s)}static render(t){const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,n=t.intent||"display",r=document.createElement(i.name);i.attributes&&this.setAttributes({html:r,element:i,intent:n,linkService:s});const a=n!=="richText",o=t.div;if(o.append(r),t.viewport){const d=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=d}a&&o.setAttribute("class","xfaLayer xfaFont");const h=[];if(i.children.length===0){if(i.value){const d=document.createTextNode(i.value);r.append(d),a&&fe.shouldBuildText(i.name)&&h.push(d)}return{textDivs:h}}const c=[[i,-1,r]];for(;c.length>0;){const[d,u,p]=c.at(-1);if(u+1===d.children.length){c.pop();continue}const g=d.children[++c.at(-1)[1]];if(g===null)continue;const{name:f}=g;if(f==="#text"){const m=document.createTextNode(g.value);h.push(m),p.append(m);continue}const v=g?.attributes?.xmlns?document.createElementNS(g.attributes.xmlns,f):document.createElement(f);if(p.append(v),g.attributes&&this.setAttributes({html:v,element:g,storage:e,intent:n,linkService:s}),g.children?.length>0)c.push([g,-1,v]);else if(g.value){const m=document.createTextNode(g.value);a&&fe.shouldBuildText(f)&&h.push(m),v.append(m)}}for(const d of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))d.setAttribute("readOnly",!0);return{textDivs:h}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const Ae=1e3,Ut=new WeakSet;function It(l){return{width:l[2]-l[0],height:l[3]-l[1]}}class ra{static create(t){switch(t.data.annotationType){case Sn:return new Hi(t);case En:return new aa(t);case Hn:switch(t.data.fieldType){case"Tx":return new oa(t);case"Btn":return t.data.radioButton?new $i(t):t.data.checkBox?new la(t):new ca(t);case"Ch":return new da(t);case"Sig":return new ha(t)}return new Kt(t);case Ai:return new ps(t);case Cn:return new zi(t);case kn:return new pa(t);case Mn:return new ga(t);case Rn:return new fa(t);case Pn:return new Vi(t);case Nn:return new va(t);case jn:return new Gi(t);case Tn:return new ma(t);case Ln:return new ba(t);case In:return new Aa(t);case Dn:return new ya(t);case Fn:return new wa(t);case On:return new Ui(t);case Bn:return new _a(t);default:return new Z(t)}}}class Z{#t=null;#e=!1;#s=null;constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(s)),i&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:s}){return!!(t?.str||e?.str||s?.str)}get hasPopupData(){return Z._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;this.#t||={rect:this.data.rect.slice(0)};const{rect:e}=t;e&&this.#n(e),this.#s?.popup.updateEdited(t)}resetEdited(){this.#t&&(this.#n(this.#t.rect),this.#s?.popup.resetEdited(),this.#t=null)}#n(t){const{container:{style:e},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:r,pageX:a,pageY:o}}}}=this;s?.splice(0,4,...t);const{width:h,height:c}=It(t);e.left=100*(t[0]-a)/n+"%",e.top=100*(r-t[3]+o)/r+"%",i===0?(e.width=100*h/n+"%",e.height=100*c/r+"%"):this.setRotation(i)}_createContainer(t){const{data:e,parent:{page:s,viewport:i}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",e.id),this instanceof Kt||(n.tabIndex=Ae);const{style:r}=n;if(r.zIndex=this.parent.zIndex++,e.popupRef&&n.setAttribute("aria-haspopup","dialog"),e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof ps){const{rotation:f}=e;return e.hasOwnCanvas||f===0||this.setRotation(f,n),n}const{width:a,height:o}=It(e.rect);if(!t&&e.borderStyle.width>0){r.borderWidth=`${e.borderStyle.width}px`;const f=e.borderStyle.horizontalCornerRadius,v=e.borderStyle.verticalCornerRadius;if(f>0||v>0){const b=`calc(${f}px * var(--scale-factor)) / calc(${v}px * var(--scale-factor))`;r.borderRadius=b}else if(this instanceof $i){const b=`calc(${a}px * var(--scale-factor)) / calc(${o}px * var(--scale-factor))`;r.borderRadius=b}switch(e.borderStyle.style){case $n:r.borderStyle="solid";break;case zn:r.borderStyle="dashed";break;case Vn:O("Unimplemented border style: beveled");break;case Gn:O("Unimplemented border style: inset");break;case Un:r.borderBottomStyle="solid"}const m=e.borderColor||null;m?(this.#e=!0,r.borderColor=k.makeHexColor(0|m[0],0|m[1],0|m[2])):r.borderWidth=0}const h=k.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]),{pageWidth:c,pageHeight:d,pageX:u,pageY:p}=i.rawDims;r.left=100*(h[0]-u)/c+"%",r.top=100*(h[1]-p)/d+"%";const{rotation:g}=e;return e.hasOwnCanvas||g===0?(r.width=100*a/c+"%",r.height=100*o/d+"%"):this.setRotation(g,n),n}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims,{width:n,height:r}=It(this.data.rect);let a,o;t%180==0?(a=100*n/s,o=100*r/i):(a=100*r/s,o=100*n/i),e.style.width=`${a}%`,e.style.height=`${o}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,s,i)=>{const n=i.detail[e],r=n[0],a=n.slice(1);i.target.style[s]=ni[`${r}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[s]:ni[`${r}_rgb`](a)})};return z(this,"_commonActions",{display:e=>{const{display:s}=e.detail,i=s%2==1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:s===1||s===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:s}=e.detail;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:s,noView:s})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:e=>{const s=e.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(t,e){const s=this._commonActions;for(const i of Object.keys(e.detail))(t[i]||s[i])?.(e)}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const s=this._commonActions;for(const[i,n]of Object.entries(e)){const r=s[i];r&&(r({detail:{[i]:n},target:t}),delete e[i])}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,s,i,n]=this.data.rect.map(f=>Math.fround(f));if(t.length===8){const[f,v,m,b]=t.subarray(2,6);if(i===f&&n===v&&e===m&&s===b)return}const{style:r}=this.container;let a;if(this.#e){const{borderColor:f,borderWidth:v}=r;r.borderWidth=0,a=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${f}" stroke-width="${v}">`],this.container.classList.add("hasBorder")}const o=i-e,h=n-s,{svgFactory:c}=this,d=c.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0);const u=c.createElement("defs");d.append(u);const p=c.createElement("clipPath"),g=`clippath_${this.data.id}`;p.setAttribute("id",g),p.setAttribute("clipPathUnits","objectBoundingBox"),u.append(p);for(let f=2,v=t.length;f<v;f+=8){const m=t[f],b=t[f+1],A=t[f+2],w=t[f+3],_=c.createElement("rect"),y=(A-e)/o,E=(n-b)/h,S=(m-A)/o,C=(b-w)/h;_.setAttribute("x",y),_.setAttribute("y",E),_.setAttribute("width",S),_.setAttribute("height",C),p.append(_),a?.push(`<rect vector-effect="non-scaling-stroke" x="${y}" y="${E}" width="${S}" height="${C}"/>`)}this.#e&&(a.push("</g></svg>')"),r.backgroundImage=a.join("")),this.container.append(d),this.container.style.clipPath=`url(#${g})`}_createPopup(){const{container:t,data:e}=this;t.setAttribute("aria-haspopup","dialog");const s=this.#s=new ps({data:{color:e.color,titleObj:e.titleObj,modificationDate:e.modificationDate,contentsObj:e.contentsObj,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation},parent:this.parent,elements:[this]});this.parent.div.append(s.render())}render(){q("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const s=[];if(this._fieldObjects){const i=this._fieldObjects[t];if(i)for(const{page:n,id:r,exportValues:a}of i){if(n===-1||r===e)continue;const o=typeof a=="string"?a:null,h=document.querySelector(`[data-element-id="${r}"]`);!h||Ut.has(h)?s.push({id:r,exportValue:o,domElement:h}):O(`_getElementsByName - element not allowed: ${r}`)}return s}for(const i of document.getElementsByName(t)){const{exportValue:n}=i,r=i.getAttribute("data-element-id");r!==e&&Ut.has(i)&&s.push({id:r,exportValue:n,domElement:i})}return s}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}get _isEditable(){return!1}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e})})}}class Hi extends Z{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){const{data:t,linkService:e}=this,s=document.createElement("a");s.setAttribute("data-element-id",t.id);let i=!1;return t.url?(e.addLinkAttributes(s,t.url,t.newWindow),i=!0):t.action?(this._bindNamedAction(s,t.action),i=!0):t.attachment?(this.#e(s,t.attachment,t.attachmentDest),i=!0):t.setOCGState?(this.#s(s,t.setOCGState),i=!0):t.dest?(this._bindLink(s,t.dest),i=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(s,t),i=!0),t.resetForm?(this._bindResetFormAction(s,t.resetForm),i=!0):this.isTooltipOnly&&!i&&(this._bindLink(s,""),i=!0)),this.container.classList.add("linkAnnotation"),i&&this.container.append(s),this.container}#t(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||e==="")&&this.#t()}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),this.#t()}#e(t,e,s=null){t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,s),!1),this.#t()}#s(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),this.#t()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const s=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const i of Object.keys(e.actions)){const n=s.get(i);n&&(t[n]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:i}}),!1))}t.onclick||(t.onclick=()=>!1),this.#t()}_bindResetFormAction(t,e){const s=t.onclick;if(s||(t.href=this.linkService.getAnchorUrl("")),this.#t(),!this._fieldObjects)return O('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(s||(t.onclick=()=>!1));t.onclick=()=>{s?.();const{fields:i,refs:n,include:r}=e,a=[];if(i.length!==0||n.length!==0){const c=new Set(n);for(const d of i){const u=this._fieldObjects[d]||[];for(const{id:p}of u)c.add(p)}for(const d of Object.values(this._fieldObjects))for(const u of d)c.has(u.id)===r&&a.push(u)}else for(const c of Object.values(this._fieldObjects))a.push(...c);const o=this.annotationStorage,h=[];for(const c of a){const{id:d}=c;switch(h.push(d),c.type){case"text":{const p=c.defaultValue||"";o.setValue(d,{value:p});break}case"checkbox":case"radiobutton":{const p=c.defaultValue===c.exportValues;o.setValue(d,{value:p});break}case"combobox":case"listbox":{const p=c.defaultValue||"";o.setValue(d,{value:p});break}default:continue}const u=document.querySelector(`[data-element-id="${d}"]`);u&&(Ut.has(u)?u.dispatchEvent(new Event("resetform")):O(`_bindResetFormAction - element not allowed: ${d}`))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:h,name:"ResetForm"}}),!1}}}class aa extends Z{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(t),this.container}}class Kt extends Z{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&(t.previousSibling?.nodeName==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return pt.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,i,n){s.includes("mouse")?t.addEventListener(s,r=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(r),shift:r.shiftKey,modifier:this._getKeyModifier(r)}})}):t.addEventListener(s,r=>{if(s==="blur"){if(!e.focused||!r.relatedTarget)return;e.focused=!1}else if(s==="focus"){if(e.focused)return;e.focused=!0}n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(r)}})})}_setEventListeners(t,e,s,i){for(const[n,r]of s)(r==="Action"||this.data.actions?.[r])&&(r!=="Focus"&&r!=="Blur"||(e||={focused:!1}),this._setEventListener(t,e,n,r,i),r!=="Focus"||this.data.actions?.Blur?r!=="Blur"||this.data.actions?.Focus||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":k.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||9,n=t.style;let r;const a=o=>Math.round(10*o)/10;if(this.data.multiLine){const o=Math.abs(this.data.rect[3]-this.data.rect[1]-2),h=o/(Math.round(o/(Ke*i))||1);r=Math.min(i,a(h/Ke))}else{const o=Math.abs(this.data.rect[3]-this.data.rect[1]-2);r=Math.min(i,a(o/Ke))}n.fontSize=`calc(${r}px * var(--scale-factor))`,n.color=k.makeHexColor(s[0],s[1],s[2]),this.data.textAlignment!==null&&(n.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class oa extends Kt{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,s,i){const n=this.annotationStorage;for(const r of this._getElementsByName(t.name,t.id))r.domElement&&(r.domElement[e]=s),n.setValue(r.id,{[i]:s})}render(){const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const i=t.getValue(e,{value:this.data.fieldValue});let n=i.value||"";const r=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;r&&n.length>r&&(n=n.slice(0,r));let a=i.formattedValue||this.data.textContent?.join(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/empty-BHW5kDnt.js","assets/sentry-BTyPPF0t.js","assets/empty-CfqAKA3M.js","assets/index-BSfz3Hzd.js","assets/index-n6IrYjfy.js","assets/zeni-epic-state-CbUjX_b3.js","assets/core-D1cXuJMi.js","assets/utils-C_-saZ2j.js","assets/url-CsQlFR2d.js","assets/index-B4eiJr7Z.js","assets/index-3aBFjHPN.js","assets/url-Dq7O3gKi.js"])))=>i.map(i=>d[i]);
2
+ import{L as Ns,_ as _e}from"./zeni-epic-state-CbUjX_b3.js";import{p as Zt,g as fn,a as x}from"./sentry-BTyPPF0t.js";import{j as G}from"./liveblocks-Hyy2O23M.js";import{i as $,c as re}from"./recharts-CrZf7bKF.js";(function(){try{var l=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new l.Error().stack;t&&(l._sentryDebugIds=l._sentryDebugIds||{},l._sentryDebugIds[t]="9d2c58bd-1f88-4061-b5ce-ece07ce555e5",l._sentryDebugIdIdentifier="sentry-dbid-9d2c58bd-1f88-4061-b5ce-ece07ce555e5")}catch{}})();var is={d:(l,t)=>{for(var e in t)is.o(t,e)&&!is.o(l,e)&&Object.defineProperty(l,e,{enumerable:!0,get:t[e]})},o:(l,t)=>Object.prototype.hasOwnProperty.call(l,t)},T=globalThis.pdfjsLib={};is.d(T,{AbortException:()=>Xt,AnnotationEditorLayer:()=>Pt,AnnotationEditorParamsType:()=>L,AnnotationEditorType:()=>j,AnnotationEditorUIManager:()=>jt,AnnotationLayer:()=>xa,AnnotationMode:()=>Nt,CMapCompressionType:()=>rs,ColorPicker:()=>St,DOMSVGFactory:()=>_s,DrawLayer:()=>ct,FeatureTest:()=>pt,GlobalWorkerOptions:()=>ge,ImageKind:()=>Re,InvalidPDFException:()=>yi,MissingPDFException:()=>Wt,OPS:()=>wt,Outliner:()=>gs,PDFDataRangeTransport:()=>Ni,PDFDateString:()=>Ci,PDFWorker:()=>bt,PasswordResponses:()=>qn,PermissionFlag:()=>wn,PixelsPerInch:()=>ae,RenderingCancelledException:()=>xs,TextLayer:()=>Fe,UnexpectedResponseException:()=>He,Util:()=>k,VerbosityLevel:()=>Ne,XfaLayer:()=>Bi,build:()=>na,createValidAbsoluteUrl:()=>Kn,fetchData:()=>Ge,getDocument:()=>Qr,getFilenameFromUrl:()=>or,getPdfFilenameFromUrl:()=>hr,getXfaPageViewport:()=>lr,isDataScheme:()=>Es,isPdfFile:()=>Ss,noContextMenu:()=>gt,normalizeUnicode:()=>Qn,renderTextLayer:()=>Gr,setLayerDimensions:()=>Gt,shadow:()=>z,updateTextLayer:()=>Ur,version:()=>ia});const dt=!(typeof Zt!="object"||Zt+""!="[object process]"||Zt.versions.nw||Zt.versions.electron&&Zt.type&&Zt.type!=="browser"),bi=[1,0,0,1,0,0],ns=[.001,0,0,.001,0,0],Ke=1.35,mn=1,As=2,Te=4,vn=16,bn=32,An=64,yn=256,Nt={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},j={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},L={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35},wn={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Me=0,Ye=1,he=2,_n=3,js=3,xn=4,Re={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},En=1,Sn=2,Cn=3,kn=4,Mn=5,Rn=6,Tn=7,Pn=8,Ln=9,In=10,Dn=11,Fn=12,On=13,Nn=14,jn=15,Ai=16,Bn=17,Hn=20,$n=1,zn=2,Vn=3,Gn=4,Un=5,Ne={ERRORS:0,WARNINGS:1,INFOS:5},rs={NONE:0,BINARY:1},wt={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},qn={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let je=Ne.WARNINGS;function Wn(l){Number.isInteger(l)&&(je=l)}function Xn(){return je}function Be(l){je>=Ne.INFOS&&console.log(`Info: ${l}`)}function O(l){je>=Ne.WARNINGS&&console.log(`Warning: ${l}`)}function q(l){throw new Error(l)}function nt(l,t){l||q(t)}function Kn(l,t=null,e=null){if(!l)return null;try{if(e&&typeof l=="string"&&(e.addDefaultProtocol&&l.startsWith("www.")&&l.match(/\./g)?.length>=2&&(l=`http://${l}`),e.tryConvertEncoding))try{l=decodeURIComponent(escape(l))}catch{}const s=t?new URL(l,t):new URL(l);if(function(i){switch(i?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(s))return s}catch{}return null}function z(l,t,e,s=!1){return Object.defineProperty(l,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const Ht=function(){function l(t,e){this.constructor===l&&q("Cannot initialize BaseException."),this.message=t,this.name=e}return l.prototype=new Error,l.constructor=l,l}();class as extends Ht{constructor(t,e){super(t,"PasswordException"),this.code=e}}class os extends Ht{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class yi extends Ht{constructor(t){super(t,"InvalidPDFException")}}class Wt extends Ht{constructor(t){super(t,"MissingPDFException")}}class He extends Ht{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}}class Yn extends Ht{constructor(t){super(t,"FormatError")}}class Xt extends Ht{constructor(t){super(t,"AbortException")}}function wi(l){typeof l=="object"&&l?.length!==void 0||q("Invalid argument for bytesToString");const t=l.length,e=8192;if(t<e)return String.fromCharCode.apply(null,l);const s=[];for(let i=0;i<t;i+=e){const n=Math.min(i+e,t),r=l.subarray(i,n);s.push(String.fromCharCode.apply(null,r))}return s.join("")}function $e(l){typeof l!="string"&&q("Invalid argument for stringToBytes");const t=l.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=255&l.charCodeAt(s);return e}function ys(l){const t=Object.create(null);for(const[e,s]of l)t[e]=s;return t}class pt{static get isLittleEndian(){return z(this,"isLittleEndian",function(){const t=new Uint8Array(4);return t[0]=1,new Uint32Array(t.buffer,0,1)[0]===1}())}static get isEvalSupported(){return z(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return z(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get platform(){return typeof navigator<"u"&&typeof navigator?.platform=="string"?z(this,"platform",{isMac:navigator.platform.includes("Mac")}):z(this,"platform",{isMac:!1})}static get isCSSRoundSupported(){return z(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const Qe=Array.from(Array(256).keys(),l=>l.toString(16).padStart(2,"0"));class k{static makeHexColor(t,e,s){return`#${Qe[t]}${Qe[e]}${Qe[s]}`}static scaleMinMax(t,e){let s;t[0]?(t[0]<0&&(s=e[0],e[0]=e[2],e[2]=s),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[3],e[3]*=t[3]):(s=e[0],e[0]=e[1],e[1]=s,s=e[2],e[2]=e[3],e[3]=s,t[1]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(s=e[0],e[0]=e[2],e[2]=s),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static applyTransform(t,e){return[t[0]*e[0]+t[1]*e[2]+e[4],t[0]*e[1]+t[1]*e[3]+e[5]]}static applyInverseTransform(t,e){const s=e[0]*e[3]-e[1]*e[2];return[(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/s,(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/s]}static getAxialAlignedBoundingBox(t,e){const s=this.applyTransform(t,e),i=this.applyTransform(t.slice(2,4),e),n=this.applyTransform([t[0],t[3]],e),r=this.applyTransform([t[2],t[1]],e);return[Math.min(s[0],i[0],n[0],r[0]),Math.min(s[1],i[1],n[1],r[1]),Math.max(s[0],i[0],n[0],r[0]),Math.max(s[1],i[1],n[1],r[1])]}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t){const e=[t[0],t[2],t[1],t[3]],s=t[0]*e[0]+t[1]*e[2],i=t[0]*e[1]+t[1]*e[3],n=t[2]*e[0]+t[3]*e[2],r=t[2]*e[1]+t[3]*e[3],a=(s+r)/2,o=Math.sqrt((s+r)**2-4*(s*r-n*i))/2,h=a+o||1,c=a-o||1;return[Math.sqrt(h),Math.sqrt(c)]}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),i=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>i)return null;const n=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),r=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return n>r?null:[s,n,i,r]}static#t(t,e,s,i,n,r,a,o,h,c){if(h<=0||h>=1)return;const d=1-h,u=h*h,p=u*h,g=d*(d*(d*t+3*h*e)+3*u*s)+p*i,f=d*(d*(d*n+3*h*r)+3*u*a)+p*o;c[0]=Math.min(c[0],g),c[1]=Math.min(c[1],f),c[2]=Math.max(c[2],g),c[3]=Math.max(c[3],f)}static#e(t,e,s,i,n,r,a,o,h,c,d,u){if(Math.abs(h)<1e-12)return void(Math.abs(c)>=1e-12&&this.#t(t,e,s,i,n,r,a,o,-d/c,u));const p=c**2-4*d*h;if(p<0)return;const g=Math.sqrt(p),f=2*h;this.#t(t,e,s,i,n,r,a,o,(-c+g)/f,u),this.#t(t,e,s,i,n,r,a,o,(-c-g)/f,u)}static bezierBoundingBox(t,e,s,i,n,r,a,o,h){return h?(h[0]=Math.min(h[0],t,a),h[1]=Math.min(h[1],e,o),h[2]=Math.max(h[2],t,a),h[3]=Math.max(h[3],e,o)):h=[Math.min(t,a),Math.min(e,o),Math.max(t,a),Math.max(e,o)],this.#e(t,s,n,a,e,i,r,o,3*(3*(s-n)-t+a),6*(t-2*s+n),3*(s-t),h),this.#e(t,s,n,a,e,i,r,o,3*(3*(i-r)-e+o),6*(e-2*i+r),3*(i-e),h),h}}let Je=null,Bs=null;function Qn(l){return Je||(Je=/([\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,Bs=new Map([["ſt","ſt"]])),l.replaceAll(Je,(t,e,s)=>e?e.normalize("NFKC"):Bs.get(s))}const _i="pdfjs_internal_id_",Jn=0,Zn=1,tr=2,er=3,sr=4,ir=5,nr=6,rr=7,ar=8;class Pe{constructor(){this.constructor===Pe&&q("Cannot initialize BaseFilterFactory.")}addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,s,i,n){return"none"}destroy(t=!1){}}class Le{#t=!1;constructor({enableHWA:t=!1}={}){this.constructor===Le&&q("Cannot initialize BaseCanvasFactory."),this.#t=t}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!this.#t})}}reset(t,e,s){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||s<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=s}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){q("Abstract method `_createCanvas` called.")}}class ze{constructor({baseUrl:t=null,isCompressed:e=!0}){this.constructor===ze&&q("Cannot initialize BaseCMapReaderFactory."),this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error('The CMap "baseUrl" parameter must be specified, ensure that the "cMapUrl" and "cMapPacked" API parameters are provided.');if(!t)throw new Error("CMap name must be specified.");const e=this.baseUrl+t+(this.isCompressed?".bcmap":""),s=this.isCompressed?rs.BINARY:rs.NONE;return this._fetchData(e,s).catch(i=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}_fetchData(t,e){q("Abstract method `_fetchData` called.")}}class Ve{constructor({baseUrl:t=null}){this.constructor===Ve&&q("Cannot initialize BaseStandardFontDataFactory."),this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error('The standard font "baseUrl" parameter must be specified, ensure that the "standardFontDataUrl" API parameter is provided.');if(!t)throw new Error("Font filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetchData(e).catch(s=>{throw new Error(`Unable to load font data at: ${e}`)})}_fetchData(t){q("Abstract method `_fetchData` called.")}}class ws{constructor(){this.constructor===ws&&q("Cannot initialize BaseSVGFactory.")}create(t,e,s=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const i=this._createSVG("svg:svg");return i.setAttribute("version","1.1"),s||(i.setAttribute("width",`${t}px`),i.setAttribute("height",`${e}px`)),i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${t} ${e}`),i}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){q("Abstract method `_createSVG` called.")}}const Tt="http://www.w3.org/2000/svg";class ae{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function Ge(l,t="text"){if(de(l,document.baseURI)){const e=await fetch(l);if(!e.ok)throw new Error(e.statusText);switch(t){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"json":return e.json()}return e.text()}return new Promise((e,s)=>{const i=new XMLHttpRequest;i.open("GET",l,!0),i.responseType=t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE)if(i.status!==200&&i.status!==0)s(new Error(i.statusText));else{switch(t){case"arraybuffer":case"blob":case"json":return void e(i.response)}e(i.responseText)}},i.send(null)})}class xi extends ze{_fetchData(t,e){return Ge(t,this.isCompressed?"arraybuffer":"text").then(s=>({cMapData:s instanceof ArrayBuffer?new Uint8Array(s):$e(s),compressionType:e}))}}class Ei extends Ve{_fetchData(t){return Ge(t,"arraybuffer").then(e=>new Uint8Array(e))}}class _s extends ws{_createSVG(t){return document.createElementNS(Tt,t)}}class me{constructor({viewBox:t,scale:e,rotation:s,offsetX:i=0,offsetY:n=0,dontFlip:r=!1}){this.viewBox=t,this.scale=e,this.rotation=s,this.offsetX=i,this.offsetY=n;const a=(t[2]+t[0])/2,o=(t[3]+t[1])/2;let h,c,d,u,p,g,f,v;switch((s%=360)<0&&(s+=360),s){case 180:h=-1,c=0,d=0,u=1;break;case 90:h=0,c=1,d=1,u=0;break;case 270:h=0,c=-1,d=-1,u=0;break;case 0:h=1,c=0,d=0,u=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}r&&(d=-d,u=-u),h===0?(p=Math.abs(o-t[1])*e+i,g=Math.abs(a-t[0])*e+n,f=(t[3]-t[1])*e,v=(t[2]-t[0])*e):(p=Math.abs(a-t[0])*e+i,g=Math.abs(o-t[1])*e+n,f=(t[2]-t[0])*e,v=(t[3]-t[1])*e),this.transform=[h*e,c*e,d*e,u*e,p-h*e*a-d*e*o,g-c*e*a-u*e*o],this.width=f,this.height=v}get rawDims(){const{viewBox:t}=this;return z(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:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:n=!1}={}){return new me({viewBox:this.viewBox.slice(),scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}convertToViewportPoint(t,e){return k.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=k.applyTransform([t[0],t[1]],this.transform),s=k.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){return k.applyInverseTransform([t,e],this.transform)}}class xs extends Ht{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function Es(l){const t=l.length;let e=0;for(;e<t&&l[e].trim()==="";)e++;return l.substring(e,e+5).toLowerCase()==="data:"}function Ss(l){return typeof l=="string"&&/\.pdf$/i.test(l)}function or(l){return[l]=l.split(/[#?]/,1),l.substring(l.lastIndexOf("/")+1)}function hr(l,t="document.pdf"){if(typeof l!="string")return t;if(Es(l))return O('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const e=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,s=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(l);let i=e.exec(s[1])||e.exec(s[2])||e.exec(s[3]);if(i&&(i=i[0],i.includes("%")))try{i=e.exec(decodeURIComponent(i))[0]}catch{}return i||t}class Hs{started=Object.create(null);times=[];time(t){t in this.started&&O(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||O(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let e=0;for(const{name:s}of this.times)e=Math.max(s.length,e);for(const{name:s,start:i,end:n}of this.times)t.push(`${s.padEnd(e)} ${n-i}ms
3
+ `);return t.join("")}}function de(l,t){try{const{protocol:e}=t?new URL(l,t):new URL(l);return e==="http:"||e==="https:"}catch{return!1}}function gt(l){l.preventDefault()}function Si(l){console.log("Deprecated API usage: "+l)}let $s;class Ci{static toDateObject(t){if(!t||typeof t!="string")return null;$s||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");const e=$s.exec(t);if(!e)return null;const s=parseInt(e[1],10);let i=parseInt(e[2],10);i=i>=1&&i<=12?i-1:0;let n=parseInt(e[3],10);n=n>=1&&n<=31?n:1;let r=parseInt(e[4],10);r=r>=0&&r<=23?r:0;let a=parseInt(e[5],10);a=a>=0&&a<=59?a:0;let o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;const h=e[7]||"Z";let c=parseInt(e[8],10);c=c>=0&&c<=23?c:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,h==="-"?(r+=c,a+=d):h==="+"&&(r-=c,a-=d),new Date(Date.UTC(s,i,n,r,a,o))}}function lr(l,{scale:t=1,rotation:e=0}){const{width:s,height:i}=l.attributes.style,n=[0,0,parseInt(s),parseInt(i)];return new me({viewBox:n,scale:t,rotation:e})}function hs(l){if(l.startsWith("#")){const t=parseInt(l.slice(1),16);return[(16711680&t)>>16,(65280&t)>>8,255&t]}return l.startsWith("rgb(")?l.slice(4,-1).split(",").map(t=>parseInt(t)):l.startsWith("rgba(")?l.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(O(`Not a valid color format: "${l}"`),[0,0,0])}function K(l){const{a:t,b:e,c:s,d:i,e:n,f:r}=l.getTransform();return[t,e,s,i,n,r]}function Rt(l){const{a:t,b:e,c:s,d:i,e:n,f:r}=l.getTransform().invertSelf();return[t,e,s,i,n,r]}function Gt(l,t,e=!1,s=!0){if(t instanceof me){const{pageWidth:i,pageHeight:n}=t.rawDims,{style:r}=l,a=pt.isCSSRoundSupported,o=`var(--scale-factor) * ${i}px`,h=`var(--scale-factor) * ${n}px`,c=a?`round(${o}, 1px)`:`calc(${o})`,d=a?`round(${h}, 1px)`:`calc(${h})`;e&&t.rotation%180!=0?(r.width=d,r.height=c):(r.width=c,r.height=d)}s&&l.setAttribute("data-main-rotation",t.rotation)}class Cs{#t=null;#e=null;#s;#n=null;constructor(t){this.#s=t}render(){const t=this.#t=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar");const e=this.#s._uiManager._signal;t.addEventListener("contextmenu",gt,{signal:e}),t.addEventListener("pointerdown",Cs.#o,{signal:e});const s=this.#n=document.createElement("div");s.className="buttons",t.append(s);const i=this.#s.toolbarPosition;if(i){const{style:n}=t,r=this.#s._uiManager.direction==="ltr"?1-i[0]:i[0];n.insetInlineEnd=100*r+"%",n.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return this.#c(),t}static#o(t){t.stopPropagation()}#i(t){this.#s._focusEventsAllowed=!1,t.preventDefault(),t.stopPropagation()}#r(t){this.#s._focusEventsAllowed=!0,t.preventDefault(),t.stopPropagation()}#h(t){const e=this.#s._uiManager._signal;t.addEventListener("focusin",this.#i.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#r.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",gt,{signal:e})}hide(){this.#t.classList.add("hidden"),this.#e?.hideDropdown()}show(){this.#t.classList.remove("hidden")}#c(){const t=document.createElement("button");t.className="delete",t.tabIndex=0,t.setAttribute("data-l10n-id",`pdfjs-editor-remove-${this.#s.editorType}-button`),this.#h(t),t.addEventListener("click",e=>{this.#s._uiManager.delete()},{signal:this.#s._uiManager._signal}),this.#n.append(t)}get#d(){const t=document.createElement("div");return t.className="divider",t}addAltTextButton(t){this.#h(t),this.#n.prepend(t,this.#d)}addColorPicker(t){this.#e=t;const e=t.renderButton();this.#h(e),this.#n.prepend(e,this.#d)}remove(){this.#t.remove(),this.#e?.destroy(),this.#e=null}}class cr{#t=null;#e=null;#s;constructor(t){this.#s=t}#n(){const t=this.#e=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",gt,{signal:this.#s._signal});const e=this.#t=document.createElement("div");return e.className="buttons",t.append(e),this.#i(),t}#o(t,e){let s=0,i=0;for(const n of t){const r=n.y+n.height;if(r<s)continue;const a=n.x+(e?n.width:0);r>s?(i=a,s=r):e?a>i&&(i=a):a<i&&(i=a)}return[e?1-i:i,s]}show(t,e,s){const[i,n]=this.#o(e,s),{style:r}=this.#e||=this.#n();t.append(this.#e),r.insetInlineEnd=100*i+"%",r.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){this.#e.remove()}#i(){const t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const s=this.#s._signal;t.addEventListener("contextmenu",gt,{signal:s}),t.addEventListener("click",()=>{this.#s.highlightSelection("floating_button")},{signal:s}),this.#t.append(t)}}function Ie(l,t,e){for(const s of e)t.addEventListener(s,l[s].bind(l))}class dr{#t=0;get id(){return"pdfjs_internal_editor_"+this.#t++}}class ks{#t=function(){if(typeof crypto<"u"&&typeof crypto?.randomUUID=="function")return crypto.randomUUID();const t=new Uint8Array(32);if(typeof crypto<"u"&&typeof crypto?.getRandomValues=="function")crypto.getRandomValues(t);else for(let e=0;e<32;e++)t[e]=Math.floor(255*Math.random());return wi(t)}();#e=0;#s=null;static get _isSVGFittingCanvas(){const 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>',z(this,"_isSVGFittingCanvas",e.decode().then(()=>(t.drawImage(e,0,0,1,1,0,0,1,3),new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0]===0)))}async#n(t,e){this.#s||=new Map;let s=this.#s.get(t);if(s===null)return null;if(s?.bitmap)return s.refCounter+=1,s;try{let i;if(s||={bitmap:null,id:`image_${this.#t}_${this.#e++}`,refCounter:0,isSvg:!1},typeof e=="string"?(s.url=e,i=await Ge(e,"blob")):i=s.file=e,i.type==="image/svg+xml"){const n=ks._isSVGFittingCanvas,r=new FileReader,a=new Image,o=new Promise((h,c)=>{a.onload=()=>{s.bitmap=a,s.isSvg=!0,h()},r.onload=async()=>{const d=s.svgUrl=r.result;a.src=await n?`${d}#svgView(preserveAspectRatio(none))`:d},a.onerror=r.onerror=c});r.readAsDataURL(i),await o}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){console.error(i),s=null}return this.#s.set(t,s),s&&this.#s.set(s.id,s),s}async getFromFile(t){const{lastModified:e,name:s,size:i,type:n}=t;return this.#n(`${e}_${s}_${i}_${n}`,t)}async getFromUrl(t){return this.#n(t,t)}async getFromId(t){this.#s||=new Map;const e=this.#s.get(t);return e?e.bitmap?(e.refCounter+=1,e):e.file?this.getFromFile(e.file):this.getFromUrl(e.url):null}getSvgUrl(t){const e=this.#s.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#s||=new Map;const e=this.#s.get(t);e&&(e.refCounter-=1,e.refCounter===0&&(e.bitmap=null))}isValidId(t){return t.startsWith(`image_${this.#t}_`)}}class ur{#t=[];#e=!1;#s;#n=-1;constructor(t=128){this.#s=t}add({cmd:t,undo:e,post:s,mustExec:i,type:n=NaN,overwriteIfSameType:r=!1,keepUndo:a=!1}){if(i&&t(),this.#e)return;const o={cmd:t,undo:e,post:s,type:n};if(this.#n===-1)return this.#t.length>0&&(this.#t.length=0),this.#n=0,void this.#t.push(o);if(r&&this.#t[this.#n].type===n)return a&&(o.undo=this.#t[this.#n].undo),void(this.#t[this.#n]=o);const h=this.#n+1;h===this.#s?this.#t.splice(0,1):(this.#n=h,h<this.#t.length&&this.#t.splice(h)),this.#t.push(o)}undo(){if(this.#n===-1)return;this.#e=!0;const{undo:t,post:e}=this.#t[this.#n];t(),e?.(),this.#e=!1,this.#n-=1}redo(){if(this.#n<this.#t.length-1){this.#n+=1,this.#e=!0;const{cmd:t,post:e}=this.#t[this.#n];t(),e?.(),this.#e=!1}}hasSomethingToUndo(){return this.#n!==-1}hasSomethingToRedo(){return this.#n<this.#t.length-1}destroy(){this.#t=null}}class ve{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=pt.platform;for(const[s,i,n={}]of t)for(const r of s){const a=r.startsWith("mac+");e&&a?(this.callbacks.set(r.slice(4),{callback:i,options:n}),this.allKeys.add(r.split("+").at(-1))):e||a||(this.callbacks.set(r,{callback:i,options:n}),this.allKeys.add(r.split("+").at(-1)))}}#t(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);const e=this.buffer.join("+");return this.buffer.length=0,e}exec(t,e){if(!this.allKeys.has(e.key))return;const s=this.callbacks.get(this.#t(e));if(!s)return;const{callback:i,options:{bubbles:n=!1,args:r=[],checker:a=null}}=s;a&&!a(t,e)||(i.bind(t,...r,e)(),n||(e.stopPropagation(),e.preventDefault()))}}class Ms{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return function(e){const s=document.createElement("span");s.style.visibility="hidden",document.body.append(s);for(const i of e.keys()){s.style.color=i;const n=window.getComputedStyle(s).color;e.set(i,hs(n))}s.remove()}(t),z(this,"_colors",t)}convert(t){const e=hs(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[s,i]of this._colors)if(i.every((n,r)=>n===e[r]))return Ms._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?k.makeHexColor(...e):t}}class jt{#t=new AbortController;#e=null;#s=new Map;#n=new Map;#o=null;#i=null;#r=null;#h=new ur;#c=0;#d=new Set;#p=null;#l=null;#a=new Set;#g=!1;#m=null;#u=null;#b=null;#f=!1;#A=null;#w=new dr;#x=!1;#S=!1;#C=null;#T=null;#E=null;#y=j.NONE;#v=new Set;#_=null;#k=null;#M=null;#L=this.blur.bind(this);#P=this.focus.bind(this);#F=this.copy.bind(this);#I=this.cut.bind(this);#O=this.paste.bind(this);#D=this.keydown.bind(this);#G=this.keyup.bind(this);#U=this.onEditingAction.bind(this);#z=this.onPageChanging.bind(this);#H=this.onScaleChanging.bind(this);#N=this.onRotationChanging.bind(this);#K={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#V=[0,0];#j=null;#$=null;#Y=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const t=jt.prototype,e=r=>r.#$.contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&r.hasSomethingToControl(),s=(r,{target:a})=>{if(a instanceof HTMLInputElement){const{type:o}=a;return o!=="text"&&o!=="number"}return!0},i=this.TRANSLATE_SMALL,n=this.TRANSLATE_BIG;return z(this,"_keyboardManager",new ve([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],t.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:s}],[["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:s}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&r.#$.contains(a)&&!r.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&r.#$.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}]]))}constructor(t,e,s,i,n,r,a,o,h){this._signal=this.#t.signal,this.#$=t,this.#Y=e,this.#o=s,this._eventBus=i,this._eventBus._on("editingaction",this.#U),this._eventBus._on("pagechanging",this.#z),this._eventBus._on("scalechanging",this.#H),this._eventBus._on("rotationchanging",this.#N),this.#nt(),this.#ht(),this.#Q(),this.#i=n.annotationStorage,this.#m=n.filterFactory,this.#k=r,this.#b=a||null,this.#g=o,this.#E=h||null,this.viewParameters={realScale:ae.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1}destroy(){this.#t?.abort(),this.#t=null,this._signal=null,this._eventBus._off("editingaction",this.#U),this._eventBus._off("pagechanging",this.#z),this._eventBus._off("scalechanging",this.#H),this._eventBus._off("rotationchanging",this.#N);for(const t of this.#n.values())t.destroy();this.#n.clear(),this.#s.clear(),this.#a.clear(),this.#e=null,this.#v.clear(),this.#h.destroy(),this.#o?.destroy(),this.#A?.hide(),this.#A=null,this.#u&&(clearTimeout(this.#u),this.#u=null),this.#j&&(clearTimeout(this.#j),this.#j=null)}async mlGuess(t){return this.#E?.guess(t)||null}get hasMLManager(){return!!this.#E}get hcmFilter(){return z(this,"hcmFilter",this.#k?this.#m.addHCMFilter(this.#k.foreground,this.#k.background):"none")}get direction(){return z(this,"direction",getComputedStyle(this.#$).direction)}get highlightColors(){return z(this,"highlightColors",this.#b?new Map(this.#b.split(",").map(t=>t.split("=").map(e=>e.trim()))):null)}get highlightColorNames(){return z(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}setMainHighlightColorPicker(t){this.#T=t}editAltText(t){this.#o?.editAltText(this,t)}onPageChanging({pageNumber:t}){this.#c=t-1}focusMainContainer(){this.#$.focus()}findParent(t,e){for(const s of this.#n.values()){const{x:i,y:n,width:r,height:a}=s.div.getBoundingClientRect();if(t>=i&&t<=i+r&&e>=n&&e<=n+a)return s}return null}disableUserSelect(t=!1){this.#Y.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#a.add(t)}removeShouldRescale(t){this.#a.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*ae.PDF_TO_CSS_UNITS;for(const e of this.#a)e.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#W({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}highlightSelection(t=""){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:s,anchorOffset:i,focusNode:n,focusOffset:r}=e,a=e.toString(),o=this.#W(e).closest(".textLayer"),h=this.getSelectionBoxes(o);if(h){e.empty(),this.#y===j.NONE&&(this._eventBus.dispatch("showannotationeditorui",{source:this,mode:j.HIGHLIGHT}),this.showAllEditors("highlight",!0,!0));for(const c of this.#n.values())if(c.hasTextLayer(o)){c.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:h,anchorNode:s,anchorOffset:i,focusNode:n,focusOffset:r,text:a});break}}}#st(){const t=document.getSelection();if(!t||t.isCollapsed)return;const e=this.#W(t).closest(".textLayer"),s=this.getSelectionBoxes(e);s&&(this.#A||=new cr(this),this.#A.show(e,s,this.direction==="ltr"))}addToAnnotationStorage(t){t.isEmpty()||!this.#i||this.#i.has(t.id)||this.#i.setValue(t.id,t)}#it(){const t=document.getSelection();if(!t||t.isCollapsed)return void(this.#_&&(this.#A?.hide(),this.#_=null,this.#R({hasSelectedText:!1})));const{anchorNode:e}=t;if(e!==this.#_)if(this.#W(t).closest(".textLayer")){if(this.#A?.hide(),this.#_=e,this.#R({hasSelectedText:!0}),(this.#y===j.HIGHLIGHT||this.#y===j.NONE)&&(this.#y===j.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#f=this.isShiftKeyDown,!this.isShiftKeyDown)){const s=this._signal,i=n=>{n.type==="pointerup"&&n.button!==0||(window.removeEventListener("pointerup",i),window.removeEventListener("blur",i),n.type==="pointerup"&&this.#X("main_toolbar"))};window.addEventListener("pointerup",i,{signal:s}),window.addEventListener("blur",i,{signal:s})}}else this.#_&&(this.#A?.hide(),this.#_=null,this.#R({hasSelectedText:!1}))}#X(t=""){this.#y===j.HIGHLIGHT?this.highlightSelection(t):this.#g&&this.#st()}#nt(){document.addEventListener("selectionchange",this.#it.bind(this),{signal:this._signal})}#rt(){const t=this._signal;window.addEventListener("focus",this.#P,{signal:t}),window.addEventListener("blur",this.#L,{signal:t})}#at(){window.removeEventListener("focus",this.#P),window.removeEventListener("blur",this.#L)}blur(){if(this.isShiftKeyDown=!1,this.#f&&(this.#f=!1,this.#X("main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of this.#v)if(e.div.contains(t)){this.#C=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#C)return;const[t,e]=this.#C;this.#C=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#Q(){const t=this._signal;window.addEventListener("keydown",this.#D,{signal:t}),window.addEventListener("keyup",this.#G,{signal:t})}#ot(){window.removeEventListener("keydown",this.#D),window.removeEventListener("keyup",this.#G)}#J(){const t=this._signal;document.addEventListener("copy",this.#F,{signal:t}),document.addEventListener("cut",this.#I,{signal:t}),document.addEventListener("paste",this.#O,{signal:t})}#Z(){document.removeEventListener("copy",this.#F),document.removeEventListener("cut",this.#I),document.removeEventListener("paste",this.#O)}#ht(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#Q(),this.#J()}removeEditListeners(){this.#ot(),this.#Z()}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of this.#l)if(s.isHandlingMimeForPasting(e))return t.dataTransfer.dropEffect="copy",void t.preventDefault()}drop(t){for(const e of t.dataTransfer.items)for(const s of this.#l)if(s.isHandlingMimeForPasting(e.type))return s.paste(e,this.currentLayer),void t.preventDefault()}copy(t){if(t.preventDefault(),this.#e?.commitOrRemove(),!this.hasSelection)return;const e=[];for(const s of this.#v){const i=s.serialize(!0);i&&e.push(i)}e.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}paste(t){t.preventDefault();const{clipboardData:e}=t;for(const n of e.items)for(const r of this.#l)if(r.isHandlingMimeForPasting(n.type))return void r.paste(n,this.currentLayer);let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(n){return void O(`paste: "${n.message}".`)}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const n=[];for(const o of s){const h=i.deserialize(o);if(!h)return;n.push(h)}const r=()=>{for(const o of n)this.#tt(o);this.#et(n)},a=()=>{for(const o of n)o.remove()};this.addCommands({cmd:r,undo:a,mustExec:!0})}catch(n){O(`paste: "${n.message}".`)}}keydown(t){this.isShiftKeyDown||t.key!=="Shift"||(this.isShiftKeyDown=!0),this.#y===j.NONE||this.isEditorHandlingKeyboard||jt._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,this.#f&&(this.#f=!1,this.#X("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu")}}#R(t){Object.entries(t).some(([e,s])=>this.#K[e]!==s)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#K,t)}),this.#y===j.HIGHLIGHT&&t.hasSelectedEditor===!1&&this.#B([[L.HIGHLIGHT_FREE,!0]]))}#B(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#rt(),this.#J(),this.#R({isEditing:this.#y!==j.NONE,isEmpty:this.#q(),hasSomethingToUndo:this.#h.hasSomethingToUndo(),hasSomethingToRedo:this.#h.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#at(),this.#Z(),this.#R({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#l){this.#l=t;for(const e of this.#l)this.#B(e.defaultPropertiesToUpdate)}}getId(){return this.#w.id}get currentLayer(){return this.#n.get(this.#c)}getLayer(t){return this.#n.get(t)}get currentPageIndex(){return this.#c}addLayer(t){this.#n.set(t.pageIndex,t),this.#x?t.enable():t.disable()}removeLayer(t){this.#n.delete(t.pageIndex)}updateMode(t,e=null,s=!1){if(this.#y!==t){if(this.#y=t,t===j.NONE)return this.setEditingState(!1),void this.#ct();this.setEditingState(!0),this.#lt(),this.unselectAll();for(const i of this.#n.values())i.updateMode(t);if(e||!s){if(e){for(const i of this.#s.values())if(i.annotationElementId===e){this.setSelected(i),i.enterInEditMode();break}}}else this.addNewEditorFromKeyboard()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==this.#y&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){if(this.#l){switch(t){case L.CREATE:return void this.currentLayer.addNewEditor();case L.HIGHLIGHT_DEFAULT_COLOR:this.#T?.updateColor(e);break;case L.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#M||=new Map).set(t,e),this.showAllEditors("highlight",e)}for(const s of this.#v)s.updateParams(t,e);for(const s of this.#l)s.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){for(const i of this.#s.values())i.editorType===t&&i.show(e);(this.#M?.get(L.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#B([[L.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#S!==t){this.#S=t;for(const e of this.#n.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}#lt(){if(!this.#x){this.#x=!0;for(const t of this.#n.values())t.enable();for(const t of this.#s.values())t.enable()}}#ct(){if(this.unselectAll(),this.#x){this.#x=!1;for(const t of this.#n.values())t.disable();for(const t of this.#s.values())t.disable()}}getEditors(t){const e=[];for(const s of this.#s.values())s.pageIndex===t&&e.push(s);return e}getEditor(t){return this.#s.get(t)}addEditor(t){this.#s.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#u&&clearTimeout(this.#u),this.#u=setTimeout(()=>{this.focusMainContainer(),this.#u=null},0)),this.#s.delete(t.id),this.unselect(t),t.annotationElementId&&this.#d.has(t.annotationElementId)||this.#i?.remove(t.id)}addDeletedAnnotationElement(t){this.#d.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#d.has(t)}removeDeletedAnnotationElement(t){this.#d.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#tt(t){const e=this.#n.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#e!==t&&(this.#e=t,t&&this.#B(t.propertiesToUpdate))}get#dt(){let t=null;for(t of this.#v);return t}updateUI(t){this.#dt===t&&this.#B(t.propertiesToUpdate)}toggleSelected(t){if(this.#v.has(t))return this.#v.delete(t),t.unselect(),void this.#R({hasSelectedEditor:this.hasSelection});this.#v.add(t),t.select(),this.#B(t.propertiesToUpdate),this.#R({hasSelectedEditor:!0})}setSelected(t){for(const e of this.#v)e!==t&&e.unselect();this.#v.clear(),this.#v.add(t),t.select(),this.#B(t.propertiesToUpdate),this.#R({hasSelectedEditor:!0})}isSelected(t){return this.#v.has(t)}get firstSelectedEditor(){return this.#v.values().next().value}unselect(t){t.unselect(),this.#v.delete(t),this.#R({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#v.size!==0}get isEnterHandled(){return this.#v.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#h.undo(),this.#R({hasSomethingToUndo:this.#h.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#q()})}redo(){this.#h.redo(),this.#R({hasSomethingToUndo:!0,hasSomethingToRedo:this.#h.hasSomethingToRedo(),isEmpty:this.#q()})}addCommands(t){this.#h.add(t),this.#R({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#q()})}#q(){if(this.#s.size===0)return!0;if(this.#s.size===1)for(const t of this.#s.values())return t.isEmpty();return!1}delete(){if(this.commitOrRemove(),!this.hasSelection)return;const t=[...this.#v];this.addCommands({cmd:()=>{for(const e of t)e.remove()},undo:()=>{for(const e of t)this.#tt(e)},mustExec:!0})}commitOrRemove(){this.#e?.commitOrRemove()}hasSomethingToControl(){return this.#e||this.hasSelection}#et(t){for(const e of this.#v)e.unselect();this.#v.clear();for(const e of t)e.isEmpty()||(this.#v.add(e),e.select());this.#R({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#v)t.commit();this.#et(this.#s.values())}unselectAll(){if((!this.#e||(this.#e.commitOrRemove(),this.#y===j.NONE))&&this.hasSelection){for(const t of this.#v)t.unselect();this.#v.clear(),this.#R({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;this.#V[0]+=t,this.#V[1]+=e;const[i,n]=this.#V,r=[...this.#v];this.#j&&clearTimeout(this.#j),this.#j=setTimeout(()=>{this.#j=null,this.#V[0]=this.#V[1]=0,this.addCommands({cmd:()=>{for(const a of r)this.#s.has(a.id)&&a.translateInPage(i,n)},undo:()=>{for(const a of r)this.#s.has(a.id)&&a.translateInPage(-i,-n)},mustExec:!1})},1e3);for(const a of r)a.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#p=new Map;for(const t of this.#v)this.#p.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#p)return!1;this.disableUserSelect(!1);const t=this.#p;this.#p=null;let e=!1;for(const[{x:i,y:n,pageIndex:r},a]of t)a.newX=i,a.newY=n,a.newPageIndex=r,e||=i!==a.savedX||n!==a.savedY||r!==a.savedPageIndex;if(!e)return!1;const s=(i,n,r,a)=>{if(this.#s.has(i.id)){const o=this.#n.get(a);o?i._setParentAndPosition(o,n,r):(i.pageIndex=a,i.x=n,i.y=r)}};return this.addCommands({cmd:()=>{for(const[i,{newX:n,newY:r,newPageIndex:a}]of t)s(i,n,r,a)},undo:()=>{for(const[i,{savedX:n,savedY:r,savedPageIndex:a}]of t)s(i,n,r,a)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#p)for(const s of this.#p.keys())s.drag(t,e)}rebuild(t){if(t.parent===null){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||this.#v.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#e===t}getActive(){return this.#e}getMode(){return this.#y}get imageManager(){return z(this,"imageManager",new ks)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let h=0,c=e.rangeCount;h<c;h++)if(!t.contains(e.getRangeAt(h).commonAncestorContainer))return null;const{x:s,y:i,width:n,height:r}=t.getBoundingClientRect();let a;switch(t.getAttribute("data-main-rotation")){case"90":a=(h,c,d,u)=>({x:(c-i)/r,y:1-(h+d-s)/n,width:u/r,height:d/n});break;case"180":a=(h,c,d,u)=>({x:1-(h+d-s)/n,y:1-(c+u-i)/r,width:d/n,height:u/r});break;case"270":a=(h,c,d,u)=>({x:1-(c+u-i)/r,y:(h-s)/n,width:u/r,height:d/n});break;default:a=(h,c,d,u)=>({x:(h-s)/n,y:(c-i)/r,width:d/n,height:u/r})}const o=[];for(let h=0,c=e.rangeCount;h<c;h++){const d=e.getRangeAt(h);if(!d.collapsed)for(const{x:u,y:p,width:g,height:f}of d.getClientRects())g!==0&&f!==0&&o.push(a(u,p,g,f))}return o.length===0?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#r||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#r?.delete(t)}renderAnnotationElement(t){const e=this.#r?.get(t.data.id);if(!e)return;const s=this.#i.getRawValue(e);s&&(this.#y!==j.NONE||s.hasBeenModified)&&s.renderAnnotationElement(t)}}class $t{#t="";#e=!1;#s=null;#n=null;#o=null;#i=!1;#r=null;static _l10nPromise=null;constructor(t){this.#r=t}static initialize(t){$t._l10nPromise||=t}async render(){const t=this.#s=document.createElement("button");t.className="altText";const e=await $t._l10nPromise.get("pdfjs-editor-alt-text-button-label");t.textContent=e,t.setAttribute("aria-label",e),t.tabIndex="0";const s=this.#r._uiManager._signal;t.addEventListener("contextmenu",gt,{signal:s}),t.addEventListener("pointerdown",n=>n.stopPropagation(),{signal:s});const i=n=>{n.preventDefault(),this.#r._uiManager.editAltText(this.#r)};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",n=>{n.target===t&&n.key==="Enter"&&(this.#i=!0,i(n))},{signal:s}),await this.#h(),t}finish(){this.#s&&(this.#s.focus({focusVisible:this.#i}),this.#i=!1)}isEmpty(){return!this.#t&&!this.#e}get data(){return{altText:this.#t,decorative:this.#e}}set data({altText:t,decorative:e}){this.#t===t&&this.#e===e||(this.#t=t,this.#e=e,this.#h())}toggle(t=!1){this.#s&&(!t&&this.#o&&(clearTimeout(this.#o),this.#o=null),this.#s.disabled=!t)}destroy(){this.#s?.remove(),this.#s=null,this.#n=null}async#h(){const t=this.#s;if(!t)return;if(!this.#t&&!this.#e)return t.classList.remove("done"),void this.#n?.remove();t.classList.add("done"),$t._l10nPromise.get("pdfjs-editor-alt-text-edit-button-label").then(i=>{t.setAttribute("aria-label",i)});let e=this.#n;if(!e){this.#n=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip");const i=e.id=`alt-text-tooltip-${this.#r.id}`;t.setAttribute("aria-describedby",i);const n=100,r=this.#r._uiManager._signal;r.addEventListener("abort",()=>{clearTimeout(this.#o),this.#o=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#o=setTimeout(()=>{this.#o=null,this.#n.classList.add("show"),this.#r._reportTelemetry({action:"alt_text_tooltip"})},n)},{signal:r}),t.addEventListener("mouseleave",()=>{this.#o&&(clearTimeout(this.#o),this.#o=null),this.#n?.classList.remove("show")},{signal:r})}e.innerText=this.#e?await $t._l10nPromise.get("pdfjs-editor-alt-text-decorative-tooltip"):this.#t,e.parentNode||t.append(e),this.#r.getImageForAltText()?.setAttribute("aria-describedby",e.id)}}class P{#t=null;#e=null;#s=null;#n=!1;#o=!1;#i=null;#r=null;#h=this.focusin.bind(this);#c=this.focusout.bind(this);#d=null;#p="";#l=!1;#a=null;#g=!1;#m=!1;#u=!1;#b=null;#f=0;#A=0;#w=null;_initialOptions=Object.create(null);_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;_l10nPromise=null;#x=!1;#S=P._zIndex++;static _borderLineWidth=-1;static _colorManager=new Ms;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=P.prototype._resizeWithKeyboard,e=jt.TRANSLATE_SMALL,s=jt.TRANSLATE_BIG;return z(this,"_resizerKeyboardManager",new ve([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-s,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[s,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-s]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,s]}],[["Escape","mac+Escape"],P.prototype._stopResizingWithKeyboard]]))}constructor(t){this.constructor===P&&q("Cannot initialize AnnotationEditor."),this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null;const{rotation:e,rawDims:{pageWidth:s,pageHeight:i,pageX:n,pageY:r}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[n,r];const[a,o]=this.parentDimensions;this.x=t.x/a,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return z(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new pr({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e,s){if(P._l10nPromise||=new Map(["pdfjs-editor-alt-text-button-label","pdfjs-editor-alt-text-edit-button-label","pdfjs-editor-alt-text-decorative-tooltip","pdfjs-editor-resizer-label-topLeft","pdfjs-editor-resizer-label-topMiddle","pdfjs-editor-resizer-label-topRight","pdfjs-editor-resizer-label-middleRight","pdfjs-editor-resizer-label-bottomRight","pdfjs-editor-resizer-label-bottomMiddle","pdfjs-editor-resizer-label-bottomLeft","pdfjs-editor-resizer-label-middleLeft"].map(n=>[n,t.get(n.replaceAll(/([A-Z])/g,r=>`-${r.toLowerCase()}`))])),s?.strings)for(const n of s.strings)P._l10nPromise.set(n,t.get(n));if(P._borderLineWidth!==-1)return;const i=getComputedStyle(document.documentElement);P._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){q("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#x}set _isDraggable(t){this.#x=t,this.div?.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(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.#S}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):this.#D(),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#l?this.#l=!1:this.parent.setSelected(this))}focusout(t){if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;t.relatedTarget?.closest(`#${this.id}`)||(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,s,i){const[n,r]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/n,this.y=(e+i)/r,this.fixAndSetPosition()}#C([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this.fixAndSetPosition()}translate(t,e){this.#C(this.parentDimensions,t,e)}translateInPage(t,e){this.#a||=[this.x,this.y],this.#C(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){this.#a||=[this.x,this.y];const[s,i]=this.parentDimensions;if(this.x+=t/s,this.y+=e/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:h,y:c}=this.div.getBoundingClientRect();this.parent.findNewParent(this,h,c)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:n,y:r}=this;const[a,o]=this.getBaseTranslation();n+=a,r+=o,this.div.style.left=`${(100*n).toFixed(2)}%`,this.div.style.top=`${(100*r).toFixed(2)}%`,this.div.scrollIntoView({block:"nearest"})}get _hasBeenMoved(){return!!this.#a&&(this.#a[0]!==this.x||this.#a[1]!==this.y)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=P,i=s/t,n=s/e;switch(this.rotation){case 90:return[-i,n];case 180:return[i,n];case 270:return[i,-n];default:return[-i,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const[e,s]=this.pageDimensions;let{x:i,y:n,width:r,height:a}=this;if(r*=e,a*=s,i*=e,n*=s,this._mustFixPosition)switch(t){case 0:i=Math.max(0,Math.min(e-r,i)),n=Math.max(0,Math.min(s-a,n));break;case 90:i=Math.max(0,Math.min(e-a,i)),n=Math.min(s,Math.max(r,n));break;case 180:i=Math.min(e,Math.max(r,i)),n=Math.min(s,Math.max(a,n));break;case 270:i=Math.min(e,Math.max(a,i)),n=Math.max(0,Math.min(s-r,n))}this.x=i/=e,this.y=n/=s;const[o,h]=this.getBaseTranslation();i+=o,n+=h;const{style:c}=this.div;c.left=`${(100*i).toFixed(2)}%`,c.top=`${(100*n).toFixed(2)}%`,this.moveInDOM()}static#T(t,e,s){switch(s){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return P.#T(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return P.#T(t,e,360-this.parentRotation)}#E(t){switch(t){case 90:{const[e,s]=this.pageDimensions;return[0,-e/s,s/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,s]=this.pageDimensions;return[0,e/s,-s/e,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,s]}=this,i=e*t,n=s*t;return pt.isCSSRoundSupported?[Math.round(i),Math.round(n)]:[i,n]}setDims(t,e){const[s,i]=this.parentDimensions;this.div.style.width=`${(100*t/s).toFixed(2)}%`,this.#o||(this.div.style.height=`${(100*e/i).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:s}=t,i=s.endsWith("%"),n=!this.#o&&e.endsWith("%");if(i&&n)return;const[r,a]=this.parentDimensions;i||(t.width=`${(100*parseFloat(s)/r).toFixed(2)}%`),this.#o||n||(t.height=`${(100*parseFloat(e)/a).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#y(){if(this.#i)return;this.#i=document.createElement("div"),this.#i.classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const s of t){const i=document.createElement("div");this.#i.append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",this.#v.bind(this,s),{signal:e}),i.addEventListener("contextmenu",gt,{signal:e}),i.tabIndex=-1}this.div.prepend(this.#i)}#v(t,e){e.preventDefault();const{isMac:s}=pt.platform;if(e.button!==0||e.ctrlKey&&s)return;this.#s?.toggle(!1);const i=this.#k.bind(this,t),n=this._isDraggable;this._isDraggable=!1;const r=this._uiManager._signal,a={passive:!0,capture:!0,signal:r};this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",i,a),window.addEventListener("contextmenu",gt,{signal:r});const o=this.x,h=this.y,c=this.width,d=this.height,u=this.parent.div.style.cursor,p=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const g=()=>{this.parent.togglePointerEvents(!0),this.#s?.toggle(!0),this._isDraggable=n,window.removeEventListener("pointerup",g),window.removeEventListener("blur",g),window.removeEventListener("pointermove",i,a),window.removeEventListener("contextmenu",gt),this.parent.div.style.cursor=u,this.div.style.cursor=p,this.#_(o,h,c,d)};window.addEventListener("pointerup",g,{signal:r}),window.addEventListener("blur",g,{signal:r})}#_(t,e,s,i){const n=this.x,r=this.y,a=this.width,o=this.height;n===t&&r===e&&a===s&&o===i||this.addCommands({cmd:()=>{this.width=a,this.height=o,this.x=n,this.y=r;const[h,c]=this.parentDimensions;this.setDims(h*a,c*o),this.fixAndSetPosition()},undo:()=>{this.width=s,this.height=i,this.x=t,this.y=e;const[h,c]=this.parentDimensions;this.setDims(h*s,c*i),this.fixAndSetPosition()},mustExec:!0})}#k(t,e){const[s,i]=this.parentDimensions,n=this.x,r=this.y,a=this.width,o=this.height,h=P.MIN_SIZE/s,c=P.MIN_SIZE/i,d=R=>Math.round(1e4*R)/1e4,u=this.#E(this.rotation),p=(R,F)=>[u[0]*R+u[2]*F,u[1]*R+u[3]*F],g=this.#E(360-this.rotation);let f,v,m=!1,b=!1;switch(t){case"topLeft":m=!0,f=(R,F)=>[0,0],v=(R,F)=>[R,F];break;case"topMiddle":f=(R,F)=>[R/2,0],v=(R,F)=>[R/2,F];break;case"topRight":m=!0,f=(R,F)=>[R,0],v=(R,F)=>[0,F];break;case"middleRight":b=!0,f=(R,F)=>[R,F/2],v=(R,F)=>[0,F/2];break;case"bottomRight":m=!0,f=(R,F)=>[R,F],v=(R,F)=>[0,0];break;case"bottomMiddle":f=(R,F)=>[R/2,F],v=(R,F)=>[R/2,0];break;case"bottomLeft":m=!0,f=(R,F)=>[0,F],v=(R,F)=>[R,0];break;case"middleLeft":b=!0,f=(R,F)=>[0,F/2],v=(R,F)=>[R,F/2]}const A=f(a,o),w=v(a,o);let _=p(...w);const y=d(n+_[0]),E=d(r+_[1]);let S=1,C=1,[I,M]=this.screenToPageTranslation(e.movementX,e.movementY);var W,D;if([I,M]=(W=I/s,D=M/i,[g[0]*W+g[2]*D,g[1]*W+g[3]*D]),m){const R=Math.hypot(a,o);S=C=Math.max(Math.min(Math.hypot(w[0]-A[0]-I,w[1]-A[1]-M)/R,1/a,1/o),h/a,c/o)}else b?S=Math.max(h,Math.min(1,Math.abs(w[0]-A[0]-I)))/a:C=Math.max(c,Math.min(1,Math.abs(w[1]-A[1]-M)))/o;const B=d(a*S),U=d(o*C);_=p(...v(B,U));const Y=y-_[0],J=E-_[1];this.width=B,this.height=U,this.x=Y,this.y=J,this.setDims(s*B,i*U),this.fixAndSetPosition()}altTextFinish(){this.#s?.finish()}async addEditToolbar(){return this.#d||this.#m||(this.#d=new Cs(this),this.div.append(this.#d.render()),this.#s&&this.#d.addAltTextButton(await this.#s.render())),this.#d}removeEditToolbar(){this.#d&&(this.#d.remove(),this.#d=null,this.#s?.destroy())}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#s||($t.initialize(P._l10nPromise),this.#s=new $t(this),this.#t&&(this.#s.data=this.#t,this.#t=null),await this.addEditToolbar())}get altTextData(){return this.#s?.data}set altTextData(t){this.#s&&(this.#s.data=t)}hasAltText(){return!this.#s?.isEmpty()}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=this.#n?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground();const t=this._uiManager._signal;this.div.addEventListener("focusin",this.#h,{signal:t}),this.div.addEventListener("focusout",this.#c,{signal:t});const[e,s]=this.parentDimensions;this.parentRotation%180!=0&&(this.div.style.maxWidth=`${(100*s/e).toFixed(2)}%`,this.div.style.maxHeight=`${(100*e/s).toFixed(2)}%`);const[i,n]=this.getInitialTranslation();return this.translate(i,n),Ie(this,this.div,["pointerdown"]),this.div}pointerdown(t){const{isMac:e}=pt.platform;t.button!==0||t.ctrlKey&&e?t.preventDefault():(this.#l=!0,this._isDraggable?this.#L(t):this.#M(t))}#M(t){const{isMac:e}=pt.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#L(t){const e=this._uiManager.isSelected(this);let s,i;this._uiManager.setUpDragSession();const n=this._uiManager._signal;e&&(this.div.classList.add("moving"),s={passive:!0,capture:!0,signal:n},this.#f=t.clientX,this.#A=t.clientY,i=a=>{const{clientX:o,clientY:h}=a,[c,d]=this.screenToPageTranslation(o-this.#f,h-this.#A);this.#f=o,this.#A=h,this._uiManager.dragSelectedEditors(c,d)},window.addEventListener("pointermove",i,s));const r=()=>{window.removeEventListener("pointerup",r),window.removeEventListener("blur",r),e&&(this.div.classList.remove("moving"),window.removeEventListener("pointermove",i,s)),this.#l=!1,this._uiManager.endDragSession()||this.#M(t)};window.addEventListener("pointerup",r,{signal:n}),window.addEventListener("blur",r,{signal:n})}moveInDOM(){this.#b&&clearTimeout(this.#b),this.#b=setTimeout(()=>{this.#b=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition()}getRect(t,e,s=this.rotation){const i=this.parentScale,[n,r]=this.pageDimensions,[a,o]=this.pageTranslation,h=t/i,c=e/i,d=this.x*n,u=this.y*r,p=this.width*n,g=this.height*r;switch(s){case 0:return[d+h+a,r-u-c-g+o,d+h+p+a,r-u-c+o];case 90:return[d+c+a,r-u+h+o,d+c+g+a,r-u+h+p+o];case 180:return[d-h-p+a,r-u+c+o,d-h+a,r-u+c+g+o];case 270:return[d-c-g+a,r-u-h-p+o,d-c+a,r-u-h+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,i,n,r]=t,a=n-s,o=r-i;switch(this.rotation){case 0:return[s,e-r,a,o];case 90:return[s,e-i,o,a];case 180:return[n,e-i,a,o];case 270:return[n,e-r,o,a];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){this.#m=!0}disableEditMode(){this.#m=!1}isInEditMode(){return this.#m}shouldGetKeyboardEvents(){return this.#u}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){const t=this._uiManager._signal;this.div?.addEventListener("focusin",this.#h,{signal:t}),this.div?.addEventListener("focusout",this.#c,{signal:t})}rotate(t){}serialize(t=!1,e=null){q("An editor must be serializable")}static deserialize(t,e,s){const i=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:s});i.rotation=t.rotation,i.#t=t.accessibilityData;const[n,r]=i.pageDimensions,[a,o,h,c]=i.getRectInCurrentCoords(t.rect,r);return i.x=a/n,i.y=o/r,i.width=h/n,i.height=c/r,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.div.removeEventListener("focusin",this.#h),this.div.removeEventListener("focusout",this.#c),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#b&&(clearTimeout(this.#b),this.#b=null),this.#D(),this.removeEditToolbar(),this.#w){for(const t of this.#w.values())clearTimeout(t);this.#w=null}this.parent=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#y(),this.#i.classList.remove("hidden"),Ie(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),this.#r={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#i.children;if(!this.#e){this.#e=Array.from(e);const r=this.#P.bind(this),a=this.#F.bind(this),o=this._uiManager._signal;for(const h of this.#e){const c=h.getAttribute("data-resizer-name");h.setAttribute("role","spinbutton"),h.addEventListener("keydown",r,{signal:o}),h.addEventListener("blur",a,{signal:o}),h.addEventListener("focus",this.#I.bind(this,c),{signal:o}),P._l10nPromise.get(`pdfjs-editor-resizer-label-${c}`).then(d=>h.setAttribute("aria-label",d))}}const s=this.#e[0];let i=0;for(const r of e){if(r===s)break;i++}const n=(360-this.rotation+this.parentRotation)%360/90*(this.#e.length/4);if(n!==i){if(n<i)for(let a=0;a<i-n;a++)this.#i.append(this.#i.firstChild);else if(n>i)for(let a=0;a<n-i;a++)this.#i.firstChild.before(this.#i.lastChild);let r=0;for(const a of e){const o=this.#e[r++].getAttribute("data-resizer-name");P._l10nPromise.get(`pdfjs-editor-resizer-label-${o}`).then(h=>a.setAttribute("aria-label",h))}}this.#O(0),this.#u=!0,this.#i.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#P(t){P._resizerKeyboardManager.exec(this,t)}#F(t){this.#u&&t.relatedTarget?.parentNode!==this.#i&&this.#D()}#I(t){this.#p=this.#u?t:""}#O(t){if(this.#e)for(const e of this.#e)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#u&&this.#k(this.#p,{movementX:t,movementY:e})}#D(){if(this.#u=!1,this.#O(-1),this.#r){const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=this.#r;this.#_(t,e,s,i),this.#r=null}}_stopResizingWithKeyboard(){this.#D(),this.div.focus()}select(){this.makeResizable(),this.div?.classList.add("selectedEditor"),this.#d?this.#d?.show():this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this.#d?.show()})}unselect(){this.#i?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this.#d?.hide()}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#g}set isEditing(t){this.#g=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){this.#o=!0;const s=t/e,{style:i}=this.div;i.aspectRatio=s,i.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,e=!1){if(e){this.#w||=new Map;const{action:s}=t;let i=this.#w.get(s);return i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),this.#w.delete(s),this.#w.size===0&&(this.#w=null)},P._telemetryTimeout),void this.#w.set(s,i)}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.#n=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#n=!0}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent");if(e){if(e.nodeName==="CANVAS"){const s=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),s.before(e)}}else e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){const{firstChild:e}=t.container;e.nodeName==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}}class pr extends P{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex}}}const zs=3285377520,vt=4294901760,Ft=65535;class ki{constructor(t){this.h1=t?4294967295&t:zs,this.h2=t?4294967295&t:zs}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(2*t.length),s=0;for(let f=0,v=t.length;f<v;f++){const m=t.charCodeAt(f);m<=255?e[s++]=m:(e[s++]=m>>>8,e[s++]=255&m)}}else{if(!ArrayBuffer.isView(t))throw new Error("Invalid data format, must be a string or TypedArray.");e=t.slice(),s=e.byteLength}const i=s>>2,n=s-4*i,r=new Uint32Array(e.buffer,0,i);let a=0,o=0,h=this.h1,c=this.h2;const d=3432918353,u=461845907,p=11601,g=13715;for(let f=0;f<i;f++)1&f?(a=r[f],a=a*d&vt|a*p&Ft,a=a<<15|a>>>17,a=a*u&vt|a*g&Ft,h^=a,h=h<<13|h>>>19,h=5*h+3864292196):(o=r[f],o=o*d&vt|o*p&Ft,o=o<<15|o>>>17,o=o*u&vt|o*g&Ft,c^=o,c=c<<13|c>>>19,c=5*c+3864292196);switch(a=0,n){case 3:a^=e[4*i+2]<<16;case 2:a^=e[4*i+1]<<8;case 1:a^=e[4*i],a=a*d&vt|a*p&Ft,a=a<<15|a>>>17,a=a*u&vt|a*g&Ft,1&i?h^=a:c^=a}this.h1=h,this.h2=c}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=3981806797*t&vt|36045*t&Ft,e=4283543511*e&vt|(2950163797*(e<<16|t>>>16)&vt)>>>16,t^=e>>>1,t=444984403*t&vt|60499*t&Ft,e=3301882366*e&vt|(3120437893*(e<<16|t>>>16)&vt)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const ls=Object.freeze({map:null,hash:"",transfer:void 0});class Rs{#t=!1;#e=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const s=this.#e.get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return this.#e.get(t)}remove(t){if(this.#e.delete(t),this.#e.size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const e of this.#e.values())if(e instanceof P)return;this.onAnnotationEditor(null)}}setValue(t,e){const s=this.#e.get(t);let i=!1;if(s!==void 0)for(const[n,r]of Object.entries(e))s[n]!==r&&(i=!0,s[n]=r);else i=!0,this.#e.set(t,e);i&&this.#s(),e instanceof P&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type)}has(t){return this.#e.has(t)}getAll(){return this.#e.size>0?ys(this.#e):null}setAll(t){for(const[e,s]of Object.entries(t))this.setValue(e,s)}get size(){return this.#e.size}#s(){this.#t||(this.#t=!0,typeof this.onSetModified=="function"&&this.onSetModified())}resetModified(){this.#t&&(this.#t=!1,typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new Mi(this)}get serializable(){if(this.#e.size===0)return ls;const t=new Map,e=new ki,s=[],i=Object.create(null);let n=!1;for(const[r,a]of this.#e){const o=a instanceof P?a.serialize(!1,i):a;o&&(t.set(r,o),e.update(`${r}:${JSON.stringify(o)}`),n||=!!o.bitmap)}if(n)for(const r of t.values())r.bitmap&&s.push(r.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:ls}get editorStats(){let t=null;const e=new Map;for(const s of this.#e.values()){if(!(s instanceof P))continue;const i=s.telemetryFinalData;if(!i)continue;const{type:n}=i;e.has(n)||e.set(n,Object.getPrototypeOf(s).constructor),t||=Object.create(null);const r=t[n]||=new Map;for(const[a,o]of Object.entries(i)){if(a==="type")continue;let h=r.get(a);h||(h=new Map,r.set(a,h));const c=h.get(o)??0;h.set(o,c+1)}}for(const[s,i]of e)t[s]=i.computeTelemetryFinalData(t[s]);return t}}class Mi extends Rs{#t;constructor(t){super();const{map:e,hash:s,transfer:i}=t.serializable,n=structuredClone(e,i?{transfer:i}:null);this.#t={map:n,hash:s,transfer:i}}get print(){q("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#t}}class gr{#t=new Set;constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),this.#t.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(t&&!this.#t.has(t.loadedName))if(nt(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:s,src:i,style:n}=t,r=new FontFace(s,i,n);this.addNativeFontFace(r);try{await r.load(),this.#t.add(s),e?.(t)}catch{O(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(r)}}else q("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){const s=t.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(i){throw O(`Failed to load font '${s.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(s=>{const i=this._queueLoadingCallback(s);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){return z(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){let t=!1;return(dt||typeof navigator<"u"&&typeof navigator?.userAgent=="string"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),z(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){const{loadingRequests:e}=this,s={done:!1,complete:function(){for(nt(!s.done,"completeRequest() cannot be called twice."),s.done=!0;e.length>0&&e[0].done;){const i=e.shift();setTimeout(i.callback,0)}},callback:t};return e.push(s),s}get _loadTestFont(){return z(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){function s(m,b){return m.charCodeAt(b)<<24|m.charCodeAt(b+1)<<16|m.charCodeAt(b+2)<<8|255&m.charCodeAt(b+3)}function i(m,b,A,w){return m.substring(0,b)+w+m.substring(b+A)}let n,r;const a=this._document.createElement("canvas");a.width=1,a.height=1;const o=a.getContext("2d");let h=0;const c=`lt${Date.now()}${this.loadTestFontId++}`;let d=this._loadTestFont;d=i(d,976,c.length,c);const u=1482184792;let p=s(d,16);for(n=0,r=c.length-3;n<r;n+=4)p=p-u+s(c,n)|0;var g;n<c.length&&(p=p-u+s(c+"XXX",n)|0),d=i(d,16,4,(g=p,String.fromCharCode(g>>24&255,g>>16&255,g>>8&255,255&g)));const f=`@font-face {font-family:"${c}";src:${`url(data:font/opentype;base64,${btoa(d)});`}}`;this.insertRule(f);const v=this._document.createElement("div");v.style.visibility="hidden",v.style.width=v.style.height="10px",v.style.position="absolute",v.style.top=v.style.left="0px";for(const m of[t.loadedName,c]){const b=this._document.createElement("span");b.textContent="Hi",b.style.fontFamily=m,v.append(b)}this._document.body.append(v),function m(b,A){if(++h>30)return O("Load test font never loaded."),void A();o.font="30px "+b,o.fillText(".",0,20),o.getImageData(0,0,1,1).data[3]>0?A():setTimeout(m.bind(null,b,A))}(c,()=>{v.remove(),e.complete()})}}class fr{constructor(t,{disableFontFace:e=!1,inspectFont:s=null}){this.compiledGlyphs=Object.create(null);for(const i in t)this[i]=t[i];this.disableFontFace=e===!0,this._inspectFont=s}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(this.cssFontInfo){const e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}else t=new FontFace(this.loadedName,this.data,{});return this._inspectFont?.(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const t=wi(this.data),e=`url(data:${this.mimetype};base64,${btoa(t)});`;let s;if(this.cssFontInfo){let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),s=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${e}}`}else s=`@font-face {font-family:"${this.loadedName}";src:${e}}`;return this._inspectFont?.(this,e),s}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];let s;try{s=t.get(this.loadedName+"_path_"+e)}catch(n){O(`getPathGenerator - ignoring character: "${n}".`)}if(!Array.isArray(s)||s.length===0)return this.compiledGlyphs[e]=function(n,r){};const i=[];for(let n=0,r=s.length;n<r;)switch(s[n++]){case Jn:{const[a,o,h,c,d,u]=s.slice(n,n+6);i.push(p=>p.bezierCurveTo(a,o,h,c,d,u)),n+=6}break;case Zn:{const[a,o]=s.slice(n,n+2);i.push(h=>h.moveTo(a,o)),n+=2}break;case tr:{const[a,o]=s.slice(n,n+2);i.push(h=>h.lineTo(a,o)),n+=2}break;case er:{const[a,o,h,c]=s.slice(n,n+4);i.push(d=>d.quadraticCurveTo(a,o,h,c)),n+=4}break;case sr:i.push(a=>a.restore());break;case ir:i.push(a=>a.save());break;case nr:nt(i.length===2,"Scale command is only valid at the third position.");break;case rr:{const[a,o,h,c,d,u]=s.slice(n,n+6);i.push(p=>p.transform(a,o,h,c,d,u)),n+=6}break;case ar:{const[a,o]=s.slice(n,n+2);i.push(h=>h.translate(a,o)),n+=2}}return this.compiledGlyphs[e]=function(n,r){i[0](n),i[1](n),n.scale(r,-r);for(let a=2,o=i.length;a<o;a++)i[a](n)}}}if(dt){var cs=Promise.withResolvers(),ds=null;(async()=>{const l=await _e(()=>import("./empty-BHW5kDnt.js").then(i=>i.e),__vite__mapDeps([0,1,2])),t=await _e(()=>import("./index-BSfz3Hzd.js").then(i=>i.i),__vite__mapDeps([3,1,4,5,6,7,8])),e=await _e(()=>import("./index-B4eiJr7Z.js").then(i=>i.i),__vite__mapDeps([9,1,10,4,5,6,7,8])),s=await _e(()=>import("./url-Dq7O3gKi.js").then(i=>i.u),__vite__mapDeps([11,1,8,7,5,6]));return new Map(Object.entries({fs:l,http:t,https:e,url:s,canvas:void 0,path2d:void 0}))})().then(l=>{ds=l,cs.resolve()},l=>{O(`loadPackages: ${l}`),ds=new Map,cs.resolve()})}class kt{static get promise(){return cs.promise}static get(t){return ds?.get(t)}}const Ri=function(l){return kt.get("fs").promises.readFile(l).then(t=>new Uint8Array(t))},zt="Fill",Ts="Stroke",pe="Shading";function us(l,t){if(!t)return;const e=t[2]-t[0],s=t[3]-t[1],i=new Path2D;i.rect(t[0],t[1],e,s),l.clip(i)}class be{constructor(){this.constructor===be&&q("Cannot initialize BaseShadingPattern.")}getPattern(){q("Abstract method `getPattern` called.")}}class mr extends be{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){let e;this._type==="axial"?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const s of this._colorStops)e.addColorStop(s[0],s[1]);return e}getPattern(t,e,s,i){let n;if(i===Ts||i===zt){const r=e.current.getClippedPathBoundingBox(i,K(t))||[0,0,0,0],a=Math.ceil(r[2]-r[0])||1,o=Math.ceil(r[3]-r[1])||1,h=e.cachedCanvases.getCanvas("pattern",a,o,!0),c=h.context;c.clearRect(0,0,c.canvas.width,c.canvas.height),c.beginPath(),c.rect(0,0,c.canvas.width,c.canvas.height),c.translate(-r[0],-r[1]),s=k.transform(s,[1,0,0,1,r[0],r[1]]),c.transform(...e.baseTransform),this.matrix&&c.transform(...this.matrix),us(c,this._bbox),c.fillStyle=this._createGradient(c),c.fill(),n=t.createPattern(h.canvas,"no-repeat");const d=new DOMMatrix(s);n.setTransform(d)}else us(t,this._bbox),n=this._createGradient(t);return n}}function Ze(l,t,e,s,i,n,r,a){const o=t.coords,h=t.colors,c=l.data,d=4*l.width;let u;o[e+1]>o[s+1]&&(u=e,e=s,s=u,u=n,n=r,r=u),o[s+1]>o[i+1]&&(u=s,s=i,i=u,u=r,r=a,a=u),o[e+1]>o[s+1]&&(u=e,e=s,s=u,u=n,n=r,r=u);const p=(o[e]+t.offsetX)*t.scaleX,g=(o[e+1]+t.offsetY)*t.scaleY,f=(o[s]+t.offsetX)*t.scaleX,v=(o[s+1]+t.offsetY)*t.scaleY,m=(o[i]+t.offsetX)*t.scaleX,b=(o[i+1]+t.offsetY)*t.scaleY;if(g>=b)return;const A=h[n],w=h[n+1],_=h[n+2],y=h[r],E=h[r+1],S=h[r+2],C=h[a],I=h[a+1],M=h[a+2],W=Math.round(g),D=Math.round(b);let B,U,Y,J,R,F,_t,At;for(let tt=W;tt<=D;tt++){if(tt<v){const V=tt<g?0:(g-tt)/(g-v);B=p-(p-f)*V,U=A-(A-y)*V,Y=w-(w-E)*V,J=_-(_-S)*V}else{let V;V=tt>b?1:v===b?0:(v-tt)/(v-b),B=f-(f-m)*V,U=y-(y-C)*V,Y=E-(E-I)*V,J=S-(S-M)*V}let et;et=tt<g?0:tt>b?1:(g-tt)/(g-b),R=p-(p-m)*et,F=A-(A-C)*et,_t=w-(w-I)*et,At=_-(_-M)*et;const H=Math.round(Math.min(B,R)),X=Math.round(Math.max(B,R));let N=d*tt+4*H;for(let V=H;V<=X;V++)et=(B-V)/(B-R),et<0?et=0:et>1&&(et=1),c[N++]=U-(U-F)*et|0,c[N++]=Y-(Y-_t)*et|0,c[N++]=J-(J-At)*et|0,c[N++]=255}}function vr(l,t,e){const s=t.coords,i=t.colors;let n,r;switch(t.type){case"lattice":const a=t.verticesPerRow,o=Math.floor(s.length/a)-1,h=a-1;for(n=0;n<o;n++){let c=n*a;for(let d=0;d<h;d++,c++)Ze(l,e,s[c],s[c+1],s[c+a],i[c],i[c+1],i[c+a]),Ze(l,e,s[c+a+1],s[c+1],s[c+a],i[c+a+1],i[c+1],i[c+a])}break;case"triangles":for(n=0,r=s.length;n<r;n+=3)Ze(l,e,s[n],s[n+1],s[n+2],i[n],i[n+1],i[n+2]);break;default:throw new Error("illegal figure")}}class br extends be{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[7],this._background=t[8],this.matrix=null}_createMeshCanvas(t,e,s){const i=Math.floor(this._bounds[0]),n=Math.floor(this._bounds[1]),r=Math.ceil(this._bounds[2])-i,a=Math.ceil(this._bounds[3])-n,o=Math.min(Math.ceil(Math.abs(r*t[0]*1.1)),3e3),h=Math.min(Math.ceil(Math.abs(a*t[1]*1.1)),3e3),c=r/o,d=a/h,u={coords:this._coords,colors:this._colors,offsetX:-i,offsetY:-n,scaleX:1/c,scaleY:1/d},p=o+4,g=h+4,f=s.getCanvas("mesh",p,g,!1),v=f.context,m=v.createImageData(o,h);if(e){const b=m.data;for(let A=0,w=b.length;A<w;A+=4)b[A]=e[0],b[A+1]=e[1],b[A+2]=e[2],b[A+3]=255}for(const b of this._figures)vr(m,b,u);return v.putImageData(m,2,2),{canvas:f.canvas,offsetX:i-2*c,offsetY:n-2*d,scaleX:c,scaleY:d}}getPattern(t,e,s,i){let n;if(us(t,this._bbox),i===pe)n=k.singularValueDecompose2dScale(K(t));else if(n=k.singularValueDecompose2dScale(e.baseTransform),this.matrix){const a=k.singularValueDecompose2dScale(this.matrix);n=[n[0]*a[0],n[1]*a[1]]}const r=this._createMeshCanvas(n,i===pe?null:this._background,e.cachedCanvases);return i!==pe&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(r.offsetX,r.offsetY),t.scale(r.scaleX,r.scaleY),t.createPattern(r.canvas,"no-repeat")}}class Ar extends be{getPattern(){return"hotpink"}}const yr=1,wr=2;class Ps{static MAX_PATTERN_SIZE=3e3;constructor(t,e,s,i,n){this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.color=e,this.ctx=s,this.canvasGraphicsFactory=i,this.baseTransform=n}createPatternCanvas(t){const e=this.operatorList,s=this.bbox,i=this.xstep,n=this.ystep,r=this.paintType,a=this.tilingType,o=this.color,h=this.canvasGraphicsFactory;Be("TilingType: "+a);const c=s[0],d=s[1],u=s[2],p=s[3],g=k.singularValueDecompose2dScale(this.matrix),f=k.singularValueDecompose2dScale(this.baseTransform),v=[g[0]*f[0],g[1]*f[1]],m=this.getSizeAndScale(i,this.ctx.canvas.width,v[0]),b=this.getSizeAndScale(n,this.ctx.canvas.height,v[1]),A=t.cachedCanvases.getCanvas("pattern",m.size,b.size,!0),w=A.context,_=h.createCanvasGraphics(w);_.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(_,r,o);let y=c,E=d,S=u,C=p;return c<0&&(y=0,S+=Math.abs(c)),d<0&&(E=0,C+=Math.abs(d)),w.translate(-m.scale*y,-b.scale*E),_.transform(m.scale,0,0,b.scale,0,0),w.save(),this.clipBbox(_,y,E,S,C),_.baseTransform=K(_.ctx),_.executeOperatorList(e),_.endDrawing(),{canvas:A.canvas,scaleX:m.scale,scaleY:b.scale,offsetX:y,offsetY:E}}getSizeAndScale(t,e,s){t=Math.abs(t);const i=Math.max(Ps.MAX_PATTERN_SIZE,e);let n=Math.ceil(t*s);return n>=i?n=i:s=n/t,{scale:s,size:n}}clipBbox(t,e,s,i,n){const r=i-e,a=n-s;t.ctx.rect(e,s,r,a),t.current.updateRectMinMax(K(t.ctx),[e,s,i,n]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,s){const i=t.ctx,n=t.current;switch(e){case yr:const r=this.ctx;i.fillStyle=r.fillStyle,i.strokeStyle=r.strokeStyle,n.fillColor=r.fillStyle,n.strokeColor=r.strokeStyle;break;case wr:const a=k.makeHexColor(s[0],s[1],s[2]);i.fillStyle=a,i.strokeStyle=a,n.fillColor=a,n.strokeColor=a;break;default:throw new Yn(`Unsupported paint type: ${e}`)}}getPattern(t,e,s,i){let n=s;i!==pe&&(n=k.transform(n,e.baseTransform),this.matrix&&(n=k.transform(n,this.matrix)));const r=this.createPatternCanvas(e);let a=new DOMMatrix(n);a=a.translate(r.offsetX,r.offsetY),a=a.scale(1/r.scaleX,1/r.scaleY);const o=t.createPattern(r.canvas,"repeat");return o.setTransform(a),o}}function _r({src:l,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:n=4294967295,inverseDecode:r=!1}){const a=pt.isLittleEndian?4278190080:255,[o,h]=r?[n,a]:[a,n],c=s>>3,d=7&s,u=l.length;e=new Uint32Array(e.buffer);let p=0;for(let g=0;g<i;g++){for(const v=t+c;t<v;t++){const m=t<u?l[t]:255;e[p++]=128&m?h:o,e[p++]=64&m?h:o,e[p++]=32&m?h:o,e[p++]=16&m?h:o,e[p++]=8&m?h:o,e[p++]=4&m?h:o,e[p++]=2&m?h:o,e[p++]=1&m?h:o}if(d===0)continue;const f=t<u?l[t++]:255;for(let v=0;v<d;v++)e[p++]=f&1<<7-v?h:o}return{srcPos:t,destPos:p}}const ut=16;class xr{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,s){let i;return this.cache[t]!==void 0?(i=this.cache[t],this.canvasFactory.reset(i,e,s)):(i=this.canvasFactory.create(e,s),this.cache[t]=i),i}delete(t){delete this.cache[t]}clear(){for(const t in this.cache){const e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function xe(l,t,e,s,i,n,r,a,o,h){const[c,d,u,p,g,f]=K(l);if(d===0&&u===0){const v=r*c+g,m=Math.round(v),b=a*p+f,A=Math.round(b),w=(r+o)*c+g,_=Math.abs(Math.round(w)-m)||1,y=(a+h)*p+f,E=Math.abs(Math.round(y)-A)||1;return l.setTransform(Math.sign(c),0,0,Math.sign(p),m,A),l.drawImage(t,e,s,i,n,0,0,_,E),l.setTransform(c,d,u,p,g,f),[_,E]}if(c===0&&p===0){const v=a*u+g,m=Math.round(v),b=r*d+f,A=Math.round(b),w=(a+h)*u+g,_=Math.abs(Math.round(w)-m)||1,y=(r+o)*d+f,E=Math.abs(Math.round(y)-A)||1;return l.setTransform(0,Math.sign(d),Math.sign(u),0,m,A),l.drawImage(t,e,s,i,n,0,0,E,_),l.setTransform(c,d,u,p,g,f),[E,_]}return l.drawImage(t,e,s,i,n,r,a,o,h),[Math.hypot(c,d)*o,Math.hypot(u,p)*h]}class Vs{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=bi,this.textMatrixScale=1,this.fontMatrix=ns,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=Me,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,t,e])}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,e){this.x=t,this.y=e}updatePathMinMax(t,e,s){[e,s]=k.applyTransform([e,s],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,s),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,s)}updateRectMinMax(t,e){const s=k.applyTransform(e,t),i=k.applyTransform(e.slice(2),t),n=k.applyTransform([e[0],e[3]],t),r=k.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,s[0],i[0],n[0],r[0]),this.minY=Math.min(this.minY,s[1],i[1],n[1],r[1]),this.maxX=Math.max(this.maxX,s[0],i[0],n[0],r[0]),this.maxY=Math.max(this.maxY,s[1],i[1],n[1],r[1])}updateScalingPathMinMax(t,e){k.scaleMinMax(t,e),this.minX=Math.min(this.minX,e[0]),this.minY=Math.min(this.minY,e[1]),this.maxX=Math.max(this.maxX,e[2]),this.maxY=Math.max(this.maxY,e[3])}updateCurvePathMinMax(t,e,s,i,n,r,a,o,h,c){const d=k.bezierBoundingBox(e,s,i,n,r,a,o,h,c);c||this.updateRectMinMax(t,d)}getPathBoundingBox(t=zt,e=null){const s=[this.minX,this.minY,this.maxX,this.maxY];if(t===Ts){e||q("Stroke bounding box must include transform.");const i=k.singularValueDecompose2dScale(e),n=i[0]*this.lineWidth/2,r=i[1]*this.lineWidth/2;s[0]-=n,s[1]-=r,s[2]+=n,s[3]+=r}return s}updateClipFromPath(){const t=k.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(t){this.clipBox=t,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(t=zt,e=null){return k.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Gs(l,t){if(typeof ImageData<"u"&&t instanceof ImageData)return void l.putImageData(t,0,0);const e=t.height,s=t.width,i=e%ut,n=(e-i)/ut,r=i===0?n:n+1,a=l.createImageData(s,ut);let o,h=0;const c=t.data,d=a.data;let u,p,g,f;if(t.kind===Re.GRAYSCALE_1BPP){const v=c.byteLength,m=new Uint32Array(d.buffer,0,d.byteLength>>2),b=m.length,A=s+7>>3,w=4294967295,_=pt.isLittleEndian?4278190080:255;for(u=0;u<r;u++){for(g=u<n?ut:i,o=0,p=0;p<g;p++){const y=v-h;let E=0;const S=y>A?s:8*y-7,C=-8&S;let I=0,M=0;for(;E<C;E+=8)M=c[h++],m[o++]=128&M?w:_,m[o++]=64&M?w:_,m[o++]=32&M?w:_,m[o++]=16&M?w:_,m[o++]=8&M?w:_,m[o++]=4&M?w:_,m[o++]=2&M?w:_,m[o++]=1&M?w:_;for(;E<S;E++)I===0&&(M=c[h++],I=128),m[o++]=M&I?w:_,I>>=1}for(;o<b;)m[o++]=0;l.putImageData(a,0,u*ut)}}else if(t.kind===Re.RGBA_32BPP){for(p=0,f=s*ut*4,u=0;u<n;u++)d.set(c.subarray(h,h+f)),h+=f,l.putImageData(a,0,p),p+=ut;u<r&&(f=s*i*4,d.set(c.subarray(h,h+f)),l.putImageData(a,0,p))}else{if(t.kind!==Re.RGB_24BPP)throw new Error(`bad image kind: ${t.kind}`);for(g=ut,f=s*g,u=0;u<r;u++){for(u>=n&&(g=i,f=s*g),o=0,p=f;p--;)d[o++]=c[h++],d[o++]=c[h++],d[o++]=c[h++],d[o++]=255;l.putImageData(a,0,u*ut)}}}function Us(l,t){if(t.bitmap)return void l.drawImage(t.bitmap,0,0);const e=t.height,s=t.width,i=e%ut,n=(e-i)/ut,r=i===0?n:n+1,a=l.createImageData(s,ut);let o=0;const h=t.data,c=a.data;for(let d=0;d<r;d++){const u=d<n?ut:i;({srcPos:o}=_r({src:h,srcPos:o,dest:c,width:s,height:u,nonBlackColor:0})),l.putImageData(a,0,d*ut)}}function le(l,t){const e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of e)l[s]!==void 0&&(t[s]=l[s]);l.setLineDash!==void 0&&(t.setLineDash(l.getLineDash()),t.lineDashOffset=l.lineDashOffset)}function Ee(l){if(l.strokeStyle=l.fillStyle="#000000",l.fillRule="nonzero",l.globalAlpha=1,l.lineWidth=1,l.lineCap="butt",l.lineJoin="miter",l.miterLimit=10,l.globalCompositeOperation="source-over",l.font="10px sans-serif",l.setLineDash!==void 0&&(l.setLineDash([]),l.lineDashOffset=0),!dt){const{filter:t}=l;t!=="none"&&t!==""&&(l.filter="none")}}function qs(l,t){if(t)return!0;const e=k.singularValueDecompose2dScale(l);e[0]=Math.fround(e[0]),e[1]=Math.fround(e[1]);const s=Math.fround((globalThis.devicePixelRatio||1)*ae.PDF_TO_CSS_UNITS);return e[0]<=s&&e[1]<=s}const Er=["butt","round","square"],Sr=["miter","round","bevel"],Cr={},Ws={};class ee{constructor(t,e,s,i,n,{optionalContentConfig:r,markedContentStack:a=null},o,h){this.ctx=t,this.current=new Vs(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=s,this.canvasFactory=i,this.filterFactory=n,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=a||[],this.optionalContentConfig=r,this.cachedCanvases=new xr(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=o,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=h,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t,e=null){return typeof t=="string"?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:i=null}){const n=this.ctx.canvas.width,r=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,n,r),this.ctx.fillStyle=a,s){const o=this.cachedCanvases.getCanvas("transparent",n,r);this.compositeCtx=this.ctx,this.transparentCanvas=o.canvas,this.ctx=o.context,this.ctx.save(),this.ctx.transform(...K(this.compositeCtx))}this.ctx.save(),Ee(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[0]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=K(this.ctx)}executeOperatorList(t,e,s,i){const n=t.argsArray,r=t.fnArray;let a=e||0;const o=n.length;if(o===a)return a;const h=o-a>10&&typeof s=="function",c=h?Date.now()+15:0;let d=0;const u=this.commonObjs,p=this.objs;let g;for(;;){if(i!==void 0&&a===i.nextBreakPoint)return i.breakIt(a,s),a;if(g=r[a],g!==wt.dependency)this[g].apply(this,n[a]);else for(const f of n[a]){const v=f.startsWith("g_")?u:p;if(!v.has(f))return v.get(f,s),a}if(a++,a===o)return a;if(h&&++d>10){if(Date.now()>c)return s(),a;d=0}}}#t(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)}endDrawing(){this.#t(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#e()}#e(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){const s=t.width,i=t.height;let n,r,a=Math.max(Math.hypot(e[0],e[1]),1),o=Math.max(Math.hypot(e[2],e[3]),1),h=s,c=i,d="prescale1";for(;a>2&&h>1||o>2&&c>1;){let u=h,p=c;a>2&&h>1&&(u=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h/2),a/=h/u),o>2&&c>1&&(p=c>=16384?Math.floor(c/2)-1||1:Math.ceil(c)/2,o/=c/p),n=this.cachedCanvases.getCanvas(d,u,p),r=n.context,r.clearRect(0,0,u,p),r.drawImage(t,0,0,h,c,0,0,u,p),t=n.canvas,h=u,c=p,d=d==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:h,paintHeight:c}}_createMaskCanvas(t){const e=this.ctx,{width:s,height:i}=t,n=this.current.fillColor,r=this.current.patternFill,a=K(e);let o,h,c,d;if((t.bitmap||t.data)&&t.count>1){const S=t.bitmap||t.data.buffer;h=JSON.stringify(r?a:[a.slice(0,4),n]),o=this._cachedBitmapsMap.get(S),o||(o=new Map,this._cachedBitmapsMap.set(S,o));const C=o.get(h);if(C&&!r)return{canvas:C,offsetX:Math.round(Math.min(a[0],a[2])+a[4]),offsetY:Math.round(Math.min(a[1],a[3])+a[5])};c=C}c||(d=this.cachedCanvases.getCanvas("maskCanvas",s,i),Us(d.context,t));let u=k.transform(a,[1/s,0,0,-1/i,0,0]);u=k.transform(u,[1,0,0,1,0,-i]);const[p,g,f,v]=k.getAxialAlignedBoundingBox([0,0,s,i],u),m=Math.round(f-p)||1,b=Math.round(v-g)||1,A=this.cachedCanvases.getCanvas("fillCanvas",m,b),w=A.context,_=p,y=g;w.translate(-_,-y),w.transform(...u),c||(c=this._scaleImage(d.canvas,Rt(w)),c=c.img,o&&r&&o.set(h,c)),w.imageSmoothingEnabled=qs(K(w),t.interpolate),xe(w,c,0,0,c.width,c.height,0,0,s,i),w.globalCompositeOperation="source-in";const E=k.transform(Rt(w),[1,0,0,1,-_,-y]);return w.fillStyle=r?n.getPattern(e,this,E,zt):n,w.fillRect(0,0,s,i),o&&!r&&(this.cachedCanvases.delete("fillCanvas"),o.set(h,A.canvas)),{canvas:A.canvas,offsetX:Math.round(_),offsetY:Math.round(y)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=Er[t]}setLineJoin(t){this.ctx.lineJoin=Sr[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const s=this.ctx;s.setLineDash!==void 0&&(s.setLineDash(t),s.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[e,s]of t)switch(e){case"LW":this.setLineWidth(s);break;case"LC":this.setLineCap(s);break;case"LJ":this.setLineJoin(s);break;case"ML":this.setMiterLimit(s);break;case"D":this.setDash(s[0],s[1]);break;case"RI":this.setRenderingIntent(s);break;case"FL":this.setFlatness(s);break;case"Font":this.setFont(s[0],s[1]);break;case"CA":this.current.strokeAlpha=s;break;case"ca":this.current.fillAlpha=s,this.ctx.globalAlpha=s;break;case"BM":this.ctx.globalCompositeOperation=s;break;case"SMask":this.current.activeSMask=s?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(s)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const t=this.ctx.canvas.width,e=this.ctx.canvas.height,s="smaskGroupAt"+this.groupLevel,i=this.cachedCanvases.getCanvas(s,t,e);this.suspendedCtx=this.ctx,this.ctx=i.context;const n=this.ctx;n.setTransform(...K(this.suspendedCtx)),le(this.suspendedCtx,n),function(r,a){if(r._removeMirroring)throw new 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(o,h){a.translate(o,h),this.__originalTranslate(o,h)},r.scale=function(o,h){a.scale(o,h),this.__originalScale(o,h)},r.transform=function(o,h,c,d,u,p){a.transform(o,h,c,d,u,p),this.__originalTransform(o,h,c,d,u,p)},r.setTransform=function(o,h,c,d,u,p){a.setTransform(o,h,c,d,u,p),this.__originalSetTransform(o,h,c,d,u,p)},r.resetTransform=function(){a.resetTransform(),this.__originalResetTransform()},r.rotate=function(o){a.rotate(o),this.__originalRotate(o)},r.clip=function(o){a.clip(o),this.__originalClip(o)},r.moveTo=function(o,h){a.moveTo(o,h),this.__originalMoveTo(o,h)},r.lineTo=function(o,h){a.lineTo(o,h),this.__originalLineTo(o,h)},r.bezierCurveTo=function(o,h,c,d,u,p){a.bezierCurveTo(o,h,c,d,u,p),this.__originalBezierCurveTo(o,h,c,d,u,p)},r.rect=function(o,h,c,d){a.rect(o,h,c,d),this.__originalRect(o,h,c,d)},r.closePath=function(){a.closePath(),this.__originalClosePath()},r.beginPath=function(){a.beginPath(),this.__originalBeginPath()}}(n,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),le(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,s=this.suspendedCtx;this.composeSMask(s,e,this.ctx,t),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(t,e,s,i){const n=i[0],r=i[1],a=i[2]-n,o=i[3]-r;a!==0&&o!==0&&(this.genericComposeSMask(e.context,s,a,o,e.subtype,e.backdrop,e.transferMap,n,r,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(s.canvas,0,0),t.restore())}genericComposeSMask(t,e,s,i,n,r,a,o,h,c,d){let u=t.canvas,p=o-c,g=h-d;if(r){if(p<0||g<0||p+s>u.width||g+i>u.height){const v=this.cachedCanvases.getCanvas("maskExtension",s,i),m=v.context;m.drawImage(u,-p,-g),r.some(b=>b!==0)&&(m.globalCompositeOperation="destination-atop",m.fillStyle=k.makeHexColor(...r),m.fillRect(0,0,s,i),m.globalCompositeOperation="source-over"),u=v.canvas,p=g=0}else if(r.some(v=>v!==0)){t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const v=new Path2D;v.rect(p,g,s,i),t.clip(v),t.globalCompositeOperation="destination-atop",t.fillStyle=k.makeHexColor(...r),t.fillRect(p,g,s,i),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),n==="Alpha"&&a?e.filter=this.filterFactory.addAlphaFilter(a):n==="Luminosity"&&(e.filter=this.filterFactory.addLuminosityFilter(a));const f=new Path2D;f.rect(o,h,s,i),e.clip(f),e.globalCompositeOperation="destination-in",e.drawImage(u,p,g,s,i,o,h,s,i),e.restore()}save(){this.inSMaskMode?(le(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){this.stateStack.length===0&&this.inSMaskMode&&this.endSMaskMode(),this.stateStack.length!==0&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),le(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,s,i,n,r){this.ctx.transform(t,e,s,i,n,r),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,s){const i=this.ctx,n=this.current;let r,a,o=n.x,h=n.y;const c=K(i),d=c[0]===0&&c[3]===0||c[1]===0&&c[2]===0,u=d?s.slice(0):null;for(let p=0,g=0,f=t.length;p<f;p++)switch(0|t[p]){case wt.rectangle:o=e[g++],h=e[g++];const v=e[g++],m=e[g++],b=o+v,A=h+m;i.moveTo(o,h),v===0||m===0?i.lineTo(b,A):(i.lineTo(b,h),i.lineTo(b,A),i.lineTo(o,A)),d||n.updateRectMinMax(c,[o,h,b,A]),i.closePath();break;case wt.moveTo:o=e[g++],h=e[g++],i.moveTo(o,h),d||n.updatePathMinMax(c,o,h);break;case wt.lineTo:o=e[g++],h=e[g++],i.lineTo(o,h),d||n.updatePathMinMax(c,o,h);break;case wt.curveTo:r=o,a=h,o=e[g+4],h=e[g+5],i.bezierCurveTo(e[g],e[g+1],e[g+2],e[g+3],o,h),n.updateCurvePathMinMax(c,r,a,e[g],e[g+1],e[g+2],e[g+3],o,h,u),g+=6;break;case wt.curveTo2:r=o,a=h,i.bezierCurveTo(o,h,e[g],e[g+1],e[g+2],e[g+3]),n.updateCurvePathMinMax(c,r,a,o,h,e[g],e[g+1],e[g+2],e[g+3],u),o=e[g+2],h=e[g+3],g+=4;break;case wt.curveTo3:r=o,a=h,o=e[g+2],h=e[g+3],i.bezierCurveTo(e[g],e[g+1],o,h,o,h),n.updateCurvePathMinMax(c,r,a,e[g],e[g+1],o,h,o,h,u),g+=4;break;case wt.closePath:i.closePath()}d&&n.updateScalingPathMinMax(c,u),n.setCurrentPoint(o,h)}closePath(){this.ctx.closePath()}stroke(t=!0){const e=this.ctx,s=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof s=="object"&&s?.getPattern?(e.save(),e.strokeStyle=s.getPattern(e,this,Rt(e),Ts),this.rescaleAndStroke(!1),e.restore()):this.rescaleAndStroke(!0)),t&&this.consumePath(this.current.getClippedPathBoundingBox()),e.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(t=!0){const e=this.ctx,s=this.current.fillColor;let i=!1;this.current.patternFill&&(e.save(),e.fillStyle=s.getPattern(e,this,Rt(e),zt),i=!0);const n=this.current.getClippedPathBoundingBox();this.contentVisible&&n!==null&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),i&&e.restore(),t&&this.consumePath(n)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=Cr}eoClip(){this.pendingClip=Ws}beginText(){this.current.textMatrix=bi,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const t=this.pendingTextPaths,e=this.ctx;if(t!==void 0){e.save(),e.beginPath();for(const s of t)e.setTransform(...s.transform),e.translate(s.x,s.y),s.addToPath(e,s.fontSize);e.restore(),e.clip(),e.beginPath(),delete this.pendingTextPaths}else e.beginPath()}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){const s=this.commonObjs.get(t),i=this.current;if(!s)throw new Error(`Can't find font for ${t}`);if(i.fontMatrix=s.fontMatrix||ns,i.fontMatrix[0]!==0&&i.fontMatrix[3]!==0||O("Invalid font matrix for font "+t),e<0?(e=-e,i.fontDirection=-1):i.fontDirection=1,this.current.font=s,this.current.fontSize=e,s.isType3Font)return;const n=s.loadedName||"sans-serif",r=s.systemFontInfo?.css||`"${n}", ${s.fallbackName}`;let a="normal";s.black?a="900":s.bold&&(a="bold");const o=s.italic?"italic":"normal";let h=e;e<16?h=16:e>100&&(h=100),this.current.fontSizeScale=e/h,this.ctx.font=`${o} ${a} ${h}px ${r}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t,e,s,i,n,r){this.current.textMatrix=[t,e,s,i,n,r],this.current.textMatrixScale=Math.hypot(t,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(t,e,s,i){const n=this.ctx,r=this.current,a=r.font,o=r.textRenderingMode,h=r.fontSize/r.fontSizeScale,c=o&js,d=!!(o&xn),u=r.patternFill&&!a.missingFile;let p;(a.disableFontFace||d||u)&&(p=a.getPathGenerator(this.commonObjs,t)),a.disableFontFace||u?(n.save(),n.translate(e,s),n.beginPath(),p(n,h),i&&n.setTransform(...i),c!==Me&&c!==he||n.fill(),c!==Ye&&c!==he||n.stroke(),n.restore()):(c!==Me&&c!==he||n.fillText(t,e,s),c!==Ye&&c!==he||n.strokeText(t,e,s)),d&&(this.pendingTextPaths||=[]).push({transform:K(n),x:e,y:s,fontSize:h,addToPath:p})}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let s=!1;for(let i=3;i<e.length;i+=4)if(e[i]>0&&e[i]<255){s=!0;break}return z(this,"isFontSubpixelAAEnabled",s)}showText(t){const e=this.current,s=e.font;if(s.isType3Font)return this.showType3Text(t);const i=e.fontSize;if(i===0)return;const n=this.ctx,r=e.fontSizeScale,a=e.charSpacing,o=e.wordSpacing,h=e.fontDirection,c=e.textHScale*h,d=t.length,u=s.vertical,p=u?1:-1,g=s.defaultVMetrics,f=i*e.fontMatrix[0],v=e.textRenderingMode===Me&&!s.disableFontFace&&!e.patternFill;let m;if(n.save(),n.transform(...e.textMatrix),n.translate(e.x,e.y+e.textRise),h>0?n.scale(c,-1):n.scale(c,1),e.patternFill){n.save();const y=e.fillColor.getPattern(n,this,Rt(n),zt);m=K(n),n.restore(),n.fillStyle=y}let b=e.lineWidth;const A=e.textMatrixScale;if(A===0||b===0){const y=e.textRenderingMode&js;y!==Ye&&y!==he||(b=this.getSinglePixelWidth())}else b/=A;if(r!==1&&(n.scale(r,r),b/=r),n.lineWidth=b,s.isInvalidPDFjsFont){const y=[];let E=0;for(const S of t)y.push(S.unicode),E+=S.width;return n.fillText(y.join(""),0,0),e.x+=E*f*c,n.restore(),void this.compose()}let w,_=0;for(w=0;w<d;++w){const y=t[w];if(typeof y=="number"){_+=p*y*i/1e3;continue}let E=!1;const S=(y.isSpace?o:0)+a,C=y.fontChar,I=y.accent;let M,W,D=y.width;if(u){const B=y.vmetric||g,U=-(y.vmetric?B[1]:.5*D)*f,Y=B[2]*f;D=B?-B[0]:D,M=U/r,W=(_+Y)/r}else M=_/r,W=0;if(s.remeasure&&D>0){const B=1e3*n.measureText(C).width/i*r;if(D<B&&this.isFontSubpixelAAEnabled){const U=D/B;E=!0,n.save(),n.scale(U,1),M/=U}else D!==B&&(M+=(D-B)/2e3*i/r)}if(this.contentVisible&&(y.isInFont||s.missingFile)){if(v&&!I)n.fillText(C,M,W);else if(this.paintChar(C,M,W,m),I){const B=M+i*I.offset.x/r,U=W-i*I.offset.y/r;this.paintChar(I.fontChar,B,U,m)}}_+=u?D*f-S*h:D*f+S*h,E&&n.restore()}u?e.y-=_:e.x+=_*c,n.restore(),this.compose()}showType3Text(t){const e=this.ctx,s=this.current,i=s.font,n=s.fontSize,r=s.fontDirection,a=i.vertical?1:-1,o=s.charSpacing,h=s.wordSpacing,c=s.textHScale*r,d=s.fontMatrix||ns,u=t.length;let p,g,f,v;if(s.textRenderingMode!==_n&&n!==0){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),e.transform(...s.textMatrix),e.translate(s.x,s.y),e.scale(c,r),p=0;p<u;++p){if(g=t[p],typeof g=="number"){v=a*g*n/1e3,this.ctx.translate(v,0),s.x+=v*c;continue}const m=(g.isSpace?h:0)+o,b=i.charProcOperatorList[g.operatorListId];if(!b){O(`Type3 character "${g.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=g,this.save(),e.scale(n,n),e.transform(...d),this.executeOperatorList(b),this.restore()),f=k.applyTransform([g.width,0],d)[0]*n+m,e.translate(f,0),s.x+=f*c}e.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,s,i,n,r){this.ctx.rect(s,i,n-s,r-i),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if(t[0]==="TilingPattern"){const s=t[1],i=this.baseTransform||K(this.ctx),n={createCanvasGraphics:r=>new ee(r,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new Ps(t,s,this.ctx,n,i)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,s){const i=k.makeHexColor(t,e,s);this.ctx.strokeStyle=i,this.current.strokeColor=i}setFillRGBColor(t,e,s){const i=k.makeHexColor(t,e,s);this.ctx.fillStyle=i,this.current.fillColor=i,this.current.patternFill=!1}_getPattern(t,e=null){let s;return this.cachedPatterns.has(t)?s=this.cachedPatterns.get(t):(s=function(i){switch(i[0]){case"RadialAxial":return new mr(i);case"Mesh":return new br(i);case"Dummy":return new Ar}throw new Error(`Unknown IR type: ${i[0]}`)}(this.getObject(t)),this.cachedPatterns.set(t,s)),e&&(s.matrix=e),s}shadingFill(t){if(!this.contentVisible)return;const e=this.ctx;this.save();const s=this._getPattern(t);e.fillStyle=s.getPattern(e,this,Rt(e),pe);const i=Rt(e);if(i){const{width:n,height:r}=e.canvas,[a,o,h,c]=k.getAxialAlignedBoundingBox([0,0,n,r],i);this.ctx.fillRect(a,o,h-a,c-o)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){q("Should not call beginInlineImage")}beginImageData(){q("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=K(this.ctx),e)){const s=e[2]-e[0],i=e[3]-e[1];this.ctx.rect(e[0],e[1],s,i),this.current.updateRectMinMax(K(this.ctx),e),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const e=this.ctx;t.isolated||Be("TODO: Support non-isolated groups."),t.knockout&&O("Knockout groups not supported.");const s=K(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let i=k.getAxialAlignedBoundingBox(t.bbox,K(e));const n=[0,0,e.canvas.width,e.canvas.height];i=k.intersect(i,n)||[0,0,0,0];const r=Math.floor(i[0]),a=Math.floor(i[1]),o=Math.max(Math.ceil(i[2])-r,1),h=Math.max(Math.ceil(i[3])-a,1);this.current.startNewPathAndClipBox([0,0,o,h]);let c="groupAt"+this.groupLevel;t.smask&&(c+="_smask_"+this.smaskCounter++%2);const d=this.cachedCanvases.getCanvas(c,o,h),u=d.context;u.translate(-r,-a),u.transform(...s),t.smask?this.smaskStack.push({canvas:d.canvas,context:u,offsetX:r,offsetY:a,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(r,a),e.save()),le(e,u),this.ctx=u,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;const e=this.ctx,s=this.groupStack.pop();if(this.ctx=s,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const i=K(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...i);const n=k.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],i);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(n)}}beginAnnotation(t,e,s,i,n){if(this.#t(),Ee(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const r=e[2]-e[0],a=e[3]-e[1];if(n&&this.annotationCanvasMap){(s=s.slice())[4]-=e[0],s[5]-=e[1],(e=e.slice())[0]=e[1]=0,e[2]=r,e[3]=a;const[o,h]=k.singularValueDecompose2dScale(K(this.ctx)),{viewportScale:c}=this,d=Math.ceil(r*this.outputScaleX*c),u=Math.ceil(a*this.outputScaleY*c);this.annotationCanvas=this.canvasFactory.create(d,u);const{canvas:p,context:g}=this.annotationCanvas;this.annotationCanvasMap.set(t,p),this.annotationCanvas.savedCtx=this.ctx,this.ctx=g,this.ctx.save(),this.ctx.setTransform(o,0,0,-h,0,a*h),Ee(this.ctx)}else Ee(this.ctx),this.ctx.rect(e[0],e[1],r,a),this.ctx.clip(),this.endPath()}this.current=new Vs(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...s),this.transform(...i)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#e(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;const e=t.count;(t=this.getObject(t.data,t)).count=e;const s=this.ctx,i=this.processingType3;if(i&&(i.compiled===void 0&&(i.compiled=function(a){const{width:o,height:h}=a;if(o>1e3||h>1e3)return null;const c=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),d=o+1;let u,p,g,f=new Uint8Array(d*(h+1));const v=o+7&-8;let m=new Uint8Array(v*h),b=0;for(const y of a.data){let E=128;for(;E>0;)m[b++]=y&E?0:255,E>>=1}let A=0;for(b=0,m[b]!==0&&(f[0]=1,++A),p=1;p<o;p++)m[b]!==m[b+1]&&(f[p]=m[b]?2:1,++A),b++;for(m[b]!==0&&(f[p]=2,++A),u=1;u<h;u++){b=u*v,g=u*d,m[b-v]!==m[b]&&(f[g]=m[b]?1:8,++A);let y=(m[b]?4:0)+(m[b-v]?8:0);for(p=1;p<o;p++)y=(y>>2)+(m[b+1]?4:0)+(m[b-v+1]?8:0),c[y]&&(f[g+p]=c[y],++A),b++;if(m[b-v]!==m[b]&&(f[g+p]=m[b]?2:4,++A),A>1e3)return null}for(b=v*(h-1),g=u*d,m[b]!==0&&(f[g]=8,++A),p=1;p<o;p++)m[b]!==m[b+1]&&(f[g+p]=m[b]?4:8,++A),b++;if(m[b]!==0&&(f[g+p]=4,++A),A>1e3)return null;const w=new Int32Array([0,d,-1,0,-d,0,0,0,1]),_=new Path2D;for(u=0;A&&u<=h;u++){let y=u*d;const E=y+o;for(;y<E&&!f[y];)y++;if(y===E)continue;_.moveTo(y%d,u);const S=y;let C=f[y];do{const I=w[C];do y+=I;while(!f[y]);const M=f[y];M!==5&&M!==10?(C=M,f[y]=0):(C=M&51*C>>4,f[y]&=C>>2|C<<2),_.lineTo(y%d,y/d|0),f[y]||--A}while(S!==y);--u}return m=null,f=null,function(y){y.save(),y.scale(1/o,-1/h),y.translate(0,-h),y.fill(_),y.beginPath(),y.restore()}}(t)),i.compiled))return void i.compiled(s);const n=this._createMaskCanvas(t),r=n.canvas;s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(r,n.offsetX,n.offsetY),s.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,s=0,i=0,n,r){if(!this.contentVisible)return;t=this.getObject(t.data,t);const a=this.ctx;a.save();const o=K(a);a.transform(e,s,i,n,0,0);const h=this._createMaskCanvas(t);a.setTransform(1,0,0,1,h.offsetX-o[4],h.offsetY-o[5]);for(let c=0,d=r.length;c<d;c+=2){const u=k.transform(o,[e,s,i,n,r[c],r[c+1]]),[p,g]=k.applyTransform([0,0],u);a.drawImage(h.canvas,p,g)}a.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const e=this.ctx,s=this.current.fillColor,i=this.current.patternFill;for(const n of t){const{data:r,width:a,height:o,transform:h}=n,c=this.cachedCanvases.getCanvas("maskCanvas",a,o),d=c.context;d.save(),Us(d,this.getObject(r,n)),d.globalCompositeOperation="source-in",d.fillStyle=i?s.getPattern(d,this,Rt(e),zt):s,d.fillRect(0,0,a,o),d.restore(),e.save(),e.transform(...h),e.scale(1,-1),xe(e,c.canvas,0,0,a,o,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=this.getObject(t);e?this.paintInlineImageXObject(e):O("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,s,i){if(!this.contentVisible)return;const n=this.getObject(t);if(!n)return void O("Dependent image isn't ready yet");const r=n.width,a=n.height,o=[];for(let h=0,c=i.length;h<c;h+=2)o.push({transform:[e,0,0,s,i[h],i[h+1]],x:0,y:0,w:r,h:a});this.paintInlineImageXObjectGroup(n,o)}applyTransferMapsToCanvas(t){return this.current.transferMaps!=="none"&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if(this.current.transferMaps==="none")return t.bitmap;const{bitmap:e,width:s,height:i}=t,n=this.cachedCanvases.getCanvas("inlineImage",s,i),r=n.context;return r.filter=this.current.transferMaps,r.drawImage(e,0,0),r.filter="none",n.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,s=t.height,i=this.ctx;if(this.save(),!dt){const{filter:a}=i;a!=="none"&&a!==""&&(i.filter="none")}let n;if(i.scale(1/e,-1/s),t.bitmap)n=this.applyTransferMapsToBitmap(t);else if(typeof HTMLElement=="function"&&t instanceof HTMLElement||!t.data)n=t;else{const a=this.cachedCanvases.getCanvas("inlineImage",e,s).context;Gs(a,t),n=this.applyTransferMapsToCanvas(a)}const r=this._scaleImage(n,Rt(i));i.imageSmoothingEnabled=qs(K(i),t.interpolate),xe(i,r.img,0,0,r.paintWidth,r.paintHeight,0,-s,e,s),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;const s=this.ctx;let i;if(t.bitmap)i=t.bitmap;else{const n=t.width,r=t.height,a=this.cachedCanvases.getCanvas("inlineImage",n,r).context;Gs(a,t),i=this.applyTransferMapsToCanvas(a)}for(const n of e)s.save(),s.transform(...n.transform),s.scale(1,-1),xe(s,i,n.x,n.y,n.w,n.h,0,-1,1,1),s.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,e){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e){t==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(e)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t){const e=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);const s=this.ctx;this.pendingClip&&(e||(this.pendingClip===Ws?s.clip("evenodd"):s.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),s.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=K(this.ctx);if(t[1]===0&&t[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),s=Math.hypot(t[0],t[2]),i=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(s,i)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:t}=this.current,{a:e,b:s,c:i,d:n}=this.ctx.getTransform();let r,a;if(s===0&&i===0){const o=Math.abs(e),h=Math.abs(n);if(o===h)if(t===0)r=a=1/o;else{const c=o*t;r=a=c<1?1/c:1}else if(t===0)r=1/o,a=1/h;else{const c=o*t,d=h*t;r=c<1?1/c:1,a=d<1?1/d:1}}else{const o=Math.abs(e*n-s*i),h=Math.hypot(e,s),c=Math.hypot(i,n);if(t===0)r=c/o,a=h/o;else{const d=t*o;r=c>d?c/d:1,a=h>d?h/d:1}}this._cachedScaleForStroking[0]=r,this._cachedScaleForStroking[1]=a}return this._cachedScaleForStroking}rescaleAndStroke(t){const{ctx:e}=this,{lineWidth:s}=this.current,[i,n]=this.getScaleForStroking();if(e.lineWidth=s||1,i===1&&n===1)return void e.stroke();const r=e.getLineDash();if(t&&e.save(),e.scale(i,n),r.length>0){const a=Math.max(i,n);e.setLineDash(r.map(o=>o/a)),e.lineDashOffset/=a}e.stroke(),t&&e.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(const l in wt)ee.prototype[l]!==void 0&&(ee.prototype[wt[l]]=ee.prototype[l]);class ge{static#t=null;static#e="";static get workerPort(){return this.#t}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");this.#t=t}static get workerSrc(){return this.#e}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");this.#e=t}}const Xs=1,Ks=2,Ys=1,ts=2,Qs=3,Js=4,Zs=5,ti=6,Se=7,es=8;function ft(l){switch(l instanceof Error||typeof l=="object"&&l!==null||q('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),l.name){case"AbortException":return new Xt(l.message);case"MissingPDFException":return new Wt(l.message);case"PasswordException":return new as(l.message,l.code);case"UnexpectedResponseException":return new He(l.message,l.status);case"UnknownErrorException":return new os(l.message,l.details);default:return new os(l.message,l.toString())}}class ue{constructor(t,e,s){this.sourceName=t,this.targetName=e,this.comObj=s,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),this._onComObjOnMessage=i=>{const n=i.data;if(n.targetName!==this.sourceName)return;if(n.stream)return void this.#e(n);if(n.callback){const a=n.callbackId,o=this.callbackCapabilities[a];if(!o)throw new Error(`Cannot resolve callback ${a}`);if(delete this.callbackCapabilities[a],n.callback===Xs)o.resolve(n.data);else{if(n.callback!==Ks)throw new Error("Unexpected callback case");o.reject(ft(n.reason))}return}const r=this.actionHandler[n.action];if(!r)throw new Error(`Unknown action from worker: ${n.action}`);if(n.callbackId){const a=this.sourceName,o=n.sourceName;new Promise(function(h){h(r(n.data))}).then(function(h){s.postMessage({sourceName:a,targetName:o,callback:Xs,callbackId:n.callbackId,data:h})},function(h){s.postMessage({sourceName:a,targetName:o,callback:Ks,callbackId:n.callbackId,reason:ft(h)})})}else n.streamId?this.#t(n):r(n.data)},s.addEventListener("message",this._onComObjOnMessage)}on(t,e){const s=this.actionHandler;if(s[t])throw new Error(`There is already an actionName called "${t}"`);s[t]=e}send(t,e,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},s)}sendWithPromise(t,e,s){const i=this.callbackId++,n=Promise.withResolvers();this.callbackCapabilities[i]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:i,data:e},s)}catch(r){n.reject(r)}return n.promise}sendWithStream(t,e,s,i){const n=this.streamId++,r=this.sourceName,a=this.targetName,o=this.comObj;return new ReadableStream({start:h=>{const c=Promise.withResolvers();return this.streamControllers[n]={controller:h,startCall:c,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:r,targetName:a,action:t,streamId:n,data:e,desiredSize:h.desiredSize},i),c.promise},pull:h=>{const c=Promise.withResolvers();return this.streamControllers[n].pullCall=c,o.postMessage({sourceName:r,targetName:a,stream:ti,streamId:n,desiredSize:h.desiredSize}),c.promise},cancel:h=>{nt(h instanceof Error,"cancel must have a valid reason");const c=Promise.withResolvers();return this.streamControllers[n].cancelCall=c,this.streamControllers[n].isClosed=!0,o.postMessage({sourceName:r,targetName:a,stream:Ys,streamId:n,reason:ft(h)}),c.promise}},s)}#t(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,r=this,a=this.actionHandler[t.action],o={enqueue(h,c=1,d){if(this.isCancelled)return;const u=this.desiredSize;this.desiredSize-=c,u>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:s,targetName:i,stream:Js,streamId:e,chunk:h},d)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:Qs,streamId:e}),delete r.streamSinks[e])},error(h){nt(h instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:Zs,streamId:e,reason:ft(h)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,new Promise(function(h){h(a(t.data,o))}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:es,streamId:e,success:!0})},function(h){n.postMessage({sourceName:s,targetName:i,stream:es,streamId:e,reason:ft(h)})})}#e(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,r=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case es:t.success?r.startCall.resolve():r.startCall.reject(ft(t.reason));break;case Se:t.success?r.pullCall.resolve():r.pullCall.reject(ft(t.reason));break;case ti:if(!a){n.postMessage({sourceName:s,targetName:i,stream:Se,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,new Promise(function(o){o(a.onPull?.())}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:Se,streamId:e,success:!0})},function(o){n.postMessage({sourceName:s,targetName:i,stream:Se,streamId:e,reason:ft(o)})});break;case Js:if(nt(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case Qs:if(nt(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#s(r,e);break;case Zs:nt(r,"error should have stream controller"),r.controller.error(ft(t.reason)),this.#s(r,e);break;case ts:t.success?r.cancelCall.resolve():r.cancelCall.reject(ft(t.reason)),this.#s(r,e);break;case Ys:if(!a)break;new Promise(function(o){o(a.onCancel?.(ft(t.reason)))}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:ts,streamId:e,success:!0})},function(o){n.postMessage({sourceName:s,targetName:i,stream:ts,streamId:e,reason:ft(o)})}),a.sinkCapability.reject(ft(t.reason)),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#s(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}class kr{#t;#e;constructor({parsedData:t,rawData:e}){this.#t=t,this.#e=e}getRaw(){return this.#e}get(t){return this.#t.get(t)??null}getAll(){return ys(this.#t)}has(t){return this.#t.has(t)}}const Ot=Symbol("INTERNAL");class Mr{#t=!1;#e=!1;#s=!1;#n=!0;constructor(t,{name:e,intent:s,usage:i}){this.#t=!!(t&As),this.#e=!!(t&Te),this.name=e,this.intent=s,this.usage=i}get visible(){if(this.#s)return this.#n;if(!this.#n)return!1;const{print:t,view:e}=this.usage;return this.#t?e?.viewState!=="OFF":!this.#e||t?.printState!=="OFF"}_setVisible(t,e,s=!1){t!==Ot&&q("Internal method `_setVisible` called."),this.#s=s,this.#n=e}}class Rr{#t=null;#e=new Map;#s=null;#n=null;constructor(t,e=As){if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,this.#n=t.order;for(const s of t.groups)this.#e.set(s.id,new Mr(e,s));if(t.baseState==="OFF")for(const s of this.#e.values())s._setVisible(Ot,!1);for(const s of t.on)this.#e.get(s)._setVisible(Ot,!0);for(const s of t.off)this.#e.get(s)._setVisible(Ot,!1);this.#s=this.getHash()}}#o(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let i=1;i<e;i++){const n=t[i];let r;if(Array.isArray(n))r=this.#o(n);else{if(!this.#e.has(n))return O(`Optional content group not found: ${n}`),!0;r=this.#e.get(n).visible}switch(s){case"And":if(!r)return!1;break;case"Or":if(r)return!0;break;case"Not":return!r;default:return!0}}return s==="And"}isVisible(t){if(this.#e.size===0)return!0;if(!t)return Be("Optional content group not defined."),!0;if(t.type==="OCG")return this.#e.has(t.id)?this.#e.get(t.id).visible:(O(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return this.#o(t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!this.#e.has(e))return O(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!0}return!1}if(t.policy==="AllOn"){for(const e of t.ids){if(!this.#e.has(e))return O(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!1}return!0}if(t.policy==="AnyOff"){for(const e of t.ids){if(!this.#e.has(e))return O(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!0}return!1}if(t.policy==="AllOff"){for(const e of t.ids){if(!this.#e.has(e))return O(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!1}return!0}return O(`Unknown optional content policy ${t.policy}.`),!0}return O(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0){const s=this.#e.get(t);s?(s._setVisible(Ot,!!e,!0),this.#t=null):O(`Optional content group not found: ${t}`)}setOCGState({state:t,preserveRB:e}){let s;for(const i of t){switch(i){case"ON":case"OFF":case"Toggle":s=i;continue}const n=this.#e.get(i);if(n)switch(s){case"ON":n._setVisible(Ot,!0);break;case"OFF":n._setVisible(Ot,!1);break;case"Toggle":n._setVisible(Ot,!n.visible)}}this.#t=null}get hasInitialVisibility(){return this.#s===null||this.getHash()===this.#s}getOrder(){return this.#e.size?this.#n?this.#n.slice():[...this.#e.keys()]:null}getGroups(){return this.#e.size>0?ys(this.#e):null}getGroup(t){return this.#e.get(t)||null}getHash(){if(this.#t!==null)return this.#t;const t=new ki;for(const[e,s]of this.#e)t.update(`${e}:${s.visible}`);return this.#t=t.hexdigest()}}class Tr{constructor(t,{disableRange:e=!1,disableStream:s=!1}){nt(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:i,initialData:n,progressiveDone:r,contentDispositionFilename:a}=t;if(this._queuedChunks=[],this._progressiveDone=r,this._contentDispositionFilename=a,n?.length>0){const o=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;this._queuedChunks.push(o)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!s,this._isRangeSupported=!e,this._contentLength=i,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((o,h)=>{this._onReceiveData({begin:o,chunk:h})}),t.addProgressListener((o,h)=>{this._onProgress({loaded:o,total:h})}),t.addProgressiveReadListener(o=>{this._onReceiveData({chunk:o})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const s=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;t===void 0?this._fullRequestReader?this._fullRequestReader._enqueue(s):this._queuedChunks.push(s):nt(this._rangeReaders.some(function(i){return i._begin===t&&(i._enqueue(s),!0)}),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){t.total===void 0?this._rangeReaders[0]?.onProgress?.({loaded:t.loaded}):this._fullRequestReader?.onProgress?.({loaded:t.loaded,total:t.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){nt(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new Pr(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new Lr(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeReaders.slice(0))e.cancel(t);this._pdfDataRangeTransport.abort()}}class Pr{constructor(t,e,s=!1,i=null){this._stream=t,this._done=s||!1,this._filename=Ss(i)?i:null,this._queuedChunks=e||[],this._loaded=0;for(const n of this._queuedChunks)this._loaded+=n.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class Lr{constructor(t,e,s){this._stream=t,this._begin=e,this._end=s,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length===0)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function Ls({getResponseHeader:l,isHttp:t,rangeChunkSize:e,disableRange:s}){const i={allowRangeRequests:!1,suggestedLength:void 0},n=parseInt(l("Content-Length"),10);return!Number.isInteger(n)||(i.suggestedLength=n,n<=2*e)||s||!t||l("Accept-Ranges")!=="bytes"||(l("Content-Encoding")||"identity")!=="identity"||(i.allowRangeRequests=!0),i}function Is(l){const t=l("Content-Disposition");if(t){let e=function(s){let i=!0,n=r("filename\\*","i").exec(s);if(n){n=n[1];let u=h(n);return u=unescape(u),u=c(u),u=d(u),o(u)}if(n=function(u){const p=[];let g;const f=r("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(g=f.exec(u))!==null;){let[,m,b,A]=g;if(m=parseInt(m,10),m in p){if(m===0)break}else p[m]=[b,A]}const v=[];for(let m=0;m<p.length&&m in p;++m){let[b,A]=p[m];A=h(A),b&&(A=unescape(A),m===0&&(A=c(A))),v.push(A)}return v.join("")}(s),n)return o(d(n));if(n=r("filename","i").exec(s),n){n=n[1];let u=h(n);return u=d(u),o(u)}function r(u,p){return new RegExp("(?:^|;)\\s*"+u+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',p)}function a(u,p){if(u){if(!/^[\x00-\xFF]+$/.test(p))return p;try{const g=new TextDecoder(u,{fatal:!0}),f=$e(p);p=g.decode(f),i=!1}catch{}}return p}function o(u){return i&&/[\x80-\xff]/.test(u)&&(u=a("utf-8",u),i&&(u=a("iso-8859-1",u))),u}function h(u){if(u.startsWith('"')){const p=u.slice(1).split('\\"');for(let g=0;g<p.length;++g){const f=p[g].indexOf('"');f!==-1&&(p[g]=p[g].slice(0,f),p.length=g+1),p[g]=p[g].replaceAll(/\\(.)/g,"$1")}u=p.join('"')}return u}function c(u){const p=u.indexOf("'");return p===-1?u:a(u.slice(0,p),u.slice(p+1).replace(/^[^']*'/,""))}function d(u){return!u.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(u)?u:u.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(p,g,f,v){if(f==="q"||f==="Q")return a(g,v=(v=v.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,function(m,b){return String.fromCharCode(parseInt(b,16))}));try{v=atob(v)}catch{}return a(g,v)})}return""}(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(Ss(e))return e}return null}function Ue(l,t){return l===404||l===0&&t.startsWith("file:")?new Wt('Missing PDF "'+t+'".'):new He(`Unexpected server response (${l}) while retrieving PDF "${t}".`,l)}function Ti(l){return l===200||l===206}function Pi(l,t,e){return{method:"GET",headers:l,signal:e.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function Li(l){const t=new Headers;for(const e in l){const s=l[e];s!==void 0&&t.append(e,s)}return t}function Ii(l){return l instanceof Uint8Array?l.buffer:l instanceof ArrayBuffer?l:(O(`getArrayBuffer - unexpected data format: ${l}`),new Uint8Array(l).buffer)}class ei{constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.httpHeaders=this.isHttp&&t.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return nt(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new Ir(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new Dr(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Ir{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._headers=Li(this._stream.httpHeaders);const s=e.url;fetch(s,Pi(this._headers,this._withCredentials,this._abortController)).then(i=>{if(!Ti(i.status))throw Ue(i.status,s);this._reader=i.body.getReader(),this._headersCapability.resolve();const n=o=>i.headers.get(o),{allowRangeRequests:r,suggestedLength:a}=Ls({getResponseHeader:n,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=r,this._contentLength=a||this._contentLength,this._filename=Is(n),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Xt("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:Ii(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Dr{constructor(t,e,s){this._stream=t,this._reader=null,this._loaded=0;const i=t.source;this._withCredentials=i.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!i.disableStream,this._abortController=new AbortController,this._headers=Li(this._stream.httpHeaders),this._headers.append("Range",`bytes=${e}-${s-1}`);const n=i.url;fetch(n,Pi(this._headers,this._withCredentials,this._abortController)).then(r=>{if(!Ti(r.status))throw Ue(r.status,n);this._readCapability.resolve(),this._reader=r.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded}),{value:Ii(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Fr{constructor(t,e={}){this.url=t,this.isHttp=/^https?:/i.test(t),this.httpHeaders=this.isHttp&&e.httpHeaders||Object.create(null),this.withCredentials=e.withCredentials||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(t,e,s){const i={begin:t,end:e};for(const n in s)i[n]=s[n];return this.request(i)}requestFull(t){return this.request(t)}request(t){const e=new XMLHttpRequest,s=this.currXhrId++,i=this.pendingRequests[s]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const n in this.httpHeaders){const r=this.httpHeaders[n];r!==void 0&&e.setRequestHeader(n,r)}return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),i.expectedStatus=206):i.expectedStatus=200,e.responseType="arraybuffer",t.onError&&(e.onerror=function(n){t.onError(e.status)}),e.onreadystatechange=this.onStateChange.bind(this,s),e.onprogress=this.onProgress.bind(this,s),i.onHeadersReceived=t.onHeadersReceived,i.onDone=t.onDone,i.onError=t.onError,i.onProgress=t.onProgress,e.send(null),s}onProgress(t,e){const s=this.pendingRequests[t];s&&s.onProgress?.(e)}onStateChange(t,e){const s=this.pendingRequests[t];if(!s)return;const i=s.xhr;if(i.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),i.readyState!==4||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],i.status===0&&this.isHttp)return void s.onError?.(i.status);const n=i.status||200;if(!(n===200&&s.expectedStatus===206)&&n!==s.expectedStatus)return void s.onError?.(i.status);const r=function(a){const o=a.response;return typeof o!="string"?o:$e(o).buffer}(i);if(n===206){const a=i.getResponseHeader("Content-Range"),o=/bytes (\d+)-(\d+)\/(\d+)/.exec(a);s.onDone({begin:parseInt(o[1],10),chunk:r})}else r?s.onDone({begin:0,chunk:r}):s.onError?.(i.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class Or{constructor(t){this._source=t,this._manager=new Fr(t.url,{httpHeaders:t.httpHeaders,withCredentials:t.withCredentials}),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){const e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return nt(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new Nr(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const s=new jr(this._manager,t,e);return s.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Nr{constructor(t,e){this._manager=t;const s={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=e.url,this._fullRequestId=t.requestFull(s),this._headersReceivedCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const t=this._fullRequestId,e=this._manager.getRequestXhr(t),s=r=>e.getResponseHeader(r),{allowRangeRequests:i,suggestedLength:n}=Ls({getResponseHeader:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=n||this._contentLength,this._filename=Is(s),this._isRangeSupported&&this._manager.abortRequest(t),this._headersReceivedCapability.resolve()}_onDone(t){if(t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=Ue(t,this._url),this._headersReceivedCapability.reject(this._storedError);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersReceivedCapability.promise}async read(){if(this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersReceivedCapability.reject(t);for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class jr{constructor(t,e,s){this._manager=t;const i={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=t.url,this._requestId=t.requestRange(e,s,i),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_close(){this.onClosed?.(this)}_onDone(t){const e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0;for(const s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError=Ue(t,this._url);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){this.isStreamingSupported||this.onProgress?.({loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const Di=/^file:\/\/\/[a-zA-Z]:\//;class Br{constructor(t){this.source=t,this.url=function(e){const s=kt.get("url"),i=s.parse(e);return i.protocol==="file:"||i.host?i:/^[a-z]:[/\\]/i.test(e)?s.parse(`file:///${e}`):(i.host||(i.protocol="file:"),i)}(t.url),this.isHttp=this.url.protocol==="http:"||this.url.protocol==="https:",this.isFsUrl=this.url.protocol==="file:",this.httpHeaders=this.isHttp&&t.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return nt(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new zr(this):new Hr(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=this.isFsUrl?new Vr(this,t,e):new $r(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Fi{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers()}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new Xt("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class Oi{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const e=t.source;this._isStreamingSupported=!e.disableStream}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),this._storedError&&this._readableStream.destroy(this._storedError)}}function De(l,t){return{protocol:l.protocol,auth:l.auth,host:l.hostname,port:l.port,path:l.path,method:"GET",headers:t}}class Hr extends Fi{constructor(t){super(t);const e=s=>{if(s.statusCode===404){const a=new Wt(`Missing PDF "${this._url}".`);return this._storedError=a,void this._headersCapability.reject(a)}this._headersCapability.resolve(),this._setReadableStream(s);const i=a=>this._readableStream.headers[a.toLowerCase()],{allowRangeRequests:n,suggestedLength:r}=Ls({getResponseHeader:i,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=n,this._contentLength=r||this._contentLength,this._filename=Is(i)};if(this._request=null,this._url.protocol==="http:"){const s=kt.get("http");this._request=s.request(De(this._url,t.httpHeaders),e)}else{const s=kt.get("https");this._request=s.request(De(this._url,t.httpHeaders),e)}this._request.on("error",s=>{this._storedError=s,this._headersCapability.reject(s)}),this._request.end()}}class $r extends Oi{constructor(t,e,s){super(t),this._httpHeaders={};for(const n in t.httpHeaders){const r=t.httpHeaders[n];r!==void 0&&(this._httpHeaders[n]=r)}this._httpHeaders.Range=`bytes=${e}-${s-1}`;const i=n=>{if(n.statusCode!==404)this._setReadableStream(n);else{const r=new Wt(`Missing PDF "${this._url}".`);this._storedError=r}};if(this._request=null,this._url.protocol==="http:"){const n=kt.get("http");this._request=n.request(De(this._url,this._httpHeaders),i)}else{const n=kt.get("https");this._request=n.request(De(this._url,this._httpHeaders),i)}this._request.on("error",n=>{this._storedError=n}),this._request.end()}}class zr extends Fi{constructor(t){super(t);let e=decodeURIComponent(this._url.path);Di.test(this._url.href)&&(e=e.replace(/^\//,""));const s=kt.get("fs");s.promises.lstat(e).then(i=>{this._contentLength=i.size,this._setReadableStream(s.createReadStream(e)),this._headersCapability.resolve()},i=>{i.code==="ENOENT"&&(i=new Wt(`Missing PDF "${e}".`)),this._storedError=i,this._headersCapability.reject(i)})}}class Vr extends Oi{constructor(t,e,s){super(t);let i=decodeURIComponent(this._url.path);Di.test(this._url.href)&&(i=i.replace(/^\//,""));const n=kt.get("fs");this._setReadableStream(n.createReadStream(i,{start:e,end:s-1}))}}const mt=30;let Fe=class Et{#t=Promise.withResolvers();#e=null;#s=!1;#n=!!globalThis.FontInspector?.enabled;#o=null;#i=null;#r=0;#h=0;#c=null;#d=null;#p=0;#l=0;#a=Object.create(null);#g=[];#m=null;#u=[];#b=new WeakMap;#f=null;static#A=new Map;static#w=new Map;static#x=null;static#S=new Set;constructor({textContentSource:t,container:e,viewport:s}){if(t instanceof ReadableStream)this.#m=t;else{if(typeof t!="object")throw new Error('No "textContentSource" parameter specified.');this.#m=new ReadableStream({start(o){o.enqueue(t),o.close()}})}this.#e=this.#d=e,this.#l=s.scale*(globalThis.devicePixelRatio||1),this.#p=s.rotation,this.#i={prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:null};const{pageWidth:i,pageHeight:n,pageX:r,pageY:a}=s.rawDims;this.#f=[1,0,0,-1,-r,a+n],this.#h=i,this.#r=n,Et.#v(),Gt(e,s),this.#t.promise.catch(()=>{}).then(()=>{Et.#S.delete(this),this.#i=null,this.#a=null})}render(){const t=()=>{this.#c.read().then(({value:e,done:s})=>{s?this.#t.resolve():(this.#o??=e.lang,Object.assign(this.#a,e.styles),this.#C(e.items),t())},this.#t.reject)};return this.#c=this.#m.getReader(),Et.#S.add(this),t(),this.#t.promise}update({viewport:t,onBefore:e=null}){const s=t.scale*(globalThis.devicePixelRatio||1),i=t.rotation;if(i!==this.#p&&(e?.(),this.#p=i,Gt(this.#d,{rotation:i})),s!==this.#l){e?.(),this.#l=s;const n={prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:Et.#y(this.#o)};for(const r of this.#u)n.properties=this.#b.get(r),n.div=r,this.#E(n)}}cancel(){const t=new Xt("TextLayer task cancelled.");this.#c?.cancel(t).catch(()=>{}),this.#c=null,this.#t.reject(t)}get textDivs(){return this.#u}get textContentItemsStr(){return this.#g}#C(t){if(this.#s)return;this.#i.ctx??=Et.#y(this.#o);const e=this.#u,s=this.#g;for(const i of t){if(e.length>1e5)return O("Ignoring additional textDivs for performance reasons."),void(this.#s=!0);if(i.str!==void 0)s.push(i.str),this.#T(i);else if(i.type==="beginMarkedContentProps"||i.type==="beginMarkedContent"){const n=this.#e;this.#e=document.createElement("span"),this.#e.classList.add("markedContent"),i.id!==null&&this.#e.setAttribute("id",`${i.id}`),n.append(this.#e)}else i.type==="endMarkedContent"&&(this.#e=this.#e.parentNode)}}#T(t){const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};this.#u.push(e);const i=k.transform(this.#f,t.transform);let n=Math.atan2(i[1],i[0]);const r=this.#a[t.fontName];r.vertical&&(n+=Math.PI/2);const a=this.#n&&r.fontSubstitution||r.fontFamily,o=Math.hypot(i[2],i[3]),h=o*Et.#_(a,this.#o);let c,d;n===0?(c=i[4],d=i[5]-h):(c=i[4]+h*Math.sin(n),d=i[5]-h*Math.cos(n));const u="calc(var(--scale-factor)*",p=e.style;this.#e===this.#d?(p.left=`${(100*c/this.#h).toFixed(2)}%`,p.top=`${(100*d/this.#r).toFixed(2)}%`):(p.left=`${u}${c.toFixed(2)}px)`,p.top=`${u}${d.toFixed(2)}px)`),p.fontSize=`${u}${(Et.#x*o).toFixed(2)}px)`,p.fontFamily=a,s.fontSize=o,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,this.#n&&(e.dataset.fontName=r.fontSubstitutionLoadedName||t.fontName),n!==0&&(s.angle=n*(180/Math.PI));let g=!1;if(t.str.length>1)g=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const f=Math.abs(t.transform[0]),v=Math.abs(t.transform[3]);f!==v&&Math.max(f,v)/Math.min(f,v)>1.5&&(g=!0)}if(g&&(s.canvasWidth=r.vertical?t.height:t.width),this.#b.set(e,s),this.#i.div=e,this.#i.properties=s,this.#E(this.#i),s.hasText&&this.#e.append(e),s.hasEOL){const f=document.createElement("br");f.setAttribute("role","presentation"),this.#e.append(f)}}#E(t){const{div:e,properties:s,ctx:i,prevFontSize:n,prevFontFamily:r}=t,{style:a}=e;let o="";if(Et.#x>1&&(o=`scale(${1/Et.#x})`),s.canvasWidth!==0&&s.hasText){const{fontFamily:h}=a,{canvasWidth:c,fontSize:d}=s;n===d&&r===h||(i.font=`${d*this.#l}px ${h}`,t.prevFontSize=d,t.prevFontFamily=h);const{width:u}=i.measureText(e.textContent);u>0&&(o=`scaleX(${c*this.#l/u}) ${o}`)}s.angle!==0&&(o=`rotate(${s.angle}deg) ${o}`),o.length>0&&(a.transform=o)}static cleanup(){if(!(this.#S.size>0)){this.#A.clear();for(const{canvas:t}of this.#w.values())t.remove();this.#w.clear()}}static#y(t=null){let e=this.#w.get(t||="");if(!e){const s=document.createElement("canvas");s.className="hiddenCanvasElement",s.lang=t,document.body.append(s),e=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#w.set(t,e)}return e}static#v(){if(this.#x!==null)return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.textContent="X",document.body.append(t),this.#x=t.getBoundingClientRect().height,t.remove()}static#_(t,e){const s=this.#A.get(t);if(s)return s;const i=this.#y(e),n=i.font;i.canvas.width=i.canvas.height=mt,i.font=`30px ${t}`;const r=i.measureText("");let a=r.fontBoundingBoxAscent,o=Math.abs(r.fontBoundingBoxDescent);if(a){const d=a/(a+o);return this.#A.set(t,d),i.canvas.width=i.canvas.height=0,i.font=n,d}i.strokeStyle="red",i.clearRect(0,0,mt,mt),i.strokeText("g",0,0);let h=i.getImageData(0,0,mt,mt).data;o=0;for(let d=h.length-1-3;d>=0;d-=4)if(h[d]>0){o=Math.ceil(d/4/mt);break}i.clearRect(0,0,mt,mt),i.strokeText("A",0,mt),h=i.getImageData(0,0,mt,mt).data,a=0;for(let d=0,u=h.length;d<u;d+=4)if(h[d]>0){a=mt-Math.floor(d/4/mt);break}i.canvas.width=i.canvas.height=0,i.font=n;const c=a?a/(a+o):.8;return this.#A.set(t,c),c}};function Gr(){Si("`renderTextLayer`, please use `TextLayer` instead.");const{textContentSource:l,container:t,viewport:e,...s}=arguments[0],i=Object.keys(s);i.length>0&&O("Ignoring `renderTextLayer` parameters: "+i.join(", "));const n=new Fe({textContentSource:l,container:t,viewport:e}),{textDivs:r,textContentItemsStr:a}=n;return{promise:n.render(),textDivs:r,textContentItemsStr:a}}function Ur(){Si("`updateTextLayer`, please use `TextLayer` instead.")}class fe{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};return function i(n){if(!n)return;let r=null;const a=n.name;if(a==="#text")r=n.value;else{if(!fe.shouldBuildText(a))return;n?.attributes?.textContent?r=n.attributes.textContent:n.value&&(r=n.value)}if(r!==null&&e.push({str:r}),n.children)for(const o of n.children)i(o)}(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}const qr=65536,Wr=dt?class extends Le{_createCanvas(l,t){return kt.get("canvas").createCanvas(l,t)}}:class extends Le{constructor({ownerDocument:l=globalThis.document,enableHWA:t=!1}={}){super({enableHWA:t}),this._document=l}_createCanvas(l,t){const e=this._document.createElement("canvas");return e.width=l,e.height=t,e}},Xr=dt?class extends ze{_fetchData(l,t){return Ri(l).then(e=>({cMapData:e,compressionType:t}))}}:xi,Kr=dt?class extends Pe{}:class extends Pe{#t;#e;#s;#n;#o;#i=0;constructor({docId:l,ownerDocument:t=globalThis.document}={}){super(),this.#s=l,this.#n=t}get#r(){return this.#t||=new Map}get#h(){return this.#o||=new Map}get#c(){if(!this.#e){const l=this.#n.createElement("div"),{style:t}=l;t.visibility="hidden",t.contain="strict",t.width=t.height=0,t.position="absolute",t.top=t.left=0,t.zIndex=-1;const e=this.#n.createElementNS(Tt,"svg");e.setAttribute("width",0),e.setAttribute("height",0),this.#e=this.#n.createElementNS(Tt,"defs"),l.append(e),e.append(this.#e),this.#n.body.append(l)}return this.#e}#d(l){if(l.length===1){const a=l[0],o=new Array(256);for(let c=0;c<256;c++)o[c]=a[c]/255;const h=o.join(",");return[h,h,h]}const[t,e,s]=l,i=new Array(256),n=new Array(256),r=new Array(256);for(let a=0;a<256;a++)i[a]=t[a]/255,n[a]=e[a]/255,r[a]=s[a]/255;return[i.join(","),n.join(","),r.join(",")]}addFilter(l){if(!l)return"none";let t=this.#r.get(l);if(t)return t;const[e,s,i]=this.#d(l),n=l.length===1?e:`${e}${s}${i}`;if(t=this.#r.get(n),t)return this.#r.set(l,t),t;const r=`g_${this.#s}_transfer_map_${this.#i++}`,a=`url(#${r})`;this.#r.set(l,a),this.#r.set(n,a);const o=this.#a(r);return this.#m(e,s,i,o),a}addHCMFilter(l,t){const e=`${l}-${t}`,s="base";let i=this.#h.get(s);if(i?.key===e||(i?(i.filter?.remove(),i.key=e,i.url="none",i.filter=null):(i={key:e,url:"none",filter:null},this.#h.set(s,i)),!l||!t))return i.url;const n=this.#b(l);l=k.makeHexColor(...n);const r=this.#b(t);if(t=k.makeHexColor(...r),this.#c.style.color="",l==="#000000"&&t==="#ffffff"||l===t)return i.url;const a=new Array(256);for(let u=0;u<=255;u++){const p=u/255;a[u]=p<=.03928?p/12.92:((p+.055)/1.055)**2.4}const o=a.join(","),h=`g_${this.#s}_hcm_filter`,c=i.filter=this.#a(h);this.#m(o,o,o,c),this.#l(c);const d=(u,p)=>{const g=n[u]/255,f=r[u]/255,v=new Array(p+1);for(let m=0;m<=p;m++)v[m]=g+m/p*(f-g);return v.join(",")};return this.#m(d(0,5),d(1,5),d(2,5),c),i.url=`url(#${h})`,i.url}addAlphaFilter(l){let t=this.#r.get(l);if(t)return t;const[e]=this.#d([l]),s=`alpha_${e}`;if(t=this.#r.get(s),t)return this.#r.set(l,t),t;const i=`g_${this.#s}_alpha_map_${this.#i++}`,n=`url(#${i})`;this.#r.set(l,n),this.#r.set(s,n);const r=this.#a(i);return this.#u(e,r),n}addLuminosityFilter(l){let t,e,s=this.#r.get(l||"luminosity");if(s)return s;if(l?([t]=this.#d([l]),e=`luminosity_${t}`):e="luminosity",s=this.#r.get(e),s)return this.#r.set(l,s),s;const i=`g_${this.#s}_luminosity_map_${this.#i++}`,n=`url(#${i})`;this.#r.set(l,n),this.#r.set(e,n);const r=this.#a(i);return this.#p(r),l&&this.#u(t,r),n}addHighlightHCMFilter(l,t,e,s,i){const n=`${t}-${e}-${s}-${i}`;let r=this.#h.get(l);if(r?.key===n||(r?(r.filter?.remove(),r.key=n,r.url="none",r.filter=null):(r={key:n,url:"none",filter:null},this.#h.set(l,r)),!t||!e))return r.url;const[a,o]=[t,e].map(this.#b.bind(this));let h=Math.round(.2126*a[0]+.7152*a[1]+.0722*a[2]),c=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),[d,u]=[s,i].map(this.#b.bind(this));c<h&&([h,c,d,u]=[c,h,u,d]),this.#c.style.color="";const p=(v,m,b)=>{const A=new Array(256),w=(c-h)/b,_=v/255,y=(m-v)/(255*b);let E=0;for(let S=0;S<=b;S++){const C=Math.round(h+S*w),I=_+S*y;for(let M=E;M<=C;M++)A[M]=I;E=C+1}for(let S=E;S<256;S++)A[S]=A[E-1];return A.join(",")},g=`g_${this.#s}_hcm_${l}_filter`,f=r.filter=this.#a(g);return this.#l(f),this.#m(p(d[0],u[0],5),p(d[1],u[1],5),p(d[2],u[2],5),f),r.url=`url(#${g})`,r.url}destroy(l=!1){l&&this.#h.size!==0||(this.#e&&(this.#e.parentNode.parentNode.remove(),this.#e=null),this.#t&&(this.#t.clear(),this.#t=null),this.#i=0)}#p(l){const t=this.#n.createElementNS(Tt,"feColorMatrix");t.setAttribute("type","matrix"),t.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"),l.append(t)}#l(l){const t=this.#n.createElementNS(Tt,"feColorMatrix");t.setAttribute("type","matrix"),t.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"),l.append(t)}#a(l){const t=this.#n.createElementNS(Tt,"filter");return t.setAttribute("color-interpolation-filters","sRGB"),t.setAttribute("id",l),this.#c.append(t),t}#g(l,t,e){const s=this.#n.createElementNS(Tt,t);s.setAttribute("type","discrete"),s.setAttribute("tableValues",e),l.append(s)}#m(l,t,e,s){const i=this.#n.createElementNS(Tt,"feComponentTransfer");s.append(i),this.#g(i,"feFuncR",l),this.#g(i,"feFuncG",t),this.#g(i,"feFuncB",e)}#u(l,t){const e=this.#n.createElementNS(Tt,"feComponentTransfer");t.append(e),this.#g(e,"feFuncA",l)}#b(l){return this.#c.style.color=l,hs(getComputedStyle(this.#c).getPropertyValue("color"))}},Yr=dt?class extends Ve{_fetchData(l){return Ri(l)}}:Ei;function Qr(l={}){typeof l=="string"||l instanceof URL?l={url:l}:(l instanceof ArrayBuffer||ArrayBuffer.isView(l))&&(l={data:l});const t=new Ds,{docId:e}=t,s=l.url?function(H){if(H instanceof URL)return H.href;try{return new URL(H,window.location).href}catch{if(dt&&typeof H=="string")return H}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(l.url):null,i=l.data?function(H){if(dt&&Ns!==void 0&&H instanceof Ns)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(H instanceof Uint8Array&&H.byteLength===H.buffer.byteLength)return H;if(typeof H=="string")return $e(H);if(H instanceof ArrayBuffer||ArrayBuffer.isView(H)||typeof H=="object"&&!isNaN(H?.length))return new Uint8Array(H);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(l.data):null,n=l.httpHeaders||null,r=l.withCredentials===!0,a=l.password??null,o=l.range instanceof Ni?l.range:null,h=Number.isInteger(l.rangeChunkSize)&&l.rangeChunkSize>0?l.rangeChunkSize:qr;let c=l.worker instanceof bt?l.worker:null;const d=l.verbosity,u=typeof l.docBaseUrl!="string"||Es(l.docBaseUrl)?null:l.docBaseUrl,p=typeof l.cMapUrl=="string"?l.cMapUrl:null,g=l.cMapPacked!==!1,f=l.CMapReaderFactory||Xr,v=typeof l.standardFontDataUrl=="string"?l.standardFontDataUrl:null,m=l.StandardFontDataFactory||Yr,b=l.stopAtErrors!==!0,A=Number.isInteger(l.maxImageSize)&&l.maxImageSize>-1?l.maxImageSize:-1,w=l.isEvalSupported!==!1,_=typeof l.isOffscreenCanvasSupported=="boolean"?l.isOffscreenCanvasSupported:!dt,y=Number.isInteger(l.canvasMaxAreaInBytes)?l.canvasMaxAreaInBytes:-1,E=typeof l.disableFontFace=="boolean"?l.disableFontFace:dt,S=l.fontExtraProperties===!0,C=l.enableXfa===!0,I=l.ownerDocument||globalThis.document,M=l.disableRange===!0,W=l.disableStream===!0,D=l.disableAutoFetch===!0,B=l.pdfBug===!0,U=l.enableHWA===!0,Y=o?o.length:l.length??NaN,J=typeof l.useSystemFonts=="boolean"?l.useSystemFonts:!dt&&!E,R=typeof l.useWorkerFetch=="boolean"?l.useWorkerFetch:f===xi&&m===Ei&&p&&v&&de(p,document.baseURI)&&de(v,document.baseURI),F=l.canvasFactory||new Wr({ownerDocument:I,enableHWA:U}),_t=l.filterFactory||new Kr({docId:e,ownerDocument:I});Wn(d);const At={canvasFactory:F,filterFactory:_t};if(R||(At.cMapReaderFactory=new f({baseUrl:p,isCompressed:g}),At.standardFontDataFactory=new m({baseUrl:v})),!c){const H={verbosity:d,port:ge.workerPort};c=H.port?bt.fromPort(H):new bt(H),t._worker=c}const tt={docId:e,apiVersion:"4.4.168",data:i,password:a,disableAutoFetch:D,rangeChunkSize:h,length:Y,docBaseUrl:u,enableXfa:C,evaluatorOptions:{maxImageSize:A,disableFontFace:E,ignoreErrors:b,isEvalSupported:w,isOffscreenCanvasSupported:_,canvasMaxAreaInBytes:y,fontExtraProperties:S,useSystemFonts:J,cMapUrl:R?p:null,standardFontDataUrl:R?v:null}},et={disableFontFace:E,fontExtraProperties:S,ownerDocument:I,pdfBug:B,styleElement:null,loadingParams:{disableAutoFetch:D,enableXfa:C}};return c.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const H=c.messageHandler.sendWithPromise("GetDocRequest",tt,i?[i.buffer]:null);let X;if(o)X=new Tr(o,{disableRange:M,disableStream:W});else if(!i){if(!s)throw new Error("getDocument - no `url` parameter provided.");X=(N=>dt?function(){return typeof fetch<"u"&&typeof Response<"u"&&"body"in Response.prototype}()&&de(N.url)?new ei(N):new Br(N):de(N.url)?new ei(N):new Or(N))({url:s,length:Y,httpHeaders:n,withCredentials:r,rangeChunkSize:h,disableRange:M,disableStream:W})}return H.then(N=>{if(t.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const V=new ue(e,N,c.port),lt=new ea(V,t,X,et,At);t._transport=lt,V.send("Ready",null)})}).catch(t._capability.reject),t}function si(l){return typeof l=="object"&&Number.isInteger(l?.num)&&l.num>=0&&Number.isInteger(l?.gen)&&l.gen>=0}class Ds{static#t=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId="d"+Ds.#t++,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await this._transport?.destroy()}catch(t){throw this._worker?.port&&delete this._worker._pendingDestroy,t}this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)}}let Ni=class{constructor(l,t,e=!1,s=null){this.length=l,this.initialData=t,this.progressiveDone=e,this.contentDispositionFilename=s,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(l){this._rangeListeners.push(l)}addProgressListener(l){this._progressListeners.push(l)}addProgressiveReadListener(l){this._progressiveReadListeners.push(l)}addProgressiveDoneListener(l){this._progressiveDoneListeners.push(l)}onDataRange(l,t){for(const e of this._rangeListeners)e(l,t)}onDataProgress(l,t){this._readyCapability.promise.then(()=>{for(const e of this._progressListeners)e(l,t)})}onDataProgressiveRead(l){this._readyCapability.promise.then(()=>{for(const t of this._progressiveReadListeners)t(l)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(const l of this._progressiveDoneListeners)l()})}transportReady(){this._readyCapability.resolve()}requestDataRange(l,t){q("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}};class Jr{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return z(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class Zr{#t=null;#e=!1;constructor(t,e,s,i=!1){this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=i?new Hs:null,this._pdfBug=i,this.commonObjs=s.commonObjs,this.objs=new ji,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:s=0,offsetY:i=0,dontFlip:n=!1}={}){return new me({viewBox:this.view,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return z(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,viewport:e,intent:s="display",annotationMode:i=Nt.ENABLE,transform:n=null,background:r=null,optionalContentConfigPromise:a=null,annotationCanvasMap:o=null,pageColors:h=null,printAnnotationStorage:c=null}){this._stats?.time("Overall");const d=this._transport.getRenderingIntent(s,i,c),{renderingIntent:u,cacheKey:p}=d;this.#e=!1,this.#n(),a||=this._transport.getOptionalContentConfig(u);let g=this._intentStates.get(p);g||(g=Object.create(null),this._intentStates.set(p,g)),g.streamReaderCancelTimeout&&(clearTimeout(g.streamReaderCancelTimeout),g.streamReaderCancelTimeout=null);const f=!!(u&Te);g.displayReadyCapability||(g.displayReadyCapability=Promise.withResolvers(),g.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(d));const v=A=>{g.renderTasks.delete(m),(this._maybeCleanupAfterRender||f)&&(this.#e=!0),this.#s(!f),A?(m.capability.reject(A),this._abortOperatorList({intentState:g,reason:A instanceof Error?A:new Error(A)})):m.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},m=new te({callback:v,params:{canvasContext:t,viewport:e,transform:n,background:r},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:o,operatorList:g.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!f,pdfBug:this._pdfBug,pageColors:h});(g.renderTasks||=new Set).add(m);const b=m.task;return Promise.all([g.displayReadyCapability.promise,a]).then(([A,w])=>{if(this.destroyed)v();else{if(this._stats?.time("Rendering"),!(w.renderingIntent&u))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");m.initializeGraphics({transparency:A,optionalContentConfig:w}),m.operatorListChanged()}}).catch(v),b}getOperatorList({intent:t="display",annotationMode:e=Nt.ENABLE,printAnnotationStorage:s=null}={}){const i=this._transport.getRenderingIntent(t,e,s,!0);let n,r=this._intentStates.get(i.cacheKey);return r||(r=Object.create(null),this._intentStates.set(i.cacheKey,r)),r.opListReadCapability||(n=Object.create(null),n.operatorListChanged=function(){r.operatorList.lastChunk&&(r.opListReadCapability.resolve(r.operatorList),r.renderTasks.delete(n))},r.opListReadCapability=Promise.withResolvers(),(r.renderTasks||=new Set).add(n),r.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(i)),r.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size:s=>s.items.length})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(s=>fe.textContent(s));const e=this.streamTextContent(t);return new Promise(function(s,i){const n=e.getReader(),r={items:[],styles:Object.create(null),lang:null};(function a(){n.read().then(function({value:o,done:h}){h?s(r):(r.lang??=o.lang,Object.assign(r.styles,o.styles),r.items.push(...o.items),a())},i)})()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const s of e.renderTasks)t.push(s.completed),s.cancel();return this.objs.clear(),this.#e=!1,this.#n(),Promise.all(t)}cleanup(t=!1){this.#e=!0;const e=this.#s(!1);return t&&e&&(this._stats&&=new Hs),e}#s(t=!1){if(this.#n(),!this.#e||this.destroyed)return!1;if(t)return this.#t=setTimeout(()=>{this.#t=null,this.#s(!1)},5e3),!1;for(const{renderTasks:e,operatorList:s}of this._intentStates.values())if(e.size>0||!s.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#e=!1,!0}#n(){this.#t&&(clearTimeout(this.#t),this.#t=null)}_startRenderPage(t,e){const s=this._intentStates.get(e);s&&(this._stats?.timeEnd("Page Request"),s.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let s=0,i=t.length;s<i;s++)e.operatorList.fnArray.push(t.fnArray[s]),e.operatorList.argsArray.push(t.argsArray[s]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const s of e.renderTasks)s.operatorListChanged();t.lastChunk&&this.#s(!0)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s}){const{map:i,transfer:n}=s,r=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:i},n).getReader(),a=this._intentStates.get(e);a.streamReader=r;const o=()=>{r.read().then(({value:h,done:c})=>{c?a.streamReader=null:this._transport.destroyed||(this._renderPageChunk(h,a),o())},h=>{if(a.streamReader=null,!this._transport.destroyed){if(a.operatorList){a.operatorList.lastChunk=!0;for(const c of a.renderTasks)c.operatorListChanged();this.#s(!0)}if(a.displayReadyCapability)a.displayReadyCapability.reject(h);else{if(!a.opListReadCapability)throw h;a.opListReadCapability.reject(h)}}})};o()}_abortOperatorList({intentState:t,reason:e,force:s=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!s){if(t.renderTasks.size>0)return;if(e instanceof xs){let i=100;return e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay),void(t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},i))}}if(t.streamReader.cancel(new Xt(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[i,n]of this._intentStates)if(n===t){this._intentStates.delete(i);break}this.cleanup()}}}get stats(){return this._stats}}class ta{#t=new Set;#e=Promise.resolve();postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};this.#e.then(()=>{for(const i of this.#t)i.call(this,s)})}addEventListener(t,e){this.#t.add(e)}removeEventListener(t,e){this.#t.delete(e)}terminate(){this.#t.clear()}}const Lt={isWorkerDisabled:!1,fakeWorkerId:0};dt&&(Lt.isWorkerDisabled=!0,ge.workerSrc||="./pdf.worker.mjs"),Lt.isSameOrigin=function(l,t){let e;try{if(e=new URL(l),!e.origin||e.origin==="null")return!1}catch{return!1}const s=new URL(t,e);return e.origin===s.origin},Lt.createCDNWrapper=function(l){const t=`await import("${l}");`;return URL.createObjectURL(new Blob([t],{type:"text/javascript"}))};class bt{static#t;constructor({name:t=null,port:e=null,verbosity:s=Xn()}={}){if(this.name=t,this.destroyed=!1,this.verbosity=s,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,e){if(bt.#t?.has(e))throw new Error("Cannot use more than one PDFWorker per port.");return(bt.#t||=new WeakMap).set(e,this),void this._initializeFromPort(e)}this._initialize()}get promise(){return dt?Promise.all([kt.promise,this._readyCapability.promise]):this._readyCapability.promise}#e(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new ue("main","worker",t),this._messageHandler.on("ready",function(){}),this.#e()}_initialize(){if(Lt.isWorkerDisabled||bt.#s)return void this._setupFakeWorker();let{workerSrc:t}=bt;try{Lt.isSameOrigin(window.location.href,t)||(t=Lt.createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new ue("main","worker",e),i=()=>{n.abort(),s.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},n=new AbortController;e.addEventListener("error",()=>{this._webWorker||i()},{signal:n.signal}),s.on("test",a=>{n.abort(),!this.destroyed&&a?(this._messageHandler=s,this._port=e,this._webWorker=e,this.#e()):i()}),s.on("ready",a=>{if(n.abort(),this.destroyed)i();else try{r()}catch{this._setupFakeWorker()}});const r=()=>{const a=new Uint8Array;s.send("test",a,[a.buffer])};return void r()}catch{Be("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){Lt.isWorkerDisabled||(O("Setting up fake worker."),Lt.isWorkerDisabled=!0),bt._setupFakeWorkerGlobal.then(t=>{if(this.destroyed)return void this._readyCapability.reject(new Error("Worker was destroyed"));const e=new ta;this._port=e;const s="fake"+Lt.fakeWorkerId++,i=new ue(s+"_worker",s,e);t.setup(i,e),this._messageHandler=new ue(s,s+"_worker",e),this.#e()}).catch(t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),bt.#t?.delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(t){if(!t?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");const e=this.#t?.get(t.port);if(e){if(e._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new bt(t)}static get workerSrc(){if(ge.workerSrc)return ge.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#s(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return z(this,"_setupFakeWorkerGlobal",(async()=>this.#s?this.#s:(await import(this.workerSrc)).WorkerMessageHandler)())}}class ea{#t=new Map;#e=new Map;#s=new Map;#n=new Map;#o=null;constructor(t,e,s,i,n){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new ji,this.fontLoader=new gr({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.cMapReaderFactory=n.cMapReaderFactory,this.standardFontDataFactory=n.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=s,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#i(t,e=null){const s=this.#t.get(t);if(s)return s;const i=this.messageHandler.sendWithPromise(t,e);return this.#t.set(t,i),i}get annotationStorage(){return z(this,"annotationStorage",new Rs)}getRenderingIntent(t,e=Nt.ENABLE,s=null,i=!1){let n=As,r=ls;switch(t){case"any":n=mn;break;case"display":break;case"print":n=Te;break;default:O(`getRenderingIntent - invalid intent: ${t}`)}switch(e){case Nt.DISABLE:n+=An;break;case Nt.ENABLE:break;case Nt.ENABLE_FORMS:n+=vn;break;case Nt.ENABLE_STORAGE:n+=bn,r=(n&Te&&s instanceof Mi?s:this.annotationStorage).serializable;break;default:O(`getRenderingIntent - invalid annotationMode: ${e}`)}return i&&(n+=yn),{renderingIntent:n,cacheKey:`${n}_${r.hash}`,annotationStorageSerializable:r}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#o?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const s of this.#e.values())t.push(s._destroy());this.#e.clear(),this.#s.clear(),this.#n.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#t.clear(),this.filterFactory.destroy(),Fe.cleanup(),this._networkStream?.cancelAllRequests(new Xt("Worker was terminated.")),this.messageHandler&&(this.messageHandler.destroy(),this.messageHandler=null),this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(s,i)=>{nt(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=n=>{this._lastProgress={loaded:n.loaded,total:n.total}},i.onPull=()=>{this._fullReader.read().then(function({value:n,done:r}){r?i.close():(nt(n instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(n),1,[n]))}).catch(n=>{i.error(n)})},i.onCancel=n=>{this._fullReader.cancel(n),i.ready.catch(r=>{if(!this.destroyed)throw r})}}),t.on("ReaderHeadersReady",s=>{const i=Promise.withResolvers(),n=this._fullReader;return n.headersReady.then(()=>{n.isStreamingSupported&&n.isRangeSupported||(this._lastProgress&&e.onProgress?.(this._lastProgress),n.onProgress=r=>{e.onProgress?.({loaded:r.loaded,total:r.total})}),i.resolve({isStreamingSupported:n.isStreamingSupported,isRangeSupported:n.isRangeSupported,contentLength:n.contentLength})},i.reject),i.promise}),t.on("GetRangeReader",(s,i)=>{nt(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const n=this._networkStream.getRangeReader(s.begin,s.end);n?(i.onPull=()=>{n.read().then(function({value:r,done:a}){a?i.close():(nt(r instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(r),1,[r]))}).catch(r=>{i.error(r)})},i.onCancel=r=>{n.cancel(r),i.ready.catch(a=>{if(!this.destroyed)throw a})}):i.close()}),t.on("GetDoc",({pdfInfo:s})=>{this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,e._capability.resolve(new Jr(s,this))}),t.on("DocException",function(s){let i;switch(s.name){case"PasswordException":i=new as(s.message,s.code);break;case"InvalidPDFException":i=new yi(s.message);break;case"MissingPDFException":i=new Wt(s.message);break;case"UnexpectedResponseException":i=new He(s.message,s.status);break;case"UnknownErrorException":i=new os(s.message,s.details);break;default:q("DocException - expected a valid Error.")}e._capability.reject(i)}),t.on("PasswordRequest",s=>{if(this.#o=Promise.withResolvers(),e.onPassword){const i=n=>{n instanceof Error?this.#o.reject(n):this.#o.resolve({password:n})};try{e.onPassword(i,s.code)}catch(n){this.#o.reject(n)}}else this.#o.reject(new as(s.message,s.code));return this.#o.promise}),t.on("DataLoaded",s=>{e.onProgress?.({loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",s=>{this.destroyed||this.#e.get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,i,n])=>{if(this.destroyed||this.commonObjs.has(s))return null;switch(i){case"Font":const{disableFontFace:r,fontExtraProperties:a,pdfBug:o}=this._params;if("error"in n){const u=n.error;O(`Error during font loading: ${u}`),this.commonObjs.resolve(s,u);break}const h=o&&globalThis.FontInspector?.enabled?(u,p)=>globalThis.FontInspector.fontAdded(u,p):null,c=new fr(n,{disableFontFace:r,inspectFont:h});this.fontLoader.bind(c).catch(()=>t.sendWithPromise("FontFallback",{id:s})).finally(()=>{!a&&c.data&&(c.data=null),this.commonObjs.resolve(s,c)});break;case"CopyLocalImage":const{imageRef:d}=n;nt(d,"The imageRef must be defined.");for(const u of this.#e.values())for(const[,p]of u.objs)if(p?.ref===d)return p.dataLen?(this.commonObjs.resolve(s,structuredClone(p)),p.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(s,n);break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([s,i,n,r])=>{if(this.destroyed)return;const a=this.#e.get(i);if(!a.objs.has(s))if(a._intentStates.size!==0)switch(n){case"Image":a.objs.resolve(s,r),r?.dataLen>1e7&&(a._maybeCleanupAfterRender=!0);break;case"Pattern":a.objs.resolve(s,r);break;default:throw new Error(`Got unknown object type ${n}`)}else r?.bitmap?.close()}),t.on("DocProgress",s=>{this.destroyed||e.onProgress?.({loaded:s.loaded,total:s.total})}),t.on("FetchBuiltInCMap",s=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.cMapReaderFactory?this.cMapReaderFactory.fetch(s):Promise.reject(new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter."))),t.on("FetchStandardFontData",s=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.standardFontDataFactory?this.standardFontDataFactory.fetch(s):Promise.reject(new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.")))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&O("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this._fullReader?.filename??null},e).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=t-1,s=this.#s.get(e);if(s)return s;const i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(n=>{if(this.destroyed)throw new Error("Transport destroyed");n.refStr&&this.#n.set(n.refStr,t);const r=new Zr(e,n,this,this._params.pdfBug);return this.#e.set(e,r),r});return this.#s.set(e,i),i}getPageIndex(t){return si(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return this.#i("GetFieldObjects")}hasJSActions(){return this.#i("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return typeof t!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return this.#i("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#i("GetOptionalContentConfig").then(e=>new Rr(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=this.#t.get(t);if(e)return e;const s=this.messageHandler.sendWithPromise(t,null).then(i=>({info:i[0],metadata:i[1]?new kr(i[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return this.#t.set(t,s),s}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of this.#e.values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#t.clear(),this.filterFactory.destroy(!0),Fe.cleanup()}}cachedPageNumber(t){if(!si(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return this.#n.get(e)??null}}const Ce=Symbol("INITIAL_DATA");class ji{#t=Object.create(null);#e(t){return this.#t[t]||={...Promise.withResolvers(),data:Ce}}get(t,e=null){if(e){const i=this.#e(t);return i.promise.then(()=>e(i.data)),null}const s=this.#t[t];if(!s||s.data===Ce)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=this.#t[t];return!!e&&e.data!==Ce}resolve(t,e=null){const s=this.#e(t);s.data=e,s.resolve()}clear(){for(const t in this.#t){const{data:e}=this.#t[t];e?.bitmap?.close()}this.#t=Object.create(null)}*[Symbol.iterator](){for(const t in this.#t){const{data:e}=this.#t[t];e!==Ce&&(yield[t,e])}}}class sa{#t=null;constructor(t){this.#t=t,this.onContinue=null}get promise(){return this.#t.capability.promise}cancel(t=0){this.#t.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this.#t.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this.#t;return t.form||t.canvas&&e?.size>0}}class te{#t=null;static#e=new WeakSet;constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:n,operatorList:r,pageIndex:a,canvasFactory:o,filterFactory:h,useRequestAnimationFrame:c=!1,pdfBug:d=!1,pageColors:u=null}){this.callback=t,this.params=e,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=a,this.canvasFactory=o,this.filterFactory=h,this._pdfBug=d,this.pageColors=u,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=c===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new sa(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(te.#e.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");te.#e.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:s,viewport:i,transform:n,background:r}=this.params;this.gfx=new ee(s,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:n,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.#t&&(window.cancelAnimationFrame(this.#t),this.#t=null),te.#e.delete(this._canvas),this.callback(t||new xs(`Rendering cancelled, page ${this._pageIndex+1}`,e))}operatorListChanged(){this.graphicsReady?(this.stepper?.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||=this._continueBound}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#t=window.requestAnimationFrame(()=>{this.#t=null,this._nextBound().catch(this._cancelBound)}):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),te.#e.delete(this._canvas),this.callback())))}}const ia="4.4.168",na="19fbc8998";function ii(l){return Math.floor(255*Math.max(0,Math.min(1,l))).toString(16).padStart(2,"0")}function ce(l){return Math.max(0,Math.min(255,255*l))}class ni{static CMYK_G([t,e,s,i]){return["G",1-Math.min(1,.3*t+.59*s+.11*e+i)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return[t=ce(t),t,t]}static G_HTML([t]){const e=ii(t);return`#${e}${e}${e}`}static RGB_G([t,e,s]){return["G",.3*t+.59*e+.11*s]}static RGB_rgb(t){return t.map(ce)}static RGB_HTML(t){return`#${t.map(ii).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,s,i]){return["RGB",1-Math.min(1,t+i),1-Math.min(1,s+i),1-Math.min(1,e+i)]}static CMYK_rgb([t,e,s,i]){return[ce(1-Math.min(1,t+i)),ce(1-Math.min(1,s+i)),ce(1-Math.min(1,e+i))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,s]){const i=1-t,n=1-e,r=1-s;return["CMYK",i,n,r,Math.min(i,n,r)]}}class Bi{static setupStorage(t,e,s,i,n){const r=i.getValue(e,{value:null});switch(s.name){case"textarea":if(r.value!==null&&(t.textContent=r.value),n==="print")break;t.addEventListener("input",a=>{i.setValue(e,{value:a.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(r.value===s.attributes.xfaOn?t.setAttribute("checked",!0):r.value===s.attributes.xfaOff&&t.removeAttribute("checked"),n==="print")break;t.addEventListener("change",a=>{i.setValue(e,{value:a.target.checked?a.target.getAttribute("xfaOn"):a.target.getAttribute("xfaOff")})})}else{if(r.value!==null&&t.setAttribute("value",r.value),n==="print")break;t.addEventListener("input",a=>{i.setValue(e,{value:a.target.value})})}break;case"select":if(r.value!==null){t.setAttribute("value",r.value);for(const a of s.children)a.attributes.value===r.value?a.attributes.selected=!0:a.attributes.hasOwnProperty("selected")&&delete a.attributes.selected}t.addEventListener("input",a=>{const o=a.target.options,h=o.selectedIndex===-1?"":o[o.selectedIndex].value;i.setValue(e,{value:h})})}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:n}){const{attributes:r}=e,a=t instanceof HTMLAnchorElement;r.type==="radio"&&(r.name=`${r.name}-${i}`);for(const[o,h]of Object.entries(r))if(h!=null)switch(o){case"class":h.length&&t.setAttribute(o,h.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",h);break;case"style":Object.assign(t.style,h);break;case"textContent":t.textContent=h;break;default:(!a||o!=="href"&&o!=="newWindow")&&t.setAttribute(o,h)}a&&n.addLinkAttributes(t,r.href,r.newWindow),s&&r.dataId&&this.setupStorage(t,r.dataId,e,s)}static render(t){const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,n=t.intent||"display",r=document.createElement(i.name);i.attributes&&this.setAttributes({html:r,element:i,intent:n,linkService:s});const a=n!=="richText",o=t.div;if(o.append(r),t.viewport){const d=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=d}a&&o.setAttribute("class","xfaLayer xfaFont");const h=[];if(i.children.length===0){if(i.value){const d=document.createTextNode(i.value);r.append(d),a&&fe.shouldBuildText(i.name)&&h.push(d)}return{textDivs:h}}const c=[[i,-1,r]];for(;c.length>0;){const[d,u,p]=c.at(-1);if(u+1===d.children.length){c.pop();continue}const g=d.children[++c.at(-1)[1]];if(g===null)continue;const{name:f}=g;if(f==="#text"){const m=document.createTextNode(g.value);h.push(m),p.append(m);continue}const v=g?.attributes?.xmlns?document.createElementNS(g.attributes.xmlns,f):document.createElement(f);if(p.append(v),g.attributes&&this.setAttributes({html:v,element:g,storage:e,intent:n,linkService:s}),g.children?.length>0)c.push([g,-1,v]);else if(g.value){const m=document.createTextNode(g.value);a&&fe.shouldBuildText(f)&&h.push(m),v.append(m)}}for(const d of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))d.setAttribute("readOnly",!0);return{textDivs:h}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const Ae=1e3,Ut=new WeakSet;function It(l){return{width:l[2]-l[0],height:l[3]-l[1]}}class ra{static create(t){switch(t.data.annotationType){case Sn:return new Hi(t);case En:return new aa(t);case Hn:switch(t.data.fieldType){case"Tx":return new oa(t);case"Btn":return t.data.radioButton?new $i(t):t.data.checkBox?new la(t):new ca(t);case"Ch":return new da(t);case"Sig":return new ha(t)}return new Kt(t);case Ai:return new ps(t);case Cn:return new zi(t);case kn:return new pa(t);case Mn:return new ga(t);case Rn:return new fa(t);case Pn:return new Vi(t);case Nn:return new va(t);case jn:return new Gi(t);case Tn:return new ma(t);case Ln:return new ba(t);case In:return new Aa(t);case Dn:return new ya(t);case Fn:return new wa(t);case On:return new Ui(t);case Bn:return new _a(t);default:return new Z(t)}}}class Z{#t=null;#e=!1;#s=null;constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(s)),i&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:s}){return!!(t?.str||e?.str||s?.str)}get hasPopupData(){return Z._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;this.#t||={rect:this.data.rect.slice(0)};const{rect:e}=t;e&&this.#n(e),this.#s?.popup.updateEdited(t)}resetEdited(){this.#t&&(this.#n(this.#t.rect),this.#s?.popup.resetEdited(),this.#t=null)}#n(t){const{container:{style:e},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:r,pageX:a,pageY:o}}}}=this;s?.splice(0,4,...t);const{width:h,height:c}=It(t);e.left=100*(t[0]-a)/n+"%",e.top=100*(r-t[3]+o)/r+"%",i===0?(e.width=100*h/n+"%",e.height=100*c/r+"%"):this.setRotation(i)}_createContainer(t){const{data:e,parent:{page:s,viewport:i}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",e.id),this instanceof Kt||(n.tabIndex=Ae);const{style:r}=n;if(r.zIndex=this.parent.zIndex++,e.popupRef&&n.setAttribute("aria-haspopup","dialog"),e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof ps){const{rotation:f}=e;return e.hasOwnCanvas||f===0||this.setRotation(f,n),n}const{width:a,height:o}=It(e.rect);if(!t&&e.borderStyle.width>0){r.borderWidth=`${e.borderStyle.width}px`;const f=e.borderStyle.horizontalCornerRadius,v=e.borderStyle.verticalCornerRadius;if(f>0||v>0){const b=`calc(${f}px * var(--scale-factor)) / calc(${v}px * var(--scale-factor))`;r.borderRadius=b}else if(this instanceof $i){const b=`calc(${a}px * var(--scale-factor)) / calc(${o}px * var(--scale-factor))`;r.borderRadius=b}switch(e.borderStyle.style){case $n:r.borderStyle="solid";break;case zn:r.borderStyle="dashed";break;case Vn:O("Unimplemented border style: beveled");break;case Gn:O("Unimplemented border style: inset");break;case Un:r.borderBottomStyle="solid"}const m=e.borderColor||null;m?(this.#e=!0,r.borderColor=k.makeHexColor(0|m[0],0|m[1],0|m[2])):r.borderWidth=0}const h=k.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]),{pageWidth:c,pageHeight:d,pageX:u,pageY:p}=i.rawDims;r.left=100*(h[0]-u)/c+"%",r.top=100*(h[1]-p)/d+"%";const{rotation:g}=e;return e.hasOwnCanvas||g===0?(r.width=100*a/c+"%",r.height=100*o/d+"%"):this.setRotation(g,n),n}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims,{width:n,height:r}=It(this.data.rect);let a,o;t%180==0?(a=100*n/s,o=100*r/i):(a=100*r/s,o=100*n/i),e.style.width=`${a}%`,e.style.height=`${o}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,s,i)=>{const n=i.detail[e],r=n[0],a=n.slice(1);i.target.style[s]=ni[`${r}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[s]:ni[`${r}_rgb`](a)})};return z(this,"_commonActions",{display:e=>{const{display:s}=e.detail,i=s%2==1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:s===1||s===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:s}=e.detail;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:s,noView:s})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:e=>{const s=e.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(t,e){const s=this._commonActions;for(const i of Object.keys(e.detail))(t[i]||s[i])?.(e)}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const s=this._commonActions;for(const[i,n]of Object.entries(e)){const r=s[i];r&&(r({detail:{[i]:n},target:t}),delete e[i])}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,s,i,n]=this.data.rect.map(f=>Math.fround(f));if(t.length===8){const[f,v,m,b]=t.subarray(2,6);if(i===f&&n===v&&e===m&&s===b)return}const{style:r}=this.container;let a;if(this.#e){const{borderColor:f,borderWidth:v}=r;r.borderWidth=0,a=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${f}" stroke-width="${v}">`],this.container.classList.add("hasBorder")}const o=i-e,h=n-s,{svgFactory:c}=this,d=c.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0);const u=c.createElement("defs");d.append(u);const p=c.createElement("clipPath"),g=`clippath_${this.data.id}`;p.setAttribute("id",g),p.setAttribute("clipPathUnits","objectBoundingBox"),u.append(p);for(let f=2,v=t.length;f<v;f+=8){const m=t[f],b=t[f+1],A=t[f+2],w=t[f+3],_=c.createElement("rect"),y=(A-e)/o,E=(n-b)/h,S=(m-A)/o,C=(b-w)/h;_.setAttribute("x",y),_.setAttribute("y",E),_.setAttribute("width",S),_.setAttribute("height",C),p.append(_),a?.push(`<rect vector-effect="non-scaling-stroke" x="${y}" y="${E}" width="${S}" height="${C}"/>`)}this.#e&&(a.push("</g></svg>')"),r.backgroundImage=a.join("")),this.container.append(d),this.container.style.clipPath=`url(#${g})`}_createPopup(){const{container:t,data:e}=this;t.setAttribute("aria-haspopup","dialog");const s=this.#s=new ps({data:{color:e.color,titleObj:e.titleObj,modificationDate:e.modificationDate,contentsObj:e.contentsObj,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation},parent:this.parent,elements:[this]});this.parent.div.append(s.render())}render(){q("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const s=[];if(this._fieldObjects){const i=this._fieldObjects[t];if(i)for(const{page:n,id:r,exportValues:a}of i){if(n===-1||r===e)continue;const o=typeof a=="string"?a:null,h=document.querySelector(`[data-element-id="${r}"]`);!h||Ut.has(h)?s.push({id:r,exportValue:o,domElement:h}):O(`_getElementsByName - element not allowed: ${r}`)}return s}for(const i of document.getElementsByName(t)){const{exportValue:n}=i,r=i.getAttribute("data-element-id");r!==e&&Ut.has(i)&&s.push({id:r,exportValue:n,domElement:i})}return s}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}get _isEditable(){return!1}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e})})}}class Hi extends Z{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){const{data:t,linkService:e}=this,s=document.createElement("a");s.setAttribute("data-element-id",t.id);let i=!1;return t.url?(e.addLinkAttributes(s,t.url,t.newWindow),i=!0):t.action?(this._bindNamedAction(s,t.action),i=!0):t.attachment?(this.#e(s,t.attachment,t.attachmentDest),i=!0):t.setOCGState?(this.#s(s,t.setOCGState),i=!0):t.dest?(this._bindLink(s,t.dest),i=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(s,t),i=!0),t.resetForm?(this._bindResetFormAction(s,t.resetForm),i=!0):this.isTooltipOnly&&!i&&(this._bindLink(s,""),i=!0)),this.container.classList.add("linkAnnotation"),i&&this.container.append(s),this.container}#t(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||e==="")&&this.#t()}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),this.#t()}#e(t,e,s=null){t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,s),!1),this.#t()}#s(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),this.#t()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const s=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const i of Object.keys(e.actions)){const n=s.get(i);n&&(t[n]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:i}}),!1))}t.onclick||(t.onclick=()=>!1),this.#t()}_bindResetFormAction(t,e){const s=t.onclick;if(s||(t.href=this.linkService.getAnchorUrl("")),this.#t(),!this._fieldObjects)return O('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(s||(t.onclick=()=>!1));t.onclick=()=>{s?.();const{fields:i,refs:n,include:r}=e,a=[];if(i.length!==0||n.length!==0){const c=new Set(n);for(const d of i){const u=this._fieldObjects[d]||[];for(const{id:p}of u)c.add(p)}for(const d of Object.values(this._fieldObjects))for(const u of d)c.has(u.id)===r&&a.push(u)}else for(const c of Object.values(this._fieldObjects))a.push(...c);const o=this.annotationStorage,h=[];for(const c of a){const{id:d}=c;switch(h.push(d),c.type){case"text":{const p=c.defaultValue||"";o.setValue(d,{value:p});break}case"checkbox":case"radiobutton":{const p=c.defaultValue===c.exportValues;o.setValue(d,{value:p});break}case"combobox":case"listbox":{const p=c.defaultValue||"";o.setValue(d,{value:p});break}default:continue}const u=document.querySelector(`[data-element-id="${d}"]`);u&&(Ut.has(u)?u.dispatchEvent(new Event("resetform")):O(`_bindResetFormAction - element not allowed: ${d}`))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:h,name:"ResetForm"}}),!1}}}class aa extends Z{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(t),this.container}}class Kt extends Z{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&(t.previousSibling?.nodeName==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return pt.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,i,n){s.includes("mouse")?t.addEventListener(s,r=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(r),shift:r.shiftKey,modifier:this._getKeyModifier(r)}})}):t.addEventListener(s,r=>{if(s==="blur"){if(!e.focused||!r.relatedTarget)return;e.focused=!1}else if(s==="focus"){if(e.focused)return;e.focused=!0}n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(r)}})})}_setEventListeners(t,e,s,i){for(const[n,r]of s)(r==="Action"||this.data.actions?.[r])&&(r!=="Focus"&&r!=="Blur"||(e||={focused:!1}),this._setEventListener(t,e,n,r,i),r!=="Focus"||this.data.actions?.Blur?r!=="Blur"||this.data.actions?.Focus||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":k.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||9,n=t.style;let r;const a=o=>Math.round(10*o)/10;if(this.data.multiLine){const o=Math.abs(this.data.rect[3]-this.data.rect[1]-2),h=o/(Math.round(o/(Ke*i))||1);r=Math.min(i,a(h/Ke))}else{const o=Math.abs(this.data.rect[3]-this.data.rect[1]-2);r=Math.min(i,a(o/Ke))}n.fontSize=`calc(${r}px * var(--scale-factor))`,n.color=k.makeHexColor(s[0],s[1],s[2]),this.data.textAlignment!==null&&(n.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class oa extends Kt{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,s,i){const n=this.annotationStorage;for(const r of this._getElementsByName(t.name,t.id))r.domElement&&(r.domElement[e]=s),n.setValue(r.id,{[i]:s})}render(){const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const i=t.getValue(e,{value:this.data.fieldValue});let n=i.value||"";const r=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;r&&n.length>r&&(n=n.slice(0,r));let a=i.formattedValue||this.data.textContent?.join(`
4
4
  `)||null;a&&this.data.comb&&(a=a.replaceAll(/\s+/g,""));const o={userValue:n,formattedValue:a,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=a??n,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type="text",s.setAttribute("value",a??n),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(s.hidden=!0),Ut.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=Ae,this._setRequired(s,this.data.required),r&&(s.maxLength=r),s.addEventListener("input",c=>{t.setValue(e,{value:c.target.value}),this.setPropertyOnSiblings(s,"value",c.target.value,"value"),o.formattedValue=null}),s.addEventListener("resetform",c=>{const d=this.data.defaultFieldValue??"";s.value=o.userValue=d,o.formattedValue=null});let h=c=>{const{formattedValue:d}=o;d!=null&&(c.target.value=d),c.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",d=>{if(o.focused)return;const{target:u}=d;o.userValue&&(u.value=o.userValue),o.lastCommittedValue=u.value,o.commitKey=1,this.data.actions?.Focus||(o.focused=!0)}),s.addEventListener("updatefromsandbox",d=>{this.showElementAndHideCanvas(d.target);const u={value(p){o.userValue=p.detail.value??"",t.setValue(e,{value:o.userValue.toString()}),p.target.value=o.userValue},formattedValue(p){const{formattedValue:g}=p.detail;o.formattedValue=g,g!=null&&p.target!==document.activeElement&&(p.target.value=g),t.setValue(e,{formattedValue:g})},selRange(p){p.target.setSelectionRange(...p.detail.selRange)},charLimit:p=>{const{charLimit:g}=p.detail,{target:f}=p;if(g===0)return void f.removeAttribute("maxLength");f.setAttribute("maxLength",g);let v=o.userValue;!v||v.length<=g||(v=v.slice(0,g),f.value=o.userValue=v,t.setValue(e,{value:v}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:v,willCommit:!0,commitKey:1,selStart:f.selectionStart,selEnd:f.selectionEnd}}))}};this._dispatchEventFromSandbox(u,d)}),s.addEventListener("keydown",d=>{o.commitKey=1;let u=-1;if(d.key==="Escape"?u=0:d.key!=="Enter"||this.data.multiLine?d.key==="Tab"&&(o.commitKey=3):u=2,u===-1)return;const{value:p}=d.target;o.lastCommittedValue!==p&&(o.lastCommittedValue=p,o.userValue=p,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:p,willCommit:!0,commitKey:u,selStart:d.target.selectionStart,selEnd:d.target.selectionEnd}}))});const c=h;h=null,s.addEventListener("blur",d=>{if(!o.focused||!d.relatedTarget)return;this.data.actions?.Blur||(o.focused=!1);const{value:u}=d.target;o.userValue=u,o.lastCommittedValue!==u&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:u,willCommit:!0,commitKey:o.commitKey,selStart:d.target.selectionStart,selEnd:d.target.selectionEnd}}),c(d)}),this.data.actions?.Keystroke&&s.addEventListener("beforeinput",d=>{o.lastCommittedValue=null;const{data:u,target:p}=d,{value:g,selectionStart:f,selectionEnd:v}=p;let m=f,b=v;switch(d.inputType){case"deleteWordBackward":{const A=g.substring(0,f).match(/\w*[^\w]*$/);A&&(m-=A[0].length);break}case"deleteWordForward":{const A=g.substring(f).match(/^[^\w]*\w*/);A&&(b+=A[0].length);break}case"deleteContentBackward":f===v&&(m-=1);break;case"deleteContentForward":f===v&&(b+=1)}d.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:g,change:u||"",willCommit:!1,selStart:m,selEnd:b}})}),this._setEventListeners(s,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],d=>d.target.value)}if(h&&s.addEventListener("blur",h),this.data.comb){const c=(this.data.rect[2]-this.data.rect[0])/r;s.classList.add("comb"),s.style.letterSpacing=`calc(${c}px * var(--scale-factor) - 1ch)`}}else s=document.createElement("div"),s.textContent=this.data.fieldValue,s.style.verticalAlign="middle",s.style.display="table-cell",this.data.hasOwnCanvas&&(s.hidden=!0);return this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class ha extends Kt{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class la extends Kt{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.exportValue===e.fieldValue}).value;typeof i=="string"&&(i=i!=="Off",t.setValue(s,{value:i})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const n=document.createElement("input");return Ut.add(n),n.setAttribute("data-element-id",s),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="checkbox",n.name=e.fieldName,i&&n.setAttribute("checked",!0),n.setAttribute("exportValue",e.exportValue),n.tabIndex=Ae,n.addEventListener("change",r=>{const{name:a,checked:o}=r.target;for(const h of this._getElementsByName(a,s)){const c=o&&h.exportValue===e.exportValue;h.domElement&&(h.domElement.checked=c),t.setValue(h.id,{value:c})}t.setValue(s,{value:o})}),n.addEventListener("resetform",r=>{const a=e.defaultFieldValue||"Off";r.target.checked=a===e.exportValue}),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",r=>{const a={value(o){o.target.checked=o.detail.value!=="Off",t.setValue(s,{value:o.target.checked})}};this._dispatchEventFromSandbox(a,r)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],r=>r.target.checked)),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class $i extends Kt{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.fieldValue===e.buttonValue}).value;if(typeof i=="string"&&(i=i!==e.buttonValue,t.setValue(s,{value:i})),i)for(const r of this._getElementsByName(e.fieldName,s))t.setValue(r.id,{value:!1});const n=document.createElement("input");if(Ut.add(n),n.setAttribute("data-element-id",s),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="radio",n.name=e.fieldName,i&&n.setAttribute("checked",!0),n.tabIndex=Ae,n.addEventListener("change",r=>{const{name:a,checked:o}=r.target;for(const h of this._getElementsByName(a,s))t.setValue(h.id,{value:!1});t.setValue(s,{value:o})}),n.addEventListener("resetform",r=>{const a=e.defaultFieldValue;r.target.checked=a!=null&&a===e.buttonValue}),this.enableScripting&&this.hasJSActions){const r=e.buttonValue;n.addEventListener("updatefromsandbox",a=>{const o={value:h=>{const c=r===h.detail.value;for(const d of this._getElementsByName(h.target.name)){const u=c&&d.id===s;d.domElement&&(d.domElement.checked=u),t.setValue(d.id,{value:u})}}};this._dispatchEventFromSandbox(o,a)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],a=>a.target.checked)}return this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class ca extends Hi{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",s=>{this._dispatchEventFromSandbox({},s)})),t}}class da extends Kt{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,s=t.getValue(e,{value:this.data.fieldValue}),i=document.createElement("select");Ut.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,this._setRequired(i,this.data.required),i.name=this.data.fieldName,i.tabIndex=Ae;let n=this.data.combo&&this.data.options.length>0;this.data.combo||(i.size=this.data.options.length,this.data.multiSelect&&(i.multiple=!0)),i.addEventListener("resetform",c=>{const d=this.data.defaultFieldValue;for(const u of i.options)u.selected=u.value===d});for(const c of this.data.options){const d=document.createElement("option");d.textContent=c.displayValue,d.value=c.exportValue,s.value.includes(c.exportValue)&&(d.setAttribute("selected",!0),n=!1),i.append(d)}let r=null;if(n){const c=document.createElement("option");c.value=" ",c.setAttribute("hidden",!0),c.setAttribute("selected",!0),i.prepend(c),r=()=>{c.remove(),i.removeEventListener("input",r),r=null},i.addEventListener("input",r)}const a=c=>{const d=c?"value":"textContent",{options:u,multiple:p}=i;return p?Array.prototype.filter.call(u,g=>g.selected).map(g=>g[d]):u.selectedIndex===-1?null:u[u.selectedIndex][d]};let o=a(!1);const h=c=>{const d=c.target.options;return Array.prototype.map.call(d,u=>({displayValue:u.textContent,exportValue:u.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",c=>{const d={value(u){r?.();const p=u.detail.value,g=new Set(Array.isArray(p)?p:[p]);for(const f of i.options)f.selected=g.has(f.value);t.setValue(e,{value:a(!0)}),o=a(!1)},multipleSelection(u){i.multiple=!0},remove(u){const p=i.options,g=u.detail.remove;p[g].selected=!1,i.remove(g),p.length>0&&Array.prototype.findIndex.call(p,f=>f.selected)===-1&&(p[0].selected=!0),t.setValue(e,{value:a(!0),items:h(u)}),o=a(!1)},clear(u){for(;i.length!==0;)i.remove(0);t.setValue(e,{value:null,items:[]}),o=a(!1)},insert(u){const{index:p,displayValue:g,exportValue:f}=u.detail.insert,v=i.children[p],m=document.createElement("option");m.textContent=g,m.value=f,v?v.before(m):i.append(m),t.setValue(e,{value:a(!0),items:h(u)}),o=a(!1)},items(u){const{items:p}=u.detail;for(;i.length!==0;)i.remove(0);for(const g of p){const{displayValue:f,exportValue:v}=g,m=document.createElement("option");m.textContent=f,m.value=v,i.append(m)}i.options.length>0&&(i.options[0].selected=!0),t.setValue(e,{value:a(!0),items:h(u)}),o=a(!1)},indices(u){const p=new Set(u.detail.indices);for(const g of u.target.options)g.selected=p.has(g.index);t.setValue(e,{value:a(!0)}),o=a(!1)},editable(u){u.target.disabled=!u.detail.editable}};this._dispatchEventFromSandbox(d,c)}),i.addEventListener("input",c=>{const d=a(!0),u=a(!1);t.setValue(e,{value:d}),c.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:o,change:u,changeEx:d,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(i,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],c=>c.target.value)):i.addEventListener("input",function(c){t.setValue(e,{value:a(!0)})}),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class ps extends Z{constructor(t){const{data:e,elements:s}=t;super(t,{isRenderable:Z._hasPopupData(e)}),this.elements=s,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new ua({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),e=[];for(const s of this.elements)s.popup=t,e.push(s.data.id),s.addHighlightArea();return this.container.setAttribute("aria-controls",e.map(s=>`${_i}${s}`).join(",")),this.container}}class ua{#t=this.#T.bind(this);#e=this.#_.bind(this);#s=this.#v.bind(this);#n=this.#y.bind(this);#o=null;#i=null;#r=null;#h=null;#c=null;#d=null;#p=null;#l=!1;#a=null;#g=null;#m=null;#u=null;#b=null;#f=null;#A=!1;constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:n,contentsObj:r,richText:a,parent:o,rect:h,parentRect:c,open:d}){this.#i=t,this.#b=i,this.#r=r,this.#u=a,this.#d=o,this.#o=e,this.#m=h,this.#p=c,this.#c=s,this.#h=Ci.toDateObject(n),this.trigger=s.flatMap(u=>u.getElementsToTriggerPopup());for(const u of this.trigger)u.addEventListener("click",this.#n),u.addEventListener("mouseenter",this.#s),u.addEventListener("mouseleave",this.#e),u.classList.add("popupTriggerArea");for(const u of s)u.container?.addEventListener("keydown",this.#t);this.#i.hidden=!0,d&&this.#y()}render(){if(this.#a)return;const t=this.#a=document.createElement("div");if(t.className="popup",this.#o){const n=t.style.outlineColor=k.makeHexColor(...this.#o);CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?t.style.backgroundColor=`color-mix(in srgb, ${n} 30%, white)`:t.style.backgroundColor=k.makeHexColor(...this.#o.map(a=>Math.floor(.7*(255-a)+a)))}const e=document.createElement("span");e.className="header";const s=document.createElement("h1");if(e.append(s),{dir:s.dir,str:s.textContent}=this.#b,t.append(e),this.#h){const n=document.createElement("span");n.classList.add("popupDate"),n.setAttribute("data-l10n-id","pdfjs-annotation-date-string"),n.setAttribute("data-l10n-args",JSON.stringify({date:this.#h.toLocaleDateString(),time:this.#h.toLocaleTimeString()})),e.append(n)}const i=this.#w;if(i)Bi.render({xfaHtml:i,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const n=this._formatContents(this.#r);t.append(n)}this.#i.append(t)}get#w(){const t=this.#u,e=this.#r;return!t?.str||e?.str&&e.str!==t.str?null:this.#u.html||null}get#x(){return this.#w?.attributes?.style?.fontSize||0}get#S(){return this.#w?.attributes?.style?.color||null}#C(t){const e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:this.#S,fontSize:this.#x?`calc(${this.#x}px * var(--scale-factor))`:""}};for(const n of t.split(`
5
5
  `))e.push({name:"span",value:n,attributes:i});return s}_formatContents({str:t,dir:e}){const s=document.createElement("p");s.classList.add("popupContent"),s.dir=e;const i=t.split(/(?:\r\n?|\n)/);for(let n=0,r=i.length;n<r;++n){const a=i[n];s.append(document.createTextNode(a)),n<r-1&&s.append(document.createElement("br"))}return s}#T(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&this.#l)&&this.#y()}updateEdited({rect:t,popupContent:e}){this.#f||={contentsObj:this.#r,richText:this.#u},t&&(this.#g=null),e&&(this.#u=this.#C(e),this.#r=null),this.#a?.remove(),this.#a=null}resetEdited(){this.#f&&({contentsObj:this.#r,richText:this.#u}=this.#f,this.#f=null,this.#a?.remove(),this.#a=null,this.#g=null)}#E(){if(this.#g!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:i,pageY:n}}}=this.#d;let r=!!this.#p,a=r?this.#p:this.#m;for(const p of this.#c)if(!a||k.intersect(p.data.rect,a)!==null){a=p.data.rect,r=!0;break}const o=k.normalizeRect([a[0],t[3]-a[1]+t[1],a[2],t[3]-a[3]+t[1]]),h=r?a[2]-a[0]+5:0,c=o[0]+h,d=o[1];this.#g=[100*(c-i)/e,100*(d-n)/s];const{style:u}=this.#i;u.left=`${this.#g[0]}%`,u.top=`${this.#g[1]}%`}#y(){this.#l=!this.#l,this.#l?(this.#v(),this.#i.addEventListener("click",this.#n),this.#i.addEventListener("keydown",this.#t)):(this.#_(),this.#i.removeEventListener("click",this.#n),this.#i.removeEventListener("keydown",this.#t))}#v(){this.#a||this.render(),this.isVisible?this.#l&&this.#i.classList.add("focused"):(this.#E(),this.#i.hidden=!1,this.#i.style.zIndex=parseInt(this.#i.style.zIndex)+1e3)}#_(){this.#i.classList.remove("focused"),!this.#l&&this.isVisible&&(this.#i.hidden=!0,this.#i.style.zIndex=parseInt(this.#i.style.zIndex)-1e3)}forceHide(){this.#A=this.isVisible,this.#A&&(this.#i.hidden=!0)}maybeShow(){this.#A&&(this.#a||this.#v(),this.#A=!1,this.#i.hidden=!1)}get isVisible(){return this.#i.hidden===!1}}class zi extends Z{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=j.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const e of this.textContent){const s=document.createElement("span");s.textContent=e,t.append(s)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}get _isEditable(){return this.data.hasOwnCanvas}}class pa extends Z{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const t=this.data,{width:e,height:s}=It(t.rect),i=this.svgFactory.create(e,s,!0),n=this.#t=this.svgFactory.createElement("svg:line");return n.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),n.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),n.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),n.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),n.setAttribute("stroke-width",t.borderStyle.width||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),i.append(n),this.container.append(i),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class ga extends Z{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const t=this.data,{width:e,height:s}=It(t.rect),i=this.svgFactory.create(e,s,!0),n=t.borderStyle.width,r=this.#t=this.svgFactory.createElement("svg:rect");return r.setAttribute("x",n/2),r.setAttribute("y",n/2),r.setAttribute("width",e-n),r.setAttribute("height",s-n),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),i.append(r),this.container.append(i),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class fa extends Z{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const t=this.data,{width:e,height:s}=It(t.rect),i=this.svgFactory.create(e,s,!0),n=t.borderStyle.width,r=this.#t=this.svgFactory.createElement("svg:ellipse");return r.setAttribute("cx",e/2),r.setAttribute("cy",s/2),r.setAttribute("rx",e/2-n/2),r.setAttribute("ry",s/2-n/2),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),i.append(r),this.container.append(i),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Vi extends Z{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,vertices:e,borderStyle:s,popupRef:i}}=this;if(!e)return this.container;const{width:n,height:r}=It(t),a=this.svgFactory.create(n,r,!0);let o=[];for(let c=0,d=e.length;c<d;c+=2){const u=e[c]-t[0],p=t[3]-e[c+1];o.push(`${u},${p}`)}o=o.join(" ");const h=this.#t=this.svgFactory.createElement(this.svgElementName);return h.setAttribute("points",o),h.setAttribute("stroke-width",s.width||1),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),a.append(h),this.container.append(a),!i&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class ma extends Vi{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class va extends Z{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class Gi extends Z{#t=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=j.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,inkLists:e,borderStyle:s,popupRef:i}}=this,{width:n,height:r}=It(t),a=this.svgFactory.create(n,r,!0);for(const o of e){let h=[];for(let d=0,u=o.length;d<u;d+=2){const p=o[d]-t[0],g=t[3]-o[d+1];h.push(`${p},${g}`)}h=h.join(" ");const c=this.svgFactory.createElement(this.svgElementName);this.#t.push(c),c.setAttribute("points",h),c.setAttribute("stroke-width",s.width||1),c.setAttribute("stroke","transparent"),c.setAttribute("fill","transparent"),!i&&this.hasPopupData&&this._createPopup(),a.append(c)}return this.container.append(a),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class ba extends Z{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this.container}}class Aa extends Z{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class ya extends Z{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class wa extends Z{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class Ui extends Z{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("stampAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class _a extends Z{#t=null;constructor(t){super(t,{isRenderable:!0});const{file:e}=this.data;this.filename=e.filename,this.content=e.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...e})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:t,data:e}=this;let s;e.hasAppearance||e.fillAlpha===0?s=document.createElement("div"):(s=document.createElement("img"),s.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(s.style=`filter: opacity(${Math.round(100*e.fillAlpha)}%);`)),s.addEventListener("dblclick",this.#e.bind(this)),this.#t=s;const{isMac:i}=pt.platform;return t.addEventListener("keydown",n=>{n.key==="Enter"&&(i?n.metaKey:n.ctrlKey)&&this.#e()}),!e.popupRef&&this.hasPopupData?this._createPopup():s.classList.add("popupTriggerArea"),t.append(s),t}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}#e(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}let xa=class{#t=null;#e=null;#s=new Map;constructor({div:l,accessibilityManager:t,annotationCanvasMap:e,annotationEditorUIManager:s,page:i,viewport:n}){this.div=l,this.#t=t,this.#e=e,this.page=i,this.viewport=n,this.zIndex=0,this._annotationEditorUIManager=s}#n(l,t){const e=l.firstChild||l;e.id=`${_i}${t}`,this.div.append(l),this.#t?.moveElementInDOM(this.div,l,e,!1)}async render(l){const{annotations:t}=l,e=this.div;Gt(e,this.viewport);const s=new Map,i={data:null,layer:e,linkService:l.linkService,downloadManager:l.downloadManager,imageResourcesPath:l.imageResourcesPath||"",renderForms:l.renderForms!==!1,svgFactory:new _s,annotationStorage:l.annotationStorage||new Rs,enableScripting:l.enableScripting===!0,hasJSActions:l.hasJSActions,fieldObjects:l.fieldObjects,parent:this,elements:null};for(const n of t){if(n.noHTML)continue;const r=n.annotationType===Ai;if(r){const h=s.get(n.id);if(!h)continue;i.elements=h}else{const{width:h,height:c}=It(n.rect);if(h<=0||c<=0)continue}i.data=n;const a=ra.create(i);if(!a.isRenderable)continue;if(!r&&n.popupRef){const h=s.get(n.popupRef);h?h.push(a):s.set(n.popupRef,[a])}const o=a.render();n.hidden&&(o.style.visibility="hidden"),this.#n(o,n.id),a.annotationEditorType>0&&(this.#s.set(a.data.id,a),this._annotationEditorUIManager?.renderAnnotationElement(a))}this.#o()}update({viewport:l}){const t=this.div;this.viewport=l,Gt(t,{rotation:l.rotation}),this.#o(),t.hidden=!1}#o(){if(!this.#e)return;const l=this.div;for(const[t,e]of this.#e){const s=l.querySelector(`[data-annotation-id="${t}"]`);if(!s)continue;e.className="annotationContent";const{firstChild:i}=s;i?i.nodeName==="CANVAS"?i.replaceWith(e):i.classList.contains("annotationContent")?i.after(e):i.before(e):s.append(e)}this.#e.clear()}getEditableAnnotations(){return Array.from(this.#s.values())}getEditableAnnotation(l){return this.#s.get(l)}};const ke=/\r\n?|\n/g;class it extends P{#t=this.editorDivBlur.bind(this);#e=this.editorDivFocus.bind(this);#s=this.editorDivInput.bind(this);#n=this.editorDivKeydown.bind(this);#o=this.editorDivPaste.bind(this);#i;#r="";#h=`${this.id}-editor`;#c;#d=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=it.prototype,e=n=>n.isEmpty(),s=jt.TRANSLATE_SMALL,i=jt.TRANSLATE_BIG;return z(this,"_keyboardManager",new ve([[["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:[-s,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}]]))}static _type="freetext";static _editorType=j.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.#i=t.color||it._defaultColor||P._defaultLineColor,this.#c=t.fontSize||it._defaultFontSize}static initialize(t,e){P.initialize(t,e,{strings:["pdfjs-free-text-default-content"]});const s=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(s.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case L.FREETEXT_SIZE:it._defaultFontSize=e;break;case L.FREETEXT_COLOR:it._defaultColor=e}}updateParams(t,e){switch(t){case L.FREETEXT_SIZE:this.#p(e);break;case L.FREETEXT_COLOR:this.#l(e)}}static get defaultPropertiesToUpdate(){return[[L.FREETEXT_SIZE,it._defaultFontSize],[L.FREETEXT_COLOR,it._defaultColor||P._defaultLineColor]]}get propertiesToUpdate(){return[[L.FREETEXT_SIZE,this.#c],[L.FREETEXT_COLOR,this.#i]]}#p(t){const e=i=>{this.editorDiv.style.fontSize=`calc(${i}px * var(--scale-factor))`,this.translate(0,-(i-this.#c)*this.parentScale),this.#c=i,this.#g()},s=this.#c;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:L.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#l(t){const e=i=>{this.#i=this.editorDiv.style.color=i},s=this.#i;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:L.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-it._internalPadding*t,-(it._internalPadding+this.#c)*t]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(j.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant");const t=this._uiManager._signal;this.editorDiv.addEventListener("keydown",this.#n,{signal:t}),this.editorDiv.addEventListener("focus",this.#e,{signal:t}),this.editorDiv.addEventListener("blur",this.#t,{signal:t}),this.editorDiv.addEventListener("input",this.#s,{signal:t}),this.editorDiv.addEventListener("paste",this.#o,{signal:t})}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#h),this._isDraggable=!0,this.editorDiv.removeEventListener("keydown",this.#n),this.editorDiv.removeEventListener("focus",this.#e),this.editorDiv.removeEventListener("blur",this.#t),this.editorDiv.removeEventListener("input",this.#s),this.editorDiv.removeEventListener("paste",this.#o),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(){this.width||(this.enableEditMode(),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()}#a(){const t=[];this.editorDiv.normalize();for(const e of this.editorDiv.childNodes)t.push(it.#m(e));return t.join(`
6
6
  `)}#g(){const[t,e]=this.parentDimensions;let s;if(this.isAttachedToDOM)s=this.div.getBoundingClientRect();else{const{currentLayer:i,div:n}=this,r=n.style.display,a=n.classList.contains("hidden");n.classList.remove("hidden"),n.style.display="hidden",i.div.append(this.div),s=n.getBoundingClientRect(),n.remove(),n.style.display=r,n.classList.toggle("hidden",a)}this.rotation%180==this.parentRotation%180?(this.width=s.width/t,this.height=s.height/e):(this.width=s.height/t,this.height=s.width/e),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=this.#r,e=this.#r=this.#a().trimEnd();if(t===e)return;const s=i=>{this.#r=i,i?(this.#u(),this._uiManager.rebuild(this),this.#g()):this.remove()};this.addCommands({cmd:()=>{s(e)},undo:()=>{s(t)},mustExec:!1}),this.#g()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(t){this.enterInEditMode()}keydown(t){t.target===this.div&&t.key==="Enter"&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){it._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let t,e;this.width&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#h),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text"),this.enableEditing(),P._l10nPromise.get("pdfjs-free-text-default-content").then(i=>this.editorDiv?.setAttribute("default-content",i)),this.editorDiv.contentEditable=!0;const{style:s}=this.editorDiv;if(s.fontSize=`calc(${this.#c}px * var(--scale-factor))`,s.color=this.#i,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),Ie(this,this.div,["dblclick","keydown"]),this.width){const[i,n]=this.parentDimensions;if(this.annotationElementId){const{position:r}=this.#d;let[a,o]=this.getInitialTranslation();[a,o]=this.pageTranslationToScreen(a,o);const[h,c]=this.pageDimensions,[d,u]=this.pageTranslation;let p,g;switch(this.rotation){case 0:p=t+(r[0]-d)/h,g=e+this.height-(r[1]-u)/c;break;case 90:p=t+(r[0]-d)/h,g=e-(r[1]-u)/c,[a,o]=[o,-a];break;case 180:p=t-this.width+(r[0]-d)/h,g=e-(r[1]-u)/c,[a,o]=[-a,-o];break;case 270:p=t+(r[0]-d-this.height*c)/h,g=e+(r[1]-u-this.width*h)/c,[a,o]=[-o,a]}this.setAt(p*i,g*n,a,o)}else this.setAt(t*i,e*n,this.width*i,this.height*n);this.#u(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#m(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(ke,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:s}=e;if(s.length===1&&s[0]==="text/plain")return;t.preventDefault();const i=it.#f(e.getData("text")||"").replaceAll(ke,`
@@ -10,4 +10,4 @@ import{L as Ns,_ as _e}from"./zeni-epic-state-BYztznIU.js";import{p as Zt,g as f
10
10
  `)}`,this.#u();const d=new Range;let u=h.reduce((p,g)=>p+g.length,0);for(const{firstChild:p}of this.editorDiv.childNodes)if(p.nodeType===Node.TEXT_NODE){const g=p.nodeValue.length;if(u<=g){d.setStart(p,u),d.setEnd(p,u);break}u-=g}n.removeAllRanges(),n.addRange(d)}#u(){if(this.editorDiv.replaceChildren(),this.#r)for(const t of this.#r.split(`
11
11
  `)){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#b(){return this.#r.replaceAll(" "," ")}static#f(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}static deserialize(t,e,s){let i=null;if(t instanceof zi){const{data:{defaultAppearanceData:{fontSize:r,fontColor:a},rect:o,rotation:h,id:c},textContent:d,textPosition:u,parent:{page:{pageNumber:p}}}=t;if(!d||d.length===0)return null;i=t={annotationType:j.FREETEXT,color:Array.from(a),fontSize:r,value:d.join(`
12
12
  `),position:u,pageIndex:p-1,rect:o.slice(0),rotation:h,id:c,deleted:!1}}const n=super.deserialize(t,e,s);return n.#c=t.fontSize,n.#i=k.makeHexColor(...t.color),n.#r=it.#f(t.value),n.annotationElementId=t.id||null,n.#d=i,n}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return{pageIndex:this.pageIndex,id:this.annotationElementId,deleted:!0};const e=it._internalPadding*this.parentScale,s=this.getRect(e,e),i=P._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#i),n={annotationType:j.FREETEXT,color:i,fontSize:this.#c,value:this.#b(),pageIndex:this.pageIndex,rect:s,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?n:this.annotationElementId&&!this.#A(n)?null:(n.id=this.annotationElementId,n)}#A(t){const{value:e,fontSize:s,color:i,pageIndex:n}=this.#d;return this._hasBeenMoved||t.value!==e||t.fontSize!==s||t.color.some((r,a)=>r!==i[a])||t.pageIndex!==n}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(this.deleted)return e;const{style:s}=e;s.fontSize=`calc(${this.#c}px * var(--scale-factor))`,s.color=this.#i,e.replaceChildren();for(const n of this.#r.split(`
13
- `)){const r=document.createElement("div");r.append(n?document.createTextNode(n):document.createElement("br")),e.append(r)}const i=it._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(i,i),popupContent:this.#r}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class gs{#t;#e=[];#s=[];constructor(t,e=0,s=0,i=!0){let n=1/0,r=-1/0,a=1/0,o=-1/0;const h=1e-4;for(const{x:v,y:m,width:b,height:A}of t){const w=Math.floor((v-e)/h)*h,_=Math.ceil((v+b+e)/h)*h,y=Math.floor((m-e)/h)*h,E=Math.ceil((m+A+e)/h)*h,S=[w,y,E,!0],C=[_,y,E,!1];this.#e.push(S,C),n=Math.min(n,w),r=Math.max(r,_),a=Math.min(a,y),o=Math.max(o,E)}const c=r-n+2*s,d=o-a+2*s,u=n-s,p=a-s,g=this.#e.at(i?-1:-2),f=[g[0],g[2]];for(const v of this.#e){const[m,b,A]=v;v[0]=(m-u)/c,v[1]=(b-p)/d,v[2]=(A-p)/d}this.#t={x:u,y:p,width:c,height:d,lastPoint:f}}getOutlines(){this.#e.sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of this.#e)e[3]?(t.push(...this.#h(e)),this.#i(e)):(this.#r(e),t.push(...this.#h(e)));return this.#n(t)}#n(t){const e=[],s=new Set;for(const r of t){const[a,o,h]=r;e.push([a,o,r],[a,h,r])}e.sort((r,a)=>r[1]-a[1]||r[0]-a[0]);for(let r=0,a=e.length;r<a;r+=2){const o=e[r][2],h=e[r+1][2];o.push(h),h.push(o),s.add(o),s.add(h)}const i=[];let n;for(;s.size>0;){const r=s.values().next().value;let[a,o,h,c,d]=r;s.delete(r);let u=a,p=o;for(n=[a,h],i.push(n);;){let g;if(s.has(c))g=c;else{if(!s.has(d))break;g=d}s.delete(g),[a,o,h,c,d]=g,u!==a&&(n.push(u,p,a,p===o?o:h),u=a),p=p===o?h:o}n.push(u,p)}return new Ea(i,this.#t)}#o(t){const e=this.#s;let s=0,i=e.length-1;for(;s<=i;){const n=s+i>>1,r=e[n][0];if(r===t)return n;r<t?s=n+1:i=n-1}return i+1}#i([,t,e]){const s=this.#o(t);this.#s.splice(s,0,[t,e])}#r([,t,e]){const s=this.#o(t);for(let i=s;i<this.#s.length;i++){const[n,r]=this.#s[i];if(n!==t)break;if(n===t&&r===e)return void this.#s.splice(i,1)}for(let i=s-1;i>=0;i--){const[n,r]=this.#s[i];if(n!==t)break;if(n===t&&r===e)return void this.#s.splice(i,1)}}#h(t){const[e,s,i]=t,n=[[e,s,i]],r=this.#o(i);for(let a=0;a<r;a++){const[o,h]=this.#s[a];for(let c=0,d=n.length;c<d;c++){const[,u,p]=n[c];if(!(h<=u||p<=o))if(u>=o)if(p>h)n[c][1]=h;else{if(d===1)return[];n.splice(c,1),c--,d--}else n[c][2]=o,p>h&&n.push([e,h,p])}}return n}}let qi=class{toSVGPath(){throw new Error("Abstract method `toSVGPath` must be implemented.")}get box(){throw new Error("Abstract getter `box` must be implemented.")}serialize(l,t){throw new Error("Abstract method `serialize` must be implemented.")}get free(){return this instanceof fs}};class Ea extends qi{#t;#e;constructor(t,e){super(),this.#e=t,this.#t=e}toSVGPath(){const t=[];for(const e of this.#e){let[s,i]=e;t.push(`M${s} ${i}`);for(let n=2;n<e.length;n+=2){const r=e[n],a=e[n+1];r===s?(t.push(`V${a}`),i=a):a===i&&(t.push(`H${r}`),s=r)}t.push("Z")}return t.join(" ")}serialize([t,e,s,i],n){const r=[],a=s-t,o=i-e;for(const h of this.#e){const c=new Array(h.length);for(let d=0;d<h.length;d+=2)c[d]=t+h[d]*a,c[d+1]=i-h[d+1]*o;r.push(c)}return r}get box(){return this.#t}}class Vt{#t;#e=[];#s;#n;#o=[];#i=new Float64Array(18);#r;#h;#c;#d;#p;#l;#a=[];static#g=8;static#m=2;static#u=Vt.#g+Vt.#m;constructor({x:t,y:e},s,i,n,r,a=0){this.#t=s,this.#l=n*i,this.#n=r,this.#i.set([NaN,NaN,NaN,NaN,t,e],6),this.#s=a,this.#d=Vt.#g*i,this.#c=Vt.#u*i,this.#p=i,this.#a.push(t,e)}get free(){return!0}isEmpty(){return isNaN(this.#i[8])}#b(){const t=this.#i.subarray(4,6),e=this.#i.subarray(16,18),[s,i,n,r]=this.#t;return[(this.#r+(t[0]-e[0])/2-s)/n,(this.#h+(t[1]-e[1])/2-i)/r,(this.#r+(e[0]-t[0])/2-s)/n,(this.#h+(e[1]-t[1])/2-i)/r]}add({x:t,y:e}){this.#r=t,this.#h=e;const[s,i,n,r]=this.#t;let[a,o,h,c]=this.#i.subarray(8,12);const d=t-h,u=e-c,p=Math.hypot(d,u);if(p<this.#c)return!1;const g=p-this.#d,f=g/p,v=f*d,m=f*u;let b=a,A=o;a=h,o=c,h+=v,c+=m,this.#a?.push(t,e);const w=v/g,_=-m/g*this.#l,y=w*this.#l;return this.#i.set(this.#i.subarray(2,8),0),this.#i.set([h+_,c+y],4),this.#i.set(this.#i.subarray(14,18),12),this.#i.set([h-_,c-y],16),isNaN(this.#i[6])?(this.#o.length===0&&(this.#i.set([a+_,o+y],2),this.#o.push(NaN,NaN,NaN,NaN,(a+_-s)/n,(o+y-i)/r),this.#i.set([a-_,o-y],14),this.#e.push(NaN,NaN,NaN,NaN,(a-_-s)/n,(o-y-i)/r)),this.#i.set([b,A,a,o,h,c],6),!this.isEmpty()):(this.#i.set([b,A,a,o,h,c],6),Math.abs(Math.atan2(A-o,b-a)-Math.atan2(m,v))<Math.PI/2?([a,o,h,c]=this.#i.subarray(2,6),this.#o.push(NaN,NaN,NaN,NaN,((a+h)/2-s)/n,((o+c)/2-i)/r),[a,o,b,A]=this.#i.subarray(14,18),this.#e.push(NaN,NaN,NaN,NaN,((b+a)/2-s)/n,((A+o)/2-i)/r),!0):([b,A,a,o,h,c]=this.#i.subarray(0,6),this.#o.push(((b+5*a)/6-s)/n,((A+5*o)/6-i)/r,((5*a+h)/6-s)/n,((5*o+c)/6-i)/r,((a+h)/2-s)/n,((o+c)/2-i)/r),[h,c,a,o,b,A]=this.#i.subarray(12,18),this.#e.push(((b+5*a)/6-s)/n,((A+5*o)/6-i)/r,((5*a+h)/6-s)/n,((5*o+c)/6-i)/r,((a+h)/2-s)/n,((o+c)/2-i)/r),!0))}toSVGPath(){if(this.isEmpty())return"";const t=this.#o,e=this.#e,s=this.#i.subarray(4,6),i=this.#i.subarray(16,18),[n,r,a,o]=this.#t,[h,c,d,u]=this.#b();if(isNaN(this.#i[6])&&!this.isEmpty())return`M${(this.#i[2]-n)/a} ${(this.#i[3]-r)/o} L${(this.#i[4]-n)/a} ${(this.#i[5]-r)/o} L${h} ${c} L${d} ${u} L${(this.#i[16]-n)/a} ${(this.#i[17]-r)/o} L${(this.#i[14]-n)/a} ${(this.#i[15]-r)/o} Z`;const p=[];p.push(`M${t[4]} ${t[5]}`);for(let g=6;g<t.length;g+=6)isNaN(t[g])?p.push(`L${t[g+4]} ${t[g+5]}`):p.push(`C${t[g]} ${t[g+1]} ${t[g+2]} ${t[g+3]} ${t[g+4]} ${t[g+5]}`);p.push(`L${(s[0]-n)/a} ${(s[1]-r)/o} L${h} ${c} L${d} ${u} L${(i[0]-n)/a} ${(i[1]-r)/o}`);for(let g=e.length-6;g>=6;g-=6)isNaN(e[g])?p.push(`L${e[g+4]} ${e[g+5]}`):p.push(`C${e[g]} ${e[g+1]} ${e[g+2]} ${e[g+3]} ${e[g+4]} ${e[g+5]}`);return p.push(`L${e[4]} ${e[5]} Z`),p.join(" ")}getOutlines(){const t=this.#o,e=this.#e,s=this.#i,i=s.subarray(4,6),n=s.subarray(16,18),[r,a,o,h]=this.#t,c=new Float64Array((this.#a?.length??0)+2);for(let m=0,b=c.length-2;m<b;m+=2)c[m]=(this.#a[m]-r)/o,c[m+1]=(this.#a[m+1]-a)/h;c[c.length-2]=(this.#r-r)/o,c[c.length-1]=(this.#h-a)/h;const[d,u,p,g]=this.#b();if(isNaN(s[6])&&!this.isEmpty()){const m=new Float64Array(36);return m.set([NaN,NaN,NaN,NaN,(s[2]-r)/o,(s[3]-a)/h,NaN,NaN,NaN,NaN,(s[4]-r)/o,(s[5]-a)/h,NaN,NaN,NaN,NaN,d,u,NaN,NaN,NaN,NaN,p,g,NaN,NaN,NaN,NaN,(s[16]-r)/o,(s[17]-a)/h,NaN,NaN,NaN,NaN,(s[14]-r)/o,(s[15]-a)/h],0),new fs(m,c,this.#t,this.#p,this.#s,this.#n)}const f=new Float64Array(this.#o.length+24+this.#e.length);let v=t.length;for(let m=0;m<v;m+=2)isNaN(t[m])?f[m]=f[m+1]=NaN:(f[m]=t[m],f[m+1]=t[m+1]);f.set([NaN,NaN,NaN,NaN,(i[0]-r)/o,(i[1]-a)/h,NaN,NaN,NaN,NaN,d,u,NaN,NaN,NaN,NaN,p,g,NaN,NaN,NaN,NaN,(n[0]-r)/o,(n[1]-a)/h],v),v+=24;for(let m=e.length-6;m>=6;m-=6)for(let b=0;b<6;b+=2)isNaN(e[m+b])?(f[v]=f[v+1]=NaN,v+=2):(f[v]=e[m+b],f[v+1]=e[m+b+1],v+=2);return f.set([NaN,NaN,NaN,NaN,e[4],e[5]],v),new fs(f,c,this.#t,this.#p,this.#s,this.#n)}}class fs extends qi{#t;#e=null;#s;#n;#o;#i;#r;constructor(t,e,s,i,n,r){super(),this.#r=t,this.#o=e,this.#t=s,this.#i=i,this.#s=n,this.#n=r,this.#d(r);const{x:a,y:o,width:h,height:c}=this.#e;for(let d=0,u=t.length;d<u;d+=2)t[d]=(t[d]-a)/h,t[d+1]=(t[d+1]-o)/c;for(let d=0,u=e.length;d<u;d+=2)e[d]=(e[d]-a)/h,e[d+1]=(e[d+1]-o)/c}toSVGPath(){const t=[`M${this.#r[4]} ${this.#r[5]}`];for(let e=6,s=this.#r.length;e<s;e+=6)isNaN(this.#r[e])?t.push(`L${this.#r[e+4]} ${this.#r[e+5]}`):t.push(`C${this.#r[e]} ${this.#r[e+1]} ${this.#r[e+2]} ${this.#r[e+3]} ${this.#r[e+4]} ${this.#r[e+5]}`);return t.push("Z"),t.join(" ")}serialize([t,e,s,i],n){const r=s-t,a=i-e;let o,h;switch(n){case 0:o=this.#h(this.#r,t,i,r,-a),h=this.#h(this.#o,t,i,r,-a);break;case 90:o=this.#c(this.#r,t,e,r,a),h=this.#c(this.#o,t,e,r,a);break;case 180:o=this.#h(this.#r,s,e,-r,a),h=this.#h(this.#o,s,e,-r,a);break;case 270:o=this.#c(this.#r,s,i,-r,-a),h=this.#c(this.#o,s,i,-r,-a)}return{outline:Array.from(o),points:[Array.from(h)]}}#h(t,e,s,i,n){const r=new Float64Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a]*i,r[a+1]=s+t[a+1]*n;return r}#c(t,e,s,i,n){const r=new Float64Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a+1]*i,r[a+1]=s+t[a]*n;return r}#d(t){const e=this.#r;let s=e[4],i=e[5],n=s,r=i,a=s,o=i,h=s,c=i;const d=t?Math.max:Math.min;for(let v=6,m=e.length;v<m;v+=6){if(isNaN(e[v]))n=Math.min(n,e[v+4]),r=Math.min(r,e[v+5]),a=Math.max(a,e[v+4]),o=Math.max(o,e[v+5]),c<e[v+5]?(h=e[v+4],c=e[v+5]):c===e[v+5]&&(h=d(h,e[v+4]));else{const b=k.bezierBoundingBox(s,i,...e.slice(v,v+6));n=Math.min(n,b[0]),r=Math.min(r,b[1]),a=Math.max(a,b[2]),o=Math.max(o,b[3]),c<b[3]?(h=b[2],c=b[3]):c===b[3]&&(h=d(h,b[2]))}s=e[v+4],i=e[v+5]}const u=n-this.#s,p=r-this.#s,g=a-n+2*this.#s,f=o-r+2*this.#s;this.#e={x:u,y:p,width:g,height:f,lastPoint:[h,c]}}get box(){return this.#e}getNewOutline(t,e){const{x:s,y:i,width:n,height:r}=this.#e,[a,o,h,c]=this.#t,d=n*h,u=r*c,p=s*h+a,g=i*c+o,f=new Vt({x:this.#o[0]*d+p,y:this.#o[1]*u+g},this.#t,this.#i,t,this.#n,e??this.#s);for(let v=2;v<this.#o.length;v+=2)f.add({x:this.#o[v]*d+p,y:this.#o[v+1]*u+g});return f.getOutlines()}}class St{#t=this.#m.bind(this);#e=this.#b.bind(this);#s=null;#n=null;#o;#i=null;#r=!1;#h=!1;#c=null;#d;#p=null;#l;static get _keyboardManager(){return z(this,"_keyboardManager",new ve([[["Escape","mac+Escape"],St.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],St.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],St.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],St.prototype._moveToPrevious],[["Home","mac+Home"],St.prototype._moveToBeginning],[["End","mac+End"],St.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){t?(this.#h=!1,this.#l=L.HIGHLIGHT_COLOR,this.#c=t):(this.#h=!0,this.#l=L.HIGHLIGHT_DEFAULT_COLOR),this.#p=t?._uiManager||e,this.#d=this.#p._eventBus,this.#o=t?.color||this.#p?.highlightColors.values().next().value||"#FFFF98"}renderButton(){const t=this.#s=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);const e=this.#p._signal;t.addEventListener("click",this.#u.bind(this),{signal:e}),t.addEventListener("keydown",this.#t,{signal:e});const s=this.#n=document.createElement("span");return s.className="swatch",s.setAttribute("aria-hidden",!0),s.style.backgroundColor=this.#o,t.append(s),t}renderMainDropdown(){const t=this.#i=this.#a();return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}#a(){const t=document.createElement("div"),e=this.#p._signal;t.addEventListener("contextmenu",gt,{signal:e}),t.className="dropdown",t.role="listbox",t.setAttribute("aria-multiselectable",!1),t.setAttribute("aria-orientation","vertical"),t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(const[s,i]of this.#p.highlightColors){const n=document.createElement("button");n.tabIndex="0",n.role="option",n.setAttribute("data-color",i),n.title=s,n.setAttribute("data-l10n-id",`pdfjs-editor-colorpicker-${s}`);const r=document.createElement("span");n.append(r),r.className="swatch",r.style.backgroundColor=i,n.setAttribute("aria-selected",i===this.#o),n.addEventListener("click",this.#g.bind(this,i),{signal:e}),t.append(n)}return t.addEventListener("keydown",this.#t,{signal:e}),t}#g(t,e){e.stopPropagation(),this.#d.dispatch("switchannotationeditorparams",{source:this,type:this.#l,value:t})}_colorSelectFromKeyboard(t){if(t.target===this.#s)return void this.#u(t);const e=t.target.getAttribute("data-color");e&&this.#g(e,t)}_moveToNext(t){this.#f?t.target!==this.#s?t.target.nextSibling?.focus():this.#i.firstChild?.focus():this.#u(t)}_moveToPrevious(t){t.target!==this.#i?.firstChild&&t.target!==this.#s?(this.#f||this.#u(t),t.target.previousSibling?.focus()):this.#f&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){this.#f?this.#i.firstChild?.focus():this.#u(t)}_moveToEnd(t){this.#f?this.#i.lastChild?.focus():this.#u(t)}#m(t){St._keyboardManager.exec(this,t)}#u(t){if(this.#f)return void this.hideDropdown();if(this.#r=t.detail===0,window.addEventListener("pointerdown",this.#e,{signal:this.#p._signal}),this.#i)return void this.#i.classList.remove("hidden");const e=this.#i=this.#a();this.#s.append(e)}#b(t){this.#i?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#i?.classList.add("hidden"),window.removeEventListener("pointerdown",this.#e)}get#f(){return this.#i&&!this.#i.classList.contains("hidden")}_hideDropdownFromKeyboard(){this.#h||(this.#f?(this.hideDropdown(),this.#s.focus({preventScroll:!0,focusVisible:this.#r})):this.#c?.unselect())}updateColor(t){if(this.#n&&(this.#n.style.backgroundColor=t),!this.#i)return;const e=this.#p.highlightColors.values();for(const s of this.#i.children)s.setAttribute("aria-selected",e.next().value===t)}destroy(){this.#s?.remove(),this.#s=null,this.#n=null,this.#i?.remove(),this.#i=null}}class st extends P{#t=null;#e=0;#s;#n=null;#o=null;#i=null;#r=null;#h=0;#c=null;#d=null;#p=null;#l=!1;#a=this.#_.bind(this);#g=null;#m;#u=null;#b="";#f;#A="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _l10nPromise;static _type="highlight";static _editorType=j.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const t=st.prototype;return z(this,"_keyboardManager",new ve([[["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.#f=t.thickness||st._defaultThickness,this.#m=t.opacity||st._defaultOpacity,this.#s=t.boxes||null,this.#A=t.methodOfCreation||"",this.#b=t.text||"",this._isDraggable=!1,t.highlightId>-1?(this.#l=!0,this.#x(t),this.#y()):(this.#t=t.anchorNode,this.#e=t.anchorOffset,this.#r=t.focusNode,this.#h=t.focusOffset,this.#w(),this.#y(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#l?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#f,methodOfCreation:this.#A}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#w(){const t=new gs(this.#s,.001);this.#d=t.getOutlines(),{x:this.x,y:this.y,width:this.width,height:this.height}=this.#d.box;const e=new gs(this.#s,.0025,.001,this._uiManager.direction==="ltr");this.#i=e.getOutlines();const{lastPoint:s}=this.#i.box;this.#g=[(s[0]-this.x)/this.width,(s[1]-this.y)/this.height]}#x({highlightOutlines:t,highlightId:e,clipPathId:s}){if(this.#d=t,this.#i=t.getNewOutline(this.#f/2+1.5,.0025),e>=0)this.#p=e,this.#n=s,this.parent.drawLayer.finalizeLine(e,t),this.#u=this.parent.drawLayer.highlightOutline(this.#i);else if(this.parent){const h=this.parent.viewport.rotation;this.parent.drawLayer.updateLine(this.#p,t),this.parent.drawLayer.updateBox(this.#p,st.#v(this.#d.box,(h-this.rotation+360)%360)),this.parent.drawLayer.updateLine(this.#u,this.#i),this.parent.drawLayer.updateBox(this.#u,st.#v(this.#i.box,h))}const{x:i,y:n,width:r,height:a}=t.box;switch(this.rotation){case 0:this.x=i,this.y=n,this.width=r,this.height=a;break;case 90:{const[h,c]=this.parentDimensions;this.x=n,this.y=1-i,this.width=r*c/h,this.height=a*h/c;break}case 180:this.x=1-i,this.y=1-n,this.width=r,this.height=a;break;case 270:{const[h,c]=this.parentDimensions;this.x=1-n,this.y=i,this.width=r*c/h,this.height=a*h/c;break}}const{lastPoint:o}=this.#i.box;this.#g=[(o[0]-i)/r,(o[1]-n)/a]}static initialize(t,e){P.initialize(t,e),st._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case L.HIGHLIGHT_DEFAULT_COLOR:st._defaultColor=e;break;case L.HIGHLIGHT_THICKNESS:st._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#g}updateParams(t,e){switch(t){case L.HIGHLIGHT_COLOR:this.#S(e);break;case L.HIGHLIGHT_THICKNESS:this.#C(e)}}static get defaultPropertiesToUpdate(){return[[L.HIGHLIGHT_DEFAULT_COLOR,st._defaultColor],[L.HIGHLIGHT_THICKNESS,st._defaultThickness]]}get propertiesToUpdate(){return[[L.HIGHLIGHT_COLOR,this.color||st._defaultColor],[L.HIGHLIGHT_THICKNESS,this.#f||st._defaultThickness],[L.HIGHLIGHT_FREE,this.#l]]}#S(t){const e=i=>{this.color=i,this.parent?.drawLayer.changeColor(this.#p,i),this.#o?.updateColor(i)},s=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:L.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}#C(t){const e=this.#f,s=i=>{this.#f=i,this.#T(i)};this.addCommands({cmd:s.bind(this,t),undo:s.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:L.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}async addEditToolbar(){const t=await super.addEditToolbar();return t?(this._uiManager.highlightColors&&(this.#o=new St({editor:this}),t.addColorPicker(this.#o)),t):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#M())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#M())}onceAdded(){this.parent.addUndoableEditor(this),this.div.focus()}remove(){this.#E(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#y(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#E():t&&(this.#y(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#T(t){if(!this.#l)return;this.#x({highlightOutlines:this.#d.getNewOutline(t/2)}),this.fixAndSetPosition();const[e,s]=this.parentDimensions;this.setDims(this.width*e,this.height*s)}#E(){this.#p!==null&&this.parent&&(this.parent.drawLayer.remove(this.#p),this.#p=null,this.parent.drawLayer.remove(this.#u),this.#u=null)}#y(t=this.parent){this.#p===null&&({id:this.#p,clipPathId:this.#n}=t.drawLayer.highlight(this.#d,this.color,this.#m),this.#u=t.drawLayer.highlightOutline(this.#i),this.#c&&(this.#c.style.clipPath=this.#n))}static#v({x:t,y:e,width:s,height:i},n){switch(n){case 90:return{x:1-e-i,y:t,width:i,height:s};case 180:return{x:1-t-s,y:1-e-i,width:s,height:i};case 270:return{x:e,y:1-t-s,width:i,height:s}}return{x:t,y:e,width:s,height:i}}rotate(t){const{drawLayer:e}=this.parent;let s;this.#l?(t=(t-this.rotation+360)%360,s=st.#v(this.#d.box,t)):s=st.#v(this,t),e.rotate(this.#p,t),e.rotate(this.#u,t),e.updateBox(this.#p,s),e.updateBox(this.#u,st.#v(this.#i.box,t))}render(){if(this.div)return this.div;const t=super.render();this.#b&&(t.setAttribute("aria-label",this.#b),t.setAttribute("role","mark")),this.#l?t.classList.add("free"):this.div.addEventListener("keydown",this.#a,{signal:this._uiManager._signal});const e=this.#c=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#n;const[s,i]=this.parentDimensions;return this.setDims(this.width*s,this.height*i),Ie(this,this.#c,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.parent.drawLayer.addClass(this.#u,"hovered")}pointerleave(){this.parent.drawLayer.removeClass(this.#u,"hovered")}#_(t){st._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#k(!0);break;case 1:case 3:this.#k(!1)}}#k(t){if(!this.#t)return;const e=window.getSelection();t?e.setPosition(this.#t,this.#e):e.setPosition(this.#r,this.#h)}select(){super.select(),this.#u&&(this.parent?.drawLayer.removeClass(this.#u,"hovered"),this.parent?.drawLayer.addClass(this.#u,"selected"))}unselect(){super.unselect(),this.#u&&(this.parent?.drawLayer.removeClass(this.#u,"selected"),this.#l||this.#k(!1))}get _mustFixPosition(){return!this.#l}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.show(this.#p,t),this.parent.drawLayer.show(this.#u,t))}#M(){return this.#l?this.rotation:0}#L(){if(this.#l)return null;const[t,e]=this.pageDimensions,s=this.#s,i=new Float32Array(8*s.length);let n=0;for(const{x:r,y:a,width:o,height:h}of s){const c=r*t,d=(1-a-h)*e;i[n]=i[n+4]=c,i[n+1]=i[n+3]=d,i[n+2]=i[n+6]=c+o*t,i[n+5]=i[n+7]=d+h*e,n+=8}return i}#P(t){return this.#d.serialize(t,this.#M())}static startHighlighting(t,e,{target:s,x:i,y:n}){const{x:r,y:a,width:o,height:h}=s.getBoundingClientRect(),c=f=>{this.#F(t,f)},d=t._signal,u={capture:!0,passive:!1,signal:d},p=f=>{f.preventDefault(),f.stopPropagation()},g=f=>{s.removeEventListener("pointermove",c),window.removeEventListener("blur",g),window.removeEventListener("pointerup",g),window.removeEventListener("pointerdown",p,u),window.removeEventListener("contextmenu",gt),this.#I(t,f)};window.addEventListener("blur",g,{signal:d}),window.addEventListener("pointerup",g,{signal:d}),window.addEventListener("pointerdown",p,u),window.addEventListener("contextmenu",gt,{signal:d}),s.addEventListener("pointermove",c,{signal:d}),this._freeHighlight=new Vt({x:i,y:n},[r,a,o,h],t.scale,this._defaultThickness/2,e,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.highlight(this._freeHighlight,this._defaultColor,this._defaultOpacity,!0)}static#F(t,e){this._freeHighlight.add(e)&&t.drawLayer.updatePath(this._freeHighlightId,this._freeHighlight)}static#I(t,e){this._freeHighlight.isEmpty()?t.drawLayer.removeFreeHighlight(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 deserialize(t,e,s){const i=super.deserialize(t,e,s),{rect:[n,r,a,o],color:h,quadPoints:c}=t;i.color=k.makeHexColor(...h),i.#m=t.opacity;const[d,u]=i.pageDimensions;i.width=(a-n)/d,i.height=(o-r)/u;const p=i.#s=[];for(let g=0;g<c.length;g+=8)p.push({x:(c[4]-a)/d,y:(o-(1-c[g+5]))/u,width:(c[g+2]-c[g])/d,height:(c[g+5]-c[g+1])/u});return i.#w(),i}serialize(t=!1){if(this.isEmpty()||t)return null;const e=this.getRect(0,0),s=P._colorManager.convert(this.color);return{annotationType:j.HIGHLIGHT,color:s,opacity:this.#m,thickness:this.#f,quadPoints:this.#L(),outlines:this.#P(e),pageIndex:this.pageIndex,rect:e,rotation:this.#M(),structTreeParentId:this._structTreeParentId}}static canCreateNewEmptyEditor(){return!1}}class ot extends P{#t=0;#e=0;#s=this.canvasPointermove.bind(this);#n=this.canvasPointerleave.bind(this);#o=this.canvasPointerup.bind(this);#i=this.canvasPointerdown.bind(this);#r=null;#h=new Path2D;#c=!1;#d=!1;#p=!1;#l=null;#a=0;#g=0;#m=null;static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=1;static _type="ink";static _editorType=j.INK;constructor(t){super({...t,name:"inkEditor"}),this.color=t.color||null,this.thickness=t.thickness||null,this.opacity=t.opacity||null,this.paths=[],this.bezierPath2D=[],this.allRawPaths=[],this.currentPath=[],this.scaleFactor=1,this.translationX=this.translationY=0,this.x=0,this.y=0,this._willKeepAspectRatio=!0}static initialize(t,e){P.initialize(t,e)}static updateDefaultParams(t,e){switch(t){case L.INK_THICKNESS:ot._defaultThickness=e;break;case L.INK_COLOR:ot._defaultColor=e;break;case L.INK_OPACITY:ot._defaultOpacity=e/100}}updateParams(t,e){switch(t){case L.INK_THICKNESS:this.#u(e);break;case L.INK_COLOR:this.#b(e);break;case L.INK_OPACITY:this.#f(e)}}static get defaultPropertiesToUpdate(){return[[L.INK_THICKNESS,ot._defaultThickness],[L.INK_COLOR,ot._defaultColor||P._defaultLineColor],[L.INK_OPACITY,Math.round(100*ot._defaultOpacity)]]}get propertiesToUpdate(){return[[L.INK_THICKNESS,this.thickness||ot._defaultThickness],[L.INK_COLOR,this.color||ot._defaultColor||P._defaultLineColor],[L.INK_OPACITY,Math.round(100*(this.opacity??ot._defaultOpacity))]]}#u(t){const e=i=>{this.thickness=i,this.#N()},s=this.thickness;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:L.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})}#b(t){const e=i=>{this.color=i,this.#_()},s=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:L.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})}#f(t){const e=i=>{this.opacity=i,this.#_()};t/=100;const s=this.opacity;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:L.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.canvas||(this.#M(),this.#L()),this.isAttachedToDOM||(this.parent.add(this),this.#P()),this.#N()))}remove(){this.canvas!==null&&(this.isEmpty()||this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,this.#r&&(clearTimeout(this.#r),this.#r=null),this.#l?.disconnect(),this.#l=null,super.remove())}setParent(t){!this.parent&&t?this._uiManager.removeShouldRescale(this):this.parent&&t===null&&this._uiManager.addShouldRescale(this),super.setParent(t)}onScaleChanging(){const[t,e]=this.parentDimensions,s=this.width*t,i=this.height*e;this.setDimensions(s,i)}enableEditMode(){this.#c||this.canvas===null||(super.enableEditMode(),this._isDraggable=!1,this.canvas.addEventListener("pointerdown",this.#i,{signal:this._uiManager._signal}))}disableEditMode(){this.isInEditMode()&&this.canvas!==null&&(super.disableEditMode(),this._isDraggable=!this.isEmpty(),this.div.classList.remove("editing"),this.canvas.removeEventListener("pointerdown",this.#i))}onceAdded(){this._isDraggable=!this.isEmpty()}isEmpty(){return this.paths.length===0||this.paths.length===1&&this.paths[0].length===0}#A(){const{parentRotation:t,parentDimensions:[e,s]}=this;switch(t){case 90:return[0,s,s,e];case 180:return[e,s,e,s];case 270:return[e,0,s,e];default:return[0,0,e,s]}}#w(){const{ctx:t,color:e,opacity:s,thickness:i,parentScale:n,scaleFactor:r}=this;t.lineWidth=i*n/r,t.lineCap="round",t.lineJoin="round",t.miterLimit=10,t.strokeStyle=`${e}${function(a){return Math.round(Math.min(255,Math.max(1,255*a))).toString(16).padStart(2,"0")}(s)}`}#x(t,e){const s=this._uiManager._signal;this.canvas.addEventListener("contextmenu",gt,{signal:s}),this.canvas.addEventListener("pointerleave",this.#n,{signal:s}),this.canvas.addEventListener("pointermove",this.#s,{signal:s}),this.canvas.addEventListener("pointerup",this.#o,{signal:s}),this.canvas.removeEventListener("pointerdown",this.#i),this.isEditing=!0,this.#p||(this.#p=!0,this.#P(),this.thickness||=ot._defaultThickness,this.color||=ot._defaultColor||P._defaultLineColor,this.opacity??=ot._defaultOpacity),this.currentPath.push([t,e]),this.#d=!1,this.#w(),this.#m=()=>{this.#E(),this.#m&&window.requestAnimationFrame(this.#m)},window.requestAnimationFrame(this.#m)}#S(t,e){const[s,i]=this.currentPath.at(-1);if(this.currentPath.length>1&&t===s&&e===i)return;const n=this.currentPath;let r=this.#h;if(n.push([t,e]),this.#d=!0,n.length<=2)return r.moveTo(...n[0]),void r.lineTo(t,e);n.length===3&&(this.#h=r=new Path2D,r.moveTo(...n[0])),this.#y(r,...n.at(-3),...n.at(-2),t,e)}#C(){if(this.currentPath.length===0)return;const t=this.currentPath.at(-1);this.#h.lineTo(...t)}#T(t,e){let s;if(this.#m=null,t=Math.min(Math.max(t,0),this.canvas.width),e=Math.min(Math.max(e,0),this.canvas.height),this.#S(t,e),this.#C(),this.currentPath.length!==1)s=this.#v();else{const r=[t,e];s=[[r,r.slice(),r.slice(),r]]}const i=this.#h,n=this.currentPath;this.currentPath=[],this.#h=new Path2D,this.addCommands({cmd:()=>{this.allRawPaths.push(n),this.paths.push(s),this.bezierPath2D.push(i),this._uiManager.rebuild(this)},undo:()=>{this.allRawPaths.pop(),this.paths.pop(),this.bezierPath2D.pop(),this.paths.length===0?this.remove():(this.canvas||(this.#M(),this.#L()),this.#N())},mustExec:!0})}#E(){if(!this.#d)return;this.#d=!1,Math.ceil(this.thickness*this.parentScale);const t=this.currentPath.slice(-3),e=t.map(n=>n[0]),s=t.map(n=>n[1]);Math.min(...e),Math.max(...e),Math.min(...s),Math.max(...s);const{ctx:i}=this;i.save(),i.clearRect(0,0,this.canvas.width,this.canvas.height);for(const n of this.bezierPath2D)i.stroke(n);i.stroke(this.#h),i.restore()}#y(t,e,s,i,n,r,a){const o=(e+i)/2,h=(s+n)/2,c=(i+r)/2,d=(n+a)/2;t.bezierCurveTo(o+2*(i-o)/3,h+2*(n-h)/3,c+2*(i-c)/3,d+2*(n-d)/3,c,d)}#v(){const t=this.currentPath;if(t.length<=2)return[[t[0],t[0],t.at(-1),t.at(-1)]];const e=[];let s,[i,n]=t[0];for(s=1;s<t.length-2;s++){const[u,p]=t[s],[g,f]=t[s+1],v=(u+g)/2,m=(p+f)/2,b=[i+2*(u-i)/3,n+2*(p-n)/3],A=[v+2*(u-v)/3,m+2*(p-m)/3];e.push([[i,n],b,A,[v,m]]),[i,n]=[v,m]}const[r,a]=t[s],[o,h]=t[s+1],c=[i+2*(r-i)/3,n+2*(a-n)/3],d=[o+2*(r-o)/3,h+2*(a-h)/3];return e.push([[i,n],c,d,[o,h]]),e}#_(){if(this.isEmpty())return void this.#I();this.#w();const{canvas:t,ctx:e}=this;e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height),this.#I();for(const s of this.bezierPath2D)e.stroke(s)}commit(){this.#c||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),this.#c=!0,this.div.classList.add("disabled"),this.#N(!0),this.select(),this.parent.addInkEditorIfNeeded(!0),this.moveInDOM(),this.div.focus({preventScroll:!0}))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),this.enableEditMode())}canvasPointerdown(t){t.button===0&&this.isInEditMode()&&!this.#c&&(this.setInForeground(),t.preventDefault(),this.div.contains(document.activeElement)||this.div.focus({preventScroll:!0}),this.#x(t.offsetX,t.offsetY))}canvasPointermove(t){t.preventDefault(),this.#S(t.offsetX,t.offsetY)}canvasPointerup(t){t.preventDefault(),this.#k(t)}canvasPointerleave(t){this.#k(t)}#k(t){this.canvas.removeEventListener("pointerleave",this.#n),this.canvas.removeEventListener("pointermove",this.#s),this.canvas.removeEventListener("pointerup",this.#o),this.canvas.addEventListener("pointerdown",this.#i,{signal:this._uiManager._signal}),this.#r&&clearTimeout(this.#r),this.#r=setTimeout(()=>{this.#r=null,this.canvas.removeEventListener("contextmenu",gt)},10),this.#T(t.offsetX,t.offsetY),this.addToAnnotationStorage(),this.setInBackground()}#M(){this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=0,this.canvas.className="inkEditorCanvas",this.canvas.setAttribute("data-l10n-id","pdfjs-ink-canvas"),this.div.append(this.canvas),this.ctx=this.canvas.getContext("2d")}#L(){this.#l=new ResizeObserver(t=>{const e=t[0].contentRect;e.width&&e.height&&this.setDimensions(e.width,e.height)}),this.#l.observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{this.#l?.disconnect(),this.#l=null},{once:!0})}get isResizable(){return!this.isEmpty()&&this.#c}render(){if(this.div)return this.div;let t,e;this.width&&(t=this.x,e=this.y),super.render(),this.div.setAttribute("data-l10n-id","pdfjs-ink");const[s,i,n,r]=this.#A();if(this.setAt(s,i,0,0),this.setDims(n,r),this.#M(),this.width){const[a,o]=this.parentDimensions;this.setAspectRatio(this.width*a,this.height*o),this.setAt(t*a,e*o,this.width*a,this.height*o),this.#p=!0,this.#P(),this.setDims(this.width*a,this.height*o),this.#_(),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return this.#L(),this.div}#P(){if(!this.#p)return;const[t,e]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*t),this.canvas.height=Math.ceil(this.height*e),this.#I()}setDimensions(t,e){const s=Math.round(t),i=Math.round(e);if(this.#a===s&&this.#g===i)return;this.#a=s,this.#g=i,this.canvas.style.visibility="hidden";const[n,r]=this.parentDimensions;this.width=t/n,this.height=e/r,this.fixAndSetPosition(),this.#c&&this.#F(t,e),this.#P(),this.#_(),this.canvas.style.visibility="visible",this.fixDims()}#F(t,e){const s=this.#H(),i=(t-s)/this.#e,n=(e-s)/this.#t;this.scaleFactor=Math.min(i,n)}#I(){const t=this.#H()/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+t,this.translationY*this.scaleFactor+t)}static#O(t){const e=new Path2D;for(let s=0,i=t.length;s<i;s++){const[n,r,a,o]=t[s];s===0&&e.moveTo(...n),e.bezierCurveTo(r[0],r[1],a[0],a[1],o[0],o[1])}return e}static#D(t,e,s){const[i,n,r,a]=e;switch(s){case 0:for(let o=0,h=t.length;o<h;o+=2)t[o]+=i,t[o+1]=a-t[o+1];break;case 90:for(let o=0,h=t.length;o<h;o+=2){const c=t[o];t[o]=t[o+1]+i,t[o+1]=c+n}break;case 180:for(let o=0,h=t.length;o<h;o+=2)t[o]=r-t[o],t[o+1]+=n;break;case 270:for(let o=0,h=t.length;o<h;o+=2){const c=t[o];t[o]=r-t[o+1],t[o+1]=a-c}break;default:throw new Error("Invalid rotation")}return t}static#G(t,e,s){const[i,n,r,a]=e;switch(s){case 0:for(let o=0,h=t.length;o<h;o+=2)t[o]-=i,t[o+1]=a-t[o+1];break;case 90:for(let o=0,h=t.length;o<h;o+=2){const c=t[o];t[o]=t[o+1]-n,t[o+1]=c-i}break;case 180:for(let o=0,h=t.length;o<h;o+=2)t[o]=r-t[o],t[o+1]-=n;break;case 270:for(let o=0,h=t.length;o<h;o+=2){const c=t[o];t[o]=a-t[o+1],t[o+1]=r-c}break;default:throw new Error("Invalid rotation")}return t}#U(t,e,s,i){const n=[],r=this.thickness/2,a=t*e+r,o=t*s+r;for(const h of this.paths){const c=[],d=[];for(let u=0,p=h.length;u<p;u++){const[g,f,v,m]=h[u];if(g[0]===m[0]&&g[1]===m[1]&&p===1){const I=t*g[0]+a,M=t*g[1]+o;c.push(I,M),d.push(I,M);break}const b=t*g[0]+a,A=t*g[1]+o,w=t*f[0]+a,_=t*f[1]+o,y=t*v[0]+a,E=t*v[1]+o,S=t*m[0]+a,C=t*m[1]+o;u===0&&(c.push(b,A),d.push(b,A)),c.push(w,_,y,E,S,C),d.push(w,_),u===p-1&&d.push(S,C)}n.push({bezier:ot.#D(c,i,this.rotation),points:ot.#D(d,i,this.rotation)})}return n}#z(){let t=1/0,e=-1/0,s=1/0,i=-1/0;for(const n of this.paths)for(const[r,a,o,h]of n){const c=k.bezierBoundingBox(...r,...a,...o,...h);t=Math.min(t,c[0]),s=Math.min(s,c[1]),e=Math.max(e,c[2]),i=Math.max(i,c[3])}return[t,s,e,i]}#H(){return this.#c?Math.ceil(this.thickness*this.parentScale):0}#N(t=!1){if(this.isEmpty())return;if(!this.#c)return void this.#_();const e=this.#z(),s=this.#H();this.#e=Math.max(P.MIN_SIZE,e[2]-e[0]),this.#t=Math.max(P.MIN_SIZE,e[3]-e[1]);const i=Math.ceil(s+this.#e*this.scaleFactor),n=Math.ceil(s+this.#t*this.scaleFactor),[r,a]=this.parentDimensions;this.width=i/r,this.height=n/a,this.setAspectRatio(i,n);const o=this.translationX,h=this.translationY;this.translationX=-e[0],this.translationY=-e[1],this.#P(),this.#_(),this.#a=i,this.#g=n,this.setDims(i,n);const c=t?s/this.scaleFactor/2:0;this.translate(o-this.translationX-c,h-this.translationY-c)}static deserialize(t,e,s){if(t instanceof Gi)return null;const i=super.deserialize(t,e,s);i.thickness=t.thickness,i.color=k.makeHexColor(...t.color),i.opacity=t.opacity;const[n,r]=i.pageDimensions,a=i.width*n,o=i.height*r,h=i.parentScale,c=t.thickness/2;i.#c=!0,i.#a=Math.round(a),i.#g=Math.round(o);const{paths:d,rect:u,rotation:p}=t;for(let{bezier:f}of d){f=ot.#G(f,u,p);const v=[];i.paths.push(v);let m=h*(f[0]-c),b=h*(f[1]-c);for(let w=2,_=f.length;w<_;w+=6){const y=h*(f[w]-c),E=h*(f[w+1]-c),S=h*(f[w+2]-c),C=h*(f[w+3]-c),I=h*(f[w+4]-c),M=h*(f[w+5]-c);v.push([[m,b],[y,E],[S,C],[I,M]]),m=I,b=M}const A=this.#O(v);i.bezierPath2D.push(A)}const g=i.#z();return i.#e=Math.max(P.MIN_SIZE,g[2]-g[0]),i.#t=Math.max(P.MIN_SIZE,g[3]-g[1]),i.#F(a,o),i}serialize(){if(this.isEmpty())return null;const t=this.getRect(0,0),e=P._colorManager.convert(this.ctx.strokeStyle);return{annotationType:j.INK,color:e,thickness:this.thickness,opacity:this.opacity,paths:this.#U(this.scaleFactor/this.parentScale,this.translationX,this.translationY,t),pageIndex:this.pageIndex,rect:t,rotation:this.rotation,structTreeParentId:this._structTreeParentId}}}class Fs extends P{#t=null;#e=null;#s=null;#n=null;#o=null;#i="";#r=null;#h=null;#c=null;#d=!1;#p=!1;static _type="stamp";static _editorType=j.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#n=t.bitmapUrl,this.#o=t.bitmapFile}static initialize(t,e){P.initialize(t,e)}static get supportedTypes(){return z(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(t=>`image/${t}`))}static get supportedTypesStr(){return z(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,e){e.pasteEditor(j.STAMP,{bitmapFile:t.getAsFile()})}#l(t,e=!1){t?(this.#t=t.bitmap,e||(this.#e=t.id,this.#d=t.isSvg),t.file&&(this.#i=t.file.name),this.#m()):this.remove()}#a(){this.#s=null,this._uiManager.enableWaiting(!1),this.#r&&this.div.focus()}#g(){if(this.#e)return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(this.#e).then(s=>this.#l(s,!0)).finally(()=>this.#a());if(this.#n){const s=this.#n;return this.#n=null,this._uiManager.enableWaiting(!0),void(this.#s=this._uiManager.imageManager.getFromUrl(s).then(i=>this.#l(i)).finally(()=>this.#a()))}if(this.#o){const s=this.#o;return this.#o=null,this._uiManager.enableWaiting(!0),void(this.#s=this._uiManager.imageManager.getFromFile(s).then(i=>this.#l(i)).finally(()=>this.#a()))}const t=document.createElement("input");t.type="file",t.accept=Fs.supportedTypesStr;const e=this._uiManager._signal;this.#s=new Promise(s=>{t.addEventListener("change",async()=>{if(t.files&&t.files.length!==0){this._uiManager.enableWaiting(!0);const i=await this._uiManager.imageManager.getFromFile(t.files[0]);this.#l(i)}else this.remove();s()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),s()},{signal:e})}).finally(()=>this.#a()),t.click()}remove(){this.#e&&(this.#t=null,this._uiManager.imageManager.deleteId(this.#e),this.#r?.remove(),this.#r=null,this.#h?.disconnect(),this.#h=null,this.#c&&(clearTimeout(this.#c),this.#c=null)),super.remove()}rebuild(){this.parent?(super.rebuild(),this.div!==null&&(this.#e&&this.#r===null&&this.#g(),this.isAttachedToDOM||this.parent.add(this))):this.#e&&this.#g()}onceAdded(){this._isDraggable=!0,this.div.focus()}isEmpty(){return!(this.#s||this.#t||this.#n||this.#o||this.#e)}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;if(this.width&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.addAltTextButton(),this.#t?this.#m():this.#g(),this.width){const[s,i]=this.parentDimensions;this.setAt(t*s,e*i,this.width*s,this.height*i)}return this.div}#m(){const{div:t}=this;let{width:e,height:s}=this.#t;const[i,n]=this.pageDimensions,r=.75;if(this.width)e=this.width*i,s=this.height*n;else if(e>r*i||s>r*n){const c=Math.min(r*i/e,r*n/s);e*=c,s*=c}const[a,o]=this.parentDimensions;this.setDims(e*a/i,s*o/n),this._uiManager.enableWaiting(!1);const h=this.#r=document.createElement("canvas");t.append(h),t.hidden=!1,this.#f(e,s),this.#w(),this.#p||(this.parent.addUndoableEditor(this),this.#p=!0),this._reportTelemetry({action:"inserted_image"}),this.#i&&h.setAttribute("aria-label",this.#i)}#u(t,e){const[s,i]=this.parentDimensions;this.width=t/s,this.height=e/i,this.setDims(t,e),this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this.#c!==null&&clearTimeout(this.#c),this.#c=setTimeout(()=>{this.#c=null,this.#f(t,e)},200)}#b(t,e){const{width:s,height:i}=this.#t;let n=s,r=i,a=this.#t;for(;n>2*t||r>2*e;){const o=n,h=r;n>2*t&&(n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2)),r>2*e&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2));const c=new OffscreenCanvas(n,r);c.getContext("2d").drawImage(a,0,0,o,h,0,0,n,r),a=c.transferToImageBitmap()}return a}#f(t,e){t=Math.ceil(t),e=Math.ceil(e);const s=this.#r;if(!s||s.width===t&&s.height===e)return;s.width=t,s.height=e;const i=this.#d?this.#t:this.#b(t,e);if(this._uiManager.hasMLManager&&!this.hasAltText()){const r=new OffscreenCanvas(t,e).getContext("2d");r.drawImage(i,0,0,i.width,i.height,0,0,t,e),this._uiManager.mlGuess({service:"image-to-text",request:{data:r.getImageData(0,0,t,e).data,width:t,height:e,channels:4}}).then(a=>{const o=a?.output||"";this.parent&&o&&!this.hasAltText()&&(this.altTextData={altText:o,decorative:!1})})}const n=s.getContext("2d");n.filter=this._uiManager.hcmFilter,n.drawImage(i,0,0,i.width,i.height,0,0,t,e)}getImageForAltText(){return this.#r}#A(t){if(t){if(this.#d){const s=this._uiManager.imageManager.getSvgUrl(this.#e);if(s)return s}const e=document.createElement("canvas");return{width:e.width,height:e.height}=this.#t,e.getContext("2d").drawImage(this.#t,0,0),e.toDataURL()}if(this.#d){const[e,s]=this.pageDimensions,i=Math.round(this.width*e*ae.PDF_TO_CSS_UNITS),n=Math.round(this.height*s*ae.PDF_TO_CSS_UNITS),r=new OffscreenCanvas(i,n);return r.getContext("2d").drawImage(this.#t,0,0,this.#t.width,this.#t.height,0,0,i,n),r.transferToImageBitmap()}return structuredClone(this.#t)}#w(){this._uiManager._signal&&(this.#h=new ResizeObserver(t=>{const e=t[0].contentRect;e.width&&e.height&&this.#u(e.width,e.height)}),this.#h.observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{this.#h?.disconnect(),this.#h=null},{once:!0}))}static deserialize(t,e,s){if(t instanceof Ui)return null;const i=super.deserialize(t,e,s),{rect:n,bitmapUrl:r,bitmapId:a,isSvg:o,accessibilityData:h}=t;a&&s.imageManager.isValidId(a)?i.#e=a:i.#n=r,i.#d=o;const[c,d]=i.pageDimensions;return i.width=(n[2]-n[0])/c,i.height=(n[3]-n[1])/d,h&&(i.altTextData=h),i}serialize(t=!1,e=null){if(this.isEmpty())return null;const s={annotationType:j.STAMP,bitmapId:this.#e,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#d,structTreeParentId:this._structTreeParentId};if(t)return s.bitmapUrl=this.#A(!0),s.accessibilityData=this.altTextData,s;const{decorative:i,altText:n}=this.altTextData;if(!i&&n&&(s.accessibilityData={type:"Figure",alt:n}),e===null)return s;e.stamps||=new Map;const r=this.#d?(s.rect[2]-s.rect[0])*(s.rect[3]-s.rect[1]):null;if(e.stamps.has(this.#e)){if(this.#d){const a=e.stamps.get(this.#e);r>a.area&&(a.area=r,a.serialized.bitmap.close(),a.serialized.bitmap=this.#A(!1))}}else e.stamps.set(this.#e,{area:r,serialized:s}),s.bitmap=this.#A(!1);return s}}class Pt{#t;#e=!1;#s=null;#n=null;#o=null;#i=null;#r=null;#h=new Map;#c=!1;#d=!1;#p=!1;#l=null;#a;static _initialized=!1;static#g=new Map([it,ot,Fs,st].map(t=>[t._editorType,t]));constructor({uiManager:t,pageIndex:e,div:s,accessibilityManager:i,annotationLayer:n,drawLayer:r,textLayer:a,viewport:o,l10n:h}){const c=[...Pt.#g.values()];if(!Pt._initialized){Pt._initialized=!0;for(const d of c)d.initialize(h,t)}t.registerEditorTypes(c),this.#a=t,this.pageIndex=e,this.div=s,this.#t=i,this.#s=n,this.viewport=o,this.#l=a,this.drawLayer=r,this.#a.addLayer(this)}get isEmpty(){return this.#h.size===0}get isInvisible(){return this.isEmpty&&this.#a.getMode()===j.NONE}updateToolbar(t){this.#a.updateToolbar(t)}updateMode(t=this.#a.getMode()){switch(this.#A(),t){case j.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case j.INK:this.addInkEditorIfNeeded(!1),this.disableTextSelection(),this.togglePointerEvents(!0),this.disableClick();break;case j.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;for(const s of Pt.#g.values())e.toggle(`${s._type}Editing`,t===s._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#l?.div}addInkEditorIfNeeded(t){if(this.#a.getMode()===j.INK){if(!t){for(const e of this.#h.values())if(e.isEmpty())return void e.setInBackground()}this.createAndAddNewEditor({offsetX:0,offsetY:0},!1).setInBackground()}}setEditingState(t){this.#a.setEditingState(t)}addCommands(t){this.#a.addCommands(t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#s?.div.classList.toggle("disabled",!t)}enable(){this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const s of this.#h.values())s.enableEditing(),s.show(!0),s.annotationElementId&&(this.#a.removeChangedExistingAnnotation(s),t.add(s.annotationElementId));if(!this.#s)return;const e=this.#s.getEditableAnnotations();for(const s of e){if(s.hide(),this.#a.isDeletedAnnotationElement(s.data.id)||t.has(s.data.id))continue;const i=this.deserialize(s);i&&(this.addOrRebuild(i),i.enableEditing())}}disable(){this.#p=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);const t=new Map,e=new Map;for(const i of this.#h.values())i.disableEditing(),i.annotationElementId&&(i.serialize()===null?(e.set(i.annotationElementId,i),this.getEditableAnnotation(i.annotationElementId)?.show(),i.remove()):t.set(i.annotationElementId,i));if(this.#s){const i=this.#s.getEditableAnnotations();for(const n of i){const{id:r}=n.data;if(this.#a.isDeletedAnnotationElement(r))continue;let a=e.get(r);a?(a.resetAnnotationElement(n),a.show(!1),n.show()):(a=t.get(r),a&&(this.#a.addChangedExistingAnnotation(a),a.renderAnnotationElement(n),a.show(!1)),n.show())}}this.#A(),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const i of Pt.#g.values())s.remove(`${i._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#p=!1}getEditableAnnotation(t){return this.#s?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#a.getActive()!==t&&this.#a.setActiveEditor(t)}enableTextSelection(){this.div.tabIndex=-1,this.#l?.div&&!this.#i&&(this.#i=this.#m.bind(this),this.#l.div.addEventListener("pointerdown",this.#i,{signal:this.#a._signal}),this.#l.div.classList.add("highlighting"))}disableTextSelection(){this.div.tabIndex=0,this.#l?.div&&this.#i&&(this.#l.div.removeEventListener("pointerdown",this.#i),this.#i=null,this.#l.div.classList.remove("highlighting"))}#m(t){if(this.#a.unselectAll(),t.target===this.#l.div){const{isMac:e}=pt.platform;if(t.button!==0||t.ctrlKey&&e)return;this.#a.showAllEditors("highlight",!0,!0),this.#l.div.classList.add("free"),st.startHighlighting(this,this.#a.direction==="ltr",t),this.#l.div.addEventListener("pointerup",()=>{this.#l.div.classList.remove("free")},{once:!0,signal:this.#a._signal}),t.preventDefault()}}enableClick(){if(this.#o)return;const t=this.#a._signal;this.#o=this.pointerdown.bind(this),this.#n=this.pointerup.bind(this),this.div.addEventListener("pointerdown",this.#o,{signal:t}),this.div.addEventListener("pointerup",this.#n,{signal:t})}disableClick(){this.#o&&(this.div.removeEventListener("pointerdown",this.#o),this.div.removeEventListener("pointerup",this.#n),this.#o=null,this.#n=null)}attach(t){this.#h.set(t.id,t);const{annotationElementId:e}=t;e&&this.#a.isDeletedAnnotationElement(e)&&this.#a.removeDeletedAnnotationElement(t)}detach(t){this.#h.delete(t.id),this.#t?.removePointerInTextLayer(t.contentDiv),!this.#p&&t.annotationElementId&&this.#a.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#a.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1,this.#d||this.addInkEditorIfNeeded(!1)}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#a.addDeletedAnnotationElement(t.annotationElementId),P.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.#a.addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(),this.#a.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!this.#r&&(t._focusEventsAllowed=!1,this.#r=setTimeout(()=>{this.#r=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#a._signal}),e.focus())},0)),t._structTreeParentId=this.#t?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getNextId(){return this.#a.getId()}get#u(){return Pt.#g.get(this.#a.getMode())}get _signal(){return this.#a._signal}#b(t){const e=this.#u;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#u?.canCreateNewEmptyEditor()}pasteEditor(t,e){this.#a.updateToolbar(t),this.#a.updateMode(t);const{offsetX:s,offsetY:i}=this.#f(),n=this.getNextId(),r=this.#b({parent:this,id:n,x:s,y:i,uiManager:this.#a,isCentered:!0,...e});r&&this.add(r)}deserialize(t){return Pt.#g.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#a)||null}createAndAddNewEditor(t,e,s={}){const i=this.getNextId(),n=this.#b({parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:this.#a,isCentered:e,...s});return n&&this.add(n),n}#f(){const{x:t,y:e,width:s,height:i}=this.div.getBoundingClientRect(),n=Math.max(0,t),r=Math.max(0,e),a=(n+Math.min(window.innerWidth,t+s))/2-t,o=(r+Math.min(window.innerHeight,e+i))/2-e,[h,c]=this.viewport.rotation%180==0?[a,o]:[o,a];return{offsetX:h,offsetY:c}}addNewEditor(){this.createAndAddNewEditor(this.#f(),!0)}setSelected(t){this.#a.setSelected(t)}toggleSelected(t){this.#a.toggleSelected(t)}isSelected(t){return this.#a.isSelected(t)}unselect(t){this.#a.unselect(t)}pointerup(t){const{isMac:e}=pt.platform;t.button!==0||t.ctrlKey&&e||t.target===this.div&&this.#c&&(this.#c=!1,this.#e?this.#a.getMode()!==j.STAMP?this.createAndAddNewEditor(t,!1):this.#a.unselectAll():this.#e=!0)}pointerdown(t){if(this.#a.getMode()===j.HIGHLIGHT&&this.enableTextSelection(),this.#c)return void(this.#c=!1);const{isMac:e}=pt.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;this.#c=!0;const s=this.#a.getActive();this.#e=!s||s.isEmpty()}findNewParent(t,e,s){const i=this.#a.findParent(e,s);return i!==null&&i!==this&&(i.changeParent(t),!0)}destroy(){this.#a.getActive()?.parent===this&&(this.#a.commitOrRemove(),this.#a.setActiveEditor(null)),this.#r&&(clearTimeout(this.#r),this.#r=null);for(const t of this.#h.values())this.#t?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#h.clear(),this.#a.removeLayer(this)}#A(){this.#d=!0;for(const t of this.#h.values())t.isEmpty()&&t.remove();this.#d=!1}render({viewport:t}){this.viewport=t,Gt(this.div,t);for(const e of this.#a.getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){this.#a.commitOrRemove(),this.#A();const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,Gt(this.div,{rotation:s}),e!==s)for(const i of this.#h.values())i.rotate(s);this.addInkEditorIfNeeded(!1)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#a.viewParameters.realScale}}class ct{#t=null;#e=0;#s=new Map;#n=new Map;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(this.#t){if(this.#t!==t){if(this.#s.size>0)for(const e of this.#s.values())e.remove(),t.append(e);this.#t=t}}else this.#t=t}static get _svgFactory(){return z(this,"_svgFactory",new _s)}static#o(t,{x:e=0,y:s=0,width:i=1,height:n=1}={}){const{style:r}=t;r.top=100*s+"%",r.left=100*e+"%",r.width=100*i+"%",r.height=100*n+"%"}#i(t){const e=ct._svgFactory.create(1,1,!0);return this.#t.append(e),e.setAttribute("aria-hidden",!0),ct.#o(e,t),e}#r(t,e){const s=ct._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const n=ct._svgFactory.createElement("use");return s.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),i}highlight(t,e,s,i=!1){const n=this.#e++,r=this.#i(t.box);r.classList.add("highlight"),t.free&&r.classList.add("free");const a=ct._svgFactory.createElement("defs");r.append(a);const o=ct._svgFactory.createElement("path");a.append(o);const h=`path_p${this.pageIndex}_${n}`;o.setAttribute("id",h),o.setAttribute("d",t.toSVGPath()),i&&this.#n.set(n,o);const c=this.#r(a,h),d=ct._svgFactory.createElement("use");return r.append(d),r.setAttribute("fill",e),r.setAttribute("fill-opacity",s),d.setAttribute("href",`#${h}`),this.#s.set(n,r),{id:n,clipPathId:`url(#${c})`}}highlightOutline(t){const e=this.#e++,s=this.#i(t.box);s.classList.add("highlightOutline");const i=ct._svgFactory.createElement("defs");s.append(i);const n=ct._svgFactory.createElement("path");i.append(n);const r=`path_p${this.pageIndex}_${e}`;let a;if(n.setAttribute("id",r),n.setAttribute("d",t.toSVGPath()),n.setAttribute("vector-effect","non-scaling-stroke"),t.free){s.classList.add("free");const c=ct._svgFactory.createElement("mask");i.append(c),a=`mask_p${this.pageIndex}_${e}`,c.setAttribute("id",a),c.setAttribute("maskUnits","objectBoundingBox");const d=ct._svgFactory.createElement("rect");c.append(d),d.setAttribute("width","1"),d.setAttribute("height","1"),d.setAttribute("fill","white");const u=ct._svgFactory.createElement("use");c.append(u),u.setAttribute("href",`#${r}`),u.setAttribute("stroke","none"),u.setAttribute("fill","black"),u.setAttribute("fill-rule","nonzero"),u.classList.add("mask")}const o=ct._svgFactory.createElement("use");s.append(o),o.setAttribute("href",`#${r}`),a&&o.setAttribute("mask",`url(#${a})`);const h=o.cloneNode();return s.append(h),o.classList.add("mainOutline"),h.classList.add("secondaryOutline"),this.#s.set(e,s),e}finalizeLine(t,e){const s=this.#n.get(t);this.#n.delete(t),this.updateBox(t,e.box),s.setAttribute("d",e.toSVGPath())}updateLine(t,e){this.#s.get(t).firstChild.firstChild.setAttribute("d",e.toSVGPath())}removeFreeHighlight(t){this.remove(t),this.#n.delete(t)}updatePath(t,e){this.#n.get(t).setAttribute("d",e.toSVGPath())}updateBox(t,e){ct.#o(this.#s.get(t),e)}show(t,e){this.#s.get(t).classList.toggle("hidden",!e)}rotate(t,e){this.#s.get(t).setAttribute("data-main-rotation",e)}changeColor(t,e){this.#s.get(t).setAttribute("fill",e)}changeOpacity(t,e){this.#s.get(t).setAttribute("fill-opacity",e)}addClass(t,e){this.#s.get(t).classList.add(e)}removeClass(t,e){this.#s.get(t).classList.remove(e)}remove(t){this.#t!==null&&(this.#s.get(t).remove(),this.#s.delete(t))}destroy(){this.#t=null;for(const t of this.#s.values())t.remove();this.#s.clear()}}var Sa=T.AbortException,Ca=T.AnnotationEditorLayer,ka=T.AnnotationEditorParamsType,Ma=T.AnnotationEditorType,Ra=T.AnnotationEditorUIManager,Wi=T.AnnotationLayer,Xi=T.AnnotationMode,Ta=T.CMapCompressionType,Pa=T.ColorPicker,La=T.DOMSVGFactory,Ia=T.DrawLayer,Da=T.FeatureTest,Ki=T.GlobalWorkerOptions,Fa=T.ImageKind,Oa=T.InvalidPDFException,Na=T.MissingPDFException,ja=T.OPS,Ba=T.Outliner,Ha=T.PDFDataRangeTransport,$a=T.PDFDateString,za=T.PDFWorker,Va=T.PasswordResponses,Ga=T.PermissionFlag,Ua=T.PixelsPerInch,qa=T.RenderingCancelledException,Yi=T.TextLayer,Wa=T.UnexpectedResponseException,Xa=T.Util,Ka=T.VerbosityLevel,Ya=T.XfaLayer,Qa=T.build,Ja=T.createValidAbsoluteUrl,Za=T.fetchData,Qi=T.getDocument,to=T.getFilenameFromUrl,eo=T.getPdfFilenameFromUrl,so=T.getXfaPageViewport,io=T.isDataScheme,no=T.isPdfFile,ro=T.noContextMenu,ao=T.normalizeUnicode,oo=T.renderTextLayer,ho=T.setLayerDimensions,lo=T.shadow,co=T.updateTextLayer,uo=T.version;const Ji=Object.freeze(Object.defineProperty({__proto__:null,AbortException:Sa,AnnotationEditorLayer:Ca,AnnotationEditorParamsType:ka,AnnotationEditorType:Ma,AnnotationEditorUIManager:Ra,AnnotationLayer:Wi,AnnotationMode:Xi,CMapCompressionType:Ta,ColorPicker:Pa,DOMSVGFactory:La,DrawLayer:Ia,FeatureTest:Da,GlobalWorkerOptions:Ki,ImageKind:Fa,InvalidPDFException:Oa,MissingPDFException:Na,OPS:ja,Outliner:Ba,PDFDataRangeTransport:Ha,PDFDateString:$a,PDFWorker:za,PasswordResponses:Va,PermissionFlag:Ga,PixelsPerInch:Ua,RenderingCancelledException:qa,TextLayer:Yi,UnexpectedResponseException:Wa,Util:Xa,VerbosityLevel:Ka,XfaLayer:Ya,build:Qa,createValidAbsoluteUrl:Ja,fetchData:Za,getDocument:Qi,getFilenameFromUrl:to,getPdfFilenameFromUrl:eo,getXfaPageViewport:so,isDataScheme:io,isPdfFile:no,noContextMenu:ro,normalizeUnicode:ao,renderTextLayer:oo,setLayerDimensions:ho,shadow:lo,updateTextLayer:co,version:uo},Symbol.toStringTag,{value:"Module"}));var ri,ai,at=function(l,t,e){if(e||arguments.length===2)for(var s,i=0,n=t.length;i<n;i++)!s&&i in t||(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return l.concat(s||Array.prototype.slice.call(t))},po=at(at(at(at(at(at(at(at(at(at(at(at(at(at(at(at(at(at([],["onCopy","onCut","onPaste"],!0),["onCompositionEnd","onCompositionStart","onCompositionUpdate"],!0),["onFocus","onBlur"],!0),["onInput","onInvalid","onReset","onSubmit"],!0),["onLoad","onError"],!0),["onKeyDown","onKeyPress","onKeyUp"],!0),["onAbort","onCanPlay","onCanPlayThrough","onDurationChange","onEmptied","onEncrypted","onEnded","onError","onLoadedData","onLoadedMetadata","onLoadStart","onPause","onPlay","onPlaying","onProgress","onRateChange","onSeeked","onSeeking","onStalled","onSuspend","onTimeUpdate","onVolumeChange","onWaiting"],!0),["onClick","onContextMenu","onDoubleClick","onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseOut","onMouseOver","onMouseUp"],!0),["onDrag","onDragEnd","onDragEnter","onDragExit","onDragLeave","onDragOver","onDragStart","onDrop"],!0),["onSelect"],!0),["onTouchCancel","onTouchEnd","onTouchMove","onTouchStart"],!0),["onPointerDown","onPointerMove","onPointerUp","onPointerCancel","onGotPointerCapture","onLostPointerCapture","onPointerEnter","onPointerLeave","onPointerOver","onPointerOut"],!0),["onScroll"],!0),["onWheel"],!0),["onAnimationStart","onAnimationEnd","onAnimationIteration"],!0),["onTransitionEnd"],!0),["onChange"],!0),["onToggle"],!0);function Os(l,t){var e={};return po.forEach(function(s){var i=l[s];i&&(e[s]=t?function(n){return i(n,t(s))}:i)}),e}function oe(l){var t=!1;return{promise:new Promise(function(e,s){l.then(function(i){return!t&&e(i)}).catch(function(i){return!t&&s(i)})}),cancel:function(){t=!0}}}const ht=fn(ai?ri:(ai=1,ri=function(){}));var oi=Object.prototype.hasOwnProperty;function hi(l,t,e){for(e of l.keys())if(se(e,t))return e}function se(l,t){var e,s,i;if(l===t)return!0;if(l&&t&&(e=l.constructor)===t.constructor){if(e===Date)return l.getTime()===t.getTime();if(e===RegExp)return l.toString()===t.toString();if(e===Array){if((s=l.length)===t.length)for(;s--&&se(l[s],t[s]););return s===-1}if(e===Set){if(l.size!==t.size)return!1;for(s of l)if((i=s)&&typeof i=="object"&&!(i=hi(t,i))||!t.has(i))return!1;return!0}if(e===Map){if(l.size!==t.size)return!1;for(s of l)if((i=s[0])&&typeof i=="object"&&!(i=hi(t,i))||!se(s[1],t.get(i)))return!1;return!0}if(e===ArrayBuffer)l=new Uint8Array(l),t=new Uint8Array(t);else if(e===DataView){if((s=l.byteLength)===t.byteLength)for(;s--&&l.getInt8(s)===t.getInt8(s););return s===-1}if(ArrayBuffer.isView(l)){if((s=l.byteLength)===t.byteLength)for(;s--&&l[s]===t[s];);return s===-1}if(!e||typeof l=="object"){for(e in s=0,l)if(oi.call(l,e)&&++s&&!oi.call(t,e)||!(e in t)||!se(l[e],t[e]))return!1;return Object.keys(t).length===s}}return l!=l&&t!=t}const Zi=x.createContext(null);function ie({children:l,type:t}){return G.jsx("div",{className:`react-pdf__message react-pdf__message--${t}`,children:l})}class go{constructor(){this.externalLinkEnabled=!0,this.externalLinkRel=void 0,this.externalLinkTarget=void 0,this.isInPresentationMode=!1,this.pdfDocument=void 0,this.pdfViewer=void 0}setDocument(t){this.pdfDocument=t}setViewer(t){this.pdfViewer=t}setExternalLinkRel(t){this.externalLinkRel=t}setExternalLinkTarget(t){this.externalLinkTarget=t}setHistory(){}get pagesCount(){return this.pdfDocument?this.pdfDocument.numPages:0}get page(){return $(this.pdfViewer),this.pdfViewer.currentPageNumber||0}set page(t){$(this.pdfViewer),this.pdfViewer.currentPageNumber=t}get rotation(){return 0}set rotation(t){}goToDestination(t){return new Promise(e=>{$(this.pdfDocument),$(t),typeof t=="string"?this.pdfDocument.getDestination(t).then(e):Array.isArray(t)?e(t):t.then(e)}).then(e=>{$(Array.isArray(e));const s=e[0];new Promise(i=>{$(this.pdfDocument),s instanceof Object?this.pdfDocument.getPageIndex(s).then(n=>{i(n)}).catch(()=>{$(!1)}):typeof s=="number"?i(s):$(!1)}).then(i=>{const n=i+1;$(this.pdfViewer),$(n>=1&&n<=this.pagesCount),this.pdfViewer.scrollPageIntoView({dest:e,pageIndex:i,pageNumber:n})})})}navigateTo(t){this.goToDestination(t)}goToPage(t){const e=t-1;$(this.pdfViewer),$(t>=1&&t<=this.pagesCount),this.pdfViewer.scrollPageIntoView({pageIndex:e,pageNumber:t})}addLinkAttributes(t,e,s){t.href=e,t.rel=this.externalLinkRel||"noopener noreferrer nofollow",t.target=s?"_blank":this.externalLinkTarget||""}getDestinationHash(){return"#"}getAnchorUrl(){return"#"}setHash(){}executeNamedAction(){}cachePageRef(){}isPageVisible(){return!0}isPageCached(){return!0}executeSetOCGState(){}}const ms={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},Oe=typeof window<"u",tn=Oe&&window.location.protocol==="file:";function en(l){return l!==void 0}function Ct(l){return en(l)&&l!==null}function vs(l){return function(t){return typeof t=="string"}(l)&&/^data:/.test(l)}function li(l){$(vs(l));const[t="",e=""]=l.split(",");return t.split(";").indexOf("base64")!==-1?atob(e):unescape(e)}function fo(){return Oe&&window.devicePixelRatio||1}const sn="On Chromium based browsers, you can use --allow-file-access-from-files flag for debugging purposes.";function ci(){ht(!tn,`Loading PDF as base64 strings/URLs may not work on protocols other than HTTP/HTTPS. ${sn}`)}function Bt(l){l?.cancel&&l.cancel()}function bs(l,t){return Object.defineProperty(l,"width",{get(){return this.view[2]*t},configurable:!0}),Object.defineProperty(l,"height",{get(){return this.view[3]*t},configurable:!0}),Object.defineProperty(l,"originalWidth",{get(){return this.view[2]},configurable:!0}),Object.defineProperty(l,"originalHeight",{get(){return this.view[3]},configurable:!0}),l}function mo(l,t){switch(t.type){case"RESOLVE":return{value:t.value,error:void 0};case"REJECT":return{value:!1,error:t.error};case"RESET":return{value:void 0,error:void 0};default:return l}}function qt(){return x.useReducer(mo,{value:void 0,error:void 0})}var vo=function(l,t,e,s){return new(e||(e=Promise))(function(i,n){function r(h){try{o(s.next(h))}catch(c){n(c)}}function a(h){try{o(s.throw(h))}catch(c){n(c)}}function o(h){var c;h.done?i(h.value):(c=h.value,c instanceof e?c:new e(function(d){d(c)})).then(r,a)}o((s=s.apply(l,t||[])).next())})},di=function(l,t){var e={};for(var s in l)Object.prototype.hasOwnProperty.call(l,s)&&t.indexOf(s)<0&&(e[s]=l[s]);if(l!=null&&typeof Object.getOwnPropertySymbols=="function"){var i=0;for(s=Object.getOwnPropertySymbols(l);i<s.length;i++)t.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(l,s[i])&&(e[s[i]]=l[s[i]])}return e};const{PDFDataRangeTransport:bo}=Ji,Ao=(l,t)=>{switch(t){case ms.NEED_PASSWORD:l(prompt("Enter the password to open this PDF file."));break;case ms.INCORRECT_PASSWORD:l(prompt("Invalid password. Please try again."));break}};function ui(l){return typeof l=="object"&&l!==null&&("data"in l||"range"in l||"url"in l)}const yo=x.forwardRef(function(l,t){var{children:e,className:s,error:i="Failed to load PDF file.",externalLinkRel:n,externalLinkTarget:r,file:a,inputRef:o,imageResourcesPath:h,loading:c="Loading PDF…",noData:d="No PDF file specified.",onItemClick:u,onLoadError:p,onLoadProgress:g,onLoadSuccess:f,onPassword:v=Ao,onSourceError:m,onSourceSuccess:b,options:A,renderMode:w,rotate:_}=l,y=di(l,["children","className","error","externalLinkRel","externalLinkTarget","file","inputRef","imageResourcesPath","loading","noData","onItemClick","onLoadError","onLoadProgress","onLoadSuccess","onPassword","onSourceError","onSourceSuccess","options","renderMode","rotate"]);const[E,S]=qt(),{value:C,error:I}=E,[M,W]=qt(),{value:D,error:B}=M,U=x.useRef(new go),Y=x.useRef([]),J=x.useRef(void 0),R=x.useRef(void 0);a&&a!==J.current&&ui(a)&&(ht(!se(a,J.current),`File prop passed to <Document /> changed, but it's equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "file" prop.`),J.current=a),A&&A!==R.current&&(ht(!se(A,R.current),`Options prop passed to <Document /> changed, but it's equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "options" prop.`),R.current=A);const F=x.useRef({scrollPageIntoView:X=>{const{dest:N,pageNumber:V,pageIndex:lt=V-1}=X;if(u)return void u({dest:N,pageIndex:lt,pageNumber:V});const rt=Y.current[lt];rt?rt.scrollIntoView():ht(!1,`An internal link leading to page ${V} was clicked, but neither <Document> was provided with onItemClick nor it was able to find the page within itself. Either provide onItemClick to <Document> and handle navigating by yourself or ensure that all pages are rendered within <Document>.`)}});x.useImperativeHandle(t,()=>({linkService:U,pages:Y,viewer:F}),[]),x.useEffect(function(){S({type:"RESET"})},[a,S]);const _t=x.useCallback(()=>vo(this,void 0,void 0,function*(){if(!a)return null;if(typeof a=="string")return vs(a)?{data:li(a)}:(ci(),{url:a});if(a instanceof bo)return{range:a};if(a instanceof ArrayBuffer)return{data:a};if(Oe&&function(X){return $(Oe),X instanceof Blob}(a))return{data:yield function(N){return new Promise((V,lt)=>{const rt=new FileReader;rt.onload=()=>{if(!rt.result)return lt(new Error("Error while reading a file."));V(rt.result)},rt.onerror=Q=>{if(!Q.target)return lt(new Error("Error while reading a file."));const{error:Mt}=Q.target;if(!Mt)return lt(new Error("Error while reading a file."));switch(Mt.code){case Mt.NOT_FOUND_ERR:return lt(new Error("Error while reading a file: File not found."));case Mt.SECURITY_ERR:return lt(new Error("Error while reading a file: Security error."));case Mt.ABORT_ERR:return lt(new Error("Error while reading a file: Aborted."));default:return lt(new Error("Error while reading a file."))}},rt.readAsArrayBuffer(N)})}(a)};if($(typeof a=="object"),$(ui(a)),"url"in a&&typeof a.url=="string"){if(vs(a.url)){const{url:X}=a,N=di(a,["url"]),V=li(X);return Object.assign({data:V},N)}ci()}return a}),[a]);x.useEffect(()=>{const X=oe(_t());return X.promise.then(N=>{S({type:"RESOLVE",value:N})}).catch(N=>{S({type:"REJECT",error:N})}),()=>{Bt(X)}},[_t,S]),x.useEffect(()=>{C!==void 0&&(C!==!1?b&&b():I&&(ht(!1,I.toString()),m&&m(I)))},[C]),x.useEffect(function(){W({type:"RESET"})},[W,C]),x.useEffect(function(){if(!C)return;const X=A?Object.assign(Object.assign({},C),A):C,N=Qi(X);g&&(N.onProgress=g),v&&(N.onPassword=v);const V=N,lt=V.promise.then(rt=>{W({type:"RESOLVE",value:rt})}).catch(rt=>{V.destroyed||W({type:"REJECT",error:rt})});return()=>{lt.finally(()=>V.destroy())}},[A,W,C]),x.useEffect(()=>{D!==void 0&&(D!==!1?D&&(f&&f(D),Y.current=new Array(D.numPages),U.current.setDocument(D)):B&&(ht(!1,B.toString()),p&&p(B)))},[D]),x.useEffect(function(){U.current.setViewer(F.current),U.current.setExternalLinkRel(n),U.current.setExternalLinkTarget(r)},[n,r]);const At=x.useCallback((X,N)=>{Y.current[X]=N},[]),tt=x.useCallback(X=>{delete Y.current[X]},[]),et=x.useMemo(()=>({imageResourcesPath:h,linkService:U.current,onItemClick:u,pdf:D,registerPage:At,renderMode:w,rotate:_,unregisterPage:tt}),[h,u,D,At,w,_,tt]),H=x.useMemo(()=>Os(y,()=>D),[y,D]);return G.jsx("div",Object.assign({className:re("react-pdf__Document",s),ref:o,style:{"--scale-factor":"1"}},H,{children:a?D==null?G.jsx(ie,{type:"loading",children:typeof c=="function"?c():c}):D===!1?G.jsx(ie,{type:"error",children:typeof i=="function"?i():i}):G.jsx(Zi.Provider,{value:et,children:e}):G.jsx(ie,{type:"no-data",children:typeof d=="function"?d():d})}))}),nn=x.createContext(null);class wo{constructor({num:t,gen:e}){this.num=t,this.gen=e}toString(){let t=`${this.num}R`;return this.gen!==0&&(t+=this.gen),t}}function ss(l){const t=x.useRef(void 0),e=t.current;return en(e)?()=>e:()=>{const s=l();return t.current=s,s}}function ne(){return x.useContext(Zi)}function rn(){return x.useContext(nn)}var pi=function(l,t,e,s){return new(e||(e=Promise))(function(i,n){function r(h){try{o(s.next(h))}catch(c){n(c)}}function a(h){try{o(s.throw(h))}catch(c){n(c)}}function o(h){var c;h.done?i(h.value):(c=h.value,c instanceof e?c:new e(function(d){d(c)})).then(r,a)}o((s=s.apply(l,t||[])).next())})},_o=function(l,t){var e={};for(var s in l)Object.prototype.hasOwnProperty.call(l,s)&&t.indexOf(s)<0&&(e[s]=l[s]);if(l!=null&&typeof Object.getOwnPropertySymbols=="function"){var i=0;for(s=Object.getOwnPropertySymbols(l);i<s.length;i++)t.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(l,s[i])&&(e[s[i]]=l[s[i]])}return e};function an(l){const t=ne(),e=rn();$(e);const s=Object.assign(Object.assign(Object.assign({},t),e),l),{item:i,linkService:n,onItemClick:r,pdf:a}=s,o=_o(s,["item","linkService","onItemClick","pdf"]);$(a);const h=ss(()=>typeof i.dest=="string"?a.getDestination(i.dest):i.dest),c=ss(()=>pi(this,void 0,void 0,function*(){const u=yield h();if(!u)throw new Error("Destination not found.");const[p]=u;return a.getPageIndex(new wo(p))})),d=ss(()=>pi(this,void 0,void 0,function*(){return(yield c())+1}));return G.jsxs("li",{children:[G.jsx("a",{href:"#",onClick:function(u){u.preventDefault(),$(r||n),r?Promise.all([h(),c(),d()]).then(([p,g,f])=>{r({dest:p,pageIndex:g,pageNumber:f})}):n&&n.goToDestination(i.dest)},children:i.title}),function(){if(!i.items||!i.items.length)return null;const{items:u}=i;return G.jsx("ul",{children:u.map((p,g)=>G.jsx(an,Object.assign({item:p,pdf:a},o),typeof p.dest=="string"?p.dest:g))})}()]})}var xo=function(l,t){var e={};for(var s in l)Object.prototype.hasOwnProperty.call(l,s)&&t.indexOf(s)<0&&(e[s]=l[s]);if(l!=null&&typeof Object.getOwnPropertySymbols=="function"){var i=0;for(s=Object.getOwnPropertySymbols(l);i<s.length;i++)t.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(l,s[i])&&(e[s[i]]=l[s[i]])}return e};function on(){for(var l=[],t=0;t<arguments.length;t++)l[t]=arguments[t];var e=l.filter(Boolean);return e.length<=1?e[0]||null:function(s){e.forEach(function(i){typeof i=="function"?i(s):i&&(i.current=s)})}}const hn=x.createContext(null),gi={Document:null,DocumentFragment:null,Part:"group",Sect:"group",Div:"group",Aside:"note",NonStruct:"none",P:null,H:"heading",Title:null,FENote:"note",Sub:"group",Lbl:null,Span:null,Em:null,Strong:null,Link:"link",Annot:"note",Form:"form",Ruby:null,RB:null,RT:null,RP:null,Warichu:null,WT:null,WP:null,L:"list",LI:"listitem",LBody:null,Table:"table",TR:"row",TH:"columnheader",TD:"cell",THead:"columnheader",TBody:null,TFoot:null,Caption:null,Figure:"figure",Formula:null,Artifact:null},Eo=/^H(\d+)$/;function qe(l){return"children"in l}function ln(l){return!!qe(l)&&l.children.length===1&&0 in l.children&&"id"in l.children[0]}function So(l){const t={};if(qe(l)){const{role:e}=l,s=e.match(Eo);if(s)t.role="heading",t["aria-level"]=Number(s[1]);else if(function(i){return i in gi}(e)){const i=gi[e];i&&(t.role=i)}}return t}function cn(l){const t={};if(qe(l)){if(l.alt!==void 0&&(t["aria-label"]=l.alt),l.lang!==void 0&&(t.lang=l.lang),ln(l)){const[e]=l.children;if(e){const s=cn(e);return Object.assign(Object.assign({},t),s)}}}else"id"in l&&(t["aria-owns"]=l.id);return t}function Co(l){return l?Object.assign(Object.assign({},So(l)),cn(l)):null}function dn({className:l,node:t}){const e=x.useMemo(()=>Co(t),[t]),s=x.useMemo(()=>qe(t)?ln(t)?null:t.children.map((i,n)=>G.jsx(dn,{node:i},n)):null,[t]);return G.jsx("span",Object.assign({className:l},e,{children:s}))}function ye(){return x.useContext(hn)}function ko(){const l=ye();$(l);const{onGetStructTreeError:t,onGetStructTreeSuccess:e}=l,[s,i]=qt(),{value:n,error:r}=s,{customTextRenderer:a,page:o}=l;return x.useEffect(function(){i({type:"RESET"})},[i,o]),x.useEffect(function(){if(a||!o)return;const h=oe(o.getStructTree()),c=h;return h.promise.then(d=>{i({type:"RESOLVE",value:d})}).catch(d=>{i({type:"REJECT",error:d})}),()=>Bt(c)},[a,o,i]),x.useEffect(()=>{n!==void 0&&(n!==!1?n&&e&&e(n):r&&(ht(!1,r.toString()),t&&t(r)))},[n]),n?G.jsx(dn,{className:"react-pdf__Page__structTree structTree",node:n}):null}const fi=Xi;function Mo(l){const t=ye();$(t);const e=Object.assign(Object.assign({},t),l),{_className:s,canvasBackground:i,devicePixelRatio:n=fo(),onRenderError:r,onRenderSuccess:a,page:o,renderForms:h,renderTextLayer:c,rotate:d,scale:u}=e,{canvasRef:p}=l;$(o);const g=x.useRef(null);function f(A){(function(w){return w.name==="RenderingCancelledException"})(A)||(ht(!1,A.toString()),r&&r(A))}const v=x.useMemo(()=>o.getViewport({scale:u*n,rotation:d}),[n,o,d,u]),m=x.useMemo(()=>o.getViewport({scale:u,rotation:d}),[o,d,u]);x.useEffect(function(){if(!o)return;o.cleanup();const{current:A}=g;if(!A)return;A.width=v.width,A.height=v.height,A.style.width=`${Math.floor(m.width)}px`,A.style.height=`${Math.floor(m.height)}px`,A.style.visibility="hidden";const w={annotationMode:h?fi.ENABLE_FORMS:fi.ENABLE,canvasContext:A.getContext("2d",{alpha:!1}),viewport:v};i&&(w.background=i);const _=o.render(w),y=_;return _.promise.then(()=>{A.style.visibility="",o&&a&&a(bs(o,u))}).catch(f),()=>Bt(y)},[i,o,h,v,m]);const b=x.useCallback(()=>{const{current:A}=g;A&&(A.width=0,A.height=0)},[]);return x.useEffect(()=>b,[b]),G.jsx("canvas",{className:`${s}__canvas`,dir:"ltr",ref:on(p,g),style:{display:"block",userSelect:"none"},children:c?G.jsx(ko,{}):null})}function Ro(){const l=ye();$(l);const{customTextRenderer:t,onGetTextError:e,onGetTextSuccess:s,onRenderTextLayerError:i,onRenderTextLayerSuccess:n,page:r,pageIndex:a,pageNumber:o,rotate:h,scale:c}=l;$(r);const[d,u]=qt(),{value:p,error:g}=d,f=x.useRef(null),v=x.useRef(void 0);ht(Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-text-layer"),10)===1,"TextLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-text-layer"),x.useEffect(function(){u({type:"RESET"})},[r,u]),x.useEffect(function(){if(!r)return;const w=oe(r.getTextContent()),_=w;return w.promise.then(y=>{u({type:"RESOLVE",value:y})}).catch(y=>{u({type:"REJECT",error:y})}),()=>Bt(_)},[r,u]),x.useEffect(()=>{p!==void 0&&(p!==!1?p&&s&&s(p):g&&(ht(!1,g.toString()),e&&e(g)))},[p]);const m=x.useCallback(()=>{n&&n()},[n]),b=x.useCallback(w=>{ht(!1,w.toString()),i&&i(w)},[i]),A=x.useMemo(()=>r.getViewport({scale:c,rotation:h}),[r,h,c]);return x.useLayoutEffect(function(){if(!r||!p)return;const{current:w}=f;if(!w)return;w.innerHTML="";const _=r.streamTextContent({includeMarkedContent:!0}),y=new Yi({container:w,textContentSource:_,viewport:A}),E=y;return y.render().then(()=>{const S=document.createElement("div");S.className="endOfContent",w.append(S),v.current=S;const C=w.querySelectorAll('[role="presentation"]');if(t){let I=0;p.items.forEach((M,W)=>{if(!function(U){return"str"in U}(M))return;const D=C[I];if(!D)return;const B=t(Object.assign({pageIndex:a,pageNumber:o,itemIndex:W},M));D.innerHTML=B,I+=M.str&&M.hasEOL?2:1})}m()}).catch(b),()=>Bt(E)},[t,b,m,r,a,o,p,A]),G.jsx("div",{className:re("react-pdf__Page__textContent","textLayer"),onMouseUp:function(){const w=v.current;w&&w.classList.remove("active")},onMouseDown:function(){const w=v.current;w&&w.classList.add("active")},ref:f})}function To(){const l=ne(),t=ye();$(t);const e=Object.assign(Object.assign({},l),t),{imageResourcesPath:s,linkService:i,onGetAnnotationsError:n,onGetAnnotationsSuccess:r,onRenderAnnotationLayerError:a,onRenderAnnotationLayerSuccess:o,page:h,pdf:c,renderForms:d,rotate:u,scale:p=1}=e;$(c),$(h),$(i);const[g,f]=qt(),{value:v,error:m}=g,b=x.useRef(null);ht(Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-annotation-layer"),10)===1,"AnnotationLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-annotations"),x.useEffect(function(){f({type:"RESET"})},[f,h]),x.useEffect(function(){if(!h)return;const w=oe(h.getAnnotations()),_=w;return w.promise.then(y=>{f({type:"RESOLVE",value:y})}).catch(y=>{f({type:"REJECT",error:y})}),()=>{Bt(_)}},[f,h]),x.useEffect(()=>{v!==void 0&&(v!==!1?v&&r&&r(v):m&&(ht(!1,m.toString()),n&&n(m)))},[v]);const A=x.useMemo(()=>h.getViewport({scale:p,rotation:u}),[h,u,p]);return x.useEffect(function(){if(!(c&&h&&i&&v))return;const{current:w}=b;if(!w)return;const _=A.clone({dontFlip:!0}),y={accessibilityManager:null,annotationCanvasMap:null,annotationEditorUIManager:null,div:w,l10n:null,page:h,viewport:_},E={annotations:v,annotationStorage:c.annotationStorage,div:w,imageResourcesPath:s,linkService:i,page:h,renderForms:d,viewport:_};w.innerHTML="";try{new Wi(y).render(E),o&&o()}catch(S){(function(C){ht(!1,`${C}`),a&&a(C)})(S)}return()=>{}},[v,s,i,h,c,d,A]),G.jsx("div",{className:re("react-pdf__Page__annotations","annotationLayer"),ref:b})}var Po=function(l,t){var e={};for(var s in l)Object.prototype.hasOwnProperty.call(l,s)&&t.indexOf(s)<0&&(e[s]=l[s]);if(l!=null&&typeof Object.getOwnPropertySymbols=="function"){var i=0;for(s=Object.getOwnPropertySymbols(l);i<s.length;i++)t.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(l,s[i])&&(e[s[i]]=l[s[i]])}return e};const mi=1;function vi(l){const t=ne(),e=Object.assign(Object.assign({},t),l),{_className:s="react-pdf__Page",_enableRegisterUnregisterPage:i=!0,canvasBackground:n,canvasRef:r,children:a,className:o,customRenderer:h,customTextRenderer:c,devicePixelRatio:d,error:u="Failed to load the page.",height:p,inputRef:g,loading:f="Loading page…",noData:v="No page specified.",onGetAnnotationsError:m,onGetAnnotationsSuccess:b,onGetStructTreeError:A,onGetStructTreeSuccess:w,onGetTextError:_,onGetTextSuccess:y,onLoadError:E,onLoadSuccess:S,onRenderAnnotationLayerError:C,onRenderAnnotationLayerSuccess:I,onRenderError:M,onRenderSuccess:W,onRenderTextLayerError:D,onRenderTextLayerSuccess:B,pageIndex:U,pageNumber:Y,pdf:J,registerPage:R,renderAnnotationLayer:F=!0,renderForms:_t=!1,renderMode:At="canvas",renderTextLayer:tt=!0,rotate:et,scale:H=mi,unregisterPage:X,width:N}=e,V=Po(e,["_className","_enableRegisterUnregisterPage","canvasBackground","canvasRef","children","className","customRenderer","customTextRenderer","devicePixelRatio","error","height","inputRef","loading","noData","onGetAnnotationsError","onGetAnnotationsSuccess","onGetStructTreeError","onGetStructTreeSuccess","onGetTextError","onGetTextSuccess","onLoadError","onLoadSuccess","onRenderAnnotationLayerError","onRenderAnnotationLayerSuccess","onRenderError","onRenderSuccess","onRenderTextLayerError","onRenderTextLayerSuccess","pageIndex","pageNumber","pdf","registerPage","renderAnnotationLayer","renderForms","renderMode","renderTextLayer","rotate","scale","unregisterPage","width"]),[lt,rt]=qt(),{value:Q,error:Mt}=lt,We=x.useRef(null);$(J);const xt=Ct(Y)?Y-1:U??null,Dt=Y??(Ct(U)?U+1:null),Yt=et??(Q?Q.rotate:null),yt=x.useMemo(()=>{if(!Q)return null;let Qt=1;const Xe=H??mi;if(N||p){const Jt=Q.getViewport({scale:1,rotation:Yt});N?Qt=N/Jt.width:p&&(Qt=p/Jt.height)}return Xe*Qt},[p,Q,Yt,H,N]);x.useEffect(function(){return()=>{Ct(xt)&&i&&X&&X(xt)}},[i,J,xt,X]),x.useEffect(function(){rt({type:"RESET"})},[rt,J,xt]),x.useEffect(function(){if(!J||!Dt)return;const Qt=oe(J.getPage(Dt)),Xe=Qt;return Qt.promise.then(Jt=>{rt({type:"RESOLVE",value:Jt})}).catch(Jt=>{rt({type:"REJECT",error:Jt})}),()=>Bt(Xe)},[rt,J,Dt]),x.useEffect(()=>{Q!==void 0&&(Q!==!1?function(){if(S){if(!Q||!yt)return;S(bs(Q,yt))}if(i&&R){if(!Ct(xt)||!We.current)return;R(xt,We.current)}}():Mt&&(ht(!1,Mt.toString()),E&&E(Mt)))},[Q,yt]);const un=x.useMemo(()=>Q&&Ct(xt)&&Dt&&Ct(Yt)&&Ct(yt)?{_className:s,canvasBackground:n,customTextRenderer:c,devicePixelRatio:d,onGetAnnotationsError:m,onGetAnnotationsSuccess:b,onGetStructTreeError:A,onGetStructTreeSuccess:w,onGetTextError:_,onGetTextSuccess:y,onRenderAnnotationLayerError:C,onRenderAnnotationLayerSuccess:I,onRenderError:M,onRenderSuccess:W,onRenderTextLayerError:D,onRenderTextLayerSuccess:B,page:Q,pageIndex:xt,pageNumber:Dt,renderForms:_t,renderTextLayer:tt,rotate:Yt,scale:yt}:null,[s,n,c,d,m,b,A,w,_,y,C,I,M,W,D,B,Q,xt,Dt,_t,tt,Yt,yt]),pn=x.useMemo(()=>Os(V,()=>Q&&(yt?bs(Q,yt):void 0)),[V,Q,yt]),we=`${xt}@${yt}/${Yt}`;function gn(){switch(At){case"custom":return $(h),G.jsx(h,{},`${we}_custom`);case"none":return null;default:return G.jsx(Mo,{canvasRef:r},`${we}_canvas`)}}return G.jsx("div",Object.assign({className:re(s,o),"data-page-number":Dt,ref:on(g,We),style:{"--scale-factor":`${yt}`,backgroundColor:n||"white",position:"relative",minWidth:"min-content",minHeight:"min-content"}},pn,{children:Dt?J===null||Q==null?G.jsx(ie,{type:"loading",children:typeof f=="function"?f():f}):J===!1||Q===!1?G.jsx(ie,{type:"error",children:typeof u=="function"?u():u}):G.jsxs(hn.Provider,{value:un,children:[gn(),tt?G.jsx(Ro,{},`${we}_text`):null,F?G.jsx(To,{},`${we}_annotations`):null,a]}):G.jsx(ie,{type:"no-data",children:typeof v=="function"?v():v})}))}var Lo=function(l,t){var e={};for(var s in l)Object.prototype.hasOwnProperty.call(l,s)&&t.indexOf(s)<0&&(e[s]=l[s]);if(l!=null&&typeof Object.getOwnPropertySymbols=="function"){var i=0;for(s=Object.getOwnPropertySymbols(l);i<s.length;i++)t.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(l,s[i])&&(e[s[i]]=l[s[i]])}return e};ht(!tn,`Loading PDF.js worker may not work on protocols other than HTTP/HTTPS. ${sn}`),Ki.workerSrc="pdf.worker.mjs";const No=Object.freeze(Object.defineProperty({__proto__:null,Document:yo,Outline:function(l){const t=ne(),e=Object.assign(Object.assign({},t),l),{className:s,inputRef:i,onItemClick:n,onLoadError:r,onLoadSuccess:a,pdf:o}=e,h=xo(e,["className","inputRef","onItemClick","onLoadError","onLoadSuccess","pdf"]);$(o);const[c,d]=qt(),{value:u,error:p}=c;x.useEffect(function(){d({type:"RESET"})},[d,o]),x.useEffect(function(){if(!o)return;const v=oe(o.getOutline()),m=v;return v.promise.then(b=>{d({type:"RESOLVE",value:b})}).catch(b=>{d({type:"REJECT",error:b})}),()=>Bt(m)},[d,o]),x.useEffect(()=>{u!==void 0&&(u!==!1?u!==void 0&&u!==!1&&a&&a(u):p&&(ht(!1,p.toString()),r&&r(p)))},[u]);const g=x.useMemo(()=>({onItemClick:n}),[n]),f=x.useMemo(()=>Os(h,()=>u),[h,u]);return u?G.jsx("div",Object.assign({className:re("react-pdf__Outline",s),ref:i},f,{children:G.jsx(nn.Provider,{value:g,children:u?G.jsx("ul",{children:u.map((v,m)=>G.jsx(an,{item:v,pdf:o},typeof v.dest=="string"?v.dest:m))}):null})})):null},Page:vi,PasswordResponses:ms,Thumbnail:function(l){const t=ne(),e=Object.assign(Object.assign({},t),l),{className:s,linkService:i,onItemClick:n,pageIndex:r,pageNumber:a,pdf:o}=e;$(o);const h=Ct(a)?a-1:r??null,c=a??(Ct(r)?r+1:null),{className:d,onItemClick:u}=l,p=Lo(l,["className","onItemClick"]);return G.jsx("a",{className:re("react-pdf__Thumbnail",s),href:c?"#":void 0,onClick:function(g){g.preventDefault(),Ct(h)&&c&&($(n||i),n?n({pageIndex:h,pageNumber:c}):i&&i.goToPage(c))},children:G.jsx(vi,Object.assign({},p,{_className:"react-pdf__Thumbnail__page",_enableRegisterUnregisterPage:!1,renderAnnotationLayer:!1,renderTextLayer:!1}))})},pdfjs:Ji,useDocumentContext:ne,useOutlineContext:rn,usePageContext:ye},Symbol.toStringTag,{value:"Module"}));export{yo as D,vi as P,uo as _,Ki as a,No as i};
13
+ `)){const r=document.createElement("div");r.append(n?document.createTextNode(n):document.createElement("br")),e.append(r)}const i=it._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(i,i),popupContent:this.#r}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class gs{#t;#e=[];#s=[];constructor(t,e=0,s=0,i=!0){let n=1/0,r=-1/0,a=1/0,o=-1/0;const h=10**-4;for(const{x:v,y:m,width:b,height:A}of t){const w=Math.floor((v-e)/h)*h,_=Math.ceil((v+b+e)/h)*h,y=Math.floor((m-e)/h)*h,E=Math.ceil((m+A+e)/h)*h,S=[w,y,E,!0],C=[_,y,E,!1];this.#e.push(S,C),n=Math.min(n,w),r=Math.max(r,_),a=Math.min(a,y),o=Math.max(o,E)}const c=r-n+2*s,d=o-a+2*s,u=n-s,p=a-s,g=this.#e.at(i?-1:-2),f=[g[0],g[2]];for(const v of this.#e){const[m,b,A]=v;v[0]=(m-u)/c,v[1]=(b-p)/d,v[2]=(A-p)/d}this.#t={x:u,y:p,width:c,height:d,lastPoint:f}}getOutlines(){this.#e.sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of this.#e)e[3]?(t.push(...this.#h(e)),this.#i(e)):(this.#r(e),t.push(...this.#h(e)));return this.#n(t)}#n(t){const e=[],s=new Set;for(const r of t){const[a,o,h]=r;e.push([a,o,r],[a,h,r])}e.sort((r,a)=>r[1]-a[1]||r[0]-a[0]);for(let r=0,a=e.length;r<a;r+=2){const o=e[r][2],h=e[r+1][2];o.push(h),h.push(o),s.add(o),s.add(h)}const i=[];let n;for(;s.size>0;){const r=s.values().next().value;let[a,o,h,c,d]=r;s.delete(r);let u=a,p=o;for(n=[a,h],i.push(n);;){let g;if(s.has(c))g=c;else{if(!s.has(d))break;g=d}s.delete(g),[a,o,h,c,d]=g,u!==a&&(n.push(u,p,a,p===o?o:h),u=a),p=p===o?h:o}n.push(u,p)}return new Ea(i,this.#t)}#o(t){const e=this.#s;let s=0,i=e.length-1;for(;s<=i;){const n=s+i>>1,r=e[n][0];if(r===t)return n;r<t?s=n+1:i=n-1}return i+1}#i([,t,e]){const s=this.#o(t);this.#s.splice(s,0,[t,e])}#r([,t,e]){const s=this.#o(t);for(let i=s;i<this.#s.length;i++){const[n,r]=this.#s[i];if(n!==t)break;if(n===t&&r===e)return void this.#s.splice(i,1)}for(let i=s-1;i>=0;i--){const[n,r]=this.#s[i];if(n!==t)break;if(n===t&&r===e)return void this.#s.splice(i,1)}}#h(t){const[e,s,i]=t,n=[[e,s,i]],r=this.#o(i);for(let a=0;a<r;a++){const[o,h]=this.#s[a];for(let c=0,d=n.length;c<d;c++){const[,u,p]=n[c];if(!(h<=u||p<=o))if(u>=o)if(p>h)n[c][1]=h;else{if(d===1)return[];n.splice(c,1),c--,d--}else n[c][2]=o,p>h&&n.push([e,h,p])}}return n}}let qi=class{toSVGPath(){throw new Error("Abstract method `toSVGPath` must be implemented.")}get box(){throw new Error("Abstract getter `box` must be implemented.")}serialize(l,t){throw new Error("Abstract method `serialize` must be implemented.")}get free(){return this instanceof fs}};class Ea extends qi{#t;#e;constructor(t,e){super(),this.#e=t,this.#t=e}toSVGPath(){const t=[];for(const e of this.#e){let[s,i]=e;t.push(`M${s} ${i}`);for(let n=2;n<e.length;n+=2){const r=e[n],a=e[n+1];r===s?(t.push(`V${a}`),i=a):a===i&&(t.push(`H${r}`),s=r)}t.push("Z")}return t.join(" ")}serialize([t,e,s,i],n){const r=[],a=s-t,o=i-e;for(const h of this.#e){const c=new Array(h.length);for(let d=0;d<h.length;d+=2)c[d]=t+h[d]*a,c[d+1]=i-h[d+1]*o;r.push(c)}return r}get box(){return this.#t}}class Vt{#t;#e=[];#s;#n;#o=[];#i=new Float64Array(18);#r;#h;#c;#d;#p;#l;#a=[];static#g=8;static#m=2;static#u=Vt.#g+Vt.#m;constructor({x:t,y:e},s,i,n,r,a=0){this.#t=s,this.#l=n*i,this.#n=r,this.#i.set([NaN,NaN,NaN,NaN,t,e],6),this.#s=a,this.#d=Vt.#g*i,this.#c=Vt.#u*i,this.#p=i,this.#a.push(t,e)}get free(){return!0}isEmpty(){return isNaN(this.#i[8])}#b(){const t=this.#i.subarray(4,6),e=this.#i.subarray(16,18),[s,i,n,r]=this.#t;return[(this.#r+(t[0]-e[0])/2-s)/n,(this.#h+(t[1]-e[1])/2-i)/r,(this.#r+(e[0]-t[0])/2-s)/n,(this.#h+(e[1]-t[1])/2-i)/r]}add({x:t,y:e}){this.#r=t,this.#h=e;const[s,i,n,r]=this.#t;let[a,o,h,c]=this.#i.subarray(8,12);const d=t-h,u=e-c,p=Math.hypot(d,u);if(p<this.#c)return!1;const g=p-this.#d,f=g/p,v=f*d,m=f*u;let b=a,A=o;a=h,o=c,h+=v,c+=m,this.#a?.push(t,e);const w=v/g,_=-m/g*this.#l,y=w*this.#l;return this.#i.set(this.#i.subarray(2,8),0),this.#i.set([h+_,c+y],4),this.#i.set(this.#i.subarray(14,18),12),this.#i.set([h-_,c-y],16),isNaN(this.#i[6])?(this.#o.length===0&&(this.#i.set([a+_,o+y],2),this.#o.push(NaN,NaN,NaN,NaN,(a+_-s)/n,(o+y-i)/r),this.#i.set([a-_,o-y],14),this.#e.push(NaN,NaN,NaN,NaN,(a-_-s)/n,(o-y-i)/r)),this.#i.set([b,A,a,o,h,c],6),!this.isEmpty()):(this.#i.set([b,A,a,o,h,c],6),Math.abs(Math.atan2(A-o,b-a)-Math.atan2(m,v))<Math.PI/2?([a,o,h,c]=this.#i.subarray(2,6),this.#o.push(NaN,NaN,NaN,NaN,((a+h)/2-s)/n,((o+c)/2-i)/r),[a,o,b,A]=this.#i.subarray(14,18),this.#e.push(NaN,NaN,NaN,NaN,((b+a)/2-s)/n,((A+o)/2-i)/r),!0):([b,A,a,o,h,c]=this.#i.subarray(0,6),this.#o.push(((b+5*a)/6-s)/n,((A+5*o)/6-i)/r,((5*a+h)/6-s)/n,((5*o+c)/6-i)/r,((a+h)/2-s)/n,((o+c)/2-i)/r),[h,c,a,o,b,A]=this.#i.subarray(12,18),this.#e.push(((b+5*a)/6-s)/n,((A+5*o)/6-i)/r,((5*a+h)/6-s)/n,((5*o+c)/6-i)/r,((a+h)/2-s)/n,((o+c)/2-i)/r),!0))}toSVGPath(){if(this.isEmpty())return"";const t=this.#o,e=this.#e,s=this.#i.subarray(4,6),i=this.#i.subarray(16,18),[n,r,a,o]=this.#t,[h,c,d,u]=this.#b();if(isNaN(this.#i[6])&&!this.isEmpty())return`M${(this.#i[2]-n)/a} ${(this.#i[3]-r)/o} L${(this.#i[4]-n)/a} ${(this.#i[5]-r)/o} L${h} ${c} L${d} ${u} L${(this.#i[16]-n)/a} ${(this.#i[17]-r)/o} L${(this.#i[14]-n)/a} ${(this.#i[15]-r)/o} Z`;const p=[];p.push(`M${t[4]} ${t[5]}`);for(let g=6;g<t.length;g+=6)isNaN(t[g])?p.push(`L${t[g+4]} ${t[g+5]}`):p.push(`C${t[g]} ${t[g+1]} ${t[g+2]} ${t[g+3]} ${t[g+4]} ${t[g+5]}`);p.push(`L${(s[0]-n)/a} ${(s[1]-r)/o} L${h} ${c} L${d} ${u} L${(i[0]-n)/a} ${(i[1]-r)/o}`);for(let g=e.length-6;g>=6;g-=6)isNaN(e[g])?p.push(`L${e[g+4]} ${e[g+5]}`):p.push(`C${e[g]} ${e[g+1]} ${e[g+2]} ${e[g+3]} ${e[g+4]} ${e[g+5]}`);return p.push(`L${e[4]} ${e[5]} Z`),p.join(" ")}getOutlines(){const t=this.#o,e=this.#e,s=this.#i,i=s.subarray(4,6),n=s.subarray(16,18),[r,a,o,h]=this.#t,c=new Float64Array((this.#a?.length??0)+2);for(let m=0,b=c.length-2;m<b;m+=2)c[m]=(this.#a[m]-r)/o,c[m+1]=(this.#a[m+1]-a)/h;c[c.length-2]=(this.#r-r)/o,c[c.length-1]=(this.#h-a)/h;const[d,u,p,g]=this.#b();if(isNaN(s[6])&&!this.isEmpty()){const m=new Float64Array(36);return m.set([NaN,NaN,NaN,NaN,(s[2]-r)/o,(s[3]-a)/h,NaN,NaN,NaN,NaN,(s[4]-r)/o,(s[5]-a)/h,NaN,NaN,NaN,NaN,d,u,NaN,NaN,NaN,NaN,p,g,NaN,NaN,NaN,NaN,(s[16]-r)/o,(s[17]-a)/h,NaN,NaN,NaN,NaN,(s[14]-r)/o,(s[15]-a)/h],0),new fs(m,c,this.#t,this.#p,this.#s,this.#n)}const f=new Float64Array(this.#o.length+24+this.#e.length);let v=t.length;for(let m=0;m<v;m+=2)isNaN(t[m])?f[m]=f[m+1]=NaN:(f[m]=t[m],f[m+1]=t[m+1]);f.set([NaN,NaN,NaN,NaN,(i[0]-r)/o,(i[1]-a)/h,NaN,NaN,NaN,NaN,d,u,NaN,NaN,NaN,NaN,p,g,NaN,NaN,NaN,NaN,(n[0]-r)/o,(n[1]-a)/h],v),v+=24;for(let m=e.length-6;m>=6;m-=6)for(let b=0;b<6;b+=2)isNaN(e[m+b])?(f[v]=f[v+1]=NaN,v+=2):(f[v]=e[m+b],f[v+1]=e[m+b+1],v+=2);return f.set([NaN,NaN,NaN,NaN,e[4],e[5]],v),new fs(f,c,this.#t,this.#p,this.#s,this.#n)}}class fs extends qi{#t;#e=null;#s;#n;#o;#i;#r;constructor(t,e,s,i,n,r){super(),this.#r=t,this.#o=e,this.#t=s,this.#i=i,this.#s=n,this.#n=r,this.#d(r);const{x:a,y:o,width:h,height:c}=this.#e;for(let d=0,u=t.length;d<u;d+=2)t[d]=(t[d]-a)/h,t[d+1]=(t[d+1]-o)/c;for(let d=0,u=e.length;d<u;d+=2)e[d]=(e[d]-a)/h,e[d+1]=(e[d+1]-o)/c}toSVGPath(){const t=[`M${this.#r[4]} ${this.#r[5]}`];for(let e=6,s=this.#r.length;e<s;e+=6)isNaN(this.#r[e])?t.push(`L${this.#r[e+4]} ${this.#r[e+5]}`):t.push(`C${this.#r[e]} ${this.#r[e+1]} ${this.#r[e+2]} ${this.#r[e+3]} ${this.#r[e+4]} ${this.#r[e+5]}`);return t.push("Z"),t.join(" ")}serialize([t,e,s,i],n){const r=s-t,a=i-e;let o,h;switch(n){case 0:o=this.#h(this.#r,t,i,r,-a),h=this.#h(this.#o,t,i,r,-a);break;case 90:o=this.#c(this.#r,t,e,r,a),h=this.#c(this.#o,t,e,r,a);break;case 180:o=this.#h(this.#r,s,e,-r,a),h=this.#h(this.#o,s,e,-r,a);break;case 270:o=this.#c(this.#r,s,i,-r,-a),h=this.#c(this.#o,s,i,-r,-a)}return{outline:Array.from(o),points:[Array.from(h)]}}#h(t,e,s,i,n){const r=new Float64Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a]*i,r[a+1]=s+t[a+1]*n;return r}#c(t,e,s,i,n){const r=new Float64Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a+1]*i,r[a+1]=s+t[a]*n;return r}#d(t){const e=this.#r;let s=e[4],i=e[5],n=s,r=i,a=s,o=i,h=s,c=i;const d=t?Math.max:Math.min;for(let v=6,m=e.length;v<m;v+=6){if(isNaN(e[v]))n=Math.min(n,e[v+4]),r=Math.min(r,e[v+5]),a=Math.max(a,e[v+4]),o=Math.max(o,e[v+5]),c<e[v+5]?(h=e[v+4],c=e[v+5]):c===e[v+5]&&(h=d(h,e[v+4]));else{const b=k.bezierBoundingBox(s,i,...e.slice(v,v+6));n=Math.min(n,b[0]),r=Math.min(r,b[1]),a=Math.max(a,b[2]),o=Math.max(o,b[3]),c<b[3]?(h=b[2],c=b[3]):c===b[3]&&(h=d(h,b[2]))}s=e[v+4],i=e[v+5]}const u=n-this.#s,p=r-this.#s,g=a-n+2*this.#s,f=o-r+2*this.#s;this.#e={x:u,y:p,width:g,height:f,lastPoint:[h,c]}}get box(){return this.#e}getNewOutline(t,e){const{x:s,y:i,width:n,height:r}=this.#e,[a,o,h,c]=this.#t,d=n*h,u=r*c,p=s*h+a,g=i*c+o,f=new Vt({x:this.#o[0]*d+p,y:this.#o[1]*u+g},this.#t,this.#i,t,this.#n,e??this.#s);for(let v=2;v<this.#o.length;v+=2)f.add({x:this.#o[v]*d+p,y:this.#o[v+1]*u+g});return f.getOutlines()}}class St{#t=this.#m.bind(this);#e=this.#b.bind(this);#s=null;#n=null;#o;#i=null;#r=!1;#h=!1;#c=null;#d;#p=null;#l;static get _keyboardManager(){return z(this,"_keyboardManager",new ve([[["Escape","mac+Escape"],St.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],St.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],St.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],St.prototype._moveToPrevious],[["Home","mac+Home"],St.prototype._moveToBeginning],[["End","mac+End"],St.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){t?(this.#h=!1,this.#l=L.HIGHLIGHT_COLOR,this.#c=t):(this.#h=!0,this.#l=L.HIGHLIGHT_DEFAULT_COLOR),this.#p=t?._uiManager||e,this.#d=this.#p._eventBus,this.#o=t?.color||this.#p?.highlightColors.values().next().value||"#FFFF98"}renderButton(){const t=this.#s=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);const e=this.#p._signal;t.addEventListener("click",this.#u.bind(this),{signal:e}),t.addEventListener("keydown",this.#t,{signal:e});const s=this.#n=document.createElement("span");return s.className="swatch",s.setAttribute("aria-hidden",!0),s.style.backgroundColor=this.#o,t.append(s),t}renderMainDropdown(){const t=this.#i=this.#a();return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}#a(){const t=document.createElement("div"),e=this.#p._signal;t.addEventListener("contextmenu",gt,{signal:e}),t.className="dropdown",t.role="listbox",t.setAttribute("aria-multiselectable",!1),t.setAttribute("aria-orientation","vertical"),t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(const[s,i]of this.#p.highlightColors){const n=document.createElement("button");n.tabIndex="0",n.role="option",n.setAttribute("data-color",i),n.title=s,n.setAttribute("data-l10n-id",`pdfjs-editor-colorpicker-${s}`);const r=document.createElement("span");n.append(r),r.className="swatch",r.style.backgroundColor=i,n.setAttribute("aria-selected",i===this.#o),n.addEventListener("click",this.#g.bind(this,i),{signal:e}),t.append(n)}return t.addEventListener("keydown",this.#t,{signal:e}),t}#g(t,e){e.stopPropagation(),this.#d.dispatch("switchannotationeditorparams",{source:this,type:this.#l,value:t})}_colorSelectFromKeyboard(t){if(t.target===this.#s)return void this.#u(t);const e=t.target.getAttribute("data-color");e&&this.#g(e,t)}_moveToNext(t){this.#f?t.target!==this.#s?t.target.nextSibling?.focus():this.#i.firstChild?.focus():this.#u(t)}_moveToPrevious(t){t.target!==this.#i?.firstChild&&t.target!==this.#s?(this.#f||this.#u(t),t.target.previousSibling?.focus()):this.#f&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){this.#f?this.#i.firstChild?.focus():this.#u(t)}_moveToEnd(t){this.#f?this.#i.lastChild?.focus():this.#u(t)}#m(t){St._keyboardManager.exec(this,t)}#u(t){if(this.#f)return void this.hideDropdown();if(this.#r=t.detail===0,window.addEventListener("pointerdown",this.#e,{signal:this.#p._signal}),this.#i)return void this.#i.classList.remove("hidden");const e=this.#i=this.#a();this.#s.append(e)}#b(t){this.#i?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#i?.classList.add("hidden"),window.removeEventListener("pointerdown",this.#e)}get#f(){return this.#i&&!this.#i.classList.contains("hidden")}_hideDropdownFromKeyboard(){this.#h||(this.#f?(this.hideDropdown(),this.#s.focus({preventScroll:!0,focusVisible:this.#r})):this.#c?.unselect())}updateColor(t){if(this.#n&&(this.#n.style.backgroundColor=t),!this.#i)return;const e=this.#p.highlightColors.values();for(const s of this.#i.children)s.setAttribute("aria-selected",e.next().value===t)}destroy(){this.#s?.remove(),this.#s=null,this.#n=null,this.#i?.remove(),this.#i=null}}class st extends P{#t=null;#e=0;#s;#n=null;#o=null;#i=null;#r=null;#h=0;#c=null;#d=null;#p=null;#l=!1;#a=this.#_.bind(this);#g=null;#m;#u=null;#b="";#f;#A="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _l10nPromise;static _type="highlight";static _editorType=j.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const t=st.prototype;return z(this,"_keyboardManager",new ve([[["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.#f=t.thickness||st._defaultThickness,this.#m=t.opacity||st._defaultOpacity,this.#s=t.boxes||null,this.#A=t.methodOfCreation||"",this.#b=t.text||"",this._isDraggable=!1,t.highlightId>-1?(this.#l=!0,this.#x(t),this.#y()):(this.#t=t.anchorNode,this.#e=t.anchorOffset,this.#r=t.focusNode,this.#h=t.focusOffset,this.#w(),this.#y(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#l?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#f,methodOfCreation:this.#A}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#w(){const t=new gs(this.#s,.001);this.#d=t.getOutlines(),{x:this.x,y:this.y,width:this.width,height:this.height}=this.#d.box;const e=new gs(this.#s,.0025,.001,this._uiManager.direction==="ltr");this.#i=e.getOutlines();const{lastPoint:s}=this.#i.box;this.#g=[(s[0]-this.x)/this.width,(s[1]-this.y)/this.height]}#x({highlightOutlines:t,highlightId:e,clipPathId:s}){if(this.#d=t,this.#i=t.getNewOutline(this.#f/2+1.5,.0025),e>=0)this.#p=e,this.#n=s,this.parent.drawLayer.finalizeLine(e,t),this.#u=this.parent.drawLayer.highlightOutline(this.#i);else if(this.parent){const h=this.parent.viewport.rotation;this.parent.drawLayer.updateLine(this.#p,t),this.parent.drawLayer.updateBox(this.#p,st.#v(this.#d.box,(h-this.rotation+360)%360)),this.parent.drawLayer.updateLine(this.#u,this.#i),this.parent.drawLayer.updateBox(this.#u,st.#v(this.#i.box,h))}const{x:i,y:n,width:r,height:a}=t.box;switch(this.rotation){case 0:this.x=i,this.y=n,this.width=r,this.height=a;break;case 90:{const[h,c]=this.parentDimensions;this.x=n,this.y=1-i,this.width=r*c/h,this.height=a*h/c;break}case 180:this.x=1-i,this.y=1-n,this.width=r,this.height=a;break;case 270:{const[h,c]=this.parentDimensions;this.x=1-n,this.y=i,this.width=r*c/h,this.height=a*h/c;break}}const{lastPoint:o}=this.#i.box;this.#g=[(o[0]-i)/r,(o[1]-n)/a]}static initialize(t,e){P.initialize(t,e),st._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case L.HIGHLIGHT_DEFAULT_COLOR:st._defaultColor=e;break;case L.HIGHLIGHT_THICKNESS:st._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#g}updateParams(t,e){switch(t){case L.HIGHLIGHT_COLOR:this.#S(e);break;case L.HIGHLIGHT_THICKNESS:this.#C(e)}}static get defaultPropertiesToUpdate(){return[[L.HIGHLIGHT_DEFAULT_COLOR,st._defaultColor],[L.HIGHLIGHT_THICKNESS,st._defaultThickness]]}get propertiesToUpdate(){return[[L.HIGHLIGHT_COLOR,this.color||st._defaultColor],[L.HIGHLIGHT_THICKNESS,this.#f||st._defaultThickness],[L.HIGHLIGHT_FREE,this.#l]]}#S(t){const e=i=>{this.color=i,this.parent?.drawLayer.changeColor(this.#p,i),this.#o?.updateColor(i)},s=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:L.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}#C(t){const e=this.#f,s=i=>{this.#f=i,this.#T(i)};this.addCommands({cmd:s.bind(this,t),undo:s.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:L.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}async addEditToolbar(){const t=await super.addEditToolbar();return t?(this._uiManager.highlightColors&&(this.#o=new St({editor:this}),t.addColorPicker(this.#o)),t):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#M())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#M())}onceAdded(){this.parent.addUndoableEditor(this),this.div.focus()}remove(){this.#E(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#y(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#E():t&&(this.#y(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#T(t){if(!this.#l)return;this.#x({highlightOutlines:this.#d.getNewOutline(t/2)}),this.fixAndSetPosition();const[e,s]=this.parentDimensions;this.setDims(this.width*e,this.height*s)}#E(){this.#p!==null&&this.parent&&(this.parent.drawLayer.remove(this.#p),this.#p=null,this.parent.drawLayer.remove(this.#u),this.#u=null)}#y(t=this.parent){this.#p===null&&({id:this.#p,clipPathId:this.#n}=t.drawLayer.highlight(this.#d,this.color,this.#m),this.#u=t.drawLayer.highlightOutline(this.#i),this.#c&&(this.#c.style.clipPath=this.#n))}static#v({x:t,y:e,width:s,height:i},n){switch(n){case 90:return{x:1-e-i,y:t,width:i,height:s};case 180:return{x:1-t-s,y:1-e-i,width:s,height:i};case 270:return{x:e,y:1-t-s,width:i,height:s}}return{x:t,y:e,width:s,height:i}}rotate(t){const{drawLayer:e}=this.parent;let s;this.#l?(t=(t-this.rotation+360)%360,s=st.#v(this.#d.box,t)):s=st.#v(this,t),e.rotate(this.#p,t),e.rotate(this.#u,t),e.updateBox(this.#p,s),e.updateBox(this.#u,st.#v(this.#i.box,t))}render(){if(this.div)return this.div;const t=super.render();this.#b&&(t.setAttribute("aria-label",this.#b),t.setAttribute("role","mark")),this.#l?t.classList.add("free"):this.div.addEventListener("keydown",this.#a,{signal:this._uiManager._signal});const e=this.#c=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#n;const[s,i]=this.parentDimensions;return this.setDims(this.width*s,this.height*i),Ie(this,this.#c,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.parent.drawLayer.addClass(this.#u,"hovered")}pointerleave(){this.parent.drawLayer.removeClass(this.#u,"hovered")}#_(t){st._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#k(!0);break;case 1:case 3:this.#k(!1)}}#k(t){if(!this.#t)return;const e=window.getSelection();t?e.setPosition(this.#t,this.#e):e.setPosition(this.#r,this.#h)}select(){super.select(),this.#u&&(this.parent?.drawLayer.removeClass(this.#u,"hovered"),this.parent?.drawLayer.addClass(this.#u,"selected"))}unselect(){super.unselect(),this.#u&&(this.parent?.drawLayer.removeClass(this.#u,"selected"),this.#l||this.#k(!1))}get _mustFixPosition(){return!this.#l}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.show(this.#p,t),this.parent.drawLayer.show(this.#u,t))}#M(){return this.#l?this.rotation:0}#L(){if(this.#l)return null;const[t,e]=this.pageDimensions,s=this.#s,i=new Float32Array(8*s.length);let n=0;for(const{x:r,y:a,width:o,height:h}of s){const c=r*t,d=(1-a-h)*e;i[n]=i[n+4]=c,i[n+1]=i[n+3]=d,i[n+2]=i[n+6]=c+o*t,i[n+5]=i[n+7]=d+h*e,n+=8}return i}#P(t){return this.#d.serialize(t,this.#M())}static startHighlighting(t,e,{target:s,x:i,y:n}){const{x:r,y:a,width:o,height:h}=s.getBoundingClientRect(),c=f=>{this.#F(t,f)},d=t._signal,u={capture:!0,passive:!1,signal:d},p=f=>{f.preventDefault(),f.stopPropagation()},g=f=>{s.removeEventListener("pointermove",c),window.removeEventListener("blur",g),window.removeEventListener("pointerup",g),window.removeEventListener("pointerdown",p,u),window.removeEventListener("contextmenu",gt),this.#I(t,f)};window.addEventListener("blur",g,{signal:d}),window.addEventListener("pointerup",g,{signal:d}),window.addEventListener("pointerdown",p,u),window.addEventListener("contextmenu",gt,{signal:d}),s.addEventListener("pointermove",c,{signal:d}),this._freeHighlight=new Vt({x:i,y:n},[r,a,o,h],t.scale,this._defaultThickness/2,e,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.highlight(this._freeHighlight,this._defaultColor,this._defaultOpacity,!0)}static#F(t,e){this._freeHighlight.add(e)&&t.drawLayer.updatePath(this._freeHighlightId,this._freeHighlight)}static#I(t,e){this._freeHighlight.isEmpty()?t.drawLayer.removeFreeHighlight(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 deserialize(t,e,s){const i=super.deserialize(t,e,s),{rect:[n,r,a,o],color:h,quadPoints:c}=t;i.color=k.makeHexColor(...h),i.#m=t.opacity;const[d,u]=i.pageDimensions;i.width=(a-n)/d,i.height=(o-r)/u;const p=i.#s=[];for(let g=0;g<c.length;g+=8)p.push({x:(c[4]-a)/d,y:(o-(1-c[g+5]))/u,width:(c[g+2]-c[g])/d,height:(c[g+5]-c[g+1])/u});return i.#w(),i}serialize(t=!1){if(this.isEmpty()||t)return null;const e=this.getRect(0,0),s=P._colorManager.convert(this.color);return{annotationType:j.HIGHLIGHT,color:s,opacity:this.#m,thickness:this.#f,quadPoints:this.#L(),outlines:this.#P(e),pageIndex:this.pageIndex,rect:e,rotation:this.#M(),structTreeParentId:this._structTreeParentId}}static canCreateNewEmptyEditor(){return!1}}class ot extends P{#t=0;#e=0;#s=this.canvasPointermove.bind(this);#n=this.canvasPointerleave.bind(this);#o=this.canvasPointerup.bind(this);#i=this.canvasPointerdown.bind(this);#r=null;#h=new Path2D;#c=!1;#d=!1;#p=!1;#l=null;#a=0;#g=0;#m=null;static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=1;static _type="ink";static _editorType=j.INK;constructor(t){super({...t,name:"inkEditor"}),this.color=t.color||null,this.thickness=t.thickness||null,this.opacity=t.opacity||null,this.paths=[],this.bezierPath2D=[],this.allRawPaths=[],this.currentPath=[],this.scaleFactor=1,this.translationX=this.translationY=0,this.x=0,this.y=0,this._willKeepAspectRatio=!0}static initialize(t,e){P.initialize(t,e)}static updateDefaultParams(t,e){switch(t){case L.INK_THICKNESS:ot._defaultThickness=e;break;case L.INK_COLOR:ot._defaultColor=e;break;case L.INK_OPACITY:ot._defaultOpacity=e/100}}updateParams(t,e){switch(t){case L.INK_THICKNESS:this.#u(e);break;case L.INK_COLOR:this.#b(e);break;case L.INK_OPACITY:this.#f(e)}}static get defaultPropertiesToUpdate(){return[[L.INK_THICKNESS,ot._defaultThickness],[L.INK_COLOR,ot._defaultColor||P._defaultLineColor],[L.INK_OPACITY,Math.round(100*ot._defaultOpacity)]]}get propertiesToUpdate(){return[[L.INK_THICKNESS,this.thickness||ot._defaultThickness],[L.INK_COLOR,this.color||ot._defaultColor||P._defaultLineColor],[L.INK_OPACITY,Math.round(100*(this.opacity??ot._defaultOpacity))]]}#u(t){const e=i=>{this.thickness=i,this.#N()},s=this.thickness;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:L.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})}#b(t){const e=i=>{this.color=i,this.#_()},s=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:L.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})}#f(t){const e=i=>{this.opacity=i,this.#_()};t/=100;const s=this.opacity;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:L.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.canvas||(this.#M(),this.#L()),this.isAttachedToDOM||(this.parent.add(this),this.#P()),this.#N()))}remove(){this.canvas!==null&&(this.isEmpty()||this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,this.#r&&(clearTimeout(this.#r),this.#r=null),this.#l?.disconnect(),this.#l=null,super.remove())}setParent(t){!this.parent&&t?this._uiManager.removeShouldRescale(this):this.parent&&t===null&&this._uiManager.addShouldRescale(this),super.setParent(t)}onScaleChanging(){const[t,e]=this.parentDimensions,s=this.width*t,i=this.height*e;this.setDimensions(s,i)}enableEditMode(){this.#c||this.canvas===null||(super.enableEditMode(),this._isDraggable=!1,this.canvas.addEventListener("pointerdown",this.#i,{signal:this._uiManager._signal}))}disableEditMode(){this.isInEditMode()&&this.canvas!==null&&(super.disableEditMode(),this._isDraggable=!this.isEmpty(),this.div.classList.remove("editing"),this.canvas.removeEventListener("pointerdown",this.#i))}onceAdded(){this._isDraggable=!this.isEmpty()}isEmpty(){return this.paths.length===0||this.paths.length===1&&this.paths[0].length===0}#A(){const{parentRotation:t,parentDimensions:[e,s]}=this;switch(t){case 90:return[0,s,s,e];case 180:return[e,s,e,s];case 270:return[e,0,s,e];default:return[0,0,e,s]}}#w(){const{ctx:t,color:e,opacity:s,thickness:i,parentScale:n,scaleFactor:r}=this;t.lineWidth=i*n/r,t.lineCap="round",t.lineJoin="round",t.miterLimit=10,t.strokeStyle=`${e}${function(a){return Math.round(Math.min(255,Math.max(1,255*a))).toString(16).padStart(2,"0")}(s)}`}#x(t,e){const s=this._uiManager._signal;this.canvas.addEventListener("contextmenu",gt,{signal:s}),this.canvas.addEventListener("pointerleave",this.#n,{signal:s}),this.canvas.addEventListener("pointermove",this.#s,{signal:s}),this.canvas.addEventListener("pointerup",this.#o,{signal:s}),this.canvas.removeEventListener("pointerdown",this.#i),this.isEditing=!0,this.#p||(this.#p=!0,this.#P(),this.thickness||=ot._defaultThickness,this.color||=ot._defaultColor||P._defaultLineColor,this.opacity??=ot._defaultOpacity),this.currentPath.push([t,e]),this.#d=!1,this.#w(),this.#m=()=>{this.#E(),this.#m&&window.requestAnimationFrame(this.#m)},window.requestAnimationFrame(this.#m)}#S(t,e){const[s,i]=this.currentPath.at(-1);if(this.currentPath.length>1&&t===s&&e===i)return;const n=this.currentPath;let r=this.#h;if(n.push([t,e]),this.#d=!0,n.length<=2)return r.moveTo(...n[0]),void r.lineTo(t,e);n.length===3&&(this.#h=r=new Path2D,r.moveTo(...n[0])),this.#y(r,...n.at(-3),...n.at(-2),t,e)}#C(){if(this.currentPath.length===0)return;const t=this.currentPath.at(-1);this.#h.lineTo(...t)}#T(t,e){let s;if(this.#m=null,t=Math.min(Math.max(t,0),this.canvas.width),e=Math.min(Math.max(e,0),this.canvas.height),this.#S(t,e),this.#C(),this.currentPath.length!==1)s=this.#v();else{const r=[t,e];s=[[r,r.slice(),r.slice(),r]]}const i=this.#h,n=this.currentPath;this.currentPath=[],this.#h=new Path2D,this.addCommands({cmd:()=>{this.allRawPaths.push(n),this.paths.push(s),this.bezierPath2D.push(i),this._uiManager.rebuild(this)},undo:()=>{this.allRawPaths.pop(),this.paths.pop(),this.bezierPath2D.pop(),this.paths.length===0?this.remove():(this.canvas||(this.#M(),this.#L()),this.#N())},mustExec:!0})}#E(){if(!this.#d)return;this.#d=!1,Math.ceil(this.thickness*this.parentScale);const t=this.currentPath.slice(-3),e=t.map(n=>n[0]),s=t.map(n=>n[1]);Math.min(...e),Math.max(...e),Math.min(...s),Math.max(...s);const{ctx:i}=this;i.save(),i.clearRect(0,0,this.canvas.width,this.canvas.height);for(const n of this.bezierPath2D)i.stroke(n);i.stroke(this.#h),i.restore()}#y(t,e,s,i,n,r,a){const o=(e+i)/2,h=(s+n)/2,c=(i+r)/2,d=(n+a)/2;t.bezierCurveTo(o+2*(i-o)/3,h+2*(n-h)/3,c+2*(i-c)/3,d+2*(n-d)/3,c,d)}#v(){const t=this.currentPath;if(t.length<=2)return[[t[0],t[0],t.at(-1),t.at(-1)]];const e=[];let s,[i,n]=t[0];for(s=1;s<t.length-2;s++){const[u,p]=t[s],[g,f]=t[s+1],v=(u+g)/2,m=(p+f)/2,b=[i+2*(u-i)/3,n+2*(p-n)/3],A=[v+2*(u-v)/3,m+2*(p-m)/3];e.push([[i,n],b,A,[v,m]]),[i,n]=[v,m]}const[r,a]=t[s],[o,h]=t[s+1],c=[i+2*(r-i)/3,n+2*(a-n)/3],d=[o+2*(r-o)/3,h+2*(a-h)/3];return e.push([[i,n],c,d,[o,h]]),e}#_(){if(this.isEmpty())return void this.#I();this.#w();const{canvas:t,ctx:e}=this;e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height),this.#I();for(const s of this.bezierPath2D)e.stroke(s)}commit(){this.#c||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),this.#c=!0,this.div.classList.add("disabled"),this.#N(!0),this.select(),this.parent.addInkEditorIfNeeded(!0),this.moveInDOM(),this.div.focus({preventScroll:!0}))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),this.enableEditMode())}canvasPointerdown(t){t.button===0&&this.isInEditMode()&&!this.#c&&(this.setInForeground(),t.preventDefault(),this.div.contains(document.activeElement)||this.div.focus({preventScroll:!0}),this.#x(t.offsetX,t.offsetY))}canvasPointermove(t){t.preventDefault(),this.#S(t.offsetX,t.offsetY)}canvasPointerup(t){t.preventDefault(),this.#k(t)}canvasPointerleave(t){this.#k(t)}#k(t){this.canvas.removeEventListener("pointerleave",this.#n),this.canvas.removeEventListener("pointermove",this.#s),this.canvas.removeEventListener("pointerup",this.#o),this.canvas.addEventListener("pointerdown",this.#i,{signal:this._uiManager._signal}),this.#r&&clearTimeout(this.#r),this.#r=setTimeout(()=>{this.#r=null,this.canvas.removeEventListener("contextmenu",gt)},10),this.#T(t.offsetX,t.offsetY),this.addToAnnotationStorage(),this.setInBackground()}#M(){this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=0,this.canvas.className="inkEditorCanvas",this.canvas.setAttribute("data-l10n-id","pdfjs-ink-canvas"),this.div.append(this.canvas),this.ctx=this.canvas.getContext("2d")}#L(){this.#l=new ResizeObserver(t=>{const e=t[0].contentRect;e.width&&e.height&&this.setDimensions(e.width,e.height)}),this.#l.observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{this.#l?.disconnect(),this.#l=null},{once:!0})}get isResizable(){return!this.isEmpty()&&this.#c}render(){if(this.div)return this.div;let t,e;this.width&&(t=this.x,e=this.y),super.render(),this.div.setAttribute("data-l10n-id","pdfjs-ink");const[s,i,n,r]=this.#A();if(this.setAt(s,i,0,0),this.setDims(n,r),this.#M(),this.width){const[a,o]=this.parentDimensions;this.setAspectRatio(this.width*a,this.height*o),this.setAt(t*a,e*o,this.width*a,this.height*o),this.#p=!0,this.#P(),this.setDims(this.width*a,this.height*o),this.#_(),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return this.#L(),this.div}#P(){if(!this.#p)return;const[t,e]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*t),this.canvas.height=Math.ceil(this.height*e),this.#I()}setDimensions(t,e){const s=Math.round(t),i=Math.round(e);if(this.#a===s&&this.#g===i)return;this.#a=s,this.#g=i,this.canvas.style.visibility="hidden";const[n,r]=this.parentDimensions;this.width=t/n,this.height=e/r,this.fixAndSetPosition(),this.#c&&this.#F(t,e),this.#P(),this.#_(),this.canvas.style.visibility="visible",this.fixDims()}#F(t,e){const s=this.#H(),i=(t-s)/this.#e,n=(e-s)/this.#t;this.scaleFactor=Math.min(i,n)}#I(){const t=this.#H()/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+t,this.translationY*this.scaleFactor+t)}static#O(t){const e=new Path2D;for(let s=0,i=t.length;s<i;s++){const[n,r,a,o]=t[s];s===0&&e.moveTo(...n),e.bezierCurveTo(r[0],r[1],a[0],a[1],o[0],o[1])}return e}static#D(t,e,s){const[i,n,r,a]=e;switch(s){case 0:for(let o=0,h=t.length;o<h;o+=2)t[o]+=i,t[o+1]=a-t[o+1];break;case 90:for(let o=0,h=t.length;o<h;o+=2){const c=t[o];t[o]=t[o+1]+i,t[o+1]=c+n}break;case 180:for(let o=0,h=t.length;o<h;o+=2)t[o]=r-t[o],t[o+1]+=n;break;case 270:for(let o=0,h=t.length;o<h;o+=2){const c=t[o];t[o]=r-t[o+1],t[o+1]=a-c}break;default:throw new Error("Invalid rotation")}return t}static#G(t,e,s){const[i,n,r,a]=e;switch(s){case 0:for(let o=0,h=t.length;o<h;o+=2)t[o]-=i,t[o+1]=a-t[o+1];break;case 90:for(let o=0,h=t.length;o<h;o+=2){const c=t[o];t[o]=t[o+1]-n,t[o+1]=c-i}break;case 180:for(let o=0,h=t.length;o<h;o+=2)t[o]=r-t[o],t[o+1]-=n;break;case 270:for(let o=0,h=t.length;o<h;o+=2){const c=t[o];t[o]=a-t[o+1],t[o+1]=r-c}break;default:throw new Error("Invalid rotation")}return t}#U(t,e,s,i){const n=[],r=this.thickness/2,a=t*e+r,o=t*s+r;for(const h of this.paths){const c=[],d=[];for(let u=0,p=h.length;u<p;u++){const[g,f,v,m]=h[u];if(g[0]===m[0]&&g[1]===m[1]&&p===1){const I=t*g[0]+a,M=t*g[1]+o;c.push(I,M),d.push(I,M);break}const b=t*g[0]+a,A=t*g[1]+o,w=t*f[0]+a,_=t*f[1]+o,y=t*v[0]+a,E=t*v[1]+o,S=t*m[0]+a,C=t*m[1]+o;u===0&&(c.push(b,A),d.push(b,A)),c.push(w,_,y,E,S,C),d.push(w,_),u===p-1&&d.push(S,C)}n.push({bezier:ot.#D(c,i,this.rotation),points:ot.#D(d,i,this.rotation)})}return n}#z(){let t=1/0,e=-1/0,s=1/0,i=-1/0;for(const n of this.paths)for(const[r,a,o,h]of n){const c=k.bezierBoundingBox(...r,...a,...o,...h);t=Math.min(t,c[0]),s=Math.min(s,c[1]),e=Math.max(e,c[2]),i=Math.max(i,c[3])}return[t,s,e,i]}#H(){return this.#c?Math.ceil(this.thickness*this.parentScale):0}#N(t=!1){if(this.isEmpty())return;if(!this.#c)return void this.#_();const e=this.#z(),s=this.#H();this.#e=Math.max(P.MIN_SIZE,e[2]-e[0]),this.#t=Math.max(P.MIN_SIZE,e[3]-e[1]);const i=Math.ceil(s+this.#e*this.scaleFactor),n=Math.ceil(s+this.#t*this.scaleFactor),[r,a]=this.parentDimensions;this.width=i/r,this.height=n/a,this.setAspectRatio(i,n);const o=this.translationX,h=this.translationY;this.translationX=-e[0],this.translationY=-e[1],this.#P(),this.#_(),this.#a=i,this.#g=n,this.setDims(i,n);const c=t?s/this.scaleFactor/2:0;this.translate(o-this.translationX-c,h-this.translationY-c)}static deserialize(t,e,s){if(t instanceof Gi)return null;const i=super.deserialize(t,e,s);i.thickness=t.thickness,i.color=k.makeHexColor(...t.color),i.opacity=t.opacity;const[n,r]=i.pageDimensions,a=i.width*n,o=i.height*r,h=i.parentScale,c=t.thickness/2;i.#c=!0,i.#a=Math.round(a),i.#g=Math.round(o);const{paths:d,rect:u,rotation:p}=t;for(let{bezier:f}of d){f=ot.#G(f,u,p);const v=[];i.paths.push(v);let m=h*(f[0]-c),b=h*(f[1]-c);for(let w=2,_=f.length;w<_;w+=6){const y=h*(f[w]-c),E=h*(f[w+1]-c),S=h*(f[w+2]-c),C=h*(f[w+3]-c),I=h*(f[w+4]-c),M=h*(f[w+5]-c);v.push([[m,b],[y,E],[S,C],[I,M]]),m=I,b=M}const A=this.#O(v);i.bezierPath2D.push(A)}const g=i.#z();return i.#e=Math.max(P.MIN_SIZE,g[2]-g[0]),i.#t=Math.max(P.MIN_SIZE,g[3]-g[1]),i.#F(a,o),i}serialize(){if(this.isEmpty())return null;const t=this.getRect(0,0),e=P._colorManager.convert(this.ctx.strokeStyle);return{annotationType:j.INK,color:e,thickness:this.thickness,opacity:this.opacity,paths:this.#U(this.scaleFactor/this.parentScale,this.translationX,this.translationY,t),pageIndex:this.pageIndex,rect:t,rotation:this.rotation,structTreeParentId:this._structTreeParentId}}}class Fs extends P{#t=null;#e=null;#s=null;#n=null;#o=null;#i="";#r=null;#h=null;#c=null;#d=!1;#p=!1;static _type="stamp";static _editorType=j.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#n=t.bitmapUrl,this.#o=t.bitmapFile}static initialize(t,e){P.initialize(t,e)}static get supportedTypes(){return z(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(t=>`image/${t}`))}static get supportedTypesStr(){return z(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,e){e.pasteEditor(j.STAMP,{bitmapFile:t.getAsFile()})}#l(t,e=!1){t?(this.#t=t.bitmap,e||(this.#e=t.id,this.#d=t.isSvg),t.file&&(this.#i=t.file.name),this.#m()):this.remove()}#a(){this.#s=null,this._uiManager.enableWaiting(!1),this.#r&&this.div.focus()}#g(){if(this.#e)return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(this.#e).then(s=>this.#l(s,!0)).finally(()=>this.#a());if(this.#n){const s=this.#n;return this.#n=null,this._uiManager.enableWaiting(!0),void(this.#s=this._uiManager.imageManager.getFromUrl(s).then(i=>this.#l(i)).finally(()=>this.#a()))}if(this.#o){const s=this.#o;return this.#o=null,this._uiManager.enableWaiting(!0),void(this.#s=this._uiManager.imageManager.getFromFile(s).then(i=>this.#l(i)).finally(()=>this.#a()))}const t=document.createElement("input");t.type="file",t.accept=Fs.supportedTypesStr;const e=this._uiManager._signal;this.#s=new Promise(s=>{t.addEventListener("change",async()=>{if(t.files&&t.files.length!==0){this._uiManager.enableWaiting(!0);const i=await this._uiManager.imageManager.getFromFile(t.files[0]);this.#l(i)}else this.remove();s()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),s()},{signal:e})}).finally(()=>this.#a()),t.click()}remove(){this.#e&&(this.#t=null,this._uiManager.imageManager.deleteId(this.#e),this.#r?.remove(),this.#r=null,this.#h?.disconnect(),this.#h=null,this.#c&&(clearTimeout(this.#c),this.#c=null)),super.remove()}rebuild(){this.parent?(super.rebuild(),this.div!==null&&(this.#e&&this.#r===null&&this.#g(),this.isAttachedToDOM||this.parent.add(this))):this.#e&&this.#g()}onceAdded(){this._isDraggable=!0,this.div.focus()}isEmpty(){return!(this.#s||this.#t||this.#n||this.#o||this.#e)}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;if(this.width&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.addAltTextButton(),this.#t?this.#m():this.#g(),this.width){const[s,i]=this.parentDimensions;this.setAt(t*s,e*i,this.width*s,this.height*i)}return this.div}#m(){const{div:t}=this;let{width:e,height:s}=this.#t;const[i,n]=this.pageDimensions,r=.75;if(this.width)e=this.width*i,s=this.height*n;else if(e>r*i||s>r*n){const c=Math.min(r*i/e,r*n/s);e*=c,s*=c}const[a,o]=this.parentDimensions;this.setDims(e*a/i,s*o/n),this._uiManager.enableWaiting(!1);const h=this.#r=document.createElement("canvas");t.append(h),t.hidden=!1,this.#f(e,s),this.#w(),this.#p||(this.parent.addUndoableEditor(this),this.#p=!0),this._reportTelemetry({action:"inserted_image"}),this.#i&&h.setAttribute("aria-label",this.#i)}#u(t,e){const[s,i]=this.parentDimensions;this.width=t/s,this.height=e/i,this.setDims(t,e),this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this.#c!==null&&clearTimeout(this.#c),this.#c=setTimeout(()=>{this.#c=null,this.#f(t,e)},200)}#b(t,e){const{width:s,height:i}=this.#t;let n=s,r=i,a=this.#t;for(;n>2*t||r>2*e;){const o=n,h=r;n>2*t&&(n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2)),r>2*e&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2));const c=new OffscreenCanvas(n,r);c.getContext("2d").drawImage(a,0,0,o,h,0,0,n,r),a=c.transferToImageBitmap()}return a}#f(t,e){t=Math.ceil(t),e=Math.ceil(e);const s=this.#r;if(!s||s.width===t&&s.height===e)return;s.width=t,s.height=e;const i=this.#d?this.#t:this.#b(t,e);if(this._uiManager.hasMLManager&&!this.hasAltText()){const r=new OffscreenCanvas(t,e).getContext("2d");r.drawImage(i,0,0,i.width,i.height,0,0,t,e),this._uiManager.mlGuess({service:"image-to-text",request:{data:r.getImageData(0,0,t,e).data,width:t,height:e,channels:4}}).then(a=>{const o=a?.output||"";this.parent&&o&&!this.hasAltText()&&(this.altTextData={altText:o,decorative:!1})})}const n=s.getContext("2d");n.filter=this._uiManager.hcmFilter,n.drawImage(i,0,0,i.width,i.height,0,0,t,e)}getImageForAltText(){return this.#r}#A(t){if(t){if(this.#d){const s=this._uiManager.imageManager.getSvgUrl(this.#e);if(s)return s}const e=document.createElement("canvas");return{width:e.width,height:e.height}=this.#t,e.getContext("2d").drawImage(this.#t,0,0),e.toDataURL()}if(this.#d){const[e,s]=this.pageDimensions,i=Math.round(this.width*e*ae.PDF_TO_CSS_UNITS),n=Math.round(this.height*s*ae.PDF_TO_CSS_UNITS),r=new OffscreenCanvas(i,n);return r.getContext("2d").drawImage(this.#t,0,0,this.#t.width,this.#t.height,0,0,i,n),r.transferToImageBitmap()}return structuredClone(this.#t)}#w(){this._uiManager._signal&&(this.#h=new ResizeObserver(t=>{const e=t[0].contentRect;e.width&&e.height&&this.#u(e.width,e.height)}),this.#h.observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{this.#h?.disconnect(),this.#h=null},{once:!0}))}static deserialize(t,e,s){if(t instanceof Ui)return null;const i=super.deserialize(t,e,s),{rect:n,bitmapUrl:r,bitmapId:a,isSvg:o,accessibilityData:h}=t;a&&s.imageManager.isValidId(a)?i.#e=a:i.#n=r,i.#d=o;const[c,d]=i.pageDimensions;return i.width=(n[2]-n[0])/c,i.height=(n[3]-n[1])/d,h&&(i.altTextData=h),i}serialize(t=!1,e=null){if(this.isEmpty())return null;const s={annotationType:j.STAMP,bitmapId:this.#e,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#d,structTreeParentId:this._structTreeParentId};if(t)return s.bitmapUrl=this.#A(!0),s.accessibilityData=this.altTextData,s;const{decorative:i,altText:n}=this.altTextData;if(!i&&n&&(s.accessibilityData={type:"Figure",alt:n}),e===null)return s;e.stamps||=new Map;const r=this.#d?(s.rect[2]-s.rect[0])*(s.rect[3]-s.rect[1]):null;if(e.stamps.has(this.#e)){if(this.#d){const a=e.stamps.get(this.#e);r>a.area&&(a.area=r,a.serialized.bitmap.close(),a.serialized.bitmap=this.#A(!1))}}else e.stamps.set(this.#e,{area:r,serialized:s}),s.bitmap=this.#A(!1);return s}}class Pt{#t;#e=!1;#s=null;#n=null;#o=null;#i=null;#r=null;#h=new Map;#c=!1;#d=!1;#p=!1;#l=null;#a;static _initialized=!1;static#g=new Map([it,ot,Fs,st].map(t=>[t._editorType,t]));constructor({uiManager:t,pageIndex:e,div:s,accessibilityManager:i,annotationLayer:n,drawLayer:r,textLayer:a,viewport:o,l10n:h}){const c=[...Pt.#g.values()];if(!Pt._initialized){Pt._initialized=!0;for(const d of c)d.initialize(h,t)}t.registerEditorTypes(c),this.#a=t,this.pageIndex=e,this.div=s,this.#t=i,this.#s=n,this.viewport=o,this.#l=a,this.drawLayer=r,this.#a.addLayer(this)}get isEmpty(){return this.#h.size===0}get isInvisible(){return this.isEmpty&&this.#a.getMode()===j.NONE}updateToolbar(t){this.#a.updateToolbar(t)}updateMode(t=this.#a.getMode()){switch(this.#A(),t){case j.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case j.INK:this.addInkEditorIfNeeded(!1),this.disableTextSelection(),this.togglePointerEvents(!0),this.disableClick();break;case j.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;for(const s of Pt.#g.values())e.toggle(`${s._type}Editing`,t===s._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#l?.div}addInkEditorIfNeeded(t){if(this.#a.getMode()===j.INK){if(!t){for(const e of this.#h.values())if(e.isEmpty())return void e.setInBackground()}this.createAndAddNewEditor({offsetX:0,offsetY:0},!1).setInBackground()}}setEditingState(t){this.#a.setEditingState(t)}addCommands(t){this.#a.addCommands(t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#s?.div.classList.toggle("disabled",!t)}enable(){this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const s of this.#h.values())s.enableEditing(),s.show(!0),s.annotationElementId&&(this.#a.removeChangedExistingAnnotation(s),t.add(s.annotationElementId));if(!this.#s)return;const e=this.#s.getEditableAnnotations();for(const s of e){if(s.hide(),this.#a.isDeletedAnnotationElement(s.data.id)||t.has(s.data.id))continue;const i=this.deserialize(s);i&&(this.addOrRebuild(i),i.enableEditing())}}disable(){this.#p=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);const t=new Map,e=new Map;for(const i of this.#h.values())i.disableEditing(),i.annotationElementId&&(i.serialize()===null?(e.set(i.annotationElementId,i),this.getEditableAnnotation(i.annotationElementId)?.show(),i.remove()):t.set(i.annotationElementId,i));if(this.#s){const i=this.#s.getEditableAnnotations();for(const n of i){const{id:r}=n.data;if(this.#a.isDeletedAnnotationElement(r))continue;let a=e.get(r);a?(a.resetAnnotationElement(n),a.show(!1),n.show()):(a=t.get(r),a&&(this.#a.addChangedExistingAnnotation(a),a.renderAnnotationElement(n),a.show(!1)),n.show())}}this.#A(),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const i of Pt.#g.values())s.remove(`${i._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#p=!1}getEditableAnnotation(t){return this.#s?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#a.getActive()!==t&&this.#a.setActiveEditor(t)}enableTextSelection(){this.div.tabIndex=-1,this.#l?.div&&!this.#i&&(this.#i=this.#m.bind(this),this.#l.div.addEventListener("pointerdown",this.#i,{signal:this.#a._signal}),this.#l.div.classList.add("highlighting"))}disableTextSelection(){this.div.tabIndex=0,this.#l?.div&&this.#i&&(this.#l.div.removeEventListener("pointerdown",this.#i),this.#i=null,this.#l.div.classList.remove("highlighting"))}#m(t){if(this.#a.unselectAll(),t.target===this.#l.div){const{isMac:e}=pt.platform;if(t.button!==0||t.ctrlKey&&e)return;this.#a.showAllEditors("highlight",!0,!0),this.#l.div.classList.add("free"),st.startHighlighting(this,this.#a.direction==="ltr",t),this.#l.div.addEventListener("pointerup",()=>{this.#l.div.classList.remove("free")},{once:!0,signal:this.#a._signal}),t.preventDefault()}}enableClick(){if(this.#o)return;const t=this.#a._signal;this.#o=this.pointerdown.bind(this),this.#n=this.pointerup.bind(this),this.div.addEventListener("pointerdown",this.#o,{signal:t}),this.div.addEventListener("pointerup",this.#n,{signal:t})}disableClick(){this.#o&&(this.div.removeEventListener("pointerdown",this.#o),this.div.removeEventListener("pointerup",this.#n),this.#o=null,this.#n=null)}attach(t){this.#h.set(t.id,t);const{annotationElementId:e}=t;e&&this.#a.isDeletedAnnotationElement(e)&&this.#a.removeDeletedAnnotationElement(t)}detach(t){this.#h.delete(t.id),this.#t?.removePointerInTextLayer(t.contentDiv),!this.#p&&t.annotationElementId&&this.#a.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#a.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1,this.#d||this.addInkEditorIfNeeded(!1)}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#a.addDeletedAnnotationElement(t.annotationElementId),P.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.#a.addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(),this.#a.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!this.#r&&(t._focusEventsAllowed=!1,this.#r=setTimeout(()=>{this.#r=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#a._signal}),e.focus())},0)),t._structTreeParentId=this.#t?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getNextId(){return this.#a.getId()}get#u(){return Pt.#g.get(this.#a.getMode())}get _signal(){return this.#a._signal}#b(t){const e=this.#u;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#u?.canCreateNewEmptyEditor()}pasteEditor(t,e){this.#a.updateToolbar(t),this.#a.updateMode(t);const{offsetX:s,offsetY:i}=this.#f(),n=this.getNextId(),r=this.#b({parent:this,id:n,x:s,y:i,uiManager:this.#a,isCentered:!0,...e});r&&this.add(r)}deserialize(t){return Pt.#g.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#a)||null}createAndAddNewEditor(t,e,s={}){const i=this.getNextId(),n=this.#b({parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:this.#a,isCentered:e,...s});return n&&this.add(n),n}#f(){const{x:t,y:e,width:s,height:i}=this.div.getBoundingClientRect(),n=Math.max(0,t),r=Math.max(0,e),a=(n+Math.min(window.innerWidth,t+s))/2-t,o=(r+Math.min(window.innerHeight,e+i))/2-e,[h,c]=this.viewport.rotation%180==0?[a,o]:[o,a];return{offsetX:h,offsetY:c}}addNewEditor(){this.createAndAddNewEditor(this.#f(),!0)}setSelected(t){this.#a.setSelected(t)}toggleSelected(t){this.#a.toggleSelected(t)}isSelected(t){return this.#a.isSelected(t)}unselect(t){this.#a.unselect(t)}pointerup(t){const{isMac:e}=pt.platform;t.button!==0||t.ctrlKey&&e||t.target===this.div&&this.#c&&(this.#c=!1,this.#e?this.#a.getMode()!==j.STAMP?this.createAndAddNewEditor(t,!1):this.#a.unselectAll():this.#e=!0)}pointerdown(t){if(this.#a.getMode()===j.HIGHLIGHT&&this.enableTextSelection(),this.#c)return void(this.#c=!1);const{isMac:e}=pt.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;this.#c=!0;const s=this.#a.getActive();this.#e=!s||s.isEmpty()}findNewParent(t,e,s){const i=this.#a.findParent(e,s);return i!==null&&i!==this&&(i.changeParent(t),!0)}destroy(){this.#a.getActive()?.parent===this&&(this.#a.commitOrRemove(),this.#a.setActiveEditor(null)),this.#r&&(clearTimeout(this.#r),this.#r=null);for(const t of this.#h.values())this.#t?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#h.clear(),this.#a.removeLayer(this)}#A(){this.#d=!0;for(const t of this.#h.values())t.isEmpty()&&t.remove();this.#d=!1}render({viewport:t}){this.viewport=t,Gt(this.div,t);for(const e of this.#a.getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){this.#a.commitOrRemove(),this.#A();const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,Gt(this.div,{rotation:s}),e!==s)for(const i of this.#h.values())i.rotate(s);this.addInkEditorIfNeeded(!1)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#a.viewParameters.realScale}}class ct{#t=null;#e=0;#s=new Map;#n=new Map;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(this.#t){if(this.#t!==t){if(this.#s.size>0)for(const e of this.#s.values())e.remove(),t.append(e);this.#t=t}}else this.#t=t}static get _svgFactory(){return z(this,"_svgFactory",new _s)}static#o(t,{x:e=0,y:s=0,width:i=1,height:n=1}={}){const{style:r}=t;r.top=100*s+"%",r.left=100*e+"%",r.width=100*i+"%",r.height=100*n+"%"}#i(t){const e=ct._svgFactory.create(1,1,!0);return this.#t.append(e),e.setAttribute("aria-hidden",!0),ct.#o(e,t),e}#r(t,e){const s=ct._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const n=ct._svgFactory.createElement("use");return s.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),i}highlight(t,e,s,i=!1){const n=this.#e++,r=this.#i(t.box);r.classList.add("highlight"),t.free&&r.classList.add("free");const a=ct._svgFactory.createElement("defs");r.append(a);const o=ct._svgFactory.createElement("path");a.append(o);const h=`path_p${this.pageIndex}_${n}`;o.setAttribute("id",h),o.setAttribute("d",t.toSVGPath()),i&&this.#n.set(n,o);const c=this.#r(a,h),d=ct._svgFactory.createElement("use");return r.append(d),r.setAttribute("fill",e),r.setAttribute("fill-opacity",s),d.setAttribute("href",`#${h}`),this.#s.set(n,r),{id:n,clipPathId:`url(#${c})`}}highlightOutline(t){const e=this.#e++,s=this.#i(t.box);s.classList.add("highlightOutline");const i=ct._svgFactory.createElement("defs");s.append(i);const n=ct._svgFactory.createElement("path");i.append(n);const r=`path_p${this.pageIndex}_${e}`;let a;if(n.setAttribute("id",r),n.setAttribute("d",t.toSVGPath()),n.setAttribute("vector-effect","non-scaling-stroke"),t.free){s.classList.add("free");const c=ct._svgFactory.createElement("mask");i.append(c),a=`mask_p${this.pageIndex}_${e}`,c.setAttribute("id",a),c.setAttribute("maskUnits","objectBoundingBox");const d=ct._svgFactory.createElement("rect");c.append(d),d.setAttribute("width","1"),d.setAttribute("height","1"),d.setAttribute("fill","white");const u=ct._svgFactory.createElement("use");c.append(u),u.setAttribute("href",`#${r}`),u.setAttribute("stroke","none"),u.setAttribute("fill","black"),u.setAttribute("fill-rule","nonzero"),u.classList.add("mask")}const o=ct._svgFactory.createElement("use");s.append(o),o.setAttribute("href",`#${r}`),a&&o.setAttribute("mask",`url(#${a})`);const h=o.cloneNode();return s.append(h),o.classList.add("mainOutline"),h.classList.add("secondaryOutline"),this.#s.set(e,s),e}finalizeLine(t,e){const s=this.#n.get(t);this.#n.delete(t),this.updateBox(t,e.box),s.setAttribute("d",e.toSVGPath())}updateLine(t,e){this.#s.get(t).firstChild.firstChild.setAttribute("d",e.toSVGPath())}removeFreeHighlight(t){this.remove(t),this.#n.delete(t)}updatePath(t,e){this.#n.get(t).setAttribute("d",e.toSVGPath())}updateBox(t,e){ct.#o(this.#s.get(t),e)}show(t,e){this.#s.get(t).classList.toggle("hidden",!e)}rotate(t,e){this.#s.get(t).setAttribute("data-main-rotation",e)}changeColor(t,e){this.#s.get(t).setAttribute("fill",e)}changeOpacity(t,e){this.#s.get(t).setAttribute("fill-opacity",e)}addClass(t,e){this.#s.get(t).classList.add(e)}removeClass(t,e){this.#s.get(t).classList.remove(e)}remove(t){this.#t!==null&&(this.#s.get(t).remove(),this.#s.delete(t))}destroy(){this.#t=null;for(const t of this.#s.values())t.remove();this.#s.clear()}}var Sa=T.AbortException,Ca=T.AnnotationEditorLayer,ka=T.AnnotationEditorParamsType,Ma=T.AnnotationEditorType,Ra=T.AnnotationEditorUIManager,Wi=T.AnnotationLayer,Xi=T.AnnotationMode,Ta=T.CMapCompressionType,Pa=T.ColorPicker,La=T.DOMSVGFactory,Ia=T.DrawLayer,Da=T.FeatureTest,Ki=T.GlobalWorkerOptions,Fa=T.ImageKind,Oa=T.InvalidPDFException,Na=T.MissingPDFException,ja=T.OPS,Ba=T.Outliner,Ha=T.PDFDataRangeTransport,$a=T.PDFDateString,za=T.PDFWorker,Va=T.PasswordResponses,Ga=T.PermissionFlag,Ua=T.PixelsPerInch,qa=T.RenderingCancelledException,Yi=T.TextLayer,Wa=T.UnexpectedResponseException,Xa=T.Util,Ka=T.VerbosityLevel,Ya=T.XfaLayer,Qa=T.build,Ja=T.createValidAbsoluteUrl,Za=T.fetchData,Qi=T.getDocument,to=T.getFilenameFromUrl,eo=T.getPdfFilenameFromUrl,so=T.getXfaPageViewport,io=T.isDataScheme,no=T.isPdfFile,ro=T.noContextMenu,ao=T.normalizeUnicode,oo=T.renderTextLayer,ho=T.setLayerDimensions,lo=T.shadow,co=T.updateTextLayer,uo=T.version;const Ji=Object.freeze(Object.defineProperty({__proto__:null,AbortException:Sa,AnnotationEditorLayer:Ca,AnnotationEditorParamsType:ka,AnnotationEditorType:Ma,AnnotationEditorUIManager:Ra,AnnotationLayer:Wi,AnnotationMode:Xi,CMapCompressionType:Ta,ColorPicker:Pa,DOMSVGFactory:La,DrawLayer:Ia,FeatureTest:Da,GlobalWorkerOptions:Ki,ImageKind:Fa,InvalidPDFException:Oa,MissingPDFException:Na,OPS:ja,Outliner:Ba,PDFDataRangeTransport:Ha,PDFDateString:$a,PDFWorker:za,PasswordResponses:Va,PermissionFlag:Ga,PixelsPerInch:Ua,RenderingCancelledException:qa,TextLayer:Yi,UnexpectedResponseException:Wa,Util:Xa,VerbosityLevel:Ka,XfaLayer:Ya,build:Qa,createValidAbsoluteUrl:Ja,fetchData:Za,getDocument:Qi,getFilenameFromUrl:to,getPdfFilenameFromUrl:eo,getXfaPageViewport:so,isDataScheme:io,isPdfFile:no,noContextMenu:ro,normalizeUnicode:ao,renderTextLayer:oo,setLayerDimensions:ho,shadow:lo,updateTextLayer:co,version:uo},Symbol.toStringTag,{value:"Module"}));var ri,ai,at=function(l,t,e){if(e||arguments.length===2)for(var s,i=0,n=t.length;i<n;i++)!s&&i in t||(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return l.concat(s||Array.prototype.slice.call(t))},po=at(at(at(at(at(at(at(at(at(at(at(at(at(at(at(at(at(at([],["onCopy","onCut","onPaste"],!0),["onCompositionEnd","onCompositionStart","onCompositionUpdate"],!0),["onFocus","onBlur"],!0),["onInput","onInvalid","onReset","onSubmit"],!0),["onLoad","onError"],!0),["onKeyDown","onKeyPress","onKeyUp"],!0),["onAbort","onCanPlay","onCanPlayThrough","onDurationChange","onEmptied","onEncrypted","onEnded","onError","onLoadedData","onLoadedMetadata","onLoadStart","onPause","onPlay","onPlaying","onProgress","onRateChange","onSeeked","onSeeking","onStalled","onSuspend","onTimeUpdate","onVolumeChange","onWaiting"],!0),["onClick","onContextMenu","onDoubleClick","onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseOut","onMouseOver","onMouseUp"],!0),["onDrag","onDragEnd","onDragEnter","onDragExit","onDragLeave","onDragOver","onDragStart","onDrop"],!0),["onSelect"],!0),["onTouchCancel","onTouchEnd","onTouchMove","onTouchStart"],!0),["onPointerDown","onPointerMove","onPointerUp","onPointerCancel","onGotPointerCapture","onLostPointerCapture","onPointerEnter","onPointerLeave","onPointerOver","onPointerOut"],!0),["onScroll"],!0),["onWheel"],!0),["onAnimationStart","onAnimationEnd","onAnimationIteration"],!0),["onTransitionEnd"],!0),["onChange"],!0),["onToggle"],!0);function Os(l,t){var e={};return po.forEach(function(s){var i=l[s];i&&(e[s]=t?function(n){return i(n,t(s))}:i)}),e}function oe(l){var t=!1;return{promise:new Promise(function(e,s){l.then(function(i){return!t&&e(i)}).catch(function(i){return!t&&s(i)})}),cancel:function(){t=!0}}}const ht=fn(ai?ri:(ai=1,ri=function(){}));var oi=Object.prototype.hasOwnProperty;function hi(l,t,e){for(e of l.keys())if(se(e,t))return e}function se(l,t){var e,s,i;if(l===t)return!0;if(l&&t&&(e=l.constructor)===t.constructor){if(e===Date)return l.getTime()===t.getTime();if(e===RegExp)return l.toString()===t.toString();if(e===Array){if((s=l.length)===t.length)for(;s--&&se(l[s],t[s]););return s===-1}if(e===Set){if(l.size!==t.size)return!1;for(s of l)if((i=s)&&typeof i=="object"&&!(i=hi(t,i))||!t.has(i))return!1;return!0}if(e===Map){if(l.size!==t.size)return!1;for(s of l)if((i=s[0])&&typeof i=="object"&&!(i=hi(t,i))||!se(s[1],t.get(i)))return!1;return!0}if(e===ArrayBuffer)l=new Uint8Array(l),t=new Uint8Array(t);else if(e===DataView){if((s=l.byteLength)===t.byteLength)for(;s--&&l.getInt8(s)===t.getInt8(s););return s===-1}if(ArrayBuffer.isView(l)){if((s=l.byteLength)===t.byteLength)for(;s--&&l[s]===t[s];);return s===-1}if(!e||typeof l=="object"){for(e in s=0,l)if(oi.call(l,e)&&++s&&!oi.call(t,e)||!(e in t)||!se(l[e],t[e]))return!1;return Object.keys(t).length===s}}return l!=l&&t!=t}const Zi=x.createContext(null);function ie({children:l,type:t}){return G.jsx("div",{className:`react-pdf__message react-pdf__message--${t}`,children:l})}class go{constructor(){this.externalLinkEnabled=!0,this.externalLinkRel=void 0,this.externalLinkTarget=void 0,this.isInPresentationMode=!1,this.pdfDocument=void 0,this.pdfViewer=void 0}setDocument(t){this.pdfDocument=t}setViewer(t){this.pdfViewer=t}setExternalLinkRel(t){this.externalLinkRel=t}setExternalLinkTarget(t){this.externalLinkTarget=t}setHistory(){}get pagesCount(){return this.pdfDocument?this.pdfDocument.numPages:0}get page(){return $(this.pdfViewer),this.pdfViewer.currentPageNumber||0}set page(t){$(this.pdfViewer),this.pdfViewer.currentPageNumber=t}get rotation(){return 0}set rotation(t){}goToDestination(t){return new Promise(e=>{$(this.pdfDocument),$(t),typeof t=="string"?this.pdfDocument.getDestination(t).then(e):Array.isArray(t)?e(t):t.then(e)}).then(e=>{$(Array.isArray(e));const s=e[0];new Promise(i=>{$(this.pdfDocument),s instanceof Object?this.pdfDocument.getPageIndex(s).then(n=>{i(n)}).catch(()=>{$(!1)}):typeof s=="number"?i(s):$(!1)}).then(i=>{const n=i+1;$(this.pdfViewer),$(n>=1&&n<=this.pagesCount),this.pdfViewer.scrollPageIntoView({dest:e,pageIndex:i,pageNumber:n})})})}navigateTo(t){this.goToDestination(t)}goToPage(t){const e=t-1;$(this.pdfViewer),$(t>=1&&t<=this.pagesCount),this.pdfViewer.scrollPageIntoView({pageIndex:e,pageNumber:t})}addLinkAttributes(t,e,s){t.href=e,t.rel=this.externalLinkRel||"noopener noreferrer nofollow",t.target=s?"_blank":this.externalLinkTarget||""}getDestinationHash(){return"#"}getAnchorUrl(){return"#"}setHash(){}executeNamedAction(){}cachePageRef(){}isPageVisible(){return!0}isPageCached(){return!0}executeSetOCGState(){}}const ms={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},Oe=typeof window<"u",tn=Oe&&window.location.protocol==="file:";function en(l){return l!==void 0}function Ct(l){return en(l)&&l!==null}function vs(l){return function(t){return typeof t=="string"}(l)&&/^data:/.test(l)}function li(l){$(vs(l));const[t="",e=""]=l.split(",");return t.split(";").indexOf("base64")!==-1?atob(e):unescape(e)}function fo(){return Oe&&window.devicePixelRatio||1}const sn="On Chromium based browsers, you can use --allow-file-access-from-files flag for debugging purposes.";function ci(){ht(!tn,`Loading PDF as base64 strings/URLs may not work on protocols other than HTTP/HTTPS. ${sn}`)}function Bt(l){l?.cancel&&l.cancel()}function bs(l,t){return Object.defineProperty(l,"width",{get(){return this.view[2]*t},configurable:!0}),Object.defineProperty(l,"height",{get(){return this.view[3]*t},configurable:!0}),Object.defineProperty(l,"originalWidth",{get(){return this.view[2]},configurable:!0}),Object.defineProperty(l,"originalHeight",{get(){return this.view[3]},configurable:!0}),l}function mo(l,t){switch(t.type){case"RESOLVE":return{value:t.value,error:void 0};case"REJECT":return{value:!1,error:t.error};case"RESET":return{value:void 0,error:void 0};default:return l}}function qt(){return x.useReducer(mo,{value:void 0,error:void 0})}var vo=function(l,t,e,s){return new(e||(e=Promise))(function(i,n){function r(h){try{o(s.next(h))}catch(c){n(c)}}function a(h){try{o(s.throw(h))}catch(c){n(c)}}function o(h){var c;h.done?i(h.value):(c=h.value,c instanceof e?c:new e(function(d){d(c)})).then(r,a)}o((s=s.apply(l,t||[])).next())})},di=function(l,t){var e={};for(var s in l)Object.prototype.hasOwnProperty.call(l,s)&&t.indexOf(s)<0&&(e[s]=l[s]);if(l!=null&&typeof Object.getOwnPropertySymbols=="function"){var i=0;for(s=Object.getOwnPropertySymbols(l);i<s.length;i++)t.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(l,s[i])&&(e[s[i]]=l[s[i]])}return e};const{PDFDataRangeTransport:bo}=Ji,Ao=(l,t)=>{switch(t){case ms.NEED_PASSWORD:l(prompt("Enter the password to open this PDF file."));break;case ms.INCORRECT_PASSWORD:l(prompt("Invalid password. Please try again."));break}};function ui(l){return typeof l=="object"&&l!==null&&("data"in l||"range"in l||"url"in l)}const yo=x.forwardRef(function(l,t){var{children:e,className:s,error:i="Failed to load PDF file.",externalLinkRel:n,externalLinkTarget:r,file:a,inputRef:o,imageResourcesPath:h,loading:c="Loading PDF…",noData:d="No PDF file specified.",onItemClick:u,onLoadError:p,onLoadProgress:g,onLoadSuccess:f,onPassword:v=Ao,onSourceError:m,onSourceSuccess:b,options:A,renderMode:w,rotate:_}=l,y=di(l,["children","className","error","externalLinkRel","externalLinkTarget","file","inputRef","imageResourcesPath","loading","noData","onItemClick","onLoadError","onLoadProgress","onLoadSuccess","onPassword","onSourceError","onSourceSuccess","options","renderMode","rotate"]);const[E,S]=qt(),{value:C,error:I}=E,[M,W]=qt(),{value:D,error:B}=M,U=x.useRef(new go),Y=x.useRef([]),J=x.useRef(void 0),R=x.useRef(void 0);a&&a!==J.current&&ui(a)&&(ht(!se(a,J.current),`File prop passed to <Document /> changed, but it's equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "file" prop.`),J.current=a),A&&A!==R.current&&(ht(!se(A,R.current),`Options prop passed to <Document /> changed, but it's equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "options" prop.`),R.current=A);const F=x.useRef({scrollPageIntoView:X=>{const{dest:N,pageNumber:V,pageIndex:lt=V-1}=X;if(u)return void u({dest:N,pageIndex:lt,pageNumber:V});const rt=Y.current[lt];rt?rt.scrollIntoView():ht(!1,`An internal link leading to page ${V} was clicked, but neither <Document> was provided with onItemClick nor it was able to find the page within itself. Either provide onItemClick to <Document> and handle navigating by yourself or ensure that all pages are rendered within <Document>.`)}});x.useImperativeHandle(t,()=>({linkService:U,pages:Y,viewer:F}),[]),x.useEffect(function(){S({type:"RESET"})},[a,S]);const _t=x.useCallback(()=>vo(this,void 0,void 0,function*(){if(!a)return null;if(typeof a=="string")return vs(a)?{data:li(a)}:(ci(),{url:a});if(a instanceof bo)return{range:a};if(a instanceof ArrayBuffer)return{data:a};if(Oe&&function(X){return $(Oe),X instanceof Blob}(a))return{data:yield function(N){return new Promise((V,lt)=>{const rt=new FileReader;rt.onload=()=>{if(!rt.result)return lt(new Error("Error while reading a file."));V(rt.result)},rt.onerror=Q=>{if(!Q.target)return lt(new Error("Error while reading a file."));const{error:Mt}=Q.target;if(!Mt)return lt(new Error("Error while reading a file."));switch(Mt.code){case Mt.NOT_FOUND_ERR:return lt(new Error("Error while reading a file: File not found."));case Mt.SECURITY_ERR:return lt(new Error("Error while reading a file: Security error."));case Mt.ABORT_ERR:return lt(new Error("Error while reading a file: Aborted."));default:return lt(new Error("Error while reading a file."))}},rt.readAsArrayBuffer(N)})}(a)};if($(typeof a=="object"),$(ui(a)),"url"in a&&typeof a.url=="string"){if(vs(a.url)){const{url:X}=a,N=di(a,["url"]),V=li(X);return Object.assign({data:V},N)}ci()}return a}),[a]);x.useEffect(()=>{const X=oe(_t());return X.promise.then(N=>{S({type:"RESOLVE",value:N})}).catch(N=>{S({type:"REJECT",error:N})}),()=>{Bt(X)}},[_t,S]),x.useEffect(()=>{C!==void 0&&(C!==!1?b&&b():I&&(ht(!1,I.toString()),m&&m(I)))},[C]),x.useEffect(function(){W({type:"RESET"})},[W,C]),x.useEffect(function(){if(!C)return;const X=A?Object.assign(Object.assign({},C),A):C,N=Qi(X);g&&(N.onProgress=g),v&&(N.onPassword=v);const V=N,lt=V.promise.then(rt=>{W({type:"RESOLVE",value:rt})}).catch(rt=>{V.destroyed||W({type:"REJECT",error:rt})});return()=>{lt.finally(()=>V.destroy())}},[A,W,C]),x.useEffect(()=>{D!==void 0&&(D!==!1?D&&(f&&f(D),Y.current=new Array(D.numPages),U.current.setDocument(D)):B&&(ht(!1,B.toString()),p&&p(B)))},[D]),x.useEffect(function(){U.current.setViewer(F.current),U.current.setExternalLinkRel(n),U.current.setExternalLinkTarget(r)},[n,r]);const At=x.useCallback((X,N)=>{Y.current[X]=N},[]),tt=x.useCallback(X=>{delete Y.current[X]},[]),et=x.useMemo(()=>({imageResourcesPath:h,linkService:U.current,onItemClick:u,pdf:D,registerPage:At,renderMode:w,rotate:_,unregisterPage:tt}),[h,u,D,At,w,_,tt]),H=x.useMemo(()=>Os(y,()=>D),[y,D]);return G.jsx("div",Object.assign({className:re("react-pdf__Document",s),ref:o,style:{"--scale-factor":"1"}},H,{children:a?D==null?G.jsx(ie,{type:"loading",children:typeof c=="function"?c():c}):D===!1?G.jsx(ie,{type:"error",children:typeof i=="function"?i():i}):G.jsx(Zi.Provider,{value:et,children:e}):G.jsx(ie,{type:"no-data",children:typeof d=="function"?d():d})}))}),nn=x.createContext(null);class wo{constructor({num:t,gen:e}){this.num=t,this.gen=e}toString(){let t=`${this.num}R`;return this.gen!==0&&(t+=this.gen),t}}function ss(l){const t=x.useRef(void 0),e=t.current;return en(e)?()=>e:()=>{const s=l();return t.current=s,s}}function ne(){return x.useContext(Zi)}function rn(){return x.useContext(nn)}var pi=function(l,t,e,s){return new(e||(e=Promise))(function(i,n){function r(h){try{o(s.next(h))}catch(c){n(c)}}function a(h){try{o(s.throw(h))}catch(c){n(c)}}function o(h){var c;h.done?i(h.value):(c=h.value,c instanceof e?c:new e(function(d){d(c)})).then(r,a)}o((s=s.apply(l,t||[])).next())})},_o=function(l,t){var e={};for(var s in l)Object.prototype.hasOwnProperty.call(l,s)&&t.indexOf(s)<0&&(e[s]=l[s]);if(l!=null&&typeof Object.getOwnPropertySymbols=="function"){var i=0;for(s=Object.getOwnPropertySymbols(l);i<s.length;i++)t.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(l,s[i])&&(e[s[i]]=l[s[i]])}return e};function an(l){const t=ne(),e=rn();$(e);const s=Object.assign(Object.assign(Object.assign({},t),e),l),{item:i,linkService:n,onItemClick:r,pdf:a}=s,o=_o(s,["item","linkService","onItemClick","pdf"]);$(a);const h=ss(()=>typeof i.dest=="string"?a.getDestination(i.dest):i.dest),c=ss(()=>pi(this,void 0,void 0,function*(){const u=yield h();if(!u)throw new Error("Destination not found.");const[p]=u;return a.getPageIndex(new wo(p))})),d=ss(()=>pi(this,void 0,void 0,function*(){return(yield c())+1}));return G.jsxs("li",{children:[G.jsx("a",{href:"#",onClick:function(u){u.preventDefault(),$(r||n),r?Promise.all([h(),c(),d()]).then(([p,g,f])=>{r({dest:p,pageIndex:g,pageNumber:f})}):n&&n.goToDestination(i.dest)},children:i.title}),function(){if(!i.items||!i.items.length)return null;const{items:u}=i;return G.jsx("ul",{children:u.map((p,g)=>G.jsx(an,Object.assign({item:p,pdf:a},o),typeof p.dest=="string"?p.dest:g))})}()]})}var xo=function(l,t){var e={};for(var s in l)Object.prototype.hasOwnProperty.call(l,s)&&t.indexOf(s)<0&&(e[s]=l[s]);if(l!=null&&typeof Object.getOwnPropertySymbols=="function"){var i=0;for(s=Object.getOwnPropertySymbols(l);i<s.length;i++)t.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(l,s[i])&&(e[s[i]]=l[s[i]])}return e};function on(){for(var l=[],t=0;t<arguments.length;t++)l[t]=arguments[t];var e=l.filter(Boolean);return e.length<=1?e[0]||null:function(s){e.forEach(function(i){typeof i=="function"?i(s):i&&(i.current=s)})}}const hn=x.createContext(null),gi={Document:null,DocumentFragment:null,Part:"group",Sect:"group",Div:"group",Aside:"note",NonStruct:"none",P:null,H:"heading",Title:null,FENote:"note",Sub:"group",Lbl:null,Span:null,Em:null,Strong:null,Link:"link",Annot:"note",Form:"form",Ruby:null,RB:null,RT:null,RP:null,Warichu:null,WT:null,WP:null,L:"list",LI:"listitem",LBody:null,Table:"table",TR:"row",TH:"columnheader",TD:"cell",THead:"columnheader",TBody:null,TFoot:null,Caption:null,Figure:"figure",Formula:null,Artifact:null},Eo=/^H(\d+)$/;function qe(l){return"children"in l}function ln(l){return!!qe(l)&&l.children.length===1&&0 in l.children&&"id"in l.children[0]}function So(l){const t={};if(qe(l)){const{role:e}=l,s=e.match(Eo);if(s)t.role="heading",t["aria-level"]=Number(s[1]);else if(function(i){return i in gi}(e)){const i=gi[e];i&&(t.role=i)}}return t}function cn(l){const t={};if(qe(l)){if(l.alt!==void 0&&(t["aria-label"]=l.alt),l.lang!==void 0&&(t.lang=l.lang),ln(l)){const[e]=l.children;if(e){const s=cn(e);return Object.assign(Object.assign({},t),s)}}}else"id"in l&&(t["aria-owns"]=l.id);return t}function Co(l){return l?Object.assign(Object.assign({},So(l)),cn(l)):null}function dn({className:l,node:t}){const e=x.useMemo(()=>Co(t),[t]),s=x.useMemo(()=>qe(t)?ln(t)?null:t.children.map((i,n)=>G.jsx(dn,{node:i},n)):null,[t]);return G.jsx("span",Object.assign({className:l},e,{children:s}))}function ye(){return x.useContext(hn)}function ko(){const l=ye();$(l);const{onGetStructTreeError:t,onGetStructTreeSuccess:e}=l,[s,i]=qt(),{value:n,error:r}=s,{customTextRenderer:a,page:o}=l;return x.useEffect(function(){i({type:"RESET"})},[i,o]),x.useEffect(function(){if(a||!o)return;const h=oe(o.getStructTree()),c=h;return h.promise.then(d=>{i({type:"RESOLVE",value:d})}).catch(d=>{i({type:"REJECT",error:d})}),()=>Bt(c)},[a,o,i]),x.useEffect(()=>{n!==void 0&&(n!==!1?n&&e&&e(n):r&&(ht(!1,r.toString()),t&&t(r)))},[n]),n?G.jsx(dn,{className:"react-pdf__Page__structTree structTree",node:n}):null}const fi=Xi;function Mo(l){const t=ye();$(t);const e=Object.assign(Object.assign({},t),l),{_className:s,canvasBackground:i,devicePixelRatio:n=fo(),onRenderError:r,onRenderSuccess:a,page:o,renderForms:h,renderTextLayer:c,rotate:d,scale:u}=e,{canvasRef:p}=l;$(o);const g=x.useRef(null);function f(A){(function(w){return w.name==="RenderingCancelledException"})(A)||(ht(!1,A.toString()),r&&r(A))}const v=x.useMemo(()=>o.getViewport({scale:u*n,rotation:d}),[n,o,d,u]),m=x.useMemo(()=>o.getViewport({scale:u,rotation:d}),[o,d,u]);x.useEffect(function(){if(!o)return;o.cleanup();const{current:A}=g;if(!A)return;A.width=v.width,A.height=v.height,A.style.width=`${Math.floor(m.width)}px`,A.style.height=`${Math.floor(m.height)}px`,A.style.visibility="hidden";const w={annotationMode:h?fi.ENABLE_FORMS:fi.ENABLE,canvasContext:A.getContext("2d",{alpha:!1}),viewport:v};i&&(w.background=i);const _=o.render(w),y=_;return _.promise.then(()=>{A.style.visibility="",o&&a&&a(bs(o,u))}).catch(f),()=>Bt(y)},[i,o,h,v,m]);const b=x.useCallback(()=>{const{current:A}=g;A&&(A.width=0,A.height=0)},[]);return x.useEffect(()=>b,[b]),G.jsx("canvas",{className:`${s}__canvas`,dir:"ltr",ref:on(p,g),style:{display:"block",userSelect:"none"},children:c?G.jsx(ko,{}):null})}function Ro(){const l=ye();$(l);const{customTextRenderer:t,onGetTextError:e,onGetTextSuccess:s,onRenderTextLayerError:i,onRenderTextLayerSuccess:n,page:r,pageIndex:a,pageNumber:o,rotate:h,scale:c}=l;$(r);const[d,u]=qt(),{value:p,error:g}=d,f=x.useRef(null),v=x.useRef(void 0);ht(Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-text-layer"),10)===1,"TextLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-text-layer"),x.useEffect(function(){u({type:"RESET"})},[r,u]),x.useEffect(function(){if(!r)return;const w=oe(r.getTextContent()),_=w;return w.promise.then(y=>{u({type:"RESOLVE",value:y})}).catch(y=>{u({type:"REJECT",error:y})}),()=>Bt(_)},[r,u]),x.useEffect(()=>{p!==void 0&&(p!==!1?p&&s&&s(p):g&&(ht(!1,g.toString()),e&&e(g)))},[p]);const m=x.useCallback(()=>{n&&n()},[n]),b=x.useCallback(w=>{ht(!1,w.toString()),i&&i(w)},[i]),A=x.useMemo(()=>r.getViewport({scale:c,rotation:h}),[r,h,c]);return x.useLayoutEffect(function(){if(!r||!p)return;const{current:w}=f;if(!w)return;w.innerHTML="";const _=r.streamTextContent({includeMarkedContent:!0}),y=new Yi({container:w,textContentSource:_,viewport:A}),E=y;return y.render().then(()=>{const S=document.createElement("div");S.className="endOfContent",w.append(S),v.current=S;const C=w.querySelectorAll('[role="presentation"]');if(t){let I=0;p.items.forEach((M,W)=>{if(!function(U){return"str"in U}(M))return;const D=C[I];if(!D)return;const B=t(Object.assign({pageIndex:a,pageNumber:o,itemIndex:W},M));D.innerHTML=B,I+=M.str&&M.hasEOL?2:1})}m()}).catch(b),()=>Bt(E)},[t,b,m,r,a,o,p,A]),G.jsx("div",{className:re("react-pdf__Page__textContent","textLayer"),onMouseUp:function(){const w=v.current;w&&w.classList.remove("active")},onMouseDown:function(){const w=v.current;w&&w.classList.add("active")},ref:f})}function To(){const l=ne(),t=ye();$(t);const e=Object.assign(Object.assign({},l),t),{imageResourcesPath:s,linkService:i,onGetAnnotationsError:n,onGetAnnotationsSuccess:r,onRenderAnnotationLayerError:a,onRenderAnnotationLayerSuccess:o,page:h,pdf:c,renderForms:d,rotate:u,scale:p=1}=e;$(c),$(h),$(i);const[g,f]=qt(),{value:v,error:m}=g,b=x.useRef(null);ht(Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-annotation-layer"),10)===1,"AnnotationLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-annotations"),x.useEffect(function(){f({type:"RESET"})},[f,h]),x.useEffect(function(){if(!h)return;const w=oe(h.getAnnotations()),_=w;return w.promise.then(y=>{f({type:"RESOLVE",value:y})}).catch(y=>{f({type:"REJECT",error:y})}),()=>{Bt(_)}},[f,h]),x.useEffect(()=>{v!==void 0&&(v!==!1?v&&r&&r(v):m&&(ht(!1,m.toString()),n&&n(m)))},[v]);const A=x.useMemo(()=>h.getViewport({scale:p,rotation:u}),[h,u,p]);return x.useEffect(function(){if(!(c&&h&&i&&v))return;const{current:w}=b;if(!w)return;const _=A.clone({dontFlip:!0}),y={accessibilityManager:null,annotationCanvasMap:null,annotationEditorUIManager:null,div:w,l10n:null,page:h,viewport:_},E={annotations:v,annotationStorage:c.annotationStorage,div:w,imageResourcesPath:s,linkService:i,page:h,renderForms:d,viewport:_};w.innerHTML="";try{new Wi(y).render(E),o&&o()}catch(S){(function(C){ht(!1,`${C}`),a&&a(C)})(S)}return()=>{}},[v,s,i,h,c,d,A]),G.jsx("div",{className:re("react-pdf__Page__annotations","annotationLayer"),ref:b})}var Po=function(l,t){var e={};for(var s in l)Object.prototype.hasOwnProperty.call(l,s)&&t.indexOf(s)<0&&(e[s]=l[s]);if(l!=null&&typeof Object.getOwnPropertySymbols=="function"){var i=0;for(s=Object.getOwnPropertySymbols(l);i<s.length;i++)t.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(l,s[i])&&(e[s[i]]=l[s[i]])}return e};const mi=1;function vi(l){const t=ne(),e=Object.assign(Object.assign({},t),l),{_className:s="react-pdf__Page",_enableRegisterUnregisterPage:i=!0,canvasBackground:n,canvasRef:r,children:a,className:o,customRenderer:h,customTextRenderer:c,devicePixelRatio:d,error:u="Failed to load the page.",height:p,inputRef:g,loading:f="Loading page…",noData:v="No page specified.",onGetAnnotationsError:m,onGetAnnotationsSuccess:b,onGetStructTreeError:A,onGetStructTreeSuccess:w,onGetTextError:_,onGetTextSuccess:y,onLoadError:E,onLoadSuccess:S,onRenderAnnotationLayerError:C,onRenderAnnotationLayerSuccess:I,onRenderError:M,onRenderSuccess:W,onRenderTextLayerError:D,onRenderTextLayerSuccess:B,pageIndex:U,pageNumber:Y,pdf:J,registerPage:R,renderAnnotationLayer:F=!0,renderForms:_t=!1,renderMode:At="canvas",renderTextLayer:tt=!0,rotate:et,scale:H=mi,unregisterPage:X,width:N}=e,V=Po(e,["_className","_enableRegisterUnregisterPage","canvasBackground","canvasRef","children","className","customRenderer","customTextRenderer","devicePixelRatio","error","height","inputRef","loading","noData","onGetAnnotationsError","onGetAnnotationsSuccess","onGetStructTreeError","onGetStructTreeSuccess","onGetTextError","onGetTextSuccess","onLoadError","onLoadSuccess","onRenderAnnotationLayerError","onRenderAnnotationLayerSuccess","onRenderError","onRenderSuccess","onRenderTextLayerError","onRenderTextLayerSuccess","pageIndex","pageNumber","pdf","registerPage","renderAnnotationLayer","renderForms","renderMode","renderTextLayer","rotate","scale","unregisterPage","width"]),[lt,rt]=qt(),{value:Q,error:Mt}=lt,We=x.useRef(null);$(J);const xt=Ct(Y)?Y-1:U??null,Dt=Y??(Ct(U)?U+1:null),Yt=et??(Q?Q.rotate:null),yt=x.useMemo(()=>{if(!Q)return null;let Qt=1;const Xe=H??mi;if(N||p){const Jt=Q.getViewport({scale:1,rotation:Yt});N?Qt=N/Jt.width:p&&(Qt=p/Jt.height)}return Xe*Qt},[p,Q,Yt,H,N]);x.useEffect(function(){return()=>{Ct(xt)&&i&&X&&X(xt)}},[i,J,xt,X]),x.useEffect(function(){rt({type:"RESET"})},[rt,J,xt]),x.useEffect(function(){if(!J||!Dt)return;const Qt=oe(J.getPage(Dt)),Xe=Qt;return Qt.promise.then(Jt=>{rt({type:"RESOLVE",value:Jt})}).catch(Jt=>{rt({type:"REJECT",error:Jt})}),()=>Bt(Xe)},[rt,J,Dt]),x.useEffect(()=>{Q!==void 0&&(Q!==!1?function(){if(S){if(!Q||!yt)return;S(bs(Q,yt))}if(i&&R){if(!Ct(xt)||!We.current)return;R(xt,We.current)}}():Mt&&(ht(!1,Mt.toString()),E&&E(Mt)))},[Q,yt]);const un=x.useMemo(()=>Q&&Ct(xt)&&Dt&&Ct(Yt)&&Ct(yt)?{_className:s,canvasBackground:n,customTextRenderer:c,devicePixelRatio:d,onGetAnnotationsError:m,onGetAnnotationsSuccess:b,onGetStructTreeError:A,onGetStructTreeSuccess:w,onGetTextError:_,onGetTextSuccess:y,onRenderAnnotationLayerError:C,onRenderAnnotationLayerSuccess:I,onRenderError:M,onRenderSuccess:W,onRenderTextLayerError:D,onRenderTextLayerSuccess:B,page:Q,pageIndex:xt,pageNumber:Dt,renderForms:_t,renderTextLayer:tt,rotate:Yt,scale:yt}:null,[s,n,c,d,m,b,A,w,_,y,C,I,M,W,D,B,Q,xt,Dt,_t,tt,Yt,yt]),pn=x.useMemo(()=>Os(V,()=>Q&&(yt?bs(Q,yt):void 0)),[V,Q,yt]),we=`${xt}@${yt}/${Yt}`;function gn(){switch(At){case"custom":return $(h),G.jsx(h,{},`${we}_custom`);case"none":return null;default:return G.jsx(Mo,{canvasRef:r},`${we}_canvas`)}}return G.jsx("div",Object.assign({className:re(s,o),"data-page-number":Dt,ref:on(g,We),style:{"--scale-factor":`${yt}`,backgroundColor:n||"white",position:"relative",minWidth:"min-content",minHeight:"min-content"}},pn,{children:Dt?J===null||Q==null?G.jsx(ie,{type:"loading",children:typeof f=="function"?f():f}):J===!1||Q===!1?G.jsx(ie,{type:"error",children:typeof u=="function"?u():u}):G.jsxs(hn.Provider,{value:un,children:[gn(),tt?G.jsx(Ro,{},`${we}_text`):null,F?G.jsx(To,{},`${we}_annotations`):null,a]}):G.jsx(ie,{type:"no-data",children:typeof v=="function"?v():v})}))}var Lo=function(l,t){var e={};for(var s in l)Object.prototype.hasOwnProperty.call(l,s)&&t.indexOf(s)<0&&(e[s]=l[s]);if(l!=null&&typeof Object.getOwnPropertySymbols=="function"){var i=0;for(s=Object.getOwnPropertySymbols(l);i<s.length;i++)t.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(l,s[i])&&(e[s[i]]=l[s[i]])}return e};ht(!tn,`Loading PDF.js worker may not work on protocols other than HTTP/HTTPS. ${sn}`),Ki.workerSrc="pdf.worker.mjs";const No=Object.freeze(Object.defineProperty({__proto__:null,Document:yo,Outline:function(l){const t=ne(),e=Object.assign(Object.assign({},t),l),{className:s,inputRef:i,onItemClick:n,onLoadError:r,onLoadSuccess:a,pdf:o}=e,h=xo(e,["className","inputRef","onItemClick","onLoadError","onLoadSuccess","pdf"]);$(o);const[c,d]=qt(),{value:u,error:p}=c;x.useEffect(function(){d({type:"RESET"})},[d,o]),x.useEffect(function(){if(!o)return;const v=oe(o.getOutline()),m=v;return v.promise.then(b=>{d({type:"RESOLVE",value:b})}).catch(b=>{d({type:"REJECT",error:b})}),()=>Bt(m)},[d,o]),x.useEffect(()=>{u!==void 0&&(u!==!1?u!==void 0&&u!==!1&&a&&a(u):p&&(ht(!1,p.toString()),r&&r(p)))},[u]);const g=x.useMemo(()=>({onItemClick:n}),[n]),f=x.useMemo(()=>Os(h,()=>u),[h,u]);return u?G.jsx("div",Object.assign({className:re("react-pdf__Outline",s),ref:i},f,{children:G.jsx(nn.Provider,{value:g,children:u?G.jsx("ul",{children:u.map((v,m)=>G.jsx(an,{item:v,pdf:o},typeof v.dest=="string"?v.dest:m))}):null})})):null},Page:vi,PasswordResponses:ms,Thumbnail:function(l){const t=ne(),e=Object.assign(Object.assign({},t),l),{className:s,linkService:i,onItemClick:n,pageIndex:r,pageNumber:a,pdf:o}=e;$(o);const h=Ct(a)?a-1:r??null,c=a??(Ct(r)?r+1:null),{className:d,onItemClick:u}=l,p=Lo(l,["className","onItemClick"]);return G.jsx("a",{className:re("react-pdf__Thumbnail",s),href:c?"#":void 0,onClick:function(g){g.preventDefault(),Ct(h)&&c&&($(n||i),n?n({pageIndex:h,pageNumber:c}):i&&i.goToPage(c))},children:G.jsx(vi,Object.assign({},p,{_className:"react-pdf__Thumbnail__page",_enableRegisterUnregisterPage:!1,renderAnnotationLayer:!1,renderTextLayer:!1}))})},pdfjs:Ji,useDocumentContext:ne,useOutlineContext:rn,usePageContext:ye},Symbol.toStringTag,{value:"Module"}));export{yo as D,vi as P,uo as _,Ki as a,No as i};