// @bun
import{f as x}from"../chunk-e2713ftx.js";import{i as S}from"../chunk-es84e2a1.js";import"../chunk-9p1z3vnt.js";import"../chunk-e4vawn5g.js";import"../chunk-9p8h8aej.js";import"../chunk-07keqpsw.js";import"../chunk-8ty8fefr.js";import"../chunk-2vpsbhpm.js";import{createElement as $,Fragment as e,isValidElement as b}from"react";function y(r,n){let s=Object.values(n).some((o)=>typeof o==="function"&&b(o(""))),g=/{{([^{}]+?)(?::([^{}\[\]]+?))?(?:\[(.*?)\])?}}/g;if(!s)return r.replace(g,(f,d,t,w)=>{let P=d.includes(":")?d.split(":")[0]:d,i=n[P];if(i===void 0)return f;if(typeof i==="function"){let U=i(w!==void 0?w:"");if(b(U))throw Error("JSX returned in string context");return String(U)}if(t)switch(t.toLowerCase()){case"number":return Number(i).toString();case"string":return String(i);case"boolean":return Boolean(i).toString();default:return String(i)}return String(i)});else{let o=[],f=0,d=null;while((d=g.exec(r))!==null){let[t,w,P,i]=d,c=d.index,U=w.includes(":")?w.split(":")[0]:w;if(c>f)o.push(r.substring(f,c));let T=n[U];if(T===void 0)o.push(t);else if(typeof T==="function"){let K=T(i!==void 0?i:"");o.push(K)}else if(P)switch(P.toLowerCase()){case"number":o.push(Number(T).toString());break;case"string":o.push(String(T));break;case"boolean":o.push(Boolean(T).toString());break;default:o.push(String(T))}else o.push(String(T));f=c+t.length}if(f<r.length)o.push(r.substring(f));return $(e,{},...o)}}class R{name;dictionary;constructor(r,n){this.name=r;this.dictionary=n}reference(r){if(typeof window<"u")throw Error("Cannot use reference in the browser");if(!this.dictionary?.[r])throw Error(`Translation not found for ${String(r)}`);return this.dictionary[r]}render(r,...n){let{locale:s=S.locale(),params:g}={params:{},...n[0]};if(typeof window<"u")throw Error("Cannot use render in the browser");if(!this.dictionary?.[r]?.[s])throw Error(`Translation not found for ${String(r)} in ${String(s)}`);return y(this.dictionary[r][s],g??{})}static create(r,n){return new R(r,n)}static text(r,...n){let{locale:s=S.locale(),params:g}={params:{},...n?.[0]};if(!r?.[s])throw Error(`Translation not found for ${String(s)}`);return y(r[s],g??{})}}export{x as I18nServiceProvider,R as Dictionary};

//# debugId=53AE96E7344B124364756E2164756E21
