@codexhost/cli-win32-x64 0.33.0 → 0.35.0

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 (122) hide show
  1. package/README.md +2 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +670 -116
  4. package/app/console-web.js +2032 -309
  5. package/app/desktop-controller.mjs +621 -74
  6. package/app/desktop-mcp-client.mjs +619 -0
  7. package/app/host-runtime.mjs +7134 -3865
  8. package/app/plugins/antigravity/plugin.mjs +1411 -121
  9. package/app/plugins/claude-code/plugin.mjs +527 -70
  10. package/app/plugins/codebuddy/plugin.mjs +592 -98
  11. package/app/plugins/codex-usage/plugin.mjs +659 -74
  12. package/app/plugins/copilot/plugin.mjs +527 -72
  13. package/app/plugins/cursor-cli/plugin.mjs +527 -70
  14. package/app/plugins/deepseek-harness/plugin.mjs +527 -70
  15. package/app/plugins/devin/plugin.mjs +527 -70
  16. package/app/plugins/enabled.json +1 -0
  17. package/app/plugins/grok/plugin.mjs +580 -92
  18. package/app/plugins/hermes/plugin.mjs +526 -69
  19. package/app/plugins/kimi-code/plugin.mjs +527 -70
  20. package/app/plugins/kiro-cli/plugin.mjs +527 -70
  21. package/app/plugins/omp/plugin.mjs +1338 -301
  22. package/app/plugins/opencode/plugin.mjs +527 -70
  23. package/app/plugins/pi/plugin.mjs +527 -70
  24. package/app/plugins/qoder/plugin.mjs +528 -71
  25. package/app/plugins/qoder-cn/plugin.mjs +528 -71
  26. package/app/plugins/qwen-code/plugin.mjs +526 -69
  27. package/app/plugins/workbuddy/plugin.mjs +1231 -546
  28. package/app/plugins/workbuddy-cn/assets/icon.svg +27 -0
  29. package/app/plugins/workbuddy-cn/manifest.json +32 -0
  30. package/app/plugins/workbuddy-cn/plugin.mjs +36524 -0
  31. package/app/plugins/zcode/plugin.mjs +528 -70
  32. package/app/renderer-extension.js +3898 -478
  33. package/app/web/assets/{abnfDiagram-XWFEHMT6-VnfRaHM6.js → abnfDiagram-XWFEHMT6-CGkBtBVj.js} +1 -1
  34. package/app/web/assets/{architectureDiagram-CSQXQB3N-BA1ehtvi.js → architectureDiagram-CSQXQB3N-Byv-cZeH.js} +1 -1
  35. package/app/web/assets/{blockDiagram-BEDRHYPZ-31BZSfd4.js → blockDiagram-BEDRHYPZ-DjLzUtwg.js} +1 -1
  36. package/app/web/assets/{c4Diagram-M2UUVUY5-CNzGWc5k.js → c4Diagram-M2UUVUY5-CJlsb6QO.js} +1 -1
  37. package/app/web/assets/{chunk-2Q5K7J3B-ahAIR-NM.js → chunk-2Q5K7J3B-CWm537bw.js} +1 -1
  38. package/app/web/assets/{chunk-3GCGMST5-BIV5YeRJ.js → chunk-3GCGMST5-NpcInIx4.js} +1 -1
  39. package/app/web/assets/{chunk-5VM5RSS4-CluTMPJG.js → chunk-5VM5RSS4-CeyyP0dm.js} +1 -1
  40. package/app/web/assets/{chunk-7U7NFRK5-4NIQuFbE.js → chunk-7U7NFRK5-Bto5OgbF.js} +1 -1
  41. package/app/web/assets/{chunk-CNRTWJTD-_0bEfGn3.js → chunk-CNRTWJTD-CuRMFCjT.js} +1 -1
  42. package/app/web/assets/{chunk-D5HYT7QG-_kTC6f8F.js → chunk-D5HYT7QG-DtQM1-2k.js} +1 -1
  43. package/app/web/assets/{chunk-EBZ3SEQC-CykaYOrL.js → chunk-EBZ3SEQC-DbUb3ZJ4.js} +2 -2
  44. package/app/web/assets/{chunk-JWPE2WC7-3vVOQ_py.js → chunk-JWPE2WC7-Dxh3d9Ag.js} +1 -1
  45. package/app/web/assets/{chunk-KTR4FSNJ-aVg5vgrm.js → chunk-KTR4FSNJ-BfwavXUO.js} +1 -1
  46. package/app/web/assets/{chunk-XXDRQBXY-_gVwGeSp.js → chunk-XXDRQBXY-CxR1flID.js} +1 -1
  47. package/app/web/assets/{classDiagram-v2-KXABOMEV-fI1LfeBf.js → classDiagram-v2-KXABOMEV-2WV2q_X2.js} +1 -1
  48. package/app/web/assets/{cose-bilkent-JH36ORCC-DFXMlWov.js → cose-bilkent-JH36ORCC-C-ENrCL_.js} +1 -1
  49. package/app/web/assets/{cynefin-EF2NZ3EQ-lZy7X6FO.js → cynefin-EF2NZ3EQ-Bg5LeTZO.js} +1 -1
  50. package/app/web/assets/{cynefinDiagram-NJNITYFG-N4DwFSW1.js → cynefinDiagram-NJNITYFG-CRAdbGGt.js} +1 -1
  51. package/app/web/assets/{dagre-KIHZ2IZ3-B7-8baTH.js → dagre-KIHZ2IZ3-dNHEvUqL.js} +1 -1
  52. package/app/web/assets/{diagram-7YQZDPLS-DLfjiBXV.js → diagram-7YQZDPLS-7F4O37o5.js} +1 -1
  53. package/app/web/assets/{diagram-QBROCOUO-CQnRzSTi.js → diagram-QBROCOUO-B-5KpeI2.js} +1 -1
  54. package/app/web/assets/{diagram-RJJCUUZO-DPnxazRT.js → diagram-RJJCUUZO-DqDsyDaL.js} +1 -1
  55. package/app/web/assets/{diagram-WERXNKYE-BBuEFRvD.js → diagram-WERXNKYE-f1oaPKos.js} +1 -1
  56. package/app/web/assets/{diagram-YHHI257C-BQ92JNJs.js → diagram-YHHI257C-DVMtl9Bt.js} +1 -1
  57. package/app/web/assets/{diagram-YR4HJLHV-Ce6BQO3J.js → diagram-YR4HJLHV-BWFCNFFF.js} +1 -1
  58. package/app/web/assets/{ebnfDiagram-N527522P-DYknE2Jy.js → ebnfDiagram-N527522P-B4N7d-Bi.js} +1 -1
  59. package/app/web/assets/{elk-O5DQBFGD-4S6_JJFF.js → elk-O5DQBFGD-DRdfF_UQ.js} +1 -1
  60. package/app/web/assets/{erDiagram-K3K3BIDK-DRtF7JVQ.js → erDiagram-K3K3BIDK-BW4-_5sZ.js} +1 -1
  61. package/app/web/assets/{flowDiagram-Z6JWZHQI-7Ho8CyR9.js → flowDiagram-Z6JWZHQI-DIQa5yEv.js} +1 -1
  62. package/app/web/assets/{ganttDiagram-3PRQTZWP-CW8Ig5y4.js → ganttDiagram-3PRQTZWP-JBK9PM7A.js} +1 -1
  63. package/app/web/assets/{gitGraphDiagram-VXDFKS5L-CzS8Xg2D.js → gitGraphDiagram-VXDFKS5L-TPI9Su0g.js} +1 -1
  64. package/app/web/assets/{grid-E2QIVN74-Cq284lCe.js → grid-E2QIVN74-DmHbunuP.js} +1 -1
  65. package/app/web/assets/index-BKDmniRf.js +209 -0
  66. package/app/web/assets/index-BPMnQdGr.css +1 -0
  67. package/app/web/assets/{infoDiagram-EZ3ZOAHP-BZgN6qlY.js → infoDiagram-EZ3ZOAHP-BeFwO9PI.js} +1 -1
  68. package/app/web/assets/{ishikawaDiagram-S3EKX5GW-BH9YHc-1.js → ishikawaDiagram-S3EKX5GW-BTbrKF_p.js} +1 -1
  69. package/app/web/assets/{journeyDiagram-POQNLL5X-D50KYOLe.js → journeyDiagram-POQNLL5X-DR0yWxJi.js} +1 -1
  70. package/app/web/assets/{kanban-definition-BH5XI6FM-Crw_5mMP.js → kanban-definition-BH5XI6FM-DMHrC9oV.js} +1 -1
  71. package/app/web/assets/{mermaid.core-o2Qjrppc.js → mermaid.core-Brmc1kJw.js} +4 -4
  72. package/app/web/assets/{mindmap-definition-WVAN44T4-B_bEbpAH.js → mindmap-definition-WVAN44T4-NT_XVwlI.js} +1 -1
  73. package/app/web/assets/{pegDiagram-D4NLKWP3-VecAHoyw.js → pegDiagram-D4NLKWP3-K67_THcc.js} +1 -1
  74. package/app/web/assets/{pieDiagram-36ENHN4W-o3ei2T-6.js → pieDiagram-36ENHN4W-GlTgKnTi.js} +1 -1
  75. package/app/web/assets/{quadrantDiagram-ZQUDMS73-DHndOAcn.js → quadrantDiagram-ZQUDMS73-yMEZ6-Nr.js} +1 -1
  76. package/app/web/assets/{railroadDiagram-JIZHGYPL-DRd_lfii.js → railroadDiagram-JIZHGYPL-MXCqwbuq.js} +1 -1
  77. package/app/web/assets/{render-VIF2ZAQL-awM3hUqB.js → render-VIF2ZAQL-BRUlhHPG.js} +2 -2
  78. package/app/web/assets/{requirementDiagram-AXW2TVFA-Ce1ePsOe.js → requirementDiagram-AXW2TVFA-Dqx4p0Bz.js} +1 -1
  79. package/app/web/assets/{sankeyDiagram-FBCJTAIF-cP-LtgW-.js → sankeyDiagram-FBCJTAIF-COp3IWvs.js} +1 -1
  80. package/app/web/assets/{sequenceDiagram-3LA2ROMG-C3JStTuW.js → sequenceDiagram-3LA2ROMG-j1xwrmp8.js} +1 -1
  81. package/app/web/assets/{sizeCapture-2Q2CQKSF-Dyyelr9K.js → sizeCapture-2Q2CQKSF-ZEXdxLeY.js} +1 -1
  82. package/app/web/assets/{stateDiagram-v2-ATKHQDJO-DkYRBVTd.js → stateDiagram-v2-ATKHQDJO-2pt2L-Zd.js} +1 -1
  83. package/app/web/assets/{swimlanes-YQL5WMAO-B2FwJU5_.js → swimlanes-YQL5WMAO-BHpgfPPd.js} +1 -1
  84. package/app/web/assets/swimlanesDiagram-UCCPES4V-BrYKheZO.js +8 -0
  85. package/app/web/assets/{timeline-definition-7Z437IG3-Di-qRIIi.js → timeline-definition-7Z437IG3-Cw4F_3FM.js} +1 -1
  86. package/app/web/assets/{usecaseDiagram-RDK6N6HP-yAImn62t.js → usecaseDiagram-RDK6N6HP-DefiMBIg.js} +1 -1
  87. package/app/web/assets/{vennDiagram-SHRQU5PJ-BEv8jpfv.js → vennDiagram-SHRQU5PJ-D30EMFrI.js} +1 -1
  88. package/app/web/assets/{wardleyDiagram-F3OXNVQS-7irksA0b.js → wardleyDiagram-F3OXNVQS-4ok25PKp.js} +1 -1
  89. package/app/web/assets/{xychartDiagram-GDYJKCDI-BokJGG2y.js → xychartDiagram-GDYJKCDI-BB0uAQX5.js} +1 -1
  90. package/app/web/codexhost-settings.js +429 -159
  91. package/app/web/index.html +2 -2
  92. package/app/web/plugins/deepseek-ai__dsh-api-gateway/client.js +1 -1
  93. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +63 -63
  94. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +70 -70
  95. package/app/web/plugins/deepseek-ai__dsh-client-file-upload/client.js +1 -1
  96. package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +75 -75
  97. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +172 -77
  98. package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +104 -100
  99. package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +65 -65
  100. package/app/web/plugins/deepseek-ai__dsh-client-ui-session/client.js +1 -1
  101. package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +5 -5
  102. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.js +6 -6
  103. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.pdf.js +1 -1
  104. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-right/client.js +62 -62
  105. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +72 -72
  106. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +70 -70
  107. package/app/web/plugins.json +1 -0
  108. package/app/web/role-avatars/builtin/advisor-otter.webp +0 -0
  109. package/app/web/role-avatars/builtin/builder-otter.webp +0 -0
  110. package/app/web/role-avatars/builtin/sailor-otter.webp +0 -0
  111. package/app/web/role-avatars/builtin/wizard-otter.webp +0 -0
  112. package/app/web-modules/server.mjs +7262 -2970
  113. package/bin/codexhost.exe +0 -0
  114. package/libexec/codexhost-node-repl.exe +0 -0
  115. package/libexec/codexhost-screenshot.exe +0 -0
  116. package/libexec/codexhost-shell.exe +0 -0
  117. package/libexec/codexhost-shim.exe +0 -0
  118. package/libexec/codexhost-updater.exe +0 -0
  119. package/package.json +1 -1
  120. package/app/web/assets/index-CINZ6P-q.css +0 -1
  121. package/app/web/assets/index-CvV6veuY.js +0 -208
  122. package/app/web/assets/swimlanesDiagram-UCCPES4V-BkMsxCPb.js +0 -8
@@ -602,4 +602,4 @@ pdfjs-digital-signature-properties-sub-signatures =
602
602
  /*@vite-ignore*/
