@heycatch/sdk 0.7.1-dev.1459 → 0.8.0-dev.1460
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/README.md +33 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/react-native.cjs +1 -1
- package/dist/react-native.js +1 -1
- package/dist/server.cjs +1 -1
- package/dist/server.js +1 -1
- package/package.json +1 -1
package/dist/react-native.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var ie=Object.defineProperty;var St=Object.getOwnPropertyDescriptor;var It=Object.getOwnPropertyNames;var Tt=Object.prototype.hasOwnProperty;var Mt=(e,t)=>{for(var r in t)ie(e,r,{get:t[r],enumerable:!0})},Nt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of It(t))!Tt.call(e,o)&&o!==r&&ie(e,o,{get:()=>t[o],enumerable:!(n=St(t,o))||n.enumerable});return e};var Rt=e=>Nt(ie({},"__esModule",{value:!0}),e);var kr={};Mt(kr,{HeyCatchProvider:()=>At,SDK_VERSION:()=>I,STAGE:()=>S,analytics:()=>wr});module.exports=Rt(kr);var ye="project",Ot="[a-z0-9]",Pr=new RegExp(`^${Ot}$`);var jt=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function se(e){let t=jt.exec(e);if(t===null)return!1;let[,r="",n=""]=t,o=Number(r),s=Number(n);return o>255||s>255?!1:o===0||o===10||o===127||o===100&&s>=64&&s<=127||o===169&&s===254||o===172&&s>=16&&s<=31||o===192&&s===168}var Lt=/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/;function Dt(e){if(e==="::1"||e==="::")return!0;if(e.startsWith("::ffff:")){let t=Lt.exec(e);if(t===null)return se(e.slice(7));let[,r="",n=""]=t,o=Number.parseInt(r,16),s=Number.parseInt(n,16);return se(`${Math.floor(o/256)}.${o%256}.${Math.floor(s/256)}.${s%256}`)}return/^f[cd][0-9a-f]{2}:/.test(e)||/^fe[89ab][0-9a-f]:/.test(e)}function Ft(e){return e.toLowerCase().replace(/^\[/,"").replace(/\]$/,"").replace(/\.+$/,"")}function $e(e){let t=Ft(e);return t==="localhost"||t.endsWith(".localhost")||se(t)||Dt(t)}var gt=require("posthog-react-native");var be;function l(e,t,r){function n(c,u){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:u,constr:i,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,u);let a=i.prototype,p=Object.keys(a);for(let h=0;h<p.length;h++){let d=p[h];d in c||(c[d]=a[d].bind(c))}}let o=r?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:e});function i(c){var u;let a=r?.Parent?new s:this;n(a,c),(u=a._zod).deferred??(u.deferred=[]);for(let p of a._zod.deferred)p();return a}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:c=>r?.Parent&&c instanceof r.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}var k=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};(be=globalThis).__zod_globalConfig??(be.__zod_globalConfig={});var ce=globalThis.__zod_globalConfig;function M(e){return e&&Object.assign(ce,e),ce}function ke(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function Ze(e,t){return typeof t=="bigint"?t.toString():t}function Pe(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Ee(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}var we=Symbol("evaluating");function P(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==we)return n===void 0&&(n=we,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}var ae="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Y(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ce(e){if(Y(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Y(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function le(e){return Ce(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Ae=new Set(["string","number","symbol"]);function Se(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function pe(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function b(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Ie(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Cr={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function F(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Te(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function fe(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function J(e){return typeof e=="string"?e:e?.message}function N(e,t,r){let n=e.message?e.message:J(e.inst?._zod.def?.error?.(e))??J(t?.error?.(e))??J(r.customError?.(e))??J(r.localeError?.(e))??"Invalid input",{inst:o,continue:s,input:i,...c}=e;return c.path??(c.path=[]),c.message=n,t?.reportInput&&(c.input=i),c}function de(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}var Me=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Ze,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ne=l("$ZodError",Me),U=l("$ZodError",Me,{Parent:Error});var Ut=e=>(t,r,n,o)=>{let s=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},s);if(i instanceof Promise)throw new k;if(i.issues.length){let c=new(o?.Err??e)(i.issues.map(u=>N(u,s,M())));throw ae(c,o?.callee),c}return i.value},q=Ut(U),Vt=e=>async(t,r,n,o)=>{let s=n?{...n,async:!0}:{async:!0},i=t._zod.run({value:r,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){let c=new(o?.Err??e)(i.issues.map(u=>N(u,s,M())));throw ae(c,o?.callee),c}return i.value},X=Vt(U),Bt=e=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new k;return s.issues.length?{success:!1,error:new(e??Ne)(s.issues.map(i=>N(i,o,M())))}:{success:!0,data:s.value}},V=Bt(U),Kt=e=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>N(i,o,M())))}:{success:!0,data:s.value}},B=Kt(U);var Gt="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Wt=new RegExp(`^${Gt}$`);var Re=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var Oe=/^-?\d+(?:\.\d+)?$/,je=/^(?:true|false)$/i;var K=l("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var De=l("$ZodCheckStringFormat",(e,t)=>{var r,n;K.init(e,t),e._zod.onattach.push(o=>{let s=o._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Fe=l("$ZodCheckRegex",(e,t)=>{De.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}});var Ue={major:4,minor:4,patch:3};var $=l("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ue;let n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(let o of n)for(let s of o._zod.onattach)s(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let o=(i,c,u)=>{let a=F(i),p;for(let h of c){if(h._zod.def.when){if(Te(i)||!h._zod.def.when(i))continue}else if(a)continue;let d=i.issues.length,g=h._zod.check(i);if(g instanceof Promise&&u?.async===!1)throw new k;if(p||g instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await g,i.issues.length!==d&&(a||(a=F(i,d)))});else{if(i.issues.length===d)continue;a||(a=F(i,d))}}return p?p.then(()=>i):i},s=(i,c,u)=>{if(F(i))return i.aborted=!0,i;let a=o(c,n,u);if(a instanceof Promise){if(u.async===!1)throw new k;return a.then(p=>e._zod.parse(p,u))}return e._zod.parse(a,u)};e._zod.run=(i,c)=>{if(c.skipChecks)return e._zod.parse(i,c);if(c.direction==="backward"){let a=e._zod.parse({value:i.value,issues:[]},{...c,skipChecks:!0});return a instanceof Promise?a.then(p=>s(p,i,c)):s(a,i,c)}let u=e._zod.parse(i,c);if(u instanceof Promise){if(c.async===!1)throw new k;return u.then(a=>o(a,n,c))}return o(u,n,c)}}P(e,"~standard",()=>({validate:o=>{try{let s=V(e,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return B(e,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),We=l("$ZodString",(e,t)=>{$.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Re(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}});var Je=l("$ZodNumber",(e,t)=>{$.init(e,t),e._zod.pattern=e._zod.bag.pattern??Oe,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),r}});var Ye=l("$ZodBoolean",(e,t)=>{$.init(e,t),e._zod.pattern=je,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}});function Ve(e,t,r){e.issues.length&&t.issues.push(...fe(r,e.issues)),t.value[r]=e.value}var qe=l("$ZodArray",(e,t)=>{$.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=Array(o.length);let s=[];for(let i=0;i<o.length;i++){let c=o[i],u=t.element._zod.run({value:c,issues:[]},n);u instanceof Promise?s.push(u.then(a=>Ve(a,r,i))):Ve(u,r,i)}return s.length?Promise.all(s).then(()=>r):r}});function Q(e,t,r,n,o,s){let i=r in n;if(e.issues.length){if(o&&s&&!i)return;t.issues.push(...fe(r,e.issues))}if(!i&&!o){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?i&&(t.value[r]=void 0):t.value[r]=e.value}function Jt(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);let r=Ie(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function Yt(e,t,r,n,o,s){let i=[],c=o.keySet,u=o.catchall._zod,a=u.def.type,p=u.optin==="optional",h=u.optout==="optional";for(let d in t){if(d==="__proto__"||c.has(d))continue;if(a==="never"){i.push(d);continue}let g=u.run({value:t[d],issues:[]},n);g instanceof Promise?e.push(g.then(v=>Q(v,r,d,t,p,h))):Q(g,r,d,t,p,h)}return i.length&&r.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s}),e.length?Promise.all(e).then(()=>r):r}var Xe=l("$ZodObject",(e,t)=>{if($.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let c=t.shape;Object.defineProperty(t,"shape",{get:()=>{let u={...c};return Object.defineProperty(t,"shape",{value:u}),u}})}let n=Pe(()=>Jt(t));P(e._zod,"propValues",()=>{let c=t.shape,u={};for(let a in c){let p=c[a]._zod;if(p.values){u[a]??(u[a]=new Set);for(let h of p.values)u[a].add(h)}}return u});let o=Y,s=t.catchall,i;e._zod.parse=(c,u)=>{i??(i=n.value);let a=c.value;if(!o(a))return c.issues.push({expected:"object",code:"invalid_type",input:a,inst:e}),c;c.value={};let p=[],h=i.shape;for(let d of i.keys){let g=h[d],v=g._zod.optin==="optional",G=g._zod.optout==="optional",j=g._zod.run({value:a[d],issues:[]},u);j instanceof Promise?p.push(j.then(m=>Q(m,c,d,a,v,G))):Q(j,c,d,a,v,G)}return s?Yt(p,a,c,u,n.value,e):p.length?Promise.all(p).then(()=>c):c}});var Qe=l("$ZodEnum",(e,t)=>{$.init(e,t);let r=ke(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(o=>Ae.has(typeof o)).map(o=>typeof o=="string"?Se(o):o.toString()).join("|")})$`),e._zod.parse=(o,s)=>{let i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:r,input:i,inst:e}),o}});function Be(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var et=l("$ZodOptional",(e,t)=>{$.init(e,t),e._zod.optin="optional",e._zod.optout="optional",P(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),P(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Ee(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){let o=r.value,s=t.innerType._zod.run(r,n);return s instanceof Promise?s.then(i=>Be(i,o)):Be(s,o)}return r.value===void 0?r:t.innerType._zod.run(r,n)}});var tt=l("$ZodDefault",(e,t)=>{$.init(e,t),e._zod.optin="optional",P(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Ke(s,t)):Ke(o,t)}});function Ke(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var rt=l("$ZodCustom",(e,t)=>{K.init(e,t),$.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(s=>Ge(s,r,n,e));Ge(o,r,n,e)}});function Ge(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(de(o))}}function nt(e,t){return new e({type:"string",...b(t)})}function ot(e,t){return new e({type:"number",checks:[],...b(t)})}function it(e,t){return new e({type:"boolean",...b(t)})}function me(e,t){return new Fe({check:"string_format",format:"regex",...b(t),pattern:e})}function st(e,t,r){let n=b(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}var Z=l("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");$.init(e,t),e.def=t,e.type=t.type,e.parse=(r,n)=>q(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>V(e,r,n),e.parseAsync=async(r,n)=>X(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>B(e,r,n),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]},{parent:!0}),e.with=e.check,e.clone=(r,n)=>pe(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.apply=r=>r(e)}),Xt=l("ZodMiniString",(e,t)=>{We.init(e,t),Z.init(e,t)});function A(e){return nt(Xt,e)}var Qt=l("ZodMiniNumber",(e,t)=>{Je.init(e,t),Z.init(e,t)});function he(e){return ot(Qt,e)}var er=l("ZodMiniBoolean",(e,t)=>{Ye.init(e,t),Z.init(e,t)});function E(e){return it(er,e)}var tr=l("ZodMiniArray",(e,t)=>{qe.init(e,t),Z.init(e,t)});function _e(e,t){return new tr({type:"array",element:e,...b(t)})}var rr=l("ZodMiniObject",(e,t)=>{Xe.init(e,t),Z.init(e,t),P(e,"shape",()=>t.shape)});function ge(e,t){let r={type:"object",shape:e??{},...b(t)};return new rr(r)}var nr=l("ZodMiniEnum",(e,t)=>{Qe.init(e,t),Z.init(e,t),e.options=Object.values(t.entries)});function ct(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new nr({type:"enum",entries:r,...b(t)})}var or=l("ZodMiniOptional",(e,t)=>{et.init(e,t),Z.init(e,t)});function x(e){return new or({type:"optional",innerType:e})}var ir=l("ZodMiniDefault",(e,t)=>{tt.init(e,t),Z.init(e,t)});function R(e,t){return new ir({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():le(t)}})}var sr=l("ZodMiniCustom",(e,t)=>{rt.init(e,t),Z.init(e,t)});function xe(e,t){return st(sr,e??(()=>!0),t)}var ee="https://in.dev.heycatch.ai",S="dev",I="0.7.1-dev.1459",ut="phc_CqKdgm7xbFBs3mSdtqzrHNTfzTRKrwRmCrEB9aftENY9";function at(e=S){return e!=="dev"?null:`[HeyCatch] WARNING: this is an internal development build (v${I}). Events are being sent to the HeyCatch development environment and will NEVER appear in your dashboard. Reinstall the latest stable version - resolve it with \`npm view @heycatch/sdk version\` - or re-run the install guide: https://heycatch.ai/agents.md`}var O="unknown",lr=["localStorage","cookie","memory","localStorage+cookie","sessionStorage"];var lt=ge({projectKey:A({error:'config.projectKey is missing or malformed \u2014 expected a string starting with "hck_pk_". Copy it from your project page in the HeyCatch dashboard.'}).check(me(/^hck_pk_/,{error:'config.projectKey is missing or malformed \u2014 expected a string starting with "hck_pk_". Copy it from your project page in the HeyCatch dashboard.'})),tracingHosts:R(_e(A()),[]),install:R(ge({framework:R(A(),O),frameworkVersion:R(A(),O),agent:R(A(),O)}),{framework:O,frameworkVersion:O,agent:O}),autocapture:x(E()),maskAllText:x(E()),maskAllElementAttributes:x(E()),propertyDenylist:x(_e(A())),sanitizeProperties:x(xe(e=>typeof e=="function")),beforeSend:x(xe(e=>typeof e=="function"||Array.isArray(e)&&e.every(t=>typeof t=="function"))),persistence:x(ct(lr)),disablePersistence:x(E()),cookieExpirationDays:x(he()),optOutCapturingByDefault:x(E()),respectDnt:x(E()),requestBatching:x(E()),flushIntervalMs:x(he())});var pr=5e3,fr=60,dr=1e3,mr=60,hr=new Set(["$set"]),ve="heycatch_volume_cap_reached",pt=3,_r=6e4;function te({bucket:e,perMinute:t,now:r}){if(e===void 0)return t;let n=Math.max(0,r-e.at);return Math.min(t,e.tokens+n*t/_r)}function gr(e){return e===void 0||e.length===0?!1:$e(xr(e))}function xr(e){if(e.startsWith("[")){let r=e.indexOf("]");return r===-1?e:e.slice(0,r+1)}let t=e.indexOf(":");return t!==-1&&t===e.lastIndexOf(":")?e.slice(0,t):e}function ft(e){let{$session_id:t,$host:r}=e.properties;return{sessionId:typeof t=="string"?t:"",host:typeof r=="string"?r:void 0}}var mt=4;function dt(e){if(e!==void 0)return typeof e=="object"&&e!==null&&"tokens"in e&&typeof e.tokens=="number"&&Number.isFinite(e.tokens)&&e.tokens>=0&&"at"in e&&typeof e.at=="number"&&Number.isFinite(e.at)?{tokens:e.tokens,at:e.at}:!1}function vr(e){if(typeof e=="object"&&e!==null&&"sessionId"in e&&typeof e.sessionId=="string"&&"count"in e&&typeof e.count=="number"&&Number.isInteger(e.count)&&e.count>=0&&"markerAttempts"in e&&typeof e.markerAttempts=="number"&&Number.isInteger(e.markerAttempts)&&e.markerAttempts>=0){let t=dt("person"in e?e.person:void 0),r=dt("localhost"in e?e.localhost:void 0);if(t!==!1&&r!==!1)return{sessionId:e.sessionId,count:e.count,markerAttempts:e.markerAttempts,person:t,localhost:r}}return null}function zr(e){if(e===null)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t.flatMap(r=>{let n=vr(r);return n===null?[]:[n]}).slice(0,mt)}catch{}return[]}function ht({store:e,warn:t,emitMarker:r,cap:n=pr,personUpdateBudget:o=fr,localhostFreeEvents:s=dr,localhostRatePerMinute:i=mr,now:c=Date.now}){let u=[],a=!1,p=!1,h=!1,d=!1;function g(){if(e===void 0||a)return u;try{return zr(e.read())}catch{return u}}function v(m){let w=g().filter(f=>f.sessionId!==m.sessionId);u=[m,...w].slice(0,mt);try{e?.write(JSON.stringify(u))}catch{a=!0}}function G(m){let w=g().find(_=>_.sessionId===m),f=u.find(_=>_.sessionId===m),y=[w,f].filter(_=>_!==void 0),W=c();function L(_,D){let C;for(let{[_]:T}of y)T!==void 0&&te({bucket:T,perMinute:D,now:W})<te({bucket:C,perMinute:D,now:W})&&(C=T);return C}return{sessionId:m,count:Math.max(0,...y.map(_=>_.count)),markerAttempts:Math.max(0,...y.map(_=>_.markerAttempts)),person:L("person",o),localhost:L("localhost",i)}}function j(m,w){let f=w,y=c(),{sessionId:W,host:L}=ft(m);f.person!==void 0&&f.person.at>y&&(f={...f,person:{...f.person,at:y}},v(f)),f.localhost!==void 0&&f.localhost.at>y&&(f={...f,localhost:{...f.localhost,at:y}},v(f));let _=hr.has(m.event),D=_?te({bucket:f.person,perMinute:o,now:y}):0;if(_&&D<1)return h||(h=!0,t(`[HeyCatch] setPersonProperties is being called more than ${o} times a minute - call it when a property changes, not on every render. Dropping the extra updates for now; other events are unaffected.`)),null;let C=f.count>=s&&gr(L),T=C?te({bucket:f.localhost,perMinute:i,now:y}):0;return C&&T<1?(d||(d=!0,t(`[HeyCatch] this local dev session (${L??"unknown host"}, session ${W||"unknown"}) sent ${s} events - throttling it to ${i} a minute so a dev loop cannot flood your analytics. Production traffic is unaffected.`)),null):(v({...f,count:f.count+1,..._?{person:{tokens:D-1,at:y}}:{},...C?{localhost:{tokens:T-1,at:y}}:{}}),m)}return m=>{if(m===null||m.event===ve)return m;let{sessionId:w}=ft(m),f=G(w);return f.count<n?j(m,f):(p||(p=!0,t(`[HeyCatch] this session sent ${n} events, the per-session cap - dropping the rest until a new session starts (session ${w||"unknown"}). A tracking call inside a render loop or an effect is the usual cause.`)),f.markerAttempts<pt&&(v({...f,markerAttempts:pt}),r({cap:n,sessionId:w})||v({...f,markerAttempts:f.markerAttempts+1})),null)}}function _t(e){let t=ht({warn:r=>{console.warn(r)},emitMarker:({cap:r})=>{let n=e();return n?.capture(ve,{heycatch_session_event_cap:r}),n!==null}});return r=>r===null||t({event:r.event,properties:r.properties??{}})===null?null:r}var re=null;function z(){return re}var ze=null;function xt(){ze?.()}function vt(e){if(re!==null)return;let t=lt.safeParse(e);if(!t.success){let i=t.error.issues[0]?.message??"init() requires a config object with { projectKey }.";console.error(`[HeyCatch] ${i}`);return}let r=new gt.PostHog(ut,{host:ee,preloadFeatureFlags:!1,disableRemoteFeatureFlags:!0,sendFeatureFlagEvent:!1,disableSurveys:!0,...t.data.optOutCapturingByDefault===void 0?{}:{defaultOptIn:!t.data.optOutCapturingByDefault},before_send:[_t(()=>re)]}),{install:n}=t.data,o={heycatch_framework:n.framework,heycatch_framework_version:n.frameworkVersion,heycatch_agent:n.agent};ze=()=>{r.register({heycatch_sdk_version:I,heycatch_sdk_stage:S,heycatch_project_key:t.data.projectKey,...o}),r.group(ye,t.data.projectKey,{key:t.data.projectKey,sdk_version:I,sdk_stage:S,framework:n.framework,framework_version:n.frameworkVersion,agent:n.agent,api_host:ee})},ze(),re=r,console.info(`[HeyCatch] SDK v${I} (${S}) initialized \u2192 ${ee}`);let s=at();s!==null&&console.warn(s)}function zt(e){return t=>{console.error(`[HeyCatch] consent ${e} could not be saved - capture state may reset on the next app launch:`,t)}}function yt(){z()?.optIn().catch(zt("opt-in"))}function $t(){z()?.optOut().catch(zt("opt-out"))}function bt(e,t,r){let n=z();if(n!==null){if(typeof e!="string"||e.length===0){console.error("[HeyCatch] setIdentity() requires a non-empty string user id. Pass a stable internal user id from your auth provider \u2014 not an email or session token.");return}n.identify(e,{...t?{$set:t}:{},...r?{$set_once:r}:{}})}}function wt(){let e=z();e!==null&&(e.reset(),xt())}function ne(e,t){let r=z();if(r!==null){if(typeof e!="string"||e.length===0){console.error("[HeyCatch] trackScreen() requires a non-empty screen name.");return}r.screen(e,t?t:void 0)}}function kt(e,t,r){let n=z();if(n!==null){if(typeof e!="string"||e.length===0){console.error("[HeyCatch] trackEvent() requires a non-empty event name.");return}if(e.startsWith("$")){console.error(`[HeyCatch] trackEvent() event names cannot start with "$" (got "${e}") - that prefix is reserved for built-in events.`);return}n.capture(e,{...t,...r?.set?{$set:r.set}:{},...r?.setOnce?{$set_once:r.setOnce}:{},heycatch_custom_user_event:!0})}}function Zt(e,t){let r=z();r!==null&&(!e&&!t||r.capture("$set",{...e?{$set:e}:{},...t?{$set_once:t}:{}}))}var Et=require("posthog-react-native"),Ct=require("react");var oe=require("react/jsx-runtime");function yr(){try{if(typeof require!="function")return null;let e=require("expo-router");return typeof e=="object"&&e!==null&&"usePathname"in e&&typeof e.usePathname=="function"&&"useGlobalSearchParams"in e&&typeof e.useGlobalSearchParams=="function"?{usePathname:e.usePathname,useGlobalSearchParams:e.useGlobalSearchParams}:null}catch{return null}}var Pt=yr();function $r(e){let t=JSON.parse(e);if(typeof t!="object"||t===null)return{};let r={};for(let[n,o]of Object.entries(t)){if(typeof o=="string"||typeof o=="number"||typeof o=="boolean"){r[n]=o;continue}Array.isArray(o)&&(r[n]=o.filter(s=>typeof s=="string").join(","))}return r}function br({router:e}){let{useGlobalSearchParams:t,usePathname:r}=e,n=r(),o=JSON.stringify(t());return(0,Ct.useEffect)(()=>{ne(n,$r(o))},[n,o]),null}function At({children:e}){let t=z();return t===null?(console.error("[HeyCatch] HeyCatchProvider mounted before init() - call analytics.init({ projectKey }) at module scope of the root layout."),e):(0,oe.jsxs)(Et.PostHogProvider,{autocapture:{captureScreens:!1,captureTouches:!0},client:t,children:[Pt===null?null:(0,oe.jsx)(br,{router:Pt}),e]})}var wr={init:vt,optInCapturing:yt,optOutCapturing:$t,resetIdentity:wt,setIdentity:bt,setPersonProperties:Zt,trackEvent:kt,trackScreen:ne};0&&(module.exports={HeyCatchProvider,SDK_VERSION,STAGE,analytics});
|
|
1
|
+
"use strict";var ie=Object.defineProperty;var St=Object.getOwnPropertyDescriptor;var It=Object.getOwnPropertyNames;var Tt=Object.prototype.hasOwnProperty;var Mt=(e,t)=>{for(var r in t)ie(e,r,{get:t[r],enumerable:!0})},Nt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of It(t))!Tt.call(e,o)&&o!==r&&ie(e,o,{get:()=>t[o],enumerable:!(n=St(t,o))||n.enumerable});return e};var Rt=e=>Nt(ie({},"__esModule",{value:!0}),e);var kr={};Mt(kr,{HeyCatchProvider:()=>At,SDK_VERSION:()=>I,STAGE:()=>S,analytics:()=>wr});module.exports=Rt(kr);var ye="project",Ot="[a-z0-9]",Pr=new RegExp(`^${Ot}$`);var jt=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function se(e){let t=jt.exec(e);if(t===null)return!1;let[,r="",n=""]=t,o=Number(r),s=Number(n);return o>255||s>255?!1:o===0||o===10||o===127||o===100&&s>=64&&s<=127||o===169&&s===254||o===172&&s>=16&&s<=31||o===192&&s===168}var Lt=/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/;function Dt(e){if(e==="::1"||e==="::")return!0;if(e.startsWith("::ffff:")){let t=Lt.exec(e);if(t===null)return se(e.slice(7));let[,r="",n=""]=t,o=Number.parseInt(r,16),s=Number.parseInt(n,16);return se(`${Math.floor(o/256)}.${o%256}.${Math.floor(s/256)}.${s%256}`)}return/^f[cd][0-9a-f]{2}:/.test(e)||/^fe[89ab][0-9a-f]:/.test(e)}function Ft(e){return e.toLowerCase().replace(/^\[/,"").replace(/\]$/,"").replace(/\.+$/,"")}function $e(e){let t=Ft(e);return t==="localhost"||t.endsWith(".localhost")||se(t)||Dt(t)}var gt=require("posthog-react-native");var be;function l(e,t,r){function n(c,u){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:u,constr:i,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,u);let a=i.prototype,p=Object.keys(a);for(let h=0;h<p.length;h++){let d=p[h];d in c||(c[d]=a[d].bind(c))}}let o=r?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:e});function i(c){var u;let a=r?.Parent?new s:this;n(a,c),(u=a._zod).deferred??(u.deferred=[]);for(let p of a._zod.deferred)p();return a}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:c=>r?.Parent&&c instanceof r.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}var k=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};(be=globalThis).__zod_globalConfig??(be.__zod_globalConfig={});var ce=globalThis.__zod_globalConfig;function M(e){return e&&Object.assign(ce,e),ce}function ke(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function Ze(e,t){return typeof t=="bigint"?t.toString():t}function Pe(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Ee(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}var we=Symbol("evaluating");function P(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==we)return n===void 0&&(n=we,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}var ae="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Y(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ce(e){if(Y(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Y(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function le(e){return Ce(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Ae=new Set(["string","number","symbol"]);function Se(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function pe(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function b(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Ie(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Cr={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function F(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Te(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function fe(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function J(e){return typeof e=="string"?e:e?.message}function N(e,t,r){let n=e.message?e.message:J(e.inst?._zod.def?.error?.(e))??J(t?.error?.(e))??J(r.customError?.(e))??J(r.localeError?.(e))??"Invalid input",{inst:o,continue:s,input:i,...c}=e;return c.path??(c.path=[]),c.message=n,t?.reportInput&&(c.input=i),c}function de(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}var Me=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Ze,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ne=l("$ZodError",Me),U=l("$ZodError",Me,{Parent:Error});var Ut=e=>(t,r,n,o)=>{let s=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},s);if(i instanceof Promise)throw new k;if(i.issues.length){let c=new(o?.Err??e)(i.issues.map(u=>N(u,s,M())));throw ae(c,o?.callee),c}return i.value},q=Ut(U),Vt=e=>async(t,r,n,o)=>{let s=n?{...n,async:!0}:{async:!0},i=t._zod.run({value:r,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){let c=new(o?.Err??e)(i.issues.map(u=>N(u,s,M())));throw ae(c,o?.callee),c}return i.value},X=Vt(U),Bt=e=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new k;return s.issues.length?{success:!1,error:new(e??Ne)(s.issues.map(i=>N(i,o,M())))}:{success:!0,data:s.value}},V=Bt(U),Kt=e=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>N(i,o,M())))}:{success:!0,data:s.value}},B=Kt(U);var Gt="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Wt=new RegExp(`^${Gt}$`);var Re=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var Oe=/^-?\d+(?:\.\d+)?$/,je=/^(?:true|false)$/i;var K=l("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var De=l("$ZodCheckStringFormat",(e,t)=>{var r,n;K.init(e,t),e._zod.onattach.push(o=>{let s=o._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Fe=l("$ZodCheckRegex",(e,t)=>{De.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}});var Ue={major:4,minor:4,patch:3};var $=l("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ue;let n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(let o of n)for(let s of o._zod.onattach)s(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let o=(i,c,u)=>{let a=F(i),p;for(let h of c){if(h._zod.def.when){if(Te(i)||!h._zod.def.when(i))continue}else if(a)continue;let d=i.issues.length,g=h._zod.check(i);if(g instanceof Promise&&u?.async===!1)throw new k;if(p||g instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await g,i.issues.length!==d&&(a||(a=F(i,d)))});else{if(i.issues.length===d)continue;a||(a=F(i,d))}}return p?p.then(()=>i):i},s=(i,c,u)=>{if(F(i))return i.aborted=!0,i;let a=o(c,n,u);if(a instanceof Promise){if(u.async===!1)throw new k;return a.then(p=>e._zod.parse(p,u))}return e._zod.parse(a,u)};e._zod.run=(i,c)=>{if(c.skipChecks)return e._zod.parse(i,c);if(c.direction==="backward"){let a=e._zod.parse({value:i.value,issues:[]},{...c,skipChecks:!0});return a instanceof Promise?a.then(p=>s(p,i,c)):s(a,i,c)}let u=e._zod.parse(i,c);if(u instanceof Promise){if(c.async===!1)throw new k;return u.then(a=>o(a,n,c))}return o(u,n,c)}}P(e,"~standard",()=>({validate:o=>{try{let s=V(e,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return B(e,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),We=l("$ZodString",(e,t)=>{$.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Re(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}});var Je=l("$ZodNumber",(e,t)=>{$.init(e,t),e._zod.pattern=e._zod.bag.pattern??Oe,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),r}});var Ye=l("$ZodBoolean",(e,t)=>{$.init(e,t),e._zod.pattern=je,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}});function Ve(e,t,r){e.issues.length&&t.issues.push(...fe(r,e.issues)),t.value[r]=e.value}var qe=l("$ZodArray",(e,t)=>{$.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=Array(o.length);let s=[];for(let i=0;i<o.length;i++){let c=o[i],u=t.element._zod.run({value:c,issues:[]},n);u instanceof Promise?s.push(u.then(a=>Ve(a,r,i))):Ve(u,r,i)}return s.length?Promise.all(s).then(()=>r):r}});function Q(e,t,r,n,o,s){let i=r in n;if(e.issues.length){if(o&&s&&!i)return;t.issues.push(...fe(r,e.issues))}if(!i&&!o){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?i&&(t.value[r]=void 0):t.value[r]=e.value}function Jt(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);let r=Ie(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function Yt(e,t,r,n,o,s){let i=[],c=o.keySet,u=o.catchall._zod,a=u.def.type,p=u.optin==="optional",h=u.optout==="optional";for(let d in t){if(d==="__proto__"||c.has(d))continue;if(a==="never"){i.push(d);continue}let g=u.run({value:t[d],issues:[]},n);g instanceof Promise?e.push(g.then(v=>Q(v,r,d,t,p,h))):Q(g,r,d,t,p,h)}return i.length&&r.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s}),e.length?Promise.all(e).then(()=>r):r}var Xe=l("$ZodObject",(e,t)=>{if($.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let c=t.shape;Object.defineProperty(t,"shape",{get:()=>{let u={...c};return Object.defineProperty(t,"shape",{value:u}),u}})}let n=Pe(()=>Jt(t));P(e._zod,"propValues",()=>{let c=t.shape,u={};for(let a in c){let p=c[a]._zod;if(p.values){u[a]??(u[a]=new Set);for(let h of p.values)u[a].add(h)}}return u});let o=Y,s=t.catchall,i;e._zod.parse=(c,u)=>{i??(i=n.value);let a=c.value;if(!o(a))return c.issues.push({expected:"object",code:"invalid_type",input:a,inst:e}),c;c.value={};let p=[],h=i.shape;for(let d of i.keys){let g=h[d],v=g._zod.optin==="optional",G=g._zod.optout==="optional",j=g._zod.run({value:a[d],issues:[]},u);j instanceof Promise?p.push(j.then(m=>Q(m,c,d,a,v,G))):Q(j,c,d,a,v,G)}return s?Yt(p,a,c,u,n.value,e):p.length?Promise.all(p).then(()=>c):c}});var Qe=l("$ZodEnum",(e,t)=>{$.init(e,t);let r=ke(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(o=>Ae.has(typeof o)).map(o=>typeof o=="string"?Se(o):o.toString()).join("|")})$`),e._zod.parse=(o,s)=>{let i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:r,input:i,inst:e}),o}});function Be(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var et=l("$ZodOptional",(e,t)=>{$.init(e,t),e._zod.optin="optional",e._zod.optout="optional",P(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),P(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Ee(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){let o=r.value,s=t.innerType._zod.run(r,n);return s instanceof Promise?s.then(i=>Be(i,o)):Be(s,o)}return r.value===void 0?r:t.innerType._zod.run(r,n)}});var tt=l("$ZodDefault",(e,t)=>{$.init(e,t),e._zod.optin="optional",P(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Ke(s,t)):Ke(o,t)}});function Ke(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var rt=l("$ZodCustom",(e,t)=>{K.init(e,t),$.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(s=>Ge(s,r,n,e));Ge(o,r,n,e)}});function Ge(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(de(o))}}function nt(e,t){return new e({type:"string",...b(t)})}function ot(e,t){return new e({type:"number",checks:[],...b(t)})}function it(e,t){return new e({type:"boolean",...b(t)})}function me(e,t){return new Fe({check:"string_format",format:"regex",...b(t),pattern:e})}function st(e,t,r){let n=b(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}var Z=l("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");$.init(e,t),e.def=t,e.type=t.type,e.parse=(r,n)=>q(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>V(e,r,n),e.parseAsync=async(r,n)=>X(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>B(e,r,n),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]},{parent:!0}),e.with=e.check,e.clone=(r,n)=>pe(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.apply=r=>r(e)}),Xt=l("ZodMiniString",(e,t)=>{We.init(e,t),Z.init(e,t)});function A(e){return nt(Xt,e)}var Qt=l("ZodMiniNumber",(e,t)=>{Je.init(e,t),Z.init(e,t)});function he(e){return ot(Qt,e)}var er=l("ZodMiniBoolean",(e,t)=>{Ye.init(e,t),Z.init(e,t)});function E(e){return it(er,e)}var tr=l("ZodMiniArray",(e,t)=>{qe.init(e,t),Z.init(e,t)});function _e(e,t){return new tr({type:"array",element:e,...b(t)})}var rr=l("ZodMiniObject",(e,t)=>{Xe.init(e,t),Z.init(e,t),P(e,"shape",()=>t.shape)});function ge(e,t){let r={type:"object",shape:e??{},...b(t)};return new rr(r)}var nr=l("ZodMiniEnum",(e,t)=>{Qe.init(e,t),Z.init(e,t),e.options=Object.values(t.entries)});function ct(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new nr({type:"enum",entries:r,...b(t)})}var or=l("ZodMiniOptional",(e,t)=>{et.init(e,t),Z.init(e,t)});function x(e){return new or({type:"optional",innerType:e})}var ir=l("ZodMiniDefault",(e,t)=>{tt.init(e,t),Z.init(e,t)});function R(e,t){return new ir({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():le(t)}})}var sr=l("ZodMiniCustom",(e,t)=>{rt.init(e,t),Z.init(e,t)});function xe(e,t){return st(sr,e??(()=>!0),t)}var ee="https://in.dev.heycatch.ai",S="dev",I="0.8.0-dev.1460",ut="phc_CqKdgm7xbFBs3mSdtqzrHNTfzTRKrwRmCrEB9aftENY9";function at(e=S){return e!=="dev"?null:`[HeyCatch] WARNING: this is an internal development build (v${I}). Events are being sent to the HeyCatch development environment and will NEVER appear in your dashboard. Reinstall the latest stable version - resolve it with \`npm view @heycatch/sdk version\` - or re-run the install guide: https://heycatch.ai/agents.md`}var O="unknown",lr=["localStorage","cookie","memory","localStorage+cookie","sessionStorage"];var lt=ge({projectKey:A({error:'config.projectKey is missing or malformed \u2014 expected a string starting with "hck_pk_". Copy it from your project page in the HeyCatch dashboard.'}).check(me(/^hck_pk_/,{error:'config.projectKey is missing or malformed \u2014 expected a string starting with "hck_pk_". Copy it from your project page in the HeyCatch dashboard.'})),tracingHosts:R(_e(A()),[]),install:R(ge({framework:R(A(),O),frameworkVersion:R(A(),O),agent:R(A(),O)}),{framework:O,frameworkVersion:O,agent:O}),autocapture:x(E()),maskAllText:x(E()),maskAllElementAttributes:x(E()),propertyDenylist:x(_e(A())),sanitizeProperties:x(xe(e=>typeof e=="function")),beforeSend:x(xe(e=>typeof e=="function"||Array.isArray(e)&&e.every(t=>typeof t=="function"))),persistence:x(ct(lr)),disablePersistence:x(E()),cookieExpirationDays:x(he()),optOutCapturingByDefault:x(E()),respectDnt:x(E()),requestBatching:x(E()),flushIntervalMs:x(he())});var pr=5e3,fr=60,dr=1e3,mr=60,hr=new Set(["$set"]),ve="heycatch_volume_cap_reached",pt=3,_r=6e4;function te({bucket:e,perMinute:t,now:r}){if(e===void 0)return t;let n=Math.max(0,r-e.at);return Math.min(t,e.tokens+n*t/_r)}function gr(e){return e===void 0||e.length===0?!1:$e(xr(e))}function xr(e){if(e.startsWith("[")){let r=e.indexOf("]");return r===-1?e:e.slice(0,r+1)}let t=e.indexOf(":");return t!==-1&&t===e.lastIndexOf(":")?e.slice(0,t):e}function ft(e){let{$session_id:t,$host:r}=e.properties;return{sessionId:typeof t=="string"?t:"",host:typeof r=="string"?r:void 0}}var mt=4;function dt(e){if(e!==void 0)return typeof e=="object"&&e!==null&&"tokens"in e&&typeof e.tokens=="number"&&Number.isFinite(e.tokens)&&e.tokens>=0&&"at"in e&&typeof e.at=="number"&&Number.isFinite(e.at)?{tokens:e.tokens,at:e.at}:!1}function vr(e){if(typeof e=="object"&&e!==null&&"sessionId"in e&&typeof e.sessionId=="string"&&"count"in e&&typeof e.count=="number"&&Number.isInteger(e.count)&&e.count>=0&&"markerAttempts"in e&&typeof e.markerAttempts=="number"&&Number.isInteger(e.markerAttempts)&&e.markerAttempts>=0){let t=dt("person"in e?e.person:void 0),r=dt("localhost"in e?e.localhost:void 0);if(t!==!1&&r!==!1)return{sessionId:e.sessionId,count:e.count,markerAttempts:e.markerAttempts,person:t,localhost:r}}return null}function zr(e){if(e===null)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t.flatMap(r=>{let n=vr(r);return n===null?[]:[n]}).slice(0,mt)}catch{}return[]}function ht({store:e,warn:t,emitMarker:r,cap:n=pr,personUpdateBudget:o=fr,localhostFreeEvents:s=dr,localhostRatePerMinute:i=mr,now:c=Date.now}){let u=[],a=!1,p=!1,h=!1,d=!1;function g(){if(e===void 0||a)return u;try{return zr(e.read())}catch{return u}}function v(m){let w=g().filter(f=>f.sessionId!==m.sessionId);u=[m,...w].slice(0,mt);try{e?.write(JSON.stringify(u))}catch{a=!0}}function G(m){let w=g().find(_=>_.sessionId===m),f=u.find(_=>_.sessionId===m),y=[w,f].filter(_=>_!==void 0),W=c();function L(_,D){let C;for(let{[_]:T}of y)T!==void 0&&te({bucket:T,perMinute:D,now:W})<te({bucket:C,perMinute:D,now:W})&&(C=T);return C}return{sessionId:m,count:Math.max(0,...y.map(_=>_.count)),markerAttempts:Math.max(0,...y.map(_=>_.markerAttempts)),person:L("person",o),localhost:L("localhost",i)}}function j(m,w){let f=w,y=c(),{sessionId:W,host:L}=ft(m);f.person!==void 0&&f.person.at>y&&(f={...f,person:{...f.person,at:y}},v(f)),f.localhost!==void 0&&f.localhost.at>y&&(f={...f,localhost:{...f.localhost,at:y}},v(f));let _=hr.has(m.event),D=_?te({bucket:f.person,perMinute:o,now:y}):0;if(_&&D<1)return h||(h=!0,t(`[HeyCatch] setPersonProperties is being called more than ${o} times a minute - call it when a property changes, not on every render. Dropping the extra updates for now; other events are unaffected.`)),null;let C=f.count>=s&&gr(L),T=C?te({bucket:f.localhost,perMinute:i,now:y}):0;return C&&T<1?(d||(d=!0,t(`[HeyCatch] this local dev session (${L??"unknown host"}, session ${W||"unknown"}) sent ${s} events - throttling it to ${i} a minute so a dev loop cannot flood your analytics. Production traffic is unaffected.`)),null):(v({...f,count:f.count+1,..._?{person:{tokens:D-1,at:y}}:{},...C?{localhost:{tokens:T-1,at:y}}:{}}),m)}return m=>{if(m===null||m.event===ve)return m;let{sessionId:w}=ft(m),f=G(w);return f.count<n?j(m,f):(p||(p=!0,t(`[HeyCatch] this session sent ${n} events, the per-session cap - dropping the rest until a new session starts (session ${w||"unknown"}). A tracking call inside a render loop or an effect is the usual cause.`)),f.markerAttempts<pt&&(v({...f,markerAttempts:pt}),r({cap:n,sessionId:w})||v({...f,markerAttempts:f.markerAttempts+1})),null)}}function _t(e){let t=ht({warn:r=>{console.warn(r)},emitMarker:({cap:r})=>{let n=e();return n?.capture(ve,{heycatch_session_event_cap:r}),n!==null}});return r=>r===null||t({event:r.event,properties:r.properties??{}})===null?null:r}var re=null;function z(){return re}var ze=null;function xt(){ze?.()}function vt(e){if(re!==null)return;let t=lt.safeParse(e);if(!t.success){let i=t.error.issues[0]?.message??"init() requires a config object with { projectKey }.";console.error(`[HeyCatch] ${i}`);return}let r=new gt.PostHog(ut,{host:ee,preloadFeatureFlags:!1,disableRemoteFeatureFlags:!0,sendFeatureFlagEvent:!1,disableSurveys:!0,...t.data.optOutCapturingByDefault===void 0?{}:{defaultOptIn:!t.data.optOutCapturingByDefault},before_send:[_t(()=>re)]}),{install:n}=t.data,o={heycatch_framework:n.framework,heycatch_framework_version:n.frameworkVersion,heycatch_agent:n.agent};ze=()=>{r.register({heycatch_sdk_version:I,heycatch_sdk_stage:S,heycatch_project_key:t.data.projectKey,...o}),r.group(ye,t.data.projectKey,{key:t.data.projectKey,sdk_version:I,sdk_stage:S,framework:n.framework,framework_version:n.frameworkVersion,agent:n.agent,api_host:ee})},ze(),re=r,console.info(`[HeyCatch] SDK v${I} (${S}) initialized \u2192 ${ee}`);let s=at();s!==null&&console.warn(s)}function zt(e){return t=>{console.error(`[HeyCatch] consent ${e} could not be saved - capture state may reset on the next app launch:`,t)}}function yt(){z()?.optIn().catch(zt("opt-in"))}function $t(){z()?.optOut().catch(zt("opt-out"))}function bt(e,t,r){let n=z();if(n!==null){if(typeof e!="string"||e.length===0){console.error("[HeyCatch] setIdentity() requires a non-empty string user id. Pass a stable internal user id from your auth provider \u2014 not an email or session token.");return}n.identify(e,{...t?{$set:t}:{},...r?{$set_once:r}:{}})}}function wt(){let e=z();e!==null&&(e.reset(),xt())}function ne(e,t){let r=z();if(r!==null){if(typeof e!="string"||e.length===0){console.error("[HeyCatch] trackScreen() requires a non-empty screen name.");return}r.screen(e,t?t:void 0)}}function kt(e,t,r){let n=z();if(n!==null){if(typeof e!="string"||e.length===0){console.error("[HeyCatch] trackEvent() requires a non-empty event name.");return}if(e.startsWith("$")){console.error(`[HeyCatch] trackEvent() event names cannot start with "$" (got "${e}") - that prefix is reserved for built-in events.`);return}n.capture(e,{...t,...r?.set?{$set:r.set}:{},...r?.setOnce?{$set_once:r.setOnce}:{},heycatch_custom_user_event:!0})}}function Zt(e,t){let r=z();r!==null&&(!e&&!t||r.capture("$set",{...e?{$set:e}:{},...t?{$set_once:t}:{}}))}var Et=require("posthog-react-native"),Ct=require("react");var oe=require("react/jsx-runtime");function yr(){try{if(typeof require!="function")return null;let e=require("expo-router");return typeof e=="object"&&e!==null&&"usePathname"in e&&typeof e.usePathname=="function"&&"useGlobalSearchParams"in e&&typeof e.useGlobalSearchParams=="function"?{usePathname:e.usePathname,useGlobalSearchParams:e.useGlobalSearchParams}:null}catch{return null}}var Pt=yr();function $r(e){let t=JSON.parse(e);if(typeof t!="object"||t===null)return{};let r={};for(let[n,o]of Object.entries(t)){if(typeof o=="string"||typeof o=="number"||typeof o=="boolean"){r[n]=o;continue}Array.isArray(o)&&(r[n]=o.filter(s=>typeof s=="string").join(","))}return r}function br({router:e}){let{useGlobalSearchParams:t,usePathname:r}=e,n=r(),o=JSON.stringify(t());return(0,Ct.useEffect)(()=>{ne(n,$r(o))},[n,o]),null}function At({children:e}){let t=z();return t===null?(console.error("[HeyCatch] HeyCatchProvider mounted before init() - call analytics.init({ projectKey }) at module scope of the root layout."),e):(0,oe.jsxs)(Et.PostHogProvider,{autocapture:{captureScreens:!1,captureTouches:!0},client:t,children:[Pt===null?null:(0,oe.jsx)(br,{router:Pt}),e]})}var wr={init:vt,optInCapturing:yt,optOutCapturing:$t,resetIdentity:wt,setIdentity:bt,setPersonProperties:Zt,trackEvent:kt,trackScreen:ne};0&&(module.exports={HeyCatchProvider,SDK_VERSION,STAGE,analytics});
|
|
2
2
|
//# sourceMappingURL=react-native.cjs.map
|
package/dist/react-native.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var oe=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var ze="project",Zt="[a-z0-9]",zr=new RegExp(`^${Zt}$`);var Pt=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function ie(e){let t=Pt.exec(e);if(t===null)return!1;let[,r="",n=""]=t,o=Number(r),s=Number(n);return o>255||s>255?!1:o===0||o===10||o===127||o===100&&s>=64&&s<=127||o===169&&s===254||o===172&&s>=16&&s<=31||o===192&&s===168}var Et=/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/;function Ct(e){if(e==="::1"||e==="::")return!0;if(e.startsWith("::ffff:")){let t=Et.exec(e);if(t===null)return ie(e.slice(7));let[,r="",n=""]=t,o=Number.parseInt(r,16),s=Number.parseInt(n,16);return ie(`${Math.floor(o/256)}.${o%256}.${Math.floor(s/256)}.${s%256}`)}return/^f[cd][0-9a-f]{2}:/.test(e)||/^fe[89ab][0-9a-f]:/.test(e)}function At(e){return e.toLowerCase().replace(/^\[/,"").replace(/\]$/,"").replace(/\.+$/,"")}function ye(e){let t=At(e);return t==="localhost"||t.endsWith(".localhost")||ie(t)||Ct(t)}import{PostHog as lr}from"posthog-react-native";var $e;function l(e,t,r){function n(c,u){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:u,constr:i,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,u);let a=i.prototype,p=Object.keys(a);for(let h=0;h<p.length;h++){let d=p[h];d in c||(c[d]=a[d].bind(c))}}let o=r?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:e});function i(c){var u;let a=r?.Parent?new s:this;n(a,c),(u=a._zod).deferred??(u.deferred=[]);for(let p of a._zod.deferred)p();return a}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:c=>r?.Parent&&c instanceof r.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}var k=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};($e=globalThis).__zod_globalConfig??($e.__zod_globalConfig={});var se=globalThis.__zod_globalConfig;function I(e){return e&&Object.assign(se,e),se}function we(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function ke(e,t){return typeof t=="bigint"?t.toString():t}function Ze(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Pe(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}var be=Symbol("evaluating");function P(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==be)return n===void 0&&(n=be,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}var ue="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Y(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ee(e){if(Y(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Y(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function ae(e){return Ee(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Ce=new Set(["string","number","symbol"]);function Ae(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function le(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function b(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Se(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var $r={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function F(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Ie(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function pe(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function J(e){return typeof e=="string"?e:e?.message}function T(e,t,r){let n=e.message?e.message:J(e.inst?._zod.def?.error?.(e))??J(t?.error?.(e))??J(r.customError?.(e))??J(r.localeError?.(e))??"Invalid input",{inst:o,continue:s,input:i,...c}=e;return c.path??(c.path=[]),c.message=n,t?.reportInput&&(c.input=i),c}function fe(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}var Te=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,ke,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Me=l("$ZodError",Te),U=l("$ZodError",Te,{Parent:Error});var It=e=>(t,r,n,o)=>{let s=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},s);if(i instanceof Promise)throw new k;if(i.issues.length){let c=new(o?.Err??e)(i.issues.map(u=>T(u,s,I())));throw ue(c,o?.callee),c}return i.value},q=It(U),Tt=e=>async(t,r,n,o)=>{let s=n?{...n,async:!0}:{async:!0},i=t._zod.run({value:r,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){let c=new(o?.Err??e)(i.issues.map(u=>T(u,s,I())));throw ue(c,o?.callee),c}return i.value},X=Tt(U),Mt=e=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new k;return s.issues.length?{success:!1,error:new(e??Me)(s.issues.map(i=>T(i,o,I())))}:{success:!0,data:s.value}},V=Mt(U),Nt=e=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>T(i,o,I())))}:{success:!0,data:s.value}},B=Nt(U);var Rt="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Ot=new RegExp(`^${Rt}$`);var Ne=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var Re=/^-?\d+(?:\.\d+)?$/,Oe=/^(?:true|false)$/i;var K=l("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var Le=l("$ZodCheckStringFormat",(e,t)=>{var r,n;K.init(e,t),e._zod.onattach.push(o=>{let s=o._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),De=l("$ZodCheckRegex",(e,t)=>{Le.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}});var He={major:4,minor:4,patch:3};var $=l("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=He;let n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(let o of n)for(let s of o._zod.onattach)s(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let o=(i,c,u)=>{let a=F(i),p;for(let h of c){if(h._zod.def.when){if(Ie(i)||!h._zod.def.when(i))continue}else if(a)continue;let d=i.issues.length,g=h._zod.check(i);if(g instanceof Promise&&u?.async===!1)throw new k;if(p||g instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await g,i.issues.length!==d&&(a||(a=F(i,d)))});else{if(i.issues.length===d)continue;a||(a=F(i,d))}}return p?p.then(()=>i):i},s=(i,c,u)=>{if(F(i))return i.aborted=!0,i;let a=o(c,n,u);if(a instanceof Promise){if(u.async===!1)throw new k;return a.then(p=>e._zod.parse(p,u))}return e._zod.parse(a,u)};e._zod.run=(i,c)=>{if(c.skipChecks)return e._zod.parse(i,c);if(c.direction==="backward"){let a=e._zod.parse({value:i.value,issues:[]},{...c,skipChecks:!0});return a instanceof Promise?a.then(p=>s(p,i,c)):s(a,i,c)}let u=e._zod.parse(i,c);if(u instanceof Promise){if(c.async===!1)throw new k;return u.then(a=>o(a,n,c))}return o(u,n,c)}}P(e,"~standard",()=>({validate:o=>{try{let s=V(e,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return B(e,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),Ge=l("$ZodString",(e,t)=>{$.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Ne(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}});var We=l("$ZodNumber",(e,t)=>{$.init(e,t),e._zod.pattern=e._zod.bag.pattern??Re,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),r}});var Je=l("$ZodBoolean",(e,t)=>{$.init(e,t),e._zod.pattern=Oe,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}});function Ue(e,t,r){e.issues.length&&t.issues.push(...pe(r,e.issues)),t.value[r]=e.value}var Ye=l("$ZodArray",(e,t)=>{$.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=Array(o.length);let s=[];for(let i=0;i<o.length;i++){let c=o[i],u=t.element._zod.run({value:c,issues:[]},n);u instanceof Promise?s.push(u.then(a=>Ue(a,r,i))):Ue(u,r,i)}return s.length?Promise.all(s).then(()=>r):r}});function Q(e,t,r,n,o,s){let i=r in n;if(e.issues.length){if(o&&s&&!i)return;t.issues.push(...pe(r,e.issues))}if(!i&&!o){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?i&&(t.value[r]=void 0):t.value[r]=e.value}function jt(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);let r=Se(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function Lt(e,t,r,n,o,s){let i=[],c=o.keySet,u=o.catchall._zod,a=u.def.type,p=u.optin==="optional",h=u.optout==="optional";for(let d in t){if(d==="__proto__"||c.has(d))continue;if(a==="never"){i.push(d);continue}let g=u.run({value:t[d],issues:[]},n);g instanceof Promise?e.push(g.then(v=>Q(v,r,d,t,p,h))):Q(g,r,d,t,p,h)}return i.length&&r.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s}),e.length?Promise.all(e).then(()=>r):r}var qe=l("$ZodObject",(e,t)=>{if($.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let c=t.shape;Object.defineProperty(t,"shape",{get:()=>{let u={...c};return Object.defineProperty(t,"shape",{value:u}),u}})}let n=Ze(()=>jt(t));P(e._zod,"propValues",()=>{let c=t.shape,u={};for(let a in c){let p=c[a]._zod;if(p.values){u[a]??(u[a]=new Set);for(let h of p.values)u[a].add(h)}}return u});let o=Y,s=t.catchall,i;e._zod.parse=(c,u)=>{i??(i=n.value);let a=c.value;if(!o(a))return c.issues.push({expected:"object",code:"invalid_type",input:a,inst:e}),c;c.value={};let p=[],h=i.shape;for(let d of i.keys){let g=h[d],v=g._zod.optin==="optional",G=g._zod.optout==="optional",j=g._zod.run({value:a[d],issues:[]},u);j instanceof Promise?p.push(j.then(m=>Q(m,c,d,a,v,G))):Q(j,c,d,a,v,G)}return s?Lt(p,a,c,u,n.value,e):p.length?Promise.all(p).then(()=>c):c}});var Xe=l("$ZodEnum",(e,t)=>{$.init(e,t);let r=we(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(o=>Ce.has(typeof o)).map(o=>typeof o=="string"?Ae(o):o.toString()).join("|")})$`),e._zod.parse=(o,s)=>{let i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:r,input:i,inst:e}),o}});function Ve(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Qe=l("$ZodOptional",(e,t)=>{$.init(e,t),e._zod.optin="optional",e._zod.optout="optional",P(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),P(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Pe(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){let o=r.value,s=t.innerType._zod.run(r,n);return s instanceof Promise?s.then(i=>Ve(i,o)):Ve(s,o)}return r.value===void 0?r:t.innerType._zod.run(r,n)}});var et=l("$ZodDefault",(e,t)=>{$.init(e,t),e._zod.optin="optional",P(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Be(s,t)):Be(o,t)}});function Be(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var tt=l("$ZodCustom",(e,t)=>{K.init(e,t),$.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(s=>Ke(s,r,n,e));Ke(o,r,n,e)}});function Ke(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(fe(o))}}function rt(e,t){return new e({type:"string",...b(t)})}function nt(e,t){return new e({type:"number",checks:[],...b(t)})}function ot(e,t){return new e({type:"boolean",...b(t)})}function de(e,t){return new De({check:"string_format",format:"regex",...b(t),pattern:e})}function it(e,t,r){let n=b(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}var Z=l("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");$.init(e,t),e.def=t,e.type=t.type,e.parse=(r,n)=>q(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>V(e,r,n),e.parseAsync=async(r,n)=>X(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>B(e,r,n),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]},{parent:!0}),e.with=e.check,e.clone=(r,n)=>le(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.apply=r=>r(e)}),Ft=l("ZodMiniString",(e,t)=>{Ge.init(e,t),Z.init(e,t)});function A(e){return rt(Ft,e)}var Ht=l("ZodMiniNumber",(e,t)=>{We.init(e,t),Z.init(e,t)});function me(e){return nt(Ht,e)}var Ut=l("ZodMiniBoolean",(e,t)=>{Je.init(e,t),Z.init(e,t)});function E(e){return ot(Ut,e)}var Vt=l("ZodMiniArray",(e,t)=>{Ye.init(e,t),Z.init(e,t)});function he(e,t){return new Vt({type:"array",element:e,...b(t)})}var Bt=l("ZodMiniObject",(e,t)=>{qe.init(e,t),Z.init(e,t),P(e,"shape",()=>t.shape)});function _e(e,t){let r={type:"object",shape:e??{},...b(t)};return new Bt(r)}var Kt=l("ZodMiniEnum",(e,t)=>{Xe.init(e,t),Z.init(e,t),e.options=Object.values(t.entries)});function st(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new Kt({type:"enum",entries:r,...b(t)})}var Gt=l("ZodMiniOptional",(e,t)=>{Qe.init(e,t),Z.init(e,t)});function x(e){return new Gt({type:"optional",innerType:e})}var Wt=l("ZodMiniDefault",(e,t)=>{et.init(e,t),Z.init(e,t)});function M(e,t){return new Wt({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():ae(t)}})}var Jt=l("ZodMiniCustom",(e,t)=>{tt.init(e,t),Z.init(e,t)});function ge(e,t){return it(Jt,e??(()=>!0),t)}var ee="https://in.dev.heycatch.ai",R="dev",O="0.7.1-dev.1459",ct="phc_CqKdgm7xbFBs3mSdtqzrHNTfzTRKrwRmCrEB9aftENY9";function ut(e=R){return e!=="dev"?null:`[HeyCatch] WARNING: this is an internal development build (v${O}). Events are being sent to the HeyCatch development environment and will NEVER appear in your dashboard. Reinstall the latest stable version - resolve it with \`npm view @heycatch/sdk version\` - or re-run the install guide: https://heycatch.ai/agents.md`}var N="unknown",Qt=["localStorage","cookie","memory","localStorage+cookie","sessionStorage"];var at=_e({projectKey:A({error:'config.projectKey is missing or malformed \u2014 expected a string starting with "hck_pk_". Copy it from your project page in the HeyCatch dashboard.'}).check(de(/^hck_pk_/,{error:'config.projectKey is missing or malformed \u2014 expected a string starting with "hck_pk_". Copy it from your project page in the HeyCatch dashboard.'})),tracingHosts:M(he(A()),[]),install:M(_e({framework:M(A(),N),frameworkVersion:M(A(),N),agent:M(A(),N)}),{framework:N,frameworkVersion:N,agent:N}),autocapture:x(E()),maskAllText:x(E()),maskAllElementAttributes:x(E()),propertyDenylist:x(he(A())),sanitizeProperties:x(ge(e=>typeof e=="function")),beforeSend:x(ge(e=>typeof e=="function"||Array.isArray(e)&&e.every(t=>typeof t=="function"))),persistence:x(st(Qt)),disablePersistence:x(E()),cookieExpirationDays:x(me()),optOutCapturingByDefault:x(E()),respectDnt:x(E()),requestBatching:x(E()),flushIntervalMs:x(me())});var er=5e3,tr=60,rr=1e3,nr=60,or=new Set(["$set"]),xe="heycatch_volume_cap_reached",lt=3,ir=6e4;function te({bucket:e,perMinute:t,now:r}){if(e===void 0)return t;let n=Math.max(0,r-e.at);return Math.min(t,e.tokens+n*t/ir)}function sr(e){return e===void 0||e.length===0?!1:ye(cr(e))}function cr(e){if(e.startsWith("[")){let r=e.indexOf("]");return r===-1?e:e.slice(0,r+1)}let t=e.indexOf(":");return t!==-1&&t===e.lastIndexOf(":")?e.slice(0,t):e}function pt(e){let{$session_id:t,$host:r}=e.properties;return{sessionId:typeof t=="string"?t:"",host:typeof r=="string"?r:void 0}}var dt=4;function ft(e){if(e!==void 0)return typeof e=="object"&&e!==null&&"tokens"in e&&typeof e.tokens=="number"&&Number.isFinite(e.tokens)&&e.tokens>=0&&"at"in e&&typeof e.at=="number"&&Number.isFinite(e.at)?{tokens:e.tokens,at:e.at}:!1}function ur(e){if(typeof e=="object"&&e!==null&&"sessionId"in e&&typeof e.sessionId=="string"&&"count"in e&&typeof e.count=="number"&&Number.isInteger(e.count)&&e.count>=0&&"markerAttempts"in e&&typeof e.markerAttempts=="number"&&Number.isInteger(e.markerAttempts)&&e.markerAttempts>=0){let t=ft("person"in e?e.person:void 0),r=ft("localhost"in e?e.localhost:void 0);if(t!==!1&&r!==!1)return{sessionId:e.sessionId,count:e.count,markerAttempts:e.markerAttempts,person:t,localhost:r}}return null}function ar(e){if(e===null)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t.flatMap(r=>{let n=ur(r);return n===null?[]:[n]}).slice(0,dt)}catch{}return[]}function mt({store:e,warn:t,emitMarker:r,cap:n=er,personUpdateBudget:o=tr,localhostFreeEvents:s=rr,localhostRatePerMinute:i=nr,now:c=Date.now}){let u=[],a=!1,p=!1,h=!1,d=!1;function g(){if(e===void 0||a)return u;try{return ar(e.read())}catch{return u}}function v(m){let w=g().filter(f=>f.sessionId!==m.sessionId);u=[m,...w].slice(0,dt);try{e?.write(JSON.stringify(u))}catch{a=!0}}function G(m){let w=g().find(_=>_.sessionId===m),f=u.find(_=>_.sessionId===m),y=[w,f].filter(_=>_!==void 0),W=c();function L(_,D){let C;for(let{[_]:S}of y)S!==void 0&&te({bucket:S,perMinute:D,now:W})<te({bucket:C,perMinute:D,now:W})&&(C=S);return C}return{sessionId:m,count:Math.max(0,...y.map(_=>_.count)),markerAttempts:Math.max(0,...y.map(_=>_.markerAttempts)),person:L("person",o),localhost:L("localhost",i)}}function j(m,w){let f=w,y=c(),{sessionId:W,host:L}=pt(m);f.person!==void 0&&f.person.at>y&&(f={...f,person:{...f.person,at:y}},v(f)),f.localhost!==void 0&&f.localhost.at>y&&(f={...f,localhost:{...f.localhost,at:y}},v(f));let _=or.has(m.event),D=_?te({bucket:f.person,perMinute:o,now:y}):0;if(_&&D<1)return h||(h=!0,t(`[HeyCatch] setPersonProperties is being called more than ${o} times a minute - call it when a property changes, not on every render. Dropping the extra updates for now; other events are unaffected.`)),null;let C=f.count>=s&&sr(L),S=C?te({bucket:f.localhost,perMinute:i,now:y}):0;return C&&S<1?(d||(d=!0,t(`[HeyCatch] this local dev session (${L??"unknown host"}, session ${W||"unknown"}) sent ${s} events - throttling it to ${i} a minute so a dev loop cannot flood your analytics. Production traffic is unaffected.`)),null):(v({...f,count:f.count+1,..._?{person:{tokens:D-1,at:y}}:{},...C?{localhost:{tokens:S-1,at:y}}:{}}),m)}return m=>{if(m===null||m.event===xe)return m;let{sessionId:w}=pt(m),f=G(w);return f.count<n?j(m,f):(p||(p=!0,t(`[HeyCatch] this session sent ${n} events, the per-session cap - dropping the rest until a new session starts (session ${w||"unknown"}). A tracking call inside a render loop or an effect is the usual cause.`)),f.markerAttempts<lt&&(v({...f,markerAttempts:lt}),r({cap:n,sessionId:w})||v({...f,markerAttempts:f.markerAttempts+1})),null)}}function ht(e){let t=mt({warn:r=>{console.warn(r)},emitMarker:({cap:r})=>{let n=e();return n?.capture(xe,{heycatch_session_event_cap:r}),n!==null}});return r=>r===null||t({event:r.event,properties:r.properties??{}})===null?null:r}var re=null;function z(){return re}var ve=null;function _t(){ve?.()}function gt(e){if(re!==null)return;let t=at.safeParse(e);if(!t.success){let i=t.error.issues[0]?.message??"init() requires a config object with { projectKey }.";console.error(`[HeyCatch] ${i}`);return}let r=new lr(ct,{host:ee,preloadFeatureFlags:!1,disableRemoteFeatureFlags:!0,sendFeatureFlagEvent:!1,disableSurveys:!0,...t.data.optOutCapturingByDefault===void 0?{}:{defaultOptIn:!t.data.optOutCapturingByDefault},before_send:[ht(()=>re)]}),{install:n}=t.data,o={heycatch_framework:n.framework,heycatch_framework_version:n.frameworkVersion,heycatch_agent:n.agent};ve=()=>{r.register({heycatch_sdk_version:O,heycatch_sdk_stage:R,heycatch_project_key:t.data.projectKey,...o}),r.group(ze,t.data.projectKey,{key:t.data.projectKey,sdk_version:O,sdk_stage:R,framework:n.framework,framework_version:n.frameworkVersion,agent:n.agent,api_host:ee})},ve(),re=r,console.info(`[HeyCatch] SDK v${O} (${R}) initialized \u2192 ${ee}`);let s=ut();s!==null&&console.warn(s)}function xt(e){return t=>{console.error(`[HeyCatch] consent ${e} could not be saved - capture state may reset on the next app launch:`,t)}}function vt(){z()?.optIn().catch(xt("opt-in"))}function zt(){z()?.optOut().catch(xt("opt-out"))}function yt(e,t,r){let n=z();if(n!==null){if(typeof e!="string"||e.length===0){console.error("[HeyCatch] setIdentity() requires a non-empty string user id. Pass a stable internal user id from your auth provider \u2014 not an email or session token.");return}n.identify(e,{...t?{$set:t}:{},...r?{$set_once:r}:{}})}}function $t(){let e=z();e!==null&&(e.reset(),_t())}function ne(e,t){let r=z();if(r!==null){if(typeof e!="string"||e.length===0){console.error("[HeyCatch] trackScreen() requires a non-empty screen name.");return}r.screen(e,t?t:void 0)}}function bt(e,t,r){let n=z();if(n!==null){if(typeof e!="string"||e.length===0){console.error("[HeyCatch] trackEvent() requires a non-empty event name.");return}if(e.startsWith("$")){console.error(`[HeyCatch] trackEvent() event names cannot start with "$" (got "${e}") - that prefix is reserved for built-in events.`);return}n.capture(e,{...t,...r?.set?{$set:r.set}:{},...r?.setOnce?{$set_once:r.setOnce}:{},heycatch_custom_user_event:!0})}}function wt(e,t){let r=z();r!==null&&(!e&&!t||r.capture("$set",{...e?{$set:e}:{},...t?{$set_once:t}:{}}))}import{PostHogProvider as pr}from"posthog-react-native";import{useEffect as fr}from"react";import{jsx as gr,jsxs as xr}from"react/jsx-runtime";function dr(){try{if(typeof oe!="function")return null;let e=oe("expo-router");return typeof e=="object"&&e!==null&&"usePathname"in e&&typeof e.usePathname=="function"&&"useGlobalSearchParams"in e&&typeof e.useGlobalSearchParams=="function"?{usePathname:e.usePathname,useGlobalSearchParams:e.useGlobalSearchParams}:null}catch{return null}}var kt=dr();function mr(e){let t=JSON.parse(e);if(typeof t!="object"||t===null)return{};let r={};for(let[n,o]of Object.entries(t)){if(typeof o=="string"||typeof o=="number"||typeof o=="boolean"){r[n]=o;continue}Array.isArray(o)&&(r[n]=o.filter(s=>typeof s=="string").join(","))}return r}function hr({router:e}){let{useGlobalSearchParams:t,usePathname:r}=e,n=r(),o=JSON.stringify(t());return fr(()=>{ne(n,mr(o))},[n,o]),null}function _r({children:e}){let t=z();return t===null?(console.error("[HeyCatch] HeyCatchProvider mounted before init() - call analytics.init({ projectKey }) at module scope of the root layout."),e):xr(pr,{autocapture:{captureScreens:!1,captureTouches:!0},client:t,children:[kt===null?null:gr(hr,{router:kt}),e]})}var Ws={init:gt,optInCapturing:vt,optOutCapturing:zt,resetIdentity:$t,setIdentity:yt,setPersonProperties:wt,trackEvent:bt,trackScreen:ne};export{_r as HeyCatchProvider,O as SDK_VERSION,R as STAGE,Ws as analytics};
|
|
1
|
+
var oe=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var ze="project",Zt="[a-z0-9]",zr=new RegExp(`^${Zt}$`);var Pt=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function ie(e){let t=Pt.exec(e);if(t===null)return!1;let[,r="",n=""]=t,o=Number(r),s=Number(n);return o>255||s>255?!1:o===0||o===10||o===127||o===100&&s>=64&&s<=127||o===169&&s===254||o===172&&s>=16&&s<=31||o===192&&s===168}var Et=/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/;function Ct(e){if(e==="::1"||e==="::")return!0;if(e.startsWith("::ffff:")){let t=Et.exec(e);if(t===null)return ie(e.slice(7));let[,r="",n=""]=t,o=Number.parseInt(r,16),s=Number.parseInt(n,16);return ie(`${Math.floor(o/256)}.${o%256}.${Math.floor(s/256)}.${s%256}`)}return/^f[cd][0-9a-f]{2}:/.test(e)||/^fe[89ab][0-9a-f]:/.test(e)}function At(e){return e.toLowerCase().replace(/^\[/,"").replace(/\]$/,"").replace(/\.+$/,"")}function ye(e){let t=At(e);return t==="localhost"||t.endsWith(".localhost")||ie(t)||Ct(t)}import{PostHog as lr}from"posthog-react-native";var $e;function l(e,t,r){function n(c,u){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:u,constr:i,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,u);let a=i.prototype,p=Object.keys(a);for(let h=0;h<p.length;h++){let d=p[h];d in c||(c[d]=a[d].bind(c))}}let o=r?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:e});function i(c){var u;let a=r?.Parent?new s:this;n(a,c),(u=a._zod).deferred??(u.deferred=[]);for(let p of a._zod.deferred)p();return a}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:c=>r?.Parent&&c instanceof r.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}var k=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};($e=globalThis).__zod_globalConfig??($e.__zod_globalConfig={});var se=globalThis.__zod_globalConfig;function I(e){return e&&Object.assign(se,e),se}function we(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function ke(e,t){return typeof t=="bigint"?t.toString():t}function Ze(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Pe(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}var be=Symbol("evaluating");function P(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==be)return n===void 0&&(n=be,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}var ue="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Y(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ee(e){if(Y(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Y(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function ae(e){return Ee(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Ce=new Set(["string","number","symbol"]);function Ae(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function le(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function b(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Se(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var $r={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function F(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Ie(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function pe(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function J(e){return typeof e=="string"?e:e?.message}function T(e,t,r){let n=e.message?e.message:J(e.inst?._zod.def?.error?.(e))??J(t?.error?.(e))??J(r.customError?.(e))??J(r.localeError?.(e))??"Invalid input",{inst:o,continue:s,input:i,...c}=e;return c.path??(c.path=[]),c.message=n,t?.reportInput&&(c.input=i),c}function fe(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}var Te=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,ke,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Me=l("$ZodError",Te),U=l("$ZodError",Te,{Parent:Error});var It=e=>(t,r,n,o)=>{let s=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},s);if(i instanceof Promise)throw new k;if(i.issues.length){let c=new(o?.Err??e)(i.issues.map(u=>T(u,s,I())));throw ue(c,o?.callee),c}return i.value},q=It(U),Tt=e=>async(t,r,n,o)=>{let s=n?{...n,async:!0}:{async:!0},i=t._zod.run({value:r,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){let c=new(o?.Err??e)(i.issues.map(u=>T(u,s,I())));throw ue(c,o?.callee),c}return i.value},X=Tt(U),Mt=e=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new k;return s.issues.length?{success:!1,error:new(e??Me)(s.issues.map(i=>T(i,o,I())))}:{success:!0,data:s.value}},V=Mt(U),Nt=e=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>T(i,o,I())))}:{success:!0,data:s.value}},B=Nt(U);var Rt="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Ot=new RegExp(`^${Rt}$`);var Ne=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var Re=/^-?\d+(?:\.\d+)?$/,Oe=/^(?:true|false)$/i;var K=l("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var Le=l("$ZodCheckStringFormat",(e,t)=>{var r,n;K.init(e,t),e._zod.onattach.push(o=>{let s=o._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),De=l("$ZodCheckRegex",(e,t)=>{Le.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}});var He={major:4,minor:4,patch:3};var $=l("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=He;let n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(let o of n)for(let s of o._zod.onattach)s(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let o=(i,c,u)=>{let a=F(i),p;for(let h of c){if(h._zod.def.when){if(Ie(i)||!h._zod.def.when(i))continue}else if(a)continue;let d=i.issues.length,g=h._zod.check(i);if(g instanceof Promise&&u?.async===!1)throw new k;if(p||g instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await g,i.issues.length!==d&&(a||(a=F(i,d)))});else{if(i.issues.length===d)continue;a||(a=F(i,d))}}return p?p.then(()=>i):i},s=(i,c,u)=>{if(F(i))return i.aborted=!0,i;let a=o(c,n,u);if(a instanceof Promise){if(u.async===!1)throw new k;return a.then(p=>e._zod.parse(p,u))}return e._zod.parse(a,u)};e._zod.run=(i,c)=>{if(c.skipChecks)return e._zod.parse(i,c);if(c.direction==="backward"){let a=e._zod.parse({value:i.value,issues:[]},{...c,skipChecks:!0});return a instanceof Promise?a.then(p=>s(p,i,c)):s(a,i,c)}let u=e._zod.parse(i,c);if(u instanceof Promise){if(c.async===!1)throw new k;return u.then(a=>o(a,n,c))}return o(u,n,c)}}P(e,"~standard",()=>({validate:o=>{try{let s=V(e,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return B(e,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),Ge=l("$ZodString",(e,t)=>{$.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Ne(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}});var We=l("$ZodNumber",(e,t)=>{$.init(e,t),e._zod.pattern=e._zod.bag.pattern??Re,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),r}});var Je=l("$ZodBoolean",(e,t)=>{$.init(e,t),e._zod.pattern=Oe,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}});function Ue(e,t,r){e.issues.length&&t.issues.push(...pe(r,e.issues)),t.value[r]=e.value}var Ye=l("$ZodArray",(e,t)=>{$.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=Array(o.length);let s=[];for(let i=0;i<o.length;i++){let c=o[i],u=t.element._zod.run({value:c,issues:[]},n);u instanceof Promise?s.push(u.then(a=>Ue(a,r,i))):Ue(u,r,i)}return s.length?Promise.all(s).then(()=>r):r}});function Q(e,t,r,n,o,s){let i=r in n;if(e.issues.length){if(o&&s&&!i)return;t.issues.push(...pe(r,e.issues))}if(!i&&!o){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?i&&(t.value[r]=void 0):t.value[r]=e.value}function jt(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);let r=Se(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function Lt(e,t,r,n,o,s){let i=[],c=o.keySet,u=o.catchall._zod,a=u.def.type,p=u.optin==="optional",h=u.optout==="optional";for(let d in t){if(d==="__proto__"||c.has(d))continue;if(a==="never"){i.push(d);continue}let g=u.run({value:t[d],issues:[]},n);g instanceof Promise?e.push(g.then(v=>Q(v,r,d,t,p,h))):Q(g,r,d,t,p,h)}return i.length&&r.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s}),e.length?Promise.all(e).then(()=>r):r}var qe=l("$ZodObject",(e,t)=>{if($.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let c=t.shape;Object.defineProperty(t,"shape",{get:()=>{let u={...c};return Object.defineProperty(t,"shape",{value:u}),u}})}let n=Ze(()=>jt(t));P(e._zod,"propValues",()=>{let c=t.shape,u={};for(let a in c){let p=c[a]._zod;if(p.values){u[a]??(u[a]=new Set);for(let h of p.values)u[a].add(h)}}return u});let o=Y,s=t.catchall,i;e._zod.parse=(c,u)=>{i??(i=n.value);let a=c.value;if(!o(a))return c.issues.push({expected:"object",code:"invalid_type",input:a,inst:e}),c;c.value={};let p=[],h=i.shape;for(let d of i.keys){let g=h[d],v=g._zod.optin==="optional",G=g._zod.optout==="optional",j=g._zod.run({value:a[d],issues:[]},u);j instanceof Promise?p.push(j.then(m=>Q(m,c,d,a,v,G))):Q(j,c,d,a,v,G)}return s?Lt(p,a,c,u,n.value,e):p.length?Promise.all(p).then(()=>c):c}});var Xe=l("$ZodEnum",(e,t)=>{$.init(e,t);let r=we(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(o=>Ce.has(typeof o)).map(o=>typeof o=="string"?Ae(o):o.toString()).join("|")})$`),e._zod.parse=(o,s)=>{let i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:r,input:i,inst:e}),o}});function Ve(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Qe=l("$ZodOptional",(e,t)=>{$.init(e,t),e._zod.optin="optional",e._zod.optout="optional",P(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),P(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Pe(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){let o=r.value,s=t.innerType._zod.run(r,n);return s instanceof Promise?s.then(i=>Ve(i,o)):Ve(s,o)}return r.value===void 0?r:t.innerType._zod.run(r,n)}});var et=l("$ZodDefault",(e,t)=>{$.init(e,t),e._zod.optin="optional",P(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Be(s,t)):Be(o,t)}});function Be(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var tt=l("$ZodCustom",(e,t)=>{K.init(e,t),$.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(s=>Ke(s,r,n,e));Ke(o,r,n,e)}});function Ke(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(fe(o))}}function rt(e,t){return new e({type:"string",...b(t)})}function nt(e,t){return new e({type:"number",checks:[],...b(t)})}function ot(e,t){return new e({type:"boolean",...b(t)})}function de(e,t){return new De({check:"string_format",format:"regex",...b(t),pattern:e})}function it(e,t,r){let n=b(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}var Z=l("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");$.init(e,t),e.def=t,e.type=t.type,e.parse=(r,n)=>q(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>V(e,r,n),e.parseAsync=async(r,n)=>X(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>B(e,r,n),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]},{parent:!0}),e.with=e.check,e.clone=(r,n)=>le(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.apply=r=>r(e)}),Ft=l("ZodMiniString",(e,t)=>{Ge.init(e,t),Z.init(e,t)});function A(e){return rt(Ft,e)}var Ht=l("ZodMiniNumber",(e,t)=>{We.init(e,t),Z.init(e,t)});function me(e){return nt(Ht,e)}var Ut=l("ZodMiniBoolean",(e,t)=>{Je.init(e,t),Z.init(e,t)});function E(e){return ot(Ut,e)}var Vt=l("ZodMiniArray",(e,t)=>{Ye.init(e,t),Z.init(e,t)});function he(e,t){return new Vt({type:"array",element:e,...b(t)})}var Bt=l("ZodMiniObject",(e,t)=>{qe.init(e,t),Z.init(e,t),P(e,"shape",()=>t.shape)});function _e(e,t){let r={type:"object",shape:e??{},...b(t)};return new Bt(r)}var Kt=l("ZodMiniEnum",(e,t)=>{Xe.init(e,t),Z.init(e,t),e.options=Object.values(t.entries)});function st(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new Kt({type:"enum",entries:r,...b(t)})}var Gt=l("ZodMiniOptional",(e,t)=>{Qe.init(e,t),Z.init(e,t)});function x(e){return new Gt({type:"optional",innerType:e})}var Wt=l("ZodMiniDefault",(e,t)=>{et.init(e,t),Z.init(e,t)});function M(e,t){return new Wt({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():ae(t)}})}var Jt=l("ZodMiniCustom",(e,t)=>{tt.init(e,t),Z.init(e,t)});function ge(e,t){return it(Jt,e??(()=>!0),t)}var ee="https://in.dev.heycatch.ai",R="dev",O="0.8.0-dev.1460",ct="phc_CqKdgm7xbFBs3mSdtqzrHNTfzTRKrwRmCrEB9aftENY9";function ut(e=R){return e!=="dev"?null:`[HeyCatch] WARNING: this is an internal development build (v${O}). Events are being sent to the HeyCatch development environment and will NEVER appear in your dashboard. Reinstall the latest stable version - resolve it with \`npm view @heycatch/sdk version\` - or re-run the install guide: https://heycatch.ai/agents.md`}var N="unknown",Qt=["localStorage","cookie","memory","localStorage+cookie","sessionStorage"];var at=_e({projectKey:A({error:'config.projectKey is missing or malformed \u2014 expected a string starting with "hck_pk_". Copy it from your project page in the HeyCatch dashboard.'}).check(de(/^hck_pk_/,{error:'config.projectKey is missing or malformed \u2014 expected a string starting with "hck_pk_". Copy it from your project page in the HeyCatch dashboard.'})),tracingHosts:M(he(A()),[]),install:M(_e({framework:M(A(),N),frameworkVersion:M(A(),N),agent:M(A(),N)}),{framework:N,frameworkVersion:N,agent:N}),autocapture:x(E()),maskAllText:x(E()),maskAllElementAttributes:x(E()),propertyDenylist:x(he(A())),sanitizeProperties:x(ge(e=>typeof e=="function")),beforeSend:x(ge(e=>typeof e=="function"||Array.isArray(e)&&e.every(t=>typeof t=="function"))),persistence:x(st(Qt)),disablePersistence:x(E()),cookieExpirationDays:x(me()),optOutCapturingByDefault:x(E()),respectDnt:x(E()),requestBatching:x(E()),flushIntervalMs:x(me())});var er=5e3,tr=60,rr=1e3,nr=60,or=new Set(["$set"]),xe="heycatch_volume_cap_reached",lt=3,ir=6e4;function te({bucket:e,perMinute:t,now:r}){if(e===void 0)return t;let n=Math.max(0,r-e.at);return Math.min(t,e.tokens+n*t/ir)}function sr(e){return e===void 0||e.length===0?!1:ye(cr(e))}function cr(e){if(e.startsWith("[")){let r=e.indexOf("]");return r===-1?e:e.slice(0,r+1)}let t=e.indexOf(":");return t!==-1&&t===e.lastIndexOf(":")?e.slice(0,t):e}function pt(e){let{$session_id:t,$host:r}=e.properties;return{sessionId:typeof t=="string"?t:"",host:typeof r=="string"?r:void 0}}var dt=4;function ft(e){if(e!==void 0)return typeof e=="object"&&e!==null&&"tokens"in e&&typeof e.tokens=="number"&&Number.isFinite(e.tokens)&&e.tokens>=0&&"at"in e&&typeof e.at=="number"&&Number.isFinite(e.at)?{tokens:e.tokens,at:e.at}:!1}function ur(e){if(typeof e=="object"&&e!==null&&"sessionId"in e&&typeof e.sessionId=="string"&&"count"in e&&typeof e.count=="number"&&Number.isInteger(e.count)&&e.count>=0&&"markerAttempts"in e&&typeof e.markerAttempts=="number"&&Number.isInteger(e.markerAttempts)&&e.markerAttempts>=0){let t=ft("person"in e?e.person:void 0),r=ft("localhost"in e?e.localhost:void 0);if(t!==!1&&r!==!1)return{sessionId:e.sessionId,count:e.count,markerAttempts:e.markerAttempts,person:t,localhost:r}}return null}function ar(e){if(e===null)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t.flatMap(r=>{let n=ur(r);return n===null?[]:[n]}).slice(0,dt)}catch{}return[]}function mt({store:e,warn:t,emitMarker:r,cap:n=er,personUpdateBudget:o=tr,localhostFreeEvents:s=rr,localhostRatePerMinute:i=nr,now:c=Date.now}){let u=[],a=!1,p=!1,h=!1,d=!1;function g(){if(e===void 0||a)return u;try{return ar(e.read())}catch{return u}}function v(m){let w=g().filter(f=>f.sessionId!==m.sessionId);u=[m,...w].slice(0,dt);try{e?.write(JSON.stringify(u))}catch{a=!0}}function G(m){let w=g().find(_=>_.sessionId===m),f=u.find(_=>_.sessionId===m),y=[w,f].filter(_=>_!==void 0),W=c();function L(_,D){let C;for(let{[_]:S}of y)S!==void 0&&te({bucket:S,perMinute:D,now:W})<te({bucket:C,perMinute:D,now:W})&&(C=S);return C}return{sessionId:m,count:Math.max(0,...y.map(_=>_.count)),markerAttempts:Math.max(0,...y.map(_=>_.markerAttempts)),person:L("person",o),localhost:L("localhost",i)}}function j(m,w){let f=w,y=c(),{sessionId:W,host:L}=pt(m);f.person!==void 0&&f.person.at>y&&(f={...f,person:{...f.person,at:y}},v(f)),f.localhost!==void 0&&f.localhost.at>y&&(f={...f,localhost:{...f.localhost,at:y}},v(f));let _=or.has(m.event),D=_?te({bucket:f.person,perMinute:o,now:y}):0;if(_&&D<1)return h||(h=!0,t(`[HeyCatch] setPersonProperties is being called more than ${o} times a minute - call it when a property changes, not on every render. Dropping the extra updates for now; other events are unaffected.`)),null;let C=f.count>=s&&sr(L),S=C?te({bucket:f.localhost,perMinute:i,now:y}):0;return C&&S<1?(d||(d=!0,t(`[HeyCatch] this local dev session (${L??"unknown host"}, session ${W||"unknown"}) sent ${s} events - throttling it to ${i} a minute so a dev loop cannot flood your analytics. Production traffic is unaffected.`)),null):(v({...f,count:f.count+1,..._?{person:{tokens:D-1,at:y}}:{},...C?{localhost:{tokens:S-1,at:y}}:{}}),m)}return m=>{if(m===null||m.event===xe)return m;let{sessionId:w}=pt(m),f=G(w);return f.count<n?j(m,f):(p||(p=!0,t(`[HeyCatch] this session sent ${n} events, the per-session cap - dropping the rest until a new session starts (session ${w||"unknown"}). A tracking call inside a render loop or an effect is the usual cause.`)),f.markerAttempts<lt&&(v({...f,markerAttempts:lt}),r({cap:n,sessionId:w})||v({...f,markerAttempts:f.markerAttempts+1})),null)}}function ht(e){let t=mt({warn:r=>{console.warn(r)},emitMarker:({cap:r})=>{let n=e();return n?.capture(xe,{heycatch_session_event_cap:r}),n!==null}});return r=>r===null||t({event:r.event,properties:r.properties??{}})===null?null:r}var re=null;function z(){return re}var ve=null;function _t(){ve?.()}function gt(e){if(re!==null)return;let t=at.safeParse(e);if(!t.success){let i=t.error.issues[0]?.message??"init() requires a config object with { projectKey }.";console.error(`[HeyCatch] ${i}`);return}let r=new lr(ct,{host:ee,preloadFeatureFlags:!1,disableRemoteFeatureFlags:!0,sendFeatureFlagEvent:!1,disableSurveys:!0,...t.data.optOutCapturingByDefault===void 0?{}:{defaultOptIn:!t.data.optOutCapturingByDefault},before_send:[ht(()=>re)]}),{install:n}=t.data,o={heycatch_framework:n.framework,heycatch_framework_version:n.frameworkVersion,heycatch_agent:n.agent};ve=()=>{r.register({heycatch_sdk_version:O,heycatch_sdk_stage:R,heycatch_project_key:t.data.projectKey,...o}),r.group(ze,t.data.projectKey,{key:t.data.projectKey,sdk_version:O,sdk_stage:R,framework:n.framework,framework_version:n.frameworkVersion,agent:n.agent,api_host:ee})},ve(),re=r,console.info(`[HeyCatch] SDK v${O} (${R}) initialized \u2192 ${ee}`);let s=ut();s!==null&&console.warn(s)}function xt(e){return t=>{console.error(`[HeyCatch] consent ${e} could not be saved - capture state may reset on the next app launch:`,t)}}function vt(){z()?.optIn().catch(xt("opt-in"))}function zt(){z()?.optOut().catch(xt("opt-out"))}function yt(e,t,r){let n=z();if(n!==null){if(typeof e!="string"||e.length===0){console.error("[HeyCatch] setIdentity() requires a non-empty string user id. Pass a stable internal user id from your auth provider \u2014 not an email or session token.");return}n.identify(e,{...t?{$set:t}:{},...r?{$set_once:r}:{}})}}function $t(){let e=z();e!==null&&(e.reset(),_t())}function ne(e,t){let r=z();if(r!==null){if(typeof e!="string"||e.length===0){console.error("[HeyCatch] trackScreen() requires a non-empty screen name.");return}r.screen(e,t?t:void 0)}}function bt(e,t,r){let n=z();if(n!==null){if(typeof e!="string"||e.length===0){console.error("[HeyCatch] trackEvent() requires a non-empty event name.");return}if(e.startsWith("$")){console.error(`[HeyCatch] trackEvent() event names cannot start with "$" (got "${e}") - that prefix is reserved for built-in events.`);return}n.capture(e,{...t,...r?.set?{$set:r.set}:{},...r?.setOnce?{$set_once:r.setOnce}:{},heycatch_custom_user_event:!0})}}function wt(e,t){let r=z();r!==null&&(!e&&!t||r.capture("$set",{...e?{$set:e}:{},...t?{$set_once:t}:{}}))}import{PostHogProvider as pr}from"posthog-react-native";import{useEffect as fr}from"react";import{jsx as gr,jsxs as xr}from"react/jsx-runtime";function dr(){try{if(typeof oe!="function")return null;let e=oe("expo-router");return typeof e=="object"&&e!==null&&"usePathname"in e&&typeof e.usePathname=="function"&&"useGlobalSearchParams"in e&&typeof e.useGlobalSearchParams=="function"?{usePathname:e.usePathname,useGlobalSearchParams:e.useGlobalSearchParams}:null}catch{return null}}var kt=dr();function mr(e){let t=JSON.parse(e);if(typeof t!="object"||t===null)return{};let r={};for(let[n,o]of Object.entries(t)){if(typeof o=="string"||typeof o=="number"||typeof o=="boolean"){r[n]=o;continue}Array.isArray(o)&&(r[n]=o.filter(s=>typeof s=="string").join(","))}return r}function hr({router:e}){let{useGlobalSearchParams:t,usePathname:r}=e,n=r(),o=JSON.stringify(t());return fr(()=>{ne(n,mr(o))},[n,o]),null}function _r({children:e}){let t=z();return t===null?(console.error("[HeyCatch] HeyCatchProvider mounted before init() - call analytics.init({ projectKey }) at module scope of the root layout."),e):xr(pr,{autocapture:{captureScreens:!1,captureTouches:!0},client:t,children:[kt===null?null:gr(hr,{router:kt}),e]})}var Ws={init:gt,optInCapturing:vt,optOutCapturing:zt,resetIdentity:$t,setIdentity:yt,setPersonProperties:wt,trackEvent:bt,trackScreen:ne};export{_r as HeyCatchProvider,O as SDK_VERSION,R as STAGE,Ws as analytics};
|
|
2
2
|
//# sourceMappingURL=react-native.js.map
|