"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("svelte/store"),t=require("deepmerge"),n=require("intl-messageformat");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=r(t),i=r(n);const a={},l=(e,t,n)=>n?(t in a||(a[t]={}),e in a[t]||(a[t][e]=n),n):n,s=(e,t)=>{if(null==t)return;if(t in a&&e in a[t])return a[t][e];const n=k(t);for(let r=0;r0){const t=n.slice(e,n.length).join(".");if(t in r){r=r[t];break}}r=r[n[e]]}else r=void 0;return r}(function(e){return u[e]||null}(e),t)}function d(e,...t){delete a[e],c.update((n=>(n[e]=o.default.all([n[e]||{},...t]),n)))}const g=e.derived([c],(([e])=>Object.keys(e)));c.subscribe((e=>u=e));const p={};function w(e){return p[e]}function h(e){return k(e).some((e=>{var t;return null===(t=w(e))||void 0===t?void 0:t.size}))}function b(e,t){return Promise.all(t.map((t=>(function(e,t){p[e].delete(t),0===p[e].size&&delete p[e]}(e,t),t().then((e=>e.default||e)))))).then((t=>d(e,...t)))}const y={};function v(e){if(!h(e))return e in y?y[e]:void 0;const t=function(e){return k(e).map((e=>{const t=w(e);return[e,t?[...t]:[]]})).filter((([,e])=>e.length>0))}(e);return y[e]=Promise.all(t.map((([e,t])=>b(e,t)))).then((()=>{if(h(e))return v(e);delete y[e]})),y[e]} /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ function x(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);on.slice(0,t+1).join("-"))).reverse()}function k(e,t=j().fallbackLocale){const n=$(e);return t?[...new Set([...n,...$(t)])]:n}function T(){return F}M.subscribe((e=>{F=e,"undefined"!=typeof window&&null!==e&&document.documentElement.setAttribute("lang",e)}));const D=M.set;M.set=e=>{if(function(e){if(null==e)return;const t=k(e);for(let e=0;eL.set(!0)),t):L.set(!0),v(e).then((()=>{D(e)})).finally((()=>{clearTimeout(n),L.set(!1)}))}return D(e)},M.update=e=>D(e(F));const E=(e,t)=>{const n=e.split("&").find((e=>0===e.indexOf(`${t}=`)));return n?n.split("=").pop():null},N=(e,t)=>{const n=t.exec(e);return n&&n[1]||null},P=e=>{const t=Object.create(null);return n=>{const r=JSON.stringify(n);return r in t?t[r]:t[r]=e(n)}},S=(e,t)=>{const{formats:n}=j();if(e in n&&t in n[e])return n[e][t];throw new Error(`[svelte-i18n] Unknown "${t}" ${e} format.`)},A=P((e=>{var{locale:t,format:n}=e,r=x(e,["locale","format"]);if(null==t)throw new Error('[svelte-i18n] A "locale" must be set to format numbers');return n&&(r=S("number",n)),new Intl.NumberFormat(t,r)})),I=P((e=>{var{locale:t,format:n}=e,r=x(e,["locale","format"]);if(null==t)throw new Error('[svelte-i18n] A "locale" must be set to format dates');return n?r=S("date",n):0===Object.keys(r).length&&(r=S("date","short")),new Intl.DateTimeFormat(t,r)})),q=P((e=>{var{locale:t,format:n}=e,r=x(e,["locale","format"]);if(null==t)throw new Error('[svelte-i18n] A "locale" must be set to format time values');return n?r=S("time",n):0===Object.keys(r).length&&(r=S("time","short")),new Intl.DateTimeFormat(t,r)})),_=(e={})=>{var{locale:t=T()}=e,n=x(e,["locale"]);return A(Object.assign({locale:t},n))},z=(e={})=>{var{locale:t=T()}=e,n=x(e,["locale"]);return I(Object.assign({locale:t},n))},H=(e={})=>{var{locale:t=T()}=e,n=x(e,["locale"]);return q(Object.assign({locale:t},n))},Z=P(((e,t=T())=>new i.default(e,t,j().formats,{ignoreTag:j().ignoreTag}))),C=(e,t={})=>{"object"==typeof e&&(e=(t=e).id);const{values:n,locale:r=T(),default:o}=t;if(null==r)throw new Error("[svelte-i18n] Cannot format a message without first setting the initial locale.");let i=s(e,r);if(i){if("string"!=typeof i)return console.warn(`[svelte-i18n] Message with id "${e}" must be of type "string", found: "${typeof i}". Gettin its value through the "$format" method is deprecated; use the "json" method instead.`),i}else j().warnOnMissingMessages&&console.warn(`[svelte-i18n] The message "${e}" was not found in "${k(r).join('", "')}".${h(T())?"\n\nNote: there are at least one loader still registered to this locale that wasn't executed.":""}`),i=o||e;if(!n)return i;let a=i;try{a=Z(i,r).format(n)}catch(t){console.warn(`[svelte-i18n] Message "${e}" has syntax error:`,t.message)}return a},G=(e,t)=>H(t).format(e),J=(e,t)=>z(t).format(e),Q=(e,t)=>_(t).format(e),U=(e,t=T())=>s(e,t),B=e.derived([M,c],(()=>C)),K=e.derived([M],(()=>G)),R=e.derived([M],(()=>J)),V=e.derived([M],(()=>Q)),W=e.derived([M,c],(()=>U));exports._=B,exports.addMessages=d,exports.date=R,exports.defineMessages=function(e){return e},exports.dictionary=c,exports.format=B,exports.getDateFormatter=z,exports.getLocaleFromHash=e=>"undefined"==typeof window?null:E(window.location.hash.substr(1),e),exports.getLocaleFromHostname=e=>"undefined"==typeof window?null:N(window.location.hostname,e),exports.getLocaleFromNavigator=()=>"undefined"==typeof window?null:window.navigator.language||window.navigator.languages[0],exports.getLocaleFromPathname=e=>"undefined"==typeof window?null:N(window.location.pathname,e),exports.getLocaleFromQueryString=e=>"undefined"==typeof window?null:E(window.location.search.substr(1),e),exports.getMessageFormatter=Z,exports.getNumberFormatter=_,exports.getTimeFormatter=H,exports.init=function(e){const{formats:t}=e,n=x(e,["formats"]),r=e.initialLocale||e.fallbackLocale;return Object.assign(O,n,{initialLocale:r}),t&&("number"in t&&Object.assign(O.formats.number,t.number),"date"in t&&Object.assign(O.formats.date,t.date),"time"in t&&Object.assign(O.formats.time,t.time)),M.set(r)},exports.isLoading=L,exports.json=W,exports.locale=M,exports.locales=g,exports.number=V,exports.register=function(e,t){w(e)||function(e){p[e]=new Set}(e);const n=w(e);w(e).has(t)||(m(e)||c.update((t=>(t[e]={},t))),n.add(t))},exports.t=B,exports.time=K,exports.waitLocale=function(e){return v(e||T()||j().initialLocale)};