(()=>{function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){for(var o=0;o<e.length;o++){var i=e[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,n(i.key),i)}}function o(t,e,o){return(e=n(e))in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function n(e){var o=function(e,o){if("object"!=t(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,o||"default");if("object"!=t(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===o?String:Number)(e)}(e,"string");return"symbol"==t(o)?o:o+""}$(document).ready((function(){(new(function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),o(this,"$customFieldOptions",$("#custom-field-options")),o(this,"$customFieldsBox",$("#custom_fields_box"))},(n=[{key:"init",value:function(){this.sortable(),this.handleType(),this.addNewRow(),this.removeRow()}},{key:"handleType",value:function(){var t=this.$customFieldsBox,e=$(".custom-field-type"),o=$("#placeholder").closest(".form-group");"text"===e.val()||"textarea"===e.val()||"number"===e.val()?(this.$customFieldsBox.hide(),o.show()):(this.$customFieldsBox.show(),o.hide()),e.change((function(){if("text"===$(this).val()||"textarea"===$(this).val()||"number"===e.val())return t.hide(),void o.show();t.show(),o.hide()}))}},{key:"sortable",value:function(){$(".option-sortable").sortable({stop:function(){$(".option-sortable").sortable("toArray",{attribute:"data-index"}).map((function(t,e){$('.option-row[data-index="'.concat(t,'"]')).find(".option-order").val(e)}))}})}},{key:"addNewRow",value:function(){this.$customFieldOptions.on("click","#add-new-row",(function(){var t=$(this).parent().find("table tbody"),e=t.find("tr").last().clone(),o="options[".concat(t.find("tr").length,"][label]"),n="options[".concat(t.find("tr").length,"][value]");e.find(".option-label").val("").attr("name",o),e.find(".option-value").val("").attr("name",n),t.append(e)}))}},{key:"removeRow",value:function(){this.$customFieldOptions.on("click",".remove-row",(function(){var t=$(this).parent().parent(),e=t.parent().find("tr");if(e.length<=1)return e.find(".option-label").val(""),void e.find(".option-value").val("");t.remove()}))}}])&&e(t.prototype,n),i&&e(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,n,i}())).init()}))})();