/*!
 * Nutrient Web SDK 1.14.0-749c28d (https://www.nutrient.io/sdk/web)
 *
 * Copyright (c) 2016-2026 PSPDFKit GmbH. All rights reserved.
 *
 * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
 * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE PSPDFKIT LICENSE AGREEMENT.
 * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
 * This notice may not be removed from this file.
 *
 * PSPDFKit uses several open source third-party components: https://www.nutrient.io/legal/acknowledgements/web-acknowledgements/
 */
"use strict";(globalThis.webpackChunkNutrientViewer=globalThis.webpackChunkNutrientViewer||[]).push([[362],{8009(e,t,s){s.r(t),s.d(t,{corePool:()=>d.mG,customFontsPromiseRef:()=>k,default:()=>E,loadModule:()=>I,normalizeCoreOptions:()=>d.DO,validateStandaloneConfiguration:()=>d.mn});var n=s(34724),a=s(57191),i=s(89339),o=s(95420),r=s(70274),c=s(64662),l=s(80695),u=s(23264),d=s(74129),h=s(39515),f=s(9855),m=s(28805),p=s(33704),y=s(44457),g=s(96584),w=s(51974),A=s(73844);function b(e){return null!==e&&(0,A.uA)(e)&&!(0,A.C5)(e)}function _(e){return"opfs"!==e.mode?"memory":e.isAuto?"auto":"opfs"}function F(e){const t={credentials:"same-origin"};if(e&&Object.keys(e).length>0){const s=new Headers;Object.entries(e).forEach(e=>{let[t,n]=e;s.append(t,n)}),t.headers=s}return t}function P(e,t){"opfs"===e.mode&&(e.isAuto?(0,i.R8)(`OPFS storage: ${t}. Falling back to memory.`):(0,i.R8)(`OPFS storage was explicitly requested, but ${t}. Falling back to memory.`))}async function v(e){try{await e.closeOPFSStorage()}catch{}}async function D(e,t,s,n,a,o,r,c){const l=F(a);let u;r?(u=r,o?.()):u=await fetch(e,l).finally(()=>{o?.()});const d=(h=u.headers?.get("Content-Type"),h?.toLowerCase().split(";")[0].trim()||null);var h;d&&c?.(d);const f=u.headers?.get("Content-Length"),m=f?parseInt(f,10):null,p=Number.isFinite(m)?m:null,y=_(n),g=function(e,t,s){return"opfs"===e.mode&&!b(t)&&(null===e.minFileSize||null!==s&&s>=e.minFileSize)}(n,d,p);let D;if("opfs"===n.mode&&(b(d)?D="unsupported-content-type":null!==n.minFileSize&&null===p?D="file-size-unknown":null!==n.minFileSize&&null!==p&&p<n.minFileSize&&(D="below-min-file-size")),g){const a=await async function(e,t,s,n){const a=e.headers?.get("Content-Length");if(!a)return P(n,"the Content-Length header is missing"),{document:null,canReuseResponse:!0,fallbackReason:"content-length-missing"};const o=parseInt(a,10);if(isNaN(o)||o<=0)return P(n,"the Content-Length header is invalid"),{document:null,canReuseResponse:!0,fallbackReason:"content-length-invalid"};if(!await t.initOPFSStorage(o))return{document:null,canReuseResponse:!0,fallbackReason:"init-failed"};const r=1048576,c=e.body?.getReader();if(!c)return(0,i.R8)("OPFS storage: ReadableStream not available. Falling back to memory."),await v(t),{document:null,canReuseResponse:!0,fallbackReason:"readable-stream-unavailable"};let l=0,u=null;try{let e=new Uint8Array(r),s=0;for(;;){const{done:n,value:a}=await c.read();if(n){if(s>0){const n=e.subarray(0,s);await t.writeOPFSChunk(n,l-s)}break}null===u&&(u=a.slice(0,Math.min(a.byteLength,16384)));let i=0;for(;i<a.byteLength;){const n=r-s,o=Math.min(n,a.byteLength-i);e.set(a.subarray(i,i+o),s),s+=o,i+=o,l+=o,s===r&&(await t.writeOPFSChunk(e,l-s),e=new Uint8Array(r),s=0)}}}catch(e){return(0,i.R8)(`OPFS storage: error during streaming write: ${e}. Falling back to memory.`),await v(t),{document:null,canReuseResponse:!1,fallbackReason:"streaming-write-error"}}if(l!==o)return(0,i.R8)(`OPFS storage: short response (${l} of ${o} bytes). Falling back to memory.`),await v(t),{document:null,canReuseResponse:!1,fallbackReason:"short-response"};try{const a=Math.min(o,16384),i=null!==u&&u.byteLength>=a?u.slice(0,a):await t.readOPFSBytes(0,a),r=i.slice(0,Math.min(i.byteLength,8192)),c=await(0,A.oj)(r.buffer,s,e.headers?.get("Content-Type"));return{document:{type:"opfs",isFullyAvailable:!0,fullDocument:null,opfsActive:!0,documentHeadBuffer:i.buffer,contentType:c,storageAnalytics:{storageRequested:_(n),storageActual:"opfs"}},canReuseResponse:!1}}catch(e){return(0,i.R8)(`OPFS storage: error during finalization: ${e}. Falling back to memory.`),await v(t),{document:null,canReuseResponse:!1,fallbackReason:"finalization-error"}}}(u,t,s,n);if(a.document)return a.document;D=a.fallbackReason??D,(0,w.q)("DocumentLoader: OPFS load failed; falling back to in-memory document load",{canReuseResponse:a.canReuseResponse,fallbackReason:D}),a.canReuseResponse||(u=await fetch(e,l))}const S=await u.arrayBuffer();return{type:"memory",isFullyAvailable:!0,fullDocument:S,contentType:await(0,A.oj)(S,s,u.headers?.get("Content-Type")),storageAnalytics:{storageRequested:y,storageActual:"memory",...D?{storageFallbackReason:D}:{}}}}async function S(e,t,s,n){let a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{mode:"memory"},r=arguments.length>5?arguments[5]:void 0,c=arguments.length>6?arguments[6]:void 0,l=arguments.length>7?arguments[7]:void 0;if(e instanceof ArrayBuffer){const t=await(0,A.oj)(e,s),n=_(a);return l?.(t),{type:"memory",isFullyAvailable:!0,fullDocument:e,contentType:t,storageAnalytics:{storageRequested:n,storageActual:"memory",..."memory"!==n?{storageFallbackReason:"arraybuffer-input"}:{}}}}(0,i.V1)("string"==typeof e,"Document is not a string");let u=!1;const{linearizedDocument:d,serverSupportsRangeRequests:h,fallbackResponse:f}=await(async()=>{if(n&&function(e){if(e.startsWith("/"))return!0;try{const t=new URL(e);return"http:"===t.protocol||"https:"===t.protocol}catch(e){return!1}}(e)){const t=await s.openLinearizedDocument(o.EA);(0,i.V1)(t,"Linearized document is not available"),t.contentType&&l&&l(t.contentType);const n=await t.initialize(e,r);return n.supportsRanges?{linearizedDocument:t,serverSupportsRangeRequests:!0,fallbackResponse:void 0}:{linearizedDocument:null,serverSupportsRangeRequests:!1,fallbackResponse:n.fullResponse}}return{linearizedDocument:null,serverSupportsRangeRequests:!1,fallbackResponse:void 0}})();try{if(!h)return u=!0,D(e,t,s,a,r,c,f,l);(0,i.V1)(d,"Linearized document is not available"),d.startDownload();if(!await d.waitUntilIsLinearizedIsKnown())return await d.destroyAsync(),u=!0,D(e,t,s,a,r,c,void 0,l);c?.();const n=await d.waitUntilDocumentInfoAvailable();return n?("undefined"!=typeof performance&&"function"==typeof performance.mark&&performance.mark("linearized-first-page-ready"),c?.(),{type:"linearized",isFullyAvailable:!1,documentResponse:n,contentType:"application/pdf",storageAnalytics:{storageRequested:_(a),storageActual:d.isUsingOPFS?"opfs":"memory",...d.opfsFallbackReason?{storageFallbackReason:d.opfsFallbackReason}:{}}}):(await d.destroyAsync(),u=!0,D(e,t,s,a,r,c,void 0,l))}catch(n){if(await(d?.destroyAsync()),u)throw n;return D(e,t,s,a,r,c,void 0,l)}}var R=s(61469),L=s(82725);let C;class O extends Error{}class E extends d.Ay{waitForAbandonedLoad(){return new Promise(()=>{})}retainGdPictureLoad(){this._retainedGdPictureLoad||(this._retainedGdPictureLoad=!0,(0,y.qR)())}async releaseGdPictureLoad(){this._retainedGdPictureLoad&&(this._retainedGdPictureLoad=!1,await(0,y.M7)())}async abandonLoadAfterCleanup(){throw await this.releaseGdPictureLoad(),new O}async openDocumentOrAbandon(e,t){try{const s=await this.client.openDocument(e,t);return this.destroyed&&await this.abandonLoadAfterCleanup(),s}catch(e){throw this.destroyed&&await this.abandonLoadAfterCleanup(),e}}async openDocumentWithOPFSOrAbandon(e){try{const t=await this.client.openDocumentWithOPFS(e);return this.destroyed&&await this.abandonLoadAfterCleanup(),t}catch(e){throw this.destroyed&&await this.abandonLoadAfterCleanup(),e}}stashDocumentHeadBuffer(e){const t=Math.min(e.byteLength,16384);this._documentHeadBuffer=e.slice(0,t)}constructor(e){const t=e.baseUrl||(0,u.$_)(window.document),s=e.baseCoreUrl||t,a=e.baseProcessorEngineUrl||t,o={...e,baseUrl:t,baseCoreUrl:s,baseProcessorEngineUrl:a};if("string"!=typeof o.baseUrl)throw new i.uE("`baseUrl` is mandatory and must be a valid URL, e.g. `https://example.com/`");if("string"!=typeof o.document&&!(o.document instanceof ArrayBuffer))throw new i.uE("document must be either an URL to a supported document type (PDF and images), e.g. `https://example.com/document.pdf`, or an `ArrayBuffer`");if(C&&C!==o.licenseKey)throw new i.uE("Trying to re-use instance with a different licenseKey.\nUnfortunately we only allow one licenseKey per instance.\nPlease contact support for further assistance.");if("string"==typeof o.licenseKey&&o.licenseKey.startsWith("TRIAL-"))throw new i.uE("You're using the npm key instead of the license key. This key is used to download the Nutrient Web SDK package via the node package manager.\n\nLeave out the license key to activate as a trial.");super(o),(0,n.A)(this,"_resolvedPdfBuffer",null),(0,n.A)(this,"_documentHeadBuffer",null),(0,n.A)(this,"_loadInProgress",!1),(0,n.A)(this,"_retainedGdPictureLoad",!1),(0,n.A)(this,"_opfsActive",!1),(0,n.A)(this,"_documentStorageAnalytics",null),(0,n.A)(this,"corePDFAccess",null),(0,n.A)(this,"_pageHideListener",e=>{e.persisted||this.destroyed||"opfs"!==this._state.storage.mode||this.cleanupOPFSStorage("pagehide",!1)}),this.destroyed=!1,this.activeConfiguration=e,window.addEventListener("pagehide",this._pageHideListener)}cleanupOPFSStorage(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const s=this.corePDFAccess,n="opfs"===this._state.storage.mode&&s&&(!t||this._opfsActive);this._opfsActive=!1,n&&s.closeOPFSStorage().catch(t=>{(0,i.R8)(`OPFS storage cleanup error (${e}): ${t}`)})}async load(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._resolvedPdfBuffer=null,this._documentHeadBuffer=null,this._opfsActive=!1,this._documentStorageAnalytics=null,this._loadInProgress=!0;try{const t=()=>{try{this.retainGdPictureLoad();let e=(0,y.jU)();e||(e=(0,y.NY)({baseUrl:this._state.baseProcessorEngineUrl,mainThreadOrigin:this._state.appName||(0,c.D5)()||window.location.origin,licenseKey:this._state.licenseKey||void 0,customFonts:this._state.customFonts||void 0,dynamicFonts:this._state.dynamicFonts||void 0,fontSubstitutions:this._state.fontSubstitutions,processorEngine:this._state.processorEngine}),(0,y.Pm)(e))}catch(e){console.error("Error initializing GdPicture client:",e)}};let s=.2;e.progressCallback&&e.progressCallback("loading",s),this._isPDFJavaScriptEnabled=e.isPDFJavaScriptEnabled,"string"==typeof this._state.document&&(0,A.XC)(this._state.baseUrl,this._state.document,this._state.productId),this._state.document instanceof ArrayBuffer&&(0,A.uA)(await(0,A.oj)(this._state.document))&&t();const n=await I(this.client,this._state).finally(()=>{s+=.3,e.progressCallback&&e.progressCallback("loading",s)});(0,l.lp)(),this.destroyed&&await this.abandonLoadAfterCleanup();const o=this.client.workerSpawner;(0,i.V1)(o,"WorkerSpawner is null");const u=o.getWorker();(0,i.V1)(u,"Worker is null");const d=r.LV(u);this.corePDFAccess=d,"opfs"===this._state.storage.mode&&d.cleanupOPFSOrphans().catch(e=>{(0,i.R8)(`OPFS orphan cleanup failed: ${e}`)});const h="string"==typeof this._state.dynamicFonts?this._state.dynamicFonts.split("/").slice(0,-1).join("/"):void 0;this.corePDFDocument=new L.N({corePDFAccess:d,canvasRendering:this._state.canvasRendering,dynamicFontsBaseURL:h,storage:this._state.storage},{type:"alreadyLoadedDocument"});const g=S(this._state.document,d,this.corePDFDocument,this._state.allowLinearizedLoading,this._state.storage,this._state.httpHeaders||void 0,()=>{s+=.3,e.progressCallback&&e.progressCallback("loading",s)},e=>{(0,A.uA)(e)&&t()});(0,i.V1)(n);const{features:w,signatureFeatureAvailability:b,capabilities:_,licenseData:F}=n;if(this._state.productId===p.v.SharePoint&&"string"==typeof this._state.document&&Array.isArray(n.afu)){const e=new URL(this._state.document,this._state.baseUrl);if(!n.afu.some(t=>e.hostname.match(t)))throw new i.uE(`The document origin ${e.hostname} is not authorized.`)}const P=b===f.g.ELECTRONIC_SIGNATURES&&(0,m.UX)(w)&&this._state.forceLegacySignaturesFeature?f.g.LEGACY_SIGNATURES:b;this._state=this._state.set("features",(0,a.B8)(w)).set("signatureFeatureAvailability",P),C=this._state.licenseKey;const v=await g;this._documentStorageAnalytics=v.storageAnalytics??null;let D=null;const R={password:e.password,initialPageIndex:"number"==typeof e.initialPageIndex?e.initialPageIndex:0,formsConfiguration:this._formsConfiguration};if("memory"===v.type){let t=null;const s=(0,A.C5)(v.contentType),n=_.includes("GdPictureWASM"),a=s||!n;if(a)try{this.destroyed?D=await this.abandonLoadAfterCleanup():((this.activeConfiguration.isTextComparison||this.activeConfiguration.aiAssistant)&&(this._resolvedPdfBuffer=v.fullDocument.slice(0)),this.stashDocumentHeadBuffer(v.fullDocument),D=await this.openDocumentOrAbandon(v.fullDocument,R))}catch(e){const s=e;if("INVALID_PASSWORD"===s.message){const e=Array.isArray(s.callArgs)?s.callArgs[0]:null;this._state.document instanceof ArrayBuffer&&e instanceof ArrayBuffer&&(this._state=this._state.set("document",e))}else"IMAGE_DOCUMENTS_NOT_LICENSED"===s.message?s.message="The image documents feature is not enabled for your license key. Please contact support or sales to purchase the UI module for your product.":_.includes("GdPictureWASM")||(s.message="File not in PDF format or corrupted.");t=s}const o=t?.message,r=t instanceof i.uE&&"string"==typeof o&&o.includes("File not in PDF format or corrupted.");if(!n||!r&&s){if(t)throw t}else{this.retainGdPictureLoad();let s=null;const n=t?.callArgs,o=Array.isArray(n)?n[0]:null;if(o instanceof ArrayBuffer?s=o:a?"string"==typeof this._state.document&&(s=await this.fetchDocumentBytesWithCurrentHeaders(this._state.document)):s=v.fullDocument,!(s instanceof ArrayBuffer)){if(t)throw t;throw new i.uE("Document bytes are not available")}let r=this.destroyed;const u=v.contentType;try{if(!r){(0,l.HN)();const t=await(0,y.fL)(s,u,{baseUrl:this._state.baseProcessorEngineUrl,mainThreadOrigin:this._state.appName||(0,c.D5)()||window.location.origin,licenseKey:this._state.licenseKey||void 0,processorEngine:this._state.processorEngine,customFonts:this._state.customFonts||void 0,dynamicFonts:this._state.dynamicFonts||void 0,fontSubstitutions:this._state.fontSubstitutions},e.officeConversionSettings,!0);(0,l.yq)(),(this.activeConfiguration.isTextComparison||this.activeConfiguration.aiAssistant)&&(this._resolvedPdfBuffer=t.slice(0)),this.stashDocumentHeadBuffer(t),r=this.destroyed,r||(D=await this.openDocumentOrAbandon(t,R))}}catch(e){if(!this.destroyed){const t=e;if("INVALID_PASSWORD"===t.message&&this._state.document instanceof ArrayBuffer){const e=Array.isArray(t.callArgs)?t.callArgs[0]:null;e instanceof ArrayBuffer&&(this._state=this._state.set("document",e))}throw"IMAGE_DOCUMENTS_NOT_LICENSED"===t.message&&(t.message="The image documents feature is not enabled for your license key. Please contact support or sales to purchase the UI module for your product."),t}r=!0}r&&(D=await this.abandonLoadAfterCleanup())}(0,i.V1)(D),await this.afterDocumentLoaded(D)}else if("opfs"===v.type)if(this.destroyed)D=await this.abandonLoadAfterCleanup();else{this._opfsActive=!0,this._documentHeadBuffer=v.documentHeadBuffer;try{D=await this.openDocumentWithOPFSOrAbandon(R)}catch(t){const s=t,n=_.includes("GdPictureWASM"),a=s instanceof i.uE&&"string"==typeof s.message&&s.message.includes("File not in PDF format or corrupted.");this._opfsActive=!1,this._documentStorageAnalytics&&(this._documentStorageAnalytics={...this._documentStorageAnalytics,storageActual:"memory",storageFallbackReason:"open-document-failed"});try{await(this.corePDFAccess?.closeOPFSStorage())}catch{}if(!n||!a||"string"!=typeof this._state.document)throw s;{this.retainGdPictureLoad();let t=this.destroyed;const s=v.contentType;try{if(!t){(0,l.HN)();const n=await(0,y.fL)(await this.fetchDocumentBytesWithCurrentHeaders(this._state.document),s,{baseUrl:this._state.baseProcessorEngineUrl,mainThreadOrigin:this._state.appName||(0,c.D5)()||window.location.origin,licenseKey:this._state.licenseKey||void 0,processorEngine:this._state.processorEngine,customFonts:this._state.customFonts||void 0,dynamicFonts:this._state.dynamicFonts||void 0,fontSubstitutions:this._state.fontSubstitutions},e.officeConversionSettings,!0);(0,l.yq)(),this.activeConfiguration.isTextComparison&&(this._resolvedPdfBuffer=n.slice(0)),this.stashDocumentHeadBuffer(n),t=this.destroyed,t||(D=await this.openDocumentOrAbandon(n,R))}}catch(e){if(!this.destroyed){const t=e;if("INVALID_PASSWORD"===t.message){const e=Array.isArray(t.callArgs)?t.callArgs[0]:null;e instanceof ArrayBuffer&&(this._state=this._state.set("document",e))}throw"IMAGE_DOCUMENTS_NOT_LICENSED"===t.message&&(t.message="The image documents feature is not enabled for your license key. Please contact support or sales to purchase the UI module for your product."),t}t=!0}t&&(D=await this.abandonLoadAfterCleanup())}}(0,i.V1)(D),await this.afterDocumentLoaded(D)}else D=v.documentResponse;this._state=this._state.set("documentResponse",D);const O=this.mapLicenseDataToClientInfo(F);return{features:this._state.features,signatureFeatureAvailability:this._state.signatureFeatureAvailability,hasPassword:!!e.password,password:e.password,allowedTileScales:"all",evaluation:n.evaluation,linearizedLoading:!v.isFullyAvailable,documentResponse:D,clientInfo:O}}catch(e){if(e instanceof O)return this.waitForAbandonedLoad();throw e}finally{this._loadInProgress=!1,await this.releaseGdPictureLoad()}}mapLicenseDataToClientInfo(e){const t="1.14.0-749c28d";if(!e)return{environment:R.n.EVALUATION,productId:R.O.WEB,productVersion:t,licenseId:void 0,demoKeyId:void 0};let s=R.n.DEVELOPMENT;return"p"===e.type?s=R.n.PRODUCTION:"d"===e.type?s=R.n.DEMO:"b"===e.type?s=R.n.DEVELOPMENT:"t"===e.type&&(s=R.n.EVALUATION),{environment:s,productId:R.O.WEB,productVersion:t,licenseId:e.li,demoKeyId:"d"===e.type?e.i:void 0}}takeResolvedPdfBuffer(){const e=this._resolvedPdfBuffer;return this._resolvedPdfBuffer=null,e}takeDocumentHeadBuffer(){const e=this._documentHeadBuffer;return this._documentHeadBuffer=null,e}getDocumentStorageAnalytics(){return this._documentStorageAnalytics}destroy(){if(this.destroyed=!0,this._resolvedPdfBuffer=null,this._documentHeadBuffer=null,this._documentStorageAnalytics=null,window.removeEventListener("pagehide",this._pageHideListener),this._loadInProgress)return this.releaseGdPictureLoad(),this.destroyResources(),this.client.destroy(),this._opfsActive=!1,void(this.corePDFAccess=null);this.cleanupOPFSStorage("destroy"),this.corePDFAccess=null,super.destroy()}getCustomFontsPromise(){return k}async afterDocumentLoaded(e){if(this._isPDFJavaScriptEnabled&&(this._initialChanges=await this.client.enablePDFJavaScriptSupport()),this._XFDF&&await this.client.importXFDF(this._XFDF.source,this._XFDF.keepCurrentAnnotations,this._XFDF.ignorePageRotation,this._XFDF.richTextEnabled),this._instantJSON&&this._instantJSON.pdfId&&e.ID.permanent){const t=this._instantJSON.pdfId,s=e.ID,n=s.changing??s.update;if(t.permanent!==s.permanent)throw new i.uE("Could not instantiate from Instant JSON: Permanent PDF ID mismatch.\nPlease use the same PDF document that was used to create this Instant JSON.\nFor more information, please visit: https://www.nutrient.io/guides/web/importing-exporting/instant-json/");if(t.changing!==n)throw new i.uE("Could not instantiate from Instant JSON: Changing PDF ID mismatch.\nPlease use the same revision of this PDF document that was used to create this Instant JSON.\nFor more information, please visit: https://www.nutrient.io/guides/web/importing-exporting/instant-json/")}if(this._trustedCAsCallback)try{const e=await this._trustedCAsCallback();if(!Array.isArray(e))throw new i.uE("Certificates response must be an array");if(e.some(e=>!(e instanceof ArrayBuffer)&&"string"!=typeof e))throw new i.uE("All certificates must be passed as ArrayBuffer (DER) or string (PEM)");await this.client.loadCertificates(e.map(h.PI))}catch(e){throw new i.uE(`Could not retrieve certificates for digital signatures validation: ${e.message}.`)}}async waitUntilFullyLoaded(e){return this.corePDFDocument.linearizedDocument.waitUntilDownloaded().then(async()=>{const t=this.corePDFDocument.linearizedDocument.isUsingOPFS,s=await this.corePDFDocument.normallyOpenLinearizedDocument(this,{password:e,initialPageIndex:0,formsConfiguration:this._formsConfiguration});this.destroyed&&(t&&(await(this.corePDFAccess?.closeOPFSStorage().catch(e=>{(0,i.R8)(`OPFS storage cleanup error: ${e}`)})),this._opfsActive=!1),await this.waitForAbandonedLoad()),t&&(this._opfsActive=!0),this._state=this._state.set("documentResponse",s),await this.afterDocumentLoaded(s)})}async getDocumentBytes(){if(this._state.document instanceof ArrayBuffer)return this._state.document;if("string"==typeof this._state.document){const e=await fetch(this._state.document);if(!e.ok)throw new i.uE(`Failed to fetch document: ${e.statusText}`);return e.arrayBuffer()}throw new i.uE("Document bytes are not available")}async fetchDocumentBytesWithCurrentHeaders(e){return(await fetch(e,F(this._state.httpHeaders||void 0))).arrayBuffer()}}const k={current:void 0};async function I(e,t){k.current=k.current||(t.customFonts?(0,g.eY)(t.customFonts):void 0);const s=(0,u.f)(t.appName);return e.loadNativeModule(t.baseCoreUrl,{mainThreadOrigin:s,disableWebAssemblyStreaming:t.disableWebAssemblyStreaming,enableAutomaticLinkExtraction:t.enableAutomaticLinkExtraction,overrideMemoryLimit:t.overrideMemoryLimit,workerSpawnerFn:()=>(0,o.pj)(t.inlineWorkers)}).then(async()=>e.load(t.baseCoreUrl,t.licenseKey,{mainThreadOrigin:s,...k.current?{customFonts:await k.current}:null,dynamicFonts:t.dynamicFonts,productId:t.productId,featureFlags:(()=>{const e=[];return t.enableCoreUnifiedComments&&e.push("UnifiedComments"),t.enableCorePreservePDFAccessibility&&e.push("PreservePDFAccessibility"),e.length>0?e:void 0})()}))}}}]);