1import{Qa as b}from"./chunk-BKNJGD3W.js";import{A as u,D as d,N as m,Oc as o,Sc as n,T as C,Tc as O,W as f,c as p,d as h,h as k,qa as g,y as l}from"./chunk-YOURNG5N.js";import{h as r}from"./chunk-P4CXXLFV.js";var D=(()=>{let i=class i{constructor(t,e,a){r(this,"http");r(this,"authGuard");r(this,"platformId");r(this,"contentOfferpackSubject");r(this,"offerpack");r(this,"unsubscribe$",new p);r(this,"offerpackCountBroadcastChannel");r(this,"partnerid","");this.http=t,this.authGuard=e,this.platformId=a,this.contentOfferpackSubject=new h(null),this.offerpack={},this.offerpack.packlist=[],this.initData()}ngOnDestroy(){var t;this.unsubscribe$.next(!0),this.unsubscribe$.complete(),(t=this.offerpackCountBroadcastChannel)==null||t.close()}async initData(){this.authGuard.getPartnerid$.pipe(m(this.unsubscribe$)).subscribe(t=>{var e;(t==null?void 0:t.length)>0&&(this.partnerid!==t&&((e=this.offerpackCountBroadcastChannel)==null||e.close(),this.offerpackCountBroadcastChannel=void 0),this.partnerid=t,this.initfromlocalstorage())})}inOfferpack(t){var e;return((e=this.offerpack.packlist)==null?void 0:e.find(a=>a.offerid===t))!==void 0}async addOffer(t){var e;((e=t.offerid)==null?void 0:e.length)>0&&(this.offerpack.packlist.push(t),this.emitOfferpackCount(),window.localStorage.setItem(this.partnerid+"_offerpack",JSON.stringify(this.offerpack)))}async removeOffer(t){if((t==null?void 0:t.length)>0){for(let e=0;e<this.offerpack.packlist.length;e++)this.offerpack.packlist[e].offerid===t&&(this.offerpack.packlist.splice(e,1),e=this.offerpack.packlist.length);this.emitOfferpackCount(),window.localStorage.setItem(this.partnerid+"_offerpack",JSON.stringify(this.offerpack))}}async initfromlocalstorage(){if(o(this.platformId)){let t=window.localStorage.getItem(this.partnerid+"_offerpack");if((t==null?void 0:t.length)>0){try{this.offerpack=JSON.parse(t),!this.offerpack.packlist&&!this.offerpack.packid&&this.resetOfferpackList()}catch{this.resetOfferpackList()}this.emitOfferpackCount()}else this.resetOfferpackList()}}async resetOfferpackList(){this.offerpack={},this.offerpack.packlist=[],this.offerpack.packid="",window.localStorage.setItem(this.partnerid+"_offerpack",JSON.stringify(this.offerpack)),this.emitOfferpackCount()}async setOfferpackdata(t){this.offerpack=t,window.localStorage.setItem(this.partnerid+"_offerpack",JSON.stringify(this.offerpack)),this.emitOfferpackCount()}async setOfferpackid(t){this.offerpack.packid=t,window.localStorage.setItem(this.partnerid+"_offerpack",JSON.stringify(this.offerpack))}emitOfferpackCount(){var e;let t=((e=this.offerpack.packlist)==null?void 0:e.length)||0;this.contentOfferpackSubject.next(t),this.broadcastOfferpackCount(t)}broadcastOfferpackCount(t){let e=this.getOfferpackCountBroadcastChannel();e&&e.postMessage({type:"offerpack-count",partnerid:this.partnerid,count:t})}getOfferpackCountBroadcastChannel(){return!o(this.platformId)||typeof BroadcastChannel>"u"?null:(this.offerpackCountBroadcastChannel||(this.offerpackCountBroadcastChannel=new BroadcastChannel(this.getOfferpackCountChannelName()),this.offerpackCountBroadcastChannel.onmessage=t=>{var e,a;((e=t==null?void 0:t.data)==null?void 0:e.type)==="get-offerpack-count"&&this.broadcastOfferpackCount(((a=this.offerpack.packlist)==null?void 0:a.length)||0)}),this.offerpackCountBroadcastChannel)}getOfferpackCountChannelName(){return"_offerpack_count_"+this.partnerid}request(t,e,a){let c={headers:new n({"Content-Type":"application/json","ngsw-bypass":""})};return(a==null?void 0:a.length)>0&&(c={headers:new n({"Content-Type":"application/json","x-access-token":a,"ngsw-bypass":"","x-access-partnerid":this.partnerid})}),this.http.post("api/offerpack/"+e,{body:t},c).pipe(u(100),d(),l(y=>k(y)))}getofferpack(){return this.offerpack}getofferpackListe(){return this.offerpack.packlist}getofferpacksid(){return this.offerpack.packid}get offerpack$(){return this.contentOfferpackSubject.asObservable()}};r(i,"\u0275fac",function(e){return new(e||i)(f(O),f(b),f(g))}),r(i,"\u0275prov",C({token:i,factory:i.\u0275fac,providedIn:"root"}));let s=i;return s})();export{D as a}; 2//# sourceMappingURL=chunk-KVTY4NSX.js.map
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.