contextmax
Version:
Privacy-first, browser-based tool for creating precise context sets for LLMs
2 lines (1 loc) • 5.32 kB
JavaScript
import{c as j,h as O,j as T,m as N,e as B}from"./CTO2oVUC.js";import{Q as E,c0 as _,b9 as U,aW as H,bZ as A,aH as I,c1 as D,c2 as F,aD as V,c3 as W,aa as L,a$ as P,c4 as k,c5 as z,y as p,c6 as M,c7 as $,c8 as Q}from"./Dhxe2AST.js";const G=(...t)=>t.find(u=>u!==void 0);function Z(t){const u=t.componentName||"NuxtLink";function h(e){return typeof e=="string"&&e.startsWith("#")}function R(e,n,m){const a=m??t.trailingSlash;if(!e||a!=="append"&&a!=="remove")return e;if(typeof e=="string")return C(e,a);const s="path"in e&&e.path!==void 0?e.path:n(e).path;return{...e,name:void 0,path:C(s,a)}}function q(e){const n=_(),m=M(),a=p(()=>!!e.target&&e.target!=="_self"),s=p(()=>{const f=e.to||e.href||"";return typeof f=="string"&&O(f,{acceptRelative:!0})}),x=P("RouterLink"),g=x&&typeof x!="string"?x.useLink:void 0,d=p(()=>{if(e.external)return!0;const f=e.to||e.href||"";return typeof f=="object"?!1:f===""||s.value}),l=p(()=>{const f=e.to||e.href||"";return d.value?f:R(f,n.resolve,e.trailingSlash)}),c=d.value||g==null?void 0:g({...e,to:l}),y=p(()=>{var S;const f=e.trailingSlash??t.trailingSlash;if(!l.value||s.value||h(l.value))return l.value;if(d.value){const b=typeof l.value=="object"&&"path"in l.value?k(l.value):l.value,r=typeof b=="object"?n.resolve(b).href:b;return C(r,f)}return typeof l.value=="object"?((S=n.resolve(l.value))==null?void 0:S.href)??null:C(T(m.app.baseURL,l.value),f)});return{to:l,hasTarget:a,isAbsoluteUrl:s,isExternal:d,href:y,isActive:(c==null?void 0:c.isActive)??p(()=>l.value===n.currentRoute.value.path),isExactActive:(c==null?void 0:c.isExactActive)??p(()=>l.value===n.currentRoute.value.path),route:(c==null?void 0:c.route)??p(()=>n.resolve(l.value)),async navigate(f){await $(y.value,{replace:e.replace,external:d.value||a.value})}}}return E({name:u,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:q,setup(e,{slots:n}){const m=_(),{to:a,href:s,navigate:x,isExternal:g,hasTarget:d,isAbsoluteUrl:l}=q(e),c=U(!1),y=H(null),f=r=>{var o;y.value=e.custom?(o=r==null?void 0:r.$el)==null?void 0:o.nextElementSibling:r==null?void 0:r.$el};function S(r){var o,i;return!c.value&&(typeof e.prefetchOn=="string"?e.prefetchOn===r:((o=e.prefetchOn)==null?void 0:o[r])??((i=t.prefetchOn)==null?void 0:i[r]))&&(e.prefetch??t.prefetch)!==!1&&e.noPrefetch!==!0&&e.target!=="_blank"&&!X()}async function b(r=A()){if(c.value)return;c.value=!0;const o=typeof a.value=="string"?a.value:g.value?k(a.value):m.resolve(a.value).fullPath,i=g.value?new URL(o,window.location.href).href:o;await Promise.all([r.hooks.callHook("link:prefetch",i).catch(()=>{}),!g.value&&!d.value&&z(a.value,m).catch(()=>{})])}if(S("visibility")){const r=A();let o,i=null;I(()=>{const v=J();D(()=>{o=F(()=>{var w;(w=y==null?void 0:y.value)!=null&&w.tagName&&(i=v.observe(y.value,async()=>{i==null||i(),i=null,await b(r)}))})})}),V(()=>{o&&W(o),i==null||i(),i=null})}return()=>{var i;if(!g.value&&!d.value&&!h(a.value)){const v={ref:f,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||(S("interaction")&&(v.onPointerenter=b.bind(null,void 0),v.onFocus=b.bind(null,void 0)),c.value&&(v.class=e.prefetchedClass||t.prefetchedClass),v.rel=e.rel||void 0),L(P("RouterLink"),v,n.default)}const r=e.target||null,o=G(e.noRel?"":e.rel,t.externalRelAttribute,l.value||d.value?"noopener noreferrer":"")||null;return e.custom?n.default?n.default({href:s.value,navigate:x,prefetch:b,get route(){if(!s.value)return;const v=new URL(s.value,window.location.href);return{path:v.pathname,fullPath:v.pathname,get query(){return j(v.search)},hash:v.hash,params:{},name:void 0,matched:[],redirectedFrom:void 0,meta:{},href:s.value}},rel:o,target:r,isExternal:g.value||d.value,isActive:!1,isExactActive:!1}):null:L("a",{ref:y,href:s.value||null,rel:o,target:r},(i=n.default)==null?void 0:i.call(n))}}})}const te=Z(Q);function C(t,u){const h=u==="append"?N:B;return O(t)&&!t.startsWith("http")?t:h(t,!0)}function J(){const t=A();if(t._observer)return t._observer;let u=null;const h=new Map,R=(e,n)=>(u||(u=new IntersectionObserver(m=>{for(const a of m){const s=h.get(a.target);(a.isIntersecting||a.intersectionRatio>0)&&s&&s()}})),h.set(e,n),u.observe(e),()=>{h.delete(e),u==null||u.unobserve(e),h.size===0&&(u==null||u.disconnect(),u=null)});return t._observer={observe:R}}const K=/2g/;function X(){const t=navigator.connection;return!!(t&&(t.saveData||K.test(t.effectiveType)))}export{te as _};