import{a as p}from"./chunk-HSCZHVGH.js";import{c as h,d as a,e as x}from"./chunk-D75D27YU.js";import{ba as d,v as m}from"./chunk-V6BPA3D7.js";function s(i){return new a(function(e,n){return new h(function(r){var c,u,o;try{c=n(e).subscribe({next:function(t){if(t.errors&&(o=i({graphQLErrors:t.errors,response:t,operation:e,forward:n}),o)){u=o.subscribe({next:r.next.bind(r),error:r.error.bind(r),complete:r.complete.bind(r)});return}r.next(t)},error:function(t){if(o=i({operation:e,networkError:t,graphQLErrors:t&&t.result&&t.result.errors,forward:n}),o){u=o.subscribe({next:r.next.bind(r),error:r.error.bind(r),complete:r.complete.bind(r)});return}r.error(t)},complete:function(){o||r.complete.bind(r)()}})}catch(t){i({networkError:t,operation:e,forward:n}),r.error(t)}return function(){c&&c.unsubscribe(),u&&c.unsubscribe()}})})}var E=function(i){m(e,i);function e(n){var r=i.call(this)||this;return r.link=s(n),r}return e.prototype.request=function(n,r){return this.link.request(n,r)},e}(a);function A(i,e,n,r,c){let u=i.use(n);if(u)return u;let o=e.create({uri:r,withCredentials:!0}),t=new a((f,l)=>l?l(f).map(C=>C):null),y=s(f=>{f.graphQLErrors&&f.graphQLErrors.find(l=>l.extensions?.errorCode===p.entityNotFound||l.extensions?.errorCode===p.illegalCartState||l.extensions?.errorCode===p.illegalCartCmd)&&c?.refresh().pipe(d(1)).subscribe(()=>{window.location.reload()})});i.createNamed(n,{link:y.concat(t.concat(o)),cache:new x,defaultOptions:{watchQuery:{fetchPolicy:"no-cache",errorPolicy:"ignore"},query:{fetchPolicy:"no-cache",errorPolicy:"all"},mutate:{fetchPolicy:"no-cache",errorPolicy:"all"}}})}export{A as a};