@buoy-gg/network 7.0.77 → 7.0.79

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 (84) hide show
  1. package/README.md +68 -2
  2. package/lib/commonjs/expo-network.js +1 -0
  3. package/lib/commonjs/index.js +1 -1
  4. package/lib/commonjs/index.web.js +1 -1
  5. package/lib/commonjs/netinfo.js +1 -0
  6. package/lib/commonjs/network/components/NetworkCopySettingsView.js +1 -1
  7. package/lib/commonjs/network/components/NetworkEventDetailView.js +2 -2
  8. package/lib/commonjs/network/components/NetworkEventDetailView.web.js +1 -1
  9. package/lib/commonjs/network/components/NetworkEventItemCompact.js +2 -2
  10. package/lib/commonjs/network/components/NetworkEventItemCompact.web.js +1 -1
  11. package/lib/commonjs/network/components/NetworkListScreen.js +1 -1
  12. package/lib/commonjs/network/components/NetworkModal.js +1 -1
  13. package/lib/commonjs/network/components/NetworkSavedScreen.js +1 -1
  14. package/lib/commonjs/network/conditions/NetworkConditionsControl.js +1 -1
  15. package/lib/commonjs/network/conditions/NetworkConditionsControl.test.js +1 -1
  16. package/lib/commonjs/network/conditions/NetworkConditionsIcon.js +1 -1
  17. package/lib/commonjs/network/conditions/NetworkFloatingTool.js +1 -1
  18. package/lib/commonjs/network/conditions/NetworkFloatingTool.test.js +1 -1
  19. package/lib/commonjs/network/conditions/connectivity/netInfoFacade.js +1 -0
  20. package/lib/commonjs/network/conditions/connectivity/patchNetwork.js +1 -0
  21. package/lib/commonjs/network/conditions/pacer.js +1 -0
  22. package/lib/commonjs/network/conditions/profiles.js +1 -0
  23. package/lib/commonjs/network/conditions/remoteState.js +1 -0
  24. package/lib/commonjs/network/conditions/store.js +1 -1
  25. package/lib/commonjs/network/conditions/wait.js +1 -1
  26. package/lib/commonjs/network/conditions/xhr.js +1 -1
  27. package/lib/commonjs/network/overrides/engine.js +1 -1
  28. package/lib/commonjs/network/overrides/matchRule.js +1 -1
  29. package/lib/commonjs/network/overrides/overrideRulesStore.js +1 -1
  30. package/lib/commonjs/network/sync/networkSyncAdapter.js +1 -1
  31. package/lib/commonjs/network/utils/generateNetworkCopyText.js +1 -0
  32. package/lib/commonjs/network/utils/networkListener.js +4 -4
  33. package/lib/module/expo-network.js +1 -0
  34. package/lib/module/index.js +1 -1
  35. package/lib/module/index.web.js +1 -1
  36. package/lib/module/netinfo.js +1 -0
  37. package/lib/module/network/components/NetworkCopySettingsView.js +3 -3
  38. package/lib/module/network/components/NetworkEventDetailView.js +2 -2
  39. package/lib/module/network/components/NetworkEventDetailView.web.js +2 -2
  40. package/lib/module/network/components/NetworkEventItemCompact.js +2 -2
  41. package/lib/module/network/components/NetworkEventItemCompact.web.js +1 -1
  42. package/lib/module/network/components/NetworkListScreen.js +1 -1
  43. package/lib/module/network/components/NetworkModal.js +1 -1
  44. package/lib/module/network/components/NetworkSavedScreen.js +1 -1
  45. package/lib/module/network/conditions/NetworkConditionsControl.js +1 -1
  46. package/lib/module/network/conditions/NetworkConditionsControl.test.js +1 -1
  47. package/lib/module/network/conditions/NetworkConditionsIcon.js +1 -1
  48. package/lib/module/network/conditions/NetworkFloatingTool.js +1 -1
  49. package/lib/module/network/conditions/NetworkFloatingTool.test.js +1 -1
  50. package/lib/module/network/conditions/connectivity/netInfoFacade.js +1 -0
  51. package/lib/module/network/conditions/connectivity/patchNetwork.js +1 -0
  52. package/lib/module/network/conditions/pacer.js +1 -0
  53. package/lib/module/network/conditions/profiles.js +1 -0
  54. package/lib/module/network/conditions/remoteState.js +1 -0
  55. package/lib/module/network/conditions/store.js +1 -1
  56. package/lib/module/network/conditions/wait.js +1 -1
  57. package/lib/module/network/conditions/xhr.js +1 -1
  58. package/lib/module/network/overrides/engine.js +1 -1
  59. package/lib/module/network/overrides/matchRule.js +1 -1
  60. package/lib/module/network/overrides/overrideRulesStore.js +1 -1
  61. package/lib/module/network/sync/networkSyncAdapter.js +1 -1
  62. package/lib/module/network/utils/generateNetworkCopyText.js +23 -22
  63. package/lib/module/network/utils/networkListener.js +4 -4
  64. package/lib/typescript/expo-network.d.ts +2 -0
  65. package/lib/typescript/index.d.ts +3 -2
  66. package/lib/typescript/index.web.d.ts +3 -2
  67. package/lib/typescript/netinfo.d.ts +3 -0
  68. package/lib/typescript/network/conditions/NetworkConditionsControl.d.ts +5 -2
  69. package/lib/typescript/network/conditions/NetworkFloatingTool.d.ts +4 -3
  70. package/lib/typescript/network/conditions/connectivity/netInfoFacade.d.ts +3 -0
  71. package/lib/typescript/network/conditions/connectivity/patchNetwork.d.ts +24 -0
  72. package/lib/typescript/network/conditions/pacer.d.ts +16 -0
  73. package/lib/typescript/network/conditions/profiles.d.ts +57 -0
  74. package/lib/typescript/network/conditions/remoteState.d.ts +4 -0
  75. package/lib/typescript/network/conditions/store.d.ts +45 -19
  76. package/lib/typescript/network/conditions/xhr.d.ts +1 -1
  77. package/lib/typescript/network/overrides/engine.d.ts +14 -0
  78. package/lib/typescript/network/overrides/matchRule.d.ts +3 -0
  79. package/lib/typescript/network/overrides/overrideRulesStore.d.ts +3 -0
  80. package/lib/typescript/network/overrides/types.d.ts +19 -0
  81. package/lib/typescript/network/sync/networkSyncAdapter.d.ts +27 -12
  82. package/lib/typescript/network/utils/networkListener.d.ts +4 -0
  83. package/lib/web/index.mjs +58 -57
  84. package/package.json +26 -3
package/lib/web/index.mjs CHANGED
@@ -1,114 +1,115 @@
1
- "use client";var lo=Object.defineProperty;var Ws=Object.getOwnPropertyDescriptor;var Vs=Object.getOwnPropertyNames;var Us=Object.prototype.hasOwnProperty;var gr=(e,t)=>()=>(e&&(t=e(e=0)),t);var _s=(e,t)=>{for(var r in t)lo(e,r,{get:t[r],enumerable:true})},uo=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Vs(t))!Us.call(e,n)&&n!==r&&lo(e,n,{get:()=>t[n],enumerable:!(o=Ws(t,n))||o.enumerable});return e},Xs=(e,t,r)=>(uo(e,t,"default"),r&&uo(r,t,"default"));var Js=e=>uo(lo({},"__esModule",{value:true}),e);var ce,q=gr(()=>{"use strict";ce=(()=>{try{let e=globalThis.Capacitor;if(e&&typeof e.isNativePlatform=="function"&&e.isNativePlatform())return e.DEBUG===true}catch{}return process.env.NODE_ENV!=="production"})();typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis)});var fn,Gs=gr(()=>{"use strict";q();fn='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif'});import{useEffect as Ks,useState as Qs}from"react";import{createPortal as Zs}from"react-dom";import{jsx as Ys}from"react/jsx-runtime";function gn(){let e=document;if(e[Dt])return e[Dt].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:fn});let r=()=>{let u=document.fullscreenElement,v=u&&u.tagName!=="CANVAS"?u:document.body;t.parentElement!==v&&v.appendChild(t)},o=new Map,n=u=>{(!t.contains(u.target)||!co(u.target))&&o.set(u.code||u.key,{key:u.key,code:u.code,location:u.location,keyCode:u.keyCode,which:u.which,altKey:u.altKey,ctrlKey:u.ctrlKey,metaKey:u.metaKey,shiftKey:u.shiftKey})},i=u=>{o.delete(u.code||u.key)},s=()=>o.clear(),l=()=>{let u=[...o.values()];o.clear();for(let v of u)document.dispatchEvent(new KeyboardEvent("keyup",{...v,bubbles:true}))},a=u=>{co(u.target)&&u.stopPropagation()},d=u=>u.stopPropagation();return r(),document.addEventListener("fullscreenchange",r),document.addEventListener("keydown",n,true),document.addEventListener("keyup",i,true),window.addEventListener("blur",s),t.addEventListener("focusin",l),t.addEventListener("keydown",a),t.addEventListener("keyup",a),t.addEventListener("keypress",a),t.addEventListener("wheel",d,{passive:true}),e[Dt]={host:t,users:0,dispose:()=>{document.removeEventListener("fullscreenchange",r),document.removeEventListener("keydown",n,true),document.removeEventListener("keyup",i,true),window.removeEventListener("blur",s),t.remove(),delete e[Dt]}},t}function ea({children:e}){let[t,r]=Qs(null);return Ks(()=>{let o=gn(),n=document[Dt];return n.users++,r(o),()=>{--n.users===0&&n.dispose()}},[]),t?Zs(Ys("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}var Dt,co,ta=gr(()=>{"use strict";q();Gs();Dt=Symbol.for("@buoy-gg/portal-host"),co=e=>{if(!(e instanceof Element))return false;if(e.closest("input, textarea, select"))return true;let t=e.closest("[contenteditable]")?.getAttribute("contenteditable")?.toLowerCase();return t===""||t==="true"||t==="plaintext-only"}});var ho={};_s(ho,{AccessibilityInfo:()=>ia,ActivityIndicator:()=>yo,Alert:()=>Pn,Animated:()=>xn,AppRegistry:()=>aa,AppState:()=>la,Appearance:()=>sa,BackHandler:()=>da,Button:()=>En,CheckBox:()=>ka,Clipboard:()=>ua,DeviceEventEmitter:()=>$a,Dimensions:()=>ca,Easing:()=>ha,FlatList:()=>po,I18nManager:()=>pa,Image:()=>Ra,ImageBackground:()=>Ea,InteractionManager:()=>ga,Keyboard:()=>fa,KeyboardAvoidingView:()=>Ia,LayoutAnimation:()=>ma,Linking:()=>ya,LogBox:()=>Na,Modal:()=>kn,NativeEventEmitter:()=>ba,NativeModules:()=>na,PanResponder:()=>va,Picker:()=>Pa,PixelRatio:()=>Sa,Platform:()=>xa,Pressable:()=>Cn,ProgressBar:()=>Ba,RefreshControl:()=>La,SafeAreaView:()=>qa,ScrollView:()=>ht,SectionList:()=>Oa,Share:()=>wa,StatusBar:()=>Da,StyleSheet:()=>he,Switch:()=>Rn,Text:()=>b,TextInput:()=>zt,Touchable:()=>za,TouchableHighlight:()=>wn,TouchableNativeFeedback:()=>Aa,TouchableOpacity:()=>N,TouchableWithoutFeedback:()=>Tn,UIManager:()=>Ta,Vibration:()=>Ca,View:()=>f,VirtualizedList:()=>Ha,YellowBox:()=>Ma,findNodeHandle:()=>In,unstable_createElement:()=>oa,useColorScheme:()=>ja,useLocaleContext:()=>Fa,useWindowDimensions:()=>mn});import*as ra from"react-native-web";import{unstable_createElement as oa,NativeModules as na,AccessibilityInfo as ia,Appearance as sa,AppRegistry as aa,AppState as la,BackHandler as da,Clipboard as ua,Dimensions as ca,Easing as ha,I18nManager as pa,Keyboard as fa,InteractionManager as ga,LayoutAnimation as ma,Linking as ya,NativeEventEmitter as ba,PanResponder as va,PixelRatio as Sa,Platform as xa,Share as wa,UIManager as Ta,Vibration as Ca,CheckBox as ka,FlatList as po,Image as Ra,ImageBackground as Ea,KeyboardAvoidingView as Ia,Picker as Pa,ProgressBar as Ba,RefreshControl as La,SafeAreaView as qa,SectionList as Oa,StatusBar as Da,Touchable as za,TouchableNativeFeedback as Aa,VirtualizedList as Ha,YellowBox as Ma,LogBox as Na,DeviceEventEmitter as $a,useColorScheme as ja,useLocaleContext as Fa,useWindowDimensions as mn}from"react-native-web";import*as Ee from"react-native-web";import{createElement as fo,forwardRef as yn,useCallback as Wa,useRef as Va}from"react";function go(e){if(Array.isArray(e)){let v=e.map(go);return v.some((T,x)=>T!==e[x])?v:e}if(!e||typeof e!="object"||!vn.some(v=>e[v]!=null))return e;let{shadowColor:t,shadowOffset:r,shadowOpacity:o,shadowRadius:n,textShadowColor:i,textShadowOffset:s,textShadowRadius:l,...a}=e;if(t!=null||r!=null||o!=null||n!=null){let v=t??"black",T=o==null?v:`color-mix(in srgb, ${v} ${Math.min(o,1)*100}%, transparent)`,x=`${ct(r?.width??0)} ${ct(r?.height??0)} ${ct(n??0)} ${T}`;a.boxShadow=typeof a.boxShadow=="string"?`${a.boxShadow}, ${x}`:a.boxShadow??x}let{width:d=0,height:u=0}=s??{};if(i&&(d||u||l)){let v=`${ct(d)} ${ct(u)} ${ct(l??0)} ${i}`;a.textShadow=a.textShadow?`${a.textShadow}, ${v}`:v}return a}function bn(e,t){if(typeof e=="function")return o=>bn(e(o),t);let r=go(e);return t?[r,Sn[t]]:r}function ze(e){let t=yn((o,n)=>{let{accessibilityState:i,accessibilityValue:s,pointerEvents:l,...a}=o;for(let u of["busy","checked","disabled","expanded","selected"])i?.[u]!==void 0&&a[`aria-${u}`]===void 0&&(a[`aria-${u}`]=i[u]);for(let[u,v]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))s?.[u]!==void 0&&a[`aria-${v}`]===void 0&&(a[`aria-${v}`]=s[u]);let d=bn(a.style,l);return d!==a.style&&(a.style=d),fo(e,{...a,ref:n})}),r=e.State;return r&&Object.assign(t,{State:r}),t.displayName=e.displayName??e.name??"NativeWebView",t}var ut,vn,ct,Sn,he,f,b,xn,zt,N,wn,Tn,Cn,ht,mo,kn,Rn,yo,En,In,Pn,pe=gr(()=>{q();Xs(ho,ra);ta();ut=Ee,vn=["shadowColor","shadowOffset","shadowOpacity","shadowRadius","textShadowColor","textShadowOffset","textShadowRadius"],ct=e=>typeof e=="number"?`${e}px`:e;Sn=ut.StyleSheet.create({auto:{pointerEvents:"auto"},none:{pointerEvents:"none"},"box-none":{pointerEvents:"box-none"},"box-only":{pointerEvents:"box-only"}});he={...ut.StyleSheet,create:e=>ut.StyleSheet.create(Object.fromEntries(Object.entries(e).map(([t,r])=>[t,go(r)])))};f=ze(Ee.View),b=ze(Ee.Text),xn={...ut.Animated,View:ut.Animated.createAnimatedComponent(f),Text:ut.Animated.createAnimatedComponent(b)},zt=ze(Ee.TextInput),N=ze(Ee.TouchableOpacity),wn=ze(Ee.TouchableHighlight),Tn=ze(Ee.TouchableWithoutFeedback),Cn=ze(Ee.Pressable),ht=ze(Ee.ScrollView),mo=yn((e,t)=>{let r=Va(null),o=Wa(n=>{if(n){let i=n;for(;i.parentElement&&i.parentElement!==document.body;)i=i.parentElement;i.parentElement===document.body&&(r.current=i,Object.assign(i.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),gn().appendChild(i))}else r.current&&(document.body.appendChild(r.current),r.current=null);typeof t=="function"?t(n):t&&(t.current=n)},[t]);return fo(ea,null,fo(Ee.Modal,{...e,ref:o}))});mo.displayName="Modal";kn=ze(mo),Rn=ze(Ee.Switch),yo=ze(Ee.ActivityIndicator),En=ze(Ee.Button),In=Ee.findNodeHandle,Pn={alert(e,t,r,o){if(typeof document>"u")return;let n=document.createElement("dialog");n.dataset.buoyRoot="",n.setAttribute("aria-label",e),n.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let i=document.createElement("h2");if(i.textContent=e,i.style.cssText="font-size:18px;margin:0 0 12px",n.appendChild(i),t){let d=document.createElement("p");d.textContent=t,d.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",n.appendChild(d)}let s=document.createElement("div");s.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let l=r?.length?r:[{text:"OK"}],a=()=>{n.close?.(),n.remove()};for(let d of l){let u=document.createElement("button");u.type="button",u.textContent=d.text??"OK",u.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${d.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,u.onclick=()=>{a(),d.onPress?.()},s.appendChild(u)}n.addEventListener("cancel",d=>{d.preventDefault(),o?.cancelable!==false&&(a(),o?.onDismiss?.())}),n.appendChild(s),document.body.appendChild(n),n.showModal?n.showModal():n.setAttribute("open","")}}});q();q();q();pe();import{useSyncExternalStore as Ua}from"react";import{NetworkIcon as _a}from"@buoy-gg/shared-ui/web";q();import{hasAccountAccess as Bn,subscribeAccountAccess as Xa}from"@buoy-gg/shared-ui/web";q();import{isBuoyRequest as Ja}from"@buoy-gg/shared-ui/web";q();function mr(e){if(typeof document>"u")return e;try{return new URL(e,document.baseURI).href}catch{return e}}q();var Ln=globalThis;function yr(e){let t=Ln.__BUOY_NETWORK_REQUEST_SEQUENCE__??(Ln.__BUOY_NETWORK_REQUEST_SEQUENCE__={session:`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,next:0});return`${e}_${t.session}_${++t.next}`}q();q();q();function ue(){let e=globalThis.__buoyRealNow;return typeof e=="function"?e():Date.now()}function qn(){return globalThis.__buoyRealTimers??globalThis}function bo(e,t){return qn().setTimeout(e,t)}function Jt(e){qn().clearTimeout(e)}var On=2,Dn=3,Gt=4,br=e=>e,zn=false;function An(e){let t=br(e);return typeof t.setReadyState=="function"&&typeof t.setResponseHeaders=="function"}function Ga(e){return typeof e.addEventListener=="function"&&typeof e.removeEventListener=="function"&&typeof e.dispatchEvent=="function"}function Ka(){zn||(zn=true,typeof ce<"u"&&ce&&console.warn("[Buoy] Network overrides need an XMLHttpRequest they can drive (React Native's, or a standards EventTarget one) and this environment provides neither \u2014 requests will run normally."))}function Hn(e,t,r){let o=br(e);o.responseURL=t,o.status=r.status,o.statusText=r.statusText,o.setResponseHeaders?.(r.headers),o.setReadyState?.(On),!o._aborted&&(o._responseType="text",o._response=r.body,o._cachedResponse=void 0,o.setReadyState?.(Dn),!o._aborted&&o.setReadyState?.(Gt))}function Mn(e,t){let r=br(e),o=t.failKind==="timeout";r._hasError=true,r._timedOut=o,r._responseType="text",r._response=o?"Request timed out (Buoy override)":"Network request failed (Buoy override)",r._cachedResponse=void 0,r.setReadyState?.(Gt)}function Ke(e,t,r){Object.defineProperty(e,t,{value:r,configurable:true,enumerable:true,writable:false})}function Qa(e){if(e!=="readystatechange"&&typeof ProgressEvent=="function")try{return new ProgressEvent(e)}catch{}if(typeof Event=="function")try{return new Event(e)}catch{}return{type:e}}function pt(e,t){e.dispatchEvent(Qa(t))}function Kt(e,t){Ke(e,"readyState",t),pt(e,"readystatechange")}function Za(e,t){let r="";try{r=e.responseType}catch{}switch(r){case"":case"text":return t.body;case"json":try{return JSON.parse(t.body)}catch{return null}case"arraybuffer":return typeof TextEncoder=="function"?new TextEncoder().encode(t.body).buffer:t.body;case"blob":if(typeof Blob=="function"){let o=Object.entries(t.headers).find(([n])=>n.toLowerCase()==="content-type")?.[1]??"";return new Blob([t.body],{type:o})}return t.body;default:return t.body}}function Ya(e,t,r,o){let n=r.headers,i=Object.entries(n).map(([s,l])=>`${s.toLowerCase()}: ${l}\r
2
- `).join("");Ke(e,"getAllResponseHeaders",()=>i),Ke(e,"getResponseHeader",s=>{let l=String(s).toLowerCase();for(let[a,d]of Object.entries(n))if(a.toLowerCase()===l)return d;return null}),Ke(e,"responseURL",t),Ke(e,"status",r.status),Ke(e,"statusText",r.statusText),Ke(e,"response",Za(e,r)),Ke(e,"responseText",r.body),Kt(e,On),!o()&&(Kt(e,Dn),!o()&&(Kt(e,Gt),!o()&&(pt(e,"load"),pt(e,"loadend"))))}function vo(e,t){Kt(e,Gt),pt(e,t.failKind==="timeout"?"timeout":"error"),pt(e,"loadend")}var At=new WeakMap;function el(e){return At.has(e)}function tl(e,t,r,o){let n=ue(),i={},s,l,a=false,d=false,u=false,v=e.timeout,T=e.abort,x=e.open,L=["abort","open","timeout","readyState","status","statusText","response","responseText","responseURL","getAllResponseHeaders","getResponseHeader"],m=new Map(L.map(H=>[H,Object.getOwnPropertyDescriptor(e,H)])),k=Object.getPrototypeOf(e),E;for(;k&&!E;)E=Object.getOwnPropertyDescriptor(k,"timeout"),k=Object.getPrototypeOf(k);let g=()=>{a=true,At.get(e)===i&&At.delete(e),clearTimeout(s),Jt(l),e.removeEventListener("loadend",g)},I=()=>{g();for(let[H,S]of m)S?Object.defineProperty(e,H,S):delete e[H];e.timeout=v},D=()=>{Jt(l),u?E?.set?.call(e,v>0?Math.max(1,v-(ue()-n)):0):v>0&&(l=bo(()=>{a||(clearTimeout(s),vo(e,{...r,kind:"fail",failKind:"timeout"}),g())},Math.max(0,v-(ue()-n))))};return Object.defineProperty(e,"timeout",{configurable:true,get:()=>v,set:H=>{v=Math.max(0,Number(H)||0),D()}}),Object.defineProperty(e,"open",{configurable:true,value:(...H)=>(I(),Reflect.apply(x,e,H))}),Object.defineProperty(e,"abort",{configurable:true,value:()=>{if(u||a){I(),T.call(e);return}d=true,clearTimeout(s),Kt(e,Gt),pt(e,"abort"),pt(e,"loadend"),g(),At.has(e)||Ke(e,"readyState",0)}}),At.set(e,i),e.addEventListener("loadend",g),D(),s=setTimeout(()=>{if(!(a||d)){if(r.kind==="delay"){u=true,D();try{o()}catch{vo(e,{...r,kind:"fail",failKind:"network"}),g()}return}r.kind==="fail"?vo(e,r):Ya(e,t,r,()=>d||At.get(e)!==i),g()}},r.delayMs),true}function Nn(e,t,r,o){if(!An(e))return Ga(e)?tl(e,t,r,o):(Ka(),false);let n=br(e);n._sent=true,n._requestId=null;let i=null,s=()=>{e.removeEventListener("abort",s),i!==null&&(clearTimeout(i),i=null)};return e.addEventListener("abort",s),i=setTimeout(()=>{if(i=null,e.removeEventListener("abort",s),!n._aborted){if(r.kind==="delay"){n._sent=false,o();return}if(r.kind==="fail"){Mn(e,r);return}Hn(e,t,r)}},r.delayMs),true}function rl(e,t,r){r.kind==="fail"?Mn(e,r):r.kind==="respond"&&Hn(e,t,r)}function ol(e,t,r,o,n){if(!An(e)){let S={id:"condition",enabled:true,urlPattern:t,kind:"delay",hits:0,seen:0,createdAt:Date.now()},z=r.profile==="offline"?{kind:"fail",rule:S,failKind:"network",delayMs:0}:o?{...o,delayMs:r.delayMs+o.delayMs}:{kind:"delay",rule:S,delayMs:r.delayMs};if(!Nn(e,t,z,n))throw new Error("Network conditions are unavailable for this XMLHttpRequest implementation.");return}let i=e;if(i.readyState!==1||i._sent)throw new Error("Request is not open or has already been sent.");let s=ue(),l=i.timeout,a=false,d=false,u,v,T=i.abort,x=i.open,L=Object.getOwnPropertyDescriptor(i,"abort"),m=Object.getOwnPropertyDescriptor(i,"open"),k=Object.getOwnPropertyDescriptor(i,"timeout"),E=(S,z)=>{z?Object.defineProperty(i,S,z):delete i[S]},g=()=>{a||(a=true,clearTimeout(v),Jt(u),i.removeEventListener("loadend",g),E("abort",L),E("open",m),E("timeout",k),i.timeout=l)},I=S=>{a||(Object.assign(i,{readyState:4}),T.call(i),i._aborted=false,i._hasError=true,i._timedOut=S,i._response=S?"Request timed out (Buoy conditions)":"Network request failed (Buoy Offline)",i.setReadyState(4),g())},D=()=>l>0&&ue()-s>=l,H=()=>{Jt(u),l>0&&(u=bo(()=>I(true),Math.max(0,l-(ue()-s))))};Object.defineProperty(i,"timeout",{configurable:true,get:()=>d?0:l,set:S=>{l=Math.max(0,Number(S)||0),H()}}),Object.defineProperty(i,"abort",{configurable:true,value:()=>{a||(T.call(i),g())}}),Object.defineProperty(i,"open",{configurable:true,value:(...S)=>{let z=Reflect.apply(x,i,S);return g(),z}}),i._sent=true,i._requestId=null,i.addEventListener("loadend",g),H(),v=setTimeout(()=>{if(!a){if(D()){I(true);return}if(r.profile==="offline"){I(false);return}if(o&&o.kind!=="delay"){rl(i,t,o);return}i._sent=false,d=true;try{n()}catch{I(false)}finally{d=false}}},r.delayMs+(o?.delayMs??0))}q();function vr(e){if(!e?.aborted)return;if(e.reason!==void 0)throw e.reason;let t=new Error("The request was aborted.");throw t.name="AbortError",t}function nl(e,t){return new Promise((r,o)=>{try{vr(t)}catch(l){o(l);return}let n=()=>t?.removeEventListener("abort",i),i=()=>{clearTimeout(s),n();try{vr(t)}catch(l){o(l)}},s=setTimeout(()=>{n(),r()},e);t?.addEventListener("abort",i,{once:true})})}q();import{getAccountAccess as $n,hasAccountAccess as jn,subscribeAccountAccess as il}from"@buoy-gg/shared-ui/web";q();q();var Fn=[204,205,304];function Wn(){return typeof Response=="function"}function sl(e,t){let r=Fn.includes(t.status)?null:t.body,o=new Response(r,{status:t.status,statusText:t.statusText,headers:t.headers});try{Object.defineProperty(o,"url",{value:e,configurable:true})}catch{}return o}function al(e){return new TypeError(e.failKind==="timeout"?"Network request timed out":"Network request failed")}q();var ll="[]{}()\\.^$+|-,?";function Vn(e){let t="";for(let r=0;r<e.length;r++){let o=e.charAt(r);ll.indexOf(o)!==-1&&(t+="\\"),t+=o}return t.split("*").join(".*")}var Sr=new Map;function dl(e){let t=Sr.get(e);if(t)return t;let r=e.startsWith("/")?`[a-zA-Z][a-zA-Z0-9+.-]*://[^/]*${Vn(e)}`:Vn(e),o=new RegExp(`^${r}$`);return Sr.size>200&&Sr.clear(),Sr.set(e,o),o}function ul(e,t){if(!e)return false;let r=t.toLowerCase();for(let o of Object.keys(e))if(o.toLowerCase()===r&&e[o]!==void 0&&e[o]!=="")return true;return false}function So(e,t,r,o,n){if(e.methods&&e.methods.length>0&&!e.methods.includes(r.toUpperCase())||e.requireHeader&&!ul(o,e.requireHeader)||e.bodyIncludes&&(typeof n!="string"||!n.includes(e.bodyIncludes)))return false;try{return dl(e.urlPattern).test(t)}catch{return false}}q();import{TIER_LIMITS as cl}from"@buoy-gg/shared-ui/web";var Qt=200,Zt=599,Fe=50,Un=cl["network.overrideRules"].free;function _n(e){return{ruleId:e.rule.id,ruleName:e.rule.name,kind:e.kind,delayMs:e.delayMs||void 0}}var hl=[/(^|\.)keygen\.sh/i,/^https?:\/\/(www\.)?buoy\.gg\/api\/license(\/|$)/i];function pl(e){return hl.some(t=>t.test(e))}function fl(e){let t=e.trim();if(t==="")return"text/plain; charset=utf-8";if(t.startsWith("{")||t.startsWith("["))try{return JSON.parse(t),"application/json"}catch{}return"text/plain; charset=utf-8"}function gl(e,t){let r=t.toLowerCase();return Object.keys(e).some(o=>o.toLowerCase()===r)}function ml(e){let t=Math.max(0,e.delayMs??0);if(e.kind==="delay")return{kind:"delay",rule:e,delayMs:t};if(e.kind==="fail")return{kind:"fail",rule:e,delayMs:t,failKind:e.failKind??"network"};let r=Math.min(Zt,Math.max(Qt,e.status??200)),o=Fn.includes(r)?"":e.body??"",n={...e.headers??{}};return gl(n,"content-type")||(n["content-type"]=fl(o)),{kind:"respond",rule:e,delayMs:t,status:r,statusText:e.statusText??"",headers:n,body:o}}function xo(e){return typeof e.times=="number"&&e.hits>=e.times}function yl(e){return e.alternate?e.seen%2===1:true}function wo(e,t,r,o,n){if(r.length===0||t.toUpperCase()==="OPTIONS"||pl(e))return null;for(let i of r)if(i.enabled&&!xo(i)&&So(i,e,t,o,n))return i;return null}var Ae=null;function bl(e){Ae=e}function Xn(){return jn()&&!(typeof ce<"u"&&!ce)}var vl="Response overrides never apply in a release build \u2014 the rule is saved but will not affect any request.";function Sl(e,t){return{hooksInstalled:Ae!==null,devFlag:typeof ce>"u"?"undefined":ce,ruleCount:Ae?Ae.getRules().length:0,matches:Ae?wo(e,t,Ae.getRules())!==null:false}}var xl=3e3;function wl(e,t,r,o){return!Ae||jn()||typeof ce<"u"&&!ce||$n().status!=="initializing"||!wo(e,t,Ae.getRules(),r,o)?null:new Promise(n=>{let i=()=>{},s=()=>{Jt(l),i(),n()},l=bo(s,xl);i=il(()=>{$n().status!=="initializing"&&s()})})}function Jn(e,t,r,o){if(!Ae||!Xn())return null;let n=Ae.getRules();if(n.length===0)return null;let i=wo(e,t,n,r,o);if(!i)return null;let s=yl(i);return Ae.recordMatch(i.id),s?(Ae.recordHit(i.id),ml(i)):null}q();var Tl={400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",408:"Request Timeout",429:"Too Many Requests",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout"};function Cl(e){return typeof e=="number"&&e>0?"response":"error"}function kl(e,t){let r=(t??"").trim();return r||(Tl[e]??"")}var ft;function Gn(e){let t=globalThis.__buoyHeaderInjectors;if(!t||t.length===0)return;let r;for(let o of t)try{let n=o(e);n&&(r={...r,...n})}catch{}return r}function Rl(){if(ft!==void 0)return ft;ft=null;try{if(typeof ce<"u"&&!ce)return ft;let e=(pe(),Js(ho))?.NativeModules?.SourceCode,t=e?.getConstants?.().scriptURL??e?.scriptURL;if(typeof t=="string"&&/^https?:\/\//.test(t)){let r=new URL(t);ft=`${r.protocol}//${r.host}`}}catch{ft=null}return ft}var gt=false;function El(e){let t={};if(!e)return t;if(typeof Headers<"u"&&e instanceof Headers)e.forEach((r,o)=>{t[o]=r});else if(Array.isArray(e))for(let[r,o]of e)t[r]=o;else Object.assign(t,e);return t}var Kn="__buoyNetworkFetchIntercepted",Qn="__buoyNetworkXhrIntercepted",Il=["text/event-stream","application/x-ndjson","application/stream+json"],Zn="[streaming\u2026]",To=false;function Pl(){return To?true:(To=!!globalThis.document?.querySelector?.("[ng-version]"),To)}function Yn(e){if(!e)return false;let t=e.toLowerCase();return Il.some(r=>t.includes(r))}var Bl="__BUOY_INTERNAL_HOSTS__";function Ll(e){let t=globalThis[Bl];if(!(t instanceof Set)||t.size===0)return false;let r;try{r=new URL(e).host.toLowerCase()}catch{return false}for(let o of t)if(typeof o=="string"&&o&&r===o.toLowerCase())return true;return false}var ql=class{constructor(){this.listeners=[];this.isListening=false;this.patchedFetch=null;this.patchedXHROpen=null;this.patchedXHRSend=null;this.patchedXHRSetRequestHeader=null;this.fetchGeneration=0;this.xhrGeneration=0;this.originalFetch=globalThis.fetch,this.originalXHROpen=XMLHttpRequest.prototype.open,this.originalXHRSend=XMLHttpRequest.prototype.send,this.originalXHRSetRequestHeader=XMLHttpRequest.prototype.setRequestHeader}shouldIgnoreUrl(e){if(Ja(e))return true;try{let t=new URL(e);if(t.hostname==="keygen.sh"||t.hostname.endsWith(".keygen.sh")||(t.hostname==="buoy.gg"||t.hostname==="www.buoy.gg")&&(t.pathname.startsWith("/api/license")||t.pathname.startsWith("/api/settings/"))||(t.hostname==="localhost"||t.hostname==="127.0.0.1"||t.hostname==="10.0.2.2")&&["8081","8802"].includes(t.port))return true;let r=Rl();if(r&&`${t.protocol}//${t.host}`===r)return true}catch{return false}return Ll(e)}emit(e){this.listeners.forEach(t=>{try{t(e)}catch{}})}parseUrl(e){let t=null,r=e.indexOf("?");return r>-1&&(t={},e.substring(r+1).split("&").forEach(o=>{let[n,i]=o.split("=");n&&i!==void 0&&(t[n]=decodeURIComponent(i.replace(/\+/g," ")))})),{url:r>-1?e.substring(0,r):e,params:t}}async readStreamedBody(e,t=256*1024){let r=e.body;if(!r||typeof r.getReader!="function"){let a=await e.text();return a.length>t?{body:`${a.slice(0,t)}
1
+ "use client";var qo=Object.defineProperty;var Sa=Object.getOwnPropertyDescriptor;var wa=Object.getOwnPropertyNames;var xa=Object.prototype.hasOwnProperty;var Ir=(e,t)=>()=>(e&&(t=e(e=0)),t);var Ca=(e,t)=>{for(var r in t)qo(e,r,{get:t[r],enumerable:true})},Oo=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of wa(t))!xa.call(e,n)&&n!==r&&qo(e,n,{get:()=>t[n],enumerable:!(o=Sa(t,n))||o.enumerable});return e},ka=(e,t,r)=>(Oo(e,t,"default"),r&&Oo(r,t,"default"));var Ta=e=>Oo(qo({},"__esModule",{value:true}),e);var me,O=Ir(()=>{"use strict";me=(()=>{try{let e=globalThis.Capacitor;if(e&&typeof e.isNativePlatform=="function"&&e.isNativePlatform())return e.DEBUG===true}catch{}return process.env.NODE_ENV!=="production"})();typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis)});var _n,Ra=Ir(()=>{"use strict";O();_n='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif'});import{useEffect as Ea,useState as Ia}from"react";import{createPortal as Pa}from"react-dom";import{jsx as La}from"react/jsx-runtime";function Xn(){let e=document;if(e[Xt])return e[Xt].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:_n});let r=()=>{let d=document.fullscreenElement,g=d&&d.tagName!=="CANVAS"?d:document.body;t.parentElement!==g&&g.appendChild(t)},o=new Map,n=d=>{(!t.contains(d.target)||!zo(d.target))&&o.set(d.code||d.key,{key:d.key,code:d.code,location:d.location,keyCode:d.keyCode,which:d.which,altKey:d.altKey,ctrlKey:d.ctrlKey,metaKey:d.metaKey,shiftKey:d.shiftKey})},i=d=>{o.delete(d.code||d.key)},s=()=>o.clear(),l=()=>{let d=[...o.values()];o.clear();for(let g of d)document.dispatchEvent(new KeyboardEvent("keyup",{...g,bubbles:true}))},a=d=>{zo(d.target)&&d.stopPropagation()},u=d=>d.stopPropagation();return r(),document.addEventListener("fullscreenchange",r),document.addEventListener("keydown",n,true),document.addEventListener("keyup",i,true),window.addEventListener("blur",s),t.addEventListener("focusin",l),t.addEventListener("keydown",a),t.addEventListener("keyup",a),t.addEventListener("keypress",a),t.addEventListener("wheel",u,{passive:true}),e[Xt]={host:t,users:0,dispose:()=>{document.removeEventListener("fullscreenchange",r),document.removeEventListener("keydown",n,true),document.removeEventListener("keyup",i,true),window.removeEventListener("blur",s),t.remove(),delete e[Xt]}},t}function Ba({children:e}){let[t,r]=Ia(null);return Ea(()=>{let o=Xn(),n=document[Xt];return n.users++,r(o),()=>{--n.users===0&&n.dispose()}},[]),t?Pa(La("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}var Xt,zo,qa=Ir(()=>{"use strict";O();Ra();Xt=Symbol.for("@buoy-gg/portal-host"),zo=e=>{if(!(e instanceof Element))return false;if(e.closest("input, textarea, select"))return true;let t=e.closest("[contenteditable]")?.getAttribute("contenteditable")?.toLowerCase();return t===""||t==="true"||t==="plaintext-only"}});var Do={};Ca(Do,{AccessibilityInfo:()=>Aa,ActivityIndicator:()=>Lr,Alert:()=>ai,Animated:()=>Qn,AppRegistry:()=>Ma,AppState:()=>Na,Appearance:()=>Ha,BackHandler:()=>$a,Button:()=>ii,CheckBox:()=>tl,Clipboard:()=>Fa,DeviceEventEmitter:()=>gl,Dimensions:()=>ja,Easing:()=>Wa,FlatList:()=>Ao,I18nManager:()=>Va,Image:()=>rl,ImageBackground:()=>ol,InteractionManager:()=>_a,Keyboard:()=>Ua,KeyboardAvoidingView:()=>nl,LayoutAnimation:()=>Xa,Linking:()=>Ja,LogBox:()=>yl,Modal:()=>oi,NativeEventEmitter:()=>Ga,NativeModules:()=>Da,PanResponder:()=>Ka,Picker:()=>il,PixelRatio:()=>Ya,Platform:()=>Pr,Pressable:()=>ri,ProgressBar:()=>sl,RefreshControl:()=>al,SafeAreaView:()=>ll,ScrollView:()=>yt,SectionList:()=>dl,Share:()=>Za,StatusBar:()=>ul,StyleSheet:()=>ve,Switch:()=>ni,Text:()=>b,TextInput:()=>Jt,Touchable:()=>cl,TouchableHighlight:()=>ei,TouchableNativeFeedback:()=>hl,TouchableOpacity:()=>F,TouchableWithoutFeedback:()=>ti,UIManager:()=>Qa,Vibration:()=>el,View:()=>m,VirtualizedList:()=>pl,YellowBox:()=>fl,findNodeHandle:()=>si,unstable_createElement:()=>za,useColorScheme:()=>ml,useLocaleContext:()=>bl,useWindowDimensions:()=>Jn});import*as Oa from"react-native-web";import{unstable_createElement as za,NativeModules as Da,AccessibilityInfo as Aa,Appearance as Ha,AppRegistry as Ma,AppState as Na,BackHandler as $a,Clipboard as Fa,Dimensions as ja,Easing as Wa,I18nManager as Va,Keyboard as Ua,InteractionManager as _a,LayoutAnimation as Xa,Linking as Ja,NativeEventEmitter as Ga,PanResponder as Ka,PixelRatio as Ya,Platform as Pr,Share as Za,UIManager as Qa,Vibration as el,CheckBox as tl,FlatList as Ao,Image as rl,ImageBackground as ol,KeyboardAvoidingView as nl,Picker as il,ProgressBar as sl,RefreshControl as al,SafeAreaView as ll,SectionList as dl,StatusBar as ul,Touchable as cl,TouchableNativeFeedback as hl,VirtualizedList as pl,YellowBox as fl,LogBox as yl,DeviceEventEmitter as gl,useColorScheme as ml,useLocaleContext as bl,useWindowDimensions as Jn}from"react-native-web";import*as He from"react-native-web";import{createElement as Ho,forwardRef as Gn,useCallback as vl,useRef as Sl}from"react";function Mo(e){if(Array.isArray(e)){let g=e.map(Mo);return g.some((x,y)=>x!==e[y])?g:e}if(!e||typeof e!="object"||!Yn.some(g=>e[g]!=null))return e;let{shadowColor:t,shadowOffset:r,shadowOpacity:o,shadowRadius:n,textShadowColor:i,textShadowOffset:s,textShadowRadius:l,...a}=e;if(t!=null||r!=null||o!=null||n!=null){let g=t??"black",x=o==null?g:`color-mix(in srgb, ${g} ${Math.min(o,1)*100}%, transparent)`,y=`${kt(r?.width??0)} ${kt(r?.height??0)} ${kt(n??0)} ${x}`;a.boxShadow=typeof a.boxShadow=="string"?`${a.boxShadow}, ${y}`:a.boxShadow??y}let{width:u=0,height:d=0}=s??{};if(i&&(u||d||l)){let g=`${kt(u)} ${kt(d)} ${kt(l??0)} ${i}`;a.textShadow=a.textShadow?`${a.textShadow}, ${g}`:g}return a}function Kn(e,t){if(typeof e=="function")return o=>Kn(e(o),t);let r=Mo(e);return t?[r,Zn[t]]:r}function Ve(e){let t=Gn((o,n)=>{let{accessibilityState:i,accessibilityValue:s,pointerEvents:l,...a}=o;for(let d of["busy","checked","disabled","expanded","selected"])i?.[d]!==void 0&&a[`aria-${d}`]===void 0&&(a[`aria-${d}`]=i[d]);for(let[d,g]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))s?.[d]!==void 0&&a[`aria-${g}`]===void 0&&(a[`aria-${g}`]=s[d]);let u=Kn(a.style,l);return u!==a.style&&(a.style=u),Ho(e,{...a,ref:n})}),r=e.State;return r&&Object.assign(t,{State:r}),t.displayName=e.displayName??e.name??"NativeWebView",t}var Ct,Yn,kt,Zn,ve,m,b,Qn,Jt,F,ei,ti,ri,yt,No,oi,ni,Lr,ii,si,ai,Se=Ir(()=>{O();ka(Do,Oa);qa();Ct=He,Yn=["shadowColor","shadowOffset","shadowOpacity","shadowRadius","textShadowColor","textShadowOffset","textShadowRadius"],kt=e=>typeof e=="number"?`${e}px`:e;Zn=Ct.StyleSheet.create({auto:{pointerEvents:"auto"},none:{pointerEvents:"none"},"box-none":{pointerEvents:"box-none"},"box-only":{pointerEvents:"box-only"}});ve={...Ct.StyleSheet,create:e=>Ct.StyleSheet.create(Object.fromEntries(Object.entries(e).map(([t,r])=>[t,Mo(r)])))};m=Ve(He.View),b=Ve(He.Text),Qn={...Ct.Animated,View:Ct.Animated.createAnimatedComponent(m),Text:Ct.Animated.createAnimatedComponent(b)},Jt=Ve(He.TextInput),F=Ve(He.TouchableOpacity),ei=Ve(He.TouchableHighlight),ti=Ve(He.TouchableWithoutFeedback),ri=Ve(He.Pressable),yt=Ve(He.ScrollView),No=Gn((e,t)=>{let r=Sl(null),o=vl(n=>{if(n){let i=n;for(;i.parentElement&&i.parentElement!==document.body;)i=i.parentElement;i.parentElement===document.body&&(r.current=i,Object.assign(i.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),Xn().appendChild(i))}else r.current&&(document.body.appendChild(r.current),r.current=null);typeof t=="function"?t(n):t&&(t.current=n)},[t]);return Ho(Ba,null,Ho(He.Modal,{...e,ref:o}))});No.displayName="Modal";oi=Ve(No),ni=Ve(He.Switch),Lr=Ve(He.ActivityIndicator),ii=Ve(He.Button),si=He.findNodeHandle,ai={alert(e,t,r,o){if(typeof document>"u")return;let n=document.createElement("dialog");n.dataset.buoyRoot="",n.setAttribute("aria-label",e),n.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let i=document.createElement("h2");if(i.textContent=e,i.style.cssText="font-size:18px;margin:0 0 12px",n.appendChild(i),t){let u=document.createElement("p");u.textContent=t,u.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",n.appendChild(u)}let s=document.createElement("div");s.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let l=r?.length?r:[{text:"OK"}],a=()=>{n.close?.(),n.remove()};for(let u of l){let d=document.createElement("button");d.type="button",d.textContent=u.text??"OK",d.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${u.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,d.onclick=()=>{a(),u.onPress?.()},s.appendChild(d)}n.addEventListener("cancel",u=>{u.preventDefault(),o?.cancelable!==false&&(a(),o?.onDismiss?.())}),n.appendChild(s),document.body.appendChild(n),n.showModal?n.showModal():n.setAttribute("open","")}}});O();O();O();Se();import{useSyncExternalStore as li}from"react";import{NetworkIcon as wl}from"@buoy-gg/shared-ui/web";O();import{hasAccountAccess as di,subscribeAccountAccess as xl}from"@buoy-gg/shared-ui/web";O();O();O();function ue(){let e=globalThis.__buoyRealNow;return typeof e=="function"?e():Date.now()}function ui(){return globalThis.__buoyRealTimers??globalThis}function lr(e,t){return ui().setTimeout(e,t)}function Tt(e){ui().clearTimeout(e)}O();function lt(e){if(!e?.aborted)return;if(e.reason!==void 0)throw e.reason;let t=new Error("The request was aborted.");throw t.name="AbortError",t}function $o(e,t){return new Promise((r,o)=>{try{lt(t)}catch(l){o(l);return}let n=()=>t?.removeEventListener("abort",i),i=()=>{Tt(s),n();try{lt(t)}catch(l){o(l)}},s=lr(()=>{n(),r()},e);t?.addEventListener("abort",i,{once:true})})}var Br=e=>Math.max(1,Math.min(16384,Math.floor(e*.02))),Fo=e=>new TextEncoder().encode(e).byteLength;function qr(e){return e==null?0:typeof e=="string"?Fo(e):e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:typeof Blob<"u"&&e instanceof Blob?e.size:typeof URLSearchParams<"u"&&e instanceof URLSearchParams?Fo(e.toString()):null}async function Or(e,t,r,o){let n=Br(t),i=ue();for(let s=0;s<e;){let l=Math.min(n,e-s);await $o(Math.max(0,i+(s+l)/t*1e3-ue()),r),lt(r),s+=l,o?.(s,e)}}function Cl(e,t){try{let r=typeof e=="object"&&"method"in e?e:void 0,o=t?.body!==void 0?t.body:r&&"_bodyInit"in r?r._bodyInit:r?.body;return jo(o)}catch{return ci(0)}}function ci(e){return{knownBytes:e,status:e>0?"partial":"not-applied",note:e>0?"upload cap partial: size unknown":"upload cap not applied: size unknown"}}function jo(e){let t=0;try{let r=qr(e);if(r!==null)return{knownBytes:r,status:"applied"};if(e&&typeof e=="object"){let o=e,n=Array.isArray(o._parts)?o._parts:typeof FormData<"u"&&e instanceof FormData&&o.entries?o.entries():void 0;if(n)for(let[,i]of n)try{let s=qr(i);s!==null?t+=s:i&&typeof i=="object"&&"uri"in i&&"size"in i&&typeof i.size=="number"&&Number.isSafeInteger(i.size)&&i.size>=0&&(t+=i.size)}catch{}}}catch{}return ci(t)}function hi(e){let t=0;return async(r,o)=>{let n=r/e*1e3,i=ue(),s=Math.max(0,n-t);s>0&&await $o(s,o),lt(o),t=Math.min(Br(e)/e*1e3,Math.max(0,t+ue()-i-n))}}function kl(e,t,r,o){let n=hi(t),i,s=()=>{i?.releaseLock(),i=void 0},l=h=>{(i?i.cancel(h):e.cancel(h)).catch(()=>{}),s()},a=new AbortController,u,d=0,g=false,x,y=(h,C=false)=>{g||(g=true,r?.removeEventListener("abort",R),a.abort(),u=void 0,C?x.error(h):(s(),x.close()),o?.(null,h))},R=()=>{let h=r?.reason!==void 0?r.reason:Object.assign(new Error("The request was aborted."),{name:"AbortError"});y(h,true),l(h)};return new ReadableStream({start(h){x=h,r?.addEventListener("abort",R,{once:true}),r?.aborted&&R()},async pull(){try{if(!u||d===u.byteLength){let k=await(i??(i=e.getReader())).read();if(g)return;if(k.done){y();return}u=k.value,d=0}let h=Math.min(Br(t),u.byteLength-d),C=u.subarray(d,d+h);if(await n(h,a.signal),g)return;d+=h,o?.(C),x.enqueue(C)}catch(h){g||(y(h,true),l(h))}},cancel(h){g||(g=true,r?.removeEventListener("abort",R),a.abort(),u=void 0,o?.(null,h??new Error("Body read stopped."))),l(h)}},{highWaterMark:0})}function pi(e,t,r,o,n=false){if(n||[204,205,304].includes(e.status)||e.body===null)return o?.(null),e;let i,s=false,l=()=>{if(!i){let u,d=false,g=new ReadableStream({async pull(x){s=true;try{if(e.body?.getReader){u??(u=e.body.getReader());let y=await u.read();if(d)return;y.done?(d=true,u.releaseLock(),u=void 0,x.close()):x.enqueue(y.value)}else{let y=new Uint8Array(await e.arrayBuffer());if(d)return;x.enqueue(y),d=true,x.close()}}catch(y){d||(d=true,u?.releaseLock(),u=void 0,x.error(y))}},cancel(x){s=true,d=true;let y=u?u.cancel(x):e.body?.cancel?.(x);return u?.releaseLock(),u=void 0,y}},{highWaterMark:0});i=kl(g,t,r,o)}return i},a=async(u=true)=>{if(s||i?.locked||e.bodyUsed)throw new TypeError("Body has already been read.");s=true;let d=l().getReader(),g=[],x=0;try{for(;;){let h=await d.read();if(h.done)break;u&&(g.push(h.value),x+=h.value.byteLength)}}finally{d.releaseLock()}let y=new Uint8Array(x),R=0;for(let h of g)y.set(h,R),R+=h.byteLength;return y};return new Proxy(e,{get(u,d){if(d==="body")return l();if(d==="bodyUsed")return s||e.bodyUsed;if(d==="arrayBuffer")return async()=>(await a()).buffer;if(d==="bytes")return a;if(d==="text")return async()=>new TextDecoder().decode(await a());if(d==="json")return async()=>JSON.parse(new TextDecoder().decode(await a()));if(d==="blob")return async()=>{if(s||i?.locked||e.bodyUsed)throw new TypeError("Body has already been read.");lt(r);let x=false;try{new Blob([new Uint8Array(0)]),x=true}catch{}if(x)return new Blob([await a()],{type:u.headers.get("content-type")??""});let y=u.clone(),R;Object.defineProperty(y,"arrayBuffer",{configurable:true,value:async()=>(y.body&&!y.body.locked&&y.body.cancel().catch(()=>{}),R??(R=a()),(await R).buffer)});try{let h=y.blob();return h.catch(()=>{}),await(R??a(false)),lt(r),await h}finally{y.body&&!y.body.locked&&y.body.cancel().catch(()=>{})}};if(d==="formData")return async()=>{let x=await a();return new Response(x,{headers:u.headers}).formData()};if(d==="clone")return()=>{if(s||i?.locked||e.bodyUsed)throw new TypeError("Body has already been read.");return pi(u.clone(),t,r)};let g=Reflect.get(u,d,u);return typeof g=="function"?g.bind(u):g}})}import{isBuoyRequest as Tl}from"@buoy-gg/shared-ui/web";O();function zr(e){if(typeof document>"u")return e;try{return new URL(e,document.baseURI).href}catch{return e}}O();var fi=globalThis;function Dr(e){let t=fi.__BUOY_NETWORK_REQUEST_SEQUENCE__??(fi.__BUOY_NETWORK_REQUEST_SEQUENCE__={session:`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,next:0});return`${e}_${t.session}_${++t.next}`}O();O();var yi=2,gi=3,dr=4,Ar=e=>e,mi=false;function bi(e){let t=Ar(e);return typeof t.setReadyState=="function"&&typeof t.setResponseHeaders=="function"}function Rl(e){return typeof e.addEventListener=="function"&&typeof e.removeEventListener=="function"&&typeof e.dispatchEvent=="function"}function El(){mi||(mi=true,typeof me<"u"&&me&&console.warn("[Buoy] Network overrides need an XMLHttpRequest they can drive (React Native's, or a standards EventTarget one) and this environment provides neither \u2014 requests will run normally."))}function vi(e,t,r){let o=Ar(e);o.responseURL=t,o.status=r.status,o.statusText=r.statusText,o.setResponseHeaders?.(r.headers),o.setReadyState?.(yi),!o._aborted&&(o._responseType="text",o._response=r.body,o._cachedResponse=void 0,o.setReadyState?.(gi),!o._aborted&&o.setReadyState?.(dr))}function Si(e,t){let r=Ar(e),o=t.failKind==="timeout";r._hasError=true,r._timedOut=o,r._responseType="text",r._response=o?"Request timed out (Buoy override)":"Network request failed (Buoy override)",r._cachedResponse=void 0,r.setReadyState?.(dr)}function dt(e,t,r){Object.defineProperty(e,t,{value:r,configurable:true,enumerable:true,writable:false})}function Il(e){if(e!=="readystatechange"&&typeof ProgressEvent=="function")try{return new ProgressEvent(e)}catch{}if(typeof Event=="function")try{return new Event(e)}catch{}return{type:e}}function Rt(e,t){e.dispatchEvent(Il(t))}function ur(e,t){dt(e,"readyState",t),Rt(e,"readystatechange")}function Pl(e,t){let r="";try{r=e.responseType}catch{}switch(r){case"":case"text":return t.body;case"json":try{return JSON.parse(t.body)}catch{return null}case"arraybuffer":return typeof TextEncoder=="function"?new TextEncoder().encode(t.body).buffer:t.body;case"blob":if(typeof Blob=="function"){let o=Object.entries(t.headers).find(([n])=>n.toLowerCase()==="content-type")?.[1]??"";return new Blob([t.body],{type:o})}return t.body;default:return t.body}}function Ll(e,t,r,o){let n=r.headers,i=Object.entries(n).map(([s,l])=>`${s.toLowerCase()}: ${l}\r
2
+ `).join("");dt(e,"getAllResponseHeaders",()=>i),dt(e,"getResponseHeader",s=>{let l=String(s).toLowerCase();for(let[a,u]of Object.entries(n))if(a.toLowerCase()===l)return u;return null}),dt(e,"responseURL",t),dt(e,"status",r.status),dt(e,"statusText",r.statusText),dt(e,"response",Pl(e,r)),dt(e,"responseText",r.body),ur(e,yi),!o()&&(ur(e,gi),!o()&&(ur(e,dr),!o()&&(Rt(e,"load"),Rt(e,"loadend"))))}function Wo(e,t){ur(e,dr),Rt(e,t.failKind==="timeout"?"timeout":"error"),Rt(e,"loadend")}var Gt=new WeakMap;function Bl(e){return Gt.has(e)}function ql(e,t,r,o){let n=ue(),i={},s,l,a=false,u=false,d=false,g=e.timeout,x=e.abort,y=e.open,R=["abort","open","timeout","readyState","status","statusText","response","responseText","responseURL","getAllResponseHeaders","getResponseHeader"],h=new Map(R.map($=>[$,Object.getOwnPropertyDescriptor(e,$)])),C=Object.getPrototypeOf(e),k;for(;C&&!k;)k=Object.getOwnPropertyDescriptor(C,"timeout"),C=Object.getPrototypeOf(C);let w=()=>{a=true,Gt.get(e)===i&&Gt.delete(e),clearTimeout(s),Tt(l),e.removeEventListener("loadend",w)},I=()=>{w();for(let[$,P]of h)P?Object.defineProperty(e,$,P):delete e[$];e.timeout=g},z=()=>{Tt(l),d?k?.set?.call(e,g>0?Math.max(1,g-(ue()-n)):0):g>0&&(l=lr(()=>{a||(clearTimeout(s),Wo(e,{...r,kind:"fail",failKind:"timeout"}),w())},Math.max(0,g-(ue()-n))))};return Object.defineProperty(e,"timeout",{configurable:true,get:()=>g,set:$=>{g=Math.max(0,Number($)||0),z()}}),Object.defineProperty(e,"open",{configurable:true,value:(...$)=>(I(),Reflect.apply(y,e,$))}),Object.defineProperty(e,"abort",{configurable:true,value:()=>{if(d||a){I(),x.call(e);return}u=true,clearTimeout(s),ur(e,dr),Rt(e,"abort"),Rt(e,"loadend"),w(),Gt.has(e)||dt(e,"readyState",0)}}),Gt.set(e,i),e.addEventListener("loadend",w),z(),s=setTimeout(()=>{if(!(a||u)){if(r.kind==="delay"){d=true,z();try{o()}catch{Wo(e,{...r,kind:"fail",failKind:"network"}),w()}return}r.kind==="fail"?Wo(e,r):Ll(e,t,r,()=>u||Gt.get(e)!==i),w()}},r.delayMs),true}function wi(e,t,r,o){if(!bi(e))return Rl(e)?ql(e,t,r,o):(El(),false);let n=Ar(e);n._sent=true,n._requestId=null;let i=null,s=()=>{e.removeEventListener("abort",s),i!==null&&(clearTimeout(i),i=null)};return e.addEventListener("abort",s),i=setTimeout(()=>{if(i=null,e.removeEventListener("abort",s),!n._aborted){if(r.kind==="delay"){n._sent=false,o();return}if(r.kind==="fail"){Si(e,r);return}vi(e,t,r)}},r.delayMs),true}function Ol(e,t,r){r.kind==="fail"?Si(e,r):r.kind==="respond"&&vi(e,t,r)}function zl(e,t,r,o,n,i){if(!bi(e)){if(r.downloadBytesPerSecond)throw new Error("Byte caps need RN XHR. This XHR only supports waits and Offline.");let H={id:"condition",enabled:true,urlPattern:t,kind:"delay",hits:0,seen:0,createdAt:Date.now()},V=r.profile==="offline"?{kind:"fail",rule:H,failKind:"network",delayMs:0}:o?{...o,delayMs:r.delayMs+o.delayMs}:{kind:"delay",rule:H,delayMs:r.delayMs};if(!wi(e,t,V,n))throw new Error("Network conditions are unavailable for this XMLHttpRequest implementation.");return}let s=e;if(s.readyState!==1||s._sent)throw new Error("Request is not open or has already been sent.");let l=ue(),a=s.timeout,u=false,d=new AbortController,g=[],x=false,y,R,h=s.abort,C=s.open,k=Object.getOwnPropertyDescriptor(s,"abort"),w=Object.getOwnPropertyDescriptor(s,"open"),I=Object.getOwnPropertyDescriptor(s,"timeout"),z=(H,V)=>{V?Object.defineProperty(s,H,V):delete s[H]},$=()=>{u||(u=true,Tt(R),d.abort(),g.forEach(H=>H()),Tt(y),s.removeEventListener("loadend",$),z("abort",k),z("open",w),z("timeout",I),s.timeout=a)},P=(H,V)=>{u||(Object.assign(s,{readyState:4}),h.call(s),s._aborted=false,s._hasError=true,s._timedOut=H,s._response=V??(H?"Request timed out (Buoy conditions)":"Network request failed (Buoy Offline)"),s.setReadyState(4),$())},A=()=>a>0&&ue()-l>=a,v=()=>{Tt(y),a>0&&(y=lr(()=>P(true),Math.max(0,a-(ue()-l))))};Object.defineProperty(s,"timeout",{configurable:true,get:()=>x?0:a,set:H=>{a=Math.max(0,Number(H)||0),v()}}),Object.defineProperty(s,"abort",{configurable:true,value:()=>{u||(h.call(s),$())}}),Object.defineProperty(s,"open",{configurable:true,value:(...H)=>{let V=Reflect.apply(C,s,H);return $(),V}}),s._sent=true,s._requestId=null,s.addEventListener("loadend",$),v();let c=s,p=(H,V)=>{let Z=Object.getOwnPropertyDescriptor(s,H);Object.defineProperty(s,H,{configurable:true,writable:true,value:V}),g.push(()=>z(H,Z))},f=(H,V,Z)=>{let Y=new Event("progress");Object.defineProperties(Y,{loaded:{value:V},total:{value:Z},lengthComputable:{value:true}}),H.dispatchEvent(Y)},S=r.downloadBytesPerSecond;if(S&&typeof c.__didReceiveData=="function"&&typeof c.__didCompleteResponse=="function"){let H=c.__didReceiveData.bind(s),V=c.__didReceiveIncrementalData?.bind(s),Z=c.__didCompleteResponse.bind(s),Y=c.__didReceiveDataProgress?.bind(s),L=Promise.resolve(),M=0,N=hi(S),J=ne=>{L=L.then(async()=>{u||await ne()}).catch(K=>{u||P(false,K instanceof Error?K.message:String(K))})},le=async(ne,K,be=-1)=>{if((!s.responseType||s.responseType==="text"||s.responseType==="json")&&typeof K=="string"&&V){let pe=new TextEncoder().encode(K),ft=new TextDecoder;for(let Ae=0;Ae<pe.byteLength;){let Ye=Math.min(Br(S),pe.byteLength-Ae);if(await N(Ye,d.signal),u)return;let Eo=ft.decode(pe.subarray(Ae,Ae+Ye),{stream:Ae+Ye<pe.byteLength});Ae+=Ye,M+=Ye,V(ne,Eo,M,be),Y?.(ne,M,be)}}else{let pe=typeof K=="object"&&K?K.size:s.responseType==="arraybuffer"&&typeof K=="string"?Math.max(0,K.length*3/4-(K.endsWith("==")?2:K.endsWith("=")?1:0)):qr(K);if(typeof pe!="number")throw new Error("Cannot read this response size.");let ft=M;await Or(pe,S,d.signal,Ae=>{M=ft+Ae,Y?.(ne,M,be<0?pe:be)}),u||H(ne,K)}};p("__didReceiveData",(ne,K)=>J(()=>le(ne,K))),p("__didReceiveIncrementalData",(ne,K,be,pe)=>J(()=>le(ne,K,pe))),p("__didReceiveDataProgress",()=>{}),p("__didCompleteResponse",(ne,K,be)=>{if(K){Z(ne,K,be);return}J(async()=>{u||Z(ne,K,be)})})}else if(S)throw $(),new Error("This XHR lacks the RN byte hooks.");let D=typeof c.__didUploadProgress=="function"?c.__didUploadProgress.bind(s):void 0;r.uploadBytesPerSecond&&D&&p("__didUploadProgress",()=>{}),R=lr(()=>{(async()=>{if(!u){if(A()){P(true);return}if(r.profile==="offline"){P(false);return}if(r.uploadBytesPerSecond){let H=(r.uploadCap??jo(i)).knownBytes;await Or(H,r.uploadBytesPerSecond,d.signal,(V,Z)=>{D?D(s._requestId,V,Z):s.upload&&f(s.upload,V,Z)})}if(!u){if(o&&o.kind!=="delay"){S&&o.kind==="respond"&&await Or(qr(o.body)??0,S,d.signal),u||Ol(s,t,o);return}s._sent=false,x=true;try{n()}finally{x=false}}}})().catch(H=>{u||P(false,H instanceof Error?H.message:String(H))})},r.delayMs+(o?.delayMs??0))}O();import{getAccountAccess as xi,hasAccountAccess as Vo,subscribeAccountAccess as Dl}from"@buoy-gg/shared-ui/web";O();O();var Ci=[204,205,304];function Uo(){return typeof Response=="function"}function Al(e,t){let r=Ci.includes(t.status)?null:t.body,o=new Response(r,{status:t.status,statusText:t.statusText,headers:t.headers});try{Object.defineProperty(o,"url",{value:e,configurable:true})}catch{}return o}function Hl(e){return new TypeError(e.failKind==="timeout"?"Network request timed out":"Network request failed")}O();var Ml="[]{}()\\.^$+|-,?";function ki(e){let t="";for(let r=0;r<e.length;r++){let o=e.charAt(r);Ml.indexOf(o)!==-1&&(t+="\\"),t+=o}return t.split("*").join(".*")}var Hr=new Map;function Nl(e){let t=Hr.get(e);if(t)return t;let r=e.startsWith("/")?`[a-zA-Z][a-zA-Z0-9+.-]*://[^/]*${ki(e)}`:ki(e),o=new RegExp(`^${r}$`);return Hr.size>200&&Hr.clear(),Hr.set(e,o),o}function $l(e,t){if(!e)return false;let r=t.toLowerCase();for(let o of Object.keys(e))if(o.toLowerCase()===r&&e[o]!==void 0&&e[o]!=="")return true;return false}function Fl(e){let t=r=>Array.isArray(r)?r.map(t):r&&typeof r=="object"?Object.fromEntries(Object.keys(r).sort().map(o=>[o,t(r[o])])):r;return JSON.stringify(t(e))??"null"}function jl(e,t,r){if(typeof e!="string"||!e.includes(t))return false;try{let o=JSON.parse(e);return(Array.isArray(o)?o:[o]).some(n=>!n||typeof n!="object"||n.operationName!==t?false:r===void 0||Fl(n.variables??{})===r)}catch{return false}}function _o(e,t,r,o,n){if(e.methods&&e.methods.length>0&&!e.methods.includes(r.toUpperCase())||e.requireHeader&&!$l(o,e.requireHeader)||e.bodyIncludes&&(typeof n!="string"||!n.includes(e.bodyIncludes))||e.graphqlOperation&&!jl(n,e.graphqlOperation,e.graphqlVariables))return false;try{return Nl(e.urlPattern).test(t)}catch{return false}}O();import{TIER_LIMITS as Wl}from"@buoy-gg/shared-ui/web";var cr=200,hr=599,Ze=50,Ti=Wl["network.overrideRules"].free;function Ri(e){return{ruleId:e.rule.id,ruleName:e.rule.name,kind:e.kind,delayMs:e.delayMs||void 0}}var Vl=[/(^|\.)keygen\.sh/i,/^https?:\/\/(www\.)?buoy\.gg\/api\/license(\/|$)/i];function Ul(e){return Vl.some(t=>t.test(e))}function _l(e){let t=e.trim();if(t==="")return"text/plain; charset=utf-8";if(t.startsWith("{")||t.startsWith("["))try{return JSON.parse(t),"application/json"}catch{}return"text/plain; charset=utf-8"}function Xl(e,t){let r=t.toLowerCase();return Object.keys(e).some(o=>o.toLowerCase()===r)}function Jl(e){let t=Math.max(0,e.delayMs??0);if(e.kind==="delay")return{kind:"delay",rule:e,delayMs:t};if(e.kind==="fail")return{kind:"fail",rule:e,delayMs:t,failKind:e.failKind??"network"};let r=Math.min(hr,Math.max(cr,e.status??200)),o=Ci.includes(r)?"":e.body??"",n={...e.headers??{}};return Xl(n,"content-type")||(n["content-type"]=_l(o)),{kind:"respond",rule:e,delayMs:t,status:r,statusText:e.statusText??"",headers:n,body:o}}function Xo(e){return typeof e.times=="number"&&e.hits>=e.times}function Gl(e){return e.alternate?e.seen%2===1:true}function Jo(e,t,r,o,n){if(r.length===0||t.toUpperCase()==="OPTIONS"||Ul(e))return null;for(let i of r)if(i.enabled&&!Xo(i)&&_o(i,e,t,o,n))return i;return null}var Oe=null;function Kl(e){Oe=e}function Ei(){return Oe?.ready?.()??Promise.resolve()}function Yl(){return Oe?.isReady?.()??true}function Zl(){return!!Oe?.getRules().some(e=>e.enabled&&(e.bodyIncludes||e.graphqlOperation))}function Ql(){return Vo()&&!(typeof me<"u"&&!me)}var ed="Response overrides never apply in a release build \u2014 the rule is saved but will not affect any request.";function td(e,t){return{hooksInstalled:Oe!==null,devFlag:typeof me>"u"?"undefined":me,ruleCount:Oe?Oe.getRules().length:0,matches:Oe?Jo(e,t,Oe.getRules())!==null:false}}var rd=3e3;function od(e,t,r,o){return!Oe||Vo()||typeof me<"u"&&!me||xi().status!=="initializing"||!Jo(e,t,Oe.getRules(),r,o)?null:new Promise(n=>{let i=()=>{},s=()=>{Tt(l),i(),n()},l=lr(s,rd);i=Dl(()=>{xi().status!=="initializing"&&s()})})}function Ii(e,t,r,o){if(!Oe||typeof me<"u"&&!me)return null;let n=Oe.getRules();if(n.length===0||!Vo()&&(n=n.filter(l=>l.sandbox===true),n.length===0))return null;let i=Jo(e,t,n,r,o);if(!i)return null;let s=Gl(i);return Oe.recordMatch(i.id),s?(Oe.recordHit(i.id),Jl(i)):null}O();var nd={400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",408:"Request Timeout",429:"Too Many Requests",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout"};function id(e){return typeof e=="number"&&e>0?"response":"error"}function sd(e,t){let r=(t??"").trim();return r||(nd[e]??"")}var Et;function Pi(e){let t=globalThis.__buoyHeaderInjectors;if(!t||t.length===0)return;let r;for(let o of t)try{let n=o(e);n&&(r={...r,...n})}catch{}return r}function ad(){if(Et!==void 0)return Et;Et=null;try{if(typeof me<"u"&&!me)return Et;let e=(Se(),Ta(Do))?.NativeModules?.SourceCode,t=e?.getConstants?.().scriptURL??e?.scriptURL;if(typeof t=="string"&&/^https?:\/\//.test(t)){let r=new URL(t);Et=`${r.protocol}//${r.host}`}}catch{Et=null}return Et}var It=false,ld=Symbol.for("buoy.earlyNetwork");function dd(e){let t={};if(!e)return t;if(typeof Headers<"u"&&e instanceof Headers)e.forEach((r,o)=>{t[o]=r});else if(Array.isArray(e))for(let[r,o]of e)t[r]=o;else Object.assign(t,e);return t}var Li="__buoyNetworkFetchIntercepted",Bi="__buoyNetworkXhrIntercepted",ud=["text/event-stream","application/x-ndjson","application/stream+json"],Go="[streaming\u2026]",Ko=false;function cd(){return Ko?true:(Ko=!!globalThis.document?.querySelector?.("[ng-version]"),Ko)}function qi(e){if(!e)return false;let t=e.toLowerCase();return ud.some(r=>t.includes(r))}var hd="__BUOY_INTERNAL_HOSTS__";function pd(e){let t=globalThis[hd];if(!(t instanceof Set)||t.size===0)return false;let r;try{r=new URL(e).host.toLowerCase()}catch{return false}for(let o of t)if(typeof o=="string"&&o&&r===o.toLowerCase())return true;return false}var fd=class{constructor(){this.listeners=[];this.isListening=false;this.patchedFetch=null;this.patchedXHROpen=null;this.patchedXHRSend=null;this.patchedXHRSetRequestHeader=null;this.fetchGeneration=0;this.xhrGeneration=0;this.originalFetch=globalThis.fetch,this.originalXHROpen=XMLHttpRequest.prototype.open,this.originalXHRSend=XMLHttpRequest.prototype.send,this.originalXHRSetRequestHeader=XMLHttpRequest.prototype.setRequestHeader}shouldIgnoreUrl(e){if(Tl(e))return true;try{let t=new URL(e);if(t.hostname==="keygen.sh"||t.hostname.endsWith(".keygen.sh")||(t.hostname==="buoy.gg"||t.hostname==="www.buoy.gg")&&(t.pathname.startsWith("/api/license")||t.pathname.startsWith("/api/settings/"))||(t.hostname==="localhost"||t.hostname==="127.0.0.1"||t.hostname==="10.0.2.2")&&["8081","8802"].includes(t.port))return true;let r=ad();if(r&&`${t.protocol}//${t.host}`===r)return true}catch{return false}return pd(e)}emit(e){this.listeners.forEach(t=>{try{t(e)}catch{}})}parseUrl(e){let t=null,r=e.indexOf("?");return r>-1&&(t={},e.substring(r+1).split("&").forEach(o=>{let[n,i]=o.split("=");n&&i!==void 0&&(t[n]=decodeURIComponent(i.replace(/\+/g," ")))})),{url:r>-1?e.substring(0,r):e,params:t}}async readStreamedBody(e,t=256*1024){let r=e.body;if(!r||typeof r.getReader!="function"){let a=await e.text();return a.length>t?{body:`${a.slice(0,t)}
3
3
 
4
- ... [truncated]`,size:a.length}:{body:a,size:a.length}}let o=r.getReader(),n=new TextDecoder,i="",s=0,l=false;try{for(;;){let{done:a,value:d}=await o.read();if(a)break;if(s+=d?.byteLength??0,!l&&(i+=n.decode(d,{stream:true}),s>=t)){i=`${i.slice(0,t)}
4
+ ... [truncated]`,size:a.length}:{body:a,size:a.length}}let o=r.getReader(),n=new TextDecoder,i="",s=0,l=false;try{for(;;){let{done:a,value:u}=await o.read();if(a)break;if(s+=u?.byteLength??0,!l&&(i+=n.decode(u,{stream:true}),s>=t)){i=`${i.slice(0,t)}
5
5
 
6
6
  ... [truncated]`,l=true;break}}l||(i+=n.decode())}finally{try{Promise.resolve(o.cancel()).catch(()=>{})}catch{}try{o.releaseLock()}catch{}}return{body:i,size:s}}async processResponseBody(e,t=1024*1024){try{let r=e.headers.get("content-length");if(r){let i=parseInt(r,10);if(!isNaN(i)&&i>t)return{body:`[Response too large: ${this.formatBytes(i)}]`,size:i,truncated:true}}let o=await e.text(),n=o.length;if(n>t){let i=o.substring(0,t),s=n-t;return{body:`${i}
7
7
 
8
- ... [truncated, ${this.formatBytes(s)} omitted]`,size:n,truncated:true}}try{return{body:JSON.parse(o),size:n,truncated:false}}catch{return{body:o,size:n,truncated:false}}}catch{return{body:"~~~ unable to read body ~~~",size:0,truncated:false}}}formatBytes(e){if(e===0)return"0 B";let t=1024,r=["B","KB","MB","GB"],o=Math.floor(Math.log(e)/Math.log(t));return`${Math.round(e/Math.pow(t,o)*100)/100} ${r[o]}`}handleXHRResponse(e,t,r,o,n,i,s,l,a=false,d="xhr",u,v){let T=l?ue()-l:0,x=e._buoyTtfb,L=x===void 0?void 0:{ttfb:x,download:Math.max(0,T-x)};if(a||e.status===0){this.emit({type:"error",timestamp:new Date,duration:T,request:{id:t||"unknown",url:r,method:o,headers:n,data:i,params:s||void 0,client:d},error:{message:a?"Request failed":"Network error or request aborted"},override:u,condition:v});return}let m,k=0;try{let g=e.response;if(e.responseType==="json"&&g)m=g,k=JSON.stringify(g).length;else if(e.responseType===""||e.responseType==="text"){if(e.responseText){k=e.responseText.length;try{m=JSON.parse(e.responseText)}catch{m=e.responseText}}}else if(e.responseType==="arraybuffer")if(g)try{let I=new TextDecoder("utf-8").decode(g);k=I.length;try{m=JSON.parse(I)}catch{m=I}}catch{m=`[arraybuffer response - ${g.byteLength||0} bytes]`,k=g.byteLength||0}else m="[arraybuffer response - no data]",k=0;else if(e.responseType==="blob")if(g instanceof Blob)m=`[blob response - ${g.size} bytes, type: ${g.type||"unknown"}]`,k=g.size;else if(g)try{m=typeof g=="string"?JSON.parse(g):g,k=JSON.stringify(m).length}catch{m="[blob response - unable to parse]",k=0}else m="[blob response - no data]",k=0;else if(g)if(typeof g=="string"){m=g,k=g.length;try{m=JSON.parse(g)}catch{}}else typeof g=="object"?(m=g,k=JSON.stringify(g).length):(m=String(g),k=String(g).length)}catch{m="~~~ unable to read body ~~~"}let E={};try{let g=e.getAllResponseHeaders();g&&g.split(`\r
9
- `).forEach(I=>{if(I){let D=I.indexOf(": ");if(D>0){let H=I.substring(0,D).toLowerCase(),S=I.substring(D+2);E[H]=S}}})}catch{}Cl(e.status)==="response"?this.emit({type:"response",timestamp:new Date,duration:T,timings:L,request:{id:t||"unknown",url:r,method:o,headers:n,data:i,params:s||void 0,client:d},response:{status:e.status,statusText:kl(e.status,e.statusText),headers:E,body:m,size:k},override:u,condition:v}):this.emit({type:"error",timestamp:new Date,duration:T,request:{id:t||"unknown",url:r,method:o,headers:n,data:i,params:s||void 0,client:d},response:{status:e.status,statusText:e.statusText,headers:E,body:m,size:k},error:{message:"Network Error"},override:u,condition:v})}isFetchInterceptionLive(){return globalThis.fetch[Kn]===true}isXhrInterceptionLive(){return XMLHttpRequest.prototype.send[Qn]===true}isInterceptionLive(){return this.isFetchInterceptionLive()&&this.isXhrInterceptionLive()}startListening(){let e=this.isListening&&this.isFetchInterceptionLive(),t=this.isListening&&this.isXhrInterceptionLive();e&&t||(e||this.installFetchInterceptor(),t||this.installXhrInterceptor(),this.isListening=true)}installFetchInterceptor(){let e=this,t=globalThis.fetch.bind(globalThis);this.originalFetch=globalThis.fetch;let r=++this.fetchGeneration,o=async(n,i)=>{let s=mr(typeof n=="string"?n:n instanceof URL?n.href:n.url);if(r!==e.fetchGeneration)return t(n,i);if(i?.__buoyInternal||e.shouldIgnoreUrl(s)){let S=gt;gt=true;try{return t(n,i)}finally{gt=S}}let l=ue(),a=yr("fetch"),d=typeof n=="object"&&"method"in n?n:void 0,u=i?.method??d?.method??"GET",v=i?.signal!==void 0?i.signal:d?.signal;vr(v);let T=ri(s),{url:x,params:L}=e.parseUrl(s),m={},k=i?.headers??d?.headers;k&&(k instanceof Headers?k.forEach((S,z)=>{m[z]=S}):Array.isArray(k)?k.forEach(([S,z])=>{m[S]=z}):m={...k}),Object.assign(m,Gn(s));let E;if(i?.body)if(typeof i.body=="string")try{E=JSON.parse(i.body)}catch{E=i.body}else E=i.body;let g=m["X-Request-Client"]||m["x-request-client"]||"fetch",I=T?.profile!=="offline"&&Wn()?wl(s,u,m,typeof i?.body=="string"?i.body:void 0):null;I&&await I;let D=T?.profile!=="offline"&&Wn()?Jn(s,u,m,typeof i?.body=="string"?i.body:void 0):null,H=D?_n(D):void 0;if(e.emit({type:"request",timestamp:new Date,request:{id:a||"unknown",url:x,method:u,headers:m,data:E,params:L||void 0,client:g},override:H,condition:T}),i?.body===void 0&&d?.body&&!d.bodyUsed)try{let S=d.clone();e.readStreamedBody(S).then(({body:z})=>{try{E=JSON.parse(z)}catch{E=z}e.emit({type:"request-body",timestamp:new Date,request:{id:a||"unknown",url:x,method:u,data:E,client:g}})}).catch(()=>{})}catch{}try{if((T||D)&&await nl((T?.delayMs??0)+(D?.delayMs??0),v),vr(v),T?.profile==="offline")throw new TypeError("Network request failed (Buoy Offline)");if(D?.kind==="fail")throw al(D);let S;if(D?.kind==="respond")S=sl(s,D);else{let ee=gt;gt=true;let X;try{X=t(n,i)}finally{gt=ee}S=await X}let z=ue()-l,w=typeof S.body?.getReader=="function"||Yn(S.headers?.get?.("content-type")),p=S.clone(),{body:h,size:c}=w?{body:Zn,size:0}:await e.processResponseBody(p),y=ue()-l,O=Math.max(0,y-z),re=O>0?{ttfb:z,download:O}:void 0,ne={};if(S.headers.forEach((ee,X)=>{ne[X.toLowerCase()]=ee}),e.emit({type:"response",timestamp:new Date,duration:y,timings:re,request:{id:a||"unknown",url:x,method:u,headers:m,data:E,params:L||void 0,client:g},response:{status:S.status,statusText:S.statusText,headers:ne,body:h,size:c},override:H,condition:T}),w){let ee=S.headers?.get?.("content-type");e.readStreamedBody(p,Yn(ee)?void 0:1024*1024).then(X=>{let A=X.body;if(ee?.includes("json"))try{A=JSON.parse(X.body)}catch{}e.emit({type:"response",timestamp:new Date,duration:ue()-l,timings:re,request:{id:a||"unknown",url:x,method:u,headers:m,data:E,params:L||void 0,client:g},response:{status:S.status,statusText:S.statusText,headers:ne,body:A,size:X.size},override:H,condition:T})}).catch(()=>{})}return S}catch(S){let z=ue()-l;throw e.emit({type:"error",timestamp:new Date,duration:z,request:{id:a||"unknown",url:x,method:u,headers:m,data:E,params:L||void 0,client:g},error:{message:S instanceof Error?S.message:"Network error",stack:S instanceof Error?S.stack:void 0},override:H,condition:T}),S}};o[Kn]=true,this.patchedFetch=o,globalThis.fetch=this.patchedFetch}installXhrInterceptor(){let e=this,t=XMLHttpRequest.prototype.open,r=XMLHttpRequest.prototype.send,o=XMLHttpRequest.prototype.setRequestHeader;this.originalXHROpen=t,this.originalXHRSend=r,this.originalXHRSetRequestHeader=o;let n=++this.xhrGeneration,i=new WeakMap,s=function(d,u,v,T,x){let L=t.call(this,d,u,v??true,T,x);if(n===e.xhrGeneration){i.get(this)?.();let m=this;m._buoyRequestId=yr("xhr"),m._method=d,m._url=mr(u),m._buoyStartTime=ue(),m._requestHeaders={}}return L},l=function(d,u){let v=this;return n===e.xhrGeneration&&v._requestHeaders&&(v._requestHeaders[d]=u),o.call(this,d,u)},a=function(d){if(n!==e.xhrGeneration||gt)return r.call(this,d);if(el(this))throw new DOMException("The request has already been sent.","InvalidStateError");if(this.readyState!==1||this._sent)return r.call(this,d);let u=this,v=u._buoyRequestId,T=u._method||"GET",x=u._url||"",L=ue();u._buoyStartTime=L,u._buoyTtfb=void 0;let m=u._requestHeaders||{};if(Object.assign(m,Gn(x)),e.shouldIgnoreUrl(x))return r.call(this,d);let{url:k,params:E}=e.parseUrl(x),g;if(d)if(typeof d=="string")try{g=JSON.parse(d)}catch{g=d}else g=d;let I=m["X-Request-Client"]||m["x-request-client"],D=m.Accept||m.accept||"",H=D.includes("application/json")&&D.includes("text/plain")&&D.includes("*/*")&&!Pl(),S=I||(H?"axios":"xhr"),z=ri(x),w=z?.profile==="offline"?null:Jn(x,T,m,typeof d=="string"?d:void 0),p=w?_n(w):void 0;e.emit({type:"request",timestamp:new Date,request:{id:v||"unknown",url:k,method:T,headers:m,data:g,params:E||void 0,client:S},override:p,condition:z});let h=false,c=(X=false)=>{h||(h=true,e.handleXHRResponse(this,v||"unknown",k,T,m,g,E,L||0,X,S,p,z),y())},y=()=>{i.delete(this),this.removeEventListener("load",O),this.removeEventListener("error",re),this.removeEventListener("abort",ne),this.removeEventListener("readystatechange",ee)};i.set(this,y);let O=()=>{c(false)},re=()=>{c(true)},ne=()=>{c(true)},ee=()=>{if(this.readyState===2){let X=this;X._buoyTtfb===void 0&&X._buoyStartTime&&(X._buoyTtfb=ue()-X._buoyStartTime)}this.readyState===4&&!h&&c(false)};if(this.addEventListener("load",O),this.addEventListener("error",re),this.addEventListener("abort",ne),this.addEventListener("readystatechange",ee),z){ol(this,x,z,w,()=>r.call(this,d));return}if(!(w&&Nn(this,x,w,()=>r.call(this,d))))return r.call(this,d)};a[Qn]=true,this.patchedXHROpen=s,this.patchedXHRSend=a,this.patchedXHRSetRequestHeader=l,XMLHttpRequest.prototype.open=this.patchedXHROpen,XMLHttpRequest.prototype.send=this.patchedXHRSend,XMLHttpRequest.prototype.setRequestHeader=this.patchedXHRSetRequestHeader}stopListening(){this.isListening&&(this.fetchGeneration++,this.xhrGeneration++,this.patchedFetch&&globalThis.fetch===this.patchedFetch&&(globalThis.fetch=this.originalFetch),this.patchedXHROpen&&XMLHttpRequest.prototype.open===this.patchedXHROpen&&(XMLHttpRequest.prototype.open=this.originalXHROpen),this.patchedXHRSend&&XMLHttpRequest.prototype.send===this.patchedXHRSend&&(XMLHttpRequest.prototype.send=this.originalXHRSend),this.patchedXHRSetRequestHeader&&XMLHttpRequest.prototype.setRequestHeader===this.patchedXHRSetRequestHeader&&(XMLHttpRequest.prototype.setRequestHeader=this.originalXHRSetRequestHeader),this.patchedFetch=null,this.patchedXHROpen=null,this.patchedXHRSend=null,this.patchedXHRSetRequestHeader=null,this.isListening=false)}adoptEarlyRequests(){let e=globalThis.__BUOY_EARLY_NETWORK__;if(e?.version===1)for(let t of e.adopt())try{t.kind==="fetch"?this.adoptEarlyFetch(t):this.adoptEarlyXhr(t)}catch{}}adoptEarlyFetch(e){let{input:t,init:r}=e,o=typeof t=="object"&&"method"in t?t:void 0,n=mr(typeof t=="string"?t:t instanceof URL?t.href:t.url);if(this.shouldIgnoreUrl(n))return;let i=yr("fetch"),s=r?.method??o?.method??"GET",{url:l,params:a}=this.parseUrl(n),d=El(r?.headers??o?.headers),u=r?.body;if(typeof u=="string")try{u=JSON.parse(u)}catch{}let v=d["X-Request-Client"]||d["x-request-client"]||"fetch",T=()=>({id:i,url:l,method:s,headers:d,data:u,params:a||void 0,client:v});this.emit({type:"request",timestamp:new Date(e.start),request:T()}),e.requestCopy&&this.readStreamedBody(e.requestCopy).then(({body:x})=>{try{u=JSON.parse(x)}catch{u=x}this.emit({type:"request-body",timestamp:new Date,request:{id:i,url:l,method:s,data:u,client:v}})}).catch(()=>{}),e.settled.then(async({response:x,clone:L,error:m,headersAt:k})=>{if(!x){this.emit({type:"error",timestamp:new Date,duration:k-e.start,request:T(),error:{message:m instanceof Error?m.message:"Network error",stack:m instanceof Error?m.stack:void 0}});return}let{body:E,size:g}=L?await this.processResponseBody(L):{body:Zn,size:0},I=Math.max(0,ue()-e.start),D=k-e.start,H={};x.headers.forEach((S,z)=>{H[z.toLowerCase()]=S}),this.emit({type:"response",timestamp:new Date,duration:I,timings:I>D?{ttfb:D,download:I-D}:void 0,request:T(),response:{status:x.status,statusText:x.statusText,headers:H,body:E,size:g}})})}adoptEarlyXhr(e){let t=mr(e.url);if(this.shouldIgnoreUrl(t))return;let r=yr("xhr"),o=e.method.toUpperCase(),{url:n,params:i}=this.parseUrl(t),s=e.body;if(typeof s=="string")try{s=JSON.parse(s)}catch{}let l=e.headers["X-Request-Client"]||e.headers["x-request-client"]||"xhr";this.emit({type:"request",timestamp:new Date(e.start),request:{id:r,url:n,method:o,headers:e.headers,data:s,params:i||void 0,client:l}});let a=e.xhr,d=()=>{let u=(a._buoyEarlyEnd??ue())-e.start;this.handleXHRResponse(a,r,n,o,e.headers,s,i,ue()-u,false,l)};a.readyState===4?d():a.addEventListener("loadend",d,{once:true})}addListener(e){return this.listeners.push(e),()=>{let t=this.listeners.indexOf(e);t>-1&&this.listeners.splice(t,1)}}removeAllListeners(){this.listeners=[]}get isActive(){return this.isListening}get listenerCount(){return this.listeners.length}},ot=null,Co=()=>(ot||(ot=new ql),ot),xr=Co,ei=()=>Co().startListening(),Yt=()=>ot?.stopListening(),er=e=>Co().addListener(e),Ol=()=>ot?.removeAllListeners(),ti=()=>ot?.isActive??false,mt=()=>ot?.listenerCount??0,Dl=()=>ot?.isInterceptionLive()??false;var tr={normal:{label:"Normal",delayMs:0},offline:{label:"Offline (requests)",delayMs:0},slow:{label:"Slow (+500 ms)",delayMs:500},verySlow:{label:"Very slow (+2000 ms)",delayMs:2e3}},ko=`${Date.now()}-${Math.random().toString(36).slice(2)}`,yt="normal",wr,Tr=new Set,bt=()=>typeof ce<"u"&&ce&&Bn(),vt=()=>yt,rr=e=>(Tr.add(e),()=>{Tr.delete(e)});function Cr(e){if(typeof e!="string"||!Object.prototype.hasOwnProperty.call(tr,e))throw new Error("Choose normal, offline, slow, or verySlow.");if(e!=="normal"&&!bt())throw new Error("Network conditions require an admitted account and a development build.");return e===yt||(e!=="normal"&&!wr?(ei(),wr=er(()=>{})):e==="normal"&&(wr?.(),wr=void 0,mt()===0&&Yt()),yt=e,Tr.forEach(t=>t())),yt}function ri(e){if(!(yt==="normal"||!bt()||!/^https?:\/\//i.test(e)))return Object.freeze({profile:yt,delayMs:tr[yt].delayMs})}Xa(()=>{Bn()||Cr("normal"),Tr.forEach(e=>e())});import{jsx as Ro,jsxs as zl}from"react/jsx-runtime";function Al({size:e}){let t=Ua(rr,vt,vt);return zl(f,{accessibilityLabel:t==="normal"?"Network":`Network: ${tr[t].label}`,children:[Ro(_a,{size:e}),t!=="normal"&&Ro(f,{pointerEvents:"none",style:{position:"absolute",top:-6,right:-8,width:48,alignItems:"flex-end"},children:Ro(b,{testID:"buoy-network-condition-indicator",numberOfLines:1,style:{color:"#FFCC66",fontSize:10,fontWeight:"700"},children:t==="offline"?"OFF":`+${tr[t].delayMs}`})})]})}import{createToolFactory as Hl,defineToolPreset as Ml}from"@buoy-gg/shared-ui/web";q();q();pe();import{useEffect as oi,useRef as Eo,useState as ni,useSyncExternalStore as Io}from"react";import{FloatingTool as Nl,night as ke,openFloatingTool as $l,persistentStorage as jl,registerPersistentFloatingTool as Fl}from"@buoy-gg/shared-ui/web";import{jsx as Re,jsxs as ii}from"react/jsx-runtime";function Wl(){let e,t=new Set;return{getSnapshot:()=>e,subscribe:r=>(t.add(r),()=>{t.delete(r)}),update(r){e=r,t.forEach(o=>o())}}}var Vl=()=>()=>{},si=()=>{},kr=[{id:"normal",label:"No throttling",detail:"No added delay"},{id:"slow",label:"Slow",detail:"+500 ms before sending"},{id:"verySlow",label:"Very slow",detail:"+2 seconds before sending"},{id:"offline",label:"Offline",detail:"New requests fail"}],Ul={id:"network-throttling",render:e=>Re(li,{...e})};function ai(){return typeof ce>"u"||!ce?()=>{}:Fl(Ul,jl)}typeof ce<"u"&&ce&&typeof navigator<"u"&&navigator.product==="ReactNative"&&ai();function _l(e){$l({id:"network-throttling",render:t=>Re(li,{...t,source:e})})}function li({id:e,revealToken:t,dismiss:r,source:o}){let n=Io(rr,vt,vt),i=Io(rr,bt,bt),s=Io(o?.subscribe??Vl,o?.getSnapshot??si,si),l=o?s?.profile??null:n,a=o?s?.available===true:i,[d,u]=ni(false),[v,T]=ni(),x=Eo(false),L=Eo(0),m=Eo(true),{width:k}=mn();oi(()=>(m.current=true,()=>{m.current=false}),[]),oi(()=>{L.current+=1,x.current=false,u(false),T(void 0)},[o,s?.targetId]);let E=l!==null&&l!=="normal",g=l??"normal",I=kr.find(p=>p.id===g),D=kr[(kr.findIndex(p=>p.id===g)+1)%kr.length],H=!a||g==="offline"?0:g==="verySlow"?1:g==="slow"?2:4,S=d?"Applying\u2026":a?g==="normal"?"0 ms":g==="slow"?"+500 ms":g==="verySlow"?"+2000 ms":"Blocked":"Unavailable";async function z(p,h=false){if(x.current)return;let c=++L.current;x.current=true,u(true),T(void 0);let y=o?.getSnapshot();try{if(o){if(!y?.available)throw new Error("Device unavailable. Open Network again to reconnect these controls.");await y.onChange(p)}else Cr(p);m.current&&L.current===c&&h&&r()}catch(O){m.current&&L.current===c&&T(O instanceof Error?O.message:String(O))}finally{L.current===c&&(x.current=false,m.current&&u(false))}}let w=v?Re(f,{style:Le.menu,children:Re(b,{accessibilityRole:"alert",style:Le.error,children:v})}):void 0;return Re(Nl,{id:e,revealToken:t,variant:"strip",dragFromSurface:true,accessibilityLabel:`Move or hide network throttling. ${E?"Active":"Off"}`,accessory:w,children:ii(f,{style:[Le.row,{width:Math.max(220,Math.min(292,k-64))}],children:[Re(N,{testID:"throttling-cycle",accessibilityRole:"button",accessibilityLabel:`Network: ${I.label}. Switch to ${D.label}`,accessibilityState:{disabled:d||!a},disabled:d||!a,onPress:()=>void z(D.id),style:Le.signalButton,children:d?Re(yo,{size:"small",color:ke.color.accent}):ii(f,{testID:`throttling-signal-${g}`,style:Le.signal,children:[[7,12,18,24].map((p,h)=>Re(f,{style:{width:4,height:p,borderRadius:2,backgroundColor:h<H?g==="offline"?ke.color.danger:ke.color.accent:ke.color.fillTertiary}},p)),g==="offline"&&Re(f,{style:Le.slash})]})}),Re(f,{style:Le.profile,children:Re(b,{testID:"throttling-profile",accessibilityLabel:`Connection profile: ${I.label}`,accessibilityLiveRegion:"polite",numberOfLines:1,style:Le.profileLabel,children:I.label})}),Re(b,{testID:"throttling-status",numberOfLines:1,accessibilityLiveRegion:"polite",style:Le.status,children:S}),Re(f,{style:Le.separator}),Re(N,{testID:"throttling-close",accessibilityRole:"button",accessibilityLabel:"Close and turn off throttling",disabled:d,accessibilityState:{disabled:d},onPress:()=>{l==="normal"?r():z("normal",true)},style:[Le.action,d&&Le.disabled],children:Re(b,{style:Le.actionText,children:"Close"})})]})})}var Le=he.create({row:{flexDirection:"row",alignItems:"center",gap:6,paddingVertical:4,minHeight:48},signalButton:{width:36,minHeight:44,alignItems:"center",justifyContent:"center"},signal:{flexDirection:"row",alignItems:"flex-end",gap:3,height:24},slash:{position:"absolute",width:30,height:2,backgroundColor:ke.color.danger,top:11,left:-2,transform:[{rotate:"-45deg"}]},separator:{height:20,width:1,backgroundColor:ke.color.separator,marginHorizontal:2},status:{color:ke.color.textSecondary,fontSize:10,lineHeight:15,flexShrink:1},profile:{flex:1,flexDirection:"row",alignItems:"center",gap:6,minHeight:44},profileLabel:{color:ke.color.text,fontSize:13,fontWeight:"500",flexShrink:1},action:{minHeight:36,minWidth:52,borderRadius:ke.radius.input,borderWidth:1,borderColor:ke.color.accentBorderStrong,alignItems:"center",justifyContent:"center",paddingHorizontal:10},actionText:{color:ke.color.accent,fontSize:12,fontWeight:"600"},disabled:{opacity:.4},menu:{marginVertical:8,padding:6,borderRadius:ke.radius.card,borderWidth:1,borderColor:ke.color.separator,backgroundColor:ke.color.surface,shadowColor:"#000",shadowOffset:{width:0,height:6},shadowOpacity:.25,shadowRadius:16,elevation:8},error:{color:ke.color.danger,fontSize:12,lineHeight:18,padding:10}});pe();import{useState as ye,useRef as Rr,useEffect as St,useCallback as Po}from"react";import{Search as Xl,Wifi as Jl,Filter as Gl,Bookmark as Kl,JsModal as Ql,ModalHeader as me,devToolsStorageKeys as Er,macOSColors as Zl,night as Qe,persistentStorage as di,NightSegmented as Yl,useFeatureGate as ed,UpgradeModal as td,PowerToggleButton as rd,useIgnoredPatterns as od,windowDragProps as nd}from"@buoy-gg/shared-ui/web";q();pe();import{CheckCircle as id,Clock as sd,DynamicFilterView as ad,Film as ld,FileJson as dd,FileText as ud,Filter as ui,Globe as ci,Image as cd,macOSColors as be,night as Ie,Music as hd,XCircle as pd,monoFont as Bo}from"@buoy-gg/shared-ui/web";import{useCallback as Ir,useMemo as We,useState as fd}from"react";import{jsx as Ze,jsxs as hi}from"react/jsx-runtime";var gd=()=>false;function Lo(e){let t=e.responseHeaders||e.requestHeaders,r=t?.["content-type"]||t?.["Content-Type"]||"";return r.includes("json")?{type:"JSON",color:be.semantic.info}:r.includes("xml")?{type:"XML",color:be.semantic.success}:r.includes("html")?{type:"HTML",color:be.semantic.warning}:r.includes("text")?{type:"TEXT",color:be.semantic.success}:r.includes("image")?{type:"IMAGE",color:be.semantic.error}:r.includes("video")?{type:"VIDEO",color:be.semantic.error}:r.includes("audio")?{type:"AUDIO",color:be.semantic.debug}:r.includes("form")?{type:"FORM",color:be.semantic.info}:{type:"OTHER",color:Ie.color.textTertiary}}function md(e){switch(e){case"JSON":return dd;case"HTML":case"XML":case"TEXT":return ud;case"IMAGE":return cd;case"VIDEO":return ld;case"AUDIO":return hd;default:return ci}}function yd(e){switch(e){case"GET":return be.semantic.success;case"POST":return be.semantic.info;case"PUT":return be.semantic.warning;case"DELETE":return be.semantic.error;case"PATCH":return be.semantic.success;default:return Ie.color.textTertiary}}function bd({events:e,filter:t,onFilterChange:r,ignoredPatterns:o=[],onRemovePattern:n=()=>{},isTeamPattern:i=gd,onAddPattern:s=()=>{},onTogglePatternMode:l=()=>{}}){let[a,d]=fd("contains"),u=We(()=>{let w=new Map;for(let p of o)w.set(p.value,p.mode);return w},[o]),v=We(()=>new Set(o.map(w=>w.value)),[o]),T=Ir(w=>{s({value:w,mode:a})},[s,a]),x=Ir(w=>{if(i(w)){let y=Ie.color.accent;return Ze(f,{accessibilityLabel:"Set by your team on buoy.gg",style:[He.modeBadge,{borderColor:`${y}60`,backgroundColor:`${y}15`}],children:Ze(b,{style:[He.modeBadgeText,{color:y}],children:"TEAM"})})}let p=u.get(w)??"contains",h=p==="exact",c=h?Ie.color.warning:Ie.color.info;return Ze(N,{accessibilityRole:"button",accessibilityLabel:`Match mode: ${p}. Tap to toggle.`,onPress:()=>l(w),style:[He.modeBadge,{borderColor:`${c}60`,backgroundColor:`${c}15`}],hitSlop:{top:6,bottom:6,left:6,right:6},children:Ze(b,{style:[He.modeBadgeText,{color:c}],children:h?"EXACT":"CONTAINS"})})},[u,l,i]),L=Ir(()=>{let w=[{label:"Contains",value:"contains",hint:"substring"},{label:"Exact",value:"exact",hint:"whole path/host/url"}];return hi(f,{style:He.modeToggleRow,children:[Ze(b,{style:He.modeToggleLabel,children:"Match:"}),Ze(f,{style:He.modeToggleGroup,children:w.map(p=>{let h=a===p.value;return hi(N,{onPress:()=>d(p.value),style:[He.modeToggleButton,h&&He.modeToggleButtonActive],accessibilityRole:"button",accessibilityState:{selected:h},children:[Ze(b,{style:[He.modeToggleButtonText,h&&He.modeToggleButtonTextActive],children:p.label}),Ze(b,{style:He.modeToggleButtonHint,children:p.hint})]},p.value)})})]})},[a]),m=We(()=>{let w={all:e.length,success:0,error:0,pending:0};return e.forEach(p=>{if(p.error||p.status&&p.status>=400){w.error+=1;return}if(p.status&&p.status>=200&&p.status<300){w.success+=1;return}!p.status&&!p.error&&(w.pending+=1)}),w},[e]),k=We(()=>e.reduce((w,p)=>(p.method&&(w[p.method]=(w[p.method]||0)+1),w),{}),[e]),E=We(()=>e.reduce((w,p)=>{let{type:h}=Lo(p);return w[h]=(w[h]||0)+1,w},{}),[e]),g=We(()=>{let w=new Set;return e.forEach(p=>{if(p.host){w.add(p.host);return}try{if(p.url){let h=new URL(p.url),c=String(h.host||"");c&&w.add(c)}}catch{}}),Array.from(w).filter(p=>p&&p!=="").sort((p,h)=>p.localeCompare(h))},[e]),I=We(()=>{let w=new Set;return e.forEach(p=>{if(p.url)try{let h=new URL(p.url),c=String(h.origin||""),y=String(h.pathname||""),O=`${c}${y}`;w.add(O)}catch{w.add(p.url)}}),Array.from(w).filter(p=>p&&p!=="").sort((p,h)=>p.localeCompare(h))},[e]),D=We(()=>{let w=g.slice(0,30),p=I.slice(0,30);return[...w,...p]},[g,I]),H=Ir((w,p)=>{let[h]=w.split("::");if(h==="status"){r({...t,status:p==="all"?void 0:p});return}if(h==="method"){let c=String(p),y=t.method||[],O=y.includes(c)?y.filter(re=>re!==c):[c];r({...t,method:O.length>0?O:void 0});return}if(h==="contentType"){let c=String(p),y=t.contentType||[],O=y.includes(c)?y.filter(re=>re!==c):[c];r({...t,contentType:O.length>0?O:void 0})}},[t,r]),S=We(()=>{let w=[];w.push({id:"status",title:"Status",type:"status",data:["all","success","error","pending"].map(c=>({id:`status::${c}`,label:c.charAt(0).toUpperCase()+c.slice(1),count:m[c],icon:c==="success"?id:c==="error"?pd:c==="pending"?sd:ci,color:c==="success"?be.semantic.success:c==="error"?be.semantic.error:c==="pending"?be.semantic.warning:be.semantic.info,isActive:t.status===c||!t.status&&c==="all",value:c}))});let p=Object.entries(k);p.length>0&&w.push({id:"method",title:"Method",type:"method",data:p.map(([c,y])=>({id:`method::${c}`,label:c,count:y,color:yd(c),isActive:t.method?.includes(c)??false,value:c}))});let h=Object.entries(E);return h.length>0&&w.push({id:"contentType",title:"Content Type",type:"contentType",data:h.map(([c,y])=>{let O=e.find(ne=>Lo(ne).type===c),{color:re}=O?Lo(O):{color:Ie.color.textTertiary};return{id:`contentType::${c}`,label:c,count:y,icon:md(c),color:re,isActive:t.contentType?.includes(c)??false,value:c}})}),w},[E,e,t.contentType,t.method,t.status,k,m]),z=We(()=>({sections:S,addFilterSection:{enabled:true,placeholder:"Enter domain or URL pattern...",title:"ACTIVE FILTERS",icon:ui,renderExtra:L},availableItemsSection:{enabled:true,title:"AVAILABLE DOMAINS & URLS",emptyMessage:"No network events captured yet. Domains and URLs will appear here.",items:D},howItWorksSection:{enabled:true,title:"HOW NETWORK FILTERS WORK",description:"Patterns hide matching requests from the network event list. Each pattern has a match mode you can toggle on its badge: CONTAINS hides any URL containing the text; EXACT hides only an exact path/host/url match.",examples:["\u2022 example.com (CONTAINS) \u2192 any request whose URL contains example.com","\u2022 example.com (EXACT) \u2192 only requests served by that exact host","\u2022 /v1 (CONTAINS) \u2192 any URL containing /v1 (e.g. /v1, /v1/users)","\u2022 /v1 (EXACT) \u2192 only requests whose pathname is exactly /v1"],icon:ui},onFilterChange:H,onPatternAdd:T,onPatternToggle:n,activePatterns:v,renderPatternMeta:x}),[v,S,H,T,n,L,x,D]);return Ze(ad,{...z})}var He=he.create({modeBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:6,borderWidth:1},modeBadgeText:{fontSize:9,fontFamily:Bo,fontWeight:"700",letterSpacing:.5},modeToggleRow:{flexDirection:"row",alignItems:"center",gap:8,marginBottom:8},modeToggleLabel:{fontSize:11,fontWeight:"600",color:Ie.color.textSecondary,fontFamily:Bo,letterSpacing:.3},modeToggleGroup:{flexDirection:"row",gap:6,flex:1},modeToggleButton:{flex:1,paddingVertical:6,paddingHorizontal:10,borderRadius:8,borderWidth:1,borderColor:Ie.color.border,backgroundColor:Ie.color.buttonSurface,alignItems:"center"},modeToggleButtonActive:{borderColor:Ie.color.accentBorderStrong,backgroundColor:Ie.color.accentSoft},modeToggleButtonText:{fontSize:11,fontWeight:"700",color:Ie.color.textSecondary,fontFamily:Bo,letterSpacing:.3},modeToggleButtonTextActive:{color:Ie.color.accent},modeToggleButtonHint:{fontSize:9,color:Ie.color.textTertiary,marginTop:1}});q();import{TickProvider as qo}from"@buoy-gg/shared-ui/web";import{useTick as vd}from"@buoy-gg/shared-ui/web";function Oo(){return vd()??Date.now()}q();pe();import{useState as or,useEffect as pi,useMemo as Sd,memo as xd}from"react";import{Clock as Do,Upload as fi,Download as gi,AlertCircle as wd,ChevronDown as mi,ChevronUp as yi,Lock as Td,Unlock as Cd,FileJson as Pr,Filter as kd,Globe as Rd,Link as Ed,Copy as bi,FlaskConical as Id,InlineCopyButton as vi,macOSColors as Br,night as B,useFeatureGate as Pd,UpgradeModal as Bd,monoFont as Ht}from"@buoy-gg/shared-ui/web";q();import{formatBytes as Ye,formatDuration as Lr,formatHttpStatus as Si,getMethodColor as cf}from"@buoy-gg/shared-ui/web";import{formatRelativeTime as Ld}from"@buoy-gg/shared-ui/web";import{DataViewer as nr}from"@buoy-gg/shared-ui/web/dataViewer";q();function zo(e,t=30){if(e==null)return null;if(typeof e=="boolean"||typeof e=="number")return String(e);if(typeof e=="string")return e.length>t?e.substring(0,t-1)+"\u2026":e;if(Array.isArray(e))return e.length===0?null:e.length===1?zo(e[0],t):`${e.length} items`;if(typeof e=="object"){let r=Object.entries(e);if(r.length===0)return null;for(let[o,n]of r){let i=zo(n,t);if(i)return i}return null}return null}function qd(e,t=3){if(!e||typeof e!="object")return null;let r=[];for(let[o,n]of Object.entries(e)){let i=zo(n);if(i&&r.push(i),r.length>=t)break}return r.length>0?r:null}function xi(e,t){let r=qd(t);return!r||r.length===0?e:[e,...r].join(" \u203A ")}function wi(e,t){if(!e||typeof e!="object")return false;for(let r of Object.values(e))if(Ao(r,t))return true;return false}function Ao(e,t){return typeof e=="string"?e.toLowerCase().includes(t):typeof e=="number"||typeof e=="boolean"?String(e).includes(t):Array.isArray(e)?e.some(r=>Ao(r,t)):typeof e=="object"&&e!==null?Object.values(e).some(r=>Ao(r,t)):false}q();import{createContext as Od,useContext as Dd}from"react";import{jsx as zd}from"react/jsx-runtime";var Ti=Od(null);function Ad({resolver:e,children:t}){return zd(Ti.Provider,{value:e,children:t})}function Hd(){return Dd(Ti)}import{Fragment as Ho,jsx as C,jsxs as J}from"react/jsx-runtime";var qr=B.color.accent,Md=new Set,Nd=()=>{},$d=({timings:e,total:t})=>{let r=Math.max(1,t),o=[{label:"Waiting (TTFB)",hint:"incl. queue, DNS, TLS",value:e.ttfb,color:Br.semantic.warning},{label:"Content download",hint:void 0,value:e.download,color:Br.semantic.success}];return C(f,{style:R.phaseList,children:o.map(n=>J(f,{style:R.phaseRow,children:[J(f,{style:R.phaseLabelGroup,children:[C(b,{style:R.phaseLabel,children:n.label}),n.hint?C(b,{style:R.phaseHint,children:n.hint}):null]}),C(f,{style:R.phaseTrack,children:C(f,{style:[R.phaseBar,{backgroundColor:n.color,width:`${Math.min(100,Math.max(1,n.value/r*100))}%`}]})}),C(b,{style:R.phaseValue,children:Lr(n.value)})]},n.label))})},Ci=()=>C(f,{style:R.bodyDeferred}),xt=({title:e,icon:t,children:r,defaultOpen:o=false,count:n})=>{let[i,s]=or(o);return J(f,{style:R.collapsibleSection,children:[J(N,{style:R.collapsibleHeader,onPress:()=>s(!i),testID:`buoy-network-section-${e.toLowerCase().replace(/\s+/g,"-")}`,accessibilityRole:"button",accessibilityLabel:e,children:[J(f,{style:R.collapsibleTitle,children:[t,C(b,{style:R.collapsibleTitleText,children:e}),n!==void 0?C(b,{style:R.collapsibleCount,children:n}):null]}),i?C(yi,{size:16,color:B.color.textSecondary}):C(mi,{size:16,color:B.color.textSecondary})]}),i?C(f,{style:R.collapsibleContent,children:r}):null]})},jd=({url:e,requestData:t,operationName:r,graphqlVariables:o,requestClient:n,isPro:i=false,onUpgradePress:s})=>{let l=v=>{try{let T=new URL(v),x=String(T.protocol||""),L=String(T.host||""),m=x==="https:",k=String(T.pathname||"");if(n==="graphql"&&r){let I=xi(r,o);k=`${k} (${I})`}else r&&(k=`${k} (${r})`);let E={},g=T.searchParams;return g&&typeof g.forEach=="function"&&g.forEach((I,D)=>{E[D]=I}),{protocol:x.replace(":",""),host:L,pathname:k,params:Object.keys(E).length>0?E:null,isSecure:m}}catch{return{protocol:"",host:e,pathname:"",params:null,isSecure:false}}},a=Sd(()=>l(e),[e,n,r,o]),[d,u]=or(false);return J(f,{style:R.urlBreakdown,children:[J(f,{style:R.urlRow,children:[a.isSecure?C(Td,{size:12,color:Br.semantic.success}):C(Cd,{size:12,color:Br.semantic.warning}),C(b,{style:R.urlDomain,children:a.host}),J(b,{style:R.urlProtocol,children:["(",a.protocol.toUpperCase(),")"]}),i?C(vi,{value:e,buttonStyle:R.copyButton}):C(N,{style:R.copyButton,onPress:s,activeOpacity:.7,children:C(bi,{size:14,color:B.color.textSecondary})})]}),C(f,{style:R.urlPathRow,children:J(b,{style:R.urlPath,numberOfLines:2,children:[a.pathname,a.params?J(b,{style:R.urlQueryString,children:["?",new URLSearchParams(a.params).toString()]}):null]})}),a.params?J(f,{style:R.queryParamsCollapsible,children:[J(N,{style:R.queryParamsToggle,onPress:()=>u(!d),activeOpacity:.7,children:[C(b,{style:R.queryParamsToggleText,children:"Query Parameters"}),C(b,{style:R.collapsibleCount,children:Object.keys(a.params).length}),d?C(yi,{size:14,color:B.color.textSecondary}):C(mi,{size:14,color:B.color.textSecondary})]}),d?C(nr,{title:"",data:a.params,showTypeFilter:true,rawMode:true,initialExpanded:true}):null]}):null]})},ki=xd(function({event:e,ignoredPatterns:t=Md,onTogglePattern:r=Nd,showBodies:o=true}){let n=e.status?Si(e.status):null,i=!e.status&&!e.error,{isPro:s}=Pd(),[l,a]=or(false);pi(()=>{l&&s&&a(false)},[l,s]);let d=Hd(),u=e.requestData===void 0&&(e.requestBodyOmitted===true||(e.requestSize??0)>0),v=e.responseData===void 0&&(e.responseBodyOmitted===true||(e.responseSize??0)>0),T=e.headersOmitted===true,[x,L]=or(null),[m,k]=or(false);pi(()=>{if(L(null),!d||!u&&!v&&!T){k(false);return}let S=false;return k(true),d(e.id).then(z=>{S||L(z)}).catch(()=>{}).finally(()=>{S||k(false)}),()=>{S=true}},[e.id,d,u,v,T]);let E=e.requestData??x?.requestData??void 0,g=e.responseData??x?.responseData??void 0,I=(T?x?.requestHeaders:void 0)??e.requestHeaders,D=(T?x?.responseHeaders:void 0)??e.responseHeaders,H=()=>{let S={method:e.method,url:e.url,status:e.status,statusText:e.statusText,timestamp:new Date(e.timestamp).toISOString(),duration:e.duration?`${e.duration}ms`:"N/A",requestHeaders:I,requestData:E,responseHeaders:D,responseData:g,requestSize:e.requestSize?Ye(e.requestSize):"N/A",responseSize:e.responseSize?Ye(e.responseSize):"N/A",error:e.error,client:e.requestClient};return`# Network Request Details
8
+ ... [truncated, ${this.formatBytes(s)} omitted]`,size:n,truncated:true}}try{return{body:JSON.parse(o),size:n,truncated:false}}catch{return{body:o,size:n,truncated:false}}}catch{return{body:"~~~ unable to read body ~~~",size:0,truncated:false}}}formatBytes(e){if(e===0)return"0 B";let t=1024,r=["B","KB","MB","GB"],o=Math.floor(Math.log(e)/Math.log(t));return`${Math.round(e/Math.pow(t,o)*100)/100} ${r[o]}`}handleXHRResponse(e,t,r,o,n,i,s,l,a=false,u="xhr",d,g){let x=l?ue()-l:0,y=e._buoyTtfb,R=y===void 0?void 0:{ttfb:y,download:Math.max(0,x-y)};if(a||e.status===0){this.emit({type:"error",timestamp:new Date,duration:x,request:{id:t||"unknown",url:r,method:o,headers:n,data:i,params:s||void 0,client:u},error:{message:a?"Request failed":"Network error or request aborted"},override:d,condition:g});return}let h,C=0;try{let w=e.response;if(e.responseType==="json"&&w)h=w,C=JSON.stringify(w).length;else if(e.responseType===""||e.responseType==="text"){if(e.responseText){C=e.responseText.length;try{h=JSON.parse(e.responseText)}catch{h=e.responseText}}}else if(e.responseType==="arraybuffer")if(w)try{let I=new TextDecoder("utf-8").decode(w);C=I.length;try{h=JSON.parse(I)}catch{h=I}}catch{h=`[arraybuffer response - ${w.byteLength||0} bytes]`,C=w.byteLength||0}else h="[arraybuffer response - no data]",C=0;else if(e.responseType==="blob")if(w instanceof Blob)h=`[blob response - ${w.size} bytes, type: ${w.type||"unknown"}]`,C=w.size;else if(w)try{h=typeof w=="string"?JSON.parse(w):w,C=JSON.stringify(h).length}catch{h="[blob response - unable to parse]",C=0}else h="[blob response - no data]",C=0;else if(w)if(typeof w=="string"){h=w,C=w.length;try{h=JSON.parse(w)}catch{}}else typeof w=="object"?(h=w,C=JSON.stringify(w).length):(h=String(w),C=String(w).length)}catch{h="~~~ unable to read body ~~~"}if(g?.downloadBytesPerSecond&&(!e.responseType||e.responseType==="text"||e.responseType==="json")){let w=e._response;typeof w=="string"&&(C=Fo(w))}let k={};try{let w=e.getAllResponseHeaders();w&&w.split(`\r
9
+ `).forEach(I=>{if(I){let z=I.indexOf(": ");if(z>0){let $=I.substring(0,z).toLowerCase(),P=I.substring(z+2);k[$]=P}}})}catch{}id(e.status)==="response"?this.emit({type:"response",timestamp:new Date,duration:x,timings:R,request:{id:t||"unknown",url:r,method:o,headers:n,data:i,params:s||void 0,client:u},response:{status:e.status,statusText:sd(e.status,e.statusText),headers:k,body:h,size:C},override:d,condition:g}):this.emit({type:"error",timestamp:new Date,duration:x,request:{id:t||"unknown",url:r,method:o,headers:n,data:i,params:s||void 0,client:u},response:{status:e.status,statusText:e.statusText,headers:k,body:h,size:C},error:{message:"Network Error"},override:d,condition:g})}isFetchInterceptionLive(){return globalThis.fetch[Li]===true}isXhrInterceptionLive(){return XMLHttpRequest.prototype.send[Bi]===true}isInterceptionLive(){return this.isFetchInterceptionLive()&&this.isXhrInterceptionLive()}startListening(){let e=this.isListening&&this.isFetchInterceptionLive(),t=this.isListening&&this.isXhrInterceptionLive();e&&t||(e||this.installFetchInterceptor(),t||this.installXhrInterceptor(),this.isListening=true)}installFetchInterceptor(){let e=this,t=globalThis.fetch.bind(globalThis);this.originalFetch=globalThis.fetch;let r=++this.fetchGeneration,o=async(n,i)=>{let s=zr(typeof n=="string"?n:n instanceof URL?n.href:n.url);if(r!==e.fetchGeneration)return t(n,i);if(i?.__buoyInternal||e.shouldIgnoreUrl(s)){let c=It;It=true;try{return t(n,i)}finally{It=c}}let l=ue(),a=Dr("fetch"),u=typeof n=="object"&&"method"in n?n:void 0,d=i?.method??u?.method??"GET",g=i?.signal!==void 0?i.signal:u?.signal;lt(g);let x=Di(s),y=x?.uploadBytesPerSecond?{...x,uploadCap:Cl(n,i)}:x,{url:R,params:h}=e.parseUrl(s),C={},k=i?.headers??u?.headers;k&&(k instanceof Headers?k.forEach((c,p)=>{C[p]=c}):Array.isArray(k)?k.forEach(([c,p])=>{C[c]=p}):C={...k}),Object.assign(C,Pi(s));let w;if(i?.body)if(typeof i.body=="string")try{w=JSON.parse(i.body)}catch{w=i.body}else w=i.body;let I=C["X-Request-Client"]||C["x-request-client"]||"fetch";y?.profile!=="offline"&&Uo()&&await Ei();let z=typeof i?.body=="string"?i.body:void 0;if(z===void 0&&i?.body===void 0&&u&&!u.bodyUsed&&d!=="GET"&&d!=="HEAD"&&Zl())try{z=(await e.readStreamedBody(u.clone())).body}catch{}let $=y?.profile!=="offline"&&Uo()?od(s,d,C,z):null;$&&await $;let P=y?.profile!=="offline"&&Uo()?Ii(s,d,C,z):null,A=P?Ri(P):void 0;e.emit({type:"request",timestamp:new Date,request:{id:a||"unknown",url:R,method:d,headers:C,data:w,params:h||void 0,client:I},override:A,condition:y});let v=c=>{try{w=JSON.parse(c)}catch{w=c}e.emit({type:"request-body",timestamp:new Date,request:{id:a||"unknown",url:R,method:d,data:w,client:I}})};if(i?.body===void 0&&u&&typeof z=="string")v(z);else if(!y?.uploadBytesPerSecond&&i?.body===void 0&&u&&!u.bodyUsed&&d!=="GET"&&d!=="HEAD")try{let c=u.clone();e.readStreamedBody(c).then(({body:p})=>{p&&v(p)}).catch(()=>{})}catch{}try{if((y||P)&&await $o((y?.delayMs??0)+(P?.delayMs??0),g),lt(g),y?.profile==="offline")throw new TypeError("Network request failed (Buoy Offline)");if(P?.kind==="fail")throw Hl(P);y?.uploadBytesPerSecond&&(await Or(y.uploadCap?.knownBytes??0,y.uploadBytesPerSecond,g),lt(g));let c;if(P?.kind==="respond")c=Al(s,P);else{let M=It;It=true;let N;try{N=t(n,i)}finally{It=M}c=await N}if(y?.downloadBytesPerSecond){let M={};c.headers.forEach((K,be)=>{M[be.toLowerCase()]=K});let N=0,J=0,le=[],ne=(K,be)=>{let pe=new Uint8Array(J),ft=0;for(let Ye of le)pe.set(Ye,ft),ft+=Ye.byteLength;let Ae=K?new TextDecoder().decode(pe):Go;if(K&&M["content-type"]?.includes("json"))try{Ae=JSON.parse(Ae)}catch{}e.emit({type:be!==void 0?"error":"response",timestamp:new Date,duration:ue()-l,request:{id:a,url:R,method:d,headers:C,data:w,params:h||void 0,client:I},response:{status:c.status,statusText:c.statusText,headers:M,body:Ae,size:N},...be!==void 0?{error:{message:be instanceof Error?be.message:String(be)}}:{},override:A,condition:y})};return ne(false),pi(c,y.downloadBytesPerSecond,g,(K,be)=>{if(K){N+=K.byteLength;let pe=Math.min(K.byteLength,65536-J);pe>0&&(le.push(K.slice(0,pe)),J+=pe)}else ne(true,be)},d.toUpperCase()==="HEAD")}let p=ue()-l,f=typeof c.body?.getReader=="function"||qi(c.headers?.get?.("content-type")),S=c.clone(),{body:D,size:H}=f?{body:Go,size:0}:await e.processResponseBody(S),V=ue()-l,Z=Math.max(0,V-p),Y=Z>0?{ttfb:p,download:Z}:void 0,L={};if(c.headers.forEach((M,N)=>{L[N.toLowerCase()]=M}),e.emit({type:"response",timestamp:new Date,duration:V,timings:Y,request:{id:a||"unknown",url:R,method:d,headers:C,data:w,params:h||void 0,client:I},response:{status:c.status,statusText:c.statusText,headers:L,body:D,size:H},override:A,condition:y}),f){let M=c.headers?.get?.("content-type");e.readStreamedBody(S,qi(M)?void 0:1024*1024).then(N=>{let J=N.body;if(M?.includes("json"))try{J=JSON.parse(N.body)}catch{}e.emit({type:"response",timestamp:new Date,duration:ue()-l,timings:Y,request:{id:a||"unknown",url:R,method:d,headers:C,data:w,params:h||void 0,client:I},response:{status:c.status,statusText:c.statusText,headers:L,body:J,size:N.size},override:A,condition:y})}).catch(()=>{})}return c}catch(c){let p=ue()-l;throw e.emit({type:"error",timestamp:new Date,duration:p,request:{id:a||"unknown",url:R,method:d,headers:C,data:w,params:h||void 0,client:I},error:{message:c instanceof Error?c.message:"Network error",stack:c instanceof Error?c.stack:void 0},override:A,condition:y}),c}};o[Li]=true,this.patchedFetch=o,globalThis.fetch=this.patchedFetch}installXhrInterceptor(){let e=this,t=XMLHttpRequest.prototype.open,r=XMLHttpRequest.prototype.send,o=XMLHttpRequest.prototype.setRequestHeader;this.originalXHROpen=t,this.originalXHRSend=r,this.originalXHRSetRequestHeader=o;let n=++this.xhrGeneration,i=new WeakMap,s=function(u,d,g,x,y){let R=t.call(this,u,d,g??true,x,y);if(n===e.xhrGeneration){i.get(this)?.();let h=this;h._buoyRequestId=Dr("xhr"),h._method=u,h._url=zr(d),h._buoyStartTime=ue(),h._requestHeaders={},h._buoyAsync=g!==false,h._buoyRestoreAbort?.(),h._buoyWaitedForRules=false,h._buoyHeldSend=false,h._buoyOpenSeq=(h._buoyOpenSeq??0)+1}return R},l=function(u,d){let g=this;return n===e.xhrGeneration&&g._requestHeaders&&(g._requestHeaders[u]=d),o.call(this,u,d)},a=function(u){if(n!==e.xhrGeneration||It)return r.call(this,u);if(Bl(this))throw new DOMException("The request has already been sent.","InvalidStateError");if(this.readyState!==1||this._sent)return r.call(this,u);let d=this;if(d._buoyHeldSend)throw new DOMException("The request has already been sent.","InvalidStateError");if(!Yl()&&d._buoyAsync!==false&&!d._buoyWaitedForRules){d._buoyWaitedForRules=true,d._buoyHeldSend=true;let L=d._buoyOpenSeq,M=false,N=Object.prototype.hasOwnProperty.call(this,"abort")?this.abort:void 0,J=()=>{d._buoyRestoreAbort===J&&(d._buoyRestoreAbort=void 0,N?this.abort=N:delete this.abort)};d._buoyRestoreAbort=J;let le=N??Object.getPrototypeOf(this).abort;this.abort=function(){return M=true,d._buoyHeldSend=false,J(),le.call(this)};let ne=()=>{J(),!(M||d._buoyOpenSeq!==L)&&(d._buoyHeldSend=false,this.readyState===1&&!this._sent&&a.call(this,u))};Ei().then(ne,ne);return}let g=d._buoyRequestId,x=d._method||"GET",y=d._url||"",R=ue();d._buoyStartTime=R,d._buoyTtfb=void 0;let h=d._requestHeaders||{};if(Object.assign(h,Pi(y)),e.shouldIgnoreUrl(y))return r.call(this,u);let{url:C,params:k}=e.parseUrl(y),w;if(u)if(typeof u=="string")try{w=JSON.parse(u)}catch{w=u}else w=u;let I=h["X-Request-Client"]||h["x-request-client"],z=h.Accept||h.accept||"",$=z.includes("application/json")&&z.includes("text/plain")&&z.includes("*/*")&&!cd(),P=I||($?"axios":"xhr"),A=Di(y),v=A?.uploadBytesPerSecond?{...A,uploadCap:jo(u)}:A,c=v?.profile==="offline"?null:Ii(y,x,h,typeof u=="string"?u:void 0),p=c?Ri(c):void 0;e.emit({type:"request",timestamp:new Date,request:{id:g||"unknown",url:C,method:x,headers:h,data:w,params:k||void 0,client:P},override:p,condition:v});let f=false,S=(L=false)=>{f||(f=true,e.handleXHRResponse(this,g||"unknown",C,x,h,w,k,R||0,L,P,p,v),D())},D=()=>{i.delete(this),this.removeEventListener("load",H),this.removeEventListener("error",V),this.removeEventListener("abort",Z),this.removeEventListener("readystatechange",Y)};i.set(this,D);let H=()=>{S(false)},V=()=>{S(true)},Z=()=>{S(true)},Y=()=>{if(this.readyState===2){let L=this;L._buoyTtfb===void 0&&L._buoyStartTime&&(L._buoyTtfb=ue()-L._buoyStartTime)}this.readyState===4&&!f&&S(false)};if(this.addEventListener("load",H),this.addEventListener("error",V),this.addEventListener("abort",Z),this.addEventListener("readystatechange",Y),v){zl(this,y,v,c,()=>r.call(this,u),u);return}if(!(c&&wi(this,y,c,()=>r.call(this,u))))return r.call(this,u)};a[Bi]=true,this.patchedXHROpen=s,this.patchedXHRSend=a,this.patchedXHRSetRequestHeader=l,XMLHttpRequest.prototype.open=this.patchedXHROpen,XMLHttpRequest.prototype.send=this.patchedXHRSend,XMLHttpRequest.prototype.setRequestHeader=this.patchedXHRSetRequestHeader}stopListening(){this.isListening&&(this.fetchGeneration++,this.xhrGeneration++,this.patchedFetch&&globalThis.fetch===this.patchedFetch&&(globalThis.fetch=this.originalFetch),this.patchedXHROpen&&XMLHttpRequest.prototype.open===this.patchedXHROpen&&(XMLHttpRequest.prototype.open=this.originalXHROpen),this.patchedXHRSend&&XMLHttpRequest.prototype.send===this.patchedXHRSend&&(XMLHttpRequest.prototype.send=this.originalXHRSend),this.patchedXHRSetRequestHeader&&XMLHttpRequest.prototype.setRequestHeader===this.patchedXHRSetRequestHeader&&(XMLHttpRequest.prototype.setRequestHeader=this.originalXHRSetRequestHeader),this.patchedFetch=null,this.patchedXHROpen=null,this.patchedXHRSend=null,this.patchedXHRSetRequestHeader=null,this.isListening=false)}adoptEarlyRequests(){let e=globalThis,t=e[ld]??e.__BUOY_EARLY_NETWORK__;if(t?.version===1)for(let r of t.adopt())try{r.kind==="fetch"?this.adoptEarlyFetch(r):this.adoptEarlyXhr(r)}catch{}}adoptEarlyFetch(e){let{input:t,init:r}=e,o=typeof t=="object"&&"method"in t?t:void 0,n=zr(typeof t=="string"?t:t instanceof URL?t.href:t.url);if(this.shouldIgnoreUrl(n))return;let i=Dr("fetch"),s=r?.method??o?.method??"GET",{url:l,params:a}=this.parseUrl(n),u=dd(r?.headers??o?.headers),d=r?.body;if(typeof d=="string")try{d=JSON.parse(d)}catch{}let g=u["X-Request-Client"]||u["x-request-client"]||"fetch",x=()=>({id:i,url:l,method:s,headers:u,data:d,params:a||void 0,client:g});this.emit({type:"request",timestamp:new Date(e.start),request:x()}),e.requestCopy&&this.readStreamedBody(e.requestCopy).then(({body:y})=>{try{d=JSON.parse(y)}catch{d=y}this.emit({type:"request-body",timestamp:new Date,request:{id:i,url:l,method:s,data:d,client:g}})}).catch(()=>{}),e.settled.then(async({response:y,clone:R,error:h,headersAt:C})=>{if(!y){this.emit({type:"error",timestamp:new Date,duration:C-e.start,request:x(),error:{message:h instanceof Error?h.message:"Network error",stack:h instanceof Error?h.stack:void 0}});return}let{body:k,size:w}=R?await this.processResponseBody(R):{body:Go,size:0},I=Math.max(0,ue()-e.start),z=C-e.start,$={};y.headers.forEach((P,A)=>{$[A.toLowerCase()]=P}),this.emit({type:"response",timestamp:new Date,duration:I,timings:I>z?{ttfb:z,download:I-z}:void 0,request:x(),response:{status:y.status,statusText:y.statusText,headers:$,body:k,size:w}})})}adoptEarlyXhr(e){let t=zr(e.url);if(this.shouldIgnoreUrl(t))return;let r=Dr("xhr"),o=e.method.toUpperCase(),{url:n,params:i}=this.parseUrl(t),s=e.body;if(typeof s=="string")try{s=JSON.parse(s)}catch{}let l=e.headers["X-Request-Client"]||e.headers["x-request-client"]||"xhr";this.emit({type:"request",timestamp:new Date(e.start),request:{id:r,url:n,method:o,headers:e.headers,data:s,params:i||void 0,client:l}});let a=e.xhr,u=()=>{let d=(a._buoyEarlyEnd??ue())-e.start;this.handleXHRResponse(a,r,n,o,e.headers,s,i,ue()-d,false,l)};a.readyState===4?u():a.addEventListener("loadend",u,{once:true})}addListener(e){return this.listeners.push(e),()=>{let t=this.listeners.indexOf(e);t>-1&&this.listeners.splice(t,1)}}removeAllListeners(){this.listeners=[]}get isActive(){return this.isListening}get listenerCount(){return this.listeners.length}},gt=null,Yo=()=>(gt||(gt=new fd),gt),Mr=Yo,Oi=()=>Yo().startListening(),pr=()=>gt?.stopListening(),fr=e=>Yo().addListener(e),yd=()=>gt?.removeAllListeners(),zi=()=>gt?.isActive??false,Pt=()=>gt?.listenerCount??0,gd=()=>gt?.isInterceptionLive()??false;O();var mt={normal:{label:"Normal",delayMs:0},offline:{label:"Offline (requests)",delayMs:0},slow:{label:"Slow (+500 ms)",delayMs:500},verySlow:{label:"Very slow (+2000 ms)",delayMs:2e3},slow3g:{label:"Slow 3G",delayMs:2e3,downloadBytesPerSecond:5e4,uploadBytesPerSecond:5e4},slow4g:{label:"Slow 4G",delayMs:562.5,downloadBytesPerSecond:18e4,uploadBytesPerSecond:84375},fast4g:{label:"Fast 4G",delayMs:165,downloadBytesPerSecond:1012500,uploadBytesPerSecond:168750}},md=["auto","real","offline","wifi","cellular","noInternet"],bd={download:"Paces bytes to the app in JS. The socket stays at its real speed.",upload:"Waits before send for known body bytes. Unknown sizes pass through with latency only. Multipart overhead is not counted. Each call marks a partial or skipped cap. Upload time is simulated; the socket is not paced.",transports:"Affects global fetch and RN XHR. WebSocket, native images, native SDKs and file transfers are not affected."};var Zo={netInfo:{supported:false,reason:"Load the NetInfo hook before app code."},expoNetwork:{supported:false,reason:"Load the Expo Network hook before app code."}},Kt="auto",Qo=0,vd=()=>Kt,Lt=()=>Qo;var en=()=>Qe!=="normal"||!["auto","real"].includes(Kt);function Bt(){let e=mt[Qe];return{version:2,runtimeId:Sd,revision:Qo,profile:Qe,connection:Kt,available:qt(),active:en(),delayMs:e.delayMs,downloadBytesPerSecond:e.downloadBytesPerSecond??null,uploadBytesPerSecond:e.uploadBytesPerSecond??null,capabilities:{...Zo,fetch:"JS body delivery",xhr:"RN progress and body delivery",upload:"time-simulated",webSocket:false,nativeImages:false,nativeModules:false},scope:bd}}function Nr(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Choose a speed or link state.");let t=e;if(Object.keys(t).some(i=>i!=="profile"&&i!=="connection")||!("profile"in t)&&!("connection"in t))throw new Error("Choose a speed or link state.");let r="profile"in t?t.profile:Qe,o="connection"in t?t.connection:r==="normal"&&"profile"in t?"auto":Kt;if(typeof r!="string"||!Object.prototype.hasOwnProperty.call(mt,r))throw new Error("Choose a valid speed profile.");if(!md.includes(o))throw new Error("Choose a valid link state.");if((r!=="normal"||!["auto","real"].includes(o))&&!qt())throw new Error("Use a signed-in account and a dev build.");if(!["auto","real"].includes(o)&&!Zo.netInfo.supported&&!Zo.expoNetwork.supported)throw new Error("Load a link hook before app code.");if(r===Qe&&o===Kt)return Bt();let n=r!=="normal";return n&&!$r&&(Oi(),$r=fr(()=>{})),n||($r?.(),$r=void 0,Pt()===0&&pr()),Qe=r,Kt=o,Qo++,Fr.forEach(i=>i()),Bt()}var Sd=`${Date.now()}-${Math.random().toString(36).slice(2)}`,Qe="normal",$r,Fr=new Set,qt=()=>typeof me<"u"&&me&&di(),Ot=()=>Qe,et=e=>(Fr.add(e),()=>{Fr.delete(e)});function jr(e){return Nr({profile:e}).profile}function Di(e){if(Qe==="normal"||!qt()||!/^https?:\/\//i.test(e))return;let{label:t,...r}=mt[Qe];return Object.freeze({profile:Qe,...r})}xl(()=>{di()||jr("normal"),Fr.forEach(e=>e())});import{jsx as tn,jsxs as wd}from"react/jsx-runtime";function xd({size:e}){li(et,Lt,Lt);let t=en(),r=li(et,Ot,Ot);return wd(m,{accessibilityLabel:r==="normal"?"Network":`Network: ${mt[r].label}`,children:[tn(wl,{size:e}),t&&tn(m,{pointerEvents:"none",style:{position:"absolute",top:-6,right:-8,width:48,alignItems:"flex-end"},children:tn(b,{testID:"buoy-network-condition-indicator",numberOfLines:1,style:{color:"#FFCC66",fontSize:10,fontWeight:"700"},children:r==="normal"?"LINK":r==="offline"?"OFF":`+${mt[r].delayMs}`})})]})}import{createToolFactory as Cd,defineToolPreset as kd}from"@buoy-gg/shared-ui/web";O();O();Se();import{useEffect as rn,useRef as on,useState as nn,useSyncExternalStore as Wr}from"react";import{FloatingTool as Td,night as ze,openFloatingTool as Rd,persistentStorage as Ed,registerPersistentFloatingTool as Id}from"@buoy-gg/shared-ui/web";O();Se();import{useEffect as Ai,useRef as sn,useState as Vr,useSyncExternalStore as an}from"react";import{ChevronDown as Pd,Check as Ld,night as de}from"@buoy-gg/shared-ui/web";import{jsx as we,jsxs as zt}from"react/jsx-runtime";var Hi=[{profile:"normal",label:"No throttling"},{profile:"slow",label:"Slow"},{profile:"verySlow",label:"Very slow"},{profile:"offline",label:"Offline"},{profile:"slow3g",label:"Slow 3G"},{profile:"slow4g",label:"Slow 4G"},{profile:"fast4g",label:"Fast 4G"}],Mi={normal:"No added delay",slow:"+500 ms before each new request",verySlow:"+2 seconds before each new request",offline:"New requests fail before sending",slow3g:"50 KB/s down, 50 KB/s up; +2000 ms",slow4g:"180 KB/s down, 84.375 KB/s up; +562.5 ms",fast4g:"1012.5 KB/s down, 168.75 KB/s up; +165 ms"};function Bd({remote:e,compact:t=false}){an(et,Lt,Lt);let r=e?e.state:Bt(),[o,n]=Vr(false),i=an(et,Ot,Ot),s=an(et,qt,qt),[l,a]=Vr(false),[u,d]=Vr(),[g,x]=Vr(false),y=sn(false),R=sn(true),h=sn(0);Ai(()=>{h.current++,y.current=false,x(false),d(void 0)},[e?.targetId]),Ai(()=>(R.current=true,()=>{R.current=false}),[]);let C=e?e.profile:i,k=e?e.available:s,w=r?.active??(C!==null&&C!=="normal"),I=C==="offline"?de.color.danger:w?de.color.warning:de.color.accent;async function z(v){if(!k||y.current)return;if(v===C&&(v!=="normal"||!r?.active)){a(false);return}let c=++h.current;y.current=true,x(true),d(void 0);try{e?await e.onChange(v):jr(v),R.current&&h.current===c&&a(false)}catch(p){R.current&&h.current===c&&d(p instanceof Error?p.message:String(p))}finally{h.current===c&&(y.current=false,R.current&&x(false))}}let $=[["auto","Follow speed"],["real","Real link"],["offline","Offline"],["wifi","Wi-Fi"],["cellular","Cellular"],["noInternet","No internet"]],P=(!e||!!e.onConnectionChange)&&(r?.capabilities.netInfo.supported||r?.capabilities.expoNetwork.supported),A=Hi.find(v=>v.profile===C)?.label??"Unavailable";return zt(m,{style:se.container,testID:"buoy-network-throttling-screen",children:[we(b,{style:se.heading,children:"Connection profile"}),zt(F,{testID:"buoy-network-conditions",accessibilityRole:"button",accessibilityLabel:`Network throttling: ${A}`,accessibilityState:{expanded:l,disabled:!k||g},disabled:!k||g,onPress:()=>a(v=>!v),style:[se.dropdown,l&&se.dropdownOpen,!k&&se.disabled],children:[we(b,{style:[se.value,w&&{color:I}],children:A}),g?we(Lr,{size:"small",color:de.color.textSecondary}):we(Pd,{size:16,color:de.color.textSecondary})]}),l&&we(m,{accessibilityRole:"radiogroup",accessibilityLabel:"Connection profile",style:se.options,children:Hi.map(v=>{let c=C===v.profile;return zt(F,{testID:`buoy-network-condition-${v.profile}`,accessibilityRole:"radio",accessibilityLabel:v.label,accessibilityState:{checked:c,disabled:!k||g},disabled:!k||g,onPress:()=>void z(v.profile),style:[se.option,c&&se.selected],children:[zt(m,{style:se.optionBody,children:[we(b,{style:[se.optionTitle,c&&{color:I}],children:v.label}),we(b,{style:se.caption,children:Mi[v.profile]})]}),c&&we(Ld,{size:16,color:I})]},v.profile)})}),we(b,{style:se.caption,accessibilityLiveRegion:"polite",children:g?"Applying to device\u2026":k?C?Mi[C]:"Waiting for device status":e?"Conditions unavailable on this device":"Requires a signed-in account and a development build"}),!!u&&we(b,{accessibilityRole:"alert",style:se.error,children:u}),we(F,{testID:"buoy-network-link-state",accessibilityRole:"button",accessibilityLabel:"App link state",disabled:!k||g||!P,onPress:()=>n(v=>!v),style:se.dropdown,children:zt(b,{style:se.value,children:["App link: ",$.find(([v])=>v===r?.connection)?.[1]??"Unavailable"]})}),o&&$.map(([v,c])=>we(F,{testID:`buoy-network-link-${v}`,accessibilityRole:"radio",accessibilityState:{checked:r?.connection===v,disabled:g||!k},disabled:g||!k,style:se.option,onPress:async()=>{if(y.current)return;let p=++h.current;y.current=true,x(true),d(void 0);try{e?await e.onConnectionChange?.(v):Nr({connection:v}),R.current&&h.current===p&&n(false)}catch(f){R.current&&h.current===p&&d(f instanceof Error?f.message:String(f))}finally{h.current===p&&(y.current=false,R.current&&x(false))}},children:we(b,{style:se.optionTitle,children:c})},v)),!P&&we(b,{style:se.caption,children:r?.capabilities.netInfo.reason??"This device has no link hook."}),!t&&zt(m,{style:se.help,children:[we(b,{style:se.heading,children:"How it works"}),r&&zt(b,{style:se.caption,children:["NetInfo: ",r.capabilities.netInfo.supported?"Hook on":r.capabilities.netInfo.reason??"No hook",". Expo Network: ",r.capabilities.expoNetwork.supported?"Hook on":r.capabilities.expoNetwork.reason??"No hook","."]}),we(b,{style:se.caption,children:"Down caps pace bytes to the app in JS. The socket stays at its real speed."}),we(b,{style:se.caption,children:"Up caps wait before send for known bytes. Upload time is simulated. The socket is not paced. Unknown sizes pass through with latency only. Each call shows any cap gap."}),we(b,{style:se.caption,children:"Caps apply per call through global fetch and RN XHR. WebSocket, native images, native SDKs and file transfers are not affected."}),we(b,{style:se.caption,children:"Link state changes what NetInfo and Expo Network report. It does not change the radio or web calls."}),we(b,{style:se.caption,children:"Stays on when this tool closes or capture pauses. No throttling clears both controls. App reload clears them too."})]})]})}var se=ve.create({container:{padding:de.gutter,gap:10},heading:{fontSize:de.font.caption,fontWeight:"600",color:de.color.textSecondary},dropdown:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:12,minHeight:44,paddingHorizontal:12,paddingVertical:10,borderRadius:de.radius.segment,borderWidth:1,borderColor:de.color.separator,backgroundColor:de.color.surfaceElevated},dropdownOpen:{borderColor:de.color.accentBorderStrong},value:{flex:1,fontSize:de.font.body,color:de.color.text},options:{padding:4,borderRadius:de.radius.row,borderWidth:1,borderColor:de.color.border,backgroundColor:de.color.surface},option:{flexDirection:"row",alignItems:"center",gap:12,minHeight:54,padding:10,borderRadius:de.radius.segment},optionBody:{flex:1,gap:4},optionTitle:{fontSize:de.font.caption,fontWeight:"600",color:de.color.text},selected:{backgroundColor:de.color.surfaceElevated},disabled:{opacity:.45},caption:{fontSize:de.font.caption,lineHeight:19,color:de.color.textSecondary},help:{marginTop:14,paddingTop:16,gap:10,borderTopWidth:1,borderTopColor:de.color.separator},error:{fontSize:de.font.caption,lineHeight:18,color:de.color.danger}});import{jsx as Ce,jsxs as Ur}from"react/jsx-runtime";function qd(){let e,t=new Set;return{getSnapshot:()=>e,subscribe:r=>(t.add(r),()=>{t.delete(r)}),update(r){e=r,t.forEach(o=>o())}}}var Od=()=>()=>{},Ni=()=>{},_r=[{id:"normal",label:"No throttling",detail:"No added delay"},{id:"slow",label:"Slow",detail:"+500 ms before sending"},{id:"verySlow",label:"Very slow",detail:"+2 seconds before sending"},{id:"offline",label:"Offline",detail:"New requests fail"}],zd={id:"network-throttling",render:e=>Ce(ji,{...e})};function $i(){return typeof me>"u"||!me?()=>{}:Id(zd,Ed)}typeof me<"u"&&me&&typeof navigator<"u"&&navigator.product==="ReactNative"&&$i();function Fi(e,t=false){Rd({id:"network-throttling",render:r=>Ce(ji,{...r,source:e,showControls:t})})}function ji({id:e,revealToken:t,dismiss:r,source:o,showControls:n=false}){Wr(et,Lt,Lt);let i=Bt(),s=Wr(et,Ot,Ot),l=Wr(et,qt,qt),a=Wr(o?.subscribe??Od,o?.getSnapshot??Ni,Ni),u=o?a?.profile??null:s,d=o?a?.available===true:l,[g,x]=nn(n);rn(()=>{x(n)},[n,t]);let[y,R]=nn(false),[h,C]=nn(),k=on(false),w=on(0),I=on(true),{width:z,height:$}=Jn();rn(()=>(I.current=true,()=>{I.current=false}),[]),rn(()=>{w.current+=1,k.current=false,R(false),C(void 0)},[o,a?.targetId]);let P=o?a?.state?.active??(u!==null&&u!=="normal"):i.active,A=u??"normal",v=_r.find(H=>H.id===A)??{label:mt[A].label},c=_r[(_r.findIndex(H=>H.id===A)+1)%_r.length],p=!d||A==="offline"?0:A==="verySlow"?1:A==="slow"?2:4,f=y?"Applying\u2026":d?A==="normal"?P?"Link set":"0 ms":A==="slow"?"+500 ms":A==="verySlow"?"+2000 ms":A==="offline"?"Blocked":`${Math.round((mt[A].downloadBytesPerSecond??0)/1e3)} kB/s`:"Unavailable";async function S(H,V=false){if(k.current)return;let Z=++w.current;k.current=true,R(true),C(void 0);let Y=o?.getSnapshot();try{if(o){if(!Y?.available)throw new Error("Device unavailable. Open Network again to reconnect these controls.");await Y.onChange(H)}else jr(H);I.current&&w.current===Z&&V&&r()}catch(L){I.current&&w.current===Z&&C(L instanceof Error?L.message:String(L))}finally{w.current===Z&&(k.current=false,I.current&&R(false))}}let D=h||g?Ur(m,{style:De.menu,children:[!!h&&Ce(b,{accessibilityRole:"alert",style:De.error,children:h}),g&&Ce(yt,{testID:"throttling-controls-scroll",style:{maxHeight:Math.min(420,$-180)},children:Ce(Bd,{remote:o?a??{profile:null,available:false,onChange:async()=>{throw new Error("Device unavailable.")}}:void 0})})]}):void 0;return Ce(Td,{id:e,revealToken:t,variant:"strip",dragFromSurface:Pr.OS!=="android"||!g,accessibilityLabel:`Move or hide network throttling. ${P?"Active":"Off"}`,accessory:Pr.OS==="android"?void 0:D,children:Ur(m,{style:{width:Math.max(220,Math.min(336,z-64))},children:[Ur(m,{style:[De.row,{width:Math.max(220,Math.min(336,z-64))}],children:[Ce(F,{testID:"throttling-cycle",accessibilityRole:"button",accessibilityLabel:`Network: ${v.label}. Switch to ${c.label}`,accessibilityState:{disabled:y||!d},disabled:y||!d,onPress:()=>void S(c.id),style:De.signalButton,children:y?Ce(Lr,{size:"small",color:ze.color.accent}):Ur(m,{testID:`throttling-signal-${A}`,style:De.signal,children:[[7,12,18,24].map((H,V)=>Ce(m,{style:{width:4,height:H,borderRadius:2,backgroundColor:V<p?A==="offline"?ze.color.danger:ze.color.accent:ze.color.fillTertiary}},H)),A==="offline"&&Ce(m,{style:De.slash})]})}),Ce(m,{style:De.profile,children:Ce(b,{testID:"throttling-profile",accessibilityLabel:`Connection profile: ${v.label}`,accessibilityLiveRegion:"polite",numberOfLines:1,style:De.profileLabel,children:v.label})}),Ce(b,{testID:"throttling-status",numberOfLines:1,accessibilityLiveRegion:"polite",style:De.status,children:f}),Ce(F,{testID:"throttling-edit",accessibilityRole:"button",accessibilityLabel:g?"Hide speed and link controls":"Edit speed and link state",onPress:()=>x(H=>!H),style:De.action,children:Ce(b,{style:De.actionText,children:g?"Done":"Edit"})}),Ce(m,{style:De.separator}),Ce(F,{testID:"throttling-close",accessibilityRole:"button",accessibilityLabel:"Close and turn off throttling",disabled:y,accessibilityState:{disabled:y},onPress:()=>{P?S("normal",true):r()},style:[De.action,y&&De.disabled],children:Ce(b,{style:De.actionText,children:"Close"})})]}),Pr.OS==="android"&&D]})})}var De=ve.create({row:{flexDirection:"row",alignItems:"center",gap:6,paddingVertical:4,minHeight:48},signalButton:{width:36,minHeight:44,alignItems:"center",justifyContent:"center"},signal:{flexDirection:"row",alignItems:"flex-end",gap:3,height:24},slash:{position:"absolute",width:30,height:2,backgroundColor:ze.color.danger,top:11,left:-2,transform:[{rotate:"-45deg"}]},separator:{height:20,width:1,backgroundColor:ze.color.separator,marginHorizontal:2},status:{color:ze.color.textSecondary,fontSize:10,lineHeight:15,flexShrink:1},profile:{flex:1,flexDirection:"row",alignItems:"center",gap:6,minHeight:44},profileLabel:{color:ze.color.text,fontSize:13,fontWeight:"500",flexShrink:1},action:{minHeight:36,minWidth:52,borderRadius:ze.radius.input,borderWidth:1,borderColor:ze.color.accentBorderStrong,alignItems:"center",justifyContent:"center",paddingHorizontal:10},actionText:{color:ze.color.accent,fontSize:12,fontWeight:"600"},disabled:{opacity:.4},menu:{marginVertical:8,padding:6,borderRadius:ze.radius.card,borderWidth:1,borderColor:ze.color.separator,backgroundColor:ze.color.surface,shadowColor:"#000",shadowOffset:{width:0,height:6},shadowOpacity:.25,shadowRadius:16,elevation:8},error:{color:ze.color.danger,fontSize:12,lineHeight:18,padding:10}});Se();import{useState as Te,useRef as Xr,useEffect as Dt,useCallback as ln}from"react";import{Search as Dd,Wifi as Wi,Filter as Ad,Bookmark as Hd,JsModal as Md,ModalHeader as ke,devToolsStorageKeys as Jr,macOSColors as Nd,night as tt,persistentStorage as Vi,NightSegmented as $d,useFeatureGate as Fd,UpgradeModal as jd,PowerToggleButton as Wd,useIgnoredPatterns as Vd,windowDragProps as Ud}from"@buoy-gg/shared-ui/web";O();Se();import{CheckCircle as _d,Clock as Xd,DynamicFilterView as Jd,Film as Gd,FileJson as Kd,FileText as Yd,Filter as Ui,Globe as _i,Image as Zd,macOSColors as Re,night as Me,Music as Qd,XCircle as eu,monoFont as dn}from"@buoy-gg/shared-ui/web";import{useCallback as Gr,useMemo as rt,useState as tu}from"react";import{jsx as ut,jsxs as Xi}from"react/jsx-runtime";var ru=()=>false;function un(e){let t=e.responseHeaders||e.requestHeaders,r=t?.["content-type"]||t?.["Content-Type"]||"";return r.includes("json")?{type:"JSON",color:Re.semantic.info}:r.includes("xml")?{type:"XML",color:Re.semantic.success}:r.includes("html")?{type:"HTML",color:Re.semantic.warning}:r.includes("text")?{type:"TEXT",color:Re.semantic.success}:r.includes("image")?{type:"IMAGE",color:Re.semantic.error}:r.includes("video")?{type:"VIDEO",color:Re.semantic.error}:r.includes("audio")?{type:"AUDIO",color:Re.semantic.debug}:r.includes("form")?{type:"FORM",color:Re.semantic.info}:{type:"OTHER",color:Me.color.textTertiary}}function ou(e){switch(e){case"JSON":return Kd;case"HTML":case"XML":case"TEXT":return Yd;case"IMAGE":return Zd;case"VIDEO":return Gd;case"AUDIO":return Qd;default:return _i}}function nu(e){switch(e){case"GET":return Re.semantic.success;case"POST":return Re.semantic.info;case"PUT":return Re.semantic.warning;case"DELETE":return Re.semantic.error;case"PATCH":return Re.semantic.success;default:return Me.color.textTertiary}}function iu({events:e,filter:t,onFilterChange:r,ignoredPatterns:o=[],onRemovePattern:n=()=>{},isTeamPattern:i=ru,onAddPattern:s=()=>{},onTogglePatternMode:l=()=>{}}){let[a,u]=tu("contains"),d=rt(()=>{let v=new Map;for(let c of o)v.set(c.value,c.mode);return v},[o]),g=rt(()=>new Set(o.map(v=>v.value)),[o]),x=Gr(v=>{s({value:v,mode:a})},[s,a]),y=Gr(v=>{if(i(v)){let S=Me.color.accent;return ut(m,{accessibilityLabel:"Set by your team on buoy.gg",style:[Ue.modeBadge,{borderColor:`${S}60`,backgroundColor:`${S}15`}],children:ut(b,{style:[Ue.modeBadgeText,{color:S}],children:"TEAM"})})}let c=d.get(v)??"contains",p=c==="exact",f=p?Me.color.warning:Me.color.info;return ut(F,{accessibilityRole:"button",accessibilityLabel:`Match mode: ${c}. Tap to toggle.`,onPress:()=>l(v),style:[Ue.modeBadge,{borderColor:`${f}60`,backgroundColor:`${f}15`}],hitSlop:{top:6,bottom:6,left:6,right:6},children:ut(b,{style:[Ue.modeBadgeText,{color:f}],children:p?"EXACT":"CONTAINS"})})},[d,l,i]),R=Gr(()=>{let v=[{label:"Contains",value:"contains",hint:"substring"},{label:"Exact",value:"exact",hint:"whole path/host/url"}];return Xi(m,{style:Ue.modeToggleRow,children:[ut(b,{style:Ue.modeToggleLabel,children:"Match:"}),ut(m,{style:Ue.modeToggleGroup,children:v.map(c=>{let p=a===c.value;return Xi(F,{onPress:()=>u(c.value),style:[Ue.modeToggleButton,p&&Ue.modeToggleButtonActive],accessibilityRole:"button",accessibilityState:{selected:p},children:[ut(b,{style:[Ue.modeToggleButtonText,p&&Ue.modeToggleButtonTextActive],children:c.label}),ut(b,{style:Ue.modeToggleButtonHint,children:c.hint})]},c.value)})})]})},[a]),h=rt(()=>{let v={all:e.length,success:0,error:0,pending:0};return e.forEach(c=>{if(c.error||c.status&&c.status>=400){v.error+=1;return}if(c.status&&c.status>=200&&c.status<300){v.success+=1;return}!c.status&&!c.error&&(v.pending+=1)}),v},[e]),C=rt(()=>e.reduce((v,c)=>(c.method&&(v[c.method]=(v[c.method]||0)+1),v),{}),[e]),k=rt(()=>e.reduce((v,c)=>{let{type:p}=un(c);return v[p]=(v[p]||0)+1,v},{}),[e]),w=rt(()=>{let v=new Set;return e.forEach(c=>{if(c.host){v.add(c.host);return}try{if(c.url){let p=new URL(c.url),f=String(p.host||"");f&&v.add(f)}}catch{}}),Array.from(v).filter(c=>c&&c!=="").sort((c,p)=>c.localeCompare(p))},[e]),I=rt(()=>{let v=new Set;return e.forEach(c=>{if(c.url)try{let p=new URL(c.url),f=String(p.origin||""),S=String(p.pathname||""),D=`${f}${S}`;v.add(D)}catch{v.add(c.url)}}),Array.from(v).filter(c=>c&&c!=="").sort((c,p)=>c.localeCompare(p))},[e]),z=rt(()=>{let v=w.slice(0,30),c=I.slice(0,30);return[...v,...c]},[w,I]),$=Gr((v,c)=>{let[p]=v.split("::");if(p==="status"){r({...t,status:c==="all"?void 0:c});return}if(p==="method"){let f=String(c),S=t.method||[],D=S.includes(f)?S.filter(H=>H!==f):[f];r({...t,method:D.length>0?D:void 0});return}if(p==="contentType"){let f=String(c),S=t.contentType||[],D=S.includes(f)?S.filter(H=>H!==f):[f];r({...t,contentType:D.length>0?D:void 0})}},[t,r]),P=rt(()=>{let v=[];v.push({id:"status",title:"Status",type:"status",data:["all","success","error","pending"].map(f=>({id:`status::${f}`,label:f.charAt(0).toUpperCase()+f.slice(1),count:h[f],icon:f==="success"?_d:f==="error"?eu:f==="pending"?Xd:_i,color:f==="success"?Re.semantic.success:f==="error"?Re.semantic.error:f==="pending"?Re.semantic.warning:Re.semantic.info,isActive:t.status===f||!t.status&&f==="all",value:f}))});let c=Object.entries(C);c.length>0&&v.push({id:"method",title:"Method",type:"method",data:c.map(([f,S])=>({id:`method::${f}`,label:f,count:S,color:nu(f),isActive:t.method?.includes(f)??false,value:f}))});let p=Object.entries(k);return p.length>0&&v.push({id:"contentType",title:"Content Type",type:"contentType",data:p.map(([f,S])=>{let D=e.find(V=>un(V).type===f),{color:H}=D?un(D):{color:Me.color.textTertiary};return{id:`contentType::${f}`,label:f,count:S,icon:ou(f),color:H,isActive:t.contentType?.includes(f)??false,value:f}})}),v},[k,e,t.contentType,t.method,t.status,C,h]),A=rt(()=>({sections:P,addFilterSection:{enabled:true,placeholder:"Enter domain or URL pattern...",title:"ACTIVE FILTERS",icon:Ui,renderExtra:R},availableItemsSection:{enabled:true,title:"AVAILABLE DOMAINS & URLS",emptyMessage:"No network events captured yet. Domains and URLs will appear here.",items:z},howItWorksSection:{enabled:true,title:"HOW NETWORK FILTERS WORK",description:"Patterns hide matching requests from the network event list. Each pattern has a match mode you can toggle on its badge: CONTAINS hides any URL containing the text; EXACT hides only an exact path/host/url match.",examples:["\u2022 example.com (CONTAINS) \u2192 any request whose URL contains example.com","\u2022 example.com (EXACT) \u2192 only requests served by that exact host","\u2022 /v1 (CONTAINS) \u2192 any URL containing /v1 (e.g. /v1, /v1/users)","\u2022 /v1 (EXACT) \u2192 only requests whose pathname is exactly /v1"],icon:Ui},onFilterChange:$,onPatternAdd:x,onPatternToggle:n,activePatterns:g,renderPatternMeta:y}),[g,P,$,x,n,R,y,z]);return ut(Jd,{...A})}var Ue=ve.create({modeBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:6,borderWidth:1},modeBadgeText:{fontSize:9,fontFamily:dn,fontWeight:"700",letterSpacing:.5},modeToggleRow:{flexDirection:"row",alignItems:"center",gap:8,marginBottom:8},modeToggleLabel:{fontSize:11,fontWeight:"600",color:Me.color.textSecondary,fontFamily:dn,letterSpacing:.3},modeToggleGroup:{flexDirection:"row",gap:6,flex:1},modeToggleButton:{flex:1,paddingVertical:6,paddingHorizontal:10,borderRadius:8,borderWidth:1,borderColor:Me.color.border,backgroundColor:Me.color.buttonSurface,alignItems:"center"},modeToggleButtonActive:{borderColor:Me.color.accentBorderStrong,backgroundColor:Me.color.accentSoft},modeToggleButtonText:{fontSize:11,fontWeight:"700",color:Me.color.textSecondary,fontFamily:dn,letterSpacing:.3},modeToggleButtonTextActive:{color:Me.color.accent},modeToggleButtonHint:{fontSize:9,color:Me.color.textTertiary,marginTop:1}});O();import{TickProvider as cn}from"@buoy-gg/shared-ui/web";import{useTick as su}from"@buoy-gg/shared-ui/web";function hn(){return su()??Date.now()}O();Se();import{useState as yr,useEffect as Ji,useMemo as au,memo as lu}from"react";import{Clock as pn,Upload as Gi,Download as Ki,AlertCircle as du,ChevronDown as Yi,ChevronUp as Zi,Lock as uu,Unlock as cu,FileJson as Kr,Filter as hu,Globe as pu,Link as fu,Copy as Qi,FlaskConical as yu,InlineCopyButton as es,macOSColors as Yr,night as q,useFeatureGate as gu,UpgradeModal as mu,monoFont as Yt}from"@buoy-gg/shared-ui/web";O();import{formatBytes as ct,formatDuration as Zr,formatHttpStatus as ts,getMethodColor as ty}from"@buoy-gg/shared-ui/web";import{formatRelativeTime as bu}from"@buoy-gg/shared-ui/web";import{DataViewer as gr}from"@buoy-gg/shared-ui/web/dataViewer";O();function fn(e,t=30){if(e==null)return null;if(typeof e=="boolean"||typeof e=="number")return String(e);if(typeof e=="string")return e.length>t?e.substring(0,t-1)+"\u2026":e;if(Array.isArray(e))return e.length===0?null:e.length===1?fn(e[0],t):`${e.length} items`;if(typeof e=="object"){let r=Object.entries(e);if(r.length===0)return null;for(let[o,n]of r){let i=fn(n,t);if(i)return i}return null}return null}function vu(e,t=3){if(!e||typeof e!="object")return null;let r=[];for(let[o,n]of Object.entries(e)){let i=fn(n);if(i&&r.push(i),r.length>=t)break}return r.length>0?r:null}function rs(e,t){let r=vu(t);return!r||r.length===0?e:[e,...r].join(" \u203A ")}function os(e,t){if(!e||typeof e!="object")return false;for(let r of Object.values(e))if(yn(r,t))return true;return false}function yn(e,t){return typeof e=="string"?e.toLowerCase().includes(t):typeof e=="number"||typeof e=="boolean"?String(e).includes(t):Array.isArray(e)?e.some(r=>yn(r,t)):typeof e=="object"&&e!==null?Object.values(e).some(r=>yn(r,t)):false}O();import{createContext as Su,useContext as wu}from"react";import{jsx as xu}from"react/jsx-runtime";var ns=Su(null);function Cu({resolver:e,children:t}){return xu(ns.Provider,{value:e,children:t})}function ku(){return wu(ns)}import{Fragment as gn,jsx as T,jsxs as Q}from"react/jsx-runtime";var Qr=q.color.accent,Tu=new Set,Ru=()=>{},Eu=({timings:e,total:t})=>{let r=Math.max(1,t),o=[{label:"Waiting (TTFB)",hint:"incl. queue, DNS, TLS",value:e.ttfb,color:Yr.semantic.warning},{label:"Content download",hint:void 0,value:e.download,color:Yr.semantic.success}];return T(m,{style:E.phaseList,children:o.map(n=>Q(m,{style:E.phaseRow,children:[Q(m,{style:E.phaseLabelGroup,children:[T(b,{style:E.phaseLabel,children:n.label}),n.hint?T(b,{style:E.phaseHint,children:n.hint}):null]}),T(m,{style:E.phaseTrack,children:T(m,{style:[E.phaseBar,{backgroundColor:n.color,width:`${Math.min(100,Math.max(1,n.value/r*100))}%`}]})}),T(b,{style:E.phaseValue,children:Zr(n.value)})]},n.label))})},is=()=>T(m,{style:E.bodyDeferred}),At=({title:e,icon:t,children:r,defaultOpen:o=false,count:n})=>{let[i,s]=yr(o);return Q(m,{style:E.collapsibleSection,children:[Q(F,{style:E.collapsibleHeader,onPress:()=>s(!i),testID:`buoy-network-section-${e.toLowerCase().replace(/\s+/g,"-")}`,accessibilityRole:"button",accessibilityLabel:e,children:[Q(m,{style:E.collapsibleTitle,children:[t,T(b,{style:E.collapsibleTitleText,children:e}),n!==void 0?T(b,{style:E.collapsibleCount,children:n}):null]}),i?T(Zi,{size:16,color:q.color.textSecondary}):T(Yi,{size:16,color:q.color.textSecondary})]}),i?T(m,{style:E.collapsibleContent,children:r}):null]})},Iu=({url:e,requestData:t,operationName:r,graphqlVariables:o,requestClient:n,isPro:i=false,onUpgradePress:s})=>{let l=g=>{try{let x=new URL(g),y=String(x.protocol||""),R=String(x.host||""),h=y==="https:",C=String(x.pathname||"");if(n==="graphql"&&r){let I=rs(r,o);C=`${C} (${I})`}else r&&(C=`${C} (${r})`);let k={},w=x.searchParams;return w&&typeof w.forEach=="function"&&w.forEach((I,z)=>{k[z]=I}),{protocol:y.replace(":",""),host:R,pathname:C,params:Object.keys(k).length>0?k:null,isSecure:h}}catch{return{protocol:"",host:e,pathname:"",params:null,isSecure:false}}},a=au(()=>l(e),[e,n,r,o]),[u,d]=yr(false);return Q(m,{style:E.urlBreakdown,children:[Q(m,{style:E.urlRow,children:[a.isSecure?T(uu,{size:12,color:Yr.semantic.success}):T(cu,{size:12,color:Yr.semantic.warning}),T(b,{style:E.urlDomain,children:a.host}),Q(b,{style:E.urlProtocol,children:["(",a.protocol.toUpperCase(),")"]}),i?T(es,{value:e,buttonStyle:E.copyButton}):T(F,{style:E.copyButton,onPress:s,activeOpacity:.7,children:T(Qi,{size:14,color:q.color.textSecondary})})]}),T(m,{style:E.urlPathRow,children:Q(b,{style:E.urlPath,numberOfLines:2,children:[a.pathname,a.params?Q(b,{style:E.urlQueryString,children:["?",new URLSearchParams(a.params).toString()]}):null]})}),a.params?Q(m,{style:E.queryParamsCollapsible,children:[Q(F,{style:E.queryParamsToggle,onPress:()=>d(!u),activeOpacity:.7,children:[T(b,{style:E.queryParamsToggleText,children:"Query Parameters"}),T(b,{style:E.collapsibleCount,children:Object.keys(a.params).length}),u?T(Zi,{size:14,color:q.color.textSecondary}):T(Yi,{size:14,color:q.color.textSecondary})]}),u?T(gr,{title:"",data:a.params,showTypeFilter:true,rawMode:true,initialExpanded:true}):null]}):null]})},ss=lu(function({event:e,ignoredPatterns:t=Tu,onTogglePattern:r=Ru,showBodies:o=true}){let n=e.status?ts(e.status):null,i=!e.status&&!e.error,{isPro:s}=gu(),[l,a]=yr(false);Ji(()=>{l&&s&&a(false)},[l,s]);let u=ku(),d=e.requestData===void 0&&(e.requestBodyOmitted===true||(e.requestSize??0)>0),g=e.responseData===void 0&&(e.responseBodyOmitted===true||(e.responseSize??0)>0),x=e.headersOmitted===true,[y,R]=yr(null),[h,C]=yr(false);Ji(()=>{if(R(null),!u||!d&&!g&&!x){C(false);return}let P=false;return C(true),u(e.id).then(A=>{P||R(A)}).catch(()=>{}).finally(()=>{P||C(false)}),()=>{P=true}},[e.id,u,d,g,x]);let k=e.requestData??y?.requestData??void 0,w=e.responseData??y?.responseData??void 0,I=(x?y?.requestHeaders:void 0)??e.requestHeaders,z=(x?y?.responseHeaders:void 0)??e.responseHeaders,$=()=>{let P={method:e.method,url:e.url,status:e.status,statusText:e.statusText,timestamp:new Date(e.timestamp).toISOString(),duration:e.duration?`${e.duration}ms`:"N/A",requestHeaders:I,requestData:k,responseHeaders:z,responseData:w,requestSize:e.requestSize?ct(e.requestSize):"N/A",responseSize:e.responseSize?ct(e.responseSize):"N/A",error:e.error,client:e.requestClient};return`# Network Request Details
10
10
 
11
11
  ## Request
12
- - **Method:** ${S.method}
13
- - **URL:** ${S.url}
14
- - **Client:** ${S.client||"N/A"}
15
- - **Timestamp:** ${S.timestamp}
12
+ - **Method:** ${P.method}
13
+ - **URL:** ${P.url}
14
+ - **Client:** ${P.client||"N/A"}
15
+ - **Timestamp:** ${P.timestamp}
16
16
 
17
17
  ## Response
18
- - **Status:** ${S.status||"Pending"}${S.statusText?` (${S.statusText})`:""}
19
- - **Duration:** ${S.duration}
20
- - **Request Size:** ${S.requestSize}
21
- - **Response Size:** ${S.responseSize}
22
- ${S.error?`- **Error:** ${S.error}`:""}
18
+ - **Status:** ${P.status||"Pending"}${P.statusText?` (${P.statusText})`:""}
19
+ - **Duration:** ${P.duration}
20
+ - **Request Size:** ${P.requestSize}
21
+ - **Response Size:** ${P.responseSize}
22
+ ${P.error?`- **Error:** ${P.error}`:""}
23
23
 
24
24
  ## Request Headers
25
25
  \`\`\`json
26
- ${JSON.stringify(S.requestHeaders,null,2)}
26
+ ${JSON.stringify(P.requestHeaders,null,2)}
27
27
  \`\`\`
28
28
 
29
29
  ## Request Data
30
30
  \`\`\`json
31
- ${JSON.stringify(S.requestData,null,2)}
31
+ ${JSON.stringify(P.requestData,null,2)}
32
32
  \`\`\`
33
33
 
34
34
  ## Response Headers
35
35
  \`\`\`json
36
- ${JSON.stringify(S.responseHeaders,null,2)}
36
+ ${JSON.stringify(P.responseHeaders,null,2)}
37
37
  \`\`\`
38
38
 
39
39
  ## Response Data
40
40
  \`\`\`json
41
- ${JSON.stringify(S.responseData,null,2)}
41
+ ${JSON.stringify(P.responseData,null,2)}
42
42
  \`\`\`
43
- `};return J(Ho,{children:[J(ht,{testID:"buoy-network-detail-scroll",style:R.container,children:[J(f,{style:R.requestDetailsSection,children:[J(f,{style:R.httpHeader,children:[C(f,{style:R.httpMethodBadge,children:C(b,{style:R.httpMethod,children:e.method})}),e.status?C(f,{style:[R.httpStatusBadge,{backgroundColor:`${n?.color}20`}],children:J(b,{style:[R.httpStatusText,{color:n?.color}],children:[n?.text," ",n?.meaning]})}):i?J(f,{style:R.pendingBadge,children:[C(Do,{size:10,color:B.color.warning}),C(b,{style:R.pendingBadgeText,children:"Pending"})]}):null,e.condition&&J(b,{style:{color:"#FFCC66"},children:["Conditions: ",e.condition.profile," (+",e.condition.delayMs," ms)"]}),e.duration?J(f,{style:R.httpDuration,children:[C(Do,{size:10,color:B.color.textTertiary}),C(b,{style:R.httpDurationText,children:Lr(e.duration)})]}):null,e.override?J(f,{style:R.overrideBadge,children:[C(Id,{size:10,color:B.color.warning}),C(b,{style:R.overrideBadgeText,children:e.override.ruleName||"Overridden"})]}):null,s?C(vi,{value:H,buttonStyle:R.copyFullButton}):C(N,{style:R.copyFullButton,onPress:()=>a(true),activeOpacity:.7,children:C(bi,{size:14,color:B.color.textSecondary})})]}),C(jd,{url:e.url,requestData:E,operationName:e.operationName,graphqlVariables:e.graphqlVariables,requestClient:e.requestClient,isPro:s,onUpgradePress:()=>a(true)}),e.error?J(f,{style:R.errorBox,children:[C(wd,{size:12,color:B.color.danger}),C(b,{style:R.errorText,children:e.error})]}):null]}),J(f,{style:R.timingSection,children:[J(f,{style:R.timingRow,children:[C(Do,{size:12,color:B.color.textSecondary}),C(b,{style:R.timingLabel,children:"Started:"}),C(b,{style:R.timingValue,children:Ld(e.timestamp)}),J(b,{style:R.timingExact,children:["(",new Date(e.timestamp).toLocaleTimeString(),")"]}),e.requestSize||e.responseSize?J(f,{style:R.sizeRow,children:[e.requestSize!==void 0?J(f,{style:R.sizeItem,children:[C(fi,{size:10,color:B.color.info}),C(b,{style:R.sizeLabel,children:"Sent:"}),C(b,{style:R.sizeValue,children:Ye(e.requestSize)})]}):null,e.responseSize!==void 0?J(f,{style:R.sizeItem,children:[C(gi,{size:10,color:qr}),C(b,{style:R.sizeLabel,children:"Received:"}),C(b,{style:R.sizeValue,children:Ye(e.responseSize)})]}):null]}):null]}),e.timings?J(Ho,{children:[C(f,{style:R.phaseDivider}),C($d,{timings:e.timings,total:e.duration??e.timings.ttfb+e.timings.download})]}):null]}),C(xt,{title:"Request Headers",icon:C(fi,{size:14,color:B.color.info}),defaultOpen:false,count:Object.keys(I).length,children:Object.keys(I).length>0?C(f,{style:R.dataViewerContainer,children:C(nr,{title:"",data:I,showTypeFilter:true,rawMode:true,initialExpanded:true,disableCopy:!s})}):C(b,{style:R.emptyText,children:"No request headers"})}),C(xt,{title:"Response Headers",icon:C(gi,{size:14,color:qr}),defaultOpen:false,count:Object.keys(D).length,children:Object.keys(D).length>0?C(f,{style:R.dataViewerContainer,children:C(nr,{title:"",data:D,showTypeFilter:true,rawMode:true,initialExpanded:true,disableCopy:!s})}):C(b,{style:R.emptyText,children:"No response headers yet"})}),E!==void 0?C(xt,{title:"Request Body",icon:C(Pr,{size:14,color:B.color.accent}),defaultOpen:false,children:C(f,{style:R.dataViewerContainer,children:o?C(nr,{title:"",data:E,showTypeFilter:true,rawMode:true,initialExpanded:true,disableCopy:!s}):C(Ci,{})})}):u?C(xt,{title:"Request Body",icon:C(Pr,{size:14,color:B.color.accent}),defaultOpen:true,children:C(b,{style:R.emptyText,children:m?`Loading request body (${Ye(e.requestSize??0)})\u2026`:"Request body unavailable"})}):null,g!==void 0?C(xt,{title:"Response Body",icon:C(Pr,{size:14,color:qr}),defaultOpen:true,children:C(f,{style:R.dataViewerContainer,children:o?C(nr,{title:"",data:g,showTypeFilter:true,rawMode:true,initialExpanded:true,disableCopy:!s}):C(Ci,{})})}):v?C(xt,{title:"Response Body",icon:C(Pr,{size:14,color:qr}),defaultOpen:true,children:C(b,{style:R.emptyText,children:m?`Loading response body (${Ye(e.responseSize??0)})\u2026`:"Response body unavailable"})}):null,C(xt,{title:"Filter Options",icon:C(kd,{size:14,color:B.color.warning}),defaultOpen:false,children:C(f,{style:R.filterOptionsContainer,children:(()=>{let S="",z="";try{let h=new URL(e.url);S=h.hostname,z=h.pathname}catch{z=e.url}let w=t.has(S),p=t.has(z);return J(Ho,{children:[J(N,{style:[R.filterOption,w&&R.filterOptionActive],onPress:()=>S&&r(S),children:[J(f,{style:R.filterOptionLeft,children:[C(Rd,{size:16,color:w?B.color.warning:B.color.textTertiary}),J(f,{style:R.filterOptionContent,children:[C(b,{style:R.filterOptionLabel,children:"Ignore Domain"}),C(b,{style:R.filterOptionValue,children:S||"N/A"})]})]}),C(f,{style:[R.filterToggle,w&&R.filterToggleActive],children:C(b,{style:[R.filterToggleText,w&&R.filterToggleTextActive],children:w?"IGNORED":"IGNORE"})})]}),J(N,{style:[R.filterOption,p&&R.filterOptionActive],onPress:()=>z&&r(z),children:[J(f,{style:R.filterOptionLeft,children:[C(Ed,{size:16,color:p?B.color.warning:B.color.textTertiary}),J(f,{style:R.filterOptionContent,children:[C(b,{style:R.filterOptionLabel,children:"Ignore URL Pattern"}),C(b,{style:R.filterOptionValue,numberOfLines:1,children:z||"N/A"})]})]}),C(f,{style:[R.filterToggle,p&&R.filterToggleActive],children:C(b,{style:[R.filterToggleText,p&&R.filterToggleTextActive],children:p?"IGNORED":"IGNORE"})})]}),C(f,{style:R.filterInfoBox,children:C(b,{style:R.filterInfoText,children:"Ignored requests will be hidden from the network list. You can manage filters in the Filters tab."})})]})})()})})]}),C(Bd,{visible:l,onClose:()=>a(false),featureName:"Copy Request Details",description:"Copy network request details to share or debug issues.",benefits:["Copy full request details including headers and body","Export to JSON, Markdown, or plain text","Share request data with teammates","Feed data to AI assistants for debugging"]})]})}),R=he.create({container:{flex:1,backgroundColor:"transparent"},requestDetailsSection:{marginHorizontal:12,marginTop:12,backgroundColor:B.color.surface,borderRadius:8,borderWidth:1,borderColor:B.color.border,padding:12},httpHeader:{flexDirection:"row",alignItems:"center",gap:8,marginBottom:12,flexWrap:"nowrap"},httpMethodBadge:{backgroundColor:B.color.infoSoft,paddingHorizontal:8,paddingVertical:4,borderRadius:4},httpMethod:{color:B.color.info,fontSize:11,fontWeight:"700",letterSpacing:.5},httpStatusBadge:{paddingHorizontal:8,paddingVertical:4,borderRadius:4},httpStatusText:{fontSize:11,fontWeight:"600"},pendingBadge:{flexDirection:"row",alignItems:"center",gap:4,backgroundColor:B.color.warningSoft,paddingHorizontal:8,paddingVertical:4,borderRadius:4},pendingBadgeText:{color:B.color.warning,fontSize:11,fontWeight:"600"},httpDuration:{flexDirection:"row",alignItems:"center",gap:4},httpDurationText:{color:B.color.textSecondary,fontSize:11},overrideBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:6,paddingVertical:3,borderRadius:4,backgroundColor:B.color.warningSoft},overrideBadgeText:{color:B.color.warning,fontSize:10,fontWeight:"700"},copyFullButton:{marginLeft:"auto",flexShrink:0,padding:4},urlBreakdown:{backgroundColor:B.color.bg,borderRadius:4,padding:8},urlRow:{flexDirection:"row",alignItems:"center",gap:6,marginBottom:4},urlDomain:{color:B.color.text,fontSize:12,fontWeight:"600",flex:1},urlProtocol:{color:B.color.textTertiary,fontSize:10},copyButton:{padding:4},urlPathRow:{paddingLeft:18},urlPath:{color:B.color.textSecondary,fontSize:11,fontFamily:Ht},urlQueryString:{color:B.color.info,fontSize:11,fontFamily:Ht},queryParamsCollapsible:{marginTop:8},queryParamsToggle:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:10,backgroundColor:B.color.surfaceElevated,borderRadius:8,borderWidth:1,borderColor:B.color.border,marginBottom:8},queryParamsToggleText:{flexGrow:0,color:B.color.text,fontSize:12,fontWeight:"600",letterSpacing:.3},timingSection:{marginHorizontal:12,marginTop:8,backgroundColor:B.color.surface,borderRadius:8,borderWidth:1,borderColor:B.color.border,padding:12},timingRow:{flexDirection:"row",alignItems:"center",gap:6,flexWrap:"wrap"},timingLabel:{color:B.color.textSecondary,fontSize:11},timingValue:{color:B.color.text,fontSize:11,fontWeight:"600"},timingExact:{color:B.color.textTertiary,fontSize:10,marginLeft:4},sizeRow:{flexDirection:"row",alignItems:"center",gap:16,marginLeft:"auto"},sizeItem:{flexDirection:"row",alignItems:"center",gap:4},sizeLabel:{color:B.color.textTertiary,fontSize:10},sizeValue:{color:B.color.info,fontSize:10,fontFamily:Ht,fontWeight:"600"},phaseDivider:{height:1,backgroundColor:B.color.border,marginTop:12,marginBottom:12},phaseList:{gap:8},phaseRow:{flexDirection:"row",alignItems:"center",gap:14},phaseLabelGroup:{width:150},phaseLabel:{fontSize:12,color:B.color.textSecondary},phaseHint:{fontSize:10,color:B.color.textTertiary},phaseTrack:{flex:1,height:7,borderRadius:4,backgroundColor:B.color.surfaceElevated,justifyContent:"center",overflow:"hidden"},phaseBar:{height:7,borderRadius:4},phaseValue:{width:72,textAlign:"right",fontSize:12,fontFamily:Ht,color:B.color.text},collapsibleSection:{marginHorizontal:12,marginTop:8,backgroundColor:B.color.surface,borderRadius:8,borderWidth:1,borderColor:B.color.border,overflow:"hidden"},collapsibleHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:12,backgroundColor:B.color.surfaceElevated},collapsibleTitle:{flexDirection:"row",alignItems:"center",gap:8},collapsibleTitleText:{color:B.color.text,fontSize:13,fontWeight:"600"},collapsibleCount:{color:B.color.textTertiary,fontSize:11.5,fontFamily:Ht},collapsibleContent:{padding:12},dataViewerContainer:{marginTop:-12,marginHorizontal:-12,marginBottom:-12},bodyDeferred:{height:120},errorBox:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:B.color.dangerSoft,padding:8,borderRadius:4,marginTop:8},errorText:{color:B.color.danger,fontSize:11,flex:1},emptyText:{color:B.color.textTertiary,fontSize:12,fontStyle:"italic",textAlign:"center"},filterOptionsContainer:{gap:12},filterOption:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",backgroundColor:B.color.surfaceElevated,borderRadius:8,padding:12,borderWidth:1,borderColor:B.color.border},filterOptionActive:{backgroundColor:B.color.warningSoft,borderColor:B.color.warning+"33"},filterOptionLeft:{flexDirection:"row",alignItems:"center",gap:12,flex:1},filterOptionContent:{flex:1},filterOptionLabel:{color:B.color.textSecondary,fontSize:11,marginBottom:2,textTransform:"uppercase",letterSpacing:.5},filterOptionValue:{color:B.color.text,fontSize:13,fontFamily:Ht},filterToggle:{paddingHorizontal:10,paddingVertical:6,borderRadius:4,backgroundColor:B.color.bg,borderWidth:1,borderColor:B.color.border},filterToggleActive:{backgroundColor:B.color.warningSoft,borderColor:B.color.warning+"4D"},filterToggleText:{fontSize:10,fontWeight:"600",color:B.color.textTertiary,letterSpacing:.5},filterToggleTextActive:{color:B.color.warning},filterInfoBox:{backgroundColor:B.color.infoSoft,borderRadius:6,padding:10,borderWidth:1,borderColor:B.color.info+"33"},filterInfoText:{color:B.color.textSecondary,fontSize:11,lineHeight:16}});q();pe();import{DynamicFilterView as Ri,macOSColors as je,FileText as Ei,FileCode as Ii,Link as Fd,Zap as Wd,Settings as Vd,Hash as Ud,Eye as _d,ToolbarCopyButton as Xd,formatRelativeTime as Jd,useFeatureGate as Gd,ProFeatureBanner as Kd,ExportPreview as Qd,monoFont as Pi}from"@buoy-gg/shared-ui/web";import{DataViewer as Zd}from"@buoy-gg/shared-ui/web/dataViewer";import{useCallback as Ve,useMemo as wt,useState as Yd}from"react";import{Fragment as eu,jsx as Me,jsxs as Bi}from"react/jsx-runtime";var tu={includeMethod:true,includeStatus:true,includeDuration:true,includeTimestamp:true,includeClient:true,includeSizes:true,includeErrors:true,includeRequestHeaders:true,includeResponseHeaders:true,includeRequestBody:true,includeResponseBody:true,bodySizeThreshold:10,format:"markdown",filterMode:"all"},ir={urls:{includeMethod:true,includeStatus:false,includeDuration:false,includeTimestamp:false,includeClient:false,includeSizes:false,includeErrors:false,includeRequestHeaders:false,includeResponseHeaders:false,includeRequestBody:false,includeResponseBody:false,bodySizeThreshold:10,format:"plaintext",filterMode:"all"},llm:{includeMethod:true,includeStatus:true,includeDuration:true,includeTimestamp:true,includeClient:true,includeSizes:true,includeErrors:true,includeRequestHeaders:true,includeResponseHeaders:true,includeRequestBody:true,includeResponseBody:true,bodySizeThreshold:10,format:"markdown",filterMode:"all"},json:{includeMethod:true,includeStatus:true,includeDuration:true,includeTimestamp:true,includeClient:true,includeSizes:true,includeErrors:true,includeRequestHeaders:true,includeResponseHeaders:true,includeRequestBody:true,includeResponseBody:true,bodySizeThreshold:-1,format:"json",filterMode:"all"},full:{includeMethod:true,includeStatus:true,includeDuration:true,includeTimestamp:true,includeClient:true,includeSizes:true,includeErrors:true,includeRequestHeaders:true,includeResponseHeaders:true,includeRequestBody:true,includeResponseBody:true,bodySizeThreshold:-1,format:"markdown",filterMode:"all"}};function ru(e){for(let[t,r]of Object.entries(ir))if(Object.keys(r).every(o=>r[o]===e[o]))return t;return null}var ou=100*1024,nu=500*1024;function iu(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function su({settings:e,onSettingsChange:t,events:r=[]}){let{isPro:o}=Gd(),n=Oo(),[i,s]=Yd(false),l=r.length>0,a=wt(()=>{if(!l)return null;let p=r.map(h=>typeof h.timestamp=="number"?h.timestamp:new Date(h.timestamp).getTime());return Math.max(...p)},[r,l]),d=wt(()=>ru(e),[e]),u=Ve(()=>{t(ir.urls)},[t]),v=Ve(()=>{t(ir.llm)},[t]),T=Ve(()=>{t(ir.json)},[t]),x=Ve(()=>{t(ir.full)},[t]),L=Ve((p,h)=>{let[c,y]=p.split("::");if(c==="preset"){switch(y){case"urls":u();break;case"llm":v();break;case"json":T();break;case"full":x();break}return}if(c==="requestInfo"){t({...e,[y]:!e[y]});return}if(c==="headers"){t({...e,[y]:!e[y]});return}if(c==="body"){t(y==="bodySizeThreshold"?{...e,bodySizeThreshold:h}:{...e,[y]:!e[y]});return}if(c==="format"){t({...e,format:h});return}c==="filter"&&t({...e,filterMode:h})},[e,t,u,v,T,x]),m=wt(()=>({method:"POST",url:"https://api.example.com/v1/users",status:201,duration:342,timestamp:new Date().toISOString(),requestHeaders:{"Content-Type":"application/json",Authorization:"Bearer ***"},responseHeaders:{"Content-Type":"application/json","X-Request-ID":"abc123"},requestBody:{name:"John Doe",email:"john@example.com"},responseBody:{id:"user_123",name:"John Doe",email:"john@example.com",createdAt:"2025-01-10T12:00:00Z"}}),[]),k=wt(()=>l?r:[m],[l,r,m]),E=wt(()=>{let p=l?r:[m],h=0;for(let c of p){if(e.includeMethod&&(h+=(c.url?.length||0)+10),e.includeStatus&&(h+=30),e.includeTimestamp&&(h+=30),e.includeRequestHeaders)try{h+=JSON.stringify(c.requestHeaders||{}).length}catch{h+=100}if(e.includeRequestBody){let y="requestBody"in c?c.requestBody:c.requestData;try{h+=JSON.stringify(y||{}).length}catch{h+=100}}if(e.includeResponseBody){let y="responseBody"in c?c.responseBody:c.responseData;try{h+=JSON.stringify(y||{}).length}catch{h+=100}}}return h},[l,r,m,e]),g=wt(()=>E>=nu?"danger":E>=ou?"warning":"none",[E]),I=Ve(()=>{let p=l?r:[m],{format:h,includeMethod:c,includeStatus:y,includeTimestamp:O,includeRequestHeaders:re,includeRequestBody:ne,includeResponseBody:ee}=e,X=A=>{let W={};return c&&(W.method=A.method,W.url=A.url),y&&(W.status=A.status,W.duration=A.duration),O&&(W.timestamp=A.timestamp),re&&(W.requestHeaders=A.requestHeaders),ne&&(W.requestBody="requestBody"in A?A.requestBody:A.requestData),ee&&(W.responseBody="responseBody"in A?A.responseBody:A.responseData),W};if(h==="json"){let A=p.map(X);return JSON.stringify(A,null,2)}return h==="markdown"?p.map((A,W)=>{let $=[];$.push(`# Request ${W+1}`),c&&$.push(`
44
- **${A.method}** ${A.url}`);let oe=[];if(y&&(oe.push(`**Status:** ${A.status}`),oe.push(`**Duration:** ${A.duration}ms`)),O&&oe.push(`**Timestamp:** ${A.timestamp}`),oe.length>0&&$.push(`
45
- `+oe.join(`
46
- `)),re){let ge=A.requestHeaders||{};$.push(`
43
+ `};return Q(gn,{children:[Q(yt,{keyboardShouldPersistTaps:"handled",testID:"buoy-network-detail-scroll",style:E.container,children:[Q(m,{style:E.requestDetailsSection,children:[Q(m,{style:E.httpHeader,children:[T(m,{style:E.httpMethodBadge,children:T(b,{style:E.httpMethod,children:e.method})}),e.status?T(m,{style:[E.httpStatusBadge,{backgroundColor:`${n?.color}20`}],children:Q(b,{style:[E.httpStatusText,{color:n?.color}],children:[n?.text," ",n?.meaning]})}):i?Q(m,{style:E.pendingBadge,children:[T(pn,{size:10,color:q.color.warning}),T(b,{style:E.pendingBadgeText,children:"Pending"})]}):null,e.condition&&Q(b,{style:{color:"#FFCC66"},children:["Conditions: ",e.condition.profile," (+",e.condition.delayMs," ms)"]}),e.condition?.uploadCap?.note&&T(b,{testID:"buoy-network-upload-cap-detail",style:{color:"#FFCC66"},children:e.condition.uploadCap.note}),e.duration?Q(m,{style:E.httpDuration,children:[T(pn,{size:10,color:q.color.textTertiary}),T(b,{style:E.httpDurationText,children:Zr(e.duration)})]}):null,e.override?Q(m,{style:E.overrideBadge,children:[T(yu,{size:10,color:q.color.warning}),T(b,{style:E.overrideBadgeText,children:e.override.ruleName||"Overridden"})]}):null,s?T(es,{value:$,buttonStyle:E.copyFullButton}):T(F,{style:E.copyFullButton,onPress:()=>a(true),activeOpacity:.7,children:T(Qi,{size:14,color:q.color.textSecondary})})]}),T(Iu,{url:e.url,requestData:k,operationName:e.operationName,graphqlVariables:e.graphqlVariables,requestClient:e.requestClient,isPro:s,onUpgradePress:()=>a(true)}),e.error?Q(m,{style:E.errorBox,children:[T(du,{size:12,color:q.color.danger}),T(b,{style:E.errorText,children:e.error})]}):null]}),Q(m,{style:E.timingSection,children:[Q(m,{style:E.timingRow,children:[T(pn,{size:12,color:q.color.textSecondary}),T(b,{style:E.timingLabel,children:"Started:"}),T(b,{style:E.timingValue,children:bu(e.timestamp)}),Q(b,{style:E.timingExact,children:["(",new Date(e.timestamp).toLocaleTimeString(),")"]}),e.requestSize||e.responseSize?Q(m,{style:E.sizeRow,children:[e.requestSize!==void 0?Q(m,{style:E.sizeItem,children:[T(Gi,{size:10,color:q.color.info}),T(b,{style:E.sizeLabel,children:"Sent:"}),T(b,{style:E.sizeValue,children:ct(e.requestSize)})]}):null,e.responseSize!==void 0?Q(m,{style:E.sizeItem,children:[T(Ki,{size:10,color:Qr}),T(b,{style:E.sizeLabel,children:"Received:"}),T(b,{style:E.sizeValue,children:ct(e.responseSize)})]}):null]}):null]}),e.timings?Q(gn,{children:[T(m,{style:E.phaseDivider}),T(Eu,{timings:e.timings,total:e.duration??e.timings.ttfb+e.timings.download})]}):null]}),T(At,{title:"Request Headers",icon:T(Gi,{size:14,color:q.color.info}),defaultOpen:false,count:Object.keys(I).length,children:Object.keys(I).length>0?T(m,{style:E.dataViewerContainer,children:T(gr,{title:"",data:I,showTypeFilter:true,rawMode:true,initialExpanded:true,disableCopy:!s})}):T(b,{style:E.emptyText,children:"No request headers"})}),T(At,{title:"Response Headers",icon:T(Ki,{size:14,color:Qr}),defaultOpen:false,count:Object.keys(z).length,children:Object.keys(z).length>0?T(m,{style:E.dataViewerContainer,children:T(gr,{title:"",data:z,showTypeFilter:true,rawMode:true,initialExpanded:true,disableCopy:!s})}):T(b,{style:E.emptyText,children:"No response headers yet"})}),k!==void 0?T(At,{title:"Request Body",icon:T(Kr,{size:14,color:q.color.accent}),defaultOpen:false,children:T(m,{style:E.dataViewerContainer,children:o?T(gr,{title:"",data:k,showTypeFilter:true,rawMode:true,initialExpanded:true,disableCopy:!s}):T(is,{})})}):d?T(At,{title:"Request Body",icon:T(Kr,{size:14,color:q.color.accent}),defaultOpen:true,children:T(b,{style:E.emptyText,children:h?`Loading request body (${ct(e.requestSize??0)})\u2026`:"Request body unavailable"})}):null,w!==void 0?T(At,{title:"Response Body",icon:T(Kr,{size:14,color:Qr}),defaultOpen:true,children:T(m,{style:E.dataViewerContainer,children:o?T(gr,{title:"",data:w,showTypeFilter:true,rawMode:true,initialExpanded:true,disableCopy:!s}):T(is,{})})}):g?T(At,{title:"Response Body",icon:T(Kr,{size:14,color:Qr}),defaultOpen:true,children:T(b,{style:E.emptyText,children:h?`Loading response body (${ct(e.responseSize??0)})\u2026`:"Response body unavailable"})}):null,T(At,{title:"Filter Options",icon:T(hu,{size:14,color:q.color.warning}),defaultOpen:false,children:T(m,{style:E.filterOptionsContainer,children:(()=>{let P="",A="";try{let p=new URL(e.url);P=p.hostname,A=p.pathname}catch{A=e.url}let v=t.has(P),c=t.has(A);return Q(gn,{children:[Q(F,{style:[E.filterOption,v&&E.filterOptionActive],onPress:()=>P&&r(P),children:[Q(m,{style:E.filterOptionLeft,children:[T(pu,{size:16,color:v?q.color.warning:q.color.textTertiary}),Q(m,{style:E.filterOptionContent,children:[T(b,{style:E.filterOptionLabel,children:"Ignore Domain"}),T(b,{style:E.filterOptionValue,children:P||"N/A"})]})]}),T(m,{style:[E.filterToggle,v&&E.filterToggleActive],children:T(b,{style:[E.filterToggleText,v&&E.filterToggleTextActive],children:v?"IGNORED":"IGNORE"})})]}),Q(F,{style:[E.filterOption,c&&E.filterOptionActive],onPress:()=>A&&r(A),children:[Q(m,{style:E.filterOptionLeft,children:[T(fu,{size:16,color:c?q.color.warning:q.color.textTertiary}),Q(m,{style:E.filterOptionContent,children:[T(b,{style:E.filterOptionLabel,children:"Ignore URL Pattern"}),T(b,{style:E.filterOptionValue,numberOfLines:1,children:A||"N/A"})]})]}),T(m,{style:[E.filterToggle,c&&E.filterToggleActive],children:T(b,{style:[E.filterToggleText,c&&E.filterToggleTextActive],children:c?"IGNORED":"IGNORE"})})]}),T(m,{style:E.filterInfoBox,children:T(b,{style:E.filterInfoText,children:"Ignored requests will be hidden from the network list. You can manage filters in the Filters tab."})})]})})()})})]}),T(mu,{visible:l,onClose:()=>a(false),featureName:"Copy Request Details",description:"Copy network request details to share or debug issues.",benefits:["Copy full request details including headers and body","Export to JSON, Markdown, or plain text","Share request data with teammates","Feed data to AI assistants for debugging"]})]})}),E=ve.create({container:{flex:1,backgroundColor:"transparent"},requestDetailsSection:{marginHorizontal:12,marginTop:12,backgroundColor:q.color.surface,borderRadius:8,borderWidth:1,borderColor:q.color.border,padding:12},httpHeader:{flexDirection:"row",alignItems:"center",gap:8,marginBottom:12,flexWrap:"nowrap"},httpMethodBadge:{backgroundColor:q.color.infoSoft,paddingHorizontal:8,paddingVertical:4,borderRadius:4},httpMethod:{color:q.color.info,fontSize:11,fontWeight:"700",letterSpacing:.5},httpStatusBadge:{paddingHorizontal:8,paddingVertical:4,borderRadius:4},httpStatusText:{fontSize:11,fontWeight:"600"},pendingBadge:{flexDirection:"row",alignItems:"center",gap:4,backgroundColor:q.color.warningSoft,paddingHorizontal:8,paddingVertical:4,borderRadius:4},pendingBadgeText:{color:q.color.warning,fontSize:11,fontWeight:"600"},httpDuration:{flexDirection:"row",alignItems:"center",gap:4},httpDurationText:{color:q.color.textSecondary,fontSize:11},overrideBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:6,paddingVertical:3,borderRadius:4,backgroundColor:q.color.warningSoft},overrideBadgeText:{color:q.color.warning,fontSize:10,fontWeight:"700"},copyFullButton:{marginLeft:"auto",flexShrink:0,padding:4},urlBreakdown:{backgroundColor:q.color.bg,borderRadius:4,padding:8},urlRow:{flexDirection:"row",alignItems:"center",gap:6,marginBottom:4},urlDomain:{color:q.color.text,fontSize:12,fontWeight:"600",flex:1},urlProtocol:{color:q.color.textTertiary,fontSize:10},copyButton:{padding:4},urlPathRow:{paddingLeft:18},urlPath:{color:q.color.textSecondary,fontSize:11,fontFamily:Yt},urlQueryString:{color:q.color.info,fontSize:11,fontFamily:Yt},queryParamsCollapsible:{marginTop:8},queryParamsToggle:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:10,backgroundColor:q.color.surfaceElevated,borderRadius:8,borderWidth:1,borderColor:q.color.border,marginBottom:8},queryParamsToggleText:{flexGrow:0,color:q.color.text,fontSize:12,fontWeight:"600",letterSpacing:.3},timingSection:{marginHorizontal:12,marginTop:8,backgroundColor:q.color.surface,borderRadius:8,borderWidth:1,borderColor:q.color.border,padding:12},timingRow:{flexDirection:"row",alignItems:"center",gap:6,flexWrap:"wrap"},timingLabel:{color:q.color.textSecondary,fontSize:11},timingValue:{color:q.color.text,fontSize:11,fontWeight:"600"},timingExact:{color:q.color.textTertiary,fontSize:10,marginLeft:4},sizeRow:{flexDirection:"row",alignItems:"center",gap:16,marginLeft:"auto"},sizeItem:{flexDirection:"row",alignItems:"center",gap:4},sizeLabel:{color:q.color.textTertiary,fontSize:10},sizeValue:{color:q.color.info,fontSize:10,fontFamily:Yt,fontWeight:"600"},phaseDivider:{height:1,backgroundColor:q.color.border,marginTop:12,marginBottom:12},phaseList:{gap:8},phaseRow:{flexDirection:"row",alignItems:"center",gap:14},phaseLabelGroup:{width:150},phaseLabel:{fontSize:12,color:q.color.textSecondary},phaseHint:{fontSize:10,color:q.color.textTertiary},phaseTrack:{flex:1,height:7,borderRadius:4,backgroundColor:q.color.surfaceElevated,justifyContent:"center",overflow:"hidden"},phaseBar:{height:7,borderRadius:4},phaseValue:{width:72,textAlign:"right",fontSize:12,fontFamily:Yt,color:q.color.text},collapsibleSection:{marginHorizontal:12,marginTop:8,backgroundColor:q.color.surface,borderRadius:8,borderWidth:1,borderColor:q.color.border,overflow:"hidden"},collapsibleHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:12,backgroundColor:q.color.surfaceElevated},collapsibleTitle:{flexDirection:"row",alignItems:"center",gap:8},collapsibleTitleText:{color:q.color.text,fontSize:13,fontWeight:"600"},collapsibleCount:{color:q.color.textTertiary,fontSize:11.5,fontFamily:Yt},collapsibleContent:{padding:12},dataViewerContainer:{marginTop:-12,marginHorizontal:-12,marginBottom:-12},bodyDeferred:{height:120},errorBox:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:q.color.dangerSoft,padding:8,borderRadius:4,marginTop:8},errorText:{color:q.color.danger,fontSize:11,flex:1},emptyText:{color:q.color.textTertiary,fontSize:12,fontStyle:"italic",textAlign:"center"},filterOptionsContainer:{gap:12},filterOption:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",backgroundColor:q.color.surfaceElevated,borderRadius:8,padding:12,borderWidth:1,borderColor:q.color.border},filterOptionActive:{backgroundColor:q.color.warningSoft,borderColor:q.color.warning+"33"},filterOptionLeft:{flexDirection:"row",alignItems:"center",gap:12,flex:1},filterOptionContent:{flex:1},filterOptionLabel:{color:q.color.textSecondary,fontSize:11,marginBottom:2,textTransform:"uppercase",letterSpacing:.5},filterOptionValue:{color:q.color.text,fontSize:13,fontFamily:Yt},filterToggle:{paddingHorizontal:10,paddingVertical:6,borderRadius:4,backgroundColor:q.color.bg,borderWidth:1,borderColor:q.color.border},filterToggleActive:{backgroundColor:q.color.warningSoft,borderColor:q.color.warning+"4D"},filterToggleText:{fontSize:10,fontWeight:"600",color:q.color.textTertiary,letterSpacing:.5},filterToggleTextActive:{color:q.color.warning},filterInfoBox:{backgroundColor:q.color.infoSoft,borderRadius:6,padding:10,borderWidth:1,borderColor:q.color.info+"33"},filterInfoText:{color:q.color.textSecondary,fontSize:11,lineHeight:16}});O();Se();import{DynamicFilterView as as,macOSColors as Ge,FileText as ls,FileCode as ds,Link as Pu,Zap as Lu,Settings as Bu,Hash as qu,Eye as Ou,ToolbarCopyButton as zu,formatRelativeTime as Du,useFeatureGate as Au,ProFeatureBanner as Hu,ExportPreview as Mu,monoFont as us}from"@buoy-gg/shared-ui/web";import{DataViewer as Nu}from"@buoy-gg/shared-ui/web/dataViewer";import{useCallback as ot,useMemo as Ht,useState as $u}from"react";import{Fragment as Fu,jsx as _e,jsxs as cs}from"react/jsx-runtime";var ju={includeMethod:true,includeStatus:true,includeDuration:true,includeTimestamp:true,includeClient:true,includeSizes:true,includeErrors:true,includeRequestHeaders:true,includeResponseHeaders:true,includeRequestBody:true,includeResponseBody:true,bodySizeThreshold:10,format:"markdown",filterMode:"all"},mr={urls:{includeMethod:true,includeStatus:false,includeDuration:false,includeTimestamp:false,includeClient:false,includeSizes:false,includeErrors:false,includeRequestHeaders:false,includeResponseHeaders:false,includeRequestBody:false,includeResponseBody:false,bodySizeThreshold:10,format:"plaintext",filterMode:"all"},llm:{includeMethod:true,includeStatus:true,includeDuration:true,includeTimestamp:true,includeClient:true,includeSizes:true,includeErrors:true,includeRequestHeaders:true,includeResponseHeaders:true,includeRequestBody:true,includeResponseBody:true,bodySizeThreshold:10,format:"markdown",filterMode:"all"},json:{includeMethod:true,includeStatus:true,includeDuration:true,includeTimestamp:true,includeClient:true,includeSizes:true,includeErrors:true,includeRequestHeaders:true,includeResponseHeaders:true,includeRequestBody:true,includeResponseBody:true,bodySizeThreshold:-1,format:"json",filterMode:"all"},full:{includeMethod:true,includeStatus:true,includeDuration:true,includeTimestamp:true,includeClient:true,includeSizes:true,includeErrors:true,includeRequestHeaders:true,includeResponseHeaders:true,includeRequestBody:true,includeResponseBody:true,bodySizeThreshold:-1,format:"markdown",filterMode:"all"}};function Wu(e){for(let[t,r]of Object.entries(mr))if(Object.keys(r).every(o=>r[o]===e[o]))return t;return null}var Vu=100*1024,Uu=500*1024;function _u(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Xu({settings:e,onSettingsChange:t,events:r=[]}){let{isPro:o}=Au(),n=hn(),[i,s]=$u(false),l=r.length>0,a=Ht(()=>{if(!l)return null;let c=r.map(p=>typeof p.timestamp=="number"?p.timestamp:new Date(p.timestamp).getTime());return Math.max(...c)},[r,l]),u=Ht(()=>Wu(e),[e]),d=ot(()=>{t(mr.urls)},[t]),g=ot(()=>{t(mr.llm)},[t]),x=ot(()=>{t(mr.json)},[t]),y=ot(()=>{t(mr.full)},[t]),R=ot((c,p)=>{let[f,S]=c.split("::");if(f==="preset"){switch(S){case"urls":d();break;case"llm":g();break;case"json":x();break;case"full":y();break}return}if(f==="requestInfo"){t({...e,[S]:!e[S]});return}if(f==="headers"){t({...e,[S]:!e[S]});return}if(f==="body"){t(S==="bodySizeThreshold"?{...e,bodySizeThreshold:p}:{...e,[S]:!e[S]});return}if(f==="format"){t({...e,format:p});return}f==="filter"&&t({...e,filterMode:p})},[e,t,d,g,x,y]),h=Ht(()=>({method:"POST",url:"https://api.example.com/v1/users",status:201,duration:342,timestamp:new Date().toISOString(),requestHeaders:{"Content-Type":"application/json",Authorization:"Bearer ***"},responseHeaders:{"Content-Type":"application/json","X-Request-ID":"abc123"},requestBody:{name:"John Doe",email:"john@example.com"},responseBody:{id:"user_123",name:"John Doe",email:"john@example.com",createdAt:"2025-01-10T12:00:00Z"}}),[]),C=Ht(()=>l?r:[h],[l,r,h]),k=Ht(()=>{let c=l?r:[h],p=0;for(let f of c){if(e.includeMethod&&(p+=(f.url?.length||0)+10),e.includeStatus&&(p+=30),e.includeTimestamp&&(p+=30),e.includeRequestHeaders)try{p+=JSON.stringify(f.requestHeaders||{}).length}catch{p+=100}if(e.includeRequestBody){let S="requestBody"in f?f.requestBody:f.requestData;try{p+=JSON.stringify(S||{}).length}catch{p+=100}}if(e.includeResponseBody){let S="responseBody"in f?f.responseBody:f.responseData;try{p+=JSON.stringify(S||{}).length}catch{p+=100}}}return p},[l,r,h,e]),w=Ht(()=>k>=Uu?"danger":k>=Vu?"warning":"none",[k]),I=ot(()=>{let c=l?r:[h],{format:p,includeMethod:f,includeStatus:S,includeTimestamp:D,includeRequestHeaders:H,includeRequestBody:V,includeResponseBody:Z}=e,Y=L=>{let M={};return f&&(M.method=L.method,M.url=L.url),S&&(M.status=L.status,M.duration=L.duration),D&&(M.timestamp=L.timestamp),H&&(M.requestHeaders=L.requestHeaders),V&&(M.requestBody="requestBody"in L?L.requestBody:L.requestData),Z&&(M.responseBody="responseBody"in L?L.responseBody:L.responseData),M};if(p==="json"){let L=c.map(Y);return JSON.stringify(L,null,2)}return p==="markdown"?c.map((L,M)=>{let N=[];N.push(`# Request ${M+1}`),f&&N.push(`
44
+ **${L.method}** ${L.url}`);let J=[];if(S&&(J.push(`**Status:** ${L.status}`),J.push(`**Duration:** ${L.duration}ms`)),D&&J.push(`**Timestamp:** ${L.timestamp}`),J.length>0&&N.push(`
45
+ `+J.join(`
46
+ `)),H){let le=L.requestHeaders||{};N.push(`
47
47
  ## Request Headers
48
48
  \`\`\`json
49
- ${JSON.stringify(ge,null,2)}
50
- \`\`\``)}if(ne){let ge="requestBody"in A?A.requestBody:A.requestData;$.push(`
49
+ ${JSON.stringify(le,null,2)}
50
+ \`\`\``)}if(V){let le="requestBody"in L?L.requestBody:L.requestData;N.push(`
51
51
  ## Request Body
52
52
  \`\`\`json
53
- ${JSON.stringify(ge||{},null,2)}
54
- \`\`\``)}if(ee){let ge="responseBody"in A?A.responseBody:A.responseData;$.push(`
53
+ ${JSON.stringify(le||{},null,2)}
54
+ \`\`\``)}if(Z){let le="responseBody"in L?L.responseBody:L.responseData;N.push(`
55
55
  ## Response Body
56
56
  \`\`\`json
57
- ${JSON.stringify(ge||{},null,2)}
58
- \`\`\``)}return $.join(`
57
+ ${JSON.stringify(le||{},null,2)}
58
+ \`\`\``)}return N.join(`
59
59
  `)}).join(`
60
60
 
61
61
  ---
62
62
 
63
- `)||"No data included":p.map((A,W)=>{let $=[];if($.push(`Request ${W+1}:`),c&&$.push(`${A.method} ${A.url}`),y&&($.push(`Status: ${A.status}`),$.push(`Duration: ${A.duration}ms`)),O&&$.push(`Timestamp: ${A.timestamp}`),ne){let oe="requestBody"in A?A.requestBody:A.requestData;$.push(`
64
- Request:`),$.push(JSON.stringify(oe||{},null,2))}if(ee){let oe="responseBody"in A?A.responseBody:A.responseData;$.push(`
65
- Response:`),$.push(JSON.stringify(oe||{},null,2))}return $.join(`
63
+ `)||"No data included":c.map((L,M)=>{let N=[];if(N.push(`Request ${M+1}:`),f&&N.push(`${L.method} ${L.url}`),S&&(N.push(`Status: ${L.status}`),N.push(`Duration: ${L.duration}ms`)),D&&N.push(`Timestamp: ${L.timestamp}`),V){let J="requestBody"in L?L.requestBody:L.requestData;N.push(`
64
+ Request:`),N.push(JSON.stringify(J||{},null,2))}if(Z){let J="responseBody"in L?L.responseBody:L.responseData;N.push(`
65
+ Response:`),N.push(JSON.stringify(J||{},null,2))}return N.join(`
66
66
  `)}).join(`
67
67
 
68
68
  ---
69
69
 
70
- `)||"No data included"},[l,r,m,e]),D=Ve(()=>{let p=l?r:[m],{format:h,includeMethod:c,includeStatus:y,includeTimestamp:O,includeRequestHeaders:re,includeRequestBody:ne,includeResponseBody:ee}=e,X=W=>{let $={};return c&&($.method=W.method,$.url=W.url),y&&($.status=W.status,$.duration=W.duration),O&&($.timestamp=W.timestamp),re&&($.requestHeaders=W.requestHeaders),ne&&($.requestBody="requestBody"in W?W.requestBody:W.requestData),ee&&($.responseBody="responseBody"in W?W.responseBody:W.responseData),$};if(h==="json"){let W=p.map(X);return Me(Zd,{data:W,title:"",showTypeFilter:false})}if(h==="markdown"){let W=p.map(($,oe)=>{let ge=[];ge.push(`# Request ${oe+1}`),c&&ge.push(`
71
- **${$.method}** ${$.url}`);let rt=[];if(y&&(rt.push(`**Status:** ${$.status}`),rt.push(`**Duration:** ${$.duration}ms`)),O&&rt.push(`**Timestamp:** ${$.timestamp}`),rt.length>0&&ge.push(`
72
- `+rt.join(`
73
- `)),re){let dt=$.requestHeaders||{};ge.push(`
70
+ `)||"No data included"},[l,r,h,e]),z=ot(()=>{let c=l?r:[h],{format:p,includeMethod:f,includeStatus:S,includeTimestamp:D,includeRequestHeaders:H,includeRequestBody:V,includeResponseBody:Z}=e,Y=M=>{let N={};return f&&(N.method=M.method,N.url=M.url),S&&(N.status=M.status,N.duration=M.duration),D&&(N.timestamp=M.timestamp),H&&(N.requestHeaders=M.requestHeaders),V&&(N.requestBody="requestBody"in M?M.requestBody:M.requestData),Z&&(N.responseBody="responseBody"in M?M.responseBody:M.responseData),N};if(p==="json"){let M=c.map(Y);return _e(Nu,{data:M,title:"",showTypeFilter:false})}if(p==="markdown"){let M=c.map((N,J)=>{let le=[];le.push(`# Request ${J+1}`),f&&le.push(`
71
+ **${N.method}** ${N.url}`);let ne=[];if(S&&(ne.push(`**Status:** ${N.status}`),ne.push(`**Duration:** ${N.duration}ms`)),D&&ne.push(`**Timestamp:** ${N.timestamp}`),ne.length>0&&le.push(`
72
+ `+ne.join(`
73
+ `)),H){let K=N.requestHeaders||{};le.push(`
74
74
  ## Request Headers
75
75
  \`\`\`json
76
- ${JSON.stringify(dt,null,2)}
77
- \`\`\``)}if(ne){let dt="requestBody"in $?$.requestBody:$.requestData;ge.push(`
76
+ ${JSON.stringify(K,null,2)}
77
+ \`\`\``)}if(V){let K="requestBody"in N?N.requestBody:N.requestData;le.push(`
78
78
  ## Request Body
79
79
  \`\`\`json
80
- ${JSON.stringify(dt||{},null,2)}
81
- \`\`\``)}if(ee){let dt="responseBody"in $?$.responseBody:$.responseData;ge.push(`
80
+ ${JSON.stringify(K||{},null,2)}
81
+ \`\`\``)}if(Z){let K="responseBody"in N?N.responseBody:N.responseData;le.push(`
82
82
  ## Response Body
83
83
  \`\`\`json
84
- ${JSON.stringify(dt||{},null,2)}
85
- \`\`\``)}return ge.join(`
84
+ ${JSON.stringify(K||{},null,2)}
85
+ \`\`\``)}return le.join(`
86
86
  `)}).join(`
87
87
 
88
88
  ---
89
89
 
90
- `);return Me(ht,{style:Tt.previewScroll,nestedScrollEnabled:true,children:Me(b,{style:Tt.markdownText,selectable:o,children:W||"No data included"})})}let A=p.map((W,$)=>{let oe=[];if(oe.push(`Request ${$+1}:`),c&&oe.push(`${W.method} ${W.url}`),y&&(oe.push(`Status: ${W.status}`),oe.push(`Duration: ${W.duration}ms`)),O&&oe.push(`Timestamp: ${W.timestamp}`),ne){let ge="requestBody"in W?W.requestBody:W.requestData;oe.push(`
91
- Request:`),oe.push(JSON.stringify(ge||{},null,2))}if(ee){let ge="responseBody"in W?W.responseBody:W.responseData;oe.push(`
92
- Response:`),oe.push(JSON.stringify(ge||{},null,2))}return oe.join(`
90
+ `);return _e(yt,{keyboardShouldPersistTaps:"handled",style:Mt.previewScroll,nestedScrollEnabled:true,children:_e(b,{style:Mt.markdownText,selectable:o,children:M||"No data included"})})}let L=c.map((M,N)=>{let J=[];if(J.push(`Request ${N+1}:`),f&&J.push(`${M.method} ${M.url}`),S&&(J.push(`Status: ${M.status}`),J.push(`Duration: ${M.duration}ms`)),D&&J.push(`Timestamp: ${M.timestamp}`),V){let le="requestBody"in M?M.requestBody:M.requestData;J.push(`
91
+ Request:`),J.push(JSON.stringify(le||{},null,2))}if(Z){let le="responseBody"in M?M.responseBody:M.responseData;J.push(`
92
+ Response:`),J.push(JSON.stringify(le||{},null,2))}return J.join(`
93
93
  `)}).join(`
94
94
 
95
95
  ---
96
96
 
97
- `);return Me(ht,{style:Tt.previewScroll,nestedScrollEnabled:true,children:Me(b,{style:Tt.plaintextText,selectable:o,children:A||"No data included"})})},[e,l,r,m,o]),H=Ve(()=>{let p=(l?r:[m]).length;return Me(Qd,{expanded:i,onExpandedChange:s,summary:`${p} request${p!==1?"s":""} \u2022 ~${iu(E)}`,warningLevel:g,warningText:{warning:"Large payload - preview may be slow",danger:"Very large payload - may cause performance issues"},renderBody:D})},[e,l,r,m,i,E,g,D]),S=Ve(()=>{let p=l&&a?`Live data \u2022 Updated ${Jd(a,n)}`:"Mock data (no events captured)";return Bi(eu,{children:[Me(b,{style:Tt.statusLabel,children:p}),Me(Xd,{value:I()})]})},[l,a,n,I]),z=Ve(()=>H(),[H]),w=wt(()=>({sections:[{id:"presets",title:"Presets",type:"custom",data:[{id:"preset::urls",label:"URLs",icon:Fd,color:je.semantic.info,value:"urls",isActive:d==="urls"},{id:"preset::llm",label:"LLM",icon:Wd,color:je.semantic.success,value:"llm",isActive:d==="llm"},{id:"preset::json",label:"JSON",icon:Ii,color:je.semantic.warning,value:"json",isActive:d==="json"},{id:"preset::full",label:"Full",icon:Ei,color:je.semantic.info,value:"full",isActive:d==="full"},{id:"preset::custom",label:"Custom",icon:Vd,color:je.text.secondary,value:"custom",isActive:d===null}]},{id:"include",title:"Include",type:"custom",data:[{id:"requestInfo::includeMethod",label:"URL",value:"includeMethod",isActive:e.includeMethod},{id:"requestInfo::includeStatus",label:"Status",value:"includeStatus",isActive:e.includeStatus},{id:"requestInfo::includeTimestamp",label:"Time",value:"includeTimestamp",isActive:e.includeTimestamp},{id:"headers::includeRequestHeaders",label:"Headers",value:"includeRequestHeaders",isActive:e.includeRequestHeaders},{id:"body::includeRequestBody",label:"Req Body",value:"includeRequestBody",isActive:e.includeRequestBody},{id:"body::includeResponseBody",label:"Res Body",value:"includeResponseBody",isActive:e.includeResponseBody},{id:"requestInfo::includeErrors",label:"Errors",value:"includeErrors",isActive:e.includeErrors}]},{id:"format",title:"Format",type:"custom",data:[{id:"format::markdown",label:"Markdown",icon:Ei,color:je.semantic.info,value:"markdown",isActive:e.format==="markdown"},{id:"format::json",label:"JSON",icon:Ii,color:je.semantic.warning,value:"json",isActive:e.format==="json"},{id:"format::plaintext",label:"Text",icon:Ud,color:je.text.secondary,value:"plaintext",isActive:e.format==="plaintext"}]}],previewSection:{enabled:true,title:"PREVIEW",icon:_d,content:z,headerActions:S},onFilterChange:L}),[e,L,z,S,d]);return o?Me(Ri,{...w}):Bi(f,{style:Tt.gatedContainer,children:[Me(Kd,{featureName:"Network Export",description:"Export network requests to share with your team, debug APIs, or feed into AI tools.",benefits:["Export to JSON, Markdown, or plain text","Customizable copy presets (URLs only, LLM-ready, full data)","Share request details with teammates","Feed network data directly to AI assistants"]}),Me(f,{style:Tt.gatedPreview,children:Me(Ri,{...w})})]})}var Tt=he.create({previewScroll:{maxHeight:300},markdownText:{fontFamily:Pi,fontSize:11,color:je.text.primary,lineHeight:18},plaintextText:{fontFamily:Pi,fontSize:11,color:je.text.primary,lineHeight:18},statusLabel:{fontSize:11,fontWeight:"600",color:je.text.muted,marginRight:8},gatedContainer:{flex:1,padding:12},gatedPreview:{flex:1}});q();pe();import{Bookmark as Li,CheckCircle as au,XCircle as lu,Clock as du,Copy as uu,Pin as cu,Trash2 as hu,CopyButton as pu,macOSColors as nt,night as te,useLimit as fu,monoFont as qi}from"@buoy-gg/shared-ui/web";q();import{isBuoyRequest as Oi,getAccountAccess as Di}from"@buoy-gg/shared-ui/web";import{BaseEventStore as gu}from"@buoy-gg/shared-ui/web";q();function zi(e){if(!e||typeof e!="object")return null;if("operationName"in e&&e.operationName){let t=e.operationName;if(typeof t=="string"&&t.trim().length>0)return t.trim()}if("query"in e&&typeof e.query=="string"){let t=e.query.match(/(?:query|mutation|subscription)\s+(\w+)/);if(t&&t[1])return t[1]}return null}q();import{isBuoyRequest as mu,devToolsStorageKeys as Ai,persistentStorage as Hi}from"@buoy-gg/shared-ui/web";import{TIER_LIMITS as yu}from"@buoy-gg/shared-ui/web";var Mo=`${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`,Or=25,it=50,Mi=yu["network.saved"].free,st=16*1024,Ni=512*1024;function No(e){if(!e||typeof e!="object")return false;let t=e;return typeof t.id=="string"&&typeof t.url=="string"&&!mu(t.url)}var bu=800;function Dr(e,t){if(!t)return{pinned:false,saved:false};let r=e.pinnedLiveIds.has(t),o=e.savedLiveIds.has(t);if(r||o)return{pinned:r,saved:o};let n=e.records.find(i=>i.event.id===t);return n?{pinned:n.pinned,saved:n.saved}:{pinned:false,saved:false}}var vu={records:[],pinnedEvents:[],savedRecords:[],pinnedLiveIds:new Set,savedLiveIds:new Set};function $i(e){if(e==null)return{value:e,truncated:false};if(typeof e=="string")return e.length<=st?{value:e,truncated:false}:{value:`${e.slice(0,st)}
97
+ `);return _e(yt,{keyboardShouldPersistTaps:"handled",style:Mt.previewScroll,nestedScrollEnabled:true,children:_e(b,{style:Mt.plaintextText,selectable:o,children:L||"No data included"})})},[e,l,r,h,o]),$=ot(()=>{let c=(l?r:[h]).length;return _e(Mu,{expanded:i,onExpandedChange:s,summary:`${c} request${c!==1?"s":""} \u2022 ~${_u(k)}`,warningLevel:w,warningText:{warning:"Large payload - preview may be slow",danger:"Very large payload - may cause performance issues"},renderBody:z})},[e,l,r,h,i,k,w,z]),P=ot(()=>{let c=l&&a?`Live data \u2022 Updated ${Du(a,n)}`:"Mock data (no events captured)";return cs(Fu,{children:[_e(b,{style:Mt.statusLabel,children:c}),_e(zu,{value:I()})]})},[l,a,n,I]),A=ot(()=>$(),[$]),v=Ht(()=>({sections:[{id:"presets",title:"Presets",type:"custom",data:[{id:"preset::urls",label:"URLs",icon:Pu,color:Ge.semantic.info,value:"urls",isActive:u==="urls"},{id:"preset::llm",label:"LLM",icon:Lu,color:Ge.semantic.success,value:"llm",isActive:u==="llm"},{id:"preset::json",label:"JSON",icon:ds,color:Ge.semantic.warning,value:"json",isActive:u==="json"},{id:"preset::full",label:"Full",icon:ls,color:Ge.semantic.info,value:"full",isActive:u==="full"},{id:"preset::custom",label:"Custom",icon:Bu,color:Ge.text.secondary,value:"custom",isActive:u===null}]},{id:"include",title:"Include",type:"custom",data:[{id:"requestInfo::includeMethod",label:"URL",value:"includeMethod",isActive:e.includeMethod},{id:"requestInfo::includeStatus",label:"Status",value:"includeStatus",isActive:e.includeStatus},{id:"requestInfo::includeTimestamp",label:"Time",value:"includeTimestamp",isActive:e.includeTimestamp},{id:"headers::includeRequestHeaders",label:"Headers",value:"includeRequestHeaders",isActive:e.includeRequestHeaders},{id:"body::includeRequestBody",label:"Req Body",value:"includeRequestBody",isActive:e.includeRequestBody},{id:"body::includeResponseBody",label:"Res Body",value:"includeResponseBody",isActive:e.includeResponseBody},{id:"requestInfo::includeErrors",label:"Errors",value:"includeErrors",isActive:e.includeErrors}]},{id:"format",title:"Format",type:"custom",data:[{id:"format::markdown",label:"Markdown",icon:ls,color:Ge.semantic.info,value:"markdown",isActive:e.format==="markdown"},{id:"format::json",label:"JSON",icon:ds,color:Ge.semantic.warning,value:"json",isActive:e.format==="json"},{id:"format::plaintext",label:"Text",icon:qu,color:Ge.text.secondary,value:"plaintext",isActive:e.format==="plaintext"}]}],previewSection:{enabled:true,title:"PREVIEW",icon:Ou,content:A,headerActions:P},onFilterChange:R}),[e,R,A,P,u]);return o?_e(as,{...v}):cs(m,{style:Mt.gatedContainer,children:[_e(Hu,{featureName:"Network Export",description:"Export network requests to share with your team, debug APIs, or feed into AI tools.",benefits:["Export to JSON, Markdown, or plain text","Customizable copy presets (URLs only, LLM-ready, full data)","Share request details with teammates","Feed network data directly to AI assistants"]}),_e(m,{style:Mt.gatedPreview,children:_e(as,{...v})})]})}var Mt=ve.create({previewScroll:{maxHeight:300},markdownText:{fontFamily:us,fontSize:11,color:Ge.text.primary,lineHeight:18},plaintextText:{fontFamily:us,fontSize:11,color:Ge.text.primary,lineHeight:18},statusLabel:{fontSize:11,fontWeight:"600",color:Ge.text.muted,marginRight:8},gatedContainer:{flex:1,padding:12},gatedPreview:{flex:1}});O();Se();import{Bookmark as hs,CheckCircle as Ju,XCircle as Gu,Clock as Ku,Copy as Yu,Pin as Zu,Trash2 as Qu,CopyButton as ec,macOSColors as bt,night as ae,useLimit as tc,monoFont as ps}from"@buoy-gg/shared-ui/web";O();import{isBuoyRequest as fs,getAccountAccess as ys}from"@buoy-gg/shared-ui/web";import{BaseEventStore as rc}from"@buoy-gg/shared-ui/web";O();function gs(e){if(!e||typeof e!="object")return null;if("operationName"in e&&e.operationName){let t=e.operationName;if(typeof t=="string"&&t.trim().length>0)return t.trim()}if("query"in e&&typeof e.query=="string"){let t=e.query.match(/(?:query|mutation|subscription)\s+(\w+)/);if(t&&t[1])return t[1]}return null}O();import{isBuoyRequest as oc,devToolsStorageKeys as ms,persistentStorage as bs}from"@buoy-gg/shared-ui/web";import{TIER_LIMITS as nc}from"@buoy-gg/shared-ui/web";var mn=`${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`,eo=25,vt=50,vs=nc["network.saved"].free,St=16*1024,Ss=512*1024;function bn(e){if(!e||typeof e!="object")return false;let t=e;return typeof t.id=="string"&&typeof t.url=="string"&&!oc(t.url)}var ic=800;function to(e,t){if(!t)return{pinned:false,saved:false};let r=e.pinnedLiveIds.has(t),o=e.savedLiveIds.has(t);if(r||o)return{pinned:r,saved:o};let n=e.records.find(i=>i.event.id===t);return n?{pinned:n.pinned,saved:n.saved}:{pinned:false,saved:false}}var sc={records:[],pinnedEvents:[],savedRecords:[],pinnedLiveIds:new Set,savedLiveIds:new Set};function ws(e){if(e==null)return{value:e,truncated:false};if(typeof e=="string")return e.length<=St?{value:e,truncated:false}:{value:`${e.slice(0,St)}
98
98
 
99
- \u2026 truncated by Buoy (body exceeded ${st} bytes)`,truncated:true};try{let t=JSON.stringify(e);return t===void 0?{value:void 0,truncated:false}:t.length<=st?{value:e,truncated:false}:{value:`${t.slice(0,st)}
99
+ \u2026 truncated by Buoy (body exceeded ${St} bytes)`,truncated:true};try{let t=JSON.stringify(e);return t===void 0?{value:void 0,truncated:false}:t.length<=St?{value:e,truncated:false}:{value:`${t.slice(0,St)}
100
100
 
101
- \u2026 truncated by Buoy (body exceeded ${st} bytes)`,truncated:true}}catch{return{value:"[unserializable body]",truncated:true}}}function ji(e){let t=$i(e.requestData),r=$i(e.responseData);return!t.truncated&&!r.truncated?{event:{...e},bodyTruncated:false}:{event:{...e,requestData:t.value,responseData:r.value},bodyTruncated:true}}function Fi(e){let t=0;return e.requestData!=null&&(t+=Math.min(e.requestSize??0,st)),e.responseData!=null&&(t+=Math.min(e.responseSize??0,st)),t}function Su(e){let t=0;for(let i of e)t+=Fi(i.event);if(t<=Ni)return e;let r=[...e].sort((i,s)=>i.pinned!==s.pinned?i.pinned?-1:1:s.savedAt-i.savedAt),o=new Set,n=0;for(let i of r){let s=Fi(i.event);n+s<=Ni?n+=s:o.add(i.key)}return o.size===0?e:e.map(i=>o.has(i.key)?{...i,event:{...i.event,requestData:void 0,responseData:void 0},bodyTruncated:true}:i)}function xu(e){if(!Array.isArray(e))return[];let t=[];for(let r of e){if(!r||typeof r!="object")continue;let o=r;typeof o.key=="string"&&No(o.event)&&(!o.pinned&&!o.saved||t.push({key:o.key,event:{...o.event,id:`saved:${o.key}`},pinned:!!o.pinned,saved:!!o.saved,savedAt:typeof o.savedAt=="number"?o.savedAt:0,sessionId:typeof o.sessionId=="string"?o.sessionId:"unknown",liveId:typeof o.liveId=="string"?o.liveId:"",bodyTruncated:!!o.bodyTruncated}))}return t}var wu=class{constructor(){this.records=[];this.listeners=new Set;this.loaded=false;this.loadPromise=null;this.dirty=false;this.keyCounter=0;this.trackedLiveIds=new Set;this.state=vu;this.remote=null;this.remoteEchoUntil=0}getState(){return this.state}enableRemoteMode(e){this.remote=e}disableRemoteMode(){this.remote=null}replaceRecords(e,t=false){this.remote&&(!t&&Date.now()<this.remoteEchoUntil||(this.records=e.filter(r=>No(r.event)),this.rebuild(),this.emit()))}sessionMatches(e){return this.remote!==null||e.sessionId===Mo}getRecords(){return this.records}subscribe(e){return this.listeners.add(e),this.ensureLoaded(),()=>{this.listeners.delete(e)}}getEventById(e){for(let t of this.records)if(t.event.id===e)return t.event;return null}isPinned(e){return this.state.pinnedLiveIds.has(e)}isSaved(e){return this.state.savedLiveIds.has(e)}syncFromLive(e){if(this.trackedLiveIds.size===0||!this.trackedLiveIds.has(e.id))return;let t=this.records.findIndex(o=>this.sessionMatches(o)&&o.liveId===e.id);if(t===-1)return;let r=ji(e);this.commit(this.records.map((o,n)=>n===t?{...o,event:r.event,bodyTruncated:r.bodyTruncated}:o))}togglePin(e){return this.setFlag(e,"pinned")}toggleSave(e){return this.setFlag(e,"saved")}remove(e){this.records.some(t=>t.key===e)&&(this.remote?.removeRecord(e),this.commit(this.records.filter(t=>t.key!==e)))}clearSaved(){this.records.some(e=>e.saved)&&(this.remote?.clearSaved(),this.commit(this.records.filter(e=>e.pinned).map(e=>({...e,saved:false}))))}clearPinned(){this.records.some(e=>e.pinned)&&(this.remote?.clearPinned(),this.commit(this.records.filter(e=>e.saved).map(e=>({...e,pinned:false}))))}setFlag(e,t){if(!No(e))return{ok:false,reason:"invalid-event"};let r=this.findRecordFor(e);if(this.remote){let s=r?!r[t]:true;t==="pinned"?this.remote.setPinned(e.id,s):this.remote.setSaved(e.id,s),this.remoteEchoUntil=Date.now()+bu}if(r){let s=!r[t];if(s&&!this.hasRoomFor(t,r.key))return{ok:false,reason:t==="pinned"?"pin-cap":"saved-cap"};let l={...r,[t]:s};return this.commit(l.pinned||l.saved?this.records.map(a=>a.key===r.key?l:a):this.records.filter(a=>a.key!==r.key)),{ok:true,active:s}}if(!this.hasRoomFor(t,null))return{ok:false,reason:t==="pinned"?"pin-cap":"saved-cap"};let o=Date.now(),n=ji(e),i={key:`${Mo}_${++this.keyCounter}`,event:n.event,pinned:t==="pinned",saved:t==="saved",savedAt:o,sessionId:Mo,liveId:e.id,bodyTruncated:n.bodyTruncated};return this.commit(this.evictIfNeeded([i,...this.records])),{ok:true,active:true}}findRecordFor(e){return this.records.find(t=>t.event.id===e.id||this.sessionMatches(t)&&t.liveId===e.id)}hasRoomFor(e,t){let r=e==="pinned"?Or:it;return this.records.filter(o=>o[e]&&o.key!==t).length<r}evictIfNeeded(e){let t=e.filter(n=>n.saved);if(t.length<=it)return e;let r=t.filter(n=>!n.pinned).sort((n,i)=>n.savedAt-i.savedAt).slice(0,t.length-it);if(r.length===0)return e;let o=new Set(r.map(n=>n.key));return e.filter(n=>!o.has(n.key))}ensureLoaded(){return this.remote||this.loaded?Promise.resolve():this.loadPromise?this.loadPromise:(this.loadPromise=(async()=>{try{let e=await Hi.getItem(Ai.network.saved());e&&!this.dirty&&(this.records=xu(JSON.parse(e)),this.rebuild())}catch{}finally{this.loaded=true,this.emit()}})(),this.loadPromise)}persist(){this.remote||Hi.setItem(Ai.network.saved(),JSON.stringify(this.records)).catch(()=>{})}commit(e){this.dirty=true,this.records=Su(e),this.rebuild(),this.emit(),this.persist()}rebuild(){let e=[],t=[],r=new Set,o=new Set,n=new Set;for(let i of this.records)i.pinned&&e.push(i),i.saved&&t.push(i),!(!this.sessionMatches(i)||!i.liveId)&&(n.add(i.liveId),i.pinned&&r.add(i.liveId),i.saved&&o.add(i.liveId));this.trackedLiveIds=n,this.state={records:this.records,pinnedEvents:e.map(i=>i.event),savedRecords:t,pinnedLiveIds:r,savedLiveIds:o}}emit(){this.listeners.forEach(e=>e())}},ae=new wu;var Tu=200,Cu=class extends gu{constructor(){super({storeName:"network",maxEvents:500});this.pendingRequests=new Map;this.rawListenerUnsubscribe=null;this.bootBuffer=[];this.bootBufferUnsubscribe=null;this.mirrorMode=false}replaceEvents(e){super.replaceEvents(e.filter(t=>!Oi(t.url)))}startBootCapture(){if(Di().status==="locked"||this.mirrorMode||this.bootBufferUnsubscribe||this.isCapturing())return;let e=xr();e.isActive||e.startListening(),this.bootBufferUnsubscribe=er(t=>{this.bootBuffer.push(t),this.bootBuffer.length>Tu&&this.bootBuffer.shift()})}takeBootBuffer(){this.bootBufferUnsubscribe&&(this.bootBufferUnsubscribe(),this.bootBufferUnsubscribe=null);let e=this.bootBuffer;return this.bootBuffer=[],e}startCapturing(){let e=xr();e.isActive||e.startListening();for(let t of this.takeBootBuffer())this.processNetworkEvent(t);this.rawListenerUnsubscribe||(this.rawListenerUnsubscribe=er(t=>{this.processNetworkEvent(t)})),e.adoptEarlyRequests()}stopCapturing(){this.takeBootBuffer(),this.rawListenerUnsubscribe&&(this.rawListenerUnsubscribe(),this.rawListenerUnsubscribe=null),mt()===0&&Yt()}disableCapture(){this.mirrorMode=true,this.takeBootBuffer(),mt()===0&&Yt(),super.disableCapture()}isCapturing(){return this.rawListenerUnsubscribe!==null}ensureInterception(){this.isCapturing()&&xr().startListening()}subscribeToEvents(e){let t=super.subscribeToEvents(e);return this.ensureInterception(),t}processNetworkEvent(e){if(Di().status==="locked")return;let{request:t}=e;if(!Oi(t.url)){if(e.type==="request"){if(this.events.some(l=>l.id===t.id))return;let r=t.params?`?${new URLSearchParams(t.params).toString()}`:"",o=`${t.url}${r}`,n,i;t.client==="graphql"&&(n=zi(t.data)||void 0,t.data&&typeof t.data=="object"&&"variables"in t.data&&t.data.variables&&typeof t.data.variables=="object"&&(i=t.data.variables));let s={id:t.id,method:t.method,url:o,host:this.extractHost(t.url),path:this.extractPath(t.url),query:r,timestamp:e.timestamp.getTime(),requestHeaders:t.headers||{},requestData:t.data,requestSize:this.getDataSize(t.data),responseHeaders:{},requestClient:t.client,operationName:n,graphqlVariables:i,override:e.override,condition:e.condition};this.pendingRequests.set(t.id,s),this.events=[s,...this.events].slice(0,this.maxEvents),this.notify(s),this.notifyArrayListeners()}else if(e.type==="request-body"){let r=this.events.find(n=>n.id===t.id);if(!r)return;let o={...r,requestData:t.data,requestSize:this.getDataSize(t.data)};if(t.client==="graphql"){o.operationName=zi(t.data)||void 0;let n=t.data?.variables;n&&typeof n=="object"&&(o.graphqlVariables=n)}this.events=this.events.map(n=>n.id===t.id?o:n),this.pendingRequests.has(t.id)&&this.pendingRequests.set(t.id,o),ae.syncFromLive(o),this.notify(o),this.notifyArrayListeners()}else if(e.type==="response"||e.type==="error"){let r=this.events.findIndex(o=>o.id===t.id);if(r!==-1){let o={...this.events[r],duration:e.duration,timings:e.timings};e.response&&(o.status=e.response.status,o.statusText=e.response.statusText,o.responseHeaders=e.response.headers||{},o.responseData=e.response.body,o.responseSize=e.response.size||0,o.responseType=e.response.headers?.["content-type"]),e.error&&(o.error=e.error.message,o.status=o.status||0),e.override&&(o.override=e.override),this.events=this.events.map((n,i)=>i===r?o:n),this.pendingRequests.delete(t.id),ae.syncFromLive(o),this.notify(o),this.notifyArrayListeners()}}}}extractHost(e){try{return new URL(e).hostname}catch{return""}}extractPath(e){try{return new URL(e).pathname}catch{return e}}getDataSize(e){if(!e)return 0;if(typeof e=="string")return e.length;try{return JSON.stringify(e).length}catch{return 0}}getEventById(e){return this.events.find(t=>t.id===e)}clearEvents(){super.clearEvents(),this.pendingRequests.clear()}onEvent(e,t=true){let r=this.subscribe(e);if(t&&this.events.length>0){let o=[...this.events].reverse();for(let n of o)try{e(n)}catch{}}return r}getStats(){let e=this.events.length,t=this.events.filter(a=>a.status&&a.status>=200&&a.status<300).length,r=this.events.filter(a=>a.error||a.status&&a.status>=400).length,o=this.events.filter(a=>!a.status&&!a.error).length,n=this.events.filter(a=>a.duration).map(a=>a.duration),i=n.length>0?n.reduce((a,d)=>a+d,0)/n.length:0,s=this.events.reduce((a,d)=>a+(d.requestSize||0),0),l=this.events.reduce((a,d)=>a+(d.responseSize||0),0);return{totalRequests:e,successfulRequests:t,failedRequests:r,pendingRequests:o,totalDataSent:s,totalDataReceived:l,averageDuration:Math.round(i)}}filterEvents(e){let t=[...this.events];if(e.method&&(t=t.filter(r=>r.method===e.method)),e.status)switch(e.status){case"success":t=t.filter(r=>r.status&&r.status>=200&&r.status<300);break;case"error":t=t.filter(r=>r.error||r.status&&r.status>=400);break;case"pending":t=t.filter(r=>!r.status&&!r.error);break}if(e.searchText){let r=e.searchText.toLowerCase();t=t.filter(o=>o.url.toLowerCase().includes(r)||o.method.toLowerCase().includes(r)||o.error&&o.error.toLowerCase().includes(r))}return e.host&&(t=t.filter(r=>r.host===e.host)),t}},K=new Cu;q();import{useEffect as ku,useState as Ru}from"react";var Eu=e=>ae.togglePin(e),Iu=e=>ae.toggleSave(e),Pu=e=>ae.remove(e),Bu=()=>ae.clearSaved(),Lu=()=>ae.clearPinned();function Mt(){let[e,t]=Ru(()=>ae.getState());return ku(()=>ae.subscribe(()=>{t(ae.getState())}),[]),{...e,togglePin:Eu,toggleSave:Iu,remove:Pu,clearSaved:Bu,clearPinned:Lu}}q();import{useSyncExternalStore as sr}from"react";q();var qu=120,Ou=class{constructor(){this.ids=[];this.index=-1;this.selectedId=null;this.bodyId=null;this.renderedId=null;this.settleMs=120;this.settleTimer=null;this.subscribers=new Set;this.snapshot=this.buildSnapshot()}buildSnapshot(){return{ids:this.ids,index:this.index,selectedId:this.selectedId,bodyId:this.bodyId,renderedId:this.renderedId}}emit(){this.snapshot=this.buildSnapshot();for(let e of this.subscribers)e(this.snapshot)}getState(){return this.snapshot}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}setIds(e){e.length===this.ids.length&&e.every((t,r)=>t===this.ids[r])||(this.ids=e,this.index=this.selectedId==null?-1:e.indexOf(this.selectedId),this.emit())}select(e){e!==this.selectedId&&(this.selectedId=e,this.index=e==null?-1:this.ids.indexOf(e),this.scheduleBody(e),this.emit())}clear(){this.select(null)}step(e){if(this.index<0)return null;let t=this.index+e;if(t<0||t>=this.ids.length)return null;let r=this.ids[t];return this.selectedId=r,this.index=t,this.scheduleBody(r),this.emit(),r}scheduleBody(e){if(this.settleTimer!=null&&(clearTimeout(this.settleTimer),this.settleTimer=null),e==null||this.bodyId==null||this.settleMs<=0){this.bodyId=e;return}this.settleTimer=setTimeout(()=>{this.settleTimer=null,this.bodyId!==this.selectedId&&(this.bodyId=this.selectedId,this.emit())},this.settleMs)}setSettleMs(e){this.settleMs=Math.max(0,e)}getSettleMs(){return this.settleMs}reportRendered(e){e!==this.renderedId&&(this.renderedId=e,this.emit())}reset(){this.settleTimer!=null&&clearTimeout(this.settleTimer),this.settleTimer=null,this.ids=[],this.index=-1,this.selectedId=null,this.bodyId=null,this.renderedId=null,this.emit()}},Ue=new Ou;function Du(e){return e.map(t=>t.id)}var ar=e=>Ue.subscribe(e),_e=()=>Ue.getState();function zu(){return sr(ar,()=>_e().selectedId!=null,()=>_e().selectedId!=null)}function $o(){return sr(ar,()=>_e().selectedId,()=>_e().selectedId)}function Au(){return sr(ar,()=>_e().bodyId,()=>_e().bodyId)}function Hu(){let e=sr(ar,()=>_e().index,()=>_e().index),t=sr(ar,()=>_e().ids.length,()=>_e().ids.length);return{index:e,total:t}}q();import{useEffect as Wi,useState as Mu}from"react";q();import{urlMatchesIgnoredPattern as Nu}from"@buoy-gg/shared-ui/web";function lr(e,t){let r=t.searchText?t.searchText.toLowerCase():null,o=t.method&&t.method.length>0?new Set(t.method):null,n=t.contentType&&t.contentType.length>0?new Set(t.contentType):null,i=[...e];if(o&&(i=i.filter(s=>o.has(s.method))),t.status&&t.status!=="all")switch(t.status){case"success":i=i.filter(s=>s.status&&s.status>=200&&s.status<300);break;case"error":i=i.filter(s=>s.error||s.status&&s.status>=400);break;case"pending":i=i.filter(s=>!s.status&&!s.error);break}return r&&(i=i.filter(s=>s.url.toLowerCase().includes(r)||s.method.toLowerCase().includes(r)||s.path?.toLowerCase().includes(r)||s.host?.toLowerCase().includes(r)||s.error&&s.error.toLowerCase().includes(r)||s.operationName&&s.operationName.toLowerCase().includes(r)||wi(s.graphqlVariables,r))),t.host&&(i=i.filter(s=>s.host===t.host)),n&&(i=i.filter(s=>{let l=s.responseHeaders||s.requestHeaders,a=l?.["content-type"]||l?.["Content-Type"]||"";for(let d of n)switch(d){case"JSON":if(a.includes("json"))return true;break;case"XML":if(a.includes("xml"))return true;break;case"HTML":if(a.includes("html"))return true;break;case"TEXT":if(a.includes("text"))return true;break;case"IMAGE":if(a.includes("image"))return true;break;case"VIDEO":if(a.includes("video"))return true;break;case"AUDIO":if(a.includes("audio"))return true;break;case"FORM":if(a.includes("form"))return true;break;case"OTHER":if(!a||!a.includes("json")&&!a.includes("xml")&&!a.includes("html")&&!a.includes("text")&&!a.includes("image")&&!a.includes("video")&&!a.includes("audio")&&!a.includes("form"))return true;break}return false})),i}function dr(e,t){return t.length===0?e:e.filter(r=>!t.some(o=>Nu(r.url,o)))}function Vi(e,t){let r=0,o=0,n=0;for(let i of dr(e,t))i.status&&i.status>=200&&i.status<300?r++:i.error||i.status&&i.status>=400?o++:!i.status&&!i.error&&n++;return{successful:r,failed:o,pending:n,total:e.length}}function $u(e,t){return e.successful===t.successful&&e.failed===t.failed&&e.pending===t.pending&&e.total===t.total}function Ui(e){let{ignoredPatterns:t,paused:r}=e,[o,n]=Mu(()=>Vi(K.getEvents(),t));return Wi(()=>{if(r)return;let i=null,s=null,l=K.subscribeToEvents(a=>{s=a,i==null&&(i=requestAnimationFrame(()=>{if(i=null,!s)return;let d=Vi(s,t);s=null,n(u=>$u(u,d)?u:d)}))});return()=>{l(),i!=null&&cancelAnimationFrame(i)}},[r,t]),Wi(()=>K.onClear(()=>{n({successful:0,failed:0,pending:0,total:0})}),[]),o}q();import{useEffect as zr,useState as _i}from"react";function ju(e){let{paused:t}=e,[r,o]=_i(()=>K.getEvents().length>0);return zr(()=>{if(!t)return K.subscribeToEvents(n=>{let i=n.length>0;o(s=>s===i?s:i)})},[t]),zr(()=>K.onClear(()=>o(false)),[]),r}function Fu(e){let{filter:t,ignoredPatterns:r,paused:o}=e,[n,i]=_i(()=>lr(dr(K.getEvents(),r),t).length>0);return zr(()=>{if(!o)return K.subscribeToEvents(s=>{let l=lr(dr(s,r),t).length>0;i(a=>a===l?a:l)})},[o,t,r]),zr(()=>K.onClear(()=>i(false)),[]),n}q();function Ar(e){if(e==null)return"N/A";if(e===0)return"0 B";let t=1024,r=["B","KB","MB","GB","TB"],o=Math.floor(Math.log(e)/Math.log(t));return`${(e/Math.pow(t,o)).toFixed(1)} ${r[o]}`}function Hr(e,t){if(t===-1||!e)return true;try{return JSON.stringify(e).length<t*1024}catch{return false}}function Xi(e,t){let r=e;if(t.filterMode==="failed"?r=r.filter(n=>n.error||n.status&&n.status>=400):t.filterMode==="success"&&(r=r.filter(n=>n.status&&n.status>=200&&n.status<300)),r.length===0)return"No requests to copy";if(t.format==="plaintext")return r.map(n=>`${n.method} ${n.url}`).join(`
102
- `);if(t.format==="json"){let n=r.map(i=>{let s={};return t.includeMethod&&(s.method=i.method,s.url=i.url),t.includeStatus&&(s.status=i.status,s.statusText=i.statusText),t.includeDuration&&(s.duration=i.duration),i.condition&&(s.condition=i.condition),t.includeTimestamp&&(s.timestamp=i.timestamp),t.includeClient&&(s.requestClient=i.requestClient),t.includeSizes&&(s.requestSize=i.requestSize,s.responseSize=i.responseSize),t.includeErrors&&i.error&&(s.error=i.error),t.includeRequestHeaders&&(s.requestHeaders=i.requestHeaders),t.includeResponseHeaders&&(s.responseHeaders=i.responseHeaders),t.includeRequestBody&&Hr(i.requestData,t.bodySizeThreshold)&&(s.requestData=i.requestData),t.includeResponseBody&&Hr(i.responseData,t.bodySizeThreshold)&&(s.responseData=i.responseData),s});return JSON.stringify(n,null,2)}let o=r.map((n,i)=>{let s=`# Request ${i+1}
101
+ \u2026 truncated by Buoy (body exceeded ${St} bytes)`,truncated:true}}catch{return{value:"[unserializable body]",truncated:true}}}function xs(e){let t=ws(e.requestData),r=ws(e.responseData);return!t.truncated&&!r.truncated?{event:{...e},bodyTruncated:false}:{event:{...e,requestData:t.value,responseData:r.value},bodyTruncated:true}}function Cs(e){let t=0;return e.requestData!=null&&(t+=Math.min(e.requestSize??0,St)),e.responseData!=null&&(t+=Math.min(e.responseSize??0,St)),t}function ac(e){let t=0;for(let i of e)t+=Cs(i.event);if(t<=Ss)return e;let r=[...e].sort((i,s)=>i.pinned!==s.pinned?i.pinned?-1:1:s.savedAt-i.savedAt),o=new Set,n=0;for(let i of r){let s=Cs(i.event);n+s<=Ss?n+=s:o.add(i.key)}return o.size===0?e:e.map(i=>o.has(i.key)?{...i,event:{...i.event,requestData:void 0,responseData:void 0},bodyTruncated:true}:i)}function lc(e){if(!Array.isArray(e))return[];let t=[];for(let r of e){if(!r||typeof r!="object")continue;let o=r;typeof o.key=="string"&&bn(o.event)&&(!o.pinned&&!o.saved||t.push({key:o.key,event:{...o.event,id:`saved:${o.key}`},pinned:!!o.pinned,saved:!!o.saved,savedAt:typeof o.savedAt=="number"?o.savedAt:0,sessionId:typeof o.sessionId=="string"?o.sessionId:"unknown",liveId:typeof o.liveId=="string"?o.liveId:"",bodyTruncated:!!o.bodyTruncated}))}return t}var dc=class{constructor(){this.records=[];this.listeners=new Set;this.loaded=false;this.loadPromise=null;this.dirty=false;this.keyCounter=0;this.trackedLiveIds=new Set;this.state=sc;this.remote=null;this.remoteEchoUntil=0}getState(){return this.state}enableRemoteMode(e){this.remote=e}disableRemoteMode(){this.remote=null}replaceRecords(e,t=false){this.remote&&(!t&&Date.now()<this.remoteEchoUntil||(this.records=e.filter(r=>bn(r.event)),this.rebuild(),this.emit()))}sessionMatches(e){return this.remote!==null||e.sessionId===mn}getRecords(){return this.records}subscribe(e){return this.listeners.add(e),this.ensureLoaded(),()=>{this.listeners.delete(e)}}getEventById(e){for(let t of this.records)if(t.event.id===e)return t.event;return null}isPinned(e){return this.state.pinnedLiveIds.has(e)}isSaved(e){return this.state.savedLiveIds.has(e)}syncFromLive(e){if(this.trackedLiveIds.size===0||!this.trackedLiveIds.has(e.id))return;let t=this.records.findIndex(o=>this.sessionMatches(o)&&o.liveId===e.id);if(t===-1)return;let r=xs(e);this.commit(this.records.map((o,n)=>n===t?{...o,event:r.event,bodyTruncated:r.bodyTruncated}:o))}togglePin(e){return this.setFlag(e,"pinned")}toggleSave(e){return this.setFlag(e,"saved")}remove(e){this.records.some(t=>t.key===e)&&(this.remote?.removeRecord(e),this.commit(this.records.filter(t=>t.key!==e)))}clearSaved(){this.records.some(e=>e.saved)&&(this.remote?.clearSaved(),this.commit(this.records.filter(e=>e.pinned).map(e=>({...e,saved:false}))))}clearPinned(){this.records.some(e=>e.pinned)&&(this.remote?.clearPinned(),this.commit(this.records.filter(e=>e.saved).map(e=>({...e,pinned:false}))))}setFlag(e,t){if(!bn(e))return{ok:false,reason:"invalid-event"};let r=this.findRecordFor(e);if(this.remote){let s=r?!r[t]:true;t==="pinned"?this.remote.setPinned(e.id,s):this.remote.setSaved(e.id,s),this.remoteEchoUntil=Date.now()+ic}if(r){let s=!r[t];if(s&&!this.hasRoomFor(t,r.key))return{ok:false,reason:t==="pinned"?"pin-cap":"saved-cap"};let l={...r,[t]:s};return this.commit(l.pinned||l.saved?this.records.map(a=>a.key===r.key?l:a):this.records.filter(a=>a.key!==r.key)),{ok:true,active:s}}if(!this.hasRoomFor(t,null))return{ok:false,reason:t==="pinned"?"pin-cap":"saved-cap"};let o=Date.now(),n=xs(e),i={key:`${mn}_${++this.keyCounter}`,event:n.event,pinned:t==="pinned",saved:t==="saved",savedAt:o,sessionId:mn,liveId:e.id,bodyTruncated:n.bodyTruncated};return this.commit(this.evictIfNeeded([i,...this.records])),{ok:true,active:true}}findRecordFor(e){return this.records.find(t=>t.event.id===e.id||this.sessionMatches(t)&&t.liveId===e.id)}hasRoomFor(e,t){let r=e==="pinned"?eo:vt;return this.records.filter(o=>o[e]&&o.key!==t).length<r}evictIfNeeded(e){let t=e.filter(n=>n.saved);if(t.length<=vt)return e;let r=t.filter(n=>!n.pinned).sort((n,i)=>n.savedAt-i.savedAt).slice(0,t.length-vt);if(r.length===0)return e;let o=new Set(r.map(n=>n.key));return e.filter(n=>!o.has(n.key))}ensureLoaded(){return this.remote||this.loaded?Promise.resolve():this.loadPromise?this.loadPromise:(this.loadPromise=(async()=>{try{let e=await bs.getItem(ms.network.saved());e&&!this.dirty&&(this.records=lc(JSON.parse(e)),this.rebuild())}catch{}finally{this.loaded=true,this.emit()}})(),this.loadPromise)}persist(){this.remote||bs.setItem(ms.network.saved(),JSON.stringify(this.records)).catch(()=>{})}commit(e){this.dirty=true,this.records=ac(e),this.rebuild(),this.emit(),this.persist()}rebuild(){let e=[],t=[],r=new Set,o=new Set,n=new Set;for(let i of this.records)i.pinned&&e.push(i),i.saved&&t.push(i),!(!this.sessionMatches(i)||!i.liveId)&&(n.add(i.liveId),i.pinned&&r.add(i.liveId),i.saved&&o.add(i.liveId));this.trackedLiveIds=n,this.state={records:this.records,pinnedEvents:e.map(i=>i.event),savedRecords:t,pinnedLiveIds:r,savedLiveIds:o}}emit(){this.listeners.forEach(e=>e())}},fe=new dc;var uc=200,cc=class extends rc{constructor(){super({storeName:"network",maxEvents:500});this.pendingRequests=new Map;this.rawListenerUnsubscribe=null;this.bootBuffer=[];this.bootBufferUnsubscribe=null;this.mirrorMode=false}replaceEvents(e){super.replaceEvents(e.filter(t=>!fs(t.url)))}startBootCapture(){if(ys().status==="locked"||this.mirrorMode||this.bootBufferUnsubscribe||this.isCapturing())return;let e=Mr();e.isActive||e.startListening(),this.bootBufferUnsubscribe=fr(t=>{this.bootBuffer.push(t),this.bootBuffer.length>uc&&this.bootBuffer.shift()})}takeBootBuffer(){this.bootBufferUnsubscribe&&(this.bootBufferUnsubscribe(),this.bootBufferUnsubscribe=null);let e=this.bootBuffer;return this.bootBuffer=[],e}startCapturing(){let e=Mr();e.isActive||e.startListening();for(let t of this.takeBootBuffer())this.processNetworkEvent(t);this.rawListenerUnsubscribe||(this.rawListenerUnsubscribe=fr(t=>{this.processNetworkEvent(t)})),e.adoptEarlyRequests()}stopCapturing(){this.takeBootBuffer(),this.rawListenerUnsubscribe&&(this.rawListenerUnsubscribe(),this.rawListenerUnsubscribe=null),Pt()===0&&pr()}disableCapture(){this.mirrorMode=true,this.takeBootBuffer(),Pt()===0&&pr(),super.disableCapture()}isCapturing(){return this.rawListenerUnsubscribe!==null}ensureInterception(){this.isCapturing()&&Mr().startListening()}subscribeToEvents(e){let t=super.subscribeToEvents(e);return this.ensureInterception(),t}processNetworkEvent(e){if(ys().status==="locked")return;let{request:t}=e;if(!fs(t.url)){if(e.type==="request"){if(this.events.some(l=>l.id===t.id))return;let r=t.params?`?${new URLSearchParams(t.params).toString()}`:"",o=`${t.url}${r}`,n,i;t.client==="graphql"&&(n=gs(t.data)||void 0,t.data&&typeof t.data=="object"&&"variables"in t.data&&t.data.variables&&typeof t.data.variables=="object"&&(i=t.data.variables));let s={id:t.id,method:t.method,url:o,host:this.extractHost(t.url),path:this.extractPath(t.url),query:r,timestamp:e.timestamp.getTime(),requestHeaders:t.headers||{},requestData:t.data,requestSize:this.getDataSize(t.data),responseHeaders:{},requestClient:t.client,operationName:n,graphqlVariables:i,override:e.override,condition:e.condition};this.pendingRequests.set(t.id,s),this.events=[s,...this.events].slice(0,this.maxEvents),this.notify(s),this.notifyArrayListeners()}else if(e.type==="request-body"){let r=this.events.find(n=>n.id===t.id);if(!r)return;let o={...r,requestData:t.data,requestSize:this.getDataSize(t.data)};if(t.client==="graphql"){o.operationName=gs(t.data)||void 0;let n=t.data?.variables;n&&typeof n=="object"&&(o.graphqlVariables=n)}this.events=this.events.map(n=>n.id===t.id?o:n),this.pendingRequests.has(t.id)&&this.pendingRequests.set(t.id,o),fe.syncFromLive(o),this.notify(o),this.notifyArrayListeners()}else if(e.type==="response"||e.type==="error"){let r=this.events.findIndex(o=>o.id===t.id);if(r!==-1){let o={...this.events[r],duration:e.duration,timings:e.timings};e.response&&(o.status=e.response.status,o.statusText=e.response.statusText,o.responseHeaders=e.response.headers||{},o.responseData=e.response.body,o.responseSize=e.response.size||0,o.responseType=e.response.headers?.["content-type"]),e.error&&(o.error=e.error.message,o.status=o.status||0),e.override&&(o.override=e.override),this.events=this.events.map((n,i)=>i===r?o:n),this.pendingRequests.delete(t.id),fe.syncFromLive(o),this.notify(o),this.notifyArrayListeners()}}}}extractHost(e){try{return new URL(e).hostname}catch{return""}}extractPath(e){try{return new URL(e).pathname}catch{return e}}getDataSize(e){if(!e)return 0;if(typeof e=="string")return e.length;try{return JSON.stringify(e).length}catch{return 0}}getEventById(e){return this.events.find(t=>t.id===e)}clearEvents(){super.clearEvents(),this.pendingRequests.clear()}onEvent(e,t=true){let r=this.subscribe(e);if(t&&this.events.length>0){let o=[...this.events].reverse();for(let n of o)try{e(n)}catch{}}return r}getStats(){let e=this.events.length,t=this.events.filter(a=>a.status&&a.status>=200&&a.status<300).length,r=this.events.filter(a=>a.error||a.status&&a.status>=400).length,o=this.events.filter(a=>!a.status&&!a.error).length,n=this.events.filter(a=>a.duration).map(a=>a.duration),i=n.length>0?n.reduce((a,u)=>a+u,0)/n.length:0,s=this.events.reduce((a,u)=>a+(u.requestSize||0),0),l=this.events.reduce((a,u)=>a+(u.responseSize||0),0);return{totalRequests:e,successfulRequests:t,failedRequests:r,pendingRequests:o,totalDataSent:s,totalDataReceived:l,averageDuration:Math.round(i)}}filterEvents(e){let t=[...this.events];if(e.method&&(t=t.filter(r=>r.method===e.method)),e.status)switch(e.status){case"success":t=t.filter(r=>r.status&&r.status>=200&&r.status<300);break;case"error":t=t.filter(r=>r.error||r.status&&r.status>=400);break;case"pending":t=t.filter(r=>!r.status&&!r.error);break}if(e.searchText){let r=e.searchText.toLowerCase();t=t.filter(o=>o.url.toLowerCase().includes(r)||o.method.toLowerCase().includes(r)||o.error&&o.error.toLowerCase().includes(r))}return e.host&&(t=t.filter(r=>r.host===e.host)),t}},te=new cc;O();import{useEffect as hc,useState as pc}from"react";var fc=e=>fe.togglePin(e),yc=e=>fe.toggleSave(e),gc=e=>fe.remove(e),mc=()=>fe.clearSaved(),bc=()=>fe.clearPinned();function Zt(){let[e,t]=pc(()=>fe.getState());return hc(()=>fe.subscribe(()=>{t(fe.getState())}),[]),{...e,togglePin:fc,toggleSave:yc,remove:gc,clearSaved:mc,clearPinned:bc}}O();import{useSyncExternalStore as br}from"react";O();var vc=120,Sc=class{constructor(){this.ids=[];this.index=-1;this.selectedId=null;this.bodyId=null;this.renderedId=null;this.settleMs=120;this.settleTimer=null;this.subscribers=new Set;this.snapshot=this.buildSnapshot()}buildSnapshot(){return{ids:this.ids,index:this.index,selectedId:this.selectedId,bodyId:this.bodyId,renderedId:this.renderedId}}emit(){this.snapshot=this.buildSnapshot();for(let e of this.subscribers)e(this.snapshot)}getState(){return this.snapshot}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}setIds(e){e.length===this.ids.length&&e.every((t,r)=>t===this.ids[r])||(this.ids=e,this.index=this.selectedId==null?-1:e.indexOf(this.selectedId),this.emit())}select(e){e!==this.selectedId&&(this.selectedId=e,this.index=e==null?-1:this.ids.indexOf(e),this.scheduleBody(e),this.emit())}clear(){this.select(null)}step(e){if(this.index<0)return null;let t=this.index+e;if(t<0||t>=this.ids.length)return null;let r=this.ids[t];return this.selectedId=r,this.index=t,this.scheduleBody(r),this.emit(),r}scheduleBody(e){if(this.settleTimer!=null&&(clearTimeout(this.settleTimer),this.settleTimer=null),e==null||this.bodyId==null||this.settleMs<=0){this.bodyId=e;return}this.settleTimer=setTimeout(()=>{this.settleTimer=null,this.bodyId!==this.selectedId&&(this.bodyId=this.selectedId,this.emit())},this.settleMs)}setSettleMs(e){this.settleMs=Math.max(0,e)}getSettleMs(){return this.settleMs}reportRendered(e){e!==this.renderedId&&(this.renderedId=e,this.emit())}reset(){this.settleTimer!=null&&clearTimeout(this.settleTimer),this.settleTimer=null,this.ids=[],this.index=-1,this.selectedId=null,this.bodyId=null,this.renderedId=null,this.emit()}},nt=new Sc;function wc(e){return e.map(t=>t.id)}var vr=e=>nt.subscribe(e),it=()=>nt.getState();function xc(){return br(vr,()=>it().selectedId!=null,()=>it().selectedId!=null)}function vn(){return br(vr,()=>it().selectedId,()=>it().selectedId)}function Cc(){return br(vr,()=>it().bodyId,()=>it().bodyId)}function kc(){let e=br(vr,()=>it().index,()=>it().index),t=br(vr,()=>it().ids.length,()=>it().ids.length);return{index:e,total:t}}O();import{useEffect as ks,useState as Tc}from"react";O();import{urlMatchesIgnoredPattern as Rc}from"@buoy-gg/shared-ui/web";function Sr(e,t){let r=t.searchText?t.searchText.toLowerCase():null,o=t.method&&t.method.length>0?new Set(t.method):null,n=t.contentType&&t.contentType.length>0?new Set(t.contentType):null,i=[...e];if(o&&(i=i.filter(s=>o.has(s.method))),t.status&&t.status!=="all")switch(t.status){case"success":i=i.filter(s=>s.status&&s.status>=200&&s.status<300);break;case"error":i=i.filter(s=>s.error||s.status&&s.status>=400);break;case"pending":i=i.filter(s=>!s.status&&!s.error);break}return r&&(i=i.filter(s=>s.url.toLowerCase().includes(r)||s.method.toLowerCase().includes(r)||s.path?.toLowerCase().includes(r)||s.host?.toLowerCase().includes(r)||s.error&&s.error.toLowerCase().includes(r)||s.operationName&&s.operationName.toLowerCase().includes(r)||os(s.graphqlVariables,r))),t.host&&(i=i.filter(s=>s.host===t.host)),n&&(i=i.filter(s=>{let l=s.responseHeaders||s.requestHeaders,a=l?.["content-type"]||l?.["Content-Type"]||"";for(let u of n)switch(u){case"JSON":if(a.includes("json"))return true;break;case"XML":if(a.includes("xml"))return true;break;case"HTML":if(a.includes("html"))return true;break;case"TEXT":if(a.includes("text"))return true;break;case"IMAGE":if(a.includes("image"))return true;break;case"VIDEO":if(a.includes("video"))return true;break;case"AUDIO":if(a.includes("audio"))return true;break;case"FORM":if(a.includes("form"))return true;break;case"OTHER":if(!a||!a.includes("json")&&!a.includes("xml")&&!a.includes("html")&&!a.includes("text")&&!a.includes("image")&&!a.includes("video")&&!a.includes("audio")&&!a.includes("form"))return true;break}return false})),i}function wr(e,t){return t.length===0?e:e.filter(r=>!t.some(o=>Rc(r.url,o)))}function Ts(e,t){let r=0,o=0,n=0;for(let i of wr(e,t))i.status&&i.status>=200&&i.status<300?r++:i.error||i.status&&i.status>=400?o++:!i.status&&!i.error&&n++;return{successful:r,failed:o,pending:n,total:e.length}}function Ec(e,t){return e.successful===t.successful&&e.failed===t.failed&&e.pending===t.pending&&e.total===t.total}function Rs(e){let{ignoredPatterns:t,paused:r}=e,[o,n]=Tc(()=>Ts(te.getEvents(),t));return ks(()=>{if(r)return;let i=null,s=null,l=te.subscribeToEvents(a=>{s=a,i==null&&(i=requestAnimationFrame(()=>{if(i=null,!s)return;let u=Ts(s,t);s=null,n(d=>Ec(d,u)?d:u)}))});return()=>{l(),i!=null&&cancelAnimationFrame(i)}},[r,t]),ks(()=>te.onClear(()=>{n({successful:0,failed:0,pending:0,total:0})}),[]),o}O();import{useEffect as ro,useState as Es}from"react";function Ic(e){let{paused:t}=e,[r,o]=Es(()=>te.getEvents().length>0);return ro(()=>{if(!t)return te.subscribeToEvents(n=>{let i=n.length>0;o(s=>s===i?s:i)})},[t]),ro(()=>te.onClear(()=>o(false)),[]),r}function Pc(e){let{filter:t,ignoredPatterns:r,paused:o}=e,[n,i]=Es(()=>Sr(wr(te.getEvents(),r),t).length>0);return ro(()=>{if(!o)return te.subscribeToEvents(s=>{let l=Sr(wr(s,r),t).length>0;i(a=>a===l?a:l)})},[o,t,r]),ro(()=>te.onClear(()=>i(false)),[]),n}O();function oo(e){if(e==null)return"N/A";if(e===0)return"0 B";let t=1024,r=["B","KB","MB","GB","TB"],o=Math.floor(Math.log(e)/Math.log(t));return`${(e/Math.pow(t,o)).toFixed(1)} ${r[o]}`}function no(e,t){if(t===-1||!e)return true;try{return JSON.stringify(e).length<t*1024}catch{return false}}function Is(e,t){let r=e;if(t.filterMode==="failed"?r=r.filter(n=>n.error||n.status&&n.status>=400):t.filterMode==="success"&&(r=r.filter(n=>n.status&&n.status>=200&&n.status<300)),r.length===0)return"No requests to copy";if(t.format==="plaintext")return r.map(n=>`${n.method} ${n.url}`).join(`
102
+ `);if(t.format==="json"){let n=r.map(i=>{let s={};return t.includeMethod&&(s.method=i.method,s.url=i.url),t.includeStatus&&(s.status=i.status,s.statusText=i.statusText),t.includeDuration&&(s.duration=i.duration),i.condition&&(s.condition=i.condition),t.includeTimestamp&&(s.timestamp=i.timestamp),t.includeClient&&(s.requestClient=i.requestClient),t.includeSizes&&(s.requestSize=i.requestSize,s.responseSize=i.responseSize),t.includeErrors&&i.error&&(s.error=i.error),t.includeRequestHeaders&&(s.requestHeaders=i.requestHeaders),t.includeResponseHeaders&&(s.responseHeaders=i.responseHeaders),t.includeRequestBody&&no(i.requestData,t.bodySizeThreshold)&&(s.requestData=i.requestData),t.includeResponseBody&&no(i.responseData,t.bodySizeThreshold)&&(s.responseData=i.responseData),s});return JSON.stringify(n,null,2)}let o=r.map((n,i)=>{let s=`# Request ${i+1}
103
103
 
104
104
  `;if(t.includeMethod&&(s+=`**Method:** ${n.method}
105
105
  `,s+=`**URL:** ${n.url}
106
106
  `),t.includeStatus){let l=n.status||"Pending";s+=`**Status:** ${l}${n.statusText?` (${n.statusText})`:""}
107
107
  `}if(t.includeClient&&n.requestClient&&(s+=`**Client:** ${n.requestClient}
108
108
  `),n.condition&&(s+=`Conditions: ${n.condition.profile} (+${n.condition.delayMs} ms)
109
+ `),n.condition?.uploadCap?.note&&(s+=`${n.condition.uploadCap.note}
109
110
  `),t.includeDuration&&n.duration&&(s+=`**Duration:** ${n.duration}ms
110
111
  `),t.includeTimestamp&&(s+=`**Timestamp:** ${new Date(n.timestamp).toISOString()}
111
- `),t.includeSizes){let l=n.requestSize?Ar(n.requestSize):"N/A",a=n.responseSize?Ar(n.responseSize):"N/A";s+=`**Request Size:** ${l}
112
+ `),t.includeSizes){let l=n.requestSize?oo(n.requestSize):"N/A",a=n.responseSize?oo(n.responseSize):"N/A";s+=`**Request Size:** ${l}
112
113
  `,s+=`**Response Size:** ${a}
113
114
  `}if(t.includeErrors&&n.error&&(s+=`**Error:** ${n.error}
114
115
  `),t.includeRequestHeaders&&Object.keys(n.requestHeaders).length>0&&(s+=`
@@ -118,10 +119,10 @@ ${JSON.stringify(n.requestHeaders,null,2)}
118
119
  \`\`\`
119
120
  `),t.includeRequestBody)if(s+=`
120
121
  ## Request Data
121
- `,Hr(n.requestData,t.bodySizeThreshold))s+=`\`\`\`json
122
+ `,no(n.requestData,t.bodySizeThreshold))s+=`\`\`\`json
122
123
  ${JSON.stringify(n.requestData,null,2)}
123
124
  \`\`\`
124
- `;else{let l=n.requestSize?Ar(n.requestSize):"Unknown size";s+=`_Payload omitted (${l}). Exceeds ${t.bodySizeThreshold}KB threshold._
125
+ `;else{let l=n.requestSize?oo(n.requestSize):"Unknown size";s+=`_Payload omitted (${l}). Exceeds ${t.bodySizeThreshold}KB threshold._
125
126
  `}if(t.includeResponseHeaders&&Object.keys(n.responseHeaders).length>0&&(s+=`
126
127
  ## Response Headers
127
128
  \`\`\`json
@@ -129,17 +130,17 @@ ${JSON.stringify(n.responseHeaders,null,2)}
129
130
  \`\`\`
130
131
  `),t.includeResponseBody)if(s+=`
131
132
  ## Response Data
132
- `,Hr(n.responseData,t.bodySizeThreshold))s+=`\`\`\`json
133
+ `,no(n.responseData,t.bodySizeThreshold))s+=`\`\`\`json
133
134
  ${JSON.stringify(n.responseData,null,2)}
134
135
  \`\`\`
135
- `;else{let l=n.responseSize?Ar(n.responseSize):"Unknown size";s+=`_Payload omitted (${l}). Exceeds ${t.bodySizeThreshold}KB threshold._
136
+ `;else{let l=n.responseSize?oo(n.responseSize):"Unknown size";s+=`_Payload omitted (${l}). Exceeds ${t.bodySizeThreshold}KB threshold._
136
137
  `}return s+=`
137
138
  ---
138
139
  `,s}).join(`
139
140
  `);return`# Network Requests (${r.length} total)
140
141
 
141
- `+o}import{Fragment as Wu,jsx as fe,jsxs as Ct}from"react/jsx-runtime";function Vu({activeStatus:e,onToggleStatus:t,ignoredPatterns:r,paused:o}){let n=Ui({ignoredPatterns:r,paused:o});return fe(Ji,{counts:n,activeStatus:e,onToggleStatus:t})}function Ji({counts:e,activeStatus:t,onToggleStatus:r}){return Ct(f,{style:Y.headerChipRow,children:[Ct(N,{style:[Y.headerChip,t==="success"&&Y.headerChipActive],onPress:()=>r("success"),children:[fe(au,{size:12,color:nt.semantic.success}),fe(b,{style:[Y.headerChipValue,{color:nt.semantic.success}],children:e.successful})]}),Ct(N,{style:[Y.headerChip,t==="error"&&Y.headerChipActive],onPress:()=>r("error"),children:[fe(lu,{size:12,color:nt.semantic.error}),fe(b,{style:[Y.headerChipValue,{color:nt.semantic.error}],children:e.failed})]}),Ct(N,{style:[Y.headerChip,t==="pending"&&Y.headerChipActive],onPress:()=>r("pending"),children:[fe(du,{size:12,color:nt.semantic.warning}),fe(b,{style:[Y.headerChipValue,{color:nt.semantic.warning}],children:e.pending})]})]})}function Uu({paused:e}){let t=ju({paused:e});return fe(N,{"sentry-label":"ignore clear events",testID:"buoy-network-clear",accessibilityLabel:"Clear network requests",accessibilityRole:"button",onPress:()=>K.clearEvents(),style:[Y.headerActionButton,!t&&Y.headerActionButtonDisabled],disabled:!t,children:fe(hu,{size:14,color:t?te.color.textSecondary:te.color.textTertiary})})}function _u({onPress:e}){let{savedRecords:t}=Mt(),r=t.length;return Ct(N,{"sentry-label":"ignore open saved",onPress:e,accessibilityLabel:"Saved requests",style:Y.headerActionButton,children:[fe(Li,{size:14,color:r>0?te.color.accent:te.color.textSecondary}),r>0?fe(f,{style:Y.savedBadge,children:fe(b,{style:Y.savedBadgeText,children:r>99?"99+":r})}):null]})}function Gi({isPro:e,onUpgradePress:t}){let r=$o(),o=Mt(),{pinned:n,saved:i}=Dr(o,r),s=fu("network.saved"),l=!n&&o.pinnedEvents.length>=Or,a=!i&&o.savedRecords.length>=s,d=()=>r?K.getEvents().find(T=>T.id===r)??ae.getEventById(r):null,u=()=>{let T=d();T&&o.togglePin(T)},v=()=>{if(a&&!e){t();return}let T=d();T&&o.toggleSave(T)};return Ct(Wu,{children:[fe(N,{"sentry-label":"ignore pin request",onPress:u,disabled:l,testID:"buoy-network-pin",accessibilityRole:"button",accessibilityLabel:n?"Unpin request":"Pin request",accessibilityHint:l?`Pin limit reached (${Or})`:void 0,style:[Y.headerActionButton,n&&Y.headerActionButtonActive,l&&Y.headerActionButtonDisabled],children:fe(cu,{size:14,active:n,color:n?te.color.accent:l?te.color.textTertiary:te.color.textSecondary})}),fe(N,{"sentry-label":"ignore save request",onPress:v,disabled:a&&e,testID:"buoy-network-save",accessibilityRole:"button",accessibilityLabel:i?"Remove from saved":"Save request",accessibilityHint:a&&e?`Saved limit reached (${it})`:void 0,style:[Y.headerActionButton,i&&Y.headerActionButtonSaved,a&&e&&Y.headerActionButtonDisabled],children:fe(Li,{size:14,color:i?te.color.accent:a&&e?te.color.textTertiary:te.color.textSecondary})})]})}function Xu({isPro:e,filter:t,ignoredPatterns:r,copySettings:o,paused:n,onUpgradePress:i,label:s}){let l=Fu({filter:t,ignoredPatterns:r,paused:n});return e?fe(pu,{value:()=>Xi(lr(dr(K.getEvents(),r),t),o),size:14,label:s,buttonStyle:s?Y.copyMenuRow:Y.headerActionButton,labelStyle:Y.copyMenuLabel,colors:{idle:l?te.color.textSecondary:te.color.textTertiary,success:nt.semantic.success,error:nt.semantic.error},disabled:!l}):Ct(N,{"sentry-label":"ignore copy pro",onPress:i,style:[s?Y.copyMenuRow:Y.headerActionButton,!l&&Y.headerActionButtonDisabled],disabled:!l,children:[fe(uu,{size:14,color:l?te.color.textSecondary:te.color.textTertiary}),s?fe(b,{style:Y.copyMenuLabel,children:s}):null]})}var Y=he.create({copyMenuRow:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:6,paddingVertical:11,justifyContent:"flex-start"},copyMenuLabel:{fontSize:13,fontWeight:"600",color:te.color.text},headerChipRow:{flexDirection:"row",alignItems:"center",gap:8},headerChip:{flexDirection:"row",alignItems:"center",gap:4,backgroundColor:te.color.buttonSurface,paddingHorizontal:10,paddingVertical:5,borderRadius:12,borderWidth:1,borderColor:te.color.border},headerChipActive:{backgroundColor:te.color.accentSoft,borderColor:te.color.accentBorderStrong},headerChipValue:{fontSize:12,fontWeight:"600",fontFamily:qi},headerActionButton:{width:32,height:32,borderRadius:8,backgroundColor:te.color.buttonSurface,borderWidth:1,borderColor:te.color.border,alignItems:"center",justifyContent:"center"},headerActionButtonDisabled:{opacity:.55},headerActionButtonActive:{backgroundColor:te.color.accentSoft,borderColor:te.color.accentBorderStrong},headerActionButtonSaved:{backgroundColor:te.color.accentSoft,borderColor:te.color.accentBorderStrong},savedBadge:{position:"absolute",top:-3,right:-3,minWidth:14,height:14,paddingHorizontal:3,borderRadius:7,backgroundColor:te.color.accent,alignItems:"center",justifyContent:"center"},savedBadgeText:{color:te.color.onAccent,fontSize:9,fontWeight:"700",fontFamily:qi}});q();pe();import{useCallback as Ju}from"react";import{FlaskConical as Gu,Pin as Ku,Power as Qu,macOSColors as ve,ToolEmptyState as Zu,resolveListEmptyState as Yu,EVENT_LIST_PRESET as ec,monoFont as tc}from"@buoy-gg/shared-ui/web";q();pe();import{memo as rc}from"react";import{ChevronRight as oc,Upload as nc,Download as ic,Clock as sc,AlertCircle as ac,Bookmark as lc,FlaskConical as dc,Pin as uc,DevToolsCard as cc,MethodBadge as hc,TypeBadge as pc,night as Te,macOSColors as Nt,monoFont as jo}from"@buoy-gg/shared-ui/web";import{formatRelativeTime as fc}from"@buoy-gg/shared-ui/web";import{jsx as ie,jsxs as Xe}from"react/jsx-runtime";function gc(e,t){return t?Nt.semantic.error:e?e>=200&&e<300?Nt.semantic.success:e>=300&&e<400?Nt.semantic.info:e>=400?Nt.semantic.error:Nt.text.muted:Nt.semantic.warning}function mc(e){let t=e?.["content-type"]||e?.["Content-Type"]||"";return t.includes("json")?"JSON":t.includes("xml")?"XML":t.includes("html")?"HTML":t.includes("text")?"TEXT":t.includes("image")?"IMG":t.includes("video")?"VIDEO":t.includes("audio")?"AUDIO":t.includes("form")?"FORM":null}function Ki(e){switch(e){case"fetch":return{backgroundColor:"rgba(74, 144, 226, 0.15)",color:"#4A90E2"};case"graphql":return{backgroundColor:"rgba(229, 53, 171, 0.15)",color:"#E535AB"};case"grpc-web":return{backgroundColor:"rgba(16, 185, 129, 0.15)",color:"#10B981"};case"xhr":return{backgroundColor:"rgba(245, 158, 11, 0.15)",color:"#F59E0B"};default:return{backgroundColor:"rgba(147, 51, 234, 0.15)",color:"#9333EA"}}}function yc({event:e,isPending:t,statusColor:r}){return t?Xe(f,{style:le.pendingBadge,children:[ie(sc,{size:10,color:Te.color.warning}),ie(b,{style:le.pendingText,children:"..."})]}):e.error?Xe(f,{style:le.errorBadge,children:[ie(ac,{size:10,color:Te.color.danger}),ie(b,{style:le.errorText,children:"ERR"})]}):ie(f,{style:le.statusBadge,children:ie(b,{style:[le.statusText,{color:r}],children:String(e.status)})})}function bc({requestSize:e,responseSize:t}){return!e&&!t?null:Xe(f,{style:le.sizeRow,children:[e?Xe(f,{style:le.sizeItem,children:[ie(nc,{size:8,color:Te.color.info}),ie(b,{style:le.sizeText,children:Ye(e)})]}):null,t?Xe(f,{style:le.sizeItem,children:[ie(ic,{size:8,color:Te.color.accent}),ie(b,{style:le.sizeText,children:Ye(t)})]}):null]})}function vc({timestamp:e,duration:t}){let r=Oo(),o=fc(e,r);return t?Xe(b,{style:le.bottomRightText,children:[Lr(t)," ",o]}):ie(b,{style:le.bottomRightText,children:o})}var $t=rc(function({event:e,onPress:t,pinned:r=false,saved:o=false,overridden:n=false,onLongPress:i}){let s=gc(e.status,e.error),l=!e.status&&!e.error,a=mc(e.responseHeaders),d=e.path||e.url.replace(/^https?:\/\/[^/]+/,"");return e.requestClient==="graphql"?e.operationName?d=xi(e.operationName,e.graphqlVariables):d=d.replace(/\/graphql[^?]*/,"/graphql"):e.operationName&&(d=`${d}
142
- (${e.operationName})`),Xe(cc,{onPress:()=>t(e),onLongPress:i?()=>i(e):void 0,style:le.cardWrapper,contentStyle:[le.container,{borderLeftColor:s}],testID:`buoy-network-row-${e.id}`,accessibilityLabel:`${e.method} ${e.path||e.url}`,children:[Xe(f,{style:le.topRightContainer,children:[r?ie(uc,{size:10,active:true,color:Te.color.info}):null,o?ie(lc,{size:10,color:Te.color.accent}):null,n||e.override?ie(dc,{size:10,color:Te.color.warning}):null,ie(yc,{event:e,isPending:l,statusColor:s}),e.requestClient?ie(f,{style:[le.topRightBadge,{backgroundColor:Ki(e.requestClient).backgroundColor}],children:ie(b,{style:[le.clientText,{color:Ki(e.requestClient).color}],children:e.requestClient==="graphql"?"GQL":e.requestClient==="grpc-web"?"gRPC":e.requestClient==="xhr"?"XHR":e.requestClient})}):null]}),Xe(f,{style:le.leftSection,children:[ie(hc,{method:e.method,size:"small"}),ie(bc,{requestSize:e.requestSize,responseSize:e.responseSize})]}),ie(f,{style:le.middleSection,children:ie(b,{style:le.urlText,numberOfLines:2,children:d})}),Xe(f,{style:le.rightSection,children:[a?ie(pc,{type:a,size:"small"}):null,ie(oc,{size:14,color:Te.color.textTertiary})]}),ie(f,{style:le.bottomRightContainer,children:ie(vc,{timestamp:e.timestamp,duration:e.duration})})]})});$t.displayName="NetworkEventItemCompact";var le=he.create({cardWrapper:{marginHorizontal:8},container:{flexDirection:"row",alignItems:"center",backgroundColor:"rgba(12, 12, 12, 0.9)",borderLeftWidth:3,borderLeftColor:"transparent",borderBottomWidth:1},leftSection:{marginRight:8,alignItems:"flex-start"},topRightContainer:{position:"absolute",top:1,right:1,flexDirection:"row",alignItems:"center",gap:4},topRightBadge:{paddingHorizontal:4,paddingVertical:2,borderRadius:4},middleSection:{flex:1,justifyContent:"center",paddingRight:8},urlText:{fontSize:12,color:Te.color.text,lineHeight:16,fontFamily:jo},rightSection:{flexDirection:"row",alignItems:"center",gap:6},bottomRightContainer:{position:"absolute",bottom:4,right:8},bottomRightText:{fontSize:9,color:Te.color.textTertiary,fontFamily:jo},statusBadge:{paddingHorizontal:4,paddingVertical:1,borderRadius:3},statusText:{fontSize:10,fontWeight:"600"},pendingBadge:{flexDirection:"row",alignItems:"center",gap:2,paddingHorizontal:4,paddingVertical:1,backgroundColor:Te.color.warningSoft,borderRadius:3},pendingText:{fontSize:10,color:Te.color.warning,fontWeight:"600"},errorBadge:{flexDirection:"row",alignItems:"center",gap:2,paddingHorizontal:4,paddingVertical:1,backgroundColor:Te.color.dangerSoft,borderRadius:3},errorText:{fontSize:10,color:Te.color.danger,fontWeight:"600"},durationText:{fontSize:9,color:Te.color.textSecondary},sizeRow:{flexDirection:"row",gap:4,marginTop:4},sizeItem:{flexDirection:"row",alignItems:"center",gap:2},sizeText:{fontSize:8,color:Te.color.textSecondary,fontFamily:jo},clientText:{fontSize:8,fontWeight:"700",letterSpacing:.3,textTransform:"uppercase"}});q();pe();import{ProBadge as Sc,Zap as xc,buoyColors as ur}from"@buoy-gg/shared-ui/web";import{jsx as Mr,jsxs as Fo}from"react/jsx-runtime";function Qi({title:e,subtitle:t,onPress:r}){return Fo(N,{style:cr.banner,onPress:r,activeOpacity:.8,children:[Fo(f,{style:cr.content,children:[Fo(f,{style:cr.left,children:[Mr(xc,{size:16,color:ur.primary}),Mr(b,{style:cr.title,children:e})]}),Mr(Sc,{})]}),Mr(b,{style:cr.subtitle,children:t})]})}var cr=he.create({banner:{backgroundColor:ur.card,borderRadius:10,borderWidth:1,borderColor:ur.primary+"40",padding:12,marginHorizontal:12,marginTop:12,marginBottom:34},content:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:4},left:{flexDirection:"row",alignItems:"center",gap:8},title:{color:ur.text,fontSize:13,fontWeight:"600"},subtitle:{color:ur.textMuted,fontSize:11}});q();import{useEffect as Zi,useMemo as Nr,useState as wc}from"react";import{useLimit as Tc}from"@buoy-gg/shared-ui/web";function hr(e){let{filter:t,ignoredPatterns:r,paused:o,visible:n=true,isPro:i}=e,s=Tc("network.requests"),l=i?1/0:s,[a,d]=wc(()=>K.getEvents());Zi(()=>{if(!n)return;if(o){d(K.getEvents());return}let m=null,k=null,E=K.subscribeToEvents(g=>{k=g,m==null&&(m=requestAnimationFrame(()=>{m=null,k&&d(k),k=null}))});return()=>{E(),m!=null&&cancelAnimationFrame(m)}},[o,n]),Zi(()=>K.onClear(()=>{d([])}),[]);let u=Nr(()=>dr(a,r),[a,r]),v=Nr(()=>lr(u,t),[u,t]),T=Nr(()=>{let m=new Set;return a.slice(l).forEach(k=>{m.add(k.id)}),m},[a,l]),x=Nr(()=>T.size===0?v:v.filter(m=>!T.has(m.id)),[v,T]),L=v.length-x.length;return{events:v,visibleEvents:x,hasLockedEvents:L>0,lockedEventCount:L,totalEvents:u.length}}q();import{useCallback as jt,useSyncExternalStore as Cc}from"react";q();import{devToolsStorageKeys as $r,persistentStorage as Yi}from"@buoy-gg/shared-ui/web";var kc=800,Rc=3;function Ec(){let e=`${$r.network.overrides()}_launch`;try{let t=globalThis.sessionStorage;if(!t)return false;if(t.getItem(e))return true;t.setItem(e,"1")}catch{}return false}var Ic=Object.freeze([]),Pc=250,Bc=["respond","fail","delay"];function es(e){if(!Array.isArray(e))return[];let t=[];for(let r of e){if(!r||typeof r!="object")continue;let o=r;if(typeof o.id!="string"||typeof o.urlPattern!="string"||!o.urlPattern)continue;let n=Bc.includes(o.kind)?o.kind:"respond";t.push({id:o.id,enabled:o.enabled!==false,name:typeof o.name=="string"?o.name:void 0,urlPattern:o.urlPattern,methods:Array.isArray(o.methods)?o.methods.filter(i=>typeof i=="string"):void 0,requireHeader:typeof o.requireHeader=="string"&&o.requireHeader?o.requireHeader:void 0,bodyIncludes:typeof o.bodyIncludes=="string"&&o.bodyIncludes?o.bodyIncludes:void 0,kind:n,status:typeof o.status=="number"?Math.min(Zt,Math.max(Qt,o.status)):void 0,statusText:typeof o.statusText=="string"?o.statusText:void 0,headers:o.headers&&typeof o.headers=="object"?o.headers:void 0,body:typeof o.body=="string"?o.body:void 0,failKind:o.failKind==="timeout"?"timeout":void 0,delayMs:typeof o.delayMs=="number"?o.delayMs:void 0,times:typeof o.times=="number"?o.times:null,alternate:o.alternate===true,hits:0,seen:0,createdAt:typeof o.createdAt=="number"?o.createdAt:0})}return t.slice(0,Fe)}var Lc=class{constructor(){this.rules=[];this.enabled=true;this.listeners=new Set;this.loaded=false;this.loadPromise=null;this.dirty=false;this.idCounter=0;this.state={enabled:true,rules:[],autoPaused:false};this.launchStreak=0;this.autoPaused=false;this.keepAlive=null;this.hitEmitTimer=null;this.engineDisabled=false;this.remote=null;this.remoteEchoUntil=0}enableRemoteMode(e){this.remote=e,this.disableEngine()}disableRemoteMode(){this.remote=null}replaceRules(e,t=false){this.remote&&(!t&&ue()<this.remoteEchoUntil||(this.enabled=e.enabled,this.rules=e.rules,this.rebuild(),this.emit()))}markLocalEdit(){this.remote&&(this.remoteEchoUntil=ue()+kc)}disableEngine(){this.engineDisabled=true,this.keepAlive&&(this.keepAlive(),this.keepAlive=null,mt()===0&&Yt())}getState(){return this.state}getRules(){return this.engineDisabled||!this.enabled?Ic:this.rules}async fetchRuleBody(e){let t=this.rules.find(r=>r.id===e);if(!t)return null;if(!t.bodyOmitted)return t.body??null;if(!this.remote?.getRuleBody)return null;try{return await this.remote.getRuleBody(e)}catch{return null}}activeCount(){return this.enabled?this.rules.filter(e=>e.enabled&&!xo(e)).length:0}subscribe(e){return this.listeners.add(e),this.ensureLoaded(),()=>{this.listeners.delete(e)}}setEnabled(e){this.enabled!==e&&(this.remote?.setEnabled(e),this.markLocalEdit(),this.markTouched(),this.enabled=e,this.commit(this.rules))}addRule(e){if(this.rules.length>=Fe)return null;let t={...e,id:`ovr_${Date.now().toString(36)}_${++this.idCounter}`,hits:0,seen:0,createdAt:Date.now()};return this.commit([t,...this.rules]),t}upsertRule(e){this.remote?.upsertRule(e),this.markLocalEdit(),this.markTouched();let{id:t,...r}=e;return t&&this.rules.some(o=>o.id===t)?(this.updateRule(t,r),this.rules.find(o=>o.id===t)??null):this.addRule(r)}replaceAllRules(e,t){if(this.remote)return null;this.markTouched();let r=e.map(o=>o&&typeof o=="object"&&typeof o.id=="string"?o:{...o,id:`ovr_${Date.now().toString(36)}_${++this.idCounter}`,createdAt:Date.now()});return this.enabled=t,this.commit(es(r)),this.rules.slice()}updateRule(e,t){let r=this.rules.findIndex(n=>n.id===e);if(r===-1)return;let o=[...this.rules];o[r]={...o[r],...t,hits:0,seen:0},this.commit(o)}setRuleEnabled(e,t){let r=this.rules.findIndex(n=>n.id===e);if(r===-1||this.rules[r].enabled===t)return;this.remote?.setRuleEnabled(e,t),this.markLocalEdit(),this.markTouched();let o=[...this.rules];o[r]={...o[r],enabled:t,hits:t?0:o[r].hits,seen:t?0:o[r].seen},this.commit(o)}removeRule(e){let t=this.rules.filter(r=>r.id!==e);t.length!==this.rules.length&&(this.remote?.removeRule(e),this.markLocalEdit(),this.markTouched(),this.commit(t))}clearRules(){this.rules.length!==0&&(this.remote?.clearRules(),this.markLocalEdit(),this.markTouched(),this.commit([]))}recordMatch(e){let t=this.rules.findIndex(o=>o.id===e);if(t===-1)return;let r=[...this.rules];r[t]={...r[t],seen:r[t].seen+1},this.rules=r,this.rebuild()}recordHit(e){let t=this.rules.findIndex(s=>s.id===e);if(t===-1)return;let r=this.rules[t],o=r.hits+1,n=typeof r.times=="number"&&o>=r.times,i=[...this.rules];if(i[t]={...r,hits:o,enabled:n?false:r.enabled},n){this.commit(i);return}this.rules=i,this.rebuild(),this.scheduleHitEmit()}ensureLoaded(){return this.remote||this.loaded?Promise.resolve():this.loadPromise?this.loadPromise:(this.loadPromise=(async()=>{let e=null;try{e=await Yi.getItem($r.network.overrides())}catch{}this.hydrate(e)})(),this.loadPromise)}loadNow(){if(this.remote||this.loaded||this.loadPromise)return;let e;try{e=globalThis.localStorage?.getItem($r.network.overrides())??null}catch{return}e!==null&&this.hydrate(e)}hydrate(e){try{if(e&&!this.dirty){let t=JSON.parse(e);this.enabled=t?.enabled!==false,this.rules=es(t?.rules),this.launchStreak=typeof t?.launchStreak=="number"?t.launchStreak:0,this.autoPaused=t?.autoPaused===true&&!this.enabled,this.applyLaunchGuard(),this.rebuild()}}catch{}finally{this.loaded=true,this.syncKeepAlive(),this.emit()}}applyLaunchGuard(){if(!this.enabled||this.activeCount()===0){this.launchStreak=0;return}Ec()||(this.launchStreak+=1,this.launchStreak>=Rc&&(this.enabled=false,this.autoPaused=true,this.launchStreak=0),this.persist())}syncKeepAlive(){let e=!this.engineDisabled&&this.activeCount()>0;if(e&&!this.keepAlive){ei(),this.keepAlive=er(()=>{});return}!e&&this.keepAlive&&(this.keepAlive(),this.keepAlive=null,mt()===0&&Yt())}scheduleHitEmit(){this.hitEmitTimer===null&&(this.hitEmitTimer=setTimeout(()=>{this.hitEmitTimer=null,this.emit()},Pc))}commit(e){this.dirty=true,this.rules=e.slice(0,Fe),this.rebuild(),this.syncKeepAlive(),this.emit(),this.persist()}rebuild(){this.state={enabled:this.enabled,rules:this.rules,autoPaused:this.autoPaused}}markTouched(){this.launchStreak=0,this.autoPaused=false}noteHealthyLaunch(){this.launchStreak===0&&!this.autoPaused||(this.markTouched(),this.persist(),this.rebuild(),this.emit())}persist(){this.remote||Yi.setItem($r.network.overrides(),JSON.stringify({enabled:this.enabled,rules:this.rules,launchStreak:this.launchStreak,autoPaused:this.autoPaused})).catch(()=>{})}emit(){this.listeners.forEach(e=>e())}},U=new Lc;bl({getRules:()=>U.getRules(),recordHit:e=>U.recordHit(e),recordMatch:e=>U.recordMatch(e)});typeof window<"u"&&typeof document<"u"&&!(typeof navigator<"u"&&navigator.product==="ReactNative")&&U.loadNow();function jr(){let e=Cc(jt(s=>U.subscribe(s),[]),()=>U.getState(),()=>U.getState()),t=jt(s=>U.setEnabled(s),[]),r=jt(s=>U.upsertRule(s),[]),o=jt((s,l)=>U.setRuleEnabled(s,l),[]),n=jt(s=>U.removeRule(s),[]),i=jt(()=>U.clearRules(),[]);return{enabled:e.enabled,rules:e.rules,autoPaused:e.autoPaused,activeCount:U.activeCount(),setEnabled:t,upsertRule:r,setRuleEnabled:o,removeRule:n,clearRules:i,isRuleSpent:xo}}q();function qc(e,t){if(t.length===0)return[];let r=new Set(t.map(n=>n.id)),o=new Set;for(let n of t){let i;for(let s of e){if(s.override&&r.has(s.override.ruleId)){o.add(s.id);continue}So(n,s.url,String(s.method||"GET"),s.requestHeaders)&&(s.timestamp>=n.createdAt?o.add(s.id):(!i||s.timestamp>i.timestamp)&&(i=s))}i&&o.add(i.id)}return e.filter(n=>o.has(n.id))}q();var Oc=[];function Wo(e,t,r){return t.length===0?{pinned:Oc,rest:e}:{pinned:t,rest:r.size===0?e:e.filter(o=>!r.has(o.id))}}import{jsx as Se,jsxs as kt}from"react/jsx-runtime";var Dc=e=>e.id;function zc({events:e,onEventPress:t,onLongPress:r,savedLiveIds:o,onClearPinned:n}){return e.length===0?null:kt(f,{style:xe.pinnedSection,children:[kt(f,{style:xe.pinnedHeader,children:[Se(Ku,{size:11,active:true,color:ve.semantic.info}),kt(b,{style:xe.pinnedTitle,children:["PINNED \xB7 ",e.length]}),Se(N,{onPress:n,"sentry-label":"ignore unpin all",style:xe.pinnedClear,children:Se(b,{style:xe.pinnedClearText,children:"Unpin all"})})]}),e.map(i=>Se($t,{event:i,onPress:t,onLongPress:r,pinned:true,saved:o.has(i.id)},i.id))]})}function Ac({events:e,onEventPress:t,onLongPress:r,savedLiveIds:o,paused:n,onTogglePaused:i}){return e.length===0?null:kt(f,{style:[xe.overriddenSection,n&&xe.overriddenSectionOff],children:[kt(f,{style:xe.overriddenHeader,children:[Se(Gu,{size:11,color:n?ve.text.muted:ve.semantic.warning}),Se(b,{testID:"buoy-network-overridden-strip",style:[xe.overriddenTitle,n&&xe.overriddenTitleOff],children:n?`PAUSED \xB7 ${e.length}`:`OVERRIDDEN \xB7 ${e.length}`}),Se(N,{onPress:i,"sentry-label":"ignore pause overrides",style:xe.overriddenManage,children:Se(b,{style:[xe.overriddenManageText,n&&xe.overriddenTitleOff],children:n?"Resume":"Pause"})})]}),e.map(s=>Se($t,{event:s,onPress:t,onLongPress:r,overridden:true,saved:o.has(s.id)},s.id))]})}function Hc({visible:e,paused:t,filter:r,ignoredPatterns:o,isPro:n,searchText:i,onEventPress:s,onUpgradePress:l}){let{visibleEvents:a,hasLockedEvents:d,lockedEventCount:u,totalEvents:v}=hr({filter:r,ignoredPatterns:o,paused:t,visible:e,isPro:n}),{pinnedEvents:T,pinnedLiveIds:x,savedLiveIds:L,togglePin:m,clearPinned:k}=Mt(),{rules:E,enabled:g,setEnabled:I,isRuleSpent:D}=jr(),H=Ju(X=>{m(X)},[m]);if(!e)return null;let{pinned:S,rest:z}=Wo(a,T,x),w=E.filter(X=>X.enabled&&!D(X)),p=qc([...S,...z],w),h=new Set(p.map(X=>X.id)),c=S.filter(X=>!h.has(X.id)),y=h.size?z.filter(X=>!h.has(X.id)):z,O=!t,re=({item:X})=>Se($t,{event:X,onPress:s,onLongPress:H,saved:L.has(X.id)}),ne=()=>c.length>0||p.length>0?null:Se(Zu,{testID:"buoy-network-empty",...Yu({subject:"requests",search:i,total:v,capturing:O,waiting:{otto:"fishing",title:"No network events",message:"Network requests will appear here"},paused:{title:"No network events",message:"Enable interception to start capturing"}})}),ee=()=>{if(!d)return null;let X=i.length>0,A=X?`${u} matching ${u===1?"request":"requests"} in locked history`:`${u} requests locked`;return Se(Qi,{title:A,subtitle:X?"Upgrade to Pro to search your full request history":"Upgrade to Pro to unlock full request history",onPress:l})};return kt(f,{style:xe.root,children:[O?null:kt(f,{style:xe.disabledBanner,children:[Se(Qu,{size:14,color:ve.semantic.warning}),Se(b,{style:xe.disabledText,children:"Network interception is disabled"})]}),Se(Ac,{events:p,onEventPress:s,onLongPress:H,savedLiveIds:L,paused:!g,onTogglePaused:()=>I(!g)}),Se(zc,{events:c,onEventPress:s,onLongPress:H,savedLiveIds:L,onClearPinned:k}),y.length>0||d?Se(po,{testID:"buoy-network-list",data:y,renderItem:re,keyExtractor:Dc,contentContainerStyle:xe.listContent,showsVerticalScrollIndicator:true,onEndReachedThreshold:.8,scrollEnabled:true,...ec,extraData:L,"sentry-label":"ignore network events list",ListFooterComponent:ee}):ne()]})}var xe=he.create({root:{flex:1,minHeight:0},overriddenSection:{borderBottomWidth:1,borderBottomColor:ve.semantic.warning+"44",backgroundColor:ve.semantic.warningBackground},overriddenSectionOff:{borderBottomColor:ve.border.default,backgroundColor:ve.background.card},overriddenTitleOff:{color:ve.text.muted},overriddenHeader:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:12,paddingTop:8,paddingBottom:4},overriddenTitle:{flex:1,fontSize:10,fontWeight:"700",letterSpacing:.8,color:ve.semantic.warning},overriddenManage:{paddingHorizontal:6,paddingVertical:2},overriddenManageText:{fontSize:10,fontWeight:"600",color:ve.semantic.warning},pinnedSection:{borderBottomWidth:1,borderBottomColor:ve.border.default,paddingBottom:4},pinnedHeader:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:20,paddingTop:10,paddingBottom:6},pinnedTitle:{flex:1,color:ve.semantic.info,fontSize:10,fontWeight:"700",letterSpacing:.6,fontFamily:tc},pinnedClear:{paddingHorizontal:6,paddingVertical:2},pinnedClearText:{color:ve.text.muted,fontSize:10},disabledBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:ve.semantic.warningBackground,borderRadius:8,borderWidth:1,borderColor:ve.semantic.warning+"20"},disabledText:{color:ve.semantic.warning,fontSize:11,flex:1},listContent:{paddingTop:8}});q();pe();import{useState as Mc}from"react";import{Bookmark as Nc,CopyButton as $c,Search as jc,macOSColors as Ne,useLimit as Fc,ToolEmptyState as Wc,resolveListEmptyState as Vc,EVENT_LIST_PRESET as Uc,monoFont as _c}from"@buoy-gg/shared-ui/web";q();function ts(e,t,r){let o=e.slice(0,Math.min(t,it)),n=o.map(i=>i.event);return{events:r?lr(n,{searchText:r}):n,lockedCount:e.length-o.length}}import{jsx as Je,jsxs as Fr}from"react/jsx-runtime";var Xc=e=>e.id;function rs({visible:e,isPro:t,copySettings:r,search:o,onSearchChange:n,onEventPress:i,onUpgradePress:s}){let{savedRecords:l,pinnedLiveIds:a,toggleSave:d,clearSaved:u}=Mt(),v=Fc("network.saved"),[T,x]=Mc(""),L=o!=null&&n!=null,m=L?o:T,k=L?n:x;if(!e)return null;let{events:E,lockedCount:g}=ts(l,v,m),I=S=>{d(S)},D=({item:S})=>Je($t,{event:S,onPress:i,onLongPress:I,saved:true,pinned:a.has(S.id)}),H=()=>g===0?null:Je(Qi,{title:`${g} saved ${g===1?"request":"requests"} locked`,subtitle:`Your plan keeps ${v}. Upgrade to Pro to unlock the rest.`,onPress:s});return Fr(f,{style:Ge.root,children:[Fr(f,{style:Ge.toolbar,children:[Je(Nc,{size:11,color:Ne.semantic.debug}),Fr(b,{style:Ge.toolbarTitle,children:["SAVED \xB7 ",l.length,v>=it?"":`/${v}`]}),t?Je($c,{value:()=>Xi(E,r),size:13,buttonStyle:Ge.toolbarButton,colors:{idle:Ne.text.secondary,success:Ne.semantic.success,error:Ne.semantic.error},disabled:E.length===0}):null,Je(N,{onPress:u,"sentry-label":"ignore clear saved",style:Ge.toolbarClear,disabled:l.length===0,children:Je(b,{style:[Ge.toolbarClearText,l.length===0&&Ge.toolbarClearTextDisabled],children:"Clear all"})})]}),l.length>0?Fr(f,{style:Ge.searchRow,children:[Je(jc,{size:13,color:Ne.text.secondary}),Je(zt,{style:Ge.searchInput,placeholder:"Search saved requests\u2026",placeholderTextColor:Ne.text.muted,value:m,onChangeText:k,"sentry-label":"ignore saved search",accessibilityLabel:"Search saved requests",autoCapitalize:"none",autoCorrect:false,returnKeyType:"search"})]}):null,l.length===0||m.trim().length>0&&E.length===0&&g===0?Je(Wc,{testID:"buoy-network-saved-empty",...Vc({subject:"saved requests",verb:"kept",search:l.length===0?"":m,total:l.length,waiting:{otto:"empty",title:"No saved requests",message:"Open a request and tap the bookmark to keep it here \u2014 saved requests survive Clear and app restarts."}})}):Je(po,{data:E,renderItem:D,keyExtractor:Xc,contentContainerStyle:Ge.listContent,showsVerticalScrollIndicator:true,scrollEnabled:true,...Uc,extraData:a,"sentry-label":"ignore saved requests list",ListFooterComponent:H})]})}var Ge=he.create({root:{flex:1,minHeight:0},toolbar:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:20,paddingTop:10,paddingBottom:6},toolbarTitle:{flex:1,color:Ne.semantic.debug,fontSize:10,fontWeight:"700",letterSpacing:.6,fontFamily:_c},toolbarButton:{width:26,height:26,borderRadius:6,alignItems:"center",justifyContent:"center"},toolbarClear:{paddingHorizontal:6,paddingVertical:2},toolbarClearText:{color:Ne.text.muted,fontSize:10},toolbarClearTextDisabled:{color:Ne.text.disabled},searchRow:{flexDirection:"row",alignItems:"center",gap:6,marginHorizontal:12,marginBottom:8,paddingHorizontal:10,paddingVertical:5,backgroundColor:Ne.background.input,borderRadius:10,borderWidth:1,borderColor:Ne.border.default},searchInput:{flex:1,color:Ne.text.primary,fontSize:13,paddingVertical:2},listContent:{paddingTop:4}});q();pe();import{useCallback as Jc,useEffect as Wr,useState as Gc}from"react";import{AlertCircle as Kc,AlertTriangle as Qc,DevToolsCard as Zc,EmptyState as Yc,MethodBadge as eh,Plus as th,Trash2 as rh,macOSColors as Q,useLimit as oh,monoFont as nh}from"@buoy-gg/shared-ui/web";q();pe();import{useMemo as os,useState as Vr}from"react";import{ChevronDown as ih,ChevronRight as sh,macOSColors as _,useSafeAreaInsets as ah,monoFont as lh}from"@buoy-gg/shared-ui/web";q();pe();import{useState as Ur,useMemo as _r,useCallback as pr,useRef as Vo,useEffect as dh,memo as Xr}from"react";import{displayValue as uh,buoyColors as P,monoFont as qe}from"@buoy-gg/shared-ui/web";import{CopyButton as ch}from"@buoy-gg/shared-ui/web";import{ChevronRight as hh,ChevronDown as ph,Trash as ns}from"@buoy-gg/shared-ui/web";import{CyberpunkInput as fh}from"@buoy-gg/shared-ui/web/dataViewer";q();var Rt=(e,t,r)=>{if(t.length===0)return r;if(e instanceof Map){let o=new Map(e);if(t.length===1)return o.set(t[0],r),o;let[n,...i]=t,s=o.get(n);return o.set(n,Rt(s??null,i,r)),o}if(e instanceof Set){let o=Rt(Array.from(e),t,r);return new Set(Array.isArray(o)?o:[])}if(Array.isArray(e)){let o=[...e];if(t.length===1)return o[t[0]]=r,o;let[n,...i]=t;return o[n]=Rt(o[n],i,r),o}if(e instanceof Object){let o={...e};if(t.length===1)return o[t[0]]=r,o;let[n,...i]=t;return o[n]=Rt(o[n],i,r),o}return e};q();var Et=(e,t)=>{if(e instanceof Map){let r=new Map(e);if(t.length===1)return r.delete(t[0]),r;let[o,...n]=t;return r.set(o,Et(r.get(o),n)),r}if(e instanceof Set){let r=Et(Array.from(e),t);return new Set(r)}if(Array.isArray(e)){let r=[...e];if(t.length===1)return r.filter((i,s)=>s.toString()!==t[0]);let[o,...n]=t;return r[o]=Et(r[o],n),r}if(e instanceof Object){let r={...e};if(t.length===1)return delete r[t[0]],r;let[o,...n]=t;return r[o]=Et(r[o],n),r}return e};q();import{createContext as gh,useContext as mh}from"react";var is=gh(null);function Jr(){return mh(is)}import{Fragment as Gr,jsx as G,jsxs as Pe}from"react/jsx-runtime";var fr=100,Ft={top:8,bottom:8,left:8,right:8},ss=12,yh=(e,t=fr)=>{if(t<1||e.length===0)return[];let r=[];for(let o=0;o<e.length;o+=t)r.push(e.slice(o,o+t));return r},Uo=Xr(({expanded:e,isFocused:t=false,isMain:r=false})=>G(f,{style:[F.expanderIcon,r&&F.expanderIconMain,e?F.expanded:F.collapsed],children:e?G(ph,{size:r?14:ss,color:t?P.primary:r?P.text:P.textSecondary,strokeWidth:2.5}):G(hh,{size:r?14:ss,color:t?P.primary:r?P.text:P.textSecondary,strokeWidth:2.5})}));Uo.displayName="Expander";var as=Xr(({value:e,isFocused:t=false})=>G(ch,{value:e,isFocused:t,buttonStyle:t?{...F.buttonStyle,...F.buttonStyleFocused}:F.buttonStyle}));as.displayName="CopyButton";var _o=Xr(({dataPath:e,isFocused:t=false})=>{let r=Jr(),o=pr(()=>{r&&r.onChange(Et(r.root,e))},[r,e]);return r?G(N,{"sentry-label":"ignore devtools explorer delete button",onPress:o,style:[F.deleteButton,t&&F.deleteButtonFocused],accessibilityLabel:"Delete item",hitSlop:Ft,activeOpacity:.7,children:G(ns,{size:14,strokeWidth:2,color:t?P.error:P.error+"CC"})}):null});_o.displayName="DeleteItemButton";var ls=Xr(({dataPath:e,isFocused:t=false})=>{let r=Jr(),o=pr(()=>{r&&r.onChange(Rt(r.root,e,[]))},[r,e]);return r?G(N,{"sentry-label":"ignore devtools explorer clear button",style:[F.clearButton,t&&F.clearButtonFocused],"aria-label":"Remove all items",onPress:o,hitSlop:Ft,activeOpacity:.7,children:G(b,{style:[F.clearButtonText,{color:t?P.warning:P.warning+"CC"}],children:"[]"})}):null});ls.displayName="ClearArrayButton";function bh({dataPath:e,value:t,itemsDeletable:r}){let o=Jr(),n=pr(()=>{if(!o)return;let a=typeof t=="boolean"?t:false;o.onChange(Rt(o.root,e,!a))},[o,e,t]),i=pr(()=>{o&&o.onChange(Et(o.root,e))},[o,e]);if(!o)return null;let s=t?F.toggleBadgeTrue:F.toggleBadgeFalse,l=t?F.toggleTextTrue:F.toggleTextFalse;return Pe(N,{"sentry-label":"ignore devtools explorer toggle button",style:F.modernToggleButton,onPress:n,hitSlop:Ft,activeOpacity:.8,children:[G(f,{style:[F.toggleBadge,s],children:G(b,{style:[F.toggleBadgeText,l],children:t?"TRUE":"FALSE"})}),r&&G(N,{"sentry-label":"ignore devtools explorer delete button in toggle",onPress:i,style:F.deleteButtonInToggle,accessibilityLabel:"Delete item",hitSlop:Ft,activeOpacity:.7,children:G(ns,{size:14,strokeWidth:2,color:P.error+"CC"})})]})}function Xo({editable:e,label:t,value:r,defaultExpanded:o,dataPath:n,itemsDeletable:i,dataVersion:s=0}){let l=Jr(),[a,d]=Ur(false),[u,v]=Ur("");dh(()=>{if(r!=null&&(typeof r=="string"||typeof r=="number")){let h=r.toString();v(h)}},[r,t,s]);let T=_r(()=>{let h=t.toUpperCase();return["DATA","QUERY","QUERYKEY","TYPES","STATS","OPTIONS","OBSERVERS"].includes(h)},[t]),[x,L]=Ur((o||[]).includes(t)),m=()=>L(h=>!h),[k,E]=Ur([]),g=_r(()=>r==null||typeof r!="object"?[]:Array.isArray(r)?(r.length>1e3?r.slice(0,1e3):r).map((h,c)=>({label:c.toString(),value:h})):r instanceof Map?Array.from(r.entries()).slice(0,1e3).map(([h,c])=>({label:h.toString(),value:c})):r instanceof Set?Array.from(r).slice(0,1e3).map((h,c)=>({label:c.toString(),value:h})):Object.entries(r).slice(0,1e3).map(([h,c])=>({label:h,value:c})),[r]),I=_r(()=>Array.isArray(r)?"array":r===null||typeof r!="object"?typeof r:r instanceof Map||r instanceof Set?"Iterable":"object",[r]),D=_r(()=>yh(g,fr),[g]),H=n??[],S=Vo(l),z=Vo(H),w=Vo(I);S.current=l,z.current=H,w.current=I;let p=pr((h,c)=>{v(c);let y=S.current;if(!y||h&&isNaN(Number(c)))return;let O=w.current==="number"?Number(c):c;y.onChange(Rt(y.root,z.current,O))},[v]);return G(f,{style:F.minWidthWrapper,children:Pe(f,{style:F.fullWidthMarginRight,children:[D.length>0&&Pe(Gr,{children:[Pe(f,{style:[F.flexRowItemsCenterGap,T&&F.flexRowItemsCenterGapMain],children:[Pe(N,{"sentry-label":"ignore devtools explorer expander button",style:F.expanderButton,onPress:m,hitSlop:Ft,activeOpacity:.6,children:[G(Uo,{expanded:x,isFocused:a,isMain:T}),G(b,{style:[F.labelText,a&&F.labelTextFocused,T&&F.labelTextMain],children:t}),G(b,{style:F.textGray500,children:`${String(I).toLowerCase()==="iterable"?"(Iterable) ":""}${g.length} ${g.length>1?"items":"item"}`})]}),e&&Pe(f,{style:F.flexRowGapItemsCenter,children:[G(as,{value:r,isFocused:a}),i&&l!==null&&G(_o,{dataPath:H,isFocused:a}),I==="array"&&l!==null&&G(ls,{dataPath:H,isFocused:a})]})]}),x&&Pe(Gr,{children:[D.length===1&&G(f,{style:[F.singleEntryContainer,T&&F.singleEntryContainerMain],children:g.map((h,c)=>G(Xo,{defaultExpanded:o,label:h.label,value:h.value,editable:e,dataPath:[...H,h.label],itemsDeletable:I==="array"||I==="Iterable"||I==="object",dataVersion:s},h.label+c))}),D.length>1&&G(f,{style:F.multiEntryContainer,children:D.map((h,c)=>G(f,{children:Pe(f,{style:F.relativeOutlineNone,children:[Pe(N,{"sentry-label":"ignore devtools explorer page toggle",onPress:()=>E(y=>y.includes(c)?y.filter(O=>O!==c):[...y,c]),style:F.pageExpanderButton,hitSlop:Ft,children:[G(Uo,{expanded:k.includes(c)}),Pe(b,{style:F.pageRangeText,children:["[",c*fr,"...",c*fr+fr-1,"]"]})]}),k.includes(c)&&G(f,{style:F.entriesContainer,children:h.map(y=>G(Xo,{defaultExpanded:o,label:y.label,value:y.value,editable:e,dataPath:[...H,y.label],dataVersion:s},y.label))})]})},c))})]})]}),D.length===0&&Pe(f,{style:F.flexRowGapFullWidth,children:[e&&l!==null&&(I==="string"||I==="number"||I==="boolean")?Pe(Gr,{children:[e&&l&&(I==="string"||I==="number")&&G(f,{style:F.nebulaInputWrapper,children:G(fh,{label:t,accessibilityLabel:"Data input field for editing values",style:[I==="number"?F.textNumber:F.textString],keyboardType:I==="number"?"numeric":"default",value:u,onChangeText:h=>p(I==="number",h),onFocus:()=>d(true),onBlur:()=>d(false),showNumberControls:I==="number",onIncrement:()=>{let h=Number(u)||0;p(true,String(h+1))},onDecrement:()=>{let h=Number(u)||0;p(true,String(h-1))},showDeleteButton:i,onDelete:()=>{l.onChange(Et(l.root,H))}})}),I==="boolean"&&Pe(f,{style:F.booleanRowContainer,children:[G(b,{style:F.booleanLabel,children:t}),G(f,{style:F.booleanToggleWrapper,children:G(bh,{dataPath:H,value:r,itemsDeletable:i})})]})]}):Pe(Gr,{children:[G(b,{style:F.text344054,children:t}),G(b,{style:F.displayValueText,children:uh(r)})]}),e&&i&&l!==null&&I!=="string"&&I!=="number"&&I!=="boolean"&&G(_o,{dataPath:H,isFocused:a})]})]})})}var F=he.create({buttonStyle:{backgroundColor:P.card+"E6",borderWidth:1,borderColor:P.textSecondary+"33",borderRadius:6,flexDirection:"row",alignItems:"center",justifyContent:"center",width:28,height:28,position:"relative",shadowColor:"#000",shadowOffset:{width:0,height:1},shadowOpacity:.2,shadowRadius:2},buttonStyleFocused:{borderColor:P.primary+"CC",backgroundColor:P.primary+"26",shadowColor:P.primary,shadowOpacity:.3,shadowRadius:4},deleteButton:{backgroundColor:P.error+"1A",borderColor:P.error+"4D",borderWidth:1,borderRadius:6,padding:0,alignItems:"center",justifyContent:"center",width:28,height:28,position:"relative",shadowColor:P.error,shadowOffset:{width:0,height:0},shadowOpacity:.15,shadowRadius:3},deleteButtonFocused:{borderColor:P.error+"CC",backgroundColor:P.error+"33",shadowOpacity:.3,shadowRadius:5},deleteButtonInToggle:{backgroundColor:P.error+"1A",borderColor:P.error+"4D",borderWidth:1,borderRadius:6,padding:0,alignItems:"center",justifyContent:"center",width:28,height:28,shadowColor:P.error,shadowOffset:{width:0,height:0},shadowOpacity:.15,shadowRadius:3},clearButton:{backgroundColor:P.warning+"1A",borderWidth:1,borderColor:P.warning+"4D",borderRadius:6,flexDirection:"row",padding:0,alignItems:"center",justifyContent:"center",width:28,height:28,position:"relative",zIndex:10,shadowColor:P.warning,shadowOffset:{width:0,height:0},shadowOpacity:.15,shadowRadius:3},clearButtonFocused:{borderColor:P.warning+"CC",backgroundColor:P.warning+"33",shadowOpacity:.3,shadowRadius:5},clearButtonText:{fontSize:12,fontWeight:"700",fontFamily:qe},expanderIcon:{width:18,height:18,alignItems:"center",justifyContent:"center",marginRight:1,backgroundColor:P.textSecondary+"14",borderRadius:3},expanderIconMain:{backgroundColor:P.textSecondary+"1A",width:20,height:20,borderRadius:4,borderWidth:.5,borderColor:P.textSecondary+"33"},expanded:{transform:[{rotate:"0deg"}]},collapsed:{transform:[{rotate:"0deg"}]},minWidthWrapper:{minWidth:180,fontSize:11,flexDirection:"row",flexWrap:"wrap",width:"100%",marginVertical:.5},fullWidthMarginRight:{position:"relative",width:"100%",marginRight:1},flexRowItemsCenterGap:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:3,paddingHorizontal:6,marginVertical:1,borderRadius:4,backgroundColor:P.card+"66",borderWidth:.5,borderColor:P.textSecondary+"1A"},flexRowItemsCenterGapMain:{backgroundColor:P.card+"E6",borderLeftWidth:2.5,borderLeftColor:P.textSecondary+"80",borderColor:P.textSecondary+"26",paddingVertical:5,paddingHorizontal:8,marginBottom:3,borderWidth:1,shadowColor:"#000",shadowOffset:{width:0,height:0},shadowOpacity:.08,shadowRadius:3},expanderButton:{flexDirection:"row",alignItems:"center",backgroundColor:"transparent",paddingVertical:1,paddingHorizontal:2,gap:6,borderWidth:0,minHeight:24,flex:1},labelText:{color:P.textSecondary,fontSize:10,fontWeight:"600",marginRight:4,fontFamily:qe,letterSpacing:.4},labelTextFocused:{color:P.text},labelTextMain:{color:P.text,fontSize:11,fontWeight:"700",letterSpacing:.6},textGray500:{color:P.textMuted,fontSize:10,fontWeight:"400",fontFamily:qe,opacity:.7},pageRangeText:{color:P.textSecondary,fontSize:10,fontWeight:"600",fontFamily:qe},flexRowGapItemsCenter:{flexDirection:"row",alignItems:"center",gap:4,paddingLeft:2},singleEntryContainer:{marginLeft:2,marginTop:2,paddingLeft:8,borderLeftWidth:1.5,borderLeftColor:P.textSecondary+"40"},singleEntryContainerMain:{borderLeftColor:P.textSecondary+"4D",marginLeft:4,paddingLeft:10},multiEntryContainer:{marginLeft:2,marginTop:2,paddingLeft:8,borderLeftWidth:1.5,borderLeftColor:P.textSecondary+"40"},multiEntryContainerMain:{borderLeftColor:P.textSecondary+"4D",marginLeft:4,paddingLeft:10},relativeOutlineNone:{position:"relative"},pageExpanderButton:{flexDirection:"row",alignItems:"center",backgroundColor:P.card+"66",paddingVertical:3,paddingHorizontal:6,gap:6,borderRadius:4,borderWidth:.5,borderColor:P.textSecondary+"1A",marginBottom:2,minHeight:24},entriesContainer:{marginLeft:2,paddingLeft:8,marginTop:2,borderLeftWidth:1.5,borderLeftColor:P.textSecondary+"40"},textNumber:{color:P.text,fontWeight:"600",fontFamily:qe},textString:{color:P.text,fontFamily:qe},flexRowGapFullWidth:{flexDirection:"row",width:"100%",alignItems:"center",marginVertical:1,gap:6,paddingHorizontal:4,paddingVertical:2,borderRadius:3},text344054:{color:P.textSecondary,fontWeight:"600",fontSize:9,minWidth:50,fontFamily:qe,letterSpacing:.4,opacity:.8},numberInputButtons:{position:"absolute",right:8,top:"50%",transform:[{translateY:-18}],flexDirection:"row",gap:4,zIndex:10},touchableButton:{width:32,height:32,borderRadius:6,backgroundColor:P.card+"E6",borderWidth:1,borderColor:P.textSecondary+"33",alignItems:"center",justifyContent:"center",marginLeft:2,shadowColor:"#000",shadowOffset:{width:0,height:1},shadowOpacity:.2,shadowRadius:2},touchableButtonFocused:{borderColor:P.primary+"CC",backgroundColor:P.primary+"26",shadowColor:P.primary,shadowOffset:{width:0,height:0},shadowOpacity:.3,shadowRadius:4,elevation:3},nebulaInputWrapper:{flex:1,width:"100%",position:"relative"},displayValueText:{flex:1,color:P.text,fontWeight:"400",fontFamily:qe,fontSize:12,paddingVertical:6,paddingHorizontal:10,borderRadius:6,borderWidth:1,borderColor:P.textMuted+"66",minHeight:34},dataRow:{flexDirection:"row",alignItems:"center",paddingVertical:4,paddingHorizontal:8,minHeight:44,gap:12},dataLabel:{color:P.textSecondary,fontSize:13,fontWeight:"500",minWidth:80,flexShrink:0},dataValueContainer:{flex:1,flexDirection:"row",alignItems:"center"},inputWithActions:{flex:1,position:"relative"},numberControls:{position:"absolute",right:8,top:"50%",transform:[{translateY:-16}],flexDirection:"column",gap:2},numberButton:{width:32,height:16,borderRadius:4,alignItems:"center",justifyContent:"center",borderWidth:1,borderColor:P.primary+"0F"},readOnlyValue:{color:P.text,fontSize:13,fontFamily:qe,paddingVertical:8,paddingHorizontal:12,borderRadius:6,borderWidth:1,borderColor:P.textMuted+"33",flex:1},actionButtons:{flexDirection:"row",gap:6,paddingLeft:8},booleanContainer:{flexDirection:"row",alignItems:"center",padding:8,borderRadius:6,borderWidth:1,borderColor:P.textMuted+"4D",flex:1},booleanText:{marginLeft:8,color:P.warning,fontWeight:"500",fontFamily:qe},modernToggleButton:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",borderRadius:6,borderWidth:1,borderColor:P.textMuted+"99",paddingHorizontal:8,paddingVertical:6,marginVertical:2,minHeight:34,gap:8},toggleIconContainer:{marginRight:6},toggleIcon:{padding:8,borderRadius:8,alignItems:"center",justifyContent:"center",width:32,height:32},toggleIconSmall:{width:8,height:8,borderRadius:4},toggleContent:{flex:1,minWidth:0},toggleLabel:{color:"#E5E7EB",fontSize:11,fontWeight:"600",fontFamily:qe,letterSpacing:.3},toggleStatus:{color:"#9CA3AF",fontSize:11},toggleBadge:{marginLeft:6,paddingHorizontal:6,paddingVertical:3,borderRadius:4,borderWidth:1},toggleBadgeText:{fontSize:9,fontWeight:"700",textTransform:"uppercase",letterSpacing:.8,fontFamily:qe},toggleIconTrue:{backgroundColor:P.primary},toggleIconFalse:{backgroundColor:P.textMuted},toggleBadgeTrue:{backgroundColor:P.primary+"1A",borderColor:P.primary+"4D"},toggleBadgeFalse:{backgroundColor:P.textMuted+"1A",borderColor:P.textMuted+"4D"},toggleTextTrue:{color:P.primary,fontWeight:"600"},toggleTextFalse:{color:P.textSecondary,fontWeight:"500"},booleanRowContainer:{flexDirection:"row",alignItems:"center",width:"100%",gap:8,paddingVertical:2},booleanLabel:{color:P.textSecondary,fontSize:10,fontWeight:"600",fontFamily:qe,letterSpacing:.4,minWidth:60,flexShrink:0},booleanToggleWrapper:{flex:1}});q();pe();import{useState as vh}from"react";import{absoluteFill as ds,macOSColors as Be}from"@buoy-gg/shared-ui/web";import{jsx as at,jsxs as Jo}from"react/jsx-runtime";function Go({title:e,hint:t,value:r,placeholder:o="Number",min:n,max:i,onSubmit:s,onCancel:l}){let[a,d]=vh(r!=null?String(r):""),u=()=>{let v=a.trim();if(!v){s(null);return}let T=Number(v);if(!Number.isFinite(T)){s(null);return}let x=T;n!=null&&(x=Math.max(n,x)),i!=null&&(x=Math.min(i,x)),s(x)};return Jo(f,{style:Oe.overlay,children:[at(N,{style:Oe.backdrop,activeOpacity:1,onPress:l,"sentry-label":"ignore dismiss number prompt"}),Jo(f,{style:Oe.panel,children:[at(b,{style:Oe.title,children:e}),at(zt,{style:Oe.input,value:a,onChangeText:d,placeholder:o,placeholderTextColor:Be.text.muted,keyboardType:"number-pad",autoFocus:true,selectTextOnFocus:true,onSubmitEditing:u,returnKeyType:"done","sentry-label":"ignore number prompt input",accessibilityLabel:e}),t?at(b,{style:Oe.hint,children:t}):null,Jo(f,{style:Oe.actions,children:[at(N,{onPress:l,"sentry-label":"ignore cancel number prompt",style:[Oe.button,Oe.cancelButton],children:at(b,{style:Oe.cancelText,children:"Cancel"})}),at(N,{onPress:u,"sentry-label":"ignore save number prompt",style:[Oe.button,Oe.saveButton],children:at(b,{style:Oe.saveText,children:"Set"})})]})]})]})}var Oe=he.create({overlay:{...ds,zIndex:40},backdrop:{...ds,backgroundColor:"rgba(0,0,0,0.6)"},panel:{marginHorizontal:12,marginTop:12,padding:14,borderRadius:10,borderWidth:1,borderColor:Be.border.hover,backgroundColor:Be.background.card,gap:10},title:{fontSize:13,fontWeight:"700",color:Be.text.primary},input:{backgroundColor:Be.background.input,borderWidth:1,borderColor:Be.border.input,borderRadius:6,paddingHorizontal:12,paddingVertical:10,fontSize:16,fontWeight:"700",color:Be.text.primary},hint:{fontSize:10,color:Be.text.muted},actions:{flexDirection:"row",gap:8},button:{flex:1,paddingVertical:10,borderRadius:6,alignItems:"center",borderWidth:1},cancelButton:{borderColor:Be.border.default,backgroundColor:Be.background.base},cancelText:{fontSize:12,fontWeight:"600",color:Be.text.secondary},saveButton:{borderColor:Be.semantic.info,backgroundColor:`${Be.semantic.info}22`},saveText:{fontSize:12,fontWeight:"700",color:Be.semantic.info}});import{Fragment as us,jsx as V,jsxs as Ce}from"react/jsx-runtime";var Sh=["GET","POST","PUT","PATCH","DELETE"],cs=[0,500,1e3,3e3,1e4],hs=[{id:"500",label:"Server error",code:"500",danger:true,patch:{kind:"respond",status:500,statusText:"Internal Server Error"}},{id:"401",label:"Unauthorized",code:"401",danger:true,patch:{kind:"respond",status:401,statusText:"Unauthorized"}},{id:"404",label:"Not found",code:"404",danger:true,patch:{kind:"respond",status:404,statusText:"Not Found"}},{id:"403",label:"Forbidden",code:"403",danger:true,patch:{kind:"respond",status:403,statusText:"Forbidden"}},{id:"429",label:"Rate limited",code:"429",danger:true,patch:{kind:"respond",status:429,statusText:"Too Many Requests"}},{id:"503",label:"Unavailable",code:"503",danger:true,patch:{kind:"respond",status:503,statusText:"Service Unavailable"}},{id:"400",label:"Bad request",code:"400",danger:true,patch:{kind:"respond",status:400,statusText:"Bad Request"}},{id:"200",label:"Success",code:"200",patch:{kind:"respond",status:200,statusText:"OK"}},{id:"offline",label:"Offline",danger:true,patch:{kind:"fail",failKind:"network"}},{id:"timeout",label:"Timeout",danger:true,patch:{kind:"fail",failKind:"timeout"}},{id:"passthrough",label:"Real response",patch:{kind:"delay"}}];function xh(e){return e.kind==="delay"?"passthrough":e.kind==="fail"?e.failKind==="timeout"?"timeout":"offline":String(e.status??200)}function wh({outcome:e,active:t,onPress:r}){let o=e.danger?_.semantic.error:_.semantic.info;return Ce(N,{onPress:r,"sentry-label":"ignore override outcome",testID:`buoy-network-outcome-${e.label.toLowerCase().replace(/\s+/g,"-")}${e.code?`-${e.code}`:""}`,accessibilityRole:"button",accessibilityLabel:`${e.label}${e.code?` ${e.code}`:""}`,style:[M.outcome,t&&{borderColor:o,backgroundColor:`${o}1F`}],children:[V(b,{style:[M.outcomeLabel,t&&{color:o}],children:e.label}),e.code?V(b,{style:[M.outcomeCode,t&&{color:o}],children:e.code}):null]})}function ps({title:e,summary:t,open:r,onToggle:o,children:n}){return Ce(f,{style:M.disclosure,children:[Ce(N,{onPress:o,"sentry-label":"ignore override disclosure",testID:`buoy-network-disclosure-${e.toLowerCase().replace(/\s+/g,"-")}`,accessibilityRole:"button",accessibilityLabel:e,style:M.disclosureHeader,children:[r?V(ih,{size:12,color:_.text.muted}):V(sh,{size:12,color:_.text.muted}),V(b,{style:M.disclosureTitle,children:e}),t&&!r?V(b,{style:M.disclosureSummary,numberOfLines:1,children:t}):null]}),r?V(f,{style:M.disclosureBody,children:n}):null]})}function Wt({label:e,active:t,onPress:r}){return V(N,{onPress:r,"sentry-label":"ignore override chip",testID:`buoy-network-chip-${e.toLowerCase().replace(/\s+/g,"-")}`,accessibilityRole:"button",accessibilityLabel:e,style:[M.chip,t&&M.chipActive],children:V(b,{style:[M.chipText,t&&M.chipTextActive],children:e})})}function Th({draft:e,onChange:t,onSave:r,onCancel:o,saveLabel:n="Save",applySafeAreaInset:i=false}){let s=ah({minBottom:16}),l=i?s.bottom:0,a=y=>t({...e,...y}),[d,u]=Vr(!e.urlPattern.trim()),[v,T]=Vr(false),[x,L]=Vr(null),[m,k]=Vr(null),E=xh(e),g=e.kind==="respond"&&typeof e.status=="number"&&!hs.some(y=>y.code===String(e.status)),I=e.kind==="respond",D=e.methods?.[0],H=`${D??"Any"} ${e.urlPattern||"No URL yet"}`,S=os(()=>{let y=(e.body??"").trim();if(!y)return"Empty";let O=y.split(`
143
- `).length;return`${O} line${O===1?"":"s"}`},[e.body]),z=os(()=>{let y=(e.body??"").trim();if(!y)return null;try{return JSON.parse(y)}catch{return null}},[e.body]),w=(e.body??"").trim().length>0&&!z,p=e.delayMs??0,h=p>0&&!cs.includes(p),c=!e.alternate&&typeof e.times=="number"&&e.times!==1;return Ce(f,{style:M.root,children:[Ce(ht,{testID:"buoy-network-editor-scroll",style:M.scroll,contentContainerStyle:M.scrollContent,keyboardShouldPersistTaps:"handled",children:[Ce(ps,{title:"Applies to",summary:H,open:d,onToggle:()=>u(y=>!y),children:[V(zt,{style:M.input,value:e.urlPattern,onChangeText:y=>a({urlPattern:y}),testID:"buoy-network-override-pattern",accessibilityLabel:"Override URL pattern",placeholder:"https://api.example.com/v1/users*",placeholderTextColor:_.text.muted,autoCapitalize:"none",autoCorrect:false,multiline:true,"sentry-label":"ignore override url pattern"}),Ce(f,{style:M.chipRow,children:[V(Wt,{label:"Any",active:!D,onPress:()=>a({methods:void 0})}),Sh.map(y=>V(Wt,{label:y,active:D===y,onPress:()=>a({methods:[y]})},y))]})]}),Ce(f,{style:M.outcomeGrid,children:[hs.map(y=>V(wh,{outcome:y,active:E===y.id,onPress:()=>a(y.patch)},y.id)),V(N,{onPress:()=>k("status"),"sentry-label":"ignore custom status",accessibilityLabel:"Custom status code",style:[M.customField,g&&M.customFieldActive],children:V(b,{style:[M.customValue,g&&M.customInputActive],children:g?String(e.status):"Custom"})})]}),I?V(ps,{title:"Response body",summary:S,open:v,onToggle:()=>T(y=>!y),children:x!==null?Ce(us,{children:[V(zt,{style:[M.input,M.bodyInput],value:x,onChangeText:L,placeholder:"Paste a new body\u2026",placeholderTextColor:_.text.muted,autoCapitalize:"none",autoCorrect:false,autoFocus:true,multiline:true,"sentry-label":"ignore override body paste"}),Ce(f,{style:M.inlineActions,children:[V(N,{onPress:()=>L(null),"sentry-label":"ignore cancel body paste",style:M.textButton,children:V(b,{style:M.textButtonMuted,children:"Cancel"})}),V(N,{onPress:()=>{let y=x.trim();try{a({body:JSON.stringify(JSON.parse(y),null,2)})}catch{a({body:y})}L(null)},disabled:!x.trim(),"sentry-label":"ignore apply body paste",style:M.textButton,children:V(b,{style:[M.textButtonLabel,!x.trim()&&M.textButtonDisabled],children:"Replace"})})]})]}):Ce(us,{children:[z!==null?V(is.Provider,{value:{root:z,onChange:y=>a({body:JSON.stringify(y,null,2)})},children:V(Xo,{editable:true,label:"",value:z,defaultExpanded:[""]})}):V(b,{style:M.emptyBody,children:w?"This body isn't JSON, so there's no tree to show.":"No body yet."}),V(N,{onPress:()=>L(""),"sentry-label":"ignore edit all body",style:M.textButton,children:V(b,{style:M.textButtonLabel,children:"Edit all"})})]})}):null,Ce(f,{style:M.field,children:[V(b,{style:M.subLabel,children:"Delay"}),Ce(f,{style:M.chipRow,children:[cs.map(y=>V(Wt,{label:y===0?"None":`${y/1e3}s`,active:p===y,onPress:()=>a({delayMs:y})},y)),V(N,{onPress:()=>k("delay"),"sentry-label":"ignore custom delay",accessibilityLabel:"Custom delay in seconds",style:[M.customField,h&&M.customFieldActive],children:V(b,{style:[M.customValue,h&&M.customInputActive],children:h?`${p/1e3}s`:"Custom"})})]})]}),Ce(f,{style:M.field,children:[V(b,{style:M.subLabel,children:"Fires"}),V(b,{style:M.subHint,children:"A limited rule switches itself off once it's used up. Every other alternates forever \u2014 the first request through, the next overridden."}),Ce(f,{style:M.chipRow,children:[V(Wt,{label:"Always",active:!e.alternate&&e.times==null,onPress:()=>a({alternate:false,times:null})}),V(Wt,{label:"Once",active:!e.alternate&&e.times===1,onPress:()=>a({alternate:false,times:1})}),V(Wt,{label:"Every other",active:e.alternate===true,onPress:()=>a({alternate:true,times:null})}),V(N,{onPress:()=>{a({alternate:false}),k("times")},"sentry-label":"ignore custom times",accessibilityLabel:"Custom number of times",style:[M.customField,c&&M.customFieldActive],children:V(b,{style:[M.customValue,c&&M.customInputActive],children:c?`${e.times}\xD7`:"Custom"})})]})]})]}),m==="status"?V(Go,{title:"Custom status code",hint:`${Qt}\u2013${Zt}`,value:g?e.status:void 0,min:Qt,max:Zt,onSubmit:y=>{a({kind:"respond",status:y??void 0,statusText:void 0}),k(null)},onCancel:()=>k(null)}):null,m==="delay"?V(Go,{title:"Custom delay",hint:"Seconds",value:h?p/1e3:void 0,min:0,onSubmit:y=>{a({delayMs:y!=null?Math.round(y*1e3):0}),k(null)},onCancel:()=>k(null)}):null,m==="times"?V(Go,{title:"Fires how many times",hint:"Leave empty for always",value:c?e.times:void 0,min:1,onSubmit:y=>{a({alternate:false,times:y&&y>0?y:null}),k(null)},onCancel:()=>k(null)}):null,Ce(f,{style:[M.footer,{paddingBottom:12+l}],children:[V(N,{onPress:o,"sentry-label":"ignore cancel override",testID:"buoy-network-editor-cancel",accessibilityRole:"button",accessibilityLabel:"Cancel",style:[M.footerButton,M.cancelButton],children:V(b,{style:M.cancelText,children:"Cancel"})}),V(N,{onPress:r,disabled:!e.urlPattern.trim(),"sentry-label":"ignore save override",testID:"buoy-network-editor-save",accessibilityRole:"button",accessibilityLabel:n,style:[M.footerButton,M.saveButton,!e.urlPattern.trim()&&M.saveButtonDisabled],children:V(b,{style:M.saveText,children:n})})]})]})}var M=he.create({root:{flex:1},scroll:{flex:1},scrollContent:{padding:12,paddingBottom:24,gap:4},field:{gap:8,paddingVertical:6},outcomeGrid:{flexDirection:"row",flexWrap:"wrap",gap:6,paddingVertical:10},outcome:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:9,borderRadius:6,borderWidth:1,borderColor:_.border.default,backgroundColor:_.background.card},outcomeLabel:{fontSize:12,fontWeight:"600",color:_.text.primary},outcomeCode:{fontSize:10,fontWeight:"700",color:_.text.muted},disclosure:{borderRadius:6,borderWidth:1,borderColor:_.border.default,backgroundColor:_.background.card,overflow:"hidden"},disclosureHeader:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:10},disclosureTitle:{fontSize:12,fontWeight:"600",color:_.text.primary},disclosureSummary:{flex:1,textAlign:"right",fontSize:11,color:_.text.muted},disclosureBody:{paddingHorizontal:10,paddingBottom:10,gap:8},input:{backgroundColor:_.background.input,borderWidth:1,borderColor:_.border.input,borderRadius:6,paddingHorizontal:10,paddingVertical:8,color:_.text.primary,fontSize:12,fontFamily:lh,minHeight:40},bodyInput:{minHeight:140,textAlignVertical:"top"},chipRow:{flexDirection:"row",flexWrap:"wrap",gap:6},chip:{paddingHorizontal:10,paddingVertical:6,borderRadius:5,borderWidth:1,borderColor:_.border.default,backgroundColor:_.background.base},chipActive:{borderColor:_.semantic.info,backgroundColor:`${_.semantic.info}1F`},chipText:{fontSize:11,fontWeight:"600",color:_.text.secondary},chipTextActive:{color:_.semantic.info},customField:{flexDirection:"row",alignItems:"center",paddingHorizontal:8,borderRadius:5,borderWidth:1,borderColor:_.border.default,backgroundColor:_.background.base},customFieldActive:{borderColor:_.semantic.info,backgroundColor:`${_.semantic.info}1F`},customValue:{paddingVertical:6,fontSize:11,fontWeight:"600",color:_.text.secondary},customInputActive:{color:_.semantic.info},subHint:{fontSize:10,lineHeight:14,color:_.text.muted,marginTop:-2},subLabel:{fontSize:10,fontWeight:"700",letterSpacing:.6,color:_.text.muted,textTransform:"uppercase"},textButton:{alignSelf:"flex-start",paddingVertical:4},textButtonLabel:{fontSize:11,fontWeight:"600",color:_.semantic.info},textButtonMuted:{fontSize:11,fontWeight:"600",color:_.text.secondary},textButtonDisabled:{opacity:.4},inlineActions:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},emptyBody:{fontSize:11,color:_.text.muted,paddingVertical:6},footer:{flexDirection:"row",gap:8,padding:12,borderTopWidth:1,borderTopColor:_.border.default,backgroundColor:_.background.base},footerButton:{flex:1,paddingVertical:11,borderRadius:6,alignItems:"center",borderWidth:1},cancelButton:{borderColor:_.border.default,backgroundColor:_.background.card},cancelText:{fontSize:12,fontWeight:"600",color:_.text.secondary},saveButton:{borderColor:_.semantic.info,backgroundColor:`${_.semantic.info}22`},saveButtonDisabled:{opacity:.4},saveText:{fontSize:12,fontWeight:"700",color:_.semantic.info}});import{jsx as de,jsxs as It}from"react/jsx-runtime";function Ch(){return{enabled:true,urlPattern:"",kind:"respond",status:500,body:"",times:null}}function kh(e){let{id:t,hits:r,seen:o,createdAt:n,...i}=e;return i}function Rh(e){let t=e.urlPattern,r=t.indexOf("://");if(r===-1)return t;let o=t.indexOf("/",r+3);return o===-1?t.slice(r+3):t.slice(o)}function Eh(e){let t=[];return e.delayMs&&t.push(`${e.delayMs/1e3}s delay`),e.alternate?t.push("every other"):e.times===1?t.push("once"):typeof e.times=="number"&&t.push(`${e.times}\xD7`),t.join(" \xB7 ")}function Ih(e){if(e.kind==="fail")return Q.semantic.error;if(e.kind==="delay")return Q.semantic.info;let t=e.status??200;return t>=200&&t<300?Q.semantic.success:t>=300&&t<400?Q.semantic.info:Q.semantic.error}function Ph({rule:e,spent:t,onEdit:r,onDelete:o}){let n=e.enabled&&!t,i=Ih(e),s=Eh(e),l=e.methods?.length?e.methods.join("/"):"ANY";return It(Zc,{onPress:r,style:se.cardWrapper,contentStyle:[se.card,{borderLeftColor:n?i:"transparent"}],children:[de(eh,{method:l,size:"small"}),It(f,{style:se.cardMiddle,children:[de(b,{style:[se.urlText,!n&&se.urlTextOff],numberOfLines:2,children:Rh(e)}),s?de(b,{style:se.extrasText,children:s}):null]}),e.hits>0?de(b,{style:se.rowHits,children:e.hits}):null,e.kind==="fail"?It(f,{style:se.failBadge,children:[de(Kc,{size:10,color:Q.semantic.error}),de(b,{style:se.failText,children:e.failKind==="timeout"?"TIMEOUT":"OFFLINE"})]}):de(b,{style:[se.statusText,{color:i}],children:e.kind==="delay"?"PASS":String(e.status??200)}),de(N,{onPress:o,"sentry-label":"ignore delete override rule",testID:"buoy-network-rule-delete",accessibilityRole:"button",accessibilityLabel:"Delete rule",hitSlop:{top:8,bottom:8,left:4,right:4},style:se.rowDelete,children:de(rh,{size:13,color:Q.text.muted})})]})}function Bh(e){return e.visible?de(Lh,{...e}):null}function Lh({isPro:e,onUpgradePress:t,pendingDraft:r,onPendingConsumed:o,backHandlerRef:n,applySafeAreaInset:i}){let s=oh("network.overrideRules"),l=e?Fe:s,{enabled:a,autoPaused:d,rules:u,activeCount:v,setEnabled:T,upsertRule:x,setRuleEnabled:L,removeRule:m,isRuleSpent:k}=jr(),[E,g]=Gc(null);Wr(()=>{U.noteHealthyLaunch()},[]),Wr(()=>{if(n)return n.current=E?()=>(g(null),true):null,()=>{n.current=null}},[n,E]);let I=Jc(w=>{U.fetchRuleBody(w).then(p=>{p!=null&&g(h=>h?.id===w?{...h,draft:{...h.draft,body:p,bodyOmitted:void 0}}:h)})},[]);Wr(()=>{if(!r)return;let{id:w,...p}=r;g({id:w,draft:p}),w&&p.bodyOmitted&&I(w),o?.()},[r,o,I]),Wr(()=>{E?.id&&(u.some(w=>w.id===E.id)||g(null))},[E?.id,u]);let D=w=>{g({id:w.id,draft:kh(w)}),w.bodyOmitted&&I(w.id)},H=w=>{u.filter(p=>p.enabled&&!k(p)).length<=l||u.filter(p=>p.enabled&&!k(p)&&p.id!==w).forEach(p=>L(p.id,false))},S=()=>{if(!E)return;let w={...E.draft,enabled:true,urlPattern:E.draft.urlPattern.trim()};if(!w.urlPattern)return;let p=x({...w,id:E.id});H(p?.id??E.id),T(true),g(null)};if(E)return de(Th,{draft:E.draft,onChange:w=>g({...E,draft:w}),onSave:S,onCancel:()=>g(null),saveLabel:E.id?"Save":"Add",applySafeAreaInset:i});let z=u.length>0;return It(f,{style:se.root,children:[z?It(f,{style:[se.bar,a&&v>0&&se.barOn],children:[a&&v>0?de(Qc,{size:12,color:Q.semantic.warning}):null,de(b,{style:[se.barText,a&&v>0&&se.barTextOn],numberOfLines:2,children:d?"Overrides paused \u2014 they'd been on for 3 launches":a&&v>0?`${v} override${v===1?" is":"s are"} on`:"Overrides are off"}),de(N,{onPress:()=>T(!(a&&v>0)),"sentry-label":"ignore toggle overrides master",testID:"buoy-network-overrides-master",accessibilityRole:"button",style:se.barButton,children:de(b,{style:se.barButtonText,children:a&&v>0?"Turn all off":d?"Turn back on":"Turn on"})})]}):null,It(f,{style:se.listHeader,children:[de(b,{style:se.listHeaderText,children:z?`${u.length} rule${u.length===1?"":"s"}`:""}),de(N,{onPress:()=>g({draft:Ch()}),"sentry-label":"ignore new override rule",accessibilityLabel:"New override rule",style:se.newButton,children:de(th,{size:14,color:Q.semantic.info})})]}),z?It(ht,{style:se.list,contentContainerStyle:se.listContent,keyboardShouldPersistTaps:"handled",children:[u.map(w=>de(Ph,{rule:w,spent:k(w),onEdit:()=>D(w),onDelete:()=>m(w.id)},w.id)),l<Fe?de(b,{style:se.footNote,children:`Your plan: ${l} override at a time. Pro: up to ${Fe}.`}):null]}):de(f,{style:se.emptyWrap,children:de(Yc,{otto:"empty",iconSize:32,title:"Nothing overridden",description:"Open any request and tap Override, or + to write a rule."})})]})}var se=he.create({root:{flex:1},bar:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingVertical:10,borderBottomWidth:1,borderBottomColor:Q.border.default,backgroundColor:Q.background.card},barOn:{borderBottomColor:Q.semantic.warning+"44",backgroundColor:Q.semantic.warningBackground},barText:{flex:1,fontSize:12,fontWeight:"600",color:Q.text.secondary},barTextOn:{color:Q.semantic.warning},barButton:{paddingHorizontal:10,paddingVertical:6,borderRadius:5,borderWidth:1,borderColor:Q.border.hover,backgroundColor:Q.background.base},barButtonText:{fontSize:11,fontWeight:"700",color:Q.text.primary},listHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingTop:10,paddingBottom:4},listHeaderText:{fontSize:10,fontWeight:"700",letterSpacing:.6,color:Q.text.muted,textTransform:"uppercase"},newButton:{padding:6,borderRadius:5,borderWidth:1,borderColor:Q.border.default,backgroundColor:Q.background.card},emptyWrap:{flex:1,justifyContent:"center"},list:{flex:1},listContent:{padding:10,gap:6},cardWrapper:{marginHorizontal:0,marginVertical:0},card:{flexDirection:"row",alignItems:"center",gap:8,borderLeftWidth:3,borderLeftColor:"transparent"},cardMiddle:{flex:1},urlText:{fontSize:12,color:Q.text.primary,lineHeight:16,fontFamily:nh},urlTextOff:{color:Q.text.muted},extrasText:{fontSize:10,color:Q.text.secondary,marginTop:2},statusText:{fontSize:11,fontWeight:"600"},failBadge:{flexDirection:"row",alignItems:"center",gap:2,paddingHorizontal:4,paddingVertical:1,backgroundColor:Q.semantic.error+"26",borderRadius:3},failText:{fontSize:10,color:Q.semantic.error,fontWeight:"600"},rowHits:{fontSize:11,fontWeight:"700",color:Q.semantic.warning},rowDelete:{padding:5,borderRadius:5,borderWidth:1,borderColor:Q.border.default,backgroundColor:Q.background.base},footNote:{fontSize:10,lineHeight:14,color:Q.text.muted,paddingHorizontal:4,paddingTop:8}});q();pe();import{FlaskConical as qh,night as Pt}from"@buoy-gg/shared-ui/web";import{jsx as Ko,jsxs as Oh}from"react/jsx-runtime";function Dh({onPress:e}){let{activeCount:t}=jr(),r=t>0;return Oh(N,{onPress:e,"sentry-label":"ignore open overrides",testID:"buoy-network-overrides",accessibilityRole:"button",style:[Kr.button,r&&Kr.buttonActive],accessibilityLabel:r?`Response overrides \u2014 ${t} active`:"Response overrides",children:[Ko(qh,{size:14,color:r?Pt.color.warning:Pt.color.textSecondary}),r?Ko(f,{style:Kr.badge,children:Ko(b,{style:Kr.badgeText,children:t})}):null]})}var Kr=he.create({button:{width:32,height:32,borderRadius:8,alignItems:"center",justifyContent:"center",backgroundColor:Pt.color.buttonSurface,borderWidth:1,borderColor:Pt.color.border},buttonActive:{backgroundColor:Pt.color.warningSoft,borderColor:Pt.color.warning+"77"},badge:{position:"absolute",top:1,right:1,minWidth:12,height:12,borderRadius:6,paddingHorizontal:3,alignItems:"center",justifyContent:"center",backgroundColor:Pt.color.warning},badgeText:{fontSize:8,fontWeight:"800",color:"#000000"}});q();pe();import{night as Vt}from"@buoy-gg/shared-ui/web";q();function zh(e){let t=e.indexOf("?");return t===-1?e:`${e.slice(0,t)}*`}function Ah(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return""}}function Qo(e){return{enabled:true,name:void 0,urlPattern:zh(e.url),methods:[String(e.method||"GET").toUpperCase()],kind:"respond",status:e.status&&e.status>=200?e.status:200,statusText:e.statusText,body:Ah(e.responseData),times:null}}import{jsx as fs}from"react/jsx-runtime";function Hh({onOpen:e}){let t=$o(),{rules:r,isRuleSpent:o}=jr(),n=t?K.getEvents().find(l=>l.id===t)??ae.getEventById(t):null,i=n?r.find(l=>l.enabled&&!o(l)&&So(l,n.url,String(n.method||"GET")))??null:null,s=i!==null;return fs(N,{onPress:()=>{if(n){if(i){let{id:l,hits:a,seen:d,createdAt:u,...v}=i;e(v,l);return}e(Qo(n))}},"sentry-label":"ignore open overrides",testID:"buoy-network-override-request",accessibilityRole:"button",accessibilityLabel:s?"Edit the override on this request":"Override this request",style:[Qr.button,s&&Qr.buttonActive],children:fs(b,{style:[Qr.label,s&&Qr.labelActive],children:"Override"})})}var Qr=he.create({button:{paddingHorizontal:10,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:Vt.color.border,backgroundColor:Vt.color.buttonSurface},buttonActive:{borderColor:Vt.color.warning+"77",backgroundColor:Vt.color.warningSoft},label:{fontSize:11,fontWeight:"700",color:Vt.color.accent},labelActive:{color:Vt.color.warning}});q();pe();import{absoluteFill as gs,night as lt}from"@buoy-gg/shared-ui/web";import{jsx as et,jsxs as Zr}from"react/jsx-runtime";function Mh({onPress:e,isOpen:t,hasIndicator:r}){return Zr(N,{onPress:e,"sentry-label":"ignore toggle header menu",testID:"buoy-network-menu",accessibilityRole:"button",accessibilityLabel:t?"Close menu":"More actions",style:[we.button,t&&we.buttonOpen],children:[Zr(f,{style:we.dots,children:[et(f,{style:[we.dot,t&&we.dotOpen]}),et(f,{style:[we.dot,t&&we.dotOpen]}),et(f,{style:[we.dot,t&&we.dotOpen]})]}),r?et(f,{style:we.indicator}):null]})}function Nh({onClose:e,children:t}){return Zr(f,{style:we.overlay,children:[et(N,{style:we.backdrop,activeOpacity:1,onPress:e,"sentry-label":"ignore dismiss header menu"}),et(f,{style:we.panel,children:t})]})}function Zo({icon:e,label:t,detail:r,testID:o,onPress:n}){return Zr(N,{onPress:n,"sentry-label":"ignore header menu item",testID:o,accessibilityRole:"button",accessibilityLabel:t,style:we.item,children:[et(f,{style:we.itemIcon,children:e}),et(b,{style:we.itemLabel,children:t}),r?et(b,{style:we.itemDetail,children:r}):null]})}var we=he.create({button:{width:32,height:32,borderRadius:8,alignItems:"center",justifyContent:"center"},buttonOpen:{backgroundColor:lt.color.surfaceElevated},dots:{flexDirection:"column",gap:2.5,alignItems:"center"},dot:{width:3,height:3,borderRadius:2,backgroundColor:lt.color.textSecondary},dotOpen:{backgroundColor:lt.color.text},indicator:{position:"absolute",top:6,right:8,width:6,height:6,borderRadius:3,backgroundColor:lt.color.accent},overlay:{...gs,zIndex:50},backdrop:{...gs,backgroundColor:"rgba(0,0,0,0.5)"},panel:{position:"absolute",top:6,right:8,minWidth:196,paddingVertical:4,borderRadius:10,borderWidth:1,borderColor:lt.color.border,backgroundColor:lt.color.surface},item:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:11},itemIcon:{width:16,alignItems:"center"},itemLabel:{flex:1,fontSize:13,fontWeight:"600",color:lt.color.text},itemDetail:{fontSize:11,color:lt.color.textTertiary}});q();import{memo as $h,useEffect as jh,useMemo as Fh}from"react";import{EventStepperFooter as Wh,useLimit as Vh}from"@buoy-gg/shared-ui/web";import{jsx as Uh}from"react/jsx-runtime";var _h=()=>Ue.step(-1),Xh=()=>Ue.step(1),Jh=$h(function({paused:e,filter:t,ignoredPatterns:r,isPro:o,fromSaved:n,savedSearch:i,applySafeAreaInset:s}){let{visibleEvents:l}=hr({filter:t,ignoredPatterns:r,paused:e,isPro:o}),{pinnedEvents:a,pinnedLiveIds:d,savedRecords:u}=Mt(),v=Vh("network.saved"),T=Fh(()=>{if(n)return ts(u,v,i).events;let{pinned:m,rest:k}=Wo(l,a,d);return m.length===0?k:[...m,...k]},[n,u,i,o,l,a,d]);jh(()=>{Ue.setIds(Du(T))},[T]);let{index:x,total:L}=Hu();return x<0?null:Uh(Wh,{currentIndex:x,totalItems:L,itemLabel:"Request",applySafeAreaInset:s,onPrevious:_h,onNext:Xh,variant:"night"})});q();import{useEffect as Gh,useState as Kh}from"react";function Qh(e){return K.getEvents().find(t=>t.id===e)??ae.getEventById(e)}function ms(e,t={}){let{paused:r=false}=t,[o,n]=Kh(null);return Gh(()=>{if(!(!e||r))return K.subscribeToEvents(i=>{let s=i.find(l=>l.id===e);s&&n(l=>l&&l.id===e&&l.event===s?l:{id:e,event:s})})},[e,r]),e?o&&o.id===e?o.event:Qh(e):null}import{Fragment as Zh,jsx as j,jsxs as $e}from"react/jsx-runtime";function Yh({visible:e,paused:t,ignoredPatternValues:r,onTogglePattern:o,isPro:n,filter:i,ignoredPatterns:s,fromSaved:l,savedSearch:a,applySafeAreaInset:d}){let u=$o(),v=Au(),T=u!=null&&u===v,x=ms(u,{paused:t||!e});return St(()=>{e&&x&&T&&Ue.reportRendered(x.id)},[e,x,T]),e?$e(f,{style:Bt.detailRoot,children:[x?j(ki,{event:x,ignoredPatterns:r,onTogglePattern:o,showBodies:T}):j(f,{style:Bt.detailBodyFallback}),j(Jh,{paused:t,filter:i,ignoredPatterns:s,isPro:n,fromSaved:l,savedSearch:a,applySafeAreaInset:d})]}):null}function ep({visible:e,paused:t,isPro:r,filter:o,onFilterChange:n,ignoredPatterns:i,onRemovePattern:s,onAddPattern:l,onTogglePatternMode:a,isTeamPattern:d}){let{events:u}=hr({filter:o,ignoredPatterns:i,paused:t,visible:e,isPro:r});return e?j(bd,{events:u,filter:o,onFilterChange:n,ignoredPatterns:i,onRemovePattern:s,onAddPattern:l,onTogglePatternMode:a,isTeamPattern:d}):null}function tp({visible:e,paused:t,isPro:r,filter:o,ignoredPatterns:n,settings:i,onSettingsChange:s}){let{events:l}=hr({filter:o,ignoredPatterns:n,paused:t,visible:e,isPro:r});return e?j(su,{settings:i,onSettingsChange:s,events:l}):null}function ys({visible:e,onClose:t,onBack:r,onMinimize:o,enableSharedModalDimensions:n=false,inline:i=false,paused:s,onPausedChange:l,remoteConditions:a}){let{isPro:d}=ed(),[u,v]=ye(false),T=s!=null&&l!=null,x=T?s:u,L=Z=>{let De=typeof Z=="function"?Z(x):Z;T?l(De):v(De)},[m,k]=ye({}),E=zu(),[g,I]=ye(false),[D,H]=ye(false),[S,z]=ye(false),[w,p]=ye(false),[h,c]=ye(0),[y]=ye(Wl);St(()=>{y.update(a)},[y,a]),St(()=>()=>y.update(void 0),[y]);let O=true,[re,ne]=ye(null),[ee,X]=ye("filters"),[A,W]=ye(""),[$,oe]=ye(false),ge=Rr(false),[rt,dt]=ye(""),Es=Rr(null),{patterns:qt,values:Is,add:Ps,remove:Bs,toggle:Ls,toggleMode:qs,isTeamOnly:Os}=od(),[_t,an]=ye(tu),no=Rr(false),[io,so]=ye(false),[Ot,Ds]=ye("export"),Xt=Z=>{Ds(Z),so(true)};St(()=>{io&&d&&so(false)},[io,d]),St(()=>{if(!e||no.current)return;(async()=>{try{let Z=await di.getItem(Er.network.copyOptions());if(Z){let De=JSON.parse(Z);an(De)}}catch{}finally{no.current=true}})()},[e]),St(()=>{if(!no.current)return;(async()=>{try{await di.setItem(Er.network.copyOptions(),JSON.stringify(_t))}catch{}})()},[_t]);let zs=()=>{Ue.clear()},ln=Po(Z=>{Ue.select(Z.id)},[]),As=Po((Z,De)=>{ne(De?{...Z,id:De}:Z),z(true),Ue.clear()},[]),Hs=Po(()=>ne(null),[]),dn=Rr(null),un=Z=>{W(Z),k(De=>({...De,searchText:Z}))},Ms=Z=>{k(De=>({...De,status:De.status===Z?void 0:Z}))},[cn,Ns]=ye("bottomSheet"),$s=Z=>{Ns(Z)};St(()=>{$&&requestAnimationFrame(()=>{Es.current?.focus()})},[$]);let hn=()=>g?$e(me,{children:[j(me.Navigation,{onBack:()=>I(false)}),j(me.Content,{title:"",noMargin:true,children:j(Yl,{size:"sm",tabs:[{key:"filters",label:"Filters"},{key:"copy",label:"Copy"}],activeKey:ee,onChange:Z=>X(Z)})})]}):E?$e(me,{children:[j(me.Navigation,{onBack:zs}),j(me.Content,{title:"Request Details",centered:true}),$e(me.Actions,{children:[O?j(Hh,{onOpen:As}):null,j(Gi,{isPro:d,onUpgradePress:()=>Xt("saved")})]})]}):S&&O?$e(me,{children:[j(me.Navigation,{onBack:()=>{dn.current?.()||(z(false),ne(null))}}),j(me.Content,{title:"Response Overrides",centered:true})]}):D?$e(me,{children:[j(me.Navigation,{onBack:()=>H(false)}),j(me.Content,{title:"Saved Requests",centered:true})]}):$e(me,{children:[r&&j(me.Navigation,{onBack:r}),j(me.Content,{title:"",children:$?j(me.Search,{value:A,onChangeText:un,onCancel:()=>{un(""),oe(false)},onDismiss:()=>oe(false),dismissOnBlur:true,clearOnlyWhenText:true,placeholder:"Search URL, method, operation, error...",accessibilityLabel:"Search network requests",iconSize:14,testID:"buoy-network-search-input",clearTestID:"buoy-network-search-clear",inputProps:{"sentry-label":"ignore network search header"}}):j(Vu,{activeStatus:m.status,onToggleStatus:Ms,ignoredPatterns:qt,paused:x})}),$e(me.Actions,{children:[j(N,{"sentry-label":"ignore open search",testID:"buoy-network-search-open",accessibilityLabel:"Open search",accessibilityRole:"button",onPress:()=>oe(true),style:Bt.headerActionButton,children:j(Xl,{size:14,color:Qe.color.textSecondary})}),O?j(Dh,{onPress:()=>z(true)}):null,j(rd,{isEnabled:!x,onToggle:()=>L(Z=>!Z),accessibilityLabel:x?"Resume network capture":"Pause network capture",testID:"buoy-network-power"}),j(Uu,{paused:x}),j(Mh,{onPress:()=>p(Z=>!Z),isOpen:w,hasIndicator:ao})]})]}),ao=!!(m.status||m.method||m.contentType),js=n?Er.modal.root():Er.network.modal();if(!e)return null;let Fs=E||!g,pn=$e(Zh,{children:[$e(f,{style:Bt.container,children:[j(Yh,{visible:E,paused:x,ignoredPatternValues:Is,onTogglePattern:Ls,isPro:d,filter:m,ignoredPatterns:qt,fromSaved:D,savedSearch:rt,applySafeAreaInset:!i&&cn==="bottomSheet"}),j(ep,{visible:g&&ee==="filters"&&!E,paused:x,isPro:d,filter:m,onFilterChange:k,ignoredPatterns:qt,onRemovePattern:Bs,onAddPattern:Ps,onTogglePatternMode:qs,isTeamPattern:Os}),j(tp,{visible:g&&ee==="copy"&&!E,paused:x,isPro:d,filter:m,ignoredPatterns:qt,settings:_t,onSettingsChange:an}),j(Bh,{visible:O&&S&&!E&&!g,isPro:d,onUpgradePress:()=>Xt("overrides"),pendingDraft:re,onPendingConsumed:Hs,backHandlerRef:dn,applySafeAreaInset:!i&&cn==="bottomSheet"}),j(rs,{visible:D&&!E&&!g&&!(S&&O),isPro:d,copySettings:_t,search:rt,onSearchChange:dt,onEventPress:ln,onUpgradePress:()=>Xt("saved")}),j(Hc,{visible:!E&&!g&&!D&&!(S&&O),paused:x,filter:m,ignoredPatterns:qt,isPro:d,searchText:A,onEventPress:ln,onUpgradePress:()=>Xt("export")})]}),w?$e(Nh,{onClose:()=>p(false),children:[j(Zo,{icon:j(Jl,{size:14,color:Qe.color.textSecondary}),label:"Network throttling",testID:"buoy-network-menu-throttling",onPress:()=>{p(false),_l(a?y:void 0),i||c(Z=>Z+1)}}),j(Zo,{icon:j(Gl,{size:14,color:ao?Qe.color.accent:Qe.color.textSecondary}),label:"Filters",detail:ao?"Active":void 0,onPress:()=>{p(false),X("filters"),I(true)}}),j(Zo,{icon:j(Kl,{size:14,color:Qe.color.textSecondary}),label:"Saved requests",onPress:()=>{p(false),H(true)}}),j(f,{style:Bt.menuCopyRow,children:j(Xu,{isPro:d,filter:m,ignoredPatterns:qt,copySettings:_t,paused:x,onUpgradePress:()=>{p(false),Xt("export")},label:"Copy requests"})})]}):null,j(td,{visible:io,onClose:()=>so(false),featureName:Ot==="saved"?"Saved Requests":Ot==="overrides"?"Response Overrides":"Network Export",description:Ot==="saved"?"Keep the requests that matter. Saved requests survive Clear, app restarts, and the 500-request history cap.":Ot==="overrides"?"Force any endpoint to fail, stall or return something else \u2014 no backend changes, no code changes. Free keeps one active rule.":"Export network requests to share with your team, debug APIs, or feed into AI tools.",benefits:Ot==="overrides"?[`Run ${Fe} rules at once (free keeps ${Un})`,"Force a 500, a 401 or an empty list in one tap","Simulate offline, timeouts and slow connections","Rules survive an app reload, so you can test the boot path"]:Ot==="saved"?[`Save up to ${it} requests (free keeps ${Mi})`,"Failed requests stay put through a Clear","Snapshots survive an app restart","Export saved requests to teammates or AI assistants"]:["Export to JSON, Markdown, or plain text","Customizable copy presets (URLs only, LLM-ready, full data)","Share request details with teammates","Feed network data directly to AI assistants"]})]});return i?$e(f,{style:Bt.inlineRoot,children:[j(f,{style:Bt.inlineHeader,...nd,children:hn()}),pn]}):j(Ql,{visible:e,onClose:t,onMinimize:o,minimizeRequest:h,persistenceKey:js,variant:"night",header:{showToggleButton:true,customContent:hn()},onModeChange:$s,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,disableScrollWrapper:Fs,styles:{},children:pn})}var Bt=he.create({container:{flex:1,backgroundColor:"transparent"},detailRoot:{flex:1,minHeight:0},detailBodyFallback:{flex:1},inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:Zl.border.default,backgroundColor:"transparent"},menuCopyRow:{paddingHorizontal:6},headerActionButton:{width:32,height:32,borderRadius:8,backgroundColor:Qe.color.buttonSurface,borderWidth:1,borderColor:Qe.color.border,alignItems:"center",justifyContent:"center"},activeFilterButton:{backgroundColor:Qe.color.accentSoft,borderColor:Qe.color.accentBorderStrong}});function bs(e){return j(qo,{children:j(ys,{...e})})}function rp(e={}){return j(qo,{children:j(ys,{...e,inline:true,visible:true,onClose:op})})}var op=()=>{};import{jsx as np}from"react/jsx-runtime";var vs=typeof navigator<"u"&&navigator.product==="ReactNative";vs&&U.ensureLoaded();vs&&typeof ce<"u"&&ce&&K.startBootCapture();var Ss=Ml({id:"network",name:"NET",description:"Network request logger",slot:"both",icon:({size:e})=>np(Al,{size:e}),component:bs,props:{enableSharedModalDimensions:false}}),ip=Hl(Ss,e=>({enableSharedModalDimensions:e.enableSharedModalDimensions??false}));q();function sp(){let e=typeof navigator<"u"&&navigator.product==="ReactNative";if(!e&&(typeof window>"u"||typeof document>"u"))return()=>{};U.ensureLoaded();let t=e?()=>{}:ai(),r=K.subscribeToEvents(()=>{}),o=false;return()=>{o||(o=true,t(),r())}}q();import{useState as Yo,useEffect as ap,useCallback as Yr,useMemo as tt,useRef as lp}from"react";import{useLimit as dp,TIER_LIMITS as up}from"@buoy-gg/shared-ui/web";var Cg=up["network.requests"].free;function cp(e={}){let{isPro:t=false}=e,r=dp("network.requests"),o=t?1/0:r,[n,i]=Yo([]),[s,l]=Yo({}),[a,d]=Yo(true),u=lp(null);ap(()=>(a&&(u.current=K.subscribeToEvents(i)),()=>{u.current&&(u.current(),u.current=null)}),[a]);let v=Yr(()=>{K.clearEvents(),i([])},[]),T=Yr(()=>{d(false)},[]),x=Yr(()=>{d(true)},[]),L=tt(()=>s.searchText?s.searchText.toLowerCase():null,[s.searchText]),m=tt(()=>s.method&&s.method.length>0?new Set(s.method):null,[s.method]),k=tt(()=>s.contentType&&s.contentType.length>0?new Set(s.contentType):null,[s.contentType]),E=tt(()=>{let h=[...n];if(m&&(h=h.filter(c=>m.has(c.method))),s.status&&s.status!=="all")switch(s.status){case"success":h=h.filter(c=>c.status&&c.status>=200&&c.status<300);break;case"error":h=h.filter(c=>c.error||c.status&&c.status>=400);break;case"pending":h=h.filter(c=>!c.status&&!c.error);break}return L&&(h=h.filter(c=>c.url.toLowerCase().includes(L)||c.method.toLowerCase().includes(L)||c.path?.toLowerCase().includes(L)||c.host?.toLowerCase().includes(L)||c.error&&c.error.toLowerCase().includes(L)||c.operationName&&c.operationName.toLowerCase().includes(L)||wi(c.graphqlVariables,L))),s.host&&(h=h.filter(c=>c.host===s.host)),k&&(h=h.filter(c=>{let y=c.responseHeaders||c.requestHeaders,O=y?.["content-type"]||y?.["Content-Type"]||"";for(let re of k)switch(re){case"JSON":if(O.includes("json"))return true;break;case"XML":if(O.includes("xml"))return true;break;case"HTML":if(O.includes("html"))return true;break;case"TEXT":if(O.includes("text"))return true;break;case"IMAGE":if(O.includes("image"))return true;break;case"VIDEO":if(O.includes("video"))return true;break;case"AUDIO":if(O.includes("audio"))return true;break;case"FORM":if(O.includes("form"))return true;break;case"OTHER":if(!O||!O.includes("json")&&!O.includes("xml")&&!O.includes("html")&&!O.includes("text")&&!O.includes("image")&&!O.includes("video")&&!O.includes("audio")&&!O.includes("form"))return true;break}return false})),h},[n,s,L,m,k]),g=tt(()=>{let h=new Set;return n.slice(o).forEach(c=>{h.add(c.id)}),h},[n,o]),I=tt(()=>E.filter(h=>g.has(h.id)),[E,g]),D=I.length>0,H=I.length,S=Yr(h=>g.has(h),[g]),z=tt(()=>{let h=0,c=0,y=0,O=0,re=0,ne=0,ee=0;for(let A of n)A.status&&A.status>=200&&A.status<300?h++:A.error||A.status&&A.status>=400?c++:!A.status&&!A.error&&y++,O+=A.requestSize||0,re+=A.responseSize||0,A.duration&&(ne+=A.duration,ee++);let X=ee>0?ne/ee:0;return{totalRequests:n.length,successfulRequests:h,failedRequests:c,pendingRequests:y,totalDataSent:O,totalDataReceived:re,averageDuration:Math.round(X)}},[n]),w=tt(()=>{let h=new Set;for(let c of n)c.host&&h.add(c.host);return Array.from(h)},[n]),p=tt(()=>{let h=new Set;for(let c of n)h.add(c.method);return Array.from(h)},[n]);return{events:E,allEvents:n,stats:z,filter:s,setFilter:l,clearEvents:v,isCapturing:a,pauseCapturing:T,resumeCapturing:x,hosts:w,methods:p,hasLockedEvents:D,lockedEventCount:H,isEventLocked:S,requestLimit:o,getSubscriberCounts:()=>K.getSubscriberCounts()}}import{useIgnoredPatterns as hp,ignoredPatternsStore as pp,urlMatchesIgnoredPattern as fp,isUrlIgnored as gp}from"@buoy-gg/shared-ui/web";q();import{approxJsonSize as en,isOverWireBudget as mp}from"@buoy-gg/shared-ui/web";import{expandKeyedArrays as yp,patchFromPath as bp,refusalText as vp,shapeKind as xs,suggestedPatch as Sp,typedEditViolations as xp}from"@buoy-gg/shared-ui/web";var tn=16*1024,eo=1.25*1024*1024;function rn(e,t){return e===void 0?false:(t??0)>tn?true:mp(e,tn)}var ws=new WeakMap,Ts=new WeakMap;function on(e){let t=ws.get(e);if(t)return t;let r;try{r=Tp(e)}catch{r=wp(e)}return ws.set(e,r),r}function wp(e){let t={...e,requestData:void 0,responseData:void 0,graphqlVariables:void 0,requestBodyOmitted:e.requestData!==void 0?true:void 0,responseBodyOmitted:e.responseData!==void 0?true:void 0},r=1024;try{r=en(t,eo).bytes}catch{}return{event:t,bytes:r}}function Tp(e){let t=rn(e.requestData,e.requestSize),r=rn(e.responseData,e.responseSize),o=Cs(e.graphqlVariables),n=ks(e.requestHeaders),i=ks(e.responseHeaders),s=t||r||o!==e.graphqlVariables||n!==e.requestHeaders||i!==e.responseHeaders,l=e;return s&&(l={...e},t&&(l.requestData=void 0,l.requestBodyOmitted=true),r&&(l.responseData=void 0,l.responseBodyOmitted=true),o!==e.graphqlVariables&&(l.graphqlVariables=o),n!==e.requestHeaders&&(l.requestHeaders=n,l.headersOmitted=true),i!==e.responseHeaders&&(l.responseHeaders=i,l.headersOmitted=true)),{event:l,bytes:en(l,eo).bytes}}function Cp(e){let t=Ts.get(e);if(t)return t;let{event:r}=on(e),o={...r};o.requestData!==void 0&&(o.requestData=void 0,o.requestBodyOmitted=true),o.responseData!==void 0&&(o.responseData=void 0,o.responseBodyOmitted=true),o.graphqlVariables!==void 0&&(o.graphqlVariables=Cs(o.graphqlVariables,true));let n={event:o,bytes:en(o,eo).bytes};return Ts.set(e,n),n}function kp(e){let t=new Array(e.length),r=0;for(let o=0;o<e.length;o++){let n=on(e[o]);if(r+n.bytes<=eo)t[o]=n.event,r+=n.bytes;else{let i=Cp(e[o]);t[o]=i.event,r+=i.bytes}}return t}function Cs(e,t=false){if(!e||!t&&!rn(e,void 0))return e;let r={};for(let[o,n]of Object.entries(e))(typeof n=="string"&&n.length<=64||typeof n=="number"||typeof n=="boolean")&&(r[o]=n);return Object.keys(r).length>0?r:void 0}var nn=64;function ks(e){if(!e)return e;let t=false,r={};for(let[o,n]of Object.entries(e))typeof n=="string"&&(n.length<=nn?r[o]=n:(r[o]=`${n.slice(0,nn)}\u2026 [${n.length-nn} more]`,t=true));return t?r:e}var Rp=e=>{let t=false,r=e.rules.map(o=>!o.body||o.body.length<=tn?o:(t=true,{...o,body:void 0,bodyOmitted:true}));return t?{...e,rules:r}:e},to=e=>K.getEventById(e)??ae.getEventById(e),Ut=e=>e&&typeof e=="object"?e.id:void 0,ro=(e,t)=>!!(e&&typeof e=="object"&&e[t]),oo=()=>Xn()?{}:{active:false,inactiveReason:vl},Ep=["respond","fail","delay"];function Ip(e,t){if(!e||typeof e!="object")return null;let r=e.rule??e;if(!r||typeof r!="object")return null;let o=r,n=typeof o.urlPattern=="string"&&o.urlPattern.trim()?o.urlPattern.trim():t?.urlPattern??"";if(!n)return null;let i=Ep.includes(o.kind)?o.kind:t?.kind??"respond";return{id:typeof o.id=="string"?o.id:void 0,enabled:o.enabled!==false,name:typeof o.name=="string"?o.name:t?.name,urlPattern:n,methods:Array.isArray(o.methods)?o.methods.filter(s=>typeof s=="string").map(s=>s.toUpperCase()):t?.methods,requireHeader:typeof o.requireHeader=="string"&&o.requireHeader.trim()?o.requireHeader.trim():void 0,bodyIncludes:typeof o.bodyIncludes=="string"&&o.bodyIncludes?o.bodyIncludes.slice(0,4096):t?.bodyIncludes,kind:i,status:typeof o.status=="number"?o.status:t?.status,statusText:typeof o.statusText=="string"?o.statusText:t?.statusText,headers:o.headers&&typeof o.headers=="object"?o.headers:t?.headers,body:Bp(o,t),failKind:o.failKind==="timeout"?"timeout":void 0,delayMs:typeof o.delayMs=="number"?o.delayMs:void 0,times:typeof o.times=="number"?o.times:null,alternate:o.alternate===true}}var Lt=e=>!!e&&typeof e=="object"&&!Array.isArray(e);function Rs(e,t,r="",o={shrunk:[],breaks:[]}){if(Array.isArray(e)&&Array.isArray(t))return t.length>0&&t.length<e.length&&o.shrunk.push({path:r||"(root)",have:e.length,sent:t.length}),t;if(!Lt(e)||!Lt(t))return t;let n={...e};for(let[i,s]of Object.entries(t)){let l=r?`${r}.${i}`:i;if(i in e){let a=xs(e[i]),d=xs(s);(a==="array"||a==="object")&&a!==d&&o.breaks.push({path:l,from:a,to:d}),n[i]=Rs(e[i],s,l,o)}else n[i]=s}return n}function Pp(e,t){if(e.body!=null||!Lt(e.bodyPatch)||typeof t!="string")return[];try{return xp(JSON.parse(t),e.bodyPatch,{noun:"response body"})}catch{return[]}}function Bp(e,t){if(typeof e.body=="string")return e.body;if(e.body!=null)return JSON.stringify(e.body,null,2);let r=t?.body??(Lt(e.bodyPatch)&&typeof e.id=="string"?U.getState().rules.find(o=>o.id===e.id)?.body:void 0);if(Lt(e.bodyPatch)&&typeof r=="string")try{return JSON.stringify(Rs(JSON.parse(r),e.bodyPatch),null,2)}catch{return r}return r}function Lp(e){if(!e||typeof e!="object")return null;let t=e.rule??e;if(!t||typeof t!="object")return null;let r=t.id;if(typeof r!="string")return null;let o=U.getState().rules.find(n=>n.id===r);return o?{...o}:null}function qp(e){if(!e||typeof e!="object")return null;let t=e.rule??e;if(!t||typeof t!="object")return null;let r=t;if(r.bodyOmitted!==true||typeof r.id!="string")return null;let o=U.getState().rules.find(n=>n.id===r.id);return o?{body:o.body}:null}function Op(e){if(!e||typeof e!="object")return null;let t=e.fromRequestId;if(typeof t!="string"||!t)return null;let r=to(t);return r?Qo(r):null}var Dp={dispose:()=>{U.setEnabled(false)},version:6,getSnapshot:()=>(K.ensureInterception(),{conditions:{version:1,runtimeId:ko,profile:vt(),available:bt()},events:kp(K.getEvents()),overrides:Rp(U.getState()),saved:ae.getRecords().map(e=>({...e,event:on(e.event).event}))}),subscribe:e=>{let t=K.subscribeToEvents(e),r=rr(e),o=ae.subscribe(e),n=U.subscribe(e);return()=>{r(),t(),o(),n()}},actions:{getNetworkConditions:()=>({runtimeId:ko,profile:vt(),available:bt()}),setNetworkConditions:e=>{let t=e&&typeof e=="object"?e.profile:void 0;return{runtimeId:ko,profile:Cr(t),available:bt()}},clearEvents:()=>{K.clearEvents()},getEventBody:e=>{let t=Ut(e);if(!t)return null;let r=to(t);return r?{url:r.url??null,method:r.method??null,status:r.status??null,override:r.override??null,requestData:r.requestData??null,responseData:r.responseData??null,requestHeaders:r.requestHeaders??null,responseHeaders:r.responseHeaders??null}:null},setPinned:e=>{let t=Ut(e);if(!t)return null;let r=to(t);if(!r)return null;let o=ro(e,"pinned");return Dr(ae.getState(),t).pinned===o?{ok:true}:ae.togglePin(r)},setSaved:e=>{let t=Ut(e);if(!t)return null;let r=to(t);if(!r)return null;let o=ro(e,"saved");return Dr(ae.getState(),t).saved===o?{ok:true}:ae.toggleSave(r)},removeSavedRecord:e=>{let t=e&&typeof e=="object"?e.key:void 0;return t?(ae.remove(t),{ok:true}):null},clearSavedRequests:()=>(ae.clearSaved(),{ok:true}),clearPinnedRequests:()=>(ae.clearPinned(),{ok:true}),setOverridesEnabled:e=>(U.setEnabled(ro(e,"enabled")),{ok:true,enabled:U.getState().enabled,...oo()}),upsertOverrideRule:e=>{let t=e?.rule??e,r=!!t&&t.body==null&&(Lt(t.bodyPatch)||typeof t.bodyPath=="string"),o=Op(e)??qp(e)??(r?Lp(e):null);if(t&&typeof t.bodyPath=="string"&&t.body==null){let s=o?.body??(typeof t.id=="string"?U.getState().rules.find(d=>d.id===t.id)?.body:void 0);if(typeof s!="string")return{ok:false,error:"bodyPath needs something to patch: send fromRequestId (the captured request whose real response it addresses) or the id of an existing rule."};if(t.bodyValue===void 0)return{ok:false,error:`Refused: sent \`bodyPath\` without \`bodyValue\`. Say what to set "${t.bodyPath}" to.`};let l;try{l=JSON.parse(s)}catch{return{ok:false,error:"The captured response body is not JSON, so it cannot be addressed by path. Send a whole `body` instead."}}let a=bp(l,t.bodyPath,t.bodyValue);if(!a.ok)return{ok:false,error:`Refused: ${a.error}`};t.bodyPatch=a.patch,delete t.bodyPath,delete t.bodyValue}if(t&&Lt(t.bodyPatch)&&t.body==null){let s=o?.body??(typeof t.id=="string"?U.getState().rules.find(l=>l.id===t.id)?.body:void 0);if(typeof s!="string")return{ok:false,error:"bodyPatch needs something to patch: send fromRequestId (the captured request whose real response the patch is merged into) or the id of an existing rule."};if(t.force!==true){let l;try{let d=yp(JSON.parse(s),t.bodyPatch);l=d.error,d.notes.length&&(t.bodyPatch=d.patch)}catch{}if(l)return{ok:false,error:`Refused: ${l}`};let a=Pp(t,s);if(a.length>0)return{ok:false,error:vp(a,"response body",Sp(t.bodyPatch,a)),violations:a}}}let n=Ip(e,o);if(!n){let s=e?.fromRequestId;return{ok:false,error:s?`No captured request \`${s}\` \u2014 it may have been cleared. Send a urlPattern instead.`:"A rule needs a non-empty urlPattern."}}let i=U.upsertRule(n);return i?(i.enabled&&U.setEnabled(true),{ok:true,rule:{id:i.id,urlPattern:i.urlPattern,enabled:i.enabled,kind:i.kind,status:i.status,times:i.times,bodySize:i.body?i.body.length:0},...i.times===void 0||i.times===null?{lingers:`This rule has no \`times\` budget, so it overrides EVERY matching request until it is disabled or deleted (id \`${i.id}\`). If you meant only the next one, set times:1.`}:{},...oo()}):{ok:false,error:"Override rule limit reached."}},setOverrideRuleEnabled:e=>{let t=Ut(e);return t?(U.setRuleEnabled(t,ro(e,"enabled")),{ok:true,...oo()}):{ok:false,error:"Missing rule id."}},deleteOverrideRule:e=>{let t=Ut(e);return t?(U.removeRule(t),{ok:true}):{ok:false,error:"Missing rule id."}},clearOverrideRules:()=>(U.clearRules(),{ok:true}),replaceOverrideRules:async e=>{let t=e??{};if(!Array.isArray(t.rules))return{ok:false,error:"replaceOverrideRules needs `rules`: an array of rules, first match first."};if(t.rules.length>Fe)return{ok:false,error:`Too many rules: ${t.rules.length}. The most is ${Fe}.`};await U.ensureLoaded();let r=U.replaceAllRules(t.rules,t.enabled!==false);return r?{ok:true,count:r.length,enabled:U.getState().enabled,...oo()}:{ok:false,error:"This copy of the Network tool only mirrors a device, so it can't replace rules."}},listOverrideRules:async()=>(await U.ensureLoaded(),U.getState()),getOverrideRuleBody:e=>{let t=Ut(e);if(!t)return null;let r=U.getState().rules.find(o=>o.id===t);return r?{body:r.body??null}:null},getCaptureStatus:()=>{let e=K.getSubscriberCounts().total,t=null,r=null;try{t=ti(),r=mt()}catch{}let o=null;try{o=Dl()}catch{}return{capturing:e>0,subscribers:e,interceptorInstalled:t,interceptorLive:o,listenerCount:r,eventCount:K.getEvents().length}},debugOverrides:e=>{let{url:t,method:r}=e&&typeof e=="object"?e:{},o=typeof t=="string"?t:"https://example.com/",n=typeof r=="string"&&r.trim()?r.trim().toUpperCase():"GET";return{tested:{url:o,method:n},interceptorInstalled:ti(),listenerCount:mt(),engine:Sl(o,n),store:{enabled:U.getState().enabled,autoPaused:U.getState().autoPaused,ruleCount:U.getState().rules.length,rulesVisibleToEngine:U.getRules().length}}}}};q();var zp=new Set(["content-length","host","connection","accept-encoding"]);function sn(e){return`'${e.replace(/'/g,"'\\''")}'`}function Ap(e){if(e==null)return null;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return null}}function Hp(e){let t=(e.method||"GET").toUpperCase(),r=Ap(e.requestData),o=[];t!=="GET"&&!(t==="POST"&&r!==null)&&o.push(`-X ${t}`);for(let[i,s]of Object.entries(e.requestHeaders||{}))zp.has(i.toLowerCase())||o.push(`-H ${sn(`${i}: ${s}`)}`);r!==null&&o.push(`--data-raw ${sn(r)}`);let n=`curl ${sn(e.url)}`;return o.length===0?n:`${n} \\
142
+ `+o}import{Fragment as Lc,jsx as xe,jsxs as Nt}from"react/jsx-runtime";function Bc({activeStatus:e,onToggleStatus:t,ignoredPatterns:r,paused:o}){let n=Rs({ignoredPatterns:r,paused:o});return xe(Ps,{counts:n,activeStatus:e,onToggleStatus:t})}function Ps({counts:e,activeStatus:t,onToggleStatus:r}){return Nt(m,{style:ie.headerChipRow,children:[Nt(F,{style:[ie.headerChip,t==="success"&&ie.headerChipActive],onPress:()=>r("success"),children:[xe(Ju,{size:12,color:bt.semantic.success}),xe(b,{style:[ie.headerChipValue,{color:bt.semantic.success}],children:e.successful})]}),Nt(F,{style:[ie.headerChip,t==="error"&&ie.headerChipActive],onPress:()=>r("error"),children:[xe(Gu,{size:12,color:bt.semantic.error}),xe(b,{style:[ie.headerChipValue,{color:bt.semantic.error}],children:e.failed})]}),Nt(F,{style:[ie.headerChip,t==="pending"&&ie.headerChipActive],onPress:()=>r("pending"),children:[xe(Ku,{size:12,color:bt.semantic.warning}),xe(b,{style:[ie.headerChipValue,{color:bt.semantic.warning}],children:e.pending})]})]})}function qc({paused:e}){let t=Ic({paused:e});return xe(F,{"sentry-label":"ignore clear events",testID:"buoy-network-clear",accessibilityLabel:"Clear network requests",accessibilityRole:"button",onPress:()=>te.clearEvents(),style:[ie.headerActionButton,!t&&ie.headerActionButtonDisabled],disabled:!t,children:xe(Qu,{size:14,color:t?ae.color.textSecondary:ae.color.textTertiary})})}function Oc({onPress:e}){let{savedRecords:t}=Zt(),r=t.length;return Nt(F,{"sentry-label":"ignore open saved",onPress:e,accessibilityLabel:"Saved requests",style:ie.headerActionButton,children:[xe(hs,{size:14,color:r>0?ae.color.accent:ae.color.textSecondary}),r>0?xe(m,{style:ie.savedBadge,children:xe(b,{style:ie.savedBadgeText,children:r>99?"99+":r})}):null]})}function Ls({isPro:e,onUpgradePress:t}){let r=vn(),o=Zt(),{pinned:n,saved:i}=to(o,r),s=tc("network.saved"),l=!n&&o.pinnedEvents.length>=eo,a=!i&&o.savedRecords.length>=s,u=()=>r?te.getEvents().find(x=>x.id===r)??fe.getEventById(r):null,d=()=>{let x=u();x&&o.togglePin(x)},g=()=>{if(a&&!e){t();return}let x=u();x&&o.toggleSave(x)};return Nt(Lc,{children:[xe(F,{"sentry-label":"ignore pin request",onPress:d,disabled:l,testID:"buoy-network-pin",accessibilityRole:"button",accessibilityLabel:n?"Unpin request":"Pin request",accessibilityHint:l?`Pin limit reached (${eo})`:void 0,style:[ie.headerActionButton,n&&ie.headerActionButtonActive,l&&ie.headerActionButtonDisabled],children:xe(Zu,{size:14,active:n,color:n?ae.color.accent:l?ae.color.textTertiary:ae.color.textSecondary})}),xe(F,{"sentry-label":"ignore save request",onPress:g,disabled:a&&e,testID:"buoy-network-save",accessibilityRole:"button",accessibilityLabel:i?"Remove from saved":"Save request",accessibilityHint:a&&e?`Saved limit reached (${vt})`:void 0,style:[ie.headerActionButton,i&&ie.headerActionButtonSaved,a&&e&&ie.headerActionButtonDisabled],children:xe(hs,{size:14,color:i?ae.color.accent:a&&e?ae.color.textTertiary:ae.color.textSecondary})})]})}function zc({isPro:e,filter:t,ignoredPatterns:r,copySettings:o,paused:n,onUpgradePress:i,label:s}){let l=Pc({filter:t,ignoredPatterns:r,paused:n});return e?xe(ec,{value:()=>Is(Sr(wr(te.getEvents(),r),t),o),size:14,label:s,buttonStyle:s?ie.copyMenuRow:ie.headerActionButton,labelStyle:ie.copyMenuLabel,colors:{idle:l?ae.color.textSecondary:ae.color.textTertiary,success:bt.semantic.success,error:bt.semantic.error},disabled:!l}):Nt(F,{"sentry-label":"ignore copy pro",onPress:i,style:[s?ie.copyMenuRow:ie.headerActionButton,!l&&ie.headerActionButtonDisabled],disabled:!l,children:[xe(Yu,{size:14,color:l?ae.color.textSecondary:ae.color.textTertiary}),s?xe(b,{style:ie.copyMenuLabel,children:s}):null]})}var ie=ve.create({copyMenuRow:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:6,paddingVertical:11,justifyContent:"flex-start"},copyMenuLabel:{fontSize:13,fontWeight:"600",color:ae.color.text},headerChipRow:{flexDirection:"row",alignItems:"center",gap:8},headerChip:{flexDirection:"row",alignItems:"center",gap:4,backgroundColor:ae.color.buttonSurface,paddingHorizontal:10,paddingVertical:5,borderRadius:12,borderWidth:1,borderColor:ae.color.border},headerChipActive:{backgroundColor:ae.color.accentSoft,borderColor:ae.color.accentBorderStrong},headerChipValue:{fontSize:12,fontWeight:"600",fontFamily:ps},headerActionButton:{width:32,height:32,borderRadius:8,backgroundColor:ae.color.buttonSurface,borderWidth:1,borderColor:ae.color.border,alignItems:"center",justifyContent:"center"},headerActionButtonDisabled:{opacity:.55},headerActionButtonActive:{backgroundColor:ae.color.accentSoft,borderColor:ae.color.accentBorderStrong},headerActionButtonSaved:{backgroundColor:ae.color.accentSoft,borderColor:ae.color.accentBorderStrong},savedBadge:{position:"absolute",top:-3,right:-3,minWidth:14,height:14,paddingHorizontal:3,borderRadius:7,backgroundColor:ae.color.accent,alignItems:"center",justifyContent:"center"},savedBadgeText:{color:ae.color.onAccent,fontSize:9,fontWeight:"700",fontFamily:ps}});O();Se();import{useCallback as Dc}from"react";import{FlaskConical as Ac,Pin as Hc,Power as Mc,macOSColors as Ee,ToolEmptyState as Nc,resolveListEmptyState as $c,EVENT_LIST_PRESET as Fc,monoFont as jc}from"@buoy-gg/shared-ui/web";O();Se();import{memo as Wc}from"react";import{ChevronRight as Vc,Upload as Uc,Download as _c,Clock as Xc,AlertCircle as Jc,Bookmark as Gc,FlaskConical as Kc,Pin as Yc,DevToolsCard as Zc,MethodBadge as Qc,TypeBadge as eh,night as Ie,macOSColors as Qt,monoFont as Sn}from"@buoy-gg/shared-ui/web";import{formatRelativeTime as th}from"@buoy-gg/shared-ui/web";import{jsx as ce,jsxs as Ke}from"react/jsx-runtime";function rh(e,t){return t?Qt.semantic.error:e?e>=200&&e<300?Qt.semantic.success:e>=300&&e<400?Qt.semantic.info:e>=400?Qt.semantic.error:Qt.text.muted:Qt.semantic.warning}function oh(e){let t=e?.["content-type"]||e?.["Content-Type"]||"";return t.includes("json")?"JSON":t.includes("xml")?"XML":t.includes("html")?"HTML":t.includes("text")?"TEXT":t.includes("image")?"IMG":t.includes("video")?"VIDEO":t.includes("audio")?"AUDIO":t.includes("form")?"FORM":null}function Bs(e){switch(e){case"fetch":return{backgroundColor:"rgba(74, 144, 226, 0.15)",color:"#4A90E2"};case"graphql":return{backgroundColor:"rgba(229, 53, 171, 0.15)",color:"#E535AB"};case"grpc-web":return{backgroundColor:"rgba(16, 185, 129, 0.15)",color:"#10B981"};case"xhr":return{backgroundColor:"rgba(245, 158, 11, 0.15)",color:"#F59E0B"};default:return{backgroundColor:"rgba(147, 51, 234, 0.15)",color:"#9333EA"}}}function nh({event:e,isPending:t,statusColor:r}){return t?Ke(m,{style:ye.pendingBadge,children:[ce(Xc,{size:10,color:Ie.color.warning}),ce(b,{style:ye.pendingText,children:"..."})]}):e.error?Ke(m,{style:ye.errorBadge,children:[ce(Jc,{size:10,color:Ie.color.danger}),ce(b,{style:ye.errorText,children:"ERR"})]}):ce(m,{style:ye.statusBadge,children:ce(b,{style:[ye.statusText,{color:r}],children:String(e.status)})})}function ih({requestSize:e,responseSize:t}){return!e&&!t?null:Ke(m,{style:ye.sizeRow,children:[e?Ke(m,{style:ye.sizeItem,children:[ce(Uc,{size:8,color:Ie.color.info}),ce(b,{style:ye.sizeText,children:ct(e)})]}):null,t?Ke(m,{style:ye.sizeItem,children:[ce(_c,{size:8,color:Ie.color.accent}),ce(b,{style:ye.sizeText,children:ct(t)})]}):null]})}function sh({timestamp:e,duration:t}){let r=hn(),o=th(e,r);return t?Ke(b,{style:ye.bottomRightText,children:[Zr(t)," ",o]}):ce(b,{style:ye.bottomRightText,children:o})}var er=Wc(function({event:e,onPress:t,pinned:r=false,saved:o=false,overridden:n=false,onLongPress:i}){let s=rh(e.status,e.error),l=!e.status&&!e.error,a=oh(e.responseHeaders),u=e.path||e.url.replace(/^https?:\/\/[^/]+/,"");return e.requestClient==="graphql"?e.operationName?u=rs(e.operationName,e.graphqlVariables):u=u.replace(/\/graphql[^?]*/,"/graphql"):e.operationName&&(u=`${u}
143
+ (${e.operationName})`),Ke(Zc,{onPress:()=>t(e),onLongPress:i?()=>i(e):void 0,style:ye.cardWrapper,contentStyle:[ye.container,{borderLeftColor:s}],testID:`buoy-network-row-${e.id}`,accessibilityLabel:`${e.method} ${e.path||e.url}`,children:[Ke(m,{style:ye.topRightContainer,children:[r?ce(Yc,{size:10,active:true,color:Ie.color.info}):null,o?ce(Gc,{size:10,color:Ie.color.accent}):null,n||e.override?ce(Kc,{size:10,color:Ie.color.warning}):null,ce(nh,{event:e,isPending:l,statusColor:s}),e.requestClient?ce(m,{style:[ye.topRightBadge,{backgroundColor:Bs(e.requestClient).backgroundColor}],children:ce(b,{style:[ye.clientText,{color:Bs(e.requestClient).color}],children:e.requestClient==="graphql"?"GQL":e.requestClient==="grpc-web"?"gRPC":e.requestClient==="xhr"?"XHR":e.requestClient})}):null]}),Ke(m,{style:ye.leftSection,children:[ce(Qc,{method:e.method,size:"small"}),ce(ih,{requestSize:e.requestSize,responseSize:e.responseSize})]}),Ke(m,{style:ye.middleSection,children:[ce(b,{style:ye.urlText,numberOfLines:2,children:u}),e.condition?.uploadCap?.note&&ce(b,{testID:`buoy-network-upload-cap-${e.id}`,style:{color:Ie.color.warning,fontSize:10},children:e.condition.uploadCap.note})]}),Ke(m,{style:ye.rightSection,children:[a?ce(eh,{type:a,size:"small"}):null,ce(Vc,{size:14,color:Ie.color.textTertiary})]}),ce(m,{style:ye.bottomRightContainer,children:ce(sh,{timestamp:e.timestamp,duration:e.duration})})]})});er.displayName="NetworkEventItemCompact";var ye=ve.create({cardWrapper:{marginHorizontal:8},container:{flexDirection:"row",alignItems:"center",backgroundColor:"rgba(12, 12, 12, 0.9)",borderLeftWidth:3,borderLeftColor:"transparent",borderBottomWidth:1},leftSection:{marginRight:8,alignItems:"flex-start"},topRightContainer:{position:"absolute",top:1,right:1,flexDirection:"row",alignItems:"center",gap:4},topRightBadge:{paddingHorizontal:4,paddingVertical:2,borderRadius:4},middleSection:{flex:1,justifyContent:"center",paddingRight:8},urlText:{fontSize:12,color:Ie.color.text,lineHeight:16,fontFamily:Sn},rightSection:{flexDirection:"row",alignItems:"center",gap:6},bottomRightContainer:{position:"absolute",bottom:4,right:8},bottomRightText:{fontSize:9,color:Ie.color.textTertiary,fontFamily:Sn},statusBadge:{paddingHorizontal:4,paddingVertical:1,borderRadius:3},statusText:{fontSize:10,fontWeight:"600"},pendingBadge:{flexDirection:"row",alignItems:"center",gap:2,paddingHorizontal:4,paddingVertical:1,backgroundColor:Ie.color.warningSoft,borderRadius:3},pendingText:{fontSize:10,color:Ie.color.warning,fontWeight:"600"},errorBadge:{flexDirection:"row",alignItems:"center",gap:2,paddingHorizontal:4,paddingVertical:1,backgroundColor:Ie.color.dangerSoft,borderRadius:3},errorText:{fontSize:10,color:Ie.color.danger,fontWeight:"600"},durationText:{fontSize:9,color:Ie.color.textSecondary},sizeRow:{flexDirection:"row",gap:4,marginTop:4},sizeItem:{flexDirection:"row",alignItems:"center",gap:2},sizeText:{fontSize:8,color:Ie.color.textSecondary,fontFamily:Sn},clientText:{fontSize:8,fontWeight:"700",letterSpacing:.3,textTransform:"uppercase"}});O();Se();import{ProBadge as ah,Zap as lh,buoyColors as xr}from"@buoy-gg/shared-ui/web";import{jsx as io,jsxs as wn}from"react/jsx-runtime";function qs({title:e,subtitle:t,onPress:r}){return wn(F,{style:Cr.banner,onPress:r,activeOpacity:.8,children:[wn(m,{style:Cr.content,children:[wn(m,{style:Cr.left,children:[io(lh,{size:16,color:xr.primary}),io(b,{style:Cr.title,children:e})]}),io(ah,{})]}),io(b,{style:Cr.subtitle,children:t})]})}var Cr=ve.create({banner:{backgroundColor:xr.card,borderRadius:10,borderWidth:1,borderColor:xr.primary+"40",padding:12,marginHorizontal:12,marginTop:12,marginBottom:34},content:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:4},left:{flexDirection:"row",alignItems:"center",gap:8},title:{color:xr.text,fontSize:13,fontWeight:"600"},subtitle:{color:xr.textMuted,fontSize:11}});O();import{useEffect as Os,useMemo as so,useState as dh}from"react";import{useLimit as uh}from"@buoy-gg/shared-ui/web";function kr(e){let{filter:t,ignoredPatterns:r,paused:o,visible:n=true,isPro:i}=e,s=uh("network.requests"),l=i?1/0:s,[a,u]=dh(()=>te.getEvents());Os(()=>{if(!n)return;if(o){u(te.getEvents());return}let h=null,C=null,k=te.subscribeToEvents(w=>{C=w,h==null&&(h=requestAnimationFrame(()=>{h=null,C&&u(C),C=null}))});return()=>{k(),h!=null&&cancelAnimationFrame(h)}},[o,n]),Os(()=>te.onClear(()=>{u([])}),[]);let d=so(()=>wr(a,r),[a,r]),g=so(()=>Sr(d,t),[d,t]),x=so(()=>{let h=new Set;return a.slice(l).forEach(C=>{h.add(C.id)}),h},[a,l]),y=so(()=>x.size===0?g:g.filter(h=>!x.has(h.id)),[g,x]),R=g.length-y.length;return{events:g,visibleEvents:y,hasLockedEvents:R>0,lockedEventCount:R,totalEvents:d.length}}O();import{useCallback as tr,useSyncExternalStore as ch}from"react";O();import{devToolsStorageKeys as ao,persistentStorage as zs}from"@buoy-gg/shared-ui/web";var hh=800,ph=3;function fh(){let e=`${ao.network.overrides()}_launch`;try{let t=globalThis.sessionStorage;if(!t)return false;if(t.getItem(e))return true;t.setItem(e,"1")}catch{}return false}var Ds=Object.freeze([]),yh=250,gh=["respond","fail","delay"];function As(e){if(!Array.isArray(e))return[];let t=[];for(let r of e){if(!r||typeof r!="object")continue;let o=r;if(typeof o.id!="string"||typeof o.urlPattern!="string"||!o.urlPattern)continue;let n=gh.includes(o.kind)?o.kind:"respond";t.push({id:o.id,enabled:o.enabled!==false,name:typeof o.name=="string"?o.name:void 0,urlPattern:o.urlPattern,methods:Array.isArray(o.methods)?o.methods.filter(i=>typeof i=="string"):void 0,requireHeader:typeof o.requireHeader=="string"&&o.requireHeader?o.requireHeader:void 0,bodyIncludes:typeof o.bodyIncludes=="string"&&o.bodyIncludes?o.bodyIncludes:void 0,graphqlOperation:typeof o.graphqlOperation=="string"&&o.graphqlOperation?o.graphqlOperation:void 0,graphqlVariables:typeof o.graphqlVariables=="string"?o.graphqlVariables:void 0,sandbox:o.sandbox===true?true:void 0,kind:n,status:typeof o.status=="number"?Math.min(hr,Math.max(cr,o.status)):void 0,statusText:typeof o.statusText=="string"?o.statusText:void 0,headers:o.headers&&typeof o.headers=="object"?o.headers:void 0,body:typeof o.body=="string"?o.body:void 0,failKind:o.failKind==="timeout"?"timeout":void 0,delayMs:typeof o.delayMs=="number"?o.delayMs:void 0,times:typeof o.times=="number"?o.times:null,alternate:o.alternate===true,hits:0,seen:0,createdAt:typeof o.createdAt=="number"?o.createdAt:0})}return t.slice(0,Ze)}var mh=class{constructor(){this.rules=[];this.enabled=true;this.listeners=new Set;this.loaded=false;this.loadPromise=null;this.dirty=false;this.idCounter=0;this.state={enabled:true,rules:[],autoPaused:false};this.launchStreak=0;this.autoPaused=false;this.keepAlive=null;this.hitEmitTimer=null;this.engineDisabled=false;this.remote=null;this.remoteEchoUntil=0;this.sandboxCache=null}enableRemoteMode(e){this.remote=e,this.disableEngine()}disableRemoteMode(){this.remote=null}replaceRules(e,t=false){this.remote&&(!t&&ue()<this.remoteEchoUntil||(this.enabled=e.enabled,this.rules=e.rules,this.rebuild(),this.emit()))}markLocalEdit(){this.remote&&(this.remoteEchoUntil=ue()+hh)}disableEngine(){this.engineDisabled=true,this.keepAlive&&(this.keepAlive(),this.keepAlive=null,Pt()===0&&pr())}getState(){return this.state}getRules(){return this.engineDisabled?Ds:this.enabled?this.rules:this.sandboxOnly()}sandboxOnly(){if(this.sandboxCache?.from!==this.rules){let e=this.rules.filter(t=>t.sandbox===true);this.sandboxCache={from:this.rules,rules:e.length?e:Ds}}return this.sandboxCache.rules}async fetchRuleBody(e){let t=this.rules.find(r=>r.id===e);if(!t)return null;if(!t.bodyOmitted)return t.body??null;if(!this.remote?.getRuleBody)return null;try{return await this.remote.getRuleBody(e)}catch{return null}}activeCount(){return(this.enabled?this.rules:this.sandboxOnly()).filter(e=>e.enabled&&!Xo(e)).length}subscribe(e){return this.listeners.add(e),this.ensureLoaded(),()=>{this.listeners.delete(e)}}setEnabled(e){this.enabled!==e&&(this.remote?.setEnabled(e),this.markLocalEdit(),this.markTouched(),this.enabled=e,this.commit(this.rules))}addRule(e){if(this.rules.length>=Ze)return null;let t={...e,id:`ovr_${Date.now().toString(36)}_${++this.idCounter}`,hits:0,seen:0,createdAt:Date.now()};return this.commit([t,...this.rules]),t}upsertRule(e){this.remote?.upsertRule(e),this.markLocalEdit(),this.markTouched();let{id:t,...r}=e;return t&&this.rules.some(o=>o.id===t)?(this.updateRule(t,r),this.rules.find(o=>o.id===t)??null):this.addRule(r)}replaceAllRules(e,t){if(this.remote)return null;this.markTouched();let r=e.map(o=>o&&typeof o=="object"&&typeof o.id=="string"?o:{...o,id:`ovr_${Date.now().toString(36)}_${++this.idCounter}`,createdAt:Date.now()});return this.enabled=t,this.commit(As(r)),this.rules.slice()}updateRule(e,t){let r=this.rules.findIndex(n=>n.id===e);if(r===-1)return;let o=[...this.rules];o[r]={...o[r],...t,hits:0,seen:0},this.commit(o)}setRuleEnabled(e,t){let r=this.rules.findIndex(n=>n.id===e);if(r===-1||this.rules[r].enabled===t)return;this.remote?.setRuleEnabled(e,t),this.markLocalEdit(),this.markTouched();let o=[...this.rules];o[r]={...o[r],enabled:t,hits:t?0:o[r].hits,seen:t?0:o[r].seen},this.commit(o)}removeRule(e){let t=this.rules.filter(r=>r.id!==e);t.length!==this.rules.length&&(this.remote?.removeRule(e),this.markLocalEdit(),this.markTouched(),this.commit(t))}clearRules(){this.rules.length!==0&&(this.remote?.clearRules(),this.markLocalEdit(),this.markTouched(),this.commit([]))}recordMatch(e){let t=this.rules.findIndex(o=>o.id===e);if(t===-1)return;let r=[...this.rules];r[t]={...r[t],seen:r[t].seen+1},this.rules=r,this.rebuild()}recordHit(e){let t=this.rules.findIndex(s=>s.id===e);if(t===-1)return;let r=this.rules[t],o=r.hits+1,n=typeof r.times=="number"&&o>=r.times,i=[...this.rules];if(i[t]={...r,hits:o,enabled:n?false:r.enabled},n){this.commit(i);return}this.rules=i,this.rebuild(),this.scheduleHitEmit()}isLoaded(){return!!this.remote||this.loaded}ensureLoaded(){return this.remote||this.loaded?Promise.resolve():this.loadPromise?this.loadPromise:(this.loadPromise=(async()=>{let e=null;try{e=await zs.getItem(ao.network.overrides())}catch{}this.hydrate(e)})(),this.loadPromise)}loadNow(){if(this.remote||this.loaded||this.loadPromise)return;let e;try{e=globalThis.localStorage?.getItem(ao.network.overrides())??null}catch{return}e!==null&&this.hydrate(e)}hydrate(e){try{if(e&&!this.dirty){let t=JSON.parse(e);this.enabled=t?.enabled!==false,this.rules=As(t?.rules),this.launchStreak=typeof t?.launchStreak=="number"?t.launchStreak:0,this.autoPaused=t?.autoPaused===true&&!this.enabled,this.applyLaunchGuard(),this.rebuild()}}catch{}finally{this.loaded=true,this.syncKeepAlive(),this.emit()}}applyLaunchGuard(){if(!this.enabled||this.activeCount()===0||this.rules.some(e=>e.enabled&&e.sandbox)){this.launchStreak=0;return}fh()||(this.launchStreak+=1,this.launchStreak>=ph&&(this.enabled=false,this.autoPaused=true,this.launchStreak=0),this.persist())}syncKeepAlive(){let e=!this.engineDisabled&&this.activeCount()>0;if(e&&!this.keepAlive){Oi(),this.keepAlive=fr(()=>{});return}!e&&this.keepAlive&&(this.keepAlive(),this.keepAlive=null,Pt()===0&&pr())}scheduleHitEmit(){this.hitEmitTimer===null&&(this.hitEmitTimer=setTimeout(()=>{this.hitEmitTimer=null,this.emit()},yh))}commit(e){this.dirty=true,this.rules=e.slice(0,Ze),this.rebuild(),this.syncKeepAlive(),this.emit(),this.persist()}rebuild(){this.state={enabled:this.enabled,rules:this.rules,autoPaused:this.autoPaused}}markTouched(){this.launchStreak=0,this.autoPaused=false}noteHealthyLaunch(){this.launchStreak===0&&!this.autoPaused||(this.markTouched(),this.persist(),this.rebuild(),this.emit())}persist(){this.remote||zs.setItem(ao.network.overrides(),JSON.stringify({enabled:this.enabled,rules:this.rules,launchStreak:this.launchStreak,autoPaused:this.autoPaused})).catch(()=>{})}emit(){this.listeners.forEach(e=>e())}},_=new mh;Kl({getRules:()=>_.getRules(),ready:()=>_.ensureLoaded(),isReady:()=>_.isLoaded(),recordHit:e=>_.recordHit(e),recordMatch:e=>_.recordMatch(e)});typeof window<"u"&&typeof document<"u"&&!(typeof navigator<"u"&&navigator.product==="ReactNative")&&_.loadNow();function lo(){let e=ch(tr(s=>_.subscribe(s),[]),()=>_.getState(),()=>_.getState()),t=tr(s=>_.setEnabled(s),[]),r=tr(s=>_.upsertRule(s),[]),o=tr((s,l)=>_.setRuleEnabled(s,l),[]),n=tr(s=>_.removeRule(s),[]),i=tr(()=>_.clearRules(),[]);return{enabled:e.enabled,rules:e.rules,autoPaused:e.autoPaused,activeCount:_.activeCount(),setEnabled:t,upsertRule:r,setRuleEnabled:o,removeRule:n,clearRules:i,isRuleSpent:Xo}}O();function bh(e,t){if(t.length===0)return[];let r=new Set(t.map(n=>n.id)),o=new Set;for(let n of t){let i;for(let s of e){if(s.override&&r.has(s.override.ruleId)){o.add(s.id);continue}_o(n,s.url,String(s.method||"GET"),s.requestHeaders)&&(s.timestamp>=n.createdAt?o.add(s.id):(!i||s.timestamp>i.timestamp)&&(i=s))}i&&o.add(i.id)}return e.filter(n=>o.has(n.id))}O();var vh=[];function xn(e,t,r){return t.length===0?{pinned:vh,rest:e}:{pinned:t,rest:r.size===0?e:e.filter(o=>!r.has(o.id))}}import{jsx as Pe,jsxs as $t}from"react/jsx-runtime";var Sh=e=>e.id;function wh({events:e,onEventPress:t,onLongPress:r,savedLiveIds:o,onClearPinned:n}){return e.length===0?null:$t(m,{style:Le.pinnedSection,children:[$t(m,{style:Le.pinnedHeader,children:[Pe(Hc,{size:11,active:true,color:Ee.semantic.info}),$t(b,{style:Le.pinnedTitle,children:["PINNED \xB7 ",e.length]}),Pe(F,{onPress:n,"sentry-label":"ignore unpin all",style:Le.pinnedClear,children:Pe(b,{style:Le.pinnedClearText,children:"Unpin all"})})]}),e.map(i=>Pe(er,{event:i,onPress:t,onLongPress:r,pinned:true,saved:o.has(i.id)},i.id))]})}function xh({events:e,onEventPress:t,onLongPress:r,savedLiveIds:o,paused:n,onTogglePaused:i}){return e.length===0?null:$t(m,{style:[Le.overriddenSection,n&&Le.overriddenSectionOff],children:[$t(m,{style:Le.overriddenHeader,children:[Pe(Ac,{size:11,color:n?Ee.text.muted:Ee.semantic.warning}),Pe(b,{testID:"buoy-network-overridden-strip",style:[Le.overriddenTitle,n&&Le.overriddenTitleOff],children:n?`PAUSED \xB7 ${e.length}`:`OVERRIDDEN \xB7 ${e.length}`}),Pe(F,{onPress:i,"sentry-label":"ignore pause overrides",style:Le.overriddenManage,children:Pe(b,{style:[Le.overriddenManageText,n&&Le.overriddenTitleOff],children:n?"Resume":"Pause"})})]}),e.map(s=>Pe(er,{event:s,onPress:t,onLongPress:r,overridden:true,saved:o.has(s.id)},s.id))]})}function Ch({visible:e,paused:t,filter:r,ignoredPatterns:o,isPro:n,searchText:i,onEventPress:s,onUpgradePress:l}){let{visibleEvents:a,hasLockedEvents:u,lockedEventCount:d,totalEvents:g}=kr({filter:r,ignoredPatterns:o,paused:t,visible:e,isPro:n}),{pinnedEvents:x,pinnedLiveIds:y,savedLiveIds:R,togglePin:h,clearPinned:C}=Zt(),{rules:k,enabled:w,setEnabled:I,isRuleSpent:z}=lo(),$=Dc(Y=>{h(Y)},[h]);if(!e)return null;let{pinned:P,rest:A}=xn(a,x,y),v=k.filter(Y=>Y.enabled&&!z(Y)),c=bh([...P,...A],v),p=new Set(c.map(Y=>Y.id)),f=P.filter(Y=>!p.has(Y.id)),S=p.size?A.filter(Y=>!p.has(Y.id)):A,D=!t,H=({item:Y})=>Pe(er,{event:Y,onPress:s,onLongPress:$,saved:R.has(Y.id)}),V=()=>f.length>0||c.length>0?null:Pe(Nc,{testID:"buoy-network-empty",...$c({subject:"requests",search:i,total:g,capturing:D,waiting:{otto:"fishing",title:"No network events",message:"Network requests will appear here"},paused:{title:"No network events",message:"Enable interception to start capturing"}})}),Z=()=>{if(!u)return null;let Y=i.length>0,L=Y?`${d} matching ${d===1?"request":"requests"} in locked history`:`${d} requests locked`;return Pe(qs,{title:L,subtitle:Y?"Upgrade to Pro to search your full request history":"Upgrade to Pro to unlock full request history",onPress:l})};return $t(m,{style:Le.root,children:[D?null:$t(m,{style:Le.disabledBanner,children:[Pe(Mc,{size:14,color:Ee.semantic.warning}),Pe(b,{style:Le.disabledText,children:"Network interception is disabled"})]}),Pe(xh,{events:c,onEventPress:s,onLongPress:$,savedLiveIds:R,paused:!w,onTogglePaused:()=>I(!w)}),Pe(wh,{events:f,onEventPress:s,onLongPress:$,savedLiveIds:R,onClearPinned:C}),S.length>0||u?Pe(Ao,{keyboardShouldPersistTaps:"handled",testID:"buoy-network-list",data:S,renderItem:H,keyExtractor:Sh,contentContainerStyle:Le.listContent,showsVerticalScrollIndicator:true,onEndReachedThreshold:.8,scrollEnabled:true,...Fc,extraData:R,"sentry-label":"ignore network events list",ListFooterComponent:Z}):V()]})}var Le=ve.create({root:{flex:1,minHeight:0},overriddenSection:{borderBottomWidth:1,borderBottomColor:Ee.semantic.warning+"44",backgroundColor:Ee.semantic.warningBackground},overriddenSectionOff:{borderBottomColor:Ee.border.default,backgroundColor:Ee.background.card},overriddenTitleOff:{color:Ee.text.muted},overriddenHeader:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:12,paddingTop:8,paddingBottom:4},overriddenTitle:{flex:1,fontSize:10,fontWeight:"700",letterSpacing:.8,color:Ee.semantic.warning},overriddenManage:{paddingHorizontal:6,paddingVertical:2},overriddenManageText:{fontSize:10,fontWeight:"600",color:Ee.semantic.warning},pinnedSection:{borderBottomWidth:1,borderBottomColor:Ee.border.default,paddingBottom:4},pinnedHeader:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:20,paddingTop:10,paddingBottom:6},pinnedTitle:{flex:1,color:Ee.semantic.info,fontSize:10,fontWeight:"700",letterSpacing:.6,fontFamily:jc},pinnedClear:{paddingHorizontal:6,paddingVertical:2},pinnedClearText:{color:Ee.text.muted,fontSize:10},disabledBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:Ee.semantic.warningBackground,borderRadius:8,borderWidth:1,borderColor:Ee.semantic.warning+"20"},disabledText:{color:Ee.semantic.warning,fontSize:11,flex:1},listContent:{paddingTop:8}});O();Se();import{useState as kh}from"react";import{Bookmark as Th,CopyButton as Rh,Search as Eh,macOSColors as Xe,useLimit as Ih,ToolEmptyState as Ph,resolveListEmptyState as Lh,EVENT_LIST_PRESET as Bh,monoFont as qh}from"@buoy-gg/shared-ui/web";O();function Hs(e,t,r){let o=e.slice(0,Math.min(t,vt)),n=o.map(i=>i.event);return{events:r?Sr(n,{searchText:r}):n,lockedCount:e.length-o.length}}import{jsx as st,jsxs as uo}from"react/jsx-runtime";var Oh=e=>e.id;function Ms({visible:e,isPro:t,copySettings:r,search:o,onSearchChange:n,onEventPress:i,onUpgradePress:s}){let{savedRecords:l,pinnedLiveIds:a,toggleSave:u,clearSaved:d}=Zt(),g=Ih("network.saved"),[x,y]=kh(""),R=o!=null&&n!=null,h=R?o:x,C=R?n:y;if(!e)return null;let{events:k,lockedCount:w}=Hs(l,g,h),I=P=>{u(P)},z=({item:P})=>st(er,{event:P,onPress:i,onLongPress:I,saved:true,pinned:a.has(P.id)}),$=()=>w===0?null:st(qs,{title:`${w} saved ${w===1?"request":"requests"} locked`,subtitle:`Your plan keeps ${g}. Upgrade to Pro to unlock the rest.`,onPress:s});return uo(m,{style:at.root,children:[uo(m,{style:at.toolbar,children:[st(Th,{size:11,color:Xe.semantic.debug}),uo(b,{style:at.toolbarTitle,children:["SAVED \xB7 ",l.length,g>=vt?"":`/${g}`]}),t?st(Rh,{value:()=>Is(k,r),size:13,buttonStyle:at.toolbarButton,colors:{idle:Xe.text.secondary,success:Xe.semantic.success,error:Xe.semantic.error},disabled:k.length===0}):null,st(F,{onPress:d,"sentry-label":"ignore clear saved",style:at.toolbarClear,disabled:l.length===0,children:st(b,{style:[at.toolbarClearText,l.length===0&&at.toolbarClearTextDisabled],children:"Clear all"})})]}),l.length>0?uo(m,{style:at.searchRow,children:[st(Eh,{size:13,color:Xe.text.secondary}),st(Jt,{style:at.searchInput,placeholder:"Search saved requests\u2026",placeholderTextColor:Xe.text.muted,value:h,onChangeText:C,"sentry-label":"ignore saved search",accessibilityLabel:"Search saved requests",autoCapitalize:"none",autoCorrect:false,returnKeyType:"search"})]}):null,l.length===0||h.trim().length>0&&k.length===0&&w===0?st(Ph,{testID:"buoy-network-saved-empty",...Lh({subject:"saved requests",verb:"kept",search:l.length===0?"":h,total:l.length,waiting:{otto:"empty",title:"No saved requests",message:"Open a request and tap the bookmark to keep it here \u2014 saved requests survive Clear and app restarts."}})}):st(Ao,{keyboardShouldPersistTaps:"handled",data:k,renderItem:z,keyExtractor:Oh,contentContainerStyle:at.listContent,showsVerticalScrollIndicator:true,scrollEnabled:true,...Bh,extraData:a,"sentry-label":"ignore saved requests list",ListFooterComponent:$})]})}var at=ve.create({root:{flex:1,minHeight:0},toolbar:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:20,paddingTop:10,paddingBottom:6},toolbarTitle:{flex:1,color:Xe.semantic.debug,fontSize:10,fontWeight:"700",letterSpacing:.6,fontFamily:qh},toolbarButton:{width:26,height:26,borderRadius:6,alignItems:"center",justifyContent:"center"},toolbarClear:{paddingHorizontal:6,paddingVertical:2},toolbarClearText:{color:Xe.text.muted,fontSize:10},toolbarClearTextDisabled:{color:Xe.text.disabled},searchRow:{flexDirection:"row",alignItems:"center",gap:6,marginHorizontal:12,marginBottom:8,paddingHorizontal:10,paddingVertical:5,backgroundColor:Xe.background.input,borderRadius:10,borderWidth:1,borderColor:Xe.border.default},searchInput:{flex:1,color:Xe.text.primary,fontSize:13,paddingVertical:2},listContent:{paddingTop:4}});O();Se();import{useCallback as zh,useEffect as co,useState as Dh}from"react";import{AlertCircle as Ah,AlertTriangle as Hh,DevToolsCard as Mh,EmptyState as Nh,MethodBadge as $h,Plus as Fh,Trash2 as jh,macOSColors as oe,useLimit as Wh,monoFont as Vh}from"@buoy-gg/shared-ui/web";O();Se();import{useMemo as Ns,useState as ho}from"react";import{ChevronDown as Uh,ChevronRight as _h,macOSColors as G,useSafeAreaInsets as Xh,monoFont as Jh}from"@buoy-gg/shared-ui/web";O();Se();import{useState as po,useMemo as fo,useCallback as Tr,useRef as Cn,useEffect as Gh,memo as yo}from"react";import{displayValue as Kh,buoyColors as B,monoFont as Fe}from"@buoy-gg/shared-ui/web";import{CopyButton as Yh}from"@buoy-gg/shared-ui/web";import{ChevronRight as Zh,ChevronDown as Qh,Trash as $s}from"@buoy-gg/shared-ui/web";import{CyberpunkInput as ep}from"@buoy-gg/shared-ui/web/dataViewer";O();var Ft=(e,t,r)=>{if(t.length===0)return r;if(e instanceof Map){let o=new Map(e);if(t.length===1)return o.set(t[0],r),o;let[n,...i]=t,s=o.get(n);return o.set(n,Ft(s??null,i,r)),o}if(e instanceof Set){let o=Ft(Array.from(e),t,r);return new Set(Array.isArray(o)?o:[])}if(Array.isArray(e)){let o=[...e];if(t.length===1)return o[t[0]]=r,o;let[n,...i]=t;return o[n]=Ft(o[n],i,r),o}if(e instanceof Object){let o={...e};if(t.length===1)return o[t[0]]=r,o;let[n,...i]=t;return o[n]=Ft(o[n],i,r),o}return e};O();var jt=(e,t)=>{if(e instanceof Map){let r=new Map(e);if(t.length===1)return r.delete(t[0]),r;let[o,...n]=t;return r.set(o,jt(r.get(o),n)),r}if(e instanceof Set){let r=jt(Array.from(e),t);return new Set(r)}if(Array.isArray(e)){let r=[...e];if(t.length===1)return r.filter((i,s)=>s.toString()!==t[0]);let[o,...n]=t;return r[o]=jt(r[o],n),r}if(e instanceof Object){let r={...e};if(t.length===1)return delete r[t[0]],r;let[o,...n]=t;return r[o]=jt(r[o],n),r}return e};O();import{createContext as tp,useContext as rp}from"react";var Fs=tp(null);function go(){return rp(Fs)}import{Fragment as mo,jsx as ee,jsxs as Ne}from"react/jsx-runtime";var Rr=100,rr={top:8,bottom:8,left:8,right:8},js=12,op=(e,t=Rr)=>{if(t<1||e.length===0)return[];let r=[];for(let o=0;o<e.length;o+=t)r.push(e.slice(o,o+t));return r},kn=yo(({expanded:e,isFocused:t=false,isMain:r=false})=>ee(m,{style:[U.expanderIcon,r&&U.expanderIconMain,e?U.expanded:U.collapsed],children:e?ee(Qh,{size:r?14:js,color:t?B.primary:r?B.text:B.textSecondary,strokeWidth:2.5}):ee(Zh,{size:r?14:js,color:t?B.primary:r?B.text:B.textSecondary,strokeWidth:2.5})}));kn.displayName="Expander";var Ws=yo(({value:e,isFocused:t=false})=>ee(Yh,{value:e,isFocused:t,buttonStyle:t?{...U.buttonStyle,...U.buttonStyleFocused}:U.buttonStyle}));Ws.displayName="CopyButton";var Tn=yo(({dataPath:e,isFocused:t=false})=>{let r=go(),o=Tr(()=>{r&&r.onChange(jt(r.root,e))},[r,e]);return r?ee(F,{"sentry-label":"ignore devtools explorer delete button",onPress:o,style:[U.deleteButton,t&&U.deleteButtonFocused],accessibilityLabel:"Delete item",hitSlop:rr,activeOpacity:.7,children:ee($s,{size:14,strokeWidth:2,color:t?B.error:B.error+"CC"})}):null});Tn.displayName="DeleteItemButton";var Vs=yo(({dataPath:e,isFocused:t=false})=>{let r=go(),o=Tr(()=>{r&&r.onChange(Ft(r.root,e,[]))},[r,e]);return r?ee(F,{"sentry-label":"ignore devtools explorer clear button",style:[U.clearButton,t&&U.clearButtonFocused],"aria-label":"Remove all items",onPress:o,hitSlop:rr,activeOpacity:.7,children:ee(b,{style:[U.clearButtonText,{color:t?B.warning:B.warning+"CC"}],children:"[]"})}):null});Vs.displayName="ClearArrayButton";function np({dataPath:e,value:t,itemsDeletable:r}){let o=go(),n=Tr(()=>{if(!o)return;let a=typeof t=="boolean"?t:false;o.onChange(Ft(o.root,e,!a))},[o,e,t]),i=Tr(()=>{o&&o.onChange(jt(o.root,e))},[o,e]);if(!o)return null;let s=t?U.toggleBadgeTrue:U.toggleBadgeFalse,l=t?U.toggleTextTrue:U.toggleTextFalse;return Ne(F,{"sentry-label":"ignore devtools explorer toggle button",style:U.modernToggleButton,onPress:n,hitSlop:rr,activeOpacity:.8,children:[ee(m,{style:[U.toggleBadge,s],children:ee(b,{style:[U.toggleBadgeText,l],children:t?"TRUE":"FALSE"})}),r&&ee(F,{"sentry-label":"ignore devtools explorer delete button in toggle",onPress:i,style:U.deleteButtonInToggle,accessibilityLabel:"Delete item",hitSlop:rr,activeOpacity:.7,children:ee($s,{size:14,strokeWidth:2,color:B.error+"CC"})})]})}function Rn({editable:e,label:t,value:r,defaultExpanded:o,dataPath:n,itemsDeletable:i,dataVersion:s=0}){let l=go(),[a,u]=po(false),[d,g]=po("");Gh(()=>{if(r!=null&&(typeof r=="string"||typeof r=="number")){let p=r.toString();g(p)}},[r,t,s]);let x=fo(()=>{let p=t.toUpperCase();return["DATA","QUERY","QUERYKEY","TYPES","STATS","OPTIONS","OBSERVERS"].includes(p)},[t]),[y,R]=po((o||[]).includes(t)),h=()=>R(p=>!p),[C,k]=po([]),w=fo(()=>r==null||typeof r!="object"?[]:Array.isArray(r)?(r.length>1e3?r.slice(0,1e3):r).map((p,f)=>({label:f.toString(),value:p})):r instanceof Map?Array.from(r.entries()).slice(0,1e3).map(([p,f])=>({label:p.toString(),value:f})):r instanceof Set?Array.from(r).slice(0,1e3).map((p,f)=>({label:f.toString(),value:p})):Object.entries(r).slice(0,1e3).map(([p,f])=>({label:p,value:f})),[r]),I=fo(()=>Array.isArray(r)?"array":r===null||typeof r!="object"?typeof r:r instanceof Map||r instanceof Set?"Iterable":"object",[r]),z=fo(()=>op(w,Rr),[w]),$=n??[],P=Cn(l),A=Cn($),v=Cn(I);P.current=l,A.current=$,v.current=I;let c=Tr((p,f)=>{g(f);let S=P.current;if(!S||p&&isNaN(Number(f)))return;let D=v.current==="number"?Number(f):f;S.onChange(Ft(S.root,A.current,D))},[g]);return ee(m,{style:U.minWidthWrapper,children:Ne(m,{style:U.fullWidthMarginRight,children:[z.length>0&&Ne(mo,{children:[Ne(m,{style:[U.flexRowItemsCenterGap,x&&U.flexRowItemsCenterGapMain],children:[Ne(F,{"sentry-label":"ignore devtools explorer expander button",style:U.expanderButton,onPress:h,hitSlop:rr,activeOpacity:.6,children:[ee(kn,{expanded:y,isFocused:a,isMain:x}),ee(b,{style:[U.labelText,a&&U.labelTextFocused,x&&U.labelTextMain],children:t}),ee(b,{style:U.textGray500,children:`${String(I).toLowerCase()==="iterable"?"(Iterable) ":""}${w.length} ${w.length>1?"items":"item"}`})]}),e&&Ne(m,{style:U.flexRowGapItemsCenter,children:[ee(Ws,{value:r,isFocused:a}),i&&l!==null&&ee(Tn,{dataPath:$,isFocused:a}),I==="array"&&l!==null&&ee(Vs,{dataPath:$,isFocused:a})]})]}),y&&Ne(mo,{children:[z.length===1&&ee(m,{style:[U.singleEntryContainer,x&&U.singleEntryContainerMain],children:w.map((p,f)=>ee(Rn,{defaultExpanded:o,label:p.label,value:p.value,editable:e,dataPath:[...$,p.label],itemsDeletable:I==="array"||I==="Iterable"||I==="object",dataVersion:s},p.label+f))}),z.length>1&&ee(m,{style:U.multiEntryContainer,children:z.map((p,f)=>ee(m,{children:Ne(m,{style:U.relativeOutlineNone,children:[Ne(F,{"sentry-label":"ignore devtools explorer page toggle",onPress:()=>k(S=>S.includes(f)?S.filter(D=>D!==f):[...S,f]),style:U.pageExpanderButton,hitSlop:rr,children:[ee(kn,{expanded:C.includes(f)}),Ne(b,{style:U.pageRangeText,children:["[",f*Rr,"...",f*Rr+Rr-1,"]"]})]}),C.includes(f)&&ee(m,{style:U.entriesContainer,children:p.map(S=>ee(Rn,{defaultExpanded:o,label:S.label,value:S.value,editable:e,dataPath:[...$,S.label],dataVersion:s},S.label))})]})},f))})]})]}),z.length===0&&Ne(m,{style:U.flexRowGapFullWidth,children:[e&&l!==null&&(I==="string"||I==="number"||I==="boolean")?Ne(mo,{children:[e&&l&&(I==="string"||I==="number")&&ee(m,{style:U.nebulaInputWrapper,children:ee(ep,{label:t,accessibilityLabel:"Data input field for editing values",style:[I==="number"?U.textNumber:U.textString],keyboardType:I==="number"?"numeric":"default",value:d,onChangeText:p=>c(I==="number",p),onFocus:()=>u(true),onBlur:()=>u(false),showNumberControls:I==="number",onIncrement:()=>{let p=Number(d)||0;c(true,String(p+1))},onDecrement:()=>{let p=Number(d)||0;c(true,String(p-1))},showDeleteButton:i,onDelete:()=>{l.onChange(jt(l.root,$))}})}),I==="boolean"&&Ne(m,{style:U.booleanRowContainer,children:[ee(b,{style:U.booleanLabel,children:t}),ee(m,{style:U.booleanToggleWrapper,children:ee(np,{dataPath:$,value:r,itemsDeletable:i})})]})]}):Ne(mo,{children:[ee(b,{style:U.text344054,children:t}),ee(b,{style:U.displayValueText,children:Kh(r)})]}),e&&i&&l!==null&&I!=="string"&&I!=="number"&&I!=="boolean"&&ee(Tn,{dataPath:$,isFocused:a})]})]})})}var U=ve.create({buttonStyle:{backgroundColor:B.card+"E6",borderWidth:1,borderColor:B.textSecondary+"33",borderRadius:6,flexDirection:"row",alignItems:"center",justifyContent:"center",width:28,height:28,position:"relative",shadowColor:"#000",shadowOffset:{width:0,height:1},shadowOpacity:.2,shadowRadius:2},buttonStyleFocused:{borderColor:B.primary+"CC",backgroundColor:B.primary+"26",shadowColor:B.primary,shadowOpacity:.3,shadowRadius:4},deleteButton:{backgroundColor:B.error+"1A",borderColor:B.error+"4D",borderWidth:1,borderRadius:6,padding:0,alignItems:"center",justifyContent:"center",width:28,height:28,position:"relative",shadowColor:B.error,shadowOffset:{width:0,height:0},shadowOpacity:.15,shadowRadius:3},deleteButtonFocused:{borderColor:B.error+"CC",backgroundColor:B.error+"33",shadowOpacity:.3,shadowRadius:5},deleteButtonInToggle:{backgroundColor:B.error+"1A",borderColor:B.error+"4D",borderWidth:1,borderRadius:6,padding:0,alignItems:"center",justifyContent:"center",width:28,height:28,shadowColor:B.error,shadowOffset:{width:0,height:0},shadowOpacity:.15,shadowRadius:3},clearButton:{backgroundColor:B.warning+"1A",borderWidth:1,borderColor:B.warning+"4D",borderRadius:6,flexDirection:"row",padding:0,alignItems:"center",justifyContent:"center",width:28,height:28,position:"relative",zIndex:10,shadowColor:B.warning,shadowOffset:{width:0,height:0},shadowOpacity:.15,shadowRadius:3},clearButtonFocused:{borderColor:B.warning+"CC",backgroundColor:B.warning+"33",shadowOpacity:.3,shadowRadius:5},clearButtonText:{fontSize:12,fontWeight:"700",fontFamily:Fe},expanderIcon:{width:18,height:18,alignItems:"center",justifyContent:"center",marginRight:1,backgroundColor:B.textSecondary+"14",borderRadius:3},expanderIconMain:{backgroundColor:B.textSecondary+"1A",width:20,height:20,borderRadius:4,borderWidth:.5,borderColor:B.textSecondary+"33"},expanded:{transform:[{rotate:"0deg"}]},collapsed:{transform:[{rotate:"0deg"}]},minWidthWrapper:{minWidth:180,fontSize:11,flexDirection:"row",flexWrap:"wrap",width:"100%",marginVertical:.5},fullWidthMarginRight:{position:"relative",width:"100%",marginRight:1},flexRowItemsCenterGap:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:3,paddingHorizontal:6,marginVertical:1,borderRadius:4,backgroundColor:B.card+"66",borderWidth:.5,borderColor:B.textSecondary+"1A"},flexRowItemsCenterGapMain:{backgroundColor:B.card+"E6",borderLeftWidth:2.5,borderLeftColor:B.textSecondary+"80",borderColor:B.textSecondary+"26",paddingVertical:5,paddingHorizontal:8,marginBottom:3,borderWidth:1,shadowColor:"#000",shadowOffset:{width:0,height:0},shadowOpacity:.08,shadowRadius:3},expanderButton:{flexDirection:"row",alignItems:"center",backgroundColor:"transparent",paddingVertical:1,paddingHorizontal:2,gap:6,borderWidth:0,minHeight:24,flex:1},labelText:{color:B.textSecondary,fontSize:10,fontWeight:"600",marginRight:4,fontFamily:Fe,letterSpacing:.4},labelTextFocused:{color:B.text},labelTextMain:{color:B.text,fontSize:11,fontWeight:"700",letterSpacing:.6},textGray500:{color:B.textMuted,fontSize:10,fontWeight:"400",fontFamily:Fe,opacity:.7},pageRangeText:{color:B.textSecondary,fontSize:10,fontWeight:"600",fontFamily:Fe},flexRowGapItemsCenter:{flexDirection:"row",alignItems:"center",gap:4,paddingLeft:2},singleEntryContainer:{marginLeft:2,marginTop:2,paddingLeft:8,borderLeftWidth:1.5,borderLeftColor:B.textSecondary+"40"},singleEntryContainerMain:{borderLeftColor:B.textSecondary+"4D",marginLeft:4,paddingLeft:10},multiEntryContainer:{marginLeft:2,marginTop:2,paddingLeft:8,borderLeftWidth:1.5,borderLeftColor:B.textSecondary+"40"},multiEntryContainerMain:{borderLeftColor:B.textSecondary+"4D",marginLeft:4,paddingLeft:10},relativeOutlineNone:{position:"relative"},pageExpanderButton:{flexDirection:"row",alignItems:"center",backgroundColor:B.card+"66",paddingVertical:3,paddingHorizontal:6,gap:6,borderRadius:4,borderWidth:.5,borderColor:B.textSecondary+"1A",marginBottom:2,minHeight:24},entriesContainer:{marginLeft:2,paddingLeft:8,marginTop:2,borderLeftWidth:1.5,borderLeftColor:B.textSecondary+"40"},textNumber:{color:B.text,fontWeight:"600",fontFamily:Fe},textString:{color:B.text,fontFamily:Fe},flexRowGapFullWidth:{flexDirection:"row",width:"100%",alignItems:"center",marginVertical:1,gap:6,paddingHorizontal:4,paddingVertical:2,borderRadius:3},text344054:{color:B.textSecondary,fontWeight:"600",fontSize:9,minWidth:50,fontFamily:Fe,letterSpacing:.4,opacity:.8},numberInputButtons:{position:"absolute",right:8,top:"50%",transform:[{translateY:-18}],flexDirection:"row",gap:4,zIndex:10},touchableButton:{width:32,height:32,borderRadius:6,backgroundColor:B.card+"E6",borderWidth:1,borderColor:B.textSecondary+"33",alignItems:"center",justifyContent:"center",marginLeft:2,shadowColor:"#000",shadowOffset:{width:0,height:1},shadowOpacity:.2,shadowRadius:2},touchableButtonFocused:{borderColor:B.primary+"CC",backgroundColor:B.primary+"26",shadowColor:B.primary,shadowOffset:{width:0,height:0},shadowOpacity:.3,shadowRadius:4,elevation:3},nebulaInputWrapper:{flex:1,width:"100%",position:"relative"},displayValueText:{flex:1,color:B.text,fontWeight:"400",fontFamily:Fe,fontSize:12,paddingVertical:6,paddingHorizontal:10,borderRadius:6,borderWidth:1,borderColor:B.textMuted+"66",minHeight:34},dataRow:{flexDirection:"row",alignItems:"center",paddingVertical:4,paddingHorizontal:8,minHeight:44,gap:12},dataLabel:{color:B.textSecondary,fontSize:13,fontWeight:"500",minWidth:80,flexShrink:0},dataValueContainer:{flex:1,flexDirection:"row",alignItems:"center"},inputWithActions:{flex:1,position:"relative"},numberControls:{position:"absolute",right:8,top:"50%",transform:[{translateY:-16}],flexDirection:"column",gap:2},numberButton:{width:32,height:16,borderRadius:4,alignItems:"center",justifyContent:"center",borderWidth:1,borderColor:B.primary+"0F"},readOnlyValue:{color:B.text,fontSize:13,fontFamily:Fe,paddingVertical:8,paddingHorizontal:12,borderRadius:6,borderWidth:1,borderColor:B.textMuted+"33",flex:1},actionButtons:{flexDirection:"row",gap:6,paddingLeft:8},booleanContainer:{flexDirection:"row",alignItems:"center",padding:8,borderRadius:6,borderWidth:1,borderColor:B.textMuted+"4D",flex:1},booleanText:{marginLeft:8,color:B.warning,fontWeight:"500",fontFamily:Fe},modernToggleButton:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",borderRadius:6,borderWidth:1,borderColor:B.textMuted+"99",paddingHorizontal:8,paddingVertical:6,marginVertical:2,minHeight:34,gap:8},toggleIconContainer:{marginRight:6},toggleIcon:{padding:8,borderRadius:8,alignItems:"center",justifyContent:"center",width:32,height:32},toggleIconSmall:{width:8,height:8,borderRadius:4},toggleContent:{flex:1,minWidth:0},toggleLabel:{color:"#E5E7EB",fontSize:11,fontWeight:"600",fontFamily:Fe,letterSpacing:.3},toggleStatus:{color:"#9CA3AF",fontSize:11},toggleBadge:{marginLeft:6,paddingHorizontal:6,paddingVertical:3,borderRadius:4,borderWidth:1},toggleBadgeText:{fontSize:9,fontWeight:"700",textTransform:"uppercase",letterSpacing:.8,fontFamily:Fe},toggleIconTrue:{backgroundColor:B.primary},toggleIconFalse:{backgroundColor:B.textMuted},toggleBadgeTrue:{backgroundColor:B.primary+"1A",borderColor:B.primary+"4D"},toggleBadgeFalse:{backgroundColor:B.textMuted+"1A",borderColor:B.textMuted+"4D"},toggleTextTrue:{color:B.primary,fontWeight:"600"},toggleTextFalse:{color:B.textSecondary,fontWeight:"500"},booleanRowContainer:{flexDirection:"row",alignItems:"center",width:"100%",gap:8,paddingVertical:2},booleanLabel:{color:B.textSecondary,fontSize:10,fontWeight:"600",fontFamily:Fe,letterSpacing:.4,minWidth:60,flexShrink:0},booleanToggleWrapper:{flex:1}});O();Se();import{useState as ip}from"react";import{absoluteFill as Us,macOSColors as $e}from"@buoy-gg/shared-ui/web";import{jsx as wt,jsxs as En}from"react/jsx-runtime";function In({title:e,hint:t,value:r,placeholder:o="Number",min:n,max:i,onSubmit:s,onCancel:l}){let[a,u]=ip(r!=null?String(r):""),d=()=>{let g=a.trim();if(!g){s(null);return}let x=Number(g);if(!Number.isFinite(x)){s(null);return}let y=x;n!=null&&(y=Math.max(n,y)),i!=null&&(y=Math.min(i,y)),s(y)};return En(m,{style:je.overlay,children:[wt(F,{style:je.backdrop,activeOpacity:1,onPress:l,"sentry-label":"ignore dismiss number prompt"}),En(m,{style:je.panel,children:[wt(b,{style:je.title,children:e}),wt(Jt,{style:je.input,value:a,onChangeText:u,placeholder:o,placeholderTextColor:$e.text.muted,keyboardType:"number-pad",autoFocus:true,selectTextOnFocus:true,onSubmitEditing:d,returnKeyType:"done","sentry-label":"ignore number prompt input",accessibilityLabel:e}),t?wt(b,{style:je.hint,children:t}):null,En(m,{style:je.actions,children:[wt(F,{onPress:l,"sentry-label":"ignore cancel number prompt",style:[je.button,je.cancelButton],children:wt(b,{style:je.cancelText,children:"Cancel"})}),wt(F,{onPress:d,"sentry-label":"ignore save number prompt",style:[je.button,je.saveButton],children:wt(b,{style:je.saveText,children:"Set"})})]})]})]})}var je=ve.create({overlay:{...Us,zIndex:40},backdrop:{...Us,backgroundColor:"rgba(0,0,0,0.6)"},panel:{marginHorizontal:12,marginTop:12,padding:14,borderRadius:10,borderWidth:1,borderColor:$e.border.hover,backgroundColor:$e.background.card,gap:10},title:{fontSize:13,fontWeight:"700",color:$e.text.primary},input:{backgroundColor:$e.background.input,borderWidth:1,borderColor:$e.border.input,borderRadius:6,paddingHorizontal:12,paddingVertical:10,fontSize:16,fontWeight:"700",color:$e.text.primary},hint:{fontSize:10,color:$e.text.muted},actions:{flexDirection:"row",gap:8},button:{flex:1,paddingVertical:10,borderRadius:6,alignItems:"center",borderWidth:1},cancelButton:{borderColor:$e.border.default,backgroundColor:$e.background.base},cancelText:{fontSize:12,fontWeight:"600",color:$e.text.secondary},saveButton:{borderColor:$e.semantic.info,backgroundColor:`${$e.semantic.info}22`},saveText:{fontSize:12,fontWeight:"700",color:$e.semantic.info}});import{Fragment as _s,jsx as X,jsxs as qe}from"react/jsx-runtime";var sp=["GET","POST","PUT","PATCH","DELETE"],Xs=[0,500,1e3,3e3,1e4],Js=[{id:"500",label:"Server error",code:"500",danger:true,patch:{kind:"respond",status:500,statusText:"Internal Server Error"}},{id:"401",label:"Unauthorized",code:"401",danger:true,patch:{kind:"respond",status:401,statusText:"Unauthorized"}},{id:"404",label:"Not found",code:"404",danger:true,patch:{kind:"respond",status:404,statusText:"Not Found"}},{id:"403",label:"Forbidden",code:"403",danger:true,patch:{kind:"respond",status:403,statusText:"Forbidden"}},{id:"429",label:"Rate limited",code:"429",danger:true,patch:{kind:"respond",status:429,statusText:"Too Many Requests"}},{id:"503",label:"Unavailable",code:"503",danger:true,patch:{kind:"respond",status:503,statusText:"Service Unavailable"}},{id:"400",label:"Bad request",code:"400",danger:true,patch:{kind:"respond",status:400,statusText:"Bad Request"}},{id:"200",label:"Success",code:"200",patch:{kind:"respond",status:200,statusText:"OK"}},{id:"offline",label:"Offline",danger:true,patch:{kind:"fail",failKind:"network"}},{id:"timeout",label:"Timeout",danger:true,patch:{kind:"fail",failKind:"timeout"}},{id:"passthrough",label:"Real response",patch:{kind:"delay"}}];function ap(e){return e.kind==="delay"?"passthrough":e.kind==="fail"?e.failKind==="timeout"?"timeout":"offline":String(e.status??200)}function lp({outcome:e,active:t,onPress:r}){let o=e.danger?G.semantic.error:G.semantic.info;return qe(F,{onPress:r,"sentry-label":"ignore override outcome",testID:`buoy-network-outcome-${e.label.toLowerCase().replace(/\s+/g,"-")}${e.code?`-${e.code}`:""}`,accessibilityRole:"button",accessibilityLabel:`${e.label}${e.code?` ${e.code}`:""}`,style:[j.outcome,t&&{borderColor:o,backgroundColor:`${o}1F`}],children:[X(b,{style:[j.outcomeLabel,t&&{color:o}],children:e.label}),e.code?X(b,{style:[j.outcomeCode,t&&{color:o}],children:e.code}):null]})}function Gs({title:e,summary:t,open:r,onToggle:o,children:n}){return qe(m,{style:j.disclosure,children:[qe(F,{onPress:o,"sentry-label":"ignore override disclosure",testID:`buoy-network-disclosure-${e.toLowerCase().replace(/\s+/g,"-")}`,accessibilityRole:"button",accessibilityLabel:e,style:j.disclosureHeader,children:[r?X(Uh,{size:12,color:G.text.muted}):X(_h,{size:12,color:G.text.muted}),X(b,{style:j.disclosureTitle,children:e}),t&&!r?X(b,{style:j.disclosureSummary,numberOfLines:1,children:t}):null]}),r?X(m,{style:j.disclosureBody,children:n}):null]})}function or({label:e,active:t,onPress:r}){return X(F,{onPress:r,"sentry-label":"ignore override chip",testID:`buoy-network-chip-${e.toLowerCase().replace(/\s+/g,"-")}`,accessibilityRole:"button",accessibilityLabel:e,style:[j.chip,t&&j.chipActive],children:X(b,{style:[j.chipText,t&&j.chipTextActive],children:e})})}function dp({draft:e,onChange:t,onSave:r,onCancel:o,saveLabel:n="Save",applySafeAreaInset:i=false}){let s=Xh({minBottom:16}),l=i?s.bottom:0,a=S=>t({...e,...S}),[u,d]=ho(!e.urlPattern.trim()),[g,x]=ho(false),[y,R]=ho(null),[h,C]=ho(null),k=ap(e),w=e.kind==="respond"&&typeof e.status=="number"&&!Js.some(S=>S.code===String(e.status)),I=e.kind==="respond",z=e.methods?.[0],$=`${z??"Any"} ${e.urlPattern||"No URL yet"}`,P=Ns(()=>{let S=(e.body??"").trim();if(!S)return"Empty";let D=S.split(`
144
+ `).length;return`${D} line${D===1?"":"s"}`},[e.body]),A=Ns(()=>{let S=(e.body??"").trim();if(!S)return null;try{return JSON.parse(S)}catch{return null}},[e.body]),v=(e.body??"").trim().length>0&&!A,c=e.delayMs??0,p=c>0&&!Xs.includes(c),f=!e.alternate&&typeof e.times=="number"&&e.times!==1;return qe(m,{style:j.root,children:[qe(yt,{testID:"buoy-network-editor-scroll",style:j.scroll,contentContainerStyle:j.scrollContent,keyboardShouldPersistTaps:"handled",children:[qe(Gs,{title:"Applies to",summary:$,open:u,onToggle:()=>d(S=>!S),children:[X(Jt,{style:j.input,value:e.urlPattern,onChangeText:S=>a({urlPattern:S}),testID:"buoy-network-override-pattern",accessibilityLabel:"Override URL pattern",placeholder:"https://api.example.com/v1/users*",placeholderTextColor:G.text.muted,autoCapitalize:"none",autoCorrect:false,multiline:true,"sentry-label":"ignore override url pattern"}),qe(m,{style:j.chipRow,children:[X(or,{label:"Any",active:!z,onPress:()=>a({methods:void 0})}),sp.map(S=>X(or,{label:S,active:z===S,onPress:()=>a({methods:[S]})},S))]})]}),qe(m,{style:j.outcomeGrid,children:[Js.map(S=>X(lp,{outcome:S,active:k===S.id,onPress:()=>a(S.patch)},S.id)),X(F,{onPress:()=>C("status"),"sentry-label":"ignore custom status",accessibilityLabel:"Custom status code",style:[j.customField,w&&j.customFieldActive],children:X(b,{style:[j.customValue,w&&j.customInputActive],children:w?String(e.status):"Custom"})})]}),I?X(Gs,{title:"Response body",summary:P,open:g,onToggle:()=>x(S=>!S),children:y!==null?qe(_s,{children:[X(Jt,{style:[j.input,j.bodyInput],value:y,onChangeText:R,placeholder:"Paste a new body\u2026",placeholderTextColor:G.text.muted,autoCapitalize:"none",autoCorrect:false,autoFocus:true,multiline:true,"sentry-label":"ignore override body paste"}),qe(m,{style:j.inlineActions,children:[X(F,{onPress:()=>R(null),"sentry-label":"ignore cancel body paste",style:j.textButton,children:X(b,{style:j.textButtonMuted,children:"Cancel"})}),X(F,{onPress:()=>{let S=y.trim();try{a({body:JSON.stringify(JSON.parse(S),null,2)})}catch{a({body:S})}R(null)},disabled:!y.trim(),"sentry-label":"ignore apply body paste",style:j.textButton,children:X(b,{style:[j.textButtonLabel,!y.trim()&&j.textButtonDisabled],children:"Replace"})})]})]}):qe(_s,{children:[A!==null?X(Fs.Provider,{value:{root:A,onChange:S=>a({body:JSON.stringify(S,null,2)})},children:X(Rn,{editable:true,label:"",value:A,defaultExpanded:[""]})}):X(b,{style:j.emptyBody,children:v?"This body isn't JSON, so there's no tree to show.":"No body yet."}),X(F,{onPress:()=>R(""),"sentry-label":"ignore edit all body",style:j.textButton,children:X(b,{style:j.textButtonLabel,children:"Edit all"})})]})}):null,qe(m,{style:j.field,children:[X(b,{style:j.subLabel,children:"Delay"}),qe(m,{style:j.chipRow,children:[Xs.map(S=>X(or,{label:S===0?"None":`${S/1e3}s`,active:c===S,onPress:()=>a({delayMs:S})},S)),X(F,{onPress:()=>C("delay"),"sentry-label":"ignore custom delay",accessibilityLabel:"Custom delay in seconds",style:[j.customField,p&&j.customFieldActive],children:X(b,{style:[j.customValue,p&&j.customInputActive],children:p?`${c/1e3}s`:"Custom"})})]})]}),qe(m,{style:j.field,children:[X(b,{style:j.subLabel,children:"Fires"}),X(b,{style:j.subHint,children:"A limited rule switches itself off once it's used up. Every other alternates forever \u2014 the first request through, the next overridden."}),qe(m,{style:j.chipRow,children:[X(or,{label:"Always",active:!e.alternate&&e.times==null,onPress:()=>a({alternate:false,times:null})}),X(or,{label:"Once",active:!e.alternate&&e.times===1,onPress:()=>a({alternate:false,times:1})}),X(or,{label:"Every other",active:e.alternate===true,onPress:()=>a({alternate:true,times:null})}),X(F,{onPress:()=>{a({alternate:false}),C("times")},"sentry-label":"ignore custom times",accessibilityLabel:"Custom number of times",style:[j.customField,f&&j.customFieldActive],children:X(b,{style:[j.customValue,f&&j.customInputActive],children:f?`${e.times}\xD7`:"Custom"})})]})]})]}),h==="status"?X(In,{title:"Custom status code",hint:`${cr}\u2013${hr}`,value:w?e.status:void 0,min:cr,max:hr,onSubmit:S=>{a({kind:"respond",status:S??void 0,statusText:void 0}),C(null)},onCancel:()=>C(null)}):null,h==="delay"?X(In,{title:"Custom delay",hint:"Seconds",value:p?c/1e3:void 0,min:0,onSubmit:S=>{a({delayMs:S!=null?Math.round(S*1e3):0}),C(null)},onCancel:()=>C(null)}):null,h==="times"?X(In,{title:"Fires how many times",hint:"Leave empty for always",value:f?e.times:void 0,min:1,onSubmit:S=>{a({alternate:false,times:S&&S>0?S:null}),C(null)},onCancel:()=>C(null)}):null,qe(m,{style:[j.footer,{paddingBottom:12+l}],children:[X(F,{onPress:o,"sentry-label":"ignore cancel override",testID:"buoy-network-editor-cancel",accessibilityRole:"button",accessibilityLabel:"Cancel",style:[j.footerButton,j.cancelButton],children:X(b,{style:j.cancelText,children:"Cancel"})}),X(F,{onPress:r,disabled:!e.urlPattern.trim(),"sentry-label":"ignore save override",testID:"buoy-network-editor-save",accessibilityRole:"button",accessibilityLabel:n,style:[j.footerButton,j.saveButton,!e.urlPattern.trim()&&j.saveButtonDisabled],children:X(b,{style:j.saveText,children:n})})]})]})}var j=ve.create({root:{flex:1},scroll:{flex:1},scrollContent:{padding:12,paddingBottom:24,gap:4},field:{gap:8,paddingVertical:6},outcomeGrid:{flexDirection:"row",flexWrap:"wrap",gap:6,paddingVertical:10},outcome:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:9,borderRadius:6,borderWidth:1,borderColor:G.border.default,backgroundColor:G.background.card},outcomeLabel:{fontSize:12,fontWeight:"600",color:G.text.primary},outcomeCode:{fontSize:10,fontWeight:"700",color:G.text.muted},disclosure:{borderRadius:6,borderWidth:1,borderColor:G.border.default,backgroundColor:G.background.card,overflow:"hidden"},disclosureHeader:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:10},disclosureTitle:{fontSize:12,fontWeight:"600",color:G.text.primary},disclosureSummary:{flex:1,textAlign:"right",fontSize:11,color:G.text.muted},disclosureBody:{paddingHorizontal:10,paddingBottom:10,gap:8},input:{backgroundColor:G.background.input,borderWidth:1,borderColor:G.border.input,borderRadius:6,paddingHorizontal:10,paddingVertical:8,color:G.text.primary,fontSize:12,fontFamily:Jh,minHeight:40},bodyInput:{minHeight:140,textAlignVertical:"top"},chipRow:{flexDirection:"row",flexWrap:"wrap",gap:6},chip:{paddingHorizontal:10,paddingVertical:6,borderRadius:5,borderWidth:1,borderColor:G.border.default,backgroundColor:G.background.base},chipActive:{borderColor:G.semantic.info,backgroundColor:`${G.semantic.info}1F`},chipText:{fontSize:11,fontWeight:"600",color:G.text.secondary},chipTextActive:{color:G.semantic.info},customField:{flexDirection:"row",alignItems:"center",paddingHorizontal:8,borderRadius:5,borderWidth:1,borderColor:G.border.default,backgroundColor:G.background.base},customFieldActive:{borderColor:G.semantic.info,backgroundColor:`${G.semantic.info}1F`},customValue:{paddingVertical:6,fontSize:11,fontWeight:"600",color:G.text.secondary},customInputActive:{color:G.semantic.info},subHint:{fontSize:10,lineHeight:14,color:G.text.muted,marginTop:-2},subLabel:{fontSize:10,fontWeight:"700",letterSpacing:.6,color:G.text.muted,textTransform:"uppercase"},textButton:{alignSelf:"flex-start",paddingVertical:4},textButtonLabel:{fontSize:11,fontWeight:"600",color:G.semantic.info},textButtonMuted:{fontSize:11,fontWeight:"600",color:G.text.secondary},textButtonDisabled:{opacity:.4},inlineActions:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},emptyBody:{fontSize:11,color:G.text.muted,paddingVertical:6},footer:{flexDirection:"row",gap:8,padding:12,borderTopWidth:1,borderTopColor:G.border.default,backgroundColor:G.background.base},footerButton:{flex:1,paddingVertical:11,borderRadius:6,alignItems:"center",borderWidth:1},cancelButton:{borderColor:G.border.default,backgroundColor:G.background.card},cancelText:{fontSize:12,fontWeight:"600",color:G.text.secondary},saveButton:{borderColor:G.semantic.info,backgroundColor:`${G.semantic.info}22`},saveButtonDisabled:{opacity:.4},saveText:{fontSize:12,fontWeight:"700",color:G.semantic.info}});import{jsx as ge,jsxs as Wt}from"react/jsx-runtime";function up(){return{enabled:true,urlPattern:"",kind:"respond",status:500,body:"",times:null}}function cp(e){let{id:t,hits:r,seen:o,createdAt:n,...i}=e;return i}function hp(e){let t=e.urlPattern,r=t.indexOf("://");if(r===-1)return t;let o=t.indexOf("/",r+3);return o===-1?t.slice(r+3):t.slice(o)}function pp(e){let t=[];return e.delayMs&&t.push(`${e.delayMs/1e3}s delay`),e.alternate?t.push("every other"):e.times===1?t.push("once"):typeof e.times=="number"&&t.push(`${e.times}\xD7`),t.join(" \xB7 ")}function fp(e){if(e.kind==="fail")return oe.semantic.error;if(e.kind==="delay")return oe.semantic.info;let t=e.status??200;return t>=200&&t<300?oe.semantic.success:t>=300&&t<400?oe.semantic.info:oe.semantic.error}function yp({rule:e,spent:t,onEdit:r,onDelete:o}){let n=e.enabled&&!t,i=fp(e),s=pp(e),l=e.methods?.length?e.methods.join("/"):"ANY";return Wt(Mh,{onPress:r,style:he.cardWrapper,contentStyle:[he.card,{borderLeftColor:n?i:"transparent"}],children:[ge($h,{method:l,size:"small"}),Wt(m,{style:he.cardMiddle,children:[ge(b,{style:[he.urlText,!n&&he.urlTextOff],numberOfLines:2,children:hp(e)}),s?ge(b,{style:he.extrasText,children:s}):null]}),e.hits>0?ge(b,{style:he.rowHits,children:e.hits}):null,e.kind==="fail"?Wt(m,{style:he.failBadge,children:[ge(Ah,{size:10,color:oe.semantic.error}),ge(b,{style:he.failText,children:e.failKind==="timeout"?"TIMEOUT":"OFFLINE"})]}):ge(b,{style:[he.statusText,{color:i}],children:e.kind==="delay"?"PASS":String(e.status??200)}),ge(F,{onPress:o,"sentry-label":"ignore delete override rule",testID:"buoy-network-rule-delete",accessibilityRole:"button",accessibilityLabel:"Delete rule",hitSlop:{top:8,bottom:8,left:4,right:4},style:he.rowDelete,children:ge(jh,{size:13,color:oe.text.muted})})]})}function gp(e){return e.visible?ge(mp,{...e}):null}function mp({isPro:e,onUpgradePress:t,pendingDraft:r,onPendingConsumed:o,backHandlerRef:n,applySafeAreaInset:i}){let s=Wh("network.overrideRules"),l=e?Ze:s,{enabled:a,autoPaused:u,rules:d,activeCount:g,setEnabled:x,upsertRule:y,setRuleEnabled:R,removeRule:h,isRuleSpent:C}=lo(),[k,w]=Dh(null);co(()=>{_.noteHealthyLaunch()},[]),co(()=>{if(n)return n.current=k?()=>(w(null),true):null,()=>{n.current=null}},[n,k]);let I=zh(v=>{_.fetchRuleBody(v).then(c=>{c!=null&&w(p=>p?.id===v?{...p,draft:{...p.draft,body:c,bodyOmitted:void 0}}:p)})},[]);co(()=>{if(!r)return;let{id:v,...c}=r;w({id:v,draft:c}),v&&c.bodyOmitted&&I(v),o?.()},[r,o,I]),co(()=>{k?.id&&(d.some(v=>v.id===k.id)||w(null))},[k?.id,d]);let z=v=>{w({id:v.id,draft:cp(v)}),v.bodyOmitted&&I(v.id)},$=v=>{d.filter(c=>c.enabled&&!C(c)).length<=l||d.filter(c=>c.enabled&&!C(c)&&c.id!==v).forEach(c=>R(c.id,false))},P=()=>{if(!k)return;let v={...k.draft,enabled:true,urlPattern:k.draft.urlPattern.trim()};if(!v.urlPattern)return;let c=y({...v,id:k.id});$(c?.id??k.id),x(true),w(null)};if(k)return ge(dp,{draft:k.draft,onChange:v=>w({...k,draft:v}),onSave:P,onCancel:()=>w(null),saveLabel:k.id?"Save":"Add",applySafeAreaInset:i});let A=d.length>0;return Wt(m,{style:he.root,children:[A?Wt(m,{style:[he.bar,a&&g>0&&he.barOn],children:[a&&g>0?ge(Hh,{size:12,color:oe.semantic.warning}):null,ge(b,{style:[he.barText,a&&g>0&&he.barTextOn],numberOfLines:2,children:u?"Overrides paused \u2014 they'd been on for 3 launches":a&&g>0?`${g} override${g===1?" is":"s are"} on`:"Overrides are off"}),ge(F,{onPress:()=>x(!(a&&g>0)),"sentry-label":"ignore toggle overrides master",testID:"buoy-network-overrides-master",accessibilityRole:"button",style:he.barButton,children:ge(b,{style:he.barButtonText,children:a&&g>0?"Turn all off":u?"Turn back on":"Turn on"})})]}):null,Wt(m,{style:he.listHeader,children:[ge(b,{style:he.listHeaderText,children:A?`${d.length} rule${d.length===1?"":"s"}`:""}),ge(F,{onPress:()=>w({draft:up()}),"sentry-label":"ignore new override rule",accessibilityLabel:"New override rule",style:he.newButton,children:ge(Fh,{size:14,color:oe.semantic.info})})]}),A?Wt(yt,{style:he.list,contentContainerStyle:he.listContent,keyboardShouldPersistTaps:"handled",children:[d.map(v=>ge(yp,{rule:v,spent:C(v),onEdit:()=>z(v),onDelete:()=>h(v.id)},v.id)),l<Ze?ge(b,{style:he.footNote,children:`Your plan: ${l} override at a time. Pro: up to ${Ze}.`}):null]}):ge(m,{style:he.emptyWrap,children:ge(Nh,{otto:"empty",iconSize:32,title:"Nothing overridden",description:"Open any request and tap Override, or + to write a rule."})})]})}var he=ve.create({root:{flex:1},bar:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingVertical:10,borderBottomWidth:1,borderBottomColor:oe.border.default,backgroundColor:oe.background.card},barOn:{borderBottomColor:oe.semantic.warning+"44",backgroundColor:oe.semantic.warningBackground},barText:{flex:1,fontSize:12,fontWeight:"600",color:oe.text.secondary},barTextOn:{color:oe.semantic.warning},barButton:{paddingHorizontal:10,paddingVertical:6,borderRadius:5,borderWidth:1,borderColor:oe.border.hover,backgroundColor:oe.background.base},barButtonText:{fontSize:11,fontWeight:"700",color:oe.text.primary},listHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingTop:10,paddingBottom:4},listHeaderText:{fontSize:10,fontWeight:"700",letterSpacing:.6,color:oe.text.muted,textTransform:"uppercase"},newButton:{padding:6,borderRadius:5,borderWidth:1,borderColor:oe.border.default,backgroundColor:oe.background.card},emptyWrap:{flex:1,justifyContent:"center"},list:{flex:1},listContent:{padding:10,gap:6},cardWrapper:{marginHorizontal:0,marginVertical:0},card:{flexDirection:"row",alignItems:"center",gap:8,borderLeftWidth:3,borderLeftColor:"transparent"},cardMiddle:{flex:1},urlText:{fontSize:12,color:oe.text.primary,lineHeight:16,fontFamily:Vh},urlTextOff:{color:oe.text.muted},extrasText:{fontSize:10,color:oe.text.secondary,marginTop:2},statusText:{fontSize:11,fontWeight:"600"},failBadge:{flexDirection:"row",alignItems:"center",gap:2,paddingHorizontal:4,paddingVertical:1,backgroundColor:oe.semantic.error+"26",borderRadius:3},failText:{fontSize:10,color:oe.semantic.error,fontWeight:"600"},rowHits:{fontSize:11,fontWeight:"700",color:oe.semantic.warning},rowDelete:{padding:5,borderRadius:5,borderWidth:1,borderColor:oe.border.default,backgroundColor:oe.background.base},footNote:{fontSize:10,lineHeight:14,color:oe.text.muted,paddingHorizontal:4,paddingTop:8}});O();Se();import{FlaskConical as bp,night as Vt}from"@buoy-gg/shared-ui/web";import{jsx as Pn,jsxs as vp}from"react/jsx-runtime";function Sp({onPress:e}){let{activeCount:t}=lo(),r=t>0;return vp(F,{onPress:e,"sentry-label":"ignore open overrides",testID:"buoy-network-overrides",accessibilityRole:"button",style:[bo.button,r&&bo.buttonActive],accessibilityLabel:r?`Response overrides \u2014 ${t} active`:"Response overrides",children:[Pn(bp,{size:14,color:r?Vt.color.warning:Vt.color.textSecondary}),r?Pn(m,{style:bo.badge,children:Pn(b,{style:bo.badgeText,children:t})}):null]})}var bo=ve.create({button:{width:32,height:32,borderRadius:8,alignItems:"center",justifyContent:"center",backgroundColor:Vt.color.buttonSurface,borderWidth:1,borderColor:Vt.color.border},buttonActive:{backgroundColor:Vt.color.warningSoft,borderColor:Vt.color.warning+"77"},badge:{position:"absolute",top:1,right:1,minWidth:12,height:12,borderRadius:6,paddingHorizontal:3,alignItems:"center",justifyContent:"center",backgroundColor:Vt.color.warning},badgeText:{fontSize:8,fontWeight:"800",color:"#000000"}});O();Se();import{night as nr}from"@buoy-gg/shared-ui/web";O();function wp(e){let t=e.indexOf("?");return t===-1?e:`${e.slice(0,t)}*`}function xp(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return""}}function Ln(e){return{enabled:true,name:void 0,urlPattern:wp(e.url),methods:[String(e.method||"GET").toUpperCase()],kind:"respond",status:e.status&&e.status>=200?e.status:200,statusText:e.statusText,body:xp(e.responseData),times:null}}import{jsx as Ks}from"react/jsx-runtime";function Cp({onOpen:e}){let t=vn(),{rules:r,isRuleSpent:o}=lo(),n=t?te.getEvents().find(l=>l.id===t)??fe.getEventById(t):null,i=n?r.find(l=>l.enabled&&!o(l)&&_o(l,n.url,String(n.method||"GET")))??null:null,s=i!==null;return Ks(F,{onPress:()=>{if(n){if(i){let{id:l,hits:a,seen:u,createdAt:d,...g}=i;e(g,l);return}e(Ln(n))}},"sentry-label":"ignore open overrides",testID:"buoy-network-override-request",accessibilityRole:"button",accessibilityLabel:s?"Edit the override on this request":"Override this request",style:[vo.button,s&&vo.buttonActive],children:Ks(b,{style:[vo.label,s&&vo.labelActive],children:"Override"})})}var vo=ve.create({button:{paddingHorizontal:10,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:nr.color.border,backgroundColor:nr.color.buttonSurface},buttonActive:{borderColor:nr.color.warning+"77",backgroundColor:nr.color.warningSoft},label:{fontSize:11,fontWeight:"700",color:nr.color.accent},labelActive:{color:nr.color.warning}});O();Se();import{absoluteFill as Ys,night as xt}from"@buoy-gg/shared-ui/web";import{jsx as ht,jsxs as So}from"react/jsx-runtime";function kp({onPress:e,isOpen:t,hasIndicator:r}){return So(F,{onPress:e,"sentry-label":"ignore toggle header menu",testID:"buoy-network-menu",accessibilityRole:"button",accessibilityLabel:t?"Close menu":"More actions",style:[Be.button,t&&Be.buttonOpen],children:[So(m,{style:Be.dots,children:[ht(m,{style:[Be.dot,t&&Be.dotOpen]}),ht(m,{style:[Be.dot,t&&Be.dotOpen]}),ht(m,{style:[Be.dot,t&&Be.dotOpen]})]}),r?ht(m,{style:Be.indicator}):null]})}function Tp({onClose:e,children:t}){return So(m,{style:Be.overlay,children:[ht(F,{style:Be.backdrop,activeOpacity:1,onPress:e,"sentry-label":"ignore dismiss header menu"}),ht(m,{style:Be.panel,children:t})]})}function wo({icon:e,label:t,detail:r,testID:o,onPress:n}){return So(F,{onPress:n,"sentry-label":"ignore header menu item",testID:o,accessibilityRole:"button",accessibilityLabel:t,style:Be.item,children:[ht(m,{style:Be.itemIcon,children:e}),ht(b,{style:Be.itemLabel,children:t}),r?ht(b,{style:Be.itemDetail,children:r}):null]})}var Be=ve.create({button:{width:32,height:32,borderRadius:8,alignItems:"center",justifyContent:"center"},buttonOpen:{backgroundColor:xt.color.surfaceElevated},dots:{flexDirection:"column",gap:2.5,alignItems:"center"},dot:{width:3,height:3,borderRadius:2,backgroundColor:xt.color.textSecondary},dotOpen:{backgroundColor:xt.color.text},indicator:{position:"absolute",top:6,right:8,width:6,height:6,borderRadius:3,backgroundColor:xt.color.accent},overlay:{...Ys,zIndex:50},backdrop:{...Ys,backgroundColor:"rgba(0,0,0,0.5)"},panel:{position:"absolute",top:6,right:8,minWidth:196,paddingVertical:4,borderRadius:10,borderWidth:1,borderColor:xt.color.border,backgroundColor:xt.color.surface},item:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:11},itemIcon:{width:16,alignItems:"center"},itemLabel:{flex:1,fontSize:13,fontWeight:"600",color:xt.color.text},itemDetail:{fontSize:11,color:xt.color.textTertiary}});O();import{memo as Rp,useEffect as Ep,useMemo as Ip}from"react";import{EventStepperFooter as Pp,useLimit as Lp}from"@buoy-gg/shared-ui/web";import{jsx as Bp}from"react/jsx-runtime";var qp=()=>nt.step(-1),Op=()=>nt.step(1),zp=Rp(function({paused:e,filter:t,ignoredPatterns:r,isPro:o,fromSaved:n,savedSearch:i,applySafeAreaInset:s}){let{visibleEvents:l}=kr({filter:t,ignoredPatterns:r,paused:e,isPro:o}),{pinnedEvents:a,pinnedLiveIds:u,savedRecords:d}=Zt(),g=Lp("network.saved"),x=Ip(()=>{if(n)return Hs(d,g,i).events;let{pinned:h,rest:C}=xn(l,a,u);return h.length===0?C:[...h,...C]},[n,d,i,o,l,a,u]);Ep(()=>{nt.setIds(wc(x))},[x]);let{index:y,total:R}=kc();return y<0?null:Bp(Pp,{currentIndex:y,totalItems:R,itemLabel:"Request",applySafeAreaInset:s,onPrevious:qp,onNext:Op,variant:"night"})});O();import{useEffect as Dp,useState as Ap}from"react";function Hp(e){return te.getEvents().find(t=>t.id===e)??fe.getEventById(e)}function Zs(e,t={}){let{paused:r=false}=t,[o,n]=Ap(null);return Dp(()=>{if(!(!e||r))return te.subscribeToEvents(i=>{let s=i.find(l=>l.id===e);s&&n(l=>l&&l.id===e&&l.event===s?l:{id:e,event:s})})},[e,r]),e?o&&o.id===e?o.event:Hp(e):null}import{Fragment as Mp,jsx as W,jsxs as Je}from"react/jsx-runtime";function Np({visible:e,paused:t,ignoredPatternValues:r,onTogglePattern:o,isPro:n,filter:i,ignoredPatterns:s,fromSaved:l,savedSearch:a,applySafeAreaInset:u}){let d=vn(),g=Cc(),x=d!=null&&d===g,y=Zs(d,{paused:t||!e});return Dt(()=>{e&&y&&x&&nt.reportRendered(y.id)},[e,y,x]),e?Je(m,{style:Ut.detailRoot,children:[y?W(ss,{event:y,ignoredPatterns:r,onTogglePattern:o,showBodies:x}):W(m,{style:Ut.detailBodyFallback}),W(zp,{paused:t,filter:i,ignoredPatterns:s,isPro:n,fromSaved:l,savedSearch:a,applySafeAreaInset:u})]}):null}function $p({visible:e,paused:t,isPro:r,filter:o,onFilterChange:n,ignoredPatterns:i,onRemovePattern:s,onAddPattern:l,onTogglePatternMode:a,isTeamPattern:u}){let{events:d}=kr({filter:o,ignoredPatterns:i,paused:t,visible:e,isPro:r});return e?W(iu,{events:d,filter:o,onFilterChange:n,ignoredPatterns:i,onRemovePattern:s,onAddPattern:l,onTogglePatternMode:a,isTeamPattern:u}):null}function Fp({visible:e,paused:t,isPro:r,filter:o,ignoredPatterns:n,settings:i,onSettingsChange:s}){let{events:l}=kr({filter:o,ignoredPatterns:n,paused:t,visible:e,isPro:r});return e?W(Xu,{settings:i,onSettingsChange:s,events:l}):null}function Qs({visible:e,onClose:t,onBack:r,onMinimize:o,enableSharedModalDimensions:n=false,inline:i=false,paused:s,onPausedChange:l,remoteConditions:a}){let{isPro:u}=Fd(),[d,g]=Te(false),x=s!=null&&l!=null,y=x?s:d,R=re=>{let We=typeof re=="function"?re(y):re;x?l(We):g(We)},[h,C]=Te({}),k=xc(),[w,I]=Te(false),[z,$]=Te(false),[P,A]=Te(false),[v,c]=Te(false),[p,f]=Te(0),[S]=Te(qd);Dt(()=>{S.update(a)},[S,a]),Dt(()=>()=>S.update(void 0),[S]);let D=true,[H,V]=Te(null),[Z,Y]=Te("filters"),[L,M]=Te(""),[N,J]=Te(false),le=Xr(false),[ne,K]=Te(""),be=Xr(null),{patterns:pe,values:ft,add:Ae,remove:Ye,toggle:Eo,toggleMode:da,isTeamOnly:ua}=Vd(),[sr,Nn]=Te(ju),Io=Xr(false),[Po,Lo]=Te(false),[_t,ca]=Te("export"),ar=re=>{ca(re),Lo(true)};Dt(()=>{Po&&u&&Lo(false)},[Po,u]),Dt(()=>{if(!e||Io.current)return;(async()=>{try{let re=await Vi.getItem(Jr.network.copyOptions());if(re){let We=JSON.parse(re);Nn(We)}}catch{}finally{Io.current=true}})()},[e]),Dt(()=>{if(!Io.current)return;(async()=>{try{await Vi.setItem(Jr.network.copyOptions(),JSON.stringify(sr))}catch{}})()},[sr]);let ha=()=>{nt.clear()},$n=ln(re=>{nt.select(re.id)},[]),pa=ln((re,We)=>{V(We?{...re,id:We}:re),A(true),nt.clear()},[]),fa=ln(()=>V(null),[]),Fn=Xr(null),jn=re=>{M(re),C(We=>({...We,searchText:re}))},ya=re=>{C(We=>({...We,status:We.status===re?void 0:re}))},[Wn,ga]=Te("bottomSheet"),ma=re=>{ga(re)};Dt(()=>{N&&requestAnimationFrame(()=>{be.current?.focus()})},[N]);let Vn=()=>w?Je(ke,{children:[W(ke.Navigation,{onBack:()=>I(false)}),W(ke.Content,{title:"",noMargin:true,children:W($d,{size:"sm",tabs:[{key:"filters",label:"Filters"},{key:"copy",label:"Copy"}],activeKey:Z,onChange:re=>Y(re)})})]}):k?Je(ke,{children:[W(ke.Navigation,{onBack:ha}),W(ke.Content,{title:"Request Details",centered:true}),Je(ke.Actions,{children:[D?W(Cp,{onOpen:pa}):null,W(Ls,{isPro:u,onUpgradePress:()=>ar("saved")})]})]}):P&&D?Je(ke,{children:[W(ke.Navigation,{onBack:()=>{Fn.current?.()||(A(false),V(null))}}),W(ke.Content,{title:"Response Overrides",centered:true})]}):z?Je(ke,{children:[W(ke.Navigation,{onBack:()=>$(false)}),W(ke.Content,{title:"Saved Requests",centered:true})]}):Je(ke,{children:[r&&W(ke.Navigation,{onBack:r}),W(ke.Content,{title:"",children:N?W(ke.Search,{value:L,onChangeText:jn,onCancel:()=>{jn(""),J(false)},onDismiss:()=>J(false),dismissOnBlur:true,clearOnlyWhenText:true,placeholder:"Search URL, method, operation, error...",accessibilityLabel:"Search network requests",iconSize:14,testID:"buoy-network-search-input",clearTestID:"buoy-network-search-clear",inputProps:{"sentry-label":"ignore network search header"}}):W(Bc,{activeStatus:h.status,onToggleStatus:ya,ignoredPatterns:pe,paused:y})}),Je(ke.Actions,{children:[W(F,{"sentry-label":"ignore open search",testID:"buoy-network-search-open",accessibilityLabel:"Open search",accessibilityRole:"button",onPress:()=>J(true),style:Ut.headerActionButton,children:W(Dd,{size:14,color:tt.color.textSecondary})}),D?W(Sp,{onPress:()=>A(true)}):null,W(Wd,{isEnabled:!y,onToggle:()=>R(re=>!re),accessibilityLabel:y?"Resume network capture":"Pause network capture",testID:"buoy-network-power"}),W(qc,{paused:y}),W(kp,{onPress:()=>c(re=>!re),isOpen:v,hasIndicator:Bo})]})]}),Bo=!!(h.status||h.method||h.contentType),ba=n?Jr.modal.root():Jr.network.modal();if(!e)return null;let va=k||!w,Un=Je(Mp,{children:[Je(m,{style:Ut.container,children:[W(Np,{visible:k,paused:y,ignoredPatternValues:ft,onTogglePattern:Eo,isPro:u,filter:h,ignoredPatterns:pe,fromSaved:z,savedSearch:ne,applySafeAreaInset:!i&&Wn==="bottomSheet"}),W($p,{visible:w&&Z==="filters"&&!k,paused:y,isPro:u,filter:h,onFilterChange:C,ignoredPatterns:pe,onRemovePattern:Ye,onAddPattern:Ae,onTogglePatternMode:da,isTeamPattern:ua}),W(Fp,{visible:w&&Z==="copy"&&!k,paused:y,isPro:u,filter:h,ignoredPatterns:pe,settings:sr,onSettingsChange:Nn}),W(gp,{visible:D&&P&&!k&&!w,isPro:u,onUpgradePress:()=>ar("overrides"),pendingDraft:H,onPendingConsumed:fa,backHandlerRef:Fn,applySafeAreaInset:!i&&Wn==="bottomSheet"}),W(Ms,{visible:z&&!k&&!w&&!(P&&D),isPro:u,copySettings:sr,search:ne,onSearchChange:K,onEventPress:$n,onUpgradePress:()=>ar("saved")}),W(Ch,{visible:!k&&!w&&!z&&!(P&&D),paused:y,filter:h,ignoredPatterns:pe,isPro:u,searchText:L,onEventPress:$n,onUpgradePress:()=>ar("export")})]}),v?Je(Tp,{onClose:()=>c(false),children:[W(wo,{icon:W(Wi,{size:14,color:tt.color.textSecondary}),label:"Network throttling",testID:"buoy-network-menu-throttling",onPress:()=>{c(false),Fi(a?S:void 0),i||f(re=>re+1)}}),W(wo,{icon:W(Wi,{size:14,color:tt.color.textSecondary}),label:"Speed and link state",testID:"buoy-network-menu-conditions",onPress:()=>{c(false),Fi(a?S:void 0,true),i||f(re=>re+1)}}),W(wo,{icon:W(Ad,{size:14,color:Bo?tt.color.accent:tt.color.textSecondary}),label:"Filters",detail:Bo?"Active":void 0,onPress:()=>{c(false),Y("filters"),I(true)}}),W(wo,{icon:W(Hd,{size:14,color:tt.color.textSecondary}),label:"Saved requests",onPress:()=>{c(false),$(true)}}),W(m,{style:Ut.menuCopyRow,children:W(zc,{isPro:u,filter:h,ignoredPatterns:pe,copySettings:sr,paused:y,onUpgradePress:()=>{c(false),ar("export")},label:"Copy requests"})})]}):null,W(jd,{visible:Po,onClose:()=>Lo(false),featureName:_t==="saved"?"Saved Requests":_t==="overrides"?"Response Overrides":"Network Export",description:_t==="saved"?"Keep the requests that matter. Saved requests survive Clear, app restarts, and the 500-request history cap.":_t==="overrides"?"Force any endpoint to fail, stall or return something else \u2014 no backend changes, no code changes. Free keeps one active rule.":"Export network requests to share with your team, debug APIs, or feed into AI tools.",benefits:_t==="overrides"?[`Run ${Ze} rules at once (free keeps ${Ti})`,"Force a 500, a 401 or an empty list in one tap","Simulate offline, timeouts and slow connections","Rules survive an app reload, so you can test the boot path"]:_t==="saved"?[`Save up to ${vt} requests (free keeps ${vs})`,"Failed requests stay put through a Clear","Snapshots survive an app restart","Export saved requests to teammates or AI assistants"]:["Export to JSON, Markdown, or plain text","Customizable copy presets (URLs only, LLM-ready, full data)","Share request details with teammates","Feed network data directly to AI assistants"]})]});return i?Je(m,{style:Ut.inlineRoot,children:[W(m,{style:Ut.inlineHeader,...Ud,children:Vn()}),Un]}):W(Md,{visible:e,onClose:t,onMinimize:o,minimizeRequest:p,persistenceKey:ba,variant:"night",header:{showToggleButton:true,customContent:Vn()},onModeChange:ma,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,disableScrollWrapper:va,styles:{},children:Un})}var Ut=ve.create({container:{flex:1,backgroundColor:"transparent"},detailRoot:{flex:1,minHeight:0},detailBodyFallback:{flex:1},inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:Nd.border.default,backgroundColor:"transparent"},menuCopyRow:{paddingHorizontal:6},headerActionButton:{width:32,height:32,borderRadius:8,backgroundColor:tt.color.buttonSurface,borderWidth:1,borderColor:tt.color.border,alignItems:"center",justifyContent:"center"},activeFilterButton:{backgroundColor:tt.color.accentSoft,borderColor:tt.color.accentBorderStrong}});function ea(e){return W(cn,{children:W(Qs,{...e})})}function jp(e={}){return W(cn,{children:W(Qs,{...e,inline:true,visible:true,onClose:Wp})})}var Wp=()=>{};import{jsx as Vp}from"react/jsx-runtime";var ta=typeof navigator<"u"&&navigator.product==="ReactNative";ta&&_.ensureLoaded();ta&&typeof me<"u"&&me&&te.startBootCapture();var ra=kd({id:"network",name:"NET",description:"Network request logger",slot:"both",icon:({size:e})=>Vp(xd,{size:e}),component:ea,props:{enableSharedModalDimensions:false}}),Up=Cd(ra,e=>({enableSharedModalDimensions:e.enableSharedModalDimensions??false}));O();function _p(){let e=typeof navigator<"u"&&navigator.product==="ReactNative";if(!e&&(typeof window>"u"||typeof document>"u"))return()=>{};_.ensureLoaded();let t=e?()=>{}:$i(),r=te.subscribeToEvents(()=>{}),o=false;return()=>{o||(o=true,t(),r())}}O();import{useState as Bn,useEffect as Xp,useCallback as xo,useMemo as pt,useRef as Jp}from"react";import{useLimit as Gp,TIER_LIMITS as Kp}from"@buoy-gg/shared-ui/web";var fg=Kp["network.requests"].free;function Yp(e={}){let{isPro:t=false}=e,r=Gp("network.requests"),o=t?1/0:r,[n,i]=Bn([]),[s,l]=Bn({}),[a,u]=Bn(true),d=Jp(null);Xp(()=>(a&&(d.current=te.subscribeToEvents(i)),()=>{d.current&&(d.current(),d.current=null)}),[a]);let g=xo(()=>{te.clearEvents(),i([])},[]),x=xo(()=>{u(false)},[]),y=xo(()=>{u(true)},[]),R=pt(()=>s.searchText?s.searchText.toLowerCase():null,[s.searchText]),h=pt(()=>s.method&&s.method.length>0?new Set(s.method):null,[s.method]),C=pt(()=>s.contentType&&s.contentType.length>0?new Set(s.contentType):null,[s.contentType]),k=pt(()=>{let p=[...n];if(h&&(p=p.filter(f=>h.has(f.method))),s.status&&s.status!=="all")switch(s.status){case"success":p=p.filter(f=>f.status&&f.status>=200&&f.status<300);break;case"error":p=p.filter(f=>f.error||f.status&&f.status>=400);break;case"pending":p=p.filter(f=>!f.status&&!f.error);break}return R&&(p=p.filter(f=>f.url.toLowerCase().includes(R)||f.method.toLowerCase().includes(R)||f.path?.toLowerCase().includes(R)||f.host?.toLowerCase().includes(R)||f.error&&f.error.toLowerCase().includes(R)||f.operationName&&f.operationName.toLowerCase().includes(R)||os(f.graphqlVariables,R))),s.host&&(p=p.filter(f=>f.host===s.host)),C&&(p=p.filter(f=>{let S=f.responseHeaders||f.requestHeaders,D=S?.["content-type"]||S?.["Content-Type"]||"";for(let H of C)switch(H){case"JSON":if(D.includes("json"))return true;break;case"XML":if(D.includes("xml"))return true;break;case"HTML":if(D.includes("html"))return true;break;case"TEXT":if(D.includes("text"))return true;break;case"IMAGE":if(D.includes("image"))return true;break;case"VIDEO":if(D.includes("video"))return true;break;case"AUDIO":if(D.includes("audio"))return true;break;case"FORM":if(D.includes("form"))return true;break;case"OTHER":if(!D||!D.includes("json")&&!D.includes("xml")&&!D.includes("html")&&!D.includes("text")&&!D.includes("image")&&!D.includes("video")&&!D.includes("audio")&&!D.includes("form"))return true;break}return false})),p},[n,s,R,h,C]),w=pt(()=>{let p=new Set;return n.slice(o).forEach(f=>{p.add(f.id)}),p},[n,o]),I=pt(()=>k.filter(p=>w.has(p.id)),[k,w]),z=I.length>0,$=I.length,P=xo(p=>w.has(p),[w]),A=pt(()=>{let p=0,f=0,S=0,D=0,H=0,V=0,Z=0;for(let L of n)L.status&&L.status>=200&&L.status<300?p++:L.error||L.status&&L.status>=400?f++:!L.status&&!L.error&&S++,D+=L.requestSize||0,H+=L.responseSize||0,L.duration&&(V+=L.duration,Z++);let Y=Z>0?V/Z:0;return{totalRequests:n.length,successfulRequests:p,failedRequests:f,pendingRequests:S,totalDataSent:D,totalDataReceived:H,averageDuration:Math.round(Y)}},[n]),v=pt(()=>{let p=new Set;for(let f of n)f.host&&p.add(f.host);return Array.from(p)},[n]),c=pt(()=>{let p=new Set;for(let f of n)p.add(f.method);return Array.from(p)},[n]);return{events:k,allEvents:n,stats:A,filter:s,setFilter:l,clearEvents:g,isCapturing:a,pauseCapturing:x,resumeCapturing:y,hosts:v,methods:c,hasLockedEvents:z,lockedEventCount:$,isEventLocked:P,requestLimit:o,getSubscriberCounts:()=>te.getSubscriberCounts()}}import{useIgnoredPatterns as Zp,ignoredPatternsStore as Qp,urlMatchesIgnoredPattern as ef,isUrlIgnored as tf}from"@buoy-gg/shared-ui/web";O();import{approxJsonSize as qn,isOverWireBudget as rf}from"@buoy-gg/shared-ui/web";import{expandKeyedArrays as of,patchFromPath as nf,refusalText as sf,shapeKind as oa,suggestedPatch as af,typedEditViolations as lf}from"@buoy-gg/shared-ui/web";var On=16*1024,Co=1.25*1024*1024;function zn(e,t){return e===void 0?false:(t??0)>On?true:rf(e,On)}var na=new WeakMap,ia=new WeakMap;function Dn(e){let t=na.get(e);if(t)return t;let r;try{r=uf(e)}catch{r=df(e)}return na.set(e,r),r}function df(e){let t={...e,requestData:void 0,responseData:void 0,graphqlVariables:void 0,requestBodyOmitted:e.requestData!==void 0?true:void 0,responseBodyOmitted:e.responseData!==void 0?true:void 0},r=1024;try{r=qn(t,Co).bytes}catch{}return{event:t,bytes:r}}function uf(e){let t=zn(e.requestData,e.requestSize),r=zn(e.responseData,e.responseSize),o=sa(e.graphqlVariables),n=aa(e.requestHeaders),i=aa(e.responseHeaders),s=t||r||o!==e.graphqlVariables||n!==e.requestHeaders||i!==e.responseHeaders,l=e;return s&&(l={...e},t&&(l.requestData=void 0,l.requestBodyOmitted=true),r&&(l.responseData=void 0,l.responseBodyOmitted=true),o!==e.graphqlVariables&&(l.graphqlVariables=o),n!==e.requestHeaders&&(l.requestHeaders=n,l.headersOmitted=true),i!==e.responseHeaders&&(l.responseHeaders=i,l.headersOmitted=true)),{event:l,bytes:qn(l,Co).bytes}}function cf(e){let t=ia.get(e);if(t)return t;let{event:r}=Dn(e),o={...r};o.requestData!==void 0&&(o.requestData=void 0,o.requestBodyOmitted=true),o.responseData!==void 0&&(o.responseData=void 0,o.responseBodyOmitted=true),o.graphqlVariables!==void 0&&(o.graphqlVariables=sa(o.graphqlVariables,true));let n={event:o,bytes:qn(o,Co).bytes};return ia.set(e,n),n}function hf(e){let t=new Array(e.length),r=0;for(let o=0;o<e.length;o++){let n=Dn(e[o]);if(r+n.bytes<=Co)t[o]=n.event,r+=n.bytes;else{let i=cf(e[o]);t[o]=i.event,r+=i.bytes}}return t}function sa(e,t=false){if(!e||!t&&!zn(e,void 0))return e;let r={};for(let[o,n]of Object.entries(e))(typeof n=="string"&&n.length<=64||typeof n=="number"||typeof n=="boolean")&&(r[o]=n);return Object.keys(r).length>0?r:void 0}var An=64;function aa(e){if(!e)return e;let t=false,r={};for(let[o,n]of Object.entries(e))typeof n=="string"&&(n.length<=An?r[o]=n:(r[o]=`${n.slice(0,An)}\u2026 [${n.length-An} more]`,t=true));return t?r:e}var pf=e=>{let t=false,r=e.rules.map(o=>!o.body||o.body.length<=On?o:(t=true,{...o,body:void 0,bodyOmitted:true}));return t?{...e,rules:r}:e},ko=e=>te.getEventById(e)??fe.getEventById(e),ir=e=>e&&typeof e=="object"?e.id:void 0,To=(e,t)=>!!(e&&typeof e=="object"&&e[t]),Ro=()=>Ql()?{}:{active:false,inactiveReason:ed},ff=["respond","fail","delay"];function yf(e,t){if(!e||typeof e!="object")return null;let r=e.rule??e;if(!r||typeof r!="object")return null;let o=r,n=typeof o.urlPattern=="string"&&o.urlPattern.trim()?o.urlPattern.trim():t?.urlPattern??"";if(!n)return null;let i=ff.includes(o.kind)?o.kind:t?.kind??"respond";return{id:typeof o.id=="string"?o.id:void 0,enabled:o.enabled!==false,name:typeof o.name=="string"?o.name:t?.name,urlPattern:n,methods:Array.isArray(o.methods)?o.methods.filter(s=>typeof s=="string").map(s=>s.toUpperCase()):t?.methods,requireHeader:typeof o.requireHeader=="string"&&o.requireHeader.trim()?o.requireHeader.trim():void 0,bodyIncludes:typeof o.bodyIncludes=="string"&&o.bodyIncludes?o.bodyIncludes.slice(0,4096):t?.bodyIncludes,graphqlOperation:typeof o.graphqlOperation=="string"&&o.graphqlOperation?o.graphqlOperation.slice(0,200):t?.graphqlOperation,graphqlVariables:typeof o.graphqlVariables=="string"?o.graphqlVariables.slice(0,4096):t?.graphqlVariables,sandbox:o.sandbox===true?true:void 0,kind:i,status:typeof o.status=="number"?o.status:t?.status,statusText:typeof o.statusText=="string"?o.statusText:t?.statusText,headers:o.headers&&typeof o.headers=="object"?o.headers:t?.headers,body:mf(o,t),failKind:o.failKind==="timeout"?"timeout":void 0,delayMs:typeof o.delayMs=="number"?o.delayMs:void 0,times:typeof o.times=="number"?o.times:null,alternate:o.alternate===true}}var Hn=e=>!!e&&typeof e=="object"&&!Array.isArray(e),Er=e=>Hn(e)||Array.isArray(e);function la(e,t,r="",o={shrunk:[],breaks:[]}){if(Array.isArray(e)&&Array.isArray(t))return t.length>0&&t.length<e.length&&o.shrunk.push({path:r||"(root)",have:e.length,sent:t.length}),t;if(!Hn(e)||!Hn(t))return t;let n={...e};for(let[i,s]of Object.entries(t)){let l=r?`${r}.${i}`:i;if(i in e){let a=oa(e[i]),u=oa(s);(a==="array"||a==="object")&&a!==u&&o.breaks.push({path:l,from:a,to:u}),n[i]=la(e[i],s,l,o)}else n[i]=s}return n}function gf(e,t){if(e.body!=null||!Er(e.bodyPatch)||typeof t!="string")return[];try{return lf(JSON.parse(t),e.bodyPatch,{noun:"response body"})}catch{return[]}}function mf(e,t){if(typeof e.body=="string")return e.body;if(e.body!=null)return JSON.stringify(e.body,null,2);let r=t?.body??(Er(e.bodyPatch)&&typeof e.id=="string"?_.getState().rules.find(o=>o.id===e.id)?.body:void 0);if(Er(e.bodyPatch)&&typeof r=="string")try{return JSON.stringify(la(JSON.parse(r),e.bodyPatch),null,2)}catch{return r}return r}function bf(e){if(!e||typeof e!="object")return null;let t=e.rule??e;if(!t||typeof t!="object")return null;let r=t.id;if(typeof r!="string")return null;let o=_.getState().rules.find(n=>n.id===r);return o?{...o}:null}function vf(e){if(!e||typeof e!="object")return null;let t=e.rule??e;if(!t||typeof t!="object")return null;let r=t;if(r.bodyOmitted!==true||typeof r.id!="string")return null;let o=_.getState().rules.find(n=>n.id===r.id);return o?{body:o.body}:null}function Sf(e){if(!e||typeof e!="object")return null;let t=e.fromRequestId;if(typeof t!="string"||!t)return null;let r=ko(t);return r?Ln(r):null}var wf={dispose:()=>{_.setEnabled(false)},version:6,getSnapshot:()=>(te.ensureInterception(),{conditions:Bt(),events:hf(te.getEvents()),overrides:pf(_.getState()),saved:fe.getRecords().map(e=>({...e,event:Dn(e.event).event}))}),subscribe:e=>{let t=te.subscribeToEvents(e),r=et(e),o=fe.subscribe(e),n=_.subscribe(e);return()=>{r(),t(),o(),n()}},actions:{getNetworkConditions:Bt,setNetworkConditions:Nr,clearEvents:()=>{te.clearEvents()},getEventBody:e=>{let t=ir(e);if(!t)return null;let r=ko(t);return r?{url:r.url??null,method:r.method??null,status:r.status??null,override:r.override??null,condition:r.condition??null,requestData:r.requestData??null,responseData:r.responseData??null,requestHeaders:r.requestHeaders??null,responseHeaders:r.responseHeaders??null}:null},setPinned:e=>{let t=ir(e);if(!t)return null;let r=ko(t);if(!r)return null;let o=To(e,"pinned");return to(fe.getState(),t).pinned===o?{ok:true}:fe.togglePin(r)},setSaved:e=>{let t=ir(e);if(!t)return null;let r=ko(t);if(!r)return null;let o=To(e,"saved");return to(fe.getState(),t).saved===o?{ok:true}:fe.toggleSave(r)},removeSavedRecord:e=>{let t=e&&typeof e=="object"?e.key:void 0;return t?(fe.remove(t),{ok:true}):null},clearSavedRequests:()=>(fe.clearSaved(),{ok:true}),clearPinnedRequests:()=>(fe.clearPinned(),{ok:true}),setOverridesEnabled:e=>(_.setEnabled(To(e,"enabled")),{ok:true,enabled:_.getState().enabled,...Ro()}),upsertOverrideRule:e=>{let t=e?.rule??e,r=!!t&&t.body==null&&(Er(t.bodyPatch)||typeof t.bodyPath=="string"),o=Sf(e)??vf(e)??(r?bf(e):null);if(t&&typeof t.bodyPath=="string"&&t.body==null){let s=o?.body??(typeof t.id=="string"?_.getState().rules.find(u=>u.id===t.id)?.body:void 0);if(typeof s!="string")return{ok:false,error:"bodyPath needs something to patch: send fromRequestId (the captured request whose real response it addresses) or the id of an existing rule."};if(t.bodyValue===void 0)return{ok:false,error:`Refused: sent \`bodyPath\` without \`bodyValue\`. Say what to set "${t.bodyPath}" to.`};let l;try{l=JSON.parse(s)}catch{return{ok:false,error:"The captured response body is not JSON, so it cannot be addressed by path. Send a whole `body` instead."}}let a=nf(l,t.bodyPath,t.bodyValue);if(!a.ok)return{ok:false,error:`Refused: ${a.error}`};t.bodyPatch=a.patch,delete t.bodyPath,delete t.bodyValue}if(t&&Er(t.bodyPatch)&&t.body==null){let s=o?.body??(typeof t.id=="string"?_.getState().rules.find(a=>a.id===t.id)?.body:void 0);if(typeof s!="string")return{ok:false,error:"bodyPatch needs something to patch: send fromRequestId (the captured request whose real response the patch is merged into) or the id of an existing rule."};let l;try{let a=of(JSON.parse(s),t.bodyPatch);l=a.error,a.notes.length&&(t.bodyPatch=a.patch)}catch{}if(l)return{ok:false,error:`Refused: ${l}`};if(t.force!==true){let a=gf(t,s);if(a.length>0)return{ok:false,error:sf(a,"response body",af(t.bodyPatch,a)),violations:a}}}let n=yf(e,o);if(!n){let s=e?.fromRequestId;return{ok:false,error:s?`No captured request \`${s}\` \u2014 it may have been cleared. Send a urlPattern instead.`:"A rule needs a non-empty urlPattern."}}let i=_.upsertRule(n);return i?(i.enabled&&_.setEnabled(true),{ok:true,rule:{id:i.id,urlPattern:i.urlPattern,enabled:i.enabled,kind:i.kind,status:i.status,times:i.times,bodySize:i.body?i.body.length:0},...i.times===void 0||i.times===null?{lingers:`This rule has no \`times\` budget, so it overrides EVERY matching request until it is disabled or deleted (id \`${i.id}\`). If you meant only the next one, set times:1.`}:{},...Ro()}):{ok:false,error:"Override rule limit reached."}},setOverrideRuleEnabled:e=>{let t=ir(e);return t?(_.setRuleEnabled(t,To(e,"enabled")),{ok:true,...Ro()}):{ok:false,error:"Missing rule id."}},deleteOverrideRule:e=>{let t=ir(e);return t?(_.removeRule(t),{ok:true}):{ok:false,error:"Missing rule id."}},clearOverrideRules:()=>(_.clearRules(),{ok:true}),replaceOverrideRules:async e=>{let t=e??{};if(!Array.isArray(t.rules))return{ok:false,error:"replaceOverrideRules needs `rules`: an array of rules, first match first."};if(t.rules.length>Ze)return{ok:false,error:`Too many rules: ${t.rules.length}. The most is ${Ze}.`};await _.ensureLoaded();let r=_.replaceAllRules(t.rules,t.enabled!==false);return r?{ok:true,count:r.length,enabled:_.getState().enabled,...Ro()}:{ok:false,error:"This copy of the Network tool only mirrors a device, so it can't replace rules."}},listOverrideRules:async()=>(await _.ensureLoaded(),_.getState()),getOverrideRuleBody:e=>{let t=ir(e);if(!t)return null;let r=_.getState().rules.find(o=>o.id===t);return r?{body:r.body??null}:null},getCaptureStatus:()=>{let e=te.getSubscriberCounts().total,t=null,r=null;try{t=zi(),r=Pt()}catch{}let o=null;try{o=gd()}catch{}return{capturing:e>0,subscribers:e,interceptorInstalled:t,interceptorLive:o,listenerCount:r,eventCount:te.getEvents().length}},debugOverrides:e=>{let{url:t,method:r}=e&&typeof e=="object"?e:{},o=typeof t=="string"?t:"https://example.com/",n=typeof r=="string"&&r.trim()?r.trim().toUpperCase():"GET";return{tested:{url:o,method:n},interceptorInstalled:zi(),listenerCount:Pt(),engine:td(o,n),store:{enabled:_.getState().enabled,autoPaused:_.getState().autoPaused,ruleCount:_.getState().rules.length,rulesVisibleToEngine:_.getRules().length}}}}};O();var xf=new Set(["content-length","host","connection","accept-encoding"]);function Mn(e){return`'${e.replace(/'/g,"'\\''")}'`}function Cf(e){if(e==null)return null;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return null}}function kf(e){let t=(e.method||"GET").toUpperCase(),r=Cf(e.requestData),o=[];t!=="GET"&&!(t==="POST"&&r!==null)&&o.push(`-X ${t}`);for(let[i,s]of Object.entries(e.requestHeaders||{}))xf.has(i.toLowerCase())||o.push(`-H ${Mn(`${i}: ${s}`)}`);r!==null&&o.push(`--data-raw ${Mn(r)}`);let n=`curl ${Mn(e.url)}`;return o.length===0?n:`${n} \\
144
145
  ${o.join(` \\
145
- `)}`}export{qu as DEFAULT_SETTLE_MS,Un as FREE_TIER_OVERRIDE_LIMIT,Mi as FREE_TIER_SAVED_LIMIT,Fe as MAX_OVERRIDE_RULES,Or as MAX_PINNED,it as MAX_SAVED,tr as NETWORK_CONDITIONS,Ad as NetworkBodyResolverProvider,Gi as NetworkDetailPinActions,ki as NetworkEventDetailView,$t as NetworkEventItemCompact,Ji as NetworkHeaderBadgesView,bs as NetworkModal,_u as NetworkSavedButton,rs as NetworkSavedScreen,rp as NetworkToolView,Zt as OVERRIDE_STATUS_MAX,Qt as OVERRIDE_STATUS_MIN,qo as TickProvider,er as addNetworkListener,ip as createNetworkTool,Qo as draftFromEvent,Dr as flagsForEventId,Ye as formatBytes,Lr as formatDuration,Si as formatHttpStatus,Hp as generateCurl,vt as getNetworkCondition,pp as ignoredPatternsStore,gp as isUrlIgnored,K as networkEventStore,xr as networkListener,ae as networkSavedStore,Ue as networkSelectionStore,Dp as networkSyncAdapter,Ss as networkToolPreset,U as overrideRulesStore,Ol as removeAllNetworkListeners,Cr as setNetworkCondition,Wo as splitPinned,sp as startNetworkCapture,rr as subscribeNetworkConditions,fp as urlMatchesIgnoredPattern,hp as useIgnoredPatterns,ms as useLiveNetworkEvent,Ui as useNetworkBadgeCounts,hr as useNetworkEventList,cp as useNetworkEvents,Mt as useNetworkSaved,Oo as useTickEveryMinute};
146
+ `)}`}O();function Tf(e,t){return e?!t||t.runtimeId!==e.runtimeId||t.revision<e.revision?e:t:null}export{vc as DEFAULT_SETTLE_MS,Ti as FREE_TIER_OVERRIDE_LIMIT,vs as FREE_TIER_SAVED_LIMIT,Ze as MAX_OVERRIDE_RULES,eo as MAX_PINNED,vt as MAX_SAVED,mt as NETWORK_CONDITIONS,Cu as NetworkBodyResolverProvider,Ls as NetworkDetailPinActions,ss as NetworkEventDetailView,er as NetworkEventItemCompact,Ps as NetworkHeaderBadgesView,ea as NetworkModal,Oc as NetworkSavedButton,Ms as NetworkSavedScreen,jp as NetworkToolView,hr as OVERRIDE_STATUS_MAX,cr as OVERRIDE_STATUS_MIN,cn as TickProvider,fr as addNetworkListener,Tf as chooseConditionsSnapshot,Up as createNetworkTool,Ln as draftFromEvent,to as flagsForEventId,ct as formatBytes,Zr as formatDuration,ts as formatHttpStatus,kf as generateCurl,Lt as getConditionsRevision,Ot as getNetworkCondition,Bt as getNetworkConditions,vd as getNetworkConnection,Qp as ignoredPatternsStore,tf as isUrlIgnored,en as networkConditionsActive,te as networkEventStore,Mr as networkListener,fe as networkSavedStore,nt as networkSelectionStore,wf as networkSyncAdapter,ra as networkToolPreset,_ as overrideRulesStore,yd as removeAllNetworkListeners,jr as setNetworkCondition,Nr as setNetworkConditions,xn as splitPinned,_p as startNetworkCapture,et as subscribeNetworkConditions,ef as urlMatchesIgnoredPattern,Zp as useIgnoredPatterns,Zs as useLiveNetworkEvent,Rs as useNetworkBadgeCounts,kr as useNetworkEventList,Yp as useNetworkEvents,Zt as useNetworkSaved,hn as useTickEveryMinute};