1import{s as h,w as v,b as g,c as l,l as _,aj as a,ah as u,M as w,S,C as E}from"./storefrontApp.DHj_rTVq.min.js";import{w as d,h as m,$ as A,e as f,t as y}from"./chunk-vendor-lit.NvY0u02.js";import{S as x}from"./chunk-storefront_base_lit_element.BDgKmPq.js";import{o as $}from"./chunk-observe_when_directive.DWgxaey.js";import{P as p}from"./chunk-product_review_events.Ro9L3Du.js";import"./chunk-vendor-di.Bh23gdA.js";import"./chunk-storefront_settings_constants.DIF02Gz.js";import"./chunk-vendor-rxjs.Dp7kflo.js";import"./chunk-vendor-lodash.CWHFt7Z.js";import"./chunk-vendor-phoenix.cdKS79L.js";class N{#e;constructor({productRatingStore:e}){this.#e=e}selectDoesReviewsExists$(){return this.#e.pipe(h(e=>e.doesReviewsExists))}setDoesReviewsExists(e){this.#e.update(v(t=>t.doesReviewsExists=e))}}class P extends g{constructor({productRatingStoreRepository:e,messageStorageApi:t,rateAndReviewApi:r}){super(),this._messageStorageApi=t,this._rateAndReviewApi=r,this._productRatingStoreRepository=e,this._checkForReviewsModule(),this._setupEventHandlers()}_checkForReviewsModule(){const e=this._messageStorageApi.getChannelMessages(p.reviewsRendered);this._productRatingStoreRepository.setDoesReviewsExists(!!(e&&e.length>0))}_setupEventHandlers(){this.eventBus.on(p.reviewsRendered,()=>{this._productRatingStoreRepository.setDoesReviewsExists(!0)})}selectDoesReviewsExist$(){return this._productRatingStoreRepository.selectDoesReviewsExists$()}disableVotingIfAlreadyVoted(e,t){this._rateAndReviewApi.selectHasBeenReviewed$(e).subscribe(r=>{if(r||this._rateAndReviewApi.hasBeenReviewed(e)){const s=t.querySelector("product-vote"),o=t.querySelector("product-vote[disabled]");s&&(s.hidden=!0),o&&(o.hidden=!1)}})}}const b=()=>l({name:a.store},_({doesReviewsExists:!1}));var D=Object.defineProperty,R=(i,e,t,r)=>{for(var s=void 0,o=i.length-1,c;o>=0;o--)(c=i[o])&&(s=c(e,t,s)||s);return s&&D(e,t,s),s};class n extends x{constructor(){super(...arguments),this.productId=""}static{this.moduleName=a.component}connectedCallback(){super.connectedCallback(),this._$ratingWithoutReview=this.querySelector('[slot="rating-without-reviews"]'),this._$ratingWithoutReview&&this.getApi(u.api).then(e=>{const t=this.getApiSync(w),r=b(),s=new N({productRatingStore:r});this._productRatingService=new P({productRatingStoreRepository:s,messageStorageApi:t,rateAndReviewApi:e}),this._productRatingService.disableVotingIfAlreadyVoted(this.productId,this._$ratingWithoutReview.content)})}render(){return this._productRatingService?A`${$(this._productRatingService.selectDoesReviewsExist$(),this.getSlot("rating-with-reviews"),this._$ratingWithoutReview?m(this._$ratingWithoutReview):d)}`:d}}R([f({type:String,attribute:"product-id"})],n.prototype,"productId");R([y()],n.prototype,"_productRatingService");class q extends S{static{this.dependencies=[u.feature]}static{this.featureName=a.feature}init(){return{cores:[{type:E,instance:[n]}]}}}export{q as ProductRatingInitializer};
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.