Current Path : /home2/church/hebrews111.esselwebdesign.com/wp-content/plugins/woocommerce-square/build/ |
Current File : //home2/church/hebrews111.esselwebdesign.com/wp-content/plugins/woocommerce-square/build/index.js |
(()=>{"use strict";const e=window.wc.wcBlocksRegistry,t=window.React,n=window.wp.element,a=window.wc.wcSettings;let o=null;const s=()=>{if(null!==o)return o;const e=(0,a.getSetting)("square_credit_card_data",null);if(!e)throw new Error("Square initialization data is not available");return o={title:e.title||"",applicationId:e.application_id||"",locationId:e.location_id||"",isSandbox:e.is_sandbox||!1,availableCardTypes:e.available_card_types||{},loggingEnabled:e.logging_enabled||!1,generalError:e.general_error||"",showSavedCards:e.show_saved_cards||!1,showSaveOption:e.show_save_option||!1,supports:e.supports||{},isTokenizationForced:e.is_tokenization_forced||!1,paymentTokenNonce:e.payment_token_nonce||"",isDigitalWalletsEnabled:e.is_digital_wallets_enabled||!1,isPayForOrderPage:e.is_pay_for_order_page||!1,recalculateTotalNonce:e.recalculate_totals_nonce||!1,context:e.context||"",ajaxUrl:e.ajax_url||"",paymentRequestNonce:e.payment_request_nonce||"",googlePayColor:e.google_pay_color||"black",applePayColor:e.apple_pay_color||"black",applePayType:e.apple_pay_type||"buy",hideButtonOptions:e.hide_button_options||[]},o},i=(e,t)=>{s().loggingEnabled&&t&&t.logs.push(e)},r=(e,t={logs:[],notices:[]})=>{let n=!1;if(e){const a=["none","cardNumber","expirationDate","cvv","postalCode"];e.length>=1&&e.sort(((e,t)=>a.indexOf(e.field)-a.indexOf(t.field)));for(const a of e)"UNSUPPORTED_CARD_BRAND"===a.type||"VALIDATION_ERROR"===a.type?(t.notices.push(a.message.replace(/CVV/,"CSC")),n=!0):i(a,t)}n||t.notices.push(s().generalError)},l=(e,t="notice")=>{s().loggingEnabled&&("error"===t?console.error(e):console.log(e))},c=(0,n.createContext)(!1),d=({checkoutFormHandler:e,eventRegistration:t,emitResponse:a})=>{const o=(0,n.useContext)(c),{onPaymentSetup:i,onCheckoutAfterProcessingWithError:r,onCheckoutAfterProcessingWithSuccess:l}=t,{getPaymentMethodData:d,createNonce:p,verifyBuyer:u}=e;return((e,t,a,o,i,r)=>{const l=(0,n.useRef)(a);(0,n.useEffect)((()=>{l.current=a}),[a]),(0,n.useEffect)((()=>e((async()=>{const e={type:t.responseTypes.SUCCESS},n={nonce:"",notices:[],logs:[]};if(l.current?.token){const{paymentTokenNonce:e}=s(),t=await fetch(`${wc.wcSettings.ADMIN_URL}admin-ajax.php?action=wc_square_credit_card_get_token_by_id&token_id=${l.current.token}&nonce=${e}`),{success:a,data:o}=await t.json();n.token=a?o:""}else{const e=await i(l.current.card);n.nonce=e.token,e?.details?.card&&e?.details?.billing&&(n.cardData={...e.details.card,...e.details.billing})}const a=n.token||n.nonce;if(a){const e=await r(l.current.payments,a);n.verificationToken=e.verificationToken||"",n.logs=n.logs.concat(e.log||[]),n.errors=n.notices.concat(e.errors||[])}return a||n.logs.length>0?e.meta={paymentMethodData:o(n)}:n.notices.length>0&&(e.type=t.responseTypes.ERROR,e.message=n.notices),e}))),[e,t.responseTypes.SUCCESS,t.responseTypes.ERROR,i,r,o])})(i,a,o,d,p,u),((e,t,a)=>{(0,n.useEffect)((()=>{const n=e=>{let t={type:a.responseTypes.SUCCESS};const{paymentStatus:n,paymentDetails:o}=e.processingResponse;return n===a.responseTypes.ERROR&&o.checkoutNotices&&(t={type:a.responseTypes.ERROR,message:JSON.parse(o.checkoutNotices),messageContext:a.noticeContexts.PAYMENTS,retry:!0}),t},o=e(n),s=t(n);return()=>{o(),s()}}),[e,t,a.noticeContexts.PAYMENTS,a.responseTypes.ERROR,a.responseTypes.SUCCESS])})(r,l,a),null},p="square-credit-card",u="square_credit_card",C=(e,t=!1,a=null)=>{const[o,c]=(0,n.useState)(!1),[d,u]=(0,n.useState)(""),C=(0,n.useMemo)((()=>{const n=t&&!a?"STORE":"CHARGE",o={billingContact:{familyName:e.billingData.last_name||"",givenName:e.billingData.first_name||"",email:e.billingData.email||"",country:e.billingData.country||"",region:e.billingData.state||"",city:e.billingData.city||"",postalCode:e.billingData.postcode||"",phone:e.billingData.phone||"",addressLines:[e.billingData.address_1||"",e.billingData.address_2||""]},intent:n};return"CHARGE"===n&&(o.amount=(e.cartTotal.value/100).toString(),o.currencyCode=e.currency.code),o}),[e.billingData,e.cartTotal.value,e.currency.code,t,a]),g=(0,n.useCallback)((e=>{const{cardData:n={},nonce:o,verificationToken:s,notices:i,logs:r}=e,l={[`wc-${p}-card-type`]:n?.brand||"",[`wc-${p}-last-four`]:n?.last4||"",[`wc-${p}-exp-month`]:n?.expMonth?.toString()||"",[`wc-${p}-exp-year`]:n?.expYear?.toString()||"",[`wc-${p}-payment-postcode`]:n?.postalCode||"",[`wc-${p}-payment-nonce`]:o||"",[`wc-${p}-payment-token`]:a||"",[`wc-${p}-buyer-verification-token`]:s||"",[`wc-${p}-tokenize-payment-method`]:t||!1,"log-data":r.length>0?JSON.stringify(r):"","checkout-notices":i.length>0?JSON.stringify(i):""};return a&&(l.token=a),l}),[d,t,a]),y=(0,n.useCallback)((async e=>a||await e.tokenize()),[a]),m=(0,n.useCallback)((e=>{const t={notices:[],logs:[]};return e&&e.token?t.verificationToken=e.token:(i("Verification token is missing from the Square response",t),l("Verification token is missing from the Square response","error"),r([],t)),t}),[]),h=(0,n.useCallback)((async(e,t)=>{let n;try{return n=await e.verifyBuyer(t,C),m(n)}catch(e){r([e])}return!1}),[C,m]);return{handleInputReceived:(0,n.useCallback)((e=>{if("cardBrandChanged"===e.eventType){const t=e.cardBrand;let n="plain";null!==t&&"unknown"!==t||(n=""),null!==s().availableCardTypes[t]&&(n=s().availableCardTypes[t]),l(`Card brand changed to ${t}`),u(n)}}),[]),isLoaded:o,setLoaded:c,getPostalCode:(0,n.useCallback)((()=>e.billingData.postcode||""),[e.billingData.postcode]),cardType:d,createNonce:y,verifyBuyer:h,getPaymentMethodData:g}},g=e=>{const{children:a,token:o=null,defaults:{postalCode:i=""}}=e,[r,l]=(0,n.useState)(!1),[d,p]=(0,n.useState)(!1),{applicationId:u,locationId:C}=s();return(0,n.useEffect)((()=>{!r&&window.Square&&l(window.Square.payments(u,C))}),[u,C,r]),(0,n.useEffect)((()=>{!r||d||o||(async()=>{const e=await r.card({postalCode:i});p(e)})()}),[r,d,o,i]),r?(0,t.createElement)(c.Provider,{value:{payments:r,card:d,token:o}},a):null},y=()=>{const{card:e}=(0,n.useContext)(c),a=(0,n.useRef)(!1);return(0,n.useEffect)((()=>{e&&(async()=>{e.attach(a.current)})()}),[e]),(0,t.createElement)("div",{ref:a})},m=({billing:e,eventRegistration:n,emitResponse:a,shouldSavePayment:o})=>{const{isTokenizationForced:i}=s(),r=C(e,o||i);return(0,t.createElement)(g,{defaults:{postalCode:r.getPostalCode()}},(0,t.createElement)(y,null),(0,t.createElement)(d,{checkoutFormHandler:r,eventRegistration:n,emitResponse:a}))},h=({RenderedComponent:e,...n})=>(0,t.createElement)(e,{...n}),f={name:u,label:(0,t.createElement)((e=>{const{PaymentMethodLabel:n}=e.components;return(0,t.createElement)(n,{text:s().title})}),null),content:(0,t.createElement)(h,{RenderedComponent:m}),edit:(0,t.createElement)(h,{RenderedComponent:m}),savedTokenComponent:(0,t.createElement)(h,{RenderedComponent:({billing:e,eventRegistration:n,emitResponse:a,token:o})=>{const s=C(e,!1,o);return(0,t.createElement)(g,{token:o,defaults:{postalCode:s.getPostalCode()}},(0,t.createElement)(d,{checkoutFormHandler:s,eventRegistration:n,emitResponse:a}))}}),paymentMethodId:u,ariaLabel:"Square",canMakePayment:()=>!(!s().applicationId||!s().locationId),supports:{features:s().supports,showSavedCards:s().showSavedCards,showSaveOption:s().showSaveOption}},w=window.wp.i18n,_=e=>s().ajaxUrl.replace("%%endpoint%%",`square_digital_wallet_${e}`),b=async e=>new Promise(((t,n)=>jQuery.post(_("recalculate_totals"),e,(e=>e.success?t(e.data):n(e.data)))));const E=()=>(0,t.createElement)("svg",{width:"343",height:"50",viewBox:"0 0 343 50",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,t.createElement)("rect",{width:"343",height:"50",rx:"4",fill:"black"}),(0,t.createElement)("path",{d:"M97.6482 17.68H103.048C103.622 17.68 104.162 17.78 104.668 17.98C105.188 18.1667 105.642 18.4333 106.028 18.78C106.428 19.1133 106.742 19.5133 106.968 19.98C107.195 20.4467 107.308 20.9533 107.308 21.5C107.308 22.2333 107.122 22.86 106.748 23.38C106.388 23.8867 105.928 24.2667 105.368 24.52V24.64C106.088 24.8933 106.668 25.3067 107.108 25.88C107.562 26.4533 107.788 27.1467 107.788 27.96C107.788 28.5733 107.668 29.1267 107.428 29.62C107.188 30.1133 106.862 30.54 106.448 30.9C106.035 31.2467 105.555 31.52 105.008 31.72C104.475 31.9067 103.902 32 103.288 32H97.6482V17.68ZM102.968 23.66C103.302 23.66 103.602 23.6067 103.868 23.5C104.135 23.38 104.355 23.2333 104.528 23.06C104.715 22.8733 104.855 22.6667 104.948 22.44C105.042 22.2 105.088 21.96 105.088 21.72C105.088 21.48 105.042 21.2467 104.948 21.02C104.855 20.78 104.722 20.5733 104.548 20.4C104.375 20.2133 104.162 20.0667 103.908 19.96C103.655 19.84 103.368 19.78 103.048 19.78H99.9082V23.66H102.968ZM103.288 29.9C103.648 29.9 103.968 29.84 104.248 29.72C104.528 29.6 104.762 29.44 104.948 29.24C105.135 29.04 105.275 28.8133 105.368 28.56C105.475 28.3067 105.528 28.0467 105.528 27.78C105.528 27.5133 105.475 27.26 105.368 27.02C105.275 26.7667 105.128 26.5467 104.928 26.36C104.728 26.16 104.482 26 104.188 25.88C103.908 25.76 103.582 25.7 103.208 25.7H99.9082V29.9H103.288ZM116.875 30.68H116.755C116.461 31.1467 116.041 31.54 115.495 31.86C114.961 32.1667 114.355 32.32 113.675 32.32C112.435 32.32 111.508 31.9533 110.895 31.22C110.281 30.4733 109.975 29.4867 109.975 28.26V22.2H112.195V27.96C112.195 28.8133 112.388 29.4133 112.775 29.76C113.175 30.0933 113.695 30.26 114.335 30.26C114.708 30.26 115.041 30.18 115.335 30.02C115.641 29.86 115.901 29.6467 116.115 29.38C116.328 29.1 116.488 28.7867 116.595 28.44C116.701 28.08 116.755 27.7067 116.755 27.32V22.2H118.975V32H116.875V30.68ZM124.747 31.44L120.667 22.2H123.147L125.847 28.7H125.947L128.567 22.2H131.027L124.887 36.32H122.527L124.747 31.44ZM136.589 22.2H139.009L140.909 28.98H140.989L143.189 22.2H145.489L147.669 28.98H147.749L149.629 22.2H152.009L148.869 32H146.529L144.309 25.14H144.229L142.069 32H139.729L136.589 22.2ZM154.995 20.46C154.568 20.46 154.208 20.3133 153.915 20.02C153.635 19.7267 153.495 19.3733 153.495 18.96C153.495 18.5467 153.635 18.1933 153.915 17.9C154.208 17.6067 154.568 17.46 154.995 17.46C155.408 17.46 155.755 17.6067 156.035 17.9C156.328 18.1933 156.475 18.5467 156.475 18.96C156.475 19.3733 156.328 19.7267 156.035 20.02C155.755 20.3133 155.408 20.46 154.995 20.46ZM153.875 32V22.2H156.095V32H153.875ZM159.982 24.16H158.262V22.2H159.982V19.2H162.202V22.2H164.622V24.16H162.202V28.52C162.202 28.76 162.229 28.98 162.282 29.18C162.336 29.38 162.416 29.5467 162.522 29.68C162.749 29.9333 163.036 30.06 163.382 30.06C163.596 30.06 163.762 30.0467 163.882 30.02C164.002 29.98 164.129 29.9267 164.262 29.86L164.942 31.82C164.662 31.9267 164.369 32.0067 164.062 32.06C163.756 32.1267 163.409 32.16 163.022 32.16C162.556 32.16 162.142 32.0867 161.782 31.94C161.422 31.7933 161.109 31.5933 160.842 31.34C160.269 30.7667 159.982 29.9867 159.982 29V24.16ZM167.059 17.68H169.279V21.94L169.159 23.52H169.279C169.559 23.0533 169.972 22.6667 170.519 22.36C171.065 22.04 171.672 21.88 172.339 21.88C172.979 21.88 173.532 21.98 173.999 22.18C174.465 22.3667 174.852 22.64 175.159 23C175.465 23.36 175.692 23.7933 175.839 24.3C175.985 24.7933 176.059 25.34 176.059 25.94V32H173.839V26.24C173.839 25.4267 173.639 24.84 173.239 24.48C172.852 24.12 172.359 23.94 171.759 23.94C171.372 23.94 171.025 24.0267 170.719 24.2C170.425 24.36 170.165 24.58 169.939 24.86C169.725 25.14 169.559 25.46 169.439 25.82C169.332 26.18 169.279 26.5533 169.279 26.94V32H167.059V17.68Z",fill:"white"}),(0,t.createElement)("path",{d:"M213.951 24.6725V31.7485H211.69V14.2748H217.684C219.203 14.2748 220.498 14.7778 221.558 15.7836C222.641 16.7895 223.183 18.0175 223.183 19.4678C223.183 20.9532 222.641 22.1813 221.558 23.1754C220.51 24.1696 219.215 24.6608 217.684 24.6608H213.951V24.6725ZM213.951 16.4269V22.5204H217.731C218.626 22.5204 219.379 22.2164 219.968 21.6199C220.569 21.0234 220.875 20.2982 220.875 19.4795C220.875 18.6725 220.569 17.9591 219.968 17.3626C219.379 16.7427 218.638 16.4386 217.731 16.4386H213.951V16.4269Z",fill:"white"}),(0,t.createElement)("path",{d:"M229.094 19.3976C230.766 19.3976 232.085 19.8421 233.05 20.731C234.016 21.6199 234.499 22.8362 234.499 24.3801V31.7485H232.344V30.0877H232.25C231.319 31.4561 230.071 32.1345 228.517 32.1345C227.186 32.1345 226.079 31.7485 225.185 30.9649C224.29 30.1813 223.842 29.2105 223.842 28.0409C223.842 26.8011 224.313 25.8187 225.255 25.0935C226.197 24.3567 227.457 23.9941 229.023 23.9941C230.366 23.9941 231.472 24.2397 232.332 24.731V24.2164C232.332 23.4327 232.026 22.7778 231.402 22.228C230.778 21.6783 230.048 21.4093 229.212 21.4093C227.952 21.4093 226.951 21.9357 226.221 23L224.231 21.7602C225.326 20.1813 226.951 19.3976 229.094 19.3976ZM226.174 28.076C226.174 28.6608 226.421 29.152 226.927 29.538C227.422 29.9239 228.011 30.1228 228.682 30.1228C229.636 30.1228 230.483 29.7719 231.225 29.0701C231.967 28.3684 232.344 27.5497 232.344 26.6023C231.637 26.0526 230.66 25.7719 229.4 25.7719C228.482 25.7719 227.716 25.9941 227.104 26.4269C226.48 26.883 226.174 27.4327 226.174 28.076Z",fill:"white"}),(0,t.createElement)("path",{d:"M246.792 19.7836L239.256 37H236.924L239.727 30.9766L234.758 19.7836H237.219L240.798 28.3684H240.845L244.331 19.7836H246.792Z",fill:"white"}),(0,t.createElement)("path",{d:"M204.959 23.2456C204.959 22.5134 204.893 21.8128 204.77 21.1392H195.294V24.9988L200.751 25C200.53 26.2842 199.818 27.3789 198.726 28.1087V30.6128H201.975C203.872 28.869 204.959 26.2912 204.959 23.2456Z",fill:"#4285F4"}),(0,t.createElement)("path",{d:"M198.727 28.1088C197.823 28.7146 196.658 29.069 195.296 29.069C192.664 29.069 190.432 27.3076 189.632 24.9333H186.281V27.5158C187.941 30.7883 191.354 33.0339 195.296 33.0339C198.021 33.0339 200.31 32.1439 201.976 30.6117L198.727 28.1088Z",fill:"#34A853"}),(0,t.createElement)("path",{d:"M189.317 23.0175C189.317 22.3509 189.428 21.7064 189.632 21.1006V18.5181H186.281C185.594 19.8713 185.208 21.3988 185.208 23.0175C185.208 24.6362 185.596 26.1637 186.281 27.5169L189.632 24.9345C189.428 24.3286 189.317 23.6842 189.317 23.0175Z",fill:"#FABB05"}),(0,t.createElement)("path",{d:"M195.296 16.9649C196.783 16.9649 198.115 17.4737 199.166 18.4678L202.045 15.6105C200.297 13.993 198.017 13 195.296 13C191.355 13 187.941 15.2456 186.281 18.5181L189.632 21.1006C190.432 18.7263 192.664 16.9649 195.296 16.9649Z",fill:"#E94235"})),v=()=>(0,t.createElement)("svg",{width:"343",height:"50",viewBox:"0 0 343 50",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,t.createElement)("rect",{width:"343",height:"50",rx:"8",fill:"black"}),(0,t.createElement)("path",{d:"M155.748 19.8275C154.411 19.8275 153.333 20.636 152.637 20.636C151.907 20.636 150.93 19.8724 149.773 19.8724C147.572 19.8724 145.337 21.7029 145.337 25.1282C145.337 27.2733 146.168 29.5306 147.19 31.0018C148.055 32.2259 148.83 33.2366 149.93 33.2366C151.02 33.2366 151.503 32.5179 152.862 32.5179C154.232 32.5179 154.546 33.2142 155.748 33.2142C156.95 33.2142 157.747 32.1248 158.499 31.0467C159.33 29.8001 159.69 28.5872 159.701 28.5311C159.634 28.5086 157.343 27.5765 157.343 24.9485C157.343 22.68 159.139 21.6693 159.241 21.5906C158.061 19.8724 156.253 19.8275 155.748 19.8275ZM155.13 18.3787C155.669 17.7161 156.051 16.8177 156.051 15.908C156.051 15.7845 156.04 15.6609 156.017 15.5599C155.141 15.5936 154.063 16.1439 153.423 16.8963C152.929 17.4691 152.457 18.3787 152.457 19.2884C152.457 19.4232 152.48 19.5692 152.491 19.6141C152.547 19.6253 152.637 19.6365 152.727 19.6365C153.524 19.6365 154.535 19.0975 155.13 18.3787ZM164.115 16.8289V33.0345H167.013V27.7225H170.528C173.807 27.7225 176.098 25.5213 176.098 22.3094C176.098 19.0413 173.886 16.8289 170.652 16.8289H164.115ZM167.013 19.2547H169.888C171.977 19.2547 173.156 20.3216 173.156 22.3094C173.156 24.241 171.943 25.3192 169.877 25.3192H167.013V19.2547ZM181.535 31.0467C180.3 31.0467 179.412 30.429 179.412 29.3958C179.412 28.3963 180.142 27.8348 181.703 27.7337L184.477 27.554V28.5311C184.477 29.9573 183.219 31.0467 181.535 31.0467ZM180.715 33.2366C182.321 33.2366 183.669 32.5403 184.354 31.3499H184.545V33.0345H187.229V24.6453C187.229 22.0399 185.454 20.5013 182.299 20.5013C179.379 20.5013 177.346 21.8826 177.121 24.0501H179.749C180.008 23.2191 180.884 22.7698 182.164 22.7698C183.669 22.7698 184.477 23.4437 184.477 24.6453V25.6785L181.31 25.8694C178.323 26.0491 176.65 27.3294 176.65 29.553C176.65 31.7991 178.345 33.2366 180.715 33.2366ZM190.329 37.493C193.081 37.493 194.395 36.4822 195.439 33.4276L199.875 20.7484H196.933L194.069 30.3392H193.878L191.003 20.7484H187.948L192.34 33.0906L192.194 33.6297C191.834 34.764 191.172 35.2132 189.992 35.2132C189.801 35.2132 189.386 35.202 189.229 35.1683V37.4481C189.408 37.4818 190.161 37.493 190.329 37.493Z",fill:"white"}),(0,t.createElement)("rect",{width:"343",height:"50",rx:"8",stroke:"black"})),S={name:"square-credit-card",title:"Square",description:(0,w.__)("This will show users the Apple Pay and/or Google Pay buttons depending on their browser and logged in status.","woocommerce-square"),gatewayId:"square_credit_card",paymentMethodId:"square_credit_card",content:(0,t.createElement)((({billing:e,shippingData:a,onClick:o,onClose:i,onSubmit:r,setExpressPaymentError:l,emitResponse:c,eventRegistration:{onPaymentSetup:d,onCheckoutFail:p}})=>{const{needsShipping:u}=a,C=function(){const[e,t]=(0,n.useState)(null);return(0,n.useEffect)((()=>{const e=s().applicationId,n=s().locationId;if(window.Square)try{const a=window.Square.payments(e,n);t(a)}catch(e){console.error(e)}}),[]),e}(),g=function(e,t){const[a,o]=(0,n.useState)(null);return(0,n.useEffect)((()=>{e&&(async()=>{const t=await new Promise(((e,t)=>{const n={context:s().context,security:s().paymentRequestNonce,is_pay_for_order_page:s().isPayForOrderPage};jQuery.post(_("get_payment_request"),n,(n=>n.success?e(n.data):t(n.data)))})),n=JSON.parse(t),a=e.paymentRequest(n);o(a)})()}),[e,t]),a}(C,u),[y,m]=function(e,t){const[a,o]=(0,n.useState)(null),i=(0,n.useRef)(null);return(0,n.useEffect)((()=>{e&&t&&(async()=>{try{const n=await e.googlePay(t);await n.attach(i.current,{buttonColor:s().googlePayColor,buttonSizeMode:"fill",buttonType:"long"}),o(n)}catch(e){}})()}),[e,t]),[a,i]}(C,g),[h,f]=function(e,t){const[a,o]=(0,n.useState)(null),i=(0,n.useRef)(null);return(0,n.useEffect)((()=>{e&&t&&(async()=>{try{const n=await e.applePay(t);o(n)}catch(e){}})()}),[e,t]),(0,n.useEffect)((()=>{if(!i?.current||!a)return;const e=s().applePayColor,t=s().applePayType;"plain"!==t&&(i.current.querySelector(".text").innerText=`${t.charAt(0).toUpperCase()}${t.slice(1)} with`,i.current.classList.add("wc-square-wallet-button-with-text")),i.current.style.cssText+=`-apple-pay-button-type: ${t};`,i.current.style.cssText+=`-apple-pay-button-style: ${e};`,i.current.style.display="block",i.current.classList.add(`wc-square-wallet-button-${e}`)}),[a,i]),[a,i]}(C,g),[w,E]=(0,n.useState)(!1);(function(e){(0,n.useEffect)((()=>{e?.addEventListener("shippingcontactchanged",(e=>(async e=>{const t={context:s().context,shipping_contact:e,security:s().recalculateTotalNonce,is_pay_for_order_page:s().isPayForOrderPage};return await b(t)})(e)))}),[e])})(g),function(e){(0,n.useEffect)((()=>{e?.addEventListener("shippingoptionchanged",(e=>(async e=>{const t={context:s().context,shipping_option:e.id,security:s().recalculateTotalNonce,is_pay_for_order_page:s().isPayForOrderPage};return await b(t)})(e)))}),[e])}(g),function(e,t,a,o,s){const i=(e=>({intent:"CHARGE",amount:(e.cartTotal.value/100).toString(),currencyCode:e.currency.code,billingContact:{familyName:e.billingData.last_name||"",givenName:e.billingData.first_name||"",email:e.billingData.email||"",country:e.billingData.country||"",region:e.billingData.state||"",city:e.billingData.city||"",postalCode:e.billingData.postcode||"",phone:e.billingData.phone||"",addressLines:[e.billingData.address_1||"",e.billingData.address_2||""]}}))(t);(0,n.useEffect)((()=>s((()=>async function(){var t,n,s,r,l,c,d,p,u,C,g,y,m,h,f,w,_,b,E;let v={type:o.responseTypes.SUCCESS};if(!a)return v={type:o.responseTypes.FAILURE},v;const{details:{card:S,method:H},token:k}=a,R=a?.details?.billing||{},{contact:L={},option:x={}}=a?.details?.shipping||{},V=await(async(e,t,n)=>await e.verifyBuyer(t,n))(e,k,i),M="wc-square-credit-card",{token:T}=V,P=null!==(t=null!==(n=R?.email)&&void 0!==n?n:L?.email)&&void 0!==t?t:"",D=null!==(s=null!==(r=R?.phone)&&void 0!==r?r:L?.phone)&&void 0!==s?s:"",N=null!==(l=null!==(c=L?.phone)&&void 0!==c?c:R?.phone)&&void 0!==l?l:"";return v.meta={paymentMethodData:{[`${M}-card-type`]:H||"",[`${M}-last-four`]:S?.last4||"",[`${M}-exp-month`]:S?.expMonth?.toString()||"",[`${M}-exp-year`]:S?.expYear?.toString()||"",[`${M}-payment-postcode`]:S?.postalCode||"",[`${M}-payment-nonce`]:k||"",[`${M}-buyer-verification-token`]:T||"",shipping_method:null!==(d=x.id)&&void 0!==d&&d},billingAddress:{email:P,first_name:null!==(p=R.givenName)&&void 0!==p?p:"",last_name:null!==(u=R.familyName)&&void 0!==u?u:"",company:"",address_1:R.addressLines?R.addressLines[0]:"",address_2:R.addressLines?R.addressLines[1]:"",city:null!==(C=R.city)&&void 0!==C?C:"",state:null!==(g=R.state)&&void 0!==g?g:"",postcode:null!==(y=R.postalCode)&&void 0!==y?y:"",country:null!==(m=R.countryCode)&&void 0!==m?m:"",phone:D},shippingAddress:{first_name:null!==(h=L.givenName)&&void 0!==h?h:"",last_name:null!==(f=L.familyName)&&void 0!==f?f:"",company:"",address_1:L.addressLines?L.addressLines[0]:"",address_2:L.addressLines?L.addressLines[1]:"",city:null!==(w=L.city)&&void 0!==w?w:"",state:null!==(_=L.state)&&void 0!==_?_:"",postcode:null!==(b=L.postalCode)&&void 0!==b?b:"",country:null!==(E=L.countryCode)&&void 0!==E?E:"",phone:N}},wp.data.dispatch("wc/store/cart").setBillingAddress(v.meta.billingAddress),wp.data.select("wc/store/cart").getNeedsShipping()&&(wp.data.dispatch("wc/store/cart").setShippingAddress(v.meta.shippingAddress),!wp.data.select("wc/store/cart").getShippingRates().some((e=>e.shipping_rates.length)))?(v.type=o.responseTypes.FAILURE,v):v}()))),[s,t.billingData,a])}(C,e,w,c,d),(0,n.useEffect)((()=>p((()=>(i(),!0)))),[p]);const v=s().hideButtonOptions.includes("google"),S=s().hideButtonOptions.includes("apple");function H(e){e&&(l(""),o(),(async()=>{const t=await(async e=>{try{const t=await e.tokenize();if("OK"===t.status)return t}catch(e){return!1}return!1})(e);t?(E(t),r()):i()})())}const k=!v&&(0,t.createElement)("div",{tabIndex:0,role:"button",ref:m,onClick:()=>H(y)}),R=!S&&(0,t.createElement)("div",{tabIndex:0,role:"button",ref:f,onClick:()=>H(h),className:"apple-pay-button wc-square-wallet-buttons"},(0,t.createElement)("span",{className:"text"}),(0,t.createElement)("span",{className:"logo"}));return(0,t.createElement)(t.Fragment,null,R,k)}),null),edit:(0,t.createElement)((()=>(0,t.createElement)(t.Fragment,null,(0,t.createElement)(E,null),(0,t.createElement)(v,null))),null),canMakePayment:()=>{const e=!(!s().applicationId||!s().locationId),t=s().isDigitalWalletsEnabled;return e&&t},supports:{features:s().supports}};(0,e.registerPaymentMethod)(f);const H=s().hideButtonOptions;H.includes("google")&&H.includes("apple")||(0,e.registerExpressPaymentMethod)(S)})();