1import d from"./CritterCard.KJb9FQL6.js";import{a5 as f,C as i,L as o,Q as c,O as m,F as l,P as g,V as p,a0 as y,D as w,R as _,J as b,a3 as C}from"./runtime-dom.esm-bundler.CqpSJMCm.js";import{_ as S}from"./_plugin-vue_export-helper.DlAUqK2U.js";const k={name:"CrittersResults",components:{CritterCard:d},props:{elementsPerPage:{type:Number,default:100},filters:{type:Object},loadMoreText:{type:String,default:"Load More"},com:{type:Number}},data(){return{entries:[],error:null,isDataAvailable:!1,nextQuery:null,showLoadMore:!1,showSpinner:!1,refreshing:!1,totalResults:null}},controller:!1,mounted:async function(){await this.getEntries(null,!1,!0).catch(n=>console.log(n))},watch:{filters:{async handler(n){this.controller&&this.controller.abort(),this.refreshing=!0,await this.getEntries().catch(s=>console.log(s))},deep:!0}},methods:{async fetchEntries(n,s){this.controller=new AbortController;const a=this.controller.signal,r=n??`/api/critters/entries.json?pg=1&elementsPerPage=${this.elementsPerPage}&random=${s}&filters=${encodeURIComponent(JSON.stringify(this.filters))}`,e=await fetch(r,{method:"GET",headers:{Accept:"application/json"},dataType:"json",credentials:"same-origin",signal:a});return e.ok||(this.error="Sorry, something went wrong. Please refresh the page and try again, or contact us."),e.json()},async getEntries(n=null,s=!1,a=!1){s&&(this.showSpinner=!0),this.showLoadMore=!1,await this.fetchEntries(n,a).then(async r=>{if(Array.isArray(r.data)){if(this.controller=!1,s){this.entries=this.entries.concat(r.data),this.showSpinner=!1;const u=document.getElementsByTagName("html")[0];u.classList.add("u-smoothScroll");const t=r.data[0].id;await this.$nextTick(()=>{window.location.hash="#entry-"+t,setTimeout(function(){u.classList.remove("u-smoothScroll")},500)})}else this.entries=r.data,this.refreshing=!1;this.isDataAvailable=!0;const e=r.meta.pagination;this.$emit("update-results-count",e.total),this.$emit("update-results-shown",this.entries.length),this.totalResults=e.total;const h=e.current_page===0?1:e.current_page;this.nextQuery=e.links.next,this.showLoadMore=h<e.total_pages}else console.log(r.error),this.refreshing=!1,this.showSpinner=!1}).catch(r=>{console.log(r)})},loadMore(){this.showSpinner=!0,this.showLoadMore=!1,this.getEntries(this.nextQuery,!0)}}},v={key:0,class:""},x={key:1,class:"Test"},M={class:"loader centerInGrid",key:"initialLoader"},E={class:"loader centerInGrid",key:"loadingMore"};function L(n,s,a,r,e,h){const u=f("CritterCard");return o(),i("section",null,[e.isDataAvailable&&e.entries.length===0?(o(),i("div",v,s[1]||(s[1]=[l("span",{class:""},"Sorry, no results found.",-1),l("p",null,"Search tips:",-1),l("ul",null,[l("li",null,"Double check your spelling"),l("li",null,"Search again using different words"),l("li",null,"Remove your filters")],-1)]))):c("",!0),e.error?(o(),i("div",x," Sorry, an error has occurred. Please try a different search or refresh the page. ")):c("",!0),m(C,{name:"fade",tag:"div",class:b(["boxEntries",{"boxEntries--disabled":e.refreshing}])},{default:g(()=>[e.isDataAvailable?c("",!0):(o(),i("div",M)),(o(!0),i(p,null,y(e.entries,t=>(o(),w(u,{key:t.id,id:t.id,url:t.u,title:t.t,"scientific-name":t.s,description:t.d,"category-name":t.ct,"category-class":t.cc,"image-attrs":t.i,com:a.com===t.id},null,8,["id","url","title","scientific-name","description","category-name","category-class","image-attrs","com"]))),128)),e.showSpinner?(o(),i("div",E)):c("",!0),e.showLoadMore?(o(),i("button",{key:2,class:"button button--primary button--center centerInGrid loadMoreButton",id:"blogExtra__loadMoreButton",onClick:s[0]||(s[0]=(...t)=>h.loadMore&&h.loadMore(...t))},_(a.loadMoreText),1)):c("",!0)]),_:1},8,["class"])])}const B=S(k,[["render",L],["__scopeId","data-v-669f14a5"]]);export{B as default}; 2//# sourceMappingURL=CrittersResults.CtlWsg4q.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.