import{C,b1 as n,b2 as F,aW as O,b3 as R,H as $}from"./CSGWN0Ke.js";function j(o,r,i){const[e={},u]=typeof r=="string"?[{},r]:[r,i],t=C(()=>n(o)),s=e.key||F([u,typeof t.value=="string"?t.value:"",...x(e)]);if(!s||typeof s!="string")throw new TypeError("[nuxt] [useFetch] key must be a string: "+s);if(!o)throw new Error("[nuxt] [useFetch] request is missing.");const c=s===u?"$f"+s:s;if(!e.baseURL&&typeof t.value=="string"&&t.value[0]==="/"&&t.value[1]==="/")throw new Error('[nuxt] [useFetch] the request URL must not start with "//".');const{server:d,lazy:y,default:b,transform:g,pick:w,watch:h,immediate:v,getCachedData:_,deep:k,dedupe:q,...D}=e,l=O({...R,...D,cache:typeof e.cache=="boolean"?void 0:e.cache}),T={server:d,lazy:y,default:b,transform:g,pick:w,immediate:v,getCachedData:_,deep:k,dedupe:q,watch:h===!1?[]:[l,t,...h||[]]};let a;return $(c,()=>{var m;(m=a==null?void 0:a.abort)==null||m.call(a,"Request aborted as another request to the same endpoint was initiated."),a=typeof AbortController<"u"?new AbortController:{};const p=n(e.timeout);let f;return p&&(f=setTimeout(()=>a.abort("Request aborted due to timeout."),p),a.signal.onabort=()=>clearTimeout(f)),(e.$fetch||globalThis.$fetch)(t.value,{signal:a.signal,...l}).finally(()=>{clearTimeout(f)})},T)}function x(o){var i;const r=[((i=n(o.method))==null?void 0:i.toUpperCase())||"GET",n(o.baseURL)];for(const e of[o.params||o.query]){const u=n(e);if(!u)continue;const t={};for(const[s,c]of Object.entries(u))t[n(s)]=n(c);r.push(t)}return r}export{j as u};