PageSourceSearch

https://wikiherbalist.com/_nuxt/o_NIC5qI.js

js wikiherbalist.com collected 2026-10-03 00:58:31 UTC 9,663 bytes, 1 lines download raw bytes

1import oe from"./SJKPJgkY.js";import{_ as se}from"./CB85pML-.js";import{a9 as ae,d as u,z as k,u as ne,B as le,x as i,N as n,U as l,$ as d,a1 as T,O as f,_ as ie,a0 as re,a7 as ce,a5 as y,J as V,a3 as H,V as S,Q as D,a2 as P,P as ue,a6 as de,E as me}from"./Ce8km2VT.js";import{g as he}from"./DyjlkccN.js";import{p as ve}from"./DxJI3Wx7.js";import{_ as ge}from"./DlAUqK2U.js";import{u as xe}from"./msvM5ABP.js";const fe={class:"w-full sm:w-4/5 md:w-3/5 mx-auto bg-white rounded-2xl shadow-lg overflow-hidden"},pe={class:"px-2 sm:px-4"},be={key:0,class:"flex justify-center items-center p-4"},ye={key:1,class:"max-h-[60vh] overflow-y-auto scrollbar-hide"},we=["onClick"],_e={class:"relative flex-shrink-0 w-16 h-16 sm:w-20 sm:h-20 mr-2 sm:mr-4"},ke={key:0,class:"absolute inset-0 flex items-center justify-center bg-gray-100 rounded-lg"},Te=["src","alt","onLoad"],Se={class:"flex-grow min-w-0"},Pe=["innerHTML"],Ie=["innerHTML"],Le={key:1,class:"text-xs sm:text-sm text-gray-600 truncate"},Ce={key:2,class:"text-xs text-gray-500 mt-1 truncate"},je={class:"flex-shrink-0 ml-1 sm:ml-2"},Ee=["onMouseenter","data-id"],De={key:2,class:"flex justify-center items-center py-4"},Re=["disabled"],Ae={class:"flex items-center"},Me=["onClick"],$e=["disabled"],Ue={key:3,class:"flex flex-col p-4 sm:p-10 w-auto m-auto"},Ne={class:"text-xs text-gray-600 mt-2"},w=5,Be={__name:"Searchfield",setup(Ve){const O=ae(),I=he(),R=u(null),_=u(!1),m=u(""),c=u([]),p=u(!1),g=u(!1),L=u(!1),A=u(""),C=u({x:0,y:0}),M=u(null),r=u(1);async function W(o){try{const t=await fetch(`https://${I.public.algolia.applicationId}-dsn.algolia.net/1/indexes/wikiherbalist/query`,{method:"POST",headers:{"X-Algolia-API-Key":I.public.algolia.apiKey,"X-Algolia-Application-Id":I.public.algolia.applicationId,"Content-Type":"application/json"},body:JSON.stringify({query:o,hitsPerPage:1e3,attributesToRetrieve:["title","nomeScientifico","authorName","imageUrl","imageAlt","contentType","objectID"],attributesToHighlight:["title","nomeScientifico"]})});if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);const a=(await t.json()).hits.map(e=>({...e,imageLoaded:!1,imageUrl:e.imageUrl||"/media/placeholder.jpg",excerpt:e.excerpt||""}));return a.length>0&&setTimeout(()=>{a.slice(0,5).forEach(h=>{if(h.imageUrl){const v=new Image;v.onload=()=>{const b=c.value.find(te=>te.objectID===h.objectID);b&&(b.imageLoaded=!0)},v.src=h.imageUrl}})},100),a}catch(t){throw console.error("Search failed:",t),t}}const x=k(()=>Math.ceil(c.value.length/w)),z=k(()=>{const o=(r.value-1)*w,t=o+w,s=c.value.slice(o,t);if(r.value<x.value){const a=r.value*w,e=a+w;c.value.slice(a,e).forEach(v=>{if(v.imageUrl&&!v.imageLoaded){const b=new Image;b.onload=()=>{v.imageLoaded=!0},b.src=v.imageUrl}})}return s}),q=k(()=>{const t=[],s=[];let a;for(let e=1;e<=x.value;e++)(e===1||e===x.value||e>=r.value-2&&e<=r.value+2)&&t.push(e);return t.forEach(e=>{a&&(e-a===2?s.push(a+1):e-a!==1&&s.push("...")),s.push(e),a=e}),s});function K(){r.value<x.value&&r.value++}function F(){r.value>1&&r.value--}function G(o){typeof o=="number"&&o!==r.value&&(r.value=o)}function $(){if(!m.value.trim()){E();return}X()}function j(o){o&&!m.value.trim()||(_.value=o)}async function U(){if(!m.value.trim()){E();return}try{g.value=!0;const o=await W(m.value);c.value=o,p.value=!0,j(!0),window.gtag&&window.gtag("event","search",{search_term:m.value})}catch(o){console.error("Search error:",o),c.value=[]}finally{g.value=!1}}const X=xe(U,300);function E(){m.value="",c.value=[],p.value=!1,g.value=!1,r.value=1,j(!1)}function J(o){const t=o.contentType==="plant"?`/${o.objectID}`:o.contentType==="blog"?`/blog/${o.objectID}`:`/glossario/${o.objectID}`;O.push(t)}function Q(o){switch(o){case"plant":return"Erba medicinale";case"blog":return"Blog post";case"glossary":return"Glossario";default:return""}}function Y(o,t){A.value=Q(o),L.value=!0,M.value=t,me(()=>{const s=document.querySelector(`[data-id="${t}"]`);if(s){const a=s.getBoundingClientRect();C.value={x:a.left+window.scrollX+a.width/2,y:a.top+window.scrollY-10}}})}function Z(){L.value=!1,M.value=null}const ee=k(()=>({top:`${C.value.y}px`,left:`${C.value.x}px`,transform:"translate(-50%, -100%)"}));function N(o){if(!o)return"";const t=o.replace(/<em>/g,'<span class="bg-yellow-100 shadow-sm rounded">').replace(/<\/em>/g,"</span>");return ve.sanitize(t,{ALLOWED_TAGS:["span"],ALLOWED_ATTR:["class"]})}function B(o){const t=R.value,s=t?.querySelector('input[type="text"]'),a=t?.querySelector(".bg-gray-50");_.value&&!s?.contains(o.target)&&(!a||!a.contains(o.target))&&j(!1)}return ne(()=>{document.addEventListener("mousedown",B)}),le(()=>{document.removeEventListener("mousedown",B)}),(o,t)=>{const s=oe,a=se;return n(),i("div",{class:"relative w-5/6 mx-auto -my-4",ref_key:"searchContainerRef",ref:R},[l("div",fe,[l("div",{class:T(["flex items-center h-12 md:h-14","border-2 border-celeste rounded-2xl overflow-hidden",{"rounded-b-none border-b-0":_.value&&(c.value.length>0||g.value||p.value&&c.value.length===0)},"focus-within:ring-2 focus-within:ring-celeste focus-within:ring-opacity-50"])},[t[1]||(t[1]=l("label",{for:"wiki-search",class:"sr-only"},"Cerca in Wikiherbalist",-1)),f(s,{name:"heroicons:magnifying-glass-16-solid",class:"ml-2 sm:ml-5 text-celeste text-xl sm:text-2xl flex-shrink-0"}),ie(l("input",{id:"wiki-search",type:"text",placeholder:"Cerca in Wikiherbalist","aria-label":"Cerca in Wikiherbalist",class:"w-full py-2 px-2 sm:px-4 text-sm sm:text-base text-gray-700 leading-tight focus:outline-none","onUpdate:modelValue":t[0]||(t[0]=e=>m.value=e),onInput:$,onFocus:$,onKeydown:ce(U,["enter"])},null,544),[[re,m.value]]),m.value?(n(),i("div",{key:0,onClick:y(E,["stop"]),class:"mr-2 sm:mr-4 hover:cursor-pointer flex-shrink-0"},[f(s,{name:"ic:baseline-close",class:"text-xl sm:text-2xl text-celeste"})])):d("",!0)],2),_.value&&(c.value.length||p.value&&!c.value.length)?(n(),i("div",{key:0,class:T(["bg-gray-50 border-2 border-t-0 border-celeste overflow-hidden w-full",{"rounded-b-2xl":!g.value}])},[l("div",pe,[g.value?(n(),i("div",be,[f(s,{name:"eos-icons:three-dots-loading",class:"text-4xl text-celeste"})])):c.value.length?(n(),i("div",ye,[(n(!0),i(V,null,H(z.value,e=>(n(),i("div",{key:e.objectID,class:"flex items-center py-2 hover:bg-gray-100 hover:cursor-pointer w-full",onClick:y(h=>J(e),["stop"])},[l("div",_e,[e.imageLoaded?d("",!0):(n(),i("div",ke,[...t[2]||(t[2]=[l("div",{class:"animate-spin rounded-full h-8 w-8 border-t-2 border-b-2 border-blu"},null,-1)])])),l("img",{src:e.imageUrl||"/media/placeholder.jpg",alt:e.imageAlt||e.title,class:T(["rounded-lg w-full h-full object-cover",{"opacity-0":!e.imageLoaded,"opacity-100":e.imageLoaded}]),onLoad:h=>e.imageLoaded=!0},null,42,Te)]),l("div",Se,[l("h3",{class:"text-sm sm:text-lg font-bold truncate",innerHTML:N(e._highlightResult?.title?.value||e.title)},null,8,Pe),e.contentType==="plant"?(n(),i("p",{key:0,class:"text-xs sm:text-sm italic truncate",innerHTML:N(e._highlightResult?.nomeScientifico?.value||e.nomeScientifico)},null,8,Ie)):d("",!0),e.contentType==="blog"?(n(),i("p",Le,"Di: "+S(e.authorName),1)):d("",!0),e.excerpt?(n(),i("p",Ce,S(e.excerpt),1)):d("",!0)]),l("div",je,[l("div",{onMouseenter:h=>Y(e.contentType,e.objectID),onMouseleave:Z,class:"cursor-help","data-id":e.objectID},[e.contentType==="plant"?(n(),D(s,{key:0,name:"mdi:flower",class:"text-xl sm:text-2xl text-verde"})):e.contentType==="blog"?(n(),D(s,{key:1,name:"mdi:post",class:"text-xl sm:text-2xl text-blu"})):e.contentType==="glossary"?(n(),D(s,{key:2,name:"mdi:book-open-page-variant",class:"text-xl sm:text-2xl text-celeste"})):d("",!0)],40,Ee)])],8,we))),128))])):d("",!0),x.value>1?(n(),i("div",De,[l("button",{onClick:y(F,["stop"]),disabled:r.value===1,class:"flex items-center justify-center w-8 h-8 sm:w-10 sm:h-10 rounded-full bg-ghiaccio text-blu hover:bg-celeste hover:text-white transition-colors duration-300 disabled:opacity-50 disabled:cursor-not-allowed mr-1 sm:mr-2","aria-label":"Pagina precedente"},[f(s,{name:"mdi:chevron-left",class:"text-xl sm:text-2xl"})],8,Re),l("div",Ae,[(n(!0),i(V,null,H(q.value,e=>(n(),i("button",{key:e,onClick:y(h=>G(e),["stop"]),class:T(["w-8 h-8 sm:w-10 sm:h-10 rounded-full mx-1 text-xs sm:text-sm font-medium transition-colors duration-300",e==="..."?"cursor-default":"",r.value===e?"bg-blu text-white":"bg-ghiaccio text-blu hover:bg-celeste hover:text-white"])},S(e),11,Me))),128))]),l("button",{onClick:y(K,["stop"]),disabled:r.value===x.value,class:"flex items-center justify-center w-8 h-8 sm:w-10 sm:h-10 rounded-full bg-ghiaccio text-blu hover:bg-celeste hover:text-white transition-colors duration-300 disabled:opacity-50 disabled:cursor-not-allowed ml-1 sm:ml-2","aria-label":"Pagina successiva"},[f(s,{name:"mdi:chevron-right",class:"text-xl sm:text-2xl"})],8,$e)])):d("",!0),p.value&&!c.value.length?(n(),i("div",Ue,[t[6]||(t[6]=l("p",{class:"text-red-500 border border-red-500 rounded-lg p-2 text-xs sm:text-sm"}," Nessun risultato trovato. Prova con parole chiave diverse. ",-1)),l("p",Ne,[t[4]||(t[4]=P(" Non trovi la voce che cerchi? ",-1)),f(a,{to:"/#section-contacts",class:"text-blu hover:text-celeste"},{default:ue(()=>
1[...t[3]||(t[3]=[P(" Segnalacelo! ",-1)])]),_:1}),t[5]||(t[5]=P(" La inseriremo al più presto ",-1))])])):d("",!0)])],2)):d("",!0)]),L.value?(n(),i("div",{key:0,class:"fixed z-50 px-2 sm:px-3 py-1 sm:py-2 text-xs sm:text-sm font-medium text-white bg-gray-900 rounded-lg shadow-sm",style:de(ee.value)},[P(S(A.value)+" ",1),t[7]||(t[7]=l("div",{class:"absolute w-2 h-2 bg-gray-900 rotate-45 -bottom-1 left-1/2 transform -translate-x-1/2"},null,-1))],4)):d("",!0)],512)}}},Ge=ge(Be,[["__scopeId","data-v-e5b7d46d"]]);export{Ge as S};

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.