"use strict";const mutations=require("./mutations-6e603e86.js"),watchers=require("./watchers-517825ae.js"),getters=require("./getters-051ccbf6.js"),maybeUpdateProcessor=()=>{var e,t;const s=[...getters.availableProcessors().map((({processor_type:e})=>e)),...getters.availableManualPaymentMethods().map((({id:e})=>e))];s.includes(watchers.state.id)||(null===(t=null===(e=null===window||void 0===window?void 0:window.wp)||void 0===e?void 0:e.hooks)||void 0===t?void 0:t.applyFilters)&&!window.wp.hooks.applyFilters("surecart_auto_select_payment_method",!0)||(watchers.state.id=(null==s?void 0:s.length)?null==s?void 0:s[0]:null)},maybeUpdateMethod=()=>{const e=(getters.availableMethodTypes()||[]).map((({id:e})=>e));getters.isMethodAwareProcessor(null===watchers.state||void 0===watchers.state?void 0:watchers.state.id)?e.includes(watchers.state.method)||(watchers.state.method=(null==e?void 0:e.length)?null==e?void 0:e[0]:null):watchers.state.method=null};mutations.onChange("checkout",(()=>{maybeUpdateProcessor(),maybeUpdateMethod()})),watchers.onChange("id",(()=>{maybeUpdateProcessor(),maybeUpdateMethod()})),getters.onChange("processors",(()=>maybeUpdateProcessor())),getters.onChange("disabled",(()=>maybeUpdateProcessor())),getters.onChange("methods",(()=>maybeUpdateMethod()));