@claudeye/linux-arm64 1.0.6-beta.4 → 1.0.6-beta.6

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.
Files changed (122) hide show
  1. package/assets/standalone/.next/BUILD_ID +1 -1
  2. package/assets/standalone/.next/build-manifest.json +3 -3
  3. package/assets/standalone/.next/prerender-manifest.json +3 -3
  4. package/assets/standalone/.next/server/app/_global-error.html +1 -1
  5. package/assets/standalone/.next/server/app/_global-error.rsc +1 -1
  6. package/assets/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  7. package/assets/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  8. package/assets/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  9. package/assets/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  10. package/assets/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  11. package/assets/standalone/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
  12. package/assets/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  13. package/assets/standalone/.next/server/app/_not-found.html +2 -2
  14. package/assets/standalone/.next/server/app/_not-found.rsc +17 -17
  15. package/assets/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +17 -17
  16. package/assets/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +4 -4
  17. package/assets/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +11 -11
  18. package/assets/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
  19. package/assets/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +3 -3
  20. package/assets/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  21. package/assets/standalone/.next/server/app/dashboard/[viewName]/page/server-reference-manifest.json +5 -5
  22. package/assets/standalone/.next/server/app/dashboard/[viewName]/page_client-reference-manifest.js +1 -1
  23. package/assets/standalone/.next/server/app/dashboard/page/server-reference-manifest.json +5 -5
  24. package/assets/standalone/.next/server/app/dashboard/page_client-reference-manifest.js +1 -1
  25. package/assets/standalone/.next/server/app/hooks/page/server-reference-manifest.json +56 -8
  26. package/assets/standalone/.next/server/app/hooks/page.js +3 -2
  27. package/assets/standalone/.next/server/app/hooks/page_client-reference-manifest.js +1 -1
  28. package/assets/standalone/.next/server/app/login/page/server-reference-manifest.json +3 -3
  29. package/assets/standalone/.next/server/app/login/page_client-reference-manifest.js +1 -1
  30. package/assets/standalone/.next/server/app/login.html +2 -2
  31. package/assets/standalone/.next/server/app/login.rsc +20 -20
  32. package/assets/standalone/.next/server/app/login.segments/_full.segment.rsc +20 -20
  33. package/assets/standalone/.next/server/app/login.segments/_head.segment.rsc +4 -4
  34. package/assets/standalone/.next/server/app/login.segments/_index.segment.rsc +11 -11
  35. package/assets/standalone/.next/server/app/login.segments/_tree.segment.rsc +2 -2
  36. package/assets/standalone/.next/server/app/login.segments/login/__PAGE__.segment.rsc +4 -4
  37. package/assets/standalone/.next/server/app/login.segments/login.segment.rsc +3 -3
  38. package/assets/standalone/.next/server/app/page/server-reference-manifest.json +2 -2
  39. package/assets/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  40. package/assets/standalone/.next/server/app/project/[name]/page/server-reference-manifest.json +2 -2
  41. package/assets/standalone/.next/server/app/project/[name]/page_client-reference-manifest.js +1 -1
  42. package/assets/standalone/.next/server/app/project/[name]/session/[sessionId]/page/react-loadable-manifest.json +2 -2
  43. package/assets/standalone/.next/server/app/project/[name]/session/[sessionId]/page/server-reference-manifest.json +30 -18
  44. package/assets/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js +1 -1
  45. package/assets/standalone/.next/server/app/project/[name]/session/[sessionId]/page_client-reference-manifest.js +1 -1
  46. package/assets/standalone/.next/server/app/queue/page/server-reference-manifest.json +4 -4
  47. package/assets/standalone/.next/server/app/queue/page_client-reference-manifest.js +1 -1
  48. package/assets/standalone/.next/server/chunks/[externals]__0-p9.k~._.js +3 -0
  49. package/assets/standalone/.next/server/chunks/[externals]__12dv.x0._.js +3 -0
  50. package/assets/standalone/.next/server/chunks/[root-of-the-server]__031vvrp._.js +1 -1
  51. package/assets/standalone/.next/server/chunks/[root-of-the-server]__0_03u6.._.js +2 -2
  52. package/assets/standalone/.next/server/chunks/[root-of-the-server]__0f_5ws6._.js +1 -1
  53. package/assets/standalone/.next/server/chunks/[root-of-the-server]__0g72weg._.js +1 -1
  54. package/assets/standalone/.next/server/chunks/[root-of-the-server]__0wkrejt._.js +1 -1
  55. package/assets/standalone/.next/server/chunks/_0aylu-q._.js +1 -1
  56. package/assets/standalone/.next/server/chunks/_0lq2_wn._.js +1 -1
  57. package/assets/standalone/.next/server/chunks/_0oqawqx._.js +2 -2
  58. package/assets/standalone/.next/server/chunks/_0vt409y._.js +1 -1
  59. package/assets/standalone/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_0l15kkr.js +1 -1
  60. package/assets/standalone/.next/server/chunks/node_modules_posthog-node_dist_entrypoints_index_node_mjs_00~~2w9._.js +1 -1
  61. package/assets/standalone/.next/server/chunks/node_modules_posthog-node_dist_entrypoints_index_node_mjs_05pz9._._.js +1 -1
  62. package/assets/standalone/.next/server/chunks/package_json_[json]_cjs_0z7w.hh._.js +1 -1
  63. package/assets/standalone/.next/server/chunks/ssr/[externals]__12dv.x0._.js +3 -0
  64. package/assets/standalone/.next/server/chunks/ssr/[externals]_node_async_hooks_0v0ln8c._.js +3 -0
  65. package/assets/standalone/.next/server/chunks/ssr/[root-of-the-server]__00fve8g._.js +36 -0
  66. package/assets/standalone/.next/server/chunks/ssr/[root-of-the-server]__02x4-91._.js +1 -1
  67. package/assets/standalone/.next/server/chunks/ssr/[root-of-the-server]__06tqxbp._.js +1 -1
  68. package/assets/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0idy2kl._.js → [root-of-the-server]__08a4wva._.js} +2 -2
  69. package/assets/standalone/.next/server/chunks/ssr/[root-of-the-server]__0dsucx_._.js +1 -1
  70. package/assets/standalone/.next/server/chunks/ssr/[root-of-the-server]__0e9ohz2._.js +1 -1
  71. package/assets/standalone/.next/server/chunks/ssr/[root-of-the-server]__0fltiz1._.js +1 -1
  72. package/assets/standalone/.next/server/chunks/ssr/[root-of-the-server]__0ni-as.._.js +1 -1
  73. package/assets/standalone/.next/server/chunks/ssr/[root-of-the-server]__0tsew7c._.js +4 -0
  74. package/assets/standalone/.next/server/chunks/ssr/[root-of-the-server]__0x5abxa._.js +1 -1
  75. package/assets/standalone/.next/server/chunks/ssr/[root-of-the-server]__0yi-883._.js +4 -0
  76. package/assets/standalone/.next/server/chunks/ssr/[root-of-the-server]__10_wjge._.js +1 -1
  77. package/assets/standalone/.next/server/chunks/ssr/_03l0_j6._.js +1 -1
  78. package/assets/standalone/.next/server/chunks/ssr/_050qnuh._.js +1 -1
  79. package/assets/standalone/.next/server/chunks/ssr/_0_~1-jh._.js +1 -1
  80. package/assets/standalone/.next/server/chunks/ssr/_0kfjwwu._.js +1 -1
  81. package/assets/standalone/.next/server/chunks/ssr/_0ndt7tj._.js +1 -1
  82. package/assets/standalone/.next/server/chunks/ssr/_0uig1kl._.js +1 -1
  83. package/assets/standalone/.next/server/chunks/ssr/app_actions_compute-dashboard_ts_13cb_9d._.js +1 -1
  84. package/assets/standalone/.next/server/chunks/ssr/app_hooks_hooks-client_tsx_0n~.yoz._.js +1 -1
  85. package/assets/standalone/.next/server/chunks/ssr/app_login_page_tsx_0z71ad3._.js +1 -1
  86. package/assets/standalone/.next/server/chunks/ssr/app_queue_queue-client_tsx_0c0olxv._.js +1 -1
  87. package/assets/standalone/.next/server/chunks/ssr/node_modules_posthog-node_dist_entrypoints_index_node_mjs_0mebn66._.js +1 -1
  88. package/assets/standalone/.next/server/middleware-build-manifest.js +3 -3
  89. package/assets/standalone/.next/server/pages/404.html +2 -2
  90. package/assets/standalone/.next/server/pages/500.html +1 -1
  91. package/assets/standalone/.next/server/server-reference-manifest.js +1 -1
  92. package/assets/standalone/.next/server/server-reference-manifest.json +85 -31
  93. package/assets/standalone/.next/static/chunks/05l6_6jd1ey6v.js +1 -0
  94. package/assets/standalone/.next/static/chunks/{11nb_~r_eojyk.js → 083938s.mkrm-.js} +1 -1
  95. package/assets/standalone/.next/static/chunks/{0s_luev559g4b.js → 096~89k5h2-o..js} +3 -3
  96. package/assets/standalone/.next/static/chunks/0_f5xq5lhf8-0.js +1 -0
  97. package/assets/standalone/.next/static/chunks/{0oemft0-s7nqv.js → 0h6039djg7yn~.js} +2 -2
  98. package/assets/standalone/.next/static/chunks/0hg.grz.-b6wv.js +1 -0
  99. package/assets/standalone/.next/static/chunks/{0p1vxt.2i3k6h.js → 0hmgtlt-1s-_z.js} +1 -1
  100. package/assets/standalone/.next/static/chunks/0j1-mgai_b50s.css +1 -0
  101. package/assets/standalone/.next/static/chunks/0ljjv.c03-d.y.js +1 -0
  102. package/assets/standalone/.next/static/chunks/0vyjtt~0eaw3_.js +1 -0
  103. package/assets/standalone/.next/static/chunks/15gen854~c206.js +1 -0
  104. package/assets/standalone/README.md +4 -2
  105. package/assets/standalone/package.json +1 -1
  106. package/bin/claudeye +0 -0
  107. package/package.json +1 -1
  108. package/assets/standalone/.next/server/chunks/[externals]__0-18y4s._.js +0 -3
  109. package/assets/standalone/.next/server/chunks/[externals]__02vhdx5._.js +0 -3
  110. package/assets/standalone/.next/server/chunks/ssr/[externals]__02vhdx5._.js +0 -3
  111. package/assets/standalone/.next/server/chunks/ssr/[root-of-the-server]__00r7mh3._.js +0 -4
  112. package/assets/standalone/.next/server/chunks/ssr/[root-of-the-server]__0fiobs_._.js +0 -4
  113. package/assets/standalone/.next/static/chunks/08-m031knjk.2.js +0 -1
  114. package/assets/standalone/.next/static/chunks/0d~lou4l3p2.g.css +0 -1
  115. package/assets/standalone/.next/static/chunks/0q8v-t~3ny9co.js +0 -1
  116. package/assets/standalone/.next/static/chunks/0tyqntivqkiwt.js +0 -1
  117. package/assets/standalone/.next/static/chunks/11pull0n1ziko.js +0 -1
  118. package/assets/standalone/.next/static/chunks/11s--zoqx20-r.js +0 -1
  119. package/assets/standalone/.next/static/chunks/15n7f_2h_nvad.js +0 -1
  120. /package/assets/standalone/.next/static/{B9luWx1Z31ygILxMA8k6o → OCXqJ711WVPVfYYr2iQc0}/_buildManifest.js +0 -0
  121. /package/assets/standalone/.next/static/{B9luWx1Z31ygILxMA8k6o → OCXqJ711WVPVfYYr2iQc0}/_clientMiddlewareManifest.js +0 -0
  122. /package/assets/standalone/.next/static/{B9luWx1Z31ygILxMA8k6o → OCXqJ711WVPVfYYr2iQc0}/_ssgManifest.js +0 -0
@@ -1,3 +1,3 @@
1
- module.exports=[57730,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(38246),e=a.i(210),f=a.i(70106);let g=(0,f.default)("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),h=(0,f.default)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);var i=a.i(69520),j=a.i(65967),k=a.i(5050);let l=(0,k.createServerReference)("4065f8732e9f272012c28e8c9a15ccb3998a3c9804",k.callServer,void 0,k.findSourceMapURL,"getCompletedHistoryAction"),m=(0,k.createServerReference)("60ec55b74018ebec91b801c4822c9e7922a7a163a0",k.callServer,void 0,k.findSourceMapURL,"searchCompletedHistoryAction");var n=a.i(6236),o=a.i(90619),p=a.i(95947);function q(a){let b=Math.floor((Date.now()-a)/1e3);if(b<60)return`${b}s ago`;let c=Math.floor(b/60);if(c<60)return`${c}m ago`;let d=Math.floor(c/60);return`${d}h ago`}function r({type:a}){let c="eval"===a?"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400":"action"===a?"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400":"bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-400";return(0,b.jsx)("span",{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[0.6rem] font-medium ${c}`,children:a.toUpperCase()})}function s({priority:a}){let c=a<=0;return(0,b.jsx)("span",{className:`text-[0.6rem] font-medium px-1.5 py-0.5 rounded ${c?"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400":"bg-muted text-muted-foreground"}`,children:c?"HIGH":"LOW"})}function t({projectName:a,sessionId:c}){return(0,b.jsx)(d.default,{href:`/project/${encodeURIComponent(a)}/session/${encodeURIComponent(c)}`,className:"text-blue-600 dark:text-blue-400 hover:underline truncate block max-w-[200px]",children:c})}a.s(["default",0,function(){let a,f,{intervalSec:k}=(0,n.useAutoRefresh)(),u=(0,o.useUrlParams)(),v=(0,c.useRef)(!1),[w,x]=(0,c.useState)(null),[y,z]=(0,c.useState)(null),[A,B]=(0,c.useState)(()=>{let a=u.get("tab");return"pending"===a||"processing"===a||"completed"===a?a:"processing"}),[C,D]=(0,c.useState)(()=>(0,p.paramToPage)(u.get("page"))),[E,F]=(0,c.useState)(null),G=(0,c.useRef)(A),[H,I]=(0,c.useState)(()=>{let a=u.get("type");return"eval"===a||"enrichment"===a||"action"===a?a:""}),[J,K]=(0,c.useState)(()=>u.get("item")??""),[L,M]=(0,c.useState)(()=>u.get("session")??""),N=(0,c.useRef)(null),O=(0,c.useRef)({filterType:H,filterItem:J,filterSession:L});O.current={filterType:H,filterItem:J,filterSession:L},(0,c.useEffect)(()=>{if(!v.current){v.current=!0;return}u.setAll({tab:"processing"===A?void 0:A,type:H||void 0,item:J||void 0,session:L||void 0,page:"completed"===A?(0,p.pageToParam)(C):void 0})},[A,H,J,L,C]);let P=(0,c.useCallback)(async()=>{try{let a=await fetch("/api/queue-status",{cache:"no-store"});if(a.ok){let b=await a.json();x(b),z(null)}else z(`Failed to fetch: ${a.status}`)}catch{z("Network error")}},[]),Q=(0,c.useCallback)(async a=>{try{let b,{filterType:c,filterItem:d,filterSession:e}=O.current;b=""!==c||""!==d||""!==e?await m({type:c||void 0,itemName:d||void 0,sessionId:e||void 0},a):await l(a),F(b)}catch{}},[]);(0,c.useEffect)(()=>{P();let a=setInterval(P,k>0?1e3*k:5e3);return()=>clearInterval(a)},[P,k]),(0,c.useEffect)(()=>{"completed"===A&&"completed"!==G.current&&(D(1),Q(1)),G.current=A},[A,Q]),(0,c.useEffect)(()=>{if("completed"===A)return N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{D(1),Q(1)},300),()=>{N.current&&clearTimeout(N.current)}},[H,J,L]),(0,c.useEffect)(()=>{if("completed"!==A)return;Q(C);let a=setInterval(()=>Q(C),k>0?1e3*k:5e3);return()=>clearInterval(a)},[C,A,Q,k]),(0,c.useEffect)(()=>{"completed"===A&&k>0&&1===C&&E&&0===E.entries.length&&E.totalPages>1&&D(2)},[A,k,C,E]);let R=[{key:"pending",label:"In Queue",count:w?.pending.length??0},{key:"processing",label:"Processing",count:w?.processing.length??0},{key:"completed",label:"Processed"}];return(0,b.jsxs)("div",{className:"min-h-screen bg-background p-6 max-w-4xl mx-auto",children:[(0,b.jsxs)("div",{className:"mb-6",children:[(0,b.jsxs)(d.default,{href:"/",className:"inline-flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[(0,b.jsx)(e.ArrowLeft,{className:"h-4 w-4"}),"Back"]}),(0,b.jsx)("h1",{className:"text-2xl font-bold text-foreground mt-2",children:"Queue Details"})]}),y&&!w&&(0,b.jsxs)("div",{className:"bg-card border border-border rounded-lg p-4 text-center",children:[(0,b.jsx)("p",{className:"text-sm text-destructive mb-2",children:y}),(0,b.jsx)("button",{onClick:P,className:"text-xs text-primary hover:underline",children:"Retry"})]}),!w&&!y&&(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:"Loading..."}),w&&(0,b.jsxs)("div",{className:"space-y-4",children:[(0,b.jsx)("div",{className:"flex gap-1 border-b border-border",children:R.map(a=>(0,b.jsxs)("button",{onClick:()=>B(a.key),className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${A===a.key?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[a.label,null!=a.count&&(0,b.jsxs)("span",{className:"ml-1.5 text-xs text-muted-foreground",children:["(",a.count,")"]})]},a.key))}),(0,b.jsxs)("div",{className:"bg-card border border-border rounded-lg overflow-hidden",children:["pending"===A&&(0===w.pending.length?(0,b.jsx)("p",{className:"px-4 py-8 text-xs text-muted-foreground text-center",children:"No items in queue."}):(0,b.jsx)("div",{className:"overflow-x-auto",children:(0,b.jsxs)("table",{className:"w-full text-xs",children:[(0,b.jsx)("thead",{children:(0,b.jsxs)("tr",{className:"text-left text-muted-foreground border-b border-border bg-muted/30",children:[(0,b.jsx)("th",{className:"px-3 py-2 font-medium",children:"Type"}),(0,b.jsx)("th",{className:"px-3 py-2 font-medium",children:"Item"}),(0,b.jsx)("th",{className:"px-3 py-2 font-medium",children:"Session"}),(0,b.jsx)("th",{className:"px-3 py-2 font-medium",children:"Priority"}),(0,b.jsx)("th",{className:"px-3 py-2 font-medium text-right",children:"Queued"})]})}),(0,b.jsx)("tbody",{className:"divide-y divide-border/50",children:w.pending.map(a=>(0,b.jsxs)("tr",{className:"hover:bg-muted/20",children:[(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(r,{type:a.type})}),(0,b.jsx)("td",{className:"px-3 py-2 font-mono text-foreground",children:a.itemName}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(t,{projectName:a.projectName,sessionId:a.sessionId})}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(s,{priority:a.priority})}),(0,b.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:q(a.addedAt)})]},a.key))})]})})),"processing"===A&&(0===w.processing.length?(0,b.jsx)("p",{className:"px-4 py-8 text-xs text-muted-foreground text-center",children:"No items currently processing."}):(0,b.jsx)("div",{className:"overflow-x-auto",children:(0,b.jsxs)("table",{className:"w-full text-xs",children:[(0,b.jsx)("thead",{children:(0,b.jsxs)("tr",{className:"text-left text-muted-foreground border-b border-border bg-muted/30",children:[(0,b.jsx)("th",{className:"px-3 py-2 font-medium",children:"Type"}),(0,b.jsx)("th",{className:"px-3 py-2 font-medium",children:"Item"}),(0,b.jsx)("th",{className:"px-3 py-2 font-medium",children:"Session"}),(0,b.jsx)("th",{className:"px-3 py-2 font-medium",children:"Priority"}),(0,b.jsx)("th",{className:"px-3 py-2 font-medium text-right",children:"Started"})]})}),(0,b.jsx)("tbody",{className:"divide-y divide-border/50",children:w.processing.map(a=>(0,b.jsxs)("tr",{className:"hover:bg-muted/20",children:[(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(r,{type:a.type})}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,b.jsx)(i.RefreshCw,{className:"w-3 h-3 text-blue-500 animate-spin flex-shrink-0"}),(0,b.jsx)("span",{className:"font-mono text-foreground",children:a.itemName})]})}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(t,{projectName:a.projectName,sessionId:a.sessionId})}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(s,{priority:a.priority})}),(0,b.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:q(a.startedAt)})]},a.key))})]})})),"completed"===A&&(a=E?.entries??w.completed,f=E?.totalPages??1,(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border bg-muted/30",children:[(0,b.jsxs)("select",{value:H,onChange:a=>I(a.target.value),className:"h-7 rounded border border-border bg-background px-2 text-xs text-foreground",children:[(0,b.jsx)("option",{value:"",children:"All Types"}),(0,b.jsx)("option",{value:"eval",children:"Eval"}),(0,b.jsx)("option",{value:"enrichment",children:"Enrichment"}),(0,b.jsx)("option",{value:"action",children:"Action"})]}),(0,b.jsx)("input",{type:"text",value:J,onChange:a=>K(a.target.value),placeholder:"Filter by item...",className:"h-7 rounded border border-border bg-background px-2 text-xs text-foreground placeholder:text-muted-foreground w-40"}),(0,b.jsx)("input",{type:"text",value:L,onChange:a=>M(a.target.value),placeholder:"Filter by session...",className:"h-7 rounded border border-border bg-background px-2 text-xs text-foreground placeholder:text-muted-foreground w-40"})]}),0===a.length?(0,b.jsx)("p",{className:"px-4 py-8 text-xs text-muted-foreground text-center",children:"No completed items."}):(0,b.jsx)("div",{className:"overflow-x-auto",children:(0,b.jsxs)("table",{className:"w-full text-xs",children:[(0,b.jsx)("thead",{children:(0,b.jsxs)("tr",{className:"text-left text-muted-foreground border-b border-border bg-muted/30",children:[(0,b.jsx)("th",{className:"px-3 py-2 font-medium",children:"Type"}),(0,b.jsx)("th",{className:"px-3 py-2 font-medium",children:"Item"}),(0,b.jsx)("th",{className:"px-3 py-2 font-medium",children:"Session"}),(0,b.jsx)("th",{className:"px-3 py-2 font-medium",children:"Duration"}),(0,b.jsx)("th",{className:"px-3 py-2 font-medium",children:"Status"}),(0,b.jsx)("th",{className:"px-3 py-2 font-medium text-right",children:"Completed"})]})}),(0,b.jsx)("tbody",{className:"divide-y divide-border/50",children:a.map((a,c)=>(0,b.jsxs)("tr",{className:"hover:bg-muted/20",children:[(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(r,{type:a.type})}),(0,b.jsx)("td",{className:"px-3 py-2 font-mono text-foreground",children:a.itemName}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(t,{projectName:a.projectName,sessionId:a.sessionId})}),(0,b.jsx)("td",{className:"px-3 py-2 text-muted-foreground",children:function(a){if(a<1e3)return`${a}ms`;let b=(a/1e3).toFixed(1);return`${b}s`}(a.durationMs)}),(0,b.jsx)("td",{className:"px-3 py-2",children:a.success?(0,b.jsx)(g,{className:"h-3.5 w-3.5 text-green-600 dark:text-green-400"}):(0,b.jsx)(h,{className:"h-3.5 w-3.5 text-red-600 dark:text-red-400"})}),(0,b.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:new Date(a.completedAt).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})})]},`${a.key}-${a.completedAt}-${c}`))})]})}),(0,b.jsx)(j.default,{currentPage:C,totalPages:f,onPageChange:D})]}))]}),w.recentErrors.length>0&&(0,b.jsxs)("section",{className:"bg-card border border-border rounded-lg p-4",children:[(0,b.jsxs)("h2",{className:"text-sm font-semibold text-foreground mb-2",children:["Recent Errors",(0,b.jsxs)("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:["(",w.recentErrors.length,")"]})]}),(0,b.jsx)("div",{className:"space-y-1",children:w.recentErrors.map((a,c)=>(0,b.jsxs)("div",{className:"text-xs bg-muted/30 rounded px-2 py-1 flex items-start gap-2",children:[(0,b.jsx)("span",{className:"font-mono text-muted-foreground shrink-0",children:a.key}),(0,b.jsx)("span",{className:"text-red-500 break-all",children:a.error}),(0,b.jsx)("span",{className:"text-muted-foreground shrink-0 ml-auto",children:q(a.at)})]},`${a.key}-${a.at}-${c}`))})]})]})]})}],57730)}];
1
+ module.exports=[57730,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(38246),e=a.i(210),f=a.i(70106);let g=(0,f.default)("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),h=(0,f.default)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);var i=a.i(69520),j=a.i(65967),k=a.i(5050);let l=(0,k.createServerReference)("4009fb6b59c6b03388bf0f3f4dbcc9e4707ebc567d",k.callServer,void 0,k.findSourceMapURL,"getCompletedHistoryAction"),m=(0,k.createServerReference)("60e1175b81d180c1e6feb795d20f5db8fbcfc436a0",k.callServer,void 0,k.findSourceMapURL,"searchCompletedHistoryAction");var n=a.i(6236),o=a.i(90619),p=a.i(95947);function q(a){let b=Math.floor((Date.now()-a)/1e3);if(b<60)return`${b}s ago`;let c=Math.floor(b/60);if(c<60)return`${c}m ago`;let d=Math.floor(c/60);return`${d}h ago`}function r({type:a}){let c="eval"===a?"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400":"action"===a?"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400":"bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-400";return(0,b.jsx)("span",{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[0.6rem] font-medium ${c}`,children:a.toUpperCase()})}function s({priority:a}){let c=a<=0;return(0,b.jsx)("span",{className:`text-[0.6rem] font-medium px-1.5 py-0.5 rounded ${c?"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400":"bg-muted text-muted-foreground"}`,children:c?"HIGH":"LOW"})}function t({projectName:a,sessionId:c}){return(0,b.jsx)(d.default,{href:`/project/${encodeURIComponent(a)}/session/${encodeURIComponent(c)}`,className:"text-blue-600 dark:text-blue-400 hover:underline truncate block max-w-[200px]",children:c})}a.s(["default",0,function(){let a,f,{intervalSec:k}=(0,n.useAutoRefresh)(),u=(0,o.useUrlParams)(),v=(0,c.useRef)(!1),[w,x]=(0,c.useState)(null),[y,z]=(0,c.useState)(null),[A,B]=(0,c.useState)(()=>{let a=u.get("tab");return"pending"===a||"processing"===a||"completed"===a?a:"processing"}),[C,D]=(0,c.useState)(()=>(0,p.paramToPage)(u.get("page"))),[E,F]=(0,c.useState)(null),G=(0,c.useRef)(A),[H,I]=(0,c.useState)(()=>{let a=u.get("type");return"eval"===a||"enrichment"===a||"action"===a?a:""}),[J,K]=(0,c.useState)(()=>u.get("item")??""),[L,M]=(0,c.useState)(()=>u.get("session")??""),N=(0,c.useRef)(null),O=(0,c.useRef)({filterType:H,filterItem:J,filterSession:L});O.current={filterType:H,filterItem:J,filterSession:L},(0,c.useEffect)(()=>{if(!v.current){v.current=!0;return}u.setAll({tab:"processing"===A?void 0:A,type:H||void 0,item:J||void 0,session:L||void 0,page:"completed"===A?(0,p.pageToParam)(C):void 0})},[A,H,J,L,C]);let P=(0,c.useCallback)(async()=>{try{let a=await fetch("/api/queue-status",{cache:"no-store"});if(a.ok){let b=await a.json();x(b),z(null)}else z(`Failed to fetch: ${a.status}`)}catch{z("Network error")}},[]),Q=(0,c.useCallback)(async a=>{try{let b,{filterType:c,filterItem:d,filterSession:e}=O.current;b=""!==c||""!==d||""!==e?await m({type:c||void 0,itemName:d||void 0,sessionId:e||void 0},a):await l(a),F(b)}catch{}},[]);(0,c.useEffect)(()=>{P();let a=setInterval(P,k>0?1e3*k:5e3);return()=>clearInterval(a)},[P,k]),(0,c.useEffect)(()=>{"completed"===A&&"completed"!==G.current&&(D(1),Q(1)),G.current=A},[A,Q]),(0,c.useEffect)(()=>{if("completed"===A)return N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{D(1),Q(1)},300),()=>{N.current&&clearTimeout(N.current)}},[H,J,L]),(0,c.useEffect)(()=>{if("completed"!==A)return;Q(C);let a=setInterval(()=>Q(C),k>0?1e3*k:5e3);return()=>clearInterval(a)},[C,A,Q,k]),(0,c.useEffect)(()=>{"completed"===A&&k>0&&1===C&&E&&0===E.entries.length&&E.totalPages>1&&D(2)},[A,k,C,E]);let R=[{key:"pending",label:"In Queue",count:w?.pending.length??0},{key:"processing",label:"Processing",count:w?.processing.length??0},{key:"completed",label:"Processed"}];return(0,b.jsxs)("div",{className:"min-h-screen bg-background p-6 max-w-4xl mx-auto",children:[(0,b.jsxs)("div",{className:"mb-6",children:[(0,b.jsxs)(d.default,{href:"/",className:"inline-flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[(0,b.jsx)(e.ArrowLeft,{className:"h-4 w-4"}),"Back"]}),(0,b.jsx)("h1",{className:"text-2xl font-bold text-foreground mt-2",children:"Queue Details"})]}),y&&!w&&(0,b.jsxs)("div",{className:"bg-card border border-border rounded-lg p-4 text-center",children:[(0,b.jsx)("p",{className:"text-sm text-destructive mb-2",children:y}),(0,b.jsx)("button",{onClick:P,className:"text-xs text-primary hover:underline",children:"Retry"})]}),!w&&!y&&(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:"Loading..."}),w&&(0,b.jsxs)("div",{className:"space-y-4",children:[(0,b.jsx)("div",{className:"flex gap-1 border-b border-border",children:R.map(a=>(0,b.jsxs)("button",{onClick:()=>B(a.key),className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${A===a.key?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[a.label,null!=a.count&&(0,b.jsxs)("span",{className:"ml-1.5 text-xs text-muted-foreground",children:["(",a.count,")"]})]},a.key))}),(0,b.jsxs)("div",{className:"bg-card border border-border rounded-lg overflow-hidden",children:["pending"===A&&(0===w.pending.length?(0,b.jsx)("p",{className:"px-4 py-8 text-xs text-muted-foreground text-center",children:"No items in queue."}):(0,b.jsx)("div",{className:"overflow-x-auto",children:(0,b.jsxs)("table",{className:"w-full text-xs",children:[(0,b.jsx)("thead",{children:(0,b.jsxs)("tr",{className:"text-left text-muted-foreground border-b border-border bg-muted/30",children:[(0,b.jsx)("th",{className:"px-3 py-2 font-medium",children:"Type"}),(0,b.jsx)("th",{className:"px-3 py-2 font-medium",children:"Item"}),(0,b.jsx)("th",{className:"px-3 py-2 font-medium",children:"Session"}),(0,b.jsx)("th",{className:"px-3 py-2 font-medium",children:"Priority"}),(0,b.jsx)("th",{className:"px-3 py-2 font-medium text-right",children:"Queued"})]})}),(0,b.jsx)("tbody",{className:"divide-y divide-border/50",children:w.pending.map(a=>(0,b.jsxs)("tr",{className:"hover:bg-muted/20",children:[(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(r,{type:a.type})}),(0,b.jsx)("td",{className:"px-3 py-2 font-mono text-foreground",children:a.itemName}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(t,{projectName:a.projectName,sessionId:a.sessionId})}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(s,{priority:a.priority})}),(0,b.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:q(a.addedAt)})]},a.key))})]})})),"processing"===A&&(0===w.processing.length?(0,b.jsx)("p",{className:"px-4 py-8 text-xs text-muted-foreground text-center",children:"No items currently processing."}):(0,b.jsx)("div",{className:"overflow-x-auto",children:(0,b.jsxs)("table",{className:"w-full text-xs",children:[(0,b.jsx)("thead",{children:(0,b.jsxs)("tr",{className:"text-left text-muted-foreground border-b border-border bg-muted/30",children:[(0,b.jsx)("th",{className:"px-3 py-2 font-medium",children:"Type"}),(0,b.jsx)("th",{className:"px-3 py-2 font-medium",children:"Item"}),(0,b.jsx)("th",{className:"px-3 py-2 font-medium",children:"Session"}),(0,b.jsx)("th",{className:"px-3 py-2 font-medium",children:"Priority"}),(0,b.jsx)("th",{className:"px-3 py-2 font-medium text-right",children:"Started"})]})}),(0,b.jsx)("tbody",{className:"divide-y divide-border/50",children:w.processing.map(a=>(0,b.jsxs)("tr",{className:"hover:bg-muted/20",children:[(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(r,{type:a.type})}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,b.jsx)(i.RefreshCw,{className:"w-3 h-3 text-blue-500 animate-spin flex-shrink-0"}),(0,b.jsx)("span",{className:"font-mono text-foreground",children:a.itemName})]})}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(t,{projectName:a.projectName,sessionId:a.sessionId})}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(s,{priority:a.priority})}),(0,b.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:q(a.startedAt)})]},a.key))})]})})),"completed"===A&&(a=E?.entries??w.completed,f=E?.totalPages??1,(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border bg-muted/30",children:[(0,b.jsxs)("select",{value:H,onChange:a=>I(a.target.value),className:"h-7 rounded border border-border bg-background px-2 text-xs text-foreground",children:[(0,b.jsx)("option",{value:"",children:"All Types"}),(0,b.jsx)("option",{value:"eval",children:"Eval"}),(0,b.jsx)("option",{value:"enrichment",children:"Enrichment"}),(0,b.jsx)("option",{value:"action",children:"Action"})]}),(0,b.jsx)("input",{type:"text",value:J,onChange:a=>K(a.target.value),placeholder:"Filter by item...",className:"h-7 rounded border border-border bg-background px-2 text-xs text-foreground placeholder:text-muted-foreground w-40"}),(0,b.jsx)("input",{type:"text",value:L,onChange:a=>M(a.target.value),placeholder:"Filter by session...",className:"h-7 rounded border border-border bg-background px-2 text-xs text-foreground placeholder:text-muted-foreground w-40"})]}),0===a.length?(0,b.jsx)("p",{className:"px-4 py-8 text-xs text-muted-foreground text-center",children:"No completed items."}):(0,b.jsx)("div",{className:"overflow-x-auto",children:(0,b.jsxs)("table",{className:"w-full text-xs",children:[(0,b.jsx)("thead",{children:(0,b.jsxs)("tr",{className:"text-left text-muted-foreground border-b border-border bg-muted/30",children:[(0,b.jsx)("th",{className:"px-3 py-2 font-medium",children:"Type"}),(0,b.jsx)("th",{className:"px-3 py-2 font-medium",children:"Item"}),(0,b.jsx)("th",{className:"px-3 py-2 font-medium",children:"Session"}),(0,b.jsx)("th",{className:"px-3 py-2 font-medium",children:"Duration"}),(0,b.jsx)("th",{className:"px-3 py-2 font-medium",children:"Status"}),(0,b.jsx)("th",{className:"px-3 py-2 font-medium text-right",children:"Completed"})]})}),(0,b.jsx)("tbody",{className:"divide-y divide-border/50",children:a.map((a,c)=>(0,b.jsxs)("tr",{className:"hover:bg-muted/20",children:[(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(r,{type:a.type})}),(0,b.jsx)("td",{className:"px-3 py-2 font-mono text-foreground",children:a.itemName}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(t,{projectName:a.projectName,sessionId:a.sessionId})}),(0,b.jsx)("td",{className:"px-3 py-2 text-muted-foreground",children:function(a){if(a<1e3)return`${a}ms`;let b=(a/1e3).toFixed(1);return`${b}s`}(a.durationMs)}),(0,b.jsx)("td",{className:"px-3 py-2",children:a.success?(0,b.jsx)(g,{className:"h-3.5 w-3.5 text-green-600 dark:text-green-400"}):(0,b.jsx)(h,{className:"h-3.5 w-3.5 text-red-600 dark:text-red-400"})}),(0,b.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:new Date(a.completedAt).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})})]},`${a.key}-${a.completedAt}-${c}`))})]})}),(0,b.jsx)(j.default,{currentPage:C,totalPages:f,onPageChange:D})]}))]}),w.recentErrors.length>0&&(0,b.jsxs)("section",{className:"bg-card border border-border rounded-lg p-4",children:[(0,b.jsxs)("h2",{className:"text-sm font-semibold text-foreground mb-2",children:["Recent Errors",(0,b.jsxs)("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:["(",w.recentErrors.length,")"]})]}),(0,b.jsx)("div",{className:"space-y-1",children:w.recentErrors.map((a,c)=>(0,b.jsxs)("div",{className:"text-xs bg-muted/30 rounded px-2 py-1 flex items-start gap-2",children:[(0,b.jsx)("span",{className:"font-mono text-muted-foreground shrink-0",children:a.key}),(0,b.jsx)("span",{className:"text-red-500 break-all",children:a.error}),(0,b.jsx)("span",{className:"text-muted-foreground shrink-0 ml-auto",children:q(a.at)})]},`${a.key}-${a.at}-${c}`))})]})]})]})}],57730)}];
2
2
 
