diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..9c5408b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = tab + +[{*.json,*.yml,.babelrc,.bowerrc,.browserslistrc,.postcssrc, .eslintrc, .stylelintrc}] +indent_style = space +indent_size = 2 + +[{*.txt,wp-config-sample.php}] +end_of_line = crlf diff --git a/.github/_typos.toml b/.github/_typos.toml index fe193de..c6faa5e 100644 --- a/.github/_typos.toml +++ b/.github/_typos.toml @@ -2,6 +2,7 @@ # Add words that should be ignored (define them as themselves) Tung = "Tung" # Example: Don't correct the surname "Tung" curent = "curent" # Intentionally preserving misspelling to avoid breaking changes +stati = "stati" # Plural for statuses [type.php] extend-ignore-re = [ @@ -10,4 +11,4 @@ extend-ignore-re = [ # spellchecker:: "//\\s*@spellchecker:off\\s*\\n.*\\n\\s*//\\s*@spellchecker:on" -] \ No newline at end of file +] diff --git a/.gitignore b/.gitignore index c4b3478..2120d99 100644 --- a/.gitignore +++ b/.gitignore @@ -33,4 +33,3 @@ config.codekit /assets/js/content-connect.js /assets/js/content-connect.min.js - diff --git a/assets/js/content-connect.js b/assets/js/content-connect.js index 11de7d6..f7746ba 100644 --- a/assets/js/content-connect.js +++ b/assets/js/content-connect.js @@ -182,7 +182,7 @@ module.exports = { if (module.exports.__esModule) module.exports = module.exports.default var __vue__options__ = (typeof module.exports === "function"? module.exports.options: module.exports) if (__vue__options__.functional) {console.error("[vueify] functional components are not supported and should be defined in plain js files using render functions.")} -__vue__options__.render = function render () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"tenup-content-connect vtab-frame"},[(_vm.relationships.length > 1)?_c('div',{staticClass:"vtab-left"},[_c('div',{staticClass:"vtab-frame-menu"},[_c('div',{staticClass:"vtab-menu"},[(_vm.relationships.length)?_vm._l((_vm.relationships),function(relationship){return _c('a',{staticClass:"vtab-menu-item",class:_vm.activeMenuItem(relationship),on:{"click":function($event){$event.preventDefault();_vm.setActiveRelationship(relationship)}}},[_vm._v("\n\t\t\t\t\t\t"+_vm._s(relationship.labels.name)+"\n\t\t\t\t\t")])}):_vm._e()],2)])]):_vm._e(),_vm._v(" "),_c('div',{staticClass:"vtab-right"},[(_vm.activeRelationship)?[_c('div',{staticClass:"vtab-frame-title"},[_c('h1',[_vm._v(_vm._s(_vm.activeRelationship.labels.name))])]),_vm._v(" "),_c('div',{staticClass:"vtab-frame-content"},[_c('div',{staticClass:"vtab-content-area"},[_c('picker-list',{attrs:{"sortable":_vm.activeRelationship.sortable,"items":_vm.activeRelationship.selected},on:{"reorder-items":_vm.reorderItems,"delete-item":_vm.deleteItem}}),_vm._v(" "),_c('picker-search',{attrs:{"results":_vm.searchResults,"searching":_vm.searching,"didsearch":_vm.didSearch,"searcherror":_vm.searchErrorMessage,"prevPages":_vm.prevPages,"morePages":_vm.morePages},on:{"add-item":_vm.addSearchItem,"search":_vm.search,"next-page":_vm.nextPage,"prev-page":_vm.prevPage}})],1)])]:_vm._e()],2),_vm._v(" "),_c('br'),_vm._v(" "),_c('div',[_c('input',{directives:[{name:"model",rawName:"v-model",value:(_vm.saveData),expression:"saveData"}],attrs:{"type":"hidden","name":"tenup-content-connect-relationships"},domProps:{"value":(_vm.saveData)},on:{"input":function($event){if($event.target.composing){ return; }_vm.saveData=$event.target.value}}})])])} +__vue__options__.render = function render () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"tenup-content-connect vtab-frame"},[(_vm.relationships.length > 1)?_c('div',{staticClass:"vtab-left"},[_c('div',{staticClass:"vtab-frame-menu"},[_c('div',{staticClass:"vtab-menu"},[(_vm.relationships.length)?_vm._l((_vm.relationships),function(relationship){return _c('a',{staticClass:"vtab-menu-item",class:_vm.activeMenuItem(relationship),on:{"click":function($event){$event.preventDefault();return _vm.setActiveRelationship(relationship)}}},[_vm._v("\n\t\t\t\t\t\t"+_vm._s(relationship.labels.name)+"\n\t\t\t\t\t")])}):_vm._e()],2)])]):_vm._e(),_vm._v(" "),_c('div',{staticClass:"vtab-right"},[(_vm.activeRelationship)?[_c('div',{staticClass:"vtab-frame-title"},[_c('h1',[_vm._v(_vm._s(_vm.activeRelationship.labels.name))])]),_vm._v(" "),_c('div',{staticClass:"vtab-frame-content"},[_c('div',{staticClass:"vtab-content-area"},[_c('picker-list',{attrs:{"sortable":_vm.activeRelationship.sortable,"items":_vm.activeRelationship.selected},on:{"reorder-items":_vm.reorderItems,"delete-item":_vm.deleteItem}}),_vm._v(" "),_c('picker-search',{attrs:{"results":_vm.searchResults,"searching":_vm.searching,"didsearch":_vm.didSearch,"searcherror":_vm.searchErrorMessage,"prevPages":_vm.prevPages,"morePages":_vm.morePages},on:{"add-item":_vm.addSearchItem,"search":_vm.search,"next-page":_vm.nextPage,"prev-page":_vm.prevPage}})],1)])]:_vm._e()],2),_vm._v(" "),_c('br'),_vm._v(" "),_c('div',[_c('input',{directives:[{name:"model",rawName:"v-model",value:(_vm.saveData),expression:"saveData"}],attrs:{"type":"hidden","name":"tenup-content-connect-relationships"},domProps:{"value":(_vm.saveData)},on:{"input":function($event){if($event.target.composing){ return; }_vm.saveData=$event.target.value}}})])])} __vue__options__.staticRenderFns = [] if (module.hot) {(function () { var hotAPI = require("vue-hot-reload-api") hotAPI.install(require("vue"), true) @@ -190,13 +190,13 @@ if (module.hot) {(function () { var hotAPI = require("vue-hot-reload-api") module.hot.accept() module.hot.dispose(__vueify_style_dispose__) if (!module.hot.data) { - hotAPI.createRecord("data-v-4fd92f7a", __vue__options__) + hotAPI.createRecord("data-v-c761e17a", __vue__options__) } else { - hotAPI.reload("data-v-4fd92f7a", __vue__options__) + hotAPI.reload("data-v-c761e17a", __vue__options__) } })()} -},{"./components/picker-list.vue":2,"./components/picker-search.vue":3,"babel-runtime/core-js/json/stringify":5,"babel-runtime/core-js/object/assign":6,"vue":50,"vue-hot-reload-api":48,"vueify/lib/insert-css":52}],2:[function(require,module,exports){ -var __vueify_style_dispose__ = require("vueify/lib/insert-css").insert("*[data-v-6900689b] {\n\tbox-sizing: border-box;\n}\n\n.content-connect-picker-list-item[data-v-6900689b] {\n\twidth: 100%;\n\tposition: relative;\n\tpadding: 1em 1em 1em 0.5em;\n}\n\n.content-connect-picker-list-item.sortable[data-v-6900689b] {\n\tcursor: move;\n}\n\n.content-connect-picker-list-item[data-v-6900689b]:nth-child(odd) {\n\tbackground-color: #f9f9f9;\n}\n\n.content-connect-picker-list-item.ghost[data-v-6900689b] {\n\topacity: 0.5;\n\tbackground: #c8ebfb;\n}\n\n.content-connect-grab-icon[data-v-6900689b] {\n\tfont-size: 16px;\n\tcolor: #bbb;\n}\n\n.content-connect-delete-button[data-v-6900689b] {\n\tcolor: #a00;\n\tvisibility: hidden;\n\tdisplay: inline-block;\n\tfloat: right;\n\tposition: relative;\n\tcursor: pointer;\n}\n\n.content-connect-delete-button[data-v-6900689b]:hover {\n\tcolor: #dc3232;\n}\n\n.content-connect-picker-list-item:hover .content-connect-delete-button[data-v-6900689b] {\n\tvisibility: visible;\n}") +},{"./components/picker-list.vue":2,"./components/picker-search.vue":3,"babel-runtime/core-js/json/stringify":5,"babel-runtime/core-js/object/assign":6,"vue":52,"vue-hot-reload-api":49,"vueify/lib/insert-css":55}],2:[function(require,module,exports){ +var __vueify_style_dispose__ = require("vueify/lib/insert-css").insert("*[data-v-6e397a32] {\n\tbox-sizing: border-box;\n}\n\n.content-connect-picker-list-item[data-v-6e397a32] {\n\twidth: 100%;\n\tposition: relative;\n\tpadding: 1em 1em 1em 0.5em;\n}\n\n.content-connect-picker-list-item.sortable[data-v-6e397a32] {\n\tcursor: move;\n}\n\n.content-connect-picker-list-item[data-v-6e397a32]:nth-child(odd) {\n\tbackground-color: #f9f9f9;\n}\n\n.content-connect-picker-list-item.ghost[data-v-6e397a32] {\n\topacity: 0.5;\n\tbackground: #c8ebfb;\n}\n\n.content-connect-grab-icon[data-v-6e397a32] {\n\tfont-size: 16px;\n\tcolor: #bbb;\n}\n\n.content-connect-delete-button[data-v-6e397a32] {\n\tcolor: #a00;\n\tvisibility: hidden;\n\tdisplay: inline-block;\n\tfloat: right;\n\tposition: relative;\n\tcursor: pointer;\n}\n\n.content-connect-delete-button[data-v-6e397a32]:hover {\n\tcolor: #dc3232;\n}\n\n.content-connect-picker-list-item:hover .content-connect-delete-button[data-v-6e397a32] {\n\tvisibility: visible;\n}") ;(function(){ 'use strict'; @@ -235,22 +235,22 @@ exports.default = { if (module.exports.__esModule) module.exports = module.exports.default var __vue__options__ = (typeof module.exports === "function"? module.exports.options: module.exports) if (__vue__options__.functional) {console.error("[vueify] functional components are not supported and should be defined in plain js files using render functions.")} -__vue__options__.render = function render () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"content-connect-picker-list-container"},[_c('ul',{staticClass:"content-connect-picker"},[(_vm.sortable === true)?_c('draggable',{attrs:{"options":{ghostClass: 'ghost'}},on:{"start":function($event){_vm.drag=true},"end":function($event){_vm.drag=false}},model:{value:(_vm.localItems),callback:function ($$v) {_vm.localItems=$$v},expression:"localItems"}},_vm._l((_vm.items),function(item){return _c('li',{staticClass:"content-connect-picker-list-item sortable"},[_c('span',{staticClass:"content-connect-grab-icon dashicons dashicons-move"}),_vm._v(" "),_c('span',{staticClass:"content-connect-selected-item-name"},[_vm._v(_vm._s(item.name))]),_vm._v(" "),_c('span',{staticClass:"delete-item content-connect-delete-button",on:{"click":function($event){$event.preventDefault();_vm.deleteItem(item)}}},[_vm._v("delete")])])})):_vm._e(),_vm._v(" "),_vm._l((_vm.items),function(item){return (_vm.sortable === false)?_c('li',{staticClass:"content-connect-picker-list-item"},[_c('span',{staticClass:"content-connect-selected-item-name"},[_vm._v(_vm._s(item.name))]),_vm._v(" "),_c('span',{staticClass:"delete-item content-connect-delete-button",on:{"click":function($event){$event.preventDefault();_vm.deleteItem(item)}}},[_vm._v("delete")])]):_vm._e()})],2)])} +__vue__options__.render = function render () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"content-connect-picker-list-container"},[_c('ul',{staticClass:"content-connect-picker"},[(_vm.sortable === true)?_c('draggable',{attrs:{"options":{ghostClass: 'ghost'}},on:{"start":function($event){_vm.drag=true},"end":function($event){_vm.drag=false}},model:{value:(_vm.localItems),callback:function ($$v) {_vm.localItems=$$v},expression:"localItems"}},_vm._l((_vm.items),function(item){return _c('li',{staticClass:"content-connect-picker-list-item sortable"},[_c('span',{staticClass:"content-connect-grab-icon dashicons dashicons-move"}),_vm._v(" "),_c('span',{staticClass:"content-connect-selected-item-name"},[_vm._v(_vm._s(item.name))]),_vm._v(" "),_c('span',{staticClass:"delete-item content-connect-delete-button",on:{"click":function($event){$event.preventDefault();return _vm.deleteItem(item)}}},[_vm._v("delete")])])}),0):_vm._e(),_vm._v(" "),_vm._l((_vm.items),function(item){return (_vm.sortable === false)?_c('li',{staticClass:"content-connect-picker-list-item"},[_c('span',{staticClass:"content-connect-selected-item-name"},[_vm._v(_vm._s(item.name))]),_vm._v(" "),_c('span',{staticClass:"delete-item content-connect-delete-button",on:{"click":function($event){$event.preventDefault();return _vm.deleteItem(item)}}},[_vm._v("delete")])]):_vm._e()})],2)])} __vue__options__.staticRenderFns = [] -__vue__options__._scopeId = "data-v-6900689b" +__vue__options__._scopeId = "data-v-6e397a32" if (module.hot) {(function () { var hotAPI = require("vue-hot-reload-api") hotAPI.install(require("vue"), true) if (!hotAPI.compatible) return module.hot.accept() module.hot.dispose(__vueify_style_dispose__) if (!module.hot.data) { - hotAPI.createRecord("data-v-6900689b", __vue__options__) + hotAPI.createRecord("data-v-6e397a32", __vue__options__) } else { - hotAPI.reload("data-v-6900689b", __vue__options__) + hotAPI.reload("data-v-6e397a32", __vue__options__) } })()} -},{"vue":50,"vue-hot-reload-api":48,"vuedraggable":51,"vueify/lib/insert-css":52}],3:[function(require,module,exports){ -var __vueify_style_dispose__ = require("vueify/lib/insert-css").insert("*[data-v-29630365] {\n\tbox-sizing: border-box;\n}\n\n.content-connect-picker-search-container[data-v-29630365] {\n\tpadding-bottom: 20px;\n}\n\n.content-connect-picker-search-input-label[data-v-29630365] {\n\tdisplay: block;\n}\n\n.content-connect-picker-search-input-container form[data-v-29630365] {\n\tdisplay: flex;\n}\n\n.content-connect-picker-search-input[data-v-29630365] {\n\tflex: 1;\n\tmargin-right: 0.5em;\n}\n\n.content-connect-picker-search-item[data-v-29630365] {\n\twidth: 100%;\n\tposition: relative;\n\tpadding: 1em 1em 1em 0.5em;\n}\n\n.content-connect-picker-search-item.result[data-v-29630365]:nth-child(odd) {\n\tbackground-color: #f9f9f9;\n}\n\n.content-connect-picker-search-item.searching .spinner[data-v-29630365] {\n\tfloat: left;\n\tmargin-top: 0;\n}\n\n.content-connect-already-added[data-v-29630365],\n.content-connect-add-button[data-v-29630365] {\n\tdisplay: inline-block;\n\tfloat: right;\n\tposition: relative;\n}\n\n.content-connect-add-button[data-v-29630365] {\n\tcolor: #0073aa;\n\tcursor: pointer;\n}\n\n.content-connect-already-added[data-v-29630365] {\n\tcolor: #aaa;\n\tfont-style: italic;\n}\n\n.content-connect-add-button[data-v-29630365]:hover {\n\tcolor: #00a0d2;\n}\n\n.content-connect-picker-pagination[data-v-29630365] {\n\theight: 3em;\n\tborder-top: 1px solid #ddd;\n\tpadding-top: 20px;\n}\n\n.content-connect-picker-pagination a[data-v-29630365] {\n\tcursor: pointer;\n}\n\n.content-connect-picker-pagination .next-page[data-v-29630365] {\n\tfloat: right;\n}") +},{"vue":52,"vue-hot-reload-api":49,"vuedraggable":54,"vueify/lib/insert-css":55}],3:[function(require,module,exports){ +var __vueify_style_dispose__ = require("vueify/lib/insert-css").insert("*[data-v-76c3e988] {\n\tbox-sizing: border-box;\n}\n\n.content-connect-picker-search-container[data-v-76c3e988] {\n\tpadding-bottom: 20px;\n}\n\n.content-connect-picker-search-input-label[data-v-76c3e988] {\n\tdisplay: block;\n}\n\n.content-connect-picker-search-input-container form[data-v-76c3e988] {\n\tdisplay: flex;\n}\n\n.content-connect-picker-search-input[data-v-76c3e988] {\n\tflex: 1;\n\tmargin-right: 0.5em;\n}\n\n.content-connect-picker-search-item[data-v-76c3e988] {\n\twidth: 100%;\n\tposition: relative;\n\tpadding: 1em 1em 1em 0.5em;\n}\n\n.content-connect-picker-search-item.result[data-v-76c3e988]:nth-child(odd) {\n\tbackground-color: #f9f9f9;\n}\n\n.content-connect-picker-search-item.searching .spinner[data-v-76c3e988] {\n\tfloat: left;\n\tmargin-top: 0;\n}\n\n.content-connect-already-added[data-v-76c3e988],\n.content-connect-add-button[data-v-76c3e988] {\n\tdisplay: inline-block;\n\tfloat: right;\n\tposition: relative;\n}\n\n.content-connect-add-button[data-v-76c3e988] {\n\tcolor: #0073aa;\n\tcursor: pointer;\n}\n\n.content-connect-already-added[data-v-76c3e988] {\n\tcolor: #aaa;\n\tfont-style: italic;\n}\n\n.content-connect-add-button[data-v-76c3e988]:hover {\n\tcolor: #00a0d2;\n}\n\n.content-connect-picker-pagination[data-v-76c3e988] {\n\theight: 3em;\n\tborder-top: 1px solid #ddd;\n\tpadding-top: 20px;\n}\n\n.content-connect-picker-pagination a[data-v-76c3e988] {\n\tcursor: pointer;\n}\n\n.content-connect-picker-pagination .next-page[data-v-76c3e988] {\n\tfloat: right;\n}") ;(function(){ 'use strict'; @@ -289,21 +289,21 @@ exports.default = { if (module.exports.__esModule) module.exports = module.exports.default var __vue__options__ = (typeof module.exports === "function"? module.exports.options: module.exports) if (__vue__options__.functional) {console.error("[vueify] functional components are not supported and should be defined in plain js files using render functions.")} -__vue__options__.render = function render () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"content-connect-picker-search-container"},[_c('label',{staticClass:"content-connect-picker-search-input-label",attrs:{"for":_vm._uid}},[_vm._v("Search")]),_vm._v(" "),_c('div',{staticClass:"content-connect-picker-search-input-container"},[_c('form',{on:{"submit":function($event){$event.preventDefault();_vm.search($event)}}},[_c('input',{directives:[{name:"model",rawName:"v-model",value:(_vm.searchtext),expression:"searchtext"}],staticClass:"content-connect-picker-search-input widefat",attrs:{"type":"text","id":_vm._uid},domProps:{"value":(_vm.searchtext)},on:{"input":function($event){if($event.target.composing){ return; }_vm.searchtext=$event.target.value}}}),_vm._v(" "),_c('button',{staticClass:"button",attrs:{"type":"submit"}},[_vm._v("Search")])])]),_vm._v(" "),_c('ul',{staticClass:"content-connect-picker-search-list"},[_vm._l((_vm.results),function(result){return _c('li',{staticClass:"content-connect-picker-search-item result"},[_c('span',{staticClass:"content-connect-selected-item-name"},[_vm._v(_vm._s(result.name))]),_vm._v(" "),(!result.added)?_c('span',{staticClass:"add-item content-connect-add-button",on:{"click":function($event){$event.preventDefault();$event.stopPropagation();_vm.add(result)}}},[_vm._v("add")]):_vm._e(),_vm._v(" "),(result.added)?_c('span',{staticClass:"add-item content-connect-already-added"},[_vm._v("Added")]):_vm._e()])}),_vm._v(" "),(_vm.searching)?_c('li',{staticClass:"content-connect-picker-search-item searching"},[_vm._m(0)]):_vm._e(),_vm._v(" "),(! _vm.searching && _vm.searcherror.length > 0)?_c('li',{staticClass:"content-connect-picker-search-item error"},[_c('p',{staticClass:"error"},[_vm._v(_vm._s(_vm.searcherror))])]):_vm._e()],2),_vm._v(" "),(! _vm.searching && ( _vm.morePages || _vm.prevPages ))?_c('div',{staticClass:"content-connect-picker-pagination"},[(_vm.prevPages)?_c('a',{staticClass:"prev-page",on:{"click":function($event){$event.preventDefault();$event.stopPropagation();_vm.prevPage()}}},[_vm._v("‹ Previous Page")]):_vm._e(),_vm._v(" "),(_vm.morePages)?_c('a',{staticClass:"next-page",on:{"click":function($event){$event.preventDefault();$event.stopPropagation();_vm.nextPage()}}},[_vm._v("Next Page ›")]):_vm._e()]):_vm._e()])} +__vue__options__.render = function render () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"content-connect-picker-search-container"},[_c('label',{staticClass:"content-connect-picker-search-input-label",attrs:{"for":_vm._uid}},[_vm._v("Search")]),_vm._v(" "),_c('div',{staticClass:"content-connect-picker-search-input-container"},[_c('form',{on:{"submit":function($event){$event.preventDefault();return _vm.search.apply(null, arguments)}}},[_c('input',{directives:[{name:"model",rawName:"v-model",value:(_vm.searchtext),expression:"searchtext"}],staticClass:"content-connect-picker-search-input widefat",attrs:{"type":"text","id":_vm._uid},domProps:{"value":(_vm.searchtext)},on:{"input":function($event){if($event.target.composing){ return; }_vm.searchtext=$event.target.value}}}),_vm._v(" "),_c('button',{staticClass:"button",attrs:{"type":"submit"}},[_vm._v("Search")])])]),_vm._v(" "),_c('ul',{staticClass:"content-connect-picker-search-list"},[_vm._l((_vm.results),function(result){return _c('li',{staticClass:"content-connect-picker-search-item result"},[_c('span',{staticClass:"content-connect-selected-item-name"},[_vm._v(_vm._s(result.name))]),_vm._v(" "),(!result.added)?_c('span',{staticClass:"add-item content-connect-add-button",on:{"click":function($event){$event.preventDefault();$event.stopPropagation();return _vm.add(result)}}},[_vm._v("add")]):_vm._e(),_vm._v(" "),(result.added)?_c('span',{staticClass:"add-item content-connect-already-added"},[_vm._v("Added")]):_vm._e()])}),_vm._v(" "),(_vm.searching)?_c('li',{staticClass:"content-connect-picker-search-item searching"},[_vm._m(0)]):_vm._e(),_vm._v(" "),(! _vm.searching && _vm.searcherror.length > 0)?_c('li',{staticClass:"content-connect-picker-search-item error"},[_c('p',{staticClass:"error"},[_vm._v(_vm._s(_vm.searcherror))])]):_vm._e()],2),_vm._v(" "),(! _vm.searching && ( _vm.morePages || _vm.prevPages ))?_c('div',{staticClass:"content-connect-picker-pagination"},[(_vm.prevPages)?_c('a',{staticClass:"prev-page",on:{"click":function($event){$event.preventDefault();$event.stopPropagation();return _vm.prevPage()}}},[_vm._v("‹ Previous Page")]):_vm._e(),_vm._v(" "),(_vm.morePages)?_c('a',{staticClass:"next-page",on:{"click":function($event){$event.preventDefault();$event.stopPropagation();return _vm.nextPage()}}},[_vm._v("Next Page ›")]):_vm._e()]):_vm._e()])} __vue__options__.staticRenderFns = [function render () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('p',[_c('span',{staticClass:"spinner is-active"}),_vm._v("\n\t\t\t\tSearching...\n\t\t\t")])}] -__vue__options__._scopeId = "data-v-29630365" +__vue__options__._scopeId = "data-v-76c3e988" if (module.hot) {(function () { var hotAPI = require("vue-hot-reload-api") hotAPI.install(require("vue"), true) if (!hotAPI.compatible) return module.hot.accept() module.hot.dispose(__vueify_style_dispose__) if (!module.hot.data) { - hotAPI.createRecord("data-v-29630365", __vue__options__) + hotAPI.createRecord("data-v-76c3e988", __vue__options__) } else { - hotAPI.reload("data-v-29630365", __vue__options__) + hotAPI.reload("data-v-76c3e988", __vue__options__) } })()} -},{"vue":50,"vue-hot-reload-api":48,"vueify/lib/insert-css":52}],4:[function(require,module,exports){ +},{"vue":52,"vue-hot-reload-api":49,"vueify/lib/insert-css":55}],4:[function(require,module,exports){ var Vue = require( 'vue' ); var App = require( './App.vue' ); @@ -321,7 +321,7 @@ window.ContentConnectApp = new Vue({ }).$mount( '#tenup-content-connect-app' ); -},{"./App.vue":1,"vue":50,"vue-resource":49}],5:[function(require,module,exports){ +},{"./App.vue":1,"vue":52,"vue-resource":50}],5:[function(require,module,exports){ module.exports = { "default": require("core-js/library/fn/json/stringify"), __esModule: true }; },{"core-js/library/fn/json/stringify":8}],6:[function(require,module,exports){ module.exports = { "default": require("core-js/library/fn/object/assign"), __esModule: true }; @@ -338,7 +338,7 @@ module.exports = function stringify(it) { // eslint-disable-line no-unused-vars require('../../modules/es6.object.assign'); module.exports = require('../../modules/_core').Object.assign; -},{"../../modules/_core":14,"../../modules/es6.object.assign":44}],10:[function(require,module,exports){ +},{"../../modules/_core":14,"../../modules/es6.object.assign":45}],10:[function(require,module,exports){ module.exports = function (it) { if (typeof it != 'function') throw TypeError(it + ' is not a function!'); return it; @@ -376,7 +376,7 @@ module.exports = function (IS_INCLUDES) { }; }; -},{"./_to-absolute-index":37,"./_to-iobject":39,"./_to-length":40}],13:[function(require,module,exports){ +},{"./_to-absolute-index":38,"./_to-iobject":40,"./_to-length":41}],13:[function(require,module,exports){ var toString = {}.toString; module.exports = function (it) { @@ -384,7 +384,7 @@ module.exports = function (it) { }; },{}],14:[function(require,module,exports){ -var core = module.exports = { version: '2.5.1' }; +var core = module.exports = { version: '2.6.12' }; if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef },{}],15:[function(require,module,exports){ @@ -442,6 +442,7 @@ var global = require('./_global'); var core = require('./_core'); var ctx = require('./_ctx'); var hide = require('./_hide'); +var has = require('./_has'); var PROTOTYPE = 'prototype'; var $export = function (type, name, source) { @@ -459,7 +460,7 @@ var $export = function (type, name, source) { for (key in source) { // contains in native own = !IS_FORCED && target && target[key] !== undefined; - if (own && key in exports) continue; + if (own && has(exports, key)) continue; // export native or passed out = own ? target[key] : source[key]; // prevent global pollution for namespaces @@ -500,7 +501,7 @@ $export.U = 64; // safe $export.R = 128; // real proto method for `library` module.exports = $export; -},{"./_core":14,"./_ctx":15,"./_global":22,"./_hide":24}],21:[function(require,module,exports){ +},{"./_core":14,"./_ctx":15,"./_global":22,"./_has":23,"./_hide":24}],21:[function(require,module,exports){ module.exports = function (exec) { try { return !!exec(); @@ -533,7 +534,7 @@ module.exports = require('./_descriptors') ? function (object, key, value) { return object; }; -},{"./_descriptors":17,"./_object-dp":29,"./_property-desc":34}],25:[function(require,module,exports){ +},{"./_descriptors":17,"./_object-dp":30,"./_property-desc":35}],25:[function(require,module,exports){ module.exports = !require('./_descriptors') && !require('./_fails')(function () { return Object.defineProperty(require('./_dom-create')('div'), 'a', { get: function () { return 7; } }).a != 7; }); @@ -552,8 +553,12 @@ module.exports = function (it) { }; },{}],28:[function(require,module,exports){ +module.exports = true; + +},{}],29:[function(require,module,exports){ 'use strict'; // 19.1.2.1 Object.assign(target, source, ...) +var DESCRIPTORS = require('./_descriptors'); var getKeys = require('./_object-keys'); var gOPS = require('./_object-gops'); var pIE = require('./_object-pie'); @@ -583,11 +588,14 @@ module.exports = !$assign || require('./_fails')(function () { var length = keys.length; var j = 0; var key; - while (length > j) if (isEnum.call(S, key = keys[j++])) T[key] = S[key]; + while (length > j) { + key = keys[j++]; + if (!DESCRIPTORS || isEnum.call(S, key)) T[key] = S[key]; + } } return T; } : $assign; -},{"./_fails":21,"./_iobject":26,"./_object-gops":30,"./_object-keys":32,"./_object-pie":33,"./_to-object":41}],29:[function(require,module,exports){ +},{"./_descriptors":17,"./_fails":21,"./_iobject":26,"./_object-gops":31,"./_object-keys":33,"./_object-pie":34,"./_to-object":42}],30:[function(require,module,exports){ var anObject = require('./_an-object'); var IE8_DOM_DEFINE = require('./_ie8-dom-define'); var toPrimitive = require('./_to-primitive'); @@ -605,10 +613,10 @@ exports.f = require('./_descriptors') ? Object.defineProperty : function defineP return O; }; -},{"./_an-object":11,"./_descriptors":17,"./_ie8-dom-define":25,"./_to-primitive":42}],30:[function(require,module,exports){ +},{"./_an-object":11,"./_descriptors":17,"./_ie8-dom-define":25,"./_to-primitive":43}],31:[function(require,module,exports){ exports.f = Object.getOwnPropertySymbols; -},{}],31:[function(require,module,exports){ +},{}],32:[function(require,module,exports){ var has = require('./_has'); var toIObject = require('./_to-iobject'); var arrayIndexOf = require('./_array-includes')(false); @@ -627,7 +635,7 @@ module.exports = function (object, names) { return result; }; -},{"./_array-includes":12,"./_has":23,"./_shared-key":35,"./_to-iobject":39}],32:[function(require,module,exports){ +},{"./_array-includes":12,"./_has":23,"./_shared-key":36,"./_to-iobject":40}],33:[function(require,module,exports){ // 19.1.2.14 / 15.2.3.14 Object.keys(O) var $keys = require('./_object-keys-internal'); var enumBugKeys = require('./_enum-bug-keys'); @@ -636,10 +644,10 @@ module.exports = Object.keys || function keys(O) { return $keys(O, enumBugKeys); }; -},{"./_enum-bug-keys":19,"./_object-keys-internal":31}],33:[function(require,module,exports){ +},{"./_enum-bug-keys":19,"./_object-keys-internal":32}],34:[function(require,module,exports){ exports.f = {}.propertyIsEnumerable; -},{}],34:[function(require,module,exports){ +},{}],35:[function(require,module,exports){ module.exports = function (bitmap, value) { return { enumerable: !(bitmap & 1), @@ -649,22 +657,28 @@ module.exports = function (bitmap, value) { }; }; -},{}],35:[function(require,module,exports){ +},{}],36:[function(require,module,exports){ var shared = require('./_shared')('keys'); var uid = require('./_uid'); module.exports = function (key) { return shared[key] || (shared[key] = uid(key)); }; -},{"./_shared":36,"./_uid":43}],36:[function(require,module,exports){ +},{"./_shared":37,"./_uid":44}],37:[function(require,module,exports){ +var core = require('./_core'); var global = require('./_global'); var SHARED = '__core-js_shared__'; var store = global[SHARED] || (global[SHARED] = {}); -module.exports = function (key) { - return store[key] || (store[key] = {}); -}; -},{"./_global":22}],37:[function(require,module,exports){ +(module.exports = function (key, value) { + return store[key] || (store[key] = value !== undefined ? value : {}); +})('versions', []).push({ + version: core.version, + mode: require('./_library') ? 'pure' : 'global', + copyright: '© 2020 Denis Pushkarev (zloirock.ru)' +}); + +},{"./_core":14,"./_global":22,"./_library":28}],38:[function(require,module,exports){ var toInteger = require('./_to-integer'); var max = Math.max; var min = Math.min; @@ -673,7 +687,7 @@ module.exports = function (index, length) { return index < 0 ? max(index + length, 0) : min(index, length); }; -},{"./_to-integer":38}],38:[function(require,module,exports){ +},{"./_to-integer":39}],39:[function(require,module,exports){ // 7.1.4 ToInteger var ceil = Math.ceil; var floor = Math.floor; @@ -681,7 +695,7 @@ module.exports = function (it) { return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it); }; -},{}],39:[function(require,module,exports){ +},{}],40:[function(require,module,exports){ // to indexed object, toObject with fallback for non-array-like ES3 strings var IObject = require('./_iobject'); var defined = require('./_defined'); @@ -689,7 +703,7 @@ module.exports = function (it) { return IObject(defined(it)); }; -},{"./_defined":16,"./_iobject":26}],40:[function(require,module,exports){ +},{"./_defined":16,"./_iobject":26}],41:[function(require,module,exports){ // 7.1.15 ToLength var toInteger = require('./_to-integer'); var min = Math.min; @@ -697,14 +711,14 @@ module.exports = function (it) { return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 }; -},{"./_to-integer":38}],41:[function(require,module,exports){ +},{"./_to-integer":39}],42:[function(require,module,exports){ // 7.1.13 ToObject(argument) var defined = require('./_defined'); module.exports = function (it) { return Object(defined(it)); }; -},{"./_defined":16}],42:[function(require,module,exports){ +},{"./_defined":16}],43:[function(require,module,exports){ // 7.1.1 ToPrimitive(input [, PreferredType]) var isObject = require('./_is-object'); // instead of the ES6 spec version, we didn't implement @@toPrimitive case @@ -718,20 +732,20 @@ module.exports = function (it, S) { throw TypeError("Can't convert object to primitive value"); }; -},{"./_is-object":27}],43:[function(require,module,exports){ +},{"./_is-object":27}],44:[function(require,module,exports){ var id = 0; var px = Math.random(); module.exports = function (key) { return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); }; -},{}],44:[function(require,module,exports){ +},{}],45:[function(require,module,exports){ // 19.1.3.1 Object.assign(target, source) var $export = require('./_export'); $export($export.S + $export.F, 'Object', { assign: require('./_object-assign') }); -},{"./_export":20,"./_object-assign":28}],45:[function(require,module,exports){ +},{"./_export":20,"./_object-assign":29}],46:[function(require,module,exports){ // shim for using process in browser var process = module.exports = {}; @@ -917,8633 +931,11910 @@ process.chdir = function (dir) { }; process.umask = function() { return 0; }; -},{}],46:[function(require,module,exports){ +},{}],47:[function(require,module,exports){ /**! - * Sortable + * Sortable 1.10.2 * @author RubaXa + * @author owenm * @license MIT */ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global = global || self, global.Sortable = factory()); +}(this, function () { 'use strict'; -(function sortableModule(factory) { - "use strict"; - - if (typeof define === "function" && define.amd) { - define(factory); - } - else if (typeof module != "undefined" && typeof module.exports != "undefined") { - module.exports = factory(); - } - else { - /* jshint sub:true */ - window["Sortable"] = factory(); - } -})(function sortableFactory() { - "use strict"; + function _typeof(obj) { + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function (obj) { + return typeof obj; + }; + } else { + _typeof = function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } - if (typeof window == "undefined" || !window.document) { - return function sortableError() { - throw new Error("Sortable.js requires a window with a document"); - }; - } + return _typeof(obj); + } - var dragEl, - parentEl, - ghostEl, - cloneEl, - rootEl, - nextEl, - lastDownEl, + function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } - scrollEl, - scrollParentEl, - scrollCustomFn, + return obj; + } - lastEl, - lastCSS, - lastParentCSS, + function _extends() { + _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; - oldIndex, - newIndex, + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } - activeGroup, - putSortable, + return target; + }; - autoScroll = {}, + return _extends.apply(this, arguments); + } - tapEvt, - touchEvt, + function _objectSpread(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? arguments[i] : {}; + var ownKeys = Object.keys(source); - moved, + if (typeof Object.getOwnPropertySymbols === 'function') { + ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { + return Object.getOwnPropertyDescriptor(source, sym).enumerable; + })); + } - /** @const */ - R_SPACE = /\s+/g, - R_FLOAT = /left|right|inline/, + ownKeys.forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } - expando = 'Sortable' + (new Date).getTime(), + return target; + } - win = window, - document = win.document, - parseInt = win.parseInt, + function _objectWithoutPropertiesLoose(source, excluded) { + if (source == null) return {}; + var target = {}; + var sourceKeys = Object.keys(source); + var key, i; - $ = win.jQuery || win.Zepto, - Polymer = win.Polymer, + for (i = 0; i < sourceKeys.length; i++) { + key = sourceKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + target[key] = source[key]; + } - captureMode = false, + return target; + } - supportDraggable = !!('draggable' in document.createElement('div')), - supportCssPointerEvents = (function (el) { - // false when IE11 - if (!!navigator.userAgent.match(/Trident.*rv[ :]?11\./)) { - return false; - } - el = document.createElement('x'); - el.style.cssText = 'pointer-events:auto'; - return el.style.pointerEvents === 'auto'; - })(), - - _silent = false, - - abs = Math.abs, - min = Math.min, - - savedInputChecked = [], - touchDragOverListeners = [], - - _autoScroll = _throttle(function (/**Event*/evt, /**Object*/options, /**HTMLElement*/rootEl) { - // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=505521 - if (rootEl && options.scroll) { - var _this = rootEl[expando], - el, - rect, - sens = options.scrollSensitivity, - speed = options.scrollSpeed, - - x = evt.clientX, - y = evt.clientY, - - winWidth = window.innerWidth, - winHeight = window.innerHeight, - - vx, - vy, - - scrollOffsetX, - scrollOffsetY - ; - - // Delect scrollEl - if (scrollParentEl !== rootEl) { - scrollEl = options.scroll; - scrollParentEl = rootEl; - scrollCustomFn = options.scrollFn; - - if (scrollEl === true) { - scrollEl = rootEl; - - do { - if ((scrollEl.offsetWidth < scrollEl.scrollWidth) || - (scrollEl.offsetHeight < scrollEl.scrollHeight) - ) { - break; - } - /* jshint boss:true */ - } while (scrollEl = scrollEl.parentNode); - } - } + function _objectWithoutProperties(source, excluded) { + if (source == null) return {}; - if (scrollEl) { - el = scrollEl; - rect = scrollEl.getBoundingClientRect(); - vx = (abs(rect.right - x) <= sens) - (abs(rect.left - x) <= sens); - vy = (abs(rect.bottom - y) <= sens) - (abs(rect.top - y) <= sens); - } + var target = _objectWithoutPropertiesLoose(source, excluded); + var key, i; - if (!(vx || vy)) { - vx = (winWidth - x <= sens) - (x <= sens); - vy = (winHeight - y <= sens) - (y <= sens); + if (Object.getOwnPropertySymbols) { + var sourceSymbolKeys = Object.getOwnPropertySymbols(source); - /* jshint expr:true */ - (vx || vy) && (el = win); - } + for (i = 0; i < sourceSymbolKeys.length; i++) { + key = sourceSymbolKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; + target[key] = source[key]; + } + } + return target; + } - if (autoScroll.vx !== vx || autoScroll.vy !== vy || autoScroll.el !== el) { - autoScroll.el = el; - autoScroll.vx = vx; - autoScroll.vy = vy; + function _toConsumableArray(arr) { + return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); + } - clearInterval(autoScroll.pid); + function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) { + for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; - if (el) { - autoScroll.pid = setInterval(function () { - scrollOffsetY = vy ? vy * speed : 0; - scrollOffsetX = vx ? vx * speed : 0; + return arr2; + } + } - if ('function' === typeof(scrollCustomFn)) { - return scrollCustomFn.call(_this, scrollOffsetX, scrollOffsetY, evt); - } + function _iterableToArray(iter) { + if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); + } - if (el === win) { - win.scrollTo(win.pageXOffset + scrollOffsetX, win.pageYOffset + scrollOffsetY); - } else { - el.scrollTop += scrollOffsetY; - el.scrollLeft += scrollOffsetX; - } - }, 24); - } - } - } - }, 30), + function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance"); + } - _prepareGroup = function (options) { - function toFn(value, pull) { - if (value === void 0 || value === true) { - value = group.name; - } + var version = "1.10.2"; - if (typeof value === 'function') { - return value; - } else { - return function (to, from) { - var fromGroup = from.options.group.name; - - return pull - ? value - : value && (value.join - ? value.indexOf(fromGroup) > -1 - : (fromGroup == value) - ); - }; - } - } + function userAgent(pattern) { + if (typeof window !== 'undefined' && window.navigator) { + return !! + /*@__PURE__*/ + navigator.userAgent.match(pattern); + } + } - var group = {}; - var originalGroup = options.group; + var IE11OrLess = userAgent(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i); + var Edge = userAgent(/Edge/i); + var FireFox = userAgent(/firefox/i); + var Safari = userAgent(/safari/i) && !userAgent(/chrome/i) && !userAgent(/android/i); + var IOS = userAgent(/iP(ad|od|hone)/i); + var ChromeForAndroid = userAgent(/chrome/i) && userAgent(/android/i); - if (!originalGroup || typeof originalGroup != 'object') { - originalGroup = {name: originalGroup}; - } + var captureMode = { + capture: false, + passive: false + }; - group.name = originalGroup.name; - group.checkPull = toFn(originalGroup.pull, true); - group.checkPut = toFn(originalGroup.put); - group.revertClone = originalGroup.revertClone; + function on(el, event, fn) { + el.addEventListener(event, fn, !IE11OrLess && captureMode); + } - options.group = group; - } - ; + function off(el, event, fn) { + el.removeEventListener(event, fn, !IE11OrLess && captureMode); + } + function matches( + /**HTMLElement*/ + el, + /**String*/ + selector) { + if (!selector) return; + selector[0] === '>' && (selector = selector.substring(1)); - /** - * @class Sortable - * @param {HTMLElement} el - * @param {Object} [options] - */ - function Sortable(el, options) { - if (!(el && el.nodeType && el.nodeType === 1)) { - throw 'Sortable: `el` must be HTMLElement, and not ' + {}.toString.call(el); - } + if (el) { + try { + if (el.matches) { + return el.matches(selector); + } else if (el.msMatchesSelector) { + return el.msMatchesSelector(selector); + } else if (el.webkitMatchesSelector) { + return el.webkitMatchesSelector(selector); + } + } catch (_) { + return false; + } + } - this.el = el; // root element - this.options = options = _extend({}, options); - - - // Export instance - el[expando] = this; - - // Default options - var defaults = { - group: Math.random(), - sort: true, - disabled: false, - store: null, - handle: null, - scroll: true, - scrollSensitivity: 30, - scrollSpeed: 10, - draggable: /[uo]l/i.test(el.nodeName) ? 'li' : '>*', - ghostClass: 'sortable-ghost', - chosenClass: 'sortable-chosen', - dragClass: 'sortable-drag', - ignore: 'a, img', - filter: null, - preventOnFilter: true, - animation: 0, - setData: function (dataTransfer, dragEl) { - dataTransfer.setData('Text', dragEl.textContent); - }, - dropBubble: false, - dragoverBubble: false, - dataIdAttr: 'data-id', - delay: 0, - forceFallback: false, - fallbackClass: 'sortable-fallback', - fallbackOnBody: false, - fallbackTolerance: 0, - fallbackOffset: {x: 0, y: 0} - }; + return false; + } + function getParentOrHost(el) { + return el.host && el !== document && el.host.nodeType ? el.host : el.parentNode; + } - // Set default options - for (var name in defaults) { - !(name in options) && (options[name] = defaults[name]); - } + function closest( + /**HTMLElement*/ + el, + /**String*/ + selector, + /**HTMLElement*/ + ctx, includeCTX) { + if (el) { + ctx = ctx || document; + + do { + if (selector != null && (selector[0] === '>' ? el.parentNode === ctx && matches(el, selector) : matches(el, selector)) || includeCTX && el === ctx) { + return el; + } - _prepareGroup(options); + if (el === ctx) break; + /* jshint boss:true */ + } while (el = getParentOrHost(el)); + } - // Bind all private methods - for (var fn in this) { - if (fn.charAt(0) === '_' && typeof this[fn] === 'function') { - this[fn] = this[fn].bind(this); - } - } + return null; + } - // Setup drag mode - this.nativeDraggable = options.forceFallback ? false : supportDraggable; + var R_SPACE = /\s+/g; - // Bind events - _on(el, 'mousedown', this._onTapStart); - _on(el, 'touchstart', this._onTapStart); - _on(el, 'pointerdown', this._onTapStart); + function toggleClass(el, name, state) { + if (el && name) { + if (el.classList) { + el.classList[state ? 'add' : 'remove'](name); + } else { + var className = (' ' + el.className + ' ').replace(R_SPACE, ' ').replace(' ' + name + ' ', ' '); + el.className = (className + (state ? ' ' + name : '')).replace(R_SPACE, ' '); + } + } + } - if (this.nativeDraggable) { - _on(el, 'dragover', this); - _on(el, 'dragenter', this); - } + function css(el, prop, val) { + var style = el && el.style; - touchDragOverListeners.push(this._onDragOver); + if (style) { + if (val === void 0) { + if (document.defaultView && document.defaultView.getComputedStyle) { + val = document.defaultView.getComputedStyle(el, ''); + } else if (el.currentStyle) { + val = el.currentStyle; + } - // Restore sorting - options.store && this.sort(options.store.get(this)); - } + return prop === void 0 ? val : val[prop]; + } else { + if (!(prop in style) && prop.indexOf('webkit') === -1) { + prop = '-webkit-' + prop; + } + style[prop] = val + (typeof val === 'string' ? '' : 'px'); + } + } + } - Sortable.prototype = /** @lends Sortable.prototype */ { - constructor: Sortable, + function matrix(el, selfOnly) { + var appliedTransforms = ''; - _onTapStart: function (/** Event|TouchEvent */evt) { - var _this = this, - el = this.el, - options = this.options, - preventOnFilter = options.preventOnFilter, - type = evt.type, - touch = evt.touches && evt.touches[0], - target = (touch || evt).target, - originalTarget = evt.target.shadowRoot && (evt.path && evt.path[0]) || target, - filter = options.filter, - startIndex; + if (typeof el === 'string') { + appliedTransforms = el; + } else { + do { + var transform = css(el, 'transform'); - _saveInputCheckedState(el); + if (transform && transform !== 'none') { + appliedTransforms = transform + ' ' + appliedTransforms; + } + /* jshint boss:true */ + } while (!selfOnly && (el = el.parentNode)); + } - // Don't trigger start event when an element is been dragged, otherwise the evt.oldindex always wrong when set option.group. - if (dragEl) { - return; - } + var matrixFn = window.DOMMatrix || window.WebKitCSSMatrix || window.CSSMatrix || window.MSCSSMatrix; + /*jshint -W056 */ - if (/mousedown|pointerdown/.test(type) && evt.button !== 0 || options.disabled) { - return; // only left button or enabled - } + return matrixFn && new matrixFn(appliedTransforms); + } + function find(ctx, tagName, iterator) { + if (ctx) { + var list = ctx.getElementsByTagName(tagName), + i = 0, + n = list.length; - target = _closest(target, options.draggable, el); + if (iterator) { + for (; i < n; i++) { + iterator(list[i], i); + } + } - if (!target) { - return; - } + return list; + } - if (lastDownEl === target) { - // Ignoring duplicate `down` - return; - } + return []; + } - // Get the index of the dragged element within its parent - startIndex = _index(target, options.draggable); + function getWindowScrollingElement() { + var scrollingElement = document.scrollingElement; - // Check filter - if (typeof filter === 'function') { - if (filter.call(this, evt, target, this)) { - _dispatchEvent(_this, originalTarget, 'filter', target, el, startIndex); - preventOnFilter && evt.preventDefault(); - return; // cancel dnd - } - } - else if (filter) { - filter = filter.split(',').some(function (criteria) { - criteria = _closest(originalTarget, criteria.trim(), el); + if (scrollingElement) { + return scrollingElement; + } else { + return document.documentElement; + } + } + /** + * Returns the "bounding client rect" of given element + * @param {HTMLElement} el The element whose boundingClientRect is wanted + * @param {[Boolean]} relativeToContainingBlock Whether the rect should be relative to the containing block of (including) the container + * @param {[Boolean]} relativeToNonStaticParent Whether the rect should be relative to the relative parent of (including) the contaienr + * @param {[Boolean]} undoScale Whether the container's scale() should be undone + * @param {[HTMLElement]} container The parent the element will be placed in + * @return {Object} The boundingClientRect of el, with specified adjustments + */ - if (criteria) { - _dispatchEvent(_this, criteria, 'filter', target, el, startIndex); - return true; - } - }); - if (filter) { - preventOnFilter && evt.preventDefault(); - return; // cancel dnd - } - } + function getRect(el, relativeToContainingBlock, relativeToNonStaticParent, undoScale, container) { + if (!el.getBoundingClientRect && el !== window) return; + var elRect, top, left, bottom, right, height, width; - if (options.handle && !_closest(originalTarget, options.handle, el)) { - return; - } + if (el !== window && el !== getWindowScrollingElement()) { + elRect = el.getBoundingClientRect(); + top = elRect.top; + left = elRect.left; + bottom = elRect.bottom; + right = elRect.right; + height = elRect.height; + width = elRect.width; + } else { + top = 0; + left = 0; + bottom = window.innerHeight; + right = window.innerWidth; + height = window.innerHeight; + width = window.innerWidth; + } + + if ((relativeToContainingBlock || relativeToNonStaticParent) && el !== window) { + // Adjust for translate() + container = container || el.parentNode; // solves #1123 (see: https://stackoverflow.com/a/37953806/6088312) + // Not needed on <= IE11 + + if (!IE11OrLess) { + do { + if (container && container.getBoundingClientRect && (css(container, 'transform') !== 'none' || relativeToNonStaticParent && css(container, 'position') !== 'static')) { + var containerRect = container.getBoundingClientRect(); // Set relative to edges of padding box of container + + top -= containerRect.top + parseInt(css(container, 'border-top-width')); + left -= containerRect.left + parseInt(css(container, 'border-left-width')); + bottom = top + elRect.height; + right = left + elRect.width; + break; + } + /* jshint boss:true */ - // Prepare `dragstart` - this._prepareDragStart(evt, touch, target, startIndex); - }, + } while (container = container.parentNode); + } + } - _prepareDragStart: function (/** Event */evt, /** Touch */touch, /** HTMLElement */target, /** Number */startIndex) { - var _this = this, - el = _this.el, - options = _this.options, - ownerDocument = el.ownerDocument, - dragStartFn; + if (undoScale && el !== window) { + // Adjust for scale() + var elMatrix = matrix(container || el), + scaleX = elMatrix && elMatrix.a, + scaleY = elMatrix && elMatrix.d; - if (target && !dragEl && (target.parentNode === el)) { - tapEvt = evt; + if (elMatrix) { + top /= scaleY; + left /= scaleX; + width /= scaleX; + height /= scaleY; + bottom = top + height; + right = left + width; + } + } - rootEl = el; - dragEl = target; - parentEl = dragEl.parentNode; - nextEl = dragEl.nextSibling; - lastDownEl = target; - activeGroup = options.group; - oldIndex = startIndex; + return { + top: top, + left: left, + bottom: bottom, + right: right, + width: width, + height: height + }; + } + /** + * Checks if a side of an element is scrolled past a side of its parents + * @param {HTMLElement} el The element who's side being scrolled out of view is in question + * @param {String} elSide Side of the element in question ('top', 'left', 'right', 'bottom') + * @param {String} parentSide Side of the parent in question ('top', 'left', 'right', 'bottom') + * @return {HTMLElement} The parent scroll element that the el's side is scrolled past, or null if there is no such element + */ - this._lastX = (touch || evt).clientX; - this._lastY = (touch || evt).clientY; - dragEl.style['will-change'] = 'transform'; + function isScrolledPast(el, elSide, parentSide) { + var parent = getParentAutoScrollElement(el, true), + elSideVal = getRect(el)[elSide]; + /* jshint boss:true */ - dragStartFn = function () { - // Delayed drag has been triggered - // we can re-enable the events: touchmove/mousemove - _this._disableDelayedDrag(); + while (parent) { + var parentSideVal = getRect(parent)[parentSide], + visible = void 0; - // Make the element draggable - dragEl.draggable = _this.nativeDraggable; + if (parentSide === 'top' || parentSide === 'left') { + visible = elSideVal >= parentSideVal; + } else { + visible = elSideVal <= parentSideVal; + } - // Chosen item - _toggleClass(dragEl, options.chosenClass, true); + if (!visible) return parent; + if (parent === getWindowScrollingElement()) break; + parent = getParentAutoScrollElement(parent, false); + } - // Bind the events: dragstart/dragend - _this._triggerDragStart(evt, touch); + return false; + } + /** + * Gets nth child of el, ignoring hidden children, sortable's elements (does not ignore clone if it's visible) + * and non-draggable elements + * @param {HTMLElement} el The parent element + * @param {Number} childNum The index of the child + * @param {Object} options Parent Sortable's options + * @return {HTMLElement} The child at index childNum, or null if not found + */ - // Drag start event - _dispatchEvent(_this, rootEl, 'choose', dragEl, rootEl, oldIndex); - }; - // Disable "draggable" - options.ignore.split(',').forEach(function (criteria) { - _find(dragEl, criteria.trim(), _disableDraggable); - }); - - _on(ownerDocument, 'mouseup', _this._onDrop); - _on(ownerDocument, 'touchend', _this._onDrop); - _on(ownerDocument, 'touchcancel', _this._onDrop); - _on(ownerDocument, 'pointercancel', _this._onDrop); - _on(ownerDocument, 'selectstart', _this); - - if (options.delay) { - // If the user moves the pointer or let go the click or touch - // before the delay has been reached: - // disable the delayed drag - _on(ownerDocument, 'mouseup', _this._disableDelayedDrag); - _on(ownerDocument, 'touchend', _this._disableDelayedDrag); - _on(ownerDocument, 'touchcancel', _this._disableDelayedDrag); - _on(ownerDocument, 'mousemove', _this._disableDelayedDrag); - _on(ownerDocument, 'touchmove', _this._disableDelayedDrag); - _on(ownerDocument, 'pointermove', _this._disableDelayedDrag); - - _this._dragStartTimer = setTimeout(dragStartFn, options.delay); - } else { - dragStartFn(); - } + function getChild(el, childNum, options) { + var currentChild = 0, + i = 0, + children = el.children; + while (i < children.length) { + if (children[i].style.display !== 'none' && children[i] !== Sortable.ghost && children[i] !== Sortable.dragged && closest(children[i], options.draggable, el, false)) { + if (currentChild === childNum) { + return children[i]; + } - } - }, + currentChild++; + } - _disableDelayedDrag: function () { - var ownerDocument = this.el.ownerDocument; + i++; + } - clearTimeout(this._dragStartTimer); - _off(ownerDocument, 'mouseup', this._disableDelayedDrag); - _off(ownerDocument, 'touchend', this._disableDelayedDrag); - _off(ownerDocument, 'touchcancel', this._disableDelayedDrag); - _off(ownerDocument, 'mousemove', this._disableDelayedDrag); - _off(ownerDocument, 'touchmove', this._disableDelayedDrag); - _off(ownerDocument, 'pointermove', this._disableDelayedDrag); - }, + return null; + } + /** + * Gets the last child in the el, ignoring ghostEl or invisible elements (clones) + * @param {HTMLElement} el Parent element + * @param {selector} selector Any other elements that should be ignored + * @return {HTMLElement} The last child, ignoring ghostEl + */ - _triggerDragStart: function (/** Event */evt, /** Touch */touch) { - touch = touch || (evt.pointerType == 'touch' ? evt : null); - if (touch) { - // Touch device support - tapEvt = { - target: dragEl, - clientX: touch.clientX, - clientY: touch.clientY - }; + function lastChild(el, selector) { + var last = el.lastElementChild; - this._onDragStart(tapEvt, 'touch'); - } - else if (!this.nativeDraggable) { - this._onDragStart(tapEvt, true); - } - else { - _on(dragEl, 'dragend', this); - _on(rootEl, 'dragstart', this._onDragStart); - } + while (last && (last === Sortable.ghost || css(last, 'display') === 'none' || selector && !matches(last, selector))) { + last = last.previousElementSibling; + } - try { - if (document.selection) { - // Timeout neccessary for IE9 - setTimeout(function () { - document.selection.empty(); - }); - } else { - window.getSelection().removeAllRanges(); - } - } catch (err) { - } - }, + return last || null; + } + /** + * Returns the index of an element within its parent for a selected set of + * elements + * @param {HTMLElement} el + * @param {selector} selector + * @return {number} + */ - _dragStarted: function () { - if (rootEl && dragEl) { - var options = this.options; - // Apply effect - _toggleClass(dragEl, options.ghostClass, true); - _toggleClass(dragEl, options.dragClass, false); + function index(el, selector) { + var index = 0; - Sortable.active = this; + if (!el || !el.parentNode) { + return -1; + } + /* jshint boss:true */ - // Drag start event - _dispatchEvent(this, rootEl, 'start', dragEl, rootEl, oldIndex); - } else { - this._nulling(); - } - }, - _emulateDragOver: function () { - if (touchEvt) { - if (this._lastX === touchEvt.clientX && this._lastY === touchEvt.clientY) { - return; - } + while (el = el.previousElementSibling) { + if (el.nodeName.toUpperCase() !== 'TEMPLATE' && el !== Sortable.clone && (!selector || matches(el, selector))) { + index++; + } + } - this._lastX = touchEvt.clientX; - this._lastY = touchEvt.clientY; + return index; + } + /** + * Returns the scroll offset of the given element, added with all the scroll offsets of parent elements. + * The value is returned in real pixels. + * @param {HTMLElement} el + * @return {Array} Offsets in the format of [left, top] + */ - if (!supportCssPointerEvents) { - _css(ghostEl, 'display', 'none'); - } - var target = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY), - parent = target, - i = touchDragOverListeners.length; - - if (parent) { - do { - if (parent[expando]) { - while (i--) { - touchDragOverListeners[i]({ - clientX: touchEvt.clientX, - clientY: touchEvt.clientY, - target: target, - rootEl: parent - }); - } - - break; - } - - target = parent; // store last element - } - /* jshint boss:true */ - while (parent = parent.parentNode); - } + function getRelativeScrollOffset(el) { + var offsetLeft = 0, + offsetTop = 0, + winScroller = getWindowScrollingElement(); - if (!supportCssPointerEvents) { - _css(ghostEl, 'display', ''); - } - } - }, + if (el) { + do { + var elMatrix = matrix(el), + scaleX = elMatrix.a, + scaleY = elMatrix.d; + offsetLeft += el.scrollLeft * scaleX; + offsetTop += el.scrollTop * scaleY; + } while (el !== winScroller && (el = el.parentNode)); + } + return [offsetLeft, offsetTop]; + } + /** + * Returns the index of the object within the given array + * @param {Array} arr Array that may or may not hold the object + * @param {Object} obj An object that has a key-value pair unique to and identical to a key-value pair in the object you want to find + * @return {Number} The index of the object in the array, or -1 + */ - _onTouchMove: function (/**TouchEvent*/evt) { - if (tapEvt) { - var options = this.options, - fallbackTolerance = options.fallbackTolerance, - fallbackOffset = options.fallbackOffset, - touch = evt.touches ? evt.touches[0] : evt, - dx = (touch.clientX - tapEvt.clientX) + fallbackOffset.x, - dy = (touch.clientY - tapEvt.clientY) + fallbackOffset.y, - translate3d = evt.touches ? 'translate3d(' + dx + 'px,' + dy + 'px,0)' : 'translate(' + dx + 'px,' + dy + 'px)'; - - // only set the status to dragging, when we are actually dragging - if (!Sortable.active) { - if (fallbackTolerance && - min(abs(touch.clientX - this._lastX), abs(touch.clientY - this._lastY)) < fallbackTolerance - ) { - return; - } - this._dragStarted(); - } + function indexOfObject(arr, obj) { + for (var i in arr) { + if (!arr.hasOwnProperty(i)) continue; - // as well as creating the ghost element on the document body - this._appendGhost(); + for (var key in obj) { + if (obj.hasOwnProperty(key) && obj[key] === arr[i][key]) return Number(i); + } + } - moved = true; - touchEvt = touch; + return -1; + } - _css(ghostEl, 'webkitTransform', translate3d); - _css(ghostEl, 'mozTransform', translate3d); - _css(ghostEl, 'msTransform', translate3d); - _css(ghostEl, 'transform', translate3d); + function getParentAutoScrollElement(el, includeSelf) { + // skip to window + if (!el || !el.getBoundingClientRect) return getWindowScrollingElement(); + var elem = el; + var gotSelf = false; - evt.preventDefault(); - } - }, + do { + // we don't need to get elem css if it isn't even overflowing in the first place (performance) + if (elem.clientWidth < elem.scrollWidth || elem.clientHeight < elem.scrollHeight) { + var elemCSS = css(elem); - _appendGhost: function () { - if (!ghostEl) { - var rect = dragEl.getBoundingClientRect(), - css = _css(dragEl), - options = this.options, - ghostRect; - - ghostEl = dragEl.cloneNode(true); - - _toggleClass(ghostEl, options.ghostClass, false); - _toggleClass(ghostEl, options.fallbackClass, true); - _toggleClass(ghostEl, options.dragClass, true); - - _css(ghostEl, 'top', rect.top - parseInt(css.marginTop, 10)); - _css(ghostEl, 'left', rect.left - parseInt(css.marginLeft, 10)); - _css(ghostEl, 'width', rect.width); - _css(ghostEl, 'height', rect.height); - _css(ghostEl, 'opacity', '0.8'); - _css(ghostEl, 'position', 'fixed'); - _css(ghostEl, 'zIndex', '100000'); - _css(ghostEl, 'pointerEvents', 'none'); - - options.fallbackOnBody && document.body.appendChild(ghostEl) || rootEl.appendChild(ghostEl); - - // Fixing dimensions. - ghostRect = ghostEl.getBoundingClientRect(); - _css(ghostEl, 'width', rect.width * 2 - ghostRect.width); - _css(ghostEl, 'height', rect.height * 2 - ghostRect.height); - } - }, + if (elem.clientWidth < elem.scrollWidth && (elemCSS.overflowX == 'auto' || elemCSS.overflowX == 'scroll') || elem.clientHeight < elem.scrollHeight && (elemCSS.overflowY == 'auto' || elemCSS.overflowY == 'scroll')) { + if (!elem.getBoundingClientRect || elem === document.body) return getWindowScrollingElement(); + if (gotSelf || includeSelf) return elem; + gotSelf = true; + } + } + /* jshint boss:true */ - _onDragStart: function (/**Event*/evt, /**boolean*/useFallback) { - var dataTransfer = evt.dataTransfer, - options = this.options; + } while (elem = elem.parentNode); - this._offUpEvents(); + return getWindowScrollingElement(); + } - if (activeGroup.checkPull(this, this, dragEl, evt)) { - cloneEl = _clone(dragEl); + function extend(dst, src) { + if (dst && src) { + for (var key in src) { + if (src.hasOwnProperty(key)) { + dst[key] = src[key]; + } + } + } - cloneEl.draggable = false; - cloneEl.style['will-change'] = ''; + return dst; + } - _css(cloneEl, 'display', 'none'); - _toggleClass(cloneEl, this.options.chosenClass, false); + function isRectEqual(rect1, rect2) { + return Math.round(rect1.top) === Math.round(rect2.top) && Math.round(rect1.left) === Math.round(rect2.left) && Math.round(rect1.height) === Math.round(rect2.height) && Math.round(rect1.width) === Math.round(rect2.width); + } - rootEl.insertBefore(cloneEl, dragEl); - _dispatchEvent(this, rootEl, 'clone', dragEl); - } + var _throttleTimeout; - _toggleClass(dragEl, options.dragClass, true); - - if (useFallback) { - if (useFallback === 'touch') { - // Bind touch events - _on(document, 'touchmove', this._onTouchMove); - _on(document, 'touchend', this._onDrop); - _on(document, 'touchcancel', this._onDrop); - _on(document, 'pointermove', this._onTouchMove); - _on(document, 'pointerup', this._onDrop); - } else { - // Old brwoser - _on(document, 'mousemove', this._onTouchMove); - _on(document, 'mouseup', this._onDrop); - } + function throttle(callback, ms) { + return function () { + if (!_throttleTimeout) { + var args = arguments, + _this = this; - this._loopId = setInterval(this._emulateDragOver, 50); - } - else { - if (dataTransfer) { - dataTransfer.effectAllowed = 'move'; - options.setData && options.setData.call(this, dataTransfer, dragEl); - } + if (args.length === 1) { + callback.call(_this, args[0]); + } else { + callback.apply(_this, args); + } - _on(document, 'drop', this); - setTimeout(this._dragStarted, 0); - } - }, + _throttleTimeout = setTimeout(function () { + _throttleTimeout = void 0; + }, ms); + } + }; + } - _onDragOver: function (/**Event*/evt) { - var el = this.el, - target, - dragRect, - targetRect, - revert, - options = this.options, - group = options.group, - activeSortable = Sortable.active, - isOwner = (activeGroup === group), - isMovingBetweenSortable = false, - canSort = options.sort; - - if (evt.preventDefault !== void 0) { - evt.preventDefault(); - !options.dragoverBubble && evt.stopPropagation(); - } + function cancelThrottle() { + clearTimeout(_throttleTimeout); + _throttleTimeout = void 0; + } - if (dragEl.animated) { - return; - } + function scrollBy(el, x, y) { + el.scrollLeft += x; + el.scrollTop += y; + } - moved = true; - - if (activeSortable && !options.disabled && - (isOwner - ? canSort || (revert = !rootEl.contains(dragEl)) // Reverting item into the original list - : ( - putSortable === this || - ( - (activeSortable.lastPullMode = activeGroup.checkPull(this, activeSortable, dragEl, evt)) && - group.checkPut(this, activeSortable, dragEl, evt) - ) - ) - ) && - (evt.rootEl === void 0 || evt.rootEl === this.el) // touch fallback - ) { - // Smart auto-scrolling - _autoScroll(evt, options, this.el); - - if (_silent) { - return; - } + function clone(el) { + var Polymer = window.Polymer; + var $ = window.jQuery || window.Zepto; - target = _closest(evt.target, options.draggable, el); - dragRect = dragEl.getBoundingClientRect(); + if (Polymer && Polymer.dom) { + return Polymer.dom(el).cloneNode(true); + } else if ($) { + return $(el).clone(true)[0]; + } else { + return el.cloneNode(true); + } + } - if (putSortable !== this) { - putSortable = this; - isMovingBetweenSortable = true; - } + function setRect(el, rect) { + css(el, 'position', 'absolute'); + css(el, 'top', rect.top); + css(el, 'left', rect.left); + css(el, 'width', rect.width); + css(el, 'height', rect.height); + } - if (revert) { - _cloneHide(activeSortable, true); - parentEl = rootEl; // actualization + function unsetRect(el) { + css(el, 'position', ''); + css(el, 'top', ''); + css(el, 'left', ''); + css(el, 'width', ''); + css(el, 'height', ''); + } - if (cloneEl || nextEl) { - rootEl.insertBefore(dragEl, cloneEl || nextEl); - } - else if (!canSort) { - rootEl.appendChild(dragEl); - } + var expando = 'Sortable' + new Date().getTime(); - return; - } + function AnimationStateManager() { + var animationStates = [], + animationCallbackId; + return { + captureAnimationState: function captureAnimationState() { + animationStates = []; + if (!this.options.animation) return; + var children = [].slice.call(this.el.children); + children.forEach(function (child) { + if (css(child, 'display') === 'none' || child === Sortable.ghost) return; + animationStates.push({ + target: child, + rect: getRect(child) + }); + var fromRect = _objectSpread({}, animationStates[animationStates.length - 1].rect); // If animating: compensate for current animation - if ((el.children.length === 0) || (el.children[0] === ghostEl) || - (el === evt.target) && (_ghostIsLast(el, evt)) - ) { - //assign target only if condition is true - if (el.children.length !== 0 && el.children[0] !== ghostEl && el === evt.target) { - target = el.lastElementChild; - } - if (target) { - if (target.animated) { - return; - } + if (child.thisAnimationDuration) { + var childMatrix = matrix(child, true); - targetRect = target.getBoundingClientRect(); - } + if (childMatrix) { + fromRect.top -= childMatrix.f; + fromRect.left -= childMatrix.e; + } + } - _cloneHide(activeSortable, isOwner); + child.fromRect = fromRect; + }); + }, + addAnimationState: function addAnimationState(state) { + animationStates.push(state); + }, + removeAnimationState: function removeAnimationState(target) { + animationStates.splice(indexOfObject(animationStates, { + target: target + }), 1); + }, + animateAll: function animateAll(callback) { + var _this = this; - if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt) !== false) { - if (!dragEl.contains(el)) { - el.appendChild(dragEl); - parentEl = el; // actualization - } + if (!this.options.animation) { + clearTimeout(animationCallbackId); + if (typeof callback === 'function') callback(); + return; + } - this._animate(dragRect, dragEl); - target && this._animate(targetRect, target); - } - } - else if (target && !target.animated && target !== dragEl && (target.parentNode[expando] !== void 0)) { - if (lastEl !== target) { - lastEl = target; - lastCSS = _css(target); - lastParentCSS = _css(target.parentNode); - } + var animating = false, + animationTime = 0; + animationStates.forEach(function (state) { + var time = 0, + target = state.target, + fromRect = target.fromRect, + toRect = getRect(target), + prevFromRect = target.prevFromRect, + prevToRect = target.prevToRect, + animatingRect = state.rect, + targetMatrix = matrix(target, true); + + if (targetMatrix) { + // Compensate for current animation + toRect.top -= targetMatrix.f; + toRect.left -= targetMatrix.e; + } - targetRect = target.getBoundingClientRect(); - - var width = targetRect.right - targetRect.left, - height = targetRect.bottom - targetRect.top, - floating = R_FLOAT.test(lastCSS.cssFloat + lastCSS.display) - || (lastParentCSS.display == 'flex' && lastParentCSS['flex-direction'].indexOf('row') === 0), - isWide = (target.offsetWidth > dragEl.offsetWidth), - isLong = (target.offsetHeight > dragEl.offsetHeight), - halfway = (floating ? (evt.clientX - targetRect.left) / width : (evt.clientY - targetRect.top) / height) > 0.5, - nextSibling = target.nextElementSibling, - after = false - ; - - if (floating) { - var elTop = dragEl.offsetTop, - tgTop = target.offsetTop; - - if (elTop === tgTop) { - after = (target.previousElementSibling === dragEl) && !isWide || halfway && isWide; - } - else if (target.previousElementSibling === dragEl || dragEl.previousElementSibling === target) { - after = (evt.clientY - targetRect.top) / height > 0.5; - } else { - after = tgTop > elTop; - } - } else if (!isMovingBetweenSortable) { - after = (nextSibling !== dragEl) && !isLong || halfway && isLong; - } + target.toRect = toRect; - var moveVector = _onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, after); + if (target.thisAnimationDuration) { + // Could also check if animatingRect is between fromRect and toRect + if (isRectEqual(prevFromRect, toRect) && !isRectEqual(fromRect, toRect) && // Make sure animatingRect is on line between toRect & fromRect + (animatingRect.top - toRect.top) / (animatingRect.left - toRect.left) === (fromRect.top - toRect.top) / (fromRect.left - toRect.left)) { + // If returning to same place as started from animation and on same axis + time = calculateRealTime(animatingRect, prevFromRect, prevToRect, _this.options); + } + } // if fromRect != toRect: animate - if (moveVector !== false) { - if (moveVector === 1 || moveVector === -1) { - after = (moveVector === 1); - } - _silent = true; - setTimeout(_unsilent, 30); + if (!isRectEqual(toRect, fromRect)) { + target.prevFromRect = fromRect; + target.prevToRect = toRect; - _cloneHide(activeSortable, isOwner); + if (!time) { + time = _this.options.animation; + } - if (!dragEl.contains(el)) { - if (after && !nextSibling) { - el.appendChild(dragEl); - } else { - target.parentNode.insertBefore(dragEl, after ? nextSibling : target); - } - } + _this.animate(target, animatingRect, toRect, time); + } - parentEl = dragEl.parentNode; // actualization + if (time) { + animating = true; + animationTime = Math.max(animationTime, time); + clearTimeout(target.animationResetTimer); + target.animationResetTimer = setTimeout(function () { + target.animationTime = 0; + target.prevFromRect = null; + target.fromRect = null; + target.prevToRect = null; + target.thisAnimationDuration = null; + }, time); + target.thisAnimationDuration = time; + } + }); + clearTimeout(animationCallbackId); - this._animate(dragRect, dragEl); - this._animate(targetRect, target); - } - } - } - }, + if (!animating) { + if (typeof callback === 'function') callback(); + } else { + animationCallbackId = setTimeout(function () { + if (typeof callback === 'function') callback(); + }, animationTime); + } - _animate: function (prevRect, target) { - var ms = this.options.animation; + animationStates = []; + }, + animate: function animate(target, currentRect, toRect, duration) { + if (duration) { + css(target, 'transition', ''); + css(target, 'transform', ''); + var elMatrix = matrix(this.el), + scaleX = elMatrix && elMatrix.a, + scaleY = elMatrix && elMatrix.d, + translateX = (currentRect.left - toRect.left) / (scaleX || 1), + translateY = (currentRect.top - toRect.top) / (scaleY || 1); + target.animatingX = !!translateX; + target.animatingY = !!translateY; + css(target, 'transform', 'translate3d(' + translateX + 'px,' + translateY + 'px,0)'); + repaint(target); // repaint + + css(target, 'transition', 'transform ' + duration + 'ms' + (this.options.easing ? ' ' + this.options.easing : '')); + css(target, 'transform', 'translate3d(0,0,0)'); + typeof target.animated === 'number' && clearTimeout(target.animated); + target.animated = setTimeout(function () { + css(target, 'transition', ''); + css(target, 'transform', ''); + target.animated = false; + target.animatingX = false; + target.animatingY = false; + }, duration); + } + } + }; + } - if (ms) { - var currentRect = target.getBoundingClientRect(); + function repaint(target) { + return target.offsetWidth; + } - if (prevRect.nodeType === 1) { - prevRect = prevRect.getBoundingClientRect(); - } + function calculateRealTime(animatingRect, fromRect, toRect, options) { + return Math.sqrt(Math.pow(fromRect.top - animatingRect.top, 2) + Math.pow(fromRect.left - animatingRect.left, 2)) / Math.sqrt(Math.pow(fromRect.top - toRect.top, 2) + Math.pow(fromRect.left - toRect.left, 2)) * options.animation; + } - _css(target, 'transition', 'none'); - _css(target, 'transform', 'translate3d(' - + (prevRect.left - currentRect.left) + 'px,' - + (prevRect.top - currentRect.top) + 'px,0)' - ); + var plugins = []; + var defaults = { + initializeByDefault: true + }; + var PluginManager = { + mount: function mount(plugin) { + // Set default static properties + for (var option in defaults) { + if (defaults.hasOwnProperty(option) && !(option in plugin)) { + plugin[option] = defaults[option]; + } + } - target.offsetWidth; // repaint + plugins.push(plugin); + }, + pluginEvent: function pluginEvent(eventName, sortable, evt) { + var _this = this; - _css(target, 'transition', 'all ' + ms + 'ms'); - _css(target, 'transform', 'translate3d(0,0,0)'); + this.eventCanceled = false; - clearTimeout(target.animated); - target.animated = setTimeout(function () { - _css(target, 'transition', ''); - _css(target, 'transform', ''); - target.animated = false; - }, ms); - } - }, + evt.cancel = function () { + _this.eventCanceled = true; + }; - _offUpEvents: function () { - var ownerDocument = this.el.ownerDocument; - - _off(document, 'touchmove', this._onTouchMove); - _off(document, 'pointermove', this._onTouchMove); - _off(ownerDocument, 'mouseup', this._onDrop); - _off(ownerDocument, 'touchend', this._onDrop); - _off(ownerDocument, 'pointerup', this._onDrop); - _off(ownerDocument, 'touchcancel', this._onDrop); - _off(ownerDocument, 'pointercancel', this._onDrop); - _off(ownerDocument, 'selectstart', this); - }, + var eventNameGlobal = eventName + 'Global'; + plugins.forEach(function (plugin) { + if (!sortable[plugin.pluginName]) return; // Fire global events if it exists in this sortable - _onDrop: function (/**Event*/evt) { - var el = this.el, - options = this.options; + if (sortable[plugin.pluginName][eventNameGlobal]) { + sortable[plugin.pluginName][eventNameGlobal](_objectSpread({ + sortable: sortable + }, evt)); + } // Only fire plugin event if plugin is enabled in this sortable, + // and plugin has event defined - clearInterval(this._loopId); - clearInterval(autoScroll.pid); - clearTimeout(this._dragStartTimer); - // Unbind events - _off(document, 'mousemove', this._onTouchMove); + if (sortable.options[plugin.pluginName] && sortable[plugin.pluginName][eventName]) { + sortable[plugin.pluginName][eventName](_objectSpread({ + sortable: sortable + }, evt)); + } + }); + }, + initializePlugins: function initializePlugins(sortable, el, defaults, options) { + plugins.forEach(function (plugin) { + var pluginName = plugin.pluginName; + if (!sortable.options[pluginName] && !plugin.initializeByDefault) return; + var initialized = new plugin(sortable, el, sortable.options); + initialized.sortable = sortable; + initialized.options = sortable.options; + sortable[pluginName] = initialized; // Add default options from plugin + + _extends(defaults, initialized.defaults); + }); - if (this.nativeDraggable) { - _off(document, 'drop', this); - _off(el, 'dragstart', this._onDragStart); - } + for (var option in sortable.options) { + if (!sortable.options.hasOwnProperty(option)) continue; + var modified = this.modifyOption(sortable, option, sortable.options[option]); - this._offUpEvents(); + if (typeof modified !== 'undefined') { + sortable.options[option] = modified; + } + } + }, + getEventProperties: function getEventProperties(name, sortable) { + var eventProperties = {}; + plugins.forEach(function (plugin) { + if (typeof plugin.eventProperties !== 'function') return; - if (evt) { - if (moved) { - evt.preventDefault(); - !options.dropBubble && evt.stopPropagation(); - } + _extends(eventProperties, plugin.eventProperties.call(sortable[plugin.pluginName], name)); + }); + return eventProperties; + }, + modifyOption: function modifyOption(sortable, name, value) { + var modifiedValue; + plugins.forEach(function (plugin) { + // Plugin must exist on the Sortable + if (!sortable[plugin.pluginName]) return; // If static option listener exists for this option, call in the context of the Sortable's instance of this plugin + + if (plugin.optionListeners && typeof plugin.optionListeners[name] === 'function') { + modifiedValue = plugin.optionListeners[name].call(sortable[plugin.pluginName], value); + } + }); + return modifiedValue; + } + }; - ghostEl && ghostEl.parentNode && ghostEl.parentNode.removeChild(ghostEl); + function dispatchEvent(_ref) { + var sortable = _ref.sortable, + rootEl = _ref.rootEl, + name = _ref.name, + targetEl = _ref.targetEl, + cloneEl = _ref.cloneEl, + toEl = _ref.toEl, + fromEl = _ref.fromEl, + oldIndex = _ref.oldIndex, + newIndex = _ref.newIndex, + oldDraggableIndex = _ref.oldDraggableIndex, + newDraggableIndex = _ref.newDraggableIndex, + originalEvent = _ref.originalEvent, + putSortable = _ref.putSortable, + extraEventProperties = _ref.extraEventProperties; + sortable = sortable || rootEl && rootEl[expando]; + if (!sortable) return; + var evt, + options = sortable.options, + onName = 'on' + name.charAt(0).toUpperCase() + name.substr(1); // Support for new CustomEvent feature + + if (window.CustomEvent && !IE11OrLess && !Edge) { + evt = new CustomEvent(name, { + bubbles: true, + cancelable: true + }); + } else { + evt = document.createEvent('Event'); + evt.initEvent(name, true, true); + } + + evt.to = toEl || rootEl; + evt.from = fromEl || rootEl; + evt.item = targetEl || rootEl; + evt.clone = cloneEl; + evt.oldIndex = oldIndex; + evt.newIndex = newIndex; + evt.oldDraggableIndex = oldDraggableIndex; + evt.newDraggableIndex = newDraggableIndex; + evt.originalEvent = originalEvent; + evt.pullMode = putSortable ? putSortable.lastPutMode : undefined; + + var allEventProperties = _objectSpread({}, extraEventProperties, PluginManager.getEventProperties(name, sortable)); + + for (var option in allEventProperties) { + evt[option] = allEventProperties[option]; + } + + if (rootEl) { + rootEl.dispatchEvent(evt); + } + + if (options[onName]) { + options[onName].call(sortable, evt); + } + } + + var pluginEvent = function pluginEvent(eventName, sortable) { + var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, + originalEvent = _ref.evt, + data = _objectWithoutProperties(_ref, ["evt"]); + + PluginManager.pluginEvent.bind(Sortable)(eventName, sortable, _objectSpread({ + dragEl: dragEl, + parentEl: parentEl, + ghostEl: ghostEl, + rootEl: rootEl, + nextEl: nextEl, + lastDownEl: lastDownEl, + cloneEl: cloneEl, + cloneHidden: cloneHidden, + dragStarted: moved, + putSortable: putSortable, + activeSortable: Sortable.active, + originalEvent: originalEvent, + oldIndex: oldIndex, + oldDraggableIndex: oldDraggableIndex, + newIndex: newIndex, + newDraggableIndex: newDraggableIndex, + hideGhostForTarget: _hideGhostForTarget, + unhideGhostForTarget: _unhideGhostForTarget, + cloneNowHidden: function cloneNowHidden() { + cloneHidden = true; + }, + cloneNowShown: function cloneNowShown() { + cloneHidden = false; + }, + dispatchSortableEvent: function dispatchSortableEvent(name) { + _dispatchEvent({ + sortable: sortable, + name: name, + originalEvent: originalEvent + }); + } + }, data)); + }; - if (rootEl === parentEl || Sortable.active.lastPullMode !== 'clone') { - // Remove clone - cloneEl && cloneEl.parentNode && cloneEl.parentNode.removeChild(cloneEl); - } + function _dispatchEvent(info) { + dispatchEvent(_objectSpread({ + putSortable: putSortable, + cloneEl: cloneEl, + targetEl: dragEl, + rootEl: rootEl, + oldIndex: oldIndex, + oldDraggableIndex: oldDraggableIndex, + newIndex: newIndex, + newDraggableIndex: newDraggableIndex + }, info)); + } + + var dragEl, + parentEl, + ghostEl, + rootEl, + nextEl, + lastDownEl, + cloneEl, + cloneHidden, + oldIndex, + newIndex, + oldDraggableIndex, + newDraggableIndex, + activeGroup, + putSortable, + awaitingDragStarted = false, + ignoreNextClick = false, + sortables = [], + tapEvt, + touchEvt, + lastDx, + lastDy, + tapDistanceLeft, + tapDistanceTop, + moved, + lastTarget, + lastDirection, + pastFirstInvertThresh = false, + isCircumstantialInvert = false, + targetMoveDistance, + // For positioning ghost absolutely + ghostRelativeParent, + ghostRelativeParentInitialScroll = [], + // (left, top) + _silent = false, + savedInputChecked = []; + /** @const */ + + var documentExists = typeof document !== 'undefined', + PositionGhostAbsolutely = IOS, + CSSFloatProperty = Edge || IE11OrLess ? 'cssFloat' : 'float', + // This will not pass for IE9, because IE9 DnD only works on anchors + supportDraggable = documentExists && !ChromeForAndroid && !IOS && 'draggable' in document.createElement('div'), + supportCssPointerEvents = function () { + if (!documentExists) return; // false when <= IE11 + + if (IE11OrLess) { + return false; + } + + var el = document.createElement('x'); + el.style.cssText = 'pointer-events:auto'; + return el.style.pointerEvents === 'auto'; + }(), + _detectDirection = function _detectDirection(el, options) { + var elCSS = css(el), + elWidth = parseInt(elCSS.width) - parseInt(elCSS.paddingLeft) - parseInt(elCSS.paddingRight) - parseInt(elCSS.borderLeftWidth) - parseInt(elCSS.borderRightWidth), + child1 = getChild(el, 0, options), + child2 = getChild(el, 1, options), + firstChildCSS = child1 && css(child1), + secondChildCSS = child2 && css(child2), + firstChildWidth = firstChildCSS && parseInt(firstChildCSS.marginLeft) + parseInt(firstChildCSS.marginRight) + getRect(child1).width, + secondChildWidth = secondChildCSS && parseInt(secondChildCSS.marginLeft) + parseInt(secondChildCSS.marginRight) + getRect(child2).width; + + if (elCSS.display === 'flex') { + return elCSS.flexDirection === 'column' || elCSS.flexDirection === 'column-reverse' ? 'vertical' : 'horizontal'; + } + + if (elCSS.display === 'grid') { + return elCSS.gridTemplateColumns.split(' ').length <= 1 ? 'vertical' : 'horizontal'; + } + + if (child1 && firstChildCSS["float"] && firstChildCSS["float"] !== 'none') { + var touchingSideChild2 = firstChildCSS["float"] === 'left' ? 'left' : 'right'; + return child2 && (secondChildCSS.clear === 'both' || secondChildCSS.clear === touchingSideChild2) ? 'vertical' : 'horizontal'; + } + + return child1 && (firstChildCSS.display === 'block' || firstChildCSS.display === 'flex' || firstChildCSS.display === 'table' || firstChildCSS.display === 'grid' || firstChildWidth >= elWidth && elCSS[CSSFloatProperty] === 'none' || child2 && elCSS[CSSFloatProperty] === 'none' && firstChildWidth + secondChildWidth > elWidth) ? 'vertical' : 'horizontal'; + }, + _dragElInRowColumn = function _dragElInRowColumn(dragRect, targetRect, vertical) { + var dragElS1Opp = vertical ? dragRect.left : dragRect.top, + dragElS2Opp = vertical ? dragRect.right : dragRect.bottom, + dragElOppLength = vertical ? dragRect.width : dragRect.height, + targetS1Opp = vertical ? targetRect.left : targetRect.top, + targetS2Opp = vertical ? targetRect.right : targetRect.bottom, + targetOppLength = vertical ? targetRect.width : targetRect.height; + return dragElS1Opp === targetS1Opp || dragElS2Opp === targetS2Opp || dragElS1Opp + dragElOppLength / 2 === targetS1Opp + targetOppLength / 2; + }, - if (dragEl) { - if (this.nativeDraggable) { - _off(dragEl, 'dragend', this); - } + /** + * Detects first nearest empty sortable to X and Y position using emptyInsertThreshold. + * @param {Number} x X position + * @param {Number} y Y position + * @return {HTMLElement} Element of the first found nearest Sortable + */ + _detectNearestEmptySortable = function _detectNearestEmptySortable(x, y) { + var ret; + sortables.some(function (sortable) { + if (lastChild(sortable)) return; + var rect = getRect(sortable), + threshold = sortable[expando].options.emptyInsertThreshold, + insideHorizontally = x >= rect.left - threshold && x <= rect.right + threshold, + insideVertically = y >= rect.top - threshold && y <= rect.bottom + threshold; + + if (threshold && insideHorizontally && insideVertically) { + return ret = sortable; + } + }); + return ret; + }, + _prepareGroup = function _prepareGroup(options) { + function toFn(value, pull) { + return function (to, from, dragEl, evt) { + var sameGroup = to.options.group.name && from.options.group.name && to.options.group.name === from.options.group.name; + + if (value == null && (pull || sameGroup)) { + // Default pull value + // Default pull and put value if same group + return true; + } else if (value == null || value === false) { + return false; + } else if (pull && value === 'clone') { + return value; + } else if (typeof value === 'function') { + return toFn(value(to, from, dragEl, evt), pull)(to, from, dragEl, evt); + } else { + var otherGroup = (pull ? to : from).options.group.name; + return value === true || typeof value === 'string' && value === otherGroup || value.join && value.indexOf(otherGroup) > -1; + } + }; + } - _disableDraggable(dragEl); - dragEl.style['will-change'] = ''; + var group = {}; + var originalGroup = options.group; - // Remove class's - _toggleClass(dragEl, this.options.ghostClass, false); - _toggleClass(dragEl, this.options.chosenClass, false); + if (!originalGroup || _typeof(originalGroup) != 'object') { + originalGroup = { + name: originalGroup + }; + } - // Drag stop event - _dispatchEvent(this, rootEl, 'unchoose', dragEl, rootEl, oldIndex); + group.name = originalGroup.name; + group.checkPull = toFn(originalGroup.pull, true); + group.checkPut = toFn(originalGroup.put); + group.revertClone = originalGroup.revertClone; + options.group = group; + }, + _hideGhostForTarget = function _hideGhostForTarget() { + if (!supportCssPointerEvents && ghostEl) { + css(ghostEl, 'display', 'none'); + } + }, + _unhideGhostForTarget = function _unhideGhostForTarget() { + if (!supportCssPointerEvents && ghostEl) { + css(ghostEl, 'display', ''); + } + }; // #1184 fix - Prevent click event on fallback if dragged but item not changed position - if (rootEl !== parentEl) { - newIndex = _index(dragEl, options.draggable); - if (newIndex >= 0) { - // Add event - _dispatchEvent(null, parentEl, 'add', dragEl, rootEl, oldIndex, newIndex); + if (documentExists) { + document.addEventListener('click', function (evt) { + if (ignoreNextClick) { + evt.preventDefault(); + evt.stopPropagation && evt.stopPropagation(); + evt.stopImmediatePropagation && evt.stopImmediatePropagation(); + ignoreNextClick = false; + return false; + } + }, true); + } - // Remove event - _dispatchEvent(this, rootEl, 'remove', dragEl, rootEl, oldIndex, newIndex); + var nearestEmptyInsertDetectEvent = function nearestEmptyInsertDetectEvent(evt) { + if (dragEl) { + evt = evt.touches ? evt.touches[0] : evt; - // drag from one list and drop into another - _dispatchEvent(null, parentEl, 'sort', dragEl, rootEl, oldIndex, newIndex); - _dispatchEvent(this, rootEl, 'sort', dragEl, rootEl, oldIndex, newIndex); - } - } - else { - if (dragEl.nextSibling !== nextEl) { - // Get the index of the dragged element within its parent - newIndex = _index(dragEl, options.draggable); - - if (newIndex >= 0) { - // drag & drop within the same list - _dispatchEvent(this, rootEl, 'update', dragEl, rootEl, oldIndex, newIndex); - _dispatchEvent(this, rootEl, 'sort', dragEl, rootEl, oldIndex, newIndex); - } - } - } + var nearest = _detectNearestEmptySortable(evt.clientX, evt.clientY); - if (Sortable.active) { - /* jshint eqnull:true */ - if (newIndex == null || newIndex === -1) { - newIndex = oldIndex; - } + if (nearest) { + // Create imitation event + var event = {}; - _dispatchEvent(this, rootEl, 'end', dragEl, rootEl, oldIndex, newIndex); + for (var i in evt) { + if (evt.hasOwnProperty(i)) { + event[i] = evt[i]; + } + } - // Save sorting - this.save(); - } - } + event.target = event.rootEl = nearest; + event.preventDefault = void 0; + event.stopPropagation = void 0; - } + nearest[expando]._onDragOver(event); + } + } + }; - this._nulling(); - }, + var _checkOutsideTargetEl = function _checkOutsideTargetEl(evt) { + if (dragEl) { + dragEl.parentNode[expando]._isOutsideThisEl(evt.target); + } + }; + /** + * @class Sortable + * @param {HTMLElement} el + * @param {Object} [options] + */ - _nulling: function() { - rootEl = - dragEl = - parentEl = - ghostEl = - nextEl = - cloneEl = - lastDownEl = - scrollEl = - scrollParentEl = + function Sortable(el, options) { + if (!(el && el.nodeType && el.nodeType === 1)) { + throw "Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(el)); + } + + this.el = el; // root element + + this.options = options = _extends({}, options); // Export instance + + el[expando] = this; + var defaults = { + group: null, + sort: true, + disabled: false, + store: null, + handle: null, + draggable: /^[uo]l$/i.test(el.nodeName) ? '>li' : '>*', + swapThreshold: 1, + // percentage; 0 <= x <= 1 + invertSwap: false, + // invert always + invertedSwapThreshold: null, + // will be set to same as swapThreshold if default + removeCloneOnHide: true, + direction: function direction() { + return _detectDirection(el, this.options); + }, + ghostClass: 'sortable-ghost', + chosenClass: 'sortable-chosen', + dragClass: 'sortable-drag', + ignore: 'a, img', + filter: null, + preventOnFilter: true, + animation: 0, + easing: null, + setData: function setData(dataTransfer, dragEl) { + dataTransfer.setData('Text', dragEl.textContent); + }, + dropBubble: false, + dragoverBubble: false, + dataIdAttr: 'data-id', + delay: 0, + delayOnTouchOnly: false, + touchStartThreshold: (Number.parseInt ? Number : window).parseInt(window.devicePixelRatio, 10) || 1, + forceFallback: false, + fallbackClass: 'sortable-fallback', + fallbackOnBody: false, + fallbackTolerance: 0, + fallbackOffset: { + x: 0, + y: 0 + }, + supportPointer: Sortable.supportPointer !== false && 'PointerEvent' in window, + emptyInsertThreshold: 5 + }; + PluginManager.initializePlugins(this, el, defaults); // Set default options - tapEvt = - touchEvt = + for (var name in defaults) { + !(name in options) && (options[name] = defaults[name]); + } - moved = - newIndex = + _prepareGroup(options); // Bind all private methods - lastEl = - lastCSS = - putSortable = - activeGroup = - Sortable.active = null; + for (var fn in this) { + if (fn.charAt(0) === '_' && typeof this[fn] === 'function') { + this[fn] = this[fn].bind(this); + } + } // Setup drag mode - savedInputChecked.forEach(function (el) { - el.checked = true; - }); - savedInputChecked.length = 0; - }, - handleEvent: function (/**Event*/evt) { - switch (evt.type) { - case 'drop': - case 'dragend': - this._onDrop(evt); - break; + this.nativeDraggable = options.forceFallback ? false : supportDraggable; - case 'dragover': - case 'dragenter': - if (dragEl) { - this._onDragOver(evt); - _globalDragOver(evt); - } - break; + if (this.nativeDraggable) { + // Touch start threshold cannot be greater than the native dragstart threshold + this.options.touchStartThreshold = 1; + } // Bind events - case 'selectstart': - evt.preventDefault(); - break; - } - }, + if (options.supportPointer) { + on(el, 'pointerdown', this._onTapStart); + } else { + on(el, 'mousedown', this._onTapStart); + on(el, 'touchstart', this._onTapStart); + } - /** - * Serializes the item into an array of string. - * @returns {String[]} - */ - toArray: function () { - var order = [], - el, - children = this.el.children, - i = 0, - n = children.length, - options = this.options; - - for (; i < n; i++) { - el = children[i]; - if (_closest(el, options.draggable, this.el)) { - order.push(el.getAttribute(options.dataIdAttr) || _generateId(el)); - } - } + if (this.nativeDraggable) { + on(el, 'dragover', this); + on(el, 'dragenter', this); + } - return order; - }, + sortables.push(this.el); // Restore sorting + options.store && options.store.get && this.sort(options.store.get(this) || []); // Add animation state manager - /** - * Sorts the elements according to the array. - * @param {String[]} order order of the items - */ - sort: function (order) { - var items = {}, rootEl = this.el; + _extends(this, AnimationStateManager()); + } - this.toArray().forEach(function (id, i) { - var el = rootEl.children[i]; + Sortable.prototype = + /** @lends Sortable.prototype */ + { + constructor: Sortable, + _isOutsideThisEl: function _isOutsideThisEl(target) { + if (!this.el.contains(target) && target !== this.el) { + lastTarget = null; + } + }, + _getDirection: function _getDirection(evt, target) { + return typeof this.options.direction === 'function' ? this.options.direction.call(this, evt, target, dragEl) : this.options.direction; + }, + _onTapStart: function _onTapStart( + /** Event|TouchEvent */ + evt) { + if (!evt.cancelable) return; - if (_closest(el, this.options.draggable, rootEl)) { - items[id] = el; - } - }, this); + var _this = this, + el = this.el, + options = this.options, + preventOnFilter = options.preventOnFilter, + type = evt.type, + touch = evt.touches && evt.touches[0] || evt.pointerType && evt.pointerType === 'touch' && evt, + target = (touch || evt).target, + originalTarget = evt.target.shadowRoot && (evt.path && evt.path[0] || evt.composedPath && evt.composedPath()[0]) || target, + filter = options.filter; - order.forEach(function (id) { - if (items[id]) { - rootEl.removeChild(items[id]); - rootEl.appendChild(items[id]); - } - }); - }, + _saveInputCheckedState(el); // Don't trigger start event when an element is been dragged, otherwise the evt.oldindex always wrong when set option.group. - /** - * Save the current sorting - */ - save: function () { - var store = this.options.store; - store && store.set(this); - }, + if (dragEl) { + return; + } + if (/mousedown|pointerdown/.test(type) && evt.button !== 0 || options.disabled) { + return; // only left button and enabled + } // cancel dnd if original target is content editable - /** - * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree. - * @param {HTMLElement} el - * @param {String} [selector] default: `options.draggable` - * @returns {HTMLElement|null} - */ - closest: function (el, selector) { - return _closest(el, selector || this.options.draggable, this.el); - }, + if (originalTarget.isContentEditable) { + return; + } - /** - * Set/get option - * @param {string} name - * @param {*} [value] - * @returns {*} - */ - option: function (name, value) { - var options = this.options; + target = closest(target, options.draggable, el, false); - if (value === void 0) { - return options[name]; - } else { - options[name] = value; + if (target && target.animated) { + return; + } - if (name === 'group') { - _prepareGroup(options); - } - } - }, + if (lastDownEl === target) { + // Ignoring duplicate `down` + return; + } // Get the index of the dragged element within its parent - /** - * Destroy - */ - destroy: function () { - var el = this.el; + oldIndex = index(target); + oldDraggableIndex = index(target, options.draggable); // Check filter - el[expando] = null; + if (typeof filter === 'function') { + if (filter.call(this, evt, target, this)) { + _dispatchEvent({ + sortable: _this, + rootEl: originalTarget, + name: 'filter', + targetEl: target, + toEl: el, + fromEl: el + }); - _off(el, 'mousedown', this._onTapStart); - _off(el, 'touchstart', this._onTapStart); - _off(el, 'pointerdown', this._onTapStart); + pluginEvent('filter', _this, { + evt: evt + }); + preventOnFilter && evt.cancelable && evt.preventDefault(); + return; // cancel dnd + } + } else if (filter) { + filter = filter.split(',').some(function (criteria) { + criteria = closest(originalTarget, criteria.trim(), el, false); + + if (criteria) { + _dispatchEvent({ + sortable: _this, + rootEl: criteria, + name: 'filter', + targetEl: target, + fromEl: el, + toEl: el + }); - if (this.nativeDraggable) { - _off(el, 'dragover', this); - _off(el, 'dragenter', this); - } + pluginEvent('filter', _this, { + evt: evt + }); + return true; + } + }); - // Remove draggable attributes - Array.prototype.forEach.call(el.querySelectorAll('[draggable]'), function (el) { - el.removeAttribute('draggable'); - }); + if (filter) { + preventOnFilter && evt.cancelable && evt.preventDefault(); + return; // cancel dnd + } + } - touchDragOverListeners.splice(touchDragOverListeners.indexOf(this._onDragOver), 1); + if (options.handle && !closest(originalTarget, options.handle, el, false)) { + return; + } // Prepare `dragstart` - this._onDrop(); - this.el = el = null; - } - }; + this._prepareDragStart(evt, touch, target); + }, + _prepareDragStart: function _prepareDragStart( + /** Event */ + evt, + /** Touch */ + touch, + /** HTMLElement */ + target) { + var _this = this, + el = _this.el, + options = _this.options, + ownerDocument = el.ownerDocument, + dragStartFn; + + if (target && !dragEl && target.parentNode === el) { + var dragRect = getRect(target); + rootEl = el; + dragEl = target; + parentEl = dragEl.parentNode; + nextEl = dragEl.nextSibling; + lastDownEl = target; + activeGroup = options.group; + Sortable.dragged = dragEl; + tapEvt = { + target: dragEl, + clientX: (touch || evt).clientX, + clientY: (touch || evt).clientY + }; + tapDistanceLeft = tapEvt.clientX - dragRect.left; + tapDistanceTop = tapEvt.clientY - dragRect.top; + this._lastX = (touch || evt).clientX; + this._lastY = (touch || evt).clientY; + dragEl.style['will-change'] = 'all'; + + dragStartFn = function dragStartFn() { + pluginEvent('delayEnded', _this, { + evt: evt + }); + if (Sortable.eventCanceled) { + _this._onDrop(); - function _cloneHide(sortable, state) { - if (sortable.lastPullMode !== 'clone') { - state = true; - } + return; + } // Delayed drag has been triggered + // we can re-enable the events: touchmove/mousemove - if (cloneEl && (cloneEl.state !== state)) { - _css(cloneEl, 'display', state ? 'none' : ''); - if (!state) { - if (cloneEl.state) { - if (sortable.options.group.revertClone) { - rootEl.insertBefore(cloneEl, nextEl); - sortable._animate(dragEl, cloneEl); - } else { - rootEl.insertBefore(cloneEl, dragEl); - } - } - } + _this._disableDelayedDragEvents(); - cloneEl.state = state; - } - } + if (!FireFox && _this.nativeDraggable) { + dragEl.draggable = true; + } // Bind the events: dragstart/dragend - function _closest(/**HTMLElement*/el, /**String*/selector, /**HTMLElement*/ctx) { - if (el) { - ctx = ctx || document; + _this._triggerDragStart(evt, touch); // Drag start event - do { - if ((selector === '>*' && el.parentNode === ctx) || _matches(el, selector)) { - return el; - } - /* jshint boss:true */ - } while (el = _getParentOrHost(el)); - } - return null; - } + _dispatchEvent({ + sortable: _this, + name: 'choose', + originalEvent: evt + }); // Chosen item - function _getParentOrHost(el) { - var parent = el.host; + toggleClass(dragEl, options.chosenClass, true); + }; // Disable "draggable" - return (parent && parent.nodeType) ? parent : el.parentNode; - } + options.ignore.split(',').forEach(function (criteria) { + find(dragEl, criteria.trim(), _disableDraggable); + }); + on(ownerDocument, 'dragover', nearestEmptyInsertDetectEvent); + on(ownerDocument, 'mousemove', nearestEmptyInsertDetectEvent); + on(ownerDocument, 'touchmove', nearestEmptyInsertDetectEvent); + on(ownerDocument, 'mouseup', _this._onDrop); + on(ownerDocument, 'touchend', _this._onDrop); + on(ownerDocument, 'touchcancel', _this._onDrop); // Make dragEl draggable (must be before delay for FireFox) + + if (FireFox && this.nativeDraggable) { + this.options.touchStartThreshold = 4; + dragEl.draggable = true; + } - function _globalDragOver(/**Event*/evt) { - if (evt.dataTransfer) { - evt.dataTransfer.dropEffect = 'move'; - } - evt.preventDefault(); - } + pluginEvent('delayStart', this, { + evt: evt + }); // Delay is impossible for native DnD in Edge or IE + if (options.delay && (!options.delayOnTouchOnly || touch) && (!this.nativeDraggable || !(Edge || IE11OrLess))) { + if (Sortable.eventCanceled) { + this._onDrop(); - function _on(el, event, fn) { - el.addEventListener(event, fn, captureMode); - } + return; + } // If the user moves the pointer or let go the click or touch + // before the delay has been reached: + // disable the delayed drag + + + on(ownerDocument, 'mouseup', _this._disableDelayedDrag); + on(ownerDocument, 'touchend', _this._disableDelayedDrag); + on(ownerDocument, 'touchcancel', _this._disableDelayedDrag); + on(ownerDocument, 'mousemove', _this._delayedDragTouchMoveHandler); + on(ownerDocument, 'touchmove', _this._delayedDragTouchMoveHandler); + options.supportPointer && on(ownerDocument, 'pointermove', _this._delayedDragTouchMoveHandler); + _this._dragStartTimer = setTimeout(dragStartFn, options.delay); + } else { + dragStartFn(); + } + } + }, + _delayedDragTouchMoveHandler: function _delayedDragTouchMoveHandler( + /** TouchEvent|PointerEvent **/ + e) { + var touch = e.touches ? e.touches[0] : e; + if (Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) >= Math.floor(this.options.touchStartThreshold / (this.nativeDraggable && window.devicePixelRatio || 1))) { + this._disableDelayedDrag(); + } + }, + _disableDelayedDrag: function _disableDelayedDrag() { + dragEl && _disableDraggable(dragEl); + clearTimeout(this._dragStartTimer); - function _off(el, event, fn) { - el.removeEventListener(event, fn, captureMode); - } + this._disableDelayedDragEvents(); + }, + _disableDelayedDragEvents: function _disableDelayedDragEvents() { + var ownerDocument = this.el.ownerDocument; + off(ownerDocument, 'mouseup', this._disableDelayedDrag); + off(ownerDocument, 'touchend', this._disableDelayedDrag); + off(ownerDocument, 'touchcancel', this._disableDelayedDrag); + off(ownerDocument, 'mousemove', this._delayedDragTouchMoveHandler); + off(ownerDocument, 'touchmove', this._delayedDragTouchMoveHandler); + off(ownerDocument, 'pointermove', this._delayedDragTouchMoveHandler); + }, + _triggerDragStart: function _triggerDragStart( + /** Event */ + evt, + /** Touch */ + touch) { + touch = touch || evt.pointerType == 'touch' && evt; + + if (!this.nativeDraggable || touch) { + if (this.options.supportPointer) { + on(document, 'pointermove', this._onTouchMove); + } else if (touch) { + on(document, 'touchmove', this._onTouchMove); + } else { + on(document, 'mousemove', this._onTouchMove); + } + } else { + on(dragEl, 'dragend', this); + on(rootEl, 'dragstart', this._onDragStart); + } + try { + if (document.selection) { + // Timeout neccessary for IE9 + _nextTick(function () { + document.selection.empty(); + }); + } else { + window.getSelection().removeAllRanges(); + } + } catch (err) {} + }, + _dragStarted: function _dragStarted(fallback, evt) { - function _toggleClass(el, name, state) { - if (el) { - if (el.classList) { - el.classList[state ? 'add' : 'remove'](name); - } - else { - var className = (' ' + el.className + ' ').replace(R_SPACE, ' ').replace(' ' + name + ' ', ' '); - el.className = (className + (state ? ' ' + name : '')).replace(R_SPACE, ' '); - } - } - } + awaitingDragStarted = false; + if (rootEl && dragEl) { + pluginEvent('dragStarted', this, { + evt: evt + }); - function _css(el, prop, val) { - var style = el && el.style; + if (this.nativeDraggable) { + on(document, 'dragover', _checkOutsideTargetEl); + } - if (style) { - if (val === void 0) { - if (document.defaultView && document.defaultView.getComputedStyle) { - val = document.defaultView.getComputedStyle(el, ''); - } - else if (el.currentStyle) { - val = el.currentStyle; - } + var options = this.options; // Apply effect - return prop === void 0 ? val : val[prop]; - } - else { - if (!(prop in style)) { - prop = '-webkit-' + prop; - } + !fallback && toggleClass(dragEl, options.dragClass, false); + toggleClass(dragEl, options.ghostClass, true); + Sortable.active = this; + fallback && this._appendGhost(); // Drag start event - style[prop] = val + (typeof val === 'string' ? '' : 'px'); - } - } - } + _dispatchEvent({ + sortable: this, + name: 'start', + originalEvent: evt + }); + } else { + this._nulling(); + } + }, + _emulateDragOver: function _emulateDragOver() { + if (touchEvt) { + this._lastX = touchEvt.clientX; + this._lastY = touchEvt.clientY; + _hideGhostForTarget(); - function _find(ctx, tagName, iterator) { - if (ctx) { - var list = ctx.getElementsByTagName(tagName), i = 0, n = list.length; + var target = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY); + var parent = target; - if (iterator) { - for (; i < n; i++) { - iterator(list[i], i); - } - } + while (target && target.shadowRoot) { + target = target.shadowRoot.elementFromPoint(touchEvt.clientX, touchEvt.clientY); + if (target === parent) break; + parent = target; + } - return list; - } + dragEl.parentNode[expando]._isOutsideThisEl(target); + + if (parent) { + do { + if (parent[expando]) { + var inserted = void 0; + inserted = parent[expando]._onDragOver({ + clientX: touchEvt.clientX, + clientY: touchEvt.clientY, + target: target, + rootEl: parent + }); + + if (inserted && !this.options.dragoverBubble) { + break; + } + } - return []; - } + target = parent; // store last element + } + /* jshint boss:true */ + while (parent = parent.parentNode); + } + _unhideGhostForTarget(); + } + }, + _onTouchMove: function _onTouchMove( + /**TouchEvent*/ + evt) { + if (tapEvt) { + var options = this.options, + fallbackTolerance = options.fallbackTolerance, + fallbackOffset = options.fallbackOffset, + touch = evt.touches ? evt.touches[0] : evt, + ghostMatrix = ghostEl && matrix(ghostEl, true), + scaleX = ghostEl && ghostMatrix && ghostMatrix.a, + scaleY = ghostEl && ghostMatrix && ghostMatrix.d, + relativeScrollOffset = PositionGhostAbsolutely && ghostRelativeParent && getRelativeScrollOffset(ghostRelativeParent), + dx = (touch.clientX - tapEvt.clientX + fallbackOffset.x) / (scaleX || 1) + (relativeScrollOffset ? relativeScrollOffset[0] - ghostRelativeParentInitialScroll[0] : 0) / (scaleX || 1), + dy = (touch.clientY - tapEvt.clientY + fallbackOffset.y) / (scaleY || 1) + (relativeScrollOffset ? relativeScrollOffset[1] - ghostRelativeParentInitialScroll[1] : 0) / (scaleY || 1); // only set the status to dragging, when we are actually dragging + + if (!Sortable.active && !awaitingDragStarted) { + if (fallbackTolerance && Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) < fallbackTolerance) { + return; + } + this._onDragStart(evt, true); + } - function _dispatchEvent(sortable, rootEl, name, targetEl, fromEl, startIndex, newIndex) { - sortable = (sortable || rootEl[expando]); + if (ghostEl) { + if (ghostMatrix) { + ghostMatrix.e += dx - (lastDx || 0); + ghostMatrix.f += dy - (lastDy || 0); + } else { + ghostMatrix = { + a: 1, + b: 0, + c: 0, + d: 1, + e: dx, + f: dy + }; + } - var evt = document.createEvent('Event'), - options = sortable.options, - onName = 'on' + name.charAt(0).toUpperCase() + name.substr(1); + var cssMatrix = "matrix(".concat(ghostMatrix.a, ",").concat(ghostMatrix.b, ",").concat(ghostMatrix.c, ",").concat(ghostMatrix.d, ",").concat(ghostMatrix.e, ",").concat(ghostMatrix.f, ")"); + css(ghostEl, 'webkitTransform', cssMatrix); + css(ghostEl, 'mozTransform', cssMatrix); + css(ghostEl, 'msTransform', cssMatrix); + css(ghostEl, 'transform', cssMatrix); + lastDx = dx; + lastDy = dy; + touchEvt = touch; + } - evt.initEvent(name, true, true); + evt.cancelable && evt.preventDefault(); + } + }, + _appendGhost: function _appendGhost() { + // Bug if using scale(): https://stackoverflow.com/questions/2637058 + // Not being adjusted for + if (!ghostEl) { + var container = this.options.fallbackOnBody ? document.body : rootEl, + rect = getRect(dragEl, true, PositionGhostAbsolutely, true, container), + options = this.options; // Position absolutely + + if (PositionGhostAbsolutely) { + // Get relatively positioned parent + ghostRelativeParent = container; + + while (css(ghostRelativeParent, 'position') === 'static' && css(ghostRelativeParent, 'transform') === 'none' && ghostRelativeParent !== document) { + ghostRelativeParent = ghostRelativeParent.parentNode; + } - evt.to = rootEl; - evt.from = fromEl || rootEl; - evt.item = targetEl || rootEl; - evt.clone = cloneEl; + if (ghostRelativeParent !== document.body && ghostRelativeParent !== document.documentElement) { + if (ghostRelativeParent === document) ghostRelativeParent = getWindowScrollingElement(); + rect.top += ghostRelativeParent.scrollTop; + rect.left += ghostRelativeParent.scrollLeft; + } else { + ghostRelativeParent = getWindowScrollingElement(); + } - evt.oldIndex = startIndex; - evt.newIndex = newIndex; + ghostRelativeParentInitialScroll = getRelativeScrollOffset(ghostRelativeParent); + } - rootEl.dispatchEvent(evt); + ghostEl = dragEl.cloneNode(true); + toggleClass(ghostEl, options.ghostClass, false); + toggleClass(ghostEl, options.fallbackClass, true); + toggleClass(ghostEl, options.dragClass, true); + css(ghostEl, 'transition', ''); + css(ghostEl, 'transform', ''); + css(ghostEl, 'box-sizing', 'border-box'); + css(ghostEl, 'margin', 0); + css(ghostEl, 'top', rect.top); + css(ghostEl, 'left', rect.left); + css(ghostEl, 'width', rect.width); + css(ghostEl, 'height', rect.height); + css(ghostEl, 'opacity', '0.8'); + css(ghostEl, 'position', PositionGhostAbsolutely ? 'absolute' : 'fixed'); + css(ghostEl, 'zIndex', '100000'); + css(ghostEl, 'pointerEvents', 'none'); + Sortable.ghost = ghostEl; + container.appendChild(ghostEl); // Set transform-origin + + css(ghostEl, 'transform-origin', tapDistanceLeft / parseInt(ghostEl.style.width) * 100 + '% ' + tapDistanceTop / parseInt(ghostEl.style.height) * 100 + '%'); + } + }, + _onDragStart: function _onDragStart( + /**Event*/ + evt, + /**boolean*/ + fallback) { + var _this = this; - if (options[onName]) { - options[onName].call(sortable, evt); - } - } + var dataTransfer = evt.dataTransfer; + var options = _this.options; + pluginEvent('dragStart', this, { + evt: evt + }); + if (Sortable.eventCanceled) { + this._onDrop(); - function _onMove(fromEl, toEl, dragEl, dragRect, targetEl, targetRect, originalEvt, willInsertAfter) { - var evt, - sortable = fromEl[expando], - onMoveFn = sortable.options.onMove, - retVal; + return; + } - evt = document.createEvent('Event'); - evt.initEvent('move', true, true); + pluginEvent('setupClone', this); - evt.to = toEl; - evt.from = fromEl; - evt.dragged = dragEl; - evt.draggedRect = dragRect; - evt.related = targetEl || toEl; - evt.relatedRect = targetRect || toEl.getBoundingClientRect(); - evt.willInsertAfter = willInsertAfter; + if (!Sortable.eventCanceled) { + cloneEl = clone(dragEl); + cloneEl.draggable = false; + cloneEl.style['will-change'] = ''; - fromEl.dispatchEvent(evt); + this._hideClone(); - if (onMoveFn) { - retVal = onMoveFn.call(sortable, evt, originalEvt); - } + toggleClass(cloneEl, this.options.chosenClass, false); + Sortable.clone = cloneEl; + } // #1143: IFrame support workaround - return retVal; - } + _this.cloneId = _nextTick(function () { + pluginEvent('clone', _this); + if (Sortable.eventCanceled) return; - function _disableDraggable(el) { - el.draggable = false; - } + if (!_this.options.removeCloneOnHide) { + rootEl.insertBefore(cloneEl, dragEl); + } + _this._hideClone(); - function _unsilent() { - _silent = false; - } + _dispatchEvent({ + sortable: _this, + name: 'clone' + }); + }); + !fallback && toggleClass(dragEl, options.dragClass, true); // Set proper drop events + if (fallback) { + ignoreNextClick = true; + _this._loopId = setInterval(_this._emulateDragOver, 50); + } else { + // Undo what was set in _prepareDragStart before drag started + off(document, 'mouseup', _this._onDrop); + off(document, 'touchend', _this._onDrop); + off(document, 'touchcancel', _this._onDrop); + + if (dataTransfer) { + dataTransfer.effectAllowed = 'move'; + options.setData && options.setData.call(_this, dataTransfer, dragEl); + } - /** @returns {HTMLElement|false} */ - function _ghostIsLast(el, evt) { - var lastEl = el.lastElementChild, - rect = lastEl.getBoundingClientRect(); + on(document, 'drop', _this); // #1276 fix: - // 5 — min delta - // abs — нельзя добавлять, а то глюки при наведении сверху - return (evt.clientY - (rect.top + rect.height) > 5) || - (evt.clientX - (rect.left + rect.width) > 5); - } + css(dragEl, 'transform', 'translateZ(0)'); + } + awaitingDragStarted = true; + _this._dragStartId = _nextTick(_this._dragStarted.bind(_this, fallback, evt)); + on(document, 'selectstart', _this); + moved = true; - /** - * Generate id - * @param {HTMLElement} el - * @returns {String} - * @private - */ - function _generateId(el) { - var str = el.tagName + el.className + el.src + el.href + el.textContent, - i = str.length, - sum = 0; + if (Safari) { + css(document.body, 'user-select', 'none'); + } + }, + // Returns true - if no further action is needed (either inserted or another condition) + _onDragOver: function _onDragOver( + /**Event*/ + evt) { + var el = this.el, + target = evt.target, + dragRect, + targetRect, + revert, + options = this.options, + group = options.group, + activeSortable = Sortable.active, + isOwner = activeGroup === group, + canSort = options.sort, + fromSortable = putSortable || activeSortable, + vertical, + _this = this, + completedFired = false; + + if (_silent) return; + + function dragOverEvent(name, extra) { + pluginEvent(name, _this, _objectSpread({ + evt: evt, + isOwner: isOwner, + axis: vertical ? 'vertical' : 'horizontal', + revert: revert, + dragRect: dragRect, + targetRect: targetRect, + canSort: canSort, + fromSortable: fromSortable, + target: target, + completed: completed, + onMove: function onMove(target, after) { + return _onMove(rootEl, el, dragEl, dragRect, target, getRect(target), evt, after); + }, + changed: changed + }, extra)); + } // Capture animation state - while (i--) { - sum += str.charCodeAt(i); - } - return sum.toString(36); - } + function capture() { + dragOverEvent('dragOverAnimationCapture'); - /** - * Returns the index of an element within its parent for a selected set of - * elements - * @param {HTMLElement} el - * @param {selector} selector - * @return {number} - */ - function _index(el, selector) { - var index = 0; - - if (!el || !el.parentNode) { - return -1; - } + _this.captureAnimationState(); - while (el && (el = el.previousElementSibling)) { - if ((el.nodeName.toUpperCase() !== 'TEMPLATE') && (selector === '>*' || _matches(el, selector))) { - index++; - } - } + if (_this !== fromSortable) { + fromSortable.captureAnimationState(); + } + } // Return invocation when dragEl is inserted (or completed) - return index; - } - function _matches(/**HTMLElement*/el, /**String*/selector) { - if (el) { - selector = selector.split('.'); + function completed(insertion) { + dragOverEvent('dragOverCompleted', { + insertion: insertion + }); - var tag = selector.shift().toUpperCase(), - re = new RegExp('\\s(' + selector.join('|') + ')(?=\\s)', 'g'); + if (insertion) { + // Clones must be hidden before folding animation to capture dragRectAbsolute properly + if (isOwner) { + activeSortable._hideClone(); + } else { + activeSortable._showClone(_this); + } - return ( - (tag === '' || el.nodeName.toUpperCase() == tag) && - (!selector.length || ((' ' + el.className + ' ').match(re) || []).length == selector.length) - ); - } + if (_this !== fromSortable) { + // Set ghost class to new sortable's ghost class + toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : activeSortable.options.ghostClass, false); + toggleClass(dragEl, options.ghostClass, true); + } - return false; - } + if (putSortable !== _this && _this !== Sortable.active) { + putSortable = _this; + } else if (_this === Sortable.active && putSortable) { + putSortable = null; + } // Animation - function _throttle(callback, ms) { - var args, _this; - return function () { - if (args === void 0) { - args = arguments; - _this = this; + if (fromSortable === _this) { + _this._ignoreWhileAnimating = target; + } - setTimeout(function () { - if (args.length === 1) { - callback.call(_this, args[0]); - } else { - callback.apply(_this, args); - } + _this.animateAll(function () { + dragOverEvent('dragOverAnimationComplete'); + _this._ignoreWhileAnimating = null; + }); - args = void 0; - }, ms); - } - }; - } + if (_this !== fromSortable) { + fromSortable.animateAll(); + fromSortable._ignoreWhileAnimating = null; + } + } // Null lastTarget if it is not inside a previously swapped element - function _extend(dst, src) { - if (dst && src) { - for (var key in src) { - if (src.hasOwnProperty(key)) { - dst[key] = src[key]; - } - } - } - return dst; - } + if (target === dragEl && !dragEl.animated || target === el && !target.animated) { + lastTarget = null; + } // no bubbling and not fallback - function _clone(el) { - return $ - ? $(el).clone(true)[0] - : (Polymer && Polymer.dom - ? Polymer.dom(el).cloneNode(true) - : el.cloneNode(true) - ); - } - function _saveInputCheckedState(root) { - var inputs = root.getElementsByTagName('input'); - var idx = inputs.length; + if (!options.dragoverBubble && !evt.rootEl && target !== document) { + dragEl.parentNode[expando]._isOutsideThisEl(evt.target); // Do not detect for empty insert if already inserted - while (idx--) { - var el = inputs[idx]; - el.checked && savedInputChecked.push(el); - } - } - // Fixed #973: - _on(document, 'touchmove', function (evt) { - if (Sortable.active) { - evt.preventDefault(); - } - }); - - try { - window.addEventListener('test', null, Object.defineProperty({}, 'passive', { - get: function () { - captureMode = { - capture: false, - passive: false - }; - } - })); - } catch (err) {} - - // Export utils - Sortable.utils = { - on: _on, - off: _off, - css: _css, - find: _find, - is: function (el, selector) { - return !!_closest(el, selector, el); - }, - extend: _extend, - throttle: _throttle, - closest: _closest, - toggleClass: _toggleClass, - clone: _clone, - index: _index - }; - - - /** - * Create sortable instance - * @param {HTMLElement} el - * @param {Object} [options] - */ - Sortable.create = function (el, options) { - return new Sortable(el, options); - }; - - - // Export - Sortable.version = '1.6.1'; - return Sortable; -}); + !insertion && nearestEmptyInsertDetectEvent(evt); + } -},{}],47:[function(require,module,exports){ -(function (setImmediate,clearImmediate){ -var nextTick = require('process/browser.js').nextTick; -var apply = Function.prototype.apply; -var slice = Array.prototype.slice; -var immediateIds = {}; -var nextImmediateId = 0; + !options.dragoverBubble && evt.stopPropagation && evt.stopPropagation(); + return completedFired = true; + } // Call when dragEl has been inserted -// DOM APIs, for completeness -exports.setTimeout = function() { - return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout); -}; -exports.setInterval = function() { - return new Timeout(apply.call(setInterval, window, arguments), clearInterval); -}; -exports.clearTimeout = -exports.clearInterval = function(timeout) { timeout.close(); }; + function changed() { + newIndex = index(dragEl); + newDraggableIndex = index(dragEl, options.draggable); -function Timeout(id, clearFn) { - this._id = id; - this._clearFn = clearFn; -} -Timeout.prototype.unref = Timeout.prototype.ref = function() {}; -Timeout.prototype.close = function() { - this._clearFn.call(window, this._id); -}; + _dispatchEvent({ + sortable: _this, + name: 'change', + toEl: el, + newIndex: newIndex, + newDraggableIndex: newDraggableIndex, + originalEvent: evt + }); + } -// Does not start the time, just sets up the members needed. -exports.enroll = function(item, msecs) { - clearTimeout(item._idleTimeoutId); - item._idleTimeout = msecs; -}; + if (evt.preventDefault !== void 0) { + evt.cancelable && evt.preventDefault(); + } -exports.unenroll = function(item) { - clearTimeout(item._idleTimeoutId); - item._idleTimeout = -1; -}; + target = closest(target, options.draggable, el, true); + dragOverEvent('dragOver'); + if (Sortable.eventCanceled) return completedFired; -exports._unrefActive = exports.active = function(item) { - clearTimeout(item._idleTimeoutId); + if (dragEl.contains(evt.target) || target.animated && target.animatingX && target.animatingY || _this._ignoreWhileAnimating === target) { + return completed(false); + } - var msecs = item._idleTimeout; - if (msecs >= 0) { - item._idleTimeoutId = setTimeout(function onTimeout() { - if (item._onTimeout) - item._onTimeout(); - }, msecs); - } -}; + ignoreNextClick = false; -// That's not how node.js implements it but the exposed api is the same. -exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) { - var id = nextImmediateId++; - var args = arguments.length < 2 ? false : slice.call(arguments, 1); + if (activeSortable && !options.disabled && (isOwner ? canSort || (revert = !rootEl.contains(dragEl)) // Reverting item into the original list + : putSortable === this || (this.lastPutMode = activeGroup.checkPull(this, activeSortable, dragEl, evt)) && group.checkPut(this, activeSortable, dragEl, evt))) { + vertical = this._getDirection(evt, target) === 'vertical'; + dragRect = getRect(dragEl); + dragOverEvent('dragOverValid'); + if (Sortable.eventCanceled) return completedFired; - immediateIds[id] = true; + if (revert) { + parentEl = rootEl; // actualization - nextTick(function onNextTick() { - if (immediateIds[id]) { - // fn.call() is faster so we optimize for the common use-case - // @see http://jsperf.com/call-apply-segu - if (args) { - fn.apply(null, args); - } else { - fn.call(null); - } - // Prevent ids from leaking - exports.clearImmediate(id); - } - }); + capture(); - return id; -}; + this._hideClone(); -exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) { - delete immediateIds[id]; -}; -}).call(this,require("timers").setImmediate,require("timers").clearImmediate) -},{"process/browser.js":45,"timers":47}],48:[function(require,module,exports){ -var Vue // late bind -var version -var map = (window.__VUE_HOT_MAP__ = Object.create(null)) -var installed = false -var isBrowserify = false -var initHookName = 'beforeCreate' + dragOverEvent('revert'); -exports.install = function (vue, browserify) { - if (installed) { return } - installed = true + if (!Sortable.eventCanceled) { + if (nextEl) { + rootEl.insertBefore(dragEl, nextEl); + } else { + rootEl.appendChild(dragEl); + } + } - Vue = vue.__esModule ? vue.default : vue - version = Vue.version.split('.').map(Number) - isBrowserify = browserify + return completed(true); + } - // compat with < 2.0.0-alpha.7 - if (Vue.config._lifecycleHooks.indexOf('init') > -1) { - initHookName = 'init' - } + var elLastChild = lastChild(el, options.draggable); - exports.compatible = version[0] >= 2 - if (!exports.compatible) { - console.warn( - '[HMR] You are using a version of vue-hot-reload-api that is ' + - 'only compatible with Vue.js core ^2.0.0.' - ) - return - } -} + if (!elLastChild || _ghostIsLast(evt, vertical, this) && !elLastChild.animated) { + // If already at end of list: Do not insert + if (elLastChild === dragEl) { + return completed(false); + } // assign target only if condition is true -/** - * Create a record for a hot module, which keeps track of its constructor - * and instances - * - * @param {String} id - * @param {Object} options - */ -exports.createRecord = function (id, options) { - var Ctor = null - if (typeof options === 'function') { - Ctor = options - options = Ctor.options - } - makeOptionsHot(id, options) - map[id] = { - Ctor: Ctor, - options: options, - instances: [] - } -} + if (elLastChild && el === evt.target) { + target = elLastChild; + } -/** - * Make a Component options object hot. - * - * @param {String} id - * @param {Object} options - */ + if (target) { + targetRect = getRect(target); + } -function makeOptionsHot(id, options) { - if (options.functional) { - var render = options.render - options.render = function (h, ctx) { - var instances = map[id].instances - if (instances.indexOf(ctx.parent) < 0) { - instances.push(ctx.parent) - } - return render(h, ctx) - } - } else { - injectHook(options, initHookName, function() { - var record = map[id] - if (!record.Ctor) { - record.Ctor = this.constructor - } - record.instances.push(this) - }) - injectHook(options, 'beforeDestroy', function() { - var instances = map[id].instances - instances.splice(instances.indexOf(this), 1) - }) - } -} + if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, !!target) !== false) { + capture(); + el.appendChild(dragEl); + parentEl = el; // actualization -/** - * Inject a hook to a hot reloadable component so that - * we can keep track of it. - * - * @param {Object} options - * @param {String} name - * @param {Function} hook - */ + changed(); + return completed(true); + } + } else if (target.parentNode === el) { + targetRect = getRect(target); + var direction = 0, + targetBeforeFirstSwap, + differentLevel = dragEl.parentNode !== el, + differentRowCol = !_dragElInRowColumn(dragEl.animated && dragEl.toRect || dragRect, target.animated && target.toRect || targetRect, vertical), + side1 = vertical ? 'top' : 'left', + scrolledPastTop = isScrolledPast(target, 'top', 'top') || isScrolledPast(dragEl, 'top', 'top'), + scrollBefore = scrolledPastTop ? scrolledPastTop.scrollTop : void 0; + + if (lastTarget !== target) { + targetBeforeFirstSwap = targetRect[side1]; + pastFirstInvertThresh = false; + isCircumstantialInvert = !differentRowCol && options.invertSwap || differentLevel; + } -function injectHook(options, name, hook) { - var existing = options[name] - options[name] = existing - ? Array.isArray(existing) ? existing.concat(hook) : [existing, hook] - : [hook] -} + direction = _getSwapDirection(evt, target, targetRect, vertical, differentRowCol ? 1 : options.swapThreshold, options.invertedSwapThreshold == null ? options.swapThreshold : options.invertedSwapThreshold, isCircumstantialInvert, lastTarget === target); + var sibling; -function tryWrap(fn) { - return function (id, arg) { - try { - fn(id, arg) - } catch (e) { - console.error(e) - console.warn( - 'Something went wrong during Vue component hot-reload. Full reload required.' - ) - } - } -} + if (direction !== 0) { + // Check if target is beside dragEl in respective direction (ignoring hidden elements) + var dragIndex = index(dragEl); -function updateOptions (oldOptions, newOptions) { - for (var key in oldOptions) { - if (!(key in newOptions)) { - delete oldOptions[key] - } - } - for (var key$1 in newOptions) { - oldOptions[key$1] = newOptions[key$1] - } -} + do { + dragIndex -= direction; + sibling = parentEl.children[dragIndex]; + } while (sibling && (css(sibling, 'display') === 'none' || sibling === ghostEl)); + } // If dragEl is already beside target: Do not insert -exports.rerender = tryWrap(function (id, options) { - var record = map[id] - if (!options) { - record.instances.slice().forEach(function (instance) { - instance.$forceUpdate() - }) - return - } - if (typeof options === 'function') { - options = options.options - } - if (record.Ctor) { - record.Ctor.options.render = options.render - record.Ctor.options.staticRenderFns = options.staticRenderFns - record.instances.slice().forEach(function (instance) { - instance.$options.render = options.render - instance.$options.staticRenderFns = options.staticRenderFns - // reset static trees - if (instance._staticTrees) { - // pre 2.5 staticTrees are cached per-instance - instance._staticTrees = [] - } else { - // post 2.5 staticTrees are cached on shared options - record.Ctor.options._staticTrees = [] - } - instance.$forceUpdate() - }) - } else { - // functional or no instance created yet - record.options.render = options.render - record.options.staticRenderFns = options.staticRenderFns - // handle functional component re-render - if (record.options.functional) { - // rerender with full options - if (Object.keys(options).length > 2) { - updateOptions(record.options, options) - } else { - // template-only rerender. - // need to inject the style injection code for CSS modules - // to work properly. - var injectStyles = record.options._injectStyles - if (injectStyles) { - var render = options.render - record.options.render = function (h, ctx) { - injectStyles.call(ctx) - return render(h, ctx) + if (direction === 0 || sibling === target) { + return completed(false); + } + + lastTarget = target; + lastDirection = direction; + var nextSibling = target.nextElementSibling, + after = false; + after = direction === 1; + + var moveVector = _onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, after); + + if (moveVector !== false) { + if (moveVector === 1 || moveVector === -1) { + after = moveVector === 1; + } + + _silent = true; + setTimeout(_unsilent, 30); + capture(); + + if (after && !nextSibling) { + el.appendChild(dragEl); + } else { + target.parentNode.insertBefore(dragEl, after ? nextSibling : target); + } // Undo chrome's scroll adjustment (has no effect on other browsers) + + + if (scrolledPastTop) { + scrollBy(scrolledPastTop, 0, scrollBefore - scrolledPastTop.scrollTop); + } + + parentEl = dragEl.parentNode; // actualization + // must be done before animation + + if (targetBeforeFirstSwap !== undefined && !isCircumstantialInvert) { + targetMoveDistance = Math.abs(targetBeforeFirstSwap - getRect(target)[side1]); + } + + changed(); + return completed(true); } } + + if (el.contains(dragEl)) { + return completed(false); + } } - record.options._Ctor = null - record.options._staticTrees = [] - record.instances.slice().forEach(function (instance) { - instance.$forceUpdate() - }) - } - } -}) -exports.reload = tryWrap(function (id, options) { - var record = map[id] - if (options) { - if (typeof options === 'function') { - options = options.options - } - makeOptionsHot(id, options) - if (record.Ctor) { - if (version[1] < 2) { - // preserve pre 2.2 behavior for global mixin handling - record.Ctor.extendOptions = options - } - var newCtor = record.Ctor.super.extend(options) - record.Ctor.options = newCtor.options - record.Ctor.cid = newCtor.cid - record.Ctor.prototype = newCtor.prototype - if (newCtor.release) { - // temporary global mixin strategy used in < 2.0.0-alpha.6 - newCtor.release() - } - } else { - updateOptions(record.options, options) - } - } - record.instances.slice().forEach(function (instance) { - if (instance.$vnode && instance.$vnode.context) { - instance.$vnode.context.$forceUpdate() - } else { - console.warn( - 'Root or manually mounted instance modified. Full reload required.' - ) - } - }) -}) + return false; + }, + _ignoreWhileAnimating: null, + _offMoveEvents: function _offMoveEvents() { + off(document, 'mousemove', this._onTouchMove); + off(document, 'touchmove', this._onTouchMove); + off(document, 'pointermove', this._onTouchMove); + off(document, 'dragover', nearestEmptyInsertDetectEvent); + off(document, 'mousemove', nearestEmptyInsertDetectEvent); + off(document, 'touchmove', nearestEmptyInsertDetectEvent); + }, + _offUpEvents: function _offUpEvents() { + var ownerDocument = this.el.ownerDocument; + off(ownerDocument, 'mouseup', this._onDrop); + off(ownerDocument, 'touchend', this._onDrop); + off(ownerDocument, 'pointerup', this._onDrop); + off(ownerDocument, 'touchcancel', this._onDrop); + off(document, 'selectstart', this); + }, + _onDrop: function _onDrop( + /**Event*/ + evt) { + var el = this.el, + options = this.options; // Get the index of the dragged element within its parent + + newIndex = index(dragEl); + newDraggableIndex = index(dragEl, options.draggable); + pluginEvent('drop', this, { + evt: evt + }); + parentEl = dragEl && dragEl.parentNode; // Get again after plugin event -},{}],49:[function(require,module,exports){ -/*! - * vue-resource v1.3.4 - * https://github.com/pagekit/vue-resource - * Released under the MIT License. - */ + newIndex = index(dragEl); + newDraggableIndex = index(dragEl, options.draggable); -'use strict'; + if (Sortable.eventCanceled) { + this._nulling(); -/** - * Promises/A+ polyfill v1.1.4 (https://github.com/bramstein/promis) - */ + return; + } -var RESOLVED = 0; -var REJECTED = 1; -var PENDING = 2; + awaitingDragStarted = false; + isCircumstantialInvert = false; + pastFirstInvertThresh = false; + clearInterval(this._loopId); + clearTimeout(this._dragStartTimer); -function Promise$1(executor) { + _cancelNextTick(this.cloneId); - this.state = PENDING; - this.value = undefined; - this.deferred = []; + _cancelNextTick(this._dragStartId); // Unbind events - var promise = this; - try { - executor(function (x) { - promise.resolve(x); - }, function (r) { - promise.reject(r); - }); - } catch (e) { - promise.reject(e); - } -} + if (this.nativeDraggable) { + off(document, 'drop', this); + off(el, 'dragstart', this._onDragStart); + } -Promise$1.reject = function (r) { - return new Promise$1(function (resolve, reject) { - reject(r); - }); -}; + this._offMoveEvents(); -Promise$1.resolve = function (x) { - return new Promise$1(function (resolve, reject) { - resolve(x); - }); -}; + this._offUpEvents(); -Promise$1.all = function all(iterable) { - return new Promise$1(function (resolve, reject) { - var count = 0, result = []; + if (Safari) { + css(document.body, 'user-select', ''); + } - if (iterable.length === 0) { - resolve(result); + css(dragEl, 'transform', ''); + + if (evt) { + if (moved) { + evt.cancelable && evt.preventDefault(); + !options.dropBubble && evt.stopPropagation(); } - function resolver(i) { - return function (x) { - result[i] = x; - count += 1; + ghostEl && ghostEl.parentNode && ghostEl.parentNode.removeChild(ghostEl); - if (count === iterable.length) { - resolve(result); - } - }; + if (rootEl === parentEl || putSortable && putSortable.lastPutMode !== 'clone') { + // Remove clone(s) + cloneEl && cloneEl.parentNode && cloneEl.parentNode.removeChild(cloneEl); } - for (var i = 0; i < iterable.length; i += 1) { - Promise$1.resolve(iterable[i]).then(resolver(i), reject); - } - }); -}; + if (dragEl) { + if (this.nativeDraggable) { + off(dragEl, 'dragend', this); + } -Promise$1.race = function race(iterable) { - return new Promise$1(function (resolve, reject) { - for (var i = 0; i < iterable.length; i += 1) { - Promise$1.resolve(iterable[i]).then(resolve, reject); - } - }); -}; + _disableDraggable(dragEl); -var p$1 = Promise$1.prototype; + dragEl.style['will-change'] = ''; // Remove classes + // ghostClass is added in dragStarted -p$1.resolve = function resolve(x) { - var promise = this; + if (moved && !awaitingDragStarted) { + toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : this.options.ghostClass, false); + } - if (promise.state === PENDING) { - if (x === promise) { - throw new TypeError('Promise settled with itself.'); - } + toggleClass(dragEl, this.options.chosenClass, false); // Drag stop event - var called = false; + _dispatchEvent({ + sortable: this, + name: 'unchoose', + toEl: parentEl, + newIndex: null, + newDraggableIndex: null, + originalEvent: evt + }); - try { - var then = x && x['then']; + if (rootEl !== parentEl) { + if (newIndex >= 0) { + // Add event + _dispatchEvent({ + rootEl: parentEl, + name: 'add', + toEl: parentEl, + fromEl: rootEl, + originalEvent: evt + }); // Remove event + + + _dispatchEvent({ + sortable: this, + name: 'remove', + toEl: parentEl, + originalEvent: evt + }); // drag from one list and drop into another + + + _dispatchEvent({ + rootEl: parentEl, + name: 'sort', + toEl: parentEl, + fromEl: rootEl, + originalEvent: evt + }); + + _dispatchEvent({ + sortable: this, + name: 'sort', + toEl: parentEl, + originalEvent: evt + }); + } - if (x !== null && typeof x === 'object' && typeof then === 'function') { - then.call(x, function (x) { - if (!called) { - promise.resolve(x); - } - called = true; + putSortable && putSortable.save(); + } else { + if (newIndex !== oldIndex) { + if (newIndex >= 0) { + // drag & drop within the same list + _dispatchEvent({ + sortable: this, + name: 'update', + toEl: parentEl, + originalEvent: evt + }); - }, function (r) { - if (!called) { - promise.reject(r); - } - called = true; + _dispatchEvent({ + sortable: this, + name: 'sort', + toEl: parentEl, + originalEvent: evt }); - return; + } } - } catch (e) { - if (!called) { - promise.reject(e); + } + + if (Sortable.active) { + /* jshint eqnull:true */ + if (newIndex == null || newIndex === -1) { + newIndex = oldIndex; + newDraggableIndex = oldDraggableIndex; } - return; - } - promise.state = RESOLVED; - promise.value = x; - promise.notify(); - } -}; + _dispatchEvent({ + sortable: this, + name: 'end', + toEl: parentEl, + originalEvent: evt + }); // Save sorting -p$1.reject = function reject(reason) { - var promise = this; - if (promise.state === PENDING) { - if (reason === promise) { - throw new TypeError('Promise settled with itself.'); + this.save(); + } } + } - promise.state = REJECTED; - promise.value = reason; - promise.notify(); - } -}; + this._nulling(); + }, + _nulling: function _nulling() { + pluginEvent('nulling', this); + rootEl = dragEl = parentEl = ghostEl = nextEl = cloneEl = lastDownEl = cloneHidden = tapEvt = touchEvt = moved = newIndex = newDraggableIndex = oldIndex = oldDraggableIndex = lastTarget = lastDirection = putSortable = activeGroup = Sortable.dragged = Sortable.ghost = Sortable.clone = Sortable.active = null; + savedInputChecked.forEach(function (el) { + el.checked = true; + }); + savedInputChecked.length = lastDx = lastDy = 0; + }, + handleEvent: function handleEvent( + /**Event*/ + evt) { + switch (evt.type) { + case 'drop': + case 'dragend': + this._onDrop(evt); + + break; + + case 'dragenter': + case 'dragover': + if (dragEl) { + this._onDragOver(evt); + + _globalDragOver(evt); + } -p$1.notify = function notify() { - var promise = this; + break; - nextTick(function () { - if (promise.state !== PENDING) { - while (promise.deferred.length) { - var deferred = promise.deferred.shift(), - onResolved = deferred[0], - onRejected = deferred[1], - resolve = deferred[2], - reject = deferred[3]; + case 'selectstart': + evt.preventDefault(); + break; + } + }, - try { - if (promise.state === RESOLVED) { - if (typeof onResolved === 'function') { - resolve(onResolved.call(undefined, promise.value)); - } else { - resolve(promise.value); - } - } else if (promise.state === REJECTED) { - if (typeof onRejected === 'function') { - resolve(onRejected.call(undefined, promise.value)); - } else { - reject(promise.value); - } - } - } catch (e) { - reject(e); - } - } + /** + * Serializes the item into an array of string. + * @returns {String[]} + */ + toArray: function toArray() { + var order = [], + el, + children = this.el.children, + i = 0, + n = children.length, + options = this.options; + + for (; i < n; i++) { + el = children[i]; + + if (closest(el, options.draggable, this.el, false)) { + order.push(el.getAttribute(options.dataIdAttr) || _generateId(el)); } - }); -}; + } -p$1.then = function then(onResolved, onRejected) { - var promise = this; + return order; + }, - return new Promise$1(function (resolve, reject) { - promise.deferred.push([onResolved, onRejected, resolve, reject]); - promise.notify(); - }); -}; + /** + * Sorts the elements according to the array. + * @param {String[]} order order of the items + */ + sort: function sort(order) { + var items = {}, + rootEl = this.el; + this.toArray().forEach(function (id, i) { + var el = rootEl.children[i]; + + if (closest(el, this.options.draggable, rootEl, false)) { + items[id] = el; + } + }, this); + order.forEach(function (id) { + if (items[id]) { + rootEl.removeChild(items[id]); + rootEl.appendChild(items[id]); + } + }); + }, -p$1.catch = function (onRejected) { - return this.then(undefined, onRejected); -}; + /** + * Save the current sorting + */ + save: function save() { + var store = this.options.store; + store && store.set && store.set(this); + }, -/** - * Promise adapter. - */ + /** + * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree. + * @param {HTMLElement} el + * @param {String} [selector] default: `options.draggable` + * @returns {HTMLElement|null} + */ + closest: function closest$1(el, selector) { + return closest(el, selector || this.options.draggable, this.el, false); + }, -if (typeof Promise === 'undefined') { - window.Promise = Promise$1; -} + /** + * Set/get option + * @param {string} name + * @param {*} [value] + * @returns {*} + */ + option: function option(name, value) { + var options = this.options; + + if (value === void 0) { + return options[name]; + } else { + var modifiedValue = PluginManager.modifyOption(this, name, value); -function PromiseObj(executor, context) { + if (typeof modifiedValue !== 'undefined') { + options[name] = modifiedValue; + } else { + options[name] = value; + } - if (executor instanceof Promise) { - this.promise = executor; - } else { - this.promise = new Promise(executor.bind(context)); - } + if (name === 'group') { + _prepareGroup(options); + } + } + }, - this.context = context; -} + /** + * Destroy + */ + destroy: function destroy() { + pluginEvent('destroy', this); + var el = this.el; + el[expando] = null; + off(el, 'mousedown', this._onTapStart); + off(el, 'touchstart', this._onTapStart); + off(el, 'pointerdown', this._onTapStart); + + if (this.nativeDraggable) { + off(el, 'dragover', this); + off(el, 'dragenter', this); + } // Remove draggable attributes + + + Array.prototype.forEach.call(el.querySelectorAll('[draggable]'), function (el) { + el.removeAttribute('draggable'); + }); -PromiseObj.all = function (iterable, context) { - return new PromiseObj(Promise.all(iterable), context); -}; + this._onDrop(); -PromiseObj.resolve = function (value, context) { - return new PromiseObj(Promise.resolve(value), context); -}; + this._disableDelayedDragEvents(); -PromiseObj.reject = function (reason, context) { - return new PromiseObj(Promise.reject(reason), context); -}; + sortables.splice(sortables.indexOf(this.el), 1); + this.el = el = null; + }, + _hideClone: function _hideClone() { + if (!cloneHidden) { + pluginEvent('hideClone', this); + if (Sortable.eventCanceled) return; + css(cloneEl, 'display', 'none'); + + if (this.options.removeCloneOnHide && cloneEl.parentNode) { + cloneEl.parentNode.removeChild(cloneEl); + } -PromiseObj.race = function (iterable, context) { - return new PromiseObj(Promise.race(iterable), context); -}; + cloneHidden = true; + } + }, + _showClone: function _showClone(putSortable) { + if (putSortable.lastPutMode !== 'clone') { + this._hideClone(); + + return; + } -var p = PromiseObj.prototype; + if (cloneHidden) { + pluginEvent('showClone', this); + if (Sortable.eventCanceled) return; // show clone at dragEl or original position -p.bind = function (context) { - this.context = context; - return this; -}; + if (rootEl.contains(dragEl) && !this.options.group.revertClone) { + rootEl.insertBefore(cloneEl, dragEl); + } else if (nextEl) { + rootEl.insertBefore(cloneEl, nextEl); + } else { + rootEl.appendChild(cloneEl); + } -p.then = function (fulfilled, rejected) { + if (this.options.group.revertClone) { + this.animate(dragEl, cloneEl); + } - if (fulfilled && fulfilled.bind && this.context) { - fulfilled = fulfilled.bind(this.context); + css(cloneEl, 'display', ''); + cloneHidden = false; + } } + }; - if (rejected && rejected.bind && this.context) { - rejected = rejected.bind(this.context); + function _globalDragOver( + /**Event*/ + evt) { + if (evt.dataTransfer) { + evt.dataTransfer.dropEffect = 'move'; } - return new PromiseObj(this.promise.then(fulfilled, rejected), this.context); -}; + evt.cancelable && evt.preventDefault(); + } -p.catch = function (rejected) { + function _onMove(fromEl, toEl, dragEl, dragRect, targetEl, targetRect, originalEvent, willInsertAfter) { + var evt, + sortable = fromEl[expando], + onMoveFn = sortable.options.onMove, + retVal; // Support for new CustomEvent feature - if (rejected && rejected.bind && this.context) { - rejected = rejected.bind(this.context); + if (window.CustomEvent && !IE11OrLess && !Edge) { + evt = new CustomEvent('move', { + bubbles: true, + cancelable: true + }); + } else { + evt = document.createEvent('Event'); + evt.initEvent('move', true, true); } - return new PromiseObj(this.promise.catch(rejected), this.context); -}; - -p.finally = function (callback) { - - return this.then(function (value) { - callback.call(this); - return value; - }, function (reason) { - callback.call(this); - return Promise.reject(reason); - } - ); -}; + evt.to = toEl; + evt.from = fromEl; + evt.dragged = dragEl; + evt.draggedRect = dragRect; + evt.related = targetEl || toEl; + evt.relatedRect = targetRect || getRect(toEl); + evt.willInsertAfter = willInsertAfter; + evt.originalEvent = originalEvent; + fromEl.dispatchEvent(evt); -/** - * Utility functions. - */ + if (onMoveFn) { + retVal = onMoveFn.call(sortable, evt, originalEvent); + } -var ref = {}; -var hasOwnProperty = ref.hasOwnProperty; + return retVal; + } -var ref$1 = []; -var slice = ref$1.slice; -var debug = false; -var ntick; + function _disableDraggable(el) { + el.draggable = false; + } -var inBrowser = typeof window !== 'undefined'; + function _unsilent() { + _silent = false; + } -var Util = function (ref) { - var config = ref.config; - var nextTick = ref.nextTick; + function _ghostIsLast(evt, vertical, sortable) { + var rect = getRect(lastChild(sortable.el, sortable.options.draggable)); + var spacer = 10; + return vertical ? evt.clientX > rect.right + spacer || evt.clientX <= rect.right && evt.clientY > rect.bottom && evt.clientX >= rect.left : evt.clientX > rect.right && evt.clientY > rect.top || evt.clientX <= rect.right && evt.clientY > rect.bottom + spacer; + } - ntick = nextTick; - debug = config.debug || !config.silent; -}; + function _getSwapDirection(evt, target, targetRect, vertical, swapThreshold, invertedSwapThreshold, invertSwap, isLastTarget) { + var mouseOnAxis = vertical ? evt.clientY : evt.clientX, + targetLength = vertical ? targetRect.height : targetRect.width, + targetS1 = vertical ? targetRect.top : targetRect.left, + targetS2 = vertical ? targetRect.bottom : targetRect.right, + invert = false; -function warn(msg) { - if (typeof console !== 'undefined' && debug) { - console.warn('[VueResource warn]: ' + msg); - } -} + if (!invertSwap) { + // Never invert or create dragEl shadow when target movemenet causes mouse to move past the end of regular swapThreshold + if (isLastTarget && targetMoveDistance < targetLength * swapThreshold) { + // multiplied only by swapThreshold because mouse will already be inside target by (1 - threshold) * targetLength / 2 + // check if past first invert threshold on side opposite of lastDirection + if (!pastFirstInvertThresh && (lastDirection === 1 ? mouseOnAxis > targetS1 + targetLength * invertedSwapThreshold / 2 : mouseOnAxis < targetS2 - targetLength * invertedSwapThreshold / 2)) { + // past first invert threshold, do not restrict inverted threshold to dragEl shadow + pastFirstInvertThresh = true; + } -function error(msg) { - if (typeof console !== 'undefined') { - console.error(msg); + if (!pastFirstInvertThresh) { + // dragEl shadow (target move distance shadow) + if (lastDirection === 1 ? mouseOnAxis < targetS1 + targetMoveDistance // over dragEl shadow + : mouseOnAxis > targetS2 - targetMoveDistance) { + return -lastDirection; + } + } else { + invert = true; + } + } else { + // Regular + if (mouseOnAxis > targetS1 + targetLength * (1 - swapThreshold) / 2 && mouseOnAxis < targetS2 - targetLength * (1 - swapThreshold) / 2) { + return _getInsertDirection(target); + } + } } -} -function nextTick(cb, ctx) { - return ntick(cb, ctx); -} + invert = invert || invertSwap; -function trim(str) { - return str ? str.replace(/^\s*|\s*$/g, '') : ''; -} + if (invert) { + // Invert of regular + if (mouseOnAxis < targetS1 + targetLength * invertedSwapThreshold / 2 || mouseOnAxis > targetS2 - targetLength * invertedSwapThreshold / 2) { + return mouseOnAxis > targetS1 + targetLength / 2 ? 1 : -1; + } + } -function trimEnd(str, chars) { + return 0; + } + /** + * Gets the direction dragEl must be swapped relative to target in order to make it + * seem that dragEl has been "inserted" into that element's position + * @param {HTMLElement} target The target whose position dragEl is being inserted at + * @return {Number} Direction dragEl must be swapped + */ - if (str && chars === undefined) { - return str.replace(/\s+$/, ''); - } - if (!str || !chars) { - return str; + function _getInsertDirection(target) { + if (index(dragEl) < index(target)) { + return 1; + } else { + return -1; } + } + /** + * Generate id + * @param {HTMLElement} el + * @returns {String} + * @private + */ - return str.replace(new RegExp(("[" + chars + "]+$")), ''); -} -function toLower(str) { - return str ? str.toLowerCase() : ''; -} + function _generateId(el) { + var str = el.tagName + el.className + el.src + el.href + el.textContent, + i = str.length, + sum = 0; -function toUpper(str) { - return str ? str.toUpperCase() : ''; -} + while (i--) { + sum += str.charCodeAt(i); + } -var isArray = Array.isArray; + return sum.toString(36); + } -function isString(val) { - return typeof val === 'string'; -} + function _saveInputCheckedState(root) { + savedInputChecked.length = 0; + var inputs = root.getElementsByTagName('input'); + var idx = inputs.length; + while (idx--) { + var el = inputs[idx]; + el.checked && savedInputChecked.push(el); + } + } + function _nextTick(fn) { + return setTimeout(fn, 0); + } -function isFunction(val) { - return typeof val === 'function'; -} + function _cancelNextTick(id) { + return clearTimeout(id); + } // Fixed #973: -function isObject(obj) { - return obj !== null && typeof obj === 'object'; -} -function isPlainObject(obj) { - return isObject(obj) && Object.getPrototypeOf(obj) == Object.prototype; -} + if (documentExists) { + on(document, 'touchmove', function (evt) { + if ((Sortable.active || awaitingDragStarted) && evt.cancelable) { + evt.preventDefault(); + } + }); + } // Export utils -function isBlob(obj) { - return typeof Blob !== 'undefined' && obj instanceof Blob; -} -function isFormData(obj) { - return typeof FormData !== 'undefined' && obj instanceof FormData; -} + Sortable.utils = { + on: on, + off: off, + css: css, + find: find, + is: function is(el, selector) { + return !!closest(el, selector, el, false); + }, + extend: extend, + throttle: throttle, + closest: closest, + toggleClass: toggleClass, + clone: clone, + index: index, + nextTick: _nextTick, + cancelNextTick: _cancelNextTick, + detectDirection: _detectDirection, + getChild: getChild + }; + /** + * Get the Sortable instance of an element + * @param {HTMLElement} element The element + * @return {Sortable|undefined} The instance of Sortable + */ -function when(value, fulfilled, rejected) { + Sortable.get = function (element) { + return element[expando]; + }; + /** + * Mount a plugin to Sortable + * @param {...SortablePlugin|SortablePlugin[]} plugins Plugins being mounted + */ - var promise = PromiseObj.resolve(value); - if (arguments.length < 2) { - return promise; + Sortable.mount = function () { + for (var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++) { + plugins[_key] = arguments[_key]; } - return promise.then(fulfilled, rejected); -} + if (plugins[0].constructor === Array) plugins = plugins[0]; + plugins.forEach(function (plugin) { + if (!plugin.prototype || !plugin.prototype.constructor) { + throw "Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(plugin)); + } -function options(fn, obj, opts) { + if (plugin.utils) Sortable.utils = _objectSpread({}, Sortable.utils, plugin.utils); + PluginManager.mount(plugin); + }); + }; + /** + * Create sortable instance + * @param {HTMLElement} el + * @param {Object} [options] + */ - opts = opts || {}; - if (isFunction(opts)) { - opts = opts.call(obj); - } + Sortable.create = function (el, options) { + return new Sortable(el, options); + }; // Export - return merge(fn.bind({$vm: obj, $options: opts}), fn, {$options: opts}); -} -function each(obj, iterator) { + Sortable.version = version; - var i, key; + var autoScrolls = [], + scrollEl, + scrollRootEl, + scrolling = false, + lastAutoScrollX, + lastAutoScrollY, + touchEvt$1, + pointerElemChangedInterval; - if (isArray(obj)) { - for (i = 0; i < obj.length; i++) { - iterator.call(obj[i], obj[i], i); - } - } else if (isObject(obj)) { - for (key in obj) { - if (hasOwnProperty.call(obj, key)) { - iterator.call(obj[key], obj[key], key); - } + function AutoScrollPlugin() { + function AutoScroll() { + this.defaults = { + scroll: true, + scrollSensitivity: 30, + scrollSpeed: 10, + bubbleScroll: true + }; // Bind all private methods + + for (var fn in this) { + if (fn.charAt(0) === '_' && typeof this[fn] === 'function') { + this[fn] = this[fn].bind(this); } + } } - return obj; -} + AutoScroll.prototype = { + dragStarted: function dragStarted(_ref) { + var originalEvent = _ref.originalEvent; -var assign = Object.assign || _assign; + if (this.sortable.nativeDraggable) { + on(document, 'dragover', this._handleAutoScroll); + } else { + if (this.options.supportPointer) { + on(document, 'pointermove', this._handleFallbackAutoScroll); + } else if (originalEvent.touches) { + on(document, 'touchmove', this._handleFallbackAutoScroll); + } else { + on(document, 'mousemove', this._handleFallbackAutoScroll); + } + } + }, + dragOverCompleted: function dragOverCompleted(_ref2) { + var originalEvent = _ref2.originalEvent; -function merge(target) { + // For when bubbling is canceled and using fallback (fallback 'touchmove' always reached) + if (!this.options.dragOverBubble && !originalEvent.rootEl) { + this._handleAutoScroll(originalEvent); + } + }, + drop: function drop() { + if (this.sortable.nativeDraggable) { + off(document, 'dragover', this._handleAutoScroll); + } else { + off(document, 'pointermove', this._handleFallbackAutoScroll); + off(document, 'touchmove', this._handleFallbackAutoScroll); + off(document, 'mousemove', this._handleFallbackAutoScroll); + } - var args = slice.call(arguments, 1); + clearPointerElemChangedInterval(); + clearAutoScrolls(); + cancelThrottle(); + }, + nulling: function nulling() { + touchEvt$1 = scrollRootEl = scrollEl = scrolling = pointerElemChangedInterval = lastAutoScrollX = lastAutoScrollY = null; + autoScrolls.length = 0; + }, + _handleFallbackAutoScroll: function _handleFallbackAutoScroll(evt) { + this._handleAutoScroll(evt, true); + }, + _handleAutoScroll: function _handleAutoScroll(evt, fallback) { + var _this = this; - args.forEach(function (source) { - _merge(target, source, true); - }); + var x = (evt.touches ? evt.touches[0] : evt).clientX, + y = (evt.touches ? evt.touches[0] : evt).clientY, + elem = document.elementFromPoint(x, y); + touchEvt$1 = evt; // IE does not seem to have native autoscroll, + // Edge's autoscroll seems too conditional, + // MACOS Safari does not have autoscroll, + // Firefox and Chrome are good - return target; -} + if (fallback || Edge || IE11OrLess || Safari) { + autoScroll(evt, this.options, elem, fallback); // Listener for pointer element change -function defaults(target) { + var ogElemScroller = getParentAutoScrollElement(elem, true); - var args = slice.call(arguments, 1); + if (scrolling && (!pointerElemChangedInterval || x !== lastAutoScrollX || y !== lastAutoScrollY)) { + pointerElemChangedInterval && clearPointerElemChangedInterval(); // Detect for pointer elem change, emulating native DnD behaviour - args.forEach(function (source) { + pointerElemChangedInterval = setInterval(function () { + var newElem = getParentAutoScrollElement(document.elementFromPoint(x, y), true); - for (var key in source) { - if (target[key] === undefined) { - target[key] = source[key]; - } + if (newElem !== ogElemScroller) { + ogElemScroller = newElem; + clearAutoScrolls(); + } + + autoScroll(evt, _this.options, newElem, fallback); + }, 10); + lastAutoScrollX = x; + lastAutoScrollY = y; + } + } else { + // if DnD is enabled (and browser has good autoscrolling), first autoscroll will already scroll, so get parent autoscroll of first autoscroll + if (!this.options.bubbleScroll || getParentAutoScrollElement(elem, true) === getWindowScrollingElement()) { + clearAutoScrolls(); + return; + } + + autoScroll(evt, this.options, getParentAutoScrollElement(elem, false), false); } + } + }; + return _extends(AutoScroll, { + pluginName: 'scroll', + initializeByDefault: true + }); + } + function clearAutoScrolls() { + autoScrolls.forEach(function (autoScroll) { + clearInterval(autoScroll.pid); }); + autoScrolls = []; + } + + function clearPointerElemChangedInterval() { + clearInterval(pointerElemChangedInterval); + } + + var autoScroll = throttle(function (evt, options, rootEl, isFallback) { + // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=505521 + if (!options.scroll) return; + var x = (evt.touches ? evt.touches[0] : evt).clientX, + y = (evt.touches ? evt.touches[0] : evt).clientY, + sens = options.scrollSensitivity, + speed = options.scrollSpeed, + winScroller = getWindowScrollingElement(); + var scrollThisInstance = false, + scrollCustomFn; // New scroll root, set scrollEl + + if (scrollRootEl !== rootEl) { + scrollRootEl = rootEl; + clearAutoScrolls(); + scrollEl = options.scroll; + scrollCustomFn = options.scrollFn; + + if (scrollEl === true) { + scrollEl = getParentAutoScrollElement(rootEl, true); + } + } + + var layersOut = 0; + var currentParent = scrollEl; + + do { + var el = currentParent, + rect = getRect(el), + top = rect.top, + bottom = rect.bottom, + left = rect.left, + right = rect.right, + width = rect.width, + height = rect.height, + canScrollX = void 0, + canScrollY = void 0, + scrollWidth = el.scrollWidth, + scrollHeight = el.scrollHeight, + elCSS = css(el), + scrollPosX = el.scrollLeft, + scrollPosY = el.scrollTop; + + if (el === winScroller) { + canScrollX = width < scrollWidth && (elCSS.overflowX === 'auto' || elCSS.overflowX === 'scroll' || elCSS.overflowX === 'visible'); + canScrollY = height < scrollHeight && (elCSS.overflowY === 'auto' || elCSS.overflowY === 'scroll' || elCSS.overflowY === 'visible'); + } else { + canScrollX = width < scrollWidth && (elCSS.overflowX === 'auto' || elCSS.overflowX === 'scroll'); + canScrollY = height < scrollHeight && (elCSS.overflowY === 'auto' || elCSS.overflowY === 'scroll'); + } - return target; -} + var vx = canScrollX && (Math.abs(right - x) <= sens && scrollPosX + width < scrollWidth) - (Math.abs(left - x) <= sens && !!scrollPosX); + var vy = canScrollY && (Math.abs(bottom - y) <= sens && scrollPosY + height < scrollHeight) - (Math.abs(top - y) <= sens && !!scrollPosY); -function _assign(target) { + if (!autoScrolls[layersOut]) { + for (var i = 0; i <= layersOut; i++) { + if (!autoScrolls[i]) { + autoScrolls[i] = {}; + } + } + } - var args = slice.call(arguments, 1); + if (autoScrolls[layersOut].vx != vx || autoScrolls[layersOut].vy != vy || autoScrolls[layersOut].el !== el) { + autoScrolls[layersOut].el = el; + autoScrolls[layersOut].vx = vx; + autoScrolls[layersOut].vy = vy; + clearInterval(autoScrolls[layersOut].pid); - args.forEach(function (source) { - _merge(target, source); - }); + if (vx != 0 || vy != 0) { + scrollThisInstance = true; + /* jshint loopfunc:true */ - return target; -} + autoScrolls[layersOut].pid = setInterval(function () { + // emulate drag over during autoscroll (fallback), emulating native DnD behaviour + if (isFallback && this.layer === 0) { + Sortable.active._onTouchMove(touchEvt$1); // To move ghost if it is positioned absolutely -function _merge(target, source, deep) { - for (var key in source) { - if (deep && (isPlainObject(source[key]) || isArray(source[key]))) { - if (isPlainObject(source[key]) && !isPlainObject(target[key])) { - target[key] = {}; } - if (isArray(source[key]) && !isArray(target[key])) { - target[key] = []; + + var scrollOffsetY = autoScrolls[this.layer].vy ? autoScrolls[this.layer].vy * speed : 0; + var scrollOffsetX = autoScrolls[this.layer].vx ? autoScrolls[this.layer].vx * speed : 0; + + if (typeof scrollCustomFn === 'function') { + if (scrollCustomFn.call(Sortable.dragged.parentNode[expando], scrollOffsetX, scrollOffsetY, evt, touchEvt$1, autoScrolls[this.layer].el) !== 'continue') { + return; + } } - _merge(target[key], source[key], deep); - } else if (source[key] !== undefined) { - target[key] = source[key]; + + scrollBy(autoScrolls[this.layer].el, scrollOffsetX, scrollOffsetY); + }.bind({ + layer: layersOut + }), 24); } + } + + layersOut++; + } while (options.bubbleScroll && currentParent !== winScroller && (currentParent = getParentAutoScrollElement(currentParent, false))); + + scrolling = scrollThisInstance; // in case another function catches scrolling as false in between when it is not + }, 30); + + var drop = function drop(_ref) { + var originalEvent = _ref.originalEvent, + putSortable = _ref.putSortable, + dragEl = _ref.dragEl, + activeSortable = _ref.activeSortable, + dispatchSortableEvent = _ref.dispatchSortableEvent, + hideGhostForTarget = _ref.hideGhostForTarget, + unhideGhostForTarget = _ref.unhideGhostForTarget; + if (!originalEvent) return; + var toSortable = putSortable || activeSortable; + hideGhostForTarget(); + var touch = originalEvent.changedTouches && originalEvent.changedTouches.length ? originalEvent.changedTouches[0] : originalEvent; + var target = document.elementFromPoint(touch.clientX, touch.clientY); + unhideGhostForTarget(); + + if (toSortable && !toSortable.el.contains(target)) { + dispatchSortableEvent('spill'); + this.onSpill({ + dragEl: dragEl, + putSortable: putSortable + }); } -} + }; -/** - * Root Prefix Transform. - */ + function Revert() {} -var root = function (options$$1, next) { + Revert.prototype = { + startIndex: null, + dragStart: function dragStart(_ref2) { + var oldDraggableIndex = _ref2.oldDraggableIndex; + this.startIndex = oldDraggableIndex; + }, + onSpill: function onSpill(_ref3) { + var dragEl = _ref3.dragEl, + putSortable = _ref3.putSortable; + this.sortable.captureAnimationState(); - var url = next(options$$1); + if (putSortable) { + putSortable.captureAnimationState(); + } - if (isString(options$$1.root) && !/^(https?:)?\//.test(url)) { - url = trimEnd(options$$1.root, '/') + '/' + url; - } + var nextSibling = getChild(this.sortable.el, this.startIndex, this.options); - return url; -}; + if (nextSibling) { + this.sortable.el.insertBefore(dragEl, nextSibling); + } else { + this.sortable.el.appendChild(dragEl); + } -/** - * Query Parameter Transform. - */ + this.sortable.animateAll(); + + if (putSortable) { + putSortable.animateAll(); + } + }, + drop: drop + }; -var query = function (options$$1, next) { + _extends(Revert, { + pluginName: 'revertOnSpill' + }); - var urlParams = Object.keys(Url.options.params), query = {}, url = next(options$$1); + function Remove() {} - each(options$$1.params, function (value, key) { - if (urlParams.indexOf(key) === -1) { - query[key] = value; - } - }); + Remove.prototype = { + onSpill: function onSpill(_ref4) { + var dragEl = _ref4.dragEl, + putSortable = _ref4.putSortable; + var parentSortable = putSortable || this.sortable; + parentSortable.captureAnimationState(); + dragEl.parentNode && dragEl.parentNode.removeChild(dragEl); + parentSortable.animateAll(); + }, + drop: drop + }; + + _extends(Remove, { + pluginName: 'removeOnSpill' + }); - query = Url.params(query); + var lastSwapEl; - if (query) { - url += (url.indexOf('?') == -1 ? '?' : '&') + query; + function SwapPlugin() { + function Swap() { + this.defaults = { + swapClass: 'sortable-swap-highlight' + }; } - return url; -}; + Swap.prototype = { + dragStart: function dragStart(_ref) { + var dragEl = _ref.dragEl; + lastSwapEl = dragEl; + }, + dragOverValid: function dragOverValid(_ref2) { + var completed = _ref2.completed, + target = _ref2.target, + onMove = _ref2.onMove, + activeSortable = _ref2.activeSortable, + changed = _ref2.changed, + cancel = _ref2.cancel; + if (!activeSortable.options.swap) return; + var el = this.sortable.el, + options = this.options; + + if (target && target !== el) { + var prevSwapEl = lastSwapEl; + + if (onMove(target) !== false) { + toggleClass(target, options.swapClass, true); + lastSwapEl = target; + } else { + lastSwapEl = null; + } -/** - * URL Template v2.0.6 (https://github.com/bramstein/url-template) - */ + if (prevSwapEl && prevSwapEl !== lastSwapEl) { + toggleClass(prevSwapEl, options.swapClass, false); + } + } -function expand(url, params, variables) { + changed(); + completed(true); + cancel(); + }, + drop: function drop(_ref3) { + var activeSortable = _ref3.activeSortable, + putSortable = _ref3.putSortable, + dragEl = _ref3.dragEl; + var toSortable = putSortable || this.sortable; + var options = this.options; + lastSwapEl && toggleClass(lastSwapEl, options.swapClass, false); + + if (lastSwapEl && (options.swap || putSortable && putSortable.options.swap)) { + if (dragEl !== lastSwapEl) { + toSortable.captureAnimationState(); + if (toSortable !== activeSortable) activeSortable.captureAnimationState(); + swapNodes(dragEl, lastSwapEl); + toSortable.animateAll(); + if (toSortable !== activeSortable) activeSortable.animateAll(); + } + } + }, + nulling: function nulling() { + lastSwapEl = null; + } + }; + return _extends(Swap, { + pluginName: 'swap', + eventProperties: function eventProperties() { + return { + swapItem: lastSwapEl + }; + } + }); + } - var tmpl = parse(url), expanded = tmpl.expand(params); + function swapNodes(n1, n2) { + var p1 = n1.parentNode, + p2 = n2.parentNode, + i1, + i2; + if (!p1 || !p2 || p1.isEqualNode(n2) || p2.isEqualNode(n1)) return; + i1 = index(n1); + i2 = index(n2); + + if (p1.isEqualNode(p2) && i1 < i2) { + i2++; + } + + p1.insertBefore(n2, p1.children[i1]); + p2.insertBefore(n1, p2.children[i2]); + } + + var multiDragElements = [], + multiDragClones = [], + lastMultiDragSelect, + // for selection with modifier key down (SHIFT) + multiDragSortable, + initialFolding = false, + // Initial multi-drag fold when drag started + folding = false, + // Folding any other time + dragStarted = false, + dragEl$1, + clonesFromRect, + clonesHidden; + + function MultiDragPlugin() { + function MultiDrag(sortable) { + // Bind all private methods + for (var fn in this) { + if (fn.charAt(0) === '_' && typeof this[fn] === 'function') { + this[fn] = this[fn].bind(this); + } + } - if (variables) { - variables.push.apply(variables, tmpl.vars); - } + if (sortable.options.supportPointer) { + on(document, 'pointerup', this._deselectMultiDrag); + } else { + on(document, 'mouseup', this._deselectMultiDrag); + on(document, 'touchend', this._deselectMultiDrag); + } - return expanded; -} + on(document, 'keydown', this._checkKeyDown); + on(document, 'keyup', this._checkKeyUp); + this.defaults = { + selectedClass: 'sortable-selected', + multiDragKey: null, + setData: function setData(dataTransfer, dragEl) { + var data = ''; -function parse(template) { + if (multiDragElements.length && multiDragSortable === sortable) { + multiDragElements.forEach(function (multiDragElement, i) { + data += (!i ? '' : ', ') + multiDragElement.textContent; + }); + } else { + data = dragEl.textContent; + } - var operators = ['+', '#', '.', '/', ';', '?', '&'], variables = []; + dataTransfer.setData('Text', data); + } + }; + } - return { - vars: variables, - expand: function expand(context) { - return template.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g, function (_, expression, literal) { - if (expression) { + MultiDrag.prototype = { + multiDragKeyDown: false, + isMultiDrag: false, + delayStartGlobal: function delayStartGlobal(_ref) { + var dragged = _ref.dragEl; + dragEl$1 = dragged; + }, + delayEnded: function delayEnded() { + this.isMultiDrag = ~multiDragElements.indexOf(dragEl$1); + }, + setupClone: function setupClone(_ref2) { + var sortable = _ref2.sortable, + cancel = _ref2.cancel; + if (!this.isMultiDrag) return; + + for (var i = 0; i < multiDragElements.length; i++) { + multiDragClones.push(clone(multiDragElements[i])); + multiDragClones[i].sortableIndex = multiDragElements[i].sortableIndex; + multiDragClones[i].draggable = false; + multiDragClones[i].style['will-change'] = ''; + toggleClass(multiDragClones[i], this.options.selectedClass, false); + multiDragElements[i] === dragEl$1 && toggleClass(multiDragClones[i], this.options.chosenClass, false); + } - var operator = null, values = []; + sortable._hideClone(); - if (operators.indexOf(expression.charAt(0)) !== -1) { - operator = expression.charAt(0); - expression = expression.substr(1); - } + cancel(); + }, + clone: function clone(_ref3) { + var sortable = _ref3.sortable, + rootEl = _ref3.rootEl, + dispatchSortableEvent = _ref3.dispatchSortableEvent, + cancel = _ref3.cancel; + if (!this.isMultiDrag) return; + + if (!this.options.removeCloneOnHide) { + if (multiDragElements.length && multiDragSortable === sortable) { + insertMultiDragClones(true, rootEl); + dispatchSortableEvent('clone'); + cancel(); + } + } + }, + showClone: function showClone(_ref4) { + var cloneNowShown = _ref4.cloneNowShown, + rootEl = _ref4.rootEl, + cancel = _ref4.cancel; + if (!this.isMultiDrag) return; + insertMultiDragClones(false, rootEl); + multiDragClones.forEach(function (clone) { + css(clone, 'display', ''); + }); + cloneNowShown(); + clonesHidden = false; + cancel(); + }, + hideClone: function hideClone(_ref5) { + var _this = this; + + var sortable = _ref5.sortable, + cloneNowHidden = _ref5.cloneNowHidden, + cancel = _ref5.cancel; + if (!this.isMultiDrag) return; + multiDragClones.forEach(function (clone) { + css(clone, 'display', 'none'); + + if (_this.options.removeCloneOnHide && clone.parentNode) { + clone.parentNode.removeChild(clone); + } + }); + cloneNowHidden(); + clonesHidden = true; + cancel(); + }, + dragStartGlobal: function dragStartGlobal(_ref6) { + var sortable = _ref6.sortable; - expression.split(/,/g).forEach(function (variable) { - var tmp = /([^:\*]*)(?::(\d+)|(\*))?/.exec(variable); - values.push.apply(values, getValues(context, operator, tmp[1], tmp[2] || tmp[3])); - variables.push(tmp[1]); - }); + if (!this.isMultiDrag && multiDragSortable) { + multiDragSortable.multiDrag._deselectMultiDrag(); + } - if (operator && operator !== '+') { + multiDragElements.forEach(function (multiDragElement) { + multiDragElement.sortableIndex = index(multiDragElement); + }); // Sort multi-drag elements - var separator = ','; + multiDragElements = multiDragElements.sort(function (a, b) { + return a.sortableIndex - b.sortableIndex; + }); + dragStarted = true; + }, + dragStarted: function dragStarted(_ref7) { + var _this2 = this; + + var sortable = _ref7.sortable; + if (!this.isMultiDrag) return; + + if (this.options.sort) { + // Capture rects, + // hide multi drag elements (by positioning them absolute), + // set multi drag elements rects to dragRect, + // show multi drag elements, + // animate to rects, + // unset rects & remove from DOM + sortable.captureAnimationState(); + + if (this.options.animation) { + multiDragElements.forEach(function (multiDragElement) { + if (multiDragElement === dragEl$1) return; + css(multiDragElement, 'position', 'absolute'); + }); + var dragRect = getRect(dragEl$1, false, true, true); + multiDragElements.forEach(function (multiDragElement) { + if (multiDragElement === dragEl$1) return; + setRect(multiDragElement, dragRect); + }); + folding = true; + initialFolding = true; + } + } - if (operator === '?') { - separator = '&'; - } else if (operator !== '#') { - separator = operator; - } + sortable.animateAll(function () { + folding = false; + initialFolding = false; - return (values.length !== 0 ? operator : '') + values.join(separator); - } else { - return values.join(','); - } + if (_this2.options.animation) { + multiDragElements.forEach(function (multiDragElement) { + unsetRect(multiDragElement); + }); + } // Remove all auxiliary multidrag items from el, if sorting enabled - } else { - return encodeReserved(literal); - } + + if (_this2.options.sort) { + removeMultiDragElements(); + } + }); + }, + dragOver: function dragOver(_ref8) { + var target = _ref8.target, + completed = _ref8.completed, + cancel = _ref8.cancel; + + if (folding && ~multiDragElements.indexOf(target)) { + completed(false); + cancel(); + } + }, + revert: function revert(_ref9) { + var fromSortable = _ref9.fromSortable, + rootEl = _ref9.rootEl, + sortable = _ref9.sortable, + dragRect = _ref9.dragRect; + + if (multiDragElements.length > 1) { + // Setup unfold animation + multiDragElements.forEach(function (multiDragElement) { + sortable.addAnimationState({ + target: multiDragElement, + rect: folding ? getRect(multiDragElement) : dragRect }); + unsetRect(multiDragElement); + multiDragElement.fromRect = dragRect; + fromSortable.removeAnimationState(multiDragElement); + }); + folding = false; + insertMultiDragElements(!this.options.removeCloneOnHide, rootEl); } - }; -} + }, + dragOverCompleted: function dragOverCompleted(_ref10) { + var sortable = _ref10.sortable, + isOwner = _ref10.isOwner, + insertion = _ref10.insertion, + activeSortable = _ref10.activeSortable, + parentEl = _ref10.parentEl, + putSortable = _ref10.putSortable; + var options = this.options; + + if (insertion) { + // Clones must be hidden before folding animation to capture dragRectAbsolute properly + if (isOwner) { + activeSortable._hideClone(); + } -function getValues(context, operator, key, modifier) { + initialFolding = false; // If leaving sort:false root, or already folding - Fold to new location - var value = context[key], result = []; + if (options.animation && multiDragElements.length > 1 && (folding || !isOwner && !activeSortable.options.sort && !putSortable)) { + // Fold: Set all multi drag elements's rects to dragEl's rect when multi-drag elements are invisible + var dragRectAbsolute = getRect(dragEl$1, false, true, true); + multiDragElements.forEach(function (multiDragElement) { + if (multiDragElement === dragEl$1) return; + setRect(multiDragElement, dragRectAbsolute); // Move element(s) to end of parentEl so that it does not interfere with multi-drag clones insertion if they are inserted + // while folding, and so that we can capture them again because old sortable will no longer be fromSortable + + parentEl.appendChild(multiDragElement); + }); + folding = true; + } // Clones must be shown (and check to remove multi drags) after folding when interfering multiDragElements are moved out - if (isDefined(value) && value !== '') { - if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') { - value = value.toString(); - if (modifier && modifier !== '*') { - value = value.substring(0, parseInt(modifier, 10)); + if (!isOwner) { + // Only remove if not folding (folding will remove them anyways) + if (!folding) { + removeMultiDragElements(); } - result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : null)); - } else { - if (modifier === '*') { - if (Array.isArray(value)) { - value.filter(isDefined).forEach(function (value) { - result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : null)); - }); - } else { - Object.keys(value).forEach(function (k) { - if (isDefined(value[k])) { - result.push(encodeValue(operator, value[k], k)); - } - }); - } - } else { - var tmp = []; + if (multiDragElements.length > 1) { + var clonesHiddenBefore = clonesHidden; - if (Array.isArray(value)) { - value.filter(isDefined).forEach(function (value) { - tmp.push(encodeValue(operator, value)); - }); - } else { - Object.keys(value).forEach(function (k) { - if (isDefined(value[k])) { - tmp.push(encodeURIComponent(k)); - tmp.push(encodeValue(operator, value[k].toString())); - } - }); - } + activeSortable._showClone(sortable); // Unfold animation for clones if showing from hidden - if (isKeyOperator(operator)) { - result.push(encodeURIComponent(key) + '=' + tmp.join(',')); - } else if (tmp.length !== 0) { - result.push(tmp.join(',')); - } + + if (activeSortable.options.animation && !clonesHidden && clonesHiddenBefore) { + multiDragClones.forEach(function (clone) { + activeSortable.addAnimationState({ + target: clone, + rect: clonesFromRect + }); + clone.fromRect = clonesFromRect; + clone.thisAnimationDuration = null; + }); + } + } else { + activeSortable._showClone(sortable); } + } } - } else { - if (operator === ';') { - result.push(encodeURIComponent(key)); - } else if (value === '' && (operator === '&' || operator === '?')) { - result.push(encodeURIComponent(key) + '='); - } else if (value === '') { - result.push(''); - } - } - - return result; -} + }, + dragOverAnimationCapture: function dragOverAnimationCapture(_ref11) { + var dragRect = _ref11.dragRect, + isOwner = _ref11.isOwner, + activeSortable = _ref11.activeSortable; + multiDragElements.forEach(function (multiDragElement) { + multiDragElement.thisAnimationDuration = null; + }); -function isDefined(value) { - return value !== undefined && value !== null; -} + if (activeSortable.options.animation && !isOwner && activeSortable.multiDrag.isMultiDrag) { + clonesFromRect = _extends({}, dragRect); + var dragMatrix = matrix(dragEl$1, true); + clonesFromRect.top -= dragMatrix.f; + clonesFromRect.left -= dragMatrix.e; + } + }, + dragOverAnimationComplete: function dragOverAnimationComplete() { + if (folding) { + folding = false; + removeMultiDragElements(); + } + }, + drop: function drop(_ref12) { + var evt = _ref12.originalEvent, + rootEl = _ref12.rootEl, + parentEl = _ref12.parentEl, + sortable = _ref12.sortable, + dispatchSortableEvent = _ref12.dispatchSortableEvent, + oldIndex = _ref12.oldIndex, + putSortable = _ref12.putSortable; + var toSortable = putSortable || this.sortable; + if (!evt) return; + var options = this.options, + children = parentEl.children; // Multi-drag selection + + if (!dragStarted) { + if (options.multiDragKey && !this.multiDragKeyDown) { + this._deselectMultiDrag(); + } -function isKeyOperator(operator) { - return operator === ';' || operator === '&' || operator === '?'; -} + toggleClass(dragEl$1, options.selectedClass, !~multiDragElements.indexOf(dragEl$1)); + + if (!~multiDragElements.indexOf(dragEl$1)) { + multiDragElements.push(dragEl$1); + dispatchEvent({ + sortable: sortable, + rootEl: rootEl, + name: 'select', + targetEl: dragEl$1, + originalEvt: evt + }); // Modifier activated, select from last to dragEl + + if (evt.shiftKey && lastMultiDragSelect && sortable.el.contains(lastMultiDragSelect)) { + var lastIndex = index(lastMultiDragSelect), + currentIndex = index(dragEl$1); + + if (~lastIndex && ~currentIndex && lastIndex !== currentIndex) { + // Must include lastMultiDragSelect (select it), in case modified selection from no selection + // (but previous selection existed) + var n, i; + + if (currentIndex > lastIndex) { + i = lastIndex; + n = currentIndex; + } else { + i = currentIndex; + n = lastIndex + 1; + } -function encodeValue(operator, value, key) { + for (; i < n; i++) { + if (~multiDragElements.indexOf(children[i])) continue; + toggleClass(children[i], options.selectedClass, true); + multiDragElements.push(children[i]); + dispatchEvent({ + sortable: sortable, + rootEl: rootEl, + name: 'select', + targetEl: children[i], + originalEvt: evt + }); + } + } + } else { + lastMultiDragSelect = dragEl$1; + } - value = (operator === '+' || operator === '#') ? encodeReserved(value) : encodeURIComponent(value); + multiDragSortable = toSortable; + } else { + multiDragElements.splice(multiDragElements.indexOf(dragEl$1), 1); + lastMultiDragSelect = null; + dispatchEvent({ + sortable: sortable, + rootEl: rootEl, + name: 'deselect', + targetEl: dragEl$1, + originalEvt: evt + }); + } + } // Multi-drag drop + + + if (dragStarted && this.isMultiDrag) { + // Do not "unfold" after around dragEl if reverted + if ((parentEl[expando].options.sort || parentEl !== rootEl) && multiDragElements.length > 1) { + var dragRect = getRect(dragEl$1), + multiDragIndex = index(dragEl$1, ':not(.' + this.options.selectedClass + ')'); + if (!initialFolding && options.animation) dragEl$1.thisAnimationDuration = null; + toSortable.captureAnimationState(); + + if (!initialFolding) { + if (options.animation) { + dragEl$1.fromRect = dragRect; + multiDragElements.forEach(function (multiDragElement) { + multiDragElement.thisAnimationDuration = null; + + if (multiDragElement !== dragEl$1) { + var rect = folding ? getRect(multiDragElement) : dragRect; + multiDragElement.fromRect = rect; // Prepare unfold animation + + toSortable.addAnimationState({ + target: multiDragElement, + rect: rect + }); + } + }); + } // Multi drag elements are not necessarily removed from the DOM on drop, so to reinsert + // properly they must all be removed - if (key) { - return encodeURIComponent(key) + '=' + value; - } else { - return value; - } -} -function encodeReserved(str) { - return str.split(/(%[0-9A-Fa-f]{2})/g).map(function (part) { - if (!/%[0-9A-Fa-f]/.test(part)) { - part = encodeURI(part); - } - return part; - }).join(''); -} + removeMultiDragElements(); + multiDragElements.forEach(function (multiDragElement) { + if (children[multiDragIndex]) { + parentEl.insertBefore(multiDragElement, children[multiDragIndex]); + } else { + parentEl.appendChild(multiDragElement); + } -/** - * URL Template (RFC 6570) Transform. - */ + multiDragIndex++; + }); // If initial folding is done, the elements may have changed position because they are now + // unfolding around dragEl, even though dragEl may not have his index changed, so update event + // must be fired here as Sortable will not. -var template = function (options) { + if (oldIndex === index(dragEl$1)) { + var update = false; + multiDragElements.forEach(function (multiDragElement) { + if (multiDragElement.sortableIndex !== index(multiDragElement)) { + update = true; + return; + } + }); - var variables = [], url = expand(options.url, options.params, variables); + if (update) { + dispatchSortableEvent('update'); + } + } + } // Must be done after capturing individual rects (scroll bar) - variables.forEach(function (key) { - delete options.params[key]; - }); - return url; -}; + multiDragElements.forEach(function (multiDragElement) { + unsetRect(multiDragElement); + }); + toSortable.animateAll(); + } -/** - * Service for URL templating. - */ + multiDragSortable = toSortable; + } // Remove clones if necessary -function Url(url, params) { - var self = this || {}, options$$1 = url, transform; + if (rootEl === parentEl || putSortable && putSortable.lastPutMode !== 'clone') { + multiDragClones.forEach(function (clone) { + clone.parentNode && clone.parentNode.removeChild(clone); + }); + } + }, + nullingGlobal: function nullingGlobal() { + this.isMultiDrag = dragStarted = false; + multiDragClones.length = 0; + }, + destroyGlobal: function destroyGlobal() { + this._deselectMultiDrag(); + + off(document, 'pointerup', this._deselectMultiDrag); + off(document, 'mouseup', this._deselectMultiDrag); + off(document, 'touchend', this._deselectMultiDrag); + off(document, 'keydown', this._checkKeyDown); + off(document, 'keyup', this._checkKeyUp); + }, + _deselectMultiDrag: function _deselectMultiDrag(evt) { + if (typeof dragStarted !== "undefined" && dragStarted) return; // Only deselect if selection is in this sortable - if (isString(url)) { - options$$1 = {url: url, params: params}; - } + if (multiDragSortable !== this.sortable) return; // Only deselect if target is not item in this sortable - options$$1 = merge({}, Url.options, self.$options, options$$1); + if (evt && closest(evt.target, this.options.draggable, this.sortable.el, false)) return; // Only deselect if left click - Url.transforms.forEach(function (handler) { + if (evt && evt.button !== 0) return; - if (isString(handler)) { - handler = Url.transform[handler]; + while (multiDragElements.length) { + var el = multiDragElements[0]; + toggleClass(el, this.options.selectedClass, false); + multiDragElements.shift(); + dispatchEvent({ + sortable: this.sortable, + rootEl: this.sortable.el, + name: 'deselect', + targetEl: el, + originalEvt: evt + }); } - - if (isFunction(handler)) { - transform = factory(handler, transform, self.$vm); + }, + _checkKeyDown: function _checkKeyDown(evt) { + if (evt.key === this.options.multiDragKey) { + this.multiDragKeyDown = true; } + }, + _checkKeyUp: function _checkKeyUp(evt) { + if (evt.key === this.options.multiDragKey) { + this.multiDragKeyDown = false; + } + } + }; + return _extends(MultiDrag, { + // Static methods & properties + pluginName: 'multiDrag', + utils: { + /** + * Selects the provided multi-drag item + * @param {HTMLElement} el The element to be selected + */ + select: function select(el) { + var sortable = el.parentNode[expando]; + if (!sortable || !sortable.options.multiDrag || ~multiDragElements.indexOf(el)) return; + + if (multiDragSortable && multiDragSortable !== sortable) { + multiDragSortable.multiDrag._deselectMultiDrag(); + + multiDragSortable = sortable; + } - }); + toggleClass(el, sortable.options.selectedClass, true); + multiDragElements.push(el); + }, - return transform(options$$1); -} + /** + * Deselects the provided multi-drag item + * @param {HTMLElement} el The element to be deselected + */ + deselect: function deselect(el) { + var sortable = el.parentNode[expando], + index = multiDragElements.indexOf(el); + if (!sortable || !sortable.options.multiDrag || !~index) return; + toggleClass(el, sortable.options.selectedClass, false); + multiDragElements.splice(index, 1); + } + }, + eventProperties: function eventProperties() { + var _this3 = this; -/** - * Url options. - */ + var oldIndicies = [], + newIndicies = []; + multiDragElements.forEach(function (multiDragElement) { + oldIndicies.push({ + multiDragElement: multiDragElement, + index: multiDragElement.sortableIndex + }); // multiDragElements will already be sorted if folding -Url.options = { - url: '', - root: null, - params: {} -}; + var newIndex; -/** - * Url transforms. - */ - -Url.transform = {template: template, query: query, root: root}; -Url.transforms = ['template', 'query', 'root']; + if (folding && multiDragElement !== dragEl$1) { + newIndex = -1; + } else if (folding) { + newIndex = index(multiDragElement, ':not(.' + _this3.options.selectedClass + ')'); + } else { + newIndex = index(multiDragElement); + } -/** - * Encodes a Url parameter string. - * - * @param {Object} obj - */ + newIndicies.push({ + multiDragElement: multiDragElement, + index: newIndex + }); + }); + return { + items: _toConsumableArray(multiDragElements), + clones: [].concat(multiDragClones), + oldIndicies: oldIndicies, + newIndicies: newIndicies + }; + }, + optionListeners: { + multiDragKey: function multiDragKey(key) { + key = key.toLowerCase(); + + if (key === 'ctrl') { + key = 'Control'; + } else if (key.length > 1) { + key = key.charAt(0).toUpperCase() + key.substr(1); + } -Url.params = function (obj) { + return key; + } + } + }); + } - var params = [], escape = encodeURIComponent; + function insertMultiDragElements(clonesInserted, rootEl) { + multiDragElements.forEach(function (multiDragElement, i) { + var target = rootEl.children[multiDragElement.sortableIndex + (clonesInserted ? Number(i) : 0)]; - params.add = function (key, value) { + if (target) { + rootEl.insertBefore(multiDragElement, target); + } else { + rootEl.appendChild(multiDragElement); + } + }); + } + /** + * Insert multi-drag clones + * @param {[Boolean]} elementsInserted Whether the multi-drag elements are inserted + * @param {HTMLElement} rootEl + */ - if (isFunction(value)) { - value = value(); - } - if (value === null) { - value = ''; - } + function insertMultiDragClones(elementsInserted, rootEl) { + multiDragClones.forEach(function (clone, i) { + var target = rootEl.children[clone.sortableIndex + (elementsInserted ? Number(i) : 0)]; - this.push(escape(key) + '=' + escape(value)); - }; + if (target) { + rootEl.insertBefore(clone, target); + } else { + rootEl.appendChild(clone); + } + }); + } - serialize(params, obj); + function removeMultiDragElements() { + multiDragElements.forEach(function (multiDragElement) { + if (multiDragElement === dragEl$1) return; + multiDragElement.parentNode && multiDragElement.parentNode.removeChild(multiDragElement); + }); + } - return params.join('&').replace(/%20/g, '+'); -}; + Sortable.mount(new AutoScrollPlugin()); + Sortable.mount(Remove, Revert); -/** - * Parse a URL and return its components. - * - * @param {String} url - */ + Sortable.mount(new SwapPlugin()); + Sortable.mount(new MultiDragPlugin()); -Url.parse = function (url) { + return Sortable; - var el = document.createElement('a'); +})); - if (document.documentMode) { - el.href = url; - url = el.href; - } +},{}],48:[function(require,module,exports){ +(function (setImmediate,clearImmediate){(function (){ +var nextTick = require('process/browser.js').nextTick; +var apply = Function.prototype.apply; +var slice = Array.prototype.slice; +var immediateIds = {}; +var nextImmediateId = 0; - el.href = url; +// DOM APIs, for completeness - return { - href: el.href, - protocol: el.protocol ? el.protocol.replace(/:$/, '') : '', - port: el.port, - host: el.host, - hostname: el.hostname, - pathname: el.pathname.charAt(0) === '/' ? el.pathname : '/' + el.pathname, - search: el.search ? el.search.replace(/^\?/, '') : '', - hash: el.hash ? el.hash.replace(/^#/, '') : '' - }; +exports.setTimeout = function() { + return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout); }; +exports.setInterval = function() { + return new Timeout(apply.call(setInterval, window, arguments), clearInterval); +}; +exports.clearTimeout = +exports.clearInterval = function(timeout) { timeout.close(); }; -function factory(handler, next, vm) { - return function (options$$1) { - return handler.call(vm, options$$1, next); - }; +function Timeout(id, clearFn) { + this._id = id; + this._clearFn = clearFn; } +Timeout.prototype.unref = Timeout.prototype.ref = function() {}; +Timeout.prototype.close = function() { + this._clearFn.call(window, this._id); +}; -function serialize(params, obj, scope) { - - var array = isArray(obj), plain = isPlainObject(obj), hash; - - each(obj, function (value, key) { - - hash = isObject(value) || isArray(value); - - if (scope) { - key = scope + '[' + (plain || hash ? key : '') + ']'; - } +// Does not start the time, just sets up the members needed. +exports.enroll = function(item, msecs) { + clearTimeout(item._idleTimeoutId); + item._idleTimeout = msecs; +}; - if (!scope && array) { - params.add(value.name, value.value); - } else if (hash) { - serialize(params, value, key); - } else { - params.add(key, value); - } - }); -} +exports.unenroll = function(item) { + clearTimeout(item._idleTimeoutId); + item._idleTimeout = -1; +}; -/** - * XDomain client (Internet Explorer). - */ +exports._unrefActive = exports.active = function(item) { + clearTimeout(item._idleTimeoutId); -var xdrClient = function (request) { - return new PromiseObj(function (resolve) { + var msecs = item._idleTimeout; + if (msecs >= 0) { + item._idleTimeoutId = setTimeout(function onTimeout() { + if (item._onTimeout) + item._onTimeout(); + }, msecs); + } +}; - var xdr = new XDomainRequest(), handler = function (ref) { - var type = ref.type; +// That's not how node.js implements it but the exposed api is the same. +exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) { + var id = nextImmediateId++; + var args = arguments.length < 2 ? false : slice.call(arguments, 1); + immediateIds[id] = true; - var status = 0; + nextTick(function onNextTick() { + if (immediateIds[id]) { + // fn.call() is faster so we optimize for the common use-case + // @see http://jsperf.com/call-apply-segu + if (args) { + fn.apply(null, args); + } else { + fn.call(null); + } + // Prevent ids from leaking + exports.clearImmediate(id); + } + }); - if (type === 'load') { - status = 200; - } else if (type === 'error') { - status = 500; - } + return id; +}; - resolve(request.respondWith(xdr.responseText, {status: status})); - }; +exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) { + delete immediateIds[id]; +}; +}).call(this)}).call(this,require("timers").setImmediate,require("timers").clearImmediate) +},{"process/browser.js":46,"timers":48}],49:[function(require,module,exports){ +var Vue // late bind +var version +var map = Object.create(null) +if (typeof window !== 'undefined') { + window.__VUE_HOT_MAP__ = map +} +var installed = false +var isBrowserify = false +var initHookName = 'beforeCreate' - request.abort = function () { return xdr.abort(); }; +exports.install = function (vue, browserify) { + if (installed) { return } + installed = true - xdr.open(request.method, request.getUrl()); + Vue = vue.__esModule ? vue.default : vue + version = Vue.version.split('.').map(Number) + isBrowserify = browserify - if (request.timeout) { - xdr.timeout = request.timeout; - } + // compat with < 2.0.0-alpha.7 + if (Vue.config._lifecycleHooks.indexOf('init') > -1) { + initHookName = 'init' + } - xdr.onload = handler; - xdr.onabort = handler; - xdr.onerror = handler; - xdr.ontimeout = handler; - xdr.onprogress = function () {}; - xdr.send(request.getBody()); - }); -}; + exports.compatible = version[0] >= 2 + if (!exports.compatible) { + console.warn( + '[HMR] You are using a version of vue-hot-reload-api that is ' + + 'only compatible with Vue.js core ^2.0.0.' + ) + return + } +} /** - * CORS Interceptor. + * Create a record for a hot module, which keeps track of its constructor + * and instances + * + * @param {String} id + * @param {Object} options */ -var SUPPORTS_CORS = inBrowser && 'withCredentials' in new XMLHttpRequest(); - -var cors = function (request, next) { - - if (inBrowser) { - - var orgUrl = Url.parse(location.href); - var reqUrl = Url.parse(request.getUrl()); - - if (reqUrl.protocol !== orgUrl.protocol || reqUrl.host !== orgUrl.host) { - - request.crossOrigin = true; - request.emulateHTTP = false; - - if (!SUPPORTS_CORS) { - request.client = xdrClient; - } - } - } +exports.createRecord = function (id, options) { + if(map[id]) { return } - next(); -}; + var Ctor = null + if (typeof options === 'function') { + Ctor = options + options = Ctor.options + } + makeOptionsHot(id, options) + map[id] = { + Ctor: Ctor, + options: options, + instances: [] + } +} /** - * Form data Interceptor. + * Check if module is recorded + * + * @param {String} id */ -var form = function (request, next) { - - if (isFormData(request.body)) { - - request.headers.delete('Content-Type'); - - } else if (isObject(request.body) && request.emulateJSON) { - - request.body = Url.params(request.body); - request.headers.set('Content-Type', 'application/x-www-form-urlencoded'); - } - - next(); -}; +exports.isRecorded = function (id) { + return typeof map[id] !== 'undefined' +} /** - * JSON Interceptor. + * Make a Component options object hot. + * + * @param {String} id + * @param {Object} options */ -var json = function (request, next) { - - var type = request.headers.get('Content-Type') || ''; - - if (isObject(request.body) && type.indexOf('application/json') === 0) { - request.body = JSON.stringify(request.body); +function makeOptionsHot(id, options) { + if (options.functional) { + var render = options.render + options.render = function (h, ctx) { + var instances = map[id].instances + if (ctx && instances.indexOf(ctx.parent) < 0) { + instances.push(ctx.parent) + } + return render(h, ctx) } - - next(function (response) { - - return response.bodyText ? when(response.text(), function (text) { - - type = response.headers.get('Content-Type') || ''; - - if (type.indexOf('application/json') === 0 || isJson(text)) { - - try { - response.body = JSON.parse(text); - } catch (e) { - response.body = null; - } - - } else { - response.body = text; - } - - return response; - - }) : response; - - }); -}; - -function isJson(str) { - - var start = str.match(/^\[|^\{(?!\{)/), end = {'[': /]$/, '{': /}$/}; - - return start && end[start[0]].test(str); + } else { + injectHook(options, initHookName, function() { + var record = map[id] + if (!record.Ctor) { + record.Ctor = this.constructor + } + record.instances.push(this) + }) + injectHook(options, 'beforeDestroy', function() { + var instances = map[id].instances + instances.splice(instances.indexOf(this), 1) + }) + } } /** - * JSONP client (Browser). + * Inject a hook to a hot reloadable component so that + * we can keep track of it. + * + * @param {Object} options + * @param {String} name + * @param {Function} hook */ -var jsonpClient = function (request) { - return new PromiseObj(function (resolve) { +function injectHook(options, name, hook) { + var existing = options[name] + options[name] = existing + ? Array.isArray(existing) ? existing.concat(hook) : [existing, hook] + : [hook] +} - var name = request.jsonp || 'callback', callback = request.jsonpCallback || '_jsonp' + Math.random().toString(36).substr(2), body = null, handler, script; - - handler = function (ref) { - var type = ref.type; +function tryWrap(fn) { + return function (id, arg) { + try { + fn(id, arg) + } catch (e) { + console.error(e) + console.warn( + 'Something went wrong during Vue component hot-reload. Full reload required.' + ) + } + } +} +function updateOptions (oldOptions, newOptions) { + for (var key in oldOptions) { + if (!(key in newOptions)) { + delete oldOptions[key] + } + } + for (var key$1 in newOptions) { + oldOptions[key$1] = newOptions[key$1] + } +} - var status = 0; +exports.rerender = tryWrap(function (id, options) { + var record = map[id] + if (!options) { + record.instances.slice().forEach(function (instance) { + instance.$forceUpdate() + }) + return + } + if (typeof options === 'function') { + options = options.options + } + if (record.Ctor) { + record.Ctor.options.render = options.render + record.Ctor.options.staticRenderFns = options.staticRenderFns + record.instances.slice().forEach(function (instance) { + instance.$options.render = options.render + instance.$options.staticRenderFns = options.staticRenderFns + // reset static trees + // pre 2.5, all static trees are cached together on the instance + if (instance._staticTrees) { + instance._staticTrees = [] + } + // 2.5.0 + if (Array.isArray(record.Ctor.options.cached)) { + record.Ctor.options.cached = [] + } + // 2.5.3 + if (Array.isArray(instance.$options.cached)) { + instance.$options.cached = [] + } - if (type === 'load' && body !== null) { - status = 200; - } else if (type === 'error') { - status = 500; - } + // post 2.5.4: v-once trees are cached on instance._staticTrees. + // Pure static trees are cached on the staticRenderFns array + // (both already reset above) - if (status && window[callback]) { - delete window[callback]; - document.body.removeChild(script); - } + // 2.6: temporarily mark rendered scoped slots as unstable so that + // child components can be forced to update + var restore = patchScopedSlots(instance) + instance.$forceUpdate() + instance.$nextTick(restore) + }) + } else { + // functional or no instance created yet + record.options.render = options.render + record.options.staticRenderFns = options.staticRenderFns - resolve(request.respondWith(body, {status: status})); - }; + // handle functional component re-render + if (record.options.functional) { + // rerender with full options + if (Object.keys(options).length > 2) { + updateOptions(record.options, options) + } else { + // template-only rerender. + // need to inject the style injection code for CSS modules + // to work properly. + var injectStyles = record.options._injectStyles + if (injectStyles) { + var render = options.render + record.options.render = function (h, ctx) { + injectStyles.call(ctx) + return render(h, ctx) + } + } + } + record.options._Ctor = null + // 2.5.3 + if (Array.isArray(record.options.cached)) { + record.options.cached = [] + } + record.instances.slice().forEach(function (instance) { + instance.$forceUpdate() + }) + } + } +}) - window[callback] = function (result) { - body = JSON.stringify(result); - }; +exports.reload = tryWrap(function (id, options) { + var record = map[id] + if (options) { + if (typeof options === 'function') { + options = options.options + } + makeOptionsHot(id, options) + if (record.Ctor) { + if (version[1] < 2) { + // preserve pre 2.2 behavior for global mixin handling + record.Ctor.extendOptions = options + } + var newCtor = record.Ctor.super.extend(options) + // prevent record.options._Ctor from being overwritten accidentally + newCtor.options._Ctor = record.options._Ctor + record.Ctor.options = newCtor.options + record.Ctor.cid = newCtor.cid + record.Ctor.prototype = newCtor.prototype + if (newCtor.release) { + // temporary global mixin strategy used in < 2.0.0-alpha.6 + newCtor.release() + } + } else { + updateOptions(record.options, options) + } + } + record.instances.slice().forEach(function (instance) { + if (instance.$vnode && instance.$vnode.context) { + instance.$vnode.context.$forceUpdate() + } else { + console.warn( + 'Root or manually mounted instance modified. Full reload required.' + ) + } + }) +}) - request.abort = function () { - handler({type: 'abort'}); - }; +// 2.6 optimizes template-compiled scoped slots and skips updates if child +// only uses scoped slots. We need to patch the scoped slots resolving helper +// to temporarily mark all scoped slots as unstable in order to force child +// updates. +function patchScopedSlots (instance) { + if (!instance._u) { return } + // https://github.com/vuejs/vue/blob/dev/src/core/instance/render-helpers/resolve-scoped-slots.js + var original = instance._u + instance._u = function (slots) { + try { + // 2.6.4 ~ 2.6.6 + return original(slots, true) + } catch (e) { + // 2.5 / >= 2.6.7 + return original(slots, null, true) + } + } + return function () { + instance._u = original + } +} - request.params[name] = callback; +},{}],50:[function(require,module,exports){ +/*! + * vue-resource v1.5.3 + * https://github.com/pagekit/vue-resource + * Released under the MIT License. + */ - if (request.timeout) { - setTimeout(request.abort, request.timeout); - } +'use strict'; - script = document.createElement('script'); - script.src = request.getUrl(); - script.type = 'text/javascript'; - script.async = true; - script.onload = handler; - script.onerror = handler; +/** + * Promises/A+ polyfill v1.1.4 (https://github.com/bramstein/promis) + */ +var RESOLVED = 0; +var REJECTED = 1; +var PENDING = 2; +function Promise$1(executor) { + this.state = PENDING; + this.value = undefined; + this.deferred = []; + var promise = this; - document.body.appendChild(script); + try { + executor(function (x) { + promise.resolve(x); + }, function (r) { + promise.reject(r); }); + } catch (e) { + promise.reject(e); + } +} + +Promise$1.reject = function (r) { + return new Promise$1(function (resolve, reject) { + reject(r); + }); }; -/** - * JSONP Interceptor. - */ +Promise$1.resolve = function (x) { + return new Promise$1(function (resolve, reject) { + resolve(x); + }); +}; -var jsonp = function (request, next) { +Promise$1.all = function all(iterable) { + return new Promise$1(function (resolve, reject) { + var count = 0, + result = []; - if (request.method == 'JSONP') { - request.client = jsonpClient; + if (iterable.length === 0) { + resolve(result); } - next(); -}; - -/** - * Before Interceptor. - */ + function resolver(i) { + return function (x) { + result[i] = x; + count += 1; -var before = function (request, next) { + if (count === iterable.length) { + resolve(result); + } + }; + } - if (isFunction(request.before)) { - request.before.call(this, request); + for (var i = 0; i < iterable.length; i += 1) { + Promise$1.resolve(iterable[i]).then(resolver(i), reject); } + }); +}; - next(); +Promise$1.race = function race(iterable) { + return new Promise$1(function (resolve, reject) { + for (var i = 0; i < iterable.length; i += 1) { + Promise$1.resolve(iterable[i]).then(resolve, reject); + } + }); }; -/** - * HTTP method override Interceptor. - */ +var p = Promise$1.prototype; -var method = function (request, next) { +p.resolve = function resolve(x) { + var promise = this; - if (request.emulateHTTP && /^(PUT|PATCH|DELETE)$/i.test(request.method)) { - request.headers.set('X-HTTP-Method-Override', request.method); - request.method = 'POST'; + if (promise.state === PENDING) { + if (x === promise) { + throw new TypeError('Promise settled with itself.'); } - next(); -}; - -/** - * Header Interceptor. - */ - -var header = function (request, next) { + var called = false; - var headers = assign({}, Http.headers.common, - !request.crossOrigin ? Http.headers.custom : {}, - Http.headers[toLower(request.method)] - ); + try { + var then = x && x['then']; - each(headers, function (value, name) { - if (!request.headers.has(name)) { - request.headers.set(name, value); - } - }); + if (x !== null && typeof x === 'object' && typeof then === 'function') { + then.call(x, function (x) { + if (!called) { + promise.resolve(x); + } - next(); -}; + called = true; + }, function (r) { + if (!called) { + promise.reject(r); + } -/** - * XMLHttp client (Browser). - */ + called = true; + }); + return; + } + } catch (e) { + if (!called) { + promise.reject(e); + } -var xhrClient = function (request) { - return new PromiseObj(function (resolve) { + return; + } - var xhr = new XMLHttpRequest(), handler = function (event) { + promise.state = RESOLVED; + promise.value = x; + promise.notify(); + } +}; - var response = request.respondWith( - 'response' in xhr ? xhr.response : xhr.responseText, { - status: xhr.status === 1223 ? 204 : xhr.status, // IE9 status bug - statusText: xhr.status === 1223 ? 'No Content' : trim(xhr.statusText) - } - ); +p.reject = function reject(reason) { + var promise = this; - each(trim(xhr.getAllResponseHeaders()).split('\n'), function (row) { - response.headers.append(row.slice(0, row.indexOf(':')), row.slice(row.indexOf(':') + 1)); - }); + if (promise.state === PENDING) { + if (reason === promise) { + throw new TypeError('Promise settled with itself.'); + } - resolve(response); - }; + promise.state = REJECTED; + promise.value = reason; + promise.notify(); + } +}; - request.abort = function () { return xhr.abort(); }; +p.notify = function notify() { + var promise = this; + nextTick(function () { + if (promise.state !== PENDING) { + while (promise.deferred.length) { + var deferred = promise.deferred.shift(), + onResolved = deferred[0], + onRejected = deferred[1], + resolve = deferred[2], + reject = deferred[3]; - if (request.progress) { - if (request.method === 'GET') { - xhr.addEventListener('progress', request.progress); - } else if (/^(POST|PUT)$/i.test(request.method)) { - xhr.upload.addEventListener('progress', request.progress); + try { + if (promise.state === RESOLVED) { + if (typeof onResolved === 'function') { + resolve(onResolved.call(undefined, promise.value)); + } else { + resolve(promise.value); } + } else if (promise.state === REJECTED) { + if (typeof onRejected === 'function') { + resolve(onRejected.call(undefined, promise.value)); + } else { + reject(promise.value); + } + } + } catch (e) { + reject(e); } + } + } + }); +}; - xhr.open(request.method, request.getUrl(), true); +p.then = function then(onResolved, onRejected) { + var promise = this; + return new Promise$1(function (resolve, reject) { + promise.deferred.push([onResolved, onRejected, resolve, reject]); + promise.notify(); + }); +}; - if (request.timeout) { - xhr.timeout = request.timeout; - } +p["catch"] = function (onRejected) { + return this.then(undefined, onRejected); +}; - if (request.responseType && 'responseType' in xhr) { - xhr.responseType = request.responseType; - } +/** + * Promise adapter. + */ - if (request.withCredentials || request.credentials) { - xhr.withCredentials = true; - } +if (typeof Promise === 'undefined') { + window.Promise = Promise$1; +} - if (!request.crossOrigin) { - request.headers.set('X-Requested-With', 'XMLHttpRequest'); - } +function PromiseObj(executor, context) { + if (executor instanceof Promise) { + this.promise = executor; + } else { + this.promise = new Promise(executor.bind(context)); + } - request.headers.forEach(function (value, name) { - xhr.setRequestHeader(name, value); - }); + this.context = context; +} - xhr.onload = handler; - xhr.onabort = handler; - xhr.onerror = handler; - xhr.ontimeout = handler; - xhr.send(request.getBody()); - }); +PromiseObj.all = function (iterable, context) { + return new PromiseObj(Promise.all(iterable), context); }; -/** - * Http client (Node). - */ +PromiseObj.resolve = function (value, context) { + return new PromiseObj(Promise.resolve(value), context); +}; -var nodeClient = function (request) { +PromiseObj.reject = function (reason, context) { + return new PromiseObj(Promise.reject(reason), context); +}; - var client = require('got'); +PromiseObj.race = function (iterable, context) { + return new PromiseObj(Promise.race(iterable), context); +}; - return new PromiseObj(function (resolve) { +var p$1 = PromiseObj.prototype; - var url = request.getUrl(); - var body = request.getBody(); - var method = request.method; - var headers = {}, handler; +p$1.bind = function (context) { + this.context = context; + return this; +}; - request.headers.forEach(function (value, name) { - headers[name] = value; - }); +p$1.then = function (fulfilled, rejected) { + if (fulfilled && fulfilled.bind && this.context) { + fulfilled = fulfilled.bind(this.context); + } - client(url, {body: body, method: method, headers: headers}).then(handler = function (resp) { + if (rejected && rejected.bind && this.context) { + rejected = rejected.bind(this.context); + } - var response = request.respondWith(resp.body, { - status: resp.statusCode, - statusText: trim(resp.statusMessage) - } - ); + return new PromiseObj(this.promise.then(fulfilled, rejected), this.context); +}; - each(resp.headers, function (value, name) { - response.headers.set(name, value); - }); +p$1["catch"] = function (rejected) { + if (rejected && rejected.bind && this.context) { + rejected = rejected.bind(this.context); + } - resolve(response); + return new PromiseObj(this.promise["catch"](rejected), this.context); +}; - }, function (error$$1) { return handler(error$$1.response); }); - }); +p$1["finally"] = function (callback) { + return this.then(function (value) { + callback.call(this); + return value; + }, function (reason) { + callback.call(this); + return Promise.reject(reason); + }); }; /** - * Base client. + * Utility functions. */ +var _ref = {}, + hasOwnProperty = _ref.hasOwnProperty, + slice = [].slice, + debug = false, + ntick; +var inBrowser = typeof window !== 'undefined'; +function Util (_ref2) { + var config = _ref2.config, + nextTick = _ref2.nextTick; + ntick = nextTick; + debug = config.debug || !config.silent; +} +function warn(msg) { + if (typeof console !== 'undefined' && debug) { + console.warn('[VueResource warn]: ' + msg); + } +} +function error(msg) { + if (typeof console !== 'undefined') { + console.error(msg); + } +} +function nextTick(cb, ctx) { + return ntick(cb, ctx); +} +function trim(str) { + return str ? str.replace(/^\s*|\s*$/g, '') : ''; +} +function trimEnd(str, chars) { + if (str && chars === undefined) { + return str.replace(/\s+$/, ''); + } -var Client = function (context) { - - var reqHandlers = [sendRequest], resHandlers = [], handler; + if (!str || !chars) { + return str; + } - if (!isObject(context)) { - context = null; - } + return str.replace(new RegExp("[" + chars + "]+$"), ''); +} +function toLower(str) { + return str ? str.toLowerCase() : ''; +} +function toUpper(str) { + return str ? str.toUpperCase() : ''; +} +var isArray = Array.isArray; +function isString(val) { + return typeof val === 'string'; +} +function isFunction(val) { + return typeof val === 'function'; +} +function isObject(obj) { + return obj !== null && typeof obj === 'object'; +} +function isPlainObject(obj) { + return isObject(obj) && Object.getPrototypeOf(obj) == Object.prototype; +} +function isBlob(obj) { + return typeof Blob !== 'undefined' && obj instanceof Blob; +} +function isFormData(obj) { + return typeof FormData !== 'undefined' && obj instanceof FormData; +} +function when(value, fulfilled, rejected) { + var promise = PromiseObj.resolve(value); - function Client(request) { - return new PromiseObj(function (resolve, reject) { + if (arguments.length < 2) { + return promise; + } - function exec() { + return promise.then(fulfilled, rejected); +} +function options(fn, obj, opts) { + opts = opts || {}; - handler = reqHandlers.pop(); + if (isFunction(opts)) { + opts = opts.call(obj); + } - if (isFunction(handler)) { - handler.call(context, request, next); - } else { - warn(("Invalid interceptor of type " + (typeof handler) + ", must be a function")); - next(); - } - } + return merge(fn.bind({ + $vm: obj, + $options: opts + }), fn, { + $options: opts + }); +} +function each(obj, iterator) { + var i, key; - function next(response) { + if (isArray(obj)) { + for (i = 0; i < obj.length; i++) { + iterator.call(obj[i], obj[i], i); + } + } else if (isObject(obj)) { + for (key in obj) { + if (hasOwnProperty.call(obj, key)) { + iterator.call(obj[key], obj[key], key); + } + } + } - if (isFunction(response)) { + return obj; +} +var assign = Object.assign || _assign; +function merge(target) { + var args = slice.call(arguments, 1); + args.forEach(function (source) { + _merge(target, source, true); + }); + return target; +} +function defaults(target) { + var args = slice.call(arguments, 1); + args.forEach(function (source) { + for (var key in source) { + if (target[key] === undefined) { + target[key] = source[key]; + } + } + }); + return target; +} - resHandlers.unshift(response); +function _assign(target) { + var args = slice.call(arguments, 1); + args.forEach(function (source) { + _merge(target, source); + }); + return target; +} - } else if (isObject(response)) { +function _merge(target, source, deep) { + for (var key in source) { + if (deep && (isPlainObject(source[key]) || isArray(source[key]))) { + if (isPlainObject(source[key]) && !isPlainObject(target[key])) { + target[key] = {}; + } - resHandlers.forEach(function (handler) { - response = when(response, function (response) { - return handler.call(context, response) || response; - }, reject); - }); + if (isArray(source[key]) && !isArray(target[key])) { + target[key] = []; + } - when(response, resolve, reject); + _merge(target[key], source[key], deep); + } else if (source[key] !== undefined) { + target[key] = source[key]; + } + } +} - return; - } +/** + * Root Prefix Transform. + */ +function root (options$$1, next) { + var url = next(options$$1); - exec(); - } + if (isString(options$$1.root) && !/^(https?:)?\//.test(url)) { + url = trimEnd(options$$1.root, '/') + '/' + url; + } - exec(); + return url; +} - }, context); +/** + * Query Parameter Transform. + */ +function query (options$$1, next) { + var urlParams = Object.keys(Url.options.params), + query = {}, + url = next(options$$1); + each(options$$1.params, function (value, key) { + if (urlParams.indexOf(key) === -1) { + query[key] = value; } + }); + query = Url.params(query); - Client.use = function (handler) { - reqHandlers.push(handler); - }; - - return Client; -}; - -function sendRequest(request, resolve) { - - var client = request.client || (inBrowser ? xhrClient : nodeClient); + if (query) { + url += (url.indexOf('?') == -1 ? '?' : '&') + query; + } - resolve(client(request)); + return url; } /** - * HTTP Headers. + * URL Template v2.0.6 (https://github.com/bramstein/url-template) */ +function expand(url, params, variables) { + var tmpl = parse(url), + expanded = tmpl.expand(params); -var Headers = function Headers(headers) { - var this$1 = this; - + if (variables) { + variables.push.apply(variables, tmpl.vars); + } - this.map = {}; + return expanded; +} +function parse(template) { + var operators = ['+', '#', '.', '/', ';', '?', '&'], + variables = []; + return { + vars: variables, + expand: function expand(context) { + return template.replace(/\{([^{}]+)\}|([^{}]+)/g, function (_, expression, literal) { + if (expression) { + var operator = null, + values = []; + + if (operators.indexOf(expression.charAt(0)) !== -1) { + operator = expression.charAt(0); + expression = expression.substr(1); + } - each(headers, function (value, name) { return this$1.append(name, value); }); -}; + expression.split(/,/g).forEach(function (variable) { + var tmp = /([^:*]*)(?::(\d+)|(\*))?/.exec(variable); + values.push.apply(values, getValues(context, operator, tmp[1], tmp[2] || tmp[3])); + variables.push(tmp[1]); + }); -Headers.prototype.has = function has (name) { - return getName(this.map, name) !== null; -}; + if (operator && operator !== '+') { + var separator = ','; -Headers.prototype.get = function get (name) { + if (operator === '?') { + separator = '&'; + } else if (operator !== '#') { + separator = operator; + } - var list = this.map[getName(this.map, name)]; + return (values.length !== 0 ? operator : '') + values.join(separator); + } else { + return values.join(','); + } + } else { + return encodeReserved(literal); + } + }); + } + }; +} - return list ? list.join() : null; -}; +function getValues(context, operator, key, modifier) { + var value = context[key], + result = []; -Headers.prototype.getAll = function getAll (name) { - return this.map[getName(this.map, name)] || []; -}; + if (isDefined(value) && value !== '') { + if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') { + value = value.toString(); -Headers.prototype.set = function set (name, value) { - this.map[normalizeName(getName(this.map, name) || name)] = [trim(value)]; -}; + if (modifier && modifier !== '*') { + value = value.substring(0, parseInt(modifier, 10)); + } -Headers.prototype.append = function append (name, value){ + result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : null)); + } else { + if (modifier === '*') { + if (Array.isArray(value)) { + value.filter(isDefined).forEach(function (value) { + result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : null)); + }); + } else { + Object.keys(value).forEach(function (k) { + if (isDefined(value[k])) { + result.push(encodeValue(operator, value[k], k)); + } + }); + } + } else { + var tmp = []; - var list = this.map[getName(this.map, name)]; + if (Array.isArray(value)) { + value.filter(isDefined).forEach(function (value) { + tmp.push(encodeValue(operator, value)); + }); + } else { + Object.keys(value).forEach(function (k) { + if (isDefined(value[k])) { + tmp.push(encodeURIComponent(k)); + tmp.push(encodeValue(operator, value[k].toString())); + } + }); + } - if (list) { - list.push(trim(value)); - } else { - this.set(name, value); + if (isKeyOperator(operator)) { + result.push(encodeURIComponent(key) + '=' + tmp.join(',')); + } else if (tmp.length !== 0) { + result.push(tmp.join(',')); + } + } } -}; + } else { + if (operator === ';') { + result.push(encodeURIComponent(key)); + } else if (value === '' && (operator === '&' || operator === '?')) { + result.push(encodeURIComponent(key) + '='); + } else if (value === '') { + result.push(''); + } + } -Headers.prototype.delete = function delete$1 (name){ - delete this.map[getName(this.map, name)]; -}; + return result; +} -Headers.prototype.deleteAll = function deleteAll (){ - this.map = {}; -}; +function isDefined(value) { + return value !== undefined && value !== null; +} -Headers.prototype.forEach = function forEach (callback, thisArg) { - var this$1 = this; +function isKeyOperator(operator) { + return operator === ';' || operator === '&' || operator === '?'; +} - each(this.map, function (list, name) { - each(list, function (value) { return callback.call(thisArg, value, name, this$1); }); - }); -}; +function encodeValue(operator, value, key) { + value = operator === '+' || operator === '#' ? encodeReserved(value) : encodeURIComponent(value); -function getName(map, name) { - return Object.keys(map).reduce(function (prev, curr) { - return toLower(name) === toLower(curr) ? curr : prev; - }, null); + if (key) { + return encodeURIComponent(key) + '=' + value; + } else { + return value; + } } -function normalizeName(name) { - - if (/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(name)) { - throw new TypeError('Invalid character in header field name'); +function encodeReserved(str) { + return str.split(/(%[0-9A-Fa-f]{2})/g).map(function (part) { + if (!/%[0-9A-Fa-f]/.test(part)) { + part = encodeURI(part); } - return trim(name); + return part; + }).join(''); } /** - * HTTP Response. + * URL Template (RFC 6570) Transform. */ +function template (options) { + var variables = [], + url = expand(options.url, options.params, variables); + variables.forEach(function (key) { + delete options.params[key]; + }); + return url; +} -var Response = function Response(body, ref) { - var url = ref.url; - var headers = ref.headers; - var status = ref.status; - var statusText = ref.statusText; - +/** + * Service for URL templating. + */ +function Url(url, params) { + var self = this || {}, + options$$1 = url, + transform; + + if (isString(url)) { + options$$1 = { + url: url, + params: params + }; + } - this.url = url; - this.ok = status >= 200 && status < 300; - this.status = status || 0; - this.statusText = statusText || ''; - this.headers = new Headers(headers); - this.body = body; + options$$1 = merge({}, Url.options, self.$options, options$$1); + Url.transforms.forEach(function (handler) { + if (isString(handler)) { + handler = Url.transform[handler]; + } - if (isString(body)) { + if (isFunction(handler)) { + transform = factory(handler, transform, self.$vm); + } + }); + return transform(options$$1); +} +/** + * Url options. + */ - this.bodyText = body; +Url.options = { + url: '', + root: null, + params: {} +}; +/** + * Url transforms. + */ - } else if (isBlob(body)) { +Url.transform = { + template: template, + query: query, + root: root +}; +Url.transforms = ['template', 'query', 'root']; +/** + * Encodes a Url parameter string. + * + * @param {Object} obj + */ - this.bodyBlob = body; +Url.params = function (obj) { + var params = [], + escape = encodeURIComponent; - if (isBlobText(body)) { - this.bodyText = blobText(body); - } + params.add = function (key, value) { + if (isFunction(value)) { + value = value(); } -}; -Response.prototype.blob = function blob () { - return when(this.bodyBlob); -}; + if (value === null) { + value = ''; + } -Response.prototype.text = function text () { - return when(this.bodyText); -}; + this.push(escape(key) + '=' + escape(value)); + }; -Response.prototype.json = function json () { - return when(this.text(), function (text) { return JSON.parse(text); }); + serialize(params, obj); + return params.join('&').replace(/%20/g, '+'); }; +/** + * Parse a URL and return its components. + * + * @param {String} url + */ -Object.defineProperty(Response.prototype, 'data', { - - get: function get() { - return this.body; - }, - set: function set(body) { - this.body = body; - } +Url.parse = function (url) { + var el = document.createElement('a'); -}); + if (document.documentMode) { + el.href = url; + url = el.href; + } -function blobText(body) { - return new PromiseObj(function (resolve) { + el.href = url; + return { + href: el.href, + protocol: el.protocol ? el.protocol.replace(/:$/, '') : '', + port: el.port, + host: el.host, + hostname: el.hostname, + pathname: el.pathname.charAt(0) === '/' ? el.pathname : '/' + el.pathname, + search: el.search ? el.search.replace(/^\?/, '') : '', + hash: el.hash ? el.hash.replace(/^#/, '') : '' + }; +}; - var reader = new FileReader(); +function factory(handler, next, vm) { + return function (options$$1) { + return handler.call(vm, options$$1, next); + }; +} - reader.readAsText(body); - reader.onload = function () { - resolve(reader.result); - }; +function serialize(params, obj, scope) { + var array = isArray(obj), + plain = isPlainObject(obj), + hash; + each(obj, function (value, key) { + hash = isObject(value) || isArray(value); - }); -} + if (scope) { + key = scope + '[' + (plain || hash ? key : '') + ']'; + } -function isBlobText(body) { - return body.type.indexOf('text') === 0 || body.type.indexOf('json') !== -1; + if (!scope && array) { + params.add(value.name, value.value); + } else if (hash) { + serialize(params, value, key); + } else { + params.add(key, value); + } + }); } /** - * HTTP Request. + * XDomain client (Internet Explorer). */ +function xdrClient (request) { + return new PromiseObj(function (resolve) { + var xdr = new XDomainRequest(), + handler = function handler(_ref) { + var type = _ref.type; + var status = 0; -var Request = function Request(options$$1) { + if (type === 'load') { + status = 200; + } else if (type === 'error') { + status = 500; + } - this.body = null; - this.params = {}; + resolve(request.respondWith(xdr.responseText, { + status: status + })); + }; - assign(this, options$$1, { - method: toUpper(options$$1.method || 'GET') - }); + request.abort = function () { + return xdr.abort(); + }; - if (!(this.headers instanceof Headers)) { - this.headers = new Headers(this.headers); + xdr.open(request.method, request.getUrl()); + + if (request.timeout) { + xdr.timeout = request.timeout; } -}; -Request.prototype.getUrl = function getUrl (){ - return Url(this); -}; + xdr.onload = handler; + xdr.onabort = handler; + xdr.onerror = handler; + xdr.ontimeout = handler; -Request.prototype.getBody = function getBody (){ - return this.body; -}; + xdr.onprogress = function () {}; -Request.prototype.respondWith = function respondWith (body, options$$1) { - return new Response(body, assign(options$$1 || {}, {url: this.getUrl()})); -}; + xdr.send(request.getBody()); + }); +} /** - * Service for sending network requests. + * CORS Interceptor. */ +var SUPPORTS_CORS = inBrowser && 'withCredentials' in new XMLHttpRequest(); +function cors (request) { + if (inBrowser) { + var orgUrl = Url.parse(location.href); + var reqUrl = Url.parse(request.getUrl()); -var COMMON_HEADERS = {'Accept': 'application/json, text/plain, */*'}; -var JSON_CONTENT_TYPE = {'Content-Type': 'application/json;charset=utf-8'}; + if (reqUrl.protocol !== orgUrl.protocol || reqUrl.host !== orgUrl.host) { + request.crossOrigin = true; + request.emulateHTTP = false; -function Http(options$$1) { + if (!SUPPORTS_CORS) { + request.client = xdrClient; + } + } + } +} - var self = this || {}, client = Client(self.$vm); +/** + * Form data Interceptor. + */ +function form (request) { + if (isFormData(request.body)) { + request.headers["delete"]('Content-Type'); + } else if (isObject(request.body) && request.emulateJSON) { + request.body = Url.params(request.body); + request.headers.set('Content-Type', 'application/x-www-form-urlencoded'); + } +} - defaults(options$$1 || {}, self.$options, Http.options); +/** + * JSON Interceptor. + */ +function json (request) { + var type = request.headers.get('Content-Type') || ''; - Http.interceptors.forEach(function (handler) { + if (isObject(request.body) && type.indexOf('application/json') === 0) { + request.body = JSON.stringify(request.body); + } - if (isString(handler)) { - handler = Http.interceptor[handler]; - } + return function (response) { + return response.bodyText ? when(response.text(), function (text) { + var type = response.headers.get('Content-Type') || ''; - if (isFunction(handler)) { - client.use(handler); + if (type.indexOf('application/json') === 0 || isJson(text)) { + try { + response.body = JSON.parse(text); + } catch (e) { + response.body = null; } + } else { + response.body = text; + } - }); - - return client(new Request(options$$1)).then(function (response) { - - return response.ok ? response : PromiseObj.reject(response); + return response; + }) : response; + }; +} - }, function (response) { +function isJson(str) { + var start = str.match(/^\s*(\[|\{)/); + var end = { + '[': /]\s*$/, + '{': /}\s*$/ + }; + return start && end[start[1]].test(str); +} - if (response instanceof Error) { - error(response); - } +/** + * JSONP client (Browser). + */ +function jsonpClient (request) { + return new PromiseObj(function (resolve) { + var name = request.jsonp || 'callback', + callback = request.jsonpCallback || '_jsonp' + Math.random().toString(36).substr(2), + body = null, + handler, + script; - return PromiseObj.reject(response); - }); -} + handler = function handler(_ref) { + var type = _ref.type; + var status = 0; -Http.options = {}; + if (type === 'load' && body !== null) { + status = 200; + } else if (type === 'error') { + status = 500; + } -Http.headers = { - put: JSON_CONTENT_TYPE, - post: JSON_CONTENT_TYPE, - patch: JSON_CONTENT_TYPE, - delete: JSON_CONTENT_TYPE, - common: COMMON_HEADERS, - custom: {} -}; + if (status && window[callback]) { + delete window[callback]; + document.body.removeChild(script); + } -Http.interceptor = {before: before, method: method, jsonp: jsonp, json: json, form: form, header: header, cors: cors}; -Http.interceptors = ['before', 'method', 'jsonp', 'json', 'form', 'header', 'cors']; + resolve(request.respondWith(body, { + status: status + })); + }; -['get', 'delete', 'head', 'jsonp'].forEach(function (method$$1) { + window[callback] = function (result) { + body = JSON.stringify(result); + }; - Http[method$$1] = function (url, options$$1) { - return this(assign(options$$1 || {}, {url: url, method: method$$1})); + request.abort = function () { + handler({ + type: 'abort' + }); }; -}); + request.params[name] = callback; -['post', 'put', 'patch'].forEach(function (method$$1) { + if (request.timeout) { + setTimeout(request.abort, request.timeout); + } - Http[method$$1] = function (url, body, options$$1) { - return this(assign(options$$1 || {}, {url: url, method: method$$1, body: body})); - }; + script = document.createElement('script'); + script.src = request.getUrl(); + script.type = 'text/javascript'; + script.async = true; + script.onload = handler; + script.onerror = handler; + document.body.appendChild(script); + }); +} -}); +/** + * JSONP Interceptor. + */ +function jsonp (request) { + if (request.method == 'JSONP') { + request.client = jsonpClient; + } +} /** - * Service for interacting with RESTful services. + * Before Interceptor. */ +function before (request) { + if (isFunction(request.before)) { + request.before.call(this, request); + } +} -function Resource(url, params, actions, options$$1) { +/** + * HTTP method override Interceptor. + */ +function method (request) { + if (request.emulateHTTP && /^(PUT|PATCH|DELETE)$/i.test(request.method)) { + request.headers.set('X-HTTP-Method-Override', request.method); + request.method = 'POST'; + } +} - var self = this || {}, resource = {}; +/** + * Header Interceptor. + */ +function header (request) { + var headers = assign({}, Http.headers.common, !request.crossOrigin ? Http.headers.custom : {}, Http.headers[toLower(request.method)]); + each(headers, function (value, name) { + if (!request.headers.has(name)) { + request.headers.set(name, value); + } + }); +} - actions = assign({}, - Resource.actions, - actions - ); +/** + * XMLHttp client (Browser). + */ +function xhrClient (request) { + return new PromiseObj(function (resolve) { + var xhr = new XMLHttpRequest(), + handler = function handler(event) { + var response = request.respondWith('response' in xhr ? xhr.response : xhr.responseText, { + status: xhr.status === 1223 ? 204 : xhr.status, + // IE9 status bug + statusText: xhr.status === 1223 ? 'No Content' : trim(xhr.statusText) + }); + each(trim(xhr.getAllResponseHeaders()).split('\n'), function (row) { + response.headers.append(row.slice(0, row.indexOf(':')), row.slice(row.indexOf(':') + 1)); + }); + resolve(response); + }; - each(actions, function (action, name) { + request.abort = function () { + return xhr.abort(); + }; - action = merge({url: url, params: assign({}, params)}, options$$1, action); + xhr.open(request.method, request.getUrl(), true); - resource[name] = function () { - return (self.$http || Http)(opts(action, arguments)); - }; - }); + if (request.timeout) { + xhr.timeout = request.timeout; + } - return resource; -} + if (request.responseType && 'responseType' in xhr) { + xhr.responseType = request.responseType; + } -function opts(action, args) { + if (request.withCredentials || request.credentials) { + xhr.withCredentials = true; + } - var options$$1 = assign({}, action), params = {}, body; + if (!request.crossOrigin) { + request.headers.set('X-Requested-With', 'XMLHttpRequest'); + } // deprecated use downloadProgress - switch (args.length) { - case 2: + if (isFunction(request.progress) && request.method === 'GET') { + xhr.addEventListener('progress', request.progress); + } - params = args[0]; - body = args[1]; + if (isFunction(request.downloadProgress)) { + xhr.addEventListener('progress', request.downloadProgress); + } // deprecated use uploadProgress - break; - case 1: + if (isFunction(request.progress) && /^(POST|PUT)$/i.test(request.method)) { + xhr.upload.addEventListener('progress', request.progress); + } - if (/^(POST|PUT|PATCH)$/i.test(options$$1.method)) { - body = args[0]; - } else { - params = args[0]; - } + if (isFunction(request.uploadProgress) && xhr.upload) { + xhr.upload.addEventListener('progress', request.uploadProgress); + } - break; + request.headers.forEach(function (value, name) { + xhr.setRequestHeader(name, value); + }); + xhr.onload = handler; + xhr.onabort = handler; + xhr.onerror = handler; + xhr.ontimeout = handler; + xhr.send(request.getBody()); + }); +} - case 0: +/** + * Http client (Node). + */ +function nodeClient (request) { + var client = require('got'); + + return new PromiseObj(function (resolve) { + var url = request.getUrl(); + var body = request.getBody(); + var method = request.method; + var headers = {}, + handler; + request.headers.forEach(function (value, name) { + headers[name] = value; + }); + client(url, { + body: body, + method: method, + headers: headers + }).then(handler = function handler(resp) { + var response = request.respondWith(resp.body, { + status: resp.statusCode, + statusText: trim(resp.statusMessage) + }); + each(resp.headers, function (value, name) { + response.headers.set(name, value); + }); + resolve(response); + }, function (error$$1) { + return handler(error$$1.response); + }); + }); +} - break; +/** + * Base client. + */ +function Client (context) { + var reqHandlers = [sendRequest], + resHandlers = []; + + if (!isObject(context)) { + context = null; + } + + function Client(request) { + while (reqHandlers.length) { + var handler = reqHandlers.pop(); + + if (isFunction(handler)) { + var _ret = function () { + var response = void 0, + next = void 0; + response = handler.call(context, request, function (val) { + return next = val; + }) || next; + + if (isObject(response)) { + return { + v: new PromiseObj(function (resolve, reject) { + resHandlers.forEach(function (handler) { + response = when(response, function (response) { + return handler.call(context, response) || response; + }, reject); + }); + when(response, resolve, reject); + }, context) + }; + } - default: + if (isFunction(response)) { + resHandlers.unshift(response); + } + }(); - throw 'Expected up to 2 arguments [params, body], got ' + args.length + ' arguments'; + if (typeof _ret === "object") return _ret.v; + } else { + warn("Invalid interceptor of type " + typeof handler + ", must be a function"); + } } + } - options$$1.body = body; - options$$1.params = assign({}, options$$1.params, params); + Client.use = function (handler) { + reqHandlers.push(handler); + }; - return options$$1; + return Client; } -Resource.actions = { - - get: {method: 'GET'}, - save: {method: 'POST'}, - query: {method: 'GET'}, - update: {method: 'PUT'}, - remove: {method: 'DELETE'}, - delete: {method: 'DELETE'} - -}; +function sendRequest(request) { + var client = request.client || (inBrowser ? xhrClient : nodeClient); + return client(request); +} /** - * Install plugin. + * HTTP Headers. */ -function plugin(Vue) { - - if (plugin.installed) { - return; - } +var Headers = /*#__PURE__*/function () { + function Headers(headers) { + var _this = this; - Util(Vue); - - Vue.url = Url; - Vue.http = Http; - Vue.resource = Resource; - Vue.Promise = PromiseObj; + this.map = {}; + each(headers, function (value, name) { + return _this.append(name, value); + }); + } - Object.defineProperties(Vue.prototype, { + var _proto = Headers.prototype; - $url: { - get: function get() { - return options(Vue.url, this, this.$options.url); - } - }, + _proto.has = function has(name) { + return getName(this.map, name) !== null; + }; - $http: { - get: function get() { - return options(Vue.http, this, this.$options.http); - } - }, + _proto.get = function get(name) { + var list = this.map[getName(this.map, name)]; + return list ? list.join() : null; + }; - $resource: { - get: function get() { - return Vue.resource.bind(this); - } - }, + _proto.getAll = function getAll(name) { + return this.map[getName(this.map, name)] || []; + }; - $promise: { - get: function get() { - var this$1 = this; + _proto.set = function set(name, value) { + this.map[normalizeName(getName(this.map, name) || name)] = [trim(value)]; + }; - return function (executor) { return new Vue.Promise(executor, this$1); }; - } - } + _proto.append = function append(name, value) { + var list = this.map[getName(this.map, name)]; - }); -} + if (list) { + list.push(trim(value)); + } else { + this.set(name, value); + } + }; -if (typeof window !== 'undefined' && window.Vue) { - window.Vue.use(plugin); -} + _proto["delete"] = function _delete(name) { + delete this.map[getName(this.map, name)]; + }; -module.exports = plugin; + _proto.deleteAll = function deleteAll() { + this.map = {}; + }; -},{"got":7}],50:[function(require,module,exports){ -(function (process,global,setImmediate){ -/*! - * Vue.js v2.5.2 - * (c) 2014-2017 Evan You - * Released under the MIT License. - */ -'use strict'; + _proto.forEach = function forEach(callback, thisArg) { + var _this2 = this; -/* */ + each(this.map, function (list, name) { + each(list, function (value) { + return callback.call(thisArg, value, name, _this2); + }); + }); + }; -// these helpers produces better vm code in JS engines due to their -// explicitness and function inlining -function isUndef (v) { - return v === undefined || v === null -} + return Headers; +}(); -function isDef (v) { - return v !== undefined && v !== null +function getName(map, name) { + return Object.keys(map).reduce(function (prev, curr) { + return toLower(name) === toLower(curr) ? curr : prev; + }, null); } -function isTrue (v) { - return v === true -} +function normalizeName(name) { + if (/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(name)) { + throw new TypeError('Invalid character in header field name'); + } -function isFalse (v) { - return v === false + return trim(name); } /** - * Check if value is primitive + * HTTP Response. */ -function isPrimitive (value) { - return ( - typeof value === 'string' || - typeof value === 'number' || - typeof value === 'boolean' - ) -} -/** - * Quick object check - this is primarily used to tell - * Objects from primitive values when we know the value - * is a JSON-compliant type. - */ -function isObject (obj) { - return obj !== null && typeof obj === 'object' -} +var Response = /*#__PURE__*/function () { + function Response(body, _ref) { + var url = _ref.url, + headers = _ref.headers, + status = _ref.status, + statusText = _ref.statusText; + this.url = url; + this.ok = status >= 200 && status < 300; + this.status = status || 0; + this.statusText = statusText || ''; + this.headers = new Headers(headers); + this.body = body; -/** - * Get the raw type string of a value e.g. [object Object] - */ -var _toString = Object.prototype.toString; + if (isString(body)) { + this.bodyText = body; + } else if (isBlob(body)) { + this.bodyBlob = body; -function toRawType (value) { - return _toString.call(value).slice(8, -1) -} + if (isBlobText(body)) { + this.bodyText = blobText(body); + } + } + } -/** - * Strict object type check. Only returns true - * for plain JavaScript objects. - */ -function isPlainObject (obj) { - return _toString.call(obj) === '[object Object]' -} + var _proto = Response.prototype; -function isRegExp (v) { - return _toString.call(v) === '[object RegExp]' -} + _proto.blob = function blob() { + return when(this.bodyBlob); + }; -/** - * Check if val is a valid array index. - */ -function isValidArrayIndex (val) { - var n = parseFloat(String(val)); - return n >= 0 && Math.floor(n) === n && isFinite(val) -} + _proto.text = function text() { + return when(this.bodyText); + }; -/** - * Convert a value to a string that is actually rendered. - */ -function toString (val) { - return val == null - ? '' - : typeof val === 'object' - ? JSON.stringify(val, null, 2) - : String(val) -} + _proto.json = function json() { + return when(this.text(), function (text) { + return JSON.parse(text); + }); + }; -/** - * Convert a input value to a number for persistence. - * If the conversion fails, return original string. - */ -function toNumber (val) { - var n = parseFloat(val); - return isNaN(n) ? val : n + return Response; +}(); +Object.defineProperty(Response.prototype, 'data', { + get: function get() { + return this.body; + }, + set: function set(body) { + this.body = body; + } +}); + +function blobText(body) { + return new PromiseObj(function (resolve) { + var reader = new FileReader(); + reader.readAsText(body); + + reader.onload = function () { + resolve(reader.result); + }; + }); } -/** - * Make a map and return a function for checking if a key - * is in that map. - */ -function makeMap ( - str, - expectsLowerCase -) { - var map = Object.create(null); - var list = str.split(','); - for (var i = 0; i < list.length; i++) { - map[list[i]] = true; - } - return expectsLowerCase - ? function (val) { return map[val.toLowerCase()]; } - : function (val) { return map[val]; } +function isBlobText(body) { + return body.type.indexOf('text') === 0 || body.type.indexOf('json') !== -1; } /** - * Check if a tag is a built-in tag. + * HTTP Request. */ -var isBuiltInTag = makeMap('slot,component', true); -/** - * Check if a attribute is a reserved attribute. - */ -var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is'); +var Request = /*#__PURE__*/function () { + function Request(options$$1) { + this.body = null; + this.params = {}; + assign(this, options$$1, { + method: toUpper(options$$1.method || 'GET') + }); -/** - * Remove an item from an array - */ -function remove (arr, item) { - if (arr.length) { - var index = arr.indexOf(item); - if (index > -1) { - return arr.splice(index, 1) + if (!(this.headers instanceof Headers)) { + this.headers = new Headers(this.headers); } } -} -/** - * Check whether the object has the property. + var _proto = Request.prototype; + + _proto.getUrl = function getUrl() { + return Url(this); + }; + + _proto.getBody = function getBody() { + return this.body; + }; + + _proto.respondWith = function respondWith(body, options$$1) { + return new Response(body, assign(options$$1 || {}, { + url: this.getUrl() + })); + }; + + return Request; +}(); + +/** + * Service for sending network requests. + */ +var COMMON_HEADERS = { + 'Accept': 'application/json, text/plain, */*' +}; +var JSON_CONTENT_TYPE = { + 'Content-Type': 'application/json;charset=utf-8' +}; +function Http(options$$1) { + var self = this || {}, + client = Client(self.$vm); + defaults(options$$1 || {}, self.$options, Http.options); + Http.interceptors.forEach(function (handler) { + if (isString(handler)) { + handler = Http.interceptor[handler]; + } + + if (isFunction(handler)) { + client.use(handler); + } + }); + return client(new Request(options$$1)).then(function (response) { + return response.ok ? response : PromiseObj.reject(response); + }, function (response) { + if (response instanceof Error) { + error(response); + } + + return PromiseObj.reject(response); + }); +} +Http.options = {}; +Http.headers = { + put: JSON_CONTENT_TYPE, + post: JSON_CONTENT_TYPE, + patch: JSON_CONTENT_TYPE, + "delete": JSON_CONTENT_TYPE, + common: COMMON_HEADERS, + custom: {} +}; +Http.interceptor = { + before: before, + method: method, + jsonp: jsonp, + json: json, + form: form, + header: header, + cors: cors +}; +Http.interceptors = ['before', 'method', 'jsonp', 'json', 'form', 'header', 'cors']; +['get', 'delete', 'head', 'jsonp'].forEach(function (method$$1) { + Http[method$$1] = function (url, options$$1) { + return this(assign(options$$1 || {}, { + url: url, + method: method$$1 + })); + }; +}); +['post', 'put', 'patch'].forEach(function (method$$1) { + Http[method$$1] = function (url, body, options$$1) { + return this(assign(options$$1 || {}, { + url: url, + method: method$$1, + body: body + })); + }; +}); + +/** + * Service for interacting with RESTful services. */ -var hasOwnProperty = Object.prototype.hasOwnProperty; -function hasOwn (obj, key) { - return hasOwnProperty.call(obj, key) +function Resource(url, params, actions, options$$1) { + var self = this || {}, + resource = {}; + actions = assign({}, Resource.actions, actions); + each(actions, function (action, name) { + action = merge({ + url: url, + params: assign({}, params) + }, options$$1, action); + + resource[name] = function () { + return (self.$http || Http)(opts(action, arguments)); + }; + }); + return resource; +} + +function opts(action, args) { + var options$$1 = assign({}, action), + params = {}, + body; + + switch (args.length) { + case 2: + params = args[0]; + body = args[1]; + break; + + case 1: + if (/^(POST|PUT|PATCH)$/i.test(options$$1.method)) { + body = args[0]; + } else { + params = args[0]; + } + + break; + + case 0: + break; + + default: + throw 'Expected up to 2 arguments [params, body], got ' + args.length + ' arguments'; + } + + options$$1.body = body; + options$$1.params = assign({}, options$$1.params, params); + return options$$1; } +Resource.actions = { + get: { + method: 'GET' + }, + save: { + method: 'POST' + }, + query: { + method: 'GET' + }, + update: { + method: 'PUT' + }, + remove: { + method: 'DELETE' + }, + "delete": { + method: 'DELETE' + } +}; + /** - * Create a cached version of a pure function. + * Install plugin. */ -function cached (fn) { - var cache = Object.create(null); - return (function cachedFn (str) { - var hit = cache[str]; - return hit || (cache[str] = fn(str)) - }) + +function plugin(Vue) { + if (plugin.installed) { + return; + } + + Util(Vue); + Vue.url = Url; + Vue.http = Http; + Vue.resource = Resource; + Vue.Promise = PromiseObj; + Object.defineProperties(Vue.prototype, { + $url: { + get: function get() { + return options(Vue.url, this, this.$options.url); + } + }, + $http: { + get: function get() { + return options(Vue.http, this, this.$options.http); + } + }, + $resource: { + get: function get() { + return Vue.resource.bind(this); + } + }, + $promise: { + get: function get() { + var _this = this; + + return function (executor) { + return new Vue.Promise(executor, _this); + }; + } + } + }); +} + +if (typeof window !== 'undefined' && window.Vue && !window.Vue.resource) { + window.Vue.use(plugin); } +module.exports = plugin; + +},{"got":7}],51:[function(require,module,exports){ +(function (global,setImmediate){(function (){ +/*! + * Vue.js v2.7.16 + * (c) 2014-2023 Evan You + * Released under the MIT License. + */ +'use strict'; + +const emptyObject = Object.freeze({}); +const isArray = Array.isArray; +// These helpers produce better VM code in JS engines due to their +// explicitness and function inlining. +function isUndef(v) { + return v === undefined || v === null; +} +function isDef(v) { + return v !== undefined && v !== null; +} +function isTrue(v) { + return v === true; +} +function isFalse(v) { + return v === false; +} +/** + * Check if value is primitive. + */ +function isPrimitive(value) { + return (typeof value === 'string' || + typeof value === 'number' || + // $flow-disable-line + typeof value === 'symbol' || + typeof value === 'boolean'); +} +function isFunction(value) { + return typeof value === 'function'; +} +/** + * Quick object check - this is primarily used to tell + * objects from primitive values when we know the value + * is a JSON-compliant type. + */ +function isObject(obj) { + return obj !== null && typeof obj === 'object'; +} +/** + * Get the raw type string of a value, e.g., [object Object]. + */ +const _toString = Object.prototype.toString; +function toRawType(value) { + return _toString.call(value).slice(8, -1); +} +/** + * Strict object type check. Only returns true + * for plain JavaScript objects. + */ +function isPlainObject(obj) { + return _toString.call(obj) === '[object Object]'; +} +function isRegExp(v) { + return _toString.call(v) === '[object RegExp]'; +} +/** + * Check if val is a valid array index. + */ +function isValidArrayIndex(val) { + const n = parseFloat(String(val)); + return n >= 0 && Math.floor(n) === n && isFinite(val); +} +function isPromise(val) { + return (isDef(val) && + typeof val.then === 'function' && + typeof val.catch === 'function'); +} +/** + * Convert a value to a string that is actually rendered. + */ +function toString(val) { + return val == null + ? '' + : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString) + ? JSON.stringify(val, replacer, 2) + : String(val); +} +function replacer(_key, val) { + // avoid circular deps from v3 + if (val && val.__v_isRef) { + return val.value; + } + return val; +} +/** + * Convert an input value to a number for persistence. + * If the conversion fails, return original string. + */ +function toNumber(val) { + const n = parseFloat(val); + return isNaN(n) ? val : n; +} +/** + * Make a map and return a function for checking if a key + * is in that map. + */ +function makeMap(str, expectsLowerCase) { + const map = Object.create(null); + const list = str.split(','); + for (let i = 0; i < list.length; i++) { + map[list[i]] = true; + } + return expectsLowerCase ? val => map[val.toLowerCase()] : val => map[val]; +} +/** + * Check if a tag is a built-in tag. + */ +const isBuiltInTag = makeMap('slot,component', true); +/** + * Check if an attribute is a reserved attribute. + */ +const isReservedAttribute = makeMap('key,ref,slot,slot-scope,is'); +/** + * Remove an item from an array. + */ +function remove$2(arr, item) { + const len = arr.length; + if (len) { + // fast path for the only / last item + if (item === arr[len - 1]) { + arr.length = len - 1; + return; + } + const index = arr.indexOf(item); + if (index > -1) { + return arr.splice(index, 1); + } + } +} +/** + * Check whether an object has the property. + */ +const hasOwnProperty = Object.prototype.hasOwnProperty; +function hasOwn(obj, key) { + return hasOwnProperty.call(obj, key); +} +/** + * Create a cached version of a pure function. + */ +function cached(fn) { + const cache = Object.create(null); + return function cachedFn(str) { + const hit = cache[str]; + return hit || (cache[str] = fn(str)); + }; +} /** * Camelize a hyphen-delimited string. */ -var camelizeRE = /-(\w)/g; -var camelize = cached(function (str) { - return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; }) +const camelizeRE = /-(\w)/g; +const camelize = cached((str) => { + return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : '')); }); - /** * Capitalize a string. */ -var capitalize = cached(function (str) { - return str.charAt(0).toUpperCase() + str.slice(1) +const capitalize = cached((str) => { + return str.charAt(0).toUpperCase() + str.slice(1); }); - /** * Hyphenate a camelCase string. */ -var hyphenateRE = /\B([A-Z])/g; -var hyphenate = cached(function (str) { - return str.replace(hyphenateRE, '-$1').toLowerCase() +const hyphenateRE = /\B([A-Z])/g; +const hyphenate = cached((str) => { + return str.replace(hyphenateRE, '-$1').toLowerCase(); }); - /** - * Simple bind, faster than native + * Simple bind polyfill for environments that do not support it, + * e.g., PhantomJS 1.x. Technically, we don't need this anymore + * since native bind is now performant enough in most browsers. + * But removing it would mean breaking code that was able to run in + * PhantomJS 1.x, so this must be kept for backward compatibility. */ -function bind (fn, ctx) { - function boundFn (a) { - var l = arguments.length; - return l - ? l > 1 - ? fn.apply(ctx, arguments) - : fn.call(ctx, a) - : fn.call(ctx) - } - // record original fn length - boundFn._length = fn.length; - return boundFn -} - +/* istanbul ignore next */ +function polyfillBind(fn, ctx) { + function boundFn(a) { + const l = arguments.length; + return l + ? l > 1 + ? fn.apply(ctx, arguments) + : fn.call(ctx, a) + : fn.call(ctx); + } + boundFn._length = fn.length; + return boundFn; +} +function nativeBind(fn, ctx) { + return fn.bind(ctx); +} +// @ts-expect-error bind cannot be `undefined` +const bind = Function.prototype.bind ? nativeBind : polyfillBind; /** * Convert an Array-like object to a real Array. */ -function toArray (list, start) { - start = start || 0; - var i = list.length - start; - var ret = new Array(i); - while (i--) { - ret[i] = list[i + start]; - } - return ret +function toArray(list, start) { + start = start || 0; + let i = list.length - start; + const ret = new Array(i); + while (i--) { + ret[i] = list[i + start]; + } + return ret; } - /** * Mix properties into target object. */ -function extend (to, _from) { - for (var key in _from) { - to[key] = _from[key]; - } - return to +function extend(to, _from) { + for (const key in _from) { + to[key] = _from[key]; + } + return to; } - /** * Merge an Array of Objects into a single Object. */ -function toObject (arr) { - var res = {}; - for (var i = 0; i < arr.length; i++) { - if (arr[i]) { - extend(res, arr[i]); +function toObject(arr) { + const res = {}; + for (let i = 0; i < arr.length; i++) { + if (arr[i]) { + extend(res, arr[i]); + } } - } - return res + return res; } - +/* eslint-disable no-unused-vars */ /** * Perform no operation. * Stubbing args to make Flow happy without leaving useless transpiled code - * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/) + * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/). */ -function noop (a, b, c) {} - +function noop(a, b, c) { } /** * Always return false. */ -var no = function (a, b, c) { return false; }; - -/** - * Return same value - */ -var identity = function (_) { return _; }; - +const no = (a, b, c) => false; +/* eslint-enable no-unused-vars */ /** - * Generate a static keys string from compiler modules. + * Return the same value. */ - - +const identity = (_) => _; /** * Check if two values are loosely equal - that is, * if they are plain objects, do they have the same shape? */ -function looseEqual (a, b) { - if (a === b) { return true } - var isObjectA = isObject(a); - var isObjectB = isObject(b); - if (isObjectA && isObjectB) { - try { - var isArrayA = Array.isArray(a); - var isArrayB = Array.isArray(b); - if (isArrayA && isArrayB) { - return a.length === b.length && a.every(function (e, i) { - return looseEqual(e, b[i]) - }) - } else if (!isArrayA && !isArrayB) { - var keysA = Object.keys(a); - var keysB = Object.keys(b); - return keysA.length === keysB.length && keysA.every(function (key) { - return looseEqual(a[key], b[key]) - }) - } else { - /* istanbul ignore next */ - return false - } - } catch (e) { - /* istanbul ignore next */ - return false +function looseEqual(a, b) { + if (a === b) + return true; + const isObjectA = isObject(a); + const isObjectB = isObject(b); + if (isObjectA && isObjectB) { + try { + const isArrayA = Array.isArray(a); + const isArrayB = Array.isArray(b); + if (isArrayA && isArrayB) { + return (a.length === b.length && + a.every((e, i) => { + return looseEqual(e, b[i]); + })); + } + else if (a instanceof Date && b instanceof Date) { + return a.getTime() === b.getTime(); + } + else if (!isArrayA && !isArrayB) { + const keysA = Object.keys(a); + const keysB = Object.keys(b); + return (keysA.length === keysB.length && + keysA.every(key => { + return looseEqual(a[key], b[key]); + })); + } + else { + /* istanbul ignore next */ + return false; + } + } + catch (e) { + /* istanbul ignore next */ + return false; + } + } + else if (!isObjectA && !isObjectB) { + return String(a) === String(b); + } + else { + return false; } - } else if (!isObjectA && !isObjectB) { - return String(a) === String(b) - } else { - return false - } } - -function looseIndexOf (arr, val) { - for (var i = 0; i < arr.length; i++) { - if (looseEqual(arr[i], val)) { return i } - } - return -1 +/** + * Return the first index at which a loosely equal value can be + * found in the array (if value is a plain object, the array must + * contain an object of the same shape), or -1 if it is not present. + */ +function looseIndexOf(arr, val) { + for (let i = 0; i < arr.length; i++) { + if (looseEqual(arr[i], val)) + return i; + } + return -1; } - /** * Ensure a function is called only once. */ -function once (fn) { - var called = false; - return function () { - if (!called) { - called = true; - fn.apply(this, arguments); - } - } +function once(fn) { + let called = false; + return function () { + if (!called) { + called = true; + fn.apply(this, arguments); + } + }; } - -var SSR_ATTR = 'data-server-rendered'; - -var ASSET_TYPES = [ - 'component', - 'directive', - 'filter' +// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is#polyfill +function hasChanged(x, y) { + if (x === y) { + return x === 0 && 1 / x !== 1 / y; + } + else { + return x === x || y === y; + } +} + +const SSR_ATTR = 'data-server-rendered'; +const ASSET_TYPES = ['component', 'directive', 'filter']; +const LIFECYCLE_HOOKS = [ + 'beforeCreate', + 'created', + 'beforeMount', + 'mounted', + 'beforeUpdate', + 'updated', + 'beforeDestroy', + 'destroyed', + 'activated', + 'deactivated', + 'errorCaptured', + 'serverPrefetch', + 'renderTracked', + 'renderTriggered' ]; -var LIFECYCLE_HOOKS = [ - 'beforeCreate', - 'created', - 'beforeMount', - 'mounted', - 'beforeUpdate', - 'updated', - 'beforeDestroy', - 'destroyed', - 'activated', - 'deactivated', - 'errorCaptured' -]; +var config = { + /** + * Option merge strategies (used in core/util/options) + */ + // $flow-disable-line + optionMergeStrategies: Object.create(null), + /** + * Whether to suppress warnings. + */ + silent: false, + /** + * Show production mode tip message on boot? + */ + productionTip: true, + /** + * Whether to enable devtools + */ + devtools: true, + /** + * Whether to record perf + */ + performance: false, + /** + * Error handler for watcher errors + */ + errorHandler: null, + /** + * Warn handler for watcher warns + */ + warnHandler: null, + /** + * Ignore certain custom elements + */ + ignoredElements: [], + /** + * Custom user key aliases for v-on + */ + // $flow-disable-line + keyCodes: Object.create(null), + /** + * Check if a tag is reserved so that it cannot be registered as a + * component. This is platform-dependent and may be overwritten. + */ + isReservedTag: no, + /** + * Check if an attribute is reserved so that it cannot be used as a component + * prop. This is platform-dependent and may be overwritten. + */ + isReservedAttr: no, + /** + * Check if a tag is an unknown element. + * Platform-dependent. + */ + isUnknownElement: no, + /** + * Get the namespace of an element + */ + getTagNamespace: noop, + /** + * Parse the real tag name for the specific platform. + */ + parsePlatformTagName: identity, + /** + * Check if an attribute must be bound using property, e.g. value + * Platform-dependent. + */ + mustUseProp: no, + /** + * Perform updates asynchronously. Intended to be used by Vue Test Utils + * This will significantly reduce performance if set to false. + */ + async: true, + /** + * Exposed for legacy reasons + */ + _lifecycleHooks: LIFECYCLE_HOOKS +}; -/* */ +/** + * unicode letters used for parsing html tags, component names and property paths. + * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname + * skipping \u10000-\uEFFFF due to it freezing up PhantomJS + */ +const unicodeRegExp = /a-zA-Z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD/; +/** + * Check if a string starts with $ or _ + */ +function isReserved(str) { + const c = (str + '').charCodeAt(0); + return c === 0x24 || c === 0x5f; +} +/** + * Define a property. + */ +function def(obj, key, val, enumerable) { + Object.defineProperty(obj, key, { + value: val, + enumerable: !!enumerable, + writable: true, + configurable: true + }); +} +/** + * Parse simple path. + */ +const bailRE = new RegExp(`[^${unicodeRegExp.source}.$_\\d]`); +function parsePath(path) { + if (bailRE.test(path)) { + return; + } + const segments = path.split('.'); + return function (obj) { + for (let i = 0; i < segments.length; i++) { + if (!obj) + return; + obj = obj[segments[i]]; + } + return obj; + }; +} -var config = ({ - /** - * Option merge strategies (used in core/util/options) - */ - optionMergeStrategies: Object.create(null), - - /** - * Whether to suppress warnings. - */ - silent: false, - - /** - * Show production mode tip message on boot? - */ - productionTip: process.env.NODE_ENV !== 'production', - - /** - * Whether to enable devtools - */ - devtools: process.env.NODE_ENV !== 'production', - - /** - * Whether to record perf - */ - performance: false, - - /** - * Error handler for watcher errors - */ - errorHandler: null, - - /** - * Warn handler for watcher warns - */ - warnHandler: null, - - /** - * Ignore certain custom elements - */ - ignoredElements: [], - - /** - * Custom user key aliases for v-on - */ - keyCodes: Object.create(null), - - /** - * Check if a tag is reserved so that it cannot be registered as a - * component. This is platform-dependent and may be overwritten. - */ - isReservedTag: no, - - /** - * Check if an attribute is reserved so that it cannot be used as a component - * prop. This is platform-dependent and may be overwritten. - */ - isReservedAttr: no, - - /** - * Check if a tag is an unknown element. - * Platform-dependent. - */ - isUnknownElement: no, - - /** - * Get the namespace of an element - */ - getTagNamespace: noop, - - /** - * Parse the real tag name for the specific platform. - */ - parsePlatformTagName: identity, - - /** - * Check if an attribute must be bound using property, e.g. value - * Platform-dependent. - */ - mustUseProp: no, - - /** - * Exposed for legacy reasons - */ - _lifecycleHooks: LIFECYCLE_HOOKS -}); - -/* */ - -var emptyObject = Object.freeze({}); +// can we use __proto__? +const hasProto = '__proto__' in {}; +// Browser environment sniffing +const inBrowser = typeof window !== 'undefined'; +const UA = inBrowser && window.navigator.userAgent.toLowerCase(); +const isIE = UA && /msie|trident/.test(UA); +const isIE9 = UA && UA.indexOf('msie 9.0') > 0; +const isEdge = UA && UA.indexOf('edge/') > 0; +UA && UA.indexOf('android') > 0; +const isIOS = UA && /iphone|ipad|ipod|ios/.test(UA); +UA && /chrome\/\d+/.test(UA) && !isEdge; +UA && /phantomjs/.test(UA); +const isFF = UA && UA.match(/firefox\/(\d+)/); +// Firefox has a "watch" function on Object.prototype... +// @ts-expect-error firebox support +const nativeWatch = {}.watch; +let supportsPassive = false; +if (inBrowser) { + try { + const opts = {}; + Object.defineProperty(opts, 'passive', { + get() { + /* istanbul ignore next */ + supportsPassive = true; + } + }); // https://github.com/facebook/flow/issues/285 + window.addEventListener('test-passive', null, opts); + } + catch (e) { } +} +// this needs to be lazy-evaled because vue may be required before +// vue-server-renderer can set VUE_ENV +let _isServer; +const isServerRendering = () => { + if (_isServer === undefined) { + /* istanbul ignore if */ + if (!inBrowser && typeof global !== 'undefined') { + // detect presence of vue-server-renderer and avoid + // Webpack shimming the process + _isServer = + global['process'] && global['process'].env.VUE_ENV === 'server'; + } + else { + _isServer = false; + } + } + return _isServer; +}; +// detect devtools +const devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__; +/* istanbul ignore next */ +function isNative(Ctor) { + return typeof Ctor === 'function' && /native code/.test(Ctor.toString()); +} +const hasSymbol = typeof Symbol !== 'undefined' && + isNative(Symbol) && + typeof Reflect !== 'undefined' && + isNative(Reflect.ownKeys); +let _Set; // $flow-disable-line +/* istanbul ignore if */ if (typeof Set !== 'undefined' && isNative(Set)) { + // use native Set when available. + _Set = Set; +} +else { + // a non-standard Set polyfill that only works with primitive keys. + _Set = class Set { + constructor() { + this.set = Object.create(null); + } + has(key) { + return this.set[key] === true; + } + add(key) { + this.set[key] = true; + } + clear() { + this.set = Object.create(null); + } + }; +} +let currentInstance = null; /** - * Check if a string starts with $ or _ + * This is exposed for compatibility with v3 (e.g. some functions in VueUse + * relies on it). Do not use this internally, just use `currentInstance`. + * + * @internal this function needs manual type declaration because it relies + * on previously manually authored types from Vue 2 */ -function isReserved (str) { - var c = (str + '').charCodeAt(0); - return c === 0x24 || c === 0x5F +function getCurrentInstance() { + return currentInstance && { proxy: currentInstance }; } - /** - * Define a property. + * @internal */ -function def (obj, key, val, enumerable) { - Object.defineProperty(obj, key, { - value: val, - enumerable: !!enumerable, - writable: true, - configurable: true - }); +function setCurrentInstance(vm = null) { + if (!vm) + currentInstance && currentInstance._scope.off(); + currentInstance = vm; + vm && vm._scope.on(); } /** - * Parse simple path. - */ -var bailRE = /[^\w.$]/; -function parsePath (path) { - if (bailRE.test(path)) { - return - } - var segments = path.split('.'); - return function (obj) { - for (var i = 0; i < segments.length; i++) { - if (!obj) { return } - obj = obj[segments[i]]; + * @internal + */ +class VNode { + constructor(tag, data, children, text, elm, context, componentOptions, asyncFactory) { + this.tag = tag; + this.data = data; + this.children = children; + this.text = text; + this.elm = elm; + this.ns = undefined; + this.context = context; + this.fnContext = undefined; + this.fnOptions = undefined; + this.fnScopeId = undefined; + this.key = data && data.key; + this.componentOptions = componentOptions; + this.componentInstance = undefined; + this.parent = undefined; + this.raw = false; + this.isStatic = false; + this.isRootInsert = true; + this.isComment = false; + this.isCloned = false; + this.isOnce = false; + this.asyncFactory = asyncFactory; + this.asyncMeta = undefined; + this.isAsyncPlaceholder = false; + } + // DEPRECATED: alias for componentInstance for backwards compat. + /* istanbul ignore next */ + get child() { + return this.componentInstance; } - return obj - } -} - -/* */ - -// can we use __proto__? -var hasProto = '__proto__' in {}; - -// Browser environment sniffing -var inBrowser = typeof window !== 'undefined'; -var UA = inBrowser && window.navigator.userAgent.toLowerCase(); -var isIE = UA && /msie|trident/.test(UA); -var isIE9 = UA && UA.indexOf('msie 9.0') > 0; -var isEdge = UA && UA.indexOf('edge/') > 0; -var isAndroid = UA && UA.indexOf('android') > 0; -var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA); -var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge; - -// Firefox has a "watch" function on Object.prototype... -var nativeWatch = ({}).watch; - -var supportsPassive = false; -if (inBrowser) { - try { - var opts = {}; - Object.defineProperty(opts, 'passive', ({ - get: function get () { - /* istanbul ignore next */ - supportsPassive = true; - } - })); // https://github.com/facebook/flow/issues/285 - window.addEventListener('test-passive', null, opts); - } catch (e) {} } - -// this needs to be lazy-evaled because vue may be required before -// vue-server-renderer can set VUE_ENV -var _isServer; -var isServerRendering = function () { - if (_isServer === undefined) { - /* istanbul ignore if */ - if (!inBrowser && typeof global !== 'undefined') { - // detect presence of vue-server-renderer and avoid - // Webpack shimming the process - _isServer = global['process'].env.VUE_ENV === 'server'; - } else { - _isServer = false; - } - } - return _isServer +const createEmptyVNode = (text = '') => { + const node = new VNode(); + node.text = text; + node.isComment = true; + return node; }; - -// detect devtools -var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__; - -/* istanbul ignore next */ -function isNative (Ctor) { - return typeof Ctor === 'function' && /native code/.test(Ctor.toString()) -} - -var hasSymbol = - typeof Symbol !== 'undefined' && isNative(Symbol) && - typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys); - -var _Set; -/* istanbul ignore if */ // $flow-disable-line -if (typeof Set !== 'undefined' && isNative(Set)) { - // use native Set when available. - _Set = Set; -} else { - // a non-standard Set polyfill that only works with primitive keys. - _Set = (function () { - function Set () { - this.set = Object.create(null); - } - Set.prototype.has = function has (key) { - return this.set[key] === true - }; - Set.prototype.add = function add (key) { - this.set[key] = true; - }; - Set.prototype.clear = function clear () { - this.set = Object.create(null); - }; - - return Set; - }()); +function createTextVNode(val) { + return new VNode(undefined, undefined, undefined, String(val)); } - -/* */ - -var warn = noop; -var tip = noop; -var generateComponentTrace = (noop); // work around flow check -var formatComponentName = (noop); - -if (process.env.NODE_ENV !== 'production') { - var hasConsole = typeof console !== 'undefined'; - var classifyRE = /(?:^|[-_])(\w)/g; - var classify = function (str) { return str - .replace(classifyRE, function (c) { return c.toUpperCase(); }) - .replace(/[-_]/g, ''); }; - - warn = function (msg, vm) { - var trace = vm ? generateComponentTrace(vm) : ''; - - if (config.warnHandler) { - config.warnHandler.call(null, msg, vm, trace); - } else if (hasConsole && (!config.silent)) { - console.error(("[Vue warn]: " + msg + trace)); - } - }; - - tip = function (msg, vm) { - if (hasConsole && (!config.silent)) { - console.warn("[Vue tip]: " + msg + ( - vm ? generateComponentTrace(vm) : '' - )); - } - }; - - formatComponentName = function (vm, includeFile) { - if (vm.$root === vm) { - return '' - } - var options = typeof vm === 'function' && vm.cid != null - ? vm.options - : vm._isVue - ? vm.$options || vm.constructor.options - : vm || {}; - var name = options.name || options._componentTag; - var file = options.__file; - if (!name && file) { - var match = file.match(/([^/\\]+)\.vue$/); - name = match && match[1]; +// optimized shallow clone +// used for static nodes and slot nodes because they may be reused across +// multiple renders, cloning them avoids errors when DOM manipulations rely +// on their elm reference. +function cloneVNode(vnode) { + const cloned = new VNode(vnode.tag, vnode.data, + // #7975 + // clone children array to avoid mutating original in case of cloning + // a child. + vnode.children && vnode.children.slice(), vnode.text, vnode.elm, vnode.context, vnode.componentOptions, vnode.asyncFactory); + cloned.ns = vnode.ns; + cloned.isStatic = vnode.isStatic; + cloned.key = vnode.key; + cloned.isComment = vnode.isComment; + cloned.fnContext = vnode.fnContext; + cloned.fnOptions = vnode.fnOptions; + cloned.fnScopeId = vnode.fnScopeId; + cloned.asyncMeta = vnode.asyncMeta; + cloned.isCloned = true; + return cloned; +} + +let uid$2 = 0; +const pendingCleanupDeps = []; +const cleanupDeps = () => { + for (let i = 0; i < pendingCleanupDeps.length; i++) { + const dep = pendingCleanupDeps[i]; + dep.subs = dep.subs.filter(s => s); + dep._pending = false; + } + pendingCleanupDeps.length = 0; +}; +/** + * A dep is an observable that can have multiple + * directives subscribing to it. + * @internal + */ +class Dep { + constructor() { + // pending subs cleanup + this._pending = false; + this.id = uid$2++; + this.subs = []; + } + addSub(sub) { + this.subs.push(sub); + } + removeSub(sub) { + // #12696 deps with massive amount of subscribers are extremely slow to + // clean up in Chromium + // to workaround this, we unset the sub for now, and clear them on + // next scheduler flush. + this.subs[this.subs.indexOf(sub)] = null; + if (!this._pending) { + this._pending = true; + pendingCleanupDeps.push(this); + } } - - return ( - (name ? ("<" + (classify(name)) + ">") : "") + - (file && includeFile !== false ? (" at " + file) : '') - ) - }; - - var repeat = function (str, n) { - var res = ''; - while (n) { - if (n % 2 === 1) { res += str; } - if (n > 1) { str += str; } - n >>= 1; + depend(info) { + if (Dep.target) { + Dep.target.addDep(this); + if (info && Dep.target.onTrack) { + Dep.target.onTrack(Object.assign({ effect: Dep.target }, info)); + } + } } - return res - }; - - generateComponentTrace = function (vm) { - if (vm._isVue && vm.$parent) { - var tree = []; - var currentRecursiveSequence = 0; - while (vm) { - if (tree.length > 0) { - var last = tree[tree.length - 1]; - if (last.constructor === vm.constructor) { - currentRecursiveSequence++; - vm = vm.$parent; - continue - } else if (currentRecursiveSequence > 0) { - tree[tree.length - 1] = [last, currentRecursiveSequence]; - currentRecursiveSequence = 0; - } + notify(info) { + // stabilize the subscriber list first + const subs = this.subs.filter(s => s); + if (!config.async) { + // subs aren't sorted in scheduler if not running async + // we need to sort them now to make sure they fire in correct + // order + subs.sort((a, b) => a.id - b.id); + } + for (let i = 0, l = subs.length; i < l; i++) { + const sub = subs[i]; + if (info) { + sub.onTrigger && + sub.onTrigger(Object.assign({ effect: subs[i] }, info)); + } + sub.update(); } - tree.push(vm); - vm = vm.$parent; - } - return '\n\nfound in\n\n' + tree - .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm) - ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)") - : formatComponentName(vm))); }) - .join('\n') - } else { - return ("\n\n(found in " + (formatComponentName(vm)) + ")") } - }; } - -/* */ - - -var uid$1 = 0; - -/** - * A dep is an observable that can have multiple - * directives subscribing to it. - */ -var Dep = function Dep () { - this.id = uid$1++; - this.subs = []; -}; - -Dep.prototype.addSub = function addSub (sub) { - this.subs.push(sub); -}; - -Dep.prototype.removeSub = function removeSub (sub) { - remove(this.subs, sub); -}; - -Dep.prototype.depend = function depend () { - if (Dep.target) { - Dep.target.addDep(this); - } -}; - -Dep.prototype.notify = function notify () { - // stabilize the subscriber list first - var subs = this.subs.slice(); - for (var i = 0, l = subs.length; i < l; i++) { - subs[i].update(); - } -}; - -// the current target watcher being evaluated. -// this is globally unique because there could be only one -// watcher being evaluated at any time. +// The current target watcher being evaluated. +// This is globally unique because only one watcher +// can be evaluated at a time. Dep.target = null; -var targetStack = []; - -function pushTarget (_target) { - if (Dep.target) { targetStack.push(Dep.target); } - Dep.target = _target; -} - -function popTarget () { - Dep.target = targetStack.pop(); -} - -/* */ - -var VNode = function VNode ( - tag, - data, - children, - text, - elm, - context, - componentOptions, - asyncFactory -) { - this.tag = tag; - this.data = data; - this.children = children; - this.text = text; - this.elm = elm; - this.ns = undefined; - this.context = context; - this.functionalContext = undefined; - this.functionalOptions = undefined; - this.functionalScopeId = undefined; - this.key = data && data.key; - this.componentOptions = componentOptions; - this.componentInstance = undefined; - this.parent = undefined; - this.raw = false; - this.isStatic = false; - this.isRootInsert = true; - this.isComment = false; - this.isCloned = false; - this.isOnce = false; - this.asyncFactory = asyncFactory; - this.asyncMeta = undefined; - this.isAsyncPlaceholder = false; -}; - -var prototypeAccessors = { child: { configurable: true } }; - -// DEPRECATED: alias for componentInstance for backwards compat. -/* istanbul ignore next */ -prototypeAccessors.child.get = function () { - return this.componentInstance -}; - -Object.defineProperties( VNode.prototype, prototypeAccessors ); - -var createEmptyVNode = function (text) { - if ( text === void 0 ) text = ''; - - var node = new VNode(); - node.text = text; - node.isComment = true; - return node -}; - -function createTextVNode (val) { - return new VNode(undefined, undefined, undefined, String(val)) -} - -// optimized shallow clone -// used for static nodes and slot nodes because they may be reused across -// multiple renders, cloning them avoids errors when DOM manipulations rely -// on their elm reference. -function cloneVNode (vnode, deep) { - var cloned = new VNode( - vnode.tag, - vnode.data, - vnode.children, - vnode.text, - vnode.elm, - vnode.context, - vnode.componentOptions, - vnode.asyncFactory - ); - cloned.ns = vnode.ns; - cloned.isStatic = vnode.isStatic; - cloned.key = vnode.key; - cloned.isComment = vnode.isComment; - cloned.isCloned = true; - if (deep && vnode.children) { - cloned.children = cloneVNodes(vnode.children); - } - return cloned +const targetStack = []; +function pushTarget(target) { + targetStack.push(target); + Dep.target = target; } - -function cloneVNodes (vnodes, deep) { - var len = vnodes.length; - var res = new Array(len); - for (var i = 0; i < len; i++) { - res[i] = cloneVNode(vnodes[i], deep); - } - return res +function popTarget() { + targetStack.pop(); + Dep.target = targetStack[targetStack.length - 1]; } /* * not type checking this file because flow doesn't play well with * dynamically accessing methods on Array prototype */ - -var arrayProto = Array.prototype; -var arrayMethods = Object.create(arrayProto);[ - 'push', - 'pop', - 'shift', - 'unshift', - 'splice', - 'sort', - 'reverse' -] -.forEach(function (method) { - // cache original method - var original = arrayProto[method]; - def(arrayMethods, method, function mutator () { - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - - var result = original.apply(this, args); - var ob = this.__ob__; - var inserted; - switch (method) { - case 'push': - case 'unshift': - inserted = args; - break - case 'splice': - inserted = args.slice(2); - break - } - if (inserted) { ob.observeArray(inserted); } - // notify change - ob.dep.notify(); - return result - }); +const arrayProto = Array.prototype; +const arrayMethods = Object.create(arrayProto); +const methodsToPatch = [ + 'push', + 'pop', + 'shift', + 'unshift', + 'splice', + 'sort', + 'reverse' +]; +/** + * Intercept mutating methods and emit events + */ +methodsToPatch.forEach(function (method) { + // cache original method + const original = arrayProto[method]; + def(arrayMethods, method, function mutator(...args) { + const result = original.apply(this, args); + const ob = this.__ob__; + let inserted; + switch (method) { + case 'push': + case 'unshift': + inserted = args; + break; + case 'splice': + inserted = args.slice(2); + break; + } + if (inserted) + ob.observeArray(inserted); + // notify change + { + ob.dep.notify({ + type: "array mutation" /* TriggerOpTypes.ARRAY_MUTATION */, + target: this, + key: method + }); + } + return result; + }); }); -/* */ - -var arrayKeys = Object.getOwnPropertyNames(arrayMethods); - +const arrayKeys = Object.getOwnPropertyNames(arrayMethods); +const NO_INITIAL_VALUE = {}; /** - * By default, when a reactive property is set, the new value is - * also converted to become reactive. However when passing down props, - * we don't want to force conversion because the value may be a nested value - * under a frozen data structure. Converting it would defeat the optimization. + * In some cases we may want to disable observation inside a component's + * update computation. */ -var observerState = { - shouldConvert: true +let shouldObserve = true; +function toggleObserving(value) { + shouldObserve = value; +} +// ssr mock dep +const mockDep = { + notify: noop, + depend: noop, + addSub: noop, + removeSub: noop }; - /** - * Observer class that are attached to each observed - * object. Once attached, the observer converts target + * Observer class that is attached to each observed + * object. Once attached, the observer converts the target * object's property keys into getter/setters that - * collect dependencies and dispatches updates. - */ -var Observer = function Observer (value) { - this.value = value; - this.dep = new Dep(); - this.vmCount = 0; - def(value, '__ob__', this); - if (Array.isArray(value)) { - var augment = hasProto - ? protoAugment - : copyAugment; - augment(value, arrayMethods, arrayKeys); - this.observeArray(value); - } else { - this.walk(value); - } -}; - -/** - * Walk through each property and convert them into - * getter/setters. This method should only be called when - * value type is Object. - */ -Observer.prototype.walk = function walk (obj) { - var keys = Object.keys(obj); - for (var i = 0; i < keys.length; i++) { - defineReactive(obj, keys[i], obj[keys[i]]); - } -}; - -/** - * Observe a list of Array items. - */ -Observer.prototype.observeArray = function observeArray (items) { - for (var i = 0, l = items.length; i < l; i++) { - observe(items[i]); - } -}; - -// helpers - -/** - * Augment an target Object or Array by intercepting - * the prototype chain using __proto__ - */ -function protoAugment (target, src, keys) { - /* eslint-disable no-proto */ - target.__proto__ = src; - /* eslint-enable no-proto */ -} - -/** - * Augment an target Object or Array by defining - * hidden properties. - */ -/* istanbul ignore next */ -function copyAugment (target, src, keys) { - for (var i = 0, l = keys.length; i < l; i++) { - var key = keys[i]; - def(target, key, src[key]); - } + * collect dependencies and dispatch updates. + */ +class Observer { + constructor(value, shallow = false, mock = false) { + this.value = value; + this.shallow = shallow; + this.mock = mock; + // this.value = value + this.dep = mock ? mockDep : new Dep(); + this.vmCount = 0; + def(value, '__ob__', this); + if (isArray(value)) { + if (!mock) { + if (hasProto) { + value.__proto__ = arrayMethods; + /* eslint-enable no-proto */ + } + else { + for (let i = 0, l = arrayKeys.length; i < l; i++) { + const key = arrayKeys[i]; + def(value, key, arrayMethods[key]); + } + } + } + if (!shallow) { + this.observeArray(value); + } + } + else { + /** + * Walk through all properties and convert them into + * getter/setters. This method should only be called when + * value type is Object. + */ + const keys = Object.keys(value); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + defineReactive(value, key, NO_INITIAL_VALUE, undefined, shallow, mock); + } + } + } + /** + * Observe a list of Array items. + */ + observeArray(value) { + for (let i = 0, l = value.length; i < l; i++) { + observe(value[i], false, this.mock); + } + } } - +// helpers /** * Attempt to create an observer instance for a value, * returns the new observer if successfully observed, * or the existing observer if the value already has one. */ -function observe (value, asRootData) { - if (!isObject(value) || value instanceof VNode) { - return - } - var ob; - if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) { - ob = value.__ob__; - } else if ( - observerState.shouldConvert && - !isServerRendering() && - (Array.isArray(value) || isPlainObject(value)) && - Object.isExtensible(value) && - !value._isVue - ) { - ob = new Observer(value); - } - if (asRootData && ob) { - ob.vmCount++; - } - return ob +function observe(value, shallow, ssrMockReactivity) { + if (value && hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) { + return value.__ob__; + } + if (shouldObserve && + (ssrMockReactivity || !isServerRendering()) && + (isArray(value) || isPlainObject(value)) && + Object.isExtensible(value) && + !value.__v_skip /* ReactiveFlags.SKIP */ && + !isRef(value) && + !(value instanceof VNode)) { + return new Observer(value, shallow, ssrMockReactivity); + } } - /** * Define a reactive property on an Object. */ -function defineReactive ( - obj, - key, - val, - customSetter, - shallow -) { - var dep = new Dep(); - - var property = Object.getOwnPropertyDescriptor(obj, key); - if (property && property.configurable === false) { - return - } - - // cater for pre-defined getter/setters - var getter = property && property.get; - var setter = property && property.set; - - var childOb = !shallow && observe(val); - Object.defineProperty(obj, key, { - enumerable: true, - configurable: true, - get: function reactiveGetter () { - var value = getter ? getter.call(obj) : val; - if (Dep.target) { - dep.depend(); - if (childOb) { - childOb.dep.depend(); - if (Array.isArray(value)) { - dependArray(value); - } - } - } - return value - }, - set: function reactiveSetter (newVal) { - var value = getter ? getter.call(obj) : val; - /* eslint-disable no-self-compare */ - if (newVal === value || (newVal !== newVal && value !== value)) { - return - } - /* eslint-enable no-self-compare */ - if (process.env.NODE_ENV !== 'production' && customSetter) { - customSetter(); - } - if (setter) { - setter.call(obj, newVal); - } else { - val = newVal; - } - childOb = !shallow && observe(newVal); - dep.notify(); +function defineReactive(obj, key, val, customSetter, shallow, mock, observeEvenIfShallow = false) { + const dep = new Dep(); + const property = Object.getOwnPropertyDescriptor(obj, key); + if (property && property.configurable === false) { + return; + } + // cater for pre-defined getter/setters + const getter = property && property.get; + const setter = property && property.set; + if ((!getter || setter) && + (val === NO_INITIAL_VALUE || arguments.length === 2)) { + val = obj[key]; + } + let childOb = shallow ? val && val.__ob__ : observe(val, false, mock); + Object.defineProperty(obj, key, { + enumerable: true, + configurable: true, + get: function reactiveGetter() { + const value = getter ? getter.call(obj) : val; + if (Dep.target) { + { + dep.depend({ + target: obj, + type: "get" /* TrackOpTypes.GET */, + key + }); + } + if (childOb) { + childOb.dep.depend(); + if (isArray(value)) { + dependArray(value); + } + } + } + return isRef(value) && !shallow ? value.value : value; + }, + set: function reactiveSetter(newVal) { + const value = getter ? getter.call(obj) : val; + if (!hasChanged(value, newVal)) { + return; + } + if (customSetter) { + customSetter(); + } + if (setter) { + setter.call(obj, newVal); + } + else if (getter) { + // #7981: for accessor properties without setter + return; + } + else if (!shallow && isRef(value) && !isRef(newVal)) { + value.value = newVal; + return; + } + else { + val = newVal; + } + childOb = shallow ? newVal && newVal.__ob__ : observe(newVal, false, mock); + { + dep.notify({ + type: "set" /* TriggerOpTypes.SET */, + target: obj, + key, + newValue: newVal, + oldValue: value + }); + } + } + }); + return dep; +} +function set(target, key, val) { + if ((isUndef(target) || isPrimitive(target))) { + warn(`Cannot set reactive property on undefined, null, or primitive value: ${target}`); + } + if (isReadonly(target)) { + warn(`Set operation on key "${key}" failed: target is readonly.`); + return; + } + const ob = target.__ob__; + if (isArray(target) && isValidArrayIndex(key)) { + target.length = Math.max(target.length, key); + target.splice(key, 1, val); + // when mocking for SSR, array methods are not hijacked + if (ob && !ob.shallow && ob.mock) { + observe(val, false, true); + } + return val; + } + if (key in target && !(key in Object.prototype)) { + target[key] = val; + return val; + } + if (target._isVue || (ob && ob.vmCount)) { + warn('Avoid adding reactive properties to a Vue instance or its root $data ' + + 'at runtime - declare it upfront in the data option.'); + return val; + } + if (!ob) { + target[key] = val; + return val; + } + defineReactive(ob.value, key, val, undefined, ob.shallow, ob.mock); + { + ob.dep.notify({ + type: "add" /* TriggerOpTypes.ADD */, + target: target, + key, + newValue: val, + oldValue: undefined + }); + } + return val; +} +function del(target, key) { + if ((isUndef(target) || isPrimitive(target))) { + warn(`Cannot delete reactive property on undefined, null, or primitive value: ${target}`); + } + if (isArray(target) && isValidArrayIndex(key)) { + target.splice(key, 1); + return; + } + const ob = target.__ob__; + if (target._isVue || (ob && ob.vmCount)) { + warn('Avoid deleting properties on a Vue instance or its root $data ' + + '- just set it to null.'); + return; + } + if (isReadonly(target)) { + warn(`Delete operation on key "${key}" failed: target is readonly.`); + return; + } + if (!hasOwn(target, key)) { + return; + } + delete target[key]; + if (!ob) { + return; + } + { + ob.dep.notify({ + type: "delete" /* TriggerOpTypes.DELETE */, + target: target, + key + }); } - }); -} - -/** - * Set a property on an object. Adds the new property and - * triggers change notification if the property doesn't - * already exist. - */ -function set (target, key, val) { - if (Array.isArray(target) && isValidArrayIndex(key)) { - target.length = Math.max(target.length, key); - target.splice(key, 1, val); - return val - } - if (hasOwn(target, key)) { - target[key] = val; - return val - } - var ob = (target).__ob__; - if (target._isVue || (ob && ob.vmCount)) { - process.env.NODE_ENV !== 'production' && warn( - 'Avoid adding reactive properties to a Vue instance or its root $data ' + - 'at runtime - declare it upfront in the data option.' - ); - return val - } - if (!ob) { - target[key] = val; - return val - } - defineReactive(ob.value, key, val); - ob.dep.notify(); - return val -} - -/** - * Delete a property and trigger change if necessary. - */ -function del (target, key) { - if (Array.isArray(target) && isValidArrayIndex(key)) { - target.splice(key, 1); - return - } - var ob = (target).__ob__; - if (target._isVue || (ob && ob.vmCount)) { - process.env.NODE_ENV !== 'production' && warn( - 'Avoid deleting properties on a Vue instance or its root $data ' + - '- just set it to null.' - ); - return - } - if (!hasOwn(target, key)) { - return - } - delete target[key]; - if (!ob) { - return - } - ob.dep.notify(); } - /** * Collect dependencies on array elements when the array is touched, since * we cannot intercept array element access like property getters. */ -function dependArray (value) { - for (var e = (void 0), i = 0, l = value.length; i < l; i++) { - e = value[i]; - e && e.__ob__ && e.__ob__.dep.depend(); - if (Array.isArray(e)) { - dependArray(e); +function dependArray(value) { + for (let e, i = 0, l = value.length; i < l; i++) { + e = value[i]; + if (e && e.__ob__) { + e.__ob__.dep.depend(); + } + if (isArray(e)) { + dependArray(e); + } } - } } -/* */ - +function reactive(target) { + makeReactive(target, false); + return target; +} /** - * Option overwriting strategies are functions that handle - * how to merge a parent option value and a child option - * value into the final value. + * Return a shallowly-reactive copy of the original object, where only the root + * level properties are reactive. It also does not auto-unwrap refs (even at the + * root level). + */ +function shallowReactive(target) { + makeReactive(target, true); + def(target, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, true); + return target; +} +function makeReactive(target, shallow) { + // if trying to observe a readonly proxy, return the readonly version. + if (!isReadonly(target)) { + { + if (isArray(target)) { + warn(`Avoid using Array as root value for ${shallow ? `shallowReactive()` : `reactive()`} as it cannot be tracked in watch() or watchEffect(). Use ${shallow ? `shallowRef()` : `ref()`} instead. This is a Vue-2-only limitation.`); + } + const existingOb = target && target.__ob__; + if (existingOb && existingOb.shallow !== shallow) { + warn(`Target is already a ${existingOb.shallow ? `` : `non-`}shallow reactive object, and cannot be converted to ${shallow ? `` : `non-`}shallow.`); + } + } + const ob = observe(target, shallow, isServerRendering() /* ssr mock reactivity */); + if (!ob) { + if (target == null || isPrimitive(target)) { + warn(`value cannot be made reactive: ${String(target)}`); + } + if (isCollectionType(target)) { + warn(`Vue 2 does not support reactive collection types such as Map or Set.`); + } + } + } +} +function isReactive(value) { + if (isReadonly(value)) { + return isReactive(value["__v_raw" /* ReactiveFlags.RAW */]); + } + return !!(value && value.__ob__); +} +function isShallow(value) { + return !!(value && value.__v_isShallow); +} +function isReadonly(value) { + return !!(value && value.__v_isReadonly); +} +function isProxy(value) { + return isReactive(value) || isReadonly(value); +} +function toRaw(observed) { + const raw = observed && observed["__v_raw" /* ReactiveFlags.RAW */]; + return raw ? toRaw(raw) : observed; +} +function markRaw(value) { + // non-extensible objects won't be observed anyway + if (Object.isExtensible(value)) { + def(value, "__v_skip" /* ReactiveFlags.SKIP */, true); + } + return value; +} +/** + * @internal */ -var strats = config.optionMergeStrategies; +function isCollectionType(value) { + const type = toRawType(value); + return (type === 'Map' || type === 'WeakMap' || type === 'Set' || type === 'WeakSet'); +} /** - * Options with restrictions + * @internal + */ +const RefFlag = `__v_isRef`; +function isRef(r) { + return !!(r && r.__v_isRef === true); +} +function ref$1(value) { + return createRef(value, false); +} +function shallowRef(value) { + return createRef(value, true); +} +function createRef(rawValue, shallow) { + if (isRef(rawValue)) { + return rawValue; + } + const ref = {}; + def(ref, RefFlag, true); + def(ref, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, shallow); + def(ref, 'dep', defineReactive(ref, 'value', rawValue, null, shallow, isServerRendering())); + return ref; +} +function triggerRef(ref) { + if (!ref.dep) { + warn(`received object is not a triggerable ref.`); + } + { + ref.dep && + ref.dep.notify({ + type: "set" /* TriggerOpTypes.SET */, + target: ref, + key: 'value' + }); + } +} +function unref(ref) { + return isRef(ref) ? ref.value : ref; +} +function proxyRefs(objectWithRefs) { + if (isReactive(objectWithRefs)) { + return objectWithRefs; + } + const proxy = {}; + const keys = Object.keys(objectWithRefs); + for (let i = 0; i < keys.length; i++) { + proxyWithRefUnwrap(proxy, objectWithRefs, keys[i]); + } + return proxy; +} +function proxyWithRefUnwrap(target, source, key) { + Object.defineProperty(target, key, { + enumerable: true, + configurable: true, + get: () => { + const val = source[key]; + if (isRef(val)) { + return val.value; + } + else { + const ob = val && val.__ob__; + if (ob) + ob.dep.depend(); + return val; + } + }, + set: value => { + const oldValue = source[key]; + if (isRef(oldValue) && !isRef(value)) { + oldValue.value = value; + } + else { + source[key] = value; + } + } + }); +} +function customRef(factory) { + const dep = new Dep(); + const { get, set } = factory(() => { + { + dep.depend({ + target: ref, + type: "get" /* TrackOpTypes.GET */, + key: 'value' + }); + } + }, () => { + { + dep.notify({ + target: ref, + type: "set" /* TriggerOpTypes.SET */, + key: 'value' + }); + } + }); + const ref = { + get value() { + return get(); + }, + set value(newVal) { + set(newVal); + } + }; + def(ref, RefFlag, true); + return ref; +} +function toRefs(object) { + if (!isReactive(object)) { + warn(`toRefs() expects a reactive object but received a plain one.`); + } + const ret = isArray(object) ? new Array(object.length) : {}; + for (const key in object) { + ret[key] = toRef(object, key); + } + return ret; +} +function toRef(object, key, defaultValue) { + const val = object[key]; + if (isRef(val)) { + return val; + } + const ref = { + get value() { + const val = object[key]; + return val === undefined ? defaultValue : val; + }, + set value(newVal) { + object[key] = newVal; + } + }; + def(ref, RefFlag, true); + return ref; +} + +const rawToReadonlyFlag = `__v_rawToReadonly`; +const rawToShallowReadonlyFlag = `__v_rawToShallowReadonly`; +function readonly(target) { + return createReadonly(target, false); +} +function createReadonly(target, shallow) { + if (!isPlainObject(target)) { + { + if (isArray(target)) { + warn(`Vue 2 does not support readonly arrays.`); + } + else if (isCollectionType(target)) { + warn(`Vue 2 does not support readonly collection types such as Map or Set.`); + } + else { + warn(`value cannot be made readonly: ${typeof target}`); + } + } + return target; + } + if (!Object.isExtensible(target)) { + warn(`Vue 2 does not support creating readonly proxy for non-extensible object.`); + } + // already a readonly object + if (isReadonly(target)) { + return target; + } + // already has a readonly proxy + const existingFlag = shallow ? rawToShallowReadonlyFlag : rawToReadonlyFlag; + const existingProxy = target[existingFlag]; + if (existingProxy) { + return existingProxy; + } + const proxy = Object.create(Object.getPrototypeOf(target)); + def(target, existingFlag, proxy); + def(proxy, "__v_isReadonly" /* ReactiveFlags.IS_READONLY */, true); + def(proxy, "__v_raw" /* ReactiveFlags.RAW */, target); + if (isRef(target)) { + def(proxy, RefFlag, true); + } + if (shallow || isShallow(target)) { + def(proxy, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, true); + } + const keys = Object.keys(target); + for (let i = 0; i < keys.length; i++) { + defineReadonlyProperty(proxy, target, keys[i], shallow); + } + return proxy; +} +function defineReadonlyProperty(proxy, target, key, shallow) { + Object.defineProperty(proxy, key, { + enumerable: true, + configurable: true, + get() { + const val = target[key]; + return shallow || !isPlainObject(val) ? val : readonly(val); + }, + set() { + warn(`Set operation on key "${key}" failed: target is readonly.`); + } + }); +} +/** + * Returns a reactive-copy of the original object, where only the root level + * properties are readonly, and does NOT unwrap refs nor recursively convert + * returned properties. + * This is used for creating the props proxy object for stateful components. + */ +function shallowReadonly(target) { + return createReadonly(target, true); +} + +function computed(getterOrOptions, debugOptions) { + let getter; + let setter; + const onlyGetter = isFunction(getterOrOptions); + if (onlyGetter) { + getter = getterOrOptions; + setter = () => { + warn('Write operation failed: computed value is readonly'); + } + ; + } + else { + getter = getterOrOptions.get; + setter = getterOrOptions.set; + } + const watcher = isServerRendering() + ? null + : new Watcher(currentInstance, getter, noop, { lazy: true }); + if (watcher && debugOptions) { + watcher.onTrack = debugOptions.onTrack; + watcher.onTrigger = debugOptions.onTrigger; + } + const ref = { + // some libs rely on the presence effect for checking computed refs + // from normal refs, but the implementation doesn't matter + effect: watcher, + get value() { + if (watcher) { + if (watcher.dirty) { + watcher.evaluate(); + } + if (Dep.target) { + if (Dep.target.onTrack) { + Dep.target.onTrack({ + effect: Dep.target, + target: ref, + type: "get" /* TrackOpTypes.GET */, + key: 'value' + }); + } + watcher.depend(); + } + return watcher.value; + } + else { + return getter(); + } + }, + set value(newVal) { + setter(newVal); + } + }; + def(ref, RefFlag, true); + def(ref, "__v_isReadonly" /* ReactiveFlags.IS_READONLY */, onlyGetter); + return ref; +} + +const WATCHER = `watcher`; +const WATCHER_CB = `${WATCHER} callback`; +const WATCHER_GETTER = `${WATCHER} getter`; +const WATCHER_CLEANUP = `${WATCHER} cleanup`; +// Simple effect. +function watchEffect(effect, options) { + return doWatch(effect, null, options); +} +function watchPostEffect(effect, options) { + return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'post' }) )); +} +function watchSyncEffect(effect, options) { + return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'sync' }) )); +} +// initial value for watchers to trigger on undefined initial values +const INITIAL_WATCHER_VALUE = {}; +// implementation +function watch(source, cb, options) { + if (typeof cb !== 'function') { + warn(`\`watch(fn, options?)\` signature has been moved to a separate API. ` + + `Use \`watchEffect(fn, options?)\` instead. \`watch\` now only ` + + `supports \`watch(source, cb, options?) signature.`); + } + return doWatch(source, cb, options); +} +function doWatch(source, cb, { immediate, deep, flush = 'pre', onTrack, onTrigger } = emptyObject) { + if (!cb) { + if (immediate !== undefined) { + warn(`watch() "immediate" option is only respected when using the ` + + `watch(source, callback, options?) signature.`); + } + if (deep !== undefined) { + warn(`watch() "deep" option is only respected when using the ` + + `watch(source, callback, options?) signature.`); + } + } + const warnInvalidSource = (s) => { + warn(`Invalid watch source: ${s}. A watch source can only be a getter/effect ` + + `function, a ref, a reactive object, or an array of these types.`); + }; + const instance = currentInstance; + const call = (fn, type, args = null) => { + const res = invokeWithErrorHandling(fn, null, args, instance, type); + if (deep && res && res.__ob__) + res.__ob__.dep.depend(); + return res; + }; + let getter; + let forceTrigger = false; + let isMultiSource = false; + if (isRef(source)) { + getter = () => source.value; + forceTrigger = isShallow(source); + } + else if (isReactive(source)) { + getter = () => { + source.__ob__.dep.depend(); + return source; + }; + deep = true; + } + else if (isArray(source)) { + isMultiSource = true; + forceTrigger = source.some(s => isReactive(s) || isShallow(s)); + getter = () => source.map(s => { + if (isRef(s)) { + return s.value; + } + else if (isReactive(s)) { + s.__ob__.dep.depend(); + return traverse(s); + } + else if (isFunction(s)) { + return call(s, WATCHER_GETTER); + } + else { + warnInvalidSource(s); + } + }); + } + else if (isFunction(source)) { + if (cb) { + // getter with cb + getter = () => call(source, WATCHER_GETTER); + } + else { + // no cb -> simple effect + getter = () => { + if (instance && instance._isDestroyed) { + return; + } + if (cleanup) { + cleanup(); + } + return call(source, WATCHER, [onCleanup]); + }; + } + } + else { + getter = noop; + warnInvalidSource(source); + } + if (cb && deep) { + const baseGetter = getter; + getter = () => traverse(baseGetter()); + } + let cleanup; + let onCleanup = (fn) => { + cleanup = watcher.onStop = () => { + call(fn, WATCHER_CLEANUP); + }; + }; + // in SSR there is no need to setup an actual effect, and it should be noop + // unless it's eager + if (isServerRendering()) { + // we will also not call the invalidate callback (+ runner is not set up) + onCleanup = noop; + if (!cb) { + getter(); + } + else if (immediate) { + call(cb, WATCHER_CB, [ + getter(), + isMultiSource ? [] : undefined, + onCleanup + ]); + } + return noop; + } + const watcher = new Watcher(currentInstance, getter, noop, { + lazy: true + }); + watcher.noRecurse = !cb; + let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE; + // overwrite default run + watcher.run = () => { + if (!watcher.active) { + return; + } + if (cb) { + // watch(source, cb) + const newValue = watcher.get(); + if (deep || + forceTrigger || + (isMultiSource + ? newValue.some((v, i) => hasChanged(v, oldValue[i])) + : hasChanged(newValue, oldValue))) { + // cleanup before running cb again + if (cleanup) { + cleanup(); + } + call(cb, WATCHER_CB, [ + newValue, + // pass undefined as the old value when it's changed for the first time + oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue, + onCleanup + ]); + oldValue = newValue; + } + } + else { + // watchEffect + watcher.get(); + } + }; + if (flush === 'sync') { + watcher.update = watcher.run; + } + else if (flush === 'post') { + watcher.post = true; + watcher.update = () => queueWatcher(watcher); + } + else { + // pre + watcher.update = () => { + if (instance && instance === currentInstance && !instance._isMounted) { + // pre-watcher triggered before + const buffer = instance._preWatchers || (instance._preWatchers = []); + if (buffer.indexOf(watcher) < 0) + buffer.push(watcher); + } + else { + queueWatcher(watcher); + } + }; + } + { + watcher.onTrack = onTrack; + watcher.onTrigger = onTrigger; + } + // initial run + if (cb) { + if (immediate) { + watcher.run(); + } + else { + oldValue = watcher.get(); + } + } + else if (flush === 'post' && instance) { + instance.$once('hook:mounted', () => watcher.get()); + } + else { + watcher.get(); + } + return () => { + watcher.teardown(); + }; +} + +let activeEffectScope; +class EffectScope { + constructor(detached = false) { + this.detached = detached; + /** + * @internal + */ + this.active = true; + /** + * @internal + */ + this.effects = []; + /** + * @internal + */ + this.cleanups = []; + this.parent = activeEffectScope; + if (!detached && activeEffectScope) { + this.index = + (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1; + } + } + run(fn) { + if (this.active) { + const currentEffectScope = activeEffectScope; + try { + activeEffectScope = this; + return fn(); + } + finally { + activeEffectScope = currentEffectScope; + } + } + else { + warn(`cannot run an inactive effect scope.`); + } + } + /** + * This should only be called on non-detached scopes + * @internal + */ + on() { + activeEffectScope = this; + } + /** + * This should only be called on non-detached scopes + * @internal + */ + off() { + activeEffectScope = this.parent; + } + stop(fromParent) { + if (this.active) { + let i, l; + for (i = 0, l = this.effects.length; i < l; i++) { + this.effects[i].teardown(); + } + for (i = 0, l = this.cleanups.length; i < l; i++) { + this.cleanups[i](); + } + if (this.scopes) { + for (i = 0, l = this.scopes.length; i < l; i++) { + this.scopes[i].stop(true); + } + } + // nested scope, dereference from parent to avoid memory leaks + if (!this.detached && this.parent && !fromParent) { + // optimized O(1) removal + const last = this.parent.scopes.pop(); + if (last && last !== this) { + this.parent.scopes[this.index] = last; + last.index = this.index; + } + } + this.parent = undefined; + this.active = false; + } + } +} +function effectScope(detached) { + return new EffectScope(detached); +} +/** + * @internal */ -if (process.env.NODE_ENV !== 'production') { - strats.el = strats.propsData = function (parent, child, vm, key) { - if (!vm) { - warn( - "option \"" + key + "\" can only be used during instance " + - 'creation with the `new` keyword.' - ); +function recordEffectScope(effect, scope = activeEffectScope) { + if (scope && scope.active) { + scope.effects.push(effect); + } +} +function getCurrentScope() { + return activeEffectScope; +} +function onScopeDispose(fn) { + if (activeEffectScope) { + activeEffectScope.cleanups.push(fn); + } + else { + warn(`onScopeDispose() is called when there is no active effect scope` + + ` to be associated with.`); + } +} + +function provide(key, value) { + if (!currentInstance) { + { + warn(`provide() can only be used inside setup().`); + } + } + else { + // TS doesn't allow symbol as index type + resolveProvided(currentInstance)[key] = value; + } +} +function resolveProvided(vm) { + // by default an instance inherits its parent's provides object + // but when it needs to provide values of its own, it creates its + // own provides object using parent provides object as prototype. + // this way in `inject` we can simply look up injections from direct + // parent and let the prototype chain do the work. + const existing = vm._provided; + const parentProvides = vm.$parent && vm.$parent._provided; + if (parentProvides === existing) { + return (vm._provided = Object.create(parentProvides)); + } + else { + return existing; + } +} +function inject(key, defaultValue, treatDefaultAsFactory = false) { + // fallback to `currentRenderingInstance` so that this can be called in + // a functional component + const instance = currentInstance; + if (instance) { + // #2400 + // to support `app.use` plugins, + // fallback to appContext's `provides` if the instance is at root + const provides = instance.$parent && instance.$parent._provided; + if (provides && key in provides) { + // TS doesn't allow symbol as index type + return provides[key]; + } + else if (arguments.length > 1) { + return treatDefaultAsFactory && isFunction(defaultValue) + ? defaultValue.call(instance) + : defaultValue; + } + else { + warn(`injection "${String(key)}" not found.`); + } + } + else { + warn(`inject() can only be used inside setup() or functional components.`); + } +} + +const normalizeEvent = cached((name) => { + const passive = name.charAt(0) === '&'; + name = passive ? name.slice(1) : name; + const once = name.charAt(0) === '~'; // Prefixed last, checked first + name = once ? name.slice(1) : name; + const capture = name.charAt(0) === '!'; + name = capture ? name.slice(1) : name; + return { + name, + once, + capture, + passive + }; +}); +function createFnInvoker(fns, vm) { + function invoker() { + const fns = invoker.fns; + if (isArray(fns)) { + const cloned = fns.slice(); + for (let i = 0; i < cloned.length; i++) { + invokeWithErrorHandling(cloned[i], null, arguments, vm, `v-on handler`); + } + } + else { + // return handler return value for single handlers + return invokeWithErrorHandling(fns, null, arguments, vm, `v-on handler`); + } + } + invoker.fns = fns; + return invoker; +} +function updateListeners(on, oldOn, add, remove, createOnceHandler, vm) { + let name, cur, old, event; + for (name in on) { + cur = on[name]; + old = oldOn[name]; + event = normalizeEvent(name); + if (isUndef(cur)) { + warn(`Invalid handler for event "${event.name}": got ` + String(cur), vm); + } + else if (isUndef(old)) { + if (isUndef(cur.fns)) { + cur = on[name] = createFnInvoker(cur, vm); + } + if (isTrue(event.once)) { + cur = on[name] = createOnceHandler(event.name, cur, event.capture); + } + add(event.name, cur, event.capture, event.passive, event.params); + } + else if (cur !== old) { + old.fns = cur; + on[name] = old; + } + } + for (name in oldOn) { + if (isUndef(on[name])) { + event = normalizeEvent(name); + remove(event.name, oldOn[name], event.capture); + } + } +} + +function mergeVNodeHook(def, hookKey, hook) { + if (def instanceof VNode) { + def = def.data.hook || (def.data.hook = {}); + } + let invoker; + const oldHook = def[hookKey]; + function wrappedHook() { + hook.apply(this, arguments); + // important: remove merged hook to ensure it's called only once + // and prevent memory leak + remove$2(invoker.fns, wrappedHook); + } + if (isUndef(oldHook)) { + // no existing hook + invoker = createFnInvoker([wrappedHook]); + } + else { + /* istanbul ignore if */ + if (isDef(oldHook.fns) && isTrue(oldHook.merged)) { + // already a merged invoker + invoker = oldHook; + invoker.fns.push(wrappedHook); + } + else { + // existing plain hook + invoker = createFnInvoker([oldHook, wrappedHook]); + } + } + invoker.merged = true; + def[hookKey] = invoker; +} + +function extractPropsFromVNodeData(data, Ctor, tag) { + // we are only extracting raw values here. + // validation and default values are handled in the child + // component itself. + const propOptions = Ctor.options.props; + if (isUndef(propOptions)) { + return; + } + const res = {}; + const { attrs, props } = data; + if (isDef(attrs) || isDef(props)) { + for (const key in propOptions) { + const altKey = hyphenate(key); + { + const keyInLowerCase = key.toLowerCase(); + if (key !== keyInLowerCase && attrs && hasOwn(attrs, keyInLowerCase)) { + tip(`Prop "${keyInLowerCase}" is passed to component ` + + `${formatComponentName( + // @ts-expect-error tag is string + tag || Ctor)}, but the declared prop name is` + + ` "${key}". ` + + `Note that HTML attributes are case-insensitive and camelCased ` + + `props need to use their kebab-case equivalents when using in-DOM ` + + `templates. You should probably use "${altKey}" instead of "${key}".`); + } + } + checkProp(res, props, key, altKey, true) || + checkProp(res, attrs, key, altKey, false); + } + } + return res; +} +function checkProp(res, hash, key, altKey, preserve) { + if (isDef(hash)) { + if (hasOwn(hash, key)) { + res[key] = hash[key]; + if (!preserve) { + delete hash[key]; + } + return true; + } + else if (hasOwn(hash, altKey)) { + res[key] = hash[altKey]; + if (!preserve) { + delete hash[altKey]; + } + return true; + } + } + return false; +} + +// The template compiler attempts to minimize the need for normalization by +// statically analyzing the template at compile time. +// +// For plain HTML markup, normalization can be completely skipped because the +// generated render function is guaranteed to return Array. There are +// two cases where extra normalization is needed: +// 1. When the children contains components - because a functional component +// may return an Array instead of a single root. In this case, just a simple +// normalization is needed - if any child is an Array, we flatten the whole +// thing with Array.prototype.concat. It is guaranteed to be only 1-level deep +// because functional components already normalize their own children. +function simpleNormalizeChildren(children) { + for (let i = 0; i < children.length; i++) { + if (isArray(children[i])) { + return Array.prototype.concat.apply([], children); + } + } + return children; +} +// 2. When the children contains constructs that always generated nested Arrays, +// e.g.