@dtect/security-sdk-js 0.0.18 → 0.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -11
- package/dist/index.mjs +1 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1 @@
|
|
|
1
|
-
"use strict";var Ne=Object.defineProperty;var Er=Object.getOwnPropertyDescriptor;var wr=Object.getOwnPropertyNames;var Ir=Object.prototype.hasOwnProperty;var vr=(e,t)=>{for(var r in t)Ne(e,r,{get:t[r],enumerable:!0})},Rr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of wr(t))!Ir.call(e,o)&&o!==r&&Ne(e,o,{get:()=>t[o],enumerable:!(n=Er(t,o))||n.enumerable});return e};var br=e=>Rr(Ne({},"__esModule",{value:!0}),e);var ho={};vr(ho,{LanguageCodes:()=>V,QualityQuestionsRespondentTypes:()=>j,SecurityAPIError:()=>fr,checkQualityQuestions:()=>Oe,default:()=>fo,getQualityQuestions:()=>Te,getSecurityResult:()=>Re,getSecurityToken:()=>be,init:()=>yr,isAIUsageDetected:()=>Ae});module.exports=br(ho);function Tr(e,t){return function(r,n){return Object.prototype.hasOwnProperty.call(r,n)}(e,t)?e[t]:void 0}function Or(e,t,r,n){let o=document,i="securitypolicyviolation",a,s=m=>{let u=new URL(e,location.href),{blockedURI:l}=m;l!==u.href&&l!==u.protocol.slice(0,-1)&&l!==u.origin||(a=m,c())};o.addEventListener(i,s);let c=()=>o.removeEventListener(i,s);return n?.then(c,c),Promise.resolve().then(t).then(m=>(c(),m),m=>new Promise(u=>{let l=new MessageChannel;l.port1.onmessage=()=>u(),l.port2.postMessage(null)}).then(()=>{if(c(),a)return r(a);throw m}))}function N(e){let t="";for(let r=0;r<e.length;++r)if(r>0){let n=e[r].toLowerCase();n!==e[r]?t+=` ${n}`:t+=e[r]}else t+=e[r].toUpperCase();return t}var Ar={default:"endpoint"},Dr={default:"tlsEndpoint"},Sr="Client timeout",_r="Network connection error",Pr="Network request aborted",xr="Response cannot be parsed",Me="Blocked by CSP",Le="The endpoint parameter is not a valid URL",kr="Handle on demand agent data error",Nr=N("WrongRegion"),Mr=N("SubscriptionNotActive"),Lr=N("UnsupportedVersion"),Cr=N("InstallationMethodRestricted"),Fr=N("HostnameRestricted"),Ur=N("IntegrationFailed"),Br=N("NetworkRestricted"),qr=N("InvalidProxyIntegrationSecret"),Kr=N("InvalidProxyIntegrationHeaders"),Gr=N("ProxyIntegrationSecretEnvironmentMismatch"),Ce="API key required",pt="API key not found",gt="API key expired",Vr="Request cannot be parsed",jr="Request failed",Wr="Request failed to process",Qr="Too many requests, rate limit exceeded",$r="Not available for this origin",zr="Not available with restricted header",Yr=Ce,Xr=pt,Jr=gt,Zr="3.12.0",oe="Failed to load the JS script of the agent",Fe="9319";function Hr(e,t){let r=[],[n,o]=function(s){let c=function(l){let d=[...l];return{current:()=>d[0],postpone(){let y=d.shift();y!==void 0&&d.push(y)},exclude(){d.shift()}}}(s),m=function(l,d){let y=0;return()=>Math.random()*Math.min(d,l*Math.pow(2,y++))}(100,3e3),u=new Set;return[c.current(),(l,d)=>{let y,E=d instanceof Error?d.message:"";if(E===Me||E===Le)c.exclude(),y=0;else if(E===Fe)c.exclude();else if(E===oe){let w=Date.now()-l.getTime()<50,p=c.current();p&&w&&!u.has(p)&&(u.add(p),y=0),c.postpone()}else c.postpone();let f=c.current();return f===void 0?void 0:[f,y??l.getTime()+m()-Date.now()]}]}(e),i;if(n===void 0)return Promise.reject(new TypeError("The list of script URL patterns is empty"));let a=s=>{let c=new Date,m=l=>r.push({url:s,startedAt:c,finishedAt:new Date,error:l}),u=t(s);return u.then(()=>m(),m),u.catch(l=>{if(i!=null||(i=l),r.length>=5)throw i;let d=o(c,l);if(!d)throw i;let[y,E]=d;return(f=E,new Promise(w=>setTimeout(w,f))).then(()=>a(y));var f})};return a(n).then(s=>[s,r])}var yt="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",en=yt;function tn(e){var t,r;let{picked:n,rest:o}=function(u,l){let d={},y={};for(let[E,f]of Object.entries(u))l.includes(E)?d[E]=f:y[E]=f;return{picked:d,rest:y}}(e,["scriptUrlPattern","token","apiKey"]),i=n.token,a=(t=n.apiKey)!==null&&t!==void 0?t:i,s=(r=Tr(e,"scriptUrlPattern"))!==null&&r!==void 0?r:yt,[c,m]=function(){let u=[],l=()=>{u.push({time:new Date,state:document.visibilityState})},d=function(y,E,f,w){return y.addEventListener(E,f,w),()=>y.removeEventListener(E,f,w)}(document,"visibilitychange",l);return l(),[u,d]}();return Promise.resolve().then(()=>{if(!a||typeof a!="string")throw new Error(Ce);let u=function(l,d){return(Array.isArray(l)?l:[l]).map(y=>function(E,f){let w=encodeURIComponent;return E.replace(/<[^<>]+>/g,p=>p==="<version>"?"3":p==="<apiKey>"?w(f):p==="<loaderVersion>"?w(Zr):p)}(String(y),d))}(s,a);return Hr(u,rn)}).catch(u=>{throw m(),function(l){return l instanceof Error&&l.message===Fe?new Error(oe):l}(u)}).then(([u,l])=>(m(),u.load({...o,ldi:{attempts:l,visibilityStates:c}})))}function rn(e){return Or(e,()=>function(t){return new Promise((r,n)=>{if(function(s){if(URL.prototype)try{return new URL(s,location.href),!1}catch(c){if(c instanceof Error&&c.name==="TypeError")return!0;throw c}}(t))throw new Error(Le);let o=document.createElement("script"),i=()=>{var s;return(s=o.parentNode)===null||s===void 0?void 0:s.removeChild(o)},a=document.head||document.getElementsByTagName("head")[0];o.onload=()=>{i(),r()},o.onerror=()=>{i(),n(new Error(oe))},o.async=!0,o.src=t,a.appendChild(o)})}(e),()=>{throw new Error(Me)}).then(nn)}function nn(){let e=window,t="__fpjs_p_l_b",r=e[t];if(function(n,o){var i;let a=(i=Object.getOwnPropertyDescriptor)===null||i===void 0?void 0:i.call(Object,n,o);a?.configurable?delete n[o]:a&&!a.writable||(n[o]=void 0)}(e,t),typeof r?.load!="function")throw new Error(Fe);return r}var G={load:tn,defaultScriptUrlPattern:en,ERROR_SCRIPT_LOAD_FAIL:oe,ERROR_API_KEY_EXPIRED:gt,ERROR_API_KEY_INVALID:pt,ERROR_API_KEY_MISSING:Ce,ERROR_BAD_REQUEST_FORMAT:Vr,ERROR_BAD_RESPONSE_FORMAT:xr,ERROR_CLIENT_TIMEOUT:Sr,ERROR_CSP_BLOCK:Me,ERROR_FORBIDDEN_ENDPOINT:Fr,ERROR_FORBIDDEN_HEADER:zr,ERROR_FORBIDDEN_ORIGIN:$r,ERROR_GENERAL_SERVER_FAILURE:jr,ERROR_HANDLE_AGENT_DATA:kr,ERROR_INSTALLATION_METHOD_RESTRICTED:Cr,ERROR_INTEGRATION_FAILURE:Ur,ERROR_INVALID_ENDPOINT:Le,ERROR_INVALID_PROXY_INTEGRATION_HEADERS:Kr,ERROR_INVALID_PROXY_INTEGRATION_SECRET:qr,ERROR_NETWORK_ABORT:Pr,ERROR_NETWORK_CONNECTION:_r,ERROR_NETWORK_RESTRICTED:Br,ERROR_PROXY_INTEGRATION_SECRET_ENVIRONMENT_MISMATCH:Gr,ERROR_RATE_LIMIT:Qr,ERROR_SERVER_TIMEOUT:Wr,ERROR_SUBSCRIPTION_NOT_ACTIVE:Mr,ERROR_TOKEN_EXPIRED:Jr,ERROR_TOKEN_INVALID:Xr,ERROR_TOKEN_MISSING:Yr,ERROR_UNSUPPORTED_VERSION:Lr,ERROR_WRONG_REGION:Nr,defaultEndpoint:Ar,defaultTlsEndpoint:Dr};var T=[];for(let e=0;e<256;++e)T.push((e+256).toString(16).slice(1));function Et(e,t=0){return(T[e[t+0]]+T[e[t+1]]+T[e[t+2]]+T[e[t+3]]+"-"+T[e[t+4]]+T[e[t+5]]+"-"+T[e[t+6]]+T[e[t+7]]+"-"+T[e[t+8]]+T[e[t+9]]+"-"+T[e[t+10]]+T[e[t+11]]+T[e[t+12]]+T[e[t+13]]+T[e[t+14]]+T[e[t+15]]).toLowerCase()}var Ue,on=new Uint8Array(16);function Be(){if(!Ue){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Ue=crypto.getRandomValues.bind(crypto)}return Ue(on)}var sn=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),qe={randomUUID:sn};function an(e,t,r){if(qe.randomUUID&&!t&&!e)return qe.randomUUID();e=e||{};let n=e.random??e.rng?.()??Be();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){if(r=r||0,r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let o=0;o<16;++o)t[r+o]=n[o];return t}return Et(n)}var X=an;var cn={UNAUTHORIZED:"Unauthorized"},un={EXPIRED:"EXPIRED_TOKEN",INVALID_API_KEY:"INVALID_API_KEY",MISSING_AUTHENTICATION_TOKEN:"MISSING_AUTHENTICATION_TOKEN"},wt={INTERNAL_SERVER_ERROR:"Internal Server Error during API Request",MISSING_CREDENTIALS:"Missing Public Client ID or Public API Key",MAINTENANCE_MODE:"API Under Maintenance",RATE_LIMIT_REACHED:"Too many requests. Rate limit exceeded"},It={SDK_INIT_ERROR:"Internal Server Error during SDK Initialization",DUPLICATE_INITIALIZATION:"Multiple SDK Initializations Detected",NOT_INITIALIZED:"SDK Not Initialized"},vt={INVALID_CREDENTIALS:"Invalid Public Client ID or Public API Key"},Rt={FAILED_TO_GET_SECURITY_RESULT:"Failed to Retrieve Security Result"},bt={FAILED_TO_GET_SECURITY_TOKEN:" Failed to Generate Security Token"},v={...cn,...un,...wt,...It,...vt,...Rt,...bt},Tt={...wt,...It,...vt,...Rt,...bt};var V=(p=>(p.AR="ar",p.BN="bn",p.DE="de",p.EN="en",p.ES="es",p.FR="fr",p.HI="hi",p.ID="id",p.IT="it",p.JA="ja",p.KO="ko",p.MS="ms",p.NL="nl",p.PT="pt",p.RU="ru",p.YU="yu",p.ZH="zh",p))(V||{}),j=(I=>(I.GeneralConsumer="general-consumer",I.HRManagerDirector="hr-manager-director",I.WebDeveloper="web-developer",I.SoftwareEngineer="software-engineer",I.ITDirector="it-director",I.BusinessAdministrator="business-administrator",I.AccountsPayableManager="accounts-payable-manager",I.Accountant="accountant",I.FinanceDirector="finance-director",I.SmallBusinessOwner="small-business-owner",I.GeneralContractor="general-contractor",I.MarketingManagerDirector="marketing-manager-director",I.ConsumerShopper="consumer-shopper",I.Travel="travel",I.Entertainment="entertainment",I.FinanceAndBanking="finance-and-banking",I.General="general",I.B2BWhiteCollar="b2b-white-collar",I.B2BBlueCollar="b2b-blue-collar",I.Lawyer="lawyer",I))(j||{});var W={exclude:[],include:[],stabilize:["private","iframe"],logging:!0,timeout:5e3,cache_api_call:!0,performance:!1,experimental:!1},Fo={...W},Ke={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"]}]};async function Ge(){return ln()}async function ln(){return new Promise((t,r)=>{try{let i=new(window.OfflineAudioContext||window.webkitOfflineAudioContext)(1,5e3,44100),a=i?.createBufferSource(),s=i.createOscillator();s.frequency.value=1e3;let c=i.createDynamicsCompressor();c.threshold.value=-50,c.knee.value=40,c.ratio.value=12,c.attack.value=0,c.release.value=.2,s.connect(c),c.connect(i.destination),s.start();let m;i.oncomplete=u=>{m=u.renderedBuffer.getChannelData(0),t({sampleHash:mn(m),maxChannels:i.destination.maxChannelCount,channelCountMode:a.channelCountMode})},i.startRendering()}catch(n){console.error("Error creating audio fingerprint:",n),r(n)}})}function mn(e){let t=0;for(let r=0;r<e.length;++r)t+=Math.abs(e[r]);return t}function ie(e,t,r){let n=[];for(let a=0;a<e[0].data.length;a++){let s=[];for(let c=0;c<e.length;c++)s.push(e[c].data[a]);n.push(dn(s))}let o=n,i=new Uint8ClampedArray(o);return new ImageData(i,t,r)}function dn(e){if(e.length===0)return 0;let t={};for(let n of e)t[n]=(t[n]||0)+1;let r=e[0];for(let n in t)t[n]>t[r]&&(r=parseInt(n,10));return r}function fn(e){return new TextEncoder().encode(e).buffer}function se(e){return e^=e>>>16,e=Math.imul(e,2246822507),e^=e>>>13,e=Math.imul(e,3266489909),e^=e>>>16,e>>>0}var A=new Uint32Array([597399067,2869860233,951274213,2716044179]);function x(e,t){return e<<t|e>>>32-t}function hn(e,t){let r=e.byteLength/16|0,n=new Uint32Array(e,0,r*4);for(let o=0;o<r;o++){let i=n.subarray(o*4,(o+1)*4);i[0]=Math.imul(i[0],A[0]),i[0]=x(i[0],15),i[0]=Math.imul(i[0],A[1]),t[0]=t[0]^i[0],t[0]=x(t[0],19),t[0]=t[0]+t[1],t[0]=Math.imul(t[0],5)+1444728091,i[1]=Math.imul(i[1],A[1]),i[1]=x(i[1],16),i[1]=Math.imul(i[1],A[2]),t[1]=t[1]^i[1],t[1]=x(t[1],17),t[1]=t[1]+t[2],t[1]=Math.imul(t[1],5)+197830471,i[2]=Math.imul(i[2],A[2]),i[2]=x(i[2],17),i[2]=Math.imul(i[2],A[3]),t[2]=t[2]^i[2],t[2]=x(t[2],15),t[2]=t[2]+t[3],t[2]=Math.imul(t[2],5)+2530024501,i[3]=Math.imul(i[3],A[3]),i[3]=x(i[3],18),i[3]=Math.imul(i[3],A[0]),t[3]=t[3]^i[3],t[3]=x(t[3],13),t[3]=t[3]+t[0],t[3]=Math.imul(t[3],5)+850148119}}function pn(e,t){let r=e.byteLength/16|0,n=e.byteLength%16,o=new Uint32Array(4),i=new Uint8Array(e,r*16,n);switch(n){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]<<0,o[3]=Math.imul(o[3],A[3]),o[3]=x(o[3],18),o[3]=Math.imul(o[3],A[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]<<0,o[2]=Math.imul(o[2],A[2]),o[2]=x(o[2],17),o[2]=Math.imul(o[2],A[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]<<0,o[1]=Math.imul(o[1],A[1]),o[1]=x(o[1],16),o[1]=Math.imul(o[1],A[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]<<0,o[0]=Math.imul(o[0],A[0]),o[0]=x(o[0],15),o[0]=Math.imul(o[0],A[1]),t[0]=t[0]^o[0]}}function gn(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]=se(t[0]),t[1]=se(t[1]),t[2]=se(t[2]),t[3]=se(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}function O(e,t=0){if(t=t?t|0:0,typeof e=="string"&&(e=fn(e)),!(e instanceof ArrayBuffer))throw new TypeError("Expected key to be ArrayBuffer or string");let r=new Uint32Array([t,t,t,t]);hn(e,r),pn(e,r),gn(e,r);let n=new Uint8Array(r.buffer);return Array.from(n).map(o=>o.toString(16).padStart(2,"0")).join("")}var yn=3,Ot=280,At=20;async function Ve(){return En()}function En(){return new Promise(e=>{let t=Array.from({length:yn},()=>wn()),r=ie(t,Ot,At);e({commonPixelsHash:O(r.data.toString()).toString()})})}function wn(){let e=document.createElement("canvas"),t=e.getContext("2d");if(!t)return new ImageData(1,1);e.width=Ot,e.height=At;let r=t.createLinearGradient(0,0,e.width,e.height);r.addColorStop(0,"red"),r.addColorStop(1/6,"orange"),r.addColorStop(2/6,"yellow"),r.addColorStop(3/6,"green"),r.addColorStop(4/6,"blue"),r.addColorStop(5/6,"indigo"),r.addColorStop(1,"violet"),t.fillStyle=r,t.fillRect(0,0,e.width,e.height);let n="Random Text WMwmil10Oo";return t.font="23.123px Arial",t.fillStyle="black",t.fillText(n,-5,15),t.fillStyle="rgba(0, 0, 255, 0.5)",t.fillText(n,-3.3,17.7),t.beginPath(),t.moveTo(0,0),t.lineTo(e.width*2/7,e.height),t.strokeStyle="white",t.lineWidth=2,t.stroke(),t.getImageData(0,0,e.width,e.height)}async function ae(e){for(;!document.body;)await In(50);let t=document.createElement("iframe");t.setAttribute("frameBorder","0");let r=t.style;r.setProperty("position","fixed"),r.setProperty("display","block","important"),r.setProperty("visibility","visible"),r.setProperty("border","0"),r.setProperty("opacity","0"),t.src="about:blank",document.body.appendChild(t);let n=t.contentDocument||t.contentWindow?.document;if(!n)throw new Error("Iframe document is not accessible");e({iframe:n}),setTimeout(()=>{document.body.removeChild(t)},0)}function In(e,t){return new Promise(r=>setTimeout(r,e,t))}var vn=["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"],Rn=["monospace","sans-serif","serif"];async function je(e){return bn()}function bn(){return new Promise((e,t)=>{try{ae(async({iframe:r})=>{let o=r.createElement("canvas").getContext("2d"),i=Rn.map(s=>Dt(o,s)),a={};vn.forEach(s=>{let c=Dt(o,s);i.includes(c)||(a[s]=c)}),e(a)})}catch{t({error:"unsupported"})}})}function Dt(e,t){if(!e)return null;let r="WwMmLli0Oo";return e.font=`72px ${t}`,e.measureText(r).width}function We(){return new Promise((e,t)=>{let r=navigator.deviceMemory!==void 0?navigator.deviceMemory:0,n=window.performance&&window.performance.memory?window.performance.memory:0;e({videocard:Tn(),architecture:On(),deviceMemory:r.toString()||"undefined",jsHeapSizeLimit:n.jsHeapSizeLimit||0})})}function Tn(){let e=document.createElement("canvas"),t=e.getContext("webgl")??e.getContext("experimental-webgl");if(t&&"getParameter"in t)try{let r=(t.getParameter(t.VENDOR)||"").toString(),n=(t.getParameter(t.RENDERER)||"").toString(),o={vendor:r,renderer:n,version:(t.getParameter(t.VERSION)||"").toString(),shadingLanguageVersion:(t.getParameter(t.SHADING_LANGUAGE_VERSION)||"").toString()};if(!n.length||!r.length){let i=t.getExtension("WEBGL_debug_renderer_info");if(i){let a=(t.getParameter(i.UNMASKED_VENDOR_WEBGL)||"").toString(),s=(t.getParameter(i.UNMASKED_RENDERER_WEBGL)||"").toString();a&&(o.vendorUnmasked=a),s&&(o.rendererUnmasked=s)}}return o}catch{}return"undefined"}function On(){let e=new Float32Array(1),t=new Uint8Array(e.buffer);return e[0]=1/0,e[0]=e[0]-e[0],t[3]}function Qe(){return new Promise(e=>{e({languages:An(),timezone:Dn()})})}function An(){let e=[];return navigator.language}function Dn(){return Intl.DateTimeFormat().resolvedOptions().timeZone}var ce=(e,t,r,n)=>{let o=(r-t)/n,i=0;for(let a=0;a<n;a++){let s=t+(a+.5)*o;i+=e(s)}return i*o};function $e(){return new Promise(e=>{e({acos:Math.acos(.5),asin:ce(Math.asin,-1,1,97),cos:ce(Math.cos,0,Math.PI,97),largeCos:Math.cos(1e20),largeSin:Math.sin(1e20),largeTan:Math.tan(1e20),sin:ce(Math.sin,-Math.PI,Math.PI,97),tan:ce(Math.tan,0,2*Math.PI,97)})})}function Sn(e){if(e.length===0)return null;let t={};e.forEach(o=>{let i=String(o);t[i]=(t[i]||0)+1});let r=e[0],n=1;return Object.keys(t).forEach(o=>{t[o]>n&&(r=o,n=t[o])}),r}function St(e,t){let r={};return t.forEach(n=>{let o=e.map(a=>n in a?a[n]:void 0).filter(a=>a!==void 0),i=Sn(o);i&&(r[n]=i)}),r}var _n=["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"];async function ze(e){let t=e?.permissions_to_check||_n,n=await Promise.all(Array.from({length:3},()=>Pn(t)));return St(n,t)}async function Pn(e){let t={};for(let r of e)try{let n=await navigator.permissions.query({name:r});t[r]=n.state.toString()}catch{}return t}async function Ye(){let e=[];if(navigator.plugins)for(let t=0;t<navigator.plugins.length;t++){let r=navigator.plugins[t];e.push([r.name,r.filename,r.description].join("|"))}return new Promise(t=>{t({plugins:e})})}function Q(){if(typeof navigator>"u")return{name:"unknown",version:"unknown"};let e=navigator.userAgent,t=[/(?<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>Brave)\/(?<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+)+)/],r={edg:"Edge",edga:"Edge",edgios:"Edge",opr:"Opera",opx:"Opera",crios:"Chrome",fxios:"Firefox",samsung:"SamsungBrowser",vivaldi:"Vivaldi",brave:"Brave"};for(let n of t){let o=e.match(n);if(o){let i=o.groups?.name,a=o.groups?.version||o.groups?.version1||o.groups?.version2;if(!i&&(o.groups?.version1||o.groups?.version2)&&(i="Safari"),!i&&n.source.includes("Opera Mini")&&(i="Opera Mini"),!i&&n.source.includes("Opera Mobi")&&(i="Opera Mobi"),!i&&n.source.includes("Opera")&&(i="Opera"),!i&&o[1]&&(i=o[1]),!a&&o[2]&&(a=o[2]),i)return{name:r[i.toLowerCase()]||i,version:a||"unknown"}}}return{name:"unknown",version:"unknown"}}function ue(){if(typeof navigator>"u"||!navigator.userAgent)return!1;let 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 Xe(){return new Promise(e=>{let t={is_touchscreen:navigator.maxTouchPoints>0,maxTouchPoints:navigator.maxTouchPoints,colorDepth:screen.colorDepth,mediaMatches:kn()};ue()&&navigator.maxTouchPoints>0&&(t.resolution=xn()),e(t)})}function xn(){let e=window.screen.width,t=window.screen.height,r=Math.max(e,t).toString(),n=Math.min(e,t).toString();return`${r}x${n}`}function kn(){let e=[],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(r=>{t[r].forEach(n=>{matchMedia(`(${r}: ${n})`).matches&&e.push(`${r}: ${n}`)})}),e}function Je(){return new Promise(e=>{let t=Q(),r=navigator.userAgent,n={platform:window.navigator.platform,productSub:navigator.productSub,product:navigator.product,useragent:navigator.userAgent,hardwareConcurrency:navigator.hardwareConcurrency,browser:{name:t.name,version:t.version},mobile:ue(),applePayVersion:Nn(),cookieEnabled:window.navigator.cookieEnabled};e(n)})}function Nn(){if(window.location.protocol==="https:"&&typeof window.ApplePaySession=="function")try{let e=window.ApplePaySession.supportsVersion;for(let t=15;t>0;t--)if(e(t))return t}catch{return 0}return 0}var Mn=Q().name!=="SamsungBrowser"?1:3,D,h=null;function Ln(){typeof document<"u"&&(D=document.createElement("canvas"),D.width=200,D.height=100,h=D.getContext("webgl"))}async function Ze(){Ln();try{if(!h)throw new Error("WebGL not supported");let e=Array.from({length:Mn},()=>Cn()),t=ie(e,D.width,D.height);return{commonPixelsHash:O(t.data.toString()).toString()}}catch{return{webgl:"unsupported"}}}function Cn(){try{if(!h)throw new Error("WebGL not supported");let e=`
|
|
2
|
-
attribute vec2 position;
|
|
3
|
-
void main() {
|
|
4
|
-
gl_Position = vec4(position, 0.0, 1.0);
|
|
5
|
-
}
|
|
6
|
-
`,t=`
|
|
7
|
-
precision mediump float;
|
|
8
|
-
void main() {
|
|
9
|
-
gl_FragColor = vec4(0.812, 0.195, 0.553, 0.921); // Set line color
|
|
10
|
-
}
|
|
11
|
-
`,r=h.createShader(h.VERTEX_SHADER),n=h.createShader(h.FRAGMENT_SHADER);if(!r||!n)throw new Error("Failed to create shaders");if(h.shaderSource(r,e),h.shaderSource(n,t),h.compileShader(r),!h.getShaderParameter(r,h.COMPILE_STATUS))throw new Error("Vertex shader compilation failed: "+h.getShaderInfoLog(r));if(h.compileShader(n),!h.getShaderParameter(n,h.COMPILE_STATUS))throw new Error("Fragment shader compilation failed: "+h.getShaderInfoLog(n));let o=h.createProgram();if(!o)throw new Error("Failed to create shader program");if(h.attachShader(o,r),h.attachShader(o,n),h.linkProgram(o),!h.getProgramParameter(o,h.LINK_STATUS))throw new Error("Shader program linking failed: "+h.getProgramInfoLog(o));h.useProgram(o);let i=137,a=new Float32Array(i*4),s=2*Math.PI/i;for(let d=0;d<i;d++){let y=d*s;a[d*4]=0,a[d*4+1]=0,a[d*4+2]=Math.cos(y)*(D.width/2),a[d*4+3]=Math.sin(y)*(D.height/2)}let c=h.createBuffer();h.bindBuffer(h.ARRAY_BUFFER,c),h.bufferData(h.ARRAY_BUFFER,a,h.STATIC_DRAW);let m=h.getAttribLocation(o,"position");h.enableVertexAttribArray(m),h.vertexAttribPointer(m,2,h.FLOAT,!1,0,0),h.viewport(0,0,D.width,D.height),h.clearColor(0,0,0,1),h.clear(h.COLOR_BUFFER_BIT),h.drawArrays(h.LINES,0,i*2);let u=new Uint8ClampedArray(D.width*D.height*4);return h.readPixels(0,0,D.width,D.height,h.RGBA,h.UNSIGNED_BYTE,u),new ImageData(u,D.width,D.height)}catch{return new ImageData(1,1)}finally{h&&(h.bindBuffer(h.ARRAY_BUFFER,null),h.useProgram(null),h.viewport(0,0,h.drawingBufferWidth,h.drawingBufferHeight),h.clearColor(0,0,0,0))}}function _(e){let t=[];return function r(n){if(n&&n.toJSON&&typeof n.toJSON=="function"&&(n=n.toJSON()),n===void 0)return;if(typeof n=="number")return isFinite(n)?""+n:"null";if(typeof n!="object")return JSON.stringify(n);let o,i;if(Array.isArray(n)){for(i="[",o=0;o<n.length;o++)o&&(i+=","),i+=r(n[o])||"null";return i+"]"}if(n===null)return"null";if(t.indexOf(n)!==-1)throw new TypeError("Converting circular structure to JSON");let a=t.push(n)-1,s=Object.keys(n).sort();for(i="",o=0;o<s.length;o++){let c=s[o],m=r(n[c]);m&&(i&&(i+=","),i+=JSON.stringify(c)+":"+m)}return t.splice(a,1),"{"+i+"}"}(e)||""}async function He(){return new Promise(e=>{try{let t=window.RTCPeerConnection||window.webkitRTCPeerConnection||window.mozRTCPeerConnection;if(!t){e({supported:!1,error:"WebRTC not supported"});return}let r={iceCandidatePoolSize:1,iceServers:[]},n=new t(r);n.createDataChannel(""),(async()=>{try{let i={offerToReceiveAudio:!0,offerToReceiveVideo:!0},a=await n.createOffer(i);await n.setLocalDescription(a);let s=a.sdp||"",c=[...new Set((s.match(/extmap:\d+ [^\n\r]+/g)||[]).map(f=>f.replace(/extmap:\d+ /,"")))].sort(),m=f=>{let w=s.match(new RegExp(`m=${f} [^\\s]+ [^\\s]+ ([^\\n\\r]+)`));return w?w[1].split(" "):[]},u=(f,w)=>w.map(p=>{let b=new RegExp(`(rtpmap|fmtp|rtcp-fb):${p} (.+)`,"g"),S=[...s.matchAll(b)];if(!S.length)return null;let I={};return S.forEach(_e=>{let[po,Pe,xe]=_e,ke=xe.split("/");Pe==="rtpmap"?(I.mimeType=`${f}/${ke[0]}`,I.clockRate=+ke[1],f==="audio"&&(I.channels=+ke[2]||1)):Pe==="rtcp-fb"?(I.feedbackSupport=I.feedbackSupport||[],I.feedbackSupport.push(xe)):Pe==="fmtp"&&(I.sdpFmtpLine=xe)}),I}).filter(Boolean),l=u("audio",m("audio")),d=u("video",m("video")),y={audio:{count:l.length,hash:O(_(l))},video:{count:d.length,hash:O(_(d))},extensionsHash:O(_(c))},E=await new Promise(f=>{let w=setTimeout(()=>{n.removeEventListener("icecandidate",p),n.close(),f({supported:!0,...y,timeout:!0})},3e3),p=b=>{let S=b.candidate;!S||!S.candidate||(clearTimeout(w),n.removeEventListener("icecandidate",p),n.close(),f({supported:!0,...y,candidateType:S.type||""}))};n.addEventListener("icecandidate",p)});e({details:E,hash:O(_(E))})}catch(i){n.close(),e({supported:!0,error:`WebRTC offer failed: ${i.message}`})}})()}catch(t){e({supported:!1,error:`WebRTC error: ${t.message}`})}})}var _t=["\u{1D504}","\u{1D505}","\u212D","\u{1D507}","\u{1D508}","\u{1D509}","\u{1D538}","\u{1D539}","\u2102","\u{1D53B}","\u{1D53C}","\u{1D53D}"],Pt=["\u03B2","\u03C8","\u03BB","\u03B5","\u03B6","\u03B1","\u03BE","\u03BC","\u03C1","\u03C6","\u03BA","\u03C4","\u03B7","\u03C3","\u03B9","\u03C9","\u03B3","\u03BD","\u03C7","\u03B4","\u03B8","\u03C0","\u03C5","\u03BF"];async function et(){return new Promise(e=>{try{ae(async({iframe:t})=>{try{if(!Fn(t)){e({supported:!1,error:"MathML not supported"});return}let r=[J("integral","<msubsup><mo>\u222B</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>"),J("fraction","<mfrac><mrow><mi>\u03C0</mi><mo>\xD7</mo><msup><mi>r</mi><mn>2</mn></msup></mrow><mrow><mn>2</mn><mi>\u03C3</mi></mrow></mfrac>"),J("matrix","<mo>[</mo><mtable><mtr><mtd><mi>\u03B1</mi></mtd><mtd><mi>\u03B2</mi></mtd></mtr><mtr><mtd><mi>\u03B3</mi></mtd><mtd><mi>\u03B4</mi></mtd></mtr></mtable><mo>]</mo>"),Un(),...Bn()],n=[],o="";r.forEach((a,s)=>{let c=qn(a,t);n.push({width:c.dimensions.width,height:c.dimensions.height}),s===0&&c.fontInfo&&(o=O(_(c.fontInfo)))});let i={fontStyleHash:o,dimensions:n};e({details:i,hash:O(_(i))})}catch(r){e({supported:!1,error:`MathML error: ${r.message}`})}})}catch(t){e({supported:!1,error:`MathML error: ${t.message}`})}})}function Fn(e){try{let t=e.createElement("math");t.innerHTML="<mrow><mi>x</mi></mrow>",t.style.position="absolute",t.style.visibility="hidden",e.body.appendChild(t);let r=t.getBoundingClientRect();return e.body.removeChild(t),r.width>0&&r.height>0}catch{return!1}}function J(e,t){return`<math><mrow>${t}</mrow></math>`}function Un(){let e="<mo>\u220F</mo>";return _t.forEach((t,r)=>{let n=r*2,o=Pt.slice(n,n+2);o.length===2&&(e+=`<mmultiscripts><mi>${t}</mi><none/><mi>${o[1]}</mi><mprescripts></mprescripts><mi>${o[0]}</mi><none/></mmultiscripts>`)}),J("complex_nested",`<munderover><mmultiscripts>${e}</mmultiscripts></munderover>`)}function Bn(){let e=[];return _t.forEach((t,r)=>{let n=r*2,o=Pt.slice(n,n+2);o.length===2&&e.push(J("combined",`<mmultiscripts><mi>${t}</mi><none/><mi>${o[1]}</mi><mprescripts></mprescripts><mi>${o[0]}</mi><none/></mmultiscripts>`))}),e}function qn(e,t){try{let r=t.createElement("math");r.innerHTML=e.replace(/<\/?math>/g,""),r.style.whiteSpace="nowrap",r.style.position="absolute",r.style.visibility="hidden",r.style.top="-9999px",t.body.appendChild(r);let n=r.getBoundingClientRect(),i=(t.defaultView||window).getComputedStyle(r),a={dimensions:{width:n.width,height:n.height},fontInfo:{fontFamily:i.fontFamily,fontSize:i.fontSize,fontWeight:i.fontWeight,fontStyle:i.fontStyle,lineHeight:i.lineHeight,fontVariant:i.fontVariant||"normal",fontStretch:i.fontStretch||"normal",fontSizeAdjust:i.fontSizeAdjust||"none",textRendering:i.textRendering||"auto",fontFeatureSettings:i.fontFeatureSettings||"normal",fontVariantNumeric:i.fontVariantNumeric||"normal",fontKerning:i.fontKerning||"auto"}};return t.body.removeChild(r),a}catch(r){return{error:r.message}}}var Kn=800;async function tt(){return new Promise(e=>{try{if(typeof window>"u"||!window.speechSynthesis||typeof window.speechSynthesis.getVoices!="function"){e({supported:!1,error:"Speech Synthesis API not supported"});return}let t=!1,r=null,n=a=>{if(!t){t=!0,r&&clearTimeout(r);try{let s=a.map(m=>{let u=d=>d.replace(/\\/g,"\\\\").replace(/,/g,"\\,");return[u(m.voiceURI||""),u(m.name||""),u(m.lang||""),m.localService?"1":"0",m.default?"1":"0"].join(",")});s.sort();let c={voiceCount:a.length,voicesHash:O(_(s))};e({details:c,hash:O(_(c))})}catch(s){e({supported:!0,error:`Voice processing failed: ${s.message}`})}}},o=window.speechSynthesis.getVoices();if(o.length>0){n(o);return}r=setTimeout(()=>{let a=window.speechSynthesis.getVoices();n(a)},Kn);let i=()=>{window.speechSynthesis.removeEventListener("voiceschanged",i);let a=window.speechSynthesis.getVoices();n(a)};window.speechSynthesis.addEventListener("voiceschanged",i)}catch(t){e({supported:!1,error:`Speech Synthesis error: ${t.message}`})}})}var xt={audio:Ge,canvas:Ve,fonts:je,hardware:We,locales:Qe,math:$e,permissions:ze,plugins:Ye,screen:Xe,system:Je,webgl:Ze},kt={webrtc:He,mathml:et,speech:tt},rt={},Nt={timeout:"true"},nt=(e,t,r)=>{rt[e]=t};function Gn(e,t){return new Promise(r=>{setTimeout(()=>r(t),e)})}function Mt(e,t,r){return Promise.all(e.map(n=>{let o=performance.now();return Promise.race([n.then(i=>({value:i,elapsed:performance.now()-o})),Gn(t,r).then(i=>({value:i,elapsed:performance.now()-o}))])}))}function le(e,t){let r=Q();if(r.name==="unknown"&&e.system&&typeof e.system=="object"&&!Array.isArray(e.system)){let l=e.system.browser;if(l&&typeof l=="object"&&!Array.isArray(l)){let d=l;r={name:d.name||"unknown",version:d.version||"unknown"}}}let n=r.name.toLowerCase(),o=r.version.split(".")[0]||"0",i=parseInt(o,10),a=[...t?.exclude||[]],s=t?.stabilize||[],c=t?.include||[];for(let u of s){let l=Ke[u];if(l)for(let d of l){let y=!("browsers"in d),E=!y&&d.browsers?.some(f=>{let w=f.match(/(.+?)(>=)(\d+)/);if(w){let[,p,,b]=w,S=parseInt(b,10);return n===p&&i>=S}return n===f});(y||E)&&a.push(...d.exclude)}}function m(u,l=""){let d={};for(let[y,E]of Object.entries(u)){let f=l?`${l}.${y}`:y;if(typeof E=="object"&&!Array.isArray(E)&&E!==null){let w=m(E,f);Object.keys(w).length>0&&(d[y]=w)}else{let w=a.some(b=>f.startsWith(b)),p=c.some(b=>f.startsWith(b));(!w||p)&&(d[y]=E)}}return d}return m(e)}async function ot(e){let t={...W,...e},r=t.logging&&!sessionStorage.getItem("_tmjs_l")&&Math.random()<1e-4,n={...xt,...rt},{elapsed:o,resolvedComponents:i}=await Lt(n,t),a={},s={};if(r||t.experimental){let{elapsed:w,resolvedComponents:p}=await Lt(kt,t);a=p,s=w}let c={...o,...s},m=t.performance?{elapsed:c}:{},u=le({},t),l={...i,...u},d={};return{thumbmark:O(_(l)),components:l,info:d,version:"",...m,...Object.keys(a).length>0&&t.experimental&&{experimental:a}}}async function Lt(e,t){let r={...W,...t},n=Object.entries(e).filter(([u])=>!r?.exclude?.includes(u)).filter(([u])=>r?.include?.some(l=>l.includes("."))?r?.include?.some(l=>l.startsWith(u)):r?.include?.length===0||r?.include?.includes(u)),o=n.map(([u])=>u),i=n.map(([u,l])=>l(t)),a=await Mt(i,r?.timeout||5e3,Nt),s={},c={};a.forEach((u,l)=>{u.value!=null&&(c[o[l]]=u.value,s[o[l]]=u.elapsed??0)});let m=le(c,r);return{elapsed:s,resolvedComponents:m}}var Z=class{options;constructor(t){this.options={...W,...t}}async get(t){let r={...this.options,...t};return ot(r)}getVersion(){return""}includeComponent(t,r){nt(t,r)}};var Vn=(e,t={})=>({"Content-Type":"application/json",...e?.accessToken&&{Authorization:`Bearer ${e?.accessToken}`},...t}),jn=async(e,t)=>{if(!e.ok){let r=await e.text();throw new Error(r)}return t==="file"?e.blob():t==="json"?e.json():t==="text"?e.text():null},Ct=async({url:e,auth:t,body:r,method:n="GET",headers:o={},responseType:i="json"})=>{let a={method:n,headers:Vn(t,o),...r?{body:r instanceof FormData?r:JSON.stringify(r)}:{}},s=await fetch(e,a);return jn(s,i)},it=e=>Ct({...e,method:"GET"}),me=e=>Ct({...e,method:"POST"});function Ft(e){let t=e?.qbc||!1,r=e?.mas||!1,n=e?.apd||!1,o=e?.scb||null,i=0,a=()=>{t=!1,r=!1,n=!1,o=void 0,i=0},s=()=>{let l=window?.getSelection()?.toString();l&&l.length>0&&(i=Date.now(),t=!0)},c=u=>{let l=u.clipboardData?.getData("text"),d=u.target instanceof HTMLInputElement||u.target instanceof HTMLTextAreaElement;l&&d&&(n=!0)},m=()=>{r=!0;let u=Date.now();if(i){let l=(u-i)/1e3;(o===void 0||l<o)&&(o=l)}};return document?.addEventListener("copy",s),document?.addEventListener("paste",c),window?.addEventListener("blur",m),{get qbc(){return t},get mas(){return r},get apd(){return n},get scb(){return o},reset:a,destroy(){document?.removeEventListener("copy",s),document?.removeEventListener("paste",c),window?.removeEventListener("blur",m)}}}var L=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var C=typeof window>"u"||"Deno"in globalThis;function P(){}function qt(e,t){return typeof e=="function"?e(t):e}function Kt(e){return typeof e=="number"&&e>=0&&e!==1/0}function Gt(e,t){return Math.max(e+(t||0)-Date.now(),0)}function at(e,t){return typeof e=="function"?e(t):e}function Vt(e,t){return typeof e=="function"?e(t):e}function ct(e,t){let{type:r="all",exact:n,fetchStatus:o,predicate:i,queryKey:a,stale:s}=e;if(a){if(n){if(t.queryHash!==H(a,t.options))return!1}else if(!z(t.queryKey,a))return!1}if(r!=="all"){let c=t.isActive();if(r==="active"&&!c||r==="inactive"&&c)return!1}return!(typeof s=="boolean"&&t.isStale()!==s||o&&o!==t.state.fetchStatus||i&&!i(t))}function ut(e,t){let{exact:r,status:n,predicate:o,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(r){if($(t.options.mutationKey)!==$(i))return!1}else if(!z(t.options.mutationKey,i))return!1}return!(n&&t.state.status!==n||o&&!o(t))}function H(e,t){return(t?.queryKeyHashFn||$)(e)}function $(e){return JSON.stringify(e,(t,r)=>st(r)?Object.keys(r).sort().reduce((n,o)=>(n[o]=r[o],n),{}):r)}function z(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(r=>!z(e[r],t[r])):!1}function jt(e,t){if(e===t)return e;let r=Ut(e)&&Ut(t);if(r||st(e)&&st(t)){let n=r?e:Object.keys(e),o=n.length,i=r?t:Object.keys(t),a=i.length,s=r?[]:{},c=0;for(let m=0;m<a;m++){let u=r?m:i[m];(!r&&n.includes(u)||r)&&e[u]===void 0&&t[u]===void 0?(s[u]=void 0,c++):(s[u]=jt(e[u],t[u]),s[u]===e[u]&&e[u]!==void 0&&c++)}return o===a&&c===o?e:s}return t}function Ut(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function st(e){if(!Bt(e))return!1;let t=e.constructor;if(t===void 0)return!0;let r=t.prototype;return!(!Bt(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Bt(e){return Object.prototype.toString.call(e)==="[object Object]"}function Wt(e){return new Promise(t=>{setTimeout(t,e)})}function Qt(e,t,r){return typeof r.structuralSharing=="function"?r.structuralSharing(e,t):r.structuralSharing!==!1?jt(e,t):t}function $t(e,t,r=0){let n=[...e,t];return r&&n.length>r?n.slice(1):n}function zt(e,t,r=0){let n=[t,...e];return r&&n.length>r?n.slice(0,-1):n}var ee=Symbol();function de(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===ee?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var Wn=class extends L{#e;#t;#r;constructor(){super(),this.#r=e=>{if(!C&&window.addEventListener){let t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},fe=new Wn;var Qn=class extends L{#e=!0;#t;#r;constructor(){super(),this.#r=e=>{if(!C&&window.addEventListener){let t=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(r=>{r(e)}))}isOnline(){return this.#e}},Y=new Qn;function Yt(){let e,t,r=new Promise((o,i)=>{e=o,t=i});r.status="pending",r.catch(()=>{});function n(o){Object.assign(r,o),delete r.resolve,delete r.reject}return r.resolve=o=>{n({status:"fulfilled",value:o}),e(o)},r.reject=o=>{n({status:"rejected",reason:o}),t(o)},r}function $n(e){return Math.min(1e3*2**e,3e4)}function lt(e){return(e??"online")==="online"?Y.isOnline():!0}var Xt=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function he(e){return e instanceof Xt}function pe(e){let t=!1,r=0,n=!1,o,i=Yt(),a=f=>{n||(d(new Xt(f)),e.abort?.())},s=()=>{t=!0},c=()=>{t=!1},m=()=>fe.isFocused()&&(e.networkMode==="always"||Y.isOnline())&&e.canRun(),u=()=>lt(e.networkMode)&&e.canRun(),l=f=>{n||(n=!0,e.onSuccess?.(f),o?.(),i.resolve(f))},d=f=>{n||(n=!0,e.onError?.(f),o?.(),i.reject(f))},y=()=>new Promise(f=>{o=w=>{(n||m())&&f(w)},e.onPause?.()}).then(()=>{o=void 0,n||e.onContinue?.()}),E=()=>{if(n)return;let f,w=r===0?e.initialPromise:void 0;try{f=w??e.fn()}catch(p){f=Promise.reject(p)}Promise.resolve(f).then(l).catch(p=>{if(n)return;let b=e.retry??(C?0:3),S=e.retryDelay??$n,I=typeof S=="function"?S(r,p):S,_e=b===!0||typeof b=="number"&&r<b||typeof b=="function"&&b(r,p);if(t||!_e){d(p);return}r++,e.onFail?.(r,p),Wt(I).then(()=>m()?void 0:y()).then(()=>{t?d(p):E()})})};return{promise:i,cancel:a,continue:()=>(o?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?E():y().then(E),i)}}function zn(){let e=[],t=0,r=s=>{s()},n=s=>{s()},o=s=>setTimeout(s,0),i=s=>{t?e.push(s):o(()=>{r(s)})},a=()=>{let s=e;e=[],s.length&&o(()=>{n(()=>{s.forEach(c=>{r(c)})})})};return{batch:s=>{let c;t++;try{c=s()}finally{t--,t||a()}return c},batchCalls:s=>(...c)=>{i(()=>{s(...c)})},schedule:i,setNotifyFunction:s=>{r=s},setBatchNotifyFunction:s=>{n=s},setScheduler:s=>{o=s}}}var R=zn();var ge=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Kt(this.gcTime)&&(this.#e=setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(C?1/0:5*60*1e3))}clearGcTimeout(){this.#e&&(clearTimeout(this.#e),this.#e=void 0)}};var Jt=class extends ge{#e;#t;#r;#n;#s;#i;constructor(e){super(),this.#i=!1,this.#s=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.cache,this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=Xn(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#n?.promise}setOptions(e){this.options={...this.#s,...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#r.remove(this)}setData(e,t){let r=Qt(this.state.data,e,this.options);return this.#o({data:r,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),r}setState(e,t){this.#o({type:"setState",state:e,setStateOptions:t})}cancel(e){let t=this.#n?.promise;return this.#n?.cancel(e),t?t.then(P).catch(P):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(e=>Vt(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===ee||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(e=0){return this.state.isInvalidated||this.state.data===void 0||!Gt(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#n?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#n?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#n&&(this.#i?this.#n.cancel({revert:!0}):this.#n.cancelRetry()),this.scheduleGc()),this.#r.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#o({type:"invalidate"})}fetch(e,t){if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#n)return this.#n.continueRetry(),this.#n.promise}if(e&&this.setOptions(e),!this.options.queryFn){let s=this.observers.find(c=>c.options.queryFn);s&&this.setOptions(s.options)}let r=new AbortController,n=s=>{Object.defineProperty(s,"signal",{enumerable:!0,get:()=>(this.#i=!0,r.signal)})},o=()=>{let s=de(this.options,t),c={queryKey:this.queryKey,meta:this.meta};return n(c),this.#i=!1,this.options.persister?this.options.persister(s,c,this):s(c)},i={fetchOptions:t,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:o};n(i),this.options.behavior?.onFetch(i,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==i.fetchOptions?.meta)&&this.#o({type:"fetch",meta:i.fetchOptions?.meta});let a=s=>{he(s)&&s.silent||this.#o({type:"error",error:s}),he(s)||(this.#r.config.onError?.(s,this),this.#r.config.onSettled?.(this.state.data,s,this)),this.scheduleGc()};return this.#n=pe({initialPromise:t?.initialPromise,fn:i.fetchFn,abort:r.abort.bind(r),onSuccess:s=>{if(s===void 0){a(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(s)}catch(c){a(c);return}this.#r.config.onSuccess?.(s,this),this.#r.config.onSettled?.(s,this.state.error,this),this.scheduleGc()},onError:a,onFail:(s,c)=>{this.#o({type:"failed",failureCount:s,error:c})},onPause:()=>{this.#o({type:"pause"})},onContinue:()=>{this.#o({type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0}),this.#n.start()}#o(e){let t=r=>{switch(e.type){case"failed":return{...r,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...Yn(r.data,this.options),fetchMeta:e.meta??null};case"success":return{...r,data:e.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":let n=e.error;return he(n)&&n.revert&&this.#t?{...this.#t,fetchStatus:"idle"}:{...r,error:n,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...e.state}}};this.state=t(this.state),R.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),this.#r.notify({query:this,type:"updated",action:e})})}};function Yn(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:lt(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Xn(e){let t=typeof e.initialData=="function"?e.initialData():e.initialData,r=t!==void 0,n=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var te=class extends L{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,r){let n=t.queryKey,o=t.queryHash??H(n,t),i=this.get(o);return i||(i=new Jt({cache:this,queryKey:n,queryHash:o,options:e.defaultQueryOptions(t),state:r,defaultOptions:e.getQueryDefaults(n)}),this.add(i)),i}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){R.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(r=>ct(t,r))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(r=>ct(e,r)):t}notify(e){R.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){R.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){R.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}};var Zt=class extends ge{#e;#t;#r;constructor(e){super(),this.mutationId=e.mutationId,this.#t=e.mutationCache,this.#e=[],this.state=e.state||Jn(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#e.includes(e)||(this.#e.push(e),this.clearGcTimeout(),this.#t.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#e=this.#e.filter(t=>t!==e),this.scheduleGc(),this.#t.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#e.length||(this.state.status==="pending"?this.scheduleGc():this.#t.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){this.#r=pe({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(n,o)=>{this.#n({type:"failed",failureCount:n,error:o})},onPause:()=>{this.#n({type:"pause"})},onContinue:()=>{this.#n({type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#t.canRun(this)});let t=this.state.status==="pending",r=!this.#r.canStart();try{if(!t){this.#n({type:"pending",variables:e,isPaused:r}),await this.#t.config.onMutate?.(e,this);let o=await this.options.onMutate?.(e);o!==this.state.context&&this.#n({type:"pending",context:o,variables:e,isPaused:r})}let n=await this.#r.start();return await this.#t.config.onSuccess?.(n,e,this.state.context,this),await this.options.onSuccess?.(n,e,this.state.context),await this.#t.config.onSettled?.(n,null,this.state.variables,this.state.context,this),await this.options.onSettled?.(n,null,e,this.state.context),this.#n({type:"success",data:n}),n}catch(n){try{throw await this.#t.config.onError?.(n,e,this.state.context,this),await this.options.onError?.(n,e,this.state.context),await this.#t.config.onSettled?.(void 0,n,this.state.variables,this.state.context,this),await this.options.onSettled?.(void 0,n,e,this.state.context),n}finally{this.#n({type:"error",error:n})}}finally{this.#t.runNext(this)}}#n(e){let t=r=>{switch(e.type){case"failed":return{...r,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...r,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:e.error,failureCount:r.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),R.batch(()=>{this.#e.forEach(r=>{r.onMutationUpdate(e)}),this.#t.notify({mutation:this,type:"updated",action:e})})}};function Jn(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var re=class extends L{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#r=0}#e;#t;#r;build(e,t,r){let n=new Zt({mutationCache:this,mutationId:++this.#r,options:e.defaultMutationOptions(t),state:r});return this.add(n),n}add(e){this.#e.add(e);let t=ye(e);if(typeof t=="string"){let r=this.#t.get(t);r?r.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){let t=ye(e);if(typeof t=="string"){let r=this.#t.get(t);if(r)if(r.length>1){let n=r.indexOf(e);n!==-1&&r.splice(n,1)}else r[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){let t=ye(e);if(typeof t=="string"){let n=this.#t.get(t)?.find(o=>o.state.status==="pending");return!n||n===e}else return!0}runNext(e){let t=ye(e);return typeof t=="string"?this.#t.get(t)?.find(n=>n!==e&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){R.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(r=>ut(t,r))}findAll(e={}){return this.getAll().filter(t=>ut(e,t))}notify(e){R.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(t=>t.state.isPaused);return R.batch(()=>Promise.all(e.map(t=>t.continue().catch(P))))}};function ye(e){return e.options.scope?.id}function mt(e){return{onFetch:(t,r)=>{let n=t.options,o=t.fetchOptions?.meta?.fetchMore?.direction,i=t.state.data?.pages||[],a=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,m=async()=>{let u=!1,l=E=>{Object.defineProperty(E,"signal",{enumerable:!0,get:()=>(t.signal.aborted?u=!0:t.signal.addEventListener("abort",()=>{u=!0}),t.signal)})},d=de(t.options,t.fetchOptions),y=async(E,f,w)=>{if(u)return Promise.reject();if(f==null&&E.pages.length)return Promise.resolve(E);let p={queryKey:t.queryKey,pageParam:f,direction:w?"backward":"forward",meta:t.options.meta};l(p);let b=await d(p),{maxPages:S}=t.options,I=w?zt:$t;return{pages:I(E.pages,b,S),pageParams:I(E.pageParams,f,S)}};if(o&&i.length){let E=o==="backward",f=E?Zn:Ht,w={pages:i,pageParams:a},p=f(n,w);s=await y(w,p,E)}else{let E=e??i.length;do{let f=c===0?a[0]??n.initialPageParam:Ht(n,s);if(c>0&&f==null)break;s=await y(s,f),c++}while(c<E)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(m,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r):t.fetchFn=m}}}function Ht(e,{pages:t,pageParams:r}){let n=t.length-1;return t.length>0?e.getNextPageParam(t[n],t,r[n],r):void 0}function Zn(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}var dt=class{#e;#t;#r;#n;#s;#i;#o;#a;constructor(e={}){this.#e=e.queryCache||new te,this.#t=e.mutationCache||new re,this.#r=e.defaultOptions||{},this.#n=new Map,this.#s=new Map,this.#i=0}mount(){this.#i++,this.#i===1&&(this.#o=fe.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=Y.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#i--,this.#i===0&&(this.#o?.(),this.#o=void 0,this.#a?.(),this.#a=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),r=this.#e.build(this,t),n=r.state.data;return n===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(at(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(n))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:r})=>{let n=r.data;return[t,n]})}setQueryData(e,t,r){let n=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(n.queryHash)?.state.data,a=qt(t,i);if(a!==void 0)return this.#e.build(this,n).setData(a,{...r,manual:!0})}setQueriesData(e,t,r){return R.batch(()=>this.#e.findAll(e).map(({queryKey:n})=>[n,this.setQueryData(n,t,r)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;R.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r)})})}resetQueries(e,t){let r=this.#e,n={type:"active",...e};return R.batch(()=>(r.findAll(e).forEach(o=>{o.reset()}),this.refetchQueries(n,t)))}cancelQueries(e,t={}){let r={revert:!0,...t},n=R.batch(()=>this.#e.findAll(e).map(o=>o.cancel(r)));return Promise.all(n).then(P).catch(P)}invalidateQueries(e,t={}){return R.batch(()=>{if(this.#e.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none")return Promise.resolve();let r={...e,type:e?.refetchType??e?.type??"active"};return this.refetchQueries(r,t)})}refetchQueries(e,t={}){let r={...t,cancelRefetch:t.cancelRefetch??!0},n=R.batch(()=>this.#e.findAll(e).filter(o=>!o.isDisabled()).map(o=>{let i=o.fetch(void 0,r);return r.throwOnError||(i=i.catch(P)),o.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(n).then(P)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let r=this.#e.build(this,t);return r.isStaleByTime(at(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(P).catch(P)}fetchInfiniteQuery(e){return e.behavior=mt(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(P).catch(P)}ensureInfiniteQueryData(e){return e.behavior=mt(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Y.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#r}setDefaultOptions(e){this.#r=e}setQueryDefaults(e,t){this.#n.set($(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#n.values()],r={};return t.forEach(n=>{z(e,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(e,t){this.#s.set($(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#s.values()],r={};return t.forEach(n=>{z(e,n.mutationKey)&&(r={...r,...n.defaultOptions})}),r}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#r.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=H(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===ee&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#r.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}};var Hn=new dt({defaultOptions:{queries:{staleTime:3e4}},queryCache:new te({onError:(e,t)=>{}}),mutationCache:new re}),er=Hn;var eo=[{name:"lowCpuCores",weight:1,async check(){let e=navigator.hardwareConcurrency||0,t=e>0&&e<=2;return{value:e,triggered:t}}},{name:"lowDeviceMemory",weight:1,async check(){let e=navigator.deviceMemory||0,t=e>0&&e<=4;return{value:e,triggered:t}}},{name:"platformMismatch",weight:1,async check(){let e=navigator.userAgent||"",t=navigator.platform||"",r=e.includes("Mac")&&t.includes("Linux")||e.includes("Win")&&t.includes("Mac")||t===""||t==="Unknown";return{value:t,triggered:r}}},{name:"webglSoftwareRenderer",weight:2,async check(){let e=null,t=null,r=!1;try{let n=document.createElement("canvas"),o=n.getContext("webgl")||n.getContext("experimental-webgl");if(o){let i=o.getExtension("WEBGL_debug_renderer_info");if(i){e=o.getParameter(i.UNMASKED_VENDOR_WEBGL)||"",t=o.getParameter(i.UNMASKED_RENDERER_WEBGL)||"";let a=t.toLowerCase(),s=e.toLowerCase();r=a.includes("swiftshader")||a.includes("llvmpipe")||a.includes("softwar")||a.includes("basic render")||a.includes("vmware")||a.includes("virtualbox")||s.includes("vmware")||s.includes("parallels")}}}catch{}return{value:{vendor:e,renderer:t},triggered:r}}},{name:"missingWebGPUAdapter",weight:2,async check(){if(!("gpu"in navigator))return{value:"no WebGPU",triggered:!0};try{let e=await navigator.gpu.requestAdapter();return{value:e?"adapter-present":"adapter-null",triggered:!e}}catch{return{value:"adapter-error",triggered:!0}}}},{name:"reducedTimerPrecision",weight:1,async check(){let e=performance.now();await new Promise(n=>setTimeout(n,50));let t=performance.now()-e,r=t<30||t>80;return{value:t.toFixed(2),triggered:r}}},{name:"timerJitter",weight:1,async check(){let e=[];for(let n=0;n<10;n++){let o=performance.now();await new Promise(a=>setTimeout(a,10));let i=performance.now();e.push(i-o)}let t=Math.sqrt(e.map(n=>(n-10)**2).reduce((n,o)=>n+o)/e.length),r=t>5;return{value:t.toFixed(3),triggered:r}}},{name:"audioFingerprint",weight:1,async check(){try{let e=new(window.OfflineAudioContext||window.webkitOfflineAudioContext)(1,44100,44100),t=e.createOscillator();t.frequency.value=440,t.connect(e.destination),t.start(0);let n=(await e.startRendering()).getChannelData(0).reduce((i,a)=>i+Math.abs(a),0),o=n<100;return{value:n,triggered:o}}catch{return{value:"audio-error",triggered:!0}}}},{name:"canvasEntropy",weight:1,async check(){try{let e=document.createElement("canvas"),t=e.getContext("2d");t.textBaseline="top",t.font="14px 'Arial'",t.fillText("VM CHECK",2,2);let n=[...e.toDataURL()].reduce((i,a)=>(i+a.charCodeAt(0))%9999999,0);return{value:n,triggered:n===0||n===999999}}catch{return{value:"canvas-error",triggered:!0}}}},{name:"windowSizeWeird",weight:1,async check(){let e=window.innerWidth/window.innerHeight,t=e===1.333||e===1.6;return{value:e.toFixed(2),triggered:t}}},{name:"touchMismatch",weight:1,async check(){let e="ontouchstart"in window,t=navigator.maxTouchPoints||0;return{value:{hasTouch:e,maxTouch:t},triggered:e&&t===0}}},{name:"batteryVirtualized",weight:1,async check(){if(!navigator.getBattery)return{value:"no API",triggered:!0};try{let e=await navigator.getBattery(),t=e.chargingTime===0&&e.dischargingTime===1/0;return{value:{chargingTime:e.chargingTime,dischargingTime:e.dischargingTime},triggered:t}}catch{return{value:"battery-error",triggered:!0}}}},{name:"permissionsWeird",weight:1,async check(){try{let e=await navigator.permissions.query({name:"camera"}),t=e.state==="prompt";return{value:e.state,triggered:t}}catch{return{value:"perm-error",triggered:!0}}}},{name:"noMediaDevices",weight:1,async check(){try{let e=await navigator.mediaDevices.enumerateDevices(),t=e.length===0;return{value:e.length,triggered:t}}catch{return{value:"media-error",triggered:!0}}}},{name:"virtualizedMediaDevices",weight:1,async check(){try{let e=await navigator.mediaDevices.enumerateDevices(),t=e.some(r=>r.label.toLowerCase().includes("virtual"));return{value:e.map(r=>r.label),triggered:t}}catch{return{value:"media-error",triggered:!0}}}},{name:"webrtcIpPattern",weight:2,async check(){return new Promise(e=>{let t=new RTCPeerConnection({iceServers:[]});t.createDataChannel("x"),t.onicecandidate=r=>{if(!r||!r.candidate){e({value:"no candidate",triggered:!0});return}let n=r.candidate.candidate.toLowerCase(),o=n.includes("10.0.2.")||n.includes("172.16.")||n.includes("192.168.56.");e({value:n,triggered:o})},t.createOffer().then(r=>t.setLocalDescription(r))})}},{name:"gpuAccelerationDisabled",weight:2,async check(){let t=document.createElement("canvas").getContext("webgl");return{value:!!t,triggered:!t}}},{name:"noWebGL2",weight:1,async check(){let e=document.createElement("canvas").getContext("webgl2");return{value:!!e,triggered:!e}}},{name:"lowStorageQuota",weight:1,async check(){try{let e=await navigator.storage.estimate(),t=e.quota<500*1024*1024;return{value:e.quota,triggered:t}}catch{return{value:"storage-error",triggered:!0}}}},{name:"lowEntropy",weight:1,async check(){let e=Object.keys(navigator).length+Object.keys(screen).length+Object.keys(window).length,t=e<200;return{value:e,triggered:t}}},{name:"noLanguages",weight:1,async check(){let e=navigator.languages||[];return{value:e,triggered:e.length===0}}},{name:"uaEntropyLow",weight:1,async check(){let e=navigator.userAgent,t=e.length<30;return{value:e,triggered:t}}},{name:"weirdDPI",weight:1,async check(){let e=window.devicePixelRatio;return{value:e,triggered:e===1}}}];async function tr({threshold:e=6}={}){let t={},r=0;for(let n of eo){let o=await n.check();t[n.name]=o,o.triggered&&(r+=n.weight)}return{isLikelyVM:r>=e,score:r,threshold:e,signals:t}}var to=[{name:"hookedFunctionToString",weight:2,async check(){let e=Function.prototype.toString.toString(),t=Function.prototype.toString+"";return{value:{native:e,current:t},triggered:e!==t}}},{name:"navigatorProxyTrap",weight:2,async check(){let e=!1;try{let t=Object.getOwnPropertyDescriptor(window,"navigator");t&&t.get&&t.get.toString()?.includes("[native code]")===!1&&(e=!0)}catch{}return{value:"navigator getter",triggered:e}}},{name:"uaMismatch",weight:2,async check(){let e=navigator.userAgent||"",t="";try{let n=await navigator.userAgentData?.getHighEntropyValues?.(["platform","brands"]);t=JSON.stringify(n)}catch{}let r=e?.includes("Mac")&&t?.includes("Windows")||e?.includes("Win")&&t?.includes("Mac")||t&&t.length>0&&!e;return{value:{ua:e,brandInfo:t},triggered:r}}},{name:"timezoneLocaleMismatch",weight:1,async check(){let e=Intl.DateTimeFormat().resolvedOptions().timeZone,t=navigator.language||"",r=t.startsWith("en")&&e==="Asia/Shanghai"||t.startsWith("zh")&&e==="America/New_York"||e===void 0;return{value:{tz:e,lang:t},triggered:r}}},{name:"canvasNoise",weight:2,async check(){let e=()=>{let o=document.createElement("canvas"),i=o.getContext("2d");return i.textBaseline="top",i.font="14px Arial",i.fillText("anti-detect-check",2,2),o.toDataURL()},t=e(),r=e();return{value:{a:t,b:r},triggered:t!==r}}},{name:"webglNoise",weight:2,async check(){try{let t=document.createElement("canvas").getContext("webgl");if(!t)return{value:"no-webgl",triggered:!0};let r=t.getExtension("WEBGL_debug_renderer_info");if(!r)return{value:"no-debug-extension",triggered:!1};let n=t.getParameter(r.UNMASKED_VENDOR_WEBGL),o=t.getParameter(r.UNMASKED_RENDERER_WEBGL),i=n===""||o===""||n?.includes(" ")===!1||o?.includes(" ")===!1;return{value:{v:n,r:o},triggered:i}}catch{return{value:"gl-error",triggered:!0}}}},{name:"webdriverFlag",weight:3,async check(){let e=navigator.webdriver===!0;return{value:navigator.webdriver,triggered:e}}},{name:"perfectEventTiming",weight:1,async check(){let e=performance.now();return{value:e,triggered:e%1===0}}},{name:"serviceWorkerBlocked",weight:1,async check(){let e=!("serviceWorker"in navigator);return{value:e,triggered:e}}},{name:"smallQuota",weight:2,async check(){try{let e=await navigator.storage.estimate(),t=e.quota<50*1024*1024;return{value:e.quota,triggered:t}}catch{return{value:"quota-error",triggered:!0}}}},{name:"indexedDbBlocked",weight:2,async check(){try{let e=indexedDB.open("tamper-check");return await new Promise(t=>{e.onerror=()=>t({value:"error",triggered:!0}),e.onsuccess=()=>t({value:"ok",triggered:!1})})}catch{return{value:"throw",triggered:!0}}}},{name:"screenDprMismatch",weight:1,async check(){let e=window.screen.width,t=window.screen.height,r=window.devicePixelRatio,n=e===1920&&r===1&&t===1080||r%1!==0&&r%1!==.5;return{value:{w:e,h:t,dpr:r},triggered:n}}},{name:"missingCommonFonts",weight:1,async check(){return{value:"skipped",triggered:!1}}},{name:"noMediaDevices",weight:1,async check(){try{let e=await navigator.mediaDevices.enumerateDevices();return{value:e.length,triggered:e.length===0}}catch{return{value:"error",triggered:!0}}}},{name:"languagesEmpty",weight:1,async check(){let e=navigator.languages||[];return{value:e,triggered:e.length===0}}},{name:"pluginMismatch",weight:1,async check(){try{let e=navigator.plugins.length;return{value:e,triggered:e===0}}catch{return{value:"error",triggered:!0}}}},{name:"devtoolsDetected",weight:2,async check(){return new Promise(async e=>{let t={viewportBreakpoint:!1,debuggerLatency:!1,consoleSpeed:!1},r=160,n=window.outerWidth-window.innerWidth,o=window.outerHeight-window.innerHeight;(n>r||o>r)&&(t.viewportBreakpoint=!0);function i(c=200){let m=performance.now();debugger;return performance.now()-m>c}t.debuggerLatency=i();async function a(c=50){return new Promise(m=>{let u=performance.now();console.log("%c ","font-size:3000px");let l=performance.now();m(l-u>c)})}t.consoleSpeed=await a();let s=Object.values(t).some(Boolean);setTimeout(()=>{e({value:s,triggered:s})},50)})}},{name:"knownAntiDetectBrowser",weight:5,async check(){let e=navigator.userAgent.toLowerCase(),r=["incogniton","multilogin","morelogin","adspect","kameleo","goLogin"].some(n=>e?.includes(n));return{value:e,triggered:r}}}];async function rr({threshold:e=5}={}){let t={},r=0;for(let o of to){let i=await o.check();t[o.name]=i,i.triggered&&(r+=o.weight)}let n=Math.min(1,r/15);return{result:n>=.5||t.knownAntiDetectBrowser?.triggered,anomalyScore:n,antiDetectBrowser:t.knownAntiDetectBrowser?.triggered||!1,signals:t}}function ro(){let e=0;try{0 .toFixed(-1)}catch(t){e=t.message.length}return e}function no(){let e=navigator.userAgent,t=ro();return t===44||t===43?"Safari":t===51?"Chrome":t===25?"Firefox":navigator.msSaveBlob!==void 0?"MSIE":e.match(/Chrome/)?navigator.brave!==void 0?"Brave":e.includes("Edg")?"Edge":e.includes("OPR")?"Opera":"Chrome":"Unknown"}var oo=[{name:"safari_currentStorageTest",weight:2,browser:"Safari",async check(){if(typeof navigator.storage?.getDirectory!="function")return{triggered:!1,value:"unsupported"};try{return await navigator.storage.getDirectory(),{triggered:!1,value:"ok"}}catch(e){let t=e?.message??String(e);return{triggered:t.includes("unknown transient reason"),value:t}}}},{name:"safari13to18_indexedDbBlobTest",weight:2,browser:"Safari",async check(){return await new Promise(e=>{let t=String(Math.random()),r=indexedDB.open(t,1);r.onupgradeneeded=n=>{let o=n.target.result;try{o.createObjectStore("t",{autoIncrement:!0}).put(new Blob),e({triggered:!1,value:"ok"})}catch(i){let a=i?.message??String(i);e({triggered:a.includes("are not yet supported"),value:a})}finally{o.close(),indexedDB.deleteDatabase(t)}},r.onerror=()=>e({triggered:!1,value:"idb-error"})})}},{name:"safari_oldWebkitTest",weight:1,browser:"Safari",async check(){let e=window.openDatabase,t=window.localStorage;try{e(null,null,null,null)}catch{return{triggered:!0,value:"openDatabase denied"}}try{t.setItem("test","1"),t.removeItem("test")}catch{return{triggered:!0,value:"localStorage denied"}}return{triggered:!1,value:"ok"}}},{name:"chrome_storageQuotaPrivateTest",weight:2,browser:"Chrome",async check(){return await new Promise((e,t)=>{let n=window?.performance?.memory?.jsHeapSizeLimit??1073741824;navigator.webkitTemporaryStorage.queryUsageAndQuota((o,i)=>{let a=Math.round(i/1048576),s=Math.round(n/(1024*1024))*2;e({triggered:a<s,value:{quotaMB:a,limitMB:s}})},o=>t(o))})}},{name:"chrome_oldFileSystemTest",weight:1,browser:"Chrome",async check(){let e=window.webkitRequestFileSystem;return e?await new Promise(t=>e(0,1,()=>t({triggered:!1,value:"ok"}),()=>t({triggered:!0,value:"denied"}))):{triggered:!1,value:"unsupported"}}},{name:"firefox_storageDirectoryTest",weight:2,browser:"Firefox",async check(){if(typeof navigator.storage?.getDirectory!="function")return{triggered:!1,value:"unsupported"};try{return await navigator.storage.getDirectory(),{triggered:!1,value:"ok"}}catch(e){let t=e?.message??String(e);return{triggered:t.includes("Security error"),value:t}}}},{name:"firefox_indexedDbInvalidStateTest",weight:1,browser:"Firefox",async check(){return await new Promise(e=>{let t=indexedDB.open("inPrivate");t.onerror=()=>{e({triggered:t.error?.name==="InvalidStateError",value:t.error?.name})},t.onsuccess=()=>{indexedDB.deleteDatabase("inPrivate"),e({triggered:!1,value:"ok"})}})}},{name:"msie_indexedDbMissing",weight:2,browser:"MSIE",async check(){return{triggered:window.indexedDB===void 0,value:"msie-idb-check"}}}];async function nr(){let e=no(),t={},r=0;for(let n of oo){if(n.browser!==e)continue;let o=await n.check();t[n.name]=o,o.triggered&&(r+=n.weight)}return{isPrivate:r>0,browserName:e,score:r,signals:t}}typeof window<"u"&&(window.detectIncognito=nr);var or=nr;var ir="dtect_security_sdk_state",sr=typeof window<"u",ar={isLoading:!1,token:"",visitorId:"",projectId:"",questionData:null,clientData:null,aiCheckData:null,tokens:null},Ee={state:{...ar},securityKeys:{behaviorKey:"",automationKey:""}};function cr(){if(!sr)return Ee;try{let e=sessionStorage.getItem(ir);if(!e)return Ee;let t=JSON.parse(e);return t.expiresAt&&t.expiresAt<Date.now()?Ee:{state:{...ar,...t.state},securityKeys:t.securityKeys||{behaviorKey:"",automationKey:""}}}catch{return Ee}}function U(e){if(sr)try{let t=Date.now()+864e5,r={...e,expiresAt:t};sessionStorage.setItem(ir,JSON.stringify(r))}catch{}}function ur(e){return e.token||X()}var we,B="https://api.dtect.io/security",Ie=`${B}/client/check`,F="",K="",mr="0.0.18",dr,lr,io="20000000-aaaa-bbbb-cccc-000000000002",ve;var{state:g,securityKeys:{automationKey:k,behaviorKey:M}}=cr(),fr=Tt,ne;async function so({clientId:e,apiKey:t,endpoint:r}){if(De({automationKey:k,behaviorKey:M}))return{automationKey:k,behaviorKey:M};let n=await er.fetchQuery({queryKey:["getClientConfig",e,t],queryFn:()=>it({url:`${r}/client/config`,headers:{"client-id":F,"x-api-key":K}})});if(!De(n))throw new Error;return k=n.automationKey,M=n.behaviorKey,U({state:g,securityKeys:n}),n}function ft(e){if(e instanceof Error){if(e?.message?.includes("maintenance_mode"))throw new Error(v.MAINTENANCE_MODE);if(e?.message?.includes("rate-limited"))throw new Error(v.RATE_LIMIT_REACHED);switch(e?.message){case G.ERROR_RATE_LIMIT:throw new Error(v.RATE_LIMIT_REACHED);default:throw new Error(v.INTERNAL_SERVER_ERROR)}}throw new Error(v.FAILED_TO_GET_SECURITY_TOKEN)}function q(){if(gr(g)&&De({automationKey:k,behaviorKey:M}))return!0;let e=Se(),t=document.querySelector("#dtect-h-captcha");return!!we&&!!(t||e)}function hr(){return!!(F&&K)}function ao(){return new Promise(e=>{let t=()=>{window?.hcaptcha?e():requestAnimationFrame(t)};t()})}var Se=()=>window?.location?.href?.includes("localhost")||window?.location?.href?.includes("file:///");async function co({behaviorKey:e}){if(we=await G.load({apiKey:e,endpoint:["https://fp.dtect.io",G.defaultEndpoint],scriptUrlPattern:["https://fp.dtect.io/web/v<version>/<apiKey>/loader_v<loaderVersion>.js",G.defaultScriptUrlPattern]}),Se()||(await ao(),await window.hcaptcha.render("dtect-h-captcha",{sitekey:k,size:"invisible"})),!we)throw new Error(v.SDK_INIT_ERROR)}async function uo(){if(g.tokens)return g.tokens;let e=new Promise(o=>{let i=we?.get();o(i)}),t=new Promise(async o=>{Se()&&o({response:io});let a=await window?.hcaptcha?.execute({async:!0});o(a)}),[r,n]=await Promise.all([t,e]);return g.tokens={behaviorRequestId:n?.requestId,behaviorToken:n?.sealedResult,automationToken:r?.response},g.tokens}function lo(e){let t=e?.projectId,r=e?.visitorId||X();return(typeof e?.projectId=="number"||typeof e?.visitorId=="number")&&(t=`${e?.projectId}`,r=`${e?.visitorId}`),{visitorId:r,projectId:t}}function ht(e){if(g.projectId&&g.visitorId)return{visitorId:g.visitorId,projectId:g.projectId};let{projectId:t,visitorId:r}=lo(e);return{projectId:t,visitorId:r}}async function pr(e,t){if(!q())throw new Error(v.NOT_INITIALIZED);if(!hr())throw new Error(v.MISSING_CREDENTIALS);let{projectId:r,visitorId:n}=ht(e);if(g.projectId=r,g.visitorId=n,!e||!r?.trim())throw new Error(v.FAILED_TO_GET_SECURITY_RESULT);try{let o=await uo(),i=new Z,[a,s,c,m]=await Promise.allSettled([i.get(),tr(),rr(),or()]);if(o?.behaviorToken&&o?.behaviorRequestId&&o?.automationToken){let u={behaviorToken:o.behaviorToken,automationToken:o.automationToken,behaviorRequestId:o.behaviorRequestId,entryLink:window?.location?.href,securitySettings:e.securitySettings,metaData:e.metaData,vmDtectResults:s?.value,tamperingDtectResults:c?.value,incognitoDtectResults:m?.value,deviceIdResults:a?.value};g.clientData=u;let l={...e,projectId:r,visitorId:n,clientData:u,version:"0.0.18",token:g.token,questionData:g.questionData,aiCheckData:g.aiCheckData};lr=performance.now();let d=(lr-dr).toFixed(),y=await me({url:`${t}?clientId=${F}&diff=${d}`,body:{...l},headers:{"client-id":F,"x-api-key":K}});if("token"in y||"results"in y)return U({state:g,securityKeys:{automationKey:k,behaviorKey:M}}),y}throw new Error(v.INTERNAL_SERVER_ERROR)}catch(o){if(o instanceof Error){if(o?.message?.includes("maintenance_mode"))throw new Error(v.MAINTENANCE_MODE);if(o?.message?.includes("rate-limited")||o?.message?.includes("429"))throw new Error(v.RATE_LIMIT_REACHED);switch(o?.message){case G.ERROR_RATE_LIMIT:throw new Error(v.RATE_LIMIT_REACHED);default:throw new Error(v.INTERNAL_SERVER_ERROR)}}throw new Error(v.FAILED_TO_GET_SECURITY_RESULT)}}async function Re(e){return await pr(e,`${B}/client/check/result`)}async function be(e){return await pr(e,`${B}/client/check`)}async function Te(e){if(!q())throw new Error(v.NOT_INITIALIZED);let{respondentType:t,language:r}=e;try{let n=await it({url:`${B}/client/quality-questions/${t}/${r}`,headers:{"client-id":F,"x-api-key":K}});if(n)return n;throw new Error(v.INTERNAL_SERVER_ERROR)}catch(n){ft(n)}}async function Oe(e){if(!q())throw new Error(v.NOT_INITIALIZED);g.questionData||(g.questionData={questions:e.questions});let{visitorId:t,projectId:r}=ht(e);g.visitorId=t,g.projectId=r;try{let n=await me({url:Ie,headers:{"client-id":F,"x-api-key":K},body:{token:g.token,visitorId:t,projectId:r,version:mr,questionData:g.questionData,aiCheckData:g.aiCheckData,clientData:g.clientData}});if(n)return U({state:g,securityKeys:{automationKey:k,behaviorKey:M}}),n;throw new Error(v.INTERNAL_SERVER_ERROR)}catch(n){ft(n)}}async function Ae(e){if(!q())throw new Error(v.NOT_INITIALIZED);g.aiCheckData={timeTakenSeconds:e.timeTakenSeconds,qbc:e.qbc||ne.qbc,mas:e.mas||ne.mas,scb:e.scb||ne.scb,apd:e.apd||ne.apd};let{visitorId:t,projectId:r}=ht(e);g.visitorId=t,g.projectId=r;try{let n=await me({url:Ie,headers:{"client-id":F,"x-api-key":K},body:{token:g.token,visitorId:t,projectId:r,version:mr,clientData:g.clientData,questionData:g.questionData,aiCheckData:g.aiCheckData}});if(n)return U({state:g,securityKeys:{automationKey:k,behaviorKey:M}}),n;throw new Error(v.INTERNAL_SERVER_ERROR)}catch(n){ft(n)}}function mo(){let e=document.querySelector("head"),t=document.querySelector("body");if(!Se()){t?.insertAdjacentHTML("beforeend",'<div id="dtect-h-captcha" ></div>');let n=document.createElement("script");n.setAttribute("src","https://js.hcaptcha.com/1/api.js"),n.setAttribute("async","true"),n.setAttribute("defer","true"),e?.append(n)}}function De(e){return e?.automationKey&&e?.behaviorKey}function gr(e){let t=e.tokens;return!!(t&&t.behaviorToken&&t.behaviorRequestId&&t.automationToken)}async function yr(e){if(!e?.clientId||!e?.apiKey)throw new Error(v.MISSING_CREDENTIALS);dr=performance.now();let{clientId:t,apiKey:r,endpoint:n="https://api.dtect.io/security",includeResults:o}=e;B=n,Ie=`${B}/client/check`;let i=ur(g);if(g.isLoading){if(q())return ve;throw new Error(v.DUPLICATE_INITIALIZATION)}if(ne=Ft(g.aiCheckData),F=t,K=r,o&&(Ie=`${B}/client/check/result`),g={...g,isLoading:!0,token:i||""},gr(g)&&De({automationKey:k,behaviorKey:M}))return g={...g,isLoading:!1,token:i},U({state:g,securityKeys:{automationKey:k,behaviorKey:M}}),{getSecurityResult:Re,getSecurityToken:be,isAIUsageDetected:Ae,checkQualityQuestions:Oe,getQualityQuestions:Te,LanguageCodes:V,QualityQuestionsRespondentTypes:j};if(!hr())throw new Error(v.MISSING_CREDENTIALS);if(q())return ve;mo();try{let s=await so({clientId:t,apiKey:r,endpoint:n});if(q())throw new Error;return co({behaviorKey:s.behaviorKey}).then(()=>({getSecurityResult:Re,getSecurityToken:be,SecurityAPIError:fr,isAIUsageDetected:Ae,checkQualityQuestions:Oe,getQualityQuestions:Te,LanguageCodes:V,QualityQuestionsRespondentTypes:j})).catch(c=>{throw new Error(c.message)})}catch(s){if(s instanceof Error){if(s?.message?.includes("maintenance_mode"))throw new Error(v.MAINTENANCE_MODE);if([v.INVALID_API_KEY,v.UNAUTHORIZED].includes(s?.message))throw new Error(v.INVALID_CREDENTIALS)}throw new Error(v.SDK_INIT_ERROR)}finally{g={...g,isLoading:!1,token:i},U({state:g,securityKeys:{automationKey:k,behaviorKey:M}})}}ve={init:yr,getSecurityResult:Re,getSecurityToken:be,isAIUsageDetected:Ae,checkQualityQuestions:Oe,getQualityQuestions:Te,QualityQuestionsRespondentTypes:j,LanguageCodes:V};var fo=ve;
|
|
1
|
+
"use strict";var pe=Object.defineProperty;var It=Object.getOwnPropertyDescriptor;var Tt=Object.getOwnPropertyNames;var Ot=Object.prototype.hasOwnProperty;var gt=(e,t)=>{for(var r in t)pe(e,r,{get:t[r],enumerable:!0})},vt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Tt(t))!Ot.call(e,i)&&i!==r&&pe(e,i,{get:()=>t[i],enumerable:!(n=It(t,i))||n.enumerable});return e};var _t=e=>vt(pe({},"__esModule",{value:!0}),e);var br={};gt(br,{LanguageCodes:()=>q,QualityQuestionsRespondentTypes:()=>K,SecurityAPIError:()=>dt,checkQualityQuestions:()=>le,default:()=>Nr,getQualityQuestions:()=>ue,getSecurityResult:()=>ae,getSecurityToken:()=>ce,init:()=>Rt,isAIUsageDetected:()=>he});module.exports=_t(br);function At(e,t){return function(r,n){return Object.prototype.hasOwnProperty.call(r,n)}(e,t)?e[t]:void 0}function Dt(e,t,r,n){let i=document,o="securitypolicyviolation",c,s=p=>{let l=new URL(e,location.href),{blockedURI:h}=p;h!==l.href&&h!==l.protocol.slice(0,-1)&&h!==l.origin||(c=p,a())};i.addEventListener(o,s);let a=()=>i.removeEventListener(o,s);return n?.then(a,a),Promise.resolve().then(t).then(p=>(a(),p),p=>new Promise(l=>{let h=new MessageChannel;h.port1.onmessage=()=>l(),h.port2.postMessage(null)}).then(()=>{if(a(),c)return r(c);throw p}))}function w(e){let t="";for(let r=0;r<e.length;++r)if(r>0){let n=e[r].toLowerCase();n!==e[r]?t+=` ${n}`:t+=e[r]}else t+=e[r].toUpperCase();return t}var wt={default:"endpoint"},Nt={default:"tlsEndpoint"},bt="Client timeout",Pt="Network connection error",kt="Network request aborted",St="Response cannot be parsed",Ee="Blocked by CSP",me="The endpoint parameter is not a valid URL",Mt="Handle on demand agent data error",Lt=w("WrongRegion"),Ft=w("SubscriptionNotActive"),xt=w("UnsupportedVersion"),Ut=w("InstallationMethodRestricted"),qt=w("HostnameRestricted"),Kt=w("IntegrationFailed"),Gt=w("NetworkRestricted"),Bt=w("InvalidProxyIntegrationSecret"),Qt=w("InvalidProxyIntegrationHeaders"),Ct=w("ProxyIntegrationSecretEnvironmentMismatch"),Re="API key required",Se="API key not found",Me="API key expired",jt="Request cannot be parsed",Vt="Request failed",Yt="Request failed to process",$t="Too many requests, rate limit exceeded",Xt="Not available for this origin",Wt="Not available with restricted header",Jt=Re,zt=Se,Zt=Me,Ht="3.12.0",W="Failed to load the JS script of the agent",ye="9319";function er(e,t){let r=[],[n,i]=function(s){let a=function(h){let R=[...h];return{current:()=>R[0],postpone(){let y=R.shift();y!==void 0&&R.push(y)},exclude(){R.shift()}}}(s),p=function(h,R){let y=0;return()=>Math.random()*Math.min(R,h*Math.pow(2,y++))}(100,3e3),l=new Set;return[a.current(),(h,R)=>{let y,m=R instanceof Error?R.message:"";if(m===Ee||m===me)a.exclude(),y=0;else if(m===ye)a.exclude();else if(m===W){let g=Date.now()-h.getTime()<50,f=a.current();f&&g&&!l.has(f)&&(l.add(f),y=0),a.postpone()}else a.postpone();let d=a.current();return d===void 0?void 0:[d,y??h.getTime()+p()-Date.now()]}]}(e),o;if(n===void 0)return Promise.reject(new TypeError("The list of script URL patterns is empty"));let c=s=>{let a=new Date,p=h=>r.push({url:s,startedAt:a,finishedAt:new Date,error:h}),l=t(s);return l.then(()=>p(),p),l.catch(h=>{if(o!=null||(o=h),r.length>=5)throw o;let R=i(a,h);if(!R)throw o;let[y,m]=R;return(d=m,new Promise(g=>setTimeout(g,d))).then(()=>c(y));var d})};return c(n).then(s=>[s,r])}var Le="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",tr=Le;function rr(e){var t,r;let{picked:n,rest:i}=function(l,h){let R={},y={};for(let[m,d]of Object.entries(l))h.includes(m)?R[m]=d:y[m]=d;return{picked:R,rest:y}}(e,["scriptUrlPattern","token","apiKey"]),o=n.token,c=(t=n.apiKey)!==null&&t!==void 0?t:o,s=(r=At(e,"scriptUrlPattern"))!==null&&r!==void 0?r:Le,[a,p]=function(){let l=[],h=()=>{l.push({time:new Date,state:document.visibilityState})},R=function(y,m,d,g){return y.addEventListener(m,d,g),()=>y.removeEventListener(m,d,g)}(document,"visibilitychange",h);return h(),[l,R]}();return Promise.resolve().then(()=>{if(!c||typeof c!="string")throw new Error(Re);let l=function(h,R){return(Array.isArray(h)?h:[h]).map(y=>function(m,d){let g=encodeURIComponent;return m.replace(/<[^<>]+>/g,f=>f==="<version>"?"3":f==="<apiKey>"?g(d):f==="<loaderVersion>"?g(Ht):f)}(String(y),R))}(s,c);return er(l,nr)}).catch(l=>{throw p(),function(h){return h instanceof Error&&h.message===ye?new Error(W):h}(l)}).then(([l,h])=>(p(),l.load({...i,ldi:{attempts:h,visibilityStates:a}})))}function nr(e){return Dt(e,()=>function(t){return new Promise((r,n)=>{if(function(s){if(URL.prototype)try{return new URL(s,location.href),!1}catch(a){if(a instanceof Error&&a.name==="TypeError")return!0;throw a}}(t))throw new Error(me);let i=document.createElement("script"),o=()=>{var s;return(s=i.parentNode)===null||s===void 0?void 0:s.removeChild(i)},c=document.head||document.getElementsByTagName("head")[0];i.onload=()=>{o(),r()},i.onerror=()=>{o(),n(new Error(W))},i.async=!0,i.src=t,c.appendChild(i)})}(e),()=>{throw new Error(Ee)}).then(ir)}function ir(){let e=window,t="__fpjs_p_l_b",r=e[t];if(function(n,i){var o;let c=(o=Object.getOwnPropertyDescriptor)===null||o===void 0?void 0:o.call(Object,n,i);c?.configurable?delete n[i]:c&&!c.writable||(n[i]=void 0)}(e,t),typeof r?.load!="function")throw new Error(ye);return r}var U={load:rr,defaultScriptUrlPattern:tr,ERROR_SCRIPT_LOAD_FAIL:W,ERROR_API_KEY_EXPIRED:Me,ERROR_API_KEY_INVALID:Se,ERROR_API_KEY_MISSING:Re,ERROR_BAD_REQUEST_FORMAT:jt,ERROR_BAD_RESPONSE_FORMAT:St,ERROR_CLIENT_TIMEOUT:bt,ERROR_CSP_BLOCK:Ee,ERROR_FORBIDDEN_ENDPOINT:qt,ERROR_FORBIDDEN_HEADER:Wt,ERROR_FORBIDDEN_ORIGIN:Xt,ERROR_GENERAL_SERVER_FAILURE:Vt,ERROR_HANDLE_AGENT_DATA:Mt,ERROR_INSTALLATION_METHOD_RESTRICTED:Ut,ERROR_INTEGRATION_FAILURE:Kt,ERROR_INVALID_ENDPOINT:me,ERROR_INVALID_PROXY_INTEGRATION_HEADERS:Qt,ERROR_INVALID_PROXY_INTEGRATION_SECRET:Bt,ERROR_NETWORK_ABORT:kt,ERROR_NETWORK_CONNECTION:Pt,ERROR_NETWORK_RESTRICTED:Gt,ERROR_PROXY_INTEGRATION_SECRET_ENVIRONMENT_MISMATCH:Ct,ERROR_RATE_LIMIT:$t,ERROR_SERVER_TIMEOUT:Yt,ERROR_SUBSCRIPTION_NOT_ACTIVE:Ft,ERROR_TOKEN_EXPIRED:Zt,ERROR_TOKEN_INVALID:zt,ERROR_TOKEN_MISSING:Jt,ERROR_UNSUPPORTED_VERSION:xt,ERROR_WRONG_REGION:Lt,defaultEndpoint:wt,defaultTlsEndpoint:Nt};var v=[];for(let e=0;e<256;++e)v.push((e+256).toString(16).slice(1));function Fe(e,t=0){return(v[e[t+0]]+v[e[t+1]]+v[e[t+2]]+v[e[t+3]]+"-"+v[e[t+4]]+v[e[t+5]]+"-"+v[e[t+6]]+v[e[t+7]]+"-"+v[e[t+8]]+v[e[t+9]]+"-"+v[e[t+10]]+v[e[t+11]]+v[e[t+12]]+v[e[t+13]]+v[e[t+14]]+v[e[t+15]]).toLowerCase()}var Ie,sr=new Uint8Array(16);function Te(){if(!Ie){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Ie=crypto.getRandomValues.bind(crypto)}return Ie(sr)}var or=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Oe={randomUUID:or};function ar(e,t,r){if(Oe.randomUUID&&!t&&!e)return Oe.randomUUID();e=e||{};let n=e.random??e.rng?.()??Te();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){if(r=r||0,r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let i=0;i<16;++i)t[r+i]=n[i];return t}return Fe(n)}var C=ar;var cr={UNAUTHORIZED:"Unauthorized"},ur={EXPIRED:"EXPIRED_TOKEN",INVALID_API_KEY:"INVALID_API_KEY",MISSING_AUTHENTICATION_TOKEN:"MISSING_AUTHENTICATION_TOKEN"},xe={INTERNAL_SERVER_ERROR:"Internal Server Error during API Request",MISSING_CREDENTIALS:"Missing Public Client ID or Public API Key",MAINTENANCE_MODE:"API Under Maintenance",RATE_LIMIT_REACHED:"Too many requests. Rate limit exceeded"},Ue={SDK_INIT_ERROR:"Internal Server Error during SDK Initialization",DUPLICATE_INITIALIZATION:"Multiple SDK Initializations Detected",NOT_INITIALIZED:"SDK Not Initialized"},qe={INVALID_CREDENTIALS:"Invalid Public Client ID or Public API Key"},Ke={FAILED_TO_GET_SECURITY_RESULT:"Failed to Retrieve Security Result"},Ge={FAILED_TO_GET_SECURITY_TOKEN:" Failed to Generate Security Token"},E={...cr,...ur,...xe,...Ue,...qe,...Ke,...Ge},Be={...xe,...Ue,...qe,...Ke,...Ge};var q=(f=>(f.AR="ar",f.BN="bn",f.DE="de",f.EN="en",f.ES="es",f.FR="fr",f.HI="hi",f.ID="id",f.IT="it",f.JA="ja",f.KO="ko",f.MS="ms",f.NL="nl",f.PT="pt",f.RU="ru",f.YU="yu",f.ZH="zh",f))(q||{}),K=(I=>(I.GeneralConsumer="general-consumer",I.HRManagerDirector="hr-manager-director",I.WebDeveloper="web-developer",I.SoftwareEngineer="software-engineer",I.ITDirector="it-director",I.BusinessAdministrator="business-administrator",I.AccountsPayableManager="accounts-payable-manager",I.Accountant="accountant",I.FinanceDirector="finance-director",I.SmallBusinessOwner="small-business-owner",I.GeneralContractor="general-contractor",I.MarketingManagerDirector="marketing-manager-director",I.ConsumerShopper="consumer-shopper",I.Travel="travel",I.Entertainment="entertainment",I.FinanceAndBanking="finance-and-banking",I.General="general",I.B2BWhiteCollar="b2b-white-collar",I.B2BBlueCollar="b2b-blue-collar",I.Lawyer="lawyer",I))(K||{});var lr=(e,t={})=>({"Content-Type":"application/json",...e?.accessToken&&{Authorization:`Bearer ${e?.accessToken}`},...t}),hr=async(e,t)=>{if(!e.ok){let r=await e.text();throw new Error(r)}return t==="file"?e.blob():t==="json"?e.json():t==="text"?e.text():null},Qe=async({url:e,auth:t,body:r,method:n="GET",headers:i={},responseType:o="json"})=>{let c={method:n,headers:lr(t,i),...r?{body:r instanceof FormData?r:JSON.stringify(r)}:{}},s=await fetch(e,c);return hr(s,o)},ge=e=>Qe({...e,method:"GET"}),J=e=>Qe({...e,method:"POST"});function Ce(e){let t=e?.qbc||!1,r=e?.mas||!1,n=e?.apd||!1,i=e?.scb||null,o=0,c=()=>{t=!1,r=!1,n=!1,i=void 0,o=0},s=()=>{let h=window?.getSelection()?.toString();h&&h.length>0&&(o=Date.now(),t=!0)},a=l=>{let h=l.clipboardData?.getData("text"),R=l.target instanceof HTMLInputElement||l.target instanceof HTMLTextAreaElement;h&&R&&(n=!0)},p=()=>{r=!0;let l=Date.now();if(o){let h=(l-o)/1e3;(i===void 0||h<i)&&(i=h)}};return document?.addEventListener("copy",s),document?.addEventListener("paste",a),window?.addEventListener("blur",p),{get qbc(){return t},get mas(){return r},get apd(){return n},get scb(){return i},reset:c,destroy(){document?.removeEventListener("copy",s),document?.removeEventListener("paste",a),window?.removeEventListener("blur",p)}}}var b=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var P=typeof window>"u"||"Deno"in globalThis;function A(){}function Ye(e,t){return typeof e=="function"?e(t):e}function $e(e){return typeof e=="number"&&e>=0&&e!==1/0}function Xe(e,t){return Math.max(e+(t||0)-Date.now(),0)}function _e(e,t){return typeof e=="function"?e(t):e}function We(e,t){return typeof e=="function"?e(t):e}function Ae(e,t){let{type:r="all",exact:n,fetchStatus:i,predicate:o,queryKey:c,stale:s}=e;if(c){if(n){if(t.queryHash!==j(c,t.options))return!1}else if(!B(t.queryKey,c))return!1}if(r!=="all"){let a=t.isActive();if(r==="active"&&!a||r==="inactive"&&a)return!1}return!(typeof s=="boolean"&&t.isStale()!==s||i&&i!==t.state.fetchStatus||o&&!o(t))}function De(e,t){let{exact:r,status:n,predicate:i,mutationKey:o}=e;if(o){if(!t.options.mutationKey)return!1;if(r){if(G(t.options.mutationKey)!==G(o))return!1}else if(!B(t.options.mutationKey,o))return!1}return!(n&&t.state.status!==n||i&&!i(t))}function j(e,t){return(t?.queryKeyHashFn||G)(e)}function G(e){return JSON.stringify(e,(t,r)=>ve(r)?Object.keys(r).sort().reduce((n,i)=>(n[i]=r[i],n),{}):r)}function B(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(r=>!B(e[r],t[r])):!1}function Je(e,t){if(e===t)return e;let r=je(e)&&je(t);if(r||ve(e)&&ve(t)){let n=r?e:Object.keys(e),i=n.length,o=r?t:Object.keys(t),c=o.length,s=r?[]:{},a=0;for(let p=0;p<c;p++){let l=r?p:o[p];(!r&&n.includes(l)||r)&&e[l]===void 0&&t[l]===void 0?(s[l]=void 0,a++):(s[l]=Je(e[l],t[l]),s[l]===e[l]&&e[l]!==void 0&&a++)}return i===c&&a===i?e:s}return t}function je(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function ve(e){if(!Ve(e))return!1;let t=e.constructor;if(t===void 0)return!0;let r=t.prototype;return!(!Ve(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Ve(e){return Object.prototype.toString.call(e)==="[object Object]"}function ze(e){return new Promise(t=>{setTimeout(t,e)})}function Ze(e,t,r){return typeof r.structuralSharing=="function"?r.structuralSharing(e,t):r.structuralSharing!==!1?Je(e,t):t}function He(e,t,r=0){let n=[...e,t];return r&&n.length>r?n.slice(1):n}function et(e,t,r=0){let n=[t,...e];return r&&n.length>r?n.slice(0,-1):n}var V=Symbol();function z(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===V?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var fr=class extends b{#e;#t;#r;constructor(){super(),this.#r=e=>{if(!P&&window.addEventListener){let t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},Z=new fr;var dr=class extends b{#e=!0;#t;#r;constructor(){super(),this.#r=e=>{if(!P&&window.addEventListener){let t=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(r=>{r(e)}))}isOnline(){return this.#e}},Q=new dr;function tt(){let e,t,r=new Promise((i,o)=>{e=i,t=o});r.status="pending",r.catch(()=>{});function n(i){Object.assign(r,i),delete r.resolve,delete r.reject}return r.resolve=i=>{n({status:"fulfilled",value:i}),e(i)},r.reject=i=>{n({status:"rejected",reason:i}),t(i)},r}function pr(e){return Math.min(1e3*2**e,3e4)}function we(e){return(e??"online")==="online"?Q.isOnline():!0}var rt=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function H(e){return e instanceof rt}function ee(e){let t=!1,r=0,n=!1,i,o=tt(),c=d=>{n||(R(new rt(d)),e.abort?.())},s=()=>{t=!0},a=()=>{t=!1},p=()=>Z.isFocused()&&(e.networkMode==="always"||Q.isOnline())&&e.canRun(),l=()=>we(e.networkMode)&&e.canRun(),h=d=>{n||(n=!0,e.onSuccess?.(d),i?.(),o.resolve(d))},R=d=>{n||(n=!0,e.onError?.(d),i?.(),o.reject(d))},y=()=>new Promise(d=>{i=g=>{(n||p())&&d(g)},e.onPause?.()}).then(()=>{i=void 0,n||e.onContinue?.()}),m=()=>{if(n)return;let d,g=r===0?e.initialPromise:void 0;try{d=g??e.fn()}catch(f){d=Promise.reject(f)}Promise.resolve(d).then(h).catch(f=>{if(n)return;let k=e.retry??(P?0:3),x=e.retryDelay??pr,I=typeof x=="function"?x(r,f):x,yt=k===!0||typeof k=="number"&&r<k||typeof k=="function"&&k(r,f);if(t||!yt){R(f);return}r++,e.onFail?.(r,f),ze(I).then(()=>p()?void 0:y()).then(()=>{t?R(f):m()})})};return{promise:o,cancel:c,continue:()=>(i?.(),o),cancelRetry:s,continueRetry:a,canStart:l,start:()=>(l()?m():y().then(m),o)}}function Er(){let e=[],t=0,r=s=>{s()},n=s=>{s()},i=s=>setTimeout(s,0),o=s=>{t?e.push(s):i(()=>{r(s)})},c=()=>{let s=e;e=[],s.length&&i(()=>{n(()=>{s.forEach(a=>{r(a)})})})};return{batch:s=>{let a;t++;try{a=s()}finally{t--,t||c()}return a},batchCalls:s=>(...a)=>{o(()=>{s(...a)})},schedule:o,setNotifyFunction:s=>{r=s},setBatchNotifyFunction:s=>{n=s},setScheduler:s=>{i=s}}}var O=Er();var te=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),$e(this.gcTime)&&(this.#e=setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(P?1/0:5*60*1e3))}clearGcTimeout(){this.#e&&(clearTimeout(this.#e),this.#e=void 0)}};var nt=class extends te{#e;#t;#r;#n;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.cache,this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=Rr(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#n?.promise}setOptions(e){this.options={...this.#o,...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#r.remove(this)}setData(e,t){let r=Ze(this.state.data,e,this.options);return this.#i({data:r,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),r}setState(e,t){this.#i({type:"setState",state:e,setStateOptions:t})}cancel(e){let t=this.#n?.promise;return this.#n?.cancel(e),t?t.then(A).catch(A):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(e=>We(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===V||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(e=0){return this.state.isInvalidated||this.state.data===void 0||!Xe(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#n?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#n?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#n&&(this.#s?this.#n.cancel({revert:!0}):this.#n.cancelRetry()),this.scheduleGc()),this.#r.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#i({type:"invalidate"})}fetch(e,t){if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#n)return this.#n.continueRetry(),this.#n.promise}if(e&&this.setOptions(e),!this.options.queryFn){let s=this.observers.find(a=>a.options.queryFn);s&&this.setOptions(s.options)}let r=new AbortController,n=s=>{Object.defineProperty(s,"signal",{enumerable:!0,get:()=>(this.#s=!0,r.signal)})},i=()=>{let s=z(this.options,t),a={queryKey:this.queryKey,meta:this.meta};return n(a),this.#s=!1,this.options.persister?this.options.persister(s,a,this):s(a)},o={fetchOptions:t,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:i};n(o),this.options.behavior?.onFetch(o,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==o.fetchOptions?.meta)&&this.#i({type:"fetch",meta:o.fetchOptions?.meta});let c=s=>{H(s)&&s.silent||this.#i({type:"error",error:s}),H(s)||(this.#r.config.onError?.(s,this),this.#r.config.onSettled?.(this.state.data,s,this)),this.scheduleGc()};return this.#n=ee({initialPromise:t?.initialPromise,fn:o.fetchFn,abort:r.abort.bind(r),onSuccess:s=>{if(s===void 0){c(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(s)}catch(a){c(a);return}this.#r.config.onSuccess?.(s,this),this.#r.config.onSettled?.(s,this.state.error,this),this.scheduleGc()},onError:c,onFail:(s,a)=>{this.#i({type:"failed",failureCount:s,error:a})},onPause:()=>{this.#i({type:"pause"})},onContinue:()=>{this.#i({type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0}),this.#n.start()}#i(e){let t=r=>{switch(e.type){case"failed":return{...r,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...mr(r.data,this.options),fetchMeta:e.meta??null};case"success":return{...r,data:e.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":let n=e.error;return H(n)&&n.revert&&this.#t?{...this.#t,fetchStatus:"idle"}:{...r,error:n,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...e.state}}};this.state=t(this.state),O.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),this.#r.notify({query:this,type:"updated",action:e})})}};function mr(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:we(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Rr(e){let t=typeof e.initialData=="function"?e.initialData():e.initialData,r=t!==void 0,n=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var Y=class extends b{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,r){let n=t.queryKey,i=t.queryHash??j(n,t),o=this.get(i);return o||(o=new nt({cache:this,queryKey:n,queryHash:i,options:e.defaultQueryOptions(t),state:r,defaultOptions:e.getQueryDefaults(n)}),this.add(o)),o}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){O.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(r=>Ae(t,r))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(r=>Ae(e,r)):t}notify(e){O.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){O.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){O.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}};var it=class extends te{#e;#t;#r;constructor(e){super(),this.mutationId=e.mutationId,this.#t=e.mutationCache,this.#e=[],this.state=e.state||yr(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#e.includes(e)||(this.#e.push(e),this.clearGcTimeout(),this.#t.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#e=this.#e.filter(t=>t!==e),this.scheduleGc(),this.#t.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#e.length||(this.state.status==="pending"?this.scheduleGc():this.#t.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){this.#r=ee({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(n,i)=>{this.#n({type:"failed",failureCount:n,error:i})},onPause:()=>{this.#n({type:"pause"})},onContinue:()=>{this.#n({type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#t.canRun(this)});let t=this.state.status==="pending",r=!this.#r.canStart();try{if(!t){this.#n({type:"pending",variables:e,isPaused:r}),await this.#t.config.onMutate?.(e,this);let i=await this.options.onMutate?.(e);i!==this.state.context&&this.#n({type:"pending",context:i,variables:e,isPaused:r})}let n=await this.#r.start();return await this.#t.config.onSuccess?.(n,e,this.state.context,this),await this.options.onSuccess?.(n,e,this.state.context),await this.#t.config.onSettled?.(n,null,this.state.variables,this.state.context,this),await this.options.onSettled?.(n,null,e,this.state.context),this.#n({type:"success",data:n}),n}catch(n){try{throw await this.#t.config.onError?.(n,e,this.state.context,this),await this.options.onError?.(n,e,this.state.context),await this.#t.config.onSettled?.(void 0,n,this.state.variables,this.state.context,this),await this.options.onSettled?.(void 0,n,e,this.state.context),n}finally{this.#n({type:"error",error:n})}}finally{this.#t.runNext(this)}}#n(e){let t=r=>{switch(e.type){case"failed":return{...r,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...r,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:e.error,failureCount:r.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),O.batch(()=>{this.#e.forEach(r=>{r.onMutationUpdate(e)}),this.#t.notify({mutation:this,type:"updated",action:e})})}};function yr(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var $=class extends b{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#r=0}#e;#t;#r;build(e,t,r){let n=new it({mutationCache:this,mutationId:++this.#r,options:e.defaultMutationOptions(t),state:r});return this.add(n),n}add(e){this.#e.add(e);let t=re(e);if(typeof t=="string"){let r=this.#t.get(t);r?r.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){let t=re(e);if(typeof t=="string"){let r=this.#t.get(t);if(r)if(r.length>1){let n=r.indexOf(e);n!==-1&&r.splice(n,1)}else r[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){let t=re(e);if(typeof t=="string"){let n=this.#t.get(t)?.find(i=>i.state.status==="pending");return!n||n===e}else return!0}runNext(e){let t=re(e);return typeof t=="string"?this.#t.get(t)?.find(n=>n!==e&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){O.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(r=>De(t,r))}findAll(e={}){return this.getAll().filter(t=>De(e,t))}notify(e){O.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(t=>t.state.isPaused);return O.batch(()=>Promise.all(e.map(t=>t.continue().catch(A))))}};function re(e){return e.options.scope?.id}function Ne(e){return{onFetch:(t,r)=>{let n=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,o=t.state.data?.pages||[],c=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},a=0,p=async()=>{let l=!1,h=m=>{Object.defineProperty(m,"signal",{enumerable:!0,get:()=>(t.signal.aborted?l=!0:t.signal.addEventListener("abort",()=>{l=!0}),t.signal)})},R=z(t.options,t.fetchOptions),y=async(m,d,g)=>{if(l)return Promise.reject();if(d==null&&m.pages.length)return Promise.resolve(m);let f={queryKey:t.queryKey,pageParam:d,direction:g?"backward":"forward",meta:t.options.meta};h(f);let k=await R(f),{maxPages:x}=t.options,I=g?et:He;return{pages:I(m.pages,k,x),pageParams:I(m.pageParams,d,x)}};if(i&&o.length){let m=i==="backward",d=m?Ir:st,g={pages:o,pageParams:c},f=d(n,g);s=await y(g,f,m)}else{let m=e??o.length;do{let d=a===0?c[0]??n.initialPageParam:st(n,s);if(a>0&&d==null)break;s=await y(s,d),a++}while(a<m)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(p,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r):t.fetchFn=p}}}function st(e,{pages:t,pageParams:r}){let n=t.length-1;return t.length>0?e.getNextPageParam(t[n],t,r[n],r):void 0}function Ir(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}var be=class{#e;#t;#r;#n;#o;#s;#i;#a;constructor(e={}){this.#e=e.queryCache||new Y,this.#t=e.mutationCache||new $,this.#r=e.defaultOptions||{},this.#n=new Map,this.#o=new Map,this.#s=0}mount(){this.#s++,this.#s===1&&(this.#i=Z.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=Q.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#s--,this.#s===0&&(this.#i?.(),this.#i=void 0,this.#a?.(),this.#a=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),r=this.#e.build(this,t),n=r.state.data;return n===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(_e(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(n))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:r})=>{let n=r.data;return[t,n]})}setQueryData(e,t,r){let n=this.defaultQueryOptions({queryKey:e}),o=this.#e.get(n.queryHash)?.state.data,c=Ye(t,o);if(c!==void 0)return this.#e.build(this,n).setData(c,{...r,manual:!0})}setQueriesData(e,t,r){return O.batch(()=>this.#e.findAll(e).map(({queryKey:n})=>[n,this.setQueryData(n,t,r)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;O.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r)})})}resetQueries(e,t){let r=this.#e,n={type:"active",...e};return O.batch(()=>(r.findAll(e).forEach(i=>{i.reset()}),this.refetchQueries(n,t)))}cancelQueries(e,t={}){let r={revert:!0,...t},n=O.batch(()=>this.#e.findAll(e).map(i=>i.cancel(r)));return Promise.all(n).then(A).catch(A)}invalidateQueries(e,t={}){return O.batch(()=>{if(this.#e.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none")return Promise.resolve();let r={...e,type:e?.refetchType??e?.type??"active"};return this.refetchQueries(r,t)})}refetchQueries(e,t={}){let r={...t,cancelRefetch:t.cancelRefetch??!0},n=O.batch(()=>this.#e.findAll(e).filter(i=>!i.isDisabled()).map(i=>{let o=i.fetch(void 0,r);return r.throwOnError||(o=o.catch(A)),i.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(n).then(A)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let r=this.#e.build(this,t);return r.isStaleByTime(_e(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(A).catch(A)}fetchInfiniteQuery(e){return e.behavior=Ne(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(A).catch(A)}ensureInfiniteQueryData(e){return e.behavior=Ne(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Q.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#r}setDefaultOptions(e){this.#r=e}setQueryDefaults(e,t){this.#n.set(G(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#n.values()],r={};return t.forEach(n=>{B(e,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(e,t){this.#o.set(G(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#o.values()],r={};return t.forEach(n=>{B(e,n.mutationKey)&&(r={...r,...n.defaultOptions})}),r}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#r.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=j(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===V&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#r.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}};var Tr=new be({defaultOptions:{queries:{staleTime:3e4}},queryCache:new Y({onError:(e,t)=>{}}),mutationCache:new $}),ot=Tr;var at="dtect_security_sdk_state",ct=typeof window<"u",ut={isLoading:!1,token:"",visitorId:"",projectId:"",questionData:null,clientData:null,aiCheckData:null,tokens:null},ne={state:{...ut},securityKeys:{behaviorKey:"",automationKey:""}};function lt(){if(!ct)return ne;try{let e=sessionStorage.getItem(at);if(!e)return ne;let t=JSON.parse(e);return t.expiresAt&&t.expiresAt<Date.now()?ne:{state:{...ut,...t.state},securityKeys:t.securityKeys||{behaviorKey:"",automationKey:""}}}catch{return ne}}function S(e){if(ct)try{let t=Date.now()+864e5,r={...e,expiresAt:t};sessionStorage.setItem(at,JSON.stringify(r))}catch{}}function ht(e){return e.token||C()}async function _(e,t="info",r={}){let n=`${r.endpoint??"https://api.dtect.io/security"}/log`,i={message:e,type:t,payload:r};navigator.sendBeacon(n,JSON.stringify(i))}var ie,T="https://api.dtect.io/security",se=`${T}/client/check`,L="",F="",ft="0.0.19";var Or="20000000-aaaa-bbbb-cccc-000000000002",oe;var{state:u,securityKeys:{automationKey:D,behaviorKey:N}}=lt(),dt=Be,X;async function gr({clientId:e,apiKey:t,endpoint:r}){if(fe({automationKey:D,behaviorKey:N}))return{automationKey:D,behaviorKey:N};let n=await ot.fetchQuery({queryKey:["getClientConfig",e,t],queryFn:()=>ge({url:`${r}/client/config`,headers:{"client-id":L,"x-api-key":F}})});if(!fe(n))throw new Error;return D=n.automationKey,N=n.behaviorKey,S({state:u,securityKeys:n}),n}function Pe(e){if(e instanceof Error){if(e?.message?.includes("maintenance_mode"))throw new Error(E.MAINTENANCE_MODE);if(e?.message?.includes("rate-limited"))throw new Error(E.RATE_LIMIT_REACHED);switch(e?.message){case U.ERROR_RATE_LIMIT:throw new Error(E.RATE_LIMIT_REACHED);default:throw new Error(E.INTERNAL_SERVER_ERROR)}}throw new Error(E.FAILED_TO_GET_SECURITY_TOKEN)}function M(){if(mt(u)&&fe({automationKey:D,behaviorKey:N}))return!0;let e=de(),t=document.querySelector("#dtect-h-captcha");return!!ie&&!!(t||e)}function pt(){return!!(L&&F)}function vr(){return new Promise(e=>{let t=()=>{window?.hcaptcha?e():requestAnimationFrame(t)};t()})}var de=()=>window?.location?.href?.includes("localhost")||window?.location?.href?.includes("file:///");async function _r({behaviorKey:e}){if(ie=await U.load({apiKey:e,endpoint:["https://fp.dtect.io",U.defaultEndpoint],scriptUrlPattern:["https://fp.dtect.io/web/v<version>/<apiKey>/loader_v<loaderVersion>.js",U.defaultScriptUrlPattern]}),de()||(await vr(),await window.hcaptcha.render("dtect-h-captcha",{sitekey:D,size:"invisible"})),!ie)throw new Error(E.SDK_INIT_ERROR)}async function Ar(){let e=performance.now();if(u.tokens){let a=(performance.now()-e).toFixed();return _(`getTokens finishes in ${a}ms`,"info",{function:"getTokens",endpoint:T,diff:a,token:u.token}),u.tokens}let t=new Promise(s=>{let a=ie?.get();s(a)}),r=new Promise(async s=>{de()&&s({response:Or});let p=await window?.hcaptcha?.execute({async:!0});s(p)}),[n,i]=await Promise.all([r,t]);u.tokens={behaviorRequestId:i?.requestId,behaviorToken:i?.sealedResult,automationToken:n?.response};let c=(performance.now()-e).toFixed();return _(`getTokens finishes in ${c}ms`,"info",{function:"getTokens",endpoint:T,diff:c,token:u.token}),u.tokens}function Dr(e){let t=e?.projectId,r=e?.visitorId||C();return(typeof e?.projectId=="number"||typeof e?.visitorId=="number")&&(t=`${e?.projectId}`,r=`${e?.visitorId}`),{visitorId:r,projectId:t}}function ke(e){if(u.projectId&&u.visitorId)return{visitorId:u.visitorId,projectId:u.projectId};let{projectId:t,visitorId:r}=Dr(e);return{projectId:t,visitorId:r}}async function Et(e,t){let r=performance.now();if(!M())throw new Error(E.NOT_INITIALIZED);if(!pt())throw new Error(E.MISSING_CREDENTIALS);let{projectId:n,visitorId:i}=ke(e);if(u.projectId=n,u.visitorId=i,!e||!n?.trim())throw new Error(E.FAILED_TO_GET_SECURITY_RESULT);try{let o=await Ar();if(o?.behaviorToken&&o?.behaviorRequestId&&o?.automationToken){let c={behaviorToken:o.behaviorToken,automationToken:o.automationToken,behaviorRequestId:o.behaviorRequestId,entryLink:window?.location?.href,securitySettings:e.securitySettings,metaData:e.metaData};u.clientData=c;let s={...e,projectId:n,visitorId:i,clientData:c,version:"0.0.19",token:u.token,questionData:u.questionData,aiCheckData:u.aiCheckData},a=await J({url:`${t}`,body:{...s},headers:{"client-id":L,"x-api-key":F}});if("token"in a||"results"in a){S({state:u,securityKeys:{automationKey:D,behaviorKey:N}});let l=(performance.now()-r).toFixed();return _(`getResultBase finishes in ${l}ms`,"info",{function:"getResultBase",endpoint:T,diff:l,token:u.token}),a}}throw new Error(E.INTERNAL_SERVER_ERROR)}catch(o){let s=(performance.now()-r).toFixed();if(_("getResultBase error","error",{function:"getResultBase",endpoint:T,error:o,diff:s,token:u.token}),o instanceof Error){if(o?.message?.includes("maintenance_mode"))throw new Error(E.MAINTENANCE_MODE);if(o?.message?.includes("rate-limited")||o?.message?.includes("429"))throw new Error(E.RATE_LIMIT_REACHED);switch(o?.message){case U.ERROR_RATE_LIMIT:throw new Error(E.RATE_LIMIT_REACHED);default:throw new Error(E.INTERNAL_SERVER_ERROR)}}throw new Error(E.FAILED_TO_GET_SECURITY_RESULT)}}async function ae(e){return await Et(e,`${T}/client/check/result`)}async function ce(e){return await Et(e,`${T}/client/check`)}async function ue(e){let t=performance.now();if(!M())throw new Error(E.NOT_INITIALIZED);let{respondentType:r,language:n}=e;try{let i=await ge({url:`${T}/client/quality-questions/${r}/${n}`,headers:{"client-id":L,"x-api-key":F}});if(i){let c=(performance.now()-t).toFixed();return _(`getQualityQuestions finishes in ${c}ms`,"info",{function:"getQualityQuestions",endpoint:T,diff:c,token:u.token}),i}throw new Error(E.INTERNAL_SERVER_ERROR)}catch(i){let c=(performance.now()-t).toFixed();_("getQualityQuestions error","error",{endpoint:T,error:i,diff:c,token:u.token}),Pe(i)}}async function le(e){let t=performance.now();if(!M())throw new Error(E.NOT_INITIALIZED);u.questionData||(u.questionData={questions:e.questions});let{visitorId:r,projectId:n}=ke(e);u.visitorId=r,u.projectId=n;try{let i=await J({url:se,headers:{"client-id":L,"x-api-key":F},body:{token:u.token,visitorId:r,projectId:n,version:ft,questionData:u.questionData,aiCheckData:u.aiCheckData,clientData:u.clientData}});if(i){S({state:u,securityKeys:{automationKey:D,behaviorKey:N}});let c=(performance.now()-t).toFixed();return _(`checkQualityQuestions finishes in ${c}ms`,"info",{function:"checkQualityQuestions",endpoint:T,diff:c,token:u.token}),i}throw new Error(E.INTERNAL_SERVER_ERROR)}catch(i){let c=(performance.now()-t).toFixed();_("checkQualityQuestions error","error",{endpoint:T,error:i,diff:c,token:u.token}),Pe(i)}}async function he(e){let t=performance.now();if(!M())throw new Error(E.NOT_INITIALIZED);u.aiCheckData={timeTakenSeconds:e.timeTakenSeconds,qbc:e.qbc||X.qbc,mas:e.mas||X.mas,scb:e.scb||X.scb,apd:e.apd||X.apd};let{visitorId:r,projectId:n}=ke(e);u.visitorId=r,u.projectId=n;try{let i=await J({url:se,headers:{"client-id":L,"x-api-key":F},body:{token:u.token,visitorId:r,projectId:n,version:ft,clientData:u.clientData,questionData:u.questionData,aiCheckData:u.aiCheckData}});if(i){S({state:u,securityKeys:{automationKey:D,behaviorKey:N}});let c=(performance.now()-t).toFixed();return _(`isAIUsageDetected finishes in ${c}ms`,"info",{function:"isAIUsageDetected",endpoint:T,diff:c,token:u.token}),i}throw new Error(E.INTERNAL_SERVER_ERROR)}catch(i){let c=(performance.now()-t).toFixed();_("isAIUsageDetected error","error",{endpoint:T,error:i,diff:c,token:u.token}),Pe(i)}}function wr(){let e=performance.now(),t=document.querySelector("head"),r=document.querySelector("body");if(!de()){r?.insertAdjacentHTML("beforeend",'<div id="dtect-h-captcha" ></div>');let i=document.createElement("script");i.setAttribute("src","https://js.hcaptcha.com/1/api.js"),i.setAttribute("async","true"),i.setAttribute("defer","true"),t?.append(i);let c=(performance.now()-e).toFixed();_(`loadHCaptcha finishes in ${c}ms`,"info",{function:"loadHCaptcha",endpoint:T,diff:c,token:u.token})}}function fe(e){return e?.automationKey&&e?.behaviorKey}function mt(e){let t=e.tokens;return!!(t&&t.behaviorToken&&t.behaviorRequestId&&t.automationToken)}async function Rt(e){let t=performance.now();if(!e?.clientId||!e?.apiKey)throw _(E.MISSING_CREDENTIALS,"error",{endpoint:T,...e}),new Error(E.MISSING_CREDENTIALS);let{clientId:r,apiKey:n,endpoint:i="https://api.dtect.io/security",includeResults:o}=e;T=i,se=`${T}/client/check`;let c=ht(u);if(u.isLoading){if(M())return oe;throw _(E.DUPLICATE_INITIALIZATION,"error",{endpoint:T,clientId:r,apiKey:n,token:u.token}),new Error(E.DUPLICATE_INITIALIZATION)}if(X=Ce(u.aiCheckData),L=r,F=n,o&&(se=`${T}/client/check/result`),u={...u,isLoading:!0,token:c||""},mt(u)&&fe({automationKey:D,behaviorKey:N}))return u={...u,isLoading:!1,token:c},S({state:u,securityKeys:{automationKey:D,behaviorKey:N}}),{getSecurityResult:ae,getSecurityToken:ce,isAIUsageDetected:he,checkQualityQuestions:le,getQualityQuestions:ue,LanguageCodes:q,QualityQuestionsRespondentTypes:K};if(!pt())throw _(E.MISSING_CREDENTIALS,"error",{endpoint:T,...e}),new Error(E.MISSING_CREDENTIALS);if(M())return oe;wr();try{let a=await gr({clientId:r,apiKey:n,endpoint:i});if(M())throw new Error;return _r({behaviorKey:a.behaviorKey}).then(()=>{let l=(performance.now()-t).toFixed();return _(`init() finishes ${l}ms`,"info",{endpoint:T,function:"init",diff:l,token:u.token}),{getSecurityResult:ae,getSecurityToken:ce,SecurityAPIError:dt,isAIUsageDetected:he,checkQualityQuestions:le,getQualityQuestions:ue,LanguageCodes:q,QualityQuestionsRespondentTypes:K}}).catch(p=>{throw new Error(p.message)})}catch(a){if(a instanceof Error){if(_(a.message,"error",{function:"init",endpoint:T,error:a,token:u.token}),a?.message?.includes("maintenance_mode"))throw new Error(E.MAINTENANCE_MODE);if([E.INVALID_API_KEY,E.UNAUTHORIZED].includes(a?.message))throw new Error(E.INVALID_CREDENTIALS)}throw new Error(E.SDK_INIT_ERROR)}finally{u={...u,isLoading:!1,token:c},S({state:u,securityKeys:{automationKey:D,behaviorKey:N}})}}oe={init:Rt,getSecurityResult:ae,getSecurityToken:ce,isAIUsageDetected:he,checkQualityQuestions:le,getQualityQuestions:ue,QualityQuestionsRespondentTypes:K,LanguageCodes:q};var Nr=oe;
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1 @@
|
|
|
1
|
-
function pr(e,t){return function(r,n){return Object.prototype.hasOwnProperty.call(r,n)}(e,t)?e[t]:void 0}function gr(e,t,r,n){let o=document,i="securitypolicyviolation",a,s=m=>{let u=new URL(e,location.href),{blockedURI:l}=m;l!==u.href&&l!==u.protocol.slice(0,-1)&&l!==u.origin||(a=m,c())};o.addEventListener(i,s);let c=()=>o.removeEventListener(i,s);return n?.then(c,c),Promise.resolve().then(t).then(m=>(c(),m),m=>new Promise(u=>{let l=new MessageChannel;l.port1.onmessage=()=>u(),l.port2.postMessage(null)}).then(()=>{if(c(),a)return r(a);throw m}))}function N(e){let t="";for(let r=0;r<e.length;++r)if(r>0){let n=e[r].toLowerCase();n!==e[r]?t+=` ${n}`:t+=e[r]}else t+=e[r].toUpperCase();return t}var yr={default:"endpoint"},Er={default:"tlsEndpoint"},wr="Client timeout",Ir="Network connection error",vr="Network request aborted",Rr="Response cannot be parsed",Se="Blocked by CSP",_e="The endpoint parameter is not a valid URL",br="Handle on demand agent data error",Tr=N("WrongRegion"),Or=N("SubscriptionNotActive"),Ar=N("UnsupportedVersion"),Dr=N("InstallationMethodRestricted"),Sr=N("HostnameRestricted"),_r=N("IntegrationFailed"),Pr=N("NetworkRestricted"),xr=N("InvalidProxyIntegrationSecret"),kr=N("InvalidProxyIntegrationHeaders"),Nr=N("ProxyIntegrationSecretEnvironmentMismatch"),Pe="API key required",ht="API key not found",pt="API key expired",Mr="Request cannot be parsed",Lr="Request failed",Cr="Request failed to process",Fr="Too many requests, rate limit exceeded",Ur="Not available for this origin",Br="Not available with restricted header",qr=Pe,Kr=ht,Gr=pt,Vr="3.12.0",oe="Failed to load the JS script of the agent",xe="9319";function jr(e,t){let r=[],[n,o]=function(s){let c=function(l){let d=[...l];return{current:()=>d[0],postpone(){let y=d.shift();y!==void 0&&d.push(y)},exclude(){d.shift()}}}(s),m=function(l,d){let y=0;return()=>Math.random()*Math.min(d,l*Math.pow(2,y++))}(100,3e3),u=new Set;return[c.current(),(l,d)=>{let y,E=d instanceof Error?d.message:"";if(E===Se||E===_e)c.exclude(),y=0;else if(E===xe)c.exclude();else if(E===oe){let w=Date.now()-l.getTime()<50,p=c.current();p&&w&&!u.has(p)&&(u.add(p),y=0),c.postpone()}else c.postpone();let f=c.current();return f===void 0?void 0:[f,y??l.getTime()+m()-Date.now()]}]}(e),i;if(n===void 0)return Promise.reject(new TypeError("The list of script URL patterns is empty"));let a=s=>{let c=new Date,m=l=>r.push({url:s,startedAt:c,finishedAt:new Date,error:l}),u=t(s);return u.then(()=>m(),m),u.catch(l=>{if(i!=null||(i=l),r.length>=5)throw i;let d=o(c,l);if(!d)throw i;let[y,E]=d;return(f=E,new Promise(w=>setTimeout(w,f))).then(()=>a(y));var f})};return a(n).then(s=>[s,r])}var gt="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",Wr=gt;function Qr(e){var t,r;let{picked:n,rest:o}=function(u,l){let d={},y={};for(let[E,f]of Object.entries(u))l.includes(E)?d[E]=f:y[E]=f;return{picked:d,rest:y}}(e,["scriptUrlPattern","token","apiKey"]),i=n.token,a=(t=n.apiKey)!==null&&t!==void 0?t:i,s=(r=pr(e,"scriptUrlPattern"))!==null&&r!==void 0?r:gt,[c,m]=function(){let u=[],l=()=>{u.push({time:new Date,state:document.visibilityState})},d=function(y,E,f,w){return y.addEventListener(E,f,w),()=>y.removeEventListener(E,f,w)}(document,"visibilitychange",l);return l(),[u,d]}();return Promise.resolve().then(()=>{if(!a||typeof a!="string")throw new Error(Pe);let u=function(l,d){return(Array.isArray(l)?l:[l]).map(y=>function(E,f){let w=encodeURIComponent;return E.replace(/<[^<>]+>/g,p=>p==="<version>"?"3":p==="<apiKey>"?w(f):p==="<loaderVersion>"?w(Vr):p)}(String(y),d))}(s,a);return jr(u,$r)}).catch(u=>{throw m(),function(l){return l instanceof Error&&l.message===xe?new Error(oe):l}(u)}).then(([u,l])=>(m(),u.load({...o,ldi:{attempts:l,visibilityStates:c}})))}function $r(e){return gr(e,()=>function(t){return new Promise((r,n)=>{if(function(s){if(URL.prototype)try{return new URL(s,location.href),!1}catch(c){if(c instanceof Error&&c.name==="TypeError")return!0;throw c}}(t))throw new Error(_e);let o=document.createElement("script"),i=()=>{var s;return(s=o.parentNode)===null||s===void 0?void 0:s.removeChild(o)},a=document.head||document.getElementsByTagName("head")[0];o.onload=()=>{i(),r()},o.onerror=()=>{i(),n(new Error(oe))},o.async=!0,o.src=t,a.appendChild(o)})}(e),()=>{throw new Error(Se)}).then(zr)}function zr(){let e=window,t="__fpjs_p_l_b",r=e[t];if(function(n,o){var i;let a=(i=Object.getOwnPropertyDescriptor)===null||i===void 0?void 0:i.call(Object,n,o);a?.configurable?delete n[o]:a&&!a.writable||(n[o]=void 0)}(e,t),typeof r?.load!="function")throw new Error(xe);return r}var G={load:Qr,defaultScriptUrlPattern:Wr,ERROR_SCRIPT_LOAD_FAIL:oe,ERROR_API_KEY_EXPIRED:pt,ERROR_API_KEY_INVALID:ht,ERROR_API_KEY_MISSING:Pe,ERROR_BAD_REQUEST_FORMAT:Mr,ERROR_BAD_RESPONSE_FORMAT:Rr,ERROR_CLIENT_TIMEOUT:wr,ERROR_CSP_BLOCK:Se,ERROR_FORBIDDEN_ENDPOINT:Sr,ERROR_FORBIDDEN_HEADER:Br,ERROR_FORBIDDEN_ORIGIN:Ur,ERROR_GENERAL_SERVER_FAILURE:Lr,ERROR_HANDLE_AGENT_DATA:br,ERROR_INSTALLATION_METHOD_RESTRICTED:Dr,ERROR_INTEGRATION_FAILURE:_r,ERROR_INVALID_ENDPOINT:_e,ERROR_INVALID_PROXY_INTEGRATION_HEADERS:kr,ERROR_INVALID_PROXY_INTEGRATION_SECRET:xr,ERROR_NETWORK_ABORT:vr,ERROR_NETWORK_CONNECTION:Ir,ERROR_NETWORK_RESTRICTED:Pr,ERROR_PROXY_INTEGRATION_SECRET_ENVIRONMENT_MISMATCH:Nr,ERROR_RATE_LIMIT:Fr,ERROR_SERVER_TIMEOUT:Cr,ERROR_SUBSCRIPTION_NOT_ACTIVE:Or,ERROR_TOKEN_EXPIRED:Gr,ERROR_TOKEN_INVALID:Kr,ERROR_TOKEN_MISSING:qr,ERROR_UNSUPPORTED_VERSION:Ar,ERROR_WRONG_REGION:Tr,defaultEndpoint:yr,defaultTlsEndpoint:Er};var T=[];for(let e=0;e<256;++e)T.push((e+256).toString(16).slice(1));function yt(e,t=0){return(T[e[t+0]]+T[e[t+1]]+T[e[t+2]]+T[e[t+3]]+"-"+T[e[t+4]]+T[e[t+5]]+"-"+T[e[t+6]]+T[e[t+7]]+"-"+T[e[t+8]]+T[e[t+9]]+"-"+T[e[t+10]]+T[e[t+11]]+T[e[t+12]]+T[e[t+13]]+T[e[t+14]]+T[e[t+15]]).toLowerCase()}var ke,Yr=new Uint8Array(16);function Ne(){if(!ke){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ke=crypto.getRandomValues.bind(crypto)}return ke(Yr)}var Xr=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Me={randomUUID:Xr};function Jr(e,t,r){if(Me.randomUUID&&!t&&!e)return Me.randomUUID();e=e||{};let n=e.random??e.rng?.()??Ne();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){if(r=r||0,r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let o=0;o<16;++o)t[r+o]=n[o];return t}return yt(n)}var z=Jr;var Zr={UNAUTHORIZED:"Unauthorized"},Hr={EXPIRED:"EXPIRED_TOKEN",INVALID_API_KEY:"INVALID_API_KEY",MISSING_AUTHENTICATION_TOKEN:"MISSING_AUTHENTICATION_TOKEN"},Et={INTERNAL_SERVER_ERROR:"Internal Server Error during API Request",MISSING_CREDENTIALS:"Missing Public Client ID or Public API Key",MAINTENANCE_MODE:"API Under Maintenance",RATE_LIMIT_REACHED:"Too many requests. Rate limit exceeded"},wt={SDK_INIT_ERROR:"Internal Server Error during SDK Initialization",DUPLICATE_INITIALIZATION:"Multiple SDK Initializations Detected",NOT_INITIALIZED:"SDK Not Initialized"},It={INVALID_CREDENTIALS:"Invalid Public Client ID or Public API Key"},vt={FAILED_TO_GET_SECURITY_RESULT:"Failed to Retrieve Security Result"},Rt={FAILED_TO_GET_SECURITY_TOKEN:" Failed to Generate Security Token"},v={...Zr,...Hr,...Et,...wt,...It,...vt,...Rt},bt={...Et,...wt,...It,...vt,...Rt};var Y=(p=>(p.AR="ar",p.BN="bn",p.DE="de",p.EN="en",p.ES="es",p.FR="fr",p.HI="hi",p.ID="id",p.IT="it",p.JA="ja",p.KO="ko",p.MS="ms",p.NL="nl",p.PT="pt",p.RU="ru",p.YU="yu",p.ZH="zh",p))(Y||{}),X=(I=>(I.GeneralConsumer="general-consumer",I.HRManagerDirector="hr-manager-director",I.WebDeveloper="web-developer",I.SoftwareEngineer="software-engineer",I.ITDirector="it-director",I.BusinessAdministrator="business-administrator",I.AccountsPayableManager="accounts-payable-manager",I.Accountant="accountant",I.FinanceDirector="finance-director",I.SmallBusinessOwner="small-business-owner",I.GeneralContractor="general-contractor",I.MarketingManagerDirector="marketing-manager-director",I.ConsumerShopper="consumer-shopper",I.Travel="travel",I.Entertainment="entertainment",I.FinanceAndBanking="finance-and-banking",I.General="general",I.B2BWhiteCollar="b2b-white-collar",I.B2BBlueCollar="b2b-blue-collar",I.Lawyer="lawyer",I))(X||{});var V={exclude:[],include:[],stabilize:["private","iframe"],logging:!0,timeout:5e3,cache_api_call:!0,performance:!1,experimental:!1},Do={...V},Le={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"]}]};async function Ce(){return en()}async function en(){return new Promise((t,r)=>{try{let i=new(window.OfflineAudioContext||window.webkitOfflineAudioContext)(1,5e3,44100),a=i?.createBufferSource(),s=i.createOscillator();s.frequency.value=1e3;let c=i.createDynamicsCompressor();c.threshold.value=-50,c.knee.value=40,c.ratio.value=12,c.attack.value=0,c.release.value=.2,s.connect(c),c.connect(i.destination),s.start();let m;i.oncomplete=u=>{m=u.renderedBuffer.getChannelData(0),t({sampleHash:tn(m),maxChannels:i.destination.maxChannelCount,channelCountMode:a.channelCountMode})},i.startRendering()}catch(n){console.error("Error creating audio fingerprint:",n),r(n)}})}function tn(e){let t=0;for(let r=0;r<e.length;++r)t+=Math.abs(e[r]);return t}function ie(e,t,r){let n=[];for(let a=0;a<e[0].data.length;a++){let s=[];for(let c=0;c<e.length;c++)s.push(e[c].data[a]);n.push(rn(s))}let o=n,i=new Uint8ClampedArray(o);return new ImageData(i,t,r)}function rn(e){if(e.length===0)return 0;let t={};for(let n of e)t[n]=(t[n]||0)+1;let r=e[0];for(let n in t)t[n]>t[r]&&(r=parseInt(n,10));return r}function nn(e){return new TextEncoder().encode(e).buffer}function se(e){return e^=e>>>16,e=Math.imul(e,2246822507),e^=e>>>13,e=Math.imul(e,3266489909),e^=e>>>16,e>>>0}var A=new Uint32Array([597399067,2869860233,951274213,2716044179]);function x(e,t){return e<<t|e>>>32-t}function on(e,t){let r=e.byteLength/16|0,n=new Uint32Array(e,0,r*4);for(let o=0;o<r;o++){let i=n.subarray(o*4,(o+1)*4);i[0]=Math.imul(i[0],A[0]),i[0]=x(i[0],15),i[0]=Math.imul(i[0],A[1]),t[0]=t[0]^i[0],t[0]=x(t[0],19),t[0]=t[0]+t[1],t[0]=Math.imul(t[0],5)+1444728091,i[1]=Math.imul(i[1],A[1]),i[1]=x(i[1],16),i[1]=Math.imul(i[1],A[2]),t[1]=t[1]^i[1],t[1]=x(t[1],17),t[1]=t[1]+t[2],t[1]=Math.imul(t[1],5)+197830471,i[2]=Math.imul(i[2],A[2]),i[2]=x(i[2],17),i[2]=Math.imul(i[2],A[3]),t[2]=t[2]^i[2],t[2]=x(t[2],15),t[2]=t[2]+t[3],t[2]=Math.imul(t[2],5)+2530024501,i[3]=Math.imul(i[3],A[3]),i[3]=x(i[3],18),i[3]=Math.imul(i[3],A[0]),t[3]=t[3]^i[3],t[3]=x(t[3],13),t[3]=t[3]+t[0],t[3]=Math.imul(t[3],5)+850148119}}function sn(e,t){let r=e.byteLength/16|0,n=e.byteLength%16,o=new Uint32Array(4),i=new Uint8Array(e,r*16,n);switch(n){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]<<0,o[3]=Math.imul(o[3],A[3]),o[3]=x(o[3],18),o[3]=Math.imul(o[3],A[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]<<0,o[2]=Math.imul(o[2],A[2]),o[2]=x(o[2],17),o[2]=Math.imul(o[2],A[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]<<0,o[1]=Math.imul(o[1],A[1]),o[1]=x(o[1],16),o[1]=Math.imul(o[1],A[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]<<0,o[0]=Math.imul(o[0],A[0]),o[0]=x(o[0],15),o[0]=Math.imul(o[0],A[1]),t[0]=t[0]^o[0]}}function an(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]=se(t[0]),t[1]=se(t[1]),t[2]=se(t[2]),t[3]=se(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}function O(e,t=0){if(t=t?t|0:0,typeof e=="string"&&(e=nn(e)),!(e instanceof ArrayBuffer))throw new TypeError("Expected key to be ArrayBuffer or string");let r=new Uint32Array([t,t,t,t]);on(e,r),sn(e,r),an(e,r);let n=new Uint8Array(r.buffer);return Array.from(n).map(o=>o.toString(16).padStart(2,"0")).join("")}var cn=3,Tt=280,Ot=20;async function Fe(){return un()}function un(){return new Promise(e=>{let t=Array.from({length:cn},()=>ln()),r=ie(t,Tt,Ot);e({commonPixelsHash:O(r.data.toString()).toString()})})}function ln(){let e=document.createElement("canvas"),t=e.getContext("2d");if(!t)return new ImageData(1,1);e.width=Tt,e.height=Ot;let r=t.createLinearGradient(0,0,e.width,e.height);r.addColorStop(0,"red"),r.addColorStop(1/6,"orange"),r.addColorStop(2/6,"yellow"),r.addColorStop(3/6,"green"),r.addColorStop(4/6,"blue"),r.addColorStop(5/6,"indigo"),r.addColorStop(1,"violet"),t.fillStyle=r,t.fillRect(0,0,e.width,e.height);let n="Random Text WMwmil10Oo";return t.font="23.123px Arial",t.fillStyle="black",t.fillText(n,-5,15),t.fillStyle="rgba(0, 0, 255, 0.5)",t.fillText(n,-3.3,17.7),t.beginPath(),t.moveTo(0,0),t.lineTo(e.width*2/7,e.height),t.strokeStyle="white",t.lineWidth=2,t.stroke(),t.getImageData(0,0,e.width,e.height)}async function ae(e){for(;!document.body;)await mn(50);let t=document.createElement("iframe");t.setAttribute("frameBorder","0");let r=t.style;r.setProperty("position","fixed"),r.setProperty("display","block","important"),r.setProperty("visibility","visible"),r.setProperty("border","0"),r.setProperty("opacity","0"),t.src="about:blank",document.body.appendChild(t);let n=t.contentDocument||t.contentWindow?.document;if(!n)throw new Error("Iframe document is not accessible");e({iframe:n}),setTimeout(()=>{document.body.removeChild(t)},0)}function mn(e,t){return new Promise(r=>setTimeout(r,e,t))}var dn=["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"],fn=["monospace","sans-serif","serif"];async function Ue(e){return hn()}function hn(){return new Promise((e,t)=>{try{ae(async({iframe:r})=>{let o=r.createElement("canvas").getContext("2d"),i=fn.map(s=>At(o,s)),a={};dn.forEach(s=>{let c=At(o,s);i.includes(c)||(a[s]=c)}),e(a)})}catch{t({error:"unsupported"})}})}function At(e,t){if(!e)return null;let r="WwMmLli0Oo";return e.font=`72px ${t}`,e.measureText(r).width}function Be(){return new Promise((e,t)=>{let r=navigator.deviceMemory!==void 0?navigator.deviceMemory:0,n=window.performance&&window.performance.memory?window.performance.memory:0;e({videocard:pn(),architecture:gn(),deviceMemory:r.toString()||"undefined",jsHeapSizeLimit:n.jsHeapSizeLimit||0})})}function pn(){let e=document.createElement("canvas"),t=e.getContext("webgl")??e.getContext("experimental-webgl");if(t&&"getParameter"in t)try{let r=(t.getParameter(t.VENDOR)||"").toString(),n=(t.getParameter(t.RENDERER)||"").toString(),o={vendor:r,renderer:n,version:(t.getParameter(t.VERSION)||"").toString(),shadingLanguageVersion:(t.getParameter(t.SHADING_LANGUAGE_VERSION)||"").toString()};if(!n.length||!r.length){let i=t.getExtension("WEBGL_debug_renderer_info");if(i){let a=(t.getParameter(i.UNMASKED_VENDOR_WEBGL)||"").toString(),s=(t.getParameter(i.UNMASKED_RENDERER_WEBGL)||"").toString();a&&(o.vendorUnmasked=a),s&&(o.rendererUnmasked=s)}}return o}catch{}return"undefined"}function gn(){let e=new Float32Array(1),t=new Uint8Array(e.buffer);return e[0]=1/0,e[0]=e[0]-e[0],t[3]}function qe(){return new Promise(e=>{e({languages:yn(),timezone:En()})})}function yn(){let e=[];return navigator.language}function En(){return Intl.DateTimeFormat().resolvedOptions().timeZone}var ce=(e,t,r,n)=>{let o=(r-t)/n,i=0;for(let a=0;a<n;a++){let s=t+(a+.5)*o;i+=e(s)}return i*o};function Ke(){return new Promise(e=>{e({acos:Math.acos(.5),asin:ce(Math.asin,-1,1,97),cos:ce(Math.cos,0,Math.PI,97),largeCos:Math.cos(1e20),largeSin:Math.sin(1e20),largeTan:Math.tan(1e20),sin:ce(Math.sin,-Math.PI,Math.PI,97),tan:ce(Math.tan,0,2*Math.PI,97)})})}function wn(e){if(e.length===0)return null;let t={};e.forEach(o=>{let i=String(o);t[i]=(t[i]||0)+1});let r=e[0],n=1;return Object.keys(t).forEach(o=>{t[o]>n&&(r=o,n=t[o])}),r}function Dt(e,t){let r={};return t.forEach(n=>{let o=e.map(a=>n in a?a[n]:void 0).filter(a=>a!==void 0),i=wn(o);i&&(r[n]=i)}),r}var In=["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"];async function Ge(e){let t=e?.permissions_to_check||In,n=await Promise.all(Array.from({length:3},()=>vn(t)));return Dt(n,t)}async function vn(e){let t={};for(let r of e)try{let n=await navigator.permissions.query({name:r});t[r]=n.state.toString()}catch{}return t}async function Ve(){let e=[];if(navigator.plugins)for(let t=0;t<navigator.plugins.length;t++){let r=navigator.plugins[t];e.push([r.name,r.filename,r.description].join("|"))}return new Promise(t=>{t({plugins:e})})}function j(){if(typeof navigator>"u")return{name:"unknown",version:"unknown"};let e=navigator.userAgent,t=[/(?<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>Brave)\/(?<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+)+)/],r={edg:"Edge",edga:"Edge",edgios:"Edge",opr:"Opera",opx:"Opera",crios:"Chrome",fxios:"Firefox",samsung:"SamsungBrowser",vivaldi:"Vivaldi",brave:"Brave"};for(let n of t){let o=e.match(n);if(o){let i=o.groups?.name,a=o.groups?.version||o.groups?.version1||o.groups?.version2;if(!i&&(o.groups?.version1||o.groups?.version2)&&(i="Safari"),!i&&n.source.includes("Opera Mini")&&(i="Opera Mini"),!i&&n.source.includes("Opera Mobi")&&(i="Opera Mobi"),!i&&n.source.includes("Opera")&&(i="Opera"),!i&&o[1]&&(i=o[1]),!a&&o[2]&&(a=o[2]),i)return{name:r[i.toLowerCase()]||i,version:a||"unknown"}}}return{name:"unknown",version:"unknown"}}function ue(){if(typeof navigator>"u"||!navigator.userAgent)return!1;let 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 je(){return new Promise(e=>{let t={is_touchscreen:navigator.maxTouchPoints>0,maxTouchPoints:navigator.maxTouchPoints,colorDepth:screen.colorDepth,mediaMatches:bn()};ue()&&navigator.maxTouchPoints>0&&(t.resolution=Rn()),e(t)})}function Rn(){let e=window.screen.width,t=window.screen.height,r=Math.max(e,t).toString(),n=Math.min(e,t).toString();return`${r}x${n}`}function bn(){let e=[],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(r=>{t[r].forEach(n=>{matchMedia(`(${r}: ${n})`).matches&&e.push(`${r}: ${n}`)})}),e}function We(){return new Promise(e=>{let t=j(),r=navigator.userAgent,n={platform:window.navigator.platform,productSub:navigator.productSub,product:navigator.product,useragent:navigator.userAgent,hardwareConcurrency:navigator.hardwareConcurrency,browser:{name:t.name,version:t.version},mobile:ue(),applePayVersion:Tn(),cookieEnabled:window.navigator.cookieEnabled};e(n)})}function Tn(){if(window.location.protocol==="https:"&&typeof window.ApplePaySession=="function")try{let e=window.ApplePaySession.supportsVersion;for(let t=15;t>0;t--)if(e(t))return t}catch{return 0}return 0}var On=j().name!=="SamsungBrowser"?1:3,D,h=null;function An(){typeof document<"u"&&(D=document.createElement("canvas"),D.width=200,D.height=100,h=D.getContext("webgl"))}async function Qe(){An();try{if(!h)throw new Error("WebGL not supported");let e=Array.from({length:On},()=>Dn()),t=ie(e,D.width,D.height);return{commonPixelsHash:O(t.data.toString()).toString()}}catch{return{webgl:"unsupported"}}}function Dn(){try{if(!h)throw new Error("WebGL not supported");let e=`
|
|
2
|
-
attribute vec2 position;
|
|
3
|
-
void main() {
|
|
4
|
-
gl_Position = vec4(position, 0.0, 1.0);
|
|
5
|
-
}
|
|
6
|
-
`,t=`
|
|
7
|
-
precision mediump float;
|
|
8
|
-
void main() {
|
|
9
|
-
gl_FragColor = vec4(0.812, 0.195, 0.553, 0.921); // Set line color
|
|
10
|
-
}
|
|
11
|
-
`,r=h.createShader(h.VERTEX_SHADER),n=h.createShader(h.FRAGMENT_SHADER);if(!r||!n)throw new Error("Failed to create shaders");if(h.shaderSource(r,e),h.shaderSource(n,t),h.compileShader(r),!h.getShaderParameter(r,h.COMPILE_STATUS))throw new Error("Vertex shader compilation failed: "+h.getShaderInfoLog(r));if(h.compileShader(n),!h.getShaderParameter(n,h.COMPILE_STATUS))throw new Error("Fragment shader compilation failed: "+h.getShaderInfoLog(n));let o=h.createProgram();if(!o)throw new Error("Failed to create shader program");if(h.attachShader(o,r),h.attachShader(o,n),h.linkProgram(o),!h.getProgramParameter(o,h.LINK_STATUS))throw new Error("Shader program linking failed: "+h.getProgramInfoLog(o));h.useProgram(o);let i=137,a=new Float32Array(i*4),s=2*Math.PI/i;for(let d=0;d<i;d++){let y=d*s;a[d*4]=0,a[d*4+1]=0,a[d*4+2]=Math.cos(y)*(D.width/2),a[d*4+3]=Math.sin(y)*(D.height/2)}let c=h.createBuffer();h.bindBuffer(h.ARRAY_BUFFER,c),h.bufferData(h.ARRAY_BUFFER,a,h.STATIC_DRAW);let m=h.getAttribLocation(o,"position");h.enableVertexAttribArray(m),h.vertexAttribPointer(m,2,h.FLOAT,!1,0,0),h.viewport(0,0,D.width,D.height),h.clearColor(0,0,0,1),h.clear(h.COLOR_BUFFER_BIT),h.drawArrays(h.LINES,0,i*2);let u=new Uint8ClampedArray(D.width*D.height*4);return h.readPixels(0,0,D.width,D.height,h.RGBA,h.UNSIGNED_BYTE,u),new ImageData(u,D.width,D.height)}catch{return new ImageData(1,1)}finally{h&&(h.bindBuffer(h.ARRAY_BUFFER,null),h.useProgram(null),h.viewport(0,0,h.drawingBufferWidth,h.drawingBufferHeight),h.clearColor(0,0,0,0))}}function _(e){let t=[];return function r(n){if(n&&n.toJSON&&typeof n.toJSON=="function"&&(n=n.toJSON()),n===void 0)return;if(typeof n=="number")return isFinite(n)?""+n:"null";if(typeof n!="object")return JSON.stringify(n);let o,i;if(Array.isArray(n)){for(i="[",o=0;o<n.length;o++)o&&(i+=","),i+=r(n[o])||"null";return i+"]"}if(n===null)return"null";if(t.indexOf(n)!==-1)throw new TypeError("Converting circular structure to JSON");let a=t.push(n)-1,s=Object.keys(n).sort();for(i="",o=0;o<s.length;o++){let c=s[o],m=r(n[c]);m&&(i&&(i+=","),i+=JSON.stringify(c)+":"+m)}return t.splice(a,1),"{"+i+"}"}(e)||""}async function $e(){return new Promise(e=>{try{let t=window.RTCPeerConnection||window.webkitRTCPeerConnection||window.mozRTCPeerConnection;if(!t){e({supported:!1,error:"WebRTC not supported"});return}let r={iceCandidatePoolSize:1,iceServers:[]},n=new t(r);n.createDataChannel(""),(async()=>{try{let i={offerToReceiveAudio:!0,offerToReceiveVideo:!0},a=await n.createOffer(i);await n.setLocalDescription(a);let s=a.sdp||"",c=[...new Set((s.match(/extmap:\d+ [^\n\r]+/g)||[]).map(f=>f.replace(/extmap:\d+ /,"")))].sort(),m=f=>{let w=s.match(new RegExp(`m=${f} [^\\s]+ [^\\s]+ ([^\\n\\r]+)`));return w?w[1].split(" "):[]},u=(f,w)=>w.map(p=>{let b=new RegExp(`(rtpmap|fmtp|rtcp-fb):${p} (.+)`,"g"),S=[...s.matchAll(b)];if(!S.length)return null;let I={};return S.forEach(Te=>{let[io,Oe,Ae]=Te,De=Ae.split("/");Oe==="rtpmap"?(I.mimeType=`${f}/${De[0]}`,I.clockRate=+De[1],f==="audio"&&(I.channels=+De[2]||1)):Oe==="rtcp-fb"?(I.feedbackSupport=I.feedbackSupport||[],I.feedbackSupport.push(Ae)):Oe==="fmtp"&&(I.sdpFmtpLine=Ae)}),I}).filter(Boolean),l=u("audio",m("audio")),d=u("video",m("video")),y={audio:{count:l.length,hash:O(_(l))},video:{count:d.length,hash:O(_(d))},extensionsHash:O(_(c))},E=await new Promise(f=>{let w=setTimeout(()=>{n.removeEventListener("icecandidate",p),n.close(),f({supported:!0,...y,timeout:!0})},3e3),p=b=>{let S=b.candidate;!S||!S.candidate||(clearTimeout(w),n.removeEventListener("icecandidate",p),n.close(),f({supported:!0,...y,candidateType:S.type||""}))};n.addEventListener("icecandidate",p)});e({details:E,hash:O(_(E))})}catch(i){n.close(),e({supported:!0,error:`WebRTC offer failed: ${i.message}`})}})()}catch(t){e({supported:!1,error:`WebRTC error: ${t.message}`})}})}var St=["\u{1D504}","\u{1D505}","\u212D","\u{1D507}","\u{1D508}","\u{1D509}","\u{1D538}","\u{1D539}","\u2102","\u{1D53B}","\u{1D53C}","\u{1D53D}"],_t=["\u03B2","\u03C8","\u03BB","\u03B5","\u03B6","\u03B1","\u03BE","\u03BC","\u03C1","\u03C6","\u03BA","\u03C4","\u03B7","\u03C3","\u03B9","\u03C9","\u03B3","\u03BD","\u03C7","\u03B4","\u03B8","\u03C0","\u03C5","\u03BF"];async function ze(){return new Promise(e=>{try{ae(async({iframe:t})=>{try{if(!Sn(t)){e({supported:!1,error:"MathML not supported"});return}let r=[J("integral","<msubsup><mo>\u222B</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>"),J("fraction","<mfrac><mrow><mi>\u03C0</mi><mo>\xD7</mo><msup><mi>r</mi><mn>2</mn></msup></mrow><mrow><mn>2</mn><mi>\u03C3</mi></mrow></mfrac>"),J("matrix","<mo>[</mo><mtable><mtr><mtd><mi>\u03B1</mi></mtd><mtd><mi>\u03B2</mi></mtd></mtr><mtr><mtd><mi>\u03B3</mi></mtd><mtd><mi>\u03B4</mi></mtd></mtr></mtable><mo>]</mo>"),_n(),...Pn()],n=[],o="";r.forEach((a,s)=>{let c=xn(a,t);n.push({width:c.dimensions.width,height:c.dimensions.height}),s===0&&c.fontInfo&&(o=O(_(c.fontInfo)))});let i={fontStyleHash:o,dimensions:n};e({details:i,hash:O(_(i))})}catch(r){e({supported:!1,error:`MathML error: ${r.message}`})}})}catch(t){e({supported:!1,error:`MathML error: ${t.message}`})}})}function Sn(e){try{let t=e.createElement("math");t.innerHTML="<mrow><mi>x</mi></mrow>",t.style.position="absolute",t.style.visibility="hidden",e.body.appendChild(t);let r=t.getBoundingClientRect();return e.body.removeChild(t),r.width>0&&r.height>0}catch{return!1}}function J(e,t){return`<math><mrow>${t}</mrow></math>`}function _n(){let e="<mo>\u220F</mo>";return St.forEach((t,r)=>{let n=r*2,o=_t.slice(n,n+2);o.length===2&&(e+=`<mmultiscripts><mi>${t}</mi><none/><mi>${o[1]}</mi><mprescripts></mprescripts><mi>${o[0]}</mi><none/></mmultiscripts>`)}),J("complex_nested",`<munderover><mmultiscripts>${e}</mmultiscripts></munderover>`)}function Pn(){let e=[];return St.forEach((t,r)=>{let n=r*2,o=_t.slice(n,n+2);o.length===2&&e.push(J("combined",`<mmultiscripts><mi>${t}</mi><none/><mi>${o[1]}</mi><mprescripts></mprescripts><mi>${o[0]}</mi><none/></mmultiscripts>`))}),e}function xn(e,t){try{let r=t.createElement("math");r.innerHTML=e.replace(/<\/?math>/g,""),r.style.whiteSpace="nowrap",r.style.position="absolute",r.style.visibility="hidden",r.style.top="-9999px",t.body.appendChild(r);let n=r.getBoundingClientRect(),i=(t.defaultView||window).getComputedStyle(r),a={dimensions:{width:n.width,height:n.height},fontInfo:{fontFamily:i.fontFamily,fontSize:i.fontSize,fontWeight:i.fontWeight,fontStyle:i.fontStyle,lineHeight:i.lineHeight,fontVariant:i.fontVariant||"normal",fontStretch:i.fontStretch||"normal",fontSizeAdjust:i.fontSizeAdjust||"none",textRendering:i.textRendering||"auto",fontFeatureSettings:i.fontFeatureSettings||"normal",fontVariantNumeric:i.fontVariantNumeric||"normal",fontKerning:i.fontKerning||"auto"}};return t.body.removeChild(r),a}catch(r){return{error:r.message}}}var kn=800;async function Ye(){return new Promise(e=>{try{if(typeof window>"u"||!window.speechSynthesis||typeof window.speechSynthesis.getVoices!="function"){e({supported:!1,error:"Speech Synthesis API not supported"});return}let t=!1,r=null,n=a=>{if(!t){t=!0,r&&clearTimeout(r);try{let s=a.map(m=>{let u=d=>d.replace(/\\/g,"\\\\").replace(/,/g,"\\,");return[u(m.voiceURI||""),u(m.name||""),u(m.lang||""),m.localService?"1":"0",m.default?"1":"0"].join(",")});s.sort();let c={voiceCount:a.length,voicesHash:O(_(s))};e({details:c,hash:O(_(c))})}catch(s){e({supported:!0,error:`Voice processing failed: ${s.message}`})}}},o=window.speechSynthesis.getVoices();if(o.length>0){n(o);return}r=setTimeout(()=>{let a=window.speechSynthesis.getVoices();n(a)},kn);let i=()=>{window.speechSynthesis.removeEventListener("voiceschanged",i);let a=window.speechSynthesis.getVoices();n(a)};window.speechSynthesis.addEventListener("voiceschanged",i)}catch(t){e({supported:!1,error:`Speech Synthesis error: ${t.message}`})}})}var Pt={audio:Ce,canvas:Fe,fonts:Ue,hardware:Be,locales:qe,math:Ke,permissions:Ge,plugins:Ve,screen:je,system:We,webgl:Qe},xt={webrtc:$e,mathml:ze,speech:Ye},Xe={},kt={timeout:"true"},Je=(e,t,r)=>{Xe[e]=t};function Nn(e,t){return new Promise(r=>{setTimeout(()=>r(t),e)})}function Nt(e,t,r){return Promise.all(e.map(n=>{let o=performance.now();return Promise.race([n.then(i=>({value:i,elapsed:performance.now()-o})),Nn(t,r).then(i=>({value:i,elapsed:performance.now()-o}))])}))}function le(e,t){let r=j();if(r.name==="unknown"&&e.system&&typeof e.system=="object"&&!Array.isArray(e.system)){let l=e.system.browser;if(l&&typeof l=="object"&&!Array.isArray(l)){let d=l;r={name:d.name||"unknown",version:d.version||"unknown"}}}let n=r.name.toLowerCase(),o=r.version.split(".")[0]||"0",i=parseInt(o,10),a=[...t?.exclude||[]],s=t?.stabilize||[],c=t?.include||[];for(let u of s){let l=Le[u];if(l)for(let d of l){let y=!("browsers"in d),E=!y&&d.browsers?.some(f=>{let w=f.match(/(.+?)(>=)(\d+)/);if(w){let[,p,,b]=w,S=parseInt(b,10);return n===p&&i>=S}return n===f});(y||E)&&a.push(...d.exclude)}}function m(u,l=""){let d={};for(let[y,E]of Object.entries(u)){let f=l?`${l}.${y}`:y;if(typeof E=="object"&&!Array.isArray(E)&&E!==null){let w=m(E,f);Object.keys(w).length>0&&(d[y]=w)}else{let w=a.some(b=>f.startsWith(b)),p=c.some(b=>f.startsWith(b));(!w||p)&&(d[y]=E)}}return d}return m(e)}async function Ze(e){let t={...V,...e},r=t.logging&&!sessionStorage.getItem("_tmjs_l")&&Math.random()<1e-4,n={...Pt,...Xe},{elapsed:o,resolvedComponents:i}=await Mt(n,t),a={},s={};if(r||t.experimental){let{elapsed:w,resolvedComponents:p}=await Mt(xt,t);a=p,s=w}let c={...o,...s},m=t.performance?{elapsed:c}:{},u=le({},t),l={...i,...u},d={};return{thumbmark:O(_(l)),components:l,info:d,version:"",...m,...Object.keys(a).length>0&&t.experimental&&{experimental:a}}}async function Mt(e,t){let r={...V,...t},n=Object.entries(e).filter(([u])=>!r?.exclude?.includes(u)).filter(([u])=>r?.include?.some(l=>l.includes("."))?r?.include?.some(l=>l.startsWith(u)):r?.include?.length===0||r?.include?.includes(u)),o=n.map(([u])=>u),i=n.map(([u,l])=>l(t)),a=await Nt(i,r?.timeout||5e3,kt),s={},c={};a.forEach((u,l)=>{u.value!=null&&(c[o[l]]=u.value,s[o[l]]=u.elapsed??0)});let m=le(c,r);return{elapsed:s,resolvedComponents:m}}var Z=class{options;constructor(t){this.options={...V,...t}}async get(t){let r={...this.options,...t};return Ze(r)}getVersion(){return""}includeComponent(t,r){Je(t,r)}};var Mn=(e,t={})=>({"Content-Type":"application/json",...e?.accessToken&&{Authorization:`Bearer ${e?.accessToken}`},...t}),Ln=async(e,t)=>{if(!e.ok){let r=await e.text();throw new Error(r)}return t==="file"?e.blob():t==="json"?e.json():t==="text"?e.text():null},Lt=async({url:e,auth:t,body:r,method:n="GET",headers:o={},responseType:i="json"})=>{let a={method:n,headers:Mn(t,o),...r?{body:r instanceof FormData?r:JSON.stringify(r)}:{}},s=await fetch(e,a);return Ln(s,i)},He=e=>Lt({...e,method:"GET"}),me=e=>Lt({...e,method:"POST"});function Ct(e){let t=e?.qbc||!1,r=e?.mas||!1,n=e?.apd||!1,o=e?.scb||null,i=0,a=()=>{t=!1,r=!1,n=!1,o=void 0,i=0},s=()=>{let l=window?.getSelection()?.toString();l&&l.length>0&&(i=Date.now(),t=!0)},c=u=>{let l=u.clipboardData?.getData("text"),d=u.target instanceof HTMLInputElement||u.target instanceof HTMLTextAreaElement;l&&d&&(n=!0)},m=()=>{r=!0;let u=Date.now();if(i){let l=(u-i)/1e3;(o===void 0||l<o)&&(o=l)}};return document?.addEventListener("copy",s),document?.addEventListener("paste",c),window?.addEventListener("blur",m),{get qbc(){return t},get mas(){return r},get apd(){return n},get scb(){return o},reset:a,destroy(){document?.removeEventListener("copy",s),document?.removeEventListener("paste",c),window?.removeEventListener("blur",m)}}}var L=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var C=typeof window>"u"||"Deno"in globalThis;function P(){}function Bt(e,t){return typeof e=="function"?e(t):e}function qt(e){return typeof e=="number"&&e>=0&&e!==1/0}function Kt(e,t){return Math.max(e+(t||0)-Date.now(),0)}function tt(e,t){return typeof e=="function"?e(t):e}function Gt(e,t){return typeof e=="function"?e(t):e}function rt(e,t){let{type:r="all",exact:n,fetchStatus:o,predicate:i,queryKey:a,stale:s}=e;if(a){if(n){if(t.queryHash!==H(a,t.options))return!1}else if(!Q(t.queryKey,a))return!1}if(r!=="all"){let c=t.isActive();if(r==="active"&&!c||r==="inactive"&&c)return!1}return!(typeof s=="boolean"&&t.isStale()!==s||o&&o!==t.state.fetchStatus||i&&!i(t))}function nt(e,t){let{exact:r,status:n,predicate:o,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(r){if(W(t.options.mutationKey)!==W(i))return!1}else if(!Q(t.options.mutationKey,i))return!1}return!(n&&t.state.status!==n||o&&!o(t))}function H(e,t){return(t?.queryKeyHashFn||W)(e)}function W(e){return JSON.stringify(e,(t,r)=>et(r)?Object.keys(r).sort().reduce((n,o)=>(n[o]=r[o],n),{}):r)}function Q(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(r=>!Q(e[r],t[r])):!1}function Vt(e,t){if(e===t)return e;let r=Ft(e)&&Ft(t);if(r||et(e)&&et(t)){let n=r?e:Object.keys(e),o=n.length,i=r?t:Object.keys(t),a=i.length,s=r?[]:{},c=0;for(let m=0;m<a;m++){let u=r?m:i[m];(!r&&n.includes(u)||r)&&e[u]===void 0&&t[u]===void 0?(s[u]=void 0,c++):(s[u]=Vt(e[u],t[u]),s[u]===e[u]&&e[u]!==void 0&&c++)}return o===a&&c===o?e:s}return t}function Ft(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function et(e){if(!Ut(e))return!1;let t=e.constructor;if(t===void 0)return!0;let r=t.prototype;return!(!Ut(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Ut(e){return Object.prototype.toString.call(e)==="[object Object]"}function jt(e){return new Promise(t=>{setTimeout(t,e)})}function Wt(e,t,r){return typeof r.structuralSharing=="function"?r.structuralSharing(e,t):r.structuralSharing!==!1?Vt(e,t):t}function Qt(e,t,r=0){let n=[...e,t];return r&&n.length>r?n.slice(1):n}function $t(e,t,r=0){let n=[t,...e];return r&&n.length>r?n.slice(0,-1):n}var ee=Symbol();function de(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===ee?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var Cn=class extends L{#e;#t;#r;constructor(){super(),this.#r=e=>{if(!C&&window.addEventListener){let t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},fe=new Cn;var Fn=class extends L{#e=!0;#t;#r;constructor(){super(),this.#r=e=>{if(!C&&window.addEventListener){let t=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(r=>{r(e)}))}isOnline(){return this.#e}},$=new Fn;function zt(){let e,t,r=new Promise((o,i)=>{e=o,t=i});r.status="pending",r.catch(()=>{});function n(o){Object.assign(r,o),delete r.resolve,delete r.reject}return r.resolve=o=>{n({status:"fulfilled",value:o}),e(o)},r.reject=o=>{n({status:"rejected",reason:o}),t(o)},r}function Un(e){return Math.min(1e3*2**e,3e4)}function ot(e){return(e??"online")==="online"?$.isOnline():!0}var Yt=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function he(e){return e instanceof Yt}function pe(e){let t=!1,r=0,n=!1,o,i=zt(),a=f=>{n||(d(new Yt(f)),e.abort?.())},s=()=>{t=!0},c=()=>{t=!1},m=()=>fe.isFocused()&&(e.networkMode==="always"||$.isOnline())&&e.canRun(),u=()=>ot(e.networkMode)&&e.canRun(),l=f=>{n||(n=!0,e.onSuccess?.(f),o?.(),i.resolve(f))},d=f=>{n||(n=!0,e.onError?.(f),o?.(),i.reject(f))},y=()=>new Promise(f=>{o=w=>{(n||m())&&f(w)},e.onPause?.()}).then(()=>{o=void 0,n||e.onContinue?.()}),E=()=>{if(n)return;let f,w=r===0?e.initialPromise:void 0;try{f=w??e.fn()}catch(p){f=Promise.reject(p)}Promise.resolve(f).then(l).catch(p=>{if(n)return;let b=e.retry??(C?0:3),S=e.retryDelay??Un,I=typeof S=="function"?S(r,p):S,Te=b===!0||typeof b=="number"&&r<b||typeof b=="function"&&b(r,p);if(t||!Te){d(p);return}r++,e.onFail?.(r,p),jt(I).then(()=>m()?void 0:y()).then(()=>{t?d(p):E()})})};return{promise:i,cancel:a,continue:()=>(o?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?E():y().then(E),i)}}function Bn(){let e=[],t=0,r=s=>{s()},n=s=>{s()},o=s=>setTimeout(s,0),i=s=>{t?e.push(s):o(()=>{r(s)})},a=()=>{let s=e;e=[],s.length&&o(()=>{n(()=>{s.forEach(c=>{r(c)})})})};return{batch:s=>{let c;t++;try{c=s()}finally{t--,t||a()}return c},batchCalls:s=>(...c)=>{i(()=>{s(...c)})},schedule:i,setNotifyFunction:s=>{r=s},setBatchNotifyFunction:s=>{n=s},setScheduler:s=>{o=s}}}var R=Bn();var ge=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),qt(this.gcTime)&&(this.#e=setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(C?1/0:5*60*1e3))}clearGcTimeout(){this.#e&&(clearTimeout(this.#e),this.#e=void 0)}};var Xt=class extends ge{#e;#t;#r;#n;#s;#i;constructor(e){super(),this.#i=!1,this.#s=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.cache,this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=Kn(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#n?.promise}setOptions(e){this.options={...this.#s,...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#r.remove(this)}setData(e,t){let r=Wt(this.state.data,e,this.options);return this.#o({data:r,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),r}setState(e,t){this.#o({type:"setState",state:e,setStateOptions:t})}cancel(e){let t=this.#n?.promise;return this.#n?.cancel(e),t?t.then(P).catch(P):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(e=>Gt(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===ee||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(e=0){return this.state.isInvalidated||this.state.data===void 0||!Kt(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#n?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#n?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#n&&(this.#i?this.#n.cancel({revert:!0}):this.#n.cancelRetry()),this.scheduleGc()),this.#r.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#o({type:"invalidate"})}fetch(e,t){if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#n)return this.#n.continueRetry(),this.#n.promise}if(e&&this.setOptions(e),!this.options.queryFn){let s=this.observers.find(c=>c.options.queryFn);s&&this.setOptions(s.options)}let r=new AbortController,n=s=>{Object.defineProperty(s,"signal",{enumerable:!0,get:()=>(this.#i=!0,r.signal)})},o=()=>{let s=de(this.options,t),c={queryKey:this.queryKey,meta:this.meta};return n(c),this.#i=!1,this.options.persister?this.options.persister(s,c,this):s(c)},i={fetchOptions:t,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:o};n(i),this.options.behavior?.onFetch(i,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==i.fetchOptions?.meta)&&this.#o({type:"fetch",meta:i.fetchOptions?.meta});let a=s=>{he(s)&&s.silent||this.#o({type:"error",error:s}),he(s)||(this.#r.config.onError?.(s,this),this.#r.config.onSettled?.(this.state.data,s,this)),this.scheduleGc()};return this.#n=pe({initialPromise:t?.initialPromise,fn:i.fetchFn,abort:r.abort.bind(r),onSuccess:s=>{if(s===void 0){a(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(s)}catch(c){a(c);return}this.#r.config.onSuccess?.(s,this),this.#r.config.onSettled?.(s,this.state.error,this),this.scheduleGc()},onError:a,onFail:(s,c)=>{this.#o({type:"failed",failureCount:s,error:c})},onPause:()=>{this.#o({type:"pause"})},onContinue:()=>{this.#o({type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0}),this.#n.start()}#o(e){let t=r=>{switch(e.type){case"failed":return{...r,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...qn(r.data,this.options),fetchMeta:e.meta??null};case"success":return{...r,data:e.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":let n=e.error;return he(n)&&n.revert&&this.#t?{...this.#t,fetchStatus:"idle"}:{...r,error:n,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...e.state}}};this.state=t(this.state),R.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),this.#r.notify({query:this,type:"updated",action:e})})}};function qn(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:ot(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Kn(e){let t=typeof e.initialData=="function"?e.initialData():e.initialData,r=t!==void 0,n=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var te=class extends L{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,r){let n=t.queryKey,o=t.queryHash??H(n,t),i=this.get(o);return i||(i=new Xt({cache:this,queryKey:n,queryHash:o,options:e.defaultQueryOptions(t),state:r,defaultOptions:e.getQueryDefaults(n)}),this.add(i)),i}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){R.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(r=>rt(t,r))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(r=>rt(e,r)):t}notify(e){R.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){R.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){R.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}};var Jt=class extends ge{#e;#t;#r;constructor(e){super(),this.mutationId=e.mutationId,this.#t=e.mutationCache,this.#e=[],this.state=e.state||Gn(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#e.includes(e)||(this.#e.push(e),this.clearGcTimeout(),this.#t.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#e=this.#e.filter(t=>t!==e),this.scheduleGc(),this.#t.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#e.length||(this.state.status==="pending"?this.scheduleGc():this.#t.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){this.#r=pe({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(n,o)=>{this.#n({type:"failed",failureCount:n,error:o})},onPause:()=>{this.#n({type:"pause"})},onContinue:()=>{this.#n({type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#t.canRun(this)});let t=this.state.status==="pending",r=!this.#r.canStart();try{if(!t){this.#n({type:"pending",variables:e,isPaused:r}),await this.#t.config.onMutate?.(e,this);let o=await this.options.onMutate?.(e);o!==this.state.context&&this.#n({type:"pending",context:o,variables:e,isPaused:r})}let n=await this.#r.start();return await this.#t.config.onSuccess?.(n,e,this.state.context,this),await this.options.onSuccess?.(n,e,this.state.context),await this.#t.config.onSettled?.(n,null,this.state.variables,this.state.context,this),await this.options.onSettled?.(n,null,e,this.state.context),this.#n({type:"success",data:n}),n}catch(n){try{throw await this.#t.config.onError?.(n,e,this.state.context,this),await this.options.onError?.(n,e,this.state.context),await this.#t.config.onSettled?.(void 0,n,this.state.variables,this.state.context,this),await this.options.onSettled?.(void 0,n,e,this.state.context),n}finally{this.#n({type:"error",error:n})}}finally{this.#t.runNext(this)}}#n(e){let t=r=>{switch(e.type){case"failed":return{...r,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...r,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:e.error,failureCount:r.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),R.batch(()=>{this.#e.forEach(r=>{r.onMutationUpdate(e)}),this.#t.notify({mutation:this,type:"updated",action:e})})}};function Gn(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var re=class extends L{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#r=0}#e;#t;#r;build(e,t,r){let n=new Jt({mutationCache:this,mutationId:++this.#r,options:e.defaultMutationOptions(t),state:r});return this.add(n),n}add(e){this.#e.add(e);let t=ye(e);if(typeof t=="string"){let r=this.#t.get(t);r?r.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){let t=ye(e);if(typeof t=="string"){let r=this.#t.get(t);if(r)if(r.length>1){let n=r.indexOf(e);n!==-1&&r.splice(n,1)}else r[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){let t=ye(e);if(typeof t=="string"){let n=this.#t.get(t)?.find(o=>o.state.status==="pending");return!n||n===e}else return!0}runNext(e){let t=ye(e);return typeof t=="string"?this.#t.get(t)?.find(n=>n!==e&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){R.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(r=>nt(t,r))}findAll(e={}){return this.getAll().filter(t=>nt(e,t))}notify(e){R.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(t=>t.state.isPaused);return R.batch(()=>Promise.all(e.map(t=>t.continue().catch(P))))}};function ye(e){return e.options.scope?.id}function it(e){return{onFetch:(t,r)=>{let n=t.options,o=t.fetchOptions?.meta?.fetchMore?.direction,i=t.state.data?.pages||[],a=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,m=async()=>{let u=!1,l=E=>{Object.defineProperty(E,"signal",{enumerable:!0,get:()=>(t.signal.aborted?u=!0:t.signal.addEventListener("abort",()=>{u=!0}),t.signal)})},d=de(t.options,t.fetchOptions),y=async(E,f,w)=>{if(u)return Promise.reject();if(f==null&&E.pages.length)return Promise.resolve(E);let p={queryKey:t.queryKey,pageParam:f,direction:w?"backward":"forward",meta:t.options.meta};l(p);let b=await d(p),{maxPages:S}=t.options,I=w?$t:Qt;return{pages:I(E.pages,b,S),pageParams:I(E.pageParams,f,S)}};if(o&&i.length){let E=o==="backward",f=E?Vn:Zt,w={pages:i,pageParams:a},p=f(n,w);s=await y(w,p,E)}else{let E=e??i.length;do{let f=c===0?a[0]??n.initialPageParam:Zt(n,s);if(c>0&&f==null)break;s=await y(s,f),c++}while(c<E)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(m,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r):t.fetchFn=m}}}function Zt(e,{pages:t,pageParams:r}){let n=t.length-1;return t.length>0?e.getNextPageParam(t[n],t,r[n],r):void 0}function Vn(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}var st=class{#e;#t;#r;#n;#s;#i;#o;#a;constructor(e={}){this.#e=e.queryCache||new te,this.#t=e.mutationCache||new re,this.#r=e.defaultOptions||{},this.#n=new Map,this.#s=new Map,this.#i=0}mount(){this.#i++,this.#i===1&&(this.#o=fe.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=$.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#i--,this.#i===0&&(this.#o?.(),this.#o=void 0,this.#a?.(),this.#a=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),r=this.#e.build(this,t),n=r.state.data;return n===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(tt(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(n))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:r})=>{let n=r.data;return[t,n]})}setQueryData(e,t,r){let n=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(n.queryHash)?.state.data,a=Bt(t,i);if(a!==void 0)return this.#e.build(this,n).setData(a,{...r,manual:!0})}setQueriesData(e,t,r){return R.batch(()=>this.#e.findAll(e).map(({queryKey:n})=>[n,this.setQueryData(n,t,r)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;R.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r)})})}resetQueries(e,t){let r=this.#e,n={type:"active",...e};return R.batch(()=>(r.findAll(e).forEach(o=>{o.reset()}),this.refetchQueries(n,t)))}cancelQueries(e,t={}){let r={revert:!0,...t},n=R.batch(()=>this.#e.findAll(e).map(o=>o.cancel(r)));return Promise.all(n).then(P).catch(P)}invalidateQueries(e,t={}){return R.batch(()=>{if(this.#e.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none")return Promise.resolve();let r={...e,type:e?.refetchType??e?.type??"active"};return this.refetchQueries(r,t)})}refetchQueries(e,t={}){let r={...t,cancelRefetch:t.cancelRefetch??!0},n=R.batch(()=>this.#e.findAll(e).filter(o=>!o.isDisabled()).map(o=>{let i=o.fetch(void 0,r);return r.throwOnError||(i=i.catch(P)),o.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(n).then(P)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let r=this.#e.build(this,t);return r.isStaleByTime(tt(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(P).catch(P)}fetchInfiniteQuery(e){return e.behavior=it(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(P).catch(P)}ensureInfiniteQueryData(e){return e.behavior=it(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return $.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#r}setDefaultOptions(e){this.#r=e}setQueryDefaults(e,t){this.#n.set(W(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#n.values()],r={};return t.forEach(n=>{Q(e,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(e,t){this.#s.set(W(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#s.values()],r={};return t.forEach(n=>{Q(e,n.mutationKey)&&(r={...r,...n.defaultOptions})}),r}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#r.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=H(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===ee&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#r.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}};var jn=new st({defaultOptions:{queries:{staleTime:3e4}},queryCache:new te({onError:(e,t)=>{}}),mutationCache:new re}),Ht=jn;var Wn=[{name:"lowCpuCores",weight:1,async check(){let e=navigator.hardwareConcurrency||0,t=e>0&&e<=2;return{value:e,triggered:t}}},{name:"lowDeviceMemory",weight:1,async check(){let e=navigator.deviceMemory||0,t=e>0&&e<=4;return{value:e,triggered:t}}},{name:"platformMismatch",weight:1,async check(){let e=navigator.userAgent||"",t=navigator.platform||"",r=e.includes("Mac")&&t.includes("Linux")||e.includes("Win")&&t.includes("Mac")||t===""||t==="Unknown";return{value:t,triggered:r}}},{name:"webglSoftwareRenderer",weight:2,async check(){let e=null,t=null,r=!1;try{let n=document.createElement("canvas"),o=n.getContext("webgl")||n.getContext("experimental-webgl");if(o){let i=o.getExtension("WEBGL_debug_renderer_info");if(i){e=o.getParameter(i.UNMASKED_VENDOR_WEBGL)||"",t=o.getParameter(i.UNMASKED_RENDERER_WEBGL)||"";let a=t.toLowerCase(),s=e.toLowerCase();r=a.includes("swiftshader")||a.includes("llvmpipe")||a.includes("softwar")||a.includes("basic render")||a.includes("vmware")||a.includes("virtualbox")||s.includes("vmware")||s.includes("parallels")}}}catch{}return{value:{vendor:e,renderer:t},triggered:r}}},{name:"missingWebGPUAdapter",weight:2,async check(){if(!("gpu"in navigator))return{value:"no WebGPU",triggered:!0};try{let e=await navigator.gpu.requestAdapter();return{value:e?"adapter-present":"adapter-null",triggered:!e}}catch{return{value:"adapter-error",triggered:!0}}}},{name:"reducedTimerPrecision",weight:1,async check(){let e=performance.now();await new Promise(n=>setTimeout(n,50));let t=performance.now()-e,r=t<30||t>80;return{value:t.toFixed(2),triggered:r}}},{name:"timerJitter",weight:1,async check(){let e=[];for(let n=0;n<10;n++){let o=performance.now();await new Promise(a=>setTimeout(a,10));let i=performance.now();e.push(i-o)}let t=Math.sqrt(e.map(n=>(n-10)**2).reduce((n,o)=>n+o)/e.length),r=t>5;return{value:t.toFixed(3),triggered:r}}},{name:"audioFingerprint",weight:1,async check(){try{let e=new(window.OfflineAudioContext||window.webkitOfflineAudioContext)(1,44100,44100),t=e.createOscillator();t.frequency.value=440,t.connect(e.destination),t.start(0);let n=(await e.startRendering()).getChannelData(0).reduce((i,a)=>i+Math.abs(a),0),o=n<100;return{value:n,triggered:o}}catch{return{value:"audio-error",triggered:!0}}}},{name:"canvasEntropy",weight:1,async check(){try{let e=document.createElement("canvas"),t=e.getContext("2d");t.textBaseline="top",t.font="14px 'Arial'",t.fillText("VM CHECK",2,2);let n=[...e.toDataURL()].reduce((i,a)=>(i+a.charCodeAt(0))%9999999,0);return{value:n,triggered:n===0||n===999999}}catch{return{value:"canvas-error",triggered:!0}}}},{name:"windowSizeWeird",weight:1,async check(){let e=window.innerWidth/window.innerHeight,t=e===1.333||e===1.6;return{value:e.toFixed(2),triggered:t}}},{name:"touchMismatch",weight:1,async check(){let e="ontouchstart"in window,t=navigator.maxTouchPoints||0;return{value:{hasTouch:e,maxTouch:t},triggered:e&&t===0}}},{name:"batteryVirtualized",weight:1,async check(){if(!navigator.getBattery)return{value:"no API",triggered:!0};try{let e=await navigator.getBattery(),t=e.chargingTime===0&&e.dischargingTime===1/0;return{value:{chargingTime:e.chargingTime,dischargingTime:e.dischargingTime},triggered:t}}catch{return{value:"battery-error",triggered:!0}}}},{name:"permissionsWeird",weight:1,async check(){try{let e=await navigator.permissions.query({name:"camera"}),t=e.state==="prompt";return{value:e.state,triggered:t}}catch{return{value:"perm-error",triggered:!0}}}},{name:"noMediaDevices",weight:1,async check(){try{let e=await navigator.mediaDevices.enumerateDevices(),t=e.length===0;return{value:e.length,triggered:t}}catch{return{value:"media-error",triggered:!0}}}},{name:"virtualizedMediaDevices",weight:1,async check(){try{let e=await navigator.mediaDevices.enumerateDevices(),t=e.some(r=>r.label.toLowerCase().includes("virtual"));return{value:e.map(r=>r.label),triggered:t}}catch{return{value:"media-error",triggered:!0}}}},{name:"webrtcIpPattern",weight:2,async check(){return new Promise(e=>{let t=new RTCPeerConnection({iceServers:[]});t.createDataChannel("x"),t.onicecandidate=r=>{if(!r||!r.candidate){e({value:"no candidate",triggered:!0});return}let n=r.candidate.candidate.toLowerCase(),o=n.includes("10.0.2.")||n.includes("172.16.")||n.includes("192.168.56.");e({value:n,triggered:o})},t.createOffer().then(r=>t.setLocalDescription(r))})}},{name:"gpuAccelerationDisabled",weight:2,async check(){let t=document.createElement("canvas").getContext("webgl");return{value:!!t,triggered:!t}}},{name:"noWebGL2",weight:1,async check(){let e=document.createElement("canvas").getContext("webgl2");return{value:!!e,triggered:!e}}},{name:"lowStorageQuota",weight:1,async check(){try{let e=await navigator.storage.estimate(),t=e.quota<500*1024*1024;return{value:e.quota,triggered:t}}catch{return{value:"storage-error",triggered:!0}}}},{name:"lowEntropy",weight:1,async check(){let e=Object.keys(navigator).length+Object.keys(screen).length+Object.keys(window).length,t=e<200;return{value:e,triggered:t}}},{name:"noLanguages",weight:1,async check(){let e=navigator.languages||[];return{value:e,triggered:e.length===0}}},{name:"uaEntropyLow",weight:1,async check(){let e=navigator.userAgent,t=e.length<30;return{value:e,triggered:t}}},{name:"weirdDPI",weight:1,async check(){let e=window.devicePixelRatio;return{value:e,triggered:e===1}}}];async function er({threshold:e=6}={}){let t={},r=0;for(let n of Wn){let o=await n.check();t[n.name]=o,o.triggered&&(r+=n.weight)}return{isLikelyVM:r>=e,score:r,threshold:e,signals:t}}var Qn=[{name:"hookedFunctionToString",weight:2,async check(){let e=Function.prototype.toString.toString(),t=Function.prototype.toString+"";return{value:{native:e,current:t},triggered:e!==t}}},{name:"navigatorProxyTrap",weight:2,async check(){let e=!1;try{let t=Object.getOwnPropertyDescriptor(window,"navigator");t&&t.get&&t.get.toString()?.includes("[native code]")===!1&&(e=!0)}catch{}return{value:"navigator getter",triggered:e}}},{name:"uaMismatch",weight:2,async check(){let e=navigator.userAgent||"",t="";try{let n=await navigator.userAgentData?.getHighEntropyValues?.(["platform","brands"]);t=JSON.stringify(n)}catch{}let r=e?.includes("Mac")&&t?.includes("Windows")||e?.includes("Win")&&t?.includes("Mac")||t&&t.length>0&&!e;return{value:{ua:e,brandInfo:t},triggered:r}}},{name:"timezoneLocaleMismatch",weight:1,async check(){let e=Intl.DateTimeFormat().resolvedOptions().timeZone,t=navigator.language||"",r=t.startsWith("en")&&e==="Asia/Shanghai"||t.startsWith("zh")&&e==="America/New_York"||e===void 0;return{value:{tz:e,lang:t},triggered:r}}},{name:"canvasNoise",weight:2,async check(){let e=()=>{let o=document.createElement("canvas"),i=o.getContext("2d");return i.textBaseline="top",i.font="14px Arial",i.fillText("anti-detect-check",2,2),o.toDataURL()},t=e(),r=e();return{value:{a:t,b:r},triggered:t!==r}}},{name:"webglNoise",weight:2,async check(){try{let t=document.createElement("canvas").getContext("webgl");if(!t)return{value:"no-webgl",triggered:!0};let r=t.getExtension("WEBGL_debug_renderer_info");if(!r)return{value:"no-debug-extension",triggered:!1};let n=t.getParameter(r.UNMASKED_VENDOR_WEBGL),o=t.getParameter(r.UNMASKED_RENDERER_WEBGL),i=n===""||o===""||n?.includes(" ")===!1||o?.includes(" ")===!1;return{value:{v:n,r:o},triggered:i}}catch{return{value:"gl-error",triggered:!0}}}},{name:"webdriverFlag",weight:3,async check(){let e=navigator.webdriver===!0;return{value:navigator.webdriver,triggered:e}}},{name:"perfectEventTiming",weight:1,async check(){let e=performance.now();return{value:e,triggered:e%1===0}}},{name:"serviceWorkerBlocked",weight:1,async check(){let e=!("serviceWorker"in navigator);return{value:e,triggered:e}}},{name:"smallQuota",weight:2,async check(){try{let e=await navigator.storage.estimate(),t=e.quota<50*1024*1024;return{value:e.quota,triggered:t}}catch{return{value:"quota-error",triggered:!0}}}},{name:"indexedDbBlocked",weight:2,async check(){try{let e=indexedDB.open("tamper-check");return await new Promise(t=>{e.onerror=()=>t({value:"error",triggered:!0}),e.onsuccess=()=>t({value:"ok",triggered:!1})})}catch{return{value:"throw",triggered:!0}}}},{name:"screenDprMismatch",weight:1,async check(){let e=window.screen.width,t=window.screen.height,r=window.devicePixelRatio,n=e===1920&&r===1&&t===1080||r%1!==0&&r%1!==.5;return{value:{w:e,h:t,dpr:r},triggered:n}}},{name:"missingCommonFonts",weight:1,async check(){return{value:"skipped",triggered:!1}}},{name:"noMediaDevices",weight:1,async check(){try{let e=await navigator.mediaDevices.enumerateDevices();return{value:e.length,triggered:e.length===0}}catch{return{value:"error",triggered:!0}}}},{name:"languagesEmpty",weight:1,async check(){let e=navigator.languages||[];return{value:e,triggered:e.length===0}}},{name:"pluginMismatch",weight:1,async check(){try{let e=navigator.plugins.length;return{value:e,triggered:e===0}}catch{return{value:"error",triggered:!0}}}},{name:"devtoolsDetected",weight:2,async check(){return new Promise(async e=>{let t={viewportBreakpoint:!1,debuggerLatency:!1,consoleSpeed:!1},r=160,n=window.outerWidth-window.innerWidth,o=window.outerHeight-window.innerHeight;(n>r||o>r)&&(t.viewportBreakpoint=!0);function i(c=200){let m=performance.now();debugger;return performance.now()-m>c}t.debuggerLatency=i();async function a(c=50){return new Promise(m=>{let u=performance.now();console.log("%c ","font-size:3000px");let l=performance.now();m(l-u>c)})}t.consoleSpeed=await a();let s=Object.values(t).some(Boolean);setTimeout(()=>{e({value:s,triggered:s})},50)})}},{name:"knownAntiDetectBrowser",weight:5,async check(){let e=navigator.userAgent.toLowerCase(),r=["incogniton","multilogin","morelogin","adspect","kameleo","goLogin"].some(n=>e?.includes(n));return{value:e,triggered:r}}}];async function tr({threshold:e=5}={}){let t={},r=0;for(let o of Qn){let i=await o.check();t[o.name]=i,i.triggered&&(r+=o.weight)}let n=Math.min(1,r/15);return{result:n>=.5||t.knownAntiDetectBrowser?.triggered,anomalyScore:n,antiDetectBrowser:t.knownAntiDetectBrowser?.triggered||!1,signals:t}}function $n(){let e=0;try{0 .toFixed(-1)}catch(t){e=t.message.length}return e}function zn(){let e=navigator.userAgent,t=$n();return t===44||t===43?"Safari":t===51?"Chrome":t===25?"Firefox":navigator.msSaveBlob!==void 0?"MSIE":e.match(/Chrome/)?navigator.brave!==void 0?"Brave":e.includes("Edg")?"Edge":e.includes("OPR")?"Opera":"Chrome":"Unknown"}var Yn=[{name:"safari_currentStorageTest",weight:2,browser:"Safari",async check(){if(typeof navigator.storage?.getDirectory!="function")return{triggered:!1,value:"unsupported"};try{return await navigator.storage.getDirectory(),{triggered:!1,value:"ok"}}catch(e){let t=e?.message??String(e);return{triggered:t.includes("unknown transient reason"),value:t}}}},{name:"safari13to18_indexedDbBlobTest",weight:2,browser:"Safari",async check(){return await new Promise(e=>{let t=String(Math.random()),r=indexedDB.open(t,1);r.onupgradeneeded=n=>{let o=n.target.result;try{o.createObjectStore("t",{autoIncrement:!0}).put(new Blob),e({triggered:!1,value:"ok"})}catch(i){let a=i?.message??String(i);e({triggered:a.includes("are not yet supported"),value:a})}finally{o.close(),indexedDB.deleteDatabase(t)}},r.onerror=()=>e({triggered:!1,value:"idb-error"})})}},{name:"safari_oldWebkitTest",weight:1,browser:"Safari",async check(){let e=window.openDatabase,t=window.localStorage;try{e(null,null,null,null)}catch{return{triggered:!0,value:"openDatabase denied"}}try{t.setItem("test","1"),t.removeItem("test")}catch{return{triggered:!0,value:"localStorage denied"}}return{triggered:!1,value:"ok"}}},{name:"chrome_storageQuotaPrivateTest",weight:2,browser:"Chrome",async check(){return await new Promise((e,t)=>{let n=window?.performance?.memory?.jsHeapSizeLimit??1073741824;navigator.webkitTemporaryStorage.queryUsageAndQuota((o,i)=>{let a=Math.round(i/1048576),s=Math.round(n/(1024*1024))*2;e({triggered:a<s,value:{quotaMB:a,limitMB:s}})},o=>t(o))})}},{name:"chrome_oldFileSystemTest",weight:1,browser:"Chrome",async check(){let e=window.webkitRequestFileSystem;return e?await new Promise(t=>e(0,1,()=>t({triggered:!1,value:"ok"}),()=>t({triggered:!0,value:"denied"}))):{triggered:!1,value:"unsupported"}}},{name:"firefox_storageDirectoryTest",weight:2,browser:"Firefox",async check(){if(typeof navigator.storage?.getDirectory!="function")return{triggered:!1,value:"unsupported"};try{return await navigator.storage.getDirectory(),{triggered:!1,value:"ok"}}catch(e){let t=e?.message??String(e);return{triggered:t.includes("Security error"),value:t}}}},{name:"firefox_indexedDbInvalidStateTest",weight:1,browser:"Firefox",async check(){return await new Promise(e=>{let t=indexedDB.open("inPrivate");t.onerror=()=>{e({triggered:t.error?.name==="InvalidStateError",value:t.error?.name})},t.onsuccess=()=>{indexedDB.deleteDatabase("inPrivate"),e({triggered:!1,value:"ok"})}})}},{name:"msie_indexedDbMissing",weight:2,browser:"MSIE",async check(){return{triggered:window.indexedDB===void 0,value:"msie-idb-check"}}}];async function rr(){let e=zn(),t={},r=0;for(let n of Yn){if(n.browser!==e)continue;let o=await n.check();t[n.name]=o,o.triggered&&(r+=n.weight)}return{isPrivate:r>0,browserName:e,score:r,signals:t}}typeof window<"u"&&(window.detectIncognito=rr);var nr=rr;var or="dtect_security_sdk_state",ir=typeof window<"u",sr={isLoading:!1,token:"",visitorId:"",projectId:"",questionData:null,clientData:null,aiCheckData:null,tokens:null},Ee={state:{...sr},securityKeys:{behaviorKey:"",automationKey:""}};function ar(){if(!ir)return Ee;try{let e=sessionStorage.getItem(or);if(!e)return Ee;let t=JSON.parse(e);return t.expiresAt&&t.expiresAt<Date.now()?Ee:{state:{...sr,...t.state},securityKeys:t.securityKeys||{behaviorKey:"",automationKey:""}}}catch{return Ee}}function U(e){if(ir)try{let t=Date.now()+864e5,r={...e,expiresAt:t};sessionStorage.setItem(or,JSON.stringify(r))}catch{}}function cr(e){return e.token||z()}var we,B="https://api.dtect.io/security",Ie=`${B}/client/check`,F="",K="",lr="0.0.18",mr,ur,Xn="20000000-aaaa-bbbb-cccc-000000000002",ve;var{state:g,securityKeys:{automationKey:k,behaviorKey:M}}=ar(),Jn=bt,ne;async function Zn({clientId:e,apiKey:t,endpoint:r}){if(Re({automationKey:k,behaviorKey:M}))return{automationKey:k,behaviorKey:M};let n=await Ht.fetchQuery({queryKey:["getClientConfig",e,t],queryFn:()=>He({url:`${r}/client/config`,headers:{"client-id":F,"x-api-key":K}})});if(!Re(n))throw new Error;return k=n.automationKey,M=n.behaviorKey,U({state:g,securityKeys:n}),n}function dt(e){if(e instanceof Error){if(e?.message?.includes("maintenance_mode"))throw new Error(v.MAINTENANCE_MODE);if(e?.message?.includes("rate-limited"))throw new Error(v.RATE_LIMIT_REACHED);switch(e?.message){case G.ERROR_RATE_LIMIT:throw new Error(v.RATE_LIMIT_REACHED);default:throw new Error(v.INTERNAL_SERVER_ERROR)}}throw new Error(v.FAILED_TO_GET_SECURITY_TOKEN)}function q(){if(hr(g)&&Re({automationKey:k,behaviorKey:M}))return!0;let e=be(),t=document.querySelector("#dtect-h-captcha");return!!we&&!!(t||e)}function dr(){return!!(F&&K)}function Hn(){return new Promise(e=>{let t=()=>{window?.hcaptcha?e():requestAnimationFrame(t)};t()})}var be=()=>window?.location?.href?.includes("localhost")||window?.location?.href?.includes("file:///");async function eo({behaviorKey:e}){if(we=await G.load({apiKey:e,endpoint:["https://fp.dtect.io",G.defaultEndpoint],scriptUrlPattern:["https://fp.dtect.io/web/v<version>/<apiKey>/loader_v<loaderVersion>.js",G.defaultScriptUrlPattern]}),be()||(await Hn(),await window.hcaptcha.render("dtect-h-captcha",{sitekey:k,size:"invisible"})),!we)throw new Error(v.SDK_INIT_ERROR)}async function to(){if(g.tokens)return g.tokens;let e=new Promise(o=>{let i=we?.get();o(i)}),t=new Promise(async o=>{be()&&o({response:Xn});let a=await window?.hcaptcha?.execute({async:!0});o(a)}),[r,n]=await Promise.all([t,e]);return g.tokens={behaviorRequestId:n?.requestId,behaviorToken:n?.sealedResult,automationToken:r?.response},g.tokens}function ro(e){let t=e?.projectId,r=e?.visitorId||z();return(typeof e?.projectId=="number"||typeof e?.visitorId=="number")&&(t=`${e?.projectId}`,r=`${e?.visitorId}`),{visitorId:r,projectId:t}}function ft(e){if(g.projectId&&g.visitorId)return{visitorId:g.visitorId,projectId:g.projectId};let{projectId:t,visitorId:r}=ro(e);return{projectId:t,visitorId:r}}async function fr(e,t){if(!q())throw new Error(v.NOT_INITIALIZED);if(!dr())throw new Error(v.MISSING_CREDENTIALS);let{projectId:r,visitorId:n}=ft(e);if(g.projectId=r,g.visitorId=n,!e||!r?.trim())throw new Error(v.FAILED_TO_GET_SECURITY_RESULT);try{let o=await to(),i=new Z,[a,s,c,m]=await Promise.allSettled([i.get(),er(),tr(),nr()]);if(o?.behaviorToken&&o?.behaviorRequestId&&o?.automationToken){let u={behaviorToken:o.behaviorToken,automationToken:o.automationToken,behaviorRequestId:o.behaviorRequestId,entryLink:window?.location?.href,securitySettings:e.securitySettings,metaData:e.metaData,vmDtectResults:s?.value,tamperingDtectResults:c?.value,incognitoDtectResults:m?.value,deviceIdResults:a?.value};g.clientData=u;let l={...e,projectId:r,visitorId:n,clientData:u,version:"0.0.18",token:g.token,questionData:g.questionData,aiCheckData:g.aiCheckData};ur=performance.now();let d=(ur-mr).toFixed(),y=await me({url:`${t}?clientId=${F}&diff=${d}`,body:{...l},headers:{"client-id":F,"x-api-key":K}});if("token"in y||"results"in y)return U({state:g,securityKeys:{automationKey:k,behaviorKey:M}}),y}throw new Error(v.INTERNAL_SERVER_ERROR)}catch(o){if(o instanceof Error){if(o?.message?.includes("maintenance_mode"))throw new Error(v.MAINTENANCE_MODE);if(o?.message?.includes("rate-limited")||o?.message?.includes("429"))throw new Error(v.RATE_LIMIT_REACHED);switch(o?.message){case G.ERROR_RATE_LIMIT:throw new Error(v.RATE_LIMIT_REACHED);default:throw new Error(v.INTERNAL_SERVER_ERROR)}}throw new Error(v.FAILED_TO_GET_SECURITY_RESULT)}}async function at(e){return await fr(e,`${B}/client/check/result`)}async function ct(e){return await fr(e,`${B}/client/check`)}async function ut(e){if(!q())throw new Error(v.NOT_INITIALIZED);let{respondentType:t,language:r}=e;try{let n=await He({url:`${B}/client/quality-questions/${t}/${r}`,headers:{"client-id":F,"x-api-key":K}});if(n)return n;throw new Error(v.INTERNAL_SERVER_ERROR)}catch(n){dt(n)}}async function lt(e){if(!q())throw new Error(v.NOT_INITIALIZED);g.questionData||(g.questionData={questions:e.questions});let{visitorId:t,projectId:r}=ft(e);g.visitorId=t,g.projectId=r;try{let n=await me({url:Ie,headers:{"client-id":F,"x-api-key":K},body:{token:g.token,visitorId:t,projectId:r,version:lr,questionData:g.questionData,aiCheckData:g.aiCheckData,clientData:g.clientData}});if(n)return U({state:g,securityKeys:{automationKey:k,behaviorKey:M}}),n;throw new Error(v.INTERNAL_SERVER_ERROR)}catch(n){dt(n)}}async function mt(e){if(!q())throw new Error(v.NOT_INITIALIZED);g.aiCheckData={timeTakenSeconds:e.timeTakenSeconds,qbc:e.qbc||ne.qbc,mas:e.mas||ne.mas,scb:e.scb||ne.scb,apd:e.apd||ne.apd};let{visitorId:t,projectId:r}=ft(e);g.visitorId=t,g.projectId=r;try{let n=await me({url:Ie,headers:{"client-id":F,"x-api-key":K},body:{token:g.token,visitorId:t,projectId:r,version:lr,clientData:g.clientData,questionData:g.questionData,aiCheckData:g.aiCheckData}});if(n)return U({state:g,securityKeys:{automationKey:k,behaviorKey:M}}),n;throw new Error(v.INTERNAL_SERVER_ERROR)}catch(n){dt(n)}}function no(){let e=document.querySelector("head"),t=document.querySelector("body");if(!be()){t?.insertAdjacentHTML("beforeend",'<div id="dtect-h-captcha" ></div>');let n=document.createElement("script");n.setAttribute("src","https://js.hcaptcha.com/1/api.js"),n.setAttribute("async","true"),n.setAttribute("defer","true"),e?.append(n)}}function Re(e){return e?.automationKey&&e?.behaviorKey}function hr(e){let t=e.tokens;return!!(t&&t.behaviorToken&&t.behaviorRequestId&&t.automationToken)}async function oo(e){if(!e?.clientId||!e?.apiKey)throw new Error(v.MISSING_CREDENTIALS);mr=performance.now();let{clientId:t,apiKey:r,endpoint:n="https://api.dtect.io/security",includeResults:o}=e;B=n,Ie=`${B}/client/check`;let i=cr(g);if(g.isLoading){if(q())return ve;throw new Error(v.DUPLICATE_INITIALIZATION)}if(ne=Ct(g.aiCheckData),F=t,K=r,o&&(Ie=`${B}/client/check/result`),g={...g,isLoading:!0,token:i||""},hr(g)&&Re({automationKey:k,behaviorKey:M}))return g={...g,isLoading:!1,token:i},U({state:g,securityKeys:{automationKey:k,behaviorKey:M}}),{getSecurityResult:at,getSecurityToken:ct,isAIUsageDetected:mt,checkQualityQuestions:lt,getQualityQuestions:ut,LanguageCodes:Y,QualityQuestionsRespondentTypes:X};if(!dr())throw new Error(v.MISSING_CREDENTIALS);if(q())return ve;no();try{let s=await Zn({clientId:t,apiKey:r,endpoint:n});if(q())throw new Error;return eo({behaviorKey:s.behaviorKey}).then(()=>({getSecurityResult:at,getSecurityToken:ct,SecurityAPIError:Jn,isAIUsageDetected:mt,checkQualityQuestions:lt,getQualityQuestions:ut,LanguageCodes:Y,QualityQuestionsRespondentTypes:X})).catch(c=>{throw new Error(c.message)})}catch(s){if(s instanceof Error){if(s?.message?.includes("maintenance_mode"))throw new Error(v.MAINTENANCE_MODE);if([v.INVALID_API_KEY,v.UNAUTHORIZED].includes(s?.message))throw new Error(v.INVALID_CREDENTIALS)}throw new Error(v.SDK_INIT_ERROR)}finally{g={...g,isLoading:!1,token:i},U({state:g,securityKeys:{automationKey:k,behaviorKey:M}})}}ve={init:oo,getSecurityResult:at,getSecurityToken:ct,isAIUsageDetected:mt,checkQualityQuestions:lt,getQualityQuestions:ut,QualityQuestionsRespondentTypes:X,LanguageCodes:Y};var Va=ve;export{Y as LanguageCodes,X as QualityQuestionsRespondentTypes,Jn as SecurityAPIError,lt as checkQualityQuestions,Va as default,ut as getQualityQuestions,at as getSecurityResult,ct as getSecurityToken,oo as init,mt as isAIUsageDetected};
|
|
1
|
+
function mt(e,t){return function(r,n){return Object.prototype.hasOwnProperty.call(r,n)}(e,t)?e[t]:void 0}function Rt(e,t,r,n){let i=document,o="securitypolicyviolation",c,s=p=>{let l=new URL(e,location.href),{blockedURI:h}=p;h!==l.href&&h!==l.protocol.slice(0,-1)&&h!==l.origin||(c=p,a())};i.addEventListener(o,s);let a=()=>i.removeEventListener(o,s);return n?.then(a,a),Promise.resolve().then(t).then(p=>(a(),p),p=>new Promise(l=>{let h=new MessageChannel;h.port1.onmessage=()=>l(),h.port2.postMessage(null)}).then(()=>{if(a(),c)return r(c);throw p}))}function w(e){let t="";for(let r=0;r<e.length;++r)if(r>0){let n=e[r].toLowerCase();n!==e[r]?t+=` ${n}`:t+=e[r]}else t+=e[r].toUpperCase();return t}var yt={default:"endpoint"},It={default:"tlsEndpoint"},Tt="Client timeout",Ot="Network connection error",gt="Network request aborted",vt="Response cannot be parsed",ue="Blocked by CSP",le="The endpoint parameter is not a valid URL",_t="Handle on demand agent data error",At=w("WrongRegion"),Dt=w("SubscriptionNotActive"),wt=w("UnsupportedVersion"),Nt=w("InstallationMethodRestricted"),bt=w("HostnameRestricted"),Pt=w("IntegrationFailed"),kt=w("NetworkRestricted"),St=w("InvalidProxyIntegrationSecret"),Mt=w("InvalidProxyIntegrationHeaders"),Lt=w("ProxyIntegrationSecretEnvironmentMismatch"),he="API key required",ke="API key not found",Se="API key expired",Ft="Request cannot be parsed",xt="Request failed",Ut="Request failed to process",qt="Too many requests, rate limit exceeded",Kt="Not available for this origin",Gt="Not available with restricted header",Bt=he,Qt=ke,Ct=Se,jt="3.12.0",W="Failed to load the JS script of the agent",fe="9319";function Vt(e,t){let r=[],[n,i]=function(s){let a=function(h){let R=[...h];return{current:()=>R[0],postpone(){let y=R.shift();y!==void 0&&R.push(y)},exclude(){R.shift()}}}(s),p=function(h,R){let y=0;return()=>Math.random()*Math.min(R,h*Math.pow(2,y++))}(100,3e3),l=new Set;return[a.current(),(h,R)=>{let y,m=R instanceof Error?R.message:"";if(m===ue||m===le)a.exclude(),y=0;else if(m===fe)a.exclude();else if(m===W){let g=Date.now()-h.getTime()<50,f=a.current();f&&g&&!l.has(f)&&(l.add(f),y=0),a.postpone()}else a.postpone();let d=a.current();return d===void 0?void 0:[d,y??h.getTime()+p()-Date.now()]}]}(e),o;if(n===void 0)return Promise.reject(new TypeError("The list of script URL patterns is empty"));let c=s=>{let a=new Date,p=h=>r.push({url:s,startedAt:a,finishedAt:new Date,error:h}),l=t(s);return l.then(()=>p(),p),l.catch(h=>{if(o!=null||(o=h),r.length>=5)throw o;let R=i(a,h);if(!R)throw o;let[y,m]=R;return(d=m,new Promise(g=>setTimeout(g,d))).then(()=>c(y));var d})};return c(n).then(s=>[s,r])}var Me="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",Yt=Me;function $t(e){var t,r;let{picked:n,rest:i}=function(l,h){let R={},y={};for(let[m,d]of Object.entries(l))h.includes(m)?R[m]=d:y[m]=d;return{picked:R,rest:y}}(e,["scriptUrlPattern","token","apiKey"]),o=n.token,c=(t=n.apiKey)!==null&&t!==void 0?t:o,s=(r=mt(e,"scriptUrlPattern"))!==null&&r!==void 0?r:Me,[a,p]=function(){let l=[],h=()=>{l.push({time:new Date,state:document.visibilityState})},R=function(y,m,d,g){return y.addEventListener(m,d,g),()=>y.removeEventListener(m,d,g)}(document,"visibilitychange",h);return h(),[l,R]}();return Promise.resolve().then(()=>{if(!c||typeof c!="string")throw new Error(he);let l=function(h,R){return(Array.isArray(h)?h:[h]).map(y=>function(m,d){let g=encodeURIComponent;return m.replace(/<[^<>]+>/g,f=>f==="<version>"?"3":f==="<apiKey>"?g(d):f==="<loaderVersion>"?g(jt):f)}(String(y),R))}(s,c);return Vt(l,Xt)}).catch(l=>{throw p(),function(h){return h instanceof Error&&h.message===fe?new Error(W):h}(l)}).then(([l,h])=>(p(),l.load({...i,ldi:{attempts:h,visibilityStates:a}})))}function Xt(e){return Rt(e,()=>function(t){return new Promise((r,n)=>{if(function(s){if(URL.prototype)try{return new URL(s,location.href),!1}catch(a){if(a instanceof Error&&a.name==="TypeError")return!0;throw a}}(t))throw new Error(le);let i=document.createElement("script"),o=()=>{var s;return(s=i.parentNode)===null||s===void 0?void 0:s.removeChild(i)},c=document.head||document.getElementsByTagName("head")[0];i.onload=()=>{o(),r()},i.onerror=()=>{o(),n(new Error(W))},i.async=!0,i.src=t,c.appendChild(i)})}(e),()=>{throw new Error(ue)}).then(Wt)}function Wt(){let e=window,t="__fpjs_p_l_b",r=e[t];if(function(n,i){var o;let c=(o=Object.getOwnPropertyDescriptor)===null||o===void 0?void 0:o.call(Object,n,i);c?.configurable?delete n[i]:c&&!c.writable||(n[i]=void 0)}(e,t),typeof r?.load!="function")throw new Error(fe);return r}var U={load:$t,defaultScriptUrlPattern:Yt,ERROR_SCRIPT_LOAD_FAIL:W,ERROR_API_KEY_EXPIRED:Se,ERROR_API_KEY_INVALID:ke,ERROR_API_KEY_MISSING:he,ERROR_BAD_REQUEST_FORMAT:Ft,ERROR_BAD_RESPONSE_FORMAT:vt,ERROR_CLIENT_TIMEOUT:Tt,ERROR_CSP_BLOCK:ue,ERROR_FORBIDDEN_ENDPOINT:bt,ERROR_FORBIDDEN_HEADER:Gt,ERROR_FORBIDDEN_ORIGIN:Kt,ERROR_GENERAL_SERVER_FAILURE:xt,ERROR_HANDLE_AGENT_DATA:_t,ERROR_INSTALLATION_METHOD_RESTRICTED:Nt,ERROR_INTEGRATION_FAILURE:Pt,ERROR_INVALID_ENDPOINT:le,ERROR_INVALID_PROXY_INTEGRATION_HEADERS:Mt,ERROR_INVALID_PROXY_INTEGRATION_SECRET:St,ERROR_NETWORK_ABORT:gt,ERROR_NETWORK_CONNECTION:Ot,ERROR_NETWORK_RESTRICTED:kt,ERROR_PROXY_INTEGRATION_SECRET_ENVIRONMENT_MISMATCH:Lt,ERROR_RATE_LIMIT:qt,ERROR_SERVER_TIMEOUT:Ut,ERROR_SUBSCRIPTION_NOT_ACTIVE:Dt,ERROR_TOKEN_EXPIRED:Ct,ERROR_TOKEN_INVALID:Qt,ERROR_TOKEN_MISSING:Bt,ERROR_UNSUPPORTED_VERSION:wt,ERROR_WRONG_REGION:At,defaultEndpoint:yt,defaultTlsEndpoint:It};var v=[];for(let e=0;e<256;++e)v.push((e+256).toString(16).slice(1));function Le(e,t=0){return(v[e[t+0]]+v[e[t+1]]+v[e[t+2]]+v[e[t+3]]+"-"+v[e[t+4]]+v[e[t+5]]+"-"+v[e[t+6]]+v[e[t+7]]+"-"+v[e[t+8]]+v[e[t+9]]+"-"+v[e[t+10]]+v[e[t+11]]+v[e[t+12]]+v[e[t+13]]+v[e[t+14]]+v[e[t+15]]).toLowerCase()}var de,Jt=new Uint8Array(16);function pe(){if(!de){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");de=crypto.getRandomValues.bind(crypto)}return de(Jt)}var zt=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Ee={randomUUID:zt};function Zt(e,t,r){if(Ee.randomUUID&&!t&&!e)return Ee.randomUUID();e=e||{};let n=e.random??e.rng?.()??pe();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){if(r=r||0,r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let i=0;i<16;++i)t[r+i]=n[i];return t}return Le(n)}var B=Zt;var Ht={UNAUTHORIZED:"Unauthorized"},er={EXPIRED:"EXPIRED_TOKEN",INVALID_API_KEY:"INVALID_API_KEY",MISSING_AUTHENTICATION_TOKEN:"MISSING_AUTHENTICATION_TOKEN"},Fe={INTERNAL_SERVER_ERROR:"Internal Server Error during API Request",MISSING_CREDENTIALS:"Missing Public Client ID or Public API Key",MAINTENANCE_MODE:"API Under Maintenance",RATE_LIMIT_REACHED:"Too many requests. Rate limit exceeded"},xe={SDK_INIT_ERROR:"Internal Server Error during SDK Initialization",DUPLICATE_INITIALIZATION:"Multiple SDK Initializations Detected",NOT_INITIALIZED:"SDK Not Initialized"},Ue={INVALID_CREDENTIALS:"Invalid Public Client ID or Public API Key"},qe={FAILED_TO_GET_SECURITY_RESULT:"Failed to Retrieve Security Result"},Ke={FAILED_TO_GET_SECURITY_TOKEN:" Failed to Generate Security Token"},E={...Ht,...er,...Fe,...xe,...Ue,...qe,...Ke},Ge={...Fe,...xe,...Ue,...qe,...Ke};var Q=(f=>(f.AR="ar",f.BN="bn",f.DE="de",f.EN="en",f.ES="es",f.FR="fr",f.HI="hi",f.ID="id",f.IT="it",f.JA="ja",f.KO="ko",f.MS="ms",f.NL="nl",f.PT="pt",f.RU="ru",f.YU="yu",f.ZH="zh",f))(Q||{}),C=(I=>(I.GeneralConsumer="general-consumer",I.HRManagerDirector="hr-manager-director",I.WebDeveloper="web-developer",I.SoftwareEngineer="software-engineer",I.ITDirector="it-director",I.BusinessAdministrator="business-administrator",I.AccountsPayableManager="accounts-payable-manager",I.Accountant="accountant",I.FinanceDirector="finance-director",I.SmallBusinessOwner="small-business-owner",I.GeneralContractor="general-contractor",I.MarketingManagerDirector="marketing-manager-director",I.ConsumerShopper="consumer-shopper",I.Travel="travel",I.Entertainment="entertainment",I.FinanceAndBanking="finance-and-banking",I.General="general",I.B2BWhiteCollar="b2b-white-collar",I.B2BBlueCollar="b2b-blue-collar",I.Lawyer="lawyer",I))(C||{});var tr=(e,t={})=>({"Content-Type":"application/json",...e?.accessToken&&{Authorization:`Bearer ${e?.accessToken}`},...t}),rr=async(e,t)=>{if(!e.ok){let r=await e.text();throw new Error(r)}return t==="file"?e.blob():t==="json"?e.json():t==="text"?e.text():null},Be=async({url:e,auth:t,body:r,method:n="GET",headers:i={},responseType:o="json"})=>{let c={method:n,headers:tr(t,i),...r?{body:r instanceof FormData?r:JSON.stringify(r)}:{}},s=await fetch(e,c);return rr(s,o)},me=e=>Be({...e,method:"GET"}),J=e=>Be({...e,method:"POST"});function Qe(e){let t=e?.qbc||!1,r=e?.mas||!1,n=e?.apd||!1,i=e?.scb||null,o=0,c=()=>{t=!1,r=!1,n=!1,i=void 0,o=0},s=()=>{let h=window?.getSelection()?.toString();h&&h.length>0&&(o=Date.now(),t=!0)},a=l=>{let h=l.clipboardData?.getData("text"),R=l.target instanceof HTMLInputElement||l.target instanceof HTMLTextAreaElement;h&&R&&(n=!0)},p=()=>{r=!0;let l=Date.now();if(o){let h=(l-o)/1e3;(i===void 0||h<i)&&(i=h)}};return document?.addEventListener("copy",s),document?.addEventListener("paste",a),window?.addEventListener("blur",p),{get qbc(){return t},get mas(){return r},get apd(){return n},get scb(){return i},reset:c,destroy(){document?.removeEventListener("copy",s),document?.removeEventListener("paste",a),window?.removeEventListener("blur",p)}}}var b=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var P=typeof window>"u"||"Deno"in globalThis;function A(){}function Ve(e,t){return typeof e=="function"?e(t):e}function Ye(e){return typeof e=="number"&&e>=0&&e!==1/0}function $e(e,t){return Math.max(e+(t||0)-Date.now(),0)}function ye(e,t){return typeof e=="function"?e(t):e}function Xe(e,t){return typeof e=="function"?e(t):e}function Ie(e,t){let{type:r="all",exact:n,fetchStatus:i,predicate:o,queryKey:c,stale:s}=e;if(c){if(n){if(t.queryHash!==j(c,t.options))return!1}else if(!K(t.queryKey,c))return!1}if(r!=="all"){let a=t.isActive();if(r==="active"&&!a||r==="inactive"&&a)return!1}return!(typeof s=="boolean"&&t.isStale()!==s||i&&i!==t.state.fetchStatus||o&&!o(t))}function Te(e,t){let{exact:r,status:n,predicate:i,mutationKey:o}=e;if(o){if(!t.options.mutationKey)return!1;if(r){if(q(t.options.mutationKey)!==q(o))return!1}else if(!K(t.options.mutationKey,o))return!1}return!(n&&t.state.status!==n||i&&!i(t))}function j(e,t){return(t?.queryKeyHashFn||q)(e)}function q(e){return JSON.stringify(e,(t,r)=>Re(r)?Object.keys(r).sort().reduce((n,i)=>(n[i]=r[i],n),{}):r)}function K(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(r=>!K(e[r],t[r])):!1}function We(e,t){if(e===t)return e;let r=Ce(e)&&Ce(t);if(r||Re(e)&&Re(t)){let n=r?e:Object.keys(e),i=n.length,o=r?t:Object.keys(t),c=o.length,s=r?[]:{},a=0;for(let p=0;p<c;p++){let l=r?p:o[p];(!r&&n.includes(l)||r)&&e[l]===void 0&&t[l]===void 0?(s[l]=void 0,a++):(s[l]=We(e[l],t[l]),s[l]===e[l]&&e[l]!==void 0&&a++)}return i===c&&a===i?e:s}return t}function Ce(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Re(e){if(!je(e))return!1;let t=e.constructor;if(t===void 0)return!0;let r=t.prototype;return!(!je(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function je(e){return Object.prototype.toString.call(e)==="[object Object]"}function Je(e){return new Promise(t=>{setTimeout(t,e)})}function ze(e,t,r){return typeof r.structuralSharing=="function"?r.structuralSharing(e,t):r.structuralSharing!==!1?We(e,t):t}function Ze(e,t,r=0){let n=[...e,t];return r&&n.length>r?n.slice(1):n}function He(e,t,r=0){let n=[t,...e];return r&&n.length>r?n.slice(0,-1):n}var V=Symbol();function z(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===V?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var nr=class extends b{#e;#t;#r;constructor(){super(),this.#r=e=>{if(!P&&window.addEventListener){let t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},Z=new nr;var ir=class extends b{#e=!0;#t;#r;constructor(){super(),this.#r=e=>{if(!P&&window.addEventListener){let t=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(r=>{r(e)}))}isOnline(){return this.#e}},G=new ir;function et(){let e,t,r=new Promise((i,o)=>{e=i,t=o});r.status="pending",r.catch(()=>{});function n(i){Object.assign(r,i),delete r.resolve,delete r.reject}return r.resolve=i=>{n({status:"fulfilled",value:i}),e(i)},r.reject=i=>{n({status:"rejected",reason:i}),t(i)},r}function sr(e){return Math.min(1e3*2**e,3e4)}function Oe(e){return(e??"online")==="online"?G.isOnline():!0}var tt=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function H(e){return e instanceof tt}function ee(e){let t=!1,r=0,n=!1,i,o=et(),c=d=>{n||(R(new tt(d)),e.abort?.())},s=()=>{t=!0},a=()=>{t=!1},p=()=>Z.isFocused()&&(e.networkMode==="always"||G.isOnline())&&e.canRun(),l=()=>Oe(e.networkMode)&&e.canRun(),h=d=>{n||(n=!0,e.onSuccess?.(d),i?.(),o.resolve(d))},R=d=>{n||(n=!0,e.onError?.(d),i?.(),o.reject(d))},y=()=>new Promise(d=>{i=g=>{(n||p())&&d(g)},e.onPause?.()}).then(()=>{i=void 0,n||e.onContinue?.()}),m=()=>{if(n)return;let d,g=r===0?e.initialPromise:void 0;try{d=g??e.fn()}catch(f){d=Promise.reject(f)}Promise.resolve(d).then(h).catch(f=>{if(n)return;let k=e.retry??(P?0:3),x=e.retryDelay??sr,I=typeof x=="function"?x(r,f):x,Et=k===!0||typeof k=="number"&&r<k||typeof k=="function"&&k(r,f);if(t||!Et){R(f);return}r++,e.onFail?.(r,f),Je(I).then(()=>p()?void 0:y()).then(()=>{t?R(f):m()})})};return{promise:o,cancel:c,continue:()=>(i?.(),o),cancelRetry:s,continueRetry:a,canStart:l,start:()=>(l()?m():y().then(m),o)}}function or(){let e=[],t=0,r=s=>{s()},n=s=>{s()},i=s=>setTimeout(s,0),o=s=>{t?e.push(s):i(()=>{r(s)})},c=()=>{let s=e;e=[],s.length&&i(()=>{n(()=>{s.forEach(a=>{r(a)})})})};return{batch:s=>{let a;t++;try{a=s()}finally{t--,t||c()}return a},batchCalls:s=>(...a)=>{o(()=>{s(...a)})},schedule:o,setNotifyFunction:s=>{r=s},setBatchNotifyFunction:s=>{n=s},setScheduler:s=>{i=s}}}var O=or();var te=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Ye(this.gcTime)&&(this.#e=setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(P?1/0:5*60*1e3))}clearGcTimeout(){this.#e&&(clearTimeout(this.#e),this.#e=void 0)}};var rt=class extends te{#e;#t;#r;#n;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.cache,this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=cr(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#n?.promise}setOptions(e){this.options={...this.#o,...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#r.remove(this)}setData(e,t){let r=ze(this.state.data,e,this.options);return this.#i({data:r,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),r}setState(e,t){this.#i({type:"setState",state:e,setStateOptions:t})}cancel(e){let t=this.#n?.promise;return this.#n?.cancel(e),t?t.then(A).catch(A):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(e=>Xe(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===V||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(e=0){return this.state.isInvalidated||this.state.data===void 0||!$e(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#n?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#n?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#n&&(this.#s?this.#n.cancel({revert:!0}):this.#n.cancelRetry()),this.scheduleGc()),this.#r.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#i({type:"invalidate"})}fetch(e,t){if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#n)return this.#n.continueRetry(),this.#n.promise}if(e&&this.setOptions(e),!this.options.queryFn){let s=this.observers.find(a=>a.options.queryFn);s&&this.setOptions(s.options)}let r=new AbortController,n=s=>{Object.defineProperty(s,"signal",{enumerable:!0,get:()=>(this.#s=!0,r.signal)})},i=()=>{let s=z(this.options,t),a={queryKey:this.queryKey,meta:this.meta};return n(a),this.#s=!1,this.options.persister?this.options.persister(s,a,this):s(a)},o={fetchOptions:t,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:i};n(o),this.options.behavior?.onFetch(o,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==o.fetchOptions?.meta)&&this.#i({type:"fetch",meta:o.fetchOptions?.meta});let c=s=>{H(s)&&s.silent||this.#i({type:"error",error:s}),H(s)||(this.#r.config.onError?.(s,this),this.#r.config.onSettled?.(this.state.data,s,this)),this.scheduleGc()};return this.#n=ee({initialPromise:t?.initialPromise,fn:o.fetchFn,abort:r.abort.bind(r),onSuccess:s=>{if(s===void 0){c(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(s)}catch(a){c(a);return}this.#r.config.onSuccess?.(s,this),this.#r.config.onSettled?.(s,this.state.error,this),this.scheduleGc()},onError:c,onFail:(s,a)=>{this.#i({type:"failed",failureCount:s,error:a})},onPause:()=>{this.#i({type:"pause"})},onContinue:()=>{this.#i({type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0}),this.#n.start()}#i(e){let t=r=>{switch(e.type){case"failed":return{...r,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...ar(r.data,this.options),fetchMeta:e.meta??null};case"success":return{...r,data:e.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":let n=e.error;return H(n)&&n.revert&&this.#t?{...this.#t,fetchStatus:"idle"}:{...r,error:n,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...e.state}}};this.state=t(this.state),O.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),this.#r.notify({query:this,type:"updated",action:e})})}};function ar(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Oe(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function cr(e){let t=typeof e.initialData=="function"?e.initialData():e.initialData,r=t!==void 0,n=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var Y=class extends b{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,r){let n=t.queryKey,i=t.queryHash??j(n,t),o=this.get(i);return o||(o=new rt({cache:this,queryKey:n,queryHash:i,options:e.defaultQueryOptions(t),state:r,defaultOptions:e.getQueryDefaults(n)}),this.add(o)),o}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){O.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(r=>Ie(t,r))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(r=>Ie(e,r)):t}notify(e){O.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){O.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){O.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}};var nt=class extends te{#e;#t;#r;constructor(e){super(),this.mutationId=e.mutationId,this.#t=e.mutationCache,this.#e=[],this.state=e.state||ur(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#e.includes(e)||(this.#e.push(e),this.clearGcTimeout(),this.#t.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#e=this.#e.filter(t=>t!==e),this.scheduleGc(),this.#t.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#e.length||(this.state.status==="pending"?this.scheduleGc():this.#t.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){this.#r=ee({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(n,i)=>{this.#n({type:"failed",failureCount:n,error:i})},onPause:()=>{this.#n({type:"pause"})},onContinue:()=>{this.#n({type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#t.canRun(this)});let t=this.state.status==="pending",r=!this.#r.canStart();try{if(!t){this.#n({type:"pending",variables:e,isPaused:r}),await this.#t.config.onMutate?.(e,this);let i=await this.options.onMutate?.(e);i!==this.state.context&&this.#n({type:"pending",context:i,variables:e,isPaused:r})}let n=await this.#r.start();return await this.#t.config.onSuccess?.(n,e,this.state.context,this),await this.options.onSuccess?.(n,e,this.state.context),await this.#t.config.onSettled?.(n,null,this.state.variables,this.state.context,this),await this.options.onSettled?.(n,null,e,this.state.context),this.#n({type:"success",data:n}),n}catch(n){try{throw await this.#t.config.onError?.(n,e,this.state.context,this),await this.options.onError?.(n,e,this.state.context),await this.#t.config.onSettled?.(void 0,n,this.state.variables,this.state.context,this),await this.options.onSettled?.(void 0,n,e,this.state.context),n}finally{this.#n({type:"error",error:n})}}finally{this.#t.runNext(this)}}#n(e){let t=r=>{switch(e.type){case"failed":return{...r,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...r,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:e.error,failureCount:r.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),O.batch(()=>{this.#e.forEach(r=>{r.onMutationUpdate(e)}),this.#t.notify({mutation:this,type:"updated",action:e})})}};function ur(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var $=class extends b{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#r=0}#e;#t;#r;build(e,t,r){let n=new nt({mutationCache:this,mutationId:++this.#r,options:e.defaultMutationOptions(t),state:r});return this.add(n),n}add(e){this.#e.add(e);let t=re(e);if(typeof t=="string"){let r=this.#t.get(t);r?r.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){let t=re(e);if(typeof t=="string"){let r=this.#t.get(t);if(r)if(r.length>1){let n=r.indexOf(e);n!==-1&&r.splice(n,1)}else r[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){let t=re(e);if(typeof t=="string"){let n=this.#t.get(t)?.find(i=>i.state.status==="pending");return!n||n===e}else return!0}runNext(e){let t=re(e);return typeof t=="string"?this.#t.get(t)?.find(n=>n!==e&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){O.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(r=>Te(t,r))}findAll(e={}){return this.getAll().filter(t=>Te(e,t))}notify(e){O.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(t=>t.state.isPaused);return O.batch(()=>Promise.all(e.map(t=>t.continue().catch(A))))}};function re(e){return e.options.scope?.id}function ge(e){return{onFetch:(t,r)=>{let n=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,o=t.state.data?.pages||[],c=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},a=0,p=async()=>{let l=!1,h=m=>{Object.defineProperty(m,"signal",{enumerable:!0,get:()=>(t.signal.aborted?l=!0:t.signal.addEventListener("abort",()=>{l=!0}),t.signal)})},R=z(t.options,t.fetchOptions),y=async(m,d,g)=>{if(l)return Promise.reject();if(d==null&&m.pages.length)return Promise.resolve(m);let f={queryKey:t.queryKey,pageParam:d,direction:g?"backward":"forward",meta:t.options.meta};h(f);let k=await R(f),{maxPages:x}=t.options,I=g?He:Ze;return{pages:I(m.pages,k,x),pageParams:I(m.pageParams,d,x)}};if(i&&o.length){let m=i==="backward",d=m?lr:it,g={pages:o,pageParams:c},f=d(n,g);s=await y(g,f,m)}else{let m=e??o.length;do{let d=a===0?c[0]??n.initialPageParam:it(n,s);if(a>0&&d==null)break;s=await y(s,d),a++}while(a<m)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(p,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r):t.fetchFn=p}}}function it(e,{pages:t,pageParams:r}){let n=t.length-1;return t.length>0?e.getNextPageParam(t[n],t,r[n],r):void 0}function lr(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}var ve=class{#e;#t;#r;#n;#o;#s;#i;#a;constructor(e={}){this.#e=e.queryCache||new Y,this.#t=e.mutationCache||new $,this.#r=e.defaultOptions||{},this.#n=new Map,this.#o=new Map,this.#s=0}mount(){this.#s++,this.#s===1&&(this.#i=Z.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=G.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#s--,this.#s===0&&(this.#i?.(),this.#i=void 0,this.#a?.(),this.#a=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),r=this.#e.build(this,t),n=r.state.data;return n===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(ye(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(n))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:r})=>{let n=r.data;return[t,n]})}setQueryData(e,t,r){let n=this.defaultQueryOptions({queryKey:e}),o=this.#e.get(n.queryHash)?.state.data,c=Ve(t,o);if(c!==void 0)return this.#e.build(this,n).setData(c,{...r,manual:!0})}setQueriesData(e,t,r){return O.batch(()=>this.#e.findAll(e).map(({queryKey:n})=>[n,this.setQueryData(n,t,r)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;O.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r)})})}resetQueries(e,t){let r=this.#e,n={type:"active",...e};return O.batch(()=>(r.findAll(e).forEach(i=>{i.reset()}),this.refetchQueries(n,t)))}cancelQueries(e,t={}){let r={revert:!0,...t},n=O.batch(()=>this.#e.findAll(e).map(i=>i.cancel(r)));return Promise.all(n).then(A).catch(A)}invalidateQueries(e,t={}){return O.batch(()=>{if(this.#e.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none")return Promise.resolve();let r={...e,type:e?.refetchType??e?.type??"active"};return this.refetchQueries(r,t)})}refetchQueries(e,t={}){let r={...t,cancelRefetch:t.cancelRefetch??!0},n=O.batch(()=>this.#e.findAll(e).filter(i=>!i.isDisabled()).map(i=>{let o=i.fetch(void 0,r);return r.throwOnError||(o=o.catch(A)),i.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(n).then(A)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let r=this.#e.build(this,t);return r.isStaleByTime(ye(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(A).catch(A)}fetchInfiniteQuery(e){return e.behavior=ge(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(A).catch(A)}ensureInfiniteQueryData(e){return e.behavior=ge(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return G.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#r}setDefaultOptions(e){this.#r=e}setQueryDefaults(e,t){this.#n.set(q(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#n.values()],r={};return t.forEach(n=>{K(e,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(e,t){this.#o.set(q(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#o.values()],r={};return t.forEach(n=>{K(e,n.mutationKey)&&(r={...r,...n.defaultOptions})}),r}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#r.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=j(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===V&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#r.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}};var hr=new ve({defaultOptions:{queries:{staleTime:3e4}},queryCache:new Y({onError:(e,t)=>{}}),mutationCache:new $}),st=hr;var ot="dtect_security_sdk_state",at=typeof window<"u",ct={isLoading:!1,token:"",visitorId:"",projectId:"",questionData:null,clientData:null,aiCheckData:null,tokens:null},ne={state:{...ct},securityKeys:{behaviorKey:"",automationKey:""}};function ut(){if(!at)return ne;try{let e=sessionStorage.getItem(ot);if(!e)return ne;let t=JSON.parse(e);return t.expiresAt&&t.expiresAt<Date.now()?ne:{state:{...ct,...t.state},securityKeys:t.securityKeys||{behaviorKey:"",automationKey:""}}}catch{return ne}}function S(e){if(at)try{let t=Date.now()+864e5,r={...e,expiresAt:t};sessionStorage.setItem(ot,JSON.stringify(r))}catch{}}function lt(e){return e.token||B()}async function _(e,t="info",r={}){let n=`${r.endpoint??"https://api.dtect.io/security"}/log`,i={message:e,type:t,payload:r};navigator.sendBeacon(n,JSON.stringify(i))}var ie,T="https://api.dtect.io/security",se=`${T}/client/check`,L="",F="",ht="0.0.19";var fr="20000000-aaaa-bbbb-cccc-000000000002",oe;var{state:u,securityKeys:{automationKey:D,behaviorKey:N}}=ut(),dr=Ge,X;async function pr({clientId:e,apiKey:t,endpoint:r}){if(ae({automationKey:D,behaviorKey:N}))return{automationKey:D,behaviorKey:N};let n=await st.fetchQuery({queryKey:["getClientConfig",e,t],queryFn:()=>me({url:`${r}/client/config`,headers:{"client-id":L,"x-api-key":F}})});if(!ae(n))throw new Error;return D=n.automationKey,N=n.behaviorKey,S({state:u,securityKeys:n}),n}function be(e){if(e instanceof Error){if(e?.message?.includes("maintenance_mode"))throw new Error(E.MAINTENANCE_MODE);if(e?.message?.includes("rate-limited"))throw new Error(E.RATE_LIMIT_REACHED);switch(e?.message){case U.ERROR_RATE_LIMIT:throw new Error(E.RATE_LIMIT_REACHED);default:throw new Error(E.INTERNAL_SERVER_ERROR)}}throw new Error(E.FAILED_TO_GET_SECURITY_TOKEN)}function M(){if(pt(u)&&ae({automationKey:D,behaviorKey:N}))return!0;let e=ce(),t=document.querySelector("#dtect-h-captcha");return!!ie&&!!(t||e)}function ft(){return!!(L&&F)}function Er(){return new Promise(e=>{let t=()=>{window?.hcaptcha?e():requestAnimationFrame(t)};t()})}var ce=()=>window?.location?.href?.includes("localhost")||window?.location?.href?.includes("file:///");async function mr({behaviorKey:e}){if(ie=await U.load({apiKey:e,endpoint:["https://fp.dtect.io",U.defaultEndpoint],scriptUrlPattern:["https://fp.dtect.io/web/v<version>/<apiKey>/loader_v<loaderVersion>.js",U.defaultScriptUrlPattern]}),ce()||(await Er(),await window.hcaptcha.render("dtect-h-captcha",{sitekey:D,size:"invisible"})),!ie)throw new Error(E.SDK_INIT_ERROR)}async function Rr(){let e=performance.now();if(u.tokens){let a=(performance.now()-e).toFixed();return _(`getTokens finishes in ${a}ms`,"info",{function:"getTokens",endpoint:T,diff:a,token:u.token}),u.tokens}let t=new Promise(s=>{let a=ie?.get();s(a)}),r=new Promise(async s=>{ce()&&s({response:fr});let p=await window?.hcaptcha?.execute({async:!0});s(p)}),[n,i]=await Promise.all([r,t]);u.tokens={behaviorRequestId:i?.requestId,behaviorToken:i?.sealedResult,automationToken:n?.response};let c=(performance.now()-e).toFixed();return _(`getTokens finishes in ${c}ms`,"info",{function:"getTokens",endpoint:T,diff:c,token:u.token}),u.tokens}function yr(e){let t=e?.projectId,r=e?.visitorId||B();return(typeof e?.projectId=="number"||typeof e?.visitorId=="number")&&(t=`${e?.projectId}`,r=`${e?.visitorId}`),{visitorId:r,projectId:t}}function Pe(e){if(u.projectId&&u.visitorId)return{visitorId:u.visitorId,projectId:u.projectId};let{projectId:t,visitorId:r}=yr(e);return{projectId:t,visitorId:r}}async function dt(e,t){let r=performance.now();if(!M())throw new Error(E.NOT_INITIALIZED);if(!ft())throw new Error(E.MISSING_CREDENTIALS);let{projectId:n,visitorId:i}=Pe(e);if(u.projectId=n,u.visitorId=i,!e||!n?.trim())throw new Error(E.FAILED_TO_GET_SECURITY_RESULT);try{let o=await Rr();if(o?.behaviorToken&&o?.behaviorRequestId&&o?.automationToken){let c={behaviorToken:o.behaviorToken,automationToken:o.automationToken,behaviorRequestId:o.behaviorRequestId,entryLink:window?.location?.href,securitySettings:e.securitySettings,metaData:e.metaData};u.clientData=c;let s={...e,projectId:n,visitorId:i,clientData:c,version:"0.0.19",token:u.token,questionData:u.questionData,aiCheckData:u.aiCheckData},a=await J({url:`${t}`,body:{...s},headers:{"client-id":L,"x-api-key":F}});if("token"in a||"results"in a){S({state:u,securityKeys:{automationKey:D,behaviorKey:N}});let l=(performance.now()-r).toFixed();return _(`getResultBase finishes in ${l}ms`,"info",{function:"getResultBase",endpoint:T,diff:l,token:u.token}),a}}throw new Error(E.INTERNAL_SERVER_ERROR)}catch(o){let s=(performance.now()-r).toFixed();if(_("getResultBase error","error",{function:"getResultBase",endpoint:T,error:o,diff:s,token:u.token}),o instanceof Error){if(o?.message?.includes("maintenance_mode"))throw new Error(E.MAINTENANCE_MODE);if(o?.message?.includes("rate-limited")||o?.message?.includes("429"))throw new Error(E.RATE_LIMIT_REACHED);switch(o?.message){case U.ERROR_RATE_LIMIT:throw new Error(E.RATE_LIMIT_REACHED);default:throw new Error(E.INTERNAL_SERVER_ERROR)}}throw new Error(E.FAILED_TO_GET_SECURITY_RESULT)}}async function _e(e){return await dt(e,`${T}/client/check/result`)}async function Ae(e){return await dt(e,`${T}/client/check`)}async function De(e){let t=performance.now();if(!M())throw new Error(E.NOT_INITIALIZED);let{respondentType:r,language:n}=e;try{let i=await me({url:`${T}/client/quality-questions/${r}/${n}`,headers:{"client-id":L,"x-api-key":F}});if(i){let c=(performance.now()-t).toFixed();return _(`getQualityQuestions finishes in ${c}ms`,"info",{function:"getQualityQuestions",endpoint:T,diff:c,token:u.token}),i}throw new Error(E.INTERNAL_SERVER_ERROR)}catch(i){let c=(performance.now()-t).toFixed();_("getQualityQuestions error","error",{endpoint:T,error:i,diff:c,token:u.token}),be(i)}}async function we(e){let t=performance.now();if(!M())throw new Error(E.NOT_INITIALIZED);u.questionData||(u.questionData={questions:e.questions});let{visitorId:r,projectId:n}=Pe(e);u.visitorId=r,u.projectId=n;try{let i=await J({url:se,headers:{"client-id":L,"x-api-key":F},body:{token:u.token,visitorId:r,projectId:n,version:ht,questionData:u.questionData,aiCheckData:u.aiCheckData,clientData:u.clientData}});if(i){S({state:u,securityKeys:{automationKey:D,behaviorKey:N}});let c=(performance.now()-t).toFixed();return _(`checkQualityQuestions finishes in ${c}ms`,"info",{function:"checkQualityQuestions",endpoint:T,diff:c,token:u.token}),i}throw new Error(E.INTERNAL_SERVER_ERROR)}catch(i){let c=(performance.now()-t).toFixed();_("checkQualityQuestions error","error",{endpoint:T,error:i,diff:c,token:u.token}),be(i)}}async function Ne(e){let t=performance.now();if(!M())throw new Error(E.NOT_INITIALIZED);u.aiCheckData={timeTakenSeconds:e.timeTakenSeconds,qbc:e.qbc||X.qbc,mas:e.mas||X.mas,scb:e.scb||X.scb,apd:e.apd||X.apd};let{visitorId:r,projectId:n}=Pe(e);u.visitorId=r,u.projectId=n;try{let i=await J({url:se,headers:{"client-id":L,"x-api-key":F},body:{token:u.token,visitorId:r,projectId:n,version:ht,clientData:u.clientData,questionData:u.questionData,aiCheckData:u.aiCheckData}});if(i){S({state:u,securityKeys:{automationKey:D,behaviorKey:N}});let c=(performance.now()-t).toFixed();return _(`isAIUsageDetected finishes in ${c}ms`,"info",{function:"isAIUsageDetected",endpoint:T,diff:c,token:u.token}),i}throw new Error(E.INTERNAL_SERVER_ERROR)}catch(i){let c=(performance.now()-t).toFixed();_("isAIUsageDetected error","error",{endpoint:T,error:i,diff:c,token:u.token}),be(i)}}function Ir(){let e=performance.now(),t=document.querySelector("head"),r=document.querySelector("body");if(!ce()){r?.insertAdjacentHTML("beforeend",'<div id="dtect-h-captcha" ></div>');let i=document.createElement("script");i.setAttribute("src","https://js.hcaptcha.com/1/api.js"),i.setAttribute("async","true"),i.setAttribute("defer","true"),t?.append(i);let c=(performance.now()-e).toFixed();_(`loadHCaptcha finishes in ${c}ms`,"info",{function:"loadHCaptcha",endpoint:T,diff:c,token:u.token})}}function ae(e){return e?.automationKey&&e?.behaviorKey}function pt(e){let t=e.tokens;return!!(t&&t.behaviorToken&&t.behaviorRequestId&&t.automationToken)}async function Tr(e){let t=performance.now();if(!e?.clientId||!e?.apiKey)throw _(E.MISSING_CREDENTIALS,"error",{endpoint:T,...e}),new Error(E.MISSING_CREDENTIALS);let{clientId:r,apiKey:n,endpoint:i="https://api.dtect.io/security",includeResults:o}=e;T=i,se=`${T}/client/check`;let c=lt(u);if(u.isLoading){if(M())return oe;throw _(E.DUPLICATE_INITIALIZATION,"error",{endpoint:T,clientId:r,apiKey:n,token:u.token}),new Error(E.DUPLICATE_INITIALIZATION)}if(X=Qe(u.aiCheckData),L=r,F=n,o&&(se=`${T}/client/check/result`),u={...u,isLoading:!0,token:c||""},pt(u)&&ae({automationKey:D,behaviorKey:N}))return u={...u,isLoading:!1,token:c},S({state:u,securityKeys:{automationKey:D,behaviorKey:N}}),{getSecurityResult:_e,getSecurityToken:Ae,isAIUsageDetected:Ne,checkQualityQuestions:we,getQualityQuestions:De,LanguageCodes:Q,QualityQuestionsRespondentTypes:C};if(!ft())throw _(E.MISSING_CREDENTIALS,"error",{endpoint:T,...e}),new Error(E.MISSING_CREDENTIALS);if(M())return oe;Ir();try{let a=await pr({clientId:r,apiKey:n,endpoint:i});if(M())throw new Error;return mr({behaviorKey:a.behaviorKey}).then(()=>{let l=(performance.now()-t).toFixed();return _(`init() finishes ${l}ms`,"info",{endpoint:T,function:"init",diff:l,token:u.token}),{getSecurityResult:_e,getSecurityToken:Ae,SecurityAPIError:dr,isAIUsageDetected:Ne,checkQualityQuestions:we,getQualityQuestions:De,LanguageCodes:Q,QualityQuestionsRespondentTypes:C}}).catch(p=>{throw new Error(p.message)})}catch(a){if(a instanceof Error){if(_(a.message,"error",{function:"init",endpoint:T,error:a,token:u.token}),a?.message?.includes("maintenance_mode"))throw new Error(E.MAINTENANCE_MODE);if([E.INVALID_API_KEY,E.UNAUTHORIZED].includes(a?.message))throw new Error(E.INVALID_CREDENTIALS)}throw new Error(E.SDK_INIT_ERROR)}finally{u={...u,isLoading:!1,token:c},S({state:u,securityKeys:{automationKey:D,behaviorKey:N}})}}oe={init:Tr,getSecurityResult:_e,getSecurityToken:Ae,isAIUsageDetected:Ne,checkQualityQuestions:we,getQualityQuestions:De,QualityQuestionsRespondentTypes:C,LanguageCodes:Q};var Si=oe;export{Q as LanguageCodes,C as QualityQuestionsRespondentTypes,dr as SecurityAPIError,we as checkQualityQuestions,Si as default,De as getQualityQuestions,_e as getSecurityResult,Ae as getSecurityToken,Tr as init,Ne as isAIUsageDetected};
|