@serverless-stack/nextjs-lambda
Version:
Provides handlers that can be used in CloudFront Lambda@Edge to deploy next.js applications to the edge
2 lines (1 loc) • 27.3 kB
JavaScript
Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./manifest.json"),t=require("./routes-manifest.json"),r=require("stream"),n=require("zlib"),o=require("http");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=i(e),a=i(t),c=i(r),u=i(n),f=i(o);const l={"accept-encoding":!0,"content-length":!0,"if-modified-since":!0,"if-none-match":!0,"if-range":!0,"if-unmodified-since":!0,"transfer-encoding":!0,via:!0},d={202:"Accepted",502:"Bad Gateway",400:"Bad Request",409:"Conflict",100:"Continue",201:"Created",417:"Expectation Failed",424:"Failed Dependency",403:"Forbidden",504:"Gateway Timeout",410:"Gone",505:"HTTP Version Not Supported",418:"I'm a teapot",419:"Insufficient Space on Resource",507:"Insufficient Storage",500:"Server Error",411:"Length Required",423:"Locked",420:"Method Failure",405:"Method Not Allowed",301:"Moved Permanently",302:"Moved Temporarily",207:"Multi-Status",300:"Multiple Choices",511:"Network Authentication Required",204:"No Content",203:"Non Authoritative Information",406:"Not Acceptable",404:"Not Found",501:"Not Implemented",304:"Not Modified",200:"OK",206:"Partial Content",402:"Payment Required",308:"Permanent Redirect",412:"Precondition Failed",428:"Precondition Required",102:"Processing",407:"Proxy Authentication Required",431:"Request Header Fields Too Large",408:"Request Timeout",413:"Request Entity Too Large",414:"Request-URI Too Long",416:"Requested Range Not Satisfiable",205:"Reset Content",303:"See Other",503:"Service Unavailable",101:"Switching Protocols",307:"Temporary Redirect",429:"Too Many Requests",401:"Unauthorized",422:"Unprocessable Entity",415:"Unsupported Media Type",305:"Use Proxy"},p={enableHTTPCompression:!1},h=(e,{enableHTTPCompression:t,rewrittenUri:r}=p)=>{const{request:n,response:o={headers:{}}}=e,i={headers:{}},s=new c.default.Readable,a=Object.assign(s,f.default.IncomingMessage.prototype);a.url=r||n.uri,a.method=n.method,a.rawHeaders=[],a.headers={},a.connection={},n.querystring&&(a.url=a.url+"?"+n.querystring);const h=n.headers||{};for(const e of Object.keys(h)){const t=h[e];t.forEach((e=>{a.rawHeaders.push(e.key),a.rawHeaders.push(e.value)})),a.headers[e]=t[0].value}a.getHeader=e=>a.headers[e.toLowerCase()],a.getHeaders=()=>a.headers,n.body&&n.body.data&&a.push(n.body.data,n.body.encoding?"base64":void 0),a.push(null);const E=new c.default;E.finished=!1,Object.defineProperty(E,"statusCode",{get:()=>i.status,set(e){i.status=e,i.statusDescription=d[e]}}),E.headers={};const _={};E.writeHead=(e,t)=>(i.status=e,i.statusDescription=d[e],t&&(E.headers=Object.assign(E.headers,t)),E),E.write=e=>{i.body||(i.body=Buffer.from("")),i.body=Buffer.concat([i.body,Buffer.isBuffer(e)?e:Buffer.from(e)])};let m=t&&(e=>{let t=!1;const r=e["accept-encoding"];if(r)for(let e=0;e<r.length;e++){const{value:n}=r[e];-1!==n.split(",").map((e=>e.split(";")[0].trim())).indexOf("gzip")&&(t=!0)}return t})(h);const T=new Promise((e=>{E.end=t=>{!0!==E.finished&&(E.finished=!0,t&&E.write(t),E.statusCode||(E.statusCode=200),i.body&&(i.bodyEncoding="base64",i.body=m?u.default.gzipSync(i.body).toString("base64"):Buffer.from(i.body).toString("base64")),i.headers=((e,t,r)=>{const n={};return Object.entries(r).forEach((([e,t])=>{n[e.toLowerCase()]=t})),Object.entries(e).forEach((([e,r])=>{const o=e.toLowerCase();e=t[o]||e,l[o]||(n[o]=[],r instanceof Array?r.forEach((t=>{n[o].push({key:e,value:t.toString()})})):n[o].push({key:e,value:r.toString()}))})),n})(E.headers,_,o.headers),m&&(i.headers["content-encoding"]=[{key:"Content-Encoding",value:"gzip"}]),e(i))}}));return E.setHeader=(e,t)=>{E.headers[e.toLowerCase()]=t,_[e.toLowerCase()]=e},E.removeHeader=e=>{delete E.headers[e.toLowerCase()]},E.getHeader=e=>E.headers[e.toLowerCase()],E.getHeaders=()=>E.headers,E.hasHeader=e=>!!E.getHeader(e),{req:a,res:E,responsePromise:T}};h.SPECIAL_NODE_HEADERS=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];var E=h;const _=["connection","expect","keep-alive","proxy-authenticate","proxy-authorization","proxy-connection","trailer","upgrade","x-accel-buffering","x-accel-charset","x-accel-limit-rate","x-accel-redirect","x-cache","x-forwarded-proto","x-real-ip","content-length","host","transfer-encoding","via"],m=["x-amz-cf-","x-amzn-","x-edge-"];function T(e){const t=e.toLowerCase();for(const e of m)if(t.startsWith(e))return!0;return _.includes(t)}function y(e,t){void 0===t&&(t={});for(var r=function(e){for(var t=[],r=0;r<e.length;){var n=e[r];if("*"!==n&&"+"!==n&&"?"!==n)if("\\"!==n)if("{"!==n)if("}"!==n)if(":"!==n)if("("!==n)t.push({type:"CHAR",index:r,value:e[r++]});else{var o=1,i="";if("?"===e[a=r+1])throw new TypeError('Pattern cannot start with "?" at '+a);for(;a<e.length;)if("\\"!==e[a]){if(")"===e[a]){if(0==--o){a++;break}}else if("("===e[a]&&(o++,"?"!==e[a+1]))throw new TypeError("Capturing groups are not allowed at "+a);i+=e[a++]}else i+=e[a++]+e[a++];if(o)throw new TypeError("Unbalanced pattern at "+r);if(!i)throw new TypeError("Missing pattern at "+r);t.push({type:"PATTERN",index:r,value:i}),r=a}else{for(var s="",a=r+1;a<e.length;){var c=e.charCodeAt(a);if(!(c>=48&&c<=57||c>=65&&c<=90||c>=97&&c<=122||95===c))break;s+=e[a++]}if(!s)throw new TypeError("Missing parameter name at "+r);t.push({type:"NAME",index:r,value:s}),r=a}else t.push({type:"CLOSE",index:r,value:e[r++]});else t.push({type:"OPEN",index:r,value:e[r++]});else t.push({type:"ESCAPED_CHAR",index:r++,value:e[r++]});else t.push({type:"MODIFIER",index:r,value:e[r++]})}return t.push({type:"END",index:r,value:""}),t}(e),n=t.prefixes,o=void 0===n?"./":n,i="[^"+v(t.delimiter||"/#?")+"]+?",s=[],a=0,c=0,u="",f=function(e){if(c<r.length&&r[c].type===e)return r[c++].value},l=function(e){var t=f(e);if(void 0!==t)return t;var n=r[c],o=n.type,i=n.index;throw new TypeError("Unexpected "+o+" at "+i+", expected "+e)},d=function(){for(var e,t="";e=f("CHAR")||f("ESCAPED_CHAR");)t+=e;return t};c<r.length;){var p=f("CHAR"),h=f("NAME"),E=f("PATTERN");if(h||E){var _=p||"";-1===o.indexOf(_)&&(u+=_,_=""),u&&(s.push(u),u=""),s.push({name:h||a++,prefix:_,suffix:"",pattern:E||i,modifier:f("MODIFIER")||""})}else{var m=p||f("ESCAPED_CHAR");if(m)u+=m;else if(u&&(s.push(u),u=""),f("OPEN")){_=d();var T=f("NAME")||"",y=f("PATTERN")||"",b=d();l("CLOSE"),s.push({name:T||(y?a++:""),pattern:T&&!y?i:y,prefix:_,suffix:b,modifier:f("MODIFIER")||""})}else l("END")}}return s}function b(e,t){return function(e,t){void 0===t&&(t={});var r=S(t),n=t.encode,o=void 0===n?function(e){return e}:n,i=t.validate,s=void 0===i||i,a=e.map((function(e){if("object"==typeof e)return new RegExp("^(?:"+e.pattern+")$",r)}));return function(t){for(var r="",n=0;n<e.length;n++){var i=e[n];if("string"!=typeof i){var c=t?t[i.name]:void 0,u="?"===i.modifier||"*"===i.modifier,f="*"===i.modifier||"+"===i.modifier;if(Array.isArray(c)){if(!f)throw new TypeError('Expected "'+i.name+'" to not repeat, but got an array');if(0===c.length){if(u)continue;throw new TypeError('Expected "'+i.name+'" to not be empty')}for(var l=0;l<c.length;l++){var d=o(c[l],i);if(s&&!a[n].test(d))throw new TypeError('Expected all "'+i.name+'" to match "'+i.pattern+'", but got "'+d+'"');r+=i.prefix+d+i.suffix}}else if("string"!=typeof c&&"number"!=typeof c){if(!u){var p=f?"an array":"a string";throw new TypeError('Expected "'+i.name+'" to be '+p)}}else{d=o(String(c),i);if(s&&!a[n].test(d))throw new TypeError('Expected "'+i.name+'" to match "'+i.pattern+'", but got "'+d+'"');r+=i.prefix+d+i.suffix}}else r+=i}return r}}(y(e,t),t)}function R(e,t){var r=[];return function(e,t,r){void 0===r&&(r={});var n=r.decode,o=void 0===n?function(e){return e}:n;return function(r){var n=e.exec(r);if(!n)return!1;for(var i=n[0],s=n.index,a=Object.create(null),c=function(e){if(void 0===n[e])return"continue";var r=t[e-1];"*"===r.modifier||"+"===r.modifier?a[r.name]=n[e].split(r.prefix+r.suffix).map((function(e){return o(e,r)})):a[r.name]=o(n[e],r)},u=1;u<n.length;u++)c(u);return{path:i,index:s,params:a}}}(I(e,r,t),r,t)}function v(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function S(e){return e&&e.sensitive?"":"i"}function g(e,t,r){return function(e,t,r){void 0===r&&(r={});for(var n=r.strict,o=void 0!==n&&n,i=r.start,s=void 0===i||i,a=r.end,c=void 0===a||a,u=r.encode,f=void 0===u?function(e){return e}:u,l="["+v(r.endsWith||"")+"]|$",d="["+v(r.delimiter||"/#?")+"]",p=s?"^":"",h=0,E=e;h<E.length;h++){var _=E[h];if("string"==typeof _)p+=v(f(_));else{var m=v(f(_.prefix)),T=v(f(_.suffix));if(_.pattern)if(t&&t.push(_),m||T)if("+"===_.modifier||"*"===_.modifier){var y="*"===_.modifier?"?":"";p+="(?:"+m+"((?:"+_.pattern+")(?:"+T+m+"(?:"+_.pattern+"))*)"+T+")"+y}else p+="(?:"+m+"("+_.pattern+")"+T+")"+_.modifier;else p+="("+_.pattern+")"+_.modifier;else p+="(?:"+m+T+")"+_.modifier}}if(c)o||(p+=d+"?"),p+=r.endsWith?"(?="+l+")":"$";else{var b=e[e.length-1],R="string"==typeof b?d.indexOf(b[b.length-1])>-1:void 0===b;o||(p+="(?:"+d+"(?="+l+"))?"),R||(p+="(?="+d+"|"+l+")")}return new RegExp(p,S(r))}(y(e,r),t,r)}function I(e,t,r){return e instanceof RegExp?function(e,t){if(!t)return e;for(var r=/\((?:\?<(.*?)>)?(?!\?)/g,n=0,o=r.exec(e.source);o;)t.push({name:o[1]||n++,prefix:"",suffix:"",modifier:"",pattern:""}),o=r.exec(e.source);return e}(e,t):Array.isArray(e)?function(e,t,r){var n=e.map((function(e){return I(e,t,r).source}));return new RegExp("(?:"+n.join("|")+")",S(r))}(e,t,r):g(e,t,r)}const A=(e,t)=>{var r;const n=null===(r=t.i18n)||void 0===r?void 0:r.domains;if(n){const t=e.headers.host;if(t&&t.length>0){const e=t[0].value.split(":")[0],r=n.find((t=>t.domain===e));if(r)return r.defaultLocale}}return null};function C(e,t,r=null){if(t.i18n){const n=null!=r?r:t.i18n.defaultLocale,o=t.i18n.locales,i=e.startsWith(t.basePath)?t.basePath:"",s=e.toLowerCase();for(const t of o)if(s===`${i}/${t}`.toLowerCase()||s.startsWith(`${i}/${t}/`.toLowerCase()))return e.replace(new RegExp(`${i}/${t}`,"i"),`${i}/${null!=r?r:t}`);return"/"===e||e===`${i}`?`${i}/${n}`:e.replace(`${i}/`,`${i}/${n}/`)}return e}function x(e,t){if(t.i18n){const r=e.toLowerCase(),n=t.i18n.locales;for(const e of n){const t=`/${e.toLowerCase()}`;if(r===t)return"/";if(r.startsWith(`${t}/`))return`${r.slice(t.length)}`}}return e}function w(e,t){return R(t,{decode:decodeURIComponent})(e)}function L(e,t){try{const r=e.toLowerCase();if(r.startsWith("https://")||r.startsWith("http://")){const{origin:r,pathname:n}=new URL(e),o=`${r}${b(n,{encode:encodeURIComponent})(t)}`;return!e.endsWith("/")&&o.endsWith("/")?o.slice(0,-1):o}{const r=e.replace(/\?/g,"\\?");return b(r,{encode:encodeURIComponent})(t)}}catch(t){return console.error(`Could not compile destination ${e}, returning null instead. Error: ${t}`),null}}const P=(e,t)=>{var r;const[n]=(null!==(r=e.req.url)&&void 0!==r?r:"").split("?"),o=((e,t)=>{const r=C(e,t),n={};for(const e of t.headers)if(w(r,e.source))for(const{key:t,value:r}of e.headers)t&&(n[t.toLowerCase()]=[{key:t,value:r}]);return n})(n,t);for(const[{key:t,value:r}]of Object.values(o))t&&e.res.setHeader(t,r)},N=(e,t)=>{var r;for(const[n,o]of Object.entries(t.headers||[])){const t=o.map((({key:e})=>e)),i=o.map((({value:e})=>e)).join(";");i&&e.res.setHeader(null!==(r=t[0])&&void 0!==r?r:n,i)}},O=(e,t)=>{const{basePath:r,i18n:n}=t;if(r){if(!e.startsWith(r))return(null==n?void 0:n.defaultLocale)?`/${n.defaultLocale}/404`:"/404";e=e.slice(r.length)}return e.endsWith("/")&&(e=e.slice(0,-1)),""===e?"/":e},D=(e,t,r)=>((e,t,r)=>{const n=`${function(e,t){if(t.basePath&&e.startsWith(t.basePath)&&(e=e.slice(t.basePath.length)),t.i18n){const r=e.toLowerCase();for(const e of t.i18n.locales){const t=e.toLowerCase();if(r===`/${t}`||r.startsWith(`/${t}/`))return`/${e}`}return`/${t.i18n.defaultLocale}`}return""}(e,r)}/404`;if(t.pages.html.nonDynamic[n]||t.pages.ssg.nonDynamic[n])return{isData:!1,isStatic:!0,file:`pages${n}.html`,statusCode:404}})(e,t,r)||{isData:!1,isRender:!0,page:"pages/_error.js",statusCode:404},M=e=>"/"==e?"pages/index.html":`pages${e}.html`,F=(e,t,r,n,o,i)=>{var s,a;const{pages:c}=r,u=O(C(t,n,A(e,n)),n);if(c.html.nonDynamic[u]){const e=x(u,n),t="/404"===e?404:"/500"===e?500:void 0;return{isData:!1,isStatic:!0,file:c.html.nonDynamic[u],statusCode:t}}if(c.ssg.nonDynamic[u]&&!o){const e=c.ssg.nonDynamic[u],t=null!==(s=e.srcRoute)&&void 0!==s?s:u,r=x(u,n),o="/404"===r?404:"/500"===r?500:void 0;return{isData:!1,isStatic:!0,file:M(u),page:c.ssr.nonDynamic[t]||c.ssr.dynamic[t],revalidate:e.initialRevalidateSeconds,statusCode:o}}if((null!==(a=c.ssg.notFound)&&void 0!==a?a:{})[u]&&!o)return D(t,r,n);if(c.ssr.nonDynamic[u])return{isData:!1,isRender:!0,page:c.ssr.nonDynamic[u]};const f=!i&&U(e,t,n,r);if(f){const[t,i]=f.split("?");if($(t))return{isExternal:!0,path:t,querystring:i};return{...F(e,t,r,n,o,!0),querystring:i}}const l=((e,t)=>{for(const{route:r,regex:n}of t)if(new RegExp(n,"i").test(e))return r})(u,c.dynamic),d=l&&c.ssg.dynamic[l];if(d&&!o)return{isData:!1,isStatic:!0,file:M(u),page:l?c.ssr.dynamic[l]:void 0,fallback:d.fallback};const p=l&&c.ssr.dynamic[l];if(p)return{isData:!1,isRender:!0,page:p};const h=l&&c.html.dynamic[l];return h?{isData:!1,isStatic:!0,file:h}:D(t,r,n)};function U(e,t,r,n){const o=C(t,r,A(e,r)),i=r.rewrites;for(const t of i){const i=w(o,t.source);if(!i)continue;const s=i.params,a=L(t.destination,s);if(!a)return;if(n&&o===a){if(404===F(e,a,n,r,!1,!0).statusCode)continue}const c=Object.keys(s).filter((e=>"nextInternalLocale"!==e)).filter((e=>!t.destination.endsWith(`:${e}`)&&!t.destination.includes(`:${e}/`))).map((e=>{const t=s[e];return"string"==typeof t?`${e}=${t}`:t.map((t=>`${e}=${t}`)).join("&")})).filter((e=>e)).join("&");if(c){const e=a.includes("?")?"&":"?";return`${a}${e}${c}`}return a}}function $(e){return e.startsWith("http://")||e.startsWith("https://")}const q=(e,t,r,n,o)=>{const{apis:i}=r,s=O(t,n),a=i.nonDynamic[s];if(a)return{isApi:!0,page:a};const c=!o&&U(e,t,n);if(c){const t=x(c,n),[o,i]=t.split("?");if($(o))return{isExternal:!0,path:o,querystring:i};const s=q(e,o,r,n,!0);return s?{...s,querystring:i}:s}const u=((e,t)=>{for(const{file:r,regex:n}of t)if(new RegExp(n,"i").test(e))return r})(s,i.dynamic);return u?{isApi:!0,page:u}:void 0};function j(e,t,r){let n;if(t){const[r,o]=e.split("?");n=`${r}?${t}${o?`&${o}`:""}`}else n=e;const i=r;return{isRedirect:!0,status:i,statusDescription:o.STATUS_CODES[i]||"",headers:{location:[{key:"Location",value:n}],refresh:308===r?[{key:"Refresh",value:`0;url=${n}`}]:[],"cache-control":[{key:"Cache-Control",value:"s-maxage=0"}]}}}const H=(e,t)=>{const{headers:r}=e;return function(e,t){var r;if(t&&t.username&&t.password){const n="Basic "+Buffer.from(t.username+":"+t.password).toString("base64");if(!e||(null===(r=e[0])||void 0===r?void 0:r.value)!==n)return{isUnauthorized:!0,status:401,statusDescription:"Unauthorized",body:"Unauthorized",headers:{"www-authenticate":[{key:"WWW-Authenticate",value:"Basic"}]}}}}(r.authorization,t.authentication)},B=(e,t)=>{const r=function(e,t){var r;const n=C(e.uri,t),o=null!==(r=t.redirects)&&void 0!==r?r:[];for(const e of o){const t=w(n,e.source);if(t){const r=L(e.destination,t.params);return r?{path:r,statusCode:e.statusCode}:null}}return null}(e,t);if(r){const{path:t,statusCode:n}=r;return j(t,e.querystring,n)}},k=(e,t,r)=>{const n=H(e,t);if(n)return n;const o=((e,t)=>{const r=function(e,t){const r=e.headers.host;if(r&&r.length>0){const n=r[0].value,o=t.domainRedirects;if(o&&o[n])return`${o[n]}${e.uri}`}}(e,t);if(r)return j(r,e.querystring,308)})(e,t)||B(e,r);return o||q(e,e.uri,t,r)},G=async(e,t,r,n)=>{const o=(e=>{var t;const[r,n]=(null!==(t=e.req.url)&&void 0!==t?t:"").split("?"),o={};for(const[t,r]of Object.entries(e.req.headers))r&&Array.isArray(r)?o[t.toLowerCase()]=r.map((e=>({key:t,value:e}))):r&&(o[t.toLowerCase()]=[{key:t,value:r}]);return{headers:o,querystring:n,uri:r}})(e),i=k(o,t,r);if(!i)return(e=>{e.res.statusCode=404,e.res.statusMessage="Not Found",e.res.end("Not Found")})(e);if(i.querystring&&(e.req.url=`${e.req.url}${o.querystring?"&":"?"}${i.querystring}`),i.isApi){const{page:t}=i;return P(e,r),void n(t).default(e.req,e.res)}return i.isRedirect||i.isUnauthorized?((e,t)=>{N(e,t),e.res.statusCode=t.status,e.res.statusMessage=t.statusDescription,e.res.end()})(e,i):i};var V,z,W=(()=>{var e={343:(e,t,r)=>{r.r(t),r.d(t,{Observable:()=>y,combineLatest:()=>R,default:()=>S,merge:()=>b,zip:()=>v});const n=()=>"function"==typeof Symbol,o=e=>n()&&Boolean(Symbol[e]),i=e=>o(e)?Symbol[e]:"@@"+e;n()&&!o("observable")&&(Symbol.observable=Symbol("observable"));const s=i("iterator"),a=i("observable"),c=i("species");function u(e,t){let r=e[t];if(null!=r){if("function"!=typeof r)throw new TypeError(r+" is not a function");return r}}function f(e){let t=e.constructor;return void 0!==t&&(t=t[c],null===t&&(t=void 0)),void 0!==t?t:y}function l(e){l.log?l.log(e):setTimeout((()=>{throw e}))}function d(e){Promise.resolve().then((()=>{try{e()}catch(e){l(e)}}))}function p(e){let t=e._cleanup;if(void 0!==t&&(e._cleanup=void 0,t))try{if("function"==typeof t)t();else{let e=u(t,"unsubscribe");e&&e.call(t)}}catch(e){l(e)}}function h(e){e._observer=void 0,e._queue=void 0,e._state="closed"}function E(e,t,r){e._state="running";let n=e._observer;try{let o=u(n,t);switch(t){case"next":o&&o.call(n,r);break;case"error":if(h(e),!o)throw r;o.call(n,r);break;case"complete":h(e),o&&o.call(n)}}catch(e){l(e)}"closed"===e._state?p(e):"running"===e._state&&(e._state="ready")}function _(e,t,r){if("closed"!==e._state){if("buffering"!==e._state)return"ready"!==e._state?(e._state="buffering",e._queue=[{type:t,value:r}],void d((()=>function(e){let t=e._queue;if(t){e._queue=void 0,e._state="ready";for(let r=0;r<t.length&&(E(e,t[r].type,t[r].value),"closed"!==e._state);++r);}}(e)))):void E(e,t,r);e._queue.push({type:t,value:r})}}class m{constructor(e,t){this._cleanup=void 0,this._observer=e,this._queue=void 0,this._state="initializing";let r=new T(this);try{this._cleanup=t.call(void 0,r)}catch(e){r.error(e)}"initializing"===this._state&&(this._state="ready")}get closed(){return"closed"===this._state}unsubscribe(){"closed"!==this._state&&(h(this),p(this))}}class T{constructor(e){this._subscription=e}get closed(){return"closed"===this._subscription._state}next(e){_(this._subscription,"next",e)}error(e){_(this._subscription,"error",e)}complete(){_(this._subscription,"complete")}}class y{constructor(e){if(!(this instanceof y))throw new TypeError("Observable cannot be called as a function");if("function"!=typeof e)throw new TypeError("Observable initializer must be a function");this._subscriber=e}subscribe(e){return"object"==typeof e&&null!==e||(e={next:e,error:arguments[1],complete:arguments[2]}),new m(e,this._subscriber)}forEach(e){return new Promise(((t,r)=>{if("function"!=typeof e)return void r(new TypeError(e+" is not a function"));function n(){o.unsubscribe(),t()}let o=this.subscribe({next(t){try{e(t,n)}catch(e){r(e),o.unsubscribe()}},error:r,complete:t})}))}map(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return new(f(this))((t=>this.subscribe({next(r){try{r=e(r)}catch(e){return t.error(e)}t.next(r)},error(e){t.error(e)},complete(){t.complete()}})))}filter(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return new(f(this))((t=>this.subscribe({next(r){try{if(!e(r))return}catch(e){return t.error(e)}t.next(r)},error(e){t.error(e)},complete(){t.complete()}})))}reduce(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");let t=f(this),r=arguments.length>1,n=!1,o=arguments[1];return new t((t=>this.subscribe({next(i){let s=!n;if(n=!0,!s||r)try{o=e(o,i)}catch(e){return t.error(e)}else o=i},error(e){t.error(e)},complete(){if(!n&&!r)return t.error(new TypeError("Cannot reduce an empty sequence"));t.next(o),t.complete()}})))}concat(...e){let t=f(this);return new t((r=>{let n,o=0;return function i(s){n=s.subscribe({next(e){r.next(e)},error(e){r.error(e)},complete(){o===e.length?(n=void 0,r.complete()):i(t.from(e[o++]))}})}(this),()=>{n&&(n.unsubscribe(),n=void 0)}}))}flatMap(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");let t=f(this);return new t((r=>{let n=[],o=this.subscribe({next(o){if(e)try{o=e(o)}catch(e){return r.error(e)}let s=t.from(o).subscribe({next(e){r.next(e)},error(e){r.error(e)},complete(){let e=n.indexOf(s);e>=0&&n.splice(e,1),i()}});n.push(s)},error(e){r.error(e)},complete(){i()}});function i(){o.closed&&0===n.length&&r.complete()}return()=>{n.forEach((e=>e.unsubscribe())),o.unsubscribe()}}))}[a](){return this}static from(e){let t="function"==typeof this?this:y;if(null==e)throw new TypeError(e+" is not an object");let r=u(e,a);if(r){let n=r.call(e);if(Object(n)!==n)throw new TypeError(n+" is not an object");return function(e){return e instanceof y}(n)&&n.constructor===t?n:new t((e=>n.subscribe(e)))}if(o("iterator")&&(r=u(e,s),r))return new t((t=>{d((()=>{if(!t.closed){for(let n of r.call(e))if(t.next(n),t.closed)return;t.complete()}}))}));if(Array.isArray(e))return new t((t=>{d((()=>{if(!t.closed){for(let r=0;r<e.length;++r)if(t.next(e[r]),t.closed)return;t.complete()}}))}));throw new TypeError(e+" is not observable")}static of(...e){return new("function"==typeof this?this:y)((t=>{d((()=>{if(!t.closed){for(let r=0;r<e.length;++r)if(t.next(e[r]),t.closed)return;t.complete()}}))}))}static get[c](){return this}}function b(...e){return new y((t=>{if(0===e.length)return y.from([]);let r=e.length,n=e.map((e=>y.from(e).subscribe({next(e){t.next(e)},error(e){t.error(e)},complete(){0==--r&&t.complete()}})));return()=>n.forEach((e=>e.unsubscribe()))}))}function R(...e){return new y((t=>{if(0===e.length)return y.from([]);let r=e.length,n=new Set,o=!1,i=e.map((()=>{})),s=e.map(((s,a)=>y.from(s).subscribe({next(r){if(i[a]=r,!o){if(n.add(a),n.size!==e.length)return;n=null,o=!0}t.next(Array.from(i))},error(e){t.error(e)},complete(){0==--r&&t.complete()}})));return()=>s.forEach((e=>e.unsubscribe()))}))}function v(...e){return new y((t=>{if(0===e.length)return y.from([]);let r=e.map((()=>[]));function n(){return r.some(((e,t)=>0===e.length&&o[t].closed))}let o=e.map(((e,o)=>y.from(e).subscribe({next(e){r[o].push(e),r.every((e=>e.length>0))&&(t.next(r.map((e=>e.shift()))),n()&&t.complete())},error(e){t.error(e)},complete(){n()&&t.complete()}})));return()=>o.forEach((e=>e.unsubscribe()))}))}n()&&Object.defineProperty(y,Symbol("extensions"),{value:{symbol:a,hostReportError:l},configurable:!0});const S=y}},t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={exports:{}},i=!0;try{e[n](o,o.exports,r),i=!1}finally{i&&delete t[n]}return o.exports}return r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.ab=__dirname+"/",r(343)})();(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.SERVER_DIRECTORY=t.PAGES_MANIFEST=t.SERVER_PROPS_ID=t.CLIENT_STATIC_FILES_RUNTIME_WEBPACK=t.PERMANENT_REDIRECT_STATUS=t.SERVER_FILES_MANIFEST=t.STATIC_PROPS_ID=t.BUILD_MANIFEST=t.BLOCKED_PAGES=t.STATIC_STATUS_PAGES=t.PRERENDER_MANIFEST=t.DEV_CLIENT_PAGES_MANIFEST=t.OPTIMIZED_FONT_PROVIDERS=t.TEMPORARY_REDIRECT_STATUS=t.SERVERLESS_DIRECTORY=t.EXPORT_MARKER=t.GOOGLE_FONT_PROVIDER=t.PHASE_PRODUCTION_BUILD=t.CLIENT_STATIC_FILES_RUNTIME_MAIN=t.BUILD_ID_FILE=t.CONFIG_FILE=t.CLIENT_STATIC_FILES_RUNTIME=t.PHASE_PRODUCTION_SERVER=t.EXPORT_DETAIL=t.IMAGES_MANIFEST=t.CLIENT_STATIC_FILES_RUNTIME_AMP=t.CLIENT_PUBLIC_FILES_PATH=t.CLIENT_STATIC_FILES_RUNTIME_POLYFILLS_SYMBOL=t.STRING_LITERAL_DROP_BUNDLE=t.TRACE_OUTPUT_VERSION=t.CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH=t.FONT_MANIFEST=t.REACT_LOADABLE_MANIFEST=t.ROUTES_MANIFEST=t.CLIENT_STATIC_FILES_PATH=t.BODY_RENDER_TARGET=t.PHASE_EXPORT=t.PHASE_DEVELOPMENT_SERVER=void 0,t.PHASE_EXPORT="phase-export",t.PHASE_PRODUCTION_BUILD="phase-production-build",t.PHASE_PRODUCTION_SERVER="phase-production-server",t.PHASE_DEVELOPMENT_SERVER="phase-development-server",t.PAGES_MANIFEST="pages-manifest.json",t.BUILD_MANIFEST="build-manifest.json",t.EXPORT_MARKER="export-marker.json",t.EXPORT_DETAIL="export-detail.json",t.PRERENDER_MANIFEST="prerender-manifest.json",t.ROUTES_MANIFEST="routes-manifest.json",t.IMAGES_MANIFEST="images-manifest.json",t.SERVER_FILES_MANIFEST="required-server-files.json",t.DEV_CLIENT_PAGES_MANIFEST="_devPagesManifest.json",t.REACT_LOADABLE_MANIFEST="react-loadable-manifest.json",t.FONT_MANIFEST="font-manifest.json",t.SERVER_DIRECTORY="server",t.SERVERLESS_DIRECTORY="serverless",t.CONFIG_FILE="next.config.js",t.BUILD_ID_FILE="BUILD_ID",t.BLOCKED_PAGES=["/_document","/_app","/_error"],t.CLIENT_PUBLIC_FILES_PATH="public",t.CLIENT_STATIC_FILES_PATH="static",t.CLIENT_STATIC_FILES_RUNTIME="runtime",t.BODY_RENDER_TARGET="__NEXT_BODY_RENDER_TARGET__",t.STRING_LITERAL_DROP_BUNDLE="__NEXT_DROP_CLIENT_FILE__",t.CLIENT_STATIC_FILES_RUNTIME_MAIN="main",t.CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH="react-refresh",t.CLIENT_STATIC_FILES_RUNTIME_AMP="amp",t.CLIENT_STATIC_FILES_RUNTIME_WEBPACK="webpack";const r=Symbol("polyfills");t.CLIENT_STATIC_FILES_RUNTIME_POLYFILLS_SYMBOL=r,t.TEMPORARY_REDIRECT_STATUS=307,t.PERMANENT_REDIRECT_STATUS=308,t.STATIC_PROPS_ID="__N_SSG",t.SERVER_PROPS_ID="__N_SSP";const n="https://fonts.googleapis.com/css";t.GOOGLE_FONT_PROVIDER=n;const o=[{url:n,preconnect:"https://fonts.gstatic.com"},{url:"https://use.typekit.net",preconnect:"https://use.typekit.net"}];t.OPTIMIZED_FONT_PROVIDERS=o,t.STATIC_STATUS_PAGES=["/500"],t.TRACE_OUTPUT_VERSION=1})(V={exports:{}},V.exports),!(z=W)||z.__esModule;const Y=["connection","expect","keep-alive","proxy-authenticate","proxy-authorization","proxy-connection","trailer","upgrade","x-accel-buffering","x-accel-charset","x-accel-limit-rate","x-accel-redirect","x-cache","x-forwarded-proto","x-real-ip"],X=["x-amz-cf-","x-amzn-","x-edge-"];function K(e){const t=e.toLowerCase();for(const e of X)if(t.startsWith(e))return!0;return Y.includes(t)}exports.handler=async e=>{var t;!function(){try{const e="{{ _SST_NEXTJS_SITE_ENVIRONMENT_ }}";process.env={...process.env,...e}}catch(e){console.log("Failed to set SST NextjsSite environment."),console.log(e)}}();const r=e.Records[0].cf.request,n=a.default,o=s.default,{req:i,res:c,responsePromise:u}=E(e.Records[0].cf,{enableHTTPCompression:o.enableHTTPCompression}),f=await G({req:i,res:c,responsePromise:u},o,n,(e=>require(`./${e}`)));if(f){const{path:e}=f;await async function(e,t,r,n){const{default:o}=await Promise.resolve().then((function(){return require("./index-9e574644.js")})),i={};let s;if(Object.assign(i,t.headers),i.hasOwnProperty("host")&&delete i.host,n){const r=Buffer.from(n,"base64").toString("utf8");s=await o(e,{headers:i,method:t.method,body:r,compress:!1,redirect:"manual"})}else s=await o(e,{headers:i,method:t.method,compress:!1,redirect:"manual"});for(const[e,t]of s.headers.entries())T(e)||r.setHeader(e,t);r.statusCode=s.status,r.end(await s.buffer())}(e,i,c,null===(t=r.body)||void 0===t?void 0:t.data)}const l=await u;return l.headers&&function(e){for(const t in e)K(t)&&delete e[t]}(l.headers),l};
;