@rimori/playwright-testing 0.3.23-next.0 → 0.3.23-next.2

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.
Files changed (33) hide show
  1. package/dist/harness/__mfe_internal__rimori_mf_2_scenario_mf_2_host__loadShare___mf_0_rimori_mf_1_client__loadShare__.mjs.js +8 -0
  2. package/dist/harness/{index3.js → __mfe_internal__rimori_mf_2_scenario_mf_2_host__loadShare___mf_0_rimori_mf_1_react_mf_2_client__loadShare__.mjs.js} +42 -42
  3. package/dist/harness/__mfe_internal__rimori_mf_2_scenario_mf_2_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs.js +1 -0
  4. package/dist/harness/__mfe_internal__rimori_mf_2_scenario_mf_2_host__loadShare__react__loadShare__.mjs.js +9 -0
  5. package/dist/harness/__mfe_internal__rimori_mf_2_scenario_mf_2_host__loadShare__react__loadShare__.mjs_commonjs-proxy.js +1 -0
  6. package/dist/harness/__mfe_internal__rimori_mf_2_scenario_mf_2_host__loadShare__react_mf_1_jsx_mf_2_dev_mf_2_runtime__loadShare__.mjs.js +9 -0
  7. package/dist/harness/__mfe_internal__rimori_mf_2_scenario_mf_2_host__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.mjs.js +9 -0
  8. package/dist/harness/__mfe_internal__rimori_mf_2_scenario_mf_2_host__loadShare__react_mf_2_dom__loadShare__.mjs.js +9 -0
  9. package/dist/harness/__mfe_internal__rimori_mf_2_scenario_mf_2_host__loadShare__react_mf_2_dom__loadShare__.mjs_commonjs-proxy.js +1 -0
  10. package/dist/harness/__mfe_internal__rimori_mf_2_scenario_mf_2_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs.js +25 -0
  11. package/dist/harness/__mfe_internal__rimori_mf_2_scenario_mf_2_host__loadShare__zod__loadShare__.mjs.js +1 -0
  12. package/dist/harness/hostInit.js +1 -1
  13. package/dist/harness/index.html +1 -12
  14. package/dist/harness/index.js +1 -25
  15. package/dist/harness/localSharedImportMap.js +1 -1
  16. package/dist/harness/mf-entry-bootstrap-0.js +13 -0
  17. package/dist/harness/virtual_mf-REMOTE_ENTRY_ID___mfe_internal__rimori-scenario-host__remoteEntry-_hash_.js +5 -6
  18. package/package.json +5 -5
  19. package/dist/harness/__mfe_internal__rimori_mf_2_scenario_mf_2_host__loadShare___mf_0_rimori_mf_1_client__loadShare__.js.js +0 -1
  20. package/dist/harness/__mfe_internal__rimori_mf_2_scenario_mf_2_host__loadShare___mf_0_rimori_mf_1_react_mf_2_client__loadShare__.js.js +0 -1
  21. package/dist/harness/__mfe_internal__rimori_mf_2_scenario_mf_2_host__loadShare__react__loadShare__.js.js +0 -1
  22. package/dist/harness/__mfe_internal__rimori_mf_2_scenario_mf_2_host__loadShare__react__loadShare__.js_commonjs-proxy.js +0 -1
  23. package/dist/harness/__mfe_internal__rimori_mf_2_scenario_mf_2_host__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.js.js +0 -1
  24. package/dist/harness/__mfe_internal__rimori_mf_2_scenario_mf_2_host__loadShare__react_mf_2_dom__loadShare__.js.js +0 -1
  25. package/dist/harness/__mfe_internal__rimori_mf_2_scenario_mf_2_host__loadShare__react_mf_2_dom__loadShare__.js_commonjs-proxy.js +0 -1
  26. package/dist/harness/html2canvas.esm.js +0 -22
  27. package/dist/harness/index2.js +0 -8
  28. package/dist/harness/index4.js +0 -1
  29. package/dist/harness/index5.js +0 -9
  30. package/dist/harness/index6.js +0 -9
  31. package/dist/harness/index7.js +0 -1
  32. package/dist/harness/jsx-dev-runtime.js +0 -9
  33. package/dist/harness/jsx-runtime.js +0 -9
