@frak-labs/components 1.0.9 → 1.0.10-beta.1700e6ec
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/cdn/Banner.BpIgsa8e.js +167 -0
- package/cdn/ButtonShare.QjU-SB2w.js +1 -0
- package/cdn/ButtonWallet.BQWezFCP.js +40 -0
- package/cdn/GiftIcon.QppqMfWS.js +1 -0
- package/cdn/OpenInAppButton.D1UzTuHx.js +1 -0
- package/cdn/PostPurchase.DPgGfAjM.js +89 -0
- package/cdn/components.js +1 -1
- package/cdn/defaults.kWEdCyGS.js +58 -0
- package/cdn/embeddedWallet.CDUxjdX2.js +1 -0
- package/cdn/loader.js +1 -1
- package/cdn/replay-V6FXES7X.CNozpSRg.js +1 -0
- package/cdn/rewards.D4VLYzjp.js +1 -0
- package/cdn/useGlobalComponents.BC6Jgzg5.js +1 -0
- package/cdn/useLightDomStyles.imPXuAtf.js +1 -0
- package/cdn/useReward.Cks8uGHY.js +1 -0
- package/dist/{GiftIcon-BIp9FTJs.js → GiftIcon-WEWSJ8kV.js} +1 -1
- package/dist/banner.d.ts +2 -3
- package/dist/banner.js +75 -76
- package/dist/buttonShare.d.ts +4 -3
- package/dist/buttonShare.js +11 -9
- package/dist/buttonWallet.d.ts +1 -2
- package/dist/buttonWallet.js +5 -3
- package/dist/i18n/defaults.d.ts +54 -0
- package/dist/i18n/defaults.js +70 -0
- package/dist/openInApp.d.ts +5 -5
- package/dist/openInApp.js +7 -5
- package/dist/postPurchase.d.ts +2 -3
- package/dist/postPurchase.js +28 -16
- package/dist/rewards-CsHE1hVo.js +145 -0
- package/dist/useGlobalComponents-CZ7Sh2tZ.js +17 -0
- package/dist/{useLightDomStyles-CgAkUlb_.js → useLightDomStyles-DphuQhvx.js} +1 -1
- package/dist/{usePlacement-rmDVnK7X.js → usePlacement-4PoDbn2X.js} +109 -13
- package/dist/useReward-Br6GKb9Z.js +39 -0
- package/package.json +9 -3
- package/cdn/Banner.CcOWT4lZ.js +0 -178
- package/cdn/ButtonShare.D9-F0jJJ.js +0 -1
- package/cdn/ButtonWallet.B0buPR_z.js +0 -40
- package/cdn/GiftIcon.eRNTGQ_r.js +0 -1
- package/cdn/OpenInAppButton.Dgb-qhM8.js +0 -1
- package/cdn/PostPurchase.BYxnAEyn.js +0 -89
- package/cdn/embeddedWallet.BS-9u4Be.js +0 -1
- package/cdn/formatReward.B1ZyoceC.js +0 -1
- package/cdn/replay-V6FXES7X.BoL9fAjx.js +0 -1
- package/cdn/useGlobalComponents.TG9kIYSc.js +0 -1
- package/cdn/useLightDomStyles.tjNBKcOr.js +0 -1
- package/cdn/usePlacement.BgMXY5CX.js +0 -58
- package/cdn/useReward.BtBpuMwt.js +0 -1
- package/dist/formatReward-Cf2KpA3x.js +0 -33
- package/dist/useGlobalComponents-mSs9unyN.js +0 -21
- package/dist/useReward-ClVShg45.js +0 -65
package/cdn/loader.js
CHANGED
|
@@ -151,4 +151,4 @@ var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],en
|
|
|
151
151
|
}
|
|
152
152
|
.sharedBaseCss_buttonReset__7cswil0:focus-visible {
|
|
153
153
|
outline-color: currentColor;
|
|
154
|
-
}`;function r(e,t){let n=document.getElementById(e);if(n){n.textContent!==t&&(n.textContent=t);return}let r=document.createElement(`style`);r.id=e,r.textContent=t,document.head.appendChild(r)}function i(e,t){let n=`frak-base-${e}`;if(document.getElementById(n)||!t)return;let r=document.createElement(`style`);r.id=n,r.textContent=t,document.head.appendChild(r)}function a(e,t,n){r(`frak-placement-${e}-${t}`,n)}const o={injectBase:i,injectPlacement:a};function s(e){document.readyState===`complete`||document.readyState===`interactive`?setTimeout(e,1):document.addEventListener(`DOMContentLoaded`,e)}const c={parseError:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internalError:-32603,serverError:-32e3,clientNotConnected:-32001,configError:-32002,corruptedResponse:-32003,clientAborted:-32004,walletNotConnected:-32005,serverErrorForInteractionDelegation:-32006,userRejected:-32007};var l=class extends Error{code;data;constructor(e,t,n){super(t),this.code=e,this.data=n}toJSON(){return{code:this.code,message:this.message,data:this.data}}},u=class{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}get promise(){return this._promise}resolve=e=>{this._resolve?.(e)};reject=e=>{this._reject?.(e)}};function d(e){let{emittingTransport:t,listeningTransport:n,targetOrigin:r,middleware:i=[],lifecycleHandlers:a}=e,o=new Map;function s(e){return typeof e!=`object`||!e?!1:`clientLifecycle`in e||`iframeLifecycle`in e}function c(e){return typeof e!=`object`||!e?!1:`id`in e&&`topic`in e&&`data`in e}async function d(e){try{`clientLifecycle`in e&&a?.clientLifecycle?await a.clientLifecycle(e,{origin:r,source:null}):`iframeLifecycle`in e&&a?.iframeLifecycle&&await a.iframeLifecycle(e,{origin:r,source:null})}catch{}}async function f(e){let t={origin:r,source:null};for(let n of i)n.onRequest&&await n.onRequest(e,t);return e}async function p(e,t){let n={origin:r,source:null},a=t;for(let t of i)t.onResponse&&(a=await t.onResponse(e,a,n));return a}async function m(e){try{if(new URL(e.origin).origin.toLowerCase()!==new URL(r).origin.toLowerCase())return}catch{return}if(s(e.data)){await d(e.data);return}if(!c(e.data))return;let t;try{let n=e.data.data,r=n instanceof Uint8Array||ArrayBuffer.isView(n)?{result:n}:n;t=await p(e.data,r)}catch{return}let n=o.get(e.data.id);n&&n(t)}async function h(e){let n=e;try{n=await f(e)}catch(e){throw e}t.postMessage(n,r)}function g(e){t.postMessage(e,r)}function _(){return`${Date.now()}-${Math.random().toString(36).substring(2,9)}`}n.addEventListener(`message`,m);function v(e){let t=_(),n=new u;return o.set(t,e=>{e.error?n.reject(new l(e.error.code,e.error.message,e.error.data)):n.resolve(e.result),o.delete(t)}),h({id:t,topic:e.method,data:{method:e.method,params:e.params}}).catch(e=>{o.delete(t),n.reject(e)}),n.promise}function y(e,t){let n=_();return o.set(n,e=>{e.error?o.delete(n):t(e.result)}),h({id:n,topic:e.method,data:{method:e.method,params:e.params}}).catch(e=>{o.delete(n)}),()=>{o.delete(n)}}function b(){n.removeEventListener(`message`,m),o.clear()}return{request:v,listen:y,sendLifecycle:g,cleanup:b}}function f(e){return new TextEncoder().encode(JSON.stringify(e))}function p(e){try{return JSON.parse(new TextDecoder().decode(e))}catch{return null}}const m=`frak-client-id`;function h(){return typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}function g(){if(typeof window>`u`||!window.localStorage)return h();let e=localStorage.getItem(m);return e||(e=h(),localStorage.setItem(m,e)),e}var _=class extends Map{maxSize;constructor(e){super(),this.maxSize=e}get(e){let t=super.get(e);return super.has(e)&&(super.delete(e),super.set(e,t)),t}set(e,t){if(super.has(e)&&super.delete(e),super.set(e,t),this.maxSize&&this.size>this.maxSize){let e=super.keys().next().value;e!==void 0&&super.delete(e)}return this}};const v=new _(1024),y=new _(1024),b=new _(1024);async function x(e,{cacheKey:t,cacheTime:n=3e4}){if(n>0){let e=y.get(t);if(e&&Date.now()-e.created<n)return e.data}let r=b.get(t);if(r&&Date.now()-r<1e3)throw Error(`Cache: ${t} recently failed, backing off`);let i=v.get(t);i||(i=e(),v.set(t,i));try{let e=await i;return y.set(t,{data:e,created:Date.now()}),b.delete(t),e}catch(e){throw b.set(t,Date.now()),e}finally{v.delete(t)}}function S(){v.clear(),y.clear(),b.clear()}const ee=`https://backend.frak.id`;function te(e){return e.includes(`localhost:3000`)||e.includes(`localhost:3010`)}function ne(e){return te(e)?`https://localhost:3030`:e.includes(`wallet-dev.frak.id`)||e.includes(`wallet.gcp-dev.frak.id`)?`https://backend.gcp-dev.frak.id`:ee}function C(e){if(e)return ne(e);if(typeof window<`u`){let e=window.FrakSetup?.client?.config?.walletUrl;if(e)return ne(e)}return ee}const w=`__frakSdkConfig`,re=`frak-config-cache`,T=`frak-merchant-id`,E={key:re},D=typeof window<`u`;function O(){return{isResolved:!1,merchantId:``}}let k=null;function ie(){if(!D)return null;try{let e=localStorage.getItem(E.key);if(!e)return null;let t=JSON.parse(e);return t.config?.isResolved?(k=t,t):null}catch{return null}}function ae(){return(k??ie())?.config}function oe(){let e=k??ie();return e?Date.now()-e.timestamp<3e4:!1}function se(e){if(!(!D||!e.isResolved))try{let t={config:e,timestamp:Date.now()};localStorage.setItem(E.key,JSON.stringify(t)),k=t}catch{}}function ce(){if(D){k=null;try{localStorage.removeItem(E.key)}catch{}}}function le(){D&&(window[w]||(window[w]=ae()??O()))}le();function A(){return D?window[w]??O():O()}function ue(e){D&&window.dispatchEvent(new CustomEvent(`frak:config`,{detail:e}))}function de(e){return e??(D?window.location.hostname:``)}async function fe(e,t,n){try{let r=C(t),i=n?`&lang=${encodeURIComponent(n)}`:``,a=await fetch(`${r}/user/merchant/resolve?domain=${encodeURIComponent(e)}${i}`);if(!a.ok)return;let o=await a.json();if(D)try{sessionStorage.setItem(T,o.merchantId)}catch{}return o}catch{return}}const j={getConfig:A,get isResolved(){return A().isResolved},get isCacheFresh(){return oe()},setCacheScope(e,t){E.key=`${re}:${`${e}:${t??``}`}`,k=null},setConfig(e){if(D&&(window[w]=e),se(e),ue(e),D&&e.merchantId)try{sessionStorage.setItem(T,e.merchantId)}catch{}},reset(){let e=ae()??O();D&&(window[w]=e),ue(e)},clearCache(){if(ce(),S(),D)try{sessionStorage.removeItem(T)}catch{}},resolve(e,t,n){let r=de(e);return r?x(async()=>{let e=await fe(r,t,n);if(!e)throw Error(`Config resolution returned empty`);return e},{cacheKey:`sdkConfig:${r}:${n??``}`,cacheTime:1/0}).catch(()=>void 0):Promise.resolve(void 0)},getMerchantId(){let e=A();if(e.isResolved&&e.merchantId)return e.merchantId;if(D)try{return sessionStorage.getItem(T)??void 0}catch{}},async resolveMerchantId(e,t){return j.getMerchantId()||(await j.resolve(e,t))?.merchantId}};function M(e){return btoa(Array.from(e,e=>String.fromCharCode(e)).join(``)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function N(e){let t=e.length%4;return Uint8Array.from(atob(e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(e.length+(t===0?0:4-t),`=`)),e=>e.charCodeAt(0))}function pe(e){return M(f(e))}function me(e,t,n,r,i,a){let o=pe(he({redirectUrl:t.redirectUrl,directExit:t.directExit,lang:t.lang,merchantId:n,metadata:{name:r,css:a,logoUrl:t.metadata?.logoUrl,homepageLink:t.metadata?.homepageLink},clientId:i})),s=new URL(e);return s.pathname=`/sso`,s.searchParams.set(`p`,o),s.toString()}function he(e){return{r:e.redirectUrl,cId:e.clientId,d:e.directExit,l:e.lang,m:e.merchantId,md:{n:e.metadata?.name,css:e.metadata?.css,l:e.metadata?.logoUrl,h:e.metadata?.homepageLink}}}const ge=`menubar=no,status=no,scrollbars=no,fullscreen=no,width=500, height=800`,_e=`frak-sso`;async function ve(e,t){let{metadata:n,customizations:r,walletUrl:i}=e.config,a={...t,directExit:t.directExit??!t.redirectUrl};if(a.openInSameWindow??!!a.redirectUrl)return await e.request({method:`frak_openSso`,params:[a,n.name,r?.css]});let o=a.ssoPopupUrl??me(i??`https://wallet.frak.id`,a,await j.resolveMerchantId()??``,n.name,g(),r?.css),s=window.open(o,_e,ge);if(!s)throw Error(`Popup was blocked. Please allow popups for this site.`);return s.focus(),await e.request({method:`frak_openSso`,params:[a,n.name,r?.css]})??{}}function P(e,t,n){if(e)try{e.openPanel?.track(t,n)}catch{}}function F(e,t){let n=e.get(t);if(n!==null)return n;let r=t.toLowerCase();for(let[t,n]of e)if(t.toLowerCase()===r)return n;return null}function I(e,t){let n=t.toLowerCase(),r=[...e.keys()].filter(e=>e.toLowerCase()===n);for(let t of r)e.delete(t)}const ye=/^0x[a-fA-F0-9]{40}$/;function L(e){return typeof e==`string`&&ye.test(e)}function be(e,t){return e.toLowerCase()===t.toLowerCase()}function xe(e){let t=new Uint8Array(20);for(let n=0;n<20;n++){let r=Number.parseInt(e.substring(2+n*2,4+n*2),16);if(Number.isNaN(r))throw Error(`Invalid address: ${e}`);t[n]=r}return t}const Se=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function Ce(e){let t=`0x`;for(let n=0;n<20;n++)t+=Se[e[n]];return t}function we(e){return`r`in e&&!(`v`in e)}function R(e){return`v`in e&&e.v===2}const Te=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Ee(e){return typeof e==`string`&&Te.test(e)}function De(e){let t=e.replace(/-/g,``),n=new Uint8Array(16);for(let e=0;e<16;e++)n[e]=Number.parseInt(t.substring(e*2,e*2+2),16);return n}function Oe(e){let t=``;for(let n=0;n<16;n++)t+=e[n].toString(16).padStart(2,`0`);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20,32)}`}function ke(e){if(!Ee(e.m)||!Number.isInteger(e.t)||e.t<0||e.t>4294967295)return null;let t=typeof e.c==`string`&&e.c.length>0,n=typeof e.w==`string`&&L(e.w);if(!t&&!n||t&&!Ee(e.c))return null;let r=new Uint8Array(21+(t?16:0)+(n?20:0)),i=new DataView(r.buffer,r.byteOffset,r.byteLength),a=0;return r[a++]=2|(t?16:0)|(n?32:0),r.set(De(e.m),a),a+=16,i.setUint32(a,e.t,!1),a+=4,t&&(r.set(De(e.c),a),a+=16),n&&(r.set(xe(e.w),a),a+=20),r}function Ae(e){if(e.length<21)return null;let t=e[0];if((t&15)!=2||t&192)return null;let n=(t&16)!=0,r=(t&32)!=0;if(!n&&!r)return null;let i=21+(n?16:0)+(r?20:0);if(e.length!==i)return null;let a=1,o=Oe(e.subarray(a,a+16));a+=16;let s=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(a,!1);a+=4;let c={v:2,m:o,t:s};if(n&&(c.c=Oe(e.subarray(a,a+16)),a+=16),r){let t=Ce(e.subarray(a,a+20));if(!L(t))return null;c.w=t,a+=20}return c}const z=`fCtx`;function je(e){if(e)try{if(R(e)){let t=ke(e);return t?M(t):void 0}return M(xe(e.r))}catch{}}function Me(e){if(!(!e||e.length===0))try{let t=N(e);if(t.length!==20)return Ae(t)||void 0;let n=Ce(t);if(L(n))return{r:n}}catch{}}function Ne({url:e}){if(!e)return null;let t=F(new URL(e).searchParams,z);return t?Me(t):null}function Pe(e){return{utm_source:e.utmSource??`frak`,utm_medium:e.utmMedium??void 0,utm_campaign:e.utmCampaign??void 0,utm_content:e.utmContent,utm_term:e.utmTerm,via:e.via??void 0,ref:e.ref??void 0}}function Fe(e,t){let n=Pe(t??{});for(let[t,r]of Object.entries(n))r===void 0||r===``||e.searchParams.has(t)||e.searchParams.set(t,r)}function Ie({url:e,context:t,attribution:n}){if(!e)return null;let r=je(t);if(!r)return null;let i=new URL(e);return I(i.searchParams,z),i.searchParams.set(z,r),Fe(i,n),i.toString()}function Le(e){let t=new URL(e);return I(t.searchParams,z),t.toString()}function Re({url:e,context:t}){if(!window.location?.href||typeof window>`u`)return;let n=e??window.location.href,r;r=t===null?Le(n):Ie({url:n,context:t}),r&&window.history.replaceState(null,``,r.toString())}const B={compress:je,decompress:Me,parse:Ne,update:Ie,remove:Le,replaceUrl:Re};var ze=class{constructor(e){this.baseUrl=e.baseUrl,this.headers={"Content-Type":`application/json`,...e.defaultHeaders},this.maxRetries=e.maxRetries??3,this.initialRetryDelay=e.initialRetryDelay??500}async resolveHeaders(){let e={};for(let[t,n]of Object.entries(this.headers)){let r=await n;r!==null&&(e[t]=r)}return e}addHeader(e,t){this.headers[e]=t}async post(e,t,n,r){try{let r=await fetch(e,{method:`POST`,headers:await this.resolveHeaders(),body:t?JSON.stringify(t??{}):void 0,keepalive:!0,...n});if(r.status===401)return null;if(r.status!==200&&r.status!==202)throw Error(`HTTP error! status: ${r.status}`);let i=await r.text();return i?JSON.parse(i):null}catch{if(r<this.maxRetries){let i=this.initialRetryDelay*2**r;return await new Promise(e=>setTimeout(e,i)),this.post(e,t,n,r+1)}return null}}async fetch(e,t,n={}){let r=`${this.baseUrl}${e}`;return this.post(r,t,n,0)}},Be=class{constructor(e){this.groups=[],this.queue=[],this.options=e;let t={"openpanel-client-id":e.clientId};e.clientSecret&&(t[`openpanel-client-secret`]=e.clientSecret),t[`openpanel-sdk-name`]=e.sdk||`node`,t[`openpanel-sdk-version`]=e.sdkVersion||`1.3.1`,this.api=new ze({baseUrl:e.apiUrl||`https://api.openpanel.dev`,defaultHeaders:t})}init(){}ready(){this.options.disabled=!1,this.options.waitForProfile=!1,this.flush()}shouldQueue(e){return!!(this.options.disabled||this.options.waitForProfile&&!this.profileId||e.type===`replay`&&!this.sessionId)}addQueue(e){e.type===`track`&&(e.payload.properties={...e.payload.properties??{},__timestamp:new Date().toISOString()}),this.queue.push(e)}async send(e){if(this.options.filter&&!this.options.filter(e))return Promise.resolve();if(this.shouldQueue(e))return this.addQueue(e),Promise.resolve();let t=await this.api.fetch(`/track`,e,{keepalive:e.type!==`replay`});this.deviceId=t?.deviceId;let n=!!this.sessionId;return this.sessionId=t?.sessionId,!n&&this.sessionId&&this.flush(),t}setGlobalProperties(e){this.global={...this.global,...e}}track(e,t){this.log(`track event`,e,t);let{groups:n,profileId:r,...i}=t??{},a=[...new Set([...this.groups,...n??[]])];return this.send({type:`track`,payload:{name:e,profileId:r??this.profileId,groups:a.length>0?a:void 0,properties:{...this.global??{},...i}}})}identify(e){if(this.log(`identify user`,e),e.profileId&&(this.profileId=e.profileId,this.flush()),e.profileId&&Object.keys(e).length>1)return this.send({type:`identify`,payload:{...e,properties:{...this.global,...e.properties}}})}upsertGroup(e){return this.log(`upsert group`,e),this.send({type:`group`,payload:e})}setGroup(e){return this.log(`set group`,e),this.groups.includes(e)||(this.groups=[...this.groups,e]),this.send({type:`assign_group`,payload:{groupIds:[e],profileId:this.profileId}})}setGroups(e){return this.log(`set groups`,e),this.groups=[...new Set([...this.groups,...e])],this.send({type:`assign_group`,payload:{groupIds:e,profileId:this.profileId}})}alias(e){}increment(e){return this.send({type:`increment`,payload:e})}decrement(e){return this.send({type:`decrement`,payload:e})}revenue(e,t){let n=t?.deviceId;return delete t?.deviceId,this.track(`revenue`,{...t??{},...n?{__deviceId:n}:{},__revenue:e})}getDeviceId(){return this.deviceId??``}getSessionId(){return this.sessionId??``}fetchDeviceId(){return Promise.resolve(this.deviceId??``)}clear(){this.profileId=void 0,this.groups=[],this.deviceId=void 0,this.sessionId=void 0}buildFlushPayload(e){if(e.type===`replay`)return e.payload;if(e.type===`track`){let t=`groups`in e.payload?e.payload.groups??[]:[],n=[...new Set([...this.groups,...t])];return{...e.payload,profileId:e.payload.profileId??this.profileId,groups:n.length>0?n:void 0}}return e.type===`identify`||e.type===`increment`||e.type===`decrement`||e.type===`assign_group`?{...e.payload,profileId:e.payload.profileId??this.profileId}:e.payload}flush(){let e=[];for(let t of this.queue){if(this.shouldQueue(t)){e.push(t);continue}let n=this.buildFlushPayload(t);this.send({...t,payload:n})}this.queue=e}log(...e){this.options.debug}},Ve=typeof document<`u`?document.currentScript:null;function He(e){return e.replace(/([-_][a-z])/gi,e=>e.toUpperCase().replace(`-`,``).replace(`_`,``))}var Ue=class extends Be{constructor(e){if(super({sdk:`web`,sdkVersion:`1.4.1`,...e}),this.options=e,this.lastPath=``,this.pendingRevenues=[],!this.isServer()){try{let e=sessionStorage.getItem(`openpanel-pending-revenues`);if(e){let t=JSON.parse(e);Array.isArray(t)&&(this.pendingRevenues=t)}}catch{this.pendingRevenues=[]}if(this.setGlobalProperties({__referrer:document.referrer}),this.options.trackScreenViews&&(this.trackScreenViews(),setTimeout(()=>this.screenView(),0)),this.options.trackOutgoingLinks&&this.trackOutgoingLinks(),this.options.trackAttributes&&this.trackAttributes(),this.options.sessionReplay?.enabled){let e=this.options.sessionReplay.sampleRate??1;Math.random()<e&&this.loadReplayModule().then(e=>{e&&e.startReplayRecorder(this.options.sessionReplay,e=>{this.send({type:`replay`,payload:{...e}})})})}}}async loadReplayModule(){try{if(typeof __OPENPANEL_REPLAY_URL__<`u`){let e=Ve,t=this.options.sessionReplay?.scriptUrl||e?.src?.replace(`.js`,`-replay.js`)||`https://openpanel.dev/op1-replay.js`;return window.__openpanel_replay?window.__openpanel_replay:new Promise(e=>{let n=document.createElement(`script`);n.src=t,n.onload=()=>{e(window.__openpanel_replay??null)},n.onerror=()=>{e(null)},document.head.appendChild(n)})}return await import(`./replay-V6FXES7X.BoL9fAjx.js`)}catch{return null}}debounce(e,t){clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(e,t)}isServer(){return typeof document>`u`}trackOutgoingLinks(){this.isServer()||document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`a`);if(n&&t){let e=n.getAttribute(`href`);if(e?.startsWith(`http`))try{let r=new URL(e),i=window.location.hostname;r.hostname!==i&&super.track(`link_out`,{href:e,text:n.innerText||n.getAttribute(`title`)||t.getAttribute(`alt`)||t.getAttribute(`title`)})}catch{}}})}trackScreenViews(){if(this.isServer())return;let e=history.pushState;history.pushState=function(...t){let n=e.apply(this,t);return window.dispatchEvent(new Event(`pushstate`)),window.dispatchEvent(new Event(`locationchange`)),n};let t=history.replaceState;history.replaceState=function(...e){let n=t.apply(this,e);return window.dispatchEvent(new Event(`replacestate`)),window.dispatchEvent(new Event(`locationchange`)),n},window.addEventListener(`popstate`,()=>{window.dispatchEvent(new Event(`locationchange`))});let n=()=>this.debounce(()=>this.screenView(),50);this.options.trackHashChanges?window.addEventListener(`hashchange`,n):window.addEventListener(`locationchange`,n)}trackAttributes(){this.isServer()||document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`button`),r=t.closest(`a`),i=n?.getAttribute(`data-track`)?n:r?.getAttribute(`data-track`)?r:null;if(i){let e={};for(let t of i.attributes)t.name.startsWith(`data-`)&&t.name!==`data-track`&&(e[He(t.name.replace(/^data-/,``))]=t.value);let t=i.getAttribute(`data-track`);t&&super.track(t,e)}})}track(e,t){return super.track(e,{...t,__path:this.lastPath})}screenView(e,t){if(this.isServer())return;let n,r;typeof e==`string`?(n=e,r=t):(n=window.location.href,r=e),this.lastPath!==n&&(this.lastPath=n,super.track(`screen_view`,{...r??{},__path:n,__title:document.title}))}async flushRevenue(){let e=this.pendingRevenues.map(e=>super.revenue(e.amount,e.properties));await Promise.all(e),this.clearRevenue()}clearRevenue(){if(this.pendingRevenues=[],!this.isServer())try{sessionStorage.removeItem(`openpanel-pending-revenues`)}catch{}}pendingRevenue(e,t){if(this.pendingRevenues.push({amount:e,properties:t}),!this.isServer())try{sessionStorage.setItem(`openpanel-pending-revenues`,JSON.stringify(this.pendingRevenues))}catch{}}};const V=`nexus-wallet-backup`,H=`frakwallet://`;function We(e,t){if(typeof window>`u`)return;let n=new URL(window.location.href),r=n.searchParams.get(`sso`);r&&(t.then(()=>{e.sendLifecycle({clientLifecycle:`sso-redirect-complete`,data:{compressed:r}})}).catch(e=>{}),n.searchParams.delete(`sso`),window.history.replaceState({},``,n.toString()))}function Ge(){let e=navigator.userAgent;return/Android/i.test(e)&&/Chrome\/\d+/i.test(e)}const Ke=H.replace(`://`,``);function qe(e){return`intent://${e.slice(13)}#Intent;scheme=${Ke};end`}function U(e,t){let n=t?.timeout??2500,r=!1,i=()=>{document.hidden&&(r=!0)};document.addEventListener(`visibilitychange`,i);let a=Ge()&&Je(e)?qe(e):e;window.location.href=a,setTimeout(()=>{document.removeEventListener(`visibilitychange`,i),r||t?.onFallback?.()},n)}function Je(e){return e.startsWith(H)}const W={id:`frak-wallet`,name:`frak-wallet`,title:`Frak Wallet`,allow:`publickey-credentials-get *; clipboard-write; web-share *`,style:{width:`0`,height:`0`,border:`0`,position:`absolute`,zIndex:2000001,top:`-1000px`,left:`-1000px`,colorScheme:`auto`}};function Ye({walletBaseUrl:e,config:t}){let n=document.querySelector(`#frak-wallet`);n&&n.remove();let r=document.createElement(`iframe`);r.id=W.id,r.name=W.name,r.allow=W.allow,r.style.zIndex=W.style.zIndex.toString(),Xe({iframe:r,isVisible:!1});let i=t?.walletUrl??e??`https://wallet.frak.id`,a=g();return Qe(i),Qe(C(i)),r.src=`${i}/listener?clientId=${encodeURIComponent(a)}`,new Promise(e=>{r.addEventListener(`load`,()=>e(r)),document.body.appendChild(r)})}function Xe({iframe:e,isVisible:t}){if(!t){e.style.width=`0`,e.style.height=`0`,e.style.border=`0`,e.style.position=`fixed`,e.style.top=`-1000px`,e.style.left=`-1000px`;return}e.style.position=`fixed`,e.style.top=`0`,e.style.left=`0`,e.style.width=`100%`,e.style.height=`100%`,e.style.pointerEvents=`auto`}function Ze(e=`/listener`){if(!window.opener)return null;let t=t=>{try{return t.location.origin===window.location.origin&&t.location.pathname===e}catch{return!1}};if(t(window.opener))return window.opener;try{let e=window.opener.frames;for(let n=0;n<e.length;n++)if(t(e[n]))return e[n];return null}catch{return null}}function Qe(e){if(!(typeof document>`u`))try{let t=new URL(e).origin,n=`link[rel="preconnect"][data-frak-preconnect="${t}"]`;if(document.head.querySelector(n))return;let r=document.createElement(`link`);r.rel=`preconnect`,r.href=t,r.crossOrigin=``,r.dataset.frakPreconnect=t,document.head.appendChild(r)}catch{}}const $e=(()=>{if(typeof navigator>`u`)return!1;let e=navigator.userAgent;if(!(/iPhone|iPad|iPod/i.test(e)||/Macintosh/i.test(e)&&navigator.maxTouchPoints>1))return!1;let t=e.toLowerCase();return t.includes(`instagram`)||t.includes(`fban`)||t.includes(`fbav`)||t.includes(`facebook`)})();function et(e){e?localStorage.setItem(V,e):localStorage.removeItem(V)}function G(e,t){try{let n=new URL(e);if(!n.searchParams.has(`u`))return e;let r=rt(window.location.href,t);return n.searchParams.delete(`u`),n.searchParams.append(`u`,r),n.toString()}catch{return e}}function tt(e){let t=new URL(window.location.href);e&&t.searchParams.set(`fmt`,e);let n=t.protocol===`http:`?`x-safari-http`:`x-safari-https`;window.location.href=`${n}://${t.host}${t.pathname}${t.search}${t.hash}`}function nt(e){return e.includes(`/common/social`)}function rt(e,t){if(!t)return e;try{let n=new URL(e);return n.searchParams.set(`fmt`,t),n.toString()}catch{return`${e}${e.includes(`?`)?`&`:`?`}fmt=${encodeURIComponent(t)}`}}function it(e,t,n,r,i){if(i){let e=G(t,r);window.open(e,`_blank`);return}if(Je(t)){let i=G(t,r);U(i,{onFallback:()=>{e.contentWindow?.postMessage({clientLifecycle:`deep-link-failed`,data:{originalUrl:i}},n)}})}else if($e&&nt(t))tt(r);else{let e=G(t,r);window.location.href=e}}function at({iframe:e,targetOrigin:t}){let n=new u;return{handleEvent:r=>{if(!(`iframeLifecycle`in r))return;let{iframeLifecycle:i,data:a}=r;switch(i){case`connected`:n.resolve(!0);break;case`do-backup`:et(a.backup);break;case`remove-backup`:localStorage.removeItem(V);break;case`show`:case`hide`:Xe({iframe:e,isVisible:i===`show`});break;case`redirect`:it(e,a.baseRedirectUrl,t,a.mergeToken,a.openInNewTab);break}},isConnected:n.promise}}function ot({config:e,iframe:t}){let n=e?.walletUrl??`https://wallet.frak.id`,r=typeof navigator<`u`?navigator.language?.split(`-`)[0]:void 0,i=e.metadata.lang??(r===`en`||r===`fr`?r:void 0),a=e.domain??(typeof window<`u`?window.location.hostname:``);j.setCacheScope(a,i),j.reset();let o=j.isCacheFresh?void 0:j.resolve(e.domain,e.walletUrl,i),s=at({iframe:t,targetOrigin:n}),f=new u,p=Date.now();if(!t.contentWindow)throw new l(c.configError,`The iframe does not have a content window`);let m=d({emittingTransport:t.contentWindow,listeningTransport:window,targetOrigin:n,middleware:[{async onRequest(e,t){if(!await s.isConnected)throw new l(c.clientNotConnected,`The iframe provider isn't connected yet`);return await f.promise,t}}],lifecycleHandlers:{iframeLifecycle:(e,t)=>{s.handleEvent(e)}}}),h=st(m,s),_=async()=>{h(),m.cleanup(),t.remove(),S(),j.clearCache(),j.reset()},v;{v=new Ue({apiUrl:`https://op-api.gcp.frak.id`,clientId:`f305d11d-b93b-487c-80d4-92deb7903e98`,trackScreenViews:!0,trackOutgoingLinks:!0,trackAttributes:!1,filter:({type:e,payload:t})=>(e!==`track`||!t?.properties||`sdkVersion`in t.properties||(t.properties={...t.properties,sdkVersion:`1.1.4`,userAnonymousClientId:g()}),!0)}),v.setGlobalProperties({sdkVersion:`1.1.4`,userAnonymousClientId:g()}),v.init(),v.track(`sdk_initialized`,{sdkVersion:`1.1.4`});let e=!1,t=setTimeout(()=>{e||(e=!0,v?.track(`sdk_iframe_handshake_failed`,{reason:`timeout`}))},3e4);s.isConnected.then(()=>{e||(e=!0,clearTimeout(t),v?.track(`sdk_iframe_connected`,{handshake_duration_ms:Date.now()-p}))}).catch(()=>{e||(e=!0,clearTimeout(t),v?.track(`sdk_iframe_handshake_failed`,{reason:`unknown`}))})}let y=ct({config:e,rpcClient:m,lifecycleManager:s,configPromise:o,contextSent:f,openPanel:v}).then(()=>{}).catch(e=>{throw f.reject(e),e});return{config:e,waitForConnection:s.isConnected,waitForSetup:y,request:m.request,listenerRequest:m.listen,destroy:_,openPanel:v}}function st(e,t){let n,r,i=()=>e.sendLifecycle({clientLifecycle:`heartbeat`});async function a(){i(),n=setInterval(i,250),r=setTimeout(()=>{o()},3e4),await t.isConnected,o()}function o(){n&&clearInterval(n),r&&clearTimeout(r)}return a(),o}async function ct({config:e,rpcClient:t,lifecycleManager:n,configPromise:r,contextSent:i,openPanel:a}){await n.isConnected,We(t,n.isConnected);let o=new URL(window.location.href),s=o.searchParams.get(`fmt`)??void 0;s&&(o.searchParams.delete(`fmt`),window.history.replaceState({},``,o.toString()));let c=t=>{let n=t?.merchantId??e.metadata.merchantId??``,r=t?.domain??``,i=t?.allowedDomains??[],a=t?.sdkConfig,o=a?.attribution||e.attribution?{...e.attribution,...a?.attribution}:void 0;j.setConfig(a?{isResolved:!0,merchantId:n,domain:r,allowedDomains:i,hasRawSdkConfig:!0,name:a.name??e.metadata.name,logoUrl:a.logoUrl??e.metadata.logoUrl,homepageLink:a.homepageLink??e.metadata.homepageLink,lang:a.lang??e.metadata.lang,currency:a.currency??e.metadata.currency,hidden:a.hidden,css:a.css,translations:a.translations,placements:a.placements,components:a.components,attribution:o}:{isResolved:!0,merchantId:n,domain:r,allowedDomains:i,name:e.metadata.name,logoUrl:e.metadata.logoUrl,homepageLink:e.metadata.homepageLink,lang:e.metadata.lang,currency:e.metadata.currency,attribution:o})},l=!1,u=e=>{let n=l?void 0:s;l=!0;let r=e.hasRawSdkConfig?{name:e.name,logoUrl:e.logoUrl,homepageLink:e.homepageLink,lang:e.lang,currency:e.currency,hidden:e.hidden,css:e.css,translations:e.translations,placements:e.placements,attribution:e.attribution}:e.attribution?{attribution:e.attribution}:void 0,i=g();if(a){let t=a.global??{};a.setGlobalProperties({...t,merchantId:e.merchantId,domain:e.domain??``})}t.sendLifecycle({clientLifecycle:`resolved-config`,data:{merchantId:e.merchantId,domain:e.domain??``,allowedDomains:e.allowedDomains??[],sourceUrl:window.location.href,...i&&{sdkAnonymousId:i},...n&&{pendingMergeToken:n},...r&&{sdkConfig:r}}})};j.isResolved&&(u(j.getConfig()),i.resolve()),r&&(c(await r),u(j.getConfig()),i.resolve());async function d(){let n=e.customizations?.css;n&&t.sendLifecycle({clientLifecycle:`modal-css`,data:{cssLink:n}})}async function f(){let n=e.customizations?.i18n;n&&t.sendLifecycle({clientLifecycle:`modal-i18n`,data:{i18n:n}})}async function p(){if(typeof window>`u`)return;let e=window.localStorage.getItem(V);e&&t.sendLifecycle({clientLifecycle:`restore-backup`,data:{backup:e}})}(await Promise.allSettled([d(),f(),p()])).some(e=>e.status===`rejected`)&&a?.track(`sdk_iframe_handshake_failed`,{reason:`asset_push`})}function lt(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent;return!!(/iPhone|iPad|iPod/i.test(e)||/Macintosh/i.test(e)&&navigator.maxTouchPoints>1)}const K=lt();function ut(){return typeof navigator>`u`?!1:K?!0:/Android|webOS|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}function dt(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent.toLowerCase();return e.includes(`instagram`)||e.includes(`fban`)||e.includes(`fbav`)||e.includes(`facebook`)}const ft=dt();function pt(e){K&&e.startsWith(`https://`)?window.location.href=`x-safari-https://${e.slice(8)}`:K&&e.startsWith(`http://`)?window.location.href=`x-safari-http://${e.slice(7)}`:window.location.href=`https://backend.frak.id/common/social?u=${encodeURIComponent(e)}`}function mt(e){return p(N(e))}const q={eur:`fr-FR`,usd:`en-US`,gbp:`en-GB`};function J(e){return e&&e in q?e:`eur`}function ht(e){return e?q[e]??q.eur:q.eur}function gt(e,t){let n=ht(t),r=J(t);return e.toLocaleString(n,{style:`currency`,currency:r,minimumFractionDigits:0,maximumFractionDigits:2})}function _t(e){return e?`${e}Amount`:`eurAmount`}async function vt({config:e}){let t=yt(e),n=await Ye({config:t});if(!n)return;let r=ot({config:t,iframe:n});if(await r.waitForSetup,await r.waitForConnection)return r}function yt(e){let t=J(e.metadata?.currency);return{...e,metadata:{...e.metadata,currency:t}}}function bt({perCall:e,defaults:t,productUtmContent:n}){if(e===null)return;let r=e!==void 0,i=t!==void 0&&Object.keys(t).length>0;if(!r&&!i&&!(n!==void 0&&n!==``))return;let a={...t,...e??{}},o=n??e?.utmContent;return o!==void 0&&o!==``?a.utmContent=o:delete a.utmContent,a}var xt=t({DEEP_LINK_SCHEME:()=>H,FrakContextManager:()=>B,base64urlDecode:()=>N,base64urlEncode:()=>M,baseIframeProps:()=>W,clearAllCache:()=>S,compressJsonToB64:()=>pe,createIFrameFrakClient:()=>ot,decompressJsonFromB64:()=>mt,deleteQueryParamCaseInsensitive:()=>I,findIframeInOpener:()=>Ze,formatAmount:()=>gt,generateSsoUrl:()=>me,getBackendUrl:()=>C,getClientId:()=>g,getCurrencyAmountKey:()=>_t,getQueryParamCaseInsensitive:()=>F,getSupportedCurrency:()=>J,isIOS:()=>K,isInAppBrowser:()=>ft,isMobile:()=>ut,mergeAttribution:()=>bt,redirectToExternalBrowser:()=>pt,sdkConfigStore:()=>j,setupClient:()=>vt,ssoPopupFeatures:()=>ge,ssoPopupName:()=>_e,trackEvent:()=>P,triggerDeepLinkWithFallback:()=>U,withCache:()=>x});async function St(e,t,n){return await e.request({method:`frak_displayEmbeddedWallet`,params:n?[t,e.config.metadata,n]:[t,e.config.metadata]})}async function Y(e,{steps:t,metadata:n},r){return await e.request({method:`frak_displayModal`,params:r?[t,n,e.config.metadata,r]:[t,n,e.config.metadata]})}async function Ct(e,t,n){return await e.request({method:`frak_displaySharingPage`,params:n?[t,e.config.metadata,n]:[t,e.config.metadata]})}async function wt(e){if(typeof window>`u`)return;let t=g();if(!t)return;let n=await j.resolveMerchantId();if(!n)return;let r=`frak-identity-ensured-${n}`;if(!window.sessionStorage.getItem(r))try{let i=C();(await fetch(`${i}/user/identity/ensure`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"x-wallet-sdk-auth":e,"x-frak-client-id":t},body:JSON.stringify({merchantId:n})})).ok&&window.sessionStorage.setItem(r,`1`)}catch{}}async function Tt(e,t){return x(()=>e.request({method:`frak_getMerchantInformation`}),{cacheKey:`frak_getMerchantInformation`,cacheTime:t?.cacheTime})}async function Et(e,t){return x(()=>e.request({method:`frak_getMergeToken`}),{cacheKey:`frak_getMergeToken`,cacheTime:t?.cacheTime})}async function Dt(e,t){return x(()=>e.request({method:`frak_getUserReferralStatus`}),{cacheKey:`frak_getUserReferralStatus`,cacheTime:t?.cacheTime})}async function Ot(e,t){let{metadata:n,customizations:r}=e.config;return await e.request({method:`frak_prepareSso`,params:[t,n.name,r?.css]})}async function X(e,t){try{await e.request({method:`frak_sendInteraction`,params:[t,{clientId:g()}]})}catch{}}function kt(e,t,n){return R(t)?(P(e,`user_referred_started`,{referrerClientId:t.c,referrerWallet:t.w,walletStatus:n?.key}),X(e,{type:`arrival`,referrerClientId:t.c,referrerMerchantId:t.m,referrerWallet:t.w,referralTimestamp:t.t}),!0):we(t)?(P(e,`user_referred_started`,{referrer:t.r,walletStatus:n?.key}),X(e,{type:`arrival`,referrerWallet:t.r}),!0):!1}function At(e,t){let n=g();return!n&&!t?null:{v:2,m:e,t:Math.floor(Date.now()/1e3),...n?{c:n}:{},...t?{w:t}:{}}}function jt(e,t){return R(e)?e.w&&t?.wallet?be(e.w,t.wallet):e.c?g()===e.c:!1:we(e)&&t?.wallet?be(e.r,t.wallet):!1}function Mt(e,{walletStatus:t,frakContext:n,options:r}){if(!n)return`no-referrer`;if(jt(n,t))return`self-referral`;if(!kt(e,n,t))return`no-referrer`;let i=R(n)?n.m:r?.merchantId,a=r?.alwaysAppendUrl&&i?At(i,t?.wallet):null;return B.replaceUrl({url:window.location?.href,context:a}),P(e,`user_referred_completed`,{status:`success`}),`success`}async function Nt(e,{options:t}={}){let n=B.parse({url:window.location.href}),r=await Ft(e);try{return Mt(e,{walletStatus:r,frakContext:n,options:t})}catch{}}const Z=`frak:referral-success`;async function Q(e){try{await Nt(e)===`success`&&window.dispatchEvent(new Event(Z))}catch{}}async function Pt(e){if(typeof window>`u`)return;let t=window.sessionStorage.getItem(`frak-wallet-interaction-token`),n=g();if(!t&&!n)return;let r=e.merchantId??await j.resolveMerchantId();if(!r)return;let i={Accept:`application/json`,"Content-Type":`application/json`};t&&(i[`x-wallet-sdk-auth`]=t),n&&(i[`x-frak-client-id`]=n);let a=C();await fetch(`${a}/user/track/purchase`,{method:`POST`,headers:i,body:JSON.stringify({customerId:e.customerId,orderId:e.orderId,token:e.token,merchantId:r})})}function Ft(e,t){if(!t)return e.request({method:`frak_listenToWalletStatus`}).then(t=>(It(e,t),t));let n=new u,r=!1;return e.listenerRequest({method:`frak_listenToWalletStatus`},i=>{It(e,i),t(i),r||=(n.resolve(i),!0)}),n.promise}function It(e,t){typeof window>`u`||(e.openPanel?.setGlobalProperties({wallet:t.wallet??null}),t.interactionToken?(window.sessionStorage.setItem(`frak-wallet-interaction-token`,t.interactionToken),wt(t.interactionToken)):window.sessionStorage.removeItem(`frak-wallet-interaction-token`))}function Lt(e,{metadata:t,login:n}){return $(e,{steps:{login:n??{}},metadata:t})}function $(e,t){function n(n){return $(e,{...t,steps:{...t.steps,sendTransaction:n}})}function r(n){return $(e,{...t,steps:{...t.steps,final:{...n,action:{key:`reward`}}}})}function i(n,r){return $(e,{...t,steps:{...t.steps,final:{...r,action:{key:`sharing`,options:n}}}})}async function a(n,r){return n&&(t.metadata=n(t.metadata??{})),await Y(e,t,r)}return{params:t,sendTx:n,reward:r,sharing:i,display:a}}async function Rt(e,{tx:t,metadata:n}){return(await Y(e,{metadata:n,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}function zt(e=96){let t=Math.ceil(e/2),n=``;if(typeof crypto<`u`&&crypto.getRandomValues){let e=new Uint8Array(t);crypto.getRandomValues(e);for(let t=0;t<e.length;t++)n+=e[t].toString(16).padStart(2,`0`)}else for(let e=0;e<t;e++)n+=(Math.random()*256|0).toString(16).padStart(2,`0`);return n.substring(0,e)}async function Bt(e,{siwe:t,metadata:n}){let r=e.config?.domain??window.location.host,i=t?.statement??`I confirm that I want to use my Frak wallet on: ${e.config.metadata.name}`;return(await Y(e,{metadata:n,steps:{login:{},siweAuthenticate:{siwe:{...t,statement:i,nonce:t?.nonce??zt(),uri:t?.uri??`https://${r}`,version:t?.version??`1`,domain:r}}}})).siweAuthenticate}var Vt=t({REFERRAL_SUCCESS_EVENT:()=>Z,displayEmbeddedWallet:()=>St,displayModal:()=>Y,displaySharingPage:()=>Ct,ensureIdentity:()=>wt,getMerchantInformation:()=>Tt,getMergeToken:()=>Et,getUserReferralStatus:()=>Dt,modalBuilder:()=>Lt,openSso:()=>ve,prepareSso:()=>Ot,processReferral:()=>Mt,referralInteraction:()=>Nt,sendInteraction:()=>X,sendTransaction:()=>Rt,setupReferral:()=>Q,siweAuthenticate:()=>Bt,trackPurchaseStatus:()=>Pt,watchWalletStatus:()=>Ft});async function Ht(e,t,n){window.FrakSetup?.client&&await Ct(window.FrakSetup.client,{...n?.link&&{link:n.link},...n?.products?.length&&{products:n.products},...e&&{metadata:{targetInteraction:e}}},t)}function Ut(e){try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function Wt(e){if(!e)return null;if(Array.isArray(e))return e;if(typeof e!=`string`)return null;try{let t=JSON.parse(e);return Array.isArray(t)?t:null}catch{return null}}function Gt(e){if(!e||typeof e!=`object`)return null;let t=e,n=typeof t.title==`string`?t.title.trim():``;if(n===``)return null;let r={title:n};return typeof t.imageUrl==`string`&&Ut(t.imageUrl)&&(r.imageUrl=t.imageUrl),typeof t.link==`string`&&Ut(t.link)&&(r.link=t.link),typeof t.utmContent==`string`&&t.utmContent!==``&&(r.utmContent=t.utmContent),r}function Kt(e){let t=Wt(e);if(!t)return;let n=[];for(let e of t){let t=Gt(e);t&&n.push(t)}return n.length>0?n:void 0}function qt(e){if(!e)return;let t;try{t=mt(e)}catch{return}if(t!==null)return Kt(t)}const Jt=`frak:client`;function Yt(){let e=new CustomEvent(Jt);window.dispatchEvent(e)}function Xt(e,t){if(window.FrakSetup?.client&&e===`add`){t();return}(e===`add`?window.addEventListener:window.removeEventListener)(Jt,t,!1)}function Zt(){return window.FrakSetup.core={...xt,...Vt},window.FrakSetup?.client?Promise.resolve():x(()=>Qt(),{cacheKey:`frak-sdk-init`,cacheTime:1/0}).catch(e=>{P(window.FrakSetup?.client,`sdk_init_failed`,{reason:e instanceof Error?e.message:typeof e==`string`?e:`unknown`,config_missing:!window.FrakSetup?.config})})}async function Qt(){if(!window.FrakSetup?.config)throw Error(`[Frak SDK] Configuration not found. Please ensure window.FrakSetup.config is set.`);let e=await vt({config:window.FrakSetup.config});if(!e)throw Error(`[Frak SDK] Failed to create client`);window.FrakSetup.client=e,Yt(),Q(e),$t()}function $t(){let e=new URL(window.location.href);if(F(e.searchParams,`frakAction`)?.toLowerCase()!==`share`)return;let t=F(e.searchParams,`link`)??void 0,n=F(e.searchParams,`placement`)??void 0,r=qt(F(e.searchParams,`products`));I(e.searchParams,`frakAction`),I(e.searchParams,`link`),I(e.searchParams,`placement`),I(e.searchParams,`products`),window.history.replaceState({},``,e.toString()),Ht(void 0,n,{link:t,products:r})}o.injectBase(`shared`,n),o.injectBase(`fouce`,`frak-button-share:not(:defined), frak-button-wallet:not(:defined), frak-open-in-app:not(:defined), frak-post-purchase:not(:defined), frak-banner:not(:defined) { display: none !important; }`),s(Zt);const en={"button-share":()=>import(`./ButtonShare.D9-F0jJJ.js`),"button-wallet":()=>import(`./ButtonWallet.B0buPR_z.js`),"open-in-app":()=>import(`./OpenInAppButton.Dgb-qhM8.js`),"post-purchase":()=>import(`./PostPurchase.BYxnAEyn.js`),banner:()=>import(`./Banner.CcOWT4lZ.js`)},tn=new MutationObserver(e=>{for(let{addedNodes:t}of e)for(let e of Array.from(t))e.nodeType===Node.ELEMENT_NODE&&nn(e)});async function nn(e){let t=e instanceof Element?e.tagName.toLowerCase():``,n=t?.startsWith(`frak-`),r=Array.from(e.querySelectorAll(`:not(:defined)`)).map(e=>e.tagName.toLowerCase()).filter(e=>e.startsWith(`frak-`));n&&!customElements.get(t)&&r.push(t);let i=[...new Set(r)];await Promise.allSettled(i.map(e=>rn(e)))}async function rn(e){if(customElements.get(e))return Promise.resolve();try{let t=e.replace(/^frak-/i,``);if(!(t in en))throw Error(`Component ${e} is not supported.`);await en[t]()}catch{}}nn(document.body),tn.observe(document.documentElement,{subtree:!0,childList:!0});export{s as C,l as S,n as T,H as _,Pt as a,P as b,Tt as c,pt as d,gt as f,U as g,J as h,Ht as i,St as l,ut as m,Xt as n,Dt as o,_t as p,Kt as r,Et as s,Zt as t,Z as u,ft as v,o as w,c as x,j as y};
|
|
154
|
+
}`;function r(e,t){let n=document.getElementById(e);if(n){n.textContent!==t&&(n.textContent=t);return}let r=document.createElement(`style`);r.id=e,r.textContent=t,document.head.appendChild(r)}function i(e,t){let n=`frak-base-${e}`;if(document.getElementById(n)||!t)return;let r=document.createElement(`style`);r.id=n,r.textContent=t,document.head.appendChild(r)}function a(e,t,n){r(`frak-placement-${e}-${t}`,n)}const o={injectBase:i,injectPlacement:a};function s(e){document.readyState===`complete`||document.readyState===`interactive`?setTimeout(e,1):document.addEventListener(`DOMContentLoaded`,e)}const c={parseError:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internalError:-32603,serverError:-32e3,clientNotConnected:-32001,configError:-32002,corruptedResponse:-32003,clientAborted:-32004,walletNotConnected:-32005,serverErrorForInteractionDelegation:-32006,userRejected:-32007};var l=class extends Error{code;data;constructor(e,t,n){super(t),this.code=e,this.data=n}toJSON(){return{code:this.code,message:this.message,data:this.data}}},u=class{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}get promise(){return this._promise}resolve=e=>{this._resolve?.(e)};reject=e=>{this._reject?.(e)}};function d(e){let{emittingTransport:t,listeningTransport:n,targetOrigin:r,middleware:i=[],lifecycleHandlers:a}=e,o=new Map;function s(e){return typeof e!=`object`||!e?!1:`clientLifecycle`in e||`iframeLifecycle`in e}function c(e){return typeof e!=`object`||!e?!1:`id`in e&&`topic`in e&&`data`in e}async function d(e){try{`clientLifecycle`in e&&a?.clientLifecycle?await a.clientLifecycle(e,{origin:r,source:null}):`iframeLifecycle`in e&&a?.iframeLifecycle&&await a.iframeLifecycle(e,{origin:r,source:null})}catch(e){console.error(`[RPC Client] Lifecycle handler error:`,e)}}async function f(e){let t={origin:r,source:null};for(let n of i)n.onRequest&&await n.onRequest(e,t);return e}async function p(e,t){let n={origin:r,source:null},a=t;for(let t of i)t.onResponse&&(a=await t.onResponse(e,a,n));return a}async function m(e){try{let t=new URL(e.origin).origin.toLowerCase(),n=new URL(r).origin.toLowerCase();if(t!==n){console.log(`Not expected origin`,t,n);return}}catch(e){console.error(`[RPC Client] Invalid origin`,e);return}if(s(e.data)){await d(e.data);return}if(!c(e.data))return;let t;try{let n=e.data.data,r=n instanceof Uint8Array||ArrayBuffer.isView(n)?{result:n}:n;t=await p(e.data,r)}catch(e){console.error(`[RPC Client] Middleware error on response:`,e);return}let n=o.get(e.data.id);n&&n(t)}async function h(e){let n=e;try{n=await f(e)}catch(e){throw console.error(`[RPC Client] Middleware error on request:`,e),e}t.postMessage(n,r)}function g(e){t.postMessage(e,r)}function _(){return`${Date.now()}-${Math.random().toString(36).substring(2,9)}`}n.addEventListener(`message`,m);function v(e){let t=_(),n=new u;return o.set(t,e=>{e.error?n.reject(new l(e.error.code,e.error.message,e.error.data)):n.resolve(e.result),o.delete(t)}),h({id:t,topic:e.method,data:{method:e.method,params:e.params}}).catch(e=>{o.delete(t),n.reject(e)}),n.promise}function y(e,t){let n=_();return o.set(n,e=>{e.error?(console.error(`[RPC Client] Listener error:`,e.error),o.delete(n)):t(e.result)}),h({id:n,topic:e.method,data:{method:e.method,params:e.params}}).catch(e=>{console.error(`[RPC Client] Failed to send listener request:`,e),o.delete(n)}),()=>{o.delete(n)}}function b(){n.removeEventListener(`message`,m),o.clear()}return{request:v,listen:y,sendLifecycle:g,cleanup:b}}function f(e){return new TextEncoder().encode(JSON.stringify(e))}function p(e){try{return JSON.parse(new TextDecoder().decode(e))}catch{return null}}const m=`frak-client-id`;function h(){return typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}function g(){if(typeof window>`u`||!window.localStorage)return console.warn(`[Frak SDK] No Window / localStorage available to save the clientId`),h();let e=localStorage.getItem(m);return e||(e=h(),localStorage.setItem(m,e)),e}var _=class extends Map{maxSize;constructor(e){super(),this.maxSize=e}get(e){let t=super.get(e);return super.has(e)&&(super.delete(e),super.set(e,t)),t}set(e,t){if(super.has(e)&&super.delete(e),super.set(e,t),this.maxSize&&this.size>this.maxSize){let e=super.keys().next().value;e!==void 0&&super.delete(e)}return this}};let v;function y(){return v||={promiseCache:new _(1024),responseCache:new _(1024),failureCache:new _(1024)},v}async function b(e,{cacheKey:t,cacheTime:n=3e4}){let{promiseCache:r,responseCache:i,failureCache:a}=y();if(n>0){let e=i.get(t);if(e&&Date.now()-e.created<n)return e.data}let o=a.get(t);if(o&&Date.now()-o<1e3)throw Error(`Cache: ${t} recently failed, backing off`);let s=r.get(t);s||(s=e(),r.set(t,s));try{let e=await s;return i.set(t,{data:e,created:Date.now()}),a.delete(t),e}catch(e){throw a.set(t,Date.now()),e}finally{r.delete(t)}}function x(){v&&(v.promiseCache.clear(),v.responseCache.clear(),v.failureCache.clear())}const ee=`https://backend.frak.id`;function te(e){return e.includes(`localhost:3000`)||e.includes(`localhost:3010`)}function ne(e){return te(e)?`https://localhost:3030`:e.includes(`wallet-dev.frak.id`)||e.includes(`wallet.gcp-dev.frak.id`)?`https://backend.gcp-dev.frak.id`:ee}function S(e){if(e)return ne(e);if(typeof window<`u`){let e=window.FrakSetup?.client?.config?.walletUrl;if(e)return ne(e)}return ee}const C=`__frakSdkConfig`,re=`frak-config-cache`,w=`frak-merchant-id`,T={key:re},E=typeof window<`u`;function D(){return{isResolved:!1,merchantId:``}}let O=null;function ie(){if(!E)return null;try{let e=localStorage.getItem(T.key);if(!e)return null;let t=JSON.parse(e);return t.config?.isResolved?(O=t,t):null}catch{return null}}function ae(){return(O??ie())?.config}function oe(){let e=O??ie();return e?Date.now()-e.timestamp<3e4:!1}function se(e){if(!(!E||!e.isResolved))try{let t={config:e,timestamp:Date.now()};localStorage.setItem(T.key,JSON.stringify(t)),O=t}catch{}}function ce(){if(E){O=null;try{localStorage.removeItem(T.key)}catch{}}}function le(){E&&(window[C]||(window[C]=ae()??D()))}function k(){return E?(le(),window[C]??D()):D()}function ue(e){E&&window.dispatchEvent(new CustomEvent(`frak:config`,{detail:e}))}function de(e){return e??(E?window.location.hostname:``)}async function fe(e,t,n){try{let r=S(t),i=n?`&lang=${encodeURIComponent(n)}`:``,a=await fetch(`${r}/user/merchant/resolve?domain=${encodeURIComponent(e)}${i}`);if(!a.ok){console.warn(`[Frak SDK] Merchant lookup failed for domain ${e}: ${a.status}`);return}let o=await a.json();if(E)try{sessionStorage.setItem(w,o.merchantId)}catch{}return o}catch(e){console.warn(`[Frak SDK] Failed to fetch merchant config:`,e);return}}const A={getConfig:k,get isResolved(){return k().isResolved},get isCacheFresh(){return oe()},setCacheScope(e,t){T.key=`${re}:${`${e}:${t??``}`}`,O=null},setConfig(e){if(E&&(window[C]=e),se(e),ue(e),E&&e.merchantId)try{sessionStorage.setItem(w,e.merchantId)}catch{}},reset(){let e=ae()??D();E&&(window[C]=e),ue(e)},clearCache(){if(ce(),x(),E)try{sessionStorage.removeItem(w)}catch{}},resolve(e,t,n){let r=de(e);return r?b(async()=>{let e=await fe(r,t,n);if(!e)throw Error(`Config resolution returned empty`);return e},{cacheKey:`sdkConfig:${r}:${n??``}`,cacheTime:1/0}).catch(()=>void 0):Promise.resolve(void 0)},getMerchantId(){let e=k();if(e.isResolved&&e.merchantId)return e.merchantId;if(E)try{return sessionStorage.getItem(w)??void 0}catch{}},async resolveMerchantId(e,t){return A.getMerchantId()||(await A.resolve(e,t))?.merchantId}};function j(e){return btoa(Array.from(e,e=>String.fromCharCode(e)).join(``)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function M(e){let t=e.length%4;return Uint8Array.from(atob(e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(e.length+(t===0?0:4-t),`=`)),e=>e.charCodeAt(0))}function pe(e){return j(f(e))}function me(e,t,n,r,i,a){let o=pe(he({redirectUrl:t.redirectUrl,directExit:t.directExit,lang:t.lang,merchantId:n,metadata:{name:r,css:a,logoUrl:t.metadata?.logoUrl,homepageLink:t.metadata?.homepageLink},clientId:i})),s=new URL(e);return s.pathname=`/sso`,s.searchParams.set(`p`,o),s.toString()}function he(e){return{r:e.redirectUrl,cId:e.clientId,d:e.directExit,l:e.lang,m:e.merchantId,md:{n:e.metadata?.name,css:e.metadata?.css,l:e.metadata?.logoUrl,h:e.metadata?.homepageLink}}}const ge=`menubar=no,status=no,scrollbars=no,fullscreen=no,width=500, height=800`,_e=`frak-sso`;async function ve(e,t){let{metadata:n,customizations:r,walletUrl:i}=e.config,a={...t,directExit:t.directExit??!t.redirectUrl};if(a.openInSameWindow??!!a.redirectUrl)return await e.request({method:`frak_openSso`,params:[a,n.name,r?.css]});let o=a.ssoPopupUrl??me(i??`https://wallet.frak.id`,a,await A.resolveMerchantId()??``,n.name,g(),r?.css),s=window.open(o,_e,ge);if(!s)throw Error(`Popup was blocked. Please allow popups for this site.`);return s.focus(),await e.request({method:`frak_openSso`,params:[a,n.name,r?.css]})??{}}function N(e,t,n){if(!e){console.debug(`[Frak] No client provided, skipping event tracking`);return}try{e.openPanel?.track(t,n)}catch(e){console.debug(`[Frak] Failed to track event:`,t,e)}}function P(e,t){let n=e.get(t);if(n!==null)return n;let r=t.toLowerCase();for(let[t,n]of e)if(t.toLowerCase()===r)return n;return null}function F(e,t){let n=t.toLowerCase(),r=[...e.keys()].filter(e=>e.toLowerCase()===n);for(let t of r)e.delete(t)}const ye=/^0x[a-fA-F0-9]{40}$/;function I(e){return typeof e==`string`&&ye.test(e)}function be(e,t){return e.toLowerCase()===t.toLowerCase()}function xe(e){let t=new Uint8Array(20);for(let n=0;n<20;n++){let r=Number.parseInt(e.substring(2+n*2,4+n*2),16);if(Number.isNaN(r))throw Error(`Invalid address: ${e}`);t[n]=r}return t}const Se=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function Ce(e){let t=`0x`;for(let n=0;n<20;n++)t+=Se[e[n]];return t}function we(e){return`r`in e&&!(`v`in e)}function L(e){return`v`in e&&e.v===2}const Te=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Ee(e){return typeof e==`string`&&Te.test(e)}function De(e){let t=e.replace(/-/g,``),n=new Uint8Array(16);for(let e=0;e<16;e++)n[e]=Number.parseInt(t.substring(e*2,e*2+2),16);return n}function Oe(e){let t=``;for(let n=0;n<16;n++)t+=e[n].toString(16).padStart(2,`0`);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20,32)}`}function ke(e){if(!Ee(e.m)||!Number.isInteger(e.t)||e.t<0||e.t>4294967295)return null;let t=typeof e.c==`string`&&e.c.length>0,n=typeof e.w==`string`&&I(e.w);if(!t&&!n||t&&!Ee(e.c))return null;let r=new Uint8Array(21+(t?16:0)+(n?20:0)),i=new DataView(r.buffer,r.byteOffset,r.byteLength),a=0;return r[a++]=2|(t?16:0)|(n?32:0),r.set(De(e.m),a),a+=16,i.setUint32(a,e.t,!1),a+=4,t&&(r.set(De(e.c),a),a+=16),n&&(r.set(xe(e.w),a),a+=20),r}function Ae(e){if(e.length<21)return null;let t=e[0];if((t&15)!=2||t&192)return null;let n=(t&16)!=0,r=(t&32)!=0;if(!n&&!r)return null;let i=21+(n?16:0)+(r?20:0);if(e.length!==i)return null;let a=1,o=Oe(e.subarray(a,a+16));a+=16;let s=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(a,!1);a+=4;let c={v:2,m:o,t:s};if(n&&(c.c=Oe(e.subarray(a,a+16)),a+=16),r){let t=Ce(e.subarray(a,a+20));if(!I(t))return null;c.w=t,a+=20}return c}const R=`fCtx`;function je(e){if(e)try{if(L(e)){let t=ke(e);return t?j(t):void 0}return j(xe(e.r))}catch(t){console.error(`Error compressing Frak context`,{e:t,context:e})}}function Me(e){if(!(!e||e.length===0))try{let t=M(e);if(t.length!==20)return Ae(t)||void 0;let n=Ce(t);if(I(n))return{r:n}}catch(t){console.error(`Error decompressing Frak context`,{e:t,context:e})}}function Ne({url:e}){if(!e)return null;let t=P(new URL(e).searchParams,R);return t?Me(t):null}function Pe(e){return{utm_source:e.utmSource??`frak`,utm_medium:e.utmMedium??void 0,utm_campaign:e.utmCampaign??void 0,utm_content:e.utmContent,utm_term:e.utmTerm,via:e.via??void 0,ref:e.ref??void 0}}function Fe(e,t){let n=Pe(t??{});for(let[t,r]of Object.entries(n))r===void 0||r===``||e.searchParams.has(t)||e.searchParams.set(t,r)}function Ie({url:e,context:t,attribution:n}){if(!e)return null;let r=je(t);if(!r)return null;let i=new URL(e);return F(i.searchParams,R),i.searchParams.set(R,r),Fe(i,n),i.toString()}function Le(e){let t=new URL(e);return F(t.searchParams,R),t.toString()}function Re({url:e,context:t}){if(!window.location?.href||typeof window>`u`){console.error(`No window found, can't update context`);return}let n=e??window.location.href,r;r=t===null?Le(n):Ie({url:n,context:t}),r&&window.history.replaceState(null,``,r.toString())}const z={compress:je,decompress:Me,parse:Ne,update:Ie,remove:Le,replaceUrl:Re},B={eur:`fr-FR`,usd:`en-US`,gbp:`en-GB`};function V(e){return e&&e in B?e:`eur`}function ze(e){return e?B[e]??B.eur:B.eur}function Be(e,t){let n=ze(t),r=V(t);return e.toLocaleString(n,{style:`currency`,currency:r,minimumFractionDigits:0,maximumFractionDigits:2})}function Ve(e){return e?`${e}Amount`:`eurAmount`}var He=class{constructor(e){this.baseUrl=e.baseUrl,this.headers={"Content-Type":`application/json`,...e.defaultHeaders},this.maxRetries=e.maxRetries??3,this.initialRetryDelay=e.initialRetryDelay??500}async resolveHeaders(){let e={};for(let[t,n]of Object.entries(this.headers)){let r=await n;r!==null&&(e[t]=r)}return e}addHeader(e,t){this.headers[e]=t}async post(e,t,n,r){try{let r=await fetch(e,{method:`POST`,headers:await this.resolveHeaders(),body:t?JSON.stringify(t??{}):void 0,keepalive:!0,...n});if(r.status===401)return null;if(r.status!==200&&r.status!==202)throw Error(`HTTP error! status: ${r.status}`);let i=await r.text();return i?JSON.parse(i):null}catch(i){if(r<this.maxRetries){let i=this.initialRetryDelay*2**r;return await new Promise(e=>setTimeout(e,i)),this.post(e,t,n,r+1)}return console.error(`Max retries reached:`,i),null}}async fetch(e,t,n={}){let r=`${this.baseUrl}${e}`;return this.post(r,t,n,0)}},Ue=class{constructor(e){this.groups=[],this.queue=[],this.options=e;let t={"openpanel-client-id":e.clientId};e.clientSecret&&(t[`openpanel-client-secret`]=e.clientSecret),t[`openpanel-sdk-name`]=e.sdk||`node`,t[`openpanel-sdk-version`]=e.sdkVersion||`1.3.1`,this.api=new He({baseUrl:e.apiUrl||`https://api.openpanel.dev`,defaultHeaders:t})}init(){}ready(){this.options.disabled=!1,this.options.waitForProfile=!1,this.flush()}shouldQueue(e){return!!(this.options.disabled||this.options.waitForProfile&&!this.profileId||e.type===`replay`&&!this.sessionId)}addQueue(e){e.type===`track`&&(e.payload.properties={...e.payload.properties??{},__timestamp:new Date().toISOString()}),this.queue.push(e)}async send(e){if(this.options.filter&&!this.options.filter(e))return Promise.resolve();if(this.shouldQueue(e))return this.addQueue(e),Promise.resolve();let t=await this.api.fetch(`/track`,e,{keepalive:e.type!==`replay`});this.deviceId=t?.deviceId;let n=!!this.sessionId;return this.sessionId=t?.sessionId,!n&&this.sessionId&&this.flush(),t}setGlobalProperties(e){this.global={...this.global,...e}}track(e,t){this.log(`track event`,e,t);let{groups:n,profileId:r,...i}=t??{},a=[...new Set([...this.groups,...n??[]])];return this.send({type:`track`,payload:{name:e,profileId:r??this.profileId,groups:a.length>0?a:void 0,properties:{...this.global??{},...i}}})}identify(e){if(this.log(`identify user`,e),e.profileId&&(this.profileId=e.profileId,this.flush()),e.profileId&&Object.keys(e).length>1)return this.send({type:`identify`,payload:{...e,properties:{...this.global,...e.properties}}})}upsertGroup(e){return this.log(`upsert group`,e),this.send({type:`group`,payload:e})}setGroup(e){return this.log(`set group`,e),this.groups.includes(e)||(this.groups=[...this.groups,e]),this.send({type:`assign_group`,payload:{groupIds:[e],profileId:this.profileId}})}setGroups(e){return this.log(`set groups`,e),this.groups=[...new Set([...this.groups,...e])],this.send({type:`assign_group`,payload:{groupIds:e,profileId:this.profileId}})}alias(e){}increment(e){return this.send({type:`increment`,payload:e})}decrement(e){return this.send({type:`decrement`,payload:e})}revenue(e,t){let n=t?.deviceId;return delete t?.deviceId,this.track(`revenue`,{...t??{},...n?{__deviceId:n}:{},__revenue:e})}getDeviceId(){return this.deviceId??``}getSessionId(){return this.sessionId??``}fetchDeviceId(){return Promise.resolve(this.deviceId??``)}clear(){this.profileId=void 0,this.groups=[],this.deviceId=void 0,this.sessionId=void 0}buildFlushPayload(e){if(e.type===`replay`)return e.payload;if(e.type===`track`){let t=`groups`in e.payload?e.payload.groups??[]:[],n=[...new Set([...this.groups,...t])];return{...e.payload,profileId:e.payload.profileId??this.profileId,groups:n.length>0?n:void 0}}return e.type===`identify`||e.type===`increment`||e.type===`decrement`||e.type===`assign_group`?{...e.payload,profileId:e.payload.profileId??this.profileId}:e.payload}flush(){let e=[];for(let t of this.queue){if(this.shouldQueue(t)){e.push(t);continue}let n=this.buildFlushPayload(t);this.send({...t,payload:n})}this.queue=e}log(...e){this.options.debug&&console.log(`[OpenPanel.dev]`,...e)}},We=typeof document<`u`?document.currentScript:null;function Ge(e){return e.replace(/([-_][a-z])/gi,e=>e.toUpperCase().replace(`-`,``).replace(`_`,``))}var Ke=class extends Ue{constructor(e){if(super({sdk:`web`,sdkVersion:`1.4.1`,...e}),this.options=e,this.lastPath=``,this.pendingRevenues=[],!this.isServer()){try{let e=sessionStorage.getItem(`openpanel-pending-revenues`);if(e){let t=JSON.parse(e);Array.isArray(t)&&(this.pendingRevenues=t)}}catch{this.pendingRevenues=[]}if(this.setGlobalProperties({__referrer:document.referrer}),this.options.trackScreenViews&&(this.trackScreenViews(),setTimeout(()=>this.screenView(),0)),this.options.trackOutgoingLinks&&this.trackOutgoingLinks(),this.options.trackAttributes&&this.trackAttributes(),this.options.sessionReplay?.enabled){let e=this.options.sessionReplay.sampleRate??1;Math.random()<e&&this.loadReplayModule().then(e=>{e&&e.startReplayRecorder(this.options.sessionReplay,e=>{this.send({type:`replay`,payload:{...e}})})})}}}async loadReplayModule(){try{if(typeof __OPENPANEL_REPLAY_URL__<`u`){let e=We,t=this.options.sessionReplay?.scriptUrl||e?.src?.replace(`.js`,`-replay.js`)||`https://openpanel.dev/op1-replay.js`;return window.__openpanel_replay?window.__openpanel_replay:new Promise(e=>{let n=document.createElement(`script`);n.src=t,n.onload=()=>{e(window.__openpanel_replay??null)},n.onerror=()=>{console.warn(`[OpenPanel] Failed to load replay script from`,t),e(null)},document.head.appendChild(n)})}return await import(`./replay-V6FXES7X.CNozpSRg.js`)}catch(e){return console.warn(`[OpenPanel] Failed to load replay module`,e),null}}debounce(e,t){clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(e,t)}isServer(){return typeof document>`u`}trackOutgoingLinks(){this.isServer()||document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`a`);if(n&&t){let e=n.getAttribute(`href`);if(e?.startsWith(`http`))try{let r=new URL(e),i=window.location.hostname;r.hostname!==i&&super.track(`link_out`,{href:e,text:n.innerText||n.getAttribute(`title`)||t.getAttribute(`alt`)||t.getAttribute(`title`)})}catch{}}})}trackScreenViews(){if(this.isServer())return;let e=history.pushState;history.pushState=function(...t){let n=e.apply(this,t);return window.dispatchEvent(new Event(`pushstate`)),window.dispatchEvent(new Event(`locationchange`)),n};let t=history.replaceState;history.replaceState=function(...e){let n=t.apply(this,e);return window.dispatchEvent(new Event(`replacestate`)),window.dispatchEvent(new Event(`locationchange`)),n},window.addEventListener(`popstate`,()=>{window.dispatchEvent(new Event(`locationchange`))});let n=()=>this.debounce(()=>this.screenView(),50);this.options.trackHashChanges?window.addEventListener(`hashchange`,n):window.addEventListener(`locationchange`,n)}trackAttributes(){this.isServer()||document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`button`),r=t.closest(`a`),i=n?.getAttribute(`data-track`)?n:r?.getAttribute(`data-track`)?r:null;if(i){let e={};for(let t of i.attributes)t.name.startsWith(`data-`)&&t.name!==`data-track`&&(e[Ge(t.name.replace(/^data-/,``))]=t.value);let t=i.getAttribute(`data-track`);t&&super.track(t,e)}})}track(e,t){return super.track(e,{...t,__path:this.lastPath})}screenView(e,t){if(this.isServer())return;let n,r;typeof e==`string`?(n=e,r=t):(n=window.location.href,r=e),this.lastPath!==n&&(this.lastPath=n,super.track(`screen_view`,{...r??{},__path:n,__title:document.title}))}async flushRevenue(){let e=this.pendingRevenues.map(e=>super.revenue(e.amount,e.properties));await Promise.all(e),this.clearRevenue()}clearRevenue(){if(this.pendingRevenues=[],!this.isServer())try{sessionStorage.removeItem(`openpanel-pending-revenues`)}catch{}}pendingRevenue(e,t){if(this.pendingRevenues.push({amount:e,properties:t}),!this.isServer())try{sessionStorage.setItem(`openpanel-pending-revenues`,JSON.stringify(this.pendingRevenues))}catch{}}};const H=`nexus-wallet-backup`,U=`frakwallet://`;function qe(e,t){if(typeof window>`u`)return;let n=new URL(window.location.href),r=n.searchParams.get(`sso`);r&&(t.then(()=>{e.sendLifecycle({clientLifecycle:`sso-redirect-complete`,data:{compressed:r}}),console.log(`[SSO URL Listener] Forwarded compressed SSO data to iframe`)}).catch(e=>{console.error(`[SSO URL Listener] Failed to forward SSO data:`,e)}),n.searchParams.delete(`sso`),window.history.replaceState({},``,n.toString()),console.log(`[SSO URL Listener] SSO parameter detected and URL cleaned`))}function Je(){let e=navigator.userAgent;return/Android/i.test(e)&&/Chrome\/\d+/i.test(e)}const Ye=U.replace(`://`,``);function Xe(e){return`intent://${e.slice(13)}#Intent;scheme=${Ye};end`}function W(e,t){let n=t?.timeout??2500,r=!1,i=()=>{document.hidden&&(r=!0)};document.addEventListener(`visibilitychange`,i);let a=Je()&&Ze(e)?Xe(e):e;window.location.href=a,setTimeout(()=>{document.removeEventListener(`visibilitychange`,i),r||t?.onFallback?.()},n)}function Ze(e){return e.startsWith(U)}function Qe(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent;return!!(/iPhone|iPad|iPod/i.test(e)||/Macintosh/i.test(e)&&navigator.maxTouchPoints>1)}const G=Qe();function $e(){return typeof navigator>`u`?!1:G?!0:/Android|webOS|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}function et(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent.toLowerCase();return e.includes(`instagram`)||e.includes(`fban`)||e.includes(`fbav`)||e.includes(`facebook`)}const K=et();function tt(e){G&&e.startsWith(`https://`)?window.location.href=`x-safari-https://${e.slice(8)}`:G&&e.startsWith(`http://`)?window.location.href=`x-safari-http://${e.slice(7)}`:window.location.href=`https://backend.frak.id/common/social?u=${encodeURIComponent(e)}`}const q={id:`frak-wallet`,name:`frak-wallet`,title:`Frak Wallet`,allow:`publickey-credentials-get *; clipboard-write; web-share *`,style:{width:`0`,height:`0`,border:`0`,position:`absolute`,zIndex:2000001,top:`-1000px`,left:`-1000px`,colorScheme:`auto`}};function nt({walletBaseUrl:e,config:t}){let n=document.querySelector(`#frak-wallet`);n&&n.remove();let r=document.createElement(`iframe`);r.id=q.id,r.name=q.name,r.allow=q.allow,r.style.zIndex=q.style.zIndex.toString(),it({iframe:r,isVisible:!1});let i=t?.walletUrl??e??`https://wallet.frak.id`,a=g();return ot(i),ot(S(i)),r.src=rt({walletUrl:i,clientId:a,preload:t?.preload}),new Promise(e=>{r.addEventListener(`load`,()=>e(r)),document.body.appendChild(r)})}function rt({walletUrl:e,clientId:t,preload:n}){let r=`${e}/listener?clientId=${encodeURIComponent(t)}`;return!n||n.length===0?r:`${r}#preload=${n.join(`,`)}`}function it({iframe:e,isVisible:t}){if(!t){e.style.width=`0`,e.style.height=`0`,e.style.border=`0`,e.style.position=`fixed`,e.style.top=`-1000px`,e.style.left=`-1000px`;return}e.style.position=`fixed`,e.style.top=`0`,e.style.left=`0`,e.style.width=`100%`,e.style.height=`100%`,e.style.pointerEvents=`auto`}function at(e=`/listener`){if(!window.opener)return null;let t=t=>{try{return t.location.origin===window.location.origin&&t.location.pathname===e}catch{return!1}};if(t(window.opener))return window.opener;try{let e=window.opener.frames;for(let n=0;n<e.length;n++)if(t(e[n]))return e[n];return null}catch(t){return console.error(`[findIframeInOpener] Error finding iframe with pathname ${e}:`,t),null}}function ot(e){if(!(typeof document>`u`))try{let t=new URL(e).origin,n=`link[rel="preconnect"][data-frak-preconnect="${t}"]`;if(document.head.querySelector(n))return;let r=document.createElement(`link`);r.rel=`preconnect`,r.href=t,r.crossOrigin=``,r.dataset.frakPreconnect=t,document.head.appendChild(r)}catch{}}const st=G&&K;function ct(e){e?localStorage.setItem(H,e):localStorage.removeItem(H)}function J(e,t){try{let n=new URL(e);if(!n.searchParams.has(`u`))return e;let r=dt(window.location.href,t);return n.searchParams.delete(`u`),n.searchParams.append(`u`,r),n.toString()}catch{return e}}function lt(e){let t=new URL(window.location.href);e&&t.searchParams.set(`fmt`,e);let n=t.protocol===`http:`?`x-safari-http`:`x-safari-https`;window.location.href=`${n}://${t.host}${t.pathname}${t.search}${t.hash}`}function ut(e){return e.includes(`/common/social`)}function dt(e,t){if(!t)return e;try{let n=new URL(e);return n.searchParams.set(`fmt`,t),n.toString()}catch{return`${e}${e.includes(`?`)?`&`:`?`}fmt=${encodeURIComponent(t)}`}}function ft(e,t,n,r,i){if(i){let e=J(t,r);window.open(e,`_blank`);return}if(Ze(t)){let i=J(t,r);W(i,{onFallback:()=>{e.contentWindow?.postMessage({clientLifecycle:`deep-link-failed`,data:{originalUrl:i}},n)}})}else if(st&&ut(t))lt(r);else{let e=J(t,r);window.location.href=e}}function pt({iframe:e,targetOrigin:t}){let n=new u;return{handleEvent:r=>{if(!(`iframeLifecycle`in r))return;let{iframeLifecycle:i,data:a}=r;switch(i){case`connected`:n.resolve(!0);break;case`do-backup`:ct(a.backup);break;case`remove-backup`:localStorage.removeItem(H);break;case`show`:case`hide`:it({iframe:e,isVisible:i===`show`});break;case`redirect`:ft(e,a.baseRedirectUrl,t,a.mergeToken,a.openInNewTab);break}},isConnected:n.promise}}function mt({config:e,iframe:t}){let n=e?.walletUrl??`https://wallet.frak.id`,r=typeof navigator<`u`?navigator.language?.split(`-`)[0]:void 0,i=e.metadata.lang??(r===`en`||r===`fr`?r:void 0),a=e.domain??(typeof window<`u`?window.location.hostname:``);A.setCacheScope(a,i),A.reset();let o=A.isCacheFresh?void 0:A.resolve(e.domain,e.walletUrl,i),s=pt({iframe:t,targetOrigin:n}),f=new u,p=Date.now();if(!t.contentWindow)throw new l(c.configError,`The iframe does not have a content window`);let m=d({emittingTransport:t.contentWindow,listeningTransport:window,targetOrigin:n,middleware:[{async onRequest(e,t){if(!await s.isConnected)throw new l(c.clientNotConnected,`The iframe provider isn't connected yet`);return await f.promise,t}}],lifecycleHandlers:{iframeLifecycle:(e,t)=>{s.handleEvent(e)}}}),h=ht(m,s),_=async()=>{h(),m.cleanup(),t.remove(),x(),A.clearCache(),A.reset()},v;{console.log(`[Frak SDK] Initializing OpenPanel`),v=new Ke({apiUrl:`https://op-api.gcp.frak.id`,clientId:`6eacc8d7-49ac-4936-95e9-81ef29449570`,trackScreenViews:!0,trackOutgoingLinks:!0,trackAttributes:!1,filter:({type:e,payload:t})=>(e!==`track`||!t?.properties||`sdk_version`in t.properties||(t.properties={...t.properties,sdk_version:`1.1.5`,user_anonymous_client_id:g()}),!0)}),v.setGlobalProperties({sdk_version:`1.1.5`,user_anonymous_client_id:g()}),v.init(),v.track(`sdk_initialized`,{sdk_version:`1.1.5`});let e=!1,t=setTimeout(()=>{e||(e=!0,v?.track(`sdk_iframe_handshake_failed`,{reason:`timeout`}))},3e4);s.isConnected.then(()=>{e||(e=!0,clearTimeout(t),v?.track(`sdk_iframe_connected`,{handshake_duration_ms:Date.now()-p}))}).catch(()=>{e||(e=!0,clearTimeout(t),v?.track(`sdk_iframe_handshake_failed`,{reason:`unknown`}))})}let y=gt({config:e,rpcClient:m,lifecycleManager:s,configPromise:o,contextSent:f,openPanel:v}).then(()=>{}).catch(e=>{throw f.reject(e),e});return{config:e,waitForConnection:s.isConnected,waitForSetup:y,request:m.request,listenerRequest:m.listen,destroy:_,openPanel:v}}function ht(e,t){let n,r,i=()=>e.sendLifecycle({clientLifecycle:`heartbeat`});async function a(){i(),n=setInterval(i,250),r=setTimeout(()=>{o(),console.log(`Heartbeat timeout: connection failed`)},3e4),await t.isConnected,o()}function o(){n&&clearInterval(n),r&&clearTimeout(r)}return a(),o}async function gt({config:e,rpcClient:t,lifecycleManager:n,configPromise:r,contextSent:i,openPanel:a}){await n.isConnected,qe(t,n.isConnected);let o=new URL(window.location.href),s=o.searchParams.get(`fmt`)??void 0;s&&(o.searchParams.delete(`fmt`),window.history.replaceState({},``,o.toString()));let c=t=>{let n=t?.merchantId??e.metadata.merchantId??``,r=t?.domain??``,i=t?.allowedDomains??[],a=t?.sdkConfig,o=a?.attribution||e.attribution?{...e.attribution,...a?.attribution}:void 0;A.setConfig(a?{isResolved:!0,merchantId:n,domain:r,allowedDomains:i,hasRawSdkConfig:!0,name:a.name??e.metadata.name,logoUrl:a.logoUrl??e.metadata.logoUrl,homepageLink:a.homepageLink??e.metadata.homepageLink,lang:a.lang??e.metadata.lang,currency:a.currency??e.metadata.currency,hidden:a.hidden,css:a.css,translations:a.translations,placements:a.placements,components:a.components,attribution:o}:{isResolved:!0,merchantId:n,domain:r,allowedDomains:i,name:e.metadata.name,logoUrl:e.metadata.logoUrl,homepageLink:e.metadata.homepageLink,lang:e.metadata.lang,currency:e.metadata.currency,attribution:o})},l=!1,u=e=>{let n=l?void 0:s;l=!0;let r=e.hasRawSdkConfig?{name:e.name,logoUrl:e.logoUrl,homepageLink:e.homepageLink,lang:e.lang,currency:e.currency,hidden:e.hidden,css:e.css,translations:e.translations,placements:e.placements,attribution:e.attribution}:e.attribution?{attribution:e.attribution}:void 0,i=g();if(a){let t=a.global??{};a.setGlobalProperties({...t,merchant_id:e.merchantId,domain:e.domain??``})}t.sendLifecycle({clientLifecycle:`resolved-config`,data:{merchantId:e.merchantId,domain:e.domain??``,allowedDomains:e.allowedDomains??[],sourceUrl:window.location.href,...i&&{sdkAnonymousId:i},...n&&{pendingMergeToken:n},...r&&{sdkConfig:r}}})};A.isResolved&&(u(A.getConfig()),i.resolve()),r&&(c(await r),u(A.getConfig()),i.resolve());async function d(){let n=e.customizations?.css;n&&t.sendLifecycle({clientLifecycle:`modal-css`,data:{cssLink:n}})}async function f(){let n=e.customizations?.i18n;n&&t.sendLifecycle({clientLifecycle:`modal-i18n`,data:{i18n:n}})}async function p(){if(typeof window>`u`)return;let e=window.localStorage.getItem(H);e&&t.sendLifecycle({clientLifecycle:`restore-backup`,data:{backup:e}})}(await Promise.allSettled([d(),f(),p()])).some(e=>e.status===`rejected`)&&a?.track(`sdk_iframe_handshake_failed`,{reason:`asset_push`})}function _t(e){return p(M(e))}async function vt({config:e}){let t=yt(e),n=await nt({config:t});if(!n){console.error(`Failed to create iframe`);return}let r=mt({config:t,iframe:n});if(await r.waitForSetup,!await r.waitForConnection){console.error(`Failed to connect to client`);return}return r}function yt(e){let t=V(e.metadata?.currency);return{...e,metadata:{...e.metadata,currency:t}}}function bt({perCall:e,defaults:t,productUtmContent:n}){if(e===null)return;let r=e!==void 0,i=t!==void 0&&Object.keys(t).length>0;if(!r&&!i&&!(n!==void 0&&n!==``))return;let a={...t,...e??{}},o=n??e?.utmContent;return o!==void 0&&o!==``?a.utmContent=o:delete a.utmContent,a}var xt=t({DEEP_LINK_SCHEME:()=>U,FrakContextManager:()=>z,base64urlDecode:()=>M,base64urlEncode:()=>j,baseIframeProps:()=>q,clearAllCache:()=>x,compressJsonToB64:()=>pe,createIFrameFrakClient:()=>mt,decompressJsonFromB64:()=>_t,deleteQueryParamCaseInsensitive:()=>F,findIframeInOpener:()=>at,formatAmount:()=>Be,generateSsoUrl:()=>me,getBackendUrl:()=>S,getClientId:()=>g,getCurrencyAmountKey:()=>Ve,getQueryParamCaseInsensitive:()=>P,getSupportedCurrency:()=>V,isIOS:()=>G,isInAppBrowser:()=>K,isMobile:()=>$e,mergeAttribution:()=>bt,redirectToExternalBrowser:()=>tt,sdkConfigStore:()=>A,setupClient:()=>vt,ssoPopupFeatures:()=>ge,ssoPopupName:()=>_e,trackEvent:()=>N,triggerDeepLinkWithFallback:()=>W,withCache:()=>b});async function St(e,t,n){return await e.request({method:`frak_displayEmbeddedWallet`,params:n?[t,e.config.metadata,n]:[t,e.config.metadata]})}async function Y(e,{steps:t,metadata:n},r){return await e.request({method:`frak_displayModal`,params:r?[t,n,e.config.metadata,r]:[t,n,e.config.metadata]})}async function Ct(e,t,n){return await e.request({method:`frak_displaySharingPage`,params:n?[t,e.config.metadata,n]:[t,e.config.metadata]})}async function wt(e){if(typeof window>`u`)return;let t=g();if(!t)return;let n=await A.resolveMerchantId();if(!n)return;let r=`frak-identity-ensured-${n}`;if(!window.sessionStorage.getItem(r))try{let i=S();(await fetch(`${i}/user/identity/ensure`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"x-wallet-sdk-auth":e,"x-frak-client-id":t},body:JSON.stringify({merchantId:n})})).ok&&window.sessionStorage.setItem(r,`1`)}catch{}}async function Tt(e,t){return b(()=>e.request({method:`frak_getMerchantInformation`}),{cacheKey:`frak_getMerchantInformation`,cacheTime:t?.cacheTime})}async function Et(e,t){return b(()=>e.request({method:`frak_getMergeToken`}),{cacheKey:`frak_getMergeToken`,cacheTime:t?.cacheTime})}async function Dt(e,t){return b(()=>e.request({method:`frak_getUserReferralStatus`}),{cacheKey:`frak_getUserReferralStatus`,cacheTime:t?.cacheTime})}async function Ot(e,t){let{metadata:n,customizations:r}=e.config;return await e.request({method:`frak_prepareSso`,params:[t,n.name,r?.css]})}async function X(e,t){try{await e.request({method:`frak_sendInteraction`,params:[t,{clientId:g()}]})}catch{console.warn(`[Frak SDK] Failed to send interaction:`,t.type)}}function kt(e,t,n){return L(t)?(N(e,`user_referred_started`,{referrer_client_id:t.c,referrer_wallet:t.w,wallet_status:n?.key}),X(e,{type:`arrival`,referrerClientId:t.c,referrerMerchantId:t.m,referrerWallet:t.w,referralTimestamp:t.t}),!0):we(t)?(N(e,`user_referred_started`,{referrer:t.r,wallet_status:n?.key}),X(e,{type:`arrival`,referrerWallet:t.r}),!0):!1}function At(e,t){let n=g();return!n&&!t?null:{v:2,m:e,t:Math.floor(Date.now()/1e3),...n?{c:n}:{},...t?{w:t}:{}}}function jt(e,t){return L(e)?e.w&&t?.wallet?be(e.w,t.wallet):e.c?g()===e.c:!1:we(e)&&t?.wallet?be(e.r,t.wallet):!1}function Mt(e,{walletStatus:t,frakContext:n,options:r}){if(!n)return`no-referrer`;if(jt(n,t))return`self-referral`;if(!kt(e,n,t))return`no-referrer`;let i=L(n)?n.m:r?.merchantId,a=r?.alwaysAppendUrl&&i?At(i,t?.wallet):null;return z.replaceUrl({url:window.location?.href,context:a}),N(e,`user_referred_completed`,{status:`success`}),`success`}async function Z(e,{options:t}={}){let n=z.parse({url:window.location.href}),r=await Ft(e);try{return Mt(e,{walletStatus:r,frakContext:n,options:t})}catch(e){console.warn(`Error processing referral`,{error:e})}}const Q=`frak:referral-success`;async function Nt(e){try{await Z(e)===`success`&&window.dispatchEvent(new Event(Q))}catch(e){console.warn(`[Frak] Referral setup failed`,e)}}async function Pt(e){if(typeof window>`u`){console.warn(`[Frak] No window found, can't track purchase`);return}let t=window.sessionStorage.getItem(`frak-wallet-interaction-token`),n=g();if(!t&&!n){console.warn(`[Frak] No identity found, skipping purchase check`);return}let r=e.merchantId??await A.resolveMerchantId();if(!r){console.warn(`[Frak] No merchant id found, skipping purchase check`);return}let i={Accept:`application/json`,"Content-Type":`application/json`};t&&(i[`x-wallet-sdk-auth`]=t),n&&(i[`x-frak-client-id`]=n);let a=S();await fetch(`${a}/user/track/purchase`,{method:`POST`,headers:i,body:JSON.stringify({customerId:e.customerId,orderId:e.orderId,token:e.token,merchantId:r})})}function Ft(e,t){if(!t)return e.request({method:`frak_listenToWalletStatus`}).then(t=>(It(e,t),t));let n=new u,r=!1;return e.listenerRequest({method:`frak_listenToWalletStatus`},i=>{It(e,i),t(i),r||=(n.resolve(i),!0)}),n.promise}function It(e,t){typeof window>`u`||(e.openPanel?.setGlobalProperties({wallet:t.wallet??null}),t.interactionToken?(window.sessionStorage.setItem(`frak-wallet-interaction-token`,t.interactionToken),wt(t.interactionToken)):window.sessionStorage.removeItem(`frak-wallet-interaction-token`))}function Lt(e,{metadata:t,login:n}){return $(e,{steps:{login:n??{}},metadata:t})}function $(e,t){function n(n){return $(e,{...t,steps:{...t.steps,sendTransaction:n}})}function r(n){return $(e,{...t,steps:{...t.steps,final:{...n,action:{key:`reward`}}}})}function i(n,r){return $(e,{...t,steps:{...t.steps,final:{...r,action:{key:`sharing`,options:n}}}})}async function a(n,r){return n&&(t.metadata=n(t.metadata??{})),await Y(e,t,r)}return{params:t,sendTx:n,reward:r,sharing:i,display:a}}async function Rt(e,{tx:t,metadata:n}){return(await Y(e,{metadata:n,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}function zt(e=96){let t=Math.ceil(e/2),n=``;if(typeof crypto<`u`&&crypto.getRandomValues){let e=new Uint8Array(t);crypto.getRandomValues(e);for(let t=0;t<e.length;t++)n+=e[t].toString(16).padStart(2,`0`)}else for(let e=0;e<t;e++)n+=(Math.random()*256|0).toString(16).padStart(2,`0`);return n.substring(0,e)}async function Bt(e,{siwe:t,metadata:n}){let r=e.config?.domain??window.location.host,i=t?.statement??`I confirm that I want to use my Frak wallet on: ${e.config.metadata.name}`;return(await Y(e,{metadata:n,steps:{login:{},siweAuthenticate:{siwe:{...t,statement:i,nonce:t?.nonce??zt(),uri:t?.uri??`https://${r}`,version:t?.version??`1`,domain:r}}}})).siweAuthenticate}var Vt=t({REFERRAL_SUCCESS_EVENT:()=>Q,displayEmbeddedWallet:()=>St,displayModal:()=>Y,displaySharingPage:()=>Ct,ensureIdentity:()=>wt,getMerchantInformation:()=>Tt,getMergeToken:()=>Et,getUserReferralStatus:()=>Dt,modalBuilder:()=>Lt,openSso:()=>ve,prepareSso:()=>Ot,processReferral:()=>Mt,referralInteraction:()=>Z,sendInteraction:()=>X,sendTransaction:()=>Rt,setupReferral:()=>Nt,siweAuthenticate:()=>Bt,trackPurchaseStatus:()=>Pt,watchWalletStatus:()=>Ft});async function Ht(e,t,n){if(!window.FrakSetup?.client){console.error(`Frak client not found`);return}await Ct(window.FrakSetup.client,{...n?.link&&{link:n.link},...n?.products?.length&&{products:n.products},...e&&{metadata:{targetInteraction:e}}},t)}const Ut=[`frak-button-share`,`frak-button-wallet`,`frak-open-in-app`,`frak-post-purchase`,`frak-banner`].join(`,`);function Wt(){return typeof document>`u`||document.querySelector(Ut)===null?[]:[`sharing`]}function Gt(e){try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function Kt(e){if(!e)return null;if(Array.isArray(e))return e;if(typeof e!=`string`)return null;try{let t=JSON.parse(e);return Array.isArray(t)?t:null}catch{return null}}function qt(e){if(!e||typeof e!=`object`)return null;let t=e,n=typeof t.title==`string`?t.title.trim():``;if(n===``)return null;let r={title:n};return typeof t.imageUrl==`string`&&Gt(t.imageUrl)&&(r.imageUrl=t.imageUrl),typeof t.link==`string`&&Gt(t.link)&&(r.link=t.link),typeof t.utmContent==`string`&&t.utmContent!==``&&(r.utmContent=t.utmContent),r}function Jt(e){let t=Kt(e);if(!t)return;let n=[];for(let e of t){let t=qt(e);t&&n.push(t)}return n.length>0?n:void 0}function Yt(e){if(!e)return;let t;try{t=_t(e)}catch{return}if(t!==null)return Jt(t)}const Xt=`frak:client`;function Zt(){let e=new CustomEvent(Xt);window.dispatchEvent(e)}function Qt(e,t){if(window.FrakSetup?.client&&e===`add`){t();return}(e===`add`?window.addEventListener:window.removeEventListener)(Xt,t,!1)}function $t(){return window.FrakSetup.core={...xt,...Vt},window.FrakSetup?.client?Promise.resolve():b(()=>en(),{cacheKey:`frak-sdk-init`,cacheTime:1/0}).catch(e=>{N(window.FrakSetup?.client,`sdk_init_failed`,{reason:e instanceof Error?e.message:typeof e==`string`?e:`unknown`,config_missing:!window.FrakSetup?.config})})}async function en(){if(!window.FrakSetup?.config)throw Error(`[Frak SDK] Configuration not found. Please ensure window.FrakSetup.config is set.`);console.log(`[Frak SDK] Starting initialization`);let e=await vt({config:tn(window.FrakSetup.config)});if(!e)throw Error(`[Frak SDK] Failed to create client`);window.FrakSetup.client=e,console.log(`[Frak SDK] Client initialized successfully`),Zt(),Nt(e),nn()}function tn(e){return e.preload===void 0?{...e,preload:Wt()}:e}function nn(){let e=new URL(window.location.href);if(P(e.searchParams,`frakAction`)?.toLowerCase()!==`share`)return;console.log(`[Frak SDK] Auto open share via query param`);let t=P(e.searchParams,`link`)??void 0,n=P(e.searchParams,`placement`)??void 0,r=Yt(P(e.searchParams,`products`));F(e.searchParams,`frakAction`),F(e.searchParams,`link`),F(e.searchParams,`placement`),F(e.searchParams,`products`),window.history.replaceState({},``,e.toString()),Ht(void 0,n,{link:t,products:r})}o.injectBase(`shared`,n),o.injectBase(`fouce`,`frak-button-share:not(:defined), frak-button-wallet:not(:defined), frak-open-in-app:not(:defined), frak-post-purchase:not(:defined), frak-banner:not(:defined) { display: none !important; }`),s($t);const rn={"button-share":()=>import(`./ButtonShare.QjU-SB2w.js`),"button-wallet":()=>import(`./ButtonWallet.BQWezFCP.js`),"open-in-app":()=>import(`./OpenInAppButton.D1UzTuHx.js`),"post-purchase":()=>import(`./PostPurchase.DPgGfAjM.js`),banner:()=>import(`./Banner.BpIgsa8e.js`)},an=new MutationObserver(e=>{for(let{addedNodes:t}of e)for(let e of Array.from(t))e.nodeType===Node.ELEMENT_NODE&&on(e)});async function on(e){let t=e instanceof Element?e.tagName.toLowerCase():``,n=t?.startsWith(`frak-`),r=Array.from(e.querySelectorAll(`:not(:defined)`)).map(e=>e.tagName.toLowerCase()).filter(e=>e.startsWith(`frak-`));n&&!customElements.get(t)&&r.push(t);let i=[...new Set(r)];await Promise.allSettled(i.map(e=>sn(e)))}async function sn(e){if(customElements.get(e))return Promise.resolve();try{let t=e.replace(/^frak-/i,``);if(!(t in rn))throw Error(`Component ${e} is not supported.`);await rn[t]()}catch(e){console.error(e)}}on(document.body),an.observe(document.documentElement,{subtree:!0,childList:!0});export{s as C,l as S,n as T,Be as _,Pt as a,N as b,Tt as c,$e as d,tt as f,Ve as g,K as h,Ht as i,St as l,W as m,Qt as n,Dt as o,U as p,Jt as r,Et as s,$t as t,Q as u,V as v,o as w,c as x,A as y};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(){return()=>{}}var t=null;function n(n,r){if(typeof document>`u`||typeof window>`u`)return;t&&t();let i=n.maxEventsPerChunk??200,a=n.flushIntervalMs??1e4,o=n.maxPayloadBytes??1048576,s=[],c=0,l=null;function u(e){if(s.length===0)return;let t=JSON.stringify(s);if(new TextEncoder().encode(t).length>o){if(s.length>1){let t=Math.floor(s.length/2),n=s.slice(0,t),r=s.slice(t),i=e&&n.some(e=>e.type===2);s=n,u(i),s=r,u(!1);return}s=[];return}let n=s[0].timestamp,i=s[s.length-1].timestamp;try{r({chunk_index:c,events_count:s.length,is_full_snapshot:e,started_at:new Date(n).toISOString(),ended_at:new Date(i).toISOString(),payload:t}),c+=1,s=[]}catch(e){throw console.error(`[ReplayRecorder] sendChunk failed`,e),e}}function d(e){let t=e||s.some(e=>e.type===2);s.length>=i?u(t):e&&s.length>0&&u(!0)}let f=n.maskAllText!==!1,p=n.unmaskTextSelector,m=e({emit(e,t){s.push(e),d(!!t)},checkoutEveryNms:a,maskAllInputs:n.maskAllInputs??!0,maskTextSelector:f?`*`:`[data-openpanel-replay-mask]`,maskTextFn:f&&p?(e,t)=>t?.closest(p)?e:e.replace(/\S/g,`*`):void 0,blockSelector:n.blockSelector??`[data-openpanel-replay-block]`,blockClass:n.blockClass,ignoreSelector:n.ignoreSelector});l=setInterval(()=>{s.length>0&&u(s.some(e=>e.type===2))},a);function h(){document.visibilityState===`hidden`&&s.length>0&&u(s.some(e=>e.type===2))}function g(){s.length>0&&u(s.some(e=>e.type===2))}document.addEventListener(`visibilitychange`,h),window.addEventListener(`pagehide`,g),t=()=>{s.length>0&&u(s.some(e=>e.type===2)),l&&=(clearInterval(l),null),document.removeEventListener(`visibilitychange`,h),window.removeEventListener(`pagehide`,g),m?.(),t=null}}function r(){t&&t()}export{n as startReplayRecorder,r as stopReplayRecorder};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_ as e,g as t,v as n}from"./loader.js";function r(e){return Array.isArray(e)?e:e.conditions}function i(e){if(typeof e==`number`)return e;if(typeof e==`string`&&e.trim()!==``){let t=Number(e);return Number.isFinite(t)?t:void 0}}function a(e,t,n){let o=[];for(let s of r(e)){if(`logic`in s){o.push(...a(s,t,n));continue}if(s.field===t&&n.has(s.operator)){let e=i(s.value);e!=null&&o.push(e)}}return o}const o=new Set([`gt`,`gte`,`between`]),s=new Set([`gt`,`gte`]);function c(e){let t=a(e,`purchase.amount`,o);return t.length>0?Math.min(...t):void 0}function l(e){let t=a(e,`time.timestamp`,s);if(t.length!==0)return new Date(Math.min(...t)*1e3)}function u(e,t){switch(e.payoutType){case`fixed`:return e.amount[t];case`percentage`:return e.maxAmount?.[t]??0;case`tiered`:return e.tiers.reduce((e,n)=>`amount`in n?Math.max(e,n.amount[t]):e,0)}}function d(e){return e.payoutType===`percentage`?e.percent:e.payoutType===`tiered`?e.tiers.reduce((e,t)=>`percent`in t?Math.max(e,t.percent):e,0):0}function f(e,t){let n=u(e,t);return n>0?n:d(e)*1e-6}function p(r,i){let a=n(i),o=t(a);switch(r.payoutType){case`fixed`:return e(Math.round(r.amount[o]),a);case`percentage`:return`${r.percent} %`;case`tiered`:{let t=u(r,o);if(t>0)return e(Math.round(t),a);let n=d(r);return n>0?`${n} %`:e(0,a)}}}function m(e,r){if(e&&!(f(e,t(n(r)))<=0))return p(e,r)}function h(e,t){return t?e.replace(`{REWARD}`,t):e.replace(`{REWARD}`,``)}function g(e,t){return e.expiresAt!=null&&new Date(e.expiresAt).getTime()<=t}function _(e,t){let n=l(e.conditions);return n==null||n.getTime()<=t}function v(e,t){return t===`referee`?e.referee:e.referrer}function y(e,t,n){let r=v(e,n);return r?f(r,t):0}function b(e,r={}){let i=(r.now??new Date).getTime(),a=r.audience??`referrer`,o=t(n(r.currency)),s=(r.targetInteraction?e.filter(e=>e.interactionTypeKey===r.targetInteraction):e).filter(e=>!g(e,i)),c=s.filter(e=>_(e,i));if(c.length>0)return{campaign:c.reduce((e,t)=>y(t,o,a)>y(e,o,a)?t:e),status:`live`};let u=s.map(e=>({campaign:e,startsAt:l(e.conditions)})).filter(e=>e.startsAt!=null);if(u.length===0)return;let d=u.reduce((e,t)=>t.startsAt.getTime()<e.startsAt.getTime()?t:e);return{campaign:d.campaign,status:`upcoming`,startsAt:d.startsAt}}function x(t,n={}){let r=b(t,n);if(!r)return;let i=v(r.campaign,n.audience??`referrer`);if(!i)return;let a=m(i,n.currency);if(!a)return;let o=c(r.campaign.conditions),s=o==null?void 0:e(o,n.currency),l=r.campaign.defaultLockupSeconds,u=l&&l>0?Math.round(l/86400):void 0;return{formatted:a,payoutType:i.payoutType,minPurchaseAmount:s,lockupDurationDays:u}}export{m as i,b as n,h as r,x as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{y as e}from"./loader.js";import{c as t,o as n}from"./defaults.kWEdCyGS.js";function r(){return t(n,()=>e.getConfig().components)}export{r as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{w as e}from"./loader.js";import{i as t,p as n}from"./defaults.kWEdCyGS.js";function r(r,i,a,o,s){n(()=>{s&&e.injectBase(`shared`,s),e.injectBase(r,o??t)},[r]),n(()=>{!i||!a||e.injectPlacement(r,i,a)},[r,i,a])}export{r as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e}from"./loader.js";import{d as t,p as n}from"./defaults.kWEdCyGS.js";import{t as r}from"./rewards.D4VLYzjp.js";function i(i,a,o){let[s,c]=t(void 0);return n(()=>{if(!i)return;let t=window.FrakSetup?.client;t&&e(t).then(e=>{let n=r(e.rewards,{currency:t.config.metadata?.currency,targetInteraction:a,audience:o});n&&n.payoutType!==`percentage`&&c(n.formatted)}).catch(()=>{})},[i,a,o]),{reward:s}}export{i as t};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "preact/hooks";
|
|
2
2
|
import { jsx, jsxs } from "preact/jsx-runtime";
|
|
3
3
|
import { Component, Fragment as Fragment$1, createElement, options, toChildArray } from "preact";
|
|
4
|
-
//#region ../../node_modules/.bun/preact@10.29.
|
|
4
|
+
//#region ../../node_modules/.bun/preact@10.29.2/node_modules/preact/compat/dist/compat.module.js
|
|
5
5
|
function g(n, t) {
|
|
6
6
|
for (var e in t) n[e] = t[e];
|
|
7
7
|
return n;
|
package/dist/banner.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { InteractionTypeKey } from "@frak-labs/core-sdk";
|
|
2
|
-
import * as _$preact from "preact";
|
|
3
2
|
|
|
4
3
|
//#region src/components/Banner/types.d.ts
|
|
5
4
|
/**
|
|
@@ -119,11 +118,11 @@ declare function Banner({
|
|
|
119
118
|
inappTitle: propInappTitle,
|
|
120
119
|
inappDescription: propInappDescription,
|
|
121
120
|
inappCta: propInappCta,
|
|
122
|
-
imageUrl,
|
|
121
|
+
imageUrl: propImageUrl,
|
|
123
122
|
preview,
|
|
124
123
|
previewMode,
|
|
125
124
|
allowInappRedirect
|
|
126
|
-
}: BannerProps):
|
|
125
|
+
}: BannerProps): import("preact").JSX.Element | null;
|
|
127
126
|
//#endregion
|
|
128
127
|
//#region src/components/Banner/index.d.ts
|
|
129
128
|
/**
|
package/dist/banner.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as useGlobalComponents } from "./useGlobalComponents-
|
|
3
|
-
import { t as useLightDomStyles } from "./useLightDomStyles-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { i as useLang, o as useClientReady, s as registerWebComponent, t as usePlacement } from "./usePlacement-4PoDbn2X.js";
|
|
2
|
+
import { t as useGlobalComponents } from "./useGlobalComponents-CZ7Sh2tZ.js";
|
|
3
|
+
import { t as useLightDomStyles } from "./useLightDomStyles-DphuQhvx.js";
|
|
4
|
+
import { r as b } from "./rewards-CsHE1hVo.js";
|
|
5
|
+
import { t as useReward } from "./useReward-Br6GKb9Z.js";
|
|
6
|
+
import { componentDefaults } from "./i18n/defaults.js";
|
|
7
|
+
import { a as ExternalLinkIcon, i as LogoFrakWithName, n as cssSource$5, o as CloseCircleIcon, r as WarningIcon, t as GiftIcon } from "./GiftIcon-WEWSJ8kV.js";
|
|
6
8
|
import { isInAppBrowser, redirectToExternalBrowser, trackEvent } from "@frak-labs/core-sdk";
|
|
7
9
|
import { REFERRAL_SUCCESS_EVENT, getMergeToken } from "@frak-labs/core-sdk/actions";
|
|
8
10
|
import { useCallback, useEffect, useMemo, useRef, useState } from "preact/hooks";
|
|
9
11
|
import { jsx, jsxs } from "preact/jsx-runtime";
|
|
10
|
-
//#region \0ve-inline:../../packages/design-system/src/
|
|
11
|
-
const cssSource$
|
|
12
|
+
//#region \0ve-inline:../../packages/design-system/src/keyframes.css.ts.vanilla.js
|
|
13
|
+
const cssSource$4 = `@keyframes keyframes_fadeIn__mnqmlt0 {
|
|
12
14
|
from {
|
|
13
15
|
opacity: 0;
|
|
14
16
|
transform: translateY(-4px);
|
|
@@ -17,8 +19,10 @@ const cssSource$2 = `@keyframes inAppBanner_fadeIn__1ibpiy70 {
|
|
|
17
19
|
opacity: 1;
|
|
18
20
|
transform: translateY(0);
|
|
19
21
|
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
+
}`;
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region \0ve-inline:../../packages/design-system/src/styles/inAppBanner.css.ts.vanilla.js
|
|
25
|
+
const cssSource$3 = `.inAppBanner_container__1ibpiy70 {
|
|
22
26
|
position: fixed;
|
|
23
27
|
top: max(8px, env(safe-area-inset-top));
|
|
24
28
|
left: 16px;
|
|
@@ -30,27 +34,27 @@ const cssSource$2 = `@keyframes inAppBanner_fadeIn__1ibpiy70 {
|
|
|
30
34
|
padding: 12px 16px;
|
|
31
35
|
padding-right: 32px;
|
|
32
36
|
border-radius: 12px;
|
|
33
|
-
background-color: #
|
|
37
|
+
background-color: #000000cc;
|
|
34
38
|
backdrop-filter: blur(12px);
|
|
35
39
|
-webkit-backdrop-filter: blur(12px);
|
|
36
|
-
color:
|
|
37
|
-
animation:
|
|
40
|
+
color: var(--text-onAction__pbq4ak6);
|
|
41
|
+
animation: keyframes_fadeIn__mnqmlt0 300ms ease-out;
|
|
38
42
|
}
|
|
39
|
-
.
|
|
43
|
+
.inAppBanner_header__1ibpiy71 {
|
|
40
44
|
display: flex;
|
|
41
45
|
align-items: center;
|
|
42
46
|
gap: 8px;
|
|
43
47
|
}
|
|
44
|
-
.
|
|
48
|
+
.inAppBanner_iconWrapper__1ibpiy72 {
|
|
45
49
|
flex-shrink: 0;
|
|
46
50
|
width: 20px;
|
|
47
51
|
height: 20px;
|
|
48
52
|
display: flex;
|
|
49
53
|
align-items: center;
|
|
50
54
|
justify-content: center;
|
|
51
|
-
color:
|
|
55
|
+
color: var(--text-onAction__pbq4ak6);
|
|
52
56
|
}
|
|
53
|
-
.
|
|
57
|
+
.inAppBanner_title__1ibpiy73 {
|
|
54
58
|
margin: 0;
|
|
55
59
|
padding: 0;
|
|
56
60
|
font-size: 16px;
|
|
@@ -58,13 +62,13 @@ const cssSource$2 = `@keyframes inAppBanner_fadeIn__1ibpiy70 {
|
|
|
58
62
|
line-height: 26px;
|
|
59
63
|
color: var(--text-onAction__pbq4ak6);
|
|
60
64
|
}
|
|
61
|
-
.
|
|
65
|
+
.inAppBanner_body__1ibpiy74 {
|
|
62
66
|
display: flex;
|
|
63
67
|
flex-wrap: wrap;
|
|
64
68
|
align-items: baseline;
|
|
65
69
|
gap: 0 4px;
|
|
66
70
|
}
|
|
67
|
-
.
|
|
71
|
+
.inAppBanner_description__1ibpiy75 {
|
|
68
72
|
margin: 0;
|
|
69
73
|
padding: 0;
|
|
70
74
|
font-size: 14px;
|
|
@@ -72,24 +76,24 @@ const cssSource$2 = `@keyframes inAppBanner_fadeIn__1ibpiy70 {
|
|
|
72
76
|
line-height: 22px;
|
|
73
77
|
opacity: 0.96;
|
|
74
78
|
}
|
|
75
|
-
.
|
|
79
|
+
.inAppBanner_cta__1ibpiy76 {
|
|
76
80
|
all: unset;
|
|
77
81
|
display: inline-flex;
|
|
78
82
|
align-items: center;
|
|
79
83
|
gap: 4px;
|
|
80
|
-
color: #
|
|
84
|
+
color: #2bb2ff;
|
|
81
85
|
font-size: 14px;
|
|
82
86
|
font-weight: 600;
|
|
83
87
|
text-decoration: underline;
|
|
84
88
|
text-underline-offset: 2px;
|
|
85
89
|
cursor: pointer;
|
|
86
90
|
}
|
|
87
|
-
.
|
|
88
|
-
outline: 2px solid #
|
|
91
|
+
.inAppBanner_cta__1ibpiy76:focus-visible {
|
|
92
|
+
outline: 2px solid #2bb2ff;
|
|
89
93
|
outline-offset: 2px;
|
|
90
94
|
border-radius: 4px;
|
|
91
95
|
}
|
|
92
|
-
.
|
|
96
|
+
.inAppBanner_closeButton__1ibpiy77 {
|
|
93
97
|
all: unset;
|
|
94
98
|
position: absolute;
|
|
95
99
|
top: 8px;
|
|
@@ -100,23 +104,24 @@ const cssSource$2 = `@keyframes inAppBanner_fadeIn__1ibpiy70 {
|
|
|
100
104
|
align-items: center;
|
|
101
105
|
justify-content: center;
|
|
102
106
|
border-radius: 9999px;
|
|
103
|
-
color:
|
|
107
|
+
color: #ffffff99;
|
|
104
108
|
cursor: pointer;
|
|
105
109
|
}
|
|
106
|
-
.
|
|
107
|
-
outline: 2px solid
|
|
110
|
+
.inAppBanner_closeButton__1ibpiy77:focus-visible {
|
|
111
|
+
outline: 2px solid var(--text-onAction__pbq4ak6);
|
|
108
112
|
outline-offset: 2px;
|
|
109
113
|
}`;
|
|
110
114
|
//#endregion
|
|
111
115
|
//#region ../../packages/design-system/src/styles/inAppBanner.css.ts
|
|
112
|
-
var body = "
|
|
113
|
-
var closeButton = "
|
|
114
|
-
var container = "
|
|
115
|
-
var cta = "
|
|
116
|
-
var description = "
|
|
117
|
-
var header = "
|
|
118
|
-
var iconWrapper = "
|
|
119
|
-
var title = "
|
|
116
|
+
var body = "inAppBanner_body__1ibpiy74";
|
|
117
|
+
var closeButton = "inAppBanner_closeButton__1ibpiy77";
|
|
118
|
+
var container = "inAppBanner_container__1ibpiy70";
|
|
119
|
+
var cta = "inAppBanner_cta__1ibpiy76";
|
|
120
|
+
var description = "inAppBanner_description__1ibpiy75";
|
|
121
|
+
var header = "inAppBanner_header__1ibpiy71";
|
|
122
|
+
var iconWrapper = "inAppBanner_iconWrapper__1ibpiy72";
|
|
123
|
+
var title = "inAppBanner_title__1ibpiy73";
|
|
124
|
+
cssSource$4 + cssSource$3;
|
|
120
125
|
//#endregion
|
|
121
126
|
//#region ../../packages/design-system/src/components/InAppBanner/index.tsx
|
|
122
127
|
function InAppBanner({ title: title$1, description: description$1, cta: cta$1, dismissLabel, onAction, onDismiss, className, classNames }) {
|
|
@@ -167,26 +172,16 @@ function InAppBanner({ title: title$1, description: description$1, cta: cta$1, d
|
|
|
167
172
|
}
|
|
168
173
|
//#endregion
|
|
169
174
|
//#region \0ve-inline:src/components/Banner/Banner.css.ts.vanilla.js
|
|
170
|
-
const cssSource$1 =
|
|
171
|
-
from {
|
|
172
|
-
opacity: 0;
|
|
173
|
-
transform: translateY(-4px);
|
|
174
|
-
}
|
|
175
|
-
to {
|
|
176
|
-
opacity: 1;
|
|
177
|
-
transform: translateY(0);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
.Banner_rootBase__1gnumzi1 {
|
|
175
|
+
const cssSource$1 = `.Banner_rootBase__1gnumzi0 {
|
|
181
176
|
position: relative;
|
|
182
177
|
display: flex;
|
|
183
|
-
animation:
|
|
178
|
+
animation: keyframes_fadeIn__mnqmlt0 300ms ease-out;
|
|
184
179
|
}
|
|
185
|
-
.
|
|
180
|
+
.Banner_iconSvg__1gnumzi1 {
|
|
186
181
|
width: 100%;
|
|
187
182
|
height: 100%;
|
|
188
183
|
}
|
|
189
|
-
.
|
|
184
|
+
.Banner_referral__1gnumzi2 {
|
|
190
185
|
flex-direction: row;
|
|
191
186
|
align-items: center;
|
|
192
187
|
gap: 16px;
|
|
@@ -196,7 +191,7 @@ const cssSource$1 = `@keyframes Banner_fadeIn__1gnumzi0 {
|
|
|
196
191
|
border: 1px solid var(--border-default__pbq4akv);
|
|
197
192
|
border-radius: 12px;
|
|
198
193
|
}
|
|
199
|
-
.
|
|
194
|
+
.Banner_referralIconWrapper__1gnumzi3 {
|
|
200
195
|
flex-shrink: 0;
|
|
201
196
|
align-self: flex-start;
|
|
202
197
|
display: flex;
|
|
@@ -206,7 +201,7 @@ const cssSource$1 = `@keyframes Banner_fadeIn__1gnumzi0 {
|
|
|
206
201
|
height: 40px;
|
|
207
202
|
overflow: hidden;
|
|
208
203
|
}
|
|
209
|
-
.
|
|
204
|
+
.Banner_referralImage__1gnumzi4 {
|
|
210
205
|
max-width: 100%;
|
|
211
206
|
max-height: 100%;
|
|
212
207
|
width: auto;
|
|
@@ -214,23 +209,23 @@ const cssSource$1 = `@keyframes Banner_fadeIn__1gnumzi0 {
|
|
|
214
209
|
object-fit: contain;
|
|
215
210
|
display: block;
|
|
216
211
|
}
|
|
217
|
-
.
|
|
212
|
+
.Banner_referralBody__1gnumzi5 {
|
|
218
213
|
flex: 1;
|
|
219
214
|
min-width: 0;
|
|
220
215
|
}
|
|
221
|
-
.
|
|
216
|
+
.Banner_referralTitle__1gnumzi6 {
|
|
222
217
|
font-size: 16px;
|
|
223
218
|
font-weight: 600;
|
|
224
219
|
color: var(--text-primary__pbq4ak0);
|
|
225
220
|
line-height: 22px;
|
|
226
221
|
}
|
|
227
|
-
.
|
|
222
|
+
.Banner_referralDescription__1gnumzi7 {
|
|
228
223
|
margin-bottom: 8px;
|
|
229
224
|
font-size: 14px;
|
|
230
225
|
color: #979797;
|
|
231
226
|
line-height: 22px;
|
|
232
227
|
}
|
|
233
|
-
.
|
|
228
|
+
.Banner_referralCta__1gnumzi8 {
|
|
234
229
|
display: inline-block;
|
|
235
230
|
padding: 8px 16px;
|
|
236
231
|
border: 1px solid #000000;
|
|
@@ -241,7 +236,7 @@ const cssSource$1 = `@keyframes Banner_fadeIn__1gnumzi0 {
|
|
|
241
236
|
line-height: 12px;
|
|
242
237
|
text-transform: uppercase;
|
|
243
238
|
}
|
|
244
|
-
.
|
|
239
|
+
.Banner_frakLogo__1gnumzi9 {
|
|
245
240
|
position: absolute;
|
|
246
241
|
right: 16px;
|
|
247
242
|
bottom: 12px;
|
|
@@ -249,16 +244,16 @@ const cssSource$1 = `@keyframes Banner_fadeIn__1gnumzi0 {
|
|
|
249
244
|
}`;
|
|
250
245
|
//#endregion
|
|
251
246
|
//#region src/components/Banner/Banner.css.ts
|
|
252
|
-
var frakLogo = "
|
|
253
|
-
var iconSvg = "
|
|
254
|
-
var referral = "
|
|
255
|
-
var referralBody = "
|
|
256
|
-
var referralCta = "
|
|
257
|
-
var referralDescription = "
|
|
258
|
-
var referralIconWrapper = "
|
|
259
|
-
var referralImage = "
|
|
260
|
-
var referralTitle = "
|
|
261
|
-
const cssSource = cssSource$
|
|
247
|
+
var frakLogo = "Banner_frakLogo__1gnumzi9";
|
|
248
|
+
var iconSvg = "Banner_iconSvg__1gnumzi1";
|
|
249
|
+
var referral = "Banner_referral__1gnumzi2 reset_base__1831jhd0 Banner_rootBase__1gnumzi0";
|
|
250
|
+
var referralBody = "Banner_referralBody__1gnumzi5";
|
|
251
|
+
var referralCta = "Banner_referralCta__1gnumzi8 sharedBaseCss_buttonReset__7cswil0";
|
|
252
|
+
var referralDescription = "Banner_referralDescription__1gnumzi7 reset_base__1831jhd0";
|
|
253
|
+
var referralIconWrapper = "Banner_referralIconWrapper__1gnumzi3";
|
|
254
|
+
var referralImage = "Banner_referralImage__1gnumzi4";
|
|
255
|
+
var referralTitle = "Banner_referralTitle__1gnumzi6 reset_base__1831jhd0";
|
|
256
|
+
const cssSource = cssSource$4 + cssSource$3 + cssSource$1;
|
|
262
257
|
//#endregion
|
|
263
258
|
//#region src/components/Banner/Banner.tsx
|
|
264
259
|
/**
|
|
@@ -291,13 +286,14 @@ const cssSource = cssSource$2 + cssSource$1;
|
|
|
291
286
|
* <frak-banner classname="my-custom-banner"></frak-banner>
|
|
292
287
|
* ```
|
|
293
288
|
*/
|
|
294
|
-
function Banner({ placement: placementId, classname = "", interaction, referralTitle: propReferralTitle, referralDescription: propReferralDescription, referralCta: propReferralCta, inappTitle: propInappTitle, inappDescription: propInappDescription, inappCta: propInappCta, imageUrl, preview, previewMode, allowInappRedirect }) {
|
|
289
|
+
function Banner({ placement: placementId, classname = "", interaction, referralTitle: propReferralTitle, referralDescription: propReferralDescription, referralCta: propReferralCta, inappTitle: propInappTitle, inappDescription: propInappDescription, inappCta: propInappCta, imageUrl: propImageUrl, preview, previewMode, allowInappRedirect }) {
|
|
295
290
|
const isPreview = !!preview;
|
|
291
|
+
const lang = useLang();
|
|
296
292
|
const resolvedPreviewMode = previewMode === "inapp" ? "inapp" : "referral";
|
|
297
293
|
const isInappRedirectAllowed = allowInappRedirect === true || allowInappRedirect === "true";
|
|
298
294
|
const placement = usePlacement(placementId);
|
|
299
295
|
const { shouldRender, isHidden, isClientReady } = useClientReady();
|
|
300
|
-
useLightDomStyles("frak-banner", placementId, placement?.components?.banner?.css, cssSource, cssSource$
|
|
296
|
+
useLightDomStyles("frak-banner", placementId, placement?.components?.banner?.css, cssSource, cssSource$5);
|
|
301
297
|
const [dismissed, setDismissed] = useState(false);
|
|
302
298
|
const [mode, setMode] = useState(() => {
|
|
303
299
|
if (isPreview) return resolvedPreviewMode;
|
|
@@ -307,7 +303,7 @@ function Banner({ placement: placementId, classname = "", interaction, referralT
|
|
|
307
303
|
useEffect(() => {
|
|
308
304
|
if (isPreview) setMode(resolvedPreviewMode);
|
|
309
305
|
}, [isPreview, resolvedPreviewMode]);
|
|
310
|
-
const { reward } = useReward(mode === "referral" && isClientReady, interaction);
|
|
306
|
+
const { reward } = useReward(mode === "referral" && isClientReady, interaction, "referee");
|
|
311
307
|
const [prefetchedMergeToken, setPrefetchedMergeToken] = useState(null);
|
|
312
308
|
useEffect(() => {
|
|
313
309
|
const client = window.FrakSetup?.client;
|
|
@@ -384,21 +380,24 @@ function Banner({ placement: placementId, classname = "", interaction, referralT
|
|
|
384
380
|
]);
|
|
385
381
|
const globalComponents = useGlobalComponents();
|
|
386
382
|
const bannerConfig = placement?.components?.banner ?? globalComponents?.banner;
|
|
383
|
+
const imageUrl = propImageUrl ?? bannerConfig?.imageUrl;
|
|
387
384
|
const texts = useMemo(() => {
|
|
385
|
+
const defaults = componentDefaults[lang].banner;
|
|
388
386
|
if (mode === "referral") {
|
|
389
|
-
const defaultTitle = reward ?
|
|
387
|
+
const defaultTitle = reward ? defaults.referralTitleReward : defaults.referralTitle;
|
|
390
388
|
return {
|
|
391
|
-
title: propReferralTitle ?? bannerConfig?.referralTitle ?? defaultTitle,
|
|
392
|
-
description: propReferralDescription ?? bannerConfig?.referralDescription ??
|
|
393
|
-
cta: propReferralCta ?? bannerConfig?.referralCta ??
|
|
389
|
+
title: b(propReferralTitle ?? bannerConfig?.referralTitle ?? defaultTitle, reward),
|
|
390
|
+
description: b(propReferralDescription ?? bannerConfig?.referralDescription ?? defaults.referralDescription, reward),
|
|
391
|
+
cta: propReferralCta ?? bannerConfig?.referralCta ?? defaults.referralCta
|
|
394
392
|
};
|
|
395
393
|
}
|
|
396
394
|
return {
|
|
397
|
-
title: propInappTitle ?? bannerConfig?.inappTitle ??
|
|
398
|
-
description: propInappDescription ?? bannerConfig?.inappDescription ??
|
|
399
|
-
cta: propInappCta ?? bannerConfig?.inappCta ??
|
|
395
|
+
title: propInappTitle ?? bannerConfig?.inappTitle ?? defaults.inappTitle,
|
|
396
|
+
description: propInappDescription ?? bannerConfig?.inappDescription ?? defaults.inappDescription,
|
|
397
|
+
cta: propInappCta ?? bannerConfig?.inappCta ?? defaults.inappCta
|
|
400
398
|
};
|
|
401
399
|
}, [
|
|
400
|
+
lang,
|
|
402
401
|
mode,
|
|
403
402
|
reward,
|
|
404
403
|
bannerConfig,
|
|
@@ -420,7 +419,7 @@ function Banner({ placement: placementId, classname = "", interaction, referralT
|
|
|
420
419
|
title: texts.title,
|
|
421
420
|
description: texts.description,
|
|
422
421
|
cta: texts.cta,
|
|
423
|
-
dismissLabel:
|
|
422
|
+
dismissLabel: componentDefaults[lang].banner.dismissLabel,
|
|
424
423
|
onAction: handleAction,
|
|
425
424
|
onDismiss: handleDismiss,
|
|
426
425
|
className: [
|
package/dist/buttonShare.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { InteractionTypeKey } from "@frak-labs/core-sdk";
|
|
2
|
-
import * as _$preact from "preact";
|
|
3
2
|
|
|
4
3
|
//#region src/components/ButtonShare/types.d.ts
|
|
5
4
|
/**
|
|
@@ -16,7 +15,9 @@ type ButtonShareProps = {
|
|
|
16
15
|
* estimated reward and substitutes the placeholder. When no reward is
|
|
17
16
|
* available, `noRewardText` is used as a fallback (or the placeholder is
|
|
18
17
|
* stripped if no fallback is provided).
|
|
19
|
-
*
|
|
18
|
+
*
|
|
19
|
+
* When omitted, a built-in localized default is used based on the
|
|
20
|
+
* resolved language (`"Share and earn!"` / `"Partagez et gagnez !"`).
|
|
20
21
|
*/
|
|
21
22
|
text?: string;
|
|
22
23
|
/**
|
|
@@ -104,7 +105,7 @@ declare function ButtonShare({
|
|
|
104
105
|
targetInteraction,
|
|
105
106
|
clickAction: rawClickAction,
|
|
106
107
|
preview
|
|
107
|
-
}: ButtonShareProps):
|
|
108
|
+
}: ButtonShareProps): import("preact").JSX.Element | null;
|
|
108
109
|
//#endregion
|
|
109
110
|
//#region src/components/ButtonShare/index.d.ts
|
|
110
111
|
/**
|