@mapxus/mapxus-map-jp 9.2.0 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -1,21 +1,4 @@
1
- (function(_e,Vt){typeof exports=="object"&&typeof module<"u"?Vt(exports,require("maplibre-gl")):typeof define=="function"&&define.amd?define(["exports","maplibre-gl"],Vt):(_e=typeof globalThis<"u"?globalThis:_e||self,Vt(_e.MapxusMap={},_e.maplibregl))})(this,(function(_e,Vt){"use strict";var Mn={exports:{}},no;function Qc(){if(no)return Mn.exports;no=1;function e(){}return e.prototype={on:function(t,n,r){var i=this.e||(this.e={});return(i[t]||(i[t]=[])).push({fn:n,ctx:r}),this},once:function(t,n,r){var i=this;function o(){i.off(t,o),n.apply(r,arguments)}return o._=n,this.on(t,o,r)},emit:function(t){var n=[].slice.call(arguments,1),r=((this.e||(this.e={}))[t]||[]).slice(),i=0,o=r.length;for(i;i<o;i++)r[i].fn.apply(r[i].ctx,n);return this},off:function(t,n){var r=this.e||(this.e={}),i=r[t],o=[];if(i&&n)for(var s=0,a=i.length;s<a;s++)i[s].fn!==n&&i[s].fn._!==n&&o.push(i[s]);return o.length?r[t]=o:delete r[t],this}},Mn.exports=e,Mn.exports.TinyEmitter=e,Mn.exports}var Sr=Qc();function el(e){return e.layers.filter(t=>!Ir(t.source))}function Br(e){return e.layers.filter(t=>Ir(t.source))}function Ir(e){return typeof e!="string"?!1:e.startsWith("indoor-")}function xr(e){const{buildingId:t,labelCenter:{lat:n,lon:r},floors:i,name:o,venueId:s,defaultFloor:a}=e,d=Object.entries(o).reduce((I,[b,g])=>{const w=b==="default"?"name":`name:${b}`;return Object.assign(I,{[w]:g})},{}),{codes:u,ids:p,ordinals:h}=i.reduce((I,b)=>{const{id:g,code:w,ordinal:B}=b;return{codes:I.codes?`${I.codes},${w}`:w,ids:I.ids?`${I.ids},${g}`:g,ordinals:`${I.ordinals}`?`${I.ordinals},${B}`:`${B}`}},{codes:"",ids:"",ordinals:""});return{layer:{id:"mapxus-building-line"},properties:{building:"yes",id:t,label_center:`${r},${n}`,level_ids:p,level_names:u,ordinals:h,"ref:venue":s,...d,...a?{default_displayed_floor:a}:{}},source:"indoor-planet",sourceLayer:"mapxus_building"}}function Hn(e){const{address:t,buildings:n,id:r,name:i,type:o,labelCenter:{lon:s,lat:a},defaultBuilding:d,sharedFloors:u}=e,p=Object.entries(t).reduce((w,[B,T])=>Object.assign(w,B==="default"?{"addr:street":T.street,"addr:housenumber":T.housenumber}:{[`addr:street:${B}`]:T.street}),{}),h=Object.entries(i).reduce((w,[B,T])=>{const H=B==="default"?"name":`name:${B}`;return Object.assign(w,{[H]:T})},{}),I=d?n.find(w=>w.id===d)?.defaultFloor:null,b=d?{default_displayed_building:d,...I?{default_displayed_ordinal:I}:{}}:{},g=u?.length?{shared_level_ids:u.map(({id:w})=>w).join(","),shared_level_ordinals:u.map(({ordinal:w})=>w).join(",")}:{};return{layer:{id:"mapxus-venue-fill"},properties:{...p,...h,id:r,venue:o,label_center:`${s},${a}`,building_ids:n.map(({id:w})=>w).join(),...b,...g},source:"indoor-planet",sourceLayer:"mapxus_venue"}}function Ae(e,t=","){return typeof e!="string"||!e.trim()?[]:e.split(t)}const nn="reserve_mapxus-level-fill",je="reserve_mapxus-shared-level-fill",rn="reserve_mapxus-building-fill";var De=(e=>(e.ENGLISH="en",e.CHINESE_SIMPLIFIED="zh-Hans",e.CHINESE_TRADITIONAL="zh-Hant",e.CHINESE_TRADITIONAL_TW="zh-Hant-TW",e.JAPANESE="ja",e.KOREAN="ko",e.FILIPINO="fil",e.INDONESIAN="id",e.PORTUGUESE="pt",e.THAI="th",e.VIETNAMESE="vi",e.ARABIC="ar",e))(De||{});function ro(e){let t=null;return tl(e)?t=De.ENGLISH:nl(e)?t=De.CHINESE_SIMPLIFIED:rl(e)?t=De.CHINESE_TRADITIONAL:il(e)?t=De.CHINESE_TRADITIONAL_TW:ol(e)?t=De.JAPANESE:sl(e)?t=De.KOREAN:al(e)?t=De.FILIPINO:cl(e)?t=De.INDONESIAN:ll(e)?t=De.PORTUGUESE:ul(e)?t=De.THAI:dl(e)?t=De.VIETNAMESE:fl(e)&&(t=De.ARABIC),t}function tl(e){return/^en(-(US|GB|AU))?$/.test(e)}function nl(e){return/^zh(-(Hans|CN))?$/.test(e)}function rl(e){return/^zh-(Hant|HK|MO)$/.test(e)}function il(e){return e==="zh-TW"}function ol(e){return/^ja(-JP)?$/.test(e)}function sl(e){return/^ko(-KR)?$/.test(e)}function al(e){return/^(fil|tl)(-PH)?$/.test(e)}function cl(e){return/^id(-ID)?$/.test(e)}function ll(e){return/^pt(-(BR|PT))?$/.test(e)}function ul(e){return/^th(-TH)?$/.test(e)}function dl(e){return/^vi(-VN)?$/.test(e)}function fl(e){return/^ar(-(DZ|BH|EG|IQ|JO|KW|LB|LY|MA|OM|QA|SA|SY|TN|AE|YE))?$/.test(e)}var Lr=(e=>(e.CHRISTMAS="christmas_mims2_v1",e.HALLOWEEN="halloween_mims2_v1",e.MAPPY_BEE="mappybee_mims2_v2",e.MAPXUS="mapxus_mims2_v1",e.LANDS_D="lands_d_mims2_v1",e.COMMON="common_mims2_v1",e.MAPXUS_V2="mapxus_v2",e.MAPXUS_DEFAULT="mapxus_v8",e.ROSE_TEA="rose_tea",e.PEAR_SORBET="pear_sorbet",e.CITY_WALK="city_walk",e.MOCHA_MOUSSE="mocha_mousse",e.SECTION_DISPLAY_BY_COLOR="mapxus_v7_with_section_v2",e.SECTION_DISPLAY_BY_CATEGORY="mapxus_v7_with_section_v3",e))(Lr||{}),St=(e=>(e.Access="access_control",e.Map="map",e))(St||{}),Ar=(e=>(e.FOOT="foot",e.WHEELCHAIR="wheelchair",e.ESCALATOR="escalator",e.EMERGENCY="emergency",e))(Ar||{}),io=(e=>(e.POINT="Point",e.POLYGON="Polygon",e))(io||{}),Cr=(e=>(e.POINT="Point",e.POLYGON="Polygon",e.GATE="Gate",e))(Cr||{}),oo=(e=>(e.DEFAULT_NAME="DefaultName",e))(oo||{}),so=(e=>(e.ABSOLUTE_DISTANCE="AbsoluteDistance",e.ACTUAL_DISTANCE="ActualDistance",e))(so||{});const Un={lineWidth:3,lineColor:"#A5E3FF",lineOpacity:1,lineOffset:-1.5},ao={fontColor:"#8c8c8c",activeFontColor:"#fff",backgroundColor:"#fff",activeBackgroundColor:"#074769",itemSize:50,itemCount:4,defaultFolded:!1},hl=ro(window.navigator.language)??De.ENGLISH;function co(e,t){return function(){return e.apply(t,arguments)}}const{toString:pl}=Object.prototype,{getPrototypeOf:Tr}=Object,{iterator:Nn,toStringTag:lo}=Symbol,Dn=(e=>t=>{const n=pl.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Qe=e=>(e=e.toLowerCase(),t=>Dn(t)===e),$n=e=>t=>typeof t===e,{isArray:jt}=Array,on=$n("undefined");function sn(e){return e!==null&&!on(e)&&e.constructor!==null&&!on(e.constructor)&&qe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const uo=Qe("ArrayBuffer");function yl(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&uo(e.buffer),t}const gl=$n("string"),qe=$n("function"),fo=$n("number"),an=e=>e!==null&&typeof e=="object",ml=e=>e===!0||e===!1,Vn=e=>{if(Dn(e)!=="object")return!1;const t=Tr(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(lo in e)&&!(Nn in e)},_l=e=>{if(!an(e)||sn(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},bl=Qe("Date"),wl=Qe("File"),vl=Qe("Blob"),El=Qe("FileList"),Sl=e=>an(e)&&qe(e.pipe),Bl=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||qe(e.append)&&((t=Dn(e))==="formdata"||t==="object"&&qe(e.toString)&&e.toString()==="[object FormData]"))},Il=Qe("URLSearchParams"),[xl,Ll,Al,Cl]=["ReadableStream","Request","Response","Headers"].map(Qe),Tl=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function cn(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,i;if(typeof e!="object"&&(e=[e]),jt(e))for(r=0,i=e.length;r<i;r++)t.call(null,e[r],r,e);else{if(sn(e))return;const o=n?Object.getOwnPropertyNames(e):Object.keys(e),s=o.length;let a;for(r=0;r<s;r++)a=o[r],t.call(null,e[a],a,e)}}function ho(e,t){if(sn(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,i;for(;r-- >0;)if(i=n[r],t===i.toLowerCase())return i;return null}const Bt=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,po=e=>!on(e)&&e!==Bt;function Or(){const{caseless:e}=po(this)&&this||{},t={},n=(r,i)=>{const o=e&&ho(t,i)||i;Vn(t[o])&&Vn(r)?t[o]=Or(t[o],r):Vn(r)?t[o]=Or({},r):jt(r)?t[o]=r.slice():t[o]=r};for(let r=0,i=arguments.length;r<i;r++)arguments[r]&&cn(arguments[r],n);return t}const Ol=(e,t,n,{allOwnKeys:r}={})=>(cn(t,(i,o)=>{n&&qe(i)?e[o]=co(i,n):e[o]=i},{allOwnKeys:r}),e),Rl=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Pl=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Fl=(e,t,n,r)=>{let i,o,s;const a={};if(t=t||{},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),o=i.length;o-- >0;)s=i[o],(!r||r(s,e,t))&&!a[s]&&(t[s]=e[s],a[s]=!0);e=n!==!1&&Tr(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kl=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Ml=e=>{if(!e)return null;if(jt(e))return e;let t=e.length;if(!fo(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Hl=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Tr(Uint8Array)),Ul=(e,t)=>{const r=(e&&e[Nn]).call(e);let i;for(;(i=r.next())&&!i.done;){const o=i.value;t.call(e,o[0],o[1])}},Nl=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Dl=Qe("HTMLFormElement"),$l=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,i){return r.toUpperCase()+i}),yo=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Vl=Qe("RegExp"),go=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};cn(n,(i,o)=>{let s;(s=t(i,o,e))!==!1&&(r[o]=s||i)}),Object.defineProperties(e,r)},jl=e=>{go(e,(t,n)=>{if(qe(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(qe(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},ql=(e,t)=>{const n={},r=i=>{i.forEach(o=>{n[o]=!0})};return jt(e)?r(e):r(String(e).split(t)),n},Kl=()=>{},Gl=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function zl(e){return!!(e&&qe(e.append)&&e[lo]==="FormData"&&e[Nn])}const Zl=e=>{const t=new Array(10),n=(r,i)=>{if(an(r)){if(t.indexOf(r)>=0)return;if(sn(r))return r;if(!("toJSON"in r)){t[i]=r;const o=jt(r)?[]:{};return cn(r,(s,a)=>{const d=n(s,i+1);!on(d)&&(o[a]=d)}),t[i]=void 0,o}}return r};return n(e,0)},Wl=Qe("AsyncFunction"),Yl=e=>e&&(an(e)||qe(e))&&qe(e.then)&&qe(e.catch),mo=((e,t)=>e?setImmediate:t?((n,r)=>(Bt.addEventListener("message",({source:i,data:o})=>{i===Bt&&o===n&&r.length&&r.shift()()},!1),i=>{r.push(i),Bt.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",qe(Bt.postMessage)),Xl=typeof queueMicrotask<"u"?queueMicrotask.bind(Bt):typeof process<"u"&&process.nextTick||mo,ie={isArray:jt,isArrayBuffer:uo,isBuffer:sn,isFormData:Bl,isArrayBufferView:yl,isString:gl,isNumber:fo,isBoolean:ml,isObject:an,isPlainObject:Vn,isEmptyObject:_l,isReadableStream:xl,isRequest:Ll,isResponse:Al,isHeaders:Cl,isUndefined:on,isDate:bl,isFile:wl,isBlob:vl,isRegExp:Vl,isFunction:qe,isStream:Sl,isURLSearchParams:Il,isTypedArray:Hl,isFileList:El,forEach:cn,merge:Or,extend:Ol,trim:Tl,stripBOM:Rl,inherits:Pl,toFlatObject:Fl,kindOf:Dn,kindOfTest:Qe,endsWith:kl,toArray:Ml,forEachEntry:Ul,matchAll:Nl,isHTMLForm:Dl,hasOwnProperty:yo,hasOwnProp:yo,reduceDescriptors:go,freezeMethods:jl,toObjectSet:ql,toCamelCase:$l,noop:Kl,toFiniteNumber:Gl,findKey:ho,global:Bt,isContextDefined:po,isSpecCompliantForm:zl,toJSONObject:Zl,isAsyncFn:Wl,isThenable:Yl,setImmediate:mo,asap:Xl,isIterable:e=>e!=null&&qe(e[Nn])};function Be(e,t,n,r,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),i&&(this.response=i,this.status=i.status?i.status:null)}ie.inherits(Be,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:ie.toJSONObject(this.config),code:this.code,status:this.status}}});const _o=Be.prototype,bo={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{bo[e]={value:e}}),Object.defineProperties(Be,bo),Object.defineProperty(_o,"isAxiosError",{value:!0}),Be.from=(e,t,n,r,i,o)=>{const s=Object.create(_o);return ie.toFlatObject(e,s,function(d){return d!==Error.prototype},a=>a!=="isAxiosError"),Be.call(s,e.message,t,n,r,i),s.cause=e,s.name=e.name,o&&Object.assign(s,o),s};const Jl=null;function Rr(e){return ie.isPlainObject(e)||ie.isArray(e)}function wo(e){return ie.endsWith(e,"[]")?e.slice(0,-2):e}function vo(e,t,n){return e?e.concat(t).map(function(i,o){return i=wo(i),!n&&o?"["+i+"]":i}).join(n?".":""):t}function Ql(e){return ie.isArray(e)&&!e.some(Rr)}const eu=ie.toFlatObject(ie,{},null,function(t){return/^is[A-Z]/.test(t)});function jn(e,t,n){if(!ie.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=ie.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(w,B){return!ie.isUndefined(B[w])});const r=n.metaTokens,i=n.visitor||p,o=n.dots,s=n.indexes,d=(n.Blob||typeof Blob<"u"&&Blob)&&ie.isSpecCompliantForm(t);if(!ie.isFunction(i))throw new TypeError("visitor must be a function");function u(g){if(g===null)return"";if(ie.isDate(g))return g.toISOString();if(ie.isBoolean(g))return g.toString();if(!d&&ie.isBlob(g))throw new Be("Blob is not supported. Use a Buffer instead.");return ie.isArrayBuffer(g)||ie.isTypedArray(g)?d&&typeof Blob=="function"?new Blob([g]):Buffer.from(g):g}function p(g,w,B){let T=g;if(g&&!B&&typeof g=="object"){if(ie.endsWith(w,"{}"))w=r?w:w.slice(0,-2),g=JSON.stringify(g);else if(ie.isArray(g)&&Ql(g)||(ie.isFileList(g)||ie.endsWith(w,"[]"))&&(T=ie.toArray(g)))return w=wo(w),T.forEach(function(N,X){!(ie.isUndefined(N)||N===null)&&t.append(s===!0?vo([w],X,o):s===null?w:w+"[]",u(N))}),!1}return Rr(g)?!0:(t.append(vo(B,w,o),u(g)),!1)}const h=[],I=Object.assign(eu,{defaultVisitor:p,convertValue:u,isVisitable:Rr});function b(g,w){if(!ie.isUndefined(g)){if(h.indexOf(g)!==-1)throw Error("Circular reference detected in "+w.join("."));h.push(g),ie.forEach(g,function(T,H){(!(ie.isUndefined(T)||T===null)&&i.call(t,T,ie.isString(H)?H.trim():H,w,I))===!0&&b(T,w?w.concat(H):[H])}),h.pop()}}if(!ie.isObject(e))throw new TypeError("data must be an object");return b(e),t}function Eo(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Pr(e,t){this._pairs=[],e&&jn(e,this,t)}const So=Pr.prototype;So.append=function(t,n){this._pairs.push([t,n])},So.toString=function(t){const n=t?function(r){return t.call(this,r,Eo)}:Eo;return this._pairs.map(function(i){return n(i[0])+"="+n(i[1])},"").join("&")};function tu(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Bo(e,t,n){if(!t)return e;const r=n&&n.encode||tu;ie.isFunction(n)&&(n={serialize:n});const i=n&&n.serialize;let o;if(i?o=i(t,n):o=ie.isURLSearchParams(t)?t.toString():new Pr(t,n).toString(r),o){const s=e.indexOf("#");s!==-1&&(e=e.slice(0,s)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class Io{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){ie.forEach(this.handlers,function(r){r!==null&&t(r)})}}const xo={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},nu={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Pr,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Fr=typeof window<"u"&&typeof document<"u",kr=typeof navigator=="object"&&navigator||void 0,ru=Fr&&(!kr||["ReactNative","NativeScript","NS"].indexOf(kr.product)<0),iu=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",ou=Fr&&window.location.href||"http://localhost",He={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Fr,hasStandardBrowserEnv:ru,hasStandardBrowserWebWorkerEnv:iu,navigator:kr,origin:ou},Symbol.toStringTag,{value:"Module"})),...nu};function su(e,t){return jn(e,new He.classes.URLSearchParams,{visitor:function(n,r,i,o){return He.isNode&&ie.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...t})}function au(e){return ie.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function cu(e){const t={},n=Object.keys(e);let r;const i=n.length;let o;for(r=0;r<i;r++)o=n[r],t[o]=e[o];return t}function Lo(e){function t(n,r,i,o){let s=n[o++];if(s==="__proto__")return!0;const a=Number.isFinite(+s),d=o>=n.length;return s=!s&&ie.isArray(i)?i.length:s,d?(ie.hasOwnProp(i,s)?i[s]=[i[s],r]:i[s]=r,!a):((!i[s]||!ie.isObject(i[s]))&&(i[s]=[]),t(n,r,i[s],o)&&ie.isArray(i[s])&&(i[s]=cu(i[s])),!a)}if(ie.isFormData(e)&&ie.isFunction(e.entries)){const n={};return ie.forEachEntry(e,(r,i)=>{t(au(r),i,n,0)}),n}return null}function lu(e,t,n){if(ie.isString(e))try{return(t||JSON.parse)(e),ie.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const ln={transitional:xo,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",i=r.indexOf("application/json")>-1,o=ie.isObject(t);if(o&&ie.isHTMLForm(t)&&(t=new FormData(t)),ie.isFormData(t))return i?JSON.stringify(Lo(t)):t;if(ie.isArrayBuffer(t)||ie.isBuffer(t)||ie.isStream(t)||ie.isFile(t)||ie.isBlob(t)||ie.isReadableStream(t))return t;if(ie.isArrayBufferView(t))return t.buffer;if(ie.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return su(t,this.formSerializer).toString();if((a=ie.isFileList(t))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return jn(a?{"files[]":t}:t,d&&new d,this.formSerializer)}}return o||i?(n.setContentType("application/json",!1),lu(t)):t}],transformResponse:[function(t){const n=this.transitional||ln.transitional,r=n&&n.forcedJSONParsing,i=this.responseType==="json";if(ie.isResponse(t)||ie.isReadableStream(t))return t;if(t&&ie.isString(t)&&(r&&!this.responseType||i)){const s=!(n&&n.silentJSONParsing)&&i;try{return JSON.parse(t)}catch(a){if(s)throw a.name==="SyntaxError"?Be.from(a,Be.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:He.classes.FormData,Blob:He.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ie.forEach(["delete","get","head","post","put","patch"],e=>{ln.headers[e]={}});const uu=ie.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),du=e=>{const t={};let n,r,i;return e&&e.split(`
2
- `).forEach(function(s){i=s.indexOf(":"),n=s.substring(0,i).trim().toLowerCase(),r=s.substring(i+1).trim(),!(!n||t[n]&&uu[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Ao=Symbol("internals");function un(e){return e&&String(e).trim().toLowerCase()}function qn(e){return e===!1||e==null?e:ie.isArray(e)?e.map(qn):String(e)}function fu(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const hu=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Mr(e,t,n,r,i){if(ie.isFunction(r))return r.call(this,t,n);if(i&&(t=n),!!ie.isString(t)){if(ie.isString(r))return t.indexOf(r)!==-1;if(ie.isRegExp(r))return r.test(t)}}function pu(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function yu(e,t){const n=ie.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(i,o,s){return this[r].call(this,t,i,o,s)},configurable:!0})})}let Ke=class{constructor(t){t&&this.set(t)}set(t,n,r){const i=this;function o(a,d,u){const p=un(d);if(!p)throw new Error("header name must be a non-empty string");const h=ie.findKey(i,p);(!h||i[h]===void 0||u===!0||u===void 0&&i[h]!==!1)&&(i[h||d]=qn(a))}const s=(a,d)=>ie.forEach(a,(u,p)=>o(u,p,d));if(ie.isPlainObject(t)||t instanceof this.constructor)s(t,n);else if(ie.isString(t)&&(t=t.trim())&&!hu(t))s(du(t),n);else if(ie.isObject(t)&&ie.isIterable(t)){let a={},d,u;for(const p of t){if(!ie.isArray(p))throw TypeError("Object iterator must return a key-value pair");a[u=p[0]]=(d=a[u])?ie.isArray(d)?[...d,p[1]]:[d,p[1]]:p[1]}s(a,n)}else t!=null&&o(n,t,r);return this}get(t,n){if(t=un(t),t){const r=ie.findKey(this,t);if(r){const i=this[r];if(!n)return i;if(n===!0)return fu(i);if(ie.isFunction(n))return n.call(this,i,r);if(ie.isRegExp(n))return n.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=un(t),t){const r=ie.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||Mr(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let i=!1;function o(s){if(s=un(s),s){const a=ie.findKey(r,s);a&&(!n||Mr(r,r[a],a,n))&&(delete r[a],i=!0)}}return ie.isArray(t)?t.forEach(o):o(t),i}clear(t){const n=Object.keys(this);let r=n.length,i=!1;for(;r--;){const o=n[r];(!t||Mr(this,this[o],o,t,!0))&&(delete this[o],i=!0)}return i}normalize(t){const n=this,r={};return ie.forEach(this,(i,o)=>{const s=ie.findKey(r,o);if(s){n[s]=qn(i),delete n[o];return}const a=t?pu(o):String(o).trim();a!==o&&delete n[o],n[a]=qn(i),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return ie.forEach(this,(r,i)=>{r!=null&&r!==!1&&(n[i]=t&&ie.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
3
- `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(i=>r.set(i)),r}static accessor(t){const r=(this[Ao]=this[Ao]={accessors:{}}).accessors,i=this.prototype;function o(s){const a=un(s);r[a]||(yu(i,s),r[a]=!0)}return ie.isArray(t)?t.forEach(o):o(t),this}};Ke.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),ie.reduceDescriptors(Ke.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),ie.freezeMethods(Ke);function Hr(e,t){const n=this||ln,r=t||n,i=Ke.from(r.headers);let o=r.data;return ie.forEach(e,function(a){o=a.call(n,o,i.normalize(),t?t.status:void 0)}),i.normalize(),o}function Co(e){return!!(e&&e.__CANCEL__)}function qt(e,t,n){Be.call(this,e??"canceled",Be.ERR_CANCELED,t,n),this.name="CanceledError"}ie.inherits(qt,Be,{__CANCEL__:!0});function To(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Be("Request failed with status code "+n.status,[Be.ERR_BAD_REQUEST,Be.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function gu(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function mu(e,t){e=e||10;const n=new Array(e),r=new Array(e);let i=0,o=0,s;return t=t!==void 0?t:1e3,function(d){const u=Date.now(),p=r[o];s||(s=u),n[i]=d,r[i]=u;let h=o,I=0;for(;h!==i;)I+=n[h++],h=h%e;if(i=(i+1)%e,i===o&&(o=(o+1)%e),u-s<t)return;const b=p&&u-p;return b?Math.round(I*1e3/b):void 0}}function _u(e,t){let n=0,r=1e3/t,i,o;const s=(u,p=Date.now())=>{n=p,i=null,o&&(clearTimeout(o),o=null),e(...u)};return[(...u)=>{const p=Date.now(),h=p-n;h>=r?s(u,p):(i=u,o||(o=setTimeout(()=>{o=null,s(i)},r-h)))},()=>i&&s(i)]}const Kn=(e,t,n=3)=>{let r=0;const i=mu(50,250);return _u(o=>{const s=o.loaded,a=o.lengthComputable?o.total:void 0,d=s-r,u=i(d),p=s<=a;r=s;const h={loaded:s,total:a,progress:a?s/a:void 0,bytes:d,rate:u||void 0,estimated:u&&a&&p?(a-s)/u:void 0,event:o,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(h)},n)},Oo=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Ro=e=>(...t)=>ie.asap(()=>e(...t)),bu=He.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,He.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(He.origin),He.navigator&&/(msie|trident)/i.test(He.navigator.userAgent)):()=>!0,wu=He.hasStandardBrowserEnv?{write(e,t,n,r,i,o){const s=[e+"="+encodeURIComponent(t)];ie.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),ie.isString(r)&&s.push("path="+r),ie.isString(i)&&s.push("domain="+i),o===!0&&s.push("secure"),document.cookie=s.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function vu(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Eu(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Po(e,t,n){let r=!vu(t);return e&&(r||n==!1)?Eu(e,t):t}const Fo=e=>e instanceof Ke?{...e}:e;function It(e,t){t=t||{};const n={};function r(u,p,h,I){return ie.isPlainObject(u)&&ie.isPlainObject(p)?ie.merge.call({caseless:I},u,p):ie.isPlainObject(p)?ie.merge({},p):ie.isArray(p)?p.slice():p}function i(u,p,h,I){if(ie.isUndefined(p)){if(!ie.isUndefined(u))return r(void 0,u,h,I)}else return r(u,p,h,I)}function o(u,p){if(!ie.isUndefined(p))return r(void 0,p)}function s(u,p){if(ie.isUndefined(p)){if(!ie.isUndefined(u))return r(void 0,u)}else return r(void 0,p)}function a(u,p,h){if(h in t)return r(u,p);if(h in e)return r(void 0,u)}const d={url:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(u,p,h)=>i(Fo(u),Fo(p),h,!0)};return ie.forEach(Object.keys({...e,...t}),function(p){const h=d[p]||i,I=h(e[p],t[p],p);ie.isUndefined(I)&&h!==a||(n[p]=I)}),n}const ko=e=>{const t=It({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:i,xsrfCookieName:o,headers:s,auth:a}=t;t.headers=s=Ke.from(s),t.url=Bo(Po(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):"")));let d;if(ie.isFormData(n)){if(He.hasStandardBrowserEnv||He.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((d=s.getContentType())!==!1){const[u,...p]=d?d.split(";").map(h=>h.trim()).filter(Boolean):[];s.setContentType([u||"multipart/form-data",...p].join("; "))}}if(He.hasStandardBrowserEnv&&(r&&ie.isFunction(r)&&(r=r(t)),r||r!==!1&&bu(t.url))){const u=i&&o&&wu.read(o);u&&s.set(i,u)}return t},Su=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const i=ko(e);let o=i.data;const s=Ke.from(i.headers).normalize();let{responseType:a,onUploadProgress:d,onDownloadProgress:u}=i,p,h,I,b,g;function w(){b&&b(),g&&g(),i.cancelToken&&i.cancelToken.unsubscribe(p),i.signal&&i.signal.removeEventListener("abort",p)}let B=new XMLHttpRequest;B.open(i.method.toUpperCase(),i.url,!0),B.timeout=i.timeout;function T(){if(!B)return;const N=Ke.from("getAllResponseHeaders"in B&&B.getAllResponseHeaders()),P={data:!a||a==="text"||a==="json"?B.responseText:B.response,status:B.status,statusText:B.statusText,headers:N,config:e,request:B};To(function(q){n(q),w()},function(q){r(q),w()},P),B=null}"onloadend"in B?B.onloadend=T:B.onreadystatechange=function(){!B||B.readyState!==4||B.status===0&&!(B.responseURL&&B.responseURL.indexOf("file:")===0)||setTimeout(T)},B.onabort=function(){B&&(r(new Be("Request aborted",Be.ECONNABORTED,e,B)),B=null)},B.onerror=function(){r(new Be("Network Error",Be.ERR_NETWORK,e,B)),B=null},B.ontimeout=function(){let X=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const P=i.transitional||xo;i.timeoutErrorMessage&&(X=i.timeoutErrorMessage),r(new Be(X,P.clarifyTimeoutError?Be.ETIMEDOUT:Be.ECONNABORTED,e,B)),B=null},o===void 0&&s.setContentType(null),"setRequestHeader"in B&&ie.forEach(s.toJSON(),function(X,P){B.setRequestHeader(P,X)}),ie.isUndefined(i.withCredentials)||(B.withCredentials=!!i.withCredentials),a&&a!=="json"&&(B.responseType=i.responseType),u&&([I,g]=Kn(u,!0),B.addEventListener("progress",I)),d&&B.upload&&([h,b]=Kn(d),B.upload.addEventListener("progress",h),B.upload.addEventListener("loadend",b)),(i.cancelToken||i.signal)&&(p=N=>{B&&(r(!N||N.type?new qt(null,e,B):N),B.abort(),B=null)},i.cancelToken&&i.cancelToken.subscribe(p),i.signal&&(i.signal.aborted?p():i.signal.addEventListener("abort",p)));const H=gu(i.url);if(H&&He.protocols.indexOf(H)===-1){r(new Be("Unsupported protocol "+H+":",Be.ERR_BAD_REQUEST,e));return}B.send(o||null)})},Bu=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,i;const o=function(u){if(!i){i=!0,a();const p=u instanceof Error?u:this.reason;r.abort(p instanceof Be?p:new qt(p instanceof Error?p.message:p))}};let s=t&&setTimeout(()=>{s=null,o(new Be(`timeout ${t} of ms exceeded`,Be.ETIMEDOUT))},t);const a=()=>{e&&(s&&clearTimeout(s),s=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(o):u.removeEventListener("abort",o)}),e=null)};e.forEach(u=>u.addEventListener("abort",o));const{signal:d}=r;return d.unsubscribe=()=>ie.asap(a),d}},Iu=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,i;for(;r<n;)i=r+t,yield e.slice(r,i),r=i},xu=async function*(e,t){for await(const n of Lu(e))yield*Iu(n,t)},Lu=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},Mo=(e,t,n,r)=>{const i=xu(e,t);let o=0,s,a=d=>{s||(s=!0,r&&r(d))};return new ReadableStream({async pull(d){try{const{done:u,value:p}=await i.next();if(u){a(),d.close();return}let h=p.byteLength;if(n){let I=o+=h;n(I)}d.enqueue(new Uint8Array(p))}catch(u){throw a(u),u}},cancel(d){return a(d),i.return()}},{highWaterMark:2})},Gn=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Ho=Gn&&typeof ReadableStream=="function",Au=Gn&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),Uo=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Cu=Ho&&Uo(()=>{let e=!1;const t=new Request(He.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),No=64*1024,Ur=Ho&&Uo(()=>ie.isReadableStream(new Response("").body)),zn={stream:Ur&&(e=>e.body)};Gn&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!zn[t]&&(zn[t]=ie.isFunction(e[t])?n=>n[t]():(n,r)=>{throw new Be(`Response type '${t}' is not supported`,Be.ERR_NOT_SUPPORT,r)})})})(new Response);const Tu=async e=>{if(e==null)return 0;if(ie.isBlob(e))return e.size;if(ie.isSpecCompliantForm(e))return(await new Request(He.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(ie.isArrayBufferView(e)||ie.isArrayBuffer(e))return e.byteLength;if(ie.isURLSearchParams(e)&&(e=e+""),ie.isString(e))return(await Au(e)).byteLength},Ou=async(e,t)=>{const n=ie.toFiniteNumber(e.getContentLength());return n??Tu(t)},Nr={http:Jl,xhr:Su,fetch:Gn&&(async e=>{let{url:t,method:n,data:r,signal:i,cancelToken:o,timeout:s,onDownloadProgress:a,onUploadProgress:d,responseType:u,headers:p,withCredentials:h="same-origin",fetchOptions:I}=ko(e);u=u?(u+"").toLowerCase():"text";let b=Bu([i,o&&o.toAbortSignal()],s),g;const w=b&&b.unsubscribe&&(()=>{b.unsubscribe()});let B;try{if(d&&Cu&&n!=="get"&&n!=="head"&&(B=await Ou(p,r))!==0){let P=new Request(t,{method:"POST",body:r,duplex:"half"}),F;if(ie.isFormData(r)&&(F=P.headers.get("content-type"))&&p.setContentType(F),P.body){const[q,W]=Oo(B,Kn(Ro(d)));r=Mo(P.body,No,q,W)}}ie.isString(h)||(h=h?"include":"omit");const T="credentials"in Request.prototype;g=new Request(t,{...I,signal:b,method:n.toUpperCase(),headers:p.normalize().toJSON(),body:r,duplex:"half",credentials:T?h:void 0});let H=await fetch(g,I);const N=Ur&&(u==="stream"||u==="response");if(Ur&&(a||N&&w)){const P={};["status","statusText","headers"].forEach(K=>{P[K]=H[K]});const F=ie.toFiniteNumber(H.headers.get("content-length")),[q,W]=a&&Oo(F,Kn(Ro(a),!0))||[];H=new Response(Mo(H.body,No,q,()=>{W&&W(),w&&w()}),P)}u=u||"text";let X=await zn[ie.findKey(zn,u)||"text"](H,e);return!N&&w&&w(),await new Promise((P,F)=>{To(P,F,{data:X,headers:Ke.from(H.headers),status:H.status,statusText:H.statusText,config:e,request:g})})}catch(T){throw w&&w(),T&&T.name==="TypeError"&&/Load failed|fetch/i.test(T.message)?Object.assign(new Be("Network Error",Be.ERR_NETWORK,e,g),{cause:T.cause||T}):Be.from(T,T&&T.code,e,g)}})};ie.forEach(Nr,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Do=e=>`- ${e}`,Ru=e=>ie.isFunction(e)||e===null||e===!1,$o={getAdapter:e=>{e=ie.isArray(e)?e:[e];const{length:t}=e;let n,r;const i={};for(let o=0;o<t;o++){n=e[o];let s;if(r=n,!Ru(n)&&(r=Nr[(s=String(n)).toLowerCase()],r===void 0))throw new Be(`Unknown adapter '${s}'`);if(r)break;i[s||"#"+o]=r}if(!r){const o=Object.entries(i).map(([a,d])=>`adapter ${a} `+(d===!1?"is not supported by the environment":"is not available in the build"));let s=t?o.length>1?`since :
4
- `+o.map(Do).join(`
5
- `):" "+Do(o[0]):"as no adapter specified";throw new Be("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return r},adapters:Nr};function Dr(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new qt(null,e)}function Vo(e){return Dr(e),e.headers=Ke.from(e.headers),e.data=Hr.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),$o.getAdapter(e.adapter||ln.adapter)(e).then(function(r){return Dr(e),r.data=Hr.call(e,e.transformResponse,r),r.headers=Ke.from(r.headers),r},function(r){return Co(r)||(Dr(e),r&&r.response&&(r.response.data=Hr.call(e,e.transformResponse,r.response),r.response.headers=Ke.from(r.response.headers))),Promise.reject(r)})}const jo="1.11.0",Zn={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Zn[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const qo={};Zn.transitional=function(t,n,r){function i(o,s){return"[Axios v"+jo+"] Transitional option '"+o+"'"+s+(r?". "+r:"")}return(o,s,a)=>{if(t===!1)throw new Be(i(s," has been removed"+(n?" in "+n:"")),Be.ERR_DEPRECATED);return n&&!qo[s]&&(qo[s]=!0,console.warn(i(s," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,s,a):!0}},Zn.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Pu(e,t,n){if(typeof e!="object")throw new Be("options must be an object",Be.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let i=r.length;for(;i-- >0;){const o=r[i],s=t[o];if(s){const a=e[o],d=a===void 0||s(a,o,e);if(d!==!0)throw new Be("option "+o+" must be "+d,Be.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Be("Unknown option "+o,Be.ERR_BAD_OPTION)}}const Wn={assertOptions:Pu,validators:Zn},rt=Wn.validators;let xt=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Io,response:new Io}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const o=i.stack?i.stack.replace(/^.+\n/,""):"";try{r.stack?o&&!String(r.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(r.stack+=`
6
- `+o):r.stack=o}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=It(this.defaults,n);const{transitional:r,paramsSerializer:i,headers:o}=n;r!==void 0&&Wn.assertOptions(r,{silentJSONParsing:rt.transitional(rt.boolean),forcedJSONParsing:rt.transitional(rt.boolean),clarifyTimeoutError:rt.transitional(rt.boolean)},!1),i!=null&&(ie.isFunction(i)?n.paramsSerializer={serialize:i}:Wn.assertOptions(i,{encode:rt.function,serialize:rt.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Wn.assertOptions(n,{baseUrl:rt.spelling("baseURL"),withXsrfToken:rt.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let s=o&&ie.merge(o.common,o[n.method]);o&&ie.forEach(["delete","get","head","post","put","patch","common"],g=>{delete o[g]}),n.headers=Ke.concat(s,o);const a=[];let d=!0;this.interceptors.request.forEach(function(w){typeof w.runWhen=="function"&&w.runWhen(n)===!1||(d=d&&w.synchronous,a.unshift(w.fulfilled,w.rejected))});const u=[];this.interceptors.response.forEach(function(w){u.push(w.fulfilled,w.rejected)});let p,h=0,I;if(!d){const g=[Vo.bind(this),void 0];for(g.unshift(...a),g.push(...u),I=g.length,p=Promise.resolve(n);h<I;)p=p.then(g[h++],g[h++]);return p}I=a.length;let b=n;for(h=0;h<I;){const g=a[h++],w=a[h++];try{b=g(b)}catch(B){w.call(this,B);break}}try{p=Vo.call(this,b)}catch(g){return Promise.reject(g)}for(h=0,I=u.length;h<I;)p=p.then(u[h++],u[h++]);return p}getUri(t){t=It(this.defaults,t);const n=Po(t.baseURL,t.url,t.allowAbsoluteUrls);return Bo(n,t.params,t.paramsSerializer)}};ie.forEach(["delete","get","head","options"],function(t){xt.prototype[t]=function(n,r){return this.request(It(r||{},{method:t,url:n,data:(r||{}).data}))}}),ie.forEach(["post","put","patch"],function(t){function n(r){return function(o,s,a){return this.request(It(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:o,data:s}))}}xt.prototype[t]=n(),xt.prototype[t+"Form"]=n(!0)});let Fu=class Jc{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(o){n=o});const r=this;this.promise.then(i=>{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](i);r._listeners=null}),this.promise.then=i=>{let o;const s=new Promise(a=>{r.subscribe(a),o=a}).then(i);return s.cancel=function(){r.unsubscribe(o)},s},t(function(o,s,a){r.reason||(r.reason=new qt(o,s,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new Jc(function(i){t=i}),cancel:t}}};function ku(e){return function(n){return e.apply(null,n)}}function Mu(e){return ie.isObject(e)&&e.isAxiosError===!0}const $r={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($r).forEach(([e,t])=>{$r[t]=e});function Ko(e){const t=new xt(e),n=co(xt.prototype.request,t);return ie.extend(n,xt.prototype,t,{allOwnKeys:!0}),ie.extend(n,t,null,{allOwnKeys:!0}),n.create=function(i){return Ko(It(e,i))},n}const Pe=Ko(ln);Pe.Axios=xt,Pe.CanceledError=qt,Pe.CancelToken=Fu,Pe.isCancel=Co,Pe.VERSION=jo,Pe.toFormData=jn,Pe.AxiosError=Be,Pe.Cancel=Pe.CanceledError,Pe.all=function(t){return Promise.all(t)},Pe.spread=ku,Pe.isAxiosError=Mu,Pe.mergeConfig=It,Pe.AxiosHeaders=Ke,Pe.formToJSON=e=>Lo(ie.isHTMLForm(e)?new FormData(e):e),Pe.getAdapter=$o.getAdapter,Pe.HttpStatusCode=$r,Pe.default=Pe;const{Axios:pm,AxiosError:ym,CanceledError:gm,isCancel:mm,CancelToken:_m,VERSION:bm,all:wm,Cancel:vm,isAxiosError:Em,spread:Sm,toFormData:Bm,AxiosHeaders:Im,HttpStatusCode:xm,formToJSON:Lm,getAdapter:Am,mergeConfig:Cm}=Pe,Go="https://map-api.mapxus.co.jp/accounts/v1/auth/secure-token",zo="https://map-api.mapxus.co.jp/bms",Hu="https://map-sdk.mapxus.co.jp/prod/static/resources/manifest-z6frc5.dat",Ge=10,ze=1;var Vr=function(){return Vr=Object.assign||function(t){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},Vr.apply(this,arguments)};function it(e,t,n,r){function i(o){return o instanceof n?o:new n(function(s){s(o)})}return new(n||(n=Promise))(function(o,s){function a(p){try{u(r.next(p))}catch(h){s(h)}}function d(p){try{u(r.throw(p))}catch(h){s(h)}}function u(p){p.done?o(p.value):i(p.value).then(a,d)}u((r=r.apply(e,t||[])).next())})}function ot(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(u){return function(p){return d([u,p])}}function d(u){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,u[0]&&(n=0)),n;)try{if(r=1,i&&(o=u[0]&2?i.return:u[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,u[1])).done)return o;switch(i=0,o&&(u=[u[0]&2,o.value]),u[0]){case 0:case 1:o=u;break;case 4:return n.label++,{value:u[1],done:!1};case 5:n.label++,i=u[1],u=[0];continue;case 7:u=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){n=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){n.label=u[1];break}if(u[0]===6&&n.label<o[1]){n.label=o[1],o=u;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(u);break}o[2]&&n.ops.pop(),n.trys.pop();continue}u=t.call(e,n)}catch(p){u=[6,p],i=0}finally{r=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function Zo(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,o;r<i;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var Wo="4.6.2";function Yn(e,t){return new Promise(function(n){return setTimeout(n,e,t)})}function Uu(){return new Promise(function(e){var t=new MessageChannel;t.port1.onmessage=function(){return e()},t.port2.postMessage(null)})}function Nu(e,t){t===void 0&&(t=1/0);var n=window.requestIdleCallback;return n?new Promise(function(r){return n.call(window,function(){return r()},{timeout:t})}):Yn(Math.min(e,t))}function Yo(e){return!!e&&typeof e.then=="function"}function Xo(e,t){try{var n=e();Yo(n)?n.then(function(r){return t(!0,r)},function(r){return t(!1,r)}):t(!0,n)}catch(r){t(!1,r)}}function Jo(e,t,n){return n===void 0&&(n=16),it(this,void 0,void 0,function(){var r,i,o,s;return ot(this,function(a){switch(a.label){case 0:r=Array(e.length),i=Date.now(),o=0,a.label=1;case 1:return o<e.length?(r[o]=t(e[o],o),s=Date.now(),s>=i+n?(i=s,[4,Uu()]):[3,3]):[3,4];case 2:a.sent(),a.label=3;case 3:return++o,[3,1];case 4:return[2,r]}})})}function dn(e){return e.then(void 0,function(){}),e}function Du(e,t){for(var n=0,r=e.length;n<r;++n)if(e[n]===t)return!0;return!1}function $u(e,t){return!Du(e,t)}function jr(e){return parseInt(e)}function et(e){return parseFloat(e)}function lt(e,t){return typeof e=="number"&&isNaN(e)?t:e}function $e(e){return e.reduce(function(t,n){return t+(n?1:0)},0)}function Qo(e,t){if(t===void 0&&(t=1),Math.abs(t)>=1)return Math.round(e/t)*t;var n=1/t;return Math.round(e*n)/n}function Vu(e){for(var t,n,r="Unexpected syntax '".concat(e,"'"),i=/^\s*([a-z-]*)(.*)$/i.exec(e),o=i[1]||void 0,s={},a=/([.:#][\w-]+|\[.+?\])/gi,d=function(I,b){s[I]=s[I]||[],s[I].push(b)};;){var u=a.exec(i[2]);if(!u)break;var p=u[0];switch(p[0]){case".":d("class",p.slice(1));break;case"#":d("id",p.slice(1));break;case"[":{var h=/^\[([\w-]+)([~|^$*]?=("(.*?)"|([\w-]+)))?(\s+[is])?\]$/.exec(p);if(h)d(h[1],(n=(t=h[4])!==null&&t!==void 0?t:h[5])!==null&&n!==void 0?n:"");else throw new Error(r);break}default:throw new Error(r)}}return[o,s]}function ju(e){for(var t=new Uint8Array(e.length),n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r>127)return new TextEncoder().encode(e);t[n]=r}return t}function mt(e,t){var n=e[0]>>>16,r=e[0]&65535,i=e[1]>>>16,o=e[1]&65535,s=t[0]>>>16,a=t[0]&65535,d=t[1]>>>16,u=t[1]&65535,p=0,h=0,I=0,b=0;b+=o+u,I+=b>>>16,b&=65535,I+=i+d,h+=I>>>16,I&=65535,h+=r+a,p+=h>>>16,h&=65535,p+=n+s,p&=65535,e[0]=p<<16|h,e[1]=I<<16|b}function Ye(e,t){var n=e[0]>>>16,r=e[0]&65535,i=e[1]>>>16,o=e[1]&65535,s=t[0]>>>16,a=t[0]&65535,d=t[1]>>>16,u=t[1]&65535,p=0,h=0,I=0,b=0;b+=o*u,I+=b>>>16,b&=65535,I+=i*u,h+=I>>>16,I&=65535,I+=o*d,h+=I>>>16,I&=65535,h+=r*u,p+=h>>>16,h&=65535,h+=i*d,p+=h>>>16,h&=65535,h+=o*a,p+=h>>>16,h&=65535,p+=n*u+r*d+i*a+o*s,p&=65535,e[0]=p<<16|h,e[1]=I<<16|b}function Kt(e,t){var n=e[0];t%=64,t===32?(e[0]=e[1],e[1]=n):t<32?(e[0]=n<<t|e[1]>>>32-t,e[1]=e[1]<<t|n>>>32-t):(t-=32,e[0]=e[1]<<t|n>>>32-t,e[1]=n<<t|e[1]>>>32-t)}function We(e,t){t%=64,t!==0&&(t<32?(e[0]=e[1]>>>32-t,e[1]=e[1]<<t):(e[0]=e[1]<<t-32,e[1]=0))}function Oe(e,t){e[0]^=t[0],e[1]^=t[1]}var qu=[4283543511,3981806797],Ku=[3301882366,444984403];function es(e){var t=[0,e[0]>>>1];Oe(e,t),Ye(e,qu),t[1]=e[0]>>>1,Oe(e,t),Ye(e,Ku),t[1]=e[0]>>>1,Oe(e,t)}var Xn=[2277735313,289559509],Jn=[1291169091,658871167],ts=[0,5],Gu=[0,1390208809],zu=[0,944331445];function Zu(e,t){var n=ju(e);t=t||0;var r=[0,n.length],i=r[1]%16,o=r[1]-i,s=[0,t],a=[0,t],d=[0,0],u=[0,0],p;for(p=0;p<o;p=p+16)d[0]=n[p+4]|n[p+5]<<8|n[p+6]<<16|n[p+7]<<24,d[1]=n[p]|n[p+1]<<8|n[p+2]<<16|n[p+3]<<24,u[0]=n[p+12]|n[p+13]<<8|n[p+14]<<16|n[p+15]<<24,u[1]=n[p+8]|n[p+9]<<8|n[p+10]<<16|n[p+11]<<24,Ye(d,Xn),Kt(d,31),Ye(d,Jn),Oe(s,d),Kt(s,27),mt(s,a),Ye(s,ts),mt(s,Gu),Ye(u,Jn),Kt(u,33),Ye(u,Xn),Oe(a,u),Kt(a,31),mt(a,s),Ye(a,ts),mt(a,zu);d[0]=0,d[1]=0,u[0]=0,u[1]=0;var h=[0,0];switch(i){case 15:h[1]=n[p+14],We(h,48),Oe(u,h);case 14:h[1]=n[p+13],We(h,40),Oe(u,h);case 13:h[1]=n[p+12],We(h,32),Oe(u,h);case 12:h[1]=n[p+11],We(h,24),Oe(u,h);case 11:h[1]=n[p+10],We(h,16),Oe(u,h);case 10:h[1]=n[p+9],We(h,8),Oe(u,h);case 9:h[1]=n[p+8],Oe(u,h),Ye(u,Jn),Kt(u,33),Ye(u,Xn),Oe(a,u);case 8:h[1]=n[p+7],We(h,56),Oe(d,h);case 7:h[1]=n[p+6],We(h,48),Oe(d,h);case 6:h[1]=n[p+5],We(h,40),Oe(d,h);case 5:h[1]=n[p+4],We(h,32),Oe(d,h);case 4:h[1]=n[p+3],We(h,24),Oe(d,h);case 3:h[1]=n[p+2],We(h,16),Oe(d,h);case 2:h[1]=n[p+1],We(h,8),Oe(d,h);case 1:h[1]=n[p],Oe(d,h),Ye(d,Xn),Kt(d,31),Ye(d,Jn),Oe(s,d)}return Oe(s,r),Oe(a,r),mt(s,a),mt(a,s),es(s),es(a),mt(s,a),mt(a,s),("00000000"+(s[0]>>>0).toString(16)).slice(-8)+("00000000"+(s[1]>>>0).toString(16)).slice(-8)+("00000000"+(a[0]>>>0).toString(16)).slice(-8)+("00000000"+(a[1]>>>0).toString(16)).slice(-8)}function Wu(e){var t;return Vr({name:e.name,message:e.message,stack:(t=e.stack)===null||t===void 0?void 0:t.split(`
7
- `)},e)}function Yu(e){return/^function\s.*?\{\s*\[native code]\s*}$/.test(String(e))}function Xu(e){return typeof e!="function"}function Ju(e,t){var n=dn(new Promise(function(r){var i=Date.now();Xo(e.bind(null,t),function(){for(var o=[],s=0;s<arguments.length;s++)o[s]=arguments[s];var a=Date.now()-i;if(!o[0])return r(function(){return{error:o[1],duration:a}});var d=o[1];if(Xu(d))return r(function(){return{value:d,duration:a}});r(function(){return new Promise(function(u){var p=Date.now();Xo(d,function(){for(var h=[],I=0;I<arguments.length;I++)h[I]=arguments[I];var b=a+Date.now()-p;if(!h[0])return u({error:h[1],duration:b});u({value:h[1],duration:b})})})})})}));return function(){return n.then(function(i){return i()})}}function Qu(e,t,n,r){var i=Object.keys(e).filter(function(s){return $u(n,s)}),o=dn(Jo(i,function(s){return Ju(e[s],t)},r));return function(){return it(this,void 0,void 0,function(){var a,d,u,p,h;return ot(this,function(I){switch(I.label){case 0:return[4,o];case 1:return a=I.sent(),[4,Jo(a,function(b){return dn(b())},r)];case 2:return d=I.sent(),[4,Promise.all(d)];case 3:for(u=I.sent(),p={},h=0;h<i.length;++h)p[i[h]]=u[h];return[2,p]}})})}}function ns(){var e=window,t=navigator;return $e(["MSCSSMatrix"in e,"msSetImmediate"in e,"msIndexedDB"in e,"msMaxTouchPoints"in t,"msPointerEnabled"in t])>=4}function ed(){var e=window,t=navigator;return $e(["msWriteProfilerMark"in e,"MSStream"in e,"msLaunchUri"in t,"msSaveBlob"in t])>=3&&!ns()}function fn(){var e=window,t=navigator;return $e(["webkitPersistentStorage"in t,"webkitTemporaryStorage"in t,(t.vendor||"").indexOf("Google")===0,"webkitResolveLocalFileSystemURL"in e,"BatteryManager"in e,"webkitMediaStream"in e,"webkitSpeechGrammar"in e])>=5}function tt(){var e=window,t=navigator;return $e(["ApplePayError"in e,"CSSPrimitiveValue"in e,"Counter"in e,t.vendor.indexOf("Apple")===0,"RGBColor"in e,"WebKitMediaKeys"in e])>=4}function qr(){var e=window,t=e.HTMLElement,n=e.Document;return $e(["safari"in e,!("ongestureend"in e),!("TouchEvent"in e),!("orientation"in e),t&&!("autocapitalize"in t.prototype),n&&"pointerLockElement"in n.prototype])>=4}function hn(){var e=window;return Yu(e.print)&&String(e.browser)==="[object WebPageNamespace]"}function rs(){var e,t,n=window;return $e(["buildID"in navigator,"MozAppearance"in((t=(e=document.documentElement)===null||e===void 0?void 0:e.style)!==null&&t!==void 0?t:{}),"onmozfullscreenchange"in n,"mozInnerScreenX"in n,"CSSMozDocumentRule"in n,"CanvasCaptureMediaStream"in n])>=4}function td(){var e=window;return $e([!("MediaSettingsRange"in e),"RTCEncodedAudioFrame"in e,""+e.Intl=="[object Intl]",""+e.Reflect=="[object Reflect]"])>=3}function nd(){var e=window,t=e.URLPattern;return $e(["union"in Set.prototype,"Iterator"in e,t&&"hasRegExpGroups"in t.prototype,"RGB8"in WebGLRenderingContext.prototype])>=3}function rd(){var e=window;return $e(["DOMRectList"in e,"RTCPeerConnectionIceEvent"in e,"SVGGeometryElement"in e,"ontransitioncancel"in e])>=3}function pn(){var e=window,t=navigator,n=e.CSS,r=e.HTMLButtonElement;return $e([!("getStorageUpdates"in t),r&&"popover"in r.prototype,"CSSCounterStyleRule"in e,n.supports("font-size-adjust: ex-height 0.5"),n.supports("text-transform: full-width")])>=4}function id(){if(navigator.platform==="iPad")return!0;var e=screen,t=e.width/e.height;return $e(["MediaSource"in window,!!Element.prototype.webkitRequestFullscreen,t>.65&&t<1.53])>=2}function od(){var e=document;return e.fullscreenElement||e.msFullscreenElement||e.mozFullScreenElement||e.webkitFullscreenElement||null}function sd(){var e=document;return(e.exitFullscreen||e.msExitFullscreen||e.mozCancelFullScreen||e.webkitExitFullscreen).call(e)}function Kr(){var e=fn(),t=rs(),n=window,r=navigator,i="connection";return e?$e([!("SharedWorker"in n),r[i]&&"ontypechange"in r[i],!("sinkId"in new Audio)])>=2:t?$e(["onorientationchange"in n,"orientation"in n,/android/i.test(r.appVersion)])>=2:!1}function ad(){var e=navigator,t=window,n=Audio.prototype,r=t.visualViewport;return $e(["srLatency"in n,"srChannelCount"in n,"devicePosture"in e,r&&"segments"in r,"getTextInformation"in Image.prototype])>=3}function cd(){return dd()?-4:ld()}function ld(){var e=window,t=e.OfflineAudioContext||e.webkitOfflineAudioContext;if(!t)return-2;if(ud())return-1;var n=4500,r=5e3,i=new t(1,r,44100),o=i.createOscillator();o.type="triangle",o.frequency.value=1e4;var s=i.createDynamicsCompressor();s.threshold.value=-50,s.knee.value=40,s.ratio.value=12,s.attack.value=0,s.release.value=.25,o.connect(s),s.connect(i.destination),o.start(0);var a=fd(i),d=a[0],u=a[1],p=dn(d.then(function(h){return hd(h.getChannelData(0).subarray(n))},function(h){if(h.name==="timeout"||h.name==="suspended")return-3;throw h}));return function(){return u(),p}}function ud(){return tt()&&!qr()&&!rd()}function dd(){return tt()&&pn()&&hn()||fn()&&ad()&&nd()}function fd(e){var t=3,n=500,r=500,i=5e3,o=function(){},s=new Promise(function(a,d){var u=!1,p=0,h=0;e.oncomplete=function(g){return a(g.renderedBuffer)};var I=function(){setTimeout(function(){return d(is("timeout"))},Math.min(r,h+i-Date.now()))},b=function(){try{var g=e.startRendering();switch(Yo(g)&&dn(g),e.state){case"running":h=Date.now(),u&&I();break;case"suspended":document.hidden||p++,u&&p>=t?d(is("suspended")):setTimeout(b,n);break}}catch(w){d(w)}};b(),o=function(){u||(u=!0,h>0&&I())}});return[s,o]}function hd(e){for(var t=0,n=0;n<e.length;++n)t+=Math.abs(e[n]);return t}function is(e){var t=new Error(e);return t.name=e,t}function os(e,t,n){var r,i,o;return n===void 0&&(n=50),it(this,void 0,void 0,function(){var s,a;return ot(this,function(d){switch(d.label){case 0:s=document,d.label=1;case 1:return s.body?[3,3]:[4,Yn(n)];case 2:return d.sent(),[3,1];case 3:a=s.createElement("iframe"),d.label=4;case 4:return d.trys.push([4,,10,11]),[4,new Promise(function(u,p){var h=!1,I=function(){h=!0,u()},b=function(B){h=!0,p(B)};a.onload=I,a.onerror=b;var g=a.style;g.setProperty("display","block","important"),g.position="absolute",g.top="0",g.left="0",g.visibility="hidden",t&&"srcdoc"in a?a.srcdoc=t:a.src="about:blank",s.body.appendChild(a);var w=function(){var B,T;h||(((T=(B=a.contentWindow)===null||B===void 0?void 0:B.document)===null||T===void 0?void 0:T.readyState)==="complete"?I():setTimeout(w,10))};w()})];case 5:d.sent(),d.label=6;case 6:return!((i=(r=a.contentWindow)===null||r===void 0?void 0:r.document)===null||i===void 0)&&i.body?[3,8]:[4,Yn(n)];case 7:return d.sent(),[3,6];case 8:return[4,e(a,a.contentWindow)];case 9:return[2,d.sent()];case 10:return(o=a.parentNode)===null||o===void 0||o.removeChild(a),[7];case 11:return[2]}})})}function pd(e){for(var t=Vu(e),n=t[0],r=t[1],i=document.createElement(n??"div"),o=0,s=Object.keys(r);o<s.length;o++){var a=s[o],d=r[a].join(" ");a==="style"?yd(i.style,d):i.setAttribute(a,d)}return i}function yd(e,t){for(var n=0,r=t.split(";");n<r.length;n++){var i=r[n],o=/^\s*([\w-]+)\s*:\s*(.+?)(\s*!([\w-]+))?\s*$/.exec(i);if(o){var s=o[1],a=o[2],d=o[4];e.setProperty(s,a,d||"")}}}function gd(){for(var e=window;;){var t=e.parent;if(!t||t===e)return!1;try{if(t.location.origin!==e.location.origin)return!0}catch(n){if(n instanceof Error&&n.name==="SecurityError")return!0;throw n}e=t}}var md="mmMwWLliI0O&1",_d="48px",Gt=["monospace","sans-serif","serif"],ss=["sans-serif-thin","ARNO PRO","Agency FB","Arabic Typesetting","Arial Unicode MS","AvantGarde Bk BT","BankGothic Md BT","Batang","Bitstream Vera Sans Mono","Calibri","Century","Century Gothic","Clarendon","EUROSTILE","Franklin Gothic","Futura Bk BT","Futura Md BT","GOTHAM","Gill Sans","HELV","Haettenschweiler","Helvetica Neue","Humanst521 BT","Leelawadee","Letter Gothic","Levenim MT","Lucida Bright","Lucida Sans","Menlo","MS Mincho","MS Outlook","MS Reference Specialty","MS UI Gothic","MT Extra","MYRIAD PRO","Marlett","Meiryo UI","Microsoft Uighur","Minion Pro","Monotype Corsiva","PMingLiU","Pristina","SCRIPTINA","Segoe UI Light","Serifa","SimHei","Small Fonts","Staccato222 BT","TRAJAN PRO","Univers CE 55 Medium","Vrinda","ZWAdobeF"];function bd(){var e=this;return os(function(t,n){var r=n.document;return it(e,void 0,void 0,function(){var i,o,s,a,d,u,p,h,I,b,g,w;return ot(this,function(B){for(i=r.body,i.style.fontSize=_d,o=r.createElement("div"),o.style.setProperty("visibility","hidden","important"),s={},a={},d=function(T){var H=r.createElement("span"),N=H.style;return N.position="absolute",N.top="0",N.left="0",N.fontFamily=T,H.textContent=md,o.appendChild(H),H},u=function(T,H){return d("'".concat(T,"',").concat(H))},p=function(){return Gt.map(d)},h=function(){for(var T={},H=function(F){T[F]=Gt.map(function(q){return u(F,q)})},N=0,X=ss;N<X.length;N++){var P=X[N];H(P)}return T},I=function(T){return Gt.some(function(H,N){return T[N].offsetWidth!==s[H]||T[N].offsetHeight!==a[H]})},b=p(),g=h(),i.appendChild(o),w=0;w<Gt.length;w++)s[Gt[w]]=b[w].offsetWidth,a[Gt[w]]=b[w].offsetHeight;return[2,ss.filter(function(T){return I(g[T])})]})})})}function wd(){var e=navigator.plugins;if(e){for(var t=[],n=0;n<e.length;++n){var r=e[n];if(r){for(var i=[],o=0;o<r.length;++o){var s=r[o];i.push({type:s.type,suffixes:s.suffixes})}t.push({name:r.name,description:r.description,mimeTypes:i})}}return t}}function vd(){return Ed(Cd())}function Ed(e){var t,n=!1,r,i,o=Sd(),s=o[0],a=o[1];return Bd(s,a)?(n=Id(a),e?r=i="skipped":(t=xd(s,a),r=t[0],i=t[1])):r=i="unsupported",{winding:n,geometry:r,text:i}}function Sd(){var e=document.createElement("canvas");return e.width=1,e.height=1,[e,e.getContext("2d")]}function Bd(e,t){return!!(t&&e.toDataURL)}function Id(e){return e.rect(0,0,10,10),e.rect(2,2,6,6),!e.isPointInPath(5,5,"evenodd")}function xd(e,t){Ld(e,t);var n=Gr(e),r=Gr(e);if(n!==r)return["unstable","unstable"];Ad(e,t);var i=Gr(e);return[i,n]}function Ld(e,t){e.width=240,e.height=60,t.textBaseline="alphabetic",t.fillStyle="#f60",t.fillRect(100,1,62,20),t.fillStyle="#069",t.font='11pt "Times New Roman"';var n="Cwm fjordbank gly ".concat("😃");t.fillText(n,2,15),t.fillStyle="rgba(102, 204, 0, 0.2)",t.font="18pt Arial",t.fillText(n,4,45)}function Ad(e,t){e.width=122,e.height=110,t.globalCompositeOperation="multiply";for(var n=0,r=[["#f2f",40,40],["#2ff",80,40],["#ff2",60,80]];n<r.length;n++){var i=r[n],o=i[0],s=i[1],a=i[2];t.fillStyle=o,t.beginPath(),t.arc(s,a,40,0,Math.PI*2,!0),t.closePath(),t.fill()}t.fillStyle="#f9c",t.arc(60,60,60,0,Math.PI*2,!0),t.arc(60,60,20,0,Math.PI*2,!0),t.fill("evenodd")}function Gr(e){return e.toDataURL()}function Cd(){return tt()&&pn()&&hn()}function Td(){var e=navigator,t=0,n;e.maxTouchPoints!==void 0?t=jr(e.maxTouchPoints):e.msMaxTouchPoints!==void 0&&(t=e.msMaxTouchPoints);try{document.createEvent("TouchEvent"),n=!0}catch{n=!1}var r="ontouchstart"in window;return{maxTouchPoints:t,touchEvent:n,touchStart:r}}function Od(){return navigator.oscpu}function Rd(){var e=navigator,t=[],n=e.language||e.userLanguage||e.browserLanguage||e.systemLanguage;if(n!==void 0&&t.push([n]),Array.isArray(e.languages))fn()&&td()||t.push(e.languages);else if(typeof e.languages=="string"){var r=e.languages;r&&t.push(r.split(","))}return t}function Pd(){return window.screen.colorDepth}function Fd(){return lt(et(navigator.deviceMemory),void 0)}function kd(){if(!(tt()&&pn()&&hn()))return Md()}function Md(){var e=screen,t=function(r){return lt(jr(r),null)},n=[t(e.width),t(e.height)];return n.sort().reverse(),n}var Hd=2500,Ud=10,Qn,zr;function Nd(){if(zr===void 0){var e=function(){var t=Zr();Wr(t)?zr=setTimeout(e,Hd):(Qn=t,zr=void 0)};e()}}function Dd(){var e=this;return Nd(),function(){return it(e,void 0,void 0,function(){var t;return ot(this,function(n){switch(n.label){case 0:return t=Zr(),Wr(t)?Qn?[2,Zo([],Qn,!0)]:od()?[4,sd()]:[3,2]:[3,2];case 1:n.sent(),t=Zr(),n.label=2;case 2:return Wr(t)||(Qn=t),[2,t]}})})}}function $d(){var e=this;if(tt()&&pn()&&hn())return function(){return Promise.resolve(void 0)};var t=Dd();return function(){return it(e,void 0,void 0,function(){var n,r;return ot(this,function(i){switch(i.label){case 0:return[4,t()];case 1:return n=i.sent(),r=function(o){return o===null?null:Qo(o,Ud)},[2,[r(n[0]),r(n[1]),r(n[2]),r(n[3])]]}})})}}function Zr(){var e=screen;return[lt(et(e.availTop),null),lt(et(e.width)-et(e.availWidth)-lt(et(e.availLeft),0),null),lt(et(e.height)-et(e.availHeight)-lt(et(e.availTop),0),null),lt(et(e.availLeft),null)]}function Wr(e){for(var t=0;t<4;++t)if(e[t])return!1;return!0}function Vd(){return lt(jr(navigator.hardwareConcurrency),void 0)}function jd(){var e,t=(e=window.Intl)===null||e===void 0?void 0:e.DateTimeFormat;if(t){var n=new t().resolvedOptions().timeZone;if(n)return n}var r=-qd();return"UTC".concat(r>=0?"+":"").concat(r)}function qd(){var e=new Date().getFullYear();return Math.max(et(new Date(e,0,1).getTimezoneOffset()),et(new Date(e,6,1).getTimezoneOffset()))}function Kd(){try{return!!window.sessionStorage}catch{return!0}}function Gd(){try{return!!window.localStorage}catch{return!0}}function zd(){if(!(ns()||ed()))try{return!!window.indexedDB}catch{return!0}}function Zd(){return!!window.openDatabase}function Wd(){return navigator.cpuClass}function Yd(){var e=navigator.platform;return e==="MacIntel"&&tt()&&!qr()?id()?"iPad":"iPhone":e}function Xd(){return navigator.vendor||""}function Jd(){for(var e=[],t=0,n=["chrome","safari","__crWeb","__gCrWeb","yandex","__yb","__ybro","__firefox__","__edgeTrackingPreventionStatistics","webkit","oprt","samsungAr","ucweb","UCShellJava","puffinDevice"];t<n.length;t++){var r=n[t],i=window[r];i&&typeof i=="object"&&e.push(r)}return e.sort()}function Qd(){var e=document;try{e.cookie="cookietest=1; SameSite=Strict;";var t=e.cookie.indexOf("cookietest=")!==-1;return e.cookie="cookietest=1; SameSite=Strict; expires=Thu, 01-Jan-1970 00:00:01 GMT",t}catch{return!1}}function ef(){var e=atob;return{abpIndo:["#Iklan-Melayang","#Kolom-Iklan-728","#SidebarIklan-wrapper",'[title="ALIENBOLA" i]',e("I0JveC1CYW5uZXItYWRz")],abpvn:[".quangcao","#mobileCatfish",e("LmNsb3NlLWFkcw=="),'[id^="bn_bottom_fixed_"]',"#pmadv"],adBlockFinland:[".mainostila",e("LnNwb25zb3JpdA=="),".ylamainos",e("YVtocmVmKj0iL2NsaWNrdGhyZ2guYXNwPyJd"),e("YVtocmVmXj0iaHR0cHM6Ly9hcHAucmVhZHBlYWsuY29tL2FkcyJd")],adBlockPersian:["#navbar_notice_50",".kadr",'TABLE[width="140px"]',"#divAgahi",e("YVtocmVmXj0iaHR0cDovL2cxLnYuZndtcm0ubmV0L2FkLyJd")],adBlockWarningRemoval:["#adblock-honeypot",".adblocker-root",".wp_adblock_detect",e("LmhlYWRlci1ibG9ja2VkLWFk"),e("I2FkX2Jsb2NrZXI=")],adGuardAnnoyances:[".hs-sosyal","#cookieconsentdiv",'div[class^="app_gdpr"]',".as-oil",'[data-cypress="soft-push-notification-modal"]'],adGuardBase:[".BetterJsPopOverlay",e("I2FkXzMwMFgyNTA="),e("I2Jhbm5lcmZsb2F0MjI="),e("I2NhbXBhaWduLWJhbm5lcg=="),e("I0FkLUNvbnRlbnQ=")],adGuardChinese:[e("LlppX2FkX2FfSA=="),e("YVtocmVmKj0iLmh0aGJldDM0LmNvbSJd"),"#widget-quan",e("YVtocmVmKj0iLzg0OTkyMDIwLnh5eiJd"),e("YVtocmVmKj0iLjE5NTZobC5jb20vIl0=")],adGuardFrench:["#pavePub",e("LmFkLWRlc2t0b3AtcmVjdGFuZ2xl"),".mobile_adhesion",".widgetadv",e("LmFkc19iYW4=")],adGuardGerman:['aside[data-portal-id="leaderboard"]'],adGuardJapanese:["#kauli_yad_1",e("YVtocmVmXj0iaHR0cDovL2FkMi50cmFmZmljZ2F0ZS5uZXQvIl0="),e("Ll9wb3BJbl9pbmZpbml0ZV9hZA=="),e("LmFkZ29vZ2xl"),e("Ll9faXNib29zdFJldHVybkFk")],adGuardMobile:[e("YW1wLWF1dG8tYWRz"),e("LmFtcF9hZA=="),'amp-embed[type="24smi"]',"#mgid_iframe1",e("I2FkX2ludmlld19hcmVh")],adGuardRussian:[e("YVtocmVmXj0iaHR0cHM6Ly9hZC5sZXRtZWFkcy5jb20vIl0="),e("LnJlY2xhbWE="),'div[id^="smi2adblock"]',e("ZGl2W2lkXj0iQWRGb3hfYmFubmVyXyJd"),"#psyduckpockeball"],adGuardSocial:[e("YVtocmVmXj0iLy93d3cuc3R1bWJsZXVwb24uY29tL3N1Ym1pdD91cmw9Il0="),e("YVtocmVmXj0iLy90ZWxlZ3JhbS5tZS9zaGFyZS91cmw/Il0="),".etsy-tweet","#inlineShare",".popup-social"],adGuardSpanishPortuguese:["#barraPublicidade","#Publicidade","#publiEspecial","#queTooltip",".cnt-publi"],adGuardTrackingProtection:["#qoo-counter",e("YVtocmVmXj0iaHR0cDovL2NsaWNrLmhvdGxvZy5ydS8iXQ=="),e("YVtocmVmXj0iaHR0cDovL2hpdGNvdW50ZXIucnUvdG9wL3N0YXQucGhwIl0="),e("YVtocmVmXj0iaHR0cDovL3RvcC5tYWlsLnJ1L2p1bXAiXQ=="),"#top100counter"],adGuardTurkish:["#backkapat",e("I3Jla2xhbWk="),e("YVtocmVmXj0iaHR0cDovL2Fkc2Vydi5vbnRlay5jb20udHIvIl0="),e("YVtocmVmXj0iaHR0cDovL2l6bGVuemkuY29tL2NhbXBhaWduLyJd"),e("YVtocmVmXj0iaHR0cDovL3d3dy5pbnN0YWxsYWRzLm5ldC8iXQ==")],bulgarian:[e("dGQjZnJlZW5ldF90YWJsZV9hZHM="),"#ea_intext_div",".lapni-pop-over","#xenium_hot_offers"],easyList:[".yb-floorad",e("LndpZGdldF9wb19hZHNfd2lkZ2V0"),e("LnRyYWZmaWNqdW5reS1hZA=="),".textad_headline",e("LnNwb25zb3JlZC10ZXh0LWxpbmtz")],easyListChina:[e("LmFwcGd1aWRlLXdyYXBbb25jbGljayo9ImJjZWJvcy5jb20iXQ=="),e("LmZyb250cGFnZUFkdk0="),"#taotaole","#aafoot.top_box",".cfa_popup"],easyListCookie:[".ezmob-footer",".cc-CookieWarning","[data-cookie-number]",e("LmF3LWNvb2tpZS1iYW5uZXI="),".sygnal24-gdpr-modal-wrap"],easyListCzechSlovak:["#onlajny-stickers",e("I3Jla2xhbW5pLWJveA=="),e("LnJla2xhbWEtbWVnYWJvYXJk"),".sklik",e("W2lkXj0ic2tsaWtSZWtsYW1hIl0=")],easyListDutch:[e("I2FkdmVydGVudGll"),e("I3ZpcEFkbWFya3RCYW5uZXJCbG9jaw=="),".adstekst",e("YVtocmVmXj0iaHR0cHM6Ly94bHR1YmUubmwvY2xpY2svIl0="),"#semilo-lrectangle"],easyListGermany:["#SSpotIMPopSlider",e("LnNwb25zb3JsaW5rZ3J1ZW4="),e("I3dlcmJ1bmdza3k="),e("I3Jla2xhbWUtcmVjaHRzLW1pdHRl"),e("YVtocmVmXj0iaHR0cHM6Ly9iZDc0Mi5jb20vIl0=")],easyListItaly:[e("LmJveF9hZHZfYW5udW5jaQ=="),".sb-box-pubbliredazionale",e("YVtocmVmXj0iaHR0cDovL2FmZmlsaWF6aW9uaWFkcy5zbmFpLml0LyJd"),e("YVtocmVmXj0iaHR0cHM6Ly9hZHNlcnZlci5odG1sLml0LyJd"),e("YVtocmVmXj0iaHR0cHM6Ly9hZmZpbGlhemlvbmlhZHMuc25haS5pdC8iXQ==")],easyListLithuania:[e("LnJla2xhbW9zX3RhcnBhcw=="),e("LnJla2xhbW9zX251b3JvZG9z"),e("aW1nW2FsdD0iUmVrbGFtaW5pcyBza3lkZWxpcyJd"),e("aW1nW2FsdD0iRGVkaWt1b3RpLmx0IHNlcnZlcmlhaSJd"),e("aW1nW2FsdD0iSG9zdGluZ2FzIFNlcnZlcmlhaS5sdCJd")],estonian:[e("QVtocmVmKj0iaHR0cDovL3BheTRyZXN1bHRzMjQuZXUiXQ==")],fanboyAnnoyances:["#ac-lre-player",".navigate-to-top","#subscribe_popup",".newsletter_holder","#back-top"],fanboyAntiFacebook:[".util-bar-module-firefly-visible"],fanboyEnhancedTrackers:[".open.pushModal","#issuem-leaky-paywall-articles-zero-remaining-nag","#sovrn_container",'div[class$="-hide"][zoompage-fontsize][style="display: block;"]',".BlockNag__Card"],fanboySocial:["#FollowUs","#meteored_share","#social_follow",".article-sharer",".community__social-desc"],frellwitSwedish:[e("YVtocmVmKj0iY2FzaW5vcHJvLnNlIl1bdGFyZ2V0PSJfYmxhbmsiXQ=="),e("YVtocmVmKj0iZG9rdG9yLXNlLm9uZWxpbmsubWUiXQ=="),"article.category-samarbete",e("ZGl2LmhvbGlkQWRz"),"ul.adsmodern"],greekAdBlock:[e("QVtocmVmKj0iYWRtYW4ub3RlbmV0LmdyL2NsaWNrPyJd"),e("QVtocmVmKj0iaHR0cDovL2F4aWFiYW5uZXJzLmV4b2R1cy5nci8iXQ=="),e("QVtocmVmKj0iaHR0cDovL2ludGVyYWN0aXZlLmZvcnRobmV0LmdyL2NsaWNrPyJd"),"DIV.agores300","TABLE.advright"],hungarian:["#cemp_doboz",".optimonk-iframe-container",e("LmFkX19tYWlu"),e("W2NsYXNzKj0iR29vZ2xlQWRzIl0="),"#hirdetesek_box"],iDontCareAboutCookies:['.alert-info[data-block-track*="CookieNotice"]',".ModuleTemplateCookieIndicator",".o--cookies--container","#cookies-policy-sticky","#stickyCookieBar"],icelandicAbp:[e("QVtocmVmXj0iL2ZyYW1ld29yay9yZXNvdXJjZXMvZm9ybXMvYWRzLmFzcHgiXQ==")],latvian:[e("YVtocmVmPSJodHRwOi8vd3d3LnNhbGlkemluaS5sdi8iXVtzdHlsZT0iZGlzcGxheTogYmxvY2s7IHdpZHRoOiAxMjBweDsgaGVpZ2h0OiA0MHB4OyBvdmVyZmxvdzogaGlkZGVuOyBwb3NpdGlvbjogcmVsYXRpdmU7Il0="),e("YVtocmVmPSJodHRwOi8vd3d3LnNhbGlkemluaS5sdi8iXVtzdHlsZT0iZGlzcGxheTogYmxvY2s7IHdpZHRoOiA4OHB4OyBoZWlnaHQ6IDMxcHg7IG92ZXJmbG93OiBoaWRkZW47IHBvc2l0aW9uOiByZWxhdGl2ZTsiXQ==")],listKr:[e("YVtocmVmKj0iLy9hZC5wbGFuYnBsdXMuY28ua3IvIl0="),e("I2xpdmVyZUFkV3JhcHBlcg=="),e("YVtocmVmKj0iLy9hZHYuaW1hZHJlcC5jby5rci8iXQ=="),e("aW5zLmZhc3R2aWV3LWFk"),".revenue_unit_item.dable"],listeAr:[e("LmdlbWluaUxCMUFk"),".right-and-left-sponsers",e("YVtocmVmKj0iLmFmbGFtLmluZm8iXQ=="),e("YVtocmVmKj0iYm9vcmFxLm9yZyJd"),e("YVtocmVmKj0iZHViaXp6bGUuY29tL2FyLz91dG1fc291cmNlPSJd")],listeFr:[e("YVtocmVmXj0iaHR0cDovL3Byb21vLnZhZG9yLmNvbS8iXQ=="),e("I2FkY29udGFpbmVyX3JlY2hlcmNoZQ=="),e("YVtocmVmKj0id2Vib3JhbWEuZnIvZmNnaS1iaW4vIl0="),".site-pub-interstitiel",'div[id^="crt-"][data-criteo-id]'],officialPolish:["#ceneo-placeholder-ceneo-12",e("W2hyZWZePSJodHRwczovL2FmZi5zZW5kaHViLnBsLyJd"),e("YVtocmVmXj0iaHR0cDovL2Fkdm1hbmFnZXIudGVjaGZ1bi5wbC9yZWRpcmVjdC8iXQ=="),e("YVtocmVmXj0iaHR0cDovL3d3dy50cml6ZXIucGwvP3V0bV9zb3VyY2UiXQ=="),e("ZGl2I3NrYXBpZWNfYWQ=")],ro:[e("YVtocmVmXj0iLy9hZmZ0cmsuYWx0ZXgucm8vQ291bnRlci9DbGljayJd"),e("YVtocmVmXj0iaHR0cHM6Ly9ibGFja2ZyaWRheXNhbGVzLnJvL3Ryay9zaG9wLyJd"),e("YVtocmVmXj0iaHR0cHM6Ly9ldmVudC4ycGVyZm9ybWFudC5jb20vZXZlbnRzL2NsaWNrIl0="),e("YVtocmVmXj0iaHR0cHM6Ly9sLnByb2ZpdHNoYXJlLnJvLyJd"),'a[href^="/url/"]'],ruAd:[e("YVtocmVmKj0iLy9mZWJyYXJlLnJ1LyJd"),e("YVtocmVmKj0iLy91dGltZy5ydS8iXQ=="),e("YVtocmVmKj0iOi8vY2hpa2lkaWtpLnJ1Il0="),"#pgeldiz",".yandex-rtb-block"],thaiAds:["a[href*=macau-uta-popup]",e("I2Fkcy1nb29nbGUtbWlkZGxlX3JlY3RhbmdsZS1ncm91cA=="),e("LmFkczMwMHM="),".bumq",".img-kosana"],webAnnoyancesUltralist:["#mod-social-share-2","#social-tools",e("LmN0cGwtZnVsbGJhbm5lcg=="),".zergnet-recommend",".yt.btn-link.btn-md.btn"]}}function tf(e){var t=e===void 0?{}:e,n=t.debug;return it(this,void 0,void 0,function(){var r,i,o,s,a,d;return ot(this,function(u){switch(u.label){case 0:return nf()?(r=ef(),i=Object.keys(r),o=(d=[]).concat.apply(d,i.map(function(p){return r[p]})),[4,rf(o)]):[2,void 0];case 1:return s=u.sent(),n&&of(r,s),a=i.filter(function(p){var h=r[p],I=$e(h.map(function(b){return s[b]}));return I>h.length*.6}),a.sort(),[2,a]}})})}function nf(){return tt()||Kr()}function rf(e){var t;return it(this,void 0,void 0,function(){var n,r,i,o,d,s,a,d;return ot(this,function(u){switch(u.label){case 0:for(n=document,r=n.createElement("div"),i=new Array(e.length),o={},as(r),d=0;d<e.length;++d)s=pd(e[d]),s.tagName==="DIALOG"&&s.show(),a=n.createElement("div"),as(a),a.appendChild(s),r.appendChild(a),i[d]=s;u.label=1;case 1:return n.body?[3,3]:[4,Yn(50)];case 2:return u.sent(),[3,1];case 3:n.body.appendChild(r);try{for(d=0;d<e.length;++d)i[d].offsetParent||(o[e[d]]=!0)}finally{(t=r.parentNode)===null||t===void 0||t.removeChild(r)}return[2,o]}})})}function as(e){e.style.setProperty("visibility","hidden","important"),e.style.setProperty("display","block","important")}function of(e,t){for(var n="DOM blockers debug:\n```",r=0,i=Object.keys(e);r<i.length;r++){var o=i[r];n+=`
8
- `.concat(o,":");for(var s=0,a=e[o];s<a.length;s++){var d=a[s];n+=`
9
- `.concat(t[d]?"🚫":"➡️"," ").concat(d)}}console.log("".concat(n,"\n```"))}function sf(){for(var e=0,t=["rec2020","p3","srgb"];e<t.length;e++){var n=t[e];if(matchMedia("(color-gamut: ".concat(n,")")).matches)return n}}function af(){if(cs("inverted"))return!0;if(cs("none"))return!1}function cs(e){return matchMedia("(inverted-colors: ".concat(e,")")).matches}function cf(){if(ls("active"))return!0;if(ls("none"))return!1}function ls(e){return matchMedia("(forced-colors: ".concat(e,")")).matches}var lf=100;function uf(){if(matchMedia("(min-monochrome: 0)").matches){for(var e=0;e<=lf;++e)if(matchMedia("(max-monochrome: ".concat(e,")")).matches)return e;throw new Error("Too high value")}}function df(){if(zt("no-preference"))return 0;if(zt("high")||zt("more"))return 1;if(zt("low")||zt("less"))return-1;if(zt("forced"))return 10}function zt(e){return matchMedia("(prefers-contrast: ".concat(e,")")).matches}function ff(){if(us("reduce"))return!0;if(us("no-preference"))return!1}function us(e){return matchMedia("(prefers-reduced-motion: ".concat(e,")")).matches}function hf(){if(ds("reduce"))return!0;if(ds("no-preference"))return!1}function ds(e){return matchMedia("(prefers-reduced-transparency: ".concat(e,")")).matches}function pf(){if(fs("high"))return!0;if(fs("standard"))return!1}function fs(e){return matchMedia("(dynamic-range: ".concat(e,")")).matches}var Ie=Math,Ve=function(){return 0};function yf(){var e=Ie.acos||Ve,t=Ie.acosh||Ve,n=Ie.asin||Ve,r=Ie.asinh||Ve,i=Ie.atanh||Ve,o=Ie.atan||Ve,s=Ie.sin||Ve,a=Ie.sinh||Ve,d=Ie.cos||Ve,u=Ie.cosh||Ve,p=Ie.tan||Ve,h=Ie.tanh||Ve,I=Ie.exp||Ve,b=Ie.expm1||Ve,g=Ie.log1p||Ve,w=function(W){return Ie.pow(Ie.PI,W)},B=function(W){return Ie.log(W+Ie.sqrt(W*W-1))},T=function(W){return Ie.log(W+Ie.sqrt(W*W+1))},H=function(W){return Ie.log((1+W)/(1-W))/2},N=function(W){return Ie.exp(W)-1/Ie.exp(W)/2},X=function(W){return(Ie.exp(W)+1/Ie.exp(W))/2},P=function(W){return Ie.exp(W)-1},F=function(W){return(Ie.exp(2*W)-1)/(Ie.exp(2*W)+1)},q=function(W){return Ie.log(1+W)};return{acos:e(.12312423423423424),acosh:t(1e308),acoshPf:B(1e154),asin:n(.12312423423423424),asinh:r(1),asinhPf:T(1),atanh:i(.5),atanhPf:H(.5),atan:o(.5),sin:s(-1e300),sinh:a(1),sinhPf:N(1),cos:d(10.000000000123),cosh:u(1),coshPf:X(1),tan:p(-1e300),tanh:h(1),tanhPf:F(1),exp:I(1),expm1:b(1),expm1Pf:P(1),log1p:g(10),log1pPf:q(10),powPI:w(-100)}}var gf="mmMwWLliI0fiflO&1",Yr={default:[],apple:[{font:"-apple-system-body"}],serif:[{fontFamily:"serif"}],sans:[{fontFamily:"sans-serif"}],mono:[{fontFamily:"monospace"}],min:[{fontSize:"1px"}],system:[{fontFamily:"system-ui"}]};function mf(){return _f(function(e,t){for(var n={},r={},i=0,o=Object.keys(Yr);i<o.length;i++){var s=o[i],a=Yr[s],d=a[0],u=d===void 0?{}:d,p=a[1],h=p===void 0?gf:p,I=e.createElement("span");I.textContent=h,I.style.whiteSpace="nowrap";for(var b=0,g=Object.keys(u);b<g.length;b++){var w=g[b],B=u[w];B!==void 0&&(I.style[w]=B)}n[s]=I,t.append(e.createElement("br"),I)}for(var T=0,H=Object.keys(Yr);T<H.length;T++){var s=H[T];r[s]=n[s].getBoundingClientRect().width}return r})}function _f(e,t){return t===void 0&&(t=4e3),os(function(n,r){var i=r.document,o=i.body,s=o.style;s.width="".concat(t,"px"),s.webkitTextSizeAdjust=s.textSizeAdjust="none",fn()?o.style.zoom="".concat(1/r.devicePixelRatio):tt()&&(o.style.zoom="reset");var a=i.createElement("div");return a.textContent=Zo([],Array(t/20<<0),!0).map(function(){return"word"}).join(" "),o.appendChild(a),e(i,o)},'<!doctype html><html><head><meta name="viewport" content="width=device-width, initial-scale=1">')}function bf(){return navigator.pdfViewerEnabled}function wf(){var e=new Float32Array(1),t=new Uint8Array(e.buffer);return e[0]=1/0,e[0]=e[0]-e[0],t[3]}function vf(){var e=window.ApplePaySession;if(typeof e?.canMakePayments!="function")return-1;if(Ef())return-3;try{return e.canMakePayments()?1:0}catch(t){return Sf(t)}}var Ef=gd;function Sf(e){if(e instanceof Error&&e.name==="InvalidAccessError"&&/\bfrom\b.*\binsecure\b/i.test(e.message))return-2;throw e}function Bf(){var e,t=document.createElement("a"),n=(e=t.attributionSourceId)!==null&&e!==void 0?e:t.attributionsourceid;return n===void 0?void 0:String(n)}var hs=-1,ps=-2,If=new Set([10752,2849,2884,2885,2886,2928,2929,2930,2931,2932,2960,2961,2962,2963,2964,2965,2966,2967,2968,2978,3024,3042,3088,3089,3106,3107,32773,32777,32777,32823,32824,32936,32937,32938,32939,32968,32969,32970,32971,3317,33170,3333,3379,3386,33901,33902,34016,34024,34076,3408,3410,3411,3412,3413,3414,3415,34467,34816,34817,34818,34819,34877,34921,34930,35660,35661,35724,35738,35739,36003,36004,36005,36347,36348,36349,37440,37441,37443,7936,7937,7938]),xf=new Set([34047,35723,36063,34852,34853,34854,34229,36392,36795,38449]),Lf=["FRAGMENT_SHADER","VERTEX_SHADER"],Af=["LOW_FLOAT","MEDIUM_FLOAT","HIGH_FLOAT","LOW_INT","MEDIUM_INT","HIGH_INT"],ys="WEBGL_debug_renderer_info",Cf="WEBGL_polygon_mode";function Tf(e){var t,n,r,i,o,s,a=e.cache,d=gs(a);if(!d)return hs;if(!bs(d))return ps;var u=_s()?null:d.getExtension(ys);return{version:((t=d.getParameter(d.VERSION))===null||t===void 0?void 0:t.toString())||"",vendor:((n=d.getParameter(d.VENDOR))===null||n===void 0?void 0:n.toString())||"",vendorUnmasked:u?(r=d.getParameter(u.UNMASKED_VENDOR_WEBGL))===null||r===void 0?void 0:r.toString():"",renderer:((i=d.getParameter(d.RENDERER))===null||i===void 0?void 0:i.toString())||"",rendererUnmasked:u?(o=d.getParameter(u.UNMASKED_RENDERER_WEBGL))===null||o===void 0?void 0:o.toString():"",shadingLanguageVersion:((s=d.getParameter(d.SHADING_LANGUAGE_VERSION))===null||s===void 0?void 0:s.toString())||""}}function Of(e){var t=e.cache,n=gs(t);if(!n)return hs;if(!bs(n))return ps;var r=n.getSupportedExtensions(),i=n.getContextAttributes(),o=[],s=[],a=[],d=[],u=[];if(i)for(var p=0,h=Object.keys(i);p<h.length;p++){var I=h[p];s.push("".concat(I,"=").concat(i[I]))}for(var b=ms(n),g=0,w=b;g<w.length;g++){var B=w[g],T=n[B];a.push("".concat(B,"=").concat(T).concat(If.has(T)?"=".concat(n.getParameter(T)):""))}if(r)for(var H=0,N=r;H<N.length;H++){var X=N[H];if(!(X===ys&&_s()||X===Cf&&Ff())){var P=n.getExtension(X);if(!P){o.push(X);continue}for(var F=0,q=ms(P);F<q.length;F++){var B=q[F],T=P[B];d.push("".concat(B,"=").concat(T).concat(xf.has(T)?"=".concat(n.getParameter(T)):""))}}}for(var W=0,K=Lf;W<K.length;W++)for(var J=K[W],te=0,ne=Af;te<ne.length;te++){var Y=ne[te],Q=Rf(n,J,Y);u.push("".concat(J,".").concat(Y,"=").concat(Q.join(",")))}return d.sort(),a.sort(),{contextAttributes:s,parameters:a,shaderPrecisions:u,extensions:r,extensionParameters:d,unsupportedExtensions:o}}function gs(e){if(e.webgl)return e.webgl.context;var t=document.createElement("canvas"),n;t.addEventListener("webglCreateContextError",function(){return n=void 0});for(var r=0,i=["webgl","experimental-webgl"];r<i.length;r++){var o=i[r];try{n=t.getContext(o)}catch{}if(n)break}return e.webgl={context:n},n}function Rf(e,t,n){var r=e.getShaderPrecisionFormat(e[t],e[n]);return r?[r.rangeMin,r.rangeMax,r.precision]:[]}function ms(e){var t=Object.keys(e.__proto__);return t.filter(Pf)}function Pf(e){return typeof e=="string"&&!e.match(/[^A-Z0-9_x]/)}function _s(){return rs()}function Ff(){return fn()||tt()}function bs(e){return typeof e.getParameter=="function"}function kf(){var e=Kr()||tt();if(!e)return-2;if(!window.AudioContext)return-1;var t=new AudioContext().baseLatency;return t==null?-1:isFinite(t)?t:-3}function Mf(){if(!window.Intl)return-1;var e=window.Intl.DateTimeFormat;if(!e)return-2;var t=e().resolvedOptions().locale;return!t&&t!==""?-3:t}var Hf={fonts:bd,domBlockers:tf,fontPreferences:mf,audio:cd,screenFrame:$d,canvas:vd,osCpu:Od,languages:Rd,colorDepth:Pd,deviceMemory:Fd,screenResolution:kd,hardwareConcurrency:Vd,timezone:jd,sessionStorage:Kd,localStorage:Gd,indexedDB:zd,openDatabase:Zd,cpuClass:Wd,platform:Yd,plugins:wd,touchSupport:Td,vendor:Xd,vendorFlavors:Jd,cookiesEnabled:Qd,colorGamut:sf,invertedColors:af,forcedColors:cf,monochrome:uf,contrast:df,reducedMotion:ff,reducedTransparency:hf,hdr:pf,math:yf,pdfViewerEnabled:bf,architecture:wf,applePay:vf,privateClickMeasurement:Bf,audioBaseLatency:kf,dateTimeLocale:Mf,webGlBasics:Tf,webGlExtensions:Of};function Uf(e){return Qu(Hf,e,[])}var Nf="$ if upgrade to Pro: https://fpjs.dev/pro";function Df(e){var t=$f(e),n=Vf(t);return{score:t,comment:Nf.replace(/\$/g,"".concat(n))}}function $f(e){if(Kr())return .4;if(tt())return qr()&&!(pn()&&hn())?.5:.3;var t="value"in e.platform?e.platform.value:"";return/^Win/.test(t)?.6:/^Mac/.test(t)?.5:.7}function Vf(e){return Qo(.99+.01*e,1e-4)}function jf(e){for(var t="",n=0,r=Object.keys(e).sort();n<r.length;n++){var i=r[n],o=e[i],s="error"in o?"error":JSON.stringify(o.value);t+="".concat(t?"|":"").concat(i.replace(/([:|\\])/g,"\\$1"),":").concat(s)}return t}function ws(e){return JSON.stringify(e,function(t,n){return n instanceof Error?Wu(n):n},2)}function vs(e){return Zu(jf(e))}function qf(e){var t,n=Df(e);return{get visitorId(){return t===void 0&&(t=vs(this.components)),t},set visitorId(r){t=r},confidence:n,components:e,version:Wo}}function Kf(e){return e===void 0&&(e=50),Nu(e,e*2)}function Gf(e,t){var n=Date.now();return{get:function(r){return it(this,void 0,void 0,function(){var i,o,s;return ot(this,function(a){switch(a.label){case 0:return i=Date.now(),[4,e()];case 1:return o=a.sent(),s=qf(o),(t||r?.debug)&&console.log("Copy the text below to get the debug data:\n\n```\nversion: ".concat(s.version,`
10
- userAgent: `).concat(navigator.userAgent,`
11
- timeBetweenLoadAndGet: `).concat(i-n,`
12
- visitorId: `).concat(s.visitorId,`
13
- components: `).concat(ws(o),"\n```")),[2,s]}})})}}}function zf(){if(!(window.__fpjs_d_m||Math.random()>=.001))try{var e=new XMLHttpRequest;e.open("get","https://m1.openfpcdn.io/fingerprintjs/v".concat(Wo,"/npm-monitoring"),!0),e.send()}catch(t){console.error(t)}}function Zf(e){var t;return e===void 0&&(e={}),it(this,void 0,void 0,function(){var n,r,i;return ot(this,function(o){switch(o.label){case 0:return(!((t=e.monitoring)!==null&&t!==void 0)||t)&&zf(),n=e.delayFallback,r=e.debug,[4,Kf(n)];case 1:return o.sent(),i=Uf({cache:{},debug:r}),[2,Gf(i,r)]}})})}var Es={load:Zf,hashComponents:vs,componentsToDebugString:ws};const yn={version:"9.2.0"};let Ss=[];const Wf={[Symbol.for("mapxus/callers-register")]:e=>{Ss=e}};function Yf(){return Ss}const er="-webkit-extension-67d8e3e8-";let tr=null;async function Xf(){let e=sessionStorage.getItem(er);if(!e)try{Bs(),await Is(Date.now()),e=sessionStorage.getItem(er)}catch(t){throw new Error("Failed to fetch public key: "+t)}return e}function Bs(){sessionStorage.removeItem(er),tr&&(clearTimeout(tr),tr=null)}function Jf(e){sessionStorage.setItem(er,e)}async function Is(e){try{const t=await fetch(`${Hu}?timestamp=${e}`,{method:"GET",headers:{"Content-Type":"text/plain"}}),{headers:n}=t,r=parseInt(n.get("x-retry-in"));tr=setTimeout(async()=>{await Is(e)},r*1e3),Jf(await t.text())}catch(t){throw t}}function xs(){return nt.getInstance().getIdentifier()}function Qf(e){nt.getInstance().setTokenGetter(e)}function eh(){return nt.getInstance().setupTokenManager()}var Xr={},gn={},Ls;function th(){if(Ls)return gn;Ls=1,gn.byteLength=a,gn.toByteArray=u,gn.fromByteArray=I;for(var e=[],t=[],n=typeof Uint8Array<"u"?Uint8Array:Array,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,o=r.length;i<o;++i)e[i]=r[i],t[r.charCodeAt(i)]=i;t[45]=62,t[95]=63;function s(b){var g=b.length;if(g%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var w=b.indexOf("=");w===-1&&(w=g);var B=w===g?0:4-w%4;return[w,B]}function a(b){var g=s(b),w=g[0],B=g[1];return(w+B)*3/4-B}function d(b,g,w){return(g+w)*3/4-w}function u(b){var g,w=s(b),B=w[0],T=w[1],H=new n(d(b,B,T)),N=0,X=T>0?B-4:B,P;for(P=0;P<X;P+=4)g=t[b.charCodeAt(P)]<<18|t[b.charCodeAt(P+1)]<<12|t[b.charCodeAt(P+2)]<<6|t[b.charCodeAt(P+3)],H[N++]=g>>16&255,H[N++]=g>>8&255,H[N++]=g&255;return T===2&&(g=t[b.charCodeAt(P)]<<2|t[b.charCodeAt(P+1)]>>4,H[N++]=g&255),T===1&&(g=t[b.charCodeAt(P)]<<10|t[b.charCodeAt(P+1)]<<4|t[b.charCodeAt(P+2)]>>2,H[N++]=g>>8&255,H[N++]=g&255),H}function p(b){return e[b>>18&63]+e[b>>12&63]+e[b>>6&63]+e[b&63]}function h(b,g,w){for(var B,T=[],H=g;H<w;H+=3)B=(b[H]<<16&16711680)+(b[H+1]<<8&65280)+(b[H+2]&255),T.push(p(B));return T.join("")}function I(b){for(var g,w=b.length,B=w%3,T=[],H=16383,N=0,X=w-B;N<X;N+=H)T.push(h(b,N,N+H>X?X:N+H));return B===1?(g=b[w-1],T.push(e[g>>2]+e[g<<4&63]+"==")):B===2&&(g=(b[w-2]<<8)+b[w-1],T.push(e[g>>10]+e[g>>4&63]+e[g<<2&63]+"=")),T.join("")}return gn}var nr={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */var As;function nh(){return As||(As=1,nr.read=function(e,t,n,r,i){var o,s,a=i*8-r-1,d=(1<<a)-1,u=d>>1,p=-7,h=n?i-1:0,I=n?-1:1,b=e[t+h];for(h+=I,o=b&(1<<-p)-1,b>>=-p,p+=a;p>0;o=o*256+e[t+h],h+=I,p-=8);for(s=o&(1<<-p)-1,o>>=-p,p+=r;p>0;s=s*256+e[t+h],h+=I,p-=8);if(o===0)o=1-u;else{if(o===d)return s?NaN:(b?-1:1)*(1/0);s=s+Math.pow(2,r),o=o-u}return(b?-1:1)*s*Math.pow(2,o-r)},nr.write=function(e,t,n,r,i,o){var s,a,d,u=o*8-i-1,p=(1<<u)-1,h=p>>1,I=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,b=r?0:o-1,g=r?1:-1,w=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=p):(s=Math.floor(Math.log(t)/Math.LN2),t*(d=Math.pow(2,-s))<1&&(s--,d*=2),s+h>=1?t+=I/d:t+=I*Math.pow(2,1-h),t*d>=2&&(s++,d/=2),s+h>=p?(a=0,s=p):s+h>=1?(a=(t*d-1)*Math.pow(2,i),s=s+h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;e[n+b]=a&255,b+=g,a/=256,i-=8);for(s=s<<i|a,u+=i;u>0;e[n+b]=s&255,b+=g,s/=256,u-=8);e[n+b-g]|=w*128}),nr}/*!
14
- * The buffer module from node.js, for the browser.
15
- *
16
- * @author Feross Aboukhadijeh <https://feross.org>
17
- * @license MIT
18
- */var Cs;function rh(){return Cs||(Cs=1,(function(e){const t=th(),n=nh(),r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=a,e.SlowBuffer=H,e.INSPECT_MAX_BYTES=50;const i=2147483647;e.kMaxLength=i,a.TYPED_ARRAY_SUPPORT=o(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function o(){try{const _=new Uint8Array(1),c={foo:function(){return 42}};return Object.setPrototypeOf(c,Uint8Array.prototype),Object.setPrototypeOf(_,c),_.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function s(_){if(_>i)throw new RangeError('The value "'+_+'" is invalid for option "size"');const c=new Uint8Array(_);return Object.setPrototypeOf(c,a.prototype),c}function a(_,c,l){if(typeof _=="number"){if(typeof c=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return h(_)}return d(_,c,l)}a.poolSize=8192;function d(_,c,l){if(typeof _=="string")return I(_,c);if(ArrayBuffer.isView(_))return g(_);if(_==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof _);if(ye(_,ArrayBuffer)||_&&ye(_.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ye(_,SharedArrayBuffer)||_&&ye(_.buffer,SharedArrayBuffer)))return w(_,c,l);if(typeof _=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const L=_.valueOf&&_.valueOf();if(L!=null&&L!==_)return a.from(L,c,l);const $=B(_);if($)return $;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof _[Symbol.toPrimitive]=="function")return a.from(_[Symbol.toPrimitive]("string"),c,l);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof _)}a.from=function(_,c,l){return d(_,c,l)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function u(_){if(typeof _!="number")throw new TypeError('"size" argument must be of type number');if(_<0)throw new RangeError('The value "'+_+'" is invalid for option "size"')}function p(_,c,l){return u(_),_<=0?s(_):c!==void 0?typeof l=="string"?s(_).fill(c,l):s(_).fill(c):s(_)}a.alloc=function(_,c,l){return p(_,c,l)};function h(_){return u(_),s(_<0?0:T(_)|0)}a.allocUnsafe=function(_){return h(_)},a.allocUnsafeSlow=function(_){return h(_)};function I(_,c){if((typeof c!="string"||c==="")&&(c="utf8"),!a.isEncoding(c))throw new TypeError("Unknown encoding: "+c);const l=N(_,c)|0;let L=s(l);const $=L.write(_,c);return $!==l&&(L=L.slice(0,$)),L}function b(_){const c=_.length<0?0:T(_.length)|0,l=s(c);for(let L=0;L<c;L+=1)l[L]=_[L]&255;return l}function g(_){if(ye(_,Uint8Array)){const c=new Uint8Array(_);return w(c.buffer,c.byteOffset,c.byteLength)}return b(_)}function w(_,c,l){if(c<0||_.byteLength<c)throw new RangeError('"offset" is outside of buffer bounds');if(_.byteLength<c+(l||0))throw new RangeError('"length" is outside of buffer bounds');let L;return c===void 0&&l===void 0?L=new Uint8Array(_):l===void 0?L=new Uint8Array(_,c):L=new Uint8Array(_,c,l),Object.setPrototypeOf(L,a.prototype),L}function B(_){if(a.isBuffer(_)){const c=T(_.length)|0,l=s(c);return l.length===0||_.copy(l,0,0,c),l}if(_.length!==void 0)return typeof _.length!="number"||pe(_.length)?s(0):b(_);if(_.type==="Buffer"&&Array.isArray(_.data))return b(_.data)}function T(_){if(_>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return _|0}function H(_){return+_!=_&&(_=0),a.alloc(+_)}a.isBuffer=function(c){return c!=null&&c._isBuffer===!0&&c!==a.prototype},a.compare=function(c,l){if(ye(c,Uint8Array)&&(c=a.from(c,c.offset,c.byteLength)),ye(l,Uint8Array)&&(l=a.from(l,l.offset,l.byteLength)),!a.isBuffer(c)||!a.isBuffer(l))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(c===l)return 0;let L=c.length,$=l.length;for(let ee=0,re=Math.min(L,$);ee<re;++ee)if(c[ee]!==l[ee]){L=c[ee],$=l[ee];break}return L<$?-1:$<L?1:0},a.isEncoding=function(c){switch(String(c).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(c,l){if(!Array.isArray(c))throw new TypeError('"list" argument must be an Array of Buffers');if(c.length===0)return a.alloc(0);let L;if(l===void 0)for(l=0,L=0;L<c.length;++L)l+=c[L].length;const $=a.allocUnsafe(l);let ee=0;for(L=0;L<c.length;++L){let re=c[L];if(ye(re,Uint8Array))ee+re.length>$.length?(a.isBuffer(re)||(re=a.from(re)),re.copy($,ee)):Uint8Array.prototype.set.call($,re,ee);else if(a.isBuffer(re))re.copy($,ee);else throw new TypeError('"list" argument must be an Array of Buffers');ee+=re.length}return $};function N(_,c){if(a.isBuffer(_))return _.length;if(ArrayBuffer.isView(_)||ye(_,ArrayBuffer))return _.byteLength;if(typeof _!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof _);const l=_.length,L=arguments.length>2&&arguments[2]===!0;if(!L&&l===0)return 0;let $=!1;for(;;)switch(c){case"ascii":case"latin1":case"binary":return l;case"utf8":case"utf-8":return ue(_).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return l*2;case"hex":return l>>>1;case"base64":return fe(_).length;default:if($)return L?-1:ue(_).length;c=(""+c).toLowerCase(),$=!0}}a.byteLength=N;function X(_,c,l){let L=!1;if((c===void 0||c<0)&&(c=0),c>this.length||((l===void 0||l>this.length)&&(l=this.length),l<=0)||(l>>>=0,c>>>=0,l<=c))return"";for(_||(_="utf8");;)switch(_){case"hex":return C(this,c,l);case"utf8":case"utf-8":return Q(this,c,l);case"ascii":return x(this,c,l);case"latin1":case"binary":return S(this,c,l);case"base64":return Y(this,c,l);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return V(this,c,l);default:if(L)throw new TypeError("Unknown encoding: "+_);_=(_+"").toLowerCase(),L=!0}}a.prototype._isBuffer=!0;function P(_,c,l){const L=_[c];_[c]=_[l],_[l]=L}a.prototype.swap16=function(){const c=this.length;if(c%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let l=0;l<c;l+=2)P(this,l,l+1);return this},a.prototype.swap32=function(){const c=this.length;if(c%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let l=0;l<c;l+=4)P(this,l,l+3),P(this,l+1,l+2);return this},a.prototype.swap64=function(){const c=this.length;if(c%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let l=0;l<c;l+=8)P(this,l,l+7),P(this,l+1,l+6),P(this,l+2,l+5),P(this,l+3,l+4);return this},a.prototype.toString=function(){const c=this.length;return c===0?"":arguments.length===0?Q(this,0,c):X.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(c){if(!a.isBuffer(c))throw new TypeError("Argument must be a Buffer");return this===c?!0:a.compare(this,c)===0},a.prototype.inspect=function(){let c="";const l=e.INSPECT_MAX_BYTES;return c=this.toString("hex",0,l).replace(/(.{2})/g,"$1 ").trim(),this.length>l&&(c+=" ... "),"<Buffer "+c+">"},r&&(a.prototype[r]=a.prototype.inspect),a.prototype.compare=function(c,l,L,$,ee){if(ye(c,Uint8Array)&&(c=a.from(c,c.offset,c.byteLength)),!a.isBuffer(c))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof c);if(l===void 0&&(l=0),L===void 0&&(L=c?c.length:0),$===void 0&&($=0),ee===void 0&&(ee=this.length),l<0||L>c.length||$<0||ee>this.length)throw new RangeError("out of range index");if($>=ee&&l>=L)return 0;if($>=ee)return-1;if(l>=L)return 1;if(l>>>=0,L>>>=0,$>>>=0,ee>>>=0,this===c)return 0;let re=ee-$,ge=L-l;const be=Math.min(re,ge),me=this.slice($,ee),Se=c.slice(l,L);for(let we=0;we<be;++we)if(me[we]!==Se[we]){re=me[we],ge=Se[we];break}return re<ge?-1:ge<re?1:0};function F(_,c,l,L,$){if(_.length===0)return-1;if(typeof l=="string"?(L=l,l=0):l>2147483647?l=2147483647:l<-2147483648&&(l=-2147483648),l=+l,pe(l)&&(l=$?0:_.length-1),l<0&&(l=_.length+l),l>=_.length){if($)return-1;l=_.length-1}else if(l<0)if($)l=0;else return-1;if(typeof c=="string"&&(c=a.from(c,L)),a.isBuffer(c))return c.length===0?-1:q(_,c,l,L,$);if(typeof c=="number")return c=c&255,typeof Uint8Array.prototype.indexOf=="function"?$?Uint8Array.prototype.indexOf.call(_,c,l):Uint8Array.prototype.lastIndexOf.call(_,c,l):q(_,[c],l,L,$);throw new TypeError("val must be string, number or Buffer")}function q(_,c,l,L,$){let ee=1,re=_.length,ge=c.length;if(L!==void 0&&(L=String(L).toLowerCase(),L==="ucs2"||L==="ucs-2"||L==="utf16le"||L==="utf-16le")){if(_.length<2||c.length<2)return-1;ee=2,re/=2,ge/=2,l/=2}function be(Se,we){return ee===1?Se[we]:Se.readUInt16BE(we*ee)}let me;if($){let Se=-1;for(me=l;me<re;me++)if(be(_,me)===be(c,Se===-1?0:me-Se)){if(Se===-1&&(Se=me),me-Se+1===ge)return Se*ee}else Se!==-1&&(me-=me-Se),Se=-1}else for(l+ge>re&&(l=re-ge),me=l;me>=0;me--){let Se=!0;for(let we=0;we<ge;we++)if(be(_,me+we)!==be(c,we)){Se=!1;break}if(Se)return me}return-1}a.prototype.includes=function(c,l,L){return this.indexOf(c,l,L)!==-1},a.prototype.indexOf=function(c,l,L){return F(this,c,l,L,!0)},a.prototype.lastIndexOf=function(c,l,L){return F(this,c,l,L,!1)};function W(_,c,l,L){l=Number(l)||0;const $=_.length-l;L?(L=Number(L),L>$&&(L=$)):L=$;const ee=c.length;L>ee/2&&(L=ee/2);let re;for(re=0;re<L;++re){const ge=parseInt(c.substr(re*2,2),16);if(pe(ge))return re;_[l+re]=ge}return re}function K(_,c,l,L){return Ee(ue(c,_.length-l),_,l,L)}function J(_,c,l,L){return Ee(de(c),_,l,L)}function te(_,c,l,L){return Ee(fe(c),_,l,L)}function ne(_,c,l,L){return Ee(he(c,_.length-l),_,l,L)}a.prototype.write=function(c,l,L,$){if(l===void 0)$="utf8",L=this.length,l=0;else if(L===void 0&&typeof l=="string")$=l,L=this.length,l=0;else if(isFinite(l))l=l>>>0,isFinite(L)?(L=L>>>0,$===void 0&&($="utf8")):($=L,L=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const ee=this.length-l;if((L===void 0||L>ee)&&(L=ee),c.length>0&&(L<0||l<0)||l>this.length)throw new RangeError("Attempt to write outside buffer bounds");$||($="utf8");let re=!1;for(;;)switch($){case"hex":return W(this,c,l,L);case"utf8":case"utf-8":return K(this,c,l,L);case"ascii":case"latin1":case"binary":return J(this,c,l,L);case"base64":return te(this,c,l,L);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ne(this,c,l,L);default:if(re)throw new TypeError("Unknown encoding: "+$);$=(""+$).toLowerCase(),re=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Y(_,c,l){return c===0&&l===_.length?t.fromByteArray(_):t.fromByteArray(_.slice(c,l))}function Q(_,c,l){l=Math.min(_.length,l);const L=[];let $=c;for(;$<l;){const ee=_[$];let re=null,ge=ee>239?4:ee>223?3:ee>191?2:1;if($+ge<=l){let be,me,Se,we;switch(ge){case 1:ee<128&&(re=ee);break;case 2:be=_[$+1],(be&192)===128&&(we=(ee&31)<<6|be&63,we>127&&(re=we));break;case 3:be=_[$+1],me=_[$+2],(be&192)===128&&(me&192)===128&&(we=(ee&15)<<12|(be&63)<<6|me&63,we>2047&&(we<55296||we>57343)&&(re=we));break;case 4:be=_[$+1],me=_[$+2],Se=_[$+3],(be&192)===128&&(me&192)===128&&(Se&192)===128&&(we=(ee&15)<<18|(be&63)<<12|(me&63)<<6|Se&63,we>65535&&we<1114112&&(re=we))}}re===null?(re=65533,ge=1):re>65535&&(re-=65536,L.push(re>>>10&1023|55296),re=56320|re&1023),L.push(re),$+=ge}return D(L)}const v=4096;function D(_){const c=_.length;if(c<=v)return String.fromCharCode.apply(String,_);let l="",L=0;for(;L<c;)l+=String.fromCharCode.apply(String,_.slice(L,L+=v));return l}function x(_,c,l){let L="";l=Math.min(_.length,l);for(let $=c;$<l;++$)L+=String.fromCharCode(_[$]&127);return L}function S(_,c,l){let L="";l=Math.min(_.length,l);for(let $=c;$<l;++$)L+=String.fromCharCode(_[$]);return L}function C(_,c,l){const L=_.length;(!c||c<0)&&(c=0),(!l||l<0||l>L)&&(l=L);let $="";for(let ee=c;ee<l;++ee)$+=le[_[ee]];return $}function V(_,c,l){const L=_.slice(c,l);let $="";for(let ee=0;ee<L.length-1;ee+=2)$+=String.fromCharCode(L[ee]+L[ee+1]*256);return $}a.prototype.slice=function(c,l){const L=this.length;c=~~c,l=l===void 0?L:~~l,c<0?(c+=L,c<0&&(c=0)):c>L&&(c=L),l<0?(l+=L,l<0&&(l=0)):l>L&&(l=L),l<c&&(l=c);const $=this.subarray(c,l);return Object.setPrototypeOf($,a.prototype),$};function f(_,c,l){if(_%1!==0||_<0)throw new RangeError("offset is not uint");if(_+c>l)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(c,l,L){c=c>>>0,l=l>>>0,L||f(c,l,this.length);let $=this[c],ee=1,re=0;for(;++re<l&&(ee*=256);)$+=this[c+re]*ee;return $},a.prototype.readUintBE=a.prototype.readUIntBE=function(c,l,L){c=c>>>0,l=l>>>0,L||f(c,l,this.length);let $=this[c+--l],ee=1;for(;l>0&&(ee*=256);)$+=this[c+--l]*ee;return $},a.prototype.readUint8=a.prototype.readUInt8=function(c,l){return c=c>>>0,l||f(c,1,this.length),this[c]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(c,l){return c=c>>>0,l||f(c,2,this.length),this[c]|this[c+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(c,l){return c=c>>>0,l||f(c,2,this.length),this[c]<<8|this[c+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(c,l){return c=c>>>0,l||f(c,4,this.length),(this[c]|this[c+1]<<8|this[c+2]<<16)+this[c+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(c,l){return c=c>>>0,l||f(c,4,this.length),this[c]*16777216+(this[c+1]<<16|this[c+2]<<8|this[c+3])},a.prototype.readBigUInt64LE=ae(function(c){c=c>>>0,R(c,"offset");const l=this[c],L=this[c+7];(l===void 0||L===void 0)&&G(c,this.length-8);const $=l+this[++c]*2**8+this[++c]*2**16+this[++c]*2**24,ee=this[++c]+this[++c]*2**8+this[++c]*2**16+L*2**24;return BigInt($)+(BigInt(ee)<<BigInt(32))}),a.prototype.readBigUInt64BE=ae(function(c){c=c>>>0,R(c,"offset");const l=this[c],L=this[c+7];(l===void 0||L===void 0)&&G(c,this.length-8);const $=l*2**24+this[++c]*2**16+this[++c]*2**8+this[++c],ee=this[++c]*2**24+this[++c]*2**16+this[++c]*2**8+L;return(BigInt($)<<BigInt(32))+BigInt(ee)}),a.prototype.readIntLE=function(c,l,L){c=c>>>0,l=l>>>0,L||f(c,l,this.length);let $=this[c],ee=1,re=0;for(;++re<l&&(ee*=256);)$+=this[c+re]*ee;return ee*=128,$>=ee&&($-=Math.pow(2,8*l)),$},a.prototype.readIntBE=function(c,l,L){c=c>>>0,l=l>>>0,L||f(c,l,this.length);let $=l,ee=1,re=this[c+--$];for(;$>0&&(ee*=256);)re+=this[c+--$]*ee;return ee*=128,re>=ee&&(re-=Math.pow(2,8*l)),re},a.prototype.readInt8=function(c,l){return c=c>>>0,l||f(c,1,this.length),this[c]&128?(255-this[c]+1)*-1:this[c]},a.prototype.readInt16LE=function(c,l){c=c>>>0,l||f(c,2,this.length);const L=this[c]|this[c+1]<<8;return L&32768?L|4294901760:L},a.prototype.readInt16BE=function(c,l){c=c>>>0,l||f(c,2,this.length);const L=this[c+1]|this[c]<<8;return L&32768?L|4294901760:L},a.prototype.readInt32LE=function(c,l){return c=c>>>0,l||f(c,4,this.length),this[c]|this[c+1]<<8|this[c+2]<<16|this[c+3]<<24},a.prototype.readInt32BE=function(c,l){return c=c>>>0,l||f(c,4,this.length),this[c]<<24|this[c+1]<<16|this[c+2]<<8|this[c+3]},a.prototype.readBigInt64LE=ae(function(c){c=c>>>0,R(c,"offset");const l=this[c],L=this[c+7];(l===void 0||L===void 0)&&G(c,this.length-8);const $=this[c+4]+this[c+5]*2**8+this[c+6]*2**16+(L<<24);return(BigInt($)<<BigInt(32))+BigInt(l+this[++c]*2**8+this[++c]*2**16+this[++c]*2**24)}),a.prototype.readBigInt64BE=ae(function(c){c=c>>>0,R(c,"offset");const l=this[c],L=this[c+7];(l===void 0||L===void 0)&&G(c,this.length-8);const $=(l<<24)+this[++c]*2**16+this[++c]*2**8+this[++c];return(BigInt($)<<BigInt(32))+BigInt(this[++c]*2**24+this[++c]*2**16+this[++c]*2**8+L)}),a.prototype.readFloatLE=function(c,l){return c=c>>>0,l||f(c,4,this.length),n.read(this,c,!0,23,4)},a.prototype.readFloatBE=function(c,l){return c=c>>>0,l||f(c,4,this.length),n.read(this,c,!1,23,4)},a.prototype.readDoubleLE=function(c,l){return c=c>>>0,l||f(c,8,this.length),n.read(this,c,!0,52,8)},a.prototype.readDoubleBE=function(c,l){return c=c>>>0,l||f(c,8,this.length),n.read(this,c,!1,52,8)};function y(_,c,l,L,$,ee){if(!a.isBuffer(_))throw new TypeError('"buffer" argument must be a Buffer instance');if(c>$||c<ee)throw new RangeError('"value" argument is out of bounds');if(l+L>_.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(c,l,L,$){if(c=+c,l=l>>>0,L=L>>>0,!$){const ge=Math.pow(2,8*L)-1;y(this,c,l,L,ge,0)}let ee=1,re=0;for(this[l]=c&255;++re<L&&(ee*=256);)this[l+re]=c/ee&255;return l+L},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(c,l,L,$){if(c=+c,l=l>>>0,L=L>>>0,!$){const ge=Math.pow(2,8*L)-1;y(this,c,l,L,ge,0)}let ee=L-1,re=1;for(this[l+ee]=c&255;--ee>=0&&(re*=256);)this[l+ee]=c/re&255;return l+L},a.prototype.writeUint8=a.prototype.writeUInt8=function(c,l,L){return c=+c,l=l>>>0,L||y(this,c,l,1,255,0),this[l]=c&255,l+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(c,l,L){return c=+c,l=l>>>0,L||y(this,c,l,2,65535,0),this[l]=c&255,this[l+1]=c>>>8,l+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(c,l,L){return c=+c,l=l>>>0,L||y(this,c,l,2,65535,0),this[l]=c>>>8,this[l+1]=c&255,l+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(c,l,L){return c=+c,l=l>>>0,L||y(this,c,l,4,4294967295,0),this[l+3]=c>>>24,this[l+2]=c>>>16,this[l+1]=c>>>8,this[l]=c&255,l+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(c,l,L){return c=+c,l=l>>>0,L||y(this,c,l,4,4294967295,0),this[l]=c>>>24,this[l+1]=c>>>16,this[l+2]=c>>>8,this[l+3]=c&255,l+4};function m(_,c,l,L,$){Z(c,L,$,_,l,7);let ee=Number(c&BigInt(4294967295));_[l++]=ee,ee=ee>>8,_[l++]=ee,ee=ee>>8,_[l++]=ee,ee=ee>>8,_[l++]=ee;let re=Number(c>>BigInt(32)&BigInt(4294967295));return _[l++]=re,re=re>>8,_[l++]=re,re=re>>8,_[l++]=re,re=re>>8,_[l++]=re,l}function E(_,c,l,L,$){Z(c,L,$,_,l,7);let ee=Number(c&BigInt(4294967295));_[l+7]=ee,ee=ee>>8,_[l+6]=ee,ee=ee>>8,_[l+5]=ee,ee=ee>>8,_[l+4]=ee;let re=Number(c>>BigInt(32)&BigInt(4294967295));return _[l+3]=re,re=re>>8,_[l+2]=re,re=re>>8,_[l+1]=re,re=re>>8,_[l]=re,l+8}a.prototype.writeBigUInt64LE=ae(function(c,l=0){return m(this,c,l,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=ae(function(c,l=0){return E(this,c,l,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(c,l,L,$){if(c=+c,l=l>>>0,!$){const be=Math.pow(2,8*L-1);y(this,c,l,L,be-1,-be)}let ee=0,re=1,ge=0;for(this[l]=c&255;++ee<L&&(re*=256);)c<0&&ge===0&&this[l+ee-1]!==0&&(ge=1),this[l+ee]=(c/re>>0)-ge&255;return l+L},a.prototype.writeIntBE=function(c,l,L,$){if(c=+c,l=l>>>0,!$){const be=Math.pow(2,8*L-1);y(this,c,l,L,be-1,-be)}let ee=L-1,re=1,ge=0;for(this[l+ee]=c&255;--ee>=0&&(re*=256);)c<0&&ge===0&&this[l+ee+1]!==0&&(ge=1),this[l+ee]=(c/re>>0)-ge&255;return l+L},a.prototype.writeInt8=function(c,l,L){return c=+c,l=l>>>0,L||y(this,c,l,1,127,-128),c<0&&(c=255+c+1),this[l]=c&255,l+1},a.prototype.writeInt16LE=function(c,l,L){return c=+c,l=l>>>0,L||y(this,c,l,2,32767,-32768),this[l]=c&255,this[l+1]=c>>>8,l+2},a.prototype.writeInt16BE=function(c,l,L){return c=+c,l=l>>>0,L||y(this,c,l,2,32767,-32768),this[l]=c>>>8,this[l+1]=c&255,l+2},a.prototype.writeInt32LE=function(c,l,L){return c=+c,l=l>>>0,L||y(this,c,l,4,2147483647,-2147483648),this[l]=c&255,this[l+1]=c>>>8,this[l+2]=c>>>16,this[l+3]=c>>>24,l+4},a.prototype.writeInt32BE=function(c,l,L){return c=+c,l=l>>>0,L||y(this,c,l,4,2147483647,-2147483648),c<0&&(c=4294967295+c+1),this[l]=c>>>24,this[l+1]=c>>>16,this[l+2]=c>>>8,this[l+3]=c&255,l+4},a.prototype.writeBigInt64LE=ae(function(c,l=0){return m(this,c,l,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=ae(function(c,l=0){return E(this,c,l,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function A(_,c,l,L,$,ee){if(l+L>_.length)throw new RangeError("Index out of range");if(l<0)throw new RangeError("Index out of range")}function M(_,c,l,L,$){return c=+c,l=l>>>0,$||A(_,c,l,4),n.write(_,c,l,L,23,4),l+4}a.prototype.writeFloatLE=function(c,l,L){return M(this,c,l,!0,L)},a.prototype.writeFloatBE=function(c,l,L){return M(this,c,l,!1,L)};function z(_,c,l,L,$){return c=+c,l=l>>>0,$||A(_,c,l,8),n.write(_,c,l,L,52,8),l+8}a.prototype.writeDoubleLE=function(c,l,L){return z(this,c,l,!0,L)},a.prototype.writeDoubleBE=function(c,l,L){return z(this,c,l,!1,L)},a.prototype.copy=function(c,l,L,$){if(!a.isBuffer(c))throw new TypeError("argument should be a Buffer");if(L||(L=0),!$&&$!==0&&($=this.length),l>=c.length&&(l=c.length),l||(l=0),$>0&&$<L&&($=L),$===L||c.length===0||this.length===0)return 0;if(l<0)throw new RangeError("targetStart out of bounds");if(L<0||L>=this.length)throw new RangeError("Index out of range");if($<0)throw new RangeError("sourceEnd out of bounds");$>this.length&&($=this.length),c.length-l<$-L&&($=c.length-l+L);const ee=$-L;return this===c&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(l,L,$):Uint8Array.prototype.set.call(c,this.subarray(L,$),l),ee},a.prototype.fill=function(c,l,L,$){if(typeof c=="string"){if(typeof l=="string"?($=l,l=0,L=this.length):typeof L=="string"&&($=L,L=this.length),$!==void 0&&typeof $!="string")throw new TypeError("encoding must be a string");if(typeof $=="string"&&!a.isEncoding($))throw new TypeError("Unknown encoding: "+$);if(c.length===1){const re=c.charCodeAt(0);($==="utf8"&&re<128||$==="latin1")&&(c=re)}}else typeof c=="number"?c=c&255:typeof c=="boolean"&&(c=Number(c));if(l<0||this.length<l||this.length<L)throw new RangeError("Out of range index");if(L<=l)return this;l=l>>>0,L=L===void 0?this.length:L>>>0,c||(c=0);let ee;if(typeof c=="number")for(ee=l;ee<L;++ee)this[ee]=c;else{const re=a.isBuffer(c)?c:a.from(c,$),ge=re.length;if(ge===0)throw new TypeError('The value "'+c+'" is invalid for argument "value"');for(ee=0;ee<L-l;++ee)this[ee+l]=re[ee%ge]}return this};const O={};function k(_,c,l){O[_]=class extends l{constructor(){super(),Object.defineProperty(this,"message",{value:c.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${_}]`,this.stack,delete this.name}get code(){return _}set code($){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:$,writable:!0})}toString(){return`${this.name} [${_}]: ${this.message}`}}}k("ERR_BUFFER_OUT_OF_BOUNDS",function(_){return _?`${_} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),k("ERR_INVALID_ARG_TYPE",function(_,c){return`The "${_}" argument must be of type number. Received type ${typeof c}`},TypeError),k("ERR_OUT_OF_RANGE",function(_,c,l){let L=`The value of "${_}" is out of range.`,$=l;return Number.isInteger(l)&&Math.abs(l)>2**32?$=U(String(l)):typeof l=="bigint"&&($=String(l),(l>BigInt(2)**BigInt(32)||l<-(BigInt(2)**BigInt(32)))&&($=U($)),$+="n"),L+=` It must be ${c}. Received ${$}`,L},RangeError);function U(_){let c="",l=_.length;const L=_[0]==="-"?1:0;for(;l>=L+4;l-=3)c=`_${_.slice(l-3,l)}${c}`;return`${_.slice(0,l)}${c}`}function j(_,c,l){R(c,"offset"),(_[c]===void 0||_[c+l]===void 0)&&G(c,_.length-(l+1))}function Z(_,c,l,L,$,ee){if(_>l||_<c){const re=typeof c=="bigint"?"n":"";let ge;throw c===0||c===BigInt(0)?ge=`>= 0${re} and < 2${re} ** ${(ee+1)*8}${re}`:ge=`>= -(2${re} ** ${(ee+1)*8-1}${re}) and < 2 ** ${(ee+1)*8-1}${re}`,new O.ERR_OUT_OF_RANGE("value",ge,_)}j(L,$,ee)}function R(_,c){if(typeof _!="number")throw new O.ERR_INVALID_ARG_TYPE(c,"number",_)}function G(_,c,l){throw Math.floor(_)!==_?(R(_,l),new O.ERR_OUT_OF_RANGE("offset","an integer",_)):c<0?new O.ERR_BUFFER_OUT_OF_BOUNDS:new O.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${c}`,_)}const oe=/[^+/0-9A-Za-z-_]/g;function se(_){if(_=_.split("=")[0],_=_.trim().replace(oe,""),_.length<2)return"";for(;_.length%4!==0;)_=_+"=";return _}function ue(_,c){c=c||1/0;let l;const L=_.length;let $=null;const ee=[];for(let re=0;re<L;++re){if(l=_.charCodeAt(re),l>55295&&l<57344){if(!$){if(l>56319){(c-=3)>-1&&ee.push(239,191,189);continue}else if(re+1===L){(c-=3)>-1&&ee.push(239,191,189);continue}$=l;continue}if(l<56320){(c-=3)>-1&&ee.push(239,191,189),$=l;continue}l=($-55296<<10|l-56320)+65536}else $&&(c-=3)>-1&&ee.push(239,191,189);if($=null,l<128){if((c-=1)<0)break;ee.push(l)}else if(l<2048){if((c-=2)<0)break;ee.push(l>>6|192,l&63|128)}else if(l<65536){if((c-=3)<0)break;ee.push(l>>12|224,l>>6&63|128,l&63|128)}else if(l<1114112){if((c-=4)<0)break;ee.push(l>>18|240,l>>12&63|128,l>>6&63|128,l&63|128)}else throw new Error("Invalid code point")}return ee}function de(_){const c=[];for(let l=0;l<_.length;++l)c.push(_.charCodeAt(l)&255);return c}function he(_,c){let l,L,$;const ee=[];for(let re=0;re<_.length&&!((c-=2)<0);++re)l=_.charCodeAt(re),L=l>>8,$=l%256,ee.push($),ee.push(L);return ee}function fe(_){return t.toByteArray(se(_))}function Ee(_,c,l,L){let $;for($=0;$<L&&!($+l>=c.length||$>=_.length);++$)c[$+l]=_[$];return $}function ye(_,c){return _ instanceof c||_!=null&&_.constructor!=null&&_.constructor.name!=null&&_.constructor.name===c.name}function pe(_){return _!==_}const le=(function(){const _="0123456789abcdef",c=new Array(256);for(let l=0;l<16;++l){const L=l*16;for(let $=0;$<16;++$)c[L+$]=_[l]+_[$]}return c})();function ae(_){return typeof BigInt>"u"?ce:_}function ce(){throw new Error("BigInt not supported")}})(Xr)),Xr}var ih=rh(),Jr={},Qr={},Ts;function Xe(){return Ts||(Ts=1,(function(e){/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */Object.defineProperty(e,"__esModule",{value:!0}),e.wrapCipher=e.Hash=e.nextTick=e.isLE=void 0,e.isBytes=t,e.abool=n,e.anumber=r,e.abytes=i,e.ahash=o,e.aexists=s,e.aoutput=a,e.u8=d,e.u32=u,e.clean=p,e.createView=h,e.bytesToHex=g,e.hexToBytes=T,e.hexToNumber=H,e.bytesToNumberBE=N,e.numberToBytesBE=X,e.utf8ToBytes=F,e.bytesToUtf8=q,e.toBytes=W,e.overlapBytes=K,e.complexOverlapBytes=J,e.concatBytes=te,e.checkOpts=ne,e.equalBytes=Y,e.getOutput=D,e.setBigUint64=x,e.u64Lengths=S,e.isAligned32=C,e.copyBytes=V;function t(f){return f instanceof Uint8Array||ArrayBuffer.isView(f)&&f.constructor.name==="Uint8Array"}function n(f){if(typeof f!="boolean")throw new Error(`boolean expected, not ${f}`)}function r(f){if(!Number.isSafeInteger(f)||f<0)throw new Error("positive integer expected, got "+f)}function i(f,...y){if(!t(f))throw new Error("Uint8Array expected");if(y.length>0&&!y.includes(f.length))throw new Error("Uint8Array expected of length "+y+", got length="+f.length)}function o(f){if(typeof f!="function"||typeof f.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");r(f.outputLen),r(f.blockLen)}function s(f,y=!0){if(f.destroyed)throw new Error("Hash instance has been destroyed");if(y&&f.finished)throw new Error("Hash#digest() has already been called")}function a(f,y){i(f);const m=y.outputLen;if(f.length<m)throw new Error("digestInto() expects output buffer of length at least "+m)}function d(f){return new Uint8Array(f.buffer,f.byteOffset,f.byteLength)}function u(f){return new Uint32Array(f.buffer,f.byteOffset,Math.floor(f.byteLength/4))}function p(...f){for(let y=0;y<f.length;y++)f[y].fill(0)}function h(f){return new DataView(f.buffer,f.byteOffset,f.byteLength)}e.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;const I=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",b=Array.from({length:256},(f,y)=>y.toString(16).padStart(2,"0"));function g(f){if(i(f),I)return f.toHex();let y="";for(let m=0;m<f.length;m++)y+=b[f[m]];return y}const w={_0:48,_9:57,A:65,F:70,a:97,f:102};function B(f){if(f>=w._0&&f<=w._9)return f-w._0;if(f>=w.A&&f<=w.F)return f-(w.A-10);if(f>=w.a&&f<=w.f)return f-(w.a-10)}function T(f){if(typeof f!="string")throw new Error("hex string expected, got "+typeof f);if(I)return Uint8Array.fromHex(f);const y=f.length,m=y/2;if(y%2)throw new Error("hex string expected, got unpadded hex of length "+y);const E=new Uint8Array(m);for(let A=0,M=0;A<m;A++,M+=2){const z=B(f.charCodeAt(M)),O=B(f.charCodeAt(M+1));if(z===void 0||O===void 0){const k=f[M]+f[M+1];throw new Error('hex string expected, got non-hex character "'+k+'" at index '+M)}E[A]=z*16+O}return E}function H(f){if(typeof f!="string")throw new Error("hex string expected, got "+typeof f);return BigInt(f===""?"0":"0x"+f)}function N(f){return H(g(f))}function X(f,y){return T(f.toString(16).padStart(y*2,"0"))}const P=async()=>{};e.nextTick=P;function F(f){if(typeof f!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(f))}function q(f){return new TextDecoder().decode(f)}function W(f){if(typeof f=="string")f=F(f);else if(t(f))f=V(f);else throw new Error("Uint8Array expected, got "+typeof f);return f}function K(f,y){return f.buffer===y.buffer&&f.byteOffset<y.byteOffset+y.byteLength&&y.byteOffset<f.byteOffset+f.byteLength}function J(f,y){if(K(f,y)&&f.byteOffset<y.byteOffset)throw new Error("complex overlap of input and output is not supported")}function te(...f){let y=0;for(let E=0;E<f.length;E++){const A=f[E];i(A),y+=A.length}const m=new Uint8Array(y);for(let E=0,A=0;E<f.length;E++){const M=f[E];m.set(M,A),A+=M.length}return m}function ne(f,y){if(y==null||typeof y!="object")throw new Error("options must be defined");return Object.assign(f,y)}function Y(f,y){if(f.length!==y.length)return!1;let m=0;for(let E=0;E<f.length;E++)m|=f[E]^y[E];return m===0}class Q{}e.Hash=Q;const v=(f,y)=>{function m(E,...A){if(i(E),!e.isLE)throw new Error("Non little-endian hardware is not yet supported");if(f.nonceLength!==void 0){const j=A[0];if(!j)throw new Error("nonce / iv required");f.varSizeNonce?i(j):i(j,f.nonceLength)}const M=f.tagLength;M&&A[1]!==void 0&&i(A[1]);const z=y(E,...A),O=(j,Z)=>{if(Z!==void 0){if(j!==2)throw new Error("cipher output not supported");i(Z)}};let k=!1;return{encrypt(j,Z){if(k)throw new Error("cannot encrypt() twice with same key + nonce");return k=!0,i(j),O(z.encrypt.length,Z),z.encrypt(j,Z)},decrypt(j,Z){if(i(j),M&&j.length<M)throw new Error("invalid ciphertext length: smaller than tagLength="+M);return O(z.decrypt.length,Z),z.decrypt(j,Z)}}}return Object.assign(m,f),m};e.wrapCipher=v;function D(f,y,m=!0){if(y===void 0)return new Uint8Array(f);if(y.length!==f)throw new Error("invalid output length, expected "+f+", got: "+y.length);if(m&&!C(y))throw new Error("invalid output, must be aligned");return y}function x(f,y,m,E){if(typeof f.setBigUint64=="function")return f.setBigUint64(y,m,E);const A=BigInt(32),M=BigInt(4294967295),z=Number(m>>A&M),O=Number(m&M),k=E?4:0,U=E?0:4;f.setUint32(y+k,z,E),f.setUint32(y+U,O,E)}function S(f,y,m){n(m);const E=new Uint8Array(16),A=h(E);return x(A,0,BigInt(y),m),x(A,8,BigInt(f),m),E}function C(f){return f.byteOffset%4===0}function V(f){return Uint8Array.from(f)}})(Qr)),Qr}var ei={},Me={},Os;function ti(){return Os||(Os=1,Object.defineProperty(Me,"__esModule",{value:!0}),Me.AEAD_TAG_LENGTH=Me.XCHACHA20_NONCE_LENGTH=Me.CURVE25519_PUBLIC_KEY_SIZE=Me.ETH_PUBLIC_KEY_SIZE=Me.UNCOMPRESSED_PUBLIC_KEY_SIZE=Me.COMPRESSED_PUBLIC_KEY_SIZE=Me.SECRET_KEY_LENGTH=void 0,Me.SECRET_KEY_LENGTH=32,Me.COMPRESSED_PUBLIC_KEY_SIZE=33,Me.UNCOMPRESSED_PUBLIC_KEY_SIZE=65,Me.ETH_PUBLIC_KEY_SIZE=64,Me.CURVE25519_PUBLIC_KEY_SIZE=32,Me.XCHACHA20_NONCE_LENGTH=24,Me.AEAD_TAG_LENGTH=16),Me}var Rs;function rr(){return Rs||(Rs=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ephemeralKeySize=e.symmetricNonceLength=e.symmetricAlgorithm=e.isHkdfKeyCompressed=e.isEphemeralKeyCompressed=e.ellipticCurve=e.ECIES_CONFIG=void 0;var t=ti(),n=(function(){function u(){this.ellipticCurve="secp256k1",this.isEphemeralKeyCompressed=!1,this.isHkdfKeyCompressed=!1,this.symmetricAlgorithm="aes-256-gcm",this.symmetricNonceLength=16}return u})();e.ECIES_CONFIG=new n;var r=function(){return e.ECIES_CONFIG.ellipticCurve};e.ellipticCurve=r;var i=function(){return e.ECIES_CONFIG.isEphemeralKeyCompressed};e.isEphemeralKeyCompressed=i;var o=function(){return e.ECIES_CONFIG.isHkdfKeyCompressed};e.isHkdfKeyCompressed=o;var s=function(){return e.ECIES_CONFIG.symmetricAlgorithm};e.symmetricAlgorithm=s;var a=function(){return e.ECIES_CONFIG.symmetricNonceLength};e.symmetricNonceLength=a;var d=function(){var u={secp256k1:e.ECIES_CONFIG.isEphemeralKeyCompressed?t.COMPRESSED_PUBLIC_KEY_SIZE:t.UNCOMPRESSED_PUBLIC_KEY_SIZE,x25519:t.CURVE25519_PUBLIC_KEY_SIZE,ed25519:t.CURVE25519_PUBLIC_KEY_SIZE};if(e.ECIES_CONFIG.ellipticCurve in u)return u[e.ECIES_CONFIG.ellipticCurve];throw new Error("Not implemented")};e.ephemeralKeySize=d})(ei)),ei}var ni={},mn={},Lt={},ri={},ii={},_n={},Ps;function oh(){return Ps||(Ps=1,Object.defineProperty(_n,"__esModule",{value:!0}),_n.crypto=void 0,_n.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0),_n}var Fs;function ks(){return Fs||(Fs=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.gcm=e.ctr=e.cbc=e.utils=void 0,e.randomBytes=r,e.getWebcryptoSubtle=i,e.managedNonce=o;const t=oh(),n=Xe();function r(u=32){if(t.crypto&&typeof t.crypto.getRandomValues=="function")return t.crypto.getRandomValues(new Uint8Array(u));if(t.crypto&&typeof t.crypto.randomBytes=="function")return Uint8Array.from(t.crypto.randomBytes(u));throw new Error("crypto.getRandomValues must be defined")}function i(){if(t.crypto&&typeof t.crypto.subtle=="object"&&t.crypto.subtle!=null)return t.crypto.subtle;throw new Error("crypto.subtle must be defined")}function o(u){const{nonceLength:p}=u;return(0,n.anumber)(p),((h,...I)=>({encrypt(b,...g){const w=r(p),B=u(h,w,...I).encrypt(b,...g),T=(0,n.concatBytes)(w,B);return B.fill(0),T},decrypt(b,...g){const w=b.subarray(0,p),B=b.subarray(p);return u(h,w,...I).decrypt(B,...g)}}))}e.utils={async encrypt(u,p,h,I){const b=i(),g=await b.importKey("raw",u,p,!0,["encrypt"]),w=await b.encrypt(h,g,I);return new Uint8Array(w)},async decrypt(u,p,h,I){const b=i(),g=await b.importKey("raw",u,p,!0,["decrypt"]),w=await b.decrypt(h,g,I);return new Uint8Array(w)}};const s={CBC:"AES-CBC",CTR:"AES-CTR",GCM:"AES-GCM"};function a(u,p,h){if(u===s.CBC)return{name:s.CBC,iv:p};if(u===s.CTR)return{name:s.CTR,counter:p,length:64};if(u===s.GCM)return h?{name:s.GCM,iv:p,additionalData:h}:{name:s.GCM,iv:p};throw new Error("unknown aes block mode")}function d(u){return(p,h,I)=>{(0,n.abytes)(p),(0,n.abytes)(h);const b={name:u,length:p.length*8},g=a(u,h,I);let w=!1;return{encrypt(B){if((0,n.abytes)(B),w)throw new Error("Cannot encrypt() twice with same key / nonce");return w=!0,e.utils.encrypt(p,b,g,B)},decrypt(B){return(0,n.abytes)(B),e.utils.decrypt(p,b,g,B)}}}}e.cbc=d(s.CBC),e.ctr=d(s.CTR),e.gcm=d(s.GCM)})(ii)),ii}var oi={},Le={},Ue={},si={},bn={},Ms;function sh(){return Ms||(Ms=1,Object.defineProperty(bn,"__esModule",{value:!0}),bn.crypto=void 0,bn.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0),bn}var Hs;function ut(){return Hs||(Hs=1,(function(e){/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.defineProperty(e,"__esModule",{value:!0}),e.wrapXOFConstructorWithOpts=e.wrapConstructorWithOpts=e.wrapConstructor=e.Hash=e.nextTick=e.swap32IfBE=e.byteSwapIfBE=e.swap8IfBE=e.isLE=void 0,e.isBytes=n,e.anumber=r,e.abytes=i,e.ahash=o,e.aexists=s,e.aoutput=a,e.u8=d,e.u32=u,e.clean=p,e.createView=h,e.rotr=I,e.rotl=b,e.byteSwap=g,e.byteSwap32=w,e.bytesToHex=H,e.hexToBytes=P,e.asyncLoop=q,e.utf8ToBytes=W,e.bytesToUtf8=K,e.toBytes=J,e.kdfInputToBytes=te,e.concatBytes=ne,e.checkOpts=Y,e.createHasher=v,e.createOptHasher=D,e.createXOFer=x,e.randomBytes=S;const t=sh();function n(C){return C instanceof Uint8Array||ArrayBuffer.isView(C)&&C.constructor.name==="Uint8Array"}function r(C){if(!Number.isSafeInteger(C)||C<0)throw new Error("positive integer expected, got "+C)}function i(C,...V){if(!n(C))throw new Error("Uint8Array expected");if(V.length>0&&!V.includes(C.length))throw new Error("Uint8Array expected of length "+V+", got length="+C.length)}function o(C){if(typeof C!="function"||typeof C.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");r(C.outputLen),r(C.blockLen)}function s(C,V=!0){if(C.destroyed)throw new Error("Hash instance has been destroyed");if(V&&C.finished)throw new Error("Hash#digest() has already been called")}function a(C,V){i(C);const f=V.outputLen;if(C.length<f)throw new Error("digestInto() expects output buffer of length at least "+f)}function d(C){return new Uint8Array(C.buffer,C.byteOffset,C.byteLength)}function u(C){return new Uint32Array(C.buffer,C.byteOffset,Math.floor(C.byteLength/4))}function p(...C){for(let V=0;V<C.length;V++)C[V].fill(0)}function h(C){return new DataView(C.buffer,C.byteOffset,C.byteLength)}function I(C,V){return C<<32-V|C>>>V}function b(C,V){return C<<V|C>>>32-V>>>0}e.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function g(C){return C<<24&4278190080|C<<8&16711680|C>>>8&65280|C>>>24&255}e.swap8IfBE=e.isLE?C=>C:C=>g(C),e.byteSwapIfBE=e.swap8IfBE;function w(C){for(let V=0;V<C.length;V++)C[V]=g(C[V]);return C}e.swap32IfBE=e.isLE?C=>C:w;const B=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",T=Array.from({length:256},(C,V)=>V.toString(16).padStart(2,"0"));function H(C){if(i(C),B)return C.toHex();let V="";for(let f=0;f<C.length;f++)V+=T[C[f]];return V}const N={_0:48,_9:57,A:65,F:70,a:97,f:102};function X(C){if(C>=N._0&&C<=N._9)return C-N._0;if(C>=N.A&&C<=N.F)return C-(N.A-10);if(C>=N.a&&C<=N.f)return C-(N.a-10)}function P(C){if(typeof C!="string")throw new Error("hex string expected, got "+typeof C);if(B)return Uint8Array.fromHex(C);const V=C.length,f=V/2;if(V%2)throw new Error("hex string expected, got unpadded hex of length "+V);const y=new Uint8Array(f);for(let m=0,E=0;m<f;m++,E+=2){const A=X(C.charCodeAt(E)),M=X(C.charCodeAt(E+1));if(A===void 0||M===void 0){const z=C[E]+C[E+1];throw new Error('hex string expected, got non-hex character "'+z+'" at index '+E)}y[m]=A*16+M}return y}const F=async()=>{};e.nextTick=F;async function q(C,V,f){let y=Date.now();for(let m=0;m<C;m++){f(m);const E=Date.now()-y;E>=0&&E<V||(await(0,e.nextTick)(),y+=E)}}function W(C){if(typeof C!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(C))}function K(C){return new TextDecoder().decode(C)}function J(C){return typeof C=="string"&&(C=W(C)),i(C),C}function te(C){return typeof C=="string"&&(C=W(C)),i(C),C}function ne(...C){let V=0;for(let y=0;y<C.length;y++){const m=C[y];i(m),V+=m.length}const f=new Uint8Array(V);for(let y=0,m=0;y<C.length;y++){const E=C[y];f.set(E,m),m+=E.length}return f}function Y(C,V){if(V!==void 0&&{}.toString.call(V)!=="[object Object]")throw new Error("options should be object or undefined");return Object.assign(C,V)}class Q{}e.Hash=Q;function v(C){const V=y=>C().update(J(y)).digest(),f=C();return V.outputLen=f.outputLen,V.blockLen=f.blockLen,V.create=()=>C(),V}function D(C){const V=(y,m)=>C(m).update(J(y)).digest(),f=C({});return V.outputLen=f.outputLen,V.blockLen=f.blockLen,V.create=y=>C(y),V}function x(C){const V=(y,m)=>C(m).update(J(y)).digest(),f=C({});return V.outputLen=f.outputLen,V.blockLen=f.blockLen,V.create=y=>C(y),V}e.wrapConstructor=v,e.wrapConstructorWithOpts=D,e.wrapXOFConstructorWithOpts=x;function S(C=32){if(t.crypto&&typeof t.crypto.getRandomValues=="function")return t.crypto.getRandomValues(new Uint8Array(C));if(t.crypto&&typeof t.crypto.randomBytes=="function")return Uint8Array.from(t.crypto.randomBytes(C));throw new Error("crypto.getRandomValues must be defined")}})(si)),si}var Us;function ah(){if(Us)return Ue;Us=1,Object.defineProperty(Ue,"__esModule",{value:!0}),Ue.SHA512_IV=Ue.SHA384_IV=Ue.SHA224_IV=Ue.SHA256_IV=Ue.HashMD=void 0,Ue.setBigUint64=t,Ue.Chi=n,Ue.Maj=r;const e=ut();function t(o,s,a,d){if(typeof o.setBigUint64=="function")return o.setBigUint64(s,a,d);const u=BigInt(32),p=BigInt(4294967295),h=Number(a>>u&p),I=Number(a&p),b=d?4:0,g=d?0:4;o.setUint32(s+b,h,d),o.setUint32(s+g,I,d)}function n(o,s,a){return o&s^~o&a}function r(o,s,a){return o&s^o&a^s&a}class i extends e.Hash{constructor(s,a,d,u){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=s,this.outputLen=a,this.padOffset=d,this.isLE=u,this.buffer=new Uint8Array(s),this.view=(0,e.createView)(this.buffer)}update(s){(0,e.aexists)(this),s=(0,e.toBytes)(s),(0,e.abytes)(s);const{view:a,buffer:d,blockLen:u}=this,p=s.length;for(let h=0;h<p;){const I=Math.min(u-this.pos,p-h);if(I===u){const b=(0,e.createView)(s);for(;u<=p-h;h+=u)this.process(b,h);continue}d.set(s.subarray(h,h+I),this.pos),this.pos+=I,h+=I,this.pos===u&&(this.process(a,0),this.pos=0)}return this.length+=s.length,this.roundClean(),this}digestInto(s){(0,e.aexists)(this),(0,e.aoutput)(s,this),this.finished=!0;const{buffer:a,view:d,blockLen:u,isLE:p}=this;let{pos:h}=this;a[h++]=128,(0,e.clean)(this.buffer.subarray(h)),this.padOffset>u-h&&(this.process(d,0),h=0);for(let B=h;B<u;B++)a[B]=0;t(d,u-8,BigInt(this.length*8),p),this.process(d,0);const I=(0,e.createView)(s),b=this.outputLen;if(b%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const g=b/4,w=this.get();if(g>w.length)throw new Error("_sha2: outputLen bigger than state");for(let B=0;B<g;B++)I.setUint32(4*B,w[B],p)}digest(){const{buffer:s,outputLen:a}=this;this.digestInto(s);const d=s.slice(0,a);return this.destroy(),d}_cloneInto(s){s||(s=new this.constructor),s.set(...this.get());const{blockLen:a,buffer:d,length:u,finished:p,destroyed:h,pos:I}=this;return s.destroyed=h,s.finished=p,s.length=u,s.pos=I,u%a&&s.buffer.set(d),s}clone(){return this._cloneInto()}}return Ue.HashMD=i,Ue.SHA256_IV=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ue.SHA224_IV=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),Ue.SHA384_IV=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),Ue.SHA512_IV=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),Ue}var ve={},Ns;function ch(){if(Ns)return ve;Ns=1,Object.defineProperty(ve,"__esModule",{value:!0}),ve.toBig=ve.shrSL=ve.shrSH=ve.rotrSL=ve.rotrSH=ve.rotrBL=ve.rotrBH=ve.rotr32L=ve.rotr32H=ve.rotlSL=ve.rotlSH=ve.rotlBL=ve.rotlBH=ve.add5L=ve.add5H=ve.add4L=ve.add4H=ve.add3L=ve.add3H=void 0,ve.add=T,ve.fromBig=n,ve.split=r;const e=BigInt(2**32-1),t=BigInt(32);function n(K,J=!1){return J?{h:Number(K&e),l:Number(K>>t&e)}:{h:Number(K>>t&e)|0,l:Number(K&e)|0}}function r(K,J=!1){const te=K.length;let ne=new Uint32Array(te),Y=new Uint32Array(te);for(let Q=0;Q<te;Q++){const{h:v,l:D}=n(K[Q],J);[ne[Q],Y[Q]]=[v,D]}return[ne,Y]}const i=(K,J)=>BigInt(K>>>0)<<t|BigInt(J>>>0);ve.toBig=i;const o=(K,J,te)=>K>>>te;ve.shrSH=o;const s=(K,J,te)=>K<<32-te|J>>>te;ve.shrSL=s;const a=(K,J,te)=>K>>>te|J<<32-te;ve.rotrSH=a;const d=(K,J,te)=>K<<32-te|J>>>te;ve.rotrSL=d;const u=(K,J,te)=>K<<64-te|J>>>te-32;ve.rotrBH=u;const p=(K,J,te)=>K>>>te-32|J<<64-te;ve.rotrBL=p;const h=(K,J)=>J;ve.rotr32H=h;const I=(K,J)=>K;ve.rotr32L=I;const b=(K,J,te)=>K<<te|J>>>32-te;ve.rotlSH=b;const g=(K,J,te)=>J<<te|K>>>32-te;ve.rotlSL=g;const w=(K,J,te)=>J<<te-32|K>>>64-te;ve.rotlBH=w;const B=(K,J,te)=>K<<te-32|J>>>64-te;ve.rotlBL=B;function T(K,J,te,ne){const Y=(J>>>0)+(ne>>>0);return{h:K+te+(Y/2**32|0)|0,l:Y|0}}const H=(K,J,te)=>(K>>>0)+(J>>>0)+(te>>>0);ve.add3L=H;const N=(K,J,te,ne)=>J+te+ne+(K/2**32|0)|0;ve.add3H=N;const X=(K,J,te,ne)=>(K>>>0)+(J>>>0)+(te>>>0)+(ne>>>0);ve.add4L=X;const P=(K,J,te,ne,Y)=>J+te+ne+Y+(K/2**32|0)|0;ve.add4H=P;const F=(K,J,te,ne,Y)=>(K>>>0)+(J>>>0)+(te>>>0)+(ne>>>0)+(Y>>>0);ve.add5L=F;const q=(K,J,te,ne,Y,Q)=>J+te+ne+Y+Q+(K/2**32|0)|0;ve.add5H=q;const W={fromBig:n,split:r,toBig:i,shrSH:o,shrSL:s,rotrSH:a,rotrSL:d,rotrBH:u,rotrBL:p,rotr32H:h,rotr32L:I,rotlSH:b,rotlSL:g,rotlBH:w,rotlBL:B,add:T,add3L:H,add3H:N,add4L:X,add4H:P,add5H:q,add5L:F};return ve.default=W,ve}var Ds;function ai(){if(Ds)return Le;Ds=1,Object.defineProperty(Le,"__esModule",{value:!0}),Le.sha512_224=Le.sha512_256=Le.sha384=Le.sha512=Le.sha224=Le.sha256=Le.SHA512_256=Le.SHA512_224=Le.SHA384=Le.SHA512=Le.SHA224=Le.SHA256=void 0;const e=ah(),t=ch(),n=ut(),r=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),i=new Uint32Array(64);class o extends e.HashMD{constructor(N=32){super(64,N,8,!1),this.A=e.SHA256_IV[0]|0,this.B=e.SHA256_IV[1]|0,this.C=e.SHA256_IV[2]|0,this.D=e.SHA256_IV[3]|0,this.E=e.SHA256_IV[4]|0,this.F=e.SHA256_IV[5]|0,this.G=e.SHA256_IV[6]|0,this.H=e.SHA256_IV[7]|0}get(){const{A:N,B:X,C:P,D:F,E:q,F:W,G:K,H:J}=this;return[N,X,P,F,q,W,K,J]}set(N,X,P,F,q,W,K,J){this.A=N|0,this.B=X|0,this.C=P|0,this.D=F|0,this.E=q|0,this.F=W|0,this.G=K|0,this.H=J|0}process(N,X){for(let Y=0;Y<16;Y++,X+=4)i[Y]=N.getUint32(X,!1);for(let Y=16;Y<64;Y++){const Q=i[Y-15],v=i[Y-2],D=(0,n.rotr)(Q,7)^(0,n.rotr)(Q,18)^Q>>>3,x=(0,n.rotr)(v,17)^(0,n.rotr)(v,19)^v>>>10;i[Y]=x+i[Y-7]+D+i[Y-16]|0}let{A:P,B:F,C:q,D:W,E:K,F:J,G:te,H:ne}=this;for(let Y=0;Y<64;Y++){const Q=(0,n.rotr)(K,6)^(0,n.rotr)(K,11)^(0,n.rotr)(K,25),v=ne+Q+(0,e.Chi)(K,J,te)+r[Y]+i[Y]|0,x=((0,n.rotr)(P,2)^(0,n.rotr)(P,13)^(0,n.rotr)(P,22))+(0,e.Maj)(P,F,q)|0;ne=te,te=J,J=K,K=W+v|0,W=q,q=F,F=P,P=v+x|0}P=P+this.A|0,F=F+this.B|0,q=q+this.C|0,W=W+this.D|0,K=K+this.E|0,J=J+this.F|0,te=te+this.G|0,ne=ne+this.H|0,this.set(P,F,q,W,K,J,te,ne)}roundClean(){(0,n.clean)(i)}destroy(){this.set(0,0,0,0,0,0,0,0),(0,n.clean)(this.buffer)}}Le.SHA256=o;class s extends o{constructor(){super(28),this.A=e.SHA224_IV[0]|0,this.B=e.SHA224_IV[1]|0,this.C=e.SHA224_IV[2]|0,this.D=e.SHA224_IV[3]|0,this.E=e.SHA224_IV[4]|0,this.F=e.SHA224_IV[5]|0,this.G=e.SHA224_IV[6]|0,this.H=e.SHA224_IV[7]|0}}Le.SHA224=s;const a=t.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(H=>BigInt(H))),d=a[0],u=a[1],p=new Uint32Array(80),h=new Uint32Array(80);class I extends e.HashMD{constructor(N=64){super(128,N,16,!1),this.Ah=e.SHA512_IV[0]|0,this.Al=e.SHA512_IV[1]|0,this.Bh=e.SHA512_IV[2]|0,this.Bl=e.SHA512_IV[3]|0,this.Ch=e.SHA512_IV[4]|0,this.Cl=e.SHA512_IV[5]|0,this.Dh=e.SHA512_IV[6]|0,this.Dl=e.SHA512_IV[7]|0,this.Eh=e.SHA512_IV[8]|0,this.El=e.SHA512_IV[9]|0,this.Fh=e.SHA512_IV[10]|0,this.Fl=e.SHA512_IV[11]|0,this.Gh=e.SHA512_IV[12]|0,this.Gl=e.SHA512_IV[13]|0,this.Hh=e.SHA512_IV[14]|0,this.Hl=e.SHA512_IV[15]|0}get(){const{Ah:N,Al:X,Bh:P,Bl:F,Ch:q,Cl:W,Dh:K,Dl:J,Eh:te,El:ne,Fh:Y,Fl:Q,Gh:v,Gl:D,Hh:x,Hl:S}=this;return[N,X,P,F,q,W,K,J,te,ne,Y,Q,v,D,x,S]}set(N,X,P,F,q,W,K,J,te,ne,Y,Q,v,D,x,S){this.Ah=N|0,this.Al=X|0,this.Bh=P|0,this.Bl=F|0,this.Ch=q|0,this.Cl=W|0,this.Dh=K|0,this.Dl=J|0,this.Eh=te|0,this.El=ne|0,this.Fh=Y|0,this.Fl=Q|0,this.Gh=v|0,this.Gl=D|0,this.Hh=x|0,this.Hl=S|0}process(N,X){for(let f=0;f<16;f++,X+=4)p[f]=N.getUint32(X),h[f]=N.getUint32(X+=4);for(let f=16;f<80;f++){const y=p[f-15]|0,m=h[f-15]|0,E=t.rotrSH(y,m,1)^t.rotrSH(y,m,8)^t.shrSH(y,m,7),A=t.rotrSL(y,m,1)^t.rotrSL(y,m,8)^t.shrSL(y,m,7),M=p[f-2]|0,z=h[f-2]|0,O=t.rotrSH(M,z,19)^t.rotrBH(M,z,61)^t.shrSH(M,z,6),k=t.rotrSL(M,z,19)^t.rotrBL(M,z,61)^t.shrSL(M,z,6),U=t.add4L(A,k,h[f-7],h[f-16]),j=t.add4H(U,E,O,p[f-7],p[f-16]);p[f]=j|0,h[f]=U|0}let{Ah:P,Al:F,Bh:q,Bl:W,Ch:K,Cl:J,Dh:te,Dl:ne,Eh:Y,El:Q,Fh:v,Fl:D,Gh:x,Gl:S,Hh:C,Hl:V}=this;for(let f=0;f<80;f++){const y=t.rotrSH(Y,Q,14)^t.rotrSH(Y,Q,18)^t.rotrBH(Y,Q,41),m=t.rotrSL(Y,Q,14)^t.rotrSL(Y,Q,18)^t.rotrBL(Y,Q,41),E=Y&v^~Y&x,A=Q&D^~Q&S,M=t.add5L(V,m,A,u[f],h[f]),z=t.add5H(M,C,y,E,d[f],p[f]),O=M|0,k=t.rotrSH(P,F,28)^t.rotrBH(P,F,34)^t.rotrBH(P,F,39),U=t.rotrSL(P,F,28)^t.rotrBL(P,F,34)^t.rotrBL(P,F,39),j=P&q^P&K^q&K,Z=F&W^F&J^W&J;C=x|0,V=S|0,x=v|0,S=D|0,v=Y|0,D=Q|0,{h:Y,l:Q}=t.add(te|0,ne|0,z|0,O|0),te=K|0,ne=J|0,K=q|0,J=W|0,q=P|0,W=F|0;const R=t.add3L(O,U,Z);P=t.add3H(R,z,k,j),F=R|0}({h:P,l:F}=t.add(this.Ah|0,this.Al|0,P|0,F|0)),{h:q,l:W}=t.add(this.Bh|0,this.Bl|0,q|0,W|0),{h:K,l:J}=t.add(this.Ch|0,this.Cl|0,K|0,J|0),{h:te,l:ne}=t.add(this.Dh|0,this.Dl|0,te|0,ne|0),{h:Y,l:Q}=t.add(this.Eh|0,this.El|0,Y|0,Q|0),{h:v,l:D}=t.add(this.Fh|0,this.Fl|0,v|0,D|0),{h:x,l:S}=t.add(this.Gh|0,this.Gl|0,x|0,S|0),{h:C,l:V}=t.add(this.Hh|0,this.Hl|0,C|0,V|0),this.set(P,F,q,W,K,J,te,ne,Y,Q,v,D,x,S,C,V)}roundClean(){(0,n.clean)(p,h)}destroy(){(0,n.clean)(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}Le.SHA512=I;class b extends I{constructor(){super(48),this.Ah=e.SHA384_IV[0]|0,this.Al=e.SHA384_IV[1]|0,this.Bh=e.SHA384_IV[2]|0,this.Bl=e.SHA384_IV[3]|0,this.Ch=e.SHA384_IV[4]|0,this.Cl=e.SHA384_IV[5]|0,this.Dh=e.SHA384_IV[6]|0,this.Dl=e.SHA384_IV[7]|0,this.Eh=e.SHA384_IV[8]|0,this.El=e.SHA384_IV[9]|0,this.Fh=e.SHA384_IV[10]|0,this.Fl=e.SHA384_IV[11]|0,this.Gh=e.SHA384_IV[12]|0,this.Gl=e.SHA384_IV[13]|0,this.Hh=e.SHA384_IV[14]|0,this.Hl=e.SHA384_IV[15]|0}}Le.SHA384=b;const g=Uint32Array.from([2352822216,424955298,1944164710,2312950998,502970286,855612546,1738396948,1479516111,258812777,2077511080,2011393907,79989058,1067287976,1780299464,286451373,2446758561]),w=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]);class B extends I{constructor(){super(28),this.Ah=g[0]|0,this.Al=g[1]|0,this.Bh=g[2]|0,this.Bl=g[3]|0,this.Ch=g[4]|0,this.Cl=g[5]|0,this.Dh=g[6]|0,this.Dl=g[7]|0,this.Eh=g[8]|0,this.El=g[9]|0,this.Fh=g[10]|0,this.Fl=g[11]|0,this.Gh=g[12]|0,this.Gl=g[13]|0,this.Hh=g[14]|0,this.Hl=g[15]|0}}Le.SHA512_224=B;class T extends I{constructor(){super(32),this.Ah=w[0]|0,this.Al=w[1]|0,this.Bh=w[2]|0,this.Bl=w[3]|0,this.Ch=w[4]|0,this.Cl=w[5]|0,this.Dh=w[6]|0,this.Dl=w[7]|0,this.Eh=w[8]|0,this.El=w[9]|0,this.Fh=w[10]|0,this.Fl=w[11]|0,this.Gh=w[12]|0,this.Gl=w[13]|0,this.Hh=w[14]|0,this.Hl=w[15]|0}}return Le.SHA512_256=T,Le.sha256=(0,n.createHasher)(()=>new o),Le.sha224=(0,n.createHasher)(()=>new s),Le.sha512=(0,n.createHasher)(()=>new I),Le.sha384=(0,n.createHasher)(()=>new b),Le.sha512_256=(0,n.createHasher)(()=>new T),Le.sha512_224=(0,n.createHasher)(()=>new B),Le}var Je={},ci={},$s;function _t(){return $s||($s=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.notImplemented=e.bitMask=e.utf8ToBytes=e.randomBytes=e.isBytes=e.hexToBytes=e.concatBytes=e.bytesToUtf8=e.bytesToHex=e.anumber=e.abytes=void 0,e.abool=o,e._abool2=s,e._abytes2=a,e.numberToHexUnpadded=d,e.hexToNumber=u,e.bytesToNumberBE=p,e.bytesToNumberLE=h,e.numberToBytesBE=I,e.numberToBytesLE=b,e.numberToVarBytesBE=g,e.ensureBytes=w,e.equalBytes=B,e.copyBytes=T,e.asciiToBytes=H,e.inRange=X,e.aInRange=P,e.bitLen=F,e.bitGet=q,e.bitSet=W,e.createHmacDrbg=J,e.validateObject=ne,e.isHash=Y,e._validateObject=Q,e.memoized=D;/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const t=ut();var n=ut();Object.defineProperty(e,"abytes",{enumerable:!0,get:function(){return n.abytes}}),Object.defineProperty(e,"anumber",{enumerable:!0,get:function(){return n.anumber}}),Object.defineProperty(e,"bytesToHex",{enumerable:!0,get:function(){return n.bytesToHex}}),Object.defineProperty(e,"bytesToUtf8",{enumerable:!0,get:function(){return n.bytesToUtf8}}),Object.defineProperty(e,"concatBytes",{enumerable:!0,get:function(){return n.concatBytes}}),Object.defineProperty(e,"hexToBytes",{enumerable:!0,get:function(){return n.hexToBytes}}),Object.defineProperty(e,"isBytes",{enumerable:!0,get:function(){return n.isBytes}}),Object.defineProperty(e,"randomBytes",{enumerable:!0,get:function(){return n.randomBytes}}),Object.defineProperty(e,"utf8ToBytes",{enumerable:!0,get:function(){return n.utf8ToBytes}});const r=BigInt(0),i=BigInt(1);function o(x,S){if(typeof S!="boolean")throw new Error(x+" boolean expected, got "+S)}function s(x,S=""){if(typeof x!="boolean"){const C=S&&`"${S}"`;throw new Error(C+"expected boolean, got type="+typeof x)}return x}function a(x,S,C=""){const V=(0,t.isBytes)(x),f=x?.length,y=S!==void 0;if(!V||y&&f!==S){const m=C&&`"${C}" `,E=y?` of length ${S}`:"",A=V?`length=${f}`:`type=${typeof x}`;throw new Error(m+"expected Uint8Array"+E+", got "+A)}return x}function d(x){const S=x.toString(16);return S.length&1?"0"+S:S}function u(x){if(typeof x!="string")throw new Error("hex string expected, got "+typeof x);return x===""?r:BigInt("0x"+x)}function p(x){return u((0,t.bytesToHex)(x))}function h(x){return(0,t.abytes)(x),u((0,t.bytesToHex)(Uint8Array.from(x).reverse()))}function I(x,S){return(0,t.hexToBytes)(x.toString(16).padStart(S*2,"0"))}function b(x,S){return I(x,S).reverse()}function g(x){return(0,t.hexToBytes)(d(x))}function w(x,S,C){let V;if(typeof S=="string")try{V=(0,t.hexToBytes)(S)}catch(y){throw new Error(x+" must be hex string or Uint8Array, cause: "+y)}else if((0,t.isBytes)(S))V=Uint8Array.from(S);else throw new Error(x+" must be hex string or Uint8Array");const f=V.length;if(typeof C=="number"&&f!==C)throw new Error(x+" of length "+C+" expected, got "+f);return V}function B(x,S){if(x.length!==S.length)return!1;let C=0;for(let V=0;V<x.length;V++)C|=x[V]^S[V];return C===0}function T(x){return Uint8Array.from(x)}function H(x){return Uint8Array.from(x,(S,C)=>{const V=S.charCodeAt(0);if(S.length!==1||V>127)throw new Error(`string contains non-ASCII character "${x[C]}" with code ${V} at position ${C}`);return V})}const N=x=>typeof x=="bigint"&&r<=x;function X(x,S,C){return N(x)&&N(S)&&N(C)&&S<=x&&x<C}function P(x,S,C,V){if(!X(S,C,V))throw new Error("expected valid "+x+": "+C+" <= n < "+V+", got "+S)}function F(x){let S;for(S=0;x>r;x>>=i,S+=1);return S}function q(x,S){return x>>BigInt(S)&i}function W(x,S,C){return x|(C?i:r)<<BigInt(S)}const K=x=>(i<<BigInt(x))-i;e.bitMask=K;function J(x,S,C){if(typeof x!="number"||x<2)throw new Error("hashLen must be a number");if(typeof S!="number"||S<2)throw new Error("qByteLen must be a number");if(typeof C!="function")throw new Error("hmacFn must be a function");const V=U=>new Uint8Array(U),f=U=>Uint8Array.of(U);let y=V(x),m=V(x),E=0;const A=()=>{y.fill(1),m.fill(0),E=0},M=(...U)=>C(m,y,...U),z=(U=V(0))=>{m=M(f(0),U),y=M(),U.length!==0&&(m=M(f(1),U),y=M())},O=()=>{if(E++>=1e3)throw new Error("drbg: tried 1000 values");let U=0;const j=[];for(;U<S;){y=M();const Z=y.slice();j.push(Z),U+=y.length}return(0,t.concatBytes)(...j)};return(U,j)=>{A(),z(U);let Z;for(;!(Z=j(O()));)z();return A(),Z}}const te={bigint:x=>typeof x=="bigint",function:x=>typeof x=="function",boolean:x=>typeof x=="boolean",string:x=>typeof x=="string",stringOrUint8Array:x=>typeof x=="string"||(0,t.isBytes)(x),isSafeInteger:x=>Number.isSafeInteger(x),array:x=>Array.isArray(x),field:(x,S)=>S.Fp.isValid(x),hash:x=>typeof x=="function"&&Number.isSafeInteger(x.outputLen)};function ne(x,S,C={}){const V=(f,y,m)=>{const E=te[y];if(typeof E!="function")throw new Error("invalid validator function");const A=x[f];if(!(m&&A===void 0)&&!E(A,x))throw new Error("param "+String(f)+" is invalid. Expected "+y+", got "+A)};for(const[f,y]of Object.entries(S))V(f,y,!1);for(const[f,y]of Object.entries(C))V(f,y,!0);return x}function Y(x){return typeof x=="function"&&Number.isSafeInteger(x.outputLen)}function Q(x,S,C={}){if(!x||typeof x!="object")throw new Error("expected valid options object");function V(f,y,m){const E=x[f];if(m&&E===void 0)return;const A=typeof E;if(A!==y||E===null)throw new Error(`param "${f}" is invalid: expected ${y}, got ${A}`)}Object.entries(S).forEach(([f,y])=>V(f,y,!1)),Object.entries(C).forEach(([f,y])=>V(f,y,!0))}const v=()=>{throw new Error("not implemented")};e.notImplemented=v;function D(x){const S=new WeakMap;return(C,...V)=>{const f=S.get(C);if(f!==void 0)return f;const y=x(C,...V);return S.set(C,y),y}}})(ci)),ci}var Ce={},Vs;function At(){if(Vs)return Ce;Vs=1,Object.defineProperty(Ce,"__esModule",{value:!0}),Ce.isNegativeLE=void 0,Ce.mod=h,Ce.pow=I,Ce.pow2=b,Ce.invert=g,Ce.tonelliShanks=N,Ce.FpSqrt=X,Ce.validateField=q,Ce.FpPow=W,Ce.FpInvertBatch=K,Ce.FpDiv=J,Ce.FpLegendre=te,Ce.FpIsSquare=ne,Ce.nLength=Y,Ce.Field=Q,Ce.FpSqrtOdd=v,Ce.FpSqrtEven=D,Ce.hashToPrivateScalar=x,Ce.getFieldBytesLength=S,Ce.getMinHashLength=C,Ce.mapHashToField=V;/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const e=_t(),t=BigInt(0),n=BigInt(1),r=BigInt(2),i=BigInt(3),o=BigInt(4),s=BigInt(5),a=BigInt(7),d=BigInt(8),u=BigInt(9),p=BigInt(16);function h(f,y){const m=f%y;return m>=t?m:y+m}function I(f,y,m){return W(Q(m),f,y)}function b(f,y,m){let E=f;for(;y-- >t;)E*=E,E%=m;return E}function g(f,y){if(f===t)throw new Error("invert: expected non-zero number");if(y<=t)throw new Error("invert: expected positive modulus, got "+y);let m=h(f,y),E=y,A=t,M=n;for(;m!==t;){const O=E/m,k=E%m,U=A-M*O;E=m,m=k,A=M,M=U}if(E!==n)throw new Error("invert: does not exist");return h(A,y)}function w(f,y,m){if(!f.eql(f.sqr(y),m))throw new Error("Cannot find square root")}function B(f,y){const m=(f.ORDER+n)/o,E=f.pow(y,m);return w(f,E,y),E}function T(f,y){const m=(f.ORDER-s)/d,E=f.mul(y,r),A=f.pow(E,m),M=f.mul(y,A),z=f.mul(f.mul(M,r),A),O=f.mul(M,f.sub(z,f.ONE));return w(f,O,y),O}function H(f){const y=Q(f),m=N(f),E=m(y,y.neg(y.ONE)),A=m(y,E),M=m(y,y.neg(E)),z=(f+a)/p;return(O,k)=>{let U=O.pow(k,z),j=O.mul(U,E);const Z=O.mul(U,A),R=O.mul(U,M),G=O.eql(O.sqr(j),k),oe=O.eql(O.sqr(Z),k);U=O.cmov(U,j,G),j=O.cmov(R,Z,oe);const se=O.eql(O.sqr(j),k),ue=O.cmov(U,j,se);return w(O,ue,k),ue}}function N(f){if(f<i)throw new Error("sqrt is not defined for small field");let y=f-n,m=0;for(;y%r===t;)y/=r,m++;let E=r;const A=Q(f);for(;te(A,E)===1;)if(E++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(m===1)return B;let M=A.pow(E,y);const z=(y+n)/r;return function(k,U){if(k.is0(U))return U;if(te(k,U)!==1)throw new Error("Cannot find square root");let j=m,Z=k.mul(k.ONE,M),R=k.pow(U,y),G=k.pow(U,z);for(;!k.eql(R,k.ONE);){if(k.is0(R))return k.ZERO;let oe=1,se=k.sqr(R);for(;!k.eql(se,k.ONE);)if(oe++,se=k.sqr(se),oe===j)throw new Error("Cannot find square root");const ue=n<<BigInt(j-oe-1),de=k.pow(Z,ue);j=oe,Z=k.sqr(de),R=k.mul(R,Z),G=k.mul(G,de)}return G}}function X(f){return f%o===i?B:f%d===s?T:f%p===u?H(f):N(f)}const P=(f,y)=>(h(f,y)&n)===n;Ce.isNegativeLE=P;const F=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function q(f){const y={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},m=F.reduce((E,A)=>(E[A]="function",E),y);return(0,e._validateObject)(f,m),f}function W(f,y,m){if(m<t)throw new Error("invalid exponent, negatives unsupported");if(m===t)return f.ONE;if(m===n)return y;let E=f.ONE,A=y;for(;m>t;)m&n&&(E=f.mul(E,A)),A=f.sqr(A),m>>=n;return E}function K(f,y,m=!1){const E=new Array(y.length).fill(m?f.ZERO:void 0),A=y.reduce((z,O,k)=>f.is0(O)?z:(E[k]=z,f.mul(z,O)),f.ONE),M=f.inv(A);return y.reduceRight((z,O,k)=>f.is0(O)?z:(E[k]=f.mul(z,E[k]),f.mul(z,O)),M),E}function J(f,y,m){return f.mul(y,typeof m=="bigint"?g(m,f.ORDER):f.inv(m))}function te(f,y){const m=(f.ORDER-n)/r,E=f.pow(y,m),A=f.eql(E,f.ONE),M=f.eql(E,f.ZERO),z=f.eql(E,f.neg(f.ONE));if(!A&&!M&&!z)throw new Error("invalid Legendre symbol result");return A?1:M?0:-1}function ne(f,y){return te(f,y)===1}function Y(f,y){y!==void 0&&(0,e.anumber)(y);const m=y!==void 0?y:f.toString(2).length,E=Math.ceil(m/8);return{nBitLength:m,nByteLength:E}}function Q(f,y,m=!1,E={}){if(f<=t)throw new Error("invalid field: expected ORDER > 0, got "+f);let A,M,z=!1,O;if(typeof y=="object"&&y!=null){if(E.sqrt||m)throw new Error("cannot specify opts in two arguments");const R=y;R.BITS&&(A=R.BITS),R.sqrt&&(M=R.sqrt),typeof R.isLE=="boolean"&&(m=R.isLE),typeof R.modFromBytes=="boolean"&&(z=R.modFromBytes),O=R.allowedLengths}else typeof y=="number"&&(A=y),E.sqrt&&(M=E.sqrt);const{nBitLength:k,nByteLength:U}=Y(f,A);if(U>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let j;const Z=Object.freeze({ORDER:f,isLE:m,BITS:k,BYTES:U,MASK:(0,e.bitMask)(k),ZERO:t,ONE:n,allowedLengths:O,create:R=>h(R,f),isValid:R=>{if(typeof R!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof R);return t<=R&&R<f},is0:R=>R===t,isValidNot0:R=>!Z.is0(R)&&Z.isValid(R),isOdd:R=>(R&n)===n,neg:R=>h(-R,f),eql:(R,G)=>R===G,sqr:R=>h(R*R,f),add:(R,G)=>h(R+G,f),sub:(R,G)=>h(R-G,f),mul:(R,G)=>h(R*G,f),pow:(R,G)=>W(Z,R,G),div:(R,G)=>h(R*g(G,f),f),sqrN:R=>R*R,addN:(R,G)=>R+G,subN:(R,G)=>R-G,mulN:(R,G)=>R*G,inv:R=>g(R,f),sqrt:M||(R=>(j||(j=X(f)),j(Z,R))),toBytes:R=>m?(0,e.numberToBytesLE)(R,U):(0,e.numberToBytesBE)(R,U),fromBytes:(R,G=!0)=>{if(O){if(!O.includes(R.length)||R.length>U)throw new Error("Field.fromBytes: expected "+O+" bytes, got "+R.length);const se=new Uint8Array(U);se.set(R,m?0:se.length-R.length),R=se}if(R.length!==U)throw new Error("Field.fromBytes: expected "+U+" bytes, got "+R.length);let oe=m?(0,e.bytesToNumberLE)(R):(0,e.bytesToNumberBE)(R);if(z&&(oe=h(oe,f)),!G&&!Z.isValid(oe))throw new Error("invalid field element: outside of range 0..ORDER");return oe},invertBatch:R=>K(Z,R),cmov:(R,G,oe)=>oe?G:R});return Object.freeze(Z)}function v(f,y){if(!f.isOdd)throw new Error("Field doesn't have isOdd");const m=f.sqrt(y);return f.isOdd(m)?m:f.neg(m)}function D(f,y){if(!f.isOdd)throw new Error("Field doesn't have isOdd");const m=f.sqrt(y);return f.isOdd(m)?f.neg(m):m}function x(f,y,m=!1){f=(0,e.ensureBytes)("privateHash",f);const E=f.length,A=Y(y).nByteLength+8;if(A<24||E<A||E>1024)throw new Error("hashToPrivateScalar: expected "+A+"-1024 bytes of input, got "+E);const M=m?(0,e.bytesToNumberLE)(f):(0,e.bytesToNumberBE)(f);return h(M,y-n)+n}function S(f){if(typeof f!="bigint")throw new Error("field order must be bigint");const y=f.toString(2).length;return Math.ceil(y/8)}function C(f){const y=S(f);return y+Math.ceil(y/2)}function V(f,y,m=!1){const E=f.length,A=S(y),M=C(y);if(E<16||E<M||E>1024)throw new Error("expected "+M+"-1024 bytes of input, got "+E);const z=m?(0,e.bytesToNumberLE)(f):(0,e.bytesToNumberBE)(f),O=h(z,y-n)+n;return m?(0,e.numberToBytesLE)(O,A):(0,e.numberToBytesBE)(O,A)}return Ce}var js;function li(){if(js)return Je;js=1,Object.defineProperty(Je,"__esModule",{value:!0}),Je.wNAF=void 0,Je.negateCt=i,Je.normalizeZ=o,Je.mulEndoUnsafe=B,Je.pippenger=T,Je.precomputeMSMUnsafe=H,Je.validateBasic=N,Je._createCurveFields=P;/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const e=_t(),t=At(),n=BigInt(0),r=BigInt(1);function i(F,q){const W=q.negate();return F?W:q}function o(F,q){const W=(0,t.FpInvertBatch)(F.Fp,q.map(K=>K.Z));return q.map((K,J)=>F.fromAffine(K.toAffine(W[J])))}function s(F,q){if(!Number.isSafeInteger(F)||F<=0||F>q)throw new Error("invalid window size, expected [1.."+q+"], got W="+F)}function a(F,q){s(F,q);const W=Math.ceil(q/F)+1,K=2**(F-1),J=2**F,te=(0,e.bitMask)(F),ne=BigInt(F);return{windows:W,windowSize:K,mask:te,maxNumber:J,shiftBy:ne}}function d(F,q,W){const{windowSize:K,mask:J,maxNumber:te,shiftBy:ne}=W;let Y=Number(F&J),Q=F>>ne;Y>K&&(Y-=te,Q+=r);const v=q*K,D=v+Math.abs(Y)-1,x=Y===0,S=Y<0,C=q%2!==0;return{nextN:Q,offset:D,isZero:x,isNeg:S,isNegF:C,offsetF:v}}function u(F,q){if(!Array.isArray(F))throw new Error("array expected");F.forEach((W,K)=>{if(!(W instanceof q))throw new Error("invalid point at index "+K)})}function p(F,q){if(!Array.isArray(F))throw new Error("array of scalars expected");F.forEach((W,K)=>{if(!q.isValid(W))throw new Error("invalid scalar at index "+K)})}const h=new WeakMap,I=new WeakMap;function b(F){return I.get(F)||1}function g(F){if(F!==n)throw new Error("invalid wNAF")}class w{constructor(q,W){this.BASE=q.BASE,this.ZERO=q.ZERO,this.Fn=q.Fn,this.bits=W}_unsafeLadder(q,W,K=this.ZERO){let J=q;for(;W>n;)W&r&&(K=K.add(J)),J=J.double(),W>>=r;return K}precomputeWindow(q,W){const{windows:K,windowSize:J}=a(W,this.bits),te=[];let ne=q,Y=ne;for(let Q=0;Q<K;Q++){Y=ne,te.push(Y);for(let v=1;v<J;v++)Y=Y.add(ne),te.push(Y);ne=Y.double()}return te}wNAF(q,W,K){if(!this.Fn.isValid(K))throw new Error("invalid scalar");let J=this.ZERO,te=this.BASE;const ne=a(q,this.bits);for(let Y=0;Y<ne.windows;Y++){const{nextN:Q,offset:v,isZero:D,isNeg:x,isNegF:S,offsetF:C}=d(K,Y,ne);K=Q,D?te=te.add(i(S,W[C])):J=J.add(i(x,W[v]))}return g(K),{p:J,f:te}}wNAFUnsafe(q,W,K,J=this.ZERO){const te=a(q,this.bits);for(let ne=0;ne<te.windows&&K!==n;ne++){const{nextN:Y,offset:Q,isZero:v,isNeg:D}=d(K,ne,te);if(K=Y,!v){const x=W[Q];J=J.add(D?x.negate():x)}}return g(K),J}getPrecomputes(q,W,K){let J=h.get(W);return J||(J=this.precomputeWindow(W,q),q!==1&&(typeof K=="function"&&(J=K(J)),h.set(W,J))),J}cached(q,W,K){const J=b(q);return this.wNAF(J,this.getPrecomputes(J,q,K),W)}unsafe(q,W,K,J){const te=b(q);return te===1?this._unsafeLadder(q,W,J):this.wNAFUnsafe(te,this.getPrecomputes(te,q,K),W,J)}createCache(q,W){s(W,this.bits),I.set(q,W),h.delete(q)}hasCache(q){return b(q)!==1}}Je.wNAF=w;function B(F,q,W,K){let J=q,te=F.ZERO,ne=F.ZERO;for(;W>n||K>n;)W&r&&(te=te.add(J)),K&r&&(ne=ne.add(J)),J=J.double(),W>>=r,K>>=r;return{p1:te,p2:ne}}function T(F,q,W,K){u(W,F),p(K,q);const J=W.length,te=K.length;if(J!==te)throw new Error("arrays of points and scalars must have equal length");const ne=F.ZERO,Y=(0,e.bitLen)(BigInt(J));let Q=1;Y>12?Q=Y-3:Y>4?Q=Y-2:Y>0&&(Q=2);const v=(0,e.bitMask)(Q),D=new Array(Number(v)+1).fill(ne),x=Math.floor((q.BITS-1)/Q)*Q;let S=ne;for(let C=x;C>=0;C-=Q){D.fill(ne);for(let f=0;f<te;f++){const y=K[f],m=Number(y>>BigInt(C)&v);D[m]=D[m].add(W[f])}let V=ne;for(let f=D.length-1,y=ne;f>0;f--)y=y.add(D[f]),V=V.add(y);if(S=S.add(V),C!==0)for(let f=0;f<Q;f++)S=S.double()}return S}function H(F,q,W,K){s(K,q.BITS),u(W,F);const J=F.ZERO,te=2**K-1,ne=Math.ceil(q.BITS/K),Y=(0,e.bitMask)(K),Q=W.map(v=>{const D=[];for(let x=0,S=v;x<te;x++)D.push(S),S=S.add(v);return D});return v=>{if(p(v,q),v.length>W.length)throw new Error("array of scalars must be smaller than array of points");let D=J;for(let x=0;x<ne;x++){if(D!==J)for(let C=0;C<K;C++)D=D.double();const S=BigInt(ne*K-(x+1)*K);for(let C=0;C<v.length;C++){const V=v[C],f=Number(V>>S&Y);f&&(D=D.add(Q[C][f-1]))}}return D}}function N(F){return(0,t.validateField)(F.Fp),(0,e.validateObject)(F,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,t.nLength)(F.n,F.nBitLength),...F,p:F.Fp.ORDER})}function X(F,q,W){if(q){if(q.ORDER!==F)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return(0,t.validateField)(q),q}else return(0,t.Field)(F,{isLE:W})}function P(F,q,W={},K){if(K===void 0&&(K=F==="edwards"),!q||typeof q!="object")throw new Error(`expected valid ${F} CURVE object`);for(const Q of["p","n","h"]){const v=q[Q];if(!(typeof v=="bigint"&&v>n))throw new Error(`CURVE.${Q} must be positive bigint`)}const J=X(q.p,W.Fp,K),te=X(q.n,W.Fn,K),Y=["Gx","Gy","a",F==="weierstrass"?"b":"d"];for(const Q of Y)if(!J.isValid(q[Q]))throw new Error(`CURVE.${Q} must be valid field element of CURVE.Fp`);return q=Object.freeze(Object.assign({},q)),{CURVE:q,Fp:J,Fn:te}}return Je}var bt={},qs;function lh(){if(qs)return bt;qs=1,Object.defineProperty(bt,"__esModule",{value:!0}),bt.PrimeEdwardsPoint=void 0,bt.edwards=d,bt.eddsa=p,bt.twistedEdwards=b;/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const e=_t(),t=li(),n=At(),r=BigInt(0),i=BigInt(1),o=BigInt(2),s=BigInt(8);function a(g,w,B,T){const H=g.sqr(B),N=g.sqr(T),X=g.add(g.mul(w.a,H),N),P=g.add(g.ONE,g.mul(w.d,g.mul(H,N)));return g.eql(X,P)}function d(g,w={}){const B=(0,t._createCurveFields)("edwards",g,w,w.FpFnLE),{Fp:T,Fn:H}=B;let N=B.CURVE;const{h:X}=N;(0,e._validateObject)(w,{},{uvRatio:"function"});const P=o<<BigInt(H.BYTES*8)-i,F=Q=>T.create(Q),q=w.uvRatio||((Q,v)=>{try{return{isValid:!0,value:T.sqrt(T.div(Q,v))}}catch{return{isValid:!1,value:r}}});if(!a(T,N,N.Gx,N.Gy))throw new Error("bad curve params: generator point");function W(Q,v,D=!1){const x=D?i:r;return(0,e.aInRange)("coordinate "+Q,v,x,P),v}function K(Q){if(!(Q instanceof ne))throw new Error("ExtendedPoint expected")}const J=(0,e.memoized)((Q,v)=>{const{X:D,Y:x,Z:S}=Q,C=Q.is0();v==null&&(v=C?s:T.inv(S));const V=F(D*v),f=F(x*v),y=T.mul(S,v);if(C)return{x:r,y:i};if(y!==i)throw new Error("invZ was invalid");return{x:V,y:f}}),te=(0,e.memoized)(Q=>{const{a:v,d:D}=N;if(Q.is0())throw new Error("bad point: ZERO");const{X:x,Y:S,Z:C,T:V}=Q,f=F(x*x),y=F(S*S),m=F(C*C),E=F(m*m),A=F(f*v),M=F(m*F(A+y)),z=F(E+F(D*F(f*y)));if(M!==z)throw new Error("bad point: equation left != right (1)");const O=F(x*S),k=F(C*V);if(O!==k)throw new Error("bad point: equation left != right (2)");return!0});class ne{constructor(v,D,x,S){this.X=W("x",v),this.Y=W("y",D),this.Z=W("z",x,!0),this.T=W("t",S),Object.freeze(this)}static CURVE(){return N}static fromAffine(v){if(v instanceof ne)throw new Error("extended point not allowed");const{x:D,y:x}=v||{};return W("x",D),W("y",x),new ne(D,x,i,F(D*x))}static fromBytes(v,D=!1){const x=T.BYTES,{a:S,d:C}=N;v=(0,e.copyBytes)((0,e._abytes2)(v,x,"point")),(0,e._abool2)(D,"zip215");const V=(0,e.copyBytes)(v),f=v[x-1];V[x-1]=f&-129;const y=(0,e.bytesToNumberLE)(V),m=D?P:T.ORDER;(0,e.aInRange)("point.y",y,r,m);const E=F(y*y),A=F(E-i),M=F(C*E-S);let{isValid:z,value:O}=q(A,M);if(!z)throw new Error("bad point: invalid y coordinate");const k=(O&i)===i,U=(f&128)!==0;if(!D&&O===r&&U)throw new Error("bad point: x=0 and x_0=1");return U!==k&&(O=F(-O)),ne.fromAffine({x:O,y})}static fromHex(v,D=!1){return ne.fromBytes((0,e.ensureBytes)("point",v),D)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(v=8,D=!0){return Y.createCache(this,v),D||this.multiply(o),this}assertValidity(){te(this)}equals(v){K(v);const{X:D,Y:x,Z:S}=this,{X:C,Y:V,Z:f}=v,y=F(D*f),m=F(C*S),E=F(x*f),A=F(V*S);return y===m&&E===A}is0(){return this.equals(ne.ZERO)}negate(){return new ne(F(-this.X),this.Y,this.Z,F(-this.T))}double(){const{a:v}=N,{X:D,Y:x,Z:S}=this,C=F(D*D),V=F(x*x),f=F(o*F(S*S)),y=F(v*C),m=D+x,E=F(F(m*m)-C-V),A=y+V,M=A-f,z=y-V,O=F(E*M),k=F(A*z),U=F(E*z),j=F(M*A);return new ne(O,k,j,U)}add(v){K(v);const{a:D,d:x}=N,{X:S,Y:C,Z:V,T:f}=this,{X:y,Y:m,Z:E,T:A}=v,M=F(S*y),z=F(C*m),O=F(f*x*A),k=F(V*E),U=F((S+C)*(y+m)-M-z),j=k-O,Z=k+O,R=F(z-D*M),G=F(U*j),oe=F(Z*R),se=F(U*R),ue=F(j*Z);return new ne(G,oe,ue,se)}subtract(v){return this.add(v.negate())}multiply(v){if(!H.isValidNot0(v))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:D,f:x}=Y.cached(this,v,S=>(0,t.normalizeZ)(ne,S));return(0,t.normalizeZ)(ne,[D,x])[0]}multiplyUnsafe(v,D=ne.ZERO){if(!H.isValid(v))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return v===r?ne.ZERO:this.is0()||v===i?this:Y.unsafe(this,v,x=>(0,t.normalizeZ)(ne,x),D)}isSmallOrder(){return this.multiplyUnsafe(X).is0()}isTorsionFree(){return Y.unsafe(this,N.n).is0()}toAffine(v){return J(this,v)}clearCofactor(){return X===i?this:this.multiplyUnsafe(X)}toBytes(){const{x:v,y:D}=this.toAffine(),x=T.toBytes(D);return x[x.length-1]|=v&i?128:0,x}toHex(){return(0,e.bytesToHex)(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(v){return(0,t.normalizeZ)(ne,v)}static msm(v,D){return(0,t.pippenger)(ne,H,v,D)}_setWindowSize(v){this.precompute(v)}toRawBytes(){return this.toBytes()}}ne.BASE=new ne(N.Gx,N.Gy,i,F(N.Gx*N.Gy)),ne.ZERO=new ne(r,i,i,r),ne.Fp=T,ne.Fn=H;const Y=new t.wNAF(ne,H.BITS);return ne.BASE.precompute(8),ne}class u{constructor(w){this.ep=w}static fromBytes(w){(0,e.notImplemented)()}static fromHex(w){(0,e.notImplemented)()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(w){return this.ep.toAffine(w)}toHex(){return(0,e.bytesToHex)(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(w){return this.assertSame(w),this.init(this.ep.add(w.ep))}subtract(w){return this.assertSame(w),this.init(this.ep.subtract(w.ep))}multiply(w){return this.init(this.ep.multiply(w))}multiplyUnsafe(w){return this.init(this.ep.multiplyUnsafe(w))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(w,B){return this.init(this.ep.precompute(w,B))}toRawBytes(){return this.toBytes()}}bt.PrimeEdwardsPoint=u;function p(g,w,B={}){if(typeof w!="function")throw new Error('"hash" function param is required');(0,e._validateObject)(B,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:T}=B,{BASE:H,Fp:N,Fn:X}=g,P=B.randomBytes||e.randomBytes,F=B.adjustScalarBytes||(m=>m),q=B.domain||((m,E,A)=>{if((0,e._abool2)(A,"phflag"),E.length||A)throw new Error("Contexts/pre-hash are not supported");return m});function W(m){return X.create((0,e.bytesToNumberLE)(m))}function K(m){const E=x.secretKey;m=(0,e.ensureBytes)("private key",m,E);const A=(0,e.ensureBytes)("hashed private key",w(m),2*E),M=F(A.slice(0,E)),z=A.slice(E,2*E),O=W(M);return{head:M,prefix:z,scalar:O}}function J(m){const{head:E,prefix:A,scalar:M}=K(m),z=H.multiply(M),O=z.toBytes();return{head:E,prefix:A,scalar:M,point:z,pointBytes:O}}function te(m){return J(m).pointBytes}function ne(m=Uint8Array.of(),...E){const A=(0,e.concatBytes)(...E);return W(w(q(A,(0,e.ensureBytes)("context",m),!!T)))}function Y(m,E,A={}){m=(0,e.ensureBytes)("message",m),T&&(m=T(m));const{prefix:M,scalar:z,pointBytes:O}=J(E),k=ne(A.context,M,m),U=H.multiply(k).toBytes(),j=ne(A.context,U,O,m),Z=X.create(k+j*z);if(!X.isValid(Z))throw new Error("sign failed: invalid s");const R=(0,e.concatBytes)(U,X.toBytes(Z));return(0,e._abytes2)(R,x.signature,"result")}const Q={zip215:!0};function v(m,E,A,M=Q){const{context:z,zip215:O}=M,k=x.signature;m=(0,e.ensureBytes)("signature",m,k),E=(0,e.ensureBytes)("message",E),A=(0,e.ensureBytes)("publicKey",A,x.publicKey),O!==void 0&&(0,e._abool2)(O,"zip215"),T&&(E=T(E));const U=k/2,j=m.subarray(0,U),Z=(0,e.bytesToNumberLE)(m.subarray(U,k));let R,G,oe;try{R=g.fromBytes(A,O),G=g.fromBytes(j,O),oe=H.multiplyUnsafe(Z)}catch{return!1}if(!O&&R.isSmallOrder())return!1;const se=ne(z,G.toBytes(),R.toBytes(),E);return G.add(R.multiplyUnsafe(se)).subtract(oe).clearCofactor().is0()}const D=N.BYTES,x={secretKey:D,publicKey:D,signature:2*D,seed:D};function S(m=P(x.seed)){return(0,e._abytes2)(m,x.seed,"seed")}function C(m){const E=y.randomSecretKey(m);return{secretKey:E,publicKey:te(E)}}function V(m){return(0,e.isBytes)(m)&&m.length===X.BYTES}function f(m,E){try{return!!g.fromBytes(m,E)}catch{return!1}}const y={getExtendedPublicKey:J,randomSecretKey:S,isValidSecretKey:V,isValidPublicKey:f,toMontgomery(m){const{y:E}=g.fromBytes(m),A=x.publicKey,M=A===32;if(!M&&A!==57)throw new Error("only defined for 25519 and 448");const z=M?N.div(i+E,i-E):N.div(E-i,E+i);return N.toBytes(z)},toMontgomerySecret(m){const E=x.secretKey;(0,e._abytes2)(m,E);const A=w(m.subarray(0,E));return F(A).subarray(0,E)},randomPrivateKey:S,precompute(m=8,E=g.BASE){return E.precompute(m,!1)}};return Object.freeze({keygen:C,getPublicKey:te,sign:Y,verify:v,utils:y,Point:g,lengths:x})}function h(g){const w={a:g.a,d:g.d,p:g.Fp.ORDER,n:g.n,h:g.h,Gx:g.Gx,Gy:g.Gy},B=g.Fp,T=(0,n.Field)(w.n,g.nBitLength,!0),H={Fp:B,Fn:T,uvRatio:g.uvRatio},N={randomBytes:g.randomBytes,adjustScalarBytes:g.adjustScalarBytes,domain:g.domain,prehash:g.prehash,mapToCurve:g.mapToCurve};return{CURVE:w,curveOpts:H,hash:g.hash,eddsaOpts:N}}function I(g,w){const B=w.Point;return Object.assign({},w,{ExtendedPoint:B,CURVE:g,nBitLength:B.Fn.BITS,nByteLength:B.Fn.BYTES})}function b(g){const{CURVE:w,curveOpts:B,hash:T,eddsaOpts:H}=h(g),N=d(w,B),X=p(N,T,H);return I(g,X)}return bt}var ui={},Ks;function Gs(){return Ks||(Ks=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e._DST_scalar=void 0,e.expand_message_xmd=d,e.expand_message_xof=u,e.hash_to_field=p,e.isogenyMap=h,e.createHasher=I;const t=_t(),n=At(),r=t.bytesToNumberBE;function i(b,g){if(s(b),s(g),b<0||b>=1<<8*g)throw new Error("invalid I2OSP input: "+b);const w=Array.from({length:g}).fill(0);for(let B=g-1;B>=0;B--)w[B]=b&255,b>>>=8;return new Uint8Array(w)}function o(b,g){const w=new Uint8Array(b.length);for(let B=0;B<b.length;B++)w[B]=b[B]^g[B];return w}function s(b){if(!Number.isSafeInteger(b))throw new Error("number expected")}function a(b){if(!(0,t.isBytes)(b)&&typeof b!="string")throw new Error("DST must be Uint8Array or string");return typeof b=="string"?(0,t.utf8ToBytes)(b):b}function d(b,g,w,B){(0,t.abytes)(b),s(w),g=a(g),g.length>255&&(g=B((0,t.concatBytes)((0,t.utf8ToBytes)("H2C-OVERSIZE-DST-"),g)));const{outputLen:T,blockLen:H}=B,N=Math.ceil(w/T);if(w>65535||N>255)throw new Error("expand_message_xmd: invalid lenInBytes");const X=(0,t.concatBytes)(g,i(g.length,1)),P=i(0,H),F=i(w,2),q=new Array(N),W=B((0,t.concatBytes)(P,b,F,i(0,1),X));q[0]=B((0,t.concatBytes)(W,i(1,1),X));for(let J=1;J<=N;J++){const te=[o(W,q[J-1]),i(J+1,1),X];q[J]=B((0,t.concatBytes)(...te))}return(0,t.concatBytes)(...q).slice(0,w)}function u(b,g,w,B,T){if((0,t.abytes)(b),s(w),g=a(g),g.length>255){const H=Math.ceil(2*B/8);g=T.create({dkLen:H}).update((0,t.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(g).digest()}if(w>65535||g.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return T.create({dkLen:w}).update(b).update(i(w,2)).update(g).update(i(g.length,1)).digest()}function p(b,g,w){(0,t._validateObject)(w,{p:"bigint",m:"number",k:"number",hash:"function"});const{p:B,k:T,m:H,hash:N,expand:X,DST:P}=w;if(!(0,t.isHash)(w.hash))throw new Error("expected valid hash");(0,t.abytes)(b),s(g);const F=B.toString(2).length,q=Math.ceil((F+T)/8),W=g*H*q;let K;if(X==="xmd")K=d(b,P,W,N);else if(X==="xof")K=u(b,P,W,T,N);else if(X==="_internal_pass")K=b;else throw new Error('expand must be "xmd" or "xof"');const J=new Array(g);for(let te=0;te<g;te++){const ne=new Array(H);for(let Y=0;Y<H;Y++){const Q=q*(Y+te*H),v=K.subarray(Q,Q+q);ne[Y]=(0,n.mod)(r(v),B)}J[te]=ne}return J}function h(b,g){const w=g.map(B=>Array.from(B).reverse());return(B,T)=>{const[H,N,X,P]=w.map(W=>W.reduce((K,J)=>b.add(b.mul(K,B),J))),[F,q]=(0,n.FpInvertBatch)(b,[N,P],!0);return B=b.mul(H,F),T=b.mul(T,b.mul(X,q)),{x:B,y:T}}}e._DST_scalar=(0,t.utf8ToBytes)("HashToScalar-");function I(b,g,w){if(typeof g!="function")throw new Error("mapToCurve() must be defined");function B(H){return b.fromAffine(g(H))}function T(H){const N=H.clearCofactor();return N.equals(b.ZERO)?b.ZERO:(N.assertValidity(),N)}return{defaults:w,hashToCurve(H,N){const X=Object.assign({},w,N),P=p(H,2,X),F=B(P[0]),q=B(P[1]);return T(F.add(q))},encodeToCurve(H,N){const X=w.encodeDST?{DST:w.encodeDST}:{},P=Object.assign({},w,X,N),F=p(H,1,P),q=B(F[0]);return T(q)},mapToCurve(H){if(!Array.isArray(H))throw new Error("expected array of bigints");for(const N of H)if(typeof N!="bigint")throw new Error("expected array of bigints");return T(B(H))},hashToScalar(H,N){const X=b.Fn.ORDER,P=Object.assign({},w,{p:X,m:1,DST:e._DST_scalar},N);return p(H,1,P)[0][0]}}}})(ui)),ui}var ir={},zs;function uh(){if(zs)return ir;zs=1,Object.defineProperty(ir,"__esModule",{value:!0}),ir.montgomery=s;/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const e=_t(),t=At(),n=BigInt(0),r=BigInt(1),i=BigInt(2);function o(a){return(0,e._validateObject)(a,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...a})}function s(a){const d=o(a),{P:u,type:p,adjustScalarBytes:h,powPminus2:I,randomBytes:b}=d,g=p==="x25519";if(!g&&p!=="x448")throw new Error("invalid type");const w=b||e.randomBytes,B=g?255:448,T=g?32:56,H=BigInt(g?9:5),N=BigInt(g?121665:39081),X=g?i**BigInt(254):i**BigInt(447),P=g?BigInt(8)*i**BigInt(251)-r:BigInt(4)*i**BigInt(445)-r,F=X+P+r,q=V=>(0,t.mod)(V,u),W=K(H);function K(V){return(0,e.numberToBytesLE)(q(V),T)}function J(V){const f=(0,e.ensureBytes)("u coordinate",V,T);return g&&(f[31]&=127),q((0,e.bytesToNumberLE)(f))}function te(V){return(0,e.bytesToNumberLE)(h((0,e.ensureBytes)("scalar",V,T)))}function ne(V,f){const y=v(J(f),te(V));if(y===n)throw new Error("invalid private or public key received");return K(y)}function Y(V){return ne(V,W)}function Q(V,f,y){const m=q(V*(f-y));return f=q(f-m),y=q(y+m),{x_2:f,x_3:y}}function v(V,f){(0,e.aInRange)("u",V,n,u),(0,e.aInRange)("scalar",f,X,F);const y=f,m=V;let E=r,A=n,M=V,z=r,O=n;for(let U=BigInt(B-1);U>=n;U--){const j=y>>U&r;O^=j,{x_2:E,x_3:M}=Q(O,E,M),{x_2:A,x_3:z}=Q(O,A,z),O=j;const Z=E+A,R=q(Z*Z),G=E-A,oe=q(G*G),se=R-oe,ue=M+z,de=M-z,he=q(de*Z),fe=q(ue*G),Ee=he+fe,ye=he-fe;M=q(Ee*Ee),z=q(m*q(ye*ye)),E=q(R*oe),A=q(se*(R+q(N*se)))}({x_2:E,x_3:M}=Q(O,E,M)),{x_2:A,x_3:z}=Q(O,A,z);const k=I(A);return q(E*k)}const D={secretKey:T,publicKey:T,seed:T},x=(V=w(T))=>((0,e.abytes)(V,D.seed),V);function S(V){const f=x(V);return{secretKey:f,publicKey:Y(f)}}return{keygen:S,getSharedSecret:(V,f)=>ne(V,f),getPublicKey:V=>Y(V),scalarMult:ne,scalarMultBase:Y,utils:{randomSecretKey:x,randomPrivateKey:x},GuBytes:W.slice(),lengths:D}}return ir}var Zs;function dh(){return Zs||(Zs=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.hash_to_ristretto255=e.hashToRistretto255=e.encodeToCurve=e.hashToCurve=e.RistrettoPoint=e.edwardsToMontgomery=e.ED25519_TORSION_SUBGROUP=e.ristretto255_hasher=e.ristretto255=e.ed25519_hasher=e.x25519=e.ed25519ph=e.ed25519ctx=e.ed25519=void 0,e.edwardsToMontgomeryPub=M,e.edwardsToMontgomeryPriv=z;/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const t=ai(),n=ut(),r=li(),i=lh(),o=Gs(),s=At(),a=uh(),d=_t(),u=BigInt(0),p=BigInt(1),h=BigInt(2),I=BigInt(3),b=BigInt(5),g=BigInt(8),w=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),B={p:w,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:g,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function T(O){const k=BigInt(10),U=BigInt(20),j=BigInt(40),Z=BigInt(80),R=w,oe=O*O%R*O%R,se=(0,s.pow2)(oe,h,R)*oe%R,ue=(0,s.pow2)(se,p,R)*O%R,de=(0,s.pow2)(ue,b,R)*ue%R,he=(0,s.pow2)(de,k,R)*de%R,fe=(0,s.pow2)(he,U,R)*he%R,Ee=(0,s.pow2)(fe,j,R)*fe%R,ye=(0,s.pow2)(Ee,Z,R)*Ee%R,pe=(0,s.pow2)(ye,Z,R)*Ee%R,le=(0,s.pow2)(pe,k,R)*de%R;return{pow_p_5_8:(0,s.pow2)(le,h,R)*O%R,b2:oe}}function H(O){return O[0]&=248,O[31]&=127,O[31]|=64,O}const N=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function X(O,k){const U=w,j=(0,s.mod)(k*k*k,U),Z=(0,s.mod)(j*j*k,U),R=T(O*Z).pow_p_5_8;let G=(0,s.mod)(O*j*R,U);const oe=(0,s.mod)(k*G*G,U),se=G,ue=(0,s.mod)(G*N,U),de=oe===O,he=oe===(0,s.mod)(-O,U),fe=oe===(0,s.mod)(-O*N,U);return de&&(G=se),(he||fe)&&(G=ue),(0,s.isNegativeLE)(G,U)&&(G=(0,s.mod)(-G,U)),{isValid:de||he,value:G}}const P=(0,s.Field)(B.p,{isLE:!0}),F=(0,s.Field)(B.n,{isLE:!0}),q={...B,Fp:P,hash:t.sha512,adjustScalarBytes:H,uvRatio:X};e.ed25519=(0,i.twistedEdwards)(q);function W(O,k,U){if(k.length>255)throw new Error("Context is too big");return(0,n.concatBytes)((0,n.utf8ToBytes)("SigEd25519 no Ed25519 collisions"),new Uint8Array([U?1:0,k.length]),k,O)}e.ed25519ctx=(0,i.twistedEdwards)({...q,domain:W}),e.ed25519ph=(0,i.twistedEdwards)(Object.assign({},q,{domain:W,prehash:t.sha512})),e.x25519=(()=>{const O=P.ORDER;return(0,a.montgomery)({P:O,type:"x25519",powPminus2:k=>{const{pow_p_5_8:U,b2:j}=T(k);return(0,s.mod)((0,s.pow2)(U,I,O)*j,O)},adjustScalarBytes:H})})();const K=(w+I)/g,J=P.pow(h,K),te=P.sqrt(P.neg(P.ONE));function ne(O){const k=(w-b)/g,U=BigInt(486662);let j=P.sqr(O);j=P.mul(j,h);let Z=P.add(j,P.ONE),R=P.neg(U),G=P.sqr(Z),oe=P.mul(G,Z),se=P.mul(j,U);se=P.mul(se,R),se=P.add(se,G),se=P.mul(se,R);let ue=P.sqr(oe);G=P.sqr(ue),ue=P.mul(ue,oe),ue=P.mul(ue,se),G=P.mul(G,ue);let de=P.pow(G,k);de=P.mul(de,ue);let he=P.mul(de,te);G=P.sqr(de),G=P.mul(G,oe);let fe=P.eql(G,se),Ee=P.cmov(he,de,fe),ye=P.mul(R,j),pe=P.mul(de,O);pe=P.mul(pe,J);let le=P.mul(pe,te),ae=P.mul(se,j);G=P.sqr(pe),G=P.mul(G,oe);let ce=P.eql(G,ae),_=P.cmov(le,pe,ce);G=P.sqr(Ee),G=P.mul(G,oe);let c=P.eql(G,se),l=P.cmov(ye,R,c),L=P.cmov(_,Ee,c),$=P.isOdd(L);return L=P.cmov(L,P.neg(L),c!==$),{xMn:l,xMd:Z,yMn:L,yMd:p}}const Y=(0,s.FpSqrtEven)(P,P.neg(BigInt(486664)));function Q(O){const{xMn:k,xMd:U,yMn:j,yMd:Z}=ne(O);let R=P.mul(k,Z);R=P.mul(R,Y);let G=P.mul(U,j),oe=P.sub(k,U),se=P.add(k,U),ue=P.mul(G,se),de=P.eql(ue,P.ZERO);R=P.cmov(R,P.ZERO,de),G=P.cmov(G,P.ONE,de),oe=P.cmov(oe,P.ONE,de),se=P.cmov(se,P.ONE,de);const[he,fe]=(0,s.FpInvertBatch)(P,[G,se],!0);return{x:P.mul(R,he),y:P.mul(oe,fe)}}e.ed25519_hasher=(0,o.createHasher)(e.ed25519.Point,O=>Q(O[0]),{DST:"edwards25519_XMD:SHA-512_ELL2_RO_",encodeDST:"edwards25519_XMD:SHA-512_ELL2_NU_",p:w,m:1,k:128,expand:"xmd",hash:t.sha512});const v=N,D=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),x=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),S=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),C=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),V=O=>X(p,O),f=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),y=O=>e.ed25519.Point.Fp.create((0,d.bytesToNumberLE)(O)&f);function m(O){const{d:k}=B,U=w,j=ae=>P.create(ae),Z=j(v*O*O),R=j((Z+p)*S);let G=BigInt(-1);const oe=j((G-k*Z)*j(Z+k));let{isValid:se,value:ue}=X(R,oe),de=j(ue*O);(0,s.isNegativeLE)(de,U)||(de=j(-de)),se||(ue=de),se||(G=Z);const he=j(G*(Z-p)*C-oe),fe=ue*ue,Ee=j((ue+ue)*oe),ye=j(he*D),pe=j(p-fe),le=j(p+fe);return new e.ed25519.Point(j(Ee*le),j(pe*ye),j(ye*le),j(Ee*pe))}function E(O){(0,n.abytes)(O,64);const k=y(O.subarray(0,32)),U=m(k),j=y(O.subarray(32,64)),Z=m(j);return new A(U.add(Z))}class A extends i.PrimeEdwardsPoint{constructor(k){super(k)}static fromAffine(k){return new A(e.ed25519.Point.fromAffine(k))}assertSame(k){if(!(k instanceof A))throw new Error("RistrettoPoint expected")}init(k){return new A(k)}static hashToCurve(k){return E((0,d.ensureBytes)("ristrettoHash",k,64))}static fromBytes(k){(0,n.abytes)(k,32);const{a:U,d:j}=B,Z=w,R=c=>P.create(c),G=y(k);if(!(0,d.equalBytes)(P.toBytes(G),k)||(0,s.isNegativeLE)(G,Z))throw new Error("invalid ristretto255 encoding 1");const oe=R(G*G),se=R(p+U*oe),ue=R(p-U*oe),de=R(se*se),he=R(ue*ue),fe=R(U*j*de-he),{isValid:Ee,value:ye}=V(R(fe*he)),pe=R(ye*ue),le=R(ye*pe*fe);let ae=R((G+G)*pe);(0,s.isNegativeLE)(ae,Z)&&(ae=R(-ae));const ce=R(se*le),_=R(ae*ce);if(!Ee||(0,s.isNegativeLE)(_,Z)||ce===u)throw new Error("invalid ristretto255 encoding 2");return new A(new e.ed25519.Point(ae,ce,p,_))}static fromHex(k){return A.fromBytes((0,d.ensureBytes)("ristrettoHex",k,32))}static msm(k,U){return(0,r.pippenger)(A,e.ed25519.Point.Fn,k,U)}toBytes(){let{X:k,Y:U,Z:j,T:Z}=this.ep;const R=w,G=le=>P.create(le),oe=G(G(j+U)*G(j-U)),se=G(k*U),ue=G(se*se),{value:de}=V(G(oe*ue)),he=G(de*oe),fe=G(de*se),Ee=G(he*fe*Z);let ye;if((0,s.isNegativeLE)(Z*Ee,R)){let le=G(U*v),ae=G(k*v);k=le,U=ae,ye=G(he*x)}else ye=fe;(0,s.isNegativeLE)(k*Ee,R)&&(U=G(-U));let pe=G((j-U)*ye);return(0,s.isNegativeLE)(pe,R)&&(pe=G(-pe)),P.toBytes(pe)}equals(k){this.assertSame(k);const{X:U,Y:j}=this.ep,{X:Z,Y:R}=k.ep,G=ue=>P.create(ue),oe=G(U*R)===G(j*Z),se=G(j*R)===G(U*Z);return oe||se}is0(){return this.equals(A.ZERO)}}A.BASE=new A(e.ed25519.Point.BASE),A.ZERO=new A(e.ed25519.Point.ZERO),A.Fp=P,A.Fn=F,e.ristretto255={Point:A},e.ristretto255_hasher={hashToCurve(O,k){const U=k?.DST||"ristretto255_XMD:SHA-512_R255MAP_RO_",j=(0,o.expand_message_xmd)(O,U,64,t.sha512);return E(j)},hashToScalar(O,k={DST:o._DST_scalar}){const U=(0,o.expand_message_xmd)(O,k.DST,64,t.sha512);return F.create((0,d.bytesToNumberLE)(U))}},e.ED25519_TORSION_SUBGROUP=["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"];function M(O){return e.ed25519.utils.toMontgomery((0,d.ensureBytes)("pub",O))}e.edwardsToMontgomery=M;function z(O){return e.ed25519.utils.toMontgomerySecret((0,d.ensureBytes)("pub",O))}e.RistrettoPoint=A,e.hashToCurve=e.ed25519_hasher.hashToCurve,e.encodeToCurve=e.ed25519_hasher.encodeToCurve,e.hashToRistretto255=e.ristretto255_hasher.hashToCurve,e.hash_to_ristretto255=e.ristretto255_hasher.hashToCurve})(oi)),oi}var di={},wn={},fi={},hi={},Ws;function Ys(){return Ws||(Ws=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const t=ut();class n extends t.Hash{constructor(o,s){super(),this.finished=!1,this.destroyed=!1,(0,t.ahash)(o);const a=(0,t.toBytes)(s);if(this.iHash=o.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const d=this.blockLen,u=new Uint8Array(d);u.set(a.length>d?o.create().update(a).digest():a);for(let p=0;p<u.length;p++)u[p]^=54;this.iHash.update(u),this.oHash=o.create();for(let p=0;p<u.length;p++)u[p]^=106;this.oHash.update(u),(0,t.clean)(u)}update(o){return(0,t.aexists)(this),this.iHash.update(o),this}digestInto(o){(0,t.aexists)(this),(0,t.abytes)(o,this.outputLen),this.finished=!0,this.iHash.digestInto(o),this.oHash.update(o),this.oHash.digestInto(o),this.destroy()}digest(){const o=new Uint8Array(this.oHash.outputLen);return this.digestInto(o),o}_cloneInto(o){o||(o=Object.create(Object.getPrototypeOf(this),{}));const{oHash:s,iHash:a,finished:d,destroyed:u,blockLen:p,outputLen:h}=this;return o=o,o.finished=d,o.destroyed=u,o.blockLen=p,o.outputLen=h,o.oHash=s._cloneInto(o.oHash),o.iHash=a._cloneInto(o.iHash),o}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}e.HMAC=n;const r=(i,o,s)=>new n(i,o).update(s).digest();e.hmac=r,e.hmac.create=(i,o)=>new n(i,o)})(hi)),hi}var Xs;function Js(){return Xs||(Xs=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.DER=e.DERErr=void 0,e._splitEndoScalar=a,e._normFnElement=B,e.weierstrassN=T,e.SWUFpSqrtRatio=N,e.mapToCurveSimpleSWU=X,e.ecdh=F,e.ecdsa=q,e.weierstrassPoints=W,e._legacyHelperEquat=te,e.weierstrass=Q;/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const t=Ys(),n=ut(),r=_t(),i=li(),o=At(),s=(v,D)=>(v+(v>=0?D:-D)/b)/D;function a(v,D,x){const[[S,C],[V,f]]=D,y=s(f*v,x),m=s(-C*v,x);let E=v-y*S-m*V,A=-y*C-m*f;const M=E<h,z=A<h;M&&(E=-E),z&&(A=-A);const O=(0,r.bitMask)(Math.ceil((0,r.bitLen)(x)/2))+I;if(E<h||E>=O||A<h||A>=O)throw new Error("splitScalar (endomorphism): failed, k="+v);return{k1neg:M,k1:E,k2neg:z,k2:A}}function d(v){if(!["compact","recovered","der"].includes(v))throw new Error('Signature format must be "compact", "recovered", or "der"');return v}function u(v,D){const x={};for(let S of Object.keys(D))x[S]=v[S]===void 0?D[S]:v[S];return(0,r._abool2)(x.lowS,"lowS"),(0,r._abool2)(x.prehash,"prehash"),x.format!==void 0&&d(x.format),x}class p extends Error{constructor(D=""){super(D)}}e.DERErr=p,e.DER={Err:p,_tlv:{encode:(v,D)=>{const{Err:x}=e.DER;if(v<0||v>256)throw new x("tlv.encode: wrong tag");if(D.length&1)throw new x("tlv.encode: unpadded data");const S=D.length/2,C=(0,r.numberToHexUnpadded)(S);if(C.length/2&128)throw new x("tlv.encode: long form length too big");const V=S>127?(0,r.numberToHexUnpadded)(C.length/2|128):"";return(0,r.numberToHexUnpadded)(v)+V+C+D},decode(v,D){const{Err:x}=e.DER;let S=0;if(v<0||v>256)throw new x("tlv.encode: wrong tag");if(D.length<2||D[S++]!==v)throw new x("tlv.decode: wrong tlv");const C=D[S++],V=!!(C&128);let f=0;if(!V)f=C;else{const m=C&127;if(!m)throw new x("tlv.decode(long): indefinite length not supported");if(m>4)throw new x("tlv.decode(long): byte length is too big");const E=D.subarray(S,S+m);if(E.length!==m)throw new x("tlv.decode: length bytes not complete");if(E[0]===0)throw new x("tlv.decode(long): zero leftmost byte");for(const A of E)f=f<<8|A;if(S+=m,f<128)throw new x("tlv.decode(long): not minimal encoding")}const y=D.subarray(S,S+f);if(y.length!==f)throw new x("tlv.decode: wrong value length");return{v:y,l:D.subarray(S+f)}}},_int:{encode(v){const{Err:D}=e.DER;if(v<h)throw new D("integer: negative integers are not allowed");let x=(0,r.numberToHexUnpadded)(v);if(Number.parseInt(x[0],16)&8&&(x="00"+x),x.length&1)throw new D("unexpected DER parsing assertion: unpadded hex");return x},decode(v){const{Err:D}=e.DER;if(v[0]&128)throw new D("invalid signature integer: negative");if(v[0]===0&&!(v[1]&128))throw new D("invalid signature integer: unnecessary leading zero");return(0,r.bytesToNumberBE)(v)}},toSig(v){const{Err:D,_int:x,_tlv:S}=e.DER,C=(0,r.ensureBytes)("signature",v),{v:V,l:f}=S.decode(48,C);if(f.length)throw new D("invalid signature: left bytes after parsing");const{v:y,l:m}=S.decode(2,V),{v:E,l:A}=S.decode(2,m);if(A.length)throw new D("invalid signature: left bytes after parsing");return{r:x.decode(y),s:x.decode(E)}},hexFromSig(v){const{_tlv:D,_int:x}=e.DER,S=D.encode(2,x.encode(v.r)),C=D.encode(2,x.encode(v.s)),V=S+C;return D.encode(48,V)}};const h=BigInt(0),I=BigInt(1),b=BigInt(2),g=BigInt(3),w=BigInt(4);function B(v,D){const{BYTES:x}=v;let S;if(typeof D=="bigint")S=D;else{let C=(0,r.ensureBytes)("private key",D);try{S=v.fromBytes(C)}catch{throw new Error(`invalid private key: expected ui8a of size ${x}, got ${typeof D}`)}}if(!v.isValidNot0(S))throw new Error("invalid private key: out of range [1..N-1]");return S}function T(v,D={}){const x=(0,i._createCurveFields)("weierstrass",v,D),{Fp:S,Fn:C}=x;let V=x.CURVE;const{h:f,n:y}=V;(0,r._validateObject)(D,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:m}=D;if(m&&(!S.is0(V.a)||typeof m.beta!="bigint"||!Array.isArray(m.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const E=P(S,C);function A(){if(!S.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function M(pe,le,ae){const{x:ce,y:_}=le.toAffine(),c=S.toBytes(ce);if((0,r._abool2)(ae,"isCompressed"),ae){A();const l=!S.isOdd(_);return(0,r.concatBytes)(H(l),c)}else return(0,r.concatBytes)(Uint8Array.of(4),c,S.toBytes(_))}function z(pe){(0,r._abytes2)(pe,void 0,"Point");const{publicKey:le,publicKeyUncompressed:ae}=E,ce=pe.length,_=pe[0],c=pe.subarray(1);if(ce===le&&(_===2||_===3)){const l=S.fromBytes(c);if(!S.isValid(l))throw new Error("bad point: is not on curve, wrong x");const L=U(l);let $;try{$=S.sqrt(L)}catch(ge){const be=ge instanceof Error?": "+ge.message:"";throw new Error("bad point: is not on curve, sqrt error"+be)}A();const ee=S.isOdd($);return(_&1)===1!==ee&&($=S.neg($)),{x:l,y:$}}else if(ce===ae&&_===4){const l=S.BYTES,L=S.fromBytes(c.subarray(0,l)),$=S.fromBytes(c.subarray(l,l*2));if(!j(L,$))throw new Error("bad point: is not on curve");return{x:L,y:$}}else throw new Error(`bad point: got length ${ce}, expected compressed=${le} or uncompressed=${ae}`)}const O=D.toBytes||M,k=D.fromBytes||z;function U(pe){const le=S.sqr(pe),ae=S.mul(le,pe);return S.add(S.add(ae,S.mul(pe,V.a)),V.b)}function j(pe,le){const ae=S.sqr(le),ce=U(pe);return S.eql(ae,ce)}if(!j(V.Gx,V.Gy))throw new Error("bad curve params: generator point");const Z=S.mul(S.pow(V.a,g),w),R=S.mul(S.sqr(V.b),BigInt(27));if(S.is0(S.add(Z,R)))throw new Error("bad curve params: a or b");function G(pe,le,ae=!1){if(!S.isValid(le)||ae&&S.is0(le))throw new Error(`bad point coordinate ${pe}`);return le}function oe(pe){if(!(pe instanceof fe))throw new Error("ProjectivePoint expected")}function se(pe){if(!m||!m.basises)throw new Error("no endo");return a(pe,m.basises,C.ORDER)}const ue=(0,r.memoized)((pe,le)=>{const{X:ae,Y:ce,Z:_}=pe;if(S.eql(_,S.ONE))return{x:ae,y:ce};const c=pe.is0();le==null&&(le=c?S.ONE:S.inv(_));const l=S.mul(ae,le),L=S.mul(ce,le),$=S.mul(_,le);if(c)return{x:S.ZERO,y:S.ZERO};if(!S.eql($,S.ONE))throw new Error("invZ was invalid");return{x:l,y:L}}),de=(0,r.memoized)(pe=>{if(pe.is0()){if(D.allowInfinityPoint&&!S.is0(pe.Y))return;throw new Error("bad point: ZERO")}const{x:le,y:ae}=pe.toAffine();if(!S.isValid(le)||!S.isValid(ae))throw new Error("bad point: x or y not field elements");if(!j(le,ae))throw new Error("bad point: equation left != right");if(!pe.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function he(pe,le,ae,ce,_){return ae=new fe(S.mul(ae.X,pe),ae.Y,ae.Z),le=(0,i.negateCt)(ce,le),ae=(0,i.negateCt)(_,ae),le.add(ae)}class fe{constructor(le,ae,ce){this.X=G("x",le),this.Y=G("y",ae,!0),this.Z=G("z",ce),Object.freeze(this)}static CURVE(){return V}static fromAffine(le){const{x:ae,y:ce}=le||{};if(!le||!S.isValid(ae)||!S.isValid(ce))throw new Error("invalid affine point");if(le instanceof fe)throw new Error("projective point not allowed");return S.is0(ae)&&S.is0(ce)?fe.ZERO:new fe(ae,ce,S.ONE)}static fromBytes(le){const ae=fe.fromAffine(k((0,r._abytes2)(le,void 0,"point")));return ae.assertValidity(),ae}static fromHex(le){return fe.fromBytes((0,r.ensureBytes)("pointHex",le))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(le=8,ae=!0){return ye.createCache(this,le),ae||this.multiply(g),this}assertValidity(){de(this)}hasEvenY(){const{y:le}=this.toAffine();if(!S.isOdd)throw new Error("Field doesn't support isOdd");return!S.isOdd(le)}equals(le){oe(le);const{X:ae,Y:ce,Z:_}=this,{X:c,Y:l,Z:L}=le,$=S.eql(S.mul(ae,L),S.mul(c,_)),ee=S.eql(S.mul(ce,L),S.mul(l,_));return $&&ee}negate(){return new fe(this.X,S.neg(this.Y),this.Z)}double(){const{a:le,b:ae}=V,ce=S.mul(ae,g),{X:_,Y:c,Z:l}=this;let L=S.ZERO,$=S.ZERO,ee=S.ZERO,re=S.mul(_,_),ge=S.mul(c,c),be=S.mul(l,l),me=S.mul(_,c);return me=S.add(me,me),ee=S.mul(_,l),ee=S.add(ee,ee),L=S.mul(le,ee),$=S.mul(ce,be),$=S.add(L,$),L=S.sub(ge,$),$=S.add(ge,$),$=S.mul(L,$),L=S.mul(me,L),ee=S.mul(ce,ee),be=S.mul(le,be),me=S.sub(re,be),me=S.mul(le,me),me=S.add(me,ee),ee=S.add(re,re),re=S.add(ee,re),re=S.add(re,be),re=S.mul(re,me),$=S.add($,re),be=S.mul(c,l),be=S.add(be,be),re=S.mul(be,me),L=S.sub(L,re),ee=S.mul(be,ge),ee=S.add(ee,ee),ee=S.add(ee,ee),new fe(L,$,ee)}add(le){oe(le);const{X:ae,Y:ce,Z:_}=this,{X:c,Y:l,Z:L}=le;let $=S.ZERO,ee=S.ZERO,re=S.ZERO;const ge=V.a,be=S.mul(V.b,g);let me=S.mul(ae,c),Se=S.mul(ce,l),we=S.mul(_,L),Ze=S.add(ae,ce),Re=S.add(c,l);Ze=S.mul(Ze,Re),Re=S.add(me,Se),Ze=S.sub(Ze,Re),Re=S.add(ae,_);let Ne=S.add(c,L);return Re=S.mul(Re,Ne),Ne=S.add(me,we),Re=S.sub(Re,Ne),Ne=S.add(ce,_),$=S.add(l,L),Ne=S.mul(Ne,$),$=S.add(Se,we),Ne=S.sub(Ne,$),re=S.mul(ge,Re),$=S.mul(be,we),re=S.add($,re),$=S.sub(Se,re),re=S.add(Se,re),ee=S.mul($,re),Se=S.add(me,me),Se=S.add(Se,me),we=S.mul(ge,we),Re=S.mul(be,Re),Se=S.add(Se,we),we=S.sub(me,we),we=S.mul(ge,we),Re=S.add(Re,we),me=S.mul(Se,Re),ee=S.add(ee,me),me=S.mul(Ne,Re),$=S.mul(Ze,$),$=S.sub($,me),me=S.mul(Ze,Se),re=S.mul(Ne,re),re=S.add(re,me),new fe($,ee,re)}subtract(le){return this.add(le.negate())}is0(){return this.equals(fe.ZERO)}multiply(le){const{endo:ae}=D;if(!C.isValidNot0(le))throw new Error("invalid scalar: out of range");let ce,_;const c=l=>ye.cached(this,l,L=>(0,i.normalizeZ)(fe,L));if(ae){const{k1neg:l,k1:L,k2neg:$,k2:ee}=se(le),{p:re,f:ge}=c(L),{p:be,f:me}=c(ee);_=ge.add(me),ce=he(ae.beta,re,be,l,$)}else{const{p:l,f:L}=c(le);ce=l,_=L}return(0,i.normalizeZ)(fe,[ce,_])[0]}multiplyUnsafe(le){const{endo:ae}=D,ce=this;if(!C.isValid(le))throw new Error("invalid scalar: out of range");if(le===h||ce.is0())return fe.ZERO;if(le===I)return ce;if(ye.hasCache(this))return this.multiply(le);if(ae){const{k1neg:_,k1:c,k2neg:l,k2:L}=se(le),{p1:$,p2:ee}=(0,i.mulEndoUnsafe)(fe,ce,c,L);return he(ae.beta,$,ee,_,l)}else return ye.unsafe(ce,le)}multiplyAndAddUnsafe(le,ae,ce){const _=this.multiplyUnsafe(ae).add(le.multiplyUnsafe(ce));return _.is0()?void 0:_}toAffine(le){return ue(this,le)}isTorsionFree(){const{isTorsionFree:le}=D;return f===I?!0:le?le(fe,this):ye.unsafe(this,y).is0()}clearCofactor(){const{clearCofactor:le}=D;return f===I?this:le?le(fe,this):this.multiplyUnsafe(f)}isSmallOrder(){return this.multiplyUnsafe(f).is0()}toBytes(le=!0){return(0,r._abool2)(le,"isCompressed"),this.assertValidity(),O(fe,this,le)}toHex(le=!0){return(0,r.bytesToHex)(this.toBytes(le))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(le=!0){return this.toBytes(le)}_setWindowSize(le){this.precompute(le)}static normalizeZ(le){return(0,i.normalizeZ)(fe,le)}static msm(le,ae){return(0,i.pippenger)(fe,C,le,ae)}static fromPrivateKey(le){return fe.BASE.multiply(B(C,le))}}fe.BASE=new fe(V.Gx,V.Gy,S.ONE),fe.ZERO=new fe(S.ZERO,S.ONE,S.ZERO),fe.Fp=S,fe.Fn=C;const Ee=C.BITS,ye=new i.wNAF(fe,D.endo?Math.ceil(Ee/2):Ee);return fe.BASE.precompute(8),fe}function H(v){return Uint8Array.of(v?2:3)}function N(v,D){const x=v.ORDER;let S=h;for(let k=x-I;k%b===h;k/=b)S+=I;const C=S,V=b<<C-I-I,f=V*b,y=(x-I)/f,m=(y-I)/b,E=f-I,A=V,M=v.pow(D,y),z=v.pow(D,(y+I)/b);let O=(k,U)=>{let j=M,Z=v.pow(U,E),R=v.sqr(Z);R=v.mul(R,U);let G=v.mul(k,R);G=v.pow(G,m),G=v.mul(G,Z),Z=v.mul(G,U),R=v.mul(G,k);let oe=v.mul(R,Z);G=v.pow(oe,A);let se=v.eql(G,v.ONE);Z=v.mul(R,z),G=v.mul(oe,j),R=v.cmov(Z,R,se),oe=v.cmov(G,oe,se);for(let ue=C;ue>I;ue--){let de=ue-b;de=b<<de-I;let he=v.pow(oe,de);const fe=v.eql(he,v.ONE);Z=v.mul(R,j),j=v.mul(j,j),he=v.mul(oe,j),R=v.cmov(Z,R,fe),oe=v.cmov(he,oe,fe)}return{isValid:se,value:R}};if(v.ORDER%w===g){const k=(v.ORDER-g)/w,U=v.sqrt(v.neg(D));O=(j,Z)=>{let R=v.sqr(Z);const G=v.mul(j,Z);R=v.mul(R,G);let oe=v.pow(R,k);oe=v.mul(oe,G);const se=v.mul(oe,U),ue=v.mul(v.sqr(oe),Z),de=v.eql(ue,j);let he=v.cmov(se,oe,de);return{isValid:de,value:he}}}return O}function X(v,D){(0,o.validateField)(v);const{A:x,B:S,Z:C}=D;if(!v.isValid(x)||!v.isValid(S)||!v.isValid(C))throw new Error("mapToCurveSimpleSWU: invalid opts");const V=N(v,C);if(!v.isOdd)throw new Error("Field does not have .isOdd()");return f=>{let y,m,E,A,M,z,O,k;y=v.sqr(f),y=v.mul(y,C),m=v.sqr(y),m=v.add(m,y),E=v.add(m,v.ONE),E=v.mul(E,S),A=v.cmov(C,v.neg(m),!v.eql(m,v.ZERO)),A=v.mul(A,x),m=v.sqr(E),z=v.sqr(A),M=v.mul(z,x),m=v.add(m,M),m=v.mul(m,E),z=v.mul(z,A),M=v.mul(z,S),m=v.add(m,M),O=v.mul(y,E);const{isValid:U,value:j}=V(m,z);k=v.mul(y,f),k=v.mul(k,j),O=v.cmov(O,E,U),k=v.cmov(k,j,U);const Z=v.isOdd(f)===v.isOdd(k);k=v.cmov(v.neg(k),k,Z);const R=(0,o.FpInvertBatch)(v,[A],!0)[0];return O=v.mul(O,R),{x:O,y:k}}}function P(v,D){return{secretKey:D.BYTES,publicKey:1+v.BYTES,publicKeyUncompressed:1+2*v.BYTES,publicKeyHasPrefix:!0,signature:2*D.BYTES}}function F(v,D={}){const{Fn:x}=v,S=D.randomBytes||r.randomBytes,C=Object.assign(P(v.Fp,x),{seed:(0,o.getMinHashLength)(x.ORDER)});function V(O){try{return!!B(x,O)}catch{return!1}}function f(O,k){const{publicKey:U,publicKeyUncompressed:j}=C;try{const Z=O.length;return k===!0&&Z!==U||k===!1&&Z!==j?!1:!!v.fromBytes(O)}catch{return!1}}function y(O=S(C.seed)){return(0,o.mapHashToField)((0,r._abytes2)(O,C.seed,"seed"),x.ORDER)}function m(O,k=!0){return v.BASE.multiply(B(x,O)).toBytes(k)}function E(O){const k=y(O);return{secretKey:k,publicKey:m(k)}}function A(O){if(typeof O=="bigint")return!1;if(O instanceof v)return!0;const{secretKey:k,publicKey:U,publicKeyUncompressed:j}=C;if(x.allowedLengths||k===U)return;const Z=(0,r.ensureBytes)("key",O).length;return Z===U||Z===j}function M(O,k,U=!0){if(A(O)===!0)throw new Error("first arg must be private key");if(A(k)===!1)throw new Error("second arg must be public key");const j=B(x,O);return v.fromHex(k).multiply(j).toBytes(U)}return Object.freeze({getPublicKey:m,getSharedSecret:M,keygen:E,Point:v,utils:{isValidSecretKey:V,isValidPublicKey:f,randomSecretKey:y,isValidPrivateKey:V,randomPrivateKey:y,normPrivateKeyToScalar:O=>B(x,O),precompute(O=8,k=v.BASE){return k.precompute(O,!1)}},lengths:C})}function q(v,D,x={}){(0,n.ahash)(D),(0,r._validateObject)(x,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const S=x.randomBytes||r.randomBytes,C=x.hmac||((ae,...ce)=>(0,t.hmac)(D,ae,(0,r.concatBytes)(...ce))),{Fp:V,Fn:f}=v,{ORDER:y,BITS:m}=f,{keygen:E,getPublicKey:A,getSharedSecret:M,utils:z,lengths:O}=F(v,x),k={prehash:!1,lowS:typeof x.lowS=="boolean"?x.lowS:!1,format:void 0,extraEntropy:!1},U="compact";function j(ae){const ce=y>>I;return ae>ce}function Z(ae,ce){if(!f.isValidNot0(ce))throw new Error(`invalid signature ${ae}: out of range 1..Point.Fn.ORDER`);return ce}function R(ae,ce){d(ce);const _=O.signature,c=ce==="compact"?_:ce==="recovered"?_+1:void 0;return(0,r._abytes2)(ae,c,`${ce} signature`)}class G{constructor(ce,_,c){this.r=Z("r",ce),this.s=Z("s",_),c!=null&&(this.recovery=c),Object.freeze(this)}static fromBytes(ce,_=U){R(ce,_);let c;if(_==="der"){const{r:ee,s:re}=e.DER.toSig((0,r._abytes2)(ce));return new G(ee,re)}_==="recovered"&&(c=ce[0],_="compact",ce=ce.subarray(1));const l=f.BYTES,L=ce.subarray(0,l),$=ce.subarray(l,l*2);return new G(f.fromBytes(L),f.fromBytes($),c)}static fromHex(ce,_){return this.fromBytes((0,r.hexToBytes)(ce),_)}addRecoveryBit(ce){return new G(this.r,this.s,ce)}recoverPublicKey(ce){const _=V.ORDER,{r:c,s:l,recovery:L}=this;if(L==null||![0,1,2,3].includes(L))throw new Error("recovery id invalid");if(y*b<_&&L>1)throw new Error("recovery id is ambiguous for h>1 curve");const ee=L===2||L===3?c+y:c;if(!V.isValid(ee))throw new Error("recovery id 2 or 3 invalid");const re=V.toBytes(ee),ge=v.fromBytes((0,r.concatBytes)(H((L&1)===0),re)),be=f.inv(ee),me=se((0,r.ensureBytes)("msgHash",ce)),Se=f.create(-me*be),we=f.create(l*be),Ze=v.BASE.multiplyUnsafe(Se).add(ge.multiplyUnsafe(we));if(Ze.is0())throw new Error("point at infinify");return Ze.assertValidity(),Ze}hasHighS(){return j(this.s)}toBytes(ce=U){if(d(ce),ce==="der")return(0,r.hexToBytes)(e.DER.hexFromSig(this));const _=f.toBytes(this.r),c=f.toBytes(this.s);if(ce==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return(0,r.concatBytes)(Uint8Array.of(this.recovery),_,c)}return(0,r.concatBytes)(_,c)}toHex(ce){return(0,r.bytesToHex)(this.toBytes(ce))}assertValidity(){}static fromCompact(ce){return G.fromBytes((0,r.ensureBytes)("sig",ce),"compact")}static fromDER(ce){return G.fromBytes((0,r.ensureBytes)("sig",ce),"der")}normalizeS(){return this.hasHighS()?new G(this.r,f.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return(0,r.bytesToHex)(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return(0,r.bytesToHex)(this.toBytes("compact"))}}const oe=x.bits2int||function(ce){if(ce.length>8192)throw new Error("input is too large");const _=(0,r.bytesToNumberBE)(ce),c=ce.length*8-m;return c>0?_>>BigInt(c):_},se=x.bits2int_modN||function(ce){return f.create(oe(ce))},ue=(0,r.bitMask)(m);function de(ae){return(0,r.aInRange)("num < 2^"+m,ae,h,ue),f.toBytes(ae)}function he(ae,ce){return(0,r._abytes2)(ae,void 0,"message"),ce?(0,r._abytes2)(D(ae),void 0,"prehashed message"):ae}function fe(ae,ce,_){if(["recovered","canonical"].some(Se=>Se in _))throw new Error("sign() legacy options not supported");const{lowS:c,prehash:l,extraEntropy:L}=u(_,k);ae=he(ae,l);const $=se(ae),ee=B(f,ce),re=[de(ee),de($)];if(L!=null&&L!==!1){const Se=L===!0?S(O.secretKey):L;re.push((0,r.ensureBytes)("extraEntropy",Se))}const ge=(0,r.concatBytes)(...re),be=$;function me(Se){const we=oe(Se);if(!f.isValidNot0(we))return;const Ze=f.inv(we),Re=v.BASE.multiply(we).toAffine(),Ne=f.create(Re.x);if(Ne===h)return;const Er=f.create(Ze*f.create(be+Ne*ee));if(Er===h)return;let Yc=(Re.x===Ne?0:2)|Number(Re.y&I),Xc=Er;return c&&j(Er)&&(Xc=f.neg(Er),Yc^=1),new G(Ne,Xc,Yc)}return{seed:ge,k2sig:me}}function Ee(ae,ce,_={}){ae=(0,r.ensureBytes)("message",ae);const{seed:c,k2sig:l}=fe(ae,ce,_);return(0,r.createHmacDrbg)(D.outputLen,f.BYTES,C)(c,l)}function ye(ae){let ce;const _=typeof ae=="string"||(0,r.isBytes)(ae),c=!_&&ae!==null&&typeof ae=="object"&&typeof ae.r=="bigint"&&typeof ae.s=="bigint";if(!_&&!c)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(c)ce=new G(ae.r,ae.s);else if(_){try{ce=G.fromBytes((0,r.ensureBytes)("sig",ae),"der")}catch(l){if(!(l instanceof e.DER.Err))throw l}if(!ce)try{ce=G.fromBytes((0,r.ensureBytes)("sig",ae),"compact")}catch{return!1}}return ce||!1}function pe(ae,ce,_,c={}){const{lowS:l,prehash:L,format:$}=u(c,k);if(_=(0,r.ensureBytes)("publicKey",_),ce=he((0,r.ensureBytes)("message",ce),L),"strict"in c)throw new Error("options.strict was renamed to lowS");const ee=$===void 0?ye(ae):G.fromBytes((0,r.ensureBytes)("sig",ae),$);if(ee===!1)return!1;try{const re=v.fromBytes(_);if(l&&ee.hasHighS())return!1;const{r:ge,s:be}=ee,me=se(ce),Se=f.inv(be),we=f.create(me*Se),Ze=f.create(ge*Se),Re=v.BASE.multiplyUnsafe(we).add(re.multiplyUnsafe(Ze));return Re.is0()?!1:f.create(Re.x)===ge}catch{return!1}}function le(ae,ce,_={}){const{prehash:c}=u(_,k);return ce=he(ce,c),G.fromBytes(ae,"recovered").recoverPublicKey(ce).toBytes()}return Object.freeze({keygen:E,getPublicKey:A,getSharedSecret:M,utils:z,lengths:O,Point:v,sign:Ee,verify:pe,recoverPublicKey:le,Signature:G,hash:D})}function W(v){const{CURVE:D,curveOpts:x}=K(v),S=T(D,x);return ne(v,S)}function K(v){const D={a:v.a,b:v.b,p:v.Fp.ORDER,n:v.n,h:v.h,Gx:v.Gx,Gy:v.Gy},x=v.Fp;let S=v.allowedPrivateKeyLengths?Array.from(new Set(v.allowedPrivateKeyLengths.map(f=>Math.ceil(f/2)))):void 0;const C=(0,o.Field)(D.n,{BITS:v.nBitLength,allowedLengths:S,modFromBytes:v.wrapPrivateKey}),V={Fp:x,Fn:C,allowInfinityPoint:v.allowInfinityPoint,endo:v.endo,isTorsionFree:v.isTorsionFree,clearCofactor:v.clearCofactor,fromBytes:v.fromBytes,toBytes:v.toBytes};return{CURVE:D,curveOpts:V}}function J(v){const{CURVE:D,curveOpts:x}=K(v),S={hmac:v.hmac,randomBytes:v.randomBytes,lowS:v.lowS,bits2int:v.bits2int,bits2int_modN:v.bits2int_modN};return{CURVE:D,curveOpts:x,hash:v.hash,ecdsaOpts:S}}function te(v,D,x){function S(C){const V=v.sqr(C),f=v.mul(V,C);return v.add(v.add(f,v.mul(C,D)),x)}return S}function ne(v,D){const{Fp:x,Fn:S}=D;function C(f){return(0,r.inRange)(f,I,S.ORDER)}const V=te(x,v.a,v.b);return Object.assign({},{CURVE:v,Point:D,ProjectivePoint:D,normPrivateKeyToScalar:f=>B(S,f),weierstrassEquation:V,isWithinCurveOrder:C})}function Y(v,D){const x=D.Point;return Object.assign({},D,{ProjectivePoint:x,CURVE:Object.assign({},v,(0,o.nLength)(x.Fn.ORDER,x.Fn.BITS))})}function Q(v){const{CURVE:D,curveOpts:x,hash:S,ecdsaOpts:C}=J(v),V=T(D,x),f=q(V,S,C);return Y(v,f)}})(fi)),fi}var Qs;function fh(){if(Qs)return wn;Qs=1,Object.defineProperty(wn,"__esModule",{value:!0}),wn.getHash=t,wn.createCurve=n;/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const e=Js();function t(r){return{hash:r}}function n(r,i){const o=s=>(0,e.weierstrass)({...r,hash:s});return{...o(i),create:o}}return wn}var ea;function hh(){return ea||(ea=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.encodeToCurve=e.hashToCurve=e.secp256k1_hasher=e.schnorr=e.secp256k1=void 0;/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const t=ai(),n=ut(),r=fh(),i=Gs(),o=At(),s=Js(),a=_t(),d={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},u={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},p=BigInt(0),h=BigInt(1),I=BigInt(2);function b(Y){const Q=d.p,v=BigInt(3),D=BigInt(6),x=BigInt(11),S=BigInt(22),C=BigInt(23),V=BigInt(44),f=BigInt(88),y=Y*Y*Y%Q,m=y*y*Y%Q,E=(0,o.pow2)(m,v,Q)*m%Q,A=(0,o.pow2)(E,v,Q)*m%Q,M=(0,o.pow2)(A,I,Q)*y%Q,z=(0,o.pow2)(M,x,Q)*M%Q,O=(0,o.pow2)(z,S,Q)*z%Q,k=(0,o.pow2)(O,V,Q)*O%Q,U=(0,o.pow2)(k,f,Q)*k%Q,j=(0,o.pow2)(U,V,Q)*O%Q,Z=(0,o.pow2)(j,v,Q)*m%Q,R=(0,o.pow2)(Z,C,Q)*z%Q,G=(0,o.pow2)(R,D,Q)*y%Q,oe=(0,o.pow2)(G,I,Q);if(!g.eql(g.sqr(oe),Y))throw new Error("Cannot find square root");return oe}const g=(0,o.Field)(d.p,{sqrt:b});e.secp256k1=(0,r.createCurve)({...d,Fp:g,lowS:!0,endo:u},t.sha256);const w={};function B(Y,...Q){let v=w[Y];if(v===void 0){const D=(0,t.sha256)((0,a.utf8ToBytes)(Y));v=(0,a.concatBytes)(D,D),w[Y]=v}return(0,t.sha256)((0,a.concatBytes)(v,...Q))}const T=Y=>Y.toBytes(!0).slice(1),H=e.secp256k1.Point,N=Y=>Y%I===p;function X(Y){const{Fn:Q,BASE:v}=H,D=(0,s._normFnElement)(Q,Y),x=v.multiply(D);return{scalar:N(x.y)?D:Q.neg(D),bytes:T(x)}}function P(Y){const Q=g;if(!Q.isValidNot0(Y))throw new Error("invalid x: Fail if x ≥ p");const v=Q.create(Y*Y),D=Q.create(v*Y+BigInt(7));let x=Q.sqrt(D);N(x)||(x=Q.neg(x));const S=H.fromAffine({x:Y,y:x});return S.assertValidity(),S}const F=a.bytesToNumberBE;function q(...Y){return H.Fn.create(F(B("BIP0340/challenge",...Y)))}function W(Y){return X(Y).bytes}function K(Y,Q,v=(0,n.randomBytes)(32)){const{Fn:D}=H,x=(0,a.ensureBytes)("message",Y),{bytes:S,scalar:C}=X(Q),V=(0,a.ensureBytes)("auxRand",v,32),f=D.toBytes(C^F(B("BIP0340/aux",V))),y=B("BIP0340/nonce",f,S,x),{bytes:m,scalar:E}=X(y),A=q(m,S,x),M=new Uint8Array(64);if(M.set(m,0),M.set(D.toBytes(D.create(E+A*C)),32),!J(M,x,S))throw new Error("sign: Invalid signature produced");return M}function J(Y,Q,v){const{Fn:D,BASE:x}=H,S=(0,a.ensureBytes)("signature",Y,64),C=(0,a.ensureBytes)("message",Q),V=(0,a.ensureBytes)("publicKey",v,32);try{const f=P(F(V)),y=F(S.subarray(0,32));if(!(0,a.inRange)(y,h,d.p))return!1;const m=F(S.subarray(32,64));if(!(0,a.inRange)(m,h,d.n))return!1;const E=q(D.toBytes(y),T(f),C),A=x.multiplyUnsafe(m).add(f.multiplyUnsafe(D.neg(E))),{x:M,y:z}=A.toAffine();return!(A.is0()||!N(z)||M!==y)}catch{return!1}}e.schnorr=(()=>{const v=(x=(0,n.randomBytes)(48))=>(0,o.mapHashToField)(x,d.n);e.secp256k1.utils.randomSecretKey;function D(x){const S=v(x);return{secretKey:S,publicKey:W(S)}}return{keygen:D,getPublicKey:W,sign:K,verify:J,Point:H,utils:{randomSecretKey:v,randomPrivateKey:v,taggedHash:B,lift_x:P,pointToBytes:T,numberToBytesBE:a.numberToBytesBE,bytesToNumberBE:a.bytesToNumberBE,mod:o.mod},lengths:{secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48}}})();const te=(0,i.isogenyMap)(g,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(Y=>Y.map(Q=>BigInt(Q)))),ne=(0,s.mapToCurveSimpleSWU)(g,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:g.create(BigInt("-11"))});e.secp256k1_hasher=(0,i.createHasher)(e.secp256k1.Point,Y=>{const{x:Q,y:v}=ne(g.create(Y[0]));return te(Q,v)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:g.ORDER,m:1,k:128,expand:"xmd",hash:t.sha256}),e.hashToCurve=e.secp256k1_hasher.hashToCurve,e.encodeToCurve=e.secp256k1_hasher.encodeToCurve})(di)),di}var pi={},ta;function na(){return ta||(ta=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.decodeHex=e.remove0x=void 0;var t=Xe(),n=function(i){return i.startsWith("0x")||i.startsWith("0X")?i.slice(2):i};e.remove0x=n;var r=function(i){return(0,t.hexToBytes)((0,e.remove0x)(i))};e.decodeHex=r})(pi)),pi}var ra;function ph(){return ra||(ra=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.hexToPublicKey=e.convertPublicKeyFormat=e.getSharedPoint=e.getPublicKey=e.isValidPrivateKey=e.getValidSecret=void 0;var t=ks(),n=dh(),r=hh(),i=rr(),o=ti(),s=na(),a=function(B){var T;do T=(0,t.randomBytes)(o.SECRET_KEY_LENGTH);while(!(0,e.isValidPrivateKey)(T,B));return T};e.getValidSecret=a;var d=function(B,T){return b(T||(0,i.ellipticCurve)(),function(H){return H.utils.isValidPrivateKey(B)},function(){return!0},function(){return!0})};e.isValidPrivateKey=d;var u=function(B,T){return b(T||(0,i.ellipticCurve)(),function(H){return H.getPublicKey(B)},function(H){return H.getPublicKey(B)},function(H){return H.getPublicKey(B)})};e.getPublicKey=u;var p=function(B,T,H,N){return b(N||(0,i.ellipticCurve)(),function(X){return X.getSharedSecret(B,T,H)},function(X){return X.getSharedSecret(B,T)},function(X){return w(X,B,T)})};e.getSharedPoint=p;var h=function(B,T,H){return b(H||(0,i.ellipticCurve)(),function(N){return N.getSharedSecret(BigInt(1),B,T)},function(){return B},function(){return B})};e.convertPublicKeyFormat=h;var I=function(B,T){var H=(0,s.decodeHex)(B);return b(T||(0,i.ellipticCurve)(),function(){return g(H)},function(){return H},function(){return H})};e.hexToPublicKey=I;function b(B,T,H,N){if(B==="secp256k1")return T(r.secp256k1);if(B==="x25519")return H(n.x25519);if(B==="ed25519")return N(n.ed25519);throw new Error("Not implemented")}var g=function(B){if(B.length===o.ETH_PUBLIC_KEY_SIZE){var T=new Uint8Array(1+B.length);return T.set([4]),T.set(B,1),T}return B},w=function(B,T,H){var N=B.utils.getExtendedPublicKey(T).scalar,X=B.ExtendedPoint.fromHex(H).multiply(N);return X.toRawBytes()}})(ri)),ri}var yi={},Ct={},ia;function yh(){if(ia)return Ct;ia=1,Object.defineProperty(Ct,"__esModule",{value:!0}),Ct.hkdf=void 0,Ct.extract=n,Ct.expand=o;const e=Ys(),t=ut();function n(a,d,u){return(0,t.ahash)(a),u===void 0&&(u=new Uint8Array(a.outputLen)),(0,e.hmac)(a,(0,t.toBytes)(u),(0,t.toBytes)(d))}const r=Uint8Array.from([0]),i=Uint8Array.of();function o(a,d,u,p=32){(0,t.ahash)(a),(0,t.anumber)(p);const h=a.outputLen;if(p>255*h)throw new Error("Length should be <= 255*HashLen");const I=Math.ceil(p/h);u===void 0&&(u=i);const b=new Uint8Array(I*h),g=e.hmac.create(a,d),w=g._cloneInto(),B=new Uint8Array(g.outputLen);for(let T=0;T<I;T++)r[0]=T+1,w.update(T===0?i:B).update(u).update(r).digestInto(B),b.set(B,h*T),g._cloneInto(w);return g.destroy(),w.destroy(),(0,t.clean)(B,r),b.slice(0,p)}const s=(a,d,u,p,h)=>o(a,n(a,d,u),p,h);return Ct.hkdf=s,Ct}var oa;function gh(){return oa||(oa=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getSharedKey=e.deriveKey=void 0;var t=Xe(),n=yh(),r=ai(),i=function(s,a,d){return(0,n.hkdf)(r.sha256,s,a,d,32)};e.deriveKey=i;var o=function(){for(var s=[],a=0;a<arguments.length;a++)s[a]=arguments[a];return(0,e.deriveKey)(t.concatBytes.apply(void 0,s))};e.getSharedKey=o})(yi)),yi}var gi={},Tt={},mi={},wt={},sa;function mh(){if(sa)return wt;sa=1,Object.defineProperty(wt,"__esModule",{value:!0}),wt.polyval=wt.ghash=void 0,wt._toGHASHKey=a;const e=Xe(),t=16,n=new Uint8Array(16),r=(0,e.u32)(n),i=225,o=(I,b,g,w)=>{const B=w&1;return{s3:g<<31|w>>>1,s2:b<<31|g>>>1,s1:I<<31|b>>>1,s0:I>>>1^i<<24&-(B&1)}},s=I=>(I>>>0&255)<<24|(I>>>8&255)<<16|(I>>>16&255)<<8|I>>>24&255|0;function a(I){I.reverse();const b=I[15]&1;let g=0;for(let w=0;w<I.length;w++){const B=I[w];I[w]=B>>>1|g,g=(B&1)<<7}return I[0]^=-b&225,I}const d=I=>I>64*1024?8:I>1024?4:2;class u{constructor(b,g){this.blockLen=t,this.outputLen=t,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=!1,b=(0,e.toBytes)(b),(0,e.abytes)(b,16);const w=(0,e.createView)(b);let B=w.getUint32(0,!1),T=w.getUint32(4,!1),H=w.getUint32(8,!1),N=w.getUint32(12,!1);const X=[];for(let J=0;J<128;J++)X.push({s0:s(B),s1:s(T),s2:s(H),s3:s(N)}),{s0:B,s1:T,s2:H,s3:N}=o(B,T,H,N);const P=d(g||1024);if(![1,2,4,8].includes(P))throw new Error("ghash: invalid window size, expected 2, 4 or 8");this.W=P;const q=128/P,W=this.windowSize=2**P,K=[];for(let J=0;J<q;J++)for(let te=0;te<W;te++){let ne=0,Y=0,Q=0,v=0;for(let D=0;D<P;D++){if(!(te>>>P-D-1&1))continue;const{s0:S,s1:C,s2:V,s3:f}=X[P*J+D];ne^=S,Y^=C,Q^=V,v^=f}K.push({s0:ne,s1:Y,s2:Q,s3:v})}this.t=K}_updateBlock(b,g,w,B){b^=this.s0,g^=this.s1,w^=this.s2,B^=this.s3;const{W:T,t:H,windowSize:N}=this;let X=0,P=0,F=0,q=0;const W=(1<<T)-1;let K=0;for(const J of[b,g,w,B])for(let te=0;te<4;te++){const ne=J>>>8*te&255;for(let Y=8/T-1;Y>=0;Y--){const Q=ne>>>T*Y&W,{s0:v,s1:D,s2:x,s3:S}=H[K*N+Q];X^=v,P^=D,F^=x,q^=S,K+=1}}this.s0=X,this.s1=P,this.s2=F,this.s3=q}update(b){(0,e.aexists)(this),b=(0,e.toBytes)(b),(0,e.abytes)(b);const g=(0,e.u32)(b),w=Math.floor(b.length/t),B=b.length%t;for(let T=0;T<w;T++)this._updateBlock(g[T*4+0],g[T*4+1],g[T*4+2],g[T*4+3]);return B&&(n.set(b.subarray(w*t)),this._updateBlock(r[0],r[1],r[2],r[3]),(0,e.clean)(r)),this}destroy(){const{t:b}=this;for(const g of b)g.s0=0,g.s1=0,g.s2=0,g.s3=0}digestInto(b){(0,e.aexists)(this),(0,e.aoutput)(b,this),this.finished=!0;const{s0:g,s1:w,s2:B,s3:T}=this,H=(0,e.u32)(b);return H[0]=g,H[1]=w,H[2]=B,H[3]=T,b}digest(){const b=new Uint8Array(t);return this.digestInto(b),this.destroy(),b}}class p extends u{constructor(b,g){b=(0,e.toBytes)(b),(0,e.abytes)(b);const w=a((0,e.copyBytes)(b));super(w,g),(0,e.clean)(w)}update(b){b=(0,e.toBytes)(b),(0,e.aexists)(this);const g=(0,e.u32)(b),w=b.length%t,B=Math.floor(b.length/t);for(let T=0;T<B;T++)this._updateBlock(s(g[T*4+3]),s(g[T*4+2]),s(g[T*4+1]),s(g[T*4+0]));return w&&(n.set(b.subarray(B*t)),this._updateBlock(s(r[3]),s(r[2]),s(r[1]),s(r[0])),(0,e.clean)(r)),this}digestInto(b){(0,e.aexists)(this),(0,e.aoutput)(b,this),this.finished=!0;const{s0:g,s1:w,s2:B,s3:T}=this,H=(0,e.u32)(b);return H[0]=g,H[1]=w,H[2]=B,H[3]=T,b.reverse()}}function h(I){const b=(w,B)=>I(B,w.length).update((0,e.toBytes)(w)).digest(),g=I(new Uint8Array(16),0);return b.outputLen=g.outputLen,b.blockLen=g.blockLen,b.create=(w,B)=>I(w,B),b}return wt.ghash=h((I,b)=>new u(I,b)),wt.polyval=h((I,b)=>new p(I,b)),wt}var aa;function _h(){return aa||(aa=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.unsafe=e.aeskwp=e.aeskw=e.siv=e.gcmsiv=e.gcm=e.cfb=e.cbc=e.ecb=e.ctr=void 0;const t=mh(),n=Xe(),r=16,i=4,o=new Uint8Array(r),s=283;function a(y){return y<<1^s&-(y>>7)}function d(y,m){let E=0;for(;m>0;m>>=1)E^=y&-(m&1),y=a(y);return E}const u=(()=>{const y=new Uint8Array(256);for(let E=0,A=1;E<256;E++,A^=a(A))y[E]=A;const m=new Uint8Array(256);m[0]=99;for(let E=0;E<255;E++){let A=y[255-E];A|=A<<8,m[y[E]]=(A^A>>4^A>>5^A>>6^A>>7^99)&255}return(0,n.clean)(y),m})(),p=u.map((y,m)=>u.indexOf(m)),h=y=>y<<24|y>>>8,I=y=>y<<8|y>>>24,b=y=>y<<24&4278190080|y<<8&16711680|y>>>8&65280|y>>>24&255;function g(y,m){if(y.length!==256)throw new Error("Wrong sbox length");const E=new Uint32Array(256).map((j,Z)=>m(y[Z])),A=E.map(I),M=A.map(I),z=M.map(I),O=new Uint32Array(256*256),k=new Uint32Array(256*256),U=new Uint16Array(256*256);for(let j=0;j<256;j++)for(let Z=0;Z<256;Z++){const R=j*256+Z;O[R]=E[j]^A[Z],k[R]=M[j]^z[Z],U[R]=y[j]<<8|y[Z]}return{sbox:y,sbox2:U,T0:E,T1:A,T2:M,T3:z,T01:O,T23:k}}const w=g(u,y=>d(y,3)<<24|y<<16|y<<8|d(y,2)),B=g(p,y=>d(y,11)<<24|d(y,13)<<16|d(y,9)<<8|d(y,14)),T=(()=>{const y=new Uint8Array(16);for(let m=0,E=1;m<16;m++,E=a(E))y[m]=E;return y})();function H(y){(0,n.abytes)(y);const m=y.length;if(![16,24,32].includes(m))throw new Error("aes: invalid key size, should be 16, 24 or 32, got "+m);const{sbox2:E}=w,A=[];(0,n.isAligned32)(y)||A.push(y=(0,n.copyBytes)(y));const M=(0,n.u32)(y),z=M.length,O=U=>P(E,U,U,U,U),k=new Uint32Array(m+28);k.set(M);for(let U=z;U<k.length;U++){let j=k[U-1];U%z===0?j=O(h(j))^T[U/z-1]:z>6&&U%z===4&&(j=O(j)),k[U]=k[U-z]^j}return(0,n.clean)(...A),k}function N(y){const m=H(y),E=m.slice(),A=m.length,{sbox2:M}=w,{T0:z,T1:O,T2:k,T3:U}=B;for(let j=0;j<A;j+=4)for(let Z=0;Z<4;Z++)E[j+Z]=m[A-j-4+Z];(0,n.clean)(m);for(let j=4;j<A-4;j++){const Z=E[j],R=P(M,Z,Z,Z,Z);E[j]=z[R&255]^O[R>>>8&255]^k[R>>>16&255]^U[R>>>24]}return E}function X(y,m,E,A,M,z){return y[E<<8&65280|A>>>8&255]^m[M>>>8&65280|z>>>24&255]}function P(y,m,E,A,M){return y[m&255|E&65280]|y[A>>>16&255|M>>>16&65280]<<16}function F(y,m,E,A,M){const{sbox2:z,T01:O,T23:k}=w;let U=0;m^=y[U++],E^=y[U++],A^=y[U++],M^=y[U++];const j=y.length/4-2;for(let se=0;se<j;se++){const ue=y[U++]^X(O,k,m,E,A,M),de=y[U++]^X(O,k,E,A,M,m),he=y[U++]^X(O,k,A,M,m,E),fe=y[U++]^X(O,k,M,m,E,A);m=ue,E=de,A=he,M=fe}const Z=y[U++]^P(z,m,E,A,M),R=y[U++]^P(z,E,A,M,m),G=y[U++]^P(z,A,M,m,E),oe=y[U++]^P(z,M,m,E,A);return{s0:Z,s1:R,s2:G,s3:oe}}function q(y,m,E,A,M){const{sbox2:z,T01:O,T23:k}=B;let U=0;m^=y[U++],E^=y[U++],A^=y[U++],M^=y[U++];const j=y.length/4-2;for(let se=0;se<j;se++){const ue=y[U++]^X(O,k,m,M,A,E),de=y[U++]^X(O,k,E,m,M,A),he=y[U++]^X(O,k,A,E,m,M),fe=y[U++]^X(O,k,M,A,E,m);m=ue,E=de,A=he,M=fe}const Z=y[U++]^P(z,m,M,A,E),R=y[U++]^P(z,E,m,M,A),G=y[U++]^P(z,A,E,m,M),oe=y[U++]^P(z,M,A,E,m);return{s0:Z,s1:R,s2:G,s3:oe}}function W(y,m,E,A){(0,n.abytes)(m,r),(0,n.abytes)(E);const M=E.length;A=(0,n.getOutput)(M,A),(0,n.complexOverlapBytes)(E,A);const z=m,O=(0,n.u32)(z);let{s0:k,s1:U,s2:j,s3:Z}=F(y,O[0],O[1],O[2],O[3]);const R=(0,n.u32)(E),G=(0,n.u32)(A);for(let se=0;se+4<=R.length;se+=4){G[se+0]=R[se+0]^k,G[se+1]=R[se+1]^U,G[se+2]=R[se+2]^j,G[se+3]=R[se+3]^Z;let ue=1;for(let de=z.length-1;de>=0;de--)ue=ue+(z[de]&255)|0,z[de]=ue&255,ue>>>=8;({s0:k,s1:U,s2:j,s3:Z}=F(y,O[0],O[1],O[2],O[3]))}const oe=r*Math.floor(R.length/i);if(oe<M){const se=new Uint32Array([k,U,j,Z]),ue=(0,n.u8)(se);for(let de=oe,he=0;de<M;de++,he++)A[de]=E[de]^ue[he];(0,n.clean)(se)}return A}function K(y,m,E,A,M){(0,n.abytes)(E,r),(0,n.abytes)(A),M=(0,n.getOutput)(A.length,M);const z=E,O=(0,n.u32)(z),k=(0,n.createView)(z),U=(0,n.u32)(A),j=(0,n.u32)(M),Z=m?0:12,R=A.length;let G=k.getUint32(Z,m),{s0:oe,s1:se,s2:ue,s3:de}=F(y,O[0],O[1],O[2],O[3]);for(let fe=0;fe+4<=U.length;fe+=4)j[fe+0]=U[fe+0]^oe,j[fe+1]=U[fe+1]^se,j[fe+2]=U[fe+2]^ue,j[fe+3]=U[fe+3]^de,G=G+1>>>0,k.setUint32(Z,G,m),{s0:oe,s1:se,s2:ue,s3:de}=F(y,O[0],O[1],O[2],O[3]);const he=r*Math.floor(U.length/i);if(he<R){const fe=new Uint32Array([oe,se,ue,de]),Ee=(0,n.u8)(fe);for(let ye=he,pe=0;ye<R;ye++,pe++)M[ye]=A[ye]^Ee[pe];(0,n.clean)(fe)}return M}e.ctr=(0,n.wrapCipher)({blockSize:16,nonceLength:16},function(m,E){function A(M,z){if((0,n.abytes)(M),z!==void 0&&((0,n.abytes)(z),!(0,n.isAligned32)(z)))throw new Error("unaligned destination");const O=H(m),k=(0,n.copyBytes)(E),U=[O,k];(0,n.isAligned32)(M)||U.push(M=(0,n.copyBytes)(M));const j=W(O,k,M,z);return(0,n.clean)(...U),j}return{encrypt:(M,z)=>A(M,z),decrypt:(M,z)=>A(M,z)}});function J(y){if((0,n.abytes)(y),y.length%r!==0)throw new Error("aes-(cbc/ecb).decrypt ciphertext should consist of blocks with size "+r)}function te(y,m,E){(0,n.abytes)(y);let A=y.length;const M=A%r;if(!m&&M!==0)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");(0,n.isAligned32)(y)||(y=(0,n.copyBytes)(y));const z=(0,n.u32)(y);if(m){let k=r-M;k||(k=r),A=A+k}E=(0,n.getOutput)(A,E),(0,n.complexOverlapBytes)(y,E);const O=(0,n.u32)(E);return{b:z,o:O,out:E}}function ne(y,m){if(!m)return y;const E=y.length;if(!E)throw new Error("aes/pcks5: empty ciphertext not allowed");const A=y[E-1];if(A<=0||A>16)throw new Error("aes/pcks5: wrong padding");const M=y.subarray(0,-A);for(let z=0;z<A;z++)if(y[E-z-1]!==A)throw new Error("aes/pcks5: wrong padding");return M}function Y(y){const m=new Uint8Array(16),E=(0,n.u32)(m);m.set(y);const A=r-y.length;for(let M=r-A;M<r;M++)m[M]=A;return E}e.ecb=(0,n.wrapCipher)({blockSize:16},function(m,E={}){const A=!E.disablePadding;return{encrypt(M,z){const{b:O,o:k,out:U}=te(M,A,z),j=H(m);let Z=0;for(;Z+4<=O.length;){const{s0:R,s1:G,s2:oe,s3:se}=F(j,O[Z+0],O[Z+1],O[Z+2],O[Z+3]);k[Z++]=R,k[Z++]=G,k[Z++]=oe,k[Z++]=se}if(A){const R=Y(M.subarray(Z*4)),{s0:G,s1:oe,s2:se,s3:ue}=F(j,R[0],R[1],R[2],R[3]);k[Z++]=G,k[Z++]=oe,k[Z++]=se,k[Z++]=ue}return(0,n.clean)(j),U},decrypt(M,z){J(M);const O=N(m);z=(0,n.getOutput)(M.length,z);const k=[O];(0,n.isAligned32)(M)||k.push(M=(0,n.copyBytes)(M)),(0,n.complexOverlapBytes)(M,z);const U=(0,n.u32)(M),j=(0,n.u32)(z);for(let Z=0;Z+4<=U.length;){const{s0:R,s1:G,s2:oe,s3:se}=q(O,U[Z+0],U[Z+1],U[Z+2],U[Z+3]);j[Z++]=R,j[Z++]=G,j[Z++]=oe,j[Z++]=se}return(0,n.clean)(...k),ne(z,A)}}}),e.cbc=(0,n.wrapCipher)({blockSize:16,nonceLength:16},function(m,E,A={}){const M=!A.disablePadding;return{encrypt(z,O){const k=H(m),{b:U,o:j,out:Z}=te(z,M,O);let R=E;const G=[k];(0,n.isAligned32)(R)||G.push(R=(0,n.copyBytes)(R));const oe=(0,n.u32)(R);let se=oe[0],ue=oe[1],de=oe[2],he=oe[3],fe=0;for(;fe+4<=U.length;)se^=U[fe+0],ue^=U[fe+1],de^=U[fe+2],he^=U[fe+3],{s0:se,s1:ue,s2:de,s3:he}=F(k,se,ue,de,he),j[fe++]=se,j[fe++]=ue,j[fe++]=de,j[fe++]=he;if(M){const Ee=Y(z.subarray(fe*4));se^=Ee[0],ue^=Ee[1],de^=Ee[2],he^=Ee[3],{s0:se,s1:ue,s2:de,s3:he}=F(k,se,ue,de,he),j[fe++]=se,j[fe++]=ue,j[fe++]=de,j[fe++]=he}return(0,n.clean)(...G),Z},decrypt(z,O){J(z);const k=N(m);let U=E;const j=[k];(0,n.isAligned32)(U)||j.push(U=(0,n.copyBytes)(U));const Z=(0,n.u32)(U);O=(0,n.getOutput)(z.length,O),(0,n.isAligned32)(z)||j.push(z=(0,n.copyBytes)(z)),(0,n.complexOverlapBytes)(z,O);const R=(0,n.u32)(z),G=(0,n.u32)(O);let oe=Z[0],se=Z[1],ue=Z[2],de=Z[3];for(let he=0;he+4<=R.length;){const fe=oe,Ee=se,ye=ue,pe=de;oe=R[he+0],se=R[he+1],ue=R[he+2],de=R[he+3];const{s0:le,s1:ae,s2:ce,s3:_}=q(k,oe,se,ue,de);G[he++]=le^fe,G[he++]=ae^Ee,G[he++]=ce^ye,G[he++]=_^pe}return(0,n.clean)(...j),ne(O,M)}}}),e.cfb=(0,n.wrapCipher)({blockSize:16,nonceLength:16},function(m,E){function A(M,z,O){(0,n.abytes)(M);const k=M.length;if(O=(0,n.getOutput)(k,O),(0,n.overlapBytes)(M,O))throw new Error("overlapping src and dst not supported.");const U=H(m);let j=E;const Z=[U];(0,n.isAligned32)(j)||Z.push(j=(0,n.copyBytes)(j)),(0,n.isAligned32)(M)||Z.push(M=(0,n.copyBytes)(M));const R=(0,n.u32)(M),G=(0,n.u32)(O),oe=z?G:R,se=(0,n.u32)(j);let ue=se[0],de=se[1],he=se[2],fe=se[3];for(let ye=0;ye+4<=R.length;){const{s0:pe,s1:le,s2:ae,s3:ce}=F(U,ue,de,he,fe);G[ye+0]=R[ye+0]^pe,G[ye+1]=R[ye+1]^le,G[ye+2]=R[ye+2]^ae,G[ye+3]=R[ye+3]^ce,ue=oe[ye++],de=oe[ye++],he=oe[ye++],fe=oe[ye++]}const Ee=r*Math.floor(R.length/i);if(Ee<k){({s0:ue,s1:de,s2:he,s3:fe}=F(U,ue,de,he,fe));const ye=(0,n.u8)(new Uint32Array([ue,de,he,fe]));for(let pe=Ee,le=0;pe<k;pe++,le++)O[pe]=M[pe]^ye[le];(0,n.clean)(ye)}return(0,n.clean)(...Z),O}return{encrypt:(M,z)=>A(M,!0,z),decrypt:(M,z)=>A(M,!1,z)}});function Q(y,m,E,A,M){const z=M?M.length:0,O=y.create(E,A.length+z);M&&O.update(M);const k=(0,n.u64Lengths)(8*A.length,8*z,m);O.update(A),O.update(k);const U=O.digest();return(0,n.clean)(k),U}e.gcm=(0,n.wrapCipher)({blockSize:16,nonceLength:12,tagLength:16,varSizeNonce:!0},function(m,E,A){if(E.length<8)throw new Error("aes/gcm: invalid nonce length");const M=16;function z(k,U,j){const Z=Q(t.ghash,!1,k,j,A);for(let R=0;R<U.length;R++)Z[R]^=U[R];return Z}function O(){const k=H(m),U=o.slice(),j=o.slice();if(K(k,!1,j,j,U),E.length===12)j.set(E);else{const R=o.slice(),G=(0,n.createView)(R);(0,n.setBigUint64)(G,8,BigInt(E.length*8),!1);const oe=t.ghash.create(U).update(E).update(R);oe.digestInto(j),oe.destroy()}const Z=K(k,!1,j,o);return{xk:k,authKey:U,counter:j,tagMask:Z}}return{encrypt(k){const{xk:U,authKey:j,counter:Z,tagMask:R}=O(),G=new Uint8Array(k.length+M),oe=[U,j,Z,R];(0,n.isAligned32)(k)||oe.push(k=(0,n.copyBytes)(k)),K(U,!1,Z,k,G.subarray(0,k.length));const se=z(j,R,G.subarray(0,G.length-M));return oe.push(se),G.set(se,k.length),(0,n.clean)(...oe),G},decrypt(k){const{xk:U,authKey:j,counter:Z,tagMask:R}=O(),G=[U,j,R,Z];(0,n.isAligned32)(k)||G.push(k=(0,n.copyBytes)(k));const oe=k.subarray(0,-M),se=k.subarray(-M),ue=z(j,R,oe);if(G.push(ue),!(0,n.equalBytes)(ue,se))throw new Error("aes/gcm: invalid ghash tag");const de=K(U,!1,Z,oe);return(0,n.clean)(...G),de}}});const v=(y,m,E)=>A=>{if(!Number.isSafeInteger(A)||m>A||A>E){const M="["+m+".."+E+"]";throw new Error(""+y+": expected value in range "+M+", got "+A)}};e.gcmsiv=(0,n.wrapCipher)({blockSize:16,nonceLength:12,tagLength:16,varSizeNonce:!0},function(m,E,A){const z=v("AAD",0,68719476736),O=v("plaintext",0,2**36),k=v("nonce",12,12),U=v("ciphertext",16,2**36+16);(0,n.abytes)(m,16,24,32),k(E.length),A!==void 0&&z(A.length);function j(){const G=H(m),oe=new Uint8Array(m.length),se=new Uint8Array(16),ue=[G,oe];let de=E;(0,n.isAligned32)(de)||ue.push(de=(0,n.copyBytes)(de));const he=(0,n.u32)(de);let fe=0,Ee=he[0],ye=he[1],pe=he[2],le=0;for(const ce of[se,oe].map(n.u32)){const _=(0,n.u32)(ce);for(let c=0;c<_.length;c+=2){const{s0:l,s1:L}=F(G,fe,Ee,ye,pe);_[c+0]=l,_[c+1]=L,fe=++le}}const ae={authKey:se,encKey:H(oe)};return(0,n.clean)(...ue),ae}function Z(G,oe,se){const ue=Q(t.polyval,!0,oe,se,A);for(let pe=0;pe<12;pe++)ue[pe]^=E[pe];ue[15]&=127;const de=(0,n.u32)(ue);let he=de[0],fe=de[1],Ee=de[2],ye=de[3];return{s0:he,s1:fe,s2:Ee,s3:ye}=F(G,he,fe,Ee,ye),de[0]=he,de[1]=fe,de[2]=Ee,de[3]=ye,ue}function R(G,oe,se){let ue=(0,n.copyBytes)(oe);ue[15]|=128;const de=K(G,!0,ue,se);return(0,n.clean)(ue),de}return{encrypt(G){O(G.length);const{encKey:oe,authKey:se}=j(),ue=Z(oe,se,G),de=[oe,se,ue];(0,n.isAligned32)(G)||de.push(G=(0,n.copyBytes)(G));const he=new Uint8Array(G.length+16);return he.set(ue,G.length),he.set(R(oe,ue,G)),(0,n.clean)(...de),he},decrypt(G){U(G.length);const oe=G.subarray(-16),{encKey:se,authKey:ue}=j(),de=[se,ue];(0,n.isAligned32)(G)||de.push(G=(0,n.copyBytes)(G));const he=R(se,oe,G.subarray(0,-16)),fe=Z(se,ue,he);if(de.push(fe),!(0,n.equalBytes)(oe,fe))throw(0,n.clean)(...de),new Error("invalid polyval tag");return(0,n.clean)(...de),he}}}),e.siv=e.gcmsiv;function D(y){return y instanceof Uint32Array||ArrayBuffer.isView(y)&&y.constructor.name==="Uint32Array"}function x(y,m){if((0,n.abytes)(m,16),!D(y))throw new Error("_encryptBlock accepts result of expandKeyLE");const E=(0,n.u32)(m);let{s0:A,s1:M,s2:z,s3:O}=F(y,E[0],E[1],E[2],E[3]);return E[0]=A,E[1]=M,E[2]=z,E[3]=O,m}function S(y,m){if((0,n.abytes)(m,16),!D(y))throw new Error("_decryptBlock accepts result of expandKeyLE");const E=(0,n.u32)(m);let{s0:A,s1:M,s2:z,s3:O}=q(y,E[0],E[1],E[2],E[3]);return E[0]=A,E[1]=M,E[2]=z,E[3]=O,m}const C={encrypt(y,m){if(m.length>=2**32)throw new Error("plaintext should be less than 4gb");const E=H(y);if(m.length===16)x(E,m);else{const A=(0,n.u32)(m);let M=A[0],z=A[1];for(let O=0,k=1;O<6;O++)for(let U=2;U<A.length;U+=2,k++){const{s0:j,s1:Z,s2:R,s3:G}=F(E,M,z,A[U],A[U+1]);M=j,z=Z^b(k),A[U]=R,A[U+1]=G}A[0]=M,A[1]=z}E.fill(0)},decrypt(y,m){if(m.length-8>=2**32)throw new Error("ciphertext should be less than 4gb");const E=N(y),A=m.length/8-1;if(A===1)S(E,m);else{const M=(0,n.u32)(m);let z=M[0],O=M[1];for(let k=0,U=A*6;k<6;k++)for(let j=A*2;j>=1;j-=2,U--){O^=b(U);const{s0:Z,s1:R,s2:G,s3:oe}=q(E,z,O,M[j],M[j+1]);z=Z,O=R,M[j]=G,M[j+1]=oe}M[0]=z,M[1]=O}E.fill(0)}},V=new Uint8Array(8).fill(166);e.aeskw=(0,n.wrapCipher)({blockSize:8},y=>({encrypt(m){if(!m.length||m.length%8!==0)throw new Error("invalid plaintext length");if(m.length===8)throw new Error("8-byte keys not allowed in AESKW, use AESKWP instead");const E=(0,n.concatBytes)(V,m);return C.encrypt(y,E),E},decrypt(m){if(m.length%8!==0||m.length<24)throw new Error("invalid ciphertext length");const E=(0,n.copyBytes)(m);if(C.decrypt(y,E),!(0,n.equalBytes)(E.subarray(0,8),V))throw new Error("integrity check failed");return E.subarray(0,8).fill(0),E.subarray(8)}}));const f=2790873510;e.aeskwp=(0,n.wrapCipher)({blockSize:8},y=>({encrypt(m){if(!m.length)throw new Error("invalid plaintext length");const E=Math.ceil(m.length/8)*8,A=new Uint8Array(8+E);A.set(m,8);const M=(0,n.u32)(A);return M[0]=f,M[1]=b(m.length),C.encrypt(y,A),A},decrypt(m){if(m.length<16)throw new Error("invalid ciphertext length");const E=(0,n.copyBytes)(m),A=(0,n.u32)(E);C.decrypt(y,E);const M=b(A[1])>>>0,z=Math.ceil(M/8)*8;if(A[0]!==f||E.length-8!==z)throw new Error("integrity check failed");for(let O=M;O<z;O++)if(E[8+O]!==0)throw new Error("integrity check failed");return E.subarray(0,8).fill(0),E.subarray(8,8+M)}})),e.unsafe={expandKeyLE:H,expandKeyDecLE:N,encrypt:F,decrypt:q,encryptBlock:x,decryptBlock:S,ctrCounter:W,ctr32:K}})(mi)),mi}var ca;function bh(){if(ca)return Tt;ca=1,Object.defineProperty(Tt,"__esModule",{value:!0}),Tt.aes256cbc=Tt.aes256gcm=void 0;var e=_h(),t=function(r,i,o){return(0,e.gcm)(r,i,o)};Tt.aes256gcm=t;var n=function(r,i,o){return(0,e.cbc)(r,i)};return Tt.aes256cbc=n,Tt}var Ot={},_i={},vn={},la;function wh(){if(la)return vn;la=1,Object.defineProperty(vn,"__esModule",{value:!0}),vn.rotl=s,vn.createCipher=b;const e=Xe(),t=g=>Uint8Array.from(g.split("").map(w=>w.charCodeAt(0))),n=t("expand 16-byte k"),r=t("expand 32-byte k"),i=(0,e.u32)(n),o=(0,e.u32)(r);function s(g,w){return g<<w|g>>>32-w}function a(g){return g.byteOffset%4===0}const d=64,u=16,p=2**32-1,h=new Uint32Array;function I(g,w,B,T,H,N,X,P){const F=H.length,q=new Uint8Array(d),W=(0,e.u32)(q),K=a(H)&&a(N),J=K?(0,e.u32)(H):h,te=K?(0,e.u32)(N):h;for(let ne=0;ne<F;X++){if(g(w,B,T,W,X,P),X>=p)throw new Error("arx: counter overflow");const Y=Math.min(d,F-ne);if(K&&Y===d){const Q=ne/4;if(ne%4!==0)throw new Error("arx: invalid block position");for(let v=0,D;v<u;v++)D=Q+v,te[D]=J[D]^W[v];ne+=d;continue}for(let Q=0,v;Q<Y;Q++)v=ne+Q,N[v]=H[v]^q[Q];ne+=Y}}function b(g,w){const{allowShortKeys:B,extendNonceFn:T,counterLength:H,counterRight:N,rounds:X}=(0,e.checkOpts)({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},w);if(typeof g!="function")throw new Error("core must be a function");return(0,e.anumber)(H),(0,e.anumber)(X),(0,e.abool)(N),(0,e.abool)(B),(P,F,q,W,K=0)=>{(0,e.abytes)(P),(0,e.abytes)(F),(0,e.abytes)(q);const J=q.length;if(W===void 0&&(W=new Uint8Array(J)),(0,e.abytes)(W),(0,e.anumber)(K),K<0||K>=p)throw new Error("arx: counter overflow");if(W.length<J)throw new Error(`arx: output (${W.length}) is shorter than data (${J})`);const te=[];let ne=P.length,Y,Q;if(ne===32)te.push(Y=(0,e.copyBytes)(P)),Q=o;else if(ne===16&&B)Y=new Uint8Array(32),Y.set(P),Y.set(P,16),Q=i,te.push(Y);else throw new Error(`arx: invalid 32-byte key, got length=${ne}`);a(F)||te.push(F=(0,e.copyBytes)(F));const v=(0,e.u32)(Y);if(T){if(F.length!==24)throw new Error("arx: extended nonce must be 24 bytes");T(Q,v,(0,e.u32)(F.subarray(0,16)),v),F=F.subarray(16)}const D=16-H;if(D!==F.length)throw new Error(`arx: nonce must be ${D} or 16 bytes`);if(D!==12){const S=new Uint8Array(12);S.set(F,N?0:12-F.length),F=S,te.push(F)}const x=(0,e.u32)(F);return I(g,Q,v,x,q,W,K,X),(0,e.clean)(...te),W}}return vn}var Zt={},ua;function vh(){if(ua)return Zt;ua=1,Object.defineProperty(Zt,"__esModule",{value:!0}),Zt.poly1305=void 0,Zt.wrapConstructorWithKey=r;const e=Xe(),t=(i,o)=>i[o++]&255|(i[o++]&255)<<8;class n{constructor(o){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,o=(0,e.toBytes)(o),(0,e.abytes)(o,32);const s=t(o,0),a=t(o,2),d=t(o,4),u=t(o,6),p=t(o,8),h=t(o,10),I=t(o,12),b=t(o,14);this.r[0]=s&8191,this.r[1]=(s>>>13|a<<3)&8191,this.r[2]=(a>>>10|d<<6)&7939,this.r[3]=(d>>>7|u<<9)&8191,this.r[4]=(u>>>4|p<<12)&255,this.r[5]=p>>>1&8190,this.r[6]=(p>>>14|h<<2)&8191,this.r[7]=(h>>>11|I<<5)&8065,this.r[8]=(I>>>8|b<<8)&8191,this.r[9]=b>>>5&127;for(let g=0;g<8;g++)this.pad[g]=t(o,16+2*g)}process(o,s,a=!1){const d=a?0:2048,{h:u,r:p}=this,h=p[0],I=p[1],b=p[2],g=p[3],w=p[4],B=p[5],T=p[6],H=p[7],N=p[8],X=p[9],P=t(o,s+0),F=t(o,s+2),q=t(o,s+4),W=t(o,s+6),K=t(o,s+8),J=t(o,s+10),te=t(o,s+12),ne=t(o,s+14);let Y=u[0]+(P&8191),Q=u[1]+((P>>>13|F<<3)&8191),v=u[2]+((F>>>10|q<<6)&8191),D=u[3]+((q>>>7|W<<9)&8191),x=u[4]+((W>>>4|K<<12)&8191),S=u[5]+(K>>>1&8191),C=u[6]+((K>>>14|J<<2)&8191),V=u[7]+((J>>>11|te<<5)&8191),f=u[8]+((te>>>8|ne<<8)&8191),y=u[9]+(ne>>>5|d),m=0,E=m+Y*h+Q*(5*X)+v*(5*N)+D*(5*H)+x*(5*T);m=E>>>13,E&=8191,E+=S*(5*B)+C*(5*w)+V*(5*g)+f*(5*b)+y*(5*I),m+=E>>>13,E&=8191;let A=m+Y*I+Q*h+v*(5*X)+D*(5*N)+x*(5*H);m=A>>>13,A&=8191,A+=S*(5*T)+C*(5*B)+V*(5*w)+f*(5*g)+y*(5*b),m+=A>>>13,A&=8191;let M=m+Y*b+Q*I+v*h+D*(5*X)+x*(5*N);m=M>>>13,M&=8191,M+=S*(5*H)+C*(5*T)+V*(5*B)+f*(5*w)+y*(5*g),m+=M>>>13,M&=8191;let z=m+Y*g+Q*b+v*I+D*h+x*(5*X);m=z>>>13,z&=8191,z+=S*(5*N)+C*(5*H)+V*(5*T)+f*(5*B)+y*(5*w),m+=z>>>13,z&=8191;let O=m+Y*w+Q*g+v*b+D*I+x*h;m=O>>>13,O&=8191,O+=S*(5*X)+C*(5*N)+V*(5*H)+f*(5*T)+y*(5*B),m+=O>>>13,O&=8191;let k=m+Y*B+Q*w+v*g+D*b+x*I;m=k>>>13,k&=8191,k+=S*h+C*(5*X)+V*(5*N)+f*(5*H)+y*(5*T),m+=k>>>13,k&=8191;let U=m+Y*T+Q*B+v*w+D*g+x*b;m=U>>>13,U&=8191,U+=S*I+C*h+V*(5*X)+f*(5*N)+y*(5*H),m+=U>>>13,U&=8191;let j=m+Y*H+Q*T+v*B+D*w+x*g;m=j>>>13,j&=8191,j+=S*b+C*I+V*h+f*(5*X)+y*(5*N),m+=j>>>13,j&=8191;let Z=m+Y*N+Q*H+v*T+D*B+x*w;m=Z>>>13,Z&=8191,Z+=S*g+C*b+V*I+f*h+y*(5*X),m+=Z>>>13,Z&=8191;let R=m+Y*X+Q*N+v*H+D*T+x*B;m=R>>>13,R&=8191,R+=S*w+C*g+V*b+f*I+y*h,m+=R>>>13,R&=8191,m=(m<<2)+m|0,m=m+E|0,E=m&8191,m=m>>>13,A+=m,u[0]=E,u[1]=A,u[2]=M,u[3]=z,u[4]=O,u[5]=k,u[6]=U,u[7]=j,u[8]=Z,u[9]=R}finalize(){const{h:o,pad:s}=this,a=new Uint16Array(10);let d=o[1]>>>13;o[1]&=8191;for(let h=2;h<10;h++)o[h]+=d,d=o[h]>>>13,o[h]&=8191;o[0]+=d*5,d=o[0]>>>13,o[0]&=8191,o[1]+=d,d=o[1]>>>13,o[1]&=8191,o[2]+=d,a[0]=o[0]+5,d=a[0]>>>13,a[0]&=8191;for(let h=1;h<10;h++)a[h]=o[h]+d,d=a[h]>>>13,a[h]&=8191;a[9]-=8192;let u=(d^1)-1;for(let h=0;h<10;h++)a[h]&=u;u=~u;for(let h=0;h<10;h++)o[h]=o[h]&u|a[h];o[0]=(o[0]|o[1]<<13)&65535,o[1]=(o[1]>>>3|o[2]<<10)&65535,o[2]=(o[2]>>>6|o[3]<<7)&65535,o[3]=(o[3]>>>9|o[4]<<4)&65535,o[4]=(o[4]>>>12|o[5]<<1|o[6]<<14)&65535,o[5]=(o[6]>>>2|o[7]<<11)&65535,o[6]=(o[7]>>>5|o[8]<<8)&65535,o[7]=(o[8]>>>8|o[9]<<5)&65535;let p=o[0]+s[0];o[0]=p&65535;for(let h=1;h<8;h++)p=(o[h]+s[h]|0)+(p>>>16)|0,o[h]=p&65535;(0,e.clean)(a)}update(o){(0,e.aexists)(this),o=(0,e.toBytes)(o),(0,e.abytes)(o);const{buffer:s,blockLen:a}=this,d=o.length;for(let u=0;u<d;){const p=Math.min(a-this.pos,d-u);if(p===a){for(;a<=d-u;u+=a)this.process(o,u);continue}s.set(o.subarray(u,u+p),this.pos),this.pos+=p,u+=p,this.pos===a&&(this.process(s,0,!1),this.pos=0)}return this}destroy(){(0,e.clean)(this.h,this.r,this.buffer,this.pad)}digestInto(o){(0,e.aexists)(this),(0,e.aoutput)(o,this),this.finished=!0;const{buffer:s,h:a}=this;let{pos:d}=this;if(d){for(s[d++]=1;d<16;d++)s[d]=0;this.process(s,0,!0)}this.finalize();let u=0;for(let p=0;p<8;p++)o[u++]=a[p]>>>0,o[u++]=a[p]>>>8;return o}digest(){const{buffer:o,outputLen:s}=this;this.digestInto(o);const a=o.slice(0,s);return this.destroy(),a}}function r(i){const o=(a,d)=>i(d).update((0,e.toBytes)(a)).digest(),s=i(new Uint8Array(32));return o.outputLen=s.outputLen,o.blockLen=s.blockLen,o.create=a=>i(a),o}return Zt.poly1305=r(i=>new n(i)),Zt}var da;function Eh(){return da||(da=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xchacha20poly1305=e.chacha20poly1305=e._poly1305_aead=e.chacha12=e.chacha8=e.xchacha20=e.chacha20=e.chacha20orig=void 0,e.hchacha=o;const t=wh(),n=vh(),r=Xe();function i(h,I,b,g,w,B=20){let T=h[0],H=h[1],N=h[2],X=h[3],P=I[0],F=I[1],q=I[2],W=I[3],K=I[4],J=I[5],te=I[6],ne=I[7],Y=w,Q=b[0],v=b[1],D=b[2],x=T,S=H,C=N,V=X,f=P,y=F,m=q,E=W,A=K,M=J,z=te,O=ne,k=Y,U=Q,j=v,Z=D;for(let G=0;G<B;G+=2)x=x+f|0,k=(0,t.rotl)(k^x,16),A=A+k|0,f=(0,t.rotl)(f^A,12),x=x+f|0,k=(0,t.rotl)(k^x,8),A=A+k|0,f=(0,t.rotl)(f^A,7),S=S+y|0,U=(0,t.rotl)(U^S,16),M=M+U|0,y=(0,t.rotl)(y^M,12),S=S+y|0,U=(0,t.rotl)(U^S,8),M=M+U|0,y=(0,t.rotl)(y^M,7),C=C+m|0,j=(0,t.rotl)(j^C,16),z=z+j|0,m=(0,t.rotl)(m^z,12),C=C+m|0,j=(0,t.rotl)(j^C,8),z=z+j|0,m=(0,t.rotl)(m^z,7),V=V+E|0,Z=(0,t.rotl)(Z^V,16),O=O+Z|0,E=(0,t.rotl)(E^O,12),V=V+E|0,Z=(0,t.rotl)(Z^V,8),O=O+Z|0,E=(0,t.rotl)(E^O,7),x=x+y|0,Z=(0,t.rotl)(Z^x,16),z=z+Z|0,y=(0,t.rotl)(y^z,12),x=x+y|0,Z=(0,t.rotl)(Z^x,8),z=z+Z|0,y=(0,t.rotl)(y^z,7),S=S+m|0,k=(0,t.rotl)(k^S,16),O=O+k|0,m=(0,t.rotl)(m^O,12),S=S+m|0,k=(0,t.rotl)(k^S,8),O=O+k|0,m=(0,t.rotl)(m^O,7),C=C+E|0,U=(0,t.rotl)(U^C,16),A=A+U|0,E=(0,t.rotl)(E^A,12),C=C+E|0,U=(0,t.rotl)(U^C,8),A=A+U|0,E=(0,t.rotl)(E^A,7),V=V+f|0,j=(0,t.rotl)(j^V,16),M=M+j|0,f=(0,t.rotl)(f^M,12),V=V+f|0,j=(0,t.rotl)(j^V,8),M=M+j|0,f=(0,t.rotl)(f^M,7);let R=0;g[R++]=T+x|0,g[R++]=H+S|0,g[R++]=N+C|0,g[R++]=X+V|0,g[R++]=P+f|0,g[R++]=F+y|0,g[R++]=q+m|0,g[R++]=W+E|0,g[R++]=K+A|0,g[R++]=J+M|0,g[R++]=te+z|0,g[R++]=ne+O|0,g[R++]=Y+k|0,g[R++]=Q+U|0,g[R++]=v+j|0,g[R++]=D+Z|0}function o(h,I,b,g){let w=h[0],B=h[1],T=h[2],H=h[3],N=I[0],X=I[1],P=I[2],F=I[3],q=I[4],W=I[5],K=I[6],J=I[7],te=b[0],ne=b[1],Y=b[2],Q=b[3];for(let D=0;D<20;D+=2)w=w+N|0,te=(0,t.rotl)(te^w,16),q=q+te|0,N=(0,t.rotl)(N^q,12),w=w+N|0,te=(0,t.rotl)(te^w,8),q=q+te|0,N=(0,t.rotl)(N^q,7),B=B+X|0,ne=(0,t.rotl)(ne^B,16),W=W+ne|0,X=(0,t.rotl)(X^W,12),B=B+X|0,ne=(0,t.rotl)(ne^B,8),W=W+ne|0,X=(0,t.rotl)(X^W,7),T=T+P|0,Y=(0,t.rotl)(Y^T,16),K=K+Y|0,P=(0,t.rotl)(P^K,12),T=T+P|0,Y=(0,t.rotl)(Y^T,8),K=K+Y|0,P=(0,t.rotl)(P^K,7),H=H+F|0,Q=(0,t.rotl)(Q^H,16),J=J+Q|0,F=(0,t.rotl)(F^J,12),H=H+F|0,Q=(0,t.rotl)(Q^H,8),J=J+Q|0,F=(0,t.rotl)(F^J,7),w=w+X|0,Q=(0,t.rotl)(Q^w,16),K=K+Q|0,X=(0,t.rotl)(X^K,12),w=w+X|0,Q=(0,t.rotl)(Q^w,8),K=K+Q|0,X=(0,t.rotl)(X^K,7),B=B+P|0,te=(0,t.rotl)(te^B,16),J=J+te|0,P=(0,t.rotl)(P^J,12),B=B+P|0,te=(0,t.rotl)(te^B,8),J=J+te|0,P=(0,t.rotl)(P^J,7),T=T+F|0,ne=(0,t.rotl)(ne^T,16),q=q+ne|0,F=(0,t.rotl)(F^q,12),T=T+F|0,ne=(0,t.rotl)(ne^T,8),q=q+ne|0,F=(0,t.rotl)(F^q,7),H=H+N|0,Y=(0,t.rotl)(Y^H,16),W=W+Y|0,N=(0,t.rotl)(N^W,12),H=H+N|0,Y=(0,t.rotl)(Y^H,8),W=W+Y|0,N=(0,t.rotl)(N^W,7);let v=0;g[v++]=w,g[v++]=B,g[v++]=T,g[v++]=H,g[v++]=te,g[v++]=ne,g[v++]=Y,g[v++]=Q}e.chacha20orig=(0,t.createCipher)(i,{counterRight:!1,counterLength:8,allowShortKeys:!0}),e.chacha20=(0,t.createCipher)(i,{counterRight:!1,counterLength:4,allowShortKeys:!1}),e.xchacha20=(0,t.createCipher)(i,{counterRight:!1,counterLength:8,extendNonceFn:o,allowShortKeys:!1}),e.chacha8=(0,t.createCipher)(i,{counterRight:!1,counterLength:4,rounds:8}),e.chacha12=(0,t.createCipher)(i,{counterRight:!1,counterLength:4,rounds:12});const s=new Uint8Array(16),a=(h,I)=>{h.update(I);const b=I.length%16;b&&h.update(s.subarray(b))},d=new Uint8Array(32);function u(h,I,b,g,w){const B=h(I,b,d),T=n.poly1305.create(B);w&&a(T,w),a(T,g);const H=(0,r.u64Lengths)(g.length,w?w.length:0,!0);T.update(H);const N=T.digest();return(0,r.clean)(B,H),N}const p=h=>(I,b,g)=>({encrypt(B,T){const H=B.length;T=(0,r.getOutput)(H+16,T,!1),T.set(B);const N=T.subarray(0,-16);h(I,b,N,N,1);const X=u(h,I,b,N,g);return T.set(X,H),(0,r.clean)(X),T},decrypt(B,T){T=(0,r.getOutput)(B.length-16,T,!1);const H=B.subarray(0,-16),N=B.subarray(-16),X=u(h,I,b,H,g);if(!(0,r.equalBytes)(N,X))throw new Error("invalid tag");return T.set(B.subarray(0,-16)),h(I,b,T,T,1),(0,r.clean)(X),T}});e._poly1305_aead=p,e.chacha20poly1305=(0,r.wrapCipher)({blockSize:64,nonceLength:12,tagLength:16},(0,e._poly1305_aead)(e.chacha20)),e.xchacha20poly1305=(0,r.wrapCipher)({blockSize:64,nonceLength:24,tagLength:16},(0,e._poly1305_aead)(e.xchacha20))})(_i)),_i}var fa;function Sh(){if(fa)return Ot;fa=1,Object.defineProperty(Ot,"__esModule",{value:!0}),Ot.chacha20=Ot.xchacha20=void 0;var e=Eh(),t=function(r,i,o){return(0,e.xchacha20poly1305)(r,i,o)};Ot.xchacha20=t;var n=function(r,i,o){return(0,e.chacha20poly1305)(r,i,o)};return Ot.chacha20=n,Ot}var ha;function Bh(){return ha||(ha=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.aesDecrypt=e.aesEncrypt=e.symDecrypt=e.symEncrypt=void 0;var t=Xe(),n=ks(),r=bh(),i=Sh(),o=rr(),s=ti(),a=function(I,b,g){return u(p,I,b,g)};e.symEncrypt=a;var d=function(I,b,g){return u(h,I,b,g)};e.symDecrypt=d,e.aesEncrypt=e.symEncrypt,e.aesDecrypt=e.symDecrypt;function u(I,b,g,w){var B=(0,o.symmetricAlgorithm)();if(B==="aes-256-gcm")return I(r.aes256gcm,b,g,(0,o.symmetricNonceLength)(),s.AEAD_TAG_LENGTH,w);if(B==="xchacha20")return I(i.xchacha20,b,g,s.XCHACHA20_NONCE_LENGTH,s.AEAD_TAG_LENGTH,w);if(B==="aes-256-cbc")return I(r.aes256cbc,b,g,16,0);throw new Error("Not implemented")}function p(I,b,g,w,B,T){var H=(0,n.randomBytes)(w),N=I(b,H,T),X=N.encrypt(g);if(B===0)return(0,t.concatBytes)(H,X);var P=X.length-B,F=X.subarray(0,P),q=X.subarray(P);return(0,t.concatBytes)(H,q,F)}function h(I,b,g,w,B,T){var H=g.subarray(0,w),N=I(b,Uint8Array.from(H),T),X=g.subarray(w);if(B===0)return N.decrypt(X);var P=X.subarray(0,B),F=X.subarray(B);return N.decrypt((0,t.concatBytes)(F,P))}})(gi)),gi}var pa;function bi(){return pa||(pa=1,(function(e){var t=Lt&&Lt.__createBinding||(Object.create?(function(r,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(r,s,a)}):(function(r,i,o,s){s===void 0&&(s=o),r[s]=i[o]})),n=Lt&&Lt.__exportStar||function(r,i){for(var o in r)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,r,o)};Object.defineProperty(e,"__esModule",{value:!0}),n(ph(),e),n(gh(),e),n(na(),e),n(Bh(),e)})(Lt)),Lt}var En={},ya;function ga(){if(ya)return En;ya=1,Object.defineProperty(En,"__esModule",{value:!0}),En.PublicKey=void 0;var e=Xe(),t=bi(),n=(function(){function r(i,o){var s=(0,t.convertPublicKeyFormat)(i,!0,o),a=(0,t.convertPublicKeyFormat)(i,!1,o);this.data=s,this.dataUncompressed=s.length!==a.length?a:null}return r.fromHex=function(i,o){return new r((0,t.hexToPublicKey)(i,o),o)},Object.defineProperty(r.prototype,"_uncompressed",{get:function(){return this.dataUncompressed!==null?this.dataUncompressed:this.data},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"uncompressed",{get:function(){return Buffer.from(this._uncompressed)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"compressed",{get:function(){return Buffer.from(this.data)},enumerable:!1,configurable:!0}),r.prototype.toBytes=function(i){return i===void 0&&(i=!0),i?this.data:this._uncompressed},r.prototype.toHex=function(i){return i===void 0&&(i=!0),(0,e.bytesToHex)(this.toBytes(i))},r.prototype.decapsulate=function(i,o){o===void 0&&(o=!1);var s=this.toBytes(o),a=i.multiply(this,o);return(0,t.getSharedKey)(s,a)},r.prototype.equals=function(i){return(0,e.equalBytes)(this.data,i.data)},r})();return En.PublicKey=n,En}var ma;function Ih(){if(ma)return mn;ma=1,Object.defineProperty(mn,"__esModule",{value:!0}),mn.PrivateKey=void 0;var e=Xe(),t=bi(),n=ga(),r=(function(){function i(o,s){if(this.curve=s,o===void 0)this.data=(0,t.getValidSecret)(s);else if((0,t.isValidPrivateKey)(o,s))this.data=o;else throw new Error("Invalid private key");this.publicKey=new n.PublicKey((0,t.getPublicKey)(this.data,s),s)}return i.fromHex=function(o,s){return new i((0,t.decodeHex)(o),s)},Object.defineProperty(i.prototype,"secret",{get:function(){return Buffer.from(this.data)},enumerable:!1,configurable:!0}),i.prototype.toHex=function(){return(0,e.bytesToHex)(this.data)},i.prototype.encapsulate=function(o,s){s===void 0&&(s=!1);var a=this.publicKey.toBytes(s),d=this.multiply(o,s);return(0,t.getSharedKey)(a,d)},i.prototype.multiply=function(o,s){return s===void 0&&(s=!1),(0,t.getSharedPoint)(this.data,o.toBytes(!0),s,this.curve)},i.prototype.equals=function(o){return(0,e.equalBytes)(this.data,o.data)},i})();return mn.PrivateKey=r,mn}var _a;function ba(){return _a||(_a=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.PublicKey=e.PrivateKey=void 0;var t=Ih();Object.defineProperty(e,"PrivateKey",{enumerable:!0,get:function(){return t.PrivateKey}});var n=ga();Object.defineProperty(e,"PublicKey",{enumerable:!0,get:function(){return n.PublicKey}})})(ni)),ni}var wa;function xh(){return wa||(wa=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.utils=e.PublicKey=e.PrivateKey=e.ECIES_CONFIG=void 0,e.encrypt=o,e.decrypt=a;var t=Xe(),n=rr(),r=ba(),i=bi();function o(h,I){return Buffer.from(s(h,I))}function s(h,I){var b=(0,n.ellipticCurve)(),g=new r.PrivateKey(void 0,b),w=h instanceof Uint8Array?new r.PublicKey(h,b):r.PublicKey.fromHex(h,b),B=g.encapsulate(w,(0,n.isHkdfKeyCompressed)()),T=g.publicKey.toBytes((0,n.isEphemeralKeyCompressed)()),H=(0,i.symEncrypt)(B,I);return(0,t.concatBytes)(T,H)}function a(h,I){return Buffer.from(d(h,I))}function d(h,I){var b=(0,n.ellipticCurve)(),g=h instanceof Uint8Array?new r.PrivateKey(h,b):r.PrivateKey.fromHex(h,b),w=(0,n.ephemeralKeySize)(),B=new r.PublicKey(I.subarray(0,w),b),T=I.subarray(w),H=B.decapsulate(g,(0,n.isHkdfKeyCompressed)());return(0,i.symDecrypt)(H,T)}var u=rr();Object.defineProperty(e,"ECIES_CONFIG",{enumerable:!0,get:function(){return u.ECIES_CONFIG}});var p=ba();Object.defineProperty(e,"PrivateKey",{enumerable:!0,get:function(){return p.PrivateKey}}),Object.defineProperty(e,"PublicKey",{enumerable:!0,get:function(){return p.PublicKey}}),e.utils={aesEncrypt:i.aesEncrypt,aesDecrypt:i.aesDecrypt,symEncrypt:i.symEncrypt,symDecrypt:i.symDecrypt,decodeHex:i.decodeHex,getValidSecret:i.getValidSecret,remove0x:i.remove0x}})(Jr)),Jr}var wi=xh();typeof globalThis.Buffer>"u"&&(globalThis.Buffer=ih.Buffer),wi.ECIES_CONFIG.ellipticCurve="secp256k1",wi.ECIES_CONFIG.symmetricAlgorithm="aes-256-gcm";const Lh=new TextEncoder;function Ah(e,t){return wi.encrypt(e,Lh.encode(t)).toString("hex")}const Ch=["CORE_SDK",...Yf()];async function va(e,t,n,r){if(!e||!t)throw new Error("appId and secret are required");try{const i=await Xf(),o=await Oh(n,r),{identifier:s,sdkVersion:a,...d}=o,u={"Content-Type":"text/plain",sdkVersion:a},p=Ph(i,{appId:e,secret:t,identifier:s,timestamp:Date.now(),products:Ch,...d}),h=await fetch(Go,{method:"POST",body:p,headers:u});if(!h.ok){const B=await h.json(),{code:T,message:H}=B;throw h.status===401&&T===7001005?(Bs(),new Error(H)):new Error(H||`HTTP error! status: ${h.status}`)}const I=await h.json(),{accessToken:b,expiresIn:g}=I,w=Date.now()+(g-90)*1e3;return{accessToken:b,expiredTime:w}}catch(i){throw i instanceof Error?new Error(`Failed to get access token: ${i.message}`,{cause:i}):new Error(`Failed to get access token: ${String(i)}`)}}const Th=typeof window<"u"&&window.location?.hostname?window.location.hostname:"restriction.test.example.com";async function Oh(e,t=Th){return e??Rh(t)}async function Rh(e){return{identifier:await xs(),origin:e,keyPlatform:"WEB",sdkVersion:yn.version}}function Ph(e,t){return Ah(e,JSON.stringify(t))}var Fh={value:()=>{}};function Wt(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new or(n)}function or(e){this._=e}function kh(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}or.prototype=Wt.prototype={constructor:or,on:function(e,t){var n=this._,r=kh(e+"",n),i,o=-1,s=r.length;if(arguments.length<2){for(;++o<s;)if((i=(e=r[o]).type)&&(i=Mh(n[i],e.name)))return i;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++o<s;)if(i=(e=r[o]).type)n[i]=Ea(n[i],e.name,t);else if(t==null)for(i in n)n[i]=Ea(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new or(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,o;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(o=this._[e],r=0,i=o.length;r<i;++r)o[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],i=0,o=r.length;i<o;++i)r[i].value.apply(t,n)}};function Mh(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function Ea(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=Fh,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}const vi="tokenUpdated",Hh={maxRetries:3,initialDelay:500};class nt{static instance;_appId="";_secret="";_platform;_accessToken="";_expiredTime=0;_version="";_identifier="";_webIdentifier="";_tokenGetter;_tokenPending=null;_dispatch=Wt(vi);_globalDispatcher;constructor(){}static getInstance(){return nt.instance||(nt.instance=new nt),nt.instance}async setAccessByAppKey(t){this._tokenGetter=this._fetchToken.bind(this);const{appId:n,secret:r,platform:i}=t;this._appId=n,this._secret=r,this._platform=i,this._version=i?.sdkVersion||yn.version,this._identifier=i?.identifier||await this.getWebIdentifier()}setTokenGetter(t){this._tokenGetter=t}async setupTokenManager(){if(!this._tokenGetter)throw new Error("getTokenAsync() is not set!");const{maxRetries:t,initialDelay:n}=Hh;let r=0;for(;r<=t;)try{const i=await this._tokenGetter();if(i){this._updateContext(i);return}}catch(i){if(r++,r>t)throw this._globalDispatcher.call("unauthorized"),i;await this._retryDelay(r,n)}}getSdkVersion(){return this._version||yn.version}async getIdentifier(){return this._identifier||await this.getWebIdentifier()}async getAccessToken(){if(this._accessToken&&!this._isTokenExpired)return this._accessToken;if(this._tokenPending)return this._tokenPending;if(!this._tokenGetter)throw new Error("Token getter not configured. Call setGetTokenAsync() first.");return this._tokenPending=this._tokenGetter().then(t=>(this._updateContext(t),this._dispatch.call(vi,null,t.accessToken),t.accessToken)).catch(t=>{throw this._tokenPending=null,t}).finally(()=>{this._tokenPending=null}),this._tokenPending}async getWebIdentifier(){if(!this._webIdentifier){const n=await(await Es.load()).get();this._webIdentifier=n.visitorId}return this._webIdentifier}on(t,n){return this._dispatch.on(t,n),{off:()=>this._dispatch.on(t,null)}}setGlobalDispatcher(t){this._globalDispatcher=t}getGlobalDispatcher(){return this._globalDispatcher}clearState(){this._appId="",this._secret="",this._platform=void 0,this._webIdentifier="",this._tokenPending=null,this._tokenGetter=void 0,this._accessToken="",this._expiredTime=0,this._version="",this._identifier=""}get _isTokenExpired(){return this._expiredTime<=Date.now()}_updateContext(t){const{accessToken:n,expiredTime:r,identifier:i,sdkVersion:o}=t;this._accessToken=n,this._expiredTime=r,i!==void 0&&(this._identifier=i),o!==void 0&&(this._version=o)}_fetchToken(){return va(this._appId,this._secret,this._platform)}async _retryDelay(t,n){const r=n*Math.pow(2,t-1);return console.warn(`Retrying in ${r} ms... (Attempt ${t})`),new Promise(i=>setTimeout(i,r))}}const sr=nt.getInstance();class st{static instance;_axios;_isRefreshingToken=!1;_retryCount=0;constructor(){this._axios=Pe.create({baseURL:zo}),this._setupInterceptors()}static getInstance(){return st.instance||(st.instance=new st),st.instance}async get(t){return this._axios.get(t)}async post(t,n){return this._axios.post(t,n)}async getRequestHeaders(){return{"Content-Type":"application/json",sdkVersion:sr.getSdkVersion(),identifier:await sr.getIdentifier(),token:await sr.getAccessToken()}}_setupInterceptors(){this._axios.interceptors.request.use(async t=>{const n=await this.getRequestHeaders();return t.headers=Object.assign({},t.headers,n),t},t=>{throw t}),this._axios.interceptors.response.use(null,async t=>{if(t.response?.status!==401||this._retryCount>=3)throw this._retryCount=0,t;if(this._isRefreshingToken)throw t;sr.getGlobalDispatcher().call("unauthorized"),this._isRefreshingToken=!0,this._retryCount++;try{const n=await this.getRequestHeaders(),r=t.config;return r.headers=Object.assign({},r.headers,n),this._axios.request(r)}catch(n){throw n}finally{this._isRefreshingToken=!1}})}}function at(e){if(!e)return null;const n=(Array.isArray(e)?e:[e]).filter(xe).map(r=>r.trim());return n.length>0?n.join(","):null}function xe(e){return typeof e=="string"&&e.trim().length>0}function Rt(e){return Array.isArray(e)&&e.length===2&&e.every(t=>typeof t=="number")}function Sn(e){return Array.isArray(e)&&e.length===2&&e.every(t=>Rt(t))}function Yt(e){return typeof e=="number"&&e>0}function Uh(){this.__data__=[],this.size=0}function Ei(e,t){return e===t||e!==e&&t!==t}function ar(e,t){for(var n=e.length;n--;)if(Ei(e[n][0],t))return n;return-1}var Nh=Array.prototype,Dh=Nh.splice;function $h(e){var t=this.__data__,n=ar(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():Dh.call(t,n,1),--this.size,!0}function Vh(e){var t=this.__data__,n=ar(t,e);return n<0?void 0:t[n][1]}function jh(e){return ar(this.__data__,e)>-1}function qh(e,t){var n=this.__data__,r=ar(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function dt(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}dt.prototype.clear=Uh,dt.prototype.delete=$h,dt.prototype.get=Vh,dt.prototype.has=jh,dt.prototype.set=qh;function Kh(){this.__data__=new dt,this.size=0}function Gh(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function zh(e){return this.__data__.get(e)}function Zh(e){return this.__data__.has(e)}var Sa=typeof global=="object"&&global&&global.Object===Object&&global,Wh=typeof self=="object"&&self&&self.Object===Object&&self,ct=Sa||Wh||Function("return this")(),vt=ct.Symbol,Ba=Object.prototype,Yh=Ba.hasOwnProperty,Xh=Ba.toString,Bn=vt?vt.toStringTag:void 0;function Jh(e){var t=Yh.call(e,Bn),n=e[Bn];try{e[Bn]=void 0;var r=!0}catch{}var i=Xh.call(e);return r&&(t?e[Bn]=n:delete e[Bn]),i}var Qh=Object.prototype,e0=Qh.toString;function t0(e){return e0.call(e)}var n0="[object Null]",r0="[object Undefined]",Ia=vt?vt.toStringTag:void 0;function Xt(e){return e==null?e===void 0?r0:n0:Ia&&Ia in Object(e)?Jh(e):t0(e)}function ft(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var i0="[object AsyncFunction]",o0="[object Function]",s0="[object GeneratorFunction]",a0="[object Proxy]";function xa(e){if(!ft(e))return!1;var t=Xt(e);return t==o0||t==s0||t==i0||t==a0}var Si=ct["__core-js_shared__"],La=(function(){var e=/[^.]+$/.exec(Si&&Si.keys&&Si.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""})();function c0(e){return!!La&&La in e}var l0=Function.prototype,u0=l0.toString;function Pt(e){if(e!=null){try{return u0.call(e)}catch{}try{return e+""}catch{}}return""}var d0=/[\\^$.*+?()[\]{}|]/g,f0=/^\[object .+?Constructor\]$/,h0=Function.prototype,p0=Object.prototype,y0=h0.toString,g0=p0.hasOwnProperty,m0=RegExp("^"+y0.call(g0).replace(d0,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function _0(e){if(!ft(e)||c0(e))return!1;var t=xa(e)?m0:f0;return t.test(Pt(e))}function b0(e,t){return e?.[t]}function Ft(e,t){var n=b0(e,t);return _0(n)?n:void 0}var In=Ft(ct,"Map"),xn=Ft(Object,"create");function w0(){this.__data__=xn?xn(null):{},this.size=0}function v0(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var E0="__lodash_hash_undefined__",S0=Object.prototype,B0=S0.hasOwnProperty;function I0(e){var t=this.__data__;if(xn){var n=t[e];return n===E0?void 0:n}return B0.call(t,e)?t[e]:void 0}var x0=Object.prototype,L0=x0.hasOwnProperty;function A0(e){var t=this.__data__;return xn?t[e]!==void 0:L0.call(t,e)}var C0="__lodash_hash_undefined__";function T0(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=xn&&t===void 0?C0:t,this}function kt(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}kt.prototype.clear=w0,kt.prototype.delete=v0,kt.prototype.get=I0,kt.prototype.has=A0,kt.prototype.set=T0;function O0(){this.size=0,this.__data__={hash:new kt,map:new(In||dt),string:new kt}}function R0(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function cr(e,t){var n=e.__data__;return R0(t)?n[typeof t=="string"?"string":"hash"]:n.map}function P0(e){var t=cr(this,e).delete(e);return this.size-=t?1:0,t}function F0(e){return cr(this,e).get(e)}function k0(e){return cr(this,e).has(e)}function M0(e,t){var n=cr(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function ht(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}ht.prototype.clear=O0,ht.prototype.delete=P0,ht.prototype.get=F0,ht.prototype.has=k0,ht.prototype.set=M0;var H0=200;function U0(e,t){var n=this.__data__;if(n instanceof dt){var r=n.__data__;if(!In||r.length<H0-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new ht(r)}return n.set(e,t),this.size=n.size,this}function pt(e){var t=this.__data__=new dt(e);this.size=t.size}pt.prototype.clear=Kh,pt.prototype.delete=Gh,pt.prototype.get=zh,pt.prototype.has=Zh,pt.prototype.set=U0;var N0="__lodash_hash_undefined__";function D0(e){return this.__data__.set(e,N0),this}function $0(e){return this.__data__.has(e)}function Ln(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new ht;++t<n;)this.add(e[t])}Ln.prototype.add=Ln.prototype.push=D0,Ln.prototype.has=$0;function V0(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}function Aa(e,t){return e.has(t)}var j0=1,q0=2;function Ca(e,t,n,r,i,o){var s=n&j0,a=e.length,d=t.length;if(a!=d&&!(s&&d>a))return!1;var u=o.get(e),p=o.get(t);if(u&&p)return u==t&&p==e;var h=-1,I=!0,b=n&q0?new Ln:void 0;for(o.set(e,t),o.set(t,e);++h<a;){var g=e[h],w=t[h];if(r)var B=s?r(w,g,h,t,e,o):r(g,w,h,e,t,o);if(B!==void 0){if(B)continue;I=!1;break}if(b){if(!V0(t,function(T,H){if(!Aa(b,H)&&(g===T||i(g,T,n,r,o)))return b.push(H)})){I=!1;break}}else if(!(g===w||i(g,w,n,r,o))){I=!1;break}}return o.delete(e),o.delete(t),I}var Ta=ct.Uint8Array;function K0(e){var t=-1,n=Array(e.size);return e.forEach(function(r,i){n[++t]=[i,r]}),n}function Bi(e){var t=-1,n=Array(e.size);return e.forEach(function(r){n[++t]=r}),n}var G0=1,z0=2,Z0="[object Boolean]",W0="[object Date]",Y0="[object Error]",X0="[object Map]",J0="[object Number]",Q0="[object RegExp]",ep="[object Set]",tp="[object String]",np="[object Symbol]",rp="[object ArrayBuffer]",ip="[object DataView]",Oa=vt?vt.prototype:void 0,Ii=Oa?Oa.valueOf:void 0;function op(e,t,n,r,i,o,s){switch(n){case ip:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case rp:return!(e.byteLength!=t.byteLength||!o(new Ta(e),new Ta(t)));case Z0:case W0:case J0:return Ei(+e,+t);case Y0:return e.name==t.name&&e.message==t.message;case Q0:case tp:return e==t+"";case X0:var a=K0;case ep:var d=r&G0;if(a||(a=Bi),e.size!=t.size&&!d)return!1;var u=s.get(e);if(u)return u==t;r|=z0,s.set(e,t);var p=Ca(a(e),a(t),r,i,o,s);return s.delete(e),p;case np:if(Ii)return Ii.call(e)==Ii.call(t)}return!1}function Ra(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}var yt=Array.isArray;function Pa(e,t,n){var r=t(e);return yt(e)?r:Ra(r,n(e))}function sp(e,t){for(var n=-1,r=e==null?0:e.length,i=0,o=[];++n<r;){var s=e[n];t(s,n,e)&&(o[i++]=s)}return o}function Fa(){return[]}var ap=Object.prototype,cp=ap.propertyIsEnumerable,ka=Object.getOwnPropertySymbols,Ma=ka?function(e){return e==null?[]:(e=Object(e),sp(ka(e),function(t){return cp.call(e,t)}))}:Fa;function lp(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}function Jt(e){return e!=null&&typeof e=="object"}var up="[object Arguments]";function Ha(e){return Jt(e)&&Xt(e)==up}var Ua=Object.prototype,dp=Ua.hasOwnProperty,fp=Ua.propertyIsEnumerable,Na=Ha((function(){return arguments})())?Ha:function(e){return Jt(e)&&dp.call(e,"callee")&&!fp.call(e,"callee")};function hp(){return!1}var Da=typeof _e=="object"&&_e&&!_e.nodeType&&_e,$a=Da&&typeof module=="object"&&module&&!module.nodeType&&module,pp=$a&&$a.exports===Da,Va=pp?ct.Buffer:void 0,yp=Va?Va.isBuffer:void 0,xi=yp||hp,gp=9007199254740991,mp=/^(?:0|[1-9]\d*)$/;function Li(e,t){var n=typeof e;return t=t??gp,!!t&&(n=="number"||n!="symbol"&&mp.test(e))&&e>-1&&e%1==0&&e<t}var _p=9007199254740991;function Ai(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=_p}var bp="[object Arguments]",wp="[object Array]",vp="[object Boolean]",Ep="[object Date]",Sp="[object Error]",Bp="[object Function]",Ip="[object Map]",xp="[object Number]",Lp="[object Object]",Ap="[object RegExp]",Cp="[object Set]",Tp="[object String]",Op="[object WeakMap]",Rp="[object ArrayBuffer]",Pp="[object DataView]",Fp="[object Float32Array]",kp="[object Float64Array]",Mp="[object Int8Array]",Hp="[object Int16Array]",Up="[object Int32Array]",Np="[object Uint8Array]",Dp="[object Uint8ClampedArray]",$p="[object Uint16Array]",Vp="[object Uint32Array]",Te={};Te[Fp]=Te[kp]=Te[Mp]=Te[Hp]=Te[Up]=Te[Np]=Te[Dp]=Te[$p]=Te[Vp]=!0,Te[bp]=Te[wp]=Te[Rp]=Te[vp]=Te[Pp]=Te[Ep]=Te[Sp]=Te[Bp]=Te[Ip]=Te[xp]=Te[Lp]=Te[Ap]=Te[Cp]=Te[Tp]=Te[Op]=!1;function jp(e){return Jt(e)&&Ai(e.length)&&!!Te[Xt(e)]}function qp(e){return function(t){return e(t)}}var ja=typeof _e=="object"&&_e&&!_e.nodeType&&_e,An=ja&&typeof module=="object"&&module&&!module.nodeType&&module,Kp=An&&An.exports===ja,Ci=Kp&&Sa.process,qa=(function(){try{var e=An&&An.require&&An.require("util").types;return e||Ci&&Ci.binding&&Ci.binding("util")}catch{}})(),Ka=qa&&qa.isTypedArray,Ga=Ka?qp(Ka):jp,Gp=Object.prototype,zp=Gp.hasOwnProperty;function za(e,t){var n=yt(e),r=!n&&Na(e),i=!n&&!r&&xi(e),o=!n&&!r&&!i&&Ga(e),s=n||r||i||o,a=s?lp(e.length,String):[],d=a.length;for(var u in e)(t||zp.call(e,u))&&!(s&&(u=="length"||i&&(u=="offset"||u=="parent")||o&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||Li(u,d)))&&a.push(u);return a}var Zp=Object.prototype;function Za(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||Zp;return e===n}function Wa(e,t){return function(n){return e(t(n))}}var Wp=Wa(Object.keys,Object),Yp=Object.prototype,Xp=Yp.hasOwnProperty;function Jp(e){if(!Za(e))return Wp(e);var t=[];for(var n in Object(e))Xp.call(e,n)&&n!="constructor"&&t.push(n);return t}function Ya(e){return e!=null&&Ai(e.length)&&!xa(e)}function Xa(e){return Ya(e)?za(e):Jp(e)}function Ja(e){return Pa(e,Xa,Ma)}var Qp=1,ey=Object.prototype,ty=ey.hasOwnProperty;function ny(e,t,n,r,i,o){var s=n&Qp,a=Ja(e),d=a.length,u=Ja(t),p=u.length;if(d!=p&&!s)return!1;for(var h=d;h--;){var I=a[h];if(!(s?I in t:ty.call(t,I)))return!1}var b=o.get(e),g=o.get(t);if(b&&g)return b==t&&g==e;var w=!0;o.set(e,t),o.set(t,e);for(var B=s;++h<d;){I=a[h];var T=e[I],H=t[I];if(r)var N=s?r(H,T,I,t,e,o):r(T,H,I,e,t,o);if(!(N===void 0?T===H||i(T,H,n,r,o):N)){w=!1;break}B||(B=I=="constructor")}if(w&&!B){var X=e.constructor,P=t.constructor;X!=P&&"constructor"in e&&"constructor"in t&&!(typeof X=="function"&&X instanceof X&&typeof P=="function"&&P instanceof P)&&(w=!1)}return o.delete(e),o.delete(t),w}var Ti=Ft(ct,"DataView"),Oi=Ft(ct,"Promise"),Qt=Ft(ct,"Set"),Ri=Ft(ct,"WeakMap"),Qa="[object Map]",ry="[object Object]",ec="[object Promise]",tc="[object Set]",nc="[object WeakMap]",rc="[object DataView]",iy=Pt(Ti),oy=Pt(In),sy=Pt(Oi),ay=Pt(Qt),cy=Pt(Ri),Et=Xt;(Ti&&Et(new Ti(new ArrayBuffer(1)))!=rc||In&&Et(new In)!=Qa||Oi&&Et(Oi.resolve())!=ec||Qt&&Et(new Qt)!=tc||Ri&&Et(new Ri)!=nc)&&(Et=function(e){var t=Xt(e),n=t==ry?e.constructor:void 0,r=n?Pt(n):"";if(r)switch(r){case iy:return rc;case oy:return Qa;case sy:return ec;case ay:return tc;case cy:return nc}return t});var ly=1,ic="[object Arguments]",oc="[object Array]",lr="[object Object]",uy=Object.prototype,sc=uy.hasOwnProperty;function dy(e,t,n,r,i,o){var s=yt(e),a=yt(t),d=s?oc:Et(e),u=a?oc:Et(t);d=d==ic?lr:d,u=u==ic?lr:u;var p=d==lr,h=u==lr,I=d==u;if(I&&xi(e)){if(!xi(t))return!1;s=!0,p=!1}if(I&&!p)return o||(o=new pt),s||Ga(e)?Ca(e,t,n,r,i,o):op(e,t,d,n,r,i,o);if(!(n&ly)){var b=p&&sc.call(e,"__wrapped__"),g=h&&sc.call(t,"__wrapped__");if(b||g){var w=b?e.value():e,B=g?t.value():t;return o||(o=new pt),i(w,B,n,r,o)}}return I?(o||(o=new pt),ny(e,t,n,r,i,o)):!1}function Pi(e,t,n,r,i){return e===t?!0:e==null||t==null||!Jt(e)&&!Jt(t)?e!==e&&t!==t:dy(e,t,n,r,Pi,i)}var fy=1,hy=2;function py(e,t,n,r){var i=n.length,o=i;if(e==null)return!o;for(e=Object(e);i--;){var s=n[i];if(s[2]?s[1]!==e[s[0]]:!(s[0]in e))return!1}for(;++i<o;){s=n[i];var a=s[0],d=e[a],u=s[1];if(s[2]){if(d===void 0&&!(a in e))return!1}else{var p=new pt,h;if(!(h===void 0?Pi(u,d,fy|hy,r,p):h))return!1}}return!0}function ac(e){return e===e&&!ft(e)}function yy(e){for(var t=Xa(e),n=t.length;n--;){var r=t[n],i=e[r];t[n]=[r,i,ac(i)]}return t}function cc(e,t){return function(n){return n==null?!1:n[e]===t&&(t!==void 0||e in Object(n))}}function gy(e){var t=yy(e);return t.length==1&&t[0][2]?cc(t[0][0],t[0][1]):function(n){return n===e||py(n,e,t)}}var my="[object Symbol]";function Cn(e){return typeof e=="symbol"||Jt(e)&&Xt(e)==my}var _y=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,by=/^\w*$/;function Fi(e,t){if(yt(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||Cn(e)?!0:by.test(e)||!_y.test(e)||t!=null&&e in Object(t)}var wy="Expected a function";function ki(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(wy);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var s=e.apply(this,r);return n.cache=o.set(i,s)||o,s};return n.cache=new(ki.Cache||ht),n}ki.Cache=ht;var vy=500;function Ey(e){var t=ki(e,function(r){return n.size===vy&&n.clear(),r}),n=t.cache;return t}var Sy=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,By=/\\(\\)?/g,Iy=Ey(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(Sy,function(n,r,i,o){t.push(i?o.replace(By,"$1"):r||n)}),t});function lc(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}var uc=vt?vt.prototype:void 0,dc=uc?uc.toString:void 0;function fc(e){if(typeof e=="string")return e;if(yt(e))return lc(e,fc)+"";if(Cn(e))return dc?dc.call(e):"";var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function hc(e){return e==null?"":fc(e)}function ur(e,t){return yt(e)?e:Fi(e,t)?[e]:Iy(hc(e))}function Tn(e){if(typeof e=="string"||Cn(e))return e;var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function Mi(e,t){t=ur(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[Tn(t[n++])];return n&&n==r?e:void 0}function xy(e,t,n){var r=e==null?void 0:Mi(e,t);return r===void 0?n:r}function Ly(e,t){return e!=null&&t in Object(e)}function Ay(e,t,n){t=ur(t,e);for(var r=-1,i=t.length,o=!1;++r<i;){var s=Tn(t[r]);if(!(o=e!=null&&n(e,s)))break;e=e[s]}return o||++r!=i?o:(i=e==null?0:e.length,!!i&&Ai(i)&&Li(s,i)&&(yt(e)||Na(e)))}function Cy(e,t){return e!=null&&Ay(e,t,Ly)}var Ty=1,Oy=2;function Ry(e,t){return Fi(e)&&ac(t)?cc(Tn(e),t):function(n){var r=xy(n,e);return r===void 0&&r===t?Cy(n,e):Pi(t,r,Ty|Oy)}}function Py(e){return e}function Fy(e){return function(t){return t?.[e]}}function ky(e){return function(t){return Mi(t,e)}}function My(e){return Fi(e)?Fy(Tn(e)):ky(e)}function dr(e){return typeof e=="function"?e:e==null?Py:typeof e=="object"?yt(e)?Ry(e[0],e[1]):gy(e):My(e)}var Hy="Expected a function";function Uy(e){if(typeof e!="function")throw new TypeError(Hy);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}var pc=(function(){try{var e=Ft(Object,"defineProperty");return e({},"",{}),e}catch{}})();function Ny(e,t,n){t=="__proto__"&&pc?pc(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}var Dy=Object.prototype,$y=Dy.hasOwnProperty;function Vy(e,t,n){var r=e[t];(!($y.call(e,t)&&Ei(r,n))||n===void 0&&!(t in e))&&Ny(e,t,n)}function jy(e,t,n,r){if(!ft(e))return e;t=ur(t,e);for(var i=-1,o=t.length,s=o-1,a=e;a!=null&&++i<o;){var d=Tn(t[i]),u=n;if(d==="__proto__"||d==="constructor"||d==="prototype")return e;if(i!=s){var p=a[d];u=void 0,u===void 0&&(u=ft(p)?p:Li(t[i+1])?[]:{})}Vy(a,d,u),a=a[d]}return e}function qy(e,t,n){for(var r=-1,i=t.length,o={};++r<i;){var s=t[r],a=Mi(e,s);n(a,s)&&jy(o,ur(s,e),a)}return o}var Ky=Wa(Object.getPrototypeOf,Object),Gy=Object.getOwnPropertySymbols,zy=Gy?function(e){for(var t=[];e;)Ra(t,Ma(e)),e=Ky(e);return t}:Fa;function Zy(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}var Wy=Object.prototype,Yy=Wy.hasOwnProperty;function Xy(e){if(!ft(e))return Zy(e);var t=Za(e),n=[];for(var r in e)r=="constructor"&&(t||!Yy.call(e,r))||n.push(r);return n}function Jy(e){return Ya(e)?za(e,!0):Xy(e)}function Qy(e){return Pa(e,Jy,zy)}function eg(e,t){if(e==null)return{};var n=lc(Qy(e),function(r){return[r]});return t=dr(t),qy(e,n,function(r,i){return t(r,i[0])})}function Hi(e,t){return eg(e,Uy(dr(t)))}const tg=["opening_hours","description","phone","website","email","appURL","icon"];class yc{_api="/api/v5/venues";_request=st.getInstance();constructor(){}searchByIds(t){const n=at(t);if(!n)throw new Error("Please input venue id at least one.");const r=`${this._api}/${n}`;return this._changedRes(r)}searchByDistance(t){const{center:n,distance:r,keywords:i="",offset:o=Ge,page:s=ze}=t;if(!Rt(n))throw new Error("Invalid center parameter. Expected an array of two numbers.");if(!Yt(r)||r>1e4)throw new Error("Invalid distance parameter. Expected a positive number and no more than 10000.");const a=new URLSearchParams;a.set("center",n.join(",")),a.set("distance",String(r)),a.set("offset",String(o)),a.set("page",String(s)),xe(i)&&a.set("keywords",i);const d=`${this._api}?${a.toString()}`;return this._changedRes(d)}searchByBounds(t){const{keywords:n,bounds:r,offset:i=Ge,page:o=ze}=t;if(!Sn(r))throw new Error("'bounds' must be an array of two arrays, each containing two numbers.");const s=new URLSearchParams;s.set("bbox",r.flat().join()),s.set("offset",String(i)),s.set("page",String(o)),xe(n)&&s.set("keywords",n);const a=`${this._api}?${s.toString()}`;return this._changedRes(a)}searchByGlobal(t){const{keywords:n,offset:r=Ge,page:i=ze}=t,o=new URLSearchParams;o.set("offset",String(r)),o.set("page",String(i)),xe(n)&&o.set("keywords",n);const s=`${this._api}?${o.toString()}`;return this._changedRes(s)}searchBySharedFloorId(t){if(!xe(t))throw new Error("Please input correct sharedFloorId.");const n=`${this._api}/shared_floors/${t}`;return this._changedRes(n)}search(t){const n=new URLSearchParams;return Object.entries(t).forEach(([r,i])=>{r==="bounds"?n.set("bbox",i.flat().join()):r==="center"?n.set("center",i.join()):n.set(r,String(i))}),this._changedRes(`${this._api}?${n.toString()}`)}async _changedRes(t){return this._request.get(t).then(n=>{if(n.data?.result?.venues){const r=n.data.result.venues.map(i=>Hi(i,(o,s)=>tg.includes(s)));return{...n,data:{...n.data,result:{...n.data.result,venues:r}}}}return n})}}const ng=["specialHours","businessStatus","serviceHours","keywords","siteCode","refPhotoId","totalPhotoCount","photos","description"];class gc{_api="/api/v5/buildings";_request=st.getInstance();constructor(){}searchByIds(t){const n=at(t);if(!n)throw new Error("Please input building id at least one.");const r=`${this._api}/${n}`;return this._changedRes(r)}searchByDistance(t){const{center:n,distance:r,keywords:i="",offset:o=Ge,page:s=ze}=t;if(!Rt(n))throw new Error("Invalid center parameter. Expected an array of two numbers.");if(!Yt(r)||r>1e4)throw new Error("Invalid distance parameter. Expected a positive number and no more than 10000.");const a=new URLSearchParams;a.set("center",n.join(",")),a.set("distance",String(r)),a.set("offset",String(o)),a.set("page",String(s)),xe(i)&&a.set("keywords",i);const d=`${this._api}?${a.toString()}`;return this._changedRes(d)}searchByBounds(t){const{bounds:n,offset:r=Ge,page:i=ze,keywords:o}=t;if(!Sn(n))throw new Error("'bounds' must be an array of two arrays, each containing two numbers.");const s=new URLSearchParams;s.set("bbox",n.flat().join()),s.set("offset",String(r)),s.set("page",String(i)),xe(o)&&s.set("keywords",o);const a=`${this._api}?${s.toString()}`;return this._changedRes(a)}searchByGlobal(t){const{keywords:n,offset:r=Ge,page:i=ze}=t,o=new URLSearchParams;o.set("searchGlobal",String(!0)),o.set("offset",String(r)),o.set("page",String(i)),xe(n)&&o.set("keywords",n);const s=`${this._api}?${o.toString()}`;return this._changedRes(s)}searchByFloorId(t){if(!xe(t))throw new Error("'floorId' cannot be empty.");return this._changedRes(`${this._api}/floors/${t}`)}search(t){const n=new URLSearchParams;return Object.entries(t).forEach(([r,i])=>{r==="bounds"?n.set("bbox",i.flat().join()):r==="center"?n.set("center",i.join()):n.set(r,String(i))}),this._changedRes(`${this._api}?${n.toString()}`)}async _changedRes(t){return this._request.get(t).then(n=>{if(n.data?.result?.buildings){const r=n.data.result.buildings.map(i=>Hi(i,(o,s)=>ng.includes(s)));return{...n,data:{...n.data,result:{...n.data.result,buildings:r}}}}return n})}}const rg=["specialHours","businessStatus","serviceHours","keywords","siteCode","refPhotoId","totalPhotoCount","photos","icon"];class mc{_poisApi="/api/v5/pois";_categoriesGroupApi="/api/v5/categories/group";_request=st.getInstance();constructor(){}searchByIds(t){const n=at(t);if(!n)throw new Error("Invalid ids parameter. Expected a non-empty string or an array of strings.");const r=`${this._poisApi}/${n}`;return this._changedRes(r)}searchByDistance(t){const{center:n,distance:r,keywords:i="",offset:o=Ge,page:s=ze}=t;if(!Rt(n))throw new Error("Invalid center parameter. Expected an array of two numbers.");if(!Yt(r)||r>1e4)throw new Error("Invalid distance parameter. Expected a positive number and no more than 10000.");const a=new URLSearchParams;a.set("center",n.join(",")),a.set("distance",String(Math.round(r))),a.set("offset",String(o)),a.set("page",String(s)),xe(i)&&a.set("keywords",i);const d=`${this._poisApi}?${a.toString()}`;return this._changedRes(d)}searchByBounds(t){const{bounds:n,offset:r=Ge,page:i=ze,keywords:o,orderBy:s}=t;if(!Sn(n))throw new Error("'bounds' must be an array of two arrays, each containing two numbers.");const a=new URLSearchParams;a.set("bbox",n.flat().join()),a.set("offset",String(r)),a.set("page",String(i)),xe(o)&&a.set("keywords",o),s&&a.set("orderBy",s);const d=`${this._poisApi}?${a.toString()}`;return this._changedRes(d)}searchByBuilding(t){const{buildingId:n,offset:r=Ge,page:i=ze,keywords:o,orderBy:s}=t;if(!xe(n))throw new Error("'buildingId' must be a non-empty string.");const a=new URLSearchParams;a.set("buildingId",n),a.set("offset",String(r)),a.set("page",String(i)),xe(o)&&a.set("keywords",o),s&&a.set("orderBy",s);const d=`${this._poisApi}?${a.toString()}`;return this._changedRes(d)}searchByVenue(t){const{venueId:n,offset:r=Ge,page:i=ze,keywords:o,orderBy:s}=t;if(!xe(n))throw new Error("'venueId' must be a non-empty string.");const a=new URLSearchParams;a.set("venueId",n),a.set("offset",String(r)),a.set("page",String(i)),xe(o)&&a.set("keywords",o),s&&a.set("orderBy",s);const d=`${this._poisApi}?${a.toString()}`;return this._changedRes(d)}searchByFloor(t){let n=null,r=null;if("floorId"in t&&xe(t.floorId)?(n="floorId",r=t.floorId):"sharedFloorId"in t&&xe(t.sharedFloorId)&&(n="sharedFloorId",r=t.sharedFloorId),!n||!r)throw new Error("Either 'floorId' or 'sharedFloorId' must be a non-empty string.");const{offset:i=Ge,page:o=ze,keywords:s,orderBy:a}=t,d=new URLSearchParams;d.set("offset",String(i)),d.set("page",String(o)),d.set(n,r),xe(s)&&d.set("keywords",s),a&&d.set("orderBy",a);const u=`${this._poisApi}?${d.toString()}`;return this._changedRes(u)}searchByFloors(t){let n=null,r=null;const i="floorIds"in t?at(t.floorIds):null,o="sharedFloorIds"in t?at(t.sharedFloorIds):null;if(i?(n="floorId",r=i):o&&(n="sharedFloorId",r=o),!n||!r)throw new Error("Either 'floorIds' or 'sharedFloorIds' must be a non-empty array.");const{offset:s=Ge,page:a=ze,keywords:d,orderBy:u}=t,p=new URLSearchParams;p.set("offset",String(s)),p.set("page",String(a)),p.set(n,r),xe(d)&&p.set("keywords",d),u&&p.set("orderBy",u);const h=`${this._poisApi}?${p.toString()}`;return this._changedRes(h)}searchByOrientation(t){const{center:n,angle:r,distance:i,distanceSearchType:o=Cr.POINT}=t;if(!Rt(n))throw new Error("Invalid center parameter. Expected an array of two numbers.");if(!Yt(i)||i>100)throw new Error("Invalid distance parameter. Expected a positive number and no more than 100.");if(!Yt(r))throw new Error("Invalid angle parameter. Expected a positive number.");const s=new URLSearchParams;if("ordinal"in t){if(!xe(t.ordinal))throw new Error("'ordinal' must be a non-empty string.");s.set("ordinal",t.ordinal)}else if("floorId"in t){if(!xe(t.floorId))throw new Error("'floorId' must be a non-empty string.");s.set("floorId",t.floorId)}else if("buildingId"in t){if(!xe(t.buildingId))throw new Error("'buildingId' must be a non-empty string.");s.set("buildingId",t.buildingId)}else throw new Error("Either 'ordinal', 'floorId', or 'buildingId' must be provided.");s.set("center",n.join()),s.set("angle",String(Math.round(r))),s.set("distance",String(i)),s.set("distanceSearchType",o);const a=`${this._poisApi}/orientation?${s.toString()}`;return this._request.get(a)}searchByCategory(t){const{center:n,distance:r,page:i=ze,offset:o=Ge}=t;if(!Rt(n))throw new Error("Invalid center parameter. Expected an array of two numbers.");if(!Yt(r)||r>1e4)throw new Error("Invalid distance parameter. Expected a positive number and no more than 10000");const s=new URLSearchParams;if("category"in t&&xe(t.category))s.set("category",String(t.category));else if("excludedCategories"in t&&at(t.excludedCategories))s.set("excludeCategories",at(t.excludedCategories));else throw new Error("Either 'category' or 'excludedCategories' must be provided.");s.set("center",n.join(",")),s.set("distance",String(r)),s.set("page",String(i)),s.set("offset",String(o));const a=`${this._poisApi}?${s.toString()}`;return this._changedRes(a)}searchCategories(t){const n=new URLSearchParams;if("floorId"in t&&xe(t.floorId)?n.set("floorId",t.floorId):"buildingId"in t&&xe(t.buildingId)?n.set("buildingId",t.buildingId):"sharedFloorId"in t&&xe(t.sharedFloorId)?n.set("sharedFloorId",t.sharedFloorId):"venueId"in t&&xe(t.venueId)&&n.set("venueId",t.venueId),"bounds"in t&&Sn(t.bounds)&&(n.set("bbox",t.bounds.flat().join()),xe(t.keywords)&&n.set("keywords",t.keywords)),n.toString().length===0)throw new Error("At least one of 'floorId', 'buildingId', 'sharedFloorId', 'venueId', or 'bounds' must be provided.");const r=`${this._categoriesGroupApi}?${n.toString()}`;return this._request.get(r)}search(t){const n=new URLSearchParams;Object.entries(t).forEach(([i,o])=>{switch(i){case"bounds":Sn(o)&&n.set("bbox",o.flat().join());break;case"center":Rt(o)&&n.set("center",o.join());break;case"excludedCategories":const s=at(o);s&&n.set("excludeCategories",s);break;case"floorIds":const a=at(o);a&&n.set("floorId",a);break;case"sharedFloorIds":const d=at(o);d&&n.set("sharedFloorId",d);break;default:n.set(i,String(o))}});const r=`${this._poisApi}?${n.toString()}`;return this._request.get(r)}async _changedRes(t){return this._request.get(t).then(n=>{if(n.data?.result?.pois){const r=n.data.result.pois.map(i=>Hi(i,(o,s)=>rg.includes(s)));return{...n,data:{...n.data,result:{...n.data.result,pois:r}}}}return n})}}class ig{_api="/api/v4/route/query";_request=st.getInstance();constructor(){}search(t){const{points:n,vehicle:r=Ar.FOOT,locale:i="en"}=t;if(!(n&&n.length>1&&n.length<6))throw new Error("Parameter error. It must be 1 < {points.length} < 6");if(og(n))throw new Error("Parameter error. Points must have lat and lon.");const o={points:n,vehicle:r,locale:i};return this._request.post(this._api,JSON.stringify(o))}}function og(e){return e.some(t=>!t||typeof t.lat!="number"||typeof t.lon!="number")}const _c=new gc,bc=new yc,sg=new mc;async function fr(e){try{return(await _c.searchByIds(e)).data.result.buildings[0]}catch(t){throw t}}async function ag(e){try{const n=(await _c.searchByFloorId(e)).data.result.buildings[0].buildingId;return await fr(n)}catch(t){throw t}}async function hr(e){try{return(await bc.searchByIds(e)).data.result.venues[0]}catch(t){throw t}}async function wc(e){try{return(await bc.searchBySharedFloorId(e)).data.result.venues[0]}catch(t){throw t}}async function cg(e){try{return(await sg.searchByIds([e])).data.result.pois[0]}catch(t){throw t}}class vc extends Error{status;constructor(t,n){super(t);const{status:r,name:i}=n;r!==void 0&&(this.status=r),i!==void 0&&(this.name=i)}}function lg(e,t=30){let n,r=null;return{promise:new Promise((s,a)=>{r=a;const d=performance.now(),u=()=>{e()?(clearInterval(n),s(!0)):(performance.now()-d)/1e3>t&&(a(new vc("Timeouts or Feature is not found in the map at current zoom level.",{status:404,name:"NetworkError"})),clearInterval(n))};u(),n=setInterval(u,100)}),abort:()=>{n&&(clearInterval(n),n=null),r&&(r(new vc("Query was aborted by the user.",{status:400,name:"AbortError"})),r=null)}}}class Mt{static instance;_buildingUnitsMap;_ordinalsMap;_visitedBuildingUnits;constructor(){this._buildingUnitsMap=new Map,this._ordinalsMap=new Map,this._visitedBuildingUnits=[]}static getInstance(){return Mt.instance||(Mt.instance=new Mt),Mt.instance}getBuildingUnitByVenue(t){return this._buildingUnitsMap.get(t)}setBuildingUnitByVenue(t,n){this._buildingUnitsMap.set(t,n)}getOrdinalByBuildingUnit(t){return this._ordinalsMap.get(t)}setOrdinalByBuildingUnit(t,n){this._ordinalsMap.set(t,n)}getVisitedBuildingUnits(){return this._visitedBuildingUnits}addVisitedBuildingUnit(t){this._visitedBuildingUnits.push(t),this._visitedBuildingUnits.length>100&&(this._visitedBuildingUnits=this._visitedBuildingUnits.slice(this._visitedBuildingUnits.length-100))}}class Ht{static instance;_hiddenBuildings;constructor(){this._hiddenBuildings=new Set}static getInstance(){return Ht.instance||(Ht.instance=new Ht),Ht.instance}getHiddenBuildings(){return this._hiddenBuildings}}class ug{_maplibre;_isAnimated=!0;_bounds=null;_boundsPadding;_center=null;_fitBoundsTimer=null;constructor(t,n){this._maplibre=t,this._boundsPadding=n}setAnimated(t){this._isAnimated=t}setBounds(t){this._bounds=t}getBounds(){return this._bounds}setCenter(t){this._center=t}async fitBounds(){if(!this._bounds)return;this._fitBoundsTimer&&(clearTimeout(this._fitBoundsTimer),this._fitBoundsTimer=null);const t=this._isAnimated?{animate:!0,duration:500}:{animate:!1},n=this._isAnimated?500:0;return new Promise(r=>{const i=()=>{this._maplibre.off("idle",i),r(!0)};this._maplibre.on("idle",i),this._maplibre.fitBounds(this._bounds,{...t,padding:this._boundsPadding,bearing:this._maplibre.getBearing()}),this._fitBoundsTimer=setTimeout(()=>{this._maplibre.off("idle",i),this._fitBoundsTimer=null,r(!0)},n+200)})}panToCenter(){this._center&&this._maplibre.panTo(this._center,{animate:this._isAnimated})}}function dg(e,t,n){for(var r=-1,i=e.length;++r<i;){var o=e[r],s=t(o);if(s!=null&&(a===void 0?s===s&&!Cn(s):n(s,a)))var a=s,d=o}return d}function fg(e,t){return e<t}function hg(e,t){return e&&e.length?dg(e,dr(t),fg):void 0}var Ui=function(){return ct.Date.now()},pg=/\s/;function yg(e){for(var t=e.length;t--&&pg.test(e.charAt(t)););return t}var gg=/^\s+/;function mg(e){return e&&e.slice(0,yg(e)+1).replace(gg,"")}var Ec=NaN,_g=/^[-+]0x[0-9a-f]+$/i,bg=/^0b[01]+$/i,wg=/^0o[0-7]+$/i,vg=parseInt;function pr(e){if(typeof e=="number")return e;if(Cn(e))return Ec;if(ft(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=ft(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=mg(e);var n=bg.test(e);return n||wg.test(e)?vg(e.slice(2),n?2:8):_g.test(e)?Ec:+e}var Eg="Expected a function",Sg=Math.max,Bg=Math.min;function Ni(e,t,n){var r,i,o,s,a,d,u=0,p=!1,h=!1,I=!0;if(typeof e!="function")throw new TypeError(Eg);t=pr(t)||0,ft(n)&&(p=!!n.leading,h="maxWait"in n,o=h?Sg(pr(n.maxWait)||0,t):o,I="trailing"in n?!!n.trailing:I);function b(F){var q=r,W=i;return r=i=void 0,u=F,s=e.apply(W,q),s}function g(F){return u=F,a=setTimeout(T,t),p?b(F):s}function w(F){var q=F-d,W=F-u,K=t-q;return h?Bg(K,o-W):K}function B(F){var q=F-d,W=F-u;return d===void 0||q>=t||q<0||h&&W>=o}function T(){var F=Ui();if(B(F))return H(F);a=setTimeout(T,w(F))}function H(F){return a=void 0,I&&r?b(F):(r=i=void 0,s)}function N(){a!==void 0&&clearTimeout(a),u=0,r=d=i=a=void 0}function X(){return a===void 0?s:H(Ui())}function P(){var F=Ui(),q=B(F);if(r=arguments,i=this,d=F,q){if(a===void 0)return g(d);if(h)return clearTimeout(a),a=setTimeout(T,t),b(d)}return a===void 0&&(a=setTimeout(T,t)),s}return P.cancel=N,P.flush=X,P}function Ig(e,t,n,r){for(var i=e.length,o=n+-1;++o<i;)if(t(e[o],o,e))return o;return-1}function xg(e){return e!==e}function Lg(e,t,n){for(var r=n-1,i=e.length;++r<i;)if(e[r]===t)return r;return-1}function Ag(e,t,n){return t===t?Lg(e,t,n):Ig(e,xg,n)}function Cg(e,t){var n=e==null?0:e.length;return!!n&&Ag(e,t,0)>-1}function Tg(){}var Og=1/0,Rg=Qt&&1/Bi(new Qt([,-0]))[1]==Og?function(e){return new Qt(e)}:Tg,Pg=200;function Fg(e,t,n){var r=-1,i=Cg,o=e.length,s=!0,a=[],d=a;if(o>=Pg){var u=t?null:Rg(e);if(u)return Bi(u);s=!1,i=Aa,d=new Ln}else d=t?[]:a;e:for(;++r<o;){var p=e[r],h=t?t(p):p;if(p=p!==0?p:0,s&&h===h){for(var I=d.length;I--;)if(d[I]===h)continue e;t&&d.push(h),a.push(p)}else i(d,h,n)||(d!==a&&d.push(h),a.push(p))}return a}function Sc(e,t){return e&&e.length?Fg(e,dr(t)):[]}var kg=0;function Ut(e){var t=++kg;return hc(e)+t}const On="Indoor_selectedFloorChanged",yr="Indoor_selectedBuildingChanged",Di="Indoor_mapxusMapLoaded",Bc="Indoor_maplibreMapLoaded",gr="mapxus-venue-fill",Nt="mapxus-building-line",Ic="mapxus-level-fill",$i="mapxus-shared-level-fill",Vi="highlight-mapxus_level",ji="highlight-mapxus_shared_level";class xc extends Sr.TinyEmitter{_map;_features=[];_allVenuesMap=new Map;_allBuildingsMap=new Map;_allSharedLevelsMap=new Map;_curBuildingId=null;_curBuildingFeature=null;_curSharedLevelId=null;_floor={code:null,id:null,ordinal:null};_sharedFloor={id:null,ordinal:null,name:null};_outdoorMapShown;_originIndoorLayers=[];_outdoorLayers=[];_curVenueId=null;_curVenueFeature=null;_selectedHighlightStyle;_upperLayers=[];_commonPoiLayers=[];_sectionFillLineLayers=[];_sectionSymbolLayers=[];_middleLayers=[];_lowerLayers=[];_excludedPoisInMiddle=[];_dispatch=Wt(On);_startWithIndoorView;_indoorMapLoaded=!1;_isSelectSharedFloor=!1;_isMaskMode;_upperLevels=new Set;_middleLevels=new Set;_lowerLevels=new Set;_featureIncomplete=!1;_fitBounds;_dragPan;_history=Mt.getInstance();_hiddenBuildings=Ht.getInstance().getHiddenBuildings();_maskBuildings=new Set;_maskSharedFloors=new Set;_enableIndoorClickSelection;_enableOutdoorClickSelection;_zIndexHistory=new Map;_isDestroyed=!1;_abortQueryFeature;_debounceRendering;dragPanHandler;constructor(t){super();const{map:n,startWithIndoorView:r,outdoorMapShown:i,selectedHighlightStyle:o,fitBounds:s,boundsPadding:a,maskNonSelectedAreas:d,enableIndoorClickSelection:u,enableOutdoorClickSelection:p}=t;this.dragPanHandler=new ug(n,a),this._map=n,this._enableIndoorClickSelection=u,this._enableOutdoorClickSelection=p,this._startWithIndoorView=r,this._outdoorMapShown=i,this._isMaskMode=d,this._fitBounds=s,this._selectedHighlightStyle=o?Object.assign({},Un,o):Un,this._bindMaplibreEventListeners()}destroy(){this._isDestroyed||(this._isDestroyed=!0,this._dispatch.on(`.${On}`,null),this.off(yr),this.off(Bc),this.off(Di),this._debounceRendering?.cancel(),this._abortQueryFeature&&(this._abortQueryFeature(),this._abortQueryFeature=null))}setAllowOutdoorSwitch(t){return this._enableOutdoorClickSelection=t,this}setAllowBuildingSwitch(t){return this._enableIndoorClickSelection=t,this}setAllowIndoorClickSelect(t){this._enableIndoorClickSelection=t}setAllowOutdoorClickSelect(t){this._enableOutdoorClickSelection=t}get floor(){return this._isSelectSharedFloor?this._sharedFloor:this._curBuildingId?this._floor:null}get building(){return this._curBuildingFeature}get venue(){return this._curVenueFeature}get features(){return this._features}getFeaturesById(t,n){const{layerIds:r,filter:i}=n||{},o=this._queryRenderedFeatures(r);if(!o.length)return[];const s=i?a=>a.properties.id===t&&i(a):a=>a.properties.id===t;return o.filter(s)}async switchFloorByOrdinal(t){this._updateFloorState(t),this._dispatch.call(On,null,{venue:this.venue,building:this.building,floor:this.floor}),this.venue&&t&&(this._dragPan===!0&&(this._fitBounds?await this.dragPanHandler.fitBounds():await this.panToBuildingCenter()),this._dragPan==="restrict"&&await this._checkAndPanToBuilding(),this._resetSelectedDisplayedLevel()),this.updateRendering()}setOutdoorMapShown(t){this._outdoorMapShown=t,this._setOutdoorVisibility(t)}setSelectedHighlightStyle(t){this._selectedHighlightStyle=Object.assign({},this._selectedHighlightStyle,t??{"line-opacity":0});for(const n of[Vi,ji])if(this._map.getLayer(n))if(t){const{lineColor:r,lineOpacity:i,lineWidth:o,lineOffset:s}=this._selectedHighlightStyle,a=Lc(o,s);this._map.setPaintProperty(n,"line-color",r),this._map.setPaintProperty(n,"line-opacity",i),this._map.setPaintProperty(n,"line-width",o),this._map.setPaintProperty(n,"line-offset",a)}else this._map.setPaintProperty(n,"line-opacity",0)}onMapChange(t){const n=Ut(`${On}.`);return this._dispatch.on(n,t),{unsubscribe:()=>this._dispatch.on(n,null)}}async selectBuilding(t,n){if(this._isCurrentFeature(t))return;this._isSelectSharedFloor=!1,this._curSharedLevelId=null;let r=null;if(!t||!t.properties)this.dragPanHandler.setCenter(null),this._clear();else{const{floorId:i,featureIncomplete:o}=n||{};this._featureIncomplete=o??this._featureIncomplete;const{id:s,"ref:venue":a,label_center:d}=t.properties,u=Ae(d).map(p=>parseFloat(p));this._curBuildingFeature=t,this._curBuildingId=s,this._history.addVisitedBuildingUnit({id:s,type:"building"}),this.dragPanHandler.setCenter(u),this._curVenueId!==a&&(this._curVenueId=a,this._curVenueFeature=await this._queryVenueFeature(a)),r=this._getBuildingDisplayedOrdinal(t,i)}await this.switchFloorByOrdinal(r),this.emit(yr,t?{building:t,ordinal:r,dragPan:this._dragPan}:null),this._dispatchIndoorMapLoaded()}async selectSharedFloor(t,n,r){if(t.id===this._curSharedLevelId)return;const{id:i,ordinal:o}=t;this._isSelectSharedFloor=!0,this._curBuildingId=null,this._curBuildingFeature=null,this._sharedFloor=t,this._curSharedLevelId=i,this._featureIncomplete=r?.featureIncomplete??this._featureIncomplete;const{label_center:s,id:a}=n.properties,d=Ae(s).map(u=>parseFloat(u));this._curVenueId=a,this._curVenueFeature=n,this.dragPanHandler.setCenter(d),this._history.addVisitedBuildingUnit({id:i,type:"sharedFloor"}),this._history.setOrdinalByBuildingUnit(i,o),this._history.setBuildingUnitByVenue(this._curVenueId,{id:i,type:"sharedFloor"}),this._dragPan===!0&&(this._fitBounds?await this.dragPanHandler.fitBounds():await this.panToVenueCenter()),this._dispatch.call(On,null,{venue:this.venue,building:this.building,floor:this.floor}),this.emit(yr,{...t,dragPan:this._dragPan}),this._dispatchIndoorMapLoaded(),this._resetSelectedDisplayedLevel(),this.updateRendering()}updateCustomLayers(){const t=this._map.getStyle();this._originIndoorLayers=Br(t),this._outdoorLayers=el(t),this._copyOverlapLayers(),this._copySharedFloorBackgroundLayers(),this._addSelectedHighlightLayers(),this._addReserveFloorLayers(),this._isMaskMode&&this._addBuildingMaskLayer(),this._outdoorMapShown||this._setOutdoorVisibility(!1)}updateRendering(){this._updateFeatures(),this._updateSelectedFeatures(),this._layerFloors(),this._calExcludedPoisInMiddle(),this._filterLayers(),this._filterSelectedHighlight(),this._updateUnselectedMask()}async panToBuildingCenter(){if(this.dragPanHandler.panToCenter(),this._featureIncomplete){const t=()=>this.getFeaturesById(this._curBuildingId,{layerIds:[Nt]})[0];await this._waitForFeatureLoaded(t)}}async panToVenueCenter(){if(this.dragPanHandler.panToCenter(),this._featureIncomplete){const t=()=>this.getFeaturesById(this._curVenueId,{layerIds:[gr]})[0];await this._waitForFeatureLoaded(t)}}async _waitForFeatureLoaded(t){const n=()=>this._isDestroyed?(this._abortQueryFeature?.(),!0):!!t(),{promise:r,abort:i}=lg(n);this._abortQueryFeature=i;try{await Promise.race([r,new Promise((o,s)=>{this._abortQueryFeature=()=>{s(new Error("Aborted")),this._abortQueryFeature=null}})])}catch(o){console.warn(o);return}}setDragPan(t){this._dragPan=t}setFitBounds(t){this._fitBounds=t}async queryIndoorFeaturesByClickPoint(t){const n=this._queryVisibleFeature(t);if(!n)return null;const r=async o=>{let s=this.getFeaturesById(o,{layerIds:[gr]})[0];if(!s){const a=await hr(o);s=Hn(a),this._featureIncomplete=!0}return s??null},i=async o=>{let s=this.getFeaturesById(o,{layerIds:[Nt]})[0];if(!s){const a=await fr(o);s=xr(a),this._featureIncomplete=!0}return s??null};if(mr(n.sourceLayer,n.layer.type)){const{id:o,"ref:building":s,name:a,ordinal:d}=n.properties,u=await i(s);if(u){const p=u.properties["ref:venue"];return{venue:await r(p),building:u,floor:{id:o,code:a,ordinal:d}}}}else if(Cc(n.sourceLayer,n.layer.type)){const{id:o,ordinal:s,name:a,"ref:venue":d}=n.properties;return{sharedFloor:{id:o,ordinal:s,name:typeof a=="string"?{default:a}:a},venue:await r(d)}}else{const o=n?.properties?.["ref:venue"];return n?{building:n,venue:await r(o)}:null}}async selectByClickMap(t){!this._enableIndoorClickSelection&&!this._enableOutdoorClickSelection||(this.setDragPan(!1),this.dragPanHandler.setBounds(null),this._featureIncomplete=!1,t?this._enableIndoorClickSelection&&("building"in t?await this.selectBuilding(t.building,{floorId:t?.floor?.id}):"sharedFloor"in t&&await this.selectSharedFloor(t.sharedFloor,t.venue)):this._enableOutdoorClickSelection&&await this.selectBuilding(null))}_bindMaplibreEventListeners(){this._map.once("styledata",()=>this.updateCustomLayers()),this._map.once("idle",()=>{this.emit(Bc),(!this._startWithIndoorView||this._map.getZoom()<14)&&this._dispatchIndoorMapLoaded()}),this._map.on("sourcedata",this._debounceRendering=Ni(()=>this.updateRendering(),300))}_clear(){this._curBuildingFeature=null,this._curBuildingId=null,this._floor={code:null,id:null,ordinal:null},this._curVenueId=null,this._curVenueFeature=null,this._curSharedLevelId=null}_getIndoorFeatures(){return this._queryRenderedFeatures().filter(t=>Ir(t.source))}_getBuildingFloorByOrdinal(t,n){let r=null,i=null;if(t?.properties){const{ordinals:o,level_names:s,level_ids:a}=t.properties,d=Ae(o).findIndex(u=>u===n);r=Ae(s)[d]??null,i=Ae(a)[d]??null}return{code:r,id:i,ordinal:n}}_isCurrentFeature(t){const n=t?.properties?.id??null,r=this._isSelectSharedFloor?this._curSharedLevelId:this._curBuildingId;return n===r}_setOutdoorVisibility(t){for(const{id:n}of this._outdoorLayers)this._map.getLayer(n)&&this._map.setLayoutProperty(n,"visibility",t?"visible":"none")}_addReserveFloorLayers(){for(const t of[nn,je]){if(this._map.getLayer(t))continue;const n=t.split("_")[1],r=this._map.getLayer(n);if(!r)continue;const{source:i,sourceLayer:o}=r,s=t===nn?this._middleLayers[0]:this._lowerLayers[0];let a={"fill-opacity":0};if(this._isMaskMode&&t===je){const d=this._originIndoorLayers.find(({id:u})=>u===Nt);d&&(a=Object.assign({},d.paint??{},a))}this._map.addLayer({id:t,source:i,"source-layer":o,type:"fill",paint:a},s.id)}}_addBuildingMaskLayer(){if(this._map.getLayer(rn))return;const t=this._originIndoorLayers.find(({id:n})=>n===Nt);if(t){const n=Object.assign({},t,{id:rn,layout:Object.assign({},t.layout??{},{visibility:"visible"}),paint:Object.assign({},t.paint??{},{"fill-opacity":0})});this._map.addLayer(n,Nt)}}_updateUnselectedMask(){if(!this._isMaskMode)return;const t=[...this._maskBuildings],n=[...this._maskSharedFloors];this._map.getLayer(rn)&&this._map.setPaintProperty(rn,"fill-opacity",["case",["in",["get","id"],["literal",t]],1,0]),this._map.getLayer(je)&&this._map.setPaintProperty(je,"fill-opacity",["case",["in",["get","id"],["literal",n]],1,0])}_addSelectedHighlightLayers(){const t=[{layerId:Vi,sourceLayer:"mapxus_level"},{layerId:ji,sourceLayer:"mapxus_shared_level"}];let n=this._originIndoorLayers.find(({type:r})=>Ki(r));if(!n){const r=this._originIndoorLayers.findIndex(({id:i})=>i===this._upperLayers[this._upperLayers.length-1].id);n=this._originIndoorLayers[r+1]}for(const{layerId:r,sourceLayer:i}of t){if(this._map.getLayer(r))continue;const{lineWidth:o,lineOpacity:s,lineColor:a,lineOffset:d}=this._selectedHighlightStyle,u=Lc(o,d);this._map.addLayer({id:r,source:"indoor-planet","source-layer":i,type:"line",filter:["==","id",""],paint:{"line-offset":u,"line-width":o,"line-color":a,"line-opacity":s}},n?.id)}}_filterSelectedHighlight(){for(const t of[Vi,ji])this._map.getLayer(t)&&this._map.setFilter(t,["==","id",this._isSelectSharedFloor?this._curSharedLevelId:this._floor.id??""])}_getBuildingDefaultOrdinal(t){let n=null;if(t?.properties){const{level_ids:r,ordinals:i,default_displayed_floor:o}=t.properties,s=Ae(i);if(s.length){if(o){const a=Ae(r).findIndex(d=>d===o);n=s[a]??null}n||(n=hg(s,a=>Math.abs(Number(a)-.1)))}}return n}_copyOverlapLayers(){const t=this._originIndoorLayers.findIndex(({type:a,"source-layer":d})=>Ac(d,a)),n=this._originIndoorLayers.findIndex(({type:a,"source-layer":d})=>qi(d,a)),r=this._originIndoorLayers.slice(t,n);this._upperLayers=r.filter(({type:a})=>Hg(a));const i=this._originIndoorLayers.slice(n),o=i.findIndex(({type:a,"source-layer":d})=>!qi(d,a));if(o>-1){this._commonPoiLayers=i.slice(0,o);const a=i.slice(o);this._sectionFillLineLayers=a.filter(({type:d})=>d!=="symbol"),this._sectionSymbolLayers=a.filter(({type:d})=>d==="symbol")}else this._commonPoiLayers=[...i],this._sectionSymbolLayers=r.filter(({type:a,"source-layer":d})=>d==="mapxus_section"&&a==="symbol");const s=this._upperLayers[0];this._middleLayers=this._upperLayers.filter(({type:a})=>!Ki(a)).map(a=>{const d=`${a.id}-overlap-copy`;let u=this._map.getLayer(d);return u||(u=Object.assign({},a,{id:d}),this._map.addLayer(u,s.id)),u})}_copySharedFloorBackgroundLayers(){if(!!!this._upperLayers.find(i=>i.id===je.split("_")[1]))return;const n=this._upperLayers.filter(({"source-layer":i,type:o})=>!mr(i,o)&&!Ki(o)),r=this._middleLayers[0]||this._upperLayers[0];this._lowerLayers=[...n,...this._commonPoiLayers].map(i=>{const o=`${i.id}-shared-bg`;let s=this._map.getLayer(o);return s||(s=Object.assign({},i,{id:o}),this._map.addLayer(s,r.id)),s})}_updateFeatures(){this._features=this._getIndoorFeatures();const t=Sc(this._features,o=>o.layer.id+":"+o.properties.id),n=[],r=[],i=[];for(const o of t){const s=o.layer.id;s===gr?n.push(o):s===Nt?r.push(o):s===je&&i.push(o)}this._allVenuesMap=new Map(n.map(o=>[o.properties.id,o])),this._allBuildingsMap=new Map(r.map(o=>[o.properties.id,o])),this._allSharedLevelsMap=new Map(i.map(o=>[o.properties.id,o]))}_calExcludedPoisInMiddle(){const t=this._map.querySourceFeatures("indoor-planet",{sourceLayer:"mapxus_place"}),n=i=>i?Ae(i).some(s=>this._upperLevels.has(s)):!1,r=t.filter(i=>{const o=i.properties["ref:level"]||i.properties["ref:shared_level"];return this._middleLevels.has(o)?n(i.properties.overlap):!1});this._excludedPoisInMiddle=r.map(i=>i.properties["osm:ref"])}_updateSelectedFeatures(){if(this._featureIncomplete){if(this._isSelectSharedFloor){const t=this._features.find(n=>n.properties.id===this._curVenueId);if(!t)return;this._curVenueFeature=t}else{const t=this._allBuildingsMap.get(this._curBuildingId);if(!t)return;this._curBuildingFeature=t}this._featureIncomplete=!1}}_layerFloors(){const{displayedLevels:t,selectedLevelIds:n,alwaysDisplayedSharedLevelIds:r,hiddenBuildingIds:i,maskBuildingIds:o,maskSharedFloorIds:s}=this._classifyFloors();this._upperLevels.clear(),this._middleLevels.clear(),this._lowerLevels.clear(),this._hiddenBuildings.clear(),this._layerSelectedLevels(t,n,r),this._layerUnselectedLevels(t,n,r),i.forEach(a=>{this._hiddenBuildings.add(a)}),this._isMaskMode&&(this._maskBuildings.clear(),this._maskSharedFloors.clear(),o.forEach(a=>{this._maskBuildings.add(a)}),s.forEach(a=>{this._maskSharedFloors.add(a)}))}_layerSelectedLevels(t,n,r){for(const i of n){this._upperLevels.add(i),this._zIndexHistory.set(i,!0);const o=t.find(({level:s,overlap:a})=>s===i&&!!a);if(o){for(const s of o.overlap)if(this._zIndexHistory.get(s)){if(this._zIndexHistory.delete(s),!t.find(({level:d})=>d===s))continue;r.includes(s)?(this._lowerLevels.add(s),this._zIndexHistory.delete(s)):(this._middleLevels.add(s),this._zIndexHistory.set(s,!1))}}}}_layerUnselectedLevels(t,n,r){for(const i of t){if(n.includes(i.level))continue;const{level:o,overlap:s,venueId:a}=i,d=this._zIndexHistory.get(o),u=!s||!s.some(h=>this._upperLevels.has(h)),p=r.includes(o);if(a===this._curVenueId&&p){this._lowerLevels.add(o),this._zIndexHistory.delete(o);continue}d?this._upperLevels.add(o):d===!1?this._middleLevels.add(o):p?this._lowerLevels.add(o):u?(this._upperLevels.add(o),this._zIndexHistory.set(o,!0)):(this._middleLevels.add(o),this._zIndexHistory.set(o,!1))}}_classifyFloors(){const t=[],n=[],r=[],i=[],o=[],s=[],a=[...this._allVenuesMap.values()],d=this._curVenueId?[this._allVenuesMap.get(this._curVenueId),...a.filter(u=>u.properties.id!==this._curVenueId)]:a;for(const u of d){if(!u||!u.properties)continue;const{id:p,overlap:h,building_ids:I,shared_level_ids:b,default_displayed_ordinal:g,default_displayed_building:w}=u.properties,B=p===this._curVenueId,T=Ug(h),H=Ae(I),N=this._history.getBuildingUnitByVenue(p);let X=N?this._history.getOrdinalByBuildingUnit(N.id):g;if(X)N||(this._history.setOrdinalByBuildingUnit(w,X),this._history.setBuildingUnitByVenue(p,{id:w,type:"building"}));else{const P=this._calcVenueInitDisplayedData(H);X=P.ordinal,X&&(this._history.setOrdinalByBuildingUnit(P.buildingId,X),this._history.setBuildingUnitByVenue(p,{id:P.buildingId,type:"building"}))}X&&(H.forEach(P=>{const F=this._allBuildingsMap.get(P),q=this._getBuildingDisplayedLevel(F,X);q?this._isMaskMode?B?(n.push(q),t.push({level:q,overlap:T.get(q)??null,venueId:p})):o.push(P):(t.push({level:q,overlap:T.get(q)??null,venueId:p}),B&&n.push(q)):i.push(P)}),Ae(b).forEach(P=>{const F=this._allSharedLevelsMap.get(P),{ordinal:q,persistence:W=!1}=F?.properties||{},K=!!W&&0<=q&&q<=X,J=q===X,te=K||J,ne={level:P,overlap:T.get(P)??null,venueId:p};te?this._isMaskMode?B?(t.push(ne),K&&r.push(P),J&&n.push(P)):s.push(P):(t.push(ne),B&&J&&n.push(P),K&&r.push(P)):i.push(P)}))}return{displayedLevels:t,hiddenBuildingIds:i,maskBuildingIds:o,maskSharedFloorIds:s,alwaysDisplayedSharedLevelIds:r,selectedLevelIds:n}}_calcVenueInitDisplayedData(t){const n=t.find(o=>this._allBuildingsMap.has(o))??t[0]??null,r=n?this._allBuildingsMap.get(n):null;return{ordinal:r?this._getBuildingDefaultOrdinal(r):null,buildingId:n}}_getBuildingDisplayedLevel(t,n){if(!t||!t.properties)return null;const{level_ids:r,ordinals:i}=t.properties,o=Ae(i).findIndex(s=>s===n);return Ae(r)[o]??null}_filterLayers(){this._filterIndoorLayers([...this._upperLevels,...this._middleLevels],this._commonPoiLayers),this._filterIndoorLayers([...this._upperLevels],this._upperLayers),this._filterIndoorLayers([...this._middleLevels],this._middleLayers),this._filterIndoorLayers([...this._lowerLevels],this._lowerLayers),this._sectionFillLineLayers.length?(this._filterIndoorLayers([...this._upperLevels],this._sectionFillLineLayers),this._filterIndoorLayers([...this._upperLevels],this._sectionSymbolLayers)):this._filterIndoorLayers([...this._upperLevels,...this._middleLevels,...this._lowerLevels],this._sectionSymbolLayers)}_filterIndoorLayers(t,n){let r;for(const i of n){const{id:o,filter:s,type:a,"source-layer":d}=i,u=s?[s]:[],p=o.includes("-shared-bg"),h=[...this._maskBuildings],I=[...this._maskSharedFloors];Ac(d,a)?r=["all",mr(d,a)?["!in","ref:building",...h]:["!in","id",...I],["in","id",...t],...u]:p?r=["all",["!in","ref:shared_level",...I],["in","ref:shared_level",...t],...u]:(r=["all",["any",["all",["!in","ref:building",...h],["in","ref:level",...t]],["all",["!in","ref:shared_level",...I],["in","ref:shared_level",...t]]],...u],qi(d,a)&&r.splice(1,0,["any",["!has","overlap"],["any",["in","ref:level",...this._upperLevels],["in","ref:shared_level",...this._upperLevels],["!in","osm:ref",...this._excludedPoisInMiddle]]])),this._map.setFilter(o,r)}}async _queryVenueFeature(t){let n=this.getFeaturesById(t,{layerIds:[gr]})[0]??null;if(!n)try{const r=await hr(t);n=Hn(r)}catch(r){console.error(r)}return n}_getBuildingDisplayedOrdinal(t,n){const{"ref:venue":r,level_ids:i,ordinals:o}=t.properties,s=Ae(i),a=Ae(o);if(n){const p=s.findIndex(h=>h===n);return a[p]??null}const d=this._history.getBuildingUnitByVenue(r);let u=null;if(d){const p=this._history.getOrdinalByBuildingUnit(d.id);p&&a.includes(p)&&(u=p)}return u||(u=this._getBuildingDefaultOrdinal(t)),u}_updateFloorState(t){if(!t){this._floor={code:null,id:null,ordinal:null};return}const{code:n,id:r}=this._getBuildingFloorByOrdinal(this._curBuildingFeature,t);(!n||!r)&&console.error(`Floor with ordinal "${t}" not found in building "${this._curBuildingId}".`),this._floor={code:n,id:r,ordinal:t},this._history.setOrdinalByBuildingUnit(this._curBuildingId,t),this._history.setBuildingUnitByVenue(this._curVenueId,{id:this._curBuildingId,type:"building"})}_resetSelectedDisplayedLevel(){const{building_ids:t,shared_level_ids:n}=this._curVenueFeature.properties,r=Ae(t),i=Ae(n);for(const o of r){const s=this._allBuildingsMap.get(o);if(!s)continue;const a=Ae(s.properties.level_ids);i.push(...a),this._hiddenBuildings.delete(o),this._isMaskMode&&this._maskBuildings.delete(o)}for(const o of i)this._upperLevels.delete(o),this._middleLevels.delete(o),this._lowerLevels.delete(o),this._isMaskMode&&this._maskSharedFloors.delete(o)}async _checkAndPanToBuilding(){this.getFeaturesById(this._curBuildingId,{layerIds:[Nt]})[0]||(this._fitBounds?this.dragPanHandler.fitBounds():this.dragPanHandler.panToCenter())}_queryVisibleFeature(t){const r=[Ic,$i,`${Ic}-overlap-copy`,`${$i}-overlap-copy`,`${$i}-shared-bg`,...this._isMaskMode?[je,rn]:[]].filter(s=>!!this._map.getLayer(s)),i=this._map.queryRenderedFeatures(t,{layers:r});let o=null;for(const s of r){const a=i.find(d=>d.layer.id===s);if(a){o=a;break}}return o&&Mg(o.sourceLayer,o.layer.type)&&(this._maskBuildings.has(o.properties?.id)||(o=null)),o}_queryRenderedFeatures(t){const n=(t||[]).filter(o=>this._map.getLayer(o));if(t&&t.length>0&&n.length===0)return[];const r=n.length?{layers:n}:{},i=this._map.getCanvas().getBoundingClientRect();return this._map.queryRenderedFeatures([[0,0],[i.width,i.height]],r)}_dispatchIndoorMapLoaded(){this._indoorMapLoaded||(this._indoorMapLoaded=!0,this.emit(Di))}}function Lc(e,t){const n=typeof e=="number"&&e===Un.lineWidth,r=typeof t=="number"&&t===Un.lineOffset;if(!r)return t;if(n&&r)return["interpolate",["linear"],["zoom"],18,-1.5,20.2,-3.75,20.4,-3.8,21.5,-7.5,22,-9.55];if(!n&&r)return typeof e=="number"?-(e/2):t}function Mg(e,t){return e==="mapxus_building"&&(t==="fill"||t==="line"||t==="symbol")}function Ac(e,t){return mr(e,t)||Cc(e,t)}function mr(e,t){return e==="mapxus_level"&&(t==="fill"||t==="line")}function Cc(e,t){return e==="mapxus_shared_level"&&(t==="fill"||t==="line")}function qi(e,t){return e==="mapxus_place"&&t==="symbol"}function Ki(e){return e==="fill-extrusion"}function Hg(e){return e==="line"||e==="fill"||e==="fill-extrusion"}function Ug(e){const t=new Map;if(!e)return t;for(const n of Ae(e,"/")){const[r,i]=Ae(n,":");t.set(r,Ae(i))}return t}const _r="Poi_poiClick";class Tc{_map;_currentStyle=null;_styleLayersLength=0;_layerIds=[];_dispatch=Wt(_r);_listeners=[];constructor(t){this._map=t,this._bindPoiClickEvent()}destroy(){this._dispatch.on(`.${_r}`,null),this._currentStyle=null,this._map=null,this._dispatch=null,this._listeners=[],this._layerIds=[]}onPoiClick(t){const n=Ut(`${_r}.`);return this._dispatch.on(n,t),this._listeners.push(n),{unsubscribe:()=>this._dispatch.on(n,null)}}_queryPoiLayers(){const t=this._map.getStyle();if(t.name===this._currentStyle&&t.layers.length===this._styleLayersLength)return;const n=Br(t).filter(r=>r["source-layer"]==="mapxus_place"&&r.type==="symbol");this._layerIds=n.map(({id:r})=>r),this._currentStyle=t.name,this._styleLayersLength=t.layers.length}_bindPoiClickEvent(){this._map.on("click",t=>{if(this._listeners.length===0)return;this._queryPoiLayers();const n=this._map.queryRenderedFeatures(t.point,{layers:this._layerIds});if(n.length===0)return;const r=n[0],i=Ae(r.properties["ref:sections"]),o=!!r.properties["ref:shared_level"],s={coordinate:t.lngLat,poi:r};if(i.length>0){const a=this._map.querySourceFeatures("indoor-planet",{sourceLayer:"mapxus_section"});s.sections=i.map(d=>{const u=a.find(g=>g.properties.id===d),{id:p,section:h="",correlation_id:I}=u?.properties||{},b=Oc(u?.properties);return{id:p,category:h,sectionName:b,...I&&{correlationId:I}}})}if(o){const a=r.properties["ref:shared_level"],{floor:d,venue:u}=this._queryIndoorFeaturesBySharedFloor(a);s.floor=d,s.venue=u}else{const a=r.properties["ref:level"],{floor:d,building:u,venue:p}=this._queryIndoorFeaturesByFloor(a);s.floor=d,s.building=u,s.venue=p}this._dispatch.call(_r,null,s)})}_queryIndoorFeaturesBySharedFloor(t){const n=this._map.queryRenderedFeatures({layers:[je,"mapxus-venue-fill"]}),r=n.find(u=>u.sourceLayer==="mapxus_shared_level"&&u.properties.id===t);if(!r)return{floor:null,venue:null};const i=r.properties["ref:venue"],o=n.find(u=>u.layer.id==="mapxus-venue-fill"&&u.properties.id===i)??null,{id:s,ordinal:a}=r.properties,d=Oc(r.properties);return{floor:{id:s,ordinal:a,name:d},venue:o}}_queryIndoorFeaturesByFloor(t){const n=this._map.queryRenderedFeatures({layers:[nn,"mapxus-building-line","mapxus-venue-fill"]}),r=n.find(p=>p.sourceLayer==="mapxus_level"&&p.properties.id===t);if(!r)return{floor:null,building:null,venue:null};const{id:i,ordinal:o,name:s,"ref:building":a}=r.properties||{},d=n.find(p=>p.layer.id==="mapxus-building-line"&&p.properties.id===a)??null,u=n.find(p=>p.layer.id==="mapxus-venue-fill"&&p.properties.id===d?.properties?.["ref:venue"])??null;return{floor:{id:i,ordinal:o,code:s},building:d,venue:u}}}function Oc(e){return e?Object.keys(e).filter(n=>n.includes("name")).reduce((n,r)=>{const[,i]=Ae(r,":");return i?n[i]=e[r]:n.default=e[r],n},{}):{default:""}}function Rn(e){e.parentNode&&e.parentNode.removeChild(e)}function Fe(e,t,n){const r=document.createElement(e);return t&&(r.className=t),n&&n.appendChild(r),r}class Rc{_map;_maplibre;_buildingId;_features;_$container;_$listContainer;_$buildingList;_listHeight;_language;_visible;_position="top-right";_isMobileMode;_isListShown=!1;constructor(t,n){this._map=t,this._language=t.getLanguage(),this._visible=n??!0,this._detectDeviceMode()}onAdd(t){return this._maplibre=t,this._$container=Fe("div",`maplibregl-ctrl maplibregl-ctrl-building-filter ${this._visible?"":"hide"}`,this._maplibre.getContainer()),this._$container.appendChild(this._buildingFilterIconCreate("div")),this._$container.appendChild(this._buildingNameListCreate("div")),this._bindEvents(),this._$container}onRemove(){Rn(this._$container)}get position(){return this._position}get enabled(){return this._visible}getDefaultPosition(){return"top-right"}setVisibility(t){this._visible=t,t?this._$showLayout():this._$hideLayout()}changePosition(t,n,r){const i=document.querySelector(`.maplibregl-ctrl-${t}`),o=i.querySelector(".maplibregl-ctrl-building-filter");if(t!==n){this._position=n;const s=document.querySelector(`.maplibregl-ctrl-${n}`);o&&(i.removeChild(o),Number.isFinite(r)?s.insertBefore(o,s.children[r]):s.append(o),this._updateBuildingListLayout(n))}else Number.isFinite(r)&&i.children[r]!==o&&(i.removeChild(o),i.insertBefore(o,i.children[r]))}_bindEvents(){this._maplibre.on("moveend",()=>this._refresh()),this._map.onMapChangeListener(t=>{const n=t.building?.properties?.id??"";this._buildingId!==n&&(this._buildingId=n,this._refresh())}),this._map.renderComplete(()=>this._init())}_init(){this._load()}_refresh(){this._load()}_load(){this._buildingNameListClean(),this._buildingNameListUpdate()}_buildingFilterIconCreate(t){const n=Fe(t,"mapxus-building-filter-icon");return this._bindMouseOnEvents(n,!1),this._bindMobileTouchEvents(n),n}_buildingNameListCreate(t){return this._$listContainer=Fe(t,"mapxus-building-name-layout"),this._$listContainer.style.display="none",this._$listContainer.style.top="20px",this._$buildingList=Fe(t,"mapxus-building-name-list",this._$listContainer),this._bindMouseOnEvents(this._$listContainer,!0),this._$listContainer}_buildingNameListUpdate(){this._features=[];const t=this._map.getMaplibre(),n=t?t.queryRenderedFeatures({layers:["mapxus-building-line"]}):[];for(const r of n){const{properties:i}=r,{id:o,name:s}=i,a=i?.[`name:${this._language}`]??s;this._features.find(d=>d.properties.id===o)||(this._features.push(r),this._$buildingList.appendChild(this._buildingNameCreate("p",a,o,o===this._map.building?.properties?.id)))}this._setBuildingListHeight(this._features),this._updateBuildingListLayout(this._position)}_buildingNameListClean(){this._$buildingList.replaceChildren()}_setBuildingListHeight(t){const i=t.map(o=>{const s=o?.properties?.[`name:${this._language}`]??o?.properties?.name;return s?Math.ceil(s.length*8/107):0}).reduce((o,s)=>o+s,0);this._listHeight=i*26+t.length*8,this._$buildingList.style.height=this._$listContainer.style.height=`${this._listHeight>=208?208:this._listHeight}px`}_buildingNameCreate(t,n,r,i){const o=Fe(t,`mapxus-building-name${i?" active":""}`);return o.dataset.id=r,o.innerText=n,this._buildingNameClickEvent(o),o}_toggleList(t){this._isListShown=t,this._$listContainer.style.display=t?"block":"none"}_buildingNameClickEvent(t){t.onclick||(t.onclick=async n=>{const r=n.target;await this._map.selectBuildingById(r.dataset.id)})}_bindMouseOnEvents(t,n){t.onmouseenter=()=>{this._isMobileMode||this._toggleList(!0)},n&&(t.onmouseleave=()=>this._toggleList(!1))}_bindMobileTouchEvents(t){window.addEventListener("resize",()=>this._detectDeviceMode()),t.ontouchend=()=>this._toggleList(!this._isListShown)}_$showLayout(){this._$container.classList.remove("hide")}_$hideLayout(){this._$container.classList.add("hide")}_updateBuildingListLayout(t){t.indexOf("left")>-1?(this._$listContainer.style.right=null,this._$listContainer.style.left="55px"):(this._$listContainer.style.left=null,this._$listContainer.style.right="55px");const n=this._$container.offsetParent?this._$container.offsetParent.clientHeight-(this._$container.offsetTop+this._$container.clientHeight)-25:0;t.includes("bottom")&&this._listHeight-20>n?(this._$listContainer.style.top=null,this._$listContainer.style.bottom="15px"):(this._$listContainer.style.bottom=null,this._$listContainer.style.top="20px")}_detectDeviceMode(){this._isMobileMode=window.matchMedia("(pointer: coarse) and (max-width: 768px)").matches}}var Ng=Math.max,Dg=Math.min;function $g(e,t,n){return e>=Dg(t,n)&&e<Ng(t,n)}var Pc=1/0,Vg=17976931348623157e292;function Fc(e){if(!e)return e===0?e:0;if(e=pr(e),e===Pc||e===-Pc){var t=e<0?-1:1;return t*Vg}return e===e?e:0}function kc(e,t,n){return t=Fc(t),n===void 0?(n=t,t=0):n=Fc(n),e=pr(e),$g(e,t,n)}class Mc{_container;_indoor;_maplibre;_position="top-right";_buildingId;_floorNames;_ordinals;_ordinal;_style;_$innerFloors;_$activeFloor;_centerSelectorIdx;_lastNormalScrollableIdx;_$arrowBtnUp;_$arrowBtnDown;_maxScrollTop;_$selectorExpanded;_$selectorFolded;_componentDidMount=!1;_visible=!1;_isEnabled;_dragPan;_language;_debounceScroll;_clearScrollEventListener;constructor(t,n){const{style:r,enabled:i=!0,language:o}=n;this._indoor=t,this._language=o,this._style=r?Object.assign({},ao,r):ao,this._isEnabled=i,this._addIndoorEventListeners()}onAdd(t){return this._maplibre=t,this._addMapMoveEventListener(),this._container=Fe("div","maplibregl-ctrl mapxus-ctrl-floors hidden"),this._container}onRemove(){this._debounceScroll&&this._debounceScroll.cancel(),this._clearScrollEventListener&&this._clearScrollEventListener(),Rn(this._container)}get position(){return this._position}get enabled(){return this._isEnabled}setEnabled(t){this._isEnabled=t,t&&!this._visible&&this._setVisibility(!0),!t&&this._visible&&this._setVisibility(!1)}getDefaultPosition(){return"top-right"}async switchByOrdinal(t,n){this._ordinal=t,this._dragPan=n??!0,await this._indoor.switchFloorByOrdinal(t),this._updateSelectorStatus(t),this._scrollCenterActiveFloor()}changePosition(t,n,r){const i=document.querySelector(`.maplibregl-ctrl-${t}`),o=i.querySelector(".mapxus-ctrl-floors");if(t!==n){this._position=n;const s=document.querySelector(`.maplibregl-ctrl-${n}`);o&&(i.removeChild(o),Number.isFinite(r)?s.insertBefore(o,s.children[r]):s.append(o),this._show(),this._scrollCenterActiveFloor())}else Number.isFinite(r)&&i.children[r]!==o&&(i.removeChild(o),i.insertBefore(o,i.children[r]),this._show(),this._scrollCenterActiveFloor())}setStyle(t){this._style=Object.assign({},this._style,t),this._componentDidMount&&(this._clearFloors(),this._calcSelectorLayout(),this._render(),this._scrollCenterActiveFloor())}_setVisibility(t){this._componentDidMount?t?(this._show(),this._scrollCenterActiveFloor()):this._hide():(this._visible=t,this._indoor.building&&t&&(this._render(),this._show(),this._scrollCenterActiveFloor()))}_addIndoorEventListeners(){this._indoor.on(yr,t=>{if(this._updatePrepared(),!t)return;const{ordinal:n,dragPan:r}=t;this._dragPan=r,"building"in t?this._renderBuildingFloors(t.building,n):this._renderSharedLevelFloor(t)})}_updatePrepared(){this._clearState(),this._visible&&this._hide(),this._componentDidMount&&this._clearFloors()}_renderBuildingFloors(t,n){const{level_names:r,ordinals:i,id:o}=t.properties;this._buildingId=o,this._floorNames=r.split(",").reverse(),this._ordinals=i.split(",").reverse(),this._ordinal=n,this._calcSelectorLayout(),this._render();const s=this._indoor.getFeaturesById(o,{filter:a=>a.layer.id==="mapxus-building-line"})[0];this._checkIfShowFloorSelector(s)}_renderSharedLevelFloor(t){const{name:n,ordinal:r,id:i}=t;this._floorNames=[n[this._language]||n.default],this._ordinals=[r],this._ordinal=r,this._calcSelectorLayout(),this._render();const o=this._indoor.getFeaturesById(i,{layerIds:[je]})[0];this._checkIfShowFloorSelector(o)}_checkIfShowFloorSelector(t){this.enabled&&(this._dragPan!==!1||this._dragPan===!1&&t)&&(this._show(),this._scrollCenterActiveFloor())}_addMapMoveEventListener(){this._maplibre.on("moveend",()=>{this.enabled&&this._dragPan===!1&&this._buildingId&&(this._indoor.getFeaturesById(this._buildingId,{layerIds:["mapxus-building-line"]})[0]?this._componentDidMount?this._visible||(this._show(),this._scrollCenterActiveFloor()):(this._render(),this._show(),this._scrollCenterActiveFloor()):this._componentDidMount&&this._visible&&this._hide())})}_clearState(){this._buildingId=null,this._floorNames=[],this._ordinals=[],this._ordinal=null}_calcSelectorLayout(){const{itemCount:t,itemSize:n}=this._style;this._centerSelectorIdx=Math.ceil(t/2)-1,this._maxScrollTop=(this._floorNames.length-t)*n,this._lastNormalScrollableIdx=this._floorNames.length-(t-this._centerSelectorIdx-1)-1}_render(){this._createFloors(),this._componentDidMount=!0}_hide(){this._container.classList.add("hidden"),this._visible=!1}_show(){this._container.classList.remove("hidden"),this._visible=!0}_createFloors(){this._$selectorFolded=this._$foldedSelector(this._container,()=>{this._expandSelector(!0),this._scrollCenterActiveFloor()}),this._$selectorExpanded=this._$expandedSelector(this._container,()=>this._expandSelector(!1))}_$expandedSelector(t,n){const{itemSize:r,itemCount:i,defaultFolded:o,backgroundColor:s}=this._style,a=Fe("div",`mapxus-ctrl-floors-expanded ${o?"hidden":""}`,t);if(this._floorNames.length>1){const u=Fe("div","mapxus-ctrl-floors-close",a);u.onclick=n}const d=Fe("div","mapxus-ctrl-floors-wrapper",a);return d.style.backgroundColor=s,this._floorNames.length>i&&(this._$arrowBtnUp=this._$createScrollButton(d,"up"),this._$arrowBtnUp.onclick=()=>this._handleScroll("up")),this._$innerFloors=Fe("div","mapxus-ctrl-floors-inner",d),Object.assign(this._$innerFloors.style,{maxHeight:`${r*i}px`,width:`${r}px`}),this._$createFloors(this._$innerFloors),this._floorNames.length>i&&(this._$arrowBtnDown=this._$createScrollButton(d,"down"),this._$arrowBtnDown.onclick=()=>this._handleScroll("down"),this._$innerFloors.addEventListener("scroll",this._debounceScroll=Ni(u=>{u.stopPropagation(),this._resetArrowBtnStatus(this._$innerFloors.scrollTop)},100)),this._clearScrollEventListener=()=>this._$innerFloors.removeEventListener("scroll",this._debounceScroll)),a}_$foldedSelector(t,n){const{itemSize:r,activeFontColor:i,activeBackgroundColor:o,defaultFolded:s}=this._style,a=Fe("div",`mapxus-ctrl-floors-folded mapxus-ctrl-floors-floor ${s?"":"hidden"}`,t);return a.onclick=n,Object.assign(a.style,{width:`${r}px`,height:`${r}px`,lineHeight:`${r}px`,color:i,backgroundColor:o}),a}_clearFloors(){this._container.replaceChildren(),this._componentDidMount=!1}_$createScrollButton(t,n){return Fe("div",`mapxus-ctrl-floors-arrow mapxus-ctrl-floors-floor ${n}`,t)}_$createFloors(t){const{fontColor:n,itemSize:r}=this._style;let i;this._floorNames.forEach((o,s)=>{i=Fe("div","mapxus-ctrl-floors-floor",t),i.dataset.floor=o,i.dataset.ordinal=this._ordinals[s],i.innerText=o,Object.assign(i.style,{color:n,height:`${r}px`,lineHeight:`${r}px`}),i.dataset.ordinal===this._ordinal&&(this._$activeFloor=i,this._resetActiveFloor(!0),this._$selectorFolded.innerText=o),i.onclick=async a=>{this._indoor.setDragPan("restrict"),this._indoor.dragPanHandler.setAnimated(!0),await this.switchByOrdinal(a.target.dataset.ordinal)}})}_updateSelectorStatus(t){const n=this._floorNames[this._ordinals.indexOf(t)];this._$activeFloor&&this._resetActiveFloor(!1);for(const r of this._$innerFloors.children){const i=r;i.dataset.ordinal===t&&(this._$activeFloor=i,this._resetActiveFloor(!0))}this._$selectorFolded.innerText=n}_resetArrowBtnStatus(t){t===0?this._$arrowBtnUp?.classList?.add("hidden"):this._$arrowBtnUp?.classList?.remove("hidden"),t===this._maxScrollTop?this._$arrowBtnDown?.classList?.add("hidden"):this._$arrowBtnDown?.classList?.remove("hidden")}_resetActiveFloor(t){const{activeBackgroundColor:n,backgroundColor:r,activeFontColor:i,fontColor:o}=this._style;Object.assign(this._$activeFloor.style,{color:t?i:o,backgroundColor:t?n:r,fontWeight:t?"bold":"normal",cursor:t?"auto":"pointer"}),this._$activeFloor.disabled=t}_scrollCenterActiveFloor(){if(this._ordinal){const t=this._ordinals.indexOf(this._ordinal);t>-1&&(this._$innerFloors.scrollTop=this._getScrollTop(t),this._$innerFloors.scrollTop||this._resetArrowBtnStatus(0))}}_getScrollTop(t){return kc(this._centerSelectorIdx,this._lastNormalScrollableIdx+1)?(t-this._centerSelectorIdx)*this._style.itemSize:t>this._lastNormalScrollableIdx?this._maxScrollTop:0}_handleScroll(t){const n=this._$innerFloors.scrollTop,{itemSize:r}=this._style;if(t==="up"){const i=n-r*2;this._$innerFloors.scrollTop=i<0?0:i}else if(t==="down"){const i=n+r*2;this._$innerFloors.scrollTop=i>this._maxScrollTop?this._maxScrollTop:i}}_expandSelector(t){t?(this._$selectorExpanded.classList.remove("hidden"),this._$selectorFolded.classList.add("hidden")):(this._$selectorExpanded.classList.add("hidden"),this._$selectorFolded.classList.remove("hidden"))}}class jg{_container;_isEnabled;constructor(t){this._isEnabled=t?.enabled??!0}onAdd(t){if(this._container=Fe("div","maplibregl-ctrl mapxus-ctrl-logo",t.getContainer()),this._isEnabled){const n=Fe("a","mapxus-logo",this._container);n.target="_blank",n.href="https://www.khi.co.jp/groupvision2030/mapxus.html",n.setAttribute("aria-label","Mapxus logo"),n.setAttribute("rel","noopener"),this._container.appendChild(n)}return this._container}onRemove(){Rn(this._container)}getDefaultPosition(){return"bottom-left"}}class qg{_container;_anchor;_theme;constructor(t){this._theme=t.theme?t.theme:"default"}onAdd(t){return this._container=Fe("div","maplibregl-ctrl mapxus-ctrl-attribution",t.getContainer()),this._anchor=Fe("a","mapxus-attribution",this._container),this._anchor.target="_blank",this._setCopyrightInfo(this._theme),this._anchor.setAttribute("aria-label","Mapxus attribution"),this._anchor.setAttribute("rel","noopener"),this._container.appendChild(this._anchor),this._container}onRemove(){Rn(this._container)}getDefaultPosition(){return"bottom-right"}changeTheme(t){this._setCopyrightInfo(t)}_setCopyrightInfo(t){this._anchor.innerText=t==="landsD"?"© The Government of the Hong Kong SAR":"©Mapxus driven by Kawasaki ©OpenStreetMap contributors",t==="landsD"&&(this._anchor.href="https://www.map.gov.hk/gm/")}}class Kg{_container;_$icon;_removeClickEventListener;onAdd(t){return this._container=Fe("div","maplibregl-ctrl mapxus-ctrl-collapsed-copyright",t.getContainer()),this._container.innerHTML=Gg(),this._bindEvents(),this._container}onRemove(){this._removeClickEventListener(),Rn(this._container)}getDefaultPosition(){return"bottom-right"}_bindEvents(){const t=this._container.querySelector(".mapxus-collapsed-copyright-menu");this._$icon=this._container.querySelector(".mapxus-collapsed-copyright-btn");let n=!1;this._$icon.addEventListener("click",r),this._removeClickEventListener=()=>this._$icon.removeEventListener("click",r);function r(){n=!n,i()}function i(){n?t.classList.remove("hidden"):t.classList.add("hidden")}}}function Gg(){return`
1
+ (function(p,T){typeof exports=="object"&&typeof module<"u"?T(exports,require("@mapxus/mapxus-auth-jp"),require("maplibre-gl")):typeof define=="function"&&define.amd?define(["exports","@mapxus/mapxus-auth-jp","maplibre-gl"],T):(p=typeof globalThis<"u"?globalThis:p||self,T(p.MapxusMap={},p.MapxusAuth,p.maplibregl))})(this,(function(p,T,kt){"use strict";var mr={value:()=>{}};function ye(){for(var t=0,e=arguments.length,i={},r;t<e;++t){if(!(r=arguments[t]+"")||r in i||/[\s.]/.test(r))throw new Error("illegal type: "+r);i[r]=[]}return new Ae(i)}function Ae(t){this._=t}function br(t,e){return t.trim().split(/^|\s+/).map(function(i){var r="",n=i.indexOf(".");if(n>=0&&(r=i.slice(n+1),i=i.slice(0,n)),i&&!e.hasOwnProperty(i))throw new Error("unknown type: "+i);return{type:i,name:r}})}Ae.prototype=ye.prototype={constructor:Ae,on:function(t,e){var i=this._,r=br(t+"",i),n,s=-1,o=r.length;if(arguments.length<2){for(;++s<o;)if((n=(t=r[s]).type)&&(n=Sr(i[n],t.name)))return n;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++s<o;)if(n=(t=r[s]).type)i[n]=Dt(i[n],t.name,e);else if(e==null)for(n in i)i[n]=Dt(i[n],t.name,null);return this},copy:function(){var t={},e=this._;for(var i in e)t[i]=e[i].slice();return new Ae(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var i=new Array(n),r=0,n,s;r<n;++r)i[r]=arguments[r+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(s=this._[t],r=0,n=s.length;r<n;++r)s[r].value.apply(e,i)},apply:function(t,e,i){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],n=0,s=r.length;n<s;++n)r[n].value.apply(e,i)}};function Sr(t,e){for(var i=0,r=t.length,n;i<r;++i)if((n=t[i]).name===e)return n.value}function Dt(t,e,i){for(var r=0,n=t.length;r<n;++r)if(t[r].name===e){t[r]=mr,t=t.slice(0,r).concat(t.slice(r+1));break}return i!=null&&t.push({name:e,value:i}),t}const Je={version:"10.0.0"}.version,Ht="https://map-api.mapxus.co.jp/bms",R=10,k=1;class D{static instance;_globalDispatcher;_httpSession;_theme=null;_isSDKInitialized=!1;constructor(){}static getInstance(){return D.instance||(D.instance=new D),D.instance}setGlobalDispatcher(e){this._globalDispatcher=e}getGlobalDispatcher(){return this._globalDispatcher}async getHttpSession(){return this._httpSession||(this.registerSDK(),this._httpSession=await T.HTTPSession.create(T.SDKName.MapSDK,T.base64Encode(`version-${Je}`)),this._httpSession.setBaseURL(Ht),this._httpSession.setRetryConfig(3)),this._httpSession}registerSDK(){this._isSDKInitialized||(this._isSDKInitialized=!0,T.reportLog(`${T.SDKName.MapSDK} initialized`))}get theme(){return this._theme}setTheme(e){this._theme=e}clear(){this._httpSession.destroy(),this._globalDispatcher=null,D.instance=null}}const Nt=["unauthorized","initError"],et=globalThis,tt=ye(...Nt);D.getInstance().setGlobalDispatcher(tt),et.MapxusMapEvents=et.MapxusMapEvents||{},et.MapxusMapEvents.on=function(t,e){return tt.on(t,e),{off:()=>tt.on(t,null)}};var Me={exports:{}},Ut;function vr(){if(Ut)return Me.exports;Ut=1;function t(){}return t.prototype={on:function(e,i,r){var n=this.e||(this.e={});return(n[e]||(n[e]=[])).push({fn:i,ctx:r}),this},once:function(e,i,r){var n=this;function s(){n.off(e,s),i.apply(r,arguments)}return s._=i,this.on(e,s,r)},emit:function(e){var i=[].slice.call(arguments,1),r=((this.e||(this.e={}))[e]||[]).slice(),n=0,s=r.length;for(n;n<s;n++)r[n].fn.apply(r[n].ctx,i);return this},off:function(e,i){var r=this.e||(this.e={}),n=r[e],s=[];if(n&&i)for(var o=0,a=n.length;o<a;o++)n[o].fn!==i&&n[o].fn._!==i&&s.push(n[o]);return s.length?r[e]=s:delete r[e],this}},Me.exports=t,Me.exports.TinyEmitter=t,Me.exports}var Ir=vr(),xe=(t=>(t[t.VENUE=0]="VENUE",t[t.GLOBAL=1]="GLOBAL",t))(xe||{});function Lr(t){return t.layers.filter(e=>!rt(e.source))}function it(t){return t.layers.filter(e=>rt(e.source))}function rt(t){return typeof t!="string"?!1:t.startsWith("indoor-")}function nt(t){const{buildingId:e,labelCenter:{lat:i,lon:r},floors:n,name:s,venueId:o,defaultFloor:a}=t,l=Object.entries(s).reduce((c,[f,g])=>{const _=f==="default"?"name":`name:${f}`;return Object.assign(c,{[_]:g})},{}),{codes:d,ids:u,ordinals:h}=n.reduce((c,f)=>{const{id:g,code:_,ordinal:y}=f;return{codes:c.codes?`${c.codes},${_}`:_,ids:c.ids?`${c.ids},${g}`:g,ordinals:`${c.ordinals}`?`${c.ordinals},${y}`:`${y}`}},{codes:"",ids:"",ordinals:""});return{layer:{id:"mapxus-building-line"},properties:{building:"yes",id:e,label_center:`${r},${i}`,level_ids:u,level_names:d,ordinals:h,"ref:venue":o,...l,...a?{default_displayed_floor:a}:{}},source:"indoor-planet",sourceLayer:"mapxus_building"}}function Te(t){const{address:e,buildings:i,id:r,name:n,type:s,labelCenter:{lon:o,lat:a},defaultBuilding:l,sharedFloors:d}=t,u=Object.entries(e).reduce((_,[y,m])=>Object.assign(_,y==="default"?{"addr:street":m.street,"addr:housenumber":m.housenumber}:{[`addr:street:${y}`]:m.street}),{}),h=Object.entries(n).reduce((_,[y,m])=>{const S=y==="default"?"name":`name:${y}`;return Object.assign(_,{[S]:m})},{}),c=l?i.find(_=>_.id===l)?.defaultFloor:null,f=l?{default_displayed_building:l,...c?{default_displayed_ordinal:c}:{}}:{},g=d?.length?{shared_level_ids:d.map(({id:_})=>_).join(","),shared_level_ordinals:d.map(({ordinal:_})=>_).join(",")}:{};return{layer:{id:"mapxus-venue-fill"},properties:{...u,...h,id:r,venue:s,label_center:`${o},${a}`,building_ids:i.map(({id:_})=>_).join(),...f,...g},source:"indoor-planet",sourceLayer:"mapxus_venue"}}function w(t,e=","){return typeof t!="string"||!t.trim()?[]:t.split(e)}const me="reserve_mapxus-level-fill",x="reserve_mapxus-shared-level-fill",be="reserve_mapxus-building-fill";var M=(t=>(t.ENGLISH="en",t.CHINESE_SIMPLIFIED="zh-Hans",t.CHINESE_TRADITIONAL="zh-Hant",t.CHINESE_TRADITIONAL_TW="zh-Hant-TW",t.JAPANESE="ja",t.KOREAN="ko",t.FILIPINO="fil",t.INDONESIAN="id",t.PORTUGUESE="pt",t.THAI="th",t.VIETNAMESE="vi",t.ARABIC="ar",t))(M||{});function jt(t){let e=null;return wr(t)?e=M.ENGLISH:Br(t)?e=M.CHINESE_SIMPLIFIED:Er(t)?e=M.CHINESE_TRADITIONAL:Pr(t)?e=M.CHINESE_TRADITIONAL_TW:Fr(t)?e=M.JAPANESE:Cr(t)?e=M.KOREAN:Or(t)?e=M.FILIPINO:$r(t)?e=M.INDONESIAN:Ar(t)?e=M.PORTUGUESE:Mr(t)?e=M.THAI:xr(t)?e=M.VIETNAMESE:Tr(t)&&(e=M.ARABIC),e}function wr(t){return/^en(-(US|GB|AU))?$/.test(t)}function Br(t){return/^zh(-(Hans|CN))?$/.test(t)}function Er(t){return/^zh-(Hant|HK|MO)$/.test(t)}function Pr(t){return t==="zh-TW"}function Fr(t){return/^ja(-JP)?$/.test(t)}function Cr(t){return/^ko(-KR)?$/.test(t)}function Or(t){return/^(fil|tl)(-PH)?$/.test(t)}function $r(t){return/^id(-ID)?$/.test(t)}function Ar(t){return/^pt(-(BR|PT))?$/.test(t)}function Mr(t){return/^th(-TH)?$/.test(t)}function xr(t){return/^vi(-VN)?$/.test(t)}function Tr(t){return/^ar(-(DZ|BH|EG|IQ|JO|KW|LB|LY|MA|OM|QA|SA|SY|TN|AE|YE))?$/.test(t)}const Re={lineWidth:3,lineColor:"#A5E3FF",lineOpacity:1,lineOffset:-1.5},Vt={fontColor:"#8c8c8c",activeFontColor:"#fff",backgroundColor:"#fff",activeBackgroundColor:"#074769",itemSize:50,itemCount:4,defaultFolded:!1},Rr=jt(window.navigator.language)??M.ENGLISH;let zt=class extends Error{status;constructor(e,i){super(e);const{status:r,name:n}=i;r!==void 0&&(this.status=r),n!==void 0&&(this.name=n)}};function kr(t,e=30){let i,r=null;return{promise:new Promise((o,a)=>{r=a;const l=performance.now(),d=()=>{t()?(clearInterval(i),o(!0)):(performance.now()-l)/1e3>e&&(a(new zt("Timeouts or Feature is not found in the map at current zoom level.",{status:404,name:"NetworkError"})),clearInterval(i))};d(),i=setInterval(d,100)}),abort:()=>{i&&(clearInterval(i),i=null),r&&(r(new zt("Query was aborted by the user.",{status:400,name:"AbortError"})),r=null)}}}function N(t){if(!t)return null;const i=(Array.isArray(t)?t:[t]).filter(v).map(r=>r.trim());return i.length>0?i.join(","):null}function v(t){return typeof t=="string"&&t.trim().length>0}function Z(t){return Array.isArray(t)&&t.length===2&&t.every(e=>typeof e=="number")}function Se(t){return Array.isArray(t)&&t.length===2&&t.every(e=>Z(e))}function se(t){return typeof t=="number"&&t>0}function ke(t,e){const i={...t};return e.forEach(r=>{delete i[r]}),i}var qt=(t=>(t.POINT="Point",t.POLYGON="Polygon",t))(qt||{}),st=(t=>(t.POINT="Point",t.POLYGON="Polygon",t.GATE="Gate",t))(st||{}),Gt=(t=>(t.DEFAULT_NAME="DefaultName",t))(Gt||{}),Kt=(t=>(t.ABSOLUTE_DISTANCE="AbsoluteDistance",t.ACTUAL_DISTANCE="ActualDistance",t))(Kt||{});const ot=["specialHours","businessStatus","serviceHours","keywords","siteCode","refPhotoId","totalPhotoCount","photos","icon"],at=D.getInstance();class Wt{_poisApi="api/v5/pois";_categoriesGroupApi="api/v5/categories/group";constructor(){}searchByIds(e){const i=N(e);if(!i)throw new Error("Invalid ids parameter. Expected a non-empty string or an array of strings.");const r=`${this._poisApi}/${i}`;return this._filterPoiProperties(r,W)}searchByDistance(e){const{center:i,distance:r,keywords:n="",offset:s=R,page:o=k}=e;if(!Z(i))throw new Error("Invalid center parameter. Expected an array of two numbers.");if(!se(r)||r>1e4)throw new Error("Invalid distance parameter. Expected a positive number and no more than 10000.");const a=new URLSearchParams;a.set("center",i.join(",")),a.set("distance",String(Math.round(r))),a.set("offset",String(s)),a.set("page",String(o)),v(n)&&a.set("keywords",n);const l=`${this._poisApi}?${a.toString()}`;return this._filterPoiProperties(l,W)}searchByBounds(e){const{bounds:i,offset:r=R,page:n=k,keywords:s,orderBy:o}=e;if(!Se(i))throw new Error("'bounds' must be an array of two arrays, each containing two numbers.");const a=new URLSearchParams;a.set("bbox",i.flat().join()),a.set("offset",String(r)),a.set("page",String(n)),v(s)&&a.set("keywords",s),o&&a.set("orderBy",o);const l=`${this._poisApi}?${a.toString()}`;return this._filterPoiProperties(l,W)}searchByBuilding(e){const{buildingId:i,offset:r=R,page:n=k,keywords:s,orderBy:o}=e;if(!v(i))throw new Error("'buildingId' must be a non-empty string.");const a=new URLSearchParams;a.set("buildingId",i),a.set("offset",String(r)),a.set("page",String(n)),v(s)&&a.set("keywords",s),o&&a.set("orderBy",o);const l=`${this._poisApi}?${a.toString()}`;return this._filterPoiProperties(l,d=>W(d))}searchByVenue(e){const{venueId:i,offset:r=R,page:n=k,keywords:s,orderBy:o}=e;if(!v(i))throw new Error("'venueId' must be a non-empty string.");const a=new URLSearchParams;a.set("venueId",i),a.set("offset",String(r)),a.set("page",String(n)),v(s)&&a.set("keywords",s),o&&a.set("orderBy",o);const l=`${this._poisApi}?${a.toString()}`;return this._filterPoiProperties(l,W)}searchByFloors(e){let i=null,r=null;const n="floorIds"in e?N(e.floorIds):null,s="sharedFloorIds"in e?N(e.sharedFloorIds):null;if(n?(i="floorId",r=n):s&&(i="sharedFloorId",r=s),!i||!r)throw new Error("Either 'floorIds' or 'sharedFloorIds' must be a non-empty array.");const{offset:o=R,page:a=k,keywords:l,orderBy:d}=e,u=new URLSearchParams;u.set("offset",String(o)),u.set("page",String(a)),u.set(i,r),v(l)&&u.set("keywords",l),d&&u.set("orderBy",d);const h=`${this._poisApi}?${u.toString()}`;return this._filterPoiProperties(h,W)}async searchByOrientation(e){const{center:i,angle:r,distance:n,distanceSearchType:s=st.POINT}=e;if(!Z(i))throw new Error("Invalid center parameter. Expected an array of two numbers.");if(!se(n)||n>100)throw new Error("Invalid distance parameter. Expected a positive number and no more than 100.");if(!se(r))throw new Error("Invalid angle parameter. Expected a positive number.");const o=new URLSearchParams;if("ordinal"in e){if(!v(e.ordinal))throw new Error("'ordinal' must be a non-empty string.");o.set("ordinal",e.ordinal)}else if("floorId"in e){if(!v(e.floorId))throw new Error("'floorId' must be a non-empty string.");o.set("floorId",e.floorId)}else if("buildingId"in e){if(!v(e.buildingId))throw new Error("'buildingId' must be a non-empty string.");o.set("buildingId",e.buildingId)}else throw new Error("Either 'ordinal', 'floorId', or 'buildingId' must be provided.");o.set("center",i.join()),o.set("angle",String(Math.round(r))),o.set("distance",String(n)),o.set("distanceSearchType",s);const a=`${this._poisApi}/orientation?${o.toString()}`;return(await at.getHttpSession()).request(a)}searchByCategory(e){const{center:i,distance:r,page:n=k,offset:s=R}=e;if(!Z(i))throw new Error("Invalid center parameter. Expected an array of two numbers.");if(!se(r)||r>1e4)throw new Error("Invalid distance parameter. Expected a positive number and no more than 10000");const o=new URLSearchParams;if("category"in e&&v(e.category))o.set("category",String(e.category));else if("excludedCategories"in e&&N(e.excludedCategories))o.set("excludeCategories",N(e.excludedCategories));else throw new Error("Either 'category' or 'excludedCategories' must be provided.");o.set("center",i.join(",")),o.set("distance",String(r)),o.set("page",String(n)),o.set("offset",String(s));const a=`${this._poisApi}?${o.toString()}`;return this._filterPoiProperties(a,W)}async searchCategories(e){const i=new URLSearchParams;if("floorId"in e&&v(e.floorId)?i.set("floorId",e.floorId):"buildingId"in e&&v(e.buildingId)?i.set("buildingId",e.buildingId):"sharedFloorId"in e&&v(e.sharedFloorId)?i.set("sharedFloorId",e.sharedFloorId):"venueId"in e&&v(e.venueId)&&i.set("venueId",e.venueId),"bounds"in e&&Se(e.bounds)&&(i.set("bbox",e.bounds.flat().join()),v(e.keywords)&&i.set("keywords",e.keywords)),i.toString().length===0)throw new Error("At least one of 'floorId', 'buildingId', 'sharedFloorId', 'venueId', or 'bounds' must be provided.");const r=`${this._categoriesGroupApi}?${i.toString()}`;return(await at.getHttpSession()).request(r)}search(e){const i=new URLSearchParams;Object.entries(e).forEach(([n,s])=>{switch(n){case"bounds":Se(s)&&i.set("bbox",s.flat().join());break;case"center":Z(s)&&i.set("center",s.join());break;case"excludedCategories":const o=N(s);o&&i.set("excludeCategories",o);break;case"floorIds":const a=N(s);a&&i.set("floorId",a);break;case"sharedFloorIds":const l=N(s);l&&i.set("sharedFloorId",l);break;default:i.set(n,String(s))}});const r=`${this._poisApi}?${i.toString()}`;return this._filterPoiProperties(r,W)}async _filterPoiProperties(e,i){const n=await(await at.getHttpSession()).request(e),s=n.result.pois.map(i);return{...n,result:{...n.result,pois:s}}}}function W(t){return"sharedFloorId"in t,ke(t,ot)}const Yt=["opening_hours","description","phone","website","email","appURL","icon"],Dr=D.getInstance();class Xt{_api="api/v5/venues";constructor(){}searchByIds(e){const i=N(e);if(!i)throw new Error("Please input venue id at least one.");const r=`${this._api}/${i}`;return this._filterVenueProperties(r,oe)}searchByDistance(e){const{center:i,distance:r,keywords:n="",offset:s=R,page:o=k}=e;if(!Z(i))throw new Error("Invalid center parameter. Expected an array of two numbers.");if(!se(r)||r>1e4)throw new Error("Invalid distance parameter. Expected a positive number and no more than 10000.");const a=new URLSearchParams;a.set("center",i.join(",")),a.set("distance",String(r)),a.set("offset",String(s)),a.set("page",String(o)),v(n)&&a.set("keywords",n);const l=`${this._api}?${a.toString()}`;return this._filterVenueProperties(l,oe)}searchByBounds(e){const{keywords:i,bounds:r,offset:n=R,page:s=k}=e;if(!Se(r))throw new Error("'bounds' must be an array of two arrays, each containing two numbers.");const o=new URLSearchParams;o.set("bbox",r.flat().join()),o.set("offset",String(n)),o.set("page",String(s)),v(i)&&o.set("keywords",i);const a=`${this._api}?${o.toString()}`;return this._filterVenueProperties(a,oe)}searchByGlobal(e){const{keywords:i,offset:r=R,page:n=k}=e,s=new URLSearchParams;s.set("offset",String(r)),s.set("page",String(n)),v(i)&&s.set("keywords",i);const o=`${this._api}?${s.toString()}`;return this._filterVenueProperties(o,oe)}searchBySharedFloorId(e){if(!v(e))throw new Error("Please input correct sharedFloorId.");const i=`${this._api}/shared_floors/${e}`;return this._filterVenueProperties(i,oe)}search(e){const i=new URLSearchParams;Object.entries(e).forEach(([n,s])=>{n==="bounds"?i.set("bbox",s.flat().join()):n==="center"?i.set("center",s.join()):i.set(n,String(s))});const r=`${this._api}?${i.toString()}`;return this._filterVenueProperties(r,oe)}async _filterVenueProperties(e,i){const n=await(await Dr.getHttpSession()).request(e),s=n.result.venues.map(i);return{...n,result:{...n.result,venues:s}}}}function oe(t){return ke(t,Yt)}const Qt=["specialHours","businessStatus","serviceHours","keywords","siteCode","refPhotoId","totalPhotoCount","photos","description"],Hr=D.getInstance();class Zt{_api="api/v5/buildings";constructor(){}searchByIds(e){const i=N(e);if(!i)throw new Error("Please input building id at least one.");const r=`${this._api}/${i}`;return this._filterBuildingProperties(r,ae)}searchByDistance(e){const{center:i,distance:r,keywords:n="",offset:s=R,page:o=k}=e;if(!Z(i))throw new Error("Invalid center parameter. Expected an array of two numbers.");if(!se(r)||r>1e4)throw new Error("Invalid distance parameter. Expected a positive number and no more than 10000.");const a=new URLSearchParams;a.set("center",i.join(",")),a.set("distance",String(r)),a.set("offset",String(s)),a.set("page",String(o)),v(n)&&a.set("keywords",n);const l=`${this._api}?${a.toString()}`;return this._filterBuildingProperties(l,ae)}searchByBounds(e){const{bounds:i,offset:r=R,page:n=k,keywords:s}=e;if(!Se(i))throw new Error("'bounds' must be an array of two arrays, each containing two numbers.");const o=new URLSearchParams;o.set("bbox",i.flat().join()),o.set("offset",String(r)),o.set("page",String(n)),v(s)&&o.set("keywords",s);const a=`${this._api}?${o.toString()}`;return this._filterBuildingProperties(a,ae)}searchByGlobal(e){const{keywords:i,offset:r=R,page:n=k}=e,s=new URLSearchParams;s.set("searchGlobal",String(!0)),s.set("offset",String(r)),s.set("page",String(n)),v(i)&&s.set("keywords",i);const o=`${this._api}?${s.toString()}`;return this._filterBuildingProperties(o,ae)}searchByFloorId(e){if(!v(e))throw new Error("'floorId' cannot be empty.");const i=`${this._api}/floors/${e}`;return this._filterBuildingProperties(i,ae)}search(e){const i=new URLSearchParams;Object.entries(e).forEach(([n,s])=>{n==="bounds"?i.set("bbox",s.flat().join()):n==="center"?i.set("center",s.join()):i.set(n,String(s))});const r=`${this._api}?${i.toString()}`;return this._filterBuildingProperties(r,ae)}async _filterBuildingProperties(e,i){const n=await(await Hr.getHttpSession()).request(e),s=n.result.buildings.map(i);return{...n,result:{...n.result,buildings:s}}}}function ae(t){return ke(t,Qt)}const Jt=new Zt,ei=new Xt,Nr=new Wt;async function De(t){return(await Jt.searchByIds(t)).result.buildings[0]}async function Ur(t){const i=(await Jt.searchByFloorId(t)).result.buildings[0].buildingId;return await De(i)}async function He(t){return(await ei.searchByIds(t)).result.venues[0]}async function ti(t){return(await ei.searchBySharedFloorId(t)).result.venues[0]}async function jr(t){return(await Nr.searchByIds([t])).result.pois[0]}class Y{static instance;_visitedBuildingUnits;_historyBuildingUnit;_historyOrdinal;constructor(){this._visitedBuildingUnits=[],this._historyBuildingUnit=new Map,this._historyOrdinal=new Map}static getInstance(){return Y.instance||(Y.instance=new Y),Y.instance}getHistoryBuildingUnit(e){return this._historyBuildingUnit.get(e)}setHistoryBuildingUnit(e,i){this._historyBuildingUnit.set(e,i)}getHistoryOrdinal(e){return this._historyOrdinal.get(e)}setHistoryOrdinal(e,i){this._historyOrdinal.set(e,i)}getVisitedBuildingUnits(){return this._visitedBuildingUnits}addVisitedBuildingUnit(e){this._visitedBuildingUnits.push(e),this._visitedBuildingUnits.length>100&&(this._visitedBuildingUnits=this._visitedBuildingUnits.slice(this._visitedBuildingUnits.length-100))}}var ii=typeof global=="object"&&global&&global.Object===Object&&global,Vr=typeof self=="object"&&self&&self.Object===Object&&self,U=ii||Vr||Function("return this")(),X=U.Symbol,ri=Object.prototype,zr=ri.hasOwnProperty,qr=ri.toString,ve=X?X.toStringTag:void 0;function Gr(t){var e=zr.call(t,ve),i=t[ve];try{t[ve]=void 0;var r=!0}catch{}var n=qr.call(t);return r&&(e?t[ve]=i:delete t[ve]),n}var Kr=Object.prototype,Wr=Kr.toString;function Yr(t){return Wr.call(t)}var Xr="[object Null]",Qr="[object Undefined]",ni=X?X.toStringTag:void 0;function le(t){return t==null?t===void 0?Qr:Xr:ni&&ni in Object(t)?Gr(t):Yr(t)}function de(t){return t!=null&&typeof t=="object"}var Zr="[object Symbol]";function Ie(t){return typeof t=="symbol"||de(t)&&le(t)==Zr}function Jr(t,e,i){for(var r=-1,n=t.length;++r<n;){var s=t[r],o=e(s);if(o!=null&&(a===void 0?o===o&&!Ie(o):i(o,a)))var a=o,l=s}return l}function en(){this.__data__=[],this.size=0}function si(t,e){return t===e||t!==t&&e!==e}function Ne(t,e){for(var i=t.length;i--;)if(si(t[i][0],e))return i;return-1}var tn=Array.prototype,rn=tn.splice;function nn(t){var e=this.__data__,i=Ne(e,t);if(i<0)return!1;var r=e.length-1;return i==r?e.pop():rn.call(e,i,1),--this.size,!0}function sn(t){var e=this.__data__,i=Ne(e,t);return i<0?void 0:e[i][1]}function on(t){return Ne(this.__data__,t)>-1}function an(t,e){var i=this.__data__,r=Ne(i,t);return r<0?(++this.size,i.push([t,e])):i[r][1]=e,this}function j(t){var e=-1,i=t==null?0:t.length;for(this.clear();++e<i;){var r=t[e];this.set(r[0],r[1])}}j.prototype.clear=en,j.prototype.delete=nn,j.prototype.get=sn,j.prototype.has=on,j.prototype.set=an;function ln(){this.__data__=new j,this.size=0}function dn(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i}function un(t){return this.__data__.get(t)}function cn(t){return this.__data__.has(t)}function ue(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var hn="[object AsyncFunction]",_n="[object Function]",fn="[object GeneratorFunction]",pn="[object Proxy]";function oi(t){if(!ue(t))return!1;var e=le(t);return e==_n||e==fn||e==hn||e==pn}var lt=U["__core-js_shared__"],ai=(function(){var t=/[^.]+$/.exec(lt&&lt.keys&&lt.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function gn(t){return!!ai&&ai in t}var yn=Function.prototype,mn=yn.toString;function J(t){if(t!=null){try{return mn.call(t)}catch{}try{return t+""}catch{}}return""}var bn=/[\\^$.*+?()[\]{}|]/g,Sn=/^\[object .+?Constructor\]$/,vn=Function.prototype,In=Object.prototype,Ln=vn.toString,wn=In.hasOwnProperty,Bn=RegExp("^"+Ln.call(wn).replace(bn,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function En(t){if(!ue(t)||gn(t))return!1;var e=oi(t)?Bn:Sn;return e.test(J(t))}function Pn(t,e){return t?.[e]}function ce(t,e){var i=Pn(t,e);return En(i)?i:void 0}var Le=ce(U,"Map"),we=ce(Object,"create");function Fn(){this.__data__=we?we(null):{},this.size=0}function Cn(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var On="__lodash_hash_undefined__",$n=Object.prototype,An=$n.hasOwnProperty;function Mn(t){var e=this.__data__;if(we){var i=e[t];return i===On?void 0:i}return An.call(e,t)?e[t]:void 0}var xn=Object.prototype,Tn=xn.hasOwnProperty;function Rn(t){var e=this.__data__;return we?e[t]!==void 0:Tn.call(e,t)}var kn="__lodash_hash_undefined__";function Dn(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=we&&e===void 0?kn:e,this}function ee(t){var e=-1,i=t==null?0:t.length;for(this.clear();++e<i;){var r=t[e];this.set(r[0],r[1])}}ee.prototype.clear=Fn,ee.prototype.delete=Cn,ee.prototype.get=Mn,ee.prototype.has=Rn,ee.prototype.set=Dn;function Hn(){this.size=0,this.__data__={hash:new ee,map:new(Le||j),string:new ee}}function Nn(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function Ue(t,e){var i=t.__data__;return Nn(e)?i[typeof e=="string"?"string":"hash"]:i.map}function Un(t){var e=Ue(this,t).delete(t);return this.size-=e?1:0,e}function jn(t){return Ue(this,t).get(t)}function Vn(t){return Ue(this,t).has(t)}function zn(t,e){var i=Ue(this,t),r=i.size;return i.set(t,e),this.size+=i.size==r?0:1,this}function V(t){var e=-1,i=t==null?0:t.length;for(this.clear();++e<i;){var r=t[e];this.set(r[0],r[1])}}V.prototype.clear=Hn,V.prototype.delete=Un,V.prototype.get=jn,V.prototype.has=Vn,V.prototype.set=zn;var qn=200;function Gn(t,e){var i=this.__data__;if(i instanceof j){var r=i.__data__;if(!Le||r.length<qn-1)return r.push([t,e]),this.size=++i.size,this;i=this.__data__=new V(r)}return i.set(t,e),this.size=i.size,this}function z(t){var e=this.__data__=new j(t);this.size=e.size}z.prototype.clear=ln,z.prototype.delete=dn,z.prototype.get=un,z.prototype.has=cn,z.prototype.set=Gn;var Kn="__lodash_hash_undefined__";function Wn(t){return this.__data__.set(t,Kn),this}function Yn(t){return this.__data__.has(t)}function Be(t){var e=-1,i=t==null?0:t.length;for(this.__data__=new V;++e<i;)this.add(t[e])}Be.prototype.add=Be.prototype.push=Wn,Be.prototype.has=Yn;function Xn(t,e){for(var i=-1,r=t==null?0:t.length;++i<r;)if(e(t[i],i,t))return!0;return!1}function li(t,e){return t.has(e)}var Qn=1,Zn=2;function di(t,e,i,r,n,s){var o=i&Qn,a=t.length,l=e.length;if(a!=l&&!(o&&l>a))return!1;var d=s.get(t),u=s.get(e);if(d&&u)return d==e&&u==t;var h=-1,c=!0,f=i&Zn?new Be:void 0;for(s.set(t,e),s.set(e,t);++h<a;){var g=t[h],_=e[h];if(r)var y=o?r(_,g,h,e,t,s):r(g,_,h,t,e,s);if(y!==void 0){if(y)continue;c=!1;break}if(f){if(!Xn(e,function(m,S){if(!li(f,S)&&(g===m||n(g,m,i,r,s)))return f.push(S)})){c=!1;break}}else if(!(g===_||n(g,_,i,r,s))){c=!1;break}}return s.delete(t),s.delete(e),c}var ui=U.Uint8Array;function Jn(t){var e=-1,i=Array(t.size);return t.forEach(function(r,n){i[++e]=[n,r]}),i}function dt(t){var e=-1,i=Array(t.size);return t.forEach(function(r){i[++e]=r}),i}var es=1,ts=2,is="[object Boolean]",rs="[object Date]",ns="[object Error]",ss="[object Map]",os="[object Number]",as="[object RegExp]",ls="[object Set]",ds="[object String]",us="[object Symbol]",cs="[object ArrayBuffer]",hs="[object DataView]",ci=X?X.prototype:void 0,ut=ci?ci.valueOf:void 0;function _s(t,e,i,r,n,s,o){switch(i){case hs:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case cs:return!(t.byteLength!=e.byteLength||!s(new ui(t),new ui(e)));case is:case rs:case os:return si(+t,+e);case ns:return t.name==e.name&&t.message==e.message;case as:case ds:return t==e+"";case ss:var a=Jn;case ls:var l=r&es;if(a||(a=dt),t.size!=e.size&&!l)return!1;var d=o.get(t);if(d)return d==e;r|=ts,o.set(t,e);var u=di(a(t),a(e),r,n,s,o);return o.delete(t),u;case us:if(ut)return ut.call(t)==ut.call(e)}return!1}function fs(t,e){for(var i=-1,r=e.length,n=t.length;++i<r;)t[n+i]=e[i];return t}var q=Array.isArray;function ps(t,e,i){var r=e(t);return q(t)?r:fs(r,i(t))}function gs(t,e){for(var i=-1,r=t==null?0:t.length,n=0,s=[];++i<r;){var o=t[i];e(o,i,t)&&(s[n++]=o)}return s}function ys(){return[]}var ms=Object.prototype,bs=ms.propertyIsEnumerable,hi=Object.getOwnPropertySymbols,Ss=hi?function(t){return t==null?[]:(t=Object(t),gs(hi(t),function(e){return bs.call(t,e)}))}:ys;function vs(t,e){for(var i=-1,r=Array(t);++i<t;)r[i]=e(i);return r}var Is="[object Arguments]";function _i(t){return de(t)&&le(t)==Is}var fi=Object.prototype,Ls=fi.hasOwnProperty,ws=fi.propertyIsEnumerable,pi=_i((function(){return arguments})())?_i:function(t){return de(t)&&Ls.call(t,"callee")&&!ws.call(t,"callee")};function Bs(){return!1}var gi=typeof p=="object"&&p&&!p.nodeType&&p,yi=gi&&typeof module=="object"&&module&&!module.nodeType&&module,Es=yi&&yi.exports===gi,mi=Es?U.Buffer:void 0,Ps=mi?mi.isBuffer:void 0,ct=Ps||Bs,Fs=9007199254740991,Cs=/^(?:0|[1-9]\d*)$/;function bi(t,e){var i=typeof t;return e=e??Fs,!!e&&(i=="number"||i!="symbol"&&Cs.test(t))&&t>-1&&t%1==0&&t<e}var Os=9007199254740991;function ht(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Os}var $s="[object Arguments]",As="[object Array]",Ms="[object Boolean]",xs="[object Date]",Ts="[object Error]",Rs="[object Function]",ks="[object Map]",Ds="[object Number]",Hs="[object Object]",Ns="[object RegExp]",Us="[object Set]",js="[object String]",Vs="[object WeakMap]",zs="[object ArrayBuffer]",qs="[object DataView]",Gs="[object Float32Array]",Ks="[object Float64Array]",Ws="[object Int8Array]",Ys="[object Int16Array]",Xs="[object Int32Array]",Qs="[object Uint8Array]",Zs="[object Uint8ClampedArray]",Js="[object Uint16Array]",eo="[object Uint32Array]",I={};I[Gs]=I[Ks]=I[Ws]=I[Ys]=I[Xs]=I[Qs]=I[Zs]=I[Js]=I[eo]=!0,I[$s]=I[As]=I[zs]=I[Ms]=I[qs]=I[xs]=I[Ts]=I[Rs]=I[ks]=I[Ds]=I[Hs]=I[Ns]=I[Us]=I[js]=I[Vs]=!1;function to(t){return de(t)&&ht(t.length)&&!!I[le(t)]}function io(t){return function(e){return t(e)}}var Si=typeof p=="object"&&p&&!p.nodeType&&p,Ee=Si&&typeof module=="object"&&module&&!module.nodeType&&module,ro=Ee&&Ee.exports===Si,_t=ro&&ii.process,vi=(function(){try{var t=Ee&&Ee.require&&Ee.require("util").types;return t||_t&&_t.binding&&_t.binding("util")}catch{}})(),Ii=vi&&vi.isTypedArray,Li=Ii?io(Ii):to,no=Object.prototype,so=no.hasOwnProperty;function oo(t,e){var i=q(t),r=!i&&pi(t),n=!i&&!r&&ct(t),s=!i&&!r&&!n&&Li(t),o=i||r||n||s,a=o?vs(t.length,String):[],l=a.length;for(var d in t)so.call(t,d)&&!(o&&(d=="length"||n&&(d=="offset"||d=="parent")||s&&(d=="buffer"||d=="byteLength"||d=="byteOffset")||bi(d,l)))&&a.push(d);return a}var ao=Object.prototype;function lo(t){var e=t&&t.constructor,i=typeof e=="function"&&e.prototype||ao;return t===i}function uo(t,e){return function(i){return t(e(i))}}var co=uo(Object.keys,Object),ho=Object.prototype,_o=ho.hasOwnProperty;function fo(t){if(!lo(t))return co(t);var e=[];for(var i in Object(t))_o.call(t,i)&&i!="constructor"&&e.push(i);return e}function po(t){return t!=null&&ht(t.length)&&!oi(t)}function wi(t){return po(t)?oo(t):fo(t)}function Bi(t){return ps(t,wi,Ss)}var go=1,yo=Object.prototype,mo=yo.hasOwnProperty;function bo(t,e,i,r,n,s){var o=i&go,a=Bi(t),l=a.length,d=Bi(e),u=d.length;if(l!=u&&!o)return!1;for(var h=l;h--;){var c=a[h];if(!(o?c in e:mo.call(e,c)))return!1}var f=s.get(t),g=s.get(e);if(f&&g)return f==e&&g==t;var _=!0;s.set(t,e),s.set(e,t);for(var y=o;++h<l;){c=a[h];var m=t[c],S=e[c];if(r)var E=o?r(S,m,c,e,t,s):r(m,S,c,t,e,s);if(!(E===void 0?m===S||n(m,S,i,r,s):E)){_=!1;break}y||(y=c=="constructor")}if(_&&!y){var C=t.constructor,B=e.constructor;C!=B&&"constructor"in t&&"constructor"in e&&!(typeof C=="function"&&C instanceof C&&typeof B=="function"&&B instanceof B)&&(_=!1)}return s.delete(t),s.delete(e),_}var ft=ce(U,"DataView"),pt=ce(U,"Promise"),he=ce(U,"Set"),gt=ce(U,"WeakMap"),Ei="[object Map]",So="[object Object]",Pi="[object Promise]",Fi="[object Set]",Ci="[object WeakMap]",Oi="[object DataView]",vo=J(ft),Io=J(Le),Lo=J(pt),wo=J(he),Bo=J(gt),Q=le;(ft&&Q(new ft(new ArrayBuffer(1)))!=Oi||Le&&Q(new Le)!=Ei||pt&&Q(pt.resolve())!=Pi||he&&Q(new he)!=Fi||gt&&Q(new gt)!=Ci)&&(Q=function(t){var e=le(t),i=e==So?t.constructor:void 0,r=i?J(i):"";if(r)switch(r){case vo:return Oi;case Io:return Ei;case Lo:return Pi;case wo:return Fi;case Bo:return Ci}return e});var Eo=1,$i="[object Arguments]",Ai="[object Array]",je="[object Object]",Po=Object.prototype,Mi=Po.hasOwnProperty;function Fo(t,e,i,r,n,s){var o=q(t),a=q(e),l=o?Ai:Q(t),d=a?Ai:Q(e);l=l==$i?je:l,d=d==$i?je:d;var u=l==je,h=d==je,c=l==d;if(c&&ct(t)){if(!ct(e))return!1;o=!0,u=!1}if(c&&!u)return s||(s=new z),o||Li(t)?di(t,e,i,r,n,s):_s(t,e,l,i,r,n,s);if(!(i&Eo)){var f=u&&Mi.call(t,"__wrapped__"),g=h&&Mi.call(e,"__wrapped__");if(f||g){var _=f?t.value():t,y=g?e.value():e;return s||(s=new z),n(_,y,i,r,s)}}return c?(s||(s=new z),bo(t,e,i,r,n,s)):!1}function yt(t,e,i,r,n){return t===e?!0:t==null||e==null||!de(t)&&!de(e)?t!==t&&e!==e:Fo(t,e,i,r,yt,n)}var Co=1,Oo=2;function $o(t,e,i,r){var n=i.length,s=n;if(t==null)return!s;for(t=Object(t);n--;){var o=i[n];if(o[2]?o[1]!==t[o[0]]:!(o[0]in t))return!1}for(;++n<s;){o=i[n];var a=o[0],l=t[a],d=o[1];if(o[2]){if(l===void 0&&!(a in t))return!1}else{var u=new z,h;if(!(h===void 0?yt(d,l,Co|Oo,r,u):h))return!1}}return!0}function xi(t){return t===t&&!ue(t)}function Ao(t){for(var e=wi(t),i=e.length;i--;){var r=e[i],n=t[r];e[i]=[r,n,xi(n)]}return e}function Ti(t,e){return function(i){return i==null?!1:i[t]===e&&(e!==void 0||t in Object(i))}}function Mo(t){var e=Ao(t);return e.length==1&&e[0][2]?Ti(e[0][0],e[0][1]):function(i){return i===t||$o(i,t,e)}}var xo=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,To=/^\w*$/;function mt(t,e){if(q(t))return!1;var i=typeof t;return i=="number"||i=="symbol"||i=="boolean"||t==null||Ie(t)?!0:To.test(t)||!xo.test(t)||e!=null&&t in Object(e)}var Ro="Expected a function";function bt(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(Ro);var i=function(){var r=arguments,n=e?e.apply(this,r):r[0],s=i.cache;if(s.has(n))return s.get(n);var o=t.apply(this,r);return i.cache=s.set(n,o)||s,o};return i.cache=new(bt.Cache||V),i}bt.Cache=V;var ko=500;function Do(t){var e=bt(t,function(r){return i.size===ko&&i.clear(),r}),i=e.cache;return e}var Ho=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,No=/\\(\\)?/g,Uo=Do(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(Ho,function(i,r,n,s){e.push(n?s.replace(No,"$1"):r||i)}),e});function jo(t,e){for(var i=-1,r=t==null?0:t.length,n=Array(r);++i<r;)n[i]=e(t[i],i,t);return n}var Ri=X?X.prototype:void 0,ki=Ri?Ri.toString:void 0;function Di(t){if(typeof t=="string")return t;if(q(t))return jo(t,Di)+"";if(Ie(t))return ki?ki.call(t):"";var e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function Hi(t){return t==null?"":Di(t)}function Ni(t,e){return q(t)?t:mt(t,e)?[t]:Uo(Hi(t))}function Ve(t){if(typeof t=="string"||Ie(t))return t;var e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function Ui(t,e){e=Ni(e,t);for(var i=0,r=e.length;t!=null&&i<r;)t=t[Ve(e[i++])];return i&&i==r?t:void 0}function Vo(t,e,i){var r=t==null?void 0:Ui(t,e);return r===void 0?i:r}function zo(t,e){return t!=null&&e in Object(t)}function qo(t,e,i){e=Ni(e,t);for(var r=-1,n=e.length,s=!1;++r<n;){var o=Ve(e[r]);if(!(s=t!=null&&i(t,o)))break;t=t[o]}return s||++r!=n?s:(n=t==null?0:t.length,!!n&&ht(n)&&bi(o,n)&&(q(t)||pi(t)))}function Go(t,e){return t!=null&&qo(t,e,zo)}var Ko=1,Wo=2;function Yo(t,e){return mt(t)&&xi(e)?Ti(Ve(t),e):function(i){var r=Vo(i,t);return r===void 0&&r===e?Go(i,t):yt(e,r,Ko|Wo)}}function Xo(t){return t}function Qo(t){return function(e){return e?.[t]}}function Zo(t){return function(e){return Ui(e,t)}}function Jo(t){return mt(t)?Qo(Ve(t)):Zo(t)}function ji(t){return typeof t=="function"?t:t==null?Xo:typeof t=="object"?q(t)?Yo(t[0],t[1]):Mo(t):Jo(t)}function ea(t,e){return t<e}function ta(t,e){return t&&t.length?Jr(t,ji(e),ea):void 0}class ia{_isMaskMode;_hiddenBuildings;_history;constructor(e){this._isMaskMode=e,this._hiddenBuildings=[],this._history=Y.getInstance()}getLayeredData(e){const{selectedVenueId:i,venueMap:r,buildingMap:n,sharedFloorMap:s}=e,o=[],a=[],l=[],d=[],u=[],h=[],c=[...r.values()],f=i?[r.get(i),...c.filter(g=>g.properties.id!==i)]:c;for(const g of f){if(!g||!g.properties)continue;const{id:_,overlap:y,building_ids:m,shared_level_ids:S,default_displayed_ordinal:E,default_displayed_building:C}=g.properties,B=_===i,b=sa(y),O=w(m),$=this._history.getHistoryOrdinal(_);let P=$??E;if(P)$||(this._history.setHistoryOrdinal(_,P),this._history.setHistoryBuildingUnit(_,{id:C,type:"building"}));else{const{ordinal:L,buildingId:H}=ra(O,n);if(!L)continue;P=L,this._history.setHistoryOrdinal(_,P),this._history.setHistoryBuildingUnit(_,{id:H,type:"building"})}O.forEach(L=>{const H=n.get(L),A=na(H,P);A?this._isMaskMode?B?(a.push(A),o.push({level:A,overlap:b.get(A)??null,venueId:_})):u.push(L):(o.push({level:A,overlap:b.get(A)??null,venueId:_}),B&&a.push(A)):d.push(L)}),w(S).forEach(L=>{const H=s.get(L),{ordinal:A,persistence:K}=H?.properties||{},ne=K==="true"&&0<=A&&A<=P,ge=A===P,Ze=ne||ge,$e={level:L,overlap:b.get(L)??null,venueId:_};Ze?this._isMaskMode?B?(o.push($e),ne&&l.push(L),ge&&a.push(L)):h.push(L):(o.push($e),B&&ge&&a.push(L),ne&&l.push(L)):d.push(L)})}return this._hiddenBuildings=d,{displayedLevels:o,selectedLevelIds:a,alwaysDisplayedSharedLevelIds:l,maskBuildingIds:u,maskSharedFloorIds:h}}getHiddenBuildings(){return this._hiddenBuildings}}function ra(t,e){const i=t.find(s=>e.has(s))??t[0]??null,r=i?e.get(i):null;return{ordinal:r?Vi(r):null,buildingId:i}}function Vi(t){if(!t||!t.properties)return null;const{level_ids:e,ordinals:i,default_displayed_floor:r}=t.properties,n=w(i);let s=null;if(r){const o=w(e).findIndex(a=>a===r);s=n[o]??null}return s||(s=ta(n,o=>Math.abs(Number(o)-.1))),s}function na(t,e){if(!t||!t.properties)return null;const{level_ids:i,ordinals:r}=t.properties,n=w(r).findIndex(s=>s===e);return w(i)[n]??null}function sa(t){const e=new Map;if(!t)return e;for(const i of w(t,"/")){const[r,n]=w(i,":");e.set(r,w(n))}return e}class oa{_maplibre;_isAnimated=!0;_bounds=null;_boundsPadding;_center=null;_fitBoundsTimer=null;constructor(e,i){this._maplibre=e,this._boundsPadding=i}setAnimated(e){this._isAnimated=e}setBounds(e){this._bounds=e}getBounds(){return this._bounds}setCenter(e){this._center=e}async fitBounds(){if(!this._bounds)return;this._fitBoundsTimer&&(clearTimeout(this._fitBoundsTimer),this._fitBoundsTimer=null);const e=this._isAnimated?{animate:!0,duration:500}:{animate:!1},i=this._isAnimated?500:0;return new Promise(r=>{const n=()=>{this._maplibre.off("idle",n),r(!0)};this._maplibre.on("idle",n),this._maplibre.fitBounds(this._bounds,{...e,padding:this._boundsPadding,bearing:this._maplibre.getBearing()}),this._fitBoundsTimer=setTimeout(()=>{this._maplibre.off("idle",n),this._fitBoundsTimer=null,r(!0)},i+200)})}panToCenter(){this._center&&this._maplibre.panTo(this._center,{animate:this._isAnimated})}}var St=function(){return U.Date.now()},aa=/\s/;function la(t){for(var e=t.length;e--&&aa.test(t.charAt(e)););return e}var da=/^\s+/;function ua(t){return t&&t.slice(0,la(t)+1).replace(da,"")}var zi=NaN,ca=/^[-+]0x[0-9a-f]+$/i,ha=/^0b[01]+$/i,_a=/^0o[0-7]+$/i,fa=parseInt;function ze(t){if(typeof t=="number")return t;if(Ie(t))return zi;if(ue(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=ue(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=ua(t);var i=ha.test(t);return i||_a.test(t)?fa(t.slice(2),i?2:8):ca.test(t)?zi:+t}var pa="Expected a function",ga=Math.max,ya=Math.min;function vt(t,e,i){var r,n,s,o,a,l,d=0,u=!1,h=!1,c=!0;if(typeof t!="function")throw new TypeError(pa);e=ze(e)||0,ue(i)&&(u=!!i.leading,h="maxWait"in i,s=h?ga(ze(i.maxWait)||0,e):s,c="trailing"in i?!!i.trailing:c);function f(b){var O=r,$=n;return r=n=void 0,d=b,o=t.apply($,O),o}function g(b){return d=b,a=setTimeout(m,e),u?f(b):o}function _(b){var O=b-l,$=b-d,P=e-O;return h?ya(P,s-$):P}function y(b){var O=b-l,$=b-d;return l===void 0||O>=e||O<0||h&&$>=s}function m(){var b=St();if(y(b))return S(b);a=setTimeout(m,_(b))}function S(b){return a=void 0,c&&r?f(b):(r=n=void 0,o)}function E(){a!==void 0&&clearTimeout(a),d=0,r=l=n=a=void 0}function C(){return a===void 0?o:S(St())}function B(){var b=St(),O=y(b);if(r=arguments,n=this,l=b,O){if(a===void 0)return g(l);if(h)return clearTimeout(a),a=setTimeout(m,e),f(l)}return a===void 0&&(a=setTimeout(m,e)),o}return B.cancel=E,B.flush=C,B}function ma(t,e,i,r){for(var n=t.length,s=i+-1;++s<n;)if(e(t[s],s,t))return s;return-1}function ba(t){return t!==t}function Sa(t,e,i){for(var r=i-1,n=t.length;++r<n;)if(t[r]===e)return r;return-1}function va(t,e,i){return e===e?Sa(t,e,i):ma(t,ba,i)}function Ia(t,e){var i=t==null?0:t.length;return!!i&&va(t,e,0)>-1}function La(){}var wa=1/0,Ba=he&&1/dt(new he([,-0]))[1]==wa?function(t){return new he(t)}:La,Ea=200;function Pa(t,e,i){var r=-1,n=Ia,s=t.length,o=!0,a=[],l=a;if(s>=Ea){var d=e?null:Ba(t);if(d)return dt(d);o=!1,n=li,l=new Be}else l=e?[]:a;e:for(;++r<s;){var u=t[r],h=e?e(u):u;if(u=u!==0?u:0,o&&h===h){for(var c=l.length;c--;)if(l[c]===h)continue e;e&&l.push(h),a.push(u)}else n(l,h,i)||(l!==a&&l.push(h),a.push(u))}return a}function qi(t,e){return t&&t.length?Pa(t,ji(e)):[]}var Fa=0;function te(t){var e=++Fa;return Hi(t)+e}const Pe="Indoor_selectedFloorChanged",qe="Indoor_selectedBuildingChanged",It="Indoor_mapxusMapLoaded",Gi="Indoor_maplibreMapLoaded",Ge="mapxus-venue-fill",ie="mapxus-building-line",Ki="mapxus-level-fill",Lt="mapxus-shared-level-fill",wt="highlight-mapxus_level",Bt="highlight-mapxus_shared_level";class Wi extends Ir.TinyEmitter{_map;_features=[];_allVenuesMap=new Map;_allBuildingsMap=new Map;_allSharedLevelsMap=new Map;_curBuildingId=null;_curBuildingFeature=null;_curSharedLevelId=null;_floor={code:null,id:null,ordinal:null};_sharedFloor={id:null,ordinal:null,name:null};_outdoorMapShown;_originIndoorLayers=[];_outdoorLayers=[];_curVenueId=null;_curVenueFeature=null;_selectedHighlightStyle;_upperLayers=[];_commonPoiLayers=[];_sectionFillLineLayers=[];_sectionSymbolLayers=[];_middleLayers=[];_lowerLayers=[];_excludedPoisInMiddle=[];_dispatch=ye(Pe);_startWithIndoorView;_indoorMapLoaded=!1;_isSelectSharedFloor=!1;_isMaskMode;_upperLevels=new Set;_middleLevels=new Set;_lowerLevels=new Set;_featureIncomplete=!1;_fitBounds;_dragPan;_history=Y.getInstance();_maskBuildings=new Set;_maskSharedFloors=new Set;_enableIndoorClickSelection;_enableOutdoorClickSelection;_zIndexHistory=new Map;_floorSwitchScope;_isDestroyed=!1;_abortQueryFeature;_debounceRendering;layeredHandler;dragPanHandler;constructor(e){super();const{map:i,startWithIndoorView:r,outdoorMapShown:n,selectedHighlightStyle:s,fitBounds:o,boundsPadding:a,maskNonSelectedAreas:l,enableIndoorClickSelection:d,enableOutdoorClickSelection:u,floorSwitchScope:h}=e;this.layeredHandler=new ia(l),this.dragPanHandler=new oa(i,a),this._map=i,this._enableIndoorClickSelection=d,this._enableOutdoorClickSelection=u,this._startWithIndoorView=r,this._outdoorMapShown=n,this._isMaskMode=l,this._fitBounds=o,this._floorSwitchScope=h,this._selectedHighlightStyle=s?Object.assign({},Re,s):Re,this._bindMaplibreEventListeners()}destroy(){this._isDestroyed||(this._isDestroyed=!0,this._dispatch.on(`.${Pe}`,null),this.off(qe),this.off(Gi),this.off(It),this._debounceRendering?.cancel(),this._abortQueryFeature&&(this._abortQueryFeature(),this._abortQueryFeature=null))}setAllowOutdoorSwitch(e){return this._enableOutdoorClickSelection=e,this}setAllowBuildingSwitch(e){return this._enableIndoorClickSelection=e,this}setAllowIndoorClickSelect(e){this._enableIndoorClickSelection=e}setAllowOutdoorClickSelect(e){this._enableOutdoorClickSelection=e}setFloorSwitchScope(e){this._floorSwitchScope=e}get floor(){return this._isSelectSharedFloor?this._sharedFloor:this._curBuildingId?this._floor:null}get building(){return this._curBuildingFeature}get venue(){return this._curVenueFeature}get features(){return this._features}getFeaturesById(e,i){const{layerIds:r,filter:n}=i||{},s=this._queryRenderedFeatures(r);if(!s.length)return[];const o=n?a=>a.properties.id===e&&n(a):a=>a.properties.id===e;return s.filter(o)}async switchFloorByOrdinal(e){this._updateFloorState(e),this._dispatch.call(Pe,null,{venue:this.venue,building:this.building,floor:this.floor}),this.venue&&e&&(this._floorSwitchScope===xe.GLOBAL&&this._changeOtherVenuesHistory(e),this._dragPan===!0&&(this._fitBounds?await this.dragPanHandler.fitBounds():await this.panToBuildingCenter()),this._dragPan==="restrict"&&await this._checkAndPanToBuilding()),this.updateRendering()}setOutdoorMapShown(e){this._outdoorMapShown=e,this._setOutdoorVisibility(e)}setSelectedHighlightStyle(e){this._selectedHighlightStyle=Object.assign({},this._selectedHighlightStyle,e??{"line-opacity":0});for(const i of[wt,Bt])if(this._map.getLayer(i))if(e){const{lineColor:r,lineOpacity:n,lineWidth:s,lineOffset:o}=this._selectedHighlightStyle,a=Yi(s,o);this._map.setPaintProperty(i,"line-color",r),this._map.setPaintProperty(i,"line-opacity",n),this._map.setPaintProperty(i,"line-width",s),this._map.setPaintProperty(i,"line-offset",a)}else this._map.setPaintProperty(i,"line-opacity",0)}onMapChange(e){const i=te(`${Pe}.`);return this._dispatch.on(i,e),{unsubscribe:()=>this._dispatch.on(i,null)}}async selectBuilding(e,i){if(this._isCurrentFeature(e))return;this._isSelectSharedFloor=!1,this._curSharedLevelId=null;let r=null;if(!e||!e.properties)this.dragPanHandler.setCenter(null),this._clear();else{const{floorId:n,featureIncomplete:s}=i||{};this._featureIncomplete=s??this._featureIncomplete;const{id:o,"ref:venue":a,label_center:l}=e.properties,d=w(l).map(u=>parseFloat(u));this._curBuildingFeature=e,this._curBuildingId=o,this._history.addVisitedBuildingUnit({id:o,type:"building"}),this.dragPanHandler.setCenter(d),this._curVenueId!==a&&(this._curVenueId=a,this._curVenueFeature=await this._queryVenueFeature(a)),r=this._getBuildingDisplayedOrdinal(e,n)}await this.switchFloorByOrdinal(r),this.emit(qe,e?{building:e,ordinal:r,dragPan:this._dragPan}:null),this._dispatchIndoorMapLoaded()}async selectSharedFloor(e,i,r){if(e.id===this._curSharedLevelId)return;const{id:n,ordinal:s}=e;this._isSelectSharedFloor=!0,this._curBuildingId=null,this._curBuildingFeature=null,this._sharedFloor=e,this._curSharedLevelId=n,this._featureIncomplete=r?.featureIncomplete??this._featureIncomplete;const{label_center:o,id:a}=i.properties,l=w(o).map(d=>parseFloat(d));this._curVenueId=a,this._curVenueFeature=i,this.dragPanHandler.setCenter(l),this._history.addVisitedBuildingUnit({id:n,type:"sharedFloor"}),this._history.setHistoryOrdinal(a,s),this._history.setHistoryBuildingUnit(a,{id:n,type:"sharedFloor"}),this._dragPan===!0&&(this._fitBounds?await this.dragPanHandler.fitBounds():await this.panToVenueCenter()),this._dispatch.call(Pe,null,{venue:this.venue,building:this.building,floor:this.floor}),this.emit(qe,{...e,dragPan:this._dragPan}),this._dispatchIndoorMapLoaded(),this.updateRendering()}updateCustomLayers(){const e=this._map.getStyle();this._originIndoorLayers=it(e),this._outdoorLayers=Lr(e),this._copyOverlapLayers(),this._copySharedFloorBackgroundLayers(),this._addSelectedHighlightLayers(),this._addReserveFloorLayers(),this._isMaskMode&&this._addBuildingMaskLayer(),this._outdoorMapShown||this._setOutdoorVisibility(!1)}updateRendering(){this._updateFeatures(),this._updateSelectedFeatures(),this._layerFloors(),this._calExcludedPoisInMiddle(),this._filterLayers(),this._filterSelectedHighlight(),this._updateUnselectedMask()}async panToBuildingCenter(){if(this.dragPanHandler.panToCenter(),this._featureIncomplete){const e=()=>this.getFeaturesById(this._curBuildingId,{layerIds:[ie]})[0];await this._waitForFeatureLoaded(e)}}async panToVenueCenter(){if(this.dragPanHandler.panToCenter(),this._featureIncomplete){const e=()=>this.getFeaturesById(this._curVenueId,{layerIds:[Ge]})[0];await this._waitForFeatureLoaded(e)}}async _waitForFeatureLoaded(e){const i=()=>this._isDestroyed?(this._abortQueryFeature?.(),!0):!!e(),{promise:r,abort:n}=kr(i);this._abortQueryFeature=n;try{await Promise.race([r,new Promise((s,o)=>{this._abortQueryFeature=()=>{o(new Error("Aborted")),this._abortQueryFeature=null}})])}catch(s){console.warn(s);return}}setDragPan(e){this._dragPan=e}setFitBounds(e){this._fitBounds=e}async queryIndoorFeaturesByClickPoint(e){const i=this._queryVisibleFeature(e);if(!i)return null;const r=async s=>{let o=this.getFeaturesById(s,{layerIds:[Ge]})[0];if(!o){const a=await He(s);o=Te(a),this._featureIncomplete=!0}return o??null},n=async s=>{let o=this.getFeaturesById(s,{layerIds:[ie]})[0];if(!o){const a=await De(s);o=nt(a),this._featureIncomplete=!0}return o??null};if(Ke(i.sourceLayer,i.layer.type)){const{id:s,"ref:building":o,name:a,ordinal:l}=i.properties,d=await n(o);if(d){const u=d.properties["ref:venue"];return{venue:await r(u),building:d,floor:{id:s,code:a,ordinal:l}}}}else if(Qi(i.sourceLayer,i.layer.type)){const{id:s,ordinal:o,name:a,"ref:venue":l}=i.properties;return{sharedFloor:{id:s,ordinal:o,name:typeof a=="string"?{default:a}:a},venue:await r(l)}}else{const s=i?.properties?.["ref:venue"];return i?{building:i,venue:await r(s)}:null}}async selectByClickMap(e){!this._enableIndoorClickSelection&&!this._enableOutdoorClickSelection||(this.setDragPan(!1),this.dragPanHandler.setBounds(null),this._featureIncomplete=!1,e?this._enableIndoorClickSelection&&("building"in e?await this.selectBuilding(e.building,{floorId:e?.floor?.id}):"sharedFloor"in e&&await this.selectSharedFloor(e.sharedFloor,e.venue)):this._enableOutdoorClickSelection&&await this.selectBuilding(null))}_bindMaplibreEventListeners(){this._map.once("styledata",()=>this.updateCustomLayers()),this._map.once("idle",()=>{this.emit(Gi),(!this._startWithIndoorView||this._map.getZoom()<14)&&this._dispatchIndoorMapLoaded()}),this._map.on("sourcedata",this._debounceRendering=vt(()=>this.updateRendering(),300))}_clear(){this._curBuildingFeature=null,this._curBuildingId=null,this._floor={code:null,id:null,ordinal:null},this._curVenueId=null,this._curVenueFeature=null,this._curSharedLevelId=null}_getIndoorFeatures(){return this._queryRenderedFeatures().filter(e=>rt(e.source))}_getBuildingFloorByOrdinal(e,i){let r=null,n=null;if(e?.properties){const{ordinals:s,level_names:o,level_ids:a}=e.properties,l=w(s).findIndex(d=>d===i);r=w(o)[l]??null,n=w(a)[l]??null}return{code:r,id:n,ordinal:i}}_isCurrentFeature(e){const i=e?.properties?.id??null,r=this._isSelectSharedFloor?this._curSharedLevelId:this._curBuildingId;return i===r}_setOutdoorVisibility(e){for(const{id:i}of this._outdoorLayers)this._map.getLayer(i)&&this._map.setLayoutProperty(i,"visibility",e?"visible":"none")}_addReserveFloorLayers(){for(const e of[me,x]){if(this._map.getLayer(e))continue;const i=e.split("_")[1],r=this._map.getLayer(i);if(!r)continue;const{source:n,sourceLayer:s}=r,o=e===me?this._middleLayers[0]:this._lowerLayers[0];let a={"fill-opacity":0};if(this._isMaskMode&&e===x){const l=this._originIndoorLayers.find(({id:d})=>d===ie);l&&(a=Object.assign({},l.paint??{},a))}this._map.addLayer({id:e,source:n,"source-layer":s,type:"fill",paint:a},o.id)}}_addBuildingMaskLayer(){if(this._map.getLayer(be))return;const e=this._originIndoorLayers.find(({id:i})=>i===ie);if(e){const i=Object.assign({},e,{id:be,layout:Object.assign({},e.layout??{},{visibility:"visible"}),paint:Object.assign({},e.paint??{},{"fill-opacity":0})});this._map.addLayer(i,ie)}}_updateUnselectedMask(){if(!this._isMaskMode)return;const e=[...this._maskBuildings],i=[...this._maskSharedFloors];this._map.getLayer(be)&&this._map.setPaintProperty(be,"fill-opacity",["case",["in",["get","id"],["literal",e]],1,0]),this._map.getLayer(x)&&this._map.setPaintProperty(x,"fill-opacity",["case",["in",["get","id"],["literal",i]],1,0])}_addSelectedHighlightLayers(){const e=[{layerId:wt,sourceLayer:"mapxus_level"},{layerId:Bt,sourceLayer:"mapxus_shared_level"}];let i=this._originIndoorLayers.find(({type:r})=>Pt(r));if(!i){const r=this._originIndoorLayers.findIndex(({id:n})=>n===this._upperLayers[this._upperLayers.length-1].id);i=this._originIndoorLayers[r+1]}for(const{layerId:r,sourceLayer:n}of e){if(this._map.getLayer(r))continue;const{lineWidth:s,lineOpacity:o,lineColor:a,lineOffset:l}=this._selectedHighlightStyle,d=Yi(s,l);this._map.addLayer({id:r,source:"indoor-planet","source-layer":n,type:"line",filter:["==","id",""],paint:{"line-offset":d,"line-width":s,"line-color":a,"line-opacity":o}},i?.id)}}_filterSelectedHighlight(){for(const e of[wt,Bt])this._map.getLayer(e)&&this._map.setFilter(e,["==","id",this._isSelectSharedFloor?this._curSharedLevelId:this._floor.id??""])}_copyOverlapLayers(){const e=this._originIndoorLayers.findIndex(({type:a,"source-layer":l})=>Xi(l,a)),i=this._originIndoorLayers.findIndex(({type:a,"source-layer":l})=>Et(l,a)),r=this._originIndoorLayers.slice(e,i);this._upperLayers=r.filter(({type:a})=>Oa(a));const n=this._originIndoorLayers.slice(i),s=n.findIndex(({type:a,"source-layer":l})=>!Et(l,a));if(s>-1){this._commonPoiLayers=n.slice(0,s);const a=n.slice(s).filter(({"source-layer":l})=>l==="mapxus_section");this._sectionFillLineLayers=a.filter(({type:l})=>l!=="symbol"),this._sectionSymbolLayers=a.filter(({type:l})=>l==="symbol")}else this._commonPoiLayers=[...n],this._sectionSymbolLayers=r.filter(({type:a,"source-layer":l})=>l==="mapxus_section"&&a==="symbol");const o=this._upperLayers[0];this._middleLayers=this._upperLayers.filter(({type:a})=>!Pt(a)).map(a=>{const l=`${a.id}-overlap-copy`;let d=this._map.getLayer(l);return d||(d=Object.assign({},a,{id:l}),this._map.addLayer(d,o.id)),d})}_copySharedFloorBackgroundLayers(){if(!!!this._upperLayers.find(n=>n.id===x.split("_")[1]))return;const i=this._upperLayers.filter(({"source-layer":n,type:s})=>!Ke(n,s)&&!Pt(s)),r=this._middleLayers[0]||this._upperLayers[0];this._lowerLayers=[...i,...this._commonPoiLayers].map(n=>{const s=`${n.id}-shared-bg`;let o=this._map.getLayer(s);return o||(o=Object.assign({},n,{id:s}),this._map.addLayer(o,r.id)),o})}_updateFeatures(){this._features=this._getIndoorFeatures();const e=qi(this._features,s=>s.layer.id+":"+s.properties.id),i=[],r=[],n=[];for(const s of e){const o=s.layer.id;o===Ge?i.push(s):o===ie?r.push(s):o===x&&n.push(s)}this._allVenuesMap=new Map(i.map(s=>[s.properties.id,s])),this._allBuildingsMap=new Map(r.map(s=>[s.properties.id,s])),this._allSharedLevelsMap=new Map(n.map(s=>[s.properties.id,s]))}_calExcludedPoisInMiddle(){const e=this._map.querySourceFeatures("indoor-planet",{sourceLayer:"mapxus_place"}),i=n=>n?w(n).some(o=>this._upperLevels.has(o)):!1,r=e.filter(n=>{const s=n.properties["ref:level"]||n.properties["ref:shared_level"];return this._middleLevels.has(s)?i(n.properties.overlap):!1});this._excludedPoisInMiddle=r.map(n=>n.properties["osm:ref"])}_updateSelectedFeatures(){if(this._featureIncomplete){if(this._isSelectSharedFloor){const e=this._features.find(i=>i.properties.id===this._curVenueId);if(!e)return;this._curVenueFeature=e}else{const e=this._allBuildingsMap.get(this._curBuildingId);if(!e)return;this._curBuildingFeature=e}this._featureIncomplete=!1}}_layerFloors(){const{displayedLevels:e,selectedLevelIds:i,alwaysDisplayedSharedLevelIds:r,maskBuildingIds:n,maskSharedFloorIds:s}=this.layeredHandler.getLayeredData({selectedVenueId:this._curVenueId,venueMap:this._allVenuesMap,buildingMap:this._allBuildingsMap,sharedFloorMap:this._allSharedLevelsMap});this._upperLevels.clear(),this._middleLevels.clear(),this._lowerLevels.clear(),this._layerSelectedLevels(e,i),this._layerUnselectedLevels(e,i,r),this._isMaskMode&&(this._maskBuildings.clear(),this._maskSharedFloors.clear(),n.forEach(o=>{this._maskBuildings.add(o)}),s.forEach(o=>{this._maskSharedFloors.add(o)}))}_layerSelectedLevels(e,i){for(const r of i){this._upperLevels.add(r),this._zIndexHistory.set(r,!0);const n=e.find(({level:s,overlap:o})=>s===r&&!!o);if(n)for(const s of n.overlap)this._zIndexHistory.get(s)&&this._zIndexHistory.delete(s)}}_layerUnselectedLevels(e,i,r){for(const n of e){if(i.includes(n.level))continue;const{level:s,overlap:o,venueId:a}=n,l=this._zIndexHistory.get(s),d=!o||!o.some(h=>this._upperLevels.has(h)),u=r.includes(s);if(a===this._curVenueId&&u){this._lowerLevels.add(s),this._zIndexHistory.delete(s);continue}l?this._upperLevels.add(s):l===!1?this._middleLevels.add(s):u?this._lowerLevels.add(s):d?(this._upperLevels.add(s),this._zIndexHistory.set(s,!0)):(this._middleLevels.add(s),this._zIndexHistory.set(s,!1))}}_filterLayers(){this._filterIndoorLayers([...this._upperLevels,...this._middleLevels],this._commonPoiLayers),this._filterIndoorLayers([...this._upperLevels],this._upperLayers),this._filterIndoorLayers([...this._middleLevels],this._middleLayers),this._filterIndoorLayers([...this._lowerLevels],this._lowerLayers),this._sectionSymbolLayers.length!==0&&(this._sectionFillLineLayers.length?(this._filterIndoorLayers([...this._upperLevels],this._sectionFillLineLayers),this._filterIndoorLayers([...this._upperLevels],this._sectionSymbolLayers)):this._filterIndoorLayers([...this._upperLevels,...this._middleLevels,...this._lowerLevels],this._sectionSymbolLayers))}_filterIndoorLayers(e,i){let r;for(const n of i){const{id:s,filter:o,type:a,"source-layer":l}=n,d=o?[o]:[],u=s.includes("-shared-bg"),h=[...this._maskBuildings],c=[...this._maskSharedFloors];Xi(l,a)?r=["all",Ke(l,a)?["!in","ref:building",...h]:["!in","id",...c],["in","id",...e],...d]:u?r=["all",["!in","ref:shared_level",...c],["in","ref:shared_level",...e],...d]:(r=["all",["any",["all",["!in","ref:building",...h],["in","ref:level",...e]],["all",["!in","ref:shared_level",...c],["in","ref:shared_level",...e]]],...d],Et(l,a)&&r.splice(1,0,["any",["!has","overlap"],["any",["in","ref:level",...this._upperLevels],["in","ref:shared_level",...this._upperLevels],["!in","osm:ref",...this._excludedPoisInMiddle]]])),this._map.setFilter(s,r)}}async _queryVenueFeature(e){let i=this.getFeaturesById(e,{layerIds:[Ge]})[0]??null;if(!i)try{const r=await He(e);i=Te(r)}catch(r){console.error(r)}return i}_getBuildingDisplayedOrdinal(e,i){if(!e||!e.properties)return null;const{"ref:venue":r,level_ids:n,ordinals:s}=e.properties,o=w(n),a=w(s);if(i){const d=o.findIndex(u=>u===i);return a[d]??null}const l=this._history.getHistoryOrdinal(r);return l&&a.includes(l)?l:Vi(e)}_updateFloorState(e){if(!e){this._floor={code:null,id:null,ordinal:null};return}const{code:i,id:r}=this._getBuildingFloorByOrdinal(this._curBuildingFeature,e);(!i||!r)&&console.error(`Floor with ordinal "${e}" not found in building "${this._curBuildingId}".`),this._floor={code:i,id:r,ordinal:e},this._history.setHistoryOrdinal(this._curVenueId,e),this._history.setHistoryBuildingUnit(this._curVenueId,{id:this._curBuildingId,type:"building"})}async _checkAndPanToBuilding(){this.getFeaturesById(this._curBuildingId,{layerIds:[ie]})[0]||(this._fitBounds?this.dragPanHandler.fitBounds():this.dragPanHandler.panToCenter())}_queryVisibleFeature(e){const r=[Ki,Lt,`${Ki}-overlap-copy`,`${Lt}-overlap-copy`,`${Lt}-shared-bg`,...this._isMaskMode?[x,be]:[]].filter(o=>!!this._map.getLayer(o)),n=this._map.queryRenderedFeatures(e,{layers:r});let s=null;for(const o of r){const a=n.find(l=>l.layer.id===o);if(a){s=a;break}}return s&&Ca(s.sourceLayer,s.layer.type)&&(this._maskBuildings.has(s.properties?.id)||(s=null)),s}_queryRenderedFeatures(e){const i=(e||[]).filter(s=>this._map.getLayer(s));if(e&&e.length>0&&i.length===0)return[];const r=i.length?{layers:i}:{},n=this._map.getCanvas().getBoundingClientRect();return this._map.queryRenderedFeatures([[0,0],[n.width,n.height]],r)}_dispatchIndoorMapLoaded(){this._indoorMapLoaded||(this._indoorMapLoaded=!0,this.emit(It))}_changeOtherVenuesHistory(e){const i=[...this._allVenuesMap.values()];for(const r of i){const n=r.properties.id;n!==this._curVenueId&&this._history.setHistoryOrdinal(n,e)}}}function Yi(t,e){const i=typeof t=="number"&&t===Re.lineWidth,r=typeof e=="number"&&e===Re.lineOffset;if(!r)return e;if(i&&r)return["interpolate",["linear"],["zoom"],18,-1.5,20.2,-3.75,20.4,-3.8,21.5,-7.5,22,-9.55];if(!i&&r)return typeof t=="number"?-(t/2):e}function Ca(t,e){return t==="mapxus_building"&&(e==="fill"||e==="line"||e==="symbol")}function Xi(t,e){return Ke(t,e)||Qi(t,e)}function Ke(t,e){return t==="mapxus_level"&&(e==="fill"||e==="line")}function Qi(t,e){return t==="mapxus_shared_level"&&(e==="fill"||e==="line")}function Et(t,e){return t==="mapxus_place"&&e==="symbol"}function Pt(t){return t==="fill-extrusion"}function Oa(t){return t==="line"||t==="fill"||t==="fill-extrusion"}const We="Poi_poiClick";class Zi{_map;_currentStyle=null;_styleLayersLength=0;_layerIds=[];_dispatch=ye(We);_listeners=[];constructor(e){this._map=e,this._bindPoiClickEvent()}destroy(){this._dispatch.on(`.${We}`,null),this._currentStyle=null,this._map=null,this._dispatch=null,this._listeners=[],this._layerIds=[]}onPoiClick(e){const i=te(`${We}.`);return this._dispatch.on(i,e),this._listeners.push(i),{unsubscribe:()=>this._dispatch.on(i,null)}}_queryPoiLayers(){const e=this._map.getStyle();if(e.name===this._currentStyle&&e.layers.length===this._styleLayersLength)return;const i=it(e).filter(r=>r["source-layer"]==="mapxus_place"&&r.type==="symbol");this._layerIds=i.map(({id:r})=>r),this._currentStyle=e.name,this._styleLayersLength=e.layers.length}_bindPoiClickEvent(){this._map.on("click",e=>{if(this._listeners.length===0)return;this._queryPoiLayers();const i=this._map.queryRenderedFeatures(e.point,{layers:this._layerIds});if(i.length===0)return;const r=i[0],n=w(r.properties["ref:sections"]),s=!!r.properties["ref:shared_level"],o={coordinate:e.lngLat,poi:r};if(n.length>0){const a=this._map.querySourceFeatures("indoor-planet",{sourceLayer:"mapxus_section"});o.sections=n.map(l=>{const d=a.find(g=>g.properties.id===l),{id:u,section:h="",correlation_id:c}=d?.properties||{},f=Ji(d?.properties);return{id:u,category:h,sectionName:f,...c&&{correlationId:c}}})}if(s){const a=r.properties["ref:shared_level"],{floor:l,venue:d}=this._queryIndoorFeaturesBySharedFloor(a);o.floor=l,o.venue=d}else{const a=r.properties["ref:level"],{floor:l,building:d,venue:u}=this._queryIndoorFeaturesByFloor(a);o.floor=l,o.building=d,o.venue=u}this._dispatch.call(We,null,o)})}_queryIndoorFeaturesBySharedFloor(e){const i=this._map.queryRenderedFeatures({layers:[x,"mapxus-venue-fill"]}),r=i.find(d=>d.sourceLayer==="mapxus_shared_level"&&d.properties.id===e);if(!r)return{floor:null,venue:null};const n=r.properties["ref:venue"],s=i.find(d=>d.layer.id==="mapxus-venue-fill"&&d.properties.id===n)??null,{id:o,ordinal:a}=r.properties,l=Ji(r.properties);return{floor:{id:o,ordinal:a,name:l},venue:s}}_queryIndoorFeaturesByFloor(e){const i=this._map.queryRenderedFeatures({layers:[me,"mapxus-building-line","mapxus-venue-fill"]}),r=i.find(u=>u.sourceLayer==="mapxus_level"&&u.properties.id===e);if(!r)return{floor:null,building:null,venue:null};const{id:n,ordinal:s,name:o,"ref:building":a}=r.properties||{},l=i.find(u=>u.layer.id==="mapxus-building-line"&&u.properties.id===a)??null,d=i.find(u=>u.layer.id==="mapxus-venue-fill"&&u.properties.id===l?.properties?.["ref:venue"])??null;return{floor:{id:n,ordinal:s,code:o},building:l,venue:d}}}function Ji(t){return t?Object.keys(t).filter(i=>i.includes("name")).reduce((i,r)=>{const[,n]=w(r,":");return n?i[n]=t[r]:i.default=t[r],i},{}):{default:""}}function Fe(t){t.parentNode&&t.parentNode.removeChild(t)}function F(t,e,i){const r=document.createElement(t);return e&&(r.className=e),i&&i.appendChild(r),r}class er{_map;_maplibre;_buildingId;_features;_$container;_$listContainer;_$buildingList;_listHeight;_language;_visible;_position="top-right";_isMobileMode;_isListShown=!1;constructor(e,i){this._map=e,this._language=e.getLanguage(),this._visible=i??!0,this._detectDeviceMode()}onAdd(e){return this._maplibre=e,this._$container=F("div",`maplibregl-ctrl maplibregl-ctrl-building-filter ${this._visible?"":"hide"}`,this._maplibre.getContainer()),this._$container.appendChild(this._buildingFilterIconCreate("div")),this._$container.appendChild(this._buildingNameListCreate("div")),this._bindEvents(),this._$container}onRemove(){Fe(this._$container)}get position(){return this._position}get enabled(){return this._visible}getDefaultPosition(){return"top-right"}setVisibility(e){this._visible=e,e?this._$showLayout():this._$hideLayout()}changePosition(e,i,r){const n=document.querySelector(`.maplibregl-ctrl-${e}`),s=n.querySelector(".maplibregl-ctrl-building-filter");if(e!==i){this._position=i;const o=document.querySelector(`.maplibregl-ctrl-${i}`);s&&(n.removeChild(s),Number.isFinite(r)?o.insertBefore(s,o.children[r]):o.append(s),this._updateBuildingListLayout(i))}else Number.isFinite(r)&&n.children[r]!==s&&(n.removeChild(s),n.insertBefore(s,n.children[r]))}_bindEvents(){this._maplibre.on("moveend",()=>this._refresh()),this._map.onMapChangeListener(e=>{const i=e.building?.properties?.id??"";this._buildingId!==i&&(this._buildingId=i,this._refresh())}),this._map.renderComplete(()=>this._init())}_init(){this._load()}_refresh(){this._load()}_load(){this._buildingNameListClean(),this._buildingNameListUpdate()}_buildingFilterIconCreate(e){const i=F(e,"mapxus-building-filter-icon");return this._bindMouseOnEvents(i,!1),this._bindMobileTouchEvents(i),i}_buildingNameListCreate(e){return this._$listContainer=F(e,"mapxus-building-name-layout"),this._$listContainer.style.display="none",this._$listContainer.style.top="20px",this._$buildingList=F(e,"mapxus-building-name-list",this._$listContainer),this._bindMouseOnEvents(this._$listContainer,!0),this._$listContainer}_buildingNameListUpdate(){this._features=[];const e=this._map.getMaplibre(),i=e?e.queryRenderedFeatures({layers:["mapxus-building-line"]}):[];for(const r of i){const{properties:n}=r,{id:s,name:o}=n,a=n?.[`name:${this._language}`]??o;this._features.find(l=>l.properties.id===s)||(this._features.push(r),this._$buildingList.appendChild(this._buildingNameCreate("p",a,s,s===this._map.building?.properties?.id)))}this._setBuildingListHeight(this._features),this._updateBuildingListLayout(this._position)}_buildingNameListClean(){this._$buildingList.replaceChildren()}_setBuildingListHeight(e){const n=e.map(s=>{const o=s?.properties?.[`name:${this._language}`]??s?.properties?.name;return o?Math.ceil(o.length*8/107):0}).reduce((s,o)=>s+o,0);this._listHeight=n*26+e.length*8,this._$buildingList.style.height=this._$listContainer.style.height=`${this._listHeight>=208?208:this._listHeight}px`}_buildingNameCreate(e,i,r,n){const s=F(e,`mapxus-building-name${n?" active":""}`);return s.dataset.id=r,s.innerText=i,this._buildingNameClickEvent(s),s}_toggleList(e){this._isListShown=e,this._$listContainer.style.display=e?"block":"none"}_buildingNameClickEvent(e){e.onclick||(e.onclick=async i=>{const r=i.target;await this._map.selectBuildingById(r.dataset.id)})}_bindMouseOnEvents(e,i){e.onmouseenter=()=>{this._isMobileMode||this._toggleList(!0)},i&&(e.onmouseleave=()=>this._toggleList(!1))}_bindMobileTouchEvents(e){window.addEventListener("resize",()=>this._detectDeviceMode()),e.ontouchend=()=>this._toggleList(!this._isListShown)}_$showLayout(){this._$container.classList.remove("hide")}_$hideLayout(){this._$container.classList.add("hide")}_updateBuildingListLayout(e){e.indexOf("left")>-1?(this._$listContainer.style.right=null,this._$listContainer.style.left="55px"):(this._$listContainer.style.left=null,this._$listContainer.style.right="55px");const i=this._$container.offsetParent?this._$container.offsetParent.clientHeight-(this._$container.offsetTop+this._$container.clientHeight)-25:0;e.includes("bottom")&&this._listHeight-20>i?(this._$listContainer.style.top=null,this._$listContainer.style.bottom="15px"):(this._$listContainer.style.bottom=null,this._$listContainer.style.top="20px")}_detectDeviceMode(){this._isMobileMode=window.matchMedia("(pointer: coarse) and (max-width: 768px)").matches}}var $a=Math.max,Aa=Math.min;function Ma(t,e,i){return t>=Aa(e,i)&&t<$a(e,i)}var tr=1/0,xa=17976931348623157e292;function ir(t){if(!t)return t===0?t:0;if(t=ze(t),t===tr||t===-tr){var e=t<0?-1:1;return e*xa}return t===t?t:0}function rr(t,e,i){return e=ir(e),i===void 0?(i=e,e=0):i=ir(i),t=ze(t),Ma(t,e,i)}class nr{_container;_indoor;_maplibre;_position="top-right";_buildingId;_floorNames;_ordinals;_ordinal;_style;_$innerFloors;_$activeFloor;_centerSelectorIdx;_lastNormalScrollableIdx;_$arrowBtnUp;_$arrowBtnDown;_maxScrollTop;_$selectorExpanded;_$selectorFolded;_componentDidMount=!1;_visible=!1;_isEnabled;_dragPan;_language;_debounceScroll;_clearScrollEventListener;constructor(e,i){const{style:r,enabled:n=!0,language:s}=i;this._indoor=e,this._language=s,this._style=r?Object.assign({},Vt,r):Vt,this._isEnabled=n,this._addIndoorEventListeners()}onAdd(e){return this._maplibre=e,this._addMapMoveEventListener(),this._container=F("div","maplibregl-ctrl mapxus-ctrl-floors hidden"),this._container}onRemove(){this._debounceScroll&&this._debounceScroll.cancel(),this._clearScrollEventListener&&this._clearScrollEventListener(),Fe(this._container)}get position(){return this._position}get enabled(){return this._isEnabled}setEnabled(e){this._isEnabled=e,e&&!this._visible&&this._setVisibility(!0),!e&&this._visible&&this._setVisibility(!1)}getDefaultPosition(){return"top-right"}async switchByOrdinal(e,i){this._ordinal=e,this._dragPan=i??!0,await this._indoor.switchFloorByOrdinal(e),this._updateSelectorStatus(e),this._scrollCenterActiveFloor()}changePosition(e,i,r){const n=document.querySelector(`.maplibregl-ctrl-${e}`),s=n.querySelector(".mapxus-ctrl-floors");if(e!==i){this._position=i;const o=document.querySelector(`.maplibregl-ctrl-${i}`);s&&(n.removeChild(s),Number.isFinite(r)?o.insertBefore(s,o.children[r]):o.append(s),this._show(),this._scrollCenterActiveFloor())}else Number.isFinite(r)&&n.children[r]!==s&&(n.removeChild(s),n.insertBefore(s,n.children[r]),this._show(),this._scrollCenterActiveFloor())}setStyle(e){this._style=Object.assign({},this._style,e),this._componentDidMount&&(this._clearFloors(),this._calcSelectorLayout(),this._render(),this._scrollCenterActiveFloor())}_setVisibility(e){this._componentDidMount?e?(this._show(),this._scrollCenterActiveFloor()):this._hide():(this._visible=e,this._indoor.building&&e&&(this._render(),this._show(),this._scrollCenterActiveFloor()))}_addIndoorEventListeners(){this._indoor.on(qe,e=>{if(this._updatePrepared(),!e)return;const{ordinal:i,dragPan:r}=e;this._dragPan=r,"building"in e?this._renderBuildingFloors(e.building,i):this._renderSharedLevelFloor(e)})}_updatePrepared(){this._clearState(),this._visible&&this._hide(),this._componentDidMount&&this._clearFloors()}_renderBuildingFloors(e,i){const{level_names:r,ordinals:n,id:s}=e.properties;this._buildingId=s,this._floorNames=r.split(",").reverse(),this._ordinals=n.split(",").reverse(),this._ordinal=i,this._calcSelectorLayout(),this._render();const o=this._indoor.getFeaturesById(s,{filter:a=>a.layer.id==="mapxus-building-line"})[0];this._checkIfShowFloorSelector(o)}_renderSharedLevelFloor(e){const{name:i,ordinal:r,id:n}=e;this._floorNames=[i[this._language]||i.default],this._ordinals=[r],this._ordinal=r,this._calcSelectorLayout(),this._render();const s=this._indoor.getFeaturesById(n,{layerIds:[x]})[0];this._checkIfShowFloorSelector(s)}_checkIfShowFloorSelector(e){this.enabled&&(this._dragPan!==!1||this._dragPan===!1&&e)&&(this._show(),this._scrollCenterActiveFloor())}_addMapMoveEventListener(){this._maplibre.on("moveend",()=>{this.enabled&&this._dragPan===!1&&this._buildingId&&(this._indoor.getFeaturesById(this._buildingId,{layerIds:["mapxus-building-line"]})[0]?this._componentDidMount?this._visible||(this._show(),this._scrollCenterActiveFloor()):(this._render(),this._show(),this._scrollCenterActiveFloor()):this._componentDidMount&&this._visible&&this._hide())})}_clearState(){this._buildingId=null,this._floorNames=[],this._ordinals=[],this._ordinal=null}_calcSelectorLayout(){const{itemCount:e,itemSize:i}=this._style;this._centerSelectorIdx=Math.ceil(e/2)-1,this._maxScrollTop=(this._floorNames.length-e)*i,this._lastNormalScrollableIdx=this._floorNames.length-(e-this._centerSelectorIdx-1)-1}_render(){this._createFloors(),this._componentDidMount=!0}_hide(){this._container.classList.add("hidden"),this._visible=!1}_show(){this._container.classList.remove("hidden"),this._visible=!0}_createFloors(){this._$selectorFolded=this._$foldedSelector(this._container,()=>{this._expandSelector(!0),this._scrollCenterActiveFloor()}),this._$selectorExpanded=this._$expandedSelector(this._container,()=>this._expandSelector(!1))}_$expandedSelector(e,i){const{itemSize:r,itemCount:n,defaultFolded:s,backgroundColor:o}=this._style,a=F("div",`mapxus-ctrl-floors-expanded ${s?"hidden":""}`,e);if(this._floorNames.length>1){const d=F("div","mapxus-ctrl-floors-close",a);d.onclick=i}const l=F("div","mapxus-ctrl-floors-wrapper",a);return l.style.backgroundColor=o,this._floorNames.length>n&&(this._$arrowBtnUp=this._$createScrollButton(l,"up"),this._$arrowBtnUp.onclick=()=>this._handleScroll("up")),this._$innerFloors=F("div","mapxus-ctrl-floors-inner",l),Object.assign(this._$innerFloors.style,{maxHeight:`${r*n}px`,width:`${r}px`}),this._$createFloors(this._$innerFloors),this._floorNames.length>n&&(this._$arrowBtnDown=this._$createScrollButton(l,"down"),this._$arrowBtnDown.onclick=()=>this._handleScroll("down"),this._$innerFloors.addEventListener("scroll",this._debounceScroll=vt(d=>{d.stopPropagation(),this._resetArrowBtnStatus(this._$innerFloors.scrollTop)},100)),this._clearScrollEventListener=()=>this._$innerFloors.removeEventListener("scroll",this._debounceScroll)),a}_$foldedSelector(e,i){const{itemSize:r,activeFontColor:n,activeBackgroundColor:s,defaultFolded:o}=this._style,a=F("div",`mapxus-ctrl-floors-folded mapxus-ctrl-floors-floor ${o?"":"hidden"}`,e);return a.onclick=i,Object.assign(a.style,{width:`${r}px`,height:`${r}px`,lineHeight:`${r}px`,color:n,backgroundColor:s}),a}_clearFloors(){this._container.replaceChildren(),this._componentDidMount=!1}_$createScrollButton(e,i){return F("div",`mapxus-ctrl-floors-arrow mapxus-ctrl-floors-floor ${i}`,e)}_$createFloors(e){const{fontColor:i,itemSize:r}=this._style;let n;this._floorNames.forEach((s,o)=>{n=F("div","mapxus-ctrl-floors-floor",e),n.dataset.floor=s,n.dataset.ordinal=this._ordinals[o],n.innerText=s,Object.assign(n.style,{color:i,height:`${r}px`,lineHeight:`${r}px`}),n.dataset.ordinal===this._ordinal&&(this._$activeFloor=n,this._resetActiveFloor(!0),this._$selectorFolded.innerText=s),n.onclick=async a=>{this._indoor.setDragPan("restrict"),this._indoor.dragPanHandler.setAnimated(!0),await this.switchByOrdinal(a.target.dataset.ordinal)}})}_updateSelectorStatus(e){const i=this._floorNames[this._ordinals.indexOf(e)];this._$activeFloor&&this._resetActiveFloor(!1);for(const r of this._$innerFloors.children){const n=r;n.dataset.ordinal===e&&(this._$activeFloor=n,this._resetActiveFloor(!0))}this._$selectorFolded.innerText=i}_resetArrowBtnStatus(e){e===0?this._$arrowBtnUp?.classList?.add("hidden"):this._$arrowBtnUp?.classList?.remove("hidden"),e===this._maxScrollTop?this._$arrowBtnDown?.classList?.add("hidden"):this._$arrowBtnDown?.classList?.remove("hidden")}_resetActiveFloor(e){const{activeBackgroundColor:i,backgroundColor:r,activeFontColor:n,fontColor:s}=this._style;Object.assign(this._$activeFloor.style,{color:e?n:s,backgroundColor:e?i:r,fontWeight:e?"bold":"normal",cursor:e?"auto":"pointer"}),this._$activeFloor.disabled=e}_scrollCenterActiveFloor(){if(this._ordinal){const e=this._ordinals.indexOf(this._ordinal);e>-1&&(this._$innerFloors.scrollTop=this._getScrollTop(e),this._$innerFloors.scrollTop||this._resetArrowBtnStatus(0))}}_getScrollTop(e){return rr(this._centerSelectorIdx,this._lastNormalScrollableIdx+1)?(e-this._centerSelectorIdx)*this._style.itemSize:e>this._lastNormalScrollableIdx?this._maxScrollTop:0}_handleScroll(e){const i=this._$innerFloors.scrollTop,{itemSize:r}=this._style;if(e==="up"){const n=i-r*2;this._$innerFloors.scrollTop=n<0?0:n}else if(e==="down"){const n=i+r*2;this._$innerFloors.scrollTop=n>this._maxScrollTop?this._maxScrollTop:n}}_expandSelector(e){e?(this._$selectorExpanded.classList.remove("hidden"),this._$selectorFolded.classList.add("hidden")):(this._$selectorExpanded.classList.add("hidden"),this._$selectorFolded.classList.remove("hidden"))}}class Ta{_container;_isEnabled;constructor(e){this._isEnabled=e?.enabled??!0}onAdd(e){if(this._container=F("div","maplibregl-ctrl mapxus-ctrl-logo",e.getContainer()),this._isEnabled){const i=F("a","mapxus-logo",this._container);i.target="_blank",i.href="https://www.khi.co.jp/groupvision2030/mapxus.html",i.setAttribute("aria-label","Mapxus logo"),i.setAttribute("rel","noopener"),this._container.appendChild(i)}return this._container}onRemove(){Fe(this._container)}getDefaultPosition(){return"bottom-left"}}class Ra{_container;_anchor;_theme;constructor(e){this._theme=e.theme?e.theme:"default"}onAdd(e){return this._container=F("div","maplibregl-ctrl mapxus-ctrl-attribution",e.getContainer()),this._anchor=F("a","mapxus-attribution",this._container),this._anchor.target="_blank",this._setCopyrightInfo(this._theme),this._anchor.setAttribute("aria-label","Mapxus attribution"),this._anchor.setAttribute("rel","noopener"),this._container.appendChild(this._anchor),this._container}onRemove(){Fe(this._container)}getDefaultPosition(){return"bottom-right"}changeTheme(e){this._setCopyrightInfo(e)}_setCopyrightInfo(e){this._anchor.innerText=e==="landsD"?"© The Government of the Hong Kong SAR":"©Mapxus driven by Kawasaki ©OpenStreetMap contributors",e==="landsD"&&(this._anchor.href="https://www.map.gov.hk/gm/")}}class ka{_container;_$icon;_removeClickEventListener;onAdd(e){return this._container=F("div","maplibregl-ctrl mapxus-ctrl-collapsed-copyright",e.getContainer()),this._container.innerHTML=Da(),this._bindEvents(),this._container}onRemove(){this._removeClickEventListener(),Fe(this._container)}getDefaultPosition(){return"bottom-right"}_bindEvents(){const e=this._container.querySelector(".mapxus-collapsed-copyright-menu");this._$icon=this._container.querySelector(".mapxus-collapsed-copyright-btn");let i=!1;this._$icon.addEventListener("click",r),this._removeClickEventListener=()=>this._$icon.removeEventListener("click",r);function r(){i=!i,n()}function n(){i?e.classList.remove("hidden"):e.classList.add("hidden")}}}function Da(){return`
19
2
  <div class="mapxus-collapsed-copyright-content">
20
3
  <div class="mapxus-collapsed-copyright-menu hidden">
21
4
  <div class="mapxus-collapsed-copyright-logo" onclick="window.open('https://www.khi.co.jp/groupvision2030/mapxus.html')"></div>
@@ -24,4 +7,4 @@ components: `).concat(ws(o),"\n```")),[2,s]}})})}}}function zf(){if(!(window.__f
24
7
  </div>
25
8
  <div class="mapxus-collapsed-copyright-btn"></div>
26
9
  </div>
27
- `}function Gi(e){return`${zo}/api/v3/tiles/styles/${e}`}class Hc{_buildingSelector;_isEnabled=!0;_position;constructor(t){this._buildingSelector=t}enable(){this._isEnabled=!0,this._buildingSelector.enabled||this._buildingSelector.setVisibility(!0)}disable(){this._isEnabled=!1,this._buildingSelector.enabled&&this._buildingSelector.setVisibility(!1)}setPosition(t,n){this._position=t,this._buildingSelector.changePosition(this._buildingSelector.position,t,n)}get isEnabled(){return this._isEnabled}get position(){return this._position}}class Uc{_floorSelector;_isEnabled;_position;constructor(t){this._floorSelector=t,this._position=t.position,this._isEnabled=this._floorSelector.enabled}enable(){this._isEnabled=!0,this._floorSelector.setEnabled(!0)}disable(){this._isEnabled=!1,this._floorSelector.setEnabled(!1)}setPosition(t,n){this._position=t,this._floorSelector.changePosition(this._floorSelector.position,t,n)}setStyle(t){this._floorSelector.setStyle(t)}get isEnabled(){return this._isEnabled}get position(){return this._position}}class Nc{_indoor;_isEnabled=!0;constructor(t){this._indoor=t}enable(){this._isEnabled=!0,this._indoor.setAllowBuildingSwitch(!0)}disable(){this._isEnabled=!1,this._indoor.setAllowBuildingSwitch(!1)}get isEnabled(){return this._isEnabled}}class Dc{_indoor;_isEnabled=!0;constructor(t){this._indoor=t}enable(){this._isEnabled=!0,this._indoor.setAllowOutdoorSwitch(!0)}disable(){this._isEnabled=!1,this._indoor.setAllowOutdoorSwitch(!1)}get isEnabled(){return this._isEnabled}}class $c{_indoor;_isEnabled=!0;constructor(t){this._indoor=t}enable(){this._isEnabled=!0,this._indoor.setAllowIndoorClickSelect(!0)}disable(){this._isEnabled=!1,this._indoor.setAllowIndoorClickSelect(!1)}get isEnabled(){return this._isEnabled}}class Vc{_indoor;_isEnabled=!0;constructor(t){this._indoor=t}enable(){this._isEnabled=!0,this._indoor.setAllowOutdoorClickSelect(!0)}disable(){this._isEnabled=!1,this._indoor.setAllowOutdoorClickSelect(!1)}get isEnabled(){return this._isEnabled}}const zi="Map_mapClick",Zi="Map_pointClick",Wi="Map_isRenderComplete",Pn="Map_isDestroyed",Dt=nt.getInstance();let zg=class{_map;_indoor;_poi;_floorsControl;_buildingFilterControl;_attributionControl;_language;_dispatch=Wt(zi,Zi,Wi,Pn);_fitBounds;_history=Mt.getInstance();_hiddenBuildings=Ht.getInstance().getHiddenBuildings();_debounceHTTPErrorHandler;_transformRequestHandler;_tokenRefreshingPromise=null;_request=st.getInstance();_cancelTokenChangedListener;isDestroyed=!1;switchOutdoor;outdoorClickSelection;switchBuilding;indoorClickSelection;buildingSelector;floorSelector;constructor(t){if(!t.map)throw new Error("Map is required.");if(!qc(t)&&!jc(t))throw new Error("Access params are required.");qc(t)?Dt.setAccessByAppKey({appId:t.appId,secret:t.secret,platform:t.platform}).then(async()=>{await Dt.setupTokenManager(),this._setup(t)}):jc(t)&&(Dt.setTokenGetter(t.getTokenAsync),Dt.setupTokenManager().then(()=>{this._setup(t)}))}renderComplete(t){const n=Ut(`${Wi}.`);this._dispatch.on(n,t)}destroyed(t){const n=Ut(`${Pn}.`);this._dispatch.on(n,()=>{t(),this._dispatch.on(n,null),this._dispatch._[Pn].length===0&&(delete this._dispatch,Object.freeze(this))})}setTransformRequest(t){this._transformRequestHandler=t}getIndoor(){return this._indoor}getMaplibre(){return this._map}get floor(){return this._indoor?.floor??null}get building(){return this._indoor?.building??null}get venue(){return this._indoor?.venue??null}setLanguage(t){this._language!==t&&(this._language=t);const i=(this._map?.getStyle()?.layers||[]).filter(({type:o})=>o==="symbol");for(const{id:o}of i){const s=this._map.getLayer(o),a=typeof this._map.getLayoutProperty(o,"text-field")=="string";s&&!a&&this._map.setLayoutProperty(o,"text-field",["coalesce",["get",`name:${t}`],["get","name"]])}}getLanguage(){return this._language}setOutdoorMapShown(t){this._indoor?.setOutdoorMapShown(t)}queryIndoorFeaturesByPoint(t){const{x:n,y:r}=t,i=this._map.queryRenderedFeatures([n,r],{layers:["mapxus-venue-fill","mapxus-building-line",nn,je]}),o=i.find(p=>p.layer.id==="mapxus-venue-fill");if(!o)return null;const{id:s}=o.properties,a=this._history.getBuildingUnitByVenue(s),d=this._history.getOrdinalByBuildingUnit(a.id),u=i.find(p=>p.properties?.ordinal===d);if(u){if(u.sourceLayer==="mapxus_shared_level")return{venue:o,sharedLevel:u};const p=i.find(h=>h.properties.id===u.properties["ref:building"]);return{venue:o,building:p,level:u}}}getIndoorFeaturesByCoordinates(t,n){const r=this._map.project(t),i=this._map.queryRenderedFeatures(r,{layers:["mapxus-venue-fill","mapxus-building-line","mapxus-level-fill","mapxus-level-fill-overlap-copy"]});if(i.length===0)return{venue:null,building:null,level:null};const s=i.filter(u=>u.layer.id.includes("mapxus-level-fill")).find(u=>Number.isFinite(n)?u.properties.ordinal===n+"":u.layer.id.startsWith("mapxus-level-fill"));if(!s)return{venue:null,building:null,level:null};const a=i.find(u=>u.properties.id===s.properties["ref:building"]);return{venue:i.find(u=>u.properties.id===a.properties["ref:venue"]),building:a,level:s}}getFeaturesById(t,n){return this._indoor?.getFeaturesById(t,n)||[]}async switchFloorByOrdinal(t){await this._indoor?.switchFloorByOrdinal(t)}async selectFloorById(t,n){const{dragPan:r=!0,animate:i=!0,fitBounds:o}=n||{},s=o??this._fitBounds,a=async()=>{const d=await Kc(t),{maxLat:u,maxLon:p,minLat:h,minLon:I}=d?.bbox||{};this._indoor.dragPanHandler.setBounds([I,h,p,u])};if(this._indoor.setDragPan(r),this._indoor.setFitBounds(s),this._indoor.dragPanHandler.setAnimated(i),t===this.floor?.id){if(!r)return;s?(this._indoor.dragPanHandler.getBounds()||await a(),await this._indoor.dragPanHandler.fitBounds()):this._indoor.dragPanHandler.panToCenter()}else{let d=!1,u=(this._map.getLayer("mapxus-building-line")?this._map.queryRenderedFeatures({layers:["mapxus-building-line"]}):[]).find(h=>h.properties?.level_ids?.includes(t))??null;if(u&&u.properties?.id===this.building?.properties?.id){s&&!this._indoor.dragPanHandler.getBounds()&&await a();const{level_ids:h,ordinals:I}=u.properties,b=Ae(h).indexOf(t),g=Ae(I)[b]??null;await this._floorsControl.switchByOrdinal(g,r)}else{if(u)s&&await a();else{const h=await Kc(t),{maxLat:I,maxLon:b,minLat:g,minLon:w}=h.bbox;d=!0,u=h.feature,this._indoor.dragPanHandler.setBounds([w,g,b,I])}await this._indoor.selectBuilding(u??null,{floorId:t,featureIncomplete:d})}}}async selectSharedFloorById(t,n){const{dragPan:r=!0,animate:i=!0,fitBounds:o}=n||{},s=o??this._fitBounds,a=async()=>{const d=await Zg(t),{maxLat:u,maxLon:p,minLat:h,minLon:I}=d?.bbox||{};this._indoor.dragPanHandler.setBounds([I,h,p,u])};if(this._indoor.setDragPan(r),this._indoor.setFitBounds(s),this._indoor.dragPanHandler.setAnimated(i),t===this.floor?.id){if(!r)return;s?(this._indoor.dragPanHandler.getBounds()||await a(),await this._indoor.dragPanHandler.fitBounds()):this._indoor.dragPanHandler.panToCenter()}else{let d=!1,u,p;const h=(this._map.getLayer(je)?this._map.queryRenderedFeatures({layers:[je]}):[]).find(I=>I.properties?.id===t)??null;if(h)s&&await a();else{const I=await wc(t);p=Hn(I),d=!0;const{maxLat:b,maxLon:g,minLat:w,minLon:B}=I?.bbox||{};this._indoor.dragPanHandler.setBounds([B,w,g,b]);const T=I.sharedFloors.find(({id:P})=>P===t),{id:H,name:N,ordinal:X}=T;u={id:H,name:N,ordinal:X+""}}if(!d){const{id:I,name:b,ordinal:g,"ref:venue":w}=h.properties||{};u={id:I,name:typeof b=="string"?{default:b}:b,ordinal:g},p=(this._map.getLayer("mapxus-venue-fill")?this._map.queryRenderedFeatures({layers:["mapxus-venue-fill"]}):[]).find(B=>B.properties?.id===w)??null}u&&p&&await this._indoor?.selectSharedFloor(u,p,{featureIncomplete:d})}}async selectBuildingById(t,n){const{dragPan:r=!0,animate:i=!0,fitBounds:o}=n||{},s=o??this._fitBounds,a=async()=>{const d=await fr(t),{maxLat:u,maxLon:p,minLat:h,minLon:I}=d?.bbox||{};this._indoor.dragPanHandler.setBounds([I,h,p,u])};if(this._indoor.setDragPan(r),this._indoor.setFitBounds(s),this._indoor.dragPanHandler.setAnimated(i),t===this.building?.properties?.id){if(!r)return;s?(this._indoor.dragPanHandler.getBounds()||await a(),await this._indoor.dragPanHandler.fitBounds()):this._indoor.dragPanHandler.panToCenter()}else{let d=!1,u=(this._map.getLayer("mapxus-building-line")?this._map.queryRenderedFeatures({layers:["mapxus-building-line"]}):[]).find(p=>p.properties?.id===t)??null;if(u)s&&await a();else{const p=await fr(t),{maxLat:h,maxLon:I,minLat:b,minLon:g}=p?.bbox||{};u=xr(p),d=!0,this._indoor.dragPanHandler.setBounds([g,b,I,h])}await this._indoor?.selectBuilding(u,{featureIncomplete:d})}}async selectVenueById(t,n){if(typeof t=="string"&&t.trim()===""||t===null){await this._indoor?.selectBuilding(null);return}const{dragPan:i=!0,animate:o=!0,fitBounds:s}=n||{},a=s??this._fitBounds,d=async()=>{const u=await hr(t),{maxLat:p,maxLon:h,minLat:I,minLon:b}=u?.bbox||{};this._indoor.dragPanHandler.setBounds([b,I,h,p])};if(this._indoor.setDragPan(i),this._indoor.setFitBounds(a),this._indoor.dragPanHandler.setAnimated(o),t===this.venue?.properties?.id){if(!i)return;a?(this._indoor.dragPanHandler.getBounds()||await d(),await this._indoor.dragPanHandler.fitBounds()):this._indoor.dragPanHandler.panToCenter()}else{const u=this._history.getBuildingUnitByVenue(t);if(u){const{id:p,type:h}=u;h==="building"?await this.selectBuildingById(p,n):await this.selectSharedFloorById(p,n)}else{const p=(this._map.getLayer("mapxus-venue-fill")?this._map.queryRenderedFeatures({layers:["mapxus-venue-fill"]}):[]).find(I=>I.properties?.id===t)??null;let h;if(p){const{default_displayed_building:I,building_ids:b}=p.properties;h=I||Ae(b)[0]}else{const I=await hr(t);h=I.defaultBuilding||I.buildings[0]?.id}await this.selectBuildingById(h,n)}}}onMapClickListener(t){const n=Ut(`${zi}.`);return this._dispatch.on(n,t),{unsubscribe:()=>this._dispatch.on(n,null)}}onPoiClickListener(t){return this._poi?.onPoiClick(t)}onPointClickListener(t){const n=Ut(`${Zi}.`);return this._dispatch.on(n,t),{unsubscribe:()=>this._dispatch.on(n,null)}}onMapChangeListener(t){return this._indoor?.onMapChange(t)}switchTheme(t){this._setStyle(Gi(t)),this._map?.once("styledata",()=>this._setIndoorFilter()),"changeTheme"in this._attributionControl&&this._attributionControl.changeTheme(t)}setTheme(t){this._setStyle(Gi(t)),this._map?.once("styledata",()=>this._setIndoorFilter()),"changeTheme"in this._attributionControl&&this._attributionControl.changeTheme(t)}setSelectedBuildingBorderStyle(t){return this._indoor?.setSelectedHighlightStyle(t),this}setSelectedHighlightStyle(t){return this._indoor?.setSelectedHighlightStyle(t),this}async _setup(t){const{map:n,poiId:r,sharedFloorId:i,floorId:o,buildingId:s,venueId:a,theme:d=Lr.MAPXUS_DEFAULT,floorSelectorEnabled:u,buildingSelectorEnabled:p,outdoorMapShown:h=!0,collapseCopyright:I=!1,maskNonSelectedAreas:b=!1,fitBuildingBounds:g,fitBounds:w,boundsPadding:B=30,selectedHighlightStyle:T,floorSelectorStyle:H,language:N=hl,autoSelectBuilding:X=!1,transformRequest:P=null,mapxusLogoEnabled:F=!0,enableIndoorClickSelection:q=!0,enableOutdoorClickSelection:W=!0}=t;this._map=n,this._language=N,this._fitBounds=w??g??!1,this._indoor=new xc({map:this._map,startWithIndoorView:!!(a||s||o||r||i),outdoorMapShown:h,fitBounds:this._fitBounds,boundsPadding:B,maskNonSelectedAreas:b,selectedHighlightStyle:T,enableIndoorClickSelection:q,enableOutdoorClickSelection:W}),this._poi=new Tc(this._map),this._transformRequestHandler=P,await this._resourceRequestTransform(),this._installRtlTextPlugin(),this._setStyle(Gi(d)),this._checkMapZoom(),I?this._attributionControl=new Kg:(this._attributionControl=new qg({theme:d}),this._addControl(new jg({enabled:F}))),this._addControl(this._attributionControl),this._addControl(this._buildingFilterControl=new Rc(this,p)),this._addControl(this._floorsControl=new Mc(this._indoor,{language:N,style:H,enabled:u})),r?this._selectPoiById(r):o?this.selectFloorById(o,{animate:!1}):s?this.selectBuildingById(s,{animate:!1}):a?this.selectVenueById(a,{animate:!1}):i&&this.selectSharedFloorById(i,{animate:!1}),this.switchOutdoor=new Dc(this._indoor),this.switchBuilding=new Nc(this._indoor),this.outdoorClickSelection=new Vc(this._indoor),this.indoorClickSelection=new $c(this._indoor),this.buildingSelector=new Hc(this._buildingFilterControl),this.floorSelector=new Uc(this._floorsControl),this._map.once("styledata",()=>this.setLanguage(this._language)),this._map.on("remove",()=>this._destroy()),this._map.on("error",this._debounceHTTPErrorHandler=Ni(K=>this._updatePermission(K),300)),this._indoor.once(Di,()=>{X&&this._map.on("moveend",()=>this._selectCenterBuilding()),this._bindMapClickListener(),this._bindTokenChangedListener(),this._dispatch.call(Wi)})}_setIndoorFilter(){this._indoor.updateCustomLayers(),this._indoor.updateRendering()}_setStyle(t){this._map?.setStyle(t,{localIdeographFontFamily:!1})}_addControl(t,n){this._map.addControl(t,n)}async _selectPoiById(t){try{const n=await cg(t),{lon:r,lat:i}=n.location;"floorId"in n?await this.selectFloorById(n.floorId,{animate:!1}):"sharedFloorId"in n&&await this.selectSharedFloorById(n.sharedFloorId,{animate:!1}),this._map.panTo([r,i],{animate:!1})}catch(n){this._handleSearchError(n)}}async _resourceRequestTransform(){const t=await this._request.getRequestHeaders();this._map.setTransformRequest((n,r)=>{const{host:i}=new URL(n);return i.includes("map-api")&&i.includes("mapxus")?{url:n,headers:t}:this._transformRequestHandler?this._transformRequestHandler(n,r):{url:n}})}_checkMapZoom(){const t=this._map.getZoom();(t<8||t>22)&&t>1&&console.warn("Indoor maps perform better at zoom levels [8, 22].")}async _updatePermission(t){if(t.error?.status===401)return this._tokenRefreshingPromise?this._tokenRefreshingPromise:(this._tokenRefreshingPromise=this._resourceRequestTransform().finally(()=>this._tokenRefreshingPromise=null),this._tokenRefreshingPromise)}_selectCenterBuilding(){const t=this._getCenterBuildingUnitsMap();if(!t.size)return;let n=t.entries().next().value[1];const r=this._history.getVisitedBuildingUnits().reverse();for(const i of r){const{id:o}=i;if(t.get(o)){n=i;break}}n.type==="building"?this.selectBuildingById(n.id,{dragPan:!1}):this.selectSharedFloorById(n.id,{dragPan:!1})}_getCenterBuildingUnitsMap(){const t=this._map.getCanvas().getBoundingClientRect(),n=t.width/4,r=t.height/4,i=[n,r],o=[t.width-n,t.height-r],s=["mapxus-building-line",je].filter(d=>this._map.getLayer(d));let a=this._map.queryRenderedFeatures([i,o],{layers:s});return a=Sc(a,"properties.id"),a=a.filter(d=>!this._hiddenBuildings.has(d.properties.id)),new globalThis.Map(a.map(({properties:d})=>[`${d.id}`,{id:d.id,type:d.building?"building":"sharedFloor"}]))}_bindMapClickListener(){this._map.on("click",async t=>{const{point:n,lngLat:r}=t,i=await this._indoor.queryIndoorFeaturesByClickPoint(n);await this._indoor.selectByClickMap(i),this._dispatch.call(Zi,null,{point:n,coordinate:r}),this._dispatch.call(zi,null,{coordinate:r,venue:i?.venue??null,building:i&&"building"in i?i.building:null,floor:i?"sharedFloor"in i?i.sharedFloor:i.floor??null:null})})}_bindTokenChangedListener(){const{off:t}=Dt.on(vi,async()=>{await this._resourceRequestTransform()});this._cancelTokenChangedListener=t}_handleSearchError(t){const n=t?.response?.status||"unknown",r=t?.response?.data?.message||"unknown";Dt.getGlobalDispatcher().call("initError",null,{status:n,message:r})}_installRtlTextPlugin(){Vt.getRTLTextPluginStatus()==="unavailable"&&Vt.setRTLTextPlugin("https://unpkg.com/@mapbox/mapbox-gl-rtl-text@0.3.0/dist/mapbox-gl-rtl-text.js",!0)}_destroy(){if(this.isDestroyed)return;this.isDestroyed=!0,this._debounceHTTPErrorHandler?.cancel();const t=this._dispatch._;for(const n in t)n!==Pn&&t.hasOwnProperty(n)&&t[n].forEach(({name:r})=>{this._dispatch.on(`${n}.${r}`,null)});this._indoor.destroy(),this._poi.destroy(),Object.keys(this).forEach(n=>{n!=="isDestroyed"&&n!=="_dispatch"&&delete this[n]}),this._cancelTokenChangedListener&&this._cancelTokenChangedListener(),Dt.clearState(),this._dispatch.call(Pn)}};function jc(e){return"getTokenAsync"in e&&typeof e.getTokenAsync=="function"}function qc(e){return"appId"in e&&e.appId.trim()!==""&&"secret"in e&&e.secret.trim()!==""}async function Kc(e){const t=await ag(e);return{feature:xr(t),bbox:t.bbox}}async function Zg(e){const t=await wc(e);return{feature:Hn(t),bbox:t.bbox}}async function Fn(e,t){if(!e.hasImage(t))try{const n=await e.loadImage(t);e.addImage(t,n.data)}catch(n){throw new Error(n)}}class Wg{_maplibreMap;_layerId;_sourceId;_imageName="poi-01";_imageSize=.75;_iconAnchor="bottom";constructor(t){this._maplibreMap=t;const n=Ut();this._layerId=`MXMap_preset_marker_layer_${n}`,this._sourceId=`MXMap_preset_marker_source_${n}`}async setIcon(t){if(typeof t!="string"||!t.trim())throw new Error("Icon must be a non-empty string.");await Fn(this._maplibreMap,t.trim()),this._imageName=t}setIconSize(t){this._imageSize=t}setIconAnchor(t){this._iconAnchor=t}get layerId(){return this._layerId}get sourceId(){return this._sourceId}create(t){if(!(Array.isArray(t)&&t.length))return;const n=t.map(r=>this._createIconFeature(r));this._addIconSource(n),this._addIconLayer()}updateData(t){const n=!!(t.remove&&t.remove.length),r=!!(t.add&&t.add.length),i=!!(t.update&&t.update.length),o=this._maplibreMap.getSource(this._sourceId);if(!n&&!r&&!i||!o)return;const s={};n&&(s.remove=t.remove),r&&(s.add=t.add.map(a=>this._createIconFeature(a))),i&&(s.update=t.update.map(a=>{const d=this._createIconFeature(a),{id:u,geometry:p,properties:h}=d;return{id:u,...p&&{newGeometry:p},...h&&{addOrUpdateProperties:Object.entries(h).map(([I,b])=>({key:I,value:b}))},...!p&&!h&&{removeAllProperties:!0}}})),o.updateData(s)}remove(){this._maplibreMap.getLayer(this._layerId)&&this._maplibreMap.removeLayer(this._layerId),this._maplibreMap.getSource(this._sourceId)&&this._maplibreMap.removeSource(this._sourceId)}on(t,n){const r=o=>this._handleEventListener(o,n),{unsubscribe:i}=this._maplibreMap.on(t,this._layerId,r);return{off:i}}setFilter(t){this._maplibreMap.getLayer(this._layerId)&&this._maplibreMap.setFilter(this._layerId,t)}setFilterByVenue(t,n){this._maplibreMap.getLayer(this._layerId)&&this._maplibreMap.setFilter(this._layerId,["any",["all",["==",["get","venueId"],t??""],["==",["get","ordinal"],n??""]],["all",["==",["get","venueId"],""],["==",["get","ordinal"],""]]])}setFilterByBuilding(t,n){this._maplibreMap.getLayer(this._layerId)&&this._maplibreMap.setFilter(this._layerId,["any",["all",["==",["get","buildingId"],t??""],["==",["get","ordinal"],n??""]],["all",["==",["get","buildingId"],""],["==",["get","ordinal"],""]]])}setOpacity(t){this._maplibreMap.getLayer(this._layerId)&&this._maplibreMap.setPaintProperty(this._layerId,"icon-opacity",t)}setOpacityByVenue(t,n,r){if(this._maplibreMap.getLayer(this._layerId)){const i=["case",["all",["==",["get","venueId"],t??""],["==",["get","ordinal"],n??""]],1,["all",["==",["get","venueId"],""],["==",["get","ordinal"],""]],1,r??.5];this._maplibreMap.setPaintProperty(this._layerId,"icon-opacity",i)}}setOpacityByBuilding(t,n,r){if(this._maplibreMap.getLayer(this._layerId)){const i=["case",["all",["==",["get","buildingId"],t??""],["==",["get","ordinal"],n??""]],1,["all",["==",["get","buildingId"],""],["==",["get","ordinal"],""]],1,r??.5];this._maplibreMap.setPaintProperty(this._layerId,"icon-opacity",i)}}_createIconFeature(t){const{lngLat:n,properties:r}=t;return{id:"featureId"in t?t.featureId:void 0,type:"Feature",...n&&{geometry:{type:"Point",coordinates:n}},...r&&{properties:r}}}_addIconSource(t){const n={type:"geojson",data:{type:"FeatureCollection",features:t}};this._maplibreMap.addSource(this._sourceId,n)}_addIconLayer(){this._maplibreMap.addLayer({id:this._layerId,type:"symbol",source:this._sourceId,layout:{"icon-image":this._imageName,"icon-size":this._imageSize,"icon-anchor":this._iconAnchor,"icon-allow-overlap":!0,"icon-ignore-placement":!0}})}_handleEventListener(t,n){const{point:r}=t,i=this._maplibreMap.queryRenderedFeatures(r,{layers:[this._layerId]});n(i[0])}}function br(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}const Yi={indoorLineColor:"#45b1cc",outdoorLineColor:"#8183ba",dashedLineColor:"#969696",shuttleBusLineColor:"#fb923c",lineWidth:4,dashedLineWidth:4,disableDashedLine:!1,inactiveRouteOpacity:.5,outdoorLineOpacity:1,markerIconSize:.75,markers:{from:"poi-02",to:"poi-01",stops:["waypoint-01"]},lineSymbol:{image:"east-blue-arrow-01",size:.25,spacing:1}},wr="mmws-source-line-solid",en="mmws-layer-line-solid",tn="mmws-layer-icon-line-symbol",Xi="mmws-source-line-dashed",$t="mmws-layer-line-dashed",Ji="mmws-source-icon-connector",Gc="mmws-layer-icon-connector",vr="mmws-source-icon-marker",Qi="mmws-layer-icon-marker",zc=[en,tn,$t,Gc,Qi],Yg=[wr,Xi,Ji,vr];class Xg{_maplibreMap;_routeStyle=Yi;_styleDiffs={};_filterBy="venue";_curVenue=null;_curBuilding=null;_curOrdinal=null;_renderBoundaryLayer;constructor(t,n){this._maplibreMap=t,n&&(this._updateStyleProperties(n),t.on("load",()=>this._loadMarkerIcons()))}async setStyle(t){this._updateStyleProperties(t),await this._loadMarkerIcons(),await this._updateLayers()}async setMarkerIcons(t){if(Array.isArray(t)&&t.length){const n=t.slice(1,t.length-1);this._routeStyle.markers={from:t[0],to:br(t),stops:n.length?n:[t[0]]},this._styleDiffs={markers:this._routeStyle.markers}}else"from"in t&&(this._routeStyle.markers.from=t.from,this._styleDiffs.markers.from=t.from),"to"in t&&(this._routeStyle.markers.to=t.to,this._styleDiffs.markers.to=t.to),"stops"in t&&(this._routeStyle.markers.stops=t.stops??[null],this._styleDiffs.markers.stops=t.stops??[null]);await this._loadMarkerIcons()}setMarkerIconSize(t){return this._routeStyle.markerIconSize=t,this}setIndoorLineColor(t){return this._routeStyle.indoorLineColor=t,this}setOutdoorLineColor(t){return this._routeStyle.outdoorLineColor=t,this}setDashedLineColor(t){return this._routeStyle.dashedLineColor=t,this}setBusLineColor(t){return this._routeStyle.shuttleBusLineColor=t,this}render(t,n){if(!this._renderBoundaryLayer){const u=this._maplibreMap.getStyle(),p=Br(u);let h=p.find(({type:I,id:b})=>!b.includes("-overlap-copy")&&I==="fill-extrusion");h||(h=p.find(I=>I.type==="symbol"&&I?.["source-layer"]==="mapxus_place")),this._renderBoundaryLayer=h?.id}const{instructions:r,points:{coordinates:i}}=t,{lineFeatures:o,connectorFeatures:s,dashedLineFeatures:a,markerFeatures:d}=this._classifyFeatures(r,i,n);this._renderSolidLines(o),this._renderLineSymbols(wr,tn),this._routeStyle.disableDashedLine!==!0&&this._renderDashedLines(a),this._renderConnectors(s),this._renderMarkers(d)}remove(){zc.forEach(t=>{this._maplibreMap.getLayer(t)&&this._maplibreMap.removeLayer(t)}),Yg.forEach(t=>{this._maplibreMap.getSource(t)&&this._maplibreMap.removeSource(t)})}setFilterByVenue(t,n){this._filterBy="venue",this._curVenue=t??null,this._curOrdinal=n??null,this._filterRouteOpacity()}setFilterByBuilding(t,n){this._filterBy="building",this._curBuilding=t??null,this._curOrdinal=n??null,this._filterRouteOpacity()}_classifyFeatures(t,n,r){const i=[],o=[],s=[],a=[],d=[];t.forEach((W,K)=>{const{venue_id:J,building_id:te,floor_id:ne,ordinal:Y,sign:Q,type:v,interval:[D,x]}=W;if(Qg(Q))d.push(W);else if(Jg(Q)){K!==0&&K!==t.length-1&&o.push(this._createIconFeature(`connector-${o.length}`,n[D],{...gt({venue_id:J,building_id:te,floor_id:ne,ordinal:Y}),icon:v}));const S=t[K+1];if(S){const{venue_id:C,building_id:V,floor_id:f,ordinal:y}=S;o.push(this._createIconFeature(`connector-${o.length}`,n[x],{...gt({venue_id:C,building_id:V,floor_id:f,ordinal:y}),icon:v}))}}else i.push(this._createLineFeature(`solid-line-${i.length}`,n.slice(D,x+1),gt({venue_id:J,building_id:te,floor_id:ne,ordinal:Y,isShuttleBus:em(Q)?1:0})))});const u=t[0],{venue_id:p,building_id:h,floor_id:I,ordinal:b}=u,g=t[t.length-1],{venue_id:w,building_id:B,floor_id:T,ordinal:H}=g,N=n[0],X=n[n.length-1],P=r[0],F=r[r.length-1],q=r.slice(1,r.length-1);return P&&s.push(this._createLineFeature(`dashed-line-${s.length}`,[P,N],gt({venue_id:p,building_id:h,floor_id:I,ordinal:b}))),F&&s.push(this._createLineFeature(`dashed-line-${s.length}`,[X,F],gt({venue_id:w,building_id:B,floor_id:T,ordinal:H}))),d.length&&q.length&&d.forEach(({venue_id:W,building_id:K,floor_id:J,ordinal:te,interval:[ne]},Y)=>{s.push(this._createLineFeature(`dashed-line-${s.length}`,[n[ne],q[Y]],gt({venue_id:W,building_id:K,floor_id:J,ordinal:te}))),a.push(this._createIconFeature(`marker-${a.length}`,q[Y],{...gt({venue_id:W,building_id:K,floor_id:J,ordinal:te,markerType:`stops_${Y}`}),icon:this._routeStyle.markers.stops[Y]??br(this._routeStyle.markers.stops),iconSize:this._routeStyle.markerIconSize}))}),a.push(this._createIconFeature(`marker-${a.length}`,P??N,{...gt({venue_id:p,building_id:h,floor_id:I,ordinal:b,markerType:"from"}),icon:this._routeStyle.markers.from,iconSize:this._routeStyle.markerIconSize})),a.push(this._createIconFeature(`marker-${a.length}`,F??X,{...gt({venue_id:w,building_id:B,floor_id:T,ordinal:H,markerType:"to"}),icon:this._routeStyle.markers.to,iconSize:this._routeStyle.markerIconSize})),{lineFeatures:i,connectorFeatures:o,dashedLineFeatures:s,markerFeatures:a}}_createLineFeature(t,n,r){return{id:t,type:"Feature",geometry:{type:"LineString",coordinates:n},properties:r}}_createIconFeature(t,n,r){return{id:t,type:"Feature",geometry:{type:"Point",coordinates:n},properties:r}}_renderSolidLines(t){this._addCollectionSource(wr,t),this._addLineLayer(wr,en,{"line-color":["case",["==",["get","isShuttleBus"],"1"],this._routeStyle.shuttleBusLineColor,["==",["get","floor_id"],null],this._routeStyle.outdoorLineColor,this._routeStyle.indoorLineColor],"line-opacity":["case",["==",["get","floor_id"],null],this._routeStyle.outdoorLineOpacity,1],"line-width":this._routeStyle.lineWidth})}_renderDashedLines(t){this._addCollectionSource(Xi,t),this._addLineLayer(Xi,$t,{"line-color":this._routeStyle.dashedLineColor,"line-width":this._routeStyle.dashedLineWidth,"line-dasharray":[.1,1.8]})}_renderConnectors(t){this._addCollectionSource(Ji,t),this._addIconLayer(Ji,Gc)}_renderMarkers(t){this._addCollectionSource(vr,t),this._addIconLayer(vr,Qi,{"icon-anchor":"bottom","icon-allow-overlap":!0,"icon-ignore-placement":!0})}_addCollectionSource(t,n){this._maplibreMap.addSource(t,{type:"geojson",data:{type:"FeatureCollection",features:n}})}_addLineLayer(t,n,r){this._maplibreMap.addLayer({id:n,type:"line",source:t,layout:{"line-join":"round","line-cap":"round"},paint:{"line-width":4,...r||{}}},this._renderBoundaryLayer)}_renderLineSymbols(t,n){this._maplibreMap.addLayer({id:n,type:"symbol",source:t,layout:{"symbol-placement":"line","symbol-spacing":this._routeStyle.lineSymbol.spacing,"icon-size":this._routeStyle.lineSymbol.size,"icon-image":this._routeStyle.lineSymbol.image},paint:{"icon-opacity":["case",["==",["get","floor_id"],null],this._routeStyle.outdoorLineOpacity,1]}},this._renderBoundaryLayer)}_addIconLayer(t,n,r){this._maplibreMap.addLayer({id:n,type:"symbol",source:t,layout:{"icon-image":["get","icon"],"icon-size":["case",["has","iconSize"],["get","iconSize"],1],...r||{}}})}_updateStyleProperties(t){if(this._styleDiffs=Zc(this._routeStyle,t??Yi),!t)this._routeStyle=Yi;else if(Object.keys(this._styleDiffs).length){const n={...this._routeStyle.lineSymbol,...this._styleDiffs.lineSymbol??{}},r=this._styleDiffs.markers;let i=this._routeStyle.markers;const o={outdoorLineOpacity:(this._styleDiffs.outdoorLineOpacity>1?1:this._styleDiffs.outdoorLineOpacity<0?0:this._styleDiffs.outdoorLineOpacity)??this._routeStyle.outdoorLineOpacity},s={inactiveRouteOpacity:(this._styleDiffs.inactiveRouteOpacity>1?1:this._styleDiffs.inactiveRouteOpacity<0?0:this._styleDiffs.inactiveRouteOpacity)??this._routeStyle.inactiveRouteOpacity};r&&Object.keys(r).length&&(i={...i,...r}),this._routeStyle={...this._routeStyle,...this._styleDiffs,...o,...s,markers:i,lineSymbol:n}}}async _loadMarkerIcons(){const{markers:t,lineSymbol:n}=this._styleDiffs;if(n?.image&&await Fn(this._maplibreMap,n.image),t&&Object.keys(t).length){const{from:r,to:i,stops:o}=t;if(r&&await Fn(this._maplibreMap,r),i&&await Fn(this._maplibreMap,i),o&&o.length){const s=o.filter(a=>!!a);s.length&&await Promise.all(s.map(a=>Fn(this._maplibreMap,a)))}}}async _updateLayers(){if(!this._maplibreMap.getLayer(en))return;const{indoorLineColor:t,outdoorLineColor:n,dashedLineColor:r,shuttleBusLineColor:i,lineWidth:o,dashedLineWidth:s,disableDashedLine:a,inactiveRouteOpacity:d,outdoorLineOpacity:u,markerIconSize:p,markers:h,lineSymbol:I}=this._styleDiffs;if((t||n||i)&&this._maplibreMap.setPaintProperty(en,"line-color",["case",["==",["get","isShuttleBus"],"1"],this._routeStyle.shuttleBusLineColor,["==",["get","floor_id"],null],this._routeStyle.outdoorLineColor,this._routeStyle.indoorLineColor]),o!==void 0&&o+""&&this._maplibreMap.setPaintProperty(en,"line-width",o),typeof a=="boolean"?a?this._maplibreMap.setPaintProperty($t,"line-color","transparent"):(this._maplibreMap.setPaintProperty($t,"line-color",this._routeStyle.dashedLineColor),this._maplibreMap.setPaintProperty($t,"line-width",this._routeStyle.dashedLineWidth)):this._routeStyle.disableDashedLine!==!0&&(r&&this._maplibreMap.setPaintProperty($t,"line-color",r),s!==void 0&&s+""&&this._maplibreMap.setPaintProperty($t,"line-width",s)),d!==void 0&&d+""&&this._filterRouteOpacity(),p!==void 0&&p+""&&this._maplibreMap.setLayoutProperty(Qi,"icon-size",p),h&&Object.keys(h).length){const{from:b,to:g,stops:w}=h,B=this._maplibreMap.getSource(vr),T=await B.getData();T.features=T.features.map(H=>{const{markerType:N}=H.properties;if(b!==void 0&&N==="from"&&(H.properties.icon=b),g!==void 0&&N==="to"&&(H.properties.icon=g),w&&N.includes("stops")){const X=parseInt(N.split("_")[1]);H.properties.icon=w[X]??br(w)}return H}),B.setData(T)}if(I){const{image:b,size:g,spacing:w}=I;b!==void 0&&this._maplibreMap.setLayoutProperty(tn,"icon-image",b),g!==void 0&&g+""&&this._maplibreMap.setLayoutProperty(tn,"icon-size",g),w!==void 0&&w+""&&this._maplibreMap.setLayoutProperty(tn,"symbol-spacing",w)}u!==void 0&&u+""&&(this._maplibreMap.setPaintProperty(en,"line-opacity",["case",["==",["get","floor_id"],null],u,1]),this._maplibreMap.setPaintProperty(tn,"icon-opacity",["case",["==",["get","floor_id"],null],u,1]),this._filterRouteOpacity())}_filterRouteOpacity(){let t;switch(this._filterBy){case"venue":t=["case",["all",["==",["get","ordinal"],this._curOrdinal??""],["==",["get","venue_id"],this._curVenue??""]],1,["==",["get","floor_id"],null],this._routeStyle.outdoorLineOpacity,this._routeStyle.inactiveRouteOpacity];break;case"building":t=["case",["all",["==",["get","ordinal"],this._curOrdinal??""],["==",["get","building_id"],this._curBuilding??""]],1,["==",["get","floor_id"],null],this._routeStyle.outdoorLineOpacity,this._routeStyle.inactiveRouteOpacity];break}zc.forEach(n=>{this._maplibreMap.getLayer(n)&&this._maplibreMap.setPaintProperty(n,n.includes("layer-line")?"line-opacity":"icon-opacity",t)})}}function gt(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Number.isFinite(n)?n+"":n]))}function Jg(e){return e===100||e===-100}function Qg(e){return e===5}function em(e){return kc(e,104,108)}function Zc(e,t){const n={};for(const r in t){const i=e[r],o=t[r];if(r==="markers"||r==="lineSymbol")if(Array.isArray(o)){const s=o.slice(1,o.length-1);n[r]={from:o[0],to:br(o),stops:s.length?s:[o[0]]}}else{const s=Zc(i,o);Object.keys(s).length&&(n[r]=s)}else o+""!=i+""&&(n[r]=r==="stops"?o??[null]:o)}return n}class kn extends Error{}kn.prototype.name="InvalidTokenError";function tm(e){return decodeURIComponent(atob(e).replace(/(.)/g,(t,n)=>{let r=n.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r}))}function nm(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return tm(t)}catch{return atob(t)}}function rm(e,t){if(typeof e!="string")throw new kn("Invalid token specified: must be a string");t||(t={});const n=t.header===!0?0:1,r=e.split(".")[n];if(typeof r!="string")throw new kn(`Invalid token specified: missing part #${n+1}`);let i;try{i=nm(r)}catch(o){throw new kn(`Invalid token specified: invalid base64 for part #${n+1} (${o.message})`)}try{return JSON.parse(i)}catch(o){throw new kn(`Invalid token specified: invalid json for part #${n+1} (${o.message})`)}}const im="permission-disconnected";class ke extends Sr.TinyEmitter{static instance;static platform={sdkVersion:yn.version,identifier:""};_appIds=new Map([[St.Access,{}],[St.Map,{}]]);_tokenStorage={};_appIdsHistory=[];static getInstance(){return ke.instance||(ke.instance=new ke),ke.instance}static setPlatform(t){ke.platform=t}updateToken(t){const{appId:n,secret:r,token:i,from:o}=t;this._tokenStorage[n]=i,this._appIds.get(o)[n]=r,this._appIdsHistory.push(n)}deleteToken(t,n){delete this._tokenStorage[t],n&&(delete this._appIds.get(n)[t],this.emit(im,{appId:t,from:n}))}getVersion(){return ke.platform.sdkVersion}getToken(t){return this._tokenStorage[t]}async getIdentifier(){if(!ke.platform.identifier){const n=await(await Es.load()).get();ke.platform.identifier=n.visitorId}return ke.platform.identifier}getAppId(t){const n=t?Object.keys(this._appIds.get(t)):[...Object.keys(this._appIds.get(St.Access)),...Object.keys(this._appIds.get(St.Map))];return this._appIdsHistory.reverse().find(r=>n.includes(r))}async fetchToken(t,n,r=0){try{const i={appId:t,secret:n,..."bundleId"in ke.platform?{bundleId:ke.platform.bundleId}:"sha1"in ke.platform?{sha1:ke.platform.sha1,packageName:ke.platform.packageName}:{origin:window.location.hostname||"restriction.test.example.com",keyPlatform:"WEB"}},o={"Content-Type":"application/json",sdkVersion:ke.platform.sdkVersion,identifier:ke.platform.identifier??await this.getIdentifier()};return(await(await fetch(Go,{method:"POST",body:JSON.stringify(i),headers:o})).json()).result.idToken}catch(i){if(r<3){const o=500*Math.pow(2,r);return console.warn(`Retrying to fetch token in ${o} ms...`,++r),await new Promise(s=>setTimeout(s,o)),this.fetchToken(t,n,r)}else throw i}}}class om extends Sr.TinyEmitter{_appId=null;_secret=null;isClosed=!1;_timeoutId;_isInitialized=!1;_initializationPromise;_tokenManager=ke.getInstance();_from;constructor(t,n,r=St.Access){super(),this._from=r,this._appId=t,this._secret=n,this._initializationPromise=this._initToken()}async ready(){await this._initializationPromise}get appId(){return this._appId}get token(){if(!this._isInitialized)throw new Error("Token is not initialized yet. Use the 'ready' method to wait for initialization.");return this._tokenManager.getToken(this._appId)}close(){this.isClosed||(this._timeoutId&&clearTimeout(this._timeoutId),this._tokenManager.deleteToken(this._appId,this._from),this.emit("updated",{appId:this._appId,token:null}),Object.keys(this).forEach(t=>{t!=="isClosed"&&t!=="_events"&&delete this[t]}),this.isClosed=!0,this.emit("closed"),delete this._events,Object.freeze(this))}forceUpdateToken(){this._timeoutId&&(clearTimeout(this._timeoutId),this._timeoutId=null),this._isInitialized=!1,this._initializationPromise=this._initToken()}async _initToken(){try{const t=await this._tokenManager.fetchToken(this._appId,this._secret);this._isInitialized=!0,this._tokenManager.updateToken({appId:this._appId,secret:this._secret,token:t,from:this._from});const n=rm(t),r=(n.exp-n.iat-60)*1e3;this._loopUpdateToken(r)}catch(t){throw this.emit("error",new Error("Failed to initialize token.",{cause:t})),t}}_loopUpdateToken(t){this.isClosed||(this._timeoutId=setTimeout(async()=>{try{const n=await this._tokenManager.fetchToken(this._appId,this._secret);this._tokenManager.updateToken({appId:this._appId,secret:this._secret,token:n,from:this._from}),this.emit("updated",{appId:this._appId,token:n}),this._loopUpdateToken(t)}catch(n){this.emit("error",new Error("Failed to update token.",{cause:n}))}},t))}}const sm=yn.version,Wc=["unauthorized","initError"],eo=globalThis,to=Wt(...Wc);nt.getInstance().setGlobalDispatcher(to),eo.MapxusMapEvents=eo.MapxusMapEvents||{},eo.MapxusMapEvents.on=function(e,t){return to.on(e,t),{off:()=>to.on(e,null)}},_e.ASSISTANT_LAYER_INDOOR_FLOORS=nn,_e.ASSISTANT_LAYER_SHARED_FLOORS=je,_e.AccessControl=om,_e.AccessControlOrigin=St,_e.BuildingFilterControl=Rc,_e.BuildingSelectorHandler=Hc,_e.BuildingsService=gc,_e.DistanceSearchType=io,_e.ERRORS=Wc,_e.FloorSelectorHandler=Uc,_e.FloorsControl=Mc,_e.Indoor=xc,_e.IndoorClickSelection=$c,_e.Map=zg,_e.Marker=Wg,_e.OFFSET=Ge,_e.OrientationDistanceSearchType=Cr,_e.OutdoorClickSelection=Vc,_e.PAGE=ze,_e.Poi=Tc,_e.PoisOrderBy=oo,_e.PoisService=mc,_e.PoisSortBy=so,_e.PresetLanguage=De,_e.RoutePainter=Xg,_e.RouteService=ig,_e.SwitchBuildingHandler=Nc,_e.SwitchOutdoorHandler=Dc,_e.ThemeType=Lr,_e.VERSION=sm,_e.VehicleType=Ar,_e.VenuesService=yc,_e.__internal=Wf,_e.convertBrowserLangToPresetLang=ro,_e.getAccessToken=va,_e.getIdentifier=xs,_e.setGetTokenAsync=Qf,_e.setupTokenManager=eh,Object.defineProperty(_e,Symbol.toStringTag,{value:"Module"})}));
10
+ `}function sr(t){return`${Ht}/api/v3/tiles/styles/${t}`}class or extends Error{_status;constructor(e,i){super(e);const{cause:r,status:n,type:s}=i??{};this.name=typeof s=="string"?s:"CustomError",r!==void 0&&(this.cause=r),n!==void 0&&(this._status=n)}get status(){return this._status}}var Ft=(t=>(t.CHRISTMAS="christmas_mims2_v1",t.HALLOWEEN="halloween_mims2_v1",t.MAPPY_BEE="mappybee_mims2_v2",t.MAPXUS="mapxus_mims2_v1",t.LANDS_D="lands_d_mims2_v1",t.COMMON="common_mims2_v1",t.MAPXUS_V2="mapxus_v2",t.MAPXUS_DEFAULT="mapxus_v8",t.ROSE_TEA="rose_tea",t.PEAR_SORBET="pear_sorbet",t.CITY_WALK="city_walk",t.MOCHA_MOUSSE="mocha_mousse",t.SECTION_DISPLAY_BY_COLOR="mapxus_v7_with_section_v2",t.SECTION_DISPLAY_BY_CATEGORY="mapxus_v7_with_section_v3",t))(Ft||{});class ar{_buildingSelector;_isEnabled=!0;_position;constructor(e){this._buildingSelector=e}enable(){this._isEnabled=!0,this._buildingSelector.enabled||this._buildingSelector.setVisibility(!0)}disable(){this._isEnabled=!1,this._buildingSelector.enabled&&this._buildingSelector.setVisibility(!1)}setPosition(e,i){this._position=e,this._buildingSelector.changePosition(this._buildingSelector.position,e,i)}get isEnabled(){return this._isEnabled}get position(){return this._position}}class lr{_floorSelector;_isEnabled;_position;constructor(e){this._floorSelector=e,this._position=e.position,this._isEnabled=this._floorSelector.enabled}enable(){this._isEnabled=!0,this._floorSelector.setEnabled(!0)}disable(){this._isEnabled=!1,this._floorSelector.setEnabled(!1)}setPosition(e,i){this._position=e,this._floorSelector.changePosition(this._floorSelector.position,e,i)}setStyle(e){this._floorSelector.setStyle(e)}get isEnabled(){return this._isEnabled}get position(){return this._position}}class dr{_indoor;_isEnabled=!0;constructor(e){this._indoor=e}enable(){this._isEnabled=!0,this._indoor.setAllowBuildingSwitch(!0)}disable(){this._isEnabled=!1,this._indoor.setAllowBuildingSwitch(!1)}get isEnabled(){return this._isEnabled}}class ur{_indoor;_isEnabled=!0;constructor(e){this._indoor=e}enable(){this._isEnabled=!0,this._indoor.setAllowOutdoorSwitch(!0)}disable(){this._isEnabled=!1,this._indoor.setAllowOutdoorSwitch(!1)}get isEnabled(){return this._isEnabled}}class cr{_indoor;_isEnabled=!0;constructor(e){this._indoor=e}enable(){this._isEnabled=!0,this._indoor.setAllowIndoorClickSelect(!0)}disable(){this._isEnabled=!1,this._indoor.setAllowIndoorClickSelect(!1)}get isEnabled(){return this._isEnabled}}class hr{_indoor;_isEnabled=!0;constructor(e){this._indoor=e}enable(){this._isEnabled=!0,this._indoor.setAllowOutdoorClickSelect(!0)}disable(){this._isEnabled=!1,this._indoor.setAllowOutdoorClickSelect(!1)}get isEnabled(){return this._isEnabled}}const Ct="Map_mapClick",Ot="Map_pointClick",$t="Map_isRenderComplete",Ce="Map_isDestroyed",_e=D.getInstance();let Ha=class{_map;_indoor;_poi;_floorsControl;_buildingFilterControl;_attributionControl;_language;_dispatch=ye(Ct,Ot,$t,Ce);_fitBounds;_history=Y.getInstance();_debounceHTTPErrorHandler;_transformRequestHandler;_tokenRefreshingPromise=null;_cancelTokenChangedListener;isDestroyed=!1;switchOutdoor;outdoorClickSelection;switchBuilding;indoorClickSelection;buildingSelector;floorSelector;constructor(e){if(!e.map)throw new or("Parameter 'Map' is required!",{type:"TypeError"});_e.registerSDK(),this._permissionCheck().then(()=>{this._setup(e)}).catch(i=>{const r=i.cause?i.message+" "+i.cause.message:i.message;console.error(r)})}renderComplete(e){const i=te(`${$t}.`);this._dispatch.on(i,e)}destroyed(e){const i=te(`${Ce}.`);this._dispatch.on(i,()=>{e(),this._dispatch.on(i,null),this._dispatch._[Ce].length===0&&(delete this._dispatch,Object.freeze(this))})}setTransformRequest(e){this._transformRequestHandler=e}getIndoor(){return this._indoor}getMaplibre(){return this._map}get floor(){return this._indoor?.floor??null}get building(){return this._indoor?.building??null}get venue(){return this._indoor?.venue??null}setLanguage(e){this._language!==e&&(this._language=e);const n=(this._map?.getStyle()?.layers||[]).filter(({type:s})=>s==="symbol");for(const{id:s}of n){const o=this._map.getLayer(s),a=typeof this._map.getLayoutProperty(s,"text-field")=="string";o&&!a&&this._map.setLayoutProperty(s,"text-field",["coalesce",["get",`name:${e}`],["get","name"]])}}getLanguage(){return this._language}setOutdoorMapShown(e){this._indoor?.setOutdoorMapShown(e)}queryIndoorFeaturesByPoint(e){const{x:i,y:r}=e,n=this._map.queryRenderedFeatures([i,r],{layers:["mapxus-venue-fill","mapxus-building-line",me,x]}),s=n.find(l=>l.layer.id==="mapxus-venue-fill");if(!s)return null;const o=this._history.getHistoryOrdinal(s.properties.id),a=n.find(l=>l.properties?.ordinal===o);if(a){if(a.sourceLayer==="mapxus_shared_level")return{venue:s,sharedLevel:a};const l=n.find(d=>d.properties.id===a.properties["ref:building"]);return{venue:s,building:l,level:a}}}getIndoorFeaturesByCoordinates(e,i){const r=this._map.project(e),n=this._map.queryRenderedFeatures(r,{layers:["mapxus-venue-fill","mapxus-building-line","mapxus-level-fill","mapxus-level-fill-overlap-copy"]});if(n.length===0)return{venue:null,building:null,level:null};const o=n.filter(d=>d.layer.id.includes("mapxus-level-fill")).find(d=>Number.isFinite(i)?d.properties.ordinal===i+"":d.layer.id.startsWith("mapxus-level-fill"));if(!o)return{venue:null,building:null,level:null};const a=n.find(d=>d.properties.id===o.properties["ref:building"]);return{venue:n.find(d=>d.properties.id===a.properties["ref:venue"]),building:a,level:o}}getFeaturesById(e,i){return this._indoor?.getFeaturesById(e,i)||[]}async switchFloorByOrdinal(e){await this._indoor?.switchFloorByOrdinal(e)}async selectFloorById(e,i){const{dragPan:r=!0,animate:n=!0,fitBounds:s}=i||{},o=s??this._fitBounds,a=async()=>{const l=await _r(e),{maxLat:d,maxLon:u,minLat:h,minLon:c}=l?.bbox||{};this._indoor.dragPanHandler.setBounds([c,h,u,d])};if(this._indoor.setDragPan(r),this._indoor.setFitBounds(o),this._indoor.dragPanHandler.setAnimated(n),e===this.floor?.id){if(!r)return;o?(this._indoor.dragPanHandler.getBounds()||await a(),await this._indoor.dragPanHandler.fitBounds()):this._indoor.dragPanHandler.panToCenter()}else{let l=!1,d=(this._map.getLayer("mapxus-building-line")?this._map.queryRenderedFeatures({layers:["mapxus-building-line"]}):[]).find(h=>h.properties?.level_ids?.includes(e))??null;if(d&&d.properties?.id===this.building?.properties?.id){o&&!this._indoor.dragPanHandler.getBounds()&&await a();const{level_ids:h,ordinals:c}=d.properties,f=w(h).indexOf(e),g=w(c)[f]??null;await this._floorsControl.switchByOrdinal(g,r)}else{if(d)o&&await a();else{const h=await _r(e),{maxLat:c,maxLon:f,minLat:g,minLon:_}=h.bbox;l=!0,d=h.feature,this._indoor.dragPanHandler.setBounds([_,g,f,c])}await this._indoor.selectBuilding(d??null,{floorId:e,featureIncomplete:l})}}}async selectSharedFloorById(e,i){const{dragPan:r=!0,animate:n=!0,fitBounds:s}=i||{},o=s??this._fitBounds,a=async()=>{const l=await Na(e),{maxLat:d,maxLon:u,minLat:h,minLon:c}=l?.bbox||{};this._indoor.dragPanHandler.setBounds([c,h,u,d])};if(this._indoor.setDragPan(r),this._indoor.setFitBounds(o),this._indoor.dragPanHandler.setAnimated(n),e===this.floor?.id){if(!r)return;o?(this._indoor.dragPanHandler.getBounds()||await a(),await this._indoor.dragPanHandler.fitBounds()):this._indoor.dragPanHandler.panToCenter()}else{let l=!1,d,u;const h=(this._map.getLayer(x)?this._map.queryRenderedFeatures({layers:[x]}):[]).find(c=>c.properties?.id===e)??null;if(h)o&&await a();else{const c=await ti(e);u=Te(c),l=!0;const{maxLat:f,maxLon:g,minLat:_,minLon:y}=c?.bbox||{};this._indoor.dragPanHandler.setBounds([y,_,g,f]);const m=c.sharedFloors.find(({id:B})=>B===e),{id:S,name:E,ordinal:C}=m;d={id:S,name:E,ordinal:C+""}}if(!l){const{id:c,name:f,ordinal:g,"ref:venue":_}=h.properties||{};d={id:c,name:typeof f=="string"?{default:f}:f,ordinal:g},u=(this._map.getLayer("mapxus-venue-fill")?this._map.queryRenderedFeatures({layers:["mapxus-venue-fill"]}):[]).find(y=>y.properties?.id===_)??null}d&&u&&await this._indoor?.selectSharedFloor(d,u,{featureIncomplete:l})}}async selectBuildingById(e,i){const{dragPan:r=!0,animate:n=!0,fitBounds:s}=i||{},o=s??this._fitBounds,a=async()=>{const l=await De(e),{maxLat:d,maxLon:u,minLat:h,minLon:c}=l?.bbox||{};this._indoor.dragPanHandler.setBounds([c,h,u,d])};if(this._indoor.setDragPan(r),this._indoor.setFitBounds(o),this._indoor.dragPanHandler.setAnimated(n),e===this.building?.properties?.id){if(!r)return;o?(this._indoor.dragPanHandler.getBounds()||await a(),await this._indoor.dragPanHandler.fitBounds()):this._indoor.dragPanHandler.panToCenter()}else{let l=!1,d=(this._map.getLayer("mapxus-building-line")?this._map.queryRenderedFeatures({layers:["mapxus-building-line"]}):[]).find(u=>u.properties?.id===e)??null;if(d)o&&await a();else{const u=await De(e),{maxLat:h,maxLon:c,minLat:f,minLon:g}=u?.bbox||{};d=nt(u),l=!0,this._indoor.dragPanHandler.setBounds([g,f,c,h])}await this._indoor?.selectBuilding(d,{featureIncomplete:l})}}async selectVenueById(e,i){if(typeof e=="string"&&e.trim()===""||e===null){await this._indoor?.selectBuilding(null);return}const{dragPan:n=!0,animate:s=!0,fitBounds:o}=i||{},a=o??this._fitBounds,l=async()=>{const d=await He(e),{maxLat:u,maxLon:h,minLat:c,minLon:f}=d?.bbox||{};this._indoor.dragPanHandler.setBounds([f,c,h,u])};if(this._indoor.setDragPan(n),this._indoor.setFitBounds(a),this._indoor.dragPanHandler.setAnimated(s),e===this.venue?.properties?.id){if(!n)return;a?(this._indoor.dragPanHandler.getBounds()||await l(),await this._indoor.dragPanHandler.fitBounds()):this._indoor.dragPanHandler.panToCenter()}else{const d=this._history.getHistoryBuildingUnit(e);if(d){const{id:u,type:h}=d;h==="building"?await this.selectBuildingById(u,i):await this.selectSharedFloorById(u,i)}else{const u=(this._map.getLayer("mapxus-venue-fill")?this._map.queryRenderedFeatures({layers:["mapxus-venue-fill"]}):[]).find(c=>c.properties?.id===e)??null;let h;if(u){const{default_displayed_building:c,building_ids:f}=u.properties;h=c||w(f)[0]}else{const c=await He(e);h=c.defaultBuilding||c.buildings[0]?.id}await this.selectBuildingById(h,i)}}}onMapClickListener(e){const i=te(`${Ct}.`);return this._dispatch.on(i,e),{unsubscribe:()=>this._dispatch.on(i,null)}}onPoiClickListener(e){return this._poi?.onPoiClick(e)}onPointClickListener(e){const i=te(`${Ot}.`);return this._dispatch.on(i,e),{unsubscribe:()=>this._dispatch.on(i,null)}}onMapChangeListener(e){return this._indoor?.onMapChange(e)}switchTheme(e){this.setTheme(e)}setTheme(e){e!==_e.theme&&(this._setStyle(sr(e),{diff:!1}),_e.setTheme(e),this._map?.once("styledata",()=>{this._indoor.updateCustomLayers(),this._indoor.updateRendering()}),"changeTheme"in this._attributionControl&&this._attributionControl.changeTheme(e))}setSelectedBuildingBorderStyle(e){return this._indoor?.setSelectedHighlightStyle(e),this}setSelectedHighlightStyle(e){return this._indoor?.setSelectedHighlightStyle(e),this}setFloorSwitchScope(e){this._indoor?.setFloorSwitchScope(e)}async _setup(e){const{map:i,poiId:r,sharedFloorId:n,floorId:s,buildingId:o,venueId:a,theme:l=Ft.MAPXUS_DEFAULT,floorSelectorEnabled:d,buildingSelectorEnabled:u,outdoorMapShown:h=!0,collapseCopyright:c=!1,maskNonSelectedAreas:f=!1,fitBuildingBounds:g,fitBounds:_,boundsPadding:y=30,selectedHighlightStyle:m,floorSelectorStyle:S,language:E=Rr,autoSelectBuilding:C=!1,transformRequest:B=null,mapxusLogoEnabled:b=!0,enableIndoorClickSelection:O=!0,enableOutdoorClickSelection:$=!0,floorSwitchScope:P=xe.VENUE}=e;this._map=i,this._language=E,this._fitBounds=_??g??!1,this._indoor=new Wi({map:this._map,startWithIndoorView:!!(a||o||s||r||n),outdoorMapShown:h,fitBounds:this._fitBounds,boundsPadding:y,maskNonSelectedAreas:f,selectedHighlightStyle:m,enableIndoorClickSelection:O,enableOutdoorClickSelection:$,floorSwitchScope:P}),this._poi=new Zi(this._map),this._transformRequestHandler=B,await this._resourceRequestTransform(),this._installRtlTextPlugin(),this._setStyle(sr(l)),_e.setTheme(l),this._checkMapZoom(),c?this._attributionControl=new ka:(this._attributionControl=new Ra({theme:l}),this._addControl(new Ta({enabled:b}))),this._addControl(this._attributionControl),this._addControl(this._buildingFilterControl=new er(this,u)),this._addControl(this._floorsControl=new nr(this._indoor,{language:E,style:S,enabled:d})),r?this._selectPoiById(r):s?this.selectFloorById(s,{animate:!1}):o?this.selectBuildingById(o,{animate:!1}):a?this.selectVenueById(a,{animate:!1}):n&&this.selectSharedFloorById(n,{animate:!1}),this.switchOutdoor=new ur(this._indoor),this.switchBuilding=new dr(this._indoor),this.outdoorClickSelection=new hr(this._indoor),this.indoorClickSelection=new cr(this._indoor),this.buildingSelector=new ar(this._buildingFilterControl),this.floorSelector=new lr(this._floorsControl),this._map.once("styledata",()=>this.setLanguage(this._language)),this._map.on("remove",()=>this._destroy()),this._map.on("error",this._debounceHTTPErrorHandler=vt(L=>this._updatePermission(L),300)),this._indoor.once(It,()=>{C&&this._map.on("moveend",()=>this._selectCenterBuilding()),this._bindMapClickListener(),this._dispatch.call($t)})}_setStyle(e,i){this._map?.setStyle(e,{localIdeographFontFamily:!1,...i??{}})}_addControl(e,i){this._map.addControl(e,i)}async _selectPoiById(e){try{const i=await jr(e),{lon:r,lat:n}=i.location;"floorId"in i?await this.selectFloorById(i.floorId,{animate:!1}):"sharedFloorId"in i&&await this.selectSharedFloorById(i.sharedFloorId,{animate:!1}),this._map.panTo([r,n],{animate:!1})}catch(i){this._dispatchErrorGlobal("initError",i)}}async _resourceRequestTransform(){const e={"Content-Type":"application/json",sdkVersion:Je,identifier:await T.getIdentifier(),token:await T.getToken()};this._map.setTransformRequest((i,r)=>{const{host:n}=new URL(i);return n.includes("map-api")&&n.includes("mapxus")?{url:i,headers:e}:this._transformRequestHandler?this._transformRequestHandler(i,r):{url:i}})}_checkMapZoom(){const e=this._map.getZoom();(e<8||e>22)&&e>1&&console.warn("Indoor maps perform better at zoom levels [8, 22].")}async _updatePermission(e){if(e.error?.status===401)return this._tokenRefreshingPromise?this._tokenRefreshingPromise:(this._tokenRefreshingPromise=this._resourceRequestTransform().finally(()=>this._tokenRefreshingPromise=null),this._tokenRefreshingPromise)}_selectCenterBuilding(){const e=this._getCenterBuildingUnitsMap();if(!e.size)return;let i=e.entries().next().value[1];const r=this._history.getVisitedBuildingUnits().reverse();for(const n of r){const{id:s}=n;if(e.get(s)){i=n;break}}i.type==="building"?this.selectBuildingById(i.id,{dragPan:!1}):this.selectSharedFloorById(i.id,{dragPan:!1})}_getCenterBuildingUnitsMap(){const e=this._map.getCanvas().getBoundingClientRect(),i=e.width/4,r=e.height/4,n=[i,r],s=[e.width-i,e.height-r],o=["mapxus-building-line",x].filter(u=>this._map.getLayer(u)),a=this._map.queryRenderedFeatures([n,s],{layers:o}),d=qi(a,"properties.id").filter(u=>!this._indoor.layeredHandler.getHiddenBuildings().includes(u.properties.id));return new globalThis.Map(d.map(({properties:u})=>[`${u.id}`,{id:u.id,type:u.building?"building":"sharedFloor"}]))}_bindMapClickListener(){this._map.on("click",async e=>{const{point:i,lngLat:r}=e,n=await this._indoor.queryIndoorFeaturesByClickPoint(i);await this._indoor.selectByClickMap(n),this._dispatch.call(Ot,null,{point:i,coordinate:r}),this._dispatch.call(Ct,null,{coordinate:r,venue:n?.venue??null,building:n&&"building"in n?n.building:null,floor:n?"sharedFloor"in n?n.sharedFloor:n.floor??null:null})})}_dispatchErrorGlobal(e,i){const r=_e.getGlobalDispatcher();if(!r)return;const n=i.response?.status||i.status||"unknown",s=i.response?.data?.message||i.message||"unknown";r.call(e,null,{status:n,message:s})}_installRtlTextPlugin(){kt.getRTLTextPluginStatus()==="unavailable"&&kt.setRTLTextPlugin("https://unpkg.com/@mapbox/mapbox-gl-rtl-text@0.3.0/dist/mapbox-gl-rtl-text.js",!0)}async _permissionCheck(){try{if(!(await T.md5(T.SDKName.MapSDK)==="true"))throw new or("Permission invalid!",{status:403,type:"PermissionError"});return Promise.resolve()}catch(e){return this._dispatchErrorGlobal("unauthorized",e),this._dispatchErrorGlobal("initError",e),Promise.reject(e)}}_destroy(){if(this.isDestroyed)return;this.isDestroyed=!0,this._debounceHTTPErrorHandler?.cancel();const e=this._dispatch._;for(const i in e)i!==Ce&&e.hasOwnProperty(i)&&e[i].forEach(({name:r})=>{this._dispatch.on(`${i}.${r}`,null)});this._indoor.destroy(),this._poi.destroy(),_e.clear(),Object.keys(this).forEach(i=>{i!=="isDestroyed"&&i!=="_dispatch"&&delete this[i]}),this._cancelTokenChangedListener&&this._cancelTokenChangedListener(),this._dispatch.call(Ce)}};async function _r(t){const e=await Ur(t);return{feature:nt(e),bbox:e.bbox}}async function Na(t){const e=await ti(t);return{feature:Te(e),bbox:e.bbox}}async function Oe(t,e){if(!t.hasImage(e))try{const i=await t.loadImage(e);t.addImage(e,i.data)}catch(i){throw new Error(i)}}class Ua{_maplibreMap;_layerId;_sourceId;_imageName="poi-01";_imageSize=.75;_iconAnchor="bottom";constructor(e){this._maplibreMap=e;const i=te();this._layerId=`MXMap_preset_marker_layer_${i}`,this._sourceId=`MXMap_preset_marker_source_${i}`}async setIcon(e){if(typeof e!="string"||!e.trim())throw new Error("Icon must be a non-empty string.");await Oe(this._maplibreMap,e.trim()),this._imageName=e}setIconSize(e){this._imageSize=e}setIconAnchor(e){this._iconAnchor=e}get layerId(){return this._layerId}get sourceId(){return this._sourceId}create(e){if(!(Array.isArray(e)&&e.length))return;const i=e.map(r=>this._createIconFeature(r));this._addIconSource(i),this._addIconLayer()}updateData(e){const i=!!(e.remove&&e.remove.length),r=!!(e.add&&e.add.length),n=!!(e.update&&e.update.length),s=this._maplibreMap.getSource(this._sourceId);if(!i&&!r&&!n||!s)return;const o={};i&&(o.remove=e.remove),r&&(o.add=e.add.map(a=>this._createIconFeature(a))),n&&(o.update=e.update.map(a=>{const l=this._createIconFeature(a),{id:d,geometry:u,properties:h}=l;return{id:d,...u&&{newGeometry:u},...h&&{addOrUpdateProperties:Object.entries(h).map(([c,f])=>({key:c,value:f}))},...!u&&!h&&{removeAllProperties:!0}}})),s.updateData(o)}remove(){this._maplibreMap.getLayer(this._layerId)&&this._maplibreMap.removeLayer(this._layerId),this._maplibreMap.getSource(this._sourceId)&&this._maplibreMap.removeSource(this._sourceId)}on(e,i){const r=s=>this._handleEventListener(s,i),{unsubscribe:n}=this._maplibreMap.on(e,this._layerId,r);return{off:n}}setFilter(e){this._maplibreMap.getLayer(this._layerId)&&this._maplibreMap.setFilter(this._layerId,e)}setFilterByVenue(e,i){this._maplibreMap.getLayer(this._layerId)&&this._maplibreMap.setFilter(this._layerId,["any",["all",["==",["get","venueId"],e??""],["==",["get","ordinal"],i??""]],["all",["==",["get","venueId"],""],["==",["get","ordinal"],""]]])}setFilterByBuilding(e,i){this._maplibreMap.getLayer(this._layerId)&&this._maplibreMap.setFilter(this._layerId,["any",["all",["==",["get","buildingId"],e??""],["==",["get","ordinal"],i??""]],["all",["==",["get","buildingId"],""],["==",["get","ordinal"],""]]])}setOpacity(e){this._maplibreMap.getLayer(this._layerId)&&this._maplibreMap.setPaintProperty(this._layerId,"icon-opacity",e)}setOpacityByVenue(e,i,r){if(this._maplibreMap.getLayer(this._layerId)){const n=["case",["all",["==",["get","venueId"],e??""],["==",["get","ordinal"],i??""]],1,["all",["==",["get","venueId"],""],["==",["get","ordinal"],""]],1,r??.5];this._maplibreMap.setPaintProperty(this._layerId,"icon-opacity",n)}}setOpacityByBuilding(e,i,r){if(this._maplibreMap.getLayer(this._layerId)){const n=["case",["all",["==",["get","buildingId"],e??""],["==",["get","ordinal"],i??""]],1,["all",["==",["get","buildingId"],""],["==",["get","ordinal"],""]],1,r??.5];this._maplibreMap.setPaintProperty(this._layerId,"icon-opacity",n)}}_createIconFeature(e){const{lngLat:i,properties:r}=e;return{id:"featureId"in e?e.featureId:void 0,type:"Feature",...i&&{geometry:{type:"Point",coordinates:i}},...r&&{properties:r}}}_addIconSource(e){const i={type:"geojson",data:{type:"FeatureCollection",features:e}};this._maplibreMap.addSource(this._sourceId,i)}_addIconLayer(){this._maplibreMap.addLayer({id:this._layerId,type:"symbol",source:this._sourceId,layout:{"icon-image":this._imageName,"icon-size":this._imageSize,"icon-anchor":this._iconAnchor,"icon-allow-overlap":!0,"icon-ignore-placement":!0}})}_handleEventListener(e,i){const{point:r}=e,n=this._maplibreMap.queryRenderedFeatures(r,{layers:[this._layerId]});i(n[0])}}function Ye(t){var e=t==null?0:t.length;return e?t[e-1]:void 0}const At={indoorLineColor:"#45b1cc",outdoorLineColor:"#8183ba",dashedLineColor:"#969696",shuttleBusLineColor:"#fb923c",lineWidth:4,dashedLineWidth:4,disableDashedLine:!1,inactiveRouteOpacity:.5,outdoorLineOpacity:1,markerIconSize:.75,markers:{from:"poi-02",to:"poi-01",stops:["waypoint-01"]},lineSymbol:{image:"east-blue-arrow-01",size:.25,spacing:1}},Xe="mmws-source-line-solid",fe="mmws-layer-line-solid",pe="mmws-layer-icon-line-symbol",Mt="mmws-source-line-dashed",re="mmws-layer-line-dashed",xt="mmws-source-icon-connector",fr="mmws-layer-icon-connector",Qe="mmws-source-icon-marker",Tt="mmws-layer-icon-marker",pr=[fe,pe,re,fr,Tt],ja=[Xe,Mt,xt,Qe];class Va{_maplibreMap;_routeStyle=At;_styleDiffs={};_filterBy="venue";_curVenue=null;_curBuilding=null;_curOrdinal=null;_renderBoundaryLayer;constructor(e,i){this._maplibreMap=e,i&&(this._updateStyleProperties(i),e.on("load",()=>this._loadMarkerIcons()))}async setStyle(e){this._updateStyleProperties(e),await this._loadMarkerIcons(),await this._updateLayers()}async setMarkerIcons(e){if(Array.isArray(e)&&e.length){const i=e.slice(1,e.length-1);this._routeStyle.markers={from:e[0],to:Ye(e),stops:i.length?i:[e[0]]},this._styleDiffs={markers:this._routeStyle.markers}}else"from"in e&&(this._routeStyle.markers.from=e.from,this._styleDiffs.markers.from=e.from),"to"in e&&(this._routeStyle.markers.to=e.to,this._styleDiffs.markers.to=e.to),"stops"in e&&(this._routeStyle.markers.stops=e.stops??[null],this._styleDiffs.markers.stops=e.stops??[null]);await this._loadMarkerIcons()}setMarkerIconSize(e){return this._routeStyle.markerIconSize=e,this}setIndoorLineColor(e){return this._routeStyle.indoorLineColor=e,this}setOutdoorLineColor(e){return this._routeStyle.outdoorLineColor=e,this}setDashedLineColor(e){return this._routeStyle.dashedLineColor=e,this}setBusLineColor(e){return this._routeStyle.shuttleBusLineColor=e,this}render(e,i){if(!this._renderBoundaryLayer){const d=this._maplibreMap.getStyle(),u=it(d);let h=u.find(({type:c,id:f})=>!f.includes("-overlap-copy")&&c==="fill-extrusion");h||(h=u.find(c=>c.type==="symbol"&&c?.["source-layer"]==="mapxus_place")),this._renderBoundaryLayer=h?.id}const{instructions:r,points:{coordinates:n}}=e,{lineFeatures:s,connectorFeatures:o,dashedLineFeatures:a,markerFeatures:l}=this._classifyFeatures(r,n,i);this._renderSolidLines(s),this._renderLineSymbols(Xe,pe),this._routeStyle.disableDashedLine!==!0&&this._renderDashedLines(a),this._renderConnectors(o),this._renderMarkers(l)}remove(){pr.forEach(e=>{this._maplibreMap.getLayer(e)&&this._maplibreMap.removeLayer(e)}),ja.forEach(e=>{this._maplibreMap.getSource(e)&&this._maplibreMap.removeSource(e)})}setFilterByVenue(e,i){this._filterBy="venue",this._curVenue=e??null,this._curOrdinal=i??null,this._filterRouteOpacity()}setFilterByBuilding(e,i){this._filterBy="building",this._curBuilding=e??null,this._curOrdinal=i??null,this._filterRouteOpacity()}_classifyFeatures(e,i,r){const n=[],s=[],o=[],a=[],l=[];e.forEach(($,P)=>{const{venue_id:L,building_id:H,floor_id:A,ordinal:K,sign:ne,type:ge,interval:[Ze,$e]}=$;if(qa(ne))l.push($);else if(za(ne)){P!==0&&P!==e.length-1&&s.push(this._createIconFeature(`connector-${s.length}`,i[Ze],{...G({venue_id:L,building_id:H,floor_id:A,ordinal:K}),icon:ge}));const yr=e[P+1];if(yr){const{venue_id:Xa,building_id:Qa,floor_id:Za,ordinal:Ja}=yr;s.push(this._createIconFeature(`connector-${s.length}`,i[$e],{...G({venue_id:Xa,building_id:Qa,floor_id:Za,ordinal:Ja}),icon:ge}))}}else n.push(this._createLineFeature(`solid-line-${n.length}`,i.slice(Ze,$e+1),G({venue_id:L,building_id:H,floor_id:A,ordinal:K,isShuttleBus:Ga(ne)?1:0})))});const d=e[0],{venue_id:u,building_id:h,floor_id:c,ordinal:f}=d,g=e[e.length-1],{venue_id:_,building_id:y,floor_id:m,ordinal:S}=g,E=i[0],C=i[i.length-1],B=r[0],b=r[r.length-1],O=r.slice(1,r.length-1);return B&&o.push(this._createLineFeature(`dashed-line-${o.length}`,[B,E],G({venue_id:u,building_id:h,floor_id:c,ordinal:f}))),b&&o.push(this._createLineFeature(`dashed-line-${o.length}`,[C,b],G({venue_id:_,building_id:y,floor_id:m,ordinal:S}))),l.length&&O.length&&l.forEach(({venue_id:$,building_id:P,floor_id:L,ordinal:H,interval:[A]},K)=>{o.push(this._createLineFeature(`dashed-line-${o.length}`,[i[A],O[K]],G({venue_id:$,building_id:P,floor_id:L,ordinal:H}))),a.push(this._createIconFeature(`marker-${a.length}`,O[K],{...G({venue_id:$,building_id:P,floor_id:L,ordinal:H,markerType:`stops_${K}`}),icon:this._routeStyle.markers.stops[K]??Ye(this._routeStyle.markers.stops),iconSize:this._routeStyle.markerIconSize}))}),a.push(this._createIconFeature(`marker-${a.length}`,B??E,{...G({venue_id:u,building_id:h,floor_id:c,ordinal:f,markerType:"from"}),icon:this._routeStyle.markers.from,iconSize:this._routeStyle.markerIconSize})),a.push(this._createIconFeature(`marker-${a.length}`,b??C,{...G({venue_id:_,building_id:y,floor_id:m,ordinal:S,markerType:"to"}),icon:this._routeStyle.markers.to,iconSize:this._routeStyle.markerIconSize})),{lineFeatures:n,connectorFeatures:s,dashedLineFeatures:o,markerFeatures:a}}_createLineFeature(e,i,r){return{id:e,type:"Feature",geometry:{type:"LineString",coordinates:i},properties:r}}_createIconFeature(e,i,r){return{id:e,type:"Feature",geometry:{type:"Point",coordinates:i},properties:r}}_renderSolidLines(e){this._addCollectionSource(Xe,e),this._addLineLayer(Xe,fe,{"line-color":["case",["==",["get","isShuttleBus"],"1"],this._routeStyle.shuttleBusLineColor,["==",["get","floor_id"],null],this._routeStyle.outdoorLineColor,this._routeStyle.indoorLineColor],"line-opacity":["case",["==",["get","floor_id"],null],this._routeStyle.outdoorLineOpacity,1],"line-width":this._routeStyle.lineWidth})}_renderDashedLines(e){this._addCollectionSource(Mt,e),this._addLineLayer(Mt,re,{"line-color":this._routeStyle.dashedLineColor,"line-width":this._routeStyle.dashedLineWidth,"line-dasharray":[.1,1.8]})}_renderConnectors(e){this._addCollectionSource(xt,e),this._addIconLayer(xt,fr)}_renderMarkers(e){this._addCollectionSource(Qe,e),this._addIconLayer(Qe,Tt,{"icon-anchor":"bottom","icon-allow-overlap":!0,"icon-ignore-placement":!0})}_addCollectionSource(e,i){this._maplibreMap.addSource(e,{type:"geojson",data:{type:"FeatureCollection",features:i}})}_addLineLayer(e,i,r){this._maplibreMap.addLayer({id:i,type:"line",source:e,layout:{"line-join":"round","line-cap":"round"},paint:{"line-width":4,...r||{}}},this._renderBoundaryLayer)}_renderLineSymbols(e,i){this._maplibreMap.addLayer({id:i,type:"symbol",source:e,layout:{"symbol-placement":"line","symbol-spacing":this._routeStyle.lineSymbol.spacing,"icon-size":this._routeStyle.lineSymbol.size,"icon-image":this._routeStyle.lineSymbol.image},paint:{"icon-opacity":["case",["==",["get","floor_id"],null],this._routeStyle.outdoorLineOpacity,1]}},this._renderBoundaryLayer)}_addIconLayer(e,i,r){this._maplibreMap.addLayer({id:i,type:"symbol",source:e,layout:{"icon-image":["get","icon"],"icon-size":["case",["has","iconSize"],["get","iconSize"],1],...r||{}}})}_updateStyleProperties(e){if(this._styleDiffs=gr(this._routeStyle,e??At),!e)this._routeStyle=At;else if(Object.keys(this._styleDiffs).length){const i={...this._routeStyle.lineSymbol,...this._styleDiffs.lineSymbol??{}},r=this._styleDiffs.markers;let n=this._routeStyle.markers;const s={outdoorLineOpacity:(this._styleDiffs.outdoorLineOpacity>1?1:this._styleDiffs.outdoorLineOpacity<0?0:this._styleDiffs.outdoorLineOpacity)??this._routeStyle.outdoorLineOpacity},o={inactiveRouteOpacity:(this._styleDiffs.inactiveRouteOpacity>1?1:this._styleDiffs.inactiveRouteOpacity<0?0:this._styleDiffs.inactiveRouteOpacity)??this._routeStyle.inactiveRouteOpacity};r&&Object.keys(r).length&&(n={...n,...r}),this._routeStyle={...this._routeStyle,...this._styleDiffs,...s,...o,markers:n,lineSymbol:i}}}async _loadMarkerIcons(){const{markers:e,lineSymbol:i}=this._styleDiffs;if(i?.image&&await Oe(this._maplibreMap,i.image),e&&Object.keys(e).length){const{from:r,to:n,stops:s}=e;if(r&&await Oe(this._maplibreMap,r),n&&await Oe(this._maplibreMap,n),s&&s.length){const o=s.filter(a=>!!a);o.length&&await Promise.all(o.map(a=>Oe(this._maplibreMap,a)))}}}async _updateLayers(){if(!this._maplibreMap.getLayer(fe))return;const{indoorLineColor:e,outdoorLineColor:i,dashedLineColor:r,shuttleBusLineColor:n,lineWidth:s,dashedLineWidth:o,disableDashedLine:a,inactiveRouteOpacity:l,outdoorLineOpacity:d,markerIconSize:u,markers:h,lineSymbol:c}=this._styleDiffs;if((e||i||n)&&this._maplibreMap.setPaintProperty(fe,"line-color",["case",["==",["get","isShuttleBus"],"1"],this._routeStyle.shuttleBusLineColor,["==",["get","floor_id"],null],this._routeStyle.outdoorLineColor,this._routeStyle.indoorLineColor]),s!==void 0&&s+""&&this._maplibreMap.setPaintProperty(fe,"line-width",s),typeof a=="boolean"?a?this._maplibreMap.setPaintProperty(re,"line-color","transparent"):(this._maplibreMap.setPaintProperty(re,"line-color",this._routeStyle.dashedLineColor),this._maplibreMap.setPaintProperty(re,"line-width",this._routeStyle.dashedLineWidth)):this._routeStyle.disableDashedLine!==!0&&(r&&this._maplibreMap.setPaintProperty(re,"line-color",r),o!==void 0&&o+""&&this._maplibreMap.setPaintProperty(re,"line-width",o)),l!==void 0&&l+""&&this._filterRouteOpacity(),u!==void 0&&u+""&&this._maplibreMap.setLayoutProperty(Tt,"icon-size",u),h&&Object.keys(h).length){const{from:f,to:g,stops:_}=h,y=this._maplibreMap.getSource(Qe),m=await y.getData();m.features=m.features.map(S=>{const{markerType:E}=S.properties;if(f!==void 0&&E==="from"&&(S.properties.icon=f),g!==void 0&&E==="to"&&(S.properties.icon=g),_&&E.includes("stops")){const C=parseInt(E.split("_")[1]);S.properties.icon=_[C]??Ye(_)}return S}),y.setData(m)}if(c){const{image:f,size:g,spacing:_}=c;f!==void 0&&this._maplibreMap.setLayoutProperty(pe,"icon-image",f),g!==void 0&&g+""&&this._maplibreMap.setLayoutProperty(pe,"icon-size",g),_!==void 0&&_+""&&this._maplibreMap.setLayoutProperty(pe,"symbol-spacing",_)}d!==void 0&&d+""&&(this._maplibreMap.setPaintProperty(fe,"line-opacity",["case",["==",["get","floor_id"],null],d,1]),this._maplibreMap.setPaintProperty(pe,"icon-opacity",["case",["==",["get","floor_id"],null],d,1]),this._filterRouteOpacity())}_filterRouteOpacity(){let e;switch(this._filterBy){case"venue":e=["case",["all",["==",["get","ordinal"],this._curOrdinal??""],["==",["get","venue_id"],this._curVenue??""]],1,["==",["get","floor_id"],null],this._routeStyle.outdoorLineOpacity,this._routeStyle.inactiveRouteOpacity];break;case"building":e=["case",["all",["==",["get","ordinal"],this._curOrdinal??""],["==",["get","building_id"],this._curBuilding??""]],1,["==",["get","floor_id"],null],this._routeStyle.outdoorLineOpacity,this._routeStyle.inactiveRouteOpacity];break}pr.forEach(i=>{this._maplibreMap.getLayer(i)&&this._maplibreMap.setPaintProperty(i,i.includes("layer-line")?"line-opacity":"icon-opacity",e)})}}function G(t){return Object.fromEntries(Object.entries(t).map(([e,i])=>[e,Number.isFinite(i)?i+"":i]))}function za(t){return t===100||t===-100}function qa(t){return t===5}function Ga(t){return rr(t,104,108)}function gr(t,e){const i={};for(const r in e){const n=t[r],s=e[r];if(r==="markers"||r==="lineSymbol")if(Array.isArray(s)){const o=s.slice(1,s.length-1);i[r]={from:s[0],to:Ye(s),stops:o.length?o:[s[0]]}}else{const o=gr(n,s);Object.keys(o).length&&(i[r]=o)}else s+""!=n+""&&(i[r]=r==="stops"?s??[null]:s)}return i}var Rt=(t=>(t.FOOT="foot",t.WHEELCHAIR="wheelchair",t.ESCALATOR="escalator",t.EMERGENCY="emergency",t))(Rt||{});const Ka=D.getInstance();class Wa{_api="api/v4/route/query";constructor(){}async search(e){const{points:i,vehicle:r=Rt.FOOT,locale:n="en"}=e;if(!(i&&i.length>1&&i.length<6))throw new Error("Parameter error. It must be 1 < {points.length} < 6");if(Ya(i))throw new Error("Parameter error. Points must have lat and lon.");return(await Ka.getHttpSession()).request(this._api,{method:"POST",body:JSON.stringify({points:i,vehicle:r,locale:n})})}}function Ya(t){return t.some(e=>!e||typeof e.lat!="number"||typeof e.lon!="number")}p.ASSISTANT_LAYER_INDOOR_FLOORS=me,p.ASSISTANT_LAYER_SHARED_FLOORS=x,p.BuildingFilterControl=er,p.BuildingSelectorHandler=ar,p.BuildingsService=Zt,p.DistanceSearchType=qt,p.ERRORS=Nt,p.FloorSelectorHandler=lr,p.FloorSwitchScope=xe,p.FloorsControl=nr,p.Indoor=Wi,p.IndoorClickSelection=cr,p.Map=Ha,p.Marker=Ua,p.OFFSET=R,p.OrientationDistanceSearchType=st,p.OutdoorClickSelection=hr,p.PAGE=k,p.Poi=Zi,p.PoisOrderBy=Gt,p.PoisService=Wt,p.PoisSortBy=Kt,p.PresetLanguage=M,p.RoutePainter=Va,p.RouteService=Wa,p.SwitchBuildingHandler=dr,p.SwitchOutdoorHandler=ur,p.ThemeType=Ft,p.VERSION=Je,p.VehicleType=Rt,p.VenuesService=Xt,p.convertBrowserLangToPresetLang=jt,p.omittedBuildingProps=Qt,p.omittedPoiProps=ot,p.omittedVenueKeys=Yt,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})}));