PageSourceSearch

https://sklep.497bledow.pl/application/assets/storefront/chunk-blo…article_comment_form_initializer.DHrWyze.js

js 497bledow.pl collected 2026-10-08 07:30:53 UTC 5,053 bytes, 17 lines download raw bytes

1import{h as d,G as n,ad as m,a as h,e as u,T as g,aG as l,i as N,t as F,R as T,u as p,b as O,S as I,y as R,H as y,C as B,r as v}from"./storefrontApp.DHj_rTVq.min.js";import{b as H,d as L,$,e as _}from"./chunk-vendor-lit.NvY0u02.js";import{B as U}from"./chunk-base_http_api_url.Bkqove8.js";import{S}from"./chunk-storefront_settings_constants.DIF02Gz.js";import{S as w}from"./chunk-storefront_base_lit_element.BDgKmPq.js";import{M as A}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";const P="blog-article-comments-form";class E{static getMessageBasedOnStatusCode(e,t){let s=t.translate("Error while adding comment to news.");switch(e){case d.notFound:s=t.translate("News not found.");break;case d.unauthorized:s=t.translate("Comments are disabled for non logged users.");break}return s}}class M extends U{constructor(e,t){super(e,t)}getBlogArticleCommentsUrl(e){return`${this.webapiUrl}/news/${e}/comments`}}var G=Object.defineProperty,f=(a,e,t,s)=>{for(var o=void 0,r=a.length-1,i;r>=0;r--)(i=a[r])&&(o=i(e,t,o)||o);return o&&G(e,t,o),o};class c extends w{constructor(){super(),this.moduleInstanceId="",this.blogArticleId="",this._formConnectorRef=H(),this._flashMessengerContainerName=n,this._removeAllMessages=()=>{this._flashMessengerApi.removeAllFlashMessages(this._flashMessengerContainerName)},this._onSubmit=t=>{const s=t.detail.submitActionProps.responseObject,{flashMessages:o,status:r}=s.data;o&&(r===m.success&&(this._flashMessengerApi.parseAndAddFlashMessages(o,n),this._closeModal(),this._formConnectorRef.value?.formService.resetForm()),r===m.failed&&this._flashMessengerApi.parseAndAddFlashMessages(o,this._flashMessengerContainerName))},this._onSubmitError=t=>{const s=t.detail.submitActionProps.err.request.status,o=E.getMessageBasedOnStatusCode(s,this._translationApi);this._flashMessengerApi.addFlashMessage({content:o,type:h.error,isCloseable:!1},this._flashMessengerContainerName)},this._flashMessengerApi=this.getApiSync(u.api),this._translationApi=this.getApiSync(g.api);const e=this.getApiSync(S.api);this._blogArticleCommentFormHttpUrl=new M(e)}static{this.moduleName=l.component}connectedCallback(){super.connectedCallback(),this._flashMessengerContainerName=`${P}-${this.moduleInstanceId}`,document.addEventListener(A.close,this._removeAllMessages)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener(A.close,this._removeAllMessages)}_closeModal(){document.querySelector(`#blog-article-comments-form-modal-${this.moduleInstanceId}`)?.close()}render(){return $`
2            <form-connector
3                ${L(this._formConnectorRef)}
4                @submit=${this._onSubmit}
5                @submitError=${this._onSubmitError}
6                id="blog-article-comment-form-connector-${this.moduleInstanceId}"
7                submit-strategy="frontApi"
8            >
9                <form
10                    id="blog-article-comment-form-${this.moduleInstanceId}"
11                    action="${this._blogArticleCommentFormHttpUrl.getBlogArticleCommentsUrl(this.blogArticleId)}"
12                    method="post"
13                >
14                    ${this.getSlot("form")}
15                </form>
16            </form-connector>
17        `}}f([_({type:Number,attribute:"module-instance-id"})],c.prototype,"moduleInstanceId");f([_({type:Number,attribute:"blog-article-id"})],c.prototype,"blogArticleId");class x extends N{constructor({blogArticleCommentFormService:e}){super(),this.moduleName=l.api,this.#e=e}#e;addComment(e,t){return this.#e.addComment(e,t)}}class C extends F{constructor({httpApi:e,settingsApi:t,localeOptions:s}){super(e),this.moduleName=l.httpApi,this.#e=new M(t,s)}#e;addComment(e,t){const s=this.#e.getBlogArticleCommentsUrl(e);return this.fetch({url:s,data:t,method:T.post},{decorators:[p.status,p.flashMessages]})}}class k extends O{#e;#t;#s;constructor({httpApi:e,settingsApi:t,localeOptions:s,flashMessengerApi:o,translationApi:r}){super(),this.#e=new C({httpApi:e,settingsApi:t,localeOptions:s}),this.#t=o,this.#s=r}async addComment(e,t){try{const{data:s}=await this.#e.addComment(e,t).response,{flashMessages:o,status:r}=s;return this._displayFlashMessages(o),r}catch(s){return this._displayErrorFlashMessages(s),m.failed}}_displayFlashMessages(e){e&&this.#t.parseAndAddFlashMessages(e,n
17)}_displayErrorFlashMessages(e){const t=e.request,s=E.getMessageBasedOnStatusCode(t.status,this.#s);this.#t.addFlashMessage({content:s,type:h.error,isCloseable:!1},n)}}class X extends I{static{this.featureName=l.feature}static{this.dependencies=[R.feature]}init(){const e=this.getApiSync(y),t=this.getApiSync(S.api),s=this.getApiSync(u.api),o=this.getApiSync(g.api),r=new C({httpApi:e,settingsApi:t}),i=new k({httpApi:e,settingsApi:t,flashMessengerApi:s,translationApi:o}),b=new x({blogArticleCommentFormService:i});return{cores:[{type:B,instance:[c]},{type:v.api,instance:[r,b]}]}}}export{X as BlogArticleCommentFormInitializer};

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.