import{d as g,bD as q,m as _,be as C,A as S,bi as k,bE as A,bF as D}from"./CYpMmShR.js";import{u as I,q as m}from"./DeHl_KWs.js";import"./BzhxmwLN.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},t=new r.Error().stack;t&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[t]="451030c6-3074-41c4-aeff-0ed3c1be3f7d",r._sentryDebugIdIdentifier="sentry-dbid-451030c6-3074-41c4-aeff-0ed3c1be3f7d")}catch{}})();const N=g({name:"ContentQuery",props:{path:{type:String,required:!1,default:void 0},only:{type:Array,required:!1,default:void 0},without:{type:Array,required:!1,default:void 0},where:{type:Object,required:!1,default:void 0},sort:{type:Object,required:!1,default:void 0},limit:{type:Number,required:!1,default:void 0},skip:{type:Number,required:!1,default:void 0},locale:{type:String,required:!1,default:void 0},find:{type:String,required:!1,default:void 0}},async setup(r){const{path:t,only:n,without:o,where:a,sort:d,limit:f,skip:l,locale:s,find:y}=q(r),p=_(()=>{var e;return(e=t.value)==null?void 0:e.includes("/_")}),c=!C().public.content.experimental.advanceQuery;S(()=>r,()=>i(),{deep:!0});const u=e=>c?e!=null&&e.surround?e.surround:e!=null&&e._id||Array.isArray(e)?e:e==null?void 0:e.result:e.result,{data:h,refresh:i}=await I(`content-query-${k(r)}`,()=>{let e;return t.value?e=m(t.value):e=m(),n.value&&(e=e.only(n.value)),o.value&&(e=e.without(o.value)),a.value&&(e=e.where(a.value)),d.value&&(e=e.sort(d.value)),f.value&&(e=e.limit(f.value)),l.value&&(e=e.skip(l.value)),s.value&&(e=e.where({_locale:s.value})),y.value==="one"?e.findOne().then(u):y.value==="surround"?t.value?c?e.findSurround(t.value):e.withSurround(t.value).findOne().then(u):(console.warn("[Content] Surround queries requires `path` prop to be set."),console.warn("[Content] Query without `path` will return regular `find()` results."),e.find().then(u)):e.find().then(u)});return{isPartial:p,data:h,refresh:i}},render(r){var v;const t=A(),{data:n,refresh:o,isPartial:a,path:d,only:f,without:l,where:s,sort:y,limit:p,skip:c,locale:u,find:h}=r,i={path:d,only:f,without:l,where:s,sort:y,limit:p,skip:c,locale:u,find:h};if(i.find==="one"){if(!n&&(t!=null&&t["not-found"]))return t["not-found"]({props:i,...this.$attrs});if(t!=null&&t.empty&&(n==null?void 0:n._type)==="markdown"&&!((v=n==null?void 0:n.body)!=null&&v.children.length))return t.empty({props:i,...this.$attrs})}else if((!n||!n.length)&&t!=null&&t["not-found"])return t["not-found"]({props:i,...this.$attrs});return t!=null&&t.default?t.default({data:n,refresh:o,isPartial:a,props:i,...this.$attrs}):((w,b)=>D("pre",null,JSON.stringify({message:"You should use slots with <ContentQuery>!",slot:w,data:b},null,2)))("default",{data:n,props:i,isPartial:a})}}),R=N;export{R as default};
//# sourceMappingURL=CaI9zilD.js.map
