import{g as i,s as m}from"./select-tmpl.7954c02d.js";import{r as s,w as d,j as o}from"./vue.3f733908.js";const c=a=>{const e=s({campaignId:a.data.campaignId,campaignType:a.data.campaignType,profileId:a.data.profileId,ruleType:a.data.ruleType,templateName:"",useTmpl:!1,rule:{type:a.data.ruleType,campaignType:a.data.campaignType,campaignAd:[],action:{},activeModel:"",setTime:"",weekdays:[],conditions:[]},RuleStatusButton:a.RuleStatusButton}),l=async()=>{const u=(await i(a.data)).data[0];u&&(delete u.RuleStatusButton,e.value=u,u.template?(e.value.useTmpl=!0,e.value.rule=u.template.rule):e.value.useTmpl=!1)},n=async()=>{const t={campaignId:e.value.campaignId,campaignType:e.value.campaignType,profileId:e.value.profileId,ruleType:e.value.ruleType,RuleStatusButton:e.value.RuleStatusButton,rule:null,templateName:e.value.templateName};e.value.useTmpl?t.templateId=e.value.template.id:(t.rule=e.value.rule,delete t.rule.modifier_name,delete t.rule.id),await m(t)};return d(()=>a.RuleStatusButton,()=>{e.value.RuleStatusButton=a.RuleStatusButton},{deep:!0}),o(async()=>{await l()}),{formData:e,submitFormData:n}};export{c as u};
