Files
portal_v3/api-sandbox/_old/sdk/js/afssdk.js
equippedcoding-master e2c98790b2 initial commit
2025-09-17 09:37:06 -05:00

1 line
26 KiB
JavaScript

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):e.AFSSdk=n()}(this,(function(){let e=function(e,n){"use strict";var t={timeout:3e4,jsonpCallback:"callback",jsonpCallbackFunction:null};function r(e){try{delete window[e]}catch(n){window[e]=void 0}}function o(e){var n=document.getElementById(e);n&&document.getElementsByTagName("head")[0].removeChild(n)}return function(e){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],s=e,a=n.timeout||t.timeout,i=n.jsonpCallback||t.jsonpCallback,l=void 0;return new Promise((function(t,c){var u=n.jsonpCallbackFunction||"jsonp_"+Date.now()+"_"+Math.ceil(1e5*Math.random()),d=i+"_"+u;window[u]=function(e){t({ok:!0,json:function(){return Promise.resolve(e)}}),l&&clearTimeout(l),o(d),r(u)},s+=-1===s.indexOf("?")?"?":"&";var p=document.createElement("script");p.setAttribute("src",""+s+i+"="+u),n.charset&&p.setAttribute("charset",n.charset),n.nonce&&p.setAttribute("nonce",n.nonce),n.referrerPolicy&&p.setAttribute("referrerPolicy",n.referrerPolicy),p.id=d,document.getElementsByTagName("head")[0].appendChild(p),l=setTimeout((function(){c(new Error("JSONP request to "+e+" timed out")),r(u),o(d),window[u]=function(){r(u)}}),a),p.onerror=function(){c(new Error("JSONP request to "+e+" failed")),r(u),o(d),l&&clearTimeout(l)}}))}}(),n=null,t=(function(){function n(){return"\n <style>\n \n \n \n .payment-container {\n \n }\n .paypal-button-container {\n border-radius: 5px;\n background-color: #FFFFFF; \n padding: 20px;\n max-width: 760px;\n width: 100%;\n margin: 0 auto;\n }\n .card_container {\n border-radius: 5px;\n background-color: #FFFFFF;\n max-width: 760px;\n width: 100%;\n margin: 0 auto;\n }\n .card_field{\n width: 100%;\n padding: 12px;\n border: 1px solid #ccc;\n border-radius: 4px;\n box-sizing: border-box;\n margin-top: 6px;\n margin-bottom: 16px;\n resize: vertical;\n height:40px;\n background:white;\n font-size:17px;\n color:#3a3a3a;\n font-family:helvetica, tahoma, calibri, sans-serif;\n }\n .card_field_50{\n width: 50%;\n padding: 12px;\n border: 1px solid #ccc;\n border-radius: 4px;\n box-sizing: border-box;\n margin-top: 6px;\n margin-bottom: 16px;\n resize: vertical;\n height:40px;\n background:white;\n font-size:17px;\n color:#3a3a3a;\n font-family:helvetica, tahoma, calibri, sans-serif;\n }\n .card_field_75{\n width: 75%;\n padding: 12px;\n border: 1px solid #ccc;\n border-radius: 4px;\n box-sizing: border-box;\n margin-top: 6px;\n margin-bottom: 16px;\n resize: vertical;\n height:40px;\n background:white;\n font-size:17px;\n color:#3a3a3a;\n font-family:helvetica, tahoma, calibri, sans-serif;\n }\n \n input[type=text], select, textarea {\n width: 100%;\n padding: 12px;\n border: 1px solid #ccc;\n border-radius: 4px;\n box-sizing: border-box;\n margin-top: 6px;\n margin-bottom: 16px;\n resize: vertical;\n height:40px;\n background:white;\n font-size:17px;\n color:#3a3a3a;\n font-family:helvetica, tahoma, calibri, sans-serif;\n }\n input[type=submit] {\n background-color: #4CAF50;\n color: white;\n padding: 12px 20px;\n border: none;\n border-radius: 4px;\n cursor: pointer;\n }\n .message_container {\n border-radius: 5px;\n background:#FFFFFF;\n font-size:13px;\n font-family:monospace;\n padding: 20px;\n }\n #loading {\n width: 100%;\n height: 100%;\n top: 0;\n left: 0;\n position: fixed;\n display: block;\n opacity: 0.7;\n background-color: #fff;\n z-index: 99;\n text-align: center;\n }\n #loading-image {\n position: absolute;\n z-index: 15;\n top: 50%;\n left: 50%;\n margin: -100px 0 0 -150px;\n }\n .spinner {\n position: fixed;\n top: 50%;\n left: 50%;\n margin-left: -50px; /* half width of the spinner gif */\n margin-top: -50px; /* half height of the spinner gif */\n text-align:center;\n z-index:1234;\n overflow: auto;\n width: 100px; /* width of the spinner gif */\n height: 102px; /* height of the spinner gif +2px to fix IE8 issue */\n }\n .button_container {\n display: flex;\n justify-content: center;\n }\n .Pbutton:hover {\n background-color: powderblue;\n }\n .Pbutton {\n width:229px;\n height:49px;\n background:lightblue;\n border:1px dotted black;\n font-size:17px;\n color:#3a3a3a;\n padding: 12px 20px;\n border-radius: 4px;\n cursor: pointer;\n margin: 0 auto;\n }\n .btn_small{\n width:130px;\n height:39px;\n background:lightblue;\n border:1px dotted black;\n font-size:14px;\n color:#3a3a3a;\n }\n .btn_small:hover {\n background-color: powderblue;\n }\n \n \n \n \n \n \n \n \n \n </style>\n \n \n "}function t(n){return function(t){return e(n.pay.service_request_url+"?"+new URLSearchParams({type:"capture_order",orderID:t.orderId}),{method:"get"}).then((e=>e.json())).catch((e=>{console.log(e)})).then((e=>{let t=n.options;e.purchase_units[0].payments.captures[0].amount.value;var r=t.email,o=t.name;null!=r&&null!=r&&""!=r||(r="_none_"),null!=o&&null!=o&&""!=o||(o="_none_");var s={orderData:e,values:n.options.values,options:n.options,processor_data:e,opts:t};const a=Array.isArray(e.details)&&e.details[0];if(a){var i=t.charge_failure_message;return a.description&&(i+="\n\n"+a.description),e.debug_id&&(i+=" ("+e.debug_id+")"),t.error_callback(e,a),i}var l;null!=(l=document.getElementById("paypal-button-container"))&&(l.innerHTML=""),n.callbacks.success_callback(s);let c=n.callbacks.success_content(s);const u=new bootstrap.Modal("#modal_donation_dialog_success",{});$("#dialog_container_success").empty(),$("#dialog_container_success").append(c),setTimeout((function(){u.show(),n.app.overlay(!1),document.getElementById(n.options.onSubmit.id).disabled=!1}),2e3)})).catch((e=>{console.error(e)}))}}function r(e){return{cardholderName:e.options.process.name,billingAddress:{streetAddress:e.options.billingAddressEnabled?document.getElementById("card-billing-address-street").value:"",extendedAddress:e.options.billingAddressEnabled?document.getElementById("card-billing-address-unit").value:"",region:e.options.billingAddressEnabled?document.getElementById("card-billing-address-state").value:"",locality:e.options.billingAddressEnabled?document.getElementById("card-billing-address-city").value:"",postalCode:document.getElementById("card-billing-address-zip").value,countryCodeAlpha2:"US"}}}function o(e){return function(n){var t=document.getElementById("payment-status-message-title");t&&(t.innerHTML=e.options.paypal_error_message,t.style="color:red"),e.callbacks.error_callback(n),e.app.overlay(!1),console.log(n)}}}(),class{constructor(e,n,t){let r=this;r.directPaymentInstance=n,r.processor=e,r.managed_domain=t,r.service_request_url="",r.service_request_post_url="",r.service_request_get_url="";let o=r.managed_domain.Address+":"+r.processor.json.service_port+"/"+r.processor.json.service_end_point;r.service_request_url=o,r.service_request_get_url=o,r.service_request_post_url=r.managed_domain.Address+":"+r.processor.json.service_port}getProcessorConfiguration(){return this.processor}getSubscriptions(n,t){!async function(n,t,r){e(r.service_request_url+"?"+new URLSearchParams({type:"config",data:JSON.stringify(n)}),{method:"get",headers:{"Content-Type":"application/json"}}).then((e=>e.json())).then((e=>{r.subscription_data=e,t(e),e.prices.forEach((e=>{}))})).catch((e=>{console.error("Error:",e),t(e)}))}(n,t,this)}createMembershipTier(e,n){!function(e,n,t){let r=t.subscription_data;for(let t=0;t<r.prices.length;t++){let o={};const s=t,a=r.prices[s],i=a.unit_amount/100;a.lookup_key==e.lookup_key&&($(e.label_price).text(`$${i}`),$(e.label_name).text(a.product.name),$(e.onclick).on("click",(function(e){e.preventDefault(),o.label_price=a.unit_amount/100,o.label=a.product.name,o.transactions={stripe:{price:a}},null!=n&&n(o)})))}}(e,n,this)}createCustomer(n,t){!async function(n,t,r){e(r.service_request_url+"?"+new URLSearchParams({type:"create-customer",data:JSON.stringify(n)}),{method:"get",headers:{"Content-Type":"application/json"}}).then((e=>e.json())).then((e=>{t(e)})).catch((e=>{console.log(e),t(!1,e)}))}(n,t,this)}createSubscription(n,t){!async function(n,t,r){console.log(n);let o={priceId:n.json_data.transactions.stripe.price.id,customer:n.json_data.transactions.stripe.customer.id};e(r.service_request_url+"?"+new URLSearchParams({type:"create-subscription",data:JSON.stringify(o)}),{method:"get",headers:{"Content-Type":"application/json"}}).then((e=>e.json())).then((e=>{t(e)})).catch((e=>{console.error("Error:",e),t(e)}))}(n,t,this)}setupView(e,n,t,r,o){return function(e,n,t,r,o,s){let a=t.factory.view();return s.view=a,a.newSubView({id:"payment_details",init:!0,body:t.extra.config.html.stripe_subscription_payment_details,listener:function(){console.log(s);const a=s.processor.json.client_id,i=Stripe(a);let l=s.initialize_payment_details(i,e,n,t);setTimeout((()=>{$("#stripe_start_membership_id").css("display","block"),$("#stripe_start_membership_id").on("click",(function(a){a.preventDefault(),null!=r&&null!=r&&r(l),s.startMemebership(i,l,e,n,t,o)}))}),1e3)}}),a}(e,n,t,r,o,this)}startMemebership(e,n,t,r,o,s){!async function(e,n,t,r,o,s,a){const i=t.clientSecret;e.confirmCardPayment(i,{payment_method:{card:n.cardElement,billing_details:{name:r.firstname+" "+r.lastname}}}).then((e=>{e.error?s(e.error):s(e,t,r)}))}(e,n,t,r,0,s)}initialize_payment_details(e,n,t,r){return function(e,n,t,r,o){const s={theme:"flat",variables:{colorPrimaryText:"#262626"}},a=e.elements({clientSecret:n.clientSecret,appearance:s}),i=a.create("card"),l={mode:"billing"};return a.create("address",l).mount("#address-element"),i.mount("#payment-element"),{cardElement:i,stripe:e}}(e,n)}initializeSubscription(e){!async function(){}()}check(n){!async function(n,t){let r={checking:!0};console.log(t.service_request_url),e(t.service_request_url+"?"+new URLSearchParams({type:"check",data:JSON.stringify(r)}),{method:"get"}).then((e=>e.json())).then((e=>{console.log(e),n(e)})).catch((e=>{console.error(e),n(!1,e)}))}(n,this)}account(){document.addEventListener("DOMContentLoaded",(async()=>{const{subscriptions:e}=await fetch("/subscriptions").then((e=>e.json()));document.querySelector("#subscriptions").innerHTML=e.data.map((e=>{let n=e.default_payment_method?.card?.last4||"";return`\n <hr>\n <h4>\n <a href="https://dashboard.stripe.com/test/subscriptions/${e.id}">\n ${e.id}\n </a>\n </h4>\n \n <p>\n Status: ${e.status}\n </p>\n \n <p>\n Card last4: ${n}\n </p>\n <small>If the last4 is blank, ensure webhooks are being handled. The default payment method is set in the webhook handler.</small>\n \n <p>\n Current period end: ${new Date(1e3*e.current_period_end)}\n </p>\n \n \x3c!--<a href="change-payment-method.html?subscription=${e.id}"> Update payment method </a><br />\n <a href="change-plan.html?subscription=${e.id}"> Change plan </a><br /> --\x3e\n <a href="cancel.html?subscription=${e.id}"> Cancel </a><br />\n `})).join("<br />")}))}cancel(){document.addEventListener("DOMContentLoaded",(async()=>{const e=new URLSearchParams(window.location.search).get("subscription");document.querySelector("#cancel-btn").addEventListener("click",(async t=>{t.preventDefault(),n("Cancelling subscription...");const{subscription:r}=await fetch("/cancel-subscription",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({subscriptionId:e})}).then((e=>e.json()));n(`Subscription status: ${r.status}`),n("Redirecting back to account in 7s."),setTimeout((()=>{window.location.href="account.html"}),7e3)}));const n=e=>{document.querySelector("#messages").innerHTML+="<br>"+e}}))}subscribe(){!function(n){const t=e=>{document.querySelector("#messages").innerHTML+="<br>"+e};let r,o,s={};e(n.service_request_url+"?"+new URLSearchParams({type:"config",data:JSON.stringify(s)}),{method:"get"}).then((e=>e.json())).then((e=>{r=Stripe(e.publishableKey);const n=r.elements();o=n.create("card"),o.mount("#card-element")})).catch((e=>{console.log(e)})),window.sessionStorage.getItem("subscriptionId");const a=window.sessionStorage.getItem("clientSecret");document.querySelector("#subscribe-form").addEventListener("submit",(async e=>{e.preventDefault();const n=document.getElementById("name");r.confirmCardPayment(a,{payment_method:{card:o,billing_details:{name:n.value}}}).then((e=>{e.error?t(`Payment failed: ${e.error.message}`):(t("Success! Redirecting to your account."),window.location.href="/account.html")}))}))}(this)}prices(){_stripe_prices(this)}standalone(n,t){!async function(n,t,r){let o={},s=null;e(r.service_request_url+"?"+new URLSearchParams({type:"keys",data:JSON.stringify(o)}),{method:"get"}).then((e=>e.json())).then((e=>{s=Stripe(e.keys.client_id),t(s)})).catch((e=>{console.log(e),t(null,null)}))}(0,t,this)}singleCharge(n,t,r,o,s){!async function(n,t,r,o,s,a){let i={};e(a.service_request_url+"?"+new URLSearchParams({type:"signle-create-payment-intent",data:JSON.stringify(i)}),{method:"get"}).then((e=>e.json())).then((async e=>{let a=e.clientSecret;if(e.error)return console.log(e),console.log(o),void(null!=o&&null!=o&&o(e));null==n.name&&(n.name=""),null==n.email&&(n.email=""),t(e.paymentIntent,(async function(){const{error:e,paymentIntent:t}=await n.stripe.confirmCardPayment(a,{payment_method:{card:n.card,billing_details:{name:n.name,phone:"713-777-5555",_member_reference_num:n._member_reference_num}},metadata:{}});if(e)return console.log(e),void(null!=s&&null!=s&&s(e));r(t)}))})).catch((e=>{console.error(e)}))}(n,t,r,o,s,this)}}),r=class{constructor(e,n,t,r){this.id=e,this.domain_settings=t,this.managed_domain=r,this.handlers=n,this.handler=this.getHandler(e)}getHandlers(){return this.handlers}getHandler(e){let n=this,t=null;for(const r in n.handlers)if(r==e){t=n.handlers[e];break}return t}setupVariables(e,n){const t=this;let r=t.managed_domain,o=t.domain_settings;for(const s in t.handler.handlers){let a=structuredClone(t.handler.handlers[s]),l=structuredClone(a.variables.schema),c=structuredClone(i(a,o,r));a.variables.schema=[l],a.variables.system=[c],a.variables.client=[n],0==a.alert&&("string"==typeof e&&(e=[e]),a.emails=e),t.handler.handlers[s]=a}}};class o{constructor(e){this.config=e}apicall(e,n,t){const r=this;n.headers.Authorization=`token ${r.config.key}`,async function(){const o=`${r.config.api.url}${e}`;try{const e=await fetch(o,n);if(!e.ok)throw new Error(`Response status: ${e.status}`);const r=await e.json();null!=t&&t(r)}catch(e){console.log(e)}}()}init(){!function(e,n){let t,r=new XMLHttpRequest,o=[];for(t in e)o.push(encodeURIComponent(t)+"="+encodeURIComponent(e[t]));r.open("POST","/portal/admin/core/api/php/request.php",!0),r.setRequestHeader("Content-type","application/x-www-form-urlencoded"),r.onreadystatechange=function(){4==r.readyState&&200==r.status&&n(JSON.parse(r.responseText))},r.send(o.join("&"))}({},(function(){}))}}class s{constructor(e){this.appManager=e,this.configurations=null,this.email_handler=null,this.processor=null,this.current_processor_name="",this.current_processor_object=null,this.stripeProcessor=null,this.paymentsManager=null}initialize(e,t){let r=this;null!=n?n.apicall("/v1/payments/direct_payments",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key_id:e})},(function(e){r.configurations=e,null==e.message||"error"!=e.message?("stripe"==e.processor.json.processor&&(r.processor=r._init_stripe(),r.current_processor_name=e.processor.processor_name),e.processor.json.processor,e.processor.json.processor,null==r.processor&&console.log("No processor selected!"),r.paymentsManager=new a(e.processor),null!=t&&t()):console.log("Error no direct payment")})):console.log("Appfactory Studio: SDK has not been initialized!")}initializeSubscription(e,n){let t=this;console.log(t.configurations.direct_payment.json.configuration.recurring);let r=t.paymentsManager.getProcessorGroup(e,t.configurations.direct_payment.json.configuration.recurring),o=t.paymentsManager.getLookupKeys(r);console.log(o),t.processor.getSubscriptions(o,n,t)}initializeTier(e,n){this.processor.createMembershipTier(e,n,this)}setupView(e,n,t,r,o){return this.processor.setupView(e,n,t,r,o,this)}createCustomer(e,n){this.processor.createCustomer(e,n,this)}setupSubscription(e,n){this.processor.createSubscription(e,n,this)}setEmailHandler(e){this.email_handler=e}getDirectPayment(){return this.configurations.direct_payment}saveEmailHandlersForPayment(e,n){let t=this;console.log({direct_payment:t.getDirectPayment().json,mail_handlers:t.email_handler.handler.handlers,payment_intent:e}),t.appManager.apicall("/v1/payments/save_handler",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({direct_payment:JSON.stringify(t.getDirectPayment().json),mail_handlers:JSON.stringify(t.email_handler.handler.handlers),payment_intent:JSON.stringify(e)})},(function(e){null!=n&&n(e)}))}build(e){!function(e,n,t){n.stripeProcessor.standalone(e,(function(t){const r=t.elements().create("card");r.mount(e.cardElementId),null==e.submitId&&console.log("Please provide on submit button id for paymen component");let o=document.getElementById(e.submitId.split("#")[1]);o.replaceWith(o.cloneNode(!0)),document.querySelector(e.submitId).addEventListener("click",(async o=>{o.preventDefault();let s={success:!0};null!=e.validate&&null!=e.validate&&(s=e.validate()),s.stripe=t,s.card=r,s.mail_handlers=s.mail_handlers,0!=s.success&&n.stripeProcessor.singleCharge(s,(function(e,t){n.stripeProcessor.directPaymentInstance.saveEmailHandlersForPayment(e,(function(){setTimeout((()=>{n.stripeProcessor.createCustomer({reference_num:s.customer[0],email:s.customer[1],payment_intent:e,mail_handlers:s.mail_handlers},(function(e){null!=s.callback&&null!=s.callback&&"function"==typeof s.callback&&s.callback(e),t()}))}),1e3)}))}),(function(n){null!=e.success&&null!=e.success&&(s=e.success(n))}),(function(n){null!=e.error&&null!=e.error&&(s=e.error(n,null))}),(function(n){null!=e.error&&null!=e.error&&(s=e.error(null,n))}))}))}))}(e,this)}useEmailGroup(e,n,t,o){const s=this;let a=structuredClone(s.getDirectPayment().json.mail_handlers),i=s.app.config.managed_domain,l=s.app.config.configurations.domain_settings[0];s.email_handler=new r(e,a,l,i),null==s.email_handler.handler&&console.log(`Error No email group found for ${e}`),s.email_handler.setupVariables(n,t)}_init_stripe(){let e=this;if(null==document.getElementById("stripe_script_tag_id")){const e=document.createElement("script");e.src="https://js.stripe.com/v3/",e.id="stripe_script_tag_id",document.head.appendChild(e)}return e.stripeProcessor=new t(e.configurations.processor,e,e.configurations.managed_domain),e.stripeProcessor}}class a{constructor(e,n){this.processors=[e],this.access=null,this.app=n}setupNewMember(e,n,t,r){let o=this,s=[new Promise(((e,r)=>{$.post(t.extra.url,{get_configuration:!0,category:n},(function(t){t=JSON.parse(t),e(t.configuration[n])}))}))];Promise.all(s).then((n=>{let t=null;for(let r=0;r<n.length;r++){const o=n[r];for(let n=0;n<o.length;n++){const r=o[n];if(r.json.nameid==e){t=r;break}}}o._raw_access=t,o.access=t.json,r(t.json)}))}getGroups(){return this.access.groups}getProcessorGroup(e,n){let t=this,r=t.processors,o=null;for(let t=0;t<n.processors.length;t++){const r=n.processors[t];if(r.name==e){o=r;break}}if(null==o)return o;let s=null;for(let e=0;e<n.subscriptions.length;e++){const t=n.subscriptions[e];if(o.subscription_group==t.name){s=t;break}}let a=null;if(null!=r){console.log(r);for(let e=0;e<r.length;e++){const n=r[e].json;if(n.nameid==o.processor_nameid){a=n;break}}}return t.group={processor_config:a,processor_group:o,subscriptions:s},t.group}getLookupKeys(e){let n=[];for(let t=0;t<e.subscriptions.tiers.length;t++){const r=e.subscriptions.tiers[t];"_none_"!=r.lookup_key&&""!=r.lookup_key&&null!=r.lookup_key&&null!=r.lookup_key&&n.push(r.lookup_key)}return n}getGroupFeature(e,n){let t=null;for(let n=0;n<access_settings.groups.subscriptions.length;n++){const r=access_settings.groups.subscriptions[n];if(r.name==e){t=r;break}}for(let e=0;e<access_settings.groups.authorizations.length;e++){const n=access_settings.groups.authorizations[e];for(let e=0;e<n.apps.length;e++){n.apps[e].features[0]}}return this.access_settings.groups}getTier(e,n){return n.subscriptions.tiers[e]}}function i(e,n,t,r){let o=[],s=n.json;o.push({name:"subscribe_button_link",value:t.Address}),o.push({name:"mysocial_link_threads",value:s.social_media_links.threads}),o.push({name:"mysocial_link_twitch",value:s.social_media_links.twitch}),o.push({name:"mysocial_link_youtube",value:s.social_media_links.youtube}),o.push({name:"mysocial_link_discord",value:s.social_media_links.discord}),o.push({name:"mysocial_link_pinterest",value:s.social_media_links.pinterest}),o.push({name:"mysocial_link_tiktok",value:s.social_media_links.tiktok}),o.push({name:"mysocial_link_linkedin",value:s.social_media_links.linkedin}),o.push({name:"mysocial_link_instagram",value:s.social_media_links.instagram}),o.push({name:"mysocial_link_twitter",value:s.social_media_links.twitter}),o.push({name:"mysocial_link_facebook",value:s.social_media_links.facebook}),o.push({name:"mycopyright_short",value:s.company.copyright_short}),o.push({name:"mycopyright_long",value:s.company.copyright_long}),o.push({name:"mycompany_name",value:s.company.name}),o.push({name:"mycompany_address",value:s.company.address}),o.push({name:"mycompany_phone",value:s.company.phone});let a=s.brand.logos.logo1;o.push({name:"mybrand_logo1",value:null==a||null==a?"":a.url});let i=s.brand.logos.logo2;o.push({name:"mybrand_logo2",value:null==i||null==i?"":i.url});let l=s.brand.logos.logo3;o.push({name:"mybrand_logo3",value:null==l||null==l?"":l.url}),o.push({name:"mybrand_color_1",value:s.brand.colors.primary_color_1}),o.push({name:"mybrand_color_2",value:s.brand.colors.primary_color_2}),o.push({name:"mybrand_color_3",value:s.brand.colors.primary_color_3}),o.push({name:"mybrand_favicon1",value:s.brand.favicons.favicon1}),o.push({name:"domain",value:t.Address}),o.push({name:"domain_dashboard",value:t.Address+"/portal/admin"}),o.push({name:"myheader_image_url",value:t.Address+"/assets/logo.png"}),o.push({name:"logo",value:t.Address+"/assets/logo.png"}),o.push({name:"logo2",value:t.Address+"/assets/logo2.png"}),o.push({name:"logo3",value:t.Address+"/assets/logo3.png"}),o.push({name:"dollar_amount",value:"",type:"payments"}),o.push({name:"card_type",value:"",type:"payments"}),o.push({name:"last4",value:"",type:"payments"}),o.push({name:"currency",value:"",type:"payments"}),o.push({name:"receipt_url",value:"",type:"payments"}),null!=r&&(o.push({name:"email_from",value:r.from}),o.push({name:"email_subject",value:r.subject}),null!=r.integration&&(o.push({name:"email_domain",value:r.integration.domain}),o.push({name:"email_server",value:r.integration.server})));for(let e=0;e<o.length;e++){o[e];null==o[e].value&&(o[e].value="")}return o}return{InitializeClientSDK:function(e,t){!async function(){const r=`https://api.appfactory.studio/v1/core/initialize_client_sdk?key=${e}`;try{let e={method:"GET"};const s=await fetch(r,e);if(!s.ok)throw new Error(`Response status: ${s.status}`);const a=await s.json();if(null!=t){if(0==a._authorized)throw new Error("AFS SDK NOT initialized!");n=new o(a),localStorage.setItem("afssdk",JSON.stringify(a)),t(a)}}catch(e){console.log(e)}}()},DirectPayments:s,EmailHandler:r,payments:{createNewDirectPayment:function(){return new s(n)}},useEmailGroup:function(e,n,t,o,s){let a=structuredClone(o);console.log(s.extra);let i=s.extra.config.managed_domain,l=s.extra.config.configurations.domain_settings[0],c=new r(e,a,l,i);return null==c.handler&&console.log(`Error No email group found for ${e}`),c.setupVariables(n,t),c}}}));