@bitrix24/b24jssdk 0.4.6 → 0.4.8
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/esm/index.mjs +4 -4
- package/dist/esm/index.mjs.map +1 -1
- package/dist/umd/index.js +4 -4
- package/dist/umd/index.js.map +1 -1
- package/dist/umd/index.min.js +1 -1
- package/dist/umd/index.min.js.map +1 -1
- package/package.json +1 -1
package/dist/umd/index.min.js
CHANGED
|
@@ -9,7 +9,7 @@ ${this.stack}`),e}static formatErrorMessage(e){const t=[e.code];return e.descrip
|
|
|
9
9
|
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach(s=>n.set(s)),n}static accessor(e){const n=(this[ao]=this[ao]={accessors:{}}).accessors,s=this.prototype;function i(o){const l=nr(o);n[l]||(Iu(s,o),n[l]=!0)}return k.isArray(e)?e.forEach(i):i(e),this}};Oe.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),k.reduceDescriptors(Oe.prototype,({value:r},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>r,set(n){this[t]=n}}}),k.freezeMethods(Oe);function Cn(r,e){const t=this||rr,n=e||t,s=Oe.from(n.headers);let i=n.data;return k.forEach(r,function(l){i=l.call(t,i,s.normalize(),e?e.status:void 0)}),s.normalize(),i}function lo(r){return!!(r&&r.__CANCEL__)}function Ft(r,e,t){V.call(this,r??"canceled",V.ERR_CANCELED,e,t),this.name="CanceledError"}k.inherits(Ft,V,{__CANCEL__:!0});function co(r,e,t){const n=t.config.validateStatus;!t.status||!n||n(t.status)?r(t):e(new V("Request failed with status code "+t.status,[V.ERR_BAD_REQUEST,V.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function Cu(r){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(r);return e&&e[1]||""}function Nu(r,e){r=r||10;const t=new Array(r),n=new Array(r);let s=0,i=0,o;return e=e!==void 0?e:1e3,function(a){const u=Date.now(),c=n[i];o||(o=u),t[s]=a,n[s]=u;let f=i,h=0;for(;f!==s;)h+=t[f++],f=f%r;if(s=(s+1)%r,s===i&&(i=(i+1)%r),u-o<e)return;const d=c&&u-c;return d?Math.round(h*1e3/d):void 0}}function Ru(r,e){let t=0,n=1e3/e,s,i;const o=(u,c=Date.now())=>{t=c,s=null,i&&(clearTimeout(i),i=null),r(...u)};return[(...u)=>{const c=Date.now(),f=c-t;f>=n?o(u,c):(s=u,i||(i=setTimeout(()=>{i=null,o(s)},n-f)))},()=>s&&o(s)]}const Lr=(r,e,t=3)=>{let n=0;const s=Nu(50,250);return Ru(i=>{const o=i.loaded,l=i.lengthComputable?i.total:void 0,a=o-n,u=s(a),c=o<=l;n=o;const f={loaded:o,total:l,progress:l?o/l:void 0,bytes:a,rate:u||void 0,estimated:u&&l&&c?(l-o)/u:void 0,event:i,lengthComputable:l!=null,[e?"download":"upload"]:!0};r(f)},t)},uo=(r,e)=>{const t=r!=null;return[n=>e[0]({lengthComputable:t,total:r,loaded:n}),e[1]]},ho=r=>(...e)=>k.asap(()=>r(...e)),Lu=_e.hasStandardBrowserEnv?((r,e)=>t=>(t=new URL(t,_e.origin),r.protocol===t.protocol&&r.host===t.host&&(e||r.port===t.port)))(new URL(_e.origin),_e.navigator&&/(msie|trident)/i.test(_e.navigator.userAgent)):()=>!0,Du=_e.hasStandardBrowserEnv?{write(r,e,t,n,s,i){const o=[r+"="+encodeURIComponent(e)];k.isNumber(t)&&o.push("expires="+new Date(t).toGMTString()),k.isString(n)&&o.push("path="+n),k.isString(s)&&o.push("domain="+s),i===!0&&o.push("secure"),document.cookie=o.join("; ")},read(r){const e=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(r){this.write(r,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Pu(r){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(r)}function Mu(r,e){return e?r.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):r}function fo(r,e,t){let n=!Pu(e);return r&&(n||t==!1)?Mu(r,e):e}const po=r=>r instanceof Oe?{...r}:r;function wt(r,e){e=e||{};const t={};function n(u,c,f,h){return k.isPlainObject(u)&&k.isPlainObject(c)?k.merge.call({caseless:h},u,c):k.isPlainObject(c)?k.merge({},c):k.isArray(c)?c.slice():c}function s(u,c,f,h){if(k.isUndefined(c)){if(!k.isUndefined(u))return n(void 0,u,f,h)}else return n(u,c,f,h)}function i(u,c){if(!k.isUndefined(c))return n(void 0,c)}function o(u,c){if(k.isUndefined(c)){if(!k.isUndefined(u))return n(void 0,u)}else return n(void 0,c)}function l(u,c,f){if(f in e)return n(u,c);if(f in r)return n(void 0,u)}const a={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:l,headers:(u,c,f)=>s(po(u),po(c),f,!0)};return k.forEach(Object.keys({...r,...e}),function(c){const f=a[c]||s,h=f(r[c],e[c],c);k.isUndefined(h)&&f!==l||(t[c]=h)}),t}const go=r=>{const e=wt({},r);let{data:t,withXSRFToken:n,xsrfHeaderName:s,xsrfCookieName:i,headers:o,auth:l}=e;e.headers=o=Oe.from(o),e.url=no(fo(e.baseURL,e.url,e.allowAbsoluteUrls),r.params,r.paramsSerializer),l&&o.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):"")));let a;if(k.isFormData(t)){if(_e.hasStandardBrowserEnv||_e.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if((a=o.getContentType())!==!1){const[u,...c]=a?a.split(";").map(f=>f.trim()).filter(Boolean):[];o.setContentType([u||"multipart/form-data",...c].join("; "))}}if(_e.hasStandardBrowserEnv&&(n&&k.isFunction(n)&&(n=n(e)),n||n!==!1&&Lu(e.url))){const u=s&&i&&Du.read(i);u&&o.set(s,u)}return e},Fu=typeof XMLHttpRequest<"u"&&function(r){return new Promise(function(t,n){const s=go(r);let i=s.data;const o=Oe.from(s.headers).normalize();let{responseType:l,onUploadProgress:a,onDownloadProgress:u}=s,c,f,h,d,p;function g(){d&&d(),p&&p(),s.cancelToken&&s.cancelToken.unsubscribe(c),s.signal&&s.signal.removeEventListener("abort",c)}let m=new XMLHttpRequest;m.open(s.method.toUpperCase(),s.url,!0),m.timeout=s.timeout;function y(){if(!m)return;const _=Oe.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders()),v={data:!l||l==="text"||l==="json"?m.responseText:m.response,status:m.status,statusText:m.statusText,headers:_,config:r,request:m};co(function(E){t(E),g()},function(E){n(E),g()},v),m=null}"onloadend"in m?m.onloadend=y:m.onreadystatechange=function(){!m||m.readyState!==4||m.status===0&&!(m.responseURL&&m.responseURL.indexOf("file:")===0)||setTimeout(y)},m.onabort=function(){m&&(n(new V("Request aborted",V.ECONNABORTED,r,m)),m=null)},m.onerror=function(){n(new V("Network Error",V.ERR_NETWORK,r,m)),m=null},m.ontimeout=function(){let b=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const v=s.transitional||io;s.timeoutErrorMessage&&(b=s.timeoutErrorMessage),n(new V(b,v.clarifyTimeoutError?V.ETIMEDOUT:V.ECONNABORTED,r,m)),m=null},i===void 0&&o.setContentType(null),"setRequestHeader"in m&&k.forEach(o.toJSON(),function(b,v){m.setRequestHeader(v,b)}),k.isUndefined(s.withCredentials)||(m.withCredentials=!!s.withCredentials),l&&l!=="json"&&(m.responseType=s.responseType),u&&([h,p]=Lr(u,!0),m.addEventListener("progress",h)),a&&m.upload&&([f,d]=Lr(a),m.upload.addEventListener("progress",f),m.upload.addEventListener("loadend",d)),(s.cancelToken||s.signal)&&(c=_=>{m&&(n(!_||_.type?new Ft(null,r,m):_),m.abort(),m=null)},s.cancelToken&&s.cancelToken.subscribe(c),s.signal&&(s.signal.aborted?c():s.signal.addEventListener("abort",c)));const w=Cu(s.url);if(w&&_e.protocols.indexOf(w)===-1){n(new V("Unsupported protocol "+w+":",V.ERR_BAD_REQUEST,r));return}m.send(i||null)})},xu=(r,e)=>{const{length:t}=r=r?r.filter(Boolean):[];if(e||t){let n=new AbortController,s;const i=function(u){if(!s){s=!0,l();const c=u instanceof Error?u:this.reason;n.abort(c instanceof V?c:new Ft(c instanceof Error?c.message:c))}};let o=e&&setTimeout(()=>{o=null,i(new V(`timeout ${e} of ms exceeded`,V.ETIMEDOUT))},e);const l=()=>{r&&(o&&clearTimeout(o),o=null,r.forEach(u=>{u.unsubscribe?u.unsubscribe(i):u.removeEventListener("abort",i)}),r=null)};r.forEach(u=>u.addEventListener("abort",i));const{signal:a}=n;return a.unsubscribe=()=>k.asap(l),a}},ju=function*(r,e){let t=r.byteLength;if(t<e){yield r;return}let n=0,s;for(;n<t;)s=n+e,yield r.slice(n,s),n=s},Bu=async function*(r,e){for await(const t of Uu(r))yield*ju(t,e)},Uu=async function*(r){if(r[Symbol.asyncIterator]){yield*r;return}const e=r.getReader();try{for(;;){const{done:t,value:n}=await e.read();if(t)break;yield n}}finally{await e.cancel()}},mo=(r,e,t,n)=>{const s=Bu(r,e);let i=0,o,l=a=>{o||(o=!0,n&&n(a))};return new ReadableStream({async pull(a){try{const{done:u,value:c}=await s.next();if(u){l(),a.close();return}let f=c.byteLength;if(t){let h=i+=f;t(h)}a.enqueue(new Uint8Array(c))}catch(u){throw l(u),u}},cancel(a){return l(a),s.return()}},{highWaterMark:2})},Dr=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",yo=Dr&&typeof ReadableStream=="function",$u=Dr&&(typeof TextEncoder=="function"?(r=>e=>r.encode(e))(new TextEncoder):async r=>new Uint8Array(await new Response(r).arrayBuffer())),wo=(r,...e)=>{try{return!!r(...e)}catch{return!1}},Wu=yo&&wo(()=>{let r=!1;const e=new Request(_e.origin,{body:new ReadableStream,method:"POST",get duplex(){return r=!0,"half"}}).headers.has("Content-Type");return r&&!e}),bo=64*1024,Nn=yo&&wo(()=>k.isReadableStream(new Response("").body)),Pr={stream:Nn&&(r=>r.body)};Dr&&(r=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!Pr[e]&&(Pr[e]=k.isFunction(r[e])?t=>t[e]():(t,n)=>{throw new V(`Response type '${e}' is not supported`,V.ERR_NOT_SUPPORT,n)})})})(new Response);const qu=async r=>{if(r==null)return 0;if(k.isBlob(r))return r.size;if(k.isSpecCompliantForm(r))return(await new Request(_e.origin,{method:"POST",body:r}).arrayBuffer()).byteLength;if(k.isArrayBufferView(r)||k.isArrayBuffer(r))return r.byteLength;if(k.isURLSearchParams(r)&&(r=r+""),k.isString(r))return(await $u(r)).byteLength},Vu=async(r,e)=>{const t=k.toFiniteNumber(r.getContentLength());return t??qu(e)},Rn={http:hu,xhr:Fu,fetch:Dr&&(async r=>{let{url:e,method:t,data:n,signal:s,cancelToken:i,timeout:o,onDownloadProgress:l,onUploadProgress:a,responseType:u,headers:c,withCredentials:f="same-origin",fetchOptions:h}=go(r);u=u?(u+"").toLowerCase():"text";let d=xu([s,i&&i.toAbortSignal()],o),p;const g=d&&d.unsubscribe&&(()=>{d.unsubscribe()});let m;try{if(a&&Wu&&t!=="get"&&t!=="head"&&(m=await Vu(c,n))!==0){let v=new Request(e,{method:"POST",body:n,duplex:"half"}),S;if(k.isFormData(n)&&(S=v.headers.get("content-type"))&&c.setContentType(S),v.body){const[E,L]=uo(m,Lr(ho(a)));n=mo(v.body,bo,E,L)}}k.isString(f)||(f=f?"include":"omit");const y="credentials"in Request.prototype;p=new Request(e,{...h,signal:d,method:t.toUpperCase(),headers:c.normalize().toJSON(),body:n,duplex:"half",credentials:y?f:void 0});let w=await fetch(p,h);const _=Nn&&(u==="stream"||u==="response");if(Nn&&(l||_&&g)){const v={};["status","statusText","headers"].forEach(x=>{v[x]=w[x]});const S=k.toFiniteNumber(w.headers.get("content-length")),[E,L]=l&&uo(S,Lr(ho(l),!0))||[];w=new Response(mo(w.body,bo,E,()=>{L&&L(),g&&g()}),v)}u=u||"text";let b=await Pr[k.findKey(Pr,u)||"text"](w,r);return!_&&g&&g(),await new Promise((v,S)=>{co(v,S,{data:b,headers:Oe.from(w.headers),status:w.status,statusText:w.statusText,config:r,request:p})})}catch(y){throw g&&g(),y&&y.name==="TypeError"&&/Load failed|fetch/i.test(y.message)?Object.assign(new V("Network Error",V.ERR_NETWORK,r,p),{cause:y.cause||y}):V.from(y,y&&y.code,r,p)}})};k.forEach(Rn,(r,e)=>{if(r){try{Object.defineProperty(r,"name",{value:e})}catch{}Object.defineProperty(r,"adapterName",{value:e})}});const So=r=>`- ${r}`,zu=r=>k.isFunction(r)||r===null||r===!1,_o={getAdapter:r=>{r=k.isArray(r)?r:[r];const{length:e}=r;let t,n;const s={};for(let i=0;i<e;i++){t=r[i];let o;if(n=t,!zu(t)&&(n=Rn[(o=String(t)).toLowerCase()],n===void 0))throw new V(`Unknown adapter '${o}'`);if(n)break;s[o||"#"+i]=n}if(!n){const i=Object.entries(s).map(([l,a])=>`adapter ${l} `+(a===!1?"is not supported by the environment":"is not available in the build"));let o=e?i.length>1?`since :
|
|
10
10
|
`+i.map(So).join(`
|
|
11
11
|
`):" "+So(i[0]):"as no adapter specified";throw new V("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return n},adapters:Rn};function Ln(r){if(r.cancelToken&&r.cancelToken.throwIfRequested(),r.signal&&r.signal.aborted)throw new Ft(null,r)}function ko(r){return Ln(r),r.headers=Oe.from(r.headers),r.data=Cn.call(r,r.transformRequest),["post","put","patch"].indexOf(r.method)!==-1&&r.headers.setContentType("application/x-www-form-urlencoded",!1),_o.getAdapter(r.adapter||rr.adapter)(r).then(function(n){return Ln(r),n.data=Cn.call(r,r.transformResponse,n),n.headers=Oe.from(n.headers),n},function(n){return lo(n)||(Ln(r),n&&n.response&&(n.response.data=Cn.call(r,r.transformResponse,n.response),n.response.headers=Oe.from(n.response.headers))),Promise.reject(n)})}const vo="1.11.0",Mr={};["object","boolean","number","function","string","symbol"].forEach((r,e)=>{Mr[r]=function(n){return typeof n===r||"a"+(e<1?"n ":" ")+r}});const Eo={};Mr.transitional=function(e,t,n){function s(i,o){return"[Axios v"+vo+"] Transitional option '"+i+"'"+o+(n?". "+n:"")}return(i,o,l)=>{if(e===!1)throw new V(s(o," has been removed"+(t?" in "+t:"")),V.ERR_DEPRECATED);return t&&!Eo[o]&&(Eo[o]=!0,console.warn(s(o," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(i,o,l):!0}},Mr.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function Hu(r,e,t){if(typeof r!="object")throw new V("options must be an object",V.ERR_BAD_OPTION_VALUE);const n=Object.keys(r);let s=n.length;for(;s-- >0;){const i=n[s],o=e[i];if(o){const l=r[i],a=l===void 0||o(l,i,r);if(a!==!0)throw new V("option "+i+" must be "+a,V.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new V("Unknown option "+i,V.ERR_BAD_OPTION)}}const Fr={assertOptions:Hu,validators:Mr},He=Fr.validators;let bt=class{constructor(e){this.defaults=e||{},this.interceptors={request:new so,response:new so}}async request(e,t){try{return await this._request(e,t)}catch(n){if(n instanceof Error){let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;const i=s.stack?s.stack.replace(/^.+\n/,""):"";try{n.stack?i&&!String(n.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(n.stack+=`
|
|
12
|
-
`+i):n.stack=i}catch{}}throw n}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=wt(this.defaults,t);const{transitional:n,paramsSerializer:s,headers:i}=t;n!==void 0&&Fr.assertOptions(n,{silentJSONParsing:He.transitional(He.boolean),forcedJSONParsing:He.transitional(He.boolean),clarifyTimeoutError:He.transitional(He.boolean)},!1),s!=null&&(k.isFunction(s)?t.paramsSerializer={serialize:s}:Fr.assertOptions(s,{encode:He.function,serialize:He.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Fr.assertOptions(t,{baseUrl:He.spelling("baseURL"),withXsrfToken:He.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=i&&k.merge(i.common,i[t.method]);i&&k.forEach(["delete","get","head","post","put","patch","common"],p=>{delete i[p]}),t.headers=Oe.concat(o,i);const l=[];let a=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(t)===!1||(a=a&&g.synchronous,l.unshift(g.fulfilled,g.rejected))});const u=[];this.interceptors.response.forEach(function(g){u.push(g.fulfilled,g.rejected)});let c,f=0,h;if(!a){const p=[ko.bind(this),void 0];for(p.unshift(...l),p.push(...u),h=p.length,c=Promise.resolve(t);f<h;)c=c.then(p[f++],p[f++]);return c}h=l.length;let d=t;for(f=0;f<h;){const p=l[f++],g=l[f++];try{d=p(d)}catch(m){g.call(this,m);break}}try{c=ko.call(this,d)}catch(p){return Promise.reject(p)}for(f=0,h=u.length;f<h;)c=c.then(u[f++],u[f++]);return c}getUri(e){e=wt(this.defaults,e);const t=fo(e.baseURL,e.url,e.allowAbsoluteUrls);return no(t,e.params,e.paramsSerializer)}};k.forEach(["delete","get","head","options"],function(e){bt.prototype[e]=function(t,n){return this.request(wt(n||{},{method:e,url:t,data:(n||{}).data}))}}),k.forEach(["post","put","patch"],function(e){function t(n){return function(i,o,l){return this.request(wt(l||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}bt.prototype[e]=t(),bt.prototype[e+"Form"]=t(!0)});let Ju=class oa{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(i){t=i});const n=this;this.promise.then(s=>{if(!n._listeners)return;let i=n._listeners.length;for(;i-- >0;)n._listeners[i](s);n._listeners=null}),this.promise.then=s=>{let i;const o=new Promise(l=>{n.subscribe(l),i=l}).then(s);return o.cancel=function(){n.unsubscribe(i)},o},e(function(i,o,l){n.reason||(n.reason=new Ft(i,o,l),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=n=>{e.abort(n)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new oa(function(s){e=s}),cancel:e}}};function Zu(r){return function(t){return r.apply(null,t)}}function Gu(r){return k.isObject(r)&&r.isAxiosError===!0}const Dn={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Dn).forEach(([r,e])=>{Dn[e]=r});function To(r){const e=new bt(r),t=Wi(bt.prototype.request,e);return k.extend(t,bt.prototype,e,{allOwnKeys:!0}),k.extend(t,e,null,{allOwnKeys:!0}),t.create=function(s){return To(wt(r,s))},t}const ie=To(rr);ie.Axios=bt,ie.CanceledError=Ft,ie.CancelToken=Ju,ie.isCancel=lo,ie.VERSION=vo,ie.toFormData=Nr,ie.AxiosError=V,ie.Cancel=ie.CanceledError,ie.all=function(e){return Promise.all(e)},ie.spread=Zu,ie.isAxiosError=Gu,ie.mergeConfig=wt,ie.AxiosHeaders=Oe,ie.formToJSON=r=>oo(k.isHTMLForm(r)?new FormData(r):r),ie.getAdapter=_o.getAdapter,ie.HttpStatusCode=Dn,ie.default=ie;const{Axios:Ef,AxiosError:Pn,CanceledError:Tf,isCancel:Of,CancelToken:Af,VERSION:If,all:Cf,Cancel:Nf,isAxiosError:Rf,spread:Lf,toFormData:Df,AxiosHeaders:Pf,HttpStatusCode:Mf,formToJSON:Ff,getAdapter:xf,mergeConfig:jf}=ie,Yu=String.prototype.replace,Ku=/%20/g,Oo={RFC1738:"RFC1738",RFC3986:"RFC3986"},Qu={RFC1738:function(r){return Yu.call(r,Ku,"+")},RFC3986:function(r){return String(r)}},Xu=Oo.RFC1738,eh=Oo.RFC3986,Mn=Object.prototype.hasOwnProperty,St=Array.isArray,Je=(function(){const r=[];for(let e=0;e<256;++e)r.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return r})(),th=function(e){for(;e.length>1;){const t=e.pop(),n=t.obj[t.prop];if(St(n)){const s=[];for(let i=0;i<n.length;++i)typeof n[i]<"u"&&s.push(n[i]);t.obj[t.prop]=s}}},rh=function(e,t){const n=t&&t.plainObjects?Object.create(null):{};for(let s=0;s<e.length;++s)typeof e[s]<"u"&&(n[s]=e[s]);return n},nh=function r(e,t,n){if(!t)return e;if(typeof t!="object"){if(St(e))e.push(t);else if(e&&typeof e=="object")(n&&(n.plainObjects||n.allowPrototypes)||!Mn.call(Object.prototype,t))&&(e[t]=!0);else return[e,t];return e}if(!e||typeof e!="object")return[e].concat(t);let s=e;return St(e)&&!St(t)&&(s=rh(e,n)),St(e)&&St(t)?(t.forEach(function(i,o){if(Mn.call(e,o)){const l=e[o];l&&typeof l=="object"&&i&&typeof i=="object"?e[o]=r(l,i,n):e.push(i)}else e[o]=i}),e):Object.keys(t).reduce(function(i,o){const l=t[o];return Mn.call(i,o)?i[o]=r(i[o],l,n):i[o]=l,i},s)},sh=function(r,e,t){const n=r.replace(/\+/g," ");if(t==="iso-8859-1")return n.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(n)}catch{return n}},Fn=1024,ih=function(e,t,n,s,i){if(e.length===0)return e;let o=e;if(typeof e=="symbol"?o=Symbol.prototype.toString.call(e):typeof e!="string"&&(o=String(e)),n==="iso-8859-1")return escape(o).replace(/%u[0-9a-f]{4}/gi,function(a){return"%26%23"+parseInt(a.slice(2),16)+"%3B"});let l="";for(let a=0;a<o.length;a+=Fn){const u=o.length>=Fn?o.slice(a,a+Fn):o,c=[];for(let f=0;f<u.length;++f){let h=u.charCodeAt(f);if(h===45||h===46||h===95||h===126||h>=48&&h<=57||h>=65&&h<=90||h>=97&&h<=122||i===Xu&&(h===40||h===41)){c[c.length]=u.charAt(f);continue}if(h<128){c[c.length]=Je[h];continue}if(h<2048){c[c.length]=Je[192|h>>6]+Je[128|h&63];continue}if(h<55296||h>=57344){c[c.length]=Je[224|h>>12]+Je[128|h>>6&63]+Je[128|h&63];continue}f+=1,h=65536+((h&1023)<<10|u.charCodeAt(f)&1023),c[c.length]=Je[240|h>>18]+Je[128|h>>12&63]+Je[128|h>>6&63]+Je[128|h&63]}l+=c.join("")}return l},oh=function(e){const t=[{obj:{o:e},prop:"o"}],n=[];for(let s=0;s<t.length;++s){const i=t[s],o=i.obj[i.prop],l=Object.keys(o);for(let a=0;a<l.length;++a){const u=l[a],c=o[u];typeof c=="object"&&c!==null&&n.indexOf(c)===-1&&(t.push({obj:o,prop:u}),n.push(c))}}return th(t),e},ah=function(e){return!e||typeof e!="object"?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},lh=function(e,t){return[].concat(e,t)},xn=function(e,t){if(St(e)){const n=[];for(let s=0;s<e.length;s+=1)n.push(t(e[s]));return n}return t(e)},ch={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},et=Array.isArray,uh=Array.prototype.push,Ao=function(r,e){uh.apply(r,et(e)?e:[e])},hh=Date.prototype.toISOString,Io=eh,xr={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:ih,encodeValuesOnly:!1,format:Io,formatter:Qu[Io],indices:!1,serializeDate:function(e){return hh.call(e)},skipNulls:!1,strictNullHandling:!1},fh=function(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="symbol"||typeof e=="bigint"},jn={},Co=function(e,t,n,s,i,o,l,a,u,c,f,h,d,p,g,m,y,w){let _=e,b=w,v=0,S=!1;for(;(b=b.get(jn))!==void 0&&!S;){const J=b.get(e);if(v+=1,typeof J<"u"){if(J===v)throw new RangeError("Cyclic object value");S=!0}typeof b.get(jn)>"u"&&(v=0)}if(typeof c=="function"?_=c(t,_):_ instanceof Date?_=d(_):n==="comma"&&et(_)&&(_=xn(_,function(J){return J instanceof Date?d(J):J})),_===null){if(o)return u&&!m?u(t,xr.encoder,y,"key",p):t;_=""}if(fh(_)||ah(_)){if(u){const J=m?t:u(t,xr.encoder,y,"key",p);return[g(J)+"="+g(u(_,xr.encoder,y,"value",p))]}return[g(t)+"="+g(String(_))]}const E=[];if(typeof _>"u")return E;let L;if(n==="comma"&&et(_))m&&u&&(_=xn(_,u)),L=[{value:_.length>0?_.join(",")||null:void 0}];else if(et(c))L=c;else{const J=Object.keys(_);L=f?J.sort(f):J}const x=a?t.replace(/\./g,"%2E"):t,F=s&&et(_)&&_.length===1?x+"[]":x;if(i&&et(_)&&_.length===0)return F+"[]";for(let J=0;J<L.length;++J){const me=L[J],z=typeof me=="object"&&typeof me.value<"u"?me.value:_[me];if(l&&z===null)continue;const Q=h&&a?me.replace(/\./g,"%2E"):me,U=et(_)?typeof n=="function"?n(F,Q):F:F+(h?"."+Q:"["+Q+"]");w.set(e,v);const he=new WeakMap;he.set(jn,w),Ao(E,Co(z,U,n,s,i,o,l,a,n==="comma"&&m&&et(_)?null:u,c,f,h,d,p,g,m,y,he))}return E},dh=function(e){return xr};function No(r,e){let t=r;const n=dh();let s,i;typeof n.filter=="function"?(i=n.filter,t=i("",t)):et(n.filter)&&(i=n.filter,s=i);const o=[];if(typeof t!="object"||t===null)return"";const l=ch[n.arrayFormat],a=l==="comma"&&n.commaRoundTrip;s||(s=Object.keys(t)),n.sort&&s.sort(n.sort);const u=new WeakMap;for(let h=0;h<s.length;++h){const d=s[h];n.skipNulls&&t[d]===null||Ao(o,Co(t[d],d,l,a,n.allowEmptyArrays,n.strictNullHandling,n.skipNulls,n.encodeDotInKeys,n.encode?n.encoder:null,n.filter,n.sort,n.allowDots,n.serializeDate,n.format,n.formatter,n.encodeValuesOnly,n.charset,u))}const c=o.join(n.delimiter);let f=n.addQueryPrefix===!0?"?":"";return n.charsetSentinel&&(n.charset==="iso-8859-1"?f+="utf8=%26%2310003%3B&":f+="utf8=%E2%9C%93&"),c.length>0?f+c:""}const Bn=Object.prototype.hasOwnProperty,ph=Array.isArray,jr={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:sh,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},gh=function(r){return r.replace(/&#(\d+);/g,function(e,t){return String.fromCharCode(parseInt(t,10))})},Ro=function(r,e){return r&&typeof r=="string"&&e.comma&&r.indexOf(",")>-1?r.split(","):r},mh="utf8=%26%2310003%3B",yh="utf8=%E2%9C%93",wh=function(e,t){const n={__proto__:null},s=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,i=t.parameterLimit===1/0?void 0:t.parameterLimit,o=s.split(t.delimiter,i);let l=-1,a,u=t.charset;if(t.charsetSentinel)for(a=0;a<o.length;++a)o[a].indexOf("utf8=")===0&&(o[a]===yh?u="utf-8":o[a]===mh&&(u="iso-8859-1"),l=a,a=o.length);for(a=0;a<o.length;++a){if(a===l)continue;const c=o[a],f=c.indexOf("]="),h=f===-1?c.indexOf("="):f+1;let d,p;h===-1?(d=t.decoder(c,jr.decoder,u,"key"),p=t.strictNullHandling?null:""):(d=t.decoder(c.slice(0,h),jr.decoder,u,"key"),p=xn(Ro(c.slice(h+1),t),function(m){return t.decoder(m,jr.decoder,u,"value")})),p&&t.interpretNumericEntities&&u==="iso-8859-1"&&(p=gh(p)),c.indexOf("[]=")>-1&&(p=ph(p)?[p]:p);const g=Bn.call(n,d);g&&t.duplicates==="combine"?n[d]=lh(n[d],p):(!g||t.duplicates==="last")&&(n[d]=p)}return n},bh=function(r,e,t,n){let s=n?e:Ro(e,t);for(let i=r.length-1;i>=0;--i){let o;const l=r[i];if(l==="[]"&&t.parseArrays)o=t.allowEmptyArrays&&s===""?[]:[].concat(s);else{o=t.plainObjects?Object.create(null):{};const a=l.charAt(0)==="["&&l.charAt(l.length-1)==="]"?l.slice(1,-1):l,u=t.decodeDotInKeys?a.replace(/%2E/g,"."):a,c=parseInt(u,10);!t.parseArrays&&u===""?o={0:s}:!isNaN(c)&&l!==u&&String(c)===u&&c>=0&&t.parseArrays&&c<=t.arrayLimit?(o=[],o[c]=s):u!=="__proto__"&&(o[u]=s)}s=o}return s},Sh=function(e,t,n,s){if(!e)return;const i=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,o=/(\[[^[\]]*])/,l=/(\[[^[\]]*])/g;let a=n.depth>0&&o.exec(i);const u=a?i.slice(0,a.index):i,c=[];if(u){if(!n.plainObjects&&Bn.call(Object.prototype,u)&&!n.allowPrototypes)return;c.push(u)}let f=0;for(;n.depth>0&&(a=l.exec(i))!==null&&f<n.depth;){if(f+=1,!n.plainObjects&&Bn.call(Object.prototype,a[1].slice(1,-1))&&!n.allowPrototypes)return;c.push(a[1])}return a&&c.push("["+i.slice(a.index)+"]"),bh(c,t,n,s)},_h=function(e){return jr};function Lo(r,e){const t=_h();if(r===""||r===null||typeof r>"u")return t.plainObjects?Object.create(null):{};const n=typeof r=="string"?wh(r,t):r;let s=t.plainObjects?Object.create(null):{};const i=Object.keys(n);for(let o=0;o<i.length;++o){const l=i[o],a=Sh(l,n[l],t,typeof r=="string");s=nh(s,a,t)}return t.allowSparse===!0?s:oh(s)}class Un{#e;#r;#t;#n;_logger=null;_loggerSystem=null;#s="";#o=!1;#i="";constructor(e,t,n){const s={};this.#e=ie.create({baseURL:e,headers:{...s,...n?n.headers:{}},...n&&{...n,headers:void 0}}),this.#r=t,this.#t=new _c,this.#n=new Oc}setLogger(e){this._logger=e,this.#t.setLogger(this.getLogger())}getLogger(){return this._logger===null&&(this._logger=ye.build("NullLogger"),this._logger.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!1,[I.warn]:!1,[I.error]:!0,[I.trace]:!1})),this._logger}getSystemLogger(){return this._loggerSystem===null&&(this._loggerSystem=ye.build("SystemLogger"),this._loggerSystem.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!0,[I.warn]:!0,[I.error]:!0,[I.trace]:!1})),this._loggerSystem}setRestrictionManagerParams(e){this.#t.params=e}getRestrictionManagerParams(){return this.#t.params}setLogTag(e){this.#s=e}clearLogTag(){this.#s=""}async batch(e,t=!0,n=!1){return Array.isArray(e)?this.#c(e,t,n):this.#l(e,t,n)}async#l(e,t=!0,n=!1){const s={};let i=0;const o=(l,a)=>{let u=null,c=null;l.method?(u=l.method??null,c=l?.params??null):Array.isArray(l)&&l.length>0&&(u=l[0]??null,c=l[1]??null),u&&(i++,s[a]=u+"?"+No(c))};for(const[l,a]of Object.entries(e))o(a,l);return i<1?Promise.resolve(new qe):this.call("batch",{halt:t?1:0,cmd:s}).then(l=>{const a=l.getData().result,u={},c=(p,g)=>{if(typeof a.result[g]<"u"||typeof a.result_error[g]<"u"){const m=p.split("?");u[g]=new Tr({answer:{result:C.isUndefined(a.result[g])?{}:a.result[g],error:a?.result_error[g]||void 0,total:a.result_total[g],next:a.result_next[g],time:a.result_time[g]},query:{method:m[0]||"",params:Lo(m[1]||""),start:0},status:l.getStatus()})}};for(const[p,g]of Object.entries(s))c(g,p);const f={},h=p=>p.hasError("base-error")?p.errors.get("base-error"):new Fe({code:"0",description:p.getErrorMessages().join("; "),status:0,requestInfo:{method:p.getQuery().method,params:p.getQuery().params},originalError:p.getErrors().next().value}),d=new qe;for(const p of Object.keys(u)){const g=u[p];if(g.getStatus()!==200||!g.isSuccess){const m=h(g);if(!t&&!g.isSuccess){d.addError(m,p);continue}return Promise.reject(m)}f[p]=n?g:g.getData().result}return d.setData(f),Promise.resolve(d)})}async#c(e,t=!0,n=!1){const s=[];let i=0;const o=l=>{let a=null,u=null;if(l.method?(a=l.method??null,u=l?.params??null):Array.isArray(l)&&l.length>0&&(a=l[0]??null,u=l[1]??null),a){i++;const c=a+"?"+No(u);s.push(c)}};for(const[l,a]of e.entries())o(a);return i<1?Promise.resolve(new qe):this.call("batch",{halt:t?1:0,cmd:s}).then(l=>{const a=l.getData().result,u=[],c=(p,g)=>{if(typeof a.result[g]<"u"||typeof a.result_error[g]<"u"){const m=p.split("?"),y=new Tr({answer:{result:C.isUndefined(a.result[g])?{}:a.result[g],error:a?.result_error[g]||void 0,total:a.result_total[g],next:a.result_next[g],time:a.result_time[g]},query:{method:m[0]||"",params:Lo(m[1]||""),start:0},status:l.getStatus()});u.push(y)}};for(const[p,g]of s.entries())c(g,p);const f=[],h=p=>p.hasError("base-error")?p.errors.get("base-error"):new Fe({code:"0",description:p.getErrorMessages().join("; "),status:0,requestInfo:{method:p.getQuery().method,params:p.getQuery().params},originalError:p.getErrors().next().value}),d=new qe;for(const p of u){if(p.getStatus()!==200||!p.isSuccess){const g=h(p);if(!t&&!p.isSuccess){d.addError(g);continue}return Promise.reject(g)}f.push(n?p:p.getData().result)}return d.setData(f),Promise.resolve(d)})}async call(e,t,n=0){let s=this.#r.getAuthData();return s===!1&&(s=await this.#r.refreshAuth()),await this.#t.check(),this.#o&&!this.isServerSide()&&C.isStringFilled(this.#i)&&this.getSystemLogger().warn(this.#i),this.#e.post(this.#u(e),this.#a(s,t,n)).then(i=>{const o=i.data;return Promise.resolve({status:i.status,payload:o})},async i=>{let o={error:i?.code||0,errorDescription:i?.message||""};if(i instanceof Pn&&i.response&&i.response.data&&!C.isUndefined(i.response.data.error)){const a=i.response.data;o={error:a.error,errorDescription:a.error_description}}const l=new Fe({code:String(o.error),description:o.errorDescription,status:i.response?.status||0,requestInfo:{method:e,params:t},originalError:i});return l.status===401&&["expired_token","invalid_token"].includes(l.answerError.error)?(this.getLogger().info(`refreshAuth >> ${l.answerError.error} >>>`),s=await this.#r.refreshAuth(),await this.#t.check(),this.#e.post(this.#u(e),this.#a(s,t,n)).then(async a=>{const u=a.data;return Promise.resolve({status:a.status,payload:u})},async a=>{let u={error:a?.code||0,errorDescription:a?.message||""};if(a instanceof Pn&&a.response&&a.response.data){const f=a.response.data;u={error:f.error,errorDescription:f.error_description}}const c=new Fe({code:String(u.error),description:u.errorDescription,status:i.response?.status||0,requestInfo:{method:e,params:t},originalError:a});return Promise.reject(c)})):Promise.reject(l)}).then(i=>{const o=new Tr({answer:i.payload,query:{method:e,params:t,start:n},status:i.status});return Promise.resolve(o)})}#a(e,t,n=0){const s=Object.assign({},t);return this.#s.length>0&&(s.logTag=this.#s),s.data&&s.data.start&&delete s.data.start,e.refresh_token!=="hook"&&(s.auth=e.access_token),s.start=n,s}#u(e){const t=`${encodeURIComponent(e)}.json`,n=new URLSearchParams({[this.#n.getQueryStringParameterName()]:this.#n.getRequestId(),[this.#n.getQueryStringSdkParameterName()]:"0.4.6",[this.#n.getQueryStringSdkTypeParameterName()]:"b24-js-sdk"});return`${t}?${n.toString()}`}setClientSideWarning(e,t){this.#o=e,this.#i=t}isServerSide(){return typeof window>"u"}}class _t{static batchSize=50;_isInit=!1;_http=null;_logger=null;constructor(){this._isInit=!1}get isInit(){return this._isInit}async init(){this._isInit=!0}destroy(){}setLogger(e){this._logger=e,this.getHttpClient().setLogger(this.getLogger())}getLogger(){return this._logger===null&&(this._logger=ye.build("NullLogger"),this._logger.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!1,[I.warn]:!1,[I.error]:!0,[I.trace]:!1})),this._logger}callMethod(e,t,n){return this.getHttpClient().call(e,t||{},n||0)}async callListMethod(e,t={},n=null,s=null){const i=new qe;return C.isFunction(n)&&n!==null&&n(0),this.callMethod(e,t,0).then(async o=>{let l=[],a;if(s===null?a=o.getData().result:a=o.getData().result[s],l=[...l,...a],o.isMore()){let u=o;for(;u=await u.getNext(this.getHttpClient()),u!==!1;){let c;if(s===null?c=u.getData().result:c=u.getData().result[s],l=[...l,...c],n){const f=u.getTotal();n(f>0?Math.round(100*l.length/f):100)}}}return i.setData(l),n&&n(100),i})}async*fetchListMethod(e,t={},n="ID",s=null){t.order=t.order||{},t.filter=t.filter||{},t.start=-1;const i=`>${n}`;t.order[n]="ASC",t.filter[i]=0;do{const o=await this.callMethod(e,t,t.start);let l;if(!C.isNull(s)&&s!==null?l=o.getData().result[s]:l=o.getData().result,l.length===0||(yield l,l.length<_t.batchSize))break;const a=l.at(-1);a&&n in a&&(t.filter[i]=a[n])}while(!0)}async callBatch(e,t=!0,n=!1){return this.getHttpClient().batch(e,t,n)}chunkArray(e,t=50){const n=[];for(let s=0;s<e.length;s+=t){const i=e.slice(s,s+t);n.push(i)}return n}async callBatchByChunk(e,t=!0){const n=new qe,s=[],i=this.chunkArray(e,_t.batchSize);for(const o of i){const l=await this.callBatch(o,t);s.push(...l.getData())}return n.setData(s)}getHttpClient(){if(!this.isInit||this._http===null)throw new Error("Http not init");return this._http}_getHttpOptions(){return null}_ensureInitialized(){if(!this._isInit)throw new Error("B24 not initialized")}}var $n=(r=>(r.en="en",r.de="de",r.la="la",r.br="br",r.fr="fr",r.it="it",r.pl="pl",r.ru="ru",r.ua="ua",r.tr="tr",r.sc="sc",r.tc="tc",r.ja="ja",r.vn="vn",r.id="id",r.ms="ms",r.th="th",r.ar="ar",r))($n||{});const kh={en:"en-EN",de:"de-DE",la:"es-ES",br:"pt-BR",fr:"fr-FR",it:"it-IT",pl:"pl-PL",ru:"ru-RU",ua:"uk-UA",tr:"tr-TR",sc:"zh-CN",tc:"zh-TW",ja:"ja-JP",vn:"vi-VN",id:"id-ID",ms:"ms-MY",th:"th-TH",ar:"ar-SA"},vh=()=>({scrollWidth:Math.max(document.documentElement.scrollWidth,document.documentElement.offsetWidth),scrollHeight:Math.max(document.documentElement.scrollHeight,document.documentElement.offsetHeight)});let Eh=class ht{static isInternalConstructing=!1;static instance=null;_defLocale=null;constructor(){if(!ht.isInternalConstructing)throw new TypeError("FormatterNumber is not constructable");ht.isInternalConstructing=!1}static getInstance(){return ht.instance||(ht.isInternalConstructing=!0,ht.instance=new ht),ht.instance}setDefLocale(e){this._defLocale=e}format(e,t){let n;(typeof t>"u"||!C.isStringFilled(t))&&(t=C.isStringFilled(this._defLocale)?this._defLocale||"en":typeof navigator>"u"?"en":navigator?.language||"en"),Number.isInteger(e)?n=new Intl.NumberFormat(t,{minimumFractionDigits:0,maximumFractionDigits:0}):n=new Intl.NumberFormat(t,{minimumFractionDigits:2,maximumFractionDigits:2});let s=n.format(e);return t.includes("ru")&&(s=s.replace(",",".")),s}};class T{countryCode;length;structure;example;_cachedRegex=null;constructor(e,t,n,s){this.countryCode=e,this.length=t,this.structure=n,this.example=s}isValid(e){return this.length===e.length&&this.countryCode===e.slice(0,2)&&this._regex().test(e.slice(4))&&this._iso7064Mod9710(this._iso13616Prepare(e))==1}toBBAN(e,t){return(this._regex().exec(e.slice(4)||"")||[]).slice(1).join(t)}fromBBAN(e){if(!this.isValidBBAN(e))throw new Error("Invalid BBAN");const t=("0"+(98-this._iso7064Mod9710(this._iso13616Prepare(this.countryCode+"00"+e)))).slice(-2);return this.countryCode+t+e}isValidBBAN(e){return this.length-4===e.length&&this._regex().test(e)}_regex(){return this._cachedRegex===null&&(this._cachedRegex=this._parseStructure(this.structure)),this._cachedRegex}_parseStructure(e){const t=(e.match(/(.{3})/g)||[]).map(n=>{let s;const i=n.slice(0,1),o=Number.parseInt(n.slice(1),10);switch(i){case"A":s="0-9A-Za-z";break;case"B":s="0-9A-Z";break;case"C":s="A-Za-z";break;case"F":s="0-9";break;case"L":s="a-z";break;case"U":s="A-Z";break;case"W":s="0-9a-z";break}return"(["+s+"]{"+o+"})"});return new RegExp("^"+t.join("")+"$")}_iso13616Prepare(e){return e=e.toUpperCase(),e=e.substring(4)+e.substring(0,4),e.split("").map(t=>{const n=t.charCodeAt(0);return n>=65&&n<=90?(n-65+10).toString():t}).join("")}_iso7064Mod9710(e){let t=e,n;for(;t.length>2;)n=t.slice(0,9),t=Number.parseInt(n,10)%97+t.slice(n.length);return Number.parseInt(t,10)%97}}class tt{static isInternalConstructing=!1;static instance=null;_countries;constructor(){if(!tt.isInternalConstructing)throw new TypeError("FormatterIban is not constructable");tt.isInternalConstructing=!1,this._countries=new Map}static getInstance(){return tt.instance||(tt.isInternalConstructing=!0,tt.instance=new tt),tt.instance}addSpecification(e){this._countries.set(e.countryCode,e)}isValid(e){if(!C.isString(e))return!1;e=this.electronicFormat(e);const t=e.slice(0,2);if(!this._countries.has(t))throw new Error(`No country with code ${t}`);const n=this._countries.get(t);return!!n&&n.isValid(e)}printFormat(e,t){typeof t>"u"&&(t=" ");const n=/(.{4})(?!$)/g;return this.electronicFormat(e).replace(n,"$1"+t)}electronicFormat(e){const t=/[^a-zA-Z0-9]/g;return e.replace(t,"").toUpperCase()}toBBAN(e,t){typeof t>"u"&&(t=" "),e=this.electronicFormat(e);const n=e.slice(0,2);if(!this._countries.has(n))throw new Error(`No country with code ${n}`);const s=this._countries.get(n);if(!s)throw new Error(`No country with code ${n}`);return s.toBBAN(e,t)}fromBBAN(e,t){if(!this._countries.has(e))throw new Error(`No country with code ${e}`);const n=this._countries.get(e);if(!n)throw new Error(`No country with code ${e}`);return n.fromBBAN(this.electronicFormat(t))}isValidBBAN(e,t){if(!C.isString(t))return!1;if(!this._countries.has(e))throw new Error(`No country with code ${e}`);const n=this._countries.get(e);return!!n&&n.isValidBBAN(this.electronicFormat(t))}}const Th=()=>{const r=Eh.getInstance(),e=tt.getInstance();return e.addSpecification(new T("AD",24,"F04F04A12","AD1200012030200359100100")),e.addSpecification(new T("AE",23,"F03F16","AE070331234567890123456")),e.addSpecification(new T("AL",28,"F08A16","AL47212110090000000235698741")),e.addSpecification(new T("AT",20,"F05F11","AT611904300234573201")),e.addSpecification(new T("AZ",28,"U04A20","AZ21NABZ00000000137010001944")),e.addSpecification(new T("BA",20,"F03F03F08F02","BA391290079401028494")),e.addSpecification(new T("BE",16,"F03F07F02","BE68539007547034")),e.addSpecification(new T("BG",22,"U04F04F02A08","BG80BNBG96611020345678")),e.addSpecification(new T("BH",22,"U04A14","BH67BMAG00001299123456")),e.addSpecification(new T("BR",29,"F08F05F10U01A01","BR9700360305000010009795493P1")),e.addSpecification(new T("BY",28,"A04F04A16","BY13NBRB3600900000002Z00AB00")),e.addSpecification(new T("CH",21,"F05A12","CH9300762011623852957")),e.addSpecification(new T("CR",22,"F04F14","CR72012300000171549015")),e.addSpecification(new T("CY",28,"F03F05A16","CY17002001280000001200527600")),e.addSpecification(new T("CZ",24,"F04F06F10","CZ6508000000192000145399")),e.addSpecification(new T("DE",22,"F08F10","DE89370400440532013000")),e.addSpecification(new T("DK",18,"F04F09F01","DK5000400440116243")),e.addSpecification(new T("DO",28,"U04F20","DO28BAGR00000001212453611324")),e.addSpecification(new T("EE",20,"F02F02F11F01","EE382200221020145685")),e.addSpecification(new T("EG",29,"F04F04F17","EG800002000156789012345180002")),e.addSpecification(new T("ES",24,"F04F04F01F01F10","ES9121000418450200051332")),e.addSpecification(new T("FI",18,"F06F07F01","FI2112345600000785")),e.addSpecification(new T("FO",18,"F04F09F01","FO6264600001631634")),e.addSpecification(new T("FR",27,"F05F05A11F02","FR1420041010050500013M02606")),e.addSpecification(new T("GB",22,"U04F06F08","GB29NWBK60161331926819")),e.addSpecification(new T("GE",22,"U02F16","GE29NB0000000101904917")),e.addSpecification(new T("GI",23,"U04A15","GI75NWBK000000007099453")),e.addSpecification(new T("GL",18,"F04F09F01","GL8964710001000206")),e.addSpecification(new T("GR",27,"F03F04A16","GR1601101250000000012300695")),e.addSpecification(new T("GT",28,"A04A20","GT82TRAJ01020000001210029690")),e.addSpecification(new T("HR",21,"F07F10","HR1210010051863000160")),e.addSpecification(new T("HU",28,"F03F04F01F15F01","HU42117730161111101800000000")),e.addSpecification(new T("IE",22,"U04F06F08","IE29AIBK93115212345678")),e.addSpecification(new T("IL",23,"F03F03F13","IL620108000000099999999")),e.addSpecification(new T("IS",26,"F04F02F06F10","IS140159260076545510730339")),e.addSpecification(new T("IT",27,"U01F05F05A12","IT60X0542811101000000123456")),e.addSpecification(new T("IQ",23,"U04F03A12","IQ98NBIQ850123456789012")),e.addSpecification(new T("JO",30,"A04F22","JO15AAAA1234567890123456789012")),e.addSpecification(new T("KW",30,"U04A22","KW81CBKU0000000000001234560101")),e.addSpecification(new T("KZ",20,"F03A13","KZ86125KZT5004100100")),e.addSpecification(new T("LB",28,"F04A20","LB62099900000001001901229114")),e.addSpecification(new T("LC",32,"U04F24","LC07HEMM000100010012001200013015")),e.addSpecification(new T("LI",21,"F05A12","LI21088100002324013AA")),e.addSpecification(new T("LT",20,"F05F11","LT121000011101001000")),e.addSpecification(new T("LU",20,"F03A13","LU280019400644750000")),e.addSpecification(new T("LV",21,"U04A13","LV80BANK0000435195001")),e.addSpecification(new T("MC",27,"F05F05A11F02","MC5811222000010123456789030")),e.addSpecification(new T("MD",24,"U02A18","MD24AG000225100013104168")),e.addSpecification(new T("ME",22,"F03F13F02","ME25505000012345678951")),e.addSpecification(new T("MK",19,"F03A10F02","MK07250120000058984")),e.addSpecification(new T("MR",27,"F05F05F11F02","MR1300020001010000123456753")),e.addSpecification(new T("MT",31,"U04F05A18","MT84MALT011000012345MTLCAST001S")),e.addSpecification(new T("MU",30,"U04F02F02F12F03U03","MU17BOMM0101101030300200000MUR")),e.addSpecification(new T("NL",18,"U04F10","NL91ABNA0417164300")),e.addSpecification(new T("NO",15,"F04F06F01","NO9386011117947")),e.addSpecification(new T("PK",24,"U04A16","PK36SCBL0000001123456702")),e.addSpecification(new T("PL",28,"F08F16","PL61109010140000071219812874")),e.addSpecification(new T("PS",29,"U04A21","PS92PALS000000000400123456702")),e.addSpecification(new T("PT",25,"F04F04F11F02","PT50000201231234567890154")),e.addSpecification(new T("QA",29,"U04A21","QA30AAAA123456789012345678901")),e.addSpecification(new T("RO",24,"U04A16","RO49AAAA1B31007593840000")),e.addSpecification(new T("RS",22,"F03F13F02","RS35260005601001611379")),e.addSpecification(new T("SA",24,"F02A18","SA0380000000608010167519")),e.addSpecification(new T("SC",31,"U04F04F16U03","SC18SSCB11010000000000001497USD")),e.addSpecification(new T("SE",24,"F03F16F01","SE4550000000058398257466")),e.addSpecification(new T("SI",19,"F05F08F02","SI56263300012039086")),e.addSpecification(new T("SK",24,"F04F06F10","SK3112000000198742637541")),e.addSpecification(new T("SM",27,"U01F05F05A12","SM86U0322509800000000270100")),e.addSpecification(new T("ST",25,"F08F11F02","ST68000100010051845310112")),e.addSpecification(new T("SV",28,"U04F20","SV62CENR00000000000000700025")),e.addSpecification(new T("TL",23,"F03F14F02","TL380080012345678910157")),e.addSpecification(new T("TN",24,"F02F03F13F02","TN5910006035183598478831")),e.addSpecification(new T("TR",26,"F05F01A16","TR330006100519786457841326")),e.addSpecification(new T("UA",29,"F25","UA511234567890123456789012345")),e.addSpecification(new T("VA",22,"F18","VA59001123000012345678")),e.addSpecification(new T("VG",24,"U04F16","VG96VPVG0000012345678901")),e.addSpecification(new T("XK",20,"F04F10F02","XK051212012345678906")),e.addSpecification(new T("AO",25,"F21","AO69123456789012345678901")),e.addSpecification(new T("BF",27,"F23","BF2312345678901234567890123")),e.addSpecification(new T("BI",16,"F12","BI41123456789012")),e.addSpecification(new T("BJ",28,"F24","BJ39123456789012345678901234")),e.addSpecification(new T("CI",28,"U02F22","CI70CI1234567890123456789012")),e.addSpecification(new T("CM",27,"F23","CM9012345678901234567890123")),e.addSpecification(new T("CV",25,"F21","CV30123456789012345678901")),e.addSpecification(new T("DZ",24,"F20","DZ8612345678901234567890")),e.addSpecification(new T("IR",26,"F22","IR861234568790123456789012")),e.addSpecification(new T("MG",27,"F23","MG1812345678901234567890123")),e.addSpecification(new T("ML",28,"U01F23","ML15A12345678901234567890123")),e.addSpecification(new T("MZ",25,"F21","MZ25123456789012345678901")),e.addSpecification(new T("SN",28,"U01F23","SN52A12345678901234567890123")),e.addSpecification(new T("GF",27,"F05F05A11F02","GF121234512345123456789AB13")),e.addSpecification(new T("GP",27,"F05F05A11F02","GP791234512345123456789AB13")),e.addSpecification(new T("MQ",27,"F05F05A11F02","MQ221234512345123456789AB13")),e.addSpecification(new T("RE",27,"F05F05A11F02","RE131234512345123456789AB13")),e.addSpecification(new T("PF",27,"F05F05A11F02","PF281234512345123456789AB13")),e.addSpecification(new T("TF",27,"F05F05A11F02","TF891234512345123456789AB13")),e.addSpecification(new T("YT",27,"F05F05A11F02","YT021234512345123456789AB13")),e.addSpecification(new T("NC",27,"F05F05A11F02","NC551234512345123456789AB13")),e.addSpecification(new T("BL",27,"F05F05A11F02","BL391234512345123456789AB13")),e.addSpecification(new T("MF",27,"F05F05A11F02","MF551234512345123456789AB13")),e.addSpecification(new T("PM",27,"F05F05A11F02","PM071234512345123456789AB13")),e.addSpecification(new T("WF",27,"F05F05A11F02","WF621234512345123456789AB13")),{formatterNumber:r,formatterIban:e}};class Do{#e;#r;#t;#n;constructor(e){this.#e=Object.freeze(Object.assign({},e)),this.#r=this.#e.b24Url.replaceAll("https://","").replaceAll("http://","").replace(/:(80|443)$/,""),this.#t=`https://${this.#r}/rest`,this.#n=`https://${this.#r}`}getAuthData(){return{access_token:this.#e.secret,refresh_token:"hook",expires_in:0,domain:this.#r,member_id:this.#r}}refreshAuth(){return Promise.resolve(this.getAuthData())}getUniq(e){const t=this.getAuthData();if(t===!1)throw new Error("AuthData not init");return[e,t.member_id].join("_")}getTargetOrigin(){return`${this.#n}`}getTargetOriginWithPath(){return`${this.#t}/${this.#e.userId}/${this.#e.secret}`}get isAdmin(){return!0}}class Wn extends _t{#e;constructor(e){super(),this.#e=new Do(e),this._http=new Un(this.#e.getTargetOriginWithPath(),this.#e,this._getHttpOptions()),this._http.setClientSideWarning(!0,"It is not safe to use hook requests on the client side"),this._isInit=!0}setLogger(e){super.setLogger(e)}get auth(){return this.#e}offClientSideWarning(){this.getHttpClient().setClientSideWarning(!1,"")}getTargetOrigin(){return this._ensureInitialized(),this.#e.getTargetOrigin()}getTargetOriginWithPath(){return this._ensureInitialized(),this.#e.getTargetOriginWithPath()}static fromWebhookUrl(e){if(!e.trim())throw new Error("Webhook URL cannot be empty");let t;try{t=new URL(e)}catch{throw new Error(`Invalid webhook URL format: ${e}`)}if(t.protocol!=="https:")throw new Error("Webhook requires HTTPS protocol");const n=t.pathname.split("/").filter(Boolean);if(n.length<3||n[0]!=="rest")throw new Error("Webhook URL must follow format: /rest/<userId>/<secret>");const s=n[1],i=n[2];if(!/^\d+$/.test(s))throw new Error(`User ID must be numeric in webhook URL, received: ${s}`);const o=Number.parseInt(s,10);return new Wn({b24Url:t.origin,userId:o,secret:i})}}var X=(r=>(r.getInitData="getInitData",r.setInstallFinish="setInstallFinish",r.setInstall="setInstall",r.refreshAuth="refreshAuth",r.setAppOption="setAppOption",r.setUserOption="setUserOption",r.resizeWindow="resizeWindow",r.reloadWindow="reloadWindow",r.setTitle="setTitle",r.setScroll="setScroll",r.openApplication="openApplication",r.closeApplication="closeApplication",r.openPath="openPath",r.imCallTo="imCallTo",r.imPhoneTo="imPhoneTo",r.imOpenMessenger="imOpenMessenger",r.imOpenHistory="imOpenHistory",r.selectUser="selectUser",r.selectAccess="selectAccess",r.selectCRM="selectCRM",r.showAppForm="showAppForm",r.getInterface="getInterface",r.placementBindEvent="placementBindEvent",r))(X||{});class Po{#e;#r;#t;_logger=null;runCallbackHandler;constructor(e){this.#e=e,this.#r=new Map,this.#t=new Map,this.runCallbackHandler=this._runCallback.bind(this)}setLogger(e){this._logger=e}getLogger(){return this._logger===null&&(this._logger=ye.build("NullLogger"),this._logger.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!1,[I.warn]:!1,[I.error]:!0,[I.trace]:!1})),this._logger}subscribe(){window.addEventListener("message",this.runCallbackHandler)}unsubscribe(){window.removeEventListener("message",this.runCallbackHandler)}async send(e,t=null){return new Promise((n,s)=>{let i;const o={resolve:n,reject:s,timeoutId:null},l=this.#n(o);let a=null;const u=Xn(t||{},["singleOption","callBack","isSafely","safelyTime"]),{callBack:c,singleOption:f}=t||{};if(c&&this.#t.set(l,c),f?a=f:Object.keys(u).length>0&&(a={...u}),e.toString().includes(":"))i={method:e.toString(),params:a||"",callback:l,appSid:this.#e.getAppSid()};else{i=e.toString(),t?.isRawValue!==!0&&(a=JSON.stringify(a));const h=[a||"",l,this.#e.getAppSid()];i+=":"+h.filter(Boolean).join(":")}this.getLogger().log(`send to ${this.#e.getTargetOrigin()}`,{cmd:i}),parent.postMessage(i,this.#e.getTargetOrigin()),t?.isSafely&&(this.#r.get(l).timeoutId=window.setTimeout(()=>{this.#r.has(l)&&(this.getLogger().warn(`Action ${e.toString()} stop by timeout`),this.#r.delete(l),n({isSafely:!0}))},Number.parseInt(String(t?.safelyTime||900))))})}_runCallback(e){if(e.origin===this.#e.getTargetOrigin()&&e.data){this.getLogger().log(`get from ${e.origin}`,{data:e.data});const t=e.data.split(":"),n={id:t[0],args:t.slice(1).join(":")};if(n.args&&(n.args=JSON.parse(n.args)),this.#r.has(n.id)){const s=this.#r.get(n.id);s.timeoutId&&clearTimeout(s.timeoutId),this.#r.delete(n.id),s.resolve(n.args)}else if(this.#t.has(n.id)){const s=this.#t.get(n.id);s&&s.apply(globalThis,[n.args])}}}#n(e){const t=W.getUniqId();return this.#r.set(t,e),t}}class Mo{#e="";#r=!0;#t=null;#n=null;#s=null;constructor(e){e.DOMAIN&&(this.#e=e.DOMAIN,this.#e=this.#e.replace(/:(80|443)$/,"")),this.#r=e.PROTOCOL===!0,e.LANG&&(this.#s=e.LANG),e.APP_SID&&(this.#t=e.APP_SID)}initData(e){return this.#e||(this.#e=e.DOMAIN),this.#n||(this.#n=e.PATH),this.#s||(this.#s=e.LANG),this.#r=Number.parseInt(e.PROTOCOL)===1,this.#e=this.#e.replace(/:(80|443)$/,""),this}getAppSid(){if(this.#t===null)throw new Error("Not init appSid");return this.#t}getTargetOrigin(){return`${this.#r?"https":"http"}://${this.#e}`}getTargetOriginWithPath(){return this.getTargetOrigin()+(this.#n??"")}getLang(){return this.#s||$n.en}}class Fo{#e=null;#r=null;#t=0;#n=null;#s=!1;#o;#i;constructor(e,t){this.#o=e,this.#i=t}initData(e){return e.AUTH_ID&&(this.#e=e.AUTH_ID,this.#r=e.REFRESH_ID,this.#t=Date.now()+Number.parseInt(e.AUTH_EXPIRES)*1e3,this.#s=e.IS_ADMIN,this.#n=e.MEMBER_ID||""),this}getAuthData(){return this.#t>Date.now()?{access_token:this.#e,refresh_token:this.#r,expires_in:this.#t,domain:this.#o.getTargetOrigin(),member_id:this.#n}:!1}async refreshAuth(){return this.#i.send(X.refreshAuth,{}).then(e=>(this.#e=e.AUTH_ID,this.#r=e.REFRESH_ID,this.#t=Date.now()+Number.parseInt(e.AUTH_EXPIRES)*1e3,Promise.resolve(this.getAuthData())))}getUniq(e){return[e,this.#n||""].join("_")}get isAdmin(){return this.#s}}class xo{#e;constructor(e){this.#e=e}async closeApplication(){return this.#e.send(X.closeApplication,{isSafely:!1})}async fitWindow(){const e="100%",t=this.getScrollSize().scrollHeight;return this.#e.send(X.resizeWindow,{width:e,height:t,isSafely:!0})}async resizeWindow(e,t){return e>0&&t>0?this.#e.send(X.resizeWindow,{width:e,height:t,isSafely:!0}):Promise.reject(new Error(`Wrong width:number = ${e} or height:number = ${t}`))}async resizeWindowAuto(e=null,t=0,n=0){const s=document.body;let i=Math.max(s.scrollWidth,s.offsetWidth);n>0&&(i=Math.max(n,i));let o=Math.max(s.scrollHeight,s.offsetHeight);return e&&(o=Math.max(e.scrollHeight,e.offsetHeight)),t>0&&(o=Math.max(t,o)),this.resizeWindow(i,o)}getScrollSize(){return vh()}async scrollParentWindow(e){return Number.isInteger(e)?(e<0&&(e=0),this.#e.send(X.setScroll,{scroll:e,isSafely:!0})):Promise.reject(new Error("Wrong scroll number"))}async reloadWindow(){return this.#e.send(X.reloadWindow,{isSafely:!0})}async setTitle(e){return this.#e.send(X.setTitle,{title:e.toString(),isSafely:!0})}async imCallTo(e,t=!0){return this.#e.send(X.imCallTo,{userId:e,video:t,isSafely:!0})}async imPhoneTo(e){return this.#e.send(X.imPhoneTo,{phone:e,isSafely:!0})}async imOpenMessenger(e){return this.#e.send(X.imOpenMessenger,{dialogId:e,isSafely:!0})}async imOpenHistory(e){return this.#e.send(X.imOpenHistory,{dialogId:e,isSafely:!0})}}let jo=class{#e;#r=null;#t=null;constructor(e){this.#e=e}initData(e){return e.APP_OPTIONS&&(this.#r=e.APP_OPTIONS),e.USER_OPTIONS&&(this.#t=e.USER_OPTIONS),this}appGet(e){if(this.#r&&this.#r[e])return this.#r[e];throw new Error(`app.option.${e} not set`)}async appSet(e,t){return this.#r||(this.#r=[]),this.#r[e]=t,this.#n(X.setAppOption,e,this.#r[e])}userGet(e){if(this.#t&&this.#t[e])return this.#t[e];throw new Error(`user.option.${e} not set`)}async userSet(e,t){return this.#r||(this.#r=[]),this.#r[e]||(this.#r[e]=null),this.#t[e]=t,this.#n(X.setUserOption,e,this.#t[e])}async#n(e,t,n){return this.#e.send(e,{name:t,value:n,isSafely:!0}).then(()=>Promise.resolve())}};class Bo{#e;constructor(e){this.#e=e}async selectUser(){return this.#e.send(X.selectUser,{mult:!1})}async selectUsers(){return this.#e.send(X.selectUser,{mult:!0})}async selectAccess(e=[]){return console.warn("@deprecated selectAccess"),this.#e.send(X.selectAccess,{value:e})}async selectCRM(e){return console.warn("@deprecated selectCRM"),this.#e.send(X.selectCRM,{entityType:e?.entityType,multiple:e?.multiple,value:e?.value})}}class Uo{#e;#r;constructor(e,t){this.#e=e,this.#r=t}getUrl(e="/"){return new URL(e,this.#e.getTargetOrigin())}getTargetOrigin(){return this.#e.getTargetOrigin()}async openSliderAppPage(e={}){return this.#r.send(X.openApplication,e)}async closeSliderAppPage(){return this.#r.send(X.closeApplication,{isSafely:!1})}#t(e=1640){return e>0?e>1200&&e<=1640?"/crm/type/0/details/0/../../../../..":e>950&&e<=1200?"/company/personal/user/0/groups/create/../../../../../..":e>900&&e<=950?"/crm/company/requisite/0/../../../..":e<=900?"/workgroups/group/0/card/../../../..":"/crm/deal/../..":"/crm/deal/../.."}async openPath(e,t=1640){const n=new URL(e);return n.searchParams.set("IFRAME","Y"),n.searchParams.set("IFRAME_TYPE","SIDE_SLIDER"),this.#r.send(X.openPath,{path:[this.#t(t),n.pathname,n.search].join("")}).then(s=>s?.result==="error"?s?.errorCode==="METHOD_NOT_SUPPORTED_ON_DEVICE"?new Promise((i,o)=>{const l=window.open(e,"_blank");if(!l){o(new Error("Error open window"));return}let a=0;const u=1e3*60*5,c=window.setInterval(()=>{a=a+1,l.closed?(clearInterval(c),i({isOpenAtNewWindow:!0,isClose:!0})):a>u&&(clearInterval(c),i({isOpenAtNewWindow:!0,isClose:!1}))},1e3)}):Promise.reject(new Error(s?.errorCode)):s?.result==="close"?Promise.resolve({isOpenAtNewWindow:!1,isClose:!0}):Promise.resolve({isOpenAtNewWindow:!1,isClose:!1}))}async showAppForm(e){return console.warn("@deprecated showAppForm"),this.#r.send(X.showAppForm,{params:e,isSafely:!0})}}class $o{#e;#r="";#t={};constructor(e){this.#e=e}initData(e){this.#r=e.PLACEMENT||"DEFAULT";const t=e.PLACEMENT_OPTIONS;return this.#t=Object.freeze(t),this}get title(){return this.#r}get isDefault(){return this.title==="DEFAULT"}get options(){return this.#t}get isSliderMode(){return this.options?.IFRAME==="Y"}async getInterface(){return this.#e.send(X.getInterface,{isSafely:!0})}async bindEvent(e,t){return this.#e.send(X.placementBindEvent,{event:e,callBack:t,isSafely:!0})}async call(e,t={}){return this.#e.send(e,{...t,isSafely:!0,isRawValue:["setValue"].includes(e)})}async callCustomBind(e,t=null,n){let s={};return C.isString(t)?s.singleOption=t:C.isObjectLike(t)&&(s={...t}),this.#e.send(e,{...s,callBack:n,isSafely:!0})}}class Wo extends _t{#e=!1;#r=!1;#t;#n;#s;#o;#i;#l;#c;#a;constructor(e){super(),this.#t=new Mo(e),this.#n=new Po(this.#t),this.#n.subscribe(),this.#s=new Fo(this.#t,this.#n),this.#o=new xo(this.#n),this.#i=new jo(this.#n),this.#l=new Bo(this.#n),this.#c=new Uo(this.#t,this.#n),this.#a=new $o(this.#n),this._isInit=!1}setLogger(e){super.setLogger(e),this.#n.setLogger(this.getLogger())}get isFirstRun(){return this._ensureInitialized(),this.#r}get isInstallMode(){return this._ensureInitialized(),this.#e}get parent(){return this._ensureInitialized(),this.#o}get auth(){return this._ensureInitialized(),this.#s}get slider(){return this._ensureInitialized(),this.#c}get placement(){return this._ensureInitialized(),this.#a}get options(){return this._ensureInitialized(),this.#i}get dialog(){return this._ensureInitialized(),this.#l}async init(){return this.#n.send(X.getInitData,{}).then(e=>(this.getLogger().log("init data:",e),this.#t.initData(e),this.#s.initData(e),this.#a.initData(e),this.#i.initData(e),this.#e=e.INSTALL,this.#r=e.FIRST_RUN,this._http=new Un(this.#t.getTargetOriginWithPath(),this.#s,this._getHttpOptions()),this._isInit=!0,this.#r?this.#n.send(X.setInstall,{install:!0}):Promise.resolve()))}destroy(){this.#n.unsubscribe(),super.destroy()}async installFinish(){return this.isInstallMode?this.#n.send(X.setInstallFinish,{}):Promise.reject(new Error("Application was previously installed. You cannot call installFinish"))}getTargetOrigin(){return this._ensureInitialized(),this.#t.getTargetOrigin()}getTargetOriginWithPath(){return this._ensureInitialized(),this.#t.getTargetOriginWithPath()}getAppSid(){return this._ensureInitialized(),this.#t.getAppSid()}getLang(){return this._ensureInitialized(),this.#t.getLang()}}class Oh extends Fe{}class qo{#e;#r=null;#t;#n;#s=0;#o;#i;#l;#c;#a=null;constructor(e,t){this.#t=Object.assign({},e),this.#n=Object.freeze(Object.assign({},t)),this.#o=this.#t.domain.replaceAll("https://","").replaceAll("http://","").replace(/:(80|443)$/,""),this.#i=this.#t.clientEndpoint,this.#l=this.#i.replace("/rest/",""),this.#c=this.#t.serverEndpoint.replace("/rest/",""),this.#s=this.#t.expires*1e3,this.#e=ie.create({baseURL:this.#c,headers:{"Content-Type":"application/json"}})}getAuthData(){return this.#s>Date.now()?{access_token:this.#t.accessToken,refresh_token:this.#t.refreshToken,expires_in:this.#t.expiresIn,domain:this.#o,member_id:this.#t.memberId}:!1}async refreshAuth(){try{const e=await this.#e.get("/oauth/token/",{params:{grant_type:"refresh_token",client_id:this.#n.clientId,client_secret:this.#n.clientSecret,refresh_token:this.#t.refreshToken}});if(e.data.error)throw new Error(`Token update error: ${e.data.error}`);if(e.status!==200)throw new Error(`Token update error status code: ${e.status}`);const t=e.data;this.#t.accessToken=t.access_token,this.#t.refreshToken=t.refresh_token,this.#t.expires=Number.parseInt(t.expires||"0"),this.#t.expiresIn=Number.parseInt(t.expires_in||"3600"),this.#t.clientEndpoint=t.client_endpoint,this.#t.serverEndpoint=t.server_endpoint,this.#t.scope=t.scope,this.#t.status=Object.values(Qe).find(s=>s===t.status)||Qe.Free,this.#s=this.#t.expires*1e3;const n=this.getAuthData();return this.#r&&await this.#r({authData:n,b24OAuthParams:this.#t}),n}catch(e){if(e instanceof Pn){let t={error:e?.code||0,errorDescription:e?.message||""};if(e.response&&e.response.data&&!C.isUndefined(e.response.data.error)){const n=e.response.data;t={error:n.error,errorDescription:n.error_description}}throw new Oh({code:String(t.error),description:t.errorDescription,status:e.response?.status||0,requestInfo:{method:"/oauth/token/"}})}else if(e instanceof Error)throw e;throw new Error(`Strange error: ${e instanceof Error?e.message:e}`,{cause:e})}}setCallbackRefreshAuth(e){this.#r=e}removeCallbackRefreshAuth(){this.#r=null}getUniq(e){return[e,this.#t.memberId||""].join("_")}getTargetOrigin(){return`${this.#l}`}getTargetOriginWithPath(){return`${this.#i}`}get isAdmin(){if(this.#a===null)throw new Error("isAdmin not init. You need call B24OAuth::initIsAdmin().");return this.#a}async initIsAdmin(e){const t=await e.call("profile",{},0);if(!t.isSuccess)throw new Error(t.getErrorMessages().join(";"));t.getData().result?.ADMIN&&(this.#a=!0)}}class Ah extends _t{#e;constructor(e,t){super(),this.#e=new qo(e,t),this._http=new Un(this.#e.getTargetOriginWithPath(),this.#e,this._getHttpOptions()),this._http.setClientSideWarning(!0,"It is not safe to use oauth requests on the client side"),this._isInit=!0}setLogger(e){super.setLogger(e)}async initIsAdmin(){return this._ensureInitialized(),this.#e.initIsAdmin(this._http)}setCallbackRefreshAuth(e){this._ensureInitialized(),this.#e.setCallbackRefreshAuth(e)}removeCallbackRefreshAuth(){this._ensureInitialized(),this.#e.removeCallbackRefreshAuth()}offClientSideWarning(){this.getHttpClient().setClientSideWarning(!1,"")}get auth(){return this.#e}getTargetOrigin(){return this._ensureInitialized(),this.#e.getTargetOrigin()}getTargetOriginWithPath(){return this._ensureInitialized(),this.#e.getTargetOriginWithPath()}}class qn extends Error{constructor(e,...t){super(...t),this.name="UnhandledMatchError",this.message=`Unhandled match value of type ${e}`,this.stack=new Error("for stack").stack}}class xt{_b24;_logger=null;_data=null;constructor(e){this._b24=e}setLogger(e){this._logger=e}getLogger(){return this._logger===null&&(this._logger=ye.build("NullLogger"),this._logger.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!1,[I.warn]:!1,[I.error]:!0,[I.trace]:!1})),this._logger}async initData(e){return this.getLogger().log(e),Promise.reject(new Error("Rewrite this function"))}}class Ih extends xt{_data=null;async initData(e){this._data=e}get data(){if(this._data===null)throw new Error("ProfileManager.data not initialized");return this._data}}class Ch extends xt{_data=null;async initData(e){this._data=e}get data(){if(this._data===null)throw new Error("AppManager.data not initialized");return this._data}get statusCode(){return $i[this.data.status]||"Unknown status"}}class Nh extends xt{_data=null;async initData(e){this._data=e}get data(){if(this._data===null)throw new Error("PaymentManager.data not initialized");return this._data}}class Rh extends xt{_data=null;async initData(e){this._data=e,this.makeRestrictionManagerParams()}get data(){if(this._data===null)throw new Error("LicenseManager.data not initialized");return this._data}makeRestrictionManagerParams(){this.data?.license&&this.data.license.includes("ent")&&(this.getLogger().log(`LICENSE ${this.data.license} => up restriction manager params`,yn),this._b24.getHttpClient().setRestrictionManagerParams(yn))}}class Lh extends xt{async initData(e){this._data={currencyBase:"?",currencyList:new Map},this.setBaseCurrency(e.currencyBase),this.setCurrencyList(e.currencyList);try{await this.loadData()}catch(t){throw t instanceof Error?t:(console.error(t),new Error("Failed to load data"))}}async loadData(){const e=this.currencyList.map(t=>({method:"crm.currency.get",params:{id:t}}));if(e.length===0)return Promise.resolve();try{(await this._b24.callBatchByChunk(e,!0)).getData().forEach(t=>{if(typeof t.LANG>"u")return;const n=t.CURRENCY,s=this.data.currencyList.get(n);if(!(typeof s>"u"))for(const[i,o]of Object.entries(t.LANG))switch(s.lang[i]={decimals:Number.parseInt(o.DECIMALS),decPoint:o.DEC_POINT,formatString:o.FORMAT_STRING,fullName:o.FULL_NAME,isHideZero:o.HIDE_ZERO==="Y",thousandsSep:o.THOUSANDS_SEP,thousandsVariant:o.THOUSANDS_VARIANT},s.lang[i].thousandsVariant){case"N":s.lang[i].thousandsSep="";break;case"D":s.lang[i].thousandsSep=".";break;case"C":s.lang[i].thousandsSep=",";break;case"S":s.lang[i].thousandsSep=" ";break;case"B":s.lang[i].thousandsSep=" ";break;default:C.isStringFilled(s.lang[i].thousandsSep)||(s.lang[i].thousandsSep=" ");break}})}catch(t){console.error(t)}}get data(){if(this._data===null)throw new Error("CurrencyManager.data not initialized");return this._data}setBaseCurrency(e){this._data.currencyBase=e}get baseCurrency(){return this.data.currencyBase}setCurrencyList(e=[]){this.data.currencyList.clear();for(const t of e)this.data.currencyList.set(t.CURRENCY,{amount:Number.parseFloat(t.CURRENCY),amountCnt:Number.parseInt(t.AMOUNT_CNT),isBase:t.BASE==="Y",currencyCode:t.CURRENCY,dateUpdate:W.toDateTime(t.DATE_UPDATE),decimals:Number.parseInt(t.DECIMALS),decPoint:t.DEC_POINT,formatString:t.FORMAT_STRING,fullName:t.FULL_NAME,lid:t.LID,sort:Number.parseInt(t.SORT),thousandsSep:t?.THOUSANDS_SEP||null,lang:{}})}getCurrencyFullName(e,t){const n=this.data.currencyList.get(e);if(typeof n>"u")throw new qn(e);let s=n.fullName;if(!(typeof t>"u")){const i=n.lang[t];C.isUndefined(i)||(s=i.fullName)}return s}getCurrencyLiteral(e,t){const n=this.data.currencyList.get(e);if(typeof n>"u")throw new qn(e);let s=n.formatString;if(!(typeof t>"u")){const i=n.lang[t];C.isUndefined(i)||(s=i.formatString)}return s.replaceAll("&#","&%").replaceAll("#","").replaceAll("&%","&#").trim()||""}get currencyList(){return[...this.data.currencyList.keys()]}format(e,t,n){const s=this.data.currencyList.get(t);if(typeof s>"u")throw new qn(t);const i={formatString:s.formatString,decimals:s.decimals,decPoint:s.decPoint,thousandsSep:s.thousandsSep};C.isStringFilled(i.thousandsSep)||(i.thousandsSep="");const o=s.lang[n];return C.isUndefined(o)||(i.formatString=o.formatString,i.decimals=o.decimals,i.decPoint=o.decPoint,i.thousandsSep=o.thousandsSep),i.formatString.replaceAll("&#","&%").replace("#",W.numberFormat(e,i.decimals,i.decPoint,i.thousandsSep)).replaceAll("&%","&#")||""}}class Vn extends xt{_data;_type;static getSupportTypes(){return[Xe.NotSet,Xe.JsonArray,Xe.JsonObject,Xe.FloatVal,Xe.IntegerVal,Xe.BoolYN,Xe.StringVal]}static prepareArrayList(e){return C.isArray(e)?e:C.isObject(e)?Object.values(e):[]}constructor(e,t){super(e),this._type=t,this._data=new Map}get data(){return this._data}reset(){this.data.clear()}async initData(e){if(this.reset(),C.isObject(e))for(const[t,n]of Object.entries(e))this.data.set(t,n)}getJsonArray(e,t=[]){if(!this.data.has(e))return t;let n=this.data.get(e);try{n=JSON.parse(n),!C.isArray(n)&&!C.isObject(n)&&(n=t)}catch(s){this.getLogger().error(s),n=t}return Vn.prepareArrayList(n)}getJsonObject(e,t={}){if(!this.data.has(e))return t;let n=this.data.get(e);try{n=JSON.parse(n)}catch(s){this.getLogger().error(s),n=t}return C.isObject(n)||(n=t),n}getFloat(e,t=0){return this.data.has(e)?W.toNumber(this.data.get(e)):t}getInteger(e,t=0){return this.data.has(e)?W.toInteger(this.data.get(e)):t}getBoolYN(e,t=!0){return this.data.has(e)?W.toBoolean(this.data.get(e)):t}getBoolNY(e,t=!1){return this.data.has(e)?W.toBoolean(this.data.get(e)):t}getString(e,t=""){return this.data.has(e)?this.data.get(e).toString():t}getDate(e,t=null){if(!this.data.has(e))return t;try{const n=W.toDateTime(this.data.get(e).toString());return n.isValid?n:t}catch{return t}}encode(e){return JSON.stringify(e)}decode(e,t){try{return e.length>0?JSON.parse(e):t}catch(n){this.getLogger().warn(n,e)}return t}getMethodSave(){switch(this._type){case"app":return"app.option.set";case"user":return"user.option.set"}}async save(e,t){const n=[];return n.push({method:this.getMethodSave(),params:{options:e}}),C.isObject(t)&&n.push({method:"pull.application.event.add",params:{COMMAND:t?.command,PARAMS:t?.params,MODULE_ID:t?.moduleId}}),this._b24.callBatch(n,!0)}}class Vo{_logger=null;userId;siteId;constructor(e={}){this.userId=e.userId?W.toInteger(e.userId):0,this.siteId=e.siteId??"none"}setLogger(e){this._logger=e}getLogger(){return this._logger===null&&(this._logger=ye.build("NullLogger"),this._logger.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!1,[I.warn]:!1,[I.error]:!0,[I.trace]:!1})),this._logger}set(e,t){if(typeof window.localStorage>"u"){this.getLogger().error(new Error("undefined window.localStorage"));return}typeof t!="string"&&t&&(t=JSON.stringify(t)),window.localStorage.setItem(this._getKey(e),t)}get(e,t){if(typeof window.localStorage>"u")return t||null;const n=window.localStorage.getItem(this._getKey(e));return n===null?t||null:JSON.parse(n)}remove(e){if(typeof window.localStorage>"u"){this.getLogger().error(new Error("undefined window.localStorage"));return}return window.localStorage.removeItem(this._getKey(e))}_getKey(e){return`@bitrix24/b24jssdk-pull-${this.userId}-${this.siteId}-${e}`}compareKey(e,t){return e===this._getKey(t)}}class Dh extends Error{constructor(e){super(e),this.name="ErrorNotConnected"}}class Ph extends Error{constructor(e){super(e),this.name="ErrorTimeout"}}const Br="2.0";class Mh{_logger=null;_connector;_idCounter=0;_handlers={};_rpcResponseAwaiters=new Map;constructor(e){if(this._connector=e.connector,C.isPlainObject(e.handlers))for(const t in e.handlers)this.handle(t,e.handlers[t])}setLogger(e){this._logger=e}getLogger(){return this._logger===null&&(this._logger=ye.build("NullLogger"),this._logger.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!1,[I.warn]:!1,[I.error]:!0,[I.trace]:!1})),this._logger}handle(e,t){this._handlers[e]=t}async executeOutgoingRpcCommand(e,t,n=5){return new Promise((s,i)=>{const o=this.createRequest(e,t);this._connector.send(JSON.stringify(o))||i(new Dh("websocket is not connected"));const l=setTimeout(()=>{this._rpcResponseAwaiters.delete(o.id),i(new Ph("no response"))},n*1e3);this._rpcResponseAwaiters.set(o.id,{resolve:s,reject:i,timeout:l})})}executeOutgoingRpcBatch(e){const t=[],n=[];return e.forEach(({method:s,params:i,id:o})=>{const l=this.createRequest(s,i,o);t.push(l),n.push(new Promise((a,u)=>this._rpcResponseAwaiters.set(l.id,{resolve:a,reject:u})))}),this._connector.send(JSON.stringify(t)),n}processRpcResponse(e){if("id"in e&&this._rpcResponseAwaiters.has(Number(e.id))){const t=this._rpcResponseAwaiters.get(Number(e.id));t&&("result"in e?t.resolve(e.result):"error"in e?t.reject(e?.error||"error"):t.reject("wrong response structure"),clearTimeout(t.timeout),this._rpcResponseAwaiters.delete(Number(e.id)));return}this.getLogger().error(new Error(`${W.getDateForLog()}: Pull: Received rpc response with unknown id`),e)}parseJsonRpcMessage(e){let t;try{t=JSON.parse(e)}catch(n){this.getLogger().error(new Error(`${W.getDateForLog()}: Pull: Could not decode json rpc message`),n);return}if(C.isArray(t))return this.executeIncomingRpcBatch(t);if(C.isJsonRpcRequest(t))return this.executeIncomingRpcCommand(t);if(C.isJsonRpcResponse(t))return this.processRpcResponse(t);this.getLogger().error(new Error(`${W.getDateForLog()}: Pull: unknown rpc packet`),t)}executeIncomingRpcCommand({method:e,params:t}){return e in this._handlers?this._handlers[e].call(this,t||{}):{jsonrpc:Br,error:_n.MethodNotFound}}executeIncomingRpcBatch(e){const t=[];for(const n of e)if("jsonrpc"in n)if("method"in n){const s=this.executeIncomingRpcCommand(n);s&&(s.jsonrpc=Br,s.id=n.id,t.push(s))}else this.processRpcResponse(n);else this.getLogger().error(new Error(`${W.getDateForLog()}: Pull: unknown rpc command in batch`),n),t.push({jsonrpc:Br,error:_n.InvalidRequest});return t}nextId(){return++this._idCounter}createPublishRequest(e){return e.map(t=>this.createRequest("publish",t))}createRequest(e,t,n){return n||(n=this.nextId()),{jsonrpc:Br,method:e,params:t,id:n}}}class Fh{_logger=null;_storage;_ttl=1440*60;_callbacks;constructor(e={}){e=e||{},this._storage=e.storage||new Vo,this._callbacks={onWebSocketBlockChanged:C.isFunction(e.onWebSocketBlockChanged)?e.onWebSocketBlockChanged:()=>{}},this._storage&&window.addEventListener("storage",this.onLocalStorageSet.bind(this))}setLogger(e){this._logger=e}getLogger(){return this._logger===null&&(this._logger=ye.build("NullLogger"),this._logger.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!1,[I.warn]:!1,[I.error]:!0,[I.trace]:!1})),this._logger}onLocalStorageSet(e){this._storage.compareKey(e.key||"",Ne.WebsocketBlocked)&&e.newValue!==e.oldValue&&this._callbacks.onWebSocketBlockChanged({isWebSocketBlocked:this.isWebSocketBlocked()})}isWebSocketBlocked(){return this._storage?this._storage.get(Ne.WebsocketBlocked,0)>Date.now():!1}setWebSocketBlocked(e){if(!this._storage)return!1;try{this._storage.set(Ne.WebsocketBlocked,e?Date.now()+this._ttl:0)}catch(t){return this.getLogger().error(new Error(`${W.getDateForLog()}: Pull: Could not save WS_blocked flag in local storage. Error: `),t),!1}return!0}isLongPollingBlocked(){return this._storage?this._storage.get(Ne.LongPollingBlocked,0)>Date.now():!1}setLongPollingBlocked(e){if(!this._storage)return!1;try{this._storage.set(Ne.LongPollingBlocked,e?Date.now()+this._ttl:0)}catch(t){return this.getLogger().error(new Error(`${W.getDateForLog()}: Pull: Could not save LP_blocked flag in local storage. Error: `),t),!1}return!0}isLoggingEnabled(){return this._storage?this._storage.get(Ne.LoggingEnabled,0)>this.getTimestamp():!1}setLoggingEnabled(e){if(!this._storage)return!1;try{this._storage.set(Ne.LoggingEnabled,e?this.getTimestamp()+this._ttl:0)}catch(t){return this.getLogger().error(new Error(`${W.getDateForLog()}: LocalStorage error: `),t),!1}return!0}getTimestamp(){return Date.now()}}class xh{_logger=null;_publicIds;_restClient;_getPublicListMethod;constructor(e){this._publicIds=new Map,this._restClient=e.b24,this._getPublicListMethod=e.getPublicListMethod}setLogger(e){this._logger=e}getLogger(){return this._logger===null&&(this._logger=ye.build("NullLogger"),this._logger.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!1,[I.warn]:!1,[I.error]:!0,[I.trace]:!1})),this._logger}async getPublicIds(e){const t=new Date,n={},s=[];for(const i of e){const o=this._publicIds.get(i);o&&o.end>t?n[o.userId]=o:s.push(i)}return s.length===0?Promise.resolve(n):new Promise(i=>{this._restClient.callMethod(this._getPublicListMethod,{users:s}).then(o=>{const l=o.getData().result;this.setPublicIds(Object.values(l));for(const a of s){const u=this._publicIds.get(a);u&&(n[u.userId]=u)}i(n)}).catch(o=>(this.getLogger().error(o),i({})))})}setPublicIds(e){e.forEach(t=>{const n=Number(t.user_id);this._publicIds.set(n,{userId:n,publicId:t.public_id,signature:t.signature,start:new Date(t.start),end:new Date(t.end)})})}}var sr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function jh(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var zn={exports:{}};/*!
|
|
12
|
+
`+i):n.stack=i}catch{}}throw n}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=wt(this.defaults,t);const{transitional:n,paramsSerializer:s,headers:i}=t;n!==void 0&&Fr.assertOptions(n,{silentJSONParsing:He.transitional(He.boolean),forcedJSONParsing:He.transitional(He.boolean),clarifyTimeoutError:He.transitional(He.boolean)},!1),s!=null&&(k.isFunction(s)?t.paramsSerializer={serialize:s}:Fr.assertOptions(s,{encode:He.function,serialize:He.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Fr.assertOptions(t,{baseUrl:He.spelling("baseURL"),withXsrfToken:He.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=i&&k.merge(i.common,i[t.method]);i&&k.forEach(["delete","get","head","post","put","patch","common"],p=>{delete i[p]}),t.headers=Oe.concat(o,i);const l=[];let a=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(t)===!1||(a=a&&g.synchronous,l.unshift(g.fulfilled,g.rejected))});const u=[];this.interceptors.response.forEach(function(g){u.push(g.fulfilled,g.rejected)});let c,f=0,h;if(!a){const p=[ko.bind(this),void 0];for(p.unshift(...l),p.push(...u),h=p.length,c=Promise.resolve(t);f<h;)c=c.then(p[f++],p[f++]);return c}h=l.length;let d=t;for(f=0;f<h;){const p=l[f++],g=l[f++];try{d=p(d)}catch(m){g.call(this,m);break}}try{c=ko.call(this,d)}catch(p){return Promise.reject(p)}for(f=0,h=u.length;f<h;)c=c.then(u[f++],u[f++]);return c}getUri(e){e=wt(this.defaults,e);const t=fo(e.baseURL,e.url,e.allowAbsoluteUrls);return no(t,e.params,e.paramsSerializer)}};k.forEach(["delete","get","head","options"],function(e){bt.prototype[e]=function(t,n){return this.request(wt(n||{},{method:e,url:t,data:(n||{}).data}))}}),k.forEach(["post","put","patch"],function(e){function t(n){return function(i,o,l){return this.request(wt(l||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}bt.prototype[e]=t(),bt.prototype[e+"Form"]=t(!0)});let Ju=class oa{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(i){t=i});const n=this;this.promise.then(s=>{if(!n._listeners)return;let i=n._listeners.length;for(;i-- >0;)n._listeners[i](s);n._listeners=null}),this.promise.then=s=>{let i;const o=new Promise(l=>{n.subscribe(l),i=l}).then(s);return o.cancel=function(){n.unsubscribe(i)},o},e(function(i,o,l){n.reason||(n.reason=new Ft(i,o,l),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=n=>{e.abort(n)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new oa(function(s){e=s}),cancel:e}}};function Zu(r){return function(t){return r.apply(null,t)}}function Gu(r){return k.isObject(r)&&r.isAxiosError===!0}const Dn={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Dn).forEach(([r,e])=>{Dn[e]=r});function To(r){const e=new bt(r),t=Wi(bt.prototype.request,e);return k.extend(t,bt.prototype,e,{allOwnKeys:!0}),k.extend(t,e,null,{allOwnKeys:!0}),t.create=function(s){return To(wt(r,s))},t}const ie=To(rr);ie.Axios=bt,ie.CanceledError=Ft,ie.CancelToken=Ju,ie.isCancel=lo,ie.VERSION=vo,ie.toFormData=Nr,ie.AxiosError=V,ie.Cancel=ie.CanceledError,ie.all=function(e){return Promise.all(e)},ie.spread=Zu,ie.isAxiosError=Gu,ie.mergeConfig=wt,ie.AxiosHeaders=Oe,ie.formToJSON=r=>oo(k.isHTMLForm(r)?new FormData(r):r),ie.getAdapter=_o.getAdapter,ie.HttpStatusCode=Dn,ie.default=ie;const{Axios:Ef,AxiosError:Pn,CanceledError:Tf,isCancel:Of,CancelToken:Af,VERSION:If,all:Cf,Cancel:Nf,isAxiosError:Rf,spread:Lf,toFormData:Df,AxiosHeaders:Pf,HttpStatusCode:Mf,formToJSON:Ff,getAdapter:xf,mergeConfig:jf}=ie,Yu=String.prototype.replace,Ku=/%20/g,Oo={RFC1738:"RFC1738",RFC3986:"RFC3986"},Qu={RFC1738:function(r){return Yu.call(r,Ku,"+")},RFC3986:function(r){return String(r)}},Xu=Oo.RFC1738,eh=Oo.RFC3986,Mn=Object.prototype.hasOwnProperty,St=Array.isArray,Je=(function(){const r=[];for(let e=0;e<256;++e)r.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return r})(),th=function(e){for(;e.length>1;){const t=e.pop(),n=t.obj[t.prop];if(St(n)){const s=[];for(let i=0;i<n.length;++i)typeof n[i]<"u"&&s.push(n[i]);t.obj[t.prop]=s}}},rh=function(e,t){const n=t&&t.plainObjects?Object.create(null):{};for(let s=0;s<e.length;++s)typeof e[s]<"u"&&(n[s]=e[s]);return n},nh=function r(e,t,n){if(!t)return e;if(typeof t!="object"){if(St(e))e.push(t);else if(e&&typeof e=="object")(n&&(n.plainObjects||n.allowPrototypes)||!Mn.call(Object.prototype,t))&&(e[t]=!0);else return[e,t];return e}if(!e||typeof e!="object")return[e].concat(t);let s=e;return St(e)&&!St(t)&&(s=rh(e,n)),St(e)&&St(t)?(t.forEach(function(i,o){if(Mn.call(e,o)){const l=e[o];l&&typeof l=="object"&&i&&typeof i=="object"?e[o]=r(l,i,n):e.push(i)}else e[o]=i}),e):Object.keys(t).reduce(function(i,o){const l=t[o];return Mn.call(i,o)?i[o]=r(i[o],l,n):i[o]=l,i},s)},sh=function(r,e,t){const n=r.replace(/\+/g," ");if(t==="iso-8859-1")return n.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(n)}catch{return n}},Fn=1024,ih=function(e,t,n,s,i){if(e.length===0)return e;let o=e;if(typeof e=="symbol"?o=Symbol.prototype.toString.call(e):typeof e!="string"&&(o=String(e)),n==="iso-8859-1")return escape(o).replace(/%u[0-9a-f]{4}/gi,function(a){return"%26%23"+parseInt(a.slice(2),16)+"%3B"});let l="";for(let a=0;a<o.length;a+=Fn){const u=o.length>=Fn?o.slice(a,a+Fn):o,c=[];for(let f=0;f<u.length;++f){let h=u.charCodeAt(f);if(h===45||h===46||h===95||h===126||h>=48&&h<=57||h>=65&&h<=90||h>=97&&h<=122||i===Xu&&(h===40||h===41)){c[c.length]=u.charAt(f);continue}if(h<128){c[c.length]=Je[h];continue}if(h<2048){c[c.length]=Je[192|h>>6]+Je[128|h&63];continue}if(h<55296||h>=57344){c[c.length]=Je[224|h>>12]+Je[128|h>>6&63]+Je[128|h&63];continue}f+=1,h=65536+((h&1023)<<10|u.charCodeAt(f)&1023),c[c.length]=Je[240|h>>18]+Je[128|h>>12&63]+Je[128|h>>6&63]+Je[128|h&63]}l+=c.join("")}return l},oh=function(e){const t=[{obj:{o:e},prop:"o"}],n=[];for(let s=0;s<t.length;++s){const i=t[s],o=i.obj[i.prop],l=Object.keys(o);for(let a=0;a<l.length;++a){const u=l[a],c=o[u];typeof c=="object"&&c!==null&&n.indexOf(c)===-1&&(t.push({obj:o,prop:u}),n.push(c))}}return th(t),e},ah=function(e){return!e||typeof e!="object"?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},lh=function(e,t){return[].concat(e,t)},xn=function(e,t){if(St(e)){const n=[];for(let s=0;s<e.length;s+=1)n.push(t(e[s]));return n}return t(e)},ch={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},et=Array.isArray,uh=Array.prototype.push,Ao=function(r,e){uh.apply(r,et(e)?e:[e])},hh=Date.prototype.toISOString,Io=eh,xr={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:ih,encodeValuesOnly:!1,format:Io,formatter:Qu[Io],indices:!1,serializeDate:function(e){return hh.call(e)},skipNulls:!1,strictNullHandling:!1},fh=function(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="symbol"||typeof e=="bigint"},jn={},Co=function(e,t,n,s,i,o,l,a,u,c,f,h,d,p,g,m,y,w){let _=e,b=w,v=0,S=!1;for(;(b=b.get(jn))!==void 0&&!S;){const J=b.get(e);if(v+=1,typeof J<"u"){if(J===v)throw new RangeError("Cyclic object value");S=!0}typeof b.get(jn)>"u"&&(v=0)}if(typeof c=="function"?_=c(t,_):_ instanceof Date?_=d(_):n==="comma"&&et(_)&&(_=xn(_,function(J){return J instanceof Date?d(J):J})),_===null){if(o)return u&&!m?u(t,xr.encoder,y,"key",p):t;_=""}if(fh(_)||ah(_)){if(u){const J=m?t:u(t,xr.encoder,y,"key",p);return[g(J)+"="+g(u(_,xr.encoder,y,"value",p))]}return[g(t)+"="+g(String(_))]}const E=[];if(typeof _>"u")return E;let L;if(n==="comma"&&et(_))m&&u&&(_=xn(_,u)),L=[{value:_.length>0?_.join(",")||null:void 0}];else if(et(c))L=c;else{const J=Object.keys(_);L=f?J.sort(f):J}const x=a?t.replace(/\./g,"%2E"):t,F=s&&et(_)&&_.length===1?x+"[]":x;if(i&&et(_)&&_.length===0)return F+"[]";for(let J=0;J<L.length;++J){const me=L[J],z=typeof me=="object"&&typeof me.value<"u"?me.value:_[me];if(l&&z===null)continue;const Q=h&&a?me.replace(/\./g,"%2E"):me,U=et(_)?typeof n=="function"?n(F,Q):F:F+(h?"."+Q:"["+Q+"]");w.set(e,v);const he=new WeakMap;he.set(jn,w),Ao(E,Co(z,U,n,s,i,o,l,a,n==="comma"&&m&&et(_)?null:u,c,f,h,d,p,g,m,y,he))}return E},dh=function(e){return xr};function No(r,e){let t=r;const n=dh();let s,i;typeof n.filter=="function"?(i=n.filter,t=i("",t)):et(n.filter)&&(i=n.filter,s=i);const o=[];if(typeof t!="object"||t===null)return"";const l=ch[n.arrayFormat],a=l==="comma"&&n.commaRoundTrip;s||(s=Object.keys(t)),n.sort&&s.sort(n.sort);const u=new WeakMap;for(let h=0;h<s.length;++h){const d=s[h];n.skipNulls&&t[d]===null||Ao(o,Co(t[d],d,l,a,n.allowEmptyArrays,n.strictNullHandling,n.skipNulls,n.encodeDotInKeys,n.encode?n.encoder:null,n.filter,n.sort,n.allowDots,n.serializeDate,n.format,n.formatter,n.encodeValuesOnly,n.charset,u))}const c=o.join(n.delimiter);let f=n.addQueryPrefix===!0?"?":"";return n.charsetSentinel&&(n.charset==="iso-8859-1"?f+="utf8=%26%2310003%3B&":f+="utf8=%E2%9C%93&"),c.length>0?f+c:""}const Bn=Object.prototype.hasOwnProperty,ph=Array.isArray,jr={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:sh,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},gh=function(r){return r.replace(/&#(\d+);/g,function(e,t){return String.fromCharCode(parseInt(t,10))})},Ro=function(r,e){return r&&typeof r=="string"&&e.comma&&r.indexOf(",")>-1?r.split(","):r},mh="utf8=%26%2310003%3B",yh="utf8=%E2%9C%93",wh=function(e,t){const n={__proto__:null},s=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,i=t.parameterLimit===1/0?void 0:t.parameterLimit,o=s.split(t.delimiter,i);let l=-1,a,u=t.charset;if(t.charsetSentinel)for(a=0;a<o.length;++a)o[a].indexOf("utf8=")===0&&(o[a]===yh?u="utf-8":o[a]===mh&&(u="iso-8859-1"),l=a,a=o.length);for(a=0;a<o.length;++a){if(a===l)continue;const c=o[a],f=c.indexOf("]="),h=f===-1?c.indexOf("="):f+1;let d,p;h===-1?(d=t.decoder(c,jr.decoder,u,"key"),p=t.strictNullHandling?null:""):(d=t.decoder(c.slice(0,h),jr.decoder,u,"key"),p=xn(Ro(c.slice(h+1),t),function(m){return t.decoder(m,jr.decoder,u,"value")})),p&&t.interpretNumericEntities&&u==="iso-8859-1"&&(p=gh(p)),c.indexOf("[]=")>-1&&(p=ph(p)?[p]:p);const g=Bn.call(n,d);g&&t.duplicates==="combine"?n[d]=lh(n[d],p):(!g||t.duplicates==="last")&&(n[d]=p)}return n},bh=function(r,e,t,n){let s=n?e:Ro(e,t);for(let i=r.length-1;i>=0;--i){let o;const l=r[i];if(l==="[]"&&t.parseArrays)o=t.allowEmptyArrays&&s===""?[]:[].concat(s);else{o=t.plainObjects?Object.create(null):{};const a=l.charAt(0)==="["&&l.charAt(l.length-1)==="]"?l.slice(1,-1):l,u=t.decodeDotInKeys?a.replace(/%2E/g,"."):a,c=parseInt(u,10);!t.parseArrays&&u===""?o={0:s}:!isNaN(c)&&l!==u&&String(c)===u&&c>=0&&t.parseArrays&&c<=t.arrayLimit?(o=[],o[c]=s):u!=="__proto__"&&(o[u]=s)}s=o}return s},Sh=function(e,t,n,s){if(!e)return;const i=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,o=/(\[[^[\]]*])/,l=/(\[[^[\]]*])/g;let a=n.depth>0&&o.exec(i);const u=a?i.slice(0,a.index):i,c=[];if(u){if(!n.plainObjects&&Bn.call(Object.prototype,u)&&!n.allowPrototypes)return;c.push(u)}let f=0;for(;n.depth>0&&(a=l.exec(i))!==null&&f<n.depth;){if(f+=1,!n.plainObjects&&Bn.call(Object.prototype,a[1].slice(1,-1))&&!n.allowPrototypes)return;c.push(a[1])}return a&&c.push("["+i.slice(a.index)+"]"),bh(c,t,n,s)},_h=function(e){return jr};function Lo(r,e){const t=_h();if(r===""||r===null||typeof r>"u")return t.plainObjects?Object.create(null):{};const n=typeof r=="string"?wh(r,t):r;let s=t.plainObjects?Object.create(null):{};const i=Object.keys(n);for(let o=0;o<i.length;++o){const l=i[o],a=Sh(l,n[l],t,typeof r=="string");s=nh(s,a,t)}return t.allowSparse===!0?s:oh(s)}class Un{#e;#r;#t;#n;_logger=null;_loggerSystem=null;#s="";#o=!1;#i="";constructor(e,t,n){const s={};this.#e=ie.create({baseURL:e,headers:{...s,...n?n.headers:{}},...n&&{...n,headers:void 0}}),this.#r=t,this.#t=new _c,this.#n=new Oc}setLogger(e){this._logger=e,this.#t.setLogger(this.getLogger())}getLogger(){return this._logger===null&&(this._logger=ye.build("NullLogger"),this._logger.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!1,[I.warn]:!1,[I.error]:!0,[I.trace]:!1})),this._logger}getSystemLogger(){return this._loggerSystem===null&&(this._loggerSystem=ye.build("SystemLogger"),this._loggerSystem.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!0,[I.warn]:!0,[I.error]:!0,[I.trace]:!1})),this._loggerSystem}setRestrictionManagerParams(e){this.#t.params=e}getRestrictionManagerParams(){return this.#t.params}setLogTag(e){this.#s=e}clearLogTag(){this.#s=""}async batch(e,t=!0,n=!1){return Array.isArray(e)?this.#c(e,t,n):this.#l(e,t,n)}async#l(e,t=!0,n=!1){const s={};let i=0;const o=(l,a)=>{let u=null,c=null;l.method?(u=l.method??null,c=l?.params??null):Array.isArray(l)&&l.length>0&&(u=l[0]??null,c=l[1]??null),u&&(i++,s[a]=u+"?"+No(c))};for(const[l,a]of Object.entries(e))o(a,l);return i<1?Promise.resolve(new qe):this.call("batch",{halt:t?1:0,cmd:s}).then(l=>{const a=l.getData().result,u={},c=(p,g)=>{if(typeof a.result[g]<"u"||typeof a.result_error[g]<"u"){const m=p.split("?");u[g]=new Tr({answer:{result:C.isUndefined(a.result[g])?{}:a.result[g],error:a?.result_error[g]||void 0,total:a.result_total[g],next:a.result_next[g],time:a.result_time[g]},query:{method:m[0]||"",params:Lo(m[1]||""),start:0},status:l.getStatus()})}};for(const[p,g]of Object.entries(s))c(g,p);const f={},h=p=>p.hasError("base-error")?p.errors.get("base-error"):new Fe({code:"0",description:p.getErrorMessages().join("; "),status:0,requestInfo:{method:p.getQuery().method,params:p.getQuery().params},originalError:p.getErrors().next().value}),d=new qe;for(const p of Object.keys(u)){const g=u[p];if(g.getStatus()!==200||!g.isSuccess){const m=h(g);if(!t&&!g.isSuccess){d.addError(m,p);continue}return Promise.reject(m)}f[p]=n?g:g.getData().result}return d.setData(f),Promise.resolve(d)})}async#c(e,t=!0,n=!1){const s=[];let i=0;const o=l=>{let a=null,u=null;if(l.method?(a=l.method??null,u=l?.params??null):Array.isArray(l)&&l.length>0&&(a=l[0]??null,u=l[1]??null),a){i++;const c=a+"?"+No(u);s.push(c)}};for(const[l,a]of e.entries())o(a);return i<1?Promise.resolve(new qe):this.call("batch",{halt:t?1:0,cmd:s}).then(l=>{const a=l.getData().result,u=[],c=(p,g)=>{if(typeof a.result[g]<"u"||typeof a.result_error[g]<"u"){const m=p.split("?"),y=new Tr({answer:{result:C.isUndefined(a.result[g])?{}:a.result[g],error:a?.result_error[g]||void 0,total:a.result_total[g],next:a.result_next[g],time:a.result_time[g]},query:{method:m[0]||"",params:Lo(m[1]||""),start:0},status:l.getStatus()});u.push(y)}};for(const[p,g]of s.entries())c(g,p);const f=[],h=p=>p.hasError("base-error")?p.errors.get("base-error"):new Fe({code:"0",description:p.getErrorMessages().join("; "),status:0,requestInfo:{method:p.getQuery().method,params:p.getQuery().params},originalError:p.getErrors().next().value}),d=new qe;for(const p of u){if(p.getStatus()!==200||!p.isSuccess){const g=h(p);if(!t&&!p.isSuccess){d.addError(g);continue}return Promise.reject(g)}f.push(n?p:p.getData().result)}return d.setData(f),Promise.resolve(d)})}async call(e,t,n=0){let s=this.#r.getAuthData();return s===!1&&(s=await this.#r.refreshAuth()),await this.#t.check(),this.#o&&!this.isServerSide()&&C.isStringFilled(this.#i)&&this.getSystemLogger().warn(this.#i),this.#e.post(this.#u(e),this.#a(s,t,n)).then(i=>{const o=i.data;return Promise.resolve({status:i.status,payload:o})},async i=>{let o={error:i?.code||0,errorDescription:i?.message||""};if(i instanceof Pn&&i.response&&i.response.data&&!C.isUndefined(i.response.data.error)){const a=i.response.data;o={error:a.error,errorDescription:a.error_description}}const l=new Fe({code:String(o.error),description:o.errorDescription,status:i.response?.status||0,requestInfo:{method:e,params:t},originalError:i});return l.status===401&&["expired_token","invalid_token"].includes(l.answerError.error)?(this.getLogger().info(`refreshAuth >> ${l.answerError.error} >>>`),s=await this.#r.refreshAuth(),await this.#t.check(),this.#e.post(this.#u(e),this.#a(s,t,n)).then(async a=>{const u=a.data;return Promise.resolve({status:a.status,payload:u})},async a=>{let u={error:a?.code||0,errorDescription:a?.message||""};if(a instanceof Pn&&a.response&&a.response.data){const f=a.response.data;u={error:f.error,errorDescription:f.error_description}}const c=new Fe({code:String(u.error),description:u.errorDescription,status:i.response?.status||0,requestInfo:{method:e,params:t},originalError:a});return Promise.reject(c)})):Promise.reject(l)}).then(i=>{const o=new Tr({answer:i.payload,query:{method:e,params:t,start:n},status:i.status});return Promise.resolve(o)})}#a(e,t,n=0){const s=Object.assign({},t);return this.#s.length>0&&(s.logTag=this.#s),s.data&&s.data.start&&delete s.data.start,e.refresh_token!=="hook"&&(s.auth=e.access_token),s.start=n,s}#u(e){const t=`${encodeURIComponent(e)}.json`,n=new URLSearchParams({[this.#n.getQueryStringParameterName()]:this.#n.getRequestId(),[this.#n.getQueryStringSdkParameterName()]:"0.4.8",[this.#n.getQueryStringSdkTypeParameterName()]:"b24-js-sdk"});return`${t}?${n.toString()}`}setClientSideWarning(e,t){this.#o=e,this.#i=t}isServerSide(){return typeof window>"u"}}class _t{static batchSize=50;_isInit=!1;_http=null;_logger=null;constructor(){this._isInit=!1}get isInit(){return this._isInit}async init(){this._isInit=!0}destroy(){}setLogger(e){this._logger=e,this.getHttpClient().setLogger(this.getLogger())}getLogger(){return this._logger===null&&(this._logger=ye.build("NullLogger"),this._logger.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!1,[I.warn]:!1,[I.error]:!0,[I.trace]:!1})),this._logger}callMethod(e,t,n){return this.getHttpClient().call(e,t||{},n||0)}async callListMethod(e,t={},n=null,s=null){const i=new qe;return C.isFunction(n)&&n!==null&&n(0),this.callMethod(e,t,0).then(async o=>{let l=[],a;if(s===null?a=o.getData().result:a=o.getData().result[s],l=[...l,...a],o.isMore()){let u=o;for(;u=await u.getNext(this.getHttpClient()),u!==!1;){let c;if(s===null?c=u.getData().result:c=u.getData().result[s],l=[...l,...c],n){const f=u.getTotal();n(f>0?Math.round(100*l.length/f):100)}}}return i.setData(l),n&&n(100),i})}async*fetchListMethod(e,t={},n="ID",s=null){t.order=t.order||{},t.filter=t.filter||{},t.start=-1;const i=`>${n}`;t.order[n]="ASC",t.filter[i]=0;do{const o=await this.callMethod(e,t,t.start);let l;if(!C.isNull(s)&&s!==null?l=o.getData().result[s]:l=o.getData().result,l.length===0||(yield l,l.length<_t.batchSize))break;const a=l.at(-1);a&&n in a&&(t.filter[i]=a[n])}while(!0)}async callBatch(e,t=!0,n=!1){return this.getHttpClient().batch(e,t,n)}chunkArray(e,t=50){const n=[];for(let s=0;s<e.length;s+=t){const i=e.slice(s,s+t);n.push(i)}return n}async callBatchByChunk(e,t=!0){const n=new qe,s=[],i=this.chunkArray(e,_t.batchSize);for(const o of i){const l=await this.callBatch(o,t);s.push(...l.getData())}return n.setData(s)}getHttpClient(){if(!this.isInit||this._http===null)throw new Error("Http not init");return this._http}_getHttpOptions(){return null}_ensureInitialized(){if(!this._isInit)throw new Error("B24 not initialized")}}var $n=(r=>(r.en="en",r.de="de",r.la="la",r.br="br",r.fr="fr",r.it="it",r.pl="pl",r.ru="ru",r.ua="ua",r.tr="tr",r.sc="sc",r.tc="tc",r.ja="ja",r.vn="vn",r.id="id",r.ms="ms",r.th="th",r.ar="ar",r))($n||{});const kh={en:"en-EN",de:"de-DE",la:"es-ES",br:"pt-BR",fr:"fr-FR",it:"it-IT",pl:"pl-PL",ru:"ru-RU",ua:"uk-UA",tr:"tr-TR",sc:"zh-CN",tc:"zh-TW",ja:"ja-JP",vn:"vi-VN",id:"id-ID",ms:"ms-MY",th:"th-TH",ar:"ar-SA"},vh=()=>({scrollWidth:Math.max(document.documentElement.scrollWidth,document.documentElement.offsetWidth),scrollHeight:Math.max(document.documentElement.scrollHeight,document.documentElement.offsetHeight)});let Eh=class ht{static isInternalConstructing=!1;static instance=null;_defLocale=null;constructor(){if(!ht.isInternalConstructing)throw new TypeError("FormatterNumber is not constructable");ht.isInternalConstructing=!1}static getInstance(){return ht.instance||(ht.isInternalConstructing=!0,ht.instance=new ht),ht.instance}setDefLocale(e){this._defLocale=e}format(e,t){let n;(typeof t>"u"||!C.isStringFilled(t))&&(t=C.isStringFilled(this._defLocale)?this._defLocale||"en":typeof navigator>"u"?"en":navigator?.language||"en"),Number.isInteger(e)?n=new Intl.NumberFormat(t,{minimumFractionDigits:0,maximumFractionDigits:0}):n=new Intl.NumberFormat(t,{minimumFractionDigits:2,maximumFractionDigits:2});let s=n.format(e);return t.includes("ru")&&(s=s.replace(",",".")),s}};class T{countryCode;length;structure;example;_cachedRegex=null;constructor(e,t,n,s){this.countryCode=e,this.length=t,this.structure=n,this.example=s}isValid(e){return this.length===e.length&&this.countryCode===e.slice(0,2)&&this._regex().test(e.slice(4))&&this._iso7064Mod9710(this._iso13616Prepare(e))==1}toBBAN(e,t){return(this._regex().exec(e.slice(4)||"")||[]).slice(1).join(t)}fromBBAN(e){if(!this.isValidBBAN(e))throw new Error("Invalid BBAN");const t=("0"+(98-this._iso7064Mod9710(this._iso13616Prepare(this.countryCode+"00"+e)))).slice(-2);return this.countryCode+t+e}isValidBBAN(e){return this.length-4===e.length&&this._regex().test(e)}_regex(){return this._cachedRegex===null&&(this._cachedRegex=this._parseStructure(this.structure)),this._cachedRegex}_parseStructure(e){const t=(e.match(/(.{3})/g)||[]).map(n=>{let s;const i=n.slice(0,1),o=Number.parseInt(n.slice(1),10);switch(i){case"A":s="0-9A-Za-z";break;case"B":s="0-9A-Z";break;case"C":s="A-Za-z";break;case"F":s="0-9";break;case"L":s="a-z";break;case"U":s="A-Z";break;case"W":s="0-9a-z";break}return"(["+s+"]{"+o+"})"});return new RegExp("^"+t.join("")+"$")}_iso13616Prepare(e){return e=e.toUpperCase(),e=e.substring(4)+e.substring(0,4),e.split("").map(t=>{const n=t.charCodeAt(0);return n>=65&&n<=90?(n-65+10).toString():t}).join("")}_iso7064Mod9710(e){let t=e,n;for(;t.length>2;)n=t.slice(0,9),t=Number.parseInt(n,10)%97+t.slice(n.length);return Number.parseInt(t,10)%97}}class tt{static isInternalConstructing=!1;static instance=null;_countries;constructor(){if(!tt.isInternalConstructing)throw new TypeError("FormatterIban is not constructable");tt.isInternalConstructing=!1,this._countries=new Map}static getInstance(){return tt.instance||(tt.isInternalConstructing=!0,tt.instance=new tt),tt.instance}addSpecification(e){this._countries.set(e.countryCode,e)}isValid(e){if(!C.isString(e))return!1;e=this.electronicFormat(e);const t=e.slice(0,2);if(!this._countries.has(t))throw new Error(`No country with code ${t}`);const n=this._countries.get(t);return!!n&&n.isValid(e)}printFormat(e,t){typeof t>"u"&&(t=" ");const n=/(.{4})(?!$)/g;return this.electronicFormat(e).replace(n,"$1"+t)}electronicFormat(e){const t=/[^a-zA-Z0-9]/g;return e.replace(t,"").toUpperCase()}toBBAN(e,t){typeof t>"u"&&(t=" "),e=this.electronicFormat(e);const n=e.slice(0,2);if(!this._countries.has(n))throw new Error(`No country with code ${n}`);const s=this._countries.get(n);if(!s)throw new Error(`No country with code ${n}`);return s.toBBAN(e,t)}fromBBAN(e,t){if(!this._countries.has(e))throw new Error(`No country with code ${e}`);const n=this._countries.get(e);if(!n)throw new Error(`No country with code ${e}`);return n.fromBBAN(this.electronicFormat(t))}isValidBBAN(e,t){if(!C.isString(t))return!1;if(!this._countries.has(e))throw new Error(`No country with code ${e}`);const n=this._countries.get(e);return!!n&&n.isValidBBAN(this.electronicFormat(t))}}const Th=()=>{const r=Eh.getInstance(),e=tt.getInstance();return e.addSpecification(new T("AD",24,"F04F04A12","AD1200012030200359100100")),e.addSpecification(new T("AE",23,"F03F16","AE070331234567890123456")),e.addSpecification(new T("AL",28,"F08A16","AL47212110090000000235698741")),e.addSpecification(new T("AT",20,"F05F11","AT611904300234573201")),e.addSpecification(new T("AZ",28,"U04A20","AZ21NABZ00000000137010001944")),e.addSpecification(new T("BA",20,"F03F03F08F02","BA391290079401028494")),e.addSpecification(new T("BE",16,"F03F07F02","BE68539007547034")),e.addSpecification(new T("BG",22,"U04F04F02A08","BG80BNBG96611020345678")),e.addSpecification(new T("BH",22,"U04A14","BH67BMAG00001299123456")),e.addSpecification(new T("BR",29,"F08F05F10U01A01","BR9700360305000010009795493P1")),e.addSpecification(new T("BY",28,"A04F04A16","BY13NBRB3600900000002Z00AB00")),e.addSpecification(new T("CH",21,"F05A12","CH9300762011623852957")),e.addSpecification(new T("CR",22,"F04F14","CR72012300000171549015")),e.addSpecification(new T("CY",28,"F03F05A16","CY17002001280000001200527600")),e.addSpecification(new T("CZ",24,"F04F06F10","CZ6508000000192000145399")),e.addSpecification(new T("DE",22,"F08F10","DE89370400440532013000")),e.addSpecification(new T("DK",18,"F04F09F01","DK5000400440116243")),e.addSpecification(new T("DO",28,"U04F20","DO28BAGR00000001212453611324")),e.addSpecification(new T("EE",20,"F02F02F11F01","EE382200221020145685")),e.addSpecification(new T("EG",29,"F04F04F17","EG800002000156789012345180002")),e.addSpecification(new T("ES",24,"F04F04F01F01F10","ES9121000418450200051332")),e.addSpecification(new T("FI",18,"F06F07F01","FI2112345600000785")),e.addSpecification(new T("FO",18,"F04F09F01","FO6264600001631634")),e.addSpecification(new T("FR",27,"F05F05A11F02","FR1420041010050500013M02606")),e.addSpecification(new T("GB",22,"U04F06F08","GB29NWBK60161331926819")),e.addSpecification(new T("GE",22,"U02F16","GE29NB0000000101904917")),e.addSpecification(new T("GI",23,"U04A15","GI75NWBK000000007099453")),e.addSpecification(new T("GL",18,"F04F09F01","GL8964710001000206")),e.addSpecification(new T("GR",27,"F03F04A16","GR1601101250000000012300695")),e.addSpecification(new T("GT",28,"A04A20","GT82TRAJ01020000001210029690")),e.addSpecification(new T("HR",21,"F07F10","HR1210010051863000160")),e.addSpecification(new T("HU",28,"F03F04F01F15F01","HU42117730161111101800000000")),e.addSpecification(new T("IE",22,"U04F06F08","IE29AIBK93115212345678")),e.addSpecification(new T("IL",23,"F03F03F13","IL620108000000099999999")),e.addSpecification(new T("IS",26,"F04F02F06F10","IS140159260076545510730339")),e.addSpecification(new T("IT",27,"U01F05F05A12","IT60X0542811101000000123456")),e.addSpecification(new T("IQ",23,"U04F03A12","IQ98NBIQ850123456789012")),e.addSpecification(new T("JO",30,"A04F22","JO15AAAA1234567890123456789012")),e.addSpecification(new T("KW",30,"U04A22","KW81CBKU0000000000001234560101")),e.addSpecification(new T("KZ",20,"F03A13","KZ86125KZT5004100100")),e.addSpecification(new T("LB",28,"F04A20","LB62099900000001001901229114")),e.addSpecification(new T("LC",32,"U04F24","LC07HEMM000100010012001200013015")),e.addSpecification(new T("LI",21,"F05A12","LI21088100002324013AA")),e.addSpecification(new T("LT",20,"F05F11","LT121000011101001000")),e.addSpecification(new T("LU",20,"F03A13","LU280019400644750000")),e.addSpecification(new T("LV",21,"U04A13","LV80BANK0000435195001")),e.addSpecification(new T("MC",27,"F05F05A11F02","MC5811222000010123456789030")),e.addSpecification(new T("MD",24,"U02A18","MD24AG000225100013104168")),e.addSpecification(new T("ME",22,"F03F13F02","ME25505000012345678951")),e.addSpecification(new T("MK",19,"F03A10F02","MK07250120000058984")),e.addSpecification(new T("MR",27,"F05F05F11F02","MR1300020001010000123456753")),e.addSpecification(new T("MT",31,"U04F05A18","MT84MALT011000012345MTLCAST001S")),e.addSpecification(new T("MU",30,"U04F02F02F12F03U03","MU17BOMM0101101030300200000MUR")),e.addSpecification(new T("NL",18,"U04F10","NL91ABNA0417164300")),e.addSpecification(new T("NO",15,"F04F06F01","NO9386011117947")),e.addSpecification(new T("PK",24,"U04A16","PK36SCBL0000001123456702")),e.addSpecification(new T("PL",28,"F08F16","PL61109010140000071219812874")),e.addSpecification(new T("PS",29,"U04A21","PS92PALS000000000400123456702")),e.addSpecification(new T("PT",25,"F04F04F11F02","PT50000201231234567890154")),e.addSpecification(new T("QA",29,"U04A21","QA30AAAA123456789012345678901")),e.addSpecification(new T("RO",24,"U04A16","RO49AAAA1B31007593840000")),e.addSpecification(new T("RS",22,"F03F13F02","RS35260005601001611379")),e.addSpecification(new T("SA",24,"F02A18","SA0380000000608010167519")),e.addSpecification(new T("SC",31,"U04F04F16U03","SC18SSCB11010000000000001497USD")),e.addSpecification(new T("SE",24,"F03F16F01","SE4550000000058398257466")),e.addSpecification(new T("SI",19,"F05F08F02","SI56263300012039086")),e.addSpecification(new T("SK",24,"F04F06F10","SK3112000000198742637541")),e.addSpecification(new T("SM",27,"U01F05F05A12","SM86U0322509800000000270100")),e.addSpecification(new T("ST",25,"F08F11F02","ST68000100010051845310112")),e.addSpecification(new T("SV",28,"U04F20","SV62CENR00000000000000700025")),e.addSpecification(new T("TL",23,"F03F14F02","TL380080012345678910157")),e.addSpecification(new T("TN",24,"F02F03F13F02","TN5910006035183598478831")),e.addSpecification(new T("TR",26,"F05F01A16","TR330006100519786457841326")),e.addSpecification(new T("UA",29,"F25","UA511234567890123456789012345")),e.addSpecification(new T("VA",22,"F18","VA59001123000012345678")),e.addSpecification(new T("VG",24,"U04F16","VG96VPVG0000012345678901")),e.addSpecification(new T("XK",20,"F04F10F02","XK051212012345678906")),e.addSpecification(new T("AO",25,"F21","AO69123456789012345678901")),e.addSpecification(new T("BF",27,"F23","BF2312345678901234567890123")),e.addSpecification(new T("BI",16,"F12","BI41123456789012")),e.addSpecification(new T("BJ",28,"F24","BJ39123456789012345678901234")),e.addSpecification(new T("CI",28,"U02F22","CI70CI1234567890123456789012")),e.addSpecification(new T("CM",27,"F23","CM9012345678901234567890123")),e.addSpecification(new T("CV",25,"F21","CV30123456789012345678901")),e.addSpecification(new T("DZ",24,"F20","DZ8612345678901234567890")),e.addSpecification(new T("IR",26,"F22","IR861234568790123456789012")),e.addSpecification(new T("MG",27,"F23","MG1812345678901234567890123")),e.addSpecification(new T("ML",28,"U01F23","ML15A12345678901234567890123")),e.addSpecification(new T("MZ",25,"F21","MZ25123456789012345678901")),e.addSpecification(new T("SN",28,"U01F23","SN52A12345678901234567890123")),e.addSpecification(new T("GF",27,"F05F05A11F02","GF121234512345123456789AB13")),e.addSpecification(new T("GP",27,"F05F05A11F02","GP791234512345123456789AB13")),e.addSpecification(new T("MQ",27,"F05F05A11F02","MQ221234512345123456789AB13")),e.addSpecification(new T("RE",27,"F05F05A11F02","RE131234512345123456789AB13")),e.addSpecification(new T("PF",27,"F05F05A11F02","PF281234512345123456789AB13")),e.addSpecification(new T("TF",27,"F05F05A11F02","TF891234512345123456789AB13")),e.addSpecification(new T("YT",27,"F05F05A11F02","YT021234512345123456789AB13")),e.addSpecification(new T("NC",27,"F05F05A11F02","NC551234512345123456789AB13")),e.addSpecification(new T("BL",27,"F05F05A11F02","BL391234512345123456789AB13")),e.addSpecification(new T("MF",27,"F05F05A11F02","MF551234512345123456789AB13")),e.addSpecification(new T("PM",27,"F05F05A11F02","PM071234512345123456789AB13")),e.addSpecification(new T("WF",27,"F05F05A11F02","WF621234512345123456789AB13")),{formatterNumber:r,formatterIban:e}};class Do{#e;#r;#t;#n;constructor(e){this.#e=Object.freeze(Object.assign({},e)),this.#r=this.#e.b24Url.replaceAll("https://","").replaceAll("http://","").replace(/:(80|443)$/,""),this.#t=`https://${this.#r}/rest`,this.#n=`https://${this.#r}`}getAuthData(){return{access_token:this.#e.secret,refresh_token:"hook",expires_in:0,domain:this.#r,member_id:this.#r}}refreshAuth(){return Promise.resolve(this.getAuthData())}getUniq(e){const t=this.getAuthData();if(t===!1)throw new Error("AuthData not init");return[e,t.member_id].join("_")}getTargetOrigin(){return`${this.#n}`}getTargetOriginWithPath(){return`${this.#t}/${this.#e.userId}/${this.#e.secret}`}get isAdmin(){return!0}}class Wn extends _t{#e;constructor(e){super(),this.#e=new Do(e),this._http=new Un(this.#e.getTargetOriginWithPath(),this.#e,this._getHttpOptions()),this._http.setClientSideWarning(!0,"It is not safe to use hook requests on the client side"),this._isInit=!0}setLogger(e){super.setLogger(e)}get auth(){return this.#e}offClientSideWarning(){this.getHttpClient().setClientSideWarning(!1,"")}getTargetOrigin(){return this._ensureInitialized(),this.#e.getTargetOrigin()}getTargetOriginWithPath(){return this._ensureInitialized(),this.#e.getTargetOriginWithPath()}static fromWebhookUrl(e){if(!e.trim())throw new Error("Webhook URL cannot be empty");let t;try{t=new URL(e)}catch{throw new Error(`Invalid webhook URL format: ${e}`)}if(t.protocol!=="https:")throw new Error("Webhook requires HTTPS protocol");const n=t.pathname.split("/").filter(Boolean);if(n.length<3||n[0]!=="rest")throw new Error("Webhook URL must follow format: /rest/<userId>/<secret>");const s=n[1],i=n[2];if(!/^\d+$/.test(s))throw new Error(`User ID must be numeric in webhook URL, received: ${s}`);const o=Number.parseInt(s,10);return new Wn({b24Url:t.origin,userId:o,secret:i})}}var X=(r=>(r.getInitData="getInitData",r.setInstallFinish="setInstallFinish",r.setInstall="setInstall",r.refreshAuth="refreshAuth",r.setAppOption="setAppOption",r.setUserOption="setUserOption",r.resizeWindow="resizeWindow",r.reloadWindow="reloadWindow",r.setTitle="setTitle",r.setScroll="setScroll",r.openApplication="openApplication",r.closeApplication="closeApplication",r.openPath="openPath",r.imCallTo="imCallTo",r.imPhoneTo="imPhoneTo",r.imOpenMessenger="imOpenMessenger",r.imOpenHistory="imOpenHistory",r.selectUser="selectUser",r.selectAccess="selectAccess",r.selectCRM="selectCRM",r.showAppForm="showAppForm",r.getInterface="getInterface",r.placementBindEvent="placementBindEvent",r))(X||{});class Po{#e;#r;#t;_logger=null;runCallbackHandler;constructor(e){this.#e=e,this.#r=new Map,this.#t=new Map,this.runCallbackHandler=this._runCallback.bind(this)}setLogger(e){this._logger=e}getLogger(){return this._logger===null&&(this._logger=ye.build("NullLogger"),this._logger.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!1,[I.warn]:!1,[I.error]:!0,[I.trace]:!1})),this._logger}subscribe(){window.addEventListener("message",this.runCallbackHandler)}unsubscribe(){window.removeEventListener("message",this.runCallbackHandler)}async send(e,t=null){return new Promise((n,s)=>{let i;const o={resolve:n,reject:s,timeoutId:null},l=this.#n(o);let a=null;const u=Xn(t||{},["singleOption","callBack","isSafely","safelyTime"]),{callBack:c,singleOption:f}=t||{};if(c&&this.#t.set(l,c),f?a=f:Object.keys(u).length>0&&(a={...u}),e.toString().includes(":"))i={method:e.toString(),params:a||"",callback:l,appSid:this.#e.getAppSid()};else{i=e.toString(),t?.isRawValue!==!0&&a&&(a=JSON.stringify(a));const h=[a||"",l,this.#e.getAppSid()];i+=":"+h.filter(Boolean).join(":")}this.getLogger().log(`send to ${this.#e.getTargetOrigin()}`,{cmd:i}),parent.postMessage(i,this.#e.getTargetOrigin()),t?.isSafely&&(this.#r.get(l).timeoutId=window.setTimeout(()=>{this.#r.has(l)&&(this.getLogger().warn(`Action ${e.toString()} stop by timeout`),this.#r.delete(l),n({isSafely:!0}))},Number.parseInt(String(t?.safelyTime||900))))})}_runCallback(e){if(e.origin===this.#e.getTargetOrigin()&&e.data){this.getLogger().log(`get from ${e.origin}`,{data:e.data});const t=e.data.split(":"),n={id:t[0],args:t.slice(1).join(":")};if(n.args&&(n.args=JSON.parse(n.args)),this.#r.has(n.id)){const s=this.#r.get(n.id);s.timeoutId&&clearTimeout(s.timeoutId),this.#r.delete(n.id),s.resolve(n.args)}else if(this.#t.has(n.id)){const s=this.#t.get(n.id);s&&s.apply(globalThis,[n.args])}}}#n(e){const t=W.getUniqId();return this.#r.set(t,e),t}}class Mo{#e="";#r=!0;#t=null;#n=null;#s=null;constructor(e){e.DOMAIN&&(this.#e=e.DOMAIN,this.#e=this.#e.replace(/:(80|443)$/,"")),this.#r=e.PROTOCOL===!0,e.LANG&&(this.#s=e.LANG),e.APP_SID&&(this.#t=e.APP_SID)}initData(e){return this.#e||(this.#e=e.DOMAIN),this.#n||(this.#n=e.PATH),this.#s||(this.#s=e.LANG),this.#r=Number.parseInt(e.PROTOCOL)===1,this.#e=this.#e.replace(/:(80|443)$/,""),this}getAppSid(){if(this.#t===null)throw new Error("Not init appSid");return this.#t}getTargetOrigin(){return`${this.#r?"https":"http"}://${this.#e}`}getTargetOriginWithPath(){return this.getTargetOrigin()+(this.#n??"")}getLang(){return this.#s||$n.en}}class Fo{#e=null;#r=null;#t=0;#n=null;#s=!1;#o;#i;constructor(e,t){this.#o=e,this.#i=t}initData(e){return e.AUTH_ID&&(this.#e=e.AUTH_ID,this.#r=e.REFRESH_ID,this.#t=Date.now()+Number.parseInt(e.AUTH_EXPIRES)*1e3,this.#s=e.IS_ADMIN,this.#n=e.MEMBER_ID||""),this}getAuthData(){return this.#t>Date.now()?{access_token:this.#e,refresh_token:this.#r,expires_in:this.#t,domain:this.#o.getTargetOrigin(),member_id:this.#n}:!1}async refreshAuth(){return this.#i.send(X.refreshAuth,{}).then(e=>(this.#e=e.AUTH_ID,this.#r=e.REFRESH_ID,this.#t=Date.now()+Number.parseInt(e.AUTH_EXPIRES)*1e3,Promise.resolve(this.getAuthData())))}getUniq(e){return[e,this.#n||""].join("_")}get isAdmin(){return this.#s}}class xo{#e;constructor(e){this.#e=e}async closeApplication(){return this.#e.send(X.closeApplication,{isSafely:!1})}async fitWindow(){const e="100%",t=this.getScrollSize().scrollHeight;return this.#e.send(X.resizeWindow,{width:e,height:t,isSafely:!0})}async resizeWindow(e,t){return e>0&&t>0?this.#e.send(X.resizeWindow,{width:e,height:t,isSafely:!0}):Promise.reject(new Error(`Wrong width:number = ${e} or height:number = ${t}`))}async resizeWindowAuto(e=null,t=0,n=0){const s=document.body;let i=Math.max(s.scrollWidth,s.offsetWidth);n>0&&(i=Math.max(n,i));let o=Math.max(s.scrollHeight,s.offsetHeight);return e&&(o=Math.max(e.scrollHeight,e.offsetHeight)),t>0&&(o=Math.max(t,o)),this.resizeWindow(i,o)}getScrollSize(){return vh()}async scrollParentWindow(e){return Number.isInteger(e)?(e<0&&(e=0),this.#e.send(X.setScroll,{scroll:e,isSafely:!0})):Promise.reject(new Error("Wrong scroll number"))}async reloadWindow(){return this.#e.send(X.reloadWindow,{isSafely:!0})}async setTitle(e){return this.#e.send(X.setTitle,{title:e.toString(),isSafely:!0})}async imCallTo(e,t=!0){return this.#e.send(X.imCallTo,{userId:e,video:t,isSafely:!0})}async imPhoneTo(e){return this.#e.send(X.imPhoneTo,{phone:e,isSafely:!0})}async imOpenMessenger(e){return this.#e.send(X.imOpenMessenger,{dialogId:e,isSafely:!0})}async imOpenHistory(e){return this.#e.send(X.imOpenHistory,{dialogId:e,isSafely:!0})}}let jo=class{#e;#r=null;#t=null;constructor(e){this.#e=e}initData(e){return e.APP_OPTIONS&&(this.#r=e.APP_OPTIONS),e.USER_OPTIONS&&(this.#t=e.USER_OPTIONS),this}appGet(e){if(this.#r&&this.#r[e])return this.#r[e];throw new Error(`app.option.${e} not set`)}async appSet(e,t){return this.#r||(this.#r=[]),this.#r[e]=t,this.#n(X.setAppOption,e,this.#r[e])}userGet(e){if(this.#t&&this.#t[e])return this.#t[e];throw new Error(`user.option.${e} not set`)}async userSet(e,t){return this.#r||(this.#r=[]),this.#r[e]||(this.#r[e]=null),this.#t[e]=t,this.#n(X.setUserOption,e,this.#t[e])}async#n(e,t,n){return this.#e.send(e,{name:t,value:n,isSafely:!0}).then(()=>Promise.resolve())}};class Bo{#e;constructor(e){this.#e=e}async selectUser(){return this.#e.send(X.selectUser,{mult:!1})}async selectUsers(){return this.#e.send(X.selectUser,{mult:!0})}async selectAccess(e=[]){return console.warn("@deprecated selectAccess"),this.#e.send(X.selectAccess,{value:e})}async selectCRM(e){return console.warn("@deprecated selectCRM"),this.#e.send(X.selectCRM,{entityType:e?.entityType,multiple:e?.multiple,value:e?.value})}}class Uo{#e;#r;constructor(e,t){this.#e=e,this.#r=t}getUrl(e="/"){return new URL(e,this.#e.getTargetOrigin())}getTargetOrigin(){return this.#e.getTargetOrigin()}async openSliderAppPage(e={}){return this.#r.send(X.openApplication,e)}async closeSliderAppPage(){return this.#r.send(X.closeApplication,{isSafely:!1})}#t(e=1640){return e>0?e>1200&&e<=1640?"/crm/type/0/details/0/../../../../..":e>950&&e<=1200?"/company/personal/user/0/groups/create/../../../../../..":e>900&&e<=950?"/crm/company/requisite/0/../../../..":e<=900?"/workgroups/group/0/card/../../../..":"/crm/deal/../..":"/crm/deal/../.."}async openPath(e,t=1640){const n=new URL(e);return n.searchParams.set("IFRAME","Y"),n.searchParams.set("IFRAME_TYPE","SIDE_SLIDER"),this.#r.send(X.openPath,{path:[this.#t(t),n.pathname,n.search].join("")}).then(s=>s?.result==="error"?s?.errorCode==="METHOD_NOT_SUPPORTED_ON_DEVICE"?new Promise((i,o)=>{const l=window.open(e,"_blank");if(!l){o(new Error("Error open window"));return}let a=0;const u=1e3*60*5,c=window.setInterval(()=>{a=a+1,l.closed?(clearInterval(c),i({isOpenAtNewWindow:!0,isClose:!0})):a>u&&(clearInterval(c),i({isOpenAtNewWindow:!0,isClose:!1}))},1e3)}):Promise.reject(new Error(s?.errorCode)):s?.result==="close"?Promise.resolve({isOpenAtNewWindow:!1,isClose:!0}):Promise.resolve({isOpenAtNewWindow:!1,isClose:!1}))}async showAppForm(e){return console.warn("@deprecated showAppForm"),this.#r.send(X.showAppForm,{params:e,isSafely:!0})}}class $o{#e;#r="";#t={};constructor(e){this.#e=e}initData(e){this.#r=e.PLACEMENT||"DEFAULT";const t=e.PLACEMENT_OPTIONS;return this.#t=Object.freeze(t),this}get title(){return this.#r}get isDefault(){return this.title==="DEFAULT"}get options(){return this.#t}get isSliderMode(){return this.options?.IFRAME==="Y"}async getInterface(){return this.#e.send(X.getInterface,{isSafely:!0})}async bindEvent(e,t){return this.#e.send(X.placementBindEvent,{event:e,callBack:t,isSafely:!0})}async call(e,t={}){return this.#e.send(e,{...t,isSafely:!0,isRawValue:["setValue"].includes(e)})}async callCustomBind(e,t=null,n){let s={};return C.isString(t)?s.singleOption=t:C.isObjectLike(t)&&(s={...t}),this.#e.send(e,{...s,callBack:n,isSafely:!0})}}class Wo extends _t{#e=!1;#r=!1;#t;#n;#s;#o;#i;#l;#c;#a;constructor(e){super(),this.#t=new Mo(e),this.#n=new Po(this.#t),this.#n.subscribe(),this.#s=new Fo(this.#t,this.#n),this.#o=new xo(this.#n),this.#i=new jo(this.#n),this.#l=new Bo(this.#n),this.#c=new Uo(this.#t,this.#n),this.#a=new $o(this.#n),this._isInit=!1}setLogger(e){super.setLogger(e),this.#n.setLogger(this.getLogger())}get isFirstRun(){return this._ensureInitialized(),this.#r}get isInstallMode(){return this._ensureInitialized(),this.#e}get parent(){return this._ensureInitialized(),this.#o}get auth(){return this._ensureInitialized(),this.#s}get slider(){return this._ensureInitialized(),this.#c}get placement(){return this._ensureInitialized(),this.#a}get options(){return this._ensureInitialized(),this.#i}get dialog(){return this._ensureInitialized(),this.#l}async init(){return this.#n.send(X.getInitData,{}).then(e=>(this.getLogger().log("init data:",e),this.#t.initData(e),this.#s.initData(e),this.#a.initData(e),this.#i.initData(e),this.#e=e.INSTALL,this.#r=e.FIRST_RUN,this._http=new Un(this.#t.getTargetOriginWithPath(),this.#s,this._getHttpOptions()),this._isInit=!0,this.#r?this.#n.send(X.setInstall,{install:!0}):Promise.resolve()))}destroy(){this.#n.unsubscribe(),super.destroy()}async installFinish(){return this.isInstallMode?this.#n.send(X.setInstallFinish,{}):Promise.reject(new Error("Application was previously installed. You cannot call installFinish"))}getTargetOrigin(){return this._ensureInitialized(),this.#t.getTargetOrigin()}getTargetOriginWithPath(){return this._ensureInitialized(),this.#t.getTargetOriginWithPath()}getAppSid(){return this._ensureInitialized(),this.#t.getAppSid()}getLang(){return this._ensureInitialized(),this.#t.getLang()}}class Oh extends Fe{}class qo{#e;#r=null;#t;#n;#s=0;#o;#i;#l;#c;#a=null;constructor(e,t){this.#t=Object.assign({},e),this.#n=Object.freeze(Object.assign({},t)),this.#o=this.#t.domain.replaceAll("https://","").replaceAll("http://","").replace(/:(80|443)$/,""),this.#i=this.#t.clientEndpoint,this.#l=this.#i.replace("/rest/",""),this.#c=this.#t.serverEndpoint.replace("/rest/",""),this.#s=this.#t.expires*1e3,this.#e=ie.create({baseURL:this.#c,headers:{"Content-Type":"application/json"}})}getAuthData(){return this.#s>Date.now()?{access_token:this.#t.accessToken,refresh_token:this.#t.refreshToken,expires_in:this.#t.expiresIn,domain:this.#o,member_id:this.#t.memberId}:!1}async refreshAuth(){try{const e=await this.#e.get("/oauth/token/",{params:{grant_type:"refresh_token",client_id:this.#n.clientId,client_secret:this.#n.clientSecret,refresh_token:this.#t.refreshToken}});if(e.data.error)throw new Error(`Token update error: ${e.data.error}`);if(e.status!==200)throw new Error(`Token update error status code: ${e.status}`);const t=e.data;this.#t.accessToken=t.access_token,this.#t.refreshToken=t.refresh_token,this.#t.expires=Number.parseInt(t.expires||"0"),this.#t.expiresIn=Number.parseInt(t.expires_in||"3600"),this.#t.clientEndpoint=t.client_endpoint,this.#t.serverEndpoint=t.server_endpoint,this.#t.scope=t.scope,this.#t.status=Object.values(Qe).find(s=>s===t.status)||Qe.Free,this.#s=this.#t.expires*1e3;const n=this.getAuthData();return this.#r&&await this.#r({authData:n,b24OAuthParams:this.#t}),n}catch(e){if(e instanceof Pn){let t={error:e?.code||0,errorDescription:e?.message||""};if(e.response&&e.response.data&&!C.isUndefined(e.response.data.error)){const n=e.response.data;t={error:n.error,errorDescription:n.error_description}}throw new Oh({code:String(t.error),description:t.errorDescription,status:e.response?.status||0,requestInfo:{method:"/oauth/token/"}})}else if(e instanceof Error)throw e;throw new Error(`Strange error: ${e instanceof Error?e.message:e}`,{cause:e})}}setCallbackRefreshAuth(e){this.#r=e}removeCallbackRefreshAuth(){this.#r=null}getUniq(e){return[e,this.#t.memberId||""].join("_")}getTargetOrigin(){return`${this.#l}`}getTargetOriginWithPath(){return`${this.#i}`}get isAdmin(){if(this.#a===null)throw new Error("isAdmin not init. You need call B24OAuth::initIsAdmin().");return this.#a}async initIsAdmin(e){const t=await e.call("profile",{},0);if(!t.isSuccess)throw new Error(t.getErrorMessages().join(";"));t.getData().result?.ADMIN&&(this.#a=!0)}}class Ah extends _t{#e;constructor(e,t){super(),this.#e=new qo(e,t),this._http=new Un(this.#e.getTargetOriginWithPath(),this.#e,this._getHttpOptions()),this._http.setClientSideWarning(!0,"It is not safe to use oauth requests on the client side"),this._isInit=!0}setLogger(e){super.setLogger(e)}async initIsAdmin(){return this._ensureInitialized(),this.#e.initIsAdmin(this._http)}setCallbackRefreshAuth(e){this._ensureInitialized(),this.#e.setCallbackRefreshAuth(e)}removeCallbackRefreshAuth(){this._ensureInitialized(),this.#e.removeCallbackRefreshAuth()}offClientSideWarning(){this.getHttpClient().setClientSideWarning(!1,"")}get auth(){return this.#e}getTargetOrigin(){return this._ensureInitialized(),this.#e.getTargetOrigin()}getTargetOriginWithPath(){return this._ensureInitialized(),this.#e.getTargetOriginWithPath()}}class qn extends Error{constructor(e,...t){super(...t),this.name="UnhandledMatchError",this.message=`Unhandled match value of type ${e}`,this.stack=new Error("for stack").stack}}class xt{_b24;_logger=null;_data=null;constructor(e){this._b24=e}setLogger(e){this._logger=e}getLogger(){return this._logger===null&&(this._logger=ye.build("NullLogger"),this._logger.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!1,[I.warn]:!1,[I.error]:!0,[I.trace]:!1})),this._logger}async initData(e){return this.getLogger().log(e),Promise.reject(new Error("Rewrite this function"))}}class Ih extends xt{_data=null;async initData(e){this._data=e}get data(){if(this._data===null)throw new Error("ProfileManager.data not initialized");return this._data}}class Ch extends xt{_data=null;async initData(e){this._data=e}get data(){if(this._data===null)throw new Error("AppManager.data not initialized");return this._data}get statusCode(){return $i[this.data.status]||"Unknown status"}}class Nh extends xt{_data=null;async initData(e){this._data=e}get data(){if(this._data===null)throw new Error("PaymentManager.data not initialized");return this._data}}class Rh extends xt{_data=null;async initData(e){this._data=e,this.makeRestrictionManagerParams()}get data(){if(this._data===null)throw new Error("LicenseManager.data not initialized");return this._data}makeRestrictionManagerParams(){this.data?.license&&this.data.license.includes("ent")&&(this.getLogger().log(`LICENSE ${this.data.license} => up restriction manager params`,yn),this._b24.getHttpClient().setRestrictionManagerParams(yn))}}class Lh extends xt{async initData(e){this._data={currencyBase:"?",currencyList:new Map},this.setBaseCurrency(e.currencyBase),this.setCurrencyList(e.currencyList);try{await this.loadData()}catch(t){throw t instanceof Error?t:(console.error(t),new Error("Failed to load data"))}}async loadData(){const e=this.currencyList.map(t=>({method:"crm.currency.get",params:{id:t}}));if(e.length===0)return Promise.resolve();try{(await this._b24.callBatchByChunk(e,!0)).getData().forEach(t=>{if(typeof t.LANG>"u")return;const n=t.CURRENCY,s=this.data.currencyList.get(n);if(!(typeof s>"u"))for(const[i,o]of Object.entries(t.LANG))switch(s.lang[i]={decimals:Number.parseInt(o.DECIMALS),decPoint:o.DEC_POINT,formatString:o.FORMAT_STRING,fullName:o.FULL_NAME,isHideZero:o.HIDE_ZERO==="Y",thousandsSep:o.THOUSANDS_SEP,thousandsVariant:o.THOUSANDS_VARIANT},s.lang[i].thousandsVariant){case"N":s.lang[i].thousandsSep="";break;case"D":s.lang[i].thousandsSep=".";break;case"C":s.lang[i].thousandsSep=",";break;case"S":s.lang[i].thousandsSep=" ";break;case"B":s.lang[i].thousandsSep=" ";break;default:C.isStringFilled(s.lang[i].thousandsSep)||(s.lang[i].thousandsSep=" ");break}})}catch(t){console.error(t)}}get data(){if(this._data===null)throw new Error("CurrencyManager.data not initialized");return this._data}setBaseCurrency(e){this._data.currencyBase=e}get baseCurrency(){return this.data.currencyBase}setCurrencyList(e=[]){this.data.currencyList.clear();for(const t of e)this.data.currencyList.set(t.CURRENCY,{amount:Number.parseFloat(t.CURRENCY),amountCnt:Number.parseInt(t.AMOUNT_CNT),isBase:t.BASE==="Y",currencyCode:t.CURRENCY,dateUpdate:W.toDateTime(t.DATE_UPDATE),decimals:Number.parseInt(t.DECIMALS),decPoint:t.DEC_POINT,formatString:t.FORMAT_STRING,fullName:t.FULL_NAME,lid:t.LID,sort:Number.parseInt(t.SORT),thousandsSep:t?.THOUSANDS_SEP||null,lang:{}})}getCurrencyFullName(e,t){const n=this.data.currencyList.get(e);if(typeof n>"u")throw new qn(e);let s=n.fullName;if(!(typeof t>"u")){const i=n.lang[t];C.isUndefined(i)||(s=i.fullName)}return s}getCurrencyLiteral(e,t){const n=this.data.currencyList.get(e);if(typeof n>"u")throw new qn(e);let s=n.formatString;if(!(typeof t>"u")){const i=n.lang[t];C.isUndefined(i)||(s=i.formatString)}return s.replaceAll("&#","&%").replaceAll("#","").replaceAll("&%","&#").trim()||""}get currencyList(){return[...this.data.currencyList.keys()]}format(e,t,n){const s=this.data.currencyList.get(t);if(typeof s>"u")throw new qn(t);const i={formatString:s.formatString,decimals:s.decimals,decPoint:s.decPoint,thousandsSep:s.thousandsSep};C.isStringFilled(i.thousandsSep)||(i.thousandsSep="");const o=s.lang[n];return C.isUndefined(o)||(i.formatString=o.formatString,i.decimals=o.decimals,i.decPoint=o.decPoint,i.thousandsSep=o.thousandsSep),i.formatString.replaceAll("&#","&%").replace("#",W.numberFormat(e,i.decimals,i.decPoint,i.thousandsSep)).replaceAll("&%","&#")||""}}class Vn extends xt{_data;_type;static getSupportTypes(){return[Xe.NotSet,Xe.JsonArray,Xe.JsonObject,Xe.FloatVal,Xe.IntegerVal,Xe.BoolYN,Xe.StringVal]}static prepareArrayList(e){return C.isArray(e)?e:C.isObject(e)?Object.values(e):[]}constructor(e,t){super(e),this._type=t,this._data=new Map}get data(){return this._data}reset(){this.data.clear()}async initData(e){if(this.reset(),C.isObject(e))for(const[t,n]of Object.entries(e))this.data.set(t,n)}getJsonArray(e,t=[]){if(!this.data.has(e))return t;let n=this.data.get(e);try{n=JSON.parse(n),!C.isArray(n)&&!C.isObject(n)&&(n=t)}catch(s){this.getLogger().error(s),n=t}return Vn.prepareArrayList(n)}getJsonObject(e,t={}){if(!this.data.has(e))return t;let n=this.data.get(e);try{n=JSON.parse(n)}catch(s){this.getLogger().error(s),n=t}return C.isObject(n)||(n=t),n}getFloat(e,t=0){return this.data.has(e)?W.toNumber(this.data.get(e)):t}getInteger(e,t=0){return this.data.has(e)?W.toInteger(this.data.get(e)):t}getBoolYN(e,t=!0){return this.data.has(e)?W.toBoolean(this.data.get(e)):t}getBoolNY(e,t=!1){return this.data.has(e)?W.toBoolean(this.data.get(e)):t}getString(e,t=""){return this.data.has(e)?this.data.get(e).toString():t}getDate(e,t=null){if(!this.data.has(e))return t;try{const n=W.toDateTime(this.data.get(e).toString());return n.isValid?n:t}catch{return t}}encode(e){return JSON.stringify(e)}decode(e,t){try{return e.length>0?JSON.parse(e):t}catch(n){this.getLogger().warn(n,e)}return t}getMethodSave(){switch(this._type){case"app":return"app.option.set";case"user":return"user.option.set"}}async save(e,t){const n=[];return n.push({method:this.getMethodSave(),params:{options:e}}),C.isObject(t)&&n.push({method:"pull.application.event.add",params:{COMMAND:t?.command,PARAMS:t?.params,MODULE_ID:t?.moduleId}}),this._b24.callBatch(n,!0)}}class Vo{_logger=null;userId;siteId;constructor(e={}){this.userId=e.userId?W.toInteger(e.userId):0,this.siteId=e.siteId??"none"}setLogger(e){this._logger=e}getLogger(){return this._logger===null&&(this._logger=ye.build("NullLogger"),this._logger.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!1,[I.warn]:!1,[I.error]:!0,[I.trace]:!1})),this._logger}set(e,t){if(typeof window.localStorage>"u"){this.getLogger().error(new Error("undefined window.localStorage"));return}typeof t!="string"&&t&&(t=JSON.stringify(t)),window.localStorage.setItem(this._getKey(e),t)}get(e,t){if(typeof window.localStorage>"u")return t||null;const n=window.localStorage.getItem(this._getKey(e));return n===null?t||null:JSON.parse(n)}remove(e){if(typeof window.localStorage>"u"){this.getLogger().error(new Error("undefined window.localStorage"));return}return window.localStorage.removeItem(this._getKey(e))}_getKey(e){return`@bitrix24/b24jssdk-pull-${this.userId}-${this.siteId}-${e}`}compareKey(e,t){return e===this._getKey(t)}}class Dh extends Error{constructor(e){super(e),this.name="ErrorNotConnected"}}class Ph extends Error{constructor(e){super(e),this.name="ErrorTimeout"}}const Br="2.0";class Mh{_logger=null;_connector;_idCounter=0;_handlers={};_rpcResponseAwaiters=new Map;constructor(e){if(this._connector=e.connector,C.isPlainObject(e.handlers))for(const t in e.handlers)this.handle(t,e.handlers[t])}setLogger(e){this._logger=e}getLogger(){return this._logger===null&&(this._logger=ye.build("NullLogger"),this._logger.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!1,[I.warn]:!1,[I.error]:!0,[I.trace]:!1})),this._logger}handle(e,t){this._handlers[e]=t}async executeOutgoingRpcCommand(e,t,n=5){return new Promise((s,i)=>{const o=this.createRequest(e,t);this._connector.send(JSON.stringify(o))||i(new Dh("websocket is not connected"));const l=setTimeout(()=>{this._rpcResponseAwaiters.delete(o.id),i(new Ph("no response"))},n*1e3);this._rpcResponseAwaiters.set(o.id,{resolve:s,reject:i,timeout:l})})}executeOutgoingRpcBatch(e){const t=[],n=[];return e.forEach(({method:s,params:i,id:o})=>{const l=this.createRequest(s,i,o);t.push(l),n.push(new Promise((a,u)=>this._rpcResponseAwaiters.set(l.id,{resolve:a,reject:u})))}),this._connector.send(JSON.stringify(t)),n}processRpcResponse(e){if("id"in e&&this._rpcResponseAwaiters.has(Number(e.id))){const t=this._rpcResponseAwaiters.get(Number(e.id));t&&("result"in e?t.resolve(e.result):"error"in e?t.reject(e?.error||"error"):t.reject("wrong response structure"),clearTimeout(t.timeout),this._rpcResponseAwaiters.delete(Number(e.id)));return}this.getLogger().error(new Error(`${W.getDateForLog()}: Pull: Received rpc response with unknown id`),e)}parseJsonRpcMessage(e){let t;try{t=JSON.parse(e)}catch(n){this.getLogger().error(new Error(`${W.getDateForLog()}: Pull: Could not decode json rpc message`),n);return}if(C.isArray(t))return this.executeIncomingRpcBatch(t);if(C.isJsonRpcRequest(t))return this.executeIncomingRpcCommand(t);if(C.isJsonRpcResponse(t))return this.processRpcResponse(t);this.getLogger().error(new Error(`${W.getDateForLog()}: Pull: unknown rpc packet`),t)}executeIncomingRpcCommand({method:e,params:t}){return e in this._handlers?this._handlers[e].call(this,t||{}):{jsonrpc:Br,error:_n.MethodNotFound}}executeIncomingRpcBatch(e){const t=[];for(const n of e)if("jsonrpc"in n)if("method"in n){const s=this.executeIncomingRpcCommand(n);s&&(s.jsonrpc=Br,s.id=n.id,t.push(s))}else this.processRpcResponse(n);else this.getLogger().error(new Error(`${W.getDateForLog()}: Pull: unknown rpc command in batch`),n),t.push({jsonrpc:Br,error:_n.InvalidRequest});return t}nextId(){return++this._idCounter}createPublishRequest(e){return e.map(t=>this.createRequest("publish",t))}createRequest(e,t,n){return n||(n=this.nextId()),{jsonrpc:Br,method:e,params:t,id:n}}}class Fh{_logger=null;_storage;_ttl=1440*60;_callbacks;constructor(e={}){e=e||{},this._storage=e.storage||new Vo,this._callbacks={onWebSocketBlockChanged:C.isFunction(e.onWebSocketBlockChanged)?e.onWebSocketBlockChanged:()=>{}},this._storage&&window.addEventListener("storage",this.onLocalStorageSet.bind(this))}setLogger(e){this._logger=e}getLogger(){return this._logger===null&&(this._logger=ye.build("NullLogger"),this._logger.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!1,[I.warn]:!1,[I.error]:!0,[I.trace]:!1})),this._logger}onLocalStorageSet(e){this._storage.compareKey(e.key||"",Ne.WebsocketBlocked)&&e.newValue!==e.oldValue&&this._callbacks.onWebSocketBlockChanged({isWebSocketBlocked:this.isWebSocketBlocked()})}isWebSocketBlocked(){return this._storage?this._storage.get(Ne.WebsocketBlocked,0)>Date.now():!1}setWebSocketBlocked(e){if(!this._storage)return!1;try{this._storage.set(Ne.WebsocketBlocked,e?Date.now()+this._ttl:0)}catch(t){return this.getLogger().error(new Error(`${W.getDateForLog()}: Pull: Could not save WS_blocked flag in local storage. Error: `),t),!1}return!0}isLongPollingBlocked(){return this._storage?this._storage.get(Ne.LongPollingBlocked,0)>Date.now():!1}setLongPollingBlocked(e){if(!this._storage)return!1;try{this._storage.set(Ne.LongPollingBlocked,e?Date.now()+this._ttl:0)}catch(t){return this.getLogger().error(new Error(`${W.getDateForLog()}: Pull: Could not save LP_blocked flag in local storage. Error: `),t),!1}return!0}isLoggingEnabled(){return this._storage?this._storage.get(Ne.LoggingEnabled,0)>this.getTimestamp():!1}setLoggingEnabled(e){if(!this._storage)return!1;try{this._storage.set(Ne.LoggingEnabled,e?this.getTimestamp()+this._ttl:0)}catch(t){return this.getLogger().error(new Error(`${W.getDateForLog()}: LocalStorage error: `),t),!1}return!0}getTimestamp(){return Date.now()}}class xh{_logger=null;_publicIds;_restClient;_getPublicListMethod;constructor(e){this._publicIds=new Map,this._restClient=e.b24,this._getPublicListMethod=e.getPublicListMethod}setLogger(e){this._logger=e}getLogger(){return this._logger===null&&(this._logger=ye.build("NullLogger"),this._logger.setConfig({[I.desktop]:!1,[I.log]:!1,[I.info]:!1,[I.warn]:!1,[I.error]:!0,[I.trace]:!1})),this._logger}async getPublicIds(e){const t=new Date,n={},s=[];for(const i of e){const o=this._publicIds.get(i);o&&o.end>t?n[o.userId]=o:s.push(i)}return s.length===0?Promise.resolve(n):new Promise(i=>{this._restClient.callMethod(this._getPublicListMethod,{users:s}).then(o=>{const l=o.getData().result;this.setPublicIds(Object.values(l));for(const a of s){const u=this._publicIds.get(a);u&&(n[u.userId]=u)}i(n)}).catch(o=>(this.getLogger().error(o),i({})))})}setPublicIds(e){e.forEach(t=>{const n=Number(t.user_id);this._publicIds.set(n,{userId:n,publicId:t.public_id,signature:t.signature,start:new Date(t.start),end:new Date(t.end)})})}}var sr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function jh(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var zn={exports:{}};/*!
|
|
13
13
|
* protobuf.js v6.8.6 (c) 2016, daniel wirtz
|
|
14
14
|
* compiled mon, 26 feb 2018 11:35:34 utc
|
|
15
15
|
* licensed under the bsd-3-clause license
|