UNPKG

next

Version:

The React Framework

1 lines 503 kB
(()=>{var __webpack_modules__={7315:(e,t,r)=>{"use strict";e.exports={FileSystemCache:r(4669),MaxAge:r(6564),oneBehindFetch:r(8414),log:r(277),isAmp:r(3471)}},4669:(e,t,r)=>{"use strict";const i=r(7147).promises;const{existsSync:n,mkdirSync:s}=r(7147);const a=r(6113);const o=r(2037);const c=r(277);const l=r(7330);const u=r(1017);const f={log:c,maxItems:50};class FileSystemCache{static create(e={}){const t=Object.assign(f,e);try{if(!t.baseDir){t.baseDir=u.join(o.tmpdir(),"ampproject-toolbox-optimizer")}if(!n(t.baseDir)){s(t.baseDir)}}catch(e){c.debug("No filesystem access, falling back to in-memory cache only",e);return new l(t.maxItems)}return new FileSystemCache(t)}constructor(e){this.opts=e;this.cache=new l(e.maxItems)}async get(e,t=null){let r=this.cache.get(e);if(r){return r}const n=this.createCacheFileName(e);try{const t=await i.readFile(n,"utf-8");r=JSON.parse(t);this.cache.set(e,r)}catch(e){r=t}return r}async set(e,t){try{this.cache.set(e,t);const r=this.createCacheFileName(e);return i.writeFile(r,JSON.stringify(t,null,""),"utf-8")}catch(e){this.opts.log.error("Could not write cache file",e)}}async clear(){const e=this.opts.baseDir;if(!n(e)){return}let t=await i.readdir(e,{withFileTypes:true});await Promise.all(t.map((t=>{let r=u.join(e,t.name);return t.isFile()&&t.name.endsWith(".json")?i.unlink(r):Promise.resolve()})))}createCacheFileName(e){const t=a.createHash("md5").update(e).digest("hex");return u.join(this.opts.baseDir,t+".json")}async deleteDir_(e){let t=await i.readdir(e,{withFileTypes:true});await Promise.all(t.map((t=>{let r=u.join(e,t.name);return t.isDirectory()?this.deleteDir_(r):i.unlink(r)})));await i.rmdir(e)}}e.exports=FileSystemCache},3471:e=>{"use strict";const t="<html";e.exports=function isAmp(e){let r=e.indexOf(t);if(r===-1){return false}r+=t.length;const i=e.indexOf(">",r);if(i===-1){return false}let n=e.substring(r,i).split(/\s+/);n=n.map((e=>e.split("=")[0]));return n.includes("amp")||n.includes("⚡")}},277:e=>{"use strict";class Log{constructor(e="",t=false,r=console){this.tag_=e;this.verbose_=t;this.prefix_=e?this.inverse_(e):"";this.output_=r}debug(e,...t){if(!this.verbose_){return}this.log_(this.output_.log,this.dim_(e),t)}log(e,...t){this.info(e,...t)}info(e,...t){this.log_(this.output_.log,e,...t)}success(e,...t){this.log_(this.output_.log,this.green_("SUCCESS "+e),t)}warn(e,...t){this.log_(this.output_.warn,this.yellow_("WARNING "+e),t)}error(e,...t){this.output_.log("\n");this.log_(this.output_.error,this.red_("ERROR "+e),t);this.output_.log("\n")}verbose(e=true){this.verbose_=!!e}tag(e){if(this.tag_){e=this.tag_+" "+e}return new Log(e,this.verbose_,this.output_)}log_(e,t,r){if(this.prefix_){t=this.prefix_+" "+t}if(r){e(...[t].concat(r))}else{e(t)}}inverse_(e){return`${e}`}dim_(e){return`${e}`}green_(e){return`${e}`}yellow_(e){return`${e}`}red_(e){return`${e}`}}e.exports=new Log},6564:e=>{"use strict";const t={value:0,isExpired:()=>true};class MaxAge{static zero(){return t}static parse(e){if(!e){return MaxAge.zero()}const t=e.match(/max-age=([0-9]+)[^0-9]?/i);if(!t){return MaxAge.zero()}return MaxAge.create(t[1])}static create(e){if(!Number.isInteger(e)){e=parseInt(e,10)}return new MaxAge(Date.now(),e)}static fromObject(e,t){return new MaxAge(e,t)}constructor(e,t){this.timestampInMs_=e;this.value=t}isExpired(e=Date.now()){const t=this.value*1e3;return this.timestampInMs_+t<e}toObject(){return{timestampInMs:this.timestampInMs_,maxAge:this.maxAge}}}e.exports=MaxAge},8414:(e,t,r)=>{"use strict";let i=r(3114);const n=r(6564);const s=new Map;async function oneBehindFetch(e,t){let r=s.get(e);if(!r){r={maxAge:Promise.resolve(n.zero())};s.set(e,r)}const a=await r.maxAge;if(!a.isExpired()){const e=await r.responsePromise;return e.clone()}const o=r.responsePromise;const c=i(e,t);r={responsePromise:c,maxAge:c.then((e=>n.parse(e.headers.get("cache-control"))))};s.set(e,r);const l=o||c;const u=await l;return u.clone()}oneBehindFetch.clearCache=()=>s.clear();oneBehindFetch.setDelegate=e=>i=e;e.exports=oneBehindFetch},8483:(e,t,r)=>{"use strict";const{DomTransformer:i,TRANSFORMATIONS_AMP_FIRST:n,TRANSFORMATIONS_PAIRED_AMP:s,TRANSFORMATIONS_MINIMAL:a,DEFAULT_CONFIG:o}=r(3338);const c=r(2547);e.exports={create:(e=o)=>new i(e),TRANSFORMATIONS_AMP_FIRST:n,TRANSFORMATIONS_MINIMAL:a,TRANSFORMATIONS_PAIRED_AMP:s,DEFAULT_CONFIG:o,NodeUtils:c}},8846:(e,t,r)=>{"mode strict";const{hasAttribute:i}=r(2547);e.exports={AMP_TAGS:["amp","⚡","⚡4ads","amp4ads","⚡4email","amp4email"],AMP_CACHE_HOST:"https://cdn.ampproject.org",AMP_VALIDATION_RULES_URL:"https://cdn.ampproject.org/v0/validator.json",AMP_FORMATS:["AMP","AMP4EMAIL","AMP4ADS"],AMP_RUNTIME_CSS_PATH:"/v0.css",appendRuntimeVersion:(e,t)=>e+"/rtv/"+t,isTemplate:e=>{if(!e){return false}if(e.tagName==="template"){return true}if(e.tagName==="script"&&i(e,"template")&&e.attribs.template==="amp-mustache"){return true}return false},isAmpStory:e=>{for(const t of e.children){if(isAmpScriptImport(t)&&t.attribs["custom-element"]==="amp-story"){return true}}return false}};function isAmpScriptImport(e){if(e.tagName!=="script"){return false}if(!e.attribs){return false}const t=e.attribs["custom-element"]||e.attribs["custom-template"]||"";if(!t.startsWith("amp-")){return false}return true}},3338:(e,t,r)=>{function __ncc_wildcard$0(e){if(e==="AddAmpLink")return r(4311);else if(e==="AddBlurryImagePlaceholders")return r(4949);else if(e==="AddMandatoryTags")return r(8256);else if(e==="AddTransformedFlag")return r(9494);else if(e==="AmpBoilerplateErrorHandler")return r(4975);else if(e==="AmpBoilerplateTransformer")return r(9097);else if(e==="AmpScriptCsp")return r(5557);else if(e==="ApplyCommonAttributes")return r(6070);else if(e==="ApplyLayout")return r(9464);else if(e==="AutoExtensionImporter")return r(5414);else if(e==="GoogleFontsPreconnect")return r(5141);else if(e==="Markdown")return r(9433);else if(e==="MinifyHtml")return r(1031);else if(e==="OptimizeAmpBind")return r(8046);else if(e==="OptimizeHeroImages")return r(6037);else if(e==="OptimizeImages")return r(714);else if(e==="PreloadHeroImage")return r(743);else if(e==="PreloadImages")return r(3842);else if(e==="PruneDuplicateResourceHints")return r(3144);else if(e==="RemoveAmpAttribute")return r(1865);else if(e==="RemoveCspNonce")return r(9401);else if(e==="ReorderHeadTransformer")return r(707);else if(e==="RewriteAmpUrls")return r(7185);else if(e==="SeparateKeyframes")return r(2079);else if(e==="ServerSideRendering")return r(4626)}"use strict";const i=r(3484);const n=r(255);let s=r(3114);const a=r(4178);const o=r(2412);const c=r(351);const l=["AddMandatoryTags","Markdown","AutoExtensionImporter","OptimizeImages","OptimizeHeroImages","OptimizeAmpBind","ServerSideRendering","AmpBoilerplateTransformer","RewriteAmpUrls","AmpBoilerplateErrorHandler","GoogleFontsPreconnect","PruneDuplicateResourceHints","AddBlurryImagePlaceholders","SeparateKeyframes","ReorderHeadTransformer","AddTransformedFlag","MinifyHtml","AmpScriptCsp"];const u=["AutoExtensionImporter","AddAmpLink","OptimizeImages","OptimizeHeroImages","OptimizeAmpBind","ServerSideRendering","RemoveAmpAttribute","AmpBoilerplateTransformer","RewriteAmpUrls","AmpBoilerplateErrorHandler","GoogleFontsPreconnect","PruneDuplicateResourceHints","AddBlurryImagePlaceholders","SeparateKeyframes","AddTransformedFlag","ReorderHeadTransformer","MinifyHtml","AmpScriptCsp"];const f=["OptimizeImages","OptimizeHeroImages","OptimizeAmpBind","ServerSideRendering","AmpBoilerplateTransformer","AmpBoilerplateErrorHandler","RewriteAmpUrls","GoogleFontsPreconnect","PruneDuplicateResourceHints","ReorderHeadTransformer","AddTransformedFlag"];const d={cache:c,fetch:s,log:n,profile:false,profiler:e=>{console.time(e);return()=>{console.timeEnd(e)}},transformations:l,verbose:false};class DomTransformer{constructor(e=d){this.setConfig(e)}async transformHtml(e,t){async function transform(){const r=await this.doProfile("parsing",(()=>i.parse(e)));await this.doProfile("transform",(()=>this.transformTree(r,t)));return this.doProfile("serialization",(()=>i.serialize(r)))}return await this.doProfile("overall",(()=>transform.call(this)))}async doProfile(e,t){if(!this.config.profile){return t()}const r=this.config.profiler(e);try{return await t()}finally{r()}}async transformTree(e,t={}){n.verbose(t.verbose||false);const r=await o(this.config,t);for(const t of this.transformers_){const i=this.getTransformerId(t);await this.doProfile(i,(()=>t.transform(e,r)))}}setConfig(e){this.config=Object.assign({},d,e);if(!this.config.runtimeVersion){this.config.runtimeVersion=new a(this.config.fetch)}n.verbose(this.config.verbose);this.initTransformers_(this.config)}initTransformers_(e){this.transformers_=e.transformations.map((t=>{if(typeof t==="string"){t=__ncc_wildcard$0(t)}return new t(e)}))}getTransformerId(e){return e.constructor?e.constructor.name:"custom"}}e.exports={DomTransformer:DomTransformer,DEFAULT_CONFIG:d,TRANSFORMATIONS_AMP_FIRST:l,TRANSFORMATIONS_PAIRED_AMP:u,TRANSFORMATIONS_MINIMAL:f}},9170:e=>{"mode strict";e.exports={isRenderDelayingExtension:function(e){if(e.tagName!=="script"){return false}const t=e.attribs["custom-element"];return t==="amp-dynamic-css-classes"||t==="amp-experiment"||t==="amp-story"},isCustomElement:function(e){return e.tagName&&e.tagName.startsWith("amp-")}}},7041:e=>{"use strict";function findMetaViewport(e){for(let t=e.firstChild;t!==null;t=t.nextSibling){if(t.tagName==="meta"&&t.attribs.name==="viewport"){return t}}return null}function findRuntimeScript(e){for(let t=e.firstChild;t!==null;t=t.nextSibling){if(t.tagName==="script"&&t.attribs.src&&t.attribs.src.match(/^https:\/\/.+\/v0(\.js|\.mjs)$/)){return t}}return null}function skipNodeAndChildren(e){if(!e){return null}else if(e.nextSibling){return e.nextSibling}return skipNodeAndChildren(e.parent)}e.exports={findMetaViewport:findMetaViewport,findRuntimeScript:findRuntimeScript,skipNodeAndChildren:skipNodeAndChildren}},2547:(e,t,r)=>{"use strict";const{Element:i,DataNode:n}=r(945);const{removeElement:s,append:a,prepend:o}=r(9065);const nextNode=function(e){const t=e.firstChild;if(t){return t}let r=e;while(r){const e=r.nextSibling;if(e){return e}r=r.parent}return null};const remove=function(e){s(e)};const appendChild=function(e,t){if(!t){return}t.parent=e;if(e.children.push(t)!==1){const r=e.children[e.children.length-2];r.next=t;t.prev=r;t.next=null}};const insertBefore=function(e,t,r){if(r){o(r,t);return}appendChild(e,t)};const insertAfter=function(e,t,r){if(r){a(r,t);return}appendChild(e,t)};const appendAll=function(e,t){if(!t){return}for(let r=0,i=t.length;r<i;r++){appendChild(e,t[r])}};const firstChildByTag=function(e,t){if(!e||!e.children){return null}return e.children.find((e=>e.tagName&&e.tagName===t))};const hasAttribute=function(e,t){if(!e.attribs)return false;return t in e.attribs};const setAttribute=function(e,t,r){if(!e.attribs)e.attribs={};e.attribs[t]=r};const move=function(e,t){remove(e);appendChild(t,e)};const createElement=(e,t)=>new i(e,t);const insertText=(e,t)=>{const r=new n("text",t);appendChild(e,r)};const createDocType=()=>{const e=new n("directive","!doctype html");return e};e.exports={appendChild:appendChild,appendAll:appendAll,insertAfter:insertAfter,nextNode:nextNode,remove:remove,createDocType:createDocType,createElement:createElement,insertText:insertText,insertBefore:insertBefore,hasAttribute:hasAttribute,setAttribute:setAttribute,firstChildByTag:firstChildByTag,move:move}},4056:e=>{"use strict";const t=["px","em","rem","vh","vw","vmin","vmax"];const r=["nodisplay","fixed","responsive","fixed-height","fill","container","flex-item","fluid","intrinsic"];const i=["fixed","fixed-height","responsive","fill","flex-item","intrinsic"];const n=cssLength("1",false,false);const s=cssLength("auto",true,false);const a=cssLength("44px",false,false);const o=cssLength("60px",false,false);function getLayoutClass(e){if(!e){return e}return"i-amphtml-layout-"+e}function calculateHeight(e,t,r){if((e===""||e==="fixed"||e==="fixed-height")&&!t.isSet){switch(r){case"amp-analytics":return n;case"amp-audio":return s;case"amp-pixel":return n;case"amp-social-share":return a;default:}}return t}function calculateWidth(e,t,r){if((e===""||e==="fixed")&&!t.isSet){switch(r){case"amp-analytics":return n;case"amp-audio":return s;case"amp-pixel":return n;case"amp-social-share":return o;default:}}return t}function isLayoutSizeDefined(e){return i.indexOf(e)>-1}function getCssLengthStyle(e,t){if(!e.isSet){return""}if(e.isAuto){return`${t}:auto;`}return`${t}:${e.numeral}${e.unit};`}function parseLayout(e){if(!e){return""}e=e.toLowerCase();if(r.indexOf(e)>-1){return e}return""}function calculateLayout(e,t,r,i,n){if(e!==""){return e}if(!t.isSet&&!r.isSet){return"container"}if(r.isSet&&(!t.isSet||t.isAuto)){return"fixed-height"}if(r.isSet&&t.isSet&&(i||n)){return"responsive"}return"fixed"}function cssLength(e,r=false,i=false){const n={isValid:false,isSet:false,isAuto:false,isFluid:false,numeral:Number.NaN,unit:"px"};if(e===null){n.isValid=true;return n}n.isSet=true;if(e==="auto"){n.isAuto=true;n.isValid=r;return n}if(e==="fluid"){n.isFluid=true;n.isValid=i;return n}const s=/(\d+(?:\.\d+)?)(.*)/;const a=s.exec(e);if(!a){return n}n.numeral=Number.parseFloat(a[1]);e=a[2];if(e===""){n.unit="px";n.isValid=true;return n}if(t.indexOf(e)>-1){n.isValid=true;n.unit=e}return n}function getLayoutSizeDefinedClass(){return"i-amphtml-layout-size-defined"}e.exports={parseLayout:parseLayout,cssLength:cssLength,getLayoutClass:getLayoutClass,calculateHeight:calculateHeight,calculateWidth:calculateWidth,isLayoutSizeDefined:isLayoutSizeDefined,getCssLengthStyle:getCssLengthStyle,calculateLayout:calculateLayout,getLayoutSizeDefinedClass:getLayoutSizeDefinedClass}},1150:(e,t,r)=>{"use strict";const i=r(7310).URL;const{join:n,resolve:s}=r(1017);const a="https://example.com";class PathResolver{constructor(e=""){if(typeof e==="function"){this.implementation=e}else{this.implementation=this.createStaticResolver(e)}}resolve(e,t){return this.implementation(e,t)}createStaticResolver(e){let t=false;try{new i(e);t=true}catch(e){}return r=>{try{if(t){return new i(r,e).toString()}else{return new i(r).toString()}}catch(e){}r=new i(r,a).pathname.substring(1);return s(n(e,r))}}}e.exports=PathResolver},859:(e,t,r)=>{"use strict";const{AMP_CACHE_HOST:i,appendRuntimeVersion:n}=r(8846);function calculateHost({ampUrlPrefix:e=i,ampRuntimeVersion:t,lts:r=false,rtv:s=false}){if(r&&s){throw new Error("lts flag is not compatible with runtime version parameter")}e=e.replace(/\/$/,"");if(t&&s){e=n(e,t)}else if(r){e+="/lts"}return e}e.exports={calculateHost:calculateHost}},3484:(e,t,r)=>{"use strict";const{Parser:i}=r(250);const{DomHandler:n,NodeWithChildren:s}=r(945);const{appendAll:a}=r(2547);const o=r(4404)["default"];const c={decodeEntities:false};class TreeParser{constructor(e){this.options=e}parse(e){return new Promise(((t,r)=>{const o=new n(((e,i)=>{if(e){r(e)}else{const e=new s("root",[]);a(e,i);t(e)}}),this.options);const c=new i(o,this.options);c.write(e.trim());c.end()}))}serialize(e){return o(e,{})}}e.exports=new TreeParser(c);e.exports.TreeParser=TreeParser},3741:e=>{"use strict";const isValidImageSrcURL=e=>{try{return new URL(e,"https://example.com").protocol.startsWith("http")}catch(e){return false}};e.exports={isValidImageSrcURL:isValidImageSrcURL}},351:(e,t,r)=>{"use strict";const{FileSystemCache:i}=r(7315);const n=r(1017);const s=r(255);const a=i.create({log:s,baseDir:n.join(__dirname,"..",".cache")});e.exports=a},5900:(e,t,r)=>{"use strict";const i=r(8653);const n=/^https?:\/\/|^\/\//i;function fetchImageDimensions(e){if(n.test(e)){return fetchImageDimensionsFromUrl(e)}return fetchImageDimensionsFromFile(e)}function fetchImageDimensionsFromUrl(e){return probe(e)}async function fetchImageDimensionsFromFile(e){if(!i("fs")){throw new Error("No access to the file system")}const t=r(7147);if(!t.existsSync(e)){throw new Error("Could not resolve file: "+e)}const n=t.createReadStream(e);return probe(n)}function probe(e){if(!i("probe-image-size")){throw new Error("Missing optional dependency: probe-image-size")}return r(5250)(e)}e.exports={fetchImageDimensions:fetchImageDimensions,fetchImageDimensionsFromFile:fetchImageDimensionsFromFile,fetchImageDimensionsFromUrl:fetchImageDimensionsFromUrl}},2412:(e,t,r)=>{"mode strict";const i="https://raw.githubusercontent.com/ampproject/amphtml/main/build-system/compile/bundles.config.extensions.json";const n=r(4934);const{MaxAge:s}=r(7315);const{AMP_CACHE_HOST:a,AMP_RUNTIME_CSS_PATH:o,AMP_VALIDATION_RULES_URL:c,appendRuntimeVersion:l}=r(8846);const u="validator-rules";const f=10*60;let d=false;async function fetchRuntimeParameters(e,t={}){const r=Object.assign({},t);r.verbose=t.verbose||e.verbose||false;await initRuntimeVersion(r,t,e);await initRuntimeStyles(r,e);await initValidatorRules(r,t,e);return r}async function initValidatorRules(e,t,r){try{e.validatorRules=t.validatorRules||r.validatorRules||await fetchValidatorRulesFromCache_(r)}catch(e){r.log.error("Could not fetch validator rules",e)}try{e.componentVersions=t.componentVersions||r.componentVersions||await fetchComponentVersionsFromCache_(r,e)}catch(t){r.log.error("Could not fetch latest component versions from amp.dev");r.log.verbose(t);e.componentVersions=[]}}async function fetchComponentVersionsFromCache_(e,t){const i=`component-versions-${t.ampRuntimeVersion}`;let n=await readFromCache_(e,i);if(!n){try{n=await fetchComponentVersions_(e,t);writeToCache_(e,i,n)}catch(t){e.log.warn(t.message);n=r(8649)}}return n}async function fetchComponentVersions_(e,t){const r=t.ampRuntimeVersion.substring(2);const n=`https://raw.githubusercontent.com/ampproject/amphtml/${r}/build-system/compile/bundles.config.extensions.json`;const s=await e.fetch(n);if(!s.ok){throw new Error(`Failed fetching latest component versions from ${i} with status: ${s.status}`)}return s.json()}async function fetchValidatorRulesFromCache_(e){let t=await readFromCache_(e,"validator-rules");let r;if(!t){r=await fetchValidatorRules_(e);e.log.debug("Downloaded AMP validation rules");writeToCache_(e,u,r.raw)}else{r=await n.fetch({rules:t})}return r}async function fetchValidatorRules_(e){const t=await e.fetch(c);if(!t.ok){return null}return n.fetch({rules:await t.json()})}async function initRuntimeStyles(e,t){try{e.ampRuntimeStyles=e.ampRuntimeStyles||await fetchAmpRuntimeStyles_(t,e.ampUrlPrefix,e.ampRuntimeVersion)}catch(e){t.log.error("Could not fetch AMP runtime CSS",e)}}async function initRuntimeVersion(e,t,r){e.lts=t.lts||r.lts||false;e.rtv=t.rtv||r.rtv||false;let{ampUrlPrefix:i,ampRuntimeVersion:n,lts:s}=e;if(s&&n){r.log.warn("`ampRuntimeVersion` and `lts` cannot be defined at the same time. Using LTS version.");n=""}try{e.ampRuntimeVersion=n||await fetchAmpRuntimeVersion_({config:r,ampUrlPrefix:i,lts:s})}catch(e){r.log.error("Could not fetch latest AMP runtime version",e)}}async function fetchAmpRuntimeVersion_(e){const t=`version-${e.ampUrlPrefix}-${e.lts}`;let r=await readFromCache_(e.config,t);if(!r){r=await fetchLatestRuntimeData_(e,t);e.config.log.debug("Downloaded AMP runtime v"+r.version)}else if(s.fromObject(r.maxAge).isExpired()){fetchLatestRuntimeData_(t,e)}return r.version}async function fetchLatestRuntimeData_({config:e,ampUrlPrefix:t,lts:r},i=null){let n;n={version:await e.runtimeVersion.currentVersion({ampUrlPrefix:t,lts:r}),maxAge:s.create(f).toObject()};if(!n.version&&t!==a){e.log.error(`Could not download runtime version from ${t}. Falling back to ${a}`);n=await fetchLatestRuntimeData_({config:e,ampUrlPrefix:a,lts:r},i)}else if(n.version&&i){writeToCache_(e,i,n)}return n}async function fetchAmpRuntimeStyles_(e,t,r){if(t&&!isAbsoluteUrl_(t)){e.log.warn(`AMP runtime styles cannot be fetched from relative ampUrlPrefix, please use the 'ampRuntimeStyles' parameter to provide the correct runtime style. Falling back to latest v0.css on ${a}`);t=a;r=r||await e.runtimeVersion.currentVersion()}const i=l(t||a,r)+o;const n=await downloadAmpRuntimeStyles_(e,i);if(!n){e.log.error(`Could not download ${i}. Falling back to latest v0.css.`);if(t||r){return fetchAmpRuntimeStyles_(e,a,await e.runtimeVersion.currentVersion())}else{return""}}return n}async function downloadAmpRuntimeStyles_(e,t){let r;if(e.cache!==false){r=await readFromCache_(e,t)}if(!r){const i=await e.fetch(t);if(!i.ok){return null}r=await i.text();if(!r.includes("i-amphtml-ssr")){r+=`amp-img[i-amphtml-ssr]:not(.i-amphtml-element):not([layout=container])>*{display: block;}`}e.log.debug(`Downloaded AMP runtime styles from ${t}`);if(e.cache!==false){writeToCache_(e,t,r)}}return r}function isAbsoluteUrl_(e){try{new URL(e);return true}catch(e){return false}}function readFromCache_(e,t){if(e.cache===false){return null}try{return e.cache.get(t)}catch(t){if(!d){e.log.warn("Could not read from cache",t);d=true}}}function writeToCache_(e,t,r){if(e.cache===false){return}try{e.cache.set(t,r)}catch(t){if(!d){e.log.warn("Could not write to cache",t);d=true}}}e.exports=fetchRuntimeParameters},8084:e=>{const t={"&":"\\u0026",">":"\\u003e","<":"\\u003c","\u2028":"\\u2028","\u2029":"\\u2029"};const r=/[&><\u2028\u2029]/g;e.exports=function htmlEscapeJsonString(e){return e.replace(r,(e=>t[e]))}},8653:e=>{function isDependencyInstalled(e){try{require.resolve(e);return true}catch(e){return false}}e.exports=isDependencyInstalled},255:(e,t,r)=>{"use strict";const{log:i}=r(7315);e.exports=i.tag("AMP Optimizer")},7199:e=>{"use strict";let t;let r;const parseSizes=e=>{const t={defaultValue:"",values:[]};if(!e){return t}const r=e.trim().split(/\s*,\s*/);for(let i=0;i<r.length;i++){const n=r[i];if(i===r.length-1){t.defaultValue=n.trim()}else{const r=n.split(/\)\s+/);if(r.length!==2){throw new Error(`Invalid sizes definition '${e}'`)}t.values.push({media:`${r[0]})`,size:r[1]})}}return t};e.exports=parseSizes},4311:(e,t,r)=>{"use strict";const{firstChildByTag:i,createElement:n,appendChild:s}=r(2547);class AddAmpLink{transform(e,t){if(!t.ampUrl)return;const r=i(e,"html");if(!r)return;const a=i(r,"head");if(!a)return;const o=n("link",{rel:"amphtml",href:t.ampUrl});s(a,o)}}e.exports=AddAmpLink},4949:(e,t,r)=>{const i=r(8653);const{createElement:n,appendChild:s,nextNode:a,firstChildByTag:o}=r(2547);const{URL:c}=r(7310);const{skipNodeAndChildren:l}=r(7041);const u=r(1150);const f=60;const d=100;const p=30;const h=-1;const{isTemplate:m}=r(8846);const g={"#":"%23","%":"%25",":":"%3A","<":"%3C",">":"%3E",'"':"'"};const b=new RegExp(Object.keys(g).join("|"),"g");function escaper(e){return g[e]}class AddBlurryImagePlaceholders{constructor(e){this.log_=e.log.tag("AddBlurryImagePlaceholders");this.blurredPlaceholders_=!!e.blurredPlaceholders;if(!this.blurredPlaceholders_){this.log_.debug("disabled")}this.missingDependencies_=false;if(!i("jimp")||!i("lru-cache")){if(this.blurredPlaceholders_){this.log_.warn("jimp and lru-cache need to be installed via `npm install jimp lru-cache` "+"for this transformer to work")}this.blurredPlaceholders_=false;this.missingDependencies_=true;return}this.jimp=r(4645);this.maxBlurredPlaceholders_=e.maxBlurredPlaceholders||d;this.pathResolver_=new u(e.imageBasePath);const t=e.blurredPlaceholdersCacheSize||p;if(t===h){this.log_.debug("caching all placeholders");this.cache_=new Map}else if(t>0){const e=r(7330);this.log_.debug("using LRU cache for regularily used placeholders",t);this.cache_=new e({max:t})}else{this.log_.debug("caching disabled")}}transform(e,t){if(!t.blurredPlaceholders&&!this.blurredPlaceholders_||this.missingDependencies_){return}const r=o(e,"html");const i=o(r,"body");const n=[];let c=0;for(let e=i;e!==null;e=a(e)){const{tagName:r}=e;let i;if(m(e)){e=l(e);continue}if(r==="amp-img"){i=e.attribs.src}if(r==="amp-video"&&e.attribs.poster){i=e.attribs.poster}if(this.shouldAddBlurryPlaceholder_(e,i,r)){c++;const r=this.addBlurryPlaceholder_(i,t).then((t=>{e.attribs["i-amphtml-ssr"]="";e.attribs.noloading="";s(e,t)}));n.push(r);if(c>=this.maxBlurredPlaceholders_){break}}}return Promise.all(n)}async addBlurryPlaceholder_(e,t){const r=n("img",{class:"i-amphtml-blurry-placeholder",placeholder:"",src:e,alt:""});try{const i=await this.getCachedDataURI(e,t);let n=`<svg xmlns="http://www.w3.org/2000/svg"\n xmlns:xlink="http://www.w3.org/1999/xlink"\n viewBox="0 0 ${i.width} ${i.height}">\n <filter id="b" color-interpolation-filters="sRGB">\n <feGaussianBlur stdDeviation=".5"></feGaussianBlur>\n <feComponentTransfer>\n <feFuncA type="discrete" tableValues="1 1"></feFuncA>\n </feComponentTransfer>\n </filter>\n <image filter="url(#b)" x="0" y="0"\n height="100%" width="100%"\n xlink:href="${i.src}">\n </image>\n </svg>`;n=n.replace(/\s+/g," ");n=n.replace(/> </g,"><");n=n.replace(b,escaper);r.attribs.src="data:image/svg+xml;charset=utf-8,"+n;this.log_.debug(e,"[SUCCESS]")}catch(t){this.log_.debug(e,"[FAIL]");this.log_.error(t.message)}return r}getCachedDataURI(e,t){const r=this.pathResolver_.resolve(e,t);if(this.cache_){const t=this.cache_.get(r);if(t){this.log_.debug(e,"[CACHE HIT]");return t}this.log_.debug(e,"[CACHE MISS]")}const i=this.getDataURI_(r);if(this.cache_){this.cache_.set(r,i)}return i}async getDataURI_(e){const t=/^https?:\/\//.test(e)?{headers:{"User-Agent":"AMP Optimizer"},url:e}:e;const r=await this.jimp.read(t);const i=this.getBitmapDimensions_(r.bitmap.width,r.bitmap.height);r.resize(i.width,i.height,this.jimp.RESIZE_BEZIER);const n={src:await r.getBase64Async("image/png"),width:i.width,height:i.height};return n}getBitmapDimensions_(e,t){const r=e/t;let i=f/r;i=Math.sqrt(i);const n=f/i;return{width:Math.round(n),height:Math.round(i)}}hasPlaceholder_(e){return e.childNodes.find((e=>e.attribs&&e.attribs.placeholder!==undefined))!==undefined}shouldAddBlurryPlaceholder_(e,t,r){if(!t){return false}if(this.hasPlaceholder_(e)){return false}const i=new c(t,"https://example.com");if(!i.pathname.endsWith(".jpg")&&!i.pathname.endsWith("jpeg")){return false}if(e.attribs.noloading!=null){return false}const n=r=="amp-video";const s=r=="amp-img"&&(e.attribs.layout=="intrinsic"||e.attribs.layout=="responsive"||e.attribs.layout=="fill");return n||s}}e.exports=AddBlurryImagePlaceholders},8256:(e,t,r)=>{"use strict";const{move:i,insertText:n,appendChild:s,insertBefore:a,createDocType:o,createElement:c,firstChildByTag:l}=r(2547);const{AMP_FORMATS:u,AMP_TAGS:f}=r(8846);const d="AMP";const p="data-auto";const h={AMP:[{matcher:{tagName:"meta",attribs:{charset:"utf-8"}},node:{tagName:"meta",attribs:{charset:"utf-8"}}},{matcher:{tagName:"meta",attribs:{name:"viewport"}},node:{tagName:"meta",attribs:{name:"viewport",content:"width=device-width,minimum-scale=1,initial-scale=1"}}},{matcher:{tagName:"noscript"},node:{tagName:"noscript",children:[{tagName:"style",attribs:{"amp-boilerplate":""},text:"body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}"}]}},{matcher:{tagName:"style",attribs:{"amp-boilerplate":""}},node:{tagName:"style",attribs:{"amp-boilerplate":""},text:"body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}"}},{matcher:{tagName:"script",attribs:{src:/^https:\/\/.+\/v0\.js$/}},node:{tagName:"script",attribs:{async:"",src:"https://cdn.ampproject.org/v0.js"}}},{matcher:{tagName:"link",attribs:{rel:"canonical"}},node:{tagName:"link",attribs:{rel:"canonical",href:(e,t)=>{if(!e.canonical){t.warn("No canonical param is given. Setting canonical href to `.`");e.canonical="."}return e.canonical}}}}]};class AddMandatoryTags{constructor(e){this.enabled=e.autoAddBoilerplate!==false&&e.autoAddMandatoryTags!==false;this.format=e.format||d;this.log_=e.log.tag("AddMandatoryTags")}async transform(e,t){if(!this.enabled){return}if(!u.includes(this.format)){this.log_.error("Unknown AMPHTML format",this.format);return}const r=h[this.format];if(!r){this.log_.info("Unsupported AMP format",this.format);return}let i=l(e,"html");if(!i){i=this.createHtml5Document(e)}let n=e.children.find((e=>e.type==="directive"&&e.name==="!doctype"));if(!n){n=o();a(e,n,e.firstChild)}if(!Object.keys(i.attribs).some((e=>f.includes(e)))){i.attribs[this.format.toLowerCase()]=""}let d=l(i,"head");if(!d){d=c("head");s(i,d)}const p=new Set(r);let m=d.firstChild;while(m){if(m.tagName){p.forEach((e=>{if(this.matchSpec(e.matcher,m)){p.delete(e)}}))}m=m.nextSibling}for(const e of p){this.addNode(d,e.node,t)}}matchSpec(e,t){if(e.tagName!==t.tagName){return false}if(!e.attribs){return true}for(const[r,i]of Object.entries(e.attribs)){const e=t.attribs[r];if(i instanceof RegExp){if(!i.test(e)){return false}}else if(e!==i){return false}}return true}addNode(e,t,r){const i={};i[p]="";const n=c(t.tagName,i);this.addAttributes(t,n,r);this.addChildren(t,n,r);this.addText(t,n,r);s(e,n)}addText(e,t,r){if(!e.text){return}let i;if(typeof e.text==="function"){i=e.text(r,this.log_)}else{i=e.text}n(t,i)}addChildren(e,t,r){if(!e.children){return}for(const i of e.children){this.addNode(t,i,r)}}addAttributes(e,t,r){if(!e.attribs){return}for(const[i,n]of Object.entries(e.attribs)){if(typeof n==="function"){t.attribs[i]=n(r,this.log_)}else{t.attribs[i]=n}}}createHtml5Document(e){const t=c("html",{});const r=this.createOrMoveElement(e,t,"head");const i=this.createOrMoveElement(e,t,"body");this.copyTagsToHeadAndBody(e,r,i);s(e,t);return t}createOrMoveElement(e,t,r){const n=l(e,r)||c(r);i(n,t);return n}copyTagsToHeadAndBody(e,t,r){let n=e.firstChild;while(n){const e=n;n=e.next;if(e.type==="directive"){}else if(e.tagName==="title"){i(e,t)}else{i(e,r)}}}}e.exports=AddMandatoryTags},9494:(e,t,r)=>{"use strict";const{firstChildByTag:i}=r(2547);class AddTransformedFlag{transform(e){const t=i(e,"html");if(!t)return;t.attribs.transformed="self;v=1"}}e.exports=AddTransformedFlag},4975:(e,t,r)=>{"use strict";const{appendChild:i,createElement:n,hasAttribute:s,firstChildByTag:a,insertText:o}=r(2547);const c="document.querySelector(\"script[src*='/v0.js']\").onerror=function(){"+"document.querySelector('style[amp-boilerplate]').textContent=''}";const l="[].slice.call(document.querySelectorAll("+"\"script[src*='/v0.js'],script[src*='/v0.mjs']\")).forEach("+"function(s){s.onerror="+"function(){"+"document.querySelector('style[amp-boilerplate]').textContent=''"+"}})";class AmpBoilerplateErrorHandler{transform(e,t){const r=a(e,"html");if(!r){return}if(s(r,"i-amphtml-no-boilerplate")){return}const u=a(r,"head");if(!u){return}const f=n("script",{"amp-onerror":""});if(t.esmModulesEnabled){o(f,l)}else{o(f,c)}i(u,f)}}e.exports=AmpBoilerplateErrorHandler},9097:(e,t,r)=>{"use strict";const{insertText:i,hasAttribute:n,firstChildByTag:s}=r(2547);class AmpBoilerplateTransformer{constructor(e){this.fetch_=e.fetch;this.runtimeVersion_=e.runtimeVersion;this.log_=e.log.tag("AmpBoilerplateTransformer")}transform(e,t){const r=s(e,"html");const n=s(r,"head");if(!n){return}const a=this._findAmpRuntimeStyle(n);if(!a){return}let{ampRuntimeVersion:o,ampRuntimeStyles:c}=t;if(!o||!c){this.log_.error("Missing parameters both ampRuntimeVersion and ampRuntimeStyles need to be present");return}a.attribs["i-amphtml-version"]=o;i(a,c)}_findAmpRuntimeStyle(e){let t=e.firstChild;while(t){if(n(t,"amp-runtime")){return t}t=t.nextSibling}return null}}e.exports=AmpBoilerplateTransformer},5557:(e,t,r)=>{"use strict";const{remove:i,appendChild:n,createElement:s,nextNode:a,firstChildByTag:o}=r(2547);const{calculateHash:c}=r(9874);class AmpScriptCsp{transform(e){const t=o(e,"html");if(!t)return;const r=o(t,"head");if(!r)return;const n=o(t,"body");if(!n)return;const s=this._findOrCreateCspMeta(r);const a=(s.attribs.content||"").trim().split(/\s+/);const l=new Set(a);l.delete("");const u=this._findAllInlineScripts(n);for(const e of u){const t=e.children[0]?e.children[0].data:"";l.add(c(t))}const f=Array.from(l).join(" ");if(f===""){i(s);return}s.attribs.content=f}_findAllInlineScripts(e){const t=[];let r=e;while(r!==null){if(r.tagName==="script"&&r.attribs.target==="amp-script"){t.push(r)}r=a(r)}return t}_findOrCreateCspMeta(e){for(let t=e.firstChild;t!==null;t=t.nextSibling){if(t.tagName==="meta"&&t.attribs.name==="amp-script-src"){return t}}const t=s("meta",{name:"amp-script-src"});n(e,t);return t}}e.exports=AmpScriptCsp},6070:(e,t,r)=>{"use strict";const i=r(7199);const{appendChild:n,createElement:s,insertText:a,hasAttribute:o}=r(2547);const{isCustomElement:c}=r(9170);const l="i-amp-";class MediaTransformer{constructor(){this.media=new Map}transform(e,t){let r=e.attribs.media.replace(/\s+/g," ");r=r.trim();if(!r){return false}if(r[0]==="("){r=`all and ${r}`}if(r.startsWith("not ")){r=r.substring(4)}else{r=`not ${r}`}this.addMedia(r,`#${t}`);return true}addMedia(e,t){let r=this.media.get(e);if(!r){r=[];this.media.set(e,r)}r.push(t)}toString(){let e="";for(const[t,r]of this.media.entries()){e+=`@media ${t}{${r.join(",")}{display:none}}`}return e}}class SizesTransformer{constructor(){this.sizes=[]}transform(e,t){if(!e.attribs.srcset){return false}const r=i(e.attribs.sizes);if(!r.defaultValue){return false}this.addSizes(t,r);return true}addSizes(e,t){this.sizes.push({id:e,defaultSize:t.defaultValue,sizes:t.values.reverse()})}toString(){let e="";for(const{sizes:t,defaultSize:r,id:i}of this.sizes){const n=`#${i}`;e+=`${n}{width:${r}}`;for(const r of t){e+=`@media ${r.media}{${n}{width:${r.size}}}`}}return e}}class HeightsTransformer{constructor(){this.heights=[]}transform(e,t){const r=i(e.attribs.heights);if(!r.defaultValue){return false}this.addHeights(t,r);return true}addHeights(e,t){this.heights.push({id:e,defaultHeight:t.defaultValue,heights:t.values.reverse()})}toString(){let e="";for(const{heights:t,defaultHeight:r,id:i}of this.heights){const n=`#${i}>:first-child`;e+=`${n}{padding-top:${r}}`;for(const r of t){e+=`@media ${r.media}{${n}{padding-top:${r.size}}}`}}return e}}class ApplyCommonAttributes{constructor(e){this.log=e;this.canRemoveBoilerplate=true;this.transformedNodesCounter=0;this.nodesToTransform=[];this.ids=new Set;this.attributeTransformations={media:new MediaTransformer,sizes:new SizesTransformer,heights:new HeightsTransformer}}addNode(e){if(!e.attribs){return}if(o(e,"id")){this.ids.add(e.attribs.id)}if(c(e)){this.nodesToTransform.push(e)}}apply(){for(const e of this.nodesToTransform){const t=this.getOrCreateId(e);let r=false;for(const[i,n]of Object.entries(this.attributeTransformations)){if(o(e,i)){try{r=r||n.transform(e,t)}catch(t){this.log.debug(`Cannot remove boilerplate. Failed transforming ${i}="${e.attribs[i]}".`,t);this.canRemoveBoilerplate=false}}}if(r){e.attribs.id=t}else{this.transformedNodesCounter--}}}applyToCustomStyles(e,t){const r=Object.values(this.attributeTransformations).join("");if(!r){return}if(!t){t=s("style",{"amp-custom":""});n(e,t)}if(t.children.length===0){a(t,"")}t.children[0].data+=r;for(const e of this.nodesToTransform){for(const t of Object.keys(this.attributeTransformations)){delete e.attribs[t]}}}getOrCreateId(e){if(o(e,"id")){return e.attribs.id}e.attribs=e.attribs||[];const t=l+this.transformedNodesCounter;this.transformedNodesCounter++;if(this.ids.has(t)){return this.getOrCreateId(e)}return t}}e.exports=ApplyCommonAttributes},9464:(e,t,r)=>{"use strict";const{hasAttribute:i,insertBefore:n,createElement:s,appendChild:a}=r(2547);const{parseLayout:o,cssLength:c,calculateHeight:l,calculateWidth:u,calculateLayout:f,getLayoutClass:d,isLayoutSizeDefined:p,getLayoutSizeDefinedClass:h}=r(4056);const m=["","nodisplay","fixed","fixed-height","responsive","container","fill","flex-item","fluid","intrinsic"];function isSupportedLayout(e){return m.indexOf(e)>-1}function getAttributeOrNull(e,t){return i(e,t)?e.attribs[t]:null}function addClass(e,t){const r=i(e,"class")?e.attribs.class.trim():"";e.attribs.class=r.length>0?r+" "+t:t}function apply(e,t,r,i){addClass(i,d(e));if(p(e)){addClass(i,h())}let n="";switch(e){case"nodisplay":i.attribs.hidden="hidden";break;case"fixed":n=`width:${t.numeral}${t.unit};height:${r.numeral}${r.unit};`;break;case"fixed-height":n=`height:${r.numeral}${r.unit};`;break;case"responsive":break;case"intrinsic":break;case"fill":case"container":break;case"fluid":n="width:100%;height:0;";addClass(i,"i-amphtml-layout-awaiting-size");break;case"flex-item":if(t.isSet){n=`width:${t.numeral}${t.unit};`}if(r.isSet){n+=`height:${r.numeral}${r.unit};`}break;default:}i.attribs.style=n+(i.attribs.style?i.attribs.style:"");if(i.attribs.style===""){delete i.attribs.style}i.attribs["i-amphtml-layout"]=e}function maybeAddSizerInto(e,t,r,i){if(!r.isSet||r.numeral===0||!i.isSet||r.unit!==i.unit){return}let s=null;if(t==="responsive"){s=createResponsiveSizer(r,i)}else if(t==="intrinsic"){s=createIntrinsicSizer(r,i)}if(s){const t=e.firstChild;n(e,s,t)}}function createResponsiveSizer(e,t){const r=t.numeral/e.numeral*100;const i=s("i-amphtml-sizer",{style:`display:block;padding-top:${parseFloat(r.toFixed(4))}%`});return i}function createIntrinsicSizer(e,t){const r=s("i-amphtml-sizer",{class:"i-amphtml-sizer"});const i=s("img",{alt:"","aria-hidden":"true",class:"i-amphtml-intrinsic-sizer",role:"presentation",src:"data:image/svg+xml;base64,"+Buffer.from(`<svg height="${t.numeral}" width="${e.numeral}" xmlns="http://www.w3.org/2000/svg" version="1.1"/>`).toString("base64")});a(r,i);return r}e.exports={applyLayout:function(e,t){const r=o(e.attribs.layout);const i=getAttributeOrNull(e,"width");const n=c(i,true,false);if(!n.isValid){t.debug("cannot perform SSR: invalid input width\n",i);return false}const s=getAttributeOrNull(e,"height");const a=c(s,true,r==="fluid");if(!a.isValid){t.debug("cannot perform SSR: invalid input height\n",s);return false}const d=l(r,a,e.tagName);const p=u(r,n,e.tagName);const h=f(r,p,d,getAttributeOrNull(e,"sizes"),getAttributeOrNull(e,"heights"));if(!isSupportedLayout(h)){t.debug("cannot perform SSR: unsupported layout",h);return false}if(h&&h==="responsive"){e.attribs.layout=h}apply(h,p,d,e);maybeAddSizerInto(e,h,p,d);return true}}},5414:(e,t,r)=>{"use strict";const{nextNode:i,insertAfter:n,createElement:s,firstChildByTag:a,hasAttribute:o}=r(2547);const{findMetaViewport:c,findRuntimeScript:l}=r(7041);const{AMP_FORMATS:u,AMP_CACHE_HOST:f}=r(8846);const d="bind";const p="data-amp-bind-";const h="AMP";const m=new Map([["lightbox","amp-lightbox-gallery"]]);const g=Array.from(m.values());class AutoExtensionImporter{constructor(e){this.enabled=e.autoExtensionImport!==false;this.format=e.format||h;this.log_=e.log.tag("AutoExtensionImporter");this.experimentBindAttributeEnabled=e.experimentBindAttribute===true;this.extensionVersions=e.extensionVersions||{}}createExtensionsSpec(e){const t=e.validatorRules;const r=new Map;for(const e of t.extensions){if(e.htmlFormat.includes(this.format)){r.set(e.name,{name:e.name,type:e.extensionType==="CUSTOM_TEMPLATE"?"custom-template":"custom-element",version:e.version.filter((e=>e!=="latest"))})}}const i=new Map;const n=new Map;const s=new Map;for(const e of t.getTagsForFormat(this.format)){const t=e.tagName.toLowerCase();if(t.startsWith("amp-")){let r=e.requiresExtension||[];r=r.filter((e=>!g.includes(e)));i.set(t,r)}const r=new Set;for(const i of e.attrs){if(m.has(i.name)){i.requiresExtension=[m.get(i.name)]}if(i.requiresExtension&&i.requiresExtension.length>0){const e=n.get(t)||[];e.push(i);n.set(t,e)}if(i.name.startsWith("[")){r.add(i.name.substring(1,i.name.length-1))}}s.set(t,r)}return{extensionsMap:r,tagToExtensionsMapping:i,tagToAttributeMapping:n,tagToBindAttributeMapping:s}}async transform(e,t){if(!this.enabled){return}if(!t.validatorRules){this.log_.error("Missing validation rules, cannot auto import extensions");return}if(!this.componentVersions){this.componentVersions={};for(const e of t.componentVersions){this.componentVersions[e.name]=e.latestVersion}}if(!this.extensionSpec_){this.extensionSpec_=this.createExtensionsSpec(t)}if(!u.includes(this.format)){this.log_.error("Unsupported AMPHTML format",this.format);return}const r=a(e,"html");if(!r)return;const i=a(r,"head");if(!i)return;const o=a(r,"body");if(!o)return;const d=new Set;const p=new Set;this.findExistingExtensionsAndExtensionsToImportInHead_(i,d,p);await this.findExtensionsToImportInBody_(o,d);if(d.length===0){return}let h=l(i);if(!h){h=c(i)}const m=f;for(const e of d){if(p.has(e)){continue}const t=this.extensionSpec_.extensionsMap.get(e.trim());this.log_.debug("auto importing",e);let r=this.calculateVersion(t,e);const a={async:"",src:`${m}/v0/${e}-${r}.js`};a[t.type]=e;const o=s("script",a);n(i,o,h);h=o}}calculateVersion(e,t){const r=this.extensionVersions[t];if(r){this.log_.debug("using custom version for",t,r);return r}const i=this.componentVersions[t];const n=e.version[e.version.length-1];if(n<i){return n}return i}findExistingExtensionsAndExtensionsToImportInHead_(e,t,r){let n=e;while(n){const e=this.getCustomElement_(n);if(e){r.add(e)}else if(n.tagName==="script"&&n.attribs["id"]==="amp-access"){t.add("amp-access");t.add("amp-analytics");const e=this.getJson(n);if(e.vendor==="laterpay"){t.add("amp-access-laterpay")}}else if(n.tagName==="script"&&n.attribs["id"]==="amp-subscriptions"){t.add("amp-subscriptions");t.add("amp-analytics");const e=this.getJson(n);if(e.services&&e.services.length){for(const r of e.services){if(r.serviceId==="subscribe.google.com"){t.add("amp-subscriptions-google")}}}}n=i(n)}}getJson(e){for(const t of e.children||[]){if(!t.data){continue}try{return JSON.parse(t.data)}catch(e){this.log_.error('Could not parse JSON in <script id="amp-access">',e.message)}}return{}}async findExtensionsToImportInBody_(e,t){let r=e;while(r!==null){if(r.tagName){this.addRequiredExtensionByTag_(r,t);this.addRequiredExtensionByAttributes_(r,t)}r=i(r)}}addRequiredExtensionByTag_(e,t){const r=this.extensionSpec_.tagToExtensionsMapping.get(e.tagName);if(r){r.forEach((e=>t.add(e)))}if(e.tagName==="template"&&e.attribs.type){t.add(e.attribs.type)}else if(e.tagName==="script"&&o(e,"template")){t.add(e.attribs.template)}else if(e.tagName==="input"&&o(e,"mask")){t.add("amp-inputmask")}}addRequiredExtensionByAttributes_(e,t){if(!e.tagName||!e.attribs){return}const r=this.extensionSpec_.tagToAttributeMapping;const i=r.get(e.tagName)||[];i.forEach((r=>{if(e.attribs[r.name]!==undefined){r.requiresExtension.forEach((e=>{t.add(e)}))}}));if(e.tagName==="form"){t.add("amp-form")}const n=this.extensionSpec_.tagToBindAttributeMapping;const s=Object.keys(e.attribs);if(s.some((e=>e.startsWith("[")||e.startsWith(p)))){t.add("amp-bind")}if(this.experimentBindAttributeEnabled){const r=n.get(e.tagName);let i=false;for(const n of s){if(!n.startsWith(d)){continue}const s=n.substring(d.length);if(r.has(s)){const t=`${p}${s}`;e.attribs[t]=e.attribs[n];delete e.attribs[n];i=true}if(i){t.add("amp-bind")}}}}getCustomElement_(e){if(e.tagName!=="script"){return""}const t=e.attribs["custom-element"]||e.attribs["custom-template"]||"";if(!t){return""}if(!t.startsWith("amp-")){return""}return t}}e.exports=AutoExtensionImporter},5141:(e,t,r)=>{"use strict";const{insertAfter:i,createElement:n,firstChildByTag:s}=r(2547);const{findMetaViewport:a}=r(7041);class GoogleFontsPreconnect{constructor(e){this.log_=e.log.tag("GoogleFontsPreconnect")}transform(e){const t=s(e,"html");if(!t){return}const r=s(t,"head");if(!r){return}for(let e=r.firstChild;e!==null;e=e.nextSibling){if(this.isGoogleFontsLinkNode_(e)){const e=n("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossorigin:""});const t=n("link",{rel:"dns-prefetch",href:"https://fonts.gstatic.com"});const s=a(r);i(r,e,s);this.log_.debug('adding <link rel="preconnect" href="'+e.attribs.href+'" crossorigin>');i(r,t,e);this.log_.debug('adding <link rel="dns-prefetch" href="'+t.attribs.href+'">');return}}}isGoogleFontsLinkNode_(e){return e.tagName==="link"&&e.attribs.rel==="stylesheet"&&e.attribs.href.startsWith("https://fonts.googleapis.com")}}e.exports=GoogleFontsPreconnect},9433:(e,t,r)=>{"use strict";const i=r(1150);const{fetchImageDimensions:n}=r(5900);const{remove:s,insertAfter:a,createElement:o,firstChildByTag:c,nextNode:l}=r(2547);const u="intrinsic";const f=320;class Markdown{constructor(e){this.log=e.log;this.enabled=!!e.markdown;this.pathResolver=new i(e.imageBasePath)}async transform(e,t){if(!this.enabled){return}const r=c(e,"html");if(!r){return}const i=c(r,"body");if(!i){return}let n=i;const s=[];while(n){const e=l(n);if(n.tagName==="img"){s.push(this.transformImg(n,t))}n=e}return Promise.all(s)}async transformImg(e,t){const r=e.attribs&&e.attribs.src;if(!r){return}const i=this.pathResolver.resolve(r,t);let o;try{o=await n(i)}catch(e){this.log.warn(e.message);return}const c=this.createAmpImgOrAmpAnim(o,e);a(e.parent,c,e);s(e)}createAmpImgOrAmpAnim(e,t){const r=e.type==="gif"?"amp-anim":"amp-img";const i=o(r,t.attribs);i.attribs.width=t.attribs.width||String(e.width);i.attribs.height=t.attribs.height||String(e.height);this.addLayout(i,e);return i}addLayout(e,t){if(t.width<f){return}e.attribs.layout=u}}e.exports=Markdown},1031:(e,t,r)=>{"use strict";const{minify:i}=r(6794);const{remove:n}=r(2547);const s=r(5438);const a=r(8084);const o=/^\s*__[a-bA-Z0-9_-]+__\s*$/;class MinifyHtml{constructor(e){this.opts={minify:e.minify!==false,minifyAmpScript:true,minifyJSON:true,collapseWhitespace:true,removeComments:true,canCollapseWhitespace:true,inBody:false,commentIgnorePattern:o};this.log=e.log.tag("MinifyHtml")}async transform(e){if(!this.opts.minify){return}const t=[];await this.minifyNode(e,this.opts,t);for(const e of t){n(e)}}async minifyNode(e,t,r){if(e.type==="text"){this.minifyTextNode(e,t,r)}else if(e.type==="comment"){this.minifyCommentNode(e,t,r)}else if(e.tagName==="script"){await this.minifyScriptNode(e,t)}const i=Object.assign({},t);if(t.canCollapseWhitespace&&!this.canCollapseWhitespace(e.tagName)){i.canCollapseWhitespace=false}if(e.tagName==="head"||e.tagName==="html"){i.inBody=false}else if(e.tagName==="body"){i.inBody=true}const n=[];for(const t of e.children||[]){n.push(this.minifyNode(t,i,r))}return Promise.all(n)}minifyTextNode(e,t,r){if(!e.data||!t.collapseWhitespace){return}if(t.canCollapseWhitespace){e.data=s(e.data)}if(!t.inBody){e.data=e.data.trim()}if(e.data.length===0){r.push(e)}}minifyCommentNode(e,t,r){if(!e.data||!t.removeComments){return}if(t.commentIgnorePattern.test(e.data)){return}r.push(e)}async minifyScriptNode(e,t){const r=this.isJson(e);const i=!r&&this.isInlineAmpScript(e);for(const n of e.children||[]){if(!n.data){continue}if(r&&t.minifyJSON){this.minifyJson(n)}else if(i&&t.minifyAmpScript){await this.minifyAmpScript(n)}}}async minifyAmpScript(e){try{const t=await i(e.data,{});if(t.error){this.log.warn("Could not minify inline amp-script",e.data,`${t.error.name}: ${t.error.message}`);return}e.data=t.code}catch(e){this.log.warn("Failed minifying inline amp-script",e)}}minifyJson(e){try{let t=JSON.stringify(JSON.parse(e.data),null,"");t=a(t);e.data=t}catch(t){this.log.warn("Invalid JSON",e.data)}}isInlineAmpScript(e){return e.attribs&&e.attribs.type==="text/plain"&&e.attribs.target==="amp-script"}isJson(e){return e.attribs&&(e.attribs.type==="application/json"||e.attribs.type==="application/ld+json")}canCollapseWhitespace(e){return"script"!==e&&"style"!==e&&"pre"!==e&&"textarea"!==e}canTrimWhitespace(e){return e!=="pre"&&e!=="textarea"}}e.exports=MinifyHtml},8046:(e,t,r)=>{const{nextNode:i,firstChildByTag:n,setAttribute:s}=r(2547);const{skipNodeAndChildren:a}=r(7041);const{isTemplate:o}=r(8846);class OptimizeAmpBind{constructor(e){this.log_=e.log.tag("OptimizeAmpBind");this.enabled_=e.optimizeAmpBind!==false;if(!this.enabled_){this.log_.debug("disabled")}}transform(e){if(!this.enabled_)return;const t=n(e,"html");if(!t)return;const r=n(t,"head");if(!r)return;if(!hasAmpBindScriptNode(r))return;s(t,"i-amphtml-binding","");for(let e=t;e!==null;e=i(e)){if(o(e)){e=a(e);continue}const{attribs:t}=e;if(!t)continue;for(const r in t){if(r.startsWith("data-amp-bind-")||r.startsWith("[")&&r.endsWith("]")){s(e,"i-amphtml-binding","");break}}}}}function hasAmpBindScriptNode(e){for(let t=e.firstChild;t!==null;t=t.nextSibling){if(t.tagName!=="script")continue;if(!t.attribs)continue;if(t.attribs["custom-element"]!=="amp-bind")continue;return true}return false}e.exports=OptimizeAmpBind},6037:(e,t,r)=>{"use strict";const{appendChild:i,createElement:n,hasAttribute:s,remove:a,insertAfter:o,nextNode:c,firstChildByTag:l}=r(2547);const{findMetaViewport:u,skipNodeAndChildren:f}=r(7041);const{isValidImageSrcURL:d}=r(3741);const{isTemplate:p,isAmpStory:h}=r(8846);const m=150;const g=2;class OptimizeHeroImage{constructor(e){this.log=e.log;this.enabled=e.optimizeHeroImages!==false||e.preloadHeroImage!==false;this.maxHeroImageCount=e.maxHeroImageCount||g;if(e.preloadHeroImage){this.log.info("`preloadHeroImage` option has been deprecated. Use `optimizeHeroImages` instead")}}async transform(e,t){if(t.preloadHeroImage){this.log.info("`preloadHeroImage` option has been deprecated. Use `optimizeHeroImages` instead")}if(!this.enabled||t.optimizeHeroImages===false||t.preloadHeroImage===false){return}const r=t.maxHeroImageCount||this.maxHeroImageCount;const i=l(e,"html");const n=l(i,"head");const s=l(i,"body");if(!s||!n)return;const a=this.findHeroImages(s);let o=u(n);let c=a.length;if(c>r){this.log.warn(`Found ${c} hero elements on the page, but the maximum is set to ${r}. The limit can be configured via the 'maxHeroImage' parameter.`);c=r}const f=h(n);for(let e=0;e<c;e++){const t=a[e];this.generatePreload(t,n,o);if(!f