/*!
 * Nutrient Web SDK 1.15.0-aa66391 (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([[11],{55324(t,e,r){r.d(e,{default:()=>o});var n=r(37737),i=r.n(n);function o(){return i()('/*!\n * Nutrient Web SDK 1.15.0-aa66391 (https://www.nutrient.io/sdk/web)\n *\n * Copyright (c) 2016-2026 PSPDFKit GmbH. All rights reserved.\n *\n * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW\n * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE PSPDFKIT LICENSE AGREEMENT.\n * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.\n * This notice may not be removed from this file.\n *\n * PSPDFKit uses several open source third-party components: https://www.nutrient.io/legal/acknowledgements/web-acknowledgements/\n */(()=>{"use strict";var t,e={},r={};function n(t){var i=r[t];if(void 0!==i)return i.exports;var o=r[t]={exports:{}};return e[t](o,o.exports,n),o.exports}n.m=e,n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.f={},n.e=t=>Promise.all(Object.keys(n.f).reduce((e,r)=>(n.f[r](t,e),e),[])),n.u=t=>"nutrient-viewer-lib/chunk-"+t+"-001819d9cb42b4b1.worker.js",n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.tt=()=>(void 0===t&&(t={createScriptURL:t=>t},"undefined"!=typeof trustedTypes&&trustedTypes.createPolicy&&(t=trustedTypes.createPolicy("nutrient-web-sdk#webpack",t))),t),n.tu=t=>n.tt().createScriptURL(t),n.p="",(()=>{var t={224:1};n.f.i=(e,r)=>{t[e]||importScripts(n.tu(n.p+n.u(e)))};var e=self.webpackChunkNutrientViewer=self.webpackChunkNutrientViewer||[],r=e.push.bind(e);e.push=e=>{var[i,o,a]=e;for(var s in o)n.o(o,s)&&(n.m[s]=o[s]);for(a&&a(n);i.length;)t[i.pop()]=1;r(e)}})();const i=function t(e){let r;return r=e instanceof Error?e:new Error(e),Object.setPrototypeOf(r,t.prototype),r};i.prototype=Object.create(Error.prototype,{name:{value:"PSPDFKitError",enumerable:!1}});const o=i;function a(t,e){if(!t)throw new o(`Assertion failed: ${e||"Condition not met"}\\n\\nFor further assistance, please go to: https://www.nutrient.io/support/request`)}function s(t){return"[object Object]"===Object.prototype.toString.call(t)}function u(){console.warn(...arguments)}["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 f(t){return f="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},f(t)}function c(t){var e=function(t,e){if("object"!=f(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=f(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==f(e)?e:e+""}function l(t,e,r){return(e=c(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}new WeakMap;async function d(t){const e=(await async function(t){try{const e=await fetch(t).catch(e=>{throw new o(`Error fetching dynamic fonts file ${t}. ${e}`)});if(200!==e.status)throw new o(`Error fetching dynamic fonts file ${t}. Status code: ${e.status}`);return e}catch(t){throw t}}(t)).json().catch(e=>{throw new o(`Error parsing dynamic fonts file ${t}. ${e}`)});return e}let p=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 m=/^data:([^;,]+)?;base64,(.*)$/i,h=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}(?:==)?|[A-Za-z0-9+/]{3}=?)?$/,g=new Set(["original","fixed","fit-width","fit-height","fit-max"]),w=new Set(["png","jpg","gif","bmp","tif"]),b={"image/png":"png","image/jpeg":"jpg","image/jpg":"jpg","image/gif":"gif","image/bmp":"bmp","image/tiff":"tif","image/x-tiff":"tif"};async function y(t){const e={urlImageReferences:[]},r=v(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 b[e]}(i),a=function(t){try{const e=new URL(t).pathname,r=e.split(".").pop()?.toLowerCase();if(!r)return;return _(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:S(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{delimiter:{start:"{",end:"}"}};if(!s(t))throw new Error("$.config must be a valid object.");const e={...t},r=e.delimiter;return e.delimiter=function(t){if(null==t)return{start:"{",end:"}"};if(!s(t))throw new Error("$.config.delimiter must be a valid object.");const e={...t},{start:r,end:n,objectDelimiter:i}=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.");if(null!=i&&"string"!=typeof i)throw new Error("$.config.delimiter.objectDelimiter must be a string.");return e.start="string"==typeof r?r:"{",e.end="string"==typeof n?n:"}",e}(r),e}(t.config);return{serializedData:JSON.stringify({config:n,model:r},null,2)}}function v(t,e,r){if(Array.isArray(t))return t.map((t,n)=>v(t,`${e}[${n}]`,r));if(!s(t))return t;if(function(t){return s(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(!g.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":E(t.width,`${e}.width`),E(t.height,`${e}.height`);break;case"fit-width":E(t.width,`${e}.width`);break;case"fit-height":E(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=_(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=m.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]=v(o,`${e}${U(i)}`,r);return n}function S(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||!h.test(r))throw new Error(`${e} must be valid base64 data.`)}function E(t,e){if("number"!=typeof t||!Number.isFinite(t)||t<=0)throw new Error(`${e} must be a positive number.`)}function _(t){const e=t.toLowerCase().trim();return"jpeg"===e?"jpg":"tiff"===e?"tif":w.has(e)?e:null}function U(t){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t)?`.${t}`:`[${JSON.stringify(t)}]`}const F=/^(?:[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 A=function(t){return"string"==typeof t&&F.test(t)};const j=function(t){if(!A(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 I=[];for(let t=0;t<256;++t)I.push((t+256).toString(16).slice(1));function k(t,e=0){return(I[t[e+0]]+I[t[e+1]]+I[t[e+2]]+I[t[e+3]]+"-"+I[t[e+4]]+I[t[e+5]]+"-"+I[t[e+6]]+I[t[e+7]]+"-"+I[t[e+8]]+I[t[e+9]]+"-"+I[t[e+10]]+I[t[e+11]]+I[t[e+12]]+I[t[e+13]]+I[t[e+14]]+I[t[e+15]]).toLowerCase()}let x;const M=new Uint8Array(16);function C(t){return 14+(t+64>>>9<<4)+1}function D(t,e){const r=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(r>>16)<<16|65535&r}function P(t,e,r,n,i,o){return D((a=D(D(e,t),D(n,o)))<<(s=i)|a>>>32-s,r);var a,s}function O(t,e,r,n,i,o,a){return P(e&r|~e&n,t,e,i,o,a)}function R(t,e,r,n,i,o,a){return P(e&n|r&~n,t,e,i,o,a)}function T(t,e,r,n,i,o,a){return P(e^r^n,t,e,i,o,a)}function L(t,e,r,n,i,o,a){return P(r^(e|~n),t,e,i,o,a)}const z=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(C(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=R(n,i,o,a,t[e+1],5,-165796510),a=R(a,n,i,o,t[e+6],9,-1069501632),o=R(o,a,n,i,t[e+11],14,643717713),i=R(i,o,a,n,t[e],20,-373897302),n=R(n,i,o,a,t[e+5],5,-701558691),a=R(a,n,i,o,t[e+10],9,38016083),o=R(o,a,n,i,t[e+15],14,-660478335),i=R(i,o,a,n,t[e+4],20,-405537848),n=R(n,i,o,a,t[e+9],5,568446438),a=R(a,n,i,o,t[e+14],9,-1019803690),o=R(o,a,n,i,t[e+3],14,-187363961),i=R(i,o,a,n,t[e+8],20,1163531501),n=R(n,i,o,a,t[e+13],5,-1444681467),a=R(a,n,i,o,t[e+2],9,-51403784),o=R(o,a,n,i,t[e+7],14,1735328473),i=R(i,o,a,n,t[e+12],20,-1926607734),n=T(n,i,o,a,t[e+5],4,-378558),a=T(a,n,i,o,t[e+8],11,-2022574463),o=T(o,a,n,i,t[e+11],16,1839030562),i=T(i,o,a,n,t[e+14],23,-35309556),n=T(n,i,o,a,t[e+1],4,-1530992060),a=T(a,n,i,o,t[e+4],11,1272893353),o=T(o,a,n,i,t[e+7],16,-155497632),i=T(i,o,a,n,t[e+10],23,-1094730640),n=T(n,i,o,a,t[e+13],4,681279174),a=T(a,n,i,o,t[e],11,-358537222),o=T(o,a,n,i,t[e+3],16,-722521979),i=T(i,o,a,n,t[e+6],23,76029189),n=T(n,i,o,a,t[e+9],4,-640364487),a=T(a,n,i,o,t[e+12],11,-421815835),o=T(o,a,n,i,t[e+15],16,530742520),i=T(i,o,a,n,t[e+2],23,-995338651),n=L(n,i,o,a,t[e],6,-198630844),a=L(a,n,i,o,t[e+7],10,1126891415),o=L(o,a,n,i,t[e+14],15,-1416354905),i=L(i,o,a,n,t[e+5],21,-57434055),n=L(n,i,o,a,t[e+12],6,1700485571),a=L(a,n,i,o,t[e+3],10,-1894986606),o=L(o,a,n,i,t[e+10],15,-1051523),i=L(i,o,a,n,t[e+1],21,-2054922799),n=L(n,i,o,a,t[e+8],6,1873313359),a=L(a,n,i,o,t[e+15],10,-30611744),o=L(o,a,n,i,t[e+6],15,-1560198380),i=L(i,o,a,n,t[e+13],21,1309151649),n=L(n,i,o,a,t[e+4],6,-145523070),a=L(a,n,i,o,t[e+11],10,-1120210379),o=L(o,a,n,i,t[e+2],15,718787259),i=L(i,o,a,n,t[e+9],21,-343485551),n=D(n,r),i=D(i,s),o=D(o,u),a=D(a,f)}return Uint32Array.of(n,i,o,a)}(function(t){if(0===t.length)return new Uint32Array;const e=new Uint32Array(C(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 N="6ba7b810-9dad-11d1-80b4-00c04fd430c8",B="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function q(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 k(u)}function H(t,e,r,n){return q(48,z,t,e,r,n)}H.DNS=N,H.URL=B;const W={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};const V=function(t,e,r){if(W.randomUUID&&!e&&!t)return W.randomUUID();const n=(t=t||{}).random??t.rng?.()??function(){if(!x){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");x=crypto.getRandomValues.bind(crypto)}return x(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 k(n)};function K(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 G(t,e){return t<<e|t>>>32-e}const Q=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]=G(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=G(i,5)+K(r,o,s,u)+f+e[r]+n[t]>>>0;f=u,u=s,s=G(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 Z(t,e,r,n){return q(80,Q,t,e,r,n)}Z.DNS=N,Z.URL=B;function J(){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=V();return window.localStorage.setItem(t,e),e}catch{return null}}class Y{constructor(){l(this,"maxQueueSize",1e3),l(this,"flushTimer",null),l(this,"visibilityChangeHandler",null),l(this,"isFlushing",!1),l(this,"queue",[]),l(this,"allEvents",[])}static getInstance(){return Y.instance||(Y.instance=new Y),Y.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(){Y.instance&&(Y.instance.cleanup(),Y.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 e=await this.uploadBatch(t);this.requeue(e)}finally{this.isFlushing=!1}}async uploadBatch(t){try{const e=await this.prepareUpload(t);if(!e)return t;const r=`${this.endpoint}/proto/metrics`,n=await fetch(r,{method:"POST",headers:e.headers,body:e.body,keepalive:!0});return n.ok?[]:413===n.status?this.splitAndRetryBatch(t):t}catch(e){return t}}async splitAndRetryBatch(t){if(t.length<=1)return u("Dropping one analytics event: metrics endpoint rejected a single-event payload as too large (HTTP 413)."),[];const e=Math.floor(t.length/2),r=t.slice(0,e),n=t.slice(e);return[...await this.uploadBatch(r),...await this.uploadBatch(n)]}async prepareUpload(t){const{prepareUpload:e}=await n.e(825).then(n.bind(n,825));return e({clientInfo:{...this.clientInfo,tag:J()??void 0},hmacSecret:this.hmacSecret},this.buildMetrics(t))}buildMetrics(t){return 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}))}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 X(t){var e,r;e="convert|from|office",r={feature:"office_conversion",mimeType:t},Y.getInstance().emit({name:e,attributes:r??{},timestamp:Date.now()})}l(Y,"instance",void 0);const tt="/create.pdf",et="/save.pdf",rt="/create.docx",nt="/save.docx",it="/templateData.json",ot="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope;let at=null,st=null;function ut(t){let e;a(st,"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}),s=JSON.parse(st.CommandHandler(o));if(!s.success)throw new Error(s.errorReason+": "+s.errorMessage+"\\n"+s.error);return s}const ft={allMarkup:0,simpleMarkup:1,noMarkup:2,original:3},ct=ft.noMarkup,lt={documentMarkupMode:ct};function dt(t){if(!t)return lt;if(!t.documentMarkupMode)return{...t,documentMarkupMode:ct};if(!(t.documentMarkupMode in ft))throw new Error(`Invalid documentMarkupMode value: ${t.documentMarkupMode}. Allowed values are: ${Object.keys(ft).join(", ")}`);return{...t,documentMarkupMode:ft[t.documentMarkupMode]}}const pt={"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"},mt=new class{_mountCustomFonts(t,e){a(at,"WebAssembly module not loaded."),at.FS.mkdir(e);{const r=ot?at.FS.filesystems.WORKERFS:at.FS.filesystems.MEMFS;at.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-249e54e8/jit`,i=`${r}gdpicture-249e54e8/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);st=s.GdPictureWasm.API,at=u,ut("gdpicture/setLicense",{origin:r},{licenseKey:n||"DEMO_PSPDFKIT_WEB"});const f=i?"/fonts":"";if(i&&!at.FS.analyzePath(f).exists&&(this._mountCustomFonts(i,f),ut("gdpicture/setFonts",{fontPaths:[f]})),o){const t=await d(o);ut("gdpicture/setDynamicFontLoading",{baseUrl:o.split("/").slice(0,-1).join("/"),allowedFonts:t.availableFonts,v:1})}a&&ut("gdpicture/setFontSubstitutions",{fontSubstitutions:a})}toPdf(t,e,r,n,i){let o=tt;if(i&&"pdf"!==i&&Object.values(pt).includes(i)){X(Object.keys(pt).find(t=>pt[t].toLowerCase()===i.toLowerCase()).toLowerCase()),o+=`.${i}`}else if(n&&"application/pdf"!==n){const t=n.toLowerCase();X(t);const e=pt.hasOwnProperty(t)&&pt[t];e&&(o+=`.${e}`)}at.FS.writeFile(o,new Uint8Array(t),{canOwn:!0});const a={file:et,format:"pdf",conformance:e&&e in p?e:void 0,officeConversionSettings:dt(r)};try{return ut("gdpicture/process",{input:{file:o},output:a}),at.FS.readFile(et).buffer}finally{try{at.FS.unlink(et),at.FS.unlink(o)}catch(t){}}}toOffice(t,e){at.FS.writeFile(tt,new Uint8Array(t));const r=`/save.${e}`;try{return ut("gdpicture/process",{input:{file:tt},output:{file:r,format:e}}),at.FS.readFile(r).buffer}finally{try{at.FS.unlink(r),at.FS.unlink(tt)}catch(t){console.log(t.message)}}}async populateDocumentTemplate(t,e){at.FS.writeFile(rt,new Uint8Array(t));const{serializedData:r}=await y(e);at.FS.writeFile(it,r);try{return ut("gdpicture/process-office-template",{inputFile:rt,modelAndConfigFile:it,outputFile:nt}),at.FS.readFile(nt).buffer}finally{try{at.FS.unlink(nt),at.FS.unlink(it),at.FS.unlink(rt)}catch(t){console.log(t.message)}}}},ht=self;ht.global=ht,ht.module={},ht.addEventListener("message",async t=>{let e,r,{data:n}=t;try{const t=await mt[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}}ht.postMessage(e,r)})})();',"Worker",void 0,void 0)}},37737(t){function e(t){var e=function(){var t=self||window;if(void 0===t.trustedTypes)return null;try{return t.trustedTypes.createPolicy("nutrient-web-sdk#webpack-worker",{createScriptURL:function(t){return t}})}catch(e){return t.trustedTypes.defaultPolicy||null}}();return e?e.createScriptURL(t):t}t.exports=function(t,r,n,i){var o=self||window;try{try{var a,s="\n        // Trusted Types policy for worker context - use Webpack's policy naming\n        if (typeof trustedTypes !== 'undefined') {\n          try {\n            var workerPolicy = trustedTypes.createPolicy('nutrient-web-sdk#webpack-worker', {\n              createScriptURL: function(s) { return s; }\n            });\n            // Wrap importScripts to use Trusted Types\n            var originalImportScripts = importScripts;\n            importScripts = function() {\n              var args = Array.prototype.slice.call(arguments);\n              var trustedArgs = args.map(function(url) {\n                return workerPolicy.createScriptURL(url);\n              });\n              return originalImportScripts.apply(this, trustedArgs);\n            };\n          } catch (e) {\n            // Policy creation failed, continue without Trusted Types\n          }\n        }\n      "+t;try{a=new o.Blob([s])}catch(t){(a=new(o.BlobBuilder||o.WebKitBlobBuilder||o.MozBlobBuilder||o.MSBlobBuilder)).append(s),a=a.getBlob()}var u=o.URL||o.webkitURL,c=u.createObjectURL(a),f=e(c),l=new o[r](f,n);return u.revokeObjectURL(c),l}catch(i){var p=e("data:application/javascript,".concat(encodeURIComponent(t)));return new o[r](p,n)}}catch(t){if(!i)throw Error("Inline worker is not supported");var d=e(i);return new o[r](d,n)}}}}]);