storybook-msw-addon
Version:
An MSW (Mock Service Worker) addon including a control panel that enables interaction and manipulation of mock requests within Storybook. MSW 2.3.3 + Storybook 8
38 lines (28 loc) • 73 kB
JavaScript
'use strict';
var previewApi = require('@storybook/preview-api');
var isNodeProcess = require('is-node-process');
var coreEvents = require('@storybook/core-events');
var tr=/(%?)(%([sdijo]))/g;function rr(e,t){switch(t){case"s":return e;case"d":case"i":return Number(e);case"j":return JSON.stringify(e);case"o":{if(typeof e=="string")return e;let r=JSON.stringify(e);return r==="{}"||r==="[]"||/^\[object .+?\]$/.test(r)?e:r}}}function J(e,...t){if(t.length===0)return e;let r=0,s=e.replace(tr,(n,i,a,p)=>{let o=t[r],c=rr(o,p);return i?n:(r++,c)});return r<t.length&&(s+=` ${t.slice(r).join(" ")}`),s=s.replace(/%{2,2}/g,"%"),s}var nr=2;function sr(e){if(!e.stack)return;let t=e.stack.split(`
`);t.splice(1,nr),e.stack=t.join(`
`);}var ir=class extends Error{constructor(e,...t){super(e),this.message=e,this.name="Invariant Violation",this.message=J(e,...t),sr(this);}},X=(e,t,...r)=>{if(!e)throw new ir(t,...r)};X.as=(e,t,r,...s)=>{if(!t){let n=s.length===0?r:J(r,s),i;try{i=Reflect.construct(e,[n]);}catch{i=e(n);}throw i}};var or="[MSW]";function Le(e,...t){let r=J(e,...t);return `${or} ${r}`}function ar(e,...t){console.warn(Le(e,...t));}function cr(e,...t){console.error(Le(e,...t));}var R={formatMessage:Le,warn:ar,error:cr};function Ge(){X(typeof URL<"u",R.formatMessage(`Global "URL" class is not defined. This likely means that you're running MSW in an environment that doesn't support all Node.js standard API (e.g. React Native). If that's the case, please use an appropriate polyfill for the "URL" class, like "react-native-url-polyfill".`));}var lr=/[\/\\]msw[\/\\]src[\/\\](.+)/,pr=/(node_modules)?[\/\\]lib[\/\\](core|browser|node|native|iife)[\/\\]|^[^\/\\]*$/;function Qe(e){let t=e.stack;if(!t)return;let s=t.split(`
`).slice(1).find(i=>!(lr.test(i)||pr.test(i)));return s?s.replace(/\s*at [^()]*\(([^)]+)\)/,"$1").replace(/^@/,""):void 0}function ze(e){return e?typeof e[Symbol.iterator]=="function":!1}var q=class e{static cache=new WeakMap;info;isUsed;resolver;resolverGenerator;resolverGeneratorResult;options;constructor(t){this.resolver=t.resolver,this.options=t.options;let r=Qe(new Error);this.info={...t.info,callFrame:r},this.isUsed=!1;}async parse(t){return {}}async test(t){let r=await this.parse({request:t.request,resolutionContext:t.resolutionContext});return this.predicate({request:t.request,parsedResult:r,resolutionContext:t.resolutionContext})}extendResolverArgs(t){return {}}cloneRequestOrGetFromCache(t){let r=e.cache.get(t);if(typeof r<"u")return r;let s=t.clone();return e.cache.set(t,s),s}async run(t){if(this.isUsed&&this.options?.once)return null;let r=this.cloneRequestOrGetFromCache(t.request),s=await this.parse({request:t.request,resolutionContext:t.resolutionContext});if(!this.predicate({request:t.request,parsedResult:s,resolutionContext:t.resolutionContext})||this.isUsed&&this.options?.once)return null;this.isUsed=!0;let i=this.wrapResolver(this.resolver),a=this.extendResolverArgs({request:t.request,parsedResult:s}),o=await i({...a,requestId:t.requestId,request:t.request}).catch(u=>{if(u instanceof Response)return u;throw u});return this.createExecutionResult({request:r,requestId:t.requestId,response:o,parsedResult:s})}wrapResolver(t){return async r=>{let s=this.resolverGenerator||await t(r);if(ze(s)){this.isUsed=!1;let{value:n,done:i}=s[Symbol.iterator]().next(),a=await n;return i&&(this.isUsed=!0),!a&&i?(X(this.resolverGeneratorResult,"Failed to returned a previously stored generator response: the value is not a valid Response."),this.resolverGeneratorResult.clone()):(this.resolverGenerator||(this.resolverGenerator=s),a&&(this.resolverGeneratorResult=a?.clone()),a)}return s}}createExecutionResult(t){return {handler:this,request:t.request,requestId:t.requestId,response:t.response,parsedResult:t.parsedResult}}};function Ke(e,t){return e.toLowerCase()===t.toLowerCase()}function ce(e){return e<300?"#69AB32":e<400?"#F0BB4B":"#E95F5D"}function ue(){let e=new Date;return [e.getHours(),e.getMinutes(),e.getSeconds()].map(String).map(t=>t.slice(0,2)).map(t=>t.padStart(2,"0")).join(":")}async function le(e){let r=await e.clone().text();return {url:new URL(e.url),method:e.method,headers:Object.fromEntries(e.headers.entries()),body:r}}var dr=Object.create,Je=Object.defineProperty,fr=Object.getOwnPropertyDescriptor,Xe=Object.getOwnPropertyNames,hr=Object.getPrototypeOf,mr=Object.prototype.hasOwnProperty,Ze=(e,t)=>function(){return t||(0, e[Xe(e)[0]])((t={exports:{}}).exports,t),t.exports},yr=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Xe(t))!mr.call(e,n)&&n!==r&&Je(e,n,{get:()=>t[n],enumerable:!(s=fr(t,n))||s.enumerable});return e},Er=(e,t,r)=>(r=e!=null?dr(hr(e)):{},yr(t||!e||!e.__esModule?Je(r,"default",{value:e,enumerable:!0}):r,e)),Tr=Ze({"node_modules/statuses/codes.json"(e,t){t.exports={100:"Continue",101:"Switching Protocols",102:"Processing",103:"Early Hints",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a Teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"};}}),gr=Ze({"node_modules/statuses/index.js"(e,t){var r=Tr();t.exports=p,p.message=r,p.code=s(r),p.codes=n(r),p.redirect={300:!0,301:!0,302:!0,303:!0,305:!0,307:!0,308:!0},p.empty={204:!0,205:!0,304:!0},p.retry={502:!0,503:!0,504:!0};function s(o){var c={};return Object.keys(o).forEach(function(m){var d=o[m],E=Number(m);c[d.toLowerCase()]=E;}),c}function n(o){return Object.keys(o).map(function(u){return Number(u)})}function i(o){var c=o.toLowerCase();if(!Object.prototype.hasOwnProperty.call(p.code,c))throw new Error('invalid status message: "'+o+'"');return p.code[c]}function a(o){if(!Object.prototype.hasOwnProperty.call(p.message,o))throw new Error("invalid status code: "+o);return p.message[o]}function p(o){if(typeof o=="number")return a(o);if(typeof o!="string")throw new TypeError("code must be a number or string");var c=parseInt(o,10);return isNaN(c)?i(o):a(c)}}}),xr=Er(gr(),1),pe=xr.default;var{message:_r}=pe;async function de(e){let t=e.clone(),r=await t.text(),s=t.status||200,n=t.statusText||_r[s]||"OK";return {status:s,statusText:n,headers:Object.fromEntries(t.headers.entries()),body:r}}function vr(e){for(var t=[],r=0;r<e.length;){var s=e[r];if(s==="*"||s==="+"||s==="?"){t.push({type:"MODIFIER",index:r,value:e[r++]});continue}if(s==="\\"){t.push({type:"ESCAPED_CHAR",index:r++,value:e[r++]});continue}if(s==="{"){t.push({type:"OPEN",index:r,value:e[r++]});continue}if(s==="}"){t.push({type:"CLOSE",index:r,value:e[r++]});continue}if(s===":"){for(var n="",i=r+1;i<e.length;){var a=e.charCodeAt(i);if(a>=48&&a<=57||a>=65&&a<=90||a>=97&&a<=122||a===95){n+=e[i++];continue}break}if(!n)throw new TypeError("Missing parameter name at ".concat(r));t.push({type:"NAME",index:r,value:n}),r=i;continue}if(s==="("){var p=1,o="",i=r+1;if(e[i]==="?")throw new TypeError('Pattern cannot start with "?" at '.concat(i));for(;i<e.length;){if(e[i]==="\\"){o+=e[i++]+e[i++];continue}if(e[i]===")"){if(p--,p===0){i++;break}}else if(e[i]==="("&&(p++,e[i+1]!=="?"))throw new TypeError("Capturing groups are not allowed at ".concat(i));o+=e[i++];}if(p)throw new TypeError("Unbalanced pattern at ".concat(r));if(!o)throw new TypeError("Missing pattern at ".concat(r));t.push({type:"PATTERN",index:r,value:o}),r=i;continue}t.push({type:"CHAR",index:r,value:e[r++]});}return t.push({type:"END",index:r,value:""}),t}function Or(e,t){t===void 0&&(t={});for(var r=vr(e),s=t.prefixes,n=s===void 0?"./":s,i="[^".concat(B(t.delimiter||"/#?"),"]+?"),a=[],p=0,o=0,c="",u=function(N){if(o<r.length&&r[o].type===N)return r[o++].value},m=function(N){var P=u(N);if(P!==void 0)return P;var k=r[o],be=k.type,Ce=k.index;throw new TypeError("Unexpected ".concat(be," at ").concat(Ce,", expected ").concat(N))},d=function(){for(var N="",P;P=u("CHAR")||u("ESCAPED_CHAR");)N+=P;return N};o<r.length;){var E=u("CHAR"),f=u("NAME"),h=u("PATTERN");if(f||h){var T=E||"";n.indexOf(T)===-1&&(c+=T,T=""),c&&(a.push(c),c=""),a.push({name:f||p++,prefix:T,suffix:"",pattern:h||i,modifier:u("MODIFIER")||""});continue}var g=E||u("ESCAPED_CHAR");if(g){c+=g;continue}c&&(a.push(c),c="");var x=u("OPEN");if(x){var T=d(),S=u("NAME")||"",_=u("PATTERN")||"",D=d();m("CLOSE"),a.push({name:S||(_?p++:""),pattern:S&&!_?i:_,prefix:T,suffix:D,modifier:u("MODIFIER")||""});continue}m("END");}return a}function et(e,t){var r=[],s=rt(e,r,t);return Sr(s,r,t)}function Sr(e,t,r){r===void 0&&(r={});var s=r.decode,n=s===void 0?function(i){return i}:s;return function(i){var a=e.exec(i);if(!a)return !1;for(var p=a[0],o=a.index,c=Object.create(null),u=function(d){if(a[d]===void 0)return "continue";var E=t[d-1];E.modifier==="*"||E.modifier==="+"?c[E.name]=a[d].split(E.prefix+E.suffix).map(function(f){return n(f,E)}):c[E.name]=n(a[d],E);},m=1;m<a.length;m++)u(m);return {path:p,index:o,params:c}}}function B(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function tt(e){return e&&e.sensitive?"":"i"}function Nr(e,t){if(!t)return e;for(var r=/\((?:\?<(.*?)>)?(?!\?)/g,s=0,n=r.exec(e.source);n;)t.push({name:n[1]||s++,prefix:"",suffix:"",modifier:"",pattern:""}),n=r.exec(e.source);return e}function Rr(e,t,r){var s=e.map(function(n){return rt(n,t,r).source});return new RegExp("(?:".concat(s.join("|"),")"),tt(r))}function wr(e,t,r){return Ir(Or(e,r),t,r)}function Ir(e,t,r){r===void 0&&(r={});for(var s=r.strict,n=s===void 0?!1:s,i=r.start,a=i===void 0?!0:i,p=r.end,o=p===void 0?!0:p,c=r.encode,u=c===void 0?function(Ce){return Ce}:c,m=r.delimiter,d=m===void 0?"/#?":m,E=r.endsWith,f=E===void 0?"":E,h="[".concat(B(f),"]|$"),T="[".concat(B(d),"]"),g=a?"^":"",x=0,S=e;x<S.length;x++){var _=S[x];if(typeof _=="string")g+=B(u(_));else {var D=B(u(_.prefix)),N=B(u(_.suffix));if(_.pattern)if(t&&t.push(_),D||N)if(_.modifier==="+"||_.modifier==="*"){var P=_.modifier==="*"?"?":"";g+="(?:".concat(D,"((?:").concat(_.pattern,")(?:").concat(N).concat(D,"(?:").concat(_.pattern,"))*)").concat(N,")").concat(P);}else g+="(?:".concat(D,"(").concat(_.pattern,")").concat(N,")").concat(_.modifier);else _.modifier==="+"||_.modifier==="*"?g+="((?:".concat(_.pattern,")").concat(_.modifier,")"):g+="(".concat(_.pattern,")").concat(_.modifier);else g+="(?:".concat(D).concat(N,")").concat(_.modifier);}}if(o)n||(g+="".concat(T,"?")),g+=r.endsWith?"(?=".concat(h,")"):"$";else {var k=e[e.length-1],be=typeof k=="string"?T.indexOf(k[k.length-1])>-1:k===void 0;n||(g+="(?:".concat(T,"(?=").concat(h,"))?")),be||(g+="(?=".concat(T,"|").concat(h,")"));}return new RegExp(g,tt(r))}function rt(e,t,r){return e instanceof RegExp?Nr(e,t):Array.isArray(e)?Rr(e,t,r):wr(e,t,r)}new TextEncoder;var br=Object.defineProperty,Cr=(e,t)=>{for(var r in t)br(e,r,{get:t[r],enumerable:!0});},Dr={};Cr(Dr,{blue:()=>kr,gray:()=>Mr,green:()=>Ur,red:()=>Fr,yellow:()=>Pr});function Pr(e){return `\x1B[33m${e}\x1B[0m`}function kr(e){return `\x1B[34m${e}\x1B[0m`}function Mr(e){return `\x1B[90m${e}\x1B[0m`}function Fr(e){return `\x1B[31m${e}\x1B[0m`}function Ur(e){return `\x1B[32m${e}\x1B[0m`}isNodeProcess.isNodeProcess();function nt(e,t=!0){return [t&&e.origin,e.pathname].filter(Boolean).join("")}var qr=/[\?|#].*$/g;function st(e){return new URL(`/${e}`,"http://localhost").searchParams}function fe(e){return e.replace(qr,"")}function it(e){return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}function ot(e,t){if(it(e)||e.startsWith("*"))return e;let r=t||typeof document<"u"&&document.baseURI;return r?decodeURI(new URL(encodeURI(e),r).href):e}function at(e,t){if(e instanceof RegExp)return e;let r=ot(e,t);return fe(r)}function Br(e){return e.replace(/([:a-zA-Z_-]*)(\*{1,2})+/g,(t,r,s)=>{let n="(.*)";return r?r.startsWith(":")?`${r}${s}`:`${r}${n}`:n}).replace(/([^\/])(:)(?=\d+)/,"$1\\$2").replace(/^([^\/]+)(:)(?=\/\/)/,"$1\\$2")}function he(e,t,r){let s=at(t,r),n=typeof s=="string"?Br(s):s,i=nt(e),a=et(n,{decode:decodeURIComponent})(i),p=a&&a.params||{};return {matches:a!==!1,params:p}}function j(e){if(typeof location>"u")return e.toString();let t=e instanceof URL?e:new URL(e);return t.origin===location.origin?t.pathname:t.origin+t.pathname}var jr=Object.create,ct=Object.defineProperty,Vr=Object.getOwnPropertyDescriptor,ut=Object.getOwnPropertyNames,$r=Object.getPrototypeOf,Hr=Object.prototype.hasOwnProperty,Gr=(e,t)=>function(){return t||(0, e[ut(e)[0]])((t={exports:{}}).exports,t),t.exports},Yr=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ut(t))!Hr.call(e,n)&&n!==r&&ct(e,n,{get:()=>t[n],enumerable:!(s=Vr(t,n))||s.enumerable});return e},Wr=(e,t,r)=>(r=e!=null?jr($r(e)):{},Yr(t||!e||!e.__esModule?ct(r,"default",{value:e,enumerable:!0}):r,e)),Qr=Gr({"node_modules/cookie/index.js"(e){e.parse=s,e.serialize=n;var t=Object.prototype.toString,r=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function s(c,u){if(typeof c!="string")throw new TypeError("argument str must be a string");for(var m={},d=u||{},E=d.decode||i,f=0;f<c.length;){var h=c.indexOf("=",f);if(h===-1)break;var T=c.indexOf(";",f);if(T===-1)T=c.length;else if(T<h){f=c.lastIndexOf(";",h-1)+1;continue}var g=c.slice(f,h).trim();if(m[g]===void 0){var x=c.slice(h+1,T).trim();x.charCodeAt(0)===34&&(x=x.slice(1,-1)),m[g]=o(x,E);}f=T+1;}return m}function n(c,u,m){var d=m||{},E=d.encode||a;if(typeof E!="function")throw new TypeError("option encode is invalid");if(!r.test(c))throw new TypeError("argument name is invalid");var f=E(u);if(f&&!r.test(f))throw new TypeError("argument val is invalid");var h=c+"="+f;if(d.maxAge!=null){var T=d.maxAge-0;if(isNaN(T)||!isFinite(T))throw new TypeError("option maxAge is invalid");h+="; Max-Age="+Math.floor(T);}if(d.domain){if(!r.test(d.domain))throw new TypeError("option domain is invalid");h+="; Domain="+d.domain;}if(d.path){if(!r.test(d.path))throw new TypeError("option path is invalid");h+="; Path="+d.path;}if(d.expires){var g=d.expires;if(!p(g)||isNaN(g.valueOf()))throw new TypeError("option expires is invalid");h+="; Expires="+g.toUTCString();}if(d.httpOnly&&(h+="; HttpOnly"),d.secure&&(h+="; Secure"),d.priority){var x=typeof d.priority=="string"?d.priority.toLowerCase():d.priority;switch(x){case"low":h+="; Priority=Low";break;case"medium":h+="; Priority=Medium";break;case"high":h+="; Priority=High";break;default:throw new TypeError("option priority is invalid")}}if(d.sameSite){var S=typeof d.sameSite=="string"?d.sameSite.toLowerCase():d.sameSite;switch(S){case!0:h+="; SameSite=Strict";break;case"lax":h+="; SameSite=Lax";break;case"strict":h+="; SameSite=Strict";break;case"none":h+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return h}function i(c){return c.indexOf("%")!==-1?decodeURIComponent(c):c}function a(c){return encodeURIComponent(c)}function p(c){return t.call(c)==="[object Date]"||c instanceof Date}function o(c,u){try{return u(c)}catch{return c}}}}),zr=Wr(Qr(),1),me=zr.default;var Kr=Object.create,ft=Object.defineProperty,Jr=Object.getOwnPropertyDescriptor,ht=Object.getOwnPropertyNames,Xr=Object.getPrototypeOf,Zr=Object.prototype.hasOwnProperty,en=(e,t)=>function(){return t||(0, e[ht(e)[0]])((t={exports:{}}).exports,t),t.exports},tn=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ht(t))!Zr.call(e,n)&&n!==r&&ft(e,n,{get:()=>t[n],enumerable:!(s=Jr(t,n))||s.enumerable});return e},rn=(e,t,r)=>(r=e!=null?Kr(Xr(e)):{},tn(t||!e||!e.__esModule?ft(r,"default",{value:e,enumerable:!0}):r,e)),nn=en({"node_modules/set-cookie-parser/lib/set-cookie.js"(e,t){var r={decodeValues:!0,map:!1,silent:!1};function s(o){return typeof o=="string"&&!!o.trim()}function n(o,c){var u=o.split(";").filter(s),m=u.shift(),d=i(m),E=d.name,f=d.value;c=c?Object.assign({},r,c):r;try{f=c.decodeValues?decodeURIComponent(f):f;}catch(T){console.error("set-cookie-parser encountered an error while decoding a cookie with value '"+f+"'. Set options.decodeValues to false to disable this feature.",T);}var h={name:E,value:f};return u.forEach(function(T){var g=T.split("="),x=g.shift().trimLeft().toLowerCase(),S=g.join("=");x==="expires"?h.expires=new Date(S):x==="max-age"?h.maxAge=parseInt(S,10):x==="secure"?h.secure=!0:x==="httponly"?h.httpOnly=!0:x==="samesite"?h.sameSite=S:h[x]=S;}),h}function i(o){var c="",u="",m=o.split("=");return m.length>1?(c=m.shift(),u=m.join("=")):u=o,{name:c,value:u}}function a(o,c){if(c=c?Object.assign({},r,c):r,!o)return c.map?{}:[];if(o.headers)if(typeof o.headers.getSetCookie=="function")o=o.headers.getSetCookie();else if(o.headers["set-cookie"])o=o.headers["set-cookie"];else {var u=o.headers[Object.keys(o.headers).find(function(d){return d.toLowerCase()==="set-cookie"})];!u&&o.headers.cookie&&!c.silent&&console.warn("Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."),o=u;}if(Array.isArray(o)||(o=[o]),c=c?Object.assign({},r,c):r,c.map){var m={};return o.filter(s).reduce(function(d,E){var f=n(E,c);return d[f.name]=f,d},m)}else return o.filter(s).map(function(d){return n(d,c)})}function p(o){if(Array.isArray(o))return o;if(typeof o!="string")return [];var c=[],u=0,m,d,E,f,h;function T(){for(;u<o.length&&/\s/.test(o.charAt(u));)u+=1;return u<o.length}function g(){return d=o.charAt(u),d!=="="&&d!==";"&&d!==","}for(;u<o.length;){for(m=u,h=!1;T();)if(d=o.charAt(u),d===","){for(E=u,u+=1,T(),f=u;u<o.length&&g();)u+=1;u<o.length&&o.charAt(u)==="="?(h=!0,u=f,c.push(o.substring(m,E)),m=u):u=E+1;}else u+=1;(!h||u>=o.length)&&c.push(o.substring(m,o.length));}return c}t.exports=a,t.exports.parse=a,t.exports.parseString=n,t.exports.splitCookiesString=p;}}),lt=rn(nn()),V="MSW_COOKIE_STORE";function pt(){try{if(localStorage==null)return !1;let e=V+"_test";return localStorage.setItem(e,"test"),localStorage.getItem(e),localStorage.removeItem(e),!0}catch{return !1}}function dt(e,t){try{return e[t],!0}catch{return !1}}var sn=class{constructor(){this.store=new Map;}add(e,t){if(dt(e,"credentials")&&e.credentials==="omit")return;let r=new URL(e.url),s=t.headers.get("set-cookie");if(!s)return;let n=Date.now(),i=(0, lt.parse)(s).map(({maxAge:p,...o})=>({...o,expires:p===void 0?o.expires:new Date(n+p*1e3),maxAge:p})),a=this.store.get(r.origin)||new Map;i.forEach(p=>{this.store.set(r.origin,a.set(p.name,p));});}get(e){this.deleteExpiredCookies();let t=new URL(e.url),r=this.store.get(t.origin)||new Map;if(!dt(e,"credentials"))return r;switch(e.credentials){case"include":return typeof document>"u"||(0, lt.parse)(document.cookie).forEach(n=>{r.set(n.name,n);}),r;case"same-origin":return r;default:return new Map}}getAll(){return this.deleteExpiredCookies(),this.store}deleteAll(e){let t=new URL(e.url);this.store.delete(t.origin);}clear(){this.store.clear();}hydrate(){if(!pt())return;let e=localStorage.getItem(V);if(e)try{JSON.parse(e).forEach(([r,s])=>{this.store.set(r,new Map(s.map(([n,{expires:i,...a}])=>[n,i===void 0?a:{...a,expires:new Date(i)}])));});}catch(t){console.warn(`
[virtual-cookie] Failed to parse a stored cookie from the localStorage (key "${V}").
Stored value:
${localStorage.getItem(V)}
Thrown exception:
${t}
Invalid value has been removed from localStorage to prevent subsequent failed parsing attempts.`),localStorage.removeItem(V);}}persist(){if(!pt())return;let e=Array.from(this.store.entries()).map(([t,r])=>[t,Array.from(r.entries())]);localStorage.setItem(V,JSON.stringify(e));}deleteExpiredCookies(){let e=Date.now();this.store.forEach((t,r)=>{t.forEach(({expires:s,name:n})=>{s!==void 0&&s.getTime()<=e&&t.delete(n);}),t.size===0&&this.store.delete(r);});}},De=new sn;function mt(){return me.parse(document.cookie)}function on(e){if(typeof document>"u"||typeof location>"u")return {};switch(e.credentials){case"same-origin":{let t=new URL(e.url);return location.origin===t.origin?mt():{}}case"include":return mt();default:return {}}}function ye(e){let t=e.headers.get("cookie"),r=t?me.parse(t):{};De.hydrate();let s=Array.from(De.get(e)?.entries()).reduce((a,[p,{value:o}])=>Object.assign(a,{[p.trim()]:o}),{}),i={...on(e),...s};for(let[a,p]of Object.entries(i))e.headers.append("cookie",me.serialize(a,p));return {...i,...r}}var I=(e=>(e.HEAD="HEAD",e.GET="GET",e.POST="POST",e.PUT="PUT",e.PATCH="PATCH",e.OPTIONS="OPTIONS",e.DELETE="DELETE",e))(I||{}),Ee=class extends q{constructor(t,r,s,n){super({info:{header:`${t} ${r}`,path:r,method:t},resolver:s,options:n}),this.checkRedundantQueryParameters();}checkRedundantQueryParameters(){let{method:t,path:r}=this.info;if(r instanceof RegExp||fe(r)===r)return;let n=st(r);n.forEach((a,p)=>{}),R.warn(`Found a redundant usage of query parameters in the request handler URL for "${t} ${r}". Please match against a path instead and access query parameters using "new URL(request.url).searchParams" instead. Learn more: https://mswjs.io/docs/recipes/query-parameters`);}async parse(t){let r=new URL(t.request.url),s=he(r,this.info.path,t.resolutionContext?.baseUrl),n=ye(t.request);return {match:s,cookies:n}}predicate(t){let r=this.matchMethod(t.request.method),s=t.parsedResult.match.matches;return r&&s}matchMethod(t){return this.info.method instanceof RegExp?this.info.method.test(t):Ke(this.info.method,t)}extendResolverArgs(t){return {params:t.parsedResult.match?.params||{},cookies:t.parsedResult.cookies}}async log(t){let r=j(t.request.url),s=await le(t.request),n=await de(t.response),i=ce(n.status);console.groupCollapsed(R.formatMessage(`${ue()} ${t.request.method} ${r} (%c${n.status} ${n.statusText}%c)`),`color:${i}`,"color:inherit"),console.log("Request",s),console.log("Handler:",this),console.log("Response",n),console.groupEnd();}};function b(e){return (t,r,s={})=>new Ee(e,t,r,s)}var w={all:b(/.+/),head:b(I.HEAD),get:b(I.GET),post:b(I.POST),put:b(I.PUT),delete:b(I.DELETE),patch:b(I.PATCH),options:b(I.OPTIONS)};function Te(e,t){if(!!!e)throw new Error(t)}function yt(e){return typeof e=="object"&&e!==null}function Et(e,t){if(!!!e)throw new Error(t??"Unexpected invariant triggered.")}var an=/\r\n|[\n\r]/g;function $(e,t){let r=0,s=1;for(let n of e.body.matchAll(an)){if(typeof n.index=="number"||Et(!1),n.index>=t)break;r=n.index+n[0].length,s+=1;}return {line:s,column:t+1-r}}function Pe(e){return ge(e.source,$(e.source,e.start))}function ge(e,t){let r=e.locationOffset.column-1,s="".padStart(r)+e.body,n=t.line-1,i=e.locationOffset.line-1,a=t.line+i,p=t.line===1?r:0,o=t.column+p,c=`${e.name}:${a}:${o}
`,u=s.split(/\r\n|[\n\r]/g),m=u[n];if(m.length>120){let d=Math.floor(o/80),E=o%80,f=[];for(let h=0;h<m.length;h+=80)f.push(m.slice(h,h+80));return c+Tt([[`${a} |`,f[0]],...f.slice(1,d+1).map(h=>["|",h]),["|","^".padStart(E)],["|",f[d+1]]])}return c+Tt([[`${a-1} |`,u[n-1]],[`${a} |`,m],["|","^".padStart(o)],[`${a+1} |`,u[n+1]]])}function Tt(e){let t=e.filter(([s,n])=>n!==void 0),r=Math.max(...t.map(([s])=>s.length));return t.map(([s,n])=>s.padStart(r)+(n?" "+n:"")).join(`
`)}function cn(e){let t=e[0];return t==null||"kind"in t||"length"in t?{nodes:t,source:e[1],positions:e[2],path:e[3],originalError:e[4],extensions:e[5]}:t}var xe=class e extends Error{constructor(t,...r){var s,n,i;let{nodes:a,source:p,positions:o,path:c,originalError:u,extensions:m}=cn(r);super(t),this.name="GraphQLError",this.path=c??void 0,this.originalError=u??void 0,this.nodes=gt(Array.isArray(a)?a:a?[a]:void 0);let d=gt((s=this.nodes)===null||s===void 0?void 0:s.map(f=>f.loc).filter(f=>f!=null));this.source=p??(d==null||(n=d[0])===null||n===void 0?void 0:n.source),this.positions=o??d?.map(f=>f.start),this.locations=o&&p?o.map(f=>$(p,f)):d?.map(f=>$(f.source,f.start));let E=yt(u?.extensions)?u?.extensions:void 0;this.extensions=(i=m??E)!==null&&i!==void 0?i:Object.create(null),Object.defineProperties(this,{message:{writable:!0,enumerable:!0},name:{enumerable:!1},nodes:{enumerable:!1},source:{enumerable:!1},positions:{enumerable:!1},originalError:{enumerable:!1}}),u!=null&&u.stack?Object.defineProperty(this,"stack",{value:u.stack,writable:!0,configurable:!0}):Error.captureStackTrace?Error.captureStackTrace(this,e):Object.defineProperty(this,"stack",{value:Error().stack,writable:!0,configurable:!0});}get[Symbol.toStringTag](){return "GraphQLError"}toString(){let t=this.message;if(this.nodes)for(let r of this.nodes)r.loc&&(t+=`
`+Pe(r.loc));else if(this.source&&this.locations)for(let r of this.locations)t+=`
`+ge(this.source,r);return t}toJSON(){let t={message:this.message};return this.locations!=null&&(t.locations=this.locations),this.path!=null&&(t.path=this.path),this.extensions!=null&&Object.keys(this.extensions).length>0&&(t.extensions=this.extensions),t}};function gt(e){return e===void 0||e.length===0?void 0:e}function v(e,t,r){return new xe(`Syntax Error: ${r}`,{source:e,positions:[t]})}var Z=class{constructor(t,r,s){this.start=t.start,this.end=r.end,this.startToken=t,this.endToken=r,this.source=s;}get[Symbol.toStringTag](){return "Location"}toJSON(){return {start:this.start,end:this.end}}},H=class{constructor(t,r,s,n,i,a){this.kind=t,this.start=r,this.end=s,this.line=n,this.column=i,this.value=a,this.prev=null,this.next=null;}get[Symbol.toStringTag](){return "Token"}toJSON(){return {kind:this.kind,value:this.value,line:this.line,column:this.column}}},un={Name:[],Document:["definitions"],OperationDefinition:["name","variableDefinitions","directives","selectionSet"],VariableDefinition:["variable","type","defaultValue","directives"],Variable:["name"],SelectionSet:["selections"],Field:["alias","name","arguments","directives","selectionSet"],Argument:["name","value"],FragmentSpread:["name","directives"],InlineFragment:["typeCondition","directives","selectionSet"],FragmentDefinition:["name","variableDefinitions","typeCondition","directives","selectionSet"],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:["values"],ObjectValue:["fields"],ObjectField:["name","value"],Directive:["name","arguments"],NamedType:["name"],ListType:["type"],NonNullType:["type"],SchemaDefinition:["description","directives","operationTypes"],OperationTypeDefinition:["type"],ScalarTypeDefinition:["description","name","directives"],ObjectTypeDefinition:["description","name","interfaces","directives","fields"],FieldDefinition:["description","name","arguments","type","directives"],InputValueDefinition:["description","name","type","defaultValue","directives"],InterfaceTypeDefinition:["description","name","interfaces","directives","fields"],UnionTypeDefinition:["description","name","directives","types"],EnumTypeDefinition:["description","name","directives","values"],EnumValueDefinition:["description","name","directives"],InputObjectTypeDefinition:["description","name","directives","fields"],DirectiveDefinition:["description","name","arguments","locations"],SchemaExtension:["directives","operationTypes"],ScalarTypeExtension:["name","directives"],ObjectTypeExtension:["name","interfaces","directives","fields"],InterfaceTypeExtension:["name","interfaces","directives","fields"],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"]};new Set(Object.keys(un));var C;(function(e){e.QUERY="query",e.MUTATION="mutation",e.SUBSCRIPTION="subscription";})(C||(C={}));var ee;(function(e){e.QUERY="QUERY",e.MUTATION="MUTATION",e.SUBSCRIPTION="SUBSCRIPTION",e.FIELD="FIELD",e.FRAGMENT_DEFINITION="FRAGMENT_DEFINITION",e.FRAGMENT_SPREAD="FRAGMENT_SPREAD",e.INLINE_FRAGMENT="INLINE_FRAGMENT",e.VARIABLE_DEFINITION="VARIABLE_DEFINITION",e.SCHEMA="SCHEMA",e.SCALAR="SCALAR",e.OBJECT="OBJECT",e.FIELD_DEFINITION="FIELD_DEFINITION",e.ARGUMENT_DEFINITION="ARGUMENT_DEFINITION",e.INTERFACE="INTERFACE",e.UNION="UNION",e.ENUM="ENUM",e.ENUM_VALUE="ENUM_VALUE",e.INPUT_OBJECT="INPUT_OBJECT",e.INPUT_FIELD_DEFINITION="INPUT_FIELD_DEFINITION";})(ee||(ee={}));var y;(function(e){e.NAME="Name",e.DOCUMENT="Document",e.OPERATION_DEFINITION="OperationDefinition",e.VARIABLE_DEFINITION="VariableDefinition",e.SELECTION_SET="SelectionSet",e.FIELD="Field",e.ARGUMENT="Argument",e.FRAGMENT_SPREAD="FragmentSpread",e.INLINE_FRAGMENT="InlineFragment",e.FRAGMENT_DEFINITION="FragmentDefinition",e.VARIABLE="Variable",e.INT="IntValue",e.FLOAT="FloatValue",e.STRING="StringValue",e.BOOLEAN="BooleanValue",e.NULL="NullValue",e.ENUM="EnumValue",e.LIST="ListValue",e.OBJECT="ObjectValue",e.OBJECT_FIELD="ObjectField",e.DIRECTIVE="Directive",e.NAMED_TYPE="NamedType",e.LIST_TYPE="ListType",e.NON_NULL_TYPE="NonNullType",e.SCHEMA_DEFINITION="SchemaDefinition",e.OPERATION_TYPE_DEFINITION="OperationTypeDefinition",e.SCALAR_TYPE_DEFINITION="ScalarTypeDefinition",e.OBJECT_TYPE_DEFINITION="ObjectTypeDefinition",e.FIELD_DEFINITION="FieldDefinition",e.INPUT_VALUE_DEFINITION="InputValueDefinition",e.INTERFACE_TYPE_DEFINITION="InterfaceTypeDefinition",e.UNION_TYPE_DEFINITION="UnionTypeDefinition",e.ENUM_TYPE_DEFINITION="EnumTypeDefinition",e.ENUM_VALUE_DEFINITION="EnumValueDefinition",e.INPUT_OBJECT_TYPE_DEFINITION="InputObjectTypeDefinition",e.DIRECTIVE_DEFINITION="DirectiveDefinition",e.SCHEMA_EXTENSION="SchemaExtension",e.SCALAR_TYPE_EXTENSION="ScalarTypeExtension",e.OBJECT_TYPE_EXTENSION="ObjectTypeExtension",e.INTERFACE_TYPE_EXTENSION="InterfaceTypeExtension",e.UNION_TYPE_EXTENSION="UnionTypeExtension",e.ENUM_TYPE_EXTENSION="EnumTypeExtension",e.INPUT_OBJECT_TYPE_EXTENSION="InputObjectTypeExtension";})(y||(y={}));function xt(e){return e===9||e===32}function G(e){return e>=48&&e<=57}function _t(e){return e>=97&&e<=122||e>=65&&e<=90}function ke(e){return _t(e)||e===95}function vt(e){return _t(e)||G(e)||e===95}function Ot(e){var t;let r=Number.MAX_SAFE_INTEGER,s=null,n=-1;for(let a=0;a<e.length;++a){var i;let p=e[a],o=ln(p);o!==p.length&&(s=(i=s)!==null&&i!==void 0?i:a,n=a,a!==0&&o<r&&(r=o));}return e.map((a,p)=>p===0?a:a.slice(r)).slice((t=s)!==null&&t!==void 0?t:0,n+1)}function ln(e){let t=0;for(;t<e.length&&xt(e.charCodeAt(t));)++t;return t}var l;(function(e){e.SOF="<SOF>",e.EOF="<EOF>",e.BANG="!",e.DOLLAR="$",e.AMP="&",e.PAREN_L="(",e.PAREN_R=")",e.SPREAD="...",e.COLON=":",e.EQUALS="=",e.AT="@",e.BRACKET_L="[",e.BRACKET_R="]",e.BRACE_L="{",e.PIPE="|",e.BRACE_R="}",e.NAME="Name",e.INT="Int",e.FLOAT="Float",e.STRING="String",e.BLOCK_STRING="BlockString",e.COMMENT="Comment";})(l||(l={}));var re=class{constructor(t){let r=new H(l.SOF,0,0,0,0);this.source=t,this.lastToken=r,this.token=r,this.line=1,this.lineStart=0;}get[Symbol.toStringTag](){return "Lexer"}advance(){return this.lastToken=this.token,this.token=this.lookahead()}lookahead(){let t=this.token;if(t.kind!==l.EOF)do if(t.next)t=t.next;else {let r=pn(this,t.end);t.next=r,r.prev=t,t=r;}while(t.kind===l.COMMENT);return t}};function Nt(e){return e===l.BANG||e===l.DOLLAR||e===l.AMP||e===l.PAREN_L||e===l.PAREN_R||e===l.SPREAD||e===l.COLON||e===l.EQUALS||e===l.AT||e===l.BRACKET_L||e===l.BRACKET_R||e===l.BRACE_L||e===l.PIPE||e===l.BRACE_R}function Y(e){return e>=0&&e<=55295||e>=57344&&e<=1114111}function _e(e,t){return Rt(e.charCodeAt(t))&&wt(e.charCodeAt(t+1))}function Rt(e){return e>=55296&&e<=56319}function wt(e){return e>=56320&&e<=57343}function M(e,t){let r=e.source.body.codePointAt(t);if(r===void 0)return l.EOF;if(r>=32&&r<=126){let s=String.fromCodePoint(r);return s==='"'?`'"'`:`"${s}"`}return "U+"+r.toString(16).toUpperCase().padStart(4,"0")}function O(e,t,r,s,n){let i=e.line,a=1+r-e.lineStart;return new H(t,r,s,i,a,n)}function pn(e,t){let r=e.source.body,s=r.length,n=t;for(;n<s;){let i=r.charCodeAt(n);switch(i){case 65279:case 9:case 32:case 44:++n;continue;case 10:++n,++e.line,e.lineStart=n;continue;case 13:r.charCodeAt(n+1)===10?n+=2:++n,++e.line,e.lineStart=n;continue;case 35:return dn(e,n);case 33:return O(e,l.BANG,n,n+1);case 36:return O(e,l.DOLLAR,n,n+1);case 38:return O(e,l.AMP,n,n+1);case 40:return O(e,l.PAREN_L,n,n+1);case 41:return O(e,l.PAREN_R,n,n+1);case 46:if(r.charCodeAt(n+1)===46&&r.charCodeAt(n+2)===46)return O(e,l.SPREAD,n,n+3);break;case 58:return O(e,l.COLON,n,n+1);case 61:return O(e,l.EQUALS,n,n+1);case 64:return O(e,l.AT,n,n+1);case 91:return O(e,l.BRACKET_L,n,n+1);case 93:return O(e,l.BRACKET_R,n,n+1);case 123:return O(e,l.BRACE_L,n,n+1);case 124:return O(e,l.PIPE,n,n+1);case 125:return O(e,l.BRACE_R,n,n+1);case 34:return r.charCodeAt(n+1)===34&&r.charCodeAt(n+2)===34?Tn(e,n):hn(e,n)}if(G(i)||i===45)return fn(e,n,i);if(ke(i))return gn(e,n);throw v(e.source,n,i===39?`Unexpected single quote character ('), did you mean to use a double quote (")?`:Y(i)||_e(r,n)?`Unexpected character: ${M(e,n)}.`:`Invalid character: ${M(e,n)}.`)}return O(e,l.EOF,s,s)}function dn(e,t){let r=e.source.body,s=r.length,n=t+1;for(;n<s;){let i=r.charCodeAt(n);if(i===10||i===13)break;if(Y(i))++n;else if(_e(r,n))n+=2;else break}return O(e,l.COMMENT,t,n,r.slice(t+1,n))}function fn(e,t,r){let s=e.source.body,n=t,i=r,a=!1;if(i===45&&(i=s.charCodeAt(++n)),i===48){if(i=s.charCodeAt(++n),G(i))throw v(e.source,n,`Invalid number, unexpected digit after 0: ${M(e,n)}.`)}else n=Me(e,n,i),i=s.charCodeAt(n);if(i===46&&(a=!0,i=s.charCodeAt(++n),n=Me(e,n,i),i=s.charCodeAt(n)),(i===69||i===101)&&(a=!0,i=s.charCodeAt(++n),(i===43||i===45)&&(i=s.charCodeAt(++n)),n=Me(e,n,i),i=s.charCodeAt(n)),i===46||ke(i))throw v(e.source,n,`Invalid number, expected digit but got: ${M(e,n)}.`);return O(e,a?l.FLOAT:l.INT,t,n,s.slice(t,n))}function Me(e,t,r){if(!G(r))throw v(e.source,t,`Invalid number, expected digit but got: ${M(e,t)}.`);let s=e.source.body,n=t+1;for(;G(s.charCodeAt(n));)++n;return n}function hn(e,t){let r=e.source.body,s=r.length,n=t+1,i=n,a="";for(;n<s;){let p=r.charCodeAt(n);if(p===34)return a+=r.slice(i,n),O(e,l.STRING,t,n+1,a);if(p===92){a+=r.slice(i,n);let o=r.charCodeAt(n+1)===117?r.charCodeAt(n+2)===123?mn(e,n):yn(e,n):En(e,n);a+=o.value,n+=o.size,i=n;continue}if(p===10||p===13)break;if(Y(p))++n;else if(_e(r,n))n+=2;else throw v(e.source,n,`Invalid character within String: ${M(e,n)}.`)}throw v(e.source,n,"Unterminated string.")}function mn(e,t){let r=e.source.body,s=0,n=3;for(;n<12;){let i=r.charCodeAt(t+n++);if(i===125){if(n<5||!Y(s))break;return {value:String.fromCodePoint(s),size:n}}if(s=s<<4|te(i),s<0)break}throw v(e.source,t,`Invalid Unicode escape sequence: "${r.slice(t,t+n)}".`)}function yn(e,t){let r=e.source.body,s=St(r,t+2);if(Y(s))return {value:String.fromCodePoint(s),size:6};if(Rt(s)&&r.charCodeAt(t+6)===92&&r.charCodeAt(t+7)===117){let n=St(r,t+8);if(wt(n))return {value:String.fromCodePoint(s,n),size:12}}throw v(e.source,t,`Invalid Unicode escape sequence: "${r.slice(t,t+6)}".`)}function St(e,t){return te(e.charCodeAt(t))<<12|te(e.charCodeAt(t+1))<<8|te(e.charCodeAt(t+2))<<4|te(e.charCodeAt(t+3))}function te(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1}function En(e,t){let r=e.source.body;switch(r.charCodeAt(t+1)){case 34:return {value:'"',size:2};case 92:return {value:"\\",size:2};case 47:return {value:"/",size:2};case 98:return {value:"\b",size:2};case 102:return {value:"\f",size:2};case 110:return {value:`
`,size:2};case 114:return {value:"\r",size:2};case 116:return {value:" ",size:2}}throw v(e.source,t,`Invalid character escape sequence: "${r.slice(t,t+2)}".`)}function Tn(e,t){let r=e.source.body,s=r.length,n=e.lineStart,i=t+3,a=i,p="",o=[];for(;i<s;){let c=r.charCodeAt(i);if(c===34&&r.charCodeAt(i+1)===34&&r.charCodeAt(i+2)===34){p+=r.slice(a,i),o.push(p);let u=O(e,l.BLOCK_STRING,t,i+3,Ot(o).join(`
`));return e.line+=o.length-1,e.lineStart=n,u}if(c===92&&r.charCodeAt(i+1)===34&&r.charCodeAt(i+2)===34&&r.charCodeAt(i+3)===34){p+=r.slice(a,i),a=i+1,i+=4;continue}if(c===10||c===13){p+=r.slice(a,i),o.push(p),c===13&&r.charCodeAt(i+1)===10?i+=2:++i,p="",a=i,n=i;continue}if(Y(c))++i;else if(_e(r,i))i+=2;else throw v(e.source,i,`Invalid character within String: ${M(e,i)}.`)}throw v(e.source,i,"Unterminated string.")}function gn(e,t){let r=e.source.body,s=r.length,n=t+1;for(;n<s;){let i=r.charCodeAt(n);if(vt(i))++n;else break}return O(e,l.NAME,t,n,r.slice(t,n))}function ve(e){return Oe(e,[])}function Oe(e,t){switch(typeof e){case"string":return JSON.stringify(e);case"function":return e.name?`[function ${e.name}]`:"[function]";case"object":return xn(e,t);default:return String(e)}}function xn(e,t){if(e===null)return "null";if(t.includes(e))return "[Circular]";let r=[...t,e];if(_n(e)){let s=e.toJSON();if(s!==e)return typeof s=="string"?s:Oe(s,r)}else if(Array.isArray(e))return On(e,r);return vn(e,r)}function _n(e){return typeof e.toJSON=="function"}function vn(e,t){let r=Object.entries(e);return r.length===0?"{}":t.length>2?"["+Sn(e)+"]":"{ "+r.map(([n,i])=>n+": "+Oe(i,t)).join(", ")+" }"}function On(e,t){if(e.length===0)return "[]";if(t.length>2)return "[Array]";let r=Math.min(10,e.length),s=e.length-r,n=[];for(let i=0;i<r;++i)n.push(Oe(e[i],t));return s===1?n.push("... 1 more item"):s>1&&n.push(`... ${s} more items`),"["+n.join(", ")+"]"}function Sn(e){let t=Object.prototype.toString.call(e).replace(/^\[object /,"").replace(/]$/,"");if(t==="Object"&&typeof e.constructor=="function"){let r=e.constructor.name;if(typeof r=="string"&&r!=="")return r}return t}var It=globalThis.process&&globalThis.process.env.NODE_ENV==="production"?function(t,r){return t instanceof r}:function(t,r){if(t instanceof r)return !0;if(typeof t=="object"&&t!==null){var s;let n=r.prototype[Symbol.toStringTag],i=Symbol.toStringTag in t?t[Symbol.toStringTag]:(s=t.constructor)===null||s===void 0?void 0:s.name;if(n===i){let a=ve(t);throw new Error(`Cannot use ${n} "${a}" from another module or realm.
Ensure that there is only one instance of "graphql" in the node_modules
directory. If different versions of "graphql" are the dependencies of other
relied on modules, use "resolutions" to ensure only one version is installed.
https://yarnpkg.com/en/docs/selective-version-resolutions
Duplicate "graphql" modules cannot be used at the same time since different
versions may have different capabilities and behavior. The data from one
version used in the function from another could produce confusing and
spurious results.`)}}return !1};var W=class{constructor(t,r="GraphQL request",s={line:1,column:1}){typeof t=="string"||Te(!1,`Body must be a string. Received: ${ve(t)}.`),this.body=t,this.name=r,this.locationOffset=s,this.locationOffset.line>0||Te(!1,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||Te(!1,"column in locationOffset is 1-indexed and must be positive.");}get[Symbol.toStringTag](){return "Source"}};function At(e){return It(e,W)}function Ne(e,t){return new Fe(e,t).parseDocument()}var Fe=class{constructor(t,r={}){let s=At(t)?t:new W(t);this._lexer=new re(s),this._options=r,this._tokenCounter=0;}parseName(){let t=this.expectToken(l.NAME);return this.node(t,{kind:y.NAME,value:t.value})}parseDocument(){return this.node(this._lexer.token,{kind:y.DOCUMENT,definitions:this.many(l.SOF,this.parseDefinition,l.EOF)})}parseDefinition(){if(this.peek(l.BRACE_L))return this.parseOperationDefinition();let t=this.peekDescription(),r=t?this._lexer.lookahead():this._lexer.token;if(r.kind===l.NAME){switch(r.value){case"schema":return this.parseSchemaDefinition();case"scalar":return this.parseScalarTypeDefinition();case"type":return this.parseObjectTypeDefinition();case"interface":return this.parseInterfaceTypeDefinition();case"union":return this.parseUnionTypeDefinition();case"enum":return this.parseEnumTypeDefinition();case"input":return this.parseInputObjectTypeDefinition();case"directive":return this.parseDirectiveDefinition()}if(t)throw v(this._lexer.source,this._lexer.token.start,"Unexpected description, descriptions are supported only on type definitions.");switch(r.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition();case"extend":return this.parseTypeSystemExtension()}}throw this.unexpected(r)}parseOperationDefinition(){let t=this._lexer.token;if(this.peek(l.BRACE_L))return this.node(t,{kind:y.OPERATION_DEFINITION,operation:C.QUERY,name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet()});let r=this.parseOperationType(),s;return this.peek(l.NAME)&&(s=this.parseName()),this.node(t,{kind:y.OPERATION_DEFINITION,operation:r,name:s,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseOperationType(){let t=this.expectToken(l.NAME);switch(t.value){case"query":return C.QUERY;case"mutation":return C.MUTATION;case"subscription":return C.SUBSCRIPTION}throw this.unexpected(t)}parseVariableDefinitions(){return this.optionalMany(l.PAREN_L,this.parseVariableDefinition,l.PAREN_R)}parseVariableDefinition(){return this.node(this._lexer.token,{kind:y.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(l.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(l.EQUALS)?this.parseConstValueLiteral():void 0,directives:this.parseConstDirectives()})}parseVariable(){let t=this._lexer.token;return this.expectToken(l.DOLLAR),this.node(t,{kind:y.VARIABLE,name:this.parseName()})}parseSelectionSet(){return this.node(this._lexer.token,{kind:y.SELECTION_SET,selections:this.many(l.BRACE_L,this.parseSelection,l.BRACE_R)})}parseSelection(){return this.peek(l.SPREAD)?this.parseFragment():this.parseField()}parseField(){let t=this._lexer.token,r=this.parseName(),s,n;return this.expectOptionalToken(l.COLON)?(s=r,n=this.parseName()):n=r,this.node(t,{kind:y.FIELD,alias:s,name:n,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(l.BRACE_L)?this.parseSelectionSet():void 0})}parseArguments(t){let r=t?this.parseConstArgument:this.parseArgument;return this.optionalMany(l.PAREN_L,r,l.PAREN_R)}parseArgument(t=!1){let r=this._lexer.token,s=this.parseName();return this.expectToken(l.COLON),this.node(r,{kind:y.ARGUMENT,name:s,value:this.parseValueLiteral(t)})}parseConstArgument(){return this.parseArgument(!0)}parseFragment(){let t=this._lexer.token;this.expectToken(l.SPREAD);let r=this.expectOptionalKeyword("on");return !r&&this.peek(l.NAME)?this.node(t,{kind:y.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1)}):this.node(t,{kind:y.INLINE_FRAGMENT,typeCondition:r?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentDefinition(){let t=this._lexer.token;return this.expectKeyword("fragment"),this._options.allowLegacyFragmentVariables===!0?this.node(t,{kind:y.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()}):this.node(t,{kind:y.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentName(){if(this._lexer.token.value==="on")throw this.unexpected();return this.parseName()}parseValueLiteral(t){let r=this._lexer.token;switch(r.kind){case l.BRACKET_L:return this.parseList(t);case l.BRACE_L:return this.parseObject(t);case l.INT:return this.advanceLexer(),this.node(r,{kind:y.INT,value:r.value});case l.FLOAT:return this.advanceLexer(),this.node(r,{kind:y.FLOAT,value:r.value});case l.STRING:case l.BLOCK_STRING:return this.parseStringLiteral();case l.NAME:switch(this.advanceLexer(),r.value){case"true":return this.node(r,{kind:y.BOOLEAN,value:!0});case"false":return this.node(r,{kind:y.BOOLEAN,value:!1});case"null":return this.node(r,{kind:y.NULL});default:return this.node(r,{kind:y.ENUM,value:r.value})}case l.DOLLAR:if(t)if(this.expectToken(l.DOLLAR),this._lexer.token.kind===l.NAME){let s=this._lexer.token.value;throw v(this._lexer.source,r.start,`Unexpected variable "$${s}" in constant value.`)}else throw this.unexpected(r);return this.parseVariable();default:throw this.unexpected()}}parseConstValueLiteral(){return this.parseValueLiteral(!0)}parseStringLiteral(){let t=this._lexer.token;return this.advanceLexer(),this.node(t,{kind:y.STRING,value:t.value,block:t.kind===l.BLOCK_STRING})}parseList(t){let r=()=>this.parseValueLiteral(t);return this.node(this._lexer.token,{kind:y.LIST,values:this.any(l.BRACKET_L,r,l.BRACKET_R)})}parseObject(t){let r=()=>this.parseObjectField(t);return this.node(this._lexer.token,{kind:y.OBJECT,fields:this.any(l.BRACE_L,r,l.BRACE_R)})}parseObjectField(t){let r=this._lexer.token,s=this.parseName();return this.expectToken(l.COLON),this.node(r,{kind:y.OBJECT_FIELD,name:s,value:this.parseValueLiteral(t)})}parseDirectives(t){let r=[];for(;this.peek(l.AT);)r.push(this.parseDirective(t));return r}parseConstDirectives(){return this.parseDirectives(!0)}parseDirective(t){let r=this._lexer.token;return this.expectToken(l.AT),this.node(r,{kind:y.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(t)})}parseTypeReference(){let t=this._lexer.token,r;if(this.expectOptionalToken(l.BRACKET_L)){let s=this.parseTypeReference();this.expectToken(l.BRACKET_R),r=this.node(t,{kind:y.LIST_TYPE,type:s});}else r=this.parseNamedType();return this.expectOptionalToken(l.BANG)?this.node(t,{kind:y.NON_NULL_TYPE,type:r}):r}parseNamedType(){return this.node(this._lexer.token,{kind:y.NAMED_TYPE,name:this.parseName()})}peekDescription(){return this.peek(l.STRING)||this.peek(l.BLOCK_STRING)}parseDescription(){if(this.peekDescription())return this.parseStringLiteral()}parseSchemaDefinition(){let t=this._lexer.token,r=this.parseDescription();this.expectKeyword("schema");let s=this.parseConstDirectives(),n=this.many(l.BRACE_L,this.parseOperationTypeDefinition,l.BRACE_R);return this.node(t,{kind:y.SCHEMA_DEFINITION,description:r,directives:s,operationTypes:n})}parseOperationTypeDefinition(){let t=this._lexer.token,r=this.parseOperationType();this.expectToken(l.COLON);let s=this.parseNamedType();return this.node(t,{kind:y.OPERATION_TYPE_DEFINITION,operation:r,type:s})}parseScalarTypeDefinition(){let t=this._lexer.token,r=this.parseDescription();this.expectKeyword("scalar");let s=this.parseName(),n=this.parseConstDirectives();return this.node(t,{kind:y.SCALAR_TYPE_DEFINITION,description:r,name:s,directives:n})}parseObjectTypeDefinition(){let t=this._lexer.token,r=this.parseDescription();this.expectKeyword("type");let s=this.parseName(),n=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),a=this.parseFieldsDefinition();return this.node(t,{kind:y.OBJECT_TYPE_DEFINITION,description:r,name:s,interfaces:n,directives:i,fields:a})}parseImplementsInterfaces(){return this.expectOptionalKeyword("implements")?this.delimitedMany(l.AMP,this.parseNamedType):[]}parseFieldsDefinition(){return this.optionalMany(l.BRACE_L,this.parseFieldDefinition,l.BRACE_R)}parseFieldDefinition(){let t=this._lexer.token,r=this.parseDescription(),s=this.parseName(),n=this.parseArgumentDefs();this.expectToken(l.COLON);let i=this.parseTypeReference(),a=this.parseConstDirectives();return this.node(t,{kind:y.FIELD_DEFINITION,description:r,name:s,arguments:n,type:i,directives:a})}parseArgumentDefs(){return this.optionalMany(l.PAREN_L,this.parseInputValueDef,l.PAREN_R)}parseInputValueDef(){let t=this._lexer.token,r=this.parseDescription(),s=this.parseName();this.expectToken(l.COLON);let n=this.parseTypeReference(),i;this.expectOptionalToken(l.EQUALS)&&(i=this.parseConstValueLiteral());let a=this.parseConstDirectives();return this.node(t,{kind:y.INPUT_VALUE_DEFINITION,description:r,name:s,type:n,defaultValue:i,directives:a})}parseInterfaceTypeDefinition(){let t=this._lexer.token,r=this.parseDescription();this.expectKeyword("interface");let s=this.parseName(),n=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),a=this.parseFieldsDefinition();return this.node(t,{kind:y.INTERFACE_TYPE_DEFINITION,description:r,name:s,interfaces:n,directives:i,fields:a})}parseUnionTypeDefinition(){let t=this._lexer.token,r=this.parseDescription();this.expectKeyword("union");let s=this.parseName(),n=this.parseConstDirectives(),i=this.parseUnionMemberTypes();return this.node(t,{kind:y.UNION_TYPE_DEFINITION,description:r,name:s,directives:n,types:i})}parseUnionMemberTypes(){return this.expectOptionalToken(l.EQUALS)?this.delimitedMany(l.PIPE,this.parseNamedType):[]}parseEnumTypeDefinition(){let t=this._lexer.token,r=this.parseDescription();this.expectKeyword("enum");let s=this.parseName(),n=this.parseConstDirectives(),i=this.parseEnumValuesDefinition();return this.node(t,{kind:y.ENUM_TYPE_DEFINITION,description:r,name:s,directives:n,values:i})}parseEnumValuesDefinition(){return this.optionalMany(l.BRACE_L,this.parseEnumValueDefinition,l.BRACE_R)}parseEnumValueDefinition(){let t=this._lexer.token,r=this.parseDescription(),s=this.parseEnumValueName(),n=this.parseConstDirectives();return this.node(t,{kind:y.ENUM_VALUE_DEFINITION,description:r,name:s,directives:n})}parseEnumValueName(){if(this._lexer.token.value==="true"||this._lexer.toke