3
3
  //# sourceMappingURL=app_queue_queue-client_tsx_0c0olxv._.js.map
@@ -1,3 +1,3 @@
1
- module.exports=[74493,a=>{"use strict";let b,c,d,e,f;var g,h=a.i(14747);function i(a){return a.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}let j=a=>void 0===a?void 0:a.variant??a.enabled,k=a=>{if("string"!=typeof a)return a;try{return JSON.parse(a)}catch{return a}},l="0123456789abcdef";class m{constructor(a){this.bytes=a}static ofInner(a){if(16===a.length)return new m(a);throw TypeError("not 128-bit length")}static fromFieldsV7(a,b,c,d){if(!Number.isInteger(a)||!Number.isInteger(b)||!Number.isInteger(c)||!Number.isInteger(d)||a<0||b<0||c<0||d<0||a>0xffffffffffff||b>4095||c>0x3fffffff||d>0xffffffff)throw RangeError("invalid field value");let e=new Uint8Array(16);return e[0]=a/0x10000000000,e[1]=a/0x100000000,e[2]=a/0x1000000,e[3]=a/65536,e[4]=a/256,e[5]=a,e[6]=112|b>>>8,e[7]=b,e[8]=128|c>>>24,e[9]=c>>>16,e[10]=c>>>8,e[11]=c,e[12]=d>>>24,e[13]=d>>>16,e[14]=d>>>8,e[15]=d,new m(e)}static parse(a){let b;switch(a.length){case 32:b=/^[0-9a-f]{32}$/i.exec(a)?.[0];break;case 36:b=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(a)?.slice(1,6).join("");break;case 38:b=/^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(a)?.slice(1,6).join("");break;case 45:b=/^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(a)?.slice(1,6).join("")}if(b){let a=new Uint8Array(16);for(let c=0;c<16;c+=4){let d=parseInt(b.substring(2*c,2*c+8),16);a[c+0]=d>>>24,a[c+1]=d>>>16,a[c+2]=d>>>8,a[c+3]=d}return new m(a)}throw SyntaxError("could not parse UUID string")}toString(){let a="";for(let b=0;b<this.bytes.length;b++)a+=l.charAt(this.bytes[b]>>>4),a+=l.charAt(15&this.bytes[b]),(3===b||5===b||7===b||9===b)&&(a+="-");return a}toHex(){let a="";for(let b=0;b<this.bytes.length;b++)a+=l.charAt(this.bytes[b]>>>4),a+=l.charAt(15&this.bytes[b]);return a}toJSON(){return this.toString()}getVariant(){let a=this.bytes[8]>>>4;if(a<0)throw Error("unreachable");if(a<=7)return this.bytes.every(a=>0===a)?"NIL":"VAR_0";if(a<=11)return"VAR_10";if(a<=13)return"VAR_110";if(a<=15)return this.bytes.every(a=>255===a)?"MAX":"VAR_RESERVED";throw Error("unreachable")}getVersion(){return"VAR_10"===this.getVariant()?this.bytes[6]>>>4:void 0}clone(){return new m(this.bytes.slice(0))}equals(a){return 0===this.compareTo(a)}compareTo(a){for(let b=0;b<16;b++){let c=this.bytes[b]-a.bytes[b];if(0!==c)return Math.sign(c)}return 0}}class n{constructor(a){this.timestamp=0,this.counter=0,this.random=a??o()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(a,b){let c=this.generateOrAbortCore(a,b);return void 0===c&&(this.timestamp=0,c=this.generateOrAbortCore(a,b)),c}generateOrAbortCore(a,b){if(!Number.isInteger(a)||a<1||a>0xffffffffffff)throw RangeError("`unixTsMs` must be a 48-bit positive integer");if(b<0||b>0xffffffffffff)throw RangeError("`rollbackAllowance` out of reasonable range");if(a>this.timestamp)this.timestamp=a,this.resetCounter();else{if(!(a+b>=this.timestamp))return;this.counter++,this.counter>0x3ffffffffff&&(this.timestamp++,this.resetCounter())}return m.fromFieldsV7(this.timestamp,Math.trunc(this.counter/0x40000000),this.counter&0x40000000-1,this.random.nextUint32())}resetCounter(){this.counter=1024*this.random.nextUint32()+(1023&this.random.nextUint32())}generateV4(){let a=new Uint8Array(Uint32Array.of(this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32()).buffer);return a[6]=64|a[6]>>>4,a[8]=128|a[8]>>>2,m.ofInner(a)}}let o=()=>({nextUint32:()=>65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random())}),p=()=>(b||(b=new n)).generate();var q=((g={}).AnonymousId="anonymous_id",g.DistinctId="distinct_id",g.Props="props",g.EnablePersonProcessing="enable_person_processing",g.PersonMode="person_mode",g.FeatureFlagDetails="feature_flag_details",g.FeatureFlags="feature_flags",g.FeatureFlagPayloads="feature_flag_payloads",g.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",g.BootstrapFeatureFlags="bootstrap_feature_flags",g.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",g.OverrideFeatureFlags="override_feature_flags",g.Queue="queue",g.OptedOut="opted_out",g.SessionId="session_id",g.SessionStartTimestamp="session_start_timestamp",g.SessionLastTimestamp="session_timestamp",g.PersonProperties="person_properties",g.GroupProperties="group_properties",g.InstalledAppBuild="installed_app_build",g.InstalledAppVersion="installed_app_version",g.SessionReplay="session_replay",g.SurveyLastSeenDate="survey_last_seen_date",g.SurveysSeen="surveys_seen",g.Surveys="surveys",g.RemoteConfig="remote_config",g.FlagsEndpointWasHit="flags_endpoint_was_hit",g);let r={ERRORS_WHILE_COMPUTING:"errors_while_computing_flags",FLAG_MISSING:"flag_missing",QUOTA_LIMITED:"quota_limited",TIMEOUT:"timeout",CONNECTION_ERROR:"connection_error",UNKNOWN_ERROR:"unknown_error",apiError:a=>`api_error_${a}`},s=Array.isArray,t=Object.prototype;t.hasOwnProperty;let u=t.toString,v=s||function(a){return"[object Array]"===u.call(a)},w=a=>"[object String]"==u.call(a);function x(a){return null===a||"object"!=typeof a}function y(a,b){return Object.prototype.toString.call(a)===`[object ${b}]`}function z(a){return void 0!==Event&&function(a,b){try{return a instanceof b}catch{return!1}}(a,Event)}let A="Android",B="BlackBerry",C="Nintendo",D="PlayStation",E="Xbox",F="Windows",G="(\\d+(\\.\\d+)?)";RegExp("Version/"+G),RegExp(E,"i"),RegExp(D+" \\w+","i"),RegExp(C+" \\w+","i"),RegExp(B+"|PlayBook|BB10","i");async function H(a,b){let c=null;for(let d=0;d<b.retryCount+1;d++){d>0&&await new Promise(a=>setTimeout(a,b.retryDelay));try{return await a()}catch(a){if(c=a,!b.retryCheck(a))throw a}}throw c}function I(){return new Date().toISOString()}function J(a,b){let c=setTimeout(a,b);return c?.unref&&c?.unref(),c}RegExp("rv:"+G),RegExp("Edge?\\/"+G),RegExp("(Chrome|CrMo)\\/"+G),RegExp("CriOS\\/"+G),RegExp("(UCBrowser|UCWEB)\\/"+G),RegExp("(Opera|OPR)\\/"+G),RegExp("Firefox\\/"+G),RegExp("FxiOS\\/"+G),RegExp("Konqueror[:/]?"+G,"i"),RegExp(B+" "+G),RegExp("android\\s"+G,"i"),RegExp("SamsungBrowser\\/"+G),RegExp("(rv:|MSIE )"+G),RegExp("rv:"+G),RegExp(E+"; "+E+" (.*?)[);]","i"),RegExp(C,"i"),RegExp(D,"i"),RegExp(F,"i"),RegExp("("+A+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+A+")","i");let K=a=>a instanceof Error;function L(a){return Promise.all(a.map(a=>(a??Promise.resolve()).then(a=>({status:"fulfilled",value:a}),a=>({status:"rejected",reason:a}))))}class M{constructor(){this.events={},this.events={}}on(a,b){return this.events[a]||(this.events[a]=[]),this.events[a].push(b),()=>{this.events[a]=this.events[a].filter(a=>a!==b)}}emit(a,b){for(let c of this.events[a]||[])c(b);for(let c of this.events["*"]||[])c(a,b)}}async function N(a,b=!0){try{let b=new Blob([a],{type:"text/plain"}).stream().pipeThrough(new CompressionStream("gzip"));return await new Response(b).blob()}catch(a){return b&&console.error("Failed to gzip compress data",a),null}}class O{add(a){let b=p().toString();return this.promiseByIds[b]=a,a.catch(()=>{}).finally(()=>{delete this.promiseByIds[b]}),a}async join(){let a=Object.values(this.promiseByIds),b=a.length;for(;b>0;)await Promise.all(a),b=(a=Object.values(this.promiseByIds)).length}get length(){return Object.keys(this.promiseByIds).length}constructor(){this.promiseByIds={}}}let P=(a,b,c)=>{function d(e,...f){b(()=>{(0,c[e])(a,...f)})}return{info:(...a)=>{d("log",...a)},warn:(...a)=>{d("warn",...a)},error:(...a)=>{d("error",...a)},critical:(...b)=>{c.error(a,...b)},createLogger:d=>P(`${a} ${d}`,b,c)}};class Q extends Error{constructor(a,b){super("HTTP error while fetching PostHog: status="+a.status+", reqByteLength="+b),this.response=a,this.reqByteLength=b,this.name="PostHogFetchHttpError"}get status(){return this.response.status}get text(){return this.response.text()}get json(){return this.response.json()}}class R extends Error{constructor(a){super("Network error while fetching PostHog",a instanceof Error?{cause:a}:{}),this.error=a,this.name="PostHogFetchNetworkError"}}async function S(a){if(a instanceof Q){let b="";try{b=await a.text}catch{}console.error(`Error while flushing PostHog: message=${a.message}, response body=${b}`,a)}else console.error("Error while flushing PostHog",a);return Promise.resolve()}function T(a){return"object"==typeof a&&(a instanceof Q||a instanceof R)}function U(a){return"object"==typeof a&&a instanceof Q&&413===a.status}class V{constructor(a,b={}){this.flushPromise=null,this.shutdownPromise=null,this.promiseQueue=new O,this._events=new M,this._isInitialized=!1,function(a,b){if(!a||"string"!=typeof a||0===a.trim().length)throw Error(b)}(a,"You must pass your PostHog project's api key."),this.apiKey=a,this.host=function(a){return a?.replace(/\/+$/,"")}(b.host||"https://us.i.posthog.com"),this.flushAt=b.flushAt?Math.max(b.flushAt,1):20,this.maxBatchSize=Math.max(this.flushAt,b.maxBatchSize??100),this.maxQueueSize=Math.max(this.flushAt,b.maxQueueSize??1e3),this.flushInterval=b.flushInterval??1e4,this.preloadFeatureFlags=b.preloadFeatureFlags??!0,this.defaultOptIn=b.defaultOptIn??!0,this.disableSurveys=b.disableSurveys??!1,this._retryOptions={retryCount:b.fetchRetryCount??3,retryDelay:b.fetchRetryDelay??3e3,retryCheck:T},this.requestTimeout=b.requestTimeout??1e4,this.featureFlagsRequestTimeoutMs=b.featureFlagsRequestTimeoutMs??3e3,this.remoteConfigRequestTimeoutMs=b.remoteConfigRequestTimeoutMs??3e3,this.disableGeoip=b.disableGeoip??!0,this.disabled=b.disabled??!1,this.historicalMigration=b?.historicalMigration??!1,this._initPromise=Promise.resolve(),this._isInitialized=!0,this._logger=function(a,b=a=>a()){return P(a,b,function(a=console){return{log:a.log.bind(a),warn:a.warn.bind(a),error:a.error.bind(a),debug:a.debug.bind(a)}}())}("[PostHog]",this.logMsgIfDebug.bind(this)),this.evaluationContexts=b?.evaluationContexts??b?.evaluationEnvironments,b?.evaluationEnvironments&&!b?.evaluationContexts&&this._logger.warn("evaluationEnvironments is deprecated. Use evaluationContexts instead. This property will be removed in a future version."),this.disableCompression=!("CompressionStream"in globalThis)||(b?.disableCompression??!1)}logMsgIfDebug(a){this.isDebug&&a()}wrap(a){return this.disabled?void this._logger.warn("The client is disabled"):this._isInitialized?a():void this._initPromise.then(()=>a())}getCommonEventProperties(){return{$lib:this.getLibraryId(),$lib_version:this.getLibraryVersion()}}get optedOut(){return this.getPersistedProperty(q.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(q.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(q.OptedOut,!0)})}on(a,b){return this._events.on(a,b)}debug(a=!0){if(this.removeDebugCallback?.(),a){let a=this.on("*",(a,b)=>this._logger.info(a,b));this.removeDebugCallback=()=>{a(),this.removeDebugCallback=void 0}}}get isDebug(){return!!this.removeDebugCallback}get isDisabled(){return this.disabled}buildPayload(a){return{distinct_id:a.distinct_id,event:a.event,properties:{...a.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(a){return this.promiseQueue.add(a)}identifyStateless(a,b,c){this.wrap(()=>{let d={...this.buildPayload({distinct_id:a,event:"$identify",properties:b})};this.enqueue("identify",d,c)})}async identifyStatelessImmediate(a,b,c){let d={...this.buildPayload({distinct_id:a,event:"$identify",properties:b})};await this.sendImmediate("identify",d,c)}captureStateless(a,b,c,d){this.wrap(()=>{let e=this.buildPayload({distinct_id:a,event:b,properties:c});this.enqueue("capture",e,d)})}async captureStatelessImmediate(a,b,c,d){let e=this.buildPayload({distinct_id:a,event:b,properties:c});await this.sendImmediate("capture",e,d)}aliasStateless(a,b,c,d){this.wrap(()=>{let e=this.buildPayload({event:"$create_alias",distinct_id:b,properties:{...c||{},distinct_id:b,alias:a}});this.enqueue("alias",e,d)})}async aliasStatelessImmediate(a,b,c,d){let e=this.buildPayload({event:"$create_alias",distinct_id:b,properties:{...c||{},distinct_id:b,alias:a}});await this.sendImmediate("alias",e,d)}groupIdentifyStateless(a,b,c,d,e,f){this.wrap(()=>{let g=this.buildPayload({distinct_id:e||`$${a}_${b}`,event:"$groupidentify",properties:{$group_type:a,$group_key:b,$group_set:c||{},...f||{}}});this.enqueue("capture",g,d)})}async getRemoteConfig(){await this._initPromise;let a=this.host;"https://us.i.posthog.com"===a?a="https://us-assets.i.posthog.com":"https://eu.i.posthog.com"===a&&(a="https://eu-assets.i.posthog.com");let b=`${a}/array/${this.apiKey}/config`,c={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}};return this.fetchWithRetry(b,c,{retryCount:0},this.remoteConfigRequestTimeoutMs).then(a=>a.json()).catch(a=>{this._logger.error("Remote config could not be loaded",a),this._events.emit("error",a)})}async getFlags(a,b={},c={},d={},e={},f=!1){await this._initPromise;let g=`${this.host}/flags/?v=2${f?"&config=true":""}`,h={token:this.apiKey,distinct_id:a,groups:b,person_properties:c,group_properties:d,...e};this.evaluationContexts&&this.evaluationContexts.length>0&&(h.evaluation_contexts=this.evaluationContexts);let i={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:JSON.stringify(h)};return this._logger.info("Flags URL",g),this.fetchWithRetry(g,i,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(a=>a.json()).then(a=>({success:!0,response:(a=>{if("flags"in a){let b,c=Object.fromEntries(Object.entries(a.flags??{}).map(([a,b])=>[a,j(b)]).filter(([,a])=>void 0!==a)),d=Object.fromEntries(Object.keys(b=a.flags??{}).filter(a=>{let c=b[a];return c.enabled&&c.metadata&&void 0!==c.metadata.payload}).map(a=>{let c=b[a].metadata?.payload;return[a,c?k(c):void 0]}));return{...a,featureFlags:c,featureFlagPayloads:d}}{let b=a.featureFlags??{},c=Object.fromEntries(Object.entries(a.featureFlagPayloads||{}).map(([a,b])=>[a,k(b)])),d=Object.fromEntries(Object.entries(b).map(([a,b])=>{var d,e;return[a,{key:a,enabled:"string"==typeof(d=b)||d,variant:"string"==typeof d?d:void 0,reason:void 0,metadata:{id:void 0,version:void 0,payload:(e=c[a])?JSON.stringify(e):void 0,description:void 0}}]}));return{...a,featureFlags:b,featureFlagPayloads:c,flags:d}}})(a)})).catch(a=>(this._events.emit("error",a),{success:!1,error:this.categorizeRequestError(a)}))}categorizeRequestError(a){if(a instanceof Q)return{type:"api_error",statusCode:a.status};if(a instanceof R){let b=a.error;return b instanceof Error&&("AbortError"===b.name||"TimeoutError"===b.name)?{type:"timeout"}:{type:"connection_error"}}return{type:"unknown_error"}}async getFeatureFlagStateless(a,b,c={},d={},e={},f){await this._initPromise;let g=await this.getFeatureFlagDetailStateless(a,b,c,d,e,f);if(void 0===g)return{response:void 0,requestId:void 0};let h=j(g.response);return void 0===h&&(h=!1),{response:h,requestId:g.requestId}}async getFeatureFlagDetailStateless(a,b,c={},d={},e={},f){await this._initPromise;let g=await this.getFeatureFlagDetailsStateless(b,c,d,e,f,[a]);if(void 0!==g)return{response:g.flags[a],requestId:g.requestId,evaluatedAt:g.evaluatedAt}}async getFeatureFlagPayloadStateless(a,b,c={},d={},e={},f){await this._initPromise;let g=await this.getFeatureFlagPayloadsStateless(b,c,d,e,f,[a]);if(!g)return;let h=g[a];return void 0===h?null:h}async getFeatureFlagPayloadsStateless(a,b={},c={},d={},e,f){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(a,b,c,d,e,f)).payloads}async getFeatureFlagsStateless(a,b={},c={},d={},e,f){return await this._initPromise,await this.getFeatureFlagsAndPayloadsStateless(a,b,c,d,e,f)}async getFeatureFlagsAndPayloadsStateless(a,b={},c={},d={},e,f){await this._initPromise;let g=await this.getFeatureFlagDetailsStateless(a,b,c,d,e,f);return g?{flags:g.featureFlags,payloads:g.featureFlagPayloads,requestId:g.requestId}:{flags:void 0,payloads:void 0,requestId:void 0}}async getFeatureFlagDetailsStateless(a,b={},c={},d={},e,f){await this._initPromise;let g={};(e??this.disableGeoip)&&(g.geoip_disable=!0),f&&(g.flag_keys_to_evaluate=f);let h=await this.getFlags(a,b,c,d,g);if(!h.success)return;let i=h.response;return(i.errorsWhileComputingFlags&&console.error("[FEATURE FLAGS] Error while computing feature flags, some flags may be missing or incorrect. Learn more at https://posthog.com/docs/feature-flags/best-practices"),i.quotaLimited?.includes("feature_flags"))?(console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - feature flags unavailable. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts"),{flags:{},featureFlags:{},featureFlagPayloads:{},requestId:i?.requestId,quotaLimited:i.quotaLimited}):i}async getSurveysStateless(){if(await this._initPromise,!0===this.disableSurveys)return this._logger.info("Loading surveys is disabled."),[];let a=`${this.host}/api/surveys/?token=${this.apiKey}`,b={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}},c=await this.fetchWithRetry(a,b).then(a=>{if(200!==a.status||!a.json){let b=`Surveys API could not be loaded: ${a.status}`,c=Error(b);this._logger.error(c),this._events.emit("error",Error(b));return}return a.json()}).catch(a=>{this._logger.error("Surveys API could not be loaded",a),this._events.emit("error",a)}),d=c?.surveys;return d&&this._logger.info("Surveys fetched from API: ",JSON.stringify(d)),d??[]}get props(){return this._props||(this._props=this.getPersistedProperty(q.Props)),this._props||{}}set props(a){this._props=a}async register(a){this.wrap(()=>{this.props={...this.props,...a},this.setPersistedProperty(q.Props,this.props)})}async unregister(a){this.wrap(()=>{delete this.props[a],this.setPersistedProperty(q.Props,this.props)})}processBeforeEnqueue(a){return a}async flushStorage(){}enqueue(a,b,c){this.wrap(()=>{if(this.optedOut)return void this._events.emit(a,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");let d=this.prepareMessage(a,b,c);if(null===(d=this.processBeforeEnqueue(d)))return;let e=this.getPersistedProperty(q.Queue)||[];e.length>=this.maxQueueSize&&(e.shift(),this._logger.info("Queue is full, the oldest event is dropped.")),e.push({message:d}),this.setPersistedProperty(q.Queue,e),this._events.emit(a,d),e.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=J(()=>this.flushBackground(),this.flushInterval))})}async sendImmediate(a,b,c){if(this.disabled)return void this._logger.warn("The client is disabled");if(this._isInitialized||await this._initPromise,this.optedOut)return void this._events.emit(a,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");let d=this.prepareMessage(a,b,c);if(null===(d=this.processBeforeEnqueue(d)))return;let e={api_key:this.apiKey,batch:[d],sent_at:I()};this.historicalMigration&&(e.historical_migration=!0);let f=JSON.stringify(e),g=`${this.host}/batch/`,h=this.disableCompression?null:await N(f,this.isDebug),i={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json",...null!==h&&{"Content-Encoding":"gzip"}},body:h||f};try{await this.fetchWithRetry(g,i)}catch(a){this._events.emit("error",a)}}prepareMessage(a,b,c){let d={...b,type:a,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:c?.timestamp?c?.timestamp:I(),uuid:c?.uuid?c.uuid:p().toString()};return(c?.disableGeoip??this.disableGeoip)&&(d.properties||(d.properties={}),d.properties.$geoip_disable=!0),d.distinctId&&(d.distinct_id=d.distinctId,delete d.distinctId),d}clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}flushBackground(){this.flush().catch(async a=>{await S(a)})}async flush(){let a=L([this.flushPromise]).then(()=>this._flush());return this.flushPromise=a,this.addPendingPromise(a),L([a]).then(()=>{this.flushPromise===a&&(this.flushPromise=null)}),a}getCustomHeaders(){let a=this.getCustomUserAgent(),b={};return a&&""!==a&&(b["User-Agent"]=a),b}async _flush(){this.clearFlushTimer(),await this._initPromise;let a=this.getPersistedProperty(q.Queue)||[];if(!a.length)return;let b=[],c=a.length;for(;a.length>0&&b.length<c;){let c=a.slice(0,this.maxBatchSize),d=c.map(a=>a.message),e=async()=>{let b=(this.getPersistedProperty(q.Queue)||[]).slice(c.length);this.setPersistedProperty(q.Queue,b),a=b,await this.flushStorage()},f={api_key:this.apiKey,batch:d,sent_at:I()};this.historicalMigration&&(f.historical_migration=!0);let g=JSON.stringify(f),h=`${this.host}/batch/`,i=this.disableCompression?null:await N(g,this.isDebug),j={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json",...null!==i&&{"Content-Encoding":"gzip"}},body:i||g},k={retryCheck:a=>!U(a)&&T(a)};try{await this.fetchWithRetry(h,j,k)}catch(a){if(U(a)&&d.length>1){this.maxBatchSize=Math.max(1,Math.floor(d.length/2)),this._logger.warn(`Received 413 when sending batch of size ${d.length}, reducing batch size to ${this.maxBatchSize}`);continue}throw a instanceof R||await e(),this._events.emit("error",a),a}await e(),b.push(...d)}this._events.emit("flush",b)}async fetchWithRetry(a,b,c,d){let e=b.body?b.body:"",f=-1;try{f=e instanceof Blob?e.size:Buffer.byteLength(e,"utf8")}catch{f=e instanceof Blob?e.size:new TextEncoder().encode(e).length}return await H(async()=>{let c=new AbortController,e=J(()=>c.abort(),d??this.requestTimeout),g=null;try{g=await this.fetch(a,{signal:c.signal,...b})}catch(a){throw new R(a)}finally{clearTimeout(e)}if("no-cors"!==b.mode&&(g.status<200||g.status>=400))throw new Q(g,f);return g},{...this._retryOptions,...c})}async _shutdown(a=3e4){let b;await this._initPromise;let c=!1;this.clearFlushTimer();let d=async()=>{try{for(await this.promiseQueue.join();;){let a=this.getPersistedProperty(q.Queue)||[];if(0===a.length||(await this.flush(),c))break}}catch(a){if(!T(a))throw a;await S(a)}};try{return await Promise.race([new Promise((d,e)=>{b=J(()=>{this._logger.error("Timed out while shutting down PostHog"),c=!0,e("Timeout while shutting down PostHog. Some events may not have been sent.")},a)}),d()])}finally{clearTimeout(b)}}async shutdown(a=3e4){return this.shutdownPromise?this._logger.warn("shutdown() called while already shutting down. shutdown() is meant to be called once before process exit - use flush() for per-request cleanup"):this.shutdownPromise=this._shutdown(a).finally(()=>{this.shutdownPromise=null}),this.shutdownPromise}}class W{constructor(a,b,c=[]){this.coercers=a,this.stackParser=b,this.modifiers=c}buildFromUnknown(a,b={}){let c=b&&b.mechanism||{handled:!0,type:"generic"},d=this.buildCoercingContext(c,b,0).apply(a),e=this.buildParsingContext(b),f=this.parseStacktrace(d,e);return{$exception_list:this.convertToExceptionList(f,c),$exception_level:"error"}}async modifyFrames(a){for(let b of a)b.stacktrace&&b.stacktrace.frames&&v(b.stacktrace.frames)&&(b.stacktrace.frames=await this.applyModifiers(b.stacktrace.frames));return a}coerceFallback(a){return{type:"Error",value:"Unknown error",stack:a.syntheticException?.stack,synthetic:!0}}parseStacktrace(a,b){let c,d;return null!=a.cause&&(c=this.parseStacktrace(a.cause,b)),""!=a.stack&&null!=a.stack&&(d=this.applyChunkIds(this.stackParser(a.stack,a.synthetic?b.skipFirstLines:0),b.chunkIdMap)),{...a,cause:c,stack:d}}applyChunkIds(a,b){return a.map(a=>(a.filename&&b&&(a.chunk_id=b[a.filename]),a))}applyCoercers(a,b){for(let c of this.coercers)if(c.match(a))return c.coerce(a,b);return this.coerceFallback(b)}async applyModifiers(a){let b=a;for(let a of this.modifiers)b=await a(b);return b}convertToExceptionList(a,b){let c={type:a.type,value:a.value,mechanism:{type:b.type??"generic",handled:b.handled??!0,synthetic:a.synthetic??!1}};a.stack&&(c.stacktrace={type:"raw",frames:a.stack});let d=[c];return null!=a.cause&&d.push(...this.convertToExceptionList(a.cause,{...b,handled:!0})),d}buildParsingContext(a){return{chunkIdMap:function(a){let b=globalThis._posthogChunkIds;if(!b)return;let f=Object.keys(b);return e&&f.length===d?e:(d=f.length,e=f.reduce((d,e)=>{c||(c={});let f=c[e];if(f)d[f[0]]=f[1];else{let f=a(e);for(let a=f.length-1;a>=0;a--){let g=f[a],h=g?.filename,i=b[e];if(h&&i){d[h]=i,c[e]=[h,i];break}}}return d},{}))}(this.stackParser),skipFirstLines:a.skipFirstLines??1}}buildCoercingContext(a,b,c=0){let d=(c,d)=>{if(d<=4){let e=this.buildCoercingContext(a,b,d);return this.applyCoercers(c,e)}};return{...b,syntheticException:0==c?b.syntheticException:void 0,mechanism:a,apply:a=>d(a,c),next:a=>d(a,c+1)}}}function X(a,b,c,d,e){let f={platform:a,filename:b,function:"<anonymous>"===c?"?":c,in_app:!0};return void 0!==d&&(f.lineno=d),void 0!==e&&(f.colno=e),f}a.s(["ErrorPropertiesBuilder",0,W],6762);let Y=(a,b)=>{let c=-1!==a.indexOf("safari-extension"),d=-1!==a.indexOf("safari-web-extension");return c||d?[-1!==a.indexOf("@")?a.split("@")[0]:"?",c?`safari-extension:${b}`:`safari-web-extension:${b}`]:[a,b]},Z=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,$=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,_=/\((\S*)(?::(\d+))(?::(\d+))\)/,aa=(a,b)=>{let c=Z.exec(a);if(c){let[,a,d,e]=c;return X(b,a,"?",+d,+e)}let d=$.exec(a);if(d){if(d[2]&&0===d[2].indexOf("eval")){let a=_.exec(d[2]);a&&(d[2]=a[1],d[3]=a[2],d[4]=a[3])}let[a,c]=Y(d[1]||"?",d[2]);return X(b,c,a,d[3]?+d[3]:void 0,d[4]?+d[4]:void 0)}},ab=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ac=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,ad=(a,b)=>{let c=ab.exec(a);if(c){if(c[3]&&c[3].indexOf(" > eval")>-1){let a=ac.exec(c[3]);a&&(c[1]=c[1]||"eval",c[3]=a[1],c[4]=a[2],c[5]="")}let a=c[3],d=c[1]||"?";return[d,a]=Y(d,a),X(b,a,d,c[4]?+c[4]:void 0,c[5]?+c[5]:void 0)}},ae=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:[-a-z]+):.*?):(\d+)(?::(\d+))?\)?\s*$/i,af=(a,b)=>{let c=ae.exec(a);return c?X(b,c[2],c[1]||"?",+c[3],c[4]?+c[4]:void 0):void 0},ag=/ line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i,ah=(a,b)=>{let c=ag.exec(a);return c?X(b,c[2],c[3]||"?",+c[1]):void 0},ai=/ line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^)]+))\(.*\))? in (.*):\s*$/i,aj=(a,b)=>{let c=ai.exec(a);return c?X(b,c[5],c[3]||c[4]||"?",+c[1],+c[2]):void 0},ak=/^\s*[-]{4,}$/,al=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/,am=(a,b)=>{let c=a.match(al);if(c){let a,d,e,f,g;if(c[1]){let b=(e=c[1]).lastIndexOf(".");if("."===e[b-1]&&b--,b>0){a=e.slice(0,b),d=e.slice(b+1);let c=a.indexOf(".Module");c>0&&(e=e.slice(c+1),a=a.slice(0,c))}f=void 0}d&&(f=a,g=d),"<anonymous>"===d&&(g=void 0,e=void 0),void 0===e&&(g=g||"?",e=f?`${f}.${g}`:g);let h=c[2]?.startsWith("file://")?c[2].slice(7):c[2],i="native"===c[5];return h?.match(/\/[A-Z]:/)&&(h=h.slice(1)),h||!c[5]||i||(h=c[5]),{filename:h?decodeURI(h):void 0,module:void 0,function:e,lineno:an(c[3]),colno:an(c[4]),in_app:function(a,b=!1){return!(b||a&&!a.startsWith("/")&&!a.match(/^[A-Z]:/)&&!a.startsWith(".")&&!a.match(/^[a-zA-Z]([a-zA-Z0-9.\-+])*:\/\//))&&void 0!==a&&!a.includes("node_modules/")}(h||"",i),platform:b}}if(a.match(ak))return{filename:a,platform:b}};function an(a){return parseInt(a||"",10)||void 0}let ao=/\(error: (.*)\)/;function ap(a){if(!a.length)return[];let b=Array.from(a);return b.reverse(),b.slice(0,50).map(a=>{var c;return{...a,filename:a.filename||((c=b)[c.length-1]||{}).filename,function:a.function||"?"}})}function aq(){return ar("web:javascript",aa,ad)}function ar(a,...b){return(c,d=0)=>{let e=[],f=c.split("\n");for(let c=d;c<f.length;c++){let d=f[c];if(d.length>1024)continue;let g=ao.test(d)?d.replace(ao,"$1"):d;if(!g.match(/\S*Error: /)){for(let c of b){let b=c(g,a);if(b){e.push(b);break}}if(e.length>=50)break}}return ap(e)}}a.s(["createDefaultStackParser",0,aq,"createStackParser",0,ar,"reverseAndStripFrames",0,ap],67970);class as{match(a){return this.isDOMException(a)||this.isDOMError(a)}coerce(a,b){let c=w(a.stack);return{type:this.getType(a),value:this.getValue(a),stack:c?a.stack:void 0,cause:a.cause?b.next(a.cause):void 0,synthetic:!1}}getType(a){return this.isDOMError(a)?"DOMError":"DOMException"}getValue(a){let b=a.name||(this.isDOMError(a)?"DOMError":"DOMException");return a.message?`${b}: ${a.message}`:b}isDOMException(a){return y(a,"DOMException")}isDOMError(a){return y(a,"DOMError")}}a.s(["DOMExceptionCoercer",0,as],51671);class at{match(a){return a instanceof Error}coerce(a,b){return{type:this.getType(a),value:this.getMessage(a,b),stack:this.getStack(a),cause:a.cause?b.next(a.cause):void 0,synthetic:!1}}getType(a){return a.name||a.constructor.name}getMessage(a,b){let c=a.message;return c.error&&"string"==typeof c.error.message?String(c.error.message):String(c)}getStack(a){return a.stacktrace||a.stack||void 0}}a.s(["ErrorCoercer",0,at],10692);class au{match(a){return y(a,"ErrorEvent")&&void 0!=a.error}coerce(a,b){let c=b.apply(a.error);return c||{type:"ErrorEvent",value:a.message,stack:b.syntheticException?.stack,synthetic:!0}}}a.s(["ErrorEventCoercer",0,au],75368);let av=["fatal","error","warning","log","info","debug"];function aw(a,b=40){let c=Object.keys(a);if(c.sort(),!c.length)return"[object has no keys]";for(let a=c.length;a>0;a--){let d=c.slice(0,a).join(", ");if(!(d.length>b)){if(a===c.length)return d;return d.length<=b?d:`${d.slice(0,b)}...`}}return""}class ax{match(a){return"object"==typeof a&&null!==a}coerce(a,b){let c=this.getErrorPropertyFromObject(a);return c?b.apply(c):{type:this.getType(a),value:this.getValue(a),stack:b.syntheticException?.stack,level:this.isSeverityLevel(a.level)?a.level:"error",synthetic:!0}}getType(a){return z(a)?a.constructor.name:"Error"}getValue(a){if("name"in a&&"string"==typeof a.name){let b=`'${a.name}' captured as exception`;return"message"in a&&"string"==typeof a.message&&(b+=` with message: '${a.message}'`),b}if("message"in a&&"string"==typeof a.message)return a.message;let b=this.getObjectClassName(a),c=aw(a);return`${b&&"Object"!==b?`'${b}'`:"Object"} captured as exception with keys: ${c}`}isSeverityLevel(a){return w(a)&&!(w(a)&&0===a.trim().length)&&av.indexOf(a)>=0}getErrorPropertyFromObject(a){for(let b in a)if(Object.prototype.hasOwnProperty.call(a,b)){let c=a[b];if(K(c))return c}}getObjectClassName(a){try{let b=Object.getPrototypeOf(a);return b?b.constructor.name:void 0}catch(a){return}}}a.s(["ObjectCoercer",0,ax],93874);class ay{match(a){return z(a)}coerce(a,b){let c=a.constructor.name;return{type:c,value:`${c} captured as exception with keys: ${aw(a)}`,stack:b.syntheticException?.stack,synthetic:!0}}}a.s(["EventCoercer",0,ay],46980);class az{match(a){return x(a)}coerce(a,b){return{type:"Error",value:`Primitive value captured as exception: ${String(a)}`,stack:b.syntheticException?.stack,synthetic:!0}}}a.s(["PrimitiveCoercer",0,az],28150);class aA{match(a){return y(a,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(a)}isCustomEventWrappingRejection(a){if(!z(a))return!1;try{let b=a.detail;return null!=b&&"object"==typeof b&&"reason"in b}catch{return!1}}coerce(a,b){let c=this.getUnhandledRejectionReason(a);return x(c)?{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(c)}`,stack:b.syntheticException?.stack,synthetic:!0}:b.apply(c)}getUnhandledRejectionReason(a){try{if("reason"in a)return a.reason;if("detail"in a&&null!=a.detail&&"object"==typeof a.detail&&"reason"in a.detail)return a.detail.reason}catch{}return a}}a.s(["PromiseRejectionEventCoercer",0,aA],98140),a.s([],7610),a.s([],48153),a.i(48153),a.i(6762),a.i(67970),a.s(["chromeStackLineParser",0,aa,"createDefaultStackParser",0,aq,"createStackParser",0,ar,"geckoStackLineParser",0,ad,"nodeStackLineParser",0,am,"opera10StackLineParser",0,ah,"opera11StackLineParser",0,aj,"reverseAndStripFrames",0,ap,"winjsStackLineParser",0,af],64583),a.i(64583),a.i(7610),a.i(51671),a.i(10692),a.i(75368);let aB=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class aC{match(a){return"string"==typeof a}coerce(a,b){let[c,d]=this.getInfos(a);return{type:c??"Error",value:d??a,stack:b.syntheticException?.stack,synthetic:!0}}getInfos(a){let b="Error",c=a,d=a.match(aB);return d&&(b=d[1],c=d[2]),[b,c]}}a.s(["StringCoercer",0,aC],57802),a.i(57802),a.i(93874),a.i(46980),a.i(28150),a.i(98140),a.s(["DOMExceptionCoercer",0,as,"ErrorCoercer",0,at,"ErrorEventCoercer",0,au,"EventCoercer",0,ay,"ObjectCoercer",0,ax,"PrimitiveCoercer",0,az,"PromiseRejectionEventCoercer",0,aA,"StringCoercer",0,aC],54253),a.i(54253);class aD{constructor(a){this._maxSize=a,this._cache=new Map}get(a){let b=this._cache.get(a);if(void 0!==b)return this._cache.delete(a),this._cache.set(a,b),b}set(a,b){this._cache.set(a,b)}reduce(){for(;this._cache.size>=this._maxSize;){let a=this._cache.keys().next().value;a&&this._cache.delete(a)}}}a.s(["ReduceableCache",0,aD],98966),a.i(98966),a.s(["DOMExceptionCoercer",0,as,"ErrorCoercer",0,at,"ErrorEventCoercer",0,au,"ErrorPropertiesBuilder",0,W,"EventCoercer",0,ay,"ObjectCoercer",0,ax,"PrimitiveCoercer",0,az,"PromiseRejectionEventCoercer",0,aA,"ReduceableCache",0,aD,"StringCoercer",0,aC,"chromeStackLineParser",0,aa,"createDefaultStackParser",0,aq,"createStackParser",0,ar,"geckoStackLineParser",0,ad,"nodeStackLineParser",0,am,"opera10StackLineParser",0,ah,"opera11StackLineParser",0,aj,"reverseAndStripFrames",0,ap,"winjsStackLineParser",0,af],60485);var aE=a.i(60485),aF=aE,aG=a.i(2157),aH=a.i(1457);let aI=new aF.ReduceableCache(25),aJ=new aF.ReduceableCache(20);async function aK(a){let b={};for(let e=a.length-1;e>=0;e--){var c,d;let f=a[e],g=f?.filename;!(!f||"string"!=typeof g||"number"!=typeof f.lineno||(c=g).startsWith("node:")||c.endsWith(".min.js")||c.endsWith(".min.cjs")||c.endsWith(".min.mjs")||c.startsWith("data:")||void 0!==(d=f).lineno&&d.lineno>1e4||void 0!==d.colno&&d.colno>1e3)&&(b[g]||(b[g]=[]),b[g].push(f.lineno))}let e=Object.keys(b);if(0==e.length)return a;let f=[];for(let a of e){if(aJ.get(a))continue;let c=b[a];if(!c)continue;c.sort((a,b)=>a-b);let d=function(a){if(!a.length)return[];let b=0,c=a[0];if("number"!=typeof c)return[];let d=aM(c),e=[];for(;;){if(b===a.length-1){e.push(d);break}let c=a[b+1];if("number"!=typeof c)break;c<=d[1]?d[1]=c+7:(e.push(d),d=aM(c)),b++}return e}(c);if(d.every(b=>(function(a,b){let c=aI.get(a);if(void 0===c)return!1;for(let a=b[0];a<=b[1];a++)if(void 0===c[a])return!1;return!0})(a,b)))continue;let e=function(a,b,c){let d=a.get(b);return void 0===d?(a.set(b,c),c):d}(aI,a,{});f.push(function(a,b,c){return new Promise(d=>{let e=(0,aG.createReadStream)(a),f=(0,aH.createInterface)({input:e});function g(){e.destroy(),d()}let h=0,i=0,j=b[0];if(void 0===j)return void g();let k=j[0],l=j[1];function m(){aJ.set(a,1),f.close(),f.removeAllListeners(),g()}e.on("error",m),f.on("error",m),f.on("close",g),f.on("line",a=>{if(!(++h<k)&&(c[h]=function(a,b){let c=a,d=c.length;if(d<=150)return c;b>d&&(b=d);let e=Math.max(b-60,0);e<5&&(e=0);let f=Math.min(e+140,d);return f>d-5&&(f=d),f===d&&(e=Math.max(f-140,0)),c=c.slice(e,f),e>0&&(c=`...${c}`),f<d&&(c+="..."),c}(a,0),h>=l)){if(i===b.length-1){f.close(),f.removeAllListeners();return}let a=b[++i];if(void 0===a){f.close(),f.removeAllListeners();return}k=a[0],l=a[1]}})})}(a,d,e))}return await Promise.all(f).catch(()=>{}),a&&a.length>0&&function(a,b){for(let c of a)if(c.filename&&void 0===c.context_line&&"number"==typeof c.lineno){let a=b.get(c.filename);if(void 0===a)continue;!function(a,b,c){if(void 0===b.lineno||void 0===c)return;b.pre_context=[];for(let d=aN(a);d<a;d++){let a=c[d];if(void 0===a)return void aL(b);b.pre_context.push(a)}if(void 0===c[a])return aL(b);b.context_line=c[a];let d=function(a){return a+7}(a);b.post_context=[];for(let e=a+1;e<=d;e++){let a=c[e];if(void 0===a)break;b.post_context.push(a)}}(c.lineno,c,a)}}(a,aI),aI.reduce(),a}function aL(a){delete a.pre_context,delete a.context_line,delete a.post_context}function aM(a){return[aN(a),a+7]}function aN(a){return Math.max(1,a-7)}function aO(a,b,c,d,e){if(b>c&&(d.warn("min cannot be greater than max."),b=c),"[object Number]"==u.call(a)&&a==a)if(a>c)return d.warn(" cannot be greater than max: "+c+". Using max value instead."),c;else return a<b?(d.warn(" cannot be less than min: "+b+". Using min value instead."),b):a;return d.warn(" must be a number. using max or fallback. max: "+c+", fallback: "+e),aO(e||c,b,c,d)}class aP{constructor(a){this._buckets={},this._onBucketRateLimited=a._onBucketRateLimited,this._bucketSize=aO(a.bucketSize,0,100,a._logger),this._refillRate=aO(a.refillRate,0,this._bucketSize,a._logger),this._refillInterval=aO(a.refillInterval,0,864e5,a._logger)}_applyRefill(a,b){let c=Math.floor((b-a.lastAccess)/this._refillInterval);if(c>0){let b=c*this._refillRate;a.tokens=Math.min(a.tokens+b,this._bucketSize),a.lastAccess=a.lastAccess+c*this._refillInterval}}consumeRateLimit(a){let b=Date.now(),c=String(a),d=this._buckets[c];return d?this._applyRefill(d,b):(d={tokens:this._bucketSize,lastAccess:b},this._buckets[c]=d),0===d.tokens||(d.tokens--,0===d.tokens&&this._onBucketRateLimited?.(a),0===d.tokens)}stop(){this._buckets={}}}class aQ{constructor(a,b,c){this.client=a,this._exceptionAutocaptureEnabled=b.enableExceptionAutocapture||!1,this._logger=c,this._rateLimiter=new aP({refillRate:1,bucketSize:10,refillInterval:1e4,_logger:this._logger}),this.startAutocaptureIfEnabled()}static isPreviouslyCapturedError(a){return a===Object(a)&&!v(a)&&"__posthog_previously_captured_error"in a&&!0===a.__posthog_previously_captured_error}static async buildEventMessage(a,b,c,d){let e={...d};c||(e.$process_person_profile=!1);let f=this.errorPropertiesBuilder.buildFromUnknown(a,b);return f.$exception_list=await this.errorPropertiesBuilder.modifyFrames(f.$exception_list),{event:"$exception",distinctId:c||p().toString(),properties:{...f,...e},_originatedFromCaptureException:!0}}startAutocaptureIfEnabled(){if(this.isEnabled()){var b,c,d;let e;b=this.onException.bind(this),c=this.onFatalError.bind(this),globalThis.process?.on("uncaughtException",(e=!1,Object.assign(d=>{let f=a.g.process.listeners("uncaughtException").filter(a=>"domainUncaughtExceptionClear"!==a.name&&!0!==a._posthogErrorHandler).length;b(d,{mechanism:{type:"onuncaughtexception",handled:!1}}),e||0!==f||(e=!0,c(d))},{_posthogErrorHandler:!0}))),d=this.onException.bind(this),globalThis.process?.on("unhandledRejection",a=>d(a,{mechanism:{type:"onunhandledrejection",handled:!1}}))}}onException(a,b){this.client.addPendingPromise((async()=>{if(!aQ.isPreviouslyCapturedError(a)){let c=await aQ.buildEventMessage(a,b),d=c.properties,e=d?.$exception_list[0]?.type??"Exception";return this._rateLimiter.consumeRateLimit(e)?void this._logger.info("Skipping exception capture because of client rate limiting.",{exception:e}):this.client.capture(c)}})())}async onFatalError(a){console.error(a),await this.client.shutdown(2e3),process.exit(1)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}shutdown(){this._rateLimiter.stop()}}let aR=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],aS=function(a,b=[]){if(!a)return!1;let c=a.toLowerCase();return aR.concat(b).some(a=>{let b=a.toLowerCase();return -1!==c.indexOf(b)})},aT={ERRORS_WHILE_COMPUTING:"errors_while_computing_flags",FLAG_MISSING:"flag_missing",QUOTA_LIMITED:"quota_limited",UNKNOWN_ERROR:"unknown_error"};async function aU(a){let b=globalThis.crypto?.subtle;if(!b)throw Error("SubtleCrypto API not available");return Array.from(new Uint8Array(await b.digest("SHA-1",new TextEncoder().encode(a)))).map(a=>a.toString(16).padStart(2,"0")).join("")}a.s(["FeatureFlagError",0,aT],46539);let aV=["is_not"];class aW extends Error{constructor(a){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=a,Object.setPrototypeOf(this,aW.prototype)}}class aX extends Error{constructor(a){super(a),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,aX.prototype)}}class aY extends Error{constructor(a){super(a),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,aY.prototype)}}class aZ{constructor({pollingInterval:a,personalApiKey:b,projectApiKey:c,timeout:d,host:e,customHeaders:f,...g}){this.debugMode=!1,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.pollingInterval=a,this.personalApiKey=b,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=d,this.projectApiKey=c,this.host=e,this.poller=void 0,this.fetch=g.fetch||fetch,this.onError=g.onError,this.customHeaders=f,this.onLoad=g.onLoad,this.cacheProvider=g.cacheProvider,this.strictLocalEvaluation=g.strictLocalEvaluation??!1,this.loadFeatureFlags()}debug(a=!0){this.debugMode=a}logMsgIfDebug(a){this.debugMode&&a()}createEvaluationContext(a,b={},c={},d={},e={}){return{distinctId:a,groups:b,personProperties:c,groupProperties:d,evaluationCache:e}}async getFeatureFlag(a,b,c={},d={},e={}){let f,g;if(await this.loadFeatureFlags(),!this.loadedSuccessfullyOnce)return f;if(void 0!==(g=this.featureFlagsByKey[a])){let h=this.createEvaluationContext(b,c,d,e);try{f=(await this.computeFlagAndPayloadLocally(g,h)).value,this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${a} -> ${f}`))}catch(b){b instanceof aY||b instanceof aX?this.logMsgIfDebug(()=>console.debug(`${b.name} when computing flag locally: ${a}: ${b.message}`)):b instanceof Error&&this.onError?.(Error(`Error computing flag locally: ${a}: ${b}`))}}return f}async getAllFlagsAndPayloads(a,b){await this.loadFeatureFlags();let c={},d={},e=0==this.featureFlags.length,f=b?b.map(a=>this.featureFlagsByKey[a]).filter(Boolean):this.featureFlags,g={...a,evaluationCache:a.evaluationCache??{}};return await Promise.all(f.map(async a=>{try{let{value:b,payload:e}=await this.computeFlagAndPayloadLocally(a,g);c[a.key]=b,e&&(d[a.key]=e)}catch(b){b instanceof aY||b instanceof aX?this.logMsgIfDebug(()=>console.debug(`${b.name} when computing flag locally: ${a.key}: ${b.message}`)):b instanceof Error&&this.onError?.(Error(`Error computing flag locally: ${a.key}: ${b}`)),e=!0}})),{response:c,payloads:d,fallbackToFlags:e}}async computeFlagAndPayloadLocally(a,b,c={}){let d,{matchValue:e,skipLoadCheck:f=!1}=c;if(f||await this.loadFeatureFlags(),!this.loadedSuccessfullyOnce)return{value:!1,payload:null};d=void 0!==e?e:await this.computeFlagValueLocally(a,b);let g=this.getFeatureFlagPayload(a.key,d);return{value:d,payload:g}}async computeFlagValueLocally(a,b){let{distinctId:c,groups:d,personProperties:e,groupProperties:f}=b;if(a.ensure_experience_continuity)throw new aX("Flag has experience continuity enabled");if(!a.active)return!1;let g=(a.filters||{}).aggregation_group_type_index;if(void 0!=g){let c=this.groupTypeMapping[String(g)];if(!c)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${g} for feature flag ${a.key}`)),new aX("Flag has unknown group type index");if(!(c in d))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${a.key} without group names passed in`)),!1;"device_id"===a.bucketing_identifier&&(e?.$device_id===void 0||e?.$device_id===null||e?.$device_id==="")&&this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Ignoring bucketing_identifier for group flag: ${a.key}`));let h=f[c];return await this.matchFeatureFlagProperties(a,d[c],h,b)}{let d=this.getBucketingValueForFlag(a,c,e);if(void 0===d)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute feature flag: ${a.key} without $device_id, falling back to server evaluation`)),new aX(`Can't compute feature flag: ${a.key} without $device_id`);return await this.matchFeatureFlagProperties(a,d,e,b)}}getBucketingValueForFlag(a,b,c){if(a.filters?.aggregation_group_type_index!=void 0)return b;if("device_id"===a.bucketing_identifier){let a=c?.$device_id;if(null==a||""===a)return;return a}return b}getFeatureFlagPayload(a,b){let c=null;if(!1!==b&&null!=b&&("boolean"==typeof b?c=this.featureFlagsByKey?.[a]?.filters?.payloads?.[b.toString()]||null:"string"==typeof b&&(c=this.featureFlagsByKey?.[a]?.filters?.payloads?.[b]||null),null!=c)){if("object"==typeof c)return c;if("string"==typeof c)try{return JSON.parse(c)}catch{}return c}return null}async evaluateFlagDependency(a,b,c){let{evaluationCache:d}=c,e=a.key;if(!this.featureFlagsByKey)throw new aX("Feature flags not available for dependency evaluation");if(!("dependency_chain"in a))throw new aX(`Flag dependency property for '${e}' is missing required 'dependency_chain' field`);let f=a.dependency_chain;if(!Array.isArray(f))throw new aX(`Flag dependency property for '${e}' has an invalid 'dependency_chain' (expected array, got ${typeof f})`);if(0===f.length)throw new aX(`Circular dependency detected for flag '${e}' (empty dependency chain)`);for(let a of f){if(!(a in d)){let b=this.featureFlagsByKey[a];if(b)if(b.active)try{let e=await this.computeFlagValueLocally(b,c);d[a]=e}catch(b){throw new aX(`Error evaluating flag dependency '${a}' for flag '${e}': ${b}`)}else d[a]=!1;else throw new aX(`Missing flag dependency '${a}' for flag '${e}'`)}if(null==d[a])throw new aX(`Dependency '${a}' could not be evaluated`)}let g=d[e];return this.flagEvaluatesToExpectedValue(a.value,g)}flagEvaluatesToExpectedValue(a,b){return"boolean"==typeof a?a===b||"string"==typeof b&&""!==b&&!0===a:"string"==typeof a&&b===a}async matchFeatureFlagProperties(a,b,c,d){let e,f=a.filters||{},g=f.groups||[],h=!1;for(let i of g)try{if(await this.isConditionMatch(a,b,i,c,d)){let c=i.variant,d=f.multivariate?.variants||[];e=c&&d.some(a=>a.key===c)?c:await this.getMatchingVariant(a,b)||!0;break}}catch(a){if(a instanceof aY)throw a;if(a instanceof aX)h=!0;else throw a}if(void 0!==e)return e;if(h)throw new aX("Can't determine if feature flag is enabled or not with given properties");return!1}async isConditionMatch(a,b,c,d,e){let f=c.rollout_percentage,g=a=>{this.logMsgIfDebug(()=>console.warn(a))};if((c.properties||[]).length>0){for(let a of c.properties){let b=a.type;if(!("cohort"===b?function a(b,c,d,e=!1){let f=String(b.value);if(!(f in d))throw new aY(`cohort ${f} not found in local cohorts - likely a static cohort that requires server evaluation`);return function b(c,d,e,f=!1){if(!c)return!0;let g=c.type,h=c.values;if(!h||0===h.length)return!0;let i=!1;if("values"in h[0]){for(let a of h)try{let c=b(a,d,e,f);if("AND"===g){if(!c)return!1}else if(c)return!0}catch(b){if(b instanceof aY)throw b;if(b instanceof aX)f&&console.debug(`Failed to compute property ${a} locally: ${b}`),i=!0;else throw b}if(i)throw new aX("Can't match cohort without a given cohort property value");return"AND"===g}for(let b of h)try{let c;if("cohort"===b.type)c=a(b,d,e,f);else if("flag"===b.type){f&&console.warn(`[FEATURE FLAGS] Flag dependency filters are not supported in local evaluation. Skipping condition with dependency on flag '${b.key||"unknown"}'`);continue}else c=a_(b,d);let h=b.negation||!1;if("AND"===g){if(!c&&!h||c&&h)return!1}else if(c&&!h||!c&&h)return!0}catch(a){if(a instanceof aY)throw a;if(a instanceof aX)f&&console.debug(`Failed to compute property ${b} locally: ${a}`),i=!0;else throw a}if(i)throw new aX("can't match cohort without a given cohort property value");return"AND"===g}(d[f],c,d,e)}(a,d,this.cohorts,this.debugMode):"flag"===b?await this.evaluateFlagDependency(a,d,e):a_(a,d,g)))return!1}if(void 0==f)return!0}return!(void 0!=f&&await a$(a.key,b)>f/100)}async getMatchingVariant(a,b){let c=await a$(a.key,b,"variant"),d=this.variantLookupTable(a).find(a=>c>=a.valueMin&&c<a.valueMax);if(d)return d.key}variantLookupTable(a){let b=[],c=0,d=0,e=a.filters||{};return(e.multivariate?.variants||[]).forEach(a=>{d=c+a.rollout_percentage/100,b.push({valueMin:c,valueMax:d,key:a.key}),c=d}),b}updateFlagState(a){this.featureFlags=a.flags,this.featureFlagsByKey=a.flags.reduce((a,b)=>(a[b.key]=b,a),{}),this.groupTypeMapping=a.groupTypeMapping,this.cohorts=a.cohorts,this.loadedSuccessfullyOnce=!0}warnAboutExperienceContinuityFlags(a){if(this.strictLocalEvaluation)return;let b=a.filter(a=>a.ensure_experience_continuity);b.length>0&&console.warn(`[PostHog] You are using local evaluation but ${b.length} flag(s) have experience continuity enabled: ${b.map(a=>a.key).join(", ")}. Experience continuity is incompatible with local evaluation and will cause a server request on every flag evaluation, negating local evaluation cost savings. To avoid server requests and unexpected costs, either disable experience continuity on these flags in PostHog, use strictLocalEvaluation: true in client init, or pass onlyEvaluateLocally: true per flag call (flags that cannot be evaluated locally will return undefined).`)}async loadFromCache(a){if(!this.cacheProvider)return!1;try{let b=await this.cacheProvider.getFlagDefinitions();if(b)return this.updateFlagState(b),this.logMsgIfDebug(()=>console.debug(`[FEATURE FLAGS] ${a} (${b.flags.length} flags)`)),this.onLoad?.(this.featureFlags.length),this.warnAboutExperienceContinuityFlags(b.flags),!0;return!1}catch(a){return this.onError?.(Error(`Failed to load from cache: ${a}`)),!1}}async loadFeatureFlags(a=!1){if(!this.loadedSuccessfullyOnce||a)return!a&&this.nextFetchAllowedAt&&Date.now()<this.nextFetchAllowedAt?void this.logMsgIfDebug(()=>console.debug("[FEATURE FLAGS] Skipping fetch, in backoff period")):(this.loadingPromise||(this.loadingPromise=this._loadFeatureFlags().catch(a=>this.logMsgIfDebug(()=>console.debug(`[FEATURE FLAGS] Failed to load feature flags: ${a}`))).finally(()=>{this.loadingPromise=void 0})),this.loadingPromise)}isLocalEvaluationReady(){return(this.loadedSuccessfullyOnce??!1)&&(this.featureFlags?.length??0)>0}getFlagDefinitionsLoadedAt(){return this.flagDefinitionsLoadedAt}getPollingInterval(){return this.shouldBeginExponentialBackoff?Math.min(6e4,this.pollingInterval*2**this.backOffCount):this.pollingInterval}beginBackoff(){this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,this.nextFetchAllowedAt=Date.now()+this.getPollingInterval()}clearBackoff(){this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.nextFetchAllowedAt=void 0}async _loadFeatureFlags(){this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(()=>this.loadFeatureFlags(!0),this.getPollingInterval());try{let a=!0;if(this.cacheProvider)try{a=await this.cacheProvider.shouldFetchFlagDefinitions()}catch(a){this.onError?.(Error(`Error in shouldFetchFlagDefinitions: ${a}`))}if(!a&&(await this.loadFromCache("Loaded flags from cache (skipped fetch)")||this.loadedSuccessfullyOnce))return;let b=await this._requestFeatureFlagDefinitions();if(!b)return;switch(b.status){case 304:this.logMsgIfDebug(()=>console.debug("[FEATURE FLAGS] Flags not modified (304), using cached data")),this.flagsEtag=b.headers?.get("ETag")??this.flagsEtag,this.loadedSuccessfullyOnce=!0,this.clearBackoff();return;case 401:throw this.beginBackoff(),new aW(`Your project key or personal API key is invalid. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 402:console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - unsetting all local flags. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts"),this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={};return;case 403:throw this.beginBackoff(),new aW(`Your personal API key does not have permission to fetch feature flag definitions for local evaluation. Setting next polling interval to ${this.getPollingInterval()}ms. Are you sure you're using the correct personal and Project API key pair? More information: https://posthog.com/docs/api/overview`);case 429:throw this.beginBackoff(),new aW(`You are being rate limited. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 200:{let c=await b.json()??{};if(!("flags"in c))return void this.onError?.(Error(`Invalid response when getting feature flags: ${JSON.stringify(c)}`));this.flagsEtag=b.headers?.get("ETag")??void 0;let d={flags:c.flags??[],groupTypeMapping:c.group_type_mapping||{},cohorts:c.cohorts||{}};if(this.updateFlagState(d),this.flagDefinitionsLoadedAt=Date.now(),this.clearBackoff(),this.cacheProvider&&a)try{await this.cacheProvider.onFlagDefinitionsReceived(d)}catch(a){this.onError?.(Error(`Failed to store in cache: ${a}`))}this.onLoad?.(this.featureFlags.length),this.warnAboutExperienceContinuityFlags(d.flags);break}default:return}}catch(a){a instanceof aW&&this.onError?.(a)}}getPersonalApiKeyRequestOptions(a="GET",b){let c={...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`};return b&&(c["If-None-Match"]=b),{method:a,headers:c}}_requestFeatureFlagDefinitions(){let a=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,b=this.getPersonalApiKeyRequestOptions("GET",this.flagsEtag),c=null;if(this.timeout&&"number"==typeof this.timeout){let a=new AbortController;c=J(()=>{a.abort()},this.timeout),b.signal=a.signal}try{return(0,this.fetch)(a,b)}finally{clearTimeout(c)}}async stopPoller(a=3e4){if(clearTimeout(this.poller),this.cacheProvider)try{let b=this.cacheProvider.shutdown();b instanceof Promise&&await Promise.race([b,new Promise((b,c)=>setTimeout(()=>c(Error(`Cache shutdown timeout after ${a}ms`)),a))])}catch(a){this.onError?.(Error(`Error during cache shutdown: ${a}`))}}}async function a$(a,b,c=""){return parseInt((await aU(`${a}.${b}${c}`)).slice(0,15),16)/0x1000000000000000}function a_(a,b,c){let d=a.key,e=a.value,f=a.operator||"exact";if(d in b){if("is_not_set"===f)throw new aX("Operator is_not_set is not supported")}else throw new aX(`Property ${d} not found in propertyValues`);let g=b[d];if(null==g&&!aV.includes(f))return c&&c(`Property ${d} cannot have a value of null/undefined with the ${f} operator`),!1;function h(a,b){return Array.isArray(a)?a.map(a=>String(a).toLowerCase()).includes(String(b).toLowerCase()):String(a).toLowerCase()===String(b).toLowerCase()}function i(a,b,c){if("gt"===c)return a>b;if("gte"===c)return a>=b;if("lt"===c)return a<b;if("lte"===c)return a<=b;throw Error(`Invalid operator: ${c}`)}switch(f){case"exact":return h(e,g);case"is_not":return!h(e,g);case"is_set":return d in b;case"icontains":return String(g).toLowerCase().includes(String(e).toLowerCase());case"not_icontains":return!String(g).toLowerCase().includes(String(e).toLowerCase());case"regex":return a0(String(e))&&null!==String(g).match(String(e));case"not_regex":return a0(String(e))&&null===String(g).match(String(e));case"gt":case"gte":case"lt":case"lte":{let a="number"==typeof e?e:null;if("string"==typeof e)try{a=parseFloat(e)}catch(a){}if(null==a||null==g)return i(String(g),String(e),f);if("string"==typeof g)return i(g,String(e),f);return i(g,a,f)}case"is_date_after":case"is_date_before":{if("boolean"==typeof e)throw new aX("Date operations cannot be performed on boolean values");let a=function(a){let b=a.match(/^-?(?<number>[0-9]+)(?<interval>[a-z])$/),c=new Date(new Date().toISOString());if(!b)return null;{if(!b.groups)return null;let a=parseInt(b.groups.number);if(a>=1e4)return null;let d=b.groups.interval;if("h"==d)c.setUTCHours(c.getUTCHours()-a);else if("d"==d)c.setUTCDate(c.getUTCDate()-a);else if("w"==d)c.setUTCDate(c.getUTCDate()-7*a);else if("m"==d)c.setUTCMonth(c.getUTCMonth()-a);else{if("y"!=d)return null;c.setUTCFullYear(c.getUTCFullYear()-a)}return c}}(String(e));if(null==a&&(a=a3(e)),null==a)throw new aX(`Invalid date: ${e}`);let b=a3(g);if(["is_date_before"].includes(f))return b<a;return b>a}case"semver_eq":return 0===a2(a1(String(g)),a1(String(e)));case"semver_neq":return 0!==a2(a1(String(g)),a1(String(e)));case"semver_gt":return a2(a1(String(g)),a1(String(e)))>0;case"semver_gte":return a2(a1(String(g)),a1(String(e)))>=0;case"semver_lt":return 0>a2(a1(String(g)),a1(String(e)));case"semver_lte":return 0>=a2(a1(String(g)),a1(String(e)));case"semver_tilde":{let a,b=a1(String(g)),{lower:c,upper:d}={lower:[(a=a1(String(e)))[0],a[1],a[2]],upper:[a[0],a[1]+1,0]};return a2(b,c)>=0&&0>a2(b,d)}case"semver_caret":{let a=a1(String(g)),{lower:b,upper:c}=function(a){let[b,c,d]=a1(a);return{lower:[b,c,d],upper:b>0?[b+1,0,0]:c>0?[0,c+1,0]:[0,0,d+1]}}(String(e));return a2(a,b)>=0&&0>a2(a,c)}case"semver_wildcard":{let a=a1(String(g)),{lower:b,upper:c}=function(a){let b,c,d=String(a).trim().replace(/^[vV]/,"").replace(/\.\*$/,"").replace(/\*$/,"");if(!d)throw new aX(`Invalid wildcard semver: ${a}`);let e=d.split("."),f=parseInt(e[0],10);if(isNaN(f))throw new aX(`Invalid wildcard semver: ${a}`);if(1===e.length)b=[f,0,0],c=[f+1,0,0];else{let d=parseInt(e[1],10);if(isNaN(d))throw new aX(`Invalid wildcard semver: ${a}`);b=[f,d,0],c=[f,d+1,0]}return{lower:b,upper:c}}(String(e));return a2(a,b)>=0&&0>a2(a,c)}default:throw new aX(`Unknown operator: ${f}`)}}function a0(a){try{return new RegExp(a),!0}catch(a){return!1}}function a1(a){let b=String(a).trim().replace(/^[vV]/,"").split("-")[0].split("+")[0];if(!b||b.startsWith("."))throw new aX(`Invalid semver: ${a}`);let c=b.split("."),d=b=>{if(void 0===b||""===b)return 0;if(!/^\d+$/.test(b))throw new aX(`Invalid semver: ${a}`);return parseInt(b,10)};return[d(c[0]),d(c[1]),d(c[2])]}function a2(a,b){for(let c=0;c<3;c++){if(a[c]<b[c])return -1;if(a[c]>b[c])return 1}return 0}function a3(a){if(a instanceof Date)return a;if("string"==typeof a||"number"==typeof a){let b=new Date(a);if(!isNaN(b.valueOf()))return b;throw new aX(`${a} is in an invalid date format`)}throw new aX(`The date provided ${a} must be a string, number, or date object`)}class a4{getProperty(a){return this._memoryStorage[a]}setProperty(a,b){this._memoryStorage[a]=null!==b?b:void 0}constructor(){this._memoryStorage={}}}class a5 extends V{constructor(a,b={}){if(super(a,b),this._memoryStorage=new a4,this.options=b,this.context=this.initializeContext(),this.options.featureFlagsPollingInterval="number"==typeof b.featureFlagsPollingInterval?Math.max(b.featureFlagsPollingInterval,100):3e4,"number"==typeof b.waitUntilDebounceMs&&(this.options.waitUntilDebounceMs=Math.max(b.waitUntilDebounceMs,0)),"number"==typeof b.waitUntilMaxWaitMs&&(this.options.waitUntilMaxWaitMs=Math.max(b.waitUntilMaxWaitMs,0)),b.personalApiKey){if(b.personalApiKey.includes("phc_"))throw Error('Your Personal API key is invalid. These keys are prefixed with "phx_" and can be created in PostHog project settings.');!1!==b.enableLocalEvaluation&&(this.featureFlagsPoller=new aZ({pollingInterval:this.options.featureFlagsPollingInterval,personalApiKey:b.personalApiKey,projectApiKey:a,timeout:b.requestTimeout??1e4,host:this.host,fetch:b.fetch,onError:a=>{this._events.emit("error",a)},onLoad:a=>{this._events.emit("localEvaluationFlagsLoaded",a)},customHeaders:this.getCustomHeaders(),cacheProvider:b.flagDefinitionCacheProvider,strictLocalEvaluation:b.strictLocalEvaluation}))}this.errorTracking=new aQ(this,b,this._logger),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=b.maxCacheSize||5e4}enqueue(a,b,c){super.enqueue(a,b,c),this.scheduleDebouncedFlush()}async flush(){let a=super.flush(),b=this.options.waitUntil;if(b&&!this._waitUntilCycle)try{b(a.catch(()=>{}))}catch{}return a}scheduleDebouncedFlush(){let a=this.options.waitUntil;if(!a||this.disabled||this.optedOut)return;if(!this._waitUntilCycle){let b,c=new Promise(a=>{b=a});try{a(c)}catch{return}this._waitUntilCycle={resolve:b,startedAt:Date.now(),timer:void 0}}let b=Date.now()-this._waitUntilCycle.startedAt,c=this.options.waitUntilMaxWaitMs??500;if(void 0!==this._waitUntilCycle.timer&&clearTimeout(this._waitUntilCycle.timer),b>=c)return void this.resolveWaitUntilFlush();let d=this.options.waitUntilDebounceMs??50;this._waitUntilCycle.timer=J(()=>{this.resolveWaitUntilFlush()},d)}_consumeWaitUntilCycle(){let a=this._waitUntilCycle;return a&&(clearTimeout(a.timer),this._waitUntilCycle=void 0),a?.resolve}async resolveWaitUntilFlush(){let a=this._consumeWaitUntilCycle();try{await super.flush()}catch{}finally{a?.()}}getPersistedProperty(a){return this._memoryStorage.getProperty(a)}setPersistedProperty(a,b){return this._memoryStorage.setProperty(a,b)}fetch(a,b){return this.options.fetch?this.options.fetch(a,b):fetch(a,b)}getLibraryVersion(){return"5.28.5"}getCustomUserAgent(){return`${this.getLibraryId()}/${this.getLibraryVersion()}`}enable(){return super.optIn()}disable(){return super.optOut()}debug(a=!0){super.debug(a),this.featureFlagsPoller?.debug(a)}capture(a){"string"==typeof a&&this._logger.warn("Called capture() with a string as the first argument when an object was expected."),"$exception"!==a.event||a._originatedFromCaptureException||this._logger.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.addPendingPromise(this.prepareEventMessage(a).then(({distinctId:a,event:b,properties:c,options:d})=>super.captureStateless(a,b,c,{timestamp:d.timestamp,disableGeoip:d.disableGeoip,uuid:d.uuid})).catch(a=>{a&&console.error(a)}))}async captureImmediate(a){return"string"==typeof a&&this._logger.warn("Called captureImmediate() with a string as the first argument when an object was expected."),"$exception"!==a.event||a._originatedFromCaptureException||this._logger.warn("Capturing a `$exception` event via `posthog.captureImmediate('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureExceptionImmediate(error)` instead, which attaches this metadata by default."),this.addPendingPromise(this.prepareEventMessage(a).then(({distinctId:a,event:b,properties:c,options:d})=>super.captureStatelessImmediate(a,b,c,{timestamp:d.timestamp,disableGeoip:d.disableGeoip,uuid:d.uuid})).catch(a=>{a&&console.error(a)}))}identify({distinctId:a,properties:b={},disableGeoip:c}){let{$set:d,$set_once:e,$anon_distinct_id:f,...g}=b;super.identifyStateless(a,{$set:d||g,$set_once:e||{},$anon_distinct_id:f??void 0},{disableGeoip:c})}async identifyImmediate({distinctId:a,properties:b={},disableGeoip:c}){let{$set:d,$set_once:e,$anon_distinct_id:f,...g}=b;super.identifyStatelessImmediate(a,{$set:d||g,$set_once:e||{},$anon_distinct_id:f??void 0},{disableGeoip:c})}alias(a){super.aliasStateless(a.alias,a.distinctId,void 0,{disableGeoip:a.disableGeoip})}async aliasImmediate(a){await super.aliasStatelessImmediate(a.alias,a.distinctId,void 0,{disableGeoip:a.disableGeoip})}isLocalEvaluationReady(){return this.featureFlagsPoller?.isLocalEvaluationReady()??!1}async waitForLocalEvaluationReady(a=3e4){return!!this.isLocalEvaluationReady()||void 0!==this.featureFlagsPoller&&new Promise(b=>{let c=setTimeout(()=>{d(),b(!1)},a),d=this._events.on("localEvaluationFlagsLoaded",a=>{clearTimeout(c),d(),b(a>0)})})}_resolveDistinctId(a,b){return"string"==typeof a?{distinctId:a,options:b}:{distinctId:this.context?.get()?.distinctId,options:a}}async _getFeatureFlagResult(a,b,c={},d){let e,f,g,h,i,j,k,l=c.sendFeatureFlagEvents??!0;if(void 0!==this._flagOverrides&&a in this._flagOverrides){let b=this._flagOverrides[a];if(void 0===b)return;let c=this._payloadOverrides?.[a];return{key:a,enabled:!1!==b,variant:"string"==typeof b?b:void 0,payload:c}}let{groups:m,disableGeoip:n}=c,{onlyEvaluateLocally:o,personProperties:p,groupProperties:q}=c,r=this.addLocalPersonAndGroupProperties(b,m,p,q);p=r.allPersonProperties,q=r.allGroupProperties;let s=this.createFeatureFlagEvaluationContext(b,m,p,q);void 0==o&&(o=this.options.strictLocalEvaluation??!1);let t=!1;if(void 0!==this.featureFlagsPoller){await this.featureFlagsPoller?.loadFeatureFlags();let b=this.featureFlagsPoller?.featureFlagsByKey[a];if(b)try{let c=await this.featureFlagsPoller?.computeFlagAndPayloadLocally(b,s,{matchValue:d});if(c){t=!0;let d=c.value;i=b.id,k="Evaluated locally",e={key:a,enabled:!1!==d,variant:"string"==typeof d?d:void 0,payload:c.payload??void 0}}}catch(b){if(b instanceof aY||b instanceof aX)this._logger?.info(`${b.name} when computing flag locally: ${a}: ${b.message}`);else throw b}}if(!t&&!o){let b=await super.getFeatureFlagDetailsStateless(s.distinctId,s.groups,s.personProperties,s.groupProperties,n,[a]);if(void 0===b)h=aT.UNKNOWN_ERROR;else{f=b.requestId,g=b.evaluatedAt;let c=[];b.errorsWhileComputingFlags&&c.push(aT.ERRORS_WHILE_COMPUTING),b.quotaLimited?.includes("feature_flags")&&c.push(aT.QUOTA_LIMITED);let d=b.flags[a];if(void 0===d)c.push(aT.FLAG_MISSING);else{let b;if(i=d.metadata?.id,j=d.metadata?.version,k=d.reason?.description??d.reason?.code,d.metadata?.payload!==void 0)try{b=JSON.parse(d.metadata.payload)}catch{b=d.metadata.payload}e={key:a,enabled:d.enabled,variant:d.variant,payload:b}}c.length>0&&(h=c.join(","))}}if(l){let c=void 0===e?void 0:!1!==e.enabled&&(e.variant??!0),d=`${a}_${c}`;if(!(b in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[b].includes(d)){Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[b])?this.distinctIdHasSentFlagCalls[b].push(d):this.distinctIdHasSentFlagCalls[b]=[d];let e={$feature_flag:a,$feature_flag_response:c,$feature_flag_id:i,$feature_flag_version:j,$feature_flag_reason:k,locally_evaluated:t,[`$feature/${a}`]:c,$feature_flag_request_id:f,$feature_flag_evaluated_at:t?Date.now():g};if(t&&this.featureFlagsPoller){let a=this.featureFlagsPoller.getFlagDefinitionsLoadedAt();void 0!==a&&(e.$feature_flag_definitions_loaded_at=a)}h&&(e.$feature_flag_error=h),this.capture({distinctId:b,event:"$feature_flag_called",properties:e,groups:m,disableGeoip:n})}}return void 0!==e&&void 0!==this._payloadOverrides&&a in this._payloadOverrides&&(e={...e,payload:this._payloadOverrides[a]}),e}async getFeatureFlag(a,b,c){let d=await this._getFeatureFlagResult(a,b,{...c,sendFeatureFlagEvents:c?.sendFeatureFlagEvents??this.options.sendFeatureFlagEvent??!0});if(void 0!==d)return!1!==d.enabled&&(d.variant??!0)}async getFeatureFlagPayload(a,b,c,d){if(void 0!==this._payloadOverrides&&a in this._payloadOverrides)return this._payloadOverrides[a];let e=await this._getFeatureFlagResult(a,b,{...d,sendFeatureFlagEvents:!1},c);if(void 0!==e)return e.payload??null}async getFeatureFlagResult(a,b,c){let{distinctId:d,options:e}=this._resolveDistinctId(b,c);return d?this._getFeatureFlagResult(a,d,{...e,sendFeatureFlagEvents:e?.sendFeatureFlagEvents??this.options.sendFeatureFlagEvent??!0}):void this._logger.warn("[PostHog] distinctId is required — pass it explicitly or use withContext()")}async getRemoteConfigPayload(a){if(!this.options.personalApiKey)throw Error("Personal API key is required for remote config payload decryption");let b=await this._requestRemoteConfigPayload(a);if(!b)return;let c=await b.json();if("string"==typeof c)try{return JSON.parse(c)}catch(a){}return c}async isFeatureEnabled(a,b,c){let d=await this.getFeatureFlag(a,b,c);if(void 0!==d)return!!d}async getAllFlags(a,b){let{distinctId:c,options:d}=this._resolveDistinctId(a,b);return c?(await this.getAllFlagsAndPayloads(c,d)).featureFlags||{}:(this._logger.warn("[PostHog] distinctId is required to get feature flags — pass it explicitly or use withContext()"),{})}async getAllFlagsAndPayloads(a,b){let{distinctId:c,options:d}=this._resolveDistinctId(a,b);if(!c)return this._logger.warn("[PostHog] distinctId is required to get feature flags and payloads — pass it explicitly or use withContext()"),{featureFlags:{},featureFlagPayloads:{}};let{groups:e,disableGeoip:f,flagKeys:g}=d||{},{onlyEvaluateLocally:h,personProperties:i,groupProperties:j}=d||{},k=this.addLocalPersonAndGroupProperties(c,e,i,j);i=k.allPersonProperties,j=k.allGroupProperties;let l=this.createFeatureFlagEvaluationContext(c,e,i,j);void 0==h&&(h=this.options.strictLocalEvaluation??!1);let m=await this.featureFlagsPoller?.getAllFlagsAndPayloads(l,g),n={},o={},p=!0;if(m&&(n=m.response,o=m.payloads,p=m.fallbackToFlags),p&&!h){let a=await super.getFeatureFlagsAndPayloadsStateless(l.distinctId,l.groups,l.personProperties,l.groupProperties,f,g);n={...n,...a.flags||{}},o={...o,...a.payloads||{}}}return void 0!==this._flagOverrides&&(n={...n,...this._flagOverrides}),void 0!==this._payloadOverrides&&(o={...o,...this._payloadOverrides}),{featureFlags:n,featureFlagPayloads:o}}groupIdentify({groupType:a,groupKey:b,properties:c,distinctId:d,disableGeoip:e}){super.groupIdentifyStateless(a,b,c,{disableGeoip:e},d)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}overrideFeatureFlags(a){let b=a=>Object.fromEntries(a.map(a=>[a,!0]));if(!1===a){this._flagOverrides=void 0,this._payloadOverrides=void 0;return}if(Array.isArray(a)){this._flagOverrides=b(a);return}if(this._isFeatureFlagOverrideOptions(a)){"flags"in a&&(!1===a.flags?this._flagOverrides=void 0:Array.isArray(a.flags)?this._flagOverrides=b(a.flags):void 0!==a.flags&&(this._flagOverrides={...a.flags})),"payloads"in a&&(!1===a.payloads?this._payloadOverrides=void 0:void 0!==a.payloads&&(this._payloadOverrides={...a.payloads}));return}this._flagOverrides={...a}}_isFeatureFlagOverrideOptions(a){if("object"!=typeof a||null===a||Array.isArray(a))return!1;if("flags"in a){let b=a.flags;if(!1===b||Array.isArray(b)||"object"==typeof b&&null!==b)return!0}if("payloads"in a){let b=a.payloads;if(!1===b||"object"==typeof b&&null!==b)return!0}return!1}withContext(a,b,c){return this.context?this.context.run(a,b,c):b()}getContext(){return this.context?.get()}enterContext(a,b){this.context?.enter(a,b)}async _shutdown(a){let b=this._consumeWaitUntilCycle();await this.featureFlagsPoller?.stopPoller(a),this.errorTracking.shutdown();try{return await super._shutdown(a)}finally{b?.()}}async _requestRemoteConfigPayload(a){if(!this.options.personalApiKey)return;let b=`${this.host}/api/projects/@current/feature_flags/${a}/remote_config?token=${encodeURIComponent(this.apiKey)}`,c={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json",Authorization:`Bearer ${this.options.personalApiKey}`}},d=null;if(this.options.requestTimeout&&"number"==typeof this.options.requestTimeout){let a=new AbortController;d=J(()=>{a.abort()},this.options.requestTimeout),c.signal=a.signal}try{return await this.fetch(b,c)}catch(a){this._events.emit("error",a);return}finally{d&&clearTimeout(d)}}extractPropertiesFromEvent(a,b){if(!a)return{personProperties:{},groupProperties:{}};let c={},d={};for(let[e,f]of Object.entries(a))if(y(f,"Object")&&b&&e in b){let a={};for(let[b,c]of Object.entries(f))a[String(b)]=String(c);d[String(e)]=a}else c[String(e)]=String(f);return{personProperties:c,groupProperties:d}}async getFeatureFlagsForEvent(a,b,c,d){let e=d?.personProperties||{},f=d?.groupProperties||{},g=d?.flagKeys;if(d?.onlyEvaluateLocally??this.options.strictLocalEvaluation)if(!((this.featureFlagsPoller?.featureFlags?.length||0)>0))return{};else{let d={};for(let[a,c]of Object.entries(b||{}))d[a]=String(c);return await this.getAllFlags(a,{groups:d,personProperties:e,groupProperties:f,disableGeoip:c,onlyEvaluateLocally:!0,flagKeys:g})}if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let d={};for(let[a,c]of Object.entries(b||{}))d[a]=String(c);return await this.getAllFlags(a,{groups:d,personProperties:e,groupProperties:f,disableGeoip:c,onlyEvaluateLocally:!0,flagKeys:g})}return(await super.getFeatureFlagsStateless(a,b,e,f,c)).flags}addLocalPersonAndGroupProperties(a,b,c,d){let e={distinct_id:a,...c||{}},f={};if(b)for(let a of Object.keys(b))f[a]={$group_key:b[a],...d?.[a]||{}};return{allPersonProperties:e,allGroupProperties:f}}createFeatureFlagEvaluationContext(a,b,c,d){return{distinctId:a,groups:b||{},personProperties:c||{},groupProperties:d||{},evaluationCache:{}}}captureException(a,b,c,d){if(!aQ.isPreviouslyCapturedError(a)){let e=Error("PostHog syntheticException");this.addPendingPromise(aQ.buildEventMessage(a,{syntheticException:e},b,c).then(a=>this.capture({...a,uuid:d})))}}async captureExceptionImmediate(a,b,c){if(!aQ.isPreviouslyCapturedError(a)){let d=Error("PostHog syntheticException");return this.addPendingPromise(aQ.buildEventMessage(a,{syntheticException:d},b,c).then(a=>this.captureImmediate(a)))}}async prepareEventMessage(a){let{distinctId:b,event:c,properties:d,groups:e,sendFeatureFlags:f,timestamp:g,disableGeoip:h,uuid:i}=a,j=this.context?.get(),k=b||j?.distinctId,l={...this.props,...j?.properties||{},...d||{}};k||(k=p().toString(),l.$process_person_profile=!1),j?.sessionId&&!l.$session_id&&(l.$session_id=j.sessionId);let m=this._runBeforeSend({distinctId:k,event:c,properties:l,groups:e,sendFeatureFlags:f,timestamp:g,disableGeoip:h,uuid:i});if(!m)return Promise.reject(null);let n=await Promise.resolve().then(async()=>f?await this.getFeatureFlagsForEvent(m.distinctId,e,h,"object"==typeof f?f:void 0):(m.event,{})).then(a=>{let b={};if(a)for(let[c,d]of Object.entries(a))b[`$feature/${c}`]=d;let c=Object.keys(a||{}).filter(b=>a?.[b]!==!1).sort();return c.length>0&&(b.$active_feature_flags=c),b}).catch(()=>({})).then(a=>({...a,...m.properties||{},$groups:m.groups||e}));return"$pageview"===m.event&&this.options.__preview_capture_bot_pageviews&&"string"==typeof n.$raw_user_agent&&aS(n.$raw_user_agent,this.options.custom_blocked_useragents||[])&&(m.event="$bot_pageview",n.$browser_type="bot"),{distinctId:m.distinctId,event:m.event,properties:n,options:{timestamp:m.timestamp,disableGeoip:m.disableGeoip,uuid:m.uuid}}}_runBeforeSend(a){let b=this.options.before_send;if(!b)return a;let c=Array.isArray(b)?b:[b],d=a;for(let b of c){if(!(d=b(d)))return this._logger.info(`Event '${a.event}' was rejected in beforeSend function`),null;if(!d.properties||0===Object.keys(d.properties).length){let a=`Event '${d.event}' has no properties after beforeSend function, this is likely an error.`;this._logger.warn(a)}}return d}}var aF=aE,a6=a.i(78500);class a7{constructor(){this.storage=new a6.AsyncLocalStorage}get(){return this.storage.getStore()}run(a,b,c){return this.storage.run(this.resolve(a,c),b)}enter(a,b){this.storage.enterWith(this.resolve(a,b))}resolve(a,b){if(b?.fresh===!0)return a;let c=this.get()||{};return{distinctId:a.distinctId??c.distinctId,sessionId:a.sessionId??c.sessionId,properties:{...c.properties||{},...a.properties||{}}}}}function a8(a,b){var c;b.use((c=a,(a,b,d,e)=>{if(aQ.isPreviouslyCapturedError(a))return void e(a);let f=b.headers["x-posthog-session-id"],g=b.headers["x-posthog-distinct-id"],h=Error("Synthetic exception");c.addPendingPromise(aQ.buildEventMessage(a,{mechanism:{type:"middleware",handled:!1},syntheticException:h},g,{$session_id:f,$current_url:b.url,$request_method:b.method,$request_path:b.path,$user_agent:b.headers["user-agent"],$response_status_code:d.statusCode,$ip:b.headers["x-forwarded-for"]||b?.socket?.remoteAddress}).then(a=>{c.capture(a)})),e(a)}))}a.s(["setupExpressErrorHandler",0,a8],40602),a.s([],51328),aQ.errorPropertiesBuilder=new aF.ErrorPropertiesBuilder([new aF.EventCoercer,new aF.ErrorCoercer,new aF.ObjectCoercer,new aF.StringCoercer,new aF.PrimitiveCoercer],aF.createStackParser("node:javascript",aF.nodeStackLineParser),[(f=function(a=process.argv[1]?(0,h.dirname)(process.argv[1]):process.cwd(),b="\\"===h.sep){let c=b?i(a):a;return a=>{if(!a)return;let d=b?i(a):a,{dir:e,base:f,ext:g}=h.posix.parse(d);(".js"===g||".mjs"===g||".cjs"===g)&&(f=f.slice(0,-1*g.length));let j=decodeURIComponent(f);e||(e=".");let k=e.lastIndexOf("/node_modules");if(k>-1)return`${e.slice(k+14).replace(/\//g,".")}:${j}`;if(e.startsWith(c)){let a=e.slice(c.length+1).replace(/\//g,".");return a?`${a}:${j}`:j}return j}}(),async a=>{for(let b of a)b.module=f(b.filename);return a}),aK]);class a9 extends a5{getLibraryId(){return"posthog-node"}initializeContext(){return new a7}}a.s(["PostHog",0,a9],81035),a.i(81035),a.i(51328);let ba="posthog-node";function bb(a,{organization:b,projectId:c,prefix:d,severityAllowList:e=["error"],sendExceptionsToPostHog:f=!0}={}){return g=>{if(!("*"===e||e.includes(g.level)))return g;g.tags||(g.tags={});let h=g.tags[bd.POSTHOG_ID_TAG];if(void 0===h)return g;let i=a.options.host??"https://us.i.posthog.com",j=new URL(`/project/${a.apiKey}/person/${h}`,i).toString();g.tags["PostHog Person URL"]=j;let k=g.exception?.values||[],l=k.map(a=>({...a,stacktrace:a.stacktrace?{...a.stacktrace,type:"raw",frames:(a.stacktrace.frames||[]).map(a=>({...a,platform:"node:javascript"}))}:void 0})),m={$exception_message:k[0]?.value||g.message,$exception_type:k[0]?.type,$exception_level:g.level,$exception_list:l,$sentry_event_id:g.event_id,$sentry_exception:g.exception,$sentry_exception_message:k[0]?.value||g.message,$sentry_exception_type:k[0]?.type,$sentry_tags:g.tags};return b&&c&&(m.$sentry_url=(d||"https://sentry.io/organizations/")+b+"/issues/?project="+c+"&query="+g.event_id),f&&a.capture({event:"$exception",distinctId:h,properties:m}),g}}function bc(a,b){let c=bb(a,b);return{name:ba,processEvent:a=>c(a)}}class bd{static #a=this.POSTHOG_ID_TAG="posthog_distinct_id";constructor(a,b,c,d,e){this.name=ba,this.name=ba,this.setupOnce=function(f,g){f(bb(a,{organization:b,projectId:g()?.getClient()?.getDsn()?.projectId,prefix:c,severityAllowList:d,sendExceptionsToPostHog:e??!0}))}}}a.s(["PostHogSentryIntegration",0,bd,"createEventProcessor",0,bb,"sentryIntegration",0,bc],9318),a.i(9318),a.i(40602),a.i(46539),a.s(["FeatureFlagError",0,r,"PostHogSentryIntegration",0,bd,"createEventProcessor",0,bb,"sentryIntegration",0,bc,"setupExpressErrorHandler",0,a8],80456),a.i(80456),a.s(["FeatureFlagError",0,r,"PostHog",0,a9,"PostHogSentryIntegration",0,bd,"createEventProcessor",0,bb,"sentryIntegration",0,bc,"setupExpressErrorHandler",0,a8],74493)}];
1
+ module.exports=[74493,a=>{"use strict";let b,c,d,e,f;var g,h=a.i(14747);function i(a){return a.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}let j=a=>void 0===a?void 0:a.variant??a.enabled,k=a=>{if("string"!=typeof a)return a;try{return JSON.parse(a)}catch{return a}};async function l(a,b=!0){try{let b=new Blob([a],{type:"text/plain"}).stream().pipeThrough(new CompressionStream("gzip"));return await new Response(b).blob()}catch(a){return b&&console.error("Failed to gzip compress data",a),null}}let m="0123456789abcdef";class n{constructor(a){this.bytes=a}static ofInner(a){if(16===a.length)return new n(a);throw TypeError("not 128-bit length")}static fromFieldsV7(a,b,c,d){if(!Number.isInteger(a)||!Number.isInteger(b)||!Number.isInteger(c)||!Number.isInteger(d)||a<0||b<0||c<0||d<0||a>0xffffffffffff||b>4095||c>0x3fffffff||d>0xffffffff)throw RangeError("invalid field value");let e=new Uint8Array(16);return e[0]=a/0x10000000000,e[1]=a/0x100000000,e[2]=a/0x1000000,e[3]=a/65536,e[4]=a/256,e[5]=a,e[6]=112|b>>>8,e[7]=b,e[8]=128|c>>>24,e[9]=c>>>16,e[10]=c>>>8,e[11]=c,e[12]=d>>>24,e[13]=d>>>16,e[14]=d>>>8,e[15]=d,new n(e)}static parse(a){let b;switch(a.length){case 32:b=/^[0-9a-f]{32}$/i.exec(a)?.[0];break;case 36:b=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(a)?.slice(1,6).join("");break;case 38:b=/^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(a)?.slice(1,6).join("");break;case 45:b=/^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(a)?.slice(1,6).join("")}if(b){let a=new Uint8Array(16);for(let c=0;c<16;c+=4){let d=parseInt(b.substring(2*c,2*c+8),16);a[c+0]=d>>>24,a[c+1]=d>>>16,a[c+2]=d>>>8,a[c+3]=d}return new n(a)}throw SyntaxError("could not parse UUID string")}toString(){let a="";for(let b=0;b<this.bytes.length;b++)a+=m.charAt(this.bytes[b]>>>4),a+=m.charAt(15&this.bytes[b]),(3===b||5===b||7===b||9===b)&&(a+="-");return a}toHex(){let a="";for(let b=0;b<this.bytes.length;b++)a+=m.charAt(this.bytes[b]>>>4),a+=m.charAt(15&this.bytes[b]);return a}toJSON(){return this.toString()}getVariant(){let a=this.bytes[8]>>>4;if(a<0)throw Error("unreachable");if(a<=7)return this.bytes.every(a=>0===a)?"NIL":"VAR_0";if(a<=11)return"VAR_10";if(a<=13)return"VAR_110";if(a<=15)return this.bytes.every(a=>255===a)?"MAX":"VAR_RESERVED";throw Error("unreachable")}getVersion(){return"VAR_10"===this.getVariant()?this.bytes[6]>>>4:void 0}clone(){return new n(this.bytes.slice(0))}equals(a){return 0===this.compareTo(a)}compareTo(a){for(let b=0;b<16;b++){let c=this.bytes[b]-a.bytes[b];if(0!==c)return Math.sign(c)}return 0}}class o{constructor(a){this.timestamp=0,this.counter=0,this.random=a??p()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(a,b){let c=this.generateOrAbortCore(a,b);return void 0===c&&(this.timestamp=0,c=this.generateOrAbortCore(a,b)),c}generateOrAbortCore(a,b){if(!Number.isInteger(a)||a<1||a>0xffffffffffff)throw RangeError("`unixTsMs` must be a 48-bit positive integer");if(b<0||b>0xffffffffffff)throw RangeError("`rollbackAllowance` out of reasonable range");if(a>this.timestamp)this.timestamp=a,this.resetCounter();else{if(!(a+b>=this.timestamp))return;this.counter++,this.counter>0x3ffffffffff&&(this.timestamp++,this.resetCounter())}return n.fromFieldsV7(this.timestamp,Math.trunc(this.counter/0x40000000),this.counter&0x40000000-1,this.random.nextUint32())}resetCounter(){this.counter=1024*this.random.nextUint32()+(1023&this.random.nextUint32())}generateV4(){let a=new Uint8Array(Uint32Array.of(this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32()).buffer);return a[6]=64|a[6]>>>4,a[8]=128|a[8]>>>2,n.ofInner(a)}}let p=()=>({nextUint32:()=>65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random())}),q=()=>(b||(b=new o)).generate();var r=((g={}).AnonymousId="anonymous_id",g.DistinctId="distinct_id",g.Props="props",g.EnablePersonProcessing="enable_person_processing",g.PersonMode="person_mode",g.FeatureFlagDetails="feature_flag_details",g.FeatureFlags="feature_flags",g.FeatureFlagPayloads="feature_flag_payloads",g.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",g.BootstrapFeatureFlags="bootstrap_feature_flags",g.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",g.OverrideFeatureFlags="override_feature_flags",g.Queue="queue",g.OptedOut="opted_out",g.SessionId="session_id",g.SessionStartTimestamp="session_start_timestamp",g.SessionLastTimestamp="session_timestamp",g.PersonProperties="person_properties",g.GroupProperties="group_properties",g.InstalledAppBuild="installed_app_build",g.InstalledAppVersion="installed_app_version",g.SessionReplay="session_replay",g.SurveyLastSeenDate="survey_last_seen_date",g.SurveysSeen="surveys_seen",g.Surveys="surveys",g.RemoteConfig="remote_config",g.FlagsEndpointWasHit="flags_endpoint_was_hit",g);let s={ERRORS_WHILE_COMPUTING:"errors_while_computing_flags",FLAG_MISSING:"flag_missing",QUOTA_LIMITED:"quota_limited",TIMEOUT:"timeout",CONNECTION_ERROR:"connection_error",UNKNOWN_ERROR:"unknown_error",apiError:a=>`api_error_${a}`},t=Array.isArray,u=Object.prototype;u.hasOwnProperty;let v=u.toString,w=t||function(a){return"[object Array]"===v.call(a)},x=a=>"[object String]"==v.call(a);function y(a){return null===a||"object"!=typeof a}function z(a,b){return Object.prototype.toString.call(a)===`[object ${b}]`}function A(a){return"u">typeof Event&&function(a,b){try{return a instanceof b}catch{return!1}}(a,Event)}let B="Android",C="BlackBerry",D="Nintendo",E="PlayStation",F="Xbox",G="Windows",H="(\\d+(\\.\\d+)?)";RegExp("Version/"+H),RegExp(F,"i"),RegExp(E+" \\w+","i"),RegExp(D+" \\w+","i"),RegExp(C+"|PlayBook|BB10","i");async function I(a,b){let c=null;for(let d=0;d<b.retryCount+1;d++){d>0&&await new Promise(a=>setTimeout(a,b.retryDelay));try{return await a()}catch(a){if(c=a,!b.retryCheck(a))throw a}}throw c}function J(){return new Date().toISOString()}function K(a,b){let c=setTimeout(a,b);return c?.unref&&c?.unref(),c}RegExp("rv:"+H),RegExp("Edge?\\/"+H),RegExp("(Chrome|CrMo)\\/"+H),RegExp("CriOS\\/"+H),RegExp("(UCBrowser|UCWEB)\\/"+H),RegExp("(Opera|OPR)\\/"+H),RegExp("Firefox\\/"+H),RegExp("FxiOS\\/"+H),RegExp("Konqueror[:/]?"+H,"i"),RegExp(C+" "+H),RegExp("android\\s"+H,"i"),RegExp("SamsungBrowser\\/"+H),RegExp("(rv:|MSIE )"+H),RegExp("rv:"+H),RegExp(F+"; "+F+" (.*?)[);]","i"),RegExp(D,"i"),RegExp(E,"i"),RegExp(G,"i"),RegExp("("+B+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+B+")","i");let L=a=>a instanceof Error;function M(a){return Promise.all(a.map(a=>(a??Promise.resolve()).then(a=>({status:"fulfilled",value:a}),a=>({status:"rejected",reason:a}))))}class N{constructor(){this.events={},this.events={}}on(a,b){return this.events[a]||(this.events[a]=[]),this.events[a].push(b),()=>{this.events[a]=this.events[a].filter(a=>a!==b)}}emit(a,b){for(let c of this.events[a]||[])c(b);for(let c of this.events["*"]||[])c(a,b)}}class O{add(a){let b=q().toString();return this.promiseByIds[b]=a,a.catch(()=>{}).finally(()=>{delete this.promiseByIds[b]}),a}async join(){let a=Object.values(this.promiseByIds),b=a.length;for(;b>0;)await Promise.all(a),b=(a=Object.values(this.promiseByIds)).length}get length(){return Object.keys(this.promiseByIds).length}constructor(){this.promiseByIds={}}}let P=(a,b,c)=>{function d(e,...f){b(()=>{(0,c[e])(a,...f)})}return{info:(...a)=>{d("log",...a)},warn:(...a)=>{d("warn",...a)},error:(...a)=>{d("error",...a)},critical:(...b)=>{c.error(a,...b)},createLogger:d=>P(`${a} ${d}`,b,c)}};class Q extends Error{constructor(a,b){super("HTTP error while fetching PostHog: status="+a.status+", reqByteLength="+b),this.response=a,this.reqByteLength=b,this.name="PostHogFetchHttpError"}get status(){return this.response.status}get text(){return this.response.text()}get json(){return this.response.json()}}class R extends Error{constructor(a){super("Network error while fetching PostHog",a instanceof Error?{cause:a}:{}),this.error=a,this.name="PostHogFetchNetworkError"}}async function S(a){if(a instanceof Q){let b="";try{b=await a.text}catch{}console.error(`Error while flushing PostHog: message=${a.message}, response body=${b}`,a)}else console.error("Error while flushing PostHog",a);return Promise.resolve()}function T(a){return"object"==typeof a&&(a instanceof Q||a instanceof R)}function U(a){return"object"==typeof a&&a instanceof Q&&413===a.status}class V{constructor(a,b={}){this.flushPromise=null,this.shutdownPromise=null,this.promiseQueue=new O,this._events=new N,this._isInitialized=!1,function(a,b){if(!a||"string"!=typeof a||0===a.trim().length)throw Error(b)}(a,"You must pass your PostHog project's api key."),this.apiKey=a,this.host=function(a){return a?.replace(/\/+$/,"")}(b.host||"https://us.i.posthog.com"),this.flushAt=b.flushAt?Math.max(b.flushAt,1):20,this.maxBatchSize=Math.max(this.flushAt,b.maxBatchSize??100),this.maxQueueSize=Math.max(this.flushAt,b.maxQueueSize??1e3),this.flushInterval=b.flushInterval??1e4,this.preloadFeatureFlags=b.preloadFeatureFlags??!0,this.defaultOptIn=b.defaultOptIn??!0,this.disableSurveys=b.disableSurveys??!1,this._retryOptions={retryCount:b.fetchRetryCount??3,retryDelay:b.fetchRetryDelay??3e3,retryCheck:T},this.requestTimeout=b.requestTimeout??1e4,this.featureFlagsRequestTimeoutMs=b.featureFlagsRequestTimeoutMs??3e3,this.remoteConfigRequestTimeoutMs=b.remoteConfigRequestTimeoutMs??3e3,this.disableGeoip=b.disableGeoip??!0,this.disabled=b.disabled??!1,this.historicalMigration=b?.historicalMigration??!1,this._initPromise=Promise.resolve(),this._isInitialized=!0,this._logger=function(a,b=a=>a()){return P(a,b,function(a=console){return{log:a.log.bind(a),warn:a.warn.bind(a),error:a.error.bind(a),debug:a.debug.bind(a)}}())}("[PostHog]",this.logMsgIfDebug.bind(this)),this.evaluationContexts=b?.evaluationContexts??b?.evaluationEnvironments,b?.evaluationEnvironments&&!b?.evaluationContexts&&this._logger.warn("evaluationEnvironments is deprecated. Use evaluationContexts instead. This property will be removed in a future version."),this.disableCompression=!("CompressionStream"in globalThis)||(b?.disableCompression??!1)}logMsgIfDebug(a){this.isDebug&&a()}wrap(a){return this.disabled?void this._logger.warn("The client is disabled"):this._isInitialized?a():void this._initPromise.then(()=>a())}getCommonEventProperties(){return{$lib:this.getLibraryId(),$lib_version:this.getLibraryVersion()}}get optedOut(){return this.getPersistedProperty(r.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(r.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(r.OptedOut,!0)})}on(a,b){return this._events.on(a,b)}debug(a=!0){if(this.removeDebugCallback?.(),a){let a=this.on("*",(a,b)=>this._logger.info(a,b));this.removeDebugCallback=()=>{a(),this.removeDebugCallback=void 0}}}get isDebug(){return!!this.removeDebugCallback}get isDisabled(){return this.disabled}buildPayload(a){return{distinct_id:a.distinct_id,event:a.event,properties:{...a.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(a){return this.promiseQueue.add(a)}identifyStateless(a,b,c){this.wrap(()=>{let d={...this.buildPayload({distinct_id:a,event:"$identify",properties:b})};this.enqueue("identify",d,c)})}async identifyStatelessImmediate(a,b,c){let d={...this.buildPayload({distinct_id:a,event:"$identify",properties:b})};await this.sendImmediate("identify",d,c)}captureStateless(a,b,c,d){this.wrap(()=>{let e=this.buildPayload({distinct_id:a,event:b,properties:c});this.enqueue("capture",e,d)})}async captureStatelessImmediate(a,b,c,d){let e=this.buildPayload({distinct_id:a,event:b,properties:c});await this.sendImmediate("capture",e,d)}aliasStateless(a,b,c,d){this.wrap(()=>{let e=this.buildPayload({event:"$create_alias",distinct_id:b,properties:{...c||{},distinct_id:b,alias:a}});this.enqueue("alias",e,d)})}async aliasStatelessImmediate(a,b,c,d){let e=this.buildPayload({event:"$create_alias",distinct_id:b,properties:{...c||{},distinct_id:b,alias:a}});await this.sendImmediate("alias",e,d)}groupIdentifyStateless(a,b,c,d,e,f){this.wrap(()=>{let g=this.buildPayload({distinct_id:e||`$${a}_${b}`,event:"$groupidentify",properties:{$group_type:a,$group_key:b,$group_set:c||{},...f||{}}});this.enqueue("capture",g,d)})}async getRemoteConfig(){await this._initPromise;let a=this.host;"https://us.i.posthog.com"===a?a="https://us-assets.i.posthog.com":"https://eu.i.posthog.com"===a&&(a="https://eu-assets.i.posthog.com");let b=`${a}/array/${this.apiKey}/config`,c={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}};return this.fetchWithRetry(b,c,{retryCount:0},this.remoteConfigRequestTimeoutMs).then(a=>a.json()).catch(a=>{this._logger.error("Remote config could not be loaded",a),this._events.emit("error",a)})}async getFlags(a,b={},c={},d={},e={},f=!1){await this._initPromise;let g=`${this.host}/flags/?v=2${f?"&config=true":""}`,h={token:this.apiKey,distinct_id:a,groups:b,person_properties:c,group_properties:d,...e};this.evaluationContexts&&this.evaluationContexts.length>0&&(h.evaluation_contexts=this.evaluationContexts);let i={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:JSON.stringify(h)};return this._logger.info("Flags URL",g),this.fetchWithRetry(g,i,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(a=>a.json()).then(a=>({success:!0,response:(a=>{if("flags"in a){let b,c=Object.fromEntries(Object.entries(a.flags??{}).map(([a,b])=>[a,j(b)]).filter(([,a])=>void 0!==a)),d=Object.fromEntries(Object.keys(b=a.flags??{}).filter(a=>{let c=b[a];return c.enabled&&c.metadata&&void 0!==c.metadata.payload}).map(a=>{let c=b[a].metadata?.payload;return[a,c?k(c):void 0]}));return{...a,featureFlags:c,featureFlagPayloads:d}}{let b=a.featureFlags??{},c=Object.fromEntries(Object.entries(a.featureFlagPayloads||{}).map(([a,b])=>[a,k(b)])),d=Object.fromEntries(Object.entries(b).map(([a,b])=>{var d,e;return[a,{key:a,enabled:"string"==typeof(d=b)||d,variant:"string"==typeof d?d:void 0,reason:void 0,metadata:{id:void 0,version:void 0,payload:(e=c[a])?JSON.stringify(e):void 0,description:void 0}}]}));return{...a,featureFlags:b,featureFlagPayloads:c,flags:d}}})(a)})).catch(a=>(this._events.emit("error",a),{success:!1,error:this.categorizeRequestError(a)}))}categorizeRequestError(a){if(a instanceof Q)return{type:"api_error",statusCode:a.status};if(a instanceof R){let b=a.error;return b instanceof Error&&("AbortError"===b.name||"TimeoutError"===b.name)?{type:"timeout"}:{type:"connection_error"}}return{type:"unknown_error"}}async getFeatureFlagStateless(a,b,c={},d={},e={},f){await this._initPromise;let g=await this.getFeatureFlagDetailStateless(a,b,c,d,e,f);if(void 0===g)return{response:void 0,requestId:void 0};let h=j(g.response);return void 0===h&&(h=!1),{response:h,requestId:g.requestId}}async getFeatureFlagDetailStateless(a,b,c={},d={},e={},f){await this._initPromise;let g=await this.getFeatureFlagDetailsStateless(b,c,d,e,f,[a]);if(void 0!==g)return{response:g.flags[a],requestId:g.requestId,evaluatedAt:g.evaluatedAt}}async getFeatureFlagPayloadStateless(a,b,c={},d={},e={},f){await this._initPromise;let g=await this.getFeatureFlagPayloadsStateless(b,c,d,e,f,[a]);if(!g)return;let h=g[a];return void 0===h?null:h}async getFeatureFlagPayloadsStateless(a,b={},c={},d={},e,f){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(a,b,c,d,e,f)).payloads}async getFeatureFlagsStateless(a,b={},c={},d={},e,f){return await this._initPromise,await this.getFeatureFlagsAndPayloadsStateless(a,b,c,d,e,f)}async getFeatureFlagsAndPayloadsStateless(a,b={},c={},d={},e,f){await this._initPromise;let g=await this.getFeatureFlagDetailsStateless(a,b,c,d,e,f);return g?{flags:g.featureFlags,payloads:g.featureFlagPayloads,requestId:g.requestId}:{flags:void 0,payloads:void 0,requestId:void 0}}async getFeatureFlagDetailsStateless(a,b={},c={},d={},e,f){await this._initPromise;let g={};(e??this.disableGeoip)&&(g.geoip_disable=!0),f&&(g.flag_keys_to_evaluate=f);let h=await this.getFlags(a,b,c,d,g);if(!h.success)return;let i=h.response;return(i.errorsWhileComputingFlags&&console.error("[FEATURE FLAGS] Error while computing feature flags, some flags may be missing or incorrect. Learn more at https://posthog.com/docs/feature-flags/best-practices"),i.quotaLimited?.includes("feature_flags"))?(console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - feature flags unavailable. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts"),{flags:{},featureFlags:{},featureFlagPayloads:{},requestId:i?.requestId,quotaLimited:i.quotaLimited}):i}async getSurveysStateless(){if(await this._initPromise,!0===this.disableSurveys)return this._logger.info("Loading surveys is disabled."),[];let a=`${this.host}/api/surveys/?token=${this.apiKey}`,b={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}},c=await this.fetchWithRetry(a,b).then(a=>{if(200!==a.status||!a.json){let b=`Surveys API could not be loaded: ${a.status}`,c=Error(b);this._logger.error(c),this._events.emit("error",Error(b));return}return a.json()}).catch(a=>{this._logger.error("Surveys API could not be loaded",a),this._events.emit("error",a)}),d=c?.surveys;return d&&this._logger.info("Surveys fetched from API: ",JSON.stringify(d)),d??[]}get props(){return this._props||(this._props=this.getPersistedProperty(r.Props)),this._props||{}}set props(a){this._props=a}async register(a){this.wrap(()=>{this.props={...this.props,...a},this.setPersistedProperty(r.Props,this.props)})}async unregister(a){this.wrap(()=>{delete this.props[a],this.setPersistedProperty(r.Props,this.props)})}processBeforeEnqueue(a){return a}async flushStorage(){}enqueue(a,b,c){this.wrap(()=>{if(this.optedOut)return void this._events.emit(a,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");let d=this.prepareMessage(a,b,c);if(null===(d=this.processBeforeEnqueue(d)))return;let e=this.getPersistedProperty(r.Queue)||[];e.length>=this.maxQueueSize&&(e.shift(),this._logger.info("Queue is full, the oldest event is dropped.")),e.push({message:d}),this.setPersistedProperty(r.Queue,e),this._events.emit(a,d),e.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=K(()=>this.flushBackground(),this.flushInterval))})}async sendImmediate(a,b,c){if(this.disabled)return void this._logger.warn("The client is disabled");if(this._isInitialized||await this._initPromise,this.optedOut)return void this._events.emit(a,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");let d=this.prepareMessage(a,b,c);if(null===(d=this.processBeforeEnqueue(d)))return;let e={api_key:this.apiKey,batch:[d],sent_at:J()};this.historicalMigration&&(e.historical_migration=!0);let f=JSON.stringify(e),g=`${this.host}/batch/`,h=this.disableCompression?null:await l(f,this.isDebug),i={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json",...null!==h&&{"Content-Encoding":"gzip"}},body:h||f};try{await this.fetchWithRetry(g,i)}catch(a){this._events.emit("error",a)}}prepareMessage(a,b,c){let d={...b,type:a,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:c?.timestamp?c?.timestamp:J(),uuid:c?.uuid?c.uuid:q().toString()};return(c?.disableGeoip??this.disableGeoip)&&(d.properties||(d.properties={}),d.properties.$geoip_disable=!0),d.distinctId&&(d.distinct_id=d.distinctId,delete d.distinctId),d}clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}flushBackground(){this.flush().catch(async a=>{await S(a)})}async flush(){let a=M([this.flushPromise]).then(()=>this._flush());return this.flushPromise=a,this.addPendingPromise(a),M([a]).then(()=>{this.flushPromise===a&&(this.flushPromise=null)}),a}getCustomHeaders(){let a=this.getCustomUserAgent(),b={};return a&&""!==a&&(b["User-Agent"]=a),b}async _flush(){this.clearFlushTimer(),await this._initPromise;let a=this.getPersistedProperty(r.Queue)||[];if(!a.length)return;let b=[],c=a.length;for(;a.length>0&&b.length<c;){let c=a.slice(0,this.maxBatchSize),d=c.map(a=>a.message),e=async()=>{let b=(this.getPersistedProperty(r.Queue)||[]).slice(c.length);this.setPersistedProperty(r.Queue,b),a=b,await this.flushStorage()},f={api_key:this.apiKey,batch:d,sent_at:J()};this.historicalMigration&&(f.historical_migration=!0);let g=JSON.stringify(f),h=`${this.host}/batch/`,i=this.disableCompression?null:await l(g,this.isDebug),j={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json",...null!==i&&{"Content-Encoding":"gzip"}},body:i||g},k={retryCheck:a=>!U(a)&&T(a)};try{await this.fetchWithRetry(h,j,k)}catch(a){if(U(a)&&d.length>1){this.maxBatchSize=Math.max(1,Math.floor(d.length/2)),this._logger.warn(`Received 413 when sending batch of size ${d.length}, reducing batch size to ${this.maxBatchSize}`);continue}throw a instanceof R||await e(),this._events.emit("error",a),a}await e(),b.push(...d)}this._events.emit("flush",b)}async fetchWithRetry(a,b,c,d){let e=b.body?b.body:"",f=-1;try{f=e instanceof Blob?e.size:Buffer.byteLength(e,"utf8")}catch{f=e instanceof Blob?e.size:new TextEncoder().encode(e).length}return await I(async()=>{let c=new AbortController,e=K(()=>c.abort(),d??this.requestTimeout),g=null;try{g=await this.fetch(a,{signal:c.signal,...b})}catch(a){throw new R(a)}finally{clearTimeout(e)}if("no-cors"!==b.mode&&(g.status<200||g.status>=400))throw new Q(g,f);return g},{...this._retryOptions,...c})}async _shutdown(a=3e4){let b;await this._initPromise;let c=!1;this.clearFlushTimer();let d=async()=>{try{for(await this.promiseQueue.join();;){let a=this.getPersistedProperty(r.Queue)||[];if(0===a.length||(await this.flush(),c))break}}catch(a){if(!T(a))throw a;await S(a)}};try{return await Promise.race([new Promise((d,e)=>{b=K(()=>{this._logger.error("Timed out while shutting down PostHog"),c=!0,e("Timeout while shutting down PostHog. Some events may not have been sent.")},a)}),d()])}finally{clearTimeout(b)}}async shutdown(a=3e4){return this.shutdownPromise?this._logger.warn("shutdown() called while already shutting down. shutdown() is meant to be called once before process exit - use flush() for per-request cleanup"):this.shutdownPromise=this._shutdown(a).finally(()=>{this.shutdownPromise=null}),this.shutdownPromise}}class W{constructor(a,b,c=[]){this.coercers=a,this.stackParser=b,this.modifiers=c}buildFromUnknown(a,b={}){let c=b&&b.mechanism||{handled:!0,type:"generic"},d=this.buildCoercingContext(c,b,0).apply(a),e=this.buildParsingContext(b),f=this.parseStacktrace(d,e);return{$exception_list:this.convertToExceptionList(f,c),$exception_level:"error"}}async modifyFrames(a){for(let b of a)b.stacktrace&&b.stacktrace.frames&&w(b.stacktrace.frames)&&(b.stacktrace.frames=await this.applyModifiers(b.stacktrace.frames));return a}coerceFallback(a){return{type:"Error",value:"Unknown error",stack:a.syntheticException?.stack,synthetic:!0}}parseStacktrace(a,b){let c,d;return null!=a.cause&&(c=this.parseStacktrace(a.cause,b)),""!=a.stack&&null!=a.stack&&(d=this.applyChunkIds(this.stackParser(a.stack,a.synthetic?b.skipFirstLines:0),b.chunkIdMap)),{...a,cause:c,stack:d}}applyChunkIds(a,b){return a.map(a=>(a.filename&&b&&(a.chunk_id=b[a.filename]),a))}applyCoercers(a,b){for(let c of this.coercers)if(c.match(a))return c.coerce(a,b);return this.coerceFallback(b)}async applyModifiers(a){let b=a;for(let a of this.modifiers)b=await a(b);return b}convertToExceptionList(a,b){let c={type:a.type,value:a.value,mechanism:{type:b.type??"generic",handled:b.handled??!0,synthetic:a.synthetic??!1}};a.stack&&(c.stacktrace={type:"raw",frames:a.stack});let d=[c];return null!=a.cause&&d.push(...this.convertToExceptionList(a.cause,{...b,handled:!0})),d}buildParsingContext(a){return{chunkIdMap:function(a){let b=globalThis._posthogChunkIds;if(!b)return;let f=Object.keys(b);return e&&f.length===d?e:(d=f.length,e=f.reduce((d,e)=>{c||(c={});let f=c[e];if(f)d[f[0]]=f[1];else{let f=a(e);for(let a=f.length-1;a>=0;a--){let g=f[a],h=g?.filename,i=b[e];if(h&&i){d[h]=i,c[e]=[h,i];break}}}return d},{}))}(this.stackParser),skipFirstLines:a.skipFirstLines??1}}buildCoercingContext(a,b,c=0){let d=(c,d)=>{if(d<=4){let e=this.buildCoercingContext(a,b,d);return this.applyCoercers(c,e)}};return{...b,syntheticException:0==c?b.syntheticException:void 0,mechanism:a,apply:a=>d(a,c),next:a=>d(a,c+1)}}}function X(a,b,c,d,e){let f={platform:a,filename:b,function:"<anonymous>"===c?"?":c,in_app:!0};return void 0!==d&&(f.lineno=d),void 0!==e&&(f.colno=e),f}a.s(["ErrorPropertiesBuilder",0,W],6762);let Y=(a,b)=>{let c=-1!==a.indexOf("safari-extension"),d=-1!==a.indexOf("safari-web-extension");return c||d?[-1!==a.indexOf("@")?a.split("@")[0]:"?",c?`safari-extension:${b}`:`safari-web-extension:${b}`]:[a,b]},Z=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,$=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,_=/\((\S*)(?::(\d+))(?::(\d+))\)/,aa=(a,b)=>{let c=Z.exec(a);if(c){let[,a,d,e]=c;return X(b,a,"?",+d,+e)}let d=$.exec(a);if(d){if(d[2]&&0===d[2].indexOf("eval")){let a=_.exec(d[2]);a&&(d[2]=a[1],d[3]=a[2],d[4]=a[3])}let[a,c]=Y(d[1]||"?",d[2]);return X(b,c,a,d[3]?+d[3]:void 0,d[4]?+d[4]:void 0)}},ab=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ac=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,ad=(a,b)=>{let c=ab.exec(a);if(c){if(c[3]&&c[3].indexOf(" > eval")>-1){let a=ac.exec(c[3]);a&&(c[1]=c[1]||"eval",c[3]=a[1],c[4]=a[2],c[5]="")}let a=c[3],d=c[1]||"?";return[d,a]=Y(d,a),X(b,a,d,c[4]?+c[4]:void 0,c[5]?+c[5]:void 0)}},ae=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:[-a-z]+):.*?):(\d+)(?::(\d+))?\)?\s*$/i,af=(a,b)=>{let c=ae.exec(a);return c?X(b,c[2],c[1]||"?",+c[3],c[4]?+c[4]:void 0):void 0},ag=/ line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i,ah=(a,b)=>{let c=ag.exec(a);return c?X(b,c[2],c[3]||"?",+c[1]):void 0},ai=/ line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^)]+))\(.*\))? in (.*):\s*$/i,aj=(a,b)=>{let c=ai.exec(a);return c?X(b,c[5],c[3]||c[4]||"?",+c[1],+c[2]):void 0},ak=/^\s*[-]{4,}$/,al=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/,am=(a,b)=>{let c=a.match(al);if(c){let a,d,e,f,g;if(c[1]){let b=(e=c[1]).lastIndexOf(".");if("."===e[b-1]&&b--,b>0){a=e.slice(0,b),d=e.slice(b+1);let c=a.indexOf(".Module");c>0&&(e=e.slice(c+1),a=a.slice(0,c))}f=void 0}d&&(f=a,g=d),"<anonymous>"===d&&(g=void 0,e=void 0),void 0===e&&(g=g||"?",e=f?`${f}.${g}`:g);let h=c[2]?.startsWith("file://")?c[2].slice(7):c[2],i="native"===c[5];return h?.match(/\/[A-Z]:/)&&(h=h.slice(1)),h||!c[5]||i||(h=c[5]),{filename:h?decodeURI(h):void 0,module:void 0,function:e,lineno:an(c[3]),colno:an(c[4]),in_app:function(a,b=!1){return!(b||a&&!a.startsWith("/")&&!a.match(/^[A-Z]:/)&&!a.startsWith(".")&&!a.match(/^[a-zA-Z]([a-zA-Z0-9.\-+])*:\/\//))&&void 0!==a&&!a.includes("node_modules/")}(h||"",i),platform:b}}if(a.match(ak))return{filename:a,platform:b}};function an(a){return parseInt(a||"",10)||void 0}let ao=/\(error: (.*)\)/;function ap(a){if(!a.length)return[];let b=Array.from(a);return b.reverse(),b.slice(0,50).map(a=>{var c;return{...a,filename:a.filename||((c=b)[c.length-1]||{}).filename,function:a.function||"?"}})}function aq(){return ar("web:javascript",aa,ad)}function ar(a,...b){return(c,d=0)=>{let e=[],f=c.split("\n");for(let c=d;c<f.length;c++){let d=f[c];if(d.length>1024)continue;let g=ao.test(d)?d.replace(ao,"$1"):d;if(!g.match(/\S*Error: /)){for(let c of b){let b=c(g,a);if(b){e.push(b);break}}if(e.length>=50)break}}return ap(e)}}a.s(["createDefaultStackParser",0,aq,"createStackParser",0,ar,"reverseAndStripFrames",0,ap],67970);class as{match(a){return this.isDOMException(a)||this.isDOMError(a)}coerce(a,b){let c=x(a.stack);return{type:this.getType(a),value:this.getValue(a),stack:c?a.stack:void 0,cause:a.cause?b.next(a.cause):void 0,synthetic:!1}}getType(a){return this.isDOMError(a)?"DOMError":"DOMException"}getValue(a){let b=a.name||(this.isDOMError(a)?"DOMError":"DOMException");return a.message?`${b}: ${a.message}`:b}isDOMException(a){return z(a,"DOMException")}isDOMError(a){return z(a,"DOMError")}}a.s(["DOMExceptionCoercer",0,as],51671);class at{match(a){return a instanceof Error}coerce(a,b){return{type:this.getType(a),value:this.getMessage(a,b),stack:this.getStack(a),cause:a.cause?b.next(a.cause):void 0,synthetic:!1}}getType(a){return a.name||a.constructor.name}getMessage(a,b){let c=a.message;return c.error&&"string"==typeof c.error.message?String(c.error.message):String(c)}getStack(a){return a.stacktrace||a.stack||void 0}}a.s(["ErrorCoercer",0,at],10692);class au{match(a){return z(a,"ErrorEvent")&&void 0!=a.error}coerce(a,b){let c=b.apply(a.error);return c||{type:"ErrorEvent",value:a.message,stack:b.syntheticException?.stack,synthetic:!0}}}a.s(["ErrorEventCoercer",0,au],75368);let av=["fatal","error","warning","log","info","debug"];function aw(a,b=40){let c=Object.keys(a);if(c.sort(),!c.length)return"[object has no keys]";for(let a=c.length;a>0;a--){let d=c.slice(0,a).join(", ");if(!(d.length>b)){if(a===c.length)return d;return d.length<=b?d:`${d.slice(0,b)}...`}}return""}class ax{match(a){return"object"==typeof a&&null!==a}coerce(a,b){let c=this.getErrorPropertyFromObject(a);return c?b.apply(c):{type:this.getType(a),value:this.getValue(a),stack:b.syntheticException?.stack,level:this.isSeverityLevel(a.level)?a.level:"error",synthetic:!0}}getType(a){return A(a)?a.constructor.name:"Error"}getValue(a){if("name"in a&&"string"==typeof a.name){let b=`'${a.name}' captured as exception`;return"message"in a&&"string"==typeof a.message&&(b+=` with message: '${a.message}'`),b}if("message"in a&&"string"==typeof a.message)return a.message;let b=this.getObjectClassName(a),c=aw(a);return`${b&&"Object"!==b?`'${b}'`:"Object"} captured as exception with keys: ${c}`}isSeverityLevel(a){return x(a)&&!(x(a)&&0===a.trim().length)&&av.indexOf(a)>=0}getErrorPropertyFromObject(a){for(let b in a)if(Object.prototype.hasOwnProperty.call(a,b)){let c=a[b];if(L(c))return c}}getObjectClassName(a){try{let b=Object.getPrototypeOf(a);return b?b.constructor.name:void 0}catch(a){return}}}a.s(["ObjectCoercer",0,ax],93874);class ay{match(a){return A(a)}coerce(a,b){let c=a.constructor.name;return{type:c,value:`${c} captured as exception with keys: ${aw(a)}`,stack:b.syntheticException?.stack,synthetic:!0}}}a.s(["EventCoercer",0,ay],46980);class az{match(a){return y(a)}coerce(a,b){return{type:"Error",value:`Primitive value captured as exception: ${String(a)}`,stack:b.syntheticException?.stack,synthetic:!0}}}a.s(["PrimitiveCoercer",0,az],28150);class aA{match(a){return z(a,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(a)}isCustomEventWrappingRejection(a){if(!A(a))return!1;try{let b=a.detail;return null!=b&&"object"==typeof b&&"reason"in b}catch{return!1}}coerce(a,b){let c=this.getUnhandledRejectionReason(a);return y(c)?{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(c)}`,stack:b.syntheticException?.stack,synthetic:!0}:b.apply(c)}getUnhandledRejectionReason(a){try{if("reason"in a)return a.reason;if("detail"in a&&null!=a.detail&&"object"==typeof a.detail&&"reason"in a.detail)return a.detail.reason}catch{}return a}}a.s(["PromiseRejectionEventCoercer",0,aA],98140),a.s([],7610),a.s([],48153),a.i(48153),a.i(6762),a.i(67970),a.s(["chromeStackLineParser",0,aa,"createDefaultStackParser",0,aq,"createStackParser",0,ar,"geckoStackLineParser",0,ad,"nodeStackLineParser",0,am,"opera10StackLineParser",0,ah,"opera11StackLineParser",0,aj,"reverseAndStripFrames",0,ap,"winjsStackLineParser",0,af],64583),a.i(64583),a.i(7610),a.i(51671),a.i(10692),a.i(75368);let aB=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class aC{match(a){return"string"==typeof a}coerce(a,b){let[c,d]=this.getInfos(a);return{type:c??"Error",value:d??a,stack:b.syntheticException?.stack,synthetic:!0}}getInfos(a){let b="Error",c=a,d=a.match(aB);return d&&(b=d[1],c=d[2]),[b,c]}}a.s(["StringCoercer",0,aC],57802),a.i(57802),a.i(93874),a.i(46980),a.i(28150),a.i(98140),a.s(["DOMExceptionCoercer",0,as,"ErrorCoercer",0,at,"ErrorEventCoercer",0,au,"EventCoercer",0,ay,"ObjectCoercer",0,ax,"PrimitiveCoercer",0,az,"PromiseRejectionEventCoercer",0,aA,"StringCoercer",0,aC],54253),a.i(54253);class aD{constructor(a){this._maxSize=a,this._cache=new Map}get(a){let b=this._cache.get(a);if(void 0!==b)return this._cache.delete(a),this._cache.set(a,b),b}set(a,b){this._cache.set(a,b)}reduce(){for(;this._cache.size>=this._maxSize;){let a=this._cache.keys().next().value;a&&this._cache.delete(a)}}}a.s(["ReduceableCache",0,aD],98966),a.i(98966),a.s(["DOMExceptionCoercer",0,as,"ErrorCoercer",0,at,"ErrorEventCoercer",0,au,"ErrorPropertiesBuilder",0,W,"EventCoercer",0,ay,"ObjectCoercer",0,ax,"PrimitiveCoercer",0,az,"PromiseRejectionEventCoercer",0,aA,"ReduceableCache",0,aD,"StringCoercer",0,aC,"chromeStackLineParser",0,aa,"createDefaultStackParser",0,aq,"createStackParser",0,ar,"geckoStackLineParser",0,ad,"nodeStackLineParser",0,am,"opera10StackLineParser",0,ah,"opera11StackLineParser",0,aj,"reverseAndStripFrames",0,ap,"winjsStackLineParser",0,af],60485);var aE=a.i(60485),aF=aE,aG=a.i(2157),aH=a.i(1457);let aI=new aF.ReduceableCache(25),aJ=new aF.ReduceableCache(20);async function aK(a){let b={};for(let e=a.length-1;e>=0;e--){var c,d;let f=a[e],g=f?.filename;!(!f||"string"!=typeof g||"number"!=typeof f.lineno||(c=g).startsWith("node:")||c.endsWith(".min.js")||c.endsWith(".min.cjs")||c.endsWith(".min.mjs")||c.startsWith("data:")||void 0!==(d=f).lineno&&d.lineno>1e4||void 0!==d.colno&&d.colno>1e3)&&(b[g]||(b[g]=[]),b[g].push(f.lineno))}let e=Object.keys(b);if(0==e.length)return a;let f=[];for(let a of e){if(aJ.get(a))continue;let c=b[a];if(!c)continue;c.sort((a,b)=>a-b);let d=function(a){if(!a.length)return[];let b=0,c=a[0];if("number"!=typeof c)return[];let d=aM(c),e=[];for(;;){if(b===a.length-1){e.push(d);break}let c=a[b+1];if("number"!=typeof c)break;c<=d[1]?d[1]=c+7:(e.push(d),d=aM(c)),b++}return e}(c);if(d.every(b=>(function(a,b){let c=aI.get(a);if(void 0===c)return!1;for(let a=b[0];a<=b[1];a++)if(void 0===c[a])return!1;return!0})(a,b)))continue;let e=function(a,b,c){let d=a.get(b);return void 0===d?(a.set(b,c),c):d}(aI,a,{});f.push(function(a,b,c){return new Promise(d=>{let e=(0,aG.createReadStream)(a),f=(0,aH.createInterface)({input:e});function g(){e.destroy(),d()}let h=0,i=0,j=b[0];if(void 0===j)return void g();let k=j[0],l=j[1];function m(){aJ.set(a,1),f.close(),f.removeAllListeners(),g()}e.on("error",m),f.on("error",m),f.on("close",g),f.on("line",a=>{if(!(++h<k)&&(c[h]=function(a,b){let c=a,d=c.length;if(d<=150)return c;b>d&&(b=d);let e=Math.max(b-60,0);e<5&&(e=0);let f=Math.min(e+140,d);return f>d-5&&(f=d),f===d&&(e=Math.max(f-140,0)),c=c.slice(e,f),e>0&&(c=`...${c}`),f<d&&(c+="..."),c}(a,0),h>=l)){if(i===b.length-1){f.close(),f.removeAllListeners();return}let a=b[++i];if(void 0===a){f.close(),f.removeAllListeners();return}k=a[0],l=a[1]}})})}(a,d,e))}return await Promise.all(f).catch(()=>{}),a&&a.length>0&&function(a,b){for(let c of a)if(c.filename&&void 0===c.context_line&&"number"==typeof c.lineno){let a=b.get(c.filename);if(void 0===a)continue;!function(a,b,c){if(void 0===b.lineno||void 0===c)return;b.pre_context=[];for(let d=aN(a);d<a;d++){let a=c[d];if(void 0===a)return void aL(b);b.pre_context.push(a)}if(void 0===c[a])return aL(b);b.context_line=c[a];let d=function(a){return a+7}(a);b.post_context=[];for(let e=a+1;e<=d;e++){let a=c[e];if(void 0===a)break;b.post_context.push(a)}}(c.lineno,c,a)}}(a,aI),aI.reduce(),a}function aL(a){delete a.pre_context,delete a.context_line,delete a.post_context}function aM(a){return[aN(a),a+7]}function aN(a){return Math.max(1,a-7)}function aO(a,b,c,d,e){if(b>c&&(d.warn("min cannot be greater than max."),b=c),"[object Number]"==v.call(a)&&a==a)if(a>c)return d.warn(" cannot be greater than max: "+c+". Using max value instead."),c;else return a<b?(d.warn(" cannot be less than min: "+b+". Using min value instead."),b):a;return d.warn(" must be a number. using max or fallback. max: "+c+", fallback: "+e),aO(e||c,b,c,d)}class aP{constructor(a){this._buckets={},this._onBucketRateLimited=a._onBucketRateLimited,this._bucketSize=aO(a.bucketSize,0,100,a._logger),this._refillRate=aO(a.refillRate,0,this._bucketSize,a._logger),this._refillInterval=aO(a.refillInterval,0,864e5,a._logger)}_applyRefill(a,b){let c=Math.floor((b-a.lastAccess)/this._refillInterval);if(c>0){let b=c*this._refillRate;a.tokens=Math.min(a.tokens+b,this._bucketSize),a.lastAccess=a.lastAccess+c*this._refillInterval}}consumeRateLimit(a){let b=Date.now(),c=String(a),d=this._buckets[c];return d?this._applyRefill(d,b):(d={tokens:this._bucketSize,lastAccess:b},this._buckets[c]=d),0===d.tokens||(d.tokens--,0===d.tokens&&this._onBucketRateLimited?.(a),0===d.tokens)}stop(){this._buckets={}}}class aQ{constructor(a,b,c){this.client=a,this._exceptionAutocaptureEnabled=b.enableExceptionAutocapture||!1,this._logger=c,this._rateLimiter=new aP({refillRate:1,bucketSize:10,refillInterval:1e4,_logger:this._logger}),this.startAutocaptureIfEnabled()}static isPreviouslyCapturedError(a){return a===Object(a)&&!w(a)&&"__posthog_previously_captured_error"in a&&!0===a.__posthog_previously_captured_error}static async buildEventMessage(a,b,c,d){let e={...d},f=this.errorPropertiesBuilder.buildFromUnknown(a,b);return f.$exception_list=await this.errorPropertiesBuilder.modifyFrames(f.$exception_list),{event:"$exception",distinctId:c,properties:{...f,...e},_originatedFromCaptureException:!0}}startAutocaptureIfEnabled(){if(this.isEnabled()){var b,c,d;let e;b=this.onException.bind(this),c=this.onFatalError.bind(this),globalThis.process?.on("uncaughtException",(e=!1,Object.assign(d=>{let f=a.g.process.listeners("uncaughtException").filter(a=>"domainUncaughtExceptionClear"!==a.name&&!0!==a._posthogErrorHandler).length;b(d,{mechanism:{type:"onuncaughtexception",handled:!1}}),e||0!==f||(e=!0,c(d))},{_posthogErrorHandler:!0}))),d=this.onException.bind(this),globalThis.process?.on("unhandledRejection",a=>d(a,{mechanism:{type:"onunhandledrejection",handled:!1}}))}}onException(a,b){this.client.addPendingPromise((async()=>{if(!aQ.isPreviouslyCapturedError(a)){let c=await aQ.buildEventMessage(a,b),d=c.properties,e=d?.$exception_list[0]?.type??"Exception";return this._rateLimiter.consumeRateLimit(e)?void this._logger.info("Skipping exception capture because of client rate limiting.",{exception:e}):this.client.capture(c)}})())}async onFatalError(a){console.error(a),await this.client.shutdown(2e3),process.exit(1)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}shutdown(){this._rateLimiter.stop()}}let aR=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],aS=function(a,b=[]){if(!a)return!1;let c=a.toLowerCase();return aR.concat(b).some(a=>{let b=a.toLowerCase();return -1!==c.indexOf(b)})},aT={ERRORS_WHILE_COMPUTING:"errors_while_computing_flags",FLAG_MISSING:"flag_missing",QUOTA_LIMITED:"quota_limited",UNKNOWN_ERROR:"unknown_error"};async function aU(a){let b=globalThis.crypto?.subtle;if(!b)throw Error("SubtleCrypto API not available");return Array.from(new Uint8Array(await b.digest("SHA-1",new TextEncoder().encode(a)))).map(a=>a.toString(16).padStart(2,"0")).join("")}a.s(["FeatureFlagError",0,aT],46539);let aV=["is_not"];class aW extends Error{constructor(a){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=a,Object.setPrototypeOf(this,aW.prototype)}}class aX extends Error{constructor(a){super(a),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,aX.prototype)}}class aY extends Error{constructor(a){super(a),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,aY.prototype)}}class aZ{constructor({pollingInterval:a,personalApiKey:b,projectApiKey:c,timeout:d,host:e,customHeaders:f,...g}){this.debugMode=!1,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.pollingInterval=a,this.personalApiKey=b,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=d,this.projectApiKey=c,this.host=e,this.poller=void 0,this.fetch=g.fetch||fetch,this.onError=g.onError,this.customHeaders=f,this.onLoad=g.onLoad,this.cacheProvider=g.cacheProvider,this.strictLocalEvaluation=g.strictLocalEvaluation??!1,this.loadFeatureFlags()}debug(a=!0){this.debugMode=a}logMsgIfDebug(a){this.debugMode&&a()}createEvaluationContext(a,b={},c={},d={},e={}){return{distinctId:a,groups:b,personProperties:c,groupProperties:d,evaluationCache:e}}async getFeatureFlag(a,b,c={},d={},e={}){let f,g;if(await this.loadFeatureFlags(),!this.loadedSuccessfullyOnce)return f;if(void 0!==(g=this.featureFlagsByKey[a])){let h=this.createEvaluationContext(b,c,d,e);try{f=(await this.computeFlagAndPayloadLocally(g,h)).value,this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${a} -> ${f}`))}catch(b){b instanceof aY||b instanceof aX?this.logMsgIfDebug(()=>console.debug(`${b.name} when computing flag locally: ${a}: ${b.message}`)):b instanceof Error&&this.onError?.(Error(`Error computing flag locally: ${a}: ${b}`))}}return f}async getAllFlagsAndPayloads(a,b){await this.loadFeatureFlags();let c={},d={},e=0==this.featureFlags.length,f=b?b.map(a=>this.featureFlagsByKey[a]).filter(Boolean):this.featureFlags,g={...a,evaluationCache:a.evaluationCache??{}};return await Promise.all(f.map(async a=>{try{let{value:b,payload:e}=await this.computeFlagAndPayloadLocally(a,g);c[a.key]=b,e&&(d[a.key]=e)}catch(b){b instanceof aY||b instanceof aX?this.logMsgIfDebug(()=>console.debug(`${b.name} when computing flag locally: ${a.key}: ${b.message}`)):b instanceof Error&&this.onError?.(Error(`Error computing flag locally: ${a.key}: ${b}`)),e=!0}})),{response:c,payloads:d,fallbackToFlags:e}}async computeFlagAndPayloadLocally(a,b,c={}){let d,{matchValue:e,skipLoadCheck:f=!1}=c;if(f||await this.loadFeatureFlags(),!this.loadedSuccessfullyOnce)return{value:!1,payload:null};d=void 0!==e?e:await this.computeFlagValueLocally(a,b);let g=this.getFeatureFlagPayload(a.key,d);return{value:d,payload:g}}async computeFlagValueLocally(a,b){let{distinctId:c,groups:d,personProperties:e,groupProperties:f}=b;if(a.ensure_experience_continuity)throw new aX("Flag has experience continuity enabled");if(!a.active)return!1;let g=(a.filters||{}).aggregation_group_type_index;if(void 0!=g){let c=this.groupTypeMapping[String(g)];if(!c)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${g} for feature flag ${a.key}`)),new aX("Flag has unknown group type index");if(!(c in d))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${a.key} without group names passed in`)),!1;"device_id"===a.bucketing_identifier&&(e?.$device_id===void 0||e?.$device_id===null||e?.$device_id==="")&&this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Ignoring bucketing_identifier for group flag: ${a.key}`));let h=f[c];return await this.matchFeatureFlagProperties(a,d[c],h,b)}{let d=this.getBucketingValueForFlag(a,c,e);if(void 0===d)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute feature flag: ${a.key} without $device_id, falling back to server evaluation`)),new aX(`Can't compute feature flag: ${a.key} without $device_id`);return await this.matchFeatureFlagProperties(a,d,e,b)}}getBucketingValueForFlag(a,b,c){if(a.filters?.aggregation_group_type_index!=void 0)return b;if("device_id"===a.bucketing_identifier){let a=c?.$device_id;if(null==a||""===a)return;return a}return b}getFeatureFlagPayload(a,b){let c=null;if(!1!==b&&null!=b&&("boolean"==typeof b?c=this.featureFlagsByKey?.[a]?.filters?.payloads?.[b.toString()]||null:"string"==typeof b&&(c=this.featureFlagsByKey?.[a]?.filters?.payloads?.[b]||null),null!=c)){if("object"==typeof c)return c;if("string"==typeof c)try{return JSON.parse(c)}catch{}return c}return null}async evaluateFlagDependency(a,b,c){let{evaluationCache:d}=c,e=a.key;if(!this.featureFlagsByKey)throw new aX("Feature flags not available for dependency evaluation");if(!("dependency_chain"in a))throw new aX(`Flag dependency property for '${e}' is missing required 'dependency_chain' field`);let f=a.dependency_chain;if(!Array.isArray(f))throw new aX(`Flag dependency property for '${e}' has an invalid 'dependency_chain' (expected array, got ${typeof f})`);if(0===f.length)throw new aX(`Circular dependency detected for flag '${e}' (empty dependency chain)`);for(let a of f){if(!(a in d)){let b=this.featureFlagsByKey[a];if(b)if(b.active)try{let e=await this.computeFlagValueLocally(b,c);d[a]=e}catch(b){throw new aX(`Error evaluating flag dependency '${a}' for flag '${e}': ${b}`)}else d[a]=!1;else throw new aX(`Missing flag dependency '${a}' for flag '${e}'`)}if(null==d[a])throw new aX(`Dependency '${a}' could not be evaluated`)}let g=d[e];return this.flagEvaluatesToExpectedValue(a.value,g)}flagEvaluatesToExpectedValue(a,b){return"boolean"==typeof a?a===b||"string"==typeof b&&""!==b&&!0===a:"string"==typeof a&&b===a}async matchFeatureFlagProperties(a,b,c,d){let e,f=a.filters||{},g=f.groups||[],h=!1;for(let i of g)try{if(await this.isConditionMatch(a,b,i,c,d)){let c=i.variant,d=f.multivariate?.variants||[];e=c&&d.some(a=>a.key===c)?c:await this.getMatchingVariant(a,b)||!0;break}}catch(a){if(a instanceof aY)throw a;if(a instanceof aX)h=!0;else throw a}if(void 0!==e)return e;if(h)throw new aX("Can't determine if feature flag is enabled or not with given properties");return!1}async isConditionMatch(a,b,c,d,e){let f=c.rollout_percentage,g=a=>{this.logMsgIfDebug(()=>console.warn(a))};if((c.properties||[]).length>0){for(let a of c.properties){let b=a.type;if(!("cohort"===b?function a(b,c,d,e=!1){let f=String(b.value);if(!(f in d))throw new aY(`cohort ${f} not found in local cohorts - likely a static cohort that requires server evaluation`);return function b(c,d,e,f=!1){if(!c)return!0;let g=c.type,h=c.values;if(!h||0===h.length)return!0;let i=!1;if("values"in h[0]){for(let a of h)try{let c=b(a,d,e,f);if("AND"===g){if(!c)return!1}else if(c)return!0}catch(b){if(b instanceof aY)throw b;if(b instanceof aX)f&&console.debug(`Failed to compute property ${a} locally: ${b}`),i=!0;else throw b}if(i)throw new aX("Can't match cohort without a given cohort property value");return"AND"===g}for(let b of h)try{let c;if("cohort"===b.type)c=a(b,d,e,f);else if("flag"===b.type){f&&console.warn(`[FEATURE FLAGS] Flag dependency filters are not supported in local evaluation. Skipping condition with dependency on flag '${b.key||"unknown"}'`);continue}else c=a_(b,d);let h=b.negation||!1;if("AND"===g){if(!c&&!h||c&&h)return!1}else if(c&&!h||!c&&h)return!0}catch(a){if(a instanceof aY)throw a;if(a instanceof aX)f&&console.debug(`Failed to compute property ${b} locally: ${a}`),i=!0;else throw a}if(i)throw new aX("can't match cohort without a given cohort property value");return"AND"===g}(d[f],c,d,e)}(a,d,this.cohorts,this.debugMode):"flag"===b?await this.evaluateFlagDependency(a,d,e):a_(a,d,g)))return!1}if(void 0==f)return!0}return!(void 0!=f&&await a$(a.key,b)>f/100)}async getMatchingVariant(a,b){let c=await a$(a.key,b,"variant"),d=this.variantLookupTable(a).find(a=>c>=a.valueMin&&c<a.valueMax);if(d)return d.key}variantLookupTable(a){let b=[],c=0,d=0,e=a.filters||{};return(e.multivariate?.variants||[]).forEach(a=>{d=c+a.rollout_percentage/100,b.push({valueMin:c,valueMax:d,key:a.key}),c=d}),b}updateFlagState(a){this.featureFlags=a.flags,this.featureFlagsByKey=a.flags.reduce((a,b)=>(a[b.key]=b,a),{}),this.groupTypeMapping=a.groupTypeMapping,this.cohorts=a.cohorts,this.loadedSuccessfullyOnce=!0}warnAboutExperienceContinuityFlags(a){if(this.strictLocalEvaluation)return;let b=a.filter(a=>a.ensure_experience_continuity);b.length>0&&console.warn(`[PostHog] You are using local evaluation but ${b.length} flag(s) have experience continuity enabled: ${b.map(a=>a.key).join(", ")}. Experience continuity is incompatible with local evaluation and will cause a server request on every flag evaluation, negating local evaluation cost savings. To avoid server requests and unexpected costs, either disable experience continuity on these flags in PostHog, use strictLocalEvaluation: true in client init, or pass onlyEvaluateLocally: true per flag call (flags that cannot be evaluated locally will return undefined).`)}async loadFromCache(a){if(!this.cacheProvider)return!1;try{let b=await this.cacheProvider.getFlagDefinitions();if(b)return this.updateFlagState(b),this.logMsgIfDebug(()=>console.debug(`[FEATURE FLAGS] ${a} (${b.flags.length} flags)`)),this.onLoad?.(this.featureFlags.length),this.warnAboutExperienceContinuityFlags(b.flags),!0;return!1}catch(a){return this.onError?.(Error(`Failed to load from cache: ${a}`)),!1}}async loadFeatureFlags(a=!1){if(!this.loadedSuccessfullyOnce||a)return!a&&this.nextFetchAllowedAt&&Date.now()<this.nextFetchAllowedAt?void this.logMsgIfDebug(()=>console.debug("[FEATURE FLAGS] Skipping fetch, in backoff period")):(this.loadingPromise||(this.loadingPromise=this._loadFeatureFlags().catch(a=>this.logMsgIfDebug(()=>console.debug(`[FEATURE FLAGS] Failed to load feature flags: ${a}`))).finally(()=>{this.loadingPromise=void 0})),this.loadingPromise)}isLocalEvaluationReady(){return(this.loadedSuccessfullyOnce??!1)&&(this.featureFlags?.length??0)>0}getFlagDefinitionsLoadedAt(){return this.flagDefinitionsLoadedAt}getPollingInterval(){return this.shouldBeginExponentialBackoff?Math.min(6e4,this.pollingInterval*2**this.backOffCount):this.pollingInterval}beginBackoff(){this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,this.nextFetchAllowedAt=Date.now()+this.getPollingInterval()}clearBackoff(){this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.nextFetchAllowedAt=void 0}async _loadFeatureFlags(){this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(()=>this.loadFeatureFlags(!0),this.getPollingInterval());try{let a=!0;if(this.cacheProvider)try{a=await this.cacheProvider.shouldFetchFlagDefinitions()}catch(a){this.onError?.(Error(`Error in shouldFetchFlagDefinitions: ${a}`))}if(!a&&(await this.loadFromCache("Loaded flags from cache (skipped fetch)")||this.loadedSuccessfullyOnce))return;let b=await this._requestFeatureFlagDefinitions();if(!b)return;switch(b.status){case 304:this.logMsgIfDebug(()=>console.debug("[FEATURE FLAGS] Flags not modified (304), using cached data")),this.flagsEtag=b.headers?.get("ETag")??this.flagsEtag,this.loadedSuccessfullyOnce=!0,this.clearBackoff();return;case 401:throw this.beginBackoff(),new aW(`Your project key or personal API key is invalid. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 402:console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - unsetting all local flags. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts"),this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={};return;case 403:throw this.beginBackoff(),new aW(`Your personal API key does not have permission to fetch feature flag definitions for local evaluation. Setting next polling interval to ${this.getPollingInterval()}ms. Are you sure you're using the correct personal and Project API key pair? More information: https://posthog.com/docs/api/overview`);case 429:throw this.beginBackoff(),new aW(`You are being rate limited. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 200:{let c=await b.json()??{};if(!("flags"in c))return void this.onError?.(Error(`Invalid response when getting feature flags: ${JSON.stringify(c)}`));this.flagsEtag=b.headers?.get("ETag")??void 0;let d={flags:c.flags??[],groupTypeMapping:c.group_type_mapping||{},cohorts:c.cohorts||{}};if(this.updateFlagState(d),this.flagDefinitionsLoadedAt=Date.now(),this.clearBackoff(),this.cacheProvider&&a)try{await this.cacheProvider.onFlagDefinitionsReceived(d)}catch(a){this.onError?.(Error(`Failed to store in cache: ${a}`))}this.onLoad?.(this.featureFlags.length),this.warnAboutExperienceContinuityFlags(d.flags);break}default:return}}catch(a){a instanceof aW&&this.onError?.(a)}}getPersonalApiKeyRequestOptions(a="GET",b){let c={...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`};return b&&(c["If-None-Match"]=b),{method:a,headers:c}}_requestFeatureFlagDefinitions(){let a=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,b=this.getPersonalApiKeyRequestOptions("GET",this.flagsEtag),c=null;if(this.timeout&&"number"==typeof this.timeout){let a=new AbortController;c=K(()=>{a.abort()},this.timeout),b.signal=a.signal}try{return(0,this.fetch)(a,b)}finally{clearTimeout(c)}}async stopPoller(a=3e4){if(clearTimeout(this.poller),this.cacheProvider)try{let b=this.cacheProvider.shutdown();b instanceof Promise&&await Promise.race([b,new Promise((b,c)=>setTimeout(()=>c(Error(`Cache shutdown timeout after ${a}ms`)),a))])}catch(a){this.onError?.(Error(`Error during cache shutdown: ${a}`))}}}async function a$(a,b,c=""){return parseInt((await aU(`${a}.${b}${c}`)).slice(0,15),16)/0x1000000000000000}function a_(a,b,c){let d=a.key,e=a.value,f=a.operator||"exact";if(d in b){if("is_not_set"===f)throw new aX("Operator is_not_set is not supported")}else throw new aX(`Property ${d} not found in propertyValues`);let g=b[d];if(null==g&&!aV.includes(f))return c&&c(`Property ${d} cannot have a value of null/undefined with the ${f} operator`),!1;function h(a,b){return Array.isArray(a)?a.map(a=>String(a).toLowerCase()).includes(String(b).toLowerCase()):String(a).toLowerCase()===String(b).toLowerCase()}function i(a,b,c){if("gt"===c)return a>b;if("gte"===c)return a>=b;if("lt"===c)return a<b;if("lte"===c)return a<=b;throw Error(`Invalid operator: ${c}`)}switch(f){case"exact":return h(e,g);case"is_not":return!h(e,g);case"is_set":return d in b;case"icontains":return String(g).toLowerCase().includes(String(e).toLowerCase());case"not_icontains":return!String(g).toLowerCase().includes(String(e).toLowerCase());case"regex":return a0(String(e))&&null!==String(g).match(String(e));case"not_regex":return a0(String(e))&&null===String(g).match(String(e));case"gt":case"gte":case"lt":case"lte":{let a="number"==typeof e?e:null;if("string"==typeof e)try{a=parseFloat(e)}catch(a){}if(null==a||null==g)return i(String(g),String(e),f);if("string"==typeof g)return i(g,String(e),f);return i(g,a,f)}case"is_date_after":case"is_date_before":{if("boolean"==typeof e)throw new aX("Date operations cannot be performed on boolean values");let a=function(a){let b=a.match(/^-?(?<number>[0-9]+)(?<interval>[a-z])$/),c=new Date(new Date().toISOString());if(!b)return null;{if(!b.groups)return null;let a=parseInt(b.groups.number);if(a>=1e4)return null;let d=b.groups.interval;if("h"==d)c.setUTCHours(c.getUTCHours()-a);else if("d"==d)c.setUTCDate(c.getUTCDate()-a);else if("w"==d)c.setUTCDate(c.getUTCDate()-7*a);else if("m"==d)c.setUTCMonth(c.getUTCMonth()-a);else{if("y"!=d)return null;c.setUTCFullYear(c.getUTCFullYear()-a)}return c}}(String(e));if(null==a&&(a=a3(e)),null==a)throw new aX(`Invalid date: ${e}`);let b=a3(g);if(["is_date_before"].includes(f))return b<a;return b>a}case"semver_eq":return 0===a2(a1(String(g)),a1(String(e)));case"semver_neq":return 0!==a2(a1(String(g)),a1(String(e)));case"semver_gt":return a2(a1(String(g)),a1(String(e)))>0;case"semver_gte":return a2(a1(String(g)),a1(String(e)))>=0;case"semver_lt":return 0>a2(a1(String(g)),a1(String(e)));case"semver_lte":return 0>=a2(a1(String(g)),a1(String(e)));case"semver_tilde":{let a,b=a1(String(g)),{lower:c,upper:d}={lower:[(a=a1(String(e)))[0],a[1],a[2]],upper:[a[0],a[1]+1,0]};return a2(b,c)>=0&&0>a2(b,d)}case"semver_caret":{let a=a1(String(g)),{lower:b,upper:c}=function(a){let[b,c,d]=a1(a);return{lower:[b,c,d],upper:b>0?[b+1,0,0]:c>0?[0,c+1,0]:[0,0,d+1]}}(String(e));return a2(a,b)>=0&&0>a2(a,c)}case"semver_wildcard":{let a=a1(String(g)),{lower:b,upper:c}=function(a){let b,c,d=String(a).trim().replace(/^[vV]/,"").replace(/\.\*$/,"").replace(/\*$/,"");if(!d)throw new aX(`Invalid wildcard semver: ${a}`);let e=d.split("."),f=parseInt(e[0],10);if(isNaN(f))throw new aX(`Invalid wildcard semver: ${a}`);if(1===e.length)b=[f,0,0],c=[f+1,0,0];else{let d=parseInt(e[1],10);if(isNaN(d))throw new aX(`Invalid wildcard semver: ${a}`);b=[f,d,0],c=[f,d+1,0]}return{lower:b,upper:c}}(String(e));return a2(a,b)>=0&&0>a2(a,c)}default:throw new aX(`Unknown operator: ${f}`)}}function a0(a){try{return new RegExp(a),!0}catch(a){return!1}}function a1(a){let b=String(a).trim().replace(/^[vV]/,"").split("-")[0].split("+")[0];if(!b||b.startsWith("."))throw new aX(`Invalid semver: ${a}`);let c=b.split("."),d=b=>{if(void 0===b||""===b)return 0;if(!/^\d+$/.test(b))throw new aX(`Invalid semver: ${a}`);return parseInt(b,10)};return[d(c[0]),d(c[1]),d(c[2])]}function a2(a,b){for(let c=0;c<3;c++){if(a[c]<b[c])return -1;if(a[c]>b[c])return 1}return 0}function a3(a){if(a instanceof Date)return a;if("string"==typeof a||"number"==typeof a){let b=new Date(a);if(!isNaN(b.valueOf()))return b;throw new aX(`${a} is in an invalid date format`)}throw new aX(`The date provided ${a} must be a string, number, or date object`)}class a4{getProperty(a){return this._memoryStorage[a]}setProperty(a,b){this._memoryStorage[a]=null!==b?b:void 0}constructor(){this._memoryStorage={}}}class a5 extends V{constructor(a,b={}){if(super(a,b),this._memoryStorage=new a4,this.options=b,this.context=this.initializeContext(),this.options.featureFlagsPollingInterval="number"==typeof b.featureFlagsPollingInterval?Math.max(b.featureFlagsPollingInterval,100):3e4,"number"==typeof b.waitUntilDebounceMs&&(this.options.waitUntilDebounceMs=Math.max(b.waitUntilDebounceMs,0)),"number"==typeof b.waitUntilMaxWaitMs&&(this.options.waitUntilMaxWaitMs=Math.max(b.waitUntilMaxWaitMs,0)),b.personalApiKey){if(b.personalApiKey.includes("phc_"))throw Error('Your Personal API key is invalid. These keys are prefixed with "phx_" and can be created in PostHog project settings.');!1!==b.enableLocalEvaluation&&(this.featureFlagsPoller=new aZ({pollingInterval:this.options.featureFlagsPollingInterval,personalApiKey:b.personalApiKey,projectApiKey:a,timeout:b.requestTimeout??1e4,host:this.host,fetch:b.fetch,onError:a=>{this._events.emit("error",a)},onLoad:a=>{this._events.emit("localEvaluationFlagsLoaded",a)},customHeaders:this.getCustomHeaders(),cacheProvider:b.flagDefinitionCacheProvider,strictLocalEvaluation:b.strictLocalEvaluation}))}this.errorTracking=new aQ(this,b,this._logger),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=b.maxCacheSize||5e4}enqueue(a,b,c){super.enqueue(a,b,c),this.scheduleDebouncedFlush()}async flush(){let a=super.flush(),b=this.options.waitUntil;if(b&&!this._waitUntilCycle)try{b(a.catch(()=>{}))}catch{}return a}scheduleDebouncedFlush(){let a=this.options.waitUntil;if(!a||this.disabled||this.optedOut)return;if(!this._waitUntilCycle){let b,c=new Promise(a=>{b=a});try{a(c)}catch{return}this._waitUntilCycle={resolve:b,startedAt:Date.now(),timer:void 0}}let b=Date.now()-this._waitUntilCycle.startedAt,c=this.options.waitUntilMaxWaitMs??500;if(void 0!==this._waitUntilCycle.timer&&clearTimeout(this._waitUntilCycle.timer),b>=c)return void this.resolveWaitUntilFlush();let d=this.options.waitUntilDebounceMs??50;this._waitUntilCycle.timer=K(()=>{this.resolveWaitUntilFlush()},d)}_consumeWaitUntilCycle(){let a=this._waitUntilCycle;return a&&(clearTimeout(a.timer),this._waitUntilCycle=void 0),a?.resolve}async resolveWaitUntilFlush(){let a=this._consumeWaitUntilCycle();try{await super.flush()}catch{}finally{a?.()}}getPersistedProperty(a){return this._memoryStorage.getProperty(a)}setPersistedProperty(a,b){return this._memoryStorage.setProperty(a,b)}fetch(a,b){return this.options.fetch?this.options.fetch(a,b):fetch(a,b)}getLibraryVersion(){return"5.28.9"}getCustomUserAgent(){return`${this.getLibraryId()}/${this.getLibraryVersion()}`}enable(){return super.optIn()}disable(){return super.optOut()}debug(a=!0){super.debug(a),this.featureFlagsPoller?.debug(a)}capture(a){"string"==typeof a&&this._logger.warn("Called capture() with a string as the first argument when an object was expected."),"$exception"!==a.event||a._originatedFromCaptureException||this._logger.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.addPendingPromise(this.prepareEventMessage(a).then(({distinctId:a,event:b,properties:c,options:d})=>super.captureStateless(a,b,c,{timestamp:d.timestamp,disableGeoip:d.disableGeoip,uuid:d.uuid})).catch(a=>{a&&console.error(a)}))}async captureImmediate(a){return"string"==typeof a&&this._logger.warn("Called captureImmediate() with a string as the first argument when an object was expected."),"$exception"!==a.event||a._originatedFromCaptureException||this._logger.warn("Capturing a `$exception` event via `posthog.captureImmediate('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureExceptionImmediate(error)` instead, which attaches this metadata by default."),this.addPendingPromise(this.prepareEventMessage(a).then(({distinctId:a,event:b,properties:c,options:d})=>super.captureStatelessImmediate(a,b,c,{timestamp:d.timestamp,disableGeoip:d.disableGeoip,uuid:d.uuid})).catch(a=>{a&&console.error(a)}))}identify({distinctId:a,properties:b={},disableGeoip:c}){let{$set:d,$set_once:e,$anon_distinct_id:f,...g}=b;super.identifyStateless(a,{$set:d||g,$set_once:e||{},$anon_distinct_id:f??void 0},{disableGeoip:c})}async identifyImmediate({distinctId:a,properties:b={},disableGeoip:c}){let{$set:d,$set_once:e,$anon_distinct_id:f,...g}=b;super.identifyStatelessImmediate(a,{$set:d||g,$set_once:e||{},$anon_distinct_id:f??void 0},{disableGeoip:c})}alias(a){super.aliasStateless(a.alias,a.distinctId,void 0,{disableGeoip:a.disableGeoip})}async aliasImmediate(a){await super.aliasStatelessImmediate(a.alias,a.distinctId,void 0,{disableGeoip:a.disableGeoip})}isLocalEvaluationReady(){return this.featureFlagsPoller?.isLocalEvaluationReady()??!1}async waitForLocalEvaluationReady(a=3e4){return!!this.isLocalEvaluationReady()||void 0!==this.featureFlagsPoller&&new Promise(b=>{let c=setTimeout(()=>{d(),b(!1)},a),d=this._events.on("localEvaluationFlagsLoaded",a=>{clearTimeout(c),d(),b(a>0)})})}_resolveDistinctId(a,b){return"string"==typeof a?{distinctId:a,options:b}:{distinctId:this.context?.get()?.distinctId,options:a}}async _getFeatureFlagResult(a,b,c={},d){let e,f,g,h,i,j,k,l=c.sendFeatureFlagEvents??!0;if(void 0!==this._flagOverrides&&a in this._flagOverrides){let b=this._flagOverrides[a];if(void 0===b)return;let c=this._payloadOverrides?.[a];return{key:a,enabled:!1!==b,variant:"string"==typeof b?b:void 0,payload:c}}let{groups:m,disableGeoip:n}=c,{onlyEvaluateLocally:o,personProperties:p,groupProperties:q}=c,r=this.addLocalPersonAndGroupProperties(b,m,p,q);p=r.allPersonProperties,q=r.allGroupProperties;let s=this.createFeatureFlagEvaluationContext(b,m,p,q);void 0==o&&(o=this.options.strictLocalEvaluation??!1);let t=!1;if(void 0!==this.featureFlagsPoller){await this.featureFlagsPoller?.loadFeatureFlags();let b=this.featureFlagsPoller?.featureFlagsByKey[a];if(b)try{let c=await this.featureFlagsPoller?.computeFlagAndPayloadLocally(b,s,{matchValue:d});if(c){t=!0;let d=c.value;i=b.id,k="Evaluated locally",e={key:a,enabled:!1!==d,variant:"string"==typeof d?d:void 0,payload:c.payload??void 0}}}catch(b){if(b instanceof aY||b instanceof aX)this._logger?.info(`${b.name} when computing flag locally: ${a}: ${b.message}`);else throw b}}if(!t&&!o){let b=await super.getFeatureFlagDetailsStateless(s.distinctId,s.groups,s.personProperties,s.groupProperties,n,[a]);if(void 0===b)h=aT.UNKNOWN_ERROR;else{f=b.requestId,g=b.evaluatedAt;let c=[];b.errorsWhileComputingFlags&&c.push(aT.ERRORS_WHILE_COMPUTING),b.quotaLimited?.includes("feature_flags")&&c.push(aT.QUOTA_LIMITED);let d=b.flags[a];if(void 0===d)c.push(aT.FLAG_MISSING);else{let b;if(i=d.metadata?.id,j=d.metadata?.version,k=d.reason?.description??d.reason?.code,d.metadata?.payload!==void 0)try{b=JSON.parse(d.metadata.payload)}catch{b=d.metadata.payload}e={key:a,enabled:d.enabled,variant:d.variant,payload:b}}c.length>0&&(h=c.join(","))}}if(l){let c=void 0===e?void 0:!1!==e.enabled&&(e.variant??!0),d=`${a}_${c}`;if(!(b in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[b].includes(d)){Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[b])?this.distinctIdHasSentFlagCalls[b].push(d):this.distinctIdHasSentFlagCalls[b]=[d];let e={$feature_flag:a,$feature_flag_response:c,$feature_flag_id:i,$feature_flag_version:j,$feature_flag_reason:k,locally_evaluated:t,[`$feature/${a}`]:c,$feature_flag_request_id:f,$feature_flag_evaluated_at:t?Date.now():g};if(t&&this.featureFlagsPoller){let a=this.featureFlagsPoller.getFlagDefinitionsLoadedAt();void 0!==a&&(e.$feature_flag_definitions_loaded_at=a)}h&&(e.$feature_flag_error=h),this.capture({distinctId:b,event:"$feature_flag_called",properties:e,groups:m,disableGeoip:n})}}return void 0!==e&&void 0!==this._payloadOverrides&&a in this._payloadOverrides&&(e={...e,payload:this._payloadOverrides[a]}),e}async getFeatureFlag(a,b,c){let d=await this._getFeatureFlagResult(a,b,{...c,sendFeatureFlagEvents:c?.sendFeatureFlagEvents??this.options.sendFeatureFlagEvent??!0});if(void 0!==d)return!1!==d.enabled&&(d.variant??!0)}async getFeatureFlagPayload(a,b,c,d){if(void 0!==this._payloadOverrides&&a in this._payloadOverrides)return this._payloadOverrides[a];let e=await this._getFeatureFlagResult(a,b,{...d,sendFeatureFlagEvents:!1},c);if(void 0!==e)return e.payload??null}async getFeatureFlagResult(a,b,c){let{distinctId:d,options:e}=this._resolveDistinctId(b,c);return d?this._getFeatureFlagResult(a,d,{...e,sendFeatureFlagEvents:e?.sendFeatureFlagEvents??this.options.sendFeatureFlagEvent??!0}):void this._logger.warn("[PostHog] distinctId is required — pass it explicitly or use withContext()")}async getRemoteConfigPayload(a){if(!this.options.personalApiKey)throw Error("Personal API key is required for remote config payload decryption");let b=await this._requestRemoteConfigPayload(a);if(!b)return;let c=await b.json();if("string"==typeof c)try{return JSON.parse(c)}catch(a){}return c}async isFeatureEnabled(a,b,c){let d=await this.getFeatureFlag(a,b,c);if(void 0!==d)return!!d}async getAllFlags(a,b){let{distinctId:c,options:d}=this._resolveDistinctId(a,b);return c?(await this.getAllFlagsAndPayloads(c,d)).featureFlags||{}:(this._logger.warn("[PostHog] distinctId is required to get feature flags — pass it explicitly or use withContext()"),{})}async getAllFlagsAndPayloads(a,b){let{distinctId:c,options:d}=this._resolveDistinctId(a,b);if(!c)return this._logger.warn("[PostHog] distinctId is required to get feature flags and payloads — pass it explicitly or use withContext()"),{featureFlags:{},featureFlagPayloads:{}};let{groups:e,disableGeoip:f,flagKeys:g}=d||{},{onlyEvaluateLocally:h,personProperties:i,groupProperties:j}=d||{},k=this.addLocalPersonAndGroupProperties(c,e,i,j);i=k.allPersonProperties,j=k.allGroupProperties;let l=this.createFeatureFlagEvaluationContext(c,e,i,j);void 0==h&&(h=this.options.strictLocalEvaluation??!1);let m=await this.featureFlagsPoller?.getAllFlagsAndPayloads(l,g),n={},o={},p=!0;if(m&&(n=m.response,o=m.payloads,p=m.fallbackToFlags),p&&!h){let a=await super.getFeatureFlagsAndPayloadsStateless(l.distinctId,l.groups,l.personProperties,l.groupProperties,f,g);n={...n,...a.flags||{}},o={...o,...a.payloads||{}}}return void 0!==this._flagOverrides&&(n={...n,...this._flagOverrides}),void 0!==this._payloadOverrides&&(o={...o,...this._payloadOverrides}),{featureFlags:n,featureFlagPayloads:o}}groupIdentify({groupType:a,groupKey:b,properties:c,distinctId:d,disableGeoip:e}){super.groupIdentifyStateless(a,b,c,{disableGeoip:e},d)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}overrideFeatureFlags(a){let b=a=>Object.fromEntries(a.map(a=>[a,!0]));if(!1===a){this._flagOverrides=void 0,this._payloadOverrides=void 0;return}if(Array.isArray(a)){this._flagOverrides=b(a);return}if(this._isFeatureFlagOverrideOptions(a)){"flags"in a&&(!1===a.flags?this._flagOverrides=void 0:Array.isArray(a.flags)?this._flagOverrides=b(a.flags):void 0!==a.flags&&(this._flagOverrides={...a.flags})),"payloads"in a&&(!1===a.payloads?this._payloadOverrides=void 0:void 0!==a.payloads&&(this._payloadOverrides={...a.payloads}));return}this._flagOverrides={...a}}_isFeatureFlagOverrideOptions(a){if("object"!=typeof a||null===a||Array.isArray(a))return!1;if("flags"in a){let b=a.flags;if(!1===b||Array.isArray(b)||"object"==typeof b&&null!==b)return!0}if("payloads"in a){let b=a.payloads;if(!1===b||"object"==typeof b&&null!==b)return!0}return!1}withContext(a,b,c){return this.context?this.context.run(a,b,c):b()}getContext(){return this.context?.get()}enterContext(a,b){this.context?.enter(a,b)}async _shutdown(a){let b=this._consumeWaitUntilCycle();await this.featureFlagsPoller?.stopPoller(a),this.errorTracking.shutdown();try{return await super._shutdown(a)}finally{b?.()}}async _requestRemoteConfigPayload(a){if(!this.options.personalApiKey)return;let b=`${this.host}/api/projects/@current/feature_flags/${a}/remote_config?token=${encodeURIComponent(this.apiKey)}`,c={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json",Authorization:`Bearer ${this.options.personalApiKey}`}},d=null;if(this.options.requestTimeout&&"number"==typeof this.options.requestTimeout){let a=new AbortController;d=K(()=>{a.abort()},this.options.requestTimeout),c.signal=a.signal}try{return await this.fetch(b,c)}catch(a){this._events.emit("error",a);return}finally{d&&clearTimeout(d)}}extractPropertiesFromEvent(a,b){if(!a)return{personProperties:{},groupProperties:{}};let c={},d={};for(let[e,f]of Object.entries(a))if(z(f,"Object")&&b&&e in b){let a={};for(let[b,c]of Object.entries(f))a[String(b)]=String(c);d[String(e)]=a}else c[String(e)]=String(f);return{personProperties:c,groupProperties:d}}async getFeatureFlagsForEvent(a,b,c,d){let e=d?.personProperties||{},f=d?.groupProperties||{},g=d?.flagKeys;if(d?.onlyEvaluateLocally??this.options.strictLocalEvaluation)if(!((this.featureFlagsPoller?.featureFlags?.length||0)>0))return{};else{let d={};for(let[a,c]of Object.entries(b||{}))d[a]=String(c);return await this.getAllFlags(a,{groups:d,personProperties:e,groupProperties:f,disableGeoip:c,onlyEvaluateLocally:!0,flagKeys:g})}if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let d={};for(let[a,c]of Object.entries(b||{}))d[a]=String(c);return await this.getAllFlags(a,{groups:d,personProperties:e,groupProperties:f,disableGeoip:c,onlyEvaluateLocally:!0,flagKeys:g})}return(await super.getFeatureFlagsStateless(a,b,e,f,c)).flags}addLocalPersonAndGroupProperties(a,b,c,d){let e={distinct_id:a,...c||{}},f={};if(b)for(let a of Object.keys(b))f[a]={$group_key:b[a],...d?.[a]||{}};return{allPersonProperties:e,allGroupProperties:f}}createFeatureFlagEvaluationContext(a,b,c,d){return{distinctId:a,groups:b||{},personProperties:c||{},groupProperties:d||{},evaluationCache:{}}}captureException(a,b,c,d){if(!aQ.isPreviouslyCapturedError(a)){let e=Error("PostHog syntheticException");this.addPendingPromise(aQ.buildEventMessage(a,{syntheticException:e},b,c).then(a=>this.capture({...a,uuid:d})))}}async captureExceptionImmediate(a,b,c){if(!aQ.isPreviouslyCapturedError(a)){let d=Error("PostHog syntheticException");return this.addPendingPromise(aQ.buildEventMessage(a,{syntheticException:d},b,c).then(a=>this.captureImmediate(a)))}}async prepareEventMessage(a){let{distinctId:b,event:c,properties:d,groups:e,sendFeatureFlags:f,timestamp:g,disableGeoip:h,uuid:i}=a,j=this.context?.get(),k=b||j?.distinctId,l={...this.props,...j?.properties||{},...d||{}};k||(k=q().toString(),l.$process_person_profile=!1),j?.sessionId&&!l.$session_id&&(l.$session_id=j.sessionId);let m=this._runBeforeSend({distinctId:k,event:c,properties:l,groups:e,sendFeatureFlags:f,timestamp:g,disableGeoip:h,uuid:i});if(!m)return Promise.reject(null);let n=await Promise.resolve().then(async()=>f?await this.getFeatureFlagsForEvent(m.distinctId,e,h,"object"==typeof f?f:void 0):(m.event,{})).then(a=>{let b={};if(a)for(let[c,d]of Object.entries(a))b[`$feature/${c}`]=d;let c=Object.keys(a||{}).filter(b=>a?.[b]!==!1).sort();return c.length>0&&(b.$active_feature_flags=c),b}).catch(()=>({})).then(a=>({...a,...m.properties||{},$groups:m.groups||e}));return"$pageview"===m.event&&this.options.__preview_capture_bot_pageviews&&"string"==typeof n.$raw_user_agent&&aS(n.$raw_user_agent,this.options.custom_blocked_useragents||[])&&(m.event="$bot_pageview",n.$browser_type="bot"),{distinctId:m.distinctId,event:m.event,properties:n,options:{timestamp:m.timestamp,disableGeoip:m.disableGeoip,uuid:m.uuid}}}_runBeforeSend(a){let b=this.options.before_send;if(!b)return a;let c=Array.isArray(b)?b:[b],d=a;for(let b of c){if(!(d=b(d)))return this._logger.info(`Event '${a.event}' was rejected in beforeSend function`),null;if(!d.properties||0===Object.keys(d.properties).length){let a=`Event '${d.event}' has no properties after beforeSend function, this is likely an error.`;this._logger.warn(a)}}return d}}var aF=aE,a6=a.i(78500);class a7{constructor(){this.storage=new a6.AsyncLocalStorage}get(){return this.storage.getStore()}run(a,b,c){return this.storage.run(this.resolve(a,c),b)}enter(a,b){this.storage.enterWith(this.resolve(a,b))}resolve(a,b){if(b?.fresh===!0)return a;let c=this.get()||{};return{distinctId:a.distinctId??c.distinctId,sessionId:a.sessionId??c.sessionId,properties:{...c.properties||{},...a.properties||{}}}}}function a8(a,b){var c;b.use((c=a,(a,b,d,e)=>{if(aQ.isPreviouslyCapturedError(a))return void e(a);let f=b.headers["x-posthog-session-id"],g=b.headers["x-posthog-distinct-id"],h=Error("Synthetic exception");c.addPendingPromise(aQ.buildEventMessage(a,{mechanism:{type:"middleware",handled:!1},syntheticException:h},g,{$session_id:f,$current_url:b.url,$request_method:b.method,$request_path:b.path,$user_agent:b.headers["user-agent"],$response_status_code:d.statusCode,$ip:b.headers["x-forwarded-for"]||b?.socket?.remoteAddress}).then(a=>{c.capture(a)})),e(a)}))}a.s(["setupExpressErrorHandler",0,a8],40602),a.s([],51328),aQ.errorPropertiesBuilder=new aF.ErrorPropertiesBuilder([new aF.EventCoercer,new aF.ErrorCoercer,new aF.ObjectCoercer,new aF.StringCoercer,new aF.PrimitiveCoercer],aF.createStackParser("node:javascript",aF.nodeStackLineParser),[(f=function(a=process.argv[1]?(0,h.dirname)(process.argv[1]):process.cwd(),b="\\"===h.sep){let c=b?i(a):a;return a=>{if(!a)return;let d=b?i(a):a,{dir:e,base:f,ext:g}=h.posix.parse(d);(".js"===g||".mjs"===g||".cjs"===g)&&(f=f.slice(0,-1*g.length));let j=decodeURIComponent(f);e||(e=".");let k=e.lastIndexOf("/node_modules");if(k>-1)return`${e.slice(k+14).replace(/\//g,".")}:${j}`;if(e.startsWith(c)){let a=e.slice(c.length+1).replace(/\//g,".");return a?`${a}:${j}`:j}return j}}(),async a=>{for(let b of a)b.module=f(b.filename);return a}),aK]);class a9 extends a5{getLibraryId(){return"posthog-node"}initializeContext(){return new a7}}a.s(["PostHog",0,a9],81035),a.i(81035),a.i(51328);let ba="posthog-node";function bb(a,{organization:b,projectId:c,prefix:d,severityAllowList:e=["error"],sendExceptionsToPostHog:f=!0}={}){return g=>{if(!("*"===e||e.includes(g.level)))return g;g.tags||(g.tags={});let h=g.tags[bd.POSTHOG_ID_TAG];if(void 0===h)return g;let i=a.options.host??"https://us.i.posthog.com",j=new URL(`/project/${a.apiKey}/person/${h}`,i).toString();g.tags["PostHog Person URL"]=j;let k=g.exception?.values||[],l=k.map(a=>({...a,stacktrace:a.stacktrace?{...a.stacktrace,type:"raw",frames:(a.stacktrace.frames||[]).map(a=>({...a,platform:"node:javascript"}))}:void 0})),m={$exception_message:k[0]?.value||g.message,$exception_type:k[0]?.type,$exception_level:g.level,$exception_list:l,$sentry_event_id:g.event_id,$sentry_exception:g.exception,$sentry_exception_message:k[0]?.value||g.message,$sentry_exception_type:k[0]?.type,$sentry_tags:g.tags};return b&&c&&(m.$sentry_url=(d||"https://sentry.io/organizations/")+b+"/issues/?project="+c+"&query="+g.event_id),f&&a.capture({event:"$exception",distinctId:h,properties:m}),g}}function bc(a,b){let c=bb(a,b);return{name:ba,processEvent:a=>c(a)}}class bd{static #a=this.POSTHOG_ID_TAG="posthog_distinct_id";constructor(a,b,c,d,e){this.name=ba,this.name=ba,this.setupOnce=function(f,g){f(bb(a,{organization:b,projectId:g()?.getClient()?.getDsn()?.projectId,prefix:c,severityAllowList:d,sendExceptionsToPostHog:e??!0}))}}}a.s(["PostHogSentryIntegration",0,bd,"createEventProcessor",0,bb,"sentryIntegration",0,bc],9318),a.i(9318),a.i(40602),a.i(46539),a.s(["FeatureFlagError",0,s,"PostHogSentryIntegration",0,bd,"createEventProcessor",0,bb,"sentryIntegration",0,bc,"setupExpressErrorHandler",0,a8],80456),a.i(80456),a.s(["FeatureFlagError",0,s,"PostHog",0,a9,"PostHogSentryIntegration",0,bd,"createEventProcessor",0,bb,"sentryIntegration",0,bc,"setupExpressErrorHandler",0,a8],74493)}];
2
2
 
3
3
  //# sourceMappingURL=node_modules_posthog-node_dist_entrypoints_index_node_mjs_0mebn66._.js.map
@@ -7,9 +7,9 @@ globalThis.__BUILD_MANIFEST = {
7
7
  "static/chunks/03~yq9q893hmn.js"
8
8
  ],
9
9
  "lowPriorityFiles": [
10
- "static/B9luWx1Z31ygILxMA8k6o/_buildManifest.js",
11
- "static/B9luWx1Z31ygILxMA8k6o/_ssgManifest.js",
12
- "static/B9luWx1Z31ygILxMA8k6o/_clientMiddlewareManifest.js"
10
+ "static/OCXqJ711WVPVfYYr2iQc0/_buildManifest.js",
11
+ "static/OCXqJ711WVPVfYYr2iQc0/_ssgManifest.js",
12
+ "static/OCXqJ711WVPVfYYr2iQc0/_clientMiddlewareManifest.js"
13
13
  ],
14
14
  "rootMainFiles": [
15
15
  "static/chunks/115dplafwys-z.js",