!function(e){e(document).ready((function(){const t={components:{vuedraggable:vuedraggable},template:"#wu-table",props:["list","headers","step_name"],name:"wu-draggable-table",data:()=>({delete_field_id:""}),methods:{remove_field(e){wu_checkout_forms_editor_app.remove_field(this.step_name,e),this.delete_field_id=""}}};wu_checkout_forms_editor_app=new Vue({el:"#wu-checkout-editor-app",name:"CheckoutEditor",data:()=>Object.assign({},{dragging:!1,search:"",delete_step_id:"",preview_error:!1,preview:!1,loading_preview:!1,preview_content:"",iframe_preview_url:""},wu_checkout_form),components:{vuedraggable:vuedraggable,"wu-draggable-table":t},computed:{field_count(){return _.reduce(this.steps,(function(e,t){return e+t.fields.length}),0)}},watch:{steps:{handler(){this.update_session()},deep:!0}},mounted(){this.update_session()},methods:{get_preview(t=null){if(null===t&&(this.preview=!this.preview),this.preview){this.loading_preview=!0;const i=this;i.iframe_preview_url=i.register_page+"?action=wu_generate_checkout_form_preview&form_id="+i.form_id+"&type="+t+"&uniq="+1e3*Math.random(),e("#wp-ultimo-checkout-preview").on("load",(function(){i.loading_preview=!1,setTimeout((()=>{const t=document.getElementById("wp-ultimo-checkout-preview").contentWindow.document.body.scrollHeight;e("#wp-ultimo-checkout-preview").animate({height:t})}),1e3)}))}console.log("no preview")},add_step(e,t=null){const i=e.original_id?this.find_step(e.original_id):this.find_step(e.id);if(delete e.original_id,void 0!==i){const t=_.indexOf(this.steps,i);(e=Object.assign({},i,e)).fields=i.fields,Vue.set(this.steps,t,e)}else this.steps.push(e);this.$nextTick((function(){"function"==typeof t&&(t(),this.scroll_to(`wp-ultimo-list-table-${e.id}`))}))},add_field(e,t=null){const i=_.findWhere(this.steps,{id:e.step});let s=this.find_field(e.step,e.id);if(void 0===s&&(s=this.find_field(e.step,e.original_id),delete e.original_id),void 0!==s){const t=_.indexOf(i.fields,s);Vue.set(i.fields,t,e)}else i.fields.push(e);this.$nextTick((function(){"function"==typeof t&&(t(),this.scroll_to(`wp-ultimo-field-${e.id}`))}))},scroll_to(e){this.$nextTick((function(){setTimeout((()=>{document.getElementById(e).scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"})}),500)}))},find_step(e){return _.findWhere(this.steps,{id:e})},find_field(e,t){const i=_.findWhere(this.steps,{id:e});return _.findWhere(i.fields,{id:t})},remove_step(e){this.steps=_.reject(this.steps,(function(t){return t.id===e})),this.delete_step_id=""},remove_field(e,t){const i=_.findWhere(this.steps,{id:e});i.fields=_.reject(i.fields,(function(e){return e.id===t}))},update_session(){wu_initialize_tooltip();e.ajax({method:"post",url:ajaxurl,data:{action:"wu_save_editor_session",settings:this.steps,form_id:this.form_id},success(){}})}}})}))}(jQuery);