@@ -1,8 +0,0 @@
1
- import{_ as Fe}from"./preload-helper.js";class L{listeners=new Map;responseResolvers=new Map;static instance=null;debugEnabled=!1;evName="";generatedIds=new Map;cleanupInterval=null;constructor(){this.startIdCleanup()}static create(e){const t=new L;return e&&(t.evName=e),t}static getInstance(e){return L.instance||(L.instance=new L,L.instance.on("global.system.requestDebug",()=>{L.instance.debugEnabled=!0,console.log(`[${L.instance.evName}] Debug mode enabled. Make sure debugging messages are enabled in the browser console.`)})),e&&L.instance.evName===""&&(L.instance.evName=e),L.instance}startIdCleanup(){this.cleanupInterval=setInterval(()=>{const t=Date.now()-6e4;for(const[s,i]of this.generatedIds.entries())i<t&&this.generatedIds.delete(s)},1e4)}generateUniqueId(){const e=Date.now(),t=e-6e4,s=Math.floor(Math.random()*1e10),i=this.generatedIds.get(s);return i&&i>t?this.generateUniqueId():(this.generatedIds.set(s,e),s)}createEvent(e,t,s,i,n){return{eventId:i||this.generateUniqueId(),timestamp:new Date().toISOString(),sender:e,topic:t,data:s,debug:this.debugEnabled,ai_session_token:n}}emit(e,t,s,i,n){this.emitInternal(e,t,s||{},i,!1,n)}emitInternal(e,t,s,i,n=!1,o){if(!this.validateTopic(t)){this.logAndThrowError(!1,"Invalid topic: "+t);return}const a=this.createEvent(e,t,s,i,o),l=this.getMatchingHandlers(a.topic);l.forEach(c=>{c.ignoreSender&&c.ignoreSender.includes(e)||c.handler(a)}),this.logIfDebug("Emitting event to "+t,a),l.size===0&&this.logAndThrowError(!1,"No handlers found for topic: "+t),i&&this.responseResolvers.has(i)&&!n&&(this.responseResolvers.get(i)(a),this.responseResolvers.delete(i))}on(e,t,s=[]){const i=this.toArray(e).map(n=>{this.logIfDebug("Subscribing to "+n,{ignoreSender:s}),this.validateTopic(n)||this.logAndThrowError(!0,"Invalid topic: "+n),this.listeners.has(n)||this.listeners.set(n,new Set);const o=this.generateUniqueId(),a=[],l=c=>{if(!a.some(h=>h.eventId===c.eventId&&h.sender===c.sender))return a.push({eventId:c.eventId,sender:c.sender}),a.length>100&&a.shift(),t(c)};return this.listeners.get(n).add({id:o,handler:l,ignoreSender:s}),this.logIfDebug("Subscribed to "+n,{listenerId:o,ignoreSender:s}),btoa(JSON.stringify({topic:n,id:o}))});return{off:()=>this.off(i)}}respond(e,t,s){const n=(Array.isArray(t)?t:[t]).map(o=>{const a=[],l=o.startsWith("self.")?[]:[e],c=this.on(o,async h=>{if(a.includes(h.eventId))return;a.push(h.eventId),a.length>100&&a.shift();const u=typeof s=="function"?await s(h):s;this.emit(e,o,u,h.eventId)},l);return this.logIfDebug("Added respond listener "+e+" to topic "+o,{listener:c,sender:e}),{off:()=>c.off()}});return{off:()=>n.forEach(o=>o.off())}}once(e,t){if(!this.validateTopic(e)){this.logAndThrowError(!1,"Invalid topic: "+e);return}let s;const i=n=>{t(n),s?.off()};s=this.on(e,i),this.logIfDebug("Added once listener "+e,{listener:s,topic:e})}off(e){this.toArray(e).forEach(t=>{const{topic:s,id:i}=JSON.parse(atob(t)),n=this.listeners.get(s)||new Set;n.forEach(o=>{o.id===Number(i)&&(n.delete(o),this.logIfDebug("Removed listener "+t,{topic:s,listenerId:i}))})})}toArray(e){return Array.isArray(e)?e:[e]}async request(e,t,s,i){this.validateTopic(t)||this.logAndThrowError(!0,"Invalid topic: "+t);const n=this.createEvent(e,t,s||{},void 0,i);return this.logIfDebug("Requesting data from "+t,{event:n}),new Promise(o=>{this.responseResolvers.set(n.eventId,a=>o(a)),this.emitInternal(e,t,s||{},n.eventId,!0,i)})}getMatchingHandlers(e){const t=this.listeners.get(e)||new Set,s=[...this.listeners.entries()].filter(([i])=>i.endsWith("*")&&e.startsWith(i.slice(0,-1))).flatMap(([i,n])=>[...n]);return new Set([...t,...s])}validateTopic(e){const t=e.split("."),[s,i,n]=t;if(t.length!==3)return t.length===1&&s==="*"||t.length===2&&s!=="*"&&i==="*"?!0:(this.logAndThrowError(!1,"Event type must have 3 parts separated by dots. Received: "+e),!1);if(n==="*")return!0;const o=["request","create","update","delete","trigger"];return o.some(a=>n.startsWith(a))?!0:(this.logAndThrowError(!1,"Invalid event topic name. The action: "+n+". Must be or start with one of: "+o.join(", ")),!1)}logIfDebug(...e){this.debugEnabled&&console.debug(`[${this.evName}] `+e[0],...e.slice(1))}destroy(){this.listeners.clear(),this.responseResolvers.clear(),this.cleanupInterval&&(clearInterval(this.cleanupInterval),this.cleanupInterval=null),this.generatedIds.clear()}logAndThrowError(e,...t){const s=`[${this.evName}] `+t[0];if(console.error(s,...t.slice(1)),e)throw new Error(s)}}const P=L.getInstance();class Ue{supabase;rimoriClient;constructor(e,t){this.supabase=e,this.rimoriClient=t}async getNew(e){const t=await this.rimoriClient.runtime.fetchBackend("/shared-content/generate",{method:"POST",body:JSON.stringify({tableName:e.table,skillType:e.skillType,placeholders:e.placeholders,filter:e.filter,customFields:e.customFields,tool:e.tool,options:{skipDbSave:e.skipDbSave,isPrivate:e.isPrivate,ignoreSkillLevel:e.ignoreSkillLevel}})});if(!t.ok)throw new Error(`Failed to generate shared content: ${t.statusText}`);return await t.json()}async searchByTopic(e,t,s=10){const i=await this.rimoriClient.runtime.fetchBackend("/shared-content/get-by-topic",{method:"POST",body:JSON.stringify({tableName:e,limit:s,filter:{title:{filterType:"rag",value:t}}})});if(!i.ok)throw new Error(`Failed to search shared content: ${i.statusText}`);return await i.json()}async getBookmarked(e,t=30){const s=this.getTableName(e),i=this.getCompletedTableName(e),{data:n,error:o}=await this.supabase.from(s).select(`*, completed:${i}!inner(*)`).eq("completed.bookmarked",!0).limit(t);if(o)throw console.error("Error fetching bookmarked content:",o),new Error("Error fetching bookmarked content");return n||[]}async getOngoing(e,t=30){const s=this.getTableName(e),i=this.getCompletedTableName(e),{data:n,error:o}=await this.supabase.from(s).select(`*, completed:${i}!inner(*)`).eq("completed.state","ongoing").limit(t);if(o)throw console.error("Error fetching ongoing content:",o),new Error("Error fetching ongoing content");return n||[]}async getCompleted(e,t=30){const s=this.getTableName(e),i=this.getCompletedTableName(e),{data:n,error:o}=await this.supabase.from(s).select(`*, completed:${i}!inner(*)`).eq("completed.state","completed").limit(t);if(o)throw console.error("Error fetching completed content:",o),new Error("Error fetching completed content");return n||[]}async complete(e,t){const s=this.getCompletedTableName(e),{error:i}=await this.supabase.from(s).upsert({content_id:t,state:"completed"},{onConflict:"content_id,user_id"});if(i)throw console.error("Error completing shared content:",i),new Error("Error completing shared content")}async updateState(e,t,s){const i=this.getCompletedTableName(e),{error:n}=await this.supabase.from(i).upsert({content_id:t,state:s},{onConflict:"content_id,user_id"});if(n)throw console.error("Error updating content state:",n),new Error("Error updating content state")}async bookmark(e,t,s){const i=this.getCompletedTableName(e),{error:n}=await this.supabase.from(i).upsert({content_id:t,bookmarked:s},{onConflict:"content_id,user_id"});if(n)throw console.error("Error bookmarking content:",n),new Error("Error bookmarking content")}async react(e,t,s){const i=this.getCompletedTableName(e),{error:n}=await this.supabase.from(i).upsert({content_id:t,reaction:s},{onConflict:"content_id,user_id"});if(n)throw console.error("Error reacting to content:",n),new Error("Error reacting to content")}async get(e,t){const s=this.getTableName(e),{data:i,error:n}=await this.supabase.from(s).select("*").eq("id",t).single();if(n)throw console.error("Error fetching shared content:",n),new Error("Error fetching shared content");return i}async getAll(e,t=100){const s=this.getTableName(e),{data:i,error:n}=await this.supabase.from(s).select("*").limit(t);if(n)throw console.error("Error fetching all shared content:",n),new Error("Error fetching all shared content");return i||[]}async create(e,t){const s=this.getTableName(e),{data:i,error:n}=await this.supabase.from(s).insert(t).select().single();if(n)throw console.error("Error creating shared content:",n),new Error("Error creating shared content");return i}async update(e,t,s){const i=await this.rimoriClient.runtime.fetchBackend("/shared-content/update",{method:"POST",body:JSON.stringify({tableName:e,contentId:t,updates:s})});if(!i.ok)throw console.error("Error updating shared content:",i.statusText),new Error(`Failed to update shared content: ${i.statusText}`);return await i.json()}async validate(e,t){const s=await this.rimoriClient.runtime.fetchBackend("/shared-content/validate",{method:"POST",body:JSON.stringify({tableName:e,contentId:t})});if(!s.ok)throw console.error("Error validating shared content:",s.statusText),new Error(`Failed to validate shared content: ${s.statusText}`);return await s.json()}async remove(e,t){const s=this.getTableName(e),{error:i}=await this.supabase.from(s).delete().eq("id",t);if(i)throw console.error("Error deleting shared content:",i),new Error("Error deleting shared content")}getCompletedTableName(e){return this.getTableName(e)+"_completed"}getTableName(e){return`${this.rimoriClient.plugin.pluginId}_sc_${e}`}}var Be=class extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}},qe=class{constructor(r){var e,t,s;this.shouldThrowOnError=!1,this.method=r.method,this.url=r.url,this.headers=new Headers(r.headers),this.schema=r.schema,this.body=r.body,this.shouldThrowOnError=(e=r.shouldThrowOnError)!==null&&e!==void 0?e:!1,this.signal=r.signal,this.isMaybeSingle=(t=r.isMaybeSingle)!==null&&t!==void 0?t:!1,this.urlLengthLimit=(s=r.urlLengthLimit)!==null&&s!==void 0?s:8e3,r.fetch?this.fetch=r.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(r,e){return this.headers=new Headers(this.headers),this.headers.set(r,e),this}then(r,e){var t=this;this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");const s=this.fetch;let i=s(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async n=>{let o=null,a=null,l=null,c=n.status,h=n.statusText;if(n.ok){var u,g;if(t.method!=="HEAD"){var d;const m=await n.text();m===""||(t.headers.get("Accept")==="text/csv"||t.headers.get("Accept")&&(!((d=t.headers.get("Accept"))===null||d===void 0)&&d.includes("application/vnd.pgrst.plan+text"))?a=m:a=JSON.parse(m))}const f=(u=t.headers.get("Prefer"))===null||u===void 0?void 0:u.match(/count=(exact|planned|estimated)/),y=(g=n.headers.get("content-range"))===null||g===void 0?void 0:g.split("/");f&&y&&y.length>1&&(l=parseInt(y[1])),t.isMaybeSingle&&Array.isArray(a)&&(a.length>1?(o={code:"PGRST116",details:`Results contain ${a.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},a=null,l=null,c=406,h="Not Acceptable"):a.length===1?a=a[0]:a=null)}else{const f=await n.text();try{o=JSON.parse(f),Array.isArray(o)&&n.status===404&&(a=[],o=null,c=200,h="OK")}catch{n.status===404&&f===""?(c=204,h="No Content"):o={message:f}}if(o&&t.shouldThrowOnError)throw new Be(o)}return{error:o,data:a,count:l,status:c,statusText:h}});return this.shouldThrowOnError||(i=i.catch(n=>{var o;let a="",l="",c="";const h=n?.cause;if(h){var u,g,d,f;const w=(u=h?.message)!==null&&u!==void 0?u:"",b=(g=h?.code)!==null&&g!==void 0?g:"";a=`${(d=n?.name)!==null&&d!==void 0?d:"FetchError"}: ${n?.message}`,a+=`
2
-
3
- Caused by: ${(f=h?.name)!==null&&f!==void 0?f:"Error"}: ${w}`,b&&(a+=` (${b})`),h?.stack&&(a+=`
4
- ${h.stack}`)}else{var y;a=(y=n?.stack)!==null&&y!==void 0?y:""}const m=this.url.toString().length;return n?.name==="AbortError"||n?.code==="ABORT_ERR"?(c="",l="Request was aborted (timeout or manual cancellation)",m>this.urlLengthLimit&&(l+=`. Note: Your request URL is ${m} characters, which may exceed server limits. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [many IDs])), consider using an RPC function to pass values server-side.`)):(h?.name==="HeadersOverflowError"||h?.code==="UND_ERR_HEADERS_OVERFLOW")&&(c="",l="HTTP headers exceeded server limits (typically 16KB)",m>this.urlLengthLimit&&(l+=`. Your request URL is ${m} characters. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [200+ IDs])), consider using an RPC function instead.`)),{error:{message:`${(o=n?.name)!==null&&o!==void 0?o:"FetchError"}: ${n?.message}`,details:a,hint:l,code:c},data:null,count:null,status:0,statusText:""}})),i.then(r,e)}returns(){return this}overrideTypes(){return this}},Ke=class extends qe{select(r){let e=!1;const t=(r??"*").split("").map(s=>/\s/.test(s)&&!e?"":(s==='"'&&(e=!e),s)).join("");return this.url.searchParams.set("select",t),this.headers.append("Prefer","return=representation"),this}order(r,{ascending:e=!0,nullsFirst:t,foreignTable:s,referencedTable:i=s}={}){const n=i?`${i}.order`:"order",o=this.url.searchParams.get(n);return this.url.searchParams.set(n,`${o?`${o},`:""}${r}.${e?"asc":"desc"}${t===void 0?"":t?".nullsfirst":".nullslast"}`),this}limit(r,{foreignTable:e,referencedTable:t=e}={}){const s=typeof t>"u"?"limit":`${t}.limit`;return this.url.searchParams.set(s,`${r}`),this}range(r,e,{foreignTable:t,referencedTable:s=t}={}){const i=typeof s>"u"?"offset":`${s}.offset`,n=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(i,`${r}`),this.url.searchParams.set(n,`${e-r+1}`),this}abortSignal(r){return this.signal=r,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:r=!1,verbose:e=!1,settings:t=!1,buffers:s=!1,wal:i=!1,format:n="text"}={}){var o;const a=[r?"analyze":null,e?"verbose":null,t?"settings":null,s?"buffers":null,i?"wal":null].filter(Boolean).join("|"),l=(o=this.headers.get("Accept"))!==null&&o!==void 0?o:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${n}; for="${l}"; options=${a};`),n==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(r){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${r}`),this}};const ge=new RegExp("[,()]");var B=class extends Ke{eq(r,e){return this.url.searchParams.append(r,`eq.${e}`),this}neq(r,e){return this.url.searchParams.append(r,`neq.${e}`),this}gt(r,e){return this.url.searchParams.append(r,`gt.${e}`),this}gte(r,e){return this.url.searchParams.append(r,`gte.${e}`),this}lt(r,e){return this.url.searchParams.append(r,`lt.${e}`),this}lte(r,e){return this.url.searchParams.append(r,`lte.${e}`),this}like(r,e){return this.url.searchParams.append(r,`like.${e}`),this}likeAllOf(r,e){return this.url.searchParams.append(r,`like(all).{${e.join(",")}}`),this}likeAnyOf(r,e){return this.url.searchParams.append(r,`like(any).{${e.join(",")}}`),this}ilike(r,e){return this.url.searchParams.append(r,`ilike.${e}`),this}ilikeAllOf(r,e){return this.url.searchParams.append(r,`ilike(all).{${e.join(",")}}`),this}ilikeAnyOf(r,e){return this.url.searchParams.append(r,`ilike(any).{${e.join(",")}}`),this}regexMatch(r,e){return this.url.searchParams.append(r,`match.${e}`),this}regexIMatch(r,e){return this.url.searchParams.append(r,`imatch.${e}`),this}is(r,e){return this.url.searchParams.append(r,`is.${e}`),this}isDistinct(r,e){return this.url.searchParams.append(r,`isdistinct.${e}`),this}in(r,e){const t=Array.from(new Set(e)).map(s=>typeof s=="string"&&ge.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(r,`in.(${t})`),this}notIn(r,e){const t=Array.from(new Set(e)).map(s=>typeof s=="string"&&ge.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(r,`not.in.(${t})`),this}contains(r,e){return typeof e=="string"?this.url.searchParams.append(r,`cs.${e}`):Array.isArray(e)?this.url.searchParams.append(r,`cs.{${e.join(",")}}`):this.url.searchParams.append(r,`cs.${JSON.stringify(e)}`),this}containedBy(r,e){return typeof e=="string"?this.url.searchParams.append(r,`cd.${e}`):Array.isArray(e)?this.url.searchParams.append(r,`cd.{${e.join(",")}}`):this.url.searchParams.append(r,`cd.${JSON.stringify(e)}`),this}rangeGt(r,e){return this.url.searchParams.append(r,`sr.${e}`),this}rangeGte(r,e){return this.url.searchParams.append(r,`nxl.${e}`),this}rangeLt(r,e){return this.url.searchParams.append(r,`sl.${e}`),this}rangeLte(r,e){return this.url.searchParams.append(r,`nxr.${e}`),this}rangeAdjacent(r,e){return this.url.searchParams.append(r,`adj.${e}`),this}overlaps(r,e){return typeof e=="string"?this.url.searchParams.append(r,`ov.${e}`):this.url.searchParams.append(r,`ov.{${e.join(",")}}`),this}textSearch(r,e,{config:t,type:s}={}){let i="";s==="plain"?i="pl":s==="phrase"?i="ph":s==="websearch"&&(i="w");const n=t===void 0?"":`(${t})`;return this.url.searchParams.append(r,`${i}fts${n}.${e}`),this}match(r){return Object.entries(r).filter(([e,t])=>t!==void 0).forEach(([e,t])=>{this.url.searchParams.append(e,`eq.${t}`)}),this}not(r,e,t){return this.url.searchParams.append(r,`not.${e}.${t}`),this}or(r,{foreignTable:e,referencedTable:t=e}={}){const s=t?`${t}.or`:"or";return this.url.searchParams.append(s,`(${r})`),this}filter(r,e,t){return this.url.searchParams.append(r,`${e}.${t}`),this}},ze=class{constructor(r,{headers:e={},schema:t,fetch:s,urlLengthLimit:i=8e3}){this.url=r,this.headers=new Headers(e),this.schema=t,this.fetch=s,this.urlLengthLimit=i}cloneRequestState(){return{url:new URL(this.url.toString()),headers:new Headers(this.headers)}}select(r,e){const{head:t=!1,count:s}=e??{},i=t?"HEAD":"GET";let n=!1;const o=(r??"*").split("").map(c=>/\s/.test(c)&&!n?"":(c==='"'&&(n=!n),c)).join(""),{url:a,headers:l}=this.cloneRequestState();return a.searchParams.set("select",o),s&&l.append("Prefer",`count=${s}`),new B({method:i,url:a,headers:l,schema:this.schema,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}insert(r,{count:e,defaultToNull:t=!0}={}){var s;const i="POST",{url:n,headers:o}=this.cloneRequestState();if(e&&o.append("Prefer",`count=${e}`),t||o.append("Prefer","missing=default"),Array.isArray(r)){const a=r.reduce((l,c)=>l.concat(Object.keys(c)),[]);if(a.length>0){const l=[...new Set(a)].map(c=>`"${c}"`);n.searchParams.set("columns",l.join(","))}}return new B({method:i,url:n,headers:o,schema:this.schema,body:r,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch,urlLengthLimit:this.urlLengthLimit})}upsert(r,{onConflict:e,ignoreDuplicates:t=!1,count:s,defaultToNull:i=!0}={}){var n;const o="POST",{url:a,headers:l}=this.cloneRequestState();if(l.append("Prefer",`resolution=${t?"ignore":"merge"}-duplicates`),e!==void 0&&a.searchParams.set("on_conflict",e),s&&l.append("Prefer",`count=${s}`),i||l.append("Prefer","missing=default"),Array.isArray(r)){const c=r.reduce((h,u)=>h.concat(Object.keys(u)),[]);if(c.length>0){const h=[...new Set(c)].map(u=>`"${u}"`);a.searchParams.set("columns",h.join(","))}}return new B({method:o,url:a,headers:l,schema:this.schema,body:r,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch,urlLengthLimit:this.urlLengthLimit})}update(r,{count:e}={}){var t;const s="PATCH",{url:i,headers:n}=this.cloneRequestState();return e&&n.append("Prefer",`count=${e}`),new B({method:s,url:i,headers:n,schema:this.schema,body:r,fetch:(t=this.fetch)!==null&&t!==void 0?t:fetch,urlLengthLimit:this.urlLengthLimit})}delete({count:r}={}){var e;const t="DELETE",{url:s,headers:i}=this.cloneRequestState();return r&&i.append("Prefer",`count=${r}`),new B({method:t,url:s,headers:i,schema:this.schema,fetch:(e=this.fetch)!==null&&e!==void 0?e:fetch,urlLengthLimit:this.urlLengthLimit})}};function Q(r){"@babel/helpers - typeof";return Q=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Q(r)}function He(r,e){if(Q(r)!="object"||!r)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var s=t.call(r,e);if(Q(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function Ve(r){var e=He(r,"string");return Q(e)=="symbol"?e:e+""}function Je(r,e,t){return(e=Ve(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function pe(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(r);e&&(s=s.filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable})),t.push.apply(t,s)}return t}function X(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?pe(Object(t),!0).forEach(function(s){Je(r,s,t[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):pe(Object(t)).forEach(function(s){Object.defineProperty(r,s,Object.getOwnPropertyDescriptor(t,s))})}return r}var Te=class Ne{constructor(e,{headers:t={},schema:s,fetch:i,timeout:n,urlLengthLimit:o=8e3}={}){this.url=e,this.headers=new Headers(t),this.schemaName=s,this.urlLengthLimit=o;const a=i??globalThis.fetch;n!==void 0&&n>0?this.fetch=(l,c)=>{const h=new AbortController,u=setTimeout(()=>h.abort(),n),g=c?.signal;if(g){if(g.aborted)return clearTimeout(u),a(l,c);const d=()=>{clearTimeout(u),h.abort()};return g.addEventListener("abort",d,{once:!0}),a(l,X(X({},c),{},{signal:h.signal})).finally(()=>{clearTimeout(u),g.removeEventListener("abort",d)})}return a(l,X(X({},c),{},{signal:h.signal})).finally(()=>clearTimeout(u))}:this.fetch=a}from(e){if(!e||typeof e!="string"||e.trim()==="")throw new Error("Invalid relation name: relation must be a non-empty string.");return new ze(new URL(`${this.url}/${e}`),{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}schema(e){return new Ne(this.url,{headers:this.headers,schema:e,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}rpc(e,t={},{head:s=!1,get:i=!1,count:n}={}){var o;let a;const l=new URL(`${this.url}/rpc/${e}`);let c;const h=d=>d!==null&&typeof d=="object"&&(!Array.isArray(d)||d.some(h)),u=s&&Object.values(t).some(h);u?(a="POST",c=t):s||i?(a=s?"HEAD":"GET",Object.entries(t).filter(([d,f])=>f!==void 0).map(([d,f])=>[d,Array.isArray(f)?`{${f.join(",")}}`:`${f}`]).forEach(([d,f])=>{l.searchParams.append(d,f)})):(a="POST",c=t);const g=new Headers(this.headers);return u?g.set("Prefer",n?`count=${n},return=minimal`:"return=minimal"):n&&g.set("Prefer",`count=${n}`),new B({method:a,url:l,headers:g,schema:this.schemaName,body:c,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch,urlLengthLimit:this.urlLengthLimit})}};class me{pluginId;port=null;queryParams={};supabase=null;rimoriInfo=null;isMessageChannelReady=!1;pendingRequests=[];updateCallbacks=new Set;constructor(e,t){this.pluginId=e,this.getClient=this.getClient.bind(this),!t&&this.initMessageChannel(typeof WorkerGlobalScope<"u")}initMessageChannel(e=!1){const t=s=>{const{type:i,pluginId:n,queryParams:o,rimoriInfo:a}=s.data||{},[l]=s.ports||[];i!=="rimori:init"||!l||n!==this.pluginId||(this.queryParams=o||{},this.port=l,a&&(this.rimoriInfo=a,this.supabase=this.getSupabase(a.url,a.key,a.token)),this.port.onmessage=({data:c})=>{const{event:h,type:u,eventId:g,response:d,error:f}=c||{};if(u==="response"&&g)P.emit(this.pluginId,d.topic,d.data,g);else if(u==="error"&&g)P.emit(this.pluginId,"error",{error:f},g);else if(h){const{topic:y,sender:m,data:w,eventId:b,ai_session_token:T}=h;m!==this.pluginId&&P.emit(m,y,w,b,T)}},P.on("*",c=>{c.sender===this.pluginId&&!c.topic.startsWith("self.")&&this.port?.postMessage({event:c})}),P.on(`${this.pluginId}.supabase.triggerUpdate`,c=>{this.handleRimoriInfoUpdate(c.data)}),this.isMessageChannelReady=!0,this.pendingRequests.forEach(c=>c()),this.pendingRequests=[])};e?self.onmessage=t:window.addEventListener("message",t),this.sendHello(e),P.on("self.rimori.triggerInitFinished",()=>{this.sendFinishedInit(e)})}sendHello(e=!1){try{const t={type:"rimori:hello",pluginId:this.pluginId};e?self.postMessage(t):window.parent.postMessage(t,"*")}catch(t){console.error("[PluginController] Error sending hello:",t)}}sendFinishedInit(e=!1){try{const t={type:"rimori:acknowledged",pluginId:this.pluginId};e?self.postMessage(t):window.parent.postMessage(t,"*")}catch(t){console.error("[PluginController] Error sending finished init:",t)}}getQueryParam(e){return this.queryParams[e]||null}getSupabase(e,t,s){return new Te(`${e}/rest/v1`,{schema:this.rimoriInfo?.dbSchema,headers:{apikey:t,Authorization:`Bearer ${s}`,"plugin-id":this.pluginId}})}async getClient(){if(this.supabase&&this.rimoriInfo&&this.rimoriInfo.expiration>new Date)return{supabase:this.supabase,info:this.rimoriInfo};if(!this.isMessageChannelReady)return new Promise(e=>{this.pendingRequests.push(async()=>{const t=await this.getClient();e(t)})});if(this.rimoriInfo&&this.supabase)return{supabase:this.supabase,info:this.rimoriInfo};if(!this.rimoriInfo)if(typeof WorkerGlobalScope<"u"){const e=Math.floor(Math.random()*1e9),t={event:{timestamp:new Date().toISOString(),eventId:e,sender:this.pluginId,topic:"global.supabase.requestAccess",data:{},debug:!1}};return new Promise(s=>{const i=self.onmessage;self.onmessage=n=>{n.data?.topic==="global.supabase.requestAccess"&&n.data?.eventId===e?(this.rimoriInfo=n.data.data,this.supabase=this.getSupabase(this.rimoriInfo.url,this.rimoriInfo.key,this.rimoriInfo.token),self.onmessage=i,s({supabase:this.supabase,info:this.rimoriInfo})):i&&i.call(self,n)},self.postMessage(t)})}else{const{data:e}=await P.request(this.pluginId,"global.supabase.requestAccess");this.rimoriInfo=e,this.supabase=this.getSupabase(this.rimoriInfo.url,this.rimoriInfo.key,this.rimoriInfo.token)}return{supabase:this.supabase,info:this.rimoriInfo}}handleRimoriInfoUpdate(e){JSON.stringify(this.rimoriInfo)!==JSON.stringify(e)&&(this.rimoriInfo=e,this.supabase=this.getSupabase(e.url,e.key,e.token),this.updateCallbacks.forEach(t=>{try{t(e)}catch(s){console.error("[RimoriCommunicationHandler] Error in update callback:",s)}}))}onUpdate(e){return this.updateCallbacks.add(e),()=>{this.updateCallbacks.delete(e)}}fetchBackend(e,t={}){if(!this.rimoriInfo)throw new Error(`[CommunicationHandler:${this.pluginId}] fetchBackend called before rimoriInfo was initialized`);const{token:s,backendUrl:i}=this.rimoriInfo,n={};typeof t.body=="string"&&(n["Content-Type"]="application/json");const o={...n,...t.headers,Authorization:`Bearer ${s}`,"plugin-id":this.pluginId};return fetch(i+e,{...t,headers:o})}}let We=class J{static instance;isProduction;logs=[];logIdCounter=0;originalConsole;mousePosition=null;constructor(e,t){this.isProduction=this.validateIsProduction(t),this.originalConsole={log:console.log,info:console.info,warn:console.warn,error:console.error,debug:console.debug},this.overrideConsoleMethods(),this.trackMousePosition(),this.exposeToDevTools(),this.setupNavigationClearing(),e.event.respond("logging.requestPluginLogs",async()=>{this.addLogEntry(await this.createLogEntry("info","Screenshot capture",void 0,!0));const s={logs:this.logs,pluginId:e.plugin.pluginId,timestamp:new Date().toISOString()};return this.logs=[],this.logIdCounter=0,s})}static getInstance(e,t){return J.instance||(J.instance=new J(e,t)),J.instance}validateIsProduction(e){return e!==void 0?e:typeof window<"u"&&window.location.href?!window.location.href.includes("localhost"):!0}exposeToDevTools(){typeof window<"u"&&(window.getRimoriLogs=()=>this.logs)}setupNavigationClearing(){if(typeof window>"u"||typeof history>"u")return;window.addEventListener("popstate",()=>this.logs=[]);const e=history.pushState,t=history.replaceState;history.pushState=(...n)=>{e.apply(history,n),this.logs=[]},history.replaceState=(...n)=>{t.apply(history,n),this.logs=[]};let s=window.location.href;setInterval(()=>{window.location.href!==s&&(s=window.location.href,this.logs=[])},100),window.addEventListener("hashchange",()=>this.logs=[])}overrideConsoleMethods(){console.log=(...e)=>{const{location:t,style:s}=this.getCallerLocation();this.originalConsole.log(t,s,...e),this.handleConsoleCall("info",e)},console.info=(...e)=>{const{location:t,style:s}=this.getCallerLocation();this.originalConsole.info(t,s,...e),this.handleConsoleCall("info",e)},console.warn=(...e)=>{const{location:t,style:s}=this.getCallerLocation();this.originalConsole.warn(t,s,...e),this.handleConsoleCall("warn",e)},console.error=(...e)=>{const{location:t,style:s}=this.getCallerLocation();this.originalConsole.error(t,s,...e),this.handleConsoleCall("error",e)},console.debug=(...e)=>{const{location:t,style:s}=this.getCallerLocation();this.originalConsole.debug(t,s,...e),this.handleConsoleCall("debug",e)}}getCallerLocation(){const e={location:"",style:""},t="color: #0063A2; font-weight: bold;";if(this.isProduction)return e;try{const s=new Error().stack;if(!s)return e;const n=s.split(`
5
- `)[3];if(!n)return e;const o=n.match(/(?:at\s+.*?\s+\()?([^/\\(]+\.(?:ts|tsx|js|jsx)):(\d+):(\d+)\)?/);if(o){const[,l,c]=o;return{style:t,location:`%c[${l}:${c}]`}}const a=n.match(/([^/\\]+\.(?:ts|tsx|js|jsx))/);return a?{style:t,location:`%c[${a[1]}]`}:e}catch{return e}}trackMousePosition(){if(typeof window<"u"){const e=t=>{this.mousePosition={x:t.clientX,y:t.clientY,timestamp:new Date().toISOString()}};window.addEventListener("mousemove",e),window.addEventListener("click",e)}}async handleConsoleCall(e,t){if(this.isProduction&&(e==="debug"||e==="info"))return;const s=t.map(o=>{if(typeof o!="object")return o;try{return JSON.stringify(o)}catch(a){return"Error adding object to log: "+a.message+" "+String(o)}}).join(" "),i=t.length>1?t.slice(1):void 0,n=await this.createLogEntry(e,s,i);this.addLogEntry(n)}getBrowserInfo(){return{userAgent:navigator.userAgent,language:navigator.language,cookieEnabled:navigator.cookieEnabled,onLine:navigator.onLine,screenResolution:`${screen.width}x${screen.height}`,windowSize:`${window.innerWidth}x${window.innerHeight}`,timestamp:new Date().toISOString()}}async captureScreenshot(){if(typeof window>"u"||typeof document>"u")return null;try{const e=(await Fe(async()=>{const{default:i}=await import("./html2canvas.esm.js");return{default:i}},[])).default;return(await e(document.body)).toDataURL("image/png")}catch{return null}}async createLogEntry(e,t,s,i){const n={};return typeof window>"u"||typeof document>"u"?{id:`log_${++this.logIdCounter}_${Date.now()}`,timestamp:new Date().toISOString(),level:e,message:t,data:s}:(n.url=window.location.href,n.browserInfo=this.getBrowserInfo(),n.userAgent=n.browserInfo.userAgent,(e==="error"||e==="warn"||i)&&(n.screenshot=await this.captureScreenshot()||void 0,n.mousePosition=this.mousePosition||void 0),{id:`log_${++this.logIdCounter}_${Date.now()}`,timestamp:new Date().toISOString(),level:e,message:t,data:s,context:n})}addLogEntry(e){this.logs.push(e),this.logs.length>1e3&&(this.logs=this.logs.slice(-1e3))}};var re={};const p=r=>typeof r=="string",V=()=>{let r,e;const t=new Promise((s,i)=>{r=s,e=i});return t.resolve=r,t.reject=e,t},ye=r=>r==null?"":""+r,Ge=(r,e,t)=>{r.forEach(s=>{e[s]&&(t[s]=e[s])})},Qe=/###/g,be=r=>r&&r.indexOf("###")>-1?r.replace(Qe,"."):r,we=r=>!r||p(r),W=(r,e,t)=>{const s=p(e)?e.split("."):e;let i=0;for(;i<s.length-1;){if(we(r))return{};const n=be(s[i]);!r[n]&&t&&(r[n]=new t),Object.prototype.hasOwnProperty.call(r,n)?r=r[n]:r={},++i}return we(r)?{}:{obj:r,k:be(s[i])}},ve=(r,e,t)=>{const{obj:s,k:i}=W(r,e,Object);if(s!==void 0||e.length===1){s[i]=t;return}let n=e[e.length-1],o=e.slice(0,e.length-1),a=W(r,o,Object);for(;a.obj===void 0&&o.length;)n=`${o[o.length-1]}.${n}`,o=o.slice(0,o.length-1),a=W(r,o,Object),a?.obj&&typeof a.obj[`${a.k}.${n}`]<"u"&&(a.obj=void 0);a.obj[`${a.k}.${n}`]=t},Ye=(r,e,t,s)=>{const{obj:i,k:n}=W(r,e,Object);i[n]=i[n]||[],i[n].push(t)},te=(r,e)=>{const{obj:t,k:s}=W(r,e);if(t&&Object.prototype.hasOwnProperty.call(t,s))return t[s]},Ze=(r,e,t)=>{const s=te(r,t);return s!==void 0?s:te(e,t)},Re=(r,e,t)=>{for(const s in e)s!=="__proto__"&&s!=="constructor"&&(s in r?p(r[s])||r[s]instanceof String||p(e[s])||e[s]instanceof String?t&&(r[s]=e[s]):Re(r[s],e[s],t):r[s]=e[s]);return r},F=r=>r.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Xe={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const et=r=>p(r)?r.replace(/[&<>"'\/]/g,e=>Xe[e]):r;class tt{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const t=this.regExpMap.get(e);if(t!==void 0)return t;const s=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,s),this.regExpQueue.push(e),s}}const st=[" ",",","?","!",";"],it=new tt(20),nt=(r,e,t)=>{e=e||"",t=t||"";const s=st.filter(o=>e.indexOf(o)<0&&t.indexOf(o)<0);if(s.length===0)return!0;const i=it.getRegExp(`(${s.map(o=>o==="?"?"\\?":o).join("|")})`);let n=!i.test(r);if(!n){const o=r.indexOf(t);o>0&&!i.test(r.substring(0,o))&&(n=!0)}return n},ce=(r,e,t=".")=>{if(!r)return;if(r[e])return Object.prototype.hasOwnProperty.call(r,e)?r[e]:void 0;const s=e.split(t);let i=r;for(let n=0;n<s.length;){if(!i||typeof i!="object")return;let o,a="";for(let l=n;l<s.length;++l)if(l!==n&&(a+=t),a+=s[l],o=i[a],o!==void 0){if(["string","number","boolean"].indexOf(typeof o)>-1&&l<s.length-1)continue;n+=l-n+1;break}i=o}return i},Y=r=>r?.replace(/_/g,"-"),rt={type:"logger",log(r){this.output("log",r)},warn(r){this.output("warn",r)},error(r){this.output("error",r)},output(r,e){console?.[r]?.apply?.(console,e)}};class se{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||rt,this.options=t,this.debug=t.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,t,s,i){return i&&!this.debug?null:(p(e[0])&&(e[0]=`${s}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new se(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new se(this.logger,e)}}var A=new se;class ie{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(s=>{this.observers[s]||(this.observers[s]=new Map);const i=this.observers[s].get(t)||0;this.observers[s].set(t,i+1)}),this}off(e,t){if(this.observers[e]){if(!t){delete this.observers[e];return}this.observers[e].delete(t)}}emit(e,...t){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([i,n])=>{for(let o=0;o<n;o++)i(...t)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,n])=>{for(let o=0;o<n;o++)i.apply(i,[e,...t])})}}class Se extends ie{constructor(e,t={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,s,i={}){const n=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,o=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let a;e.indexOf(".")>-1?a=e.split("."):(a=[e,t],s&&(Array.isArray(s)?a.push(...s):p(s)&&n?a.push(...s.split(n)):a.push(s)));const l=te(this.data,a);return!l&&!t&&!s&&e.indexOf(".")>-1&&(e=a[0],t=a[1],s=a.slice(2).join(".")),l||!o||!p(s)?l:ce(this.data?.[e]?.[t],s,n)}addResource(e,t,s,i,n={silent:!1}){const o=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let a=[e,t];s&&(a=a.concat(o?s.split(o):s)),e.indexOf(".")>-1&&(a=e.split("."),i=t,t=a[1]),this.addNamespaces(t),ve(this.data,a,i),n.silent||this.emit("added",e,t,s,i)}addResources(e,t,s,i={silent:!1}){for(const n in s)(p(s[n])||Array.isArray(s[n]))&&this.addResource(e,t,n,s[n],{silent:!0});i.silent||this.emit("added",e,t,s)}addResourceBundle(e,t,s,i,n,o={silent:!1,skipCopy:!1}){let a=[e,t];e.indexOf(".")>-1&&(a=e.split("."),i=s,s=t,t=a[1]),this.addNamespaces(t);let l=te(this.data,a)||{};o.skipCopy||(s=JSON.parse(JSON.stringify(s))),i?Re(l,s,n):l={...l,...s},ve(this.data,a,l),o.silent||this.emit("added",e,t,s)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}hasResourceBundle(e,t){return this.getResource(e,t)!==void 0}getResourceBundle(e,t){return t||(t=this.options.defaultNS),this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(i=>t[i]&&Object.keys(t[i]).length>0)}toJSON(){return this.data}}var Ae={processors:{},addPostProcessor(r){this.processors[r.name]=r},handle(r,e,t,s,i){return r.forEach(n=>{e=this.processors[n]?.process(e,t,s,i)??e}),e}};const je=Symbol("i18next/PATH_KEY");function ot(){const r=[],e=Object.create(null);let t;return e.get=(s,i)=>(t?.revoke?.(),i===je?r:(r.push(i),t=Proxy.revocable(s,e),t.proxy)),Proxy.revocable(Object.create(null),e).proxy}function K(r,e){const{[je]:t}=r(ot()),s=e?.keySeparator??".",i=e?.nsSeparator??":";if(t.length>1&&i){const n=e?.ns,o=Array.isArray(n)?n:null;if(o&&o.length>1&&o.slice(1).includes(t[0]))return`${t[0]}${i}${t.slice(1).join(s)}`}return t.join(s)}const xe={},oe=r=>!p(r)&&typeof r!="boolean"&&typeof r!="number";let Pe=class Me extends ie{constructor(e,t={}){super(),Ge(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=A.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){const s={...t};if(e==null)return!1;const i=this.resolve(e,s);if(i?.res===void 0)return!1;const n=oe(i.res);return!(s.returnObjects===!1&&n)}extractFromKey(e,t){let s=t.nsSeparator!==void 0?t.nsSeparator:this.options.nsSeparator;s===void 0&&(s=":");const i=t.keySeparator!==void 0?t.keySeparator:this.options.keySeparator;let n=t.ns||this.options.defaultNS||[];const o=s&&e.indexOf(s)>-1,a=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!nt(e,s,i);if(o&&!a){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:p(n)?[n]:n};const c=e.split(s);(s!==i||s===i&&this.options.ns.indexOf(c[0])>-1)&&(n=c.shift()),e=c.join(i)}return{key:e,namespaces:p(n)?[n]:n}}translate(e,t,s){let i=typeof t=="object"?{...t}:t;if(typeof i!="object"&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof i=="object"&&(i={...i}),i||(i={}),e==null)return"";typeof e=="function"&&(e=K(e,{...this.options,...i})),Array.isArray(e)||(e=[String(e)]),e=e.map(x=>typeof x=="function"?K(x,{...this.options,...i}):String(x));const n=i.returnDetails!==void 0?i.returnDetails:this.options.returnDetails,o=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,{key:a,namespaces:l}=this.extractFromKey(e[e.length-1],i),c=l[l.length-1];let h=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;h===void 0&&(h=":");const u=i.lng||this.language,g=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u?.toLowerCase()==="cimode")return g?n?{res:`${c}${h}${a}`,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:c,usedParams:this.getUsedParamsDetails(i)}:`${c}${h}${a}`:n?{res:a,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:c,usedParams:this.getUsedParamsDetails(i)}:a;const d=this.resolve(e,i);let f=d?.res;const y=d?.usedKey||a,m=d?.exactUsedKey||a,w=["[object Number]","[object Function]","[object RegExp]"],b=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,T=!this.i18nFormat||this.i18nFormat.handleAsObject,O=i.count!==void 0&&!p(i.count),N=Me.hasDefaultValue(i),v=O?this.pluralResolver.getSuffix(u,i.count,i):"",E=i.ordinal&&O?this.pluralResolver.getSuffix(u,i.count,{ordinal:!1}):"",M=O&&!i.ordinal&&i.count===0,S=M&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${v}`]||i[`defaultValue${E}`]||i.defaultValue;let I=f;T&&!f&&N&&(I=S);const ne=oe(I),D=Object.prototype.toString.apply(I);if(T&&I&&ne&&w.indexOf(D)<0&&!(p(b)&&Array.isArray(I))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const x=this.options.returnedObjectHandler?this.options.returnedObjectHandler(y,I,{...i,ns:l}):`key '${a} (${this.language})' returned an object instead of string.`;return n?(d.res=x,d.usedParams=this.getUsedParamsDetails(i),d):x}if(o){const x=Array.isArray(I),$=x?[]:{},ue=x?m:y;for(const R in I)if(Object.prototype.hasOwnProperty.call(I,R)){const j=`${ue}${o}${R}`;N&&!f?$[R]=this.translate(j,{...i,defaultValue:oe(S)?S[R]:void 0,joinArrays:!1,ns:l}):$[R]=this.translate(j,{...i,joinArrays:!1,ns:l}),$[R]===j&&($[R]=I[R])}f=$}}else if(T&&p(b)&&Array.isArray(f))f=f.join(b),f&&(f=this.extendTranslation(f,e,i,s));else{let x=!1,$=!1;!this.isValidLookup(f)&&N&&(x=!0,f=S),this.isValidLookup(f)||($=!0,f=a);const R=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&$?void 0:f,j=N&&S!==f&&this.options.updateMissing;if($||x||j){if(this.logger.log(j?"updateKey":"missingKey",u,c,a,j?S:f),o){const C=this.resolve(a,{...i,keySeparator:!1});C&&C.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let z=[];const Z=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&Z&&Z[0])for(let C=0;C<Z.length;C++)z.push(Z[C]);else this.options.saveMissingTo==="all"?z=this.languageUtils.toResolveHierarchy(i.lng||this.language):z.push(i.lng||this.language);const de=(C,_,H)=>{const fe=N&&H!==f?H:R;this.options.missingKeyHandler?this.options.missingKeyHandler(C,c,_,fe,j,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(C,c,_,fe,j,i),this.emit("missingKey",C,c,_,f)};this.options.saveMissing&&(this.options.saveMissingPlurals&&O?z.forEach(C=>{const _=this.pluralResolver.getSuffixes(C,i);M&&i[`defaultValue${this.options.pluralSeparator}zero`]&&_.indexOf(`${this.options.pluralSeparator}zero`)<0&&_.push(`${this.options.pluralSeparator}zero`),_.forEach(H=>{de([C],a+H,i[`defaultValue${H}`]||S)})}):de(z,a,S))}f=this.extendTranslation(f,e,i,d,s),$&&f===a&&this.options.appendNamespaceToMissingKey&&(f=`${c}${h}${a}`),($||x)&&this.options.parseMissingKeyHandler&&(f=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}${h}${a}`:a,x?f:void 0,i))}return n?(d.res=f,d.usedParams=this.getUsedParamsDetails(i),d):f}extendTranslation(e,t,s,i,n){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...s},s.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!s.skipInterpolation){s.interpolation&&this.interpolator.init({...s,interpolation:{...this.options.interpolation,...s.interpolation}});const l=p(e)&&(s?.interpolation?.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let c;if(l){const u=e.match(this.interpolator.nestingRegexp);c=u&&u.length}let h=s.replace&&!p(s.replace)?s.replace:s;if(this.options.interpolation.defaultVariables&&(h={...this.options.interpolation.defaultVariables,...h}),e=this.interpolator.interpolate(e,h,s.lng||this.language||i.usedLng,s),l){const u=e.match(this.interpolator.nestingRegexp),g=u&&u.length;c<g&&(s.nest=!1)}!s.lng&&i&&i.res&&(s.lng=this.language||i.usedLng),s.nest!==!1&&(e=this.interpolator.nest(e,(...u)=>n?.[0]===u[0]&&!s.context?(this.logger.warn(`It seems you are nesting recursively key: ${u[0]} in key: ${t[0]}`),null):this.translate(...u,t),s)),s.interpolation&&this.interpolator.reset()}const o=s.postProcess||this.options.postProcess,a=p(o)?[o]:o;return e!=null&&a?.length&&s.applyPostProcessor!==!1&&(e=Ae.handle(a,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(s)},...s}:s,this)),e}resolve(e,t={}){let s,i,n,o,a;return p(e)&&(e=[e]),Array.isArray(e)&&(e=e.map(l=>typeof l=="function"?K(l,{...this.options,...t}):l)),e.forEach(l=>{if(this.isValidLookup(s))return;const c=this.extractFromKey(l,t),h=c.key;i=h;let u=c.namespaces;this.options.fallbackNS&&(u=u.concat(this.options.fallbackNS));const g=t.count!==void 0&&!p(t.count),d=g&&!t.ordinal&&t.count===0,f=t.context!==void 0&&(p(t.context)||typeof t.context=="number")&&t.context!=="",y=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);u.forEach(m=>{this.isValidLookup(s)||(a=m,!xe[`${y[0]}-${m}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(a)&&(xe[`${y[0]}-${m}`]=!0,this.logger.warn(`key "${i}" for languages "${y.join(", ")}" won't get resolved as namespace "${a}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),y.forEach(w=>{if(this.isValidLookup(s))return;o=w;const b=[h];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(b,h,w,m,t);else{let O;g&&(O=this.pluralResolver.getSuffix(w,t.count,t));const N=`${this.options.pluralSeparator}zero`,v=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(g&&(t.ordinal&&O.indexOf(v)===0&&b.push(h+O.replace(v,this.options.pluralSeparator)),b.push(h+O),d&&b.push(h+N)),f){const E=`${h}${this.options.contextSeparator||"_"}${t.context}`;b.push(E),g&&(t.ordinal&&O.indexOf(v)===0&&b.push(E+O.replace(v,this.options.pluralSeparator)),b.push(E+O),d&&b.push(E+N))}}let T;for(;T=b.pop();)this.isValidLookup(s)||(n=T,s=this.getResource(w,m,T,t))}))})}),{res:s,usedKey:i,exactUsedKey:n,usedLng:o,usedNS:a}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,t,s,i={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,s,i):this.resourceStore.getResource(e,t,s,i)}getUsedParamsDetails(e={}){const t=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],s=e.replace&&!p(e.replace);let i=s?e.replace:e;if(s&&typeof e.count<"u"&&(i.count=e.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!s){i={...i};for(const n of t)delete i[n]}return i}static hasDefaultValue(e){const t="defaultValue";for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)&&t===s.substring(0,t.length)&&e[s]!==void 0)return!0;return!1}};class Oe{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=A.create("languageUtils")}getScriptPartFromCode(e){if(e=Y(e),!e||e.indexOf("-")<0)return null;const t=e.split("-");return t.length===2||(t.pop(),t[t.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(t.join("-"))}getLanguagePartFromCode(e){if(e=Y(e),!e||e.indexOf("-")<0)return e;const t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(p(e)&&e.indexOf("-")>-1){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch{}return t&&this.options.lowerCaseLng&&(t=t.toLowerCase()),t||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let t;return e.forEach(s=>{if(t)return;const i=this.formatLanguageCode(s);(!this.options.supportedLngs||this.isSupportedCode(i))&&(t=i)}),!t&&this.options.supportedLngs&&e.forEach(s=>{if(t)return;const i=this.getScriptPartFromCode(s);if(this.isSupportedCode(i))return t=i;const n=this.getLanguagePartFromCode(s);if(this.isSupportedCode(n))return t=n;t=this.options.supportedLngs.find(o=>{if(o===n)return o;if(!(o.indexOf("-")<0&&n.indexOf("-")<0)&&(o.indexOf("-")>0&&n.indexOf("-")<0&&o.substring(0,o.indexOf("-"))===n||o.indexOf(n)===0&&n.length>1))return o})}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t}getFallbackCodes(e,t){if(!e)return[];if(typeof e=="function"&&(e=e(t)),p(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let s=e[t];return s||(s=e[this.getScriptPartFromCode(t)]),s||(s=e[this.formatLanguageCode(t)]),s||(s=e[this.getLanguagePartFromCode(t)]),s||(s=e.default),s||[]}toResolveHierarchy(e,t){const s=this.getFallbackCodes((t===!1?[]:t)||this.options.fallbackLng||[],e),i=[],n=o=>{o&&(this.isSupportedCode(o)?i.push(o):this.logger.warn(`rejecting language code not found in supportedLngs: ${o}`))};return p(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&n(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&n(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&n(this.getLanguagePartFromCode(e))):p(e)&&n(this.formatLanguageCode(e)),s.forEach(o=>{i.indexOf(o)<0&&n(this.formatLanguageCode(o))}),i}}const Ie={zero:0,one:1,two:2,few:3,many:4,other:5},Le={select:r=>r===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class at{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=A.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){const s=Y(e==="dev"?"en":e),i=t.ordinal?"ordinal":"cardinal",n=JSON.stringify({cleanedCode:s,type:i});if(n in this.pluralRulesCache)return this.pluralRulesCache[n];let o;try{o=new Intl.PluralRules(s,{type:i})}catch{if(typeof Intl>"u")return this.logger.error("No Intl support, please use an Intl polyfill!"),Le;if(!e.match(/-|_/))return Le;const l=this.languageUtils.getLanguagePartFromCode(e);o=this.getRule(l,t)}return this.pluralRulesCache[n]=o,o}needsPlural(e,t={}){let s=this.getRule(e,t);return s||(s=this.getRule("dev",t)),s?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,s={}){return this.getSuffixes(e,s).map(i=>`${t}${i}`)}getSuffixes(e,t={}){let s=this.getRule(e,t);return s||(s=this.getRule("dev",t)),s?s.resolvedOptions().pluralCategories.sort((i,n)=>Ie[i]-Ie[n]).map(i=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(e,t,s={}){const i=this.getRule(e,s);return i?`${this.options.prepend}${s.ordinal?`ordinal${this.options.prepend}`:""}${i.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,s))}}const ke=(r,e,t,s=".",i=!0)=>{let n=Ze(r,e,t);return!n&&i&&p(t)&&(n=ce(r,t,s),n===void 0&&(n=ce(e,t,s))),n},ae=r=>r.replace(/\$/g,"$$$$");class Ce{constructor(e={}){this.logger=A.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(t=>t),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:t,escapeValue:s,useRawValueToEscape:i,prefix:n,prefixEscaped:o,suffix:a,suffixEscaped:l,formatSeparator:c,unescapeSuffix:h,unescapePrefix:u,nestingPrefix:g,nestingPrefixEscaped:d,nestingSuffix:f,nestingSuffixEscaped:y,nestingOptionsSeparator:m,maxReplaces:w,alwaysFormat:b}=e.interpolation;this.escape=t!==void 0?t:et,this.escapeValue=s!==void 0?s:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=n?F(n):o||"{{",this.suffix=a?F(a):l||"}}",this.formatSeparator=c||",",this.unescapePrefix=h?"":u||"-",this.unescapeSuffix=this.unescapePrefix?"":h||"",this.nestingPrefix=g?F(g):d||F("$t("),this.nestingSuffix=f?F(f):y||F(")"),this.nestingOptionsSeparator=m||",",this.maxReplaces=w||1e3,this.alwaysFormat=b!==void 0?b:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(t,s)=>t?.source===s?(t.lastIndex=0,t):new RegExp(s,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,t,s,i){let n,o,a;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},c=d=>{if(d.indexOf(this.formatSeparator)<0){const w=ke(t,l,d,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(w,void 0,s,{...i,...t,interpolationkey:d}):w}const f=d.split(this.formatSeparator),y=f.shift().trim(),m=f.join(this.formatSeparator).trim();return this.format(ke(t,l,y,this.options.keySeparator,this.options.ignoreJSONStructure),m,s,{...i,...t,interpolationkey:y})};this.resetRegExp();const h=i?.missingInterpolationHandler||this.options.missingInterpolationHandler,u=i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:d=>ae(d)},{regex:this.regexp,safeValue:d=>this.escapeValue?ae(this.escape(d)):ae(d)}].forEach(d=>{for(a=0;n=d.regex.exec(e);){const f=n[1].trim();if(o=c(f),o===void 0)if(typeof h=="function"){const m=h(e,n,i);o=p(m)?m:""}else if(i&&Object.prototype.hasOwnProperty.call(i,f))o="";else if(u){o=n[0];continue}else this.logger.warn(`missed to pass in variable ${f} for interpolating ${e}`),o="";else!p(o)&&!this.useRawValueToEscape&&(o=ye(o));const y=d.safeValue(o);if(e=e.replace(n[0],y),u?(d.regex.lastIndex+=o.length,d.regex.lastIndex-=n[0].length):d.regex.lastIndex=0,a++,a>=this.maxReplaces)break}}),e}nest(e,t,s={}){let i,n,o;const a=(l,c)=>{const h=this.nestingOptionsSeparator;if(l.indexOf(h)<0)return l;const u=l.split(new RegExp(`${F(h)}[ ]*{`));let g=`{${u[1]}`;l=u[0],g=this.interpolate(g,o);const d=g.match(/'/g),f=g.match(/"/g);((d?.length??0)%2===0&&!f||(f?.length??0)%2!==0)&&(g=g.replace(/'/g,'"'));try{o=JSON.parse(g),c&&(o={...c,...o})}catch(y){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,y),`${l}${h}${g}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,l};for(;i=this.nestingRegexp.exec(e);){let l=[];o={...s},o=o.replace&&!p(o.replace)?o.replace:o,o.applyPostProcessor=!1,delete o.defaultValue;const c=/{.*}/.test(i[1])?i[1].lastIndexOf("}")+1:i[1].indexOf(this.formatSeparator);if(c!==-1&&(l=i[1].slice(c).split(this.formatSeparator).map(h=>h.trim()).filter(Boolean),i[1]=i[1].slice(0,c)),n=t(a.call(this,i[1].trim(),o),o),n&&i[0]===e&&!p(n))return n;p(n)||(n=ye(n)),n||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),n=""),l.length&&(n=l.reduce((h,u)=>this.format(h,u,s.lng,{...s,interpolationkey:i[1].trim()}),n.trim())),e=e.replace(i[0],n),this.regexp.lastIndex=0}return e}}const lt=r=>{let e=r.toLowerCase().trim();const t={};if(r.indexOf("(")>-1){const s=r.split("(");e=s[0].toLowerCase().trim();const i=s[1].substring(0,s[1].length-1);e==="currency"&&i.indexOf(":")<0?t.currency||(t.currency=i.trim()):e==="relativetime"&&i.indexOf(":")<0?t.range||(t.range=i.trim()):i.split(";").forEach(o=>{if(o){const[a,...l]=o.split(":"),c=l.join(":").trim().replace(/^'+|'+$/g,""),h=a.trim();t[h]||(t[h]=c),c==="false"&&(t[h]=!1),c==="true"&&(t[h]=!0),isNaN(c)||(t[h]=parseInt(c,10))}})}return{formatName:e,formatOptions:t}},Ee=r=>{const e={};return(t,s,i)=>{let n=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(n={...n,[i.interpolationkey]:void 0});const o=s+JSON.stringify(n);let a=e[o];return a||(a=r(Y(s),i),e[o]=a),a(t)}},ct=r=>(e,t,s)=>r(Y(t),s)(e);class ht{constructor(e={}){this.logger=A.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";const s=t.cacheInBuiltFormats?Ee:ct;this.formats={number:s((i,n)=>{const o=new Intl.NumberFormat(i,{...n});return a=>o.format(a)}),currency:s((i,n)=>{const o=new Intl.NumberFormat(i,{...n,style:"currency"});return a=>o.format(a)}),datetime:s((i,n)=>{const o=new Intl.DateTimeFormat(i,{...n});return a=>o.format(a)}),relativetime:s((i,n)=>{const o=new Intl.RelativeTimeFormat(i,{...n});return a=>o.format(a,n.range||"day")}),list:s((i,n)=>{const o=new Intl.ListFormat(i,{...n});return a=>o.format(a)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=Ee(t)}format(e,t,s,i={}){const n=t.split(this.formatSeparator);if(n.length>1&&n[0].indexOf("(")>1&&n[0].indexOf(")")<0&&n.find(a=>a.indexOf(")")>-1)){const a=n.findIndex(l=>l.indexOf(")")>-1);n[0]=[n[0],...n.splice(1,a)].join(this.formatSeparator)}return n.reduce((a,l)=>{const{formatName:c,formatOptions:h}=lt(l);if(this.formats[c]){let u=a;try{const g=i?.formatParams?.[i.interpolationkey]||{},d=g.locale||g.lng||i.locale||i.lng||s;u=this.formats[c](a,d,{...h,...i,...g})}catch(g){this.logger.warn(g)}return u}else this.logger.warn(`there was no format function for ${c}`);return a},e)}}const ut=(r,e)=>{r.pending[e]!==void 0&&(delete r.pending[e],r.pendingCount--)};class dt extends ie{constructor(e,t,s,i={}){super(),this.backend=e,this.store=t,this.services=s,this.languageUtils=s.languageUtils,this.options=i,this.logger=A.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(s,i.backend,i)}queueLoad(e,t,s,i){const n={},o={},a={},l={};return e.forEach(c=>{let h=!0;t.forEach(u=>{const g=`${c}|${u}`;!s.reload&&this.store.hasResourceBundle(c,u)?this.state[g]=2:this.state[g]<0||(this.state[g]===1?o[g]===void 0&&(o[g]=!0):(this.state[g]=1,h=!1,o[g]===void 0&&(o[g]=!0),n[g]===void 0&&(n[g]=!0),l[u]===void 0&&(l[u]=!0)))}),h||(a[c]=!0)}),(Object.keys(n).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(n),pending:Object.keys(o),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(l)}}loaded(e,t,s){const i=e.split("|"),n=i[0],o=i[1];t&&this.emit("failedLoading",n,o,t),!t&&s&&this.store.addResourceBundle(n,o,s,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&s&&(this.state[e]=0);const a={};this.queue.forEach(l=>{Ye(l.loaded,[n],o),ut(l,e),t&&l.errors.push(t),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(c=>{a[c]||(a[c]={});const h=l.loaded[c];h.length&&h.forEach(u=>{a[c][u]===void 0&&(a[c][u]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(l=>!l.done)}read(e,t,s,i=0,n=this.retryTimeout,o){if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:s,tried:i,wait:n,callback:o});return}this.readingCalls++;const a=(c,h)=>{if(this.readingCalls--,this.waitingReads.length>0){const u=this.waitingReads.shift();this.read(u.lng,u.ns,u.fcName,u.tried,u.wait,u.callback)}if(c&&h&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,t,s,i+1,n*2,o)},n);return}o(c,h)},l=this.backend[s].bind(this.backend);if(l.length===2){try{const c=l(e,t);c&&typeof c.then=="function"?c.then(h=>a(null,h)).catch(a):a(null,c)}catch(c){a(c)}return}return l(e,t,a)}prepareLoading(e,t,s={},i){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();p(e)&&(e=this.languageUtils.toResolveHierarchy(e)),p(t)&&(t=[t]);const n=this.queueLoad(e,t,s,i);if(!n.toLoad.length)return n.pending.length||i(),null;n.toLoad.forEach(o=>{this.loadOne(o)})}load(e,t,s){this.prepareLoading(e,t,{},s)}reload(e,t,s){this.prepareLoading(e,t,{reload:!0},s)}loadOne(e,t=""){const s=e.split("|"),i=s[0],n=s[1];this.read(i,n,"read",void 0,void 0,(o,a)=>{o&&this.logger.warn(`${t}loading namespace ${n} for language ${i} failed`,o),!o&&a&&this.logger.log(`${t}loaded namespace ${n} for language ${i}`,a),this.loaded(e,o,a)})}saveMissing(e,t,s,i,n,o={},a=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(t)){this.logger.warn(`did not save key "${s}" as the namespace "${t}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(s==null||s==="")){if(this.backend?.create){const l={...o,isUpdate:n},c=this.backend.create.bind(this.backend);if(c.length<6)try{let h;c.length===5?h=c(e,t,s,i,l):h=c(e,t,s,i),h&&typeof h.then=="function"?h.then(u=>a(null,u)).catch(a):a(null,h)}catch(h){a(h)}else c(e,t,s,i,a,l)}!e||!e[0]||this.store.addResource(e[0],t,s,i)}}}const le=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:r=>{let e={};if(typeof r[1]=="object"&&(e=r[1]),p(r[1])&&(e.defaultValue=r[1]),p(r[2])&&(e.tDescription=r[2]),typeof r[2]=="object"||typeof r[3]=="object"){const t=r[3]||r[2];Object.keys(t).forEach(s=>{e[s]=t[s]})}return e},interpolation:{escapeValue:!0,format:r=>r,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),$e=r=>(p(r.ns)&&(r.ns=[r.ns]),p(r.fallbackLng)&&(r.fallbackLng=[r.fallbackLng]),p(r.fallbackNS)&&(r.fallbackNS=[r.fallbackNS]),r.supportedLngs?.indexOf?.("cimode")<0&&(r.supportedLngs=r.supportedLngs.concat(["cimode"])),typeof r.initImmediate=="boolean"&&(r.initAsync=r.initImmediate),r),ee=()=>{},ft=r=>{Object.getOwnPropertyNames(Object.getPrototypeOf(r)).forEach(t=>{typeof r[t]=="function"&&(r[t]=r[t].bind(r))})},De="__i18next_supportNoticeShown",gt=()=>!!(typeof globalThis<"u"&&globalThis[De]||typeof process<"u"&&re&&re.I18NEXT_NO_SUPPORT_NOTICE||typeof process<"u"&&re),pt=()=>{typeof globalThis<"u"&&(globalThis[De]=!0)},mt=r=>!!(r?.modules?.backend?.name?.indexOf("Locize")>0||r?.modules?.backend?.constructor?.name?.indexOf("Locize")>0||r?.options?.backend?.backends&&r.options.backend.backends.some(e=>e?.name?.indexOf("Locize")>0||e?.constructor?.name?.indexOf("Locize")>0)||r?.options?.backend?.projectId||r?.options?.backend?.backendOptions&&r.options.backend.backendOptions.some(e=>e?.projectId));class G extends ie{constructor(e={},t){if(super(),this.options=$e(e),this.services={},this.logger=A,this.modules={external:[]},ft(this),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(e={},t){this.isInitializing=!0,typeof e=="function"&&(t=e,e={}),e.defaultNS==null&&e.ns&&(p(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const s=le();this.options={...s,...this.options,...$e(e)},this.options.interpolation={...s.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator),typeof this.options.overloadTranslationOptionHandler!="function"&&(this.options.overloadTranslationOptionHandler=s.overloadTranslationOptionHandler),this.options.showSupportNotice!==!1&&!mt(this)&&!gt()&&(typeof console<"u"&&typeof console.info<"u"&&console.info("🌐 i18next is made possible by our own product, Locize — consider powering your project with managed localization (AI, CDN, integrations): https://locize.com 💙"),pt());const i=c=>c?typeof c=="function"?new c:c:null;if(!this.options.isClone){this.modules.logger?A.init(i(this.modules.logger),this.options):A.init(null,this.options);let c;this.modules.formatter?c=this.modules.formatter:c=ht;const h=new Oe(this.options);this.store=new Se(this.options.resources,this.options);const u=this.services;u.logger=A,u.resourceStore=this.store,u.languageUtils=h,u.pluralResolver=new at(h,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==s.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),c&&(!this.options.interpolation.format||this.options.interpolation.format===s.interpolation.format)&&(u.formatter=i(c),u.formatter.init&&u.formatter.init(u,this.options),this.options.interpolation.format=u.formatter.format.bind(u.formatter)),u.interpolator=new Ce(this.options),u.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},u.backendConnector=new dt(i(this.modules.backend),u.resourceStore,u,this.options),u.backendConnector.on("*",(d,...f)=>{this.emit(d,...f)}),this.modules.languageDetector&&(u.languageDetector=i(this.modules.languageDetector),u.languageDetector.init&&u.languageDetector.init(u,this.options.detection,this.options)),this.modules.i18nFormat&&(u.i18nFormat=i(this.modules.i18nFormat),u.i18nFormat.init&&u.i18nFormat.init(this)),this.translator=new Pe(this.services,this.options),this.translator.on("*",(d,...f)=>{this.emit(d,...f)}),this.modules.external.forEach(d=>{d.init&&d.init(this)})}if(this.format=this.options.interpolation.format,t||(t=ee),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const c=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);c.length>0&&c[0]!=="dev"&&(this.options.lng=c[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(c=>{this[c]=(...h)=>this.store[c](...h)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(c=>{this[c]=(...h)=>(this.store[c](...h),this)});const a=V(),l=()=>{const c=(h,u)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),a.resolve(u),t(h,u)};if(this.languages&&!this.isInitialized)return c(null,this.t.bind(this));this.changeLanguage(this.options.lng,c)};return this.options.resources||!this.options.initAsync?l():setTimeout(l,0),a}loadResources(e,t=ee){let s=t;const i=p(e)?e:this.language;if(typeof e=="function"&&(s=e),!this.options.resources||this.options.partialBundledLanguages){if(i?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return s();const n=[],o=a=>{if(!a||a==="cimode")return;this.services.languageUtils.toResolveHierarchy(a).forEach(c=>{c!=="cimode"&&n.indexOf(c)<0&&n.push(c)})};i?o(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(l=>o(l)),this.options.preload?.forEach?.(a=>o(a)),this.services.backendConnector.load(n,this.options.ns,a=>{!a&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),s(a)})}else s(null)}reloadResources(e,t,s){const i=V();return typeof e=="function"&&(s=e,e=void 0),typeof t=="function"&&(s=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),s||(s=ee),this.services.backendConnector.reload(e,t,n=>{i.resolve(),s(n)}),i}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&Ae.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!(["cimode","dev"].indexOf(e)>-1)){for(let t=0;t<this.languages.length;t++){const s=this.languages[t];if(!(["cimode","dev"].indexOf(s)>-1)&&this.store.hasLanguageSomeTranslations(s)){this.resolvedLanguage=s;break}}!this.resolvedLanguage&&this.languages.indexOf(e)<0&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;const s=V();this.emit("languageChanging",e);const i=a=>{this.language=a,this.languages=this.services.languageUtils.toResolveHierarchy(a),this.resolvedLanguage=void 0,this.setResolvedLanguage(a)},n=(a,l)=>{l?this.isLanguageChangingTo===e&&(i(l),this.translator.changeLanguage(l),this.isLanguageChangingTo=void 0,this.emit("languageChanged",l),this.logger.log("languageChanged",l)):this.isLanguageChangingTo=void 0,s.resolve((...c)=>this.t(...c)),t&&t(a,(...c)=>this.t(...c))},o=a=>{!e&&!a&&this.services.languageDetector&&(a=[]);const l=p(a)?a:a&&a[0],c=this.store.hasLanguageSomeTranslations(l)?l:this.services.languageUtils.getBestMatchFromCodes(p(a)?[a]:a);c&&(this.language||i(c),this.translator.language||this.translator.changeLanguage(c),this.services.languageDetector?.cacheUserLanguage?.(c)),this.loadResources(c,h=>{n(h,c)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?o(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(o):this.services.languageDetector.detect(o):o(e),s}getFixedT(e,t,s){const i=(n,o,...a)=>{let l;typeof o!="object"?l=this.options.overloadTranslationOptionHandler([n,o].concat(a)):l={...o},l.lng=l.lng||i.lng,l.lngs=l.lngs||i.lngs,l.ns=l.ns||i.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||s||i.keyPrefix);const c={...this.options,...l};typeof l.keyPrefix=="function"&&(l.keyPrefix=K(l.keyPrefix,c));const h=this.options.keySeparator||".";let u;return l.keyPrefix&&Array.isArray(n)?u=n.map(g=>(typeof g=="function"&&(g=K(g,c)),`${l.keyPrefix}${h}${g}`)):(typeof n=="function"&&(n=K(n,c)),u=l.keyPrefix?`${l.keyPrefix}${h}${n}`:n),this.t(u,l)};return p(e)?i.lng=e:i.lngs=e,i.ns=t,i.keyPrefix=s,i}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const s=t.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,n=this.languages[this.languages.length-1];if(s.toLowerCase()==="cimode")return!0;const o=(a,l)=>{const c=this.services.backendConnector.state[`${a}|${l}`];return c===-1||c===0||c===2};if(t.precheck){const a=t.precheck(this,o);if(a!==void 0)return a}return!!(this.hasResourceBundle(s,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(s,e)&&(!i||o(n,e)))}loadNamespaces(e,t){const s=V();return this.options.ns?(p(e)&&(e=[e]),e.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{s.resolve(),t&&t(i)}),s):(t&&t(),Promise.resolve())}loadLanguages(e,t){const s=V();p(e)&&(e=[e]);const i=this.options.preload||[],n=e.filter(o=>i.indexOf(o)<0&&this.services.languageUtils.isSupportedCode(o));return n.length?(this.options.preload=i.concat(n),this.loadResources(o=>{s.resolve(),t&&t(o)}),s):(t&&t(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{const i=new Intl.Locale(e);if(i&&i.getTextInfo){const n=i.getTextInfo();if(n&&n.direction)return n.direction}}catch{}const t=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],s=this.services?.languageUtils||new Oe(le());return e.toLowerCase().indexOf("-latn")>1?"ltr":t.indexOf(s.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){const s=new G(e,t);return s.createInstance=G.createInstance,s}cloneInstance(e={},t=ee){const s=e.forkResourceStore;s&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},n=new G(i);if((e.debug!==void 0||e.prefix!==void 0)&&(n.logger=n.logger.clone(e)),["store","services","language"].forEach(a=>{n[a]=this[a]}),n.services={...this.services},n.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},s){const a=Object.keys(this.store.data).reduce((l,c)=>(l[c]={...this.store.data[c]},l[c]=Object.keys(l[c]).reduce((h,u)=>(h[u]={...l[c][u]},h),l[c]),l),{});n.store=new Se(a,i),n.services.resourceStore=n.store}if(e.interpolation){const l={...le().interpolation,...this.options.interpolation,...e.interpolation},c={...i,interpolation:l};n.services.interpolator=new Ce(c)}return n.translator=new Pe(n.services,i),n.translator.on("*",(a,...l)=>{n.emit(a,...l)}),n.init(i,t),n.translator.options=i,n.translator.backendConnector.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},n}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const k=G.createInstance(),yt=k.createInstance;k.dir;k.init;k.loadResources;k.reloadResources;k.use;k.changeLanguage;k.getFixedT;k.t;k.exists;k.setDefaultNamespace;k.hasLoadedNamespace;k.loadNamespaces;k.loadLanguages;class bt{currentLanguage;initializationState;initializationPromise;i18n;translationUrl;ai;aiTranslationCache=new Map;aiTranslationPending=new Map;constructor(e,t,s){this.currentLanguage=e,this.initializationState="not-inited",this.initializationPromise=null,this.translationUrl=t,this.ai=s}async initialize(){if(this.initializationState!=="finished")return this.initializationState==="initing"&&this.initializationPromise?this.initializationPromise:(this.initializationState="initing",this.initializationPromise=(async()=>{try{const e=await this.fetchTranslations(this.currentLanguage),t=yt({lng:this.currentLanguage,resources:{[this.currentLanguage]:{translation:e}},debug:!1,showSupportNotice:!1,parseMissingKeyHandler:(s,i)=>s.trim()?this.isTranslationKey(s)?(console.warn(`Translation key not found: ${s}`),i??""):(this.fetchTranslation(s).then(n=>{this.i18n?.addResource(this.currentLanguage,"translation",s,n),this.i18n?.emit("languageChanged")}),s):""});await t.init(),this.i18n=t,this.initializationState="finished"}catch(e){throw this.initializationState="not-inited",this.initializationPromise=null,e}})(),this.initializationPromise)}getTranslationUrl(e){return`${(this.translationUrl||window.location.origin).replace(/\/+$/,"")}/locales/${e}.json`}usePlugin(e){if(!this.i18n)throw new Error("Translator is not initialized");this.i18n.use(e)}onLanguageChanged(e){if(!this.i18n)throw new Error("Translator is not initialized");this.i18n.on("languageChanged",e)}async fetchTranslations(e,t=0){try{const s=await fetch(this.getTranslationUrl(e));if(!s.ok)throw new Error(`Failed to fetch translations for ${e}: ${s.status}`);const i=await s.json();return Object.keys(i).length===0&&t===0?(await new Promise(n=>setTimeout(n,300)),this.fetchTranslations(e,1)):i}catch(s){return t===0?(await new Promise(i=>setTimeout(i,300)),this.fetchTranslations(e,1)):(console.warn(`Fetching of ${e} translation not possible. Falling back to english. Error details: `+s.message),e==="en"?{}:this.fetchTranslations("en").catch(i=>(console.error("Failed to fetch fallback translations:",i),{})))}}t(e,t){if(!this.i18n)throw new Error("Translator is not initialized");return this.i18n.t(e,t)}getCurrentLanguage(){return this.currentLanguage}isReady(){return this.initializationState==="finished"}isTranslationKey(e){return/^[^\s.]+(\.[^\s.]+)+$/.test(e)}async fetchTranslation(e,t){const s=this.aiTranslationCache.get(e);if(s)return s;const i=this.aiTranslationPending.get(e);if(i)return i;if(!this.ai||this.currentLanguage==="en")return e;const n=(async()=>{try{const a=(await this.ai.getObject({prompt:"global.translator.translate",variables:{additionalInstructions:t??"",language:this.currentLanguage,text:e},cache:!0}))?.translation;if(a)return this.aiTranslationCache.set(e,a),a}catch(o){console.warn("Failed to translate freeform text:",{text:e,error:o})}finally{this.aiTranslationPending.delete(e)}return e})();return this.aiTranslationPending.set(e,n),n}}class wt{pluginId;rimoriInfo;translator;supabase;communicationHandler;releaseChannel;applicationMode;theme;ttsEnabled=!0;constructor(e,t,s,i){this.rimoriInfo=s,this.supabase=e,this.pluginId=s.pluginId,this.releaseChannel=s.releaseChannel,this.communicationHandler=t;const n=s.installedPlugins.find(o=>o.id===s.pluginId);this.translator=new bt(s.interfaceLanguage,n?.endpoint||"",i),this.ttsEnabled=s.ttsEnabled??!0,this.communicationHandler.onUpdate(o=>{this.rimoriInfo=o,this.ttsEnabled=o.ttsEnabled??!0}),this.applicationMode=this.communicationHandler.getQueryParam("applicationMode"),this.theme=this.communicationHandler.getQueryParam("rm_theme")||"light"}async fetchSettings(){const e=!this.rimoriInfo.guild.allowUserPluginSettings,{data:t}=await this.supabase.schema("public").from("plugin_settings").select("*").eq("plugin_id",this.pluginId).eq("guild_id",this.rimoriInfo.guild.id).eq("is_guild_setting",e).maybeSingle();return t?.settings??null}async setSettings(e){const t=!this.rimoriInfo.guild.allowUserPluginSettings,s={plugin_id:this.pluginId,settings:e,guild_id:this.rimoriInfo.guild.id,is_guild_setting:t};t&&(s.user_id=null);const i=this.supabase.schema("public").from("plugin_settings").update({settings:e}).eq("plugin_id",this.pluginId).eq("guild_id",this.rimoriInfo.guild.id).eq("is_guild_setting",t),{data:n,error:o}=await(t?i.is("user_id",null).select():i.select());if(o&&(o.code==="42501"||o.message?.includes("policy")))throw new Error(`Cannot set ${t?"guild":"user"} settings: Permission denied.`);if(n&&n.length>0)return;const{error:a}=await this.supabase.schema("public").from("plugin_settings").insert(s);if(a){if(a.code==="23505"){const l=this.supabase.schema("public").from("plugin_settings").update({settings:e}).eq("plugin_id",this.pluginId).eq("guild_id",this.rimoriInfo.guild.id).eq("is_guild_setting",t),{error:c}=await(t?l.is("user_id",null):l);if(!c)return}throw a}}async getSettings(e){const t=await this.fetchSettings();if(!t)return await this.setSettings(e),e;const s=Object.keys(t),i=Object.keys(e);if(s.length!==i.length){const n=Object.fromEntries(Object.entries(t).filter(([a])=>i.includes(a))),o={...e,...n};return await this.setSettings(o),o}return t}getUserInfo(){return this.rimoriInfo.profile}getGuildInfo(){return{id:this.rimoriInfo.guild.id,name:this.rimoriInfo.guild.name,description:this.rimoriInfo.guild.description,isShadowGuild:this.rimoriInfo.guild.isShadowGuild}}onRimoriInfoUpdate(e){return this.communicationHandler.onUpdate(e)}getPluginInfo(){return{installedPlugins:this.rimoriInfo.installedPlugins,mainPanelPlugin:this.rimoriInfo.mainPanelPlugin,sidePanelPlugin:this.rimoriInfo.sidePanelPlugin}}async getTranslator(){return await this.translator.initialize(),this.translator}}const Nt=["anonymous","free","standard","premium","early_access"],Rt=["user","plugin_moderator","lang_moderator","admin"];class vt{supabase;communicationHandler;tablePrefix;schema;constructor(e,t,s){this.supabase=e,this.communicationHandler=t,this.tablePrefix=s.tablePrefix,this.schema=s.dbSchema,t.onUpdate(i=>{this.tablePrefix=i.tablePrefix,this.schema=i.dbSchema})}from(e){const t=this.getTableName(e);return e.startsWith("global_")?this.supabase.schema("public").from(t):this.supabase.schema(this.schema).from(t)}getTableName(e){if(/[A-Z]/.test(e))throw new Error("Table name cannot include uppercase letters. Please use snake_case for table names.");return e.startsWith("global_")?e.replace("global_",""):this.tablePrefix+"_"+e}async setPublicity(e,t,s){const i=this.getTableName(e);await this.communicationHandler.fetchBackend("/db-entry/publicity",{method:"POST",body:JSON.stringify({table_name:i,schema:this.schema,entry_id:t,publicity:s})})}async vectorSearch(e){const t=await this.communicationHandler.fetchBackend("/plugin-search/vector-search",{method:"POST",body:JSON.stringify(e)});if(!t.ok)throw new Error(`Vector search failed: ${t.statusText}`);return await t.json()}}const St=["reading","listening","speaking","writing","learning","community"];class xt{pluginId;eventBus;constructor(e,t){this.pluginId=e,this.eventBus=t??P}emitAccomplishment(e){const t={...e,type:"durationMinutes"in e?"macro":"micro"};if(!this.validateAccomplishment(t))return;const s=this.sanitizeAccomplishment(t),i="global.accomplishment.trigger"+(t.type==="macro"?"Macro":"Micro");this.eventBus.emit(this.pluginId,i,s)}validateAccomplishment(e){if(!St.includes(e.skillCategory))throw new Error(`Invalid skill category: ${e.skillCategory}`);if(!/^[0-9a-z_.-]+$/.test(e.accomplishmentKeyword))throw new Error(`The accomplishment keyword: ${e.accomplishmentKeyword} is invalid. Only lowercase letters, minuses, underscores and periods are allowed`);if(e.description.length<10)throw new Error("Description is too short");if(!["micro","macro"].includes(e.type))throw new Error("Invalid accomplishment type "+e.type);if(e.type==="macro"&&(e.errorRatio<0||e.errorRatio>1))throw new Error("The error ratio must be between 0 and 1");return!0}sanitizeAccomplishment(e){return e.description=e.description.replace(/[^\x20-\x7E]/g,""),e.meta?.forEach(t=>{t.description=t.description.replace(/[^\x20-\x7E]/g,"")}),e.meta?.forEach(t=>{t.key=t.key.replace(/([A-Z])/g,"_$1").toLowerCase()}),e}getDecoupledTopic(e){const[t,s,i]=e.split(".");return{plugin:t||"*",skillCategory:s||"*",accomplishmentKeyword:i||"*"}}subscribe(e="*",t){typeof e=="string"&&(e=[e]),e.forEach(s=>{const i=s.split(".").length;if(i===1)s+=".*.*";else if(i===2)s+=".*";else if(i!==3)throw new Error("Invalid accomplishment topic pattern. The pattern must be plugin.skillCategory.accomplishmentKeyword or an * as wildcard for any plugin, skill category or accomplishment keyword");this.eventBus.on(["global.accomplishment.triggerMicro","global.accomplishment.triggerMacro"],n=>{const{plugin:o,skillCategory:a,accomplishmentKeyword:l}=this.getDecoupledTopic(s);o!=="*"&&n.sender!==o||a!=="*"&&n.data.skillCategory!==a||l!=="*"&&n.data.accomplishmentKeyword!==l||t(n)},[this.pluginId])})}}class Pt{pluginId;accomplishmentController;aiModule;eventBus;constructor(e,t,s){this.pluginId=e,this.aiModule=t,this.eventBus=s??P,this.accomplishmentController=new xt(e,this.eventBus),this.eventBus.on(["global.session.triggerUpdate"],i=>{i.data.session_token?this.aiModule.session.set(i.data.session_token):this.aiModule.session.clear()})}getGlobalEventTopic(e){if(e.startsWith("global.")||e.startsWith("self."))return e;const t=e.split(".");if(t.length===3){if(!t[0].startsWith("pl")&&t[0]!=="global")throw new Error(`Invalid event topic '${e}'. The topic must start with the plugin id, 'self' or 'global'.`);return e}else if(t.length>3)throw new Error(`The event topic must consist of 3 parts. <pluginId>.<topic area>.<action>. Received: ${e}`);return`${this.pluginId??"global"}.${e}`}emit(e,t,s){const i=this.getGlobalEventTopic(e);this.eventBus.emit(this.pluginId,i,t,s)}async request(e,t){const s=this.getGlobalEventTopic(e),i=this.aiModule.session.get()??void 0;return this.eventBus.request(this.pluginId,s,t,i)}on(e,t){const s=Array.isArray(e)?e:[e];return this.eventBus.on(s.map(i=>this.getGlobalEventTopic(i)),i=>{i.ai_session_token&&!this.aiModule.session.get()&&this.aiModule.session.set(i.ai_session_token),t(i)})}once(e,t){this.eventBus.once(this.getGlobalEventTopic(e),t)}respond(e,t){const s=Array.isArray(e)?e:[e];let i=t;typeof t=="function"&&(i=async n=>{const o=this.aiModule.session.get();n.ai_session_token&&this.aiModule.session.set(n.ai_session_token);try{return await t(n)}finally{n.ai_session_token&&(o?this.aiModule.session.set(o):this.aiModule.session.clear())}}),this.eventBus.respond(this.pluginId,s.map(n=>this.getGlobalEventTopic(n)),i)}async emitAccomplishment(e){this.accomplishmentController.emitAccomplishment(e)}onAccomplishment(e,t){this.accomplishmentController.subscribe(e,t)}emitSidebarAction(e,t,s,i){this.emit("global.sidebar.triggerAction",{plugin_id:e,action_key:t,text:s,args:i})}emitMainPanelAction(e,t,s){this.emit("global.mainPanel.triggerAction",{plugin_id:e,action_key:t,...s})}onMainPanelAction(e,t=[]){const s=Array.isArray(t)?t:[t],i=this.on("action.requestMain",({data:n})=>{(s.length===0||s.includes(n.action_key))&&e(n)});return this.emit("action.requestMain"),i}onSidePanelAction(e,t=[]){const s=Array.isArray(t)?t:[t],i=this.on("action.requestSidebar",({data:n})=>{(s.length===0||s.includes(n.action))&&e(n)});return this.emit("action.requestSidebar"),this.eventBus.emit(this.pluginId,"global.session.requestCurrent",{}),i}}class Ot{controller;sessionTokenId=null;onRateLimitedCb;constructor(e){this.controller=e}resolvePromptName(e){return e.startsWith("global.")?e:e.split(".").length===2&&this.controller.pluginId?`${this.controller.pluginId}.${e}`:e}session={get:()=>this.sessionTokenId,set:e=>{this.sessionTokenId=e},clear:()=>{this.sessionTokenId=null}};setOnRateLimited(e){this.onRateLimitedCb=e}async getText(e){const{messages:t,tools:s,cache:i=!1,prompt:n,variables:o}=e,{result:a}=await this.streamObject({cache:i,tools:s,messages:t,prompt:n,variables:o});return a}async getStreamedText(e){const{messages:t,onMessage:s,tools:i,cache:n=!1,prompt:o,variables:a}=e,l=Math.random().toString(36).substring(3),{result:c}=await this.streamObject({cache:n,tools:i,messages:t,prompt:o,variables:a,onResult:({result:h})=>s(l,h,!1)});return s(l,c,!0),c}async getVoice(e,t="alloy",s=1,i,n=!1,o){return e.trim().length?await this.controller.fetchBackend("/voice/tts",{method:"POST",body:JSON.stringify({input:e,voice:t,speed:s,language:i,cache:n,instructions:o,session_token_id:this.sessionTokenId??void 0})}).then(a=>a.blob()):(console.warn("[rimori-client] getVoice called with empty text — skipping TTS request and returning empty Blob."),new Blob([],{type:"audio/mpeg"}))}async getTextFromVoice(e,t){const s=new FormData;return s.append("file",e),t&&s.append("language",t.code),this.sessionTokenId&&s.append("session_token_id",this.sessionTokenId),await this.controller.fetchBackend("/voice/stt",{method:"POST",body:s}).then(i=>i.json()).then(i=>i.text)}async getObject(e){const{cache:t=!1,tools:s=[],prompt:i,variables:n}=e;return await this.streamObject({messages:[],cache:t,tools:s,prompt:i,variables:n})}async getStreamedObject(e){const{onResult:t,cache:s=!1,tools:i=[],prompt:n,variables:o}=e;return await this.streamObject({messages:[],onResult:t,cache:s,tools:i,prompt:n,variables:o})}async streamObject(e){const{messages:t,onResult:s=()=>null,cache:i=!1,tools:n=[],prompt:o,variables:a}=e,l=t.map((m,w)=>({...m,id:`${w+1}`})),c={cache:i,tools:n,stream:!0,messages:l,session_token_id:this.sessionTokenId??void 0};o&&(c.prompt={name:this.resolvePromptName(o),variables:a??{}});const h=await this.controller.fetchBackend("/ai/llm",{method:"POST",body:JSON.stringify(c)});if(!h.ok){if(h.status===429){const m=await h.json().catch(()=>({})),w=m.exercises_remaining??0;throw this.onRateLimitedCb?.(w),new Error(`Rate limit exceeded: ${m.error??"Daily exercise limit reached"}. exercises_remaining: ${w}`)}throw new Error(`Failed to stream object: ${h.status} ${h.statusText}`)}if(!h.body)throw new Error("No response body.");const u=h.body.getReader(),g=new TextDecoder("utf-8");let d={},f="",y=!0;for(;y;){await new Promise(v=>setTimeout(v,30));const{value:m,done:w}=await u.read();if(w)return y=!1,s(d,!1),d;if(!m)continue;const b=g.decode(m,{stream:!0}),O=(f+b).split(`
6
- `);f=O.pop()??"";const N=O.filter(v=>v.trim());for(const v of N){if(v.startsWith("token:")){try{const S=JSON.parse(v.slice(6).trim());S.token_id&&(this.sessionTokenId=S.token_id)}catch{console.error("Failed to parse token: line",v)}continue}if(v.startsWith("debug:")){try{const S=JSON.parse(v.slice(6).trim());console.group(`[Rimori Prompt] ${S.promptName}`),console.log(`System prompt:
7
- `,S.system),console.log(`User prompt:
8
- `,S.user),console.log("Variables:",S.variables),console.groupEnd()}catch{}continue}const E=v.substring(0,5),M=v.substring(5).trim();if(M==="[DONE]")return y=!1,s(d,!1),d;if(E==="data:")d=JSON.parse(M),s(d,!0);else if(E==="tool:"){const{toolCallId:S,toolName:I,args:ne}=JSON.parse(M),D=n.find(x=>x.name===I);if(D&&D.execute){const x=await D.execute(ne);await this.sendToolResult(S,x)}else D&&!D.execute?console.error("Tool found but has no execute function:",I):console.error("Tool not found:",I)}else E==="error"?console.error("Error:",M.substring(1)):E==="info:"||console.error("Unknown stream data:",v)}}return d}async sendToolResult(e,t){await this.controller.fetchBackend("/ai/llm/tool_result",{method:"POST",body:JSON.stringify({toolCallId:e,result:t??"[DONE]"})})}}class It{supabase;communicationHandler;eventModule;constructor(e,t,s,i){this.supabase=e,this.communicationHandler=t,this.eventModule=i}async view(){const{data:e,error:t}=await this.supabase.schema("public").from("weekly_exercises").select("*");if(t)throw new Error(`Failed to fetch weekly exercises: ${t.message}`);return e||[]}async add(e){const t=Array.isArray(e)?e:[e],s=await this.communicationHandler.fetchBackend("/exercises",{method:"POST",body:JSON.stringify({exercises:t})});if(!s.ok){const n=await s.text();throw new Error(`Failed to create exercises: ${n}`)}const i=await s.json();return this.eventModule.emit("global.exercises.triggerChange"),i}async start(e){return new Promise((t,s)=>{const i=setTimeout(()=>{n.off(),s(new Error("Exercise start timed out: rimori-main did not respond within 5s"))},5e3),n=this.eventModule.on("global.session.triggerUpdate",({data:o})=>{o.session_token&&(clearTimeout(i),n.off(),t())});this.eventModule.emit("global.exercise.triggerStart",e)})}async delete(e){const t=await this.communicationHandler.fetchBackend(`/exercises/${e}`,{method:"DELETE"});if(!t.ok){const s=await t.text();throw new Error(`Failed to delete exercise: ${s}`)}return this.eventModule.emit("global.exercises.triggerChange"),await t.json()}}class Lt{controller;constructor(e){this.controller=e}async uploadImage(e){const t=new FormData;t.append("file",e,"image.png");try{const s=await this.controller.fetchBackend("/plugin-images/upload",{method:"POST",body:t});if(!s.ok){const n=await s.json().catch(()=>({}));return{error:new Error(n.message??`Upload failed (${s.status})`)}}return{data:await s.json()}}catch(s){return{error:s instanceof Error?s:new Error(String(s))}}}}class U{static instance;controller;sharedContent;db;event;plugin;ai;exercise;storage;eventBus;constructor(e,t,s,i){this.controller=e,this.eventBus=i??P,this.sharedContent=new Ue(t,this),this.ai=new Ot(e),this.ai.setOnRateLimited(n=>{this.eventBus.emit(s.pluginId,"global.quota.triggerExceeded",{exercises_remaining:n})}),this.event=new Pt(s.pluginId,this.ai,this.eventBus),this.db=new vt(t,e,s),this.plugin=new wt(t,e,s,this.ai),this.exercise=new It(t,e,s,this.event),this.storage=new Lt(e),this.plugin.applicationMode!=="sidebar"&&We.getInstance(this)}static createWithInfo(e){const t=L.create("Plugin EventBus "+e.pluginId),s=new me(e.pluginId,!0);s.handleRimoriInfoUpdate(e);const i=new Te(`${e.url}/rest/v1`,{schema:e.dbSchema,headers:{apikey:e.key,Authorization:`Bearer ${e.token}`,"plugin-id":e.pluginId}}),n=new U(s,i,e,t);return t.on(`${e.pluginId}.supabase.triggerUpdate`,o=>{console.log("[RimoriClient] Federated triggerUpdate received for",e.pluginId,"| ttsEnabled:",o.data?.ttsEnabled),s.handleRimoriInfoUpdate(o.data)}),n}static async getInstance(e){if(!U.instance){if(!e)throw new Error("Plugin ID is required");const t=new me(e,!1),s=await t.getClient();U.instance=new U(t,s.supabase,s.info)}return U.instance}navigation={toDashboard:()=>{this.event.emit("global.navigation.triggerToDashboard")}};runtime={fetchBackend:(e,t={})=>this.controller.fetchBackend(e,t)}}const kt="https://pheptqdoqsdnadgoihvr.supabase.co",Ct="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InBoZXB0cWRvcXNkbmFkZ29paHZyIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MzE2OTY2ODcsImV4cCI6MjA0NzI3MjY4N30.4GPFAXTF8685FaXISdAPNCIM-H3RGLo8GbyhQpu1mP0";class q{static instance;config;supabase;constructor(e){throw new Error("Authentication is disabled until new developer platform is released.")}static async getInstance(){if(!q.instance){const e=await fetch("https://app.rimori.se/config.json").then(t=>t.json()).catch(t=>{console.warn("Error fetching config.json, using default values",t)});q.instance=new q({url:e?.SUPABASE_URL||kt,key:e?.SUPABASE_ANON_KEY||Ct,backendUrl:e?.BACKEND_URL||"https://api.rimori.se"})}return q.instance}async getClient(){return this.supabase}async needsLogin(){const{error:e}=await this.supabase.auth.getUser();return e!==null}async login(e,t){const{error:s}=await this.supabase.auth.signInWithPassword({email:e,password:t});return s?(console.error("Login failed:",s),!1):(console.log("Successfully logged in"),!0)}static async initListeners(e){console.warn("The plugin seams to not be running inside the Rimori platform. Switching to development standalone mode.");const{supabase:t,config:s}=await q.getInstance();P.respond("standalone","global.supabase.requestAccess",async()=>{const i=await t.auth.getSession();console.log("session",i);let n=null;try{const{data:{user:l}}=await t.auth.getUser();if(l){const{data:c}=await t.from("profiles").select("current_guild_id").eq("user_id",l.id).maybeSingle();n=c?.current_guild_id||null}}catch{n=null}const o=await fetch(`${s.backendUrl}/plugin/token`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i.data.session?.access_token}`},body:JSON.stringify({pluginId:e,guildId:n})});if(!o.ok){const l=await o.text();throw new Error(`Failed to get plugin token. ${o.status}: ${l}`)}return{token:(await o.json()).token,pluginId:e,url:s.url,key:s.key,backendUrl:s.backendUrl,tablePrefix:e,expiration:new Date(Date.now()+1e3*60*60*1.5)}}),P.on("*",async i=>{console.log("[standalone] would send event to parent",i)},["standalone"])}}class Et{audioContext;chunkQueue=[];isPlaying=!1;analyser;dataArray;shouldMonitorLoudness=!0;isMonitoring=!1;handle=0;volume=1;loudnessCallback=()=>{};currentIndex=0;startedPlaying=!1;onEndOfSpeech=()=>{};backgroundNoiseLevel=30;currentSource=null;stopped=!1;constructor(){this.init()}init(){this.audioContext=new AudioContext,this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=256;const e=this.analyser.frequencyBinCount;this.dataArray=new Uint8Array(e)}setOnLoudnessChange(e){this.loudnessCallback=e}setVolume(e){this.volume=e}async addChunk(e,t){this.stopped||(console.log("Adding chunk",t,e),this.chunkQueue[t]=e,t===0&&!this.startedPlaying&&(this.startedPlaying=!0,this.playChunks()))}playChunks(){if(!(this.isPlaying||this.stopped)){if(!this.chunkQueue[this.currentIndex]){setTimeout(()=>this.playChunks(),10);return}this.isPlaying=!0,this.playChunk(this.chunkQueue[this.currentIndex]).then(()=>{this.isPlaying=!1,!this.stopped&&(this.currentIndex++,this.chunkQueue[this.currentIndex]?(this.shouldMonitorLoudness=!0,this.playChunks()):setTimeout(()=>{this.stopped||(this.chunkQueue.length>this.currentIndex?this.playChunks():(this.startedPlaying=!1,this.shouldMonitorLoudness=!1))},1e3))})}}stopPlayback(){if(this.stopped=!0,this.currentSource){try{this.currentSource.stop()}catch{}this.currentSource=null}this.isPlaying=!1,this.chunkQueue=[],this.startedPlaying=!1,this.shouldMonitorLoudness=!1,cancelAnimationFrame(this.handle),this.loudnessCallback(0)}cleanup(){this.stopPlayback(),this.audioContext&&this.audioContext.state!=="closed"&&this.audioContext.close().catch(e=>{console.warn("Error closing AudioContext:",e)})}playChunk(e){return!e||this.stopped?Promise.resolve():new Promise(t=>{const s=this.audioContext.createBufferSource();this.currentSource=s,this.audioContext.decodeAudioData(e.slice(0)).then(i=>{if(this.stopped){t();return}s.buffer=i;const n=this.audioContext.createGain();n.gain.value=this.volume,s.connect(n),n.connect(this.analyser),this.analyser.connect(this.audioContext.destination),s.start(0),n.gain.value=this.volume,s.onended=()=>{this.currentSource===s&&(this.currentSource=null),t()},this.isMonitoring||(this.isMonitoring=!0,this.shouldMonitorLoudness=!0,this.monitorLoudness())})})}async playAgain(){console.log("Playing again"),this.chunkQueue.length>0&&!this.isPlaying&&this.playChunks()}monitorLoudness(){if(!this.shouldMonitorLoudness){cancelAnimationFrame(this.handle),this.loudnessCallback(0),this.onEndOfSpeech();return}this.analyser.getByteTimeDomainData(this.dataArray);let e=0;for(let s=0;s<this.dataArray.length;s++){const i=this.dataArray[s]/128-1;e+=i*i}const t=Math.sqrt(e/this.dataArray.length);if(t!==0){let s=20*Math.log10(t);const i=-57,n=-15;s<i&&(s=i),s>n&&(s=n);let o=(s-i)/(n-i)*100;o<this.backgroundNoiseLevel?o=0:o=(o-this.backgroundNoiseLevel)/(100-this.backgroundNoiseLevel)*100,this.loudnessCallback(Math.round(o))}this.handle=requestAnimationFrame(()=>this.monitorLoudness())}reset(){this.stopPlayback(),this.stopped=!1,this.currentIndex=0,this.shouldMonitorLoudness=!0,this.isMonitoring=!1,this.isPlaying=!1,this.init()}setOnEndOfSpeech(e){this.onEndOfSpeech=e}}class At{player=new Et;fetchedSentences=new Set;lastLoading=!1;voice;voiceBackend;cache;voiceSpeed=1;instructions;constructor(e,t,s=!1){if(t?.split("_").length!==2)throw new Error("Invalid voice id format '"+t+"'. Voice id needs to look like <provider>_<voice_id>");this.voiceBackend=e,this.voice=t,this.cache=s}getCompletedSentences(e,t){const s=/(.+?[.?!]|.+?:\s+|.+?\n+)/g,i=[];let n;for(;(n=s.exec(e))!==null;){const o=n[0].trim();o.length>0&&i.push(o)}if(!t){const o=i[i.length-1],a=e.lastIndexOf(o)+o.length;a<e.length&&i.push(e.slice(a).trim())}return i}async handleNewText(e,t){if(!this.lastLoading&&t&&this.reset(),this.lastLoading=t,!e)return;const s=this.getCompletedSentences(e,t);for(let i=0;i<s.length;i++){const n=s[i];if(!this.fetchedSentences.has(n)){this.fetchedSentences.add(n);const o=await this.generateSpeech(n);await this.player.addChunk(o,i)}}}setInstructions(e){this.instructions=e}async generateSpeech(e){return await(await this.voiceBackend(e,this.voice,this.voiceSpeed,void 0,this.cache,this.instructions)).arrayBuffer()}play(){this.player.playAgain()}stop(){this.player.stopPlayback()}cleanup(){this.player.cleanup()}reset(){this.stop(),this.fetchedSentences.clear(),this.player.reset()}setVolume(e){this.player.setVolume(e)}setOnLoudnessChange(e){this.player.setOnLoudnessChange(t=>{e(t)})}setOnEndOfSpeech(e){this.player.setOnEndOfSpeech(e)}setVoiceSpeed(e){this.voiceSpeed=e}}const _e=["Pre-A1","A1","A2","B1","B2","C1","C2","Post-C2"];function he(r){return _e.indexOf(r)+1}function $t(r){return _e[r]}function jt(r,e){return $t(he(r)+e-1)}function Mt(r,e){return he(r)-he(e)}async function Dt(r,e){Object.assign(globalThis,{window:{isWorker:!0,location:{},parent:{postMessage:()=>{}},addEventListener:()=>{}}}),L.getInstance("Worker "+r+" EventBus");const s=await U.getInstance(r);console.debug("[Worker] RimoriClient initialized.");const i=new Error("[Worker "+r+"] Worker setup must complete within 5s. Use init event (e.g. onboarding.triggerInitPlugin) or run work async."),n=Promise.resolve(e(s)),o=new Promise((a,l)=>setTimeout(()=>l(i),5e3));await Promise.race([n,o]),console.debug("[Worker] Worker initialized."),s.event.emit("self.rimori.triggerInitFinished")}class _t{pluginId;constructor(e){this.pluginId=e}async startRecording(){P.emit(this.pluginId,"global.microphone.triggerStartRecording")}async stopRecording(){return(await P.request(this.pluginId,"global.microphone.triggerStopRecording")).data}async pauseRecording(){return(await P.request(this.pluginId,"global.microphone.triggerPauseRecording")).data}async resumeRecording(){return(await P.request(this.pluginId,"global.microphone.triggerResumeRecording")).data}async getCurrentStatus(){return(await P.request(this.pluginId,"global.microphone.triggerGetCurrentStatus")).data}}export{_t as AudioController,P as EventBus,L as EventBusHandler,At as MessageSender,Rt as ROLE_ORDER,U as RimoriClient,me as RimoriCommunicationHandler,q as StandaloneClient,Lt as StorageModule,Nt as TIER_ORDER,bt as Translator,Mt as compareLanguageLevels,$t as getDifficultyLabel,he as getDifficultyLevel,jt as getNeighborDifficultyLevel,Dt as setupWorker};
@@ -1 +0,0 @@
1
- import{e as nt,c as M,d as at,a as W,j as Ct,l as j,f as _,b as J}from"./__mfe_internal__rimori_mf_2_scenario_mf_2_host__loadShare__react__loadShare__.js.js";import{_ as Qt}from"./__mfe_internal__rimori_mf_2_scenario_mf_2_host__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.js.js";var I=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Vt=class extends I{#e;#t;#s;constructor(){super(),this.#s=t=>{if(typeof window<"u"&&window.addEventListener){const e=()=>t();return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#t||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#s=t,this.#t?.(),this.#t=t(e=>{typeof e=="boolean"?this.setFocused(e):this.onFocus()})}setFocused(t){this.#e!==t&&(this.#e=t,this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},ot=new Vt,Jt={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Zt=class{#e=Jt;#t=!1;setTimeoutProvider(t){this.#e=t}setTimeout(t,e){return this.#e.setTimeout(t,e)}clearTimeout(t){this.#e.clearTimeout(t)}setInterval(t,e){return this.#e.setInterval(t,e)}clearInterval(t){this.#e.clearInterval(t)}},D=new Zt;function Xt(t){setTimeout(t,0)}var Yt=typeof window>"u"||"Deno"in globalThis;function O(){}function te(t,e){return typeof t=="function"?t(e):t}function Z(t){return typeof t=="number"&&t>=0&&t!==1/0}function Et(t,e){return Math.max(t+(e||0)-Date.now(),0)}function F(t,e){return typeof t=="function"?t(e):t}function S(t,e){return typeof t=="function"?t(e):t}function pt(t,e){const{type:s="all",exact:r,fetchStatus:i,predicate:n,queryKey:a,stale:u}=t;if(a){if(r){if(e.queryHash!==ut(a,e.options))return!1}else if(!q(e.queryKey,a))return!1}if(s!=="all"){const o=e.isActive();if(s==="active"&&!o||s==="inactive"&&o)return!1}return!(typeof u=="boolean"&&e.isStale()!==u||i&&i!==e.state.fetchStatus||n&&!n(e))}function yt(t,e){const{exact:s,status:r,predicate:i,mutationKey:n}=t;if(n){if(!e.options.mutationKey)return!1;if(s){if(T(e.options.mutationKey)!==T(n))return!1}else if(!q(e.options.mutationKey,n))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function ut(t,e){return(e?.queryKeyHashFn||T)(t)}function T(t){return JSON.stringify(t,(e,s)=>X(s)?Object.keys(s).sort().reduce((r,i)=>(r[i]=s[i],r),{}):s)}function q(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(s=>q(t[s],e[s])):!1}var ee=Object.prototype.hasOwnProperty;function $(t,e,s=0){if(t===e)return t;if(s>500)return e;const r=vt(t)&&vt(e);if(!r&&!(X(t)&&X(e)))return e;const n=(r?t:Object.keys(t)).length,a=r?e:Object.keys(e),u=a.length,o=r?new Array(u):{};let c=0;for(let h=0;h<u;h++){const d=r?h:a[h],l=t[d],y=e[d];if(l===y){o[d]=l,(r?h<n:ee.call(t,d))&&c++;continue}if(l===null||y===null||typeof l!="object"||typeof y!="object"){o[d]=y;continue}const m=$(l,y,s+1);o[d]=m,m===l&&c++}return n===u&&c===n?t:o}function x(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(const s in t)if(t[s]!==e[s])return!1;return!0}function vt(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function X(t){if(!mt(t))return!1;const e=t.constructor;if(e===void 0)return!0;const s=e.prototype;return!(!mt(s)||!s.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function mt(t){return Object.prototype.toString.call(t)==="[object Object]"}function se(t){return new Promise(e=>{D.setTimeout(e,t)})}function Y(t,e,s){return typeof s.structuralSharing=="function"?s.structuralSharing(t,e):s.structuralSharing!==!1?$(t,e):e}function Te(t){return t}function Ft(t,e,s=0){const r=[...t,e];return s&&r.length>s?r.slice(1):r}function re(t,e,s=0){const r=[e,...t];return s&&r.length>s?r.slice(0,-1):r}var ht=Symbol();function Mt(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===ht?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function ct(t,e){return typeof t=="function"?t(...e):!!t}function Dt(t,e,s){let r=!1,i;return Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(i??=e(),r||(r=!0,i.aborted?s():i.addEventListener("abort",s,{once:!0})),i)}),t}var U=(()=>{let t=()=>Yt;return{isServer(){return t()},setIsServer(e){t=e}}})();function tt(){let t,e;const s=new Promise((i,n)=>{t=i,e=n});s.status="pending",s.catch(()=>{});function r(i){Object.assign(s,i),delete s.resolve,delete s.reject}return s.resolve=i=>{r({status:"fulfilled",value:i}),t(i)},s.reject=i=>{r({status:"rejected",reason:i}),e(i)},s}function ie(t){let e;if(t.then(s=>(e=s,s),O)?.catch(O),e!==void 0)return{data:e}}function Tt(t){return t}function ne(t){return{mutationKey:t.options.mutationKey,state:t.state,...t.options.scope&&{scope:t.options.scope},...t.meta&&{meta:t.meta}}}function ae(t,e,s){const r=()=>{const i=t.promise?.then(e).catch(n=>s(n)?Promise.reject(new Error("redacted")):Promise.reject(n));return i?.catch(O),i};return{dehydratedAt:Date.now(),state:{...t.state,...t.state.data!==void 0&&{data:e(t.state.data)}},queryKey:t.queryKey,queryHash:t.queryHash,...t.state.status==="pending"&&{promise:r()},...t.meta&&{meta:t.meta},...t.queryType&&{queryType:t.queryType}}}function oe(t){return t.state.isPaused}function ue(t){return t.state.status==="success"}function he(t){return!0}function Ie(t,e={}){const s=e.shouldDehydrateMutation??t.getDefaultOptions().dehydrate?.shouldDehydrateMutation??oe,r=t.getMutationCache().getAll().flatMap(o=>s(o)?[ne(o)]:[]),i=e.shouldDehydrateQuery??t.getDefaultOptions().dehydrate?.shouldDehydrateQuery??ue,n=e.shouldRedactErrors??t.getDefaultOptions().dehydrate?.shouldRedactErrors??he,a=e.serializeData??t.getDefaultOptions().dehydrate?.serializeData??Tt,u=t.getQueryCache().getAll().flatMap(o=>i(o)?[ae(o,a,n)]:[]);return{mutations:r,queries:u}}function gt(t,e,s){if(typeof e!="object"||e===null)return;const r=t.getMutationCache(),i=t.getQueryCache(),n=s?.defaultOptions?.deserializeData??t.getDefaultOptions().hydrate?.deserializeData??Tt,a=e.mutations||[],u=e.queries||[];a.forEach(({state:o,...c})=>{r.build(t,{...t.getDefaultOptions().hydrate?.mutations,...s?.defaultOptions?.mutations,...c},o)}),u.forEach(({queryKey:o,state:c,queryHash:h,meta:d,promise:l,dehydratedAt:y,queryType:m})=>{const f=l?ie(l):void 0,p=c.data===void 0?f?.data:c.data,v=p===void 0?p:n(p);let b=i.get(h);const P=b?.state.status==="pending",R=b?.state.fetchStatus==="fetching";if(b){const Q=f&&y!==void 0&&y>b.state.dataUpdatedAt;if(c.dataUpdatedAt>b.state.dataUpdatedAt||Q){const{fetchStatus:K,...C}=c;b.setState({...C,data:v,...c.status==="pending"&&v!==void 0&&{status:"success",...!R&&{fetchStatus:"idle"}}})}}else b=i.build(t,{...t.getDefaultOptions().hydrate?.queries,...s?.defaultOptions?.queries,queryKey:o,queryHash:h,meta:d,_type:m},{...c,data:v,fetchStatus:"idle",status:c.status==="pending"&&v!==void 0?"success":c.status});l&&!f&&!P&&!R&&(y===void 0||y>b.state.dataUpdatedAt)&&b.fetch(void 0,{initialPromise:Promise.resolve(l).then(n)}).catch(O)})}var ce=Xt;function le(){let t=[],e=0,s=u=>{u()},r=u=>{u()},i=ce;const n=u=>{e?t.push(u):i(()=>{s(u)})},a=()=>{const u=t;t=[],u.length&&i(()=>{r(()=>{u.forEach(o=>{s(o)})})})};return{batch:u=>{let o;e++;try{o=u()}finally{e--,e||a()}return o},batchCalls:u=>(...o)=>{n(()=>{u(...o)})},schedule:n,setNotifyFunction:u=>{s=u},setBatchNotifyFunction:u=>{r=u},setScheduler:u=>{i=u}}}var g=le(),fe=class extends I{#e=!0;#t;#s;constructor(){super(),this.#s=t=>{if(typeof window<"u"&&window.addEventListener){const e=()=>t(!0),s=()=>t(!1);return window.addEventListener("online",e,!1),window.addEventListener("offline",s,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",s)}}}}onSubscribe(){this.#t||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#s=t,this.#t?.(),this.#t=t(this.setOnline.bind(this))}setOnline(t){this.#e!==t&&(this.#e=t,this.listeners.forEach(s=>{s(t)}))}isOnline(){return this.#e}},z=new fe;function de(t){return Math.min(1e3*2**t,3e4)}function It(t){return(t??"online")==="online"?z.isOnline():!0}var G=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function _e(t){return t instanceof G}function _t(t){let e=!1,s=0,r;const i=tt(),n=()=>i.status!=="pending",a=f=>{if(!n()){const p=new G(f);l(p),t.onCancel?.(p)}},u=()=>{e=!0},o=()=>{e=!1},c=()=>ot.isFocused()&&(t.networkMode==="always"||z.isOnline())&&t.canRun(),h=()=>It(t.networkMode)&&t.canRun(),d=f=>{n()||(r?.(),i.resolve(f))},l=f=>{n()||(r?.(),i.reject(f))},y=()=>new Promise(f=>{r=p=>{(n()||c())&&f(p)},t.onPause?.()}).then(()=>{r=void 0,n()||t.onContinue?.()}),m=()=>{if(n())return;let f;const p=s===0?t.initialPromise:void 0;try{f=p??t.fn()}catch(v){f=Promise.reject(v)}Promise.resolve(f).then(d).catch(v=>{if(n())return;const b=t.retry??(U.isServer()?0:3),P=t.retryDelay??de,R=typeof P=="function"?P(s,v):P,Q=b===!0||typeof b=="number"&&s<b||typeof b=="function"&&b(s,v);if(e||!Q){l(v);return}s++,t.onFail?.(s,v),se(R).then(()=>c()?void 0:y()).then(()=>{e?l(v):m()})})};return{promise:i,status:()=>i.status,cancel:a,continue:()=>(r?.(),i),cancelRetry:u,continueRetry:o,canStart:h,start:()=>(h()?m():y().then(m),i)}}var At=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Z(this.gcTime)&&(this.#e=D.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(U.isServer()?1/0:5*60*1e3))}clearGcTimeout(){this.#e!==void 0&&(D.clearTimeout(this.#e),this.#e=void 0)}};function pe(t){return{onFetch:(e,s)=>{const r=e.options,i=e.fetchOptions?.meta?.fetchMore?.direction,n=e.state.data?.pages||[],a=e.state.data?.pageParams||[];let u={pages:[],pageParams:[]},o=0;const c=async()=>{let h=!1;const d=m=>{Dt(m,()=>e.signal,()=>h=!0)},l=Mt(e.options,e.fetchOptions),y=async(m,f,p)=>{if(h)return Promise.reject(e.signal.reason);if(f==null&&m.pages.length)return Promise.resolve(m);const b=(()=>{const K={client:e.client,queryKey:e.queryKey,pageParam:f,direction:p?"backward":"forward",meta:e.options.meta};return d(K),K})(),P=await l(b),{maxPages:R}=e.options,Q=p?re:Ft;return{pages:Q(m.pages,P,R),pageParams:Q(m.pageParams,f,R)}};if(i&&n.length){const m=i==="backward",f=m?qt:et,p={pages:n,pageParams:a},v=f(r,p);u=await y(p,v,m)}else{const m=t??n.length;do{const f=o===0?a[0]??r.initialPageParam:et(r,u);if(o>0&&f==null)break;u=await y(u,f),o++}while(o<m)}return u};e.options.persister?e.fetchFn=()=>e.options.persister?.(c,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},s):e.fetchFn=c}}}function et(t,{pages:e,pageParams:s}){const r=e.length-1;return e.length>0?t.getNextPageParam(e[r],e,s[r],s):void 0}function qt(t,{pages:e,pageParams:s}){return e.length>0?t.getPreviousPageParam?.(e[0],e,s[0],s):void 0}function ye(t,e){return e?et(t,e)!=null:!1}function ve(t,e){return!e||!t.getPreviousPageParam?!1:qt(t,e)!=null}var me=class extends At{#e;#t;#s;#r;#i;#n;#o;#a;constructor(t){super(),this.#a=!1,this.#o=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#i=t.client,this.#r=this.#i.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#t=Ot(this.options),this.state=t.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#n?.promise}setOptions(t){if(this.options={...this.#o,...t},t?._type&&(this.#e=t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const e=Ot(this.options);e.data!==void 0&&(this.setState(bt(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#r.remove(this)}setData(t,e){const s=Y(this.state.data,t,this.options);return this.#u({data:s,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),s}setState(t){this.#u({type:"setState",state:t})}cancel(t){const e=this.#n?.promise;return this.#n?.cancel(t),e?e.then(O).catch(O):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>S(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===ht||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>F(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!Et(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#n?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#n?.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(this.#n&&(this.#a||this.#c()?this.#n.cancel({revert:!0}):this.#n.cancelRetry()),this.scheduleGc()),this.#r.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}#c(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"}invalidate(){this.state.isInvalidated||this.#u({type:"invalidate"})}async fetch(t,e){if(this.state.fetchStatus!=="idle"&&this.#n?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#n)return this.#n.continueRetry(),this.#n.promise}if(t&&this.setOptions(t),!this.options.queryFn){const o=this.observers.find(c=>c.options.queryFn);o&&this.setOptions(o.options)}const s=new AbortController,r=o=>{Object.defineProperty(o,"signal",{enumerable:!0,get:()=>(this.#a=!0,s.signal)})},i=()=>{const o=Mt(this.options,e),h=(()=>{const d={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(d),d})();return this.#a=!1,this.options.persister?this.options.persister(o,h,this):o(h)},a=(()=>{const o={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(o),o})();(this.#e==="infinite"?pe(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#s=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#u({type:"fetch",meta:a.fetchOptions?.meta}),this.#n=_t({initialPromise:e?.initialPromise,fn:a.fetchFn,onCancel:o=>{o instanceof G&&o.revert&&this.setState({...this.#s,fetchStatus:"idle"}),s.abort()},onFail:(o,c)=>{this.#u({type:"failed",failureCount:o,error:c})},onPause:()=>{this.#u({type:"pause"})},onContinue:()=>{this.#u({type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{const o=await this.#n.start();if(o===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(o),this.#r.config.onSuccess?.(o,this),this.#r.config.onSettled?.(o,this.state.error,this),o}catch(o){if(o instanceof G){if(o.silent)return this.#n.promise;if(o.revert){if(this.state.data===void 0)throw o;return this.state.data}}throw this.#u({type:"error",error:o}),this.#r.config.onError?.(o,this),this.#r.config.onSettled?.(this.state.data,o,this),o}finally{this.scheduleGc()}}#u(t){const e=s=>{switch(t.type){case"failed":return{...s,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...s,fetchStatus:"paused"};case"continue":return{...s,fetchStatus:"fetching"};case"fetch":return{...s,...xt(s.data,this.options),fetchMeta:t.meta??null};case"success":const r={...s,...bt(t.data,t.dataUpdatedAt),dataUpdateCount:s.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#s=t.manual?r:void 0,r;case"error":const i=t.error;return{...s,error:i,errorUpdateCount:s.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:s.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...s,isInvalidated:!0};case"setState":return{...s,...t.state}}};this.state=e(this.state),g.batch(()=>{this.observers.forEach(s=>{s.onQueryUpdate()}),this.#r.notify({query:this,type:"updated",action:t})})}};function xt(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:It(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function bt(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Ot(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,s=e!==void 0,r=s?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:s?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:s?"success":"pending",fetchStatus:"idle"}}var k=class extends I{constructor(t,e){super(),this.options=e,this.#e=t,this.#a=null,this.#o=tt(),this.bindMethods(),this.setOptions(e)}#e;#t=void 0;#s=void 0;#r=void 0;#i;#n;#o;#a;#c;#u;#d;#l;#p;#h;#y=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),St(this.#t,this.options)?this.#f():this.updateResult(),this.#b())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return st(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return st(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#O(),this.#S(),this.#t.removeObserver(this)}setOptions(t){const e=this.options,s=this.#t;if(this.options=this.#e.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof S(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#w(),this.#t.setOptions(this.options),e._defaulted&&!x(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const r=this.hasListeners();r&&wt(this.#t,s,this.options,e)&&this.#f(),this.updateResult(),r&&(this.#t!==s||S(this.options.enabled,this.#t)!==S(e.enabled,this.#t)||F(this.options.staleTime,this.#t)!==F(e.staleTime,this.#t))&&this.#v();const i=this.#m();r&&(this.#t!==s||S(this.options.enabled,this.#t)!==S(e.enabled,this.#t)||i!==this.#h)&&this.#g(i)}getOptimisticResult(t){const e=this.#e.getQueryCache().build(this.#e,t),s=this.createResult(e,t);return be(this,s)&&(this.#r=s,this.#n=this.options,this.#i=this.#t.state),s}getCurrentResult(){return this.#r}trackResult(t,e){return new Proxy(t,{get:(s,r)=>(this.trackProp(r),e?.(r),r==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#o.status==="pending"&&this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(s,r))})}trackProp(t){this.#y.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#e.defaultQueryOptions(t),s=this.#e.getQueryCache().build(this.#e,e);return s.fetch().then(()=>this.createResult(s,e))}fetch(t){return this.#f({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#f(t){this.#w();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(O)),e}#v(){this.#O();const t=F(this.options.staleTime,this.#t);if(U.isServer()||this.#r.isStale||!Z(t))return;const s=Et(this.#r.dataUpdatedAt,t)+1;this.#l=D.setTimeout(()=>{this.#r.isStale||this.updateResult()},s)}#m(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#g(t){this.#S(),this.#h=t,!(U.isServer()||S(this.options.enabled,this.#t)===!1||!Z(this.#h)||this.#h===0)&&(this.#p=D.setInterval(()=>{(this.options.refetchIntervalInBackground||ot.isFocused())&&this.#f()},this.#h))}#b(){this.#v(),this.#g(this.#m())}#O(){this.#l!==void 0&&(D.clearTimeout(this.#l),this.#l=void 0)}#S(){this.#p!==void 0&&(D.clearInterval(this.#p),this.#p=void 0)}createResult(t,e){const s=this.#t,r=this.options,i=this.#r,n=this.#i,a=this.#n,o=t!==s?t.state:this.#s,{state:c}=t;let h={...c},d=!1,l;if(e._optimisticResults){const w=this.hasListeners(),A=!w&&St(t,e),L=w&&wt(t,s,e,r);(A||L)&&(h={...h,...xt(c.data,t.options)}),e._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:y,errorUpdatedAt:m,status:f}=h;l=h.data;let p=!1;if(e.placeholderData!==void 0&&l===void 0&&f==="pending"){let w;i?.isPlaceholderData&&e.placeholderData===a?.placeholderData?(w=i.data,p=!0):w=typeof e.placeholderData=="function"?e.placeholderData(this.#d?.state.data,this.#d):e.placeholderData,w!==void 0&&(f="success",l=Y(i?.data,w,e),d=!0)}if(e.select&&l!==void 0&&!p)if(i&&l===n?.data&&e.select===this.#c)l=this.#u;else try{this.#c=e.select,l=e.select(l),l=Y(i?.data,l,e),this.#u=l,this.#a=null}catch(w){this.#a=w}this.#a&&(y=this.#a,l=this.#u,m=Date.now(),f="error");const v=h.fetchStatus==="fetching",b=f==="pending",P=f==="error",R=b&&v,Q=l!==void 0,C={status:f,fetchStatus:h.fetchStatus,isPending:b,isSuccess:f==="success",isError:P,isInitialLoading:R,isLoading:R,data:l,dataUpdatedAt:h.dataUpdatedAt,error:y,errorUpdatedAt:m,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:h.dataUpdateCount>o.dataUpdateCount||h.errorUpdateCount>o.errorUpdateCount,isFetching:v,isRefetching:v&&!b,isLoadingError:P&&!Q,isPaused:h.fetchStatus==="paused",isPlaceholderData:d,isRefetchError:P&&Q,isStale:lt(t,e),refetch:this.refetch,promise:this.#o,isEnabled:S(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const w=C.data!==void 0,A=C.status==="error"&&!w,L=H=>{A?H.reject(C.error):w&&H.resolve(C.data)},dt=()=>{const H=this.#o=C.promise=tt();L(H)},N=this.#o;switch(N.status){case"pending":t.queryHash===s.queryHash&&L(N);break;case"fulfilled":(A||C.data!==N.value)&&dt();break;case"rejected":(!A||C.error!==N.reason)&&dt();break}}return C}updateResult(){const t=this.#r,e=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#n=this.options,this.#i.data!==void 0&&(this.#d=this.#t),x(e,t))return;this.#r=e;const s=()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,i=typeof r=="function"?r():r;if(i==="all"||!i&&!this.#y.size)return!0;const n=new Set(i??this.#y);return this.options.throwOnError&&n.add("error"),Object.keys(this.#r).some(a=>{const u=a;return this.#r[u]!==t[u]&&n.has(u)})};this.#P({listeners:s()})}#w(){const t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;const e=this.#t;this.#t=t,this.#s=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#b()}#P(t){g.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function ge(t,e){return S(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&S(e.retryOnMount,t)===!1)}function St(t,e){return ge(t,e)||t.state.data!==void 0&&st(t,e,e.refetchOnMount)}function st(t,e,s){if(S(e.enabled,t)!==!1&&F(e.staleTime,t)!=="static"){const r=typeof s=="function"?s(t):s;return r==="always"||r!==!1&&lt(t,e)}return!1}function wt(t,e,s,r){return(t!==e||S(r.enabled,t)===!1)&&(!s.suspense||t.state.status!=="error")&&lt(t,s)}function lt(t,e){return S(e.enabled,t)!==!1&&t.isStaleByTime(F(e.staleTime,t))}function be(t,e){return!x(t.getCurrentResult(),e)}var Ut=class extends k{constructor(t,e){super(t,e)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(t){t._type="infinite",super.setOptions(t)}getOptimisticResult(t){return t._type="infinite",super.getOptimisticResult(t)}fetchNextPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"backward"}}})}createResult(t,e){const{state:s}=t,r=super.createResult(t,e),{isFetching:i,isRefetching:n,isError:a,isRefetchError:u}=r,o=s.fetchMeta?.fetchMore?.direction,c=a&&o==="forward",h=i&&o==="forward",d=a&&o==="backward",l=i&&o==="backward";return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:ye(e,s.data),hasPreviousPage:ve(e,s.data),isFetchNextPageError:c,isFetchingNextPage:h,isFetchPreviousPageError:d,isFetchingPreviousPage:l,isRefetchError:u&&!c&&!d,isRefetching:n&&!h&&!l}}},Oe=class extends At{#e;#t;#s;#r;constructor(t){super(),this.#e=t.client,this.mutationId=t.mutationId,this.#s=t.mutationCache,this.#t=[],this.state=t.state||jt(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){this.#t.includes(t)||(this.#t.push(t),this.clearGcTimeout(),this.#s.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#t=this.#t.filter(e=>e!==t),this.scheduleGc(),this.#s.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#s.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(t){const e=()=>{this.#i({type:"continue"})},s={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=_t({fn:()=>this.options.mutationFn?this.options.mutationFn(t,s):Promise.reject(new Error("No mutationFn found")),onFail:(n,a)=>{this.#i({type:"failed",failureCount:n,error:a})},onPause:()=>{this.#i({type:"pause"})},onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#s.canRun(this)});const r=this.state.status==="pending",i=!this.#r.canStart();try{if(r)e();else{this.#i({type:"pending",variables:t,isPaused:i}),this.#s.config.onMutate&&await this.#s.config.onMutate(t,this,s);const a=await this.options.onMutate?.(t,s);a!==this.state.context&&this.#i({type:"pending",context:a,variables:t,isPaused:i})}const n=await this.#r.start();return await this.#s.config.onSuccess?.(n,t,this.state.context,this,s),await this.options.onSuccess?.(n,t,this.state.context,s),await this.#s.config.onSettled?.(n,null,this.state.variables,this.state.context,this,s),await this.options.onSettled?.(n,null,t,this.state.context,s),this.#i({type:"success",data:n}),n}catch(n){try{await this.#s.config.onError?.(n,t,this.state.context,this,s)}catch(a){Promise.reject(a)}try{await this.options.onError?.(n,t,this.state.context,s)}catch(a){Promise.reject(a)}try{await this.#s.config.onSettled?.(void 0,n,this.state.variables,this.state.context,this,s)}catch(a){Promise.reject(a)}try{await this.options.onSettled?.(void 0,n,t,this.state.context,s)}catch(a){Promise.reject(a)}throw this.#i({type:"error",error:n}),n}finally{this.#s.runNext(this)}}#i(t){const e=s=>{switch(t.type){case"failed":return{...s,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...s,isPaused:!0};case"continue":return{...s,isPaused:!1};case"pending":return{...s,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...s,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...s,data:void 0,error:t.error,failureCount:s.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=e(this.state),g.batch(()=>{this.#t.forEach(s=>{s.onMutationUpdate(t)}),this.#s.notify({mutation:this,type:"updated",action:t})})}};function jt(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Se=class extends I{constructor(t={}){super(),this.config=t,this.#e=new Set,this.#t=new Map,this.#s=0}#e;#t;#s;build(t,e,s){const r=new Oe({client:t,mutationCache:this,mutationId:++this.#s,options:t.defaultMutationOptions(e),state:s});return this.add(r),r}add(t){this.#e.add(t);const e=B(t);if(typeof e=="string"){const s=this.#t.get(e);s?s.push(t):this.#t.set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(this.#e.delete(t)){const e=B(t);if(typeof e=="string"){const s=this.#t.get(e);if(s)if(s.length>1){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}else s[0]===t&&this.#t.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){const e=B(t);if(typeof e=="string"){const r=this.#t.get(e)?.find(i=>i.state.status==="pending");return!r||r===t}else return!0}runNext(t){const e=B(t);return typeof e=="string"?this.#t.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){g.batch(()=>{this.#e.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(t){const e={exact:!0,...t};return this.getAll().find(s=>yt(e,s))}findAll(t={}){return this.getAll().filter(e=>yt(t,e))}notify(t){g.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return g.batch(()=>Promise.all(t.map(e=>e.continue().catch(O))))}};function B(t){return t.options.scope?.id}var we=class extends I{#e;#t=void 0;#s;#r;constructor(t,e){super(),this.#e=t,this.setOptions(e),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){const e=this.options;this.options=this.#e.defaultMutationOptions(t),x(this.options,e)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#s,observer:this}),e?.mutationKey&&this.options.mutationKey&&T(e.mutationKey)!==T(this.options.mutationKey)?this.reset():this.#s?.state.status==="pending"&&this.#s.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#s?.removeObserver(this)}onMutationUpdate(t){this.#i(),this.#n(t)}getCurrentResult(){return this.#t}reset(){this.#s?.removeObserver(this),this.#s=void 0,this.#i(),this.#n()}mutate(t,e){return this.#r=e,this.#s?.removeObserver(this),this.#s=this.#e.getMutationCache().build(this.#e,this.options),this.#s.addObserver(this),this.#s.execute(t)}#i(){const t=this.#s?.state??jt();this.#t={...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset}}#n(t){g.batch(()=>{if(this.#r&&this.hasListeners()){const e=this.#t.variables,s=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(t?.type==="success"){try{this.#r.onSuccess?.(t.data,e,s,r)}catch(i){Promise.reject(i)}try{this.#r.onSettled?.(t.data,null,e,s,r)}catch(i){Promise.reject(i)}}else if(t?.type==="error"){try{this.#r.onError?.(t.error,e,s,r)}catch(i){Promise.reject(i)}try{this.#r.onSettled?.(void 0,t.error,e,s,r)}catch(i){Promise.reject(i)}}}this.listeners.forEach(e=>{e(this.#t)})})}};function Pt(t,e){const s=new Set(e);return t.filter(r=>!s.has(r))}function Pe(t,e,s){const r=t.slice(0);return r[e]=s,r}var Re=class extends I{#e;#t;#s;#r;#i;#n;#o;#a;#c;#u=[];constructor(t,e,s){super(),this.#e=t,this.#r=s,this.#s=[],this.#i=[],this.#t=[],this.setQueries(e)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(t=>{t.subscribe(e=>{this.#y(t,e)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(t=>{t.destroy()})}setQueries(t,e){this.#s=t,this.#r=e,g.batch(()=>{const s=this.#i,r=this.#h(this.#s);r.forEach(h=>h.observer.setOptions(h.defaultedQueryOptions));const i=r.map(h=>h.observer),n=i.map(h=>h.getCurrentResult()),a=s.length!==i.length,u=i.some((h,d)=>h!==s[d]),o=a||u,c=o?!0:n.some((h,d)=>{const l=this.#t[d];return!l||!x(h,l)});!o&&!c||(o&&(this.#u=r,this.#i=i),this.#t=n,this.hasListeners()&&(o&&(Pt(s,i).forEach(h=>{h.destroy()}),Pt(i,s).forEach(h=>{h.subscribe(d=>{this.#y(h,d)})})),this.#f()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(t=>t.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(t,e){const s=this.#h(t),r=s.map(n=>n.observer.getOptimisticResult(n.defaultedQueryOptions)),i=s.map(n=>n.defaultedQueryOptions.queryHash);return[r,n=>this.#l(n??r,e,i),()=>this.#d(r,s)]}#d(t,e){return e.map((s,r)=>{const i=t[r];return s.defaultedQueryOptions.notifyOnChangeProps?i:s.observer.trackResult(i,n=>{e.forEach(a=>{a.observer.trackProp(n)})})})}#l(t,e,s){if(e){const r=this.#c,i=s!==void 0&&r!==void 0&&(r.length!==s.length||s.some((n,a)=>n!==r[a]));return(!this.#n||this.#t!==this.#a||i||e!==this.#o)&&(this.#o=e,this.#a=this.#t,s!==void 0&&(this.#c=s),this.#n=$(this.#n,e(t))),this.#n}return t}#p(){return this.#r?.combine!==void 0&&this.#i.some((t,e)=>t.options.suspense&&this.#t[e]?.data===void 0)}#h(t){const e=new Map;this.#i.forEach(r=>{const i=r.options.queryHash;if(!i)return;const n=e.get(i);n?n.push(r):e.set(i,[r])});const s=[];return t.forEach(r=>{const i=this.#e.defaultQueryOptions(r),a=e.get(i.queryHash)?.shift()??new k(this.#e,i);s.push({defaultedQueryOptions:i,observer:a})}),s}#y(t,e){const s=this.#i.indexOf(t);s!==-1&&(this.#t=Pe(this.#t,s,e),this.#f())}#f(){if(this.hasListeners()){const t=this.#d(this.#t,this.#u),e=this.#p(),s=this.#n,r=e?s:this.#l(t,this.#r?.combine);(e||s!==r)&&g.batch(()=>{this.listeners.forEach(i=>{i(this.#t)})})}}},Ce=class extends I{constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,e,s){const r=e.queryKey,i=e.queryHash??ut(r,e);let n=this.get(i);return n||(n=new me({client:t,queryKey:r,queryHash:i,options:t.defaultQueryOptions(e),state:s,defaultOptions:t.getQueryDefaults(r)}),this.add(n)),n}add(t){this.#e.has(t.queryHash)||(this.#e.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const e=this.#e.get(t.queryHash);e&&(t.destroy(),e===t&&this.#e.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){g.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#e.get(t)}getAll(){return[...this.#e.values()]}find(t){const e={exact:!0,...t};return this.getAll().find(s=>pt(e,s))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(s=>pt(t,s)):e}notify(t){g.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){g.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){g.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Ae=class{#e;#t;#s;#r;#i;#n;#o;#a;constructor(t={}){this.#e=t.queryCache||new Ce,this.#t=t.mutationCache||new Se,this.#s=t.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#n=0}mount(){this.#n++,this.#n===1&&(this.#o=ot.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=z.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#n--,this.#n===0&&(this.#o?.(),this.#o=void 0,this.#a?.(),this.#a=void 0)}isFetching(t){return this.#e.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#t.findAll({...t,status:"pending"}).length}getQueryData(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),s=this.#e.build(this,e),r=s.state.data;return r===void 0?this.fetchQuery(t):(t.revalidateIfStale&&s.isStaleByTime(F(e.staleTime,s))&&this.prefetchQuery(e),Promise.resolve(r))}getQueriesData(t){return this.#e.findAll(t).map(({queryKey:e,state:s})=>{const r=s.data;return[e,r]})}setQueryData(t,e,s){const r=this.defaultQueryOptions({queryKey:t}),n=this.#e.get(r.queryHash)?.state.data,a=te(e,n);if(a!==void 0)return this.#e.build(this,r).setData(a,{...s,manual:!0})}setQueriesData(t,e,s){return g.batch(()=>this.#e.findAll(t).map(({queryKey:r})=>[r,this.setQueryData(r,e,s)]))}getQueryState(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state}removeQueries(t){const e=this.#e;g.batch(()=>{e.findAll(t).forEach(s=>{e.remove(s)})})}resetQueries(t,e){const s=this.#e;return g.batch(()=>(s.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const s={revert:!0,...e},r=g.batch(()=>this.#e.findAll(t).map(i=>i.cancel(s)));return Promise.all(r).then(O).catch(O)}invalidateQueries(t,e={}){return g.batch(()=>(this.#e.findAll(t).forEach(s=>{s.invalidate()}),t?.refetchType==="none"?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e)))}refetchQueries(t,e={}){const s={...e,cancelRefetch:e.cancelRefetch??!0},r=g.batch(()=>this.#e.findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let n=i.fetch(void 0,s);return s.throwOnError||(n=n.catch(O)),i.state.fetchStatus==="paused"?Promise.resolve():n}));return Promise.all(r).then(O)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const s=this.#e.build(this,e);return s.isStaleByTime(F(e.staleTime,s))?s.fetch(e):Promise.resolve(s.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(O).catch(O)}fetchInfiniteQuery(t){return t._type="infinite",this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(O).catch(O)}ensureInfiniteQueryData(t){return t._type="infinite",this.ensureQueryData(t)}resumePausedMutations(){return z.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#s}setDefaultOptions(t){this.#s=t}setQueryDefaults(t,e){this.#r.set(T(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#r.values()],s={};return e.forEach(r=>{q(t,r.queryKey)&&Object.assign(s,r.defaultOptions)}),s}setMutationDefaults(t,e){this.#i.set(T(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#i.values()],s={};return e.forEach(r=>{q(t,r.mutationKey)&&Object.assign(s,r.defaultOptions)}),s}defaultQueryOptions(t){if(t._defaulted)return t;const e={...this.#s.queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=ut(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===ht&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#s.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}};function qe({streamFn:t,refetchMode:e="reset",reducer:s=(i,n)=>Ft(i,n),initialValue:r=[]}){return async i=>{const n=i.client.getQueryCache().find({queryKey:i.queryKey,exact:!0}),a=!!n&&n.isFetched();a&&e==="reset"&&n.setState({...n.resetState,fetchStatus:"fetching"});let u=r,o=!1;const c=Dt({client:i.client,meta:i.meta,queryKey:i.queryKey,pageParam:i.pageParam,direction:i.direction},()=>i.signal,()=>o=!0),h=await t(c),d=a&&e==="replace";for await(const l of h){if(o)break;d?u=s(u,l):i.client.setQueryData(i.queryKey,y=>s(y===void 0?r:y,l))}return d&&!o&&i.client.setQueryData(i.queryKey,u),i.client.getQueryData(i.queryKey)??r}}var xe=Symbol("dataTagSymbol"),Ue=Symbol("dataTagErrorSymbol"),je=Symbol("unsetMarker"),kt=nt(void 0),E=t=>{const e=at(kt);if(t)return t;if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},ke=({client:t,children:e})=>(M(()=>(t.mount(),()=>{t.unmount()}),[t]),Qt(kt.Provider,{value:t,children:e})),Kt=nt(!1),Lt=()=>at(Kt),Ke=Kt.Provider;function Nt(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Ht=nt(Nt()),Bt=()=>at(Ht),Le=({children:t})=>{const[e]=W(()=>Nt());return Qt(Ht.Provider,{value:e,children:typeof t=="function"?t(e):t})},zt=(t,e,s)=>{const r=s?.state.error&&typeof t.throwOnError=="function"?ct(t.throwOnError,[s.state.error,s]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||r)&&(e.isReset()||(t.retryOnMount=!1))},Gt=t=>{M(()=>{t.clearReset()},[t])},Wt=({result:t,errorResetBoundary:e,throwOnError:s,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||ct(s,[t.error,r])),ft=(t,e)=>e.state.data===void 0,$t=t=>{if(t.suspense){const s=i=>i==="static"?i:Math.max(i??1e3,1e3),r=t.staleTime;t.staleTime=typeof r=="function"?(...i)=>s(r(...i)):s(r),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},Qe=(t,e)=>t.isLoading&&t.isFetching&&!e,rt=(t,e)=>t?.suspense&&e.isPending,it=(t,e,s)=>e.fetchOptimistic(t).catch(()=>{s.clearReset()});function Ee({queries:t,...e},s){const r=E(s),i=Lt(),n=Bt(),a=Ct(()=>t.map(f=>{const p=r.defaultQueryOptions(f);return p._optimisticResults=i?"isRestoring":"optimistic",p}),[t,r,i]);a.forEach(f=>{$t(f);const p=r.getQueryCache().get(f.queryHash);zt(f,n,p)}),Gt(n);const[u]=W(()=>new Re(r,a,e)),[o,c,h]=u.getOptimisticResult(a,e.combine),d=!i&&e.subscribed!==!1;j(_(f=>d?u.subscribe(g.batchCalls(f)):O,[u,d]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),M(()=>{u.setQueries(a,e)},[a,e,u]);const y=o.some((f,p)=>rt(a[p],f))?o.flatMap((f,p)=>{const v=a[p];if(v&&rt(v,f)){const b=new k(r,v);return it(v,b,n)}return[]}):[];if(y.length>0)throw Promise.all(y);const m=o.find((f,p)=>{const v=a[p];return v&&Wt({result:f,errorResetBoundary:n,throwOnError:v.throwOnError,query:r.getQueryCache().get(v.queryHash),suspense:v.suspense})});if(m?.error)throw m.error;return c(h())}function V(t,e,s){const r=Lt(),i=Bt(),n=E(s),a=n.defaultQueryOptions(t);n.getDefaultOptions().queries?._experimental_beforeQuery?.(a);const u=n.getQueryCache().get(a.queryHash);a._optimisticResults=r?"isRestoring":"optimistic",$t(a),zt(a,i,u),Gt(i);const o=!n.getQueryCache().get(a.queryHash),[c]=W(()=>new e(n,a)),h=c.getOptimisticResult(a),d=!r&&t.subscribed!==!1;if(j(_(l=>{const y=d?c.subscribe(g.batchCalls(l)):O;return c.updateResult(),y},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),M(()=>{c.setOptions(a)},[a,c]),rt(a,h))throw it(a,c,i);if(Wt({result:h,errorResetBoundary:i,throwOnError:a.throwOnError,query:u,suspense:a.suspense}))throw h.error;return n.getDefaultOptions().queries?._experimental_afterQuery?.(a,h),a.experimental_prefetchInRender&&!U.isServer()&&Qe(h,r)&&(o?it(a,c,i):u?.promise)?.catch(O).finally(()=>{c.updateResult()}),a.notifyOnChangeProps?h:c.trackResult(h)}function Ne(t,e){return V(t,k,e)}function He(t,e){return V({...t,enabled:!0,suspense:!0,throwOnError:ft,placeholderData:void 0},k,e)}function Be(t,e){return V({...t,enabled:!0,suspense:!0,throwOnError:ft},Ut,e)}function ze(t,e){return Ee({...t,queries:t.queries.map(s=>({...s,suspense:!0,throwOnError:ft,enabled:!0,placeholderData:void 0}))},e)}function Ge(t,e){const s=E(e);s.getQueryState(t.queryKey)||s.prefetchQuery(t)}function We(t,e){const s=E(e);s.getQueryState(t.queryKey)||s.prefetchInfiniteQuery(t)}function $e(t){return t}function Ve(t){return t}var Je=({children:t,options:e={},state:s,queryClient:r})=>{const i=E(r),n=J(e);M(()=>{n.current=e});const a=Ct(()=>{if(s){if(typeof s!="object")return;const u=i.getQueryCache(),o=s.queries||[],c=[],h=[];for(const d of o){const l=u.get(d.queryHash);l?(d.state.dataUpdatedAt>l.state.dataUpdatedAt||d.promise&&l.state.status!=="pending"&&l.state.fetchStatus!=="fetching"&&d.dehydratedAt!==void 0&&d.dehydratedAt>l.state.dataUpdatedAt)&&h.push(d):c.push(d)}if(c.length>0&&gt(i,{queries:c},n.current),h.length>0)return h}},[i,s]);return M(()=>{a&&gt(i,{queries:a},n.current)},[i,a]),t};function Ze(t,e){const s=E(e),r=s.getQueryCache();return j(_(i=>r.subscribe(g.batchCalls(i)),[r]),()=>s.isFetching(t),()=>s.isFetching(t))}function Xe(t,e){const s=E(e);return Fe({filters:{...t,status:"pending"}},s).length}function Rt(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function Fe(t={},e){const s=E(e).getMutationCache(),r=J(t),i=J(null);return i.current===null&&(i.current=Rt(s,t)),M(()=>{r.current=t}),j(_(n=>s.subscribe(()=>{const a=$(i.current,Rt(s,r.current));i.current!==a&&(i.current=a,g.schedule(n))}),[s]),()=>i.current,()=>i.current)}function Ye(t,e){const s=E(e),[r]=W(()=>new we(s,t));M(()=>{r.setOptions(t)},[r,t]);const i=j(_(a=>r.subscribe(g.batchCalls(a)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),n=_((a,u)=>{r.mutate(a,u).catch(O)},[r]);if(i.error&&ct(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:n,mutateAsync:i.mutate}}function ts(t){return t}function es(t,e){return V(t,Ut,e)}export{G as CancelledError,Je as HydrationBoundary,Ut as InfiniteQueryObserver,Ke as IsRestoringProvider,Oe as Mutation,Se as MutationCache,we as MutationObserver,Re as QueriesObserver,me as Query,Ce as QueryCache,Ae as QueryClient,kt as QueryClientContext,ke as QueryClientProvider,Le as QueryErrorResetBoundary,k as QueryObserver,Ue as dataTagErrorSymbol,xe as dataTagSymbol,ce as defaultScheduler,oe as defaultShouldDehydrateMutation,ue as defaultShouldDehydrateQuery,Ie as dehydrate,U as environmentManager,qe as experimental_streamedQuery,ot as focusManager,T as hashKey,gt as hydrate,Ve as infiniteQueryOptions,_e as isCancelledError,Yt as isServer,Te as keepPreviousData,yt as matchMutation,pt as matchQuery,ts as mutationOptions,O as noop,g as notifyManager,z as onlineManager,q as partialMatchKey,$e as queryOptions,$ as replaceEqualDeep,ct as shouldThrowError,ht as skipToken,D as timeoutManager,je as unsetMarker,es as useInfiniteQuery,Ze as useIsFetching,Xe as useIsMutating,Lt as useIsRestoring,Ye as useMutation,Fe as useMutationState,We as usePrefetchInfiniteQuery,Ge as usePrefetchQuery,Ee as useQueries,Ne as useQuery,E as useQueryClient,Bt as useQueryErrorResetBoundary,Be as useSuspenseInfiniteQuery,ze as useSuspenseQueries,He as useSuspenseQuery};
@@ -1,9 +0,0 @@
1
- function x(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function M(t,e){for(var r=0;r<e.length;r++){const n=e[r];if(typeof n!="string"&&!Array.isArray(n)){for(const o in n)if(o!=="default"&&!(o in t)){const s=Object.getOwnPropertyDescriptor(n,o);s&&Object.defineProperty(t,o,s.get?s:{enumerable:!0,get:()=>n[o]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var w={exports:{}},u={};/**
2
- * @license React
3
- * react.production.js
4
- *
5
- * Copyright (c) Meta Platforms, Inc. and affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var v=Symbol.for("react.transitional.element"),I=Symbol.for("react.portal"),b=Symbol.for("react.fragment"),k=Symbol.for("react.strict_mode"),L=Symbol.for("react.profiler"),U=Symbol.for("react.consumer"),D=Symbol.for("react.context"),q=Symbol.for("react.forward_ref"),z=Symbol.for("react.suspense"),G=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),K=Symbol.for("react.activity"),g=Symbol.iterator;function B(t){return t===null||typeof t!="object"?null:(t=g&&t[g]||t["@@iterator"],typeof t=="function"?t:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},j=Object.assign,P={};function l(t,e,r){this.props=t,this.context=e,this.refs=P,this.updater=r||h}l.prototype.isReactComponent={};l.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")};l.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function H(){}H.prototype=l.prototype;function T(t,e,r){this.props=t,this.context=e,this.refs=P,this.updater=r||h}var m=T.prototype=new H;m.constructor=T;j(m,l.prototype);m.isPureReactComponent=!0;var d=Array.isArray;function E(){}var i={H:null,A:null,T:null,S:null},$=Object.prototype.hasOwnProperty;function R(t,e,r){var n=r.ref;return{$$typeof:v,type:t,key:e,ref:n!==void 0?n:null,props:r}}function W(t,e){return R(t.type,e,t.props)}function C(t){return typeof t=="object"&&t!==null&&t.$$typeof===v}function Q(t){var e={"=":"=0",":":"=2"};return"$"+t.replace(/[=:]/g,function(r){return e[r]})}var A=/\/+/g;function y(t,e){return typeof t=="object"&&t!==null&&t.key!=null?Q(""+t.key):e.toString(36)}function X(t){switch(t.status){case"fulfilled":return t.value;case"rejected":throw t.reason;default:switch(typeof t.status=="string"?t.then(E,E):(t.status="pending",t.then(function(e){t.status==="pending"&&(t.status="fulfilled",t.value=e)},function(e){t.status==="pending"&&(t.status="rejected",t.reason=e)})),t.status){case"fulfilled":return t.value;case"rejected":throw t.reason}}throw t}function a(t,e,r,n,o){var s=typeof t;(s==="undefined"||s==="boolean")&&(t=null);var f=!1;if(t===null)f=!0;else switch(s){case"bigint":case"string":case"number":f=!0;break;case"object":switch(t.$$typeof){case v:case I:f=!0;break;case O:return f=t._init,a(f(t._payload),e,r,n,o)}}if(f)return o=o(t),f=n===""?"."+y(t,0):n,d(o)?(r="",f!=null&&(r=f.replace(A,"$&/")+"/"),a(o,e,r,"",function(Y){return Y})):o!=null&&(C(o)&&(o=W(o,r+(o.key==null||t&&t.key===o.key?"":(""+o.key).replace(A,"$&/")+"/")+f)),e.push(o)),1;f=0;var p=n===""?".":n+":";if(d(t))for(var c=0;c<t.length;c++)n=t[c],s=p+y(n,c),f+=a(n,e,r,s,o);else if(c=B(t),typeof c=="function")for(t=c.call(t),c=0;!(n=t.next()).done;)n=n.value,s=p+y(n,c++),f+=a(n,e,r,s,o);else if(s==="object"){if(typeof t.then=="function")return a(X(t),e,r,n,o);throw e=String(t),Error("Objects are not valid as a React child (found: "+(e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)+"). If you meant to render a collection of children, use an array instead.")}return f}function _(t,e,r){if(t==null)return t;var n=[],o=0;return a(t,n,"","",function(s){return e.call(r,s,o++)}),n}function Z(t){if(t._status===-1){var e=t._result;e=e(),e.then(function(r){(t._status===0||t._status===-1)&&(t._status=1,t._result=r)},function(r){(t._status===0||t._status===-1)&&(t._status=2,t._result=r)}),t._status===-1&&(t._status=0,t._result=e)}if(t._status===1)return t._result.default;throw t._result}var S=typeof reportError=="function"?reportError:function(t){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var e=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof t=="object"&&t!==null&&typeof t.message=="string"?String(t.message):String(t),error:t});if(!window.dispatchEvent(e))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",t);return}console.error(t)},J={map:_,forEach:function(t,e,r){_(t,function(){e.apply(this,arguments)},r)},count:function(t){var e=0;return _(t,function(){e++}),e},toArray:function(t){return _(t,function(e){return e})||[]},only:function(t){if(!C(t))throw Error("React.Children.only expected to receive a single React element child.");return t}};u.Activity=K;u.Children=J;u.Component=l;u.Fragment=b;u.Profiler=L;u.PureComponent=T;u.StrictMode=k;u.Suspense=z;u.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i;u.__COMPILER_RUNTIME={__proto__:null,c:function(t){return i.H.useMemoCache(t)}};u.cache=function(t){return function(){return t.apply(null,arguments)}};u.cacheSignal=function(){return null};u.cloneElement=function(t,e,r){if(t==null)throw Error("The argument must be a React element, but you passed "+t+".");var n=j({},t.props),o=t.key;if(e!=null)for(s in e.key!==void 0&&(o=""+e.key),e)!$.call(e,s)||s==="key"||s==="__self"||s==="__source"||s==="ref"&&e.ref===void 0||(n[s]=e[s]);var s=arguments.length-2;if(s===1)n.children=r;else if(1<s){for(var f=Array(s),p=0;p<s;p++)f[p]=arguments[p+2];n.children=f}return R(t.type,o,n)};u.createContext=function(t){return t={$$typeof:D,_currentValue:t,_currentValue2:t,_threadCount:0,Provider:null,Consumer:null},t.Provider=t,t.Consumer={$$typeof:U,_context:t},t};u.createElement=function(t,e,r){var n,o={},s=null;if(e!=null)for(n in e.key!==void 0&&(s=""+e.key),e)$.call(e,n)&&n!=="key"&&n!=="__self"&&n!=="__source"&&(o[n]=e[n]);var f=arguments.length-2;if(f===1)o.children=r;else if(1<f){for(var p=Array(f),c=0;c<f;c++)p[c]=arguments[c+2];o.children=p}if(t&&t.defaultProps)for(n in f=t.defaultProps,f)o[n]===void 0&&(o[n]=f[n]);return R(t,s,o)};u.createRef=function(){return{current:null}};u.forwardRef=function(t){return{$$typeof:q,render:t}};u.isValidElement=C;u.lazy=function(t){return{$$typeof:O,_payload:{_status:-1,_result:t},_init:Z}};u.memo=function(t,e){return{$$typeof:G,type:t,compare:e===void 0?null:e}};u.startTransition=function(t){var e=i.T,r={};i.T=r;try{var n=t(),o=i.S;o!==null&&o(r,n),typeof n=="object"&&n!==null&&typeof n.then=="function"&&n.then(E,S)}catch(s){S(s)}finally{e!==null&&r.types!==null&&(e.types=r.types),i.T=e}};u.unstable_useCacheRefresh=function(){return i.H.useCacheRefresh()};u.use=function(t){return i.H.use(t)};u.useActionState=function(t,e,r){return i.H.useActionState(t,e,r)};u.useCallback=function(t,e){return i.H.useCallback(t,e)};u.useContext=function(t){return i.H.useContext(t)};u.useDebugValue=function(){};u.useDeferredValue=function(t,e){return i.H.useDeferredValue(t,e)};u.useEffect=function(t,e){return i.H.useEffect(t,e)};u.useEffectEvent=function(t){return i.H.useEffectEvent(t)};u.useId=function(){return i.H.useId()};u.useImperativeHandle=function(t,e,r){return i.H.useImperativeHandle(t,e,r)};u.useInsertionEffect=function(t,e){return i.H.useInsertionEffect(t,e)};u.useLayoutEffect=function(t,e){return i.H.useLayoutEffect(t,e)};u.useMemo=function(t,e){return i.H.useMemo(t,e)};u.useOptimistic=function(t,e){return i.H.useOptimistic(t,e)};u.useReducer=function(t,e,r){return i.H.useReducer(t,e,r)};u.useRef=function(t){return i.H.useRef(t)};u.useState=function(t){return i.H.useState(t)};u.useSyncExternalStore=function(t,e,r){return i.H.useSyncExternalStore(t,e,r)};u.useTransition=function(){return i.H.useTransition()};u.version="19.2.5";w.exports=u;var N=w.exports;const V=x(N),tt=M({__proto__:null,default:V},[N]);export{tt as i};
@@ -1,9 +0,0 @@
1
- import{r as _}from"./__mfe_internal__rimori_mf_2_scenario_mf_2_host__loadShare__react__loadShare__.js_commonjs-proxy.js";function m(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function v(r,e){for(var t=0;t<e.length;t++){const a=e[t];if(typeof a!="string"&&!Array.isArray(a)){for(const c in a)if(c!=="default"&&!(c in r)){const g=Object.getOwnPropertyDescriptor(a,c);g&&Object.defineProperty(r,c,g.get?g:{enumerable:!0,get:()=>a[c]})}}}return Object.freeze(Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}))}var s={exports:{}},i={};/**
2
- * @license React
3
- * react-dom.production.js
4
- *
5
- * Copyright (c) Meta Platforms, Inc. and affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var O=_;function d(r){var e="https://react.dev/errors/"+r;if(1<arguments.length){e+="?args[]="+encodeURIComponent(arguments[1]);for(var t=2;t<arguments.length;t++)e+="&args[]="+encodeURIComponent(arguments[t])}return"Minified React error #"+r+"; visit "+e+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function f(){}var n={d:{f,r:function(){throw Error(d(522))},D:f,C:f,L:f,m:f,X:f,S:f,M:f},p:0,findDOMNode:null},S=Symbol.for("react.portal");function E(r,e,t){var a=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:S,key:a==null?null:""+a,children:r,containerInfo:e,implementation:t}}var u=O.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function y(r,e){if(r==="font")return"";if(typeof e=="string")return e==="use-credentials"?e:""}i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=n;i.createPortal=function(r,e){var t=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)throw Error(d(299));return E(r,e,null,t)};i.flushSync=function(r){var e=u.T,t=n.p;try{if(u.T=null,n.p=2,r)return r()}finally{u.T=e,n.p=t,n.d.f()}};i.preconnect=function(r,e){typeof r=="string"&&(e?(e=e.crossOrigin,e=typeof e=="string"?e==="use-credentials"?e:"":void 0):e=null,n.d.C(r,e))};i.prefetchDNS=function(r){typeof r=="string"&&n.d.D(r)};i.preinit=function(r,e){if(typeof r=="string"&&e&&typeof e.as=="string"){var t=e.as,a=y(t,e.crossOrigin),c=typeof e.integrity=="string"?e.integrity:void 0,g=typeof e.fetchPriority=="string"?e.fetchPriority:void 0;t==="style"?n.d.S(r,typeof e.precedence=="string"?e.precedence:void 0,{crossOrigin:a,integrity:c,fetchPriority:g}):t==="script"&&n.d.X(r,{crossOrigin:a,integrity:c,fetchPriority:g,nonce:typeof e.nonce=="string"?e.nonce:void 0})}};i.preinitModule=function(r,e){if(typeof r=="string")if(typeof e=="object"&&e!==null){if(e.as==null||e.as==="script"){var t=y(e.as,e.crossOrigin);n.d.M(r,{crossOrigin:t,integrity:typeof e.integrity=="string"?e.integrity:void 0,nonce:typeof e.nonce=="string"?e.nonce:void 0})}}else e==null&&n.d.M(r)};i.preload=function(r,e){if(typeof r=="string"&&typeof e=="object"&&e!==null&&typeof e.as=="string"){var t=e.as,a=y(t,e.crossOrigin);n.d.L(r,t,{crossOrigin:a,integrity:typeof e.integrity=="string"?e.integrity:void 0,nonce:typeof e.nonce=="string"?e.nonce:void 0,type:typeof e.type=="string"?e.type:void 0,fetchPriority:typeof e.fetchPriority=="string"?e.fetchPriority:void 0,referrerPolicy:typeof e.referrerPolicy=="string"?e.referrerPolicy:void 0,imageSrcSet:typeof e.imageSrcSet=="string"?e.imageSrcSet:void 0,imageSizes:typeof e.imageSizes=="string"?e.imageSizes:void 0,media:typeof e.media=="string"?e.media:void 0})}};i.preloadModule=function(r,e){if(typeof r=="string")if(e){var t=y(e.as,e.crossOrigin);n.d.m(r,{as:typeof e.as=="string"&&e.as!=="script"?e.as:void 0,crossOrigin:t,integrity:typeof e.integrity=="string"?e.integrity:void 0})}else n.d.m(r)};i.requestFormReset=function(r){n.d.r(r)};i.unstable_batchedUpdates=function(r,e){return r(e)};i.useFormState=function(r,e,t){return u.H.useFormState(r,e,t)};i.useFormStatus=function(){return u.H.useHostTransitionStatus()};i.version="19.2.5";function l(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(l)}catch(r){console.error(r)}}l(),s.exports=i;var o=s.exports;const T=m(o),p=v({__proto__:null,default:T},[o]);export{p as i};