| 1 |
import{g as q,i as J,aH as Q,H as W,a as X,j as t,_ as l,h as o,R as Y,m as f,dr as $,cR as x,cV as u,f as h,bG as F}from"./main-634.js";import{j as K,C as Z}from"./bf-25-81.js";import{c as S,p as B}from"./bf-305-464.js";import{t as ee}from"./bf-676-386.js";import{F as y}from"./bf-767-388.js";import{A as D}from"./bf-710-385.js";import{F as j}from"./bf-457-387.js";import{S as I}from"./bf-982-242.js";import{C as P}from"./bf-297-103.js";import{S as te}from"./bf-26-460.js";import"./bf-638-271.js";import"./bf-247-269.js";import"./bf-534-247.js";import"./bf-299-245.js";import"./bf-497-246.js";import"./bf-641-107.js";import"./bf-400-72.js";import"./bf-438-114.js";function Ae(){var C,M,N,_;const{fieldKey:i}=q(),[m,g]=J(Q),n=W(m[i]),U=Object.entries(m),w=(n==null?void 0:n.payType)==="subscription",b=((C=n.config)==null?void 0:C.amountType)==="dynamic",{css:a}=X(),A=(e,s)=>{var c;if(s?f(n,e,s):$(n,e),e==="config->amount"){const d=((c=S.find(p=>p.code===n.config.options.currency))==null?void 0:c.minAmount)||0;d&&Number(s)<d?x({fieldKey:i,errorKey:"stripeAmountMin",errorMsg:l(`Stripe Minimum Amount is ${d}`),errorUrl:`field-settings/${i}`}):(u(i,"stripeAmountMin"),u(i,"stripeAmountMissing"))}else e==="config->amountFld"&&(s?u(i,"stripeAmountFldMissing"):x({fieldKey:i,errorKey:"stripeAmountFldMissing",errorMsg:l("Stripe Dynamic Amount Field is not Selected"),errorUrl:`field-settings/${i}`}));const r=h(m,d=>{d[i]=n});g(r),F({event:`${ne[e]} to ${s}: ${n.lbl||i}`,type:`${e}_changed`,state:{fields:r,fldKey:i}})};function v(e){if(!e||e.length===0)return S;const r=B.filter(p=>e.includes(p.type)).map(p=>p.currency),c=r==null?void 0:r.reduce((p,z)=>p.filter(G=>z.includes(G)));return S.filter(p=>c.includes(p.code))||[]}const H=e=>{var r;if(e){const c=e.split(",");f(n,"config->options->payment_method_types",c);const d=v(c);d.length?(u(i,"stripeCurrencyMissing"),f(n,"config->options->currency",((r=d[0])==null?void 0:r.code)||"")):(x({fieldKey:i,errorKey:"stripeCurrencyMissing",errorMsg:l("Select a valid currency for the selected payment method types"),errorUrl:`field-settings/${i}`}),f(n,"config->options->currency",""))}else $(n,"config->options->payment_method_types"),u(i,"stripeCurrencyMissing"),f(n,"config->options->currency","usd");const s=h(m,c=>{c[i]=n});g(s)},T=e=>{e.target.value?n.config.amountType=e.target.value:delete n.config.amountType,delete n.config.amount,delete n.config.amountFld,n.config.amountType==="dynamic"?(u(i,"stripeAmountMissing"),x({fieldKey:i,errorKey:"stripeAmountFldMissing",errorMsg:l("Stripe Dynamic Amount Field is not Selected"),errorUrl:`field-settings/${i}`})):(u(i,"stripeAmountFldMissing"),x({fieldKey:i,errorKey:"stripeAmountMissing",errorMsg:l("Stripe Fixed Amount is not valid"),errorUrl:`field-settings/${i}`}));const s=h(m,r=>{r[i]=n});g(s),F({event:`Amount Type Changed to "${e.target.value}": ${n.lbl||i}`,type:"set_amount",state:{fields:s,fldKey:i}})},O=()=>U.filter(s=>s[1].typ.match(/^(radio|number|currency)/)).map(s=>t.jsx("option",{value:s[0],children:s[1].adminLbl||s[1].lbl},s[0])),R=()=>V.map(e=>({label:t.jsxs("div",{className:"flx flx-between",children:[t.jsx("span",{className:"btcd-ttl-ellipsis",children:e.currency}),t.jsx("code",{className:"btcd-code",style:{textTransform:"uppercase"},children:e.code})]}),title:`${e.currency} - ${e.code}`,value:e.code})),L=()=>{var e;return(e=B)==null?void 0:e.map(s=>({label:s.name,value:s.type}))};function k(e){n.txt=e.target.value;const s=h(m,r=>{r[i]=n});g(s),F({event:`Stripe button text updated : ${n.txt}`,type:"change_stripe_btn_txt",state:{fields:s,fldKey:i}})}function E(e){n.config.payBtnTxt=e.target.value;const s=h(m,r=>{r[i]=n});g(s),F({event:`Stripe pay button text updated : ${n.config.payBtnTxt}`,type:"change_stripe_pay_btn_txt",state:{fields:s,fldKey:i}})}const V=v(n.config.options.payment_method_types);return t.jsxs("div",{children:[t.jsx(I,{id:"btn-txt-stng",title:l("Button Text"),className:a(y.fieldSection),open:!0,children:t.jsx("div",{className:a(y.placeholder),children:t.jsx(D,{id:"btn-txt","aria-label":"Stripe button text",placeholder:"Type text here...",value:n.txt,changeAction:e=>k(e)})})}),t.jsx(j,{}),t.jsx(I,{id:"pay-btn-txt-stng",title:l("Pay Button Text"),className:a(y.fieldSection),open:!0,children:t.jsx("div",{className:a(y.placeholder),children:t.jsx(D,{id:"pay-btn-txt","aria-label":"Stripe pay button text",placeholder:"Type text here...",value:n.config.payBtnTxt,changeAction:e=>E(e)})})}),t.jsx(j,{}),!w&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:a(o.ml2,o.mr2,o.p1),children:[t.jsx("b",{children:l("Payment Method Type")}),t.jsx(K,{className:"w-10 btcd-paper-drpdwn mt-1 btcd-ttc",options:L(),onChange:e=>H(e),defaultValue:((M=n.config.options)==null?void 0:M.payment_method_types)||[]})]}),t.jsx(j,{}),t.jsx("div",{className:a(o.ml2,o.mr2,o.p1),children:t.jsxs("label",{htmlFor:"currency",children:[t.jsx("b",{children:l("Currency")}),t.jsx(K,{className:"w-10 btcd-paper-drpdwn mt-1",options:R(),onChange:e=>A("config->options->currency",e),defaultValue:(N=n.config.options)==null?void 0:N.currency,largeData:!0,singleSelect:!0})]})}),t.jsx(j,{}),t.jsxs("div",{className:a(o.ml2,o.mr2,o.p1),children:[t.jsxs("b",{className:a(ie.amountType),children:[l("Amount Type"),t.jsx(Z,{children:t.jsx("div",{className:"txt-body",children:t.jsx(Y,{html:ee.amountType})})})]}),t.jsx(P,{id:"amnt-typ-fxd",onChange:T,radio:!0,checked:!b,title:l("Fixed")}),t.jsx(P,{id:"amnt-typ-dynmc",onChange:T,radio:!0,checked:b,title:l("Dynamic"),value:"dynamic"})]}),!b&&t.jsx("div",{className:a(o.ml2,o.mr2,o.p1),children:t.jsx(te,{id:"amnt",className:a(o.mt0),cls:a(y.input),inpType:"number",title:l("Amount"),value:((_=n.config)==null?void 0:_.amount)||"",action:e=>A("config->amount",e.target.value)})}),b&&t.jsxs("div",{className:a(o.ml2,o.mr2,o.p1),children:[t.jsx("b",{children:l("Select Amount Field")}),t.jsxs("select",{"data-testid":"slct-amnt-slct",onChange:e=>A("config->amountFld",e.target.value),name:"amountFld",className:a(y.input),value:n.config.amountFld,children:[t.jsx("option",{value:"",children:l("Select Field")}),O()]})]})]})]})}const ne={payIntegID:"Payment Configuration Changed",planId:"Plan Id Changed",locale:"Language Selected",disableFunding:"Disabled Card",amount:"Amount",amountFld:"Amount Field Selected",shipping:"Shipping Cost",shippingFld:"Shipping Amount Field Selected",tax:"Tax changed",taxFld:"Tax Amount Field Selected",currency:"Currency Selected",description:"Other Description",descFld:"Description Field Selected",layout:"Layout Changed"},ie={amountType:{dy:"flex !important",fw:600,"& .hover-tip":{oy:0}}};export{Ae as default}; |