langsys-js-typescript 0.6.4 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ var Langsys=(function(exports){'use strict';var ni={log:"display:inline-block;background:rgb(239,239,244);color:black;font-weight:bold;padding:3px 7px;border-radius:3px",warn:"display:inline-block;background:gold;color:black;font-weight:bold;padding:3px 7px;border-radius:3px",error:"display:inline-block;background:#e0005a;color:#fff;font-weight:bold;padding:3px 7px;border-radius:3px"};function ri(){try{return typeof window>"u"?!1:!(typeof navigator<"u"&&navigator.product==="ReactNative")}catch{return false}}function sn(t,e,n){ri()?console[t](`%c${e}`,ni[t],...n):console[t](`[${e}]`,...n);}var se=class{constructor(e=false){this.debugEnabled=e;}log(...e){this.debugEnabled&&sn("log","Langsys Debug",e);}warn(...e){sn("warn","Langsys Warning",e);}error(...e){sn("error","Langsys Error",e);}},k=new se(false);var si=/^(?:[a-z]{2,3}|[a-z]{5,8})(?:-[a-z]{4})?(?:-(?:[a-z]{2}|\d{3}))?(?=-|$)/i;function v(t){if(!t||typeof t!="string")return t;let e=t.trim().replace(/_/g,"-");try{Intl.getCanonicalLocales(e);let[n]=si.exec(e);return (Intl.getCanonicalLocales(n)[0]+e.slice(n.length)).toLowerCase()}catch{return k.debugEnabled&&k.warn(`"${t}" is not a valid BCP 47 locale tag. Falling back to lowercasing it as-is, which will very likely miss the catalog and render base language with no other symptom.`),e.toLowerCase()}}function on(t){try{let e=new Intl.Locale(v(t)).maximize();return `${e.language}-${e.script??""}`.toLowerCase()}catch{return null}}function B(t){let e=t,n=new Set,r=a=>(n.add(a),a(e),()=>{n.delete(a);}),s=a=>{if(!Object.is(e,a)){e=a;for(let l of n)l(e);}};return {subscribe:r,set:s,update:a=>{s(a(e));},get:()=>e}}function ii(t){return t.get()}var pe=t=>typeof t=="number"||typeof t=="boolean"?false:typeof t>"u"||t===null?true:typeof t.length<"u"?t.length===0:typeof t=="object"?Object.keys(t).length===0:false;function ct(t){if(typeof structuredClone=="function")return structuredClone(t);let e=n=>{if(typeof n!="object"||n===null)return n;if(Array.isArray(n))return n.map(s=>e(s));let r={};for(let s in n)Object.prototype.hasOwnProperty.call(n,s)&&(r[s]=e(n[s]));return r};return e(t)}function oi(t){let e=new TextEncoder().encode(t),n="";for(let r=0;r<e.length;r+=8192)n+=String.fromCharCode(...e.subarray(r,r+8192));return n}function ut(t){return typeof t!="string"&&(t=JSON.stringify(t)),cr(oi(t))}function an(t){return typeof t!="string"&&(t=JSON.stringify(t)),cr(t)}function cr(t){let e="0123456789abcdef";function n(w){let y,x="";for(y=0;y<=3;y++)x+=e.charAt(w>>y*8+4&15)+e.charAt(w>>y*8&15);return x}function r(w,y){let x=(w&65535)+(y&65535);return (w>>16)+(y>>16)+(x>>16)<<16|x&65535}function s(w,y){return w<<y|w>>>32-y}function i(w,y,x,M,j,$){return r(s(r(r(y,w),r(M,$)),j),x)}function o(w,y,x,M,j,$,Q){return i(y&x|~y&M,w,y,j,$,Q)}function a(w,y,x,M,j,$,Q){return i(y&M|x&~M,w,y,j,$,Q)}function l(w,y,x,M,j,$,Q){return i(y^x^M,w,y,j,$,Q)}function c(w,y,x,M,j,$,Q){return i(x^(y|~M),w,y,j,$,Q)}function u(w){let y,x=(w.length+8>>6)+1,M=new Array(x*16);for(y=0;y<x*16;y++)M[y]=0;for(y=0;y<w.length;y++)M[y>>2]|=w.charCodeAt(y)<<y%4*8;return M[y>>2]|=128<<y%4*8,M[x*16-2]=w.length*8,M}let d,f=u(""+t),h=1732584193,g=-271733879,m=-1732584194,p=271733878,A,C,b,_;for(d=0;d<f.length;d+=16)A=h,C=g,b=m,_=p,h=o(h,g,m,p,f[d+0],7,-680876936),p=o(p,h,g,m,f[d+1],12,-389564586),m=o(m,p,h,g,f[d+2],17,606105819),g=o(g,m,p,h,f[d+3],22,-1044525330),h=o(h,g,m,p,f[d+4],7,-176418897),p=o(p,h,g,m,f[d+5],12,1200080426),m=o(m,p,h,g,f[d+6],17,-1473231341),g=o(g,m,p,h,f[d+7],22,-45705983),h=o(h,g,m,p,f[d+8],7,1770035416),p=o(p,h,g,m,f[d+9],12,-1958414417),m=o(m,p,h,g,f[d+10],17,-42063),g=o(g,m,p,h,f[d+11],22,-1990404162),h=o(h,g,m,p,f[d+12],7,1804603682),p=o(p,h,g,m,f[d+13],12,-40341101),m=o(m,p,h,g,f[d+14],17,-1502002290),g=o(g,m,p,h,f[d+15],22,1236535329),h=a(h,g,m,p,f[d+1],5,-165796510),p=a(p,h,g,m,f[d+6],9,-1069501632),m=a(m,p,h,g,f[d+11],14,643717713),g=a(g,m,p,h,f[d+0],20,-373897302),h=a(h,g,m,p,f[d+5],5,-701558691),p=a(p,h,g,m,f[d+10],9,38016083),m=a(m,p,h,g,f[d+15],14,-660478335),g=a(g,m,p,h,f[d+4],20,-405537848),h=a(h,g,m,p,f[d+9],5,568446438),p=a(p,h,g,m,f[d+14],9,-1019803690),m=a(m,p,h,g,f[d+3],14,-187363961),g=a(g,m,p,h,f[d+8],20,1163531501),h=a(h,g,m,p,f[d+13],5,-1444681467),p=a(p,h,g,m,f[d+2],9,-51403784),m=a(m,p,h,g,f[d+7],14,1735328473),g=a(g,m,p,h,f[d+12],20,-1926607734),h=l(h,g,m,p,f[d+5],4,-378558),p=l(p,h,g,m,f[d+8],11,-2022574463),m=l(m,p,h,g,f[d+11],16,1839030562),g=l(g,m,p,h,f[d+14],23,-35309556),h=l(h,g,m,p,f[d+1],4,-1530992060),p=l(p,h,g,m,f[d+4],11,1272893353),m=l(m,p,h,g,f[d+7],16,-155497632),g=l(g,m,p,h,f[d+10],23,-1094730640),h=l(h,g,m,p,f[d+13],4,681279174),p=l(p,h,g,m,f[d+0],11,-358537222),m=l(m,p,h,g,f[d+3],16,-722521979),g=l(g,m,p,h,f[d+6],23,76029189),h=l(h,g,m,p,f[d+9],4,-640364487),p=l(p,h,g,m,f[d+12],11,-421815835),m=l(m,p,h,g,f[d+15],16,530742520),g=l(g,m,p,h,f[d+2],23,-995338651),h=c(h,g,m,p,f[d+0],6,-198630844),p=c(p,h,g,m,f[d+7],10,1126891415),m=c(m,p,h,g,f[d+14],15,-1416354905),g=c(g,m,p,h,f[d+5],21,-57434055),h=c(h,g,m,p,f[d+12],6,1700485571),p=c(p,h,g,m,f[d+3],10,-1894986606),m=c(m,p,h,g,f[d+10],15,-1051523),g=c(g,m,p,h,f[d+1],21,-2054922799),h=c(h,g,m,p,f[d+8],6,1873313359),p=c(p,h,g,m,f[d+15],10,-30611744),m=c(m,p,h,g,f[d+6],15,-1560198380),g=c(g,m,p,h,f[d+13],21,1309151649),h=c(h,g,m,p,f[d+4],6,-145523070),p=c(p,h,g,m,f[d+11],10,-1120210379),m=c(m,p,h,g,f[d+2],15,718787259),g=c(g,m,p,h,f[d+9],21,-343485551),h=r(h,A),g=r(g,C),m=r(m,b),p=r(p,_);return n(h)+n(g)+n(m)+n(p)}var ur=[],dr=null;function ai(t){if(dr=t,!t){_e=void 0;return}for(let e of ur)e.hydrate(t);}function li(t,e,n){let r=Re(),s=e;if(r){let o=ln(r,t,n);o!==void 0&&(s=o);}let i=B(s);return i.subscribe(o=>{let a=Re();if(a)try{a.setItem(t,JSON.stringify(o));}catch{}}),ur.push({hydrate:o=>{let a=ln(o,t,n);a!==void 0&&i.set(a);}}),i}function hr(t,e,n=[]){let r=B(e),s=null,i=false,o=false,a=0,l=false;r.subscribe(u=>{if(a+=1,!i&&a>1&&(o=true),!s||l)return;let d=Re();if(d)try{d.setItem(s,JSON.stringify(u));}catch{}});let c=u=>{let d=u===null?null:`${t}:${u}`;if(d===s)return;let f=Re(),h=d&&f?ln(f,d):void 0,g=i;if(s=d,d!==null&&(i=true),!g&&o&&d!==null){let m=Re();if(m)try{m.setItem(d,JSON.stringify(r.get()));}catch{}return}if(h!==void 0){r.set(h);return}if(g&&d!==null){l=true;try{r.set(ct(e));}finally{l=false;}}};if(n.length){let u=()=>{let f=Re();if(f?.removeItem)for(let h of n)try{f.getItem(h)!==null&&f.removeItem(h);}catch{}},d=c;return {signal:r,scope:f=>{d(f),f!==null&&u();}}}return {signal:r,scope:c}}function ln(t,e,n){for(let r of n?[e,n]:[e])try{let s=t.getItem(r);if(s!==null)return JSON.parse(s)}catch{}}function Re(){return dr??ci()}var _e;function ci(){if(_e!==void 0)return _e;if(typeof window>"u")return _e=null;try{let t=window.localStorage;return t.getItem("__langsys_probe__"),_e=t??null}catch{return _e=null}}var ui={__uncategorized__:{__category__:"__uncategorized__",__symbol__:"__uncategorized__"}},un=hr("langsys:translations",ui,["translations","langsys:translations"]),cn=()=>{};function fr(t){cn=t;}function gr(t,e){return {...t,get:()=>{let n=cn();return n?e(n):t.get()},subscribe:n=>{let r=cn();if(!r)return t.subscribe(n);let s=true;return t.subscribe(i=>{if(s){s=false,n(e(r));return}n(i);})}}}var I=gr(un.signal,t=>t.catalog),ie=()=>un.signal.get(),dt=un.scope,Le=B(void 0),ht=(t,e)=>`${t}:${e}`,pr=B(""),N=gr(pr,t=>t.locale),ft=()=>pr.get(),L={projectid:"",key:"",sUserLocale:B(""),baseLocale:"en",debug:false,key_type:"read"},F=B(void 0),V=B(false),$e=B(void 0),me=B(false),ye=B(200),be=B(0);function dn(t){typeof window>"u"||typeof t=="boolean"&&F.get()!==t&&F.set(t);}var oe=null,gt=[];function di(t){oe=t;}function P(){return oe?.getStore()??gt[gt.length-1]}function mr(t){if(!oe?.enterWith)throw new Error("scope.enter() needs an AsyncLocalStorage: call setRequestScopeStorage(new AsyncLocalStorage()) once at startup, or wrap the render in scope.run().");oe.enterWith(t);}function yr(t,e){if(oe)return oe.run(t,e);gt.push(t);try{return e()}finally{gt.pop();}}function br(t){return oe?oe.run(void 0,t):t()}function G(){return P()?.catalog??ie()}fr(()=>P());var ae=class extends Error{constructor(e){super(e),this.name="LangsysConfigurationError";}},hn=class{constructor(){this.apiurl="https://api.langsys.dev/api";this.config={projectid:"",key:"",sUserLocale:B(""),baseLocale:"en"};}setup(e){e?.key&&e?.projectid&&(this.config=e);}clearCredentials(){this.config={...this.config,projectid:"",key:"",writeGrant:void 0};}hasWriteGrant(){return !!this.config.writeGrant}moduleCredentials(){return this.config}currentCredentials(){return P()?.credentials??this.config}async resolveWriteGrant(e){let n=e.writeGrant;if(!n)return null;try{let r=typeof n=="function"?await n():n;return typeof r=="string"&&r.length>0?r:null}catch(r){return k.warn("LangsysAppAPI: writeGrant provider threw; sending request without a grant",r),null}}async buildHeaders(e){let n={"Content-Type":"application/json; charset=utf-8","x-Authorization":e.key,"X-Langsys-Capabilities":"icu"},r=await this.resolveWriteGrant(e);return r&&(n["X-Write-Grant"]=r),n}setBaseUrl(e){this.apiurl=e.replace(/\/$/,"");}async validate(e){return this.setup(e),await this.get("authorize-project/[projectid]",{},{credentials:this.config})}async getTranslations(e,n={}){let r=n.credentials??this.currentCredentials();return await this.get("translations",{project_id:r.projectid,locale:v(e)},{...n,credentials:r})}async createTranslatableItems(e,n={}){let r=n.credentials??this.currentCredentials();return await this.post("translatable-items",{project_id:r.projectid,translatable_items:e},{...n,credentials:r})}async postDiscoveryHint(e,n={}){return await this.post("discovery/hint",{page_url:e},n)}async post(e,n={},r={}){return await this.send("POST",e,n,r)}async get(e,n={},r={}){return await this.send("GET",e,n,r)}async delete(e,n={},r={}){return await this.send("DELETE",e,n,r)}async patch(e,n={},r={}){return await this.send("PATCH",e,n,r)}async put(e,n={},r={}){return await this.send("PUT",e,n,r)}async send(e,n,r={},s={}){let i=s.credentials??this.currentCredentials();if(!i.projectid||!i.key){if(e!=="GET")throw new ae(`Langsys is not configured: cannot ${e} ${n} without a project id and an API key. Call LangsysApp.init() with both first.`);return {status:false,errors:["Missing projectid or API key in configuration"],http:{status:0,statusText:"Configuration Error",url:`${this.apiurl}/${n}`,data:JSON.stringify(r)}}}n.startsWith("/")&&(n=n.substring(1)),n.includes("/[projectid]")&&(n=n.replaceAll("/[projectid]",`/${i.projectid}`));try{let o=e==="GET"?"?"+new URLSearchParams(r).toString():"",a=await fetch(`${this.apiurl}/${n}${o==="?"?"":o}`,{headers:await this.buildHeaders(i),method:e,body:e==="GET"?void 0:JSON.stringify(r),keepalive:s.keepalive||void 0}),l=a.status===204||a.headers.get("content-length")==="0"?{status:a.ok}:await a.json(),c={status:a.status,statusText:a.statusText,url:a.url,data:JSON.stringify(r)};return l.http=c,a.ok?l:(k.warn("LangsysAppAPI failed to query",l),{status:!1,errors:[`HTTP ${a.status}: ${a.statusText}`],data:l,http:c})}catch(o){let a=o instanceof Error?o.message:"Unknown error occurred";return k.error("LangsysAppAPI Error:",a),k.error("Request details:",{method:e,url:`${this.apiurl}/${n}`,data:r}),{status:false,errors:["Error communicating with API Server",a],http:{status:0,statusText:"Network Error",url:`${this.apiurl}/${n}`,data:JSON.stringify(r)}}}}},S=new hn;var pt="Errors",kr=/\{([a-z][a-z0-9_]*)\}/g;function hi(t){if(typeof t!="string"||t==="")return [];let e=[];for(let n of t.matchAll(kr))e.includes(n[1])||e.push(n[1]);return e}function gn(t,e={}){return String(t).replace(kr,(n,r)=>{if(!Object.prototype.hasOwnProperty.call(e,r))return n;let s=e[r];return s===void 0||typeof s=="object"||typeof s=="function"?n:String(s)})}function Tr(t,e={}){if(!fn(t))return null;let n=u=>t[e[u]??u],r=n("template"),s=n("message"),i=n("params"),o=n("field"),a=n("code"),l=typeof r=="string",c=typeof s=="string";return !l&&!c?null:{...l?{template:r}:{},...fn(i)?{params:i}:{},...c?{message:s}:{},...o!=null&&o!==""?{field:o}:{},...a!=null?{code:a}:{}}}function fi(t,e){let{key:n,resolver:r,pieces:s}=e??{};if(typeof r!="function"&&(typeof n!="string"||n===""))throw new TypeError('resolveServerMessages needs to know where the entries sit: pass { key } with the path your server attaches them under (Laravel: "langsys_errors"), or { resolver }.');if(typeof t=="string")try{t=JSON.parse(t);}catch{return []}let i=typeof r=="function"?r(t):pi(t,n);return gi(i).map(o=>Tr(o,s)).filter(o=>o!==null)}function gi(t){if(Array.isArray(t))return t;if(!fn(t))return [];let e=Object.values(t);return e.every(n=>Array.isArray(n))&&e.length>0?e.flat():[t]}function pi(t,e){let n=t;for(let r of e.split(".")){if(typeof n!="object"||n===null||!Object.prototype.hasOwnProperty.call(n,r))return;n=n[r];}return n}function fn(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var mt="langsys-catalog-snapshot",mi=1,ee=class extends Error{constructor(n,r){super(n);this.reason=r;this.name="SnapshotError";}},wr=["project_id","generated_at","base_locale","locales","categories","catalog"];function yt(t){if(t===null)return "null";if(typeof t=="string"||typeof t=="number"||typeof t=="boolean")return JSON.stringify(t);if(Array.isArray(t))return `[${t.map(yt).join(",")}]`;if(typeof t=="object"){let e=t;return `{${Object.keys(e).filter(r=>e[r]!==void 0).sort(pn).map(r=>`${JSON.stringify(r)}:${yt(e[r])}`).join(",")}}`}throw new TypeError(`A snapshot cannot hold a ${typeof t}.`)}function mn(t){let e={};for(let n of wr)e[n]=t[n];return "sha256:"+bi(yt(e))}function yi(t){let e=[...new Set(t.categories.map(String))].sort(pn),n={};for(let[s,i]of Object.entries(t.catalogs)){let o={};for(let a of e)Object.prototype.hasOwnProperty.call(i,a)&&(o[a]=i[a]);n[s.toLowerCase()]=o;}let r={project_id:String(t.projectId),generated_at:(t.generatedAt??new Date).toISOString().replace(/\.\d{3}Z$/,"Z"),base_locale:t.baseLocale.toLowerCase(),locales:Object.keys(n).sort(pn),categories:e,catalog:n};return {format:mt,version:1,...r,checksum:mn(r)}}function yn(t){let e=t;if(typeof t=="string")try{e=JSON.parse(t);}catch{throw new ee("This is not a Langsys catalog snapshot: it is not JSON.","not-json")}if(typeof e!="object"||e===null||Array.isArray(e))throw new ee("This is not a Langsys catalog snapshot: it is not a JSON object.","not-json");let n=e;if(n.format!==mt)throw new ee(`This is not a Langsys catalog snapshot: its format is ${JSON.stringify(n.format)}, not "${mt}".`,"format");if(n.version!==1)throw new ee(`This snapshot is version ${JSON.stringify(n.version)}; this SDK reads version 1. Export it again.`,"version");for(let r of [...wr,"checksum"])if(!Object.prototype.hasOwnProperty.call(n,r))throw new ee(`This snapshot has no "${r}". Export it again.`,"missing-member");if(n.checksum!==mn(n))throw new ee("This snapshot was changed after it was exported: its checksum does not match. A snapshot is a cache and is never edited; export it again.","checksum");return n}function pn(t,e){let n=t[Symbol.iterator](),r=e[Symbol.iterator]();for(;;){let s=n.next(),i=r.next();if(s.done||i.done)return s.done&&i.done?0:s.done?-1:1;let o=s.value.codePointAt(0)-i.value.codePointAt(0);if(o!==0)return o}}function bi(t){let e=new TextEncoder().encode(t),n=e.length,r=Math.ceil((n+9)/64),s=new Uint32Array(r*16);for(let a=0;a<n;a++)s[a>>2]|=e[a]<<24-a%4*8;s[n>>2]|=128<<24-n%4*8,s[s.length-2]=Math.floor(n*8/4294967296),s[s.length-1]=n*8>>>0;let i=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),o=new Uint32Array(64);for(let a=0;a<s.length;a+=16){for(let p=0;p<16;p++)o[p]=s[a+p];for(let p=16;p<64;p++){let A=Z(o[p-15],7)^Z(o[p-15],18)^o[p-15]>>>3,C=Z(o[p-2],17)^Z(o[p-2],19)^o[p-2]>>>10;o[p]=o[p-16]+A+o[p-7]+C>>>0;}let[l,c,u,d,f,h,g,m]=[i[0],i[1],i[2],i[3],i[4],i[5],i[6],i[7]];for(let p=0;p<64;p++){let A=m+(Z(f,6)^Z(f,11)^Z(f,25))+(f&h^~f&g)+ki[p]+o[p]>>>0,C=(Z(l,2)^Z(l,13)^Z(l,22))+(l&c^l&u^c&u)>>>0;m=g,g=h,h=f,f=d+A>>>0,d=u,u=c,c=l,l=A+C>>>0;}i[0]=i[0]+l>>>0,i[1]=i[1]+c>>>0,i[2]=i[2]+u>>>0,i[3]=i[3]+d>>>0,i[4]=i[4]+f>>>0,i[5]=i[5]+h>>>0,i[6]=i[6]+g>>>0,i[7]=i[7]+m>>>0;}return Array.from(i,a=>a.toString(16).padStart(8,"0")).join("")}function Z(t,e){return t>>>e|t<<32-e}var ki=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);var Sr=5e3,Ti=3e4,wi=200,vr="langsys:hinted:",xe=new Map,bn=false;function Nr(){if(typeof window>"u")return null;try{let t=window.sessionStorage;return t.getItem("__langsys_probe__"),t}catch{return null}}function Si(t){let e=Nr();if(!e)return false;try{return e.getItem(vr+t)!==null}catch{return false}}function Er(t){let e=Nr();if(e)try{e.setItem(vr+t,"1");}catch{}}var Ei="utm_",vi=new Set(["gclid","fbclid","msclkid","mc_cid","mc_eid","ref","ref_src"]),Ni=["token","secret","password","passwd","apikey","authoriz","session","signature","credential","email","oauth","authcode","accesscode"],Ai=new Set(["sig","auth","otp","nonce"]),_i=new Set(["state","sessionstate"]);function Ri(t){return t.toLowerCase().replace(/[-_]/g,"")}function Li(t){let e=t.startsWith("#")?t.slice(1):t;if(!e)return [];let n=e.indexOf("?"),r=n>=0?e.slice(n+1):e,s=[];for(let i of r.split("&")){let o=i.indexOf("=");if(o<=0)continue;let a=i.slice(0,o);try{s.push(decodeURIComponent(a));}catch{s.push(a);}}return s}function xi(t){return Ai.has(t)?true:Ni.some(e=>t.includes(e))}function Ci(t){try{let e=new URL(t);if(e.protocol!=="http:"&&e.protocol!=="https:")return null;e.protocol=e.protocol.toLowerCase(),e.hostname=e.hostname.toLowerCase();let n=[...e.searchParams.keys()],r=[...n,...Li(e.hash)],s=n.length,i=r.map(a=>Ri(a)),o=i.includes("code")&&i.some(a=>_i.has(a));for(let[a,l]of i.entries())if(xi(l)||o&&l==="code"){let c=a>=s?"fragment":"query string";return k.log(`Discovery hint declined: the page URL carries a credential-shaped parameter ("${r[a]??l}") in its ${c}, so this page is not reported for translation. Remove the parameter from the URL if it is not a credential, or expect this page to need translating by hand.`),null}/^#!?\/.+/.test(e.hash)||(e.hash="");for(let a of n){let l=a.toLowerCase();(l.startsWith(Ei)||vi.has(l))&&e.searchParams.delete(a);}return e.searchParams.sort(),e.toString()}catch{return null}}function Pi(t,e){let n=I.get()[t||"__uncategorized__"];return !!n&&Object.prototype.hasOwnProperty.call(n,e)}function bt(t,e){if(typeof window>"u"||bn)return;let n=window.location?.href;if(!n)return;let r=Ci(n);if(!r||Si(r))return;let s=xe.get(r);if(s){s.misses.length<wi&&!s.misses.some(a=>a.category===t&&a.phrase===e)&&s.misses.push({category:t,phrase:e});return}let i=Sr+Math.random()*(Ti-Sr),o={url:r,misses:[{category:t,phrase:e}],timer:setTimeout(()=>{Oi(r);},i)};o.timer.unref?.(),xe.set(r,o);}async function Oi(t){let e=xe.get(t);if(e&&(xe.delete(t),!bn&&F.get()===false)){if($e.get()!==true){k.log("Discovery reporting is not permitted for this API key (auto_discovery disabled) \u2014 not sending");return}if(e.misses.every(n=>Pi(n.category,n.phrase))){Er(t);return}Er(t);try{if((await S.postDiscoveryHint(t,{credentials:S.moduleCredentials()})).http?.status===429){bn=!0;for(let r of xe.values())clearTimeout(r.timer);xe.clear(),k.log("Discovery hints rate-limited; disabled for this session");}}catch(n){k.warn("Discovery hint failed",n);}}}function kt(t,e){let n=e&&e.cache?e.cache:Vi,r=e&&e.serializer?e.serializer:Fi;return (e&&e.strategy?e.strategy:Bi)(t,{cache:n,serializer:r})}function Mi(t){return t==null||typeof t=="number"||typeof t=="boolean"}function Ar(t,e,n,r){let s=Mi(r)?r:n(r),i=e.get(s);return typeof i>"u"&&(i=t.call(this,r),e.set(s,i)),i}function _r(t,e,n){let r=Array.prototype.slice.call(arguments,3),s=n(r),i=e.get(s);return typeof i>"u"&&(i=t.apply(this,r),e.set(s,i)),i}function kn(t,e,n,r,s){return n.bind(e,t,r,s)}function Bi(t,e){let n=t.length===1?Ar:_r;return kn(t,this,n,e.cache.create(),e.serializer)}function Ii(t,e){return kn(t,this,_r,e.cache.create(),e.serializer)}var Fi=function(){return JSON.stringify(arguments)},Ui=class{constructor(){this.cache=Object.create(null);}get(t){return this.cache[t]}set(t,e){this.cache[t]=e;}},Vi={create:function(){return new Ui}},Tt={variadic:Ii};var ji=/(?:[Eec]{1,6}|G{1,5}|[Qq]{1,5}|(?:[yYur]+|U{1,5})|[ML]{1,5}|d{1,2}|D{1,3}|F{1}|[abB]{1,5}|[hkHK]{1,2}|w{1,2}|W{1}|m{1,2}|s{1,2}|[zZOvVxX]{1,4})(?=([^']*'[^']*')*[^']*$)/g;function Cr(t){let e={};return t.replace(ji,n=>{let r=n.length;switch(n[0]){case "G":e.era=r===4?"long":r===5?"narrow":"short";break;case "y":e.year=r===2?"2-digit":"numeric";break;case "Y":case "u":case "U":case "r":throw new RangeError("`Y/u/U/r` (year) patterns are not supported, use `y` instead");case "q":case "Q":throw new RangeError("`q/Q` (quarter) patterns are not supported");case "M":case "L":e.month=["numeric","2-digit","short","long","narrow"][r-1];break;case "w":case "W":throw new RangeError("`w/W` (week) patterns are not supported");case "d":e.day=["numeric","2-digit"][r-1];break;case "D":case "F":case "g":throw new RangeError("`D/F/g` (day) patterns are not supported, use `d` instead");case "E":e.weekday=r===4?"long":r===5?"narrow":"short";break;case "e":if(r<4)throw new RangeError("`e..eee` (weekday) patterns are not supported");e.weekday=["short","long","narrow","short"][r-4];break;case "c":if(r<4)throw new RangeError("`c..ccc` (weekday) patterns are not supported");e.weekday=["short","long","narrow","short"][r-4];break;case "a":e.hour12=true;break;case "b":case "B":throw new RangeError("`b/B` (period) patterns are not supported, use `a` instead");case "h":e.hourCycle="h12",e.hour=["numeric","2-digit"][r-1];break;case "H":e.hourCycle="h23",e.hour=["numeric","2-digit"][r-1];break;case "K":e.hourCycle="h11",e.hour=["numeric","2-digit"][r-1];break;case "k":e.hourCycle="h24",e.hour=["numeric","2-digit"][r-1];break;case "j":case "J":case "C":throw new RangeError("`j/J/C` (hour) patterns are not supported, use `h/H/K/k` instead");case "m":e.minute=["numeric","2-digit"][r-1];break;case "s":e.second=["numeric","2-digit"][r-1];break;case "S":case "A":throw new RangeError("`S/A` (second) patterns are not supported, use `s` instead");case "z":e.timeZoneName=r<4?"short":"long";break;case "Z":case "O":case "v":case "V":case "X":case "x":throw new RangeError("`Z/O/v/V/X/x` (timeZone) patterns are not supported, use `z` instead")}return ""}),e}var $i=/[\t-\r \x85\u200E\u200F\u2028\u2029]/i;function Pr(t){if(t.length===0)throw new Error("Number skeleton cannot be empty");let e=t.split($i).filter(r=>r.length>0),n=[];for(let r of e){let s=r.split("/");if(s.length===0)throw new Error("Invalid number skeleton");let[i,...o]=s;for(let a of o)if(a.length===0)throw new Error("Invalid number skeleton");n.push({stem:i,options:o});}return n}function Di(t){return t.replace(/^(.*?)-/,"")}var Rr=/^\.(?:(0+)(\*)?|(#+)|(0+)(#+))$/g,Or=/^(@+)?(\+|#+)?[rs]?$/g,Gi=/(\*)(0+)|(#+)(0+)|(0+)/g,Mr=/^(0+)$/;function Lr(t){let e={};return t[t.length-1]==="r"?e.roundingPriority="morePrecision":t[t.length-1]==="s"&&(e.roundingPriority="lessPrecision"),t.replace(Or,function(n,r,s){return typeof s!="string"?(e.minimumSignificantDigits=r.length,e.maximumSignificantDigits=r.length):s==="+"?e.minimumSignificantDigits=r.length:r[0]==="#"?e.maximumSignificantDigits=r.length:(e.minimumSignificantDigits=r.length,e.maximumSignificantDigits=r.length+(typeof s=="string"?s.length:0)),""}),e}function Br(t){switch(t){case "sign-auto":return {signDisplay:"auto"};case "sign-accounting":case "()":return {currencySign:"accounting"};case "sign-always":case "+!":return {signDisplay:"always"};case "sign-accounting-always":case "()!":return {signDisplay:"always",currencySign:"accounting"};case "sign-except-zero":case "+?":return {signDisplay:"exceptZero"};case "sign-accounting-except-zero":case "()?":return {signDisplay:"exceptZero",currencySign:"accounting"};case "sign-never":case "+_":return {signDisplay:"never"}}}function zi(t){let e;if(t[0]==="E"&&t[1]==="E"?(e={notation:"engineering"},t=t.slice(2)):t[0]==="E"&&(e={notation:"scientific"},t=t.slice(1)),e){let n=t.slice(0,2);if(n==="+!"?(e.signDisplay="always",t=t.slice(2)):n==="+?"&&(e.signDisplay="exceptZero",t=t.slice(2)),!Mr.test(t))throw new Error("Malformed concise eng/scientific notation");e.minimumIntegerDigits=t.length;}return e}function xr(t){let e={},n=Br(t);return n||e}function Ir(t){let e={};for(let n of t){switch(n.stem){case "percent":case "%":e.style="percent";continue;case "%x100":e.style="percent",e.scale=100;continue;case "currency":e.style="currency",e.currency=n.options[0];continue;case "group-off":case ",_":e.useGrouping=false;continue;case "precision-integer":case ".":e.maximumFractionDigits=0;continue;case "measure-unit":case "unit":e.style="unit",e.unit=Di(n.options[0]);continue;case "compact-short":case "K":e.notation="compact",e.compactDisplay="short";continue;case "compact-long":case "KK":e.notation="compact",e.compactDisplay="long";continue;case "scientific":e={...e,notation:"scientific",...n.options.reduce((i,o)=>({...i,...xr(o)}),{})};continue;case "engineering":e={...e,notation:"engineering",...n.options.reduce((i,o)=>({...i,...xr(o)}),{})};continue;case "notation-simple":e.notation="standard";continue;case "unit-width-narrow":e.currencyDisplay="narrowSymbol",e.unitDisplay="narrow";continue;case "unit-width-short":e.currencyDisplay="code",e.unitDisplay="short";continue;case "unit-width-full-name":e.currencyDisplay="name",e.unitDisplay="long";continue;case "unit-width-iso-code":e.currencyDisplay="symbol";continue;case "scale":e.scale=parseFloat(n.options[0]);continue;case "rounding-mode-floor":e.roundingMode="floor";continue;case "rounding-mode-ceiling":e.roundingMode="ceil";continue;case "rounding-mode-down":e.roundingMode="trunc";continue;case "rounding-mode-up":e.roundingMode="expand";continue;case "rounding-mode-half-even":e.roundingMode="halfEven";continue;case "rounding-mode-half-down":e.roundingMode="halfTrunc";continue;case "rounding-mode-half-up":e.roundingMode="halfExpand";continue;case "integer-width":if(n.options.length>1)throw new RangeError("integer-width stems only accept a single optional option");n.options[0].replace(Gi,function(i,o,a,l,c,u){if(o)e.minimumIntegerDigits=a.length;else {if(l&&c)throw new Error("We currently do not support maximum integer digits");if(u)throw new Error("We currently do not support exact integer digits")}return ""});continue}if(Mr.test(n.stem)){e.minimumIntegerDigits=n.stem.length;continue}if(Rr.test(n.stem)){if(n.options.length>1)throw new RangeError("Fraction-precision stems only accept a single optional option");n.stem.replace(Rr,function(o,a,l,c,u,d){return l==="*"?e.minimumFractionDigits=a.length:c&&c[0]==="#"?e.maximumFractionDigits=c.length:u&&d?(e.minimumFractionDigits=u.length,e.maximumFractionDigits=u.length+d.length):(e.minimumFractionDigits=a.length,e.maximumFractionDigits=a.length),""});let i=n.options[0];i==="w"?e={...e,trailingZeroDisplay:"stripIfInteger"}:i&&(e={...e,...Lr(i)});continue}if(Or.test(n.stem)){e={...e,...Lr(n.stem)};continue}let r=Br(n.stem);r&&(e={...e,...r});let s=zi(n.stem);s&&(e={...e,...s});}return e}var Wi=(function(t){return t[t.EXPECT_ARGUMENT_CLOSING_BRACE=1]="EXPECT_ARGUMENT_CLOSING_BRACE",t[t.EMPTY_ARGUMENT=2]="EMPTY_ARGUMENT",t[t.MALFORMED_ARGUMENT=3]="MALFORMED_ARGUMENT",t[t.EXPECT_ARGUMENT_TYPE=4]="EXPECT_ARGUMENT_TYPE",t[t.INVALID_ARGUMENT_TYPE=5]="INVALID_ARGUMENT_TYPE",t[t.EXPECT_ARGUMENT_STYLE=6]="EXPECT_ARGUMENT_STYLE",t[t.INVALID_NUMBER_SKELETON=7]="INVALID_NUMBER_SKELETON",t[t.INVALID_DATE_TIME_SKELETON=8]="INVALID_DATE_TIME_SKELETON",t[t.EXPECT_NUMBER_SKELETON=9]="EXPECT_NUMBER_SKELETON",t[t.EXPECT_DATE_TIME_SKELETON=10]="EXPECT_DATE_TIME_SKELETON",t[t.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE=11]="UNCLOSED_QUOTE_IN_ARGUMENT_STYLE",t[t.EXPECT_SELECT_ARGUMENT_OPTIONS=12]="EXPECT_SELECT_ARGUMENT_OPTIONS",t[t.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE=13]="EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE",t[t.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE=14]="INVALID_PLURAL_ARGUMENT_OFFSET_VALUE",t[t.EXPECT_SELECT_ARGUMENT_SELECTOR=15]="EXPECT_SELECT_ARGUMENT_SELECTOR",t[t.EXPECT_PLURAL_ARGUMENT_SELECTOR=16]="EXPECT_PLURAL_ARGUMENT_SELECTOR",t[t.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT=17]="EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT",t[t.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT=18]="EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT",t[t.INVALID_PLURAL_ARGUMENT_SELECTOR=19]="INVALID_PLURAL_ARGUMENT_SELECTOR",t[t.DUPLICATE_PLURAL_ARGUMENT_SELECTOR=20]="DUPLICATE_PLURAL_ARGUMENT_SELECTOR",t[t.DUPLICATE_SELECT_ARGUMENT_SELECTOR=21]="DUPLICATE_SELECT_ARGUMENT_SELECTOR",t[t.MISSING_OTHER_CLAUSE=22]="MISSING_OTHER_CLAUSE",t[t.INVALID_TAG=23]="INVALID_TAG",t[t.INVALID_TAG_NAME=25]="INVALID_TAG_NAME",t[t.UNMATCHED_CLOSING_TAG=26]="UNMATCHED_CLOSING_TAG",t[t.UNCLOSED_TAG=27]="UNCLOSED_TAG",t})({});function Sn(t){return t.type===0}function Ur(t){return t.type===1}function En(t){return t.type===2}function vn(t){return t.type===3}function Nn(t){return t.type===4}function An(t){return t.type===5}function _n(t){return t.type===6}function Vr(t){return t.type===7}function Rn(t){return t.type===8}function Ln(t){return !!(t&&typeof t=="object"&&t.type===0)}function St(t){return !!(t&&typeof t=="object"&&t.type===1)}var jr=/[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/,wt={"001":["H","h"],419:["h","H","hB","hb"],AC:["H","h","hb","hB"],AD:["H","hB"],AE:["h","hB","hb","H"],AF:["H","hb","hB","h"],AG:["h","hb","H","hB"],AI:["H","h","hb","hB"],AL:["h","H","hB"],AM:["H","hB"],AO:["H","hB"],AR:["h","H","hB","hb"],AS:["h","H"],AT:["H","hB"],AU:["h","hb","H","hB"],AW:["H","hB"],AX:["H"],AZ:["H","hB","h"],BA:["H","hB","h"],BB:["h","hb","H","hB"],BD:["h","hB","H"],BE:["H","hB"],BF:["H","hB"],BG:["H","hB","h"],BH:["h","hB","hb","H"],BI:["H","h"],BJ:["H","hB"],BL:["H","hB"],BM:["h","hb","H","hB"],BN:["hb","hB","h","H"],BO:["h","H","hB","hb"],BQ:["H"],BR:["H","hB"],BS:["h","hb","H","hB"],BT:["h","H"],BW:["H","h","hb","hB"],BY:["H","h"],BZ:["H","h","hb","hB"],CA:["h","hb","H","hB"],CC:["H","h","hb","hB"],CD:["hB","H"],CF:["H","h","hB"],CG:["H","hB"],CH:["H","hB","h"],CI:["H","hB"],CK:["H","h","hb","hB"],CL:["h","H","hB","hb"],CM:["H","h","hB"],CN:["H","hB","hb","h"],CO:["h","H","hB","hb"],CP:["H"],CR:["h","H","hB","hb"],CU:["h","H","hB","hb"],CV:["H","hB"],CW:["H","hB"],CX:["H","h","hb","hB"],CY:["h","H","hb","hB"],CZ:["H"],DE:["H","hB"],DG:["H","h","hb","hB"],DJ:["h","H"],DK:["H"],DM:["h","hb","H","hB"],DO:["h","H","hB","hb"],DZ:["h","hB","hb","H"],EA:["H","h","hB","hb"],EC:["h","H","hB","hb"],EE:["H","hB"],EG:["h","hB","hb","H"],EH:["h","hB","hb","H"],ER:["h","H"],ES:["H","hB","h","hb"],ET:["hB","hb","h","H"],FI:["H"],FJ:["h","hb","H","hB"],FK:["H","h","hb","hB"],FM:["h","hb","H","hB"],FO:["H","h"],FR:["H","hB"],GA:["H","hB"],GB:["H","h","hb","hB"],GD:["h","hb","H","hB"],GE:["H","hB","h"],GF:["H","hB"],GG:["H","h","hb","hB"],GH:["h","H"],GI:["H","h","hb","hB"],GL:["H","h"],GM:["h","hb","H","hB"],GN:["H","hB"],GP:["H","hB"],GQ:["H","hB","h","hb"],GR:["h","H","hb","hB"],GS:["H","h","hb","hB"],GT:["h","H","hB","hb"],GU:["h","hb","H","hB"],GW:["H","hB"],GY:["h","hb","H","hB"],HK:["h","hB","hb","H"],HN:["h","H","hB","hb"],HR:["H","hB"],HU:["H","h"],IC:["H","h","hB","hb"],ID:["H"],IE:["H","h","hb","hB"],IL:["H","hB"],IM:["H","h","hb","hB"],IN:["h","H"],IO:["H","h","hb","hB"],IQ:["h","hB","hb","H"],IR:["hB","H"],IS:["H"],IT:["H","hB"],JE:["H","h","hb","hB"],JM:["h","hb","H","hB"],JO:["h","hB","hb","H"],JP:["H","K","h"],KE:["hB","hb","H","h"],KG:["H","h","hB","hb"],KH:["hB","h","H","hb"],KI:["h","hb","H","hB"],KM:["H","h","hB","hb"],KN:["h","hb","H","hB"],KP:["h","H","hB","hb"],KR:["h","H","hB","hb"],KW:["h","hB","hb","H"],KY:["h","hb","H","hB"],KZ:["H","hB"],LA:["H","hb","hB","h"],LB:["h","hB","hb","H"],LC:["h","hb","H","hB"],LI:["H","hB","h"],LK:["H","h","hB","hb"],LR:["h","hb","H","hB"],LS:["h","H"],LT:["H","h","hb","hB"],LU:["H","h","hB"],LV:["H","hB","hb","h"],LY:["h","hB","hb","H"],MA:["H","h","hB","hb"],MC:["H","hB"],MD:["H","hB"],ME:["H","hB","h"],MF:["H","hB"],MG:["H","h"],MH:["h","hb","H","hB"],MK:["H","h","hb","hB"],ML:["H"],MM:["hB","hb","H","h"],MN:["H","h","hb","hB"],MO:["h","hB","hb","H"],MP:["h","hb","H","hB"],MQ:["H","hB"],MR:["h","hB","hb","H"],MS:["H","h","hb","hB"],MT:["H","h"],MU:["H","h"],MV:["H","h"],MW:["h","hb","H","hB"],MX:["h","H","hB","hb"],MY:["hb","hB","h","H"],MZ:["H","hB"],NA:["h","H","hB","hb"],NC:["H","hB"],NE:["H"],NF:["H","h","hb","hB"],NG:["H","h","hb","hB"],NI:["h","H","hB","hb"],NL:["H","hB"],NO:["H","h"],NP:["H","h","hB"],NR:["H","h","hb","hB"],NU:["H","h","hb","hB"],NZ:["h","hb","H","hB"],OM:["h","hB","hb","H"],PA:["h","H","hB","hb"],PE:["h","H","hB","hb"],PF:["H","h","hB"],PG:["h","H"],PH:["h","hB","hb","H"],PK:["h","hB","H"],PL:["H","h"],PM:["H","hB"],PN:["H","h","hb","hB"],PR:["h","H","hB","hb"],PS:["h","hB","hb","H"],PT:["H","hB"],PW:["h","H"],PY:["h","H","hB","hb"],QA:["h","hB","hb","H"],RE:["H","hB"],RO:["H","hB"],RS:["H","hB","h"],RU:["H"],RW:["H","h"],SA:["h","hB","hb","H"],SB:["h","hb","H","hB"],SC:["H","h","hB"],SD:["h","hB","hb","H"],SE:["H"],SG:["h","hb","H","hB"],SH:["H","h","hb","hB"],SI:["H","hB"],SJ:["H"],SK:["H"],SL:["h","hb","H","hB"],SM:["H","h","hB"],SN:["H","h","hB"],SO:["h","H"],SR:["H","hB"],SS:["h","hb","H","hB"],ST:["H","hB"],SV:["h","H","hB","hb"],SX:["H","h","hb","hB"],SY:["h","hB","hb","H"],SZ:["h","hb","H","hB"],TA:["H","h","hb","hB"],TC:["h","hb","H","hB"],TD:["h","H","hB"],TF:["H","h","hB"],TG:["H","hB"],TH:["H","h"],TJ:["H","h"],TL:["H","hB","hb","h"],TM:["H","h"],TN:["h","hB","hb","H"],TO:["h","H"],TR:["H","hB"],TT:["h","hb","H","hB"],TW:["hB","hb","h","H"],TZ:["hB","hb","H","h"],UA:["H","hB","h"],UG:["hB","hb","H","h"],UM:["h","hb","H","hB"],US:["h","hb","H","hB"],UY:["h","H","hB","hb"],UZ:["H","hB","h"],VA:["H","h","hB"],VC:["h","hb","H","hB"],VE:["h","H","hB","hb"],VG:["h","hb","H","hB"],VI:["h","hb","H","hB"],VN:["H","h"],VU:["h","H"],WF:["H","hB"],WS:["h","H"],XK:["H","hB","h"],YE:["h","hB","hb","H"],YT:["H","hB"],ZA:["H","h","hb","hB"],ZM:["h","hb","H","hB"],ZW:["H","h"],"af-ZA":["H","h","hB","hb"],"ar-001":["h","hB","hb","H"],"ca-ES":["H","h","hB"],"en-001":["h","hb","H","hB"],"en-HK":["h","hb","H","hB"],"en-IL":["H","h","hb","hB"],"en-MY":["h","hb","H","hB"],"es-BR":["H","h","hB","hb"],"es-ES":["H","h","hB","hb"],"es-GQ":["H","h","hB","hb"],"fr-CA":["H","h","hB"],"gl-ES":["H","h","hB"],"gu-IN":["hB","hb","h","H"],"hi-IN":["hB","h","H"],"it-CH":["H","h","hB"],"it-IT":["H","h","hB"],"kn-IN":["hB","h","H"],"ku-SY":["H","hB"],"ml-IN":["hB","h","H"],"mr-IN":["hB","hb","h","H"],"pa-IN":["hB","hb","h","H"],"ta-IN":["hB","h","hb","H"],"te-IN":["hB","h","H"],"zu-ZA":["H","hB","hb","h"]};function Ki(t,e){let n="";for(let r=0;r<t.length;r++){let s=t.charAt(r);if(s==="j"){let i=0;for(;r+1<t.length&&t.charAt(r+1)===s;)i++,r++;let o=1+(i&1),a=i<2?1:3+(i>>1),l="a",c=qi(e);for((c=="H"||c=="k")&&(a=0);a-- >0;)n+=l;for(;o-- >0;)n=c+n;}else s==="J"?n+="H":n+=s;}return n}function qi(t){let e=t.hourCycle;if(e===void 0&&t.hourCycles&&t.hourCycles.length&&(e=t.hourCycles[0]),e)switch(e){case "h24":return "k";case "h23":return "H";case "h12":return "h";case "h11":return "K";default:throw new Error("Invalid hourCycle")}let n=t.language,r;return n!=="root"&&(r=t.maximize().region),(wt[r||""]||wt[n||""]||wt[`${n}-001`]||wt["001"])[0]}var Zi=new RegExp(`^${jr.source}*`),Xi=new RegExp(`${jr.source}*$`);function E(t,e){return {start:t,end:e}}var Ji=!!Object.fromEntries,Yi=!!String.prototype.trimStart,Qi=!!String.prototype.trimEnd,Hr=Ji?Object.fromEntries:function(e){let n={};for(let[r,s]of e)n[r]=s;return n},eo=Yi?function(e){return e.trimStart()}:function(e){return e.replace(Zi,"")},to=Qi?function(e){return e.trimEnd()}:function(e){return e.replace(Xi,"")},Fr=new RegExp("([^\\p{White_Space}\\p{Pattern_Syntax}]*)","yu");function no(t,e){return Fr.lastIndex=e,Fr.exec(t)[1]??""}var ro=class{constructor(t,e={}){this.message=t,this.position={offset:0,line:1,column:1},this.ignoreTag=!!e.ignoreTag,this.locale=e.locale,this.requiresOtherClause=!!e.requiresOtherClause,this.shouldParseSkeletons=!!e.shouldParseSkeletons;}parse(){if(this.offset()!==0)throw Error("parser can only be used once");return this.parseMessage(0,"",false)}parseMessage(t,e,n){let r=[];for(;!this.isEOF();){let s=this.char();if(s===123){let i=this.parseArgument(t,n);if(i.err)return i;r.push(i.val);}else {if(s===125&&t>0)break;if(s===35&&(e==="plural"||e==="selectordinal")){let i=this.clonePosition();this.bump(),r.push({type:7,location:E(i,this.clonePosition())});}else if(s===60&&!this.ignoreTag&&this.peek()===47){if(n)break;return this.error(26,E(this.clonePosition(),this.clonePosition()))}else if(s===60&&!this.ignoreTag&&Tn(this.peek()||0)){let i=this.parseTag(t,e);if(i.err)return i;r.push(i.val);}else {let i=this.parseLiteral(t,e);if(i.err)return i;r.push(i.val);}}}return {val:r,err:null}}parseTag(t,e){let n=this.clonePosition();this.bump();let r=this.parseTagName();if(this.bumpSpace(),this.bumpIf("/>"))return {val:{type:0,value:`<${r}/>`,location:E(n,this.clonePosition())},err:null};if(this.bumpIf(">")){let s=this.parseMessage(t+1,e,true);if(s.err)return s;let i=s.val,o=this.clonePosition();if(this.bumpIf("</")){if(this.isEOF()||!Tn(this.char()))return this.error(23,E(o,this.clonePosition()));let a=this.clonePosition();return r!==this.parseTagName()?this.error(26,E(a,this.clonePosition())):(this.bumpSpace(),this.bumpIf(">")?{val:{type:8,value:r,children:i,location:E(n,this.clonePosition())},err:null}:this.error(23,E(o,this.clonePosition())))}else return this.error(27,E(n,this.clonePosition()))}else return this.error(23,E(n,this.clonePosition()))}parseTagName(){let t=this.offset();for(this.bump();!this.isEOF()&&io(this.char());)this.bump();return this.message.slice(t,this.offset())}parseLiteral(t,e){let n=this.clonePosition(),r="";for(;;){let i=this.tryParseQuote(e);if(i){r+=i;continue}let o=this.tryParseUnquoted(t,e);if(o){r+=o;continue}let a=this.tryParseLeftAngleBracket();if(a){r+=a;continue}break}let s=E(n,this.clonePosition());return {val:{type:0,value:r,location:s},err:null}}tryParseLeftAngleBracket(){return !this.isEOF()&&this.char()===60&&(this.ignoreTag||!so(this.peek()||0))?(this.bump(),"<"):null}tryParseQuote(t){if(this.isEOF()||this.char()!==39)return null;switch(this.peek()){case 39:return this.bump(),this.bump(),"'";case 123:case 60:case 62:case 125:break;case 35:if(t==="plural"||t==="selectordinal")break;return null;default:return null}this.bump();let e=[this.char()];for(this.bump();!this.isEOF();){let n=this.char();if(n===39)if(this.peek()===39)e.push(39),this.bump();else {this.bump();break}else e.push(n);this.bump();}return String.fromCodePoint(...e)}tryParseUnquoted(t,e){if(this.isEOF())return null;let n=this.char();return n===60||n===123||n===35&&(e==="plural"||e==="selectordinal")||n===125&&t>0?null:(this.bump(),String.fromCodePoint(n))}parseArgument(t,e){let n=this.clonePosition();if(this.bump(),this.bumpSpace(),this.isEOF())return this.error(1,E(n,this.clonePosition()));if(this.char()===125)return this.bump(),this.error(2,E(n,this.clonePosition()));let r=this.parseIdentifierIfPossible().value;if(!r)return this.error(3,E(n,this.clonePosition()));if(this.bumpSpace(),this.isEOF())return this.error(1,E(n,this.clonePosition()));switch(this.char()){case 125:return this.bump(),{val:{type:1,value:r,location:E(n,this.clonePosition())},err:null};case 44:return this.bump(),this.bumpSpace(),this.isEOF()?this.error(1,E(n,this.clonePosition())):this.parseArgumentOptions(t,e,r,n);default:return this.error(3,E(n,this.clonePosition()))}}parseIdentifierIfPossible(){let t=this.clonePosition(),e=this.offset(),n=no(this.message,e),r=e+n.length;return this.bumpTo(r),{value:n,location:E(t,this.clonePosition())}}parseArgumentOptions(t,e,n,r){let s=this.clonePosition(),i=this.parseIdentifierIfPossible().value,o=this.clonePosition();switch(i){case "":return this.error(4,E(s,o));case "number":case "date":case "time":{this.bumpSpace();let a=null;if(this.bumpIf(",")){this.bumpSpace();let u=this.clonePosition(),d=this.parseSimpleArgStyleIfPossible();if(d.err)return d;let f=to(d.val);if(f.length===0)return this.error(6,E(this.clonePosition(),this.clonePosition()));a={style:f,styleLocation:E(u,this.clonePosition())};}let l=this.tryParseArgumentClose(r);if(l.err)return l;let c=E(r,this.clonePosition());if(a&&a.style.startsWith("::")){let u=eo(a.style.slice(2));if(i==="number"){let d=this.parseNumberSkeletonFromString(u,a.styleLocation);return d.err?d:{val:{type:2,value:n,location:c,style:d.val},err:null}}else {if(u.length===0)return this.error(10,c);let d=u;this.locale&&(d=Ki(u,this.locale));let f={type:1,pattern:d,location:a.styleLocation,parsedOptions:this.shouldParseSkeletons?Cr(d):{}};return {val:{type:i==="date"?3:4,value:n,location:c,style:f},err:null}}}return {val:{type:i==="number"?2:i==="date"?3:4,value:n,location:c,style:a?.style??null},err:null}}case "plural":case "selectordinal":case "select":{let a=this.clonePosition();if(this.bumpSpace(),!this.bumpIf(","))return this.error(12,E(a,{...a}));this.bumpSpace();let l=this.parseIdentifierIfPossible(),c=0;if(i!=="select"&&l.value==="offset"){if(!this.bumpIf(":"))return this.error(13,E(this.clonePosition(),this.clonePosition()));this.bumpSpace();let h=this.tryParseDecimalInteger(13,14);if(h.err)return h;this.bumpSpace(),l=this.parseIdentifierIfPossible(),c=h.val;}let u=this.tryParsePluralOrSelectOptions(t,i,e,l);if(u.err)return u;let d=this.tryParseArgumentClose(r);if(d.err)return d;let f=E(r,this.clonePosition());return i==="select"?{val:{type:5,value:n,options:Hr(u.val),location:f},err:null}:{val:{type:6,value:n,options:Hr(u.val),offset:c,pluralType:i==="plural"?"cardinal":"ordinal",location:f},err:null}}default:return this.error(5,E(s,o))}}tryParseArgumentClose(t){return this.isEOF()||this.char()!==125?this.error(1,E(t,this.clonePosition())):(this.bump(),{val:true,err:null})}parseSimpleArgStyleIfPossible(){let t=0,e=this.clonePosition();for(;!this.isEOF();)switch(this.char()){case 39:{this.bump();let n=this.clonePosition();if(!this.bumpUntil("'"))return this.error(11,E(n,this.clonePosition()));this.bump();break}case 123:t+=1,this.bump();break;case 125:if(t>0)t-=1;else return {val:this.message.slice(e.offset,this.offset()),err:null};break;default:this.bump();break}return {val:this.message.slice(e.offset,this.offset()),err:null}}parseNumberSkeletonFromString(t,e){let n=[];try{n=Pr(t);}catch{return this.error(7,e)}return {val:{type:0,tokens:n,location:e,parsedOptions:this.shouldParseSkeletons?Ir(n):{}},err:null}}tryParsePluralOrSelectOptions(t,e,n,r){let s=false,i=[],o=new Set,{value:a,location:l}=r;for(;;){if(a.length===0){let f=this.clonePosition();if(e!=="select"&&this.bumpIf("=")){let h=this.tryParseDecimalInteger(16,19);if(h.err)return h;l=E(f,this.clonePosition()),a=this.message.slice(f.offset,this.offset());}else break}if(o.has(a))return this.error(e==="select"?21:20,l);a==="other"&&(s=true),this.bumpSpace();let c=this.clonePosition();if(!this.bumpIf("{"))return this.error(e==="select"?17:18,E(this.clonePosition(),this.clonePosition()));let u=this.parseMessage(t+1,e,n);if(u.err)return u;let d=this.tryParseArgumentClose(c);if(d.err)return d;i.push([a,{value:u.val,location:E(c,this.clonePosition())}]),o.add(a),this.bumpSpace(),{value:a,location:l}=this.parseIdentifierIfPossible();}return i.length===0?this.error(e==="select"?15:16,E(this.clonePosition(),this.clonePosition())):this.requiresOtherClause&&!s?this.error(22,E(this.clonePosition(),this.clonePosition())):{val:i,err:null}}tryParseDecimalInteger(t,e){let n=1,r=this.clonePosition();this.bumpIf("+")||this.bumpIf("-")&&(n=-1);let s=false,i=0;for(;!this.isEOF();){let a=this.char();if(a>=48&&a<=57)s=true,i=i*10+(a-48),this.bump();else break}let o=E(r,this.clonePosition());return s?(i*=n,Number.isSafeInteger(i)?{val:i,err:null}:this.error(e,o)):this.error(t,o)}offset(){return this.position.offset}isEOF(){return this.offset()===this.message.length}clonePosition(){return {offset:this.position.offset,line:this.position.line,column:this.position.column}}char(){let t=this.position.offset;if(t>=this.message.length)throw Error("out of bound");let e=this.message.codePointAt(t);if(e===void 0)throw Error(`Offset ${t} is at invalid UTF-16 code unit boundary`);return e}error(t,e){return {val:null,err:{kind:t,message:this.message,location:e}}}bump(){if(this.isEOF())return;let t=this.char();t===10?(this.position.line+=1,this.position.column=1,this.position.offset+=1):(this.position.column+=1,this.position.offset+=t<65536?1:2);}bumpIf(t){if(this.message.startsWith(t,this.offset())){for(let e=0;e<t.length;e++)this.bump();return true}return false}bumpUntil(t){let e=this.offset(),n=this.message.indexOf(t,e);return n>=0?(this.bumpTo(n),true):(this.bumpTo(this.message.length),false)}bumpTo(t){if(this.offset()>t)throw Error(`targetOffset ${t} must be greater than or equal to the current offset ${this.offset()}`);for(t=Math.min(t,this.message.length);;){let e=this.offset();if(e===t)break;if(e>t)throw Error(`targetOffset ${t} is at invalid UTF-16 code unit boundary`);if(this.bump(),this.isEOF())break}}bumpSpace(){for(;!this.isEOF()&&oo(this.char());)this.bump();}peek(){if(this.isEOF())return null;let t=this.char(),e=this.offset();return this.message.charCodeAt(e+(t>=65536?2:1))??null}};function Tn(t){return t>=97&&t<=122||t>=65&&t<=90}function so(t){return Tn(t)||t===47}function io(t){return t===45||t===46||t>=48&&t<=57||t===95||t>=97&&t<=122||t>=65&&t<=90||t==183||t>=192&&t<=214||t>=216&&t<=246||t>=248&&t<=893||t>=895&&t<=8191||t>=8204&&t<=8205||t>=8255&&t<=8256||t>=8304&&t<=8591||t>=11264&&t<=12271||t>=12289&&t<=55295||t>=63744&&t<=64975||t>=65008&&t<=65533||t>=65536&&t<=983039}function oo(t){return t>=9&&t<=13||t===32||t===133||t>=8206&&t<=8207||t===8232||t===8233}function wn(t){t.forEach(e=>{if(delete e.location,An(e)||_n(e))for(let n in e.options)delete e.options[n].location,wn(e.options[n].value);else En(e)&&Ln(e.style)||(vn(e)||Nn(e))&&St(e.style)?delete e.style.location:Rn(e)&&wn(e.children);});}function $r(t,e={}){e={shouldParseSkeletons:true,requiresOtherClause:true,...e};let n=new ro(t,e).parse();if(n.err){let r=SyntaxError(Wi[n.err.kind]);throw r.location=n.err.location,r.originalMessage=n.err.message,r}return e?.captureLocation||wn(n.val),n.val}var vt=class extends Error{constructor(t,e,n){super(t),this.code=e,this.originalMessage=n;}toString(){return `[formatjs Error: ${this.code}] ${this.message}`}},Dr=class extends vt{constructor(t,e,n,r){super(`Invalid values for "${t}": "${e}". Options are "${Object.keys(n).join('", "')}"`,"INVALID_VALUE",r);}},ao=class extends vt{constructor(t,e,n){super(`Value for "${t}" must be of type ${e}`,"INVALID_VALUE",n);}},lo=class extends vt{constructor(t,e){super(`The intl string context variable "${t}" was not provided to the string "${e}"`,"MISSING_VALUE",e);}};function co(t){return t.length<2?t:t.reduce((e,n)=>{let r=e[e.length-1];return !r||r.type!==0||n.type!==0?e.push(n):r.value+=n.value,e},[])}function uo(t){return typeof t=="function"}function Et(t,e,n,r,s,i,o){if(t.length===1&&Sn(t[0]))return [{type:0,value:t[0].value}];let a=[];for(let l of t){if(Sn(l)){a.push({type:0,value:l.value});continue}if(Vr(l)){typeof i=="number"&&a.push({type:0,value:n.getNumberFormat(e).format(i)});continue}let{value:c}=l;if(!(s&&c in s))throw new lo(c,o);let u=s[c];if(Ur(l)){(!u||typeof u=="string"||typeof u=="number"||typeof u=="bigint")&&(u=typeof u=="string"||typeof u=="number"||typeof u=="bigint"?String(u):""),a.push({type:typeof u=="string"?0:1,value:u});continue}if(vn(l)){let d=typeof l.style=="string"?r.date[l.style]:St(l.style)?l.style.parsedOptions:void 0;a.push({type:0,value:n.getDateTimeFormat(e,d).format(u)});continue}if(Nn(l)){let d=typeof l.style=="string"?r.time[l.style]:St(l.style)?l.style.parsedOptions:r.time.medium;a.push({type:0,value:n.getDateTimeFormat(e,d).format(u)});continue}if(En(l)){let d=typeof l.style=="string"?r.number[l.style]:Ln(l.style)?l.style.parsedOptions:void 0;if(d&&d.scale){let f=d.scale||1;if(typeof u=="bigint"){if(!Number.isInteger(f))throw new TypeError(`Cannot apply fractional scale ${f} to bigint value. Scale must be an integer when formatting bigint.`);u=u*BigInt(f);}else u=u*f;}a.push({type:0,value:n.getNumberFormat(e,d).format(u)});continue}if(Rn(l)){let{children:d,value:f}=l,h=s[f];if(!uo(h))throw new ao(f,"function",o);let g=h(Et(d,e,n,r,s,i).map(m=>m.value));Array.isArray(g)||(g=[g]),a.push(...g.map(m=>({type:typeof m=="string"?0:1,value:m})));}if(An(l)){let d=u,f=(Object.prototype.hasOwnProperty.call(l.options,d)?l.options[d]:void 0)||l.options.other;if(!f)throw new Dr(l.value,u,Object.keys(l.options),o);a.push(...Et(f.value,e,n,r,s));continue}if(_n(l)){let d=`=${u}`,f=Object.prototype.hasOwnProperty.call(l.options,d)?l.options[d]:void 0;if(!f){if(!Intl.PluralRules)throw new vt(`Intl.PluralRules is not available in this environment.
2
+ Try polyfilling it using "@formatjs/intl-pluralrules"
3
+ `,"MISSING_INTL_API",o);let g=typeof u=="bigint"?Number(u):u,m=n.getPluralRules(e,{type:l.pluralType}).select(g-(l.offset||0));f=(Object.prototype.hasOwnProperty.call(l.options,m)?l.options[m]:void 0)||l.options.other;}if(!f)throw new Dr(l.value,u,Object.keys(l.options),o);let h=typeof u=="bigint"?Number(u):u;a.push(...Et(f.value,e,n,r,s,h-(l.offset||0)));continue}}return co(a)}function ho(t,e){return e?{...t,...e,...Object.keys(t).reduce((n,r)=>(n[r]={...t[r],...e[r]},n),{})}:t}function fo(t,e){return e?Object.keys(t).reduce((n,r)=>(n[r]=ho(t[r],e[r]),n),{...t}):t}function xn(t){return {create(){return {get(e){return t[e]},set(e,n){t[e]=n;}}}}}function go(t={number:{},dateTime:{},pluralRules:{}}){return {getNumberFormat:kt((...e)=>new Intl.NumberFormat(...e),{cache:xn(t.number),strategy:Tt.variadic}),getDateTimeFormat:kt((...e)=>new Intl.DateTimeFormat(...e),{cache:xn(t.dateTime),strategy:Tt.variadic}),getPluralRules:kt((...e)=>new Intl.PluralRules(...e),{cache:xn(t.pluralRules),strategy:Tt.variadic})}}var H,De=(H=class{constructor(e,n=H.defaultLocale,r,s){if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=i=>{let o=this.formatToParts(i);if(o.length===1)return o[0].value;let a=o.reduce((l,c)=>(!l.length||c.type!==0||typeof l[l.length-1]!="string"?l.push(c.value):l[l.length-1]+=c.value,l),[]);return a.length<=1?a[0]||"":a},this.formatToParts=i=>Et(this.ast,this.locales,this.formatters,this.formats,i,void 0,this.message),this.resolvedOptions=()=>({locale:this.resolvedLocale?.toString()||Intl.NumberFormat.supportedLocalesOf(this.locales)[0]}),this.getAst=()=>this.ast,this.locales=n,this.resolvedLocale=H.resolveLocale(n),typeof e=="string"){if(this.message=e,!H.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");let{...i}=s||{};this.ast=H.__parse(e,{...i,locale:this.resolvedLocale});}else this.ast=e;if(!Array.isArray(this.ast))throw new TypeError("A message must be provided as a String or AST.");this.formats=fo(H.formats,r),this.formatters=s&&s.formatters||go(this.formatterCache);}static get defaultLocale(){return H.memoizedDefaultLocale||(H.memoizedDefaultLocale=new Intl.NumberFormat().resolvedOptions().locale),H.memoizedDefaultLocale}},H.memoizedDefaultLocale=null,H.resolveLocale=e=>{if(typeof Intl.Locale>"u")return;let n=Intl.NumberFormat.supportedLocalesOf(e);return n.length>0?new Intl.Locale(n[0]):new Intl.Locale(typeof e=="string"?e:e[0])},H.__parse=$r,H.formats={number:{integer:{maximumFractionDigits:0},currency:{style:"currency"},percent:{style:"percent"}},date:{short:{month:"numeric",day:"numeric",year:"2-digit"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"}},time:{short:{hour:"numeric",minute:"numeric"},medium:{hour:"numeric",minute:"numeric",second:"numeric"},long:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"},full:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"}}},H);var le=["placeholder","alt","title","label","aria-label","aria-placeholder","aria-description","aria-valuetext","aria-roledescription","data-error","data-error-message","data-validation-message","data-invalid-message","data-required-message","data-pattern-message","data-confirm","data-tooltip","data-title","data-content","data-original-title","data-bs-title","data-bs-content","data-loading-text","data-success-message","data-warning-message","data-empty-message","data-placeholder"],te=["script","style","template","noscript","math"];function ke(t){if((t.getAttribute("translate")??"").toLowerCase()==="no")return true;if(!t.hasAttribute("data-notrans"))return false;let e=(t.getAttribute("data-notrans")??"").trim().toLowerCase();return e!=="false"&&e!=="0"}function Ce(t){return ke(t)||te.includes(t.tagName.toLowerCase())}var Nt="data-ls-phrase",Pn="data-langsys-phrase",At=[Nt,Pn],X="data-ls-contentblock",On="data-langsys-contentblock",_t=[X,On],Te="data-ls-resolved",Mn="data-langsys-resolved",ce=[Te,Mn];function R(t){return Rt(t).replace(/\s+/g," ").trim()}function Rt(t){return t.replace(/[\u0001-\u0008\u000B\u000C\u000E-\u001F]/g,"")}function O(t){return t.replace(/%([A-Za-z_][A-Za-z0-9_]*)%/g,"{$1}")}function z(t,e){return ut(Gr(t,e))}function po(t){return !t||t==="__uncategorized__"?"":t}function Gr(t,e){return JSON.stringify([po(t),e])}function Bn(t,e){return an(JSON.stringify([t,e]))}function ue(t){let e=[],n=zr(t,e);return {phrase:O(R(n)),slots:e}}function zr(t,e){let n="";for(let r of t){if("text"in r){n+=r.text;continue}if("param"in r){n+=`{${r.param}}`;continue}let s=e.length;e.push(r.payload),n+=`{m${s}o}`+zr(r.children,e)+`{m${s}c}`;}return n}var Cn="__uncategorized__";function mo(t,e){return t.length===e.length&&t.every((n,r)=>n===e[r])}function Lt(t,e,n=e){let r=t==null||t===""||t===Cn,s=r?"":t,i=r?["",Cn,null]:[s],o=r?["",Cn]:[s],a=!mo(e,n),l=a?[n,e]:[e],c=[];a&&c.push(z(s,[...n]));for(let d of l)for(let f of i)c.push(Bn(f,[...d]));for(let d of l)for(let f of o)c.push(ut([f,...d].join("|")));let u=z(s,[...e]);return [...new Set(c)].filter(d=>d!==u)}function Wr(t,e){let n=i=>O(R(i)),r=new Set(Array.from(t,n)),s=new Set(e.map(n));if(r.size!==s.size)return false;for(let i of r)if(!s.has(i))return false;return true}function ne(t){return yo.test(t)}var yo=/\{[^{}]+,\s*(plural|select|selectordinal|number|date|time)\s*[,}]/;function Xr(t,e){return !t.includes("%")||!e?t:t.replace(/%([A-Za-z_][A-Za-z0-9_]*)%/g,(n,r)=>Object.prototype.hasOwnProperty.call(e,r)?`{${r}}`:n)}var bo=/^[A-Za-z_][A-Za-z0-9_]*$/,ko=/^(.+)_gender$/;function To(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Jr(t,e){if(!e)return [];let n=Object.keys(e);if(!n.length||!t.length)return n;let r=t.join("\0"),s=i=>{let o=To(i),a=bo.test(i)?`|%${o}%`:"";return new RegExp(`\\{\\s*${o}\\s*[,}]${a}`).test(r)};return n.filter(i=>{if(s(i))return false;let o=ko.exec(i)?.[1];return !(o&&s(o))})}function Ct(t,e,n,r){if(!k.debugEnabled)return;let s=Jr(e,n);if(!s.length)return;let i=s.map(o=>`%${o}%`).join(", ");k.warn(`${t} received params with no matching placeholder in its content: ${i}. If you wrote {${s[0]}} or {{ ${s[0]} }} in markup, your framework's template compiler substituted it before Langsys saw the text \u2014 write %${s[0]}% instead.`+(r?` [${r}]`:""));}function U(t,e={},n,r={}){if(t=Xr(t,e),ne(t)){let s=n||"en",i=!!e&&Object.values(e).some(u=>u===null),o;if(!i)try{return Zr(new De(t,s),e,s)}catch(u){o=u;}let a;try{a=new De(t,s).ast;}catch{return In(t,e,n)}if(!Array.isArray(a))return In(t,e,n);let l=[],c=ze(JSON.parse(JSON.stringify(a)),e,l);if(l.length&&(r.onDefaulted?r.onDefaulted([...new Set(l)],t,s):Ao(t,s,l)),l.length||o===void 0)try{return Zr(new De(c,s),e,s)}catch(u){o=u;}return r.onFormatterFailure?r.onFormatterFailure(o,t,s):_o(t,s,o),Ge(a,e,s)}return In(t,e,n)}function wo(t,e={},n="en"){if(t=Xr(t,e),!ne(t))return [];let r;try{r=new De(t,n).ast;}catch{return []}if(!Array.isArray(r))return [];let s=[];return ze(JSON.parse(JSON.stringify(r)),e,s),[...new Set(s)]}var Hn=0,So=1,Eo=2,vo=3,No=4,Yr=5,Qr=6,es=7,ts=8,Kr=new Set;function Ao(t,e,n){if(!k.debugEnabled)return;let r=`${e}\0${t}`;if(Kr.has(r))return;Kr.add(r);let s=[...new Set(n)];k.warn(`Interpolation defaulted ${s.length===1?"argument":"arguments"} ${s.map(i=>`"${i}"`).join(", ")} while rendering a '${e}' string. The translated phrase asks for ${s.length===1?"it":"them"} but the source phrase does not, which is normal \u2014 a gendered target locale can introduce an argument the source never had. The neutral branch was used. Pass ${s.length===1?"the value":"the values"} in \`params\` if your app knows ${s.length===1?"it":"them"}.`);}function ze(t,e,n){let r=[];for(let s of t){let i=s.value,o=i!==void 0&&i in e?e[i]:void 0,a=o!=null;if(s.type===ts){r.push({...s,children:ze(s.children??[],e,n)});continue}if(s.type===Yr||s.type===Qr){if(a){let u={};for(let[d,f]of Object.entries(s.options??{}))u[d]={value:ze(f.value,e,n)};r.push({...s,options:u});continue}let l=s.options?.other;if(!l){r.push(s);continue}i&&n.push(i);let c=ze(l.value,e,n);r.push(...c.map(u=>u.type===es?{type:Hn,value:`{${i}}`}:u));continue}if(!a&&(s.type===So||s.type===Eo||s.type===vo||s.type===No)){i&&n.push(i),r.push({type:Hn,value:`{${i}}`});continue}r.push(s);}return r}var qr=new Set;function _o(t,e,n){let r=`${e}\0${t}`;if(qr.has(r))return;qr.add(r);let s=n instanceof Error?n.message:String(n);k.warn(`The message formatter failed on a '${e}' phrase, so it was rendered by the SDK's own branch selection. Fix the phrase: ${JSON.stringify(t)}. Formatter error: ${s}`);}function Ge(t,e,n,r){let s="";for(let i of t){let o=i.value,a=o!==void 0&&e&&o in e?e[o]:void 0,l=a!=null;switch(i.type){case Hn:s+=i.value??"";break;case es:s+=r===void 0?"#":typeof r=="string"?r:xt(r,n);break;case ts:s+=`<${o}>${Ge(i.children??[],e,n,r)}</${o}>`;break;case Yr:{let c=i.options??{},u=(l?c[String(a)]:void 0)??c.other;s+=u?Ge(u.value,e,n,r):`{${o}}`;break}case Qr:{let c=i.options??{},u=l?Number(a):NaN;if(Number.isNaN(u)){let h=c.other;s+=h?Ge(h.value,e,n,`{${o}}`):`{${o}}`;break}let d=u-(i.offset??0),f=c[`=${u}`];if(!f)try{f=c[new Intl.PluralRules(n,{type:i.pluralType??"cardinal"}).select(d)];}catch{}f=f??c.other,s+=f?Ge(f.value,e,n,d):`{${o}}`;break}default:s+=l?xt(a,n):`{${o}}`;}}return s}function Zr(t,e,n){let r=Object.fromEntries(Object.entries(e??{}).map(([i,o])=>[i,typeof o=="boolean"?String(o):o])),s=t.format(r);return typeof s=="string"?s:Array.isArray(s)?s.map(i=>typeof i=="string"?i:xt(i,n)).join(""):xt(s,n)}function xt(t,e){try{if(t instanceof Date)return new Intl.DateTimeFormat(e,{dateStyle:"medium"}).format(t);if(typeof t=="number"||typeof t=="bigint")return new Intl.NumberFormat(e).format(t)}catch{}return t instanceof Date?t.toISOString():String(t)}function In(t,e,n){return t.replace(/\{([^{},]+)\}/g,(r,s)=>{let i=s.trim();if(!(i in e))return r;let o=e[i];if(o==null)return r;if(o instanceof Date)try{return new Intl.DateTimeFormat(n||"en",{dateStyle:"medium"}).format(o)}catch{return o.toISOString()}if(typeof o=="number"||typeof o=="bigint")try{return new Intl.NumberFormat(n||"en").format(o)}catch{return String(o)}return String(o)})}var rs="data-ls-param",Ro=/^[a-z][a-z0-9_]*$/,Lo=/^ls:([a-z][a-z0-9_]*)$/,xo="/ls",ss=1,Pt=3,ns=8;function We(t){if(t.nodeType!==ss||!t.getAttribute)return null;let e=t.getAttribute(rs)?.trim();return !e||!Ro.test(e)?null:Array.from(t.childNodes).every(n=>n.nodeType===Pt)?e:null}function Co(t,e){let n=t[e];if(n.nodeType===ns){let s=Lo.exec((n.nodeValue??"").trim());if(!s)return null;let i=[],o=e+1;for(;o<t.length&&t[o].nodeType===Pt;)i.push(t[o++]);let a=t[o];return !a||a.nodeType!==ns||(a.nodeValue??"").trim()!==xo?null:{marker:{name:s[1],value:i,frame:[n,a]},next:o+1}}let r=We(n);return r!==null?{marker:{name:r,value:Array.from(n.childNodes),frame:[n]},next:e+1}:null}function J(t){let e=Array.from(t),n=[],r=[],s=()=>{if(r.some(i=>"marker"in i))n.push({run:{parts:r}});else for(let i of r)n.push({node:i.text});r=[];};for(let i=0;i<e.length;i++){let o=e[i];if(o.nodeType===Pt){r.push({text:o});continue}let a=Co(e,i);if(a){r.push({marker:a.marker}),i=a.next-1;continue}s(),n.push({node:o});}return s(),n}function Fn(t,e=n=>n.nodeValue??""){return t.parts.map(n=>"text"in n?e(n.text):`{${n.marker.name}}`).join("")}function is(t){return t.parts.flatMap(e=>{if("text"in e)return [e.text];let[n,r]=e.marker.frame;return r?[n,...e.marker.value,r]:[n]})}function de(t,e){return O(R(Fn(t,e)))}function os(t,e=n=>n.nodeValue??""){return t.parts.every(n=>"marker"in n||!R(e(n.text)))}function as(t,e=n=>n.nodeValue??""){let n={};for(let r of t.parts)"marker"in r&&!(r.marker.name in n)&&(n[r.marker.name]=R(r.marker.value.map(e).join("")));return n}function Ot(t,e,n,r,s){let i=[[]],o=[];for(let b of t.parts)"text"in b?i[i.length-1].push(b.text):(o.push(b.marker),i.push([]));let a=i.flat(),l=b=>b?/^\s*/.exec(s.text(b))[0]:"",c=b=>b?/\s*$/.exec(s.text(b))[0]:"",u=i[i.length-1],d=(b,_)=>(b===0?l(i[0][0]):"")+_+(b===i.length-1?c(u[u.length-1]):""),f=Po(e,o.map(b=>b.name)),h=f!==null&&f.every((b,_)=>i[_].length>0||b===""),g=[];if(h){f.forEach((b,_)=>{i[_].forEach((w,y)=>g.push([w,y===0?d(_,U(b,n,r)):""]));});for(let b of o){let _=b.value[0];if(_)if(b.name in n){let w=U(`{${b.name}}`,n,r);b.value.forEach((y,x)=>g.push([y,x===0?w:""]));}else b.value.map(w=>w.nodeValue??"").join("")||g.push([_,s.value(b)]);}return g}let m={};for(let b of o)b.name in m||(m[b.name]=s.value(b));let p=U(e,{...m,...n},r),A=a[0];if(!A)return g;let C=l(A)+p+c(a[a.length-1]);for(let b of a)g.push([b,b===A?C:""]);for(let b of o)for(let _ of b.value)g.push([_,""]);return g}function Po(t,e){if(ne(t)||new Set(e).size!==e.length)return null;let n=[],r=t;for(let s of e){let i=`{${s}}`,o=r.indexOf(i);if(o<0||r.indexOf(i,o+i.length)>=0)return null;n.push(r.slice(0,o)),r=r.slice(o+i.length);}return n.push(r),n.some(s=>e.some(i=>s.includes(`{${i}}`)))?null:n}function he(t,e,n={},r=true,s){let i=[];for(let o of J(t)){if("run"in o){for(let l of o.run.parts)"text"in l?i.push({text:l.text.nodeValue??""}):(i.push(s?{children:[{param:l.marker.name}],payload:s(l.marker)}:{param:l.marker.name}),l.marker.name in n||(n[l.marker.name]=R(l.marker.value.map(c=>c.nodeValue??"").join(""))));continue}let a=o.node;if(a.nodeType===Pt)i.push({text:a.nodeValue??""});else if(a.nodeType===ss){let l=Ce(a),c=l&&r?[]:he(a.childNodes,e,n,r,s);i.push({children:c,payload:e(a,l)});}}return i}function Mt(t,e){let n=false,r={},s=he(t,(i,o)=>(n||=o,e(i,o)),r,false);return n?{...ue(s),values:r}:null}function fe(t){return At.some(e=>{if(!t.hasAttribute(e))return false;let n=(t.getAttribute(e)??"").trim().toLowerCase();return n!=="false"&&n!=="0"})}function It(t){return we(t)!==null}var Oo=["","true","1","yes"];function we(t){for(let e of _t){if(!t.hasAttribute(e))continue;let n=(t.getAttribute(e)??"").trim(),r=n.toLowerCase();if(!(r==="false"||r==="0"))return Oo.includes(r)?{kind:"declaration"}:{kind:"identity",id:n}}return null}var Mo=["data-ls-category","data-langsys-category"];function Ht(t){for(let e of Mo){let n=t.getAttribute(e);if(n!==null)return n.trim()}return null}function W(t){let e=t??null;for(;e;){for(let n of ce){if(!e.hasAttribute(n))continue;let r=(e.getAttribute(n)??"").trim().toLowerCase();return r!=="false"&&r!=="0"}e=e.parentElement;}return false}var Pe=["button"],Oe=["submit","button"],Bo=["font-size","font-weight","font-style","font-variant","line-height","letter-spacing","word-spacing","text-align","text-decoration","text-transform","text-indent","text-shadow","white-space","-webkit-font-smoothing","color","background-color","background-image","background-position","background-size","background-repeat","border","border-top","border-right","border-bottom","border-left","border-radius","border-color","border-width","border-style","margin","margin-top","margin-right","margin-bottom","margin-left","padding","padding-top","padding-right","padding-bottom","padding-left","box-shadow","opacity","filter","display","visibility","list-style","list-style-type","cursor"];function re(t,e){let s=G()[t||"__uncategorized__"]?.[e];return typeof s=="object"&&s!==null}function Ft(t,e,n){let r=G()[t||"__uncategorized__"];if(!r)return null;for(let s of e){let i=r[s];if(!(typeof i!="object"||i===null)){if(!Wr(Object.keys(i),n)){L.debug&&k.log(`Historical content-block id ${s} resolved to a block whose phrases differ; declining it rather than attaching to the wrong text.`);continue}return L.debug&&k.log(`Content block resolved under a historical id (${s}). Its translations still apply; it is never re-keyed and never registered under that id.`),s}}return null}function Io(){return new Promise(t=>{let e=false,n=null;n=F.subscribe(r=>{r===void 0||e||(e=true,t(),queueMicrotask(()=>n?.()));});})}var Un=new Map;async function Y(t){let e=P();if(Le.get()===false&&!e?.credentials)return {status:false,skipped:true,reason:"not-configured"};if(e)return e.recordBlock(t),{status:false,skipped:true,reason:"deferred"};if(V.get())return L.debug&&k.log("Skipping content block registration: the catalog fetch failed, so an unknown block cannot be told from a registered one",{custom_id:t.custom_id}),{status:false,skipped:true,reason:"catalog-unavailable"};if(me.get()){let o=N.get()||v(L.sUserLocale?.get()??"");if(o!==v(L.baseLocale||""))return L.debug&&k.log("Skipping content block: discovery is limited to the base locale",{custom_id:t.custom_id,loaded:o}),{status:false,skipped:true,reason:"base-locale-gate"}}if(F.get()===void 0&&typeof window<"u"&&!S.hasWriteGrant())return await Io(),Y(t);if(F.get()!==true)return bt(t.category,t.custom_id),L.debug&&k.log("Skipping content block save (session is not write-enabled)",{writeEnabled:F.get(),key_type:L.key_type||"unknown"}),{status:false,skipped:true,reason:"not-write-enabled"};let n=S.moduleCredentials(),r=[n.projectid,n.key,t.category,t.custom_id].join("\0"),s=Un.get(r);if(s)return s;let i=Ho(t,n).finally(()=>Un.delete(r));return Un.set(r,i),i}async function Ho(t,e){try{let n=await S.createTranslatableItems([{type:"content_block",custom_id:t.custom_id,category:t.category,content:t.content,label:t.label,phrases:t.tokens.map(s=>({phrase:s}))}],{credentials:e});if(!n.status)return k.error("Could not save content block",n.errors),{status:!1,reason:"refused",errors:n.errors};let r=S.moduleCredentials();return r.projectid===e.projectid&&r.key===e.key&&Fo(t.category,t.custom_id),{status:!0}}catch(n){return k.error("Could not save content block",n),{status:false,reason:"failed",errors:[n]}}}function Vn(t){let e=[],n={values:{},runs:[],markerOnly:[]},r=t.cloneNode(true);return Ie(t,Array.from(r.childNodes),e,[],false,true,void 0,n),Ut(r.childNodes,{empty:s=>s.replaceChildren(),replace:(s,i,o)=>{let a=i[0];a.parentNode.insertBefore(a.ownerDocument.createTextNode(o),a);for(let l of i)l.remove();}}),{tokens:e,content:O(r.innerHTML),vars:n}}function Ut(t,e){for(let n of J(t)){if("run"in n){e.replace(t,is(n.run),Fn(n.run));continue}if(n.node.nodeType!==Bt)continue;let r=n.node;fe(r)||It(r)?e.empty(n.node):Ut(n.node.childNodes,e);}}function jn(t){let e=[],n=t.cloneNode(true);return Ie(t,Array.from(n.childNodes),e,[],true,false),e}function Fo(t,e){let n=t||"__uncategorized__";I.update(r=>{r[n]||(r[n]={__category__:n,__symbol__:n});let s=r[n];return typeof s[e]=="object"&&s[e]!==null?r:(s[e]={},{...r})});}function D(t){return ke(t)||te.includes(t.tagName.toLowerCase())||fe(t)||It(t)}var Bt=1,ls=3;function cs(t,e=false){let n=[];return Ie(null,Array.from(t),n,[],e,false),n}function Me(t){let e=[],n={values:{},runs:[],markerOnly:[]};return Ie(null,Array.from(t),e,[],false,false,void 0,n),{tokens:e,vars:n}}function Be(t,e){return t.length>0&&e.markerOnly.length===t.length}function us(t){let e=[];return Ie(null,Array.from(t),[],[],false,false,e),e}function Ke(t){let e=null,n=r=>{for(let s of Array.from(r.childNodes))if(s.nodeType===ls){if(R(s.nodeValue??"")){if(e)return false;e=s;}}else {if(s.nodeType===Bt&&D(s))continue;if(!n(s))return false}return true};return n(t)?e:null}function Ie(t,e,n,r,s,i,o,a){for(let l of J(e)){if("run"in l){let f=de(l.run);a&&(os(l.run)&&a.markerOnly.push(n.length),a.runs.push(n.length),a.values={...as(l.run),...a.values}),n.push(f);let h=l.run.parts[0];o?.push({node:"text"in h?h.text:h.marker.frame[0],run:l.run});continue}let c=l.node,u=e.indexOf(c);if(c.nodeType===Bt&&D(c))continue;i&&c.hasChildNodes()&&Vo(t,c,[...r,u]),c.nodeType===Bt&&Uo(c,n,s,o);let d=c.nodeValue?R(c.nodeValue):void 0;if(c.nodeType===ls&&d){n.push(O(d)),o?.push({node:c});continue}c.hasChildNodes()&&Ie(t,Array.from(c.childNodes),n,[...r,u],s,i,o,a);}}function Uo(t,e,n,r){let s=t.tagName.toLowerCase();if(s==="img"&&!r){let o=t;o.src&&t.setAttribute("src",o.src);}let i=o=>{let a=R(t.getAttribute(o)??"");a&&(e.push(O(a)),r?.push({node:t,attr:o}));};for(let o of le)i(o);if(Pe.includes(s)&&i("value"),s==="input"){let o=t.getAttribute("type")?.toLowerCase();o&&Oe.includes(o)&&i("value");}n&&s==="select"&&t.querySelectorAll("option").forEach(a=>{let l=R(a.textContent??"");l&&e.push(O(l));});}function Vo(t,e,n){if(typeof window>"u")return;let r=jo(Array.from(t.childNodes),n);if(!r)return;let s=r.tagName.toLowerCase(),i=document.createElement("div");i.style.display="none";let o=i.appendChild(document.createElement(s));document.body.appendChild(i);let a=window.getComputedStyle(r),l=window.getComputedStyle(o);for(let c of Bo){let u=a.getPropertyValue(c),d=l.getPropertyValue(c);u&&u!==d&&e.style.setProperty(c,u);}document.body.removeChild(i),e.removeAttribute("class");}function jo(t,e){let n=t[e[0]];for(let r=1;r<e.length;r++){if(!n||!n.hasChildNodes())return;n=Array.from(n.childNodes)[e[r]];}return n}var $o="\uE000",Do="\uE001",Go="\uE002",zo="\uE003",qe=/\uE000(\d+)\uE001|\uE002(\d+)\uE003/g;function $n(t){let e={},n=(a,l)=>{let c=a;return l?{template:c.cloneNode(false),source:c}:{template:c.cloneNode(false)}},r=t.childNodes,{phrase:s,slots:i}=ue(he(r,n,e)),o=Mt(r,n);return o?{phrase:s,slots:i,values:e,earlier:o}:{phrase:s,slots:i,values:e}}function hs(t){let e={};for(let n=0;n<t;n++)e[`m${n}o`]=`${$o}${n}${Do}`,e[`m${n}c`]=`${Go}${n}${zo}`;return e}function Se(t,e,n,r){let s=hs(n);return U(t,{...e,...s},r).replace(/\{(m\d+[oc])\}/g,(o,a)=>s[a]??o)}function Ze(t){let e=[],n=0,r=0,s,i=new RegExp(qe.source,"g");for(;(s=i.exec(t))!==null;){let a=t.slice(r,s.index);if(a&&e.push({text:a}),r=i.lastIndex,s[1]!==void 0)e.push({open:Number(s[1])}),n++;else {if(n===0)return null;e.push({close:Number(s[2])}),n--;}}let o=t.slice(r);return o&&e.push({text:o}),n===0?e:null}function fs(t,e,n){let r=Ze(e);if(!r)return false;let s=[],i=0,o=0,a=l=>{for(let c of Array.from(l.childNodes))if(c.nodeType===3){let u=r[i];u&&"text"in u?(s.push([c,u.text]),i++):s.push([c,""]);}else if(c.nodeType===1&&We(c)!==null)for(let u of Array.from(c.childNodes))s.push([u,""]);else if(c.nodeType===1){let u=r[i],d=o++,f=n?n(c):d;if(!u||!("open"in u)||u.open!==f||(i++,!Ce(c)&&!a(c)))return false;let h=r[i];if(!h||!("close"in h)||h.close!==f)return false;i++;}return true};if(!a(t)||i!==r.length)return false;for(let[l,c]of s)l.nodeValue!==c&&(l.nodeValue=c);return true}function Vt(t,e,n=document,r){let s=n.createDocumentFragment(),i=[s],o=()=>i[i.length-1],a=0,l;qe.lastIndex=0;let c=new Set;try{for(;(l=qe.exec(t))!==null;){let d=t.slice(a,l.index);d&&o().appendChild(n.createTextNode(d)),a=qe.lastIndex;let f=l[1]!==void 0,h=Number(f?l[1]:l[2]);if(f){let g=e[h];if(!g)throw new Error("unknown markup slot");if(g.source){let p=c.has(g.source)?g.source.cloneNode(!0):g.source;c.add(g.source),r?.(p,h),o().appendChild(p),i.push(n.createDocumentFragment());continue}let m=g.template.cloneNode(!1);r?.(m,h),o().appendChild(m),i.push(m);}else {if(i.length<=1)throw new Error("unbalanced close");i.pop();}}let u=t.slice(a);if(u&&o().appendChild(n.createTextNode(u)),i.length!==1)throw new Error("unbalanced open")}catch{return [n.createTextNode(Je(t))]}return Array.from(s.childNodes)}function Dn(t,e){return t.replace(/\{([A-Za-z_][A-Za-z0-9_]*)\}|%([A-Za-z_][A-Za-z0-9_]*)%/g,(n,r,s)=>{let i=r??s,o=Object.prototype.hasOwnProperty.call(e,i)?e[i]:void 0;return typeof o=="string"||typeof o=="number"||typeof o=="boolean"?String(o):n})}function Xe(t){return ke(t)&&!te.includes(t.tagName.toLowerCase())}var ds=new WeakMap;function Gn(t,e){let n=r=>{for(let s of Array.from(r.childNodes)){if(s.nodeType===1){te.includes(s.tagName.toLowerCase())||n(s);continue}if(s.nodeType!==3)continue;let i=ds.get(s),o=i&&s.nodeValue===i.written?i.original:s.nodeValue??"",a=Dn(o,e);s.nodeValue!==a&&(s.nodeValue=a),ds.set(s,{original:o,written:a});}};for(let r of t)r.source&&Xe(r.source)&&n(r.source);}function Je(t){return t.replace(qe,"")}var Wn=new Map,ms=new Set,ys={seed:new Set,mount:new Set},gs=false;function He(t){t?.customId&&Array.isArray(t.tokens)&&Wn.set(t.customId,t);}function jt(t){t?.collected&&typeof t.phrase=="string"&&ms.add(`${t.category??""}\0${t.phrase}`);}function bs(t,e){return ms.has(`${t??""}\0${e}`)}function Ye(t,e){ys[e].add(t);}function Qe(t,e){return ys[e].has(t)}function Ee(t){return Wn.get(t)?.collected===true}function ks(){gs||(gs=true,k.warn("A server-rendered block has no source to render other locales from: register the scope seed with registerBlock(seededBlock) after init(). It keeps the text it was served with."));}var zn=t=>R(O(t));function Wo(t){return t.run?de(t.run):zn(t.attr?t.node.getAttribute(t.attr)??"":t.node.nodeValue??"")}function Ts(t,e,n,r){let s=us(t.childNodes);if(s.length===0)return null;let i=Wn.get(e);if(i&&i.tokens.length===s.length)return {slots:s,sources:[...i.tokens]};let o=G()[n||"__uncategorized__"]?.[e];if(!o||typeof o!="object")return null;let a=N.get(),l=Object.entries(o).filter(([u])=>!u.startsWith("__")).flatMap(([u,d])=>{let f=g=>[zn(U(g,r,a)),zn(g)],h=[...f(u),...typeof d=="string"&&d?f(d):[]];return [...new Set(h)].map(g=>({key:u,text:g}))}),c=[];for(let u of s){let d=Wo(u),f=new Set(l.filter(h=>h.text===d).map(h=>h.key));if(f.size!==1)return null;c.push([...f][0]);}return {slots:s,sources:c}}var ps=t=>R(t.replace(/\uE000\d+\uE001|\uE002\d+\uE003/g," ").replace(/\{m\d+[oc]\}/g," "));function ws(t,e,n,r){let s=G()[n||"__uncategorized__"];if(!s||typeof s!="object")return null;let i=N.get(),o=ps(t),a=[];for(let[l,c]of Object.entries(s)){if(l.startsWith("__")||c!==null&&typeof c=="object"||(l.match(/\{m\d+o\}/g)??[]).length!==e)continue;let u=typeof c=="string"&&c?[c,l]:[l];for(let d of u){let f=Se(d,r,e,i);if(ps(f)!==o)continue;let g=Ze(f)?.flatMap(m=>"open"in m?[m.open]:[])??[];if(g.length===e){a.some(m=>m.phrase===l)||a.push({phrase:l,order:g});break}}}return a.length===1?a[0]:null}var Ss=new Set,$t=new Map,Es=false;function ge(t,e){if(!Ss.has(t)){if(!Es){$t.has(t)||$t.set(t,e);return}k.debugEnabled&&(Ss.add(t),k.log(e));}}function vs(){Es=true;let t=[...$t];$t.clear();for(let[e,n]of t)ge(e,n);}var Ko={"register-false":"A <Translate> or <Phrase> was created with `register: false`: it renders from the catalog and registers nothing (VAR-7)."};function ve(t){ge(`unregistered\0${t}`,Ko[t]??`A <Translate> or <Phrase> registers nothing (${t}): it holds a value from a variable that cannot be named without the build-time transform, so it renders from the catalog only (VAR-7).`);}var qo=/^[a-z][a-z0-9_]*$/,Ns=/^m\d+[oc]$/,As=new Set(["length","size","count"]),Zo=new Set(["value","current"]);function Ne(t){let e=t.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").toLowerCase().replace(/[^a-z0-9_]+/g,"_").replace(/_+/g,"_").replace(/^[^a-z]+/,"").replace(/_+$/,"");return e&&qo.test(e)?e:null}function _s(t){if("identifier"in t){let e=Ne(t.identifier);return e?{name:e,prev:null}:null}if("member"in t){let e=t.member;if(e.length===0)return null;let n=e[e.length-1];if(e.length>=2&&(As.has(n)||Zo.has(n))){let s=Ne(e[e.length-2]);if(!s)return null;let i=e.length>=3?Ne(e[e.length-3]):null;return {name:As.has(n)?`${s}_count`:s,prev:i}}let r=Ne(n);return r?{name:r,prev:e.length>=2?Ne(e[e.length-2]):null}:null}return "call"in t&&t.call.args.length===1?_s(t.call.args[0]):null}var Xo=t=>JSON.stringify(t);function Rs(t){return "call"in t?t.call.callee!==""&&t.call.args.every(Rs):!("other"in t)}function Kn(t){let e=t.map(l=>l.explicit?Ne(l.explicit)??l.explicit:null),n=new Set(e.filter(l=>l!==null)),r=t.map((l,c)=>e[c]===null?_s(l.shape):null),s=new Map,i=t.map((l,c)=>{if(e[c]!==null||!Rs(l.shape))return c;let u=Xo(l.shape);return s.has(u)||s.set(u,c),s.get(u)}),o=new Map;r.forEach((l,c)=>{l&&i[c]===c&&o.set(l.name,[...o.get(l.name)??[],c]);});let a=l=>{let c=l;for(let u=2;n.has(c)||Ns.test(c);u++)c=`${l}_${u}`;return n.add(c),c};for(let l=0;l<t.length;l++){if(e[l]!==null||i[l]!==l)continue;let c=r[l];if(!c)continue;let u=(o.get(c.name)?.length??0)>1||n.has(c.name)||Ns.test(c.name);e[l]=a(u&&c.prev?`${c.prev}_${c.name}`:c.name);}for(let l=0;l<t.length;l++)e[l]===null&&i[l]===l&&(e[l]=a("value"));return t.map((l,c)=>e[i[c]])}var Zn=new Set,qn=null;function Jo(t){let e=qn;if(qn=null,e?.(),!t)return;let n=t(()=>{for(let r of Zn)r();});qn=typeof n=="function"?n:null;}function Ls(t){return Zn.add(t),()=>{Zn.delete(t);}}var Jn=["laravel","vue-i18n","i18next","gettext","rails-i18n","plain"],tt=["i18next","vue-i18n","plain"],et=["zero","one","two","few","many","other"],Yo=/%%|%\{([A-Za-z_][A-Za-z0-9_]*)\}|%\(([A-Za-z_][A-Za-z0-9_]*)\)[sd]|%\([A-Za-z_][A-Za-z0-9_]*\)[-+ #0-9.]*[a-zA-Z]|%<[A-Za-z_][A-Za-z0-9_]*>[-+ #0-9.]*[a-zA-Z]|%(?:\.\d+)?[sdif](?![A-Za-z])|\{\{\s*([A-Za-z_][A-Za-z0-9_]*)\s*\}\}|(?<![\w:]):([a-z][a-z0-9_]*)/g,xs=/(?<![\w:]):[A-Z][A-Za-z0-9_]*/,Dt=class extends Error{};function Gt(t,e="plain"){return t=String(t),xs.test(t)?Ae(t,"uses a case-transforming placeholder (:Name or :NAME), which ICU cannot express"):t.includes("|")?e==="vue-i18n"?ea(t):Ae(t,e==="i18next"?'holds a "|", which i18next does not read as a plural':`holds a "|" in a file with no plural format declared; declare the file's format to convert it`):Cs(t)}function Yn(t){let e=et.filter(r=>t[r]!==void 0).map(r=>t[r]).join(" | ");if(t.other===void 0)return Ae(e,'is a plural with no "other" form');let n=[];for(let r of et){let s=t[r];if(s!==void 0){if(xs.test(s))return Ae(e,"uses a case-transforming placeholder (:Name or :NAME), which ICU cannot express");n.push([r,s]);}}return Xn(n,e)}function Qo(t,e){if(e==="t")return {text:String(t),recognised:true,issue:null};if(e==="vue-i18n"||e==="i18next")return Gt(t,e);throw new Error(`Unknown entry point "${String(e)}"; expected t, vue-i18n or i18next`)}function ea(t){let e=t.split("|").map(n=>n.trim());return e.length===2?Xn([["=1",e[0]],["other",e[1]]],t):e.length===3?Xn([["=0",e[0]],["=1",e[1]],["other",e[2]]],t):Ae(t,`is a vue-i18n plural with ${e.length} forms; only 2 or 3 map to ICU`)}function Xn(t,e){let n=[];for(let[r,s]of t){let i=Cs(s);if(!i.recognised)return Ae(e,i.issue);n.push(`${r} {${i.text.replace(/\{(?:count|n)\}/g,"#")}}`);}return {text:`{count, plural, ${n.join(" ")}}`,recognised:true,issue:null}}function Cs(t){try{return {text:t.replace(Yo,(n,r,s,i,o)=>{if(n==="%%")return "%";let a=r??s??i??o;if(a!==void 0)return `{${a}}`;throw new Dt(n.startsWith("%(")||n.startsWith("%<")?`uses a formatted placeholder (${n}), which {name} cannot express`:`uses a positional placeholder (${n}), which names no argument`)}),recognised:!0,issue:null}}catch(e){if(e instanceof Dt)return Ae(t,e.message);throw e}}function Ae(t,e){return {text:t,recognised:false,issue:e}}var nt=class extends Error{constructor(n,r,s){super(n);this.file=r;this.format=s;this.name="LegacyFormatError";}},ta={php:"laravel",yml:"rails-i18n",yaml:"rails-i18n",po:"gettext",mo:"gettext"};function Qn(t){let e=t.map(na);return {resolve(n){if(typeof n!="string"||n==="")return null;for(let r of e){let s=ra(r,n);if(!s)continue;let i=Os(s.value,r.format);return {...i,phrase:i.text,category:s.category,key:n,file:r.name}}return null},duplicates(){let n={};for(let r of e)for(let s of Object.keys(Ps(r)))(n[s]??=[]).push(r.name);return Object.fromEntries(Object.entries(n).filter(([,r])=>r.length>1))},problems(){let n=[];for(let r of e){if(r.data===null){n.push({file:r.name,key:null,issue:"is not a JSON object",fix:"pass the parsed contents of the file"});continue}for(let[s,i]of Object.entries(Ps(r))){let o=Os(i,r.format);o.recognised||n.push({file:r.name,key:s,issue:o.issue,fix:"rewrite the value as Langsys source text, or declare the file's format"});}}return n}}}function na(t){let e=String(t?.name??""),n=e.includes(".")?e.slice(e.lastIndexOf(".")+1).toLowerCase():"";if(n==="mo"){let o=e.slice(0,-3)+".po";throw new nt(`The legacy file ${e} is a compiled gettext catalog. gettext reads .po only (${o}), and gettext is not a format this core reads; it reads ${tt.join(", ")}.`,e,"gettext")}let s=t?.format??ta[n]??"plain";if(!tt.includes(s)){let o=Jn.includes(s);throw new nt(`The legacy file ${e} is in the ${o?"":"unknown "}format "${s}", which this core does not read. It reads ${tt.join(", ")}.`,e,s)}let i=Wt(t?.data)?t.data:null;return {name:e,format:s,namespace:t?.namespace?String(t.namespace):null,data:i}}function ra(t,e){if(!t.data)return null;let n=t.format==="i18next";if(t.namespace!==null){if(!e.startsWith(t.namespace+"."))return null;let i=zt(t.data,e.slice(t.namespace.length+1).split("."),n);return i===null?null:{value:i,category:t.namespace}}if(!e.includes(".")){let i=zt(t.data,[e],n);return i===null?null:{value:i,category:null}}let r=t.data[e];if(typeof r=="string")return {value:r,category:ia(e)?e.slice(0,e.indexOf(".")):null};let s=zt(t.data,e.split("."),n);return s===null?null:{value:s,category:e.slice(0,e.indexOf("."))}}function zt(t,e,n){let r=e.pop(),s=t;for(let o of e){if(!Wt(s)||!(o in s))return null;s=s[o];}if(!Wt(s))return null;if(n){let o={};for(let c of et){let u=s[`${r}_${c}`];typeof u=="string"&&(o[c]=u);}if(Object.keys(o).length>0)return o;let a=s[r],l=s[`${r}_plural`];if(typeof a=="string"&&typeof l=="string")return {one:a,other:l}}let i=s[r];return typeof i=="string"?i:null}function Ps(t){let e={};if(!t.data)return e;let n=t.namespace!==null?t.namespace+".":"";return Ms(t.data,n,e,t.format==="i18next"),e}var sa=[...et.map(t=>`_${t}`),"_plural"];function Ms(t,e,n,r){for(let[s,i]of Object.entries(t)){if(Wt(i)){Ms(i,`${e}${s}.`,n,r);continue}if(typeof i=="string"){if(r){let o=sa.find(a=>s.endsWith(a)&&s.length>a.length);if(o){let a=s.slice(0,-o.length),l=zt(t,[a],true);if(l!==null&&typeof l!="string"){n[e+a]=l;continue}}}e+s in n||(n[e+s]=i);}}}function Os(t,e){return typeof t=="string"?Gt(t,e):Yn(t)}function ia(t){return /^[A-Za-z0-9_-]+(\.[A-Za-z0-9_-]+)+$/.test(t)}function Wt(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var Kt=5,oa=400,aa=3e3,Us=3e3,Vs=3e5;function er(t){return Math.min(Us*2**(t-1),Vs)}function Bs(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function Is(t,e){return t.projectid===e.projectid&&t.category===e.category&&t.token===e.token}var Hs=null;function la(t,e){let n=`${e??"unknown"}:${t}`;n!==Hs&&(Hs=n,!(t||e!=="write"&&e!=="ip_write")&&k.warn(`Langsys: this session cannot write. The key is '${e}', but the server's answer did not make this request write-enabled \u2014 so missing phrases will NOT be registered and nothing will appear in the Translation Manager. For an 'ip_write' key this usually means the address is not allow-listed; otherwise supply a write grant via LangsysApp.setWriteGrant(). Page URLs may still be reported for discovery if auto_discovery is enabled for this key.`));}function qt(t){return typeof t.write_enabled=="boolean"?t.write_enabled:t.errors?void 0:false}var Fs=false;function tr(t){Fs||(Fs=true,k.warn(`Langsys: a write grant is configured, so this server render does not collect missing phrases (ssrTokenStrategy '${t}' is degraded to 'client'). Under a grant, write capability is per-user and a process-wide server queue cannot carry it, so missing phrases are collected in the browser after hydration instead.`));}var rt=class{constructor(e){this.lastLoaded={};this.missingTokens=[];this.warnedEllipsis=new Set;this.legacyKeys=null;this.warnedLegacy=new Set;this.timer=null;this.catalogFetchesInFlight=0;this.catalogFromSnapshot=false;this.catalogFailures=new Map;this.catalogRequests=new Map;this.flushScheduled=false;this.updateInFlight=false;this.debounceTimer=null;this.consecutiveFailures=0;this.retryNotBefore=0;this.teardownInstalled=false;this.releaseTeardownFlush=null;this.isFirstClientRun=true;this.ssrWriteEnabled=void 0;this.credentialsError=null;this.readyResolve=()=>{};this.readyPromise=new Promise(e=>{this.readyResolve=e;});this.pageView={catalog:()=>ie(),locale:()=>ft(),miss:(e,n,r)=>this.missingToken(e,n,r),fromSnapshot:()=>this.catalogFromSnapshot};this.config=e,this.debug=new se(!!e.debug),this.locale=v(e.baseLocale||""),this.tSignal=B(this.buildTFn()),I.subscribe(()=>this.tSignal.set(this.buildTFn())),N.subscribe(()=>this.tSignal.set(this.buildTFn())),F.subscribe(n=>{this.missingTokens.length&&(n===true?this.scheduleTokenFlush():n===false&&!S.hasWriteGrant()&&(this.debug.log(`Releasing ${this.missingTokens.length} held tokens (session is read-only)`),this.missingTokens=[],this.stopBackstop()));}),e.key&&e.projectid&&this.setup(e);}ready(){return this.readyPromise}settle(){this.readyResolve();}markUnconfigured(e,n){this.credentialsError=n?e:null,this.settleNotWritable(),V.set(true),this.settle();}assertConfigured(){if(this.credentialsError)throw this.credentialsError}markConfigured(){this.credentialsError===null&&!V.get()||(this.credentialsError=null,V.set(false));}settleNotWritable(){dn(false),typeof window>"u"&&(this.ssrWriteEnabled=false);}notifyNavigation(){be.set(be.get()+1),this.tSignal.set(this.buildTFn());}get t(){return this.tSignal.get()}subscribe(e){return I.subscribe(e)}lookupContent(e,n,r){let o=G()[e||"__uncategorized__"]?.[n];if(!o||typeof o!="object")return null;let a=o[r];return typeof a=="string"?a:null}lookup(e,n){let i=G()[n||"__uncategorized__"]?.[Rt(e)];return typeof i=="string"&&i.length>0?i:null}buildTFn(){return((n,...r)=>{let s=P();return s?.credentials||this.assertConfigured(),s?s.t(n,...r):this.renderWith(this.pageView,n,r)})}renderWith(e,n,r){if(ca(n)){let h=ua(n,r);if(h.phrase===null)return ve("tagged-template"),h.text;n=h.phrase,r=[h.params];}let s=typeof r[0]=="string"?r[0]:"",i=typeof r[0]=="object"?r[0]:r[1];this.legacyKeys&&({phrase:n,category:s}=this.resolveLegacyKey(n,s));let o=e.catalog(),a=s||"__uncategorized__",l=o[a],c=Rt(n),u=!!l&&Object.prototype.hasOwnProperty.call(l,c),d=u?l[c]:void 0,f;return typeof d=="string"&&d.length>0?(this.debug.log("TRANSLATION FOUND",[a,n,d]),f=d):(u||e.miss(s,c,false),f=n),u&&e.fromSnapshot()&&e.miss(s,c,true),U(f,i??{},e.locale())}setLegacyKeys(e){this.legacyKeys=e&&e.length>0?Qn(e):null,this.warnedLegacy.clear();}resolveLegacyKey(e,n){let r=this.legacyKeys.resolve(e);return r?(!r.recognised&&this.warnOnce(`value\0${r.file}\0${r.key}`)&&k.warn(`The legacy key "${r.key}" in ${r.file} ${r.issue}, so its value registers exactly as written.`),{phrase:r.phrase,category:n||r.category||""}):(k.debugEnabled&&this.warnOnce(`miss\0${e}`)&&k.warn(`"${e}" is not a key in the legacy source files, so it registers as literal source text.`),{phrase:e,category:n})}warnOnce(e){return this.warnedLegacy.has(e)?false:(this.warnedLegacy.add(e),true)}recordPageMiss(e,n){this.missingToken(e,n);}missingToken(e,n,r=false){if(n==null)return this.debug.warn(`Received undefined or null token for category: ${e}`);if(n==="toJSON"){this.debug.error(`Received toJSON as token ${e}:${n}`,n);return}if(n===""){this.debug.warn("Received empty token",n);return}if(this.debug.debugEnabled&&!this.warnedEllipsis.has(n)&&/(?:…|\.\.\.)\s*$/.test(n)&&(this.warnedEllipsis.add(n),this.debug.warn(`Langsys: phrase ends in an ellipsis \u2014 "${n}". If this is upstream truncation, the shortened form will be translated and stored, and the full text will later register as a separate phrase. Register the untruncated string if you can. Registering anyway.`)),V.get()){this.debug.log("Not recording a miss: the catalog fetch failed, so a miss cannot be told from a hit",{category:e,token:n});return}if(me.get()){let i=N.get()||this.locale;if(i!==v(this.config.baseLocale||"")){this.debug.log("Not recording a miss: discovery is limited to the base locale",{category:e,token:n,loaded:i});return}}if(r||bt(e,n),bs(e,n)){this.debug.log("Not queueing for registration: the server registers this phrase",{category:e,token:n});return}if(!this.shouldQueueForWrite()){this.debug.log("Not queueing for registration (no reachable flush path)",{category:e,token:n});return}let s={category:e,token:n,projectid:this.config.projectid};this.missingTokens.some(i=>Is(i,s))||(this.debug.log("MISSING TOKEN LOOKUP FAILED",[s,[...this.missingTokens],{...I.get()}]),this.missingTokens.push(s),this.scheduleTokenFlush());}mayWrite(){return this.canWrite()}canWrite(){return typeof window<"u"?F.get()===true:S.hasWriteGrant()?false:this.ssrWriteEnabled===true}applyWriteEnabled(e,n=this.config.key_type){typeof e=="boolean"&&(dn(e),typeof window>"u"&&(this.ssrWriteEnabled=e),la(e,n));}shouldQueueForWrite(){if(typeof window>"u"){let e=this.config.ssrTokenStrategy||"client";return S.hasWriteGrant()?(e!=="client"&&tr(e),false):e==="server"?true:e==="auto"?this.missingTokens.length<Kt:false}return !(F.get()===false&&!S.hasWriteGrant())}scheduleTokenFlush(){let e=this.config.ssrTokenStrategy||"client";if(typeof window>"u")switch(e){case "server":this.flushScheduled||(this.flushScheduled=true,queueMicrotask(()=>{this.updateTokens();}));break;case "auto":this.missingTokens.length<=Kt&&!this.flushScheduled&&(this.flushScheduled=true,queueMicrotask(()=>{this.updateTokens();}));break;default:this.debug.log("SSR: Queuing tokens for client-side transmission");break}else this.flushScheduled||(this.flushScheduled=true,this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.updateTokens();},oa)),this.ensureBackstop();}ensureBackstop(){this.timer||(this.timer=setInterval(()=>{this.updateTokens();},aa),this.debug.log("UPDATE TOKEN INTERVAL",this.timer));}stopBackstop(){this.timer&&(clearInterval(this.timer),this.timer=null);}destroy(){this.stopBackstop(),this.releaseTeardownFlush?.(),this.releaseTeardownFlush=null;}flushOnTeardown(){this.missingTokens.length&&(this.debug.log(`Teardown flush: sending ${this.missingTokens.length} queued tokens with keepalive`),this.updateTokens(true));}installTeardownFlush(){this.releaseTeardownFlush||(this.releaseTeardownFlush=Ls(()=>this.flushOnTeardown())),!this.teardownInstalled&&(typeof document>"u"||typeof window>"u"||(this.teardownInstalled=true,document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&this.flushOnTeardown();}),window.addEventListener("pagehide",()=>this.flushOnTeardown())));}setup(e){if(this.config=e,!(!this.config.projectid||!this.config.key))if(this.config.debug&&(this.debug.debugEnabled=this.config.debug),e.baseLocale&&(this.locale=v(e.baseLocale)),this.debug.log("TRANSLATION SETUP INITIATED",this.config),typeof window<"u"){if(this.isFirstClientRun&&this.missingTokens.length>0){this.isFirstClientRun=false;let n=this.config.ssrTokenStrategy||"client";(n==="client"||n==="auto"&&this.missingTokens.length>5)&&(this.debug.log(`Post-hydration: Flushing ${this.missingTokens.length} SSR-collected tokens`),queueMicrotask(()=>this.updateTokens()));}this.installTeardownFlush(),this.stopBackstop(),this.missingTokens.length&&this.ensureBackstop();}else {let n=this.config.ssrTokenStrategy||"client";this.debug.log(`SSR environment detected - using '${n}' token strategy`);}}markLoaded(e){e&&(e=v(e),this.locale=e,this.lastLoaded[e]=new Date().getTime()/1e3,this.catalogFromSnapshot=false,V.set(false),this.readyResolve());}markSeeded(){this.catalogFromSnapshot=true,V.set(false),this.readyResolve();}async change(e,n=false,r=false){if(!e||!this.config.projectid||!this.config.key)return false;if(e=v(e),dt(this.catalogScope(e)),r)return this.debug.log("Using pre-fetched translations for locale",e),V.set(false),this.locale=e,this.lastLoaded[e]=new Date().getTime()/1e3,this.readyResolve(),true;let s=new Date().getTime()/1e3;if(!n&&e===this.locale&&this.lastLoaded[e]&&Math.abs(this.lastLoaded[e]-s)<60)return false;this.debug.log("Locale change detected!",e),this.locale=e;let i=this.catalogScope(e),o=this.catalogFailures.get(i);if(!n&&o&&Date.now()<o.retryAt)return this.debug.log("Catalog fetch skipped: the last one for this project and locale failed",{scope:i,retryInMs:o.retryAt-Date.now()}),this.markCatalogUnavailable(),false;let a=this.catalogRequests.get(i);a||(a=this.fetchCatalog(i).finally(()=>this.catalogRequests.delete(i)),this.catalogRequests.set(i,a)),this.catalogFetchesInFlight+=1;try{await a;}finally{this.catalogFetchesInFlight-=1;}return this.missingTokens.length&&!V.get()&&this.scheduleTokenFlush(),true}catalogScope(e){return ht(this.config.projectid,e)}async fetchCatalog(e){if(await this.getTranslations())return this.catalogFailures.delete(e),true;let r=(this.catalogFailures.get(e)?.failures??0)+1;return this.catalogFailures.set(e,{failures:r,retryAt:Date.now()+er(r)}),false}noteSendFailure(){this.consecutiveFailures+=1;let e=Math.min(Us*2**(this.consecutiveFailures-1),Vs);this.retryNotBefore=Date.now()+e,this.debug.log(`Registration send failed (${this.consecutiveFailures}x); next attempt in ${e}ms`);}async updateTokens(e=false){this.flushScheduled=false;let n=e;if(!n&&this.updateInFlight)return false;if(!this.missingTokens.length)return this.stopBackstop(),false;if(!n&&this.retryNotBefore&&Date.now()<this.retryNotBefore||!this.config.projectid||!this.config.key)return false;if(V.get())return this.debug.log("Holding queued tokens: the catalog fetch failed, so they cannot be deduplicated"),false;if(this.catalogFetchesInFlight>0)return this.debug.log("Holding queued tokens until the catalog in flight arrives"),false;if(this.catalogFromSnapshot)return this.debug.log("Holding queued tokens until the live catalog replaces the snapshot"),false;if(!this.canWrite())return this.debug.log("Skipping token updates (session is not write-enabled)",{writeEnabled:F.get(),key_type:this.config.key_type||"unknown"}),false;typeof window>"u"&&this.debug.log(`Sending ${this.missingTokens.length} tokens from SSR`);let r=ie();if(this.missingTokens=this.missingTokens.filter(o=>{o.projectid=this.config.projectid;let a=o.category||"__uncategorized__",l=r[a];return l&&Object.prototype.hasOwnProperty.call(l,o.token)?(this.debug.log("Missing token already exists! Skipping:",{category:o.category,token:o.token,existing:r[a][o.token]}),false):true}),!this.missingTokens.length)return false;let s=[...this.missingTokens],i=false;n||(this.updateInFlight=true),this.debug.log("CREATE MISSING TOKENS",s);try{let o=s.map(c=>({type:"phrase",phrase:c.token,category:c.category||null})),a=n?Math.min(50,ye.get()):ye.get();for(let c=0;c<o.length;c+=a){let u=await S.createTranslatableItems(o.slice(c,c+a),{keepalive:e,credentials:S.moduleCredentials()});if(!u.status)return u.errors&&(this.debug.log("TOKEN UPDATE FAIL",s),this.debug.error("Error updating project tokens",u.errors)),this.noteSendFailure(),!1}let l=ie();return s.forEach(c=>{let u=c.category||"__uncategorized__";l[u]||(l[u]={__category__:u,__symbol__:u}),Object.prototype.hasOwnProperty.call(l[u],c.token)||(l[u][c.token]=null),l[u].__category__=u;}),I.set({...l}),this.missingTokens=this.missingTokens.filter(c=>!s.some(u=>Is(u,c))),i=!0,this.consecutiveFailures=0,this.retryNotBefore=0,!0}catch(o){return this.debug.log("CREATE MISSING TOKEN FAILURE",s),this.debug.error("Error updating project tokens",o),this.noteSendFailure(),false}finally{n||(this.updateInFlight=false),i&&this.missingTokens.length&&this.scheduleTokenFlush(),this.missingTokens.length||this.stopBackstop();}}markCatalogUnavailable(){V.set(true),this.readyResolve();}async getTranslations(){!S.config.projectid&&this.config.projectid&&S.setup(this.config);let e=this.locale,n=this.catalogScope(e),r=()=>e===this.locale&&n===this.catalogScope(this.locale),s;try{s=await S.getTranslations(e,{credentials:S.moduleCredentials()});}catch(o){return this.debug.error("Catalog fetch threw",o),r()&&this.markCatalogUnavailable(),false}if(this.debug.log("GET TRANSLATIONS API RESPONSE",s),!r())return this.debug.log("Catalog response dropped: the locale changed while it was in flight",{requested:e,current:this.locale}),!s.errors;if(this.applyWriteEnabled(qt(s)),typeof s.discovery_base_locale_only=="boolean"&&me.set(s.discovery_base_locale_only),s.errors)return this.debug.error("Error",s.errors[0]),this.markCatalogUnavailable(),false;let i=Bs(s.data)?s.data:{};Bs(i.__uncategorized__)||(i.__uncategorized__={__category__:"__uncategorized__",__symbol__:"__uncategorized__"});for(let o of Object.keys(i)){let a=i[o];if(typeof a!="object"||a===null||Array.isArray(a)){this.debug.warn(`Ignoring non-category member '${o}' in the /translations payload \u2014 expected an object of phrases, got ${Array.isArray(a)?"an array":typeof a}. The catalog is still usable.`),delete i[o];continue}i[o].__category__=o;}return this.debug.log("GET TRANSLATIONS "+e,i),V.set(false),this.catalogFromSnapshot=false,I.set(i),setTimeout(()=>N.set(e),100),this.lastLoaded[e]=new Date().getTime()/1e3,this.readyResolve(),true}};function ca(t){return Array.isArray(t)&&Array.isArray(t.raw)}function ua(t,e){let n=e.map(l=>{if(l===null||typeof l!="object"||Array.isArray(l))return null;let c=Object.keys(l);return c.length===1?{key:c[0],value:l[c[0]]}:null}),r=n.map((l,c)=>String(l?l.value:e[c])),s=t.reduce((l,c,u)=>l+c+(u<r.length?r[u]:""),"");if(n.some(l=>l===null))return {phrase:null,params:{},text:s};let i=Kn(n.map(l=>({shape:{identifier:l.key},explicit:l.key}))),o={};return i.forEach((l,c)=>o[l]=n[c].value),{phrase:t.reduce((l,c,u)=>l+c+(u<i.length?`{${i[u]}}`:""),""),params:o,text:s}}var nr=class{constructor(){this.translationsLoadingPromise=Promise.resolve();this.referenceLists=new Map;this.config=L,this.debug=new se(!!this.config.debug),this.Translations=new rt(this.config);}get t(){return this.Translations.t}async setWriteGrant(e){if(this.config.writeGrant=e,L.writeGrant=e,this.debug.log("Write grant",e?"set":"cleared"),!this.config.projectid||!this.config.key)return;let n=await S.validate(this.config);n.status&&n.data&&this.applyAuthorization(n.data,"grant change");}applyAuthorization(e,n){let r=e;r.key_type&&(this.config.key_type=r.key_type,L.key_type=r.key_type,this.debug.log("API Key Type:",r.key_type));let s=r.write_enabled===true;typeof r.write_enabled!="boolean"&&this.debug.warn(`The server's answer carried no write_enabled (${n}), so this session is not write-enabled.`),this.Translations.applyWriteEnabled(s,r.key_type),this.debug.log(`Session write-enabled (${n}):`,s),typeof r.discovery_base_locale_only=="boolean"&&(me.set(r.discovery_base_locale_only),this.debug.log(`Discovery limited to the base locale (${n}):`,r.discovery_base_locale_only));let i=r.langsys_settings?.translatable_items?.batch_limit;typeof i=="number"&&i>0&&(ye.set(i),this.debug.log(`Batch limit (${n}):`,i)),typeof r.auto_discovery=="boolean"&&($e.set(r.auto_discovery),this.debug.log(`Discovery reporting permitted (${n}):`,r.auto_discovery));}notifyNavigation(){this.Translations.notifyNavigation();}localeHeaders(){let e=P()?.locale||this.config?.sUserLocale?.get?.()||N.get();return e?{"Accept-Language":v(e)}:{}}seedCatalog(e,n,r){for(let s of Object.values(r?.blocks??{}))He(s);for(let s of r?.phrases??[])jt(s);this.publishSeed(e,n),this.Translations.markLoaded(v(n)),this.debug.log("Seeded catalog for locale",v(n));}loadSnapshot(e,n){let r=yn(e),s=v(n||this.config.sUserLocale?.get?.()||r.base_locale),i=r.catalog[s];return i?(this.publishSeed(JSON.parse(JSON.stringify(i)),s),this.Translations.markSeeded(),this.debug.log("Loaded snapshot catalog for locale",s),true):false}publishSeed(e,n){let r=v(n);e.__uncategorized__||(e.__uncategorized__={__category__:"__uncategorized__",__symbol__:"__uncategorized__"});for(let s of Object.keys(e))e[s].__category__=s;I.set(e),N.set(r);}renderServerMessage(e,n){if(typeof e.template!="string")return e.message??"";let r=n||this.config.messagesCategory||pt,s=e.params??{},i=this.Translations.lookup(e.template,r)!==null,a=this.Translations.tSignal.get()(e.template,r,s);return i?a:e.message??gn(e.template,s)}isAlreadySeeded(e){if(ft()!==v(e))return false;let n=ie();return Object.keys(n).some(r=>r!=="__uncategorized__"||Object.keys(n[r]).length>2)}async refresh(){let e=this.config.sUserLocale.get();for(let n of [...this.referenceLists.keys()])n.startsWith("locales/data\0")&&this.forgetReferenceList(n);return this.Translations.change(e,true)}isConfigured(){return Le.get()===true}refuseUnconfigured(e,n,r){Le.set(false),S.clearCredentials();let s={projectid:"",key:"",writeGrant:void 0};return Object.assign(L,s),Object.assign(this.config,s),this.Translations.markUnconfigured(new ae(`Langsys is not configured: LangsysApp.init() was called without ${e}.`),r),{status:false,errors:[n]}}async init(e){let n=e.projectid,r=e.key,s=e.UserLocaleStore,i=e.baseLocale||"en",o=e.debug||false,a=e.emulateFailureToLoad||false,l=e.ssrTokenStrategy||"client",c=e.initialTranslations,u=e.initialTranslationsLocale,d=e.writeGrant,f=e.requireCredentials===true;if(this.debug.debugEnabled=o,k.debugEnabled=o,vs(),e.apiUrl&&S.setBaseUrl(e.apiUrl),L.ssrTokenStrategy=l,o&&c&&this.debug.log("SSR initial translations config:",{hasInitialTranslations:!!c,initialTranslationsLocale:u,categoriesProvided:c?Object.keys(c).length:0,categories:c?Object.keys(c):[]}),!n)return this.debug.error("LangsysApp.init missing projectid in configuration object!"),this.refuseUnconfigured("a project id","Missing projectid",f);if(!r)return this.debug.error("LangsysApp.init missing API key in configuration object!"),this.refuseUnconfigured("an API key","Missing API key",f);if(!s?.subscribe||typeof s.get!="function")return this.debug.error("LangsysApp.init missing UserLocaleStore \u2014 pass any object satisfying LocaleSource (get + subscribe). createSignal('en-US') works if you have nothing of your own."),this.refuseUnconfigured("a locale store","Missing UserLocaleStore",f);if(Le.set(true),this.Translations.markConfigured(),i=v(i),this.Translations.setLegacyKeys(e.legacyKeys),!a){this.config={projectid:n,key:r,sUserLocale:s,baseLocale:i,debug:o,ssrTokenStrategy:l,writeGrant:d,messagesCategory:e.messagesCategory||pt},Object.assign(L,this.config);let g=v(s.get()||"");g&&dt(ht(n,g));}d&&l!=="client"&&this.debug.warn(`ssrTokenStrategy '${l}' degrades to 'client' while a writeGrant is configured \u2014 write capability is per-user with a grant, so a server-side decision would leak across requests. Tokens will flush after hydration instead.`);let h=await S.validate(this.config);return h.status&&h.data?this.applyAuthorization(h.data,"init"):(this.Translations.settleNotWritable(),this.Translations.settle()),c&&u&&(this.isAlreadySeeded(u)?this.debug.log("Catalog already seeded for locale; leaving it",u):this.seedCatalog(c,u)),this.Translations.setup(this.config),c&&u&&this.Translations.markLoaded(u),this.config.sUserLocale.subscribe(g=>{if(!h.status)return;let m=v(g);this.getLocalesData(m).catch(()=>{}),this.debug.log("SUBSCRIBING TO USER LOCALE STORE"),this.translationsLoadingPromise=this.Translations.change(m,false);}),h}async getDialCodes(e){return this.readReferenceList("getDialCodes","countries/dial-codes",e,()=>[])}async getCurrencies(e){return this.readReferenceList("getCurrencies","currencies",e,()=>[])}async getCountries(e){return this.readReferenceList("getCountries","countries",e,()=>[])}async getCountryName(e,n){if(!e)return "";let s=(await this.readReferenceList("getCountries","countries",n,()=>[],{copy:false})).find(i=>i.code?.toLowerCase()===e.toLowerCase())?.label;return s||this.debug.warn("getCountryName failed to match",e),s||e}async getCurrencyName(e,n){if(!e)return "";let s=(await this.readReferenceList("getCurrencies","currencies",n,()=>[],{copy:false})).find(i=>i.code?.toLowerCase()===e.toLowerCase())?.name;return s||this.debug.warn("getCurrencyName failed to match",e),s||e}async getLocalesFormat(e="",n){let r=e==="flat"?"getLocalesFlat":e==="data"?"getLocalesData":"getLocales";return this.readReferenceList(r,"locales"+(e?`/${e}`:""),n,()=>e?[]:{},{grouped:!e})}async getLocalesFlat(e){return await this.getLocalesFormat("flat",e)}async getLocalesData(e,n=false){return n&&this.forgetReferenceList(`locales/data\0${this.displayLocale(e)}`),await this.getLocalesFormat("data",e)}async getLocales(e){return await this.getLocalesFormat("",e)}async readReferenceList(e,n,r,s,i={}){let o=p=>i.copy===false?p:ct(p),a=S.currentCredentials();if(!a.projectid||!a.key)return this.Translations.assertConfigured(),s();let l=this.displayLocale(r);if(!da(l))return this.debug.warn(`LangsysApp.${e}: "${l}" is not a locale, so no list is read for it.`),s();let c=`${n}\0${l}`,u=this.referenceLists.get(c);if(u&&"list"in u)return o(u.list);if(u?.reading){let p=await u.reading;return p===void 0?s():o(p)}let d=`${a.projectid}\0${a.key}`,f=u?.failed?.get(d);if(f?.retryAt!==void 0&&Date.now()<f.retryAt)return this.debug.log(`LangsysApp.${e}: the last read of ${n} (${l}) under these credentials failed, so none is sent until`,new Date(f.retryAt)),s();let h=n.startsWith("locales"),g=(async()=>{try{let p=h?await S.get(n,{"locales[]":l,append_target_locales:"0"},{credentials:a}):await S.get(`${n}/${l}`,{},{credentials:a});if(p.errors||!p.status){this.debug.error(`LangsysApp.${e} failed: ${n} (${l}):`,p.errors??p.http?.status);return}let A=h?ha(p.data,l,i.grouped===!0,s):Array.isArray(p.data)?p.data:void 0;if(A===void 0){this.debug.error(`LangsysApp.${e}: the answer for ${n} (${l}) is not of the list's shape.`,p.data);return}return h?fa(A):A}catch(p){this.debug.error(`LangsysApp.${e} failed: ${n} (${l}):`,p);return}})();this.referenceLists.set(c,{...u,reading:g});let m=await g;if(this.referenceLists.get(c)?.reading===g)if(m!==void 0)this.referenceLists.set(c,{list:m});else {let p=(f?.failures??0)+1,A=new Map(u?.failed);this.referenceLists.set(c,{failed:A.set(d,{failures:p,retryAt:Date.now()+er(p)})});}return m===void 0?s():o(m)}forgetReferenceList(e){let n=this.referenceLists.get(e)?.failed;n?this.referenceLists.set(e,{failed:new Map([...n].map(([r,{failures:s}])=>[r,{failures:s}]))}):this.referenceLists.delete(e);}displayLocale(e){if(e)return Fe(v(e));let n=P()?.locale||v(this.config?.sUserLocale?.get?.()||"")||this.config?.baseLocale||"en";return Fe(n)}async getLocaleNameWithLookup(e,n=false,r){if(!e)return "";let s=this.displayLocale(r);return await this.readReferenceList("getLocalesData","locales/data",s,()=>[],{copy:false}),this.getLocaleName(e,n,s)}getLocaleName(e,n=false,r){let s=S.currentCredentials();if(!s.projectid||!s.key)return this.Translations.assertConfigured(),"";let i=this.displayLocale(r),o=this.referenceLists.get(`locales/data\0${i}`)?.list;if(!o)return this.debug.warn(`getLocaleName('${e}') called before locale data for '${i}' was loaded \u2014 run \`await getLocalesData('${i}')\` first, or use \`await getLocaleNameWithLookup(...)\` instead.`),"";let a=[Fe(e),v(e)],l=o.find(u=>a.includes(Fe(u.code))),c=l?n?l.lang_name:l.locale_name:"";return c||this.debug.warn("getLocaleName found no entry matching",e),c}async getLanguageName(e,n=false,r){return this.getLocaleNameWithLookup(e,n,r)}detectPreferredLocale(e,n){let r=this.getUserLanguagePreferences(e);return r.length===0?false:n&&n.length>0?this.findBestLocaleMatch(r,n)??false:v(r[0])}getUserLanguagePreferences(e){if(e)try{return this.parseAcceptLanguageHeader(e)}catch(n){this.debug.warn("Failed to parse Accept-Language header:",n);}if(typeof navigator<"u"){if(navigator.languages&&navigator.languages.length>0)return Array.from(navigator.languages);if(navigator.language)return [navigator.language]}return []}parseAcceptLanguageHeader(e){if(!e||typeof e!="string"||e.trim()==="")return [];try{return e.split(",").map(n=>{let r=n.trim();if(!r||r==="*")return null;let[s,i]=r.split(";q="),o=s?.trim(),a=i?parseFloat(i):1;return !o||isNaN(a)||a<=0||a>1?null:{locale:o,q:a}}).filter(n=>n!==null).sort((n,r)=>r.q-n.q).map(n=>n.locale)}catch(n){return this.debug.warn("Error parsing Accept-Language header:",n),[]}}findBestLocaleMatch(e,n){if(!e.length||!n.length)return null;let r=n.map(s=>v(s));for(let s of e){let i=v(s);if(r.includes(i))return i}for(let s of e){let i=on(s);if(!i)continue;let o=r.find(a=>on(a)===i);if(o)return o}return null}},T=new nr;function da(t){return typeof t=="string"&&/^[a-z]{2,8}(?:-[a-z0-9]{1,8})*$/.test(t)}function ha(t,e,n,r){if(Array.isArray(t))return t.length===0?r():void 0;if(typeof t!="object"||t===null)return;let s=Object.entries(t).find(([o])=>Fe(o)===e);if(!s)return r();let[,i]=s;if(!n)return Array.isArray(i)?i:void 0;if(Array.isArray(i))return i.length===0?{}:void 0;if(!(typeof i!="object"||i===null))return Object.values(i).every(o=>Array.isArray(o))?i:void 0}function Fe(t){return typeof t=="string"?t.replace(/_/g,"-").toLowerCase():""}function fa(t){let e=n=>Array.isArray(n)?n.map(r=>typeof r=="object"&&r!==null&&typeof r.code=="string"?{...r,code:Fe(r.code)}:r):n;return Array.isArray(t)?e(t):typeof t!="object"||t===null?t:Object.fromEntries(Object.entries(t).map(([n,r])=>[n,e(r)]))}var st=new WeakMap;function Ue(t,e,n=false){let r=st.get(t);r&&r.byWalk&&r.instance!==e&&r.instance.destroy(),st.set(t,{instance:e,byWalk:n});}function Zt(t,e){st.get(t)?.instance===e&&st.delete(t);}var js=new Set;function Xt(t){return P()?(js.has(t)||(js.add(t),k.warn(`${t} was constructed inside a request scope and does nothing there: render the block with renderBlock() and register it with registerBlock(), which complete inside the scope.`)),true):false}function rr(t){return st.has(t)}var it=class{constructor(e,n={},r=false){this.values={};this.phrase="";this.slots=[];this.textless=false;this.opaqueTexts=[];this.slotOf=new WeakMap;this.servedUnrecovered=false;this.unsubscribers=[];this.ready=false;this.checkedParamKeys=null;if(this.host=e,this.category=n.category??"",this.params=n.params??{},this.register=n.register!==false,Xt("Phrase"))return;Ue(e,this,r),this.register||ve("register-false"),this._init();let s=()=>{this.ready&&this._render();};this.unsubscribers.push(N.subscribe(s)),this.unsubscribers.push(I.subscribe(s));let i=true;this.unsubscribers.push(be.subscribe(()=>{if(i){i=false;return}!this.ready||!this.phrase||!this.register||this.textless||!this.host.isConnected||W(this.host)||T.Translations.t(this.phrase,this.category);}));}setParams(e){this.params=e??{},this._checkParams(),this.ready&&this._render();}destroy(){this.unsubscribers.forEach(e=>e()),this.unsubscribers=[],Zt(this.host,this);}async _init(){if(!this.host||!this.host.childNodes.length){this.ready=true;return}let{phrase:e,slots:n,values:r,earlier:s}=$n(this.host);this.phrase=e,this.slots=n,this.values=r,this.earlier=s,this.opaqueTexts=n.flatMap(i=>i.source&&Xe(i.source)?[i.source.textContent??""]:[]),$s(this.host).forEach((i,o)=>this.slotOf.set(i,o)),this._checkParams(),await T.Translations.ready(),this.textless=ga(this.phrase)&&(Object.keys(r).length>0||n.some(i=>i.source)),W(this.host)?this.servedUnrecovered=!this.recoverServed():this.register&&!this.textless&&T.Translations.t(this.phrase,this.category),this.ready=true,this._render();}_checkParams(){if(!this.phrase)return;let e=Object.keys(this.params).sort().join(",");e!==this.checkedParamKeys&&(this.checkedParamKeys=e,Ct("<Phrase>",[this.phrase,...this.opaqueTexts],this.params,this.category||void 0));}recoverServed(){let e=ws(this.phrase,this.slots.length,this.category,this.params);if(!e)return false;let n=this.slots,r=[];return $s(this.host).forEach((s,i)=>{let o=e.order[i];this.slotOf.set(s,o),r[o]=n[i];}),this.phrase=e.phrase,this.slots=r,true}_render(){if(!this.phrase)return;this.servedUnrecovered&&(this.servedUnrecovered=!this.recoverServed());let e=T.Translations.lookup(this.phrase,this.category),n=e===null&&this.earlier?T.Translations.lookup(this.earlier.phrase,this.category):null;if(n!==null){let{slots:i,values:o}=this.earlier,a=Se(n,{...o,...this.values,...this.params},i.length,N.get());this.host.replaceChildren(...Vt(a,i,this.host.ownerDocument??document)),Gn(i,this.params);return}let r=e??this.phrase,s=Se(r,{...this.values,...this.params},this.slots.length,N.get());if(!fs(this.host,s,i=>this.slotOf.get(i))){let i=Vt(s,this.slots,this.host.ownerDocument??document,(o,a)=>this.slotOf.set(o,a));this.host.replaceChildren(...i);}Gn(this.slots,this.params);}};function ga(t){return !t.replace(/\{[a-z][a-z0-9_]*\}/g,"").trim()}function $s(t){let e=[],n=r=>{for(let s of Array.from(r.children))We(s)===null&&(e.push(s),Ce(s)||n(s));};return n(t),e}var pa=500,Ds=new WeakMap,sr=class t{constructor(e,n={},r=false){this.tokens=[];this.parseComplete=false;this.isTokenizing=false;this.lastTranslatedLocale="";this.unsubscribers=[];this.checkedParamKeys=null;this.contentBlock=null;this.adoptedId=null;this.sourcesRecovered=false;this.servedLocale="";this.vars={values:{},runs:[],markerOnly:[]};this.runSources=new WeakMap;this.runOriginals=new WeakMap;this.markedValues=new WeakMap;this.takenOver=[];this.observer=null;this.settleTimer=null;this.settled=false;this.settleWaiters=[];this.dirty=false;this.derivedId=true;this.registeredId=null;this.written=new WeakMap;this.edges=new WeakMap;if(this.element=e,this.options={...n},this.custom_id=n.custom_id||"",Xt("Translate"))return;Ue(e,this,r),n.register===false&&ve("register-false");let s=we(e);s?.kind==="identity"&&Ds.get(e)!==s.id&&(!this.custom_id||this.custom_id===s.id)&&(this.custom_id=s.id,W(e)&&(this.adoptedId=s.id)),this.derivedId=!this.custom_id,this.observeStructure(),this.tokenizeContent(),this.unsubscribers.push(N.subscribe(o=>{o&&this.parseComplete&&this.translateUpdate(o);})),this.unsubscribers.push(I.subscribe(()=>{if(!this.parseComplete)return;let o=N.get();o&&(this.lastTranslatedLocale="",this.translateUpdate(o));}));let i=true;this.unsubscribers.push(be.subscribe(()=>{if(i){i=false;return}this.reenterAfterNavigation();}));}reenterAfterNavigation(){if(!this.parseComplete||!this.element?.isConnected||this.adoptedId||!this.registers()||this.hasUnreadChange())return;let{category:e=""}=this.options;if(this.usesSingleTextNodeFastPath()){this.renderSingleToken(e);return}this.contentBlock&&!re(this.contentBlock.category,this.custom_id)&&!W(this.element)&&!Ee(this.custom_id)&&Y({...this.contentBlock,custom_id:this.custom_id});}setParams(e){if(this.options.params=e,this.checkParams(),!this.parseComplete)return;this.lastTranslatedLocale="";let n=N.get();n&&this.translateUpdate(n);}observeStructure(){if(this.adoptedId||W(this.element)||typeof MutationObserver>"u"){this.markSettled();return}this.observer=new MutationObserver(e=>{e.some(n=>this.isUnitChange(n))&&(this.dirty=true,this.armSettle());}),this.observer.observe(this.element,{childList:true,subtree:true,characterData:true}),this.armSettle();}isUnitChange(e){return this.isUnitStructure(e.target)?e.type==="childList"?true:!this.settled&&e.target.nodeValue!==this.written.get(e.target):false}hasUnreadChange(){return (this.observer?.takeRecords()??[]).some(n=>this.isUnitChange(n))&&(this.dirty=true,this.armSettle()),this.dirty}writeText(e,n){e.nodeValue!==n&&(this.written.set(e,n),e.nodeValue=n);}writeKeepingEdges(e,n){let r=e.nodeValue??"",s=this.written.get(e)===r?this.edges.get(e):void 0;s||(s=[/^\s*/.exec(r)[0],/\s*$/.exec(r)[0]],this.edges.set(e,s)),this.writeText(e,s[0]+n+s[1]);}isUnitStructure(e){for(let n=e;n&&n!==this.element;n=n.parentNode){if(n.nodeType!==Node.ELEMENT_NODE)continue;let r=n;if(r.localName==="option"||D(r))return false}return true}armSettle(){this.settleTimer&&clearTimeout(this.settleTimer),this.settleTimer=setTimeout(()=>{this.settleTimer=null,this.dirty&&this.parseComplete&&!this.isTokenizing&&this.rederive(),this.markSettled();},pa);}markSettled(){this.settled||(this.settled=true,this.settleWaiters.forEach(e=>e()),this.settleWaiters=[]);}whenSettled(){return this.settled?Promise.resolve():new Promise(e=>this.settleWaiters.push(e))}async rederive(){this.dirty=false,this.takenOver.forEach(n=>n.destroy()),this.takenOver=[],this.derivedId&&(this.custom_id=""),this.contentBlock=null,this.parseComplete=false,this.lastTranslatedLocale="";let e=this.registeredId;await this.tokenizeContent(),e&&this.custom_id&&this.custom_id!==e&&ge(`rekey\0${e}`,`A <Translate> block registered as ${e} changed its structure after it settled and is now ${this.custom_id}. If ${e} was a placeholder (a Suspense fallback still showing when the settle window closed), it stays registered.`);}destroy(){this.observer?.disconnect(),this.observer=null,this.settleTimer&&clearTimeout(this.settleTimer),this.settleTimer=null,this.unsubscribers.forEach(e=>e()),this.unsubscribers=[],this.takenOver.forEach(e=>e.destroy()),this.takenOver=[],Zt(this.element,this);}takeOverUnmanagedHosts(){let{params:e,label:n}=this.options,r=s=>{for(let i of Array.from(s.children)){let o=Ht(i)??this.options.category;fe(i)?rr(i)||this.takenOver.push(new it(i,{category:o,params:e,register:this.options.register},true)):It(i)?rr(i)||this.takenOver.push(new t(i,{category:o,params:e,label:n,register:this.options.register},true)):D(i)||r(i);}};r(this.element);}translateUpdate(e){if(!this.element?.innerHTML||!this.parseComplete||this.hasUnreadChange()||this.lastTranslatedLocale===e)return;let{category:n=""}=this.options;if(this.usesSingleTextNodeFastPath())this.renderSingleToken(n),this.lastTranslatedLocale=e;else {if(!this.recoverServedSources(e!==this.servedLocale))return;this.translate(Array.from(this.element.childNodes)),this.lastTranslatedLocale=e,this.adoptedId&&this.restampResolvedLocale(e);}}restampResolvedLocale(e){for(let n of ce){let r=this.element.getAttribute(n);if(r!==null){!["","true","1","yes"].includes(r.trim().toLowerCase())&&r!==e&&this.element.setAttribute(n,e);return}}}recoverServedSources(e){if(!this.adoptedId||this.sourcesRecovered)return true;let{category:n="",params:r={}}=this.options,s=Ts(this.element,this.adoptedId,n,r);return s?(s.slots.forEach((i,o)=>{let a=s.sources[o];if(i.run)this.runSources.set(this.runKey(i.run),a);else if(i.attr){let l=i.node;(l.originalAttributes??={})[i.attr]=a;}else {let l=i.node,c=l.nodeValue??"";l.originalNodeValue=c.match(/^\s*/)[0]+a+c.match(/\s*$/)[0];}}),this.tokens=s.sources,this.sourcesRecovered=true,this.checkParams(),true):(e&&ks(),false)}renderSingleToken(e){let n=this.tokens[0],r=T.Translations.lookupContent(e,this.custom_id,n),s=T.Translations.t,i=this.settled&&this.registers()&&!W(this.element)&&!Ee(this.custom_id),o=r!=null;if(this.isSingleRun()){!o&&i&&(s(n,e,{...this.vars.values,...this.options.params??{}}),this.registeredId=this.custom_id);let c=this.findRun();c&&this.writeRun(c,o?r:T.Translations.lookup(n,e)??n);return}let a;o?a=this.applyParams(r):i?(a=s(n,e,this.options.params??{}),this.registeredId=this.custom_id):a=this.applyParams(T.Translations.lookup(n,e)??n);let l=this.findSingleTextNode(this.element);if(!l){k.warn("Translate: single-token fast path reached an element with no text node \u2014 this is a routing bug, not a content problem. Leaving the DOM untouched rather than replacing it.");return}this.writeKeepingEdges(l,a);}usesSingleTextNodeFastPath(){return this.adoptedId?false:this.tokens.length===1&&(this.findSingleTextNode(this.element)!==null||this.isSingleRun())}isSingleRun(){return this.tokens.length===1&&this.vars.runs.includes(0)}registers(){return this.options.register!==false&&!Be(this.tokens,this.vars)}stampContentBlockMarker(){!this.element||!this.custom_id||(this.element.setAttribute(X,this.custom_id),Ds.set(this.element,this.custom_id));}findRun(){let e=n=>{for(let r of J(n.childNodes)){if("run"in r)return r.run;if(r.node.nodeType!==Node.ELEMENT_NODE||D(r.node))continue;let s=e(r.node);if(s)return s}return null};return e(this.element)}runKey(e){let n=e.parts[0];return "text"in n?n.text:n.marker.frame[0]}runOriginal(e){let n=this.runOriginals.get(e);return n===void 0&&(n=O(e.nodeValue??""),this.runOriginals.set(e,n)),n}markedValue(e){let n=e.value[0]??e.frame[0],r=R(e.value.map(s=>s.nodeValue??"").join(""));return r&&this.markedValues.set(n,r),r||(this.markedValues.get(n)??"")}writeRun(e,n){let r=Ot(e,n,this.options.params??{},N.get(),{text:s=>this.runOriginal(s),value:s=>this.markedValue(s)});for(let[s,i]of r)this.writeText(s,i);}translateRun(e){let n=this.runSources.get(this.runKey(e))??de(e,r=>this.runOriginal(r));this.writeRun(e,this.getTranslation(n)??n);}findSingleTextNode(e){return Ke(e)}async tokenizeContent(){if(this.isTokenizing)return false;if(!this.element||!this.element.childNodes.length)return this.parseComplete=true,this.isTokenizing=false,false;this.isTokenizing=true;let{tokens:e,content:n,vars:r}=Vn(this.element);if(this.tokens=e,this.vars=r,this.registers())try{T.Translations.assertConfigured();}catch(i){throw this.isTokenizing=false,i}this.checkParams(),this.takeOverUnmanagedHosts();let{category:s=""}=this.options;if(this.usesSingleTextNodeFastPath())pe(this.custom_id)&&(this.custom_id=z(s,this.tokens)),this.stampContentBlockMarker(),this.renderSingleToken(s),this.settled||this.whenSettled().then(()=>{!this.dirty&&this.usesSingleTextNodeFastPath()&&this.renderSingleToken(s);});else {let i={custom_id:"",category:s,label:this.options.label,content:n,tokens:this.tokens};await this.handleContentBlock(i);}return this.parseComplete=true,this.isTokenizing=false,this.dirty&&this.settled&&this.rederive(),true}async handleContentBlock(e){if(this.adoptedId){await T.Translations.ready(),this.registers()&&T.Translations.assertConfigured(),this.element&&(this.recoverServedSources(false)&&this.translate(Array.from(this.element.childNodes)),this.lastTranslatedLocale=this.servedLocale=N.get());return}this.contentBlock=e;let n=pe(this.custom_id);if(n&&(this.custom_id=z(e.category,e.tokens)),e.custom_id=this.custom_id,this.stampContentBlockMarker(),await T.Translations.ready(),this.registers()&&T.Translations.assertConfigured(),re(e.category,this.custom_id)){!this.usesSingleTextNodeFastPath()&&this.element&&(this.translate(Array.from(this.element.childNodes)),this.lastTranslatedLocale=N.get());return}if(n){let r=Lt(e.category,e.tokens,jn(this.element)).filter(i=>i!==this.custom_id),s=Ft(e.category,r,e.tokens);if(s){this.custom_id=s,this.stampContentBlockMarker(),!this.usesSingleTextNodeFastPath()&&this.element&&(this.translate(Array.from(this.element.childNodes)),this.lastTranslatedLocale=N.get());return}}!this.usesSingleTextNodeFastPath()&&this.element&&(this.translate(Array.from(this.element.childNodes)),this.lastTranslatedLocale=N.get()),await this.whenSettled(),!this.dirty&&(this.registers()?Qe(this.custom_id,"seed")?k.log("Skipping content block registration: the seed already sent it"):Ee(this.custom_id)?k.log("Skipping content block registration: the server registers this block"):W(this.element)?k.log("Skipping content block registration: the host sits in a resolved scope"):(Ye(this.custom_id,"mount"),this.registeredId=this.custom_id,Y(e)):k.log("Skipping content block registration: this unit registers nothing"));}translate(e){if(!(N.get()===L.baseLocale&&(this.lastTranslatedLocale===""||this.lastTranslatedLocale===L.baseLocale)&&pe(this.options.params)&&!this.tokens.some(r=>ne(r))))for(let r of J(e)){if("run"in r){this.translateRun(r.run);continue}let s=r.node;if(s?.nodeType===Node.ELEMENT_NODE&&(D(s)||(this.translateAttributes(s),s.localName==="option"&&s.closest("select"))))continue;if(s?.nodeType!==Node.TEXT_NODE){if(!s?.hasChildNodes())continue;this.translate(Array.from(s.childNodes));continue}if(pe(R(s.nodeValue??"")))continue;pe(s.originalNodeValue)&&(s.originalNodeValue=O(s.nodeValue));let i=s.originalNodeValue?R(s.originalNodeValue):void 0;if(!i)continue;let o=this.getTranslation(i);if(o&&i&&s.originalNodeValue){let a=this.applyParams(o);this.writeText(s,s.originalNodeValue.replace(i,()=>a));}else s.originalNodeValue&&this.writeText(s,this.applyParams(s.originalNodeValue));}}getTranslation(e){if(!e)return null;let{category:n=""}=this.options;return T.Translations.lookupContent(n,this.custom_id,e)}checkParams(){if(!this.tokens.length||this.adoptedId&&!this.sourcesRecovered)return;let{params:e,category:n=""}=this.options,r=e?Object.keys(e).sort().join(","):"";r!==this.checkedParamKeys&&(this.checkedParamKeys=r,Ct("<Translate>",this.tokens,e,n||void 0));}applyParams(e){return U(e,this.options.params??{},N.get())}translateAttributes(e){let n=e.tagName.toLowerCase();e.originalAttributes||(e.originalAttributes={});for(let r of le)this.translateAttribute(e,r);if(Pe.includes(n)&&this.translateAttribute(e,"value"),n==="input"){let r=e.getAttribute("type")?.toLowerCase();r&&Oe.includes(r)&&this.translateAttribute(e,"value");}n==="select"&&e.querySelectorAll("option").forEach(s=>{let i=s;i.originalAttributes||(i.originalAttributes={}),i.originalAttributes.textContent===void 0&&(i.originalAttributes.textContent=O(s.textContent||""));let o=R(i.originalAttributes.textContent);if(o){let a=this.getTranslation(o),l=this.applyParams(a||i.originalAttributes.textContent),c=s.childNodes.length===1?s.firstChild:null;c&&c.nodeType===Node.TEXT_NODE?this.writeText(c,l):s.textContent=l;}});}translateAttribute(e,n){let r=e.getAttribute(n);if(!r)return;e.originalAttributes[n]===void 0&&(e.originalAttributes[n]=O(r));let s=R(e.originalAttributes[n]);if(!s)return;let i=this.getTranslation(s);i?e.setAttribute(n,this.applyParams(i)):e.setAttribute(n,this.applyParams(e.originalAttributes[n]));}};function ma(t){let e=Qt(t),{tokens:n,vars:r}=Me(e);return {tokens:n,shape:ir(e,n,false,r)}}function ya(t,e={}){let n=Qt(t),{tokens:r,vars:s}=Me(n),i=Ks(n,e);if(i.customId&&i.shape!=="empty"){let o=e.register!==false&&!e.customId&&!Be(r,s);P()?.recordRendered({customId:i.customId,category:e.category??"",tokens:r,shape:i.shape,...o?i.shape==="block"?{content:or(t)}:{}:{register:false}});}return i}function ba(t){ge(`unrendered\0${t}`,t==="variable"?"A <Translate> block holds a value from a variable that cannot be named without the build-time transform, so it renders from the catalog and registers nothing, on the server or the client (VAR-7).":`A <Translate> block was served as source (${t}): the binding could not show it to the renderer, so the client renders and registers it after hydration.`);}var ka={destroy(){}};function Ta(t,e={}){if(e.host&&Ue(e.host,ka),typeof window>"u"&&!P())return ge("register-block\0no-scope","registerBlock() was called on a server outside a request scope, so it registered nothing: there is no scope to hold the block for close(). Render and register inside createRequestScope().run(), or register from the client."),Promise.resolve();let n=e.register!==false&&(Array.isArray(t)||t.register!==false);if(n&&!P())try{T.Translations.assertConfigured();}catch(i){return Promise.reject(i)}if(Array.isArray(t)||He(t),e.host&&W(e.host.parentElement))return Promise.resolve();let r=Array.isArray(t)?Qt(t):null,s=()=>{try{r?Ys(r,e,t):Ra(t);}catch{}};return P()?(s(),Promise.resolve()):T.Translations.ready().then(()=>{n&&T.Translations.assertConfigured(),s();})}function Gs(t){let e=[];for(let n of Array.from(t.childNodes))if(n.nodeType===3)e.push({text:n.nodeValue??""});else if(n.nodeType===8)e.push({comment:n.nodeValue??""});else if(n.nodeType===1){let r=n,s={};for(let o of Array.from(r.attributes))s[o.name]=o.value;let i=r.localName==="template"?r.content:r;e.push({tag:r.localName,attrs:s,children:Gs(i)});}return e}function wa(t,e,n={}){let r=Array.isArray(e)?e:e.nodes,s=[],i=0,o=(l,c)=>{let u=Array.from(l.childNodes).filter(d=>d.nodeType===1||d.nodeType===3||d.nodeType===8);if(u.length!==c.length)return false;for(let d=0;d<c.length;d++){let f=u[d],h=c[d];if("text"in h){if(f.nodeType!==3)return false;f.nodeValue!==h.text&&s.push(()=>f.nodeValue=h.text);}else if("comment"in h){if(f.nodeType!==8)return false}else {let g=f;if(f.nodeType!==1||g.localName!==h.tag||h.source!==i++)return false;for(let[p,A]of Object.entries(h.attrs)){let C=A===true?"":A;(Ea(g.localName,p,h.attrs)||Sa.includes(p))&&g.getAttribute(p)!==C&&s.push(()=>g.setAttribute(p,C));}let m=g.localName==="template"?g.content:g;if(!o(m,h.children))return false}}return true},a=n.self?{childNodes:[t]}:t;if(!o(a,r))return {applied:false,reason:"structure"};for(let l of s)l();if(!Array.isArray(e))for(let[l,c]of Object.entries(e.hostAttrs))t.setAttribute(l,c);return {applied:true}}var Sa=[X,Te];function Ea(t,e,n){if(le.includes(e))return true;if(e!=="value")return false;if(Pe.includes(t))return true;let r=n.type;return t==="input"&&typeof r=="string"&&Oe.includes(r.toLowerCase())}function va(t){return t.map(e=>ar(e)).join("")}var K=class{constructor(e){this.nodeValue=e;this.nodeType=3;this.childNodes=[];}hasChildNodes(){return false}get textContent(){return this.nodeValue}},Ve=class{constructor(e){this.nodeValue=e;this.nodeType=8;this.childNodes=[];}hasChildNodes(){return false}get textContent(){return ""}},q=class t{constructor(e,n,r,s,i){this.source=s;this.params=i;this.nodeType=1;this.nodeValue=null;this.tagName=e.toUpperCase(),this.attrs=new Map(Object.entries(n??{}).map(([o,a])=>[o.toLowerCase(),a])),this.childNodes=r;}getAttribute(e){let n=this.attrs.get(e.toLowerCase());return n===void 0?null:n===true?"":n}hasAttribute(e){return this.attrs.has(e.toLowerCase())}setAttribute(e,n){this.attrs.set(e.toLowerCase(),String(n));}hasChildNodes(){return this.childNodes.length>0}get textContent(){return this.childNodes.map(e=>e.textContent).join("")}querySelectorAll(e){let n=[],r=s=>{for(let i of s.childNodes)i instanceof t&&(i.tagName.toLowerCase()===e.toLowerCase()&&n.push(i),r(i));};return r(this),n}};function Qt(t){let e=0,n=r=>r.map(s=>{if("text"in s)return new K(s.text);if("comment"in s)return new Ve(s.comment);let i=e++;return new q(s.tag,s.attrs,n(s.children??[]),i,s.params)});return n(t)}function ot(t){return t.map(e=>e instanceof K?{text:e.nodeValue}:e instanceof Ve?{comment:e.nodeValue}:{tag:e.tagName.toLowerCase(),attrs:Object.fromEntries(e.attrs),children:ot(e.childNodes),source:e.source})}function zs(t){return ot(t).map(function e(n){return "text"in n||"comment"in n?n:{tag:n.tag,attrs:n.attrs,children:n.children.map(e)}})}function ir(t,e,n,r){return e.length===0?"empty":!n&&e.length===1&&(Ke({childNodes:t})!==null||r?.runs.includes(0))?"phrase":"block"}var Na=()=>({catalog:()=>G(),locale:()=>N.get(),miss:()=>{},fromSnapshot:()=>false});function Ws(t,e,n,r){let s=z(n,e);if(re(n,s))return s;let i=Lt(n,e,cs(t,true)).filter(o=>o!==s);return Ft(n,i,e)??s}function Ks(t,e){let{category:n="",params:r={}}=e,{tokens:s,vars:i}=Me(t),o=ir(t,s,!!e.customId,i),a=N.get(),l=h=>U(h,r,a),c=(h,g)=>{let m=Ot(h,g,r,a,{text:p=>p.nodeValue??"",value:p=>R(p.value.map(A=>A.nodeValue??"").join(""))});for(let[p,A]of m)p.nodeValue=A;};if(Xs(t,e),o==="empty")return {shape:o,customId:null,nodes:ot(t),hostAttrs:{}};let u=(h,g)=>g&&a&&a!==L.baseLocale?{[X]:h,[Te]:a}:{[X]:h};if(o==="phrase"){let h=e.id??z(n,s),g=s[0],m=T.Translations.lookupContent(n,h,g),p=m!=null,A=T.Translations.lookup(g,n),C=i.runs.includes(0)?qs(t):null;if(C)c(C,p?m:A??g);else {let _=Ke({childNodes:t}),[w,y]=[/^\s*/.exec(_.nodeValue)[0],/\s*$/.exec(_.nodeValue)[0]];_.nodeValue=w+(p?l(m):T.Translations.renderWith(Na(),g,[n,r]))+y;}let b=p||A!==null;return {shape:o,customId:h,nodes:ot(t),hostAttrs:u(h,b)}}let d=e.customId??e.id??Ws(t,s,n);return a===L.baseLocale&&Object.keys(r).length===0&&!s.some(h=>ne(h))||Zs(t,h=>T.Translations.lookupContent(n,d,h),l,c),{shape:o,customId:d,nodes:ot(t),hostAttrs:u(d,re(n,d))}}function qs(t){for(let e of J(t)){if("run"in e)return e.run;let n=e.node;if(!(n instanceof q)||D(n))continue;let r=qs(n.childNodes);if(r)return r}return null}function Zs(t,e,n,r){for(let s of J(t)){if("run"in s){let c=de(s.run);r(s.run,e(c)??c);continue}let i=s.node;if(i instanceof Ve)continue;if(i instanceof q){if(D(i))continue;Aa(i,e,n),Zs(i.childNodes,e,n,r);continue}if(!R(i.nodeValue))continue;let o=O(i.nodeValue),a=R(o);if(!a)continue;let l=e(a);i.nodeValue=l?o.replace(a,()=>n(l)):n(o);}}function Aa(t,e,n){let r=t.tagName.toLowerCase(),s=[...le];Pe.includes(r)&&s.push("value");let i=t.getAttribute("type")?.toLowerCase();r==="input"&&i&&Oe.includes(i)&&s.push("value");for(let o of s){let a=t.getAttribute(o);if(a===null)continue;let l=O(a),c=R(l);if(!c)continue;let u=e(c);t.setAttribute(o,n(u??l));}}function Jt(t,e,n){let r=t,s={category:Ht(r)??e.category,params:t.params??e.params,label:e.label},i=we(r);return i?.kind==="identity"&&(Yt(r,n)?s.customId=i.id:s.id=i.id),s}function Yt(t,e){for(let n of ce){if(!t.hasAttribute(n))continue;let r=(t.getAttribute(n)??"").trim().toLowerCase();return r!=="false"&&r!=="0"}return e}function Xs(t,e,n=false){for(let r of t){if(!(r instanceof q))continue;if(fe(r)){r.childNodes=_a(r,Jt(r,e,n));continue}let s=we(r);if(s){let i=Jt(r,e,n),o=e.register!==false&&!i.customId&&!Yt(r,n);o||(i.register=false);let{tokens:a,vars:l}=Me(r.childNodes),c=Be(a,l),u=o&&!c&&P()?or(zs(r.childNodes)):void 0,d=Ks(r.childNodes,i);for(let[f,h]of Object.entries(d.hostAttrs))s.kind==="identity"&&f===X||r.setAttribute(f,h);d.customId&&d.shape!=="empty"&&P()?.recordRendered({customId:d.customId,category:i.category??"",tokens:a,shape:d.shape,...!o||c?{register:false}:d.shape==="block"?{content:u}:{}});continue}D(r)||Xs(r.childNodes,e,Yt(r,n));}}function _a(t,e){let{category:n="",params:r={}}=e,s={},i=t.childNodes,o=(b,_)=>({element:b,opaque:_}),{phrase:a,slots:l}=ue(he(i,o,s));if(!a)return t.childNodes;let c=T.Translations.lookup(a,n),u=l,d=c===null?Mt(i,o):null,f=d?T.Translations.lookup(d.phrase,n):null;if(d&&f!==null){c=f,u=d.slots;for(let[b,_]of Object.entries(d.values))b in s||(s[b]=_);}let h=N.get();c!==null&&h&&h!==L.baseLocale&&t.setAttribute(Te,h);let g=c??a;c===null&&Object.keys(s).length&&({phrase:g,slots:u}=ue(he(i,o,{},true,b=>({marker:b}))));let m=Se(g,{...s,...r},u.length,h),p=Ze(m);if(!p)return [new K(Je(m))];let A=[],C=[A];for(let b of p){let _=C[C.length-1];if("text"in b)_.push(new K(b.text));else if("open"in b){let w=u[b.open];if(!w)return [new K(Je(m))];if("marker"in w){let[$,Q]=w.marker.frame;if(Q)_.push($),C.push(_);else {let rn=$,lr=new q(rn.tagName,Object.fromEntries(rn.attrs),[],rn.source);_.push(lr),C.push(lr.childNodes);}continue}let{element:y,opaque:x}=w,M=x?Xe(y)?Js(y.childNodes,r):y.childNodes:[],j=new q(y.tagName,Object.fromEntries(y.attrs),M,y.source);_.push(j),C.push(x?[]:j.childNodes);}else {C.pop();let w=u[b.close],y=w&&"marker"in w?w.marker.frame[1]:void 0;y&&C[C.length-1].push(y);}}return A}function Js(t,e){return t.map(n=>n instanceof K?new K(Dn(n.nodeValue,e)):!(n instanceof q)||te.includes(n.tagName.toLowerCase())?n:new q(n.tagName,Object.fromEntries(n.attrs),Js(n.childNodes,e),n.source))}function Ys(t,e,n){let{category:r="",label:s}=e,{tokens:i,vars:o}=Me(t),a=ir(t,i,!!e.customId,o);if(e.register===false||(ei(t,e),a==="empty"||e.customId||Be(i,o)))return;if(a==="phrase"){let c=e.id??z(r,i);if(Ee(c))return;let u=T.Translations.lookupContent(r,c,i[0]);u==null&&T.Translations.t(i[0],r);return}let l=e.id??Ws(t,i,r);re(r,l)||Ee(l)||Qe(l,"seed")||(P()||Ye(l,"mount"),Y({custom_id:l,category:r,label:s,content:or(n),tokens:i}));}function or(t){let e=Qt(t);Ut(e,{empty:s=>{s.childNodes=[];},replace:(s,i,o)=>{let a=s;a.splice(a.indexOf(i[0]),i.length,new K(o));}});let n=Qs(t),r=s=>s.map(i=>i instanceof K?ti(i.nodeValue):i instanceof Ve?`<!--${i.nodeValue}-->`:ar(n[i.source],r(i.childNodes))).join("");return O(r(e))}function Qs(t){return t.flatMap(e=>"tag"in e?[e,...Qs(e.children??[])]:[])}function Ra(t){let{customId:e,category:n,tokens:r,shape:s}=t;if(!(t.collected||t.register===false||Qe(e,"mount"))){if(s==="phrase"){let i=T.Translations.lookupContent(n,e,r[0]??"");r[0]&&i==null&&T.Translations.t(r[0],n);return}if(!re(n,e)){if(!t.content){ge("register-block\0seeded-without-content",`registerBlock() was given a seeded block with no content ("${e}"), so it registered nothing from it. A Translate or a registerBlock() over the block's own nodes registers it as it would with no seed; a request scope's seed() carries the content of each block a client may register.`);return}Ye(e,"seed"),Y({custom_id:e,category:n,content:t.content,tokens:r});}}}function ei(t,e,n=false){for(let r of t){if(!(r instanceof q))continue;let s=Yt(r,n),i=Jt(r,e,n).category??"";if(fe(r)){let a={},{phrase:l,slots:c}=ue(he(r.childNodes,(d,f)=>f,a)),u=!l.replace(/\{[a-z][a-z0-9_]*\}/g,"").trim()&&(Object.keys(a).length>0||c.some(Boolean));l&&!s&&!u&&T.Translations.t(l,i);continue}if(we(r)){let a=Jt(r,e,n);!a.customId&&!s&&Ys(r.childNodes,a,zs(r.childNodes));continue}D(r)||ei(r.childNodes,e,s);}}var La=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]);function ar(t,e){if("text"in t)return ti(t.text);if("comment"in t)return `<!--${t.comment}-->`;let n=t.tag.toLowerCase(),r=Object.entries(t.attrs??{}).map(([s,i])=>i===true?` ${s}`:` ${s}="${xa(i)}"`).join("");return La.has(n)?`<${n}${r}>`:`<${n}${r}>${e??(t.children??[]).map(s=>ar(s)).join("")}</${n}>`}function ti(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function xa(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;")}var Ca=6e4,je=new Map;async function Pa(t){let e=t.credentials===void 0?void 0:Oa(t.credentials),n=v(t.locale),r=t.catalog?null:await Ha(n,e),s=t.catalog?lt(en(tn(t.catalog))):r?.catalog??null;return new at(n,s??lt(en({})),s!==null,false,e,r?.writeEnabled)}function Oa(t){let{projectid:e,key:n,writeGrant:r}=t??{};if(typeof e!="string"||!e||typeof n!="string"||!n)throw new ae("createRequestScope() was given credentials without both a project id and an API key. Pass both, or leave credentials out to send under the module-wide ones.");return Object.freeze({projectid:e,key:n,writeGrant:r})}function Ma(t){for(let n of Object.values(t.blocks??{}))He(n);for(let n of t.phrases??[])jt(n);let e=new at(v(t.locale),lt(en(tn(t.catalog??{}))),true,true);for(let n of Object.values(t.blocks??{}))e.recordRendered(n);return e}function Ba(){let t=P();return t instanceof at?t:void 0}function Ia(){je.clear();}var at=class{constructor(e,n,r,s=false,i=void 0,o=void 0){this.locale=e;this.catalog=n;this.available=r;this.fromSeed=s;this.keyWriteEnabled=o;this.phraseMisses=new Map;this.blockMisses=new Map;this.rendered=new Map;this.closing=null;this.view={catalog:()=>this.catalog,locale:()=>this.locale,miss:(e,n)=>{if(!(!this.available||this.closing)){if(this.fromSeed)return T.Translations.recordPageMiss(e,n);this.phraseMisses.set(`${e}\0${n}`,{category:e,phrase:n});}},fromSnapshot:()=>false};this.t=((e,...n)=>T.Translations.renderWith(this.view,e,n));Object.defineProperty(this,"credentials",{value:i,enumerable:false});}run(e){return yr(this,e)}enter(){mr(this);}seed(){let e=this.serverCollects(this.phraseMisses.size+this.blockMisses.size)&&this.mayWrite(),n={};for(let[s,i]of this.rendered){let o=i.shape==="phrase"?this.phraseMisses.has(`${i.category}\0${i.tokens[0]}`):this.blockMisses.has(`${i.category}\0${s}`),{content:a,...l}=i,c=this.catalog[i.category||"__uncategorized__"]?.[s],u=typeof c=="object"&&c!==null;n[s]=e&&o?{...l,collected:true}:u?l:{...i};}let r=[...this.phraseMisses.values()].map(({category:s,phrase:i})=>e?{category:s,phrase:i,collected:true}:{category:s,phrase:i});return {locale:this.locale,catalog:tn(this.catalog),blocks:tn(n),phrases:r}}serverCollects(e){let n=L.ssrTokenStrategy||"client";return this.credentials?.writeGrant?(n!=="client"&&tr(n),false):!this.credentials&&S.hasWriteGrant()?false:n==="server"||n==="auto"&&e<Kt}mayWrite(){return this.credentials?this.keyWriteEnabled===true:T.Translations.mayWrite()}sendsUnder(){return this.credentials??S.moduleCredentials()}recordRendered(e){this.rendered.set(e.customId,e);}misses(){return [...this.phraseMisses.values()]}recordBlock(e){if(!(!this.available||this.closing)){if(this.fromSeed){queueMicrotask(()=>{br(()=>Y(e));});return}this.blockMisses.set(`${e.category}\0${e.custom_id}`,e);}}close(){return this.closing??=this.flush(),this.closing}async flush(){let e=[...[...this.phraseMisses.values()].map(n=>({type:"phrase",phrase:n.phrase,category:n.category||null})),...[...this.blockMisses.values()].map(n=>({type:"content_block",custom_id:n.custom_id,category:n.category||null,content:n.content,label:n.label,phrases:n.tokens.map(r=>({phrase:r}))}))];if(e.length===0)return {status:true};if(!this.serverCollects(e.length))return {status:false,skipped:true,reason:"client-strategy"};if(!this.mayWrite())return {status:false,skipped:true,reason:"not-write-enabled"};try{let n=ye.get(),r=this.sendsUnder();for(let s=0;s<e.length;s+=n){let i=await S.createTranslatableItems(e.slice(s,s+n),{credentials:r});if(!i.status)return {status:!1,reason:"refused",errors:i.errors}}return {status:!0}}catch(n){return {status:false,reason:"failed",errors:[n]}}}};function Ha(t,e){let n=e??S.moduleCredentials(),r=`${n.projectid}\0${n.key}\0${n.writeGrant?"grant":""}\0${t}`,s=Date.now();for(let[a,l]of je)s-l.at>=Ca&&je.delete(a);let i=je.get(r);if(i)return i.catalog;let o=Fa(t,e).then(a=>(a===null&&je.delete(r),a));return je.set(r,{at:s,catalog:o}),o}async function Fa(t,e){try{let n=await S.getTranslations(t,{credentials:e??S.moduleCredentials()});return e||T.Translations.applyWriteEnabled(qt(n)),n.errors?null:{catalog:lt(en(nn(n.data)?n.data:{})),writeEnabled:qt(n)}}catch{return null}}function en(t){for(let e of Object.keys(t))nn(t[e])?t[e].__category__=e:delete t[e];return nn(t.__uncategorized__)||(t.__uncategorized__={__category__:"__uncategorized__",__symbol__:"__uncategorized__"}),t}function lt(t){if(nn(t)){for(let e of Object.values(t))lt(e);Object.freeze(t);}return t}function tn(t){return JSON.parse(JSON.stringify(t))}function nn(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var Pu=((t,...e)=>T.Translations.t(t,...e)),Ou=T.Translations.tSignal,Mu=()=>T.Translations.notifyNavigation(),Bu=()=>T.localeHeaders(),Iu=(t,e)=>T.renderServerMessage(t,e),Hu=t=>T.setWriteGrant(t);exports.CONTENT_BLOCK_MARKER_ATTR=X;exports.CONTENT_BLOCK_MARKER_ATTRS=_t;exports.CONTENT_BLOCK_MARKER_ATTR_LEGACY=On;exports.DEFAULT_SERVER_MESSAGE_CATEGORY=pt;exports.LEGACY_FORMATS=Jn;exports.LangsysApp=T;exports.LangsysAppAPI=S;exports.LangsysConfigurationError=ae;exports.LegacyFormatError=nt;exports.Logger=se;exports.PHRASE_MARKER_ATTR=Nt;exports.PHRASE_MARKER_ATTRS=At;exports.PHRASE_MARKER_ATTR_LEGACY=Pn;exports.Phrase=it;exports.RESOLVED_MARKER_ATTR=Te;exports.RESOLVED_MARKER_ATTRS=ce;exports.RESOLVED_MARKER_ATTR_LEGACY=Mn;exports.SNAPSHOT_FORMAT=mt;exports.SNAPSHOT_VERSION=mi;exports.SUPPORTED_LEGACY_FORMATS=tt;exports.SnapshotError=ee;exports.Translate=sr;exports.Translations=rt;exports.VAR_PARAM_ATTR=rs;exports.applyRendered=wa;exports.autoDiscovery=$e;exports.blockNodesOf=Gs;exports.buildSnapshot=yi;exports.canonicalSnapshotJson=yt;exports.canonicalizeLocale=v;exports.clearSharedCatalogs=Ia;exports.convertLegacyCall=Qo;exports.convertLegacyPluralForms=Yn;exports.convertLegacyValue=Gt;exports.createLegacyKeys=Qn;exports.createRequestScope=Pa;exports.createSignal=B;exports.currentRequestScope=Ba;exports.currentlyLoadedLocale=N;exports.defaultedArguments=wo;exports.derivePlaceholderNames=Kn;exports.encodeRichText=$n;exports.fillTemplate=gn;exports.findUnusedParamKeys=Jr;exports.generateCustomId=z;exports.generateLegacyCustomId=Bn;exports.getValue=ii;exports.interpolate=U;exports.isContentBlockKnown=re;exports.isEmpty=pe;exports.isICU=ne;exports.isPhraseMarked=fe;exports.isTranslationExcluded=ke;exports.legacyTokenizeElement=jn;exports.localeHeaders=Bu;exports.logger=k;exports.markupTokenValues=hs;exports.md5=ut;exports.md5Legacy=an;exports.normalizeMarkupPlaceholders=O;exports.notifyNavigation=Mu;exports.parseSnapshot=yn;exports.persist=li;exports.reconstitute=Vt;exports.registerBlock=Ta;exports.registerContentBlock=Y;exports.renderBlock=ya;exports.renderServerMessage=Iu;exports.resolveServerMessages=fi;exports.sTranslations=I;exports.scopeFromSeed=Ma;exports.serializeTree=va;exports.setPersistStorage=ai;exports.setRequestScopeStorage=di;exports.setTeardownSignal=Jo;exports.setWriteGrant=Hu;exports.snakeCase=Ne;exports.snapshotChecksum=mn;exports.stripSentinels=Je;exports.t=Pu;exports.tSignal=Ou;exports.templateMarkers=hi;exports.toServerMessage=Tr;exports.tokenizeElement=Vn;exports.tokenizeTree=ma;exports.warnUnregistered=ve;exports.warnUnrenderedBlock=ba;exports.writeEnabled=F;return exports;})({});