PageSourceSearch

https://cinewish-web.onrender.com/assets/Search-BMUXLOwV.js

js cinewish-web.onrender.com collected 2026-10-03 11:39:44 UTC 8,466 bytes, 1 lines download raw bytes

1import{d as B,r,a as K,u as Q,A as E,j as t}from"./index-BYNP3g4A.js";import{H as U}from"./Header-BntKbDwF.js";import{T as W}from"./index-DNKZUyKZ.js";import{C as G}from"./CardSkeleton-D8W6wBtj.js";const ee=()=>{const[p,D]=B(),[f,x]=r.useState(!1),I=K(),{searchResult:i,setSearchResult:v}=Q(),w=r.useRef(null),[d,b]=r.useState([]),[M,k]=r.useState(!1),[A,c]=r.useState(!1),[q,z]=r.useState(!1),[u,R]=r.useState(1),[j,N]=r.useState(!1),[h,g]=r.useState(-1),S=r.useRef(null),L=r.useRef(null),y=r.useRef([]),$=r.useRef(null),o=p.get("q")||"",m=p.get("t")||"";r.useEffect(()=>{var e;o||(v([]),(e=w.current)==null||e.focus())},[]),r.useEffect(()=>{o.trim()&&_()},[m]),r.useEffect(()=>{if(o.trim().length<2){b([]),c(!1);return}g(-1),y.current=[];const e=setTimeout(()=>{q&&P(o)},600);return()=>clearTimeout(e)},[o]),r.useEffect(()=>{const e=s=>{S.current&&!S.current.contains(s.target)&&c(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),r.useEffect(()=>{if(h<0||!L.current)return;const e=y.current[h];e&&e.scrollIntoView({behavior:"auto",block:"nearest"})},[h]),r.useEffect(()=>{u>1&&F()},[u]),r.useEffect(()=>{document.title=`CineWish – Search ${o}`},[o]),r.useEffect(()=>{if(!j)return;const e=new IntersectionObserver(a=>{a[0].isIntersecting&&!f&&R(l=>l+1)}),s=$.current;return s&&e.observe(s),()=>s&&e.unobserve(s)},[j,f]);const P=async e=>{k(!0);try{const{data:s}=await E.get("/tmdb/search",{params:{query:e,type:"multi"}}),l=(Array.isArray(s.data)?s.data:[]).filter(n=>n.media_type==="tv"||n.media_type==="movie").slice(0,7);b(l),c(l.length>0)}catch(s){console.error("Suggestion error:",s),b([]),c(!1)}finally{k(!1)}},_=async e=>{var l;e&&e.preventDefault(),c(!1),(l=w.current)==null||l.blur(),g(-1);const s=p.get("q")||"",a=p.get("t")||"multi";if(s.trim()){x(!0),R(1),v([]),N(!1);try{const{data:n}=await E.get("/tmdb/search",{params:{query:s,type:a,page:1}}),V=Array.isArray(n.data)?n.data:[];v(V),N((n.total_pages||0)>1)}catch(n){console.error(n)}finally{x(!1)}}},F=async()=>{x(!0);try{const{data:e}=await E.get("/tmdb/search",{params:{query:o,type:m||"multi",page:u}}),s=Array.isArray(e.data)?e.data:[];v([...i,...s]),N((e.total_pages||0)>u)}catch(e){console.error(e)}finally{x(!1)}},C=(e,s)=>
1{!e||!s||(I(`/details/${e}/${s}`),c(!1),g(-1))},T=(e,s)=>{const a=Object.fromEntries(p.entries());D({...a,[s]:e.target.value},{replace:!0}),z(!0)},H=()=>{o.trim().length>1&&d.length>0&&c(!0)},O=e=>{if(!(!A||d.length===0))switch(e.key){case"ArrowDown":e.preventDefault(),g(s=>s===d.length-1?0:s+1);break;case"ArrowUp":e.preventDefault(),g(s=>s<=0?d.length-1:s-1);break;case"Enter":if(h>-1){e.preventDefault();const s=d[h];C(s.media_type,s.id)}break;case"Escape":c(!1),g(-1);break}};return t.jsxs("div",{className:"min-h-screen text-white pb-20 md:pb-0",children:[t.jsx(U,{}),t.jsxs("div",{ref:S,className:"relative max-w-xl mx-1 sm:mx-auto my-6 flex gap-1 sm:gap-2 items-center",children:[t.jsxs("form",{onSubmit:_,className:"relative flex items-center flex-1",children:[t.jsx("input",{type:"text",ref:w,value:o,onChange:e=>T(e,"q"),onFocus:H,onKeyDown:O,placeholder:m==="movie"?"Search for movies...":m==="tv"?"Search for series...":"Search for movies or series...",className:"flex-1 px-4 pr-12 py-2 rounded-lg bg-gray-800 text-white focus:outline-none focus:ring-2 focus:ring-teal-500",autoComplete:"off"}),t.jsx("span",{onClick:_,className:"material-symbols-outlined absolute top-1/2 right-4 transform -translate-y-1/2 cursor-pointer text-gray-400 hover:text-white",children:t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24",fill:"currentColor",children:t.jsx("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"})})}),A&&t.jsx("div",{ref:L,className:"absolute top-full left-0 right-0 mt-2 bg-gray-800 border border-gray-700 rounded-lg shadow-lg z-20 max-h-96 overflow-y-auto",children:M?t.jsx("p",{className:"text-gray-400 text-sm p-3 text-center",children:"Loading..."}):t.jsxs("ul",{className:"divide-y divide-gray-700",children:[(y.current=[])&&null,d.length>0?d.map((e,s)=>t.jsxs("li",{ref:a=>y.current[s]=a,onClick:()=>C(e.media_type,e.id),onMouseEnter:()=>g(s),className:`flex items-center p-2 cursor-pointer transition-colors ${h===s?"bg-gray-700":"hover:bg-gray-700"}`,children:[t.jsx("img",{src:e.poster_path?`https://image.tmdb.org/t/p/w92${e.poster_path}`:"/placeholder.png",alt:e.title||e.name,className:"w-10 h-14 object-cover rounded flex-shrink-0"}),t.jsxs("div",{className:"ml-3 overflow-hidden",children:[t.jsx("h4",{className:"text-sm font-semibold truncate",children:e.title||e.name}),t.jsxs("p",{className:"text-xs text-gray-400 capitalize",children:[e.media_type==="movie"?"Movie":"TV Show",(e.release_date||e.first_air_date)&&` (${(e.release_date||e.first_air_date).slice(0,4)})`]})]})]},e.id)):t.jsx("p",{className:"text-gray-500 text-sm p-3 text-center",children:"No suggestions found"})]})})]}),t.jsx("div",{className:"sm:px-2 bg-gray-800 rounded-lg overflow-hidden focus-within:ring-2 focus-within:ring-teal-500",children:t.jsxs("select",{name:"type",value:m,onChange:e=>T(e,"t"),className:"bg-gray-800 text-white py-[10px] text-sm border-none outline-none",children:[t.jsx("option",{value:"",children:"All"}),t.jsx("option",{value:"movie",children:"Movies"}),t.jsx("option",{value:"tv",children:"TV"})]})})]}),f&&u===1&&t.jsx("p",{className:"text-center text-gray-400",children:"Loading..."}),!f&&u===1&&(i==null?void 0:i.length)===0&&t.jsxs("div",{className:"relative w-full flex flex-col items-center justify-center gap-4",children:[t.jsx(W,{src:"/lottie/no_result.lottie",loop:!0,autoplay:!0,style:{width:"clamp(100px, 40vw, 200px)",height:"clamp(100px, 40vw, 200px)",borderRadius:"50%",overflow:"hidden",marginTop:"100px"}}),t.jsx("p",{className:"text-center text-gray-600",children:"No results"})]}),t.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-7 2xl:gr
1id-cols-8 gap-2 sm:gap-3 md:gap-4 px-2 sm:px-4 md:mx-5 pb-4",children:[i==null?void 0:i.map((e,s)=>{var a,l;return t.jsxs("div",{onClick:()=>C(e.media_type||m,e.id),className:"group relative bg-gray-900 border border-gray-800 rounded-lg overflow-hidden shadow transition sm:hover:shadow-teal-500/10 cursor-pointer",children:[t.jsx("div",{className:"relative w-full aspect-[4/5] sm:aspect-[3/4] bg-gray-800 overflow-hidden",children:t.jsx("img",{src:e.poster_path?`https://image.tmdb.org/t/p/w500${e.poster_path}`:"/placeholder.png",alt:e.title||e.name,loading:"lazy",onError:n=>{n.currentTarget.src="/placeholder.png"},className:"w-full h-full object-cover object-top group-hover:scale-105 transition-transform duration-300"})}),!!(e.vote_average&&parseFloat(e.vote_average)>0)&&t.jsx("div",{className:"absolute top-1 left-1",children:t.jsxs("div",{className:"flex items-center gap-0.5 bg-black/60 md:backdrop-blur-sm px-1.5 py-0.5 rounded-full",children:[t.jsx("svg",{className:"w-2.5 h-2.5 sm:w-3 sm:h-3 text-yellow-400",fill:"currentColor",viewBox:"0 0 20 20",children:t.jsx("path",{d:"M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"})}),t.jsx("span",{className:"text-white text-[10px] sm:text-xs font-semibold",children:e.vote_average.toFixed(1)})]})}),t.jsx("span",{className:"absolute top-1 right-1 bg-teal-600 text-white text-[8px] sm:text-[10px] font-semibold px-1.5 py-0.5 rounded-full uppercase shadow-md",children:e.media_type||m}),t.jsxs("div",{className:"p-2 sm:p-3",children:[t.jsx("h3",{className:"text-xs sm:text-sm font-semibold truncate",children:e.title||e.name}),t.jsx("p",{className:"text-[10px] sm:text-xs text-gray-400",children:((a=e.release_date)==null?void 0:a.slice(0,4))||((l=e.first_air_date)==null?void 0:l.slice(0,4))||"N/A"})]})]},`${e.id}-${s}`)}),f&&Array.from({length:12}).map((e,s)=>t.jsx(G,{},`skeleton-${s}`))]}),t.jsx("div",{ref:$,className:"h-20 flex justify-center items-center",children:f&&u>1&&j&&t.jsx("p",{className:"text-gray-400",children:"Loading more..."})})]})};export{ee as default};

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.