"use strict";(globalThis.webpackChunk_shopby_react_skin=globalThis.webpackChunk_shopby_react_skin||[]).push([[8940],{78940(e,t,a){a.r(t),a.d(t,{ReviewImages:()=>k,ReviewsList:()=>I,Stars:()=>_,default:()=>L});var l=a(91598),r=a(54983),n=a(52386),s=a(11089),i=a(73994),o=a(76328);var c=a(10340),p=a(18267),u=a(75439),m=a(55952),v=a(54510),d=a(54983);function h(){return h=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var a=0,l=Array(t);a`리뷰 사진 ${e} 확대 보기`,dialogLabel:"리뷰 사진 확대",close:"닫기",prev:"이전",next:"다음",imageAlt:(e,t)=>`리뷰 사진 ${e} / ${t}`},pdpInquiries:c.w},f=y.review,E=y.reviewLightbox,w=[{key:"latest",label:f.sort.latest},{key:"best_first",label:f.sort.bestFirst},{key:"highest_rating",label:f.sort.highestRating},{key:"lowest_rating",label:f.sort.lowestRating}],N=()=>d.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0},d.createElement("polyline",{points:"9 18 15 12 9 6"})),_=e=>{let t=e.rate;const a=(0,p.Jt3)(t);return d.createElement("span",{"aria-label":f.ratingAria(a.label),className:"t-caption hv-pdp-rv-stars"},"★".repeat(a.full),d.createElement("span",{className:"hv-pdp-rv-stars__empty"},"★".repeat(a.empty)))};_.propTypes={rate:s.number.isRequired};const k=e=>{let t=e.images;const a=b((0,r.useState)(null),2),s=a[0],i=a[1],o=(0,r.useRef)(null),c=t.length;return(0,r.useEffect)(()=>{if(null===s)return;const e=(0,v.z)(),t=e=>{"Escape"===e.key&&i(null),"ArrowRight"===e.key&&i(e=>null===e?null:(e+1)%c),"ArrowLeft"===e.key&&i(e=>null===e?null:(e-1+c)%c)};document.addEventListener("keydown",t);const a=setTimeout(()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.focus()},50);return()=>{e(),document.removeEventListener("keydown",t),clearTimeout(a)}},[s,c]),d.createElement(d.Fragment,null,d.createElement("ul",{className:"hv-pdp-rv-thumbs"},t.slice(0,4).map((e,t)=>d.createElement("li",{key:`${t}-${e}`},d.createElement("button",{type:"button",onClick:()=>i(t),className:"hv-pdp-rv-thumb","aria-label":E.openLabel(t+1)},d.createElement("img",h({},(0,l.Pp)(e,72,!1),{alt:""})))))),null!==s?(0,n.createPortal)(d.createElement("div",{role:"dialog","aria-modal":"true","aria-label":E.dialogLabel,className:"hv-pdp-lb",onClick:e=>{e.target===e.currentTarget&&i(null)}},d.createElement("button",{ref:o,type:"button",onClick:()=>i(null),"aria-label":E.close,className:"hv-pdp-lb__close"},"×"),c>1?d.createElement(d.Fragment,null,d.createElement("button",{type:"button",onClick:()=>i(e=>null===e?null:(e-1+c)%c),"aria-label":E.prev,className:"hv-pdp-lb__nav hv-pdp-lb__nav--prev"},"‹"),d.createElement("button",{type:"button",onClick:()=>i(e=>null===e?null:(e+1)%c),"aria-label":E.next,className:"hv-pdp-lb__nav hv-pdp-lb__nav--next"},"›")):null,d.createElement("figure",{className:"hv-pdp-lb__fig"},d.createElement("img",h({},(0,l.Pp)(t[s],[400,1e3],!1),{alt:E.imageAlt(s+1,c),className:"hv-pdp-lb__img"})),d.createElement("figcaption",{className:"hv-pdp-lb__cap"},s+1," / ",c))),document.body):null)};k.propTypes={images:(0,s.arrayOf)(s.string).isRequired};const C=()=>d.createElement("div",{className:"hv-pdp-rv-empty"},d.createElement("div",{className:"hv-pdp-rv-empty__wrap"},d.createElement("h3",{className:"hv-pdp-empty-title"},f.empty.title),d.createElement("span",{"aria-hidden":!0,className:"hv-pdp-rv-stamp"},f.empty.stamp))),R=e=>{let t=e.label,a=e.disabled,l=e.onClick;return a?d.createElement("span",{className:"hv-pdp-rv-page hv-pdp-rv-page--nav is-disabled"},t):d.createElement("button",{type:"button",onClick:l,className:"hv-pdp-rv-page hv-pdp-rv-page--nav"},t)};R.propTypes={label:s.string.isRequired,disabled:s.bool.isRequired,onClick:s.func.isRequired};const S=e=>{let t=e.page,a=e.pageCount,l=e.onPage;return d.createElement("nav",{"aria-label":f.pagination.aria,className:"hv-pdp-rv-pager"},d.createElement(R,{label:f.pagination.prev,disabled:1===t,onClick:()=>l(t-1)}),(0,p.UI9)(t,a).map(e=>d.createElement("button",{key:e,type:"button",onClick:()=>l(e),"aria-current":e===t?"page":void 0,className:"hv-pdp-rv-page"+(e===t?" is-current":"")},e)),d.createElement(R,{label:f.pagination.next,disabled:t===a,onClick:()=>l(t+1)}))};S.propTypes={page:s.number.isRequired,pageCount:s.number.isRequired,onPage:s.func.isRequired};const q=e=>{let t=e.review;const a=(0,p.kNp)(t.fileUrls);return d.createElement("article",{className:"hv-pdp-rv-item"},d.createElement("div",{className:"hv-pdp-rv-item__head"},d.createElement("p",{className:"hv-pdp-rv-item__who"},t.writerId||t.registerName||y.pdpInquiries.anonymousWriter,"Y"===t.bestReviewYn?d.createElement("span",{className:"hv-pdp-rv-best"},f.bestBadge):null),d.createElement("span",{className:"t-small"},t.registerYmdt??"")),d.createElement("div",{className:"hv-pdp-rv-item__stars"},d.createElement(_,{rate:t.rate??0})),t.content?d.createElement("p",{className:"hv-pdp-rv-item__content"},t.content):null,a.length>0?d.createElement("div",{className:"hv-pdp-rv-item__imgs"},d.createElement(k,{images:a})):null)};q.propTypes={review:s.object.isRequired};const I=e=>{let t=e.productNo,a=e.initialItems,l=e.totalCount,n=e.defaultSort;const s=b((0,r.useState)(1),2),o=s[0],c=s[1],m=b((0,r.useState)(n),2),v=m[0],h=m[1],g=b((0,r.useState)(a),2),y=g[0],E=g[1],_=b((0,r.useState)(!1),2),k=_[0],C=_[1],R=b((0,r.useState)(l<=6),2),I=R[0],L=R[1],A=(0,p.$5g)(l),T=(e,t)=>{const a=(0,p.yld)(window.location.search,e,t);window.history.replaceState(window.history.state,"",`${window.location.pathname}${a?`?${a}`:""}#reviews`)},x=(e,a)=>{C(!0),(0,u.MB)(t,e).then(t=>{E((0,p.Wfq)(t.items,a)),c(e),h(a),T(e,a)}).catch(()=>(0,i.P)(f.listError)).finally(()=>C(!1))};return(0,r.useEffect)(()=>{const e=(0,p.n0n)(window.location.search,n);e.page>1?(L(!0),x(e.page,e.sort)):e.sort!==n&&(L(!0),h(e.sort),E(t=>(0,p.Wfq)(t,e.sort)))},[]),d.createElement("div",{className:"hv-pdp-rv-list"+(k?" is-loading":"")},y.length>0&&I?d.createElement("nav",{"aria-label":f.sort.ariaLabel,className:"hv-pdp-rv-sort"},w.map(e=>{const t=e.key===v;return d.createElement("button",{key:e.key,type:"button",onClick:()=>{var t;(t=e.key)!==v&&(h(t),E(e=>(0,p.Wfq)(e,t)),T(o,t))},"data-active":t||void 0,className:"hv-pdp-rv-chip"+(t?" is-active":"")},e.label)})):null,0===y.length?d.createElement("p",{className:"hv-pdp-rv-pageempty"},f.pageEmpty):(I?y:y.slice(0,6)).map(e=>d.createElement(q,{key:e.reviewNo,review:e})),I?null:d.createElement("button",{type:"button",onClick:()=>L(!0),className:"h-btn h-btn--secondary h-btn--block hv-pdp-rv-more"},f.viewAll(l),d.createElement(N,null)),I&&A>1?d.createElement(S,{page:o,pageCount:A,onPage:e=>{var t;e===o||e<1||e>A||(x(e,v),null===(t=document.getElementById("reviews"))||void 0===t||t.scrollIntoView({block:"start"}))}}):null)};I.propTypes={productNo:s.number.isRequired,initialItems:(0,s.arrayOf)(s.object).isRequired,totalCount:s.number.isRequired,defaultSort:s.string.isRequired};const L=()=>{var e,t,a;const l=(0,m.y)(),n=l.productNo,s=l.detail,i=b((0,r.useState)(null),2),o=i[0],c=i[1];(0,r.useEffect)(()=>{let e=!0;return c(null),(0,u.MB)(n,1).then(t=>e&&c({items:t.items,totalCount:t.totalCount,avg:t.rate,errored:!1})).catch(()=>e&&c({items:[],totalCount:0,avg:null,errored:!0})),()=>{e=!1}},[n]);const v=b((0,r.useState)(null),2),h=v[0],g=v[1];(0,r.useEffect)(()=>{let e=!0;return(0,u.S2)().then(t=>e&&g(t)),()=>{e=!1}},[]);const y="number"==typeof s.reviewRate?s.reviewRate:"number"==typeof(null===(e=s.baseInfo)||void 0===e?void 0:e.reviewRating)?s.baseInfo.reviewRating:0,E="number"==typeof(null===(t=s.counter)||void 0===t?void 0:t.reviewCnt)?s.counter.reviewCnt:"number"==typeof(null===(a=s.baseInfo)||void 0===a?void 0:a.totalReviewCount)?s.baseInfo.totalReviewCount:0,w=o?(0,p.qIn)({...o,fallbackRate:y,fallbackCount:E}):null;return d.createElement("section",{id:"reviews",className:"hv-pdp-section hv-pdp-rv"},d.createElement("div",{className:"hv-pdp-sec-head"},d.createElement("h2",{className:"t-pdp-section hv-pdp-sec-head__h2"},d.createElement("span",null,f.heading),w&&w.totalCount>0?d.createElement("span",{className:"t-pdp-section__count"},"[ ",w.totalCount," ]"):null)),null!==h?d.createElement("p",{className:"t-small hv-pdp-rv__reward"},f.rewardMaximum(h)):null,w?"empty"===w.state?d.createElement(C,null):d.createElement("div",{className:"hv-pdp-rv-grid"},d.createElement("aside",{className:"hv-pdp-rv-aside"},d.createElement("p",{className:"t-caption hv-pdp-rv-aside__eyebrow"},f.overall.eyebrow),d.createElement("p",{className:"hv-pdp-rv-aside__avg"+(w.avgNormalized?"":" is-empty")},w.avgNormalized??d.createElement("span",{"aria-hidden":!0,className:"hv-pdp-rv-aside__dash"},"-"),d.createElement("span",{className:"hv-pdp-rv-aside__outof"},f.overall.outOf)),d.createElement("p",{className:"t-small hv-pdp-rv-aside__count"},0===w.totalCount?f.overall.countSuffix(w.totalCount):f.overall.reviewCount(w.totalCount))),"error"===w.state?d.createElement("p",{className:"t-small hv-pdp-rv-error"},f.listError):"emptyList"===w.state?d.createElement(C,null):d.createElement(I,{productNo:n,initialItems:w.reviews,totalCount:w.totalCount,defaultSort:w.effectiveSort})):null)}}}]);