function e(){this.abort()}function t(t){return e.bind(t)}async function n(e,t,n,r=fetch){let i=new AbortController,a=setTimeout(i.abort.bind(i),Math.max(1,n));try{return await r(e,{...t,signal:i.signal})}finally{clearTimeout(a)}}const r=Symbol.for(`openclaw.fetch.abort-signal-wrapped`);function i(e,t){let n=e?.body!=null,r=!n&&typeof Request<`u`&&t instanceof Request&&t.body!=null;return!n&&!r||e&&`duplex`in e?e:e?{...e,duplex:`half`}:{duplex:`half`}}function a(e){if(e[r])return e;let n=Object.assign(((n,r)=>{let a=i(r,n),o=a?.signal;if(!o||typeof AbortSignal<`u`&&o instanceof AbortSignal||typeof AbortController>`u`||typeof o.addEventListener!=`function`)return e(n,a);let s=new AbortController,c=t(s),l=!1;o.aborted?s.abort():(o.addEventListener(`abort`,c,{once:!0}),l=!0);let u=()=>{if(!(!l||typeof o.removeEventListener!=`function`)){l=!1;try{o.removeEventListener(`abort`,c)}catch{}}};try{return e(n,{...a,signal:s.signal}).finally(u)}catch(e){throw u(),e}}),e),a=e;return n.preconnect=typeof a.preconnect==`function`?a.preconnect.bind(a):()=>{},Object.defineProperty(n,r,{value:!0,enumerable:!1,configurable:!1,writable:!1}),n}function o(e){let t=e??globalThis.fetch;if(t)return a(t)}export{t as n,n as r,o as t};
