import{getCheckout}from"../checkouts/mutations";import state from"./store";import{isAddressComplete}from"../../functions/address";export const currentCheckout=()=>getCheckout(state.formId,state.mode);export const checkoutIsLocked=(e="")=>{var t;return e?state.locks.some((t=>t===e)):!!(null===(t=state.locks)||void 0===t?void 0:t.length)};export const getLineItemByProductId=e=>{var t,i;return((null===(i=null===(t=state.checkout)||void 0===t?void 0:t.line_items)||void 0===i?void 0:i.data)||[]).find((t=>{var i,o;return(null===(o=null===(i=null==t?void 0:t.price)||void 0===i?void 0:i.product)||void 0===o?void 0:o.id)===e}))};export const fullShippingAddressRequired=()=>{var e;return"full"===(null===(e=state.checkout)||void 0===e?void 0:e.shipping_address_accuracy_requirement)};export const shippingAddressRequired=()=>{var e,t;return"full"===(null===(e=state.checkout)||void 0===e?void 0:e.shipping_address_accuracy_requirement)||"tax"===(null===(t=state.checkout)||void 0===t?void 0:t.shipping_address_accuracy_requirement)};export const getCompleteAddress=(e="shipping")=>{var t,i;if(!isAddressComplete(null===(t=state.checkout)||void 0===t?void 0:t[`${e}_address`]))return;const{line_1:o,line_2:s,...r}=(null===(i=state.checkout)||void 0===i?void 0:i[`${e}_address`])||{};return{line1:o,line2:s,...r}};export const getResolvedBillingAddress=e=>{const t=e||state.checkout,i=!1===(null==t?void 0:t.billing_matches_shipping)&&(null==t?void 0:t.billing_address)?t.billing_address:void 0,o=(null==i?void 0:i.line_1)?i:null==t?void 0:t.shipping_address;if(null==o?void 0:o.line_1)return o};export const toStripeAddress=e=>{if(!(null==e?void 0:e.line_1))return;const{line_1:t,line_2:i,city:o,state:s,country:r,postal_code:d}=e;return{line1:t,line2:i,city:o,state:s,postal_code:d,country:r}};