/*
 * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
 * This devtool is neither made for production nor for readable output files.
 * It uses "eval()" calls to create a separate source file in the browser devtools.
 * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
 * or disable the default devtool with "devtool: false".
 * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
 */
/******/ (() => { // webpackBootstrap
/******/ 	var __webpack_modules__ = ({

/***/ "./modules/table-rate-shipping/assets/src/js/table-rate-shipping.js":
/*!**************************************************************************!*\
  !*** ./modules/table-rate-shipping/assets/src/js/table-rate-shipping.js ***!
  \**************************************************************************/
/***/ (() => {

eval("/* Dokan shipping table rate rows */\n(function ($, data, wp) {\n  var wc_table_rate_rows_row_template = wp.template('table-rate-shipping-row-template'),\n      $settings_form = $('#dokan-table-rate-shipping-setting-form'),\n      $rates_table = $('#dokan_shipping_rates'),\n      $rates = $rates_table.find('tbody.table_rates');\n  var dokan_table_rate_rows = {\n    init: function init() {\n      $settings_form.on('change', '#dokan_table_rate_calculation_type', this.onCalculationTypeChange);\n      $rates_table.on('change', 'select[name^=\"shipping_condition\"]', this.onShippingConditionChange).on('change', 'input[name^=\"shipping_abort[\"]', this.onShippingAbortChange).on('click', 'button.add-table-rate', this.onAddRate).on('click', 'button.remove-table-rate', this.onRemoveRate).on('click', 'button.remove-distance-rate', this.onRemoveDistanceRate).on('click', 'button.dupe-table-rate', this.onDupeRate);\n      var rates_data = $rates.data('rates');\n      $(rates_data).each(function (i) {\n        var size = $rates.find('.table_rate').length;\n        $rates.append(wc_table_rate_rows_row_template({\n          rate: rates_data[i],\n          index: size\n        }));\n      });\n      $('label[for=\"dokan_table_rate_handling_fee\"], label[for=\"dokan_table_rate_max_cost\"], label[for=\"dokan_table_rate_min_cost\"]', $settings_form).each(function (i, el) {\n        $(el).data('o_label', $(el).text());\n      });\n      $('#dokan_table_rate_calculation_type, select[name^=\"shipping_condition\"], input[name^=\"shipping_abort[\"]', $settings_form).change();\n      $rates.sortable({\n        items: 'tr',\n        cursor: 'move',\n        axis: 'y',\n        handle: 'td',\n        scrollSensitivity: 40,\n        helper: function helper(e, ui) {\n          ui.children().each(function () {\n            $(this).width($(this).width());\n          });\n          ui.css('left', '0');\n          return ui;\n        },\n        start: function start(event, ui) {\n          ui.item.css('background-color', '#f6f6f6');\n        },\n        stop: function stop(event, ui) {\n          ui.item.removeAttr('style');\n          dokan_table_rate_rows.reindexRows();\n        }\n      });\n    },\n    onCalculationTypeChange: function onCalculationTypeChange() {\n      var selected = $(this).val();\n\n      if (selected == 'item') {\n        $('td.cost_per_item input').attr('disabled', 'disabled').addClass('disabled');\n      } else {\n        $('td.cost_per_item input').removeAttr('disabled').removeClass('disabled');\n      }\n\n      if (selected) {\n        $('#dokan_table_rate_class_priorities').hide();\n        $('td.shipping_label, th.shipping_label').hide();\n      } else {\n        $('#dokan_table_rate_class_priorities').show();\n        $('td.shipping_label, th.shipping_label').show();\n      }\n\n      if (!selected) {\n        $('#dokan_table_rate_class_priorities p.description.per_order').show();\n        $('#dokan_table_rate_class_priorities p.description.per_class').hide();\n      }\n\n      var label_text = data.i18n.order;\n\n      if (selected == 'item') {\n        label_text = data.i18n.item;\n      } else if (selected == 'line') {\n        label_text = data.i18n.line_item;\n      } else if (selected == 'class') {\n        label_text = data.i18n.class;\n      }\n\n      $('label[for=\"dokan_table_rate_handling_fee\"], label[for=\"dokan_table_rate_max_cost\"], label[for=\"dokan_table_rate_min_cost\"]').each(function (i, el) {\n        var text = $(el).data('o_label');\n        text = text.replace('[item_label]', label_text);\n        $(el).text(text);\n      });\n    },\n    onShippingConditionChange: function onShippingConditionChange() {\n      var selected = $(this).val();\n      var $row = $(this).closest('tr');\n\n      if (selected == '') {\n        $row.find('input[name^=\"shipping_min\"], input[name^=\"shipping_max\"]').val('').prop('disabled', true).addClass('disabled');\n      } else {\n        $row.find('input[name^=\"shipping_min\"], input[name^=\"shipping_max\"]').prop('disabled', false).removeClass('disabled');\n      }\n    },\n    onShippingAbortChange: function onShippingAbortChange() {\n      var checked = $(this).is(':checked');\n      var $row = $(this).closest('tr');\n\n      if (checked) {\n        $row.find('td.cost').hide();\n        $row.find('td.abort_reason').show();\n        $row.find('input[name^=\"shipping_per_item\"], input[name^=\"shipping_cost_per_weight\"], input[name^=\"shipping_cost_percent\"], input[name^=\"shipping_cost\"], input[name^=\"shipping_label\"]').prop('disabled', true).addClass('disabled');\n      } else {\n        $row.find('td.cost').show();\n        $row.find('td.abort_reason').hide();\n        $row.find('input[name^=\"shipping_per_item\"], input[name^=\"shipping_cost_per_weight\"], input[name^=\"shipping_cost_percent\"], input[name^=\"shipping_cost\"], input[name^=\"shipping_label\"]').prop('disabled', false).removeClass('disabled');\n      }\n\n      $('#dokan_table_rate_calculation_type').change();\n    },\n    onAddRate: function onAddRate(event) {\n      event.preventDefault();\n      var target = $rates;\n      var size = target.find('.table_rate').length;\n      target.append(wc_table_rate_rows_row_template({\n        rate: {\n          rate_id: '',\n          rate_class: '',\n          rate_condition: '',\n          rate_min: '',\n          rate_max: '',\n          rate_priority: '',\n          rate_abort: '',\n          rate_abort_reason: '',\n          rate_cost: '',\n          rate_cost_per_item: '',\n          rate_cost_per_weight_unit: '',\n          rate_cost_percent: '',\n          rate_label: ''\n        },\n        index: size\n      }));\n      $('#dokan_table_rate_calculation_type, select[name^=\"shipping_condition\"], input[name^=\"shipping_abort[\"]', $rates_table).change();\n    },\n    onRemoveRate: function onRemoveRate(event) {\n      event.preventDefault();\n\n      if (confirm(data.i18n.delete_rates)) {\n        var rate_ids = [];\n        $rates.find('tr td.check-column input:checked').each(function (i, el) {\n          var rate_id = $(el).closest('tr.table_rate').find('.rate_id').val();\n          rate_ids.push(rate_id);\n          $(el).closest('tr.table_rate').addClass('deleting');\n        });\n        var ajax_data = {\n          action: 'dokan_table_rate_delete',\n          rate_id: rate_ids,\n          security: data.delete_rates_nonce\n        };\n        $.post(data.ajax_url, ajax_data, function (response) {\n          $('tr.deleting').fadeOut('300', function () {\n            $(this).remove();\n          });\n        });\n      }\n    },\n    onRemoveDistanceRate: function onRemoveDistanceRate(event) {\n      event.preventDefault();\n\n      if (confirm(data.i18n.delete_rates)) {\n        var rate_ids = [];\n        $rates.find('tr td.check-column input:checked').each(function (i, el) {\n          var rate_id = $(el).closest('tr.table_rate').find('.rate_id').val();\n          rate_ids.push(rate_id);\n          $(el).closest('tr.table_rate').addClass('deleting');\n        });\n        var ajax_data = {\n          action: 'dokan_distance_rate_delete',\n          rate_id: rate_ids,\n          security: data.delete_rates_nonce\n        };\n        $.post(data.ajax_url, ajax_data, function (response) {\n          $('tr.deleting').fadeOut('300', function () {\n            $(this).remove();\n          });\n        });\n      }\n    },\n    onDupeRate: function onDupeRate(event) {\n      event.preventDefault();\n\n      if (confirm(data.i18n.dupe_rates)) {\n        $rates.find('tr td.check-column input:checked').each(function (i, el) {\n          var dupe = $(el).closest('tr').clone();\n          dupe.find('.rate_id').val('0');\n          $rates.append(dupe);\n        });\n        dokan_table_rate_rows.reindexRows();\n      }\n    },\n    reindexRows: function reindexRows() {\n      var loop = 0;\n      $rates.find('tr').each(function (index, row) {\n        $('input.text, input.checkbox, select.select, input[type=hidden]', row).each(function (i, el) {\n          var t = $(el);\n          t.attr('name', t.attr('name').replace(/\\[([^[]*)\\]/, \"[\" + loop + \"]\"));\n        });\n        loop++;\n      });\n    }\n  };\n  dokan_table_rate_rows.init();\n})(jQuery, dokan_trs_params, wp);\n\n//# sourceURL=webpack://dokan-pro/./modules/table-rate-shipping/assets/src/js/table-rate-shipping.js?");

/***/ })

/******/ 	});
/************************************************************************/
/******/ 	
/******/ 	// startup
/******/ 	// Load entry module and return exports
/******/ 	// This entry module can't be inlined because the eval devtool is used.
/******/ 	var __webpack_exports__ = {};
/******/ 	__webpack_modules__["./modules/table-rate-shipping/assets/src/js/table-rate-shipping.js"]();
/******/ 	
/******/ })()
;