/*!
 * Nutrient Web SDK 1.13.0 (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/
 */
!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";var t,e,r,n={},i={};function o(t){var e=i[t];if(void 0!==e)return e.exports;var r=i[t]={exports:{}};return n[t](r,r.exports,o),r.exports}o.m=n,o.d=(t,e)=>{for(var r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.f={},o.e=t=>Promise.all(Object.keys(o.f).reduce((e,r)=>(o.f[r](t,e),e),[])),o.u=t=>"nutrient-viewer-lib/chunk-"+t+"-"+{340:"f89849387aa2b77a",567:"29eef7c046cd0c32"}[t]+".js",o.miniCssF=t=>{},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),t={},e="NutrientViewer:",o.l=(r,n,i,a)=>{if(t[r])t[r].push(n);else{var s,u;if(void 0!==i)for(var f=document.getElementsByTagName("script"),c=0;c<f.length;c++){var l=f[c];if(l.getAttribute("src")==r||l.getAttribute("data-webpack")==e+i){s=l;break}}s||(u=!0,(s=document.createElement("script")).charset="utf-8",o.nc&&s.setAttribute("nonce",o.nc),s.setAttribute("data-webpack",e+i),s.src=o.tu(r)),t[r]=[n];var d=(e,n)=>{s.onerror=s.onload=null,clearTimeout(p);var i=t[r];if(delete t[r],s.parentNode&&s.parentNode.removeChild(s),i&&i.forEach(t=>t(n)),e)return e(n)},p=setTimeout(d.bind(null,void 0,{type:"timeout",target:s}),12e4);s.onerror=d.bind(null,s.onerror),s.onload=d.bind(null,s.onload),u&&document.head.appendChild(s)}},o.tt=()=>(void 0===r&&(r={createScriptURL:t=>t},"undefined"!=typeof trustedTypes&&trustedTypes.createPolicy&&(r=trustedTypes.createPolicy("nutrient-web-sdk#webpack",r))),r),o.tu=t=>o.tt().createScriptURL(t),o.p="",(()=>{var t={374:0};o.f.j=(e,r)=>{var n=o.o(t,e)?t[e]:void 0;if(0!==n)if(n)r.push(n[2]);else{var i=new Promise((r,i)=>n=t[e]=[r,i]);r.push(n[2]=i);var a=o.p+o.u(e),s=new Error;o.l(a,r=>{if(o.o(t,e)&&(0!==(n=t[e])&&(t[e]=void 0),n)){var i=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;s.message="Loading chunk "+e+" failed.\n("+i+": "+a+")",s.name="ChunkLoadError",s.type=i,s.request=a,n[1](s)}},"chunk-"+e,e)}};var e=(e,r)=>{var n,i,[a,s,u]=r,f=0;if(a.some(e=>0!==t[e])){for(n in s)o.o(s,n)&&(o.m[n]=s[n]);if(u)u(o)}for(e&&e(r);f<a.length;f++)i=a[f],o.o(t,i)&&t[i]&&t[i][0](),t[i]=0},r=globalThis.webpackChunkNutrientViewer=globalThis.webpackChunkNutrientViewer||[];r.forEach(e.bind(null,0)),r.push=e.bind(null,r.push.bind(r))})();const a=function t(e){let r;return r=e instanceof Error?e:new Error(e),Object.setPrototypeOf(r,t.prototype),r};a.prototype=Object.create(Error.prototype,{name:{value:"PSPDFKitError",enumerable:!1}});const s=a;function u(t,e){if(!t)throw new s(`Assertion failed: ${e||"Condition not met"}\n\nFor further assistance, please go to: https://www.nutrient.io/support/request`)}function f(t){return"[object Object]"===Object.prototype.toString.call(t)}["a[href]","area[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex^="-"])'].join(",");function c(t){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},c(t)}function l(t){var e=function(t,e){if("object"!=c(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=c(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==c(e)?e:e+""}function d(t,e,r){return(e=l(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}new WeakMap;async function p(t){const e=(await async function(t){try{const e=await fetch(t).catch(e=>{throw new s(`Error fetching dynamic fonts file ${t}. ${e}`)});if(200!==e.status)throw new s(`Error fetching dynamic fonts file ${t}. Status code: ${e.status}`);return e}catch(t){throw t}}(t)).json().catch(e=>{throw new s(`Error parsing dynamic fonts file ${t}. ${e}`)});return e}let m=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 h=/^data:([^;,]+)?;base64,(.*)$/i,g=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}(?:==)?|[A-Za-z0-9+/]{3}=?)?$/,w=new Set(["original","fixed","fit-width","fit-height","fit-max"]),b=new Set(["png","jpg","gif","bmp","tif"]),y={"image/png":"png","image/jpeg":"jpg","image/jpg":"jpg","image/gif":"gif","image/bmp":"bmp","image/tiff":"tif","image/x-tiff":"tif"};async function v(t){const e={urlImageReferences:[]},r=S(t.model,"$.model",e);if(e.urlImageReferences.length>0){const t=await async function(t){const e=Array.from(new Set(t.map(t=>t.normalizedUrl))),r=new Map;for(const e of t){if(!e.preferredFormat)continue;const t=r.get(e.normalizedUrl);if(t){if(t.format!==e.preferredFormat)throw new Error(`Conflicting image formats for URL "${e.normalizedUrl}" between ${t.path} and ${e.path}.`)}else r.set(e.normalizedUrl,{format:e.preferredFormat,path:e.path})}const n=await Promise.all(e.map(t=>async function(t,e){let r;try{r=await fetch(t)}catch(e){throw new Error(`Failed to fetch ${t}. This can happen when the URL is cross-origin without CORS headers. Configure CORS or pass base64/data URL instead.`)}if(!r.ok)throw new Error(`Failed to fetch ${t}: ${r.status} ${r.statusText}.`);const n=new Uint8Array(await r.arrayBuffer()),i=r.headers.get("content-type");if(i?.toLowerCase().includes("image/svg+xml"))throw new Error("svg format is not supported in this release.");const o=function(t){if(!t)return;const e=t.toLowerCase().split(";")[0].trim();return y[e]}(i),a=function(t){try{const e=new URL(t).pathname,r=e.split(".").pop()?.toLowerCase();if(!r)return;return U(r)??void 0}catch(t){return}}(t),s=e??o??a;if(!s)throw new Error(`Failed to infer image format for ${t}. Provide "format" in the image object.`);return{normalizedUrl:t,base64Data:E(n),format:s}}(t,r.get(t)?.format)));return new Map(n.map(t=>[t.normalizedUrl,t]))}(e.urlImageReferences);!function(t,e){for(const r of t){const t=e.get(r.normalizedUrl);r.image.source="base64",r.image.data=t.base64Data,null==r.image.format&&t.format&&(r.image.format=t.format),delete r.image.url,delete r.image.path}}(e.urlImageReferences,t)}const n=function(t){if(null==t)return{start:"{",end:"}"};if(!f(t))throw new Error("$.config must be a valid object.");const e=t.delimiter;if(null==e)return{start:"{",end:"}"};if(!f(e))throw new Error("$.config.delimiter must be a valid object.");const{start:r,end:n}=e;if(null!=r&&"string"!=typeof r)throw new Error("$.config.delimiter.start must be a string.");if(null!=n&&"string"!=typeof n)throw new Error("$.config.delimiter.end must be a string.");return{start:"string"==typeof r?r:"{",end:"string"==typeof n?n:"}"}}(t.config);return{serializedData:JSON.stringify({config:{delimiter:n},model:r},null,2)}}function S(t,e,r){if(Array.isArray(t))return t.map((t,n)=>S(t,`${e}[${n}]`,r));if(!f(t))return t;if(function(t){return f(t)&&"image"===t._type}(t))return function(t,e,r){const n={...t},i=function(t,e){if("string"!=typeof t)throw new Error(`${e}.source must be a string.`);if("dataUrl"===t)return"base64";if("base64"===t||"url"===t)return t;if("file"===t)throw new Error(`${e}.source "file" is not supported in public APIs. Use "base64" (or "dataUrl") or "url".`);throw new Error(`${e}.source must be one of "base64", "dataUrl", or "url". Received "${t}".`)}(n.source,e);n.source=i,function(t,e){if(void 0===t.sizing)return;if(!w.has(t.sizing))throw new Error(`${e}.sizing must be one of "original", "fixed", "fit-width", "fit-height", "fit-max".`);switch(t.sizing){case"fixed":case"fit-max":_(t.width,`${e}.width`),_(t.height,`${e}.height`);break;case"fit-width":_(t.width,`${e}.width`);break;case"fit-height":_(t.height,`${e}.height`)}}(n,e),function(t,e){if(void 0===t.pageNumber)return;if(!Number.isInteger(t.pageNumber)||t.pageNumber<=0)throw new Error(`${e}.pageNumber must be a positive integer.`)}(n,e);const o=function(t,e){if(void 0===t)return;if("string"!=typeof t)throw new Error(`${e}.format must be a string.`);if("svg"===t.toLowerCase().trim())throw new Error(`${e}.format svg is not supported in this release.`);const r=U(t);if(!r)throw new Error(`${e}.format must be one of "png", "jpg"/"jpeg", "gif", "bmp", "tif"/"tiff".`);return r}(n.format,e);o&&(n.format=o);switch(i){case"base64":{const t=n.data;if("string"!=typeof t||""===t.trim())throw new Error(`${e}.data must be a non-empty string.`);const r=function(t,e){const r=h.exec(t.trim());if(r){const t=(r[1]||"").toLowerCase(),n=r[2];if(!n)throw new Error(`${e} must contain non-empty base64 data.`);if("image/svg+xml"===t)throw new Error(`${e} does not support svg images in this release.`);return $(n,e),{isDataUrl:!0}}return $(t.trim(),e),{isDataUrl:!1}}(t,`${e}.data`);if(!r.isDataUrl&&!n.format)throw new Error(`${e}.format must be supplied when source is raw base64 data.`);break}case"url":{const t="string"==typeof n.url&&""!==n.url.trim()?n.url.trim():"string"==typeof n.path&&""!==n.path.trim()?n.path.trim():null;if(!t)throw new Error(`${e}.url must be supplied when source is "url".`);const i=function(t,e){let r;try{r=new URL(t.trim())}catch(t){throw new Error(`${e} must be a valid absolute URL.`)}if(!["http:","https:"].includes(r.protocol))throw new Error(`${e} must use http or https.`);return r.toString()}(t,`${e}.url`);n.url=i,r.urlImageReferences.push({path:e,image:n,normalizedUrl:i,preferredFormat:n.format});break}}return n}(t,e,r);const n={};for(const[i,o]of Object.entries(t))n[i]=S(o,`${e}${F(i)}`,r);return n}function E(t){if("undefined"!=typeof Buffer)return Buffer.from(t).toString("base64");let e="";for(let r=0;r<t.length;r+=32768){const n=t.subarray(r,r+32768);e+=String.fromCharCode(...n)}return btoa(e)}function $(t,e){const r=t.replace(/\s+/g,"");if(""===r||!g.test(r))throw new Error(`${e} must be valid base64 data.`)}function _(t,e){if("number"!=typeof t||!Number.isFinite(t)||t<=0)throw new Error(`${e} must be a positive number.`)}function U(t){const e=t.toLowerCase().trim();return"jpeg"===e?"jpg":"tiff"===e?"tif":b.has(e)?e:null}function F(t){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t)?`.${t}`:`[${JSON.stringify(t)}]`}const A=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;const k=function(t){return"string"==typeof t&&A.test(t)};const j=function(t){if(!k(t))throw TypeError("Invalid UUID");let e;return Uint8Array.of((e=parseInt(t.slice(0,8),16))>>>24,e>>>16&255,e>>>8&255,255&e,(e=parseInt(t.slice(9,13),16))>>>8,255&e,(e=parseInt(t.slice(14,18),16))>>>8,255&e,(e=parseInt(t.slice(19,23),16))>>>8,255&e,(e=parseInt(t.slice(24,36),16))/1099511627776&255,e/4294967296&255,e>>>24&255,e>>>16&255,e>>>8&255,255&e)};const x=[];for(let t=0;t<256;++t)x.push((t+256).toString(16).slice(1));function I(t,e=0){return(x[t[e+0]]+x[t[e+1]]+x[t[e+2]]+x[t[e+3]]+"-"+x[t[e+4]]+x[t[e+5]]+"-"+x[t[e+6]]+x[t[e+7]]+"-"+x[t[e+8]]+x[t[e+9]]+"-"+x[t[e+10]]+x[t[e+11]]+x[t[e+12]]+x[t[e+13]]+x[t[e+14]]+x[t[e+15]]).toLowerCase()}let C;const M=new Uint8Array(16);function T(t){return 14+(t+64>>>9<<4)+1}function P(t,e){const r=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(r>>16)<<16|65535&r}function L(t,e,r,n,i,o){return P((a=P(P(e,t),P(n,o)))<<(s=i)|a>>>32-s,r);var a,s}function O(t,e,r,n,i,o,a){return L(e&r|~e&n,t,e,i,o,a)}function D(t,e,r,n,i,o,a){return L(e&n|r&~n,t,e,i,o,a)}function R(t,e,r,n,i,o,a){return L(e^r^n,t,e,i,o,a)}function z(t,e,r,n,i,o,a){return L(r^(e|~n),t,e,i,o,a)}const N=function(t){return function(t){const e=new Uint8Array(4*t.length);for(let r=0;r<4*t.length;r++)e[r]=t[r>>2]>>>r%4*8&255;return e}(function(t,e){const r=new Uint32Array(T(e)).fill(0);r.set(t),r[e>>5]|=128<<e%32,r[r.length-1]=e,t=r;let n=1732584193,i=-271733879,o=-1732584194,a=271733878;for(let e=0;e<t.length;e+=16){const r=n,s=i,u=o,f=a;n=O(n,i,o,a,t[e],7,-680876936),a=O(a,n,i,o,t[e+1],12,-389564586),o=O(o,a,n,i,t[e+2],17,606105819),i=O(i,o,a,n,t[e+3],22,-1044525330),n=O(n,i,o,a,t[e+4],7,-176418897),a=O(a,n,i,o,t[e+5],12,1200080426),o=O(o,a,n,i,t[e+6],17,-1473231341),i=O(i,o,a,n,t[e+7],22,-45705983),n=O(n,i,o,a,t[e+8],7,1770035416),a=O(a,n,i,o,t[e+9],12,-1958414417),o=O(o,a,n,i,t[e+10],17,-42063),i=O(i,o,a,n,t[e+11],22,-1990404162),n=O(n,i,o,a,t[e+12],7,1804603682),a=O(a,n,i,o,t[e+13],12,-40341101),o=O(o,a,n,i,t[e+14],17,-1502002290),i=O(i,o,a,n,t[e+15],22,1236535329),n=D(n,i,o,a,t[e+1],5,-165796510),a=D(a,n,i,o,t[e+6],9,-1069501632),o=D(o,a,n,i,t[e+11],14,643717713),i=D(i,o,a,n,t[e],20,-373897302),n=D(n,i,o,a,t[e+5],5,-701558691),a=D(a,n,i,o,t[e+10],9,38016083),o=D(o,a,n,i,t[e+15],14,-660478335),i=D(i,o,a,n,t[e+4],20,-405537848),n=D(n,i,o,a,t[e+9],5,568446438),a=D(a,n,i,o,t[e+14],9,-1019803690),o=D(o,a,n,i,t[e+3],14,-187363961),i=D(i,o,a,n,t[e+8],20,1163531501),n=D(n,i,o,a,t[e+13],5,-1444681467),a=D(a,n,i,o,t[e+2],9,-51403784),o=D(o,a,n,i,t[e+7],14,1735328473),i=D(i,o,a,n,t[e+12],20,-1926607734),n=R(n,i,o,a,t[e+5],4,-378558),a=R(a,n,i,o,t[e+8],11,-2022574463),o=R(o,a,n,i,t[e+11],16,1839030562),i=R(i,o,a,n,t[e+14],23,-35309556),n=R(n,i,o,a,t[e+1],4,-1530992060),a=R(a,n,i,o,t[e+4],11,1272893353),o=R(o,a,n,i,t[e+7],16,-155497632),i=R(i,o,a,n,t[e+10],23,-1094730640),n=R(n,i,o,a,t[e+13],4,681279174),a=R(a,n,i,o,t[e],11,-358537222),o=R(o,a,n,i,t[e+3],16,-722521979),i=R(i,o,a,n,t[e+6],23,76029189),n=R(n,i,o,a,t[e+9],4,-640364487),a=R(a,n,i,o,t[e+12],11,-421815835),o=R(o,a,n,i,t[e+15],16,530742520),i=R(i,o,a,n,t[e+2],23,-995338651),n=z(n,i,o,a,t[e],6,-198630844),a=z(a,n,i,o,t[e+7],10,1126891415),o=z(o,a,n,i,t[e+14],15,-1416354905),i=z(i,o,a,n,t[e+5],21,-57434055),n=z(n,i,o,a,t[e+12],6,1700485571),a=z(a,n,i,o,t[e+3],10,-1894986606),o=z(o,a,n,i,t[e+10],15,-1051523),i=z(i,o,a,n,t[e+1],21,-2054922799),n=z(n,i,o,a,t[e+8],6,1873313359),a=z(a,n,i,o,t[e+15],10,-30611744),o=z(o,a,n,i,t[e+6],15,-1560198380),i=z(i,o,a,n,t[e+13],21,1309151649),n=z(n,i,o,a,t[e+4],6,-145523070),a=z(a,n,i,o,t[e+11],10,-1120210379),o=z(o,a,n,i,t[e+2],15,718787259),i=z(i,o,a,n,t[e+9],21,-343485551),n=P(n,r),i=P(i,s),o=P(o,u),a=P(a,f)}return Uint32Array.of(n,i,o,a)}(function(t){if(0===t.length)return new Uint32Array;const e=new Uint32Array(T(8*t.length)).fill(0);for(let r=0;r<t.length;r++)e[r>>2]|=(255&t[r])<<r%4*8;return e}(t),8*t.length))};const q="6ba7b810-9dad-11d1-80b4-00c04fd430c8",B="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function V(t,e,r,n,i,o){const a="string"==typeof r?function(t){t=unescape(encodeURIComponent(t));const e=new Uint8Array(t.length);for(let r=0;r<t.length;++r)e[r]=t.charCodeAt(r);return e}(r):r,s="string"==typeof n?j(n):n;if("string"==typeof n&&(n=j(n)),16!==n?.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let u=new Uint8Array(16+a.length);if(u.set(s),u.set(a,s.length),u=e(u),u[6]=15&u[6]|t,u[8]=63&u[8]|128,i){o=o||0;for(let t=0;t<16;++t)i[o+t]=u[t];return i}return I(u)}function H(t,e,r,n){return V(48,N,t,e,r,n)}H.DNS=q,H.URL=B;const W={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};const K=function(t,e,r){if(W.randomUUID&&!e&&!t)return W.randomUUID();const n=(t=t||{}).random??t.rng?.()??function(){if(!C){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");C=crypto.getRandomValues.bind(crypto)}return C(M)}();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,e){if((r=r||0)<0||r+16>e.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let t=0;t<16;++t)e[r+t]=n[t];return e}return I(n)};function G(t,e,r,n){switch(t){case 0:return e&r^~e&n;case 1:case 3:return e^r^n;case 2:return e&r^e&n^r&n}}function Q(t,e){return t<<e|t>>>32-e}const Z=function(t){const e=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520],n=new Uint8Array(t.length+1);n.set(t),n[t.length]=128;const i=(t=n).length/4+2,o=Math.ceil(i/16),a=new Array(o);for(let e=0;e<o;++e){const r=new Uint32Array(16);for(let n=0;n<16;++n)r[n]=t[64*e+4*n]<<24|t[64*e+4*n+1]<<16|t[64*e+4*n+2]<<8|t[64*e+4*n+3];a[e]=r}a[o-1][14]=8*(t.length-1)/Math.pow(2,32),a[o-1][14]=Math.floor(a[o-1][14]),a[o-1][15]=8*(t.length-1)&4294967295;for(let t=0;t<o;++t){const n=new Uint32Array(80);for(let e=0;e<16;++e)n[e]=a[t][e];for(let t=16;t<80;++t)n[t]=Q(n[t-3]^n[t-8]^n[t-14]^n[t-16],1);let i=r[0],o=r[1],s=r[2],u=r[3],f=r[4];for(let t=0;t<80;++t){const r=Math.floor(t/20),a=Q(i,5)+G(r,o,s,u)+f+e[r]+n[t]>>>0;f=u,u=s,s=Q(o,30)>>>0,o=i,i=a}r[0]=r[0]+i>>>0,r[1]=r[1]+o>>>0,r[2]=r[2]+s>>>0,r[3]=r[3]+u>>>0,r[4]=r[4]+f>>>0}return Uint8Array.of(r[0]>>24,r[0]>>16,r[0]>>8,r[0],r[1]>>24,r[1]>>16,r[1]>>8,r[1],r[2]>>24,r[2]>>16,r[2]>>8,r[2],r[3]>>24,r[3]>>16,r[3]>>8,r[3],r[4]>>24,r[4]>>16,r[4]>>8,r[4])};function J(t,e,r,n){return V(80,Z,t,e,r,n)}J.DNS=q,J.URL=B;function Y(){const t="nutrient-analytics-user-id";if(!window||!window.localStorage)return null;try{if(window.localStorage.getItem(t))return window.localStorage.getItem(t);const e=K();return window.localStorage.setItem(t,e),e}catch{return null}}class X{constructor(){d(this,"maxQueueSize",1e3),d(this,"flushTimer",null),d(this,"visibilityChangeHandler",null),d(this,"isFlushing",!1),d(this,"queue",[]),d(this,"allEvents",[])}static getInstance(){return X.instance||(X.instance=new X),X.instance}emit(t){this.collect(t)}configure(t){const{hmacSecret:e,endpoint:r,flushInterval:n,maxQueueSize:i,clientInfo:o}=t;this.clientInfo=o,this.hmacSecret=this.hexStringToHmacSecret(e),this.endpoint=r,void 0!==i&&(this.maxQueueSize=i),this.isE2E()||(this.flushTimer=setInterval(()=>this.flush(),n||3e3),this.visibilityChangeHandler=()=>{"hidden"===document.visibilityState&&this.queue.length>0&&this.flush()},document.addEventListener("visibilitychange",this.visibilityChangeHandler))}cleanup(){null!==this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null),null!==this.visibilityChangeHandler&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=null)}static cleanup(){X.instance&&(X.instance.cleanup(),X.instance=void 0)}shouldBeIgnored(t){switch(t.name){case"content|editor|save":return!!this.allEvents.find(e=>e.name===t.name&&Math.abs(e.timestamp-t.timestamp)<1e3);case"form|creator|field|add":return!this.allEvents.find(t=>"form|creator|enter"===t.name);case"annotation|edit":return!!this.allEvents.find(e=>e.name===t.name&&Math.abs(e.timestamp-t.timestamp)<100);default:return!1}}collect(t){if(this.isE2E()){const e=window;if(e.__PSPDFKIT_ANALYTICS_EVENTS__??=[],this.shouldBeIgnored(t))return;return this.allEvents.push(t),void e.__PSPDFKIT_ANALYTICS_EVENTS__.push(t)}this.shouldBeIgnored(t)||(this.allEvents.push(t),this.queue.length>=this.maxQueueSize&&this.queue.shift(),this.queue.push(t))}async flush(){if(this.isFlushing||this.isE2E()||0===this.queue.length)return;this.isFlushing=!0;const t=this.queue.splice(0,this.queue.length);try{const{prepareUpload:e}=await Promise.all([o.e(340),o.e(567)]).then(o.bind(o,23948)),r=t.map(t=>({type:"counter",name:t.name,attributes:Object.fromEntries(Object.entries(t.attributes).map(t=>{let[e,r]=t;return[e,String(r)]})),timestamp:t.timestamp})),n=await e({clientInfo:{...this.clientInfo,tag:Y()??void 0},hmacSecret:this.hmacSecret},r);if(!n)return void this.requeue(t);const i=`${this.endpoint}/proto/metrics`,a=await fetch(i,{method:"POST",headers:n.headers,body:n.body,keepalive:!0});if(!a.ok)throw new Error(`Analytics request failed with status ${a.status}`)}catch(e){this.requeue(t)}finally{this.isFlushing=!1}}requeue(t){const e=this.maxQueueSize-this.queue.length;if(e<=0)return;const r=t.slice(0,e);this.queue.unshift(...r)}isE2E(){return"undefined"!=typeof window&&Boolean(window.__E2E_TEST__)}hexStringToHmacSecret(t){if(128!==t.length)throw new Error(`Invalid hex string length: expected 128 characters, got ${t.length}`);return new Uint8Array(Array.from(t,t=>t.charCodeAt(0)))}}function tt(t){var e,r;e="convert|from|office",r={feature:"office_conversion",mimeType:t},X.getInstance().emit({name:e,attributes:r??{},timestamp:Date.now()})}d(X,"instance",void 0);const et="/create.pdf",rt="/save.pdf",nt="/create.docx",it="/save.docx",ot="/templateData.json",at="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope;let st=null,ut=null;function ft(t){let e;u(ut,"GdPicture WebAssembly is not loaded.");for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];for(const t of n)e=Object.assign(n[0],t);const o=JSON.stringify({type:t,...e}),a=JSON.parse(ut.CommandHandler(o));if(!a.success)throw new Error(a.errorReason+": "+a.errorMessage+"\n"+a.error);return a}const ct={allMarkup:0,simpleMarkup:1,noMarkup:2,original:3},lt=ct.noMarkup,dt={documentMarkupMode:lt};function pt(t){if(!t)return dt;if(!t.documentMarkupMode)return{...t,documentMarkupMode:lt};if(!(t.documentMarkupMode in ct))throw new Error(`Invalid documentMarkupMode value: ${t.documentMarkupMode}. Allowed values are: ${Object.keys(ct).join(", ")}`);return{...t,documentMarkupMode:ct[t.documentMarkupMode]}}const mt={"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"},ht=new class{_mountCustomFonts(t,e){u(st,"WebAssembly module not loaded."),st.FS.mkdir(e);{const r=at?st.FS.filesystems.WORKERFS:st.FS.filesystems.MEMFS;st.FS.mount(r,{blobs:t},e)}}async loadModule(t,e,r,n,i,o,a){const{Assemblies:s,Module:u}=await async function(t,e){if("string"==typeof t){const r="nutrient-viewer-lib/",n=`${r}gdpicture-c414c4b9/jit`,i=`${r}gdpicture-c414c4b9/aot`;let o,a;e?(o=`${t}${i}/initDotnet.js`,a=`${t}${i}`):(o=`${t}${n}/initDotnet.js`,a=`${t}${n}`);const{initDotnet:s}=await import(o);return s(a,(t,e,r,n,i)=>"blazor.boot.json"===e?fetch(r,{credentials:"same-origin"}):null)}throw new Error("GdPicture WASM loader not implemented")}(t,e);ut=s.GdPictureWasm.API,st=u,ft("gdpicture/setLicense",{origin:r},{licenseKey:n||"DEMO_PSPDFKIT_WEB"});const f=i?"/fonts":"";if(i&&!st.FS.analyzePath(f).exists&&(this._mountCustomFonts(i,f),ft("gdpicture/setFonts",{fontPaths:[f]})),o){const t=await p(o);ft("gdpicture/setDynamicFontLoading",{baseUrl:o.split("/").slice(0,-1).join("/"),allowedFonts:t.availableFonts,v:1})}a&&ft("gdpicture/setFontSubstitutions",{fontSubstitutions:a})}toPdf(t,e,r,n,i){let o=et;if(i&&"pdf"!==i&&Object.values(mt).includes(i)){tt(Object.keys(mt).find(t=>mt[t].toLowerCase()===i.toLowerCase()).toLowerCase()),o+=`.${i}`}else if(n&&"application/pdf"!==n){const t=n.toLowerCase();tt(t);const e=mt.hasOwnProperty(t)&&mt[t];e&&(o+=`.${e}`)}st.FS.writeFile(o,new Uint8Array(t),{canOwn:!0});const a={file:rt,format:"pdf",conformance:e&&e in m?e:void 0,officeConversionSettings:pt(r)};try{return ft("gdpicture/process",{input:{file:o},output:a}),st.FS.readFile(rt).buffer}finally{try{st.FS.unlink(rt),st.FS.unlink(o)}catch(t){}}}toOffice(t,e){st.FS.writeFile(et,new Uint8Array(t));const r=`/save.${e}`;try{return ft("gdpicture/process",{input:{file:et},output:{file:r,format:e}}),st.FS.readFile(r).buffer}finally{try{st.FS.unlink(r),st.FS.unlink(et)}catch(t){console.log(t.message)}}}async populateDocumentTemplate(t,e){st.FS.writeFile(nt,new Uint8Array(t));const{serializedData:r}=await v(e);st.FS.writeFile(ot,r);try{return ft("gdpicture/process-office-template",{inputFile:nt,modelAndConfigFile:ot,outputFile:it}),st.FS.readFile(it).buffer}finally{try{st.FS.unlink(it),st.FS.unlink(ot),st.FS.unlink(nt)}catch(t){console.log(t.message)}}}},gt=self;return gt.global=gt,gt.module={},gt.onmessage=async t=>{let e,r,{data:n}=t;try{const t=await ht[n.action](...n.args);if(e={id:n.id,result:t},Array.isArray(t)){const e=t.filter(t=>t instanceof ArrayBuffer);e.length>0&&(r=e)}t instanceof ArrayBuffer&&(r=[t])}catch(t){const i=[...n.args].filter(t=>t instanceof ArrayBuffer);i.length>0&&(r=i),e={id:n.id,error:t.message||t.toString(),callArgs:n.args}}gt.postMessage(e,r)},{}})());