From cf48c57378fb1ec1a525528f367e7249d1c48bca Mon Sep 17 00:00:00 2001 From: = Date: Sun, 7 May 2023 22:23:48 +0100 Subject: [PATCH 1/4] Fix static site dynamic routes for sitemap integration --- .../fixtures/basics/functions/[[path]].js | 277 ++++++++++++++++++ packages/integrations/sitemap/src/index.ts | 16 +- .../test/fixtures/static/astro.config.mjs | 7 + .../sitemap/test/fixtures/static/package.json | 9 + .../fixtures/static/src/pages/[slug].astro | 17 ++ .../sitemap/test/staticPaths.test.js | 22 ++ 6 files changed, 343 insertions(+), 5 deletions(-) create mode 100644 packages/integrations/cloudflare/test/fixtures/basics/functions/[[path]].js create mode 100644 packages/integrations/sitemap/test/fixtures/static/astro.config.mjs create mode 100644 packages/integrations/sitemap/test/fixtures/static/package.json create mode 100644 packages/integrations/sitemap/test/fixtures/static/src/pages/[slug].astro create mode 100644 packages/integrations/sitemap/test/staticPaths.test.js diff --git a/packages/integrations/cloudflare/test/fixtures/basics/functions/[[path]].js b/packages/integrations/cloudflare/test/fixtures/basics/functions/[[path]].js new file mode 100644 index 000000000000..4145f7c9b330 --- /dev/null +++ b/packages/integrations/cloudflare/test/fixtures/basics/functions/[[path]].js @@ -0,0 +1,277 @@ +globalThis.process = { + argv: [], + env: {}, +}; +var En=Object.create;var lt=Object.defineProperty;var jn=Object.getOwnPropertyDescriptor;var $n=Object.getOwnPropertyNames;var Cn=Object.getPrototypeOf,Fn=Object.prototype.hasOwnProperty;var Rn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Pn=(e,t,a,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of $n(t))!Fn.call(e,o)&&o!==a&<(e,o,{get:()=>t[o],enumerable:!(i=jn(t,o))||i.enumerable});return e};var ct=(e,t,a)=>(a=e!=null?En(Cn(e)):{},Pn(t||!e||!e.__esModule?lt(a,"default",{value:e,enumerable:!0}):a,e));var je=(e,t,a)=>{if(!t.has(e))throw TypeError("Cannot "+a)};var u=(e,t,a)=>(je(e,t,"read from private field"),a?a.call(e):t.get(e)),k=(e,t,a)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,a)},j=(e,t,a,i)=>(je(e,t,"write to private field"),i?i.call(e,a):t.set(e,a),a);var M=(e,t,a)=>(je(e,t,"access private method"),a);var Ce=Rn($e=>{"use strict";$e.parse=zn;$e.serialize=On;var Nn=decodeURIComponent,Tn=encodeURIComponent,me=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function zn(e,t){if(typeof e!="string")throw new TypeError("argument str must be a string");for(var a={},i=t||{},o=e.split(";"),r=i.decode||Nn,n=0;n`\`Astro.clientAddress\` is not available in the \`${e}\` adapter. File an issue with the adapter to add support.`},StaticClientAddressNotAvailable:{title:"`Astro.clientAddress` is not available in static mode.",code:3003,message:"`Astro.clientAddress` is only available when using `output: 'server'`. Update your Astro config if you need SSR features.",hint:"See https://docs.astro.build/en/guides/server-side-rendering/#enabling-ssr-in-your-project for more information on how to enable SSR."},NoMatchingStaticPathFound:{title:"No static path found for requested path.",code:3004,message:e=>`A \`getStaticPaths()\` route pattern was matched, but no matching static path was found for requested path \`${e}\`.`,hint:e=>`Possible dynamic routes being matched: ${e.join(", ")}.`},OnlyResponseCanBeReturned:{title:"Invalid type returned by Astro page.",code:3005,message:(e,t)=>`Route \`${e||""}\` returned a \`${t}\`. Only a [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) can be returned from Astro files.`,hint:"See https://docs.astro.build/en/guides/server-side-rendering/#response for more information."},MissingMediaQueryDirective:{title:"Missing value for `client:media` directive.",code:3006,message:'Media query not provided for `client:media` directive. A media query similar to `client:media="(max-width: 600px)"` must be provided'},NoMatchingRenderer:{title:"No matching renderer found.",code:3007,message:(e,t,a,i)=>`Unable to render \`${e}\`. + +${i>0?`There ${a?"are.":"is."} ${i} renderer${a?"s.":""} configured in your \`astro.config.mjs\` file, +but ${a?"none were.":"it was not."} able to server-side render \`${e}\`.`:`No valid renderer was found ${t?`for the \`.${t}\` file extension.`:"for this file extension."}`}`,hint:e=>`Did you mean to enable the ${e} integration? + +See https://docs.astro.build/en/core-concepts/framework-components/ for more information on how to install and configure integrations.`},NoClientEntrypoint:{title:"No client entrypoint specified in renderer.",code:3008,message:(e,t,a)=>`\`${e}\` component has a \`client:${t}\` directive, but no client entrypoint was provided by \`${a}\`.`,hint:"See https://docs.astro.build/en/reference/integrations-reference/#addrenderer-option for more information on how to configure your renderer."},NoClientOnlyHint:{title:"Missing hint on client:only directive.",code:3009,message:e=>`Unable to render \`${e}\`. When using the \`client:only\` hydration strategy, Astro needs a hint to use the correct renderer.`,hint:e=>`Did you mean to pass \`client:only="${e}"\`? See https://docs.astro.build/en/reference/directives-reference/#clientonly for more information on client:only`},InvalidGetStaticPathParam:{title:"Invalid value returned by a `getStaticPaths` path.",code:3010,message:e=>`Invalid params given to \`getStaticPaths\` path. Expected an \`object\`, got \`${e}\``,hint:"See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."},InvalidGetStaticPathsReturn:{title:"Invalid value returned by getStaticPaths.",code:3011,message:e=>`Invalid type returned by \`getStaticPaths\`. Expected an \`array\`, got \`${e}\``,hint:"See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."},GetStaticPathsRemovedRSSHelper:{title:"getStaticPaths RSS helper is not available anymore.",code:3012,message:"The RSS helper has been removed from `getStaticPaths`. Try the new @astrojs/rss package instead.",hint:"See https://docs.astro.build/en/guides/rss/ for more information."},GetStaticPathsExpectedParams:{title:"Missing params property on `getStaticPaths` route.",code:3013,message:"Missing or empty required `params` property on `getStaticPaths` route.",hint:"See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."},GetStaticPathsInvalidRouteParam:{title:"Invalid value for `getStaticPaths` route parameter.",code:3014,message:(e,t,a)=>`Invalid getStaticPaths route parameter for \`${e}\`. Expected undefined, a string or a number, received \`${a}\` (\`${t}\`)`,hint:"See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."},GetStaticPathsRequired:{title:"`getStaticPaths()` function required for dynamic routes.",code:3015,message:"`getStaticPaths()` function is required for dynamic routes. Make sure that you `export` a `getStaticPaths` function from your dynamic route.",hint:'See https://docs.astro.build/en/core-concepts/routing/#dynamic-routes for more information on dynamic routes.\n\nAlternatively, set `output: "server"` in your Astro config file to switch to a non-static server build. This error can also occur if using `export const prerender = true;`.\nSee https://docs.astro.build/en/guides/server-side-rendering/ for more information on non-static rendering.'},ReservedSlotName:{title:"Invalid slot name.",code:3016,message:e=>`Unable to create a slot named \`${e}\`. \`${e}\` is a reserved slot name. Please update the name of this slot.`},NoAdapterInstalled:{title:"Cannot use Server-side Rendering without an adapter.",code:3017,message:"Cannot use `output: 'server'` without an adapter. Please install and configure the appropriate server adapter for your final deployment.",hint:"See https://docs.astro.build/en/guides/server-side-rendering/ for more information."},NoMatchingImport:{title:"No import found for component.",code:3018,message:e=>`Could not render \`${e}\`. No matching import has been found for \`${e}\`.`,hint:"Please make sure the component is properly imported."},InvalidPrerenderExport:{title:"Invalid prerender export.",code:3019,message:(e,t)=>{let a="A `prerender` export has been detected, but its value cannot be statically analyzed.";return e!=="const"&&(a+=` +Expected \`const\` declaration but got \`${e}\`.`),t!=="true"&&(a+=` +Expected \`true\` value but got \`${t}\`.`),a},hint:"Mutable values declared at runtime are not supported. Please make sure to use exactly `export const prerender = true`."},InvalidComponentArgs:{title:"Invalid component arguments.",code:3020,message:e=>`Invalid arguments passed to${e?` <${e}>`:""} component.`,hint:"Astro components cannot be rendered directly via function call, such as `Component()` or `{items.map(Component)}`."},PageNumberParamNotFound:{title:"Page number param not found.",code:3021,message:e=>`[paginate()] page number param \`${e}\` not found in your filepath.`,hint:"Rename your file to `[page].astro` or `[...page].astro`."},ImageMissingAlt:{title:"Missing alt property.",code:3022,message:"The alt property is required.",hint:"The `alt` property is important for the purpose of accessibility, without it users using screen readers or other assistive technologies won't be able to understand what your image is supposed to represent. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attr-alt for more information."},InvalidImageService:{title:"Error while loading image service.",code:3023,message:"There was an error loading the configured image service. Please see the stack trace for more information."},MissingImageDimension:{title:"Missing image dimensions",code:3024,message:(e,t)=>`Missing ${e==="both"?"width and height attributes":`${e} attribute`} for ${t}. When using remote images, both dimensions are always required in order to avoid CLS.`,hint:"If your image is inside your `src` folder, you probably meant to import it instead. See [the Imports guide for more information](https://docs.astro.build/en/guides/imports/#other-assets)."},UnsupportedImageFormat:{title:"Unsupported image format",code:3025,message:(e,t,a)=>`Received unsupported format \`${e}\` from \`${t}\`. Currently only ${a.join(", ")} are supported for optimization.`,hint:"If you do not need optimization, using an `img` tag directly instead of the `Image` component might be what you're looking for."},PrerenderDynamicEndpointPathCollide:{title:"Prerendered dynamic endpoint has path collision.",code:3026,message:e=>`Could not render \`${e}\` with an \`undefined\` param as the generated path will collide during prerendering. Prevent passing \`undefined\` as \`params\` for the endpoint's \`getStaticPaths()\` function, or add an additional extension to the endpoint's filename.`,hint:e=>`Rename \`${e}\` to \`${e.replace(/\.(js|ts)/,t=>".json"+t)}\``},ExpectedImage:{title:"Expected src to be an image.",code:3027,message:e=>`Expected \`src\` property to be either an ESM imported image or a string with the path of a remote image. Received \`${e}\`.`,hint:"This error can often happen because of a wrong path. Make sure the path to your image is correct."},ExpectedImageOptions:{title:"Expected image options.",code:3028,message:e=>`Expected getImage() parameter to be an object. Received \`${e}\`.`},MarkdownImageNotFound:{title:"Image not found.",code:3029,message:(e,t)=>`Could not find requested image \`${e}\`${t?` at \`${t}\`.`:"."}`,hint:"This is often caused by a typo in the image path. Please make sure the file exists, and is spelled correctly."},ResponseSentError:{title:"Unable to set response",code:3030,message:"The response has already been sent to the browser and cannot be altered."},MiddlewareNoDataOrNextCalled:{title:"The middleware didn't return a response or call `next`",code:3031,message:"The middleware needs to either return a `Response` object or call the `next` function."},MiddlewareNotAResponse:{title:"The middleware returned something that is not a `Response` object",code:3032,message:"Any data returned from middleware must be a valid `Response` object."},LocalsNotAnObject:{title:"Value assigned to `locals` is not accepted",code:3033,message:"`locals` can only be assigned to an object. Other values like numbers, strings, etc. are not accepted.",hint:"If you tried to remove some information from the `locals` object, try to use `delete` or set the property to `undefined`."},LocalsNotSerializable:{title:"`Astro.locals` is not serializable",code:3034,message:e=>`The information stored in \`Astro.locals\` for the path "${e}" is not serializable. +Make sure you store only serializable data.`},UnknownViteError:{title:"Unknown Vite Error.",code:4e3},FailedToLoadModuleSSR:{title:"Could not import file.",code:4001,message:e=>`Could not import \`${e}\`.`,hint:"This is often caused by a typo in the import path. Please make sure the file exists."},InvalidGlob:{title:"Invalid glob pattern.",code:4002,message:e=>`Invalid glob pattern: \`${e}\`. Glob patterns must start with './', '../' or '/'.`,hint:"See https://docs.astro.build/en/guides/imports/#glob-patterns for more information on supported glob patterns."},UnknownCSSError:{title:"Unknown CSS Error.",code:5e3},CSSSyntaxError:{title:"CSS Syntax Error.",code:5001},UnknownMarkdownError:{title:"Unknown Markdown Error.",code:6e3},MarkdownFrontmatterParseError:{title:"Failed to parse Markdown frontmatter.",code:6001},InvalidFrontmatterInjectionError:{title:"Invalid frontmatter injection.",code:6003,message:'A remark or rehype plugin attempted to inject invalid frontmatter. Ensure "astro.frontmatter" is set to a valid JSON object that is not `null` or `undefined`.',hint:"See the frontmatter injection docs https://docs.astro.build/en/guides/markdown-content/#modifying-frontmatter-programmatically for more information."},MdxIntegrationMissingError:{title:"MDX integration missing.",code:6004,message:e=>`Unable to render ${e}. Ensure that the \`@astrojs/mdx\` integration is installed.`,hint:"See the MDX integration docs for installation and usage instructions: https://docs.astro.build/en/guides/integrations-guide/mdx/"},UnknownConfigError:{title:"Unknown configuration error.",code:7e3},ConfigNotFound:{title:"Specified configuration file not found.",code:7001,message:e=>`Unable to resolve \`--config "${e}"\`. Does the file exist?`},ConfigLegacyKey:{title:"Legacy configuration detected.",code:7002,message:e=>`Legacy configuration detected: \`${e}\`.`,hint:`Please update your configuration to the new format. +See https://astro.build/config for more information.`},UnknownCLIError:{title:"Unknown CLI Error.",code:8e3},GenerateContentTypesError:{title:"Failed to generate content types.",code:8001,message:e=>`\`astro sync\` command failed to generate content collection types: ${e}`,hint:"Check your `src/content/config.*` file for typos."},UnknownContentCollectionError:{title:"Unknown Content Collection Error.",code:9e3},InvalidContentEntryFrontmatterError:{title:"Content entry frontmatter does not match schema.",code:9001,message:(e,t,a)=>[`**${String(e)} \u2192 ${String(t)}** frontmatter does not match collection schema.`,...a.errors.map(i=>i.message)].join(` +`),hint:"See https://docs.astro.build/en/guides/content-collections/ for more information on content schemas."},InvalidContentEntrySlugError:{title:"Invalid content entry slug.",code:9002,message:(e,t)=>`${String(e)} \u2192 ${String(t)} has an invalid slug. \`slug\` must be a string.`,hint:"See https://docs.astro.build/en/guides/content-collections/ for more on the `slug` field."},ContentSchemaContainsSlugError:{title:"Content Schema should not contain `slug`.",code:9003,message:e=>`A content collection schema should not contain \`slug\` since it is reserved for slug generation. Remove this from your ${e} collection schema.`,hint:"See https://docs.astro.build/en/guides/content-collections/ for more on the `slug` field."},UnknownError:{title:"Unknown Error.",code:99999}};function Hn(e){return e.replace(/\r\n|\r(?!\n)|\n/g,` +`)}function qn(e){let t=Object.entries(f).find(a=>a[1].code===e);if(t)return{name:t[0],data:t[1]}}function Bn(e,t){if(!t||t.line===void 0||t.column===void 0)return"";let a=Hn(e).split(` +`).map(n=>n.replace(/\t/g," ")),i=[];for(let n=-2;n<=2;n++)a[t.line+n]&&i.push(t.line+n);let o=0;for(let n of i){let s=`> ${n}`;s.length>o&&(o=s.length)}let r="";for(let n of i){let s=n===t.line-1;r+=s?"> ":" ",r+=`${n+1} | ${a[n]} +`,s&&(r+=`${Array.from({length:o}).join(" ")} | ${Array.from({length:t.column}).join(" ")}^ +`)}return r}var v=class extends Error{constructor(t,...a){var i;super(...a),this.type="AstroError";let{code:o,name:r,title:n,message:s,stack:p,location:d,hint:l,frame:c}=t;this.errorCode=o,r&&r!=="Error"?this.name=r:this.name=((i=qn(this.errorCode))==null?void 0:i.name)??"UnknownError",this.title=n,s&&(this.message=s),this.stack=p||this.stack,this.loc=d,this.hint=l,this.frame=c}setErrorCode(t){this.errorCode=t}setLocation(t){this.loc=t}setName(t){this.name=t}setMessage(t){this.message=t}setHint(t){this.hint=t}setFrame(t,a){this.frame=Bn(t,a)}static is(t){return t.type==="AstroError"}},Vn=new Date(0),dt="deleted",Jn=Symbol.for("astro.responseSent"),ee=class{constructor(t){this.value=t}json(){if(this.value===void 0)throw new Error("Cannot convert undefined to an object.");return JSON.parse(this.value)}number(){return Number(this.value)}boolean(){return this.value==="false"||this.value==="0"?!1:!!this.value}},J,I,R,ie,De,oe,_e,ve,Mt,ue=class{constructor(t){k(this,ie);k(this,oe);k(this,ve);k(this,J,void 0);k(this,I,void 0);k(this,R,void 0);j(this,J,t),j(this,I,null),j(this,R,null)}delete(t,a){let i={expires:Vn};a?.domain&&(i.domain=a.domain),a?.path&&(i.path=a.path),M(this,oe,_e).call(this).set(t,[dt,(0,ae.serialize)(t,dt,i),!1])}get(t){if(u(this,R)!==null&&u(this,R).has(t)){let[o,,r]=u(this,R).get(t);return r?new ee(o):new ee(void 0)}let i=M(this,ie,De).call(this)[t];return new ee(i)}has(t){if(u(this,R)!==null&&u(this,R).has(t)){let[,,i]=u(this,R).get(t);return i}return!!M(this,ie,De).call(this)[t]}set(t,a,i){let o;if(typeof a=="string")o=a;else{let n=a.toString();n===Object.prototype.toString.call(a)?o=JSON.stringify(a):o=n}let r={};if(i&&Object.assign(r,i),M(this,oe,_e).call(this).set(t,[o,(0,ae.serialize)(t,o,r),!0]),u(this,J)[Jn])throw new v({...f.ResponseSentError})}*headers(){if(u(this,R)!=null)for(let[,t]of u(this,R))yield t[1]}};J=new WeakMap,I=new WeakMap,R=new WeakMap,ie=new WeakSet,De=function(){return u(this,I)||M(this,ve,Mt).call(this),u(this,I)||j(this,I,{}),u(this,I)},oe=new WeakSet,_e=function(){return u(this,R)||j(this,R,new Map),u(this,R)},ve=new WeakSet,Mt=function(){let t=u(this,J).headers.get("cookie");t&&j(this,I,(0,ae.parse)(t))};var It=Symbol.for("astro.cookies");function Qe(e,t){Reflect.set(e,It,t)}function Gn(e){let t=Reflect.get(e,It);if(t!=null)return t}function*Wn(e){let t=Gn(e);if(!t)return[];for(let a of t.headers())yield a;return[]}function Kn(e){return!(e.length!==3||!e[0]||typeof e[0]!="object")}function Dt(e,t){var a;let i=((a=t?.split("/").pop())==null?void 0:a.replace(".astro",""))??"",o=(...r)=>{if(!Kn(r))throw new v({...f.InvalidComponentArgs,message:f.InvalidComponentArgs.message(i)});return e(...r)};return Object.defineProperty(o,"name",{value:i,writable:!1}),o.isAstroComponentFactory=!0,o.moduleId=t,o}function Xn(e){let t=Dt(e.factory,e.moduleId);return t.propagation=e.propagation,t}function _t(e,t){return typeof e=="function"?Dt(e,t):Xn(e)}var Ut="2.4.2";function Yn(){return(t,a)=>{let i=[...Object.values(t)];if(i.length===0)throw new Error(`Astro.glob(${JSON.stringify(a())}) - no matches found.`);return Promise.all(i.map(o=>o()))}}function Lt(e){return{site:e?new URL(e):void 0,generator:`Astro v${Ut}`,glob:Yn()}}function Qn(e,t){if(e[t])return e[t];if(t==="delete"&&e.del)return e.del;if(e.all)return e.all}async function Zn(e,t,a){var i;let{request:o,params:r,locals:n}=t,s=(i=o.method)==null?void 0:i.toLowerCase(),p=Qn(e,s);if(!a&&a===!1&&s&&s!=="get"&&console.warn(` +${s} requests are not available when building a static site. Update your config to output: 'server' to handle ${s} requests.`),!p||typeof p!="function")return new Response(null,{status:404,headers:{"X-Astro-Response":"Not-Found"}});p.length>1&&console.warn(` +API routes with 2 arguments have been deprecated. Instead they take a single argument in the form of: + +export function get({ params, request }) { + //... +} + +Update your code to remove this warning.`);let d=new Proxy(t,{get(l,c){return c in l?Reflect.get(l,c):c in r?(console.warn(` +API routes no longer pass params as the first argument. Instead an object containing a params property is provided in the form of: + +export function get({ params }) { + // ... +} + +Update your code to remove this warning.`),Reflect.get(r,c)):void 0}});return p.call(e,d,o)}var{replace:ea}="",ta=/[&<>'"]/g,na={"&":"&","<":"<",">":">","'":"'",'"':"""},aa=e=>na[e],ia=e=>ea.call(e,ta,aa);function Ht(e){let t={};return a(e),Object.keys(t).join(" ");function a(i){i&&typeof i.forEach=="function"?i.forEach(a):i===Object(i)?Object.keys(i).forEach(o=>{i[o]&&a(o)}):(i=i===!1||i==null?"":String(i).trim(),i&&i.split(/\s+/).forEach(o=>{t[o]=!0}))}}function Ze(e){return!!e&&typeof e=="object"&&typeof e.then=="function"}async function*mt(e){let t=e.getReader();try{for(;;){let{done:a,value:i}=await t.read();if(a)return;yield i}}finally{t.releaseLock()}}var te=ia,V=class extends String{get[Symbol.toStringTag](){return"HTMLString"}},y=e=>e instanceof V?e:typeof e=="string"?new V(e):e;function et(e){return Object.prototype.toString.call(e)==="[object HTMLString]"}var Se="astro:jsx",ut=Symbol("empty"),ft=e=>e;function ne(e){return e&&typeof e=="object"&&e[Se]}function oa(e){if(typeof e.type=="string")return e;let t={};if(ne(e.props.children)){let a=e.props.children;if(!ne(a)||!("slot"in a.props))return;let i=ft(a.props.slot);t[i]=[a],t[i].$$slot=!0,delete a.props.slot,delete e.props.children}Array.isArray(e.props.children)&&(e.props.children=e.props.children.map(a=>{if(!ne(a)||!("slot"in a.props))return a;let i=ft(a.props.slot);return Array.isArray(t[i])?t[i].push(a):(t[i]=[a],t[i].$$slot=!0),delete a.props.slot,ut}).filter(a=>a!==ut)),Object.assign(e.props,t)}function qt(e){return typeof e=="string"?y(e):Array.isArray(e)?e.map(t=>qt(t)):e}function ra(e){if("set:html"in e.props||"set:text"in e.props){if("set:html"in e.props){let t=qt(e.props["set:html"]);delete e.props["set:html"],Object.assign(e.props,{children:t});return}if("set:text"in e.props){let t=e.props["set:text"];delete e.props["set:text"],Object.assign(e.props,{children:t});return}}}function sa(e,t){let a={[qe]:"astro:jsx",[Se]:!0,type:e,props:t??{}};return ra(a),oa(a),a}var pa=`(self.Astro = self.Astro || {}).idle = (getHydrateCallback) => { + const cb = async () => { + let hydrate = await getHydrateCallback(); + await hydrate(); + }; + if ("requestIdleCallback" in window) { + window.requestIdleCallback(cb); + } else { + setTimeout(cb, 200); + } +}; +window.dispatchEvent(new Event("astro:idle"));`,la=`(self.Astro = self.Astro || {}).load = (getHydrateCallback) => { + (async () => { + let hydrate = await getHydrateCallback(); + await hydrate(); + })(); +}; +window.dispatchEvent(new Event("astro:load"));`,ca=`(self.Astro = self.Astro || {}).media = (getHydrateCallback, options) => { + const cb = async () => { + let hydrate = await getHydrateCallback(); + await hydrate(); + }; + if (options.value) { + const mql = matchMedia(options.value); + if (mql.matches) { + cb(); + } else { + mql.addEventListener("change", cb, { once: true }); + } + } +}; +window.dispatchEvent(new Event("astro:media"));`,da=`(self.Astro = self.Astro || {}).only = (getHydrateCallback) => { + (async () => { + let hydrate = await getHydrateCallback(); + await hydrate(); + })(); +}; +window.dispatchEvent(new Event("astro:only"));`,ma=`(self.Astro = self.Astro || {}).visible = (getHydrateCallback, _opts, root) => { + const cb = async () => { + let hydrate = await getHydrateCallback(); + await hydrate(); + }; + let io = new IntersectionObserver((entries) => { + for (const entry of entries) { + if (!entry.isIntersecting) + continue; + io.disconnect(); + cb(); + break; + } + }); + for (let i = 0; i < root.children.length; i++) { + const child = root.children[i]; + io.observe(child); + } +}; +window.dispatchEvent(new Event("astro:visible"));`,ua=`var _a; +{ + const propTypes = { + 0: (value) => value, + 1: (value) => JSON.parse(value, reviver), + 2: (value) => new RegExp(value), + 3: (value) => new Date(value), + 4: (value) => new Map(JSON.parse(value, reviver)), + 5: (value) => new Set(JSON.parse(value, reviver)), + 6: (value) => BigInt(value), + 7: (value) => new URL(value), + 8: (value) => new Uint8Array(JSON.parse(value)), + 9: (value) => new Uint16Array(JSON.parse(value)), + 10: (value) => new Uint32Array(JSON.parse(value)) + }; + const reviver = (propKey, raw) => { + if (propKey === "" || !Array.isArray(raw)) + return raw; + const [type, value] = raw; + return type in propTypes ? propTypes[type](value) : void 0; + }; + if (!customElements.get("astro-island")) { + customElements.define( + "astro-island", + (_a = class extends HTMLElement { + constructor() { + super(...arguments); + this.hydrate = () => { + if (!this.hydrator || this.parentElement && this.parentElement.closest("astro-island[ssr]")) { + return; + } + const slotted = this.querySelectorAll("astro-slot"); + const slots = {}; + const templates = this.querySelectorAll("template[data-astro-template]"); + for (const template of templates) { + const closest = template.closest(this.tagName); + if (!closest || !closest.isSameNode(this)) + continue; + slots[template.getAttribute("data-astro-template") || "default"] = template.innerHTML; + template.remove(); + } + for (const slot of slotted) { + const closest = slot.closest(this.tagName); + if (!closest || !closest.isSameNode(this)) + continue; + slots[slot.getAttribute("name") || "default"] = slot.innerHTML; + } + const props = this.hasAttribute("props") ? JSON.parse(this.getAttribute("props"), reviver) : {}; + this.hydrator(this)(this.Component, props, slots, { + client: this.getAttribute("client") + }); + this.removeAttribute("ssr"); + window.removeEventListener("astro:hydrate", this.hydrate); + window.dispatchEvent(new CustomEvent("astro:hydrate")); + }; + } + connectedCallback() { + if (!this.hasAttribute("await-children") || this.firstChild) { + this.childrenConnectedCallback(); + } else { + new MutationObserver((_, mo) => { + mo.disconnect(); + this.childrenConnectedCallback(); + }).observe(this, { childList: true }); + } + } + async childrenConnectedCallback() { + window.addEventListener("astro:hydrate", this.hydrate); + let beforeHydrationUrl = this.getAttribute("before-hydration-url"); + if (beforeHydrationUrl) { + await import(beforeHydrationUrl); + } + this.start(); + } + start() { + const opts = JSON.parse(this.getAttribute("opts")); + const directive = this.getAttribute("client"); + if (Astro[directive] === void 0) { + window.addEventListener(\`astro:\${directive}\`, () => this.start(), { once: true }); + return; + } + Astro[directive]( + async () => { + const rendererUrl = this.getAttribute("renderer-url"); + const [componentModule, { default: hydrator }] = await Promise.all([ + import(this.getAttribute("component-url")), + rendererUrl ? import(rendererUrl) : () => () => { + } + ]); + const componentExport = this.getAttribute("component-export") || "default"; + if (!componentExport.includes(".")) { + this.Component = componentModule[componentExport]; + } else { + this.Component = componentModule; + for (const part of componentExport.split(".")) { + this.Component = this.Component[part]; + } + } + this.hydrator = hydrator; + return this.hydrate; + }, + opts, + this + ); + } + attributeChangedCallback() { + if (this.hydrator) + this.hydrate(); + } + }, _a.observedAttributes = ["props"], _a) + ); + } +}`;function fa(e){return e._metadata.hasHydrationScript?!1:e._metadata.hasHydrationScript=!0}var xt={idle:pa,load:la,only:da,media:ca,visible:ma};function xa(e,t){return e._metadata.hasDirectives.has(t)?!1:(e._metadata.hasDirectives.add(t),!0)}function ht(e){if(!(e in xt))throw new Error(`Unknown directive: ${e}`);return xt[e]}function ha(e,t){switch(e){case"both":return`