/*!
 * Nutrient Web SDK 1.9.0-8910930 (https://www.nutrient.io/sdk/web)
 *
 * Copyright (c) 2016-2025 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([[860],{60919:(e,t,n)=>{n.r(t),n.d(t,{Conformance:()=>r,GdPicture:()=>w,GdPictureWorker:()=>b,getBrowserSpawner:()=>k});var o=n(85409),s=n(25030);let r=function(e){return e[e.pdf_a_1a=0]="pdf_a_1a",e[e.pdf_a_1b=1]="pdf_a_1b",e[e.pdf_a_2a=2]="pdf_a_2a",e[e.pdf_a_2u=3]="pdf_a_2u",e[e.pdf_a_2b=4]="pdf_a_2b",e[e.pdf_a_3a=5]="pdf_a_3a",e[e.pdf_a_3u=6]="pdf_a_3u",e[e.pdf_a_3b=7]="pdf_a_3b",e[e.pdf_a_4=8]="pdf_a_4",e[e.pdf_a_4e=9]="pdf_a_4e",e[e.pdf_a_4f=10]="pdf_a_4f",e}({});const a="/create.pdf",i="/save.pdf",l="/create.docx",d="/save.docx",u="/templateData.json",c="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope;let p=null,f=null;function m(e){let t;(0,o.V1)(f,"GdPicture WebAssembly is not loaded.");for(var n=arguments.length,s=new Array(n>1?n-1:0),r=1;r<n;r++)s[r-1]=arguments[r];for(const e of s)t=Object.assign(s[0],e);const a=JSON.stringify({type:e,...t}),i=JSON.parse(f.CommandHandler(a));if(!i.success)throw new Error(i.errorReason+": "+i.errorMessage+"\n"+i.error);return i}class w{_mountCustomFonts(e,t){(0,o.V1)(p,"WebAssembly module not loaded."),p.FS.mkdir(t);{const n=c?p.FS.filesystems.WORKERFS:p.FS.filesystems.MEMFS;p.FS.mount(n,{blobs:e},t)}}async loadModule(e,t,n,o,r,a,i){const{Assemblies:l,Module:d}=await async function(e,t){if("string"==typeof e){const n="nutrient-viewer-lib/",o=`${n}gdpicture-aa63976b/jit`,s=`${n}gdpicture-aa63976b/aot`;let r,a;t?(r=`${e}${s}/initDotnet.js`,a=`${e}${s}`):(r=`${e}${o}/initDotnet.js`,a=`${e}${o}`);const{initDotnet:i}=await import(r);return i(a,((e,t,n,o,s)=>"blazor.boot.json"===t?fetch(n,{credentials:"same-origin"}):null))}throw new Error("GdPicture WASM loader not implemented")}(e,t);f=l.GdPictureWasm.API,p=d,m("gdpicture/setLicense",{origin:n},{licenseKey:o||"DEMO_PSPDFKIT_WEB"});const u=r?"/fonts":"";if(r&&!p.FS.analyzePath(u).exists&&(this._mountCustomFonts(r,u),m("gdpicture/setFonts",{fontPaths:[u]})),a){const e=await(0,s.sw)(a);m("gdpicture/setDynamicFontLoading",{baseUrl:a.split("/").slice(0,-1).join("/"),allowedFonts:e.availableFonts,v:1})}i&&m("gdpicture/setFontSubstitutions",{fontSubstitutions:i})}toPdf(e,t,n,o,s){let l=a;if(s&&"pdf"!==s)l+=`.${s}`;else if(o&&"application/pdf"!==o){const e=o.toLowerCase(),t=S.hasOwnProperty(e)&&S[e];t&&(l+=`.${t}`)}p.FS.writeFile(l,new Uint8Array(e));const d={file:i,format:"pdf",conformance:t&&t in r?t:void 0,officeConversionSettings:F(n)};try{return m("gdpicture/process",{input:{file:l},output:d}),p.FS.readFile(i).buffer}finally{try{p.FS.unlink(i),p.FS.unlink(l)}catch(e){}}}toOffice(e,t){p.FS.writeFile(a,new Uint8Array(e));const n=`/save.${t}`;try{return m("gdpicture/process",{input:{file:a},output:{file:n,format:t}}),p.FS.readFile(n).buffer}finally{try{p.FS.unlink(n),p.FS.unlink(a)}catch(e){console.log(e.message)}}}async populateDocumentTemplate(e,t){let n;p.FS.writeFile(l,new Uint8Array(e));try{n=JSON.stringify(t,null,2)}catch(e){throw new Error("Invalid config data")}p.FS.writeFile(u,n);try{return m("gdpicture/process-office-template",{inputFile:l,modelAndConfigFile:u,outputFile:d}),p.FS.readFile(d).buffer}finally{try{p.FS.unlink(d),p.FS.unlink(u),p.FS.unlink(l)}catch(e){console.log(e.message)}}}}const h={allMarkup:0,simpleMarkup:1,noMarkup:2,original:3},_=h.noMarkup,g={documentMarkupMode:_};function F(e){if(!e)return g;if(!e.documentMarkupMode)return{...e,documentMarkupMode:_};if(!(e.documentMarkupMode in h))throw new Error(`Invalid documentMarkupMode value: ${e.documentMarkupMode}. Allowed values are: ${Object.keys(h).join(", ")}`);return{...e,documentMarkupMode:h[e.documentMarkupMode]}}const S={"application/msword":"doc","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"docx","application/vnd.ms-excel":"xls","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"xlsx","application/vnd.ms-powerpoint":"ppt","application/vnd.openxmlformats-officedocument.presentationml.presentation":"pptx","text/plain":"txt"};var y=n(67136);const b=class{getModuleLoadPromise(){return this.moduleLoadPromise}constructor(e){let{baseUrl:t,aot:n,mainThreadOrigin:s,licenseKey:r,customFonts:a,dynamicFonts:i,fontSubstitutions:l,workerSpawner:d,wasmLoaderPath:u}=e;(0,y.A)(this,"requests",new Map),(0,y.A)(this,"nextRequestId",1),(0,y.A)(this,"handleMessage",(e=>{const t=e.data,n=this.requests.get(t.id);(0,o.V1)(n,`No request was made for id ${t.id}.`);const{resolve:s,reject:r}=n;if(this.requests.delete(t.id),t.error){const e=new o.uE(t.error);e.callArgs=t.callArgs,r(e)}else s(t.result)})),this.workerSpawner=d,this.workerSpawner.setMessageHandler(this.handleMessage),this.moduleLoadPromise=this.sendRequest("loadModule",[u?{baseUrl:t,wasmLoaderPath:u}:t,n,s,r,a,i,l])}toOffice(e,t){return this.sendRequest("toOffice",[e,t])}toPdf(e){let t,{document:n,conformance:o,officeConversionSettings:s,contentType:r,extension:a}=e;return o&&(t=o.replace("pdf","pdf_").replaceAll("-","_")),this.sendRequest("toPdf",[n,t,s,r,a])}async populateDocumentTemplate(e,t){return this.sendRequest("populateDocumentTemplate",[e,t])}destroy(){this.workerSpawner?.terminate(),this.workerSpawner=null}async sendRequest(e,t){(0,o.V1)(this.workerSpawner,"GdPictureClient has been destroyed"),this.moduleLoadPromise&&await this.moduleLoadPromise;const n=this.workerSpawner;return new Promise(((o,s)=>{const r=this.assignId(),a=[...t].filter((e=>e instanceof ArrayBuffer));n.postMessage({id:r,action:e,args:t},a),this.requests=this.requests.set(r,{resolve:o,reject:s})}))}assignId(){const e=this.nextRequestId;return this.nextRequestId=this.nextRequestId+1,e}};const k=async function(){let e;if(!(arguments.length>0&&void 0!==arguments[0])||arguments[0]){const{default:t}=await n.e(11).then(n.bind(n,37979));e=new t}else e=new Worker(new URL(n.p+n.u(374),n.b));return{setMessageHandler(t){(0,o.V1)(e,"Worker is null"),e.onmessage=t},postMessage(t,n){e?.postMessage(t,n)},terminate(){e?.terminate(),e=null}}}}}]);