"use strict";var Pt=Object.defineProperty;var Ct=(s,e,t)=>e in s?Pt(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var c=(s,e,t)=>(Ct(s,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function ye(s,e){let t;const r=()=>{t!==void 0&&e&&e(t),t=void 0};return[()=>t===void 0?t=s(r):t,r]}function K(s){const e=L(),{count:t}=e;e.unsubscribe(s),t&&!e.count&&Bt()}function Ee(s){return L().subscribe(s),()=>K(s)}class Rt{constructor(e,t={}){this.scope=e,this.options=t}print(e,...t){const r=new Date,n=Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3,timeZone:"UTC"}).format(r),{textColor:i,bgColor:o}=this.options,a="font-weight: bold;padding: 0 5px;border-radius:5px";console[e](`%c${n}%c / %c${this.scope}`,`${a};background-color: lightblue;color:black`,"",`${a};${i?`color:${i};`:""}${o?`background-color:${o}`:""}`,...t)}error(...e){this.print("error",...e)}log(...e){this.print("log",...e)}}const Q=new Rt("SDK",{bgColor:"forestgreen",textColor:"white"});let z=!1;const ge=({name:s,payload:e})=>{Q.log("Event received:",e?{name:s,payload:e}:{name:s})};function Tt(s){z!==s&&(z=s,s?Ee(ge):K(ge))}function It(...s){z&&Q.log(...s)}class S{constructor(){c(this,"listeners",new Map);c(this,"listenersCount",0);c(this,"subscribeListeners",[])}clear(){this.listeners.clear(),this.subscribeListeners=[]}get count(){return this.listenersCount+this.subscribeListeners.length}emit(e,...t){this.subscribeListeners.forEach(n=>n({event:e,args:t})),(this.listeners.get(e)||[]).forEach(([n,i])=>{n(...t),i&&this.off(e,n)})}on(e,t,r){let n=this.listeners.get(e);return n||this.listeners.set(e,n=[]),n.push([t,r]),this.listenersCount+=1,()=>this.off(e,t)}off(e,t){const r=this.listeners.get(e)||[];for(let n=0;nthis.unsubscribe(e)}unsubscribe(e){for(let t=0;twindow.removeEventListener(s,e,t)}function X(...s){let e=!1;const t=s.flat(1);return[r=>!e&&t.push(r),()=>{e||(e=!0,t.forEach(r=>r()))},e]}class k extends Error{constructor(e,t,r){super(t,{cause:r}),this.type=e,Object.setPrototypeOf(this,k.prototype)}}function f(s,e,t){return new k(s,e,t)}const ve="ERR_METHOD_UNSUPPORTED",Se="ERR_METHOD_PARAMETER_UNSUPPORTED",Pe="ERR_UNKNOWN_ENV",Ce="ERR_INVOKE_CUSTOM_METHOD_RESPONSE",Re="ERR_TIMED_OUT",Te="ERR_UNEXPECTED_TYPE",Z="ERR_PARSE",Ie="ERR_NAVIGATION_LIST_EMPTY",xe="ERR_NAVIGATION_CURSOR_INVALID",xt="ERR_NAVIGATION_ITEM_INVALID",At="ERR_SSR_INIT",Ae="ERR_INVALID_PATH_BASE";function R(){return f(Te,"Value has unexpected type")}class M{constructor(e,t,r){this.parser=e,this.isOptional=t,this.type=r}parse(e){if(!(this.isOptional&&e===void 0))try{return this.parser(e)}catch(t){throw f(Z,`Unable to parse value${this.type?` as ${this.type}`:""}`,t)}}optional(){return this.isOptional=!0,this}}function T(s,e){return()=>new M(s,!1,e)}const w=T(s=>{if(typeof s=="boolean")return s;const e=String(s);if(e==="1"||e==="true")return!0;if(e==="0"||e==="false")return!1;throw R()},"boolean");function Ne(s,e){const t={};for(const r in s){const n=s[r];if(!n)continue;let i,o;if(typeof n=="function"||"parse"in n)i=r,o=typeof n=="function"?n:n.parse.bind(n);else{const{type:a}=n;i=n.from||r,o=typeof a=="function"?a:a.parse.bind(a)}try{const a=o(e(i));a!==void 0&&(t[r]=a)}catch(a){throw f(Z,`Unable to parse field "${r}"`,a)}}return t}function qe(s){let e=s;if(typeof e=="string"&&(e=JSON.parse(e)),typeof e!="object"||e===null||Array.isArray(e))throw R();return e}function g(s,e){return new M(t=>{const r=qe(t);return Ne(s,n=>r[n])},!1,e)}const y=T(s=>{if(typeof s=="number")return s;if(typeof s=="string"){const e=Number(s);if(!Number.isNaN(e))return e}throw R()},"number"),h=T(s=>{if(typeof s=="string"||typeof s=="number")return s.toString();throw R()},"string");function ke(s){return g({eventType:h(),eventData:e=>e}).parse(s)}function Nt(){["CyberFlowGameProxy_receiveEvent","CyberFlowGameProxy","CyberFlow"].forEach(s=>{delete window[s]})}function Y(s,e){window.dispatchEvent(new MessageEvent("message",{data:JSON.stringify({eventType:s,eventData:e}),source:window.parent}))}function qt(){[["CyberFlowGameProxy_receiveEvent"],["CyberFlowGameProxy","receiveEvent"],["CyberFlow","WebView","receiveEvent"]].forEach(s=>{let e=window;s.forEach((t,r,n)=>{if(r===n.length-1){e[t]=Y;return}t in e||(e[t]={}),e=e[t]})})}const kt={clipboard_text_received:g({req_id:h(),data:s=>s===null?s:h().optional().parse(s)}),custom_method_invoked:g({req_id:h(),result:s=>s,error:h().optional()}),popup_closed:{parse(s){return g({button_id:e=>e==null?void 0:h().parse(e)}).parse(s??{})}},viewport_changed:g({height:y(),width:s=>s==null?window.innerWidth:y().parse(s),is_state_stable:w(),is_expanded:w()})};function Dt(){const s=new S,e=new S;e.subscribe(r=>{s.emit("event",{name:r.event,payload:r.args[0]})}),qt();const[,t]=X(Nt,J("resize",()=>{e.emit("viewport_changed",{width:window.innerWidth,height:window.innerHeight,is_state_stable:!0,is_expanded:!0})}),J("message",r=>{if(r.source!==window.parent)return;let n;try{n=ke(r.data)}catch{return}const{eventType:i,eventData:o}=n,a=kt[i];try{const p=a?a.parse(o):o;e.emit(...p?[i,p]:[i])}catch(p){Q.error(`An error occurred processing the "${i}" event from the Cyberflow application. Please, file an issue here: https://github.com/cyberFlowTech/cyberflow-apps/issues/new/choose`,n,p)}}),()=>s.clear(),()=>e.clear());return[{on:e.on.bind(e),off:e.off.bind(e),subscribe(r){return s.on("event",r)},unsubscribe(r){s.off("event",r)},get count(){return e.count+s.count}},t]}const[Vt,Bt]=ye(s=>{const[e,t]=Dt(),r=e.off.bind(e);return e.off=(n,i)=>{const{count:o}=e;r(n,i),o&&!e.count&&s()},[e,t]},([,s])=>s());function L(){return Vt()[0]}function D(s,e){L().off(s,e)}function b(s,e,t){return L().on(s,e,t)}function V(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}function De(s,e){const t=s.split("."),r=e.split("."),n=Math.max(t.length,r.length);for(let i=0;ia?1:-1}return 0}function _(s,e){return De(s,e)<=0}function E(s,e,t){if(typeof t=="string"){if(s==="web_app_open_link"){if(e==="try_instant_view")return _("6.4",t);if(e==="try_browser")return _("7.6",t)}if(s==="web_app_set_header_color"&&e==="color")return _("6.9",t);if(s==="web_app_close"&&e==="return_back")return _("7.6",t)}switch(s){case"web_app_open_tg_link":case"web_app_open_invoice":case"web_app_setup_back_button":case"web_app_set_background_color":case"web_app_set_header_color":case"web_app_trigger_haptic_feedback":return _("6.1",e);case"web_app_open_popup":return _("6.2",e);case"web_app_close_scan_qr_popup":case"web_app_open_scan_qr_popup":case"web_app_read_text_from_clipboard":return _("6.4",e);case"web_app_switch_inline_query":return _("6.7",e);case"web_app_invoke_custom_method":case"web_app_request_write_access":case"web_app_request_phone":return _("6.9",e);case"web_app_setup_settings_button":return _("6.10",e);case"web_app_biometry_get_info":case"web_app_biometry_open_settings":case"web_app_biometry_request_access":case"web_app_biometry_request_auth":case"web_app_biometry_update_token":return _("7.2",e);case"web_app_setup_swipe_behavior":return _("7.7",e);default:return["iframe_ready","iframe_will_reload","web_app_close","web_app_data_send","web_app_expand","web_app_open_link","web_app_ready","web_app_request_theme","web_app_request_viewport","web_app_setup_main_button","web_app_setup_closing_behavior"].includes(s)}}function Ve(s){return"external"in s&&V(s.external)&&"notify"in s.external&&typeof s.external.notify=="function"}function Be(s){return"CyberFlowWebviewProxy"in s&&V(s.CyberFlowWebviewProxy)&&"postEvent"in s.CyberFlowWebviewProxy&&typeof s.CyberFlowWebviewProxy.postEvent=="function"}function ee(){try{return window.self!==window.top}catch{return!0}}const Mt="https://web.cyberflow.social";let Me=Mt;function Lt(s){Me=s}function Le(){return Me}function P(s,e,t){let r={},n;if(!e&&!t?r={}:e&&t?(r=t,n=e):e&&("targetOrigin"in e?r=e:n=e),It("Posting event:",n?{event:s,data:n}:{event:s}),ee())return window.parent.postMessage(JSON.stringify({eventType:s,eventData:n}),r.targetOrigin||Le());if(Ve(window)){window.external.notify(JSON.stringify({eventType:s,eventData:n}));return}if(Be(window)){window.CyberFlowWebviewProxy.postEvent(s,JSON.stringify(n));return}throw f(Pe,"Unable to determine current environment and possible way to send event. You are probably trying to use Mini Apps method outside the Cyberflow application environment.")}function Oe(s){return(e,t)=>{if(!E(e,s))throw f(ve,`Method "${e}" is unsupported in Mini Apps version ${s}`);if(V(t)&&e==="web_app_set_header_color"&&"color"in t&&!E(e,"color",s))throw f(Se,`Parameter "color" of "${e}" method is unsupported in Mini Apps version ${s}`);return P(e,t)}}function te(s){return({req_id:e})=>e===s}function Ue(s){return f(Re,`Timeout reached: ${s}ms`)}function se(s,e){return Promise.race([typeof s=="function"?s():s,new Promise((t,r)=>{setTimeout(()=>{r(Ue(e))},e)})])}async function d(s){let e;const t=new Promise(a=>e=a),{event:r,capture:n,timeout:i}=s,[,o]=X((Array.isArray(r)?r:[r]).map(a=>b(a,p=>{(!n||(Array.isArray(r)?n({event:a,payload:p}):n(p)))&&e(p)})));try{return(s.postEvent||P)(s.method,s.params),await(i?se(t,i):t)}finally{o()}}async function v(s,e,t,r={}){const{result:n,error:i}=await d({...r,method:"web_app_invoke_custom_method",event:"custom_method_invoked",params:{method:s,params:e,req_id:t},capture:te(t)});if(i)throw f(Ce,i);return n}function B(...s){return s.map(e=>{if(typeof e=="string")return e;if(V(e))return B(Object.entries(e).map(t=>t[1]&&t[0]));if(Array.isArray(e))return B(...e)}).filter(Boolean).join(" ")}function Ot(...s){return s.reduce((e,t)=>(V(t)&&Object.entries(t).forEach(([r,n])=>{const i=B(e[r],n);i.length&&(e[r]=i)}),e),{})}function O(s){return/^#[\da-f]{6}$/i.test(s)}function $e(s){return/^#[\da-f]{3}$/i.test(s)}function re(s){const e=s.replace(/\s/g,"").toLowerCase();if(O(e))return e;if($e(e)){let r="#";for(let n=0;n<3;n+=1)r+=e[1+n].repeat(2);return r}const t=e.match(/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/)||e.match(/^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),\d{1,3}\)$/);if(!t)throw new Error(`Value "${s}" does not satisfy any of known RGB formats.`);return t.slice(1).reduce((r,n)=>{const i=parseInt(n,10).toString(16);return r+(i.length===1?"0":"")+i},"#")}function ne(s){const e=re(s);return Math.sqrt([.299,.587,.114].reduce((t,r,n)=>{const i=parseInt(e.slice(1+n*2,1+(n+1)*2),16);return t+i*i*r},0))<120}class Ut{constructor(e){c(this,"ee",new S);c(this,"on",this.ee.on.bind(this.ee));c(this,"off",this.ee.off.bind(this.ee));this.state=e}clone(){return{...this.state}}set(e,t){Object.entries(typeof e=="string"?{[e]:t}:e).reduce((n,[i,o])=>this.state[i]===o||o===void 0?n:(this.state[i]=o,this.ee.emit(`change:${i}`,o),!0),!1)&&this.ee.emit("change",this.state)}get(e){return this.state[e]}}class ie{constructor(e){c(this,"state");c(this,"get");c(this,"set");c(this,"clone");this.state=new Ut(e),this.set=this.state.set.bind(this.state),this.get=this.state.get.bind(this.state),this.clone=this.state.clone.bind(this.state)}}function We(s,e){return t=>E(e[t],s)}class oe extends ie{constructor(t,r,n){super(t);c(this,"supports");this.supports=We(r,n)}}class He extends oe{constructor(t,r,n){super({isVisible:t},r,{show:"web_app_setup_back_button",hide:"web_app_setup_back_button"});c(this,"on",(t,r)=>t==="click"?b("back_button_pressed",r):this.state.on(t,r));c(this,"off",(t,r)=>t==="click"?D("back_button_pressed",r):this.state.off(t,r));this.postEvent=n}set isVisible(t){this.set("isVisible",t),this.postEvent("web_app_setup_back_button",{is_visible:t})}get isVisible(){return this.get("isVisible")}hide(){this.isVisible=!1}show(){this.isVisible=!0}}const ae=T(s=>s instanceof Date?s:new Date(y().parse(s)*1e3),"Date");function U(s,e){return new M(t=>{if(typeof t!="string"&&!(t instanceof URLSearchParams))throw R();const r=typeof t=="string"?new URLSearchParams(t):t;return Ne(s,n=>{const i=r.get(n);return i===null?void 0:i})},!1,e)}const $t=g({id:y(),type:h(),title:h(),photoUrl:{type:h().optional(),from:"photo_url"},username:h().optional()},"Chat").optional(),be=g({addedToAttachmentMenu:{type:w().optional(),from:"added_to_attachment_menu"},allowsWriteToPm:{type:w().optional(),from:"allows_write_to_pm"},firstName:{type:h(),from:"first_name"},id:y(),isBot:{type:w().optional(),from:"is_bot"},isPremium:{type:w().optional(),from:"is_premium"},languageCode:{type:h().optional(),from:"language_code"},lastName:{type:h().optional(),from:"last_name"},photoUrl:{type:h().optional(),from:"photo_url"},username:h().optional()},"User").optional();function Fe(){return U({authDate:{type:ae(),from:"auth_date"},canSendAfter:{type:y().optional(),from:"can_send_after"},chat:$t,chatInstance:{type:h().optional(),from:"chat_instance"},chatType:{type:h().optional(),from:"chat_type"},hash:h(),queryId:{type:h().optional(),from:"query_id"},receiver:be,startParam:{type:h().optional(),from:"start_param"},user:be},"InitData")}const Ge=T(s=>re(h().parse(s)),"rgb");function Wt(s){return s.replace(/_[a-z]/g,e=>e[1].toUpperCase())}function Ht(s){return s.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}const je=T(s=>{const e=Ge().optional();return Object.entries(qe(s)).reduce((t,[r,n])=>(t[Wt(r)]=e.parse(n),t),{})},"ThemeParams");function $(s){return U({botInline:{type:w().optional(),from:"tgWebAppBotInline"},initData:{type:Fe().optional(),from:"tgWebAppData"},initDataRaw:{type:h().optional(),from:"tgWebAppData"},platform:{type:h(),from:"tgWebAppPlatform"},showSettings:{type:w().optional(),from:"tgWebAppShowSettings"},startParam:{type:h().optional(),from:"tgWebAppStartParam"},themeParams:{type:je(),from:"tgWebAppThemeParams"},version:{type:h(),from:"tgWebAppVersion"}}).parse(s)}function ze(s){return $(s.replace(/^[^?#]*[?#]/,"").replace(/[?#]/g,"&"))}function Ft(){return ze(window.location.href)}function Je(){return performance.getEntriesByType("navigation")[0]}function Gt(){const s=Je();if(!s)throw new Error("Unable to get first navigation entry.");return ze(s.name)}function Ye(s){return`cyberflow-apps/${s.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}`}function Ke(s,e){sessionStorage.setItem(Ye(s),JSON.stringify(e))}function Qe(s){const e=sessionStorage.getItem(Ye(s));try{return e?JSON.parse(e):void 0}catch{}}function jt(){return $(Qe("launchParams")||"")}function ce(s){return JSON.stringify(Object.fromEntries(Object.entries(s).map(([e,t])=>[Ht(e),t])))}function Xe(s){const{initDataRaw:e,themeParams:t,platform:r,version:n,showSettings:i,startParam:o,botInline:a}=s,p=new URLSearchParams;return p.set("tgWebAppPlatform",r),p.set("tgWebAppThemeParams",ce(t)),p.set("tgWebAppVersion",n),e&&p.set("tgWebAppData",e),o&&p.set("tgWebAppStartParam",o),typeof i=="boolean"&&p.set("tgWebAppShowSettings",i?"1":"0"),typeof a=="boolean"&&p.set("tgWebAppBotInline",a?"1":"0"),p.toString()}function Ze(s){Ke("launchParams",Xe(s))}function et(){const s=[];for(const e of[Ft,Gt,jt])try{const t=e();return Ze(t),t}catch(t){s.push(t instanceof Error?t.message:JSON.stringify(t))}throw new Error([`Unable to retrieve launch parameters from any known source. Perhaps, you have opened your app outside CyberFlow? `,"📖 Refer to docs for more information:",`https://docs.cyberflow-mini-apps.com/packages/cyberflow-apps-sdk/environment `,"Collected errors:",s.map(e=>`— ${e}`)].join(` `))}function pe(){const s=Je();return!!(s&&s.type==="reload")}function zt(){let s=0;return()=>(s+=1).toString()}const[Jt]=ye(zt);function l(s,e){return()=>{const t=et(),r={...t,postEvent:Oe(t.version),createRequestId:Jt()};if(typeof s=="function")return s(r);const[n,i,o]=X(),a=e({...r,state:pe()?Qe(s):void 0,addCleanup:n}),p=u=>(o||n(u.on("change",St=>{Ke(s,St)})),u);return[a instanceof Promise?a.then(p):p(a),i]}}const Yt=l("backButton",({postEvent:s,version:e,state:t={isVisible:!1}})=>new He(t.isVisible,e,s));class I extends oe{constructor(){super(...arguments);c(this,"on",this.state.on.bind(this.state));c(this,"off",this.state.off.bind(this.state))}}function tt(s){const e=s.available?s:{available:!1,device_id:"",token_saved:!1,access_requested:!1,access_granted:!1,type:""};return{available:!0,type:e.type,deviceId:e.device_id,tokenSaved:e.token_saved,accessRequested:e.access_requested,accessGranted:e.access_granted}}class st extends I{constructor({postEvent:t,version:r,...n}){super(n,r,{auth:"web_app_biometry_request_auth",openSettings:"web_app_biometry_open_settings",requestAccess:"web_app_biometry_request_access",updateToken:"web_app_biometry_update_token"});c(this,"postEvent");c(this,"authPromise");c(this,"accessPromise");this.postEvent=t}get available(){return this.get("available")}get accessGranted(){return this.get("accessGranted")}get accessRequested(){return this.get("accessRequested")}async authenticate({reason:t,...r}){return this.authPromise||(this.authPromise=d({...r,method:"web_app_biometry_request_auth",event:"biometry_auth_requested",postEvent:this.postEvent,params:{reason:(t||"").trim()}}).then(({token:n})=>n).finally(()=>this.authPromise=void 0)),this.authPromise}get deviceId(){return this.get("deviceId")}openSettings(){this.postEvent("web_app_biometry_open_settings")}requestAccess({reason:t,...r}={}){return this.accessPromise||(this.accessPromise=d({...r,postEvent:this.postEvent,method:"web_app_biometry_request_access",event:"biometry_info_received",params:{reason:t||""}}).then(n=>{const i=tt(n);return this.set(i),i.accessGranted}).finally(()=>this.accessPromise=void 0)),this.accessPromise}get biometryType(){return this.get("biometryType")}get tokenSaved(){return this.get("tokenSaved")}async updateToken({token:t,...r}={}){return["removed","updated"].includes((await d({...r,postEvent:this.postEvent,method:"web_app_biometry_update_token",event:"biometry_token_updated",params:{token:t||""}})).status)}}async function rt(s){return tt(await d({...s||{},method:"web_app_biometry_get_info",event:"biometry_info_received"}))}const Kt=l("biometryManager",async({postEvent:s,version:e,state:t})=>new st({...t||E("web_app_biometry_get_info",e)?t||await rt({timeout:1e3}):{available:!1,accessGranted:!1,accessRequested:!1,tokenSaved:!1,deviceId:""},version:e,postEvent:s}));class he extends ie{constructor(){super(...arguments);c(this,"on",this.state.on.bind(this.state));c(this,"off",this.state.off.bind(this.state))}}class nt extends he{constructor(e,t){super({isConfirmationNeeded:e}),this.postEvent=t}set isConfirmationNeeded(e){this.set("isConfirmationNeeded",e),this.postEvent("web_app_setup_closing_behavior",{need_confirmation:e})}get isConfirmationNeeded(){return this.get("isConfirmationNeeded")}disableConfirmation(){this.isConfirmationNeeded=!1}enableConfirmation(){this.isConfirmationNeeded=!0}}const Qt=l("closingBehavior",({postEvent:s,state:e={isConfirmationNeeded:!1}})=>new nt(e.isConfirmationNeeded,s));class ue{constructor(e,t){c(this,"supports");this.supports=We(e,t)}}function Xt(s){if(Array.isArray(s))return s;if(typeof s=="string")try{const e=JSON.parse(s);if(Array.isArray(e))return e}catch{}throw R()}class Zt extends M{constructor(t,r,n){super(Xt,r,n);c(this,"itemParser");this.itemParser=typeof t=="function"?t:t.parse.bind(t)}parse(t){const r=super.parse(t);return r===void 0?r:r.map(this.itemParser)}of(t){return this.itemParser=typeof t=="function"?t:t.parse.bind(t),this}}function it(s){return new Zt(e=>e,!1,s)}function we(s,e){return Object.fromEntries(s.map(t=>[t,e]))}class ot extends ue{constructor(e,t,r){super(e,{delete:"web_app_invoke_custom_method",get:"web_app_invoke_custom_method",getKeys:"web_app_invoke_custom_method",set:"web_app_invoke_custom_method"}),this.createRequestId=t,this.postEvent=r}async delete(e,t={}){const r=Array.isArray(e)?e:[e];r.length&&await v("deleteStorageValues",{keys:r},this.createRequestId(),{...t,postEvent:this.postEvent})}async getKeys(e={}){return it().of(h()).parse(await v("getStorageKeys",{},this.createRequestId(),{...e,postEvent:this.postEvent}))}async get(e,t={}){const r=Array.isArray(e)?e:[e];if(!r.length)return we(r,"");const n=await v("getStorageValues",{keys:r},this.createRequestId(),{...t,postEvent:this.postEvent}),i=g(we(r,h()),"CloudStorageData").parse(n);return Array.isArray(e)?i:i[e]}async set(e,t,r={}){await v("saveStorageValue",{key:e,value:t},this.createRequestId(),{...r,postEvent:this.postEvent})}}const es=l(({createRequestId:s,postEvent:e,version:t})=>new ot(t,s,e));class at extends ue{constructor(e,t){super(e,{impactOccurred:"web_app_trigger_haptic_feedback",notificationOccurred:"web_app_trigger_haptic_feedback",selectionChanged:"web_app_trigger_haptic_feedback"}),this.postEvent=t}impactOccurred(e){this.postEvent("web_app_trigger_haptic_feedback",{type:"impact",impact_style:e})}notificationOccurred(e){this.postEvent("web_app_trigger_haptic_feedback",{type:"notification",notification_type:e})}selectionChanged(){this.postEvent("web_app_trigger_haptic_feedback",{type:"selection_change"})}}const ts=l(({version:s,postEvent:e})=>new at(s,e));class ct{constructor(e){this.initData=e}get authDate(){return this.initData.authDate}get canSendAfter(){return this.initData.canSendAfter}get canSendAfterDate(){const{canSendAfter:e}=this;return e?new Date(this.authDate.getTime()+e*1e3):void 0}get chat(){return this.initData.chat}get chatType(){return this.initData.chatType}get chatInstance(){return this.initData.chatInstance}get hash(){return this.initData.hash}get queryId(){return this.initData.queryId}get receiver(){return this.initData.receiver}get startParam(){return this.initData.startParam}get user(){return this.initData.user}}const ss=l(({initData:s})=>s?new ct(s):void 0);function rs(s){return Fe().parse(s)}class pt extends I{constructor(e,t,r){super({isOpened:e},t,{open:"web_app_open_invoice"}),this.postEvent=r}set isOpened(e){this.set("isOpened",e)}get isOpened(){return this.get("isOpened")}async open(e,t){if(this.isOpened)throw new Error("Invoice is already opened");let r;if(!t)r=e;else{const{hostname:n,pathname:i}=new URL(e,window.location.href);if(n!=="t.me")throw new Error(`Incorrect hostname: ${n}`);const o=i.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);if(!o)throw new Error('Link pathname has incorrect format. Expected to receive "/invoice/{slug}" or "/${slug}"');[,,r]=o}this.isOpened=!0;try{return(await d({method:"web_app_open_invoice",event:"invoice_closed",params:{slug:r},postEvent:this.postEvent,capture(i){return r===i.slug}})).status}finally{this.isOpened=!1}}}const ns=l(({version:s,postEvent:e})=>new pt(!1,s,e));class ht extends ie{constructor({postEvent:t,...r}){super(r);c(this,"postEvent");c(this,"on",(t,r)=>t==="click"?b("main_button_pressed",r):this.state.on(t,r));c(this,"off",(t,r)=>t==="click"?D("main_button_pressed",r):this.state.off(t,r));this.postEvent=t}get bgColor(){return this.get("bgColor")}commit(){this.text!==""&&this.postEvent("web_app_setup_main_button",{is_visible:this.isVisible,is_active:this.isEnabled,is_progress_visible:this.isLoaderVisible,text:this.text,color:this.bgColor,text_color:this.textColor})}disable(){return this.isEnabled=!1,this}enable(){return this.isEnabled=!0,this}hide(){return this.isVisible=!1,this}hideLoader(){return this.isLoaderVisible=!1,this}set isEnabled(t){this.setParams({isEnabled:t})}get isEnabled(){return this.get("isEnabled")}set isLoaderVisible(t){this.setParams({isLoaderVisible:t})}get isLoaderVisible(){return this.get("isLoaderVisible")}set isVisible(t){this.setParams({isVisible:t})}get isVisible(){return this.get("isVisible")}show(){return this.isVisible=!0,this}showLoader(){return this.isLoaderVisible=!0,this}setText(t){return this.setParams({text:t})}setTextColor(t){return this.setParams({textColor:t})}setBgColor(t){return this.setParams({bgColor:t})}setParams(t){return this.set(t),this.commit(),this}get text(){return this.get("text")}get textColor(){return this.get("textColor")}}const is=l("mainButton",({postEvent:s,themeParams:e,state:t={isVisible:!1,isEnabled:!1,text:"",isLoaderVisible:!1,textColor:e.buttonTextColor||"#ffffff",bgColor:e.buttonColor||"#000000"}})=>new ht({...t,postEvent:s}));function os(){return U({contact:g({userId:{type:y(),from:"user_id"},phoneNumber:{type:h(),from:"phone_number"},firstName:{type:h(),from:"first_name"},lastName:{type:h().optional(),from:"last_name"}}),authDate:{type:ae(),from:"auth_date"},hash:h()},"RequestedContact")}function ut(s,e){return t=>{const[r,n]=e[t];return E(r,n,s)}}function as(s){return new Promise(e=>{setTimeout(e,s)})}class lt extends I{constructor({postEvent:t,createRequestId:r,version:n,botInline:i,...o}){super(o,n,{requestPhoneAccess:"web_app_request_phone",requestWriteAccess:"web_app_request_write_access",switchInlineQuery:"web_app_switch_inline_query",setHeaderColor:"web_app_set_header_color",setBackgroundColor:"web_app_set_background_color"});c(this,"botInline");c(this,"postEvent");c(this,"createRequestId");c(this,"requestPhoneAccessPromise");c(this,"requestWriteAccessPromise");c(this,"supportsParam");this.createRequestId=r,this.postEvent=t,this.botInline=i;const a=this.supports.bind(this);this.supports=p=>a(p)?p!=="switchInlineQuery"||i:!1,this.supportsParam=ut(n,{"setHeaderColor.color":["web_app_set_header_color","color"],"close.returnBack":["web_app_close","return_back"]})}async getRequestedContact({timeout:t=1e4}={}){return os().parse(await v("getRequestedContact",{},this.createRequestId(),{postEvent:this.postEvent,timeout:t}))}get bgColor(){return this.get("bgColor")}close(t){this.postEvent("web_app_close",this.supportsParam("close.returnBack")?{return_back:t}:{})}get headerColor(){return this.get("headerColor")}get isBotInline(){return this.botInline}get isDark(){return ne(this.bgColor)}ready(){this.postEvent("web_app_ready")}async requestContact({timeout:t=5e3}={}){try{return await this.getRequestedContact()}catch{}if(await this.requestPhoneAccess()!=="sent")throw new Error("Access denied.");const n=Date.now()+t;let i=50;return se(async()=>{for(;Date.now()r).finally(()=>this.requestPhoneAccessPromise=void 0)),this.requestPhoneAccessPromise}async requestWriteAccess(t={}){return this.requestWriteAccessPromise||(this.requestWriteAccessPromise=d({...t,method:"web_app_request_write_access",event:"write_access_requested",postEvent:this.postEvent}).then(({status:r})=>r).finally(()=>this.requestWriteAccessPromise=void 0)),this.requestWriteAccessPromise}sendData(t){const{size:r}=new Blob([t]);if(!r||r>4096)throw new Error(`Passed data has incorrect size: ${r}`);this.postEvent("web_app_data_send",{data:t})}setHeaderColor(t){this.postEvent("web_app_set_header_color",O(t)?{color:t}:{color_key:t}),this.set("headerColor",t)}setBgColor(t){this.postEvent("web_app_set_background_color",{color:t}),this.set("bgColor",t)}switchInlineQuery(t,r=[]){if(!this.supports("switchInlineQuery")&&!this.isBotInline)throw new Error("Method is unsupported because Mini App should be launched in inline mode.");this.postEvent("web_app_switch_inline_query",{query:t,chat_types:r})}}const cs=l("miniApp",({themeParams:s,botInline:e=!1,state:t={bgColor:s.bgColor||"#ffffff",headerColor:s.headerBgColor||"#000000"},...r})=>new lt({...r,...t,botInline:e}));function ps(s){const e=s.message.trim(),t=(s.title||"").trim(),r=s.buttons||[];let n;if(t.length>64)throw new Error(`Title has incorrect size: ${t.length}`);if(!e.length||e.length>256)throw new Error(`Message has incorrect size: ${e.length}`);if(r.length>3)throw new Error(`Buttons have incorrect size: ${r.length}`);return r.length?n=r.map(i=>{const{id:o=""}=i;if(o.length>64)throw new Error(`Button ID has incorrect size: ${o}`);if(!i.type||i.type==="default"||i.type==="destructive"){const a=i.text.trim();if(!a.length||a.length>64){const p=i.type||"default";throw new Error(`Button text with type "${p}" has incorrect size: ${i.text.length}`)}return{...i,text:a,id:o}}return{...i,id:o}}):n=[{type:"close",id:""}],{title:t,message:e,buttons:n}}class dt extends I{constructor(e,t,r){super({isOpened:e},t,{open:"web_app_open_popup"}),this.postEvent=r}set isOpened(e){this.set("isOpened",e)}get isOpened(){return this.get("isOpened")}async open(e){if(this.isOpened)throw new Error("Popup is already opened.");this.isOpened=!0;try{const{button_id:t=null}=await d({event:"popup_closed",method:"web_app_open_popup",postEvent:this.postEvent,params:ps(e)});return t}finally{this.isOpened=!1}}}const hs=l(({postEvent:s,version:e})=>new dt(!1,e,s));class _t extends I{constructor(e,t,r){super({isOpened:e},t,{close:"web_app_close_scan_qr_popup",open:"web_app_open_scan_qr_popup"}),this.postEvent=r}close(){this.postEvent("web_app_close_scan_qr_popup"),this.isOpened=!1}set isOpened(e){this.set("isOpened",e)}get isOpened(){return this.get("isOpened")}async open(e){if(this.isOpened)throw new Error("The scanner is already opened");const{text:t,capture:r}=(typeof e=="string"?{text:e}:e)||{};this.isOpened=!0;try{const i=(await d({method:"web_app_open_scan_qr_popup",event:["qr_text_received","scan_qr_popup_closed"],postEvent:this.postEvent,params:{text:t},capture(o){return o.event==="scan_qr_popup_closed"||!r||r(o.payload)}})||{}).data||null;return i&&this.close(),i}finally{this.isOpened=!1}}}const us=l(({version:s,postEvent:e})=>new _t(!1,s,e));class ft extends oe{constructor(t,r,n){super({isVisible:t},r,{show:"web_app_setup_settings_button",hide:"web_app_setup_settings_button"});c(this,"on",(t,r)=>t==="click"?b("settings_button_pressed",r):this.state.on(t,r));c(this,"off",(t,r)=>t==="click"?D("settings_button_pressed",r):this.state.off(t,r));this.postEvent=n}set isVisible(t){this.set("isVisible",t),this.postEvent("web_app_setup_settings_button",{is_visible:t})}get isVisible(){return this.get("isVisible")}hide(){this.isVisible=!1}show(){this.isVisible=!0}}const ls=l("settingsButton",({version:s,postEvent:e,state:t={isVisible:!1}})=>new ft(t.isVisible,s,e));class gt extends I{constructor(e,t,r){super({isVerticalSwipeEnabled:e},t,{disableVerticalSwipe:"web_app_setup_swipe_behavior",enableVerticalSwipe:"web_app_setup_swipe_behavior"}),this.postEvent=r}set isVerticalSwipeEnabled(e){this.set("isVerticalSwipeEnabled",e),this.postEvent("web_app_setup_swipe_behavior",{allow_vertical_swipe:e})}get isVerticalSwipeEnabled(){return this.get("isVerticalSwipeEnabled")}disableVerticalSwipe(){this.isVerticalSwipeEnabled=!1}enableVerticalSwipe(){this.isVerticalSwipeEnabled=!0}}const ds=l("swipeBehavior",({postEvent:s,state:e={isVerticalSwipeEnabled:!0},version:t})=>new gt(e.isVerticalSwipeEnabled,t,s));function le(s){return je().parse(s)}class bt extends he{get accentTextColor(){return this.get("accentTextColor")}get bgColor(){return this.get("bgColor")}get buttonColor(){return this.get("buttonColor")}get buttonTextColor(){return this.get("buttonTextColor")}get destructiveTextColor(){return this.get("destructiveTextColor")}getState(){return this.clone()}get headerBgColor(){return this.get("headerBgColor")}get hintColor(){return this.get("hintColor")}get isDark(){return!this.bgColor||ne(this.bgColor)}get linkColor(){return this.get("linkColor")}get secondaryBgColor(){return this.get("secondaryBgColor")}get sectionBgColor(){return this.get("sectionBgColor")}get sectionHeaderTextColor(){return this.get("sectionHeaderTextColor")}get sectionSeparatorColor(){return this.get("sectionHeaderTextColor")}listen(){return b("theme_changed",e=>{this.set(le(e.theme_params))})}get subtitleTextColor(){return this.get("subtitleTextColor")}get textColor(){return this.get("textColor")}}const _s=l("themeParams",({themeParams:s,state:e=s,addCleanup:t})=>{const r=new bt(e);return t(r.listen()),r});function fs(s={}){return d({...s,method:"web_app_request_theme",event:"theme_changed"}).then(le)}function N(s,e){return s.startsWith(e)?s:`${e}${s}`}function C(s){return new URL(typeof s=="string"?s:`${s.pathname||""}${N(s.search||"","?")}${N(s.hash||"","#")}`,"http://a")}class wt extends ue{constructor(t,r,n){super(t,{readTextFromClipboard:"web_app_read_text_from_clipboard"});c(this,"supportsParam");this.version=t,this.createRequestId=r,this.postEvent=n,this.supportsParam=ut(t,{"openLink.tryInstantView":["web_app_open_link","try_instant_view"]})}openLink(t,r){const n=C(t).toString();if(!E("web_app_open_link",this.version)){window.open(n,"_blank");return}const i=typeof r=="boolean"?{tryInstantView:r}:r||{};this.postEvent("web_app_open_link",{url:n,try_browser:i.tryBrowser,try_instant_view:i.tryInstantView})}openCyberFlowLink(t){const{hostname:r,pathname:n,search:i}=new URL(t,"https://cyberflow.me");if(r!=="t.me")throw new Error(`URL has not allowed hostname: ${r}. Only "t.me" is allowed`);if(!E("web_app_open_tg_link",this.version)){window.location.href=t;return}this.postEvent("web_app_open_tg_link",{path_full:n+i})}async readTextFromClipboard(){const t=this.createRequestId(),{data:r=null}=await d({method:"web_app_read_text_from_clipboard",event:"clipboard_text_received",postEvent:this.postEvent,params:{req_id:t},capture:te(t)});return r}shareURL(t,r){this.openCyberFlowLink("https://cyberflow.merflow.me/share/url?"+new URLSearchParams({url:t,text:r||""}).toString().replace(/\+/g,"%20"))}}const gs=l(({version:s,postEvent:e,createRequestId:t})=>new wt(s,t,e));async function de(s={}){const{is_expanded:e,is_state_stable:t,...r}=await d({...s,method:"web_app_request_viewport",event:"viewport_changed"});return{...r,isExpanded:e,isStateStable:t}}function x(s){return s<0?0:s}class mt extends he{constructor({postEvent:t,stableHeight:r,height:n,width:i,isExpanded:o}){super({height:x(n),isExpanded:o,stableHeight:x(r),width:x(i)});c(this,"postEvent");this.postEvent=t}async sync(t){const{isStateStable:r,...n}=await de(t);this.set({...n,stableHeight:r?n.height:this.get("stableHeight")})}get height(){return this.get("height")}get stableHeight(){return this.get("stableHeight")}listen(){return b("viewport_changed",t=>{const{height:r,width:n,is_expanded:i,is_state_stable:o}=t,a=x(r);this.set({height:a,isExpanded:i,width:x(n),...o?{stableHeight:a}:{}})})}get isExpanded(){return this.get("isExpanded")}get width(){return this.get("width")}expand(){this.postEvent("web_app_expand"),this.set("isExpanded",!0)}get isStable(){return this.stableHeight===this.height}}const bs=l("viewport",async({state:s,platform:e,postEvent:t,addCleanup:r})=>{let n=!1,i=0,o=0,a=0;if(s)n=s.isExpanded,i=s.height,o=s.width,a=s.stableHeight;else if(["macos","tdesktop","unigram","webk","weba","web"].includes(e))n=!0,i=window.innerHeight,o=window.innerWidth,a=window.innerHeight;else{const u=await de({timeout:1e3,postEvent:t});n=u.isExpanded,i=u.height,o=u.width,a=u.isStateStable?i:0}const p=new mt({postEvent:t,height:i,width:o,stableHeight:a,isExpanded:n});return r(p.listen()),p});function m(s,e){document.documentElement.style.setProperty(s,e)}function ws(s,e,t){t||(t=a=>`--tg-${a}-color`);const r=t("header"),n=t("bg"),i=()=>{const{headerColor:a}=s;if(O(a))m(r,a);else{const{bgColor:p,secondaryBgColor:u}=e;a==="bg_color"&&p?m(r,p):a==="secondary_bg_color"&&u&&m(r,u)}m(n,s.bgColor)},o=[e.on("change",i),s.on("change",i)];return i(),()=>o.forEach(a=>a())}function ms(s,e){e||(e=r=>`--tg-theme-${r.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`)}`);const t=()=>{Object.entries(s.getState()).forEach(([r,n])=>{n&&m(e(r),n)})};return t(),s.on("change",t)}function ys(s,e){e||(e=u=>`--tg-viewport-${u}`);const[t,r,n]=["height","width","stable-height"].map(u=>e(u)),i=()=>m(t,`${s.height}px`),o=()=>m(r,`${s.width}px`),a=()=>m(n,`${s.stableHeight}px`),p=[s.on("change:height",i),s.on("change:width",o),s.on("change:stableHeight",a)];return i(),o(),a(),()=>p.forEach(u=>u())}function Es(s=!0){const e=[b("reload_iframe",()=>{P("iframe_will_reload"),window.location.reload()})],t=()=>e.forEach(r=>r());if(s){const r=document.createElement("style");r.id="cyberflow-custom-styles",document.head.appendChild(r),e.push(b("set_custom_style",n=>{r.innerHTML=n}),()=>document.head.removeChild(r))}return P("iframe_ready",{reload_supported:!0}),t}function vs(){return typeof window>"u"}async function Ss(){if(Be(window))return!0;try{return await d({method:"web_app_request_theme",event:"theme_changed",timeout:100}),!0}catch{return!1}}function Ps(s){const e=typeof s=="string"?$(s):s;Ze(e);function t(n){if(typeof n=="string")try{const{eventType:i}=ke(n);i==="web_app_request_theme"&&Y("theme_changed",{theme_params:JSON.parse(ce(e.themeParams))}),i==="web_app_request_viewport"&&Y("viewport_changed",{width:window.innerWidth,height:window.innerHeight,is_state_stable:!0,is_expanded:!0})}catch{}}if(ee()){const n=window.parent.postMessage.bind(window.parent);window.parent.postMessage=i=>{t(i),n(i)};return}if(Ve(window)){const n=window.external.notify.bind(window.external);window.external.notify=i=>{t(i),n(i)};return}const r=window.CyberFlowWebviewProxy;window.CyberFlowWebviewProxy={...r||{},postEvent(...n){t(JSON.stringify({eventType:n[0],eventData:n[1]})),r&&r.postEvent(...n)}}}function yt(s){return s instanceof k}function Cs(s,e){return yt(s)&&s.type===e}function W(s,e){let t,r,n;return typeof s=="string"?t=s:(t=s.pathname===void 0?e:s.pathname,r=s.params,n=s.id),Object.freeze({id:n||(Math.random()*2**14|0).toString(16),pathname:t,params:r})}class Et{constructor(e,t,r=P){c(this,"history");c(this,"ee",new S);c(this,"attached",!1);c(this,"back",()=>this.go(-1));c(this,"on",this.ee.on.bind(this.ee));c(this,"off",this.ee.off.bind(this.ee));if(this._index=t,this.postEvent=r,e.length===0)throw f(Ie,"History should not be empty.");if(t<0||t>=e.length)throw f(xe,"Index should not be zero and higher or equal than history size.");this.history=e.map(n=>W(n,""))}attach(){this.attached||(this.attached=!0,this.sync(),b("back_button_pressed",this.back))}get current(){return this.history[this.index]}detach(){this.attached=!1,D("back_button_pressed",this.back)}forward(){this.go(1)}go(e,t){const r=this.index+e,n=Math.min(Math.max(0,r),this.history.length-1);(r===n||t)&&this.replaceAndMove(n,this.history[n])}goTo(e,t){this.go(e-this.index,t)}get hasPrev(){return this.index>0}get hasNext(){return this.index!==this.history.length-1}get index(){return this._index}push(e){this.hasNext&&this.history.splice(this.index+1),this.replaceAndMove(this.index+1,W(e,this.current.pathname))}replace(e){this.replaceAndMove(this.index,W(e,this.current.pathname))}replaceAndMove(e,t){const r=e-this.index;if(!r&&this.current===t)return;const n=this.current;if(this.index!==e){const i=this._index;this._index=e,this.attached&&i>0!=e>0&&this.sync()}this.history[e]=t,this.ee.emit("change",{navigator:this,from:n,to:this.current,delta:r})}sync(){this.postEvent("web_app_setup_back_button",{is_visible:!!this.index})}}function H({params:s,...e}){return{...s||{hash:"",search:""},...e}}function q(s){const e=typeof s=="string"?s.startsWith("/"):!!(s.pathname&&s.pathname.startsWith("/")),t=C(s);return`${e?t.pathname:t.pathname.slice(1)}${t.search}${t.hash}`}function F(s,e,t){let r,n;typeof s=="string"?r=s:(r=q(s),t=s.state,n=s.id);const{pathname:i,search:o,hash:a}=new URL(r,`http://a${N(e,"/")}`);return{id:n,pathname:i,params:{hash:a,search:o,state:t}}}async function A(s){return s===0?!0:Promise.race([new Promise(e=>{const t=J("popstate",()=>{t(),e(!0)});window.history.go(s)}),new Promise(e=>{setTimeout(e,50,!1)})])}async function Rs(){if(window.history.length<=1||(window.history.pushState(null,""),await A(1-window.history.length)))return;let e=await A(-1);for(;e;)e=await A(-1)}function _e(s){return C(s).pathname}const me=0,G=1,j=2;class fe{constructor(e,t,{postEvent:r,hashMode:n="classic",base:i}={}){c(this,"navigator");c(this,"ee",new S);c(this,"hashMode");c(this,"base");c(this,"attached",!1);c(this,"onPopState",({state:e})=>{if(e===null)return this.push(this.parsePath(window.location.href));e===me?window.history.forward():e===G&&this.back(),e===j&&this.forward()});c(this,"onNavigatorChange",async({to:e,from:t,delta:r})=>{this.attached&&await this.syncHistory(),this.ee.emit("change",{delta:r,from:H(t),to:H(e),navigator:this})});c(this,"on",this.ee.on.bind(this.ee));c(this,"off",this.ee.off.bind(this.ee));this.navigator=new Et(e.map(o=>F(o,"/")),t,r),this.navigator.on("change",o=>{this.onNavigatorChange(o)}),this.hashMode=n,this.base=_e(i||"")}async attach(){this.attached||(this.attached=!0,this.navigator.attach(),window.addEventListener("popstate",this.onPopState),await this.syncHistory())}back(){this.navigator.back()}detach(){this.attached=!1,this.navigator.detach(),window.removeEventListener("popstate",this.onPopState)}forward(){return this.navigator.forward()}get index(){return this.navigator.index}get id(){return this.navigator.current.id}go(e,t){return this.navigator.go(e,t)}goTo(e,t){this.navigator.goTo(e,t)}get hash(){return(this.navigator.current.params||{}).hash||""}get hasPrev(){return this.navigator.hasPrev}get hasNext(){return this.navigator.hasNext}get history(){return this.navigator.history.map(H)}get path(){return q(this)}get pathname(){return this.navigator.current.pathname}parsePath(e){let t=C(e);return this.hashMode&&(t=C(t.hash.slice(1))),{pathname:t.pathname,search:t.search,hash:t.hash}}push(e,t){const r=F(e,this.path),{state:n=t}=r.params;this.navigator.push({...r,params:{...r.params,state:n}})}replace(e,t){const r=F(e,this.path),{state:n=t}=r.params;this.navigator.replace({...r,params:{...r.params,state:n}})}renderPath(e){const t=(this.base.length===1?"":this.base)+N(q(e),"/");return this.hashMode?N(t.slice(1),this.hashMode==="classic"?"#":"#/"):t}async syncHistory(){window.removeEventListener("popstate",this.onPopState);const{state:e}=this,t=this.renderPath(this);await Rs(),this.hasPrev&&this.hasNext?(window.history.replaceState(G,""),window.history.pushState(e,"",t),window.history.pushState(j,""),await A(-1)):this.hasPrev?(window.history.replaceState(G,""),window.history.pushState(e,"",t)):this.hasNext?(window.history.replaceState(e,t),window.history.pushState(j,""),await A(-1)):(window.history.replaceState(me,""),window.history.pushState(e,"",t)),window.addEventListener("popstate",this.onPopState)}get search(){return(this.navigator.current.params||{}).search||""}get state(){return(this.navigator.current.params||{}).state}}function vt(s){s||(s={});const{href:e,hash:t}=window.location;let r=q(s.hashMode===null?e:t.includes("?")?t.slice(1):`?${t.slice(1)}`);const n=s.base?_e(s.base):void 0;if(n){if(!r.startsWith(n))throw f(Ae,`Path "${r}" expected to be starting with "${n}"`);r=r.slice(n.length)}return new fe([r],0,s)}function Ts(s){const e=s.match(/#(.+)/);return e?e[1]:null}function Is(s,e){if(pe()){const t=sessionStorage.getItem(s);if(t)try{const{index:r,history:n}=JSON.parse(t);return new fe(n,r,e)}catch(r){console.error("Unable to restore hash navigator state.",r)}}return vt(e)}function xs(s,e){const t=Is(s,e),r=()=>sessionStorage.setItem(s,JSON.stringify({index:t.index,history:t.history}));return t.on("change",r),r(),t}exports.BackButton=He;exports.BasicNavigator=Et;exports.BiometryManager=st;exports.BrowserNavigator=fe;exports.ClosingBehavior=nt;exports.CloudStorage=ot;exports.ERR_INVALID_PATH_BASE=Ae;exports.ERR_INVOKE_CUSTOM_METHOD_RESPONSE=Ce;exports.ERR_METHOD_PARAMETER_UNSUPPORTED=Se;exports.ERR_METHOD_UNSUPPORTED=ve;exports.ERR_NAVIGATION_HISTORY_EMPTY=Ie;exports.ERR_NAVIGATION_INDEX_INVALID=xe;exports.ERR_NAVIGATION_ITEM_INVALID=xt;exports.ERR_PARSE=Z;exports.ERR_SSR_INIT=At;exports.ERR_TIMED_OUT=Re;exports.ERR_UNEXPECTED_TYPE=Te;exports.ERR_UNKNOWN_ENV=Pe;exports.EventEmitter=S;exports.HapticFeedback=at;exports.InitData=ct;exports.Invoice=pt;exports.MainButton=ht;exports.MiniApp=lt;exports.Popup=dt;exports.QRScanner=_t;exports.SDKError=k;exports.SettingsButton=ft;exports.SwipeBehavior=gt;exports.ThemeParams=bt;exports.Utils=wt;exports.Viewport=mt;exports.array=it;exports.bindMiniAppCSSVars=ws;exports.bindThemeParamsCSSVars=ms;exports.bindViewportCSSVars=ys;exports.boolean=w;exports.captureSameReq=te;exports.classNames=B;exports.compareVersions=De;exports.createBrowserNavigatorFromLocation=vt;exports.createPostEvent=Oe;exports.createSafeURL=C;exports.date=ae;exports.getHash=Ts;exports.getPathname=_e;exports.initBackButton=Yt;exports.initBiometryManager=Kt;exports.initClosingBehavior=Qt;exports.initCloudStorage=es;exports.initHapticFeedback=ts;exports.initInitData=ss;exports.initInvoice=ns;exports.initMainButton=is;exports.initMiniApp=cs;exports.initNavigator=xs;exports.initPopup=hs;exports.initQRScanner=us;exports.initSettingsButton=ls;exports.initSwipeBehavior=ds;exports.initThemeParams=_s;exports.initUtils=gs;exports.initViewport=bs;exports.initWeb=Es;exports.invokeCustomMethod=v;exports.isColorDark=ne;exports.isIframe=ee;exports.isPageReload=pe;exports.isRGB=O;exports.isRGBShort=$e;exports.isSDKError=yt;exports.isSDKErrorOfType=Cs;exports.isSSR=vs;exports.isTMA=Ss;exports.json=g;exports.mergeClassNames=Ot;exports.mockCyberflowEnv=Ps;exports.number=y;exports.off=D;exports.on=b;exports.parseInitData=rs;exports.parseLaunchParams=$;exports.parseThemeParams=le;exports.postEvent=P;exports.request=d;exports.requestBiometryInfo=rt;exports.requestThemeParams=fs;exports.requestViewport=de;exports.retrieveLaunchParams=et;exports.rgb=Ge;exports.searchParams=U;exports.serializeLaunchParams=Xe;exports.serializeThemeParams=ce;exports.setCSSVar=m;exports.setDebug=Tt;exports.setTargetOrigin=Lt;exports.string=h;exports.subscribe=Ee;exports.supports=E;exports.targetOrigin=Le;exports.toRGB=re;exports.unsubscribe=K;exports.urlToPath=q;exports.withTimeout=se; //# sourceMappingURL=index.cjs.map