import{a as M,c as I,d as q}from"./chunk-D75D27YU.js";import{a as g,h as O}from"./chunk-VWCGOHBE.js";import{Ia as v,Na as E,a as w,l as y}from"./chunk-V6BPA3D7.js";var B=(e,t,i)=>{let n=["POST","PUT","PATCH"].indexOf(e.method.toUpperCase())!==-1,c=r=>["variables","extensions"].indexOf(r.toLowerCase())!==-1,f=e.body.length,s=e.options&&e.options.useMultipart,l;if(s){if(f)return new y(r=>r.error(new Error("File upload is not available when combined with Batching")));if(!n)return new y(r=>r.error(new Error("File upload is not available when GET is used")));if(!i)return new y(r=>r.error(new Error(`To use File upload you need to pass "extractFiles" function from "extract-files" library to HttpLink's options`)));l=i(e.body),s=!!l.files.size}let h={};if(f){if(!n)return new y(r=>r.error(new Error("Batching is not available for GET requests")));h={body:e.body}}else{let r=s?l.clone:e.body;n?h={body:r}:h={params:Object.keys(e.body).reduce((d,a)=>{let p=e.body[a];return d[a]=c(a)?JSON.stringify(p):p,d},{})}}if(s&&n){let r=new FormData;r.append("operations",JSON.stringify(h.body));let u={},d=l.files,a=0;d.forEach(p=>{u[++a]=p}),r.append("map",JSON.stringify(u)),a=0,d.forEach((p,m)=>{r.append(++a+"",m,m.name)}),h.body=r}return t.request(e.method,e.url,w(w({observe:"response",responseType:"json",reportProgress:!1},h),e.options))},F=(e,t)=>e&&t?t.keys().reduce((n,c)=>n.set(c,t.getAll(c)),e):t||e;function Q(...e){let t=e.find(i=>typeof i<"u");return typeof t>"u"?e[e.length-1]:t}function k(e){let t=e.headers&&e.headers instanceof g?e.headers:new g(e.headers);if(e.clientAwareness){let{name:i,version:n}=e.clientAwareness;i&&!t.has("apollographql-client-name")&&(t=t.set("apollographql-client-name",i)),n&&!t.has("apollographql-client-version")&&(t=t.set("apollographql-client-version",n))}return t}var x=class extends q{httpClient;options;requester;print=M;constructor(t,i){super(),this.httpClient=t,this.options=i,this.options.operationPrinter&&(this.print=this.options.operationPrinter),this.requester=n=>new I(c=>{let f=n.getContext(),s=(o,P)=>Q(f[o],this.options[o],P),l=s("method","POST"),h=s("includeQuery",!0),r=s("includeExtensions",!1),u=s("uri","graphql"),d=s("withCredentials"),a=s("useMultipart"),p=this.options.useGETForQueries===!0,m=n.query.definitions.some(o=>o.kind==="OperationDefinition"&&o.operation==="query");p&&m&&(l="GET");let b={method:l,url:typeof u=="function"?u(n):u,body:{operationName:n.operationName,variables:n.variables},options:{withCredentials:d,useMultipart:a,headers:this.options.headers}};r&&(b.body.extensions=n.extensions),h&&(b.body.query=this.print(n.query));let T=k(f);b.options.headers=F(b.options.headers,T);let C=B(b,this.httpClient,this.options.extractFiles).subscribe({next:o=>{n.setContext({response:o}),c.next(o.body)},error:o=>c.error(o),complete:()=>c.complete()});return()=>{C.closed||C.unsubscribe()}})}request(t){return this.requester(t)}},G=(()=>{class e{httpClient;constructor(i){this.httpClient=i}create(i){return new x(this.httpClient,i)}static \u0275fac=function(n){return new(n||e)(E(O))};static \u0275prov=v({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})();export{G as a};