/*!
 * Nutrient Web SDK 1.7.0-24b29af (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/
 */
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.NutrientViewer=e():t.NutrientViewer=e()}(globalThis,(()=>(()=>{"use strict";const t=function t(e){let n;return n=e instanceof Error?e:new Error(e),Object.setPrototypeOf(n,t.prototype),n};t.prototype=Object.create(Error.prototype,{name:{value:"PSPDFKitError",enumerable:!1}});const e=t;function n(t,n){if(!t)throw new e(`Assertion failed: ${n||"Condition not met"}\n\nFor further assistance, please go to: https://www.nutrient.io/support/request`)}["a[href]","area[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex^="-"])'].join(",");new WeakMap;async function o(t){const n=(await async function(t){try{const n=await fetch(t).catch((n=>{throw new e(`Error fetching dynamic fonts file ${t}. ${n}`)}));if(200!==n.status)throw new e(`Error fetching dynamic fonts file ${t}. Status code: ${n.status}`);return n}catch(t){throw t}}(t)).json().catch((n=>{throw new e(`Error parsing dynamic fonts file ${t}. ${n}`)}));return n}let r=function(t){return t[t.pdf_a_1a=0]="pdf_a_1a",t[t.pdf_a_1b=1]="pdf_a_1b",t[t.pdf_a_2a=2]="pdf_a_2a",t[t.pdf_a_2u=3]="pdf_a_2u",t[t.pdf_a_2b=4]="pdf_a_2b",t[t.pdf_a_3a=5]="pdf_a_3a",t[t.pdf_a_3u=6]="pdf_a_3u",t[t.pdf_a_3b=7]="pdf_a_3b",t[t.pdf_a_4=8]="pdf_a_4",t[t.pdf_a_4e=9]="pdf_a_4e",t[t.pdf_a_4f=10]="pdf_a_4f",t}({});const i="/create.pdf",a="/save.pdf",s="/create.docx",f="/save.docx",c="/templateData.json",l="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope;let d=null,u=null;function p(t){let e;n(u,"GdPicture WebAssembly is not loaded.");for(var o=arguments.length,r=new Array(o>1?o-1:0),i=1;i<o;i++)r[i-1]=arguments[i];for(const t of r)e=Object.assign(r[0],t);const a=JSON.stringify({type:t,...e}),s=JSON.parse(u.CommandHandler(a));if(!s.success)throw new Error(s.errorReason+": "+s.errorMessage+"\n"+s.error);return s}const y=new class{_mountCustomFonts(t,e){n(d,"WebAssembly module not loaded."),d.FS.mkdir(e);{const n=l?d.FS.filesystems.WORKERFS:d.FS.filesystems.MEMFS;d.FS.mount(n,{blobs:t},e)}}async loadModule(t,e,n,r,i,a,s){const{Assemblies:f,Module:c}=await async function(t,e){if("string"==typeof t){const n="nutrient-viewer-lib/",o=`${n}gdpicture-8eb92559/jit`,r=`${n}gdpicture-8eb92559/aot`;let i,a;e?(i=`${t}${r}/initDotnet.js`,a=`${t}${r}`):(i=`${t}${o}/initDotnet.js`,a=`${t}${o}`);const{initDotnet:s}=await import(i);return s(a,((t,e,n,o,r)=>"blazor.boot.json"===e?fetch(n,{credentials:"same-origin"}):null))}throw new Error("GdPicture WASM loader not implemented")}(t,e);u=f.GdPictureWasm.API,d=c,p("gdpicture/setLicense",{origin:n},{licenseKey:r||"DEMO_PSPDFKIT_WEB"});const l=i?"/fonts":"";if(i&&!d.FS.analyzePath(l).exists&&(this._mountCustomFonts(i,l),p("gdpicture/setFonts",{fontPaths:[l]})),a){const t=await o(a);p("gdpicture/setDynamicFontLoading",{baseUrl:a.split("/").slice(0,-1).join("/"),allowedFonts:t.availableFonts,v:1})}s&&p("gdpicture/setFontSubstitutions",{fontSubstitutions:s})}toPdf(t,e,n){d.FS.writeFile(i,new Uint8Array(t));const o={file:a,format:"pdf",conformance:e&&e in r?e:void 0,officeConversionSettings:n};try{return p("gdpicture/process",{input:{file:i},output:o}),d.FS.readFile(a).buffer}finally{try{d.FS.unlink(a)}catch(t){}}}toOffice(t,e){d.FS.writeFile(i,new Uint8Array(t));const n=`/save.${e}`;try{return p("gdpicture/process",{input:{file:i},output:{file:n,format:e}}),d.FS.readFile(n).buffer}finally{try{d.FS.unlink(n)}catch(t){console.log(t.message)}}}async populateDocumentTemplate(t,e){let n;d.FS.writeFile(s,new Uint8Array(t));try{n=JSON.stringify(e,null,2)}catch(t){throw new Error("Invalid config data")}d.FS.writeFile(c,n);try{return p("gdpicture/process-office-template",{inputFile:s,modelAndConfigFile:c,outputFile:f}),d.FS.readFile(f).buffer}finally{try{d.FS.unlink(f),d.FS.unlink(c)}catch(t){console.log(t.message)}}}},_=self;return _.global=_,_.module={},_.onmessage=async t=>{let e,n,{data:o}=t;try{const t=await y[o.action](...o.args);if(e={id:o.id,result:t},Array.isArray(t)){const e=t.filter((t=>t instanceof ArrayBuffer));e.length>0&&(n=e)}t instanceof ArrayBuffer&&(n=[t])}catch(t){const r=[...o.args].filter((t=>t instanceof ArrayBuffer));r.length>0&&(n=r),e={id:o.id,error:t.message||t.toString(),callArgs:o.args}}_.postMessage(e,n)},{}})()));