!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("HypoContainer"),require("mobx"),require("ElcServiceBus"),require("react"),require("ELCLogger"),require("HttpTransport")):"function"==typeof define&&define.amd?define(["HypoContainer","mobx","ElcServiceBus","react","ELCLogger","HttpTransport"],t):"object"==typeof exports?exports["pg-service-inventory"]=t(require("HypoContainer"),require("mobx"),require("ElcServiceBus"),require("react"),require("ELCLogger"),require("HttpTransport")):e["pg-service-inventory"]=t(e.ElcRuntime.HypoContainer,e.ElcRuntime.mobx,e.ElcServiceBus,e.ElcRuntime.React,e.ElcRuntime.ELCLogger,e.ElcRuntime.HttpTransport)}(self,((e,t,r,n,o,s)=>(()=>{"use strict";var i={"./node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js":(e,t,r)=>{var n=r("./node_modules/react-is/index.js"),o={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},s={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},i={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},c={};function a(e){return n.isMemo(e)?i:c[e.$$typeof]||o}c[n.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},c[n.Memo]=i;var l=Object.defineProperty,u=Object.getOwnPropertyNames,p=Object.getOwnPropertySymbols,d=Object.getOwnPropertyDescriptor,h=Object.getPrototypeOf,y=Object.prototype;e.exports=function e(t,r,n){if("string"!=typeof r){if(y){var o=h(r);o&&o!==y&&e(t,o,n)}var i=u(r);p&&(i=i.concat(p(r)));for(var c=a(t),f=a(r),v=0;v{var r="function"==typeof Symbol&&Symbol.for,n=r?Symbol.for("react.element"):60103,o=r?Symbol.for("react.portal"):60106,s=r?Symbol.for("react.fragment"):60107,i=r?Symbol.for("react.strict_mode"):60108,c=r?Symbol.for("react.profiler"):60114,a=r?Symbol.for("react.provider"):60109,l=r?Symbol.for("react.context"):60110,u=r?Symbol.for("react.async_mode"):60111,p=r?Symbol.for("react.concurrent_mode"):60111,d=r?Symbol.for("react.forward_ref"):60112,h=r?Symbol.for("react.suspense"):60113,y=r?Symbol.for("react.suspense_list"):60120,f=r?Symbol.for("react.memo"):60115,v=r?Symbol.for("react.lazy"):60116,g=r?Symbol.for("react.block"):60121,m=r?Symbol.for("react.fundamental"):60117,b=r?Symbol.for("react.responder"):60118,w=r?Symbol.for("react.scope"):60119;function S(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case n:switch(e=e.type){case u:case p:case s:case c:case i:case h:return e;default:switch(e=e&&e.$$typeof){case l:case d:case v:case f:case a:return e;default:return t}}case o:return t}}}function P(e){return S(e)===p}t.AsyncMode=u,t.ConcurrentMode=p,t.ContextConsumer=l,t.ContextProvider=a,t.Element=n,t.ForwardRef=d,t.Fragment=s,t.Lazy=v,t.Memo=f,t.Portal=o,t.Profiler=c,t.StrictMode=i,t.Suspense=h,t.isAsyncMode=function(e){return P(e)||S(e)===u},t.isConcurrentMode=P,t.isContextConsumer=function(e){return S(e)===l},t.isContextProvider=function(e){return S(e)===a},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===n},t.isForwardRef=function(e){return S(e)===d},t.isFragment=function(e){return S(e)===s},t.isLazy=function(e){return S(e)===v},t.isMemo=function(e){return S(e)===f},t.isPortal=function(e){return S(e)===o},t.isProfiler=function(e){return S(e)===c},t.isStrictMode=function(e){return S(e)===i},t.isSuspense=function(e){return S(e)===h},t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===s||e===p||e===c||e===i||e===h||e===y||"object"==typeof e&&null!==e&&(e.$$typeof===v||e.$$typeof===f||e.$$typeof===a||e.$$typeof===l||e.$$typeof===d||e.$$typeof===m||e.$$typeof===b||e.$$typeof===w||e.$$typeof===g)},t.typeOf=S},"./node_modules/react-is/index.js":(e,t,r)=>{e.exports=r("./node_modules/react-is/cjs/react-is.production.min.js")},"@estee/elc-service-bus":e=>{e.exports=r},"@estee/elc-logging":e=>{e.exports=o},"@estee/elc-http-transport":e=>{e.exports=s},"hypo-container":t=>{t.exports=e},react:e=>{e.exports=n},mobx:e=>{e.exports=t},"./package.json":e=>{e.exports=JSON.parse('{"name":"pg-service-inventory","version":"1.7.0","description":"Perlgem Inventory","main":"./build/bundle.js","types":"./typings/services/pg-service-inventory/src/index.d.ts","repository":{"type":"git","url":"https://bitbucket.esteeonline.com/projects/STARDUST/repos/fe-pg-service-inventory.git"},"scripts":{"build":"scripts build","build:prod":"scripts build:prod","bundler:analyzer":"scripts bundler:analyzer","cz":"npm run prettyquick && git add -A && scripts cz","danger":"scripts danger","danger:ci":"scripts danger:ci","dev:server":"scripts devServer","eslint":"scripts eslint","eslint:ci":"scripts eslint:ci","pr":"yarn run build:prod && yarn run test:ci && yarn run stylelint:ci && yarn run danger:ci && yarn run eslint:ci && yarn run storybook:static","prettier":"scripts prettier","prettyquick":"pretty-quick --staged","release":"npm run build:prod && yarn run storybook:static","storybook":"scripts storybook","storybook:static":"cross-env STORYBOOK_MODE=static scripts storybook","stylelint":"scripts stylelint","stylelint:ci":"scripts stylelint:ci","test":"scripts test","test:ci":"scripts test:ci","test:diagnostic":"scripts test:diagnostic","version:snapshot":"scripts version:snapshot > versions.txt"},"author":"ELC Online","license":"All rights reserved ELC Online","peerDependencies":{"react":"*","react-dom":"*"},"dependencies":{"@estee/elc-http-transport":"^5.0.6","@estee/elc-jsonrpc-api":"^1.0.17","@estee/elc-service":"^10.0.0","@estee/elc-universal-utils":"^6.0.20","hypo-container":"^1.0.9"},"devDependencies":{"@estee/elc-scripts":"^4.4.0","@estee/elc-service-bus":"2.22.0","@storybook/addon-essentials":"^6.1.14","@testing-library/dom":"^7.28.1","@testing-library/jest-dom":"^5.11.4","@testing-library/react":"^11.1.0","@testing-library/user-event":"^13.1.6","@types/styled-components":"5.1.9","babel-loader":"^8.2.2","babel-plugin-styled-components":"1.12.0","cross-env":"^7.0.3","emotion-theming":"^11.0.0","enzyme-adapter-react-16":"^1.15.2","jest-environment-jsdom-fifteen":"^1.0.2","jest-styled-components":"7.0.4","mobx":"5.15.6","mobx-react":"6.1.4","style-loader":"^2.0.0","styled-components":"5.2.3","webpack":"4.23.1","webpack-filter-warnings-plugin":"^1.2.1"},"module":"./src/index.ts","resolutions":{"conventional-changelog":"^1.0.0"},"config":{"cz-customizable":{"config":"node_modules/@estee/elc-scripts/config/commitizen/commitizen.config.js"}},"prettier":"./node_modules/@estee/elc-scripts/config/prettier/.prettierrc.js"}')}},c={};function a(e){var t=c[e];if(void 0!==t)return t.exports;var r=c[e]={exports:{}};return i[e](r,r.exports,a),r.exports}a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var l={};return(()=>{a.r(l);var e=a("hypo-container");var t=a("mobx"),r=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,c=(e,t,n)=>t in e?r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,u=(e,t)=>{for(var r in t||(t={}))s.call(t,r)&&c(e,r,t[r]);if(o)for(var r of o(t))i.call(t,r)&&c(e,r,t[r]);return e},p=(e,t,o,s)=>{for(var i,c=s>1?void 0:s?n(t,o):t,a=e.length-1;a>=0;a--)(i=e[a])&&(c=(s?i(t,o,c):i(c))||c);return s&&c&&r(t,o,c),c};class d{constructor(e){this.config=e}updateConfig(e){this.config=u(u({},this.config),e)}}p([t.observable],d.prototype,"config",2),p([t.action],d.prototype,"updateConfig",1);var h=a("@estee/elc-service-bus"),y=Object.defineProperty,f=Object.getOwnPropertyDescriptor;class v{constructor(e){this.getInventory=e=>{return t=this,r=null,n=function*(){try{return yield this.inventoryRepository.getInventories(e)}catch(e){console.warn(e.message)}},new Promise(((e,o)=>{var s=e=>{try{c(n.next(e))}catch(e){o(e)}},i=e=>{try{c(n.throw(e))}catch(e){o(e)}},c=t=>t.done?e(t.value):Promise.resolve(t.value).then(s,i);c((n=n.apply(t,r)).next())}));var t,r,n},this.inventoryRepository=e}}((e,t,r,n)=>{for(var o,s=n>1?void 0:n?f(t,r):t,i=e.length-1;i>=0;i--)(o=e[i])&&(s=(n?o(t,r,s):o(s))||s);n&&s&&y(t,r,s)})([(0,h.queryProvider)(h.serviceQueries.GET_INVENTORY)],v.prototype,"getInventory",2);const g=Object.freeze({1:"Active",2:"Temporarily out of stock",3:"Coming Soon",4:"Do Not Display",5:"Inactive",6:"Free Promo",7:"Sold Out",8:"Pre Order"});var m=Object.defineProperty,b=Object.getOwnPropertyDescriptor,w=(e,t,r,n)=>{for(var o,s=n>1?void 0:n?b(t,r):t,i=e.length-1;i>=0;i--)(o=e[i])&&(s=(n?o(t,r,s):o(s))||s);return n&&s&&m(t,r,s),s};const S=class{constructor(){this.productId="",this.skuId=""}static fromJson(e){const t=new S;var r;t.productId=e.productId,t.skuId=e.skuId,r=e.inventoryStatus,!isNaN(Number(r))&&e.inventoryStatus in g&&(t.status=g[e.inventoryStatus]);const n=e.highVelocityQuantity;return n&&(t.highVelocityQuantity=n),t}};let P=S;w([t.observable],P.prototype,"productId",2),w([t.observable],P.prototype,"skuId",2),w([t.observable],P.prototype,"status",2),w([t.observable],P.prototype,"highVelocityQuantity",2);const O=(e,t)=>(null==t||t.skus.forEach((r=>{const n={productId:t.PRODUCT_ID.replace("PROD",""),skuId:r.PRODUCT_CODE,inventoryStatus:r.INVENTORY_STATUS,highVelocityQuantity:r.highVelocityQty};e.push(n)})),e);class I{constructor(){this.queryStack=[],this.stashedProducts=[],this.beingProcessed=[],this.processed=[],this.debounce=(e,t)=>{clearTimeout(this.debounceTimeout),this.debounceTimeout=setTimeout(e,t)},this.createQueryPromise=e=>new Promise((t=>{this.queryStack.push({productIds:e,resolver:t})})),this.resolveQueue=e=>{this.queryStack.forEach((t=>{const{resolver:r}=t;this.shouldResolve(t,e)&&r()})),this.beingProcessed=this.beingProcessed.filter((t=>!e.includes(t)))}}isProcessing(e){return e.every((e=>this.beingProcessed.includes(e)))}isStashed(e){return e.every((e=>this.stashedProducts.includes(e)))}isInProgress(e){return this.isProcessing(e)||this.isStashed(e)}removeFromProcessed(e){this.processed=this.processed.filter((t=>!e.includes(t)))}stashProducts(e){this.stashedProducts=[...this.stashedProducts,...e]}get storedIds(){return[...this.stashedProducts,...this.processed]}prepareInventoryQuery(){const e=this.stashedProducts;return this.processed=[...this.processed,...this.stashedProducts],this.stashedProducts=[],e}shouldResolve(e,t){const{productIds:r}=e;return r.every((e=>t.includes(e)))}}var T=Object.defineProperty,C=Object.getOwnPropertyDescriptor,E=(e,t,r,n)=>{for(var o,s=n>1?void 0:n?C(t,r):t,i=e.length-1;i>=0;i--)(o=e[i])&&(s=(n?o(t,r,s):o(s))||s);return n&&s&&T(t,r,s),s},k=(e,t,r)=>new Promise(((n,o)=>{var s=e=>{try{c(r.next(e))}catch(e){o(e)}},i=e=>{try{c(r.throw(e))}catch(e){o(e)}},c=e=>e.done?n(e.value):Promise.resolve(e.value).then(s,i);c((r=r.apply(e,t)).next())}));class x{constructor({inventory:e,apiSdk:t}){this.inventories=[],this.debouncedGet=()=>k(this,null,(function*(){var e;const t=this.inventoryQueryStashingService.prepareInventoryQuery();this.inventoryQueryStashingService.beingProcessed=[...this.inventoryQueryStashingService.beingProcessed,...t];try{const r=yield this.apiSdk.getInventoryItems(t);if(0!==(null==(e=r.data)?void 0:e.length)){const e=(({response:e})=>{var t,r,n;return((null==(n=null==(r=null==(t=((null==e?void 0:e.data)||[])[0])?void 0:t.result)?void 0:r.value)?void 0:n.products)||[]).reduce(O,[])})({response:r});this.setInventories(e)}}catch(e){this.inventoryQueryStashingService.removeFromProcessed(t),console.warn(new Error(e))}this.inventoryQueryStashingService.resolveQueue(t)})),this.filterInventories=e=>k(this,null,(function*(){return this.inventories.filter((t=>e.includes(t.productId)))})),this.updateInventories=e=>k(this,null,(function*(){const t=this.filterNewProductIds(e);return t.length>0?(this.inventoryQueryStashingService.stashProducts(t),this.inventoryQueryStashingService.debounce(this.debouncedGet,200),this.inventoryQueryStashingService.createQueryPromise(t)):this.inventoryQueryStashingService.isInProgress(e)?this.inventoryQueryStashingService.createQueryPromise(e):void 0})),this.getInventories=e=>k(this,null,(function*(){return yield this.updateInventories(e),this.filterInventories(e)})),this.setInventories=e=>{const t=e.map((e=>P.fromJson(e)));this.inventories=Array.from([...this.inventories,...t].reduce(((e,t)=>e.set(t.skuId,t)),new Map).values())},this.inventory=e,this.apiSdk=t,this.inventoryQueryStashingService=new I}filterNewProductIds(e){const t=this.inventoryQueryStashingService.storedIds;return e.filter((e=>!t.includes(e)))}}E([t.observable],x.prototype,"inventory",2),E([t.observable],x.prototype,"inventories",2),E([t.action],x.prototype,"debouncedGet",2),E([t.action],x.prototype,"setInventories",2);var R=a("react"),j=a.n(R);function _(e,t){if(null==e)return{};var r,n,o={},s=Object.keys(e);for(n=0;n=0||(o[r]=e[r]);return o}function N(){return N=Object.assign||function(e){for(var t=1;t{function t(e){document.cookie=`${e}=; Max-Age=-99999999;`}function r(e,t,r){let n="";if(r){n=`; expires=${("number"==typeof r?new Date(Date.now()+24*r*60*60*1e3):r).toUTCString()}`}document.cookie=`${e}=${t||""}${n};path=/`}function n(e){const t=`${e}=`,r=document.cookie.split(";");for(let e=0;e{const n=o(e);r!==n&&(r=n,t(n))}),2e3)}})(oe||(oe={}));var se=a("@estee/elc-logging");function ie(){return ne.ServiceRegistry||{}}ne.ServiceRegistry=ne.ServiceRegistry||{};class ce{constructor(e,t,r){this.name=e,this.version=t,this.serviceInitializer=r,this.componentsRegistry={},this.cachedComponentsRegistry={},this.isLazy=!1,this.isStarted=!1,this.views=[],this.register=e=>{ne.ServiceRegistry=ie(),ne.ServiceRegistry[this.name]=Object.assign(ne.ServiceRegistry[this.name]||{},{start:this.start,startPromise:this.startPromise,name:this.name,version:this.version,views:this.views,getView:this.getView,registerView:this.registerView,initializeService:this.initializeService,setViewInCache:this.setViewInCache,getViewFromCache:this.getViewFromCache,serviceInitializer:this.serviceInitializer,componentsRegistry:this.componentsRegistry,cachedComponentsRegistry:this.cachedComponentsRegistry,isStarted:this.isStarted,isLazy:this.isLazy},e||{})},this.getView=e=>this.componentsRegistry[e]||null,this.setViewInCache=(e,t)=>{this.cachedComponentsRegistry[e]=t},this.getViewFromCache=e=>this.cachedComponentsRegistry[e]||null,this.registerView=(e,t,r)=>{this.views.push(e),this.componentsRegistry[e]={componentName:e,component:Z(t),viewController:r}}}initializeService(e){return t=this,r=null,n=function*(){try{yield this.serviceInitializer(e),this.isStarted=!0}catch(e){this.logger.error({message:`Could not start service ${this.name}`,triggerType:se.TriggerType.render,payload:{error:e,context:{serviceRegistry:ne.ServiceRegistry}}})}},new Promise(((e,o)=>{var s=e=>{try{c(n.next(e))}catch(e){o(e)}},i=e=>{try{c(n.throw(e))}catch(e){o(e)}},c=t=>t.done?e(t.value):Promise.resolve(t.value).then(s,i);c((n=n.apply(t,r)).next())}));var t,r,n}start(e){return this.startPromise||this.isStarted||(this.logger=new se.ELCLogger({serviceName:this.name,environment:e.env||ne.env,buid:e.businessUnitId||ne.buid,serviceVersion:this.version}),this.startPromise=this.initializeService(e)),this.startPromise}}var ae=Object.getPrototypeOf,le=Reflect.get;const{name:ue,version:pe}={branchName:"release/1.7",commitHash:"4b3a174dfd4d41af30c05b4703f0923d140c79c5",version:"1.7.0",name:"pg-service-inventory"};class de extends ce{constructor(e){super(ue,pe,e)}start(e){return t=this,r=null,n=function*(){var t,r,n;return yield(t=de.prototype,r=this,n="start",le(ae(t),n,r)).call(this,e)},new Promise(((e,o)=>{var s=e=>{try{c(n.next(e))}catch(e){o(e)}},i=e=>{try{c(n.throw(e))}catch(e){o(e)}},c=t=>t.done?e(t.value):Promise.resolve(t.value).then(s,i);c((n=n.apply(t,r)).next())}));var t,r,n}}const he=1;Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;"object"==typeof self&&(self.self,self);const ye="undefined"==typeof window?a.g:window;var fe;(e=>{function t(e){document.cookie=`${e}=; Max-Age=-99999999;`}function r(e,t,r){let n="";if(r){n=`; expires=${("number"==typeof r?new Date(Date.now()+24*r*60*60*1e3):r).toUTCString()}`}document.cookie=`${e}=${t||""}${n};path=/`}function n(e){const t=`${e}=`,r=document.cookie.split(";");for(let e=0;e{const n=o(e);r!==n&&(r=n,t(n))}),2e3)}})(fe||(fe={}));var ve=(e,t,r)=>new Promise(((n,o)=>{var s=e=>{try{c(r.next(e))}catch(e){o(e)}},i=e=>{try{c(r.throw(e))}catch(e){o(e)}},c=e=>e.done?n(e.value):Promise.resolve(e.value).then(s,i);c((r=r.apply(e,t)).next())}));const ge="AuthorizationToken";class me{constructor(e,t,r){this.delete=e=>ve(this,null,(function*(){let t={data:{},reponseHeaders:{}};try{t=yield this.httpTransport.delete(e)}catch(t){this.handleError(t,"delete",e)}return t})),this.get=(e,...t)=>ve(this,[e,...t],(function*(e,{debounceInterval:t=200,bypassCache:r=!1}={}){let n={data:{},reponseHeaders:{}};try{n=yield this.httpTransport.get(e,{debounceInterval:t,bypassCache:r})}catch(t){this.handleError(t,"get",e)}return n})),this.patch=e=>ve(this,null,(function*(){let t={data:{},reponseHeaders:{}};try{t=yield this.httpTransport.patch(e)}catch(t){this.handleError(t,"patch",e)}return t})),this.post=e=>ve(this,null,(function*(){let t={data:{},reponseHeaders:{}};try{t=yield this.httpTransport.post(e)}catch(t){this.handleError(t,"post",e)}return t})),this.put=e=>ve(this,null,(function*(){let t={data:{},reponseHeaders:{}};try{t=yield this.httpTransport.put(e)}catch(t){this.handleError(t,"put",e)}return t})),this.handleError=(e,t,r)=>{this.logger.error({triggerType:se.TriggerType.api,message:`${e}`,payload:{context:{subdomain:ye.site&&ye.site.client&&ye.site.client.subdomain,originalPayload:r,requestType:t},error:e}})},this.httpTransport=e.httpTransport,this.businessUnitId=e.businessUnitId,this.logger=new se.ELCLogger({serviceName:t,serviceVersion:r})}addHeader(e){this.httpTransport.addGlobalHeaders(e)}removeHeader(e){this.httpTransport.removeGlobalHeader(e)}setBearerToken(e){e?this.addHeader({[ge]:`${e}`}):this.removeHeader(ge)}}var be=(e=>(e.GET_TOKEN_METHOD="csrf.getToken",e.PRODCAT_METHOD="prodcat",e.TRANS_GET_RPC_METHOD="trans.get",e.UPDATE_BAG_RPC_METHOD="rpc.form",e))(be||{}),we=Object.defineProperty,Se=Object.getOwnPropertySymbols,Pe=Object.prototype.hasOwnProperty,Oe=Object.prototype.propertyIsEnumerable,Ie=(e,t,r)=>t in e?we(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Te=(e,t)=>{for(var r in t||(t={}))Pe.call(t,r)&&Ie(e,r,t[r]);if(Se)for(var r of Se(t))Oe.call(t,r)&&Ie(e,r,t[r]);return e},Ce=(e,t,r)=>new Promise(((n,o)=>{var s=e=>{try{c(r.next(e))}catch(e){o(e)}},i=e=>{try{c(r.throw(e))}catch(e){o(e)}},c=e=>e.done?n(e.value):Promise.resolve(e.value).then(s,i);c((r=r.apply(e,t)).next())}));const Ee=class extends me{constructor(e,t,r){super(e,t,r),this.fetch=e=>Ce(this,[e],(function*({method:e,headers:t,body:r,url:n}){const o=n||this.generateUrl(e),s=Te(Te({},Ee.getHeaders()),t||{});return yield this.httpTransport.post({url:o,headers:s,body:r})})),this.generateUrl=e=>`${this.baseUrl+"/rpc/jsonrpc.tmpl"}?dgbmethod=${e}`,this.getCsrfToken=()=>{const e=fe.getCookie("csrftoken");return e||this.fetchCsrfToken()},this.fetchCsrfToken=()=>Ce(this,null,(function*(){var e;const t=be.GET_TOKEN_METHOD,{data:r}=yield this.fetch({method:t,body:this.formatToRPC(t,[])}),{token:n}=null==(e=null==r?void 0:r[0].result)?void 0:e.value;return n})),this.formatToRPC=(e,t={})=>{const r=[{method:e,params:t}],n=new URLSearchParams;return n.append("JSONRPC",JSON.stringify(r)),n},this.baseUrl=Ee.getBaseUrl(),this.csrfToken=this.getCsrfToken()}};let ke=Ee;ke.getHeaders=()=>{const e={"content-type":"application/x-www-form-urlencoded; charset=UTF-8"};return e},ke.getBaseUrl=()=>`${ye.location.protocol}//${ye.location.hostname}`;class xe extends ke{constructor({pgInventoryParams:e,config:t,serviceName:r,serviceVersion:n}){super(t,r,n),this.getInventoryItems=e=>{return t=this,r=null,n=function*(){const t=be.PRODCAT_METHOD,r=this.formatToRPC(t,((e,t)=>[{products:e.map((function(e){return`PROD${e}`})),product_fields:t.productFields,sku_fields:t.skuFields,bypass_datalayer:he}])(e,this.pgInventoryParams));return yield this.fetch({method:t,body:r})},new Promise(((e,o)=>{var s=e=>{try{c(n.next(e))}catch(e){o(e)}},i=e=>{try{c(n.throw(e))}catch(e){o(e)}},c=t=>t.done?e(t.value):Promise.resolve(t.value).then(s,i);c((n=n.apply(t,r)).next())}));var t,r,n},this.pgInventoryParams=e}}const{name:Re,version:je}=a("./package.json");var _e=a("@estee/elc-http-transport");const Ne=new e.Container,$e="CONFIG",De="SERVICE_BUS_CONTROLLER",Ve="INVENTORY_SERVICE",He="INVENTORY_REPOSITORY",ze="HTTP_TRANSPORT",Ae="INVENTORY_API_SDK",Le="INVENTORY_ENTITY";Ne.register($e,(e=>new d(e.config))).register(Ve,(e=>new de((t=>{var r;return r=t,Ne.config=r,e.get(De)})))).register(Le,(()=>new P)).register(He,(e=>{const t={inventory:e.get(Le),apiSdk:e.get(Ae)};return new x(t)})).register(De,(e=>new v(e.get(He)))).register(ze,(()=>new _e.HttpTransport)).register(Ae,(e=>{const{config:t={}}=e.get($e),{inventoryConfig:r={}}=t,{pgInventoryParams:n}=r,o={pgInventoryParams:n,config:{httpTransport:e.get(ze),businessUnitId:e.get($e).businessUnitId},serviceName:Re,serviceVersion:je};return new xe(o)}));const{lazyInject:qe}=(Me=Ne,{lazyInject:e=>(t,r,n)=>{const o=e||r,s=function(){const e=Me.get(o);if(!e)throw new Error(`The requested ${o} does not exists`);return e};let i=n||{};n?i.get=s:(i={get:s},Object.defineProperty(t,r,i))}});var Me;Ne.get(Ve).register(),(e=>{const t=e,{name:r}=t,n=((e,t)=>{var r={};for(var n in e)te.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&ee)for(var n of ee(e))t.indexOf(n)<0&&re.call(e,n)&&(r[n]=e[n]);return r})(t,["name"]);ne.serviceInfo=ne.serviceInfo||{},ne.serviceInfo[r]=n})({branchName:"release/1.7",commitHash:"4b3a174dfd4d41af30c05b4703f0923d140c79c5",version:"1.7.0",name:"pg-service-inventory"})})(),l})())); //# sourceMappingURL=bundle.js.map