UNPKG

nuxt-i18n-micro

Version:

Nuxt I18n Micro is a lightweight, high-performance internationalization module for Nuxt, designed to handle multi-language support with minimal overhead, fast build times, and efficient runtime performance.

2 lines (1 loc) 9.31 kB
import{u as P,d as B,s as O,r as E,a as L,o as T,b as H,c as I,e as U,f as M,h as R,g as N,p as V,i as q,j as b,k as A,l as D,n as F,m as $,w as W,q as G,t as K,v as Q,x as J,y as C,z as _,A as X,B as Y,C as Z}from"./IdTwQBaS.js";import{_ as ee,u as te}from"./BSr9DeKx.js";async function j(t,n=P()){const{path:u,matched:p}=n.resolve(t);if(!p.length||(n._routePreloaded||=new Set,n._routePreloaded.has(u)))return;const d=n._preloadPromises||=[];if(d.length>4)return Promise.all(d).then(()=>j(t,n));n._routePreloaded.add(u);for(const e of p){const o=e.components?.default;if(typeof o!="function")continue;const c=Promise.resolve(o()).catch(()=>{}).finally(()=>d.splice(d.indexOf(c)));d.push(c)}await Promise.all(d)}const ne=(...t)=>t.find(n=>n!==void 0);function re(t){const n=t.componentName||"NuxtLink";function u(e){return typeof e=="string"&&e.startsWith("#")}function p(e,o,c){const a=c??t.trailingSlash;if(!e||a!=="append"&&a!=="remove")return e;if(typeof e=="string")return S(e,a);const s="path"in e&&e.path!==void 0?e.path:o(e).path;return{...e,name:void 0,path:S(s,a)}}function d(e){const o=P(),c=$(),a=b(()=>!!e.target&&e.target!=="_self"),s=b(()=>{const l=e.to||e.href||"";return typeof l=="string"&&A(l,{acceptRelative:!0})}),y=N("RouterLink"),g=y&&typeof y!="string"?y.useLink:void 0,h=b(()=>{if(e.external)return!0;const l=e.to||e.href||"";return typeof l=="object"?!1:l===""||s.value}),i=b(()=>{const l=e.to||e.href||"";return h.value?l:p(l,o.resolve,e.trailingSlash)}),m=h.value?void 0:g?.({...e,to:i}),x=b(()=>{const l=e.trailingSlash??t.trailingSlash;if(!i.value||s.value||u(i.value))return i.value;if(h.value){const k=typeof i.value=="object"&&"path"in i.value?q(i.value):i.value,w=typeof k=="object"?o.resolve(k).href:k;return S(w,l)}return typeof i.value=="object"?o.resolve(i.value)?.href??null:S(D(c.app.baseURL,i.value),l)});return{to:i,hasTarget:a,isAbsoluteUrl:s,isExternal:h,href:x,isActive:m?.isActive??b(()=>i.value===o.currentRoute.value.path),isExactActive:m?.isExactActive??b(()=>i.value===o.currentRoute.value.path),route:m?.route??b(()=>o.resolve(i.value)),async navigate(l){await F(x.value,{replace:e.replace,external:h.value||a.value})}}}return B({name:n,props:{to:{type:[String,Object],default:void 0,required:!1},href:{type:[String,Object],default:void 0,required:!1},target:{type:String,default:void 0,required:!1},rel:{type:String,default:void 0,required:!1},noRel:{type:Boolean,default:void 0,required:!1},prefetch:{type:Boolean,default:void 0,required:!1},prefetchOn:{type:[String,Object],default:void 0,required:!1},noPrefetch:{type:Boolean,default:void 0,required:!1},activeClass:{type:String,default:void 0,required:!1},exactActiveClass:{type:String,default:void 0,required:!1},prefetchedClass:{type:String,default:void 0,required:!1},replace:{type:Boolean,default:void 0,required:!1},ariaCurrentValue:{type:String,default:void 0,required:!1},external:{type:Boolean,default:void 0,required:!1},custom:{type:Boolean,default:void 0,required:!1},trailingSlash:{type:String,default:void 0,required:!1}},useLink:d,setup(e,{slots:o}){const c=P(),{to:a,href:s,navigate:y,isExternal:g,hasTarget:h,isAbsoluteUrl:i}=d(e),m=O(!1),x=E(null),l=f=>{x.value=e.custom?f?.$el?.nextElementSibling:f?.$el};function k(f){return!m.value&&(typeof e.prefetchOn=="string"?e.prefetchOn===f:e.prefetchOn?.[f]??t.prefetchOn?.[f])&&(e.prefetch??t.prefetch)!==!1&&e.noPrefetch!==!0&&e.target!=="_blank"&&!se()}async function w(f=L()){if(m.value)return;m.value=!0;const v=typeof a.value=="string"?a.value:g.value?q(a.value):c.resolve(a.value).fullPath,r=g.value?new URL(v,window.location.href).href:v;await Promise.all([f.hooks.callHook("link:prefetch",r).catch(()=>{}),!g.value&&!h.value&&j(a.value,c).catch(()=>{})])}if(k("visibility")){const f=L();let v,r=null;T(()=>{const z=oe();H(()=>{v=I(()=>{x?.value?.tagName&&(r=z.observe(x.value,async()=>{r?.(),r=null,await w(f)}))})})}),U(()=>{v&&M(v),r?.(),r=null})}return()=>{if(!g.value&&!h.value&&!u(a.value)){const r={ref:l,to:a.value,activeClass:e.activeClass||t.activeClass,exactActiveClass:e.exactActiveClass||t.exactActiveClass,replace:e.replace,ariaCurrentValue:e.ariaCurrentValue,custom:e.custom};return e.custom||(k("interaction")&&(r.onPointerenter=w.bind(null,void 0),r.onFocus=w.bind(null,void 0)),m.value&&(r.class=e.prefetchedClass||t.prefetchedClass),r.rel=e.rel||void 0),R(N("RouterLink"),r,o.default)}const f=e.target||null,v=ne(e.noRel?"":e.rel,t.externalRelAttribute,i.value||h.value?"noopener noreferrer":"")||null;return e.custom?o.default?o.default({href:s.value,navigate:y,prefetch:w,get route(){if(!s.value)return;const r=new URL(s.value,window.location.href);return{path:r.pathname,fullPath:r.pathname,get query(){return V(r.search)},hash:r.hash,params:{},name:void 0,matched:[],redirectedFrom:void 0,meta:{},href:s.value}},rel:v,target:f,isExternal:g.value||h.value,isActive:!1,isExactActive:!1}):null:R("a",{ref:x,href:s.value||null,rel:v,target:f,onClick:r=>{if(!(g.value||h.value))return r.preventDefault(),e.replace?c.replace(s.value):c.push(s.value)}},o.default?.())}}})}const ae=re(K);function S(t,n){const u=n==="append"?W:G;return A(t)&&!t.startsWith("http")?t:u(t,!0)}function oe(){const t=L();if(t._observer)return t._observer;let n=null;const u=new Map,p=(e,o)=>(n||=new IntersectionObserver(c=>{for(const a of c){const s=u.get(a.target);(a.isIntersecting||a.intersectionRatio>0)&&s&&s()}}),u.set(e,o),n.observe(e),()=>{u.delete(e),n?.unobserve(e),u.size===0&&(n?.disconnect(),n=null)});return t._observer={observe:p}}const ie=/2g/;function se(){const t=navigator.connection;return!!(t&&(t.saveData||ie.test(t.effectiveType)))}const le={class:"antialiased bg-white dark:bg-[#020420] dark:text-white font-sans grid min-h-screen overflow-hidden place-content-center text-[#020420] tracking-wide"},ue={class:"max-w-520px text-center"},ce=["textContent"],fe=["textContent"],de=["textContent"],he={class:"flex items-center justify-center w-full"},ve={__name:"error-404",props:{appName:{type:String,default:"Nuxt"},statusCode:{type:Number,default:404},statusMessage:{type:String,default:"Page not found"},description:{type:String,default:"Sorry, the page you are looking for could not be found."},backHome:{type:String,default:"Go back home"}},setup(t){const n=t;return te({title:`${n.statusCode} - ${n.statusMessage} | ${n.appName}`,script:[{innerHTML:`!function(){const e=document.createElement("link").relList;if(!(e&&e.supports&&e.supports("modulepreload"))){for(const e of document.querySelectorAll('link[rel="modulepreload"]'))r(e);new MutationObserver(e=>{for(const o of e)if("childList"===o.type)for(const e of o.addedNodes)"LINK"===e.tagName&&"modulepreload"===e.rel&&r(e)}).observe(document,{childList:!0,subtree:!0})}function r(e){if(e.ep)return;e.ep=!0;const r=function(e){const r={};return e.integrity&&(r.integrity=e.integrity),e.referrerPolicy&&(r.referrerPolicy=e.referrerPolicy),"use-credentials"===e.crossOrigin?r.credentials="include":"anonymous"===e.crossOrigin?r.credentials="omit":r.credentials="same-origin",r}(e);fetch(e.href,r)}}();`}],style:[{innerHTML:'*,:after,:before{border-color:var(--un-default-border-color,#e5e7eb);border-style:solid;border-width:0;box-sizing:border-box}:after,:before{--un-content:""}html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}h1,h2{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}h1,h2,p{margin:0}*,:after,:before{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 transparent;--un-ring-shadow:0 0 transparent;--un-shadow-inset: ;--un-shadow:0 0 transparent;--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgba(147,197,253,.5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }'}]}),(u,p)=>{const d=ae;return Q(),J("div",le,[C("div",ue,[C("h1",{class:"font-semibold leading-none mb-4 sm:text-[110px] tabular-nums text-[80px]",textContent:_(t.statusCode)},null,8,ce),C("h2",{class:"font-semibold mb-2 sm:text-3xl text-2xl",textContent:_(t.statusMessage)},null,8,fe),C("p",{class:"mb-4 px-2 text-[#64748B] text-md",textContent:_(t.description)},null,8,de),C("div",he,[X(d,{to:"/",class:"font-medium hover:text-[#00DC82] text-sm underline underline-offset-3"},{default:Y(()=>[Z(_(t.backHome),1)]),_:1})])])])}}},me=ee(ve,[["__scopeId","data-v-c2ebd913"]]);export{me as default};