PageSourceSearch

https://rozarium.eu/application/assets/storefront/chunk-rate_and_review_initializer.2ud86RH.js

js rozarium.eu collected 2026-10-02 23:28:48 UTC 12,939 bytes, 73 lines download raw bytes

1import{t as H,ah as u,R as g,u as d,h as A,i as G,ad as n,G as S,a as C,s as U,w as k,c as x,l as Y,e as y,T,o as D,N as q,q as V,H as j,p as z,C as K,r as Q}from"./storefrontApp.CsApItsi.min.js";import{B as W}from"./chunk-base_http_api_url.H743YfZ.js";import{b as Z,w as R,$ as h,d as J,e as f,t as _}from"./chunk-vendor-lit.NvY0u02.js";import{S as N}from"./chunk-storefront_settings_constants.DIF02Gz.js";import{S as I}from"./chunk-storefront_base_lit_element.lX23Jvc.js";import{t as c}from"./chunk-translations_directive.DWSzkd6.js";import{b as X}from"./chunk-flash_message_constants.CxvW13E.js";import{M as v}from"./chunk-modal_constants.RvL-5Lb.js";import"./chunk-vendor-di.Bh23gdA.js";import"./chunk-vendor-rxjs.Dp7kflo.js";import"./chunk-vendor-lodash.CWHFt7Z.js";import"./chunk-vendor-phoenix.cdKS79L.js";class $ extends W{constructor(e,t){super(e,t)}getProductReviewUrl(e){return`${this.webapiUrl}/products/${e}/review/`}}class b extends H{constructor({httpApi:e,settingsApi:t,localeOptions:a}){super(e),this.moduleName=u.httpApi,this.#e=new $(t,a)}#e;rate(e){const t=this.#e.getProductReviewUrl(e.productId);return this.fetch({url:t,data:e,method:g.post},{decorators:[d.status,d.flashMessages]})}review(e){const t=this.#e.getProductReviewUrl(e.productId);return this.fetch({url:t,data:e,method:g.post},{decorators:[d.status,d.flashMessages]})}rateAndReview(e){const t=this.#e.getProductReviewUrl(e.productId);return this.fetch({url:t,data:e,method:g.post},{decorators:[d.status,d.flashMessages]})}}class F{constructor(){}static{this.STATUS_CODE_CONTENT={[A.methodNotAllowed]:"Your rating has already been added. You can't vote again.",[A.badRequest]:"You cannot submit a blank form. Select the number of stars to rate the product.",[A.notFound]:"The product you are trying to rate no longer exists.",[A.unauthorized]:"You must be logged in to rate products and add reviews."}}static getMessageBasedOnStatusCode(e,t){const a=this.STATUS_CODE_CONTENT[e];return(a&&t.translate(a))??t.translate("Sending failed due to server error. Try again.")}}class ee extends G{constructor({httpApi:e,rateAndReviewService:t,settingsApi:a,localeOptions:s,flashMessengerApi:i,translationsApi:o}){super(),this.moduleName=u.api,this.#e=new b({httpApi:e,rateAndReviewService:t,settingsApi:a,localeOptions:s}),this.#s=i,this.#t=t,this._translationsApi=o}#e;#s;#t;hasBeenReviewed(e){return this.#t.hasBeenReviewed(e)}saveThatHasBeenReviewed(e){return this.#t.saveThatHasBeenReviewed(e)}selectHasBeenReviewed$(e){return this.#t.selectHasBeenReviewed$(e)}async rate(e){try{const{data:t}=await this.#e.rate(e).response,{flashMessages:a,status:s}=t;return s===n.success&&this.#t.saveThatHasBeenReviewed(e.productId),this._displayFlashMessages(a),s}catch(t){return this._displayErrorFlashMessages(t),n.failed}}async review(e){try{const{data:t}=await this.#e.review(e).response,{flashMessages:a,status:s}=t;return s===n.success&&this.#t.saveThatHasBeenReviewed(e.productId),this._displayFlashMessages(a),s}catch(t){return this._displayErrorFlashMessages(t),n.failed}}async rateAndReview(e){try{const{data:t}=await this.#e.rateAndReview(e).response,{flashMessages:a,status:s}=t;return s===n.success&&this.#t.saveThatHasBeenReviewed(e.productId),this._displayFlashMessages(a),s}catch(t){return this._displayErrorFlashMessages(t),n.failed}}_displayFlashMessages(e){e&&this.#s.parseAndAddFlashMessages(e,S)}_displayErrorFlashMessages(e){const t=e.request,a=F.getMessageBasedOnStatusCode(t.status,this._translationsApi);this.#s.addFlashMessage({content:a,type:C.error,isCloseable:!1},S)}}class te{#e;constructor({rateAndReviewStore:e}){this.#e=e}selectHasReviewBeenSaved$(e){return this.#e.pipe(U(t=>t.reviews[e]))}setReviewBeenSaved(e,t){this.#e.update(k(a=>a.reviews[e]=t))}}const M="rate_and_review";class se{#e;#s;#t;constructor({rateAndReviewRepository:e,storeFactoryApi:t}){this.#e=t,this.#s=this._getStore(),this.#t=e}_getStore(){const e=this.#e.getStore(M);return e||this.#e.createStore("local",M)}saveThatHasBeenReviewed(e){const t=this._getProductKey(e);this.#s.set(t,!0),this.#t.setReviewBeenSaved(e,!0)}hasBeenReviewed(e){const t=this._getProductKey(e);return this.#s.get(t)!==null}selectHasBeenReviewed$(e){return this.#t.selectHasReviewBeenSaved$(e)}_getProductKey(e){return`product-${e}`}}const ae=()=>x({name:u.store},Y({reviews:{}})),O="product-rating-form",re=O;var ie=Object.defineProperty,p=(r,e,t,a)=>{for(var s=void 0,i=r.length-1,o;i>=0;i--)(o=r[i])&&(s=o(e,t,s)||s);return s&&ie(e,t,s),s};class l extends I{constructor(){super(),this.productId="",this.moduleInstanceId="",this._hasFunctionalConsentsGranted=!1,this._formConnectorRef=Z(),this._flashMessengerContainerName=S,this._removeAllMessages=()=>{this._flashMessengerApi.removeAllFlashMessages(this._flashMessengerContainerName)},this._markFunctionalConsentsAsGranted=()=>{this._hasFunctionalConsentsGranted=!0},this._openConsentsModal=async()=>{await this._closeModal(),this._customerPrivacyApi?.showAdvancedModalForConsentsChange(),document.addEventListener(v.closed,this._openModalAndRemoveListener)},this._openModalAndRemoveListener=()=>{this._openModal(),document.removeEventListener(v.closed,this._openModalAndRemoveListener)},this._onSubmit=t=>{const a=t.detail.submitActionProps.responseObject,{flashMessages:s,status:i}=a.data;s&&(i===n.success&&(this._rateAndReviewApi?.saveThatHasBeenReviewed(this.productId),this._flashMessengerApi.parseAndAddFlashMessages(s,S),this._closeModal()),i===n.failed&&this._flashMessengerApi.parseAndAddFlashMessages(s,this._flashMessengerContainerName))},this._onSubmitError=t=>{const a=t.detail.submitActionProps.err.request.status,s=F.getMessageBasedOnStatusCode(a,this._translationApi);this._flashMessengerApi.addFlashMessage({content:s,type:C.error,isCloseable:!1,timeout:0},this._flashMessengerContainerName)},this._changeScore=t=>{const{value:a}=t.detail;this._formConnectorRef.value?.formService.setFormControlValue(`rating-${this.moduleInstanceId}`,a)},this._flashMessengerApi=this.getApiSync(y.api);const e=this.getApiSync(N.api);this._rateAndReviewUrl=new $(e),this._translationApi=this.getApiSync(T.api),this.getApi(u.api).then(t=>{this._rateAndReviewApi=t}),this.getApi(D).then(t=>{this._customerPrivacyApi=t,this._customerPrivacyApi.onFunctionalConsentGranted(this._markFunctionalConsentsAsGranted)})}static{this.moduleName=O}connectedCallback(){super.connectedCallback(),this._flashMessengerContainerName=`${re}-${this.moduleInstanceId}`,document.addEventListener(v.close,this._removeAllMessages)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener(v.close,this._removeAllMessages)}
1async _openModal(){await document.querySelector(`#product-rating-modal-${this.moduleInstanceId}`)?.open()}async _closeModal(){await document.querySelector(`#product-rating-modal-${this.moduleInstanceId}`)?.close()}render(){const e=document.querySelector("#iconsPath")?.href||"/assets/img/icons/symbol-defs.svg";return h`
2            ${this._hasFunctionalConsentsGranted?R:h`
3                      <span class="flash-message flash-message_secondary flash-message__warning mb-xs-2">
4                          <svg
5                              class="icon icon_s ${X}"
6                              aria-hidden="true"
7                          >
8                              <use href="${e}#icon-alert-circle" xlink:href="${e}#icon-alert-circle"></use>
9                          </svg>
10                          <p>
11                              ${c("To leave feedback")},
12                              ${this._customerPrivacyApi?.isCookieInformationEnabled()?h`<span
13                                        class="link link_secondary"
14                                        @click=${this._openConsentsModal}
15                                        >${c("accept the Functional cookie type")}</span
16                                    >`:h`${c("accept the Functional cookie type")}`}.
17                          </p>
18                      </span>
19                  `}
20            <form-connector
21                ${J(this._formConnectorRef)}
22                @submit=${this._onSubmit}
23                @submitError=${this._onSubmitError}
24                @changeScore=${this._changeScore}
25                id="product-rate-and-review-form-connector-${this.moduleInstanceId}"
26                submit-strategy="frontApi"
27            >
28                <form
29                    id="product-rate-and-review-form-${this.moduleInstanceId}"
30                    action="${this._rateAndReviewUrl.getProductReviewUrl(this.productId)}"
31                    method="post"
32                >
33                    ${this._hasFunctionalConsentsGranted?this.getSlot("form"):this.getSlot("disabled-form")}
34                </form>
35            </form-connector>
36        `}}p([f({type:Number,attribute:"product-id"})],l.prototype,"productId");p([f({type:Number,attribute:"module-instance-id"})],l.prototype,"moduleInstanceId");p([_()],l.prototype,"_hasFunctionalConsentsGranted");p([_()],l.prototype,"_rateAndReviewApi");p([_()],l.prototype,"_customerPrivacyApi");const oe={changeScore:"changeScore"},ne="star-rating-control";var ce=Object.defineProperty,w=(r,e,t,a)=>{for(var s=void 0,i=r.length-1,o;i>=0;i--)(o=r[i])&&(s=o(e,t,s)||s);return s&&ce(e,t,s),s};class m extends I{constructor(){super(...arguments),this.disabled=!1,this._selectedScore=0,this._hoveredScore=0}static{this.moduleName=ne}_highlightStars(e){this._hoveredScore=e}_unhighlightStars(){this._hoveredScore=0}_chooseScore(e){this._selectedScore=e;const t=new CustomEvent(oe.changeScore,{bubbles:!0,detail:{value:this._selectedScore}});this.dispatchEvent(t)}render(){return h` <div class="stars-rating-control">
37            <div class="stars-rating-control__stars">
38                <div
39                    @mouseleave=${()=>this._unhighlightStars()}
40                    class="star-score"
41                >
42                    ${[1,2,3,4,5].map(e=>h` <svg
43                            tabindex="0"
44                            aria-label="${c("Set rating {{ score }} out of 5 stars",{score:e})}, ${this._selectedScore>=e?c("selected"):c("unselected")}"
45                            class="
46                                icon
47                                icon_xxl
48                                icon_no-stroke
49                                star-icon
50                                ${this.disabled?"star-icon_disabled":"star-icon_hoverable"}
51                                ${this._hoveredScore>=e?" star-icon_hovered":""}
52                                ${this._selectedScore>=e?" star-icon_active":""}"
53                            viewBox="0 0 24 24"
54                            fill="none"
55                            xmlns="http://www.w3.org/2000/svg"
56                            @mouseenter=${()=>this._highlightStars(e)}
57                            @click=${()=>this._chooseScore(e)}
58                            @keydown=${t=>{t.key==="Enter"&&this._chooseScore(e)}}
59                        >
60                            <path
61                                d="M11.1033 3.81663C11.4701 3.07346 12.5299 3.07346 12.8967 3.81663L14.8576 7.78909C15.0031 8.08394 15.2843 8.2884 15.6096 8.33595L19.9962 8.97712C20.8161 9.09696 21.1429 10.1048 20.5493 10.683L17.3768 13.773C17.1409 14.0027 17.0333 14.3339 17.0889 14.6584L17.8374 19.0226C17.9775 19.8396 17.12 20.4626 16.3864 20.0767L12.4655 18.0148C12.1741 17.8615 11.8259 17.8615 11.5345 18.0148L7.61363 20.0767C6.88 20.4626 6.02245 19.8396 6.16257 19.0226L6.91109 14.6584C6.96675 14.3339 6.85908 14.0027 6.62321 13.773L3.45068 10.683C2.85708 10.1048 3.18387 9.09696 4.00378 8.97712L8.39037 8.33595C8.71572 8.2884 8.99691 8.08394 9.14245 7.78909L11.1033 3.81663Z"
62                                aria-hidden="true"
63                            />
64                        </svg>`)}
65                </div>
66            </div>
67            <div class="stars-rating-control__choice">
68                ${this._hoveredScore&&!this._selectedScore?c("Choose the rate: {{ hoveredScore }}",{hoveredScore:this._hoveredScore}):R}
69                <span class="font_semibold"
70                    >${this._selectedScore?c("Your rate: {{ score }}",{score:this._selectedScore}):R}</span
71                >
72            </div>
73        </div>`}}w([f({type:Boolean})],m.prototype,"disabled");w([_()],m.prototype,"_selectedScore");w([_()],m.prototype,"_hoveredScore");class fe extends q{static{this.featureName=u.feature}static{this.dependencies=[V]}
73async init(){const e=this.getApiSync(j),t=await this.getApi(N.api),a=await this.getApi(y.api),s=this.getApiSync(z),i=await this.getApi(T.api),o=ae(),P=new te({rateAndReviewStore:o}),E=new se({rateAndReviewRepository:P,storeFactoryApi:s}),L=new b({httpApi:e,settingsApi:t,rateAndReviewService:E}),B=new ee({httpApi:e,settingsApi:t,flashMessengerApi:a,rateAndReviewService:E,translationsApi:i});return{cores:[{type:K,instance:[l,m]},{type:Q.api,instance:[L,B]}]}}}export{fe as ReviewMatcherInitializer};

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.