next
Version:
The React Framework
1 lines • 158 kB
JavaScript
(()=>{var __webpack_modules__={6461:(t,e,r)=>{"use strict";t.exports={FileSystemCache:r(3312),MaxAge:r(7070),oneBehindFetch:r(534),log:r(6167),isAmp:r(4462)}},3312:(t,e,r)=>{"use strict";const i=r(7147).promises;const{existsSync:s,mkdirSync:n}=r(7147);const a=r(6113);const o=r(6167);const l=r(7330);const c=r(1017);const u={baseDir:c.join(__dirname,".cache"),log:o,maxItems:50};class FileSystemCache{static create(t={}){return new FileSystemCache(Object.assign(u,t))}constructor(t){this.opts=t;this.cache=new l(t.maxItems)}async get(t,e=null){let r=this.cache.get(t);if(r){return r}const s=this.createCacheFileName(t);try{const e=await i.readFile(s,"utf-8");r=JSON.parse(e);this.cache.set(t,r)}catch(t){r=e}return r}async set(t,e){try{this.cache.set(t,e);if(!s(this.opts.baseDir)){n(this.opts.baseDir)}const r=this.createCacheFileName(t);return i.writeFile(r,JSON.stringify(e,null,""),"utf-8")}catch(t){this.opts.log.error("Could not write cache file",t)}}async clear(){const t=this.opts.baseDir;if(!s(t)){return}let e=await i.readdir(t,{withFileTypes:true});await Promise.all(e.map((e=>{let r=c.join(t,e.name);return e.isFile()&&e.name.endsWith(".json")?i.unlink(r):Promise.resolve()})))}createCacheFileName(t){const e=a.createHash("md5").update(t).digest("hex");return c.join(this.opts.baseDir,e+".json")}async deleteDir_(t){let e=await i.readdir(t,{withFileTypes:true});await Promise.all(e.map((e=>{let r=c.join(t,e.name);return e.isDirectory()?this.deleteDir_(r):i.unlink(r)})));await i.rmdir(t)}}t.exports=FileSystemCache},4462:t=>{"use strict";const e="<html";t.exports=function isAmp(t){let r=t.indexOf(e);if(r===-1){return false}r+=e.length;const i=t.indexOf(">",r);if(i===-1){return false}let s=t.substring(r,i).split(/\s+/);s=s.map((t=>t.split("=")[0]));return s.includes("amp")||s.includes("⚡")}},6167:t=>{"use strict";class Log{constructor(t="",e=false,r=console){this.tag_=t;this.verbose_=e;this.prefix_=t?this.inverse_(t):"";this.output_=r}debug(t,...e){if(!this.verbose_){return}this.log_(this.output_.log,this.dim_(t),e)}log(t,...e){this.info(t,...e)}info(t,...e){this.log_(this.output_.log,t,...e)}success(t,...e){this.log_(this.output_.log,this.green_("SUCCESS "+t),e)}warn(t,...e){this.log_(this.output_.warn,this.yellow_("WARNING "+t),e)}error(t,...e){this.output_.log("\n");this.log_(this.output_.error,this.red_("ERROR "+t),e);this.output_.log("\n")}verbose(t=true){this.verbose_=!!t}tag(t){if(this.tag_){t=this.tag_+" "+t}return new Log(t,this.verbose_,this.output_)}log_(t,e,r){if(this.prefix_){e=this.prefix_+" "+e}if(r){t(...[e].concat(r))}else{t(e)}}inverse_(t){return`[7m${t}[0m`}dim_(t){return`[36m${t}[0m`}green_(t){return`[32m${t}[0m`}yellow_(t){return`[33m${t}[0m`}red_(t){return`[31m${t}[0m`}}t.exports=new Log},7070:t=>{"use strict";const e={value:0,isExpired:()=>true};class MaxAge{static zero(){return e}static parse(t){if(!t){return MaxAge.zero()}const e=t.match(/max-age=([0-9]+)[^0-9]?/i);if(!e){return MaxAge.zero()}return MaxAge.create(e[1])}static create(t){if(!Number.isInteger(t)){t=parseInt(t,10)}return new MaxAge(Date.now(),t)}static fromObject(t,e){return new MaxAge(t,e)}constructor(t,e){this.timestampInMs_=t;this.value=e}isExpired(t=Date.now()){const e=this.value*1e3;return this.timestampInMs_+e<t}toObject(){return{timestampInMs:this.timestampInMs_,maxAge:this.maxAge}}}t.exports=MaxAge},534:(t,e,r)=>{"use strict";let i=r(9796);const s=r(7070);const n=new Map;async function oneBehindFetch(t,e){let r=n.get(t);if(!r){r={maxAge:Promise.resolve(s.zero())};n.set(t,r)}const a=await r.maxAge;if(!a.isExpired()){const t=await r.responsePromise;return t.clone()}const o=r.responsePromise;const l=i(t,e);r={responsePromise:l,maxAge:l.then((t=>s.parse(t.headers.get("cache-control"))))};n.set(t,r);const c=o||l;const u=await c;return u.clone()}oneBehindFetch.clearCache=()=>n.clear();oneBehindFetch.setDelegate=t=>i=t;t.exports=oneBehindFetch},6657:(t,e,r)=>{"use strict";const{DomTransformer:i,TRANSFORMATIONS_AMP_FIRST:s,TRANSFORMATIONS_PAIRED_AMP:n,DEFAULT_CONFIG:a}=r(4234);const o=r(7731);t.exports={create:(t=a)=>new i(t),TRANSFORMATIONS_AMP_FIRST:s,TRANSFORMATIONS_PAIRED_AMP:n,DEFAULT_CONFIG:a,NodeUtils:o}},1497:(t,e,r)=>{"mode strict";const{hasAttribute:i}=r(7731);t.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:(t,e)=>t+"/rtv/"+e,isTemplate:t=>{if(t.tagName==="template"){return true}if(t.tagName==="script"&&i(t,"template")&&t.attribs.template==="amp-mustache"){return true}return false},isAmpStory:t=>{for(const e of t.children){if(isAmpScriptImport(e)&&e.attribs["custom-element"]==="amp-story"){return true}}return false}};function isAmpScriptImport(t){if(t.tagName!=="script"){return false}if(!t.attribs){return false}const e=t.attribs["custom-element"]||t.attribs["custom-template"]||"";if(!e.startsWith("amp-")){return false}return true}},4234:(t,e,r)=>{function __ncc_wildcard$0(t){if(t==="AddAmpLink")return r(1401);else if(t==="AddBlurryImagePlaceholders")return r(7334);else if(t==="AddMandatoryTags")return r(6765);else if(t==="AddTransformedFlag")return r(5544);else if(t==="AmpBoilerplateTransformer")return r(334);else if(t==="AmpScriptCsp")return r(5452);else if(t==="ApplyCommonAttributes")return r(4554);else if(t==="ApplyLayout")return r(7832);else if(t==="AutoExtensionImporter")return r(4502);else if(t==="GoogleFontsPreconnect")return r(9222);else if(t==="Markdown")return r(1169);else if(t==="MinifyHtml")return r(6618);else if(t==="OptimizeImages")return r(8445);else if(t==="PreloadHeroImage")return r(5525);else if(t==="PreloadImages")return r(1523);else if(t==="PruneDuplicateResourceHints")return r(1545);else if(t==="RemoveAmpAttribute")return r(9609);else if(t==="RemoveCspNonce")return r(4851);else if(t==="ReorderHeadTransformer")return r(710);else if(t==="RewriteAmpUrls")return r(9020);else if(t==="SeparateKeyframes")return r(5463);else if(t==="ServerSideRendering")return r(696)}"use strict";const i=r(8819);const s=r(8499);let n=r(9796);const a=r(4544);const o=r(7571);const l=["AddMandatoryTags","Markdown","AutoExtensionImporter","OptimizeImages","PreloadHeroImage","ServerSideRendering","AmpBoilerplateTransformer","ReorderHeadTransformer","RewriteAmpUrls","GoogleFontsPreconnect","PruneDuplicateResourceHints","SeparateKeyframes","AddTransformedFlag","MinifyHtml","AmpScriptCsp"];const c=["AutoExtensionImporter","AddAmpLink","OptimizeImages","PreloadHeroImage","ServerSideRendering","RemoveAmpAttribute","AmpBoilerplateTransformer","ReorderHeadTransformer","RewriteAmpUrls","GoogleFontsPreconnect","PruneDuplicateResourceHints","AddBlurryImagePlaceholders","SeparateKeyframes","AddTransformedFlag","MinifyHtml","AmpScriptCsp"];const u={fetch:n,log:s,transformations:l,verbose:false};class DomTransformer{constructor(t=u){this.setConfig(t)}async transformHtml(t,e){const r=await i.parse(t);await this.transformTree(r,e);return i.serialize(r)}async transformTree(t,e={}){s.verbose(e.verbose||false);const r=await o(this.config,e);const sequence=async(e,i)=>{await e;return i.transform(t,r)};return this.transformers_.reduce(sequence,Promise.resolve())}setConfig(t){this.config=Object.assign({},u,t);if(!this.config.runtimeVersion){this.config.runtimeVersion=new a(this.config.fetch)}s.verbose(this.config.verbose);this.initTransformers_(this.config)}initTransformers_(t){this.transformers_=t.transformations.map((e=>{if(typeof e==="string"){e=__ncc_wildcard$0(e)}return new e(t)}))}}t.exports={DomTransformer:DomTransformer,DEFAULT_CONFIG:u,TRANSFORMATIONS_AMP_FIRST:l,TRANSFORMATIONS_PAIRED_AMP:c}},1993:t=>{"mode strict";t.exports={isRenderDelayingExtension:function(t){if(t.tagName!=="script"){return false}const e=t.attribs["custom-element"];return e==="amp-dynamic-css-classes"||e==="amp-experiment"||e==="amp-story"},isCustomElement:function(t){return t.tagName&&t.tagName.startsWith("amp-")}}},187:t=>{"use strict";function findMetaViewport(t){for(let e=t.firstChild;e!==null;e=e.nextSibling){if(e.tagName==="meta"&&e.attribs.name==="viewport"){return e}}return null}function skipNodeAndChildren(t){if(t.nextSibling){return t.nextSibling}return skipNodeAndChildren(t.parent)}t.exports={findMetaViewport:findMetaViewport,skipNodeAndChildren:skipNodeAndChildren}},7731:(t,e,r)=>{"use strict";const{Element:i,DataNode:s}=r(8436);const{removeElement:n,append:a,prepend:o}=r(3790);const nextNode=function(t){const e=t.firstChild;if(e){return e}let r=t;while(r){const t=r.nextSibling;if(t){return t}r=r.parent}return null};const remove=function(t){n(t)};const appendChild=function(t,e){if(!e){return}e.parent=t;if(t.children.push(e)!==1){const r=t.children[t.children.length-2];r.next=e;e.prev=r;e.next=null}};const insertBefore=function(t,e,r){if(r){o(r,e);return}appendChild(t,e)};const insertAfter=function(t,e,r){if(r){a(r,e);return}appendChild(t,e)};const appendAll=function(t,e){if(!e){return}for(let r=0,i=e.length;r<i;r++){appendChild(t,e[r])}};const firstChildByTag=function(t,e){if(!t||!t.children){return null}return t.children.find((t=>t.tagName&&t.tagName===e))};const hasAttribute=function(t,e){if(!t.attribs)return false;return e in t.attribs};const move=function(t,e){remove(t);appendChild(e,t)};const createElement=(t,e)=>new i(t,e);const insertText=(t,e)=>{const r=new s("text",e);appendChild(t,r)};const createDocType=()=>{const t=new s("directive","!doctype html");return t};t.exports={appendChild:appendChild,appendAll:appendAll,insertAfter:insertAfter,nextNode:nextNode,remove:remove,createDocType:createDocType,createElement:createElement,insertText:insertText,insertBefore:insertBefore,hasAttribute:hasAttribute,firstChildByTag:firstChildByTag,move:move}},815:t=>{"use strict";const e=["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 s=cssLength("1",false,false);const n=cssLength("auto",true,false);const a=cssLength("44px",false,false);const o=cssLength("60px",false,false);function getLayoutClass(t){if(!t){return t}return"i-amphtml-layout-"+t}function calculateHeight(t,e,r){if((t===""||t==="fixed"||t==="fixed-height")&&!e.isSet){switch(r){case"amp-analytics":return s;case"amp-audio":return n;case"amp-pixel":return s;case"amp-social-share":return a;default:}}return e}function calculateWidth(t,e,r){if((t===""||t==="fixed")&&!e.isSet){switch(r){case"amp-analytics":return s;case"amp-audio":return n;case"amp-pixel":return s;case"amp-social-share":return o;default:}}return e}function isLayoutSizeDefined(t){return i.indexOf(t)>-1}function getCssLengthStyle(t,e){if(!t.isSet){return""}if(t.isAuto){return`${e}:auto;`}return`${e}:${t.numeral}${t.unit};`}function parseLayout(t){if(!t){return""}t=t.toLowerCase();if(r.indexOf(t)>-1){return t}return""}function calculateLayout(t,e,r,i,s){if(t!==""){return t}if(!e.isSet&&!r.isSet){return"container"}if(r.isSet&&(!e.isSet||e.isAuto)){return"fixed-height"}if(r.isSet&&e.isSet&&(i||s)){return"responsive"}return"fixed"}function cssLength(t,r=false,i=false){const s={isValid:false,isSet:false,isAuto:false,isFluid:false,numeral:Number.NaN,unit:"px"};if(t===null){s.isValid=true;return s}s.isSet=true;if(t==="auto"){s.isAuto=true;s.isValid=r;return s}if(t==="fluid"){s.isFluid=true;s.isValid=i;return s}const n=/(\d+(?:\.\d+)?)(.*)/;const a=n.exec(t);if(!a){return s}s.numeral=Number.parseFloat(a[1]);t=a[2];if(t===""){s.unit="px";s.isValid=true;return s}if(e.indexOf(t)>-1){s.isValid=true;s.unit=t}return s}function getLayoutSizeDefinedClass(){return"i-amphtml-layout-size-defined"}t.exports={parseLayout:parseLayout,cssLength:cssLength,getLayoutClass:getLayoutClass,calculateHeight:calculateHeight,calculateWidth:calculateWidth,isLayoutSizeDefined:isLayoutSizeDefined,getCssLengthStyle:getCssLengthStyle,calculateLayout:calculateLayout,getLayoutSizeDefinedClass:getLayoutSizeDefinedClass}},8098:(t,e,r)=>{"use strict";const i=r(7310).URL;const{join:s,resolve:n}=r(1017);const a="https://example.com";class PathResolver{constructor(t=""){if(typeof t==="function"){this.implementation=t}else{this.implementation=this.createStaticResolver(t)}}resolve(t,e){return this.implementation(t,e)}createStaticResolver(t){let e=false;try{new i(t);e=true}catch(t){}return r=>{try{if(e){return new i(r,t).toString()}else{return new i(r).toString()}}catch(t){}r=new i(r,a).pathname.substring(1);return n(s(t,r))}}}t.exports=PathResolver},3800:(t,e,r)=>{"use strict";const{AMP_CACHE_HOST:i,appendRuntimeVersion:s}=r(1497);function calculateHost({ampUrlPrefix:t=i,ampRuntimeVersion:e,lts:r=false,rtv:n=false}){if(r&&n){throw new Error("lts flag is not compatible with runtime version parameter")}t=t.replace(/\/$/,"");if(e&&n){t=s(t,e)}else if(r){t+="/lts"}return t}t.exports={calculateHost:calculateHost}},8819:(t,e,r)=>{"use strict";const{Parser:i}=r(91);const{DomHandler:s,NodeWithChildren:n}=r(8436);const{appendAll:a}=r(7731);const o=r(9312)["default"];const l={decodeEntities:false};class TreeParser{constructor(t){this.options=t}parse(t){return new Promise(((e,r)=>{const o=new s(((t,i)=>{if(t){r(t)}else{const t=new n("root",[]);a(t,i);e(t)}}),this.options);const l=new i(o,this.options);l.write(t.trim());l.end()}))}serialize(t){return o(t,{})}}t.exports=new TreeParser(l);t.exports.TreeParser=TreeParser},5265:t=>{"use strict";const isValidImageSrcURL=t=>{try{return new URL(t,"https://example.com").protocol.startsWith("http")}catch(t){return false}};t.exports={isValidImageSrcURL:isValidImageSrcURL}},7785:(t,e,r)=>{"use strict";const{FileSystemCache:i}=r(6461);const s=r(1017);const n=r(8499);const a=i.create({log:n,baseDir:r.ab+".cache"});t.exports=a},7980:(t,e,r)=>{"use strict";const i=r(3605);const s=/^https?:\/\/|^\/\//i;function fetchImageDimensions(t){if(s.test(t)){return fetchImageDimensionsFromUrl(t)}return fetchImageDimensionsFromFile(t)}function fetchImageDimensionsFromUrl(t){return probe(t)}async function fetchImageDimensionsFromFile(t){if(!i("fs")){throw new Error("No access to the file system")}const e=r(7147);if(!e.existsSync(t)){throw new Error("Could not resolve file: "+t)}const s=e.createReadStream(t);return probe(s)}function probe(t){if(!i("probe-image-size")){throw new Error("Missing optional dependency: probe-image-size")}return r(8520)(t)}t.exports={fetchImageDimensions:fetchImageDimensions,fetchImageDimensionsFromFile:fetchImageDimensionsFromFile,fetchImageDimensionsFromUrl:fetchImageDimensionsFromUrl}},7571:(t,e,r)=>{"mode strict";const i=r(9219);const{MaxAge:s}=r(6461);const{AMP_CACHE_HOST:n,AMP_RUNTIME_CSS_PATH:a,AMP_VALIDATION_RULES_URL:o,appendRuntimeVersion:l}=r(1497);const c="validator-rules";const u=10*60;const d=r(7785);async function fetchRuntimeParameters(t,e={}){const r=Object.assign({},e);r.verbose=e.verbose||t.verbose||false;const i=initValidatorRules(r,e,t);await initRuntimeVersion(r,e,t);await initRuntimeStyles(r,t);await i;return r}async function initValidatorRules(t,e,r){try{t.validatorRules=e.validatorRules||r.validatorRules||await fetchValidatorRulesFromCache_(r)}catch(t){r.log.error("Could not fetch validator rules",t)}}async function fetchValidatorRulesFromCache_(t){if(t.cache===false){return fetchValidatorRules_(t)}let e=await d.get("validator-rules");let r;if(!e){r=await fetchValidatorRules_(t);t.log.debug("Downloaded AMP validation rules");d.set(c,r.raw)}else{r=await i.fetch({rules:e})}return r}async function fetchValidatorRules_(t){const e=await t.fetch(o);if(!e.ok){return null}return i.fetch({rules:await e.json()})}async function initRuntimeStyles(t,e){try{t.ampRuntimeStyles=t.ampRuntimeStyles||await fetchAmpRuntimeStyles_(e,t.ampUrlPrefix,t.ampRuntimeVersion)}catch(t){e.log.error("Could not fetch AMP runtime CSS",t)}}async function initRuntimeVersion(t,e,r){t.lts=e.lts||r.lts||false;t.rtv=e.rtv||r.rtv||false;let{ampUrlPrefix:i,ampRuntimeVersion:s,lts:n}=t;if(n&&s){r.log.warn("`ampRuntimeVersion` and `lts` cannot be defined at the same time. Using LTS version.");s=""}try{t.ampRuntimeVersion=s||await fetchAmpRuntimeVersion_({config:r,ampUrlPrefix:i,lts:n})}catch(t){r.log.error("Could not fetch latest AMP runtime version",t)}}async function fetchAmpRuntimeVersion_(t){if(t.config.cache===false){return(await fetchLatestRuntimeData_(t)).version}const e=t.ampUrlPrefix+"-"+t.lts;let r=await d.get(e);if(!r){r=await fetchLatestRuntimeData_(t,e);t.config.log.debug("Downloaded AMP runtime v"+r.version)}else if(s.fromObject(r.maxAge).isExpired()){fetchLatestRuntimeData_(e,t)}return r.version}async function fetchLatestRuntimeData_({config:t,ampUrlPrefix:e,lts:r},i=null){let a;a={version:await t.runtimeVersion.currentVersion({ampUrlPrefix:e,lts:r}),maxAge:s.create(u).toObject()};if(!a.version&&e!==n){t.log.error(`Could not download runtime version from ${e}. Falling back to ${n}`);a=await fetchLatestRuntimeData_({config:t,ampUrlPrefix:n,lts:r},i)}else if(a.version&&i){d.set(i,a)}return a}async function fetchAmpRuntimeStyles_(t,e,r){if(e&&!isAbsoluteUrl_(e)){t.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 ${n}`);e=n;r=r||await t.runtimeVersion.currentVersion()}const i=l(e||n,r)+a;const s=await downloadAmpRuntimeStyles_(t,i);if(!s){t.log.error(`Could not download ${i}. Falling back to latest v0.css.`);if(e||r){return fetchAmpRuntimeStyles_(t,n,await t.runtimeVersion.currentVersion())}else{return""}}return s}async function downloadAmpRuntimeStyles_(t,e){let r;if(t.cache!==false){r=await d.get(e)}if(!r){const i=await t.fetch(e);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;}`}t.log.debug(`Downloaded AMP runtime styles from ${e}`);if(t.cache!==false){d.set(e,r)}}return r}function isAbsoluteUrl_(t){try{new URL(t);return true}catch(t){return false}}t.exports=fetchRuntimeParameters},2333:t=>{const e={"&":"\\u0026",">":"\\u003e","<":"\\u003c","\u2028":"\\u2028","\u2029":"\\u2029"};const r=/[&><\u2028\u2029]/g;t.exports=function htmlEscapeJsonString(t){return t.replace(r,(t=>e[t]))}},3605:t=>{function isDependencyInstalled(t){try{require.resolve(t);return true}catch(t){return false}}t.exports=isDependencyInstalled},8499:(t,e,r)=>{"use strict";const{log:i}=r(6461);t.exports=i.tag("AMP Optimizer")},9344:t=>{"use strict";let e;let r;const parseSizes=t=>{const e={defaultValue:"",values:[]};if(!t){return e}const r=t.trim().split(/\s*,\s*/);for(let i=0;i<r.length;i++){const s=r[i];if(i===r.length-1){e.defaultValue=s.trim()}else{const r=s.split(/\)\s+/);if(r.length!==2){throw new Error(`Invalid sizes definition '${t}'`)}e.values.push({media:`${r[0]})`,size:r[1]})}}return e};t.exports=parseSizes},1401:(t,e,r)=>{"use strict";const{firstChildByTag:i,createElement:s,appendChild:n}=r(7731);class AddAmpLink{transform(t,e){if(!e.ampUrl)return;const r=i(t,"html");if(!r)return;const a=i(r,"head");if(!a)return;const o=s("link",{rel:"amphtml",href:e.ampUrl});n(a,o)}}t.exports=AddAmpLink},7334:(t,e,r)=>{const i=r(3605);const{createElement:s,appendChild:n,nextNode:a,firstChildByTag:o}=r(7731);const{URL:l}=r(7310);const{skipNodeAndChildren:c}=r(187);const u=r(8098);const d=60;const h=100;const f=30;const p=-1;const m={"#":"%23","%":"%25",":":"%3A","<":"%3C",">":"%3E",'"':"'"};const g=new RegExp(Object.keys(m).join("|"),"g");function escaper(t){return m[t]}class AddBlurryImagePlaceholders{constructor(t){this.log_=t.log.tag("AddBlurryImagePlaceholders");this.blurredPlaceholders_=!!t.blurredPlaceholders;if(!this.blurredPlaceholders_){this.log_.debug("disabled");return}if(!i("jimp")||!i("lru-cache")){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;return}this.jimp=r(1742);this.maxBlurredPlaceholders_=t.maxBlurredPlaceholders||h;this.pathResolver_=new u(t.imageBasePath);const e=t.blurredPlaceholdersCacheSize||f;if(e===p){this.log_.debug("caching all placeholders");this.cache_=new Map}else if(e>0){const t=r(7330);this.log_.debug("using LRU cache for regularily used placeholders",e);this.cache_=new t({max:e})}else{this.log_.debug("caching disabled")}}transform(t,e){if(!this.blurredPlaceholders_){return}const r=o(t,"html");const i=o(r,"body");const s=[];let l=0;for(let t=i;t!==null;t=a(t)){const{tagName:r}=t;let i;if(r==="template"){t=c(t);continue}if(r==="amp-img"){i=t.attribs.src}if(r==="amp-video"&&t.attribs.poster){i=t.attribs.poster}if(this.shouldAddBlurryPlaceholder_(t,i,r)){l++;const r=this.addBlurryPlaceholder_(i,e).then((e=>{t.attribs.noloading="";n(t,e)}));s.push(r);if(l>=this.maxBlurredPlaceholders_){break}}}return Promise.all(s)}async addBlurryPlaceholder_(t,e){const r=s("img",{class:"i-amphtml-blurry-placeholder",placeholder:"",src:t,alt:""});try{const i=await this.getCachedDataURI(t,e);let s=`<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>`;s=s.replace(/\s+/g," ");s=s.replace(/> </g,"><");s=s.replace(g,escaper);r.attribs.src="data:image/svg+xml;charset=utf-8,"+s;this.log_.debug(t,"[SUCCESS]")}catch(e){this.log_.debug(t,"[FAIL]");this.log_.error(e.message)}return r}getCachedDataURI(t,e){const r=this.pathResolver_.resolve(t,e);if(this.cache_){const e=this.cache_.get(r);if(e){this.log_.debug(t,"[CACHE HIT]");return e}this.log_.debug(t,"[CACHE MISS]")}const i=this.getDataURI_(r);if(this.cache_){this.cache_.set(r,i)}return i}async getDataURI_(t){const e=await this.jimp.read(t);const r=this.getBitmapDimensions_(e.bitmap.width,e.bitmap.height);e.resize(r.width,r.height,this.jimp.RESIZE_BEZIER);const i={src:await e.getBase64Async("image/png"),width:r.width,height:r.height};return i}getBitmapDimensions_(t,e){const r=t/e;let i=d/r;i=Math.sqrt(i);const s=d/i;return{width:Math.round(s),height:Math.round(i)}}hasPlaceholder_(t){return t.childNodes.find((t=>t.attribs&&t.attribs.placeholder!==undefined))!==undefined}shouldAddBlurryPlaceholder_(t,e,r){if(!e){return false}if(this.hasPlaceholder_(t)){return false}const i=new l(e,"https://example.com");if(!i.pathname.endsWith(".jpg")&&!i.pathname.endsWith("jpeg")){return false}if(t.attribs.noloading!=null){return false}const s=r=="amp-video";const n=r=="amp-img"&&(t.attribs.layout=="intrinsic"||t.attribs.layout=="responsive"||t.attribs.layout=="fill");return s||n}}t.exports=AddBlurryImagePlaceholders},6765:(t,e,r)=>{"use strict";const{move:i,insertText:s,appendChild:n,insertBefore:a,createDocType:o,createElement:l,firstChildByTag:c}=r(7731);const{AMP_FORMATS:u,AMP_TAGS:d}=r(1497);const h="AMP";const f="data-auto";const p={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:(t,e)=>{if(!t.canonical){e.warn("No canonical param is given. Setting canonical href to `.`");t.canonical="."}return t.canonical}}}}]};class AddMandatoryTags{constructor(t){this.enabled=t.autoAddBoilerplate!==false&&t.autoAddMandatoryTags!==false;this.format=t.format||h;this.log_=t.log.tag("AddMandatoryTags")}async transform(t,e){if(!this.enabled){return}if(!u.includes(this.format)){this.log_.error("Unknown AMPHTML format",this.format);return}const r=p[this.format];if(!r){this.log_.info("Unsupported AMP format",this.format);return}let i=c(t,"html");if(!i){i=this.createHtml5Document(t)}let s=t.children.find((t=>t.type==="directive"&&t.name==="!doctype"));if(!s){s=o();a(t,s,t.firstChild)}if(!Object.keys(i.attribs).some((t=>d.includes(t)))){i.attribs[this.format.toLowerCase()]=""}let h=c(i,"head");if(!h){h=l("head");n(i,h)}const f=new Set(r);let m=h.firstChild;while(m){if(m.tagName){f.forEach((t=>{if(this.matchSpec(t.matcher,m)){f.delete(t)}}))}m=m.nextSibling}for(const t of f){this.addNode(h,t.node,e)}}matchSpec(t,e){if(t.tagName!==e.tagName){return false}if(!t.attribs){return true}for(const[r,i]of Object.entries(t.attribs)){const t=e.attribs[r];if(i instanceof RegExp){if(!i.test(t)){return false}}else if(t!==i){return false}}return true}addNode(t,e,r){const i={};i[f]="";const s=l(e.tagName,i);this.addAttributes(e,s,r);this.addChildren(e,s,r);this.addText(e,s,r);n(t,s)}addText(t,e,r){if(!t.text){return}let i;if(typeof t.text==="function"){i=t.text(r,this.log_)}else{i=t.text}s(e,i)}addChildren(t,e,r){if(!t.children){return}for(const i of t.children){this.addNode(e,i,r)}}addAttributes(t,e,r){if(!t.attribs){return}for(const[i,s]of Object.entries(t.attribs)){if(typeof s==="function"){e.attribs[i]=s(r,this.log_)}else{e.attribs[i]=s}}}createHtml5Document(t){const e=l("html",{});const r=this.createOrMoveElement(t,e,"head");const i=this.createOrMoveElement(t,e,"body");this.copyTagsToHeadAndBody(t,r,i);n(t,e);return e}createOrMoveElement(t,e,r){const s=c(t,r)||l(r);i(s,e);return s}copyTagsToHeadAndBody(t,e,r){let s=t.firstChild;while(s){const t=s;s=t.next;if(t.type==="directive"){}else if(t.tagName==="title"){i(t,e)}else{i(t,r)}}}}t.exports=AddMandatoryTags},5544:(t,e,r)=>{"use strict";const{firstChildByTag:i}=r(7731);class AddTransformedFlag{transform(t){const e=i(t,"html");if(!e)return;e.attribs.transformed="self;v=1"}}t.exports=AddTransformedFlag},334:(t,e,r)=>{"use strict";const{insertText:i,hasAttribute:s,firstChildByTag:n}=r(7731);class AmpBoilerplateTransformer{constructor(t){this.fetch_=t.fetch;this.runtimeVersion_=t.runtimeVersion;this.log_=t.log.tag("AmpBoilerplateTransformer")}transform(t,e){const r=n(t,"html");const s=n(r,"head");if(!s){return}const a=this._findAmpRuntimeStyle(s);if(!a){return}let{ampRuntimeVersion:o,ampRuntimeStyles:l}=e;if(!o||!l){this.log_.error("Missing parameters both ampRuntimeVersion and ampRuntimeStyles need to be present");return}a.attribs["i-amphtml-version"]=o;i(a,l)}_findAmpRuntimeStyle(t){let e=t.firstChild;while(e){if(s(e,"amp-runtime")){return e}e=e.nextSibling}return null}}t.exports=AmpBoilerplateTransformer},5452:(t,e,r)=>{"use strict";const{remove:i,appendChild:s,createElement:n,nextNode:a,firstChildByTag:o}=r(7731);const{calculateHash:l}=r(1815);class AmpScriptCsp{transform(t){const e=o(t,"html");if(!e)return;const r=o(e,"head");if(!r)return;const s=o(e,"body");if(!s)return;const n=this._findOrCreateCspMeta(r);const a=(n.attribs.content||"").trim().split(/\s+/);const c=new Set(a);c.delete("");const u=this._findAllInlineScripts(s);for(const t of u){const e=t.children[0]?t.children[0].data:"";c.add(l(e))}const d=Array.from(c).join(" ");if(d===""){i(n);return}n.attribs.content=d}_findAllInlineScripts(t){const e=[];let r=t;while(r!==null){if(r.tagName==="script"&&r.attribs.target==="amp-script"){e.push(r)}r=a(r)}return e}_findOrCreateCspMeta(t){for(let e=t.firstChild;e!==null;e=e.nextSibling){if(e.tagName==="meta"&&e.attribs.name==="amp-script-src"){return e}}const e=n("meta",{name:"amp-script-src"});s(t,e);return e}}t.exports=AmpScriptCsp},4554:(t,e,r)=>{"use strict";const i=r(9344);const{appendChild:s,createElement:n,insertText:a,hasAttribute:o}=r(7731);const{isCustomElement:l}=r(1993);const c="i-amp-";class MediaTransformer{constructor(){this.media=new Map}transform(t,e){let r=t.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,`#${e}`);return true}addMedia(t,e){let r=this.media.get(t);if(!r){r=[];this.media.set(t,r)}r.push(e)}toString(){let t="";for(const[e,r]of this.media.entries()){t+=`@media ${e}{${r.join(",")}{display:none}}`}return t}}class SizesTransformer{constructor(){this.sizes=[]}transform(t,e){if(!t.attribs.srcset){return false}const r=i(t.attribs.sizes);if(!r.defaultValue){return false}this.addSizes(e,r);return true}addSizes(t,e){this.sizes.push({id:t,defaultSize:e.defaultValue,sizes:e.values.reverse()})}toString(){let t="";for(const{sizes:e,defaultSize:r,id:i}of this.sizes){const s=`#${i}`;t+=`${s}{width:${r}}`;for(const r of e){t+=`@media ${r.media}{${s}{width:${r.size}}}`}}return t}}class HeightsTransformer{constructor(){this.heights=[]}transform(t,e){const r=i(t.attribs.heights);if(!r.defaultValue){return false}this.addHeights(e,r);return true}addHeights(t,e){this.heights.push({id:t,defaultHeight:e.defaultValue,heights:e.values.reverse()})}toString(){let t="";for(const{heights:e,defaultHeight:r,id:i}of this.heights){const s=`#${i}>:first-child`;t+=`${s}{padding-top:${r}}`;for(const r of e){t+=`@media ${r.media}{${s}{padding-top:${r.size}}}`}}return t}}class ApplyCommonAttributes{constructor(t){this.log=t;this.canRemoveBoilerplate=true;this.counter=0;this.nodesToTransform=[];this.ids=new Set;this.transformedNodes=[];this.attributeTransformations={media:new MediaTransformer,sizes:new SizesTransformer,heights:new HeightsTransformer}}addNode(t){if(!t.attribs){return}if(o(t,"id")){this.ids.add(t.attribs.id)}if(l(t)){this.nodesToTransform.push(t)}}apply(){for(const t of this.nodesToTransform){for(const[e,r]of Object.entries(this.attributeTransformations)){if(o(t,e)){try{const e=this.getOrCreateId(t);const i=r.transform(t,e);this.transformedNodes.push(t);if(i&&!t.attribs.id){t.attribs.id=e}else{this.counter--}}catch(r){this.log.debug(`Cannot remove boilerplate. Failed transforming ${e}="${t.attribs[e]}".`,r);this.canRemoveBoilerplate=false}}}}}applyToCustomStyles(t,e){const r=Object.values(this.attributeTransformations).join("");if(!r){return}if(!e){e=n("style",{"amp-custom":""});s(t,e)}if(e.children.length===0){a(e,"")}e.children[0].data+=r;for(const t of this.transformedNodes){for(const e of Object.keys(this.attributeTransformations)){delete t.attribs[e]}}}getOrCreateId(t){if(o(t,"id")){return t.attribs.id}t.attribs=t.attribs||[];const e=c+this.counter;this.counter++;if(this.ids.has(e)){return this.getOrCreateId(t)}return e}}t.exports=ApplyCommonAttributes},7832:(t,e,r)=>{"use strict";const{hasAttribute:i,insertBefore:s,createElement:n,appendChild:a}=r(7731);const{parseLayout:o,cssLength:l,calculateHeight:c,calculateWidth:u,calculateLayout:d,getLayoutClass:h,isLayoutSizeDefined:f,getLayoutSizeDefinedClass:p}=r(815);const m=["","nodisplay","fixed","fixed-height","responsive","container","fill","flex-item","intrinsic"];function isSupportedLayout(t){return m.indexOf(t)>-1}function getAttributeOrNull(t,e){return i(t,e)?t.attribs[e]:null}function addClass(t,e){t.attribs.class=i(t,"class")?t.attribs.class+" "+e:e}function apply(t,e,r,i){addClass(i,h(t));if(f(t)){addClass(i,p())}let s="";switch(t){case"nodisplay":i.attribs.hidden="hidden";break;case"fixed":s=`width:${e.numeral}${e.unit};height:${r.numeral}${r.unit};`;break;case"fixed-height":s=`height:${r.numeral}${r.unit};`;break;case"responsive":break;case"intrinsic":break;case"fill":case"container":break;case"flex-item":if(e.isSet){s=`width:${e.numeral}${e.unit};`}if(r.isSet){s+=`height:${r.numeral}${r.unit};`}break;default:}i.attribs.style=s+(i.attribs.style?i.attribs.style:"");if(i.attribs.style===""){delete i.attribs.style}i.attribs["i-amphtml-layout"]=t}function maybeAddSizerInto(t,e,r,i){if(!r.isSet||r.numeral===0||!i.isSet||r.unit!==i.unit){return}let n=null;if(e==="responsive"){n=createResponsiveSizer(r,i)}else if(e==="intrinsic"){n=createIntrinsicSizer(r,i)}if(n){const e=t.firstChild;s(t,n,e)}}function createResponsiveSizer(t,e){const r=e.numeral/t.numeral*100;const i=n("i-amphtml-sizer",{style:`display:block;padding-top:${parseFloat(r.toFixed(4))}%`});return i}function createIntrinsicSizer(t,e){const r=n("i-amphtml-sizer",{class:"i-amphtml-sizer"});const i=n("img",{alt:"","aria-hidden":"true",class:"i-amphtml-intrinsic-sizer",role:"presentation",src:`data:image/svg+xml;charset=utf-8,<svg height="${e.numeral}" width="${t.numeral}" xmlns="http://www.w3.org/2000/svg" version="1.1"/>`});a(r,i);return r}t.exports={applyLayout:function(t,e){const r=o(t.attribs.layout);const i=getAttributeOrNull(t,"width");const s=l(i,true,false);if(!s.isValid){e.debug("cannot perform SSR: invalid input width\n",i);return false}const n=getAttributeOrNull(t,"height");const a=l(n,true,r==="fluid");if(!a.isValid){e.debug("cannot perform SSR: invalid input height\n",n);return false}const h=c(r,a,t.tagName);const f=u(r,s,t.tagName);const p=d(r,f,h,getAttributeOrNull(t,"sizes"),getAttributeOrNull(t,"heights"));if(!isSupportedLayout(p)){e.debug("cannot perform SSR: unsupported layout",p);return false}apply(p,f,h,t);maybeAddSizerInto(t,p,f,h);return true}}},4502:(t,e,r)=>{"use strict";const{nextNode:i,insertAfter:s,createElement:n,firstChildByTag:a}=r(7731);const{findMetaViewport:o}=r(187);const{AMP_FORMATS:l,AMP_CACHE_HOST:c}=r(1497);const u="bind";const d="data-amp-bind-";const h="AMP";const f=new Map([["mask","amp-inputmask"],["lightbox","amp-lightbox-gallery"]]);const p=Array.from(f.values());class AutoExtensionImporter{constructor(t){this.enabled=t.autoExtensionImport!==false;this.format=t.format||h;this.log_=t.log.tag("AutoExtensionImporter");this.experimentBindAttributeEnabled=t.experimentBindAttribute===true;this.extensionVersions=t.extensionVersions||{}}createExtensionsSpec(t){const e=t.validatorRules;const r=new Map;for(const t of e.extensions){if(t.htmlFormat.includes(this.format)){r.set(t.name,{name:t.name,type:t.extensionType==="CUSTOM_TEMPLATE"?"custom-template":"custom-element",version:t.version.filter((t=>t!=="latest"))})}}const i=new Map;const s=new Map;const n=new Map;for(const t of e.getTagsForFormat(this.format)){const e=t.tagName.toLowerCase();if(e.startsWith("amp-")){let r=t.requiresExtension||[];r=r.filter((t=>!p.includes(t)));i.set(e,r)}const r=new Set;for(const i of t.attrs){if(f.has(i.name)){i.requiresExtension=[f.get(i.name)]}if(i.requiresExtension&&i.requiresExtension.length>0){const t=s.get(e)||[];t.push(i);s.set(e,t)}if(i.name.startsWith("[")){r.add(i.name.substring(1,i.name.length-1))}}n.set(e,r)}return{extensionsMap:r,tagToExtensionsMapping:i,tagToAttributeMapping:s,tagToBindAttributeMapping:n}}async transform(t,e){if(!this.enabled){return}if(!e.validatorRules){this.log_.error("Missing validation rules, cannot auto import extensions");return}if(!this.extensionSpec_){this.extensionSpec_=this.createExtensionsSpec(e)}if(!l.includes(this.format)){this.log_.error("Unsupported AMPHTML format",this.format);return}const r=a(t,"html");if(!r)return;const i=a(r,"head");if(!i)return;const u=a(r,"body");if(!u)return;const d=new Set;const h=new Set;this.findExistingExtensionsAndExtensionsToImportInHead_(i,d,h);await this.findExtensionsToImportInBody_(u,d);if(d.length===0){return}const f=o(i);const p=c;for(const t of d){if(h.has(t)){continue}const e=this.extensionSpec_.extensionsMap.get(t.trim());this.log_.debug("auto importing",t);let r=e.version[e.version.length-1];if(this.extensionVersions[t]){r=this.extensionVersions[t]}const a={async:"",src:`${p}/v0/${t}-${r}.js`};a[e.type]=t;const o=n("script",a);s(i,o,f)}}findExistingExtensionsAndExtensionsToImportInHead_(t,e,r){let s=t;while(s){const t=this.getCustomElement_(s);if(t){r.add(t)}else if(s.tagName==="script"&&s.attribs["id"]==="amp-access"){e.add("amp-access");e.add("amp-analytics");const t=this.getJson(s);if(t.vendor==="laterpay"){e.add("amp-access-laterpay")}}else if(s.tagName==="script"&&s.attribs["id"]==="amp-subscriptions"){e.add("amp-subscriptions");e.add("amp-analytics");const t=this.getJson(s);if(t.services&&t.services.length){for(const r of t.services){if(r.serviceId==="subscribe.google.com"){e.add("amp-subscriptions-google")}}}}s=i(s)}}getJson(t){for(const e of t.children||[]){if(!e.data){continue}try{return JSON.parse(e.data)}catch(t){this.log_.error('Could not parse JSON in <script id="amp-access">',t.message)}}return{}}async findExtensionsToImportInBody_(t,e){let r=t;while(r!==null){if(r.tagName){this.addRequiredExtensionByTag_(r,e);this.addRequiredExtensionByAttributes_(r,e)}r=i(r)}}addRequiredExtensionByTag_(t,e){const r=this.extensionSpec_.tagToExtensionsMapping.get(t.tagName);if(r){r.forEach((t=>e.add(t)))}if(t.tagName==="template"&&t.attribs.type){e.add(t.attribs.type)}}addRequiredExtensionByAttributes_(t,e){if(!t.tagName||!t.attribs){return}const r=this.extensionSpec_.tagToAttributeMapping;const i=r.get(t.tagName)||[];i.forEach((r=>{if(t.attribs[r.name]!==undefined){r.requiresExtension.forEach((t=>{e.add(t)}))}}));if(t.tagName==="form"){e.add("amp-form")}const s=this.extensionSpec_.tagToBindAttributeMapping;const n=Object.keys(t.attribs);if(n.some((t=>t.startsWith("[")||t.startsWith(d)))){e.add("amp-bind")}if(this.experimentBindAttributeEnabled){const r=s.get(t.tagName);let i=false;for(const s of n){if(!s.startsWith(u)){continue}const n=s.substring(u.length);if(r.has(n)){const e=`${d}${n}`;t.attribs[e]=t.attribs[s];delete t.attribs[s];i=true}if(i){e.add("amp-bind")}}}}getCustomElement_(t){if(t.tagName!=="script"){return""}const e=t.attribs["custom-element"]||t.attribs["custom-template"]||"";if(!e){return""}if(!e.startsWith("amp-")){return""}return e}}t.exports=AutoExtensionImporter},9222:(t,e,r)=>{"use strict";const{insertAfter:i,createElement:s,firstChildByTag:n}=r(7731);const{findMetaViewport:a}=r(187);class GoogleFontsPreconnect{constructor(t){this.log_=t.log.tag("GoogleFontsPreconnect")}transform(t){const e=n(t,"html");if(!e){return}const r=n(e,"head");if(!r){return}for(let t=r.firstChild;t!==null;t=t.nextSibling){if(this.isGoogleFontsLinkNode_(t)){const t=s("link",{rel:"dns-prefetch preconnect",href:"https://fonts.gstatic.com",crossorigin:""});const e=a(r);i(r,t,e);this.log_.debug('adding <link rel="dns=prefetch preconnect" href="'+t.attribs.href+'">');return}}}isGoogleFontsLinkNode_(t){return t.tagName==="link"&&t.attribs.rel==="stylesheet"&&t.attribs.href.startsWith("https://fonts.googleapis.com")}}t.exports=GoogleFontsPreconnect},1169:(t,e,r)=>{"use strict";const i=r(8098);const{fetchImageDimensions:s}=r(7980);const{remove:n,insertAfter:a,createElement:o,firstChildByTag:l,nextNode:c}=r(7731);const u="intrinsic";const d=320;class Markdown{constructor(t){this.log=t.log;this.enabled=!!t.markdown;this.pathResolver=new i(t.imageBasePath)}async transform(t,e){if(!this.enabled){return}const r=l(t,"html");if(!r){return}const i=l(r,"body");if(!i){return}let s=i;const n=[];while(s){const t=c(s);if(s.tagName==="img"){n.push(this.transformImg(s,e))}s=t}return Promise.all(n)}async transformImg(t,e){const r=t.attribs&&t.attribs.src;if(!r){return}const i=this.pathResolver.resolve(r,e);let o;try{o=await s(i)}catch(t){this.log.warn(t.message);return}const l=this.createAmpImgOrAmpAnim(o,t);a(t.parent,l,t);n(t)}createAmpImgOrAmpAnim(t,e){const r=t.type==="gif"?"amp-anim":"amp-img";const i=o(r,e.attribs);i.attribs.width=e.attribs.width||String(t.width);i.attribs.height=e.attribs.height||String(t.height);this.addLayout(i,t);return i}addLayout(t,e){if(e.width<d){return}t.attribs.layout=u}}t.exports=Markdown},6618:(t,e,r)=>{"use strict";const{minify:i}=r(6794);const{remove:s}=r(7731);const n=r(3444);const a=r(2333);const o=/^\s*__[a-bA-Z0-9_-]+__\s*$/;class MinifyHtml{constructor(t){this.opts={minify:t.minify!==false,minifyAmpScript:true,minifyJSON:true,collapseWhitespace:true,removeComments:true,canCollapseWhitespace:true,inBody:false,commentIgnorePattern:o};this.log=t.log.tag("MinifyHtml")}async transform(t){if(!this.opts.minify){return}const e=[];await this.minifyNode(t,this.opts,e);for(const t of e){s(t)}}async minifyNode(t,e,r){if(t.type==="text"){this.minifyTextNode(t,e,r)}else if(t.type==="comment"){this.minifyCommentNode(t,e,r)}else if(t.tagName==="script"){await this.minifyScriptNode(t,e)}const i=Object.assign({},e);if(e.canCollapseWhitespace&&!this.canCollapseWhitespace(t.tagName)){i.canCollapseWhitespace=false}if(t.tagName==="head"||t.tagName==="html"){i.inBody=false}else if(t.tagName==="body"){i.inBody=true}const s=[];for(const e of t.children||[]){s.push(this.minifyNode(e,i,r))}return Promise.all(s)}minifyTextNode(t,e,r){if(!t.data||!e.collapseWhitespace){return}if(e.canCollapseWhitespace){t.data=n(t.data)}if(!e.inBody){t.data=t.data.trim()}if(t.data.length===0){r.push(t)}}minifyCommentNode(t,e,r){if(!t.data||!e.removeComments){return}if(e.commentIgnorePattern.test(t.data)){return}r.push(t)}async minifyScriptNode(t,e){const r=this.isJson(t);const i=!r&&this.isInlineAmpScript(t);for(const s of t.children||[]){if(!s.data){continue}if(r&&e.minifyJSON){this.minifyJson(s)}else if(i&&e.minifyAmpScript){await this.minifyAmpScript(s)}}}async minifyAmpScript(t){try{const e=await i(t.data,{});if(e.error){this.log.warn("Could not minify inline amp-script",t.data,`${e.error.name}: ${e.error.message}`);return}t.data=e.code}catch(t){this.log.warn("Failed minifying inline amp-script",t)}}minifyJson(t){try{let e=JSON.stringify(JSON.parse(t.data),null,"");e=a(e);t.data=e}catch(e){this.log.warn("Invalid JSON",t.data)}}isInlineAmpScript(t){return t.attribs&&t.attribs.type==="text/plain"&&t.attribs.target==="amp-script"}isJson(t){return t.attribs&&(t.attribs.type==="application/json"||t.attribs.type==="application/ld+json")}canCollapseWhitespace(t){return"script"!==t&&"style"!==t&&"pre"!==t&&"textarea"!==t}canTrimWhitespace(t){return t!=="pre"&&t!=="textarea"}}t.exports=MinifyHtml},8445:(t,e,r)=>{"use strict";const{hasAttribute:i,nextNode:s,firstChildByTag:n}=r(7731);const{skipNodeAndChildren:a}=r(187);const{isValidImageSrcURL:o}=r(5265);const l=100;const c=[39,47,56,68,82,100,120,150,180,220,270,330,390,470,560,680,820,1e3,1200,1440,1750,2e3,2500];const u=c[c-1];const d=3;class SrcsetWidth{constructor(t,e=-1,r=d){this.widthList_=[];this.setBaseWidth(t,e,r)}setBaseWidth(t,e=-1,r=d){this.widthList_.length=0;let i=-1;if(e>0&&t>e){return}for(let s=r;s>0;--s){let r=this.roundUp(t*s);if(e>0&&r>e){r=e}if(r!=i){this.widthList_.push(r)}i=r}}moreWidth(){return this.widthList_.length>0}nextWidth(){return this.widthList_.pop()}isValid(){return this.widthList_.length>1}roundUp(t){for(const e of c){if(e>t){return e}}return c[c.length-1]}}class OptimizeImages{constructor(t){this.log=t.log;this.imageOptimizer=t.imageOptimizer;this.maxImageWidth=u;this.maxSrcsetValues=d}async transform(t){if(!this.imageOptimizer){return}const e=n(t,"html");const r=n(e,"body");let i=r;const o=[];while(i!==null){if(i.tagName==="template"){i=a(i)}else{if(i.tagName==="amp-img"){o.push(this.optimizeImage(i))}i=s(i)}}return Promise.all(o)}async optimizeImage(t){if(i(t,"srcset")){return}if(!i(t,"src")){return}const e=t.attribs.src;if(!o(e)){return}if(e.endsWith(",")){return}const r=t.attribs.width;if(isNaN(Number.parseInt(r))){return}const{layout:s,height:n,sizes:a}=t.attribs;const c=s==="responsive"||!s&&n&&a;if(c&&r<l){return}const u=new SrcsetWidth(r,this.maxImageWidth,this.maxSrcsetValues);if(!u.isValid()){return}let d="";while(u.moreWidth()){const t=u.nextWidth();try{const r=await this.imageOptimizer(e,t);if(r){d+=`${r} ${t}w${u.moreWidth()?", ":""}`}}catch(t){this.log.error("Exception when optimizing image",e,t)}}if(d){t.attribs.srcset=d;this.log.debug("Generating img srcset",e,t.attribs.srcset)}}}t.exports=OptimizeImages},5525:(t,e,r)=>{"use strict";const{appendChild:i,createElement:s,hasAttribute:n,insertAfter:a,nextNode:o,firstChildByTag:l}=r(7731);const{findMetaViewport:c,skipNodeAndChildren:u}=r(187);const{isValidImageSrcURL:d}=r(5265);const h=r(1497);const f=150;const p=2;class PreloadHeroImage{constructor(t){this.log=t.log;this.enabled=t.preloadHeroImage!==false}async transform(t,e){if(!this.enabled||e.preloadHeroImage===false){return}const r=l(t,"html");const i=l(r,"head");const s=l(r,"body");if(!s||!i)return;const n=this.findHeroImages(s);let a=c(i);let o=n.length;if(o>p){this.log.warn(`Found ${o} hero elements on the page. AMP currently only supports a maximum of ${p} elements.`);o=p}const u=h.isAmpStory(i);for(let t=0;t<o;t++){const e=n[t];this.generatePreload(e,i,a);if(!u){this.generateImg(e.ampImg)}}}generatePreload(t,e,r){if(t.srcset){this.log.debug("Could not preload hero image as it's using srcset, which is currently only supported Chromium-based browsers (see https://web.dev/preload-responsive-images/).",t.src);return}if(this.hasExistingImagePreload(e,t.src)){return}const i=s("link",{rel:"preload",href:t.src,as:"image","data-hero":""});if(t.media){i.attribs.media=t.media}a(e,i,r)}hasExistingImagePreload(t,e){return t.children.some((t=>{if(t.tagName!=="link"){return false}if(!n(t,"rel")){return false}if(t.attribs.rel!=="preload"){return false}if(t.attribs.as!=="image"){return false}return t.attribs.href===e}))}findHeroImages(t){let e=null;let r=[];let i=t;while(i!==null){this.addImageWithDataHero(i,r);if(!e&&r.length===0){e=this.isCandidateHeroImage(i)}if(h.isTemplate(i)){i=u(i)}else{i=o(i)}}if(r.length>0){return r}if(e){return[e]}return[]}addImageWithDataHero(t,e){if(t.tagName==="amp-img"&&n(t,"data-hero")){const{src:r,media:i,srcset:s}=t.attribs;e.push({ampImg:t,src:r,media:i,srcset:s})}else if(this.isAmpIframe(t)&&n(t,"data-hero")){const r=this.getPlaceholderImage(t);if(r){e.push(r)}}}isCandidateHeroImage(t){if(!t.tagName){return null}const e=t.attribs?t.attribs.layout:"";if(e==="nodisplay"){return null}if(t.tagName==="amp-img"){return this.isCandidateImageForPreloading(t)}if(t.tagName==="amp-video"){return this.isCandidateVideoPosterImage(t)}if(this.isAmpIframe(t)){return this.isCandidateIframePlaceholderImage(t)}return null}isAmpIframe(t){return t.tagName==="amp-iframe"||t.tagName==="amp-video-iframe"}isCandidateVideoPosterImage(t){const e=t.attribs.poster;if(!e)return null;if(!d(e)){return null}const{layout:r,width:i,height:s,media:n}=t.attribs;if(this.isTinyNode(r,i,s)){return null}return{src:e,media:n,srcset:""}}isCandidateIframePlaceholderImage(t){if(!t.children||t.children.length===0){return null}const{layout:e,width:r,height:i}=t.attribs;if(this.isTinyNode(e,r,i))return null;return this.getPlaceholderImage(t)}getPlaceholderImage(t){for(const e of t.children){if(e.tagName==="amp-img"&&n(e,"placeholder")&&d(e.attribs.src)){return{ampImg:e,src:e.attribs.src,media:t.attribs.media,srcset:e.attribs.srcset||""}}}return null}isCandidateImageForPreloading(t){const e=t.attribs.src;if(!e){return null}if(!d(e)){return null}let{width:r,height:i,srcset:s,layout:n,media:a}=t.attribs;if(!r&&!i){if(n==="fill"){({width:r,height:i}=this.nodeDimensionsFromParent(t))}else{return null}}if(this.isTinyNode(n,r,i)){return null}return{ampImg:t,src:e,srcset:s,media:a}}isTinyNode(t,e,r){if(e<=0||r<=0)return true;if(t==="intrinsic"||t==="responsive"){return false}return e<f||r<f}nodeDimensionsFromParent(t){while(t.parent){t=t.parent;if(!t.attribs){continue}const e=t.attribs.width;const r=t.attribs.height;if(!e&&!r){continue}return{width:e,height:r}}return{width:0,height:0}}generateImg(t){if(!t){return}const e=s("img",{class:"i-amphtml-fill-content i-amphtml-replaced-content",decoding:"async"});const r=["alt","attribution","object-fit","object-position","referrerpolicy","src","srcset","sizes","title"];for(const i of r){if(n(t,i)){e.attribs[i]=t.attribs[i]}}t.attribs["i-amphtml-ssr"]="";t.attribs["data-hero"]="";i(t,e)}}t.exports=PreloadHeroImage},1523:(t,e,r)=>{"use strict";const{createElement:i,nextNode:s,insertAfter:n,firstChildByTag:a}=r(7731);const{findMetaViewport:o,skipNodeAndChildren:l}=r(187);const c=5;class PreloadImages{transform(t,e){const r=e.imagePreloadCount||c;const i=a(t,"html");const u=a(i,"head");const d=a(i,"body");const h=new Map;let f=d;while(f!==null){if(h.size>=r){break}if(f.tagName==="template"){f=l(f)}else{this.addImage(h,f);f=s(f)}}let p=o(u);for(const t of h.values()){n(u,t,p);p=t}}addImage(t,e){const r=this.extractImageUrl(e);if(!r){return}if(e.attribs.srcset){return}t.set(r,this.createPreload(r,e.attribs.media))}extractImageUrl(t){if(!t.attribs){return null}if(t.tagName==="amp-img"){return t.attribs.src}if(t.tagName==="amp-video"){return t.attribs.poster}return null}createPreload(t,e){const r=i("link",{rel:"preload",href:t,as:"image"});if(e){r.attribs.media=e}return r}}t.exports=PreloadImages},1545:(t,e,r)=>{"use strict";const{firstChildByTag:i}=r(7731);const s=new Set(["dns-prefetch","preconnect","prefetch","preload",