PageSourceSearch

https://episodehive.com/_next/static/chunks/6389.0ece37470ea5ece8.js

js episodehive.com collected 2026-10-02 14:55:02 UTC 16,166 bytes, 11 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6389,5042],{13718:function(e,t,a){a.d(t,{Z:function(){return o}});var n=a(91373);/**
2 * @license lucide-react v0.436.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */let o=(0,n.Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},56389:function(e,t,a){a.r(t),a.d(t,{default:function(){return N}});var n=a(20567),o=a(14932),i=a(85893),l=a(67294),s=a(74598),d=a(36316),c=a(9560),u=a(91373);/**
7 * @license lucide-react v0.436.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */let p=(0,u.Z)("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);var g=a(13718),m=a(45697),y=a.n(m),f=a(5068),h=a(37781),E=a(90512),R=a(73935),x=a(12400);let b="pendingRating",getPendingActionKey=(e,t,a,n)=>n?"".concat("USER_EPISODE_ACTION_").concat(n,"_").concat(e,"_S").concat(t,"_E").concat(a):null,savePendingAction=(e,t)=>{if(e)try{localStorage.setItem(e,JSON.stringify((0,o._)((0,n._)({},t),{timestamp:Date.now()})))}catch(e){console.error("Error saving pending action to localStorage:",e)}},getPendingAction=e=>{if(!e)return null;try{let t=localStorage.getItem(e);if(!t)return null;let a=JSON.parse(t);if(Date.now()-a.timestamp>864e5)return localStorage.removeItem(e),null;return a}catch(t){return console.error("Error reading pending action from localStorage:",t),localStorage.removeItem(e),null}},clearPendingAction=e=>{if(e)try{localStorage.removeItem(e)}catch(e){console.error("Error clearing pending action from localStorage:",e)}},fetcher=async e=>{let t=await fetch(e);if(!t.ok){if(404===t.status)return{rating:0};let e=Error("An error occurred while fetching the data.");try{e.info=await t.json()}catch(t){e.info={message:"Failed to parse error response"}}throw e.status=t.status,e}return t.json()},T={rating:0,hoverRating:0,isSubmitting:!1,showPopup:!1,error:null,justRated:!1},_={SET_RATING:"SET_RATING",SET_HOVER_RATING:"SET_HOVER_RATING",SET_SUBMITTING:"SET_SUBMITTING",TOGGLE_POPUP:"TOGGLE_POPUP",SET_ERROR:"SET_ERROR",CLEAR_ERROR:"CLEAR_ERROR",SET_JUST_RATED:"SET_JUST_RATED"};function ratingReducer(e,t){switch(t.type){case _.SET_RATING:if(t.payload===e.rating)return e;return(0,o._)((0,n._)({},e),{rating:t.payload});case _.SET_HOVER_RATING:return(0,o._)((0,n._)({},e),{hoverRating:t.payload});case _.SET_SUBMITTING:return(0,o._)((0,n._)({},e),{isSubmitting:t.payload});case _.TOGGLE_POPUP:return(0,o._)((0,n._)({},e),{showPopup:t.payload});case _.SET_ERROR:return(0,o._)((0,n._)({},e),{error:t.payload});case _.CLEAR_ERROR:return(0,o._)((0,n._)({},e),{error:null});case _.SET_JUST_RATED:return(0,o._)((0,n._)({},e),{justRated:t.payload});default:return e}}let EpisodeRating=e=>{let{showId:t,seasonNumber:a,episodeNumber:u,initialRating:m,onRatingUpdate:y,showName:N,episodeTitle:v,onSuccess:S}=e,{user:w,isLoaded:P}=(0,s.aF)(),{openAuthModal:O}=(0,x.f)(),[I,j]=(0,l.useReducer)(ratingReducer,(0,o._)((0,n._)({},T),{rating:null!=m?m:0})),A=(0,l.useRef)(null),G=(0,l.useMemo)(()=>"S".concat(String(a).padStart(2,"0"),"E").concat(String(u).padStart(2,"0")),[a,u]),k=(0,l.useMemo)(()=>{let e=v?": ".concat(v):"";return"".concat(G).concat(e)},[G,v]),C=(0,l.useMemo)(()=>t&&null!=a&&null!=u,[t,a,u]),M=(0,l.useMemo)(()=>{if(C&&P&&w){let e=new URLSearchParams({showId:t,seasonNumber:a,episodeNumber:u,userId:w.id});return"/api/rating?".concat(e.toString())}return null},[C,P,w,t,a,u]),{data:U,error:L,isLoading:D,mutate:z}=(0,f.default)(M,fetcher,{keepPreviousData:!0});(0,l.useEffect)(()=>{var e,t;void 0!==U&&U.rating!==I.rating&&j({type:_.SET_RATING,payload:null!==(e=U.rating)&&void 0!==e?e:0}),L&&!I.error&&(console.error("SWR fetch error:",L),j({type:_.SET_ERROR,payload:(null===(t=L.info)||void 0===t?void 0:t.message)||L.message||"Error fetching rating"}),A.current&&clearTimeout(A.current),A.current=setTimeout(()=>j({type:_.CLEAR_ERROR}),5e3)),D||w||I.rating===(null!=m?m:0)||j({type:_.SET_RATING,payload:null!=m?m:0})},[U,L,D,w,m,I.rating,I.error]);let J=(0,l.useCallback)(()=>{try{let e=localStorage.getItem(b);if(e){let t=JSON.parse(e);Date.now()-t.timestamp>864e5&&localStorage.removeItem(b)}}catch(e){console.error("Error cleaning up pending ratings:",e)}},[]),Z=(0,l.useCallback)(e=>{if("number"!=typeof e||isNaN(e))throw Error("Rating must be a number");if(e<1||e>10)throw Error("Rating must be between 1 and 10");return!0},[]),K=(0,l.useCallback)(async function(e){let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!w){j({type:_.SET_ERROR,payload:"User is not authenticated to rate."});return}if(!C){j({type:_.SET_ERROR,payload:"Missing episode information."});return}j({type:_.TOGGLE_POPUP,payload:!1});let o=I.rating,i=getPendingActionKey(t,a,u,w.id);j({type:_.CLEAR_ERROR}),j({type:_.SET_RATING,payload:e}),M&&z({rating:e},!1),!n&&i&&savePendingAction(i,{rating:e,action:"rate",showName:N,episodeTitle:v}),A.current&&clearTimeout(A.current);try{Z(e),j({type:_.SET_SUBMITTING,payload:!0});let n={showId:t,seasonNumber:a,episodeNumber:u,userId:w.id,rating:e,showName:N,episodeTitle:v},o=await fetch("/api/rating",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!o.ok){let e=await o.json();throw Error(e.error||"Failed to update rating")}M&&z(),null==y||y(a,u,e),j({type:_.SET_JUST_RATED,payload:!0}),(0,h.j)("/api/user/notifications"),null==S||S(),"undefined"!=typeof document&&document.dispatchEvent(new CustomEvent("onboarding:ratingSubmitted",{detail:{showId:t,seasonNumber:a,episodeNumber:u,rating:e}})),i&&clearPendingAction(i)}catch(e){console.error("Error updating rating:",e),j({type:_.SET_RATING,payload:o}),M&&z({rating:o},!1),j({type:_.SET_ERROR,payload:e.message||"Failed to update rating. Please try again."}),A.current=setTimeout(()=>j({type:_.CLEAR_ERROR}),5e3)}finally{j({type:_.SET_SUBMITTING,payload:!1})}},[w,t,a,u,y,C,Z,N,v,S,I.rating,M,z,j]),B=(0,l.useCallback)(async e=>{try{if(Z(e),!w){let n={showId:t,seasonNumber:a,episodeNumber:u,rating:e,timestamp:Date.now(),showName:N,episodeTitle:v};localStorage.setItem(b,JSON.stringify(n)),j({type:_.TOGGLE_POPUP,payload:!1}),O({context:"rating",showName:N,episodeDisplayName:G,onClose:()=>{},onCancel:()=>{localStorage.removeItem(b)}});return}await K(e)}catch(e){j({type:_.SET_ERROR,payload:e.message}),A.current&&clearTimeout(A.current),A.current=setTimeout(()=>j({type:_.CLEAR_ERROR}),5e3)}},[w,t,a,u,K,Z,N,v,O,G]),V=(0,l.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!w){j({type:_.SET_ERROR,payload:"User is not authenticated to remove rating."});return}if(!C){j({type:_.SET_ERROR,payload:"Missing episode information."});return}j({type:_.TOGGLE_POPUP,payload:!1});let n=I.rating;if(0===n&&!e)return;let o=getPendingActionKey(t,a,u,w.id);j({type:_.CLEAR_ERROR}),j({type:_.SET_RATING,payload:0}),M&&z({rating:0},!1),!e&&o&&savePendingAction(o,{action:"delete",showName:N,episodeTitle:v}),A.current&&clearTimeout(A.current);try{j({type:_.SET_SUBMITTING,payload:!0});let e=await fetch("/api/rating",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({showId:t,seasonNumber:a,episodeNumber:u,userId:w.id})});if(!e.ok){let t=await e.json();throw Error(t.error||"Failed to remove rating")}M&&z(),null==y||y(a,u,0),null==S||S(),o&&clearPendingAction(o)}catch(e){console.error("Error removing rating:",e),j({type:_.SET_RATING,payload:n}),M&&z({rating:n},!1),j({type:_.SET_ERROR,payload:e.message||"Failed to remove rating."}),A.current=setTimeout(()=>j({type:_.CLEAR_ERROR}),5e3)}finally{j({type:_.SET_SUBMITTING,payload:!1})}},[w,t,a,u,y,C,S,I.rating,M,z,j,N,v]),F=(0,l.useCallback)((e,t)=>
11{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),B(t+1))},[B]),handleMouseEnter=e=>{j({type:_.SET_HOVER_RATING,payload:e})};if((0,l.useEffect)(()=>{if(J(),P&&w&&C){let e=localStorage.getItem(b);if(e){let n=!1,o=null;try{let i=JSON.parse(e);if(o=i,i&&"number"==typeof i.rating&&i.showId===t&&Number(i.seasonNumber)===Number(a)&&Number(i.episodeNumber)===Number(u)&&!(Date.now()-i.timestamp>864e5)){console.log("Migrating unauthenticated pending rating for this episode:",i.rating);let e=getPendingActionKey(t,a,u,w.id);e&&(savePendingAction(e,{rating:i.rating,action:"rate",showName:i.showName||N,episodeTitle:i.episodeTitle||v}),n=!0)}}catch(e){console.error("Error migrating PENDING_RATING_KEY data:",e)}finally{o&&o.showId===t&&Number(o.seasonNumber)===Number(a)&&Number(o.episodeNumber)===Number(u)&&(localStorage.removeItem(b),n?console.log("PENDING_RATING_KEY migrated and removed for this episode."):console.log("PENDING_RATING_KEY for this episode removed after check (not migrated or already expired)."))}}}return()=>{A.current&&clearTimeout(A.current)}},[P,w,C,t,a,u,J,N,v]),(0,l.useEffect)(()=>{if(P&&w&&C&&!I.isSubmitting){let e=getPendingActionKey(t,a,u,w.id),n=getPendingAction(e);if(n){console.log("Processing a stored pending action for ".concat(e," because nothing is currently submitting:"),n);let t=I.rating,a="rate"===n.action?n.rating:0;t!==a&&j({type:_.SET_RATING,payload:a}),"rate"===n.action?K(n.rating,!0):"delete"===n.action&&V(!0)}}},[P,w,C,t,a,u,K,V,I.rating,I.isSubmitting]),!C)return(0,i.jsx)("div",{className:"relative inline-flex items-center min-h-[28px]",children:(0,i.jsx)("div",{className:"bg-red-500 text-white text-xs py-0.5 px-2 rounded text-center",children:"Missing info"})});let H=!P||D&&w,q=I.rating;return(0,i.jsxs)("div",{className:"relative inline-flex items-center h-[28px]",children:[I.error&&(0,i.jsx)("div",{className:"absolute -bottom-8 left-0 right-0 bg-red-500 text-white text-sm py-1 px-2 rounded text-center z-20 shadow",children:I.error}),H?(0,i.jsx)("div",{className:"flex items-center justify-center w-full pointer-events-none",children:(0,i.jsx)(d.Z,{className:"animate-spin text-gray-400",size:20})}):(0,i.jsxs)("div",{className:"inline-flex items-center",children:[0===q&&(0,i.jsx)("button",{onClick:()=>{j({type:_.TOGGLE_POPUP,payload:!0}),"undefined"!=typeof document&&document.dispatchEvent(new CustomEvent("onboarding:ratingModalOpened"))},className:"inline-flex items-center rounded-full shadow-lg hover:shadow-xl transition-all duration-300 ease-in-out group bg-gradient-to-r from-yellow-400 to-amber-500 hover:from-yellow-300 hover:to-amber-400","aria-label":"Rate this episode",children:(0,i.jsxs)("span",{className:"flex items-center space-x-1 px-3 py-1 rounded-full text-black font-bold",children:[(0,i.jsx)(c.Z,{className:"fill-current text-black group-hover:scale-110 transition-transform duration-200",size:16}),(0,i.jsx)("span",{className:"text-sm",children:"Rate"})]})}),q>0&&(0,i.jsx)("button",{onClick:()=>{j({type:_.TOGGLE_POPUP,payload:!0}),"undefined"!=typeof document&&document.dispatchEvent(new CustomEvent("onboarding:ratingModalOpened"))},className:(0,E.Z)("inline-flex items-center rounded-full shadow-sm transition-all duration-200 ease-in-out group font-medium h-[28px]",{}),"aria-label":"Current rating: ".concat(Math.round(q)," stars. Click to edit."),children:(0,i.jsxs)("div",{className:"relative inline-flex items-stretch border border-gray-600/80 rounded-full overflow-hidden bg-gray-700/50 group-hover:border-gray-500/80 group-hover:bg-gray-600/50 transition-colors duration-200",children:[(0,i.jsxs)("div",{className:"flex items-center space-x-1 px-3 py-1 bg-yellow-100 text-yellow-700 z-10 rounded-full",children:[(0,i.jsx)(c.Z,{className:"transition-colors duration-200 flex-shrink-0 text-yellow-600",fill:"currentColor",size:20}),(0,i.jsx)("span",{className:"font-medium flex-shrink-0",children:Math.round(q)})]}),(0,i.jsx)("div",{className:"flex items-center justify-center pr-2 pl-1.5 text-gray-300 border-gray-600/80 group-hover:text-white transition-colors duration-200",children:(0,i.jsx)(p,{size:14,className:"block"})})]})})]}),I.showPopup&&"undefined"!=typeof document&&(0,R.createPortal)((0,i.jsx)("div",{className:"fixed inset-0 bg-black bg-opacity-70 flex items-center justify-center z-[2147483647] px-4",role:"dialog","aria-modal":"true","aria-labelledby":"rating-modal-title",onClick:()=>{j({type:_.TOGGLE_POPUP,payload:!1}),"undefined"!=typeof document&&document.dispatchEvent(new CustomEvent("onboarding:ratingModalClosed"))},children:(0,i.jsxs)("div",{className:"relative bg-gradient-to-br from-slate-900 via-gray-900 to-slate-800 text-white px-8 py-6 sm:px-12 sm:py-8 rounded-3xl shadow-2xl w-full max-w-md 
11sm:max-w-lg transform transition-all duration-300 ease-out border border-slate-700/50 overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,i.jsxs)("div",{className:"absolute inset-0 opacity-10 pointer-events-none",children:[(0,i.jsx)("div",{className:"absolute top-0 left-0 w-32 h-32 bg-orange-500 rounded-full blur-3xl opacity-50"}),(0,i.jsx)("div",{className:"absolute bottom-0 right-0 w-40 h-40 bg-purple-500 rounded-full blur-3xl opacity-50"})]}),(0,i.jsxs)("div",{className:"relative z-10",children:[(0,i.jsxs)("div",{className:"text-center mb-6 sm:mb-8",children:[(0,i.jsx)("h2",{id:"rating-modal-title",className:"text-xl sm:text-2xl font-bold text-white mb-2 drop-shadow-md",children:I.rating?"Edit Rating":"Rate This Episode"}),(0,i.jsx)("h3",{className:"text-base sm:text-lg text-gray-300/90 font-medium break-words",children:k})]}),(0,i.jsx)("div",{className:"flex justify-center mb-8 sm:mb-10 flex-wrap sm:flex-nowrap gap-1 sm:gap-1.5 max-w-[280px] sm:max-w-none mx-auto",onMouseLeave:()=>{j({type:_.SET_HOVER_RATING,payload:0})},role:"group","aria-label":"Star rating",children:Array.from({length:10},(e,t)=>{let a=t+1,n=a<=(I.hoverRating||I.rating);return(0,i.jsx)("button",{onClick:()=>B(a),onMouseEnter:()=>handleMouseEnter(a),onKeyPress:e=>F(e,t),className:"transition-all duration-200 transform p-0.5 sm:p-1 ".concat(n?"text-yellow-400 scale-110 drop-shadow-[0_0_8px_rgba(250,204,21,0.5)]":"text-gray-600 hover:text-yellow-200/50 hover:scale-110"),"aria-label":"Rate ".concat(a," star").concat(a>1?"s":""),"aria-pressed":I.rating===a,tabIndex:0,children:(0,i.jsx)(c.Z,{fill:n?"currentColor":"none",size:24,className:"w-6 h-6 sm:w-8 sm:h-8",strokeWidth:n?0:1.5})},t)})}),(0,i.jsxs)("div",{className:"flex justify-center space-x-4",children:[(0,i.jsx)("button",{onClick:()=>{j({type:_.TOGGLE_POPUP,payload:!1}),"undefined"!=typeof document&&document.dispatchEvent(new CustomEvent("onboarding:ratingModalClosed"))},className:"px-6 py-2.5 rounded-full text-sm font-semibold bg-white/10 hover:bg-white/20 text-white border border-white/10 transition-all duration-200",disabled:I.isSubmitting,children:"Cancel"}),I.rating>0&&(0,i.jsxs)("button",{onClick:()=>V(),className:"px-6 py-2.5 rounded-full text-sm font-semibold bg-red-500/10 hover:bg-red-500/20 text-red-200 border border-red-500/20 transition-all duration-200 flex items-center gap-2 group","aria-label":"Remove rating",children:[(0,i.jsx)(g.Z,{size:16,className:"group-hover:scale-110 transition-transform"}),(0,i.jsx)("span",{children:"Remove"})]})]})]})]})}),document.body)]})};EpisodeRating.propTypes={showId:y().oneOfType([y().string,y().number]).isRequired,seasonNumber:y().number.isRequired,episodeNumber:y().number.isRequired,initialRating:y().number,onRatingUpdate:y().func,showName:y().string,episodeTitle:y().string,onSuccess:y().func},EpisodeRating.defaultProps={onRatingUpdate:null,onSuccess:null};var N=l.memo(EpisodeRating)},90512:function(e,t,a){t.Z=function(){for(var e,t,a=0,n="",o=arguments.length;a<o;a++)(e=arguments[a])&&(t=function r(e){var t,a,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e){if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(a=r(e[t]))&&(n&&(n+=" "),n+=a)}else for(a in e)e[a]&&(n&&(n+=" "),n+=a)}return n}(e))&&(n&&(n+=" "),n+=t);return n}}}]);

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.