import{An as e,D as t,F as n,Ht as r,It as i,L as a,Lt as o,N as s,Nn as c,On as l,Qt as u,Rt as d,_ as f,_n as p,an as m,bn as h,en as g,g as _,jn as v,mn as y,nn as b,on as x,rn as S,tn as C,vn as w,vt as T,wn as E}from"./app-4kCgdoJR.js";import{t as D}from"./AdminLayout-DEe0k-dp.js";var O={class:`px-0 pt-6 pb-0 sm:px-6 sm:py-8 lg:px-8`},k={class:`col-span-full flex gap-x-8 gap-y-4`},A={class:`col-span-6 sm:col-span-3`},j={class:`col-span-6 sm:col-span-3`},M={key:0,class:`col-span-full flex flex-col gap-4 rounded-md bg-gray-100 p-4 dark:bg-gray-800`},N={class:`col-span-full`},P={class:`col-span-full`},F={class:`col-span-full`},I={class:`col-span-full`},L={class:`col-span-full`},R={class:`text-mute mt-1 text-xs`},z=Object.assign({layout:D},{__name:`Payment`,props:{current:Object,payment_methods:Array},setup(D){let{t:z}=d({}),B=D,V=l([{label:z(`General Settings`),route:`settings.index`,icon:`settings`},{label:z(`Mail Settings`),route:`settings.mail`,icon:`envelope`},{label:z(`Payment Settings`),route:`settings.payment`,icon:`dollar`},{label:z(`Scale Barcode Settings`),route:`settings.barcode`,icon:`scale`}]);o().has(`settings.pos`)&&V.value.push({label:z(`POS Settings`),route:`settings.pos`,icon:`pos`}),o().has(`shop.settings`)&&V.value.push({label:z(`Shop Settings`),route:`shop.settings`,icon:`shop`,external:!0});let H=r({gateway:B.current?.gateway||null,default_currency:B.current?.default_currency||`USD`,stripe_terminal:B.current?.stripe_terminal==1||!1,static_payment_methods:B.current?.static_payment_methods?B.current.static_payment_methods.join(`
`):``,services:{...B.current?.services,paypal:{enabled:B.current?.services?.paypal?.enabled==1,client_id:B.current?.services?.paypal?.client_id||null,secret:B.current?.services?.paypal?.secret||null,fixed:B.current?.services?.paypal?.fixed||null,same_country:B.current?.services?.paypal?.same_country||null,other_countries:B.current?.services?.paypal?.other_countries||null},stripe:{key:B.current?.services?.stripe?.key||null,secret:B.current?.services?.stripe?.secret||null,fixed:B.current?.services?.stripe?.fixed||null,same_country:B.current?.services?.stripe?.same_country||null,other_countries:B.current?.services?.stripe?.other_countries||null},paymes:{public_key:B.current?.services?.paymes?.public_key||null,secret_key:B.current?.services?.paymes?.secret_key||null},authorize:{login:B.current?.services?.authorize?.login||null,transaction_key:B.current?.services?.authorize?.transaction_key||null}}});y(()=>{Object.keys(B.payment_methods).forEach(e=>{Object.keys(B.payment_methods[e].fields).map(t=>{W(H,B.payment_methods[e].fields[t].config,U(B.current,B.payment_methods[e].fields[t].config)||null)})})});function U(e,t){return t.split(`.`).reduce((e,t)=>e&&e[t]!==`undefined`?e[t]:void 0,e)}function W(e,t,n){let r=t.split(`.`),i=e;for(let e=0;e<r.length-1;e++){let t=r[e];(!i[t]||typeof i[t]!=`object`)&&(i[t]={}),i=i[t]}i[r[r.length-1]]=n,e[t]=n}let G=l(H.static_payment_methods||``);function K(){H.transform(e=>({...e,static_payment_methods:G.value.split(`
`).map(e=>e.trim()).filter(Boolean)})).post(o(`settings.payment.store`))}return(r,o)=>{let l=h(`Head`);return p(),S(u,null,[x(l,null,{default:E(()=>[g(`title`,null,c(r.$t(`Payment Settings`)),1)]),_:1}),x(e(f),{links:V.value},null,8,[`links`]),g(`div`,O,[x(e(T),{onSubmitted:K},{title:E(()=>[m(c(r.$t(`Payment Settings`)),1)]),description:E(()=>[m(c(r.$t(`Please configure the payment settings.`)),1)]),form:E(()=>[g(`div`,k,[x(e(s),{id:`paypal-enabled`,label:r.$t(`Enable PayPal Payments`),checked:e(H).services.paypal.enabled,"onUpdate:checked":o[0]||=t=>e(H).services.paypal.enabled=t,error:e(H).errors.services?.paypal?.enabled},null,8,[`label`,`checked`,`error`]),x(e(s),{id:`stripe-terminal`,label:r.$t(`Enable Stripe Terminal`),checked:e(H).stripe_terminal,"onUpdate:checked":o[1]||=t=>e(H).stripe_terminal=t,error:e(H).errors.stripe_terminal},null,8,[`label`,`checked`,`error`])]),g(`div`,A,[x(e(t),{modelValue:e(H).default_currency,"onUpdate:modelValue":o[2]||=t=>e(H).default_currency=t,error:e(H).errors.default_currency,label:r.$t(`Default Currency`)},null,8,[`modelValue`,`error`,`label`])]),g(`div`,j,[x(e(a),{json:!0,id:`gateway`,searchable:!1,label:r.$t(`Credit Card Gateway`),modelValue:e(H).gateway,"onUpdate:modelValue":o[3]||=t=>e(H).gateway=t,error:e(H).errors.gateway,suggestions:[{value:null,label:r.$t(`Disabled`)},{value:`PayPal Rest`,label:`PayPal Rest`},{value:`Stripe`,label:`Stripe`},...Object.keys(D.payment_methods)?.map(e=>({value:e,label:D.payment_methods[e].name}))]},null,8,[`label`,`modelValue`,`error`,`suggestions`])]),D.payment_methods[e(H).gateway]?(p(),S(`div`,M,[(p(!0),S(u,null,w(D.payment_methods[e(H).gateway].fields,(n,r)=>(p(),S(`div`,{key:r},[n.type==`checkbox`?(p(),C(e(s),{key:0,id:n.config,checked:e(H)[n.config]==1,"onUpdate:checked":t=>W(e(H),n.config,+!!t),label:n.label||r.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase()),error:e(H).errors[n.config]?e(H).errors[n.config].replace(`services.`,``).replaceAll(`.`,` `):null},null,8,[`id`,`checked`,`onUpdate:checked`,`label`,`error`])):(p(),C(e(t),{key:1,modelValue:e(H)[n.config],"onUpdate:modelValue":t=>e(H)[n.config]=t,onChange:t=>W(e(H),n.config,t.target.value),label:n.label||r.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase()),error:e(H).errors[n.config]?e(H).errors[n.config].replace(`services.`,``).replaceAll(`.`,` `):null},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`,`label`,`error`]))]))),128))])):b(``,!0),e(H).services.paypal.enabled||e(H).gateway==`PayPal Rest`?(p(),S(u,{key:1},[g(`div`,N,[x(e(t),{label:r.$t(`PayPal Client Id`),modelValue:e(H).services.paypal.client_id,"onUpdate:modelValue":o[4]||=t=>e(H).services.paypal.client_id=t,error:e(H).errors[`services.paypal.client_id`]?e(H).errors[`services.paypal.client_id`].replace(`services.`,``).replaceAll(`.`,` `):null},null,8,[`label`,`modelValue`,`error`])]),g(`div`,P,[x(e(t),{label:r.$t(`PayPal Secret`),modelValue:e(H).services.paypal.secret,"onUpdate:modelValue":o[5]||=t=>e(H).services.paypal.secret=t,error:e(H).errors[`services.paypal.secret`]?e(H).errors[`services.paypal.secret`].replace(`services.`,``).replaceAll(`.`,` `):null},null,8,[`label`,`modelValue`,`error`])])],64)):b(``,!0),e(H).stripe_terminal||e(H).gateway==`Stripe`?(p(),S(u,{key:2},[g(`div`,F,[x(e(t),{label:r.$t(`Stripe Publishable Key`),modelValue:e(H).services.stripe.key,"onUpdate:modelValue":o[6]||=t=>e(H).services.stripe.key=t,error:e(H).errors[`services.stripe.key`]?e(H).errors[`services.stripe.key`].replace(`services.`,``).replaceAll(`.`,` `):null},null,8,[`label`,`modelValue`,`error`])]),g(`div`,I,[x(e(t),{label:r.$t(`Stripe Secret Key`),modelValue:e(H).services.stripe.secret,"onUpdate:modelValue":o[7]||=t=>e(H).services.stripe.secret=t,error:e(H).errors[`services.stripe.secret`]?e(H).errors[`services.stripe.secret`].replace(`services.`,``).replaceAll(`.`,` `):null},null,8,[`label`,`modelValue`,`error`])])],64)):b(``,!0),g(`div`,L,[x(e(_),{rows:`3`,modelValue:G.value,"onUpdate:modelValue":o[8]||=e=>G.value=e,label:r.$t(`Payment Methods`),error:e(H).errors.static_payment_methods,placeholder:r.$t(`Enter payment methods, one per line`)},null,8,[`modelValue`,`label`,`error`,`placeholder`]),g(`p`,R,c(r.$t(`Enter one method per line. These will appear in the payment method dropdown.`)),1)])]),actions:E(()=>[x(e(i),{on:e(H).recentlySuccessful,class:`me-3`},{default:E(()=>[m(c(r.$t(`Saved.`)),1)]),_:1},8,[`on`]),x(e(n),{class:v({"opacity-25":e(H).processing}),loading:e(H).processing},{default:E(()=>[m(c(r.$t(`Save`)),1)]),_:1},8,[`class`,`loading`])]),_:1})])],64)}}});export{z as default};