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K,GAEtB,OADgB,IAAI,aAAa,MAAO,EAAK,GAC9B,SACjB,CAEA,eAAe,MAAM,EAAK,GAExB,OADgB,IAAI,aAAa,QAAS,EAAK,GAChC,SACjB,CAEA,eAAe,QAAQ,EAAK,GAE1B,OADgB,IAAI,aAAa,SAAU,EAAK,GACjC,SACjB,QAES,aAAc,cAAe,mBAAoB,QAAS,IAAK,MAAO,KAAM","file":"/npm/@rails/request.js@0.0.13/dist/requestjs.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@rails/request.js@0.0.13/dist/requestjs.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","class FetchResponse {\n  constructor(response) {\n    this.response = response;\n  }\n  get statusCode() {\n    return this.response.status;\n  }\n  get redirected() {\n    return this.response.redirected;\n  }\n  get ok() {\n    return this.response.ok;\n  }\n  get unauthenticated() {\n    return this.statusCode === 401;\n  }\n  get unprocessableEntity() {\n    return this.statusCode === 422;\n  }\n  get authenticationURL() {\n    return this.response.headers.get(\"WWW-Authenticate\");\n  }\n  get contentType() {\n    const contentType = this.response.headers.get(\"Content-Type\") || \"\";\n    return contentType.replace(/;.*$/, \"\");\n  }\n  get headers() {\n    return this.response.headers;\n  }\n  get html() {\n    if (this.contentType.match(/^(application|text)\\/(html|xhtml\\+xml)$/)) {\n      return this.text;\n    }\n    return Promise.reject(new Error(`Expected an HTML response but got \"${this.contentType}\" instead`));\n  }\n  get json() {\n    if (this.contentType.match(/^application\\/.*json$/)) {\n      return this.responseJson || (this.responseJson = this.response.json());\n    }\n    return Promise.reject(new Error(`Expected a JSON response but got \"${this.contentType}\" instead`));\n  }\n  get text() {\n    return this.responseText || (this.responseText = this.response.text());\n  }\n  get isTurboStream() {\n    return this.contentType.match(/^text\\/vnd\\.turbo-stream\\.html/);\n  }\n  get isScript() {\n    return this.contentType.match(/\\b(?:java|ecma)script\\b/);\n  }\n  async renderTurboStream() {\n    if (this.isTurboStream) {\n      if (window.Turbo) {\n        await window.Turbo.renderStreamMessage(await this.text);\n      } else {\n        console.warn(\"You must set `window.Turbo = Turbo` to automatically process Turbo Stream events with request.js\");\n      }\n    } else {\n      return Promise.reject(new Error(`Expected a Turbo Stream response but got \"${this.contentType}\" instead`));\n    }\n  }\n  async activeScript() {\n    if (this.isScript) {\n      const script = document.createElement(\"script\");\n      const metaTag = document.querySelector(\"meta[name=csp-nonce]\");\n      if (metaTag) {\n        const nonce = metaTag.nonce === \"\" ? metaTag.content : metaTag.nonce;\n        if (nonce) {\n          script.setAttribute(\"nonce\", nonce);\n        }\n      }\n      script.innerHTML = await this.text;\n      document.body.appendChild(script);\n    } else {\n      return Promise.reject(new Error(`Expected a Script response but got \"${this.contentType}\" instead`));\n    }\n  }\n}\n\nclass RequestInterceptor {\n  static register(interceptor) {\n    this.interceptor = interceptor;\n  }\n  static get() {\n    return this.interceptor;\n  }\n  static reset() {\n    this.interceptor = undefined;\n  }\n}\n\nfunction getCookie(name) {\n  const cookies = document.cookie ? document.cookie.split(\"; \") : [];\n  const prefix = `${encodeURIComponent(name)}=`;\n  const cookie = cookies.find(cookie => cookie.startsWith(prefix));\n  if (cookie) {\n    const value = cookie.split(\"=\").slice(1).join(\"=\");\n    if (value) {\n      return decodeURIComponent(value);\n    }\n  }\n}\n\nfunction compact(object) {\n  const result = {};\n  for (const key in object) {\n    const value = object[key];\n    if (value !== undefined) {\n      result[key] = value;\n    }\n  }\n  return result;\n}\n\nfunction metaContent(name) {\n  const element = document.head.querySelector(`meta[name=\"${name}\"]`);\n  return element && element.content;\n}\n\nfunction stringEntriesFromFormData(formData) {\n  return [ ...formData ].reduce((entries, [name, value]) => entries.concat(typeof value === \"string\" ? [ [ name, value ] ] : []), []);\n}\n\nfunction mergeEntries(searchParams, entries) {\n  for (const [name, value] of entries) {\n    if (value instanceof window.File) continue;\n    if (searchParams.has(name) && !name.includes(\"[]\")) {\n      searchParams.delete(name);\n      searchParams.set(name, value);\n    } else {\n      searchParams.append(name, value);\n    }\n  }\n}\n\nclass FetchRequest {\n  constructor(method, url, options = {}) {\n    this.method = method;\n    this.options = options;\n    this.originalUrl = url.toString();\n  }\n  async perform() {\n    try {\n      const requestInterceptor = RequestInterceptor.get();\n      if (requestInterceptor) {\n        await requestInterceptor(this);\n      }\n    } catch (error) {\n      console.error(error);\n    }\n    const fetch = window.Turbo ? window.Turbo.fetch : window.fetch;\n    const response = new FetchResponse(await fetch(this.url, this.fetchOptions));\n    if (response.unauthenticated && response.authenticationURL) {\n      return Promise.reject(window.location.href = response.authenticationURL);\n    }\n    if (response.isScript) {\n      await response.activeScript();\n    }\n    const responseStatusIsTurboStreamable = response.ok || response.unprocessableEntity;\n    if (responseStatusIsTurboStreamable && response.isTurboStream) {\n      await response.renderTurboStream();\n    }\n    return response;\n  }\n  addHeader(key, value) {\n    const headers = this.additionalHeaders;\n    headers[key] = value;\n    this.options.headers = headers;\n  }\n  sameHostname() {\n    if (!this.originalUrl.startsWith(\"http:\") && !this.originalUrl.startsWith(\"https:\")) {\n      return true;\n    }\n    try {\n      return new URL(this.originalUrl).hostname === window.location.hostname;\n    } catch (_) {\n      return true;\n    }\n  }\n  get fetchOptions() {\n    return {\n      method: this.method.toUpperCase(),\n      headers: this.headers,\n      body: this.formattedBody,\n      signal: this.signal,\n      credentials: this.credentials,\n      redirect: this.redirect,\n      keepalive: this.keepalive\n    };\n  }\n  get headers() {\n    const baseHeaders = {\n      \"X-Requested-With\": \"XMLHttpRequest\",\n      \"Content-Type\": this.contentType,\n      Accept: this.accept\n    };\n    if (this.sameHostname()) {\n      baseHeaders[\"X-CSRF-Token\"] = this.csrfToken;\n    }\n    return compact(Object.assign(baseHeaders, this.additionalHeaders));\n  }\n  get csrfToken() {\n    return getCookie(metaContent(\"csrf-param\")) || metaContent(\"csrf-token\");\n  }\n  get contentType() {\n    if (this.options.contentType) {\n      return this.options.contentType;\n    } else if (this.body == null || this.body instanceof window.FormData) {\n      return undefined;\n    } else if (this.body instanceof window.File) {\n      return this.body.type;\n    }\n    return \"application/json\";\n  }\n  get accept() {\n    switch (this.responseKind) {\n     case \"html\":\n      return \"text/html, application/xhtml+xml\";\n\n     case \"turbo-stream\":\n      return \"text/vnd.turbo-stream.html, text/html, application/xhtml+xml\";\n\n     case \"json\":\n      return \"application/json, application/vnd.api+json\";\n\n     case \"script\":\n      return \"text/javascript, application/javascript\";\n\n     default:\n      return \"*/*\";\n    }\n  }\n  get body() {\n    return this.options.body;\n  }\n  get query() {\n    const originalQuery = (this.originalUrl.split(\"?\")[1] || \"\").split(\"#\")[0];\n    const params = new URLSearchParams(originalQuery);\n    let requestQuery = this.options.query;\n    if (requestQuery instanceof window.FormData) {\n      requestQuery = stringEntriesFromFormData(requestQuery);\n    } else if (requestQuery instanceof window.URLSearchParams) {\n      requestQuery = requestQuery.entries();\n    } else {\n      requestQuery = Object.entries(requestQuery || {});\n    }\n    mergeEntries(params, requestQuery);\n    const query = params.toString();\n    return query.length > 0 ? `?${query}` : \"\";\n  }\n  get url() {\n    return this.originalUrl.split(\"?\")[0].split(\"#\")[0] + this.query;\n  }\n  get responseKind() {\n    return this.options.responseKind || \"html\";\n  }\n  get signal() {\n    return this.options.signal;\n  }\n  get redirect() {\n    return this.options.redirect || \"follow\";\n  }\n  get credentials() {\n    return this.options.credentials || \"same-origin\";\n  }\n  get keepalive() {\n    return this.options.keepalive || false;\n  }\n  get additionalHeaders() {\n    return this.options.headers || {};\n  }\n  get formattedBody() {\n    const bodyIsAString = Object.prototype.toString.call(this.body) === \"[object String]\";\n    const contentTypeIsJson = this.headers[\"Content-Type\"] === \"application/json\";\n    if (contentTypeIsJson && !bodyIsAString) {\n      return JSON.stringify(this.body);\n    }\n    return this.body;\n  }\n}\n\nasync function get(url, options) {\n  const request = new FetchRequest(\"get\", url, options);\n  return request.perform();\n}\n\nasync function post(url, options) {\n  const request = new FetchRequest(\"post\", url, options);\n  return request.perform();\n}\n\nasync function put(url, options) {\n  const request = new FetchRequest(\"put\", url, options);\n  return request.perform();\n}\n\nasync function patch(url, options) {\n  const request = new FetchRequest(\"patch\", url, options);\n  return request.perform();\n}\n\nasync function destroy(url, options) {\n  const request = new FetchRequest(\"delete\", url, options);\n  return request.perform();\n}\n\nexport { FetchRequest, FetchResponse, RequestInterceptor, destroy, get, patch, post, put };\n"]}