@incodetech/tri-sdk 0.3.0 → 0.3.1-rc.0
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/tri.cjs.js +1 -1
- package/dist/tri.esm.js +1 -1
- package/dist/tri.umd.js +1 -1
- package/package.json +1 -1
package/dist/tri.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"t",{value:1});class t{constructor(){this.i=0}static get instance(){return t.o||(t.o=new t),t.o}get DEBUG(){return this.i}set DEBUG(t){this.i=t}warn(t,n,...e){this.i&&this.u("warn",t,n,...e)}error(t,n,...e){this.i&&this.u("error",t,n,...e)}info(t,n,...e){this.i&&this.u("info",t,n,...e)}fatal(t,n,e,...i){this.u(t,n,e,...i)}u(t,n,e,...i){const o=n?`[${n}]`:"",r=console?.[t];r&&r(`[IncodeTRI]${o} ${e}`,...i)}}const n=t.instance;function e(t,n,e){let i=t,o=n;if("devicepixelratiochange"===n){const t=window.devicePixelRatio;i=window.matchMedia(`(resolution: ${t}dppx)`),o="change"}i.addEventListener(o,e,{capture:1,passive:1})}function i(t,n,e){let i=t,o=n;if("devicepixelratiochange"===n){const t=window.devicePixelRatio;i=window.matchMedia(`(resolution: ${t}dppx)`),o="change"}i.removeEventListener(o,e,{capture:1})}const o=globalThis.setTimeout.bind(globalThis),r=globalThis.clearTimeout.bind(globalThis);function s(t,e){try{return t()}catch(t){n.warn("utils","safeSync swallowed error:",t)}}async function c(t){try{return await t()}catch(t){n.warn("utils","safeAsync swallowed error:",t)}}function a(t){return n=>s(()=>t(n))}function u(t){return(...e)=>{try{t(...e)}catch(t){n.warn("utils","safeTimer swallowed error:",t)}}}function l(t,n){return o(u(t),n)}function d(t){if(null!==t)try{r(t)}catch(t){n.warn("utils","safeClearTimeout swallowed error:",t)}}const h=new Set(["xmlhttprequest","fetch","beacon","navigation","script","link","css","img","iframe","video","audio"]),f=new Set(["xmlhttprequest","fetch","beacon"]);function p(t,n){return n?t:null}function m(t,n){const e=t,i=t.responseStart>0,o=p(t.domainLookupEnd-t.domainLookupStart,i),r=p(t.connectEnd-t.connectStart,i),s=p(t.connectEnd>0&&t.secureConnectionStart>0?t.connectEnd-t.secureConnectionStart:0,i),c=p(t.responseStart-t.requestStart,i),a=p(t.responseEnd-t.responseStart,i),u=i?t.transferSize:null,l=i?t.encodedBodySize:null,d=i?t.decodedBodySize:null,f=i&&t.nextHopProtocol||null,m=i&&void 0!==e.deliveryType?e.deliveryType:null,w=e.responseStatus,y=void 0!==w&&0!==w?w:null;return{name:"network_request",timestamp:Date.now(),performanceTime:t.startTime+t.duration,url:n(t.name),initiatorType:(v=t.initiatorType,h.has(v)?v:"other"),startTime:t.startTime,durationMs:t.duration,dnsLookupMs:o,tcpConnectMs:r,tlsHandshakeMs:s,ttfbMs:c,responseDownloadMs:a,transferSize:u,encodedBodySize:l,decodedBodySize:d,nextHopProtocol:f,deliveryType:m,responseStatus:y};var v}function w(){}const y=2e3;function v(t){return!!t&&t.nodeType===Node.TEXT_NODE}function g(t,n){return t.tagName?.toLowerCase()===n.toLowerCase()}function b(t){return!!t&&t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function k(t){return t?t.hasAttribute("data-tri-ignore"):0}function T(t){return t?t.hasAttribute("data-tri-redact"):0}function _(t,n){return n?.includes(t.toLowerCase())??0}function I(t){try{return new URL(t).origin!==window.location.origin}catch{return 0}}function x(t,n){return t?t[n]?.enabled??0:1}function S(){const t=document.activeElement;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement){const n=t.selectionStart,e=t.selectionEnd;return null==n||null==e||n===e?null:t.value.substring(n,e)}const n=window.getSelection();return!n||n.isCollapsed?null:n.toString()||null}function E(t,n){return"off"===n||k(t)||T(t)?0:1}function A(t){const n=document.activeElement;if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)return n;const e=window.getSelection();return(i=("start"===t?e?.anchorNode:e?.focusNode)??null)?v(i)?i.parentElement:i instanceof Element?i:null:null;var i}function M(){const t=window,n="__fpjs_p_l_b",e=t[n];if(function(t,n){var e;const i=null===(e=Object.getOwnPropertyDescriptor)||void 0===e?void 0:e.call(Object,t,n);(null==i?void 0:i.configurable)?delete t[n]:i&&!i.writable||(t[n]=void 0)}(t,n),"function"!=typeof(null==e?void 0:e.load))throw new Error($);return e}const D="Blocked by CSP",P="The endpoint parameter is not a valid URL";function C(t){return function(t,n){const e=document,i="securitypolicyviolation";let o;const r=n=>{const e=new URL(t,location.href),{blockedURI:i}=n;i!==e.href&&i!==e.protocol.slice(0,-1)&&i!==e.origin||(o=n,s())};e.addEventListener(i,r);const s=()=>e.removeEventListener(i,r);return Promise.resolve().then(n).then(t=>(s(),t),t=>new Promise(t=>{const n=new MessageChannel;n.port1.onmessage=()=>t(),n.port2.postMessage(null)}).then(()=>{if(s(),o)return(()=>{throw new Error(D)})();throw t}))}(t,()=>function(t){return new Promise((n,e)=>{if(function(t){if(URL.prototype)try{return new URL(t,location.href),0}catch(t){if(t instanceof Error&&"TypeError"===t.name)return 1;throw t}}(t))throw new Error(P);const i=document.createElement("script"),o=()=>{var t;return null===(t=i.parentNode)||void 0===t?void 0:t.removeChild(i)},r=document.head||document.getElementsByTagName("head")[0];i.onload=()=>{o(),n()},i.onerror=()=>{o(),e(new Error(L))},i.async=1,i.src=t,r.appendChild(i)})}(t)).then(M)}const R="API key required";var z="3.12.9";const L="Failed to load the JS script of the agent",$="9319",U={scriptUrl:"https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js"};function O(t){function n(){return globalThis.window&&globalThis.window[t]&&void 0!==globalThis.window[t]}return{get:function(e){if(!n())return null;try{const n=window[t].getItem(e)??"null";return"null"===n?null:JSON.parse(n)}catch{return null}},set:function(e,i){n()&&s(()=>window[t].setItem(e,JSON.stringify(i)))},remove:function(e){n()&&s(()=>window[t].removeItem(e))},key:function(e){return n()?window[t].key(e):null},get length(){return n()?window[t].length:0}}}const q=O("localStorage"),B=O("sessionStorage"),j="__tri_fingerprint";let H=null,N=null;async function F(t){try{const n=await function(t){return H||(H=function(t){var n,e;const{picked:i,rest:o}=function(t,n){const e={},i={};for(const[o,r]of Object.entries(t))n.includes(o)?e[o]=r:i[o]=r;return{picked:e,rest:i}}(t,["scriptUrlPattern","token","apiKey"]),r=null!==(n=i.apiKey)&&void 0!==n?n:i.token,s=null!==(e=function(t,n){return function(t,n){return Object.prototype.hasOwnProperty.call(t,n)}(t,n)?t[n]:void 0}(t,"scriptUrlPattern"))&&void 0!==e?e:U.scriptUrl,[c,a]=function(){const t=[],n=()=>{t.push({time:new Date,state:document.visibilityState})},e=((i=document).addEventListener("visibilitychange",o=n,r),()=>i.removeEventListener("visibilitychange",o,r));var i,o,r;return n(),[t,e]}();return Promise.resolve().then(()=>{if(!r||"string"!=typeof r)throw new Error(R);return function(t,n){const e=[],[i,o]=function(t){const n=function(t){const n=[...t];return{current:()=>n[0],postpone(){const t=n.shift();void 0!==t&&n.push(t)},exclude(){n.shift()}}}(t),e=function(){let t=0;return()=>Math.random()*Math.min(3e3,100*Math.pow(2,t++))}(),i=new Set;return[n.current(),(t,o)=>{let r;const s=o instanceof Error?o.message:"";if(s===D||s===P)n.exclude(),r=0;else if(s===$)n.exclude();else if(s===L){const e=Date.now()-t.getTime()<50,o=n.current();o&&e&&!i.has(o)&&(i.add(o),r=0),n.postpone()}else n.postpone();const c=n.current();return void 0===c?void 0:[c,null!=r?r:t.getTime()+e()-Date.now()]}]}(t);let r;if(void 0===i)return Promise.reject(new TypeError("The list of script URL patterns is empty"));const s=t=>{const i=new Date,c=n=>e.push({url:t,startedAt:i,finishedAt:new Date,error:n}),a=n(t);return a.then(()=>c(),c),a.catch(t=>{if(null!=r||(r=t),e.length>=5)throw r;const n=o(i,t);if(!n)throw r;const[c,a]=n;return(u=a,new Promise(t=>setTimeout(t,u))).then(()=>s(c));var u})};return s(i).then(t=>[t,e])}(function(t,n){return(Array.isArray(t)?t:[t]).map(t=>function(t,n){const e=encodeURIComponent;return t.replace(/<[^<>]+>/g,t=>"<version>"===t?"3":"<apiKey>"===t?e(n):"<loaderVersion>"===t?e(z):t)}(String(t),n))}(s,r),C)}).catch(t=>{throw a(),function(t){return t instanceof Error&&t.message===$?new Error(L):t}(t)}).then(([t,n])=>(a(),t.load({...o,ldi:{attempts:n,visibilityStates:c}})))}({apiKey:t.apiKey,region:t.region,endpoint:t.endpoint,scriptUrlPattern:t.scriptUrlPattern}).catch(t=>{throw H=null,t}),H)}(t),e=await n.get({timeout:t.timeoutMs,extendedResult:1});if(!e.visitorId)return null;const i=t.cacheTtlMs??2592e6;return i>0&&function(t,n,e){const i={visitorId:t,requestId:n,expiresAt:Date.now()+e};q.set(j,i)}(e.visitorId,e.requestId,i),{visitorId:e.visitorId,requestId:e.requestId}}catch{return null}}const X={apiKey:"5uYRiI0XM6p8k4124ELX",endpoint:"https://fingerprint.incodesmile.com",scriptUrlPattern:"https://fingerprint.incodesmile.com/web/v<version>/<apiKey>/loader_v<loaderVersion>.js"},K={focusin:"in",focusout:"out"};function V(t){return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement}const Y=new Set(["Shift","Control","Alt","Meta","Backspace","Delete","Enter","Tab","CapsLock","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]),J={mouse:"mouse",touch:"touch",pen:"pen"},G={pointerdown:"down",pointerup:"up",click:"click",dblclick:"dblclick",contextmenu:"contextmenu"};function Z(t,n,e,i,o){return{name:"navigation",timestamp:Date.now(),phase:t,type:n,from:e.from,to:e.to,timeOrigin:i,timing:o}}const Q={fingerprint:{create:function(t){let n=0;return c(async()=>{const e=await async function(t){const n=function(){const t=q.get(j);return t?"string"!=typeof t.visitorId||"number"!=typeof t.expiresAt||t.expiresAt<=Date.now()?(q.remove(j),null):{visitorId:t.visitorId,requestId:"string"==typeof t.requestId?t.requestId:""}:null}();return n?{visitorId:n.visitorId,requestId:n.requestId||null}:N||(N=F(t).finally(()=>{N=null}),N)}(X);!n&&e&&t.push({name:"fingerprint",deviceId:e.visitorId,requestId:e.requestId,timestamp:Date.now()})}),()=>{n=1}},layer:"device-fingerprinting"},pointer:{create:function(t,n,o){const r=a(n=>{const e=function(n){const e=n,i=function(t){if("mouse"===t.pointerType)return{button:t.button,buttons:t.buttons};const n={force:t.pressure,contact:Math.min(t.width,t.height)};return"pen"===t.pointerType&&(n.tiltX=t.tiltX,n.tiltY=t.tiltY,n.twist=t.twist),n}(e);return{id:e.pointerId,name:"pointer",timestamp:Date.now(),type:J[e.pointerType]??"unknown",phase:G[n.type],isTrusted:e.isTrusted,element:t.resolveElement(e.target),isPrimary:e.isPrimary,modifiers:{shift:e.shiftKey,ctrl:e.ctrlKey,alt:e.altKey,meta:e.metaKey},coordinates:{x:e.clientX,y:e.clientY},...i}}(n);t.push(e)});return x(o,"pointer")&&(e(document,"pointerdown",r),e(document,"pointerup",r)),x(o,"click")&&e(document,"click",r),x(o,"dblclick")&&e(document,"dblclick",r),x(o,"contextmenu")&&e(document,"contextmenu",r),()=>{i(document,"pointerdown",r),i(document,"pointerup",r),i(document,"click",r),i(document,"dblclick",r),i(document,"contextmenu",r)}},layer:"behavioral",events:["pointer","click","dblclick","contextmenu"]},pointermove:{create:function(t){let n=null,o=null;const r=a(e=>{const i=e;return n&&n.id!==i.pointerId&&(t.push(n),n=null),n?n.samples.ts.length>=50?(t.push(n),n=s(i),void c(t)):(n.samples.x.push(i.clientX),n.samples.y.push(i.clientY),n.samples.ts.push(i.timeStamp),"pen"===i.pointerType&&(n.samples.tiltX?.push(i.tiltX),n.samples.tiltY?.push(i.tiltY)),"mouse"!==i.pointerType&&(n.samples.force?.push(i.pressure),n.samples.radius?.push(Math.max(i.width,i.height))),void c(t)):(n=s(i),void c(t))});function s(t){const n=function(t){if("mouse"===t.pointerType)return null;const n={force:[t.pressure],radius:[Math.max(t.width,t.height)]};return"pen"===t.pointerType&&(n.tiltX=[t.tiltX],n.tiltY=[t.tiltY]),n}(t);return{name:"pointer",timestamp:Date.now(),id:t.pointerId,type:t.pointerType,phase:"move",isTrusted:t.isTrusted,isPrimary:t.isPrimary,samples:{x:[t.clientX],y:[t.clientY],ts:[t.timeStamp],...n??{}}}}function c(t){o&&clearTimeout(o),o=setTimeout(()=>{n&&(t.push(n),n=null),o=null},y)}return e(document,"pointermove",r),()=>{i(document,"pointermove",r),o&&(clearTimeout(o),o=null),n&&(t.push(n),n=null)}},layer:"behavioral"},focus:{create:function(t){const n=a(n=>{const e=function(n){const e=n;return{name:"focus",type:K[n.type]??"unknown",timestamp:Date.now(),isTrusted:e.isTrusted,element:t.resolveElement(e.target),relatedTarget:t.resolveElement(e.relatedTarget)}}(n);t.push(e)});return e(document,"focusin",n),e(document,"focusout",n),()=>{i(document,"focusin",n),i(document,"focusout",n)}},layer:"behavioral"},input:{create:function(t){const n=a(n=>{const e=n;t.push(function(n){return{name:"keystroke",type:"input",timestamp:Date.now(),isTrusted:n.isTrusted,element:t.resolveElement(n.target),inputType:n.inputType??"",isComposing:n.isComposing??0,length:(e=n.target,e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement?e.value.length:0)};var e}(e)),function(t){if("insertReplacementText"===t.inputType)return 1;const n=t.target;return V(n)?function(t){try{return t.matches(":-webkit-autofill")}catch{return 0}}(n):0}(e)&&t.push(function(t,n){const e=t.target;let i=0;return V(e)&&(i=e.value.length),{name:"autofill",timestamp:Date.now(),element:n.resolveElement(e),length:i}}(e,t))});return e(document,"input",n),function(){i(document,"input",n)}},layer:"behavioral"},keystroke:{create:function(t){const{resolve:n,reset:o}=function(){let t=0;const n=new Map;return{resolve:function(e,i){if("keydown"===i){const i=n.get(e);if(void 0!==i)return i;const o=++t;if(n.size>=32){const t=n.keys().next().value;void 0!==t&&n.delete(t)}return n.set(e,o),o}const o=n.get(e);return void 0!==o?(n.delete(e),o):++t},reset:function(){n.clear()}}}(),r=a(e=>{const i=function(t){const e=t,i=t.type;return{name:"keystroke",type:i,id:n(e.code,i),timestamp:Date.now(),isTrusted:e.isTrusted,keys:Y.has(e.key)?[e.key]:[]}}(e);t.push(i)}),s=a(()=>{o()});return e(document,"keydown",r),e(document,"keyup",r),e(window,"blur",s),()=>{i(document,"keydown",r),i(document,"keyup",r),i(window,"blur",s)}},layer:"behavioral"},clipboard:{create:function(t,n="on",o){const r=a(e=>{const i=function(e){const i=e,o=e.type,r=("paste"===e.type?i.clipboardData?.getData("text/plain"):S())??null,s=E(i.target,n);return{name:"clipboard",type:o,timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target),length:r?.length??0,...s&&r?{content:r}:{}}}(e);t.push(i)});return x(o,"paste")&&e(document,"paste",r),x(o,"cut")&&e(document,"cut",r),x(o,"copy")&&e(document,"copy",r),()=>{i(document,"paste",r),i(document,"cut",r),i(document,"copy",r)}},layer:"behavioral",events:["paste","cut","copy"]},form:{create:function(t,n,o){const r=a(n=>{const e={name:"form",type:(i=n).type,timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target)};var i;t.push(e)});return x(o,"submit")&&e(document,"submit",r),x(o,"invalid")&&e(document,"invalid",r),()=>{i(document,"submit",r),i(document,"invalid",r)}},layer:"behavioral",events:["submit","invalid"]},change:{create:function(t){const n=a(n=>{const e=(i=n,{name:"change",timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target)});var i;t.push(e)});return e(document,"change",n),()=>{i(document,"change",n)}},layer:"behavioral"},selection:{create:function(t,n){let o=0,r=0,s=null,c=0,u=0;function l(){s&&(clearTimeout(s),s=null)}function d(){l(),c||u||(s=setTimeout(()=>{s=null,o&&h("timeout")},250))}function h(e){o&&(o=0,l(),function(e){const i=A("end"),o=i&&E(i,n),r=S();t.push({name:"selection",phase:"end",timestamp:Date.now(),trigger:e,isTrusted:1,element:t.resolveElement(i),length:r?.length??0,...o&&r?{content:r}:{}})}(e))}const f=a(()=>{const n=function(){const t=document.getSelection();return!t||t.isCollapsed||0===t.rangeCount}();if(!o&&!n)return o=1,r=Date.now(),t.push({name:"selection",phase:"start",timestamp:r,element:t.resolveElement(A("start"))}),void d();o&&n?h("collapse"):o&&d()}),p=a(t=>{0===t.button&&(c=1,l())}),m=a(t=>{0===t.button&&(c=0,o&&h("pointer"))}),w=a(t=>{"Shift"===t.key&&(u=1,l())}),y=a(t=>{"Shift"===t.key&&(u=0,o&&h("keyboard"))}),v=a(()=>{c=0}),g=a(()=>{"hidden"===document.visibilityState&&(c=0,u=0,o&&h("timeout"))}),b=a(()=>{c=0,o&&h("pointer")});return e(document,"selectionchange",f),e(document,"pointerdown",p),e(document,"pointerup",m),e(document,"keydown",w),e(document,"keyup",y),e(document,"contextmenu",v),e(document,"visibilitychange",g),e(document,"dragend",b),()=>{l(),i(document,"selectionchange",f),i(document,"pointerdown",p),i(document,"pointerup",m),i(document,"keydown",w),i(document,"keyup",y),i(document,"contextmenu",v),i(document,"visibilitychange",g),i(document,"dragend",b)}},layer:"behavioral"},tab:{create:()=>()=>{},layer:"session",events:["state","count"]},visibility:{create:function(t){const n=a(n=>{const e=document.visibilityState;if("visible"!==e&&"hidden"!==e)return;const i={name:"visibility",type:e,timestamp:Date.now(),isTrusted:n.isTrusted};t.push(i)});return e(document,"visibilitychange",n),()=>{i(document,"visibilitychange",n)}},layer:"session"},navigation:{create:function(t){let n=t.sanitizeUrl(document.referrer||"");function o(e){t.push(e),n=e.to??""}const r=a(()=>{const[n]=performance.getEntriesByType("navigation");var e;o(Z("load",n?.type??"navigate",{from:document.referrer?t.sanitizeUrl(document.referrer):null,to:t.sanitizeUrl(location.href)},performance.timeOrigin,n?{fetchStart:(e=n).fetchStart,domainLookupStart:e.domainLookupStart,domainLookupEnd:e.domainLookupEnd,connectStart:e.connectStart,connectEnd:e.connectEnd,requestStart:e.requestStart,responseStart:e.responseStart,responseEnd:e.responseEnd,domInteractive:e.domInteractive,domContentLoadedEventStart:e.domContentLoadedEventStart,domContentLoadedEventEnd:e.domContentLoadedEventEnd,domComplete:e.domComplete,loadEventStart:e.loadEventStart,loadEventEnd:e.loadEventEnd,redirectCount:e.redirectCount,transferSize:e.transferSize,encodedBodySize:e.encodedBodySize,decodedBodySize:e.decodedBodySize}:void 0))}),c=a(e=>{const i=e;if(null===i.navigationType)return;const r=t.sanitizeUrl(location.href);r!==n&&o(Z("change",i.navigationType,{from:n,to:r},performance.timeOrigin))}),u=a(()=>d("traverse")),l=a(()=>d("hashchange"));function d(e){const i=t.sanitizeUrl(location.href);"hashchange"===e&&i===n||o(Z("change",e,{from:n,to:i},performance.timeOrigin))}const h=history.pushState,f=history.replaceState,p=function(...t){const n=h.apply(this,t);return s(()=>d("push")),n},m=function(...t){const n=f.apply(this,t);return s(()=>d("replace")),n};return window.navigation?e(window.navigation,"currententrychange",c):(history.pushState=p,history.replaceState=m,e(window,"popstate",u),e(window,"hashchange",l)),"complete"===document.readyState?r(new Event("load")):e(window,"load",r),()=>{window.navigation?i(window.navigation,"currententrychange",c):(history.pushState===p&&(history.pushState=h),history.replaceState===m&&(history.replaceState=f),i(window,"popstate",u),i(window,"hashchange",l)),i(window,"load",r)}},layer:"session"},networkconnection:{create:function(t){const n=a(()=>{const n={name:"network",type:"connection",state:navigator.onLine?"online":"offline",timestamp:Date.now()};t.push(n)});return e(window,"online",n),e(window,"offline",n),()=>{i(window,"online",n),i(window,"offline",n)}},layer:"session"},scroll:{create:function(t){let n=null,o=null;const r=a(e=>n?n.samples.ts.length>=50?(t.push(n),n=s(e),void c(t)):(n.samples.x.push(window.scrollX),n.samples.y.push(window.scrollY),n.samples.ts.push(e.timeStamp),void c(t)):(n=s(e),void c(t)));function s(t){return{name:"scroll",timestamp:Date.now(),samples:{x:[window.scrollX],y:[window.scrollY],ts:[t.timeStamp]},height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,pageX:window.pageXOffset,pageY:window.pageYOffset}}function c(t){o&&clearTimeout(o),o=setTimeout(()=>{n&&(t.push(n),n=null),o=null},y)}return e(window,"scroll",r),()=>{i(window,"scroll",r),o&&(clearTimeout(o),o=null),n&&(t.push(n),n=null)}},layer:"behavioral"},viewportresize:{create:function(t){let n=null,o=null;const r=a(e=>n?n.samples.ts.length>=50?(t.push(n),n=s(e),void c(t)):(n.samples.height.push(window.innerHeight),n.samples.width.push(window.innerWidth),n.samples.ts.push(e.timeStamp),n.samples.scrollX.push(window.scrollX),n.samples.scrollY.push(window.scrollY),n.samples.dpr.push(window.devicePixelRatio),void c(t)):(n=s(e),void c(t)));function s(t){return{name:"viewport",type:"resize",timestamp:Date.now(),samples:{height:[window.innerHeight],width:[window.innerWidth],ts:[t.timeStamp],scrollX:[window.scrollX],scrollY:[window.scrollY],dpr:[window.devicePixelRatio]}}}function c(t){o&&clearTimeout(o),o=setTimeout(()=>{n&&(t.push(n),n=null),o=null},y)}return e(window,"resize",r),()=>{i(window,"resize",r),o&&(clearTimeout(o),o=null),n&&(t.push(n),n=null)}},layer:"behavioral"},viewport:{create:function(t,n,o){const r=a(n=>{const e=c(n,"orientation");t.push(e)}),s=a(n=>{const e=c(n,"ratiochange");t.push(e)});function c(t,n){return{name:"viewport",type:n,timestamp:Date.now(),isTrusted:t.isTrusted,height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio}}return x(o,"orientationchange")&&e(window,"orientationchange",r),x(o,"devicepixelratiochange")&&e(window,"devicepixelratiochange",s),()=>{i(window,"orientationchange",r),i(window,"devicepixelratiochange",s)}},layer:"behavioral",events:["orientationchange","devicepixelratiochange"]},sensors:{create:function(t,n,o){let r=null,s=null,c=null,l=null,h=0;function f(){l&&d(l),l=setTimeout(u(()=>{p(),l=null}),y)}function p(){r&&(t.push(r),r=null),s&&(t.push(s),s=null),c&&(t.push(c),c=null)}const m=a(n=>{const e=n,i=e.timeStamp,o=e.acceleration,s=e.accelerationIncludingGravity,c=e.rotationRate;if(!o&&!s&&!c)return;if(!r)return r={name:"sensors",type:"motion",timestamp:Date.now(),interval:e.interval??null,samples:{ax:[o?.x??0],ay:[o?.y??0],az:[o?.z??0],agx:[s?.x??0],agy:[s?.y??0],agz:[s?.z??0],rrAlpha:[c?.alpha??0],rrBeta:[c?.beta??0],rrGamma:[c?.gamma??0],ts:[i]}},void f();if(r.samples.ts.length>=50)return t.push(r),r={name:"sensors",type:"motion",timestamp:Date.now(),interval:e.interval??null,samples:{ax:[o?.x??0],ay:[o?.y??0],az:[o?.z??0],agx:[s?.x??0],agy:[s?.y??0],agz:[s?.z??0],rrAlpha:[c?.alpha??0],rrBeta:[c?.beta??0],rrGamma:[c?.gamma??0],ts:[i]}},void f();const a=r.samples;a.ax.push(o?.x??0),a.ay.push(o?.y??0),a.az.push(o?.z??0),a.agx.push(s?.x??0),a.agy.push(s?.y??0),a.agz.push(s?.z??0),a.rrAlpha.push(c?.alpha??0),a.rrBeta.push(c?.beta??0),a.rrGamma.push(c?.gamma??0),a.ts.push(i),f()}),w=a(n=>{const e=n;if(null==e.alpha&&null==e.beta&&null==e.gamma)return;const i=e.timeStamp,o=e.webkitCompassHeading??0;if(!s)return s={name:"sensors",type:"orientation",timestamp:Date.now(),absolute:h||e.absolute,samples:{alpha:[e.alpha??0],beta:[e.beta??0],gamma:[e.gamma??0],compassHeading:[o],ts:[i]}},void f();if(s.samples.ts.length>=50)return t.push(s),s={name:"sensors",type:"orientation",timestamp:Date.now(),absolute:h||e.absolute,samples:{alpha:[e.alpha??0],beta:[e.beta??0],gamma:[e.gamma??0],compassHeading:[o],ts:[i]}},void f();const r=s.samples;r.alpha.push(e.alpha??0),r.beta.push(e.beta??0),r.gamma.push(e.gamma??0),r.compassHeading.push(o),r.ts.push(i),f()}),v=a(n=>{const e=n.value;if(null==e)return;const i=n.timeStamp;return c?c.samples.ts.length>=50?(t.push(c),c={name:"sensors",type:"light",timestamp:Date.now(),samples:{lux:[e],ts:[i]}},void f()):(c.samples.lux.push(e),c.samples.ts.push(i),void f()):(c={name:"sensors",type:"light",timestamp:Date.now(),samples:{lux:[e],ts:[i]}},void f())});return x(o,"motion")&&e(window,"devicemotion",m),x(o,"orientation")&&("ondeviceorientationabsolute"in window?(h=1,e(window,"deviceorientationabsolute",w)):e(window,"deviceorientation",w)),x(o,"light")&&e(window,"devicelight",v),function(){i(window,"devicemotion",m),i(window,h?"deviceorientationabsolute":"deviceorientation",w),i(window,"devicelight",v),l&&(d(l),l=null),p()}},layer:"behavioral",events:["motion","orientation","light"]},"network-request":{create:function(t){var e;const i=function(t,e,i,o=f){if("undefined"==typeof PerformanceObserver)return w;let r=null;try{r=new PerformanceObserver(n=>{for(const r of n.getEntries()){const n=r;o.has(n.initiatorType)&&(e(n.name)||t(m(n,i)))}}),r.observe({type:"resource",buffered:1})}catch{return n.warn("network-request","PerformanceObserver failed to start"),w}return function(){r?.disconnect(),r=null}}(function(n){s(()=>t.push(n))},(e=t.ignoredOrigins,function(t){try{return e.has(new URL(t).origin)}catch{return 0}}),t.sanitizeUrl);return function(){i()}},layer:"session"},screen:{create:function(t){const n=s(()=>function(){const t=window.screen;return{name:"screen",timestamp:Date.now(),availWidth:t.availWidth,availHeight:t.availHeight,width:t.width,height:t.height,colorDepth:t.colorDepth,pixelDepth:t.pixelDepth,availLeft:t.availLeft??0,availTop:t.availTop??0,orientation:t.orientation?{type:t.orientation.type,angle:t.orientation.angle}:null,isExtended:t.isExtended??0,viewport:{height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio}}}());return n&&t.push(n),()=>{}},layer:"session"}},W=Object.keys(Q),tt=[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,/^0b[01]+$/i,/^0o[0-7]+$/i,/^0x[0-9a-f]+$/i,/^[a-z][a-z0-9]{1,12}:[A-Za-z0-9+/=_-]{6,}$/i,/^[a-z]{2,8}_(?=.*\d)[A-Za-z0-9]{3,}$/,/^\d{4,}$/,/@/,/^[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{5,}\.[A-Za-z0-9_-]{10,}$/,/^[A-Za-z0-9_-]{20,}={0,2}$/,/^[0-9a-f]{7,}$/i];function nt(t){try{const n=new URL(t,location.href);n.username="",n.password="",n.hash="";const e=[...n.searchParams.keys()],i=e.length>0?"?"+e.map(t=>`${encodeURIComponent(t)}=<redacted>`).join("&"):"";n.search="",n.pathname=n.pathname.split("/").map(t=>""!==t&&function(t){for(const n of tt)if(n.test(t))return 1;return 0}(t)?":param":t).join("/");const o=n.origin+n.pathname+i;return o.length>2048?o.slice(0,2048):o}catch{return""}}const et={flush:{intervalMs:2e3,maxIntervalMs:3e4,size:50,backoffFailureThreshold:2},queue:{size:100}};function it(){const t={};for(const n of W)t[n]=st(n,void 0,1);return t}function ot(t){const n={};for(const e of W)n[e]=st(e,void 0,t[Q[e].layer]??0);return n}function rt(t){const n={};for(const e of W){const i=t[e];n[e]=st(e,i,i?.enabled??0)}return n}function st(t,n,e){const i=Q[t]?.events??[];if(0===i.length)return{enabled:e};const o=n?.events,r={};for(const t of i)r[t]={enabled:o?.[t]??1};return{enabled:e,events:r}}function ct(t){if(!t)return null;const n=t.split(".")[1],e=atob(n.replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(e)}const at=function(t,n=30){if(!t)return 1;const e=ct(t);return e&&"number"==typeof e.exp?1e3*e.exp<=Date.now()+1e3*n:1};async function ut(t,n){return globalThis.navigator&&"locks"in globalThis.navigator&&"request"in globalThis.navigator.locks&&"query"in globalThis.navigator.locks?navigator.locks.request(t,{mode:"exclusive"},async()=>c(n)):c(n)}const lt="__tri",dt=`${lt}_activity_token`,ht=`${lt}_activity_id`,ft=`${lt}_activity_status`,pt="__tri_activity_lock";class mt{constructor(t){this.context=t,this.l=null,this.h=null,this.p=null,this.m=null,this.v=0}getToken(){return this.l}getActivityId(){return this.h??""}isActive(){return"ACTIVE"===this.p&&null!==this.l}async start(){return this.v=1,this.m||(this.m=this.k()),this.m}async stop(){this.v=0,this.T(null),this.m=null,this.l&&await this.context.stopActivity(),this._(null)}async refresh(){if(!this.v)return;const t=this.l;await ut(pt,async()=>{if(this.l&&this.l!==t&&!at(this.l)&&"ACTIVE"===this.p)return;const n=this.I();n&&n.token!==t&&!at(n.token)&&"ACTIVE"===n.activityStatus?this._(n):(this.S(),await this.A())})}async k(){try{if(this.l&&!at(this.l))return;await ut(pt,async()=>{await this.A()})}finally{this.m=null}}async A(){const t=this.I();if(t&&!at(t.token)&&"ACTIVE"===t.activityStatus)return void this._(t);t&&this.S();const n=await this.context.startActivity();if(!n.ok)return;if(!n.data.token)return;const e=n.data;this._(e),this.M(e)}I(){const[t,n,e]=[q.get(dt),q.get(ht),q.get(ft)];return t&&n&&e?{token:t,activityId:n,activityStatus:e}:((t||n||e)&&this.S(),null)}M(t){q.set(dt,t.token),q.set(ht,t.activityId),q.set(ft,t.activityStatus)}S(){this.T(null),this._(null)}T(t){if(!t)return q.remove(dt),q.remove(ht),void q.remove(ft);q.set(dt,t.token),q.set(ht,t.activityId),q.set(ft,t.activityStatus)}_(t){if(!t)return this.l=null,this.h=null,void(this.p=null);this.l=t.token,this.h=t.activityId,this.p=t.activityStatus}}const wt=[401,403,409],yt=Object.freeze({tab:80,navigation:80,visibility:80,network:80,screen:80,fingerprint:80,pointer:60,keystroke:60,autofill:60,change:60,form:60,clipboard:60,selection:60,focus:60,viewport:60,network_request:60,scroll:40,sensors:40});function vt(t){return"pointer"===t.name&&"move"===t.phase||"viewport"===t.name&&"resize"===t.type?40:yt[t.name]}const gt=new Array(256);for(let t=0;t<256;t++)gt[t]=(t+256).toString(16).slice(1);const bt=new Uint8Array(16);function kt(t){return gt[t[0]]+gt[t[1]]+gt[t[2]]+gt[t[3]]+"-"+gt[t[4]]+gt[t[5]]+"-"+gt[t[6]]+gt[t[7]]+"-"+gt[t[8]]+gt[t[9]]+"-"+gt[t[10]]+gt[t[11]]+gt[t[12]]+gt[t[13]]+gt[t[14]]+gt[t[15]]}function Tt(){return crypto.randomUUID()}function _t(){return crypto.getRandomValues(bt),bt[6]=15&bt[6]|64,bt[8]=63&bt[8]|128,kt(bt)}function It(){for(let t=0;t<16;t++)bt[t]=256*Math.random()|0;return bt[6]=15&bt[6]|64,bt[8]=63&bt[8]|128,kt(bt)}const xt=function(){if("undefined"!=typeof crypto){if("function"==typeof crypto.randomUUID)return Tt;if("function"==typeof crypto.getRandomValues)return _t}return It}();function St(){return xt()}class Et{constructor(t,n){this.D=t,this.P=n,this.C=[],this.R=null,this.L=[],this.$=null,this.v=0,this.U=1,this.O=0,this.q=0,this.B=t.flush.intervalMs}push(t){if(this.v){if(this.C.length<this.j()?this.C.push(t):this.H(t),this.U)return this.C.length>=this.D.flush.size?(d(this.R),this.R=null,void this.flush("capacity")):void this.N()}else n.warn("Transport","push() called before start() — event dropped")}flush(t){if(this.v&&this.P.isActivityActive())try{if("lifecycle"===t)return void this.F();if(0===this.C.length)return;const e=this.X(t);this.P.ingest(e,0).then(t=>this.K(t,e)).catch(()=>{n.warn("Transport","ingest threw unexpectedly — batch dropped")}),this.C.length>0&&this.N()}catch(t){n.warn("Transport","flush() threw unexpectedly:",t)}}start(){this.v||(this.v=1,this.U="undefined"!=typeof navigator?navigator.onLine:1)}stop(){if(!this.v)return Promise.resolve();d(this.R),this.R=null,d(this.$),this.$=null;const t=this.F();return this.v=0,t}onConnectionChange(){const t="undefined"!=typeof navigator?navigator.onLine:1;if(t!==this.U){if(this.U=t,!this.U)return d(this.R),this.R=null,d(this.$),void(this.$=null);this.C.length>0&&this.N(),this.L.length>0&&this.V()}}N(){this.v&&this.U&&null===this.R&&(this.R=l(()=>{this.R=null,this.flush("interval")},this.B))}V(){this.v&&this.U&&null===this.$&&(this.$=l(()=>{this.$=null,this.Y()},this.B))}Y(){if(!this.v||!this.U||0===this.L.length||!this.P.isActivityActive())return;const t=this.L.shift();this.P.ingest(t.batch,0).then(n=>this.J(n,t)).catch(()=>{n.warn("Transport","retry drain ingest threw unexpectedly — batch dropped"),this.L.length>0&&this.V()})}G(t,e){this.L.length>=5&&(this.L.shift(),n.warn("Transport","retry queue full — oldest batch evicted")),this.L.push({batch:t,attempts:e}),this.V()}K(t,n){t.ok?this.Z():this.W(t)&&this.G(n,1)}J(t,e){if(t.ok)return this.Z(),void(this.L.length>0&&this.V());if(this.W(t)){if(e.attempts>=3)return this.tt(),n.warn("Transport","batch dropped after MAX_RETRY_ATTEMPTS",e.batch.batchId),void(this.L.length>0&&this.V());this.tt(),this.G(e.batch,e.attempts+1)}else this.L.length>0&&this.V()}tt(){this.O++,this.O%this.D.flush.backoffFailureThreshold===0&&(this.B=Math.min(2*this.B,this.D.flush.maxIntervalMs))}Z(){this.O=0,this.B=this.D.flush.intervalMs}j(){return this.D.queue.size*(this.U?1:2)}async F(){if(!this.P.isActivityActive())return Promise.resolve();const t=[];for(const e of this.L)t.push(this.P.ingest(e.batch,1).catch(()=>{n.warn("Transport","lifecycle retry ingest threw — batch dropped")}));if(this.L=[],this.C.length>0){const e=this.X("lifecycle");t.push(this.P.ingest(e,1).catch(()=>{n.warn("Transport","lifecycle ingest threw — batch dropped")}))}return Promise.allSettled(t).then(()=>{})}H(t){const n=vt(t);for(let e=0;e<this.C.length;e++)if(vt(this.C[e])<n){for(let t=e;t<this.C.length-1;t++)this.C[t]=this.C[t+1];return this.C.length-=1,void this.C.push(t)}}X(t){const n="lifecycle"===t?this.C.splice(-this.D.flush.size):this.C.splice(0,this.D.flush.size);return{activityId:"",batchId:St(),batchSequence:this.q++,clientTimestamp:Date.now(),schemaVersion:"0.1.0",sdkVersion:"0.3.0",sdkPlatform:"web",tabId:this.P.getTabId(),events:n}}W(t){if(t.ok)return 0;switch(t.kind){case"timeout":case"server":case"rate_limited":return 1;default:return 0}}}const At="tri:bcast:";const Mt="function"==typeof BroadcastChannel?BroadcastChannel:function(){if("undefined"==typeof Storage||"undefined"==typeof window)return 0;try{const t="__tri_bcast_probe__";localStorage.setItem(t,"1");const n="1"===localStorage.getItem(t);return localStorage.removeItem(t),n}catch{return 0}}()?class{constructor(t){this.seq=0,this.closed=0,this.listeners=new Set,this.onStorageEvent=t=>{if(this.closed)return;if(!t.key||!t.key.startsWith(`${At}${this.channelName}:`))return;if(null===t.newValue)return;let n;s(()=>q.remove(t.key));try{n=JSON.parse(t.newValue)}catch{return}const e={data:n};for(const t of this.listeners)s(()=>t(e))},this.channelName=t,this.senderId=St(),window.addEventListener("storage",this.onStorageEvent)}postMessage(t){if(this.closed)return;const n=`${At}${this.channelName}:${this.senderId}:${this.seq++}`;s(()=>{q.set(n,t),q.remove(n)})}addEventListener(t,n){this.listeners.add(n)}removeEventListener(t,n){this.listeners.delete(n)}close(){this.closed||(this.closed=1,window.removeEventListener("storage",this.onStorageEvent),this.listeners.clear())}}:class{constructor(t){n.warn("BroadcastChannel","BroadcastChannel is unavailable and localStorage is not writable in this context. Cross-tab discovery is disabled; tab count will always be reported as 1.")}postMessage(t){}addEventListener(t,n){}removeEventListener(t,n){}close(){}},Dt="__tri_tabId";class Pt{constructor(t){this.context=t,this.nt="",this.v=0,this.et=null,this.it=null,this.ot=null,this.rt=new Map,this.st=-1,this.ct=null}async start(){this.v||(this.v=1,this.nt=this.ut(),this.lt(),this.dt({type:"hello",tabId:this.nt,ts:Date.now()}),this.ht(),this.ft("active"),this.wt())}stop(){this.v&&(this.v=0,this.ft("inactive"),this.dt({type:"bye",tabId:this.nt,ts:Date.now()}),this.yt(this.vt()),this.gt(),this.bt(),this.kt())}getTabId(){return this.nt}queryTabsNumber(){return this.rt.size+1}lt(){try{this.et=new Mt("__tri_tab_channel"),this.ct=this.Tt.bind(this),this.et.addEventListener("message",this.ct)}catch(t){n.warn("TabManager","failed to open broadcast channel:",t)}}kt(){try{if(!this.et)return;this.ct&&this.et.removeEventListener("message",this.ct),this.et.close()}catch{}finally{this.et=null,this.ct=null}}ht(){this.it=setInterval(()=>{const t=Date.now();this.dt({type:"heartbeat",tabId:this.nt,ts:t})},1e3)}gt(){null!=this.it&&(clearInterval(this.it),this.it=null)}wt(){null!=this.ot&&clearTimeout(this.ot),this.ot=setTimeout(()=>{this.ot=null;const t=this.vt()+1;t!==this.st&&(this.st=t,this.yt(t))},1e3)}bt(){null!=this.ot&&(clearTimeout(this.ot),this.ot=null)}dt(t){try{if(!this.et)return;this.et.postMessage(t)}catch{n.warn("TabManager","failed to broadcast message:",t)}}Tt(t){const{type:n,tabId:e}=t.data;if(e===this.nt)return;const i=Date.now();"hello"===n?(this.dt({type:"ack",tabId:this.nt,ts:i,to:e}),this.rt.set(e,i)):"heartbeat"===n||"ack"===n?this.rt.set(e,i):"bye"===n&&this.rt.delete(e)}yt(t){this.context.events.count&&this.context.push({name:"tab",type:"count",tabId:this.nt,timestamp:Date.now(),value:t})}ft(t){this.context.events.state&&this.context.push({name:"tab",type:"state",tabId:this.nt,timestamp:Date.now(),value:t})}ut(){const t=B.get(Dt);if(t)return t;const n=St();return B.set(Dt,n),n}vt(t=Date.now()){let n=0;for(const[e,i]of this.rt.entries())t-i>=3e3?this.rt.delete(e):n++;return n}}const Ct=globalThis.CompressionStream,Rt=globalThis.Response,zt=globalThis.Blob,Lt=new TextEncoder;let $t=null;async function Ut(t){const e=await async function(t){if("function"!=typeof Ct)return null;try{const n=Lt.encode(t),e=new zt([n]).stream().pipeThrough(new Ct("gzip"));return await new Rt(e).arrayBuffer()}catch(t){return n.warn("compression","Native gzip failed:",t),null}}(t);return null!==e?e:async function(t){try{const e=await function(){if(null===$t){const t=function(t,e=1e4){let i=null;const o=new Promise(t=>{i=l(()=>{n.warn("import",`Import timed out after ${e}ms`),t(null)},e)}),r=Promise.resolve().then(t).catch(t=>(n.warn("import","Import failed:",t),null));return Promise.race([r,o]).finally(()=>{d(i)})}(()=>Promise.resolve().then(function(){return require("./chunks/browser-D1C751kT.cjs")}),1e4);$t=t,t.then(n=>{null===n&&l(()=>{$t===t&&($t=null)},1e4)})}return $t}();if(null===e)return null;const{gzipSync:i}=e,o=i(Lt.encode(t));return o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)}catch(t){return n.warn("compression","fflate gzip failed:",t),null}}(t)}function Ot(t){const n={Accept:"application/json"};return t?.hasBody&&("json"===t.contentType?n["Content-Type"]="application/json":"ndjson"===t.contentType&&(n["Content-Type"]="application/x-ndjson"),"gzip"===t.contentEncoding&&(n["Content-Encoding"]="gzip")),t?.token&&(n.Authorization=`Bearer ${t.token}`),t?.profileId&&(n["x-profile-id"]=t.profileId),t?.api?.version&&(n["x-api-version"]=t.api.version),t?.customHeaders&&Object.entries(t.customHeaders).forEach(([t,e])=>{n[t]=e}),n}const qt="function"==typeof globalThis.fetch?globalThis.fetch.bind(globalThis):void 0;class Bt{constructor(t){this.context=t}stop(){}async report(t,e){const i={name:t,metadata:e,timestamp:Date.now(),activityId:this.context.getActivityId()??""};try{const o=await this.context.reportEvent(i);if(o.ok)return o;n.warn("EventReport","Failed to report event:",t,e,"with result:",o)}catch(i){n.warn("EventReport","Failed to report event:",t,e,"with error:",i)}}}const jt=new Set(["A","BUTTON","INPUT","SELECT","TEXTAREA","SUMMARY","DETAILS","LABEL","OPTION","FIELDSET"]),Ht=new Set(["button","link","tab","menuitem","menuitemcheckbox","menuitemradio","checkbox","radio","switch","slider","spinbutton","combobox","listbox","option","searchbox","textbox","treeitem"]),Nt=255;function Ft(t,n,e){const i=t.tagName.toLowerCase(),o=function(t){const n=t.parentElement?.children??[],e=Math.min(n.length,1e3);let i=e-1,o=0,r=0;for(let i=0;i<e;i++){r++;const e=n[i];if(g(e,t.tagName)&&o++,e===t)break}return{siblings:i,ofType:o,child:r}}(t),r=function(t,n){const e=function(t){if(!t)return null;const n=t.getAttribute("data-tri-redact-attrs");return n?n.split(",").map(t=>t.trim().toLowerCase()):null}(t),i={},o=t.id;o&&!_("id",e)&&(i.id=o);const r=t.getAttribute("autocomplete");r&&!_("autocomplete",e)&&(i.autocomplete=r);const s=t.getAttribute("aria-invalid");s&&!_("aria-invalid",e)&&(i.ariaInvalid=s);const c=t.getAttribute("tabindex");c&&!_("tabindex",e)&&(i.tabIndex=parseInt(c,10));const a=function(t){return t.getAttribute("data-testid")??t.getAttribute("data-cy")??null}(t);a&&!_("data-testid",e)&&(i.testId=a);const u=t.hasAttribute("readonly");u&&!_("readonly",e)&&(i.readOnly=u);const l=t.hasAttribute("required");l&&!_("required",e)&&(i.required=l);const d=t.getAttribute("contenteditable");d&&!_("contenteditable",e)&&(i.contentEditable="true"===d||""===d);const h=t.getAttribute("href");h&&!_("href",e)&&(i.href={...n?{}:{url:h},external:I(h)});const f=t.getAttribute("role");f&&!_("role",e)&&(i.role=f);const p=t.getAttribute("type");p&&!_("type",e)&&(i.type=p);const m=t.getAttribute("name");m&&!_("name",e)&&(i.name=m);const w=t.getAttribute("placeholder");!w||n||_("placeholder",e)||(i.placeholder=w);const y=Array.from(t.classList).slice(0,5);y.length>0&&!_("class",e)&&(i.classes=y);const v=t.getAttribute("alt");return!v||n||_("alt",e)||(i.alt=v),Object.keys(i).length?i:null}(t,n);return{tagName:i,frame:e,...r?{attributes:r}:{},...o?{nth:o}:{}}}function Xt(t,n){let e=0;const i=[];return function(t){return jt.has(t.tagName)}(t)&&(e+=40,i.push("native")),function(t){return t.hasAttribute("data-tri-interactive")}(t)&&(e+=40,i.push("tri-interactive")),function(t){return g(t,"a")&&t.hasAttribute("href")}(t)&&(e+=15,i.push("has-href")),function(t){const n=t.getAttribute("role");return null!==n&&Ht.has(n)}(t)&&(e+=30,i.push("role")),function(t){return t.hasAttribute("onclick")||t.hasAttribute("ng-click")||t.hasAttribute("data-action")||t.hasAttribute("@click")}(t)&&(e+=20,i.push("click-handler")),function(t){const n=t.getAttribute("tabindex");if(null===n)return 0;const e=parseInt(n,10);return null!==e&&e>=0}(t)&&(e+=10,i.push("tabindex")),(t.id||t.getAttribute("data-testid"))&&(e+=5,i.push("has-id")),n>0&&(e+=Math.round(15/n),i.push("depth")),{score:e,reasons:i}}function Kt(t){return t>=20}function Vt(t){return null!==t&&t.width>0&&t.height>0&&t.y<window.innerHeight&&t.y+t.height>0&&t.x<window.innerWidth&&t.x+t.width>0}function Yt(t){return 1==t.disabled||"true"===t.getAttribute("aria-disabled")}function Jt(t,n=0){if(n)return null;const e=Zt(t,"labelledby");if(e)return{text:Wt(e),resolutionMethod:"aria-labelledby",confidence:"high"};const i=Qt(t);if(i)return{text:Wt(i),resolutionMethod:"aria-label",confidence:"high"};const o=function(t){if(!t.id)return null;const n=document.querySelector(`label[for="${CSS.escape(t.id)}"]`);return n?Gt(n):null}(t);if(o)return{text:Wt(o),resolutionMethod:"html-for",confidence:"high"};const r=function(t){const n=t.closest("label");return n?Gt(n):null}(t);if(r)return{text:Wt(r),resolutionMethod:"wrapping-label",confidence:"high"};const s=function(t){const n=t.getAttribute("placeholder");return n?.trim()??null}(t);if(s)return{text:Wt(s),resolutionMethod:"placeholder",confidence:"low"};const c=function(t){const n=t.getAttribute("title");return n?.trim()??null}(t);if(c)return{text:Wt(c),resolutionMethod:"title",confidence:"low"};const a=Zt(t,"describedby");if(a)return{text:Wt(a),resolutionMethod:"aria-describedby",confidence:"low"};const u=Gt(t);return u?{text:u,resolutionMethod:"text-content",confidence:"low"}:null}function Gt(t,n=0){if(n>8)return"";if(v(t))return function(t){return t?t.trim().split(/(\s+)/).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,Nt):null}(t.textContent)??"";if(!t.childNodes?.length)return"";let e="";for(const i of t.childNodes){const t=Gt(i,n+1);if(t&&(e=e?`${e} ${t}`:t,e.length>=Nt))break}return Wt(e)}function Zt(t,n){const e="labelledby"===n?"aria-labelledby":"aria-describedby",i=t?.getAttribute(e);if(!i)return null;const o=i.split(/\s+/),r=[];for(const t of o){const n=document.getElementById(t);if(!n)continue;const e=Qt(n)??Gt(n);e.length&&r.push(e)}return r.length?r.join(" "):null}function Qt(t){return t?.getAttribute("aria-label")?.trim()??null}function Wt(t){return t.length>Nt?t.slice(0,Nt)+"...":t}function tn(t){const n=t.getBoundingClientRect();return{x:n.x,y:n.y,width:n.width,height:n.height}}class nn{constructor(t){this.capacity=t,this.cache=new Map}get(t){return this.cache.get(t)}set(t,n){if(this.cache.has(t))this.cache.delete(t);else if(this.cache.size>=this.capacity){const t=this.cache.keys().next().value;t&&this.cache.delete(t)}this.cache.set(t,n)}delete(t){this.cache.delete(t)}clear(){this.cache.clear()}size(){return this.cache.size}}async function en(t,o){const{collectors:r,sdk:s}=t;let c=null,u=null,h=null,f=null;try{c=function(t){"undefined"!=typeof document&&"function"==typeof globalThis.fetch||n.warn("FalconService","createFalconServiceManager called in a non-browser environment — all requests will resolve with { ok: false, kind: 'network' }.");const e=function(t){const n=t?.timeout,e=t?.baseUrl??"",i=t?.api;async function o(t,o,r){if(void 0===qt)return{ok:0,kind:"network"};const s=e?`${e}${o}`:o,c=new AbortController;let a=null,u=0;a=l(()=>{u=1,c.abort()},n);const h=r?.signal;let f,p=()=>{};if(h)if(h.aborted)c.abort();else{const t=()=>c.abort();h.addEventListener("abort",t,{once:1}),p=()=>h.removeEventListener("abort",t)}if(null!=r&&"body"in r&&null!=r.body){const t=function(t){if(null==t)return{ok:1,body:void 0};if("string"==typeof t||t instanceof ArrayBuffer||ArrayBuffer.isView(t)||t instanceof Blob||t instanceof FormData||t instanceof URLSearchParams||t instanceof ReadableStream)return{ok:1,body:t};try{return{ok:1,body:JSON.stringify(t)}}catch{return{ok:0}}}(r.body);if(!t.ok)return d(a),p(),{ok:0,kind:"serialize"};f=t.body}try{const n=await qt(s,{method:t,headers:Ot({token:r?.token,profileId:r?.profileId,contentType:r?.contentType,contentEncoding:r?.contentEncoding,api:i,hasBody:void 0!==f,customHeaders:r?.customHeaders}),body:f,signal:c.signal,keepalive:r?.keepalive});if(!n.ok)return 429===(m=n.status)?{ok:0,kind:"rate_limited",status:m}:m>=400&&m<500?{ok:0,kind:"client",status:m}:{ok:0,kind:"server",status:m};if(204===n.status)return{ok:1,data:void 0,status:204};try{return{ok:1,data:await n.json(),status:n.status}}catch{return c.signal.aborted?u?{ok:0,kind:"timeout"}:{ok:0,kind:"abort"}:{ok:0,kind:"parse",status:n.status}}}catch{return u?{ok:0,kind:"timeout"}:c.signal.aborted?{ok:0,kind:"abort"}:{ok:0,kind:"network"}}finally{d(a),p()}var m}return{post:async function(t,n){return o("POST",t,n)},get:async function(t,n){return o("GET",t,n)}}}({baseUrl:`${t.api.url}/api/v1`,timeout:1e4,api:{version:t.api.version}}),i=function(t){const{getToken:e,refresh:i}=t;let o=null;return{withAuth:async function(t,r){if(o){const n=await o;if(n)return t(n)}const s=e()??"",c=await t(s);if((a=c).ok||"client"!==a.kind||!wt.includes(a.status)||0==r?.refreshable)return c;var a;const u=await(o||(o=async function(){try{return await i(),e()}catch(t){return n.warn("AuthMiddleware","auth refresh failed",t),null}}().finally(()=>{o=null}),o));return u&&u!==s?t(u):c}}}(t),o=()=>({profileId:t.getProfileId()??void 0});return{api:{ingest:async function(n,r){return i.withAuth(async i=>{const{events:s,...c}=n,a={...c,activityId:t.getActivityId()};let u;try{u=await async function(t,n){const e=function(t,n){const e=[JSON.stringify(t)];for(let t=0;t<n.length;t++)try{e.push(JSON.stringify(n[t]))}catch{}return e.join("\n")}(t,n),i=await Ut(e);return i?{type:"gzip",body:i}:{type:"ndjson",body:e}}(a,s)}catch{return{ok:0,kind:"serialize"}}return e.post("/events/capture",{body:u.body,token:i,keepalive:r,contentType:"ndjson",contentEncoding:"gzip"===u.type?"gzip":void 0,...o()})},{refreshable:!r})},reportEvent:async function(t){return i.withAuth(n=>e.post("/events/report-event",{body:t,token:n,contentType:"json",...o()}))},startActivity:async function(){return e.post("/events/start-activity",{token:t.getSdkToken(),...o()})},stopActivity:async function(){return i.withAuth(t=>e.post("/events/end-activity",{token:t,keepalive:1,...o()}),{refreshable:0})},collectionStatus:async function(){return e.get("/sdk/collection-status",{token:t.getSdkToken(),...o()})},linkInterview:async function(t){return i.withAuth(n=>e.post("/events/link-interview",{token:n,contentType:"json",...o(),customHeaders:{"X-Incode-Hardware-Id":t}}))}}}}({api:{version:s.api.version,url:s.api.url},getSdkToken:()=>s.token,getProfileId:()=>o.getProfileId(),getToken:()=>u?.getToken()??null,refresh:async()=>u?.refresh()??Promise.resolve(),getActivityId:()=>u?.getActivityId()??""});const t=await c.api.collectionStatus();if(!t.ok||1!=t.data.eventsCollectionEnabled)return{status:"collection-disabled"};u=new mt({startActivity:()=>c.api.startActivity(),stopActivity:()=>c.api.stopActivity()}),h=new Et(et,{ingest:(t,n)=>c.api.ingest(t,n),getTabId:()=>f?.getTabId()??"unknown",isActivityActive:()=>u?.isActive()??0});const p=r.tab;f=new Pt({push:t=>h?.push(t),events:{state:p.enabled&&p.events.state.enabled,count:p.enabled&&p.events.count.enabled}});const m=function(t){function n(n){"hidden"===document.visibilityState&&t.flush()}function o(n){t.flush(),t.stopTab(),t.getShouldSkipStopActivity()||t.stopActivity()}const r=a(()=>t.onConnectionChange());return{start:function(){e(document,"visibilitychange",n),e(window,"pagehide",o),e(window,"online",r),e(window,"offline",r)},stop:function(){i(document,"visibilitychange",n),i(window,"pagehide",o),i(window,"online",r),i(window,"offline",r)}}}({flush:()=>h?.flush("lifecycle"),stopActivity:async()=>u?.stop(),stopTab:()=>f?.stop(),getShouldSkipStopActivity:()=>(f?.queryTabsNumber()??0)>1,onConnectionChange:()=>h?.onConnectionChange()}),w=function(t){const n=t||"redact",e=new nn(6),i=new nn(6);return{resolve:function(t){if(!t||k(t)||"off"===n)return null;let o=e.get(t);if(o||(o=function(t){if(!t||k(t))return{chain:[],redaction:{level:"ignore",index:-1}};const n=[];let e=t,i=-1;for(;e;){if(k(e))return{chain:[],redaction:{level:"ignore",index:-1}};T(e)&&(i=n.length),n.push(e);const t=e.parentNode;if(!t||g(e,"body"))break;e=b(t)?t.host:t}return{chain:n,redaction:{level:-1===i?"full":"redact",index:i}}}(t.parentElement),e.set(t,o)),"ignore"===o.redaction.level)return null;const r="redact"===o.redaction.level||"redact"===n||T(t);let s=i.get(t);return s||(s=function(t,n,e,i){const o=getComputedStyle(t),r=tn(t),s=function(t,n){const e=[],i=[];for(let o=t.length-1;o>=0;o--){const r=t[o],s=o<=n,c=o+1,a=Ft(r,s,tn(r)),{score:u,reasons:l}=Xt(r,c);if(e.push(a),!Kt(u))continue;const d=Jt(r,s);i.push({...a,...d?{label:d}:{},depth:c,score:u,reasons:l})}return{ancestors:e,interactiveCandidates:i.reverse()}}(n,i),c=Ft(t,e,r),a=function(t,n,e){const{score:i,reasons:o}=Xt(t,0);return{interactive:Kt(i),...o.length>0?{reasons:o}:{},disabled:Yt(t),rendered:"none"!==n?.display,visible:"hidden"!==n?.visibility,inViewport:Vt(e),acceptsPointer:"none"!==n?.pointerEvents,opacity:parseFloat(n?.opacity||"1")}}(t,o,r);let u=null;return e||(u=a.interactive?Jt(t):null),{tagName:c.tagName,frame:c.frame,viewport:{height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio},attributes:c.attributes,nth:c.nth,...u?{label:u}:{},ancestors:s.ancestors,interactiveCandidates:s.interactiveCandidates,interactivity:a}}(t,o.chain,r,o.redaction.index),i.set(t,s)),s}}}(s.capture?.element),y=new Set;try{y.add(new URL(s.api.url).origin)}catch{}const v=function(t,n,e="on"){const i=new Map;function o(o){if(i.has(o))return;const r=Q[o];if(!r||!function(t,n){return n[t]?.enabled??0}(o,n))return;const s=n[o],c=r.create(t,e,s&&"events"in s?s.events:void 0);i.set(o,c)}return{start:o,stopCollector:function(t){const n=i.get(t);n&&(n(),i.delete(t))},stop:function(){for(const[,t]of i)t();i.clear()},isRunning:function(t){return i.has(t)},autocapture:function(){for(const t of W)o(t)}}}({push:t=>h?.push(t),resolveElement:t=>w.resolve(t),sanitizeUrl:s.sanitizeUrl,ignoredOrigins:y},r,s.capture?.content),_=new Bt({getActivityId:()=>u?.getActivityId()??"",reportEvent:t=>c.api.reportEvent(t)});return{status:"ready",managers:{falconServiceManager:c,activityManager:u,transportManager:h,tabManager:f,lifecycleManager:m,collectorManager:v,eventReportManager:_}}}catch(t){return n.warn("IncodeTRI","setup() failed during construction:",t),{status:"init-failed"}}}let on=class t{constructor(){this._t=0,this.D=null,this.It=null,this.xt="idle"}static get instance(){return t.o||(t.o=new t),t.o}async setup(t){if("idle"!==this.xt)return n.fatal("error","setup()","called more than once — ignoring."),"init-failed";try{const e=function(t){if("undefined"==typeof document)return n.fatal("error","IncodeTRI","TRI is not available in a non-browser environment."),null;if(!t?.token)return n.fatal("error","SDK","token is required."),null;if(!t.apiURL)return n.fatal("error","SDK","Couldn't initialise SDK — apiURL isn't provided."),null;const{element:e,content:i}=t.capture??{},o={token:t.token,capture:{element:e??"redact",content:i??"off"},profileId:t.profileId,api:{version:t.apiVersion??"1.0",url:t.apiURL},sanitizeUrl:(r=t.sanitizeUrl,r?function(t){return s(()=>r(t,nt))??nt(t)}:nt),DEBUG:t.DEBUG??0};var r;return void 0===t.collectors&&void 0===t.layers?{sdk:o,collectors:it()}:void 0!==t.collectors?{sdk:o,collectors:rt(t.collectors)}:{sdk:o,collectors:ot(t.layers)}}(t);if(!e)return"init-failed";n.DEBUG=e.sdk.DEBUG;const i=await en(e,{getProfileId:()=>this.St()});return"collection-disabled"===i.status?(n.fatal("warn","setup()","Collection is disabled for the provided API Key."),"collection-disabled"):"init-failed"===i.status?"init-failed":(this.D=e,this.It=i.managers,this.xt="ready",this.Et(e.sdk.profileId),"ready")}catch(t){return n.warn("setup()","failed:",t),"init-failed"}}async start(){if("idle"===this.xt)return n.warn("start()","start() requires a prior successful setup() — ignoring."),this.xt;if("ready"!==this.xt)return n.fatal("warn","start()","TRI is either already started or isn't ready — ignoring."),this.xt;this.xt="starting";const t=++this._t;return await this.k(t),this.xt}async stop(){n.warn("stop()","called");const t=this.It;return t?(++this._t,t.lifecycleManager.stop(),t.collectorManager.stop(),t.tabManager.stop(),t.eventReportManager.stop(),this.xt="ready",this.At(t)):Promise.resolve(this.xt)}async reset(){const t=this.stop();return this.xt="idle",this.D=null,this.It=null,q.remove("__tri_profile_id"),t.then(()=>this.xt)}async At(t){return await function(t){let n=null;const e=new Promise(t=>{n=l(t,2e3)});return Promise.race([t.finally(()=>d(n)),e])}(Promise.resolve(t.transportManager.stop())),await t.activityManager.stop(),this.xt}reportEvent(t,e){"started"===this.xt?this.It?c(()=>this.It.eventReportManager.report(t,e)):n.warn("reportEvent()","reportEvent() called but managers are unavailable — dropping event."):n.warn("reportEvent()","reportEvent() called before start() completed — dropping event.")}setProfileId(t){"started"===this.xt?this.D?.sdk&&(this.D.sdk.profileId=t,this.Et(t)):n.warn("setProfileId()","setProfileId() called before start() completed — ignoring.")}async linkInterview(t){if("started"!==this.xt||!this.It)return n.warn("linkInterview()","linkInterview() called before start() completed — ignoring."),0;if(!t)return n.warn("linkInterview()","linkInterview() called without sessionToken — ignoring."),0;try{return(await this.It.falconServiceManager.api.linkInterview(t)).ok}catch(t){return n.warn("linkInterview()","failed:",t),0}}St(){return this.D?.sdk?.profileId??q.get("__tri_profile_id")??null}Et(t){t&&q.set("__tri_profile_id",t)}async k(t){const e=this.It;if(e){try{if(await e.activityManager.start(),t!==this._t)return;if(e.transportManager.start(),await e.tabManager.start(),t!==this._t)return;e.lifecycleManager.start(),e.collectorManager.autocapture()}catch(e){return n.warn("start()","failed during monitoring start:",e),void(t===this._t&&(this.xt="ready"))}t===this._t&&(this.xt="started")}}};on.o=null;const rn=on.instance;exports.createSession=async function(t,n){const e=n?.apiURL??"https://falcon-ingest-k8s.stage.incodetest.com",i=n?.timeout??1e4,o=new AbortController;let r=null,s=0,c=()=>{};i&&(r=l(()=>{s=1,o.abort()},i));const a=n?.signal;if(a)if(a.aborted)o.abort();else{const t=()=>o.abort();a.addEventListener("abort",t,{once:1}),c=()=>a.removeEventListener("abort",t)}try{const n=await fetch(`${e}/api/v1/sdk/init`,{method:"POST",headers:{"content-type":"application/json","x-api-key":t,"x-api-version":"1.0"},signal:o.signal});if(!n.ok){let t=n.statusText;try{const e=await n.json();e.errorMessage&&(t=e.errorMessage)}catch{}return{token:null,eventsCollectionEnabled:0,error:{status:n.status,message:t}}}return await n.json()}catch(t){throw new Error((s?"[TRI] createSession timed out":"[TRI] Failed to create session:")+" "+t.message)}finally{d(r),c()}},exports.default=rn;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"t",{value:1});class t{constructor(){this.i=0}static get instance(){return t.o||(t.o=new t),t.o}get DEBUG(){return this.i}set DEBUG(t){this.i=t}warn(t,n,...e){this.i&&this.l("warn",t,n,...e)}error(t,n,...e){this.i&&this.l("error",t,n,...e)}info(t,n,...e){this.i&&this.l("info",t,n,...e)}fatal(t,n,e,...i){this.l(t,n,e,...i)}l(t,n,e,...i){const o=n?`[${n}]`:"",r=console?.[t];r&&r(`[IncodeTRI]${o} ${e}`,...i)}}const n=t.instance;function e(t,n,e){let i=t,o=n;if("devicepixelratiochange"===n){const t=window.devicePixelRatio;i=window.matchMedia(`(resolution: ${t}dppx)`),o="change"}i.addEventListener(o,e,{capture:1,passive:1})}function i(t,n,e){let i=t,o=n;if("devicepixelratiochange"===n){const t=window.devicePixelRatio;i=window.matchMedia(`(resolution: ${t}dppx)`),o="change"}i.removeEventListener(o,e,{capture:1})}const o=globalThis.setTimeout.bind(globalThis),r=globalThis.clearTimeout.bind(globalThis);function s(t,e){try{return t()}catch(t){n.warn("utils","safeSync swallowed error:",t)}}async function c(t){try{return await t()}catch(t){n.warn("utils","safeAsync swallowed error:",t)}}function a(t){return n=>s(()=>t(n))}function l(t){return(...e)=>{try{t(...e)}catch(t){n.warn("utils","safeTimer swallowed error:",t)}}}function u(t,n){return o(l(t),n)}function d(t){if(null!==t)try{r(t)}catch(t){n.warn("utils","safeClearTimeout swallowed error:",t)}}const h=new Set(["xmlhttprequest","fetch","beacon","navigation","script","link","css","img","iframe","video","audio"]),f=new Set(["xmlhttprequest","fetch","beacon"]);function p(t,n){return n?t:null}function m(t,n){const e=t,i=t.responseStart>0,o=p(t.domainLookupEnd-t.domainLookupStart,i),r=p(t.connectEnd-t.connectStart,i),s=p(t.connectEnd>0&&t.secureConnectionStart>0?t.connectEnd-t.secureConnectionStart:0,i),c=p(t.responseStart-t.requestStart,i),a=p(t.responseEnd-t.responseStart,i),l=i?t.transferSize:null,u=i?t.encodedBodySize:null,d=i?t.decodedBodySize:null,f=i&&t.nextHopProtocol||null,m=i&&void 0!==e.deliveryType?e.deliveryType:null,w=e.responseStatus,y=void 0!==w&&0!==w?w:null;return{name:"network_request",timestamp:Date.now(),performanceTime:t.startTime+t.duration,url:n(t.name),initiatorType:(v=t.initiatorType,h.has(v)?v:"other"),startTime:t.startTime,durationMs:t.duration,dnsLookupMs:o,tcpConnectMs:r,tlsHandshakeMs:s,ttfbMs:c,responseDownloadMs:a,transferSize:l,encodedBodySize:u,decodedBodySize:d,nextHopProtocol:f,deliveryType:m,responseStatus:y};var v}function w(){}const y=2e3;function v(t){return!!t&&t.nodeType===Node.TEXT_NODE}function g(t,n){return t.tagName?.toLowerCase()===n.toLowerCase()}function b(t){return!!t&&t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function k(t){return t?t.hasAttribute("data-tri-ignore"):0}function T(t){return t?t.hasAttribute("data-tri-redact"):0}function _(t,n){return n?.includes(t.toLowerCase())??0}function I(t){try{return new URL(t).origin!==window.location.origin}catch{return 0}}function x(t,n){return t?t[n]?.enabled??0:1}function S(){const t=document.activeElement;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement){const n=t.selectionStart,e=t.selectionEnd;return null==n||null==e||n===e?null:t.value.substring(n,e)}const n=window.getSelection();return!n||n.isCollapsed?null:n.toString()||null}function E(t,n){return"off"===n||k(t)||T(t)?0:1}function A(t){const n=document.activeElement;if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)return n;const e=window.getSelection();return(i=("start"===t?e?.anchorNode:e?.focusNode)??null)?v(i)?i.parentElement:i instanceof Element?i:null:null;var i}function M(){const t=window,n="__fpjs_p_l_b",e=t[n];if(function(t,n){var e;const i=null===(e=Object.getOwnPropertyDescriptor)||void 0===e?void 0:e.call(Object,t,n);(null==i?void 0:i.configurable)?delete t[n]:i&&!i.writable||(t[n]=void 0)}(t,n),"function"!=typeof(null==e?void 0:e.load))throw new Error($);return e}const D="Blocked by CSP",P="The endpoint parameter is not a valid URL";function C(t){return function(t,n){const e=document,i="securitypolicyviolation";let o;const r=n=>{const e=new URL(t,location.href),{blockedURI:i}=n;i!==e.href&&i!==e.protocol.slice(0,-1)&&i!==e.origin||(o=n,s())};e.addEventListener(i,r);const s=()=>e.removeEventListener(i,r);return Promise.resolve().then(n).then(t=>(s(),t),t=>new Promise(t=>{const n=new MessageChannel;n.port1.onmessage=()=>t(),n.port2.postMessage(null)}).then(()=>{if(s(),o)return(()=>{throw new Error(D)})();throw t}))}(t,()=>function(t){return new Promise((n,e)=>{if(function(t){if(URL.prototype)try{return new URL(t,location.href),0}catch(t){if(t instanceof Error&&"TypeError"===t.name)return 1;throw t}}(t))throw new Error(P);const i=document.createElement("script"),o=()=>{var t;return null===(t=i.parentNode)||void 0===t?void 0:t.removeChild(i)},r=document.head||document.getElementsByTagName("head")[0];i.onload=()=>{o(),n()},i.onerror=()=>{o(),e(new Error(L))},i.async=1,i.src=t,r.appendChild(i)})}(t)).then(M)}const R="API key required";var z="3.12.9";const L="Failed to load the JS script of the agent",$="9319",U={scriptUrl:"https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js"};function O(t){function n(){return globalThis.window&&globalThis.window[t]&&void 0!==globalThis.window[t]}return{get:function(e){if(!n())return null;try{const n=window[t].getItem(e)??"null";return"null"===n?null:JSON.parse(n)}catch{return null}},set:function(e,i){n()&&s(()=>window[t].setItem(e,JSON.stringify(i)))},remove:function(e){n()&&s(()=>window[t].removeItem(e))},key:function(e){return n()?window[t].key(e):null},get length(){return n()?window[t].length:0}}}const q=O("localStorage"),B=O("sessionStorage"),j="__tri_fingerprint";let H=null,N=null;async function F(t){try{const n=await function(t){return H||(H=function(t){var n,e;const{picked:i,rest:o}=function(t,n){const e={},i={};for(const[o,r]of Object.entries(t))n.includes(o)?e[o]=r:i[o]=r;return{picked:e,rest:i}}(t,["scriptUrlPattern","token","apiKey"]),r=null!==(n=i.apiKey)&&void 0!==n?n:i.token,s=null!==(e=function(t,n){return function(t,n){return Object.prototype.hasOwnProperty.call(t,n)}(t,n)?t[n]:void 0}(t,"scriptUrlPattern"))&&void 0!==e?e:U.scriptUrl,[c,a]=function(){const t=[],n=()=>{t.push({time:new Date,state:document.visibilityState})},e=((i=document).addEventListener("visibilitychange",o=n,r),()=>i.removeEventListener("visibilitychange",o,r));var i,o,r;return n(),[t,e]}();return Promise.resolve().then(()=>{if(!r||"string"!=typeof r)throw new Error(R);return function(t,n){const e=[],[i,o]=function(t){const n=function(t){const n=[...t];return{current:()=>n[0],postpone(){const t=n.shift();void 0!==t&&n.push(t)},exclude(){n.shift()}}}(t),e=function(){let t=0;return()=>Math.random()*Math.min(3e3,100*Math.pow(2,t++))}(),i=new Set;return[n.current(),(t,o)=>{let r;const s=o instanceof Error?o.message:"";if(s===D||s===P)n.exclude(),r=0;else if(s===$)n.exclude();else if(s===L){const e=Date.now()-t.getTime()<50,o=n.current();o&&e&&!i.has(o)&&(i.add(o),r=0),n.postpone()}else n.postpone();const c=n.current();return void 0===c?void 0:[c,null!=r?r:t.getTime()+e()-Date.now()]}]}(t);let r;if(void 0===i)return Promise.reject(new TypeError("The list of script URL patterns is empty"));const s=t=>{const i=new Date,c=n=>e.push({url:t,startedAt:i,finishedAt:new Date,error:n}),a=n(t);return a.then(()=>c(),c),a.catch(t=>{if(null!=r||(r=t),e.length>=5)throw r;const n=o(i,t);if(!n)throw r;const[c,a]=n;return(l=a,new Promise(t=>setTimeout(t,l))).then(()=>s(c));var l})};return s(i).then(t=>[t,e])}(function(t,n){return(Array.isArray(t)?t:[t]).map(t=>function(t,n){const e=encodeURIComponent;return t.replace(/<[^<>]+>/g,t=>"<version>"===t?"3":"<apiKey>"===t?e(n):"<loaderVersion>"===t?e(z):t)}(String(t),n))}(s,r),C)}).catch(t=>{throw a(),function(t){return t instanceof Error&&t.message===$?new Error(L):t}(t)}).then(([t,n])=>(a(),t.load({...o,ldi:{attempts:n,visibilityStates:c}})))}({apiKey:t.apiKey,region:t.region,endpoint:t.endpoint,scriptUrlPattern:t.scriptUrlPattern}).catch(t=>{throw H=null,t}),H)}(t),e=await n.get({timeout:t.timeoutMs,extendedResult:1});if(!e.visitorId)return null;const i=t.cacheTtlMs??2592e6;return i>0&&function(t,n,e){const i={visitorId:t,requestId:n,expiresAt:Date.now()+e};q.set(j,i)}(e.visitorId,e.requestId,i),{visitorId:e.visitorId,requestId:e.requestId}}catch{return null}}const X={apiKey:"5uYRiI0XM6p8k4124ELX",endpoint:"https://fingerprint.incodesmile.com",scriptUrlPattern:"https://fingerprint.incodesmile.com/web/v<version>/<apiKey>/loader_v<loaderVersion>.js"},K={focusin:"in",focusout:"out"};function V(t){return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement}const Y=new Set(["Shift","Control","Alt","Meta","Backspace","Delete","Enter","Tab","CapsLock","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]),J={mouse:"mouse",touch:"touch",pen:"pen"},G={pointerdown:"down",pointerup:"up",click:"click",dblclick:"dblclick",contextmenu:"contextmenu"};function Z(t,n,e,i,o){return{name:"navigation",timestamp:Date.now(),phase:t,type:n,from:e.from,to:e.to,timeOrigin:i,timing:o}}const Q={fingerprint:{create:function(t){let n=0;return c(async()=>{const e=await async function(t){const n=function(){const t=q.get(j);return t?"string"!=typeof t.visitorId||"number"!=typeof t.expiresAt||t.expiresAt<=Date.now()?(q.remove(j),null):{visitorId:t.visitorId,requestId:"string"==typeof t.requestId?t.requestId:""}:null}();return n?{visitorId:n.visitorId,requestId:n.requestId||null}:N||(N=F(t).finally(()=>{N=null}),N)}(X);!n&&e&&t.push({name:"fingerprint",deviceId:e.visitorId,requestId:e.requestId,timestamp:Date.now()})}),()=>{n=1}},layer:"device-fingerprinting"},pointer:{create:function(t,n,o){const r=a(n=>{const e=function(n){const e=n,i=function(t){if("mouse"===t.pointerType)return{button:t.button,buttons:t.buttons};const n={force:t.pressure,contact:Math.min(t.width,t.height)};return"pen"===t.pointerType&&(n.tiltX=t.tiltX,n.tiltY=t.tiltY,n.twist=t.twist),n}(e);return{id:e.pointerId,name:"pointer",timestamp:Date.now(),type:J[e.pointerType]??"unknown",phase:G[n.type],isTrusted:e.isTrusted,element:t.resolveElement(e.target),isPrimary:e.isPrimary,modifiers:{shift:e.shiftKey,ctrl:e.ctrlKey,alt:e.altKey,meta:e.metaKey},coordinates:{x:e.clientX,y:e.clientY},...i}}(n);t.push(e)});return x(o,"pointer")&&(e(document,"pointerdown",r),e(document,"pointerup",r)),x(o,"click")&&e(document,"click",r),x(o,"dblclick")&&e(document,"dblclick",r),x(o,"contextmenu")&&e(document,"contextmenu",r),()=>{i(document,"pointerdown",r),i(document,"pointerup",r),i(document,"click",r),i(document,"dblclick",r),i(document,"contextmenu",r)}},layer:"behavioral",events:["pointer","click","dblclick","contextmenu"]},pointermove:{create:function(t){let n=null,o=null;const r=a(e=>{const i=e;return n&&n.id!==i.pointerId&&(t.push(n),n=null),n?n.samples.ts.length>=50?(t.push(n),n=s(i),void c(t)):(n.samples.x.push(i.clientX),n.samples.y.push(i.clientY),n.samples.ts.push(i.timeStamp),"pen"===i.pointerType&&(n.samples.tiltX?.push(i.tiltX),n.samples.tiltY?.push(i.tiltY)),"mouse"!==i.pointerType&&(n.samples.force?.push(i.pressure),n.samples.radius?.push(Math.max(i.width,i.height))),void c(t)):(n=s(i),void c(t))});function s(t){const n=function(t){if("mouse"===t.pointerType)return null;const n={force:[t.pressure],radius:[Math.max(t.width,t.height)]};return"pen"===t.pointerType&&(n.tiltX=[t.tiltX],n.tiltY=[t.tiltY]),n}(t);return{name:"pointer",timestamp:Date.now(),id:t.pointerId,type:t.pointerType,phase:"move",isTrusted:t.isTrusted,isPrimary:t.isPrimary,samples:{x:[t.clientX],y:[t.clientY],ts:[t.timeStamp],...n??{}}}}function c(t){o&&clearTimeout(o),o=setTimeout(()=>{n&&(t.push(n),n=null),o=null},y)}return e(document,"pointermove",r),()=>{i(document,"pointermove",r),o&&(clearTimeout(o),o=null),n&&(t.push(n),n=null)}},layer:"behavioral"},focus:{create:function(t){const n=a(n=>{const e=function(n){const e=n;return{name:"focus",type:K[n.type]??"unknown",timestamp:Date.now(),isTrusted:e.isTrusted,element:t.resolveElement(e.target),relatedTarget:t.resolveElement(e.relatedTarget)}}(n);t.push(e)});return e(document,"focusin",n),e(document,"focusout",n),()=>{i(document,"focusin",n),i(document,"focusout",n)}},layer:"behavioral"},input:{create:function(t){const n=a(n=>{const e=n;t.push(function(n){return{name:"keystroke",type:"input",timestamp:Date.now(),isTrusted:n.isTrusted,element:t.resolveElement(n.target),inputType:n.inputType??"",isComposing:n.isComposing??0,length:(e=n.target,e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement?e.value.length:0)};var e}(e)),function(t){if("insertReplacementText"===t.inputType)return 1;const n=t.target;return V(n)?function(t){try{return t.matches(":-webkit-autofill")}catch{return 0}}(n):0}(e)&&t.push(function(t,n){const e=t.target;let i=0;return V(e)&&(i=e.value.length),{name:"autofill",timestamp:Date.now(),element:n.resolveElement(e),length:i}}(e,t))});return e(document,"input",n),function(){i(document,"input",n)}},layer:"behavioral"},keystroke:{create:function(t){const{resolve:n,reset:o}=function(){let t=0;const n=new Map;return{resolve:function(e,i){if("keydown"===i){const i=n.get(e);if(void 0!==i)return i;const o=++t;if(n.size>=32){const t=n.keys().next().value;void 0!==t&&n.delete(t)}return n.set(e,o),o}const o=n.get(e);return void 0!==o?(n.delete(e),o):++t},reset:function(){n.clear()}}}(),r=a(e=>{const i=function(t){const e=t,i=t.type;return{name:"keystroke",type:i,id:n(e.code,i),timestamp:Date.now(),isTrusted:e.isTrusted,keys:Y.has(e.key)?[e.key]:[]}}(e);t.push(i)}),s=a(()=>{o()});return e(document,"keydown",r),e(document,"keyup",r),e(window,"blur",s),()=>{i(document,"keydown",r),i(document,"keyup",r),i(window,"blur",s)}},layer:"behavioral"},clipboard:{create:function(t,n="on",o){const r=a(e=>{const i=function(e){const i=e,o=e.type,r=("paste"===e.type?i.clipboardData?.getData("text/plain"):S())??null,s=E(i.target,n);return{name:"clipboard",type:o,timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target),length:r?.length??0,...s&&r?{content:r}:{}}}(e);t.push(i)});return x(o,"paste")&&e(document,"paste",r),x(o,"cut")&&e(document,"cut",r),x(o,"copy")&&e(document,"copy",r),()=>{i(document,"paste",r),i(document,"cut",r),i(document,"copy",r)}},layer:"behavioral",events:["paste","cut","copy"]},form:{create:function(t,n,o){const r=a(n=>{const e={name:"form",type:(i=n).type,timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target)};var i;t.push(e)});return x(o,"submit")&&e(document,"submit",r),x(o,"invalid")&&e(document,"invalid",r),()=>{i(document,"submit",r),i(document,"invalid",r)}},layer:"behavioral",events:["submit","invalid"]},change:{create:function(t){const n=a(n=>{const e=(i=n,{name:"change",timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target)});var i;t.push(e)});return e(document,"change",n),()=>{i(document,"change",n)}},layer:"behavioral"},selection:{create:function(t,n){let o=0,r=0,s=null,c=0,l=0;function u(){s&&(clearTimeout(s),s=null)}function d(){u(),c||l||(s=setTimeout(()=>{s=null,o&&h("timeout")},250))}function h(e){o&&(o=0,u(),function(e){const i=A("end"),o=i&&E(i,n),r=S();t.push({name:"selection",phase:"end",timestamp:Date.now(),trigger:e,isTrusted:1,element:t.resolveElement(i),length:r?.length??0,...o&&r?{content:r}:{}})}(e))}const f=a(()=>{const n=function(){const t=document.getSelection();return!t||t.isCollapsed||0===t.rangeCount}();if(!o&&!n)return o=1,r=Date.now(),t.push({name:"selection",phase:"start",timestamp:r,element:t.resolveElement(A("start"))}),void d();o&&n?h("collapse"):o&&d()}),p=a(t=>{0===t.button&&(c=1,u())}),m=a(t=>{0===t.button&&(c=0,o&&h("pointer"))}),w=a(t=>{"Shift"===t.key&&(l=1,u())}),y=a(t=>{"Shift"===t.key&&(l=0,o&&h("keyboard"))}),v=a(()=>{c=0}),g=a(()=>{"hidden"===document.visibilityState&&(c=0,l=0,o&&h("timeout"))}),b=a(()=>{c=0,o&&h("pointer")});return e(document,"selectionchange",f),e(document,"pointerdown",p),e(document,"pointerup",m),e(document,"keydown",w),e(document,"keyup",y),e(document,"contextmenu",v),e(document,"visibilitychange",g),e(document,"dragend",b),()=>{u(),i(document,"selectionchange",f),i(document,"pointerdown",p),i(document,"pointerup",m),i(document,"keydown",w),i(document,"keyup",y),i(document,"contextmenu",v),i(document,"visibilitychange",g),i(document,"dragend",b)}},layer:"behavioral"},tab:{create:()=>()=>{},layer:"session",events:["state","count"]},visibility:{create:function(t){const n=a(n=>{const e=document.visibilityState;if("visible"!==e&&"hidden"!==e)return;const i={name:"visibility",type:e,timestamp:Date.now(),isTrusted:n.isTrusted};t.push(i)});return e(document,"visibilitychange",n),()=>{i(document,"visibilitychange",n)}},layer:"session"},navigation:{create:function(t){let n=t.sanitizeUrl(document.referrer||"");function o(e){t.push(e),n=e.to??""}const r=a(()=>{const[n]=performance.getEntriesByType("navigation");var e;o(Z("load",n?.type??"navigate",{from:document.referrer?t.sanitizeUrl(document.referrer):null,to:t.sanitizeUrl(location.href)},performance.timeOrigin,n?{fetchStart:(e=n).fetchStart,domainLookupStart:e.domainLookupStart,domainLookupEnd:e.domainLookupEnd,connectStart:e.connectStart,connectEnd:e.connectEnd,requestStart:e.requestStart,responseStart:e.responseStart,responseEnd:e.responseEnd,domInteractive:e.domInteractive,domContentLoadedEventStart:e.domContentLoadedEventStart,domContentLoadedEventEnd:e.domContentLoadedEventEnd,domComplete:e.domComplete,loadEventStart:e.loadEventStart,loadEventEnd:e.loadEventEnd,redirectCount:e.redirectCount,transferSize:e.transferSize,encodedBodySize:e.encodedBodySize,decodedBodySize:e.decodedBodySize}:void 0))}),c=a(e=>{const i=e;if(null===i.navigationType)return;const r=t.sanitizeUrl(location.href);r!==n&&o(Z("change",i.navigationType,{from:n,to:r},performance.timeOrigin))}),l=a(()=>d("traverse")),u=a(()=>d("hashchange"));function d(e){const i=t.sanitizeUrl(location.href);"hashchange"===e&&i===n||o(Z("change",e,{from:n,to:i},performance.timeOrigin))}const h=history.pushState,f=history.replaceState,p=function(...t){const n=h.apply(this,t);return s(()=>d("push")),n},m=function(...t){const n=f.apply(this,t);return s(()=>d("replace")),n};return window.navigation?e(window.navigation,"currententrychange",c):(history.pushState=p,history.replaceState=m,e(window,"popstate",l),e(window,"hashchange",u)),"complete"===document.readyState?r(new Event("load")):e(window,"load",r),()=>{window.navigation?i(window.navigation,"currententrychange",c):(history.pushState===p&&(history.pushState=h),history.replaceState===m&&(history.replaceState=f),i(window,"popstate",l),i(window,"hashchange",u)),i(window,"load",r)}},layer:"session"},networkconnection:{create:function(t){const n=a(()=>{const n={name:"network",type:"connection",state:navigator.onLine?"online":"offline",timestamp:Date.now()};t.push(n)});return e(window,"online",n),e(window,"offline",n),()=>{i(window,"online",n),i(window,"offline",n)}},layer:"session"},scroll:{create:function(t){let n=null,o=null;const r=a(e=>n?n.samples.ts.length>=50?(t.push(n),n=s(e),void c(t)):(n.samples.x.push(window.scrollX),n.samples.y.push(window.scrollY),n.samples.ts.push(e.timeStamp),void c(t)):(n=s(e),void c(t)));function s(t){return{name:"scroll",timestamp:Date.now(),samples:{x:[window.scrollX],y:[window.scrollY],ts:[t.timeStamp]},height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,pageX:window.pageXOffset,pageY:window.pageYOffset}}function c(t){o&&clearTimeout(o),o=setTimeout(()=>{n&&(t.push(n),n=null),o=null},y)}return e(window,"scroll",r),()=>{i(window,"scroll",r),o&&(clearTimeout(o),o=null),n&&(t.push(n),n=null)}},layer:"behavioral"},viewportresize:{create:function(t){let n=null,o=null;const r=a(e=>n?n.samples.ts.length>=50?(t.push(n),n=s(e),void c(t)):(n.samples.height.push(window.innerHeight),n.samples.width.push(window.innerWidth),n.samples.ts.push(e.timeStamp),n.samples.scrollX.push(window.scrollX),n.samples.scrollY.push(window.scrollY),n.samples.dpr.push(window.devicePixelRatio),void c(t)):(n=s(e),void c(t)));function s(t){return{name:"viewport",type:"resize",timestamp:Date.now(),samples:{height:[window.innerHeight],width:[window.innerWidth],ts:[t.timeStamp],scrollX:[window.scrollX],scrollY:[window.scrollY],dpr:[window.devicePixelRatio]}}}function c(t){o&&clearTimeout(o),o=setTimeout(()=>{n&&(t.push(n),n=null),o=null},y)}return e(window,"resize",r),()=>{i(window,"resize",r),o&&(clearTimeout(o),o=null),n&&(t.push(n),n=null)}},layer:"behavioral"},viewport:{create:function(t,n,o){const r=a(n=>{const e=c(n,"orientation");t.push(e)}),s=a(n=>{const e=c(n,"ratiochange");t.push(e)});function c(t,n){return{name:"viewport",type:n,timestamp:Date.now(),isTrusted:t.isTrusted,height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio}}return x(o,"orientationchange")&&e(window,"orientationchange",r),x(o,"devicepixelratiochange")&&e(window,"devicepixelratiochange",s),()=>{i(window,"orientationchange",r),i(window,"devicepixelratiochange",s)}},layer:"behavioral",events:["orientationchange","devicepixelratiochange"]},sensors:{create:function(t,n,o){let r=null,s=null,c=null,u=null,h=0;function f(){u&&d(u),u=setTimeout(l(()=>{p(),u=null}),y)}function p(){r&&(t.push(r),r=null),s&&(t.push(s),s=null),c&&(t.push(c),c=null)}const m=a(n=>{const e=n,i=e.timeStamp,o=e.acceleration,s=e.accelerationIncludingGravity,c=e.rotationRate;if(!o&&!s&&!c||null===o?.x&&null===o?.y&&null===o?.z&&null===s?.x&&null===s?.y&&null===s?.z&&null===c?.alpha&&null===c?.beta&&null===c?.gamma)return;if(!r)return r={name:"sensors",type:"motion",timestamp:Date.now(),interval:e.interval??null,samples:{ax:[o?.x??0],ay:[o?.y??0],az:[o?.z??0],agx:[s?.x??0],agy:[s?.y??0],agz:[s?.z??0],rrAlpha:[c?.alpha??0],rrBeta:[c?.beta??0],rrGamma:[c?.gamma??0],ts:[i]}},void f();if(r.samples.ts.length>=50)return t.push(r),r={name:"sensors",type:"motion",timestamp:Date.now(),interval:e.interval??null,samples:{ax:[o?.x??0],ay:[o?.y??0],az:[o?.z??0],agx:[s?.x??0],agy:[s?.y??0],agz:[s?.z??0],rrAlpha:[c?.alpha??0],rrBeta:[c?.beta??0],rrGamma:[c?.gamma??0],ts:[i]}},void f();const a=r.samples;a.ax.push(o?.x??0),a.ay.push(o?.y??0),a.az.push(o?.z??0),a.agx.push(s?.x??0),a.agy.push(s?.y??0),a.agz.push(s?.z??0),a.rrAlpha.push(c?.alpha??0),a.rrBeta.push(c?.beta??0),a.rrGamma.push(c?.gamma??0),a.ts.push(i),f()}),w=a(n=>{const e=n;if(null==e.alpha&&null==e.beta&&null==e.gamma)return;const i=e.timeStamp,o=e.webkitCompassHeading??0;if(!s)return s={name:"sensors",type:"orientation",timestamp:Date.now(),absolute:h||e.absolute,samples:{alpha:[e.alpha??0],beta:[e.beta??0],gamma:[e.gamma??0],compassHeading:[o],ts:[i]}},void f();if(s.samples.ts.length>=50)return t.push(s),s={name:"sensors",type:"orientation",timestamp:Date.now(),absolute:h||e.absolute,samples:{alpha:[e.alpha??0],beta:[e.beta??0],gamma:[e.gamma??0],compassHeading:[o],ts:[i]}},void f();const r=s.samples;r.alpha.push(e.alpha??0),r.beta.push(e.beta??0),r.gamma.push(e.gamma??0),r.compassHeading.push(o),r.ts.push(i),f()}),v=a(n=>{const e=n.value;if(null==e)return;const i=n.timeStamp;return c?c.samples.ts.length>=50?(t.push(c),c={name:"sensors",type:"light",timestamp:Date.now(),samples:{lux:[e],ts:[i]}},void f()):(c.samples.lux.push(e),c.samples.ts.push(i),void f()):(c={name:"sensors",type:"light",timestamp:Date.now(),samples:{lux:[e],ts:[i]}},void f())});return x(o,"motion")&&e(window,"devicemotion",m),x(o,"orientation")&&("ondeviceorientationabsolute"in window?(h=1,e(window,"deviceorientationabsolute",w)):e(window,"deviceorientation",w)),x(o,"light")&&e(window,"devicelight",v),function(){i(window,"devicemotion",m),i(window,h?"deviceorientationabsolute":"deviceorientation",w),i(window,"devicelight",v),u&&(d(u),u=null),p()}},layer:"behavioral",events:["motion","orientation","light"]},"network-request":{create:function(t){var e;const i=function(t,e,i,o=f){if("undefined"==typeof PerformanceObserver)return w;let r=null;try{r=new PerformanceObserver(n=>{for(const r of n.getEntries()){const n=r;o.has(n.initiatorType)&&(e(n.name)||t(m(n,i)))}}),r.observe({type:"resource",buffered:1})}catch{return n.warn("network-request","PerformanceObserver failed to start"),w}return function(){r?.disconnect(),r=null}}(function(n){s(()=>t.push(n))},(e=t.ignoredOrigins,function(t){try{return e.has(new URL(t).origin)}catch{return 0}}),t.sanitizeUrl);return function(){i()}},layer:"session"},screen:{create:function(t){const n=s(()=>function(){const t=window.screen;return{name:"screen",timestamp:Date.now(),availWidth:t.availWidth,availHeight:t.availHeight,width:t.width,height:t.height,colorDepth:t.colorDepth,pixelDepth:t.pixelDepth,availLeft:t.availLeft??0,availTop:t.availTop??0,orientation:t.orientation?{type:t.orientation.type,angle:t.orientation.angle}:null,isExtended:t.isExtended??0,viewport:{height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio}}}());return n&&t.push(n),()=>{}},layer:"session"}},W=Object.keys(Q),tt=[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,/^0b[01]+$/i,/^0o[0-7]+$/i,/^0x[0-9a-f]+$/i,/^[a-z][a-z0-9]{1,12}:[A-Za-z0-9+/=_-]{6,}$/i,/^[a-z]{2,8}_(?=.*\d)[A-Za-z0-9]{3,}$/,/^\d{4,}$/,/@/,/^[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{5,}\.[A-Za-z0-9_-]{10,}$/,/^[A-Za-z0-9_-]{20,}={0,2}$/,/^[0-9a-f]{7,}$/i];function nt(t){try{const n=new URL(t,location.href);n.username="",n.password="",n.hash="";const e=[...n.searchParams.keys()],i=e.length>0?"?"+e.map(t=>`${encodeURIComponent(t)}=<redacted>`).join("&"):"";n.search="",n.pathname=n.pathname.split("/").map(t=>""!==t&&function(t){for(const n of tt)if(n.test(t))return 1;return 0}(t)?":param":t).join("/");const o=n.origin+n.pathname+i;return o.length>2048?o.slice(0,2048):o}catch{return""}}const et={flush:{intervalMs:2e3,maxIntervalMs:3e4,size:50,backoffFailureThreshold:2},queue:{size:100}};function it(){const t={};for(const n of W)t[n]=st(n,void 0,1);return t}function ot(t){const n={};for(const e of W)n[e]=st(e,void 0,t[Q[e].layer]??0);return n}function rt(t){const n={};for(const e of W){const i=t[e];n[e]=st(e,i,i?.enabled??0)}return n}function st(t,n,e){const i=Q[t]?.events??[];if(0===i.length)return{enabled:e};const o=n?.events,r={};for(const t of i)r[t]={enabled:o?.[t]??1};return{enabled:e,events:r}}function ct(t){if(!t)return null;const n=t.split(".")[1],e=atob(n.replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(e)}const at=function(t,n=30){if(!t)return 1;const e=ct(t);return e&&"number"==typeof e.exp?1e3*e.exp<=Date.now()+1e3*n:1};async function lt(t,n){return globalThis.navigator&&"locks"in globalThis.navigator&&"request"in globalThis.navigator.locks&&"query"in globalThis.navigator.locks?navigator.locks.request(t,{mode:"exclusive"},async()=>c(n)):c(n)}const ut="__tri",dt=`${ut}_activity_token`,ht=`${ut}_activity_id`,ft=`${ut}_activity_status`,pt="__tri_activity_lock";class mt{constructor(t){this.context=t,this.u=null,this.h=null,this.p=null,this.m=null,this.v=0}getToken(){return this.u}getActivityId(){return this.h??""}isActive(){return"ACTIVE"===this.p&&null!==this.u}async start(){return this.v=1,this.m||(this.m=this.k()),this.m}async stop(){this.v=0,this.T(null),this.m=null,this.u&&await this.context.stopActivity(),this._(null)}async refresh(){if(!this.v)return;const t=this.u;await lt(pt,async()=>{if(this.u&&this.u!==t&&!at(this.u)&&"ACTIVE"===this.p)return;const n=this.I();n&&n.token!==t&&!at(n.token)&&"ACTIVE"===n.activityStatus?this._(n):(this.S(),await this.A())})}async k(){try{if(this.u&&!at(this.u))return;await lt(pt,async()=>{await this.A()})}finally{this.m=null}}async A(){const t=this.I();if(t&&!at(t.token)&&"ACTIVE"===t.activityStatus)return void this._(t);t&&this.S();const n=await this.context.startActivity();if(!n.ok)return;if(!n.data.token)return;const e=n.data;this._(e),this.M(e)}I(){const[t,n,e]=[q.get(dt),q.get(ht),q.get(ft)];return t&&n&&e?{token:t,activityId:n,activityStatus:e}:((t||n||e)&&this.S(),null)}M(t){q.set(dt,t.token),q.set(ht,t.activityId),q.set(ft,t.activityStatus)}S(){this.T(null),this._(null)}T(t){if(!t)return q.remove(dt),q.remove(ht),void q.remove(ft);q.set(dt,t.token),q.set(ht,t.activityId),q.set(ft,t.activityStatus)}_(t){if(!t)return this.u=null,this.h=null,void(this.p=null);this.u=t.token,this.h=t.activityId,this.p=t.activityStatus}}const wt=[401,403,409],yt=Object.freeze({tab:80,navigation:80,visibility:80,network:80,screen:80,fingerprint:80,pointer:60,keystroke:60,autofill:60,change:60,form:60,clipboard:60,selection:60,focus:60,viewport:60,network_request:60,scroll:40,sensors:40});function vt(t){return"pointer"===t.name&&"move"===t.phase||"viewport"===t.name&&"resize"===t.type?40:yt[t.name]}const gt=new Array(256);for(let t=0;t<256;t++)gt[t]=(t+256).toString(16).slice(1);const bt=new Uint8Array(16);function kt(t){return gt[t[0]]+gt[t[1]]+gt[t[2]]+gt[t[3]]+"-"+gt[t[4]]+gt[t[5]]+"-"+gt[t[6]]+gt[t[7]]+"-"+gt[t[8]]+gt[t[9]]+"-"+gt[t[10]]+gt[t[11]]+gt[t[12]]+gt[t[13]]+gt[t[14]]+gt[t[15]]}function Tt(){return crypto.randomUUID()}function _t(){return crypto.getRandomValues(bt),bt[6]=15&bt[6]|64,bt[8]=63&bt[8]|128,kt(bt)}function It(){for(let t=0;t<16;t++)bt[t]=256*Math.random()|0;return bt[6]=15&bt[6]|64,bt[8]=63&bt[8]|128,kt(bt)}const xt=function(){if("undefined"!=typeof crypto){if("function"==typeof crypto.randomUUID)return Tt;if("function"==typeof crypto.getRandomValues)return _t}return It}();function St(){return xt()}class Et{constructor(t,n){this.D=t,this.P=n,this.C=[],this.R=null,this.L=[],this.$=null,this.v=0,this.U=1,this.O=0,this.q=0,this.B=t.flush.intervalMs}push(t){if(this.v){if(this.C.length<this.j()?this.C.push(t):this.H(t),this.U)return this.C.length>=this.D.flush.size?(d(this.R),this.R=null,void this.flush("capacity")):void this.N()}else n.warn("Transport","push() called before start() — event dropped")}flush(t){if(this.v&&this.P.isActivityActive())try{if("lifecycle"===t)return void this.F();if(0===this.C.length)return;const e=this.X(t);this.P.ingest(e,0).then(t=>this.K(t,e)).catch(()=>{n.warn("Transport","ingest threw unexpectedly — batch dropped")}),this.C.length>0&&this.N()}catch(t){n.warn("Transport","flush() threw unexpectedly:",t)}}start(){this.v||(this.v=1,this.U="undefined"!=typeof navigator?navigator.onLine:1)}stop(){if(!this.v)return Promise.resolve();d(this.R),this.R=null,d(this.$),this.$=null;const t=this.F();return this.v=0,t}onConnectionChange(){const t="undefined"!=typeof navigator?navigator.onLine:1;if(t!==this.U){if(this.U=t,!this.U)return d(this.R),this.R=null,d(this.$),void(this.$=null);this.C.length>0&&this.N(),this.L.length>0&&this.V()}}N(){this.v&&this.U&&null===this.R&&(this.R=u(()=>{this.R=null,this.flush("interval")},this.B))}V(){this.v&&this.U&&null===this.$&&(this.$=u(()=>{this.$=null,this.Y()},this.B))}Y(){if(!this.v||!this.U||0===this.L.length||!this.P.isActivityActive())return;const t=this.L.shift();this.P.ingest(t.batch,0).then(n=>this.J(n,t)).catch(()=>{n.warn("Transport","retry drain ingest threw unexpectedly — batch dropped"),this.L.length>0&&this.V()})}G(t,e){this.L.length>=5&&(this.L.shift(),n.warn("Transport","retry queue full — oldest batch evicted")),this.L.push({batch:t,attempts:e}),this.V()}K(t,n){t.ok?this.Z():this.W(t)&&this.G(n,1)}J(t,e){if(t.ok)return this.Z(),void(this.L.length>0&&this.V());if(this.W(t)){if(e.attempts>=3)return this.tt(),n.warn("Transport","batch dropped after MAX_RETRY_ATTEMPTS",e.batch.batchId),void(this.L.length>0&&this.V());this.tt(),this.G(e.batch,e.attempts+1)}else this.L.length>0&&this.V()}tt(){this.O++,this.O%this.D.flush.backoffFailureThreshold===0&&(this.B=Math.min(2*this.B,this.D.flush.maxIntervalMs))}Z(){this.O=0,this.B=this.D.flush.intervalMs}j(){return this.D.queue.size*(this.U?1:2)}async F(){if(!this.P.isActivityActive())return Promise.resolve();const t=[];for(const e of this.L)t.push(this.P.ingest(e.batch,1).catch(()=>{n.warn("Transport","lifecycle retry ingest threw — batch dropped")}));if(this.L=[],this.C.length>0){const e=this.X("lifecycle");t.push(this.P.ingest(e,1).catch(()=>{n.warn("Transport","lifecycle ingest threw — batch dropped")}))}return Promise.allSettled(t).then(()=>{})}H(t){const n=vt(t);for(let e=0;e<this.C.length;e++)if(vt(this.C[e])<n){for(let t=e;t<this.C.length-1;t++)this.C[t]=this.C[t+1];return this.C.length-=1,void this.C.push(t)}}X(t){const n="lifecycle"===t?this.C.splice(-this.D.flush.size):this.C.splice(0,this.D.flush.size);return{activityId:"",batchId:St(),batchSequence:this.q++,clientTimestamp:Date.now(),schemaVersion:"0.1.0",sdkVersion:"0.3.1-rc.0",sdkPlatform:"web",tabId:this.P.getTabId(),events:n}}W(t){if(t.ok)return 0;switch(t.kind){case"timeout":case"server":case"rate_limited":return 1;default:return 0}}}const At="tri:bcast:";const Mt="function"==typeof BroadcastChannel?BroadcastChannel:function(){if("undefined"==typeof Storage||"undefined"==typeof window)return 0;try{const t="__tri_bcast_probe__";localStorage.setItem(t,"1");const n="1"===localStorage.getItem(t);return localStorage.removeItem(t),n}catch{return 0}}()?class{constructor(t){this.seq=0,this.closed=0,this.listeners=new Set,this.onStorageEvent=t=>{if(this.closed)return;if(!t.key||!t.key.startsWith(`${At}${this.channelName}:`))return;if(null===t.newValue)return;let n;s(()=>q.remove(t.key));try{n=JSON.parse(t.newValue)}catch{return}const e={data:n};for(const t of this.listeners)s(()=>t(e))},this.channelName=t,this.senderId=St(),window.addEventListener("storage",this.onStorageEvent)}postMessage(t){if(this.closed)return;const n=`${At}${this.channelName}:${this.senderId}:${this.seq++}`;s(()=>{q.set(n,t),q.remove(n)})}addEventListener(t,n){this.listeners.add(n)}removeEventListener(t,n){this.listeners.delete(n)}close(){this.closed||(this.closed=1,window.removeEventListener("storage",this.onStorageEvent),this.listeners.clear())}}:class{constructor(t){n.warn("BroadcastChannel","BroadcastChannel is unavailable and localStorage is not writable in this context. Cross-tab discovery is disabled; tab count will always be reported as 1.")}postMessage(t){}addEventListener(t,n){}removeEventListener(t,n){}close(){}},Dt="__tri_tabId";class Pt{constructor(t){this.context=t,this.nt="",this.v=0,this.et=null,this.it=null,this.ot=null,this.rt=new Map,this.st=-1,this.ct=null}async start(){this.v||(this.v=1,this.nt=this.lt(),this.ut(),this.dt({type:"hello",tabId:this.nt,ts:Date.now()}),this.ht(),this.ft("active"),this.wt())}stop(){this.v&&(this.v=0,this.ft("inactive"),this.dt({type:"bye",tabId:this.nt,ts:Date.now()}),this.yt(this.vt()),this.gt(),this.bt(),this.kt())}getTabId(){return this.nt}queryTabsNumber(){return this.rt.size+1}ut(){try{this.et=new Mt("__tri_tab_channel"),this.ct=this.Tt.bind(this),this.et.addEventListener("message",this.ct)}catch(t){n.warn("TabManager","failed to open broadcast channel:",t)}}kt(){try{if(!this.et)return;this.ct&&this.et.removeEventListener("message",this.ct),this.et.close()}catch{}finally{this.et=null,this.ct=null}}ht(){this.it=setInterval(()=>{const t=Date.now();this.dt({type:"heartbeat",tabId:this.nt,ts:t})},1e3)}gt(){null!=this.it&&(clearInterval(this.it),this.it=null)}wt(){null!=this.ot&&clearTimeout(this.ot),this.ot=setTimeout(()=>{this.ot=null;const t=this.vt()+1;t!==this.st&&(this.st=t,this.yt(t))},1e3)}bt(){null!=this.ot&&(clearTimeout(this.ot),this.ot=null)}dt(t){try{if(!this.et)return;this.et.postMessage(t)}catch{n.warn("TabManager","failed to broadcast message:",t)}}Tt(t){const{type:n,tabId:e}=t.data;if(e===this.nt)return;const i=Date.now();"hello"===n?(this.dt({type:"ack",tabId:this.nt,ts:i,to:e}),this.rt.set(e,i)):"heartbeat"===n||"ack"===n?this.rt.set(e,i):"bye"===n&&this.rt.delete(e)}yt(t){this.context.events.count&&this.context.push({name:"tab",type:"count",tabId:this.nt,timestamp:Date.now(),value:t})}ft(t){this.context.events.state&&this.context.push({name:"tab",type:"state",tabId:this.nt,timestamp:Date.now(),value:t})}lt(){const t=B.get(Dt);if(t)return t;const n=St();return B.set(Dt,n),n}vt(t=Date.now()){let n=0;for(const[e,i]of this.rt.entries())t-i>=3e3?this.rt.delete(e):n++;return n}}const Ct=globalThis.CompressionStream,Rt=globalThis.Response,zt=globalThis.Blob,Lt=new TextEncoder;let $t=null;async function Ut(t){const e=await async function(t){if("function"!=typeof Ct)return null;try{const n=Lt.encode(t),e=new zt([n]).stream().pipeThrough(new Ct("gzip"));return await new Rt(e).arrayBuffer()}catch(t){return n.warn("compression","Native gzip failed:",t),null}}(t);return null!==e?e:async function(t){try{const e=await function(){if(null===$t){const t=function(t,e=1e4){let i=null;const o=new Promise(t=>{i=u(()=>{n.warn("import",`Import timed out after ${e}ms`),t(null)},e)}),r=Promise.resolve().then(t).catch(t=>(n.warn("import","Import failed:",t),null));return Promise.race([r,o]).finally(()=>{d(i)})}(()=>Promise.resolve().then(function(){return require("./chunks/browser-D1C751kT.cjs")}),1e4);$t=t,t.then(n=>{null===n&&u(()=>{$t===t&&($t=null)},1e4)})}return $t}();if(null===e)return null;const{gzipSync:i}=e,o=i(Lt.encode(t));return o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)}catch(t){return n.warn("compression","fflate gzip failed:",t),null}}(t)}function Ot(t){const n={Accept:"application/json"};return t?.hasBody&&("json"===t.contentType?n["Content-Type"]="application/json":"ndjson"===t.contentType&&(n["Content-Type"]="application/x-ndjson"),"gzip"===t.contentEncoding&&(n["Content-Encoding"]="gzip")),t?.token&&(n.Authorization=`Bearer ${t.token}`),t?.profileId&&(n["x-profile-id"]=t.profileId),t?.api?.version&&(n["x-api-version"]=t.api.version),t?.customHeaders&&Object.entries(t.customHeaders).forEach(([t,e])=>{n[t]=e}),n}const qt="function"==typeof globalThis.fetch?globalThis.fetch.bind(globalThis):void 0;class Bt{constructor(t){this.context=t}stop(){}async report(t,e){const i={name:t,metadata:e,timestamp:Date.now(),activityId:this.context.getActivityId()??""};try{const o=await this.context.reportEvent(i);if(o.ok)return o;n.warn("EventReport","Failed to report event:",t,e,"with result:",o)}catch(i){n.warn("EventReport","Failed to report event:",t,e,"with error:",i)}}}const jt=new Set(["A","BUTTON","INPUT","SELECT","TEXTAREA","SUMMARY","DETAILS","LABEL","OPTION","FIELDSET"]),Ht=new Set(["button","link","tab","menuitem","menuitemcheckbox","menuitemradio","checkbox","radio","switch","slider","spinbutton","combobox","listbox","option","searchbox","textbox","treeitem"]),Nt=255;function Ft(t,n,e){const i=t.tagName.toLowerCase(),o=function(t){const n=t.parentElement?.children??[],e=Math.min(n.length,1e3);let i=e-1,o=0,r=0;for(let i=0;i<e;i++){r++;const e=n[i];if(g(e,t.tagName)&&o++,e===t)break}return{siblings:i,ofType:o,child:r}}(t),r=function(t,n){const e=function(t){if(!t)return null;const n=t.getAttribute("data-tri-redact-attrs");return n?n.split(",").map(t=>t.trim().toLowerCase()):null}(t),i={},o=t.id;o&&!_("id",e)&&(i.id=o);const r=t.getAttribute("autocomplete");r&&!_("autocomplete",e)&&(i.autocomplete=r);const s=t.getAttribute("aria-invalid");s&&!_("aria-invalid",e)&&(i.ariaInvalid=s);const c=t.getAttribute("tabindex");c&&!_("tabindex",e)&&(i.tabIndex=parseInt(c,10));const a=function(t){return t.getAttribute("data-testid")??t.getAttribute("data-cy")??null}(t);a&&!_("data-testid",e)&&(i.testId=a);const l=t.hasAttribute("readonly");l&&!_("readonly",e)&&(i.readOnly=l);const u=t.hasAttribute("required");u&&!_("required",e)&&(i.required=u);const d=t.getAttribute("contenteditable");d&&!_("contenteditable",e)&&(i.contentEditable="true"===d||""===d);const h=t.getAttribute("href");h&&!_("href",e)&&(i.href={...n?{}:{url:h},external:I(h)});const f=t.getAttribute("role");f&&!_("role",e)&&(i.role=f);const p=t.getAttribute("type");p&&!_("type",e)&&(i.type=p);const m=t.getAttribute("name");m&&!_("name",e)&&(i.name=m);const w=t.getAttribute("placeholder");!w||n||_("placeholder",e)||(i.placeholder=w);const y=Array.from(t.classList).slice(0,5);y.length>0&&!_("class",e)&&(i.classes=y);const v=t.getAttribute("alt");return!v||n||_("alt",e)||(i.alt=v),Object.keys(i).length?i:null}(t,n);return{tagName:i,frame:e,...r?{attributes:r}:{},...o?{nth:o}:{}}}function Xt(t,n){let e=0;const i=[];return function(t){return jt.has(t.tagName)}(t)&&(e+=40,i.push("native")),function(t){return t.hasAttribute("data-tri-interactive")}(t)&&(e+=40,i.push("tri-interactive")),function(t){return g(t,"a")&&t.hasAttribute("href")}(t)&&(e+=15,i.push("has-href")),function(t){const n=t.getAttribute("role");return null!==n&&Ht.has(n)}(t)&&(e+=30,i.push("role")),function(t){return t.hasAttribute("onclick")||t.hasAttribute("ng-click")||t.hasAttribute("data-action")||t.hasAttribute("@click")}(t)&&(e+=20,i.push("click-handler")),function(t){const n=t.getAttribute("tabindex");if(null===n)return 0;const e=parseInt(n,10);return null!==e&&e>=0}(t)&&(e+=10,i.push("tabindex")),(t.id||t.getAttribute("data-testid"))&&(e+=5,i.push("has-id")),n>0&&(e+=Math.round(15/n),i.push("depth")),{score:e,reasons:i}}function Kt(t){return t>=20}function Vt(t){return null!==t&&t.width>0&&t.height>0&&t.y<window.innerHeight&&t.y+t.height>0&&t.x<window.innerWidth&&t.x+t.width>0}function Yt(t){return 1==t.disabled||"true"===t.getAttribute("aria-disabled")}function Jt(t,n=0){if(n)return null;const e=Zt(t,"labelledby");if(e)return{text:Wt(e),resolutionMethod:"aria-labelledby",confidence:"high"};const i=Qt(t);if(i)return{text:Wt(i),resolutionMethod:"aria-label",confidence:"high"};const o=function(t){if(!t.id)return null;const n=document.querySelector(`label[for="${CSS.escape(t.id)}"]`);return n?Gt(n):null}(t);if(o)return{text:Wt(o),resolutionMethod:"html-for",confidence:"high"};const r=function(t){const n=t.closest("label");return n?Gt(n):null}(t);if(r)return{text:Wt(r),resolutionMethod:"wrapping-label",confidence:"high"};const s=function(t){const n=t.getAttribute("placeholder");return n?.trim()??null}(t);if(s)return{text:Wt(s),resolutionMethod:"placeholder",confidence:"low"};const c=function(t){const n=t.getAttribute("title");return n?.trim()??null}(t);if(c)return{text:Wt(c),resolutionMethod:"title",confidence:"low"};const a=Zt(t,"describedby");if(a)return{text:Wt(a),resolutionMethod:"aria-describedby",confidence:"low"};const l=Gt(t);return l?{text:l,resolutionMethod:"text-content",confidence:"low"}:null}function Gt(t,n=0){if(n>8)return"";if(v(t))return function(t){return t?t.trim().split(/(\s+)/).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,Nt):null}(t.textContent)??"";if(!t.childNodes?.length)return"";let e="";for(const i of t.childNodes){const t=Gt(i,n+1);if(t&&(e=e?`${e} ${t}`:t,e.length>=Nt))break}return Wt(e)}function Zt(t,n){const e="labelledby"===n?"aria-labelledby":"aria-describedby",i=t?.getAttribute(e);if(!i)return null;const o=i.split(/\s+/),r=[];for(const t of o){const n=document.getElementById(t);if(!n)continue;const e=Qt(n)??Gt(n);e.length&&r.push(e)}return r.length?r.join(" "):null}function Qt(t){return t?.getAttribute("aria-label")?.trim()??null}function Wt(t){return t.length>Nt?t.slice(0,Nt)+"...":t}function tn(t){const n=t.getBoundingClientRect();return{x:n.x,y:n.y,width:n.width,height:n.height}}class nn{constructor(t){this.capacity=t,this.cache=new Map}get(t){return this.cache.get(t)}set(t,n){if(this.cache.has(t))this.cache.delete(t);else if(this.cache.size>=this.capacity){const t=this.cache.keys().next().value;t&&this.cache.delete(t)}this.cache.set(t,n)}delete(t){this.cache.delete(t)}clear(){this.cache.clear()}size(){return this.cache.size}}async function en(t,o){const{collectors:r,sdk:s}=t;let c=null,l=null,h=null,f=null;try{c=function(t){"undefined"!=typeof document&&"function"==typeof globalThis.fetch||n.warn("FalconService","createFalconServiceManager called in a non-browser environment — all requests will resolve with { ok: false, kind: 'network' }.");const e=function(t){const n=t?.timeout,e=t?.baseUrl??"",i=t?.api;async function o(t,o,r){if(void 0===qt)return{ok:0,kind:"network"};const s=e?`${e}${o}`:o,c=new AbortController;let a=null,l=0;a=u(()=>{l=1,c.abort()},n);const h=r?.signal;let f,p=()=>{};if(h)if(h.aborted)c.abort();else{const t=()=>c.abort();h.addEventListener("abort",t,{once:1}),p=()=>h.removeEventListener("abort",t)}if(null!=r&&"body"in r&&null!=r.body){const t=function(t){if(null==t)return{ok:1,body:void 0};if("string"==typeof t||t instanceof ArrayBuffer||ArrayBuffer.isView(t)||t instanceof Blob||t instanceof FormData||t instanceof URLSearchParams||t instanceof ReadableStream)return{ok:1,body:t};try{return{ok:1,body:JSON.stringify(t)}}catch{return{ok:0}}}(r.body);if(!t.ok)return d(a),p(),{ok:0,kind:"serialize"};f=t.body}try{const n=await qt(s,{method:t,headers:Ot({token:r?.token,profileId:r?.profileId,contentType:r?.contentType,contentEncoding:r?.contentEncoding,api:i,hasBody:void 0!==f,customHeaders:r?.customHeaders}),body:f,signal:c.signal,keepalive:r?.keepalive});if(!n.ok)return 429===(m=n.status)?{ok:0,kind:"rate_limited",status:m}:m>=400&&m<500?{ok:0,kind:"client",status:m}:{ok:0,kind:"server",status:m};if(204===n.status)return{ok:1,data:void 0,status:204};try{return{ok:1,data:await n.json(),status:n.status}}catch{return c.signal.aborted?l?{ok:0,kind:"timeout"}:{ok:0,kind:"abort"}:{ok:0,kind:"parse",status:n.status}}}catch{return l?{ok:0,kind:"timeout"}:c.signal.aborted?{ok:0,kind:"abort"}:{ok:0,kind:"network"}}finally{d(a),p()}var m}return{post:async function(t,n){return o("POST",t,n)},get:async function(t,n){return o("GET",t,n)}}}({baseUrl:`${t.api.url}/api/v1`,timeout:1e4,api:{version:t.api.version}}),i=function(t){const{getToken:e,refresh:i}=t;let o=null;return{withAuth:async function(t,r){if(o){const n=await o;if(n)return t(n)}const s=e()??"",c=await t(s);if((a=c).ok||"client"!==a.kind||!wt.includes(a.status)||0==r?.refreshable)return c;var a;const l=await(o||(o=async function(){try{return await i(),e()}catch(t){return n.warn("AuthMiddleware","auth refresh failed",t),null}}().finally(()=>{o=null}),o));return l&&l!==s?t(l):c}}}(t),o=()=>({profileId:t.getProfileId()??void 0});return{api:{ingest:async function(n,r){return i.withAuth(async i=>{const{events:s,...c}=n,a={...c,activityId:t.getActivityId()};let l;try{l=await async function(t,n){const e=function(t,n){const e=[JSON.stringify(t)];for(let t=0;t<n.length;t++)try{e.push(JSON.stringify(n[t]))}catch{}return e.join("\n")}(t,n),i=await Ut(e);return i?{type:"gzip",body:i}:{type:"ndjson",body:e}}(a,s)}catch{return{ok:0,kind:"serialize"}}return e.post("/events/capture",{body:l.body,token:i,keepalive:r,contentType:"ndjson",contentEncoding:"gzip"===l.type?"gzip":void 0,...o()})},{refreshable:!r})},reportEvent:async function(t){return i.withAuth(n=>e.post("/events/report-event",{body:t,token:n,contentType:"json",...o()}))},startActivity:async function(){return e.post("/events/start-activity",{token:t.getSdkToken(),...o()})},stopActivity:async function(){return i.withAuth(t=>e.post("/events/end-activity",{token:t,keepalive:1,...o()}),{refreshable:0})},collectionStatus:async function(){return e.get("/sdk/collection-status",{token:t.getSdkToken(),...o()})},linkInterview:async function(t){return i.withAuth(n=>e.post("/events/link-interview",{token:n,contentType:"json",...o(),customHeaders:{"X-Incode-Hardware-Id":t}}))}}}}({api:{version:s.api.version,url:s.api.url},getSdkToken:()=>s.token,getProfileId:()=>o.getProfileId(),getToken:()=>l?.getToken()??null,refresh:async()=>l?.refresh()??Promise.resolve(),getActivityId:()=>l?.getActivityId()??""});const t=await c.api.collectionStatus();if(!t.ok||1!=t.data.eventsCollectionEnabled)return{status:"collection-disabled"};l=new mt({startActivity:()=>c.api.startActivity(),stopActivity:()=>c.api.stopActivity()}),h=new Et(et,{ingest:(t,n)=>c.api.ingest(t,n),getTabId:()=>f?.getTabId()??"unknown",isActivityActive:()=>l?.isActive()??0});const p=r.tab;f=new Pt({push:t=>h?.push(t),events:{state:p.enabled&&p.events.state.enabled,count:p.enabled&&p.events.count.enabled}});const m=function(t){function n(n){"hidden"===document.visibilityState&&t.flush()}function o(n){t.flush(),t.stopTab(),t.getShouldSkipStopActivity()||t.stopActivity()}const r=a(()=>t.onConnectionChange());return{start:function(){e(document,"visibilitychange",n),e(window,"pagehide",o),e(window,"online",r),e(window,"offline",r)},stop:function(){i(document,"visibilitychange",n),i(window,"pagehide",o),i(window,"online",r),i(window,"offline",r)}}}({flush:()=>h?.flush("lifecycle"),stopActivity:async()=>l?.stop(),stopTab:()=>f?.stop(),getShouldSkipStopActivity:()=>(f?.queryTabsNumber()??0)>1,onConnectionChange:()=>h?.onConnectionChange()}),w=function(t){const n=t||"redact",e=new nn(6),i=new nn(6);return{resolve:function(t){if(!t||k(t)||"off"===n)return null;let o=e.get(t);if(o||(o=function(t){if(!t||k(t))return{chain:[],redaction:{level:"ignore",index:-1}};const n=[];let e=t,i=-1;for(;e;){if(k(e))return{chain:[],redaction:{level:"ignore",index:-1}};T(e)&&(i=n.length),n.push(e);const t=e.parentNode;if(!t||g(e,"body"))break;e=b(t)?t.host:t}return{chain:n,redaction:{level:-1===i?"full":"redact",index:i}}}(t.parentElement),e.set(t,o)),"ignore"===o.redaction.level)return null;const r="redact"===o.redaction.level||"redact"===n||T(t);let s=i.get(t);return s||(s=function(t,n,e,i){const o=getComputedStyle(t),r=tn(t),s=function(t,n){const e=[],i=[];for(let o=t.length-1;o>=0;o--){const r=t[o],s=o<=n,c=o+1,a=Ft(r,s,tn(r)),{score:l,reasons:u}=Xt(r,c);if(e.push(a),!Kt(l))continue;const d=Jt(r,s);i.push({...a,...d?{label:d}:{},depth:c,score:l,reasons:u})}return{ancestors:e,interactiveCandidates:i.reverse()}}(n,i),c=Ft(t,e,r),a=function(t,n,e){const{score:i,reasons:o}=Xt(t,0);return{interactive:Kt(i),...o.length>0?{reasons:o}:{},disabled:Yt(t),rendered:"none"!==n?.display,visible:"hidden"!==n?.visibility,inViewport:Vt(e),acceptsPointer:"none"!==n?.pointerEvents,opacity:parseFloat(n?.opacity||"1")}}(t,o,r);let l=null;return e||(l=a.interactive?Jt(t):null),{tagName:c.tagName,frame:c.frame,viewport:{height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio},attributes:c.attributes,nth:c.nth,...l?{label:l}:{},ancestors:s.ancestors,interactiveCandidates:s.interactiveCandidates,interactivity:a}}(t,o.chain,r,o.redaction.index),i.set(t,s)),s}}}(s.capture?.element),y=new Set;try{y.add(new URL(s.api.url).origin)}catch{}const v=function(t,n,e="on"){const i=new Map;function o(o){if(i.has(o))return;const r=Q[o];if(!r||!function(t,n){return n[t]?.enabled??0}(o,n))return;const s=n[o],c=r.create(t,e,s&&"events"in s?s.events:void 0);i.set(o,c)}return{start:o,stopCollector:function(t){const n=i.get(t);n&&(n(),i.delete(t))},stop:function(){for(const[,t]of i)t();i.clear()},isRunning:function(t){return i.has(t)},autocapture:function(){for(const t of W)o(t)}}}({push:t=>h?.push(t),resolveElement:t=>w.resolve(t),sanitizeUrl:s.sanitizeUrl,ignoredOrigins:y},r,s.capture?.content),_=new Bt({getActivityId:()=>l?.getActivityId()??"",reportEvent:t=>c.api.reportEvent(t)});return{status:"ready",managers:{falconServiceManager:c,activityManager:l,transportManager:h,tabManager:f,lifecycleManager:m,collectorManager:v,eventReportManager:_}}}catch(t){return n.warn("IncodeTRI","setup() failed during construction:",t),{status:"init-failed"}}}let on=class t{constructor(){this._t=0,this.D=null,this.It=null,this.xt="idle"}static get instance(){return t.o||(t.o=new t),t.o}async setup(t){if("idle"!==this.xt)return n.fatal("error","setup()","called more than once — ignoring."),"init-failed";try{const e=function(t){if("undefined"==typeof document)return n.fatal("error","IncodeTRI","TRI is not available in a non-browser environment."),null;if(!t?.token)return n.fatal("error","SDK","token is required."),null;if(!t.apiURL)return n.fatal("error","SDK","Couldn't initialise SDK — apiURL isn't provided."),null;const{element:e,content:i}=t.capture??{},o={token:t.token,capture:{element:e??"redact",content:i??"off"},profileId:t.profileId,api:{version:t.apiVersion??"1.0",url:t.apiURL},sanitizeUrl:(r=t.sanitizeUrl,r?function(t){return s(()=>r(t,nt))??nt(t)}:nt),DEBUG:t.DEBUG??0};var r;return void 0===t.collectors&&void 0===t.layers?{sdk:o,collectors:it()}:void 0!==t.collectors?{sdk:o,collectors:rt(t.collectors)}:{sdk:o,collectors:ot(t.layers)}}(t);if(!e)return"init-failed";n.DEBUG=e.sdk.DEBUG;const i=await en(e,{getProfileId:()=>this.St()});return"collection-disabled"===i.status?(n.fatal("warn","setup()","Collection is disabled for the provided API Key."),"collection-disabled"):"init-failed"===i.status?"init-failed":(this.D=e,this.It=i.managers,this.xt="ready",this.Et(e.sdk.profileId),"ready")}catch(t){return n.warn("setup()","failed:",t),"init-failed"}}async start(){if("idle"===this.xt)return n.warn("start()","start() requires a prior successful setup() — ignoring."),this.xt;if("ready"!==this.xt)return n.fatal("warn","start()","TRI is either already started or isn't ready — ignoring."),this.xt;this.xt="starting";const t=++this._t;return await this.k(t),this.xt}async stop(){n.warn("stop()","called");const t=this.It;return t?(++this._t,t.lifecycleManager.stop(),t.collectorManager.stop(),t.tabManager.stop(),t.eventReportManager.stop(),this.xt="ready",this.At(t)):Promise.resolve(this.xt)}async reset(){const t=this.stop();return this.xt="idle",this.D=null,this.It=null,q.remove("__tri_profile_id"),t.then(()=>this.xt)}async At(t){return await function(t){let n=null;const e=new Promise(t=>{n=u(t,2e3)});return Promise.race([t.finally(()=>d(n)),e])}(Promise.resolve(t.transportManager.stop())),await t.activityManager.stop(),this.xt}reportEvent(t,e){"started"===this.xt?this.It?c(()=>this.It.eventReportManager.report(t,e)):n.warn("reportEvent()","reportEvent() called but managers are unavailable — dropping event."):n.warn("reportEvent()","reportEvent() called before start() completed — dropping event.")}setProfileId(t){"started"===this.xt?this.D?.sdk&&(this.D.sdk.profileId=t,this.Et(t)):n.warn("setProfileId()","setProfileId() called before start() completed — ignoring.")}async linkInterview(t){if("started"!==this.xt||!this.It)return n.warn("linkInterview()","linkInterview() called before start() completed — ignoring."),0;if(!t)return n.warn("linkInterview()","linkInterview() called without sessionToken — ignoring."),0;try{return(await this.It.falconServiceManager.api.linkInterview(t)).ok}catch(t){return n.warn("linkInterview()","failed:",t),0}}St(){return this.D?.sdk?.profileId??q.get("__tri_profile_id")??null}Et(t){t&&q.set("__tri_profile_id",t)}async k(t){const e=this.It;if(e){try{if(await e.activityManager.start(),t!==this._t)return;if(e.transportManager.start(),await e.tabManager.start(),t!==this._t)return;e.lifecycleManager.start(),e.collectorManager.autocapture()}catch(e){return n.warn("start()","failed during monitoring start:",e),void(t===this._t&&(this.xt="ready"))}t===this._t&&(this.xt="started")}}};on.o=null;const rn=on.instance;exports.createSession=async function(t,n){const e=n?.apiURL??"https://falcon-ingest-k8s.stage.incodetest.com",i=n?.timeout??1e4,o=new AbortController;let r=null,s=0,c=()=>{};i&&(r=u(()=>{s=1,o.abort()},i));const a=n?.signal;if(a)if(a.aborted)o.abort();else{const t=()=>o.abort();a.addEventListener("abort",t,{once:1}),c=()=>a.removeEventListener("abort",t)}try{const n=await fetch(`${e}/api/v1/sdk/init`,{method:"POST",headers:{"content-type":"application/json","x-api-key":t,"x-api-version":"1.0"},signal:o.signal});if(!n.ok){let t=n.statusText;try{const e=await n.json();e.errorMessage&&(t=e.errorMessage)}catch{}return{token:null,eventsCollectionEnabled:0,error:{status:n.status,message:t}}}return await n.json()}catch(t){throw new Error((s?"[TRI] createSession timed out":"[TRI] Failed to create session:")+" "+t.message)}finally{d(r),c()}},exports.default=rn;
|
package/dist/tri.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
class t{constructor(){this.t=0}static get instance(){return t.i||(t.i=new t),t.i}get DEBUG(){return this.t}set DEBUG(t){this.t=t}warn(t,n,...e){this.t&&this.o("warn",t,n,...e)}error(t,n,...e){this.t&&this.o("error",t,n,...e)}info(t,n,...e){this.t&&this.o("info",t,n,...e)}fatal(t,n,e,...i){this.o(t,n,e,...i)}o(t,n,e,...i){const o=n?`[${n}]`:"",r=console?.[t];r&&r(`[IncodeTRI]${o} ${e}`,...i)}}const n=t.instance;function e(t,n,e){let i=t,o=n;if("devicepixelratiochange"===n){const t=window.devicePixelRatio;i=window.matchMedia(`(resolution: ${t}dppx)`),o="change"}i.addEventListener(o,e,{capture:1,passive:1})}function i(t,n,e){let i=t,o=n;if("devicepixelratiochange"===n){const t=window.devicePixelRatio;i=window.matchMedia(`(resolution: ${t}dppx)`),o="change"}i.removeEventListener(o,e,{capture:1})}const o=globalThis.setTimeout.bind(globalThis),r=globalThis.clearTimeout.bind(globalThis);function s(t,e){try{return t()}catch(t){n.warn("utils","safeSync swallowed error:",t)}}async function c(t){try{return await t()}catch(t){n.warn("utils","safeAsync swallowed error:",t)}}function a(t){return n=>s(()=>t(n))}function l(t){return(...e)=>{try{t(...e)}catch(t){n.warn("utils","safeTimer swallowed error:",t)}}}function u(t,n){return o(l(t),n)}function d(t){if(null!==t)try{r(t)}catch(t){n.warn("utils","safeClearTimeout swallowed error:",t)}}const h=new Set(["xmlhttprequest","fetch","beacon","navigation","script","link","css","img","iframe","video","audio"]),f=new Set(["xmlhttprequest","fetch","beacon"]);function p(t,n){return n?t:null}function m(t,n){const e=t,i=t.responseStart>0,o=p(t.domainLookupEnd-t.domainLookupStart,i),r=p(t.connectEnd-t.connectStart,i),s=p(t.connectEnd>0&&t.secureConnectionStart>0?t.connectEnd-t.secureConnectionStart:0,i),c=p(t.responseStart-t.requestStart,i),a=p(t.responseEnd-t.responseStart,i),l=i?t.transferSize:null,u=i?t.encodedBodySize:null,d=i?t.decodedBodySize:null,f=i&&t.nextHopProtocol||null,m=i&&void 0!==e.deliveryType?e.deliveryType:null,w=e.responseStatus,y=void 0!==w&&0!==w?w:null;return{name:"network_request",timestamp:Date.now(),performanceTime:t.startTime+t.duration,url:n(t.name),initiatorType:(v=t.initiatorType,h.has(v)?v:"other"),startTime:t.startTime,durationMs:t.duration,dnsLookupMs:o,tcpConnectMs:r,tlsHandshakeMs:s,ttfbMs:c,responseDownloadMs:a,transferSize:l,encodedBodySize:u,decodedBodySize:d,nextHopProtocol:f,deliveryType:m,responseStatus:y};var v}function w(){}const y=2e3;function v(t){return!!t&&t.nodeType===Node.TEXT_NODE}function g(t,n){return t.tagName?.toLowerCase()===n.toLowerCase()}function b(t){return!!t&&t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function k(t){return t?t.hasAttribute("data-tri-ignore"):0}function T(t){return t?t.hasAttribute("data-tri-redact"):0}function _(t,n){return n?.includes(t.toLowerCase())??0}function I(t){try{return new URL(t).origin!==window.location.origin}catch{return 0}}function S(t,n){return t?t[n]?.enabled??0:1}function x(){const t=document.activeElement;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement){const n=t.selectionStart,e=t.selectionEnd;return null==n||null==e||n===e?null:t.value.substring(n,e)}const n=window.getSelection();return!n||n.isCollapsed?null:n.toString()||null}function E(t,n){return"off"===n||k(t)||T(t)?0:1}function A(t){const n=document.activeElement;if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)return n;const e=window.getSelection();return(i=("start"===t?e?.anchorNode:e?.focusNode)??null)?v(i)?i.parentElement:i instanceof Element?i:null:null;var i}function M(){const t=window,n="__fpjs_p_l_b",e=t[n];if(function(t,n){var e;const i=null===(e=Object.getOwnPropertyDescriptor)||void 0===e?void 0:e.call(Object,t,n);(null==i?void 0:i.configurable)?delete t[n]:i&&!i.writable||(t[n]=void 0)}(t,n),"function"!=typeof(null==e?void 0:e.load))throw new Error($);return e}const D="Blocked by CSP",P="The endpoint parameter is not a valid URL";function C(t){return function(t,n){const e=document,i="securitypolicyviolation";let o;const r=n=>{const e=new URL(t,location.href),{blockedURI:i}=n;i!==e.href&&i!==e.protocol.slice(0,-1)&&i!==e.origin||(o=n,s())};e.addEventListener(i,r);const s=()=>e.removeEventListener(i,r);return Promise.resolve().then(n).then(t=>(s(),t),t=>new Promise(t=>{const n=new MessageChannel;n.port1.onmessage=()=>t(),n.port2.postMessage(null)}).then(()=>{if(s(),o)return(()=>{throw new Error(D)})();throw t}))}(t,()=>function(t){return new Promise((n,e)=>{if(function(t){if(URL.prototype)try{return new URL(t,location.href),0}catch(t){if(t instanceof Error&&"TypeError"===t.name)return 1;throw t}}(t))throw new Error(P);const i=document.createElement("script"),o=()=>{var t;return null===(t=i.parentNode)||void 0===t?void 0:t.removeChild(i)},r=document.head||document.getElementsByTagName("head")[0];i.onload=()=>{o(),n()},i.onerror=()=>{o(),e(new Error(L))},i.async=1,i.src=t,r.appendChild(i)})}(t)).then(M)}const R="API key required";var z="3.12.9";const L="Failed to load the JS script of the agent",$="9319",U={scriptUrl:"https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js"};function B(t){function n(){return globalThis.window&&globalThis.window[t]&&void 0!==globalThis.window[t]}return{get:function(e){if(!n())return null;try{const n=window[t].getItem(e)??"null";return"null"===n?null:JSON.parse(n)}catch{return null}},set:function(e,i){n()&&s(()=>window[t].setItem(e,JSON.stringify(i)))},remove:function(e){n()&&s(()=>window[t].removeItem(e))},key:function(e){return n()?window[t].key(e):null},get length(){return n()?window[t].length:0}}}const O=B("localStorage"),q=B("sessionStorage"),j="__tri_fingerprint";let H=null,N=null;async function F(t){try{const n=await function(t){return H||(H=function(t){var n,e;const{picked:i,rest:o}=function(t,n){const e={},i={};for(const[o,r]of Object.entries(t))n.includes(o)?e[o]=r:i[o]=r;return{picked:e,rest:i}}(t,["scriptUrlPattern","token","apiKey"]),r=null!==(n=i.apiKey)&&void 0!==n?n:i.token,s=null!==(e=function(t,n){return function(t,n){return Object.prototype.hasOwnProperty.call(t,n)}(t,n)?t[n]:void 0}(t,"scriptUrlPattern"))&&void 0!==e?e:U.scriptUrl,[c,a]=function(){const t=[],n=()=>{t.push({time:new Date,state:document.visibilityState})},e=((i=document).addEventListener("visibilitychange",o=n,r),()=>i.removeEventListener("visibilitychange",o,r));var i,o,r;return n(),[t,e]}();return Promise.resolve().then(()=>{if(!r||"string"!=typeof r)throw new Error(R);return function(t,n){const e=[],[i,o]=function(t){const n=function(t){const n=[...t];return{current:()=>n[0],postpone(){const t=n.shift();void 0!==t&&n.push(t)},exclude(){n.shift()}}}(t),e=function(){let t=0;return()=>Math.random()*Math.min(3e3,100*Math.pow(2,t++))}(),i=new Set;return[n.current(),(t,o)=>{let r;const s=o instanceof Error?o.message:"";if(s===D||s===P)n.exclude(),r=0;else if(s===$)n.exclude();else if(s===L){const e=Date.now()-t.getTime()<50,o=n.current();o&&e&&!i.has(o)&&(i.add(o),r=0),n.postpone()}else n.postpone();const c=n.current();return void 0===c?void 0:[c,null!=r?r:t.getTime()+e()-Date.now()]}]}(t);let r;if(void 0===i)return Promise.reject(new TypeError("The list of script URL patterns is empty"));const s=t=>{const i=new Date,c=n=>e.push({url:t,startedAt:i,finishedAt:new Date,error:n}),a=n(t);return a.then(()=>c(),c),a.catch(t=>{if(null!=r||(r=t),e.length>=5)throw r;const n=o(i,t);if(!n)throw r;const[c,a]=n;return(l=a,new Promise(t=>setTimeout(t,l))).then(()=>s(c));var l})};return s(i).then(t=>[t,e])}(function(t,n){return(Array.isArray(t)?t:[t]).map(t=>function(t,n){const e=encodeURIComponent;return t.replace(/<[^<>]+>/g,t=>"<version>"===t?"3":"<apiKey>"===t?e(n):"<loaderVersion>"===t?e(z):t)}(String(t),n))}(s,r),C)}).catch(t=>{throw a(),function(t){return t instanceof Error&&t.message===$?new Error(L):t}(t)}).then(([t,n])=>(a(),t.load({...o,ldi:{attempts:n,visibilityStates:c}})))}({apiKey:t.apiKey,region:t.region,endpoint:t.endpoint,scriptUrlPattern:t.scriptUrlPattern}).catch(t=>{throw H=null,t}),H)}(t),e=await n.get({timeout:t.timeoutMs,extendedResult:1});if(!e.visitorId)return null;const i=t.cacheTtlMs??2592e6;return i>0&&function(t,n,e){const i={visitorId:t,requestId:n,expiresAt:Date.now()+e};O.set(j,i)}(e.visitorId,e.requestId,i),{visitorId:e.visitorId,requestId:e.requestId}}catch{return null}}const X={apiKey:"5uYRiI0XM6p8k4124ELX",endpoint:"https://fingerprint.incodesmile.com",scriptUrlPattern:"https://fingerprint.incodesmile.com/web/v<version>/<apiKey>/loader_v<loaderVersion>.js"},K={focusin:"in",focusout:"out"};function V(t){return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement}const Y=new Set(["Shift","Control","Alt","Meta","Backspace","Delete","Enter","Tab","CapsLock","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]),J={mouse:"mouse",touch:"touch",pen:"pen"},G={pointerdown:"down",pointerup:"up",click:"click",dblclick:"dblclick",contextmenu:"contextmenu"};function Z(t,n,e,i,o){return{name:"navigation",timestamp:Date.now(),phase:t,type:n,from:e.from,to:e.to,timeOrigin:i,timing:o}}const Q={fingerprint:{create:function(t){let n=0;return c(async()=>{const e=await async function(t){const n=function(){const t=O.get(j);return t?"string"!=typeof t.visitorId||"number"!=typeof t.expiresAt||t.expiresAt<=Date.now()?(O.remove(j),null):{visitorId:t.visitorId,requestId:"string"==typeof t.requestId?t.requestId:""}:null}();return n?{visitorId:n.visitorId,requestId:n.requestId||null}:N||(N=F(t).finally(()=>{N=null}),N)}(X);!n&&e&&t.push({name:"fingerprint",deviceId:e.visitorId,requestId:e.requestId,timestamp:Date.now()})}),()=>{n=1}},layer:"device-fingerprinting"},pointer:{create:function(t,n,o){const r=a(n=>{const e=function(n){const e=n,i=function(t){if("mouse"===t.pointerType)return{button:t.button,buttons:t.buttons};const n={force:t.pressure,contact:Math.min(t.width,t.height)};return"pen"===t.pointerType&&(n.tiltX=t.tiltX,n.tiltY=t.tiltY,n.twist=t.twist),n}(e);return{id:e.pointerId,name:"pointer",timestamp:Date.now(),type:J[e.pointerType]??"unknown",phase:G[n.type],isTrusted:e.isTrusted,element:t.resolveElement(e.target),isPrimary:e.isPrimary,modifiers:{shift:e.shiftKey,ctrl:e.ctrlKey,alt:e.altKey,meta:e.metaKey},coordinates:{x:e.clientX,y:e.clientY},...i}}(n);t.push(e)});return S(o,"pointer")&&(e(document,"pointerdown",r),e(document,"pointerup",r)),S(o,"click")&&e(document,"click",r),S(o,"dblclick")&&e(document,"dblclick",r),S(o,"contextmenu")&&e(document,"contextmenu",r),()=>{i(document,"pointerdown",r),i(document,"pointerup",r),i(document,"click",r),i(document,"dblclick",r),i(document,"contextmenu",r)}},layer:"behavioral",events:["pointer","click","dblclick","contextmenu"]},pointermove:{create:function(t){let n=null,o=null;const r=a(e=>{const i=e;return n&&n.id!==i.pointerId&&(t.push(n),n=null),n?n.samples.ts.length>=50?(t.push(n),n=s(i),void c(t)):(n.samples.x.push(i.clientX),n.samples.y.push(i.clientY),n.samples.ts.push(i.timeStamp),"pen"===i.pointerType&&(n.samples.tiltX?.push(i.tiltX),n.samples.tiltY?.push(i.tiltY)),"mouse"!==i.pointerType&&(n.samples.force?.push(i.pressure),n.samples.radius?.push(Math.max(i.width,i.height))),void c(t)):(n=s(i),void c(t))});function s(t){const n=function(t){if("mouse"===t.pointerType)return null;const n={force:[t.pressure],radius:[Math.max(t.width,t.height)]};return"pen"===t.pointerType&&(n.tiltX=[t.tiltX],n.tiltY=[t.tiltY]),n}(t);return{name:"pointer",timestamp:Date.now(),id:t.pointerId,type:t.pointerType,phase:"move",isTrusted:t.isTrusted,isPrimary:t.isPrimary,samples:{x:[t.clientX],y:[t.clientY],ts:[t.timeStamp],...n??{}}}}function c(t){o&&clearTimeout(o),o=setTimeout(()=>{n&&(t.push(n),n=null),o=null},y)}return e(document,"pointermove",r),()=>{i(document,"pointermove",r),o&&(clearTimeout(o),o=null),n&&(t.push(n),n=null)}},layer:"behavioral"},focus:{create:function(t){const n=a(n=>{const e=function(n){const e=n;return{name:"focus",type:K[n.type]??"unknown",timestamp:Date.now(),isTrusted:e.isTrusted,element:t.resolveElement(e.target),relatedTarget:t.resolveElement(e.relatedTarget)}}(n);t.push(e)});return e(document,"focusin",n),e(document,"focusout",n),()=>{i(document,"focusin",n),i(document,"focusout",n)}},layer:"behavioral"},input:{create:function(t){const n=a(n=>{const e=n;t.push(function(n){return{name:"keystroke",type:"input",timestamp:Date.now(),isTrusted:n.isTrusted,element:t.resolveElement(n.target),inputType:n.inputType??"",isComposing:n.isComposing??0,length:(e=n.target,e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement?e.value.length:0)};var e}(e)),function(t){if("insertReplacementText"===t.inputType)return 1;const n=t.target;return V(n)?function(t){try{return t.matches(":-webkit-autofill")}catch{return 0}}(n):0}(e)&&t.push(function(t,n){const e=t.target;let i=0;return V(e)&&(i=e.value.length),{name:"autofill",timestamp:Date.now(),element:n.resolveElement(e),length:i}}(e,t))});return e(document,"input",n),function(){i(document,"input",n)}},layer:"behavioral"},keystroke:{create:function(t){const{resolve:n,reset:o}=function(){let t=0;const n=new Map;return{resolve:function(e,i){if("keydown"===i){const i=n.get(e);if(void 0!==i)return i;const o=++t;if(n.size>=32){const t=n.keys().next().value;void 0!==t&&n.delete(t)}return n.set(e,o),o}const o=n.get(e);return void 0!==o?(n.delete(e),o):++t},reset:function(){n.clear()}}}(),r=a(e=>{const i=function(t){const e=t,i=t.type;return{name:"keystroke",type:i,id:n(e.code,i),timestamp:Date.now(),isTrusted:e.isTrusted,keys:Y.has(e.key)?[e.key]:[]}}(e);t.push(i)}),s=a(()=>{o()});return e(document,"keydown",r),e(document,"keyup",r),e(window,"blur",s),()=>{i(document,"keydown",r),i(document,"keyup",r),i(window,"blur",s)}},layer:"behavioral"},clipboard:{create:function(t,n="on",o){const r=a(e=>{const i=function(e){const i=e,o=e.type,r=("paste"===e.type?i.clipboardData?.getData("text/plain"):x())??null,s=E(i.target,n);return{name:"clipboard",type:o,timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target),length:r?.length??0,...s&&r?{content:r}:{}}}(e);t.push(i)});return S(o,"paste")&&e(document,"paste",r),S(o,"cut")&&e(document,"cut",r),S(o,"copy")&&e(document,"copy",r),()=>{i(document,"paste",r),i(document,"cut",r),i(document,"copy",r)}},layer:"behavioral",events:["paste","cut","copy"]},form:{create:function(t,n,o){const r=a(n=>{const e={name:"form",type:(i=n).type,timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target)};var i;t.push(e)});return S(o,"submit")&&e(document,"submit",r),S(o,"invalid")&&e(document,"invalid",r),()=>{i(document,"submit",r),i(document,"invalid",r)}},layer:"behavioral",events:["submit","invalid"]},change:{create:function(t){const n=a(n=>{const e=(i=n,{name:"change",timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target)});var i;t.push(e)});return e(document,"change",n),()=>{i(document,"change",n)}},layer:"behavioral"},selection:{create:function(t,n){let o=0,r=0,s=null,c=0,l=0;function u(){s&&(clearTimeout(s),s=null)}function d(){u(),c||l||(s=setTimeout(()=>{s=null,o&&h("timeout")},250))}function h(e){o&&(o=0,u(),function(e){const i=A("end"),o=i&&E(i,n),r=x();t.push({name:"selection",phase:"end",timestamp:Date.now(),trigger:e,isTrusted:1,element:t.resolveElement(i),length:r?.length??0,...o&&r?{content:r}:{}})}(e))}const f=a(()=>{const n=function(){const t=document.getSelection();return!t||t.isCollapsed||0===t.rangeCount}();if(!o&&!n)return o=1,r=Date.now(),t.push({name:"selection",phase:"start",timestamp:r,element:t.resolveElement(A("start"))}),void d();o&&n?h("collapse"):o&&d()}),p=a(t=>{0===t.button&&(c=1,u())}),m=a(t=>{0===t.button&&(c=0,o&&h("pointer"))}),w=a(t=>{"Shift"===t.key&&(l=1,u())}),y=a(t=>{"Shift"===t.key&&(l=0,o&&h("keyboard"))}),v=a(()=>{c=0}),g=a(()=>{"hidden"===document.visibilityState&&(c=0,l=0,o&&h("timeout"))}),b=a(()=>{c=0,o&&h("pointer")});return e(document,"selectionchange",f),e(document,"pointerdown",p),e(document,"pointerup",m),e(document,"keydown",w),e(document,"keyup",y),e(document,"contextmenu",v),e(document,"visibilitychange",g),e(document,"dragend",b),()=>{u(),i(document,"selectionchange",f),i(document,"pointerdown",p),i(document,"pointerup",m),i(document,"keydown",w),i(document,"keyup",y),i(document,"contextmenu",v),i(document,"visibilitychange",g),i(document,"dragend",b)}},layer:"behavioral"},tab:{create:()=>()=>{},layer:"session",events:["state","count"]},visibility:{create:function(t){const n=a(n=>{const e=document.visibilityState;if("visible"!==e&&"hidden"!==e)return;const i={name:"visibility",type:e,timestamp:Date.now(),isTrusted:n.isTrusted};t.push(i)});return e(document,"visibilitychange",n),()=>{i(document,"visibilitychange",n)}},layer:"session"},navigation:{create:function(t){let n=t.sanitizeUrl(document.referrer||"");function o(e){t.push(e),n=e.to??""}const r=a(()=>{const[n]=performance.getEntriesByType("navigation");var e;o(Z("load",n?.type??"navigate",{from:document.referrer?t.sanitizeUrl(document.referrer):null,to:t.sanitizeUrl(location.href)},performance.timeOrigin,n?{fetchStart:(e=n).fetchStart,domainLookupStart:e.domainLookupStart,domainLookupEnd:e.domainLookupEnd,connectStart:e.connectStart,connectEnd:e.connectEnd,requestStart:e.requestStart,responseStart:e.responseStart,responseEnd:e.responseEnd,domInteractive:e.domInteractive,domContentLoadedEventStart:e.domContentLoadedEventStart,domContentLoadedEventEnd:e.domContentLoadedEventEnd,domComplete:e.domComplete,loadEventStart:e.loadEventStart,loadEventEnd:e.loadEventEnd,redirectCount:e.redirectCount,transferSize:e.transferSize,encodedBodySize:e.encodedBodySize,decodedBodySize:e.decodedBodySize}:void 0))}),c=a(e=>{const i=e;if(null===i.navigationType)return;const r=t.sanitizeUrl(location.href);r!==n&&o(Z("change",i.navigationType,{from:n,to:r},performance.timeOrigin))}),l=a(()=>d("traverse")),u=a(()=>d("hashchange"));function d(e){const i=t.sanitizeUrl(location.href);"hashchange"===e&&i===n||o(Z("change",e,{from:n,to:i},performance.timeOrigin))}const h=history.pushState,f=history.replaceState,p=function(...t){const n=h.apply(this,t);return s(()=>d("push")),n},m=function(...t){const n=f.apply(this,t);return s(()=>d("replace")),n};return window.navigation?e(window.navigation,"currententrychange",c):(history.pushState=p,history.replaceState=m,e(window,"popstate",l),e(window,"hashchange",u)),"complete"===document.readyState?r(new Event("load")):e(window,"load",r),()=>{window.navigation?i(window.navigation,"currententrychange",c):(history.pushState===p&&(history.pushState=h),history.replaceState===m&&(history.replaceState=f),i(window,"popstate",l),i(window,"hashchange",u)),i(window,"load",r)}},layer:"session"},networkconnection:{create:function(t){const n=a(()=>{const n={name:"network",type:"connection",state:navigator.onLine?"online":"offline",timestamp:Date.now()};t.push(n)});return e(window,"online",n),e(window,"offline",n),()=>{i(window,"online",n),i(window,"offline",n)}},layer:"session"},scroll:{create:function(t){let n=null,o=null;const r=a(e=>n?n.samples.ts.length>=50?(t.push(n),n=s(e),void c(t)):(n.samples.x.push(window.scrollX),n.samples.y.push(window.scrollY),n.samples.ts.push(e.timeStamp),void c(t)):(n=s(e),void c(t)));function s(t){return{name:"scroll",timestamp:Date.now(),samples:{x:[window.scrollX],y:[window.scrollY],ts:[t.timeStamp]},height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,pageX:window.pageXOffset,pageY:window.pageYOffset}}function c(t){o&&clearTimeout(o),o=setTimeout(()=>{n&&(t.push(n),n=null),o=null},y)}return e(window,"scroll",r),()=>{i(window,"scroll",r),o&&(clearTimeout(o),o=null),n&&(t.push(n),n=null)}},layer:"behavioral"},viewportresize:{create:function(t){let n=null,o=null;const r=a(e=>n?n.samples.ts.length>=50?(t.push(n),n=s(e),void c(t)):(n.samples.height.push(window.innerHeight),n.samples.width.push(window.innerWidth),n.samples.ts.push(e.timeStamp),n.samples.scrollX.push(window.scrollX),n.samples.scrollY.push(window.scrollY),n.samples.dpr.push(window.devicePixelRatio),void c(t)):(n=s(e),void c(t)));function s(t){return{name:"viewport",type:"resize",timestamp:Date.now(),samples:{height:[window.innerHeight],width:[window.innerWidth],ts:[t.timeStamp],scrollX:[window.scrollX],scrollY:[window.scrollY],dpr:[window.devicePixelRatio]}}}function c(t){o&&clearTimeout(o),o=setTimeout(()=>{n&&(t.push(n),n=null),o=null},y)}return e(window,"resize",r),()=>{i(window,"resize",r),o&&(clearTimeout(o),o=null),n&&(t.push(n),n=null)}},layer:"behavioral"},viewport:{create:function(t,n,o){const r=a(n=>{const e=c(n,"orientation");t.push(e)}),s=a(n=>{const e=c(n,"ratiochange");t.push(e)});function c(t,n){return{name:"viewport",type:n,timestamp:Date.now(),isTrusted:t.isTrusted,height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio}}return S(o,"orientationchange")&&e(window,"orientationchange",r),S(o,"devicepixelratiochange")&&e(window,"devicepixelratiochange",s),()=>{i(window,"orientationchange",r),i(window,"devicepixelratiochange",s)}},layer:"behavioral",events:["orientationchange","devicepixelratiochange"]},sensors:{create:function(t,n,o){let r=null,s=null,c=null,u=null,h=0;function f(){u&&d(u),u=setTimeout(l(()=>{p(),u=null}),y)}function p(){r&&(t.push(r),r=null),s&&(t.push(s),s=null),c&&(t.push(c),c=null)}const m=a(n=>{const e=n,i=e.timeStamp,o=e.acceleration,s=e.accelerationIncludingGravity,c=e.rotationRate;if(!o&&!s&&!c)return;if(!r)return r={name:"sensors",type:"motion",timestamp:Date.now(),interval:e.interval??null,samples:{ax:[o?.x??0],ay:[o?.y??0],az:[o?.z??0],agx:[s?.x??0],agy:[s?.y??0],agz:[s?.z??0],rrAlpha:[c?.alpha??0],rrBeta:[c?.beta??0],rrGamma:[c?.gamma??0],ts:[i]}},void f();if(r.samples.ts.length>=50)return t.push(r),r={name:"sensors",type:"motion",timestamp:Date.now(),interval:e.interval??null,samples:{ax:[o?.x??0],ay:[o?.y??0],az:[o?.z??0],agx:[s?.x??0],agy:[s?.y??0],agz:[s?.z??0],rrAlpha:[c?.alpha??0],rrBeta:[c?.beta??0],rrGamma:[c?.gamma??0],ts:[i]}},void f();const a=r.samples;a.ax.push(o?.x??0),a.ay.push(o?.y??0),a.az.push(o?.z??0),a.agx.push(s?.x??0),a.agy.push(s?.y??0),a.agz.push(s?.z??0),a.rrAlpha.push(c?.alpha??0),a.rrBeta.push(c?.beta??0),a.rrGamma.push(c?.gamma??0),a.ts.push(i),f()}),w=a(n=>{const e=n;if(null==e.alpha&&null==e.beta&&null==e.gamma)return;const i=e.timeStamp,o=e.webkitCompassHeading??0;if(!s)return s={name:"sensors",type:"orientation",timestamp:Date.now(),absolute:h||e.absolute,samples:{alpha:[e.alpha??0],beta:[e.beta??0],gamma:[e.gamma??0],compassHeading:[o],ts:[i]}},void f();if(s.samples.ts.length>=50)return t.push(s),s={name:"sensors",type:"orientation",timestamp:Date.now(),absolute:h||e.absolute,samples:{alpha:[e.alpha??0],beta:[e.beta??0],gamma:[e.gamma??0],compassHeading:[o],ts:[i]}},void f();const r=s.samples;r.alpha.push(e.alpha??0),r.beta.push(e.beta??0),r.gamma.push(e.gamma??0),r.compassHeading.push(o),r.ts.push(i),f()}),v=a(n=>{const e=n.value;if(null==e)return;const i=n.timeStamp;return c?c.samples.ts.length>=50?(t.push(c),c={name:"sensors",type:"light",timestamp:Date.now(),samples:{lux:[e],ts:[i]}},void f()):(c.samples.lux.push(e),c.samples.ts.push(i),void f()):(c={name:"sensors",type:"light",timestamp:Date.now(),samples:{lux:[e],ts:[i]}},void f())});return S(o,"motion")&&e(window,"devicemotion",m),S(o,"orientation")&&("ondeviceorientationabsolute"in window?(h=1,e(window,"deviceorientationabsolute",w)):e(window,"deviceorientation",w)),S(o,"light")&&e(window,"devicelight",v),function(){i(window,"devicemotion",m),i(window,h?"deviceorientationabsolute":"deviceorientation",w),i(window,"devicelight",v),u&&(d(u),u=null),p()}},layer:"behavioral",events:["motion","orientation","light"]},"network-request":{create:function(t){var e;const i=function(t,e,i,o=f){if("undefined"==typeof PerformanceObserver)return w;let r=null;try{r=new PerformanceObserver(n=>{for(const r of n.getEntries()){const n=r;o.has(n.initiatorType)&&(e(n.name)||t(m(n,i)))}}),r.observe({type:"resource",buffered:1})}catch{return n.warn("network-request","PerformanceObserver failed to start"),w}return function(){r?.disconnect(),r=null}}(function(n){s(()=>t.push(n))},(e=t.ignoredOrigins,function(t){try{return e.has(new URL(t).origin)}catch{return 0}}),t.sanitizeUrl);return function(){i()}},layer:"session"},screen:{create:function(t){const n=s(()=>function(){const t=window.screen;return{name:"screen",timestamp:Date.now(),availWidth:t.availWidth,availHeight:t.availHeight,width:t.width,height:t.height,colorDepth:t.colorDepth,pixelDepth:t.pixelDepth,availLeft:t.availLeft??0,availTop:t.availTop??0,orientation:t.orientation?{type:t.orientation.type,angle:t.orientation.angle}:null,isExtended:t.isExtended??0,viewport:{height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio}}}());return n&&t.push(n),()=>{}},layer:"session"}},W=Object.keys(Q),tt=[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,/^0b[01]+$/i,/^0o[0-7]+$/i,/^0x[0-9a-f]+$/i,/^[a-z][a-z0-9]{1,12}:[A-Za-z0-9+/=_-]{6,}$/i,/^[a-z]{2,8}_(?=.*\d)[A-Za-z0-9]{3,}$/,/^\d{4,}$/,/@/,/^[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{5,}\.[A-Za-z0-9_-]{10,}$/,/^[A-Za-z0-9_-]{20,}={0,2}$/,/^[0-9a-f]{7,}$/i];function nt(t){try{const n=new URL(t,location.href);n.username="",n.password="",n.hash="";const e=[...n.searchParams.keys()],i=e.length>0?"?"+e.map(t=>`${encodeURIComponent(t)}=<redacted>`).join("&"):"";n.search="",n.pathname=n.pathname.split("/").map(t=>""!==t&&function(t){for(const n of tt)if(n.test(t))return 1;return 0}(t)?":param":t).join("/");const o=n.origin+n.pathname+i;return o.length>2048?o.slice(0,2048):o}catch{return""}}const et={flush:{intervalMs:2e3,maxIntervalMs:3e4,size:50,backoffFailureThreshold:2},queue:{size:100}};function it(){const t={};for(const n of W)t[n]=st(n,void 0,1);return t}function ot(t){const n={};for(const e of W)n[e]=st(e,void 0,t[Q[e].layer]??0);return n}function rt(t){const n={};for(const e of W){const i=t[e];n[e]=st(e,i,i?.enabled??0)}return n}function st(t,n,e){const i=Q[t]?.events??[];if(0===i.length)return{enabled:e};const o=n?.events,r={};for(const t of i)r[t]={enabled:o?.[t]??1};return{enabled:e,events:r}}function ct(t){if(!t)return null;const n=t.split(".")[1],e=atob(n.replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(e)}const at=function(t,n=30){if(!t)return 1;const e=ct(t);return e&&"number"==typeof e.exp?1e3*e.exp<=Date.now()+1e3*n:1};async function lt(t,n){return globalThis.navigator&&"locks"in globalThis.navigator&&"request"in globalThis.navigator.locks&&"query"in globalThis.navigator.locks?navigator.locks.request(t,{mode:"exclusive"},async()=>c(n)):c(n)}const ut="__tri",dt=`${ut}_activity_token`,ht=`${ut}_activity_id`,ft=`${ut}_activity_status`,pt="__tri_activity_lock";class mt{constructor(t){this.context=t,this.l=null,this.u=null,this.h=null,this.p=null,this.m=0}getToken(){return this.l}getActivityId(){return this.u??""}isActive(){return"ACTIVE"===this.h&&null!==this.l}async start(){return this.m=1,this.p||(this.p=this.v()),this.p}async stop(){this.m=0,this.k(null),this.p=null,this.l&&await this.context.stopActivity(),this.T(null)}async refresh(){if(!this.m)return;const t=this.l;await lt(pt,async()=>{if(this.l&&this.l!==t&&!at(this.l)&&"ACTIVE"===this.h)return;const n=this._();n&&n.token!==t&&!at(n.token)&&"ACTIVE"===n.activityStatus?this.T(n):(this.I(),await this.S())})}async v(){try{if(this.l&&!at(this.l))return;await lt(pt,async()=>{await this.S()})}finally{this.p=null}}async S(){const t=this._();if(t&&!at(t.token)&&"ACTIVE"===t.activityStatus)return void this.T(t);t&&this.I();const n=await this.context.startActivity();if(!n.ok)return;if(!n.data.token)return;const e=n.data;this.T(e),this.A(e)}_(){const[t,n,e]=[O.get(dt),O.get(ht),O.get(ft)];return t&&n&&e?{token:t,activityId:n,activityStatus:e}:((t||n||e)&&this.I(),null)}A(t){O.set(dt,t.token),O.set(ht,t.activityId),O.set(ft,t.activityStatus)}I(){this.k(null),this.T(null)}k(t){if(!t)return O.remove(dt),O.remove(ht),void O.remove(ft);O.set(dt,t.token),O.set(ht,t.activityId),O.set(ft,t.activityStatus)}T(t){if(!t)return this.l=null,this.u=null,void(this.h=null);this.l=t.token,this.u=t.activityId,this.h=t.activityStatus}}const wt=[401,403,409],yt=Object.freeze({tab:80,navigation:80,visibility:80,network:80,screen:80,fingerprint:80,pointer:60,keystroke:60,autofill:60,change:60,form:60,clipboard:60,selection:60,focus:60,viewport:60,network_request:60,scroll:40,sensors:40});function vt(t){return"pointer"===t.name&&"move"===t.phase||"viewport"===t.name&&"resize"===t.type?40:yt[t.name]}const gt=new Array(256);for(let t=0;t<256;t++)gt[t]=(t+256).toString(16).slice(1);const bt=new Uint8Array(16);function kt(t){return gt[t[0]]+gt[t[1]]+gt[t[2]]+gt[t[3]]+"-"+gt[t[4]]+gt[t[5]]+"-"+gt[t[6]]+gt[t[7]]+"-"+gt[t[8]]+gt[t[9]]+"-"+gt[t[10]]+gt[t[11]]+gt[t[12]]+gt[t[13]]+gt[t[14]]+gt[t[15]]}function Tt(){return crypto.randomUUID()}function _t(){return crypto.getRandomValues(bt),bt[6]=15&bt[6]|64,bt[8]=63&bt[8]|128,kt(bt)}function It(){for(let t=0;t<16;t++)bt[t]=256*Math.random()|0;return bt[6]=15&bt[6]|64,bt[8]=63&bt[8]|128,kt(bt)}const St=function(){if("undefined"!=typeof crypto){if("function"==typeof crypto.randomUUID)return Tt;if("function"==typeof crypto.getRandomValues)return _t}return It}();function xt(){return St()}class Et{constructor(t,n){this.M=t,this.D=n,this.P=[],this.C=null,this.R=[],this.L=null,this.m=0,this.$=1,this.U=0,this.B=0,this.O=t.flush.intervalMs}push(t){if(this.m){if(this.P.length<this.q()?this.P.push(t):this.j(t),this.$)return this.P.length>=this.M.flush.size?(d(this.C),this.C=null,void this.flush("capacity")):void this.H()}else n.warn("Transport","push() called before start() — event dropped")}flush(t){if(this.m&&this.D.isActivityActive())try{if("lifecycle"===t)return void this.N();if(0===this.P.length)return;const e=this.F(t);this.D.ingest(e,0).then(t=>this.X(t,e)).catch(()=>{n.warn("Transport","ingest threw unexpectedly — batch dropped")}),this.P.length>0&&this.H()}catch(t){n.warn("Transport","flush() threw unexpectedly:",t)}}start(){this.m||(this.m=1,this.$="undefined"!=typeof navigator?navigator.onLine:1)}stop(){if(!this.m)return Promise.resolve();d(this.C),this.C=null,d(this.L),this.L=null;const t=this.N();return this.m=0,t}onConnectionChange(){const t="undefined"!=typeof navigator?navigator.onLine:1;if(t!==this.$){if(this.$=t,!this.$)return d(this.C),this.C=null,d(this.L),void(this.L=null);this.P.length>0&&this.H(),this.R.length>0&&this.K()}}H(){this.m&&this.$&&null===this.C&&(this.C=u(()=>{this.C=null,this.flush("interval")},this.O))}K(){this.m&&this.$&&null===this.L&&(this.L=u(()=>{this.L=null,this.V()},this.O))}V(){if(!this.m||!this.$||0===this.R.length||!this.D.isActivityActive())return;const t=this.R.shift();this.D.ingest(t.batch,0).then(n=>this.Y(n,t)).catch(()=>{n.warn("Transport","retry drain ingest threw unexpectedly — batch dropped"),this.R.length>0&&this.K()})}J(t,e){this.R.length>=5&&(this.R.shift(),n.warn("Transport","retry queue full — oldest batch evicted")),this.R.push({batch:t,attempts:e}),this.K()}X(t,n){t.ok?this.G():this.Z(t)&&this.J(n,1)}Y(t,e){if(t.ok)return this.G(),void(this.R.length>0&&this.K());if(this.Z(t)){if(e.attempts>=3)return this.W(),n.warn("Transport","batch dropped after MAX_RETRY_ATTEMPTS",e.batch.batchId),void(this.R.length>0&&this.K());this.W(),this.J(e.batch,e.attempts+1)}else this.R.length>0&&this.K()}W(){this.U++,this.U%this.M.flush.backoffFailureThreshold===0&&(this.O=Math.min(2*this.O,this.M.flush.maxIntervalMs))}G(){this.U=0,this.O=this.M.flush.intervalMs}q(){return this.M.queue.size*(this.$?1:2)}async N(){if(!this.D.isActivityActive())return Promise.resolve();const t=[];for(const e of this.R)t.push(this.D.ingest(e.batch,1).catch(()=>{n.warn("Transport","lifecycle retry ingest threw — batch dropped")}));if(this.R=[],this.P.length>0){const e=this.F("lifecycle");t.push(this.D.ingest(e,1).catch(()=>{n.warn("Transport","lifecycle ingest threw — batch dropped")}))}return Promise.allSettled(t).then(()=>{})}j(t){const n=vt(t);for(let e=0;e<this.P.length;e++)if(vt(this.P[e])<n){for(let t=e;t<this.P.length-1;t++)this.P[t]=this.P[t+1];return this.P.length-=1,void this.P.push(t)}}F(t){const n="lifecycle"===t?this.P.splice(-this.M.flush.size):this.P.splice(0,this.M.flush.size);return{activityId:"",batchId:xt(),batchSequence:this.B++,clientTimestamp:Date.now(),schemaVersion:"0.1.0",sdkVersion:"0.3.0",sdkPlatform:"web",tabId:this.D.getTabId(),events:n}}Z(t){if(t.ok)return 0;switch(t.kind){case"timeout":case"server":case"rate_limited":return 1;default:return 0}}}const At="tri:bcast:";const Mt="function"==typeof BroadcastChannel?BroadcastChannel:function(){if("undefined"==typeof Storage||"undefined"==typeof window)return 0;try{const t="__tri_bcast_probe__";localStorage.setItem(t,"1");const n="1"===localStorage.getItem(t);return localStorage.removeItem(t),n}catch{return 0}}()?class{constructor(t){this.seq=0,this.closed=0,this.listeners=new Set,this.onStorageEvent=t=>{if(this.closed)return;if(!t.key||!t.key.startsWith(`${At}${this.channelName}:`))return;if(null===t.newValue)return;let n;s(()=>O.remove(t.key));try{n=JSON.parse(t.newValue)}catch{return}const e={data:n};for(const t of this.listeners)s(()=>t(e))},this.channelName=t,this.senderId=xt(),window.addEventListener("storage",this.onStorageEvent)}postMessage(t){if(this.closed)return;const n=`${At}${this.channelName}:${this.senderId}:${this.seq++}`;s(()=>{O.set(n,t),O.remove(n)})}addEventListener(t,n){this.listeners.add(n)}removeEventListener(t,n){this.listeners.delete(n)}close(){this.closed||(this.closed=1,window.removeEventListener("storage",this.onStorageEvent),this.listeners.clear())}}:class{constructor(t){n.warn("BroadcastChannel","BroadcastChannel is unavailable and localStorage is not writable in this context. Cross-tab discovery is disabled; tab count will always be reported as 1.")}postMessage(t){}addEventListener(t,n){}removeEventListener(t,n){}close(){}},Dt="__tri_tabId";class Pt{constructor(t){this.context=t,this.tt="",this.m=0,this.nt=null,this.et=null,this.it=null,this.ot=new Map,this.rt=-1,this.st=null}async start(){this.m||(this.m=1,this.tt=this.ct(),this.lt(),this.ut({type:"hello",tabId:this.tt,ts:Date.now()}),this.dt(),this.ht("active"),this.ft())}stop(){this.m&&(this.m=0,this.ht("inactive"),this.ut({type:"bye",tabId:this.tt,ts:Date.now()}),this.wt(this.yt()),this.vt(),this.gt(),this.bt())}getTabId(){return this.tt}queryTabsNumber(){return this.ot.size+1}lt(){try{this.nt=new Mt("__tri_tab_channel"),this.st=this.kt.bind(this),this.nt.addEventListener("message",this.st)}catch(t){n.warn("TabManager","failed to open broadcast channel:",t)}}bt(){try{if(!this.nt)return;this.st&&this.nt.removeEventListener("message",this.st),this.nt.close()}catch{}finally{this.nt=null,this.st=null}}dt(){this.et=setInterval(()=>{const t=Date.now();this.ut({type:"heartbeat",tabId:this.tt,ts:t})},1e3)}vt(){null!=this.et&&(clearInterval(this.et),this.et=null)}ft(){null!=this.it&&clearTimeout(this.it),this.it=setTimeout(()=>{this.it=null;const t=this.yt()+1;t!==this.rt&&(this.rt=t,this.wt(t))},1e3)}gt(){null!=this.it&&(clearTimeout(this.it),this.it=null)}ut(t){try{if(!this.nt)return;this.nt.postMessage(t)}catch{n.warn("TabManager","failed to broadcast message:",t)}}kt(t){const{type:n,tabId:e}=t.data;if(e===this.tt)return;const i=Date.now();"hello"===n?(this.ut({type:"ack",tabId:this.tt,ts:i,to:e}),this.ot.set(e,i)):"heartbeat"===n||"ack"===n?this.ot.set(e,i):"bye"===n&&this.ot.delete(e)}wt(t){this.context.events.count&&this.context.push({name:"tab",type:"count",tabId:this.tt,timestamp:Date.now(),value:t})}ht(t){this.context.events.state&&this.context.push({name:"tab",type:"state",tabId:this.tt,timestamp:Date.now(),value:t})}ct(){const t=q.get(Dt);if(t)return t;const n=xt();return q.set(Dt,n),n}yt(t=Date.now()){let n=0;for(const[e,i]of this.ot.entries())t-i>=3e3?this.ot.delete(e):n++;return n}}const Ct=globalThis.CompressionStream,Rt=globalThis.Response,zt=globalThis.Blob,Lt=new TextEncoder;let $t=null;async function Ut(t){const e=await async function(t){if("function"!=typeof Ct)return null;try{const n=Lt.encode(t),e=new zt([n]).stream().pipeThrough(new Ct("gzip"));return await new Rt(e).arrayBuffer()}catch(t){return n.warn("compression","Native gzip failed:",t),null}}(t);return null!==e?e:async function(t){try{const e=await function(){if(null===$t){const t=function(t,e=1e4){let i=null;const o=new Promise(t=>{i=u(()=>{n.warn("import",`Import timed out after ${e}ms`),t(null)},e)}),r=Promise.resolve().then(t).catch(t=>(n.warn("import","Import failed:",t),null));return Promise.race([r,o]).finally(()=>{d(i)})}(()=>import("./chunks/browser-8Za96B1X.js"),1e4);$t=t,t.then(n=>{null===n&&u(()=>{$t===t&&($t=null)},1e4)})}return $t}();if(null===e)return null;const{gzipSync:i}=e,o=i(Lt.encode(t));return o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)}catch(t){return n.warn("compression","fflate gzip failed:",t),null}}(t)}function Bt(t){const n={Accept:"application/json"};return t?.hasBody&&("json"===t.contentType?n["Content-Type"]="application/json":"ndjson"===t.contentType&&(n["Content-Type"]="application/x-ndjson"),"gzip"===t.contentEncoding&&(n["Content-Encoding"]="gzip")),t?.token&&(n.Authorization=`Bearer ${t.token}`),t?.profileId&&(n["x-profile-id"]=t.profileId),t?.api?.version&&(n["x-api-version"]=t.api.version),t?.customHeaders&&Object.entries(t.customHeaders).forEach(([t,e])=>{n[t]=e}),n}const Ot="function"==typeof globalThis.fetch?globalThis.fetch.bind(globalThis):void 0;class qt{constructor(t){this.context=t}stop(){}async report(t,e){const i={name:t,metadata:e,timestamp:Date.now(),activityId:this.context.getActivityId()??""};try{const o=await this.context.reportEvent(i);if(o.ok)return o;n.warn("EventReport","Failed to report event:",t,e,"with result:",o)}catch(i){n.warn("EventReport","Failed to report event:",t,e,"with error:",i)}}}const jt=new Set(["A","BUTTON","INPUT","SELECT","TEXTAREA","SUMMARY","DETAILS","LABEL","OPTION","FIELDSET"]),Ht=new Set(["button","link","tab","menuitem","menuitemcheckbox","menuitemradio","checkbox","radio","switch","slider","spinbutton","combobox","listbox","option","searchbox","textbox","treeitem"]),Nt=255;function Ft(t,n,e){const i=t.tagName.toLowerCase(),o=function(t){const n=t.parentElement?.children??[],e=Math.min(n.length,1e3);let i=e-1,o=0,r=0;for(let i=0;i<e;i++){r++;const e=n[i];if(g(e,t.tagName)&&o++,e===t)break}return{siblings:i,ofType:o,child:r}}(t),r=function(t,n){const e=function(t){if(!t)return null;const n=t.getAttribute("data-tri-redact-attrs");return n?n.split(",").map(t=>t.trim().toLowerCase()):null}(t),i={},o=t.id;o&&!_("id",e)&&(i.id=o);const r=t.getAttribute("autocomplete");r&&!_("autocomplete",e)&&(i.autocomplete=r);const s=t.getAttribute("aria-invalid");s&&!_("aria-invalid",e)&&(i.ariaInvalid=s);const c=t.getAttribute("tabindex");c&&!_("tabindex",e)&&(i.tabIndex=parseInt(c,10));const a=function(t){return t.getAttribute("data-testid")??t.getAttribute("data-cy")??null}(t);a&&!_("data-testid",e)&&(i.testId=a);const l=t.hasAttribute("readonly");l&&!_("readonly",e)&&(i.readOnly=l);const u=t.hasAttribute("required");u&&!_("required",e)&&(i.required=u);const d=t.getAttribute("contenteditable");d&&!_("contenteditable",e)&&(i.contentEditable="true"===d||""===d);const h=t.getAttribute("href");h&&!_("href",e)&&(i.href={...n?{}:{url:h},external:I(h)});const f=t.getAttribute("role");f&&!_("role",e)&&(i.role=f);const p=t.getAttribute("type");p&&!_("type",e)&&(i.type=p);const m=t.getAttribute("name");m&&!_("name",e)&&(i.name=m);const w=t.getAttribute("placeholder");!w||n||_("placeholder",e)||(i.placeholder=w);const y=Array.from(t.classList).slice(0,5);y.length>0&&!_("class",e)&&(i.classes=y);const v=t.getAttribute("alt");return!v||n||_("alt",e)||(i.alt=v),Object.keys(i).length?i:null}(t,n);return{tagName:i,frame:e,...r?{attributes:r}:{},...o?{nth:o}:{}}}function Xt(t,n){let e=0;const i=[];return function(t){return jt.has(t.tagName)}(t)&&(e+=40,i.push("native")),function(t){return t.hasAttribute("data-tri-interactive")}(t)&&(e+=40,i.push("tri-interactive")),function(t){return g(t,"a")&&t.hasAttribute("href")}(t)&&(e+=15,i.push("has-href")),function(t){const n=t.getAttribute("role");return null!==n&&Ht.has(n)}(t)&&(e+=30,i.push("role")),function(t){return t.hasAttribute("onclick")||t.hasAttribute("ng-click")||t.hasAttribute("data-action")||t.hasAttribute("@click")}(t)&&(e+=20,i.push("click-handler")),function(t){const n=t.getAttribute("tabindex");if(null===n)return 0;const e=parseInt(n,10);return null!==e&&e>=0}(t)&&(e+=10,i.push("tabindex")),(t.id||t.getAttribute("data-testid"))&&(e+=5,i.push("has-id")),n>0&&(e+=Math.round(15/n),i.push("depth")),{score:e,reasons:i}}function Kt(t){return t>=20}function Vt(t){return null!==t&&t.width>0&&t.height>0&&t.y<window.innerHeight&&t.y+t.height>0&&t.x<window.innerWidth&&t.x+t.width>0}function Yt(t){return 1==t.disabled||"true"===t.getAttribute("aria-disabled")}function Jt(t,n=0){if(n)return null;const e=Zt(t,"labelledby");if(e)return{text:Wt(e),resolutionMethod:"aria-labelledby",confidence:"high"};const i=Qt(t);if(i)return{text:Wt(i),resolutionMethod:"aria-label",confidence:"high"};const o=function(t){if(!t.id)return null;const n=document.querySelector(`label[for="${CSS.escape(t.id)}"]`);return n?Gt(n):null}(t);if(o)return{text:Wt(o),resolutionMethod:"html-for",confidence:"high"};const r=function(t){const n=t.closest("label");return n?Gt(n):null}(t);if(r)return{text:Wt(r),resolutionMethod:"wrapping-label",confidence:"high"};const s=function(t){const n=t.getAttribute("placeholder");return n?.trim()??null}(t);if(s)return{text:Wt(s),resolutionMethod:"placeholder",confidence:"low"};const c=function(t){const n=t.getAttribute("title");return n?.trim()??null}(t);if(c)return{text:Wt(c),resolutionMethod:"title",confidence:"low"};const a=Zt(t,"describedby");if(a)return{text:Wt(a),resolutionMethod:"aria-describedby",confidence:"low"};const l=Gt(t);return l?{text:l,resolutionMethod:"text-content",confidence:"low"}:null}function Gt(t,n=0){if(n>8)return"";if(v(t))return function(t){return t?t.trim().split(/(\s+)/).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,Nt):null}(t.textContent)??"";if(!t.childNodes?.length)return"";let e="";for(const i of t.childNodes){const t=Gt(i,n+1);if(t&&(e=e?`${e} ${t}`:t,e.length>=Nt))break}return Wt(e)}function Zt(t,n){const e="labelledby"===n?"aria-labelledby":"aria-describedby",i=t?.getAttribute(e);if(!i)return null;const o=i.split(/\s+/),r=[];for(const t of o){const n=document.getElementById(t);if(!n)continue;const e=Qt(n)??Gt(n);e.length&&r.push(e)}return r.length?r.join(" "):null}function Qt(t){return t?.getAttribute("aria-label")?.trim()??null}function Wt(t){return t.length>Nt?t.slice(0,Nt)+"...":t}function tn(t){const n=t.getBoundingClientRect();return{x:n.x,y:n.y,width:n.width,height:n.height}}class nn{constructor(t){this.capacity=t,this.cache=new Map}get(t){return this.cache.get(t)}set(t,n){if(this.cache.has(t))this.cache.delete(t);else if(this.cache.size>=this.capacity){const t=this.cache.keys().next().value;t&&this.cache.delete(t)}this.cache.set(t,n)}delete(t){this.cache.delete(t)}clear(){this.cache.clear()}size(){return this.cache.size}}async function en(t,o){const{collectors:r,sdk:s}=t;let c=null,l=null,h=null,f=null;try{c=function(t){"undefined"!=typeof document&&"function"==typeof globalThis.fetch||n.warn("FalconService","createFalconServiceManager called in a non-browser environment — all requests will resolve with { ok: false, kind: 'network' }.");const e=function(t){const n=t?.timeout,e=t?.baseUrl??"",i=t?.api;async function o(t,o,r){if(void 0===Ot)return{ok:0,kind:"network"};const s=e?`${e}${o}`:o,c=new AbortController;let a=null,l=0;a=u(()=>{l=1,c.abort()},n);const h=r?.signal;let f,p=()=>{};if(h)if(h.aborted)c.abort();else{const t=()=>c.abort();h.addEventListener("abort",t,{once:1}),p=()=>h.removeEventListener("abort",t)}if(null!=r&&"body"in r&&null!=r.body){const t=function(t){if(null==t)return{ok:1,body:void 0};if("string"==typeof t||t instanceof ArrayBuffer||ArrayBuffer.isView(t)||t instanceof Blob||t instanceof FormData||t instanceof URLSearchParams||t instanceof ReadableStream)return{ok:1,body:t};try{return{ok:1,body:JSON.stringify(t)}}catch{return{ok:0}}}(r.body);if(!t.ok)return d(a),p(),{ok:0,kind:"serialize"};f=t.body}try{const n=await Ot(s,{method:t,headers:Bt({token:r?.token,profileId:r?.profileId,contentType:r?.contentType,contentEncoding:r?.contentEncoding,api:i,hasBody:void 0!==f,customHeaders:r?.customHeaders}),body:f,signal:c.signal,keepalive:r?.keepalive});if(!n.ok)return 429===(m=n.status)?{ok:0,kind:"rate_limited",status:m}:m>=400&&m<500?{ok:0,kind:"client",status:m}:{ok:0,kind:"server",status:m};if(204===n.status)return{ok:1,data:void 0,status:204};try{return{ok:1,data:await n.json(),status:n.status}}catch{return c.signal.aborted?l?{ok:0,kind:"timeout"}:{ok:0,kind:"abort"}:{ok:0,kind:"parse",status:n.status}}}catch{return l?{ok:0,kind:"timeout"}:c.signal.aborted?{ok:0,kind:"abort"}:{ok:0,kind:"network"}}finally{d(a),p()}var m}return{post:async function(t,n){return o("POST",t,n)},get:async function(t,n){return o("GET",t,n)}}}({baseUrl:`${t.api.url}/api/v1`,timeout:1e4,api:{version:t.api.version}}),i=function(t){const{getToken:e,refresh:i}=t;let o=null;return{withAuth:async function(t,r){if(o){const n=await o;if(n)return t(n)}const s=e()??"",c=await t(s);if((a=c).ok||"client"!==a.kind||!wt.includes(a.status)||0==r?.refreshable)return c;var a;const l=await(o||(o=async function(){try{return await i(),e()}catch(t){return n.warn("AuthMiddleware","auth refresh failed",t),null}}().finally(()=>{o=null}),o));return l&&l!==s?t(l):c}}}(t),o=()=>({profileId:t.getProfileId()??void 0});return{api:{ingest:async function(n,r){return i.withAuth(async i=>{const{events:s,...c}=n,a={...c,activityId:t.getActivityId()};let l;try{l=await async function(t,n){const e=function(t,n){const e=[JSON.stringify(t)];for(let t=0;t<n.length;t++)try{e.push(JSON.stringify(n[t]))}catch{}return e.join("\n")}(t,n),i=await Ut(e);return i?{type:"gzip",body:i}:{type:"ndjson",body:e}}(a,s)}catch{return{ok:0,kind:"serialize"}}return e.post("/events/capture",{body:l.body,token:i,keepalive:r,contentType:"ndjson",contentEncoding:"gzip"===l.type?"gzip":void 0,...o()})},{refreshable:!r})},reportEvent:async function(t){return i.withAuth(n=>e.post("/events/report-event",{body:t,token:n,contentType:"json",...o()}))},startActivity:async function(){return e.post("/events/start-activity",{token:t.getSdkToken(),...o()})},stopActivity:async function(){return i.withAuth(t=>e.post("/events/end-activity",{token:t,keepalive:1,...o()}),{refreshable:0})},collectionStatus:async function(){return e.get("/sdk/collection-status",{token:t.getSdkToken(),...o()})},linkInterview:async function(t){return i.withAuth(n=>e.post("/events/link-interview",{token:n,contentType:"json",...o(),customHeaders:{"X-Incode-Hardware-Id":t}}))}}}}({api:{version:s.api.version,url:s.api.url},getSdkToken:()=>s.token,getProfileId:()=>o.getProfileId(),getToken:()=>l?.getToken()??null,refresh:async()=>l?.refresh()??Promise.resolve(),getActivityId:()=>l?.getActivityId()??""});const t=await c.api.collectionStatus();if(!t.ok||1!=t.data.eventsCollectionEnabled)return{status:"collection-disabled"};l=new mt({startActivity:()=>c.api.startActivity(),stopActivity:()=>c.api.stopActivity()}),h=new Et(et,{ingest:(t,n)=>c.api.ingest(t,n),getTabId:()=>f?.getTabId()??"unknown",isActivityActive:()=>l?.isActive()??0});const p=r.tab;f=new Pt({push:t=>h?.push(t),events:{state:p.enabled&&p.events.state.enabled,count:p.enabled&&p.events.count.enabled}});const m=function(t){function n(n){"hidden"===document.visibilityState&&t.flush()}function o(n){t.flush(),t.stopTab(),t.getShouldSkipStopActivity()||t.stopActivity()}const r=a(()=>t.onConnectionChange());return{start:function(){e(document,"visibilitychange",n),e(window,"pagehide",o),e(window,"online",r),e(window,"offline",r)},stop:function(){i(document,"visibilitychange",n),i(window,"pagehide",o),i(window,"online",r),i(window,"offline",r)}}}({flush:()=>h?.flush("lifecycle"),stopActivity:async()=>l?.stop(),stopTab:()=>f?.stop(),getShouldSkipStopActivity:()=>(f?.queryTabsNumber()??0)>1,onConnectionChange:()=>h?.onConnectionChange()}),w=function(t){const n=t||"redact",e=new nn(6),i=new nn(6);return{resolve:function(t){if(!t||k(t)||"off"===n)return null;let o=e.get(t);if(o||(o=function(t){if(!t||k(t))return{chain:[],redaction:{level:"ignore",index:-1}};const n=[];let e=t,i=-1;for(;e;){if(k(e))return{chain:[],redaction:{level:"ignore",index:-1}};T(e)&&(i=n.length),n.push(e);const t=e.parentNode;if(!t||g(e,"body"))break;e=b(t)?t.host:t}return{chain:n,redaction:{level:-1===i?"full":"redact",index:i}}}(t.parentElement),e.set(t,o)),"ignore"===o.redaction.level)return null;const r="redact"===o.redaction.level||"redact"===n||T(t);let s=i.get(t);return s||(s=function(t,n,e,i){const o=getComputedStyle(t),r=tn(t),s=function(t,n){const e=[],i=[];for(let o=t.length-1;o>=0;o--){const r=t[o],s=o<=n,c=o+1,a=Ft(r,s,tn(r)),{score:l,reasons:u}=Xt(r,c);if(e.push(a),!Kt(l))continue;const d=Jt(r,s);i.push({...a,...d?{label:d}:{},depth:c,score:l,reasons:u})}return{ancestors:e,interactiveCandidates:i.reverse()}}(n,i),c=Ft(t,e,r),a=function(t,n,e){const{score:i,reasons:o}=Xt(t,0);return{interactive:Kt(i),...o.length>0?{reasons:o}:{},disabled:Yt(t),rendered:"none"!==n?.display,visible:"hidden"!==n?.visibility,inViewport:Vt(e),acceptsPointer:"none"!==n?.pointerEvents,opacity:parseFloat(n?.opacity||"1")}}(t,o,r);let l=null;return e||(l=a.interactive?Jt(t):null),{tagName:c.tagName,frame:c.frame,viewport:{height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio},attributes:c.attributes,nth:c.nth,...l?{label:l}:{},ancestors:s.ancestors,interactiveCandidates:s.interactiveCandidates,interactivity:a}}(t,o.chain,r,o.redaction.index),i.set(t,s)),s}}}(s.capture?.element),y=new Set;try{y.add(new URL(s.api.url).origin)}catch{}const v=function(t,n,e="on"){const i=new Map;function o(o){if(i.has(o))return;const r=Q[o];if(!r||!function(t,n){return n[t]?.enabled??0}(o,n))return;const s=n[o],c=r.create(t,e,s&&"events"in s?s.events:void 0);i.set(o,c)}return{start:o,stopCollector:function(t){const n=i.get(t);n&&(n(),i.delete(t))},stop:function(){for(const[,t]of i)t();i.clear()},isRunning:function(t){return i.has(t)},autocapture:function(){for(const t of W)o(t)}}}({push:t=>h?.push(t),resolveElement:t=>w.resolve(t),sanitizeUrl:s.sanitizeUrl,ignoredOrigins:y},r,s.capture?.content),_=new qt({getActivityId:()=>l?.getActivityId()??"",reportEvent:t=>c.api.reportEvent(t)});return{status:"ready",managers:{falconServiceManager:c,activityManager:l,transportManager:h,tabManager:f,lifecycleManager:m,collectorManager:v,eventReportManager:_}}}catch(t){return n.warn("IncodeTRI","setup() failed during construction:",t),{status:"init-failed"}}}let on=class t{constructor(){this.Tt=0,this.M=null,this._t=null,this.It="idle"}static get instance(){return t.i||(t.i=new t),t.i}async setup(t){if("idle"!==this.It)return n.fatal("error","setup()","called more than once — ignoring."),"init-failed";try{const e=function(t){if("undefined"==typeof document)return n.fatal("error","IncodeTRI","TRI is not available in a non-browser environment."),null;if(!t?.token)return n.fatal("error","SDK","token is required."),null;if(!t.apiURL)return n.fatal("error","SDK","Couldn't initialise SDK — apiURL isn't provided."),null;const{element:e,content:i}=t.capture??{},o={token:t.token,capture:{element:e??"redact",content:i??"off"},profileId:t.profileId,api:{version:t.apiVersion??"1.0",url:t.apiURL},sanitizeUrl:(r=t.sanitizeUrl,r?function(t){return s(()=>r(t,nt))??nt(t)}:nt),DEBUG:t.DEBUG??0};var r;return void 0===t.collectors&&void 0===t.layers?{sdk:o,collectors:it()}:void 0!==t.collectors?{sdk:o,collectors:rt(t.collectors)}:{sdk:o,collectors:ot(t.layers)}}(t);if(!e)return"init-failed";n.DEBUG=e.sdk.DEBUG;const i=await en(e,{getProfileId:()=>this.St()});return"collection-disabled"===i.status?(n.fatal("warn","setup()","Collection is disabled for the provided API Key."),"collection-disabled"):"init-failed"===i.status?"init-failed":(this.M=e,this._t=i.managers,this.It="ready",this.xt(e.sdk.profileId),"ready")}catch(t){return n.warn("setup()","failed:",t),"init-failed"}}async start(){if("idle"===this.It)return n.warn("start()","start() requires a prior successful setup() — ignoring."),this.It;if("ready"!==this.It)return n.fatal("warn","start()","TRI is either already started or isn't ready — ignoring."),this.It;this.It="starting";const t=++this.Tt;return await this.v(t),this.It}async stop(){n.warn("stop()","called");const t=this._t;return t?(++this.Tt,t.lifecycleManager.stop(),t.collectorManager.stop(),t.tabManager.stop(),t.eventReportManager.stop(),this.It="ready",this.Et(t)):Promise.resolve(this.It)}async reset(){const t=this.stop();return this.It="idle",this.M=null,this._t=null,O.remove("__tri_profile_id"),t.then(()=>this.It)}async Et(t){return await function(t){let n=null;const e=new Promise(t=>{n=u(t,2e3)});return Promise.race([t.finally(()=>d(n)),e])}(Promise.resolve(t.transportManager.stop())),await t.activityManager.stop(),this.It}reportEvent(t,e){"started"===this.It?this._t?c(()=>this._t.eventReportManager.report(t,e)):n.warn("reportEvent()","reportEvent() called but managers are unavailable — dropping event."):n.warn("reportEvent()","reportEvent() called before start() completed — dropping event.")}setProfileId(t){"started"===this.It?this.M?.sdk&&(this.M.sdk.profileId=t,this.xt(t)):n.warn("setProfileId()","setProfileId() called before start() completed — ignoring.")}async linkInterview(t){if("started"!==this.It||!this._t)return n.warn("linkInterview()","linkInterview() called before start() completed — ignoring."),0;if(!t)return n.warn("linkInterview()","linkInterview() called without sessionToken — ignoring."),0;try{return(await this._t.falconServiceManager.api.linkInterview(t)).ok}catch(t){return n.warn("linkInterview()","failed:",t),0}}St(){return this.M?.sdk?.profileId??O.get("__tri_profile_id")??null}xt(t){t&&O.set("__tri_profile_id",t)}async v(t){const e=this._t;if(e){try{if(await e.activityManager.start(),t!==this.Tt)return;if(e.transportManager.start(),await e.tabManager.start(),t!==this.Tt)return;e.lifecycleManager.start(),e.collectorManager.autocapture()}catch(e){return n.warn("start()","failed during monitoring start:",e),void(t===this.Tt&&(this.It="ready"))}t===this.Tt&&(this.It="started")}}};async function rn(t,n){const e=n?.apiURL??"https://falcon-ingest-k8s.stage.incodetest.com",i=n?.timeout??1e4,o=new AbortController;let r=null,s=0,c=()=>{};i&&(r=u(()=>{s=1,o.abort()},i));const a=n?.signal;if(a)if(a.aborted)o.abort();else{const t=()=>o.abort();a.addEventListener("abort",t,{once:1}),c=()=>a.removeEventListener("abort",t)}try{const n=await fetch(`${e}/api/v1/sdk/init`,{method:"POST",headers:{"content-type":"application/json","x-api-key":t,"x-api-version":"1.0"},signal:o.signal});if(!n.ok){let t=n.statusText;try{const e=await n.json();e.errorMessage&&(t=e.errorMessage)}catch{}return{token:null,eventsCollectionEnabled:0,error:{status:n.status,message:t}}}return await n.json()}catch(t){throw new Error((s?"[TRI] createSession timed out":"[TRI] Failed to create session:")+" "+t.message)}finally{d(r),c()}}on.i=null;const sn=on.instance;export{rn as createSession,sn as default};
|
|
1
|
+
class t{constructor(){this.t=0}static get instance(){return t.i||(t.i=new t),t.i}get DEBUG(){return this.t}set DEBUG(t){this.t=t}warn(t,n,...e){this.t&&this.o("warn",t,n,...e)}error(t,n,...e){this.t&&this.o("error",t,n,...e)}info(t,n,...e){this.t&&this.o("info",t,n,...e)}fatal(t,n,e,...i){this.o(t,n,e,...i)}o(t,n,e,...i){const o=n?`[${n}]`:"",r=console?.[t];r&&r(`[IncodeTRI]${o} ${e}`,...i)}}const n=t.instance;function e(t,n,e){let i=t,o=n;if("devicepixelratiochange"===n){const t=window.devicePixelRatio;i=window.matchMedia(`(resolution: ${t}dppx)`),o="change"}i.addEventListener(o,e,{capture:1,passive:1})}function i(t,n,e){let i=t,o=n;if("devicepixelratiochange"===n){const t=window.devicePixelRatio;i=window.matchMedia(`(resolution: ${t}dppx)`),o="change"}i.removeEventListener(o,e,{capture:1})}const o=globalThis.setTimeout.bind(globalThis),r=globalThis.clearTimeout.bind(globalThis);function s(t,e){try{return t()}catch(t){n.warn("utils","safeSync swallowed error:",t)}}async function c(t){try{return await t()}catch(t){n.warn("utils","safeAsync swallowed error:",t)}}function a(t){return n=>s(()=>t(n))}function l(t){return(...e)=>{try{t(...e)}catch(t){n.warn("utils","safeTimer swallowed error:",t)}}}function u(t,n){return o(l(t),n)}function d(t){if(null!==t)try{r(t)}catch(t){n.warn("utils","safeClearTimeout swallowed error:",t)}}const h=new Set(["xmlhttprequest","fetch","beacon","navigation","script","link","css","img","iframe","video","audio"]),f=new Set(["xmlhttprequest","fetch","beacon"]);function p(t,n){return n?t:null}function m(t,n){const e=t,i=t.responseStart>0,o=p(t.domainLookupEnd-t.domainLookupStart,i),r=p(t.connectEnd-t.connectStart,i),s=p(t.connectEnd>0&&t.secureConnectionStart>0?t.connectEnd-t.secureConnectionStart:0,i),c=p(t.responseStart-t.requestStart,i),a=p(t.responseEnd-t.responseStart,i),l=i?t.transferSize:null,u=i?t.encodedBodySize:null,d=i?t.decodedBodySize:null,f=i&&t.nextHopProtocol||null,m=i&&void 0!==e.deliveryType?e.deliveryType:null,w=e.responseStatus,y=void 0!==w&&0!==w?w:null;return{name:"network_request",timestamp:Date.now(),performanceTime:t.startTime+t.duration,url:n(t.name),initiatorType:(v=t.initiatorType,h.has(v)?v:"other"),startTime:t.startTime,durationMs:t.duration,dnsLookupMs:o,tcpConnectMs:r,tlsHandshakeMs:s,ttfbMs:c,responseDownloadMs:a,transferSize:l,encodedBodySize:u,decodedBodySize:d,nextHopProtocol:f,deliveryType:m,responseStatus:y};var v}function w(){}const y=2e3;function v(t){return!!t&&t.nodeType===Node.TEXT_NODE}function g(t,n){return t.tagName?.toLowerCase()===n.toLowerCase()}function b(t){return!!t&&t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function k(t){return t?t.hasAttribute("data-tri-ignore"):0}function T(t){return t?t.hasAttribute("data-tri-redact"):0}function _(t,n){return n?.includes(t.toLowerCase())??0}function I(t){try{return new URL(t).origin!==window.location.origin}catch{return 0}}function S(t,n){return t?t[n]?.enabled??0:1}function x(){const t=document.activeElement;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement){const n=t.selectionStart,e=t.selectionEnd;return null==n||null==e||n===e?null:t.value.substring(n,e)}const n=window.getSelection();return!n||n.isCollapsed?null:n.toString()||null}function E(t,n){return"off"===n||k(t)||T(t)?0:1}function A(t){const n=document.activeElement;if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)return n;const e=window.getSelection();return(i=("start"===t?e?.anchorNode:e?.focusNode)??null)?v(i)?i.parentElement:i instanceof Element?i:null:null;var i}function M(){const t=window,n="__fpjs_p_l_b",e=t[n];if(function(t,n){var e;const i=null===(e=Object.getOwnPropertyDescriptor)||void 0===e?void 0:e.call(Object,t,n);(null==i?void 0:i.configurable)?delete t[n]:i&&!i.writable||(t[n]=void 0)}(t,n),"function"!=typeof(null==e?void 0:e.load))throw new Error($);return e}const D="Blocked by CSP",P="The endpoint parameter is not a valid URL";function C(t){return function(t,n){const e=document,i="securitypolicyviolation";let o;const r=n=>{const e=new URL(t,location.href),{blockedURI:i}=n;i!==e.href&&i!==e.protocol.slice(0,-1)&&i!==e.origin||(o=n,s())};e.addEventListener(i,r);const s=()=>e.removeEventListener(i,r);return Promise.resolve().then(n).then(t=>(s(),t),t=>new Promise(t=>{const n=new MessageChannel;n.port1.onmessage=()=>t(),n.port2.postMessage(null)}).then(()=>{if(s(),o)return(()=>{throw new Error(D)})();throw t}))}(t,()=>function(t){return new Promise((n,e)=>{if(function(t){if(URL.prototype)try{return new URL(t,location.href),0}catch(t){if(t instanceof Error&&"TypeError"===t.name)return 1;throw t}}(t))throw new Error(P);const i=document.createElement("script"),o=()=>{var t;return null===(t=i.parentNode)||void 0===t?void 0:t.removeChild(i)},r=document.head||document.getElementsByTagName("head")[0];i.onload=()=>{o(),n()},i.onerror=()=>{o(),e(new Error(L))},i.async=1,i.src=t,r.appendChild(i)})}(t)).then(M)}const R="API key required";var z="3.12.9";const L="Failed to load the JS script of the agent",$="9319",U={scriptUrl:"https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js"};function B(t){function n(){return globalThis.window&&globalThis.window[t]&&void 0!==globalThis.window[t]}return{get:function(e){if(!n())return null;try{const n=window[t].getItem(e)??"null";return"null"===n?null:JSON.parse(n)}catch{return null}},set:function(e,i){n()&&s(()=>window[t].setItem(e,JSON.stringify(i)))},remove:function(e){n()&&s(()=>window[t].removeItem(e))},key:function(e){return n()?window[t].key(e):null},get length(){return n()?window[t].length:0}}}const O=B("localStorage"),q=B("sessionStorage"),j="__tri_fingerprint";let H=null,N=null;async function F(t){try{const n=await function(t){return H||(H=function(t){var n,e;const{picked:i,rest:o}=function(t,n){const e={},i={};for(const[o,r]of Object.entries(t))n.includes(o)?e[o]=r:i[o]=r;return{picked:e,rest:i}}(t,["scriptUrlPattern","token","apiKey"]),r=null!==(n=i.apiKey)&&void 0!==n?n:i.token,s=null!==(e=function(t,n){return function(t,n){return Object.prototype.hasOwnProperty.call(t,n)}(t,n)?t[n]:void 0}(t,"scriptUrlPattern"))&&void 0!==e?e:U.scriptUrl,[c,a]=function(){const t=[],n=()=>{t.push({time:new Date,state:document.visibilityState})},e=((i=document).addEventListener("visibilitychange",o=n,r),()=>i.removeEventListener("visibilitychange",o,r));var i,o,r;return n(),[t,e]}();return Promise.resolve().then(()=>{if(!r||"string"!=typeof r)throw new Error(R);return function(t,n){const e=[],[i,o]=function(t){const n=function(t){const n=[...t];return{current:()=>n[0],postpone(){const t=n.shift();void 0!==t&&n.push(t)},exclude(){n.shift()}}}(t),e=function(){let t=0;return()=>Math.random()*Math.min(3e3,100*Math.pow(2,t++))}(),i=new Set;return[n.current(),(t,o)=>{let r;const s=o instanceof Error?o.message:"";if(s===D||s===P)n.exclude(),r=0;else if(s===$)n.exclude();else if(s===L){const e=Date.now()-t.getTime()<50,o=n.current();o&&e&&!i.has(o)&&(i.add(o),r=0),n.postpone()}else n.postpone();const c=n.current();return void 0===c?void 0:[c,null!=r?r:t.getTime()+e()-Date.now()]}]}(t);let r;if(void 0===i)return Promise.reject(new TypeError("The list of script URL patterns is empty"));const s=t=>{const i=new Date,c=n=>e.push({url:t,startedAt:i,finishedAt:new Date,error:n}),a=n(t);return a.then(()=>c(),c),a.catch(t=>{if(null!=r||(r=t),e.length>=5)throw r;const n=o(i,t);if(!n)throw r;const[c,a]=n;return(l=a,new Promise(t=>setTimeout(t,l))).then(()=>s(c));var l})};return s(i).then(t=>[t,e])}(function(t,n){return(Array.isArray(t)?t:[t]).map(t=>function(t,n){const e=encodeURIComponent;return t.replace(/<[^<>]+>/g,t=>"<version>"===t?"3":"<apiKey>"===t?e(n):"<loaderVersion>"===t?e(z):t)}(String(t),n))}(s,r),C)}).catch(t=>{throw a(),function(t){return t instanceof Error&&t.message===$?new Error(L):t}(t)}).then(([t,n])=>(a(),t.load({...o,ldi:{attempts:n,visibilityStates:c}})))}({apiKey:t.apiKey,region:t.region,endpoint:t.endpoint,scriptUrlPattern:t.scriptUrlPattern}).catch(t=>{throw H=null,t}),H)}(t),e=await n.get({timeout:t.timeoutMs,extendedResult:1});if(!e.visitorId)return null;const i=t.cacheTtlMs??2592e6;return i>0&&function(t,n,e){const i={visitorId:t,requestId:n,expiresAt:Date.now()+e};O.set(j,i)}(e.visitorId,e.requestId,i),{visitorId:e.visitorId,requestId:e.requestId}}catch{return null}}const X={apiKey:"5uYRiI0XM6p8k4124ELX",endpoint:"https://fingerprint.incodesmile.com",scriptUrlPattern:"https://fingerprint.incodesmile.com/web/v<version>/<apiKey>/loader_v<loaderVersion>.js"},K={focusin:"in",focusout:"out"};function V(t){return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement}const Y=new Set(["Shift","Control","Alt","Meta","Backspace","Delete","Enter","Tab","CapsLock","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]),J={mouse:"mouse",touch:"touch",pen:"pen"},G={pointerdown:"down",pointerup:"up",click:"click",dblclick:"dblclick",contextmenu:"contextmenu"};function Z(t,n,e,i,o){return{name:"navigation",timestamp:Date.now(),phase:t,type:n,from:e.from,to:e.to,timeOrigin:i,timing:o}}const Q={fingerprint:{create:function(t){let n=0;return c(async()=>{const e=await async function(t){const n=function(){const t=O.get(j);return t?"string"!=typeof t.visitorId||"number"!=typeof t.expiresAt||t.expiresAt<=Date.now()?(O.remove(j),null):{visitorId:t.visitorId,requestId:"string"==typeof t.requestId?t.requestId:""}:null}();return n?{visitorId:n.visitorId,requestId:n.requestId||null}:N||(N=F(t).finally(()=>{N=null}),N)}(X);!n&&e&&t.push({name:"fingerprint",deviceId:e.visitorId,requestId:e.requestId,timestamp:Date.now()})}),()=>{n=1}},layer:"device-fingerprinting"},pointer:{create:function(t,n,o){const r=a(n=>{const e=function(n){const e=n,i=function(t){if("mouse"===t.pointerType)return{button:t.button,buttons:t.buttons};const n={force:t.pressure,contact:Math.min(t.width,t.height)};return"pen"===t.pointerType&&(n.tiltX=t.tiltX,n.tiltY=t.tiltY,n.twist=t.twist),n}(e);return{id:e.pointerId,name:"pointer",timestamp:Date.now(),type:J[e.pointerType]??"unknown",phase:G[n.type],isTrusted:e.isTrusted,element:t.resolveElement(e.target),isPrimary:e.isPrimary,modifiers:{shift:e.shiftKey,ctrl:e.ctrlKey,alt:e.altKey,meta:e.metaKey},coordinates:{x:e.clientX,y:e.clientY},...i}}(n);t.push(e)});return S(o,"pointer")&&(e(document,"pointerdown",r),e(document,"pointerup",r)),S(o,"click")&&e(document,"click",r),S(o,"dblclick")&&e(document,"dblclick",r),S(o,"contextmenu")&&e(document,"contextmenu",r),()=>{i(document,"pointerdown",r),i(document,"pointerup",r),i(document,"click",r),i(document,"dblclick",r),i(document,"contextmenu",r)}},layer:"behavioral",events:["pointer","click","dblclick","contextmenu"]},pointermove:{create:function(t){let n=null,o=null;const r=a(e=>{const i=e;return n&&n.id!==i.pointerId&&(t.push(n),n=null),n?n.samples.ts.length>=50?(t.push(n),n=s(i),void c(t)):(n.samples.x.push(i.clientX),n.samples.y.push(i.clientY),n.samples.ts.push(i.timeStamp),"pen"===i.pointerType&&(n.samples.tiltX?.push(i.tiltX),n.samples.tiltY?.push(i.tiltY)),"mouse"!==i.pointerType&&(n.samples.force?.push(i.pressure),n.samples.radius?.push(Math.max(i.width,i.height))),void c(t)):(n=s(i),void c(t))});function s(t){const n=function(t){if("mouse"===t.pointerType)return null;const n={force:[t.pressure],radius:[Math.max(t.width,t.height)]};return"pen"===t.pointerType&&(n.tiltX=[t.tiltX],n.tiltY=[t.tiltY]),n}(t);return{name:"pointer",timestamp:Date.now(),id:t.pointerId,type:t.pointerType,phase:"move",isTrusted:t.isTrusted,isPrimary:t.isPrimary,samples:{x:[t.clientX],y:[t.clientY],ts:[t.timeStamp],...n??{}}}}function c(t){o&&clearTimeout(o),o=setTimeout(()=>{n&&(t.push(n),n=null),o=null},y)}return e(document,"pointermove",r),()=>{i(document,"pointermove",r),o&&(clearTimeout(o),o=null),n&&(t.push(n),n=null)}},layer:"behavioral"},focus:{create:function(t){const n=a(n=>{const e=function(n){const e=n;return{name:"focus",type:K[n.type]??"unknown",timestamp:Date.now(),isTrusted:e.isTrusted,element:t.resolveElement(e.target),relatedTarget:t.resolveElement(e.relatedTarget)}}(n);t.push(e)});return e(document,"focusin",n),e(document,"focusout",n),()=>{i(document,"focusin",n),i(document,"focusout",n)}},layer:"behavioral"},input:{create:function(t){const n=a(n=>{const e=n;t.push(function(n){return{name:"keystroke",type:"input",timestamp:Date.now(),isTrusted:n.isTrusted,element:t.resolveElement(n.target),inputType:n.inputType??"",isComposing:n.isComposing??0,length:(e=n.target,e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement?e.value.length:0)};var e}(e)),function(t){if("insertReplacementText"===t.inputType)return 1;const n=t.target;return V(n)?function(t){try{return t.matches(":-webkit-autofill")}catch{return 0}}(n):0}(e)&&t.push(function(t,n){const e=t.target;let i=0;return V(e)&&(i=e.value.length),{name:"autofill",timestamp:Date.now(),element:n.resolveElement(e),length:i}}(e,t))});return e(document,"input",n),function(){i(document,"input",n)}},layer:"behavioral"},keystroke:{create:function(t){const{resolve:n,reset:o}=function(){let t=0;const n=new Map;return{resolve:function(e,i){if("keydown"===i){const i=n.get(e);if(void 0!==i)return i;const o=++t;if(n.size>=32){const t=n.keys().next().value;void 0!==t&&n.delete(t)}return n.set(e,o),o}const o=n.get(e);return void 0!==o?(n.delete(e),o):++t},reset:function(){n.clear()}}}(),r=a(e=>{const i=function(t){const e=t,i=t.type;return{name:"keystroke",type:i,id:n(e.code,i),timestamp:Date.now(),isTrusted:e.isTrusted,keys:Y.has(e.key)?[e.key]:[]}}(e);t.push(i)}),s=a(()=>{o()});return e(document,"keydown",r),e(document,"keyup",r),e(window,"blur",s),()=>{i(document,"keydown",r),i(document,"keyup",r),i(window,"blur",s)}},layer:"behavioral"},clipboard:{create:function(t,n="on",o){const r=a(e=>{const i=function(e){const i=e,o=e.type,r=("paste"===e.type?i.clipboardData?.getData("text/plain"):x())??null,s=E(i.target,n);return{name:"clipboard",type:o,timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target),length:r?.length??0,...s&&r?{content:r}:{}}}(e);t.push(i)});return S(o,"paste")&&e(document,"paste",r),S(o,"cut")&&e(document,"cut",r),S(o,"copy")&&e(document,"copy",r),()=>{i(document,"paste",r),i(document,"cut",r),i(document,"copy",r)}},layer:"behavioral",events:["paste","cut","copy"]},form:{create:function(t,n,o){const r=a(n=>{const e={name:"form",type:(i=n).type,timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target)};var i;t.push(e)});return S(o,"submit")&&e(document,"submit",r),S(o,"invalid")&&e(document,"invalid",r),()=>{i(document,"submit",r),i(document,"invalid",r)}},layer:"behavioral",events:["submit","invalid"]},change:{create:function(t){const n=a(n=>{const e=(i=n,{name:"change",timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target)});var i;t.push(e)});return e(document,"change",n),()=>{i(document,"change",n)}},layer:"behavioral"},selection:{create:function(t,n){let o=0,r=0,s=null,c=0,l=0;function u(){s&&(clearTimeout(s),s=null)}function d(){u(),c||l||(s=setTimeout(()=>{s=null,o&&h("timeout")},250))}function h(e){o&&(o=0,u(),function(e){const i=A("end"),o=i&&E(i,n),r=x();t.push({name:"selection",phase:"end",timestamp:Date.now(),trigger:e,isTrusted:1,element:t.resolveElement(i),length:r?.length??0,...o&&r?{content:r}:{}})}(e))}const f=a(()=>{const n=function(){const t=document.getSelection();return!t||t.isCollapsed||0===t.rangeCount}();if(!o&&!n)return o=1,r=Date.now(),t.push({name:"selection",phase:"start",timestamp:r,element:t.resolveElement(A("start"))}),void d();o&&n?h("collapse"):o&&d()}),p=a(t=>{0===t.button&&(c=1,u())}),m=a(t=>{0===t.button&&(c=0,o&&h("pointer"))}),w=a(t=>{"Shift"===t.key&&(l=1,u())}),y=a(t=>{"Shift"===t.key&&(l=0,o&&h("keyboard"))}),v=a(()=>{c=0}),g=a(()=>{"hidden"===document.visibilityState&&(c=0,l=0,o&&h("timeout"))}),b=a(()=>{c=0,o&&h("pointer")});return e(document,"selectionchange",f),e(document,"pointerdown",p),e(document,"pointerup",m),e(document,"keydown",w),e(document,"keyup",y),e(document,"contextmenu",v),e(document,"visibilitychange",g),e(document,"dragend",b),()=>{u(),i(document,"selectionchange",f),i(document,"pointerdown",p),i(document,"pointerup",m),i(document,"keydown",w),i(document,"keyup",y),i(document,"contextmenu",v),i(document,"visibilitychange",g),i(document,"dragend",b)}},layer:"behavioral"},tab:{create:()=>()=>{},layer:"session",events:["state","count"]},visibility:{create:function(t){const n=a(n=>{const e=document.visibilityState;if("visible"!==e&&"hidden"!==e)return;const i={name:"visibility",type:e,timestamp:Date.now(),isTrusted:n.isTrusted};t.push(i)});return e(document,"visibilitychange",n),()=>{i(document,"visibilitychange",n)}},layer:"session"},navigation:{create:function(t){let n=t.sanitizeUrl(document.referrer||"");function o(e){t.push(e),n=e.to??""}const r=a(()=>{const[n]=performance.getEntriesByType("navigation");var e;o(Z("load",n?.type??"navigate",{from:document.referrer?t.sanitizeUrl(document.referrer):null,to:t.sanitizeUrl(location.href)},performance.timeOrigin,n?{fetchStart:(e=n).fetchStart,domainLookupStart:e.domainLookupStart,domainLookupEnd:e.domainLookupEnd,connectStart:e.connectStart,connectEnd:e.connectEnd,requestStart:e.requestStart,responseStart:e.responseStart,responseEnd:e.responseEnd,domInteractive:e.domInteractive,domContentLoadedEventStart:e.domContentLoadedEventStart,domContentLoadedEventEnd:e.domContentLoadedEventEnd,domComplete:e.domComplete,loadEventStart:e.loadEventStart,loadEventEnd:e.loadEventEnd,redirectCount:e.redirectCount,transferSize:e.transferSize,encodedBodySize:e.encodedBodySize,decodedBodySize:e.decodedBodySize}:void 0))}),c=a(e=>{const i=e;if(null===i.navigationType)return;const r=t.sanitizeUrl(location.href);r!==n&&o(Z("change",i.navigationType,{from:n,to:r},performance.timeOrigin))}),l=a(()=>d("traverse")),u=a(()=>d("hashchange"));function d(e){const i=t.sanitizeUrl(location.href);"hashchange"===e&&i===n||o(Z("change",e,{from:n,to:i},performance.timeOrigin))}const h=history.pushState,f=history.replaceState,p=function(...t){const n=h.apply(this,t);return s(()=>d("push")),n},m=function(...t){const n=f.apply(this,t);return s(()=>d("replace")),n};return window.navigation?e(window.navigation,"currententrychange",c):(history.pushState=p,history.replaceState=m,e(window,"popstate",l),e(window,"hashchange",u)),"complete"===document.readyState?r(new Event("load")):e(window,"load",r),()=>{window.navigation?i(window.navigation,"currententrychange",c):(history.pushState===p&&(history.pushState=h),history.replaceState===m&&(history.replaceState=f),i(window,"popstate",l),i(window,"hashchange",u)),i(window,"load",r)}},layer:"session"},networkconnection:{create:function(t){const n=a(()=>{const n={name:"network",type:"connection",state:navigator.onLine?"online":"offline",timestamp:Date.now()};t.push(n)});return e(window,"online",n),e(window,"offline",n),()=>{i(window,"online",n),i(window,"offline",n)}},layer:"session"},scroll:{create:function(t){let n=null,o=null;const r=a(e=>n?n.samples.ts.length>=50?(t.push(n),n=s(e),void c(t)):(n.samples.x.push(window.scrollX),n.samples.y.push(window.scrollY),n.samples.ts.push(e.timeStamp),void c(t)):(n=s(e),void c(t)));function s(t){return{name:"scroll",timestamp:Date.now(),samples:{x:[window.scrollX],y:[window.scrollY],ts:[t.timeStamp]},height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,pageX:window.pageXOffset,pageY:window.pageYOffset}}function c(t){o&&clearTimeout(o),o=setTimeout(()=>{n&&(t.push(n),n=null),o=null},y)}return e(window,"scroll",r),()=>{i(window,"scroll",r),o&&(clearTimeout(o),o=null),n&&(t.push(n),n=null)}},layer:"behavioral"},viewportresize:{create:function(t){let n=null,o=null;const r=a(e=>n?n.samples.ts.length>=50?(t.push(n),n=s(e),void c(t)):(n.samples.height.push(window.innerHeight),n.samples.width.push(window.innerWidth),n.samples.ts.push(e.timeStamp),n.samples.scrollX.push(window.scrollX),n.samples.scrollY.push(window.scrollY),n.samples.dpr.push(window.devicePixelRatio),void c(t)):(n=s(e),void c(t)));function s(t){return{name:"viewport",type:"resize",timestamp:Date.now(),samples:{height:[window.innerHeight],width:[window.innerWidth],ts:[t.timeStamp],scrollX:[window.scrollX],scrollY:[window.scrollY],dpr:[window.devicePixelRatio]}}}function c(t){o&&clearTimeout(o),o=setTimeout(()=>{n&&(t.push(n),n=null),o=null},y)}return e(window,"resize",r),()=>{i(window,"resize",r),o&&(clearTimeout(o),o=null),n&&(t.push(n),n=null)}},layer:"behavioral"},viewport:{create:function(t,n,o){const r=a(n=>{const e=c(n,"orientation");t.push(e)}),s=a(n=>{const e=c(n,"ratiochange");t.push(e)});function c(t,n){return{name:"viewport",type:n,timestamp:Date.now(),isTrusted:t.isTrusted,height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio}}return S(o,"orientationchange")&&e(window,"orientationchange",r),S(o,"devicepixelratiochange")&&e(window,"devicepixelratiochange",s),()=>{i(window,"orientationchange",r),i(window,"devicepixelratiochange",s)}},layer:"behavioral",events:["orientationchange","devicepixelratiochange"]},sensors:{create:function(t,n,o){let r=null,s=null,c=null,u=null,h=0;function f(){u&&d(u),u=setTimeout(l(()=>{p(),u=null}),y)}function p(){r&&(t.push(r),r=null),s&&(t.push(s),s=null),c&&(t.push(c),c=null)}const m=a(n=>{const e=n,i=e.timeStamp,o=e.acceleration,s=e.accelerationIncludingGravity,c=e.rotationRate;if(!o&&!s&&!c||null===o?.x&&null===o?.y&&null===o?.z&&null===s?.x&&null===s?.y&&null===s?.z&&null===c?.alpha&&null===c?.beta&&null===c?.gamma)return;if(!r)return r={name:"sensors",type:"motion",timestamp:Date.now(),interval:e.interval??null,samples:{ax:[o?.x??0],ay:[o?.y??0],az:[o?.z??0],agx:[s?.x??0],agy:[s?.y??0],agz:[s?.z??0],rrAlpha:[c?.alpha??0],rrBeta:[c?.beta??0],rrGamma:[c?.gamma??0],ts:[i]}},void f();if(r.samples.ts.length>=50)return t.push(r),r={name:"sensors",type:"motion",timestamp:Date.now(),interval:e.interval??null,samples:{ax:[o?.x??0],ay:[o?.y??0],az:[o?.z??0],agx:[s?.x??0],agy:[s?.y??0],agz:[s?.z??0],rrAlpha:[c?.alpha??0],rrBeta:[c?.beta??0],rrGamma:[c?.gamma??0],ts:[i]}},void f();const a=r.samples;a.ax.push(o?.x??0),a.ay.push(o?.y??0),a.az.push(o?.z??0),a.agx.push(s?.x??0),a.agy.push(s?.y??0),a.agz.push(s?.z??0),a.rrAlpha.push(c?.alpha??0),a.rrBeta.push(c?.beta??0),a.rrGamma.push(c?.gamma??0),a.ts.push(i),f()}),w=a(n=>{const e=n;if(null==e.alpha&&null==e.beta&&null==e.gamma)return;const i=e.timeStamp,o=e.webkitCompassHeading??0;if(!s)return s={name:"sensors",type:"orientation",timestamp:Date.now(),absolute:h||e.absolute,samples:{alpha:[e.alpha??0],beta:[e.beta??0],gamma:[e.gamma??0],compassHeading:[o],ts:[i]}},void f();if(s.samples.ts.length>=50)return t.push(s),s={name:"sensors",type:"orientation",timestamp:Date.now(),absolute:h||e.absolute,samples:{alpha:[e.alpha??0],beta:[e.beta??0],gamma:[e.gamma??0],compassHeading:[o],ts:[i]}},void f();const r=s.samples;r.alpha.push(e.alpha??0),r.beta.push(e.beta??0),r.gamma.push(e.gamma??0),r.compassHeading.push(o),r.ts.push(i),f()}),v=a(n=>{const e=n.value;if(null==e)return;const i=n.timeStamp;return c?c.samples.ts.length>=50?(t.push(c),c={name:"sensors",type:"light",timestamp:Date.now(),samples:{lux:[e],ts:[i]}},void f()):(c.samples.lux.push(e),c.samples.ts.push(i),void f()):(c={name:"sensors",type:"light",timestamp:Date.now(),samples:{lux:[e],ts:[i]}},void f())});return S(o,"motion")&&e(window,"devicemotion",m),S(o,"orientation")&&("ondeviceorientationabsolute"in window?(h=1,e(window,"deviceorientationabsolute",w)):e(window,"deviceorientation",w)),S(o,"light")&&e(window,"devicelight",v),function(){i(window,"devicemotion",m),i(window,h?"deviceorientationabsolute":"deviceorientation",w),i(window,"devicelight",v),u&&(d(u),u=null),p()}},layer:"behavioral",events:["motion","orientation","light"]},"network-request":{create:function(t){var e;const i=function(t,e,i,o=f){if("undefined"==typeof PerformanceObserver)return w;let r=null;try{r=new PerformanceObserver(n=>{for(const r of n.getEntries()){const n=r;o.has(n.initiatorType)&&(e(n.name)||t(m(n,i)))}}),r.observe({type:"resource",buffered:1})}catch{return n.warn("network-request","PerformanceObserver failed to start"),w}return function(){r?.disconnect(),r=null}}(function(n){s(()=>t.push(n))},(e=t.ignoredOrigins,function(t){try{return e.has(new URL(t).origin)}catch{return 0}}),t.sanitizeUrl);return function(){i()}},layer:"session"},screen:{create:function(t){const n=s(()=>function(){const t=window.screen;return{name:"screen",timestamp:Date.now(),availWidth:t.availWidth,availHeight:t.availHeight,width:t.width,height:t.height,colorDepth:t.colorDepth,pixelDepth:t.pixelDepth,availLeft:t.availLeft??0,availTop:t.availTop??0,orientation:t.orientation?{type:t.orientation.type,angle:t.orientation.angle}:null,isExtended:t.isExtended??0,viewport:{height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio}}}());return n&&t.push(n),()=>{}},layer:"session"}},W=Object.keys(Q),tt=[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,/^0b[01]+$/i,/^0o[0-7]+$/i,/^0x[0-9a-f]+$/i,/^[a-z][a-z0-9]{1,12}:[A-Za-z0-9+/=_-]{6,}$/i,/^[a-z]{2,8}_(?=.*\d)[A-Za-z0-9]{3,}$/,/^\d{4,}$/,/@/,/^[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{5,}\.[A-Za-z0-9_-]{10,}$/,/^[A-Za-z0-9_-]{20,}={0,2}$/,/^[0-9a-f]{7,}$/i];function nt(t){try{const n=new URL(t,location.href);n.username="",n.password="",n.hash="";const e=[...n.searchParams.keys()],i=e.length>0?"?"+e.map(t=>`${encodeURIComponent(t)}=<redacted>`).join("&"):"";n.search="",n.pathname=n.pathname.split("/").map(t=>""!==t&&function(t){for(const n of tt)if(n.test(t))return 1;return 0}(t)?":param":t).join("/");const o=n.origin+n.pathname+i;return o.length>2048?o.slice(0,2048):o}catch{return""}}const et={flush:{intervalMs:2e3,maxIntervalMs:3e4,size:50,backoffFailureThreshold:2},queue:{size:100}};function it(){const t={};for(const n of W)t[n]=st(n,void 0,1);return t}function ot(t){const n={};for(const e of W)n[e]=st(e,void 0,t[Q[e].layer]??0);return n}function rt(t){const n={};for(const e of W){const i=t[e];n[e]=st(e,i,i?.enabled??0)}return n}function st(t,n,e){const i=Q[t]?.events??[];if(0===i.length)return{enabled:e};const o=n?.events,r={};for(const t of i)r[t]={enabled:o?.[t]??1};return{enabled:e,events:r}}function ct(t){if(!t)return null;const n=t.split(".")[1],e=atob(n.replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(e)}const at=function(t,n=30){if(!t)return 1;const e=ct(t);return e&&"number"==typeof e.exp?1e3*e.exp<=Date.now()+1e3*n:1};async function lt(t,n){return globalThis.navigator&&"locks"in globalThis.navigator&&"request"in globalThis.navigator.locks&&"query"in globalThis.navigator.locks?navigator.locks.request(t,{mode:"exclusive"},async()=>c(n)):c(n)}const ut="__tri",dt=`${ut}_activity_token`,ht=`${ut}_activity_id`,ft=`${ut}_activity_status`,pt="__tri_activity_lock";class mt{constructor(t){this.context=t,this.l=null,this.u=null,this.h=null,this.p=null,this.m=0}getToken(){return this.l}getActivityId(){return this.u??""}isActive(){return"ACTIVE"===this.h&&null!==this.l}async start(){return this.m=1,this.p||(this.p=this.v()),this.p}async stop(){this.m=0,this.k(null),this.p=null,this.l&&await this.context.stopActivity(),this.T(null)}async refresh(){if(!this.m)return;const t=this.l;await lt(pt,async()=>{if(this.l&&this.l!==t&&!at(this.l)&&"ACTIVE"===this.h)return;const n=this._();n&&n.token!==t&&!at(n.token)&&"ACTIVE"===n.activityStatus?this.T(n):(this.I(),await this.S())})}async v(){try{if(this.l&&!at(this.l))return;await lt(pt,async()=>{await this.S()})}finally{this.p=null}}async S(){const t=this._();if(t&&!at(t.token)&&"ACTIVE"===t.activityStatus)return void this.T(t);t&&this.I();const n=await this.context.startActivity();if(!n.ok)return;if(!n.data.token)return;const e=n.data;this.T(e),this.A(e)}_(){const[t,n,e]=[O.get(dt),O.get(ht),O.get(ft)];return t&&n&&e?{token:t,activityId:n,activityStatus:e}:((t||n||e)&&this.I(),null)}A(t){O.set(dt,t.token),O.set(ht,t.activityId),O.set(ft,t.activityStatus)}I(){this.k(null),this.T(null)}k(t){if(!t)return O.remove(dt),O.remove(ht),void O.remove(ft);O.set(dt,t.token),O.set(ht,t.activityId),O.set(ft,t.activityStatus)}T(t){if(!t)return this.l=null,this.u=null,void(this.h=null);this.l=t.token,this.u=t.activityId,this.h=t.activityStatus}}const wt=[401,403,409],yt=Object.freeze({tab:80,navigation:80,visibility:80,network:80,screen:80,fingerprint:80,pointer:60,keystroke:60,autofill:60,change:60,form:60,clipboard:60,selection:60,focus:60,viewport:60,network_request:60,scroll:40,sensors:40});function vt(t){return"pointer"===t.name&&"move"===t.phase||"viewport"===t.name&&"resize"===t.type?40:yt[t.name]}const gt=new Array(256);for(let t=0;t<256;t++)gt[t]=(t+256).toString(16).slice(1);const bt=new Uint8Array(16);function kt(t){return gt[t[0]]+gt[t[1]]+gt[t[2]]+gt[t[3]]+"-"+gt[t[4]]+gt[t[5]]+"-"+gt[t[6]]+gt[t[7]]+"-"+gt[t[8]]+gt[t[9]]+"-"+gt[t[10]]+gt[t[11]]+gt[t[12]]+gt[t[13]]+gt[t[14]]+gt[t[15]]}function Tt(){return crypto.randomUUID()}function _t(){return crypto.getRandomValues(bt),bt[6]=15&bt[6]|64,bt[8]=63&bt[8]|128,kt(bt)}function It(){for(let t=0;t<16;t++)bt[t]=256*Math.random()|0;return bt[6]=15&bt[6]|64,bt[8]=63&bt[8]|128,kt(bt)}const St=function(){if("undefined"!=typeof crypto){if("function"==typeof crypto.randomUUID)return Tt;if("function"==typeof crypto.getRandomValues)return _t}return It}();function xt(){return St()}class Et{constructor(t,n){this.M=t,this.D=n,this.P=[],this.C=null,this.R=[],this.L=null,this.m=0,this.$=1,this.U=0,this.B=0,this.O=t.flush.intervalMs}push(t){if(this.m){if(this.P.length<this.q()?this.P.push(t):this.j(t),this.$)return this.P.length>=this.M.flush.size?(d(this.C),this.C=null,void this.flush("capacity")):void this.H()}else n.warn("Transport","push() called before start() — event dropped")}flush(t){if(this.m&&this.D.isActivityActive())try{if("lifecycle"===t)return void this.N();if(0===this.P.length)return;const e=this.F(t);this.D.ingest(e,0).then(t=>this.X(t,e)).catch(()=>{n.warn("Transport","ingest threw unexpectedly — batch dropped")}),this.P.length>0&&this.H()}catch(t){n.warn("Transport","flush() threw unexpectedly:",t)}}start(){this.m||(this.m=1,this.$="undefined"!=typeof navigator?navigator.onLine:1)}stop(){if(!this.m)return Promise.resolve();d(this.C),this.C=null,d(this.L),this.L=null;const t=this.N();return this.m=0,t}onConnectionChange(){const t="undefined"!=typeof navigator?navigator.onLine:1;if(t!==this.$){if(this.$=t,!this.$)return d(this.C),this.C=null,d(this.L),void(this.L=null);this.P.length>0&&this.H(),this.R.length>0&&this.K()}}H(){this.m&&this.$&&null===this.C&&(this.C=u(()=>{this.C=null,this.flush("interval")},this.O))}K(){this.m&&this.$&&null===this.L&&(this.L=u(()=>{this.L=null,this.V()},this.O))}V(){if(!this.m||!this.$||0===this.R.length||!this.D.isActivityActive())return;const t=this.R.shift();this.D.ingest(t.batch,0).then(n=>this.Y(n,t)).catch(()=>{n.warn("Transport","retry drain ingest threw unexpectedly — batch dropped"),this.R.length>0&&this.K()})}J(t,e){this.R.length>=5&&(this.R.shift(),n.warn("Transport","retry queue full — oldest batch evicted")),this.R.push({batch:t,attempts:e}),this.K()}X(t,n){t.ok?this.G():this.Z(t)&&this.J(n,1)}Y(t,e){if(t.ok)return this.G(),void(this.R.length>0&&this.K());if(this.Z(t)){if(e.attempts>=3)return this.W(),n.warn("Transport","batch dropped after MAX_RETRY_ATTEMPTS",e.batch.batchId),void(this.R.length>0&&this.K());this.W(),this.J(e.batch,e.attempts+1)}else this.R.length>0&&this.K()}W(){this.U++,this.U%this.M.flush.backoffFailureThreshold===0&&(this.O=Math.min(2*this.O,this.M.flush.maxIntervalMs))}G(){this.U=0,this.O=this.M.flush.intervalMs}q(){return this.M.queue.size*(this.$?1:2)}async N(){if(!this.D.isActivityActive())return Promise.resolve();const t=[];for(const e of this.R)t.push(this.D.ingest(e.batch,1).catch(()=>{n.warn("Transport","lifecycle retry ingest threw — batch dropped")}));if(this.R=[],this.P.length>0){const e=this.F("lifecycle");t.push(this.D.ingest(e,1).catch(()=>{n.warn("Transport","lifecycle ingest threw — batch dropped")}))}return Promise.allSettled(t).then(()=>{})}j(t){const n=vt(t);for(let e=0;e<this.P.length;e++)if(vt(this.P[e])<n){for(let t=e;t<this.P.length-1;t++)this.P[t]=this.P[t+1];return this.P.length-=1,void this.P.push(t)}}F(t){const n="lifecycle"===t?this.P.splice(-this.M.flush.size):this.P.splice(0,this.M.flush.size);return{activityId:"",batchId:xt(),batchSequence:this.B++,clientTimestamp:Date.now(),schemaVersion:"0.1.0",sdkVersion:"0.3.1-rc.0",sdkPlatform:"web",tabId:this.D.getTabId(),events:n}}Z(t){if(t.ok)return 0;switch(t.kind){case"timeout":case"server":case"rate_limited":return 1;default:return 0}}}const At="tri:bcast:";const Mt="function"==typeof BroadcastChannel?BroadcastChannel:function(){if("undefined"==typeof Storage||"undefined"==typeof window)return 0;try{const t="__tri_bcast_probe__";localStorage.setItem(t,"1");const n="1"===localStorage.getItem(t);return localStorage.removeItem(t),n}catch{return 0}}()?class{constructor(t){this.seq=0,this.closed=0,this.listeners=new Set,this.onStorageEvent=t=>{if(this.closed)return;if(!t.key||!t.key.startsWith(`${At}${this.channelName}:`))return;if(null===t.newValue)return;let n;s(()=>O.remove(t.key));try{n=JSON.parse(t.newValue)}catch{return}const e={data:n};for(const t of this.listeners)s(()=>t(e))},this.channelName=t,this.senderId=xt(),window.addEventListener("storage",this.onStorageEvent)}postMessage(t){if(this.closed)return;const n=`${At}${this.channelName}:${this.senderId}:${this.seq++}`;s(()=>{O.set(n,t),O.remove(n)})}addEventListener(t,n){this.listeners.add(n)}removeEventListener(t,n){this.listeners.delete(n)}close(){this.closed||(this.closed=1,window.removeEventListener("storage",this.onStorageEvent),this.listeners.clear())}}:class{constructor(t){n.warn("BroadcastChannel","BroadcastChannel is unavailable and localStorage is not writable in this context. Cross-tab discovery is disabled; tab count will always be reported as 1.")}postMessage(t){}addEventListener(t,n){}removeEventListener(t,n){}close(){}},Dt="__tri_tabId";class Pt{constructor(t){this.context=t,this.tt="",this.m=0,this.nt=null,this.et=null,this.it=null,this.ot=new Map,this.rt=-1,this.st=null}async start(){this.m||(this.m=1,this.tt=this.ct(),this.lt(),this.ut({type:"hello",tabId:this.tt,ts:Date.now()}),this.dt(),this.ht("active"),this.ft())}stop(){this.m&&(this.m=0,this.ht("inactive"),this.ut({type:"bye",tabId:this.tt,ts:Date.now()}),this.wt(this.yt()),this.vt(),this.gt(),this.bt())}getTabId(){return this.tt}queryTabsNumber(){return this.ot.size+1}lt(){try{this.nt=new Mt("__tri_tab_channel"),this.st=this.kt.bind(this),this.nt.addEventListener("message",this.st)}catch(t){n.warn("TabManager","failed to open broadcast channel:",t)}}bt(){try{if(!this.nt)return;this.st&&this.nt.removeEventListener("message",this.st),this.nt.close()}catch{}finally{this.nt=null,this.st=null}}dt(){this.et=setInterval(()=>{const t=Date.now();this.ut({type:"heartbeat",tabId:this.tt,ts:t})},1e3)}vt(){null!=this.et&&(clearInterval(this.et),this.et=null)}ft(){null!=this.it&&clearTimeout(this.it),this.it=setTimeout(()=>{this.it=null;const t=this.yt()+1;t!==this.rt&&(this.rt=t,this.wt(t))},1e3)}gt(){null!=this.it&&(clearTimeout(this.it),this.it=null)}ut(t){try{if(!this.nt)return;this.nt.postMessage(t)}catch{n.warn("TabManager","failed to broadcast message:",t)}}kt(t){const{type:n,tabId:e}=t.data;if(e===this.tt)return;const i=Date.now();"hello"===n?(this.ut({type:"ack",tabId:this.tt,ts:i,to:e}),this.ot.set(e,i)):"heartbeat"===n||"ack"===n?this.ot.set(e,i):"bye"===n&&this.ot.delete(e)}wt(t){this.context.events.count&&this.context.push({name:"tab",type:"count",tabId:this.tt,timestamp:Date.now(),value:t})}ht(t){this.context.events.state&&this.context.push({name:"tab",type:"state",tabId:this.tt,timestamp:Date.now(),value:t})}ct(){const t=q.get(Dt);if(t)return t;const n=xt();return q.set(Dt,n),n}yt(t=Date.now()){let n=0;for(const[e,i]of this.ot.entries())t-i>=3e3?this.ot.delete(e):n++;return n}}const Ct=globalThis.CompressionStream,Rt=globalThis.Response,zt=globalThis.Blob,Lt=new TextEncoder;let $t=null;async function Ut(t){const e=await async function(t){if("function"!=typeof Ct)return null;try{const n=Lt.encode(t),e=new zt([n]).stream().pipeThrough(new Ct("gzip"));return await new Rt(e).arrayBuffer()}catch(t){return n.warn("compression","Native gzip failed:",t),null}}(t);return null!==e?e:async function(t){try{const e=await function(){if(null===$t){const t=function(t,e=1e4){let i=null;const o=new Promise(t=>{i=u(()=>{n.warn("import",`Import timed out after ${e}ms`),t(null)},e)}),r=Promise.resolve().then(t).catch(t=>(n.warn("import","Import failed:",t),null));return Promise.race([r,o]).finally(()=>{d(i)})}(()=>import("./chunks/browser-8Za96B1X.js"),1e4);$t=t,t.then(n=>{null===n&&u(()=>{$t===t&&($t=null)},1e4)})}return $t}();if(null===e)return null;const{gzipSync:i}=e,o=i(Lt.encode(t));return o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)}catch(t){return n.warn("compression","fflate gzip failed:",t),null}}(t)}function Bt(t){const n={Accept:"application/json"};return t?.hasBody&&("json"===t.contentType?n["Content-Type"]="application/json":"ndjson"===t.contentType&&(n["Content-Type"]="application/x-ndjson"),"gzip"===t.contentEncoding&&(n["Content-Encoding"]="gzip")),t?.token&&(n.Authorization=`Bearer ${t.token}`),t?.profileId&&(n["x-profile-id"]=t.profileId),t?.api?.version&&(n["x-api-version"]=t.api.version),t?.customHeaders&&Object.entries(t.customHeaders).forEach(([t,e])=>{n[t]=e}),n}const Ot="function"==typeof globalThis.fetch?globalThis.fetch.bind(globalThis):void 0;class qt{constructor(t){this.context=t}stop(){}async report(t,e){const i={name:t,metadata:e,timestamp:Date.now(),activityId:this.context.getActivityId()??""};try{const o=await this.context.reportEvent(i);if(o.ok)return o;n.warn("EventReport","Failed to report event:",t,e,"with result:",o)}catch(i){n.warn("EventReport","Failed to report event:",t,e,"with error:",i)}}}const jt=new Set(["A","BUTTON","INPUT","SELECT","TEXTAREA","SUMMARY","DETAILS","LABEL","OPTION","FIELDSET"]),Ht=new Set(["button","link","tab","menuitem","menuitemcheckbox","menuitemradio","checkbox","radio","switch","slider","spinbutton","combobox","listbox","option","searchbox","textbox","treeitem"]),Nt=255;function Ft(t,n,e){const i=t.tagName.toLowerCase(),o=function(t){const n=t.parentElement?.children??[],e=Math.min(n.length,1e3);let i=e-1,o=0,r=0;for(let i=0;i<e;i++){r++;const e=n[i];if(g(e,t.tagName)&&o++,e===t)break}return{siblings:i,ofType:o,child:r}}(t),r=function(t,n){const e=function(t){if(!t)return null;const n=t.getAttribute("data-tri-redact-attrs");return n?n.split(",").map(t=>t.trim().toLowerCase()):null}(t),i={},o=t.id;o&&!_("id",e)&&(i.id=o);const r=t.getAttribute("autocomplete");r&&!_("autocomplete",e)&&(i.autocomplete=r);const s=t.getAttribute("aria-invalid");s&&!_("aria-invalid",e)&&(i.ariaInvalid=s);const c=t.getAttribute("tabindex");c&&!_("tabindex",e)&&(i.tabIndex=parseInt(c,10));const a=function(t){return t.getAttribute("data-testid")??t.getAttribute("data-cy")??null}(t);a&&!_("data-testid",e)&&(i.testId=a);const l=t.hasAttribute("readonly");l&&!_("readonly",e)&&(i.readOnly=l);const u=t.hasAttribute("required");u&&!_("required",e)&&(i.required=u);const d=t.getAttribute("contenteditable");d&&!_("contenteditable",e)&&(i.contentEditable="true"===d||""===d);const h=t.getAttribute("href");h&&!_("href",e)&&(i.href={...n?{}:{url:h},external:I(h)});const f=t.getAttribute("role");f&&!_("role",e)&&(i.role=f);const p=t.getAttribute("type");p&&!_("type",e)&&(i.type=p);const m=t.getAttribute("name");m&&!_("name",e)&&(i.name=m);const w=t.getAttribute("placeholder");!w||n||_("placeholder",e)||(i.placeholder=w);const y=Array.from(t.classList).slice(0,5);y.length>0&&!_("class",e)&&(i.classes=y);const v=t.getAttribute("alt");return!v||n||_("alt",e)||(i.alt=v),Object.keys(i).length?i:null}(t,n);return{tagName:i,frame:e,...r?{attributes:r}:{},...o?{nth:o}:{}}}function Xt(t,n){let e=0;const i=[];return function(t){return jt.has(t.tagName)}(t)&&(e+=40,i.push("native")),function(t){return t.hasAttribute("data-tri-interactive")}(t)&&(e+=40,i.push("tri-interactive")),function(t){return g(t,"a")&&t.hasAttribute("href")}(t)&&(e+=15,i.push("has-href")),function(t){const n=t.getAttribute("role");return null!==n&&Ht.has(n)}(t)&&(e+=30,i.push("role")),function(t){return t.hasAttribute("onclick")||t.hasAttribute("ng-click")||t.hasAttribute("data-action")||t.hasAttribute("@click")}(t)&&(e+=20,i.push("click-handler")),function(t){const n=t.getAttribute("tabindex");if(null===n)return 0;const e=parseInt(n,10);return null!==e&&e>=0}(t)&&(e+=10,i.push("tabindex")),(t.id||t.getAttribute("data-testid"))&&(e+=5,i.push("has-id")),n>0&&(e+=Math.round(15/n),i.push("depth")),{score:e,reasons:i}}function Kt(t){return t>=20}function Vt(t){return null!==t&&t.width>0&&t.height>0&&t.y<window.innerHeight&&t.y+t.height>0&&t.x<window.innerWidth&&t.x+t.width>0}function Yt(t){return 1==t.disabled||"true"===t.getAttribute("aria-disabled")}function Jt(t,n=0){if(n)return null;const e=Zt(t,"labelledby");if(e)return{text:Wt(e),resolutionMethod:"aria-labelledby",confidence:"high"};const i=Qt(t);if(i)return{text:Wt(i),resolutionMethod:"aria-label",confidence:"high"};const o=function(t){if(!t.id)return null;const n=document.querySelector(`label[for="${CSS.escape(t.id)}"]`);return n?Gt(n):null}(t);if(o)return{text:Wt(o),resolutionMethod:"html-for",confidence:"high"};const r=function(t){const n=t.closest("label");return n?Gt(n):null}(t);if(r)return{text:Wt(r),resolutionMethod:"wrapping-label",confidence:"high"};const s=function(t){const n=t.getAttribute("placeholder");return n?.trim()??null}(t);if(s)return{text:Wt(s),resolutionMethod:"placeholder",confidence:"low"};const c=function(t){const n=t.getAttribute("title");return n?.trim()??null}(t);if(c)return{text:Wt(c),resolutionMethod:"title",confidence:"low"};const a=Zt(t,"describedby");if(a)return{text:Wt(a),resolutionMethod:"aria-describedby",confidence:"low"};const l=Gt(t);return l?{text:l,resolutionMethod:"text-content",confidence:"low"}:null}function Gt(t,n=0){if(n>8)return"";if(v(t))return function(t){return t?t.trim().split(/(\s+)/).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,Nt):null}(t.textContent)??"";if(!t.childNodes?.length)return"";let e="";for(const i of t.childNodes){const t=Gt(i,n+1);if(t&&(e=e?`${e} ${t}`:t,e.length>=Nt))break}return Wt(e)}function Zt(t,n){const e="labelledby"===n?"aria-labelledby":"aria-describedby",i=t?.getAttribute(e);if(!i)return null;const o=i.split(/\s+/),r=[];for(const t of o){const n=document.getElementById(t);if(!n)continue;const e=Qt(n)??Gt(n);e.length&&r.push(e)}return r.length?r.join(" "):null}function Qt(t){return t?.getAttribute("aria-label")?.trim()??null}function Wt(t){return t.length>Nt?t.slice(0,Nt)+"...":t}function tn(t){const n=t.getBoundingClientRect();return{x:n.x,y:n.y,width:n.width,height:n.height}}class nn{constructor(t){this.capacity=t,this.cache=new Map}get(t){return this.cache.get(t)}set(t,n){if(this.cache.has(t))this.cache.delete(t);else if(this.cache.size>=this.capacity){const t=this.cache.keys().next().value;t&&this.cache.delete(t)}this.cache.set(t,n)}delete(t){this.cache.delete(t)}clear(){this.cache.clear()}size(){return this.cache.size}}async function en(t,o){const{collectors:r,sdk:s}=t;let c=null,l=null,h=null,f=null;try{c=function(t){"undefined"!=typeof document&&"function"==typeof globalThis.fetch||n.warn("FalconService","createFalconServiceManager called in a non-browser environment — all requests will resolve with { ok: false, kind: 'network' }.");const e=function(t){const n=t?.timeout,e=t?.baseUrl??"",i=t?.api;async function o(t,o,r){if(void 0===Ot)return{ok:0,kind:"network"};const s=e?`${e}${o}`:o,c=new AbortController;let a=null,l=0;a=u(()=>{l=1,c.abort()},n);const h=r?.signal;let f,p=()=>{};if(h)if(h.aborted)c.abort();else{const t=()=>c.abort();h.addEventListener("abort",t,{once:1}),p=()=>h.removeEventListener("abort",t)}if(null!=r&&"body"in r&&null!=r.body){const t=function(t){if(null==t)return{ok:1,body:void 0};if("string"==typeof t||t instanceof ArrayBuffer||ArrayBuffer.isView(t)||t instanceof Blob||t instanceof FormData||t instanceof URLSearchParams||t instanceof ReadableStream)return{ok:1,body:t};try{return{ok:1,body:JSON.stringify(t)}}catch{return{ok:0}}}(r.body);if(!t.ok)return d(a),p(),{ok:0,kind:"serialize"};f=t.body}try{const n=await Ot(s,{method:t,headers:Bt({token:r?.token,profileId:r?.profileId,contentType:r?.contentType,contentEncoding:r?.contentEncoding,api:i,hasBody:void 0!==f,customHeaders:r?.customHeaders}),body:f,signal:c.signal,keepalive:r?.keepalive});if(!n.ok)return 429===(m=n.status)?{ok:0,kind:"rate_limited",status:m}:m>=400&&m<500?{ok:0,kind:"client",status:m}:{ok:0,kind:"server",status:m};if(204===n.status)return{ok:1,data:void 0,status:204};try{return{ok:1,data:await n.json(),status:n.status}}catch{return c.signal.aborted?l?{ok:0,kind:"timeout"}:{ok:0,kind:"abort"}:{ok:0,kind:"parse",status:n.status}}}catch{return l?{ok:0,kind:"timeout"}:c.signal.aborted?{ok:0,kind:"abort"}:{ok:0,kind:"network"}}finally{d(a),p()}var m}return{post:async function(t,n){return o("POST",t,n)},get:async function(t,n){return o("GET",t,n)}}}({baseUrl:`${t.api.url}/api/v1`,timeout:1e4,api:{version:t.api.version}}),i=function(t){const{getToken:e,refresh:i}=t;let o=null;return{withAuth:async function(t,r){if(o){const n=await o;if(n)return t(n)}const s=e()??"",c=await t(s);if((a=c).ok||"client"!==a.kind||!wt.includes(a.status)||0==r?.refreshable)return c;var a;const l=await(o||(o=async function(){try{return await i(),e()}catch(t){return n.warn("AuthMiddleware","auth refresh failed",t),null}}().finally(()=>{o=null}),o));return l&&l!==s?t(l):c}}}(t),o=()=>({profileId:t.getProfileId()??void 0});return{api:{ingest:async function(n,r){return i.withAuth(async i=>{const{events:s,...c}=n,a={...c,activityId:t.getActivityId()};let l;try{l=await async function(t,n){const e=function(t,n){const e=[JSON.stringify(t)];for(let t=0;t<n.length;t++)try{e.push(JSON.stringify(n[t]))}catch{}return e.join("\n")}(t,n),i=await Ut(e);return i?{type:"gzip",body:i}:{type:"ndjson",body:e}}(a,s)}catch{return{ok:0,kind:"serialize"}}return e.post("/events/capture",{body:l.body,token:i,keepalive:r,contentType:"ndjson",contentEncoding:"gzip"===l.type?"gzip":void 0,...o()})},{refreshable:!r})},reportEvent:async function(t){return i.withAuth(n=>e.post("/events/report-event",{body:t,token:n,contentType:"json",...o()}))},startActivity:async function(){return e.post("/events/start-activity",{token:t.getSdkToken(),...o()})},stopActivity:async function(){return i.withAuth(t=>e.post("/events/end-activity",{token:t,keepalive:1,...o()}),{refreshable:0})},collectionStatus:async function(){return e.get("/sdk/collection-status",{token:t.getSdkToken(),...o()})},linkInterview:async function(t){return i.withAuth(n=>e.post("/events/link-interview",{token:n,contentType:"json",...o(),customHeaders:{"X-Incode-Hardware-Id":t}}))}}}}({api:{version:s.api.version,url:s.api.url},getSdkToken:()=>s.token,getProfileId:()=>o.getProfileId(),getToken:()=>l?.getToken()??null,refresh:async()=>l?.refresh()??Promise.resolve(),getActivityId:()=>l?.getActivityId()??""});const t=await c.api.collectionStatus();if(!t.ok||1!=t.data.eventsCollectionEnabled)return{status:"collection-disabled"};l=new mt({startActivity:()=>c.api.startActivity(),stopActivity:()=>c.api.stopActivity()}),h=new Et(et,{ingest:(t,n)=>c.api.ingest(t,n),getTabId:()=>f?.getTabId()??"unknown",isActivityActive:()=>l?.isActive()??0});const p=r.tab;f=new Pt({push:t=>h?.push(t),events:{state:p.enabled&&p.events.state.enabled,count:p.enabled&&p.events.count.enabled}});const m=function(t){function n(n){"hidden"===document.visibilityState&&t.flush()}function o(n){t.flush(),t.stopTab(),t.getShouldSkipStopActivity()||t.stopActivity()}const r=a(()=>t.onConnectionChange());return{start:function(){e(document,"visibilitychange",n),e(window,"pagehide",o),e(window,"online",r),e(window,"offline",r)},stop:function(){i(document,"visibilitychange",n),i(window,"pagehide",o),i(window,"online",r),i(window,"offline",r)}}}({flush:()=>h?.flush("lifecycle"),stopActivity:async()=>l?.stop(),stopTab:()=>f?.stop(),getShouldSkipStopActivity:()=>(f?.queryTabsNumber()??0)>1,onConnectionChange:()=>h?.onConnectionChange()}),w=function(t){const n=t||"redact",e=new nn(6),i=new nn(6);return{resolve:function(t){if(!t||k(t)||"off"===n)return null;let o=e.get(t);if(o||(o=function(t){if(!t||k(t))return{chain:[],redaction:{level:"ignore",index:-1}};const n=[];let e=t,i=-1;for(;e;){if(k(e))return{chain:[],redaction:{level:"ignore",index:-1}};T(e)&&(i=n.length),n.push(e);const t=e.parentNode;if(!t||g(e,"body"))break;e=b(t)?t.host:t}return{chain:n,redaction:{level:-1===i?"full":"redact",index:i}}}(t.parentElement),e.set(t,o)),"ignore"===o.redaction.level)return null;const r="redact"===o.redaction.level||"redact"===n||T(t);let s=i.get(t);return s||(s=function(t,n,e,i){const o=getComputedStyle(t),r=tn(t),s=function(t,n){const e=[],i=[];for(let o=t.length-1;o>=0;o--){const r=t[o],s=o<=n,c=o+1,a=Ft(r,s,tn(r)),{score:l,reasons:u}=Xt(r,c);if(e.push(a),!Kt(l))continue;const d=Jt(r,s);i.push({...a,...d?{label:d}:{},depth:c,score:l,reasons:u})}return{ancestors:e,interactiveCandidates:i.reverse()}}(n,i),c=Ft(t,e,r),a=function(t,n,e){const{score:i,reasons:o}=Xt(t,0);return{interactive:Kt(i),...o.length>0?{reasons:o}:{},disabled:Yt(t),rendered:"none"!==n?.display,visible:"hidden"!==n?.visibility,inViewport:Vt(e),acceptsPointer:"none"!==n?.pointerEvents,opacity:parseFloat(n?.opacity||"1")}}(t,o,r);let l=null;return e||(l=a.interactive?Jt(t):null),{tagName:c.tagName,frame:c.frame,viewport:{height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio},attributes:c.attributes,nth:c.nth,...l?{label:l}:{},ancestors:s.ancestors,interactiveCandidates:s.interactiveCandidates,interactivity:a}}(t,o.chain,r,o.redaction.index),i.set(t,s)),s}}}(s.capture?.element),y=new Set;try{y.add(new URL(s.api.url).origin)}catch{}const v=function(t,n,e="on"){const i=new Map;function o(o){if(i.has(o))return;const r=Q[o];if(!r||!function(t,n){return n[t]?.enabled??0}(o,n))return;const s=n[o],c=r.create(t,e,s&&"events"in s?s.events:void 0);i.set(o,c)}return{start:o,stopCollector:function(t){const n=i.get(t);n&&(n(),i.delete(t))},stop:function(){for(const[,t]of i)t();i.clear()},isRunning:function(t){return i.has(t)},autocapture:function(){for(const t of W)o(t)}}}({push:t=>h?.push(t),resolveElement:t=>w.resolve(t),sanitizeUrl:s.sanitizeUrl,ignoredOrigins:y},r,s.capture?.content),_=new qt({getActivityId:()=>l?.getActivityId()??"",reportEvent:t=>c.api.reportEvent(t)});return{status:"ready",managers:{falconServiceManager:c,activityManager:l,transportManager:h,tabManager:f,lifecycleManager:m,collectorManager:v,eventReportManager:_}}}catch(t){return n.warn("IncodeTRI","setup() failed during construction:",t),{status:"init-failed"}}}let on=class t{constructor(){this.Tt=0,this.M=null,this._t=null,this.It="idle"}static get instance(){return t.i||(t.i=new t),t.i}async setup(t){if("idle"!==this.It)return n.fatal("error","setup()","called more than once — ignoring."),"init-failed";try{const e=function(t){if("undefined"==typeof document)return n.fatal("error","IncodeTRI","TRI is not available in a non-browser environment."),null;if(!t?.token)return n.fatal("error","SDK","token is required."),null;if(!t.apiURL)return n.fatal("error","SDK","Couldn't initialise SDK — apiURL isn't provided."),null;const{element:e,content:i}=t.capture??{},o={token:t.token,capture:{element:e??"redact",content:i??"off"},profileId:t.profileId,api:{version:t.apiVersion??"1.0",url:t.apiURL},sanitizeUrl:(r=t.sanitizeUrl,r?function(t){return s(()=>r(t,nt))??nt(t)}:nt),DEBUG:t.DEBUG??0};var r;return void 0===t.collectors&&void 0===t.layers?{sdk:o,collectors:it()}:void 0!==t.collectors?{sdk:o,collectors:rt(t.collectors)}:{sdk:o,collectors:ot(t.layers)}}(t);if(!e)return"init-failed";n.DEBUG=e.sdk.DEBUG;const i=await en(e,{getProfileId:()=>this.St()});return"collection-disabled"===i.status?(n.fatal("warn","setup()","Collection is disabled for the provided API Key."),"collection-disabled"):"init-failed"===i.status?"init-failed":(this.M=e,this._t=i.managers,this.It="ready",this.xt(e.sdk.profileId),"ready")}catch(t){return n.warn("setup()","failed:",t),"init-failed"}}async start(){if("idle"===this.It)return n.warn("start()","start() requires a prior successful setup() — ignoring."),this.It;if("ready"!==this.It)return n.fatal("warn","start()","TRI is either already started or isn't ready — ignoring."),this.It;this.It="starting";const t=++this.Tt;return await this.v(t),this.It}async stop(){n.warn("stop()","called");const t=this._t;return t?(++this.Tt,t.lifecycleManager.stop(),t.collectorManager.stop(),t.tabManager.stop(),t.eventReportManager.stop(),this.It="ready",this.Et(t)):Promise.resolve(this.It)}async reset(){const t=this.stop();return this.It="idle",this.M=null,this._t=null,O.remove("__tri_profile_id"),t.then(()=>this.It)}async Et(t){return await function(t){let n=null;const e=new Promise(t=>{n=u(t,2e3)});return Promise.race([t.finally(()=>d(n)),e])}(Promise.resolve(t.transportManager.stop())),await t.activityManager.stop(),this.It}reportEvent(t,e){"started"===this.It?this._t?c(()=>this._t.eventReportManager.report(t,e)):n.warn("reportEvent()","reportEvent() called but managers are unavailable — dropping event."):n.warn("reportEvent()","reportEvent() called before start() completed — dropping event.")}setProfileId(t){"started"===this.It?this.M?.sdk&&(this.M.sdk.profileId=t,this.xt(t)):n.warn("setProfileId()","setProfileId() called before start() completed — ignoring.")}async linkInterview(t){if("started"!==this.It||!this._t)return n.warn("linkInterview()","linkInterview() called before start() completed — ignoring."),0;if(!t)return n.warn("linkInterview()","linkInterview() called without sessionToken — ignoring."),0;try{return(await this._t.falconServiceManager.api.linkInterview(t)).ok}catch(t){return n.warn("linkInterview()","failed:",t),0}}St(){return this.M?.sdk?.profileId??O.get("__tri_profile_id")??null}xt(t){t&&O.set("__tri_profile_id",t)}async v(t){const e=this._t;if(e){try{if(await e.activityManager.start(),t!==this.Tt)return;if(e.transportManager.start(),await e.tabManager.start(),t!==this.Tt)return;e.lifecycleManager.start(),e.collectorManager.autocapture()}catch(e){return n.warn("start()","failed during monitoring start:",e),void(t===this.Tt&&(this.It="ready"))}t===this.Tt&&(this.It="started")}}};async function rn(t,n){const e=n?.apiURL??"https://falcon-ingest-k8s.stage.incodetest.com",i=n?.timeout??1e4,o=new AbortController;let r=null,s=0,c=()=>{};i&&(r=u(()=>{s=1,o.abort()},i));const a=n?.signal;if(a)if(a.aborted)o.abort();else{const t=()=>o.abort();a.addEventListener("abort",t,{once:1}),c=()=>a.removeEventListener("abort",t)}try{const n=await fetch(`${e}/api/v1/sdk/init`,{method:"POST",headers:{"content-type":"application/json","x-api-key":t,"x-api-version":"1.0"},signal:o.signal});if(!n.ok){let t=n.statusText;try{const e=await n.json();e.errorMessage&&(t=e.errorMessage)}catch{}return{token:null,eventsCollectionEnabled:0,error:{status:n.status,message:t}}}return await n.json()}catch(t){throw new Error((s?"[TRI] createSession timed out":"[TRI] Failed to create session:")+" "+t.message)}finally{d(r),c()}}on.i=null;const sn=on.instance;export{rn as createSession,sn as default};
|
package/dist/tri.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).IncodeTRI={})}(this,function(t){"use strict";class n{constructor(){this.T=0}static get instance(){return n._||(n._=new n),n._}get DEBUG(){return this.T}set DEBUG(t){this.T=t}warn(t,n,...e){this.T&&this.S("warn",t,n,...e)}error(t,n,...e){this.T&&this.S("error",t,n,...e)}info(t,n,...e){this.T&&this.S("info",t,n,...e)}fatal(t,n,e,...i){this.S(t,n,e,...i)}S(t,n,e,...i){const r=n?`[${n}]`:"",o=console?.[t];o&&o(`[IncodeTRI]${r} ${e}`,...i)}}const e=n.instance;function i(t,n,e){let i=t,r=n;if("devicepixelratiochange"===n){const t=window.devicePixelRatio;i=window.matchMedia(`(resolution: ${t}dppx)`),r="change"}i.addEventListener(r,e,{capture:1,passive:1})}function r(t,n,e){let i=t,r=n;if("devicepixelratiochange"===n){const t=window.devicePixelRatio;i=window.matchMedia(`(resolution: ${t}dppx)`),r="change"}i.removeEventListener(r,e,{capture:1})}const o=globalThis.setTimeout.bind(globalThis),s=globalThis.clearTimeout.bind(globalThis);function a(t,n){try{return t()}catch(t){e.warn("utils","safeSync swallowed error:",t)}}async function c(t){try{return await t()}catch(t){e.warn("utils","safeAsync swallowed error:",t)}}function u(t){return n=>a(()=>t(n))}function l(t){return(...n)=>{try{t(...n)}catch(t){e.warn("utils","safeTimer swallowed error:",t)}}}function f(t,n){return o(l(t),n)}function h(t){if(null!==t)try{s(t)}catch(t){e.warn("utils","safeClearTimeout swallowed error:",t)}}const d=new Set(["xmlhttprequest","fetch","beacon","navigation","script","link","css","img","iframe","video","audio"]),v=new Set(["xmlhttprequest","fetch","beacon"]);function p(t,n){return n?t:null}function w(t,n){const e=t,i=t.responseStart>0,r=p(t.domainLookupEnd-t.domainLookupStart,i),o=p(t.connectEnd-t.connectStart,i),s=p(t.connectEnd>0&&t.secureConnectionStart>0?t.connectEnd-t.secureConnectionStart:0,i),a=p(t.responseStart-t.requestStart,i),c=p(t.responseEnd-t.responseStart,i),u=i?t.transferSize:null,l=i?t.encodedBodySize:null,f=i?t.decodedBodySize:null,h=i&&t.nextHopProtocol||null,v=i&&void 0!==e.deliveryType?e.deliveryType:null,w=e.responseStatus,m=void 0!==w&&0!==w?w:null;return{name:"network_request",timestamp:Date.now(),performanceTime:t.startTime+t.duration,url:n(t.name),initiatorType:(y=t.initiatorType,d.has(y)?y:"other"),startTime:t.startTime,durationMs:t.duration,dnsLookupMs:r,tcpConnectMs:o,tlsHandshakeMs:s,ttfbMs:a,responseDownloadMs:c,transferSize:u,encodedBodySize:l,decodedBodySize:f,nextHopProtocol:h,deliveryType:v,responseStatus:m};var y}function m(){}const y=2e3;function g(t){return!!t&&t.nodeType===Node.TEXT_NODE}function b(t,n){return t.tagName?.toLowerCase()===n.toLowerCase()}function k(t){return!!t&&t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function T(t){return t?t.hasAttribute("data-tri-ignore"):0}function _(t){return t?t.hasAttribute("data-tri-redact"):0}function I(t,n){return n?.includes(t.toLowerCase())??0}function S(t){try{return new URL(t).origin!==window.location.origin}catch{return 0}}function x(t,n){return t?t[n]?.enabled??0:1}function M(){const t=document.activeElement;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement){const n=t.selectionStart,e=t.selectionEnd;return null==n||null==e||n===e?null:t.value.substring(n,e)}const n=window.getSelection();return!n||n.isCollapsed?null:n.toString()||null}function E(t,n){return"off"===n||T(t)||_(t)?0:1}function A(t){const n=document.activeElement;if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)return n;const e=window.getSelection();return(i=("start"===t?e?.anchorNode:e?.focusNode)??null)?g(i)?i.parentElement:i instanceof Element?i:null:null;var i}function z(){const t=window,n="__fpjs_p_l_b",e=t[n];if(function(t,n){var e;const i=null===(e=Object.getOwnPropertyDescriptor)||void 0===e?void 0:e.call(Object,t,n);(null==i?void 0:i.configurable)?delete t[n]:i&&!i.writable||(t[n]=void 0)}(t,n),"function"!=typeof(null==e?void 0:e.load))throw new Error($);return e}const D="Blocked by CSP",P="The endpoint parameter is not a valid URL";function C(t){return function(t,n){const e=document,i="securitypolicyviolation";let r;const o=n=>{const e=new URL(t,location.href),{blockedURI:i}=n;i!==e.href&&i!==e.protocol.slice(0,-1)&&i!==e.origin||(r=n,s())};e.addEventListener(i,o);const s=()=>e.removeEventListener(i,o);return Promise.resolve().then(n).then(t=>(s(),t),t=>new Promise(t=>{const n=new MessageChannel;n.port1.onmessage=()=>t(),n.port2.postMessage(null)}).then(()=>{if(s(),r)return(()=>{throw new Error(D)})();throw t}))}(t,()=>function(t){return new Promise((n,e)=>{if(function(t){if(URL.prototype)try{return new URL(t,location.href),0}catch(t){if(t instanceof Error&&"TypeError"===t.name)return 1;throw t}}(t))throw new Error(P);const i=document.createElement("script"),r=()=>{var t;return null===(t=i.parentNode)||void 0===t?void 0:t.removeChild(i)},o=document.head||document.getElementsByTagName("head")[0];i.onload=()=>{r(),n()},i.onerror=()=>{r(),e(new Error(R))},i.async=1,i.src=t,o.appendChild(i)})}(t)).then(z)}const U="API key required";var L="3.12.9";const R="Failed to load the JS script of the agent",$="9319",O={scriptUrl:"https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js"};function B(t){function n(){return globalThis.window&&globalThis.window[t]&&void 0!==globalThis.window[t]}return{get:function(e){if(!n())return null;try{const n=window[t].getItem(e)??"null";return"null"===n?null:JSON.parse(n)}catch{return null}},set:function(e,i){n()&&a(()=>window[t].setItem(e,JSON.stringify(i)))},remove:function(e){n()&&a(()=>window[t].removeItem(e))},key:function(e){return n()?window[t].key(e):null},get length(){return n()?window[t].length:0}}}const j=B("localStorage"),q=B("sessionStorage"),F="__tri_fingerprint";let H=null,N=null;async function Z(t){try{const n=await function(t){return H||(H=function(t){var n,e;const{picked:i,rest:r}=function(t,n){const e={},i={};for(const[r,o]of Object.entries(t))n.includes(r)?e[r]=o:i[r]=o;return{picked:e,rest:i}}(t,["scriptUrlPattern","token","apiKey"]),o=null!==(n=i.apiKey)&&void 0!==n?n:i.token,s=null!==(e=function(t,n){return function(t,n){return Object.prototype.hasOwnProperty.call(t,n)}(t,n)?t[n]:void 0}(t,"scriptUrlPattern"))&&void 0!==e?e:O.scriptUrl,[a,c]=function(){const t=[],n=()=>{t.push({time:new Date,state:document.visibilityState})},e=((i=document).addEventListener("visibilitychange",r=n,o),()=>i.removeEventListener("visibilitychange",r,o));var i,r,o;return n(),[t,e]}();return Promise.resolve().then(()=>{if(!o||"string"!=typeof o)throw new Error(U);return function(t,n){const e=[],[i,r]=function(t){const n=function(t){const n=[...t];return{current:()=>n[0],postpone(){const t=n.shift();void 0!==t&&n.push(t)},exclude(){n.shift()}}}(t),e=function(){let t=0;return()=>Math.random()*Math.min(3e3,100*Math.pow(2,t++))}(),i=new Set;return[n.current(),(t,r)=>{let o;const s=r instanceof Error?r.message:"";if(s===D||s===P)n.exclude(),o=0;else if(s===$)n.exclude();else if(s===R){const e=Date.now()-t.getTime()<50,r=n.current();r&&e&&!i.has(r)&&(i.add(r),o=0),n.postpone()}else n.postpone();const a=n.current();return void 0===a?void 0:[a,null!=o?o:t.getTime()+e()-Date.now()]}]}(t);let o;if(void 0===i)return Promise.reject(new TypeError("The list of script URL patterns is empty"));const s=t=>{const i=new Date,a=n=>e.push({url:t,startedAt:i,finishedAt:new Date,error:n}),c=n(t);return c.then(()=>a(),a),c.catch(t=>{if(null!=o||(o=t),e.length>=5)throw o;const n=r(i,t);if(!n)throw o;const[a,c]=n;return(u=c,new Promise(t=>setTimeout(t,u))).then(()=>s(a));var u})};return s(i).then(t=>[t,e])}(function(t,n){return(Array.isArray(t)?t:[t]).map(t=>function(t,n){const e=encodeURIComponent;return t.replace(/<[^<>]+>/g,t=>"<version>"===t?"3":"<apiKey>"===t?e(n):"<loaderVersion>"===t?e(L):t)}(String(t),n))}(s,o),C)}).catch(t=>{throw c(),function(t){return t instanceof Error&&t.message===$?new Error(R):t}(t)}).then(([t,n])=>(c(),t.load({...r,ldi:{attempts:n,visibilityStates:a}})))}({apiKey:t.apiKey,region:t.region,endpoint:t.endpoint,scriptUrlPattern:t.scriptUrlPattern}).catch(t=>{throw H=null,t}),H)}(t),e=await n.get({timeout:t.timeoutMs,extendedResult:1});if(!e.visitorId)return null;const i=t.cacheTtlMs??2592e6;return i>0&&function(t,n,e){const i={visitorId:t,requestId:n,expiresAt:Date.now()+e};j.set(F,i)}(e.visitorId,e.requestId,i),{visitorId:e.visitorId,requestId:e.requestId}}catch{return null}}const X={apiKey:"5uYRiI0XM6p8k4124ELX",endpoint:"https://fingerprint.incodesmile.com",scriptUrlPattern:"https://fingerprint.incodesmile.com/web/v<version>/<apiKey>/loader_v<loaderVersion>.js"},G={focusin:"in",focusout:"out"};function K(t){return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement}const V=new Set(["Shift","Control","Alt","Meta","Backspace","Delete","Enter","Tab","CapsLock","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]),Y={mouse:"mouse",touch:"touch",pen:"pen"},J={pointerdown:"down",pointerup:"up",click:"click",dblclick:"dblclick",contextmenu:"contextmenu"};function Q(t,n,e,i,r){return{name:"navigation",timestamp:Date.now(),phase:t,type:n,from:e.from,to:e.to,timeOrigin:i,timing:r}}const W={fingerprint:{create:function(t){let n=0;return c(async()=>{const e=await async function(t){const n=function(){const t=j.get(F);return t?"string"!=typeof t.visitorId||"number"!=typeof t.expiresAt||t.expiresAt<=Date.now()?(j.remove(F),null):{visitorId:t.visitorId,requestId:"string"==typeof t.requestId?t.requestId:""}:null}();return n?{visitorId:n.visitorId,requestId:n.requestId||null}:N||(N=Z(t).finally(()=>{N=null}),N)}(X);!n&&e&&t.push({name:"fingerprint",deviceId:e.visitorId,requestId:e.requestId,timestamp:Date.now()})}),()=>{n=1}},layer:"device-fingerprinting"},pointer:{create:function(t,n,e){const o=u(n=>{const e=function(n){const e=n,i=function(t){if("mouse"===t.pointerType)return{button:t.button,buttons:t.buttons};const n={force:t.pressure,contact:Math.min(t.width,t.height)};return"pen"===t.pointerType&&(n.tiltX=t.tiltX,n.tiltY=t.tiltY,n.twist=t.twist),n}(e);return{id:e.pointerId,name:"pointer",timestamp:Date.now(),type:Y[e.pointerType]??"unknown",phase:J[n.type],isTrusted:e.isTrusted,element:t.resolveElement(e.target),isPrimary:e.isPrimary,modifiers:{shift:e.shiftKey,ctrl:e.ctrlKey,alt:e.altKey,meta:e.metaKey},coordinates:{x:e.clientX,y:e.clientY},...i}}(n);t.push(e)});return x(e,"pointer")&&(i(document,"pointerdown",o),i(document,"pointerup",o)),x(e,"click")&&i(document,"click",o),x(e,"dblclick")&&i(document,"dblclick",o),x(e,"contextmenu")&&i(document,"contextmenu",o),()=>{r(document,"pointerdown",o),r(document,"pointerup",o),r(document,"click",o),r(document,"dblclick",o),r(document,"contextmenu",o)}},layer:"behavioral",events:["pointer","click","dblclick","contextmenu"]},pointermove:{create:function(t){let n=null,e=null;const o=u(e=>{const i=e;return n&&n.id!==i.pointerId&&(t.push(n),n=null),n?n.samples.ts.length>=50?(t.push(n),n=s(i),void a(t)):(n.samples.x.push(i.clientX),n.samples.y.push(i.clientY),n.samples.ts.push(i.timeStamp),"pen"===i.pointerType&&(n.samples.tiltX?.push(i.tiltX),n.samples.tiltY?.push(i.tiltY)),"mouse"!==i.pointerType&&(n.samples.force?.push(i.pressure),n.samples.radius?.push(Math.max(i.width,i.height))),void a(t)):(n=s(i),void a(t))});function s(t){const n=function(t){if("mouse"===t.pointerType)return null;const n={force:[t.pressure],radius:[Math.max(t.width,t.height)]};return"pen"===t.pointerType&&(n.tiltX=[t.tiltX],n.tiltY=[t.tiltY]),n}(t);return{name:"pointer",timestamp:Date.now(),id:t.pointerId,type:t.pointerType,phase:"move",isTrusted:t.isTrusted,isPrimary:t.isPrimary,samples:{x:[t.clientX],y:[t.clientY],ts:[t.timeStamp],...n??{}}}}function a(t){e&&clearTimeout(e),e=setTimeout(()=>{n&&(t.push(n),n=null),e=null},y)}return i(document,"pointermove",o),()=>{r(document,"pointermove",o),e&&(clearTimeout(e),e=null),n&&(t.push(n),n=null)}},layer:"behavioral"},focus:{create:function(t){const n=u(n=>{const e=function(n){const e=n;return{name:"focus",type:G[n.type]??"unknown",timestamp:Date.now(),isTrusted:e.isTrusted,element:t.resolveElement(e.target),relatedTarget:t.resolveElement(e.relatedTarget)}}(n);t.push(e)});return i(document,"focusin",n),i(document,"focusout",n),()=>{r(document,"focusin",n),r(document,"focusout",n)}},layer:"behavioral"},input:{create:function(t){const n=u(n=>{const e=n;t.push(function(n){return{name:"keystroke",type:"input",timestamp:Date.now(),isTrusted:n.isTrusted,element:t.resolveElement(n.target),inputType:n.inputType??"",isComposing:n.isComposing??0,length:(e=n.target,e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement?e.value.length:0)};var e}(e)),function(t){if("insertReplacementText"===t.inputType)return 1;const n=t.target;return K(n)?function(t){try{return t.matches(":-webkit-autofill")}catch{return 0}}(n):0}(e)&&t.push(function(t,n){const e=t.target;let i=0;return K(e)&&(i=e.value.length),{name:"autofill",timestamp:Date.now(),element:n.resolveElement(e),length:i}}(e,t))});return i(document,"input",n),function(){r(document,"input",n)}},layer:"behavioral"},keystroke:{create:function(t){const{resolve:n,reset:e}=function(){let t=0;const n=new Map;return{resolve:function(e,i){if("keydown"===i){const i=n.get(e);if(void 0!==i)return i;const r=++t;if(n.size>=32){const t=n.keys().next().value;void 0!==t&&n.delete(t)}return n.set(e,r),r}const r=n.get(e);return void 0!==r?(n.delete(e),r):++t},reset:function(){n.clear()}}}(),o=u(e=>{const i=function(t){const e=t,i=t.type;return{name:"keystroke",type:i,id:n(e.code,i),timestamp:Date.now(),isTrusted:e.isTrusted,keys:V.has(e.key)?[e.key]:[]}}(e);t.push(i)}),s=u(()=>{e()});return i(document,"keydown",o),i(document,"keyup",o),i(window,"blur",s),()=>{r(document,"keydown",o),r(document,"keyup",o),r(window,"blur",s)}},layer:"behavioral"},clipboard:{create:function(t,n="on",e){const o=u(e=>{const i=function(e){const i=e,r=e.type,o=("paste"===e.type?i.clipboardData?.getData("text/plain"):M())??null,s=E(i.target,n);return{name:"clipboard",type:r,timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target),length:o?.length??0,...s&&o?{content:o}:{}}}(e);t.push(i)});return x(e,"paste")&&i(document,"paste",o),x(e,"cut")&&i(document,"cut",o),x(e,"copy")&&i(document,"copy",o),()=>{r(document,"paste",o),r(document,"cut",o),r(document,"copy",o)}},layer:"behavioral",events:["paste","cut","copy"]},form:{create:function(t,n,e){const o=u(n=>{const e={name:"form",type:(i=n).type,timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target)};var i;t.push(e)});return x(e,"submit")&&i(document,"submit",o),x(e,"invalid")&&i(document,"invalid",o),()=>{r(document,"submit",o),r(document,"invalid",o)}},layer:"behavioral",events:["submit","invalid"]},change:{create:function(t){const n=u(n=>{const e=(i=n,{name:"change",timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target)});var i;t.push(e)});return i(document,"change",n),()=>{r(document,"change",n)}},layer:"behavioral"},selection:{create:function(t,n){let e=0,o=0,s=null,a=0,c=0;function l(){s&&(clearTimeout(s),s=null)}function f(){l(),a||c||(s=setTimeout(()=>{s=null,e&&h("timeout")},250))}function h(i){e&&(e=0,l(),function(e){const i=A("end"),r=i&&E(i,n),o=M();t.push({name:"selection",phase:"end",timestamp:Date.now(),trigger:e,isTrusted:1,element:t.resolveElement(i),length:o?.length??0,...r&&o?{content:o}:{}})}(i))}const d=u(()=>{const n=function(){const t=document.getSelection();return!t||t.isCollapsed||0===t.rangeCount}();if(!e&&!n)return e=1,o=Date.now(),t.push({name:"selection",phase:"start",timestamp:o,element:t.resolveElement(A("start"))}),void f();e&&n?h("collapse"):e&&f()}),v=u(t=>{0===t.button&&(a=1,l())}),p=u(t=>{0===t.button&&(a=0,e&&h("pointer"))}),w=u(t=>{"Shift"===t.key&&(c=1,l())}),m=u(t=>{"Shift"===t.key&&(c=0,e&&h("keyboard"))}),y=u(()=>{a=0}),g=u(()=>{"hidden"===document.visibilityState&&(a=0,c=0,e&&h("timeout"))}),b=u(()=>{a=0,e&&h("pointer")});return i(document,"selectionchange",d),i(document,"pointerdown",v),i(document,"pointerup",p),i(document,"keydown",w),i(document,"keyup",m),i(document,"contextmenu",y),i(document,"visibilitychange",g),i(document,"dragend",b),()=>{l(),r(document,"selectionchange",d),r(document,"pointerdown",v),r(document,"pointerup",p),r(document,"keydown",w),r(document,"keyup",m),r(document,"contextmenu",y),r(document,"visibilitychange",g),r(document,"dragend",b)}},layer:"behavioral"},tab:{create:()=>()=>{},layer:"session",events:["state","count"]},visibility:{create:function(t){const n=u(n=>{const e=document.visibilityState;if("visible"!==e&&"hidden"!==e)return;const i={name:"visibility",type:e,timestamp:Date.now(),isTrusted:n.isTrusted};t.push(i)});return i(document,"visibilitychange",n),()=>{r(document,"visibilitychange",n)}},layer:"session"},navigation:{create:function(t){let n=t.sanitizeUrl(document.referrer||"");function e(e){t.push(e),n=e.to??""}const o=u(()=>{const[n]=performance.getEntriesByType("navigation");var i;e(Q("load",n?.type??"navigate",{from:document.referrer?t.sanitizeUrl(document.referrer):null,to:t.sanitizeUrl(location.href)},performance.timeOrigin,n?{fetchStart:(i=n).fetchStart,domainLookupStart:i.domainLookupStart,domainLookupEnd:i.domainLookupEnd,connectStart:i.connectStart,connectEnd:i.connectEnd,requestStart:i.requestStart,responseStart:i.responseStart,responseEnd:i.responseEnd,domInteractive:i.domInteractive,domContentLoadedEventStart:i.domContentLoadedEventStart,domContentLoadedEventEnd:i.domContentLoadedEventEnd,domComplete:i.domComplete,loadEventStart:i.loadEventStart,loadEventEnd:i.loadEventEnd,redirectCount:i.redirectCount,transferSize:i.transferSize,encodedBodySize:i.encodedBodySize,decodedBodySize:i.decodedBodySize}:void 0))}),s=u(i=>{const r=i;if(null===r.navigationType)return;const o=t.sanitizeUrl(location.href);o!==n&&e(Q("change",r.navigationType,{from:n,to:o},performance.timeOrigin))}),c=u(()=>f("traverse")),l=u(()=>f("hashchange"));function f(i){const r=t.sanitizeUrl(location.href);"hashchange"===i&&r===n||e(Q("change",i,{from:n,to:r},performance.timeOrigin))}const h=history.pushState,d=history.replaceState,v=function(...t){const n=h.apply(this,t);return a(()=>f("push")),n},p=function(...t){const n=d.apply(this,t);return a(()=>f("replace")),n};return window.navigation?i(window.navigation,"currententrychange",s):(history.pushState=v,history.replaceState=p,i(window,"popstate",c),i(window,"hashchange",l)),"complete"===document.readyState?o(new Event("load")):i(window,"load",o),()=>{window.navigation?r(window.navigation,"currententrychange",s):(history.pushState===v&&(history.pushState=h),history.replaceState===p&&(history.replaceState=d),r(window,"popstate",c),r(window,"hashchange",l)),r(window,"load",o)}},layer:"session"},networkconnection:{create:function(t){const n=u(()=>{const n={name:"network",type:"connection",state:navigator.onLine?"online":"offline",timestamp:Date.now()};t.push(n)});return i(window,"online",n),i(window,"offline",n),()=>{r(window,"online",n),r(window,"offline",n)}},layer:"session"},scroll:{create:function(t){let n=null,e=null;const o=u(e=>n?n.samples.ts.length>=50?(t.push(n),n=s(e),void a(t)):(n.samples.x.push(window.scrollX),n.samples.y.push(window.scrollY),n.samples.ts.push(e.timeStamp),void a(t)):(n=s(e),void a(t)));function s(t){return{name:"scroll",timestamp:Date.now(),samples:{x:[window.scrollX],y:[window.scrollY],ts:[t.timeStamp]},height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,pageX:window.pageXOffset,pageY:window.pageYOffset}}function a(t){e&&clearTimeout(e),e=setTimeout(()=>{n&&(t.push(n),n=null),e=null},y)}return i(window,"scroll",o),()=>{r(window,"scroll",o),e&&(clearTimeout(e),e=null),n&&(t.push(n),n=null)}},layer:"behavioral"},viewportresize:{create:function(t){let n=null,e=null;const o=u(e=>n?n.samples.ts.length>=50?(t.push(n),n=s(e),void a(t)):(n.samples.height.push(window.innerHeight),n.samples.width.push(window.innerWidth),n.samples.ts.push(e.timeStamp),n.samples.scrollX.push(window.scrollX),n.samples.scrollY.push(window.scrollY),n.samples.dpr.push(window.devicePixelRatio),void a(t)):(n=s(e),void a(t)));function s(t){return{name:"viewport",type:"resize",timestamp:Date.now(),samples:{height:[window.innerHeight],width:[window.innerWidth],ts:[t.timeStamp],scrollX:[window.scrollX],scrollY:[window.scrollY],dpr:[window.devicePixelRatio]}}}function a(t){e&&clearTimeout(e),e=setTimeout(()=>{n&&(t.push(n),n=null),e=null},y)}return i(window,"resize",o),()=>{r(window,"resize",o),e&&(clearTimeout(e),e=null),n&&(t.push(n),n=null)}},layer:"behavioral"},viewport:{create:function(t,n,e){const o=u(n=>{const e=a(n,"orientation");t.push(e)}),s=u(n=>{const e=a(n,"ratiochange");t.push(e)});function a(t,n){return{name:"viewport",type:n,timestamp:Date.now(),isTrusted:t.isTrusted,height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio}}return x(e,"orientationchange")&&i(window,"orientationchange",o),x(e,"devicepixelratiochange")&&i(window,"devicepixelratiochange",s),()=>{r(window,"orientationchange",o),r(window,"devicepixelratiochange",s)}},layer:"behavioral",events:["orientationchange","devicepixelratiochange"]},sensors:{create:function(t,n,e){let o=null,s=null,a=null,c=null,f=0;function d(){c&&h(c),c=setTimeout(l(()=>{v(),c=null}),y)}function v(){o&&(t.push(o),o=null),s&&(t.push(s),s=null),a&&(t.push(a),a=null)}const p=u(n=>{const e=n,i=e.timeStamp,r=e.acceleration,s=e.accelerationIncludingGravity,a=e.rotationRate;if(!r&&!s&&!a)return;if(!o)return o={name:"sensors",type:"motion",timestamp:Date.now(),interval:e.interval??null,samples:{ax:[r?.x??0],ay:[r?.y??0],az:[r?.z??0],agx:[s?.x??0],agy:[s?.y??0],agz:[s?.z??0],rrAlpha:[a?.alpha??0],rrBeta:[a?.beta??0],rrGamma:[a?.gamma??0],ts:[i]}},void d();if(o.samples.ts.length>=50)return t.push(o),o={name:"sensors",type:"motion",timestamp:Date.now(),interval:e.interval??null,samples:{ax:[r?.x??0],ay:[r?.y??0],az:[r?.z??0],agx:[s?.x??0],agy:[s?.y??0],agz:[s?.z??0],rrAlpha:[a?.alpha??0],rrBeta:[a?.beta??0],rrGamma:[a?.gamma??0],ts:[i]}},void d();const c=o.samples;c.ax.push(r?.x??0),c.ay.push(r?.y??0),c.az.push(r?.z??0),c.agx.push(s?.x??0),c.agy.push(s?.y??0),c.agz.push(s?.z??0),c.rrAlpha.push(a?.alpha??0),c.rrBeta.push(a?.beta??0),c.rrGamma.push(a?.gamma??0),c.ts.push(i),d()}),w=u(n=>{const e=n;if(null==e.alpha&&null==e.beta&&null==e.gamma)return;const i=e.timeStamp,r=e.webkitCompassHeading??0;if(!s)return s={name:"sensors",type:"orientation",timestamp:Date.now(),absolute:f||e.absolute,samples:{alpha:[e.alpha??0],beta:[e.beta??0],gamma:[e.gamma??0],compassHeading:[r],ts:[i]}},void d();if(s.samples.ts.length>=50)return t.push(s),s={name:"sensors",type:"orientation",timestamp:Date.now(),absolute:f||e.absolute,samples:{alpha:[e.alpha??0],beta:[e.beta??0],gamma:[e.gamma??0],compassHeading:[r],ts:[i]}},void d();const o=s.samples;o.alpha.push(e.alpha??0),o.beta.push(e.beta??0),o.gamma.push(e.gamma??0),o.compassHeading.push(r),o.ts.push(i),d()}),m=u(n=>{const e=n.value;if(null==e)return;const i=n.timeStamp;return a?a.samples.ts.length>=50?(t.push(a),a={name:"sensors",type:"light",timestamp:Date.now(),samples:{lux:[e],ts:[i]}},void d()):(a.samples.lux.push(e),a.samples.ts.push(i),void d()):(a={name:"sensors",type:"light",timestamp:Date.now(),samples:{lux:[e],ts:[i]}},void d())});return x(e,"motion")&&i(window,"devicemotion",p),x(e,"orientation")&&("ondeviceorientationabsolute"in window?(f=1,i(window,"deviceorientationabsolute",w)):i(window,"deviceorientation",w)),x(e,"light")&&i(window,"devicelight",m),function(){r(window,"devicemotion",p),r(window,f?"deviceorientationabsolute":"deviceorientation",w),r(window,"devicelight",m),c&&(h(c),c=null),v()}},layer:"behavioral",events:["motion","orientation","light"]},"network-request":{create:function(t){var n;const i=function(t,n,i,r=v){if("undefined"==typeof PerformanceObserver)return m;let o=null;try{o=new PerformanceObserver(e=>{for(const o of e.getEntries()){const e=o;r.has(e.initiatorType)&&(n(e.name)||t(w(e,i)))}}),o.observe({type:"resource",buffered:1})}catch{return e.warn("network-request","PerformanceObserver failed to start"),m}return function(){o?.disconnect(),o=null}}(function(n){a(()=>t.push(n))},(n=t.ignoredOrigins,function(t){try{return n.has(new URL(t).origin)}catch{return 0}}),t.sanitizeUrl);return function(){i()}},layer:"session"},screen:{create:function(t){const n=a(()=>function(){const t=window.screen;return{name:"screen",timestamp:Date.now(),availWidth:t.availWidth,availHeight:t.availHeight,width:t.width,height:t.height,colorDepth:t.colorDepth,pixelDepth:t.pixelDepth,availLeft:t.availLeft??0,availTop:t.availTop??0,orientation:t.orientation?{type:t.orientation.type,angle:t.orientation.angle}:null,isExtended:t.isExtended??0,viewport:{height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio}}}());return n&&t.push(n),()=>{}},layer:"session"}},tt=Object.keys(W),nt=[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,/^0b[01]+$/i,/^0o[0-7]+$/i,/^0x[0-9a-f]+$/i,/^[a-z][a-z0-9]{1,12}:[A-Za-z0-9+/=_-]{6,}$/i,/^[a-z]{2,8}_(?=.*\d)[A-Za-z0-9]{3,}$/,/^\d{4,}$/,/@/,/^[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{5,}\.[A-Za-z0-9_-]{10,}$/,/^[A-Za-z0-9_-]{20,}={0,2}$/,/^[0-9a-f]{7,}$/i];function et(t){try{const n=new URL(t,location.href);n.username="",n.password="",n.hash="";const e=[...n.searchParams.keys()],i=e.length>0?"?"+e.map(t=>`${encodeURIComponent(t)}=<redacted>`).join("&"):"";n.search="",n.pathname=n.pathname.split("/").map(t=>""!==t&&function(t){for(const n of nt)if(n.test(t))return 1;return 0}(t)?":param":t).join("/");const r=n.origin+n.pathname+i;return r.length>2048?r.slice(0,2048):r}catch{return""}}const it={flush:{intervalMs:2e3,maxIntervalMs:3e4,size:50,backoffFailureThreshold:2},queue:{size:100}};function rt(){const t={};for(const n of tt)t[n]=at(n,void 0,1);return t}function ot(t){const n={};for(const e of tt)n[e]=at(e,void 0,t[W[e].layer]??0);return n}function st(t){const n={};for(const e of tt){const i=t[e];n[e]=at(e,i,i?.enabled??0)}return n}function at(t,n,e){const i=W[t]?.events??[];if(0===i.length)return{enabled:e};const r=n?.events,o={};for(const t of i)o[t]={enabled:r?.[t]??1};return{enabled:e,events:o}}function ct(t){if(!t)return null;const n=t.split(".")[1],e=atob(n.replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(e)}const ut=function(t,n=30){if(!t)return 1;const e=ct(t);return e&&"number"==typeof e.exp?1e3*e.exp<=Date.now()+1e3*n:1};async function lt(t,n){return globalThis.navigator&&"locks"in globalThis.navigator&&"request"in globalThis.navigator.locks&&"query"in globalThis.navigator.locks?navigator.locks.request(t,{mode:"exclusive"},async()=>c(n)):c(n)}const ft="__tri",ht=`${ft}_activity_token`,dt=`${ft}_activity_id`,vt=`${ft}_activity_status`,pt="__tri_activity_lock";class wt{constructor(t){this.context=t,this.M=null,this.A=null,this.D=null,this.P=null,this.C=0}getToken(){return this.M}getActivityId(){return this.A??""}isActive(){return"ACTIVE"===this.D&&null!==this.M}async start(){return this.C=1,this.P||(this.P=this.U()),this.P}async stop(){this.C=0,this.L(null),this.P=null,this.M&&await this.context.stopActivity(),this.R(null)}async refresh(){if(!this.C)return;const t=this.M;await lt(pt,async()=>{if(this.M&&this.M!==t&&!ut(this.M)&&"ACTIVE"===this.D)return;const n=this.$();n&&n.token!==t&&!ut(n.token)&&"ACTIVE"===n.activityStatus?this.R(n):(this.O(),await this.B())})}async U(){try{if(this.M&&!ut(this.M))return;await lt(pt,async()=>{await this.B()})}finally{this.P=null}}async B(){const t=this.$();if(t&&!ut(t.token)&&"ACTIVE"===t.activityStatus)return void this.R(t);t&&this.O();const n=await this.context.startActivity();if(!n.ok)return;if(!n.data.token)return;const e=n.data;this.R(e),this.j(e)}$(){const[t,n,e]=[j.get(ht),j.get(dt),j.get(vt)];return t&&n&&e?{token:t,activityId:n,activityStatus:e}:((t||n||e)&&this.O(),null)}j(t){j.set(ht,t.token),j.set(dt,t.activityId),j.set(vt,t.activityStatus)}O(){this.L(null),this.R(null)}L(t){if(!t)return j.remove(ht),j.remove(dt),void j.remove(vt);j.set(ht,t.token),j.set(dt,t.activityId),j.set(vt,t.activityStatus)}R(t){if(!t)return this.M=null,this.A=null,void(this.D=null);this.M=t.token,this.A=t.activityId,this.D=t.activityStatus}}const mt=[401,403,409],yt=Object.freeze({tab:80,navigation:80,visibility:80,network:80,screen:80,fingerprint:80,pointer:60,keystroke:60,autofill:60,change:60,form:60,clipboard:60,selection:60,focus:60,viewport:60,network_request:60,scroll:40,sensors:40});function gt(t){return"pointer"===t.name&&"move"===t.phase||"viewport"===t.name&&"resize"===t.type?40:yt[t.name]}const bt=new Array(256);for(let t=0;t<256;t++)bt[t]=(t+256).toString(16).slice(1);const kt=new Uint8Array(16);function Tt(t){return bt[t[0]]+bt[t[1]]+bt[t[2]]+bt[t[3]]+"-"+bt[t[4]]+bt[t[5]]+"-"+bt[t[6]]+bt[t[7]]+"-"+bt[t[8]]+bt[t[9]]+"-"+bt[t[10]]+bt[t[11]]+bt[t[12]]+bt[t[13]]+bt[t[14]]+bt[t[15]]}function _t(){return crypto.randomUUID()}function It(){return crypto.getRandomValues(kt),kt[6]=15&kt[6]|64,kt[8]=63&kt[8]|128,Tt(kt)}function St(){for(let t=0;t<16;t++)kt[t]=256*Math.random()|0;return kt[6]=15&kt[6]|64,kt[8]=63&kt[8]|128,Tt(kt)}const xt=function(){if("undefined"!=typeof crypto){if("function"==typeof crypto.randomUUID)return _t;if("function"==typeof crypto.getRandomValues)return It}return St}();function Mt(){return xt()}class Et{constructor(t,n){this.q=t,this.F=n,this.H=[],this.N=null,this.X=[],this.K=null,this.C=0,this.V=1,this.Y=0,this.J=0,this.W=t.flush.intervalMs}push(t){if(this.C){if(this.H.length<this.tt()?this.H.push(t):this.nt(t),this.V)return this.H.length>=this.q.flush.size?(h(this.N),this.N=null,void this.flush("capacity")):void this.et()}else e.warn("Transport","push() called before start() — event dropped")}flush(t){if(this.C&&this.F.isActivityActive())try{if("lifecycle"===t)return void this.it();if(0===this.H.length)return;const n=this.rt(t);this.F.ingest(n,0).then(t=>this.ot(t,n)).catch(()=>{e.warn("Transport","ingest threw unexpectedly — batch dropped")}),this.H.length>0&&this.et()}catch(t){e.warn("Transport","flush() threw unexpectedly:",t)}}start(){this.C||(this.C=1,this.V="undefined"!=typeof navigator?navigator.onLine:1)}stop(){if(!this.C)return Promise.resolve();h(this.N),this.N=null,h(this.K),this.K=null;const t=this.it();return this.C=0,t}onConnectionChange(){const t="undefined"!=typeof navigator?navigator.onLine:1;if(t!==this.V){if(this.V=t,!this.V)return h(this.N),this.N=null,h(this.K),void(this.K=null);this.H.length>0&&this.et(),this.X.length>0&&this.st()}}et(){this.C&&this.V&&null===this.N&&(this.N=f(()=>{this.N=null,this.flush("interval")},this.W))}st(){this.C&&this.V&&null===this.K&&(this.K=f(()=>{this.K=null,this.ct()},this.W))}ct(){if(!this.C||!this.V||0===this.X.length||!this.F.isActivityActive())return;const t=this.X.shift();this.F.ingest(t.batch,0).then(n=>this.ut(n,t)).catch(()=>{e.warn("Transport","retry drain ingest threw unexpectedly — batch dropped"),this.X.length>0&&this.st()})}lt(t,n){this.X.length>=5&&(this.X.shift(),e.warn("Transport","retry queue full — oldest batch evicted")),this.X.push({batch:t,attempts:n}),this.st()}ot(t,n){t.ok?this.ft():this.ht(t)&&this.lt(n,1)}ut(t,n){if(t.ok)return this.ft(),void(this.X.length>0&&this.st());if(this.ht(t)){if(n.attempts>=3)return this.dt(),e.warn("Transport","batch dropped after MAX_RETRY_ATTEMPTS",n.batch.batchId),void(this.X.length>0&&this.st());this.dt(),this.lt(n.batch,n.attempts+1)}else this.X.length>0&&this.st()}dt(){this.Y++,this.Y%this.q.flush.backoffFailureThreshold===0&&(this.W=Math.min(2*this.W,this.q.flush.maxIntervalMs))}ft(){this.Y=0,this.W=this.q.flush.intervalMs}tt(){return this.q.queue.size*(this.V?1:2)}async it(){if(!this.F.isActivityActive())return Promise.resolve();const t=[];for(const n of this.X)t.push(this.F.ingest(n.batch,1).catch(()=>{e.warn("Transport","lifecycle retry ingest threw — batch dropped")}));if(this.X=[],this.H.length>0){const n=this.rt("lifecycle");t.push(this.F.ingest(n,1).catch(()=>{e.warn("Transport","lifecycle ingest threw — batch dropped")}))}return Promise.allSettled(t).then(()=>{})}nt(t){const n=gt(t);for(let e=0;e<this.H.length;e++)if(gt(this.H[e])<n){for(let t=e;t<this.H.length-1;t++)this.H[t]=this.H[t+1];return this.H.length-=1,void this.H.push(t)}}rt(t){const n="lifecycle"===t?this.H.splice(-this.q.flush.size):this.H.splice(0,this.q.flush.size);return{activityId:"",batchId:Mt(),batchSequence:this.J++,clientTimestamp:Date.now(),schemaVersion:"0.1.0",sdkVersion:"0.3.0",sdkPlatform:"web",tabId:this.F.getTabId(),events:n}}ht(t){if(t.ok)return 0;switch(t.kind){case"timeout":case"server":case"rate_limited":return 1;default:return 0}}}const At="tri:bcast:";const zt="function"==typeof BroadcastChannel?BroadcastChannel:function(){if("undefined"==typeof Storage||"undefined"==typeof window)return 0;try{const t="__tri_bcast_probe__";localStorage.setItem(t,"1");const n="1"===localStorage.getItem(t);return localStorage.removeItem(t),n}catch{return 0}}()?class{constructor(t){this.seq=0,this.closed=0,this.listeners=new Set,this.onStorageEvent=t=>{if(this.closed)return;if(!t.key||!t.key.startsWith(`${At}${this.channelName}:`))return;if(null===t.newValue)return;let n;a(()=>j.remove(t.key));try{n=JSON.parse(t.newValue)}catch{return}const e={data:n};for(const t of this.listeners)a(()=>t(e))},this.channelName=t,this.senderId=Mt(),window.addEventListener("storage",this.onStorageEvent)}postMessage(t){if(this.closed)return;const n=`${At}${this.channelName}:${this.senderId}:${this.seq++}`;a(()=>{j.set(n,t),j.remove(n)})}addEventListener(t,n){this.listeners.add(n)}removeEventListener(t,n){this.listeners.delete(n)}close(){this.closed||(this.closed=1,window.removeEventListener("storage",this.onStorageEvent),this.listeners.clear())}}:class{constructor(t){e.warn("BroadcastChannel","BroadcastChannel is unavailable and localStorage is not writable in this context. Cross-tab discovery is disabled; tab count will always be reported as 1.")}postMessage(t){}addEventListener(t,n){}removeEventListener(t,n){}close(){}},Dt="__tri_tabId";class Pt{constructor(t){this.context=t,this.vt="",this.C=0,this.wt=null,this.yt=null,this.gt=null,this.bt=new Map,this.kt=-1,this.Tt=null}async start(){this.C||(this.C=1,this.vt=this._t(),this.It(),this.St({type:"hello",tabId:this.vt,ts:Date.now()}),this.xt(),this.Mt("active"),this.Et())}stop(){this.C&&(this.C=0,this.Mt("inactive"),this.St({type:"bye",tabId:this.vt,ts:Date.now()}),this.At(this.zt()),this.Dt(),this.Pt(),this.Ct())}getTabId(){return this.vt}queryTabsNumber(){return this.bt.size+1}It(){try{this.wt=new zt("__tri_tab_channel"),this.Tt=this.Ut.bind(this),this.wt.addEventListener("message",this.Tt)}catch(t){e.warn("TabManager","failed to open broadcast channel:",t)}}Ct(){try{if(!this.wt)return;this.Tt&&this.wt.removeEventListener("message",this.Tt),this.wt.close()}catch{}finally{this.wt=null,this.Tt=null}}xt(){this.yt=setInterval(()=>{const t=Date.now();this.St({type:"heartbeat",tabId:this.vt,ts:t})},1e3)}Dt(){null!=this.yt&&(clearInterval(this.yt),this.yt=null)}Et(){null!=this.gt&&clearTimeout(this.gt),this.gt=setTimeout(()=>{this.gt=null;const t=this.zt()+1;t!==this.kt&&(this.kt=t,this.At(t))},1e3)}Pt(){null!=this.gt&&(clearTimeout(this.gt),this.gt=null)}St(t){try{if(!this.wt)return;this.wt.postMessage(t)}catch{e.warn("TabManager","failed to broadcast message:",t)}}Ut(t){const{type:n,tabId:e}=t.data;if(e===this.vt)return;const i=Date.now();"hello"===n?(this.St({type:"ack",tabId:this.vt,ts:i,to:e}),this.bt.set(e,i)):"heartbeat"===n||"ack"===n?this.bt.set(e,i):"bye"===n&&this.bt.delete(e)}At(t){this.context.events.count&&this.context.push({name:"tab",type:"count",tabId:this.vt,timestamp:Date.now(),value:t})}Mt(t){this.context.events.state&&this.context.push({name:"tab",type:"state",tabId:this.vt,timestamp:Date.now(),value:t})}_t(){const t=q.get(Dt);if(t)return t;const n=Mt();return q.set(Dt,n),n}zt(t=Date.now()){let n=0;for(const[e,i]of this.bt.entries())t-i>=3e3?this.bt.delete(e):n++;return n}}const Ct=globalThis.CompressionStream,Ut=globalThis.Response,Lt=globalThis.Blob,Rt=new TextEncoder;let $t=null;async function Ot(t){const n=await async function(t){if("function"!=typeof Ct)return null;try{const n=Rt.encode(t),e=new Lt([n]).stream().pipeThrough(new Ct("gzip"));return await new Ut(e).arrayBuffer()}catch(t){return e.warn("compression","Native gzip failed:",t),null}}(t);return null!==n?n:async function(t){try{const n=await function(){if(null===$t){const t=function(t,n=1e4){let i=null;const r=new Promise(t=>{i=f(()=>{e.warn("import",`Import timed out after ${n}ms`),t(null)},n)}),o=Promise.resolve().then(t).catch(t=>(e.warn("import","Import failed:",t),null));return Promise.race([o,r]).finally(()=>{h(i)})}(()=>Promise.resolve().then(function(){return Ti}),1e4);$t=t,t.then(n=>{null===n&&f(()=>{$t===t&&($t=null)},1e4)})}return $t}();if(null===n)return null;const{gzipSync:i}=n,r=i(Rt.encode(t));return r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength)}catch(t){return e.warn("compression","fflate gzip failed:",t),null}}(t)}function Bt(t){const n={Accept:"application/json"};return t?.hasBody&&("json"===t.contentType?n["Content-Type"]="application/json":"ndjson"===t.contentType&&(n["Content-Type"]="application/x-ndjson"),"gzip"===t.contentEncoding&&(n["Content-Encoding"]="gzip")),t?.token&&(n.Authorization=`Bearer ${t.token}`),t?.profileId&&(n["x-profile-id"]=t.profileId),t?.api?.version&&(n["x-api-version"]=t.api.version),t?.customHeaders&&Object.entries(t.customHeaders).forEach(([t,e])=>{n[t]=e}),n}const jt="function"==typeof globalThis.fetch?globalThis.fetch.bind(globalThis):void 0;class qt{constructor(t){this.context=t}stop(){}async report(t,n){const i={name:t,metadata:n,timestamp:Date.now(),activityId:this.context.getActivityId()??""};try{const r=await this.context.reportEvent(i);if(r.ok)return r;e.warn("EventReport","Failed to report event:",t,n,"with result:",r)}catch(i){e.warn("EventReport","Failed to report event:",t,n,"with error:",i)}}}const Ft=new Set(["A","BUTTON","INPUT","SELECT","TEXTAREA","SUMMARY","DETAILS","LABEL","OPTION","FIELDSET"]),Ht=new Set(["button","link","tab","menuitem","menuitemcheckbox","menuitemradio","checkbox","radio","switch","slider","spinbutton","combobox","listbox","option","searchbox","textbox","treeitem"]),Nt=255;function Zt(t,n,e){const i=t.tagName.toLowerCase(),r=function(t){const n=t.parentElement?.children??[],e=Math.min(n.length,1e3);let i=e-1,r=0,o=0;for(let i=0;i<e;i++){o++;const e=n[i];if(b(e,t.tagName)&&r++,e===t)break}return{siblings:i,ofType:r,child:o}}(t),o=function(t,n){const e=function(t){if(!t)return null;const n=t.getAttribute("data-tri-redact-attrs");return n?n.split(",").map(t=>t.trim().toLowerCase()):null}(t),i={},r=t.id;r&&!I("id",e)&&(i.id=r);const o=t.getAttribute("autocomplete");o&&!I("autocomplete",e)&&(i.autocomplete=o);const s=t.getAttribute("aria-invalid");s&&!I("aria-invalid",e)&&(i.ariaInvalid=s);const a=t.getAttribute("tabindex");a&&!I("tabindex",e)&&(i.tabIndex=parseInt(a,10));const c=function(t){return t.getAttribute("data-testid")??t.getAttribute("data-cy")??null}(t);c&&!I("data-testid",e)&&(i.testId=c);const u=t.hasAttribute("readonly");u&&!I("readonly",e)&&(i.readOnly=u);const l=t.hasAttribute("required");l&&!I("required",e)&&(i.required=l);const f=t.getAttribute("contenteditable");f&&!I("contenteditable",e)&&(i.contentEditable="true"===f||""===f);const h=t.getAttribute("href");h&&!I("href",e)&&(i.href={...n?{}:{url:h},external:S(h)});const d=t.getAttribute("role");d&&!I("role",e)&&(i.role=d);const v=t.getAttribute("type");v&&!I("type",e)&&(i.type=v);const p=t.getAttribute("name");p&&!I("name",e)&&(i.name=p);const w=t.getAttribute("placeholder");!w||n||I("placeholder",e)||(i.placeholder=w);const m=Array.from(t.classList).slice(0,5);m.length>0&&!I("class",e)&&(i.classes=m);const y=t.getAttribute("alt");return!y||n||I("alt",e)||(i.alt=y),Object.keys(i).length?i:null}(t,n);return{tagName:i,frame:e,...o?{attributes:o}:{},...r?{nth:r}:{}}}function Xt(t,n){let e=0;const i=[];return function(t){return Ft.has(t.tagName)}(t)&&(e+=40,i.push("native")),function(t){return t.hasAttribute("data-tri-interactive")}(t)&&(e+=40,i.push("tri-interactive")),function(t){return b(t,"a")&&t.hasAttribute("href")}(t)&&(e+=15,i.push("has-href")),function(t){const n=t.getAttribute("role");return null!==n&&Ht.has(n)}(t)&&(e+=30,i.push("role")),function(t){return t.hasAttribute("onclick")||t.hasAttribute("ng-click")||t.hasAttribute("data-action")||t.hasAttribute("@click")}(t)&&(e+=20,i.push("click-handler")),function(t){const n=t.getAttribute("tabindex");if(null===n)return 0;const e=parseInt(n,10);return null!==e&&e>=0}(t)&&(e+=10,i.push("tabindex")),(t.id||t.getAttribute("data-testid"))&&(e+=5,i.push("has-id")),n>0&&(e+=Math.round(15/n),i.push("depth")),{score:e,reasons:i}}function Gt(t){return t>=20}function Kt(t){return null!==t&&t.width>0&&t.height>0&&t.y<window.innerHeight&&t.y+t.height>0&&t.x<window.innerWidth&&t.x+t.width>0}function Vt(t){return 1==t.disabled||"true"===t.getAttribute("aria-disabled")}function Yt(t,n=0){if(n)return null;const e=Qt(t,"labelledby");if(e)return{text:tn(e),resolutionMethod:"aria-labelledby",confidence:"high"};const i=Wt(t);if(i)return{text:tn(i),resolutionMethod:"aria-label",confidence:"high"};const r=function(t){if(!t.id)return null;const n=document.querySelector(`label[for="${CSS.escape(t.id)}"]`);return n?Jt(n):null}(t);if(r)return{text:tn(r),resolutionMethod:"html-for",confidence:"high"};const o=function(t){const n=t.closest("label");return n?Jt(n):null}(t);if(o)return{text:tn(o),resolutionMethod:"wrapping-label",confidence:"high"};const s=function(t){const n=t.getAttribute("placeholder");return n?.trim()??null}(t);if(s)return{text:tn(s),resolutionMethod:"placeholder",confidence:"low"};const a=function(t){const n=t.getAttribute("title");return n?.trim()??null}(t);if(a)return{text:tn(a),resolutionMethod:"title",confidence:"low"};const c=Qt(t,"describedby");if(c)return{text:tn(c),resolutionMethod:"aria-describedby",confidence:"low"};const u=Jt(t);return u?{text:u,resolutionMethod:"text-content",confidence:"low"}:null}function Jt(t,n=0){if(n>8)return"";if(g(t))return function(t){return t?t.trim().split(/(\s+)/).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,Nt):null}(t.textContent)??"";if(!t.childNodes?.length)return"";let e="";for(const i of t.childNodes){const t=Jt(i,n+1);if(t&&(e=e?`${e} ${t}`:t,e.length>=Nt))break}return tn(e)}function Qt(t,n){const e="labelledby"===n?"aria-labelledby":"aria-describedby",i=t?.getAttribute(e);if(!i)return null;const r=i.split(/\s+/),o=[];for(const t of r){const n=document.getElementById(t);if(!n)continue;const e=Wt(n)??Jt(n);e.length&&o.push(e)}return o.length?o.join(" "):null}function Wt(t){return t?.getAttribute("aria-label")?.trim()??null}function tn(t){return t.length>Nt?t.slice(0,Nt)+"...":t}function nn(t){const n=t.getBoundingClientRect();return{x:n.x,y:n.y,width:n.width,height:n.height}}class en{constructor(t){this.capacity=t,this.cache=new Map}get(t){return this.cache.get(t)}set(t,n){if(this.cache.has(t))this.cache.delete(t);else if(this.cache.size>=this.capacity){const t=this.cache.keys().next().value;t&&this.cache.delete(t)}this.cache.set(t,n)}delete(t){this.cache.delete(t)}clear(){this.cache.clear()}size(){return this.cache.size}}async function rn(t,n){const{collectors:o,sdk:s}=t;let a=null,c=null,l=null,d=null;try{a=function(t){"undefined"!=typeof document&&"function"==typeof globalThis.fetch||e.warn("FalconService","createFalconServiceManager called in a non-browser environment — all requests will resolve with { ok: false, kind: 'network' }.");const n=function(t){const n=t?.timeout,e=t?.baseUrl??"",i=t?.api;async function r(t,r,o){if(void 0===jt)return{ok:0,kind:"network"};const s=e?`${e}${r}`:r,a=new AbortController;let c=null,u=0;c=f(()=>{u=1,a.abort()},n);const l=o?.signal;let d,v=()=>{};if(l)if(l.aborted)a.abort();else{const t=()=>a.abort();l.addEventListener("abort",t,{once:1}),v=()=>l.removeEventListener("abort",t)}if(null!=o&&"body"in o&&null!=o.body){const t=function(t){if(null==t)return{ok:1,body:void 0};if("string"==typeof t||t instanceof ArrayBuffer||ArrayBuffer.isView(t)||t instanceof Blob||t instanceof FormData||t instanceof URLSearchParams||t instanceof ReadableStream)return{ok:1,body:t};try{return{ok:1,body:JSON.stringify(t)}}catch{return{ok:0}}}(o.body);if(!t.ok)return h(c),v(),{ok:0,kind:"serialize"};d=t.body}try{const n=await jt(s,{method:t,headers:Bt({token:o?.token,profileId:o?.profileId,contentType:o?.contentType,contentEncoding:o?.contentEncoding,api:i,hasBody:void 0!==d,customHeaders:o?.customHeaders}),body:d,signal:a.signal,keepalive:o?.keepalive});if(!n.ok)return 429===(p=n.status)?{ok:0,kind:"rate_limited",status:p}:p>=400&&p<500?{ok:0,kind:"client",status:p}:{ok:0,kind:"server",status:p};if(204===n.status)return{ok:1,data:void 0,status:204};try{return{ok:1,data:await n.json(),status:n.status}}catch{return a.signal.aborted?u?{ok:0,kind:"timeout"}:{ok:0,kind:"abort"}:{ok:0,kind:"parse",status:n.status}}}catch{return u?{ok:0,kind:"timeout"}:a.signal.aborted?{ok:0,kind:"abort"}:{ok:0,kind:"network"}}finally{h(c),v()}var p}return{post:async function(t,n){return r("POST",t,n)},get:async function(t,n){return r("GET",t,n)}}}({baseUrl:`${t.api.url}/api/v1`,timeout:1e4,api:{version:t.api.version}}),i=function(t){const{getToken:n,refresh:i}=t;let r=null;return{withAuth:async function(t,o){if(r){const n=await r;if(n)return t(n)}const s=n()??"",a=await t(s);if((c=a).ok||"client"!==c.kind||!mt.includes(c.status)||0==o?.refreshable)return a;var c;const u=await(r||(r=async function(){try{return await i(),n()}catch(t){return e.warn("AuthMiddleware","auth refresh failed",t),null}}().finally(()=>{r=null}),r));return u&&u!==s?t(u):a}}}(t),r=()=>({profileId:t.getProfileId()??void 0});return{api:{ingest:async function(e,o){return i.withAuth(async i=>{const{events:s,...a}=e,c={...a,activityId:t.getActivityId()};let u;try{u=await async function(t,n){const e=function(t,n){const e=[JSON.stringify(t)];for(let t=0;t<n.length;t++)try{e.push(JSON.stringify(n[t]))}catch{}return e.join("\n")}(t,n),i=await Ot(e);return i?{type:"gzip",body:i}:{type:"ndjson",body:e}}(c,s)}catch{return{ok:0,kind:"serialize"}}return n.post("/events/capture",{body:u.body,token:i,keepalive:o,contentType:"ndjson",contentEncoding:"gzip"===u.type?"gzip":void 0,...r()})},{refreshable:!o})},reportEvent:async function(t){return i.withAuth(e=>n.post("/events/report-event",{body:t,token:e,contentType:"json",...r()}))},startActivity:async function(){return n.post("/events/start-activity",{token:t.getSdkToken(),...r()})},stopActivity:async function(){return i.withAuth(t=>n.post("/events/end-activity",{token:t,keepalive:1,...r()}),{refreshable:0})},collectionStatus:async function(){return n.get("/sdk/collection-status",{token:t.getSdkToken(),...r()})},linkInterview:async function(t){return i.withAuth(e=>n.post("/events/link-interview",{token:e,contentType:"json",...r(),customHeaders:{"X-Incode-Hardware-Id":t}}))}}}}({api:{version:s.api.version,url:s.api.url},getSdkToken:()=>s.token,getProfileId:()=>n.getProfileId(),getToken:()=>c?.getToken()??null,refresh:async()=>c?.refresh()??Promise.resolve(),getActivityId:()=>c?.getActivityId()??""});const t=await a.api.collectionStatus();if(!t.ok||1!=t.data.eventsCollectionEnabled)return{status:"collection-disabled"};c=new wt({startActivity:()=>a.api.startActivity(),stopActivity:()=>a.api.stopActivity()}),l=new Et(it,{ingest:(t,n)=>a.api.ingest(t,n),getTabId:()=>d?.getTabId()??"unknown",isActivityActive:()=>c?.isActive()??0});const v=o.tab;d=new Pt({push:t=>l?.push(t),events:{state:v.enabled&&v.events.state.enabled,count:v.enabled&&v.events.count.enabled}});const p=function(t){function n(n){"hidden"===document.visibilityState&&t.flush()}function e(n){t.flush(),t.stopTab(),t.getShouldSkipStopActivity()||t.stopActivity()}const o=u(()=>t.onConnectionChange());return{start:function(){i(document,"visibilitychange",n),i(window,"pagehide",e),i(window,"online",o),i(window,"offline",o)},stop:function(){r(document,"visibilitychange",n),r(window,"pagehide",e),r(window,"online",o),r(window,"offline",o)}}}({flush:()=>l?.flush("lifecycle"),stopActivity:async()=>c?.stop(),stopTab:()=>d?.stop(),getShouldSkipStopActivity:()=>(d?.queryTabsNumber()??0)>1,onConnectionChange:()=>l?.onConnectionChange()}),w=function(t){const n=t||"redact",e=new en(6),i=new en(6);return{resolve:function(t){if(!t||T(t)||"off"===n)return null;let r=e.get(t);if(r||(r=function(t){if(!t||T(t))return{chain:[],redaction:{level:"ignore",index:-1}};const n=[];let e=t,i=-1;for(;e;){if(T(e))return{chain:[],redaction:{level:"ignore",index:-1}};_(e)&&(i=n.length),n.push(e);const t=e.parentNode;if(!t||b(e,"body"))break;e=k(t)?t.host:t}return{chain:n,redaction:{level:-1===i?"full":"redact",index:i}}}(t.parentElement),e.set(t,r)),"ignore"===r.redaction.level)return null;const o="redact"===r.redaction.level||"redact"===n||_(t);let s=i.get(t);return s||(s=function(t,n,e,i){const r=getComputedStyle(t),o=nn(t),s=function(t,n){const e=[],i=[];for(let r=t.length-1;r>=0;r--){const o=t[r],s=r<=n,a=r+1,c=Zt(o,s,nn(o)),{score:u,reasons:l}=Xt(o,a);if(e.push(c),!Gt(u))continue;const f=Yt(o,s);i.push({...c,...f?{label:f}:{},depth:a,score:u,reasons:l})}return{ancestors:e,interactiveCandidates:i.reverse()}}(n,i),a=Zt(t,e,o),c=function(t,n,e){const{score:i,reasons:r}=Xt(t,0);return{interactive:Gt(i),...r.length>0?{reasons:r}:{},disabled:Vt(t),rendered:"none"!==n?.display,visible:"hidden"!==n?.visibility,inViewport:Kt(e),acceptsPointer:"none"!==n?.pointerEvents,opacity:parseFloat(n?.opacity||"1")}}(t,r,o);let u=null;return e||(u=c.interactive?Yt(t):null),{tagName:a.tagName,frame:a.frame,viewport:{height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio},attributes:a.attributes,nth:a.nth,...u?{label:u}:{},ancestors:s.ancestors,interactiveCandidates:s.interactiveCandidates,interactivity:c}}(t,r.chain,o,r.redaction.index),i.set(t,s)),s}}}(s.capture?.element),m=new Set;try{m.add(new URL(s.api.url).origin)}catch{}const y=function(t,n,e="on"){const i=new Map;function r(r){if(i.has(r))return;const o=W[r];if(!o||!function(t,n){return n[t]?.enabled??0}(r,n))return;const s=n[r],a=o.create(t,e,s&&"events"in s?s.events:void 0);i.set(r,a)}return{start:r,stopCollector:function(t){const n=i.get(t);n&&(n(),i.delete(t))},stop:function(){for(const[,t]of i)t();i.clear()},isRunning:function(t){return i.has(t)},autocapture:function(){for(const t of tt)r(t)}}}({push:t=>l?.push(t),resolveElement:t=>w.resolve(t),sanitizeUrl:s.sanitizeUrl,ignoredOrigins:m},o,s.capture?.content),g=new qt({getActivityId:()=>c?.getActivityId()??"",reportEvent:t=>a.api.reportEvent(t)});return{status:"ready",managers:{falconServiceManager:a,activityManager:c,transportManager:l,tabManager:d,lifecycleManager:p,collectorManager:y,eventReportManager:g}}}catch(t){return e.warn("IncodeTRI","setup() failed during construction:",t),{status:"init-failed"}}}let on=class t{constructor(){this.Lt=0,this.q=null,this.Rt=null,this.$t="idle"}static get instance(){return t._||(t._=new t),t._}async setup(t){if("idle"!==this.$t)return e.fatal("error","setup()","called more than once — ignoring."),"init-failed";try{const n=function(t){if("undefined"==typeof document)return e.fatal("error","IncodeTRI","TRI is not available in a non-browser environment."),null;if(!t?.token)return e.fatal("error","SDK","token is required."),null;if(!t.apiURL)return e.fatal("error","SDK","Couldn't initialise SDK — apiURL isn't provided."),null;const{element:n,content:i}=t.capture??{},r={token:t.token,capture:{element:n??"redact",content:i??"off"},profileId:t.profileId,api:{version:t.apiVersion??"1.0",url:t.apiURL},sanitizeUrl:(o=t.sanitizeUrl,o?function(t){return a(()=>o(t,et))??et(t)}:et),DEBUG:t.DEBUG??0};var o;return void 0===t.collectors&&void 0===t.layers?{sdk:r,collectors:rt()}:void 0!==t.collectors?{sdk:r,collectors:st(t.collectors)}:{sdk:r,collectors:ot(t.layers)}}(t);if(!n)return"init-failed";e.DEBUG=n.sdk.DEBUG;const i=await rn(n,{getProfileId:()=>this.Ot()});return"collection-disabled"===i.status?(e.fatal("warn","setup()","Collection is disabled for the provided API Key."),"collection-disabled"):"init-failed"===i.status?"init-failed":(this.q=n,this.Rt=i.managers,this.$t="ready",this.Bt(n.sdk.profileId),"ready")}catch(t){return e.warn("setup()","failed:",t),"init-failed"}}async start(){if("idle"===this.$t)return e.warn("start()","start() requires a prior successful setup() — ignoring."),this.$t;if("ready"!==this.$t)return e.fatal("warn","start()","TRI is either already started or isn't ready — ignoring."),this.$t;this.$t="starting";const t=++this.Lt;return await this.U(t),this.$t}async stop(){e.warn("stop()","called");const t=this.Rt;return t?(++this.Lt,t.lifecycleManager.stop(),t.collectorManager.stop(),t.tabManager.stop(),t.eventReportManager.stop(),this.$t="ready",this.jt(t)):Promise.resolve(this.$t)}async reset(){const t=this.stop();return this.$t="idle",this.q=null,this.Rt=null,j.remove("__tri_profile_id"),t.then(()=>this.$t)}async jt(t){return await function(t){let n=null;const e=new Promise(t=>{n=f(t,2e3)});return Promise.race([t.finally(()=>h(n)),e])}(Promise.resolve(t.transportManager.stop())),await t.activityManager.stop(),this.$t}reportEvent(t,n){"started"===this.$t?this.Rt?c(()=>this.Rt.eventReportManager.report(t,n)):e.warn("reportEvent()","reportEvent() called but managers are unavailable — dropping event."):e.warn("reportEvent()","reportEvent() called before start() completed — dropping event.")}setProfileId(t){"started"===this.$t?this.q?.sdk&&(this.q.sdk.profileId=t,this.Bt(t)):e.warn("setProfileId()","setProfileId() called before start() completed — ignoring.")}async linkInterview(t){if("started"!==this.$t||!this.Rt)return e.warn("linkInterview()","linkInterview() called before start() completed — ignoring."),0;if(!t)return e.warn("linkInterview()","linkInterview() called without sessionToken — ignoring."),0;try{return(await this.Rt.falconServiceManager.api.linkInterview(t)).ok}catch(t){return e.warn("linkInterview()","failed:",t),0}}Ot(){return this.q?.sdk?.profileId??j.get("__tri_profile_id")??null}Bt(t){t&&j.set("__tri_profile_id",t)}async U(t){const n=this.Rt;if(n){try{if(await n.activityManager.start(),t!==this.Lt)return;if(n.transportManager.start(),await n.tabManager.start(),t!==this.Lt)return;n.lifecycleManager.start(),n.collectorManager.autocapture()}catch(n){return e.warn("start()","failed during monitoring start:",n),void(t===this.Lt&&(this.$t="ready"))}t===this.Lt&&(this.$t="started")}}};on._=null;const sn=on.instance;var an={},cn=Uint8Array,un=Uint16Array,ln=Int32Array,fn=new cn([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),hn=new cn([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),dn=new cn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),vn=function(t,n){for(var e=new un(31),i=0;i<31;++i)e[i]=n+=1<<t[i-1];var r=new ln(e[30]);for(i=1;i<30;++i)for(var o=e[i];o<e[i+1];++o)r[o]=o-e[i]<<5|i;return{b:e,r:r}},pn=vn(fn,2),wn=pn.b,mn=pn.r;wn[28]=258,mn[258]=28;for(var yn=vn(hn,0),gn=yn.b,bn=yn.r,kn=new un(32768),Tn=0;Tn<32768;++Tn){var _n=(43690&Tn)>>1|(21845&Tn)<<1;kn[Tn]=((65280&(_n=(61680&(_n=(52428&_n)>>2|(13107&_n)<<2))>>4|(3855&_n)<<4))>>8|(255&_n)<<8)>>1}var In=function(t,n,e){for(var i=t.length,r=0,o=new un(n);r<i;++r)t[r]&&++o[t[r]-1];var s,a=new un(n);for(r=1;r<n;++r)a[r]=a[r-1]+o[r-1]<<1;if(e){s=new un(1<<n);var c=15-n;for(r=0;r<i;++r)if(t[r])for(var u=r<<4|t[r],l=n-t[r],f=a[t[r]-1]++<<l,h=f|(1<<l)-1;f<=h;++f)s[kn[f]>>c]=u}else for(s=new un(i),r=0;r<i;++r)t[r]&&(s[r]=kn[a[t[r]-1]++]>>15-t[r]);return s},Sn=new cn(288);for(Tn=0;Tn<144;++Tn)Sn[Tn]=8;for(Tn=144;Tn<256;++Tn)Sn[Tn]=9;for(Tn=256;Tn<280;++Tn)Sn[Tn]=7;for(Tn=280;Tn<288;++Tn)Sn[Tn]=8;var xn=new cn(32);for(Tn=0;Tn<32;++Tn)xn[Tn]=5;var Mn=In(Sn,9,0),En=In(Sn,9,1),An=In(xn,5,0),zn=In(xn,5,1),Dn=function(t){for(var n=t[0],e=1;e<t.length;++e)t[e]>n&&(n=t[e]);return n},Pn=function(t,n,e){var i=n/8|0;return(t[i]|t[i+1]<<8)>>(7&n)&e},Cn=function(t,n){var e=n/8|0;return(t[e]|t[e+1]<<8|t[e+2]<<16)>>(7&n)},Un=function(t){return(t+7)/8|0},Ln=function(t,n,e){return(null==n||n<0)&&(n=0),(null==e||e>t.length)&&(e=t.length),new cn(t.subarray(n,e))},Rn=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],$n=function(t,n,e){var i=new Error(n||Rn[t]);if(i.code=t,Error.captureStackTrace&&Error.captureStackTrace(i,$n),!e)throw i;return i},On=function(t,n,e,i){var r=t.length,o=i?i.length:0;if(!r||n.f&&!n.l)return e||new cn(0);var s=!e,a=s||2!=n.i,c=n.i;s&&(e=new cn(3*r));var u=function(t){var n=e.length;if(t>n){var i=new cn(Math.max(2*n,t));i.set(e),e=i}},l=n.f||0,f=n.p||0,h=n.b||0,d=n.l,v=n.d,p=n.m,w=n.n,m=8*r;do{if(!d){l=Pn(t,f,1);var y=Pn(t,f+1,3);if(f+=3,!y){var g=t[(z=Un(f)+4)-4]|t[z-3]<<8,b=z+g;if(b>r){c&&$n(0);break}a&&u(h+g),e.set(t.subarray(z,b),h),n.b=h+=g,n.p=f=8*b,n.f=l;continue}if(1==y)d=En,v=zn,p=9,w=5;else if(2==y){var k=Pn(t,f,31)+257,T=Pn(t,f+10,15)+4,_=k+Pn(t,f+5,31)+1;f+=14;for(var I=new cn(_),S=new cn(19),x=0;x<T;++x)S[dn[x]]=Pn(t,f+3*x,7);f+=3*T;var M=Dn(S),E=(1<<M)-1,A=In(S,M,1);for(x=0;x<_;){var z,D=A[Pn(t,f,E)];if(f+=15&D,(z=D>>4)<16)I[x++]=z;else{var P=0,C=0;for(16==z?(C=3+Pn(t,f,3),f+=2,P=I[x-1]):17==z?(C=3+Pn(t,f,7),f+=3):18==z&&(C=11+Pn(t,f,127),f+=7);C--;)I[x++]=P}}var U=I.subarray(0,k),L=I.subarray(k);p=Dn(U),w=Dn(L),d=In(U,p,1),v=In(L,w,1)}else $n(1);if(f>m){c&&$n(0);break}}a&&u(h+131072);for(var R=(1<<p)-1,$=(1<<w)-1,O=f;;O=f){var B=(P=d[Cn(t,f)&R])>>4;if((f+=15&P)>m){c&&$n(0);break}if(P||$n(2),B<256)e[h++]=B;else{if(256==B){O=f,d=null;break}var j=B-254;B>264&&(j=Pn(t,f,(1<<(H=fn[x=B-257]))-1)+wn[x],f+=H);var q=v[Cn(t,f)&$],F=q>>4;if(q||$n(3),f+=15&q,L=gn[F],F>3){var H=hn[F];L+=Cn(t,f)&(1<<H)-1,f+=H}if(f>m){c&&$n(0);break}a&&u(h+131072);var N=h+j;if(h<L){var Z=o-L,X=Math.min(L,N);for(Z+h<0&&$n(3);h<X;++h)e[h]=i[Z+h]}for(;h<N;++h)e[h]=e[h-L]}}n.l=d,n.p=O,n.b=h,n.f=l,d&&(l=1,n.m=p,n.d=v,n.n=w)}while(!l);return h!=e.length&&s?Ln(e,0,h):e.subarray(0,h)},Bn=function(t,n,e){var i=n/8|0;t[i]|=e<<=7&n,t[i+1]|=e>>8},jn=function(t,n,e){var i=n/8|0;t[i]|=e<<=7&n,t[i+1]|=e>>8,t[i+2]|=e>>16},qn=function(t,n){for(var e=[],i=0;i<t.length;++i)t[i]&&e.push({s:i,f:t[i]});var r=e.length,o=e.slice();if(!r)return{t:Kn,l:0};if(1==r){var s=new cn(e[0].s+1);return s[e[0].s]=1,{t:s,l:1}}e.sort(function(t,n){return t.f-n.f}),e.push({s:-1,f:25001});var a=e[0],c=e[1],u=0,l=1,f=2;for(e[0]={s:-1,f:a.f+c.f,l:a,r:c};l!=r-1;)a=e[e[u].f<e[f].f?u++:f++],c=e[u!=l&&e[u].f<e[f].f?u++:f++],e[l++]={s:-1,f:a.f+c.f,l:a,r:c};var h=o[0].s;for(i=1;i<r;++i)o[i].s>h&&(h=o[i].s);var d=new un(h+1),v=Fn(e[l-1],d,0);if(v>n){i=0;var p=0,w=v-n,m=1<<w;for(o.sort(function(t,n){return d[n.s]-d[t.s]||t.f-n.f});i<r;++i){var y=o[i].s;if(!(d[y]>n))break;p+=m-(1<<v-d[y]),d[y]=n}for(p>>=w;p>0;){var g=o[i].s;d[g]<n?p-=1<<n-d[g]++-1:++i}for(;i>=0&&p;--i){var b=o[i].s;d[b]==n&&(--d[b],++p)}v=n}return{t:new cn(d),l:v}},Fn=function(t,n,e){return-1==t.s?Math.max(Fn(t.l,n,e+1),Fn(t.r,n,e+1)):n[t.s]=e},Hn=function(t){for(var n=t.length;n&&!t[--n];);for(var e=new un(++n),i=0,r=t[0],o=1,s=function(t){e[i++]=t},a=1;a<=n;++a)if(t[a]==r&&a!=n)++o;else{if(!r&&o>2){for(;o>138;o-=138)s(32754);o>2&&(s(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(s(r),--o;o>6;o-=6)s(8304);o>2&&(s(o-3<<5|8208),o=0)}for(;o--;)s(r);o=1,r=t[a]}return{c:e.subarray(0,i),n:n}},Nn=function(t,n){for(var e=0,i=0;i<n.length;++i)e+=t[i]*n[i];return e},Zn=function(t,n,e){var i=e.length,r=Un(n+2);t[r]=255&i,t[r+1]=i>>8,t[r+2]=255^t[r],t[r+3]=255^t[r+1];for(var o=0;o<i;++o)t[r+o+4]=e[o];return 8*(r+4+i)},Xn=function(t,n,e,i,r,o,s,a,c,u,l){Bn(n,l++,e),++r[256];for(var f=qn(r,15),h=f.t,d=f.l,v=qn(o,15),p=v.t,w=v.l,m=Hn(h),y=m.c,g=m.n,b=Hn(p),k=b.c,T=b.n,_=new un(19),I=0;I<y.length;++I)++_[31&y[I]];for(I=0;I<k.length;++I)++_[31&k[I]];for(var S=qn(_,7),x=S.t,M=S.l,E=19;E>4&&!x[dn[E-1]];--E);var A,z,D,P,C=u+5<<3,U=Nn(r,Sn)+Nn(o,xn)+s,L=Nn(r,h)+Nn(o,p)+s+14+3*E+Nn(_,x)+2*_[16]+3*_[17]+7*_[18];if(c>=0&&C<=U&&C<=L)return Zn(n,l,t.subarray(c,c+u));if(Bn(n,l,1+(L<U)),l+=2,L<U){A=In(h,d,0),z=h,D=In(p,w,0),P=p;var R=In(x,M,0);for(Bn(n,l,g-257),Bn(n,l+5,T-1),Bn(n,l+10,E-4),l+=14,I=0;I<E;++I)Bn(n,l+3*I,x[dn[I]]);l+=3*E;for(var $=[y,k],O=0;O<2;++O){var B=$[O];for(I=0;I<B.length;++I)Bn(n,l,R[q=31&B[I]]),l+=x[q],q>15&&(Bn(n,l,B[I]>>5&127),l+=B[I]>>12)}}else A=Mn,z=Sn,D=An,P=xn;for(I=0;I<a;++I){var j=i[I];if(j>255){var q;jn(n,l,A[257+(q=j>>18&31)]),l+=z[q+257],q>7&&(Bn(n,l,j>>23&31),l+=fn[q]);var F=31&j;jn(n,l,D[F]),l+=P[F],F>3&&(jn(n,l,j>>5&8191),l+=hn[F])}else jn(n,l,A[j]),l+=z[j]}return jn(n,l,A[256]),l+z[256]},Gn=new ln([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Kn=new cn(0),Vn=function(t,n,e,i,r,o){var s=o.z||t.length,a=new cn(i+s+5*(1+Math.ceil(s/7e3))+r),c=a.subarray(i,a.length-r),u=o.l,l=7&(o.r||0);if(n){l&&(c[0]=o.r>>3);for(var f=Gn[n-1],h=f>>13,d=8191&f,v=(1<<e)-1,p=o.p||new un(32768),w=o.h||new un(v+1),m=Math.ceil(e/3),y=2*m,g=function(n){return(t[n]^t[n+1]<<m^t[n+2]<<y)&v},b=new ln(25e3),k=new un(288),T=new un(32),_=0,I=0,S=o.i||0,x=0,M=o.w||0,E=0;S+2<s;++S){var A=g(S),z=32767&S,D=w[A];if(p[z]=D,w[A]=z,M<=S){var P=s-S;if((_>7e3||x>24576)&&(P>423||!u)){l=Xn(t,c,0,b,k,T,I,x,E,S-E,l),x=_=I=0,E=S;for(var C=0;C<286;++C)k[C]=0;for(C=0;C<30;++C)T[C]=0}var U=2,L=0,R=d,$=z-D&32767;if(P>2&&A==g(S-$))for(var O=Math.min(h,P)-1,B=Math.min(32767,S),j=Math.min(258,P);$<=B&&--R&&z!=D;){if(t[S+U]==t[S+U-$]){for(var q=0;q<j&&t[S+q]==t[S+q-$];++q);if(q>U){if(U=q,L=$,q>O)break;var F=Math.min($,q-2),H=0;for(C=0;C<F;++C){var N=S-$+C&32767,Z=N-p[N]&32767;Z>H&&(H=Z,D=N)}}}$+=(z=D)-(D=p[z])&32767}if(L){b[x++]=268435456|mn[U]<<18|bn[L];var X=31&mn[U],G=31&bn[L];I+=fn[X]+hn[G],++k[257+X],++T[G],M=S+U,++_}else b[x++]=t[S],++k[t[S]]}}for(S=Math.max(S,M);S<s;++S)b[x++]=t[S],++k[t[S]];l=Xn(t,c,u,b,k,T,I,x,E,S-E,l),u||(o.r=7&l|c[l/8|0]<<3,l-=7,o.h=w,o.p=p,o.i=S,o.w=M)}else{for(S=o.w||0;S<s+u;S+=65535){var K=S+65535;K>=s&&(c[l/8|0]=u,K=s),l=Zn(c,l+1,t.subarray(S,K))}o.i=s}return Ln(a,0,i+Un(l)+r)},Yn=function(){for(var t=new Int32Array(256),n=0;n<256;++n){for(var e=n,i=9;--i;)e=(1&e&&-306674912)^e>>>1;t[n]=e}return t}(),Jn=function(){var t=-1;return{p:function(n){for(var e=t,i=0;i<n.length;++i)e=Yn[255&e^n[i]]^e>>>8;t=e},d:function(){return~t}}},Qn=function(){var t=1,n=0;return{p:function(e){for(var i=t,r=n,o=0|e.length,s=0;s!=o;){for(var a=Math.min(s+2655,o);s<a;++s)r+=i+=e[s];i=(65535&i)+15*(i>>16),r=(65535&r)+15*(r>>16)}t=i,n=r},d:function(){return(255&(t%=65521))<<24|(65280&t)<<8|(255&(n%=65521))<<8|n>>8}}},Wn=function(t,n,e,i,r){if(!r&&(r={l:1},n.dictionary)){var o=n.dictionary.subarray(-32768),s=new cn(o.length+t.length);s.set(o),s.set(t,o.length),t=s,r.w=o.length}return Vn(t,null==n.level?6:n.level,null==n.mem?r.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):20:12+n.mem,e,i,r)},te=function(t,n){var e={};for(var i in t)e[i]=t[i];for(var i in n)e[i]=n[i];return e},ne=function(t,n,e){for(var i=t(),r=t.toString(),o=r.slice(r.indexOf("[")+1,r.lastIndexOf("]")).replace(/\s+/g,"").split(","),s=0;s<i.length;++s){var a=i[s],c=o[s];if("function"==typeof a){n+=";"+c+"=";var u=a.toString();if(a.prototype)if(-1!=u.indexOf("[native code]")){var l=u.indexOf(" ",8)+1;n+=u.slice(l,u.indexOf("(",l))}else for(var f in n+=u,a.prototype)n+=";"+c+".prototype."+f+"="+a.prototype[f].toString();else n+=u}else e[c]=a}return n},ee=[],ie=function(t,n,e,i){if(!ee[e]){for(var r="",o={},s=t.length-1,a=0;a<s;++a)r=ne(t[a],r,o);ee[e]={c:ne(t[s],r,o),e:o}}var c=te({},ee[e].e);return function(t,n,e,i,r){var o=new Worker(an[n]||(an[n]=URL.createObjectURL(new Blob([t+';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'],{type:"text/javascript"}))));return o.onmessage=function(t){var n=t.data,e=n.$e$;if(e){var i=new Error(e[0]);i.code=e[1],i.stack=e[2],r(i,null)}else r(null,n)},o.postMessage(e,i),o}(ee[e].c+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+n.toString()+"}",e,c,function(t){var n=[];for(var e in t)t[e].buffer&&n.push((t[e]=new t[e].constructor(t[e])).buffer);return n}(c),i)},re=function(){return[cn,un,ln,fn,hn,dn,wn,gn,En,zn,kn,Rn,In,Dn,Pn,Cn,Un,Ln,$n,On,Ce,le,fe]},oe=function(){return[cn,un,ln,fn,hn,dn,mn,bn,Mn,Sn,An,xn,kn,Gn,Kn,In,Bn,jn,qn,Fn,Hn,Nn,Zn,Xn,Un,Ln,Vn,Wn,Ae,le]},se=function(){return[ge,Te,ye,Jn,Yn]},ae=function(){return[be,ke]},ce=function(){return[_e,ye,Qn]},ue=function(){return[Ie]},le=function(t){return postMessage(t,[t.buffer])},fe=function(t){return t&&{out:t.size&&new cn(t.size),dictionary:t.dictionary}},he=function(t,n,e,i,r,o){var s=ie(e,i,r,function(t,n){s.terminate(),o(t,n)});return s.postMessage([t,n],n.consume?[t.buffer]:[]),function(){s.terminate()}},de=function(t){return t.ondata=function(t,n){return postMessage([t,n],[t.buffer])},function(n){n.data.length?(t.push(n.data[0],n.data[1]),postMessage([n.data[0].length])):t.flush()}},ve=function(t,n,e,i,r,o,s){var a,c=ie(t,i,r,function(t,e){t?(c.terminate(),n.ondata.call(n,t)):Array.isArray(e)?1==e.length?(n.queuedSize-=e[0],n.ondrain&&n.ondrain(e[0])):(e[1]&&c.terminate(),n.ondata.call(n,t,e[0],e[1])):s(e)});c.postMessage(e),n.queuedSize=0,n.push=function(t,e){n.ondata||$n(5),a&&n.ondata($n(4,0,1),null,!!e),n.queuedSize+=t.length,c.postMessage([t,a=e],[t.buffer])},n.terminate=function(){c.terminate()},o&&(n.flush=function(){c.postMessage([])})},pe=function(t,n){return t[n]|t[n+1]<<8},we=function(t,n){return(t[n]|t[n+1]<<8|t[n+2]<<16|t[n+3]<<24)>>>0},me=function(t,n){return we(t,n)+4294967296*we(t,n+4)},ye=function(t,n,e){for(;e;++n)t[n]=e,e>>>=8},ge=function(t,n){var e=n.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=n.level<2?4:9==n.level?2:0,t[9]=3,0!=n.mtime&&ye(t,4,Math.floor(new Date(n.mtime||Date.now())/1e3)),e){t[3]=8;for(var i=0;i<=e.length;++i)t[i+10]=e.charCodeAt(i)}},be=function(t){31==t[0]&&139==t[1]&&8==t[2]||$n(6,"invalid gzip data");var n=t[3],e=10;4&n&&(e+=2+(t[10]|t[11]<<8));for(var i=(n>>3&1)+(n>>4&1);i>0;i-=!t[e++]);return e+(2&n)},ke=function(t){var n=t.length;return(t[n-4]|t[n-3]<<8|t[n-2]<<16|t[n-1]<<24)>>>0},Te=function(t){return 10+(t.filename?t.filename.length+1:0)},_e=function(t,n){var e=n.level,i=0==e?0:e<6?1:9==e?3:2;if(t[0]=120,t[1]=i<<6|(n.dictionary&&32),t[1]|=31-(t[0]<<8|t[1])%31,n.dictionary){var r=Qn();r.p(n.dictionary),ye(t,2,r.d())}},Ie=function(t,n){return(8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31)&&$n(6,"invalid zlib data"),(t[1]>>5&1)==+!n&&$n(6,"invalid zlib data: "+(32&t[1]?"need":"unexpected")+" dictionary"),2+(t[1]>>3&4)};function Se(t,n){return"function"==typeof t&&(n=t,t={}),this.ondata=n,t}var xe=function(){function t(t,n){if("function"==typeof t&&(n=t,t={}),this.ondata=n,this.o=t||{},this.s={l:0,i:32768,w:32768,z:32768},this.b=new cn(98304),this.o.dictionary){var e=this.o.dictionary.subarray(-32768);this.b.set(e,32768-e.length),this.s.i=32768-e.length}}return t.prototype.p=function(t,n){this.ondata(Wn(t,this.o,0,0,this.s),n)},t.prototype.push=function(t,n){this.ondata||$n(5),this.s.l&&$n(4);var e=t.length+this.s.z;if(e>this.b.length){if(e>2*this.b.length-32768){var i=new cn(-32768&e);i.set(this.b.subarray(0,this.s.z)),this.b=i}var r=this.b.length-this.s.z;this.b.set(t.subarray(0,r),this.s.z),this.s.z=this.b.length,this.p(this.b,0),this.b.set(this.b.subarray(-32768)),this.b.set(t.subarray(r),32768),this.s.z=t.length-r+32768,this.s.i=32766,this.s.w=32768}else this.b.set(t,this.s.z),this.s.z+=t.length;this.s.l=1&n,(this.s.z>this.s.w+8191||n)&&(this.p(this.b,n||0),this.s.w=this.s.i,this.s.i-=2)},t.prototype.flush=function(){this.ondata||$n(5),this.s.l&&$n(4),this.p(this.b,0),this.s.w=this.s.i,this.s.i-=2},t}(),Me=function(){return function(t,n){ve([oe,function(){return[de,xe]}],this,Se.call(this,t,n),function(t){var n=new xe(t.data);onmessage=de(n)},6,1)}}();function Ee(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&$n(7),he(t,n,[oe],function(t){return le(Ae(t.data[0],t.data[1]))},0,e)}function Ae(t,n){return Wn(t,n||{},0,0)}var ze=function(){function t(t,n){"function"==typeof t&&(n=t,t={}),this.ondata=n;var e=t&&t.dictionary&&t.dictionary.subarray(-32768);this.s={i:0,b:e?e.length:0},this.o=new cn(32768),this.p=new cn(0),e&&this.o.set(e)}return t.prototype.e=function(t){if(this.ondata||$n(5),this.d&&$n(4),this.p.length){if(t.length){var n=new cn(this.p.length+t.length);n.set(this.p),n.set(t,this.p.length),this.p=n}}else this.p=t},t.prototype.c=function(t){this.s.i=+(this.d=t||0);var n=this.s.b,e=On(this.p,this.s,this.o);this.ondata(Ln(e,n,this.s.b),this.d),this.o=Ln(e,this.s.b-32768),this.s.b=this.o.length,this.p=Ln(this.p,this.s.p/8|0),this.s.p&=7},t.prototype.push=function(t,n){this.e(t),this.c(n)},t}(),De=function(){return function(t,n){ve([re,function(){return[de,ze]}],this,Se.call(this,t,n),function(t){var n=new ze(t.data);onmessage=de(n)},7,0)}}();function Pe(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&$n(7),he(t,n,[re],function(t){return le(Ce(t.data[0],fe(t.data[1])))},1,e)}function Ce(t,n){return On(t,{i:2},n&&n.out,n&&n.dictionary)}var Ue=function(){function t(t,n){this.c=Jn(),this.l=0,this.v=1,xe.call(this,t,n)}return t.prototype.push=function(t,n){this.c.p(t),this.l+=t.length,xe.prototype.push.call(this,t,n)},t.prototype.p=function(t,n){var e=Wn(t,this.o,this.v&&Te(this.o),n&&8,this.s);this.v&&(ge(e,this.o),this.v=0),n&&(ye(e,e.length-8,this.c.d()),ye(e,e.length-4,this.l)),this.ondata(e,n)},t.prototype.flush=function(){xe.prototype.flush.call(this)},t}(),Le=function(){return function(t,n){ve([oe,se,function(){return[de,xe,Ue]}],this,Se.call(this,t,n),function(t){var n=new Ue(t.data);onmessage=de(n)},8,1)}}();function Re(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&$n(7),he(t,n,[oe,se,function(){return[$e]}],function(t){return le($e(t.data[0],t.data[1]))},2,e)}function $e(t,n){n||(n={});var e=Jn(),i=t.length;e.p(t);var r=Wn(t,n,Te(n),8),o=r.length;return ge(r,n),ye(r,o-8,e.d()),ye(r,o-4,i),r}var Oe=function(){function t(t,n){this.v=1,this.r=0,ze.call(this,t,n)}return t.prototype.push=function(t,n){if(ze.prototype.e.call(this,t),this.r+=t.length,this.v){var e=this.p.subarray(this.v-1),i=e.length>3?be(e):4;if(i>e.length){if(!n)return}else this.v>1&&this.onmember&&this.onmember(this.r-e.length);this.p=e.subarray(i),this.v=0}ze.prototype.c.call(this,n),!this.s.f||this.s.l||n||(this.v=Un(this.s.p)+9,this.s={i:0},this.o=new cn(0),this.push(new cn(0),n))},t}(),Be=function(){return function(t,n){var e=this;ve([re,ae,function(){return[de,ze,Oe]}],this,Se.call(this,t,n),function(t){var n=new Oe(t.data);n.onmember=function(t){return postMessage(t)},onmessage=de(n)},9,0,function(t){return e.onmember&&e.onmember(t)})}}();function je(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&$n(7),he(t,n,[re,ae,function(){return[qe]}],function(t){return le(qe(t.data[0],t.data[1]))},3,e)}function qe(t,n){var e=be(t);return e+8>t.length&&$n(6,"invalid gzip data"),On(t.subarray(e,-8),{i:2},n&&n.out||new cn(ke(t)),n&&n.dictionary)}var Fe=function(){function t(t,n){this.c=Qn(),this.v=1,xe.call(this,t,n)}return t.prototype.push=function(t,n){this.c.p(t),xe.prototype.push.call(this,t,n)},t.prototype.p=function(t,n){var e=Wn(t,this.o,this.v&&(this.o.dictionary?6:2),n&&4,this.s);this.v&&(_e(e,this.o),this.v=0),n&&ye(e,e.length-4,this.c.d()),this.ondata(e,n)},t.prototype.flush=function(){xe.prototype.flush.call(this)},t}(),He=function(){return function(t,n){ve([oe,ce,function(){return[de,xe,Fe]}],this,Se.call(this,t,n),function(t){var n=new Fe(t.data);onmessage=de(n)},10,1)}}();function Ne(t,n){n||(n={});var e=Qn();e.p(t);var i=Wn(t,n,n.dictionary?6:2,4);return _e(i,n),ye(i,i.length-4,e.d()),i}var Ze=function(){function t(t,n){ze.call(this,t,n),this.v=t&&t.dictionary?2:1}return t.prototype.push=function(t,n){if(ze.prototype.e.call(this,t),this.v){if(this.p.length<6&&!n)return;this.p=this.p.subarray(Ie(this.p,this.v-1)),this.v=0}n&&(this.p.length<4&&$n(6,"invalid zlib data"),this.p=this.p.subarray(0,-4)),ze.prototype.c.call(this,n)},t}(),Xe=function(){return function(t,n){ve([re,ue,function(){return[de,ze,Ze]}],this,Se.call(this,t,n),function(t){var n=new Ze(t.data);onmessage=de(n)},11,0)}}();function Ge(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&$n(7),he(t,n,[re,ue,function(){return[Ke]}],function(t){return le(Ke(t.data[0],fe(t.data[1])))},5,e)}function Ke(t,n){return On(t.subarray(Ie(t,n&&n.dictionary),-4),{i:2},n&&n.out,n&&n.dictionary)}var Ve=function(){function t(t,n){this.o=Se.call(this,t,n)||{},this.G=Oe,this.I=ze,this.Z=Ze}return t.prototype.i=function(){var t=this;this.s.ondata=function(n,e){t.ondata(n,e)}},t.prototype.push=function(t,n){if(this.ondata||$n(5),this.s)this.s.push(t,n);else{if(this.p&&this.p.length){var e=new cn(this.p.length+t.length);e.set(this.p),e.set(t,this.p.length)}else this.p=t;this.p.length>2&&(this.s=31==this.p[0]&&139==this.p[1]&&8==this.p[2]?new this.G(this.o):8!=(15&this.p[0])||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(this.o):new this.Z(this.o),this.i(),this.s.push(this.p,n),this.p=null)}},t}(),Ye=function(){function t(t,n){Ve.call(this,t,n),this.queuedSize=0,this.G=Be,this.I=De,this.Z=Xe}return t.prototype.i=function(){var t=this;this.s.ondata=function(n,e,i){t.ondata(n,e,i)},this.s.ondrain=function(n){t.queuedSize-=n,t.ondrain&&t.ondrain(n)}},t.prototype.push=function(t,n){this.queuedSize+=t.length,Ve.prototype.push.call(this,t,n)},t}(),Je=function(t,n,e,i){for(var r in t){var o=t[r],s=n+r,a=i;Array.isArray(o)&&(a=te(i,o[1]),o=o[0]),o instanceof cn?e[s]=[o,a]:(e[s+="/"]=[new cn(0),a],Je(o,s,e,i))}},Qe="undefined"!=typeof TextEncoder&&new TextEncoder,We="undefined"!=typeof TextDecoder&&new TextDecoder,ti=0;try{We.decode(Kn,{stream:1}),ti=1}catch(t){}var ni=function(t){for(var n="",e=0;;){var i=t[e++],r=(i>127)+(i>223)+(i>239);if(e+r>t.length)return{s:n,r:Ln(t,e-1)};r?3==r?(i=((15&i)<<18|(63&t[e++])<<12|(63&t[e++])<<6|63&t[e++])-65536,n+=String.fromCharCode(55296|i>>10,56320|1023&i)):n+=String.fromCharCode(1&r?(31&i)<<6|63&t[e++]:(15&i)<<12|(63&t[e++])<<6|63&t[e++]):n+=String.fromCharCode(i)}},ei=function(){function t(t){this.ondata=t,ti?this.t=new TextDecoder:this.p=Kn}return t.prototype.push=function(t,n){if(this.ondata||$n(5),n=!!n,this.t)return this.ondata(this.t.decode(t,{stream:1}),n),void(n&&(this.t.decode().length&&$n(8),this.t=null));this.p||$n(4);var e=new cn(this.p.length+t.length);e.set(this.p),e.set(t,this.p.length);var i=ni(e),r=i.s,o=i.r;n?(o.length&&$n(8),this.p=null):this.p=o,this.ondata(r,n)},t}(),ii=function(){function t(t){this.ondata=t}return t.prototype.push=function(t,n){this.ondata||$n(5),this.d&&$n(4),this.ondata(ri(t),this.d=n||0)},t}();function ri(t,n){if(n){for(var e=new cn(t.length),i=0;i<t.length;++i)e[i]=t.charCodeAt(i);return e}if(Qe)return Qe.encode(t);var r=t.length,o=new cn(t.length+(t.length>>1)),s=0,a=function(t){o[s++]=t};for(i=0;i<r;++i){if(s+5>o.length){var c=new cn(s+8+(r-i<<1));c.set(o),o=c}var u=t.charCodeAt(i);u<128||n?a(u):u<2048?(a(192|u>>6),a(128|63&u)):u>55295&&u<57344?(a(240|(u=65536+(1047552&u)|1023&t.charCodeAt(++i))>>18),a(128|u>>12&63),a(128|u>>6&63),a(128|63&u)):(a(224|u>>12),a(128|u>>6&63),a(128|63&u))}return Ln(o,0,s)}function oi(t,n){if(n){for(var e="",i=0;i<t.length;i+=16384)e+=String.fromCharCode.apply(null,t.subarray(i,i+16384));return e}if(We)return We.decode(t);var r=ni(t),o=r.s;return(e=r.r).length&&$n(8),o}var si=function(t){return 1==t?3:t<6?2:9==t?1:0},ai=function(t,n){return n+30+pe(t,n+26)+pe(t,n+28)},ci=function(t,n,e){var i=pe(t,n+28),r=oi(t.subarray(n+46,n+46+i),!(2048&pe(t,n+8))),o=n+46+i,s=we(t,n+20),a=e&&4294967295==s?ui(t,o):[s,we(t,n+24),we(t,n+42)],c=a[0],u=a[1],l=a[2];return[pe(t,n+10),c,u,r,o+pe(t,n+30)+pe(t,n+32),l]},ui=function(t,n){for(;1!=pe(t,n);n+=4+pe(t,n+2));return[me(t,n+12),me(t,n+4),me(t,n+20)]},li=function(t){var n=0;if(t)for(var e in t){var i=t[e].length;i>65535&&$n(9),n+=i+4}return n},fi=function(t,n,e,i,r,o,s,a){var c=i.length,u=e.extra,l=a&&a.length,f=li(u);ye(t,n,null!=s?33639248:67324752),n+=4,null!=s&&(t[n++]=20,t[n++]=e.os),t[n]=20,n+=2,t[n++]=e.flag<<1|(o<0&&8),t[n++]=r&&8,t[n++]=255&e.compression,t[n++]=e.compression>>8;var h=new Date(null==e.mtime?Date.now():e.mtime),d=h.getFullYear()-1980;if((d<0||d>119)&&$n(10),ye(t,n,d<<25|h.getMonth()+1<<21|h.getDate()<<16|h.getHours()<<11|h.getMinutes()<<5|h.getSeconds()>>1),n+=4,-1!=o&&(ye(t,n,e.crc),ye(t,n+4,o<0?-o-2:o),ye(t,n+8,e.size)),ye(t,n+12,c),ye(t,n+14,f),n+=16,null!=s&&(ye(t,n,l),ye(t,n+6,e.attrs),ye(t,n+10,s),n+=14),t.set(i,n),n+=c,f)for(var v in u){var p=u[v],w=p.length;ye(t,n,+v),ye(t,n+2,w),t.set(p,n+4),n+=4+w}return l&&(t.set(a,n),n+=l),n},hi=function(t,n,e,i,r){ye(t,n,101010256),ye(t,n+8,e),ye(t,n+10,e),ye(t,n+12,i),ye(t,n+16,r)},di=function(){function t(t){this.filename=t,this.c=Jn(),this.size=0,this.compression=0}return t.prototype.process=function(t,n){this.ondata(null,t,n)},t.prototype.push=function(t,n){this.ondata||$n(5),this.c.p(t),this.size+=t.length,n&&(this.crc=this.c.d()),this.process(t,n||0)},t}(),vi=function(){function t(t,n){var e=this;n||(n={}),di.call(this,t),this.d=new xe(n,function(t,n){e.ondata(null,t,n)}),this.compression=8,this.flag=si(n.level)}return t.prototype.process=function(t,n){try{this.d.push(t,n)}catch(t){this.ondata(t,null,n)}},t.prototype.push=function(t,n){di.prototype.push.call(this,t,n)},t}(),pi=function(){function t(t,n){var e=this;n||(n={}),di.call(this,t),this.d=new Me(n,function(t,n,i){e.ondata(t,n,i)}),this.compression=8,this.flag=si(n.level),this.terminate=this.d.terminate}return t.prototype.process=function(t,n){this.d.push(t,n)},t.prototype.push=function(t,n){di.prototype.push.call(this,t,n)},t}(),wi=function(){function t(t){this.ondata=t,this.u=[],this.d=1}return t.prototype.add=function(t){var n=this;if(this.ondata||$n(5),2&this.d)this.ondata($n(4+8*(1&this.d),0,1),null,0);else{var e=ri(t.filename),i=e.length,r=t.comment,o=r&&ri(r),s=i!=t.filename.length||o&&r.length!=o.length,a=i+li(t.extra)+30;i>65535&&this.ondata($n(11,0,1),null,0);var c=new cn(a);fi(c,0,t,e,s,-1);var u=[c],l=function(){for(var t=0,e=u;t<e.length;t++)n.ondata(null,e[t],0);u=[]},f=this.d;this.d=0;var h=this.u.length,d=te(t,{f:e,u:s,o:o,t:function(){t.terminate&&t.terminate()},r:function(){if(l(),f){var t=n.u[h+1];t?t.r():n.d=1}f=1}}),v=0;t.ondata=function(e,i,r){if(e)n.ondata(e,i,r),n.terminate();else if(v+=i.length,u.push(i),r){var o=new cn(16);ye(o,0,134695760),ye(o,4,t.crc),ye(o,8,v),ye(o,12,t.size),u.push(o),d.c=v,d.b=a+v+16,d.crc=t.crc,d.size=t.size,f&&d.r(),f=1}else f&&l()},this.u.push(d)}},t.prototype.end=function(){var t=this;2&this.d?this.ondata($n(4+8*(1&this.d),0,1),null,1):(this.d?this.e():this.u.push({r:function(){1&t.d&&(t.u.splice(-1,1),t.e())},t:function(){}}),this.d=3)},t.prototype.e=function(){for(var t=0,n=0,e=0,i=0,r=this.u;i<r.length;i++)e+=46+(c=r[i]).f.length+li(c.extra)+(c.o?c.o.length:0);for(var o=new cn(e+22),s=0,a=this.u;s<a.length;s++){var c;fi(o,t,c=a[s],c.f,c.u,-c.c-2,n,c.o),t+=46+c.f.length+li(c.extra)+(c.o?c.o.length:0),n+=c.b}hi(o,t,this.u.length,e,n),this.ondata(null,o,1),this.d=2},t.prototype.terminate=function(){for(var t=0,n=this.u;t<n.length;t++)n[t].t();this.d=2},t}(),mi=function(){function t(){}return t.prototype.push=function(t,n){this.ondata(null,t,n)},t.compression=0,t}(),yi=function(){function t(){var t=this;this.i=new ze(function(n,e){t.ondata(null,n,e)})}return t.prototype.push=function(t,n){try{this.i.push(t,n)}catch(t){this.ondata(t,null,n)}},t.compression=8,t}(),gi=function(){function t(t,n){var e=this;n<32e4?this.i=new ze(function(t,n){e.ondata(null,t,n)}):(this.i=new De(function(t,n,i){e.ondata(t,n,i)}),this.terminate=this.i.terminate)}return t.prototype.push=function(t,n){this.i.terminate&&(t=Ln(t,0)),this.i.push(t,n)},t.compression=8,t}(),bi=function(){function t(t){this.onfile=t,this.k=[],this.o={0:mi},this.p=Kn}return t.prototype.push=function(t,n){var e=this;if(this.onfile||$n(5),this.p||$n(4),this.c>0){var i=Math.min(this.c,t.length),r=t.subarray(0,i);if(this.c-=i,this.d?this.d.push(r,!this.c):this.k[0].push(r),(t=t.subarray(i)).length)return this.push(t,n)}else{var o=0,s=0,a=void 0,c=void 0;this.p.length?t.length?((c=new cn(this.p.length+t.length)).set(this.p),c.set(t,this.p.length)):c=this.p:c=t;for(var u=c.length,l=this.c,f=l&&this.d,h=function(){var t,n=we(c,s);if(67324752==n){o=1,a=s,d.d=null,d.c=0;var i=pe(c,s+6),r=pe(c,s+8),f=2048&i,h=8&i,v=pe(c,s+26),p=pe(c,s+28);if(u>s+30+v+p){var w=[];d.k.unshift(w),o=2;var m,y=we(c,s+18),g=we(c,s+22),b=oi(c.subarray(s+30,s+=30+v),!f);4294967295==y?(t=h?[-2]:ui(c,s),y=t[0],g=t[1]):h&&(y=-1),s+=p,d.c=y;var k={name:b,compression:r,start:function(){if(k.ondata||$n(5),y){var t=e.o[r];t||k.ondata($n(14,"unknown compression type "+r,1),null,0),(m=y<0?new t(b):new t(b,y,g)).ondata=function(t,n,e){k.ondata(t,n,e)};for(var n=0,i=w;n<i.length;n++)m.push(i[n],0);e.k[0]==w&&e.c?e.d=m:m.push(Kn,1)}else k.ondata(null,Kn,1)},terminate:function(){m&&m.terminate&&m.terminate()}};y>=0&&(k.size=y,k.originalSize=g),d.onfile(k)}return"break"}if(l){if(134695760==n)return a=s+=12+(-2==l&&8),o=3,d.c=0,"break";if(33639248==n)return a=s-=4,o=3,d.c=0,"break"}},d=this;s<u-4&&"break"!==h();++s);if(this.p=Kn,l<0){var v=c.subarray(0,o?a-12-(-2==l&&8)-(134695760==we(c,a-16)&&4):s);f?f.push(v,!!o):this.k[+(2==o)].push(v)}if(2&o)return this.push(c.subarray(s),n);this.p=c.subarray(s)}n&&(this.c&&$n(13),this.p=null)},t.prototype.register=function(t){this.o[t.compression]=t},t}(),ki="function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout?setTimeout:function(t){t()},Ti=Object.freeze({__proto__:null,AsyncCompress:Le,AsyncDecompress:Ye,AsyncDeflate:Me,AsyncGunzip:Be,AsyncGzip:Le,AsyncInflate:De,AsyncUnzipInflate:gi,AsyncUnzlib:Xe,AsyncZipDeflate:pi,AsyncZlib:He,Compress:Ue,DecodeUTF8:ei,Decompress:Ve,Deflate:xe,EncodeUTF8:ii,FlateErrorCode:{UnexpectedEOF:0,InvalidBlockType:1,InvalidLengthLiteral:2,InvalidDistance:3,StreamFinished:4,NoStreamHandler:5,InvalidHeader:6,NoCallback:7,InvalidUTF8:8,ExtraFieldTooLong:9,InvalidDate:10,FilenameTooLong:11,StreamFinishing:12,InvalidZipData:13,UnknownCompressionMethod:14},Gunzip:Oe,Gzip:Ue,Inflate:ze,Unzip:bi,UnzipInflate:yi,UnzipPassThrough:mi,Unzlib:Ze,Zip:wi,ZipDeflate:vi,ZipPassThrough:di,Zlib:Fe,compress:Re,compressSync:$e,decompress:function(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&$n(7),31==t[0]&&139==t[1]&&8==t[2]?je(t,n,e):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?Pe(t,n,e):Ge(t,n,e)},decompressSync:function(t,n){return 31==t[0]&&139==t[1]&&8==t[2]?qe(t,n):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?Ce(t,n):Ke(t,n)},deflate:Ee,deflateSync:Ae,gunzip:je,gunzipSync:qe,gzip:Re,gzipSync:$e,inflate:Pe,inflateSync:Ce,strFromU8:oi,strToU8:ri,unzip:function(t,n,e){e||(e=n,n={}),"function"!=typeof e&&$n(7);var i=[],r=function(){for(var t=0;t<i.length;++t)i[t]()},o={},s=function(t,n){ki(function(){e(t,n)})};ki(function(){s=e});for(var a=t.length-22;101010256!=we(t,a);--a)if(!a||t.length-a>65558)return s($n(13,0,1),null),r;var c=pe(t,a+8);if(c){var u=c,l=we(t,a+16),f=4294967295==l||65535==u;if(f){var h=we(t,a-12);(f=101075792==we(t,h))&&(u=c=we(t,h+32),l=we(t,h+48))}for(var d=n&&n.filter,v=function(n){var e=ci(t,l,f),a=e[0],u=e[1],h=e[2],v=e[3],p=e[4],w=ai(t,e[5]);l=p;var m=function(t,n){t?(r(),s(t,null)):(n&&(o[v]=n),--c||s(null,o))};if(!d||d({name:v,size:u,originalSize:h,compression:a}))if(a)if(8==a){var y=t.subarray(w,w+u);if(h<524288||u>.8*h)try{m(null,Ce(y,{out:new cn(h)}))}catch(t){m(t,null)}else i.push(Pe(y,{size:h},m))}else m($n(14,"unknown compression type "+a,1),null);else m(null,Ln(t,w,w+u));else m(null,null)},p=0;p<u;++p)v()}else s(null,{});return r},unzipSync:function(t,n){for(var e={},i=t.length-22;101010256!=we(t,i);--i)(!i||t.length-i>65558)&&$n(13);var r=pe(t,i+8);if(!r)return{};var o=we(t,i+16),s=4294967295==o||65535==r;if(s){var a=we(t,i-12);(s=101075792==we(t,a))&&(r=we(t,a+32),o=we(t,a+48))}for(var c=n&&n.filter,u=0;u<r;++u){var l=ci(t,o,s),f=l[0],h=l[1],d=l[2],v=l[3],p=l[4],w=ai(t,l[5]);o=p,c&&!c({name:v,size:h,originalSize:d,compression:f})||(f?8==f?e[v]=Ce(t.subarray(w,w+h),{out:new cn(d)}):$n(14,"unknown compression type "+f):e[v]=Ln(t,w,w+h))}return e},unzlib:Ge,unzlibSync:Ke,zip:function(t,n,e){e||(e=n,n={}),"function"!=typeof e&&$n(7);var i={};Je(t,"",i,n);var r=Object.keys(i),o=r.length,s=0,a=0,c=o,u=new Array(o),l=[],f=function(){for(var t=0;t<l.length;++t)l[t]()},h=function(t,n){ki(function(){e(t,n)})};ki(function(){h=e});var d=function(){var t=new cn(a+22),n=s,e=a-s;a=0;for(var i=0;i<c;++i){var r=u[i];try{var o=r.c.length;fi(t,a,r,r.f,r.u,o);var l=30+r.f.length+li(r.extra),f=a+l;t.set(r.c,f),fi(t,s,r,r.f,r.u,o,a,r.m),s+=16+l+(r.m?r.m.length:0),a=f+o}catch(t){return h(t,null)}}hi(t,s,u.length,e,n),h(null,t)};o||d();for(var v=function(t){var n=r[t],e=i[n],c=e[0],v=e[1],p=Jn(),w=c.length;p.p(c);var m=ri(n),y=m.length,g=v.comment,b=g&&ri(g),k=b&&b.length,T=li(v.extra),_=0==v.level?0:8,I=function(e,i){if(e)f(),h(e,null);else{var r=i.length;u[t]=te(v,{size:w,crc:p.d(),c:i,f:m,m:b,u:y!=n.length||b&&g.length!=k,compression:_}),s+=30+y+T+r,a+=76+2*(y+T)+(k||0)+r,--o||d()}};if(y>65535&&I($n(11,0,1),null),_)if(w<16e4)try{I(null,Ae(c,v))}catch(t){I(t,null)}else l.push(Ee(c,v,I));else I(null,c)},p=0;p<c;++p)v(p);return f},zipSync:function(t,n){n||(n={});var e={},i=[];Je(t,"",e,n);var r=0,o=0;for(var s in e){var a=e[s],c=a[0],u=a[1],l=0==u.level?0:8,f=(_=ri(s)).length,h=u.comment,d=h&&ri(h),v=d&&d.length,p=li(u.extra);f>65535&&$n(11);var w=l?Ae(c,u):c,m=w.length,y=Jn();y.p(c),i.push(te(u,{size:c.length,crc:y.d(),c:w,f:_,m:d,u:f!=s.length||d&&h.length!=v,o:r,compression:l})),r+=30+f+p+m,o+=76+2*(f+p)+(v||0)+m}for(var g=new cn(o+22),b=r,k=o-r,T=0;T<i.length;++T){var _;fi(g,(_=i[T]).o,_,_.f,_.u,_.c.length);var I=30+_.f.length+li(_.extra);g.set(_.c,_.o+I),fi(g,r,_,_.f,_.u,_.c.length,_.o,_.m),r+=16+I+(_.m?_.m.length:0)}return hi(g,r,i.length,k,b),g},zlib:function(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&$n(7),he(t,n,[oe,ce,function(){return[Ne]}],function(t){return le(Ne(t.data[0],t.data[1]))},4,e)},zlibSync:Ne});t.createSession=async function(t,n){const e=n?.apiURL??"https://falcon-ingest-k8s.stage.incodetest.com",i=n?.timeout??1e4,r=new AbortController;let o=null,s=0,a=()=>{};i&&(o=f(()=>{s=1,r.abort()},i));const c=n?.signal;if(c)if(c.aborted)r.abort();else{const t=()=>r.abort();c.addEventListener("abort",t,{once:1}),a=()=>c.removeEventListener("abort",t)}try{const n=await fetch(`${e}/api/v1/sdk/init`,{method:"POST",headers:{"content-type":"application/json","x-api-key":t,"x-api-version":"1.0"},signal:r.signal});if(!n.ok){let t=n.statusText;try{const e=await n.json();e.errorMessage&&(t=e.errorMessage)}catch{}return{token:null,eventsCollectionEnabled:0,error:{status:n.status,message:t}}}return await n.json()}catch(t){throw new Error((s?"[TRI] createSession timed out":"[TRI] Failed to create session:")+" "+t.message)}finally{h(o),a()}},t.default=sn,Object.defineProperty(t,"qt",{value:1})});
|
|
1
|
+
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).IncodeTRI={})}(this,function(t){"use strict";class n{constructor(){this.T=0}static get instance(){return n._||(n._=new n),n._}get DEBUG(){return this.T}set DEBUG(t){this.T=t}warn(t,n,...e){this.T&&this.S("warn",t,n,...e)}error(t,n,...e){this.T&&this.S("error",t,n,...e)}info(t,n,...e){this.T&&this.S("info",t,n,...e)}fatal(t,n,e,...i){this.S(t,n,e,...i)}S(t,n,e,...i){const r=n?`[${n}]`:"",o=console?.[t];o&&o(`[IncodeTRI]${r} ${e}`,...i)}}const e=n.instance;function i(t,n,e){let i=t,r=n;if("devicepixelratiochange"===n){const t=window.devicePixelRatio;i=window.matchMedia(`(resolution: ${t}dppx)`),r="change"}i.addEventListener(r,e,{capture:1,passive:1})}function r(t,n,e){let i=t,r=n;if("devicepixelratiochange"===n){const t=window.devicePixelRatio;i=window.matchMedia(`(resolution: ${t}dppx)`),r="change"}i.removeEventListener(r,e,{capture:1})}const o=globalThis.setTimeout.bind(globalThis),s=globalThis.clearTimeout.bind(globalThis);function a(t,n){try{return t()}catch(t){e.warn("utils","safeSync swallowed error:",t)}}async function c(t){try{return await t()}catch(t){e.warn("utils","safeAsync swallowed error:",t)}}function u(t){return n=>a(()=>t(n))}function l(t){return(...n)=>{try{t(...n)}catch(t){e.warn("utils","safeTimer swallowed error:",t)}}}function f(t,n){return o(l(t),n)}function h(t){if(null!==t)try{s(t)}catch(t){e.warn("utils","safeClearTimeout swallowed error:",t)}}const d=new Set(["xmlhttprequest","fetch","beacon","navigation","script","link","css","img","iframe","video","audio"]),v=new Set(["xmlhttprequest","fetch","beacon"]);function p(t,n){return n?t:null}function w(t,n){const e=t,i=t.responseStart>0,r=p(t.domainLookupEnd-t.domainLookupStart,i),o=p(t.connectEnd-t.connectStart,i),s=p(t.connectEnd>0&&t.secureConnectionStart>0?t.connectEnd-t.secureConnectionStart:0,i),a=p(t.responseStart-t.requestStart,i),c=p(t.responseEnd-t.responseStart,i),u=i?t.transferSize:null,l=i?t.encodedBodySize:null,f=i?t.decodedBodySize:null,h=i&&t.nextHopProtocol||null,v=i&&void 0!==e.deliveryType?e.deliveryType:null,w=e.responseStatus,m=void 0!==w&&0!==w?w:null;return{name:"network_request",timestamp:Date.now(),performanceTime:t.startTime+t.duration,url:n(t.name),initiatorType:(y=t.initiatorType,d.has(y)?y:"other"),startTime:t.startTime,durationMs:t.duration,dnsLookupMs:r,tcpConnectMs:o,tlsHandshakeMs:s,ttfbMs:a,responseDownloadMs:c,transferSize:u,encodedBodySize:l,decodedBodySize:f,nextHopProtocol:h,deliveryType:v,responseStatus:m};var y}function m(){}const y=2e3;function g(t){return!!t&&t.nodeType===Node.TEXT_NODE}function b(t,n){return t.tagName?.toLowerCase()===n.toLowerCase()}function k(t){return!!t&&t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function T(t){return t?t.hasAttribute("data-tri-ignore"):0}function _(t){return t?t.hasAttribute("data-tri-redact"):0}function I(t,n){return n?.includes(t.toLowerCase())??0}function S(t){try{return new URL(t).origin!==window.location.origin}catch{return 0}}function x(t,n){return t?t[n]?.enabled??0:1}function M(){const t=document.activeElement;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement){const n=t.selectionStart,e=t.selectionEnd;return null==n||null==e||n===e?null:t.value.substring(n,e)}const n=window.getSelection();return!n||n.isCollapsed?null:n.toString()||null}function E(t,n){return"off"===n||T(t)||_(t)?0:1}function A(t){const n=document.activeElement;if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)return n;const e=window.getSelection();return(i=("start"===t?e?.anchorNode:e?.focusNode)??null)?g(i)?i.parentElement:i instanceof Element?i:null:null;var i}function z(){const t=window,n="__fpjs_p_l_b",e=t[n];if(function(t,n){var e;const i=null===(e=Object.getOwnPropertyDescriptor)||void 0===e?void 0:e.call(Object,t,n);(null==i?void 0:i.configurable)?delete t[n]:i&&!i.writable||(t[n]=void 0)}(t,n),"function"!=typeof(null==e?void 0:e.load))throw new Error($);return e}const D="Blocked by CSP",P="The endpoint parameter is not a valid URL";function C(t){return function(t,n){const e=document,i="securitypolicyviolation";let r;const o=n=>{const e=new URL(t,location.href),{blockedURI:i}=n;i!==e.href&&i!==e.protocol.slice(0,-1)&&i!==e.origin||(r=n,s())};e.addEventListener(i,o);const s=()=>e.removeEventListener(i,o);return Promise.resolve().then(n).then(t=>(s(),t),t=>new Promise(t=>{const n=new MessageChannel;n.port1.onmessage=()=>t(),n.port2.postMessage(null)}).then(()=>{if(s(),r)return(()=>{throw new Error(D)})();throw t}))}(t,()=>function(t){return new Promise((n,e)=>{if(function(t){if(URL.prototype)try{return new URL(t,location.href),0}catch(t){if(t instanceof Error&&"TypeError"===t.name)return 1;throw t}}(t))throw new Error(P);const i=document.createElement("script"),r=()=>{var t;return null===(t=i.parentNode)||void 0===t?void 0:t.removeChild(i)},o=document.head||document.getElementsByTagName("head")[0];i.onload=()=>{r(),n()},i.onerror=()=>{r(),e(new Error(R))},i.async=1,i.src=t,o.appendChild(i)})}(t)).then(z)}const U="API key required";var L="3.12.9";const R="Failed to load the JS script of the agent",$="9319",O={scriptUrl:"https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js"};function B(t){function n(){return globalThis.window&&globalThis.window[t]&&void 0!==globalThis.window[t]}return{get:function(e){if(!n())return null;try{const n=window[t].getItem(e)??"null";return"null"===n?null:JSON.parse(n)}catch{return null}},set:function(e,i){n()&&a(()=>window[t].setItem(e,JSON.stringify(i)))},remove:function(e){n()&&a(()=>window[t].removeItem(e))},key:function(e){return n()?window[t].key(e):null},get length(){return n()?window[t].length:0}}}const j=B("localStorage"),q=B("sessionStorage"),F="__tri_fingerprint";let H=null,N=null;async function Z(t){try{const n=await function(t){return H||(H=function(t){var n,e;const{picked:i,rest:r}=function(t,n){const e={},i={};for(const[r,o]of Object.entries(t))n.includes(r)?e[r]=o:i[r]=o;return{picked:e,rest:i}}(t,["scriptUrlPattern","token","apiKey"]),o=null!==(n=i.apiKey)&&void 0!==n?n:i.token,s=null!==(e=function(t,n){return function(t,n){return Object.prototype.hasOwnProperty.call(t,n)}(t,n)?t[n]:void 0}(t,"scriptUrlPattern"))&&void 0!==e?e:O.scriptUrl,[a,c]=function(){const t=[],n=()=>{t.push({time:new Date,state:document.visibilityState})},e=((i=document).addEventListener("visibilitychange",r=n,o),()=>i.removeEventListener("visibilitychange",r,o));var i,r,o;return n(),[t,e]}();return Promise.resolve().then(()=>{if(!o||"string"!=typeof o)throw new Error(U);return function(t,n){const e=[],[i,r]=function(t){const n=function(t){const n=[...t];return{current:()=>n[0],postpone(){const t=n.shift();void 0!==t&&n.push(t)},exclude(){n.shift()}}}(t),e=function(){let t=0;return()=>Math.random()*Math.min(3e3,100*Math.pow(2,t++))}(),i=new Set;return[n.current(),(t,r)=>{let o;const s=r instanceof Error?r.message:"";if(s===D||s===P)n.exclude(),o=0;else if(s===$)n.exclude();else if(s===R){const e=Date.now()-t.getTime()<50,r=n.current();r&&e&&!i.has(r)&&(i.add(r),o=0),n.postpone()}else n.postpone();const a=n.current();return void 0===a?void 0:[a,null!=o?o:t.getTime()+e()-Date.now()]}]}(t);let o;if(void 0===i)return Promise.reject(new TypeError("The list of script URL patterns is empty"));const s=t=>{const i=new Date,a=n=>e.push({url:t,startedAt:i,finishedAt:new Date,error:n}),c=n(t);return c.then(()=>a(),a),c.catch(t=>{if(null!=o||(o=t),e.length>=5)throw o;const n=r(i,t);if(!n)throw o;const[a,c]=n;return(u=c,new Promise(t=>setTimeout(t,u))).then(()=>s(a));var u})};return s(i).then(t=>[t,e])}(function(t,n){return(Array.isArray(t)?t:[t]).map(t=>function(t,n){const e=encodeURIComponent;return t.replace(/<[^<>]+>/g,t=>"<version>"===t?"3":"<apiKey>"===t?e(n):"<loaderVersion>"===t?e(L):t)}(String(t),n))}(s,o),C)}).catch(t=>{throw c(),function(t){return t instanceof Error&&t.message===$?new Error(R):t}(t)}).then(([t,n])=>(c(),t.load({...r,ldi:{attempts:n,visibilityStates:a}})))}({apiKey:t.apiKey,region:t.region,endpoint:t.endpoint,scriptUrlPattern:t.scriptUrlPattern}).catch(t=>{throw H=null,t}),H)}(t),e=await n.get({timeout:t.timeoutMs,extendedResult:1});if(!e.visitorId)return null;const i=t.cacheTtlMs??2592e6;return i>0&&function(t,n,e){const i={visitorId:t,requestId:n,expiresAt:Date.now()+e};j.set(F,i)}(e.visitorId,e.requestId,i),{visitorId:e.visitorId,requestId:e.requestId}}catch{return null}}const X={apiKey:"5uYRiI0XM6p8k4124ELX",endpoint:"https://fingerprint.incodesmile.com",scriptUrlPattern:"https://fingerprint.incodesmile.com/web/v<version>/<apiKey>/loader_v<loaderVersion>.js"},G={focusin:"in",focusout:"out"};function K(t){return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement}const V=new Set(["Shift","Control","Alt","Meta","Backspace","Delete","Enter","Tab","CapsLock","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]),Y={mouse:"mouse",touch:"touch",pen:"pen"},J={pointerdown:"down",pointerup:"up",click:"click",dblclick:"dblclick",contextmenu:"contextmenu"};function Q(t,n,e,i,r){return{name:"navigation",timestamp:Date.now(),phase:t,type:n,from:e.from,to:e.to,timeOrigin:i,timing:r}}const W={fingerprint:{create:function(t){let n=0;return c(async()=>{const e=await async function(t){const n=function(){const t=j.get(F);return t?"string"!=typeof t.visitorId||"number"!=typeof t.expiresAt||t.expiresAt<=Date.now()?(j.remove(F),null):{visitorId:t.visitorId,requestId:"string"==typeof t.requestId?t.requestId:""}:null}();return n?{visitorId:n.visitorId,requestId:n.requestId||null}:N||(N=Z(t).finally(()=>{N=null}),N)}(X);!n&&e&&t.push({name:"fingerprint",deviceId:e.visitorId,requestId:e.requestId,timestamp:Date.now()})}),()=>{n=1}},layer:"device-fingerprinting"},pointer:{create:function(t,n,e){const o=u(n=>{const e=function(n){const e=n,i=function(t){if("mouse"===t.pointerType)return{button:t.button,buttons:t.buttons};const n={force:t.pressure,contact:Math.min(t.width,t.height)};return"pen"===t.pointerType&&(n.tiltX=t.tiltX,n.tiltY=t.tiltY,n.twist=t.twist),n}(e);return{id:e.pointerId,name:"pointer",timestamp:Date.now(),type:Y[e.pointerType]??"unknown",phase:J[n.type],isTrusted:e.isTrusted,element:t.resolveElement(e.target),isPrimary:e.isPrimary,modifiers:{shift:e.shiftKey,ctrl:e.ctrlKey,alt:e.altKey,meta:e.metaKey},coordinates:{x:e.clientX,y:e.clientY},...i}}(n);t.push(e)});return x(e,"pointer")&&(i(document,"pointerdown",o),i(document,"pointerup",o)),x(e,"click")&&i(document,"click",o),x(e,"dblclick")&&i(document,"dblclick",o),x(e,"contextmenu")&&i(document,"contextmenu",o),()=>{r(document,"pointerdown",o),r(document,"pointerup",o),r(document,"click",o),r(document,"dblclick",o),r(document,"contextmenu",o)}},layer:"behavioral",events:["pointer","click","dblclick","contextmenu"]},pointermove:{create:function(t){let n=null,e=null;const o=u(e=>{const i=e;return n&&n.id!==i.pointerId&&(t.push(n),n=null),n?n.samples.ts.length>=50?(t.push(n),n=s(i),void a(t)):(n.samples.x.push(i.clientX),n.samples.y.push(i.clientY),n.samples.ts.push(i.timeStamp),"pen"===i.pointerType&&(n.samples.tiltX?.push(i.tiltX),n.samples.tiltY?.push(i.tiltY)),"mouse"!==i.pointerType&&(n.samples.force?.push(i.pressure),n.samples.radius?.push(Math.max(i.width,i.height))),void a(t)):(n=s(i),void a(t))});function s(t){const n=function(t){if("mouse"===t.pointerType)return null;const n={force:[t.pressure],radius:[Math.max(t.width,t.height)]};return"pen"===t.pointerType&&(n.tiltX=[t.tiltX],n.tiltY=[t.tiltY]),n}(t);return{name:"pointer",timestamp:Date.now(),id:t.pointerId,type:t.pointerType,phase:"move",isTrusted:t.isTrusted,isPrimary:t.isPrimary,samples:{x:[t.clientX],y:[t.clientY],ts:[t.timeStamp],...n??{}}}}function a(t){e&&clearTimeout(e),e=setTimeout(()=>{n&&(t.push(n),n=null),e=null},y)}return i(document,"pointermove",o),()=>{r(document,"pointermove",o),e&&(clearTimeout(e),e=null),n&&(t.push(n),n=null)}},layer:"behavioral"},focus:{create:function(t){const n=u(n=>{const e=function(n){const e=n;return{name:"focus",type:G[n.type]??"unknown",timestamp:Date.now(),isTrusted:e.isTrusted,element:t.resolveElement(e.target),relatedTarget:t.resolveElement(e.relatedTarget)}}(n);t.push(e)});return i(document,"focusin",n),i(document,"focusout",n),()=>{r(document,"focusin",n),r(document,"focusout",n)}},layer:"behavioral"},input:{create:function(t){const n=u(n=>{const e=n;t.push(function(n){return{name:"keystroke",type:"input",timestamp:Date.now(),isTrusted:n.isTrusted,element:t.resolveElement(n.target),inputType:n.inputType??"",isComposing:n.isComposing??0,length:(e=n.target,e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement?e.value.length:0)};var e}(e)),function(t){if("insertReplacementText"===t.inputType)return 1;const n=t.target;return K(n)?function(t){try{return t.matches(":-webkit-autofill")}catch{return 0}}(n):0}(e)&&t.push(function(t,n){const e=t.target;let i=0;return K(e)&&(i=e.value.length),{name:"autofill",timestamp:Date.now(),element:n.resolveElement(e),length:i}}(e,t))});return i(document,"input",n),function(){r(document,"input",n)}},layer:"behavioral"},keystroke:{create:function(t){const{resolve:n,reset:e}=function(){let t=0;const n=new Map;return{resolve:function(e,i){if("keydown"===i){const i=n.get(e);if(void 0!==i)return i;const r=++t;if(n.size>=32){const t=n.keys().next().value;void 0!==t&&n.delete(t)}return n.set(e,r),r}const r=n.get(e);return void 0!==r?(n.delete(e),r):++t},reset:function(){n.clear()}}}(),o=u(e=>{const i=function(t){const e=t,i=t.type;return{name:"keystroke",type:i,id:n(e.code,i),timestamp:Date.now(),isTrusted:e.isTrusted,keys:V.has(e.key)?[e.key]:[]}}(e);t.push(i)}),s=u(()=>{e()});return i(document,"keydown",o),i(document,"keyup",o),i(window,"blur",s),()=>{r(document,"keydown",o),r(document,"keyup",o),r(window,"blur",s)}},layer:"behavioral"},clipboard:{create:function(t,n="on",e){const o=u(e=>{const i=function(e){const i=e,r=e.type,o=("paste"===e.type?i.clipboardData?.getData("text/plain"):M())??null,s=E(i.target,n);return{name:"clipboard",type:r,timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target),length:o?.length??0,...s&&o?{content:o}:{}}}(e);t.push(i)});return x(e,"paste")&&i(document,"paste",o),x(e,"cut")&&i(document,"cut",o),x(e,"copy")&&i(document,"copy",o),()=>{r(document,"paste",o),r(document,"cut",o),r(document,"copy",o)}},layer:"behavioral",events:["paste","cut","copy"]},form:{create:function(t,n,e){const o=u(n=>{const e={name:"form",type:(i=n).type,timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target)};var i;t.push(e)});return x(e,"submit")&&i(document,"submit",o),x(e,"invalid")&&i(document,"invalid",o),()=>{r(document,"submit",o),r(document,"invalid",o)}},layer:"behavioral",events:["submit","invalid"]},change:{create:function(t){const n=u(n=>{const e=(i=n,{name:"change",timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target)});var i;t.push(e)});return i(document,"change",n),()=>{r(document,"change",n)}},layer:"behavioral"},selection:{create:function(t,n){let e=0,o=0,s=null,a=0,c=0;function l(){s&&(clearTimeout(s),s=null)}function f(){l(),a||c||(s=setTimeout(()=>{s=null,e&&h("timeout")},250))}function h(i){e&&(e=0,l(),function(e){const i=A("end"),r=i&&E(i,n),o=M();t.push({name:"selection",phase:"end",timestamp:Date.now(),trigger:e,isTrusted:1,element:t.resolveElement(i),length:o?.length??0,...r&&o?{content:o}:{}})}(i))}const d=u(()=>{const n=function(){const t=document.getSelection();return!t||t.isCollapsed||0===t.rangeCount}();if(!e&&!n)return e=1,o=Date.now(),t.push({name:"selection",phase:"start",timestamp:o,element:t.resolveElement(A("start"))}),void f();e&&n?h("collapse"):e&&f()}),v=u(t=>{0===t.button&&(a=1,l())}),p=u(t=>{0===t.button&&(a=0,e&&h("pointer"))}),w=u(t=>{"Shift"===t.key&&(c=1,l())}),m=u(t=>{"Shift"===t.key&&(c=0,e&&h("keyboard"))}),y=u(()=>{a=0}),g=u(()=>{"hidden"===document.visibilityState&&(a=0,c=0,e&&h("timeout"))}),b=u(()=>{a=0,e&&h("pointer")});return i(document,"selectionchange",d),i(document,"pointerdown",v),i(document,"pointerup",p),i(document,"keydown",w),i(document,"keyup",m),i(document,"contextmenu",y),i(document,"visibilitychange",g),i(document,"dragend",b),()=>{l(),r(document,"selectionchange",d),r(document,"pointerdown",v),r(document,"pointerup",p),r(document,"keydown",w),r(document,"keyup",m),r(document,"contextmenu",y),r(document,"visibilitychange",g),r(document,"dragend",b)}},layer:"behavioral"},tab:{create:()=>()=>{},layer:"session",events:["state","count"]},visibility:{create:function(t){const n=u(n=>{const e=document.visibilityState;if("visible"!==e&&"hidden"!==e)return;const i={name:"visibility",type:e,timestamp:Date.now(),isTrusted:n.isTrusted};t.push(i)});return i(document,"visibilitychange",n),()=>{r(document,"visibilitychange",n)}},layer:"session"},navigation:{create:function(t){let n=t.sanitizeUrl(document.referrer||"");function e(e){t.push(e),n=e.to??""}const o=u(()=>{const[n]=performance.getEntriesByType("navigation");var i;e(Q("load",n?.type??"navigate",{from:document.referrer?t.sanitizeUrl(document.referrer):null,to:t.sanitizeUrl(location.href)},performance.timeOrigin,n?{fetchStart:(i=n).fetchStart,domainLookupStart:i.domainLookupStart,domainLookupEnd:i.domainLookupEnd,connectStart:i.connectStart,connectEnd:i.connectEnd,requestStart:i.requestStart,responseStart:i.responseStart,responseEnd:i.responseEnd,domInteractive:i.domInteractive,domContentLoadedEventStart:i.domContentLoadedEventStart,domContentLoadedEventEnd:i.domContentLoadedEventEnd,domComplete:i.domComplete,loadEventStart:i.loadEventStart,loadEventEnd:i.loadEventEnd,redirectCount:i.redirectCount,transferSize:i.transferSize,encodedBodySize:i.encodedBodySize,decodedBodySize:i.decodedBodySize}:void 0))}),s=u(i=>{const r=i;if(null===r.navigationType)return;const o=t.sanitizeUrl(location.href);o!==n&&e(Q("change",r.navigationType,{from:n,to:o},performance.timeOrigin))}),c=u(()=>f("traverse")),l=u(()=>f("hashchange"));function f(i){const r=t.sanitizeUrl(location.href);"hashchange"===i&&r===n||e(Q("change",i,{from:n,to:r},performance.timeOrigin))}const h=history.pushState,d=history.replaceState,v=function(...t){const n=h.apply(this,t);return a(()=>f("push")),n},p=function(...t){const n=d.apply(this,t);return a(()=>f("replace")),n};return window.navigation?i(window.navigation,"currententrychange",s):(history.pushState=v,history.replaceState=p,i(window,"popstate",c),i(window,"hashchange",l)),"complete"===document.readyState?o(new Event("load")):i(window,"load",o),()=>{window.navigation?r(window.navigation,"currententrychange",s):(history.pushState===v&&(history.pushState=h),history.replaceState===p&&(history.replaceState=d),r(window,"popstate",c),r(window,"hashchange",l)),r(window,"load",o)}},layer:"session"},networkconnection:{create:function(t){const n=u(()=>{const n={name:"network",type:"connection",state:navigator.onLine?"online":"offline",timestamp:Date.now()};t.push(n)});return i(window,"online",n),i(window,"offline",n),()=>{r(window,"online",n),r(window,"offline",n)}},layer:"session"},scroll:{create:function(t){let n=null,e=null;const o=u(e=>n?n.samples.ts.length>=50?(t.push(n),n=s(e),void a(t)):(n.samples.x.push(window.scrollX),n.samples.y.push(window.scrollY),n.samples.ts.push(e.timeStamp),void a(t)):(n=s(e),void a(t)));function s(t){return{name:"scroll",timestamp:Date.now(),samples:{x:[window.scrollX],y:[window.scrollY],ts:[t.timeStamp]},height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,pageX:window.pageXOffset,pageY:window.pageYOffset}}function a(t){e&&clearTimeout(e),e=setTimeout(()=>{n&&(t.push(n),n=null),e=null},y)}return i(window,"scroll",o),()=>{r(window,"scroll",o),e&&(clearTimeout(e),e=null),n&&(t.push(n),n=null)}},layer:"behavioral"},viewportresize:{create:function(t){let n=null,e=null;const o=u(e=>n?n.samples.ts.length>=50?(t.push(n),n=s(e),void a(t)):(n.samples.height.push(window.innerHeight),n.samples.width.push(window.innerWidth),n.samples.ts.push(e.timeStamp),n.samples.scrollX.push(window.scrollX),n.samples.scrollY.push(window.scrollY),n.samples.dpr.push(window.devicePixelRatio),void a(t)):(n=s(e),void a(t)));function s(t){return{name:"viewport",type:"resize",timestamp:Date.now(),samples:{height:[window.innerHeight],width:[window.innerWidth],ts:[t.timeStamp],scrollX:[window.scrollX],scrollY:[window.scrollY],dpr:[window.devicePixelRatio]}}}function a(t){e&&clearTimeout(e),e=setTimeout(()=>{n&&(t.push(n),n=null),e=null},y)}return i(window,"resize",o),()=>{r(window,"resize",o),e&&(clearTimeout(e),e=null),n&&(t.push(n),n=null)}},layer:"behavioral"},viewport:{create:function(t,n,e){const o=u(n=>{const e=a(n,"orientation");t.push(e)}),s=u(n=>{const e=a(n,"ratiochange");t.push(e)});function a(t,n){return{name:"viewport",type:n,timestamp:Date.now(),isTrusted:t.isTrusted,height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio}}return x(e,"orientationchange")&&i(window,"orientationchange",o),x(e,"devicepixelratiochange")&&i(window,"devicepixelratiochange",s),()=>{r(window,"orientationchange",o),r(window,"devicepixelratiochange",s)}},layer:"behavioral",events:["orientationchange","devicepixelratiochange"]},sensors:{create:function(t,n,e){let o=null,s=null,a=null,c=null,f=0;function d(){c&&h(c),c=setTimeout(l(()=>{v(),c=null}),y)}function v(){o&&(t.push(o),o=null),s&&(t.push(s),s=null),a&&(t.push(a),a=null)}const p=u(n=>{const e=n,i=e.timeStamp,r=e.acceleration,s=e.accelerationIncludingGravity,a=e.rotationRate;if(!r&&!s&&!a||null===r?.x&&null===r?.y&&null===r?.z&&null===s?.x&&null===s?.y&&null===s?.z&&null===a?.alpha&&null===a?.beta&&null===a?.gamma)return;if(!o)return o={name:"sensors",type:"motion",timestamp:Date.now(),interval:e.interval??null,samples:{ax:[r?.x??0],ay:[r?.y??0],az:[r?.z??0],agx:[s?.x??0],agy:[s?.y??0],agz:[s?.z??0],rrAlpha:[a?.alpha??0],rrBeta:[a?.beta??0],rrGamma:[a?.gamma??0],ts:[i]}},void d();if(o.samples.ts.length>=50)return t.push(o),o={name:"sensors",type:"motion",timestamp:Date.now(),interval:e.interval??null,samples:{ax:[r?.x??0],ay:[r?.y??0],az:[r?.z??0],agx:[s?.x??0],agy:[s?.y??0],agz:[s?.z??0],rrAlpha:[a?.alpha??0],rrBeta:[a?.beta??0],rrGamma:[a?.gamma??0],ts:[i]}},void d();const c=o.samples;c.ax.push(r?.x??0),c.ay.push(r?.y??0),c.az.push(r?.z??0),c.agx.push(s?.x??0),c.agy.push(s?.y??0),c.agz.push(s?.z??0),c.rrAlpha.push(a?.alpha??0),c.rrBeta.push(a?.beta??0),c.rrGamma.push(a?.gamma??0),c.ts.push(i),d()}),w=u(n=>{const e=n;if(null==e.alpha&&null==e.beta&&null==e.gamma)return;const i=e.timeStamp,r=e.webkitCompassHeading??0;if(!s)return s={name:"sensors",type:"orientation",timestamp:Date.now(),absolute:f||e.absolute,samples:{alpha:[e.alpha??0],beta:[e.beta??0],gamma:[e.gamma??0],compassHeading:[r],ts:[i]}},void d();if(s.samples.ts.length>=50)return t.push(s),s={name:"sensors",type:"orientation",timestamp:Date.now(),absolute:f||e.absolute,samples:{alpha:[e.alpha??0],beta:[e.beta??0],gamma:[e.gamma??0],compassHeading:[r],ts:[i]}},void d();const o=s.samples;o.alpha.push(e.alpha??0),o.beta.push(e.beta??0),o.gamma.push(e.gamma??0),o.compassHeading.push(r),o.ts.push(i),d()}),m=u(n=>{const e=n.value;if(null==e)return;const i=n.timeStamp;return a?a.samples.ts.length>=50?(t.push(a),a={name:"sensors",type:"light",timestamp:Date.now(),samples:{lux:[e],ts:[i]}},void d()):(a.samples.lux.push(e),a.samples.ts.push(i),void d()):(a={name:"sensors",type:"light",timestamp:Date.now(),samples:{lux:[e],ts:[i]}},void d())});return x(e,"motion")&&i(window,"devicemotion",p),x(e,"orientation")&&("ondeviceorientationabsolute"in window?(f=1,i(window,"deviceorientationabsolute",w)):i(window,"deviceorientation",w)),x(e,"light")&&i(window,"devicelight",m),function(){r(window,"devicemotion",p),r(window,f?"deviceorientationabsolute":"deviceorientation",w),r(window,"devicelight",m),c&&(h(c),c=null),v()}},layer:"behavioral",events:["motion","orientation","light"]},"network-request":{create:function(t){var n;const i=function(t,n,i,r=v){if("undefined"==typeof PerformanceObserver)return m;let o=null;try{o=new PerformanceObserver(e=>{for(const o of e.getEntries()){const e=o;r.has(e.initiatorType)&&(n(e.name)||t(w(e,i)))}}),o.observe({type:"resource",buffered:1})}catch{return e.warn("network-request","PerformanceObserver failed to start"),m}return function(){o?.disconnect(),o=null}}(function(n){a(()=>t.push(n))},(n=t.ignoredOrigins,function(t){try{return n.has(new URL(t).origin)}catch{return 0}}),t.sanitizeUrl);return function(){i()}},layer:"session"},screen:{create:function(t){const n=a(()=>function(){const t=window.screen;return{name:"screen",timestamp:Date.now(),availWidth:t.availWidth,availHeight:t.availHeight,width:t.width,height:t.height,colorDepth:t.colorDepth,pixelDepth:t.pixelDepth,availLeft:t.availLeft??0,availTop:t.availTop??0,orientation:t.orientation?{type:t.orientation.type,angle:t.orientation.angle}:null,isExtended:t.isExtended??0,viewport:{height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio}}}());return n&&t.push(n),()=>{}},layer:"session"}},tt=Object.keys(W),nt=[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,/^0b[01]+$/i,/^0o[0-7]+$/i,/^0x[0-9a-f]+$/i,/^[a-z][a-z0-9]{1,12}:[A-Za-z0-9+/=_-]{6,}$/i,/^[a-z]{2,8}_(?=.*\d)[A-Za-z0-9]{3,}$/,/^\d{4,}$/,/@/,/^[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{5,}\.[A-Za-z0-9_-]{10,}$/,/^[A-Za-z0-9_-]{20,}={0,2}$/,/^[0-9a-f]{7,}$/i];function et(t){try{const n=new URL(t,location.href);n.username="",n.password="",n.hash="";const e=[...n.searchParams.keys()],i=e.length>0?"?"+e.map(t=>`${encodeURIComponent(t)}=<redacted>`).join("&"):"";n.search="",n.pathname=n.pathname.split("/").map(t=>""!==t&&function(t){for(const n of nt)if(n.test(t))return 1;return 0}(t)?":param":t).join("/");const r=n.origin+n.pathname+i;return r.length>2048?r.slice(0,2048):r}catch{return""}}const it={flush:{intervalMs:2e3,maxIntervalMs:3e4,size:50,backoffFailureThreshold:2},queue:{size:100}};function rt(){const t={};for(const n of tt)t[n]=at(n,void 0,1);return t}function ot(t){const n={};for(const e of tt)n[e]=at(e,void 0,t[W[e].layer]??0);return n}function st(t){const n={};for(const e of tt){const i=t[e];n[e]=at(e,i,i?.enabled??0)}return n}function at(t,n,e){const i=W[t]?.events??[];if(0===i.length)return{enabled:e};const r=n?.events,o={};for(const t of i)o[t]={enabled:r?.[t]??1};return{enabled:e,events:o}}function ct(t){if(!t)return null;const n=t.split(".")[1],e=atob(n.replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(e)}const ut=function(t,n=30){if(!t)return 1;const e=ct(t);return e&&"number"==typeof e.exp?1e3*e.exp<=Date.now()+1e3*n:1};async function lt(t,n){return globalThis.navigator&&"locks"in globalThis.navigator&&"request"in globalThis.navigator.locks&&"query"in globalThis.navigator.locks?navigator.locks.request(t,{mode:"exclusive"},async()=>c(n)):c(n)}const ft="__tri",ht=`${ft}_activity_token`,dt=`${ft}_activity_id`,vt=`${ft}_activity_status`,pt="__tri_activity_lock";class wt{constructor(t){this.context=t,this.M=null,this.A=null,this.D=null,this.P=null,this.C=0}getToken(){return this.M}getActivityId(){return this.A??""}isActive(){return"ACTIVE"===this.D&&null!==this.M}async start(){return this.C=1,this.P||(this.P=this.U()),this.P}async stop(){this.C=0,this.L(null),this.P=null,this.M&&await this.context.stopActivity(),this.R(null)}async refresh(){if(!this.C)return;const t=this.M;await lt(pt,async()=>{if(this.M&&this.M!==t&&!ut(this.M)&&"ACTIVE"===this.D)return;const n=this.$();n&&n.token!==t&&!ut(n.token)&&"ACTIVE"===n.activityStatus?this.R(n):(this.O(),await this.B())})}async U(){try{if(this.M&&!ut(this.M))return;await lt(pt,async()=>{await this.B()})}finally{this.P=null}}async B(){const t=this.$();if(t&&!ut(t.token)&&"ACTIVE"===t.activityStatus)return void this.R(t);t&&this.O();const n=await this.context.startActivity();if(!n.ok)return;if(!n.data.token)return;const e=n.data;this.R(e),this.j(e)}$(){const[t,n,e]=[j.get(ht),j.get(dt),j.get(vt)];return t&&n&&e?{token:t,activityId:n,activityStatus:e}:((t||n||e)&&this.O(),null)}j(t){j.set(ht,t.token),j.set(dt,t.activityId),j.set(vt,t.activityStatus)}O(){this.L(null),this.R(null)}L(t){if(!t)return j.remove(ht),j.remove(dt),void j.remove(vt);j.set(ht,t.token),j.set(dt,t.activityId),j.set(vt,t.activityStatus)}R(t){if(!t)return this.M=null,this.A=null,void(this.D=null);this.M=t.token,this.A=t.activityId,this.D=t.activityStatus}}const mt=[401,403,409],yt=Object.freeze({tab:80,navigation:80,visibility:80,network:80,screen:80,fingerprint:80,pointer:60,keystroke:60,autofill:60,change:60,form:60,clipboard:60,selection:60,focus:60,viewport:60,network_request:60,scroll:40,sensors:40});function gt(t){return"pointer"===t.name&&"move"===t.phase||"viewport"===t.name&&"resize"===t.type?40:yt[t.name]}const bt=new Array(256);for(let t=0;t<256;t++)bt[t]=(t+256).toString(16).slice(1);const kt=new Uint8Array(16);function Tt(t){return bt[t[0]]+bt[t[1]]+bt[t[2]]+bt[t[3]]+"-"+bt[t[4]]+bt[t[5]]+"-"+bt[t[6]]+bt[t[7]]+"-"+bt[t[8]]+bt[t[9]]+"-"+bt[t[10]]+bt[t[11]]+bt[t[12]]+bt[t[13]]+bt[t[14]]+bt[t[15]]}function _t(){return crypto.randomUUID()}function It(){return crypto.getRandomValues(kt),kt[6]=15&kt[6]|64,kt[8]=63&kt[8]|128,Tt(kt)}function St(){for(let t=0;t<16;t++)kt[t]=256*Math.random()|0;return kt[6]=15&kt[6]|64,kt[8]=63&kt[8]|128,Tt(kt)}const xt=function(){if("undefined"!=typeof crypto){if("function"==typeof crypto.randomUUID)return _t;if("function"==typeof crypto.getRandomValues)return It}return St}();function Mt(){return xt()}class Et{constructor(t,n){this.q=t,this.F=n,this.H=[],this.N=null,this.X=[],this.K=null,this.C=0,this.V=1,this.Y=0,this.J=0,this.W=t.flush.intervalMs}push(t){if(this.C){if(this.H.length<this.tt()?this.H.push(t):this.nt(t),this.V)return this.H.length>=this.q.flush.size?(h(this.N),this.N=null,void this.flush("capacity")):void this.et()}else e.warn("Transport","push() called before start() — event dropped")}flush(t){if(this.C&&this.F.isActivityActive())try{if("lifecycle"===t)return void this.it();if(0===this.H.length)return;const n=this.rt(t);this.F.ingest(n,0).then(t=>this.ot(t,n)).catch(()=>{e.warn("Transport","ingest threw unexpectedly — batch dropped")}),this.H.length>0&&this.et()}catch(t){e.warn("Transport","flush() threw unexpectedly:",t)}}start(){this.C||(this.C=1,this.V="undefined"!=typeof navigator?navigator.onLine:1)}stop(){if(!this.C)return Promise.resolve();h(this.N),this.N=null,h(this.K),this.K=null;const t=this.it();return this.C=0,t}onConnectionChange(){const t="undefined"!=typeof navigator?navigator.onLine:1;if(t!==this.V){if(this.V=t,!this.V)return h(this.N),this.N=null,h(this.K),void(this.K=null);this.H.length>0&&this.et(),this.X.length>0&&this.st()}}et(){this.C&&this.V&&null===this.N&&(this.N=f(()=>{this.N=null,this.flush("interval")},this.W))}st(){this.C&&this.V&&null===this.K&&(this.K=f(()=>{this.K=null,this.ct()},this.W))}ct(){if(!this.C||!this.V||0===this.X.length||!this.F.isActivityActive())return;const t=this.X.shift();this.F.ingest(t.batch,0).then(n=>this.ut(n,t)).catch(()=>{e.warn("Transport","retry drain ingest threw unexpectedly — batch dropped"),this.X.length>0&&this.st()})}lt(t,n){this.X.length>=5&&(this.X.shift(),e.warn("Transport","retry queue full — oldest batch evicted")),this.X.push({batch:t,attempts:n}),this.st()}ot(t,n){t.ok?this.ft():this.ht(t)&&this.lt(n,1)}ut(t,n){if(t.ok)return this.ft(),void(this.X.length>0&&this.st());if(this.ht(t)){if(n.attempts>=3)return this.dt(),e.warn("Transport","batch dropped after MAX_RETRY_ATTEMPTS",n.batch.batchId),void(this.X.length>0&&this.st());this.dt(),this.lt(n.batch,n.attempts+1)}else this.X.length>0&&this.st()}dt(){this.Y++,this.Y%this.q.flush.backoffFailureThreshold===0&&(this.W=Math.min(2*this.W,this.q.flush.maxIntervalMs))}ft(){this.Y=0,this.W=this.q.flush.intervalMs}tt(){return this.q.queue.size*(this.V?1:2)}async it(){if(!this.F.isActivityActive())return Promise.resolve();const t=[];for(const n of this.X)t.push(this.F.ingest(n.batch,1).catch(()=>{e.warn("Transport","lifecycle retry ingest threw — batch dropped")}));if(this.X=[],this.H.length>0){const n=this.rt("lifecycle");t.push(this.F.ingest(n,1).catch(()=>{e.warn("Transport","lifecycle ingest threw — batch dropped")}))}return Promise.allSettled(t).then(()=>{})}nt(t){const n=gt(t);for(let e=0;e<this.H.length;e++)if(gt(this.H[e])<n){for(let t=e;t<this.H.length-1;t++)this.H[t]=this.H[t+1];return this.H.length-=1,void this.H.push(t)}}rt(t){const n="lifecycle"===t?this.H.splice(-this.q.flush.size):this.H.splice(0,this.q.flush.size);return{activityId:"",batchId:Mt(),batchSequence:this.J++,clientTimestamp:Date.now(),schemaVersion:"0.1.0",sdkVersion:"0.3.1-rc.0",sdkPlatform:"web",tabId:this.F.getTabId(),events:n}}ht(t){if(t.ok)return 0;switch(t.kind){case"timeout":case"server":case"rate_limited":return 1;default:return 0}}}const At="tri:bcast:";const zt="function"==typeof BroadcastChannel?BroadcastChannel:function(){if("undefined"==typeof Storage||"undefined"==typeof window)return 0;try{const t="__tri_bcast_probe__";localStorage.setItem(t,"1");const n="1"===localStorage.getItem(t);return localStorage.removeItem(t),n}catch{return 0}}()?class{constructor(t){this.seq=0,this.closed=0,this.listeners=new Set,this.onStorageEvent=t=>{if(this.closed)return;if(!t.key||!t.key.startsWith(`${At}${this.channelName}:`))return;if(null===t.newValue)return;let n;a(()=>j.remove(t.key));try{n=JSON.parse(t.newValue)}catch{return}const e={data:n};for(const t of this.listeners)a(()=>t(e))},this.channelName=t,this.senderId=Mt(),window.addEventListener("storage",this.onStorageEvent)}postMessage(t){if(this.closed)return;const n=`${At}${this.channelName}:${this.senderId}:${this.seq++}`;a(()=>{j.set(n,t),j.remove(n)})}addEventListener(t,n){this.listeners.add(n)}removeEventListener(t,n){this.listeners.delete(n)}close(){this.closed||(this.closed=1,window.removeEventListener("storage",this.onStorageEvent),this.listeners.clear())}}:class{constructor(t){e.warn("BroadcastChannel","BroadcastChannel is unavailable and localStorage is not writable in this context. Cross-tab discovery is disabled; tab count will always be reported as 1.")}postMessage(t){}addEventListener(t,n){}removeEventListener(t,n){}close(){}},Dt="__tri_tabId";class Pt{constructor(t){this.context=t,this.vt="",this.C=0,this.wt=null,this.yt=null,this.gt=null,this.bt=new Map,this.kt=-1,this.Tt=null}async start(){this.C||(this.C=1,this.vt=this._t(),this.It(),this.St({type:"hello",tabId:this.vt,ts:Date.now()}),this.xt(),this.Mt("active"),this.Et())}stop(){this.C&&(this.C=0,this.Mt("inactive"),this.St({type:"bye",tabId:this.vt,ts:Date.now()}),this.At(this.zt()),this.Dt(),this.Pt(),this.Ct())}getTabId(){return this.vt}queryTabsNumber(){return this.bt.size+1}It(){try{this.wt=new zt("__tri_tab_channel"),this.Tt=this.Ut.bind(this),this.wt.addEventListener("message",this.Tt)}catch(t){e.warn("TabManager","failed to open broadcast channel:",t)}}Ct(){try{if(!this.wt)return;this.Tt&&this.wt.removeEventListener("message",this.Tt),this.wt.close()}catch{}finally{this.wt=null,this.Tt=null}}xt(){this.yt=setInterval(()=>{const t=Date.now();this.St({type:"heartbeat",tabId:this.vt,ts:t})},1e3)}Dt(){null!=this.yt&&(clearInterval(this.yt),this.yt=null)}Et(){null!=this.gt&&clearTimeout(this.gt),this.gt=setTimeout(()=>{this.gt=null;const t=this.zt()+1;t!==this.kt&&(this.kt=t,this.At(t))},1e3)}Pt(){null!=this.gt&&(clearTimeout(this.gt),this.gt=null)}St(t){try{if(!this.wt)return;this.wt.postMessage(t)}catch{e.warn("TabManager","failed to broadcast message:",t)}}Ut(t){const{type:n,tabId:e}=t.data;if(e===this.vt)return;const i=Date.now();"hello"===n?(this.St({type:"ack",tabId:this.vt,ts:i,to:e}),this.bt.set(e,i)):"heartbeat"===n||"ack"===n?this.bt.set(e,i):"bye"===n&&this.bt.delete(e)}At(t){this.context.events.count&&this.context.push({name:"tab",type:"count",tabId:this.vt,timestamp:Date.now(),value:t})}Mt(t){this.context.events.state&&this.context.push({name:"tab",type:"state",tabId:this.vt,timestamp:Date.now(),value:t})}_t(){const t=q.get(Dt);if(t)return t;const n=Mt();return q.set(Dt,n),n}zt(t=Date.now()){let n=0;for(const[e,i]of this.bt.entries())t-i>=3e3?this.bt.delete(e):n++;return n}}const Ct=globalThis.CompressionStream,Ut=globalThis.Response,Lt=globalThis.Blob,Rt=new TextEncoder;let $t=null;async function Ot(t){const n=await async function(t){if("function"!=typeof Ct)return null;try{const n=Rt.encode(t),e=new Lt([n]).stream().pipeThrough(new Ct("gzip"));return await new Ut(e).arrayBuffer()}catch(t){return e.warn("compression","Native gzip failed:",t),null}}(t);return null!==n?n:async function(t){try{const n=await function(){if(null===$t){const t=function(t,n=1e4){let i=null;const r=new Promise(t=>{i=f(()=>{e.warn("import",`Import timed out after ${n}ms`),t(null)},n)}),o=Promise.resolve().then(t).catch(t=>(e.warn("import","Import failed:",t),null));return Promise.race([o,r]).finally(()=>{h(i)})}(()=>Promise.resolve().then(function(){return Ti}),1e4);$t=t,t.then(n=>{null===n&&f(()=>{$t===t&&($t=null)},1e4)})}return $t}();if(null===n)return null;const{gzipSync:i}=n,r=i(Rt.encode(t));return r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength)}catch(t){return e.warn("compression","fflate gzip failed:",t),null}}(t)}function Bt(t){const n={Accept:"application/json"};return t?.hasBody&&("json"===t.contentType?n["Content-Type"]="application/json":"ndjson"===t.contentType&&(n["Content-Type"]="application/x-ndjson"),"gzip"===t.contentEncoding&&(n["Content-Encoding"]="gzip")),t?.token&&(n.Authorization=`Bearer ${t.token}`),t?.profileId&&(n["x-profile-id"]=t.profileId),t?.api?.version&&(n["x-api-version"]=t.api.version),t?.customHeaders&&Object.entries(t.customHeaders).forEach(([t,e])=>{n[t]=e}),n}const jt="function"==typeof globalThis.fetch?globalThis.fetch.bind(globalThis):void 0;class qt{constructor(t){this.context=t}stop(){}async report(t,n){const i={name:t,metadata:n,timestamp:Date.now(),activityId:this.context.getActivityId()??""};try{const r=await this.context.reportEvent(i);if(r.ok)return r;e.warn("EventReport","Failed to report event:",t,n,"with result:",r)}catch(i){e.warn("EventReport","Failed to report event:",t,n,"with error:",i)}}}const Ft=new Set(["A","BUTTON","INPUT","SELECT","TEXTAREA","SUMMARY","DETAILS","LABEL","OPTION","FIELDSET"]),Ht=new Set(["button","link","tab","menuitem","menuitemcheckbox","menuitemradio","checkbox","radio","switch","slider","spinbutton","combobox","listbox","option","searchbox","textbox","treeitem"]),Nt=255;function Zt(t,n,e){const i=t.tagName.toLowerCase(),r=function(t){const n=t.parentElement?.children??[],e=Math.min(n.length,1e3);let i=e-1,r=0,o=0;for(let i=0;i<e;i++){o++;const e=n[i];if(b(e,t.tagName)&&r++,e===t)break}return{siblings:i,ofType:r,child:o}}(t),o=function(t,n){const e=function(t){if(!t)return null;const n=t.getAttribute("data-tri-redact-attrs");return n?n.split(",").map(t=>t.trim().toLowerCase()):null}(t),i={},r=t.id;r&&!I("id",e)&&(i.id=r);const o=t.getAttribute("autocomplete");o&&!I("autocomplete",e)&&(i.autocomplete=o);const s=t.getAttribute("aria-invalid");s&&!I("aria-invalid",e)&&(i.ariaInvalid=s);const a=t.getAttribute("tabindex");a&&!I("tabindex",e)&&(i.tabIndex=parseInt(a,10));const c=function(t){return t.getAttribute("data-testid")??t.getAttribute("data-cy")??null}(t);c&&!I("data-testid",e)&&(i.testId=c);const u=t.hasAttribute("readonly");u&&!I("readonly",e)&&(i.readOnly=u);const l=t.hasAttribute("required");l&&!I("required",e)&&(i.required=l);const f=t.getAttribute("contenteditable");f&&!I("contenteditable",e)&&(i.contentEditable="true"===f||""===f);const h=t.getAttribute("href");h&&!I("href",e)&&(i.href={...n?{}:{url:h},external:S(h)});const d=t.getAttribute("role");d&&!I("role",e)&&(i.role=d);const v=t.getAttribute("type");v&&!I("type",e)&&(i.type=v);const p=t.getAttribute("name");p&&!I("name",e)&&(i.name=p);const w=t.getAttribute("placeholder");!w||n||I("placeholder",e)||(i.placeholder=w);const m=Array.from(t.classList).slice(0,5);m.length>0&&!I("class",e)&&(i.classes=m);const y=t.getAttribute("alt");return!y||n||I("alt",e)||(i.alt=y),Object.keys(i).length?i:null}(t,n);return{tagName:i,frame:e,...o?{attributes:o}:{},...r?{nth:r}:{}}}function Xt(t,n){let e=0;const i=[];return function(t){return Ft.has(t.tagName)}(t)&&(e+=40,i.push("native")),function(t){return t.hasAttribute("data-tri-interactive")}(t)&&(e+=40,i.push("tri-interactive")),function(t){return b(t,"a")&&t.hasAttribute("href")}(t)&&(e+=15,i.push("has-href")),function(t){const n=t.getAttribute("role");return null!==n&&Ht.has(n)}(t)&&(e+=30,i.push("role")),function(t){return t.hasAttribute("onclick")||t.hasAttribute("ng-click")||t.hasAttribute("data-action")||t.hasAttribute("@click")}(t)&&(e+=20,i.push("click-handler")),function(t){const n=t.getAttribute("tabindex");if(null===n)return 0;const e=parseInt(n,10);return null!==e&&e>=0}(t)&&(e+=10,i.push("tabindex")),(t.id||t.getAttribute("data-testid"))&&(e+=5,i.push("has-id")),n>0&&(e+=Math.round(15/n),i.push("depth")),{score:e,reasons:i}}function Gt(t){return t>=20}function Kt(t){return null!==t&&t.width>0&&t.height>0&&t.y<window.innerHeight&&t.y+t.height>0&&t.x<window.innerWidth&&t.x+t.width>0}function Vt(t){return 1==t.disabled||"true"===t.getAttribute("aria-disabled")}function Yt(t,n=0){if(n)return null;const e=Qt(t,"labelledby");if(e)return{text:tn(e),resolutionMethod:"aria-labelledby",confidence:"high"};const i=Wt(t);if(i)return{text:tn(i),resolutionMethod:"aria-label",confidence:"high"};const r=function(t){if(!t.id)return null;const n=document.querySelector(`label[for="${CSS.escape(t.id)}"]`);return n?Jt(n):null}(t);if(r)return{text:tn(r),resolutionMethod:"html-for",confidence:"high"};const o=function(t){const n=t.closest("label");return n?Jt(n):null}(t);if(o)return{text:tn(o),resolutionMethod:"wrapping-label",confidence:"high"};const s=function(t){const n=t.getAttribute("placeholder");return n?.trim()??null}(t);if(s)return{text:tn(s),resolutionMethod:"placeholder",confidence:"low"};const a=function(t){const n=t.getAttribute("title");return n?.trim()??null}(t);if(a)return{text:tn(a),resolutionMethod:"title",confidence:"low"};const c=Qt(t,"describedby");if(c)return{text:tn(c),resolutionMethod:"aria-describedby",confidence:"low"};const u=Jt(t);return u?{text:u,resolutionMethod:"text-content",confidence:"low"}:null}function Jt(t,n=0){if(n>8)return"";if(g(t))return function(t){return t?t.trim().split(/(\s+)/).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,Nt):null}(t.textContent)??"";if(!t.childNodes?.length)return"";let e="";for(const i of t.childNodes){const t=Jt(i,n+1);if(t&&(e=e?`${e} ${t}`:t,e.length>=Nt))break}return tn(e)}function Qt(t,n){const e="labelledby"===n?"aria-labelledby":"aria-describedby",i=t?.getAttribute(e);if(!i)return null;const r=i.split(/\s+/),o=[];for(const t of r){const n=document.getElementById(t);if(!n)continue;const e=Wt(n)??Jt(n);e.length&&o.push(e)}return o.length?o.join(" "):null}function Wt(t){return t?.getAttribute("aria-label")?.trim()??null}function tn(t){return t.length>Nt?t.slice(0,Nt)+"...":t}function nn(t){const n=t.getBoundingClientRect();return{x:n.x,y:n.y,width:n.width,height:n.height}}class en{constructor(t){this.capacity=t,this.cache=new Map}get(t){return this.cache.get(t)}set(t,n){if(this.cache.has(t))this.cache.delete(t);else if(this.cache.size>=this.capacity){const t=this.cache.keys().next().value;t&&this.cache.delete(t)}this.cache.set(t,n)}delete(t){this.cache.delete(t)}clear(){this.cache.clear()}size(){return this.cache.size}}async function rn(t,n){const{collectors:o,sdk:s}=t;let a=null,c=null,l=null,d=null;try{a=function(t){"undefined"!=typeof document&&"function"==typeof globalThis.fetch||e.warn("FalconService","createFalconServiceManager called in a non-browser environment — all requests will resolve with { ok: false, kind: 'network' }.");const n=function(t){const n=t?.timeout,e=t?.baseUrl??"",i=t?.api;async function r(t,r,o){if(void 0===jt)return{ok:0,kind:"network"};const s=e?`${e}${r}`:r,a=new AbortController;let c=null,u=0;c=f(()=>{u=1,a.abort()},n);const l=o?.signal;let d,v=()=>{};if(l)if(l.aborted)a.abort();else{const t=()=>a.abort();l.addEventListener("abort",t,{once:1}),v=()=>l.removeEventListener("abort",t)}if(null!=o&&"body"in o&&null!=o.body){const t=function(t){if(null==t)return{ok:1,body:void 0};if("string"==typeof t||t instanceof ArrayBuffer||ArrayBuffer.isView(t)||t instanceof Blob||t instanceof FormData||t instanceof URLSearchParams||t instanceof ReadableStream)return{ok:1,body:t};try{return{ok:1,body:JSON.stringify(t)}}catch{return{ok:0}}}(o.body);if(!t.ok)return h(c),v(),{ok:0,kind:"serialize"};d=t.body}try{const n=await jt(s,{method:t,headers:Bt({token:o?.token,profileId:o?.profileId,contentType:o?.contentType,contentEncoding:o?.contentEncoding,api:i,hasBody:void 0!==d,customHeaders:o?.customHeaders}),body:d,signal:a.signal,keepalive:o?.keepalive});if(!n.ok)return 429===(p=n.status)?{ok:0,kind:"rate_limited",status:p}:p>=400&&p<500?{ok:0,kind:"client",status:p}:{ok:0,kind:"server",status:p};if(204===n.status)return{ok:1,data:void 0,status:204};try{return{ok:1,data:await n.json(),status:n.status}}catch{return a.signal.aborted?u?{ok:0,kind:"timeout"}:{ok:0,kind:"abort"}:{ok:0,kind:"parse",status:n.status}}}catch{return u?{ok:0,kind:"timeout"}:a.signal.aborted?{ok:0,kind:"abort"}:{ok:0,kind:"network"}}finally{h(c),v()}var p}return{post:async function(t,n){return r("POST",t,n)},get:async function(t,n){return r("GET",t,n)}}}({baseUrl:`${t.api.url}/api/v1`,timeout:1e4,api:{version:t.api.version}}),i=function(t){const{getToken:n,refresh:i}=t;let r=null;return{withAuth:async function(t,o){if(r){const n=await r;if(n)return t(n)}const s=n()??"",a=await t(s);if((c=a).ok||"client"!==c.kind||!mt.includes(c.status)||0==o?.refreshable)return a;var c;const u=await(r||(r=async function(){try{return await i(),n()}catch(t){return e.warn("AuthMiddleware","auth refresh failed",t),null}}().finally(()=>{r=null}),r));return u&&u!==s?t(u):a}}}(t),r=()=>({profileId:t.getProfileId()??void 0});return{api:{ingest:async function(e,o){return i.withAuth(async i=>{const{events:s,...a}=e,c={...a,activityId:t.getActivityId()};let u;try{u=await async function(t,n){const e=function(t,n){const e=[JSON.stringify(t)];for(let t=0;t<n.length;t++)try{e.push(JSON.stringify(n[t]))}catch{}return e.join("\n")}(t,n),i=await Ot(e);return i?{type:"gzip",body:i}:{type:"ndjson",body:e}}(c,s)}catch{return{ok:0,kind:"serialize"}}return n.post("/events/capture",{body:u.body,token:i,keepalive:o,contentType:"ndjson",contentEncoding:"gzip"===u.type?"gzip":void 0,...r()})},{refreshable:!o})},reportEvent:async function(t){return i.withAuth(e=>n.post("/events/report-event",{body:t,token:e,contentType:"json",...r()}))},startActivity:async function(){return n.post("/events/start-activity",{token:t.getSdkToken(),...r()})},stopActivity:async function(){return i.withAuth(t=>n.post("/events/end-activity",{token:t,keepalive:1,...r()}),{refreshable:0})},collectionStatus:async function(){return n.get("/sdk/collection-status",{token:t.getSdkToken(),...r()})},linkInterview:async function(t){return i.withAuth(e=>n.post("/events/link-interview",{token:e,contentType:"json",...r(),customHeaders:{"X-Incode-Hardware-Id":t}}))}}}}({api:{version:s.api.version,url:s.api.url},getSdkToken:()=>s.token,getProfileId:()=>n.getProfileId(),getToken:()=>c?.getToken()??null,refresh:async()=>c?.refresh()??Promise.resolve(),getActivityId:()=>c?.getActivityId()??""});const t=await a.api.collectionStatus();if(!t.ok||1!=t.data.eventsCollectionEnabled)return{status:"collection-disabled"};c=new wt({startActivity:()=>a.api.startActivity(),stopActivity:()=>a.api.stopActivity()}),l=new Et(it,{ingest:(t,n)=>a.api.ingest(t,n),getTabId:()=>d?.getTabId()??"unknown",isActivityActive:()=>c?.isActive()??0});const v=o.tab;d=new Pt({push:t=>l?.push(t),events:{state:v.enabled&&v.events.state.enabled,count:v.enabled&&v.events.count.enabled}});const p=function(t){function n(n){"hidden"===document.visibilityState&&t.flush()}function e(n){t.flush(),t.stopTab(),t.getShouldSkipStopActivity()||t.stopActivity()}const o=u(()=>t.onConnectionChange());return{start:function(){i(document,"visibilitychange",n),i(window,"pagehide",e),i(window,"online",o),i(window,"offline",o)},stop:function(){r(document,"visibilitychange",n),r(window,"pagehide",e),r(window,"online",o),r(window,"offline",o)}}}({flush:()=>l?.flush("lifecycle"),stopActivity:async()=>c?.stop(),stopTab:()=>d?.stop(),getShouldSkipStopActivity:()=>(d?.queryTabsNumber()??0)>1,onConnectionChange:()=>l?.onConnectionChange()}),w=function(t){const n=t||"redact",e=new en(6),i=new en(6);return{resolve:function(t){if(!t||T(t)||"off"===n)return null;let r=e.get(t);if(r||(r=function(t){if(!t||T(t))return{chain:[],redaction:{level:"ignore",index:-1}};const n=[];let e=t,i=-1;for(;e;){if(T(e))return{chain:[],redaction:{level:"ignore",index:-1}};_(e)&&(i=n.length),n.push(e);const t=e.parentNode;if(!t||b(e,"body"))break;e=k(t)?t.host:t}return{chain:n,redaction:{level:-1===i?"full":"redact",index:i}}}(t.parentElement),e.set(t,r)),"ignore"===r.redaction.level)return null;const o="redact"===r.redaction.level||"redact"===n||_(t);let s=i.get(t);return s||(s=function(t,n,e,i){const r=getComputedStyle(t),o=nn(t),s=function(t,n){const e=[],i=[];for(let r=t.length-1;r>=0;r--){const o=t[r],s=r<=n,a=r+1,c=Zt(o,s,nn(o)),{score:u,reasons:l}=Xt(o,a);if(e.push(c),!Gt(u))continue;const f=Yt(o,s);i.push({...c,...f?{label:f}:{},depth:a,score:u,reasons:l})}return{ancestors:e,interactiveCandidates:i.reverse()}}(n,i),a=Zt(t,e,o),c=function(t,n,e){const{score:i,reasons:r}=Xt(t,0);return{interactive:Gt(i),...r.length>0?{reasons:r}:{},disabled:Vt(t),rendered:"none"!==n?.display,visible:"hidden"!==n?.visibility,inViewport:Kt(e),acceptsPointer:"none"!==n?.pointerEvents,opacity:parseFloat(n?.opacity||"1")}}(t,r,o);let u=null;return e||(u=c.interactive?Yt(t):null),{tagName:a.tagName,frame:a.frame,viewport:{height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio},attributes:a.attributes,nth:a.nth,...u?{label:u}:{},ancestors:s.ancestors,interactiveCandidates:s.interactiveCandidates,interactivity:c}}(t,r.chain,o,r.redaction.index),i.set(t,s)),s}}}(s.capture?.element),m=new Set;try{m.add(new URL(s.api.url).origin)}catch{}const y=function(t,n,e="on"){const i=new Map;function r(r){if(i.has(r))return;const o=W[r];if(!o||!function(t,n){return n[t]?.enabled??0}(r,n))return;const s=n[r],a=o.create(t,e,s&&"events"in s?s.events:void 0);i.set(r,a)}return{start:r,stopCollector:function(t){const n=i.get(t);n&&(n(),i.delete(t))},stop:function(){for(const[,t]of i)t();i.clear()},isRunning:function(t){return i.has(t)},autocapture:function(){for(const t of tt)r(t)}}}({push:t=>l?.push(t),resolveElement:t=>w.resolve(t),sanitizeUrl:s.sanitizeUrl,ignoredOrigins:m},o,s.capture?.content),g=new qt({getActivityId:()=>c?.getActivityId()??"",reportEvent:t=>a.api.reportEvent(t)});return{status:"ready",managers:{falconServiceManager:a,activityManager:c,transportManager:l,tabManager:d,lifecycleManager:p,collectorManager:y,eventReportManager:g}}}catch(t){return e.warn("IncodeTRI","setup() failed during construction:",t),{status:"init-failed"}}}let on=class t{constructor(){this.Lt=0,this.q=null,this.Rt=null,this.$t="idle"}static get instance(){return t._||(t._=new t),t._}async setup(t){if("idle"!==this.$t)return e.fatal("error","setup()","called more than once — ignoring."),"init-failed";try{const n=function(t){if("undefined"==typeof document)return e.fatal("error","IncodeTRI","TRI is not available in a non-browser environment."),null;if(!t?.token)return e.fatal("error","SDK","token is required."),null;if(!t.apiURL)return e.fatal("error","SDK","Couldn't initialise SDK — apiURL isn't provided."),null;const{element:n,content:i}=t.capture??{},r={token:t.token,capture:{element:n??"redact",content:i??"off"},profileId:t.profileId,api:{version:t.apiVersion??"1.0",url:t.apiURL},sanitizeUrl:(o=t.sanitizeUrl,o?function(t){return a(()=>o(t,et))??et(t)}:et),DEBUG:t.DEBUG??0};var o;return void 0===t.collectors&&void 0===t.layers?{sdk:r,collectors:rt()}:void 0!==t.collectors?{sdk:r,collectors:st(t.collectors)}:{sdk:r,collectors:ot(t.layers)}}(t);if(!n)return"init-failed";e.DEBUG=n.sdk.DEBUG;const i=await rn(n,{getProfileId:()=>this.Ot()});return"collection-disabled"===i.status?(e.fatal("warn","setup()","Collection is disabled for the provided API Key."),"collection-disabled"):"init-failed"===i.status?"init-failed":(this.q=n,this.Rt=i.managers,this.$t="ready",this.Bt(n.sdk.profileId),"ready")}catch(t){return e.warn("setup()","failed:",t),"init-failed"}}async start(){if("idle"===this.$t)return e.warn("start()","start() requires a prior successful setup() — ignoring."),this.$t;if("ready"!==this.$t)return e.fatal("warn","start()","TRI is either already started or isn't ready — ignoring."),this.$t;this.$t="starting";const t=++this.Lt;return await this.U(t),this.$t}async stop(){e.warn("stop()","called");const t=this.Rt;return t?(++this.Lt,t.lifecycleManager.stop(),t.collectorManager.stop(),t.tabManager.stop(),t.eventReportManager.stop(),this.$t="ready",this.jt(t)):Promise.resolve(this.$t)}async reset(){const t=this.stop();return this.$t="idle",this.q=null,this.Rt=null,j.remove("__tri_profile_id"),t.then(()=>this.$t)}async jt(t){return await function(t){let n=null;const e=new Promise(t=>{n=f(t,2e3)});return Promise.race([t.finally(()=>h(n)),e])}(Promise.resolve(t.transportManager.stop())),await t.activityManager.stop(),this.$t}reportEvent(t,n){"started"===this.$t?this.Rt?c(()=>this.Rt.eventReportManager.report(t,n)):e.warn("reportEvent()","reportEvent() called but managers are unavailable — dropping event."):e.warn("reportEvent()","reportEvent() called before start() completed — dropping event.")}setProfileId(t){"started"===this.$t?this.q?.sdk&&(this.q.sdk.profileId=t,this.Bt(t)):e.warn("setProfileId()","setProfileId() called before start() completed — ignoring.")}async linkInterview(t){if("started"!==this.$t||!this.Rt)return e.warn("linkInterview()","linkInterview() called before start() completed — ignoring."),0;if(!t)return e.warn("linkInterview()","linkInterview() called without sessionToken — ignoring."),0;try{return(await this.Rt.falconServiceManager.api.linkInterview(t)).ok}catch(t){return e.warn("linkInterview()","failed:",t),0}}Ot(){return this.q?.sdk?.profileId??j.get("__tri_profile_id")??null}Bt(t){t&&j.set("__tri_profile_id",t)}async U(t){const n=this.Rt;if(n){try{if(await n.activityManager.start(),t!==this.Lt)return;if(n.transportManager.start(),await n.tabManager.start(),t!==this.Lt)return;n.lifecycleManager.start(),n.collectorManager.autocapture()}catch(n){return e.warn("start()","failed during monitoring start:",n),void(t===this.Lt&&(this.$t="ready"))}t===this.Lt&&(this.$t="started")}}};on._=null;const sn=on.instance;var an={},cn=Uint8Array,un=Uint16Array,ln=Int32Array,fn=new cn([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),hn=new cn([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),dn=new cn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),vn=function(t,n){for(var e=new un(31),i=0;i<31;++i)e[i]=n+=1<<t[i-1];var r=new ln(e[30]);for(i=1;i<30;++i)for(var o=e[i];o<e[i+1];++o)r[o]=o-e[i]<<5|i;return{b:e,r:r}},pn=vn(fn,2),wn=pn.b,mn=pn.r;wn[28]=258,mn[258]=28;for(var yn=vn(hn,0),gn=yn.b,bn=yn.r,kn=new un(32768),Tn=0;Tn<32768;++Tn){var _n=(43690&Tn)>>1|(21845&Tn)<<1;kn[Tn]=((65280&(_n=(61680&(_n=(52428&_n)>>2|(13107&_n)<<2))>>4|(3855&_n)<<4))>>8|(255&_n)<<8)>>1}var In=function(t,n,e){for(var i=t.length,r=0,o=new un(n);r<i;++r)t[r]&&++o[t[r]-1];var s,a=new un(n);for(r=1;r<n;++r)a[r]=a[r-1]+o[r-1]<<1;if(e){s=new un(1<<n);var c=15-n;for(r=0;r<i;++r)if(t[r])for(var u=r<<4|t[r],l=n-t[r],f=a[t[r]-1]++<<l,h=f|(1<<l)-1;f<=h;++f)s[kn[f]>>c]=u}else for(s=new un(i),r=0;r<i;++r)t[r]&&(s[r]=kn[a[t[r]-1]++]>>15-t[r]);return s},Sn=new cn(288);for(Tn=0;Tn<144;++Tn)Sn[Tn]=8;for(Tn=144;Tn<256;++Tn)Sn[Tn]=9;for(Tn=256;Tn<280;++Tn)Sn[Tn]=7;for(Tn=280;Tn<288;++Tn)Sn[Tn]=8;var xn=new cn(32);for(Tn=0;Tn<32;++Tn)xn[Tn]=5;var Mn=In(Sn,9,0),En=In(Sn,9,1),An=In(xn,5,0),zn=In(xn,5,1),Dn=function(t){for(var n=t[0],e=1;e<t.length;++e)t[e]>n&&(n=t[e]);return n},Pn=function(t,n,e){var i=n/8|0;return(t[i]|t[i+1]<<8)>>(7&n)&e},Cn=function(t,n){var e=n/8|0;return(t[e]|t[e+1]<<8|t[e+2]<<16)>>(7&n)},Un=function(t){return(t+7)/8|0},Ln=function(t,n,e){return(null==n||n<0)&&(n=0),(null==e||e>t.length)&&(e=t.length),new cn(t.subarray(n,e))},Rn=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],$n=function(t,n,e){var i=new Error(n||Rn[t]);if(i.code=t,Error.captureStackTrace&&Error.captureStackTrace(i,$n),!e)throw i;return i},On=function(t,n,e,i){var r=t.length,o=i?i.length:0;if(!r||n.f&&!n.l)return e||new cn(0);var s=!e,a=s||2!=n.i,c=n.i;s&&(e=new cn(3*r));var u=function(t){var n=e.length;if(t>n){var i=new cn(Math.max(2*n,t));i.set(e),e=i}},l=n.f||0,f=n.p||0,h=n.b||0,d=n.l,v=n.d,p=n.m,w=n.n,m=8*r;do{if(!d){l=Pn(t,f,1);var y=Pn(t,f+1,3);if(f+=3,!y){var g=t[(z=Un(f)+4)-4]|t[z-3]<<8,b=z+g;if(b>r){c&&$n(0);break}a&&u(h+g),e.set(t.subarray(z,b),h),n.b=h+=g,n.p=f=8*b,n.f=l;continue}if(1==y)d=En,v=zn,p=9,w=5;else if(2==y){var k=Pn(t,f,31)+257,T=Pn(t,f+10,15)+4,_=k+Pn(t,f+5,31)+1;f+=14;for(var I=new cn(_),S=new cn(19),x=0;x<T;++x)S[dn[x]]=Pn(t,f+3*x,7);f+=3*T;var M=Dn(S),E=(1<<M)-1,A=In(S,M,1);for(x=0;x<_;){var z,D=A[Pn(t,f,E)];if(f+=15&D,(z=D>>4)<16)I[x++]=z;else{var P=0,C=0;for(16==z?(C=3+Pn(t,f,3),f+=2,P=I[x-1]):17==z?(C=3+Pn(t,f,7),f+=3):18==z&&(C=11+Pn(t,f,127),f+=7);C--;)I[x++]=P}}var U=I.subarray(0,k),L=I.subarray(k);p=Dn(U),w=Dn(L),d=In(U,p,1),v=In(L,w,1)}else $n(1);if(f>m){c&&$n(0);break}}a&&u(h+131072);for(var R=(1<<p)-1,$=(1<<w)-1,O=f;;O=f){var B=(P=d[Cn(t,f)&R])>>4;if((f+=15&P)>m){c&&$n(0);break}if(P||$n(2),B<256)e[h++]=B;else{if(256==B){O=f,d=null;break}var j=B-254;B>264&&(j=Pn(t,f,(1<<(H=fn[x=B-257]))-1)+wn[x],f+=H);var q=v[Cn(t,f)&$],F=q>>4;if(q||$n(3),f+=15&q,L=gn[F],F>3){var H=hn[F];L+=Cn(t,f)&(1<<H)-1,f+=H}if(f>m){c&&$n(0);break}a&&u(h+131072);var N=h+j;if(h<L){var Z=o-L,X=Math.min(L,N);for(Z+h<0&&$n(3);h<X;++h)e[h]=i[Z+h]}for(;h<N;++h)e[h]=e[h-L]}}n.l=d,n.p=O,n.b=h,n.f=l,d&&(l=1,n.m=p,n.d=v,n.n=w)}while(!l);return h!=e.length&&s?Ln(e,0,h):e.subarray(0,h)},Bn=function(t,n,e){var i=n/8|0;t[i]|=e<<=7&n,t[i+1]|=e>>8},jn=function(t,n,e){var i=n/8|0;t[i]|=e<<=7&n,t[i+1]|=e>>8,t[i+2]|=e>>16},qn=function(t,n){for(var e=[],i=0;i<t.length;++i)t[i]&&e.push({s:i,f:t[i]});var r=e.length,o=e.slice();if(!r)return{t:Kn,l:0};if(1==r){var s=new cn(e[0].s+1);return s[e[0].s]=1,{t:s,l:1}}e.sort(function(t,n){return t.f-n.f}),e.push({s:-1,f:25001});var a=e[0],c=e[1],u=0,l=1,f=2;for(e[0]={s:-1,f:a.f+c.f,l:a,r:c};l!=r-1;)a=e[e[u].f<e[f].f?u++:f++],c=e[u!=l&&e[u].f<e[f].f?u++:f++],e[l++]={s:-1,f:a.f+c.f,l:a,r:c};var h=o[0].s;for(i=1;i<r;++i)o[i].s>h&&(h=o[i].s);var d=new un(h+1),v=Fn(e[l-1],d,0);if(v>n){i=0;var p=0,w=v-n,m=1<<w;for(o.sort(function(t,n){return d[n.s]-d[t.s]||t.f-n.f});i<r;++i){var y=o[i].s;if(!(d[y]>n))break;p+=m-(1<<v-d[y]),d[y]=n}for(p>>=w;p>0;){var g=o[i].s;d[g]<n?p-=1<<n-d[g]++-1:++i}for(;i>=0&&p;--i){var b=o[i].s;d[b]==n&&(--d[b],++p)}v=n}return{t:new cn(d),l:v}},Fn=function(t,n,e){return-1==t.s?Math.max(Fn(t.l,n,e+1),Fn(t.r,n,e+1)):n[t.s]=e},Hn=function(t){for(var n=t.length;n&&!t[--n];);for(var e=new un(++n),i=0,r=t[0],o=1,s=function(t){e[i++]=t},a=1;a<=n;++a)if(t[a]==r&&a!=n)++o;else{if(!r&&o>2){for(;o>138;o-=138)s(32754);o>2&&(s(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(s(r),--o;o>6;o-=6)s(8304);o>2&&(s(o-3<<5|8208),o=0)}for(;o--;)s(r);o=1,r=t[a]}return{c:e.subarray(0,i),n:n}},Nn=function(t,n){for(var e=0,i=0;i<n.length;++i)e+=t[i]*n[i];return e},Zn=function(t,n,e){var i=e.length,r=Un(n+2);t[r]=255&i,t[r+1]=i>>8,t[r+2]=255^t[r],t[r+3]=255^t[r+1];for(var o=0;o<i;++o)t[r+o+4]=e[o];return 8*(r+4+i)},Xn=function(t,n,e,i,r,o,s,a,c,u,l){Bn(n,l++,e),++r[256];for(var f=qn(r,15),h=f.t,d=f.l,v=qn(o,15),p=v.t,w=v.l,m=Hn(h),y=m.c,g=m.n,b=Hn(p),k=b.c,T=b.n,_=new un(19),I=0;I<y.length;++I)++_[31&y[I]];for(I=0;I<k.length;++I)++_[31&k[I]];for(var S=qn(_,7),x=S.t,M=S.l,E=19;E>4&&!x[dn[E-1]];--E);var A,z,D,P,C=u+5<<3,U=Nn(r,Sn)+Nn(o,xn)+s,L=Nn(r,h)+Nn(o,p)+s+14+3*E+Nn(_,x)+2*_[16]+3*_[17]+7*_[18];if(c>=0&&C<=U&&C<=L)return Zn(n,l,t.subarray(c,c+u));if(Bn(n,l,1+(L<U)),l+=2,L<U){A=In(h,d,0),z=h,D=In(p,w,0),P=p;var R=In(x,M,0);for(Bn(n,l,g-257),Bn(n,l+5,T-1),Bn(n,l+10,E-4),l+=14,I=0;I<E;++I)Bn(n,l+3*I,x[dn[I]]);l+=3*E;for(var $=[y,k],O=0;O<2;++O){var B=$[O];for(I=0;I<B.length;++I)Bn(n,l,R[q=31&B[I]]),l+=x[q],q>15&&(Bn(n,l,B[I]>>5&127),l+=B[I]>>12)}}else A=Mn,z=Sn,D=An,P=xn;for(I=0;I<a;++I){var j=i[I];if(j>255){var q;jn(n,l,A[257+(q=j>>18&31)]),l+=z[q+257],q>7&&(Bn(n,l,j>>23&31),l+=fn[q]);var F=31&j;jn(n,l,D[F]),l+=P[F],F>3&&(jn(n,l,j>>5&8191),l+=hn[F])}else jn(n,l,A[j]),l+=z[j]}return jn(n,l,A[256]),l+z[256]},Gn=new ln([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Kn=new cn(0),Vn=function(t,n,e,i,r,o){var s=o.z||t.length,a=new cn(i+s+5*(1+Math.ceil(s/7e3))+r),c=a.subarray(i,a.length-r),u=o.l,l=7&(o.r||0);if(n){l&&(c[0]=o.r>>3);for(var f=Gn[n-1],h=f>>13,d=8191&f,v=(1<<e)-1,p=o.p||new un(32768),w=o.h||new un(v+1),m=Math.ceil(e/3),y=2*m,g=function(n){return(t[n]^t[n+1]<<m^t[n+2]<<y)&v},b=new ln(25e3),k=new un(288),T=new un(32),_=0,I=0,S=o.i||0,x=0,M=o.w||0,E=0;S+2<s;++S){var A=g(S),z=32767&S,D=w[A];if(p[z]=D,w[A]=z,M<=S){var P=s-S;if((_>7e3||x>24576)&&(P>423||!u)){l=Xn(t,c,0,b,k,T,I,x,E,S-E,l),x=_=I=0,E=S;for(var C=0;C<286;++C)k[C]=0;for(C=0;C<30;++C)T[C]=0}var U=2,L=0,R=d,$=z-D&32767;if(P>2&&A==g(S-$))for(var O=Math.min(h,P)-1,B=Math.min(32767,S),j=Math.min(258,P);$<=B&&--R&&z!=D;){if(t[S+U]==t[S+U-$]){for(var q=0;q<j&&t[S+q]==t[S+q-$];++q);if(q>U){if(U=q,L=$,q>O)break;var F=Math.min($,q-2),H=0;for(C=0;C<F;++C){var N=S-$+C&32767,Z=N-p[N]&32767;Z>H&&(H=Z,D=N)}}}$+=(z=D)-(D=p[z])&32767}if(L){b[x++]=268435456|mn[U]<<18|bn[L];var X=31&mn[U],G=31&bn[L];I+=fn[X]+hn[G],++k[257+X],++T[G],M=S+U,++_}else b[x++]=t[S],++k[t[S]]}}for(S=Math.max(S,M);S<s;++S)b[x++]=t[S],++k[t[S]];l=Xn(t,c,u,b,k,T,I,x,E,S-E,l),u||(o.r=7&l|c[l/8|0]<<3,l-=7,o.h=w,o.p=p,o.i=S,o.w=M)}else{for(S=o.w||0;S<s+u;S+=65535){var K=S+65535;K>=s&&(c[l/8|0]=u,K=s),l=Zn(c,l+1,t.subarray(S,K))}o.i=s}return Ln(a,0,i+Un(l)+r)},Yn=function(){for(var t=new Int32Array(256),n=0;n<256;++n){for(var e=n,i=9;--i;)e=(1&e&&-306674912)^e>>>1;t[n]=e}return t}(),Jn=function(){var t=-1;return{p:function(n){for(var e=t,i=0;i<n.length;++i)e=Yn[255&e^n[i]]^e>>>8;t=e},d:function(){return~t}}},Qn=function(){var t=1,n=0;return{p:function(e){for(var i=t,r=n,o=0|e.length,s=0;s!=o;){for(var a=Math.min(s+2655,o);s<a;++s)r+=i+=e[s];i=(65535&i)+15*(i>>16),r=(65535&r)+15*(r>>16)}t=i,n=r},d:function(){return(255&(t%=65521))<<24|(65280&t)<<8|(255&(n%=65521))<<8|n>>8}}},Wn=function(t,n,e,i,r){if(!r&&(r={l:1},n.dictionary)){var o=n.dictionary.subarray(-32768),s=new cn(o.length+t.length);s.set(o),s.set(t,o.length),t=s,r.w=o.length}return Vn(t,null==n.level?6:n.level,null==n.mem?r.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):20:12+n.mem,e,i,r)},te=function(t,n){var e={};for(var i in t)e[i]=t[i];for(var i in n)e[i]=n[i];return e},ne=function(t,n,e){for(var i=t(),r=t.toString(),o=r.slice(r.indexOf("[")+1,r.lastIndexOf("]")).replace(/\s+/g,"").split(","),s=0;s<i.length;++s){var a=i[s],c=o[s];if("function"==typeof a){n+=";"+c+"=";var u=a.toString();if(a.prototype)if(-1!=u.indexOf("[native code]")){var l=u.indexOf(" ",8)+1;n+=u.slice(l,u.indexOf("(",l))}else for(var f in n+=u,a.prototype)n+=";"+c+".prototype."+f+"="+a.prototype[f].toString();else n+=u}else e[c]=a}return n},ee=[],ie=function(t,n,e,i){if(!ee[e]){for(var r="",o={},s=t.length-1,a=0;a<s;++a)r=ne(t[a],r,o);ee[e]={c:ne(t[s],r,o),e:o}}var c=te({},ee[e].e);return function(t,n,e,i,r){var o=new Worker(an[n]||(an[n]=URL.createObjectURL(new Blob([t+';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'],{type:"text/javascript"}))));return o.onmessage=function(t){var n=t.data,e=n.$e$;if(e){var i=new Error(e[0]);i.code=e[1],i.stack=e[2],r(i,null)}else r(null,n)},o.postMessage(e,i),o}(ee[e].c+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+n.toString()+"}",e,c,function(t){var n=[];for(var e in t)t[e].buffer&&n.push((t[e]=new t[e].constructor(t[e])).buffer);return n}(c),i)},re=function(){return[cn,un,ln,fn,hn,dn,wn,gn,En,zn,kn,Rn,In,Dn,Pn,Cn,Un,Ln,$n,On,Ce,le,fe]},oe=function(){return[cn,un,ln,fn,hn,dn,mn,bn,Mn,Sn,An,xn,kn,Gn,Kn,In,Bn,jn,qn,Fn,Hn,Nn,Zn,Xn,Un,Ln,Vn,Wn,Ae,le]},se=function(){return[ge,Te,ye,Jn,Yn]},ae=function(){return[be,ke]},ce=function(){return[_e,ye,Qn]},ue=function(){return[Ie]},le=function(t){return postMessage(t,[t.buffer])},fe=function(t){return t&&{out:t.size&&new cn(t.size),dictionary:t.dictionary}},he=function(t,n,e,i,r,o){var s=ie(e,i,r,function(t,n){s.terminate(),o(t,n)});return s.postMessage([t,n],n.consume?[t.buffer]:[]),function(){s.terminate()}},de=function(t){return t.ondata=function(t,n){return postMessage([t,n],[t.buffer])},function(n){n.data.length?(t.push(n.data[0],n.data[1]),postMessage([n.data[0].length])):t.flush()}},ve=function(t,n,e,i,r,o,s){var a,c=ie(t,i,r,function(t,e){t?(c.terminate(),n.ondata.call(n,t)):Array.isArray(e)?1==e.length?(n.queuedSize-=e[0],n.ondrain&&n.ondrain(e[0])):(e[1]&&c.terminate(),n.ondata.call(n,t,e[0],e[1])):s(e)});c.postMessage(e),n.queuedSize=0,n.push=function(t,e){n.ondata||$n(5),a&&n.ondata($n(4,0,1),null,!!e),n.queuedSize+=t.length,c.postMessage([t,a=e],[t.buffer])},n.terminate=function(){c.terminate()},o&&(n.flush=function(){c.postMessage([])})},pe=function(t,n){return t[n]|t[n+1]<<8},we=function(t,n){return(t[n]|t[n+1]<<8|t[n+2]<<16|t[n+3]<<24)>>>0},me=function(t,n){return we(t,n)+4294967296*we(t,n+4)},ye=function(t,n,e){for(;e;++n)t[n]=e,e>>>=8},ge=function(t,n){var e=n.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=n.level<2?4:9==n.level?2:0,t[9]=3,0!=n.mtime&&ye(t,4,Math.floor(new Date(n.mtime||Date.now())/1e3)),e){t[3]=8;for(var i=0;i<=e.length;++i)t[i+10]=e.charCodeAt(i)}},be=function(t){31==t[0]&&139==t[1]&&8==t[2]||$n(6,"invalid gzip data");var n=t[3],e=10;4&n&&(e+=2+(t[10]|t[11]<<8));for(var i=(n>>3&1)+(n>>4&1);i>0;i-=!t[e++]);return e+(2&n)},ke=function(t){var n=t.length;return(t[n-4]|t[n-3]<<8|t[n-2]<<16|t[n-1]<<24)>>>0},Te=function(t){return 10+(t.filename?t.filename.length+1:0)},_e=function(t,n){var e=n.level,i=0==e?0:e<6?1:9==e?3:2;if(t[0]=120,t[1]=i<<6|(n.dictionary&&32),t[1]|=31-(t[0]<<8|t[1])%31,n.dictionary){var r=Qn();r.p(n.dictionary),ye(t,2,r.d())}},Ie=function(t,n){return(8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31)&&$n(6,"invalid zlib data"),(t[1]>>5&1)==+!n&&$n(6,"invalid zlib data: "+(32&t[1]?"need":"unexpected")+" dictionary"),2+(t[1]>>3&4)};function Se(t,n){return"function"==typeof t&&(n=t,t={}),this.ondata=n,t}var xe=function(){function t(t,n){if("function"==typeof t&&(n=t,t={}),this.ondata=n,this.o=t||{},this.s={l:0,i:32768,w:32768,z:32768},this.b=new cn(98304),this.o.dictionary){var e=this.o.dictionary.subarray(-32768);this.b.set(e,32768-e.length),this.s.i=32768-e.length}}return t.prototype.p=function(t,n){this.ondata(Wn(t,this.o,0,0,this.s),n)},t.prototype.push=function(t,n){this.ondata||$n(5),this.s.l&&$n(4);var e=t.length+this.s.z;if(e>this.b.length){if(e>2*this.b.length-32768){var i=new cn(-32768&e);i.set(this.b.subarray(0,this.s.z)),this.b=i}var r=this.b.length-this.s.z;this.b.set(t.subarray(0,r),this.s.z),this.s.z=this.b.length,this.p(this.b,0),this.b.set(this.b.subarray(-32768)),this.b.set(t.subarray(r),32768),this.s.z=t.length-r+32768,this.s.i=32766,this.s.w=32768}else this.b.set(t,this.s.z),this.s.z+=t.length;this.s.l=1&n,(this.s.z>this.s.w+8191||n)&&(this.p(this.b,n||0),this.s.w=this.s.i,this.s.i-=2)},t.prototype.flush=function(){this.ondata||$n(5),this.s.l&&$n(4),this.p(this.b,0),this.s.w=this.s.i,this.s.i-=2},t}(),Me=function(){return function(t,n){ve([oe,function(){return[de,xe]}],this,Se.call(this,t,n),function(t){var n=new xe(t.data);onmessage=de(n)},6,1)}}();function Ee(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&$n(7),he(t,n,[oe],function(t){return le(Ae(t.data[0],t.data[1]))},0,e)}function Ae(t,n){return Wn(t,n||{},0,0)}var ze=function(){function t(t,n){"function"==typeof t&&(n=t,t={}),this.ondata=n;var e=t&&t.dictionary&&t.dictionary.subarray(-32768);this.s={i:0,b:e?e.length:0},this.o=new cn(32768),this.p=new cn(0),e&&this.o.set(e)}return t.prototype.e=function(t){if(this.ondata||$n(5),this.d&&$n(4),this.p.length){if(t.length){var n=new cn(this.p.length+t.length);n.set(this.p),n.set(t,this.p.length),this.p=n}}else this.p=t},t.prototype.c=function(t){this.s.i=+(this.d=t||0);var n=this.s.b,e=On(this.p,this.s,this.o);this.ondata(Ln(e,n,this.s.b),this.d),this.o=Ln(e,this.s.b-32768),this.s.b=this.o.length,this.p=Ln(this.p,this.s.p/8|0),this.s.p&=7},t.prototype.push=function(t,n){this.e(t),this.c(n)},t}(),De=function(){return function(t,n){ve([re,function(){return[de,ze]}],this,Se.call(this,t,n),function(t){var n=new ze(t.data);onmessage=de(n)},7,0)}}();function Pe(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&$n(7),he(t,n,[re],function(t){return le(Ce(t.data[0],fe(t.data[1])))},1,e)}function Ce(t,n){return On(t,{i:2},n&&n.out,n&&n.dictionary)}var Ue=function(){function t(t,n){this.c=Jn(),this.l=0,this.v=1,xe.call(this,t,n)}return t.prototype.push=function(t,n){this.c.p(t),this.l+=t.length,xe.prototype.push.call(this,t,n)},t.prototype.p=function(t,n){var e=Wn(t,this.o,this.v&&Te(this.o),n&&8,this.s);this.v&&(ge(e,this.o),this.v=0),n&&(ye(e,e.length-8,this.c.d()),ye(e,e.length-4,this.l)),this.ondata(e,n)},t.prototype.flush=function(){xe.prototype.flush.call(this)},t}(),Le=function(){return function(t,n){ve([oe,se,function(){return[de,xe,Ue]}],this,Se.call(this,t,n),function(t){var n=new Ue(t.data);onmessage=de(n)},8,1)}}();function Re(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&$n(7),he(t,n,[oe,se,function(){return[$e]}],function(t){return le($e(t.data[0],t.data[1]))},2,e)}function $e(t,n){n||(n={});var e=Jn(),i=t.length;e.p(t);var r=Wn(t,n,Te(n),8),o=r.length;return ge(r,n),ye(r,o-8,e.d()),ye(r,o-4,i),r}var Oe=function(){function t(t,n){this.v=1,this.r=0,ze.call(this,t,n)}return t.prototype.push=function(t,n){if(ze.prototype.e.call(this,t),this.r+=t.length,this.v){var e=this.p.subarray(this.v-1),i=e.length>3?be(e):4;if(i>e.length){if(!n)return}else this.v>1&&this.onmember&&this.onmember(this.r-e.length);this.p=e.subarray(i),this.v=0}ze.prototype.c.call(this,n),!this.s.f||this.s.l||n||(this.v=Un(this.s.p)+9,this.s={i:0},this.o=new cn(0),this.push(new cn(0),n))},t}(),Be=function(){return function(t,n){var e=this;ve([re,ae,function(){return[de,ze,Oe]}],this,Se.call(this,t,n),function(t){var n=new Oe(t.data);n.onmember=function(t){return postMessage(t)},onmessage=de(n)},9,0,function(t){return e.onmember&&e.onmember(t)})}}();function je(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&$n(7),he(t,n,[re,ae,function(){return[qe]}],function(t){return le(qe(t.data[0],t.data[1]))},3,e)}function qe(t,n){var e=be(t);return e+8>t.length&&$n(6,"invalid gzip data"),On(t.subarray(e,-8),{i:2},n&&n.out||new cn(ke(t)),n&&n.dictionary)}var Fe=function(){function t(t,n){this.c=Qn(),this.v=1,xe.call(this,t,n)}return t.prototype.push=function(t,n){this.c.p(t),xe.prototype.push.call(this,t,n)},t.prototype.p=function(t,n){var e=Wn(t,this.o,this.v&&(this.o.dictionary?6:2),n&&4,this.s);this.v&&(_e(e,this.o),this.v=0),n&&ye(e,e.length-4,this.c.d()),this.ondata(e,n)},t.prototype.flush=function(){xe.prototype.flush.call(this)},t}(),He=function(){return function(t,n){ve([oe,ce,function(){return[de,xe,Fe]}],this,Se.call(this,t,n),function(t){var n=new Fe(t.data);onmessage=de(n)},10,1)}}();function Ne(t,n){n||(n={});var e=Qn();e.p(t);var i=Wn(t,n,n.dictionary?6:2,4);return _e(i,n),ye(i,i.length-4,e.d()),i}var Ze=function(){function t(t,n){ze.call(this,t,n),this.v=t&&t.dictionary?2:1}return t.prototype.push=function(t,n){if(ze.prototype.e.call(this,t),this.v){if(this.p.length<6&&!n)return;this.p=this.p.subarray(Ie(this.p,this.v-1)),this.v=0}n&&(this.p.length<4&&$n(6,"invalid zlib data"),this.p=this.p.subarray(0,-4)),ze.prototype.c.call(this,n)},t}(),Xe=function(){return function(t,n){ve([re,ue,function(){return[de,ze,Ze]}],this,Se.call(this,t,n),function(t){var n=new Ze(t.data);onmessage=de(n)},11,0)}}();function Ge(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&$n(7),he(t,n,[re,ue,function(){return[Ke]}],function(t){return le(Ke(t.data[0],fe(t.data[1])))},5,e)}function Ke(t,n){return On(t.subarray(Ie(t,n&&n.dictionary),-4),{i:2},n&&n.out,n&&n.dictionary)}var Ve=function(){function t(t,n){this.o=Se.call(this,t,n)||{},this.G=Oe,this.I=ze,this.Z=Ze}return t.prototype.i=function(){var t=this;this.s.ondata=function(n,e){t.ondata(n,e)}},t.prototype.push=function(t,n){if(this.ondata||$n(5),this.s)this.s.push(t,n);else{if(this.p&&this.p.length){var e=new cn(this.p.length+t.length);e.set(this.p),e.set(t,this.p.length)}else this.p=t;this.p.length>2&&(this.s=31==this.p[0]&&139==this.p[1]&&8==this.p[2]?new this.G(this.o):8!=(15&this.p[0])||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(this.o):new this.Z(this.o),this.i(),this.s.push(this.p,n),this.p=null)}},t}(),Ye=function(){function t(t,n){Ve.call(this,t,n),this.queuedSize=0,this.G=Be,this.I=De,this.Z=Xe}return t.prototype.i=function(){var t=this;this.s.ondata=function(n,e,i){t.ondata(n,e,i)},this.s.ondrain=function(n){t.queuedSize-=n,t.ondrain&&t.ondrain(n)}},t.prototype.push=function(t,n){this.queuedSize+=t.length,Ve.prototype.push.call(this,t,n)},t}(),Je=function(t,n,e,i){for(var r in t){var o=t[r],s=n+r,a=i;Array.isArray(o)&&(a=te(i,o[1]),o=o[0]),o instanceof cn?e[s]=[o,a]:(e[s+="/"]=[new cn(0),a],Je(o,s,e,i))}},Qe="undefined"!=typeof TextEncoder&&new TextEncoder,We="undefined"!=typeof TextDecoder&&new TextDecoder,ti=0;try{We.decode(Kn,{stream:1}),ti=1}catch(t){}var ni=function(t){for(var n="",e=0;;){var i=t[e++],r=(i>127)+(i>223)+(i>239);if(e+r>t.length)return{s:n,r:Ln(t,e-1)};r?3==r?(i=((15&i)<<18|(63&t[e++])<<12|(63&t[e++])<<6|63&t[e++])-65536,n+=String.fromCharCode(55296|i>>10,56320|1023&i)):n+=String.fromCharCode(1&r?(31&i)<<6|63&t[e++]:(15&i)<<12|(63&t[e++])<<6|63&t[e++]):n+=String.fromCharCode(i)}},ei=function(){function t(t){this.ondata=t,ti?this.t=new TextDecoder:this.p=Kn}return t.prototype.push=function(t,n){if(this.ondata||$n(5),n=!!n,this.t)return this.ondata(this.t.decode(t,{stream:1}),n),void(n&&(this.t.decode().length&&$n(8),this.t=null));this.p||$n(4);var e=new cn(this.p.length+t.length);e.set(this.p),e.set(t,this.p.length);var i=ni(e),r=i.s,o=i.r;n?(o.length&&$n(8),this.p=null):this.p=o,this.ondata(r,n)},t}(),ii=function(){function t(t){this.ondata=t}return t.prototype.push=function(t,n){this.ondata||$n(5),this.d&&$n(4),this.ondata(ri(t),this.d=n||0)},t}();function ri(t,n){if(n){for(var e=new cn(t.length),i=0;i<t.length;++i)e[i]=t.charCodeAt(i);return e}if(Qe)return Qe.encode(t);var r=t.length,o=new cn(t.length+(t.length>>1)),s=0,a=function(t){o[s++]=t};for(i=0;i<r;++i){if(s+5>o.length){var c=new cn(s+8+(r-i<<1));c.set(o),o=c}var u=t.charCodeAt(i);u<128||n?a(u):u<2048?(a(192|u>>6),a(128|63&u)):u>55295&&u<57344?(a(240|(u=65536+(1047552&u)|1023&t.charCodeAt(++i))>>18),a(128|u>>12&63),a(128|u>>6&63),a(128|63&u)):(a(224|u>>12),a(128|u>>6&63),a(128|63&u))}return Ln(o,0,s)}function oi(t,n){if(n){for(var e="",i=0;i<t.length;i+=16384)e+=String.fromCharCode.apply(null,t.subarray(i,i+16384));return e}if(We)return We.decode(t);var r=ni(t),o=r.s;return(e=r.r).length&&$n(8),o}var si=function(t){return 1==t?3:t<6?2:9==t?1:0},ai=function(t,n){return n+30+pe(t,n+26)+pe(t,n+28)},ci=function(t,n,e){var i=pe(t,n+28),r=oi(t.subarray(n+46,n+46+i),!(2048&pe(t,n+8))),o=n+46+i,s=we(t,n+20),a=e&&4294967295==s?ui(t,o):[s,we(t,n+24),we(t,n+42)],c=a[0],u=a[1],l=a[2];return[pe(t,n+10),c,u,r,o+pe(t,n+30)+pe(t,n+32),l]},ui=function(t,n){for(;1!=pe(t,n);n+=4+pe(t,n+2));return[me(t,n+12),me(t,n+4),me(t,n+20)]},li=function(t){var n=0;if(t)for(var e in t){var i=t[e].length;i>65535&&$n(9),n+=i+4}return n},fi=function(t,n,e,i,r,o,s,a){var c=i.length,u=e.extra,l=a&&a.length,f=li(u);ye(t,n,null!=s?33639248:67324752),n+=4,null!=s&&(t[n++]=20,t[n++]=e.os),t[n]=20,n+=2,t[n++]=e.flag<<1|(o<0&&8),t[n++]=r&&8,t[n++]=255&e.compression,t[n++]=e.compression>>8;var h=new Date(null==e.mtime?Date.now():e.mtime),d=h.getFullYear()-1980;if((d<0||d>119)&&$n(10),ye(t,n,d<<25|h.getMonth()+1<<21|h.getDate()<<16|h.getHours()<<11|h.getMinutes()<<5|h.getSeconds()>>1),n+=4,-1!=o&&(ye(t,n,e.crc),ye(t,n+4,o<0?-o-2:o),ye(t,n+8,e.size)),ye(t,n+12,c),ye(t,n+14,f),n+=16,null!=s&&(ye(t,n,l),ye(t,n+6,e.attrs),ye(t,n+10,s),n+=14),t.set(i,n),n+=c,f)for(var v in u){var p=u[v],w=p.length;ye(t,n,+v),ye(t,n+2,w),t.set(p,n+4),n+=4+w}return l&&(t.set(a,n),n+=l),n},hi=function(t,n,e,i,r){ye(t,n,101010256),ye(t,n+8,e),ye(t,n+10,e),ye(t,n+12,i),ye(t,n+16,r)},di=function(){function t(t){this.filename=t,this.c=Jn(),this.size=0,this.compression=0}return t.prototype.process=function(t,n){this.ondata(null,t,n)},t.prototype.push=function(t,n){this.ondata||$n(5),this.c.p(t),this.size+=t.length,n&&(this.crc=this.c.d()),this.process(t,n||0)},t}(),vi=function(){function t(t,n){var e=this;n||(n={}),di.call(this,t),this.d=new xe(n,function(t,n){e.ondata(null,t,n)}),this.compression=8,this.flag=si(n.level)}return t.prototype.process=function(t,n){try{this.d.push(t,n)}catch(t){this.ondata(t,null,n)}},t.prototype.push=function(t,n){di.prototype.push.call(this,t,n)},t}(),pi=function(){function t(t,n){var e=this;n||(n={}),di.call(this,t),this.d=new Me(n,function(t,n,i){e.ondata(t,n,i)}),this.compression=8,this.flag=si(n.level),this.terminate=this.d.terminate}return t.prototype.process=function(t,n){this.d.push(t,n)},t.prototype.push=function(t,n){di.prototype.push.call(this,t,n)},t}(),wi=function(){function t(t){this.ondata=t,this.u=[],this.d=1}return t.prototype.add=function(t){var n=this;if(this.ondata||$n(5),2&this.d)this.ondata($n(4+8*(1&this.d),0,1),null,0);else{var e=ri(t.filename),i=e.length,r=t.comment,o=r&&ri(r),s=i!=t.filename.length||o&&r.length!=o.length,a=i+li(t.extra)+30;i>65535&&this.ondata($n(11,0,1),null,0);var c=new cn(a);fi(c,0,t,e,s,-1);var u=[c],l=function(){for(var t=0,e=u;t<e.length;t++)n.ondata(null,e[t],0);u=[]},f=this.d;this.d=0;var h=this.u.length,d=te(t,{f:e,u:s,o:o,t:function(){t.terminate&&t.terminate()},r:function(){if(l(),f){var t=n.u[h+1];t?t.r():n.d=1}f=1}}),v=0;t.ondata=function(e,i,r){if(e)n.ondata(e,i,r),n.terminate();else if(v+=i.length,u.push(i),r){var o=new cn(16);ye(o,0,134695760),ye(o,4,t.crc),ye(o,8,v),ye(o,12,t.size),u.push(o),d.c=v,d.b=a+v+16,d.crc=t.crc,d.size=t.size,f&&d.r(),f=1}else f&&l()},this.u.push(d)}},t.prototype.end=function(){var t=this;2&this.d?this.ondata($n(4+8*(1&this.d),0,1),null,1):(this.d?this.e():this.u.push({r:function(){1&t.d&&(t.u.splice(-1,1),t.e())},t:function(){}}),this.d=3)},t.prototype.e=function(){for(var t=0,n=0,e=0,i=0,r=this.u;i<r.length;i++)e+=46+(c=r[i]).f.length+li(c.extra)+(c.o?c.o.length:0);for(var o=new cn(e+22),s=0,a=this.u;s<a.length;s++){var c;fi(o,t,c=a[s],c.f,c.u,-c.c-2,n,c.o),t+=46+c.f.length+li(c.extra)+(c.o?c.o.length:0),n+=c.b}hi(o,t,this.u.length,e,n),this.ondata(null,o,1),this.d=2},t.prototype.terminate=function(){for(var t=0,n=this.u;t<n.length;t++)n[t].t();this.d=2},t}(),mi=function(){function t(){}return t.prototype.push=function(t,n){this.ondata(null,t,n)},t.compression=0,t}(),yi=function(){function t(){var t=this;this.i=new ze(function(n,e){t.ondata(null,n,e)})}return t.prototype.push=function(t,n){try{this.i.push(t,n)}catch(t){this.ondata(t,null,n)}},t.compression=8,t}(),gi=function(){function t(t,n){var e=this;n<32e4?this.i=new ze(function(t,n){e.ondata(null,t,n)}):(this.i=new De(function(t,n,i){e.ondata(t,n,i)}),this.terminate=this.i.terminate)}return t.prototype.push=function(t,n){this.i.terminate&&(t=Ln(t,0)),this.i.push(t,n)},t.compression=8,t}(),bi=function(){function t(t){this.onfile=t,this.k=[],this.o={0:mi},this.p=Kn}return t.prototype.push=function(t,n){var e=this;if(this.onfile||$n(5),this.p||$n(4),this.c>0){var i=Math.min(this.c,t.length),r=t.subarray(0,i);if(this.c-=i,this.d?this.d.push(r,!this.c):this.k[0].push(r),(t=t.subarray(i)).length)return this.push(t,n)}else{var o=0,s=0,a=void 0,c=void 0;this.p.length?t.length?((c=new cn(this.p.length+t.length)).set(this.p),c.set(t,this.p.length)):c=this.p:c=t;for(var u=c.length,l=this.c,f=l&&this.d,h=function(){var t,n=we(c,s);if(67324752==n){o=1,a=s,d.d=null,d.c=0;var i=pe(c,s+6),r=pe(c,s+8),f=2048&i,h=8&i,v=pe(c,s+26),p=pe(c,s+28);if(u>s+30+v+p){var w=[];d.k.unshift(w),o=2;var m,y=we(c,s+18),g=we(c,s+22),b=oi(c.subarray(s+30,s+=30+v),!f);4294967295==y?(t=h?[-2]:ui(c,s),y=t[0],g=t[1]):h&&(y=-1),s+=p,d.c=y;var k={name:b,compression:r,start:function(){if(k.ondata||$n(5),y){var t=e.o[r];t||k.ondata($n(14,"unknown compression type "+r,1),null,0),(m=y<0?new t(b):new t(b,y,g)).ondata=function(t,n,e){k.ondata(t,n,e)};for(var n=0,i=w;n<i.length;n++)m.push(i[n],0);e.k[0]==w&&e.c?e.d=m:m.push(Kn,1)}else k.ondata(null,Kn,1)},terminate:function(){m&&m.terminate&&m.terminate()}};y>=0&&(k.size=y,k.originalSize=g),d.onfile(k)}return"break"}if(l){if(134695760==n)return a=s+=12+(-2==l&&8),o=3,d.c=0,"break";if(33639248==n)return a=s-=4,o=3,d.c=0,"break"}},d=this;s<u-4&&"break"!==h();++s);if(this.p=Kn,l<0){var v=c.subarray(0,o?a-12-(-2==l&&8)-(134695760==we(c,a-16)&&4):s);f?f.push(v,!!o):this.k[+(2==o)].push(v)}if(2&o)return this.push(c.subarray(s),n);this.p=c.subarray(s)}n&&(this.c&&$n(13),this.p=null)},t.prototype.register=function(t){this.o[t.compression]=t},t}(),ki="function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout?setTimeout:function(t){t()},Ti=Object.freeze({__proto__:null,AsyncCompress:Le,AsyncDecompress:Ye,AsyncDeflate:Me,AsyncGunzip:Be,AsyncGzip:Le,AsyncInflate:De,AsyncUnzipInflate:gi,AsyncUnzlib:Xe,AsyncZipDeflate:pi,AsyncZlib:He,Compress:Ue,DecodeUTF8:ei,Decompress:Ve,Deflate:xe,EncodeUTF8:ii,FlateErrorCode:{UnexpectedEOF:0,InvalidBlockType:1,InvalidLengthLiteral:2,InvalidDistance:3,StreamFinished:4,NoStreamHandler:5,InvalidHeader:6,NoCallback:7,InvalidUTF8:8,ExtraFieldTooLong:9,InvalidDate:10,FilenameTooLong:11,StreamFinishing:12,InvalidZipData:13,UnknownCompressionMethod:14},Gunzip:Oe,Gzip:Ue,Inflate:ze,Unzip:bi,UnzipInflate:yi,UnzipPassThrough:mi,Unzlib:Ze,Zip:wi,ZipDeflate:vi,ZipPassThrough:di,Zlib:Fe,compress:Re,compressSync:$e,decompress:function(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&$n(7),31==t[0]&&139==t[1]&&8==t[2]?je(t,n,e):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?Pe(t,n,e):Ge(t,n,e)},decompressSync:function(t,n){return 31==t[0]&&139==t[1]&&8==t[2]?qe(t,n):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?Ce(t,n):Ke(t,n)},deflate:Ee,deflateSync:Ae,gunzip:je,gunzipSync:qe,gzip:Re,gzipSync:$e,inflate:Pe,inflateSync:Ce,strFromU8:oi,strToU8:ri,unzip:function(t,n,e){e||(e=n,n={}),"function"!=typeof e&&$n(7);var i=[],r=function(){for(var t=0;t<i.length;++t)i[t]()},o={},s=function(t,n){ki(function(){e(t,n)})};ki(function(){s=e});for(var a=t.length-22;101010256!=we(t,a);--a)if(!a||t.length-a>65558)return s($n(13,0,1),null),r;var c=pe(t,a+8);if(c){var u=c,l=we(t,a+16),f=4294967295==l||65535==u;if(f){var h=we(t,a-12);(f=101075792==we(t,h))&&(u=c=we(t,h+32),l=we(t,h+48))}for(var d=n&&n.filter,v=function(n){var e=ci(t,l,f),a=e[0],u=e[1],h=e[2],v=e[3],p=e[4],w=ai(t,e[5]);l=p;var m=function(t,n){t?(r(),s(t,null)):(n&&(o[v]=n),--c||s(null,o))};if(!d||d({name:v,size:u,originalSize:h,compression:a}))if(a)if(8==a){var y=t.subarray(w,w+u);if(h<524288||u>.8*h)try{m(null,Ce(y,{out:new cn(h)}))}catch(t){m(t,null)}else i.push(Pe(y,{size:h},m))}else m($n(14,"unknown compression type "+a,1),null);else m(null,Ln(t,w,w+u));else m(null,null)},p=0;p<u;++p)v()}else s(null,{});return r},unzipSync:function(t,n){for(var e={},i=t.length-22;101010256!=we(t,i);--i)(!i||t.length-i>65558)&&$n(13);var r=pe(t,i+8);if(!r)return{};var o=we(t,i+16),s=4294967295==o||65535==r;if(s){var a=we(t,i-12);(s=101075792==we(t,a))&&(r=we(t,a+32),o=we(t,a+48))}for(var c=n&&n.filter,u=0;u<r;++u){var l=ci(t,o,s),f=l[0],h=l[1],d=l[2],v=l[3],p=l[4],w=ai(t,l[5]);o=p,c&&!c({name:v,size:h,originalSize:d,compression:f})||(f?8==f?e[v]=Ce(t.subarray(w,w+h),{out:new cn(d)}):$n(14,"unknown compression type "+f):e[v]=Ln(t,w,w+h))}return e},unzlib:Ge,unzlibSync:Ke,zip:function(t,n,e){e||(e=n,n={}),"function"!=typeof e&&$n(7);var i={};Je(t,"",i,n);var r=Object.keys(i),o=r.length,s=0,a=0,c=o,u=new Array(o),l=[],f=function(){for(var t=0;t<l.length;++t)l[t]()},h=function(t,n){ki(function(){e(t,n)})};ki(function(){h=e});var d=function(){var t=new cn(a+22),n=s,e=a-s;a=0;for(var i=0;i<c;++i){var r=u[i];try{var o=r.c.length;fi(t,a,r,r.f,r.u,o);var l=30+r.f.length+li(r.extra),f=a+l;t.set(r.c,f),fi(t,s,r,r.f,r.u,o,a,r.m),s+=16+l+(r.m?r.m.length:0),a=f+o}catch(t){return h(t,null)}}hi(t,s,u.length,e,n),h(null,t)};o||d();for(var v=function(t){var n=r[t],e=i[n],c=e[0],v=e[1],p=Jn(),w=c.length;p.p(c);var m=ri(n),y=m.length,g=v.comment,b=g&&ri(g),k=b&&b.length,T=li(v.extra),_=0==v.level?0:8,I=function(e,i){if(e)f(),h(e,null);else{var r=i.length;u[t]=te(v,{size:w,crc:p.d(),c:i,f:m,m:b,u:y!=n.length||b&&g.length!=k,compression:_}),s+=30+y+T+r,a+=76+2*(y+T)+(k||0)+r,--o||d()}};if(y>65535&&I($n(11,0,1),null),_)if(w<16e4)try{I(null,Ae(c,v))}catch(t){I(t,null)}else l.push(Ee(c,v,I));else I(null,c)},p=0;p<c;++p)v(p);return f},zipSync:function(t,n){n||(n={});var e={},i=[];Je(t,"",e,n);var r=0,o=0;for(var s in e){var a=e[s],c=a[0],u=a[1],l=0==u.level?0:8,f=(_=ri(s)).length,h=u.comment,d=h&&ri(h),v=d&&d.length,p=li(u.extra);f>65535&&$n(11);var w=l?Ae(c,u):c,m=w.length,y=Jn();y.p(c),i.push(te(u,{size:c.length,crc:y.d(),c:w,f:_,m:d,u:f!=s.length||d&&h.length!=v,o:r,compression:l})),r+=30+f+p+m,o+=76+2*(f+p)+(v||0)+m}for(var g=new cn(o+22),b=r,k=o-r,T=0;T<i.length;++T){var _;fi(g,(_=i[T]).o,_,_.f,_.u,_.c.length);var I=30+_.f.length+li(_.extra);g.set(_.c,_.o+I),fi(g,r,_,_.f,_.u,_.c.length,_.o,_.m),r+=16+I+(_.m?_.m.length:0)}return hi(g,r,i.length,k,b),g},zlib:function(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&$n(7),he(t,n,[oe,ce,function(){return[Ne]}],function(t){return le(Ne(t.data[0],t.data[1]))},4,e)},zlibSync:Ne});t.createSession=async function(t,n){const e=n?.apiURL??"https://falcon-ingest-k8s.stage.incodetest.com",i=n?.timeout??1e4,r=new AbortController;let o=null,s=0,a=()=>{};i&&(o=f(()=>{s=1,r.abort()},i));const c=n?.signal;if(c)if(c.aborted)r.abort();else{const t=()=>r.abort();c.addEventListener("abort",t,{once:1}),a=()=>c.removeEventListener("abort",t)}try{const n=await fetch(`${e}/api/v1/sdk/init`,{method:"POST",headers:{"content-type":"application/json","x-api-key":t,"x-api-version":"1.0"},signal:r.signal});if(!n.ok){let t=n.statusText;try{const e=await n.json();e.errorMessage&&(t=e.errorMessage)}catch{}return{token:null,eventsCollectionEnabled:0,error:{status:n.status,message:t}}}return await n.json()}catch(t){throw new Error((s?"[TRI] createSession timed out":"[TRI] Failed to create session:")+" "+t.message)}finally{h(o),a()}},t.default=sn,Object.defineProperty(t,"qt",{value:1})});
|