@tap-payments/connect-v2 0.0.35-test → 1.0.0-development
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/build/index.cjs.js +1 -1
- package/build/index.esm.js +102 -98
- package/package.json +1 -1
package/build/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),f=require("react"),D=require("react-dom");function L(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const m=L(f);var y=(e=>(e.PAGE="page",e.POPUP="popup",e.CONTENT="content",e))(y||{}),I=(e=>(e.AUTH="auth",e.MERCHANT="merchant",e))(I||{}),h=(e=>(e.AUTH="auth",e.BANK="bank",e.BOARD="board",e.BRAND="brand",e.ENTITY="entity",e.INDIVIDUAL="individual",e.KYC="kyc",e.TAX="tax",e.TERMINAL="terminal",e))(h||{}),T=(e=>(e.SA="sa",e.SA_DR="sa-dr",e))(T||{}),v=(e=>(e.DARK="dark",e.LIGHT="light",e.DYNAMIC="dynamic",e))(v||{}),b=(e=>(e.AR="ar",e.EN="en",e.DYNAMIC="dynamic",e))(b||{}),g=(e=>(e.STRAIGHT="straight",e.CURVED="curved",e))(g||{}),x=(e=>(e.LEFT="left",e.RIGHT="right",e.UP="up",e.DOWN="down",e))(x||{}),c=(e=>(e.ON_CLOSE="connect:onClose",e.ON_ERROR="connect:onError",e.ON_SUCCESS="connect:onSuccess",e.ON_READY="connect:onReady",e.ON_LOADED="connect:onLoaded",e))(c||{}),u=(e=>(e.AUTH_TOKEN="token",e.CONFIG_TOKEN="config_token",e.THEME="theme",e.LANGUAGE="lang",e.BOARD_ID="board_id",e))(u||{});const G=({outerStartColor:e="rgba(244, 244, 244, 1)",outerEndColor:n="rgba(238, 238, 238, 1)",innerStartColor:t="rgba(244, 244, 244, 1)",innerEndColor:o="rgba(238, 238, 238, 1)",duration:a=3,toggleAnimation:s=!1})=>r.jsx("div",{style:{position:"relative",width:"135px",height:"135px"},children:r.jsx("div",{style:{position:"absolute",display:"flex",justifyContent:"center",alignItems:"center",width:"100%",height:"100%",opacity:.9},children:r.jsxs("svg",{width:"199",height:"197",viewBox:"0 0 199 197",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r.jsxs("g",{children:[r.jsx("circle",{cx:"89.5",cy:"86.5",r:"67.5",fill:"none",stroke:"url(#strokeGradientOuter_1427_22275)",strokeWidth:"9.6",strokeLinecap:"round",strokeDasharray:"425 125",children:s&&r.jsxs(r.Fragment,{children:[r.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"0 89.5 86.5",to:"360 89.5 86.5",dur:`${a/3}s`,repeatCount:"indefinite"}),r.jsx("animate",{attributeName:"stroke-dashoffset",values:"0; 425; 425; 0; 0",keyTimes:"0; 0.45; 0.55; 0.9; 1",dur:`${a}s`,repeatCount:"indefinite"})]})}),r.jsx("circle",{cx:"89.5",cy:"86.5",r:"48",fill:"none",stroke:"url(#strokeGradientInner_1427_22275)",strokeWidth:"9.6",strokeLinecap:"round",strokeDasharray:"300 100",children:s&&r.jsxs(r.Fragment,{children:[r.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"360 89.5 86.5",to:"0 89.5 86.5",dur:`${a/3}s`,repeatCount:"indefinite"}),r.jsx("animate",{attributeName:"stroke-dashoffset",values:"0; -300; -300; 0; 0",keyTimes:"0; 0.45; 0.55; 0.9; 1",dur:`${a}s`,repeatCount:"indefinite"})]})})]}),r.jsxs("defs",{children:[r.jsxs("filter",{id:"filter0_dddi_1427_22275",x:"0.882668",y:"0.899429",width:"198.08",height:"195.314",filterUnits:"userSpaceOnUse",colorInterpolationFilters:"sRGB",children:[r.jsx("feFlood",{floodOpacity:"0",result:"BackgroundImageFix"}),r.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),r.jsx("feOffset",{dy:"1.68224"}),r.jsx("feGaussianBlur",{stdDeviation:"4.20656"}),r.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),r.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 0.824495 0 0 0 0 0.824495 0 0 0 0 0.824495 0 0 0 1 0"}),r.jsx("feBlend",{mode:"normal",in2:"BackgroundImageFix",result:"effect1_dropShadow_1427_22275"}),r.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),r.jsx("feOffset",{dx:"22.3542",dy:"22.6047"}),r.jsx("feGaussianBlur",{stdDeviation:"9.80447"}),r.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),r.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 0.740723 0 0 0 0 0.740723 0 0 0 0 0.740723 0 0 0 0.6 0"}),r.jsx("feBlend",{mode:"normal",in2:"effect1_dropShadow_1427_22275",result:"effect2_dropShadow_1427_22275"}),r.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),r.jsx("feOffset",{dx:"-6.03352",dy:"-3.01676"}),r.jsx("feGaussianBlur",{stdDeviation:"7.5419"}),r.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),r.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.7 0"}),r.jsx("feBlend",{mode:"normal",in2:"effect2_dropShadow_1427_22275",result:"effect3_dropShadow_1427_22275"}),r.jsx("feBlend",{mode:"normal",in:"SourceGraphic",in2:"effect3_dropShadow_1427_22275",result:"shape"}),r.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),r.jsx("feOffset",{dy:"1.50838"}),r.jsx("feComposite",{in2:"hardAlpha",operator:"arithmetic",k2:"-1",k3:"1"}),r.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"}),r.jsx("feBlend",{mode:"normal",in2:"shape",result:"effect4_innerShadow_1427_22275"})]}),r.jsxs("linearGradient",{id:"strokeGradientOuter_1427_22275",x1:"89.5",y1:"19",x2:"89.5",y2:"154",gradientUnits:"userSpaceOnUse",children:[r.jsx("stop",{stopColor:e}),r.jsx("stop",{offset:"1",stopColor:n})]}),r.jsxs("linearGradient",{id:"strokeGradientInner_1427_22275",x1:"89.4991",y1:"38.2849",x2:"89.4991",y2:"134.713",gradientUnits:"userSpaceOnUse",children:[r.jsx("stop",{stopColor:t}),r.jsx("stop",{offset:"1",stopColor:o})]})]})]})})}),B=f.memo(G),S=f.createContext({}),_=()=>f.useContext(S);function P({children:e,props:n}){const[t,o]=f.useState(!1),a=i=>{o(i)},s=()=>{o(!1)};return r.jsx(S.Provider,{value:{...n,onLoadingHandler:a,loading:t,onLoaded:s},children:e})}const M="https://connect-mw.dev.tap.company/middleware/v3/connect",H="https://connect-mw.dev.tap.company/middleware/v3/connect",$="https://connect-mw.dev.tap.company/middleware/v3/connect",K="tap-connect-sdk-iframe",j="https://sdk-connect.dev.tap.company",W=({src:e})=>{const{loading:n}=_();return r.jsxs(r.Fragment,{children:[n&&r.jsx(B,{toggleAnimation:!0}),e&&r.jsx("iframe",{id:K,title:"connect",src:e,style:{width:"100%",height:"100%",border:"none",position:"absolute",top:0,left:0}})]})};var F=function(e){var n,t;return((t=(n=e==null?void 0:e.response)===null||n===void 0?void 0:n.data)===null||t===void 0?void 0:t.errors)!==void 0},Y=function(e){return e instanceof Error},q=function(e){return typeof e=="string"},V=function(e){try{var n=e.response.data.errors,t=n[0],o=t.description,a=t.code;return{message:o,code:a}}catch(s){return{message:s.message,code:"UNKNOWN"}}},z=function(e){try{var n=e.message,t=n.split("::"),o=t[0],a=t[1];return{message:a,code:o}}catch(s){return{message:s.message,code:"UNKNOWN"}}},J=function(e){try{var n=e.split("::"),t=n[0],o=n[1];return{message:o,code:t}}catch(a){return{message:a,code:"UNKNOWN"}}},X=function(){function e(n){if(Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"message",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),F(n)){var t=V(n);this.code=t.code,this.message=t.message}else if(Y(n)){var t=z(n);this.code=t.code,this.message=t.message}else if(q(n)){var t=J(n);this.code=t.code,this.message=t.message}else this.code="UNKNOWN",this.message="Unknown error"}return Object.defineProperty(e.prototype,"getCode",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.code}}),Object.defineProperty(e.prototype,"getMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.message}}),Object.defineProperty(e.prototype,"getClientError",{enumerable:!1,configurable:!0,writable:!0,value:function(){return{message:this.message,code:this.code}}}),e}();const Q=(e="tap-connect-sdk-element")=>{const n=document.getElementById(e);if(n)return n;const t=document.createElement("div");return t.setAttribute("id",e),document.body.prepend(t),t},Z=e=>e?["sa","sau"].includes(e.toLowerCase()):!1,ee=e=>e==="dr",te=(e="")=>{const[n,t]=e.split("-");return Z(n)?ee(t)?$:H:M},re=e=>{var n,t,o,a,s,i,l,d,p,C,N,E,O,A,w;return{operator:{public_key:e.publicKey},scope:e.scope,mode:e.mode||y.PAGE,domain:e.merchantDomain,...e.businessCountryCode&&{country:e.businessCountryCode},...e.data&&{data:e.data},board:{display:e.showBoard??!0,editable:e.boardEditable??!0},interface:{theme:e.theme||v.DYNAMIC,locale:e.language||b.DYNAMIC,edges:((n=e.features)==null?void 0:n.dialogEdgeFormat)||g.CURVED,parnter_logo:((t=e.features)==null?void 0:t.merchantLogo)??!1,dialog_transition:{start:((o=e.features)==null?void 0:o.dialogStartTransition)||x.UP,end:((a=e.features)==null?void 0:a.dialogEndTransition)||x.DOWN}},notification:{email:((s=e.notification)==null?void 0:s.email)??!1,sms:((i=e.notification)==null?void 0:i.sms)??!1},features:{poweredby:((l=e.features)==null?void 0:l.poweredBy)??!0,close_button:((d=e.features)==null?void 0:d.closeButton)??!1,embedded:((p=e.features)==null?void 0:p.embedded)??!1},...e.leadId&&{lead:{id:e.leadId}},...e.postUrl&&{post:{url:e.postUrl}},...e.redirectUrl&&{redirect:{url:e.redirectUrl}},...e.platforms&&{platforms:e.platforms},...(((C=e.paymentProvider)==null?void 0:C.institutionId)||((N=e.paymentProvider)==null?void 0:N.technologyId))&&{payment_provider:{...((E=e.paymentProvider)==null?void 0:E.institutionId)&&{institution:{id:(O=e.paymentProvider)==null?void 0:O.institutionId}},...((A=e.paymentProvider)==null?void 0:A.technologyId)&&{technology:{id:(w=e.paymentProvider)==null?void 0:w.technologyId}}}},app_info:{name:window.location.hostname||window.location.origin,version:"0.0.35-test"}}},ne=({theme:e,language:n,configToken:t,flow:o,token:a,boardId:s})=>{const i=new URLSearchParams;let l="";return o&&(l=o,o===h.BOARD&&s?i.append(u.BOARD_ID,s):o!==h.AUTH&&a&&i.append(u.AUTH_TOKEN,a)),e&&i.append(u.THEME,e),n&&i.append(u.LANGUAGE,n),i.append(u.CONFIG_TOKEN,t),`${j}/${l}?${i.toString()}`},oe=async e=>{const n=await fetch(te(e.region),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.publicKey}`,mdn:e.merchantDomain||j},body:JSON.stringify(re(e))});if(!n.ok)throw new Error(`${n.status}::${n.statusText}`);return n.json()},ae=()=>{const[e,n]=m.useState(""),t=_(),o=async()=>{var a,s,i;t.onLoadingHandler(!0);try{let l=t.configToken,d;if(!l){if(d=await oe(t),!d.token)throw new Error("500::Config token is missing");l=d.token}const p=ne({theme:(a=d==null?void 0:d.interface)==null?void 0:a.theme,language:(s=d==null?void 0:d.interface)==null?void 0:s.locale,configToken:l,flow:t.flow,token:t.token,boardId:t.boardId});if(t.mode!==y.PAGE)return n(p);window.location.href=p}catch(l){const d=new X(l);(i=t.onError)==null||i.call(t,d.getClientError()),t.onLoadingHandler(!1)}};return m.useEffect(()=>{o()},[]),{connectLink:e}},se=()=>{const{onSuccess:e,onClose:n,onError:t,onReady:o,onLoaded:a}=_(),s=m.useCallback(async i=>{if(i.origin!==j)return;const{data:l,event:d}=i.data;switch(d){case c.ON_CLOSE:n==null||n();break;case c.ON_ERROR:t==null||t(l);break;case c.ON_SUCCESS:e==null||e(l);break;case c.ON_LOADED:a();break;case c.ON_READY:o==null||o();break}},[n,t,a,o,e]);m.useEffect(()=>(window.addEventListener("message",s,!1),()=>{window.removeEventListener("message",s)}),[s])},ie=()=>{const{connectLink:e}=ae();return se(),r.jsx("div",{id:"tap-connect-main-container",style:{display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0, 0, 0, 0.5)",position:"fixed",top:0,left:0,width:"100%",height:"100%"},children:r.jsx(W,{src:e})})},de=e=>r.jsx(P,{props:e,children:e.open&&r.jsx(ie,{})}),R=m.memo(de);var U,k=D;U=k.createRoot,k.hydrateRoot;const le=(e,n)=>{const t=Q(e),o=U(t);return o.render(r.jsx(R,{...n})),{unmount:()=>o.unmount()}};exports.ConnectDialogEdgeFormat=g;exports.ConnectDialogTransition=x;exports.ConnectElement=R;exports.ConnectFlows=h;exports.ConnectLanguage=b;exports.ConnectMode=y;exports.ConnectRegions=T;exports.ConnectScope=I;exports.ConnectTheme=v;exports.renderConnectElement=le;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),f=require("react"),G=require("react-dom");function B(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const m=B(f);var y=(e=>(e.PAGE="page",e.POPUP="popup",e.CONTENT="content",e))(y||{}),I=(e=>(e.AUTH="auth",e.MERCHANT="merchant",e))(I||{}),h=(e=>(e.AUTH="auth",e.BANK="bank",e.BOARD="board",e.BRAND="brand",e.ENTITY="entity",e.INDIVIDUAL="individual",e.KYC="kyc",e.TAX="tax",e.TERMINAL="terminal",e))(h||{}),T=(e=>(e.SA="sa",e.SA_DR="sa-dr",e))(T||{}),v=(e=>(e.DARK="dark",e.LIGHT="light",e.DYNAMIC="dynamic",e))(v||{}),_=(e=>(e.AR="ar",e.EN="en",e.DYNAMIC="dynamic",e))(_||{}),g=(e=>(e.STRAIGHT="straight",e.CURVED="curved",e))(g||{}),x=(e=>(e.LEFT="left",e.RIGHT="right",e.UP="up",e.DOWN="down",e))(x||{}),c=(e=>(e.ON_CLOSE="connect:onClose",e.ON_ERROR="connect:onError",e.ON_SUCCESS="connect:onSuccess",e.ON_READY="connect:onReady",e.ON_LOADED="connect:onLoaded",e))(c||{}),u=(e=>(e.AUTH_TOKEN="token",e.CONFIG_TOKEN="config_token",e.THEME="theme",e.LANGUAGE="lang",e.BOARD_ID="board_id",e))(u||{});const P=({outerStartColor:e="rgba(244, 244, 244, 1)",outerEndColor:n="rgba(238, 238, 238, 1)",innerStartColor:t="rgba(244, 244, 244, 1)",innerEndColor:o="rgba(238, 238, 238, 1)",duration:a=3,toggleAnimation:s=!1})=>r.jsx("div",{style:{position:"relative",width:"135px",height:"135px"},children:r.jsx("div",{style:{position:"absolute",display:"flex",justifyContent:"center",alignItems:"center",width:"100%",height:"100%",opacity:.9},children:r.jsxs("svg",{width:"199",height:"197",viewBox:"0 0 199 197",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r.jsxs("g",{children:[r.jsx("circle",{cx:"89.5",cy:"86.5",r:"67.5",fill:"none",stroke:"url(#strokeGradientOuter_1427_22275)",strokeWidth:"9.6",strokeLinecap:"round",strokeDasharray:"425 125",children:s&&r.jsxs(r.Fragment,{children:[r.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"0 89.5 86.5",to:"360 89.5 86.5",dur:`${a/3}s`,repeatCount:"indefinite"}),r.jsx("animate",{attributeName:"stroke-dashoffset",values:"0; 425; 425; 0; 0",keyTimes:"0; 0.45; 0.55; 0.9; 1",dur:`${a}s`,repeatCount:"indefinite"})]})}),r.jsx("circle",{cx:"89.5",cy:"86.5",r:"48",fill:"none",stroke:"url(#strokeGradientInner_1427_22275)",strokeWidth:"9.6",strokeLinecap:"round",strokeDasharray:"300 100",children:s&&r.jsxs(r.Fragment,{children:[r.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"360 89.5 86.5",to:"0 89.5 86.5",dur:`${a/3}s`,repeatCount:"indefinite"}),r.jsx("animate",{attributeName:"stroke-dashoffset",values:"0; -300; -300; 0; 0",keyTimes:"0; 0.45; 0.55; 0.9; 1",dur:`${a}s`,repeatCount:"indefinite"})]})})]}),r.jsxs("defs",{children:[r.jsxs("filter",{id:"filter0_dddi_1427_22275",x:"0.882668",y:"0.899429",width:"198.08",height:"195.314",filterUnits:"userSpaceOnUse",colorInterpolationFilters:"sRGB",children:[r.jsx("feFlood",{floodOpacity:"0",result:"BackgroundImageFix"}),r.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),r.jsx("feOffset",{dy:"1.68224"}),r.jsx("feGaussianBlur",{stdDeviation:"4.20656"}),r.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),r.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 0.824495 0 0 0 0 0.824495 0 0 0 0 0.824495 0 0 0 1 0"}),r.jsx("feBlend",{mode:"normal",in2:"BackgroundImageFix",result:"effect1_dropShadow_1427_22275"}),r.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),r.jsx("feOffset",{dx:"22.3542",dy:"22.6047"}),r.jsx("feGaussianBlur",{stdDeviation:"9.80447"}),r.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),r.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 0.740723 0 0 0 0 0.740723 0 0 0 0 0.740723 0 0 0 0.6 0"}),r.jsx("feBlend",{mode:"normal",in2:"effect1_dropShadow_1427_22275",result:"effect2_dropShadow_1427_22275"}),r.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),r.jsx("feOffset",{dx:"-6.03352",dy:"-3.01676"}),r.jsx("feGaussianBlur",{stdDeviation:"7.5419"}),r.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),r.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.7 0"}),r.jsx("feBlend",{mode:"normal",in2:"effect2_dropShadow_1427_22275",result:"effect3_dropShadow_1427_22275"}),r.jsx("feBlend",{mode:"normal",in:"SourceGraphic",in2:"effect3_dropShadow_1427_22275",result:"shape"}),r.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),r.jsx("feOffset",{dy:"1.50838"}),r.jsx("feComposite",{in2:"hardAlpha",operator:"arithmetic",k2:"-1",k3:"1"}),r.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"}),r.jsx("feBlend",{mode:"normal",in2:"shape",result:"effect4_innerShadow_1427_22275"})]}),r.jsxs("linearGradient",{id:"strokeGradientOuter_1427_22275",x1:"89.5",y1:"19",x2:"89.5",y2:"154",gradientUnits:"userSpaceOnUse",children:[r.jsx("stop",{stopColor:e}),r.jsx("stop",{offset:"1",stopColor:n})]}),r.jsxs("linearGradient",{id:"strokeGradientInner_1427_22275",x1:"89.4991",y1:"38.2849",x2:"89.4991",y2:"134.713",gradientUnits:"userSpaceOnUse",children:[r.jsx("stop",{stopColor:t}),r.jsx("stop",{offset:"1",stopColor:o})]})]})]})})}),M=f.memo(P),R=f.createContext({}),N=()=>f.useContext(R);function H({children:e,props:n}){const[t,o]=f.useState(!1),a=l=>{o(l)},s=()=>{o(!1)};return r.jsx(R.Provider,{value:{...n,onLoadingHandler:a,loading:t,onLoaded:s},children:e})}const $="https://connect-mw.dev.tap.company/middleware/v3/connect",K="https://connect-mw.dev.tap.company/middleware/v3/connect",W="https://connect-mw.dev.tap.company/middleware/v3/connect",F="tap-connect-sdk-iframe",C="https://sdk-connect.dev.tap.company",Y="https://sdk-connect.dev.tap.company",q="https://sdk-connect.dev.tap.company",V=({src:e})=>{const{loading:n}=N();return r.jsxs(r.Fragment,{children:[n&&r.jsx(M,{toggleAnimation:!0}),e&&r.jsx("iframe",{id:F,title:"connect",src:e,style:{width:"100%",height:"100%",border:"none",position:"absolute",top:0,left:0}})]})};var z=function(e){var n,t;return((t=(n=e==null?void 0:e.response)===null||n===void 0?void 0:n.data)===null||t===void 0?void 0:t.errors)!==void 0},J=function(e){return e instanceof Error},X=function(e){return typeof e=="string"},Q=function(e){try{var n=e.response.data.errors,t=n[0],o=t.description,a=t.code;return{message:o,code:a}}catch(s){return{message:s.message,code:"UNKNOWN"}}},Z=function(e){try{var n=e.message,t=n.split("::"),o=t[0],a=t[1];return{message:a,code:o}}catch(s){return{message:s.message,code:"UNKNOWN"}}},ee=function(e){try{var n=e.split("::"),t=n[0],o=n[1];return{message:o,code:t}}catch(a){return{message:a,code:"UNKNOWN"}}},te=function(){function e(n){if(Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"message",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),z(n)){var t=Q(n);this.code=t.code,this.message=t.message}else if(J(n)){var t=Z(n);this.code=t.code,this.message=t.message}else if(X(n)){var t=ee(n);this.code=t.code,this.message=t.message}else this.code="UNKNOWN",this.message="Unknown error"}return Object.defineProperty(e.prototype,"getCode",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.code}}),Object.defineProperty(e.prototype,"getMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.message}}),Object.defineProperty(e.prototype,"getClientError",{enumerable:!1,configurable:!0,writable:!0,value:function(){return{message:this.message,code:this.code}}}),e}();const re=(e="tap-connect-sdk-element")=>{const n=document.getElementById(e);if(n)return n;const t=document.createElement("div");return t.setAttribute("id",e),document.body.prepend(t),t},S=e=>e?["sa","sau"].includes(e.toLowerCase()):!1,U=e=>e==="dr",ne=(e="")=>{const[n,t]=e.split("-");return S(n)?U(t)?W:K:$},oe=(e="")=>{const[n,t]=e.split("-");return S(n)?U(t)?q:Y:C},ae=e=>{var n,t,o,a,s,l,d,i,p,O,b,j,E,A,k;return{operator:{public_key:e.publicKey},scope:e.scope,mode:e.mode||y.PAGE,domain:e.merchantDomain,...e.businessCountryCode&&{country:e.businessCountryCode},...e.data&&{data:e.data},board:{display:e.showBoard??!0,editable:e.boardEditable??!0},interface:{theme:e.theme||v.DYNAMIC,locale:e.language||_.DYNAMIC,edges:((n=e.features)==null?void 0:n.dialogEdgeFormat)||g.CURVED,parnter_logo:((t=e.features)==null?void 0:t.merchantLogo)??!1,dialog_transition:{start:((o=e.features)==null?void 0:o.dialogStartTransition)||x.UP,end:((a=e.features)==null?void 0:a.dialogEndTransition)||x.DOWN}},notification:{email:((s=e.notification)==null?void 0:s.email)??!1,sms:((l=e.notification)==null?void 0:l.sms)??!1},features:{poweredby:((d=e.features)==null?void 0:d.poweredBy)??!0,close_button:((i=e.features)==null?void 0:i.closeButton)??!1,embedded:((p=e.features)==null?void 0:p.embedded)??!1},...e.leadId&&{lead:{id:e.leadId}},...e.postUrl&&{post:{url:e.postUrl}},...e.redirectUrl&&{redirect:{url:e.redirectUrl}},...e.platforms&&{platforms:e.platforms},...(((O=e.paymentProvider)==null?void 0:O.institutionId)||((b=e.paymentProvider)==null?void 0:b.technologyId))&&{payment_provider:{...((j=e.paymentProvider)==null?void 0:j.institutionId)&&{institution:{id:(E=e.paymentProvider)==null?void 0:E.institutionId}},...((A=e.paymentProvider)==null?void 0:A.technologyId)&&{technology:{id:(k=e.paymentProvider)==null?void 0:k.technologyId}}}},app_info:{name:window.location.hostname||window.location.origin,version:"1.0.0-development"}}},se=({theme:e,language:n,configToken:t,flow:o,token:a,boardId:s,region:l})=>{const d=new URLSearchParams;let i="";return o&&(i=o,o===h.BOARD&&s?d.append(u.BOARD_ID,s):o!==h.AUTH&&a&&d.append(u.AUTH_TOKEN,a)),e&&d.append(u.THEME,e),n&&d.append(u.LANGUAGE,n),d.append(u.CONFIG_TOKEN,t),`${oe(l)}/${i}?${d.toString()}`},ie=async e=>{const n=await fetch(ne(e.region),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.publicKey}`,mdn:e.merchantDomain||C},body:JSON.stringify(ae(e))});if(!n.ok)throw new Error(`${n.status}::${n.statusText}`);return n.json()},de=()=>{const[e,n]=m.useState(""),t=N(),o=async()=>{var a,s,l;t.onLoadingHandler(!0);try{let d=t.configToken,i;if(!d){if(i=await ie(t),!i.token)throw new Error("500::Config token is missing");d=i.token}const p=se({theme:(a=i==null?void 0:i.interface)==null?void 0:a.theme,language:(s=i==null?void 0:i.interface)==null?void 0:s.locale,configToken:d,flow:t.flow,token:t.token,boardId:t.boardId,region:t.region});if(t.mode!==y.PAGE)return n(p);window.location.href=p}catch(d){const i=new te(d);(l=t.onError)==null||l.call(t,i.getClientError()),t.onLoadingHandler(!1)}};return m.useEffect(()=>{o()},[]),{connectLink:e}},le=()=>{const{onSuccess:e,onClose:n,onError:t,onReady:o,onLoaded:a}=N(),s=m.useCallback(async l=>{if(l.origin!==C)return;const{data:d,event:i}=l.data;switch(i){case c.ON_CLOSE:n==null||n();break;case c.ON_ERROR:t==null||t(d);break;case c.ON_SUCCESS:e==null||e(d);break;case c.ON_LOADED:a();break;case c.ON_READY:o==null||o();break}},[n,t,a,o,e]);m.useEffect(()=>(window.addEventListener("message",s,!1),()=>{window.removeEventListener("message",s)}),[s])},ce=()=>{const{connectLink:e}=de();return le(),r.jsx("div",{id:"tap-connect-main-container",style:{display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0, 0, 0, 0.5)",position:"fixed",top:0,left:0,width:"100%",height:"100%"},children:r.jsx(V,{src:e})})},ue=e=>r.jsx(H,{props:e,children:e.open&&r.jsx(ce,{})}),D=m.memo(ue);var L,w=G;L=w.createRoot,w.hydrateRoot;const pe=(e,n)=>{const t=re(e),o=L(t);return o.render(r.jsx(D,{...n})),{unmount:()=>o.unmount()}};exports.ConnectDialogEdgeFormat=g;exports.ConnectDialogTransition=x;exports.ConnectElement=D;exports.ConnectFlows=h;exports.ConnectLanguage=_;exports.ConnectMode=y;exports.ConnectRegions=T;exports.ConnectScope=I;exports.ConnectTheme=v;exports.renderConnectElement=pe;
|
package/build/index.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsx as n, jsxs as
|
|
1
|
+
import { jsx as n, jsxs as c, Fragment as y } from "react/jsx-runtime";
|
|
2
2
|
import * as f from "react";
|
|
3
3
|
import h from "react";
|
|
4
|
-
import
|
|
5
|
-
var N = /* @__PURE__ */ ((e) => (e.PAGE = "page", e.POPUP = "popup", e.CONTENT = "content", e))(N || {}),
|
|
6
|
-
const
|
|
4
|
+
import G from "react-dom";
|
|
5
|
+
var N = /* @__PURE__ */ ((e) => (e.PAGE = "page", e.POPUP = "popup", e.CONTENT = "content", e))(N || {}), B = /* @__PURE__ */ ((e) => (e.AUTH = "auth", e.MERCHANT = "merchant", e))(B || {}), v = /* @__PURE__ */ ((e) => (e.AUTH = "auth", e.BANK = "bank", e.BOARD = "board", e.BRAND = "brand", e.ENTITY = "entity", e.INDIVIDUAL = "individual", e.KYC = "kyc", e.TAX = "tax", e.TERMINAL = "terminal", e))(v || {}), P = /* @__PURE__ */ ((e) => (e.SA = "sa", e.SA_DR = "sa-dr", e))(P || {}), x = /* @__PURE__ */ ((e) => (e.DARK = "dark", e.LIGHT = "light", e.DYNAMIC = "dynamic", e))(x || {}), R = /* @__PURE__ */ ((e) => (e.AR = "ar", e.EN = "en", e.DYNAMIC = "dynamic", e))(R || {}), T = /* @__PURE__ */ ((e) => (e.STRAIGHT = "straight", e.CURVED = "curved", e))(T || {}), _ = /* @__PURE__ */ ((e) => (e.LEFT = "left", e.RIGHT = "right", e.UP = "up", e.DOWN = "down", e))(_ || {}), u = /* @__PURE__ */ ((e) => (e.ON_CLOSE = "connect:onClose", e.ON_ERROR = "connect:onError", e.ON_SUCCESS = "connect:onSuccess", e.ON_READY = "connect:onReady", e.ON_LOADED = "connect:onLoaded", e))(u || {}), p = /* @__PURE__ */ ((e) => (e.AUTH_TOKEN = "token", e.CONFIG_TOKEN = "config_token", e.THEME = "theme", e.LANGUAGE = "lang", e.BOARD_ID = "board_id", e))(p || {});
|
|
6
|
+
const H = ({
|
|
7
7
|
outerStartColor: e = "rgba(244, 244, 244, 1)",
|
|
8
8
|
outerEndColor: r = "rgba(238, 238, 238, 1)",
|
|
9
9
|
innerStartColor: t = "rgba(244, 244, 244, 1)",
|
|
@@ -30,8 +30,8 @@ const B = ({
|
|
|
30
30
|
height: "100%",
|
|
31
31
|
opacity: 0.9
|
|
32
32
|
},
|
|
33
|
-
children: /* @__PURE__ */
|
|
34
|
-
/* @__PURE__ */
|
|
33
|
+
children: /* @__PURE__ */ c("svg", { width: "199", height: "197", viewBox: "0 0 199 197", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
34
|
+
/* @__PURE__ */ c("g", { children: [
|
|
35
35
|
/* @__PURE__ */ n(
|
|
36
36
|
"circle",
|
|
37
37
|
{
|
|
@@ -43,7 +43,7 @@ const B = ({
|
|
|
43
43
|
strokeWidth: "9.6",
|
|
44
44
|
strokeLinecap: "round",
|
|
45
45
|
strokeDasharray: "425 125",
|
|
46
|
-
children: s && /* @__PURE__ */
|
|
46
|
+
children: s && /* @__PURE__ */ c(y, { children: [
|
|
47
47
|
/* @__PURE__ */ n(
|
|
48
48
|
"animateTransform",
|
|
49
49
|
{
|
|
@@ -79,7 +79,7 @@ const B = ({
|
|
|
79
79
|
strokeWidth: "9.6",
|
|
80
80
|
strokeLinecap: "round",
|
|
81
81
|
strokeDasharray: "300 100",
|
|
82
|
-
children: s && /* @__PURE__ */
|
|
82
|
+
children: s && /* @__PURE__ */ c(y, { children: [
|
|
83
83
|
/* @__PURE__ */ n(
|
|
84
84
|
"animateTransform",
|
|
85
85
|
{
|
|
@@ -105,8 +105,8 @@ const B = ({
|
|
|
105
105
|
}
|
|
106
106
|
)
|
|
107
107
|
] }),
|
|
108
|
-
/* @__PURE__ */
|
|
109
|
-
/* @__PURE__ */
|
|
108
|
+
/* @__PURE__ */ c("defs", { children: [
|
|
109
|
+
/* @__PURE__ */ c(
|
|
110
110
|
"filter",
|
|
111
111
|
{
|
|
112
112
|
id: "filter0_dddi_1427_22275",
|
|
@@ -177,7 +177,7 @@ const B = ({
|
|
|
177
177
|
]
|
|
178
178
|
}
|
|
179
179
|
),
|
|
180
|
-
/* @__PURE__ */
|
|
180
|
+
/* @__PURE__ */ c(
|
|
181
181
|
"linearGradient",
|
|
182
182
|
{
|
|
183
183
|
id: "strokeGradientOuter_1427_22275",
|
|
@@ -192,7 +192,7 @@ const B = ({
|
|
|
192
192
|
]
|
|
193
193
|
}
|
|
194
194
|
),
|
|
195
|
-
/* @__PURE__ */
|
|
195
|
+
/* @__PURE__ */ c(
|
|
196
196
|
"linearGradient",
|
|
197
197
|
{
|
|
198
198
|
id: "strokeGradientInner_1427_22275",
|
|
@@ -212,23 +212,23 @@ const B = ({
|
|
|
212
212
|
}
|
|
213
213
|
)
|
|
214
214
|
}
|
|
215
|
-
),
|
|
216
|
-
function
|
|
217
|
-
const [t, o] = h.useState(!1), a = (
|
|
218
|
-
o(
|
|
215
|
+
), M = h.memo(H), U = h.createContext({}), E = () => h.useContext(U);
|
|
216
|
+
function $({ children: e, props: r }) {
|
|
217
|
+
const [t, o] = h.useState(!1), a = (l) => {
|
|
218
|
+
o(l);
|
|
219
219
|
}, s = () => {
|
|
220
220
|
o(!1);
|
|
221
221
|
};
|
|
222
|
-
return /* @__PURE__ */ n(
|
|
222
|
+
return /* @__PURE__ */ n(U.Provider, { value: { ...r, onLoadingHandler: a, loading: t, onLoaded: s }, children: e });
|
|
223
223
|
}
|
|
224
|
-
const
|
|
224
|
+
const K = "https://connect-mw.dev.tap.company/middleware/v3/connect", j = "https://connect-mw.dev.tap.company/middleware/v3/connect", W = "https://connect-mw.dev.tap.company/middleware/v3/connect", Y = "tap-connect-sdk-iframe", O = "https://sdk-connect.dev.tap.company", F = "https://sdk-connect.dev.tap.company", V = "https://sdk-connect.dev.tap.company", q = ({ src: e }) => {
|
|
225
225
|
const { loading: r } = E();
|
|
226
|
-
return /* @__PURE__ */
|
|
227
|
-
r && /* @__PURE__ */ n(
|
|
226
|
+
return /* @__PURE__ */ c(y, { children: [
|
|
227
|
+
r && /* @__PURE__ */ n(M, { toggleAnimation: !0 }),
|
|
228
228
|
e && /* @__PURE__ */ n(
|
|
229
229
|
"iframe",
|
|
230
230
|
{
|
|
231
|
-
id:
|
|
231
|
+
id: Y,
|
|
232
232
|
title: "connect",
|
|
233
233
|
src: e,
|
|
234
234
|
style: {
|
|
@@ -243,14 +243,14 @@ const M = "https://connect-mw.dev.tap.company/middleware/v3/connect", $ = "https
|
|
|
243
243
|
)
|
|
244
244
|
] });
|
|
245
245
|
};
|
|
246
|
-
var
|
|
246
|
+
var z = function(e) {
|
|
247
247
|
var r, t;
|
|
248
248
|
return ((t = (r = e == null ? void 0 : e.response) === null || r === void 0 ? void 0 : r.data) === null || t === void 0 ? void 0 : t.errors) !== void 0;
|
|
249
|
-
},
|
|
249
|
+
}, J = function(e) {
|
|
250
250
|
return e instanceof Error;
|
|
251
|
-
},
|
|
251
|
+
}, X = function(e) {
|
|
252
252
|
return typeof e == "string";
|
|
253
|
-
},
|
|
253
|
+
}, Q = function(e) {
|
|
254
254
|
try {
|
|
255
255
|
var r = e.response.data.errors, t = r[0], o = t.description, a = t.code;
|
|
256
256
|
return {
|
|
@@ -263,7 +263,7 @@ var Y = function(e) {
|
|
|
263
263
|
code: "UNKNOWN"
|
|
264
264
|
};
|
|
265
265
|
}
|
|
266
|
-
},
|
|
266
|
+
}, Z = function(e) {
|
|
267
267
|
try {
|
|
268
268
|
var r = e.message, t = r.split("::"), o = t[0], a = t[1];
|
|
269
269
|
return {
|
|
@@ -276,7 +276,7 @@ var Y = function(e) {
|
|
|
276
276
|
code: "UNKNOWN"
|
|
277
277
|
};
|
|
278
278
|
}
|
|
279
|
-
},
|
|
279
|
+
}, ee = function(e) {
|
|
280
280
|
try {
|
|
281
281
|
var r = e.split("::"), t = r[0], o = r[1];
|
|
282
282
|
return {
|
|
@@ -289,7 +289,7 @@ var Y = function(e) {
|
|
|
289
289
|
code: "UNKNOWN"
|
|
290
290
|
};
|
|
291
291
|
}
|
|
292
|
-
},
|
|
292
|
+
}, te = function() {
|
|
293
293
|
function e(r) {
|
|
294
294
|
if (Object.defineProperty(this, "code", {
|
|
295
295
|
enumerable: !0,
|
|
@@ -301,14 +301,14 @@ var Y = function(e) {
|
|
|
301
301
|
configurable: !0,
|
|
302
302
|
writable: !0,
|
|
303
303
|
value: void 0
|
|
304
|
-
}),
|
|
305
|
-
var t =
|
|
304
|
+
}), z(r)) {
|
|
305
|
+
var t = Q(r);
|
|
306
306
|
this.code = t.code, this.message = t.message;
|
|
307
|
-
} else if (
|
|
308
|
-
var t =
|
|
307
|
+
} else if (J(r)) {
|
|
308
|
+
var t = Z(r);
|
|
309
309
|
this.code = t.code, this.message = t.message;
|
|
310
|
-
} else if (
|
|
311
|
-
var t =
|
|
310
|
+
} else if (X(r)) {
|
|
311
|
+
var t = ee(r);
|
|
312
312
|
this.code = t.code, this.message = t.message;
|
|
313
313
|
} else
|
|
314
314
|
this.code = "UNKNOWN", this.message = "Unknown error";
|
|
@@ -339,16 +339,19 @@ var Y = function(e) {
|
|
|
339
339
|
}
|
|
340
340
|
}), e;
|
|
341
341
|
}();
|
|
342
|
-
const
|
|
342
|
+
const re = (e = "tap-connect-sdk-element") => {
|
|
343
343
|
const r = document.getElementById(e);
|
|
344
344
|
if (r) return r;
|
|
345
345
|
const t = document.createElement("div");
|
|
346
346
|
return t.setAttribute("id", e), document.body.prepend(t), t;
|
|
347
|
-
},
|
|
347
|
+
}, S = (e) => e ? ["sa", "sau"].includes(e.toLowerCase()) : !1, D = (e) => e === "dr", ne = (e = "") => {
|
|
348
|
+
const [r, t] = e.split("-");
|
|
349
|
+
return S(r) ? D(t) ? W : j : K;
|
|
350
|
+
}, oe = (e = "") => {
|
|
348
351
|
const [r, t] = e.split("-");
|
|
349
|
-
return
|
|
350
|
-
},
|
|
351
|
-
var r, t, o, a, s,
|
|
352
|
+
return S(r) ? D(t) ? V : F : O;
|
|
353
|
+
}, ae = (e) => {
|
|
354
|
+
var r, t, o, a, s, l, d, i, m, C, b, g, A, k, w;
|
|
352
355
|
return {
|
|
353
356
|
operator: { public_key: e.publicKey },
|
|
354
357
|
scope: e.scope,
|
|
@@ -361,9 +364,9 @@ const Q = (e = "tap-connect-sdk-element") => {
|
|
|
361
364
|
editable: e.boardEditable ?? !0
|
|
362
365
|
},
|
|
363
366
|
interface: {
|
|
364
|
-
theme: e.theme ||
|
|
365
|
-
locale: e.language ||
|
|
366
|
-
edges: ((r = e.features) == null ? void 0 : r.dialogEdgeFormat) ||
|
|
367
|
+
theme: e.theme || x.DYNAMIC,
|
|
368
|
+
locale: e.language || R.DYNAMIC,
|
|
369
|
+
edges: ((r = e.features) == null ? void 0 : r.dialogEdgeFormat) || T.CURVED,
|
|
367
370
|
parnter_logo: ((t = e.features) == null ? void 0 : t.merchantLogo) ?? !1,
|
|
368
371
|
dialog_transition: {
|
|
369
372
|
start: ((o = e.features) == null ? void 0 : o.dialogStartTransition) || _.UP,
|
|
@@ -372,18 +375,18 @@ const Q = (e = "tap-connect-sdk-element") => {
|
|
|
372
375
|
},
|
|
373
376
|
notification: {
|
|
374
377
|
email: ((s = e.notification) == null ? void 0 : s.email) ?? !1,
|
|
375
|
-
sms: ((
|
|
378
|
+
sms: ((l = e.notification) == null ? void 0 : l.sms) ?? !1
|
|
376
379
|
},
|
|
377
380
|
features: {
|
|
378
|
-
poweredby: ((
|
|
379
|
-
close_button: ((
|
|
381
|
+
poweredby: ((d = e.features) == null ? void 0 : d.poweredBy) ?? !0,
|
|
382
|
+
close_button: ((i = e.features) == null ? void 0 : i.closeButton) ?? !1,
|
|
380
383
|
embedded: ((m = e.features) == null ? void 0 : m.embedded) ?? !1
|
|
381
384
|
},
|
|
382
385
|
...e.leadId && { lead: { id: e.leadId } },
|
|
383
386
|
...e.postUrl && { post: { url: e.postUrl } },
|
|
384
387
|
...e.redirectUrl && { redirect: { url: e.redirectUrl } },
|
|
385
388
|
...e.platforms && { platforms: e.platforms },
|
|
386
|
-
...(((
|
|
389
|
+
...(((C = e.paymentProvider) == null ? void 0 : C.institutionId) || ((b = e.paymentProvider) == null ? void 0 : b.technologyId)) && {
|
|
387
390
|
payment_provider: {
|
|
388
391
|
...((g = e.paymentProvider) == null ? void 0 : g.institutionId) && { institution: { id: (A = e.paymentProvider) == null ? void 0 : A.institutionId } },
|
|
389
392
|
...((k = e.paymentProvider) == null ? void 0 : k.technologyId) && { technology: { id: (w = e.paymentProvider) == null ? void 0 : w.technologyId } }
|
|
@@ -391,73 +394,74 @@ const Q = (e = "tap-connect-sdk-element") => {
|
|
|
391
394
|
},
|
|
392
395
|
app_info: {
|
|
393
396
|
name: window.location.hostname || window.location.origin,
|
|
394
|
-
version: "0.0
|
|
397
|
+
version: "1.0.0-development"
|
|
395
398
|
}
|
|
396
399
|
};
|
|
397
|
-
},
|
|
398
|
-
const
|
|
399
|
-
let
|
|
400
|
-
return o && (
|
|
401
|
-
},
|
|
402
|
-
const r = await fetch(
|
|
400
|
+
}, se = ({ theme: e, language: r, configToken: t, flow: o, token: a, boardId: s, region: l }) => {
|
|
401
|
+
const d = new URLSearchParams();
|
|
402
|
+
let i = "";
|
|
403
|
+
return o && (i = o, o === v.BOARD && s ? d.append(p.BOARD_ID, s) : o !== v.AUTH && a && d.append(p.AUTH_TOKEN, a)), e && d.append(p.THEME, e), r && d.append(p.LANGUAGE, r), d.append(p.CONFIG_TOKEN, t), `${oe(l)}/${i}?${d.toString()}`;
|
|
404
|
+
}, ie = async (e) => {
|
|
405
|
+
const r = await fetch(ne(e.region), {
|
|
403
406
|
method: "POST",
|
|
404
407
|
headers: {
|
|
405
408
|
"Content-Type": "application/json",
|
|
406
409
|
Authorization: `Bearer ${e.publicKey}`,
|
|
407
|
-
mdn: e.merchantDomain ||
|
|
410
|
+
mdn: e.merchantDomain || O
|
|
408
411
|
},
|
|
409
|
-
body: JSON.stringify(
|
|
412
|
+
body: JSON.stringify(ae(e))
|
|
410
413
|
});
|
|
411
414
|
if (!r.ok)
|
|
412
415
|
throw new Error(`${r.status}::${r.statusText}`);
|
|
413
416
|
return r.json();
|
|
414
|
-
},
|
|
417
|
+
}, de = () => {
|
|
415
418
|
const [e, r] = f.useState(""), t = E(), o = async () => {
|
|
416
|
-
var a, s,
|
|
419
|
+
var a, s, l;
|
|
417
420
|
t.onLoadingHandler(!0);
|
|
418
421
|
try {
|
|
419
|
-
let
|
|
420
|
-
if (!
|
|
421
|
-
if (
|
|
422
|
-
|
|
422
|
+
let d = t.configToken, i;
|
|
423
|
+
if (!d) {
|
|
424
|
+
if (i = await ie(t), !i.token) throw new Error("500::Config token is missing");
|
|
425
|
+
d = i.token;
|
|
423
426
|
}
|
|
424
|
-
const m =
|
|
425
|
-
theme: (a =
|
|
426
|
-
language: (s =
|
|
427
|
-
configToken:
|
|
427
|
+
const m = se({
|
|
428
|
+
theme: (a = i == null ? void 0 : i.interface) == null ? void 0 : a.theme,
|
|
429
|
+
language: (s = i == null ? void 0 : i.interface) == null ? void 0 : s.locale,
|
|
430
|
+
configToken: d,
|
|
428
431
|
flow: t.flow,
|
|
429
432
|
token: t.token,
|
|
430
|
-
boardId: t.boardId
|
|
433
|
+
boardId: t.boardId,
|
|
434
|
+
region: t.region
|
|
431
435
|
});
|
|
432
436
|
if (t.mode !== N.PAGE) return r(m);
|
|
433
437
|
window.location.href = m;
|
|
434
|
-
} catch (
|
|
435
|
-
const
|
|
436
|
-
(
|
|
438
|
+
} catch (d) {
|
|
439
|
+
const i = new te(d);
|
|
440
|
+
(l = t.onError) == null || l.call(t, i.getClientError()), t.onLoadingHandler(!1);
|
|
437
441
|
}
|
|
438
442
|
};
|
|
439
443
|
return f.useEffect(() => {
|
|
440
444
|
o();
|
|
441
445
|
}, []), { connectLink: e };
|
|
442
|
-
},
|
|
446
|
+
}, le = () => {
|
|
443
447
|
const { onSuccess: e, onClose: r, onError: t, onReady: o, onLoaded: a } = E(), s = f.useCallback(
|
|
444
|
-
async (
|
|
445
|
-
if (
|
|
446
|
-
const { data:
|
|
447
|
-
switch (
|
|
448
|
-
case
|
|
448
|
+
async (l) => {
|
|
449
|
+
if (l.origin !== O) return;
|
|
450
|
+
const { data: d, event: i } = l.data;
|
|
451
|
+
switch (i) {
|
|
452
|
+
case u.ON_CLOSE:
|
|
449
453
|
r == null || r();
|
|
450
454
|
break;
|
|
451
|
-
case
|
|
452
|
-
t == null || t(
|
|
455
|
+
case u.ON_ERROR:
|
|
456
|
+
t == null || t(d);
|
|
453
457
|
break;
|
|
454
|
-
case
|
|
455
|
-
e == null || e(
|
|
458
|
+
case u.ON_SUCCESS:
|
|
459
|
+
e == null || e(d);
|
|
456
460
|
break;
|
|
457
|
-
case
|
|
461
|
+
case u.ON_LOADED:
|
|
458
462
|
a();
|
|
459
463
|
break;
|
|
460
|
-
case
|
|
464
|
+
case u.ON_READY:
|
|
461
465
|
o == null || o();
|
|
462
466
|
break;
|
|
463
467
|
}
|
|
@@ -467,9 +471,9 @@ const Q = (e = "tap-connect-sdk-element") => {
|
|
|
467
471
|
f.useEffect(() => (window.addEventListener("message", s, !1), () => {
|
|
468
472
|
window.removeEventListener("message", s);
|
|
469
473
|
}), [s]);
|
|
470
|
-
},
|
|
471
|
-
const { connectLink: e } =
|
|
472
|
-
return
|
|
474
|
+
}, ce = () => {
|
|
475
|
+
const { connectLink: e } = de();
|
|
476
|
+
return le(), /* @__PURE__ */ n(
|
|
473
477
|
"div",
|
|
474
478
|
{
|
|
475
479
|
id: "tap-connect-main-container",
|
|
@@ -484,25 +488,25 @@ const Q = (e = "tap-connect-sdk-element") => {
|
|
|
484
488
|
width: "100%",
|
|
485
489
|
height: "100%"
|
|
486
490
|
},
|
|
487
|
-
children: /* @__PURE__ */ n(
|
|
491
|
+
children: /* @__PURE__ */ n(q, { src: e })
|
|
488
492
|
}
|
|
489
493
|
);
|
|
490
|
-
},
|
|
491
|
-
var
|
|
492
|
-
|
|
493
|
-
const
|
|
494
|
-
const t =
|
|
495
|
-
return o.render(/* @__PURE__ */ n(
|
|
494
|
+
}, ue = (e) => /* @__PURE__ */ n($, { props: e, children: e.open && /* @__PURE__ */ n(ce, {}) }), pe = f.memo(ue);
|
|
495
|
+
var L, I = G;
|
|
496
|
+
L = I.createRoot, I.hydrateRoot;
|
|
497
|
+
const ye = (e, r) => {
|
|
498
|
+
const t = re(e), o = L(t);
|
|
499
|
+
return o.render(/* @__PURE__ */ n(pe, { ...r })), { unmount: () => o.unmount() };
|
|
496
500
|
};
|
|
497
501
|
export {
|
|
498
|
-
|
|
502
|
+
T as ConnectDialogEdgeFormat,
|
|
499
503
|
_ as ConnectDialogTransition,
|
|
500
|
-
|
|
504
|
+
pe as ConnectElement,
|
|
501
505
|
v as ConnectFlows,
|
|
502
|
-
|
|
506
|
+
R as ConnectLanguage,
|
|
503
507
|
N as ConnectMode,
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
+
P as ConnectRegions,
|
|
509
|
+
B as ConnectScope,
|
|
510
|
+
x as ConnectTheme,
|
|
511
|
+
ye as renderConnectElement
|
|
508
512
|
};
|