UNPKG

@thumbmarkjs/thumbmarkjs

Version:

![GitHub package.json dynamic](https://img.shields.io/github/package-json/version/ilkkapeltola/thumbmarkjs) ![NPM Version](https://img.shields.io/npm/v/@thumbmarkjs/thumbmarkjs) ![NPM Downloads](https://img.shields.io/npm/dm/%40thumbmarkjs%2Fthumbmarkjs

3 lines (2 loc) 33.2 kB
"use strict";const e=2592e5,t="thumbmark",n="https://api.thumbmarkjs.com",r={exclude:[],include:[],stabilize:["private","iframe"],logging:!0,timeout:5e3,cache_api_call:!0,cache_lifetime_in_ms:0,performance:!1,experimental:!1,property_name_factory:e=>`${t}_${e}`};let o={...r};const i={private:[{exclude:["canvas"],browsers:["firefox","safari>=17","brave"]},{exclude:["audio"],browsers:["samsungbrowser","safari"]},{exclude:["fonts"],browsers:["firefox"]},{exclude:["audio.sampleHash","hardware.deviceMemory","header.acceptLanguage.q","system.hardwareConcurrency","plugins"],browsers:["brave"]},{exclude:["tls.extensions"],browsers:["firefox","chrome","safari"]},{exclude:["header.acceptLanguage"],browsers:["edge","chrome"]}],iframe:[{exclude:["system.applePayVersion","system.cookieEnabled"],browsers:["safari"]},{exclude:["permissions"]}],vpn:[{exclude:["ip"]}],always:[{exclude:["speech"],browsers:["brave","firefox"]}]},a="undefined"!=typeof window?window.OfflineAudioContext||window.webkitOfflineAudioContext:null;function s(e){let t=0;for(let n=0;n<e.length;++n)t+=Math.abs(e[n]);return t}function c(e,t,n){if(1===e.length)return e[0];if(3===e.length){const r=e[0].data,o=e[1].data,i=e[2].data,a=new Uint8ClampedArray(r.length);for(let e=0;e<r.length;e++){const t=r[e],n=o[e],s=i[e];a[e]=t===n||t===s?t:n===s?n:t}return new ImageData(a,t,n)}let r=[];for(let t=0;t<e[0].data.length;t++){let n=[];for(let r=0;r<e.length;r++)n.push(e[r].data[t]);r.push(l(n))}const o=new Uint8ClampedArray(r);return new ImageData(o,t,n)}function l(e){if(0===e.length)return 0;const t={};for(const n of e)t[n]=(t[n]||0)+1;let n=e[0];for(const e in t)t[e]>t[n]&&(n=parseInt(e,10));return n}function u(e){return e^=e>>>16,e=Math.imul(e,2246822507),e^=e>>>13,e=Math.imul(e,3266489909),(e^=e>>>16)>>>0}const m=new Uint32Array([597399067,2869860233,951274213,2716044179]);function d(e,t){return e<<t|e>>>32-t}function p(e,t=0){if(t=t?0|t:0,"string"==typeof e&&(e=function(e){if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e).buffer;const t=[];for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);r<128?t.push(r):r<2048?t.push(192|r>>6,128|63&r):r<55296||r>=57344?t.push(224|r>>12,128|r>>6&63,128|63&r):(n++,r=65536+((1023&r)<<10|1023&e.charCodeAt(n)),t.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|63&r))}return new Uint8Array(t).buffer}(e)),!(e instanceof ArrayBuffer))throw new TypeError("Expected key to be ArrayBuffer or string");const n=new Uint32Array([t,t,t,t]);!function(e,t){const n=e.byteLength/16|0,r=new Uint32Array(e,0,4*n);for(let e=0;e<n;e++){const n=r.subarray(4*e,4*(e+1));n[0]=Math.imul(n[0],m[0]),n[0]=d(n[0],15),n[0]=Math.imul(n[0],m[1]),t[0]=t[0]^n[0],t[0]=d(t[0],19),t[0]=t[0]+t[1],t[0]=Math.imul(t[0],5)+1444728091,n[1]=Math.imul(n[1],m[1]),n[1]=d(n[1],16),n[1]=Math.imul(n[1],m[2]),t[1]=t[1]^n[1],t[1]=d(t[1],17),t[1]=t[1]+t[2],t[1]=Math.imul(t[1],5)+197830471,n[2]=Math.imul(n[2],m[2]),n[2]=d(n[2],17),n[2]=Math.imul(n[2],m[3]),t[2]=t[2]^n[2],t[2]=d(t[2],15),t[2]=t[2]+t[3],t[2]=Math.imul(t[2],5)+2530024501,n[3]=Math.imul(n[3],m[3]),n[3]=d(n[3],18),n[3]=Math.imul(n[3],m[0]),t[3]=t[3]^n[3],t[3]=d(t[3],13),t[3]=t[3]+t[0],t[3]=Math.imul(t[3],5)+850148119}}(e,n),function(e,t){const n=e.byteLength/16|0,r=e.byteLength%16,o=new Uint32Array(4),i=new Uint8Array(e,16*n,r);switch(r){case 15:o[3]=o[3]^i[14]<<16;case 14:o[3]=o[3]^i[13]<<8;case 13:o[3]=o[3]^i[12],o[3]=Math.imul(o[3],m[3]),o[3]=d(o[3],18),o[3]=Math.imul(o[3],m[0]),t[3]=t[3]^o[3];case 12:o[2]=o[2]^i[11]<<24;case 11:o[2]=o[2]^i[10]<<16;case 10:o[2]=o[2]^i[9]<<8;case 9:o[2]=o[2]^i[8],o[2]=Math.imul(o[2],m[2]),o[2]=d(o[2],17),o[2]=Math.imul(o[2],m[3]),t[2]=t[2]^o[2];case 8:o[1]=o[1]^i[7]<<24;case 7:o[1]=o[1]^i[6]<<16;case 6:o[1]=o[1]^i[5]<<8;case 5:o[1]=o[1]^i[4],o[1]=Math.imul(o[1],m[1]),o[1]=d(o[1],16),o[1]=Math.imul(o[1],m[2]),t[1]=t[1]^o[1];case 4:o[0]=o[0]^i[3]<<24;case 3:o[0]=o[0]^i[2]<<16;case 2:o[0]=o[0]^i[1]<<8;case 1:o[0]=o[0]^i[0],o[0]=Math.imul(o[0],m[0]),o[0]=d(o[0],15),o[0]=Math.imul(o[0],m[1]),t[0]=t[0]^o[0]}}(e,n),function(e,t){t[0]=t[0]^e.byteLength,t[1]=t[1]^e.byteLength,t[2]=t[2]^e.byteLength,t[3]=t[3]^e.byteLength,t[0]=t[0]+t[1]|0,t[0]=t[0]+t[2]|0,t[0]=t[0]+t[3]|0,t[1]=t[1]+t[0]|0,t[2]=t[2]+t[0]|0,t[3]=t[3]+t[0]|0,t[0]=u(t[0]),t[1]=u(t[1]),t[2]=u(t[2]),t[3]=u(t[3]),t[0]=t[0]+t[1]|0,t[0]=t[0]+t[2]|0,t[0]=t[0]+t[3]|0,t[1]=t[1]+t[0]|0,t[2]=t[2]+t[0]|0,t[3]=t[3]+t[0]|0}(e,n);const r=new Uint8Array(n.buffer);return Array.from(r).map((e=>e.toString(16).padStart(2,"0"))).join("")}const f=280;async function h(e){for(var t;!document.body;)await g(50);const n=document.createElement("iframe");n.setAttribute("frameBorder","0");const r=n.style;r.setProperty("position","fixed"),r.setProperty("display","block","important"),r.setProperty("visibility","visible"),r.setProperty("border","0"),r.setProperty("opacity","0"),n.src="about:blank",document.body.appendChild(n);const o=n.contentDocument||(null===(t=n.contentWindow)||void 0===t?void 0:t.document);if(!o)throw new Error("Iframe document is not accessible");e({iframe:o}),setTimeout((()=>{document.body.removeChild(n)}),0)}function g(e,t){return new Promise((n=>setTimeout(n,e,t)))}const w=["Arial","Arial Black","Arial Narrow","Arial Rounded MT","Arimo","Archivo","Barlow","Bebas Neue","Bitter","Bookman","Calibri","Cabin","Candara","Century","Century Gothic","Comic Sans MS","Constantia","Courier","Courier New","Crimson Text","DM Mono","DM Sans","DM Serif Display","DM Serif Text","Dosis","Droid Sans","Exo","Fira Code","Fira Sans","Franklin Gothic Medium","Garamond","Geneva","Georgia","Gill Sans","Helvetica","Impact","Inconsolata","Indie Flower","Inter","Josefin Sans","Karla","Lato","Lexend","Lucida Bright","Lucida Console","Lucida Sans Unicode","Manrope","Merriweather","Merriweather Sans","Montserrat","Myriad","Noto Sans","Nunito","Nunito Sans","Open Sans","Optima","Orbitron","Oswald","Pacifico","Palatino","Perpetua","PT Sans","PT Serif","Poppins","Prompt","Public Sans","Quicksand","Rajdhani","Recursive","Roboto","Roboto Condensed","Rockwell","Rubik","Segoe Print","Segoe Script","Segoe UI","Sora","Source Sans Pro","Space Mono","Tahoma","Taviraj","Times","Times New Roman","Titillium Web","Trebuchet MS","Ubuntu","Varela Round","Verdana","Work Sans"],v=["monospace","sans-serif","serif"];function y(e,t){return e.font=`72px ${t}`,e.measureText("WwMmLli0Oo").width}function S(){var e;const t=document.createElement("canvas"),n=null!==(e=t.getContext("webgl"))&&void 0!==e?e:t.getContext("experimental-webgl");if(n&&"getParameter"in n)try{const e=(n.getParameter(n.VENDOR)||"").toString(),t=(n.getParameter(n.RENDERER)||"").toString();let r={vendor:e,renderer:t,version:(n.getParameter(n.VERSION)||"").toString(),shadingLanguageVersion:(n.getParameter(n.SHADING_LANGUAGE_VERSION)||"").toString()};if(!t.length||!e.length){const e=n.getExtension("WEBGL_debug_renderer_info");if(e){const t=(n.getParameter(e.UNMASKED_VENDOR_WEBGL)||"").toString(),o=(n.getParameter(e.UNMASKED_RENDERER_WEBGL)||"").toString();t&&(r.vendorUnmasked=t),o&&(r.rendererUnmasked=o)}}return r}catch(e){}return"undefined"}function b(){const e=new Float32Array(1),t=new Uint8Array(e.buffer);return e[0]=1/0,e[0]=e[0]-e[0],t[3]}const x=(e,t,n,r)=>{const o=(n-t)/r;let i=0;for(let n=0;n<r;n++){i+=e(t+(n+.5)*o)}return i*o};function C(e,t){const n={};return t.forEach((t=>{const r=function(e){if(0===e.length)return null;const t={};e.forEach((e=>{const n=String(e);t[n]=(t[n]||0)+1}));let n=e[0],r=1;return Object.keys(t).forEach((e=>{t[e]>r&&(n=e,r=t[e])})),n}(e.map((e=>t in e?e[t]:void 0)).filter((e=>void 0!==e)));r&&(n[t]=r)})),n}const M=["accelerometer","accessibility","accessibility-events","ambient-light-sensor","background-fetch","background-sync","bluetooth","camera","clipboard-read","clipboard-write","device-info","display-capture","gyroscope","geolocation","local-fonts","magnetometer","microphone","midi","nfc","notifications","payment-handler","persistent-storage","push","speaker","storage-access","top-level-storage-access","window-management","query"];const _=new Map;function P(){if("undefined"==typeof navigator)return{name:"unknown",version:"unknown"};const e=!!navigator.brave,t=(e?"B|":"N|")+navigator.userAgent,n=_.get(t);if(n)return n;const r=[{name:"Brave",detect:()=>e}];let o;for(const e of r)if(e.detect()){const n=E(navigator.userAgent);return o={name:e.name,version:n.version},_.set(t,o),o}return o=E(navigator.userAgent),_.set(t,o),o}function E(e){var t,n,r,o,i,a;const s=[/(?<name>SamsungBrowser)\/(?<version>\d+(?:\.\d+)+)/,/(?<name>EdgA|EdgiOS|Edg)\/(?<version>\d+(?:\.\d+)+)/,/(?<name>OPR|OPX)\/(?<version>\d+(?:\.\d+)+)/,/Opera[\s\/](?<version>\d+(?:\.\d+)+)/,/Opera Mini\/(?<version>\d+(?:\.\d+)+)/,/Opera Mobi\/(?<version>\d+(?:\.\d+)+)/,/(?<name>Vivaldi)\/(?<version>\d+(?:\.\d+)+)/,/(?<name>CriOS)\/(?<version>\d+(?:\.\d+)+)/,/(?<name>FxiOS)\/(?<version>\d+(?:\.\d+)+)/,/(?<name>Chrome|Chromium)\/(?<version>\d+(?:\.\d+)+)/,/(?<name>Firefox|Waterfox|Iceweasel|IceCat)\/(?<version>\d+(?:\.\d+)+)/,/Version\/(?<version1>[\d.]+).*Safari\/[\d.]+|(?<name>Safari)\/(?<version2>[\d.]+)/,/(?<name>MSIE|Trident|IEMobile).+?(?<version>\d+(?:\.\d+)+)/,/(?<name>[A-Za-z]+)\/(?<version>\d+(?:\.\d+)+)/],c={edg:"Edge",edga:"Edge",edgios:"Edge",opr:"Opera",opx:"Opera",crios:"Chrome",fxios:"Firefox",samsung:"SamsungBrowser",vivaldi:"Vivaldi"};for(const l of s){const s=e.match(l);if(s){let e=null===(t=s.groups)||void 0===t?void 0:t.name,u=(null===(n=s.groups)||void 0===n?void 0:n.version)||(null===(r=s.groups)||void 0===r?void 0:r.version1)||(null===(o=s.groups)||void 0===o?void 0:o.version2);if(e||!(null===(i=s.groups)||void 0===i?void 0:i.version1)&&!(null===(a=s.groups)||void 0===a?void 0:a.version2)||(e="Safari"),!e&&l.source.includes("Opera Mini")&&(e="Opera Mini"),!e&&l.source.includes("Opera Mobi")&&(e="Opera Mobi"),!e&&l.source.includes("Opera")&&(e="Opera"),!e&&s[1]&&(e=s[1]),!u&&s[2]&&(u=s[2]),e){return{name:c[e.toLowerCase()]||e,version:u||"unknown"}}}}return{name:"unknown",version:"unknown"}}function A(){if("undefined"==typeof navigator||!navigator.userAgent)return!1;const e=navigator.userAgent;return/Mobi|Android|iPhone|iPod|IEMobile|Opera Mini|Opera Mobi|webOS|BlackBerry|Windows Phone/i.test(e)&&!/iPad/i.test(e)}function T(){let e=[];const t={"prefers-contrast":["high","more","low","less","forced","no-preference"],"any-hover":["hover","none"],"any-pointer":["none","coarse","fine"],pointer:["none","coarse","fine"],hover:["hover","none"],update:["fast","slow"],"inverted-colors":["inverted","none"],"prefers-reduced-motion":["reduce","no-preference"],"prefers-reduced-transparency":["reduce","no-preference"],scripting:["none","initial-only","enabled"],"forced-colors":["active","none"]};return Object.keys(t).forEach((n=>{t[n].forEach((t=>{matchMedia(`(${n}: ${t})`).matches&&e.push(`${n}: ${t}`)}))})),e}function I(){if("https:"===window.location.protocol&&"function"==typeof window.ApplePaySession)try{const e=window.ApplePaySession.supportsVersion;for(let t=15;t>0;t--)if(e(t))return t}catch(e){return 0}return 0}const R="SamsungBrowser"!==P().name?1:3,k="Brave"!==P().name,O=137,D=(()=>{const e=new Float32Array(548),t=2*Math.PI/O;for(let n=0;n<O;n++){const r=n*t;e[4*n]=0,e[4*n+1]=0,e[4*n+2]=100*Math.cos(r),e[4*n+3]=50*Math.sin(r)}return e})();let F=null;function L(){try{if("undefined"==typeof document)return null;const e=document.createElement("canvas");e.width=200,e.height=100;const t=e.getContext("webgl");if(!t)return null;e.addEventListener("webglcontextlost",(e=>{e.preventDefault(),F=null}),{once:!0});const n=t.createShader(t.VERTEX_SHADER),r=t.createShader(t.FRAGMENT_SHADER);if(!n||!r)return null;if(t.shaderSource(n,"\n attribute vec2 position;\n void main() {\n gl_Position = vec4(position, 0.0, 1.0);\n }\n"),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS))return null;if(t.shaderSource(r,"\n precision mediump float;\n void main() {\n gl_FragColor = vec4(0.812, 0.195, 0.553, 0.921); // Set line color\n }\n"),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))return null;const o=t.createProgram();if(!o)return null;if(t.attachShader(o,n),t.attachShader(o,r),t.linkProgram(o),!t.getProgramParameter(o,t.LINK_STATUS))return null;const i=t.createBuffer();return i?(t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,D,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,null),{canvas:e,gl:t,program:o,buffer:i}):null}catch(e){return null}}function N(e){const t=new Set;return function e(n){if(n&&n.toJSON&&"function"==typeof n.toJSON&&(n=n.toJSON()),void 0===n)return;if("number"==typeof n)return isFinite(n)?""+n:"null";if("object"!=typeof n)return JSON.stringify(n);let r,o;if(Array.isArray(n)){for(o="[",r=0;r<n.length;r++)r&&(o+=","),o+=e(n[r])||"null";return o+"]"}if(null===n)return"null";if(t.has(n))throw new TypeError("Converting circular structure to JSON");t.add(n);const i=Object.keys(n).sort();for(o="",r=0;r<i.length;r++){const t=i[r],a=e(n[t]);a&&(o&&(o+=","),o+=JSON.stringify(t)+":"+a)}return t.delete(n),"{"+o+"}"}(e)||""}const U=["𝔄","𝔅","ℭ","𝔇","𝔈","𝔉","𝔸","𝔹","ℂ","𝔻","𝔼","𝔽"],B=["β","ψ","λ","ε","ζ","α","ξ","μ","ρ","φ","κ","τ","η","σ","ι","ω","γ","ν","χ","δ","θ","π","υ","ο"];function $(e,t){return`<math><mrow>${t}</mrow></math>`}function V(){let e="<mo>∏</mo>";return U.forEach(((t,n)=>{const r=2*n,o=B.slice(r,r+2);2===o.length&&(e+=`<mmultiscripts><mi>${t}</mi><none/><mi>${o[1]}</mi><mprescripts></mprescripts><mi>${o[0]}</mi><none/></mmultiscripts>`)})),$(0,`<munderover><mmultiscripts>${e}</mmultiscripts></munderover>`)}function j(){const e=[];return U.forEach(((t,n)=>{const r=2*n,o=B.slice(r,r+2);2===o.length&&e.push($(0,`<mmultiscripts><mi>${t}</mi><none/><mi>${o[1]}</mi><mprescripts></mprescripts><mi>${o[0]}</mi><none/></mmultiscripts>`))})),e}const H={audio:async function(){return a?async function(){return new Promise(((e,t)=>{try{const t=new a(1,5e3,44100),n=t.createBufferSource(),r=t.createOscillator();r.frequency.value=1e3;const o=t.createDynamicsCompressor();let i;o.threshold.value=-50,o.knee.value=40,o.ratio.value=12,o.attack.value=0,o.release.value=.2,r.connect(o),o.connect(t.destination),r.start(),t.oncomplete=r=>{i=r.renderedBuffer.getChannelData(0),e({sampleHash:s(i),maxChannels:t.destination.maxChannelCount,channelCountMode:n.channelCountMode})},t.startRendering()}catch(e){t(e)}}))}():null},canvas:async function(){return new Promise((e=>{const t=Array.from({length:3},(()=>function(){const e=document.createElement("canvas"),t=e.getContext("2d");if(!t)return null;e.width=f,e.height=20;const n=t.createLinearGradient(0,0,e.width,e.height);n.addColorStop(0,"red"),n.addColorStop(1/6,"orange"),n.addColorStop(2/6,"yellow"),n.addColorStop(.5,"green"),n.addColorStop(4/6,"blue"),n.addColorStop(5/6,"indigo"),n.addColorStop(1,"violet"),t.fillStyle=n,t.fillRect(0,0,e.width,e.height);const r="Random Text WMwmil10Oo";return t.font="23.123px Arial",t.fillStyle="black",t.fillText(r,-5,15),t.fillStyle="rgba(0, 0, 255, 0.5)",t.fillText(r,-3.3,17.7),t.beginPath(),t.moveTo(0,0),t.lineTo(2*e.width/7,e.height),t.strokeStyle="white",t.lineWidth=2,t.stroke(),t.getImageData(0,0,e.width,e.height)}())).filter((e=>null!==e));0!==t.length?e({commonPixelsHash:p(c(t,f,20).data.toString()).toString()}):e(null)}))},fonts:async function(e){return new Promise((e=>{try{h((async({iframe:t})=>{const n=t.createElement("canvas").getContext("2d");if(!n)return void e(null);const r=v.map((e=>y(n,e)));let o={};w.forEach((e=>{const t=y(n,e);r.includes(t)||(o[e]=t)})),e(o)}))}catch(t){e(null)}}))},hardware:function(){return new Promise(((e,t)=>{const n=void 0!==navigator.deviceMemory?navigator.deviceMemory:0,r=window.performance&&window.performance.memory?window.performance.memory:0;e({videocard:S(),architecture:b(),deviceMemory:n.toString()||"undefined",jsHeapSizeLimit:r.jsHeapSizeLimit||0})}))},locales:function(){return new Promise((e=>{e({languages:navigator.language,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone})}))},math:function(){return new Promise((e=>{e({acos:Math.acos(.5),asin:x(Math.asin,-1,1,97),cos:x(Math.cos,0,Math.PI,97),largeCos:Math.cos(1e20),largeSin:Math.sin(1e20),largeTan:Math.tan(1e20),sin:x(Math.sin,-Math.PI,Math.PI,97),tan:x(Math.tan,0,2*Math.PI,97)})}))},permissions:async function(e){const t=(null==e?void 0:e.permissions_to_check)||M;return C(await Promise.all(Array.from({length:3},(()=>async function(e){const t={};for(const n of e)try{const e=await navigator.permissions.query({name:n});t[n]=e.state.toString()}catch(e){}return t}(t)))),t)},plugins:async function(){const e=[];if(navigator.plugins)for(let t=0;t<navigator.plugins.length;t++){const n=navigator.plugins[t];e.push([n.name,n.filename,n.description].join("|"))}return new Promise((t=>{t({plugins:e})}))},screen:function(){return new Promise((e=>{if("undefined"==typeof matchMedia||"undefined"==typeof screen)return void e(null);const t={is_touchscreen:navigator.maxTouchPoints>0,maxTouchPoints:navigator.maxTouchPoints,colorDepth:screen.colorDepth,mediaMatches:T()};A()&&navigator.maxTouchPoints>0&&(t.resolution=function(){const e=window.screen.width,t=window.screen.height,n=Math.max(e,t).toString(),r=Math.min(e,t).toString();return`${n}x${r}`}()),e(t)}))},system:function(){return new Promise((e=>{const t=P();e({platform:window.navigator.platform,productSub:navigator.productSub,product:navigator.product,useragent:navigator.userAgent,hardwareConcurrency:navigator.hardwareConcurrency,browser:{name:t.name,version:t.version},mobile:A(),applePayVersion:I(),cookieEnabled:window.navigator.cookieEnabled})}))},webgl:async function(){const e=k?(F||(F=L()),F):L();if(!e)return{webgl:"unsupported"};try{const t=Array.from({length:R},(()=>function(e){const{canvas:t,gl:n,program:r,buffer:o}=e;try{n.useProgram(r),n.bindBuffer(n.ARRAY_BUFFER,o);const e=n.getAttribLocation(r,"position");n.enableVertexAttribArray(e),n.vertexAttribPointer(e,2,n.FLOAT,!1,0,0),n.viewport(0,0,t.width,t.height),n.clearColor(0,0,0,1),n.clear(n.COLOR_BUFFER_BIT),n.drawArrays(n.LINES,0,274);const i=new Uint8ClampedArray(t.width*t.height*4);return n.readPixels(0,0,t.width,t.height,n.RGBA,n.UNSIGNED_BYTE,i),new ImageData(i,t.width,t.height)}catch(e){return F=null,new ImageData(1,1)}finally{n.bindBuffer(n.ARRAY_BUFFER,null),n.useProgram(null),n.viewport(0,0,n.drawingBufferWidth,n.drawingBufferHeight),n.clearColor(0,0,0,0)}}(e)));return{commonPixelsHash:p(c(t,e.canvas.width,e.canvas.height).data.toString()).toString()}}catch(e){return{webgl:"unsupported"}}},webrtc:async function(e){return new Promise((e=>{let t;try{const n=window.RTCPeerConnection||window.webkitRTCPeerConnection||window.mozRTCPeerConnection;if(!n)return void e({supported:!1,error:"WebRTC not supported"});t=new n({iceCandidatePoolSize:1,iceServers:[]});const r=t;r.createDataChannel("");(async()=>{try{const t={offerToReceiveAudio:!0,offerToReceiveVideo:!0},n=await r.createOffer(t);await r.setLocalDescription(n);const o=n.sdp||"",i=[...new Set((o.match(/extmap:\d+ [^\n\r]+/g)||[]).map((e=>e.replace(/extmap:\d+ /,""))))].sort(),a=e=>{const t=o.match(new RegExp(`m=${e} [^\\s]+ [^\\s]+ ([^\\n\\r]+)`));return t?t[1].split(" "):[]},s=(e,t)=>t.map((t=>{const n=new RegExp(`(rtpmap|fmtp|rtcp-fb):${t} (.+)`,"g"),r=[...o.matchAll(n)];if(!r.length)return null;const i={};return r.forEach((t=>{const[n,r,o]=t,a=o.split("/");"rtpmap"===r?(i.mimeType=`${e}/${a[0]}`,i.clockRate=+a[1],"audio"===e&&(i.channels=+a[2]||1)):"rtcp-fb"===r?(i.feedbackSupport=i.feedbackSupport||[],i.feedbackSupport.push(o)):"fmtp"===r&&(i.sdpFmtpLine=o)})),i})).filter(Boolean),c=s("audio",a("audio")),l=s("video",a("video")),u={audio:{count:c.length,hash:p(N(c))},video:{count:l.length,hash:p(N(l))},extensionsHash:p(N(i))};r.close();const m={supported:!0,...u,candidateType:"host"};e({details:m,hash:p(N(m))})}catch(t){r.close(),e({supported:!0,error:`WebRTC offer failed: ${t.message}`})}})()}catch(n){null==t||t.close(),e({supported:!1,error:`WebRTC error: ${n.message}`})}}))},speech:async function(){return new Promise((e=>{try{if("undefined"==typeof window||!window.speechSynthesis||"function"!=typeof window.speechSynthesis.getVoices)return void e({supported:!1,error:"Speech Synthesis API not supported"});let t=!1,n=null;const r=r=>{if(!t){t=!0,n&&clearTimeout(n);try{const t=r.map((e=>{const t=e=>e.replace(/\\/g,"\\\\").replace(/,/g,"\\,");return[t(e.voiceURI||""),t(e.name||""),t(e.lang||""),e.localService?"1":"0",e.default?"1":"0"].join(",")}));t.sort();const n={voiceCount:r.length,voicesHash:p(N(t))};e({details:n,hash:p(N(n))})}catch(t){e({supported:!0,error:`Voice processing failed: ${t.message}`})}}},o=window.speechSynthesis.getVoices();if(o.length>0)return void r(o);n=setTimeout((()=>{const e=window.speechSynthesis.getVoices();r(e)}),800);const i=()=>{window.speechSynthesis.removeEventListener("voiceschanged",i);const e=window.speechSynthesis.getVoices();r(e)};window.speechSynthesis.addEventListener("voiceschanged",i)}catch(t){e({supported:!1,error:`Speech Synthesis error: ${t.message}`})}}))}},W={intl:async function(){if("undefined"==typeof Intl)return null;try{const e=new Date(Date.UTC(2024,0,15,12,30,45)),t={dateFullFormat:new Intl.DateTimeFormat("en-US",{dateStyle:"full",timeZone:"UTC"}).format(e),dateMediumFormat:new Intl.DateTimeFormat("en-US",{dateStyle:"medium",timeZone:"UTC"}).format(e),timeFormat:new Intl.DateTimeFormat("en-US",{timeStyle:"long",timeZone:"UTC"}).format(e),numberFormat:new Intl.NumberFormat("en-US").format(123456.789),currencyFormat:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(123456.789),percentFormat:new Intl.NumberFormat("en-US",{style:"percent"}).format(.456),nonLatinDate:new Intl.DateTimeFormat("ar-EG",{timeZone:"UTC"}).format(e),nonLatinNumber:new Intl.NumberFormat("zh-Hans-CN-u-nu-hanidec").format(123456.789)},n=Intl;return"function"==typeof n.ListFormat&&(t.listFormat=new n.ListFormat("en",{type:"conjunction"}).format(["a","b","c"])),"function"==typeof n.DisplayNames&&(t.displayNames=new n.DisplayNames("en",{type:"region"}).of("US")||""),{details:t,hash:p(N(t))}}catch(e){return null}},mathml:async function(){return new Promise((e=>{try{h((async({iframe:t})=>{try{if(!function(e){try{const t=e.createElement("math");t.innerHTML="<mrow><mi>x</mi></mrow>",t.style.position="absolute",t.style.visibility="hidden",e.body.appendChild(t);const n=t.getBoundingClientRect();return e.body.removeChild(t),n.width>0&&n.height>0}catch(e){return!1}}(t))return void e({supported:!1,error:"MathML not supported"});const n=[$("integral","<msubsup><mo>∫</mo><mi>a</mi><mi>b</mi></msubsup><mfrac><mrow><mi>f</mi><mo>(</mo><mi>x</mi><mo>)</mo></mrow><mrow><mi>g</mi><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mfrac><mi>dx</mi>"),$("fraction","<mfrac><mrow><mi>π</mi><mo>×</mo><msup><mi>r</mi><mn>2</mn></msup></mrow><mrow><mn>2</mn><mi>σ</mi></mrow></mfrac>"),$("matrix","<mo>[</mo><mtable><mtr><mtd><mi>α</mi></mtd><mtd><mi>β</mi></mtd></mtr><mtr><mtd><mi>γ</mi></mtd><mtd><mi>δ</mi></mtd></mtr></mtable><mo>]</mo>"),V(),...j()],r=[];let o="";n.forEach(((e,n)=>{const i=function(e,t){try{const n=t.createElement("math");n.innerHTML=e.replace(/<\/?math>/g,""),n.style.whiteSpace="nowrap",n.style.position="absolute",n.style.visibility="hidden",n.style.top="-9999px",t.body.appendChild(n);const r=n.getBoundingClientRect(),o=(t.defaultView||window).getComputedStyle(n),i={dimensions:{width:r.width,height:r.height},fontInfo:{fontFamily:o.fontFamily,fontSize:o.fontSize,fontWeight:o.fontWeight,fontStyle:o.fontStyle,lineHeight:o.lineHeight,fontVariant:o.fontVariant||"normal",fontStretch:o.fontStretch||"normal",fontSizeAdjust:o.fontSizeAdjust||"none",textRendering:o.textRendering||"auto",fontFeatureSettings:o.fontFeatureSettings||"normal",fontVariantNumeric:o.fontVariantNumeric||"normal",fontKerning:o.fontKerning||"auto"}};return t.body.removeChild(n),i}catch(e){return{error:e.message}}}(e,t);r.push({width:i.dimensions.width,height:i.dimensions.height}),0===n&&i.fontInfo&&(o=p(N(i.fontInfo)))}));const i={fontStyleHash:o,dimensions:r};e({details:i,hash:p(N(i))})}catch(t){e({supported:!1,error:`MathML error: ${t.message}`})}}))}catch(t){e({supported:!1,error:`MathML error: ${t.message}`})}}))},mediadevices:async function(){if("undefined"==typeof navigator||!navigator.mediaDevices||"function"!=typeof navigator.mediaDevices.enumerateDevices)return null;try{const e=await navigator.mediaDevices.enumerateDevices(),t={};for(const n of e)t[n.kind]=(t[n.kind]||0)+1;return{audioinput:t.audioinput||0,audiooutput:t.audiooutput||0,videoinput:t.videoinput||0}}catch(e){return null}}},z={},G={timeout:"true"};function J(){return"1.9.0"}function q(e,t){var n,r;let o=P();if("unknown"===o.name&&t){const e=null===(n=t.system)||void 0===n?void 0:n.browser;(null==e?void 0:e.name)&&(o={name:String(e.name),version:String(e.version||"unknown")})}const a=o.name.toLowerCase(),s=parseInt(o.version.split(".")[0]||"0",10),c=[...(null==e?void 0:e.exclude)||[]],l=[...new Set([...(null==e?void 0:e.stabilize)||[],"always"])];for(const e of l){const t=i[e];if(t)for(const e of t)"browsers"in e&&!(null===(r=e.browsers)||void 0===r?void 0:r.some((e=>{const t=e.match(/(.+?)(>=)(\d+)/);return t?a===t[1]&&s>=+t[3]:a===e})))||c.push(...e.exclude)}return c}function K(e,t){const n=q(t,e),r=(null==t?void 0:t.include)||[];return function e(t,o=""){const i={};for(const[a,s]of Object.entries(t)){const t=o?`${o}.${a}`:a;if("object"!=typeof s||Array.isArray(s)||null===s){const e=n.some((e=>t.startsWith(e))),o=r.some((e=>t.startsWith(e)));e&&!o||(i[a]=s)}else{const n=e(s,t);Object.keys(n).length>0&&(i[a]=n)}}return i}(e)}const Y="visitor_id";function Z(e){return e.storage_property_name?e.storage_property_name:e.property_name_factory(Y)}const X=`${t}_${Y}`;function Q(e,t){try{localStorage.setItem(Z(t),e)}catch(e){}}const ee="cache";function te(e){try{const t=localStorage.getItem(e.property_name_factory(ee)),n=JSON.parse(t);return n||{}}catch(e){}return{}}function ne(t){return t.cache_lifetime_in_ms>e?Date.now()+e:Date.now()+t.cache_lifetime_in_ms}class re extends Error{constructor(e){super(`HTTP error! status: ${e}`),this.status=e}}let oe=null,ie=null;async function ae(e,t,n,r){const o=await fetch(e,{method:"POST",headers:{"x-api-key":n.api_key,Authorization:"custom-authorized","Content-Type":"application/json"},body:JSON.stringify(t)});if(!o.ok)throw new re(o.status);const i=await o.json();return i.visitorId&&i.visitorId!==r&&Q(i.visitorId,n),ie=i,function(e,t){if(!e.cache_api_call||!e.cache_lifetime_in_ms)return;!function(e,t){const n={...te(e),...t};try{localStorage.setItem(e.property_name_factory(ee),JSON.stringify(n))}catch(e){}}(e,{apiResponseExpiry:ne(e),apiResponse:t})}(n,i),i}const se=(e,t)=>{if(e.cache_api_call){if(ie)return Promise.resolve(ie);const t=function(e){const t=te(e);if(t&&t.apiResponse&&t.apiResponseExpiry&&Date.now()<=t.apiResponseExpiry)return t.apiResponse;return}(e);if(t)return Promise.resolve(t);if(oe)return oe}const r=`${e.api_endpoint||n}/thumbmark`,o=function(e){try{const t=Z(e);let n=localStorage.getItem(t);return n||t===X||(n=localStorage.getItem(X),n&&Q(n,e)),n}catch(e){return null}}(e),i={components:t,options:e,clientHash:p(N(t)),version:"1.9.0"};if(o&&(i.visitorId=o),e.metadata){const t="function"==typeof e.metadata?e.metadata():e.metadata;if(t){("string"==typeof t?t.length:JSON.stringify(t).length)>1e3?console.error("ThumbmarkJS: Metadata exceeds 1000 characters. Skipping metadata."):i.metadata=t}}const a=e.timeout||5e3,s=async function(e,t,n,r){for(let o=0;o<3;o++){o>0&&await new Promise((e=>setTimeout(e,200*o)));try{return await ae(e,t,n,r)}catch(e){if(e instanceof re||2===o)throw e}}throw new Error("Unreachable")}(r,i,e,o).finally((()=>{oe=null})),c=new Promise((t=>{setTimeout((()=>{const n=te(e);t((null==n?void 0:n.apiResponse)||{info:{timed_out:!0},...o&&{visitorId:o}})}),a)}));return oe=Promise.race([s,c]),oe};async function ce(e,t={}){var o,i;if("undefined"==typeof document||"undefined"==typeof window)return{thumbmark:"",components:{},info:{},version:"1.9.0",error:[{type:"fatal",message:"Browser environment required"}]};try{const a={...r,...e},s=[],c=a.logging&&!sessionStorage.getItem("_tmjs_l")&&Math.random()<1e-4,l={...H,...z,...t},{elapsed:u,resolvedComponents:m,errors:d,pipelineTimings:f}=await le(l,a);s.push(...d);let h={},g={},w={};if(c||a.experimental){const{elapsed:e,resolvedComponents:t,errors:n,pipelineTimings:r}=await le(W,a);h=t,g=e,w=r,s.push(...n)}const v=a.api_key?se(a,m):null;let y=null;if(v)try{y=await v}catch(e){if(e instanceof re&&403===e.status)return{error:[{type:"api_unauthorized",message:"Invalid API key or quota exceeded"}],components:{},info:{},version:"1.9.0",thumbmark:""};s.push({type:e instanceof re?"api_error":"network_error",message:e instanceof Error?e.message:String(e)})}(null===(o=null==y?void 0:y.info)||void 0===o?void 0:o.timed_out)&&s.push({type:"api_timeout",message:"API request timed out"});const S=performance.now(),b=K((null==y?void 0:y.components)||{},a),x=performance.now()-S,C={...m,...b},M=(null==y?void 0:y.info)||{uniqueness:{score:"api only"}};let _,P=0,E=0;if(null==y?void 0:y.thumbmark)_=y.thumbmark;else{const e=performance.now(),t=N(C);P=performance.now()-e;const n=performance.now();_=p(t),E=performance.now()-n}const A="1.9.0";c&&async function(e,t,r,o={},i=[]){var a;const s=`${n}/log`,c={thumbmark:e,components:t,experimental:o,version:"1.9.0",options:r,path:null===(a=null===window||void 0===window?void 0:window.location)||void 0===a?void 0:a.pathname,...i.length>0&&{errors:i}};sessionStorage.setItem("_tmjs_l","1");try{await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)})}catch(e){}}(_,C,a,h,s).catch((()=>{}));const T=null!==(i=w["_pipeline.filter"])&&void 0!==i?i:0,I={"_pipeline.dispatch":f["_pipeline.dispatch"],"_pipeline.resolve":f["_pipeline.resolve"],"_pipeline.filter":f["_pipeline.filter"]+T+x,"_pipeline.stringify":P,"_pipeline.hash":E,"_pipeline.assembly":0},R={...u,...g,...f,...I},k=a.performance?{elapsed:R}:{},O=performance.now(),D={...(null==y?void 0:y.visitorId)&&{visitorId:y.visitorId},thumbmark:_,components:C,info:M,version:A,...k,...s.length>0&&{error:s},...Object.keys(h).length>0&&a.experimental&&{experimental:h},...(null==y?void 0:y.requestId)&&{requestId:y.requestId},...(null==y?void 0:y.metadata)&&{metadata:y.metadata}};return R["_pipeline.assembly"]=performance.now()-O,D}catch(e){return{thumbmark:"",components:{},info:{},version:"1.9.0",error:[{type:"fatal",message:e instanceof Error?e.message:String(e)}]}}}async function le(e,t){const n={...r,...t},o=q(n).filter((e=>!e.includes("."))),i=Object.entries(e).filter((([e])=>{var t;return!(null===(t=null==n?void 0:n.exclude)||void 0===t?void 0:t.includes(e))})).filter((([e])=>!o.includes(e))).filter((([e])=>{var t,r,o,i;return(null===(t=null==n?void 0:n.include)||void 0===t?void 0:t.some((e=>e.includes("."))))?null===(r=null==n?void 0:n.include)||void 0===r?void 0:r.some((t=>t.startsWith(e))):0===(null===(o=null==n?void 0:n.include)||void 0===o?void 0:o.length)||(null===(i=null==n?void 0:n.include)||void 0===i?void 0:i.includes(e))})),a=i.map((([e])=>e)),s={},c=performance.now(),l=i.map((([e,n])=>{const r=performance.now(),o=n(t);return s[`_dispatch.${e}`]=performance.now()-r,o})),u=performance.now()-c,m=performance.now(),d=await function(e,t,n){return Promise.all(e.map((e=>{const r=performance.now();let o;const i=e.then((e=>(void 0!==o&&clearTimeout(o),{value:e,elapsed:performance.now()-r}))).catch((e=>(void 0!==o&&clearTimeout(o),{value:n,elapsed:performance.now()-r,error:e instanceof Error?e.message:String(e)}))),a=new Promise((e=>{o=setTimeout((()=>{e({value:n,elapsed:performance.now()-r,error:"timeout"})}),t)}));return Promise.race([i,a])})))}(l,(null==n?void 0:n.timeout)||5e3,G),p=performance.now()-m,f={},h={},g=[];d.forEach(((e,t)=>{var n;const r=a[t];f[r]=null!==(n=e.elapsed)&&void 0!==n?n:0,"timeout"===e.error?g.push({type:"component_timeout",message:`Component '${r}' timed out`,component:r}):e.error&&g.push({type:"component_error",message:e.error,component:r}),null!=e.value&&(h[r]=e.value)}));const w=performance.now(),v=K(h,n),y={"_pipeline.dispatch":u,"_pipeline.resolve":p,"_pipeline.filter":performance.now()-w,...s};return{elapsed:f,resolvedComponents:v,errors:g,pipelineTimings:y}}exports.Thumbmark=class{constructor(e){this.options={...r,...e},this.customComponents={}}async get(e){return ce({...this.options,...e},this.customComponents)}getVersion(){return"1.9.0"}includeComponent(e,t){this.customComponents[e]=t}},exports.filterThumbmarkData=K,exports.getFingerprint=async function(e){try{const t=await ce(o);return e?{hash:t.thumbmark.toString(),data:t.components}:t.thumbmark.toString()}catch(e){throw e}},exports.getFingerprintData=async function(){return(await ce(o)).components},exports.getFingerprintPerformance=async function(){try{const{elapsed:e,resolvedComponents:t}=await le(H,o);return{...t,elapsed:e}}catch(e){throw e}},exports.getThumbmark=ce,exports.getVersion=J,exports.includeComponent=(e,t,n)=>{z[e]=t},exports.setOption=function(e,t){o[e]=t},exports.stabilizationExclusionRules=i,exports.stableStringify=N; //# sourceMappingURL=thumbmark.cjs.js.map