{"version":3,"sources":["../../../../src/core/utils/HttpResponse/decorators.ts"],"sourcesContent":["import statuses from '../../../shims/statuses'\nimport type { HttpResponseInit } from '../../HttpResponse'\n\nconst { message } = statuses\n\nconst kSetCookie = Symbol('kSetCookie')\n\nexport interface HttpResponseDecoratedInit extends HttpResponseInit {\n  status: number\n  statusText: string\n  headers: Headers\n}\n\nexport function normalizeResponseInit(\n  init: HttpResponseInit = {},\n): HttpResponseDecoratedInit {\n  const status = init?.status || 200\n  const statusText = init?.statusText || message[status] || ''\n  const headers = new Headers(init?.headers)\n\n  return {\n    ...init,\n    headers,\n    status,\n    statusText,\n  }\n}\n\nexport function decorateResponse(\n  response: Response,\n  init: HttpResponseDecoratedInit,\n): Response {\n  // Allow mocking the response type.\n  if (init.type) {\n    Object.defineProperty(response, 'type', {\n      value: init.type,\n      enumerable: true,\n      writable: false,\n    })\n  }\n\n  const responseCookies = init.headers.get('set-cookie')\n\n  if (responseCookies) {\n    // Record the raw \"Set-Cookie\" response header provided\n    // in the HeadersInit. This is later used to store these cookies\n    // in cookie jar and return the right cookies in the \"cookies\"\n    // response resolver argument.\n    Object.defineProperty(response, kSetCookie, {\n      value: responseCookies,\n      enumerable: false,\n      writable: false,\n    })\n  }\n\n  return response\n}\n\nexport function getRawSetCookie(response: Response): string | undefined {\n  return Reflect.get(response, kSetCookie)\n}\n"],"mappings":"AAAA,OAAO,cAAc;AAGrB,MAAM,EAAE,QAAQ,IAAI;AAEpB,MAAM,aAAa,OAAO,YAAY;AAQ/B,SAAS,sBACd,OAAyB,CAAC,GACC;AAC3B,QAAM,SAAS,MAAM,UAAU;AAC/B,QAAM,aAAa,MAAM,cAAc,QAAQ,MAAM,KAAK;AAC1D,QAAM,UAAU,IAAI,QAAQ,MAAM,OAAO;AAEzC,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,iBACd,UACA,MACU;AAEV,MAAI,KAAK,MAAM;AACb,WAAO,eAAe,UAAU,QAAQ;AAAA,MACtC,OAAO,KAAK;AAAA,MACZ,YAAY;AAAA,MACZ,UAAU;AAAA,IACZ,CAAC;AAAA,EACH;AAEA,QAAM,kBAAkB,KAAK,QAAQ,IAAI,YAAY;AAErD,MAAI,iBAAiB;AAKnB,WAAO,eAAe,UAAU,YAAY;AAAA,MAC1C,OAAO;AAAA,MACP,YAAY;AAAA,MACZ,UAAU;AAAA,IACZ,CAAC;AAAA,EACH;AAEA,SAAO;AACT;AAEO,SAAS,gBAAgB,UAAwC;AACtE,SAAO,QAAQ,IAAI,UAAU,UAAU;AACzC;","names":[]}