vue-i18n-routing
Advanced tools
Comparing version 0.1.2-e7ba057 to 0.1.2
@@ -5,2 +5,2 @@ const VueI18nRouting=function(f,h,g,w){"use strict";const ye=(e=>e&&typeof e=="object"&&"default"in e?e:{default:e})(g),Q={PREFIX:"prefix",PREFIX_EXCEPT_DEFAULT:"prefix_except_default",PREFIX_AND_DEFAULT:"prefix_and_default",NO_PREFIX:"no_prefix"},G="",B=Q.PREFIX_EXCEPT_DEFAULT,M=!1,k="___",z="default",Y="ltr",J="";/*! | ||
* Released under the MIT License. | ||
*/process.env.NODE_ENV;const Ie=typeof Symbol=="function"&&typeof Symbol.toStringTag=="symbol",Ce=e=>Ie?Symbol(e):e,H=Object.assign,Te=Array.isArray,Oe=e=>typeof e=="function",T=e=>typeof e=="string",be=e=>typeof e=="boolean",Pe=e=>typeof e=="symbol",K=e=>e!==null&&typeof e=="object",Ue=/\/$|\/\?/;function Z(e="",t=!1){return t?Ue.test(e):e.endsWith("/")}function Ne(e="",t=!1){if(!t)return(Z(e)?e.slice(0,-1):e)||"/";if(!Z(e,!0))return e||"/";const[o,...n]=e.split("?");return(o.slice(0,-1)||"/")+(n.length?`?${n.join("?")}`:"")}function Fe(e="",t=!1){if(!t)return e.endsWith("/")?e:e+"/";if(Z(e,!0))return e||"/";const[o,...n]=e.split("?");return o+"/"+(n.length?`?${n.join("?")}`:"")}const we=typeof window<"u";function ae(e,t){typeof console<"u"&&(console.warn("[vue-i18n-routing] "+e),t&&console.warn(t.stack))}function ce(e){e=e||[];const t=[];for(const o of e)T(o)?t.push({code:o}):t.push(o);return t}function U(e){return e!=null&&"global"in e&&"mode"in e}function N(e){return e!=null&&!("__composer"in e)&&h.isRef(e.locale)}function O(e){return e!=null&&"__composer"in e}function $(e){return e!=null&&!("__composer"in e)&&!h.isRef(e.locale)}function y(e){return e!=null&&("__VUE_I18N_BRIDGE__"in e||"_sync"in e)}function se(e){return U(e)?N(e.global)?e.global:e.global.__composer:O(e)?e.__composer:e}function X(e){const t=U(e)?e.global:e;return N(t)?h.isVue2&&y(e)?e.locale:t.locale.value:($(t)||O(t)||y(t),t.locale)}function re(e){const t=U(e)?e.global:e;return N(t)?h.isVue2&&y(e)?e.locales:t.locales.value:($(t)||O(t)||y(t),t.locales)}function $e(e){const t=U(e)?e.global:e;return N(t)?h.isVue2&&y(e)?e.localeCodes:t.localeCodes.value:($(t)||O(t)||y(t),t.localeCodes)}function ie(e,t){const o=U(e)?e.global:e;if(N(o))h.isVue2&&y(e)?e.locale=t:o.locale.value=t;else if($(o)||O(o)||y(o))o.locale=t;else throw new Error("TODO:")}function Ve(e,t,o){return e.replace(/\/+$/,"")+(t?"/":"")||(o?"":"/")}function ue(e){return g.isVueRouter4,h.isRef(e)?e.value:e}function fe(e){return T(e)?e:Pe(e)?e.toString():"(null)"}function de(e,t,{defaultLocale:o,strategy:n,routesNameSeparator:a,defaultLocaleRouteNameSuffix:l}){let c=fe(e)+(n==="no_prefix"?"":a+t);return t===o&&n==="prefix_and_default"&&(c+=a+l),c}function he(e,t){return Oe(e)?e(t):e}function je(e,t){const o=[];for(const[n,a]of t.entries()){const l=e.find(c=>c.iso.toLowerCase()===a.toLowerCase());if(l){o.push({code:l.code,score:1-n/t.length});break}}for(const[n,a]of t.entries()){const l=a.split("-")[0].toLowerCase(),c=e.find(s=>s.iso.split("-")[0].toLowerCase()===l);if(c){o.push({code:c.code,score:.999-n/t.length});break}}return o}const ve=je;function Ge(e,t){return e.score===t.score?t.code.length-e.code.length:t.score-e.score}const Be=Ge;function Me(e,t,{matcher:o=ve,comparer:n=Be}={}){const a=[];for(const c of e){const{code:s}=c,i=c.iso||s;a.push({code:s,iso:i})}const l=o(a,t);return l.length>1&&l.sort(n),l.length?l[0].code:""}function Le(e,{defaultLocale:t=G,strategy:o=B,trailingSlash:n=M,routesNameSeparator:a=k,defaultLocaleRouteNameSuffix:l=z,includeUprefixedFallback:c=!1,optionsResolver:s=void 0,locales:i=[]}={}){if(o==="no_prefix")return e;const u=i.map(r=>T(r)?r:r.code);function d(r,L,_=!1,I=!1){if(r.redirect&&(!r.component||!r.file))return[r];let p=null;if(s!=null&&(p=s(r,L),p==null))return[r];const R={locales:u,paths:{}};if(p!=null&&H(R,p),H(R,{locales:L}),R.locales.length>0&&p&&p.locales!=null&&p.locales.length>0){const E=[];for(const m of R.locales)p.locales.includes(m)&&E.push(m);R.locales=E}return R.locales.reduce((E,m)=>{const{name:v}=r;let{path:S}=r;const A={...r};v&&(A.name=`${v}${a}${m}`),r.children&&(A.children=r.children.reduce((P,le)=>[...P,...d(le,[m],!0,I)],[])),R.paths&&R.paths[m]&&(S=R.paths[m]);const F=m===t;if(F&&o==="prefix_and_default")if(_)_&&I&&v&&(A.name+=`${a}${l}`);else{const P={...A,path:S};if(v&&(P.name=`${A.name}${a}${l}`),r.children){P.children=[];for(const le of r.children)P.children=P.children.concat(d(le,[m],!0,!0))}E.push(P)}const Se=_&&!S.startsWith("/"),Ae=!Se&&!(F&&o==="prefix_except_default");return Ae&&(S=`/${m}${S}`),S&&(S=Ve(S,n,Se)),Ae&&F&&o==="prefix"&&c&&E.push({...r}),A.path=S,E.push(A),E},[])}return e.reduce((r,L)=>[...r,...d(L,u||[])],[])}function C(e){return function(){return Reflect.apply(e,{getRouteBaseName:this.getRouteBaseName,localePath:this.localePath,localeRoute:this.localeRoute,localeLocation:this.localeLocation,resolveRoute:this.resolveRoute,switchLocalePath:this.switchLocalePath,localeHead:this.localeHead,i18n:this.$i18n,route:this.$route,router:this.$router},arguments)}}function ge(e,{locales:t=[],localeCodes:o=[],baseUrl:n=J,hooks:a={}}={}){const l=h.effectScope(),c=e.install;return e.install=(s,...i)=>{Reflect.apply(c,e,[s,...i]);const u=se(e);l.run(()=>ke(u,{locales:t,localeCodes:o,baseUrl:n,hooks:a})),O(e.global)&&He(e.global,a.onExtendVueI18n);const d=s,r=e.mode==="composition"?h.isVue3?d.config.globalProperties.$i18n:e:h.isVue2?e:null;if(r&&ze(r,u,a.onExtendExportedGlobal),(Xe(i[0])?i[0]:{inject:!0}).inject&&s.mixin({methods:{resolveRoute:C(V),localePath:C(q),localeRoute:C(x),localeLocation:C(te),switchLocalePath:C(j),getRouteBaseName:C(b),localeHead:C(oe)}}),d.unmount){const _=d.unmount;d.unmount=()=>{l.stop(),_()}}},l}function ke(e,t){const{locales:o,localeCodes:n,baseUrl:a}=t,l=h.ref(o),c=h.ref(n);e.locales=h.computed(()=>l.value),e.localeCodes=h.computed(()=>c.value),e.__baseUrl=he(a,{}),t.hooks&&t.hooks.onExtendComposer&&t.hooks.onExtendComposer(e)}function ze(e,t,o){const n=[{locales:{get(){return t.locales.value}},localeCodes:{get(){return t.localeCodes.value}},__baseUrl:{get(){return t.__baseUrl}}}];o&&n.push(o(t));for(const a of n)for(const[l,c]of Object.entries(a))Object.defineProperty(e,l,c)}function He(e,t){const o=se(e),n=[{locales:{get(){return o.locales.value}},localeCodes:{get(){return o.localeCodes.value}},__baseUrl:{get(){return o.__baseUrl}}}];t&&n.push(t(o));for(const a of n)for(const[l,c]of Object.entries(a))Object.defineProperty(e,l,c)}function Xe(e){return K(e)&&"inject"in e&&be(e.inject)}const ee=Ce("vue-i18n-routing-gor");function _e(e,t){e[ee]?ae("already registered global options"):e[ee]=t}function me(e){var t;return(t=e[ee])!=null?t:{}}function De(e,t={}){const{version:o,defaultLocale:n,locales:a,strategy:l,trailingSlash:c,routesNameSeparator:s,defaultLocaleRouteNameSuffix:i,defaultDirection:u,baseUrl:d,routes:r,routeOptionsResolver:L}=xe(t),_=ce(a),I=_.map(m=>m.code),p=pe(I,s,i);ge(e,{locales:_,baseUrl:d,localeCodes:I});const R=Le(r,{locales:a,defaultLocale:n,strategy:l,trailingSlash:c,routesNameSeparator:s,defaultLocaleRouteNameSuffix:i,optionsResolver:L});t.routes=R;const E=qe(t,o);return _e(E,{defaultLocale:n,localeCodes:I,strategy:l,trailingSlash:c,routesNameSeparator:s,defaultLocaleRouteNameSuffix:i,defaultDirection:u}),E.beforeEach((m,v,S)=>{const A=X(e),F=p(m)||A||n||"";A!==F&&ie(e,F),S()}),E}function qe(e,t){if(h.isVue3&&t===4)return g.createRouter(e);if(h.isVue2&&t===3)return new ye.default(e);throw new Error("TODO:")}function Re(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function pe(e,t,o){const n=`(${e.join("|")})`,a=`(?:${t}${o})?`,l=new RegExp(`${t}${n}${a}$`,"i"),c=Re(e);return i=>{if(K(i)){if(i.name){const d=(T(i.name)?i.name:i.name.toString()).match(l);if(d&&d.length>1)return d[1]}else if(i.path){const u=i.path.match(c);if(u&&u.length>1)return u[1]}}else if(T(i)){const u=i.match(c);if(u&&u.length>1)return u[1]}return""}}function xe(e){var t,o,n,a,l,c,s,i,u,d;return e.version=(t=e.version)!=null?t:4,e.defaultLocale=(o=e.defaultLocale)!=null?o:G,e.strategy=(n=e.strategy)!=null?n:B,e.trailingSlash=(a=e.trailingSlash)!=null?a:M,e.routesNameSeparator=(l=e.routesNameSeparator)!=null?l:k,e.defaultLocaleRouteNameSuffix=(c=e.defaultLocaleRouteNameSuffix)!=null?c:z,e.locales=(s=e.locales)!=null?s:[],e.defaultDirection=(i=e.defaultDirection)!=null?i:Y,e.baseUrl=(u=e.baseUrl)!=null?u:J,e.routes=(d=e.routes)!=null?d:[],e}function D(e,t,{defaultLocale:o=G,defaultDirection:n=Y,defaultLocaleRouteNameSuffix:a=z,routesNameSeparator:l=k,strategy:c=B,trailingSlash:s=M,localeCodes:i=[]}={}){const u=me(e);return{defaultLocale:t.defaultLocale||u.defaultLocale||o,defaultDirection:t.defaultDirection||u.defaultDirection||n,defaultLocaleRouteNameSuffix:t.defaultLocaleRouteNameSuffix||u.defaultLocaleRouteNameSuffix||a,routesNameSeparator:t.routesNameSeparator||u.routesNameSeparator||l,strategy:t.strategy||u.strategy||c,trailingSlash:t.trailingSlash||u.trailingSlash||s,localeCodes:t.localeCodes||u.localeCodes||i}}const We=new Set(["prefix_and_default","prefix_except_default"]);function b(e){const t=this.router,{routesNameSeparator:o}=D(t,this),n=e!=null?h.isRef(e)?h.unref(e):e:this.route;return n==null||!n.name?void 0:fe(n.name).split(o)[0]}function q(e,t){const o=V.call(this,e,t);return o==null?"":h.isVue3?o.redirectedFrom||o.fullPath:o.route.redirectedFrom||o.route.fullPath}function x(e,t){const o=V.call(this,e,t);return o==null?void 0:h.isVue3?o:o.route}function te(e,t){const o=V.call(this,e,t);return o==null?void 0:h.isVue3?o:o.location}function V(e,t){const o=this.router,n=this.i18n,a=t||X(n),{routesNameSeparator:l,defaultLocale:c,defaultLocaleRouteNameSuffix:s,strategy:i,trailingSlash:u}=D(o,this);let d=e;T(e)&&(d[0]==="/"?d={path:e}:d={name:e});let r=H({},d);if(r.path&&!r.name){let L=null;try{L=o.resolve(r)}catch{}const _=h.isVue3?L:L.route,I=b.call(this,_);T(I)?(r={name:de(I,a,{defaultLocale:c,strategy:i,routesNameSeparator:l,defaultLocaleRouteNameSuffix:s}),params:_.params,query:_.query,hash:_.hash},h.isVue3&&(r.state=_.state)):(!(a===c&&We.has(i))&&i!=="no_prefix"&&(r.path=`/${a}${r.path}`),r.path=u?Fe(r.path,!0):Ne(r.path,!0))}else if(!r.name&&!r.path&&(r.name=b.call(this,this.route)),r.name=de(r.name,a,{defaultLocale:c,strategy:i,routesNameSeparator:l,defaultLocaleRouteNameSuffix:s}),h.isVue2){const{params:L}=r;L&&L[0]===void 0&&L.pathMatch&&(L[0]=L.pathMatch)}try{const L=o.resolve(r);return(h.isVue3?L.name:L.route.name)?L:o.resolve(e)}catch(L){if(h.isVue3&&L.type===1)return null;if(h.isVue2)return null}}function j(e){const t=this.route,o=b.call(this,t);if(!o)return"";const{params:n,...a}=!h.isVue3&&h.isRef(t)?t.value:t,c={name:o,params:{...n,...{}}};h.isVue2&&(c.params[0]=n.pathMatch);const s=H({},a,c);return q.call(this,s,e)}function oe({addDirAttribute:e=!1,addSeoAttributes:t=!1}={}){const o=this.router,n=this.i18n,{defaultDirection:a}=D(o,this),l={htmlAttrs:{},link:[],meta:[]};if(n.locales==null||n.__baseUrl==null)return l;const c=X(n),s=re(n),i=ce(s).find(r=>r.code===c)||{code:c},u=i.iso,d=i.dir||a;return e&&(l.htmlAttrs.dir=d),t&&c&&n.locales&&(u&&(l.htmlAttrs.lang=u),Qe.call(this,s,n.__baseUrl,l.link),Ye.call(this,n.__baseUrl,l.link,t),Je(i,u,l.meta),Ke(s,u,l.meta)),l}function Qe(e,t,o){const n=this.router,{defaultLocale:a,strategy:l}=D(n,this);if(l===Q.NO_PREFIX)return;const c=new Map;for(const s of e){const i=s.iso;if(!i){ae("Locale ISO code is required to generate alternate link");continue}const[u,d]=i.split("-");u&&d&&(s.isCatchallLocale||!c.has(u))&&c.set(u,s),c.set(i,s)}for(const[s,i]of c.entries()){const u=j.call(this,i.code);u&&o.push({hid:`i18n-alt-${s}`,rel:"alternate",href:ne(u,t),hreflang:s})}if(a){const s=j.call(this,a);s&&o.push({hid:"i18n-xd",rel:"alternate",href:ne(s,t),hreflang:"x-default"})}}function Ye(e,t,o){const n=this.route,a=x.call(this,{...n,name:b.call(this,n)});if(a){let l=ne(a.path,e);const c=K(o)&&o.canonicalQueries||[];if(c.length){const s=a.query,i=new URLSearchParams;for(const d of c)if(d in s){const r=s[d];Te(r)?r.forEach(L=>i.append(d,L||"")):i.append(d,r||"")}const u=i.toString();u&&(l=`${l}?${u}`)}t.push({hid:"i18n-can",rel:"canonical",href:l})}}function Je(e,t,o){!(e&&t)||o.push({hid:"i18n-og",property:"og:locale",content:Ee(t)})}function Ke(e,t,o){const n=e.filter(a=>{const l=a.iso;return l&&l!==t});if(n.length){const a=n.map(l=>({hid:`i18n-og-alt-${l.iso}`,property:"og:locale:alternate",content:Ee(l.iso)}));o.push(...a)}}function Ee(e){return(e||"").replace(/-/g,"_")}function ne(e,t){return e.match(/^https?:\/\//)?e:t+e}function W(e,t){const{router:o,route:n,i18n:a,defaultLocale:l,strategy:c,defaultLocaleRouteNameSuffix:s,trailingSlash:i,routesNameSeparator:u}=e;return function(...d){return Reflect.apply(t,{router:o,route:n,i18n:a,defaultLocale:l,strategy:c,defaultLocaleRouteNameSuffix:s,trailingSlash:i,routesNameSeparator:u},d)}}function Ze(e=g.useRoute(),{router:t=g.useRouter(),routesNameSeparator:o=void 0}={}){const n={router:t,route:e,routesNameSeparator:o};return b.call(n,e)}function et({router:e=g.useRouter(),route:t=g.useRoute(),i18n:o=w.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:a=void 0,routesNameSeparator:l=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return W({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:a,routesNameSeparator:l,strategy:c,trailingSlash:s},q)}function tt({router:e=g.useRouter(),route:t=g.useRoute(),i18n:o=w.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:a=void 0,routesNameSeparator:l=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return W({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:a,routesNameSeparator:l,strategy:c,trailingSlash:s},x)}function ot({router:e=g.useRouter(),route:t=g.useRoute(),i18n:o=w.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:a=void 0,routesNameSeparator:l=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return W({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:a,routesNameSeparator:l,strategy:c,trailingSlash:s},te)}function nt({router:e=g.useRouter(),route:t=g.useRoute(),i18n:o=w.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:a=void 0,routesNameSeparator:l=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return W({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:a,routesNameSeparator:l,strategy:c,trailingSlash:s},j)}function lt({addDirAttribute:e=!1,addSeoAttributes:t=!1,strategy:o=void 0,defaultLocale:n=void 0,route:a=g.useRoute(),router:l=g.useRouter(),i18n:c=w.useI18n()}={}){const s=l,i=h.ref({htmlAttrs:{},link:[],meta:[]});function u(){i.value={htmlAttrs:{},link:[],meta:[]}}function d(r){i.value=Reflect.apply(oe,{router:l,route:r,i18n:c,defaultLocale:n,strategy:o},[{addDirAttribute:e,addSeoAttributes:t}])}if(we)if(h.isVue3){const r=h.watchEffect(()=>{u(),d(ue(s.currentRoute))});h.onUnmounted(()=>r())}else{const r=s.afterEach((L,_)=>{u(),d(L)});h.onUnmounted(()=>r()),d(a)}else d(ue(s.currentRoute));return i}const at="0.1.1";return f.DEFAULT_BASE_URL=J,f.DEFAULT_DETECTION_DIRECTION=Y,f.DEFAULT_LOCALE=G,f.DEFAULT_LOCALE_ROUTE_NAME_SUFFIX=z,f.DEFAULT_ROUTES_NAME_SEPARATOR=k,f.DEFAULT_STRATEGY=B,f.DEFAULT_TRAILING_SLASH=M,f.STRATEGIES=Q,f.VERSION=at,f.createLocaleFromRouteGetter=pe,f.createRouter=De,f.extendI18n=ge,f.findBrowserLocale=Me,f.getGlobalOptions=me,f.getLocale=X,f.getLocaleCodes=$e,f.getLocales=re,f.getLocalesRegex=Re,f.getRouteBaseName=b,f.isComposer=N,f.isExportedGlobalComposer=$,f.isI18nInstance=U,f.isLegacyVueI18n=y,f.isVueI18n=O,f.localeHead=oe,f.localeLocation=te,f.localePath=q,f.localeRoute=x,f.localizeRoutes=Le,f.proxyVueInstance=C,f.registerGlobalOptions=_e,f.resolveBaseUrl=he,f.resolveRoute=V,f.setLocale=ie,f.switchLocalePath=j,f.useLocaleHead=lt,f.useLocaleLocation=ot,f.useLocalePath=et,f.useLocaleRoute=tt,f.useRouteBaseName=Ze,f.useSwitchLocalePath=nt,Object.defineProperties(f,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),f}({},VueDemi,VueRouter,VueI18n); | ||
*/process.env.NODE_ENV;const Ie=typeof Symbol=="function"&&typeof Symbol.toStringTag=="symbol",Ce=e=>Ie?Symbol(e):e,H=Object.assign,Te=Array.isArray,Oe=e=>typeof e=="function",T=e=>typeof e=="string",be=e=>typeof e=="boolean",Pe=e=>typeof e=="symbol",K=e=>e!==null&&typeof e=="object",Ue=/\/$|\/\?/;function Z(e="",t=!1){return t?Ue.test(e):e.endsWith("/")}function Ne(e="",t=!1){if(!t)return(Z(e)?e.slice(0,-1):e)||"/";if(!Z(e,!0))return e||"/";const[o,...n]=e.split("?");return(o.slice(0,-1)||"/")+(n.length?`?${n.join("?")}`:"")}function Fe(e="",t=!1){if(!t)return e.endsWith("/")?e:e+"/";if(Z(e,!0))return e||"/";const[o,...n]=e.split("?");return o+"/"+(n.length?`?${n.join("?")}`:"")}const we=typeof window<"u";function ae(e,t){typeof console<"u"&&(console.warn("[vue-i18n-routing] "+e),t&&console.warn(t.stack))}function ce(e){e=e||[];const t=[];for(const o of e)T(o)?t.push({code:o}):t.push(o);return t}function U(e){return e!=null&&"global"in e&&"mode"in e}function N(e){return e!=null&&!("__composer"in e)&&h.isRef(e.locale)}function O(e){return e!=null&&"__composer"in e}function $(e){return e!=null&&!("__composer"in e)&&!h.isRef(e.locale)}function y(e){return e!=null&&("__VUE_I18N_BRIDGE__"in e||"_sync"in e)}function se(e){return U(e)?N(e.global)?e.global:e.global.__composer:O(e)?e.__composer:e}function X(e){const t=U(e)?e.global:e;return N(t)?h.isVue2&&y(e)?e.locale:t.locale.value:($(t)||O(t)||y(t),t.locale)}function re(e){const t=U(e)?e.global:e;return N(t)?h.isVue2&&y(e)?e.locales:t.locales.value:($(t)||O(t)||y(t),t.locales)}function $e(e){const t=U(e)?e.global:e;return N(t)?h.isVue2&&y(e)?e.localeCodes:t.localeCodes.value:($(t)||O(t)||y(t),t.localeCodes)}function ie(e,t){const o=U(e)?e.global:e;if(N(o))h.isVue2&&y(e)?e.locale=t:o.locale.value=t;else if($(o)||O(o)||y(o))o.locale=t;else throw new Error("TODO:")}function Ve(e,t,o){return e.replace(/\/+$/,"")+(t?"/":"")||(o?"":"/")}function ue(e){return g.isVueRouter4,h.isRef(e)?e.value:e}function fe(e){return T(e)?e:Pe(e)?e.toString():"(null)"}function de(e,t,{defaultLocale:o,strategy:n,routesNameSeparator:a,defaultLocaleRouteNameSuffix:l}){let c=fe(e)+(n==="no_prefix"?"":a+t);return t===o&&n==="prefix_and_default"&&(c+=a+l),c}function he(e,t){return Oe(e)?e(t):e}function je(e,t){const o=[];for(const[n,a]of t.entries()){const l=e.find(c=>c.iso.toLowerCase()===a.toLowerCase());if(l){o.push({code:l.code,score:1-n/t.length});break}}for(const[n,a]of t.entries()){const l=a.split("-")[0].toLowerCase(),c=e.find(s=>s.iso.split("-")[0].toLowerCase()===l);if(c){o.push({code:c.code,score:.999-n/t.length});break}}return o}const ve=je;function Ge(e,t){return e.score===t.score?t.code.length-e.code.length:t.score-e.score}const Be=Ge;function Me(e,t,{matcher:o=ve,comparer:n=Be}={}){const a=[];for(const c of e){const{code:s}=c,i=c.iso||s;a.push({code:s,iso:i})}const l=o(a,t);return l.length>1&&l.sort(n),l.length?l[0].code:""}function Le(e,{defaultLocale:t=G,strategy:o=B,trailingSlash:n=M,routesNameSeparator:a=k,defaultLocaleRouteNameSuffix:l=z,includeUprefixedFallback:c=!1,optionsResolver:s=void 0,locales:i=[]}={}){if(o==="no_prefix")return e;const u=i.map(r=>T(r)?r:r.code);function d(r,L,_=!1,I=!1){if(r.redirect&&(!r.component||!r.file))return[r];let p=null;if(s!=null&&(p=s(r,L),p==null))return[r];const R={locales:u,paths:{}};if(p!=null&&H(R,p),H(R,{locales:L}),R.locales.length>0&&p&&p.locales!=null&&p.locales.length>0){const E=[];for(const m of R.locales)p.locales.includes(m)&&E.push(m);R.locales=E}return R.locales.reduce((E,m)=>{const{name:v}=r;let{path:S}=r;const A={...r};v&&(A.name=`${v}${a}${m}`),r.children&&(A.children=r.children.reduce((P,le)=>[...P,...d(le,[m],!0,I)],[])),R.paths&&R.paths[m]&&(S=R.paths[m]);const F=m===t;if(F&&o==="prefix_and_default")if(_)_&&I&&v&&(A.name+=`${a}${l}`);else{const P={...A,path:S};if(v&&(P.name=`${A.name}${a}${l}`),r.children){P.children=[];for(const le of r.children)P.children=P.children.concat(d(le,[m],!0,!0))}E.push(P)}const Se=_&&!S.startsWith("/"),Ae=!Se&&!(F&&o==="prefix_except_default");return Ae&&(S=`/${m}${S}`),S&&(S=Ve(S,n,Se)),Ae&&F&&o==="prefix"&&c&&E.push({...r}),A.path=S,E.push(A),E},[])}return e.reduce((r,L)=>[...r,...d(L,u||[])],[])}function C(e){return function(){return Reflect.apply(e,{getRouteBaseName:this.getRouteBaseName,localePath:this.localePath,localeRoute:this.localeRoute,localeLocation:this.localeLocation,resolveRoute:this.resolveRoute,switchLocalePath:this.switchLocalePath,localeHead:this.localeHead,i18n:this.$i18n,route:this.$route,router:this.$router},arguments)}}function ge(e,{locales:t=[],localeCodes:o=[],baseUrl:n=J,hooks:a={}}={}){const l=h.effectScope(),c=e.install;return e.install=(s,...i)=>{Reflect.apply(c,e,[s,...i]);const u=se(e);l.run(()=>ke(u,{locales:t,localeCodes:o,baseUrl:n,hooks:a})),O(e.global)&&He(e.global,a.onExtendVueI18n);const d=s,r=e.mode==="composition"?h.isVue3?d.config.globalProperties.$i18n:e:h.isVue2?e:null;if(r&&ze(r,u,a.onExtendExportedGlobal),(Xe(i[0])?i[0]:{inject:!0}).inject&&s.mixin({methods:{resolveRoute:C(V),localePath:C(q),localeRoute:C(x),localeLocation:C(te),switchLocalePath:C(j),getRouteBaseName:C(b),localeHead:C(oe)}}),d.unmount){const _=d.unmount;d.unmount=()=>{l.stop(),_()}}},l}function ke(e,t){const{locales:o,localeCodes:n,baseUrl:a}=t,l=h.ref(o),c=h.ref(n);e.locales=h.computed(()=>l.value),e.localeCodes=h.computed(()=>c.value),e.__baseUrl=he(a,{}),t.hooks&&t.hooks.onExtendComposer&&t.hooks.onExtendComposer(e)}function ze(e,t,o){const n=[{locales:{get(){return t.locales.value}},localeCodes:{get(){return t.localeCodes.value}},__baseUrl:{get(){return t.__baseUrl}}}];o&&n.push(o(t));for(const a of n)for(const[l,c]of Object.entries(a))Object.defineProperty(e,l,c)}function He(e,t){const o=se(e),n=[{locales:{get(){return o.locales.value}},localeCodes:{get(){return o.localeCodes.value}},__baseUrl:{get(){return o.__baseUrl}}}];t&&n.push(t(o));for(const a of n)for(const[l,c]of Object.entries(a))Object.defineProperty(e,l,c)}function Xe(e){return K(e)&&"inject"in e&&be(e.inject)}const ee=Ce("vue-i18n-routing-gor");function _e(e,t){e[ee]?ae("already registered global options"):e[ee]=t}function me(e){var t;return(t=e[ee])!=null?t:{}}function De(e,t={}){const{version:o,defaultLocale:n,locales:a,strategy:l,trailingSlash:c,routesNameSeparator:s,defaultLocaleRouteNameSuffix:i,defaultDirection:u,baseUrl:d,routes:r,routeOptionsResolver:L}=xe(t),_=ce(a),I=_.map(m=>m.code),p=pe(I,s,i);ge(e,{locales:_,baseUrl:d,localeCodes:I});const R=Le(r,{locales:a,defaultLocale:n,strategy:l,trailingSlash:c,routesNameSeparator:s,defaultLocaleRouteNameSuffix:i,optionsResolver:L});t.routes=R;const E=qe(t,o);return _e(E,{defaultLocale:n,localeCodes:I,strategy:l,trailingSlash:c,routesNameSeparator:s,defaultLocaleRouteNameSuffix:i,defaultDirection:u}),E.beforeEach((m,v,S)=>{const A=X(e),F=p(m)||A||n||"";A!==F&&ie(e,F),S()}),E}function qe(e,t){if(h.isVue3&&t===4)return g.createRouter(e);if(h.isVue2&&t===3)return new ye.default(e);throw new Error("TODO:")}function Re(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function pe(e,t,o){const n=`(${e.join("|")})`,a=`(?:${t}${o})?`,l=new RegExp(`${t}${n}${a}$`,"i"),c=Re(e);return i=>{if(K(i)){if(i.name){const d=(T(i.name)?i.name:i.name.toString()).match(l);if(d&&d.length>1)return d[1]}else if(i.path){const u=i.path.match(c);if(u&&u.length>1)return u[1]}}else if(T(i)){const u=i.match(c);if(u&&u.length>1)return u[1]}return""}}function xe(e){var t,o,n,a,l,c,s,i,u,d;return e.version=(t=e.version)!=null?t:4,e.defaultLocale=(o=e.defaultLocale)!=null?o:G,e.strategy=(n=e.strategy)!=null?n:B,e.trailingSlash=(a=e.trailingSlash)!=null?a:M,e.routesNameSeparator=(l=e.routesNameSeparator)!=null?l:k,e.defaultLocaleRouteNameSuffix=(c=e.defaultLocaleRouteNameSuffix)!=null?c:z,e.locales=(s=e.locales)!=null?s:[],e.defaultDirection=(i=e.defaultDirection)!=null?i:Y,e.baseUrl=(u=e.baseUrl)!=null?u:J,e.routes=(d=e.routes)!=null?d:[],e}function D(e,t,{defaultLocale:o=G,defaultDirection:n=Y,defaultLocaleRouteNameSuffix:a=z,routesNameSeparator:l=k,strategy:c=B,trailingSlash:s=M,localeCodes:i=[]}={}){const u=me(e);return{defaultLocale:t.defaultLocale||u.defaultLocale||o,defaultDirection:t.defaultDirection||u.defaultDirection||n,defaultLocaleRouteNameSuffix:t.defaultLocaleRouteNameSuffix||u.defaultLocaleRouteNameSuffix||a,routesNameSeparator:t.routesNameSeparator||u.routesNameSeparator||l,strategy:t.strategy||u.strategy||c,trailingSlash:t.trailingSlash||u.trailingSlash||s,localeCodes:t.localeCodes||u.localeCodes||i}}const We=new Set(["prefix_and_default","prefix_except_default"]);function b(e){const t=this.router,{routesNameSeparator:o}=D(t,this),n=e!=null?h.isRef(e)?h.unref(e):e:this.route;return n==null||!n.name?void 0:fe(n.name).split(o)[0]}function q(e,t){const o=V.call(this,e,t);return o==null?"":h.isVue3?o.redirectedFrom||o.fullPath:o.route.redirectedFrom||o.route.fullPath}function x(e,t){const o=V.call(this,e,t);return o==null?void 0:h.isVue3?o:o.route}function te(e,t){const o=V.call(this,e,t);return o==null?void 0:h.isVue3?o:o.location}function V(e,t){const o=this.router,n=this.i18n,a=t||X(n),{routesNameSeparator:l,defaultLocale:c,defaultLocaleRouteNameSuffix:s,strategy:i,trailingSlash:u}=D(o,this);let d=e;T(e)&&(d[0]==="/"?d={path:e}:d={name:e});let r=H({},d);if(r.path&&!r.name){let L=null;try{L=o.resolve(r)}catch{}const _=h.isVue3?L:L.route,I=b.call(this,_);T(I)?(r={name:de(I,a,{defaultLocale:c,strategy:i,routesNameSeparator:l,defaultLocaleRouteNameSuffix:s}),params:_.params,query:_.query,hash:_.hash},h.isVue3&&(r.state=_.state)):(!(a===c&&We.has(i))&&i!=="no_prefix"&&(r.path=`/${a}${r.path}`),r.path=u?Fe(r.path,!0):Ne(r.path,!0))}else if(!r.name&&!r.path&&(r.name=b.call(this,this.route)),r.name=de(r.name,a,{defaultLocale:c,strategy:i,routesNameSeparator:l,defaultLocaleRouteNameSuffix:s}),h.isVue2){const{params:L}=r;L&&L[0]===void 0&&L.pathMatch&&(L[0]=L.pathMatch)}try{const L=o.resolve(r);return(h.isVue3?L.name:L.route.name)?L:o.resolve(e)}catch(L){if(h.isVue3&&L.type===1)return null;if(h.isVue2)return null}}function j(e){const t=this.route,o=b.call(this,t);if(!o)return"";const{params:n,...a}=!h.isVue3&&h.isRef(t)?t.value:t,c={name:o,params:{...n,...{}}};h.isVue2&&(c.params[0]=n.pathMatch);const s=H({},a,c);return q.call(this,s,e)}function oe({addDirAttribute:e=!1,addSeoAttributes:t=!1}={}){const o=this.router,n=this.i18n,{defaultDirection:a}=D(o,this),l={htmlAttrs:{},link:[],meta:[]};if(n.locales==null||n.__baseUrl==null)return l;const c=X(n),s=re(n),i=ce(s).find(r=>r.code===c)||{code:c},u=i.iso,d=i.dir||a;return e&&(l.htmlAttrs.dir=d),t&&c&&n.locales&&(u&&(l.htmlAttrs.lang=u),Qe.call(this,s,n.__baseUrl,l.link),Ye.call(this,n.__baseUrl,l.link,t),Je(i,u,l.meta),Ke(s,u,l.meta)),l}function Qe(e,t,o){const n=this.router,{defaultLocale:a,strategy:l}=D(n,this);if(l===Q.NO_PREFIX)return;const c=new Map;for(const s of e){const i=s.iso;if(!i){ae("Locale ISO code is required to generate alternate link");continue}const[u,d]=i.split("-");u&&d&&(s.isCatchallLocale||!c.has(u))&&c.set(u,s),c.set(i,s)}for(const[s,i]of c.entries()){const u=j.call(this,i.code);u&&o.push({hid:`i18n-alt-${s}`,rel:"alternate",href:ne(u,t),hreflang:s})}if(a){const s=j.call(this,a);s&&o.push({hid:"i18n-xd",rel:"alternate",href:ne(s,t),hreflang:"x-default"})}}function Ye(e,t,o){const n=this.route,a=x.call(this,{...n,name:b.call(this,n)});if(a){let l=ne(a.path,e);const c=K(o)&&o.canonicalQueries||[];if(c.length){const s=a.query,i=new URLSearchParams;for(const d of c)if(d in s){const r=s[d];Te(r)?r.forEach(L=>i.append(d,L||"")):i.append(d,r||"")}const u=i.toString();u&&(l=`${l}?${u}`)}t.push({hid:"i18n-can",rel:"canonical",href:l})}}function Je(e,t,o){!(e&&t)||o.push({hid:"i18n-og",property:"og:locale",content:Ee(t)})}function Ke(e,t,o){const n=e.filter(a=>{const l=a.iso;return l&&l!==t});if(n.length){const a=n.map(l=>({hid:`i18n-og-alt-${l.iso}`,property:"og:locale:alternate",content:Ee(l.iso)}));o.push(...a)}}function Ee(e){return(e||"").replace(/-/g,"_")}function ne(e,t){return e.match(/^https?:\/\//)?e:t+e}function W(e,t){const{router:o,route:n,i18n:a,defaultLocale:l,strategy:c,defaultLocaleRouteNameSuffix:s,trailingSlash:i,routesNameSeparator:u}=e;return function(...d){return Reflect.apply(t,{router:o,route:n,i18n:a,defaultLocale:l,strategy:c,defaultLocaleRouteNameSuffix:s,trailingSlash:i,routesNameSeparator:u},d)}}function Ze(e=g.useRoute(),{router:t=g.useRouter(),routesNameSeparator:o=void 0}={}){const n={router:t,route:e,routesNameSeparator:o};return b.call(n,e)}function et({router:e=g.useRouter(),route:t=g.useRoute(),i18n:o=w.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:a=void 0,routesNameSeparator:l=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return W({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:a,routesNameSeparator:l,strategy:c,trailingSlash:s},q)}function tt({router:e=g.useRouter(),route:t=g.useRoute(),i18n:o=w.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:a=void 0,routesNameSeparator:l=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return W({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:a,routesNameSeparator:l,strategy:c,trailingSlash:s},x)}function ot({router:e=g.useRouter(),route:t=g.useRoute(),i18n:o=w.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:a=void 0,routesNameSeparator:l=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return W({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:a,routesNameSeparator:l,strategy:c,trailingSlash:s},te)}function nt({router:e=g.useRouter(),route:t=g.useRoute(),i18n:o=w.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:a=void 0,routesNameSeparator:l=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return W({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:a,routesNameSeparator:l,strategy:c,trailingSlash:s},j)}function lt({addDirAttribute:e=!1,addSeoAttributes:t=!1,strategy:o=void 0,defaultLocale:n=void 0,route:a=g.useRoute(),router:l=g.useRouter(),i18n:c=w.useI18n()}={}){const s=l,i=h.ref({htmlAttrs:{},link:[],meta:[]});function u(){i.value={htmlAttrs:{},link:[],meta:[]}}function d(r){i.value=Reflect.apply(oe,{router:l,route:r,i18n:c,defaultLocale:n,strategy:o},[{addDirAttribute:e,addSeoAttributes:t}])}if(we)if(h.isVue3){const r=h.watchEffect(()=>{u(),d(ue(s.currentRoute))});h.onUnmounted(()=>r())}else{const r=s.afterEach((L,_)=>{u(),d(L)});h.onUnmounted(()=>r()),d(a)}else d(ue(s.currentRoute));return i}const at="0.1.2";return f.DEFAULT_BASE_URL=J,f.DEFAULT_DETECTION_DIRECTION=Y,f.DEFAULT_LOCALE=G,f.DEFAULT_LOCALE_ROUTE_NAME_SUFFIX=z,f.DEFAULT_ROUTES_NAME_SEPARATOR=k,f.DEFAULT_STRATEGY=B,f.DEFAULT_TRAILING_SLASH=M,f.STRATEGIES=Q,f.VERSION=at,f.createLocaleFromRouteGetter=pe,f.createRouter=De,f.extendI18n=ge,f.findBrowserLocale=Me,f.getGlobalOptions=me,f.getLocale=X,f.getLocaleCodes=$e,f.getLocales=re,f.getLocalesRegex=Re,f.getRouteBaseName=b,f.isComposer=N,f.isExportedGlobalComposer=$,f.isI18nInstance=U,f.isLegacyVueI18n=y,f.isVueI18n=O,f.localeHead=oe,f.localeLocation=te,f.localePath=q,f.localeRoute=x,f.localizeRoutes=Le,f.proxyVueInstance=C,f.registerGlobalOptions=_e,f.resolveBaseUrl=he,f.resolveRoute=V,f.setLocale=ie,f.switchLocalePath=j,f.useLocaleHead=lt,f.useLocaleLocation=ot,f.useLocalePath=et,f.useLocaleRoute=tt,f.useRouteBaseName=Ze,f.useSwitchLocalePath=nt,Object.defineProperties(f,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),f}({},VueDemi,VueRouter,VueI18n); |
@@ -5,2 +5,2 @@ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("vue-demi"),p=require("@intlify/vue-router-bridge"),N=require("@intlify/vue-i18n-bridge"),ve=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},Ae=ve(p),K={PREFIX:"prefix",PREFIX_EXCEPT_DEFAULT:"prefix_except_default",PREFIX_AND_DEFAULT:"prefix_and_default",NO_PREFIX:"no_prefix"},$="",B=K.PREFIX_EXCEPT_DEFAULT,j=!1,G="___",M="default",Z="ltr",ee="";/*! | ||
* Released under the MIT License. | ||
*/process.env.NODE_ENV;const Ie=typeof Symbol=="function"&&typeof Symbol.toStringTag=="symbol",ye=e=>Ie?Symbol(e):e,w=Object.assign,Ce=Array.isArray,Te=e=>typeof e=="function",C=e=>typeof e=="string",xe=e=>typeof e=="boolean",be=e=>typeof e=="symbol",te=e=>e!==null&&typeof e=="object",Oe=/\/$|\/\?/;function Q(e="",t=!1){return t?Oe.test(e):e.endsWith("/")}function Pe(e="",t=!1){if(!t)return(Q(e)?e.slice(0,-1):e)||"/";if(!Q(e,!0))return e||"/";const[o,...n]=e.split("?");return(o.slice(0,-1)||"/")+(n.length?`?${n.join("?")}`:"")}function De(e="",t=!1){if(!t)return e.endsWith("/")?e:e+"/";if(Q(e,!0))return e||"/";const[o,...n]=e.split("?");return o+"/"+(n.length?`?${n.join("?")}`:"")}const Ue=typeof window<"u";function re(e,t){typeof console<"u"&&(console.warn("[vue-i18n-routing] "+e),t&&console.warn(t.stack))}function ie(e){e=e||[];const t=[];for(const o of e)C(o)?t.push({code:o}):t.push(o);return t}function O(e){return e!=null&&"global"in e&&"mode"in e}function P(e){return e!=null&&!("__composer"in e)&&d.isRef(e.locale)}function x(e){return e!=null&&"__composer"in e}function V(e){return e!=null&&!("__composer"in e)&&!d.isRef(e.locale)}function A(e){return e!=null&&("__VUE_I18N_BRIDGE__"in e||"_sync"in e)}function ue(e){return O(e)?P(e.global)?e.global:e.global.__composer:x(e)?e.__composer:e}function k(e){const t=O(e)?e.global:e;return P(t)?d.isVue2&&A(e)?e.locale:t.locale.value:(V(t)||x(t)||A(t),t.locale)}function fe(e){const t=O(e)?e.global:e;return P(t)?d.isVue2&&A(e)?e.locales:t.locales.value:(V(t)||x(t)||A(t),t.locales)}function Ne(e){const t=O(e)?e.global:e;return P(t)?d.isVue2&&A(e)?e.localeCodes:t.localeCodes.value:(V(t)||x(t)||A(t),t.localeCodes)}function de(e,t){const o=O(e)?e.global:e;if(P(o))d.isVue2&&A(e)?e.locale=t:o.locale.value=t;else if(V(o)||x(o)||A(o))o.locale=t;else throw new Error("TODO:")}function Ve(e,t,o){return e.replace(/\/+$/,"")+(t?"/":"")||(o?"":"/")}function se(e){return p.isVueRouter4,d.isRef(e)?e.value:e}function he(e){return C(e)?e:be(e)?e.toString():"(null)"}function ce(e,t,{defaultLocale:o,strategy:n,routesNameSeparator:a,defaultLocaleRouteNameSuffix:l}){let s=he(e)+(n==="no_prefix"?"":a+t);return t===o&&n==="prefix_and_default"&&(s+=a+l),s}function me(e,t){return Te(e)?e(t):e}function Fe(e,t){const o=[];for(const[n,a]of t.entries()){const l=e.find(s=>s.iso.toLowerCase()===a.toLowerCase());if(l){o.push({code:l.code,score:1-n/t.length});break}}for(const[n,a]of t.entries()){const l=a.split("-")[0].toLowerCase(),s=e.find(c=>c.iso.split("-")[0].toLowerCase()===l);if(s){o.push({code:s.code,score:.999-n/t.length});break}}return o}const we=Fe;function $e(e,t){return e.score===t.score?t.code.length-e.code.length:t.score-e.score}const Be=$e;function je(e,t,{matcher:o=we,comparer:n=Be}={}){const a=[];for(const s of e){const{code:c}=s,i=s.iso||c;a.push({code:c,iso:i})}const l=o(a,t);return l.length>1&&l.sort(n),l.length?l[0].code:""}function pe(e,{defaultLocale:t=$,strategy:o=B,trailingSlash:n=j,routesNameSeparator:a=G,defaultLocaleRouteNameSuffix:l=M,includeUprefixedFallback:s=!1,optionsResolver:c=void 0,locales:i=[]}={}){if(o==="no_prefix")return e;const u=i.map(r=>C(r)?r:r.code);function f(r,h,m=!1,v=!1){if(r.redirect&&(!r.component||!r.file))return[r];let R=null;if(c!=null&&(R=c(r,h),R==null))return[r];const g={locales:u,paths:{}};if(R!=null&&w(g,R),w(g,{locales:h}),g.locales.length>0&&R&&R.locales!=null&&R.locales.length>0){const _=[];for(const L of g.locales)R.locales.includes(L)&&_.push(L);g.locales=_}return g.locales.reduce((_,L)=>{const{name:D}=r;let{path:E}=r;const S={...r};D&&(S.name=`${D}${a}${L}`),r.children&&(S.children=r.children.reduce((y,W)=>[...y,...f(W,[L],!0,v)],[])),g.paths&&g.paths[L]&&(E=g.paths[L]);const b=L===t;if(b&&o==="prefix_and_default")if(m)m&&v&&D&&(S.name+=`${a}${l}`);else{const y={...S,path:E};if(D&&(y.name=`${S.name}${a}${l}`),r.children){y.children=[];for(const W of r.children)y.children=y.children.concat(f(W,[L],!0,!0))}_.push(y)}const le=m&&!E.startsWith("/"),ae=!le&&!(b&&o==="prefix_except_default");return ae&&(E=`/${L}${E}`),E&&(E=Ve(E,n,le)),ae&&b&&o==="prefix"&&s&&_.push({...r}),S.path=E,_.push(S),_},[])}return e.reduce((r,h)=>[...r,...f(h,u||[])],[])}function I(e){return function(){return Reflect.apply(e,{getRouteBaseName:this.getRouteBaseName,localePath:this.localePath,localeRoute:this.localeRoute,localeLocation:this.localeLocation,resolveRoute:this.resolveRoute,switchLocalePath:this.switchLocalePath,localeHead:this.localeHead,i18n:this.$i18n,route:this.$route,router:this.$router},arguments)}}function Le(e,{locales:t=[],localeCodes:o=[],baseUrl:n=ee,hooks:a={}}={}){const l=d.effectScope(),s=e.install;return e.install=(c,...i)=>{Reflect.apply(s,e,[c,...i]);const u=ue(e);l.run(()=>Ge(u,{locales:t,localeCodes:o,baseUrl:n,hooks:a})),x(e.global)&&ke(e.global,a.onExtendVueI18n);const f=c,r=e.mode==="composition"?d.isVue3?f.config.globalProperties.$i18n:e:d.isVue2?e:null;if(r&&Me(r,u,a.onExtendExportedGlobal),(ze(i[0])?i[0]:{inject:!0}).inject&&c.mixin({methods:{resolveRoute:I(F),localePath:I(H),localeRoute:I(X),localeLocation:I(oe),switchLocalePath:I(U),getRouteBaseName:I(T),localeHead:I(ne)}}),f.unmount){const m=f.unmount;f.unmount=()=>{l.stop(),m()}}},l}function Ge(e,t){const{locales:o,localeCodes:n,baseUrl:a}=t,l=d.ref(o),s=d.ref(n);e.locales=d.computed(()=>l.value),e.localeCodes=d.computed(()=>s.value),e.__baseUrl=me(a,{}),t.hooks&&t.hooks.onExtendComposer&&t.hooks.onExtendComposer(e)}function Me(e,t,o){const n=[{locales:{get(){return t.locales.value}},localeCodes:{get(){return t.localeCodes.value}},__baseUrl:{get(){return t.__baseUrl}}}];o&&n.push(o(t));for(const a of n)for(const[l,s]of Object.entries(a))Object.defineProperty(e,l,s)}function ke(e,t){const o=ue(e),n=[{locales:{get(){return o.locales.value}},localeCodes:{get(){return o.localeCodes.value}},__baseUrl:{get(){return o.__baseUrl}}}];t&&n.push(t(o));for(const a of n)for(const[l,s]of Object.entries(a))Object.defineProperty(e,l,s)}function ze(e){return te(e)&&"inject"in e&&xe(e.inject)}const Y=ye("vue-i18n-routing-gor");function ge(e,t){e[Y]?re("already registered global options"):e[Y]=t}function Re(e){var t;return(t=e[Y])!=null?t:{}}function He(e,t={}){const{version:o,defaultLocale:n,locales:a,strategy:l,trailingSlash:s,routesNameSeparator:c,defaultLocaleRouteNameSuffix:i,defaultDirection:u,baseUrl:f,routes:r,routeOptionsResolver:h}=qe(t),m=ie(a),v=m.map(L=>L.code),R=Ee(v,c,i);Le(e,{locales:m,baseUrl:f,localeCodes:v});const g=pe(r,{locales:a,defaultLocale:n,strategy:l,trailingSlash:s,routesNameSeparator:c,defaultLocaleRouteNameSuffix:i,optionsResolver:h});t.routes=g;const _=Xe(t,o);return ge(_,{defaultLocale:n,localeCodes:v,strategy:l,trailingSlash:s,routesNameSeparator:c,defaultLocaleRouteNameSuffix:i,defaultDirection:u}),_.beforeEach((L,D,E)=>{const S=k(e),b=R(L)||S||n||"";S!==b&&de(e,b),E()}),_}function Xe(e,t){if(d.isVue3&&t===4)return p.createRouter(e);if(d.isVue2&&t===3)return new Ae.default(e);throw new Error("TODO:")}function _e(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function Ee(e,t,o){const n=`(${e.join("|")})`,a=`(?:${t}${o})?`,l=new RegExp(`${t}${n}${a}$`,"i"),s=_e(e);return i=>{if(te(i)){if(i.name){const f=(C(i.name)?i.name:i.name.toString()).match(l);if(f&&f.length>1)return f[1]}else if(i.path){const u=i.path.match(s);if(u&&u.length>1)return u[1]}}else if(C(i)){const u=i.match(s);if(u&&u.length>1)return u[1]}return""}}function qe(e){var t,o,n,a,l,s,c,i,u,f;return e.version=(t=e.version)!=null?t:4,e.defaultLocale=(o=e.defaultLocale)!=null?o:$,e.strategy=(n=e.strategy)!=null?n:B,e.trailingSlash=(a=e.trailingSlash)!=null?a:j,e.routesNameSeparator=(l=e.routesNameSeparator)!=null?l:G,e.defaultLocaleRouteNameSuffix=(s=e.defaultLocaleRouteNameSuffix)!=null?s:M,e.locales=(c=e.locales)!=null?c:[],e.defaultDirection=(i=e.defaultDirection)!=null?i:Z,e.baseUrl=(u=e.baseUrl)!=null?u:ee,e.routes=(f=e.routes)!=null?f:[],e}function z(e,t,{defaultLocale:o=$,defaultDirection:n=Z,defaultLocaleRouteNameSuffix:a=M,routesNameSeparator:l=G,strategy:s=B,trailingSlash:c=j,localeCodes:i=[]}={}){const u=Re(e);return{defaultLocale:t.defaultLocale||u.defaultLocale||o,defaultDirection:t.defaultDirection||u.defaultDirection||n,defaultLocaleRouteNameSuffix:t.defaultLocaleRouteNameSuffix||u.defaultLocaleRouteNameSuffix||a,routesNameSeparator:t.routesNameSeparator||u.routesNameSeparator||l,strategy:t.strategy||u.strategy||s,trailingSlash:t.trailingSlash||u.trailingSlash||c,localeCodes:t.localeCodes||u.localeCodes||i}}const We=new Set(["prefix_and_default","prefix_except_default"]);function T(e){const t=this.router,{routesNameSeparator:o}=z(t,this),n=e!=null?d.isRef(e)?d.unref(e):e:this.route;return n==null||!n.name?void 0:he(n.name).split(o)[0]}function H(e,t){const o=F.call(this,e,t);return o==null?"":d.isVue3?o.redirectedFrom||o.fullPath:o.route.redirectedFrom||o.route.fullPath}function X(e,t){const o=F.call(this,e,t);return o==null?void 0:d.isVue3?o:o.route}function oe(e,t){const o=F.call(this,e,t);return o==null?void 0:d.isVue3?o:o.location}function F(e,t){const o=this.router,n=this.i18n,a=t||k(n),{routesNameSeparator:l,defaultLocale:s,defaultLocaleRouteNameSuffix:c,strategy:i,trailingSlash:u}=z(o,this);let f=e;C(e)&&(f[0]==="/"?f={path:e}:f={name:e});let r=w({},f);if(r.path&&!r.name){let h=null;try{h=o.resolve(r)}catch{}const m=d.isVue3?h:h.route,v=T.call(this,m);C(v)?(r={name:ce(v,a,{defaultLocale:s,strategy:i,routesNameSeparator:l,defaultLocaleRouteNameSuffix:c}),params:m.params,query:m.query,hash:m.hash},d.isVue3&&(r.state=m.state)):(!(a===s&&We.has(i))&&i!=="no_prefix"&&(r.path=`/${a}${r.path}`),r.path=u?De(r.path,!0):Pe(r.path,!0))}else if(!r.name&&!r.path&&(r.name=T.call(this,this.route)),r.name=ce(r.name,a,{defaultLocale:s,strategy:i,routesNameSeparator:l,defaultLocaleRouteNameSuffix:c}),d.isVue2){const{params:h}=r;h&&h[0]===void 0&&h.pathMatch&&(h[0]=h.pathMatch)}try{const h=o.resolve(r);return(d.isVue3?h.name:h.route.name)?h:o.resolve(e)}catch(h){if(d.isVue3&&h.type===1)return null;if(d.isVue2)return null}}function U(e){const t=this.route,o=T.call(this,t);if(!o)return"";const{params:n,...a}=!d.isVue3&&d.isRef(t)?t.value:t,s={name:o,params:{...n,...{}}};d.isVue2&&(s.params[0]=n.pathMatch);const c=w({},a,s);return H.call(this,c,e)}function ne({addDirAttribute:e=!1,addSeoAttributes:t=!1}={}){const o=this.router,n=this.i18n,{defaultDirection:a}=z(o,this),l={htmlAttrs:{},link:[],meta:[]};if(n.locales==null||n.__baseUrl==null)return l;const s=k(n),c=fe(n),i=ie(c).find(r=>r.code===s)||{code:s},u=i.iso,f=i.dir||a;return e&&(l.htmlAttrs.dir=f),t&&s&&n.locales&&(u&&(l.htmlAttrs.lang=u),Qe.call(this,c,n.__baseUrl,l.link),Ye.call(this,n.__baseUrl,l.link,t),Je(i,u,l.meta),Ke(c,u,l.meta)),l}function Qe(e,t,o){const n=this.router,{defaultLocale:a,strategy:l}=z(n,this);if(l===K.NO_PREFIX)return;const s=new Map;for(const c of e){const i=c.iso;if(!i){re("Locale ISO code is required to generate alternate link");continue}const[u,f]=i.split("-");u&&f&&(c.isCatchallLocale||!s.has(u))&&s.set(u,c),s.set(i,c)}for(const[c,i]of s.entries()){const u=U.call(this,i.code);u&&o.push({hid:`i18n-alt-${c}`,rel:"alternate",href:J(u,t),hreflang:c})}if(a){const c=U.call(this,a);c&&o.push({hid:"i18n-xd",rel:"alternate",href:J(c,t),hreflang:"x-default"})}}function Ye(e,t,o){const n=this.route,a=X.call(this,{...n,name:T.call(this,n)});if(a){let l=J(a.path,e);const s=te(o)&&o.canonicalQueries||[];if(s.length){const c=a.query,i=new URLSearchParams;for(const f of s)if(f in c){const r=c[f];Ce(r)?r.forEach(h=>i.append(f,h||"")):i.append(f,r||"")}const u=i.toString();u&&(l=`${l}?${u}`)}t.push({hid:"i18n-can",rel:"canonical",href:l})}}function Je(e,t,o){!(e&&t)||o.push({hid:"i18n-og",property:"og:locale",content:Se(t)})}function Ke(e,t,o){const n=e.filter(a=>{const l=a.iso;return l&&l!==t});if(n.length){const a=n.map(l=>({hid:`i18n-og-alt-${l.iso}`,property:"og:locale:alternate",content:Se(l.iso)}));o.push(...a)}}function Se(e){return(e||"").replace(/-/g,"_")}function J(e,t){return e.match(/^https?:\/\//)?e:t+e}function q(e,t){const{router:o,route:n,i18n:a,defaultLocale:l,strategy:s,defaultLocaleRouteNameSuffix:c,trailingSlash:i,routesNameSeparator:u}=e;return function(...f){return Reflect.apply(t,{router:o,route:n,i18n:a,defaultLocale:l,strategy:s,defaultLocaleRouteNameSuffix:c,trailingSlash:i,routesNameSeparator:u},f)}}function Ze(e=p.useRoute(),{router:t=p.useRouter(),routesNameSeparator:o=void 0}={}){const n={router:t,route:e,routesNameSeparator:o};return T.call(n,e)}function et({router:e=p.useRouter(),route:t=p.useRoute(),i18n:o=N.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:a=void 0,routesNameSeparator:l=void 0,strategy:s=void 0,trailingSlash:c=void 0}={}){return q({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:a,routesNameSeparator:l,strategy:s,trailingSlash:c},H)}function tt({router:e=p.useRouter(),route:t=p.useRoute(),i18n:o=N.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:a=void 0,routesNameSeparator:l=void 0,strategy:s=void 0,trailingSlash:c=void 0}={}){return q({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:a,routesNameSeparator:l,strategy:s,trailingSlash:c},X)}function ot({router:e=p.useRouter(),route:t=p.useRoute(),i18n:o=N.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:a=void 0,routesNameSeparator:l=void 0,strategy:s=void 0,trailingSlash:c=void 0}={}){return q({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:a,routesNameSeparator:l,strategy:s,trailingSlash:c},oe)}function nt({router:e=p.useRouter(),route:t=p.useRoute(),i18n:o=N.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:a=void 0,routesNameSeparator:l=void 0,strategy:s=void 0,trailingSlash:c=void 0}={}){return q({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:a,routesNameSeparator:l,strategy:s,trailingSlash:c},U)}function lt({addDirAttribute:e=!1,addSeoAttributes:t=!1,strategy:o=void 0,defaultLocale:n=void 0,route:a=p.useRoute(),router:l=p.useRouter(),i18n:s=N.useI18n()}={}){const c=l,i=d.ref({htmlAttrs:{},link:[],meta:[]});function u(){i.value={htmlAttrs:{},link:[],meta:[]}}function f(r){i.value=Reflect.apply(ne,{router:l,route:r,i18n:s,defaultLocale:n,strategy:o},[{addDirAttribute:e,addSeoAttributes:t}])}if(Ue)if(d.isVue3){const r=d.watchEffect(()=>{u(),f(se(c.currentRoute))});d.onUnmounted(()=>r())}else{const r=c.afterEach((h,m)=>{u(),f(h)});d.onUnmounted(()=>r()),f(a)}else f(se(c.currentRoute));return i}const at="0.1.1";exports.DEFAULT_BASE_URL=ee;exports.DEFAULT_DETECTION_DIRECTION=Z;exports.DEFAULT_LOCALE=$;exports.DEFAULT_LOCALE_ROUTE_NAME_SUFFIX=M;exports.DEFAULT_ROUTES_NAME_SEPARATOR=G;exports.DEFAULT_STRATEGY=B;exports.DEFAULT_TRAILING_SLASH=j;exports.STRATEGIES=K;exports.VERSION=at;exports.createLocaleFromRouteGetter=Ee;exports.createRouter=He;exports.extendI18n=Le;exports.findBrowserLocale=je;exports.getGlobalOptions=Re;exports.getLocale=k;exports.getLocaleCodes=Ne;exports.getLocales=fe;exports.getLocalesRegex=_e;exports.getRouteBaseName=T;exports.isComposer=P;exports.isExportedGlobalComposer=V;exports.isI18nInstance=O;exports.isLegacyVueI18n=A;exports.isVueI18n=x;exports.localeHead=ne;exports.localeLocation=oe;exports.localePath=H;exports.localeRoute=X;exports.localizeRoutes=pe;exports.proxyVueInstance=I;exports.registerGlobalOptions=ge;exports.resolveBaseUrl=me;exports.resolveRoute=F;exports.setLocale=de;exports.switchLocalePath=U;exports.useLocaleHead=lt;exports.useLocaleLocation=ot;exports.useLocalePath=et;exports.useLocaleRoute=tt;exports.useRouteBaseName=Ze;exports.useSwitchLocalePath=nt; | ||
*/process.env.NODE_ENV;const Ie=typeof Symbol=="function"&&typeof Symbol.toStringTag=="symbol",ye=e=>Ie?Symbol(e):e,w=Object.assign,Ce=Array.isArray,Te=e=>typeof e=="function",C=e=>typeof e=="string",xe=e=>typeof e=="boolean",be=e=>typeof e=="symbol",te=e=>e!==null&&typeof e=="object",Oe=/\/$|\/\?/;function Q(e="",t=!1){return t?Oe.test(e):e.endsWith("/")}function Pe(e="",t=!1){if(!t)return(Q(e)?e.slice(0,-1):e)||"/";if(!Q(e,!0))return e||"/";const[o,...n]=e.split("?");return(o.slice(0,-1)||"/")+(n.length?`?${n.join("?")}`:"")}function De(e="",t=!1){if(!t)return e.endsWith("/")?e:e+"/";if(Q(e,!0))return e||"/";const[o,...n]=e.split("?");return o+"/"+(n.length?`?${n.join("?")}`:"")}const Ue=typeof window<"u";function re(e,t){typeof console<"u"&&(console.warn("[vue-i18n-routing] "+e),t&&console.warn(t.stack))}function ie(e){e=e||[];const t=[];for(const o of e)C(o)?t.push({code:o}):t.push(o);return t}function O(e){return e!=null&&"global"in e&&"mode"in e}function P(e){return e!=null&&!("__composer"in e)&&d.isRef(e.locale)}function x(e){return e!=null&&"__composer"in e}function V(e){return e!=null&&!("__composer"in e)&&!d.isRef(e.locale)}function A(e){return e!=null&&("__VUE_I18N_BRIDGE__"in e||"_sync"in e)}function ue(e){return O(e)?P(e.global)?e.global:e.global.__composer:x(e)?e.__composer:e}function k(e){const t=O(e)?e.global:e;return P(t)?d.isVue2&&A(e)?e.locale:t.locale.value:(V(t)||x(t)||A(t),t.locale)}function fe(e){const t=O(e)?e.global:e;return P(t)?d.isVue2&&A(e)?e.locales:t.locales.value:(V(t)||x(t)||A(t),t.locales)}function Ne(e){const t=O(e)?e.global:e;return P(t)?d.isVue2&&A(e)?e.localeCodes:t.localeCodes.value:(V(t)||x(t)||A(t),t.localeCodes)}function de(e,t){const o=O(e)?e.global:e;if(P(o))d.isVue2&&A(e)?e.locale=t:o.locale.value=t;else if(V(o)||x(o)||A(o))o.locale=t;else throw new Error("TODO:")}function Ve(e,t,o){return e.replace(/\/+$/,"")+(t?"/":"")||(o?"":"/")}function se(e){return p.isVueRouter4,d.isRef(e)?e.value:e}function he(e){return C(e)?e:be(e)?e.toString():"(null)"}function ce(e,t,{defaultLocale:o,strategy:n,routesNameSeparator:a,defaultLocaleRouteNameSuffix:l}){let s=he(e)+(n==="no_prefix"?"":a+t);return t===o&&n==="prefix_and_default"&&(s+=a+l),s}function me(e,t){return Te(e)?e(t):e}function Fe(e,t){const o=[];for(const[n,a]of t.entries()){const l=e.find(s=>s.iso.toLowerCase()===a.toLowerCase());if(l){o.push({code:l.code,score:1-n/t.length});break}}for(const[n,a]of t.entries()){const l=a.split("-")[0].toLowerCase(),s=e.find(c=>c.iso.split("-")[0].toLowerCase()===l);if(s){o.push({code:s.code,score:.999-n/t.length});break}}return o}const we=Fe;function $e(e,t){return e.score===t.score?t.code.length-e.code.length:t.score-e.score}const Be=$e;function je(e,t,{matcher:o=we,comparer:n=Be}={}){const a=[];for(const s of e){const{code:c}=s,i=s.iso||c;a.push({code:c,iso:i})}const l=o(a,t);return l.length>1&&l.sort(n),l.length?l[0].code:""}function pe(e,{defaultLocale:t=$,strategy:o=B,trailingSlash:n=j,routesNameSeparator:a=G,defaultLocaleRouteNameSuffix:l=M,includeUprefixedFallback:s=!1,optionsResolver:c=void 0,locales:i=[]}={}){if(o==="no_prefix")return e;const u=i.map(r=>C(r)?r:r.code);function f(r,h,m=!1,v=!1){if(r.redirect&&(!r.component||!r.file))return[r];let R=null;if(c!=null&&(R=c(r,h),R==null))return[r];const g={locales:u,paths:{}};if(R!=null&&w(g,R),w(g,{locales:h}),g.locales.length>0&&R&&R.locales!=null&&R.locales.length>0){const _=[];for(const L of g.locales)R.locales.includes(L)&&_.push(L);g.locales=_}return g.locales.reduce((_,L)=>{const{name:D}=r;let{path:E}=r;const S={...r};D&&(S.name=`${D}${a}${L}`),r.children&&(S.children=r.children.reduce((y,W)=>[...y,...f(W,[L],!0,v)],[])),g.paths&&g.paths[L]&&(E=g.paths[L]);const b=L===t;if(b&&o==="prefix_and_default")if(m)m&&v&&D&&(S.name+=`${a}${l}`);else{const y={...S,path:E};if(D&&(y.name=`${S.name}${a}${l}`),r.children){y.children=[];for(const W of r.children)y.children=y.children.concat(f(W,[L],!0,!0))}_.push(y)}const le=m&&!E.startsWith("/"),ae=!le&&!(b&&o==="prefix_except_default");return ae&&(E=`/${L}${E}`),E&&(E=Ve(E,n,le)),ae&&b&&o==="prefix"&&s&&_.push({...r}),S.path=E,_.push(S),_},[])}return e.reduce((r,h)=>[...r,...f(h,u||[])],[])}function I(e){return function(){return Reflect.apply(e,{getRouteBaseName:this.getRouteBaseName,localePath:this.localePath,localeRoute:this.localeRoute,localeLocation:this.localeLocation,resolveRoute:this.resolveRoute,switchLocalePath:this.switchLocalePath,localeHead:this.localeHead,i18n:this.$i18n,route:this.$route,router:this.$router},arguments)}}function Le(e,{locales:t=[],localeCodes:o=[],baseUrl:n=ee,hooks:a={}}={}){const l=d.effectScope(),s=e.install;return e.install=(c,...i)=>{Reflect.apply(s,e,[c,...i]);const u=ue(e);l.run(()=>Ge(u,{locales:t,localeCodes:o,baseUrl:n,hooks:a})),x(e.global)&&ke(e.global,a.onExtendVueI18n);const f=c,r=e.mode==="composition"?d.isVue3?f.config.globalProperties.$i18n:e:d.isVue2?e:null;if(r&&Me(r,u,a.onExtendExportedGlobal),(ze(i[0])?i[0]:{inject:!0}).inject&&c.mixin({methods:{resolveRoute:I(F),localePath:I(H),localeRoute:I(X),localeLocation:I(oe),switchLocalePath:I(U),getRouteBaseName:I(T),localeHead:I(ne)}}),f.unmount){const m=f.unmount;f.unmount=()=>{l.stop(),m()}}},l}function Ge(e,t){const{locales:o,localeCodes:n,baseUrl:a}=t,l=d.ref(o),s=d.ref(n);e.locales=d.computed(()=>l.value),e.localeCodes=d.computed(()=>s.value),e.__baseUrl=me(a,{}),t.hooks&&t.hooks.onExtendComposer&&t.hooks.onExtendComposer(e)}function Me(e,t,o){const n=[{locales:{get(){return t.locales.value}},localeCodes:{get(){return t.localeCodes.value}},__baseUrl:{get(){return t.__baseUrl}}}];o&&n.push(o(t));for(const a of n)for(const[l,s]of Object.entries(a))Object.defineProperty(e,l,s)}function ke(e,t){const o=ue(e),n=[{locales:{get(){return o.locales.value}},localeCodes:{get(){return o.localeCodes.value}},__baseUrl:{get(){return o.__baseUrl}}}];t&&n.push(t(o));for(const a of n)for(const[l,s]of Object.entries(a))Object.defineProperty(e,l,s)}function ze(e){return te(e)&&"inject"in e&&xe(e.inject)}const Y=ye("vue-i18n-routing-gor");function ge(e,t){e[Y]?re("already registered global options"):e[Y]=t}function Re(e){var t;return(t=e[Y])!=null?t:{}}function He(e,t={}){const{version:o,defaultLocale:n,locales:a,strategy:l,trailingSlash:s,routesNameSeparator:c,defaultLocaleRouteNameSuffix:i,defaultDirection:u,baseUrl:f,routes:r,routeOptionsResolver:h}=qe(t),m=ie(a),v=m.map(L=>L.code),R=Ee(v,c,i);Le(e,{locales:m,baseUrl:f,localeCodes:v});const g=pe(r,{locales:a,defaultLocale:n,strategy:l,trailingSlash:s,routesNameSeparator:c,defaultLocaleRouteNameSuffix:i,optionsResolver:h});t.routes=g;const _=Xe(t,o);return ge(_,{defaultLocale:n,localeCodes:v,strategy:l,trailingSlash:s,routesNameSeparator:c,defaultLocaleRouteNameSuffix:i,defaultDirection:u}),_.beforeEach((L,D,E)=>{const S=k(e),b=R(L)||S||n||"";S!==b&&de(e,b),E()}),_}function Xe(e,t){if(d.isVue3&&t===4)return p.createRouter(e);if(d.isVue2&&t===3)return new Ae.default(e);throw new Error("TODO:")}function _e(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function Ee(e,t,o){const n=`(${e.join("|")})`,a=`(?:${t}${o})?`,l=new RegExp(`${t}${n}${a}$`,"i"),s=_e(e);return i=>{if(te(i)){if(i.name){const f=(C(i.name)?i.name:i.name.toString()).match(l);if(f&&f.length>1)return f[1]}else if(i.path){const u=i.path.match(s);if(u&&u.length>1)return u[1]}}else if(C(i)){const u=i.match(s);if(u&&u.length>1)return u[1]}return""}}function qe(e){var t,o,n,a,l,s,c,i,u,f;return e.version=(t=e.version)!=null?t:4,e.defaultLocale=(o=e.defaultLocale)!=null?o:$,e.strategy=(n=e.strategy)!=null?n:B,e.trailingSlash=(a=e.trailingSlash)!=null?a:j,e.routesNameSeparator=(l=e.routesNameSeparator)!=null?l:G,e.defaultLocaleRouteNameSuffix=(s=e.defaultLocaleRouteNameSuffix)!=null?s:M,e.locales=(c=e.locales)!=null?c:[],e.defaultDirection=(i=e.defaultDirection)!=null?i:Z,e.baseUrl=(u=e.baseUrl)!=null?u:ee,e.routes=(f=e.routes)!=null?f:[],e}function z(e,t,{defaultLocale:o=$,defaultDirection:n=Z,defaultLocaleRouteNameSuffix:a=M,routesNameSeparator:l=G,strategy:s=B,trailingSlash:c=j,localeCodes:i=[]}={}){const u=Re(e);return{defaultLocale:t.defaultLocale||u.defaultLocale||o,defaultDirection:t.defaultDirection||u.defaultDirection||n,defaultLocaleRouteNameSuffix:t.defaultLocaleRouteNameSuffix||u.defaultLocaleRouteNameSuffix||a,routesNameSeparator:t.routesNameSeparator||u.routesNameSeparator||l,strategy:t.strategy||u.strategy||s,trailingSlash:t.trailingSlash||u.trailingSlash||c,localeCodes:t.localeCodes||u.localeCodes||i}}const We=new Set(["prefix_and_default","prefix_except_default"]);function T(e){const t=this.router,{routesNameSeparator:o}=z(t,this),n=e!=null?d.isRef(e)?d.unref(e):e:this.route;return n==null||!n.name?void 0:he(n.name).split(o)[0]}function H(e,t){const o=F.call(this,e,t);return o==null?"":d.isVue3?o.redirectedFrom||o.fullPath:o.route.redirectedFrom||o.route.fullPath}function X(e,t){const o=F.call(this,e,t);return o==null?void 0:d.isVue3?o:o.route}function oe(e,t){const o=F.call(this,e,t);return o==null?void 0:d.isVue3?o:o.location}function F(e,t){const o=this.router,n=this.i18n,a=t||k(n),{routesNameSeparator:l,defaultLocale:s,defaultLocaleRouteNameSuffix:c,strategy:i,trailingSlash:u}=z(o,this);let f=e;C(e)&&(f[0]==="/"?f={path:e}:f={name:e});let r=w({},f);if(r.path&&!r.name){let h=null;try{h=o.resolve(r)}catch{}const m=d.isVue3?h:h.route,v=T.call(this,m);C(v)?(r={name:ce(v,a,{defaultLocale:s,strategy:i,routesNameSeparator:l,defaultLocaleRouteNameSuffix:c}),params:m.params,query:m.query,hash:m.hash},d.isVue3&&(r.state=m.state)):(!(a===s&&We.has(i))&&i!=="no_prefix"&&(r.path=`/${a}${r.path}`),r.path=u?De(r.path,!0):Pe(r.path,!0))}else if(!r.name&&!r.path&&(r.name=T.call(this,this.route)),r.name=ce(r.name,a,{defaultLocale:s,strategy:i,routesNameSeparator:l,defaultLocaleRouteNameSuffix:c}),d.isVue2){const{params:h}=r;h&&h[0]===void 0&&h.pathMatch&&(h[0]=h.pathMatch)}try{const h=o.resolve(r);return(d.isVue3?h.name:h.route.name)?h:o.resolve(e)}catch(h){if(d.isVue3&&h.type===1)return null;if(d.isVue2)return null}}function U(e){const t=this.route,o=T.call(this,t);if(!o)return"";const{params:n,...a}=!d.isVue3&&d.isRef(t)?t.value:t,s={name:o,params:{...n,...{}}};d.isVue2&&(s.params[0]=n.pathMatch);const c=w({},a,s);return H.call(this,c,e)}function ne({addDirAttribute:e=!1,addSeoAttributes:t=!1}={}){const o=this.router,n=this.i18n,{defaultDirection:a}=z(o,this),l={htmlAttrs:{},link:[],meta:[]};if(n.locales==null||n.__baseUrl==null)return l;const s=k(n),c=fe(n),i=ie(c).find(r=>r.code===s)||{code:s},u=i.iso,f=i.dir||a;return e&&(l.htmlAttrs.dir=f),t&&s&&n.locales&&(u&&(l.htmlAttrs.lang=u),Qe.call(this,c,n.__baseUrl,l.link),Ye.call(this,n.__baseUrl,l.link,t),Je(i,u,l.meta),Ke(c,u,l.meta)),l}function Qe(e,t,o){const n=this.router,{defaultLocale:a,strategy:l}=z(n,this);if(l===K.NO_PREFIX)return;const s=new Map;for(const c of e){const i=c.iso;if(!i){re("Locale ISO code is required to generate alternate link");continue}const[u,f]=i.split("-");u&&f&&(c.isCatchallLocale||!s.has(u))&&s.set(u,c),s.set(i,c)}for(const[c,i]of s.entries()){const u=U.call(this,i.code);u&&o.push({hid:`i18n-alt-${c}`,rel:"alternate",href:J(u,t),hreflang:c})}if(a){const c=U.call(this,a);c&&o.push({hid:"i18n-xd",rel:"alternate",href:J(c,t),hreflang:"x-default"})}}function Ye(e,t,o){const n=this.route,a=X.call(this,{...n,name:T.call(this,n)});if(a){let l=J(a.path,e);const s=te(o)&&o.canonicalQueries||[];if(s.length){const c=a.query,i=new URLSearchParams;for(const f of s)if(f in c){const r=c[f];Ce(r)?r.forEach(h=>i.append(f,h||"")):i.append(f,r||"")}const u=i.toString();u&&(l=`${l}?${u}`)}t.push({hid:"i18n-can",rel:"canonical",href:l})}}function Je(e,t,o){!(e&&t)||o.push({hid:"i18n-og",property:"og:locale",content:Se(t)})}function Ke(e,t,o){const n=e.filter(a=>{const l=a.iso;return l&&l!==t});if(n.length){const a=n.map(l=>({hid:`i18n-og-alt-${l.iso}`,property:"og:locale:alternate",content:Se(l.iso)}));o.push(...a)}}function Se(e){return(e||"").replace(/-/g,"_")}function J(e,t){return e.match(/^https?:\/\//)?e:t+e}function q(e,t){const{router:o,route:n,i18n:a,defaultLocale:l,strategy:s,defaultLocaleRouteNameSuffix:c,trailingSlash:i,routesNameSeparator:u}=e;return function(...f){return Reflect.apply(t,{router:o,route:n,i18n:a,defaultLocale:l,strategy:s,defaultLocaleRouteNameSuffix:c,trailingSlash:i,routesNameSeparator:u},f)}}function Ze(e=p.useRoute(),{router:t=p.useRouter(),routesNameSeparator:o=void 0}={}){const n={router:t,route:e,routesNameSeparator:o};return T.call(n,e)}function et({router:e=p.useRouter(),route:t=p.useRoute(),i18n:o=N.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:a=void 0,routesNameSeparator:l=void 0,strategy:s=void 0,trailingSlash:c=void 0}={}){return q({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:a,routesNameSeparator:l,strategy:s,trailingSlash:c},H)}function tt({router:e=p.useRouter(),route:t=p.useRoute(),i18n:o=N.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:a=void 0,routesNameSeparator:l=void 0,strategy:s=void 0,trailingSlash:c=void 0}={}){return q({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:a,routesNameSeparator:l,strategy:s,trailingSlash:c},X)}function ot({router:e=p.useRouter(),route:t=p.useRoute(),i18n:o=N.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:a=void 0,routesNameSeparator:l=void 0,strategy:s=void 0,trailingSlash:c=void 0}={}){return q({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:a,routesNameSeparator:l,strategy:s,trailingSlash:c},oe)}function nt({router:e=p.useRouter(),route:t=p.useRoute(),i18n:o=N.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:a=void 0,routesNameSeparator:l=void 0,strategy:s=void 0,trailingSlash:c=void 0}={}){return q({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:a,routesNameSeparator:l,strategy:s,trailingSlash:c},U)}function lt({addDirAttribute:e=!1,addSeoAttributes:t=!1,strategy:o=void 0,defaultLocale:n=void 0,route:a=p.useRoute(),router:l=p.useRouter(),i18n:s=N.useI18n()}={}){const c=l,i=d.ref({htmlAttrs:{},link:[],meta:[]});function u(){i.value={htmlAttrs:{},link:[],meta:[]}}function f(r){i.value=Reflect.apply(ne,{router:l,route:r,i18n:s,defaultLocale:n,strategy:o},[{addDirAttribute:e,addSeoAttributes:t}])}if(Ue)if(d.isVue3){const r=d.watchEffect(()=>{u(),f(se(c.currentRoute))});d.onUnmounted(()=>r())}else{const r=c.afterEach((h,m)=>{u(),f(h)});d.onUnmounted(()=>r()),f(a)}else f(se(c.currentRoute));return i}const at="0.1.2";exports.DEFAULT_BASE_URL=ee;exports.DEFAULT_DETECTION_DIRECTION=Z;exports.DEFAULT_LOCALE=$;exports.DEFAULT_LOCALE_ROUTE_NAME_SUFFIX=M;exports.DEFAULT_ROUTES_NAME_SEPARATOR=G;exports.DEFAULT_STRATEGY=B;exports.DEFAULT_TRAILING_SLASH=j;exports.STRATEGIES=K;exports.VERSION=at;exports.createLocaleFromRouteGetter=Ee;exports.createRouter=He;exports.extendI18n=Le;exports.findBrowserLocale=je;exports.getGlobalOptions=Re;exports.getLocale=k;exports.getLocaleCodes=Ne;exports.getLocales=fe;exports.getLocalesRegex=_e;exports.getRouteBaseName=T;exports.isComposer=P;exports.isExportedGlobalComposer=V;exports.isI18nInstance=O;exports.isLegacyVueI18n=A;exports.isVueI18n=x;exports.localeHead=ne;exports.localeLocation=oe;exports.localePath=H;exports.localeRoute=X;exports.localizeRoutes=pe;exports.proxyVueInstance=I;exports.registerGlobalOptions=ge;exports.resolveBaseUrl=me;exports.resolveRoute=F;exports.setLocale=de;exports.switchLocalePath=U;exports.useLocaleHead=lt;exports.useLocaleLocation=ot;exports.useLocalePath=et;exports.useLocaleRoute=tt;exports.useRouteBaseName=Ze;exports.useSwitchLocalePath=nt; |
{ | ||
"name": "vue-i18n-routing", | ||
"description": "The i18n routing with using vue-i18n", | ||
"version": "0.1.2-e7ba057", | ||
"version": "0.1.2", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build", | ||
"typecheck": "tsc -p . --noEmit", | ||
"test": "vitest run", | ||
"test:watch": "vitest", | ||
"test:cover": "vitest --coverage", | ||
"build:docs": "api-docs-gen ./temp/vue-i18n-routing.api.json -c ./docsgen.config.js -o ./ -g noprefix" | ||
}, | ||
"dependencies": { | ||
@@ -106,12 +115,3 @@ "@intlify/shared": "next", | ||
}, | ||
"sideEffects": false, | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build", | ||
"typecheck": "tsc -p . --noEmit", | ||
"test": "vitest run", | ||
"test:watch": "vitest", | ||
"test:cover": "vitest --coverage", | ||
"build:docs": "api-docs-gen ./temp/vue-i18n-routing.api.json -c ./docsgen.config.js -o ./ -g noprefix" | ||
} | ||
} | ||
"sideEffects": false | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
84602