@snabcentr/common-lib 2.16.1 → 2.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/manifest.json +1 -1
- package/dist/release_notes.tmp +1 -1
- package/dist/sc-common-lib.js +973 -984
- package/dist/sc-common-lib.js.map +1 -1
- package/dist/sc-common-lib.umd.cjs +1 -1
- package/dist/sc-common-lib.umd.cjs.map +1 -1
- package/dist/src/auth/classes/detailed-jwt-payload.d.ts.map +1 -1
- package/dist/src/catalog/providers/client-price-template-provider.d.ts.map +1 -1
- package/dist/src/catalog/providers/client-product-category-data-provider.d.ts.map +1 -1
- package/dist/src/catalog/providers/price-template-provider.d.ts.map +1 -1
- package/dist/src/catalog/providers/pricing-role-provider.d.ts.map +1 -1
- package/dist/src/catalog/providers/product-category-data-provider.d.ts.map +1 -1
- package/dist/src/catalog/providers/properties-provider.d.ts.map +1 -1
- package/dist/src/catalog/providers/template-product-category-data-provider.d.ts.map +1 -1
- package/dist/src/clients/providers/client-data-provider.d.ts.map +1 -1
- package/dist/src/http/classes/http-cached-requester.d.ts +4 -3
- package/dist/src/http/classes/http-cached-requester.d.ts.map +1 -1
- package/dist/src/http/classes/http-requester.d.ts +22 -2
- package/dist/src/http/classes/http-requester.d.ts.map +1 -1
- package/dist/src/http/types/http-request-params.d.ts +5 -0
- package/dist/src/http/types/http-request-params.d.ts.map +1 -0
- package/dist/src/http/types/index.d.ts +1 -0
- package/dist/src/http/types/index.d.ts.map +1 -1
- package/dist/src/i18n/helpers/pluralize.d.ts.map +1 -1
- package/dist/src/offers/providers/offers-data-provider.d.ts.map +1 -1
- package/dist/src/orders/classes/order-item.d.ts +1 -1
- package/dist/src/orders/classes/order-item.d.ts.map +1 -1
- package/dist/src/orders/classes/orders-list-filters.d.ts.map +1 -1
- package/dist/src/orders/providers/orders-data-provider.d.ts.map +1 -1
- package/dist/src/pagination/providers/base-pagination-provider.d.ts +13 -0
- package/dist/src/pagination/providers/base-pagination-provider.d.ts.map +1 -1
- package/dist/src/price-analyze/providers/price-analyze-provider.d.ts.map +1 -1
- package/dist/src/system/providers/preferences-storage-provider.d.ts.map +1 -1
- package/dist/src/system/providers/typed-instance-factory.d.ts +9 -0
- package/dist/src/system/providers/typed-instance-factory.d.ts.map +1 -1
- package/dist/src/table-data/classes/filter-item.d.ts.map +1 -1
- package/dist/src/user-regions/providers/user-region-provider.d.ts.map +1 -1
- package/package.json +14 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(c,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("jwt-decode"),require("lodash-es"),require("ts-case-convert"),require("pinia"),require("vue"),require("date-fns"),require("axios")):typeof define=="function"&&define.amd?define(["exports","jwt-decode","lodash-es","ts-case-convert","pinia","vue","date-fns","axios"],d):(c=typeof globalThis<"u"?globalThis:c||self,d(c["SC Common Lib"]={},c["jwt-decode"],c["lodash-es"],c["ts-case-convert"],c.pinia,c.vue,c["date-fns"],c.axios))})(this,function(c,d,u,fe,J,m,g,Sr){"use strict";var ei=Object.defineProperty;var ri=(c,d,u)=>d in c?ei(c,d,{enumerable:!0,configurable:!0,writable:!0,value:u}):c[d]=u;var i=(c,d,u)=>ri(c,typeof d!="symbol"?d+"":d,u);class B{constructor(r){i(this,"exp",0);i(this,"iat",0);i(this,"authTime",0);i(this,"jti","");i(this,"iss","");i(this,"aud",[]);i(this,"sub","");i(this,"typ","Bearer");i(this,"azp","");i(this,"sid","");i(this,"acr","");i(this,"allowedOrigins",[]);i(this,"realmAccess",{roles:[]});i(this,"resourceAccess",{});i(this,"scope","");i(this,"emailVerified",!1);i(this,"name","");i(this,"guid","");i(this,"preferredUsername","");i(this,"givenName","");i(this,"email","");u.merge(this,r)}static getJwtPayload(r){const e=d.jwtDecode(r),t=new B(fe.objectToCamel(e));return t.resourceAccess=e.resource_access,t}}class gt extends B{constructor(e){super(e);i(this,"familyName");i(this,"middleName");i(this,"locale");i(this,"phoneNumber");i(this,"phoneNumberVerified");i(this,"address");u.merge(this,e)}static getJwtPayload(e){return new B(fe.objectToCamel(d.jwtDecode(e)))}}class Tr{constructor(r){i(this,"phone");i(this,"tablet");i(this,"laptop");this.phone=(r==null?void 0:r.phone)??360,this.tablet=(r==null?void 0:r.tablet)??600,this.laptop=(r==null?void 0:r.laptop)??1024}}class $r{constructor(r){i(this,"portalApiUrl");i(this,"mediaUrl");i(this,"responseDataCacheTimeout");this.portalApiUrl=(r==null?void 0:r.portalApiUrl)??"",this.mediaUrl=(r==null?void 0:r.mediaUrl)??"",this.responseDataCacheTimeout=(r==null?void 0:r.responseDataCacheTimeout)??3*60*60}}class br{constructor(r){i(this,"dsn");i(this,"environment");i(this,"ignoreErrors");i(this,"trace");i(this,"replay");i(this,"additionalParams");var e,t,s,o;this.dsn=(r==null?void 0:r.dsn)??"",this.environment=(r==null?void 0:r.environment)??"production",this.ignoreErrors=(r==null?void 0:r.ignoreErrors)??[/Network\s{1,3}Error/,/Request\s{1,3}aborted/,/Request\s{1,3}failed\s{1,3}with\s{1,3}status\s{1,3}code\s{1,3}(401|403|404|422)/],this.trace={allowedTargets:((e=r==null?void 0:r.trace)==null?void 0:e.allowedTargets)??[/^\//],sampleRate:((t=r==null?void 0:r.trace)==null?void 0:t.sampleRate)??0},this.replay={replaysOnErrorSampleRate:((s=r==null?void 0:r.replay)==null?void 0:s.replaysOnErrorSampleRate)??0,replaysSessionSampleRate:((o=r==null?void 0:r.replay)==null?void 0:o.replaysSessionSampleRate)??0},this.additionalParams=(r==null?void 0:r.additionalParams)??{}}}class dr{constructor(r){i(this,"broadcaster");i(this,"key");i(this,"wsHost");i(this,"wsPort");i(this,"wssPort");i(this,"forceTLS");i(this,"enabledTransports");this.broadcaster=r.broadcaster??"reverb",this.key=r.key??"",this.wsHost=r.wsHost??"",this.wsPort=r.wsPort??8080,this.wssPort=r.wssPort??8080,this.forceTLS=r.forceTLS??!1,this.enabledTransports=r.enabledTransports??["wss"]}}class Ir{constructor(r){i(this,"environment");i(this,"devMode");i(this,"http");i(this,"deviceTypeByResolution");i(this,"sentry");i(this,"tableDefaultHeightCoefficient");i(this,"urls");i(this,"websocket");i(this,"dateFormats");var e,t,s;this.environment=(r==null?void 0:r.environment)??"production",this.devMode=(r==null?void 0:r.devMode)??{},this.http=new $r(r==null?void 0:r.http),this.deviceTypeByResolution=new Tr(r==null?void 0:r.deviceTypeByResolution),this.sentry=new br({environment:this.environment,...r==null?void 0:r.sentry}),this.tableDefaultHeightCoefficient=(r==null?void 0:r.tableDefaultHeightCoefficient)??.7,this.urls=r==null?void 0:r.urls,this.websocket=r!=null&&r.websocket?new dr(r.websocket):void 0,this.dateFormats={api:((e=r==null?void 0:r.dateFormats)==null?void 0:e.api)??"yyyy-MM-dd HH:mm:ss",uiDate:((t=r==null?void 0:r.dateFormats)==null?void 0:t.uiDate)??"dd.MM.yyyy",uiDateWithTime:((s=r==null?void 0:r.dateFormats)==null?void 0:s.uiDateWithTime)??"dd.MM.yyyy HH:mm"}}}const b=J.defineStore("common.config",()=>{const n=m.ref(new Ir);return{config:n,getConfig:()=>n.value,setConfig:t=>{n.value=u.merge(n.value,t)}}});class ye{static getActualDataFromStorage(r){if(!this.isLocalStorageAvailable())return;let e=null;try{e=localStorage.getItem(r)}catch{return}if(e)try{const t=JSON.parse(e);if(!t.availableFor||g.isAfter(g.parseISO(t.availableFor)||g.startOfToday(),new Date)){if(u.isNil(t.data)||u.isEmpty(t.data))throw new Error("Data is empty");return t.data}}catch{try{localStorage.removeItem(r)}catch{}}}static saveActualDataToStorage(r,e,t){if(this.isLocalStorageAvailable())try{if(u.isNil(e)||u.isEmpty(e))throw new Error("Data is empty");const s=JSON.stringify({availableFor:t,data:e});localStorage.setItem(r,s)}catch(s){if(s instanceof DOMException&&s.code===DOMException.QUOTA_EXCEEDED_ERR){this.clearOldData();try{const o=JSON.stringify({availableFor:t,data:e});localStorage.setItem(r,o)}catch{}}else try{localStorage.removeItem(r)}catch{}}}static isLocalStorageAvailable(){try{const r="__localStorage_test__";return localStorage.setItem(r,"test"),localStorage.removeItem(r),!0}catch{return!1}}static clearOldData(){try{const r=[];for(let e=0;e<localStorage.length;e++){const t=localStorage.key(e);if(t)try{const s=localStorage.getItem(t);if(s){const o=JSON.parse(s);o.availableFor&&!g.isAfter(g.parseISO(o.availableFor)||g.startOfToday(),new Date)&&r.push(t)}}catch{r.push(t)}}r.forEach(e=>{try{localStorage.removeItem(e)}catch{}})}catch{}}}function kr(n){try{const r=B.getJwtPayload(n);return new Date(r.exp*1e3)}catch{return}}const re=J.defineStore("common.auth_state_private",()=>{const n=m.ref((()=>{var h;const o=ye.getActualDataFromStorage("sc.token");if(o)return Promise.resolve(o);const l=(h=b().config.devMode)==null?void 0:h.initAuthBearerToken;return l?Promise.resolve(l):void 0})()),r=m.ref(void 0),e=m.ref(void 0),t=m.markRaw(new Map);function s(){e.value=void 0,u.isNil(n.value)||n.value.then(o=>{const l=B.getJwtPayload(o);e.value=l.exp*1e3>Date.now()?u.mapValues(l.resourceAccess,h=>(h==null?void 0:h.roles)??[]):void 0}).catch(u.noop)}return{jwtToken:n,jwtTokenUpdater:r,userPermissions:e,userPermissionsComputedRefs:t,recalculateUserPermissions:s}}),Ae=J.defineStore("common.auth_state",()=>{const n=m.computed(()=>{const o=re();if(u.isNil(o.jwtToken)&&!u.isNil(o.jwtTokenUpdater)){const l=o.jwtTokenUpdater();o.jwtToken=l,l.then(h=>{o.jwtToken=Promise.resolve(h),ye.saveActualDataToStorage("sc.token",h,kr(h)),o.recalculateUserPermissions()}).catch(u.noop)}return o.jwtToken});function r(o){re().jwtTokenUpdater=o}function e(o){const l=re();l.jwtToken=Promise.resolve(o),ye.saveActualDataToStorage("sc.token",o,kr(o)),l.recalculateUserPermissions()}function t(){const o=re();o.jwtToken=void 0,o.userPermissions=void 0,ye.saveActualDataToStorage("sc.token",void 0)}function s(o){const l=re();!u.isNil(l.jwtToken)&&u.isNil(l.userPermissions)&&l.jwtToken.then(C=>{const v=B.getJwtPayload(C);l.userPermissions=v.exp*1e3>Date.now()?u.mapValues(v.resourceAccess,R=>(R==null?void 0:R.roles)??[]):void 0}).catch(u.noop);const h=u.isArray(o)?o.join(" && "):o;if(l.userPermissionsComputedRefs.has(h))return l.userPermissionsComputedRefs.get(h);const f=m.computed(()=>{const C=v=>{var me;const R=u.split(v,".");if(R.length<2)return!1;const[Re,De]=R,ge=(me=re().userPermissions)==null?void 0:me[Re];return u.isArray(ge)&&ge.includes(De)};return u.isArray(o)?u.every(o,v=>C(v)):C(o)});return l.userPermissionsComputedRefs.set(h,f),f}return{jwtToken:n,setJwtTokenUpdater:r,setJwtToken:e,invalidateJwtToken:t,hasUserPermission:s}});class M{constructor(r,e){i(this,"id");i(this,"guid");this.id=r==null?void 0:r.id,u.isNil(this.id)&&(u.isNil(e)?typeof(r==null?void 0:r.id)=="number"?this.id=-1:typeof(r==null?void 0:r.id)=="string"&&(this.id=""):this.id=e),this.guid=(r==null?void 0:r.guid)??""}isNewRec(){return typeof this.id=="number"?this.id===-1:typeof this.id=="string"?this.id==="":u.isNil(this.id)}}class T extends M{constructor(e){super(e);i(this,"name","");this.name=(e==null?void 0:e.name)??""}}class I extends T{constructor(e){super(e);i(this,"type");i(this,"isActive");this.type=e==null?void 0:e.type,this.isActive=(e==null?void 0:e.isActive)??!0}}class Or extends T{constructor(e){super(e);i(this,"costCoefficient");i(this,"isLowPriceAllowed");i(this,"publishedAt");i(this,"description");i(this,"percent");i(this,"owner");i(this,"deletedAt");this.costCoefficient=(e==null?void 0:e.costCoefficient)??0,this.isLowPriceAllowed=(e==null?void 0:e.isLowPriceAllowed)??!1,this.publishedAt=u.isString(e==null?void 0:e.publishedAt)?g.parseISO(e.publishedAt):e==null?void 0:e.publishedAt,this.description=(e==null?void 0:e.description)??void 0,this.percent=(e==null?void 0:e.percent)??0,this.owner=new I(e==null?void 0:e.owner),this.deletedAt=u.isString(e==null?void 0:e.deletedAt)?g.parseISO(e.deletedAt):e==null?void 0:e.deletedAt}}class Fe extends T{constructor(e){super(e);i(this,"updatedAt");this.updatedAt=u.isString(e==null?void 0:e.updatedAt)?g.parseISO(e.updatedAt):e==null?void 0:e.updatedAt}}class V extends Fe{constructor(e){super(e);i(this,"description");i(this,"createdAt");i(this,"owner");this.description=(e==null?void 0:e.description)??"",this.createdAt=u.isString(e==null?void 0:e.createdAt)?g.parseISO(e.createdAt):(e==null?void 0:e.createdAt)??new Date,this.owner=e!=null&&e.owner?new I(e.owner):void 0}}var Ge=(n=>(n.K0="k0",n.K1="k1",n.K2="k2",n.K3="k3",n.K4="k4",n.Retail="retail",n))(Ge||{});class a extends T{constructor(e){super(e);i(this,"slug");i(this,"description");this.description=e==null?void 0:e.description,this.slug=e==null?void 0:e.slug}}class we extends a{static getRetailPriceCoefficient(){return{id:-2,slug:Ge.Retail,name:"Розн. цена",guid:"",isNewRec:u.constant(!0)}}}class Se{constructor(r){i(this,"coefficient");i(this,"value");i(this,"cost");i(this,"percent");i(this,"readOnly");this.coefficient=new we(r==null?void 0:r.coefficient),this.value=(r==null?void 0:r.value)??0,this.cost=(r==null?void 0:r.cost)??0,this.percent=(r==null?void 0:r.percent)??0,this.readOnly=(r==null?void 0:r.readOnly)??!0}}class We{constructor(r){i(this,"lat");i(this,"long");this.lat=(r==null?void 0:r.lat)??0,this.long=(r==null?void 0:r.long)??0}}class q extends a{}class te extends a{constructor(e){var t;super(e);i(this,"address");i(this,"isMain");i(this,"deliveryTypes");i(this,"regions");i(this,"coordinates");this.address=(e==null?void 0:e.address)??"",this.isMain=(e==null?void 0:e.isMain)??!1,this.deliveryTypes=((t=e==null?void 0:e.deliveryTypes)==null?void 0:t.map(s=>new q(s)))??[],this.regions=(e==null?void 0:e.regions)??[],this.coordinates=new We(e==null?void 0:e.coordinates)}}class Lr{constructor(r){i(this,"warehouse");i(this,"count");this.warehouse=new te(r==null?void 0:r.warehouse),this.count=(r==null?void 0:r.count)??0}}class L extends T{constructor(e){super(e);i(this,"signature","");i(this,"code");i(this,"symbol","");i(this,"precision");e&&(this.signature=e.signature??"",this.code=e.code,this.symbol=e.symbol??"",this.precision=e.precision)}}class ze extends T{constructor(e){super(e);i(this,"slug","");i(this,"description");i(this,"isSquare",!1);i(this,"isLinear",!1);e&&(this.slug=e.slug??"",this.description=e.description,this.isSquare=e.isSquare??!1,this.isLinear=e.isLinear??!1)}}class ie extends T{constructor(e){super(e);i(this,"code","");this.code=(e==null?void 0:e.code)??""}}class Je extends ie{constructor(e){super(e);i(this,"slug");i(this,"type");this.slug=(e==null?void 0:e.slug)??""}}class _r extends Je{constructor(e){super(e);i(this,"isHidden");this.isHidden=(e==null?void 0:e.isHidden)??!1}}class qr{constructor(r,e){i(this,"image");i(this,"preview");i(this,"isDefault");this.image=`${e??""}${r.image}`,this.preview=`${e??""}${r.preview}`,this.isDefault=r.isDefault}}class Te extends Je{constructor(e){super(e);i(this,"isPrimary");this.isPrimary=(e==null?void 0:e.isPrimary)??!1}}class k extends _r{constructor(e){var s,o,l,h;super(e);i(this,"supplierSku");i(this,"unit");i(this,"pack");i(this,"minCount");i(this,"currency");i(this,"cost");i(this,"costRub");i(this,"costDate");i(this,"onOrder");i(this,"stockCount");i(this,"category");i(this,"categories");i(this,"images");i(this,"properties");i(this,"retailCost");i(this,"retailCostRub");i(this,"priceCoefficients");this.supplierSku=e==null?void 0:e.supplierSku,this.unit=e!=null&&e.unit?new ze(e.unit):new ze,this.pack=e==null?void 0:e.pack,this.minCount=e==null?void 0:e.minCount,this.currency=e!=null&&e.currency?new L(e.currency):new L,this.cost=(e==null?void 0:e.cost)??0,this.costRub=(e==null?void 0:e.costRub)??0,this.costDate=u.isString(e==null?void 0:e.costDate)?g.parseISO(e.costDate):e==null?void 0:e.costDate,this.onOrder=(e==null?void 0:e.onOrder)??!1,this.stockCount=((s=e==null?void 0:e.stockCount)==null?void 0:s.map(f=>new Lr(f)))??[],this.type="product";const t=(e==null?void 0:e.category)??((o=e==null?void 0:e.categories)==null?void 0:o.find(f=>f.isPrimary));t&&(this.category=new Te({...t,isPrimary:!0}),this.categories=[this.category]),e!=null&&e.categories&&(this.categories=e.categories.map(f=>new Te(f))),this.images=((l=e==null?void 0:e.images)==null?void 0:l.map(f=>new qr(f,b().config.http.mediaUrl)))??[],this.properties=(e==null?void 0:e.properties)??{},this.retailCost=e==null?void 0:e.retailCost,this.retailCostRub=e==null?void 0:e.retailCostRub,this.priceCoefficients=((h=e==null?void 0:e.priceCoefficients)==null?void 0:h.map(f=>new Se(f)))??[],e&&"codeNumber"in e&&!e.code&&(this.code=e==null?void 0:e.codeNumber)}getIsMeasurable(){return this.unit.isLinear||this.unit.isSquare}getRetailCost(){return this.retailCost??this.cost}getRetailCostRub(){return this.retailCostRub??this.costRub}}var $e=(n=>(n.Discount="discount",n.PriceTemplate="price_template",n.ClientPrice="client_price",n.Product="product",n))($e||{});class j extends k{constructor(e){super(e);i(this,"costCoefficient");i(this,"costSource");i(this,"discount");i(this,"priceTemplate");i(this,"isPreviouslyOrdered");i(this,"isRequired");i(this,"isFavorite");this.costCoefficient=(e==null?void 0:e.costCoefficient)??0,this.costSource=(e==null?void 0:e.costSource)??$e.Product,this.discount=e!=null&&e.discount?new Or(e.discount):void 0,this.priceTemplate=e!=null&&e.priceTemplate?new V(e.priceTemplate):void 0,this.isPreviouslyOrdered=e==null?void 0:e.isPreviouslyOrdered,this.isRequired=e==null?void 0:e.isRequired,this.isFavorite=e==null?void 0:e.isFavorite}}class se extends Te{constructor(e){super(e);i(this,"isHidden");i(this,"parentCategoryId");i(this,"properties");i(this,"currencyRates");this.isHidden=(e==null?void 0:e.isHidden)??!1,this.parentCategoryId=e==null?void 0:e.parentCategoryId,this.properties=e==null?void 0:e.properties,this.type="category",this.currencyRates=e!=null&&e.currencyRates?Object.fromEntries(Object.entries(e.currencyRates).map(([t,s])=>[u.toUpper(t),s])):void 0}}class Ve extends M{constructor(e){super(e);i(this,"category");i(this,"product");i(this,"quantity");i(this,"currency");i(this,"marker");i(this,"height");i(this,"length");i(this,"width");i(this,"configurator");i(this,"configuratorParams");i(this,"isAdditionalSale");i(this,"creator");i(this,"isRemoved");i(this,"ord");i(this,"onOrder");i(this,"originalId");i(this,"replacementId");this.product=new j(e.product),this.quantity=e.quantity??0,this.marker=e.marker,this.category=e.category??new se,this.currency=e.currency?new L(e.currency):void 0,this.height=e.height,this.length=e.length,this.width=e.width,this.configurator=e.configurator,this.configuratorParams=e.configuratorParams&&u.cloneDeep(e.configuratorParams),this.isAdditionalSale=e.isAdditionalSale,this.creator=e.creator&&new I(e.creator),this.isRemoved=e.isRemoved,this.ord=e.ord,this.onOrder=e.onOrder,this.originalId=e.originalId,this.replacementId=e.replacementId}}let Nr=class extends Ve{constructor(e){super(e);i(this,"cost");i(this,"costOne");i(this,"costOneRub");i(this,"costRub");i(this,"logicGroupId");i(this,"salesDirection");i(this,"specificationImgUrl");i(this,"sawing");i(this,"currency");this.cost=e.cost,this.costOne=e.costOne,this.costOneRub=e.costOneRub,this.costRub=e.costRub,this.logicGroupId=e.logicGroupId,this.salesDirection=e.salesDirection,this.specificationImgUrl=e.specificationImgUrl,this.sawing=u.isArray(e.sawing)?e.sawing:e.sawing?[e.sawing]:void 0,this.currency=new L(e.currency)}};class ne{constructor(r){i(this,"items");i(this,"resultSum");i(this,"directionsSum");this.items=r.items.map(e=>new Nr(e)),this.resultSum=r.resultSum,this.directionsSum=r.directionsSum}}class be{static simpleInstanceInitializer(r){return new r}static instanceInitializer(r,e){return new r(e)}}const P=class P{constructor(){i(this,"httpClient");i(this,"baseUrl",`${b().config.http.portalApiUrl}/api`);i(this,"errorResponseHandler",u.noop);i(this,"interceptorIds",{request:{},response:{}});i(this,"setBaseUrlRequestInterceptor",r=>(r.baseURL=this.baseUrl,r));i(this,"authRequestInterceptor",async r=>{let e;return u.isNil(Ae().jwtToken)||(e=await Ae().jwtToken),e&&r.headers.set("Authorization",`Bearer ${e}`),r});i(this,"userRequestHooksInterceptor",async r=>P.requestHooks.reduce(async(e,t)=>t(await e),Promise.resolve(r)));i(this,"dataConverterRequestInterceptor",r=>(r.method&&(r.method==="get"&&r.params&&(r.params=fe.objectToSnake(r.params)),["put","patch","post"].includes(u.toLower(r.method))&&r.data&&(r.data=fe.objectToSnake(r.data))),r));i(this,"authErrorsResponseInterceptors",r=>{var t;const e=r.rawError?(t=r.rawError)==null?void 0:t.config:void 0;return r.status===401?!e||e.__isRetryRequest?Promise.reject(r):(Ae().invalidateJwtToken(),e.__isRetryRequest=!0,this.httpClient(e)):Promise.reject(r)});i(this,"canceledResponseInterceptor",r=>{const e=r.rawError??r;if(e.name==="CanceledError"||e.code==="ERR_CANCELED")throw new Sr.CanceledError("Request canceled");return Promise.reject(r)});i(this,"userResponseHooksInterceptor",async r=>P.responseHooks.reduce(async(e,t)=>t(await e),Promise.resolve(r)));i(this,"dataConverterResponseInterceptor",r=>(r.data&&(r.data=fe.objectToCamel(r.data)),r));this.errorResponseHandler=P.defaultErrorsResponseHandler,this.httpClient=Sr.create({headers:{Accept:"application/json","Content-Type":"application/json"}}),this.interceptorIds.request.setBaseUrlRequestInterceptor=this.httpClient.interceptors.request.use(this.setBaseUrlRequestInterceptor,r=>Promise.reject(r)),this.interceptorIds.request.userRequestHooksInterceptor=this.httpClient.interceptors.request.use(this.userRequestHooksInterceptor,r=>Promise.reject(r)),this.interceptorIds.request.authRequestInterceptor=this.httpClient.interceptors.request.use(this.authRequestInterceptor,r=>Promise.reject(r)),this.interceptorIds.request.dataConverterRequestInterceptor=this.httpClient.interceptors.request.use(this.dataConverterRequestInterceptor,r=>Promise.reject(r)),this.interceptorIds.response.convertHttpErrorResponseInterceptor=this.httpClient.interceptors.response.use(r=>r,r=>P.convertHttpErrorResponse(r)),this.interceptorIds.response.canceledResponseInterceptor=this.httpClient.interceptors.response.use(r=>r,this.canceledResponseInterceptor),this.interceptorIds.response.authErrorsResponseInterceptor=this.httpClient.interceptors.response.use(r=>r,this.authErrorsResponseInterceptors),this.interceptorIds.response.dataConverterResponseInterceptor=this.httpClient.interceptors.response.use(this.dataConverterResponseInterceptor,r=>Promise.reject(r)),this.interceptorIds.response.userResponseHooksInterceptor=this.httpClient.interceptors.response.use(this.userResponseHooksInterceptor,r=>Promise.reject(r))}static setDefaultErrorsResponseHandler(r){P.defaultErrorsResponseHandler=r}static addRequestHook(r){P.requestHooks.includes(r)||P.requestHooks.push(r)}static removeRequestHook(r){const e=P.requestHooks.indexOf(r);e!==-1&&P.requestHooks.splice(e,1)}static addResponseHook(r){P.responseHooks.includes(r)||P.responseHooks.push(r)}static removeResponseHook(r){const e=P.responseHooks.indexOf(r);e!==-1&&P.responseHooks.splice(e,1)}static getInstance(r){return Object.prototype.hasOwnProperty.call(P.instances,r.name)||(P.instances[r.name]=be.simpleInstanceInitializer(r)),P.instances[r.name]}static convertHttpErrorResponse(r){var e,t;if(u.isNil(r)||!u.isNil(r.request)||!u.isNil(r.response)){const s=u.isNil(r)?{}:r==null?void 0:r.response;return Promise.reject({status:(s==null?void 0:s.status)??0,statusText:(s==null?void 0:s.statusText)??"Unknown",message:((e=s==null?void 0:s.data)==null?void 0:e.message)??"Unknown Error. Probably network error.",errors:(t=s==null?void 0:s.data)==null?void 0:t.errors,headers:(s==null?void 0:s.headers)??{},data:s==null?void 0:s.data,rawError:r})}return Promise.reject(r)}request(r,e=void 0,t={},s=!1){const o=this.httpClient.request(r).then(l=>e?e(l):l.data);return o.catch(l=>{(l==null?void 0:l.name)!=="CanceledError"&&this.errorResponseHandler(l,t,s)}),o}get(r,e={},t=void 0,s=!1,o=void 0){return this.request({method:"GET",url:r,params:e,signal:o},t,{},s)}getBlob(r,e={},t=void 0,s=!1){return this.request({method:"GET",url:r,params:e,responseType:"blob"},t,{},s)}patch(r,e={},t=void 0,s={},o=!1){return this.request({method:"PATCH",url:r,data:e},t,s,o)}post(r,e={},t=void 0,s={},o=!1){return this.request({method:"POST",url:r,data:e},t,s,o)}delete(r,e=void 0,t=!1){return this.request({method:"DELETE",url:r},e,{},t)}};i(P,"instances",{}),i(P,"defaultErrorsResponseHandler",u.noop),i(P,"requestHooks",[]),i(P,"responseHooks",[]);let y=P;class mt extends y{getCart(r){return this.get(`internal/clients/${r.id}/cart`,{},e=>new ne(e.data))}deleteCart(r){return this.delete(`internal/clients/${r.id}/cart`)}addCartItem(r,e,t={}){return this.patch(`internal/clients/${r.id}/cart`,{product_id:e.product.id,product_category_id:e.configurator?e.category.id:void 0,quantity:e.quantity,height:e.height,length:e.length,width:e.width,configurator:e.configurator,marker:e.marker,is_additional_sale:e.isAdditionalSale,...e.configuratorParams},s=>new ne(s.data),t)}patchCartItem(r,e,t={}){return this.patch(`internal/clients/${r.id}/cart/${e.id}`,{product_id:e.product.id,product_category_id:e.configurator?e.category.id:void 0,quantity:e.quantity,height:e.height,length:e.length,width:e.width,configurator:e.configurator,marker:e.marker,is_additional_sale:e.isAdditionalSale,...e.configuratorParams},s=>new ne(s.data),t)}deleteCartItem(r,e){return this.delete(`internal/clients/${r.id}/cart/${e.id}`,t=>new ne(t.data))}addCartItemFromCSV(r,e){return this.post(`internal/clients/${r.id}/cart/add-products-from-csv`,e,t=>new ne(t.data))}getCartItemFromCSVExample(r){return this.get(`internal/clients/${r.id}/cart/add-products-from-csv/example`,{},e=>new Blob([e.data],{type:"text/csv"}))}}var Ur=(n=>(n.m2Cost="m2Cost",n.percent="percent",n.value="value",n))(Ur||{}),Hr=(n=>(n.Unknown="unknown",n.Bool="bool",n.Integer="integer",n.Float="float",n.String="string",n.Range="range",n.Json="json",n.Object="object",n))(Hr||{}),Br=(n=>(n.Checkbox="checkbox",n.Range="range",n.Toggle="toggle",n))(Br||{});class N extends se{constructor(e){var t,s;super(e);i(this,"categories");i(this,"products");this.categories=(t=e==null?void 0:e.categories)==null?void 0:t.map(o=>new N(o)),this.products=(s=e==null?void 0:e.products)==null?void 0:s.map(o=>new k(o))}}class Ke{constructor(r){i(this,"phone");i(this,"email");this.phone=/^\d+$/.test(r.phone??"")?`+${r.phone}`:r.phone,this.email=r.email}}class O extends a{}class de extends T{constructor(e){super(e);i(this,"salesDirection");i(this,"photo");i(this,"contacts");i(this,"isDefault");i(this,"isRegionalDirector");this.salesDirection=e!=null&&e.salesDirection?new O(e.salesDirection):new O,this.photo=e==null?void 0:e.photo,this.contacts=e!=null&&e.contacts?new Ke(e.contacts):void 0,this.isDefault=(e==null?void 0:e.isDefault)??!1,this.isRegionalDirector=(e==null?void 0:e.isRegionalDirector)??!1}}class Ie extends a{}class Qe extends T{constructor(e){super(e);i(this,"description");i(this,"canChangeLowCost");i(this,"parentRoleId");this.description=e.description,this.canChangeLowCost=e.canChangeLowCost,this.parentRoleId=e.parentRoleId}}class oe extends de{constructor(e){var t;super(e);i(this,"isActive");i(this,"isSupervisor");i(this,"canDoReclamations");i(this,"createdAt");i(this,"supervisorId");i(this,"pricingRole");i(this,"curatedDirections");this.isActive=(e==null?void 0:e.isActive)??!1,this.isSupervisor=(e==null?void 0:e.isSupervisor)??!1,this.canDoReclamations=(e==null?void 0:e.canDoReclamations)??!1,this.createdAt=e==null?void 0:e.createdAt,this.supervisorId=e==null?void 0:e.supervisorId,this.pricingRole=e!=null&&e.pricingRole?new Qe(e.pricingRole):void 0,this.curatedDirections=((t=e==null?void 0:e.curatedDirections)==null?void 0:t.map(s=>new Ie(s)))??[]}}class ft extends se{constructor(e){super(e);i(this,"isDisabled");i(this,"isRequired");i(this,"isFavorite");i(this,"hidingComment");i(this,"manager");this.isDisabled=(e==null?void 0:e.isDisabled)??!1,this.isRequired=(e==null?void 0:e.isRequired)??!1,this.isFavorite=(e==null?void 0:e.isFavorite)??!1,this.hidingComment=e==null?void 0:e.hidingComment,this.manager=e!=null&&e.manager?new oe(e.manager):void 0}}class ae extends ft{constructor(e){var t,s;super(e);i(this,"categories");i(this,"products");this.categories=(t=e==null?void 0:e.categories)==null?void 0:t.map(o=>new ae(o)),this.products=(s=e==null?void 0:e.products)==null?void 0:s.map(o=>new j(o))}}class Ye{constructor(r){i(this,"priceCoefficient");i(this,"increasePercent");this.priceCoefficient=(r==null?void 0:r.priceCoefficient)&&new we(r.priceCoefficient),this.increasePercent=r==null?void 0:r.increasePercent}}class ke extends Ye{constructor(e){super(e);i(this,"productCategory");this.productCategory=new se(e==null?void 0:e.productCategory)}}class Oe extends T{constructor(e){super(e);i(this,"photo");i(this,"contacts");i(this,"curatedDirection");this.photo=e.photo,this.contacts=new Ke(e.contacts),this.curatedDirection=new Ie(e.curatedDirection)}}class K extends a{}class Q extends a{constructor(e){super(e);i(this,"country",new K);e&&(this.country=new K(e.country))}}class Y extends a{constructor(e){super(e);i(this,"region",new Q);e&&(this.region=new Q(e.region))}}class Xe extends T{constructor(e){super(e);i(this,"phone");i(this,"email");i(this,"getNews");i(this,"salesDirection");i(this,"createdAt");i(this,"lastLoginAt");i(this,"isActive");this.phone=/^\d+$/.test((e==null?void 0:e.phone)??"")?`+${e==null?void 0:e.phone}`:(e==null?void 0:e.phone)??"",this.email=(e==null?void 0:e.email)??"",this.getNews=(e==null?void 0:e.getNews)??!1,this.salesDirection=e!=null&&e.salesDirection?new O(e.salesDirection):void 0,this.createdAt=u.isString(e==null?void 0:e.createdAt)?g.parseISO(e.createdAt):e==null?void 0:e.createdAt,this.lastLoginAt=u.isString(e==null?void 0:e.lastLoginAt)?g.parseISO(e.lastLoginAt):e==null?void 0:e.lastLoginAt,this.isActive=(e==null?void 0:e.isActive)??!1}}class F extends Xe{constructor(e){var t,s;super(e);i(this,"salesDirection");i(this,"debt");i(this,"alternativeName");i(this,"city");i(this,"comment");i(this,"isPhoneApproved");i(this,"isEmailApproved");i(this,"managers");i(this,"curators");this.salesDirection=new O(e==null?void 0:e.salesDirection),this.debt=(e==null?void 0:e.debt)??0,this.alternativeName=(e==null?void 0:e.alternativeName)??"",this.city=new Y(e==null?void 0:e.city),this.comment=e==null?void 0:e.comment,this.isPhoneApproved=(e==null?void 0:e.isPhoneApproved)??!1,this.isEmailApproved=(e==null?void 0:e.isEmailApproved)??!1,this.managers=((t=e==null?void 0:e.managers)==null?void 0:t.map(o=>new de(o)))??[],this.curators=((s=e==null?void 0:e.curators)==null?void 0:s.map(o=>new Oe(o)))??void 0}}class ce extends M{constructor(e){super(e);i(this,"createdAt");i(this,"deletedAt");i(this,"client");i(this,"priceTemplate");this.createdAt=u.isString(e==null?void 0:e.createdAt)?g.parseISO(e.createdAt):(e==null?void 0:e.createdAt)??new Date,this.deletedAt=u.isString(e==null?void 0:e.deletedAt)?g.parseISO(e.deletedAt):e==null?void 0:e.deletedAt,this.client=new F(e==null?void 0:e.client),this.priceTemplate=new V(e==null?void 0:e.priceTemplate)}}class Le extends Ye{constructor(e){super(e);i(this,"product");this.product=new k(e==null?void 0:e.product)}}class Ze extends a{}class X extends T{constructor(e){super(e);i(this,"type");i(this,"description");i(this,"metadata");i(this,"isFilterable");this.type=new Ze(e==null?void 0:e.type),this.description=(e==null?void 0:e.description)??"",this.metadata=e==null?void 0:e.metadata,this.isFilterable=e==null?void 0:e.isFilterable}}class Z{constructor(r){i(this,"property");i(this,"value");this.property=new X(r==null?void 0:r.property),this.value=(r==null?void 0:r.value)??""}}class A{constructor(r){i(this,"from");i(this,"to");this.from=u.isString(r==null?void 0:r.from)?g.parseISO(r.from):(r==null?void 0:r.from)??null,this.to=u.isString(r==null?void 0:r.to)?g.parseISO(r.to):(r==null?void 0:r.to)??null}}class yt{constructor(r){i(this,"id");i(this,"name");i(this,"description");i(this,"ownerName");i(this,"createdAt",new A);i(this,"updatedAt",new A);this.id=r==null?void 0:r.id,this.name=r==null?void 0:r.name,this.description=r==null?void 0:r.description,this.ownerName=r==null?void 0:r.ownerName,this.createdAt=new A(r==null?void 0:r.createdAt),this.updatedAt=new A(r==null?void 0:r.updatedAt)}resetFilterValue(r){switch(r){case"id":case"name":case"description":case"ownerName":this[r]=void 0;break;case"createdAt":this.createdAt.from=null,this.createdAt.to=null;break;case"updatedAt":this.updatedAt.from=null,this.updatedAt.to=null;break}return this}asClearRaw(){var e,t,s,o;const r={};return Object.keys(this).forEach(l=>{const h=this[l];u.isNil(h)||u.isString(h)&&h.trim().length===0||u.isFunction(h.isNewRec)&&h.isNewRec()||(r[l]=h)}),!((e=r==null?void 0:r.createdAt)!=null&&e.from)&&!((t=r==null?void 0:r.createdAt)!=null&&t.to)&&delete r.createdAt,!((s=r==null?void 0:r.updatedAt)!=null&&s.from)&&!((o=r==null?void 0:r.updatedAt)!=null&&o.to)&&delete r.updatedAt,r}}class le extends T{constructor(e){super(e);i(this,"description");i(this,"canChangeLowCost");i(this,"parentRoleId");i(this,"subRoles",[]);i(this,"parentRole");i(this,"level",0);this.description=e==null?void 0:e.description,this.canChangeLowCost=(e==null?void 0:e.canChangeLowCost)??!1,this.parentRoleId=e==null?void 0:e.parentRoleId}}class xe{constructor(r){i(this,"role");i(this,"category");i(this,"minCoefficient");this.role=new le(r==null?void 0:r.role),this.category=new se(r==null?void 0:r.category),this.minCoefficient=new we(r==null?void 0:r.minCoefficient)}}class Mr{constructor(r){i(this,"isFake");i(this,"isHidden");i(this,"isMultiple");i(this,"type");i(this,"ord");this.isFake=(r==null?void 0:r.isFake)??!1,this.isHidden=(r==null?void 0:r.isHidden)??!1,this.isMultiple=(r==null?void 0:r.isMultiple)??null,this.type=(r==null?void 0:r.type)??null,this.ord=(r==null?void 0:r.ord)??0}}class Ee{constructor(r){i(this,"category");i(this,"property");i(this,"settings");this.category=new se(r==null?void 0:r.category),this.property=new X(r==null?void 0:r.property),this.settings=new Mr(r==null?void 0:r.settings)}}class wt extends y{search(r,e=!1){return this.get("/internal/catalog/search",{term:r,show_hidden:e})}getPriceExportLink(r="csv",e=!1,t=void 0,s=void 0){let l=`${b().config.http.portalApiUrl}/api/internal/price/export?format=${r}&show_hidden=${e}`;return t&&(l+=`&category_id=${t}`),s&&(l+=`&client_id=${s}`),l}}class at extends y{importPrices(r,e){return this.post(`/internal/clients/${r}/price/import`,e)}updateCategoryPrices(r,e,t){var s;return this.patch(`/internal/clients/${r}/price/categories/${e}`,{price_coefficient_id:(s=t.coefficient)==null?void 0:s.id,increase_percent:t.value})}removeCategoryPrices(r,e){return this.delete(`/internal/clients/${r}/price/categories/${e}`)}markCategoryRequired(r,e){return this.post(`/internal/clients/${r}/price/categories/${e}/required`)}unmarkCategoryRequired(r,e){return this.delete(`/internal/clients/${r}/price/categories/${e}/required`)}markCategoryDisabled(r,e,t){return this.post(`/internal/clients/${r}/price/categories/${e}/disabled`,{comment:t})}unmarkCategoryDisabled(r,e){return this.delete(`/internal/clients/${r}/price/categories/${e}/disabled`)}addCategoryManager(r,e,t){return this.post(`/internal/clients/${r}/price/categories/${e}/manager`,{manager_id:t})}removeCategoryManager(r,e){return this.delete(`/internal/clients/${r}/price/categories/${e}/manager`)}updateProductPrice(r,e,t){var s;return this.patch(`/internal/clients/${r}/price/products/${e}`,{price_coefficient_id:(s=t.coefficient)==null?void 0:s.id,increase_percent:t.value},o=>new j(o.data))}removeProductPrice(r,e){return this.delete(`/internal/clients/${r}/price/products/${e}`,t=>new j(t.data))}markProductRequired(r,e){return this.post(`/internal/clients/${r}/price/products/${e}/required`)}unmarkProductRequired(r,e){return this.delete(`/internal/clients/${r}/price/products/${e}/required`)}getCommercialOfferHtml(r,e){return this.get(`/internal/clients/${r}/price/commercial-offer/view`,e,t=>new Blob([t.data],{type:"text/html"}))}getCommercialOfferPdf(r,e){return this.getBlob(`/internal/clients/${r}/price/commercial-offer/download`,e,t=>new Blob([t.request.response],{type:"application/pdf"}))}sendCommercialOffer(r,e){return this.post(`/internal/clients/${r}/price/commercial-offer/send`,e)}}class Ct extends y{getTemplateList(r){return this.get(`/internal/clients/${r}/price/templates`,{},e=>e.data.map(t=>new ce(t)))}getActiveTemplate(r){return this.get(`/internal/clients/${r}/price/templates/active`,{},e=>new ce(e.data),!0)}attachTemplate(r,e,t){const s=b().config.dateFormats.api;return this.post(`/internal/clients/${r}/price/templates/${e}`,t&&{startAt:t.startAt&&g.format(t.startAt,s),endAt:t.endAt&&g.format(t.endAt,s)},o=>new ce(o.data),{},!0)}applyTemplate(r,e){return this.post(`/internal/clients/${r}/price/templates/${e}/apply`,{},void 0,{},!0)}changeTemplate(r,e,t,s){const o=b().config.dateFormats.api;return this.patch(`/internal/clients/${r}/price/templates/${e}/${t}`,s&&{startAt:s.startAt&&g.format(s.startAt,o),endAt:s.endAt&&g.format(s.endAt,o)},l=>new ce(l.data))}detachTemplate(r,e,t){return this.delete(`/internal/clients/${r}/price/templates/${e}/${t}`)}}class vt extends y{getRootCategoriesList(r=!1){return this.get("/internal/catalog/categories",{showHidden:r},e=>e.data.map(t=>new N(t)))}getCategoryData(r,e=!1,t=!1){return this.get(`/internal/catalog/categories/${r}`,{showHidden:e,withNestedCategories:t},s=>new N(s.data))}getPublicCategoryData(r){return this.get(`/public/catalog/categories/${r}`,{},e=>new N(e.data))}getCategoryProductsList(r,e=!0,t=!1){return this.get(`/internal/catalog/categories/${r}/products`,{showHidden:t,withPriceCoefficients:e},s=>u.map(s.data,o=>new k(o)))}getCategoryProductsCoefficients(r){return this.get(`/internal/catalog/categories/${r}/products/coefficients`,{},e=>{const{data:t}=e;return u.forEach(t,s=>s.map(o=>new Se(o))),t})}publicSimpleSearch(r,e=10){return new Promise((t,s)=>{this.get(`/public/catalog/search/simple?limit=${e}&term=${r}`).then(o=>{t(o.categories.map(l=>new N(l)))}).catch(o=>{s(o)})})}}class Pt extends y{getProductData(r,e=!1){return this.get(`/internal/catalog/products/${r}`,{withPriceCoefficients:e},t=>new k(t.data))}getPublicProductData(r){return this.get(`/public/catalog/products/${r}`,{},e=>new k(e.data))}getProductPriceCoefficients(r){return this.get(`/internal/catalog/products/${r}/coefficients`,{},e=>u.map(e.data,t=>new Se(t)))}publicSimpleSearch(r,e=10){return new Promise((t,s)=>{this.get(`/public/catalog/search/simple?limit=${e}&term=${r}`).then(o=>{t(o.products.map(l=>new k(l)))}).catch(o=>{s(o)})})}}class Rt extends y{getRootCategoriesList(r,e=!1){return this.get("/internal/catalog/categories",{clientId:r,showHidden:e},t=>t.data.map(s=>new ae(s)))}getCategoryData(r,e,t=!1,s=!1){return this.get(`/internal/catalog/categories/${e}`,{clientId:r,showHidden:t,withNestedCategories:s},o=>new ae(o.data))}getCategoryProductsList(r,e,t=!0,s=!1){return this.get(`/internal/catalog/categories/${e}/products`,{client_id:r,showHidden:s,withPriceCoefficients:t},o=>u.map(o.data,l=>new j(l)))}}class Dt extends y{getProductData(r,e,t=!1){return this.get(`/internal/catalog/products/${r}`,{clientId:e,withPriceCoefficients:t},s=>new j(s.data))}}var _e=(n=>(n.BeginWith="bw",n.Contains="cn",n.Custom="custom",n.EndsWith="ew",n.Equals="eq",n.GreaterOrEqual="ge",n.GreaterThan="gt",n.InList="in",n.LessOrEqual="le",n.LessThan="lt",n.NotBeginWith="bn",n.NotContains="nc",n.NotEndsWith="en",n.NotEqual="ne",n.NotInList="ni",n.NotNull="nn",n.Null="nu",n))(_e||{});class er{constructor(r){i(this,"field");i(this,"op");i(this,"value");this.field=(r==null?void 0:r.field)??"",this.op=(r==null?void 0:r.op)??_e.Equals,this.value=(r==null?void 0:r.value)??""}toPrimitive(){const r=b().config.dateFormats.api,e={field:this.field,op:this.op};return u.isDate(this.value)?e.value=g.format(this.value,r):u.isObject(this.value)?e.value={from:this.value.from?g.format(this.value.from,r):null,to:this.value.to?g.format(this.value.to,r):null}:e.value=this.value,e}}class G{constructor(r){i(this,"groupOp");i(this,"filters");i(this,"groups");var e,t;this.groupOp=(r==null?void 0:r.groupOp)??"and",this.filters=((e=r==null?void 0:r.filters)==null?void 0:e.map(s=>new er(s)))??[],this.groups=((t=r==null?void 0:r.groups)==null?void 0:t.map(s=>new G(s)))??[]}toPrimitive(){return{groupOp:this.groupOp,filters:this.filters.map(r=>r instanceof er&&u.isFunction(r.toPrimitive)?r.toPrimitive():r),groups:this.groups.map(r=>r instanceof G?r.toPrimitive():r)}}}class x extends y{getPaginated(r,e,t,s,o,l,h,f=void 0){let C={page:(s==null?void 0:s.page)??1,perPage:(s==null?void 0:s.pageSize)??10};return e&&(C.filters=JSON.stringify((e instanceof G?e:new G(e)).toPrimitive())),u.isEmpty(t)||(C.sort=u.isArray(t)?t:[t]),o&&(C={...C,...o}),this.get(r,C,l,h,f)}}class At extends x{getTemplateList(r,e,t){return this.getPaginated("/internal/price/templates",r,e,t,{},s=>{const o={...s.data};return o.data=o.data.map(l=>new V(l)),o})}createTemplate(r,e={}){return this.post("/internal/price/templates",r,t=>new V(t.data),e)}getTemplate(r){return this.get(`/internal/price/templates/${r}`,{},e=>new V(e.data))}updateTemplate(r,e,t={}){return this.patch(`/internal/price/templates/${r}`,e,s=>new V(s.data),t)}removeTemplate(r){return this.delete(`/internal/price/templates/${r}`)}getProductTemplatePrices(r){return this.get(`/internal/price/templates/${r}/products`,{},e=>e.data.map(t=>new Le(t)))}getProductTemplatePrice(r,e){return this.get(`/internal/price/templates/${r}/products/${e}`,{},t=>new Le(t.data))}saveProductTemplatePrice(r,e,t){var s;return this.post(`/internal/price/templates/${r}/products/${e}`,{price_coefficient_id:(s=t.coefficient)==null?void 0:s.id,increase_percent:t.value},o=>new Le(o.data))}deleteProductTemplatePrice(r,e){return this.delete(`/internal/price/templates/${r}/products/${e}`)}getCategoryTemplatePrices(r){return this.get(`/internal/price/templates/${r}/categories`,{},e=>e.data.map(t=>new ke(t)))}getCategoryTemplatePrice(r,e){return this.get(`/internal/price/templates/${r}/categories/${e}`,{},t=>new ke(t.data))}saveCategoryTemplatePrice(r,e,t,s=!1){var o;return this.request({method:"POST",url:`/internal/price/templates/${r}/categories/${e}`,data:{price_coefficient_id:(o=t.coefficient)==null?void 0:o.id,increase_percent:t.value},params:s?{recursively:!0}:{}},l=>new ke(l.data))}deleteCategoryTemplatePrice(r,e,t=!1){return this.request({method:"DELETE",url:`/internal/price/templates/${r}/categories/${e}`,params:t?{recursively:!0}:{}})}getTemplateClients(r){return this.get(`/internal/price/templates/${r}/clients`,{},e=>e.data.map(t=>new ce(t)))}}class St extends y{getRoles(){return this.get("/internal/price/roles",{},r=>r.data.map(e=>new le(e)))}createRole(r){return this.post("/internal/price/roles",r,e=>new le(e.data))}getRole(r){return this.get(`/internal/price/roles/${r}`,{},e=>new le(e.data))}updateRole(r,e){return this.patch(`/internal/price/roles/${r}`,e,t=>new le(t.data))}deleteRole(r){return this.delete(`/internal/price/roles/${r}`)}getCategoryRules(r){return this.get(`/internal/price/roles/rules/categories/${r}`,{},e=>e.data.map(t=>new xe(t)))}updateCategoryRules(r,e){return this.patch(`/internal/price/roles/rules/categories/${r}`,e,t=>t.data.map(s=>new xe(s)))}}class Tt extends x{getProperties(r,e,t){return this.getPaginated("/internal/catalog/properties",r,e,t,{},s=>{const o={...s.data};return o.data=o.data.map(l=>new X(l)),o})}createProperty(r){const{typeId:e,...t}=r;return this.post("/internal/catalog/properties",{...t,type:e},s=>new X(s.data))}getProperty(r){return this.get(`/internal/catalog/properties/${r}`,{},e=>new X(e.data))}updateProperty(r,e){const{typeId:t,...s}=e;return this.patch(`/internal/catalog/properties/${r}`,{...s,type:t},o=>new X(o.data))}deleteProperty(r){return this.delete(`/internal/catalog/properties/${r}`)}getProductProperties(r){return this.get(`/internal/catalog/products/${r}/properties`,{},e=>e.data.map(t=>new Z(t)))}getProductProperty(r,e){return this.get(`/internal/catalog/products/${r}/properties/${e}`,{},t=>new Z(t.data))}updateProductProperty(r,e,t){return this.patch(`/internal/catalog/products/${r}/properties/${e}`,{value:t},s=>new Z(s.data))}deleteProductProperty(r,e){return this.delete(`/internal/catalog/products/${r}/properties/${e}`)}getProductDescription(r){return this.get(`/internal/catalog/products/${r}/properties/description`)}updateProductDescription(r,e){return this.patch(`/internal/catalog/products/${r}/properties/description`,{text:e})}deleteProductDescription(r){return this.delete(`/internal/catalog/products/${r}/properties/description`)}getProductSpecification(r){return this.get(`/internal/catalog/products/${r}/properties/specification`)}updateProductSpecification(r,e){return this.patch(`/internal/catalog/products/${r}/properties/specification`,{text:e})}deleteProductSpecification(r){return this.delete(`/internal/catalog/products/${r}/properties/specification`)}getProductFiles(r){return this.get(`/internal/catalog/products/${r}/properties/files`)}addProductFile(r,e){return this.post(`/internal/catalog/products/${r}/properties/files`,e)}updateProductFile(r,e,t){return this.patch(`/internal/catalog/products/${r}/properties/files/${e}`,t)}deleteProductFile(r,e){return this.delete(`/internal/catalog/products/${r}/properties/files/${e}`)}updateProductSlug(r,e){return this.patch(`/internal/catalog/products/${r}/properties/slug`,{slug:e})}getCategoryProperties(r){return this.get(`/internal/catalog/categories/${r}/properties`,{},e=>e.data.map(t=>new Z(t)))}getCategoryProperty(r,e){return this.get(`/internal/catalog/categories/${r}/properties/${e}`,{},t=>new Z(t.data))}updateCategoryProperty(r,e,t){return this.patch(`/internal/catalog/categories/${r}/properties/${e}`,{value:t},s=>new Z(s.data))}deleteCategoryProperty(r,e){return this.delete(`/internal/catalog/categories/${r}/properties/${e}`)}getCategoryDescription(r){return this.get(`/internal/catalog/categories/${r}/properties/description`)}updateCategoryDescription(r,e){return this.patch(`/internal/catalog/categories/${r}/properties/description`,{text:e})}deleteCategoryDescription(r){return this.delete(`/internal/catalog/categories/${r}/properties/description`)}getCategorySpecification(r){return this.get(`/internal/catalog/categories/${r}/properties/specification`)}updateCategorySpecification(r,e){return this.patch(`/internal/catalog/categories/${r}/properties/specification`,{text:e})}deleteCategorySpecification(r){return this.delete(`/internal/catalog/categories/${r}/properties/specification`)}getCategoryFiles(r){return this.get(`/internal/catalog/categories/${r}/properties/files`)}addCategoryFile(r,e){return this.post(`/internal/catalog/categories/${r}/properties/files`,e)}updateCategoryFile(r,e,t){return this.patch(`/internal/catalog/categories/${r}/properties/files/${e}`,t)}deleteCategoryFile(r,e){return this.delete(`/internal/catalog/categories/${r}/properties/files/${e}`)}updateCategorySlug(r,e){return this.patch(`/internal/catalog/categories/${r}/properties/slug`,{slug:e})}updateCategoryImage(r,e){return this.post(`/internal/catalog/categories/${r}/image`,{image:e})}getCategoryFilterSettings(r){return this.get(`/internal/catalog/categories/${r}/filter-settings`,{},e=>e.data.map(t=>new Ee(t)))}saveCategoryFilterSetting(r,e,t){return this.patch(`/internal/catalog/categories/${r}/filter-settings/${e}`,t,s=>new Ee(s.data))}deleteCategoryFilterSetting(r,e){return this.delete(`/internal/catalog/categories/${r}/filter-settings/${e}`)}}class $t extends y{getRootCategoriesList(r,e=!1){return this.get("/internal/catalog/categories",{priceTemplateId:r,showHidden:e},t=>t.data.map(s=>new N(s)))}getCategoryData(r,e,t=!1,s=!1){return this.get(`/internal/catalog/categories/${e}`,{priceTemplateId:r,showHidden:t,withNestedCategories:s},o=>new N(o.data))}getCategoryProductsList(r,e,t=!0,s=!1){return this.get(`/internal/catalog/categories/${e}/products`,{priceTemplateId:r,showHidden:s,withPriceCoefficients:t},o=>u.map(o.data,l=>new k(l)))}}function rr(n,r,e){let t;return n.some(s=>{if(s.type===e&&s.id===r)return t=s,!0;if(s.type==="product")return!1;const o=s;if(o.products&&o.products.length>0){const l=rr(o.products,r,e);if(l)return t=l,!0}if(o.categories&&o.categories.length>0){const l=rr(o.categories,r,e);if(l)return t=l,!0}return!1}),t}function tr(n){const r=[];return n.forEach(e=>{if(r.push(e),e.type==="category"){const t=e;t.products&&t.products.length>0&&r.push(...tr(t.products)),t.categories&&t.categories.length>0&&r.push(...tr(t.categories))}}),r}var jr=(n=>(n.LastOrder="last_order",n.Contacts="contacts",n.PartnerGroups="partner_groups",n.PreferredDeliveryType="preferred_delivery_type",n.SalesDirection="sales_direction",n.Managers="managers",n.Curators="curators",n))(jr||{}),U=(n=>(n.Person="individual",n.Ic="entrepreneur",n.UlR="legal",n.UlNr="non_resident_legal",n))(U||{});class qe extends M{constructor(e){super(e);i(this,"bankName","");i(this,"bic","");i(this,"accountNumber","");i(this,"correspondentAccount","");i(this,"currency",new L);e&&(this.bankName=e.bankName??"",this.bic=e.bic??"",this.accountNumber=e.accountNumber??"",this.correspondentAccount=e.correspondentAccount??"",this.currency=new L(e.currency))}}class Ne extends T{constructor(e){super(e);i(this,"phone");i(this,"email");this.email=e==null?void 0:e.email,this.phone=/^\d+$/.test((e==null?void 0:e.phone)??"")?`+${e==null?void 0:e.phone}`:e==null?void 0:e.phone}}class W extends Ne{constructor(e){super(e);i(this,"isPrimary");i(this,"position");i(this,"notDisturb");i(this,"comment");i(this,"updatedAt");i(this,"deletedAt");this.isPrimary=(e==null?void 0:e.isPrimary)??!1,this.position=e==null?void 0:e.position,this.notDisturb=(e==null?void 0:e.notDisturb)??!1,this.comment=e==null?void 0:e.comment,this.updatedAt=e==null?void 0:e.updatedAt,this.deletedAt=u.isString(e==null?void 0:e.deletedAt)?g.parseISO(e.deletedAt):e==null?void 0:e.deletedAt}}class z extends a{static generatePersonItem(){return new z({id:1,guid:"",slug:U.Person,name:""})}}class E extends a{}class ir extends Fe{constructor(e){super(e);i(this,"deletedAt");this.deletedAt=u.isString(e==null?void 0:e.deletedAt)?g.parseISO(e.deletedAt):e==null?void 0:e.deletedAt}}class sr extends ir{constructor(e){super(e);i(this,"opf",z.generatePersonItem());i(this,"partnerGroup",new E);i(this,"contacts",[]);i(this,"bankAccounts",[]);i(this,"comment");i(this,"alternativeName");i(this,"createdAt");i(this,"creator");i(this,"updater");if(e){if(this.opf=new z(e.opf),this.comment=e.comment,this.alternativeName=e.alternativeName,this.createdAt=u.isString(e==null?void 0:e.createdAt)?g.parseISO(e.createdAt):e.createdAt,this.creator=e.creator?new I(e.creator):void 0,this.updater=e.updater?new I(e.updater):void 0,e.partnerGroup&&(this.partnerGroup=new E(e.partnerGroup)),e.contacts){const t=[];e.contacts.forEach(s=>{t.push(new W(s))}),this.contacts=t}if(e.bankAccounts){const t=[];e.bankAccounts.forEach(s=>{t.push(new qe(s))}),this.bankAccounts=t}}}}class Fr extends sr{constructor(r){super(r)}}class nr extends sr{constructor(e){super(e);i(this,"inn","");i(this,"okpo","");i(this,"directorName","");i(this,"directorPosition","");i(this,"directorActsOn","");i(this,"legalAddress","");i(this,"postalAddress","");i(this,"actualAddress","");e&&(this.inn=e.inn??"",this.okpo=e.okpo??"",this.directorName=e.directorName??"",this.directorPosition=e.directorPosition??"",this.directorActsOn=e.directorActsOn??"",this.legalAddress=e.legalAddress??"",this.postalAddress=e.postalAddress??"",this.actualAddress=e.actualAddress??"")}}class or extends nr{constructor(e){super(e);i(this,"kpp","");e&&(this.kpp=e.kpp??"")}}class Gr extends or{constructor(e){super(e);i(this,"registrationCountry",new K);i(this,"registrationNumber","");i(this,"taxNumber","");e&&(this.registrationCountry=new K(e.registrationCountry),this.registrationNumber=e.registrationNumber??"",this.taxNumber=e.taxNumber??"")}}class Ce{static createInstance(r){switch(r.opf.slug){case U.Ic:return new nr(r);case U.UlR:return new or(r);case U.UlNr:return new Gr(r);default:return new Fr(r)}}}class ue extends ir{constructor(e){var t;super(e);i(this,"address","");i(this,"coordinates");i(this,"contacts");i(this,"comment");i(this,"operatingHours");i(this,"isOneTime");i(this,"isTransportCompanyAddress");this.address=(e==null?void 0:e.address)??"",this.coordinates=new We(e==null?void 0:e.coordinates),this.contacts=((t=e==null?void 0:e.contacts)==null?void 0:t.map(s=>new W(s)))??[],this.comment=e==null?void 0:e.comment,this.operatingHours=e==null?void 0:e.operatingHours,this.isOneTime=e==null?void 0:e.isOneTime,this.isTransportCompanyAddress=e==null?void 0:e.isTransportCompanyAddress}}class cr extends a{}class lr extends a{}class ur extends F{constructor(e){var t,s,o,l;super(e);i(this,"contragents");i(this,"partnerGroups");i(this,"contacts");i(this,"deliveryAddresses");i(this,"channelPrimaryInterest");i(this,"sourcePrimaryInterest");i(this,"preferredDeliveryType");i(this,"primaryDemand");i(this,"preferredWarehouse");i(this,"extraData");this.contragents=((t=e==null?void 0:e.contragents)==null?void 0:t.map(h=>Ce.createInstance(h)))??[],this.partnerGroups=((s=e==null?void 0:e.partnerGroups)==null?void 0:s.map(h=>new E(h)))??[],this.contacts=((o=e==null?void 0:e.contacts)==null?void 0:o.map(h=>new W(h)))??[],this.deliveryAddresses=((l=e==null?void 0:e.deliveryAddresses)==null?void 0:l.map(h=>new ue(h)))??[],this.channelPrimaryInterest=new cr(e==null?void 0:e.channelPrimaryInterest),this.sourcePrimaryInterest=new lr(e==null?void 0:e.sourcePrimaryInterest),this.preferredDeliveryType=new q(e==null?void 0:e.preferredDeliveryType),this.primaryDemand=e==null?void 0:e.primaryDemand,this.preferredWarehouse=e!=null&&e.preferredWarehouse?new te(e.preferredWarehouse):void 0,this.extraData=(e==null?void 0:e.extraData)??{}}}class ve{asClearRaw(){const r={};return Object.keys(this).forEach(e=>{const t=this[e];u.isNil(t)||u.isString(t)&&t.trim().length===0||u.isFunction(t.isNewRec)&&t.isNewRec()||(r[e]=t)}),r}}class bt extends ve{constructor(e){var t,s,o,l,h,f,C,v;super();i(this,"id");i(this,"name");i(this,"alternativeName");i(this,"searchTerm");i(this,"cities");i(this,"region");i(this,"country");i(this,"phone");i(this,"email");i(this,"isActive");i(this,"createdAt",new A);i(this,"lastLoginDate",new A);i(this,"lastLoginDateHasOrder");i(this,"managers");i(this,"includeSubordinateManagers");i(this,"curators");i(this,"isManagerRequired");i(this,"salesDirections");i(this,"contragentInn");i(this,"contragentType");i(this,"preferredDeliveryType");i(this,"partnerGroups");i(this,"contact");i(this,"lastOrder");i(this,"noOrdersPeriod",new A);this.id=e==null?void 0:e.id,this.name=e==null?void 0:e.name,this.alternativeName=e==null?void 0:e.alternativeName,this.searchTerm=e==null?void 0:e.searchTerm,this.cities=(t=e==null?void 0:e.cities)==null?void 0:t.map(R=>new Y(R)),this.region=new Q(e==null?void 0:e.region),this.country=new K(e==null?void 0:e.country),this.phone=e==null?void 0:e.phone,this.email=e==null?void 0:e.email,this.isActive=e&&Object.prototype.hasOwnProperty.call(e,"isActive")?e==null?void 0:e.isActive:!0,this.createdAt=new A(e==null?void 0:e.createdAt),this.lastLoginDate=new A(e==null?void 0:e.lastLoginDate),this.lastLoginDateHasOrder=(e==null?void 0:e.lastLoginDateHasOrder)??void 0,this.managers=((s=e==null?void 0:e.managers)==null?void 0:s.map(R=>new oe(R)))??[],this.includeSubordinateManagers=(e==null?void 0:e.includeSubordinateManagers)??!0,this.curators=((o=e==null?void 0:e.curators)==null?void 0:o.map(R=>new Oe(R)))??[],this.salesDirections=(l=e==null?void 0:e.salesDirections)==null?void 0:l.map(R=>new O(R)),this.contragentInn=e==null?void 0:e.contragentInn,this.contragentType=new z(e==null?void 0:e.contragentType),this.preferredDeliveryType=e!=null&&e.preferredDeliveryType?new q(e==null?void 0:e.preferredDeliveryType):void 0,this.partnerGroups=(h=e==null?void 0:e.partnerGroups)==null?void 0:h.map(R=>new E(R)),this.contact=new Ne(e==null?void 0:e.contact),this.lastOrder={createdAt:new A((f=e==null?void 0:e.lastOrder)==null?void 0:f.createdAt),creator:(C=e==null?void 0:e.lastOrder)==null?void 0:C.creator,isApproved:(v=e==null?void 0:e.lastOrder)==null?void 0:v.isApproved},this.noOrdersPeriod=new A(e==null?void 0:e.noOrdersPeriod)}resetFilterValue(e){switch(e){case"cities":this.cities=[];break;case"region":this.region=new Q;break;case"isActive":this.isActive=!0;break;case"createdAt":this.createdAt.from=null,this.createdAt.to=null;break;case"lastLoginDate":this.lastLoginDate.from=null,this.lastLoginDate.to=null;break;case"noOrdersPeriod":this.noOrdersPeriod.from=null,this.noOrdersPeriod.to=null;break;case"lastOrder":this.lastOrder={};break;case"managers":this.managers=[];break;case"curators":this.curators=[];break;case"salesDirections":this.salesDirections=[];break;case"contragentType":this.contragentType=new z;break;case"preferredDeliveryType":this.preferredDeliveryType=new q;break;case"partnerGroups":this.partnerGroups=[];break;case"contact":this.contact=new Ne;break;default:this[e]=void 0;break}return this}asClearRaw(){var t,s,o,l,h,f;const e=super.asClearRaw();return!((t=e==null?void 0:e.createdAt)!=null&&t.from)&&!((s=e==null?void 0:e.createdAt)!=null&&s.to)&&delete e.createdAt,!((o=e==null?void 0:e.lastLoginDate)!=null&&o.from)&&!((l=e==null?void 0:e.lastLoginDate)!=null&&l.to)&&delete e.lastLoginDate,!((h=e==null?void 0:e.noOrdersPeriod)!=null&&h.from)&&!((f=e==null?void 0:e.noOrdersPeriod)!=null&&f.to)&&delete e.noOrdersPeriod,e}}class pr extends M{constructor(e){super(e);i(this,"createdAt");i(this,"creator");this.createdAt=u.isString(e==null?void 0:e.createdAt)?g.parseISO(e.createdAt):(e==null?void 0:e.createdAt)??new Date,this.creator=new I(e==null?void 0:e.creator)}}class Wr extends T{constructor(e){var t,s,o,l;super(e);i(this,"contacts",[]);i(this,"preferredDeliveryType");i(this,"partnerGroups",[]);i(this,"lastOrder");i(this,"salesDirection");i(this,"managers");i(this,"curators");this.contacts=((t=e.contacts)==null?void 0:t.map(h=>new W(h)))??void 0,this.lastOrder=e.lastOrder?new pr(e.lastOrder):void 0,this.partnerGroups=((s=e.partnerGroups)==null?void 0:s.map(h=>new E(h)))??void 0,this.preferredDeliveryType=e.preferredDeliveryType?new q(e.preferredDeliveryType):void 0,this.salesDirection=e.salesDirection?new O(e.salesDirection):void 0,this.managers=((o=e.managers)==null?void 0:o.map(h=>new de(h)))??void 0,this.curators=((l=e.curators)==null?void 0:l.map(h=>new Oe(h)))??void 0}}class Ue extends M{constructor(e){super(e);i(this,"isPrimary");this.isPrimary=e.isPrimary}}class zr extends W{constructor(e){super(e);i(this,"relations",{clients:[],contragents:[],addresses:[]});e.relations&&(e.relations.addresses&&(this.relations.addresses=e.relations.addresses.map(t=>new Ue(t))),e.relations.clients&&(this.relations.clients=e.relations.clients.map(t=>new Ue(t))),e.relations.contragents&&(this.relations.contragents=e.relations.contragents.map(t=>new Ue(t))))}}class _ extends x{static transformClientDataToRequest(r){var t;return{name:r.name,alternative_name:r.alternativeName,partner_groups:r.partnerGroups.map(s=>s.id),phone:r.phone,email:r.email,city_id:r.city.id,get_news:r.getNews,channel_primary_interest_id:r.channelPrimaryInterest.id,source_primary_interest_id:r.sourcePrimaryInterest.id,primary_demand:r.primaryDemand,preferred_warehouse_id:(t=r.preferredWarehouse)==null?void 0:t.id}}static transformContragentClientDataToRequest(r){var l,h,f,C;let e;const t=r,s=r,o=r;switch(r.opf.slug){case U.Ic:e={opf:t.opf.slug,name:t.name,alternative_name:t.alternativeName,partner_group_id:(l=t.partnerGroup)==null?void 0:l.id,comment:t.comment,inn:t.inn,okpo:t.okpo,director_name:t.directorName,director_position:t.directorPosition,director_acts_on:t.directorActsOn,legal_address:t.legalAddress,postal_address:t.postalAddress,actual_address:t.actualAddress};break;case U.UlR:e={opf:s.opf.slug,name:s.name,alternative_name:s.alternativeName,partner_group_id:(h=s.partnerGroup)==null?void 0:h.id,comment:s.comment,inn:s.inn,kpp:s.kpp,okpo:s.okpo,director_name:s.directorName,director_position:s.directorPosition,director_acts_on:s.directorActsOn,legal_address:s.legalAddress,postal_address:s.postalAddress,actual_address:s.actualAddress};break;case U.UlNr:e={opf:o.opf.slug,name:o.name,alternative_name:o.alternativeName,partner_group_id:(f=o.partnerGroup)==null?void 0:f.id,comment:o.comment,director_name:o.directorName,director_position:o.directorPosition,director_acts_on:o.directorActsOn,legal_address:o.legalAddress,postal_address:o.postalAddress,actual_address:o.actualAddress,registration_country_id:o.registrationCountry.id,registration_number:o.registrationNumber,tax_number:o.taxNumber||void 0};break;default:e={opf:r.opf.slug,name:r.name,alternative_name:r.alternativeName,partner_group_id:(C=r.partnerGroup)==null?void 0:C.id,comment:r.comment};break}return e}static transformClientDeliveryAddressToRequest(r){var t,s;const e={address:r.address,is_one_time:r.isOneTime??!1,is_transport_company_address:r.isTransportCompanyAddress??!1,comment:r.comment??""};return r.coordinates&&(e.coordinates={lat:(t=r.coordinates)==null?void 0:t.lat,long:(s=r.coordinates)==null?void 0:s.long}),r.operatingHours&&(e.operating_hours={from:r.operatingHours.from,to:r.operatingHours.to}),e}static transformClientContragentBankAccountToRequest(r){return{bank_name:r.bankName,bic:r.bic,account_number:r.accountNumber,correspondent_account:r.correspondentAccount,currency_id:r.currency.id}}getClient(r){return this.get(`/internal/clients/${r}`,{},e=>new ur(e.data))}getClientsList(r,e,t,s,o=void 0){return this.getPaginated("/internal/clients",r,e,t,s,l=>{const h={...l.data};return h.data=h.data.map(f=>new F(f)),h},void 0,o)}searchClient(r){return this.getClientsList(void 0,void 0,void 0,{searchTerm:r}).then(e=>e.data)}getClientByPhone(r){return this.getClientsList({groupOp:"and",groups:[],filters:[{field:"phone",op:_e.Contains,value:r}]})}getAdditionalClientsData(r,e){const t=r.map(s=>s.id);return this.post("/internal/clients/additional-data",{clients:t,requested_data_types:e},s=>{let o=[];return(s==null?void 0:s.data.length)>0&&(o=s.data.map(l=>new Wr(l))),o})}getAllClientContacts(r){return this.get(`/internal/clients/${r}/contacts/all`,{},e=>{let t=[];return(e==null?void 0:e.data.length)>0&&(t=e.data.map(s=>new zr(s))),t})}createClientCommonData(r,e={}){return this.post("/internal/clients",_.transformClientDataToRequest(r),t=>new ur(t.data),e)}updateClientCommonData(r,e={}){return this.patch(`/internal/clients/${r.id}`,_.transformClientDataToRequest(r),void 0,e)}updateClientNotDistribCommonData(r,e={}){const t={get_news:r.getNews};return this.patch(`/internal/clients/${r.id}`,t,void 0,e)}changeClientPassword(r,e,t,s={}){return this.patch(`/internal/clients/${r}`,{password:e,password_confirmation:t},void 0,s)}updateClientComment(r){return this.patch(`/internal/clients/${r.id}`,{comment:r.comment})}changeClientActivation(r){return this.patch(`/internal/clients/${r.id}`,{is_active:r.isActive})}async attachClientToManagers(r,e){const t=e.map(s=>this.patch(`/internal/clients/${r}/managers/${s.id}/attach`,{is_primary:s.isDefault}));await Promise.all(t)}async detachClientFromManagers(r,e){const t=e.map(s=>this.patch(`/internal/clients/${r}/managers/${s.id}/detach`));await Promise.all(t)}attachToCurator(r,e,t){return this.patch(`/internal/clients/${r}/curators/${e}/attach`,{curated_direction_id:t.id})}detachFromCurator(r,e,t){return this.patch(`/internal/clients/${r}/curators/${e}/detach`,{curated_direction_id:t.id})}setCurators(r,e){return this.patch(`/internal/clients/${r}/curators`,{curators:e.map(t=>({curator_id:t.curatorId,curated_direction_id:t.curatedDirection.id}))})}createContragentClientData(r,e,t={}){return this.post(`/internal/clients/${r}/contragents`,_.transformContragentClientDataToRequest(e),s=>Ce.createInstance(s.data),t)}updateContragentClientData(r,e,t={}){return this.patch(`/internal/clients/${r}/contragents/${e.id}`,_.transformContragentClientDataToRequest(e),s=>Ce.createInstance(s.data),t)}deleteClientContragent(r,e){return this.delete(`/internal/clients/${r}/contragents/${e.id}`)}getClientDeliveryAddresses(r){return this.get(`/internal/clients/${r}/delivery-addresses`,{},e=>e.data.map(t=>new ue(t)))}createClientDeliveryAddress(r,e,t={}){return this.post(`/internal/clients/${r}/delivery-addresses`,_.transformClientDeliveryAddressToRequest(e),s=>new ue(s.data),t)}updateClientDeliveryAddress(r,e,t={}){return this.patch(`/internal/clients/${r}/delivery-addresses/${e.id}`,_.transformClientDeliveryAddressToRequest(e),s=>new ue(s.data),t)}deleteClientDeliveryAddress(r,e){return this.delete(`/internal/clients/${r}/delivery-addresses/${e.id}`)}createContragentBankAccount(r,e,t,s={}){return this.post(`/internal/clients/${r}/contragents/${e}/bank-accounts`,_.transformClientContragentBankAccountToRequest(t),o=>new qe(o.data),s)}updateContragentBankAccount(r,e,t,s={}){return this.patch(`/internal/clients/${r}/contragents/${e}/bank-accounts/${t.id}`,_.transformClientContragentBankAccountToRequest(t),o=>new qe(o.data),s)}deleteContragentBankAccount(r,e,t){return this.delete(`/internal/clients/${r}/contragents/${e}/bank-accounts/${t.id}`)}createClientContact(r,e,t={}){return this.createContact(r,e,{client:{id:r,is_primary:e.isPrimary??!1,not_disturb:e.notDisturb??!1}},t)}updateClientContact(r,e,t={}){return this.patch(`/internal/clients/${r}/contacts/${e.id}`,{name:e.name,position:e.position,phone:e.phone,email:e.email,comment:e.comment,not_disturb:e.notDisturb},s=>new W(s.data),t)}setPrimaryClientContact(r,e){return this.setPrimaryContact(`/internal/clients/${r}/contacts/${e.id}/primary`,e.isPrimary??!1)}detachClientContact(r,e){return this.detachContact(`/internal/clients/${r}/contacts/${e.id}/detach`)}createContragentContact(r,e,t,s={}){return this.createContact(r,t,{contragents:[{id:e,is_primary:t.isPrimary??!1,not_disturb:t.notDisturb??!1}]},s)}setPrimaryContragentContact(r,e,t){return this.setPrimaryContact(`/internal/clients/${r}/contragents/${e}/contacts/${t.id}/primary`,t.isPrimary??!1)}detachContragentContact(r,e,t){return this.detachContact(`/internal/clients/${r}/contragents/${e}/contacts/${t.id}/detach`)}createDeliveryAddressContact(r,e,t,s={}){return this.createContact(r,t,{addresses:[{id:e,is_primary:t.isPrimary??!1,not_disturb:t.notDisturb??!1}]},s)}setPrimaryDeliveryAddressContact(r,e,t){return this.setPrimaryContact(`/internal/clients/${r}/delivery-addresses/${e}/contacts/${t.id}/primary`,t.isPrimary??!1)}detachDeliveryAddressContact(r,e,t){return this.detachContact(`/internal/clients/${r}/delivery-addresses/${e}/contacts/${t.id}/detach`)}createContact(r,e,t,s={}){var l,h;const o={name:e.name,position:e.position,comment:e.comment,...t};return(l=e.phone)!=null&&l.length&&(o.phone=e.phone),(h=e.email)!=null&&h.length&&(o.email=e.email),this.post(`/internal/clients/${r}/contacts`,o,f=>new W(f.data),s)}setPrimaryContact(r,e){return this.patch(r,{is_primary:e})}detachContact(r){return this.patch(r)}sendClientEmailConfirmation(r){return this.get(`/internal/clients/${r.id}/verification/email?email=${r.email}`)}}class dt extends y{checkPhoneIsBusy(r){return new Promise((e,t)=>{this.request({method:"GET",url:"/public/user/verification/phone/check",params:{phone:r}}).then(s=>{e(!!s.isBusy)}).catch(t)})}}class It{constructor(r){i(this,"date");i(this,"name");i(this,"version");this.date=u.isString(r==null?void 0:r.date)?g.parseISO(r.date):(r==null?void 0:r.date)??new Date,this.name=(r==null?void 0:r.name)??"",this.version=(r==null?void 0:r.version)??"0.0.0"}}var Jr=(n=>(n.Kozyrek="kozyrek",n.Mosquitto="mosquitto",n.Strip="strip",n.MetalForDoors="metal_for_doors",n.Sandwich="sandwich",n.SandwichM2="sandwich_m2",n))(Jr||{});class kt extends y{getConfiguratorSettings(r,e){var t;return this.get(`internal/catalog/categories/${r.id}/configurators/${(t=r.properties)==null?void 0:t.configurator}/settings?client_id=${e}`)}searchProduct(r,e,t,s={}){var l;const o=this.get(`internal/catalog/categories/${r.id}/configurators/${(l=r.properties)==null?void 0:l.configurator}/product`,{params:t,client_id:e},h=>new k(h.data));return o.catch(h=>{this.errorResponseHandler(h,s)}),o}createTemplate(r,e,t,s={}){var o;return this.post(`internal/catalog/categories/${r.id}/configurators/${(o=r.properties)==null?void 0:o.configurator}/template?client_id=${e}`,{...t},()=>{},s)}removeTemplate(r,e,t){var s;return this.delete(`internal/catalog/categories/${r.id}/configurators/${(s=r.properties)==null?void 0:s.configurator}/template/${t}?client_id=${e}`)}calculate(r,e,t){var s;return this.get(`internal/catalog/categories/${r.id}/configurators/${(s=r.properties)==null?void 0:s.configurator}/calculate`,{client_id:e,...t})}}class Vr{constructor(r){i(this,"page",1);i(this,"pageSize",50);this.page=(r==null?void 0:r.page)??1,this.pageSize=(r==null?void 0:r.pageSize)??50}}class Ot extends Vr{constructor(e){super(e);i(this,"itemCount",0);i(this,"pageCount",1);i(this,"pageSlot",5);i(this,"pageSizes",[25,50,100]);i(this,"showSizePicker",!0);this.itemCount=(e==null?void 0:e.itemCount)??0,this.pageCount=(e==null?void 0:e.pageCount)??1,this.pageSlot=(e==null?void 0:e.pageSlot)??5,this.pageSizes=(e==null?void 0:e.pageSizes)??[25,50,100],this.showSizePicker=(e==null?void 0:e.showSizePicker)??!0}}class Lt{constructor(r){i(this,"field");i(this,"direction");this.field=(r==null?void 0:r.field)??"",this.direction=(r==null?void 0:r.direction)??"asc"}}class _t{static defaultDateRanges(){const r=g.addBusinessDays(new Date,1);return{nextWorkingDay:{label:"Следующий рабочий день",from:g.startOfDay(r),to:g.endOfDay(r)},today:{label:"Сегодня",from:g.startOfToday(),to:g.endOfToday()},yesterday:{label:"Вчера",from:g.startOfYesterday(),to:g.endOfYesterday()},tomorrow:{label:"Завтра",from:g.startOfTomorrow(),to:g.endOfTomorrow()}}}}class hr{static productIsMeasurable(r){return r.unit.isLinear||r.unit.isSquare}static getProductMultiplicity(r){var e,t;return!((e=r.properties)!=null&&e.ignoreMinCountCheck)&&((t=r.properties)!=null&&t.minCount)&&!hr.productIsMeasurable(r)?r.properties.minCount:1}static getProductLengthMultiplicity(r){var e,t,s;return(e=r.properties)!=null&&e.lengthStep?r.properties.lengthStep:!((t=r.properties)!=null&&t.ignoreMinCountCheck)&&((s=r.properties)!=null&&s.minCount)?r.properties.minCount:.01}}const he=class he extends y{constructor(){super();i(this,"responseDataCacheTimeout");this.responseDataCacheTimeout=b().config.http.responseDataCacheTimeout}static getCachedResponse(e){const t=he.responseDataCache.get(e);if(t&&t.validTo>new Date)return t.val}cacheResponse(e,t){he.responseDataCache.set(e,{validTo:g.addSeconds(new Date,this.responseDataCacheTimeout),val:t})}getTypedDataArrayRequester(e,t,s=!1,o={},l=void 0){const h=t+(u.isEmpty(o)?"":` >>> ${JSON.stringify(o)}`),f=s?he.getCachedResponse(h):void 0;return f?Promise.resolve(f):this.get(t,o,void 0,!1,l).then(C=>{const v=C.map(R=>be.instanceInitializer(e,R));return s&&v&&this.cacheResponse(t,v),v})}};i(he,"responseDataCache",new Map);let pe=he;function qt(n,r){const e=[2,0,1,1,1,2];return r[n%100>4&&n%100<20?2:e[Math.min(n%10,5)]]}class Nt{static generateUndefinedManagerInstance(){return new oe({id:0,name:"- Не назначен -",isActive:!0,guid:"-undefined-"})}static isUndefinedManagerInstance(r){return r.id===0&&r.guid==="-undefined-"}}class Kr extends pe{async getManagers(){const r="/internal/managers",e=pe.getCachedResponse(r);if(e)return e;const s=(await this.get(r)).data.map(o=>be.instanceInitializer(oe,o));return this.cacheResponse(r,s),s}}class gr extends M{constructor(e){super(e);i(this,"name");i(this,"createdAt");i(this,"client");i(this,"sum");this.name=e==null?void 0:e.name,this.createdAt=u.isString(e==null?void 0:e.createdAt)?g.parseISO(e.createdAt):(e==null?void 0:e.createdAt)??new Date,this.client=new F(e==null?void 0:e.client),this.sum=e==null?void 0:e.sum}}class ee extends gr{constructor(e){super(e);i(this,"sum");i(this,"products");this.sum=e.sum??0,this.products=(e.products??[]).map(t=>new Nr(t))}}class Ut extends ve{constructor(e){super();i(this,"id");i(this,"clientSearchTerm");i(this,"name");i(this,"createdAt",new A);this.id=e==null?void 0:e.id,this.clientSearchTerm=e==null?void 0:e.clientSearchTerm,this.name=e==null?void 0:e.name,this.createdAt=new A(e==null?void 0:e.createdAt)}resetFilterValue(e){return e==="createdAt"?(this.createdAt.from=null,this.createdAt.to=null):this[e]=void 0,this}asClearRaw(){var t,s;const e=super.asClearRaw();return!((t=e==null?void 0:e.createdAt)!=null&&t.from)&&!((s=e==null?void 0:e.createdAt)!=null&&s.to)&&delete e.createdAt,e}}class Pe extends a{}class mr extends pr{constructor(e){var t,s,o,l,h,f,C,v;super(e);i(this,"client");i(this,"payment");i(this,"delivery");i(this,"attachedUser");i(this,"status");i(this,"statusDetail");i(this,"salesDirection");i(this,"attachedAt");i(this,"isOnOrder");i(this,"isNotInStock");i(this,"sum");i(this,"isLargeOrder");this.client=new F(e==null?void 0:e.client),this.payment={type:((t=e==null?void 0:e.payment)==null?void 0:t.type)??-1,status:((s=e==null?void 0:e.payment)==null?void 0:s.status)??-1,onlinePaymentLink:(o=e==null?void 0:e.payment)==null?void 0:o.onlinePaymentLink},this.delivery={type:((l=e==null?void 0:e.delivery)==null?void 0:l.type)??-1,date:u.isString((h=e==null?void 0:e.delivery)==null?void 0:h.date)?g.parseISO(e.delivery.date):((f=e==null?void 0:e.delivery)==null?void 0:f.date)??new Date,address:(C=e==null?void 0:e.delivery)!=null&&C.address?new ue(e.delivery.address):void 0,warehouse:(v=e==null?void 0:e.delivery)!=null&&v.warehouse?new te(e.delivery.warehouse):void 0},this.attachedUser=e!=null&&e.attachedUser?new I(e==null?void 0:e.attachedUser):void 0,this.status=new Pe(e==null?void 0:e.status),this.statusDetail=e!=null&&e.statusDetail?new a(e.statusDetail):void 0,this.salesDirection=new O(e==null?void 0:e.salesDirection),this.attachedAt=u.isString(e==null?void 0:e.attachedAt)?g.parseISO(e.attachedAt):e==null?void 0:e.attachedAt,this.isOnOrder=(e==null?void 0:e.isOnOrder)??!1,this.isNotInStock=(e==null?void 0:e.isNotInStock)??!1,this.sum=(e==null?void 0:e.sum)??0,this.isLargeOrder=(e==null?void 0:e.isLargeOrder)??!1}}class Qr extends Ve{constructor(e,t){super(e);i(this,"product");i(this,"cost");i(this,"costOne");i(this,"costOneRub");i(this,"costRub");i(this,"logicGroupId");i(this,"salesDirection");i(this,"specificationImgUrl");i(this,"sawing");i(this,"currency");i(this,"changedFields",[]);i(this,"replacement");this.product=new j(e.product),this.currency=new L(e.currency),this.cost=e.cost,this.costOne=e.costOne,this.costOneRub=e.costOneRub,this.costRub=e.costRub,this.logicGroupId=e.logicGroupId,this.salesDirection=e.salesDirection,this.specificationImgUrl=e.specificationImgUrl,this.sawing=e.sawing,t&&(this.replacement=t,this.quantity!==t.quantity&&this.changedFields.push("quantity"),this.length!==t.length&&this.changedFields.push("length"))}}class $ extends mr{constructor(e){var t;super(e);i(this,"products");i(this,"invoices");i(this,"comment");i(this,"image");i(this,"contragent");i(this,"barcode");i(this,"orderSource");i(this,"isAllowProcessingWithoutPayment");i(this,"nextStatuses");i(this,"actions");i(this,"operatorsComment");i(this,"operatorsForWarehouseComment");i(this,"erpOrderUrl");this.products=(e.products??[]).map(s=>{var l;const o=s.replacementId?(l=e.products)==null?void 0:l.find(h=>h.id===s.replacementId):void 0;return new Qr(s,o)}),this.invoices=e.invoices??[],this.comment=e.comment,this.image=e.image,this.contragent=e.contragent?Ce.createInstance(e.contragent):void 0,this.barcode=e.barcode,this.orderSource=e.orderSource?new a(e.orderSource):void 0,this.isAllowProcessingWithoutPayment=e.isAllowProcessingWithoutPayment,this.nextStatuses=(t=e.nextStatuses)==null?void 0:t.map(s=>new Pe(s)),this.actions=e.actions,this.operatorsComment=e.operatorsComment,this.operatorsForWarehouseComment=e.operatorsForWarehouseComment,this.erpOrderUrl=e.erpOrderUrl}}class Ht extends x{getOffers(r,e,t,s=void 0){return this.getPaginated("/internal/orders/offers",r,e,t,{},o=>{const l={...o.data};return l.data=l.data.map(h=>new gr(h)),l},void 0,s)}createOfferFromCart(r,e,t){return this.post(`/internal/orders/offers/${r}`,{name:e,items:t!=null&&t.length?t:void 0},s=>new ee(s.data))}getOffer(r){return this.get(`/internal/orders/offers/${r}`,{},e=>new ee(e.data))}updateOffer(r,e){return this.patch(`/internal/orders/offers/${r}`,{name:e},t=>new ee(t.data))}deleteOffer(r){return this.delete(`/internal/orders/offers/${r}`)}createOrderFromDraft(r,e,t,s={}){const o=b().config.dateFormats.api;return this.post(`/internal/orders/offers/${r}/create-order`,{...e,deliveryDate:e.deliveryDate?g.format(e.deliveryDate,o):void 0,items:t!=null&&t.length?t:void 0},l=>l.data.map(h=>new $(h)),s)}addOfferProduct(r,e,t={}){return this.post(`/internal/orders/offers/${r}/products`,{product_id:e.product.id,product_category_id:e.configurator?e.category.id:void 0,quantity:e.quantity,height:e.height,length:e.length,width:e.width,configurator:e.configurator,marker:e.marker,is_additional_sale:e.isAdditionalSale,...e.configuratorParams},s=>new ee(s.data),t)}patchOfferProduct(r,e,t,s={}){return this.patch(`/internal/orders/offers/${r}/products/${e}`,{product_id:t.product.id,product_category_id:t.configurator?t.category.id:void 0,quantity:t.quantity,height:t.height,length:t.length,width:t.width,configurator:t.configurator,marker:t.marker,...t.configuratorParams},o=>new ee(o.data),s)}deleteOfferProduct(r,e){return this.delete(`/internal/orders/offers/${r}/products/${e}`,t=>new ee(t.data))}getOfferHtml(r,e){return this.get(`/internal/orders/offers/${r}/view`,e?{recipientText:e}:{},t=>new Blob([t.data],{type:"text/html"}))}getOfferPdf(r,e){return this.getBlob(`/internal/orders/offers/${r}/download`,e?{recipientText:e}:{},t=>new Blob([t.request.response],{type:"application/pdf"}))}sendOffer(r,e){return this.post(`/internal/orders/offers/${r}/send`,e)}}var Yr=(n=>(n.View="view",n.Share="share",n.EditTags="edit_tags",n.SaveOrderIgnoredProducts="save_order_ignored_products",n.ChangeStatus="change_status",n.ChangeProducts="change_products",n.ChangeOrderParameters="change_order_parameters",n.Recalculate="recalculate",n.AttachOrder="attach_order",n.DetachOrder="detach_order",n.ChangeAttachedOperator="change_attached_operator",n.SendOnlinePaymentLink="send_online_payment_link",n.ConfirmOnlineFullPayment="confirm_online_full_payment",n.MergeOrders="merge_orders",n.GetHistory="get_history",n.CloneOrder="clone_order",n.DeleteAttachedFile="delete_attached_file",n))(Yr||{});class Bt{constructor(r){i(this,"paymentType");i(this,"deliveryType");i(this,"contragentId");i(this,"deliveryDate");i(this,"addressId");i(this,"warehouseId");i(this,"image");i(this,"comment");i(this,"barcode");i(this,"operatorsComment");i(this,"operatorsForWarehouseComment");i(this,"additionalEmails");i(this,"isAllowProcessingWithoutPayment");i(this,"isAdditionalSale");var e,t,s;this.paymentType=r==null?void 0:r.payment.type,this.deliveryType=r==null?void 0:r.delivery.type,this.contragentId=(e=r==null?void 0:r.contragent)==null?void 0:e.id,this.deliveryDate=r!=null&&r.delivery.date?new Date(r.delivery.date):void 0,this.addressId=(t=r==null?void 0:r.delivery.address)==null?void 0:t.id,this.warehouseId=(s=r==null?void 0:r.delivery.warehouse)==null?void 0:s.id,this.comment=r==null?void 0:r.comment,this.barcode=r==null?void 0:r.barcode,this.operatorsComment=r==null?void 0:r.operatorsComment,this.operatorsForWarehouseComment=r==null?void 0:r.operatorsForWarehouseComment,this.isAllowProcessingWithoutPayment=r==null?void 0:r.isAllowProcessingWithoutPayment}}class fr extends a{}class yr extends a{}class Mt extends ve{constructor(e){var t,s,o,l;super();i(this,"attachedUsers");i(this,"clientSearchTerm");i(this,"client");i(this,"contragent");i(this,"createdAt",new A);i(this,"creator");i(this,"deliveryDate",new A);i(this,"deliveryAddressSearch");i(this,"clientCities");i(this,"id");i(this,"isApproved");i(this,"isNotInStock");i(this,"isOnOrder");i(this,"attachedAt",new A);i(this,"salesDirections");i(this,"status");i(this,"statusDetail");i(this,"deliveryType");i(this,"paymentType");i(this,"warehouses");i(this,"isLargeOrder");i(this,"isToProcess");i(this,"onlyMyRegions");this.attachedUsers=(t=e==null?void 0:e.attachedUsers)==null?void 0:t.map(h=>"isActive"in h?new oe(h):new fr(h)),this.clientSearchTerm=e==null?void 0:e.clientSearchTerm,this.client=e!=null&&e.client?new F(e.client):void 0,this.contragent=e==null?void 0:e.contragent,this.createdAt=new A(e==null?void 0:e.createdAt),this.creator=e!=null&&e.creator?new I(e.creator):void 0,this.deliveryDate=new A(e==null?void 0:e.deliveryDate),this.deliveryAddressSearch=e==null?void 0:e.deliveryAddressSearch,this.clientCities=(s=e==null?void 0:e.clientCities)==null?void 0:s.map(h=>new Y(h)),this.id=e==null?void 0:e.id,this.isApproved=e==null?void 0:e.isApproved,this.isNotInStock=e==null?void 0:e.isNotInStock,this.isOnOrder=e==null?void 0:e.isOnOrder,this.isLargeOrder=e==null?void 0:e.isLargeOrder,this.attachedAt=new A(e==null?void 0:e.attachedAt),this.salesDirections=(o=e==null?void 0:e.salesDirections)==null?void 0:o.map(h=>new O(h)),this.status=e==null?void 0:e.status,this.statusDetail=e==null?void 0:e.statusDetail,this.deliveryType=e!=null&&e.deliveryType?new q(e.deliveryType):void 0,this.paymentType=e!=null&&e.paymentType?new yr(e.paymentType):void 0,this.warehouses=(l=e==null?void 0:e.warehouses)==null?void 0:l.map(h=>new te(h)),this.isToProcess=e==null?void 0:e.isToProcess}resetFilterValue(e){switch(e){case"createdAt":this.createdAt.from=null,this.createdAt.to=null;break;case"creator":this.creator=void 0;break;case"deliveryDate":this.deliveryDate.from=null,this.deliveryDate.to=null;break;case"deliveryType":this.deliveryType=new q;break;case"clientCities":this.clientCities=[];break;case"attachedAt":this.attachedAt.from=null,this.attachedAt.to=null;break;case"salesDirection":this.salesDirections=[];break;case"status":this.status=[];break;case"warehouse":this.warehouses=[];break;default:this[e]=void 0;break}return this}asClearRaw(){var t,s,o,l,h,f;const e=super.asClearRaw();return!((t=e==null?void 0:e.createdAt)!=null&&t.from)&&!((s=e==null?void 0:e.createdAt)!=null&&s.to)&&delete e.createdAt,!((o=e==null?void 0:e.deliveryDate)!=null&&o.from)&&!((l=e==null?void 0:e.deliveryDate)!=null&&l.to)&&delete e.deliveryDate,!((h=e==null?void 0:e.attachedAt)!=null&&h.from)&&!((f=e==null?void 0:e.attachedAt)!=null&&f.to)&&delete e.attachedAt,e}}class Xr{constructor(r){i(this,"user");i(this,"status");i(this,"statusDetail");i(this,"createdAt");this.user=new I(r==null?void 0:r.user),this.status=new Pe(r==null?void 0:r.status),this.statusDetail=r!=null&&r.statusDetail?new a(r.statusDetail):void 0,this.createdAt=u.isString(r==null?void 0:r.createdAt)?g.parseISO(r.createdAt):(r==null?void 0:r.createdAt)??new Date}}class jt extends x{getOrders(r,e,t,s=void 0){return this.getPaginated("/internal/orders",r,e,t,{},o=>{const l={...o.data};return l.data=l.data.map(h=>new mr(h)),l},void 0,s)}getOrdersCount(r,e=void 0){return this.get("/internal/orders/count",r?{filters:JSON.stringify((r instanceof G?r:new G(r)).toPrimitive())}:{},void 0,void 0,e).then(t=>t.count)}getClientOrderStatistics(r,e){return this.get(`/internal/clients/${r}/orders/statistics`,e?{period:e}:{})}getOrder(r){return this.get(`/internal/orders/${r}`,{},e=>new $(e.data))}createClientOrder(r,e,t,s,o={}){const l=b().config.dateFormats.api;return this.post(`/internal/clients/${r}/orders/${e}`,{...t,deliveryDate:g.format(t.deliveryDate,l),items:s!=null&&s.length?s:void 0},h=>h.data.map(f=>new $(f)),o)}attachOrder(r){return this.patch(`/internal/orders/${r}/attach`,{},e=>new $(e.data))}detachOrder(r){return this.patch(`/internal/orders/${r}/detach`,{},e=>new $(e.data))}mergeOrders(r,e){return this.patch(`/internal/orders/${r}/merge`,{ids:e},t=>new $(t.data))}recalculateOrder(r){return this.patch(`/internal/orders/${r}/recalculate`,{},e=>new $(e.data))}cloneOrder(r){return this.get(`/internal/orders/${r}/clone`,{})}updateOrder(r,e,t={}){const s=b().config.dateFormats.api;return this.patch(`/internal/orders/${r}`,{...e,deliveryDate:e.deliveryDate?g.format(e.deliveryDate,s):void 0},o=>new $(o.data),t)}addOrderProduct(r,e,t={}){return this.post(`/internal/orders/${r}/products`,{product_id:e.product.id,product_category_id:e.configurator?e.category.id:void 0,quantity:e.quantity,height:e.height,length:e.length,width:e.width,configurator:e.configurator,marker:e.marker,is_additional_sale:e.isAdditionalSale,...e.configuratorParams},s=>new $(s.data),t)}changeOrderStatus(r,e,t,s={}){return this.patch(`/internal/orders/${r}/status`,{status:e,statusDetail:t},o=>new $(o.data),s)}changeOrderStatusDetail(r,e){return this.patch(`/internal/orders/${r}/status`,{statusDetail:e},t=>new $(t.data))}getOrderStatusHistory(r){return this.get(`/internal/orders/${r}/history`,{},e=>e.data.map(t=>new Xr(t)))}getOrderPrintHtml(r,e){return this.get(`/internal/orders/${r}/print/view`,{...e},t=>new Blob([t.data],{type:"text/html"}))}getOrderPrintPdf(r,e){return this.getBlob(`/internal/orders/${r}/print/download`,{...e},t=>new Blob([t.request.response],{type:"application/pdf"}))}sendOrderPrint(r,e){return this.post(`/internal/orders/${r}/print/send`,e)}changeAttachedOperator(r,e){return this.patch(`/internal/orders/${r}/change-attached-operator`,{operatorId:e},t=>new $(t.data))}deleteOrderAttachedFile(r){return this.delete(`/internal/orders/${r}/file/attached`,e=>new $(e.data))}deleteOrderProduct(r,e){return this.delete(`/internal/orders/${r}/products/${e}`,t=>new $(t.data))}patchOrderProduct(r,e,t,s={}){return this.patch(`/internal/orders/${r}/products/${e}`,{product_id:t.product.id,product_category_id:t.configurator?t.category.id:void 0,quantity:t.quantity,height:t.height,length:t.length,width:t.width,configurator:t.configurator,marker:t.marker,...t.configuratorParams},o=>new $(o.data),s)}getDeliveryNearestDates(r,e=void 0){return this.get(`/internal/orders/delivery/${r}/nearest-dates`,{},t=>t.data,void 0,e)}getSelfDeliveryNearestDates(r,e=void 0){return this.get(`/internal/orders/self-delivery/${r}/nearest-dates`,{},t=>t.data,void 0,e)}getDeliveryCost(r,e,t,s=void 0){const o=b().config.dateFormats.api;return this.get(`/internal/orders/delivery/${r}/cost`,{date:g.format(e,o),warehouse_id:t},l=>l.data,void 0,s)}}class He{constructor(r){i(this,"client");i(this,"product");i(this,"cost");i(this,"costCoefficient");i(this,"source");this.client=new F(r==null?void 0:r.client),this.product=new k(r==null?void 0:r.product),this.cost=(r==null?void 0:r.cost)??0,this.costCoefficient=(r==null?void 0:r.costCoefficient)??0,this.source=(r==null?void 0:r.source)??$e.Product}}const wr=n=>{var r,e,t,s,o;return n?u.omitBy({cities:(r=n.cities)==null?void 0:r.map(l=>l.id),clients:(e=n.clients)==null?void 0:e.map(l=>l.id),managers:(t=n.managers)==null?void 0:t.map(l=>l.id),partnerGroups:(s=n.partnerGroups)==null?void 0:s.map(l=>l.id),salesDirections:(o=n.salesDirections)==null?void 0:o.map(l=>l.id),hideNotActive:n.hideNotActive},l=>u.isNil(l)||(u.isArray(l)||u.isObject(l))&&u.isEmpty(l)):{}},Zr=n=>{const r={};return n.from&&(n.from.coefficient||n.from.value)&&(r.from={},n.from.coefficient&&(r.from.priceCoefficientId=n.from.coefficient.id),n.from.value&&(r.from.increasePercent=n.from.value)),n.to&&(n.to.coefficient||n.to.value)&&(r.to={},n.to.coefficient&&(r.to.priceCoefficientId=n.to.coefficient.id),n.to.value&&(r.to.increasePercent=n.to.value)),r};class Ft extends y{analyzeProductPrices(r,e,t){return this.get(`/internal/price/products/${r}/analyze`,{...Zr(e),filters:wr(t)},s=>s.data.map(o=>new He(o)))}analyzeCategoryPrices(r,e,t){return this.get(`/internal/price/categories/${r}/analyze`,{...Zr(e),filters:wr(t)},s=>s.data.map(o=>new He(o)))}analyzeCategoryPricesBySquare(r,e,t){return this.get(`/internal/price/categories/${r}/analyze/square`,{...e,filters:wr(t)},s=>s.data.map(o=>new He(o)))}}class xr{constructor(r){i(this,"cost");i(this,"isLowCost");i(this,"isRetail");i(this,"costDate");i(this,"discountName");i(this,"priceTemplateName");i(this,"product");i(this,"client");i(this,"executor");i(this,"currency");this.cost=r.cost??0,this.isLowCost=r.isLowCost??!1,this.isRetail=r.isRetail??!1,this.costDate=u.isString(r.costDate)?g.parseISO(r.costDate):r.costDate??new Date,this.discountName=r.discountName,this.priceTemplateName=r.priceTemplateName,this.product=r.product?new ie(r.product):void 0,this.client=r.client?new I(r.client):void 0,this.executor=r.executor?new I(r.executor):void 0,this.currency=r.currency?new L(r.currency):void 0}}class Er extends ie{constructor(e){super(e);i(this,"history");this.history=u.map(e.history,t=>new xr(t))}}class Gt extends y{getProductPriceHistory(r){var o,l,h,f,C;const e=b().config.dateFormats.api,t=u.omitBy(u.merge(r,{costDate:{from:u.isDate((o=r.costDate)==null?void 0:o.from)?g.format(r.costDate.from,e):(l=r.costDate)==null?void 0:l.from,to:u.isDate((h=r.costDate)==null?void 0:h.to)?g.format(r.costDate.to,e):(f=r.costDate)==null?void 0:f.to}}),v=>u.isNil(v)||(u.isArray(v)||u.isObject(v))&&u.isEmpty(v)),s=((C=r.product)==null?void 0:C[0])??0;return delete t.product,this.get(`/internal/price/products/${s}/history`,t).then(v=>[new Er(u.merge(v[0],{history:v}))])}}class ar{constructor(r){i(this,"products",[]);i(this,"productCategories",[]);r!=null&&r.products&&(this.products=r.products.map(e=>new ie(e))),r!=null&&r.productCategories&&(this.productCategories=r.productCategories.map(e=>new ie(e)))}}class Wt extends y{getProductCategoryRecommendations(r){return this.get(`/internal/catalog/recommendations/categories/${r.id}`,{},e=>new ar(e.data))}getProductRecommendations(r){return this.get(`/internal/catalog/recommendations/products/${r.id}`,{},e=>new ar(e.data))}saveProductCategoryRecommendations(r,e){return this.post(`/internal/catalog/recommendations/categories/${r.id}`,{product_categories:e.productCategories.map(t=>t.id),products:e.products.map(t=>t.id)})}saveProductRecommendations(r,e){return this.post(`/internal/catalog/recommendations/products/${r.id}`,{product_categories:e.productCategories.map(t=>t.id),products:e.products.map(t=>t.id)})}}var et=(n=>(n.New="new",n.Processing="processing",n.AwaitingSupplyProducts="awaiting_supply_products",n.InvoiceIssued="invoice_issued",n.ProcessingOnStock="processing_on_stock",n.Finished="finished",n.OrderUpdated="order_updated",n.Canceled="canceled",n.Error="error",n))(et||{}),rt=(n=>(n.CanceledBy1c="canceled_by1c",n.CanceledByClient="canceled_by_client",n.FinishedNotApproved="finished_not_approved",n.ProcessingByPurchasingDepartment="processing_by_purchasing_department",n.WillWaiting="will_waiting",n))(rt||{});class tt extends a{}class it extends a{}class Be extends T{constructor(e){super(e);i(this,"abbr");this.abbr=(e==null?void 0:e.abbr)??""}}class Cr extends a{constructor(e){var t;super(e);i(this,"userRegions");this.userRegions=((t=e==null?void 0:e.userRegions)==null?void 0:t.map(s=>new Be(s)))??[]}}class st extends a{}class nt extends a{}class ot extends a{}class ct extends a{}class zt{static generateUndefinedInstance(r,e="- Не определён -"){return new r({id:0,name:e,slug:"-undefined-"})}static isUndefinedInstance(r){return r.id===0&&r.slug==="-undefined-"}}class vr extends a{}const H=class H extends pe{static withoutUnknownLocation(r){return r.filter(e=>e.id!==H.unknownLocationId)}getReference(r,e=!1){return this.getTypedDataArrayRequester(tt,`/internal/references/${r}`,e)}getChannelPrimaryInterest(){return this.getTypedDataArrayRequester(cr,"/internal/references/channel-primary-interest",!0)}getContactPositions(){return this.getTypedDataArrayRequester(st,"/internal/references/contact-position",!0)}getCuratedDirection(){return this.getTypedDataArrayRequester(Ie,"/internal/references/curated-direction",!0)}getCurrency(){return this.getTypedDataArrayRequester(L,"/public/references/currency",!0)}getPartnerGroup(){return this.getTypedDataArrayRequester(E,"/internal/references/partner-group",!0)}getOpf(){return this.getTypedDataArrayRequester(z,"/public/references/opf",!0)}getOperators(){return this.getTypedDataArrayRequester(fr,"/internal/references/operator",!0)}getOrderPaymentStatuses(){return this.getTypedDataArrayRequester(nt,"/public/references/order-payment-status",!0)}getOrderStatuses(){return this.getTypedDataArrayRequester(Pe,"/internal/references/order-status",!0)}getOrderStatusDetails(){return this.getTypedDataArrayRequester(ot,"/internal/references/order-status-detail",!0)}getPaymentTypes(){return this.getTypedDataArrayRequester(yr,"/public/references/payment-type",!0)}getResourceTypes(){return this.getTypedDataArrayRequester(vr,"/internal/references/resource-type",!0)}getSalesDirections(){return this.getTypedDataArrayRequester(O,"/public/references/sales-direction",!0)}getSourcePrimaryInterest(){return this.getTypedDataArrayRequester(lr,"/internal/references/source-primary-interest",!0)}searchCity(r){return this.getTypedDataArrayRequester(Y,`/internal/references/city-with-region-and-country/search?term=${r}`)}searchRegion(r){return this.getTypedDataArrayRequester(Q,`/internal/references/region-with-country/search?term=${r}`)}getRegionsByCountry(r){return this.getTypedDataArrayRequester(Q,"/internal/references/region",!1,{params:{countryId:r}}).then(e=>H.withoutUnknownLocation(e))}getCitiesByRegion(r){return this.getTypedDataArrayRequester(it,"/internal/references/city",!1,{params:{regionId:r}}).then(e=>H.withoutUnknownLocation(e))}getCitiesWithUserRegionByRegion(r){return this.getTypedDataArrayRequester(Cr,"/internal/references/city-with-user-region",!1,{params:{regionId:r}}).then(e=>H.withoutUnknownLocation(e))}searchCityWithRegion(r,e,t=void 0){return this.getTypedDataArrayRequester(Y,"/internal/references/city-with-region/search",!1,{term:r,...e?{params:{countryId:e}}:{}},t).then(s=>H.withoutUnknownLocation(s))}searchCityWithUserRegion(r,e=void 0){return this.getTypedDataArrayRequester(Cr,"/internal/references/city-with-user-region/search",!1,{term:r},e).then(t=>H.withoutUnknownLocation(t))}searchCountry(r){return this.getTypedDataArrayRequester(K,`/internal/references/country/search?term=${r}`)}getDeliveryTypes(){return this.getTypedDataArrayRequester(q,"/internal/references/delivery-type",!0)}getWarehouses(){return this.getTypedDataArrayRequester(te,"/public/references/warehouse",!0)}getPropertyTypes(){return this.getTypedDataArrayRequester(Ze,"/internal/references/property-type",!0)}getPriceCoefficients(){return this.getTypedDataArrayRequester(we,"/internal/references/price-coefficient",!0)}getProductFileType(){return this.getTypedDataArrayRequester(ct,"/public/references/product-file-type",!0)}};i(H,"unknownLocationId",1);let D=H;const S=J.defineStore("common.references_private",()=>{const n=m.ref({}),r=m.ref(void 0),e=m.ref(void 0),t=m.ref(void 0),s=m.ref(void 0),o=m.ref(void 0),l=m.ref(void 0),h=m.ref(void 0),f=m.ref(void 0),C=m.ref(void 0),v=m.ref(void 0),R=m.ref(void 0),Re=m.ref(void 0),De=m.ref(void 0),ge=m.ref(void 0),me=m.ref(void 0),Rr=m.ref(void 0),Dr=m.ref(void 0),Ar=m.ref(void 0),p=m.ref(void 0);return{dataLoaderList:n,channelPrimaryInterestReference:r,contactPositionsReference:e,currencyReference:t,deliveryTypeReference:s,managersList:o,opfReference:l,operatorReference:h,orderPaymentStatusReference:f,orderStatusReference:C,orderStatusDetailReference:v,paymentTypeReference:R,partnerGroupReference:Re,productFileTypeReference:De,resourceTypesReference:ge,salesDirectionsReference:me,sourcePrimaryInterestReference:Rr,warehousesReference:Dr,propertyTypesReference:Ar,priceCoefficientsReference:p}}),Jt=J.defineStore("common.references",()=>{const n=m.computed(()=>{const p=S();return!p.channelPrimaryInterestReference&&!p.dataLoaderList.channelPrimaryInterestReference&&(p.dataLoaderList.channelPrimaryInterestReference=!0,y.getInstance(D).getChannelPrimaryInterest().then(w=>{p.channelPrimaryInterestReference=w}).catch(u.noop)),p.channelPrimaryInterestReference}),r=m.computed(()=>{const p=S();return!p.contactPositionsReference&&!p.dataLoaderList.contactPositionsReference&&(p.dataLoaderList.contactPositionsReference=!0,y.getInstance(D).getContactPositions().then(w=>{p.contactPositionsReference=w}).catch(u.noop)),p.contactPositionsReference}),e=m.computed(()=>{const p=S();return!p.currencyReference&&!p.dataLoaderList.currencyReference&&(p.dataLoaderList.currencyReference=!0,y.getInstance(D).getCurrency().then(w=>{p.currencyReference=w}).catch(u.noop)),p.currencyReference}),t=m.computed(()=>{const p=S();return!p.opfReference&&!p.dataLoaderList.opfReference&&(p.dataLoaderList.opfReference=!0,y.getInstance(D).getOpf().then(w=>{p.opfReference=w}).catch(u.noop)),p.opfReference}),s=m.computed(()=>{const p=S();return!p.operatorReference&&!p.dataLoaderList.operatorReference&&(p.dataLoaderList.operatorReference=!0,y.getInstance(D).getOperators().then(w=>{p.operatorReference=w}).catch(u.noop)),p.operatorReference}),o=m.computed(()=>{const p=S();return!p.orderPaymentStatusReference&&!p.dataLoaderList.orderPaymentStatusReference&&(p.dataLoaderList.orderPaymentStatusReference=!0,y.getInstance(D).getOrderPaymentStatuses().then(w=>{p.orderPaymentStatusReference=w}).catch(u.noop)),p.orderPaymentStatusReference}),l=m.computed(()=>{const p=S();return!p.orderStatusReference&&!p.dataLoaderList.orderStatusReference&&(p.dataLoaderList.orderStatusReference=!0,y.getInstance(D).getOrderStatuses().then(w=>{p.orderStatusReference=w}).catch(u.noop)),p.orderStatusReference}),h=m.computed(()=>{const p=S();return!p.orderStatusDetailReference&&!p.dataLoaderList.orderStatusDetailReference&&(p.dataLoaderList.orderStatusDetailReference=!0,y.getInstance(D).getOrderStatusDetails().then(w=>{p.orderStatusDetailReference=w}).catch(u.noop)),p.orderStatusDetailReference}),f=m.computed(()=>{const p=S();return!p.paymentTypeReference&&!p.dataLoaderList.paymentTypeReference&&(p.dataLoaderList.paymentTypeReference=!0,y.getInstance(D).getPaymentTypes().then(w=>{p.paymentTypeReference=w}).catch(u.noop)),p.paymentTypeReference}),C=m.computed(()=>{const p=S();return!p.partnerGroupReference&&!p.dataLoaderList.partnerGroupReference&&(p.dataLoaderList.partnerGroupReference=!0,y.getInstance(D).getPartnerGroup().then(w=>{p.partnerGroupReference=w}).catch(u.noop)),p.partnerGroupReference}),v=m.computed(()=>{const p=S();return!p.productFileTypeReference&&!p.dataLoaderList.productFileTypeReference&&(p.dataLoaderList.productFileTypeReference=!0,y.getInstance(D).getProductFileType().then(w=>{p.productFileTypeReference=w}).catch(u.noop)),p.productFileTypeReference}),R=m.computed(()=>{const p=S();return!p.resourceTypesReference&&!p.dataLoaderList.resourceTypesReference&&(p.dataLoaderList.resourceTypesReference=!0,y.getInstance(D).getResourceTypes().then(w=>{p.resourceTypesReference=w}).catch(u.noop)),p.resourceTypesReference}),Re=m.computed(()=>{const p=S();return!p.salesDirectionsReference&&!p.dataLoaderList.salesDirectionsReference&&(p.dataLoaderList.salesDirectionsReference=!0,y.getInstance(D).getSalesDirections().then(w=>{p.salesDirectionsReference=w}).catch(u.noop)),p.salesDirectionsReference}),De=m.computed(()=>{const p=S();return!p.sourcePrimaryInterestReference&&!p.dataLoaderList.sourcePrimaryInterestReference&&(p.dataLoaderList.sourcePrimaryInterestReference=!0,y.getInstance(D).getSourcePrimaryInterest().then(w=>{p.sourcePrimaryInterestReference=w}).catch(u.noop)),p.sourcePrimaryInterestReference}),ge=m.computed(()=>{const p=S();return!p.deliveryTypeReference&&!p.dataLoaderList.deliveryTypeReference&&(p.dataLoaderList.deliveryTypeReference=!0,y.getInstance(D).getDeliveryTypes().then(w=>{p.deliveryTypeReference=w}).catch(u.noop)),p.deliveryTypeReference}),me=m.computed(()=>{const p=S();return!p.managersList&&!p.dataLoaderList.managersList&&(p.dataLoaderList.managersList=!0,y.getInstance(Kr).getManagers().then(w=>{p.managersList=w}).catch(u.noop)),p.managersList}),Rr=m.computed(()=>{const p=S();return!p.warehousesReference&&!p.dataLoaderList.warehousesReference&&(p.dataLoaderList.warehousesReference=!0,y.getInstance(D).getWarehouses().then(w=>{p.warehousesReference=w}).catch(u.noop)),p.warehousesReference}),Dr=m.computed(()=>{const p=S();return!p.propertyTypesReference&&!p.dataLoaderList.propertyTypesReference&&(p.dataLoaderList.propertyTypesReference=!0,y.getInstance(D).getPropertyTypes().then(w=>{p.propertyTypesReference=w}).catch(u.noop)),p.propertyTypesReference}),Ar=m.computed(()=>{const p=S();return!p.priceCoefficientsReference&&!p.dataLoaderList.priceCoefficientsReference&&(p.dataLoaderList.priceCoefficientsReference=!0,y.getInstance(D).getPriceCoefficients().then(w=>{p.priceCoefficientsReference=w}).catch(u.noop)),p.priceCoefficientsReference});return{channelPrimaryInterestsReference:n,contactPositionsReference:r,currencyReference:e,opfReference:t,operatorReference:s,orderPaymentStatusReference:o,orderStatusReference:l,orderStatusDetailReference:h,paymentTypeReference:f,partnerGroupsReference:C,productFilesTypesReference:v,resourceTypesReference:R,salesDirectionsReference:Re,sourcePrimaryInterestsReference:De,deliveryTypeReference:ge,managersList:me,warehousesReference:Rr,propertyTypesReference:Dr,priceCoefficientsReference:Ar}});class lt{constructor(r){i(this,"name");i(this,"content");this.name=r.name,this.content=r.content}}class Pr{constructor(r){i(this,"resourceType");i(this,"resourceId");i(this,"h1");i(this,"title");i(this,"description");i(this,"keywords");i(this,"meta");i(this,"tags");var e;this.resourceType=new vr(r==null?void 0:r.resourceType),this.resourceId=(r==null?void 0:r.resourceId)??"",this.h1=r==null?void 0:r.h1,this.title=r==null?void 0:r.title,this.description=r==null?void 0:r.description,this.keywords=r==null?void 0:r.keywords,this.meta=((e=r==null?void 0:r.meta)==null?void 0:e.map(t=>new lt(t)))??[],this.tags=r==null?void 0:r.tags}}class Vt extends y{getResourceSeoData(r,e){return this.get(`/internal/seo/${r.slug}/${e}`,{},t=>new Pr(t.data))}saveResourceSeoData(r,e={}){return this.post(`/internal/seo/${r.resourceType.slug}/${r.resourceId}`,r,t=>new Pr(t.data),e)}deleteResourceSeoData(r,e){return this.delete(`/internal/seo/${r.slug}/${e}`)}}class Kt extends y{searchAddresses(r){return this.execSuggestionQuery("/public/suggestions/address",r)}searchBank(r){return this.execSuggestionQuery("/public/suggestions/bank",r)}searchOrganization(r){return this.execSuggestionQuery("/public/suggestions/organization",r)}execSuggestionQuery(r,e){return this.get(r,{query:e}).then(t=>{const s=[...t];let o=1;return s.forEach(l=>{l.id=o++}),s})}}var ut=(n=>(n.Admin="admin",n.Manager="manager",n.Operator="operator",n.Client="client",n.Guest="guest",n))(ut||{});class pt extends Xe{constructor(e){super(e);i(this,"type");i(this,"canDoReclamations");i(this,"photo");i(this,"pricingRole");this.type=e==null?void 0:e.type,this.canDoReclamations=(e==null?void 0:e.canDoReclamations)??!1,this.photo=e==null?void 0:e.photo,this.pricingRole=e!=null&&e.pricingRole?new Qe(e.pricingRole):void 0}}class Qt extends y{constructor(){super(),this.baseUrl=`${b().config.http.portalApiUrl}/api`,this.interceptorIds.request.authRequestInterceptor&&this.httpClient.interceptors.request.eject(this.interceptorIds.request.authRequestInterceptor)}getAccessToken(){return this.get("internal/users/current-tokens").then(r=>r.accessToken)}}class ht extends y{getCurrentUser(){return this.get("/internal/users/info",{},r=>new pt(r.data),!0)}}const Yt=J.defineStore("common.user_state_private",()=>{const n=m.ref({}),r=m.ref(void 0);return{dataLoaderList:n,currentUser:r}}),Xt=J.defineStore("common.user_state",()=>({currentUser:m.computed(()=>{const r=Yt();return!r.currentUser&&!r.dataLoaderList.currentUser&&(r.dataLoaderList.currentUser=!0,y.getInstance(ht).getCurrentUser().then(e=>{r.currentUser=e}).catch(u.noop).finally(()=>{r.dataLoaderList.currentUser=!1})),r.currentUser})}));class Me{constructor(r){i(this,"user");i(this,"salesDirection");this.user=new I(r==null?void 0:r.user),this.salesDirection=new O(r==null?void 0:r.salesDirection)}}class je extends Be{constructor(e){var t,s;super(e);i(this,"cities");i(this,"users");this.cities=((t=e==null?void 0:e.cities)==null?void 0:t.map(o=>new Y(o)))??[],this.users=((s=e==null?void 0:e.users)==null?void 0:s.map(o=>new Me(o)))??[]}}class Zt extends ve{constructor(e){super();i(this,"id");i(this,"name");i(this,"abbr");this.id=e==null?void 0:e.id,this.name=e==null?void 0:e.name,this.abbr=e==null?void 0:e.abbr}resetFilterValue(e){switch(e){case"id":case"name":case"abbr":this[e]=void 0;break}return this}}class xt extends x{getRegionsList(r,e,t){return this.getPaginated("/internal/users/regions",r,e,t,{},s=>{const o={...s.data};return o.data=o.data.map(l=>new Be(l)),o})}getRegion(r){return this.get(`/internal/users/regions/${r}`,{},e=>new je(e.data))}createRegion(r,e={}){return this.post("/internal/users/regions",r,t=>new je(t.data),e)}updateRegion(r,e,t={}){return this.patch(`/internal/users/regions/${r}`,e,s=>new je(s.data),t)}removeRegion(r){return this.delete(`/internal/users/regions/${r}`)}getRegionEmployees(r){return this.get(`/internal/users/regions/${r}/users`,{},e=>e.data.map(t=>new Me(t)))}attachRegionEmployee(r,e,t){return this.post(`/internal/users/regions/${r}/users/${e}`,{salesDirectionId:t},s=>new Me(s.data))}detachRegionEmployee(r,e,t){return this.request({method:"DELETE",url:`/internal/users/regions/${r}/users/${e}`,params:{sales_direction_id:t}})}}class Et{constructor(r,e){i(this,"showFeedback",!1);i(this,"feedback","");i(this,"validationStatus");this.showFeedback=!!r,this.feedback=r,this.validationStatus=e}}c.AnyReference=tt,c.AppBaseConfig=Ir,c.BankAccount=qe,c.BasePaginationProvider=x,c.CalculationTypeEnum=Ur,c.Cart=ne,c.CartProvider=mt,c.CatalogProvider=wt,c.CatalogableItem=Je,c.Category=N,c.CategoryFilterSetting=Ee,c.CategoryPricingRule=xe,c.ChannelPrimaryInterest=cr,c.City=it,c.CityWithRegionAndCountry=Y,c.CityWithUserRegion=Cr,c.Client=ur,c.ClientAdditionalData=Wr,c.ClientCategory=ae,c.ClientDataProvider=_,c.ClientPriceProvider=at,c.ClientPriceTemplateProvider=Ct,c.ClientProduct=j,c.ClientProductCategoryDataProvider=Rt,c.ClientProductDataProvider=Dt,c.ClientShortInfo=F,c.ClientsAdditionalDataRequestTypeEnum=jr,c.ClientsListFilters=bt,c.CodedIdentity=ie,c.ConfiguratorProvider=kt,c.ConfiguratorsEnum=Jr,c.Contact=Ne,c.ContactLinks=Ke,c.ContactPerson=W,c.ContactPersonRelated=zr,c.ContactPosition=st,c.ContactRelation=Ue,c.ContragentBase=sr,c.ContragentFactory=Ce,c.ContragentIc=nr,c.ContragentPerson=Fr,c.ContragentUlNr=Gr,c.ContragentUlR=or,c.CostSourceEnum=$e,c.Country=K,c.CuratedDirection=Ie,c.Curator=Oe,c.Currency=L,c.DataSuggestionProvider=Kt,c.DateTimeProvider=_t,c.DeletableNamedIdentity=ir,c.DeliveryAddress=ue,c.DeliveryType=q,c.DetailedJwtPayload=gt,c.DeviceTypeResolutionConfig=Tr,c.DiscountShortInfo=Or,c.FieldValidationResultData=Et,c.FilterGroup=G,c.FilterItem=er,c.FilterOpEnum=_e,c.FilterSettings=Mr,c.GeoCoordinates=We,c.HiddenCatalogableItem=_r,c.HttpCachedRequester=pe,c.HttpParamsConfig=$r,c.HttpRequester=y,c.Identity=M,c.Image=qr,c.JwtPayload=B,c.Manager=oe,c.ManagerCommon=de,c.ManagerDataFactory=Nt,c.ManagerDataProvider=Kr,c.MetaTagItem=lt,c.NamedIdentity=T,c.Offer=ee,c.OfferShortInfo=gr,c.OffersDataProvider=Ht,c.OffersListFilters=Ut,c.Operator=fr,c.Opf=z,c.OpfEnum=U,c.Order=$,c.OrderAction=Yr,c.OrderEditorData=Bt,c.OrderInfo=mr,c.OrderItem=Qr,c.OrderItemBase=Ve,c.OrderPaymentStatus=nt,c.OrderShortInfo=pr,c.OrderStatus=Pe,c.OrderStatusDetail=ot,c.OrderStatusDetailEnum=rt,c.OrderStatusEnum=et,c.OrderStatusHistoryInfo=Xr,c.OrdersDataProvider=jt,c.OrdersListFilters=Mt,c.PaginationFiltersBase=ve,c.PartnerGroup=E,c.PaymentType=yr,c.PreferencesStorageProvider=ye,c.PriceAnalyze=He,c.PriceAnalyzeProvider=Ft,c.PriceCoefficient=we,c.PriceCoefficientEnum=Ge,c.PriceHistoryDataProvider=Gt,c.PriceHistoryItem=xr,c.PriceTemplate=V,c.PriceTemplateCategory=ke,c.PriceTemplateClient=ce,c.PriceTemplateICatalogableItem=Ye,c.PriceTemplateProduct=Le,c.PriceTemplateProvider=At,c.PricingRole=le,c.PricingRoleProvider=St,c.PrimaryCatalogableItem=Te,c.Product=k,c.ProductCategoryDataProvider=vt,c.ProductDataProvider=Pt,c.ProductFileType=ct,c.ProductFilterTypeEnum=Br,c.ProductPriceCoefficient=Se,c.ProductPriceHistory=Er,c.ProductUnit=ze,c.PropertiesProvider=Tt,c.Property=X,c.PropertyType=Ze,c.PropertyTypeEnum=Hr,c.PropertyValue=Z,c.RecommendationsDataProvider=Wt,c.RecommendationsList=ar,c.Reference=a,c.ReferenceDataFactory=zt,c.ReferenceDataProvider=D,c.Region=Q,c.ResourceType=vr,c.SalesDirection=O,c.SentryConfig=br,c.Seo=Pr,c.SeoDataProvider=Vt,c.SourcePrimaryInterest=lr,c.StockCount=Lr,c.TableDataPagination=Ot,c.TableDataPaginationRequestParams=Vr,c.TableDataSortRequestParams=Lt,c.TemplateProductCategoryDataProvider=$t,c.TemplatesListFilters=yt,c.TypedInstanceFactory=be,c.UnitsHelper=hr,c.UnknownClientDataProvider=dt,c.UpdatableNamedIdentity=Fe,c.User=pt,c.UserAuthDataProvider=Qt,c.UserCommonInfo=Xe,c.UserDataProvider=ht,c.UserPricingRole=Qe,c.UserRegion=je,c.UserRegionEmployee=Me,c.UserRegionProvider=xt,c.UserRegionShortInfo=Be,c.UserRegionsListFilters=Zt,c.UserShortInfo=I,c.UserTypeEnum=ut,c.VersionConfig=It,c.Warehouse=te,c.WebSocketConfig=dr,c.findCatalogItemByIdRecursive=rr,c.flattenCatalogItems=tr,c.pluralize=qt,c.useAuthStateStore=Ae,c.useBaseConfigStateStore=b,c.useReferencesStore=Jt,c.useUserStateStore=Xt,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(c,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("jwt-decode"),require("lodash-es"),require("ts-case-convert"),require("pinia"),require("vue"),require("date-fns"),require("axios")):typeof define=="function"&&define.amd?define(["exports","jwt-decode","lodash-es","ts-case-convert","pinia","vue","date-fns","axios"],d):(c=typeof globalThis<"u"?globalThis:c||self,d(c["SC Common Lib"]={},c["jwt-decode"],c["lodash-es"],c["ts-case-convert"],c.pinia,c.vue,c["date-fns"],c.axios))})(this,function(c,d,u,ye,J,f,g,Sr){"use strict";var ei=Object.defineProperty;var ri=(c,d,u)=>d in c?ei(c,d,{enumerable:!0,configurable:!0,writable:!0,value:u}):c[d]=u;var i=(c,d,u)=>ri(c,typeof d!="symbol"?d+"":d,u);class V{constructor(r){i(this,"exp",0);i(this,"iat",0);i(this,"authTime",0);i(this,"jti","");i(this,"iss","");i(this,"aud",[]);i(this,"sub","");i(this,"typ","Bearer");i(this,"azp","");i(this,"sid","");i(this,"acr","");i(this,"allowedOrigins",[]);i(this,"realmAccess",{roles:[]});i(this,"resourceAccess",{});i(this,"scope","");i(this,"emailVerified",!1);i(this,"name","");i(this,"guid","");i(this,"preferredUsername","");i(this,"givenName","");i(this,"email","");u.merge(this,r)}static getJwtPayload(r){const e=d.jwtDecode(r),t=new V(ye.objectToCamel(e));return t.resourceAccess=e.resource_access,t}}class Fe extends V{constructor(e){super(e);i(this,"familyName");i(this,"middleName");i(this,"locale");i(this,"phoneNumber");i(this,"phoneNumberVerified");i(this,"address");u.merge(this,e)}static getJwtPayload(e){const t=d.jwtDecode(e),s=new Fe(ye.objectToCamel(t));return s.resourceAccess=t.resource_access,s}}class $r{constructor(r){i(this,"phone");i(this,"tablet");i(this,"laptop");this.phone=(r==null?void 0:r.phone)??360,this.tablet=(r==null?void 0:r.tablet)??600,this.laptop=(r==null?void 0:r.laptop)??1024}}class br{constructor(r){i(this,"portalApiUrl");i(this,"mediaUrl");i(this,"responseDataCacheTimeout");this.portalApiUrl=(r==null?void 0:r.portalApiUrl)??"",this.mediaUrl=(r==null?void 0:r.mediaUrl)??"",this.responseDataCacheTimeout=(r==null?void 0:r.responseDataCacheTimeout)??3*60*60}}class dr{constructor(r){i(this,"dsn");i(this,"environment");i(this,"ignoreErrors");i(this,"trace");i(this,"replay");i(this,"additionalParams");var e,t,s,o;this.dsn=(r==null?void 0:r.dsn)??"",this.environment=(r==null?void 0:r.environment)??"production",this.ignoreErrors=(r==null?void 0:r.ignoreErrors)??[/Network\s{1,3}Error/,/Request\s{1,3}aborted/,/Request\s{1,3}failed\s{1,3}with\s{1,3}status\s{1,3}code\s{1,3}(401|403|404|422)/],this.trace={allowedTargets:((e=r==null?void 0:r.trace)==null?void 0:e.allowedTargets)??[/^\//],sampleRate:((t=r==null?void 0:r.trace)==null?void 0:t.sampleRate)??0},this.replay={replaysOnErrorSampleRate:((s=r==null?void 0:r.replay)==null?void 0:s.replaysOnErrorSampleRate)??0,replaysSessionSampleRate:((o=r==null?void 0:r.replay)==null?void 0:o.replaysSessionSampleRate)??0},this.additionalParams=(r==null?void 0:r.additionalParams)??{}}}class Ir{constructor(r){i(this,"broadcaster");i(this,"key");i(this,"wsHost");i(this,"wsPort");i(this,"wssPort");i(this,"forceTLS");i(this,"enabledTransports");this.broadcaster=r.broadcaster??"reverb",this.key=r.key??"",this.wsHost=r.wsHost??"",this.wsPort=r.wsPort??8080,this.wssPort=r.wssPort??8080,this.forceTLS=r.forceTLS??!1,this.enabledTransports=r.enabledTransports??["wss"]}}class Lr{constructor(r){i(this,"environment");i(this,"devMode");i(this,"http");i(this,"deviceTypeByResolution");i(this,"sentry");i(this,"tableDefaultHeightCoefficient");i(this,"urls");i(this,"websocket");i(this,"dateFormats");var e,t,s;this.environment=(r==null?void 0:r.environment)??"production",this.devMode=(r==null?void 0:r.devMode)??{},this.http=new br(r==null?void 0:r.http),this.deviceTypeByResolution=new $r(r==null?void 0:r.deviceTypeByResolution),this.sentry=new dr({environment:this.environment,...r==null?void 0:r.sentry}),this.tableDefaultHeightCoefficient=(r==null?void 0:r.tableDefaultHeightCoefficient)??.7,this.urls=r==null?void 0:r.urls,this.websocket=r!=null&&r.websocket?new Ir(r.websocket):void 0,this.dateFormats={api:((e=r==null?void 0:r.dateFormats)==null?void 0:e.api)??"yyyy-MM-dd HH:mm:ss",uiDate:((t=r==null?void 0:r.dateFormats)==null?void 0:t.uiDate)??"dd.MM.yyyy",uiDateWithTime:((s=r==null?void 0:r.dateFormats)==null?void 0:s.uiDateWithTime)??"dd.MM.yyyy HH:mm"}}}const b=J.defineStore("common.config",()=>{const n=f.ref(new Lr);return{config:n,getConfig:()=>n.value,setConfig:t=>{n.value=u.merge(n.value,t)}}});class we{static getActualDataFromStorage(r){if(!this.isLocalStorageAvailable())return;let e=null;try{e=localStorage.getItem(r)}catch{return}if(e)try{const t=JSON.parse(e);if(!t.availableFor||g.isAfter(g.parseISO(t.availableFor)||g.startOfToday(),new Date)){if(u.isNil(t.data)||u.isEmpty(t.data))throw new Error("Data is empty");return t.data}localStorage.removeItem(r)}catch{try{localStorage.removeItem(r)}catch{}}}static saveActualDataToStorage(r,e,t){if(this.isLocalStorageAvailable())try{if(u.isNil(e)||u.isEmpty(e))throw new Error("Data is empty");const s=JSON.stringify({availableFor:t,data:e});localStorage.setItem(r,s)}catch(s){if(s instanceof DOMException&&s.code===DOMException.QUOTA_EXCEEDED_ERR){this.clearOldData();try{const o=JSON.stringify({availableFor:t,data:e});localStorage.setItem(r,o)}catch{}}else try{localStorage.removeItem(r)}catch{}}}static isLocalStorageAvailable(){try{const r="__localStorage_test__";return localStorage.setItem(r,"test"),localStorage.removeItem(r),!0}catch{return!1}}static clearOldData(){try{const r=[];for(let e=0;e<localStorage.length;e++){const t=localStorage.key(e);if(t)try{const s=localStorage.getItem(t);if(s){const o=JSON.parse(s);o.availableFor&&!g.isAfter(g.parseISO(o.availableFor)||g.startOfToday(),new Date)&&r.push(t)}}catch{r.push(t)}}r.forEach(e=>{try{localStorage.removeItem(e)}catch{}})}catch{}}}function kr(n){try{const r=V.getJwtPayload(n);return new Date(r.exp*1e3)}catch{return}}const te=J.defineStore("common.auth_state_private",()=>{const n=f.ref((()=>{var h;const o=we.getActualDataFromStorage("sc.token");if(o)return Promise.resolve(o);const l=(h=b().config.devMode)==null?void 0:h.initAuthBearerToken;return l?Promise.resolve(l):void 0})()),r=f.ref(void 0),e=f.ref(void 0),t=f.markRaw(new Map);function s(){e.value=void 0,u.isNil(n.value)||n.value.then(o=>{const l=V.getJwtPayload(o);e.value=l.exp*1e3>Date.now()?u.mapValues(l.resourceAccess,h=>(h==null?void 0:h.roles)??[]):void 0}).catch(u.noop)}return{jwtToken:n,jwtTokenUpdater:r,userPermissions:e,userPermissionsComputedRefs:t,recalculateUserPermissions:s}}),Te=J.defineStore("common.auth_state",()=>{const n=f.computed(()=>{const o=te();if(u.isNil(o.jwtToken)&&!u.isNil(o.jwtTokenUpdater)){const l=o.jwtTokenUpdater();o.jwtToken=l,l.then(h=>{o.jwtToken=Promise.resolve(h),we.saveActualDataToStorage("sc.token",h,kr(h)),o.recalculateUserPermissions()}).catch(u.noop)}return o.jwtToken});function r(o){te().jwtTokenUpdater=o}function e(o){const l=te();l.jwtToken=Promise.resolve(o),we.saveActualDataToStorage("sc.token",o,kr(o)),l.recalculateUserPermissions()}function t(){const o=te();o.jwtToken=void 0,o.userPermissions=void 0,we.saveActualDataToStorage("sc.token",void 0)}function s(o){const l=te();!u.isNil(l.jwtToken)&&u.isNil(l.userPermissions)&&l.jwtToken.then(C=>{const P=V.getJwtPayload(C);l.userPermissions=P.exp*1e3>Date.now()?u.mapValues(P.resourceAccess,D=>(D==null?void 0:D.roles)??[]):void 0}).catch(u.noop);const h=u.isArray(o)?o.join(" && "):o;if(l.userPermissionsComputedRefs.has(h))return l.userPermissionsComputedRefs.get(h);const y=f.computed(()=>{const C=P=>{var me;const D=u.split(P,".");if(D.length<2)return!1;const[De,Ae]=D,fe=(me=te().userPermissions)==null?void 0:me[De];return u.isArray(fe)&&fe.includes(Ae)};return u.isArray(o)?u.every(o,P=>C(P)):C(o)});return l.userPermissionsComputedRefs.set(h,y),y}return{jwtToken:n,setJwtTokenUpdater:r,setJwtToken:e,invalidateJwtToken:t,hasUserPermission:s}});class M{constructor(r,e){i(this,"id");i(this,"guid");this.id=r==null?void 0:r.id,u.isNil(this.id)&&(u.isNil(e)?typeof(r==null?void 0:r.id)=="number"?this.id=-1:typeof(r==null?void 0:r.id)=="string"&&(this.id=""):this.id=e),this.guid=(r==null?void 0:r.guid)??""}isNewRec(){return typeof this.id=="number"?this.id===-1:typeof this.id=="string"?this.id==="":u.isNil(this.id)}}class S extends M{constructor(e){super(e);i(this,"name","");this.name=(e==null?void 0:e.name)??""}}class L extends S{constructor(e){super(e);i(this,"type");i(this,"isActive");this.type=e==null?void 0:e.type,this.isActive=(e==null?void 0:e.isActive)??!0}}class Or extends S{constructor(e){super(e);i(this,"costCoefficient");i(this,"isLowPriceAllowed");i(this,"publishedAt");i(this,"description");i(this,"percent");i(this,"owner");i(this,"deletedAt");this.costCoefficient=(e==null?void 0:e.costCoefficient)??0,this.isLowPriceAllowed=(e==null?void 0:e.isLowPriceAllowed)??!1,this.publishedAt=u.isString(e==null?void 0:e.publishedAt)?g.parseISO(e.publishedAt):e==null?void 0:e.publishedAt,this.description=(e==null?void 0:e.description)??void 0,this.percent=(e==null?void 0:e.percent)??0,this.owner=new L(e==null?void 0:e.owner),this.deletedAt=u.isString(e==null?void 0:e.deletedAt)?g.parseISO(e.deletedAt):e==null?void 0:e.deletedAt}}class Ge extends S{constructor(e){super(e);i(this,"updatedAt");this.updatedAt=u.isString(e==null?void 0:e.updatedAt)?g.parseISO(e.updatedAt):e==null?void 0:e.updatedAt}}class K extends Ge{constructor(e){super(e);i(this,"description");i(this,"createdAt");i(this,"owner");this.description=(e==null?void 0:e.description)??"",this.createdAt=u.isString(e==null?void 0:e.createdAt)?g.parseISO(e.createdAt):(e==null?void 0:e.createdAt)??new Date,this.owner=e!=null&&e.owner?new L(e.owner):void 0}}var ze=(n=>(n.K0="k0",n.K1="k1",n.K2="k2",n.K3="k3",n.K4="k4",n.Retail="retail",n))(ze||{});class v extends S{constructor(e){super(e);i(this,"slug");i(this,"description");this.description=e==null?void 0:e.description,this.slug=e==null?void 0:e.slug}}class Ce extends v{static getRetailPriceCoefficient(){return{id:-2,slug:ze.Retail,name:"Розн. цена",guid:"",isNewRec:u.constant(!0)}}}class Se{constructor(r){i(this,"coefficient");i(this,"value");i(this,"cost");i(this,"percent");i(this,"readOnly");this.coefficient=new Ce(r==null?void 0:r.coefficient),this.value=(r==null?void 0:r.value)??0,this.cost=(r==null?void 0:r.cost)??0,this.percent=(r==null?void 0:r.percent)??0,this.readOnly=(r==null?void 0:r.readOnly)??!0}}class We{constructor(r){i(this,"lat");i(this,"long");this.lat=(r==null?void 0:r.lat)??0,this.long=(r==null?void 0:r.long)??0}}class N extends v{}class ie extends v{constructor(e){var t;super(e);i(this,"address");i(this,"isMain");i(this,"deliveryTypes");i(this,"regions");i(this,"coordinates");this.address=(e==null?void 0:e.address)??"",this.isMain=(e==null?void 0:e.isMain)??!1,this.deliveryTypes=((t=e==null?void 0:e.deliveryTypes)==null?void 0:t.map(s=>new N(s)))??[],this.regions=(e==null?void 0:e.regions)??[],this.coordinates=new We(e==null?void 0:e.coordinates)}}class _r{constructor(r){i(this,"warehouse");i(this,"count");this.warehouse=new ie(r==null?void 0:r.warehouse),this.count=(r==null?void 0:r.count)??0}}class _ extends S{constructor(e){super(e);i(this,"signature","");i(this,"code");i(this,"symbol","");i(this,"precision");e&&(this.signature=e.signature??"",this.code=e.code,this.symbol=e.symbol??"",this.precision=e.precision)}}class Je extends S{constructor(e){super(e);i(this,"slug","");i(this,"description");i(this,"isSquare",!1);i(this,"isLinear",!1);e&&(this.slug=e.slug??"",this.description=e.description,this.isSquare=e.isSquare??!1,this.isLinear=e.isLinear??!1)}}class se extends S{constructor(e){super(e);i(this,"code","");this.code=(e==null?void 0:e.code)??""}}class Ve extends se{constructor(e){super(e);i(this,"slug");i(this,"type");this.slug=(e==null?void 0:e.slug)??""}}class qr extends Ve{constructor(e){super(e);i(this,"isHidden");this.isHidden=(e==null?void 0:e.isHidden)??!1}}class Nr{constructor(r,e){i(this,"image");i(this,"preview");i(this,"isDefault");this.image=`${e??""}${r.image}`,this.preview=`${e??""}${r.preview}`,this.isDefault=r.isDefault}}class $e extends Ve{constructor(e){super(e);i(this,"isPrimary");this.isPrimary=(e==null?void 0:e.isPrimary)??!1}}class k extends qr{constructor(e){var s,o,l,h;super(e);i(this,"supplierSku");i(this,"unit");i(this,"pack");i(this,"minCount");i(this,"currency");i(this,"cost");i(this,"costRub");i(this,"costDate");i(this,"onOrder");i(this,"stockCount");i(this,"category");i(this,"categories");i(this,"images");i(this,"properties");i(this,"retailCost");i(this,"retailCostRub");i(this,"priceCoefficients");this.supplierSku=e==null?void 0:e.supplierSku,this.unit=e!=null&&e.unit?new Je(e.unit):new Je,this.pack=e==null?void 0:e.pack,this.minCount=e==null?void 0:e.minCount,this.currency=e!=null&&e.currency?new _(e.currency):new _,this.cost=(e==null?void 0:e.cost)??0,this.costRub=(e==null?void 0:e.costRub)??0,this.costDate=u.isString(e==null?void 0:e.costDate)?g.parseISO(e.costDate):e==null?void 0:e.costDate,this.onOrder=(e==null?void 0:e.onOrder)??!1,this.stockCount=((s=e==null?void 0:e.stockCount)==null?void 0:s.map(y=>new _r(y)))??[],this.type="product";const t=(e==null?void 0:e.category)??((o=e==null?void 0:e.categories)==null?void 0:o.find(y=>y.isPrimary));t&&(this.category=new $e({...t,isPrimary:!0}),this.categories=[this.category]),e!=null&&e.categories&&(this.categories=e.categories.map(y=>new $e(y))),this.images=((l=e==null?void 0:e.images)==null?void 0:l.map(y=>new Nr(y,b().config.http.mediaUrl)))??[],this.properties=(e==null?void 0:e.properties)??{},this.retailCost=e==null?void 0:e.retailCost,this.retailCostRub=e==null?void 0:e.retailCostRub,this.priceCoefficients=((h=e==null?void 0:e.priceCoefficients)==null?void 0:h.map(y=>new Se(y)))??[],e&&"codeNumber"in e&&!e.code&&(this.code=e==null?void 0:e.codeNumber)}getIsMeasurable(){return this.unit.isLinear||this.unit.isSquare}getRetailCost(){return this.retailCost??this.cost}getRetailCostRub(){return this.retailCostRub??this.costRub}}var be=(n=>(n.Discount="discount",n.PriceTemplate="price_template",n.ClientPrice="client_price",n.Product="product",n))(be||{});class j extends k{constructor(e){super(e);i(this,"costCoefficient");i(this,"costSource");i(this,"discount");i(this,"priceTemplate");i(this,"isPreviouslyOrdered");i(this,"isRequired");i(this,"isFavorite");this.costCoefficient=(e==null?void 0:e.costCoefficient)??0,this.costSource=(e==null?void 0:e.costSource)??be.Product,this.discount=e!=null&&e.discount?new Or(e.discount):void 0,this.priceTemplate=e!=null&&e.priceTemplate?new K(e.priceTemplate):void 0,this.isPreviouslyOrdered=e==null?void 0:e.isPreviouslyOrdered,this.isRequired=e==null?void 0:e.isRequired,this.isFavorite=e==null?void 0:e.isFavorite}}class ne extends $e{constructor(e){super(e);i(this,"isHidden");i(this,"parentCategoryId");i(this,"properties");i(this,"currencyRates");this.isHidden=(e==null?void 0:e.isHidden)??!1,this.parentCategoryId=e==null?void 0:e.parentCategoryId,this.properties=e==null?void 0:e.properties,this.type="category",this.currencyRates=e!=null&&e.currencyRates?Object.fromEntries(Object.entries(e.currencyRates).map(([t,s])=>[u.toUpper(t),s])):void 0}}class Ke extends M{constructor(e){super(e);i(this,"category");i(this,"product");i(this,"quantity");i(this,"currency");i(this,"marker");i(this,"height");i(this,"length");i(this,"width");i(this,"configurator");i(this,"configuratorParams");i(this,"isAdditionalSale");i(this,"creator");i(this,"isRemoved");i(this,"ord");i(this,"onOrder");i(this,"originalId");i(this,"replacementId");this.product=new j(e.product),this.quantity=e.quantity??0,this.marker=e.marker,this.category=e.category??new ne,this.currency=e.currency?new _(e.currency):void 0,this.height=e.height,this.length=e.length,this.width=e.width,this.configurator=e.configurator,this.configuratorParams=e.configuratorParams&&u.cloneDeep(e.configuratorParams),this.isAdditionalSale=e.isAdditionalSale,this.creator=e.creator&&new L(e.creator),this.isRemoved=e.isRemoved,this.ord=e.ord,this.onOrder=e.onOrder,this.originalId=e.originalId,this.replacementId=e.replacementId}}let Ur=class extends Ke{constructor(e){super(e);i(this,"cost");i(this,"costOne");i(this,"costOneRub");i(this,"costRub");i(this,"logicGroupId");i(this,"salesDirection");i(this,"specificationImgUrl");i(this,"sawing");i(this,"currency");this.cost=e.cost,this.costOne=e.costOne,this.costOneRub=e.costOneRub,this.costRub=e.costRub,this.logicGroupId=e.logicGroupId,this.salesDirection=e.salesDirection,this.specificationImgUrl=e.specificationImgUrl,this.sawing=u.isArray(e.sawing)?e.sawing:e.sawing?[e.sawing]:void 0,this.currency=new _(e.currency)}};class oe{constructor(r){i(this,"items");i(this,"resultSum");i(this,"directionsSum");this.items=r.items.map(e=>new Ur(e)),this.resultSum=r.resultSum,this.directionsSum=r.directionsSum}}class I{static simpleInstanceInitializer(r){return new r}static instanceInitializer(r,e){return new r(e)}static instanceListInitializer(r,e){if(!u.isArray(e))throw new TypeError(`Ожидался список данных для инициализации "${r.name}", получены данные типа "${typeof e}".`);return u.map(e,t=>I.instanceInitializer(r,t))}}const a=class a{constructor(){i(this,"httpClient");i(this,"baseUrl",`${b().config.http.portalApiUrl}/api`);i(this,"errorResponseHandler",u.noop);i(this,"interceptorIds",{request:{},response:{}});i(this,"setBaseUrlRequestInterceptor",r=>(r.baseURL=this.baseUrl,r));i(this,"authRequestInterceptor",async r=>{let e;return u.isNil(Te().jwtToken)||(e=await Te().jwtToken),e&&r.headers.set("Authorization",`Bearer ${e}`),r});i(this,"userRequestHooksInterceptor",async r=>a.requestHooks.reduce(async(e,t)=>t(await e),Promise.resolve(r)));i(this,"dataConverterRequestInterceptor",r=>(r.method&&(r.method==="get"&&r.params&&(r.params=ye.objectToSnake(r.params)),["put","patch","post"].includes(u.toLower(r.method))&&r.data&&(r.data=ye.objectToSnake(r.data))),r));i(this,"authErrorsResponseInterceptors",r=>{var t;const e=r.rawError?(t=r.rawError)==null?void 0:t.config:void 0;return r.status===401?!e||e.__isRetryRequest?Promise.reject(r):(Te().invalidateJwtToken(),e.__isRetryRequest=!0,this.httpClient(e)):Promise.reject(r)});i(this,"canceledResponseInterceptor",r=>{const e=r.rawError??r;if(e.name==="CanceledError"||e.code==="ERR_CANCELED")throw new Sr.CanceledError("Request canceled");return Promise.reject(r)});i(this,"userResponseHooksInterceptor",async r=>a.responseHooks.reduce(async(e,t)=>t(await e),Promise.resolve(r)));i(this,"dataConverterResponseInterceptor",r=>(r.data&&(r.data=ye.objectToCamel(r.data)),r));this.errorResponseHandler=a.defaultErrorsResponseHandler,this.httpClient=Sr.create({headers:{Accept:"application/json","Content-Type":"application/json"}}),this.interceptorIds.request.setBaseUrlRequestInterceptor=this.httpClient.interceptors.request.use(this.setBaseUrlRequestInterceptor,r=>Promise.reject(r)),this.interceptorIds.request.userRequestHooksInterceptor=this.httpClient.interceptors.request.use(this.userRequestHooksInterceptor,r=>Promise.reject(r)),this.interceptorIds.request.authRequestInterceptor=this.httpClient.interceptors.request.use(this.authRequestInterceptor,r=>Promise.reject(r)),this.interceptorIds.request.dataConverterRequestInterceptor=this.httpClient.interceptors.request.use(this.dataConverterRequestInterceptor,r=>Promise.reject(r)),this.interceptorIds.response.convertHttpErrorResponseInterceptor=this.httpClient.interceptors.response.use(r=>r,r=>a.convertHttpErrorResponse(r)),this.interceptorIds.response.canceledResponseInterceptor=this.httpClient.interceptors.response.use(r=>r,this.canceledResponseInterceptor),this.interceptorIds.response.authErrorsResponseInterceptor=this.httpClient.interceptors.response.use(r=>r,this.authErrorsResponseInterceptors),this.interceptorIds.response.dataConverterResponseInterceptor=this.httpClient.interceptors.response.use(this.dataConverterResponseInterceptor,r=>Promise.reject(r)),this.interceptorIds.response.userResponseHooksInterceptor=this.httpClient.interceptors.response.use(this.userResponseHooksInterceptor,r=>Promise.reject(r))}static setDefaultErrorsResponseHandler(r){a.defaultErrorsResponseHandler=r}static addRequestHook(r){a.requestHooks.includes(r)||a.requestHooks.push(r)}static removeRequestHook(r){const e=a.requestHooks.indexOf(r);e!==-1&&a.requestHooks.splice(e,1)}static addResponseHook(r){a.responseHooks.includes(r)||a.responseHooks.push(r)}static removeResponseHook(r){const e=a.responseHooks.indexOf(r);e!==-1&&a.responseHooks.splice(e,1)}static getInstance(r){return Object.prototype.hasOwnProperty.call(a.instances,r.name)||(a.instances[r.name]=I.simpleInstanceInitializer(r)),a.instances[r.name]}static toHttpResponseError(r){return u.isObject(r)&&"status"in r?r:{status:0,statusText:"Invalid response data",message:u.isError(r)?r.message:"Не удалось обработать данные ответа сервера.",headers:{},rawError:u.isError(r)?r:new Error(String(r))}}static convertHttpErrorResponse(r){var e,t;if(u.isNil(r)||!u.isNil(r.request)||!u.isNil(r.response)){const s=u.isNil(r)?{}:r==null?void 0:r.response;return Promise.reject({status:(s==null?void 0:s.status)??0,statusText:(s==null?void 0:s.statusText)??"Unknown",message:((e=s==null?void 0:s.data)==null?void 0:e.message)??"Unknown Error. Probably network error.",errors:(t=s==null?void 0:s.data)==null?void 0:t.errors,headers:(s==null?void 0:s.headers)??{},data:s==null?void 0:s.data,rawError:r})}return Promise.reject(r)}request(r,e=void 0,t={},s=!1){const o=this.httpClient.request(r).then(l=>e?e(l):l.data);return o.catch(l=>{(l==null?void 0:l.name)!=="CanceledError"&&this.errorResponseHandler(a.toHttpResponseError(l),t,s)}),o}get(r,e={},t=void 0,s=!1,o=void 0){return this.request({method:"GET",url:r,params:e,signal:o},t,{},s)}getTypedList(r,e,t={},s=!1,o=void 0){return this.get(e,t,l=>I.instanceListInitializer(r,l.data),s,o)}getBlob(r,e={},t=void 0,s=!1){return this.request({method:"GET",url:r,params:e,responseType:"blob"},t,{},s)}patch(r,e={},t=void 0,s={},o=!1){return this.request({method:"PATCH",url:r,data:e},t,s,o)}post(r,e={},t=void 0,s={},o=!1){return this.request({method:"POST",url:r,data:e},t,s,o)}delete(r,e=void 0,t=!1){return this.request({method:"DELETE",url:r},e,{},t)}};i(a,"instances",{}),i(a,"defaultErrorsResponseHandler",u.noop),i(a,"requestHooks",[]),i(a,"responseHooks",[]);let m=a;class ft extends m{getCart(r){return this.get(`internal/clients/${r.id}/cart`,{},e=>new oe(e.data))}deleteCart(r){return this.delete(`internal/clients/${r.id}/cart`)}addCartItem(r,e,t={}){return this.patch(`internal/clients/${r.id}/cart`,{product_id:e.product.id,product_category_id:e.configurator?e.category.id:void 0,quantity:e.quantity,height:e.height,length:e.length,width:e.width,configurator:e.configurator,marker:e.marker,is_additional_sale:e.isAdditionalSale,...e.configuratorParams},s=>new oe(s.data),t)}patchCartItem(r,e,t={}){return this.patch(`internal/clients/${r.id}/cart/${e.id}`,{product_id:e.product.id,product_category_id:e.configurator?e.category.id:void 0,quantity:e.quantity,height:e.height,length:e.length,width:e.width,configurator:e.configurator,marker:e.marker,is_additional_sale:e.isAdditionalSale,...e.configuratorParams},s=>new oe(s.data),t)}deleteCartItem(r,e){return this.delete(`internal/clients/${r.id}/cart/${e.id}`,t=>new oe(t.data))}addCartItemFromCSV(r,e){return this.post(`internal/clients/${r.id}/cart/add-products-from-csv`,e,t=>new oe(t.data))}getCartItemFromCSVExample(r){return this.get(`internal/clients/${r.id}/cart/add-products-from-csv/example`,{},e=>new Blob([e.data],{type:"text/csv"}))}}var Hr=(n=>(n.m2Cost="m2Cost",n.percent="percent",n.value="value",n))(Hr||{}),Br=(n=>(n.Unknown="unknown",n.Bool="bool",n.Integer="integer",n.Float="float",n.String="string",n.Range="range",n.Json="json",n.Object="object",n))(Br||{}),Mr=(n=>(n.Checkbox="checkbox",n.Range="range",n.Toggle="toggle",n))(Mr||{});class U extends ne{constructor(e){var t,s;super(e);i(this,"categories");i(this,"products");this.categories=(t=e==null?void 0:e.categories)==null?void 0:t.map(o=>new U(o)),this.products=(s=e==null?void 0:e.products)==null?void 0:s.map(o=>new k(o))}}class Qe{constructor(r){i(this,"phone");i(this,"email");this.phone=/^\d+$/.test(r.phone??"")?`+${r.phone}`:r.phone,this.email=r.email}}class O extends v{}class de extends S{constructor(e){super(e);i(this,"salesDirection");i(this,"photo");i(this,"contacts");i(this,"isDefault");i(this,"isRegionalDirector");this.salesDirection=e!=null&&e.salesDirection?new O(e.salesDirection):new O,this.photo=e==null?void 0:e.photo,this.contacts=e!=null&&e.contacts?new Qe(e.contacts):void 0,this.isDefault=(e==null?void 0:e.isDefault)??!1,this.isRegionalDirector=(e==null?void 0:e.isRegionalDirector)??!1}}class Ie extends v{}class Ye extends S{constructor(e){super(e);i(this,"description");i(this,"canChangeLowCost");i(this,"parentRoleId");this.description=e.description,this.canChangeLowCost=e.canChangeLowCost,this.parentRoleId=e.parentRoleId}}class ce extends de{constructor(e){var t;super(e);i(this,"isActive");i(this,"isSupervisor");i(this,"canDoReclamations");i(this,"createdAt");i(this,"supervisorId");i(this,"pricingRole");i(this,"curatedDirections");this.isActive=(e==null?void 0:e.isActive)??!1,this.isSupervisor=(e==null?void 0:e.isSupervisor)??!1,this.canDoReclamations=(e==null?void 0:e.canDoReclamations)??!1,this.createdAt=e==null?void 0:e.createdAt,this.supervisorId=e==null?void 0:e.supervisorId,this.pricingRole=e!=null&&e.pricingRole?new Ye(e.pricingRole):void 0,this.curatedDirections=((t=e==null?void 0:e.curatedDirections)==null?void 0:t.map(s=>new Ie(s)))??[]}}class mt extends ne{constructor(e){super(e);i(this,"isDisabled");i(this,"isRequired");i(this,"isFavorite");i(this,"hidingComment");i(this,"manager");this.isDisabled=(e==null?void 0:e.isDisabled)??!1,this.isRequired=(e==null?void 0:e.isRequired)??!1,this.isFavorite=(e==null?void 0:e.isFavorite)??!1,this.hidingComment=e==null?void 0:e.hidingComment,this.manager=e!=null&&e.manager?new ce(e.manager):void 0}}class ve extends mt{constructor(e){var t,s;super(e);i(this,"categories");i(this,"products");this.categories=(t=e==null?void 0:e.categories)==null?void 0:t.map(o=>new ve(o)),this.products=(s=e==null?void 0:e.products)==null?void 0:s.map(o=>new j(o))}}class Xe{constructor(r){i(this,"priceCoefficient");i(this,"increasePercent");this.priceCoefficient=(r==null?void 0:r.priceCoefficient)&&new Ce(r.priceCoefficient),this.increasePercent=r==null?void 0:r.increasePercent}}class Le extends Xe{constructor(e){super(e);i(this,"productCategory");this.productCategory=new ne(e==null?void 0:e.productCategory)}}class ke extends S{constructor(e){super(e);i(this,"photo");i(this,"contacts");i(this,"curatedDirection");this.photo=e.photo,this.contacts=new Qe(e.contacts),this.curatedDirection=new Ie(e.curatedDirection)}}class Q extends v{}class Y extends v{constructor(e){super(e);i(this,"country",new Q);e&&(this.country=new Q(e.country))}}class X extends v{constructor(e){super(e);i(this,"region",new Y);e&&(this.region=new Y(e.region))}}class Ze extends S{constructor(e){super(e);i(this,"phone");i(this,"email");i(this,"getNews");i(this,"salesDirection");i(this,"createdAt");i(this,"lastLoginAt");i(this,"isActive");this.phone=/^\d+$/.test((e==null?void 0:e.phone)??"")?`+${e==null?void 0:e.phone}`:(e==null?void 0:e.phone)??"",this.email=(e==null?void 0:e.email)??"",this.getNews=(e==null?void 0:e.getNews)??!1,this.salesDirection=e!=null&&e.salesDirection?new O(e.salesDirection):void 0,this.createdAt=u.isString(e==null?void 0:e.createdAt)?g.parseISO(e.createdAt):e==null?void 0:e.createdAt,this.lastLoginAt=u.isString(e==null?void 0:e.lastLoginAt)?g.parseISO(e.lastLoginAt):e==null?void 0:e.lastLoginAt,this.isActive=(e==null?void 0:e.isActive)??!1}}class F extends Ze{constructor(e){var t,s;super(e);i(this,"salesDirection");i(this,"debt");i(this,"alternativeName");i(this,"city");i(this,"comment");i(this,"isPhoneApproved");i(this,"isEmailApproved");i(this,"managers");i(this,"curators");this.salesDirection=new O(e==null?void 0:e.salesDirection),this.debt=(e==null?void 0:e.debt)??0,this.alternativeName=(e==null?void 0:e.alternativeName)??"",this.city=new X(e==null?void 0:e.city),this.comment=e==null?void 0:e.comment,this.isPhoneApproved=(e==null?void 0:e.isPhoneApproved)??!1,this.isEmailApproved=(e==null?void 0:e.isEmailApproved)??!1,this.managers=((t=e==null?void 0:e.managers)==null?void 0:t.map(o=>new de(o)))??[],this.curators=((s=e==null?void 0:e.curators)==null?void 0:s.map(o=>new ke(o)))??void 0}}class le extends M{constructor(e){super(e);i(this,"createdAt");i(this,"deletedAt");i(this,"client");i(this,"priceTemplate");this.createdAt=u.isString(e==null?void 0:e.createdAt)?g.parseISO(e.createdAt):(e==null?void 0:e.createdAt)??new Date,this.deletedAt=u.isString(e==null?void 0:e.deletedAt)?g.parseISO(e.deletedAt):e==null?void 0:e.deletedAt,this.client=new F(e==null?void 0:e.client),this.priceTemplate=new K(e==null?void 0:e.priceTemplate)}}class Oe extends Xe{constructor(e){super(e);i(this,"product");this.product=new k(e==null?void 0:e.product)}}class xe extends v{}class Z extends S{constructor(e){super(e);i(this,"type");i(this,"description");i(this,"metadata");i(this,"isFilterable");this.type=new xe(e==null?void 0:e.type),this.description=(e==null?void 0:e.description)??"",this.metadata=e==null?void 0:e.metadata,this.isFilterable=e==null?void 0:e.isFilterable}}class x{constructor(r){i(this,"property");i(this,"value");this.property=new Z(r==null?void 0:r.property),this.value=(r==null?void 0:r.value)??""}}class A{constructor(r){i(this,"from");i(this,"to");this.from=u.isString(r==null?void 0:r.from)?g.parseISO(r.from):(r==null?void 0:r.from)??null,this.to=u.isString(r==null?void 0:r.to)?g.parseISO(r.to):(r==null?void 0:r.to)??null}}class yt{constructor(r){i(this,"id");i(this,"name");i(this,"description");i(this,"ownerName");i(this,"createdAt",new A);i(this,"updatedAt",new A);this.id=r==null?void 0:r.id,this.name=r==null?void 0:r.name,this.description=r==null?void 0:r.description,this.ownerName=r==null?void 0:r.ownerName,this.createdAt=new A(r==null?void 0:r.createdAt),this.updatedAt=new A(r==null?void 0:r.updatedAt)}resetFilterValue(r){switch(r){case"id":case"name":case"description":case"ownerName":this[r]=void 0;break;case"createdAt":this.createdAt.from=null,this.createdAt.to=null;break;case"updatedAt":this.updatedAt.from=null,this.updatedAt.to=null;break}return this}asClearRaw(){var e,t,s,o;const r={};return Object.keys(this).forEach(l=>{const h=this[l];u.isNil(h)||u.isString(h)&&h.trim().length===0||u.isFunction(h.isNewRec)&&h.isNewRec()||(r[l]=h)}),!((e=r==null?void 0:r.createdAt)!=null&&e.from)&&!((t=r==null?void 0:r.createdAt)!=null&&t.to)&&delete r.createdAt,!((s=r==null?void 0:r.updatedAt)!=null&&s.from)&&!((o=r==null?void 0:r.updatedAt)!=null&&o.to)&&delete r.updatedAt,r}}class ue extends S{constructor(e){super(e);i(this,"description");i(this,"canChangeLowCost");i(this,"parentRoleId");i(this,"subRoles",[]);i(this,"parentRole");i(this,"level",0);this.description=e==null?void 0:e.description,this.canChangeLowCost=(e==null?void 0:e.canChangeLowCost)??!1,this.parentRoleId=e==null?void 0:e.parentRoleId}}class Ee{constructor(r){i(this,"role");i(this,"category");i(this,"minCoefficient");this.role=new ue(r==null?void 0:r.role),this.category=new ne(r==null?void 0:r.category),this.minCoefficient=new Ce(r==null?void 0:r.minCoefficient)}}class jr{constructor(r){i(this,"isFake");i(this,"isHidden");i(this,"isMultiple");i(this,"type");i(this,"ord");this.isFake=(r==null?void 0:r.isFake)??!1,this.isHidden=(r==null?void 0:r.isHidden)??!1,this.isMultiple=(r==null?void 0:r.isMultiple)??null,this.type=(r==null?void 0:r.type)??null,this.ord=(r==null?void 0:r.ord)??0}}class er{constructor(r){i(this,"category");i(this,"property");i(this,"settings");this.category=new ne(r==null?void 0:r.category),this.property=new Z(r==null?void 0:r.property),this.settings=new jr(r==null?void 0:r.settings)}}class wt extends m{search(r,e=!1){return this.get("/internal/catalog/search",{term:r,show_hidden:e})}getPriceExportLink(r="csv",e=!1,t=void 0,s=void 0){let l=`${b().config.http.portalApiUrl}/api/internal/price/export?format=${r}&show_hidden=${e}`;return t&&(l+=`&category_id=${t}`),s&&(l+=`&client_id=${s}`),l}}class Ct extends m{importPrices(r,e){return this.post(`/internal/clients/${r}/price/import`,e)}updateCategoryPrices(r,e,t){var s;return this.patch(`/internal/clients/${r}/price/categories/${e}`,{price_coefficient_id:(s=t.coefficient)==null?void 0:s.id,increase_percent:t.value})}removeCategoryPrices(r,e){return this.delete(`/internal/clients/${r}/price/categories/${e}`)}markCategoryRequired(r,e){return this.post(`/internal/clients/${r}/price/categories/${e}/required`)}unmarkCategoryRequired(r,e){return this.delete(`/internal/clients/${r}/price/categories/${e}/required`)}markCategoryDisabled(r,e,t){return this.post(`/internal/clients/${r}/price/categories/${e}/disabled`,{comment:t})}unmarkCategoryDisabled(r,e){return this.delete(`/internal/clients/${r}/price/categories/${e}/disabled`)}addCategoryManager(r,e,t){return this.post(`/internal/clients/${r}/price/categories/${e}/manager`,{manager_id:t})}removeCategoryManager(r,e){return this.delete(`/internal/clients/${r}/price/categories/${e}/manager`)}updateProductPrice(r,e,t){var s;return this.patch(`/internal/clients/${r}/price/products/${e}`,{price_coefficient_id:(s=t.coefficient)==null?void 0:s.id,increase_percent:t.value},o=>new j(o.data))}removeProductPrice(r,e){return this.delete(`/internal/clients/${r}/price/products/${e}`,t=>new j(t.data))}markProductRequired(r,e){return this.post(`/internal/clients/${r}/price/products/${e}/required`)}unmarkProductRequired(r,e){return this.delete(`/internal/clients/${r}/price/products/${e}/required`)}getCommercialOfferHtml(r,e){return this.get(`/internal/clients/${r}/price/commercial-offer/view`,e,t=>new Blob([t.data],{type:"text/html"}))}getCommercialOfferPdf(r,e){return this.getBlob(`/internal/clients/${r}/price/commercial-offer/download`,e,t=>new Blob([t.request.response],{type:"application/pdf"}))}sendCommercialOffer(r,e){return this.post(`/internal/clients/${r}/price/commercial-offer/send`,e)}}class vt extends m{getTemplateList(r){return this.getTypedList(le,`/internal/clients/${r}/price/templates`)}getActiveTemplate(r){return this.get(`/internal/clients/${r}/price/templates/active`,{},e=>new le(e.data),!0)}attachTemplate(r,e,t){const s=b().config.dateFormats.api;return this.post(`/internal/clients/${r}/price/templates/${e}`,t&&{startAt:t.startAt&&g.format(t.startAt,s),endAt:t.endAt&&g.format(t.endAt,s)},o=>new le(o.data),{},!0)}applyTemplate(r,e){return this.post(`/internal/clients/${r}/price/templates/${e}/apply`,{},void 0,{},!0)}changeTemplate(r,e,t,s){const o=b().config.dateFormats.api;return this.patch(`/internal/clients/${r}/price/templates/${e}/${t}`,s&&{startAt:s.startAt&&g.format(s.startAt,o),endAt:s.endAt&&g.format(s.endAt,o)},l=>new le(l.data))}detachTemplate(r,e,t){return this.delete(`/internal/clients/${r}/price/templates/${e}/${t}`)}}class Pt extends m{getRootCategoriesList(r=!1){return this.getTypedList(U,"/internal/catalog/categories",{showHidden:r})}getCategoryData(r,e=!1,t=!1){return this.get(`/internal/catalog/categories/${r}`,{showHidden:e,withNestedCategories:t},s=>new U(s.data))}getPublicCategoryData(r){return this.get(`/public/catalog/categories/${r}`,{},e=>new U(e.data))}getCategoryProductsList(r,e=!0,t=!1){return this.get(`/internal/catalog/categories/${r}/products`,{showHidden:t,withPriceCoefficients:e},s=>u.map(s.data,o=>new k(o)))}getCategoryProductsCoefficients(r){return this.get(`/internal/catalog/categories/${r}/products/coefficients`,{},e=>{const{data:t}=e;return u.forEach(t,s=>s.map(o=>new Se(o))),t})}publicSimpleSearch(r,e=10){return new Promise((t,s)=>{this.get(`/public/catalog/search/simple?limit=${e}&term=${r}`).then(o=>{t(o.categories.map(l=>new U(l)))}).catch(o=>{s(o)})})}}class at extends m{getProductData(r,e=!1){return this.get(`/internal/catalog/products/${r}`,{withPriceCoefficients:e},t=>new k(t.data))}getPublicProductData(r){return this.get(`/public/catalog/products/${r}`,{},e=>new k(e.data))}getProductPriceCoefficients(r){return this.get(`/internal/catalog/products/${r}/coefficients`,{},e=>u.map(e.data,t=>new Se(t)))}publicSimpleSearch(r,e=10){return new Promise((t,s)=>{this.get(`/public/catalog/search/simple?limit=${e}&term=${r}`).then(o=>{t(o.products.map(l=>new k(l)))}).catch(o=>{s(o)})})}}class Rt extends m{getRootCategoriesList(r,e=!1){return this.getTypedList(ve,"/internal/catalog/categories",{clientId:r,showHidden:e})}getCategoryData(r,e,t=!1,s=!1){return this.get(`/internal/catalog/categories/${e}`,{clientId:r,showHidden:t,withNestedCategories:s},o=>new ve(o.data))}getCategoryProductsList(r,e,t=!0,s=!1){return this.get(`/internal/catalog/categories/${e}/products`,{client_id:r,showHidden:s,withPriceCoefficients:t},o=>u.map(o.data,l=>new j(l)))}}class Dt extends m{getProductData(r,e,t=!1){return this.get(`/internal/catalog/products/${r}`,{clientId:e,withPriceCoefficients:t},s=>new j(s.data))}}var _e=(n=>(n.BeginWith="bw",n.Contains="cn",n.Custom="custom",n.EndsWith="ew",n.Equals="eq",n.GreaterOrEqual="ge",n.GreaterThan="gt",n.InList="in",n.LessOrEqual="le",n.LessThan="lt",n.NotBeginWith="bn",n.NotContains="nc",n.NotEndsWith="en",n.NotEqual="ne",n.NotInList="ni",n.NotNull="nn",n.Null="nu",n))(_e||{});class rr{constructor(r){i(this,"field");i(this,"op");i(this,"value");this.field=(r==null?void 0:r.field)??"",this.op=(r==null?void 0:r.op)??_e.Equals,this.value=(r==null?void 0:r.value)??""}toPrimitive(){const r=b().config.dateFormats.api,e={field:this.field,op:this.op};if(u.isDate(this.value))e.value=g.format(this.value,r);else if(u.isPlainObject(this.value)){const t=this.value;e.value={from:t.from?g.format(t.from,r):null,to:t.to?g.format(t.to,r):null}}else e.value=this.value;return e}}class G{constructor(r){i(this,"groupOp");i(this,"filters");i(this,"groups");var e,t;this.groupOp=(r==null?void 0:r.groupOp)??"and",this.filters=((e=r==null?void 0:r.filters)==null?void 0:e.map(s=>new rr(s)))??[],this.groups=((t=r==null?void 0:r.groups)==null?void 0:t.map(s=>new G(s)))??[]}toPrimitive(){return{groupOp:this.groupOp,filters:this.filters.map(r=>r instanceof rr&&u.isFunction(r.toPrimitive)?r.toPrimitive():r),groups:this.groups.map(r=>r instanceof G?r.toPrimitive():r)}}}class E extends m{getPaginated(r,e,t,s,o,l,h,y=void 0){let C={page:(s==null?void 0:s.page)??1,perPage:(s==null?void 0:s.pageSize)??10};return e&&(C.filters=JSON.stringify((e instanceof G?e:new G(e)).toPrimitive())),u.isEmpty(t)||(C.sort=u.isArray(t)?t:[t]),o&&(C={...C,...o}),this.get(r,C,l,h,y)}getTypedPaginated(r,e,t,s,o,l,h,y=void 0){return this.getPaginated(e,t,s,o,l,C=>({...C.data,data:I.instanceListInitializer(r,C.data.data)}),h,y)}}class At extends E{getTemplateList(r,e,t){return this.getTypedPaginated(K,"/internal/price/templates",r,e,t)}createTemplate(r,e={}){return this.post("/internal/price/templates",r,t=>new K(t.data),e)}getTemplate(r){return this.get(`/internal/price/templates/${r}`,{},e=>new K(e.data))}updateTemplate(r,e,t={}){return this.patch(`/internal/price/templates/${r}`,e,s=>new K(s.data),t)}removeTemplate(r){return this.delete(`/internal/price/templates/${r}`)}getProductTemplatePrices(r){return this.getTypedList(Oe,`/internal/price/templates/${r}/products`)}getProductTemplatePrice(r,e){return this.get(`/internal/price/templates/${r}/products/${e}`,{},t=>new Oe(t.data))}saveProductTemplatePrice(r,e,t){var s;return this.post(`/internal/price/templates/${r}/products/${e}`,{price_coefficient_id:(s=t.coefficient)==null?void 0:s.id,increase_percent:t.value},o=>new Oe(o.data))}deleteProductTemplatePrice(r,e){return this.delete(`/internal/price/templates/${r}/products/${e}`)}getCategoryTemplatePrices(r){return this.getTypedList(Le,`/internal/price/templates/${r}/categories`)}getCategoryTemplatePrice(r,e){return this.get(`/internal/price/templates/${r}/categories/${e}`,{},t=>new Le(t.data))}saveCategoryTemplatePrice(r,e,t,s=!1){var o;return this.request({method:"POST",url:`/internal/price/templates/${r}/categories/${e}`,data:{price_coefficient_id:(o=t.coefficient)==null?void 0:o.id,increase_percent:t.value},params:s?{recursively:!0}:{}},l=>new Le(l.data))}deleteCategoryTemplatePrice(r,e,t=!1){return this.request({method:"DELETE",url:`/internal/price/templates/${r}/categories/${e}`,params:t?{recursively:!0}:{}})}getTemplateClients(r){return this.getTypedList(le,`/internal/price/templates/${r}/clients`)}}class Tt extends m{getRoles(){return this.getTypedList(ue,"/internal/price/roles")}createRole(r){return this.post("/internal/price/roles",r,e=>new ue(e.data))}getRole(r){return this.get(`/internal/price/roles/${r}`,{},e=>new ue(e.data))}updateRole(r,e){return this.patch(`/internal/price/roles/${r}`,e,t=>new ue(t.data))}deleteRole(r){return this.delete(`/internal/price/roles/${r}`)}getCategoryRules(r){return this.getTypedList(Ee,`/internal/price/roles/rules/categories/${r}`)}updateCategoryRules(r,e){return this.patch(`/internal/price/roles/rules/categories/${r}`,e,t=>I.instanceListInitializer(Ee,t.data))}}class St extends E{getProperties(r,e,t){return this.getTypedPaginated(Z,"/internal/catalog/properties",r,e,t)}createProperty(r){const{typeId:e,...t}=r;return this.post("/internal/catalog/properties",{...t,type:e},s=>new Z(s.data))}getProperty(r){return this.get(`/internal/catalog/properties/${r}`,{},e=>new Z(e.data))}updateProperty(r,e){const{typeId:t,...s}=e;return this.patch(`/internal/catalog/properties/${r}`,{...s,type:t},o=>new Z(o.data))}deleteProperty(r){return this.delete(`/internal/catalog/properties/${r}`)}getProductProperties(r){return this.getTypedList(x,`/internal/catalog/products/${r}/properties`)}getProductProperty(r,e){return this.get(`/internal/catalog/products/${r}/properties/${e}`,{},t=>new x(t.data))}updateProductProperty(r,e,t){return this.patch(`/internal/catalog/products/${r}/properties/${e}`,{value:t},s=>new x(s.data))}deleteProductProperty(r,e){return this.delete(`/internal/catalog/products/${r}/properties/${e}`)}getProductDescription(r){return this.get(`/internal/catalog/products/${r}/properties/description`)}updateProductDescription(r,e){return this.patch(`/internal/catalog/products/${r}/properties/description`,{text:e})}deleteProductDescription(r){return this.delete(`/internal/catalog/products/${r}/properties/description`)}getProductSpecification(r){return this.get(`/internal/catalog/products/${r}/properties/specification`)}updateProductSpecification(r,e){return this.patch(`/internal/catalog/products/${r}/properties/specification`,{text:e})}deleteProductSpecification(r){return this.delete(`/internal/catalog/products/${r}/properties/specification`)}getProductFiles(r){return this.get(`/internal/catalog/products/${r}/properties/files`)}addProductFile(r,e){return this.post(`/internal/catalog/products/${r}/properties/files`,e)}updateProductFile(r,e,t){return this.patch(`/internal/catalog/products/${r}/properties/files/${e}`,t)}deleteProductFile(r,e){return this.delete(`/internal/catalog/products/${r}/properties/files/${e}`)}updateProductSlug(r,e){return this.patch(`/internal/catalog/products/${r}/properties/slug`,{slug:e})}getCategoryProperties(r){return this.getTypedList(x,`/internal/catalog/categories/${r}/properties`)}getCategoryProperty(r,e){return this.get(`/internal/catalog/categories/${r}/properties/${e}`,{},t=>new x(t.data))}updateCategoryProperty(r,e,t){return this.patch(`/internal/catalog/categories/${r}/properties/${e}`,{value:t},s=>new x(s.data))}deleteCategoryProperty(r,e){return this.delete(`/internal/catalog/categories/${r}/properties/${e}`)}getCategoryDescription(r){return this.get(`/internal/catalog/categories/${r}/properties/description`)}updateCategoryDescription(r,e){return this.patch(`/internal/catalog/categories/${r}/properties/description`,{text:e})}deleteCategoryDescription(r){return this.delete(`/internal/catalog/categories/${r}/properties/description`)}getCategorySpecification(r){return this.get(`/internal/catalog/categories/${r}/properties/specification`)}updateCategorySpecification(r,e){return this.patch(`/internal/catalog/categories/${r}/properties/specification`,{text:e})}deleteCategorySpecification(r){return this.delete(`/internal/catalog/categories/${r}/properties/specification`)}getCategoryFiles(r){return this.get(`/internal/catalog/categories/${r}/properties/files`)}addCategoryFile(r,e){return this.post(`/internal/catalog/categories/${r}/properties/files`,e)}updateCategoryFile(r,e,t){return this.patch(`/internal/catalog/categories/${r}/properties/files/${e}`,t)}deleteCategoryFile(r,e){return this.delete(`/internal/catalog/categories/${r}/properties/files/${e}`)}updateCategorySlug(r,e){return this.patch(`/internal/catalog/categories/${r}/properties/slug`,{slug:e})}updateCategoryImage(r,e){return this.post(`/internal/catalog/categories/${r}/image`,{image:e})}getCategoryFilterSettings(r){return this.getTypedList(er,`/internal/catalog/categories/${r}/filter-settings`)}saveCategoryFilterSetting(r,e,t){return this.patch(`/internal/catalog/categories/${r}/filter-settings/${e}`,t,s=>new er(s.data))}deleteCategoryFilterSetting(r,e){return this.delete(`/internal/catalog/categories/${r}/filter-settings/${e}`)}}class $t extends m{getRootCategoriesList(r,e=!1){return this.getTypedList(U,"/internal/catalog/categories",{priceTemplateId:r,showHidden:e})}getCategoryData(r,e,t=!1,s=!1){return this.get(`/internal/catalog/categories/${e}`,{priceTemplateId:r,showHidden:t,withNestedCategories:s},o=>new U(o.data))}getCategoryProductsList(r,e,t=!0,s=!1){return this.get(`/internal/catalog/categories/${e}/products`,{priceTemplateId:r,showHidden:s,withPriceCoefficients:t},o=>u.map(o.data,l=>new k(l)))}}function tr(n,r,e){let t;return n.some(s=>{if(s.type===e&&s.id===r)return t=s,!0;if(s.type==="product")return!1;const o=s;if(o.products&&o.products.length>0){const l=tr(o.products,r,e);if(l)return t=l,!0}if(o.categories&&o.categories.length>0){const l=tr(o.categories,r,e);if(l)return t=l,!0}return!1}),t}function ir(n){const r=[];return n.forEach(e=>{if(r.push(e),e.type==="category"){const t=e;t.products&&t.products.length>0&&r.push(...ir(t.products)),t.categories&&t.categories.length>0&&r.push(...ir(t.categories))}}),r}var Fr=(n=>(n.LastOrder="last_order",n.Contacts="contacts",n.PartnerGroups="partner_groups",n.PreferredDeliveryType="preferred_delivery_type",n.SalesDirection="sales_direction",n.Managers="managers",n.Curators="curators",n))(Fr||{}),H=(n=>(n.Person="individual",n.Ic="entrepreneur",n.UlR="legal",n.UlNr="non_resident_legal",n))(H||{});class qe extends M{constructor(e){super(e);i(this,"bankName","");i(this,"bic","");i(this,"accountNumber","");i(this,"correspondentAccount","");i(this,"currency",new _);e&&(this.bankName=e.bankName??"",this.bic=e.bic??"",this.accountNumber=e.accountNumber??"",this.correspondentAccount=e.correspondentAccount??"",this.currency=new _(e.currency))}}class Ne extends S{constructor(e){super(e);i(this,"phone");i(this,"email");this.email=e==null?void 0:e.email,this.phone=/^\d+$/.test((e==null?void 0:e.phone)??"")?`+${e==null?void 0:e.phone}`:e==null?void 0:e.phone}}class z extends Ne{constructor(e){super(e);i(this,"isPrimary");i(this,"position");i(this,"notDisturb");i(this,"comment");i(this,"updatedAt");i(this,"deletedAt");this.isPrimary=(e==null?void 0:e.isPrimary)??!1,this.position=e==null?void 0:e.position,this.notDisturb=(e==null?void 0:e.notDisturb)??!1,this.comment=e==null?void 0:e.comment,this.updatedAt=e==null?void 0:e.updatedAt,this.deletedAt=u.isString(e==null?void 0:e.deletedAt)?g.parseISO(e.deletedAt):e==null?void 0:e.deletedAt}}class W extends v{static generatePersonItem(){return new W({id:1,guid:"",slug:H.Person,name:""})}}class ee extends v{}class sr extends Ge{constructor(e){super(e);i(this,"deletedAt");this.deletedAt=u.isString(e==null?void 0:e.deletedAt)?g.parseISO(e.deletedAt):e==null?void 0:e.deletedAt}}class nr extends sr{constructor(e){super(e);i(this,"opf",W.generatePersonItem());i(this,"partnerGroup",new ee);i(this,"contacts",[]);i(this,"bankAccounts",[]);i(this,"comment");i(this,"alternativeName");i(this,"createdAt");i(this,"creator");i(this,"updater");if(e){if(this.opf=new W(e.opf),this.comment=e.comment,this.alternativeName=e.alternativeName,this.createdAt=u.isString(e==null?void 0:e.createdAt)?g.parseISO(e.createdAt):e.createdAt,this.creator=e.creator?new L(e.creator):void 0,this.updater=e.updater?new L(e.updater):void 0,e.partnerGroup&&(this.partnerGroup=new ee(e.partnerGroup)),e.contacts){const t=[];e.contacts.forEach(s=>{t.push(new z(s))}),this.contacts=t}if(e.bankAccounts){const t=[];e.bankAccounts.forEach(s=>{t.push(new qe(s))}),this.bankAccounts=t}}}}class Gr extends nr{constructor(r){super(r)}}class or extends nr{constructor(e){super(e);i(this,"inn","");i(this,"okpo","");i(this,"directorName","");i(this,"directorPosition","");i(this,"directorActsOn","");i(this,"legalAddress","");i(this,"postalAddress","");i(this,"actualAddress","");e&&(this.inn=e.inn??"",this.okpo=e.okpo??"",this.directorName=e.directorName??"",this.directorPosition=e.directorPosition??"",this.directorActsOn=e.directorActsOn??"",this.legalAddress=e.legalAddress??"",this.postalAddress=e.postalAddress??"",this.actualAddress=e.actualAddress??"")}}class cr extends or{constructor(e){super(e);i(this,"kpp","");e&&(this.kpp=e.kpp??"")}}class zr extends cr{constructor(e){super(e);i(this,"registrationCountry",new Q);i(this,"registrationNumber","");i(this,"taxNumber","");e&&(this.registrationCountry=new Q(e.registrationCountry),this.registrationNumber=e.registrationNumber??"",this.taxNumber=e.taxNumber??"")}}class Pe{static createInstance(r){switch(r.opf.slug){case H.Ic:return new or(r);case H.UlR:return new cr(r);case H.UlNr:return new zr(r);default:return new Gr(r)}}}class pe extends sr{constructor(e){var t;super(e);i(this,"address","");i(this,"coordinates");i(this,"contacts");i(this,"comment");i(this,"operatingHours");i(this,"isOneTime");i(this,"isTransportCompanyAddress");this.address=(e==null?void 0:e.address)??"",this.coordinates=new We(e==null?void 0:e.coordinates),this.contacts=((t=e==null?void 0:e.contacts)==null?void 0:t.map(s=>new z(s)))??[],this.comment=e==null?void 0:e.comment,this.operatingHours=e==null?void 0:e.operatingHours,this.isOneTime=e==null?void 0:e.isOneTime,this.isTransportCompanyAddress=e==null?void 0:e.isTransportCompanyAddress}}class lr extends v{}class ur extends v{}class pr extends F{constructor(e){var t,s,o,l;super(e);i(this,"contragents");i(this,"partnerGroups");i(this,"contacts");i(this,"deliveryAddresses");i(this,"channelPrimaryInterest");i(this,"sourcePrimaryInterest");i(this,"preferredDeliveryType");i(this,"primaryDemand");i(this,"preferredWarehouse");i(this,"extraData");this.contragents=((t=e==null?void 0:e.contragents)==null?void 0:t.map(h=>Pe.createInstance(h)))??[],this.partnerGroups=((s=e==null?void 0:e.partnerGroups)==null?void 0:s.map(h=>new ee(h)))??[],this.contacts=((o=e==null?void 0:e.contacts)==null?void 0:o.map(h=>new z(h)))??[],this.deliveryAddresses=((l=e==null?void 0:e.deliveryAddresses)==null?void 0:l.map(h=>new pe(h)))??[],this.channelPrimaryInterest=new lr(e==null?void 0:e.channelPrimaryInterest),this.sourcePrimaryInterest=new ur(e==null?void 0:e.sourcePrimaryInterest),this.preferredDeliveryType=new N(e==null?void 0:e.preferredDeliveryType),this.primaryDemand=e==null?void 0:e.primaryDemand,this.preferredWarehouse=e!=null&&e.preferredWarehouse?new ie(e.preferredWarehouse):void 0,this.extraData=(e==null?void 0:e.extraData)??{}}}class ae{asClearRaw(){const r={};return Object.keys(this).forEach(e=>{const t=this[e];u.isNil(t)||u.isString(t)&&t.trim().length===0||u.isFunction(t.isNewRec)&&t.isNewRec()||(r[e]=t)}),r}}class bt extends ae{constructor(e){var t,s,o,l,h,y,C,P;super();i(this,"id");i(this,"name");i(this,"alternativeName");i(this,"searchTerm");i(this,"cities");i(this,"region");i(this,"country");i(this,"phone");i(this,"email");i(this,"isActive");i(this,"createdAt",new A);i(this,"lastLoginDate",new A);i(this,"lastLoginDateHasOrder");i(this,"managers");i(this,"includeSubordinateManagers");i(this,"curators");i(this,"isManagerRequired");i(this,"salesDirections");i(this,"contragentInn");i(this,"contragentType");i(this,"preferredDeliveryType");i(this,"partnerGroups");i(this,"contact");i(this,"lastOrder");i(this,"noOrdersPeriod",new A);this.id=e==null?void 0:e.id,this.name=e==null?void 0:e.name,this.alternativeName=e==null?void 0:e.alternativeName,this.searchTerm=e==null?void 0:e.searchTerm,this.cities=(t=e==null?void 0:e.cities)==null?void 0:t.map(D=>new X(D)),this.region=new Y(e==null?void 0:e.region),this.country=new Q(e==null?void 0:e.country),this.phone=e==null?void 0:e.phone,this.email=e==null?void 0:e.email,this.isActive=e&&Object.prototype.hasOwnProperty.call(e,"isActive")?e==null?void 0:e.isActive:!0,this.createdAt=new A(e==null?void 0:e.createdAt),this.lastLoginDate=new A(e==null?void 0:e.lastLoginDate),this.lastLoginDateHasOrder=(e==null?void 0:e.lastLoginDateHasOrder)??void 0,this.managers=((s=e==null?void 0:e.managers)==null?void 0:s.map(D=>new ce(D)))??[],this.includeSubordinateManagers=(e==null?void 0:e.includeSubordinateManagers)??!0,this.curators=((o=e==null?void 0:e.curators)==null?void 0:o.map(D=>new ke(D)))??[],this.salesDirections=(l=e==null?void 0:e.salesDirections)==null?void 0:l.map(D=>new O(D)),this.contragentInn=e==null?void 0:e.contragentInn,this.contragentType=new W(e==null?void 0:e.contragentType),this.preferredDeliveryType=e!=null&&e.preferredDeliveryType?new N(e==null?void 0:e.preferredDeliveryType):void 0,this.partnerGroups=(h=e==null?void 0:e.partnerGroups)==null?void 0:h.map(D=>new ee(D)),this.contact=new Ne(e==null?void 0:e.contact),this.lastOrder={createdAt:new A((y=e==null?void 0:e.lastOrder)==null?void 0:y.createdAt),creator:(C=e==null?void 0:e.lastOrder)==null?void 0:C.creator,isApproved:(P=e==null?void 0:e.lastOrder)==null?void 0:P.isApproved},this.noOrdersPeriod=new A(e==null?void 0:e.noOrdersPeriod)}resetFilterValue(e){switch(e){case"cities":this.cities=[];break;case"region":this.region=new Y;break;case"isActive":this.isActive=!0;break;case"createdAt":this.createdAt.from=null,this.createdAt.to=null;break;case"lastLoginDate":this.lastLoginDate.from=null,this.lastLoginDate.to=null;break;case"noOrdersPeriod":this.noOrdersPeriod.from=null,this.noOrdersPeriod.to=null;break;case"lastOrder":this.lastOrder={};break;case"managers":this.managers=[];break;case"curators":this.curators=[];break;case"salesDirections":this.salesDirections=[];break;case"contragentType":this.contragentType=new W;break;case"preferredDeliveryType":this.preferredDeliveryType=new N;break;case"partnerGroups":this.partnerGroups=[];break;case"contact":this.contact=new Ne;break;default:this[e]=void 0;break}return this}asClearRaw(){var t,s,o,l,h,y;const e=super.asClearRaw();return!((t=e==null?void 0:e.createdAt)!=null&&t.from)&&!((s=e==null?void 0:e.createdAt)!=null&&s.to)&&delete e.createdAt,!((o=e==null?void 0:e.lastLoginDate)!=null&&o.from)&&!((l=e==null?void 0:e.lastLoginDate)!=null&&l.to)&&delete e.lastLoginDate,!((h=e==null?void 0:e.noOrdersPeriod)!=null&&h.from)&&!((y=e==null?void 0:e.noOrdersPeriod)!=null&&y.to)&&delete e.noOrdersPeriod,e}}class hr extends M{constructor(e){super(e);i(this,"createdAt");i(this,"creator");this.createdAt=u.isString(e==null?void 0:e.createdAt)?g.parseISO(e.createdAt):(e==null?void 0:e.createdAt)??new Date,this.creator=new L(e==null?void 0:e.creator)}}class Wr extends S{constructor(e){var t,s,o,l;super(e);i(this,"contacts",[]);i(this,"preferredDeliveryType");i(this,"partnerGroups",[]);i(this,"lastOrder");i(this,"salesDirection");i(this,"managers");i(this,"curators");this.contacts=((t=e.contacts)==null?void 0:t.map(h=>new z(h)))??void 0,this.lastOrder=e.lastOrder?new hr(e.lastOrder):void 0,this.partnerGroups=((s=e.partnerGroups)==null?void 0:s.map(h=>new ee(h)))??void 0,this.preferredDeliveryType=e.preferredDeliveryType?new N(e.preferredDeliveryType):void 0,this.salesDirection=e.salesDirection?new O(e.salesDirection):void 0,this.managers=((o=e.managers)==null?void 0:o.map(h=>new de(h)))??void 0,this.curators=((l=e.curators)==null?void 0:l.map(h=>new ke(h)))??void 0}}class Ue extends M{constructor(e){super(e);i(this,"isPrimary");this.isPrimary=e.isPrimary}}class Jr extends z{constructor(e){super(e);i(this,"relations",{clients:[],contragents:[],addresses:[]});e.relations&&(e.relations.addresses&&(this.relations.addresses=e.relations.addresses.map(t=>new Ue(t))),e.relations.clients&&(this.relations.clients=e.relations.clients.map(t=>new Ue(t))),e.relations.contragents&&(this.relations.contragents=e.relations.contragents.map(t=>new Ue(t))))}}class q extends E{static transformClientDataToRequest(r){var t;return{name:r.name,alternative_name:r.alternativeName,partner_groups:r.partnerGroups.map(s=>s.id),phone:r.phone,email:r.email,city_id:r.city.id,get_news:r.getNews,channel_primary_interest_id:r.channelPrimaryInterest.id,source_primary_interest_id:r.sourcePrimaryInterest.id,primary_demand:r.primaryDemand,preferred_warehouse_id:(t=r.preferredWarehouse)==null?void 0:t.id}}static transformContragentClientDataToRequest(r){var l,h,y,C;let e;const t=r,s=r,o=r;switch(r.opf.slug){case H.Ic:e={opf:t.opf.slug,name:t.name,alternative_name:t.alternativeName,partner_group_id:(l=t.partnerGroup)==null?void 0:l.id,comment:t.comment,inn:t.inn,okpo:t.okpo,director_name:t.directorName,director_position:t.directorPosition,director_acts_on:t.directorActsOn,legal_address:t.legalAddress,postal_address:t.postalAddress,actual_address:t.actualAddress};break;case H.UlR:e={opf:s.opf.slug,name:s.name,alternative_name:s.alternativeName,partner_group_id:(h=s.partnerGroup)==null?void 0:h.id,comment:s.comment,inn:s.inn,kpp:s.kpp,okpo:s.okpo,director_name:s.directorName,director_position:s.directorPosition,director_acts_on:s.directorActsOn,legal_address:s.legalAddress,postal_address:s.postalAddress,actual_address:s.actualAddress};break;case H.UlNr:e={opf:o.opf.slug,name:o.name,alternative_name:o.alternativeName,partner_group_id:(y=o.partnerGroup)==null?void 0:y.id,comment:o.comment,director_name:o.directorName,director_position:o.directorPosition,director_acts_on:o.directorActsOn,legal_address:o.legalAddress,postal_address:o.postalAddress,actual_address:o.actualAddress,registration_country_id:o.registrationCountry.id,registration_number:o.registrationNumber,tax_number:o.taxNumber||void 0};break;default:e={opf:r.opf.slug,name:r.name,alternative_name:r.alternativeName,partner_group_id:(C=r.partnerGroup)==null?void 0:C.id,comment:r.comment};break}return e}static transformClientDeliveryAddressToRequest(r){var t,s;const e={address:r.address,is_one_time:r.isOneTime??!1,is_transport_company_address:r.isTransportCompanyAddress??!1,comment:r.comment??""};return r.coordinates&&(e.coordinates={lat:(t=r.coordinates)==null?void 0:t.lat,long:(s=r.coordinates)==null?void 0:s.long}),r.operatingHours&&(e.operating_hours={from:r.operatingHours.from,to:r.operatingHours.to}),e}static transformClientContragentBankAccountToRequest(r){return{bank_name:r.bankName,bic:r.bic,account_number:r.accountNumber,correspondent_account:r.correspondentAccount,currency_id:r.currency.id}}getClient(r){return this.get(`/internal/clients/${r}`,{},e=>new pr(e.data))}getClientsList(r,e,t,s,o=void 0){return this.getTypedPaginated(F,"/internal/clients",r,e,t,s,void 0,o)}searchClient(r){return this.getClientsList(void 0,void 0,void 0,{searchTerm:r}).then(e=>e.data)}getClientByPhone(r){return this.getClientsList({groupOp:"and",groups:[],filters:[{field:"phone",op:_e.Contains,value:r}]})}getAdditionalClientsData(r,e){const t=r.map(s=>s.id);return this.post("/internal/clients/additional-data",{clients:t,requested_data_types:e},s=>I.instanceListInitializer(Wr,s.data))}getAllClientContacts(r){return this.getTypedList(Jr,`/internal/clients/${r}/contacts/all`)}createClientCommonData(r,e={}){return this.post("/internal/clients",q.transformClientDataToRequest(r),t=>new pr(t.data),e)}updateClientCommonData(r,e={}){return this.patch(`/internal/clients/${r.id}`,q.transformClientDataToRequest(r),void 0,e)}updateClientNotDistribCommonData(r,e={}){const t={get_news:r.getNews};return this.patch(`/internal/clients/${r.id}`,t,void 0,e)}changeClientPassword(r,e,t,s={}){return this.patch(`/internal/clients/${r}`,{password:e,password_confirmation:t},void 0,s)}updateClientComment(r){return this.patch(`/internal/clients/${r.id}`,{comment:r.comment})}changeClientActivation(r){return this.patch(`/internal/clients/${r.id}`,{is_active:r.isActive})}async attachClientToManagers(r,e){const t=e.map(s=>this.patch(`/internal/clients/${r}/managers/${s.id}/attach`,{is_primary:s.isDefault}));await Promise.all(t)}async detachClientFromManagers(r,e){const t=e.map(s=>this.patch(`/internal/clients/${r}/managers/${s.id}/detach`));await Promise.all(t)}attachToCurator(r,e,t){return this.patch(`/internal/clients/${r}/curators/${e}/attach`,{curated_direction_id:t.id})}detachFromCurator(r,e,t){return this.patch(`/internal/clients/${r}/curators/${e}/detach`,{curated_direction_id:t.id})}setCurators(r,e){return this.patch(`/internal/clients/${r}/curators`,{curators:e.map(t=>({curator_id:t.curatorId,curated_direction_id:t.curatedDirection.id}))})}createContragentClientData(r,e,t={}){return this.post(`/internal/clients/${r}/contragents`,q.transformContragentClientDataToRequest(e),s=>Pe.createInstance(s.data),t)}updateContragentClientData(r,e,t={}){return this.patch(`/internal/clients/${r}/contragents/${e.id}`,q.transformContragentClientDataToRequest(e),s=>Pe.createInstance(s.data),t)}deleteClientContragent(r,e){return this.delete(`/internal/clients/${r}/contragents/${e.id}`)}getClientDeliveryAddresses(r){return this.getTypedList(pe,`/internal/clients/${r}/delivery-addresses`)}createClientDeliveryAddress(r,e,t={}){return this.post(`/internal/clients/${r}/delivery-addresses`,q.transformClientDeliveryAddressToRequest(e),s=>new pe(s.data),t)}updateClientDeliveryAddress(r,e,t={}){return this.patch(`/internal/clients/${r}/delivery-addresses/${e.id}`,q.transformClientDeliveryAddressToRequest(e),s=>new pe(s.data),t)}deleteClientDeliveryAddress(r,e){return this.delete(`/internal/clients/${r}/delivery-addresses/${e.id}`)}createContragentBankAccount(r,e,t,s={}){return this.post(`/internal/clients/${r}/contragents/${e}/bank-accounts`,q.transformClientContragentBankAccountToRequest(t),o=>new qe(o.data),s)}updateContragentBankAccount(r,e,t,s={}){return this.patch(`/internal/clients/${r}/contragents/${e}/bank-accounts/${t.id}`,q.transformClientContragentBankAccountToRequest(t),o=>new qe(o.data),s)}deleteContragentBankAccount(r,e,t){return this.delete(`/internal/clients/${r}/contragents/${e}/bank-accounts/${t.id}`)}createClientContact(r,e,t={}){return this.createContact(r,e,{client:{id:r,is_primary:e.isPrimary??!1,not_disturb:e.notDisturb??!1}},t)}updateClientContact(r,e,t={}){return this.patch(`/internal/clients/${r}/contacts/${e.id}`,{name:e.name,position:e.position,phone:e.phone,email:e.email,comment:e.comment,not_disturb:e.notDisturb},s=>new z(s.data),t)}setPrimaryClientContact(r,e){return this.setPrimaryContact(`/internal/clients/${r}/contacts/${e.id}/primary`,e.isPrimary??!1)}detachClientContact(r,e){return this.detachContact(`/internal/clients/${r}/contacts/${e.id}/detach`)}createContragentContact(r,e,t,s={}){return this.createContact(r,t,{contragents:[{id:e,is_primary:t.isPrimary??!1,not_disturb:t.notDisturb??!1}]},s)}setPrimaryContragentContact(r,e,t){return this.setPrimaryContact(`/internal/clients/${r}/contragents/${e}/contacts/${t.id}/primary`,t.isPrimary??!1)}detachContragentContact(r,e,t){return this.detachContact(`/internal/clients/${r}/contragents/${e}/contacts/${t.id}/detach`)}createDeliveryAddressContact(r,e,t,s={}){return this.createContact(r,t,{addresses:[{id:e,is_primary:t.isPrimary??!1,not_disturb:t.notDisturb??!1}]},s)}setPrimaryDeliveryAddressContact(r,e,t){return this.setPrimaryContact(`/internal/clients/${r}/delivery-addresses/${e}/contacts/${t.id}/primary`,t.isPrimary??!1)}detachDeliveryAddressContact(r,e,t){return this.detachContact(`/internal/clients/${r}/delivery-addresses/${e}/contacts/${t.id}/detach`)}createContact(r,e,t,s={}){var l,h;const o={name:e.name,position:e.position,comment:e.comment,...t};return(l=e.phone)!=null&&l.length&&(o.phone=e.phone),(h=e.email)!=null&&h.length&&(o.email=e.email),this.post(`/internal/clients/${r}/contacts`,o,y=>new z(y.data),s)}setPrimaryContact(r,e){return this.patch(r,{is_primary:e})}detachContact(r){return this.patch(r)}sendClientEmailConfirmation(r){return this.get(`/internal/clients/${r.id}/verification/email?email=${r.email}`)}}class dt extends m{checkPhoneIsBusy(r){return new Promise((e,t)=>{this.request({method:"GET",url:"/public/user/verification/phone/check",params:{phone:r}}).then(s=>{e(!!s.isBusy)}).catch(t)})}}class It{constructor(r){i(this,"date");i(this,"name");i(this,"version");this.date=u.isString(r==null?void 0:r.date)?g.parseISO(r.date):(r==null?void 0:r.date)??new Date,this.name=(r==null?void 0:r.name)??"",this.version=(r==null?void 0:r.version)??"0.0.0"}}var Vr=(n=>(n.Kozyrek="kozyrek",n.Mosquitto="mosquitto",n.Strip="strip",n.MetalForDoors="metal_for_doors",n.Sandwich="sandwich",n.SandwichM2="sandwich_m2",n))(Vr||{});class Lt extends m{getConfiguratorSettings(r,e){var t;return this.get(`internal/catalog/categories/${r.id}/configurators/${(t=r.properties)==null?void 0:t.configurator}/settings?client_id=${e}`)}searchProduct(r,e,t,s={}){var l;const o=this.get(`internal/catalog/categories/${r.id}/configurators/${(l=r.properties)==null?void 0:l.configurator}/product`,{params:t,client_id:e},h=>new k(h.data));return o.catch(h=>{this.errorResponseHandler(h,s)}),o}createTemplate(r,e,t,s={}){var o;return this.post(`internal/catalog/categories/${r.id}/configurators/${(o=r.properties)==null?void 0:o.configurator}/template?client_id=${e}`,{...t},()=>{},s)}removeTemplate(r,e,t){var s;return this.delete(`internal/catalog/categories/${r.id}/configurators/${(s=r.properties)==null?void 0:s.configurator}/template/${t}?client_id=${e}`)}calculate(r,e,t){var s;return this.get(`internal/catalog/categories/${r.id}/configurators/${(s=r.properties)==null?void 0:s.configurator}/calculate`,{client_id:e,...t})}}class Kr{constructor(r){i(this,"page",1);i(this,"pageSize",50);this.page=(r==null?void 0:r.page)??1,this.pageSize=(r==null?void 0:r.pageSize)??50}}class kt extends Kr{constructor(e){super(e);i(this,"itemCount",0);i(this,"pageCount",1);i(this,"pageSlot",5);i(this,"pageSizes",[25,50,100]);i(this,"showSizePicker",!0);this.itemCount=(e==null?void 0:e.itemCount)??0,this.pageCount=(e==null?void 0:e.pageCount)??1,this.pageSlot=(e==null?void 0:e.pageSlot)??5,this.pageSizes=(e==null?void 0:e.pageSizes)??[25,50,100],this.showSizePicker=(e==null?void 0:e.showSizePicker)??!0}}class Ot{constructor(r){i(this,"field");i(this,"direction");this.field=(r==null?void 0:r.field)??"",this.direction=(r==null?void 0:r.direction)??"asc"}}class _t{static defaultDateRanges(){const r=g.addBusinessDays(new Date,1);return{nextWorkingDay:{label:"Следующий рабочий день",from:g.startOfDay(r),to:g.endOfDay(r)},today:{label:"Сегодня",from:g.startOfToday(),to:g.endOfToday()},yesterday:{label:"Вчера",from:g.startOfYesterday(),to:g.endOfYesterday()},tomorrow:{label:"Завтра",from:g.startOfTomorrow(),to:g.endOfTomorrow()}}}}class gr{static productIsMeasurable(r){return r.unit.isLinear||r.unit.isSquare}static getProductMultiplicity(r){var e,t;return!((e=r.properties)!=null&&e.ignoreMinCountCheck)&&((t=r.properties)==null?void 0:t.minCount)!=null&&!gr.productIsMeasurable(r)?r.properties.minCount:1}static getProductLengthMultiplicity(r){var e,t,s;return((e=r.properties)==null?void 0:e.lengthStep)!=null?r.properties.lengthStep:!((t=r.properties)!=null&&t.ignoreMinCountCheck)&&((s=r.properties)==null?void 0:s.minCount)!=null?r.properties.minCount:.01}}const ge=class ge extends m{constructor(){super();i(this,"responseDataCacheTimeout");this.responseDataCacheTimeout=b().config.http.responseDataCacheTimeout}static getCachedResponse(e){const t=ge.responseDataCache.get(e);if(t&&t.validTo>new Date)return t.val}cacheResponse(e,t){ge.responseDataCache.set(e,{validTo:g.addSeconds(new Date,this.responseDataCacheTimeout),val:t})}getTypedDataArrayRequester(e,t,s=!1,o={},l=void 0){const h=t+(u.isEmpty(o)?"":` >>> ${JSON.stringify(o)}`),y=s?ge.getCachedResponse(h):void 0;return y?Promise.resolve(y):this.getTypedList(e,t,o,!1,l).then(C=>(s&&C&&this.cacheResponse(h,C),C))}};i(ge,"responseDataCache",new Map);let he=ge;function qt(n,r){const e=[2,0,1,1,1,2],t=Math.floor(Math.abs(n));return r[t%100>4&&t%100<20?2:e[Math.min(t%10,5)]]}class Nt{static generateUndefinedManagerInstance(){return new ce({id:0,name:"- Не назначен -",isActive:!0,guid:"-undefined-"})}static isUndefinedManagerInstance(r){return r.id===0&&r.guid==="-undefined-"}}class Qr extends he{async getManagers(){const r="/internal/managers",e=he.getCachedResponse(r);if(e)return e;const t=await this.get(r),s=I.instanceListInitializer(ce,t.data);return this.cacheResponse(r,s),s}}class fr extends M{constructor(e){super(e);i(this,"name");i(this,"createdAt");i(this,"client");i(this,"sum");this.name=e==null?void 0:e.name,this.createdAt=u.isString(e==null?void 0:e.createdAt)?g.parseISO(e.createdAt):(e==null?void 0:e.createdAt)??new Date,this.client=new F(e==null?void 0:e.client),this.sum=e==null?void 0:e.sum}}class re extends fr{constructor(e){super(e);i(this,"sum");i(this,"products");this.sum=e.sum??0,this.products=(e.products??[]).map(t=>new Ur(t))}}class Ut extends ae{constructor(e){super();i(this,"id");i(this,"clientSearchTerm");i(this,"name");i(this,"createdAt",new A);this.id=e==null?void 0:e.id,this.clientSearchTerm=e==null?void 0:e.clientSearchTerm,this.name=e==null?void 0:e.name,this.createdAt=new A(e==null?void 0:e.createdAt)}resetFilterValue(e){return e==="createdAt"?(this.createdAt.from=null,this.createdAt.to=null):this[e]=void 0,this}asClearRaw(){var t,s;const e=super.asClearRaw();return!((t=e==null?void 0:e.createdAt)!=null&&t.from)&&!((s=e==null?void 0:e.createdAt)!=null&&s.to)&&delete e.createdAt,e}}class Re extends v{}class mr extends hr{constructor(e){var t,s,o,l,h,y,C,P;super(e);i(this,"client");i(this,"payment");i(this,"delivery");i(this,"attachedUser");i(this,"status");i(this,"statusDetail");i(this,"salesDirection");i(this,"attachedAt");i(this,"isOnOrder");i(this,"isNotInStock");i(this,"sum");i(this,"isLargeOrder");this.client=new F(e==null?void 0:e.client),this.payment={type:((t=e==null?void 0:e.payment)==null?void 0:t.type)??-1,status:((s=e==null?void 0:e.payment)==null?void 0:s.status)??-1,onlinePaymentLink:(o=e==null?void 0:e.payment)==null?void 0:o.onlinePaymentLink},this.delivery={type:((l=e==null?void 0:e.delivery)==null?void 0:l.type)??-1,date:u.isString((h=e==null?void 0:e.delivery)==null?void 0:h.date)?g.parseISO(e.delivery.date):((y=e==null?void 0:e.delivery)==null?void 0:y.date)??new Date,address:(C=e==null?void 0:e.delivery)!=null&&C.address?new pe(e.delivery.address):void 0,warehouse:(P=e==null?void 0:e.delivery)!=null&&P.warehouse?new ie(e.delivery.warehouse):void 0},this.attachedUser=e!=null&&e.attachedUser?new L(e==null?void 0:e.attachedUser):void 0,this.status=new Re(e==null?void 0:e.status),this.statusDetail=e!=null&&e.statusDetail?new v(e.statusDetail):void 0,this.salesDirection=new O(e==null?void 0:e.salesDirection),this.attachedAt=u.isString(e==null?void 0:e.attachedAt)?g.parseISO(e.attachedAt):e==null?void 0:e.attachedAt,this.isOnOrder=(e==null?void 0:e.isOnOrder)??!1,this.isNotInStock=(e==null?void 0:e.isNotInStock)??!1,this.sum=(e==null?void 0:e.sum)??0,this.isLargeOrder=(e==null?void 0:e.isLargeOrder)??!1}}class Yr extends Ke{constructor(e,t){super(e);i(this,"product");i(this,"cost");i(this,"costOne");i(this,"costOneRub");i(this,"costRub");i(this,"logicGroupId");i(this,"salesDirection");i(this,"specificationImgUrl");i(this,"sawing");i(this,"currency");i(this,"changedFields",[]);i(this,"replacement");this.product=new j(e.product),this.currency=new _(e.currency),this.cost=e.cost,this.costOne=e.costOne,this.costOneRub=e.costOneRub,this.costRub=e.costRub,this.logicGroupId=e.logicGroupId,this.salesDirection=e.salesDirection,this.specificationImgUrl=e.specificationImgUrl,this.sawing=u.isArray(e.sawing)?e.sawing:e.sawing?[e.sawing]:void 0,t&&(this.replacement=t,this.quantity!==t.quantity&&this.changedFields.push("quantity"),this.length!==t.length&&this.changedFields.push("length"))}}class $ extends mr{constructor(e){var t;super(e);i(this,"products");i(this,"invoices");i(this,"comment");i(this,"image");i(this,"contragent");i(this,"barcode");i(this,"orderSource");i(this,"isAllowProcessingWithoutPayment");i(this,"nextStatuses");i(this,"actions");i(this,"operatorsComment");i(this,"operatorsForWarehouseComment");i(this,"erpOrderUrl");this.products=(e.products??[]).map(s=>{var l;const o=s.replacementId?(l=e.products)==null?void 0:l.find(h=>h.id===s.replacementId):void 0;return new Yr(s,o)}),this.invoices=e.invoices??[],this.comment=e.comment,this.image=e.image,this.contragent=e.contragent?Pe.createInstance(e.contragent):void 0,this.barcode=e.barcode,this.orderSource=e.orderSource?new v(e.orderSource):void 0,this.isAllowProcessingWithoutPayment=e.isAllowProcessingWithoutPayment,this.nextStatuses=(t=e.nextStatuses)==null?void 0:t.map(s=>new Re(s)),this.actions=e.actions,this.operatorsComment=e.operatorsComment,this.operatorsForWarehouseComment=e.operatorsForWarehouseComment,this.erpOrderUrl=e.erpOrderUrl}}class Ht extends E{getOffers(r,e,t,s=void 0){return this.getTypedPaginated(fr,"/internal/orders/offers",r,e,t,{},void 0,s)}createOfferFromCart(r,e,t){return this.post(`/internal/orders/offers/${r}`,{name:e,items:t!=null&&t.length?t:void 0},s=>new re(s.data))}getOffer(r){return this.get(`/internal/orders/offers/${r}`,{},e=>new re(e.data))}updateOffer(r,e){return this.patch(`/internal/orders/offers/${r}`,{name:e},t=>new re(t.data))}deleteOffer(r){return this.delete(`/internal/orders/offers/${r}`)}createOrderFromDraft(r,e,t,s={}){const o=b().config.dateFormats.api;return this.post(`/internal/orders/offers/${r}/create-order`,{...e,deliveryDate:e.deliveryDate?g.format(e.deliveryDate,o):void 0,items:t!=null&&t.length?t:void 0},l=>I.instanceListInitializer($,l.data),s)}addOfferProduct(r,e,t={}){return this.post(`/internal/orders/offers/${r}/products`,{product_id:e.product.id,product_category_id:e.configurator?e.category.id:void 0,quantity:e.quantity,height:e.height,length:e.length,width:e.width,configurator:e.configurator,marker:e.marker,is_additional_sale:e.isAdditionalSale,...e.configuratorParams},s=>new re(s.data),t)}patchOfferProduct(r,e,t,s={}){return this.patch(`/internal/orders/offers/${r}/products/${e}`,{product_id:t.product.id,product_category_id:t.configurator?t.category.id:void 0,quantity:t.quantity,height:t.height,length:t.length,width:t.width,configurator:t.configurator,marker:t.marker,...t.configuratorParams},o=>new re(o.data),s)}deleteOfferProduct(r,e){return this.delete(`/internal/orders/offers/${r}/products/${e}`,t=>new re(t.data))}getOfferHtml(r,e){return this.get(`/internal/orders/offers/${r}/view`,e?{recipientText:e}:{},t=>new Blob([t.data],{type:"text/html"}))}getOfferPdf(r,e){return this.getBlob(`/internal/orders/offers/${r}/download`,e?{recipientText:e}:{},t=>new Blob([t.request.response],{type:"application/pdf"}))}sendOffer(r,e){return this.post(`/internal/orders/offers/${r}/send`,e)}}var Xr=(n=>(n.View="view",n.Share="share",n.EditTags="edit_tags",n.SaveOrderIgnoredProducts="save_order_ignored_products",n.ChangeStatus="change_status",n.ChangeProducts="change_products",n.ChangeOrderParameters="change_order_parameters",n.Recalculate="recalculate",n.AttachOrder="attach_order",n.DetachOrder="detach_order",n.ChangeAttachedOperator="change_attached_operator",n.SendOnlinePaymentLink="send_online_payment_link",n.ConfirmOnlineFullPayment="confirm_online_full_payment",n.MergeOrders="merge_orders",n.GetHistory="get_history",n.CloneOrder="clone_order",n.DeleteAttachedFile="delete_attached_file",n))(Xr||{});class Bt{constructor(r){i(this,"paymentType");i(this,"deliveryType");i(this,"contragentId");i(this,"deliveryDate");i(this,"addressId");i(this,"warehouseId");i(this,"image");i(this,"comment");i(this,"barcode");i(this,"operatorsComment");i(this,"operatorsForWarehouseComment");i(this,"additionalEmails");i(this,"isAllowProcessingWithoutPayment");i(this,"isAdditionalSale");var e,t,s;this.paymentType=r==null?void 0:r.payment.type,this.deliveryType=r==null?void 0:r.delivery.type,this.contragentId=(e=r==null?void 0:r.contragent)==null?void 0:e.id,this.deliveryDate=r!=null&&r.delivery.date?new Date(r.delivery.date):void 0,this.addressId=(t=r==null?void 0:r.delivery.address)==null?void 0:t.id,this.warehouseId=(s=r==null?void 0:r.delivery.warehouse)==null?void 0:s.id,this.comment=r==null?void 0:r.comment,this.barcode=r==null?void 0:r.barcode,this.operatorsComment=r==null?void 0:r.operatorsComment,this.operatorsForWarehouseComment=r==null?void 0:r.operatorsForWarehouseComment,this.isAllowProcessingWithoutPayment=r==null?void 0:r.isAllowProcessingWithoutPayment}}class yr extends v{}class wr extends v{}class Mt extends ae{constructor(e){var t,s,o,l;super();i(this,"attachedUsers");i(this,"clientSearchTerm");i(this,"client");i(this,"contragent");i(this,"createdAt",new A);i(this,"creator");i(this,"deliveryDate",new A);i(this,"deliveryAddressSearch");i(this,"clientCities");i(this,"id");i(this,"isApproved");i(this,"isNotInStock");i(this,"isOnOrder");i(this,"attachedAt",new A);i(this,"salesDirections");i(this,"status");i(this,"statusDetail");i(this,"deliveryType");i(this,"paymentType");i(this,"warehouses");i(this,"isLargeOrder");i(this,"isToProcess");i(this,"onlyMyRegions");this.attachedUsers=(t=e==null?void 0:e.attachedUsers)==null?void 0:t.map(h=>"isActive"in h?new ce(h):new yr(h)),this.clientSearchTerm=e==null?void 0:e.clientSearchTerm,this.client=e!=null&&e.client?new F(e.client):void 0,this.contragent=e==null?void 0:e.contragent,this.createdAt=new A(e==null?void 0:e.createdAt),this.creator=e!=null&&e.creator?new L(e.creator):void 0,this.deliveryDate=new A(e==null?void 0:e.deliveryDate),this.deliveryAddressSearch=e==null?void 0:e.deliveryAddressSearch,this.clientCities=(s=e==null?void 0:e.clientCities)==null?void 0:s.map(h=>new X(h)),this.id=e==null?void 0:e.id,this.isApproved=e==null?void 0:e.isApproved,this.isNotInStock=e==null?void 0:e.isNotInStock,this.isOnOrder=e==null?void 0:e.isOnOrder,this.isLargeOrder=e==null?void 0:e.isLargeOrder,this.attachedAt=new A(e==null?void 0:e.attachedAt),this.salesDirections=(o=e==null?void 0:e.salesDirections)==null?void 0:o.map(h=>new O(h)),this.status=e==null?void 0:e.status,this.statusDetail=e==null?void 0:e.statusDetail,this.deliveryType=e!=null&&e.deliveryType?new N(e.deliveryType):void 0,this.paymentType=e!=null&&e.paymentType?new wr(e.paymentType):void 0,this.warehouses=(l=e==null?void 0:e.warehouses)==null?void 0:l.map(h=>new ie(h)),this.isToProcess=e==null?void 0:e.isToProcess}resetFilterValue(e){switch(e){case"createdAt":this.createdAt.from=null,this.createdAt.to=null;break;case"creator":this.creator=void 0;break;case"deliveryDate":this.deliveryDate.from=null,this.deliveryDate.to=null;break;case"deliveryType":this.deliveryType=new N;break;case"clientCities":this.clientCities=[];break;case"attachedAt":this.attachedAt.from=null,this.attachedAt.to=null;break;case"salesDirection":case"salesDirections":this.salesDirections=[];break;case"status":this.status=[];break;case"warehouse":case"warehouses":this.warehouses=[];break;default:this[e]=void 0;break}return this}asClearRaw(){var t,s,o,l,h,y;const e=super.asClearRaw();return!((t=e==null?void 0:e.createdAt)!=null&&t.from)&&!((s=e==null?void 0:e.createdAt)!=null&&s.to)&&delete e.createdAt,!((o=e==null?void 0:e.deliveryDate)!=null&&o.from)&&!((l=e==null?void 0:e.deliveryDate)!=null&&l.to)&&delete e.deliveryDate,!((h=e==null?void 0:e.attachedAt)!=null&&h.from)&&!((y=e==null?void 0:e.attachedAt)!=null&&y.to)&&delete e.attachedAt,e}}class Zr{constructor(r){i(this,"user");i(this,"status");i(this,"statusDetail");i(this,"createdAt");this.user=new L(r==null?void 0:r.user),this.status=new Re(r==null?void 0:r.status),this.statusDetail=r!=null&&r.statusDetail?new v(r.statusDetail):void 0,this.createdAt=u.isString(r==null?void 0:r.createdAt)?g.parseISO(r.createdAt):(r==null?void 0:r.createdAt)??new Date}}class jt extends E{getOrders(r,e,t,s=void 0){return this.getTypedPaginated(mr,"/internal/orders",r,e,t,{},void 0,s)}getOrdersCount(r,e=void 0){return this.get("/internal/orders/count",r?{filters:JSON.stringify((r instanceof G?r:new G(r)).toPrimitive())}:{},void 0,void 0,e).then(t=>t.count)}getClientOrderStatistics(r,e){return this.get(`/internal/clients/${r}/orders/statistics`,e?{period:e}:{})}getOrder(r){return this.get(`/internal/orders/${r}`,{},e=>new $(e.data))}createClientOrder(r,e,t,s,o={}){const l=b().config.dateFormats.api;return this.post(`/internal/clients/${r}/orders/${e}`,{...t,deliveryDate:g.format(t.deliveryDate,l),items:s!=null&&s.length?s:void 0},h=>I.instanceListInitializer($,h.data),o)}attachOrder(r){return this.patch(`/internal/orders/${r}/attach`,{},e=>new $(e.data))}detachOrder(r){return this.patch(`/internal/orders/${r}/detach`,{},e=>new $(e.data))}mergeOrders(r,e){return this.patch(`/internal/orders/${r}/merge`,{ids:e},t=>new $(t.data))}recalculateOrder(r){return this.patch(`/internal/orders/${r}/recalculate`,{},e=>new $(e.data))}cloneOrder(r){return this.get(`/internal/orders/${r}/clone`,{})}updateOrder(r,e,t={}){const s=b().config.dateFormats.api;return this.patch(`/internal/orders/${r}`,{...e,deliveryDate:e.deliveryDate?g.format(e.deliveryDate,s):void 0},o=>new $(o.data),t)}addOrderProduct(r,e,t={}){return this.post(`/internal/orders/${r}/products`,{product_id:e.product.id,product_category_id:e.configurator?e.category.id:void 0,quantity:e.quantity,height:e.height,length:e.length,width:e.width,configurator:e.configurator,marker:e.marker,is_additional_sale:e.isAdditionalSale,...e.configuratorParams},s=>new $(s.data),t)}changeOrderStatus(r,e,t,s={}){return this.patch(`/internal/orders/${r}/status`,{status:e,statusDetail:t},o=>new $(o.data),s)}changeOrderStatusDetail(r,e){return this.patch(`/internal/orders/${r}/status`,{statusDetail:e},t=>new $(t.data))}getOrderStatusHistory(r){return this.getTypedList(Zr,`/internal/orders/${r}/history`)}getOrderPrintHtml(r,e){return this.get(`/internal/orders/${r}/print/view`,{...e},t=>new Blob([t.data],{type:"text/html"}))}getOrderPrintPdf(r,e){return this.getBlob(`/internal/orders/${r}/print/download`,{...e},t=>new Blob([t.request.response],{type:"application/pdf"}))}sendOrderPrint(r,e){return this.post(`/internal/orders/${r}/print/send`,e)}changeAttachedOperator(r,e){return this.patch(`/internal/orders/${r}/change-attached-operator`,{operatorId:e},t=>new $(t.data))}deleteOrderAttachedFile(r){return this.delete(`/internal/orders/${r}/file/attached`,e=>new $(e.data))}deleteOrderProduct(r,e){return this.delete(`/internal/orders/${r}/products/${e}`,t=>new $(t.data))}patchOrderProduct(r,e,t,s={}){return this.patch(`/internal/orders/${r}/products/${e}`,{product_id:t.product.id,product_category_id:t.configurator?t.category.id:void 0,quantity:t.quantity,height:t.height,length:t.length,width:t.width,configurator:t.configurator,marker:t.marker,...t.configuratorParams},o=>new $(o.data),s)}getDeliveryNearestDates(r,e=void 0){return this.get(`/internal/orders/delivery/${r}/nearest-dates`,{},t=>t.data,void 0,e)}getSelfDeliveryNearestDates(r,e=void 0){return this.get(`/internal/orders/self-delivery/${r}/nearest-dates`,{},t=>t.data,void 0,e)}getDeliveryCost(r,e,t,s=void 0){const o=b().config.dateFormats.api;return this.get(`/internal/orders/delivery/${r}/cost`,{date:g.format(e,o),warehouse_id:t},l=>l.data,void 0,s)}}class He{constructor(r){i(this,"client");i(this,"product");i(this,"cost");i(this,"costCoefficient");i(this,"source");this.client=new F(r==null?void 0:r.client),this.product=new k(r==null?void 0:r.product),this.cost=(r==null?void 0:r.cost)??0,this.costCoefficient=(r==null?void 0:r.costCoefficient)??0,this.source=(r==null?void 0:r.source)??be.Product}}const Cr=n=>{var r,e,t,s,o;return n?u.omitBy({cities:(r=n.cities)==null?void 0:r.map(l=>l.id),clients:(e=n.clients)==null?void 0:e.map(l=>l.id),managers:(t=n.managers)==null?void 0:t.map(l=>l.id),partnerGroups:(s=n.partnerGroups)==null?void 0:s.map(l=>l.id),salesDirections:(o=n.salesDirections)==null?void 0:o.map(l=>l.id),hideNotActive:n.hideNotActive},l=>u.isNil(l)||(u.isArray(l)||u.isObject(l))&&u.isEmpty(l)):{}},xr=n=>{const r={};return n.from&&(n.from.coefficient||n.from.value)&&(r.from={},n.from.coefficient&&(r.from.priceCoefficientId=n.from.coefficient.id),n.from.value&&(r.from.increasePercent=n.from.value)),n.to&&(n.to.coefficient||n.to.value)&&(r.to={},n.to.coefficient&&(r.to.priceCoefficientId=n.to.coefficient.id),n.to.value&&(r.to.increasePercent=n.to.value)),r};class Ft extends m{analyzeProductPrices(r,e,t){return this.get(`/internal/price/products/${r}/analyze`,{...xr(e),filters:Cr(t)},s=>I.instanceListInitializer(He,s.data))}analyzeCategoryPrices(r,e,t){return this.get(`/internal/price/categories/${r}/analyze`,{...xr(e),filters:Cr(t)},s=>I.instanceListInitializer(He,s.data))}analyzeCategoryPricesBySquare(r,e,t){return this.get(`/internal/price/categories/${r}/analyze/square`,{...e,filters:Cr(t)},s=>I.instanceListInitializer(He,s.data))}}class Er{constructor(r){i(this,"cost");i(this,"isLowCost");i(this,"isRetail");i(this,"costDate");i(this,"discountName");i(this,"priceTemplateName");i(this,"product");i(this,"client");i(this,"executor");i(this,"currency");this.cost=r.cost??0,this.isLowCost=r.isLowCost??!1,this.isRetail=r.isRetail??!1,this.costDate=u.isString(r.costDate)?g.parseISO(r.costDate):r.costDate??new Date,this.discountName=r.discountName,this.priceTemplateName=r.priceTemplateName,this.product=r.product?new se(r.product):void 0,this.client=r.client?new L(r.client):void 0,this.executor=r.executor?new L(r.executor):void 0,this.currency=r.currency?new _(r.currency):void 0}}class et extends se{constructor(e){super(e);i(this,"history");this.history=u.map(e.history,t=>new Er(t))}}class Gt extends m{getProductPriceHistory(r){var o,l,h,y,C;const e=b().config.dateFormats.api,t=u.omitBy(u.merge(r,{costDate:{from:u.isDate((o=r.costDate)==null?void 0:o.from)?g.format(r.costDate.from,e):(l=r.costDate)==null?void 0:l.from,to:u.isDate((h=r.costDate)==null?void 0:h.to)?g.format(r.costDate.to,e):(y=r.costDate)==null?void 0:y.to}}),P=>u.isNil(P)||(u.isArray(P)||u.isObject(P))&&u.isEmpty(P)),s=((C=r.product)==null?void 0:C[0])??0;return delete t.product,this.get(`/internal/price/products/${s}/history`,t).then(P=>[new et(u.merge(P[0],{history:P}))])}}class vr{constructor(r){i(this,"products",[]);i(this,"productCategories",[]);r!=null&&r.products&&(this.products=r.products.map(e=>new se(e))),r!=null&&r.productCategories&&(this.productCategories=r.productCategories.map(e=>new se(e)))}}class zt extends m{getProductCategoryRecommendations(r){return this.get(`/internal/catalog/recommendations/categories/${r.id}`,{},e=>new vr(e.data))}getProductRecommendations(r){return this.get(`/internal/catalog/recommendations/products/${r.id}`,{},e=>new vr(e.data))}saveProductCategoryRecommendations(r,e){return this.post(`/internal/catalog/recommendations/categories/${r.id}`,{product_categories:e.productCategories.map(t=>t.id),products:e.products.map(t=>t.id)})}saveProductRecommendations(r,e){return this.post(`/internal/catalog/recommendations/products/${r.id}`,{product_categories:e.productCategories.map(t=>t.id),products:e.products.map(t=>t.id)})}}var rt=(n=>(n.New="new",n.Processing="processing",n.AwaitingSupplyProducts="awaiting_supply_products",n.InvoiceIssued="invoice_issued",n.ProcessingOnStock="processing_on_stock",n.Finished="finished",n.OrderUpdated="order_updated",n.Canceled="canceled",n.Error="error",n))(rt||{}),tt=(n=>(n.CanceledBy1c="canceled_by1c",n.CanceledByClient="canceled_by_client",n.FinishedNotApproved="finished_not_approved",n.ProcessingByPurchasingDepartment="processing_by_purchasing_department",n.WillWaiting="will_waiting",n))(tt||{});class it extends v{}class st extends v{}class Be extends S{constructor(e){super(e);i(this,"abbr");this.abbr=(e==null?void 0:e.abbr)??""}}class Pr extends v{constructor(e){var t;super(e);i(this,"userRegions");this.userRegions=((t=e==null?void 0:e.userRegions)==null?void 0:t.map(s=>new Be(s)))??[]}}class nt extends v{}class ot extends v{}class ct extends v{}class lt extends v{}class Wt{static generateUndefinedInstance(r,e="- Не определён -"){return new r({id:0,name:e,slug:"-undefined-"})}static isUndefinedInstance(r){return r.id===0&&r.slug==="-undefined-"}}class ar extends v{}const B=class B extends he{static withoutUnknownLocation(r){return r.filter(e=>e.id!==B.unknownLocationId)}getReference(r,e=!1){return this.getTypedDataArrayRequester(it,`/internal/references/${r}`,e)}getChannelPrimaryInterest(){return this.getTypedDataArrayRequester(lr,"/internal/references/channel-primary-interest",!0)}getContactPositions(){return this.getTypedDataArrayRequester(nt,"/internal/references/contact-position",!0)}getCuratedDirection(){return this.getTypedDataArrayRequester(Ie,"/internal/references/curated-direction",!0)}getCurrency(){return this.getTypedDataArrayRequester(_,"/public/references/currency",!0)}getPartnerGroup(){return this.getTypedDataArrayRequester(ee,"/internal/references/partner-group",!0)}getOpf(){return this.getTypedDataArrayRequester(W,"/public/references/opf",!0)}getOperators(){return this.getTypedDataArrayRequester(yr,"/internal/references/operator",!0)}getOrderPaymentStatuses(){return this.getTypedDataArrayRequester(ot,"/public/references/order-payment-status",!0)}getOrderStatuses(){return this.getTypedDataArrayRequester(Re,"/internal/references/order-status",!0)}getOrderStatusDetails(){return this.getTypedDataArrayRequester(ct,"/internal/references/order-status-detail",!0)}getPaymentTypes(){return this.getTypedDataArrayRequester(wr,"/public/references/payment-type",!0)}getResourceTypes(){return this.getTypedDataArrayRequester(ar,"/internal/references/resource-type",!0)}getSalesDirections(){return this.getTypedDataArrayRequester(O,"/public/references/sales-direction",!0)}getSourcePrimaryInterest(){return this.getTypedDataArrayRequester(ur,"/internal/references/source-primary-interest",!0)}searchCity(r){return this.getTypedDataArrayRequester(X,`/internal/references/city-with-region-and-country/search?term=${r}`)}searchRegion(r){return this.getTypedDataArrayRequester(Y,`/internal/references/region-with-country/search?term=${r}`)}getRegionsByCountry(r){return this.getTypedDataArrayRequester(Y,"/internal/references/region",!1,{params:{countryId:r}}).then(e=>B.withoutUnknownLocation(e))}getCitiesByRegion(r){return this.getTypedDataArrayRequester(st,"/internal/references/city",!1,{params:{regionId:r}}).then(e=>B.withoutUnknownLocation(e))}getCitiesWithUserRegionByRegion(r){return this.getTypedDataArrayRequester(Pr,"/internal/references/city-with-user-region",!1,{params:{regionId:r}}).then(e=>B.withoutUnknownLocation(e))}searchCityWithRegion(r,e,t=void 0){return this.getTypedDataArrayRequester(X,"/internal/references/city-with-region/search",!1,{term:r,...e?{params:{countryId:e}}:{}},t).then(s=>B.withoutUnknownLocation(s))}searchCityWithUserRegion(r,e=void 0){return this.getTypedDataArrayRequester(Pr,"/internal/references/city-with-user-region/search",!1,{term:r},e).then(t=>B.withoutUnknownLocation(t))}searchCountry(r){return this.getTypedDataArrayRequester(Q,`/internal/references/country/search?term=${r}`)}getDeliveryTypes(){return this.getTypedDataArrayRequester(N,"/internal/references/delivery-type",!0)}getWarehouses(){return this.getTypedDataArrayRequester(ie,"/public/references/warehouse",!0)}getPropertyTypes(){return this.getTypedDataArrayRequester(xe,"/internal/references/property-type",!0)}getPriceCoefficients(){return this.getTypedDataArrayRequester(Ce,"/internal/references/price-coefficient",!0)}getProductFileType(){return this.getTypedDataArrayRequester(lt,"/public/references/product-file-type",!0)}};i(B,"unknownLocationId",1);let R=B;const T=J.defineStore("common.references_private",()=>{const n=f.ref({}),r=f.ref(void 0),e=f.ref(void 0),t=f.ref(void 0),s=f.ref(void 0),o=f.ref(void 0),l=f.ref(void 0),h=f.ref(void 0),y=f.ref(void 0),C=f.ref(void 0),P=f.ref(void 0),D=f.ref(void 0),De=f.ref(void 0),Ae=f.ref(void 0),fe=f.ref(void 0),me=f.ref(void 0),Dr=f.ref(void 0),Ar=f.ref(void 0),Tr=f.ref(void 0),p=f.ref(void 0);return{dataLoaderList:n,channelPrimaryInterestReference:r,contactPositionsReference:e,currencyReference:t,deliveryTypeReference:s,managersList:o,opfReference:l,operatorReference:h,orderPaymentStatusReference:y,orderStatusReference:C,orderStatusDetailReference:P,paymentTypeReference:D,partnerGroupReference:De,productFileTypeReference:Ae,resourceTypesReference:fe,salesDirectionsReference:me,sourcePrimaryInterestReference:Dr,warehousesReference:Ar,propertyTypesReference:Tr,priceCoefficientsReference:p}}),Jt=J.defineStore("common.references",()=>{const n=f.computed(()=>{const p=T();return!p.channelPrimaryInterestReference&&!p.dataLoaderList.channelPrimaryInterestReference&&(p.dataLoaderList.channelPrimaryInterestReference=!0,m.getInstance(R).getChannelPrimaryInterest().then(w=>{p.channelPrimaryInterestReference=w}).catch(u.noop)),p.channelPrimaryInterestReference}),r=f.computed(()=>{const p=T();return!p.contactPositionsReference&&!p.dataLoaderList.contactPositionsReference&&(p.dataLoaderList.contactPositionsReference=!0,m.getInstance(R).getContactPositions().then(w=>{p.contactPositionsReference=w}).catch(u.noop)),p.contactPositionsReference}),e=f.computed(()=>{const p=T();return!p.currencyReference&&!p.dataLoaderList.currencyReference&&(p.dataLoaderList.currencyReference=!0,m.getInstance(R).getCurrency().then(w=>{p.currencyReference=w}).catch(u.noop)),p.currencyReference}),t=f.computed(()=>{const p=T();return!p.opfReference&&!p.dataLoaderList.opfReference&&(p.dataLoaderList.opfReference=!0,m.getInstance(R).getOpf().then(w=>{p.opfReference=w}).catch(u.noop)),p.opfReference}),s=f.computed(()=>{const p=T();return!p.operatorReference&&!p.dataLoaderList.operatorReference&&(p.dataLoaderList.operatorReference=!0,m.getInstance(R).getOperators().then(w=>{p.operatorReference=w}).catch(u.noop)),p.operatorReference}),o=f.computed(()=>{const p=T();return!p.orderPaymentStatusReference&&!p.dataLoaderList.orderPaymentStatusReference&&(p.dataLoaderList.orderPaymentStatusReference=!0,m.getInstance(R).getOrderPaymentStatuses().then(w=>{p.orderPaymentStatusReference=w}).catch(u.noop)),p.orderPaymentStatusReference}),l=f.computed(()=>{const p=T();return!p.orderStatusReference&&!p.dataLoaderList.orderStatusReference&&(p.dataLoaderList.orderStatusReference=!0,m.getInstance(R).getOrderStatuses().then(w=>{p.orderStatusReference=w}).catch(u.noop)),p.orderStatusReference}),h=f.computed(()=>{const p=T();return!p.orderStatusDetailReference&&!p.dataLoaderList.orderStatusDetailReference&&(p.dataLoaderList.orderStatusDetailReference=!0,m.getInstance(R).getOrderStatusDetails().then(w=>{p.orderStatusDetailReference=w}).catch(u.noop)),p.orderStatusDetailReference}),y=f.computed(()=>{const p=T();return!p.paymentTypeReference&&!p.dataLoaderList.paymentTypeReference&&(p.dataLoaderList.paymentTypeReference=!0,m.getInstance(R).getPaymentTypes().then(w=>{p.paymentTypeReference=w}).catch(u.noop)),p.paymentTypeReference}),C=f.computed(()=>{const p=T();return!p.partnerGroupReference&&!p.dataLoaderList.partnerGroupReference&&(p.dataLoaderList.partnerGroupReference=!0,m.getInstance(R).getPartnerGroup().then(w=>{p.partnerGroupReference=w}).catch(u.noop)),p.partnerGroupReference}),P=f.computed(()=>{const p=T();return!p.productFileTypeReference&&!p.dataLoaderList.productFileTypeReference&&(p.dataLoaderList.productFileTypeReference=!0,m.getInstance(R).getProductFileType().then(w=>{p.productFileTypeReference=w}).catch(u.noop)),p.productFileTypeReference}),D=f.computed(()=>{const p=T();return!p.resourceTypesReference&&!p.dataLoaderList.resourceTypesReference&&(p.dataLoaderList.resourceTypesReference=!0,m.getInstance(R).getResourceTypes().then(w=>{p.resourceTypesReference=w}).catch(u.noop)),p.resourceTypesReference}),De=f.computed(()=>{const p=T();return!p.salesDirectionsReference&&!p.dataLoaderList.salesDirectionsReference&&(p.dataLoaderList.salesDirectionsReference=!0,m.getInstance(R).getSalesDirections().then(w=>{p.salesDirectionsReference=w}).catch(u.noop)),p.salesDirectionsReference}),Ae=f.computed(()=>{const p=T();return!p.sourcePrimaryInterestReference&&!p.dataLoaderList.sourcePrimaryInterestReference&&(p.dataLoaderList.sourcePrimaryInterestReference=!0,m.getInstance(R).getSourcePrimaryInterest().then(w=>{p.sourcePrimaryInterestReference=w}).catch(u.noop)),p.sourcePrimaryInterestReference}),fe=f.computed(()=>{const p=T();return!p.deliveryTypeReference&&!p.dataLoaderList.deliveryTypeReference&&(p.dataLoaderList.deliveryTypeReference=!0,m.getInstance(R).getDeliveryTypes().then(w=>{p.deliveryTypeReference=w}).catch(u.noop)),p.deliveryTypeReference}),me=f.computed(()=>{const p=T();return!p.managersList&&!p.dataLoaderList.managersList&&(p.dataLoaderList.managersList=!0,m.getInstance(Qr).getManagers().then(w=>{p.managersList=w}).catch(u.noop)),p.managersList}),Dr=f.computed(()=>{const p=T();return!p.warehousesReference&&!p.dataLoaderList.warehousesReference&&(p.dataLoaderList.warehousesReference=!0,m.getInstance(R).getWarehouses().then(w=>{p.warehousesReference=w}).catch(u.noop)),p.warehousesReference}),Ar=f.computed(()=>{const p=T();return!p.propertyTypesReference&&!p.dataLoaderList.propertyTypesReference&&(p.dataLoaderList.propertyTypesReference=!0,m.getInstance(R).getPropertyTypes().then(w=>{p.propertyTypesReference=w}).catch(u.noop)),p.propertyTypesReference}),Tr=f.computed(()=>{const p=T();return!p.priceCoefficientsReference&&!p.dataLoaderList.priceCoefficientsReference&&(p.dataLoaderList.priceCoefficientsReference=!0,m.getInstance(R).getPriceCoefficients().then(w=>{p.priceCoefficientsReference=w}).catch(u.noop)),p.priceCoefficientsReference});return{channelPrimaryInterestsReference:n,contactPositionsReference:r,currencyReference:e,opfReference:t,operatorReference:s,orderPaymentStatusReference:o,orderStatusReference:l,orderStatusDetailReference:h,paymentTypeReference:y,partnerGroupsReference:C,productFilesTypesReference:P,resourceTypesReference:D,salesDirectionsReference:De,sourcePrimaryInterestsReference:Ae,deliveryTypeReference:fe,managersList:me,warehousesReference:Dr,propertyTypesReference:Ar,priceCoefficientsReference:Tr}});class ut{constructor(r){i(this,"name");i(this,"content");this.name=r.name,this.content=r.content}}class Rr{constructor(r){i(this,"resourceType");i(this,"resourceId");i(this,"h1");i(this,"title");i(this,"description");i(this,"keywords");i(this,"meta");i(this,"tags");var e;this.resourceType=new ar(r==null?void 0:r.resourceType),this.resourceId=(r==null?void 0:r.resourceId)??"",this.h1=r==null?void 0:r.h1,this.title=r==null?void 0:r.title,this.description=r==null?void 0:r.description,this.keywords=r==null?void 0:r.keywords,this.meta=((e=r==null?void 0:r.meta)==null?void 0:e.map(t=>new ut(t)))??[],this.tags=r==null?void 0:r.tags}}class Vt extends m{getResourceSeoData(r,e){return this.get(`/internal/seo/${r.slug}/${e}`,{},t=>new Rr(t.data))}saveResourceSeoData(r,e={}){return this.post(`/internal/seo/${r.resourceType.slug}/${r.resourceId}`,r,t=>new Rr(t.data),e)}deleteResourceSeoData(r,e){return this.delete(`/internal/seo/${r.slug}/${e}`)}}class Kt extends m{searchAddresses(r){return this.execSuggestionQuery("/public/suggestions/address",r)}searchBank(r){return this.execSuggestionQuery("/public/suggestions/bank",r)}searchOrganization(r){return this.execSuggestionQuery("/public/suggestions/organization",r)}execSuggestionQuery(r,e){return this.get(r,{query:e}).then(t=>{const s=[...t];let o=1;return s.forEach(l=>{l.id=o++}),s})}}var pt=(n=>(n.Admin="admin",n.Manager="manager",n.Operator="operator",n.Client="client",n.Guest="guest",n))(pt||{});class ht extends Ze{constructor(e){super(e);i(this,"type");i(this,"canDoReclamations");i(this,"photo");i(this,"pricingRole");this.type=e==null?void 0:e.type,this.canDoReclamations=(e==null?void 0:e.canDoReclamations)??!1,this.photo=e==null?void 0:e.photo,this.pricingRole=e!=null&&e.pricingRole?new Ye(e.pricingRole):void 0}}class Qt extends m{constructor(){super(),this.baseUrl=`${b().config.http.portalApiUrl}/api`,this.interceptorIds.request.authRequestInterceptor&&this.httpClient.interceptors.request.eject(this.interceptorIds.request.authRequestInterceptor)}getAccessToken(){return this.get("internal/users/current-tokens").then(r=>r.accessToken)}}class gt extends m{getCurrentUser(){return this.get("/internal/users/info",{},r=>new ht(r.data),!0)}}const Yt=J.defineStore("common.user_state_private",()=>{const n=f.ref({}),r=f.ref(void 0);return{dataLoaderList:n,currentUser:r}}),Xt=J.defineStore("common.user_state",()=>({currentUser:f.computed(()=>{const r=Yt();return!r.currentUser&&!r.dataLoaderList.currentUser&&(r.dataLoaderList.currentUser=!0,m.getInstance(gt).getCurrentUser().then(e=>{r.currentUser=e}).catch(u.noop).finally(()=>{r.dataLoaderList.currentUser=!1})),r.currentUser})}));class Me{constructor(r){i(this,"user");i(this,"salesDirection");this.user=new L(r==null?void 0:r.user),this.salesDirection=new O(r==null?void 0:r.salesDirection)}}class je extends Be{constructor(e){var t,s;super(e);i(this,"cities");i(this,"users");this.cities=((t=e==null?void 0:e.cities)==null?void 0:t.map(o=>new X(o)))??[],this.users=((s=e==null?void 0:e.users)==null?void 0:s.map(o=>new Me(o)))??[]}}class Zt extends ae{constructor(e){super();i(this,"id");i(this,"name");i(this,"abbr");this.id=e==null?void 0:e.id,this.name=e==null?void 0:e.name,this.abbr=e==null?void 0:e.abbr}resetFilterValue(e){switch(e){case"id":case"name":case"abbr":this[e]=void 0;break}return this}}class xt extends E{getRegionsList(r,e,t){return this.getTypedPaginated(Be,"/internal/users/regions",r,e,t)}getRegion(r){return this.get(`/internal/users/regions/${r}`,{},e=>new je(e.data))}createRegion(r,e={}){return this.post("/internal/users/regions",r,t=>new je(t.data),e)}updateRegion(r,e,t={}){return this.patch(`/internal/users/regions/${r}`,e,s=>new je(s.data),t)}removeRegion(r){return this.delete(`/internal/users/regions/${r}`)}getRegionEmployees(r){return this.getTypedList(Me,`/internal/users/regions/${r}/users`)}attachRegionEmployee(r,e,t){return this.post(`/internal/users/regions/${r}/users/${e}`,{salesDirectionId:t},s=>new Me(s.data))}detachRegionEmployee(r,e,t){return this.request({method:"DELETE",url:`/internal/users/regions/${r}/users/${e}`,params:{sales_direction_id:t}})}}class Et{constructor(r,e){i(this,"showFeedback",!1);i(this,"feedback","");i(this,"validationStatus");this.showFeedback=!!r,this.feedback=r,this.validationStatus=e}}c.AnyReference=it,c.AppBaseConfig=Lr,c.BankAccount=qe,c.BasePaginationProvider=E,c.CalculationTypeEnum=Hr,c.Cart=oe,c.CartProvider=ft,c.CatalogProvider=wt,c.CatalogableItem=Ve,c.Category=U,c.CategoryFilterSetting=er,c.CategoryPricingRule=Ee,c.ChannelPrimaryInterest=lr,c.City=st,c.CityWithRegionAndCountry=X,c.CityWithUserRegion=Pr,c.Client=pr,c.ClientAdditionalData=Wr,c.ClientCategory=ve,c.ClientDataProvider=q,c.ClientPriceProvider=Ct,c.ClientPriceTemplateProvider=vt,c.ClientProduct=j,c.ClientProductCategoryDataProvider=Rt,c.ClientProductDataProvider=Dt,c.ClientShortInfo=F,c.ClientsAdditionalDataRequestTypeEnum=Fr,c.ClientsListFilters=bt,c.CodedIdentity=se,c.ConfiguratorProvider=Lt,c.ConfiguratorsEnum=Vr,c.Contact=Ne,c.ContactLinks=Qe,c.ContactPerson=z,c.ContactPersonRelated=Jr,c.ContactPosition=nt,c.ContactRelation=Ue,c.ContragentBase=nr,c.ContragentFactory=Pe,c.ContragentIc=or,c.ContragentPerson=Gr,c.ContragentUlNr=zr,c.ContragentUlR=cr,c.CostSourceEnum=be,c.Country=Q,c.CuratedDirection=Ie,c.Curator=ke,c.Currency=_,c.DataSuggestionProvider=Kt,c.DateTimeProvider=_t,c.DeletableNamedIdentity=sr,c.DeliveryAddress=pe,c.DeliveryType=N,c.DetailedJwtPayload=Fe,c.DeviceTypeResolutionConfig=$r,c.DiscountShortInfo=Or,c.FieldValidationResultData=Et,c.FilterGroup=G,c.FilterItem=rr,c.FilterOpEnum=_e,c.FilterSettings=jr,c.GeoCoordinates=We,c.HiddenCatalogableItem=qr,c.HttpCachedRequester=he,c.HttpParamsConfig=br,c.HttpRequester=m,c.Identity=M,c.Image=Nr,c.JwtPayload=V,c.Manager=ce,c.ManagerCommon=de,c.ManagerDataFactory=Nt,c.ManagerDataProvider=Qr,c.MetaTagItem=ut,c.NamedIdentity=S,c.Offer=re,c.OfferShortInfo=fr,c.OffersDataProvider=Ht,c.OffersListFilters=Ut,c.Operator=yr,c.Opf=W,c.OpfEnum=H,c.Order=$,c.OrderAction=Xr,c.OrderEditorData=Bt,c.OrderInfo=mr,c.OrderItem=Yr,c.OrderItemBase=Ke,c.OrderPaymentStatus=ot,c.OrderShortInfo=hr,c.OrderStatus=Re,c.OrderStatusDetail=ct,c.OrderStatusDetailEnum=tt,c.OrderStatusEnum=rt,c.OrderStatusHistoryInfo=Zr,c.OrdersDataProvider=jt,c.OrdersListFilters=Mt,c.PaginationFiltersBase=ae,c.PartnerGroup=ee,c.PaymentType=wr,c.PreferencesStorageProvider=we,c.PriceAnalyze=He,c.PriceAnalyzeProvider=Ft,c.PriceCoefficient=Ce,c.PriceCoefficientEnum=ze,c.PriceHistoryDataProvider=Gt,c.PriceHistoryItem=Er,c.PriceTemplate=K,c.PriceTemplateCategory=Le,c.PriceTemplateClient=le,c.PriceTemplateICatalogableItem=Xe,c.PriceTemplateProduct=Oe,c.PriceTemplateProvider=At,c.PricingRole=ue,c.PricingRoleProvider=Tt,c.PrimaryCatalogableItem=$e,c.Product=k,c.ProductCategoryDataProvider=Pt,c.ProductDataProvider=at,c.ProductFileType=lt,c.ProductFilterTypeEnum=Mr,c.ProductPriceCoefficient=Se,c.ProductPriceHistory=et,c.ProductUnit=Je,c.PropertiesProvider=St,c.Property=Z,c.PropertyType=xe,c.PropertyTypeEnum=Br,c.PropertyValue=x,c.RecommendationsDataProvider=zt,c.RecommendationsList=vr,c.Reference=v,c.ReferenceDataFactory=Wt,c.ReferenceDataProvider=R,c.Region=Y,c.ResourceType=ar,c.SalesDirection=O,c.SentryConfig=dr,c.Seo=Rr,c.SeoDataProvider=Vt,c.SourcePrimaryInterest=ur,c.StockCount=_r,c.TableDataPagination=kt,c.TableDataPaginationRequestParams=Kr,c.TableDataSortRequestParams=Ot,c.TemplateProductCategoryDataProvider=$t,c.TemplatesListFilters=yt,c.TypedInstanceFactory=I,c.UnitsHelper=gr,c.UnknownClientDataProvider=dt,c.UpdatableNamedIdentity=Ge,c.User=ht,c.UserAuthDataProvider=Qt,c.UserCommonInfo=Ze,c.UserDataProvider=gt,c.UserPricingRole=Ye,c.UserRegion=je,c.UserRegionEmployee=Me,c.UserRegionProvider=xt,c.UserRegionShortInfo=Be,c.UserRegionsListFilters=Zt,c.UserShortInfo=L,c.UserTypeEnum=pt,c.VersionConfig=It,c.Warehouse=ie,c.WebSocketConfig=Ir,c.findCatalogItemByIdRecursive=tr,c.flattenCatalogItems=ir,c.pluralize=qt,c.useAuthStateStore=Te,c.useBaseConfigStateStore=b,c.useReferencesStore=Jt,c.useUserStateStore=Xt,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|