/*!
 * 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/
 */
"use strict";(globalThis.webpackChunkNutrientViewer=globalThis.webpackChunkNutrientViewer||[]).push([[567],{23948(t,e,n){n.d(e,{prepareUpload:()=>p});var u=n(44008),c=n(56741);const l=(0,c.wU)("Cgxjb21tb24ucHJvdG8SEG51dHJpZW50Lm1ldHJpY3Mi8gEKCEFueVZhbHVlEhYKDHN0cmluZ192YWx1ZRgBIAEoCUgAEhQKCmJvb2xfdmFsdWUYAiABKAhIABITCglpbnRfdmFsdWUYAyABKANIABIWCgxkb3VibGVfdmFsdWUYBCABKAFIABIzCgthcnJheV92YWx1ZRgFIAEoCzIcLm51dHJpZW50Lm1ldHJpY3MuQXJyYXlWYWx1ZUgAEjYKDGt2bGlzdF92YWx1ZRgGIAEoCzIeLm51dHJpZW50Lm1ldHJpY3MuS2V5VmFsdWVMaXN0SAASFQoLYnl0ZXNfdmFsdWUYByABKAxIAEIHCgV2YWx1ZSI4CgpBcnJheVZhbHVlEioKBnZhbHVlcxgBIAMoCzIaLm51dHJpZW50Lm1ldHJpY3MuQW55VmFsdWUiQgoIS2V5VmFsdWUSCwoDa2V5GAEgASgJEikKBXZhbHVlGAIgASgLMhoubnV0cmllbnQubWV0cmljcy5BbnlWYWx1ZSI6CgxLZXlWYWx1ZUxpc3QSKgoGdmFsdWVzGAEgAygLMhoubnV0cmllb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ldHJpY3NTZXRWYWx1ZXNIABIyCgphdHRyaWJ1dGVzGAUgASgLMh4ubnV0cmllbnQubWV0cmljcy5LZXlWYWx1ZUxpc3RCBwoFdmFsdWVCGFoWaW8ubnV0cmllbnQubWV0cmljcy9wYmIGcHJvdG8z",[l]),A=(0,c.Zk)(s,0),g=(0,c.Zk)(s,1),m=(0,c.Zk)(s,2);const b=(0,c.wU)("Cg1zZXJ2aWNlLnByb3RvEhBudXRyaWVudC5tZXRyaWNzIpgBChtFeHBvcnRNZXRyaWNzU2VydmljZVJlcXVlc3QSKAoGY2xpZW50GAEgASgLMhgubnV0cmllbnQubWV0cmljcy5DbGllbnQSNwoLZGF0YV9wb2ludHMYAiADKAsyIi5udXRyaWVudC5tZXRyaWNzLk1ldHJpY3NEYXRhUG9pbnQSDwoCaWQYAyABKAlIAIgBAUIFCgNfaWQigQIKHEV4cG9ydE1ldHJpY3NTZXJ2aWNlUmVzcG9uc2USHQoVcHJvY2Vzc2VkX2RhdGFfcG9pbnRzGAEgASgDEhwKFHJlamVjdGVkX2RhdGFfcG9pbnRzGAIgASgDEjMKJmxhc3RfcHJvY2Vzc2VkX2RhdGFfcG9pbnRfdGltZV91bml4X21zGAMgASgGSACIAQESGgoNZXJyb3JfbWVzc2FnZRgEIAEoCUgBiAEBEg8KAmlkGAUgASgJSAKIAQFCKQonX2xhc3RfcHJvY2Vzc2VkX2RhdGFfcG9pbnRfdGltZV91bml4X21zQhAKDl9lcnJvcl9tZXNzYWdlQgUKA19pZEIYWhZpby5udXRyaWVudC5tZXRyaWNzL3BiYgZwcm90bzM",[s,a]),W=(0,c.Zk)(b,0);async function p(t,e){if(0===e.length)return null;const n=function(t){const e=t.map(t=>({metric:t,sortedAttributes:Z(t.attributes)})),n=new Map;for(const{metric:t,sortedAttributes:u}of e){const e=u.map(t=>{let[e,n]=t;return`${e}=${n}`}).join(";"),c=`${t.name}|${e}|${t.timestamp}`;if(I(t)){const e=n.get(c);e&&"counter"===e.type?e.count+=1:n.set(c,{type:"counter",metric:t,count:1,sortedAttributes:u})}else if(y(t)){const e=n.get(c);e&&"unique"===e.type?e.values.add(t.value):n.set(c,{type:"unique",metric:t,values:new Set([t.value]),sortedAttributes:u})}}const u=[];for(const t of n.values())"counter"===t.type?u.push({...t.metric,count:t.count,sortedAttributes:t.sortedAttributes}):"unique"===t.type&&u.push({...t.metric,values:Array.from(t.values),sortedAttributes:t.sortedAttributes});return u}(e),c=[...n].sort((t,e)=>t.timestamp-e.timestamp),l=`${c[0].timestamp}-${function(){const t=new Uint8Array(4);return crypto.getRandomValues(t),Array.from(t).map(t=>t.toString(16).padStart(2,"0")).join("")}()}`,a=(0,u.vt)(W,{client:V(t.clientInfo),dataPoints:c.map(t=>function(t){let e;if(I(t))e={case:"counterValue",value:(0,u.vt)(A,{count:BigInt(t.count??1)})};else if(y(t)){const n=t.values??[t.value];e={case:"setValues",value:(0,u.vt)(g,{values:n})}}else e={case:void 0};const n=t.sortedAttributes??Z(t.attributes),c=n.length>0?(0,u.vt)(r,{values:n.map(t=>{let[e,n]=t;return(0,u.vt)(d,{key:e,value:(0,u.vt)(o,{value:{case:"stringValue",value:n}})})})}):void 0;return(0,u.vt)(m,{timeUnixMs:BigInt(t.timestamp),name:t.name,value:e,attributes:c})}(t))}),i=(0,u.Rm)(W,a),s=await async function(t,e){if("undefined"==typeof crypto||!crypto.subtle)throw new Error("Web Crypto API is not available.");try{const u=await crypto.subtle.importKey("raw",t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),c=await crypto.subtle.sign("HMAC",u,e);return n=c,Array.from(new Uint8Array(n)).map(t=>t.toString(16).padStart(2,"0")).join("")}catch(t){throw new Error(`Failed to sign request with Web Crypto API: ${t}`)}var n}(t.hmacSecret,i);return{bucketId:l,headers:{"Content-Type":"application/protobuf","Nutrient-Metrics-Signature":`sha256=${s}`},body:i,requestId:`bucketId=${l}|signature=${s}`}}function V(t){const e={};return void 0!==t.licenseId?e.licenseId=BigInt(t.licenseId):void 0!==t.demoKeyId?e.demoKeyId=BigInt(t.demoKeyId):e.tag=t.tag??Math.random().toString(36).substring(2,15),(0,u.vt)(i,{environment:t.environment,productId:BigInt(t.productId),productVersion:t.productVersion,...e})}function Z(t){return Object.keys(t).sort().map(e=>[e,t[e]])}function I(t){return"counter"===t.type}function y(t){return"unique"===t.type}}}]);