PageSourceSearch

https://genkit.dev/_astro/DocsLanguageClient.astro_astro_type_script_index_0_lang.BawiTTpR.js

js genkit.dev collected 2026-09-24 10:29:18 UTC 4,268 bytes, 1 lines download raw bytes

1const d=["js","go","dart","python"],c={globalPreference:"genkit-global-language-preference",currentLanguage:"genkit-current-language"},m={js:"js",javascript:"js",go:"go",golang:"go",python:"python",py:"python",dart:"dart"},w={docLanguageSupport:{},docLanguageAgnostic:{}};function l(g){return m[g.toLowerCase()]||"js"}class A{docLanguageSupport;docLanguageAgnostic;isInitialized=!1;setDocConfig(t){Object.keys(t.docLanguageSupport).length>0&&(this.docLanguageSupport=t.docLanguageSupport),Object.keys(t.docLanguageAgnostic).length>0&&(this.docLanguageAgnostic=t.docLanguageAgnostic)}constructor(t=w){this.docLanguageSupport=t.docLanguageSupport,this.docLanguageAgnostic=t.docLanguageAgnostic,!this.redirectNeutralDocsPathToCanonicalLanguage()&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>this.init(),{once:!0}):this.init())}init(){this.rewriteDocsEntryLinks(),!this.redirectNeutralDocsPathToCanonicalLanguage()&&(this.setupLanguage(),this.isInitialized||(this.setupEventListeners(),this.isInitialized=!0))}getStoredLanguage(t){const o=[c.currentLanguage,c.globalPreference];for(const e of o){const a=localStorage.getItem(e);if(!a)continue;const n=l(a);if(t.includes(n))return n}return d.find(e=>t.includes(e))||null}rewriteDocsEntryLinks(){const t=this.getStoredLanguage([...d])||"js";document.querySelectorAll("[data-genkit-docs-entry]").forEach(o=>{const a=(o.getAttribute("href")||"").replace(/\/$/,"").match(/^\/docs\/([^/?#]+)$/);if(!a)return;const n=a[1];d.includes(n)||(o.href=`/docs/${t}/${n}/`)})}redirectNeutralDocsPathToCanonicalLanguage(){const t=window.location.pathname.replace(/\/$/,"")||"/";if(!t.startsWith("/docs/")||/^\/docs\/(js|go|dart|python)(\/|$)/.test(t))return!1;const o=this.docLanguageSupport[t];if(!Array.isArray(o)||o.length===0||this.docLanguageAgnostic[t])return!1;const e=this.getStoredLanguage(o);if(!e)return!1;const a=t.replace(/^\/docs\//,""),n=`/docs/${e}/${a}/`,i=`${n}${window.location.search}${window.location.hash}`;return window.location.pathname===n?!1:(window.location.replace(i),!0)}setupLanguage(){const o=new URLSearchParams(window.location.search).get("lang"),e=window.location.pathname.match(/^\/docs\/(js|go|dart|python)(\/|$)/),a=e?e[1]:null,n=o?l(o):null,i=window.location.pathname.match(/^\/docs\/(js|go|dart|python)\/(.+)$/);if(a&&i&&n){const r=i[2].replace(/\/$/,""),u=`/docs/${r}`,p=this.docLanguageSupport[u];if(!!!this.docLanguageAgnostic[u]&&Array.isArray(p)&&p.includes(n)&&n!==a){const h=new URL(window.location.href);h.pathname=`/docs/${n}/${r}/`,h.searchParams.delete("lang"),window.location.replace(h.toString());return}}const s=a?l(a):n||this.getStoredLanguage([...d])||"js";if(o){const r=new URL(window.location.href);r.searchParams.delete("lang"),window.history.replaceState({},"",r)}localStorage.setItem(c.currentLanguage,s),(o||a)&&localStorage.setItem(c.globalPreference,s),document.documentElement.setAttribute("data-genkit-lang",s),document.dispatchEvent(new CustomEvent("genkit:languagechange",{detail:{language:s}}))}setupEventListeners(){document.addEventListener("astro:page-load",()=>this.init()),window.addEventListener("popstate",()=>this.init()),document.addEventListener("genkit:languagechange",()=>this.rewriteDocsEntryLinks())}setLanguage(t,o=!0){const e=l(t);localStorage.setItem(c.currentLanguage,e),o&&localStorage.setItem(c.globalPreference,e);const a=window.location.pathname.match(/^\/docs\/(js|go|dart|python)\/(.+)$/);if(a){const n=a[2].replace(/\/$/,""),i=`/docs/${n}`,s=this.docLanguageSupport[i],u=this.docLanguageAgnostic[i]?`${i}/`:Array.isArray(s)&&s.includes(e)?`/docs/${e}/${n}/`:`/docs/${e}/overview/`;if(u!==window.location.pathname){window.location.assign(u);return}}document.documentElement.setAttribute("data-genkit-lang",e),document.dispatchEvent(new CustomEvent("genkit:languagechange",{detail:{language:e}}))}}function S(g=w){return window.unifiedPageManager?(window.unifiedPageManager.setDocConfig(g),window.unifiedPageManager.init(),window.unifiedPageManager):(window.unifiedPageManager=new A(g),window.unifiedPageManager)}const L=document.getElementById("genkit-doc-language-config"),f=L?JSON.parse(L.textContent||"{}"):{};S({docLanguageSupport:f.docLanguageSupport??{},docLanguageAgnostic:f.docLanguageAgnostic??{}});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.