603
603
  e).then(e=>{n(e.QuickJSSandbox(new URL(t,location.href).href))}).catch(r)})}async createSandbox(e){(await this._ready).create(e)}async dispatchEventInSandbox(e){let t=await this._ready;setTimeout(()=>t.dispatchEvent(e),0)}async destroySandbox(){(await this._ready).nukeSandbox()}},Cl=class{#e=null;#t=null;#n=null;#r=null;#i=null;#a=null;#o=null;#s=null;#c=null;#l=!1;#u=null;#d=null;constructor({eventBus:e,externalServices:t=null,docProperties:n=null}){this.#i=e,this.#a=t,this.#n=n}setViewer(e){this.#c=e}async setDocument(e){if(this.#s&&await this.#g(),this.#s=e,!e)return;let[t,n,r]=await Promise.all([e.getFieldObjects(),e.getCalculationOrderIds(),e.getJSActions()]);if(!t&&!r){await this.#g();return}if(e!==this.#s)return;if(t){this.#o=/* @__PURE__ */ new Set;for(let e of t.values())for(let{id:t}of e)this.#o.add(t)}try{this.#u=this.#h()}catch(e){console.error(`setDocument:`,e),await this.#g();return}let i=this.#i;this.#r=new AbortController;let a={signal:this.#r.signal,...X};i.on(`updatefromsandbox`,e=>{e?.source===window&&this.#f(e.detail)},a),i.on(`dispatcheventinsandbox`,e=>{this.#u?.dispatchEventInSandbox(e.detail)},a),i.on(`pagechanging`,({pageNumber:e,previous:t})=>{e!==t&&(this.#m(t),this.#p(e))},a),i.on(`pagerendered`,({pageNumber:e})=>{this._pageOpenPending.has(e)&&e===this.#c.currentPageNumber&&this.#p(e)},a),i.on(`pagesdestroy`,async()=>{await this.#m(this.#c.currentPageNumber),await this.#u?.dispatchEventInSandbox({id:`doc`,name:`WillClose`}),this.#e?.resolve()},a);try{let a=await this.#n(e);if(e!==this.#s)return;await this.#u.createSandbox({objects:t,calculationOrder:n,appInfo:{platform:navigator.platform,language:navigator.language},docInfo:{...a,actions:r}}),i.dispatch(`sandboxcreated`,{source:this})}catch(e){console.error(`setDocument:`,e),await this.#g();return}await this.#u?.dispatchEventInSandbox({id:`doc`,name:`Open`}),await this.#p(this.#c.currentPageNumber,!0),Promise.resolve().then(()=>{e===this.#s&&(this.#l=!0)})}async dispatchWillSave(){return this.#u?.dispatchEventInSandbox({id:`doc`,name:`WillSave`})}async dispatchDidSave(){return this.#u?.dispatchEventInSandbox({id:`doc`,name:`DidSave`})}async dispatchWillPrint(){if(this.#u){await this.#d?.promise,this.#d=Promise.withResolvers();try{await this.#u.dispatchEventInSandbox({id:`doc`,name:`WillPrint`})}catch(e){throw this.#d.resolve(),this.#d=null,e}await this.#d.promise}}async dispatchDidPrint(){return this.#u?.dispatchEventInSandbox({id:`doc`,name:`DidPrint`})}get destroyPromise(){return this.#t?.promise||null}get ready(){return this.#l}get _pageOpenPending(){return fo(this,`_pageOpenPending`,/* @__PURE__ */ new Set)}get _visitedPages(){return fo(this,`_visitedPages`,/* @__PURE__ */ new Map)}async#f(e){let t=this.#c,n=t.isInPresentationMode||t.isChangingPresentationMode,{id:r,siblings:i,command:a,value:o}=e;if(!r){switch(a){case`clear`:console.clear();break;case`error`:console.error(o);break;case`layout`:n||(t.spreadMode=Yo(o).spreadMode);break;case`page-num`:t.currentPageNumber=o+1;break;case`print`:await t.pagesPromise,this.#i.dispatch(`print`,{source:this});break;case`println`:console.log(o);break;case`zoom`:n||(t.currentScaleValue=o);break;case`SaveAs`:this.#i.dispatch(`download`,{source:this});break;case`FirstPage`:t.currentPageNumber=1;break;case`LastPage`:t.currentPageNumber=t.pagesCount;break;case`NextPage`:t.nextPage();break;case`PrevPage`:t.previousPage();break;case`ZoomViewIn`:n||t.increaseScale();break;case`ZoomViewOut`:n||t.decreaseScale();break;case`WillPrintFinished`:this.#d?.resolve(),this.#d=null}return}if(n&&e.focus)return;delete e.id,delete e.siblings;let s=i?[r,...i]:[r];for(let t of s){if(!this.#o?.has(t))continue;let n=document.querySelector(`[data-element-id="${t}"]`);n?n.dispatchEvent(new CustomEvent(`updatefromsandbox`,{detail:e})):this.#s?.annotationStorage.setValue(t,e)}}async#p(e,t=!1){let n=this.#s,r=this._visitedPages;if(t&&(this.#e=Promise.withResolvers()),!this.#e)return;let i=this.#c.getPageView(e-1);if(i?.renderingState!==$.FINISHED){this._pageOpenPending.add(e);return}this._pageOpenPending.delete(e);let a=(async()=>{let t=await(r.has(e)?null:i.pdfPage?.getJSActions());n===this.#s&&await this.#u?.dispatchEventInSandbox({id:`page`,name:`PageOpen`,pageNumber:e,actions:t})})();r.set(e,a)}async#m(e){let t=this.#s,n=this._visitedPages;if(!this.#e||this._pageOpenPending.has(e))return;let r=n.get(e);r&&(n.set(e,null),await r,t===this.#s&&await this.#u?.dispatchEventInSandbox({id:`page`,name:`PageClose`,pageNumber:e}))}#h(){if(this.#t=Promise.withResolvers(),this.#u)throw Error(`#initScripting: Scripting already exists.`);return this.#a.createScripting()}async#g(){if(this.#o=null,!this.#u)this.#s=null,this.#t?.resolve();else{this.#e&&=(await Promise.race([this.#e.promise,new Promise(e=>{setTimeout(e,1e3)})]).catch(()=>{}),null),this.#s=null;try{await this.#u.destroySandbox()}catch{}this.#d?.reject(/* @__PURE__ */ Error(`Scripting destroyed.`)),this.#d=null,this.#r?.abort(),this.#r=null,this._pageOpenPending.clear(),this._visitedPages.clear(),this.#u=null,this.#l=!1,this.#t?.resolve()}}},wl=class extends Cl{constructor(e){e.externalServices||window.addEventListener(`updatefromsandbox`,t=>{e.eventBus.dispatch(`updatefromsandbox`,{source:window,detail:t.detail})}),e.externalServices||={createScripting:()=>new Sl(e.sandboxBundleSrc,e.wasmUrl)},e.docProperties||=e=>xl(e),super(e)}},Tl=class{#e=null;#t=null;#n=null;#r=null;isThumbnailViewEnabled=!1;onIdle=null;printing=!1;constructor(){Object.defineProperty(this,"hasViewer",{value:()=>!!this.#r})}setViewer(e){this.#r=e}setThumbnailViewer(e){this.#n=e}isHighestPriority(e){return this.#e===e.renderingId}renderHighestPriority(e){this.#t&&=(clearTimeout(this.#t),null),!this.#r.forceRendering(e)&&(this.isThumbnailViewEnabled&&this.#n?.forceRendering()||this.printing||this.onIdle&&(this.#t=setTimeout(this.onIdle.bind(this),3e4)))}getHighestPriority(e,t,n,r=!1,i=!1){let a=e.views,o=a.length;if(o===0)return null;for(let e=0;e<o;e++){let t=a[e].view;if(!this.isViewFinished(t))return t}if(!i)for(let e=0;e<o;e++){let{detailView:t}=a[e].view;if(t&&!this.isViewFinished(t))return t}let s=e.first.id,c=e.last.id;if(c-s+1>o){let r=e.ids;for(let e=1,i=c-s;e<i;e++){let i=n?s+e:c-e;if(r.has(i))continue;let a=t[i-1];if(!this.isViewFinished(a))return a}}let l=n?c:s-2,u=t[l];return u&&!this.isViewFinished(u)||r&&(l+=n?1:-1,u=t[l],u&&!this.isViewFinished(u))?u:null}isViewFinished(e){return e.renderingState===$.FINISHED}renderView(e){switch(e.renderingState){case $.FINISHED:return!1;case $.PAUSED:this.#e=e.renderingId,e.resume();break;case $.RUNNING:this.#e=e.renderingId;break;case $.INITIAL:this.#e=e.renderingId,e.draw().finally(()=>{this.renderHighestPriority()}).catch(e=>{e instanceof so||console.error(`renderView:`,e)})}return!0}};let El={FORCE_SCROLL_MODE_PAGE:1e4,FORCE_LAZY_PAGE_INIT:5e3,PAUSE_EAGER_PAGE_INIT:250};function Dl(e){return Object.values(q).includes(e)&&e!==q.DISABLE}var Ol=class{#e=/* @__PURE__ */ new Set;#t=0;constructor(e){this.#t=e}push(e){let t=this.#e;t.has(e)&&t.delete(e),t.add(e),t.size>this.#t&&this.#n()}resize(e,t=null){this.#t=e;let n=this.#e;if(t){let e=n.size,r=1;for(let i of n)if(t.has(i.id)&&(n.delete(i),n.add(i)),++r>e)break}for(;n.size>this.#t;)this.#n()}has(e){return this.#e.has(e)}[Symbol.iterator](){return this.#e.keys()}#n(){let e=this.#e.keys().next().value;e?.destroy(),this.#e.delete(e)}},kl=class{#e=null;#t=null;#n=null;#r=q.NONE;#i=null;#a=xa.ENABLE_FORMS;#o=null;#s=null;#c=null;#l=!1;#u=!1;#d=!1;#f=!1;#p=!0;#m=null;#h=null;#g=0;#_=null;#v=[NaN,NaN];#y=!0;#b=null;#x=!1;#S=null;#C=null;#w=!1;#T=null;#E=0;#D=new ResizeObserver(this.#ee.bind(this));#O=null;#k=null;#A=null;#j=!0;#M=jo.ENABLE;#N=null;#P=null;#F=null;#I=null;constructor(e){let t=`6.3.289`;if(So!==t)throw Error(`The API version "${So}" does not match the Viewer version "${t}".`);if(this.container=e.container,this.viewer=e.viewer||e.container.firstElementChild,this.#N=e.viewerAlert||null,this.container?.tagName!==`DIV`||this.viewer?.tagName!==`DIV`)throw Error("Invalid `container` and/or `viewer` option.");if(this.container.offsetParent&&getComputedStyle(this.container).position!==`absolute`)throw Error("The `container` must be absolutely positioned.");this.#D.observe(this.container),this.eventBus=e.eventBus,this.linkService=e.linkService||new ms,this.downloadManager=e.downloadManager||null,this.findController=e.findController||null,this.#t=e.altTextManager||null,this.#o=e.commentManager||null,this.#A=e.signatureManager||null,this.#c=e.editorUndoBar||null,this.findController&&(this.findController.onIsPageVisible=e=>this._getVisiblePages().ids.has(e)),this._scriptingManager=e.scriptingManager||null,this.#M=e.textLayerMode??jo.ENABLE,this.#a=e.annotationMode??xa.ENABLE_FORMS,this.#r=e.annotationEditorMode??q.NONE,this.#n=e.annotationEditorHighlightColors||null,this.#l=e.enableHighlightFloatingButton===!0,this.#d=e.enableUpdatedAddImage===!0,this.#f=e.enableNewAltTextWhenAddingImage===!0,this.imageResourcesPath=e.imageResourcesPath||``,this.enablePrintAutoRotate=e.enablePrintAutoRotate||!1,this.removePageBorders=e.removePageBorders||!1,this.maxCanvasPixels=e.maxCanvasPixels,this.maxCanvasDim=e.maxCanvasDim,this.capCanvasAreaFactor=e.capCanvasAreaFactor,this.enableDetailCanvas=e.enableDetailCanvas??!0,this.enableOptimizedPartialRendering=e.enableOptimizedPartialRendering??!1,this.enableSelectionRendering=e.enableSelectionRendering!==!1,this.imagesRightClickMinSize=e.imagesRightClickMinSize??-1,this.l10n=e.l10n,this.l10n||=new Hc,this.#u=e.enablePermissions||!1,this.pageColors=e.pageColors||null,this.#_=e.mlManager||null,this.#j=e.supportsPinchToZoom!==!1,this.#p=e.enableAutoLinking!==!1,this.#g=e.minDurationToUpdateCanvas??500,this.defaultRenderingQueue=!e.renderingQueue,this.defaultRenderingQueue?(this.renderingQueue=new Tl,this.renderingQueue.setViewer(this)):this.renderingQueue=e.renderingQueue;let{abortSignal:n}=e;this.#m=n||null,n?.addEventListener(`abort`,()=>{this.#D.disconnect(),this.#D=null},{once:!0}),this.scroll=No(this.container,this._scrollUpdate.bind(this),n),this.presentationModeState=Ao.UNKNOWN,this._resetView(),this.removePageBorders&&this.viewer.classList.add(`removePageBorders`),this.#$(),this.eventBus.on(`thumbnailrendered`,({pageNumber:e,pdfPage:t})=>{let n=this._pages[e-1];this.#e.has(n)||t?.cleanup()},X),e.l10n||this.l10n.translate(this.container)}get printingAllowed(){return this.#y}get pagesCount(){return this._pages.length}getPageView(e){return this._pages[e]}getCachedPageViews(){return new Set(this.#e)}get pageViewsReady(){return this._pages.every(e=>e?.pdfPage)}clearSelection(){let e=document.getSelection();if(e&&!e.isCollapsed){for(let t=0,n=e.rangeCount;t<n;t++)if(e.getRangeAt(t).intersectsNode(this.viewer)){e.removeAllRanges?.(),e.empty?.();return}}}get renderForms(){return this.#a===xa.ENABLE_FORMS}get enableScripting(){return!!this._scriptingManager}get currentPageNumber(){return this._currentPageNumber}set currentPageNumber(e){if(!Number.isInteger(e))throw Error(`Invalid page number.`);this.pdfDocument&&(this._currentPageNumber!==e&&this.clearSelection(),this._setCurrentPageNumber(e,!0)||console.error(`currentPageNumber: "${e}" is not a valid page.`))}_setCurrentPageNumber(e,t=!1){if(this._currentPageNumber===e)return t&&this.#J(),!0;if(!(0<e&&e<=this.pagesCount))return!1;let n=this._currentPageNumber;return this._currentPageNumber=e,this.eventBus.dispatch(`pagechanging`,{source:this,pageNumber:e,pageLabel:this._pageLabels?.[e-1]??null,previous:n}),t&&this.#J(),!0}get currentPageLabel(){return this._pageLabels?.[this._currentPageNumber-1]??null}set currentPageLabel(e){if(!this.pdfDocument)return;let t=e|0;if(this._pageLabels){let n=this._pageLabels.indexOf(e);n>=0&&(t=n+1)}this._currentPageNumber!==t&&this.clearSelection(),this._setCurrentPageNumber(t,!0)||console.error(`currentPageLabel: "${e}" is not a valid page.`)}get currentScale(){return this._currentScale===0?1:this._currentScale}set currentScale(e){if(isNaN(e))throw Error(`Invalid numeric scale.`);this.pdfDocument&&this.#q(e,{noScroll:!1})}get currentScaleValue(){return this._currentScaleValue}set currentScaleValue(e){this.pdfDocument&&this.#q(e,{noScroll:!1})}get pagesRotation(){return this._pagesRotation}set pagesRotation(e){if(!Uo(e))throw Error(`Invalid pages rotation angle.`);if(!this.pdfDocument||(e%=360,e<0&&(e+=360),this._pagesRotation===e))return;this.clearSelection(),this._pagesRotation=e;let t=this._currentPageNumber;this.refresh(!0,{rotation:e}),this._currentScaleValue&&this.#q(this._currentScaleValue,{noScroll:!0}),this.eventBus.dispatch(`rotationchanging`,{source:this,pagesRotation:e,pageNumber:t}),this.defaultRenderingQueue&&this.update()}get firstPagePromise(){return this.pdfDocument?this._firstPageCapability.promise:null}get onePageRendered(){return this.pdfDocument?this._onePageRenderedCapability.promise:null}get pagesPromise(){return this.pdfDocument?this._pagesCapability.promise:null}get _layerProperties(){let e=this;return fo(this,`_layerProperties`,{get annotationEditorUIManager(){return e.#i},get annotationStorage(){return e.pdfDocument?.annotationStorage},get downloadManager(){return e.downloadManager},get enableComment(){return!!e.#o},get enableScripting(){return!!e._scriptingManager},get fieldObjectsPromise(){return e.pdfDocument?.getFieldObjects()},get findController(){return e.findController},get hasJSActionsPromise(){return e.pdfDocument?.hasJSActions()},get linkService(){return e.linkService}})}#L(e){this.#y=e,this.eventBus.dispatch(`printingallowed`,{source:this,isAllowed:e})}#R(e){let t={annotationEditorMode:this.#r,annotationMode:this.#a,textLayerMode:this.#M};return e?(this.#L(e.has(ao.PRINT_HIGH_QUALITY)||e.has(ao.PRINT)),!e.has(ao.COPY)&&this.#M===jo.ENABLE&&(t.textLayerMode=jo.ENABLE_PERMISSIONS),e.has(ao.MODIFY_CONTENTS)||(t.annotationEditorMode=q.DISABLE),!e.has(ao.MODIFY_ANNOTATIONS)&&!e.has(ao.FILL_INTERACTIVE_FORMS)&&this.#a===xa.ENABLE_FORMS&&(t.annotationMode=xa.ENABLE),t):(this.#L(!0),t)}async#z(e){if(document.visibilityState===`hidden`||!this.container.offsetParent||this._getVisiblePages().views.length===0)return;let t=Promise.withResolvers(),n=new AbortController;document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`hidden`&&t.resolve()},{signal:AbortSignal.any([e,n.signal])}),await Promise.race([this._onePageRenderedCapability.promise,t.promise]),n.abort()}async getAllText(e=null){let t=[],n=[];for(let r=1,i=this.pdfDocument.numPages;r<=i;++r){if(e?.aborted)return null;n.length=0;let{items:i}=await(await this.pdfDocument.getPage(r)).getTextContent();for(let e of i)e.str&&n.push(e.str),e.hasEOL&&n.push(`
604
604
  `);t.push(Io(n.join(``)))}return t.join(`
605
- `)}#B(e,t){let n=document.getSelection(),{focusNode:r,anchorNode:i}=n;if(i&&r&&n.containsNode(this.#T)){if(this.#w||e===jo.ENABLE_PERMISSIONS){mo(t);return}this.#w=!0;let{classList:n}=this.viewer;n.add(`copyAll`);let r=new AbortController,i=new AbortController;window.addEventListener(`keydown`,e=>{e.key===`Escape`&&i.abort()},{signal:r.signal}),this.getAllText(i.signal).then(async e=>{e!==null&&await navigator.clipboard.writeText(e)}).catch(e=>{console.warn(`Something goes wrong when extracting the text: ${e.message}`)}).finally(()=>{this.#w=!1,r.abort(),n.remove(`copyAll`)}),mo(t)}}setDocument(e){if(this.pdfDocument&&(this.eventBus.dispatch(`pagesdestroy`,{source:this}),this._cancelRendering(),this._resetView(),this.findController?.setDocument(null),this._scriptingManager?.setDocument(null),this.#i?.destroy(),this.#i=null,this.#r=q.NONE,this.#y=!0),this.pdfDocument=e,!e)return;let t=e.numPages,n=e.getPage(1),r=e.getOptionalContentConfig({intent:`display`}),i=this.#u?e.getPermissions():Promise.resolve(),{eventBus:a,pageColors:o,viewer:s}=this;this.#h=new AbortController;let{signal:c}=this.#h,l={signal:c,...X};if(t>El.FORCE_SCROLL_MODE_PAGE){console.warn(`Forcing PAGE-scrolling for performance reasons, given the length of the document.`);let e=this._scrollMode=J.PAGE;a.dispatch(`scrollmodechanged`,{source:this,mode:e})}this._pagesCapability.promise.then(()=>{a.dispatch(`pagesloaded`,{source:this,pagesCount:t})},()=>{}),a.on(`pagerender`,e=>{let t=this._pages[e.pageNumber-1];t&&this.#e.push(t)},l);let u=e=>{e.cssTransform||e.isDetailView||(this._onePageRenderedCapability.resolve({timestamp:e.timestamp}),a.off(`pagerendered`,u))};a.on(`pagerendered`,u,l),Promise.all([n,i]).then(([n,i])=>{if(e!==this.pdfDocument)return;this._firstPageCapability.resolve(n),this._optionalContentConfigPromise=r;let{annotationEditorMode:l,annotationMode:u,textLayerMode:d}=this.#R(i);if(d!==jo.DISABLE){let e=this.#T=document.createElement(`div`);e.id=`hiddenCopyElement`,e.style.cssText=`position:absolute;top:0;left:0;width:0;height:0;display:none`,s.before(e)}if(l!==q.DISABLE){let t=l;e.isPureXfa?console.warn(`Warning: XFA-editing is not implemented.`):Dl(t)?(this.#i=new ya(this.container,s,this.#N,this.#t,this.#o,this.#A,a,e,o,this.#n,this.#l,this.#d,this.#f,this.#_,this.#c,this.#j),a.dispatch(`annotationeditoruimanager`,{source:this,uiManager:this.#i}),t!==q.NONE&&(this.#re(t),this.#i.updateMode(t))):console.error(`Invalid AnnotationEditor mode: ${t}`)}let f=this._scrollMode===J.PAGE?null:s,p=this.currentScale,m=n.getViewport({scale:p*oo.PDF_TO_CSS_UNITS});s.style.setProperty(`--scale-factor`,m.scale),o?.background&&s.style.setProperty(`--page-bg-color`,o.background),(o?.foreground===`CanvasText`||o?.background===`Canvas`)&&(s.style.setProperty(`--hcm-highlight-filter`,e.filterFactory.addHighlightHCMFilter(`highlight`,`CanvasText`,`Canvas`,`HighlightText`,`Highlight`)),s.style.setProperty(`--hcm-highlight-selected-filter`,e.filterFactory.addHighlightHCMFilter(`highlight_selected`,`CanvasText`,`Canvas`,`HighlightText`,`ButtonText`)));for(let e=1;e<=t;++e){let t=new bl({container:f,eventBus:a,id:e,scale:p,defaultViewport:m.clone(),optionalContentConfigPromise:r,renderingQueue:this.renderingQueue,textLayerMode:d,annotationMode:u,imageResourcesPath:this.imageResourcesPath,maxCanvasPixels:this.maxCanvasPixels,maxCanvasDim:this.maxCanvasDim,capCanvasAreaFactor:this.capCanvasAreaFactor,enableDetailCanvas:this.enableDetailCanvas,enableOptimizedPartialRendering:this.enableOptimizedPartialRendering,enableSelectionRendering:this.enableSelectionRendering,imagesRightClickMinSize:this.imagesRightClickMinSize,pageColors:o,l10n:this.l10n,layerProperties:this._layerProperties,enableAutoLinking:this.#p,minDurationToUpdateCanvas:this.#g,commentManager:this.#o,abortSignal:this.#m});this._pages.push(t)}this._pages[0]?.setPdfPage(n),this._scrollMode===J.PAGE?this.#V():this._spreadMode!==Y.NONE&&this._updateSpreadMode(),a.on(`annotationeditorlayerrendered`,e=>{this.#i&&a.dispatch(`annotationeditormodechanged`,{source:this,mode:this.#r})},{once:!0,signal:c,...X}),this.#z(c).then(async()=>{if(e!==this.pdfDocument)return;if(this.findController?.setDocument(e),this._scriptingManager?.setDocument(e),this.#T&&document.addEventListener(`copy`,this.#B.bind(this,d),{signal:c}),e.loadingParams.disableAutoFetch||t>El.FORCE_LAZY_PAGE_INIT){this._pagesCapability.resolve();return}let n=t-1;if(n<=0)this._pagesCapability.resolve();else for(let r=2;r<=t;++r){let t=e.getPage(r).then(e=>{let t=this._pages[r-1];t.pdfPage||t.setPdfPage(e),--n===0&&this._pagesCapability.resolve()},e=>{console.error(`Unable to get page ${r} to initialize viewer`,e),--n===0&&this._pagesCapability.resolve()});r%El.PAUSE_EAGER_PAGE_INIT===0&&await t}}),a.dispatch(`pagesinit`,{source:this}),e.getMetadata().then(({info:t})=>{e===this.pdfDocument&&t.Language&&(s.lang=t.Language)}),this.defaultRenderingQueue&&this.update()}).catch(e=>{console.error(`Unable to initialize viewer`,e),this._pagesCapability.reject(e)})}onPagesEdited({pagesMapper:e,type:t,hasBeenCut:n,pageNumbers:r}){if(t===`copy`){this.#P=/* @__PURE__ */ new Map;for(let e of r)this.#P.set(e,this._pages[e-1]);return}if(t===`cancelCopy`){this.#P=null;return}if((t===`cut`||t===`delete`)&&(this.#F=this._pages,this.#I=r),t===`cancelDelete`){if(this.#I=null,!this.#F)return;let e=this._scrollMode===J.PAGE?null:this.viewer;if(e){this.#i?.startUpdatePages();let t=document.createDocumentFragment();for(let e=0,n=this.#F.length;e<n;e++){let n=this.#F[e];n.updatePageNumber(e+1),t.append(n.div)}e.replaceChildren(t),this.#i?.endUpdatePages()}this._pages=this.#F,this.#F=null;return}if(t===`cleanSavedData`){if(this.#I){if(this.#F){for(let e of this.#I)this.#F[e-1].deleteMe();this.#F=null}this.#I=null}return}this._currentPageNumber=0;let i=this._pages,a=this._pages=[];this.#i?.startUpdatePages();for(let t=1,r=e.pagesNumber;t<=r;t++){let r=e.getPrevPageNumber(t);if(r<0){let e=this.#P.get(-r);n?e.updatePageNumber(t):(this.#i?.clonePage(-r-1,t-1),e=e.clone(t)),a.push(e);continue}let o=i[r-1];a.push(o),o.updatePageNumber(t)}this.#i?.endUpdatePages(),t===`paste`&&(this.#P=null);let o=this._scrollMode===J.PAGE?null:this.viewer;if(o){let e=document.createDocumentFragment();for(let{div:t}of a)e.append(t);o.replaceChildren(e)}setTimeout(()=>{this.forceRendering()})}setPageLabels(e){if(this.pdfDocument){e?Array.isArray(e)&&this.pdfDocument.numPages===e.length?this._pageLabels=e:(this._pageLabels=null,console.error(`setPageLabels: Invalid page labels.`)):this._pageLabels=null;for(let e=0,t=this._pages.length;e<t;e++)this._pages[e].setPageLabel(this._pageLabels?.[e]??null)}}_resetView(){this._pages=[],this._currentPageNumber=1,this._currentScale=0,this._currentScaleValue=null,this._pageLabels=null,this.#e=new Ol(10),this._location=null,this._pagesRotation=0,this._optionalContentConfigPromise=null,this._firstPageCapability=Promise.withResolvers(),this._onePageRenderedCapability=Promise.withResolvers(),this._pagesCapability=Promise.withResolvers(),this._scrollMode=J.VERTICAL,this._previousScrollMode=J.UNKNOWN,this._spreadMode=Y.NONE,this.#O={previousPageNumber:1,scrollDown:!0,pages:[]},this.#h?.abort(),this.#h=null,this.viewer.textContent=``,this._updateScrollMode(),this.viewer.removeAttribute(`lang`),this.#T?.remove(),this.#T=null,this.#te(),this.#ne()}#V(){if(this._scrollMode!==J.PAGE)throw Error(`#ensurePageViewVisible: Invalid scrollMode value.`);let e=this._currentPageNumber,t=this.#O,n=this.viewer;if(n.textContent=``,t.pages.length=0,this._spreadMode===Y.NONE&&!this.isInPresentationMode){let r=this._pages[e-1];n.append(r.div),t.pages.push(r)}else{let r=/* @__PURE__ */ new Set,i=this._spreadMode-1;i===-1?r.add(e-1):e%2===i?(r.add(e-2),r.add(e-1)):(r.add(e-1),r.add(e));let a=document.createElement(`div`);if(a.className=`spread`,this.isInPresentationMode){let e=document.createElement(`div`);e.className=`dummyPage`,a.append(e)}for(let e of r){let n=this._pages[e];n&&(a.append(n.div),t.pages.push(n))}n.append(a)}t.scrollDown=e>=t.previousPageNumber,t.previousPageNumber=e}_scrollUpdate(){this.pagesCount!==0&&(this.#b&&clearTimeout(this.#b),this.#b=setTimeout(()=>{this.#b=null,this.update()},100),this.update())}#H(e,t=null){let{div:n,id:r}=e;if(this._currentPageNumber!==r&&this._setCurrentPageNumber(r),this._scrollMode===J.PAGE&&(this.#V(),this.update()),!t&&!this.isInPresentationMode){let e=n.offsetLeft+n.clientLeft,r=e+n.clientWidth,{scrollLeft:i,clientWidth:a}=this.container;(this._scrollMode===J.HORIZONTAL||e<i||r>i+a)&&(t={left:0,top:0})}Mo(n,t),!this._currentScaleValue&&this._location&&(this._location=null)}#U(e){return e===this._currentScale||Math.abs(e-this._currentScale)<1e-15}panBy(e,t){let{container:n}=this,r=this.#v,{scrollLeft:i,scrollTop:a}=n,o=(Math.abs(i-r[0])<1?r[0]:i)-e,s=(Math.abs(a-r[1])<1?r[1]:a)-t;r[0]=o,r[1]=s,n.scrollLeft=o,n.scrollTop=s,this.#x=!0}#W(){if(!this.#x)return;let{first:e}=this._getVisiblePages();e&&this._updateLocation(e)}#G(e,t,{noScroll:n=!1,preset:r=!1,drawingDelay:i=-1,origin:a=null,pan:o=null}){if(this._currentScaleValue=t.toString(),this.#U(e)){o&&!n&&this.panBy(o[0],o[1]),r&&this.eventBus.dispatch(`scalechanging`,{source:this,scale:e,presetValue:t});return}this.clearSelection(),this.viewer.style.setProperty(`--scale-factor`,e*oo.PDF_TO_CSS_UNITS);let s=i>=0&&i<1e3;this.refresh(!0,{scale:e,drawingDelay:s?i:-1}),s&&(this.#k=setTimeout(()=>{this.#k=null,this.refresh()},i));let c=this._currentScale;if(this._currentScale=e,!n){this.#W();let t=this._currentPageNumber,n;this._location&&!(this.isInPresentationMode||this.isChangingPresentationMode)&&(t=this._location.pageNumber,n=[null,{name:`XYZ`},this._location.left,this._location.top,null]),this.scrollPageIntoView({pageNumber:t,destArray:n,allowNegativeOffset:!0});let r=o?.[0]??0,i=o?.[1]??0;if(Array.isArray(a)){let t=e/c-1,[n,o]=this.containerTopLeft;r-=(a[0]-o)*t,i-=(a[1]-n)*t}(r||i)&&this.panBy(r,i)}this.eventBus.dispatch(`scalechanging`,{source:this,scale:e,presetValue:r?t:void 0}),this.defaultRenderingQueue&&this.update()}get#K(){return this._spreadMode!==Y.NONE&&this._scrollMode!==J.HORIZONTAL?2:1}#q(e,t){let n=parseFloat(e);if(n>0)t.preset=!1,this.#G(n,e,t);else{let r=this._pages[this._currentPageNumber-1];if(!r)return;let i=40,a=5;this.isInPresentationMode?(i=a=4,this._spreadMode!==Y.NONE&&(i*=2)):this.removePageBorders?i=a=0:this._scrollMode===J.HORIZONTAL&&([i,a]=[a,i]);let o=(this.container.clientWidth-i)/r.width*r.scale/this.#K,s=(this.container.clientHeight-a)/r.height*r.scale;switch(e){case`page-actual`:n=1;break;case`page-width`:n=o;break;case`page-height`:n=s;break;case`page-fit`:n=Math.min(o,s);break;case`auto`:let t=Ko(r)?o:Math.min(s,o);n=Math.min(1.25,t);break;default:console.error(`#setScale: "${e}" is an unknown zoom value.`);return}t.preset=!0,this.#G(n,e,t)}}#J(){let e=this._pages[this._currentPageNumber-1];this.isInPresentationMode&&this.#q(this._currentScaleValue,{noScroll:!0}),this.#H(e)}pageLabelToPageNumber(e){if(!this._pageLabels)return null;let t=this._pageLabels.indexOf(e);return t<0?null:t+1}scrollPageIntoView({pageNumber:e,destArray:t=null,allowNegativeOffset:n=!1,ignoreDestinationZoom:r=!1,center:i=null}){if(!this.pdfDocument)return;let a=Number.isInteger(e)&&this._pages[e-1];if(!a){console.error(`scrollPageIntoView: "${e}" is not a valid pageNumber parameter.`);return}if(this.isInPresentationMode||!t){this._setCurrentPageNumber(e,!0);return}let o=0,s=0,c=0,l=0,u,d,f=a.rotation%180!=0,p=(f?a.height:a.width)/a.scale/oo.PDF_TO_CSS_UNITS,m=(f?a.width:a.height)/a.scale/oo.PDF_TO_CSS_UNITS,h=0;switch(t[1].name){case`XYZ`:o=t[2],s=t[3],h=t[4],o=o===null?0:o,s=s===null?m:s;break;case`Fit`:case`FitB`:h=`page-fit`;break;case`FitH`:case`FitBH`:s=t[2],h=`page-width`,s===null&&this._location?(o=this._location.left,s=this._location.top):(typeof s!=`number`||s<0)&&(s=m);break;case`FitV`:case`FitBV`:o=t[2],c=p,l=m,h=`page-height`;break;case`FitR`:o=t[2],s=t[3],c=t[4]-o,l=t[5]-s;let e=40,n=5;this.removePageBorders&&(e=n=0),u=(this.container.clientWidth-e)/c/oo.PDF_TO_CSS_UNITS,d=(this.container.clientHeight-n)/l/oo.PDF_TO_CSS_UNITS,h=Math.min(Math.abs(u),Math.abs(d));break;default:console.error(`scrollPageIntoView: "${t[1].name}" is not a valid destination type.`);return}if(r||(h&&h!==this._currentScale?this.currentScaleValue=h:this._currentScale===0&&(this.currentScaleValue=`auto`)),h===`page-fit`&&!t[4]){this.#H(a);return}let g=[a.viewport.convertToViewportPoint(o,s),a.viewport.convertToViewportPoint(o+c,s+l)],_=Math.min(g[0][0],g[1][0]),v=Math.min(g[0][1],g[1][1]);i?((i===`both`||i===`vertical`)&&(v-=(this.container.clientHeight-Math.abs(g[1][1]-g[0][1]))/2),(i===`both`||i===`horizontal`)&&(_-=(this.container.clientWidth-Math.abs(g[1][0]-g[0][0]))/2)):n||(_=Math.max(_,0),v=Math.max(v,0)),this.#H(a,{left:_,top:v})}_updateLocation(e){this.#x=!1;let t=this._currentScale,n=this._currentScaleValue,r=parseFloat(n)===t?Math.round(t*1e4)/100:n,i=e.id,a=this._pages[i-1],o=this.container,[s,c]=a.getPagePoint(o.scrollLeft-e.x,o.scrollTop-e.y),l=`#page=${i}`;this.isInPresentationMode||(l+=`&zoom=${r},${Math.round(s)},${Math.round(c)}`),this._location={pageNumber:i,scale:r,top:c,left:s,rotation:this._pagesRotation,pdfOpenParams:l}}update(){let e=this._getVisiblePages(),t=e.views,n=t.length;if(n===0)return;let r=Math.max(10,2*n+1);this.#e.resize(r,e.ids);for(let{view:e,visibleArea:n}of t)e.updateVisibleArea(n);for(let t of this.#e)e.ids.has(t.id)||t.updateVisibleArea(null);this.renderingQueue.renderHighestPriority(e);let i=this._spreadMode===Y.NONE&&(this._scrollMode===J.PAGE||this._scrollMode===J.VERTICAL),a=this._currentPageNumber,o=!1;for(let e of t){if(e.percent<100)break;if(e.id===a&&i){o=!0;break}}this._setCurrentPageNumber(o?this._currentPageNumber:t[0].id),this._updateLocation(e.first),this.eventBus.dispatch(`updateviewarea`,{source:this,location:this._location})}#Y(){let e=this._getVisiblePages(),t=[],{ids:n,views:r}=e;for(let e of r){let{view:r}=e;r.hasEditableAnnotations()?t.push(e):n.delete(r.id)}return t.length===0?null:(this.renderingQueue.renderHighestPriority({first:t[0],last:t.at(-1),views:t,ids:n}),n)}containsElement(e){return this.container.contains(e)}focus(){this.container.focus()}get _isContainerRtl(){return getComputedStyle(this.container).direction===`rtl`}get isInPresentationMode(){return this.presentationModeState===Ao.FULLSCREEN}get isChangingPresentationMode(){return this.presentationModeState===Ao.CHANGING}get isHorizontalScrollbarEnabled(){return!this.isInPresentationMode&&this.container.scrollWidth>this.container.clientWidth}get isVerticalScrollbarEnabled(){return!this.isInPresentationMode&&this.container.scrollHeight>this.container.clientHeight}_getVisiblePages(){let e=this._scrollMode===J.PAGE?this.#O.pages:this._pages,t=this._scrollMode===J.HORIZONTAL,n=t&&this._isContainerRtl;return Ho({scrollEl:this.container,views:e,sortByVisibility:!0,horizontal:t,rtl:n})}cleanup(){for(let e of this._pages)e.renderingState!==$.FINISHED&&e.reset()}_cancelRendering(){for(let e of this._pages)e.cancelRendering()}async#X(e){if(e.pdfPage)return e.pdfPage;try{let t=await this.pdfDocument.getPage(e.id);return e.pdfPage||e.setPdfPage(t),t}catch(e){return console.error(`Unable to get page for page view`,e),null}}#Z(e){if(e.first?.id===1)return!0;if(e.last?.id===this.pagesCount)return!1;switch(this._scrollMode){case J.PAGE:return this.#O.scrollDown;case J.HORIZONTAL:return this.scroll.right}return this.scroll.down}forceRendering(e){let t=e||this._getVisiblePages(),n=this.#Z(t),r=this._spreadMode!==Y.NONE&&this._scrollMode!==J.HORIZONTAL,i=this.#k!==null||this.#b!==null&&t.views.some(e=>e.detailView?.renderingCancelled),a=this.renderingQueue.getHighestPriority(t,this._pages,n,r,i);return a?(this.#X(a).then(()=>{this.renderingQueue.renderView(a)}),!0):!1}get hasEqualPageSizes(){let e=this._pages[0];for(let t=1,n=this._pages.length;t<n;++t){let n=this._pages[t];if(n.width!==e.width||n.height!==e.height)return!1}return!0}getPagesOverview(){let e;return this._pages.map(t=>{let n=t.pdfPage.getViewport({scale:1}),r=Ko(n);if(e===void 0)e=r;else if(this.enablePrintAutoRotate&&r!==e)return{width:n.height,height:n.width,rotation:(n.rotation-90)%360};return{width:n.width,height:n.height,rotation:n.rotation}})}get optionalContentConfigPromise(){return this.pdfDocument?this._optionalContentConfigPromise?this._optionalContentConfigPromise:(console.error(`optionalContentConfigPromise: Not initialized yet.`),this.pdfDocument.getOptionalContentConfig({intent:`display`})):Promise.resolve(null)}set optionalContentConfigPromise(e){if(!(e instanceof Promise))throw Error(`Invalid optionalContentConfigPromise: ${e}`);this.pdfDocument&&this._optionalContentConfigPromise&&(this._optionalContentConfigPromise=e,this.refresh(!1,{optionalContentConfigPromise:e}),this.eventBus.dispatch(`optionalcontentconfigchanged`,{source:this,promise:e}))}get scrollMode(){return this._scrollMode}set scrollMode(e){if(this._scrollMode!==e){if(!Wo(e))throw Error(`Invalid scroll mode: ${e}`);this.pagesCount>El.FORCE_SCROLL_MODE_PAGE||(this._previousScrollMode=this._scrollMode,this.clearSelection(),this._scrollMode=e,this.eventBus.dispatch(`scrollmodechanged`,{source:this,mode:e}),this._updateScrollMode(this._currentPageNumber))}}_updateScrollMode(e=null){let t=this._scrollMode,n=this.viewer;n.classList.toggle(`scrollHorizontal`,t===J.HORIZONTAL),n.classList.toggle(`scrollWrapped`,t===J.WRAPPED),this.pdfDocument&&e&&(t===J.PAGE?this.#V():this._previousScrollMode===J.PAGE&&this._updateSpreadMode(),this._currentScaleValue&&isNaN(this._currentScaleValue)&&this.#q(this._currentScaleValue,{noScroll:!0}),this._setCurrentPageNumber(e,!0),this.update())}get spreadMode(){return this._spreadMode}set spreadMode(e){if(this._spreadMode!==e){if(!Go(e))throw Error(`Invalid spread mode: ${e}`);this.clearSelection(),this._spreadMode=e,this.eventBus.dispatch(`spreadmodechanged`,{source:this,mode:e}),this._updateSpreadMode(this._currentPageNumber)}}_updateSpreadMode(e=null){if(!this.pdfDocument)return;let t=this.viewer,n=this._pages;if(this._scrollMode===J.PAGE)this.#V();else if(t.textContent=``,this._spreadMode===Y.NONE)for(let e of this._pages)t.append(e.div);else{let e=this._spreadMode-1,r=null;for(let i=0,a=n.length;i<a;++i)r===null?(r=document.createElement(`div`),r.className=`spread`,t.append(r)):i%2===e&&(r=r.cloneNode(!1),t.append(r)),r.append(n[i].div)}e&&(this._currentScaleValue&&isNaN(this._currentScaleValue)&&this.#q(this._currentScaleValue,{noScroll:!0}),this._setCurrentPageNumber(e,!0),this.update())}#Q(e,t=!1){switch(this._scrollMode){case J.WRAPPED:{let{views:n}=this._getVisiblePages(),r=/* @__PURE__ */ new Map;for(let{id:e,y:t,percent:i,widthPercent:a}of n)i===0||a<100||r.getOrInsertComputed(t,Ga).push(e);for(let n of r.values()){let r=n.indexOf(e);if(r===-1)continue;let i=n.length;if(i===1)break;if(t)for(let t=r-1,i=0;t>=0;t--){let r=n[t],i=n[t+1]-1;if(r<i)return e-i}else for(let t=r+1,a=i;t<a;t++){let r=n[t],i=n[t-1]+1;if(r>i)return i-e}if(t){let t=n[0];if(t<e)return e-t+1}else{let t=n[i-1];if(t>e)return t-e+1}break}break}case J.HORIZONTAL:break;case J.PAGE:case J.VERTICAL:{if(this._spreadMode===Y.NONE)break;let n=this._spreadMode-1;if(t&&e%2!==n||!t&&e%2===n)break;let{views:r}=this._getVisiblePages(),i=t?e-1:e+1;for(let{id:e,percent:t,widthPercent:n}of r)if(e===i){if(t>0&&n===100)return 2;break}break}}return 1}nextPage(){let e=this._currentPageNumber,t=this.pagesCount;if(e>=t)return!1;let n=this.#Q(e,!1)||1;return this.currentPageNumber=Math.min(e+n,t),!0}previousPage(){let e=this._currentPageNumber;if(e<=1)return!1;let t=this.#Q(e,!0)||1;return this.currentPageNumber=Math.max(e-t,1),!0}updateScale({drawingDelay:e,scaleFactor:t=null,steps:n=null,origin:r,pan:i=null}){if(n===null&&t===null)throw Error("Invalid updateScale options: either `steps` or `scaleFactor` must be provided.");if(!this.pdfDocument)return;let a=this._currentScale;if(t>0&&t!==1)a=Math.round(a*t*100)/100;else if(n){let e=n>0?1.1:1/1.1,t=n>0?Math.ceil:Math.floor;n=Math.abs(n);do a=t((a*e).toFixed(2)*10)/10;while(--n>0)}a=Ya(a,.1,25),this.#q(a,{noScroll:!1,drawingDelay:e,origin:r,pan:i})}increaseScale(e={}){this.updateScale({...e,steps:e.steps??1})}decreaseScale(e={}){this.updateScale({...e,steps:-(e.steps??1)})}#$(e=this.container.clientHeight){e!==this.#E&&(this.#E=e,qo.setProperty(`--viewer-container-height`,`${e}px`))}#ee(e){for(let t of e)if(t.target===this.container){this.#$(Math.floor(t.borderBoxSize[0].blockSize)),this.#s=null;break}}get containerTopLeft(){return this.#s||=[this.container.offsetTop,this.container.offsetLeft]}#te(){this.#k!==null&&(clearTimeout(this.#k),this.#k=null),this.#b!==null&&(clearTimeout(this.#b),this.#b=null)}#ne(){this.#S?.abort(),this.#S=null,this.#C!==null&&(clearTimeout(this.#C),this.#C=null)}#re(e){switch(e){case q.STAMP:this.#_?.loadModel(`altText`);break;case q.SIGNATURE:this.#A?.loadSignatures()}}get annotationEditorMode(){return this.#i?this.#r:q.DISABLE}set annotationEditorMode({mode:e,editId:t=null,isFromKeyboard:n=!1,mustEnterInEditMode:r=!1,editComment:i=!1}){if(!this.#i)throw Error(`The AnnotationEditor is not enabled.`);if(this.#r===e)return;if(!Dl(e))throw Error(`Invalid AnnotationEditor mode: ${e}`);if(!this.pdfDocument)return;this.#re(e);let{eventBus:a,pdfDocument:o}=this,s=async()=>{this.#ne(),this.#r=e,await this.#i.updateMode(e,t,!0,n,r,i),e===this.#r&&o===this.pdfDocument&&a.dispatch(`annotationeditormodechanged`,{source:this,mode:e})};if(e===q.NONE||this.#r===q.NONE){let t=e!==q.NONE;t||this.pdfDocument.annotationStorage.resetModifiedIds(),this.cleanup();for(let e of this._pages)e.toggleEditingMode(t);let n=this.#Y();if(t&&n){this.#ne(),this.#S=new AbortController;let e=AbortSignal.any([this.#h.signal,this.#S.signal]);a.on(`pagerendered`,({pageNumber:e})=>{n.delete(e),n.size===0&&(this.#C=setTimeout(s,0))},{signal:e,...X});return}}s()}refresh(e=!1,t=Object.create(null)){if(this.pdfDocument){for(let e of this._pages)e.update(t);this.#te(),e||this.update()}}};globalThis.pdfjsViewer={AnnotationLayerBuilder:hs,DownloadManager:_s,EventBus:bs,FindState:Qo,GenericL10n:Hc,LinkTarget:fs,parseQueryString:Po,PDFFindController:ds,PDFHistory:Wc,PDFLinkService:ps,PDFPageView:bl,PDFScriptingManager:wl,PDFSinglePageViewer:class extends kl{_resetView(){super._resetView(),this._scrollMode=J.PAGE,this._spreadMode=Y.NONE}set scrollMode(e){}_updateScrollMode(){}set spreadMode(e){}_updateSpreadMode(){}},PDFViewer:kl,ProgressBar:Jo,RenderingStates:$,ScrollMode:J,SimpleLinkService:ms,SpreadMode:Y,StructTreeLayerBuilder:pl,TextLayerBuilder:gl,XfaLayerBuilder:_l};function Al(e){return(t,n)=>{let r=new gl({pdfPage:t}),i=r.div;i.style.setProperty(`--total-scale-factor`,String(n.scale*n.userUnit)),i.style.setProperty(`--scale-round-x`,`1px`),i.style.setProperty(`--scale-round-y`,`1px`),e.append(i);let a=()=>{i.style.scale=String(e.getBoundingClientRect().width/n.width)},o=new ResizeObserver(a);return o.observe(e),a(),{promise:r.render({viewport:n}),cancel(){o.disconnect(),r.cancel(),i.remove()}}}}let jl=`@deepseek-ai/dsh-client-ui-sidebar-documentpreview/PdfBody.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(jl)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-sidebar-documentpreview`,e.dataset.pluginCss=jl,e.textContent=`.Qi9xlq_body{box-sizing:border-box;background:var(--dsw-alias-bg-document-preview);width:100%;min-width:100%;min-height:100%;font-family:var(--dsw-font,sans-serif);white-space:normal;flex-direction:column;gap:12px;padding:12px;display:flex;overflow:visible}[data-document-zoom-mode=fixed] .Qi9xlq_body{width:max-content}.Qi9xlq_page{box-sizing:border-box;width:100%;min-width:0;overflow-x:visible}.Qi9xlq_placeholder{aspect-ratio:3/4;background:var(--dsw-alias-bg-skeleton);width:100%}.Qi9xlq_canvas{width:100%;max-width:none;height:100%;margin-inline:auto;display:block;position:absolute;inset:0}.Qi9xlq_surface{width:min(var(--pdf-page-width,100%), 100%);max-width:none;box-shadow:var(--dsw-elevation-prominent);margin-inline:auto;position:relative}.Qi9xlq_surface[hidden]{display:none}.Qi9xlq_text{position:absolute;inset:0;overflow:clip}.Qi9xlq_text .textLayer{text-align:initial;letter-spacing:normal;word-spacing:normal;text-size-adjust:none;forced-color-adjust:none;transform-origin:0 0;caret-color:canvastext;z-index:0;--text-scale-factor:calc(var(--total-scale-factor) * var(--min-font-size));--min-font-size-inv:calc(1 / var(--min-font-size));line-height:1;position:absolute;inset:0;overflow:clip}.Qi9xlq_text .textLayer[data-main-rotation="90"]{transform:rotate(90deg)translateY(-100%)}.Qi9xlq_text .textLayer[data-main-rotation="180"]{transform:rotate(180deg)translate(-100%,-100%)}.Qi9xlq_text .textLayer[data-main-rotation="270"]{transform:rotate(270deg)translate(-100%)}.Qi9xlq_text :is(span,br){color:#0000;white-space:pre;cursor:text;transform-origin:0 0;user-select:text;position:absolute}.Qi9xlq_text .textLayer>:not(.markedContent),.Qi9xlq_text .markedContent span:not(.markedContent){z-index:1;--font-height:0;--scale-x:1;--rotate:0deg;font-size:calc(var(--text-scale-factor) * var(--font-height));transform:rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv))}.Qi9xlq_text .markedContent{display:contents}.Qi9xlq_text ::selection{background:var(--dsw-alias-bg-document-selection);color:#0000}.Qi9xlq_text br::selection{background:0 0}.Qi9xlq_text .textLayer .endOfContent{z-index:0;cursor:default;user-select:none;display:block;position:absolute;inset:100% 0 0}.Qi9xlq_text .selecting .endOfContent{top:0}.Qi9xlq_status{color:var(--dsw-alias-label-secondary);align-items:center;gap:8px;padding:10px;font-size:13px;line-height:1.5;display:flex}.Qi9xlq_body .Qi9xlq_status{color:var(--dsw-alias-label-document-preview)}`,document.head.appendChild(e)}var Ml={body:`Qi9xlq_body`,canvas:`Qi9xlq_canvas`,page:`Qi9xlq_page`,placeholder:`Qi9xlq_placeholder`,status:`Qi9xlq_status`,surface:`Qi9xlq_surface`,text:`Qi9xlq_text`};let Nl={page:1},Pl={kind:`fit-width`};function Fl(e){let{tab:t}=e.useTabInfo(),n=e.useStore(e=>e.byTab[t.id]??Nl),o=e.content.kind===`bytes`?e.content.data:void 0,[s,c]=(0,r.useState)(),[l,u]=(0,r.useState)(0),[d,f]=(0,r.useState)(),[p,m]=(0,r.useState)(1),{retainTab:h,actions:g,t:_,ZoomViewport:v,zoomSurfaceClass:y}=e,b=n.zoom??Pl,x={controls:_(`zoomControls`),menu:_(`zoomMenu`),out:_(`zoomOut`),into:_(`zoomIn`),fitWidth:_(`zoomFitWidth`),value:e=>_(`zoomValue`,{percent:e})},S=(0,r.useCallback)(e=>{g.page(t.id,e)},[g,t.id]),C=(0,r.useCallback)(e=>{g.zoom(t.id,e)},[g,t.id]);if((0,r.useEffect)(()=>{h(t.id,t.signal)},[h,t.id,t.signal]),(0,r.useEffect)(()=>{if(o===void 0||t.signal.aborted)return;let e=new AbortController,n=AbortSignal.any([e.signal,t.signal]);c(void 0);let r=ha(o,n,e=>{n.aborted||c({kind:`failed`,data:o,error:e})});return r.document.then(e=>{n.aborted||c({kind:`loaded`,data:o,document:e})},e=>{n.aborted||c({kind:`failed`,data:o,error:e})}),()=>{e.abort(),r.dispose()}},[o,t.signal,l]),(0,r.useEffect)(()=>{if(s?.kind!==`loaded`||s.data!==o){f(void 0);return}if(s.document.numPages<1||t.signal.aborted)return;let e=!1;return s.document.getPage(1).then(n=>{try{if(!e&&!t.signal.aborted){let{width:e}=n.getViewport({scale:96/72});f(e)}}finally{n.cleanup()}},()=>{}),()=>{e=!0}},[o,s,t.signal]),o===void 0)return/* @__PURE__ */ (0,a.jsx)(`p`,{className:Ml.status,role:`alert`,children:_(`unsupported`)});if(s?.data!==o)return e.loading;if(s.kind===`failed`)return/* @__PURE__ */ (0,a.jsxs)(`div`,{className:Ml.status,role:`alert`,children:[/* @__PURE__ */ (0,a.jsx)(`span`,{children:Rl(s.error,_)}),/* @__PURE__ */ (0,a.jsx)(i.Button,{size:`sm`,onClick:()=>{u(e=>e+1)},children:_(`retry`)})]});let w=/* @__PURE__ */ (0,a.jsx)(`section`,{className:Ml.body,"data-pdf-preview":!0,children:Array.from({length:s.document.numPages},(e,r)=>/* @__PURE__ */ (0,a.jsx)(Ll,{document:s.document,page:r+1,requested:r===0||n.page===r+1,onVisible:S,signal:t.signal,onWidth:r===0?f:void 0,zoom:p,zoomSurfaceClass:y,t:_},r))});return/* @__PURE__ */ (0,a.jsx)(v,{preference:b,intrinsicWidth:d,horizontalInset:24,labels:x,signal:t.signal,scrollportRef:e.scrollportRef,onPreference:C,onRenderZoom:m,children:w})}function Il(e){e!==null&&(e.width!==0&&(e.width=0),e.height!==0&&(e.height=0))}function Ll({document:e,page:t,requested:n,onVisible:s,signal:c,onWidth:l,zoom:u,zoomSurfaceClass:d,t:f}){let p=(0,r.useRef)(null),m=(0,r.useRef)(null),h=(0,r.useRef)(null),g=(0,r.useRef)(null),[_,v]=(0,r.useState)(),[y,b]=(0,r.useState)(n),[x,S]=(0,r.useState)(n),C=(0,r.useRef)(),w=(0,r.useRef)(Promise.resolve()),T=(0,r.useRef)(),[E,D]=(0,r.useState)(`loading`),[O,ee]=(0,r.useState)(),[k,A]=(0,r.useState)(0);(0,r.useEffect)(()=>{let e=E===`ready`?m.current:p.current;if(typeof IntersectionObserver>`u`){b(!0),S(!0);return}let n=!1,r=new IntersectionObserver(e=>{if(n)return;let r=e.at(-1);if(r===void 0)return;let i=r.isIntersecting;S(i),i&&(b(!0),s(t))},{rootMargin:`100% 0px`});return r.observe(e),()=>{n=!0,r.disconnect()}},[t,s,E]),(0,r.useEffect)(()=>{let e=h.current;return()=>{T.current?.cancel(),T.current=void 0,Il(e),C.current=void 0}},[e,t]),(0,r.useEffect)(()=>{if(!x){Il(h.current),C.current=void 0;return}if(!y||(ee(void 0),C.current===u))return;let n=h.current,r=new AbortController,i=AbortSignal.any([r.signal,c]),a;return w.current=w.current.then(async()=>{i.throwIfAborted();let r=n.ownerDocument.createElement(`canvas`);try{let s=await o(e,t,r,i,window.devicePixelRatio*u,T.current===void 0?(e,t)=>(a=Al(g.current)(e,t),a):void 0);i.throwIfAborted();let c=n.getContext(`2d`);if(c===null)throw Error(`PDF canvas has no 2D context`);n.width=r.width,n.height=r.height,n.style.setProperty(`--pdf-page-width`,`${s.width}px`),n.style.setProperty(`--pdf-page-height`,`${s.height}px`),c.drawImage(r,0,0),T.current??=a,a=void 0,C.current=u,v(e=>e!==void 0&&e.width===s.width&&e.height===s.height?e:s),l?.(s.width),D(`ready`)}finally{r.width=r.height=0,a?.cancel()}}).catch(e=>{i.aborted||ee({error:e})}),()=>{r.abort(),a?.cancel()}},[e,t,y,x,u,c,k,l]);let j=_===void 0?void 0:{"--pdf-page-width":`${_.width}px`,"--pdf-page-height":`${_.height}px`},M=_===void 0?{"--document-zoom-width":`0px`}:{"--document-zoom-width":`${_.width}px`,aspectRatio:`${_.width} / ${_.height}`};return/* @__PURE__ */ (0,a.jsxs)(`div`,{ref:p,className:Ml.page,"data-pdf-page":t,style:j,children:[O===void 0&&E!==`ready`&&(y?/* @__PURE__ */ (0,a.jsx)(`div`,{className:Ml.placeholder,role:`status`,"aria-label":f(`rendering`)}):/* @__PURE__ */ (0,a.jsx)(`div`,{className:Ml.placeholder})),O!==void 0&&/* @__PURE__ */ (0,a.jsxs)(`div`,{className:Ml.status,role:`alert`,children:[/* @__PURE__ */ (0,a.jsx)(`span`,{children:Rl(O.error,f)}),/* @__PURE__ */ (0,a.jsx)(i.Button,{size:`sm`,onClick:()=>{A(e=>e+1)},children:f(`retry`)})]}),/* @__PURE__ */ (0,a.jsxs)(`div`,{ref:m,className:`${Ml.surface} ${d}`,"data-document-zoom-surface":!0,style:M,hidden:E!==`ready`,children:[/* @__PURE__ */ (0,a.jsx)(`canvas`,{ref:h,className:Ml.canvas,role:`img`,"aria-label":f(`pageImage`,{page:t})}),/* @__PURE__ */ (0,a.jsx)(`div`,{ref:g,className:Ml.text,"data-pdf-text":!0})]})]})}function Rl(e,t){return e instanceof pa?t(`workerFailed`):e instanceof Error&&e.name===`PasswordException`?t(`password`):t(`failed`,{message:e instanceof Error?e.message:String(e)})}return n.PdfBody=Fl,t.exports}});
605
+ `)}#B(e,t){let n=document.getSelection(),{focusNode:r,anchorNode:i}=n;if(i&&r&&n.containsNode(this.#T)){if(this.#w||e===jo.ENABLE_PERMISSIONS){mo(t);return}this.#w=!0;let{classList:n}=this.viewer;n.add(`copyAll`);let r=new AbortController,i=new AbortController;window.addEventListener(`keydown`,e=>{e.key===`Escape`&&i.abort()},{signal:r.signal}),this.getAllText(i.signal).then(async e=>{e!==null&&await navigator.clipboard.writeText(e)}).catch(e=>{console.warn(`Something goes wrong when extracting the text: ${e.message}`)}).finally(()=>{this.#w=!1,r.abort(),n.remove(`copyAll`)}),mo(t)}}setDocument(e){if(this.pdfDocument&&(this.eventBus.dispatch(`pagesdestroy`,{source:this}),this._cancelRendering(),this._resetView(),this.findController?.setDocument(null),this._scriptingManager?.setDocument(null),this.#i?.destroy(),this.#i=null,this.#r=q.NONE,this.#y=!0),this.pdfDocument=e,!e)return;let t=e.numPages,n=e.getPage(1),r=e.getOptionalContentConfig({intent:`display`}),i=this.#u?e.getPermissions():Promise.resolve(),{eventBus:a,pageColors:o,viewer:s}=this;this.#h=new AbortController;let{signal:c}=this.#h,l={signal:c,...X};if(t>El.FORCE_SCROLL_MODE_PAGE){console.warn(`Forcing PAGE-scrolling for performance reasons, given the length of the document.`);let e=this._scrollMode=J.PAGE;a.dispatch(`scrollmodechanged`,{source:this,mode:e})}this._pagesCapability.promise.then(()=>{a.dispatch(`pagesloaded`,{source:this,pagesCount:t})},()=>{}),a.on(`pagerender`,e=>{let t=this._pages[e.pageNumber-1];t&&this.#e.push(t)},l);let u=e=>{e.cssTransform||e.isDetailView||(this._onePageRenderedCapability.resolve({timestamp:e.timestamp}),a.off(`pagerendered`,u))};a.on(`pagerendered`,u,l),Promise.all([n,i]).then(([n,i])=>{if(e!==this.pdfDocument)return;this._firstPageCapability.resolve(n),this._optionalContentConfigPromise=r;let{annotationEditorMode:l,annotationMode:u,textLayerMode:d}=this.#R(i);if(d!==jo.DISABLE){let e=this.#T=document.createElement(`div`);e.id=`hiddenCopyElement`,e.style.cssText=`position:absolute;top:0;left:0;width:0;height:0;display:none`,s.before(e)}if(l!==q.DISABLE){let t=l;e.isPureXfa?console.warn(`Warning: XFA-editing is not implemented.`):Dl(t)?(this.#i=new ya(this.container,s,this.#N,this.#t,this.#o,this.#A,a,e,o,this.#n,this.#l,this.#d,this.#f,this.#_,this.#c,this.#j),a.dispatch(`annotationeditoruimanager`,{source:this,uiManager:this.#i}),t!==q.NONE&&(this.#re(t),this.#i.updateMode(t))):console.error(`Invalid AnnotationEditor mode: ${t}`)}let f=this._scrollMode===J.PAGE?null:s,p=this.currentScale,m=n.getViewport({scale:p*oo.PDF_TO_CSS_UNITS});s.style.setProperty(`--scale-factor`,m.scale),o?.background&&s.style.setProperty(`--page-bg-color`,o.background),(o?.foreground===`CanvasText`||o?.background===`Canvas`)&&(s.style.setProperty(`--hcm-highlight-filter`,e.filterFactory.addHighlightHCMFilter(`highlight`,`CanvasText`,`Canvas`,`HighlightText`,`Highlight`)),s.style.setProperty(`--hcm-highlight-selected-filter`,e.filterFactory.addHighlightHCMFilter(`highlight_selected`,`CanvasText`,`Canvas`,`HighlightText`,`ButtonText`)));for(let e=1;e<=t;++e){let t=new bl({container:f,eventBus:a,id:e,scale:p,defaultViewport:m.clone(),optionalContentConfigPromise:r,renderingQueue:this.renderingQueue,textLayerMode:d,annotationMode:u,imageResourcesPath:this.imageResourcesPath,maxCanvasPixels:this.maxCanvasPixels,maxCanvasDim:this.maxCanvasDim,capCanvasAreaFactor:this.capCanvasAreaFactor,enableDetailCanvas:this.enableDetailCanvas,enableOptimizedPartialRendering:this.enableOptimizedPartialRendering,enableSelectionRendering:this.enableSelectionRendering,imagesRightClickMinSize:this.imagesRightClickMinSize,pageColors:o,l10n:this.l10n,layerProperties:this._layerProperties,enableAutoLinking:this.#p,minDurationToUpdateCanvas:this.#g,commentManager:this.#o,abortSignal:this.#m});this._pages.push(t)}this._pages[0]?.setPdfPage(n),this._scrollMode===J.PAGE?this.#V():this._spreadMode!==Y.NONE&&this._updateSpreadMode(),a.on(`annotationeditorlayerrendered`,e=>{this.#i&&a.dispatch(`annotationeditormodechanged`,{source:this,mode:this.#r})},{once:!0,signal:c,...X}),this.#z(c).then(async()=>{if(e!==this.pdfDocument)return;if(this.findController?.setDocument(e),this._scriptingManager?.setDocument(e),this.#T&&document.addEventListener(`copy`,this.#B.bind(this,d),{signal:c}),e.loadingParams.disableAutoFetch||t>El.FORCE_LAZY_PAGE_INIT){this._pagesCapability.resolve();return}let n=t-1;if(n<=0)this._pagesCapability.resolve();else for(let r=2;r<=t;++r){let t=e.getPage(r).then(e=>{let t=this._pages[r-1];t.pdfPage||t.setPdfPage(e),--n===0&&this._pagesCapability.resolve()},e=>{console.error(`Unable to get page ${r} to initialize viewer`,e),--n===0&&this._pagesCapability.resolve()});r%El.PAUSE_EAGER_PAGE_INIT===0&&await t}}),a.dispatch(`pagesinit`,{source:this}),e.getMetadata().then(({info:t})=>{e===this.pdfDocument&&t.Language&&(s.lang=t.Language)}),this.defaultRenderingQueue&&this.update()}).catch(e=>{console.error(`Unable to initialize viewer`,e),this._pagesCapability.reject(e)})}onPagesEdited({pagesMapper:e,type:t,hasBeenCut:n,pageNumbers:r}){if(t===`copy`){this.#P=/* @__PURE__ */ new Map;for(let e of r)this.#P.set(e,this._pages[e-1]);return}if(t===`cancelCopy`){this.#P=null;return}if((t===`cut`||t===`delete`)&&(this.#F=this._pages,this.#I=r),t===`cancelDelete`){if(this.#I=null,!this.#F)return;let e=this._scrollMode===J.PAGE?null:this.viewer;if(e){this.#i?.startUpdatePages();let t=document.createDocumentFragment();for(let e=0,n=this.#F.length;e<n;e++){let n=this.#F[e];n.updatePageNumber(e+1),t.append(n.div)}e.replaceChildren(t),this.#i?.endUpdatePages()}this._pages=this.#F,this.#F=null;return}if(t===`cleanSavedData`){if(this.#I){if(this.#F){for(let e of this.#I)this.#F[e-1].deleteMe();this.#F=null}this.#I=null}return}this._currentPageNumber=0;let i=this._pages,a=this._pages=[];this.#i?.startUpdatePages();for(let t=1,r=e.pagesNumber;t<=r;t++){let r=e.getPrevPageNumber(t);if(r<0){let e=this.#P.get(-r);n?e.updatePageNumber(t):(this.#i?.clonePage(-r-1,t-1),e=e.clone(t)),a.push(e);continue}let o=i[r-1];a.push(o),o.updatePageNumber(t)}this.#i?.endUpdatePages(),t===`paste`&&(this.#P=null);let o=this._scrollMode===J.PAGE?null:this.viewer;if(o){let e=document.createDocumentFragment();for(let{div:t}of a)e.append(t);o.replaceChildren(e)}setTimeout(()=>{this.forceRendering()})}setPageLabels(e){if(this.pdfDocument){e?Array.isArray(e)&&this.pdfDocument.numPages===e.length?this._pageLabels=e:(this._pageLabels=null,console.error(`setPageLabels: Invalid page labels.`)):this._pageLabels=null;for(let e=0,t=this._pages.length;e<t;e++)this._pages[e].setPageLabel(this._pageLabels?.[e]??null)}}_resetView(){this._pages=[],this._currentPageNumber=1,this._currentScale=0,this._currentScaleValue=null,this._pageLabels=null,this.#e=new Ol(10),this._location=null,this._pagesRotation=0,this._optionalContentConfigPromise=null,this._firstPageCapability=Promise.withResolvers(),this._onePageRenderedCapability=Promise.withResolvers(),this._pagesCapability=Promise.withResolvers(),this._scrollMode=J.VERTICAL,this._previousScrollMode=J.UNKNOWN,this._spreadMode=Y.NONE,this.#O={previousPageNumber:1,scrollDown:!0,pages:[]},this.#h?.abort(),this.#h=null,this.viewer.textContent=``,this._updateScrollMode(),this.viewer.removeAttribute(`lang`),this.#T?.remove(),this.#T=null,this.#te(),this.#ne()}#V(){if(this._scrollMode!==J.PAGE)throw Error(`#ensurePageViewVisible: Invalid scrollMode value.`);let e=this._currentPageNumber,t=this.#O,n=this.viewer;if(n.textContent=``,t.pages.length=0,this._spreadMode===Y.NONE&&!this.isInPresentationMode){let r=this._pages[e-1];n.append(r.div),t.pages.push(r)}else{let r=/* @__PURE__ */ new Set,i=this._spreadMode-1;i===-1?r.add(e-1):e%2===i?(r.add(e-2),r.add(e-1)):(r.add(e-1),r.add(e));let a=document.createElement(`div`);if(a.className=`spread`,this.isInPresentationMode){let e=document.createElement(`div`);e.className=`dummyPage`,a.append(e)}for(let e of r){let n=this._pages[e];n&&(a.append(n.div),t.pages.push(n))}n.append(a)}t.scrollDown=e>=t.previousPageNumber,t.previousPageNumber=e}_scrollUpdate(){this.pagesCount!==0&&(this.#b&&clearTimeout(this.#b),this.#b=setTimeout(()=>{this.#b=null,this.update()},100),this.update())}#H(e,t=null){let{div:n,id:r}=e;if(this._currentPageNumber!==r&&this._setCurrentPageNumber(r),this._scrollMode===J.PAGE&&(this.#V(),this.update()),!t&&!this.isInPresentationMode){let e=n.offsetLeft+n.clientLeft,r=e+n.clientWidth,{scrollLeft:i,clientWidth:a}=this.container;(this._scrollMode===J.HORIZONTAL||e<i||r>i+a)&&(t={left:0,top:0})}Mo(n,t),!this._currentScaleValue&&this._location&&(this._location=null)}#U(e){return e===this._currentScale||Math.abs(e-this._currentScale)<1e-15}panBy(e,t){let{container:n}=this,r=this.#v,{scrollLeft:i,scrollTop:a}=n,o=(Math.abs(i-r[0])<1?r[0]:i)-e,s=(Math.abs(a-r[1])<1?r[1]:a)-t;r[0]=o,r[1]=s,n.scrollLeft=o,n.scrollTop=s,this.#x=!0}#W(){if(!this.#x)return;let{first:e}=this._getVisiblePages();e&&this._updateLocation(e)}#G(e,t,{noScroll:n=!1,preset:r=!1,drawingDelay:i=-1,origin:a=null,pan:o=null}){if(this._currentScaleValue=t.toString(),this.#U(e)){o&&!n&&this.panBy(o[0],o[1]),r&&this.eventBus.dispatch(`scalechanging`,{source:this,scale:e,presetValue:t});return}this.clearSelection(),this.viewer.style.setProperty(`--scale-factor`,e*oo.PDF_TO_CSS_UNITS);let s=i>=0&&i<1e3;this.refresh(!0,{scale:e,drawingDelay:s?i:-1}),s&&(this.#k=setTimeout(()=>{this.#k=null,this.refresh()},i));let c=this._currentScale;if(this._currentScale=e,!n){this.#W();let t=this._currentPageNumber,n;this._location&&!(this.isInPresentationMode||this.isChangingPresentationMode)&&(t=this._location.pageNumber,n=[null,{name:`XYZ`},this._location.left,this._location.top,null]),this.scrollPageIntoView({pageNumber:t,destArray:n,allowNegativeOffset:!0});let r=o?.[0]??0,i=o?.[1]??0;if(Array.isArray(a)){let t=e/c-1,[n,o]=this.containerTopLeft;r-=(a[0]-o)*t,i-=(a[1]-n)*t}(r||i)&&this.panBy(r,i)}this.eventBus.dispatch(`scalechanging`,{source:this,scale:e,presetValue:r?t:void 0}),this.defaultRenderingQueue&&this.update()}get#K(){return this._spreadMode!==Y.NONE&&this._scrollMode!==J.HORIZONTAL?2:1}#q(e,t){let n=parseFloat(e);if(n>0)t.preset=!1,this.#G(n,e,t);else{let r=this._pages[this._currentPageNumber-1];if(!r)return;let i=40,a=5;this.isInPresentationMode?(i=a=4,this._spreadMode!==Y.NONE&&(i*=2)):this.removePageBorders?i=a=0:this._scrollMode===J.HORIZONTAL&&([i,a]=[a,i]);let o=(this.container.clientWidth-i)/r.width*r.scale/this.#K,s=(this.container.clientHeight-a)/r.height*r.scale;switch(e){case`page-actual`:n=1;break;case`page-width`:n=o;break;case`page-height`:n=s;break;case`page-fit`:n=Math.min(o,s);break;case`auto`:let t=Ko(r)?o:Math.min(s,o);n=Math.min(1.25,t);break;default:console.error(`#setScale: "${e}" is an unknown zoom value.`);return}t.preset=!0,this.#G(n,e,t)}}#J(){let e=this._pages[this._currentPageNumber-1];this.isInPresentationMode&&this.#q(this._currentScaleValue,{noScroll:!0}),this.#H(e)}pageLabelToPageNumber(e){if(!this._pageLabels)return null;let t=this._pageLabels.indexOf(e);return t<0?null:t+1}scrollPageIntoView({pageNumber:e,destArray:t=null,allowNegativeOffset:n=!1,ignoreDestinationZoom:r=!1,center:i=null}){if(!this.pdfDocument)return;let a=Number.isInteger(e)&&this._pages[e-1];if(!a){console.error(`scrollPageIntoView: "${e}" is not a valid pageNumber parameter.`);return}if(this.isInPresentationMode||!t){this._setCurrentPageNumber(e,!0);return}let o=0,s=0,c=0,l=0,u,d,f=a.rotation%180!=0,p=(f?a.height:a.width)/a.scale/oo.PDF_TO_CSS_UNITS,m=(f?a.width:a.height)/a.scale/oo.PDF_TO_CSS_UNITS,h=0;switch(t[1].name){case`XYZ`:o=t[2],s=t[3],h=t[4],o=o===null?0:o,s=s===null?m:s;break;case`Fit`:case`FitB`:h=`page-fit`;break;case`FitH`:case`FitBH`:s=t[2],h=`page-width`,s===null&&this._location?(o=this._location.left,s=this._location.top):(typeof s!=`number`||s<0)&&(s=m);break;case`FitV`:case`FitBV`:o=t[2],c=p,l=m,h=`page-height`;break;case`FitR`:o=t[2],s=t[3],c=t[4]-o,l=t[5]-s;let e=40,n=5;this.removePageBorders&&(e=n=0),u=(this.container.clientWidth-e)/c/oo.PDF_TO_CSS_UNITS,d=(this.container.clientHeight-n)/l/oo.PDF_TO_CSS_UNITS,h=Math.min(Math.abs(u),Math.abs(d));break;default:console.error(`scrollPageIntoView: "${t[1].name}" is not a valid destination type.`);return}if(r||(h&&h!==this._currentScale?this.currentScaleValue=h:this._currentScale===0&&(this.currentScaleValue=`auto`)),h===`page-fit`&&!t[4]){this.#H(a);return}let g=[a.viewport.convertToViewportPoint(o,s),a.viewport.convertToViewportPoint(o+c,s+l)],_=Math.min(g[0][0],g[1][0]),v=Math.min(g[0][1],g[1][1]);i?((i===`both`||i===`vertical`)&&(v-=(this.container.clientHeight-Math.abs(g[1][1]-g[0][1]))/2),(i===`both`||i===`horizontal`)&&(_-=(this.container.clientWidth-Math.abs(g[1][0]-g[0][0]))/2)):n||(_=Math.max(_,0),v=Math.max(v,0)),this.#H(a,{left:_,top:v})}_updateLocation(e){this.#x=!1;let t=this._currentScale,n=this._currentScaleValue,r=parseFloat(n)===t?Math.round(t*1e4)/100:n,i=e.id,a=this._pages[i-1],o=this.container,[s,c]=a.getPagePoint(o.scrollLeft-e.x,o.scrollTop-e.y),l=`#page=${i}`;this.isInPresentationMode||(l+=`&zoom=${r},${Math.round(s)},${Math.round(c)}`),this._location={pageNumber:i,scale:r,top:c,left:s,rotation:this._pagesRotation,pdfOpenParams:l}}update(){let e=this._getVisiblePages(),t=e.views,n=t.length;if(n===0)return;let r=Math.max(10,2*n+1);this.#e.resize(r,e.ids);for(let{view:e,visibleArea:n}of t)e.updateVisibleArea(n);for(let t of this.#e)e.ids.has(t.id)||t.updateVisibleArea(null);this.renderingQueue.renderHighestPriority(e);let i=this._spreadMode===Y.NONE&&(this._scrollMode===J.PAGE||this._scrollMode===J.VERTICAL),a=this._currentPageNumber,o=!1;for(let e of t){if(e.percent<100)break;if(e.id===a&&i){o=!0;break}}this._setCurrentPageNumber(o?this._currentPageNumber:t[0].id),this._updateLocation(e.first),this.eventBus.dispatch(`updateviewarea`,{source:this,location:this._location})}#Y(){let e=this._getVisiblePages(),t=[],{ids:n,views:r}=e;for(let e of r){let{view:r}=e;r.hasEditableAnnotations()?t.push(e):n.delete(r.id)}return t.length===0?null:(this.renderingQueue.renderHighestPriority({first:t[0],last:t.at(-1),views:t,ids:n}),n)}containsElement(e){return this.container.contains(e)}focus(){this.container.focus()}get _isContainerRtl(){return getComputedStyle(this.container).direction===`rtl`}get isInPresentationMode(){return this.presentationModeState===Ao.FULLSCREEN}get isChangingPresentationMode(){return this.presentationModeState===Ao.CHANGING}get isHorizontalScrollbarEnabled(){return!this.isInPresentationMode&&this.container.scrollWidth>this.container.clientWidth}get isVerticalScrollbarEnabled(){return!this.isInPresentationMode&&this.container.scrollHeight>this.container.clientHeight}_getVisiblePages(){let e=this._scrollMode===J.PAGE?this.#O.pages:this._pages,t=this._scrollMode===J.HORIZONTAL,n=t&&this._isContainerRtl;return Ho({scrollEl:this.container,views:e,sortByVisibility:!0,horizontal:t,rtl:n})}cleanup(){for(let e of this._pages)e.renderingState!==$.FINISHED&&e.reset()}_cancelRendering(){for(let e of this._pages)e.cancelRendering()}async#X(e){if(e.pdfPage)return e.pdfPage;try{let t=await this.pdfDocument.getPage(e.id);return e.pdfPage||e.setPdfPage(t),t}catch(e){return console.error(`Unable to get page for page view`,e),null}}#Z(e){if(e.first?.id===1)return!0;if(e.last?.id===this.pagesCount)return!1;switch(this._scrollMode){case J.PAGE:return this.#O.scrollDown;case J.HORIZONTAL:return this.scroll.right}return this.scroll.down}forceRendering(e){let t=e||this._getVisiblePages(),n=this.#Z(t),r=this._spreadMode!==Y.NONE&&this._scrollMode!==J.HORIZONTAL,i=this.#k!==null||this.#b!==null&&t.views.some(e=>e.detailView?.renderingCancelled),a=this.renderingQueue.getHighestPriority(t,this._pages,n,r,i);return a?(this.#X(a).then(()=>{this.renderingQueue.renderView(a)}),!0):!1}get hasEqualPageSizes(){let e=this._pages[0];for(let t=1,n=this._pages.length;t<n;++t){let n=this._pages[t];if(n.width!==e.width||n.height!==e.height)return!1}return!0}getPagesOverview(){let e;return this._pages.map(t=>{let n=t.pdfPage.getViewport({scale:1}),r=Ko(n);if(e===void 0)e=r;else if(this.enablePrintAutoRotate&&r!==e)return{width:n.height,height:n.width,rotation:(n.rotation-90)%360};return{width:n.width,height:n.height,rotation:n.rotation}})}get optionalContentConfigPromise(){return this.pdfDocument?this._optionalContentConfigPromise?this._optionalContentConfigPromise:(console.error(`optionalContentConfigPromise: Not initialized yet.`),this.pdfDocument.getOptionalContentConfig({intent:`display`})):Promise.resolve(null)}set optionalContentConfigPromise(e){if(!(e instanceof Promise))throw Error(`Invalid optionalContentConfigPromise: ${e}`);this.pdfDocument&&this._optionalContentConfigPromise&&(this._optionalContentConfigPromise=e,this.refresh(!1,{optionalContentConfigPromise:e}),this.eventBus.dispatch(`optionalcontentconfigchanged`,{source:this,promise:e}))}get scrollMode(){return this._scrollMode}set scrollMode(e){if(this._scrollMode!==e){if(!Wo(e))throw Error(`Invalid scroll mode: ${e}`);this.pagesCount>El.FORCE_SCROLL_MODE_PAGE||(this._previousScrollMode=this._scrollMode,this.clearSelection(),this._scrollMode=e,this.eventBus.dispatch(`scrollmodechanged`,{source:this,mode:e}),this._updateScrollMode(this._currentPageNumber))}}_updateScrollMode(e=null){let t=this._scrollMode,n=this.viewer;n.classList.toggle(`scrollHorizontal`,t===J.HORIZONTAL),n.classList.toggle(`scrollWrapped`,t===J.WRAPPED),this.pdfDocument&&e&&(t===J.PAGE?this.#V():this._previousScrollMode===J.PAGE&&this._updateSpreadMode(),this._currentScaleValue&&isNaN(this._currentScaleValue)&&this.#q(this._currentScaleValue,{noScroll:!0}),this._setCurrentPageNumber(e,!0),this.update())}get spreadMode(){return this._spreadMode}set spreadMode(e){if(this._spreadMode!==e){if(!Go(e))throw Error(`Invalid spread mode: ${e}`);this.clearSelection(),this._spreadMode=e,this.eventBus.dispatch(`spreadmodechanged`,{source:this,mode:e}),this._updateSpreadMode(this._currentPageNumber)}}_updateSpreadMode(e=null){if(!this.pdfDocument)return;let t=this.viewer,n=this._pages;if(this._scrollMode===J.PAGE)this.#V();else if(t.textContent=``,this._spreadMode===Y.NONE)for(let e of this._pages)t.append(e.div);else{let e=this._spreadMode-1,r=null;for(let i=0,a=n.length;i<a;++i)r===null?(r=document.createElement(`div`),r.className=`spread`,t.append(r)):i%2===e&&(r=r.cloneNode(!1),t.append(r)),r.append(n[i].div)}e&&(this._currentScaleValue&&isNaN(this._currentScaleValue)&&this.#q(this._currentScaleValue,{noScroll:!0}),this._setCurrentPageNumber(e,!0),this.update())}#Q(e,t=!1){switch(this._scrollMode){case J.WRAPPED:{let{views:n}=this._getVisiblePages(),r=/* @__PURE__ */ new Map;for(let{id:e,y:t,percent:i,widthPercent:a}of n)i===0||a<100||r.getOrInsertComputed(t,Ga).push(e);for(let n of r.values()){let r=n.indexOf(e);if(r===-1)continue;let i=n.length;if(i===1)break;if(t)for(let t=r-1,i=0;t>=0;t--){let r=n[t],i=n[t+1]-1;if(r<i)return e-i}else for(let t=r+1,a=i;t<a;t++){let r=n[t],i=n[t-1]+1;if(r>i)return i-e}if(t){let t=n[0];if(t<e)return e-t+1}else{let t=n[i-1];if(t>e)return t-e+1}break}break}case J.HORIZONTAL:break;case J.PAGE:case J.VERTICAL:{if(this._spreadMode===Y.NONE)break;let n=this._spreadMode-1;if(t&&e%2!==n||!t&&e%2===n)break;let{views:r}=this._getVisiblePages(),i=t?e-1:e+1;for(let{id:e,percent:t,widthPercent:n}of r)if(e===i){if(t>0&&n===100)return 2;break}break}}return 1}nextPage(){let e=this._currentPageNumber,t=this.pagesCount;if(e>=t)return!1;let n=this.#Q(e,!1)||1;return this.currentPageNumber=Math.min(e+n,t),!0}previousPage(){let e=this._currentPageNumber;if(e<=1)return!1;let t=this.#Q(e,!0)||1;return this.currentPageNumber=Math.max(e-t,1),!0}updateScale({drawingDelay:e,scaleFactor:t=null,steps:n=null,origin:r,pan:i=null}){if(n===null&&t===null)throw Error("Invalid updateScale options: either `steps` or `scaleFactor` must be provided.");if(!this.pdfDocument)return;let a=this._currentScale;if(t>0&&t!==1)a=Math.round(a*t*100)/100;else if(n){let e=n>0?1.1:1/1.1,t=n>0?Math.ceil:Math.floor;n=Math.abs(n);do a=t((a*e).toFixed(2)*10)/10;while(--n>0)}a=Ya(a,.1,25),this.#q(a,{noScroll:!1,drawingDelay:e,origin:r,pan:i})}increaseScale(e={}){this.updateScale({...e,steps:e.steps??1})}decreaseScale(e={}){this.updateScale({...e,steps:-(e.steps??1)})}#$(e=this.container.clientHeight){e!==this.#E&&(this.#E=e,qo.setProperty(`--viewer-container-height`,`${e}px`))}#ee(e){for(let t of e)if(t.target===this.container){this.#$(Math.floor(t.borderBoxSize[0].blockSize)),this.#s=null;break}}get containerTopLeft(){return this.#s||=[this.container.offsetTop,this.container.offsetLeft]}#te(){this.#k!==null&&(clearTimeout(this.#k),this.#k=null),this.#b!==null&&(clearTimeout(this.#b),this.#b=null)}#ne(){this.#S?.abort(),this.#S=null,this.#C!==null&&(clearTimeout(this.#C),this.#C=null)}#re(e){switch(e){case q.STAMP:this.#_?.loadModel(`altText`);break;case q.SIGNATURE:this.#A?.loadSignatures()}}get annotationEditorMode(){return this.#i?this.#r:q.DISABLE}set annotationEditorMode({mode:e,editId:t=null,isFromKeyboard:n=!1,mustEnterInEditMode:r=!1,editComment:i=!1}){if(!this.#i)throw Error(`The AnnotationEditor is not enabled.`);if(this.#r===e)return;if(!Dl(e))throw Error(`Invalid AnnotationEditor mode: ${e}`);if(!this.pdfDocument)return;this.#re(e);let{eventBus:a,pdfDocument:o}=this,s=async()=>{this.#ne(),this.#r=e,await this.#i.updateMode(e,t,!0,n,r,i),e===this.#r&&o===this.pdfDocument&&a.dispatch(`annotationeditormodechanged`,{source:this,mode:e})};if(e===q.NONE||this.#r===q.NONE){let t=e!==q.NONE;t||this.pdfDocument.annotationStorage.resetModifiedIds(),this.cleanup();for(let e of this._pages)e.toggleEditingMode(t);let n=this.#Y();if(t&&n){this.#ne(),this.#S=new AbortController;let e=AbortSignal.any([this.#h.signal,this.#S.signal]);a.on(`pagerendered`,({pageNumber:e})=>{n.delete(e),n.size===0&&(this.#C=setTimeout(s,0))},{signal:e,...X});return}}s()}refresh(e=!1,t=Object.create(null)){if(this.pdfDocument){for(let e of this._pages)e.update(t);this.#te(),e||this.update()}}};globalThis.pdfjsViewer={AnnotationLayerBuilder:hs,DownloadManager:_s,EventBus:bs,FindState:Qo,GenericL10n:Hc,LinkTarget:fs,parseQueryString:Po,PDFFindController:ds,PDFHistory:Wc,PDFLinkService:ps,PDFPageView:bl,PDFScriptingManager:wl,PDFSinglePageViewer:class extends kl{_resetView(){super._resetView(),this._scrollMode=J.PAGE,this._spreadMode=Y.NONE}set scrollMode(e){}_updateScrollMode(){}set spreadMode(e){}_updateSpreadMode(){}},PDFViewer:kl,ProgressBar:Jo,RenderingStates:$,ScrollMode:J,SimpleLinkService:ms,SpreadMode:Y,StructTreeLayerBuilder:pl,TextLayerBuilder:gl,XfaLayerBuilder:_l};function Al(e){return(t,n)=>{let r=!1,i=new gl({pdfPage:t,onAppend:()=>{r?i.cancel():e.append(a)}}),a=i.div;a.style.setProperty(`--total-scale-factor`,String(n.scale*n.userUnit)),a.style.setProperty(`--scale-round-x`,`1px`),a.style.setProperty(`--scale-round-y`,`1px`);let o=()=>{a.style.scale=String(e.getBoundingClientRect().width/n.width)},s=new ResizeObserver(o);return s.observe(e),o(),{promise:i.render({viewport:n}),cancel(){r=!0,s.disconnect(),i.cancel(),a.remove()}}}}let jl=`@deepseek-ai/dsh-client-ui-sidebar-documentpreview/PdfBody.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(jl)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-sidebar-documentpreview`,e.dataset.pluginCss=jl,e.textContent=`.Qi9xlq_body{box-sizing:border-box;background:var(--dsw-alias-bg-document-preview);width:100%;min-width:100%;min-height:100%;font-family:var(--dsw-font,sans-serif);white-space:normal;flex-direction:column;gap:12px;padding:12px;display:flex;overflow:visible}[data-document-zoom-mode=fixed] .Qi9xlq_body{width:max-content}.Qi9xlq_page{box-sizing:border-box;width:100%;min-width:0;overflow-x:visible}.Qi9xlq_placeholder{aspect-ratio:3/4;background:var(--dsw-alias-bg-skeleton);width:100%}.Qi9xlq_canvas{width:100%;max-width:none;height:100%;margin-inline:auto;display:block;position:absolute;inset:0}.Qi9xlq_surface{width:min(var(--pdf-page-width,100%), 100%);max-width:none;box-shadow:var(--dsw-elevation-prominent);margin-inline:auto;position:relative}.Qi9xlq_surface[hidden]{display:none}.Qi9xlq_text{position:absolute;inset:0;overflow:clip}.Qi9xlq_text .textLayer{text-align:initial;letter-spacing:normal;word-spacing:normal;text-size-adjust:none;forced-color-adjust:none;transform-origin:0 0;caret-color:canvastext;z-index:0;--text-scale-factor:calc(var(--total-scale-factor) * var(--min-font-size));--min-font-size-inv:calc(1 / var(--min-font-size));line-height:1;position:absolute;inset:0;overflow:clip}.Qi9xlq_text .textLayer[data-main-rotation="90"]{transform:rotate(90deg)translateY(-100%)}.Qi9xlq_text .textLayer[data-main-rotation="180"]{transform:rotate(180deg)translate(-100%,-100%)}.Qi9xlq_text .textLayer[data-main-rotation="270"]{transform:rotate(270deg)translate(-100%)}.Qi9xlq_text :is(span,br){color:#0000;white-space:pre;cursor:text;transform-origin:0 0;user-select:text;position:absolute}.Qi9xlq_text .textLayer>:not(.markedContent),.Qi9xlq_text .markedContent span:not(.markedContent){z-index:1;--font-height:0;--scale-x:1;--rotate:0deg;font-size:calc(var(--text-scale-factor) * var(--font-height));transform:rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv))}.Qi9xlq_text .markedContent{display:contents}.Qi9xlq_text ::selection{background:var(--dsw-alias-bg-document-selection);color:#0000}.Qi9xlq_text br::selection{background:0 0}.Qi9xlq_text .textLayer .endOfContent{z-index:0;cursor:default;user-select:none;display:block;position:absolute;inset:100% 0 0}.Qi9xlq_text .selecting .endOfContent{top:0}.Qi9xlq_status{color:var(--dsw-alias-label-secondary);align-items:center;gap:8px;padding:10px;font-size:13px;line-height:1.5;display:flex}.Qi9xlq_body .Qi9xlq_status{color:var(--dsw-alias-label-document-preview)}`,document.head.appendChild(e)}var Ml={body:`Qi9xlq_body`,canvas:`Qi9xlq_canvas`,page:`Qi9xlq_page`,placeholder:`Qi9xlq_placeholder`,status:`Qi9xlq_status`,surface:`Qi9xlq_surface`,text:`Qi9xlq_text`};let Nl={page:1},Pl={kind:`fit-width`};function Fl(e){let{tab:t}=e.useTabInfo(),n=e.useStore(e=>e.byTab[t.id]??Nl),o=e.content.kind===`bytes`?e.content.data:void 0,[s,c]=(0,r.useState)(),[l,u]=(0,r.useState)(0),[d,f]=(0,r.useState)(),[p,m]=(0,r.useState)(1),{retainTab:h,actions:g,t:_,ZoomViewport:v,zoomSurfaceClass:y}=e,b=n.zoom??Pl,x={controls:_(`zoomControls`),menu:_(`zoomMenu`),out:_(`zoomOut`),into:_(`zoomIn`),fitWidth:_(`zoomFitWidth`),value:e=>_(`zoomValue`,{percent:e})},S=(0,r.useCallback)(e=>{g.page(t.id,e)},[g,t.id]),C=(0,r.useCallback)(e=>{g.zoom(t.id,e)},[g,t.id]);if((0,r.useEffect)(()=>{h(t.id,t.signal)},[h,t.id,t.signal]),(0,r.useEffect)(()=>{if(o===void 0||t.signal.aborted)return;let e=new AbortController,n=AbortSignal.any([e.signal,t.signal]);c(void 0);let r=ha(o,n,e=>{n.aborted||c({kind:`failed`,data:o,error:e})});return r.document.then(e=>{n.aborted||c({kind:`loaded`,data:o,document:e})},e=>{n.aborted||c({kind:`failed`,data:o,error:e})}),()=>{e.abort(),r.dispose()}},[o,t.signal,l]),(0,r.useEffect)(()=>{if(s?.kind!==`loaded`||s.data!==o){f(void 0);return}if(s.document.numPages<1||t.signal.aborted)return;let e=!1;return s.document.getPage(1).then(n=>{try{if(!e&&!t.signal.aborted){let{width:e}=n.getViewport({scale:96/72});f(e)}}finally{n.cleanup()}},()=>{}),()=>{e=!0}},[o,s,t.signal]),o===void 0)return/* @__PURE__ */ (0,a.jsx)(`p`,{className:Ml.status,role:`alert`,children:_(`unsupported`)});if(s?.data!==o)return e.loading;if(s.kind===`failed`)return/* @__PURE__ */ (0,a.jsxs)(`div`,{className:Ml.status,role:`alert`,children:[/* @__PURE__ */ (0,a.jsx)(`span`,{children:Rl(s.error,_)}),/* @__PURE__ */ (0,a.jsx)(i.Button,{size:`sm`,onClick:()=>{u(e=>e+1)},children:_(`retry`)})]});let w=/* @__PURE__ */ (0,a.jsx)(`section`,{className:Ml.body,"data-pdf-preview":!0,children:Array.from({length:s.document.numPages},(e,r)=>/* @__PURE__ */ (0,a.jsx)(Ll,{document:s.document,page:r+1,requested:r===0||n.page===r+1,onVisible:S,signal:t.signal,onWidth:r===0?f:void 0,zoom:p,zoomSurfaceClass:y,t:_},r))});return/* @__PURE__ */ (0,a.jsx)(v,{preference:b,intrinsicWidth:d,horizontalInset:24,labels:x,signal:t.signal,scrollportRef:e.scrollportRef,onPreference:C,onRenderZoom:m,children:w})}function Il(e){e!==null&&(e.width!==0&&(e.width=0),e.height!==0&&(e.height=0))}function Ll({document:e,page:t,requested:n,onVisible:s,signal:c,onWidth:l,zoom:u,zoomSurfaceClass:d,t:f}){let p=(0,r.useRef)(null),m=(0,r.useRef)(null),h=(0,r.useRef)(null),g=(0,r.useRef)(null),[_,v]=(0,r.useState)(),[y,b]=(0,r.useState)(n),[x,S]=(0,r.useState)(n),C=(0,r.useRef)(),w=(0,r.useRef)(Promise.resolve()),T=(0,r.useRef)(),[E,D]=(0,r.useState)(`loading`),[O,ee]=(0,r.useState)(),[k,A]=(0,r.useState)(0);(0,r.useEffect)(()=>{let e=E===`ready`?m.current:p.current;if(typeof IntersectionObserver>`u`){b(!0),S(!0);return}let n=!1,r=new IntersectionObserver(e=>{if(n)return;let r=e.at(-1);if(r===void 0)return;let i=r.isIntersecting;S(i),i&&(b(!0),s(t))},{rootMargin:`100% 0px`});return r.observe(e),()=>{n=!0,r.disconnect()}},[t,s,E]),(0,r.useEffect)(()=>{let e=h.current;return()=>{T.current?.cancel(),T.current=void 0,Il(e),C.current=void 0}},[e,t]),(0,r.useEffect)(()=>{if(!x){Il(h.current),C.current=void 0;return}if(!y||(ee(void 0),C.current===u))return;let n=h.current,r=new AbortController,i=AbortSignal.any([r.signal,c]),a;return w.current=w.current.then(async()=>{i.throwIfAborted();let r=n.ownerDocument.createElement(`canvas`);try{let s=await o(e,t,r,i,window.devicePixelRatio*u,T.current===void 0?(e,t)=>(a=Al(g.current)(e,t),a):void 0);i.throwIfAborted();let c=n.getContext(`2d`);if(c===null)throw Error(`PDF canvas has no 2D context`);n.width=r.width,n.height=r.height,n.style.setProperty(`--pdf-page-width`,`${s.width}px`),n.style.setProperty(`--pdf-page-height`,`${s.height}px`),c.drawImage(r,0,0),T.current??=a,a=void 0,C.current=u,v(e=>e!==void 0&&e.width===s.width&&e.height===s.height?e:s),l?.(s.width),D(`ready`)}finally{r.width=r.height=0,a?.cancel()}}).catch(e=>{i.aborted||ee({error:e})}),()=>{r.abort(),a?.cancel()}},[e,t,y,x,u,c,k,l]);let j=_===void 0?void 0:{"--pdf-page-width":`${_.width}px`,"--pdf-page-height":`${_.height}px`},M=_===void 0?{"--document-zoom-width":`0px`}:{"--document-zoom-width":`${_.width}px`,aspectRatio:`${_.width} / ${_.height}`};return/* @__PURE__ */ (0,a.jsxs)(`div`,{ref:p,className:Ml.page,"data-pdf-page":t,style:j,children:[O===void 0&&E!==`ready`&&(y?/* @__PURE__ */ (0,a.jsx)(`div`,{className:Ml.placeholder,role:`status`,"aria-label":f(`rendering`)}):/* @__PURE__ */ (0,a.jsx)(`div`,{className:Ml.placeholder})),O!==void 0&&/* @__PURE__ */ (0,a.jsxs)(`div`,{className:Ml.status,role:`alert`,children:[/* @__PURE__ */ (0,a.jsx)(`span`,{children:Rl(O.error,f)}),/* @__PURE__ */ (0,a.jsx)(i.Button,{size:`sm`,onClick:()=>{A(e=>e+1)},children:f(`retry`)})]}),/* @__PURE__ */ (0,a.jsxs)(`div`,{ref:m,className:`${Ml.surface} ${d}`,"data-document-zoom-surface":!0,style:M,hidden:E!==`ready`,children:[/* @__PURE__ */ (0,a.jsx)(`canvas`,{ref:h,className:Ml.canvas,role:`img`,"aria-label":f(`pageImage`,{page:t})}),/* @__PURE__ */ (0,a.jsx)(`div`,{ref:g,className:Ml.text,"data-pdf-text":!0})]})]})}function Rl(e,t){return e instanceof pa?t(`workerFailed`):e instanceof Error&&e.name===`PasswordException`?t(`password`):t(`failed`,{message:e instanceof Error?e.message:String(e)})}return n.PdfBody=Fl,t.exports}});