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AQ9B,GACT,OAAO,CACR,GAiTI0I,CAAWpD,EAAU,CAAE+C,KAAMjB,EAAQiB,OAGxC,KAYF,SAASR,EAAWc,GACnB,IAAOlC,EAA+B,CACrCA,GAA+B,EAC/B,MAAMmC,EAAUzE,SAAS0E,eACxB,0DACE/E,YACH,GAAK8E,EACJ,IACC,MAAME,EAASC,KAAKC,MAAOJ,GACW,iBAA1BE,GAAQG,MAAMtC,UACzBD,EAAgBC,QAAUmC,EAAOG,KAAKtC,SAEF,iBAAzBmC,GAAQG,MAAMrC,SACzBF,EAAgBE,OAASkC,EAAOG,KAAKrC,OAEvC,CAAE,MAAO,MAMJrB,EAAMwB,WAAWmC,OAAOvC,UAE5BD,EAAgBC,QAAUpB,EAAMwB,WAAWmC,MAAMvC,SAG7CpB,EAAMwB,WAAWmC,OAAOtC,SAE5BF,EAAgBE,OAASrB,EAAMwB,WAAWmC,MAAMtC,OAGnD,CAEA,MAAMuC,EAAUzC,EAAiBiC,GAEjC,sCAA4BS,MAC3B,EAAIC,WAAaA,EAAOF,KAExB,QAEF,CAIyB,aAAnB1H,IAEJ0C,SAASkB,iBACR,SACA,SAAWY,GACV,MAAMP,EAAQO,EAAML,OAAoB0D,QAAS,KAC5C7D,EAAaC,IAASM,EAAcC,KACxCA,EAAMsD,iBACN1C,EAAQM,SAAUzB,EAAIxD,MAExB,IACA,GAGDiC,SAASkB,iBACR,cACA,SAAWY,GACV,GAA+C,MAAxCA,EAAML,QAAqB5C,SAAmB,CACpD,MAAM0C,EAAQO,EAAML,OAAoB0D,QAAS,KAC5C7D,EAAaC,IAASM,EAAcC,IACxCY,EAAQY,SAAU/B,EAAIxD,KAExB,CACD,IACA,I","sources":["webpack://wp/external import \"@wordpress/a11y\"","webpack://wp/webpack/bootstrap","webpack://wp/webpack/runtime/define property getters","webpack://wp/webpack/runtime/hasOwnProperty shorthand","webpack://wp/external module \"@wordpress/interactivity\"","webpack://wp/./packages/interactivity-router/build-module/assets/@wordpress/interactivity-router/src/assets/styles.ts","webpack://wp/./packages/interactivity-router/build-module/@wordpress/interactivity-router/src/index.ts"],"sourcesContent":["module.exports = import(\"@wordpress/a11y\");;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","var x = (y) => {\n\tvar x = {}; __webpack_require__.d(x, y); return x\n} \nvar y = (x) => (() => (x))\nconst __WEBPACK_NAMESPACE_OBJECT__ = x({ [\"getConfig\"]: () => (__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.getConfig), [\"privateApis\"]: () => (__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.privateApis), [\"store\"]: () => (__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.store) });","const cssUrlRegEx =\n\t/url\\(\\s*(?:([\"'])((?:\\\\.|[^\\n\\\\\"'])+)\\1|((?:\\\\.|[^\\s,\"'()\\\\])+))\\s*\\)/g;\n\nconst resolveUrl = ( relativeUrl: string, baseUrl: string ) => {\n\ttry {\n\t\treturn new URL( relativeUrl, baseUrl ).toString();\n\t} catch ( e ) {\n\t\treturn relativeUrl;\n\t}\n};\n\nconst withAbsoluteUrls = ( cssText: string, baseUrl: string ) =>\n\tcssText.replace(\n\t\tcssUrlRegEx,\n\t\t( _match, quotes = '', relUrl1, relUrl2 ) =>\n\t\t\t`url(${ quotes }${ resolveUrl(\n\t\t\t\trelUrl1 || relUrl2,\n\t\t\t\tbaseUrl\n\t\t\t) }${ quotes })`\n\t);\n\nconst styleSheetCache = new Map< string, Promise< CSSStyleSheet > >();\n\nconst getCachedSheet = async (\n\tsheetId: string,\n\tfactory: () => Promise< CSSStyleSheet >\n) => {\n\tif ( ! styleSheetCache.has( sheetId ) ) {\n\t\tstyleSheetCache.set( sheetId, factory() );\n\t}\n\treturn styleSheetCache.get( sheetId );\n};\n\nconst sheetFromLink = async (\n\t{ id, href, sheet: elementSheet }: HTMLLinkElement,\n\tbaseUrl: string\n) => {\n\tconst sheetId = id || href;\n\tconst sheetUrl = resolveUrl( href, baseUrl );\n\n\tif ( elementSheet ) {\n\t\treturn getCachedSheet( sheetId, () => {\n\t\t\tconst sheet = new CSSStyleSheet();\n\t\t\tfor ( const { cssText } of elementSheet.cssRules ) {\n\t\t\t\tsheet.insertRule( withAbsoluteUrls( cssText, sheetUrl ) );\n\t\t\t}\n\t\t\treturn Promise.resolve( sheet );\n\t\t} );\n\t}\n\treturn getCachedSheet( sheetId, async () => {\n\t\tconst response = await fetch( href );\n\t\tconst text = await response.text();\n\t\tconst sheet = new CSSStyleSheet();\n\t\tawait sheet.replace( withAbsoluteUrls( text, sheetUrl ) );\n\t\treturn sheet;\n\t} );\n};\n\nconst sheetFromStyle = async ( { textContent }: HTMLStyleElement ) => {\n\tconst sheetId = textContent;\n\treturn getCachedSheet( sheetId, async () => {\n\t\tconst sheet = new CSSStyleSheet();\n\t\tawait sheet.replace( textContent );\n\t\treturn sheet;\n\t} );\n};\n\nexport const generateCSSStyleSheets = (\n\tdoc: Document,\n\tbaseUrl: string = ( doc.location || window.location ).href\n): Promise< CSSStyleSheet >[] =>\n\t[ ...doc.querySelectorAll( 'style,link[rel=stylesheet]' ) ].map(\n\t\t( element ) => {\n\t\t\tif ( 'LINK' === element.nodeName ) {\n\t\t\t\treturn sheetFromLink( element as HTMLLinkElement, baseUrl );\n\t\t\t}\n\t\t\treturn sheetFromStyle( element as HTMLStyleElement );\n\t\t}\n\t);\n","/**\n * WordPress dependencies\n */\nimport { store, privateApis, getConfig } from '@wordpress/interactivity';\n\n/**\n * Internal dependencies\n */\nimport { generateCSSStyleSheets } from './assets/styles';\n\nconst {\n\tdirectivePrefix,\n\tgetRegionRootFragment,\n\tinitialVdom,\n\ttoVdom,\n\trender,\n\tparseServerData,\n\tpopulateServerData,\n\tbatch,\n} = privateApis(\n\t'I acknowledge that using private APIs means my theme or plugin will inevitably break in the next version of WordPress.'\n);\n\ninterface NavigateOptions {\n\tforce?: boolean;\n\thtml?: string;\n\treplace?: boolean;\n\ttimeout?: number;\n\tloadingAnimation?: boolean;\n\tscreenReaderAnnouncement?: boolean;\n}\n\ninterface PrefetchOptions {\n\tforce?: boolean;\n\thtml?: string;\n}\n\ninterface VdomParams {\n\tvdom?: typeof initialVdom;\n\tbaseUrl?: string;\n}\n\ninterface Page {\n\tregions: Record< string, any >;\n\tstyles: Promise< CSSStyleSheet >[];\n\tscriptModules: string[];\n\ttitle: string;\n\tinitialData: any;\n}\n\ntype RegionsToVdom = ( dom: Document, params?: VdomParams ) => Page;\n\n// Check if the navigation mode is full page or region based.\nconst navigationMode: 'regionBased' | 'fullPage' =\n\tgetConfig( 'core/router' ).navigationMode ?? 'regionBased';\n\n// The cache of visited and prefetched pages, stylesheets and scripts.\nconst pages = new Map< string, Promise< Page | false > >();\n\n// Helper to remove domain and hash from the URL. We are only interesting in\n// caching the path and the query.\nconst getPagePath = ( url: string ) => {\n\tconst u = new URL( url, window.location.href );\n\treturn u.pathname + u.search;\n};\n\n// Fetch a new page and convert it to a static virtual DOM.\nconst fetchPage = async ( url: string, { html }: { html: string } ) => {\n\ttry {\n\t\tif ( ! html ) {\n\t\t\tconst res = await window.fetch( url );\n\t\t\tif ( res.status !== 200 ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\thtml = await res.text();\n\t\t}\n\t\tconst dom = new window.DOMParser().parseFromString( html, 'text/html' );\n\t\treturn regionsToVdom( dom, { baseUrl: url } );\n\t} catch ( e ) {\n\t\treturn false;\n\t}\n};\n\n// Return an object with VDOM trees of those HTML regions marked with a\n// `router-region` directive.\nconst regionsToVdom: RegionsToVdom = ( dom, { vdom, baseUrl } = {} ) => {\n\tconst regions = { body: undefined };\n\tconst styles = generateCSSStyleSheets( dom, baseUrl );\n\tconst scriptModules = [\n\t\t...dom.querySelectorAll< HTMLScriptElement >(\n\t\t\t'script[type=module][src]'\n\t\t),\n\t].map( ( s ) => s.src );\n\n\tif ( globalThis.IS_GUTENBERG_PLUGIN ) {\n\t\tif ( navigationMode === 'fullPage' ) {\n\t\t\tregions.body = vdom\n\t\t\t\t? vdom.get( document.body )\n\t\t\t\t: toVdom( dom.body );\n\t\t}\n\t}\n\tif ( navigationMode === 'regionBased' ) {\n\t\tconst attrName = `data-${ directivePrefix }-router-region`;\n\t\tdom.querySelectorAll( `[${ attrName }]` ).forEach( ( region ) => {\n\t\t\tconst id = region.getAttribute( attrName );\n\t\t\tregions[ id ] = vdom?.has( region )\n\t\t\t\t? vdom.get( region )\n\t\t\t\t: toVdom( region );\n\t\t} );\n\t}\n\tconst title = dom.querySelector( 'title' )?.innerText;\n\tconst initialData = parseServerData( dom );\n\treturn { regions, styles, scriptModules, title, initialData };\n};\n\n// Render all interactive regions contained in the given page.\nconst renderRegions = async ( page: Page ) => {\n\t// Wait for styles and modules to be ready.\n\tawait Promise.all( [\n\t\t...page.styles,\n\t\t...page.scriptModules.map(\n\t\t\t( src ) => import( /* webpackIgnore: true */ src )\n\t\t),\n\t] );\n\t// Replace style sheets.\n\tconst sheets = await Promise.all( page.styles );\n\twindow.document\n\t\t.querySelectorAll( 'style,link[rel=stylesheet]' )\n\t\t.forEach( ( element ) => element.remove() );\n\twindow.document.adoptedStyleSheets = sheets;\n\n\tif ( globalThis.IS_GUTENBERG_PLUGIN ) {\n\t\tif ( navigationMode === 'fullPage' ) {\n\t\t\t// Update HTML.\n\t\t\tconst fragment = getRegionRootFragment( document.body );\n\t\t\tbatch( () => {\n\t\t\t\tpopulateServerData( page.initialData );\n\t\t\t\trender( page.regions.body, fragment );\n\t\t\t} );\n\t\t}\n\t}\n\tif ( navigationMode === 'regionBased' ) {\n\t\tconst attrName = `data-${ directivePrefix }-router-region`;\n\t\tbatch( () => {\n\t\t\tpopulateServerData( page.initialData );\n\t\t\tdocument\n\t\t\t\t.querySelectorAll( `[${ attrName }]` )\n\t\t\t\t.forEach( ( region ) => {\n\t\t\t\t\tconst id = region.getAttribute( attrName );\n\t\t\t\t\tconst fragment = getRegionRootFragment( region );\n\t\t\t\t\trender( page.regions[ id ], fragment );\n\t\t\t\t} );\n\t\t} );\n\t}\n\tif ( page.title ) {\n\t\tdocument.title = page.title;\n\t}\n};\n\n/**\n * Load the given page forcing a full page reload.\n *\n * The function returns a promise that won't resolve, useful to prevent any\n * potential feedback indicating that the navigation has finished while the new\n * page is being loaded.\n *\n * @param href The page href.\n * @return Promise that never resolves.\n */\nconst forcePageReload = ( href: string ) => {\n\twindow.location.assign( href );\n\treturn new Promise( () => {} );\n};\n\n// Listen to the back and forward buttons and restore the page if it's in the\n// cache.\nwindow.addEventListener( 'popstate', async () => {\n\tconst pagePath = getPagePath( window.location.href ); // Remove hash.\n\tconst page = pages.has( pagePath ) && ( await pages.get( pagePath ) );\n\tif ( page ) {\n\t\tawait renderRegions( page );\n\t\t// Update the URL in the state.\n\t\tstate.url = window.location.href;\n\t} else {\n\t\twindow.location.reload();\n\t}\n} );\n\n// Initialize the router and cache the initial page using the initial vDOM.\n// Once this code is tested and more mature, the head should be updated for\n// region based navigation as well.\npages.set(\n\tgetPagePath( window.location.href ),\n\tPromise.resolve(\n\t\tregionsToVdom( document, {\n\t\t\tvdom: initialVdom,\n\t\t\tbaseUrl: window.location.href,\n\t\t} )\n\t)\n);\n\n// Check if the link is valid for client-side navigation.\nconst isValidLink = ( ref: HTMLAnchorElement ) =>\n\tref &&\n\tref instanceof window.HTMLAnchorElement &&\n\tref.href &&\n\t( ! ref.target || ref.target === '_self' ) &&\n\tref.origin === window.location.origin &&\n\t! ref.pathname.startsWith( '/wp-admin' ) &&\n\t! ref.pathname.startsWith( '/wp-login.php' ) &&\n\t! ref.getAttribute( 'href' ).startsWith( '#' ) &&\n\t! new URL( ref.href ).searchParams.has( '_wpnonce' );\n\n// Check if the event is valid for client-side navigation.\nconst isValidEvent = ( event: MouseEvent ) =>\n\tevent &&\n\tevent.button === 0 && // Left clicks only.\n\t! event.metaKey && // Open in new tab (Mac).\n\t! event.ctrlKey && // Open in new tab (Windows).\n\t! event.altKey && // Download.\n\t! event.shiftKey &&\n\t! event.defaultPrevented;\n\n// Variable to store the current navigation.\nlet navigatingTo = '';\n\nlet hasLoadedNavigationTextsData = false;\nconst navigationTexts = {\n\tloading: 'Loading page, please wait.',\n\tloaded: 'Page Loaded.',\n};\n\ninterface Store {\n\tstate: {\n\t\turl: string;\n\t\tnavigation: {\n\t\t\tisLoading: boolean;\n\t\t\thasStarted: boolean;\n\t\t\thasFinished: boolean;\n\t\t};\n\t};\n\tactions: {\n\t\tnavigate: ( href: string, options?: NavigateOptions ) => void;\n\t\tprefetch: ( url: string, options?: PrefetchOptions ) => void;\n\t};\n}\n\nexport const { state, actions } = store< Store >( 'core/router', {\n\tstate: {\n\t\turl: window.location.href,\n\t\tnavigation: {\n\t\t\tisLoading: false,\n\t\t\thasStarted: false,\n\t\t\thasFinished: false,\n\t\t},\n\t},\n\tactions: {\n\t\t/**\n\t\t * Navigates to the specified page.\n\t\t *\n\t\t * This function normalizes the passed href, fetches the page HTML if\n\t\t * needed, and updates any interactive regions whose contents have\n\t\t * changed. It also creates a new entry in the browser session history.\n\t\t *\n\t\t * @param href The page href.\n\t\t * @param [options] Options object.\n\t\t * @param [options.force] If true, it forces re-fetching the URL.\n\t\t * @param [options.html] HTML string to be used instead of fetching the requested URL.\n\t\t * @param [options.replace] If true, it replaces the current entry in the browser session history.\n\t\t * @param [options.timeout] Time until the navigation is aborted, in milliseconds. Default is 10000.\n\t\t * @param [options.loadingAnimation] Whether an animation should be shown while navigating. Default to `true`.\n\t\t * @param [options.screenReaderAnnouncement] Whether a message for screen readers should be announced while navigating. Default to `true`.\n\t\t *\n\t\t * @return Promise that resolves once the navigation is completed or aborted.\n\t\t */\n\t\t*navigate( href: string, options: NavigateOptions = {} ) {\n\t\t\tconst { clientNavigationDisabled } = getConfig();\n\t\t\tif ( clientNavigationDisabled ) {\n\t\t\t\tyield forcePageReload( href );\n\t\t\t}\n\n\t\t\tconst pagePath = getPagePath( href );\n\t\t\tconst { navigation } = state;\n\t\t\tconst {\n\t\t\t\tloadingAnimation = true,\n\t\t\t\tscreenReaderAnnouncement = true,\n\t\t\t\ttimeout = 10000,\n\t\t\t} = options;\n\n\t\t\tnavigatingTo = href;\n\t\t\tactions.prefetch( pagePath, options );\n\n\t\t\t// Create a promise that resolves when the specified timeout ends.\n\t\t\t// The timeout value is 10 seconds by default.\n\t\t\tconst timeoutPromise = new Promise< void >( ( resolve ) =>\n\t\t\t\tsetTimeout( resolve, timeout )\n\t\t\t);\n\n\t\t\t// Don't update the navigation status immediately, wait 400 ms.\n\t\t\tconst loadingTimeout = setTimeout( () => {\n\t\t\t\tif ( navigatingTo !== href ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tnavigation.isLoading = true;\n\t\t\t\tif ( loadingAnimation ) {\n\t\t\t\t\tnavigation.hasStarted = true;\n\t\t\t\t\tnavigation.hasFinished = false;\n\t\t\t\t}\n\t\t\t\tif ( screenReaderAnnouncement ) {\n\t\t\t\t\ta11ySpeak( 'loading' );\n\t\t\t\t}\n\t\t\t}, 400 );\n\n\t\t\tconst page = yield Promise.race( [\n\t\t\t\tpages.get( pagePath ),\n\t\t\t\ttimeoutPromise,\n\t\t\t] );\n\n\t\t\t// Dismiss loading message if it hasn't been added yet.\n\t\t\tclearTimeout( loadingTimeout );\n\n\t\t\t// Once the page is fetched, the destination URL could have changed\n\t\t\t// (e.g., by clicking another link in the meantime). If so, bail\n\t\t\t// out, and let the newer execution to update the HTML.\n\t\t\tif ( navigatingTo !== href ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tpage &&\n\t\t\t\t! page.initialData?.config?.[ 'core/router' ]\n\t\t\t\t\t?.clientNavigationDisabled\n\t\t\t) {\n\t\t\t\tyield renderRegions( page );\n\t\t\t\twindow.history[\n\t\t\t\t\toptions.replace ? 'replaceState' : 'pushState'\n\t\t\t\t]( {}, '', href );\n\n\t\t\t\t// Update the URL in the state.\n\t\t\t\tstate.url = href;\n\n\t\t\t\t// Update the navigation status once the the new page rendering\n\t\t\t\t// has been completed.\n\t\t\t\tnavigation.isLoading = false;\n\t\t\t\tif ( loadingAnimation ) {\n\t\t\t\t\tnavigation.hasStarted = false;\n\t\t\t\t\tnavigation.hasFinished = true;\n\t\t\t\t}\n\n\t\t\t\tif ( screenReaderAnnouncement ) {\n\t\t\t\t\ta11ySpeak( 'loaded' );\n\t\t\t\t}\n\n\t\t\t\t// Scroll to the anchor if exits in the link.\n\t\t\t\tconst { hash } = new URL( href, window.location.href );\n\t\t\t\tif ( hash ) {\n\t\t\t\t\tdocument.querySelector( hash )?.scrollIntoView();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tyield forcePageReload( href );\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Prefetches the page with the passed URL.\n\t\t *\n\t\t * The function normalizes the URL and stores internally the fetch\n\t\t * promise, to avoid triggering a second fetch for an ongoing request.\n\t\t *\n\t\t * @param url The page URL.\n\t\t * @param [options] Options object.\n\t\t * @param [options.force] Force fetching the URL again.\n\t\t * @param [options.html] HTML string to be used instead of fetching the requested URL.\n\t\t */\n\t\tprefetch( url: string, options: PrefetchOptions = {} ) {\n\t\t\tconst { clientNavigationDisabled } = getConfig();\n\t\t\tif ( clientNavigationDisabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst pagePath = getPagePath( url );\n\t\t\tif ( options.force || ! pages.has( pagePath ) ) {\n\t\t\t\tpages.set(\n\t\t\t\t\tpagePath,\n\t\t\t\t\tfetchPage( pagePath, { html: options.html } )\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t},\n} );\n\n/**\n * Announces a message to screen readers.\n *\n * This is a wrapper around the `@wordpress/a11y` package's `speak` function. It handles importing\n * the package on demand and should be used instead of calling `ally.speak` direacly.\n *\n * @param messageKey The message to be announced by assistive technologies.\n */\nfunction a11ySpeak( messageKey: keyof typeof navigationTexts ) {\n\tif ( ! hasLoadedNavigationTextsData ) {\n\t\thasLoadedNavigationTextsData = true;\n\t\tconst content = document.getElementById(\n\t\t\t'wp-script-module-data-@wordpress/interactivity-router'\n\t\t)?.textContent;\n\t\tif ( content ) {\n\t\t\ttry {\n\t\t\t\tconst parsed = JSON.parse( content );\n\t\t\t\tif ( typeof parsed?.i18n?.loading === 'string' ) {\n\t\t\t\t\tnavigationTexts.loading = parsed.i18n.loading;\n\t\t\t\t}\n\t\t\t\tif ( typeof parsed?.i18n?.loaded === 'string' ) {\n\t\t\t\t\tnavigationTexts.loaded = parsed.i18n.loaded;\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t} else {\n\t\t\t// Fallback to localized strings from Interactivity API state.\n\t\t\t// @todo This block is for Core < 6.7.0. Remove when support is dropped.\n\n\t\t\t// @ts-expect-error\n\t\t\tif ( state.navigation.texts?.loading ) {\n\t\t\t\t// @ts-expect-error\n\t\t\t\tnavigationTexts.loading = state.navigation.texts.loading;\n\t\t\t}\n\t\t\t// @ts-expect-error\n\t\t\tif ( state.navigation.texts?.loaded ) {\n\t\t\t\t// @ts-expect-error\n\t\t\t\tnavigationTexts.loaded = state.navigation.texts.loaded;\n\t\t\t}\n\t\t}\n\t}\n\n\tconst message = navigationTexts[ messageKey ];\n\n\timport( '@wordpress/a11y' ).then(\n\t\t( { speak } ) => speak( message ),\n\t\t// Ignore failures to load the a11y module.\n\t\t() => {}\n\t);\n}\n\n// Add click and prefetch to all links.\nif ( globalThis.IS_GUTENBERG_PLUGIN ) {\n\tif ( navigationMode === 'fullPage' ) {\n\t\t// Navigate on click.\n\t\tdocument.addEventListener(\n\t\t\t'click',\n\t\t\tfunction ( event ) {\n\t\t\t\tconst ref = ( event.target as Element ).closest( 'a' );\n\t\t\t\tif ( isValidLink( ref ) && isValidEvent( event ) ) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tactions.navigate( ref.href );\n\t\t\t\t}\n\t\t\t},\n\t\t\ttrue\n\t\t);\n\t\t// Prefetch on hover.\n\t\tdocument.addEventListener(\n\t\t\t'mouseenter',\n\t\t\tfunction ( event ) {\n\t\t\t\tif ( ( event.target as Element )?.nodeName === 'A' ) {\n\t\t\t\t\tconst ref = ( event.target as Element ).closest( 'a' );\n\t\t\t\t\tif ( isValidLink( ref ) && isValidEvent( event ) ) {\n\t\t\t\t\t\tactions.prefetch( ref.href );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\ttrue\n\t\t);\n\t}\n}\n"],"names":["module","exports","import","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","d","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","y","__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__","x","cssUrlRegEx","resolveUrl","relativeUrl","baseUrl","URL","toString","e","withAbsoluteUrls","cssText","replace","_match","quotes","relUrl1","relUrl2","styleSheetCache","Map","getCachedSheet","async","sheetId","factory","has","set","directivePrefix","getRegionRootFragment","initialVdom","toVdom","render","parseServerData","populateServerData","batch","privateApis","navigationMode","_getConfig$navigation","getConfig","pages","getPagePath","url","u","window","location","href","pathname","search","regionsToVdom","dom","vdom","regions","body","styles","generateCSSStyleSheets","doc","querySelectorAll","map","element","nodeName","id","sheet","elementSheet","sheetUrl","CSSStyleSheet","cssRules","insertRule","Promise","resolve","response","fetch","text","sheetFromLink","textContent","sheetFromStyle","scriptModules","s","src","document","attrName","forEach","region","getAttribute","title","querySelector","innerText","initialData","renderRegions","all","page","sheets","remove","adoptedStyleSheets","fragment","forcePageReload","assign","addEventListener","pagePath","state","reload","isValidLink","ref","HTMLAnchorElement","target","origin","startsWith","searchParams","isValidEvent","event","button","metaKey","ctrlKey","altKey","shiftKey","defaultPrevented","navigatingTo","hasLoadedNavigationTextsData","navigationTexts","loading","loaded","actions","store","navigation","isLoading","hasStarted","hasFinished","navigate","options","clientNavigationDisabled","loadingAnimation","screenReaderAnnouncement","timeout","prefetch","timeoutPromise","setTimeout","loadingTimeout","a11ySpeak","race","clearTimeout","config","history","hash","scrollIntoView","force","html","res","status","DOMParser","parseFromString","fetchPage","messageKey","content","getElementById","parsed","JSON","parse","i18n","texts","message","then","speak","closest","preventDefault"],"sourceRoot":""}