forked from TimOetting/kirby-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
1 lines (1 loc) · 48.2 KB
/
index.js
1
(function () {function h(t){return(h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function j(t,e){return k(t)||l(t,e)||m()}function m(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function l(t,e){var n=[],i=!0,o=!1,r=void 0;try{for(var s,a=t[Symbol.iterator]();!(i=(s=a.next()).done)&&(n.push(s.value),!e||n.length!==e);i=!0);}catch(l){o=!0,r=l}finally{try{i||null==a.return||a.return()}finally{if(o)throw r}}return n}function k(t){if(Array.isArray(t))return t}var c={data:function(){return{previewFrameWindow:{},previewFrameDocument:{},previewHeight:0}},props:{markup:{type:String},styles:{type:String},script:{type:String},cssContent:{type:String},index:{type:Number}},mounted:function(){this.$root.$on("blockMoved",this.updateFrameIfEmpty),this.previewFrameWindow=this.$refs.previewFrame.contentWindow,this.previewFrameDocument=this.previewFrameWindow.document,this.updateContent();var e=document.createElement("script");if(e.type="text/javascript",e.innerHTML="\n sendResizeEvent = function () {\n if (window.frameElement) {\n window.frameElement.dispatchEvent(new CustomEvent('sizechange', { detail: { height: document.documentElement.offsetHeight } }))\n }\n }\n sendResizedEvent = function () {\n console.log('on resize')\n }\n ",this.previewFrameDocument.getElementsByTagName("body")[0].appendChild(e),this.updateContent(),this.script){var t=document.createElement("script");t.type="text/javascript",t.innerHTML=this.script,this.previewFrameDocument.getElementsByTagName("body")[0].appendChild(t)}},methods:{updateContent:function(){var e=this;this.$nextTick().then(function(){e.previewFrameWindow=e.$refs.previewFrame.contentWindow,e.previewFrameDocument=e.previewFrameWindow.document,e.previewFrameDocument.open(),e.previewFrameDocument.write(e.$refs.previewFrameContent.innerHTML),e.previewFrameDocument.close(),e.resize()})},updateFrameIfEmpty:function(){var e=this;this.$nextTick().then(function(){e.$refs.previewFrame&&null===e.$refs.previewFrame.contentWindow.document.getElementById("kirby-builder-content")&&e.updateContent()})},onResize:function(e){this.resize()},resize:function(){if(this.previewFrameDocument.getElementById){var e=this.previewFrameDocument.getElementById("kirby-builder-content").scrollHeight;e>0&&(this.previewHeight=e)}},onFrameLoad:function(){this.resize()}},watch:{markup:function(e){this.updateContent()},styles:function(e){this.updateContent()},index:function(e){this.updateFrameIfEmpty()}}};if(typeof c==="function"){c=c.options}Object.assign(c,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",{staticClass:"kBuilderPreview"},[_c("iframe",{ref:"previewFrame",staticClass:"kBuilderPreview__frame",style:{height:_vm.previewHeight+"px"},on:{"load":_vm.onFrameLoad,"sizechange":_vm.onResize}}),_vm._v(" "),_c("script",{ref:"previewFrameContent",attrs:{"type":"text/template"}},[_vm._v("\n <html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">\n <title>Kirby Builder Preview</title>\n <style>\n html,body{margin: 0;padding: 0;}\n "+_vm._s(_vm.styles)+"\n </style>\n </head>\n <body>\n <div id=\"kirby-builder-content\">\n "+_vm._s(_vm.markup)+"\n </div>\n </body>\n </html>\n ")])])};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:"data-v-fd7b8d",functional:undefined}}());var d={props:{endpoints:Object,block:Object,index:Number,columnsCount:Number,pageUid:String,pageId:String,encodedPageId:String,styles:String,script:String,parentPath:String},components:{BuilderPreview:c},mounted:function(){this.block.isNew?this.$nextTick(function(){this.pending=!1}):this.pending=!1,this.block.content._uid||(this.block.content._uid=this.block.content._key+"_"+new Date().valueOf()+"_"+this._uid),this.activeFieldSet||(this.activeFieldSet=this.fieldSets[0].key);var e=JSON.parse(localStorage.getItem(this.localUiStateKey));e?(this.expanded=e.expanded,this.showPreview=e.showPreview,this.activeFieldSet=e.activeFieldSet):this.storeLocalUiState(),this.block.preview&&this.showPreview?this.displayPreview(this.block.preview):this.displayFieldSet(this.activeFieldSet),this.block.isNew&&this.$emit("input")},data:function(){return{pending:!0,activeFieldSet:null,expanded:!0,previewFrameContent:null,previewHeight:0,previewStored:!1,previewMarkup:"",showPreview:!1}},computed:{localUiStateKey:function(){return"kBuilder.uiState.".concat(this.block.content._uid)},extendedUid:function(){return this.pageId.replace("/","-")+"-"+this._uid},previewUrl:function(){return this.previewStored?"kirby-builder-preview/"+this.extendedUid+"?"+this.objectToGetParams(this.block.preview)+"&pageid="+this.pageId:null},blockPath:function(){return this.parentPath+"+"+this.block.blockKey},fieldSets:function(){var e=[];if(this.block.tabs){for(var t in this.block.tabs)if(this.block.tabs.hasOwnProperty(t)){var i=this.block.tabs[t];e.push(this.newFieldSet(i,t,this.block.content))}}else this.block.fields&&e.push(this.newFieldSet(this.block,"content",this.block.content,"edit",this.$t("edit")));return e}},methods:{onBlockInput:function(e){this.$emit("input",this.val)},displayPreview:function(){var e=this;this.showPreview=!0,this.expanded=!0;var t={preview:this.block.preview,blockContent:this.block.content,blockFields:this.block.fields,blockUid:this.extendedUid,pageid:this.pageId};this.$api.post("kirby-builder/rendered-preview",t).then(function(t){e.previewMarkup=t.preview,e.activeFieldSet=null,e.$refs.preview.resize()}),this.storeLocalUiState()},displayFieldSet:function(e){this.showPreview=!1,this.activeFieldSet=e,this.previewHeight=0,this.storeLocalUiState()},onPreviewLoaded:function(e){this.previewHeight=e.detail.height,this.activeFieldSet=null},toggleExpand:function(e){this.expanded="boolean"==typeof e?e:!this.expanded,this.expanded&&this.showPreview&&this.displayPreview(),this.storeLocalUiState()},newFieldSet:function(e,t,i,n,s){var o=this;Object.keys(e.fields).forEach(function(t){e.fields[t].endpoints={field:"kirby-builder/pages/".concat(o.encodedPageId,"/fields/").concat(o.blockPath,"+").concat(e.fields[t].name),model:o.endpoints.model,section:o.endpoints.section},e.fields[t].parentPath=o.blockPath});var l={fields:e.fields,key:t,model:i,icon:n||e.icon||null,label:s||e.label||null};return l},objectToGetParams:function(e){return Object.keys(e).map(function(t){return t+"="+e[t]}).join("&")},storeLocalUiState:function(){var e={expanded:this.expanded,showPreview:this.showPreview,activeFieldSet:this.activeFieldSet};localStorage.setItem(this.localUiStateKey,JSON.stringify(e))},tabIcon:function(e){return e?e.indexOf("/")>-1&&e.indexOf(".")>-1?null:e:null},tabImage:function(e){return e&&e.indexOf("/")>-1&&e.indexOf(".")>-1?e:null}}};if(typeof d==="function"){d=d.options}Object.assign(d,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",{class:["kBuilderBlock","kBuilderBlock--col-"+_vm.columnsCount,"kBuilderBlock--type-"+_vm.block.blockKey,{"kBuilderBlock--pending":_vm.pending},{"kBuilderBlock--previewMode":_vm.showPreview&&_vm.expanded},{"kBuilderBlock--expanded":_vm.expanded},{"kBuilderBlock--collapsed":!_vm.expanded},{"kBuilderBlock--editMode":!_vm.showPreview&&_vm.expanded}]},[_c("div",{class:"kBuilderBlock__header kBuilderBlock__header--col-"+_vm.columnsCount},[_c("k-icon",{class:"kBuilder__dragDropHandle kBuilder__dragDropHandle--col-"+_vm.columnsCount,attrs:{"type":"sort"}}),_vm._v(" "),_c("span",{staticClass:"kBuilderBlock__label",on:{"click":_vm.toggleExpand}},[_c("k-icon",{staticClass:"kBuilderBlock__expandedIcon",class:{"kBuilderBlock__expandedIcon--expanded":_vm.expanded},attrs:{"type":"angle-down"}}),_vm._v(" "+_vm._s(_vm.block.label)+" ")],1),_vm._v(" "),_c("div",{staticClass:"kBuilderBlock__actions"},[_c("k-button-group",{staticClass:"kBuilderBlock__actionsGroup"},[_vm._l(_vm.fieldSets,function(fieldSet){return _vm.fieldSets.length>1||_vm.block.preview?_c("k-button",{key:"showFierldSetButton-"+_vm._uid+fieldSet.key,staticClass:"kBuilderBlock__actionsButton",class:{"kBuilderBlock__actionsButton--active":_vm.activeFieldSet==fieldSet.key&&_vm.expanded},attrs:{"icon":_vm.tabIcon(fieldSet.icon),"image":_vm.tabImage(fieldSet.icon)},on:{"click":function($event){_vm.displayFieldSet(fieldSet.key);_vm.toggleExpand(true)}}},[_vm._v(_vm._s(fieldSet.label))]):_vm._e()}),_vm._v(" "),_vm.block.preview?_c("k-button",{staticClass:"kBuilderBlock__actionsButton",class:{"kBuilderBlock__actionsButton--active":_vm.showPreview&&_vm.expanded},attrs:{"icon":"preview"},on:{"click":function($event){_vm.displayPreview()}}},[_vm._v(_vm._s(_vm.$t("builder.preview")))]):_vm._e()],2),_vm._v(" "),_c("div",{staticClass:"kBuilderBlock__control"},[_c("k-dropdown",{staticClass:"kBuilderBlock__actionsDropDown"},[_c("k-button",{staticClass:"kBuilderBlock__actionsButton",attrs:{"icon":"dots"},on:{"click":function($event){_vm.$refs["blockActions"+_vm.block.uniqueKey].toggle()}}}),_vm._v(" "),_c("k-dropdown-content",{ref:"blockActions"+_vm.block.uniqueKey,staticClass:"kBuilderBlock__actionsDropDownContent",attrs:{"align":"right"}},[_c("k-dropdown-item",{attrs:{"icon":"copy"},on:{"click":function($event){_vm.$emit("clone",_vm.index)}}},[_vm._v(_vm._s(_vm.$t("builder.clone")))]),_vm._v(" "),_c("k-dropdown-item",{attrs:{"icon":"trash"},on:{"click":function($event){_vm.$emit("delete",_vm.index)}}},[_vm._v(_vm._s(_vm.$t("delete")))])],1)],1)],1)],1)],1),_vm._v(" "),_c("div",{directives:[{name:"show",rawName:"v-show",value:_vm.expanded,expression:"expanded"}],staticClass:"kBuilderBlock__content"},[_vm.block.preview?_c("builder-preview",{directives:[{name:"show",rawName:"v-show",value:_vm.showPreview,expression:"showPreview"}],ref:"preview",attrs:{"markup":_vm.previewMarkup,"styles":_vm.styles,"index":_vm.index,"script":_vm.script}}):_vm._e(),_vm._v(" "),_vm._l(_vm.fieldSets,function(fieldSet){return _vm.activeFieldSet===fieldSet.key?_c("k-fieldset",_vm._g({directives:[{name:"show",rawName:"v-show",value:!_vm.showPreview,expression:"!showPreview"}],key:fieldSet.key+_vm._uid,staticClass:"kBuilderBlock__form",attrs:{"value":{},"fields":fieldSet.fields,"validate":true},model:{value:fieldSet.model,callback:function($$v){_vm.$set(fieldSet,"model",$$v)},expression:"fieldSet.model"}},_vm.$listeners)):_vm._e()})],2)])};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());var g,p={},q="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},f=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t};function b(t){if(Array.isArray(t)){for(var n=0,e=Array(t.length);n<t.length;n++)e[n]=t[n];return e}return Array.from(t)}var e,i,n=false;function o(){if(n)return;n=true;i={};!function(t){"function"==typeof e&&e.amd?e(t):void 0!==i?i=t():window.Sortable=t()}(function(){if("undefined"==typeof window||!window.document)return function(){throw new Error("Sortable.js requires a window with a document")};var t,e,n,o,i,r,a,l,s,c,u,d,h,f,p,v,b,m,g,w,y,D,_,C,T,N=[],S=!1,X=!1,Y=!1,H=[],M=!1,B=!1,k=/\s+/g,P="Sortable"+new Date().getTime(),$=window,x=$.document,A=$.parseInt,W=$.setTimeout,L=$.jQuery||$.Zepto,Z=$.Polymer,O={capture:!1,passive:!1},z=!!navigator.userAgent.match(/(?:Trident.*rv[ :]?11\.|msie|iemobile)/i),j=!!navigator.userAgent.match(/Edge/i),U=j||z?"cssFloat":"float",V="draggable"in x.createElement("div"),q=function(){if(z)return!1;var t=x.createElement("x");return t.style.cssText="pointer-events:auto","auto"===t.style.pointerEvents}(),G=!1,K=!1,Q=Math.abs,J=Math.min,I=[],F=function(t,e){var n=vt(t),o=A(n.width),i=_t(t,0,e),r=_t(t,1,e),a=i&&vt(i),l=r&&vt(r),s=a&&A(a.marginLeft)+A(a.marginRight)+kt(i).width,c=l&&A(l.marginLeft)+A(l.marginRight)+kt(r).width;return"flex"===n.display?"column"===n.flexDirection||"column-reverse"===n.flexDirection?"vertical":"horizontal":i&&("block"===a.display||"flex"===a.display||"table"===a.display||"grid"===a.display||s>=o&&"none"===n[U]||r&&"none"===n[U]&&s+c>o)?"vertical":"horizontal"},R=function(t,e){if(!t||!t.getBoundingClientRect)return $;var n=t,o=!1;do{if(n.clientWidth<n.scrollWidth||n.clientHeight<n.scrollHeight){var i=vt(n);if(n.clientWidth<n.scrollWidth&&("auto"==i.overflowX||"scroll"==i.overflowX)||n.clientHeight<n.scrollHeight&&("auto"==i.overflowY||"scroll"==i.overflowY)){if(!n||!n.getBoundingClientRect||n===x.body)return $;if(o||e)return n;o=!0}}}while(n=n.parentNode);return $},E=Xt(function(t,e,n,o){if(e.scroll){var i=n?n[P]:window,r=e.scrollSensitivity,a=e.scrollSpeed,u=t.clientX,d=t.clientY,h=(window.innerWidth,window.innerHeight,!1);s!==n&&(tt(),l=e.scroll,c=e.scrollFn,!0===l&&(l=R(n,!0),s=l));var f=0,p=l;do{var v,b,m,w,y,D,_,C,T,X=p,Y=kt(X),H=Y.top,M=Y.bottom,B=Y.left,k=Y.right,A=Y.width,W=Y.height;if(X!==$?(v=X.scrollWidth,b=X.scrollHeight,m=vt(X),D=A<v&&("auto"===m.overflowX||"scroll"===m.overflowX),_=W<b&&("auto"===m.overflowY||"scroll"===m.overflowY),C=X.scrollLeft,T=X.scrollTop):(v=x.documentElement.scrollWidth,b=x.documentElement.scrollHeight,m=vt(x.documentElement),D=A<v&&("auto"===m.overflowX||"scroll"===m.overflowX||"visible"===m.overflowX),_=W<b&&("auto"===m.overflowY||"scroll"===m.overflowY||"visible"===m.overflowY),C=x.documentElement.scrollLeft,T=x.documentElement.scrollTop),w=D&&(Q(k-u)<=r&&C+A<v)-(Q(B-u)<=r&&!!C),y=_&&(Q(M-d)<=r&&T+W<b)-(Q(H-d)<=r&&!!T),!N[f])for(var L=0;L<=f;L++)N[L]||(N[L]={});N[f].vx==w&&N[f].vy==y&&N[f].el===X||(N[f].el=X,N[f].vx=w,N[f].vy=y,clearInterval(N[f].pid),!X||0==w&&0==y||(h=!0,N[f].pid=setInterval(function(){o&&0===this.layer&&ct.active._emulateDragOver(!0);var e=N[this.layer].vy?N[this.layer].vy*a:0,n=N[this.layer].vx?N[this.layer].vx*a:0;"function"==typeof c&&"continue"!==c.call(i,n,e,t,g,N[this.layer].el)||(N[this.layer].el===$?$.scrollTo($.pageXOffset+n,$.pageYOffset+e):(N[this.layer].el.scrollTop+=e,N[this.layer].el.scrollLeft+=n))}.bind({layer:f}),24))),f++}while(e.bubbleScroll&&p!==$&&(p=R(p,!1)));S=h}},30),tt=function(){N.forEach(function(t){clearInterval(t.pid)}),N=[]},et=function(t){function e(t,n){return function(o,i,r,a){var l=o.options.group.name&&i.options.group.name&&o.options.group.name===i.options.group.name;if(null==t&&(n||l))return!0;if(null==t||!1===t)return!1;if(n&&"clone"===t)return t;if("function"==typeof t)return e(t(o,i,r,a),n)(o,i,r,a);var s=(n?o:i).options.group.name;return!0===t||"string"==typeof t&&t===s||t.join&&t.indexOf(s)>-1}}var n={},o=t.group;o&&"object"==typeof o||(o={name:o}),n.name=o.name,n.checkPull=e(o.pull,!0),n.checkPut=e(o.put),n.revertClone=o.revertClone,t.group=n},nt=function(e){t&&t.parentNode&&t.parentNode[P]&&t.parentNode[P]._computeIsAligned(e)},ot=function(t,e){for(var n=e;!n[P];)n=n.parentNode;return t===n},it=function(t,e,n){for(var o=t.parentNode;o&&!o[P];)o=o.parentNode;o&&o[P][n](Yt(e,{artificialBubble:!0}))},rt=function(){!q&&n&&vt(n,"display","none")},at=function(){!q&&n&&vt(n,"display","")};x.addEventListener("click",function(t){if(Y)return t.preventDefault(),t.stopPropagation&&t.stopPropagation(),t.stopImmediatePropagation&&t.stopImmediatePropagation(),Y=!1,!1},!0);var lt,st=function(e){if(t){var n=function(t,e){for(var n=0;n<H.length;n++)if(!H[n].children.length){var o=kt(H[n]),i=H[n][P].options.emptyInsertThreshold,r=t>=o.left-i&&t<=o.right+i,a=e>=o.top-i&&e<=o.bottom+i;if(r&&a)return H[n]}}(e.clientX,e.clientY);n&&n[P]._onDragOver({clientX:e.clientX,clientY:e.clientY,target:n,rootEl:n})}};function ct(t,e){if(!t||!t.nodeType||1!==t.nodeType)throw"Sortable: `el` must be HTMLElement, not "+{}.toString.call(t);this.el=t,this.options=e=Yt({},e),t[P]=this;var n={group:null,sort:!0,disabled:!1,store:null,handle:null,scroll:!0,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0,draggable:/[uo]l/i.test(t.nodeName)?"li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return F(t,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(t,e){t.setData("Text",e.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,touchStartThreshold:A(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:!1!==ct.supportPointer&&("PointerEvent"in window||window.navigator&&"msPointerEnabled"in window.navigator),emptyInsertThreshold:5};for(var o in n)!(o in e)&&(e[o]=n[o]);for(var i in et(e),this)"_"===i.charAt(0)&&"function"==typeof this[i]&&(this[i]=this[i].bind(this));this.nativeDraggable=!e.forceFallback&&V,e.supportPointer?ht(t,"pointerdown",this._onTapStart):(ht(t,"mousedown",this._onTapStart),ht(t,"touchstart",this._onTapStart)),this.nativeDraggable&&(ht(t,"dragover",this),ht(t,"dragenter",this)),H.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[])}function ut(t,e,n,o){if(t){n=n||x;do{if(">*"===e&&t.parentNode===n||St(t,e)||o&&t===n)return t;if(t===n)break}while(t=dt(t))}return null}function dt(t){return t.host&&t!==x&&t.host.nodeType?t.host:t.parentNode}function ht(t,e,n){t.addEventListener(e,n,O)}function ft(t,e,n){t.removeEventListener(e,n,O)}function pt(t,e,n){if(t&&e)if(t.classList)t.classList[n?"add":"remove"](e);else{var o=(" "+t.className+" ").replace(k," ").replace(" "+e+" "," ");t.className=(o+(n?" "+e:"")).replace(k," ")}}function vt(t,e,n){var o=t&&t.style;if(o){if(void 0===n)return x.defaultView&&x.defaultView.getComputedStyle?n=x.defaultView.getComputedStyle(t,""):t.currentStyle&&(n=t.currentStyle),void 0===e?n:n[e];e in o||-1!==e.indexOf("webkit")||(e="-webkit-"+e),o[e]=n+("string"==typeof n?"":"px")}}function bt(t){var e="";do{var n=vt(t,"transform");n&&"none"!==n&&(e=n+" "+e)}while(t=t.parentNode);return window.DOMMatrix?new DOMMatrix(e):window.WebKitCSSMatrix?new WebKitCSSMatrix(e):window.CSSMatrix?new CSSMatrix(e):void 0}function mt(t,e,n){if(t){var o=t.getElementsByTagName(e),i=0,r=o.length;if(n)for(;i<r;i++)n(o[i],i);return o}return[]}function gt(t,e,n,i,r,a,l,s,c){var u,d=(t=t||e[P]).options,h="on"+n.charAt(0).toUpperCase()+n.substr(1);!window.CustomEvent||z||j?(u=x.createEvent("Event")).initEvent(n,!0,!0):u=new CustomEvent(n,{bubbles:!0,cancelable:!0}),u.to=r||e,u.from=a||e,u.item=i||e,u.clone=o,u.oldIndex=l,u.newIndex=s,u.originalEvent=c,e&&e.dispatchEvent(u),d[h]&&d[h].call(t,u)}function wt(t,e,n,o,i,r,a,l){var s,c,u=t[P],d=u.options.onMove;return!window.CustomEvent||z||j?(s=x.createEvent("Event")).initEvent("move",!0,!0):s=new CustomEvent("move",{bubbles:!0,cancelable:!0}),s.to=e,s.from=t,s.dragged=n,s.draggedRect=o,s.related=i||e,s.relatedRect=r||kt(e),s.willInsertAfter=l,s.originalEvent=a,t.dispatchEvent(s),d&&(c=d.call(u,s,a)),c}function yt(t){t.draggable=!1}function Dt(){G=!1}function _t(e,o,i){for(var r=0,a=0,l=e.children;a<l.length;){if("none"!==l[a].style.display&&l[a]!==n&&l[a]!==t&&ut(l[a],i.draggable,e,!1)){if(r===o)return l[a];r++}a++}return null}function Ct(t){var e=t.lastElementChild;return e===n&&(e=t.children[t.childElementCount-2]),e||null}function Tt(t){for(var e=t.tagName+t.className+t.src+t.href+t.textContent,n=e.length,o=0;n--;)o+=e.charCodeAt(n);return o.toString(36)}function Nt(t,e){var n=0;if(!t||!t.parentNode)return-1;for(;t&&(t=t.previousElementSibling);)"TEMPLATE"!==t.nodeName.toUpperCase()&&t!==o&&n++;return n}function St(t,e){if(t)try{if(t.matches)return t.matches(e);if(t.msMatchesSelector)return t.msMatchesSelector(e);if(t.webkitMatchesSelector)return t.webkitMatchesSelector(e)}catch(n){return!1}return!1}function Xt(t,e){return function(){if(!lt){var n=arguments,o=this;lt=W(function(){1===n.length?t.call(o,n[0]):t.apply(o,n),lt=void 0},e)}}}function Yt(t,e){if(t&&e)for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}function Ht(t){return Z&&Z.dom?Z.dom(t).cloneNode(!0):L?L(t).clone(!0)[0]:t.cloneNode(!0)}function Mt(t){return W(t,0)}function Bt(t){return clearTimeout(t)}function kt(t,e,n){if(t.getBoundingClientRect||t===$){var o,i,r,a,l,s,c;if(t!==$?(i=(o=t.getBoundingClientRect()).top,r=o.left,a=o.bottom,l=o.right,s=o.height,c=o.width):(i=0,r=0,a=window.innerHeight,l=window.innerWidth,s=window.innerHeight,c=window.innerWidth),n&&t!==$){if(e=e||t.parentNode,!z)do{if(e&&e.getBoundingClientRect&&"none"!==vt(e,"transform")){var u=e.getBoundingClientRect();i-=u.top+A(vt(e,"border-top-width")),r-=u.left+A(vt(e,"border-left-width")),a=i+o.height,l=r+o.width;break}}while(e=e.parentNode);var d=bt(t),h=d&&d.a,f=d&&d.d;d&&(a=(i/=f)+(s/=f),l=(r/=h)+(c/=h))}return{top:i,left:r,bottom:a,right:l,width:c,height:s}}}return x.addEventListener("dragover",st),x.addEventListener("mousemove",st),ct.prototype={constructor:ct,_computeIsAligned:function(e){var o;if(n&&!q?(rt(),o=x.elementFromPoint(e.clientX,e.clientY),at()):o=e.target,o=ut(o,this.options.draggable,this.el,!1),!K&&t&&t.parentNode===this.el){for(var i,r,a,l,s,c,u,d,h=this.el.children,f=0;f<h.length;f++)ut(h[f],this.options.draggable,this.el,!1)&&h[f]!==o&&(h[f].sortableMouseAligned=(i=e.clientX,r=e.clientY,a=h[f],l=this._getDirection(e,null),this.options,s=void 0,c=void 0,u=void 0,d=void 0,s=kt(a),c="vertical"===l?s.left:s.top,u="vertical"===l?s.right:s.bottom,c<(d="vertical"===l?i:r)&&d<u));ut(o,this.options.draggable,this.el,!0)||(y=null),K=!0,W(function(){K=!1},30)}},_getDirection:function(e,n){return"function"==typeof this.options.direction?this.options.direction.call(this,e,n,t):this.options.direction},_onTapStart:function(e){if(e.cancelable){var n,o=this,i=this.el,r=this.options,l=r.preventOnFilter,s=e.type,c=e.touches&&e.touches[0],u=(c||e).target,d=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||u,h=r.filter;if(function(t){I.length=0;var e=t.getElementsByTagName("input"),n=e.length;for(;n--;){var o=e[n];o.checked&&I.push(o)}}(i),(!z||e.artificialBubble||ot(i,u))&&!t&&!(/mousedown|pointerdown/.test(s)&&0!==e.button||r.disabled||d.isContentEditable))if(u=ut(u,r.draggable,i,!1)){if(a!==u){if(n=Nt(u,r.draggable),"function"==typeof h){if(h.call(this,e,u,this))return gt(o,d,"filter",u,i,i,n),void(l&&e.cancelable&&e.preventDefault())}else if(h&&(h=h.split(",").some(function(t){if(t=ut(d,t.trim(),i,!1))return gt(o,t,"filter",u,i,i,n),!0})))return void(l&&e.cancelable&&e.preventDefault());r.handle&&!ut(d,r.handle,i,!1)||this._prepareDragStart(e,c,u,n)}}else z&&it(i,e,"_onTapStart")}},_handleAutoScroll:function(e,n){if(t&&this.options.scroll){var o=e.clientX,i=e.clientY,r=x.elementFromPoint(o,i),a=this;if(n||j||z){E(e,a.options,r,n);var l=R(r,!0);!S||p&&o===v&&i===b||(p&&clearInterval(p),p=setInterval(function(){if(t){var r=R(x.elementFromPoint(o,i),!0);r!==l&&(l=r,tt(),E(e,a.options,l,n))}},10),v=o,b=i)}else{if(!a.options.bubbleScroll||R(r,!0)===window)return void tt();E(e,a.options,R(r,!1),!1)}}},_prepareDragStart:function(n,o,l,s){var c,d=this,f=d.el,p=d.options,v=f.ownerDocument;l&&!t&&l.parentNode===f&&(i=f,e=(t=l).parentNode,r=t.nextSibling,a=l,h=p.group,u=s,m={target:t,clientX:(o||n).clientX,clientY:(o||n).clientY},this._lastX=(o||n).clientX,this._lastY=(o||n).clientY,t.style["will-change"]="all",t.style.transition="",t.style.transform="",c=function(){d._disableDelayedDrag(),t.draggable=d.nativeDraggable,d._triggerDragStart(n,o),gt(d,i,"choose",t,i,i,u),pt(t,p.chosenClass,!0)},p.ignore.split(",").forEach(function(e){mt(t,e.trim(),yt)}),p.supportPointer?(ht(v,"pointerup",d._onDrop),ht(v,"pointercancel",d._onDrop)):(ht(v,"mouseup",d._onDrop),ht(v,"touchend",d._onDrop),ht(v,"touchcancel",d._onDrop)),p.delay?(ht(v,"mouseup",d._disableDelayedDrag),ht(v,"touchend",d._disableDelayedDrag),ht(v,"touchcancel",d._disableDelayedDrag),ht(v,"mousemove",d._delayedDragTouchMoveHandler),ht(v,"touchmove",d._delayedDragTouchMoveHandler),p.supportPointer&&ht(v,"pointermove",d._delayedDragTouchMoveHandler),d._dragStartTimer=W(c,p.delay)):c())},_delayedDragTouchMoveHandler:function(t){var e=t.touches?t.touches[0]:t;J(Q(e.clientX-this._lastX),Q(e.clientY-this._lastY))>=this.options.touchStartThreshold&&this._disableDelayedDrag()},_disableDelayedDrag:function(){var t=this.el.ownerDocument;clearTimeout(this._dragStartTimer),ft(t,"mouseup",this._disableDelayedDrag),ft(t,"touchend",this._disableDelayedDrag),ft(t,"touchcancel",this._disableDelayedDrag),ft(t,"mousemove",this._delayedDragTouchMoveHandler),ft(t,"touchmove",this._delayedDragTouchMoveHandler),ft(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(e,n){n=n||("touch"==e.pointerType?e:null),!this.nativeDraggable||n?this.options.supportPointer?ht(x,"pointermove",this._onTouchMove):ht(x,n?"touchmove":"mousemove",this._onTouchMove):(ht(t,"dragend",this),ht(i,"dragstart",this._onDragStart));try{x.selection?Mt(function(){x.selection.empty()}):window.getSelection().removeAllRanges()}catch(o){}},_dragStarted:function(e){if(X=!1,i&&t){this.nativeDraggable&&(ht(x,"dragover",this._handleAutoScroll),ht(x,"dragover",nt));var n=this.options;!e&&pt(t,n.dragClass,!1),pt(t,n.ghostClass,!0),vt(t,"transform",""),ct.active=this,e&&this._appendGhost(),gt(this,i,"start",t,i,i,u)}else this._nulling()},_emulateDragOver:function(e){if(g){if(this._lastX===g.clientX&&this._lastY===g.clientY&&!e)return;this._lastX=g.clientX,this._lastY=g.clientY,rt();for(var n=x.elementFromPoint(g.clientX,g.clientY),o=n;n&&n.shadowRoot;)o=n=n.shadowRoot.elementFromPoint(g.clientX,g.clientY);if(o)do{if(o[P])if(o[P]._onDragOver({clientX:g.clientX,clientY:g.clientY,target:n,rootEl:o})&&!this.options.dragoverBubble)break;n=o}while(o=o.parentNode);t.parentNode[P]._computeIsAligned(g),at()}},_onTouchMove:function(t){if(m){if(!t.cancelable)return;var e=this.options,o=e.fallbackTolerance,i=e.fallbackOffset,r=t.touches?t.touches[0]:t,a=n&&bt(n),l=n&&a&&a.a,s=n&&a&&a.d,c=(r.clientX-m.clientX+i.x)/(l||1),u=(r.clientY-m.clientY+i.y)/(s||1),d=t.touches?"translate3d("+c+"px,"+u+"px,0)":"translate("+c+"px,"+u+"px)";if(!ct.active&&!X){if(o&&J(Q(r.clientX-this._lastX),Q(r.clientY-this._lastY))<o)return;this._onDragStart(t,!0)}this._handleAutoScroll(r,!0),w=!0,g=r,vt(n,"webkitTransform",d),vt(n,"mozTransform",d),vt(n,"msTransform",d),vt(n,"transform",d),t.cancelable&&t.preventDefault()}},_appendGhost:function(){if(!n){var e=kt(t,this.options.fallbackOnBody?x.body:i,!0),o=(vt(t),this.options);pt(n=t.cloneNode(!0),o.ghostClass,!1),pt(n,o.fallbackClass,!0),pt(n,o.dragClass,!0),vt(n,"box-sizing","border-box"),vt(n,"margin",0),vt(n,"top",e.top),vt(n,"left",e.left),vt(n,"width",e.width),vt(n,"height",e.height),vt(n,"opacity","0.8"),vt(n,"position","fixed"),vt(n,"zIndex","100000"),vt(n,"pointerEvents","none"),o.fallbackOnBody&&x.body.appendChild(n)||i.appendChild(n)}},_onDragStart:function(e,n){var r=this,a=e.dataTransfer,l=r.options;(o=Ht(t)).draggable=!1,o.style["will-change"]="",this._hideClone(),pt(o,r.options.chosenClass,!1),r._cloneId=Mt(function(){r.options.removeCloneOnHide||i.insertBefore(o,t),gt(r,i,"clone",t)}),!n&&pt(t,l.dragClass,!0),n?(Y=!0,r._loopId=setInterval(r._emulateDragOver,50)):(ft(x,"mouseup",r._onDrop),ft(x,"touchend",r._onDrop),ft(x,"touchcancel",r._onDrop),ft(x,"pointercancel",r._onDrop),a&&(a.effectAllowed="move",l.setData&&l.setData.call(r,a,t)),ht(x,"drop",r),vt(t,"transform","translateZ(0)")),X=!0,r._dragStartId=Mt(r._dragStarted.bind(r,n)),ht(x,"selectstart",r)},_onDragOver:function(o){var a,l,s,c=this.el,d=o.target,p=this.options,v=p.group,b=ct.active,m=h===v,g=p.sort,N=this;if(!G&&(!z||o.rootEl||o.artificialBubble||ot(c,d))){if(void 0!==o.preventDefault&&o.cancelable&&o.preventDefault(),w=!0,d=ut(d,p.draggable,c,!0),ut(o.target,null,t,!0)||d.animated)return V();if(d!==t&&(Y=!1),b&&!p.disabled&&(m?g||(s=!i.contains(t)):f===this||(this.lastPutMode=h.checkPull(this,b,t,o))&&v.checkPut(this,b,t,o))){var X=this._getDirection(o,d);if(a=kt(t),s)return this._hideClone(),e=i,r?i.insertBefore(t,r):i.appendChild(t),V();if(0===c.children.length||c.children[0]===n||function(t,e,n){var o=kt(Ct(n)),i="vertical"===e?t.clientY:t.clientX,r="vertical"===e?t.clientX:t.clientY,a="vertical"===e?o.bottom:o.right,l="vertical"===e?o.left:o.top,s="vertical"===e?o.right:o.bottom;return r>l&&r<s&&i>a}(o,X,c)&&!t.animated){if(0!==c.children.length&&c.children[0]!==n&&c===o.target&&(d=Ct(c)),d&&(l=kt(d)),m?b._hideClone():b._showClone(this),!1!==wt(i,c,t,a,d,l,o,!!d))return c.appendChild(t),e=c,T=null,q(),this._animate(a,t),d&&this._animate(l,d),V()}else if(d&&d!==t&&void 0!==d.parentNode[P]&&d!==c){var H,k=0,A=d.sortableMouseAligned,L=t.parentNode!==c,Z=function(t,e){var n=R(n,!0),o=kt(t)[e];for(;n;){var i=kt(n)[e];if(!("top"===e||"left"===e?o>=i:o<=i))return!0;if(n===$)break;n=R(n,!1)}return!1}(d,"vertical"===X?"top":"left");if(y!==d&&(_=null,H=kt(d)["vertical"===X?"top":"left"],M=!1),function(e,n,o){var i=e===t&&T||kt(e),r=n===t&&T||kt(n),a="vertical"===o?i.left:i.top,l="vertical"===o?i.right:i.bottom,s="vertical"===o?i.width:i.height,c="vertical"===o?r.left:r.top,u="vertical"===o?r.right:r.bottom,d="vertical"===o?r.width:r.height;return a===c||l===u||a+s/2===c+d/2}(t,d,X)&&A||L||Z||p.invertSwap||"insert"===_||"swap"===_?("swap"!==_&&(B=p.invertSwap||L||S||Z),k=function(e,n,o,i,r,a,l){var s=kt(n),c="vertical"===o?e.clientY:e.clientX,u="vertical"===o?s.height:s.width,d="vertical"===o?s.top:s.left,h="vertical"===o?s.bottom:s.right,f=kt(t),p=!1;if(!a)if(l&&C<u*i){if(!M&&(1===D?c>d+u*r/2:c<h-u*r/2)&&(M=!0),M)p=!0;else{"vertical"===o?f.top:f.left,"vertical"===o?f.bottom:f.right;if(1===D?c<d+C:c>h-C)return-1*D}}else if(c>d+u*(1-i)/2&&c<h-u*(1-i)/2)return c>d+u/2?-1:1;if((p=p||a)&&(c<d+u*r/2||c>h-u*r/2))return c>d+u/2?1:-1;return 0}(o,d,X,p.swapThreshold,null==p.invertedSwapThreshold?p.swapThreshold:p.invertedSwapThreshold,B,y===d),_="swap"):(k=function(e,n){var o=Nt(t,n.draggable),i=Nt(e,n.draggable);return o<i?1:-1}(d,p),_="insert"),0===k)return V();T=null,y=d,D=k,l=kt(d);var O=d.nextElementSibling,j=!1,U=wt(i,c,t,a,d,l,o,j=1===k);if(!1!==U)return 1!==U&&-1!==U||(j=1===U),G=!0,W(Dt,30),m?b._hideClone():b._showClone(this),j&&!O?c.appendChild(t):d.parentNode.insertBefore(t,j?O:d),e=t.parentNode,void 0===H||B||(C=Q(H-kt(d)["vertical"===X?"top":"left"])),q(),!L&&this._animate(l,d),this._animate(a,t),V()}if(c.contains(t))return V()}return z&&!o.rootEl&&it(c,o,"_onDragOver"),!1}function V(){return b&&(pt(t,f?f.options.ghostClass:b.options.ghostClass,!1),pt(t,p.ghostClass,!0)),f!==N&&N!==ct.active?f=N:N===ct.active&&(f=null),(d===t&&!t.animated||d===c&&!d.animated)&&(y=null),p.dragoverBubble||o.rootEl||d===x||(N._handleAutoScroll(o),t.parentNode[P]._computeIsAligned(o)),!p.dragoverBubble&&o.stopPropagation&&o.stopPropagation(),!0}function q(){gt(N,i,"change",d,c,i,u,Nt(t,p.draggable),o)}},_animate:function(e,n){var o=this.options.animation;if(o){var i=kt(n);if(n===t&&(T=i),1===e.nodeType&&(e=kt(e)),e.left+e.width/2!==i.left+i.width/2||e.top+e.height/2!==i.top+i.height/2){var r=bt(this.el),a=r&&r.a,l=r&&r.d;vt(n,"transition","none"),vt(n,"transform","translate3d("+(e.left-i.left)/(a||1)+"px,"+(e.top-i.top)/(l||1)+"px,0)"),n.offsetWidth,vt(n,"transition","transform "+o+"ms"+(this.options.easing?" "+this.options.easing:"")),vt(n,"transform","translate3d(0,0,0)")}"number"==typeof n.animated&&clearTimeout(n.animated),n.animated=W(function(){vt(n,"transition",""),vt(n,"transform",""),n.animated=!1},o)}},_offUpEvents:function(){var t=this.el.ownerDocument;ft(x,"touchmove",this._onTouchMove),ft(x,"pointermove",this._onTouchMove),ft(t,"mouseup",this._onDrop),ft(t,"touchend",this._onDrop),ft(t,"pointerup",this._onDrop),ft(t,"touchcancel",this._onDrop),ft(t,"pointercancel",this._onDrop),ft(x,"selectstart",this)},_onDrop:function(a){var l=this.el,s=this.options;X=!1,S=!1,B=!1,M=!1,clearInterval(this._loopId),clearInterval(p),tt(),clearTimeout(lt),lt=void 0,clearTimeout(this._dragStartTimer),Bt(this._cloneId),Bt(this._dragStartId),ft(x,"mousemove",this._onTouchMove),this.nativeDraggable&&(ft(x,"drop",this),ft(l,"dragstart",this._onDragStart),ft(x,"dragover",this._handleAutoScroll),ft(x,"dragover",nt)),this._offUpEvents(),a&&(w&&(a.cancelable&&a.preventDefault(),!s.dropBubble&&a.stopPropagation()),n&&n.parentNode&&n.parentNode.removeChild(n),(i===e||f&&"clone"!==f.lastPutMode)&&o&&o.parentNode&&o.parentNode.removeChild(o),t&&(this.nativeDraggable&&ft(t,"dragend",this),yt(t),t.style["will-change"]="",pt(t,f?f.options.ghostClass:this.options.ghostClass,!1),pt(t,this.options.chosenClass,!1),gt(this,i,"unchoose",t,e,i,u,null,a),i!==e?((d=Nt(t,s.draggable))>=0&&(gt(null,e,"add",t,e,i,u,d,a),gt(this,i,"remove",t,e,i,u,d,a),gt(null,e,"sort",t,e,i,u,d,a),gt(this,i,"sort",t,e,i,u,d,a)),f&&f.save()):t.nextSibling!==r&&(d=Nt(t,s.draggable))>=0&&(gt(this,i,"update",t,e,i,u,d,a),gt(this,i,"sort",t,e,i,u,d,a)),ct.active&&(null!=d&&-1!==d||(d=u),gt(this,i,"end",t,e,i,u,d,a),this.save()))),this._nulling()},_nulling:function(){i=t=e=n=r=o=a=l=s=N.length=p=v=b=m=g=w=d=u=y=D=T=f=h=ct.active=null,I.forEach(function(t){t.checked=!0}),I.length=0},handleEvent:function(e){switch(e.type){case"drop":case"dragend":this._onDrop(e);break;case"dragenter":case"dragover":t&&(this._onDragOver(e),function(t){t.dataTransfer&&(t.dataTransfer.dropEffect="move");t.cancelable&&t.preventDefault()}(e));break;case"selectstart":e.preventDefault();}},toArray:function(){for(var t,e=[],n=this.el.children,o=0,i=n.length,r=this.options;o<i;o++)ut(t=n[o],r.draggable,this.el,!1)&&e.push(t.getAttribute(r.dataIdAttr)||Tt(t));return e},sort:function(t){var e={},n=this.el;this.toArray().forEach(function(t,o){var i=n.children[o];ut(i,this.options.draggable,n,!1)&&(e[t]=i)},this),t.forEach(function(t){e[t]&&(n.removeChild(e[t]),n.appendChild(e[t]))})},save:function(){var t=this.options.store;t&&t.set&&t.set(this)},closest:function(t,e){return ut(t,e||this.options.draggable,this.el,!1)},option:function(t,e){var n=this.options;if(void 0===e)return n[t];n[t]=e,"group"===t&&et(n)},destroy:function(){var t=this.el;t[P]=null,ft(t,"mousedown",this._onTapStart),ft(t,"touchstart",this._onTapStart),ft(t,"pointerdown",this._onTapStart),this.nativeDraggable&&(ft(t,"dragover",this),ft(t,"dragenter",this)),Array.prototype.forEach.call(t.querySelectorAll("[draggable]"),function(t){t.removeAttribute("draggable")}),this._onDrop(),H.splice(H.indexOf(this.el),1),this.el=t=null},_hideClone:function(){o.cloneHidden||(vt(o,"display","none"),o.cloneHidden=!0,o.parentNode&&this.options.removeCloneOnHide&&o.parentNode.removeChild(o))},_showClone:function(e){"clone"===e.lastPutMode?o.cloneHidden&&(i.contains(t)&&!this.options.group.revertClone?i.insertBefore(o,t):r?i.insertBefore(o,r):i.appendChild(o),this.options.group.revertClone&&this._animate(t,o),vt(o,"display",""),o.cloneHidden=!1):this._hideClone()}},ht(x,"touchmove",function(t){(ct.active||X)&&t.cancelable&&t.preventDefault()}),ct.utils={on:ht,off:ft,css:vt,find:mt,is:function(t,e){return!!ut(t,e,t,!1)},extend:Yt,throttle:Xt,closest:ut,toggleClass:pt,clone:Ht,index:Nt,nextTick:Mt,cancelNextTick:Bt,detectDirection:F,getChild:_t},ct.create=function(t,e){return new ct(t,e)},ct.version="1.8.1",ct})}!function(){function t(t){function n(t){t.parentElement.removeChild(t)}function e(t,n,e){var o=0===e?t.children[0]:t.children[e-1].nextSibling;t.insertBefore(n,o)}function o(t,n){var e=this;this.$nextTick(function(){return e.$emit(t.toLowerCase(),n)})}var i=["Start","Add","Remove","Update","End"],r=["Choose","Sort","Filter","Clone"],a=["Move"].concat(i,r).map(function(t){return"on"+t}),s=null;return{name:"draggable",props:{options:Object,list:{type:Array,required:!1,default:null},value:{type:Array,required:!1,default:null},noTransitionOnDrag:{type:Boolean,default:!1},clone:{type:Function,default:function(t){return t}},element:{type:String,default:"div"},move:{type:Function,default:null},componentData:{type:Object,required:!1,default:null}},data:function(){return{transitionMode:!1,noneFunctionalComponentMode:!1,init:!1}},render:function(t){var n=this.$slots.default;if(n&&1===n.length){var e=n[0];e.componentOptions&&"transition-group"===e.componentOptions.tag&&(this.transitionMode=!0)}var o=0,i=n,r=this.$slots,a=r.header,s=r.footer;a&&(o=a.length,i=i?[].concat(b(a),b(i)):[].concat(b(a))),s&&(i=i?[].concat(b(i),b(s)):[].concat(b(s))),this.headerOffset=o;var u=null,l=function(t,n){u=function(t,n,e){return null==e?t:((t=null==t?{}:t)[n]=e,t)}(u,t,n)};if(l("attrs",this.$attrs),this.componentData){var c=this.componentData,d=c.on,f=c.props;l("on",d),l("props",f)}return t(this.element,u,i)},mounted:function(){var n=this;if(this.noneFunctionalComponentMode=this.element.toLowerCase()!==this.$el.nodeName.toLowerCase(),this.noneFunctionalComponentMode&&this.transitionMode)throw new Error("Transition-group inside component is not supported. Please alter element value or remove transition-group. Current element value: "+this.element);var e={};i.forEach(function(t){e["on"+t]=function(t){var n=this;return function(e){null!==n.realList&&n["onDrag"+t](e),o.call(n,t,e)}}.call(n,t)}),r.forEach(function(t){e["on"+t]=o.bind(n,t)});var a=f({},this.options,e,{onMove:function(t,e){return n.onDragMove(t,e)}});!("draggable"in a)&&(a.draggable=">*"),this._sortable=new t(this.rootContainer,a),this.computeIndexes()},beforeDestroy:function(){void 0!==this._sortable&&this._sortable.destroy()},computed:{rootContainer:function(){return this.transitionMode?this.$el.children[0]:this.$el},isCloning:function(){return!!this.options&&!!this.options.group&&"clone"===this.options.group.pull},realList:function(){return this.list?this.list:this.value}},watch:{options:{handler:function(t){for(var n in t)-1==a.indexOf(n)&&this._sortable.option(n,t[n])},deep:!0},realList:function(){this.computeIndexes()}},methods:{getChildrenNodes:function(){if(this.init||(this.noneFunctionalComponentMode=this.noneFunctionalComponentMode&&1==this.$children.length,this.init=!0),this.noneFunctionalComponentMode)return this.$children[0].$slots.default;var t=this.$slots.default;return this.transitionMode?t[0].child.$slots.default:t},computeIndexes:function(){var t=this;this.$nextTick(function(){t.visibleIndexes=function(t,n,e){if(!t)return[];var o=t.map(function(t){return t.elm}),i=[].concat(b(n)).map(function(t){return o.indexOf(t)});return e?i.filter(function(t){return-1!==t}):i}(t.getChildrenNodes(),t.rootContainer.children,t.transitionMode)})},getUnderlyingVm:function(t){var n=function(t,n){return t.map(function(t){return t.elm}).indexOf(n)}(this.getChildrenNodes()||[],t);return-1===n?null:{index:n,element:this.realList[n]}},getUnderlyingPotencialDraggableComponent:function(t){var n=t.__vue__;return n&&n.$options&&"transition-group"===n.$options._componentTag?n.$parent:n},emitChanges:function(t){var n=this;this.$nextTick(function(){n.$emit("change",t)})},alterList:function(t){if(this.list)t(this.list);else{var n=[].concat(b(this.value));t(n),this.$emit("input",n)}},spliceList:function(){var t=arguments,n=function(n){return n.splice.apply(n,t)};this.alterList(n)},updatePosition:function(t,n){var e=function(e){return e.splice(n,0,e.splice(t,1)[0])};this.alterList(e)},getRelatedContextFromMoveEvent:function(t){var n=t.to,e=t.related,o=this.getUnderlyingPotencialDraggableComponent(n);if(!o)return{component:o};var i=o.realList,r={list:i,component:o};if(n!==e&&i&&o.getUnderlyingVm){var a=o.getUnderlyingVm(e);if(a)return f(a,r)}return r},getVmIndex:function(t){var n=this.visibleIndexes,e=n.length;return t>e-1?e:n[t]},getComponent:function(){return this.$slots.default[0].componentInstance},resetTransitionData:function(t){if(this.noTransitionOnDrag&&this.transitionMode){this.getChildrenNodes()[t].data=null;var n=this.getComponent();n.children=[],n.kept=void 0}},onDragStart:function(t){this.context=this.getUnderlyingVm(t.item),t.item._underlying_vm_=this.clone(this.context.element),s=t.item},onDragAdd:function(t){this.updateEvenemt(t);var e=t.item._underlying_vm_;if(void 0!==e){n(t.item);var o=this.getVmIndex(t.newIndex);this.spliceList(o,0,e),this.computeIndexes();var i={element:e,newIndex:o};this.emitChanges({added:i})}},onDragRemove:function(t){if(this.updateEvenemt(t),e(this.rootContainer,t.item,t.oldIndex),this.isCloning)n(t.clone);else{var o=this.context.index;this.spliceList(o,1);var i={element:this.context.element,oldIndex:o};this.resetTransitionData(o),this.emitChanges({removed:i})}},onDragUpdate:function(t){this.updateEvenemt(t),n(t.item),e(t.from,t.item,t.oldIndex);var o=this.context.index,i=this.getVmIndex(t.newIndex);this.updatePosition(o,i);var r={element:this.context.element,oldIndex:o,newIndex:i};this.emitChanges({moved:r})},updateEvenemt:function(t){this.updateProperty(t,"newIndex"),this.updateProperty(t,"oldIndex")},updateProperty:function(t,n){t.hasOwnProperty(n)&&(t[n]+=this.headerOffset)},computeFutureIndex:function(t,n){if(!t.element)return 0;var e=[].concat(b(n.to.children)).filter(function(t){return"none"!==t.style.display}),o=e.indexOf(n.related),i=t.component.getVmIndex(o);return-1!=e.indexOf(s)||!n.willInsertAfter?i:i+1},onDragMove:function(t,n){var e=this.move;if(!e||!this.realList)return!0;var o=this.getRelatedContextFromMoveEvent(t),i=this.context,r=this.computeFutureIndex(o,t);return f(i,{futureIndex:r}),f(t,{relatedContext:o,draggedContext:i}),e(t,n)},onDragEnd:function(t){this.computeIndexes(),s=null}}}}if(Array.from||(Array.from=function(t){return[].slice.call(t)}),"object"==typeof p){var n=(o(),i);p=t(n)}else if("function"==typeof g&&g.amd)g(["sortablejs"],function(n){return t(n)});else if(window&&window.Vue&&window.Sortable){var e=t(window.Sortable);Vue.component("draggable",e)}}();var a={props:{counter:[Boolean,Object],disabled:Boolean,endpoints:Object,help:String,input:[String,Number],name:[String,Number],required:Boolean,type:String,value:String,fieldsets:Object,columns:Number,max:Number,label:String,preview:Object,pageId:String,pageUid:String,encodedPageId:String,cssUrls:String,jsUrls:String,parentPath:String},components:{BuilderBlock:d},mounted:function(){for(var t=this,e=Object.entries(this.cssUrls),n=function(){var n=j(e[i],2),o=n[0],r=n[1];fetch("/"+r.replace(/^\/+/g,"")).then(function(t){return t.text()}).then(function(e){t.$set(t.cssContents,o,e)})},i=0;i<e.length;i++)n();for(var o=Object.entries(this.jsUrls),r=function(){var e=j(o[s],2),n=e[0],i=e[1];fetch("/"+i.replace(/^\/+/g,"")).then(function(t){return t.text()}).then(function(e){t.$set(t.jsContents,n,e)})},s=0;s<o.length;s++)r()},data:function(){return{dragging:!1,toggle:!0,targetPosition:null,lastUniqueKey:0,cssContents:{},jsContents:{},dialogOpen:!1}},computed:{val:function(){return this.blocks.map(function(t){return t.content})},blocks:function(){var t=this,e=[];return this.value&&(this.value.forEach(function(n,i){e.push(t.newBlock(n,i))}),this.lastUniqueKey=this.value.length),e},classObject:function(){var t={};return t["kBuilder--col-"+this.columnsCount]=!0,t["kBuilder--dragging"]=this.dragging,t},path:function(){return this.parentPath?"".concat(this.parentPath,"+").concat(this.name):this.name},columnsCount:function(){return this.columns?this.columns:"1"},columnWidth:function(){return this.columns?"1/"+this.columns:"1/1"},draggableOptions:function(){return{group:this._uid,clone:!0,handle:".kBuilder__dragDropHandle",forceFallback:!0,fallbackClass:"sortable-fallback",fallbackOnBody:!0,scroll:document.querySelector(".k-panel-view")}},blockCount:function(){return this.blocks.length},fieldsetCount:function(){return Object.keys(this.fieldsets).length},fieldsetKeys:function(){return Object.keys(this.fieldsets)},addBlockButtonLabel:function(){return this.$t("add")},supportedBlockTypes:function(){return Object.keys(this.fieldsets)}},methods:{onBlockInput:function(t){this.$emit("input",this.value)},onBlockMoved:function(t){this.$emit("input",this.value)},onBlockAdded:function(t){this.$emit("input",this.value)},onBlockRemoved:function(t){this.$emit("input",this.value)},onDragEnd:function(t){this.dragging=!1},onMove:function(t){return this.$root.$emit("blockMoved"),t.relatedContext.index!=this.value.length+1},onStartDrag:function(t){this.dragging=!0;var e=t.item.getElementsByClassName("kBuilderPreview__frame")[0];if(e){var n=e.contentWindow.document,i=document.getElementsByClassName("sortable-drag")[0].getElementsByClassName("kBuilderPreview__frame")[0].contentWindow.document;i.open(),i.write(n.documentElement.innerHTML),i.close()}},onClickAddBlock:function(t){this.targetPosition=t,1==this.fieldsetCount?this.addBlock(this.fieldsetKeys[0]):this.$refs.dialog.open()},onOpenDialog:function(){this.dialogOpen=!0},onCloseDialog:function(){this.dialogOpen=!1},addBlock:function(t){var e=null==this.targetPosition?this.value.length:this.targetPosition,n=this.fieldsets[t];this.value.splice(e,0,this.getBlankContent(t,n)),this.$emit("input",this.value),this.$nextTick(function(){this.$emit("input",this.value)}),this.targetPosition=null,this.dialogOpen&&this.$refs.dialog.close()},getBlankContent:function(t,e){var n={_key:t};if(e.fields)Object.keys(e.fields).forEach(function(t){n[t]=e.fields[t].value||e.fields[t].default||null});else if(e.tabs)for(var i in e.tabs)e.tabs.hasOwnProperty(i)&&function(){var t=e.tabs[i];Object.keys(t.fields).forEach(function(e){n[e]=t.fields[e].value||t.fields[e].default||null})}();return n},cloneBlock:function(t){var e=JSON.parse(JSON.stringify(this.value[t]));this.deepRemoveProperty(e,"_uid"),this.value.splice(t+1,0,e),this.value[t+1].uniqueKey=this.lastUniqueKey++,this.$emit("input",this.value),this.$nextTick(function(){this.$emit("input",this.value)})},deleteBlock:function(t){this.clearLocalUiStates(this.blocks[t]),this.blocks.splice(t,1),this.$emit("input",this.val)},deepRemoveProperty:function(t,e){var n=this;Object.keys(t).forEach(function(i){i===e?delete t[i]:"object"===h(t[i])&&n.deepRemoveProperty(t[i],e)})},clearLocalUiStates:function(t){for(var e in t)if(t.hasOwnProperty(e)){t[e];"_uid"===e?localStorage.removeItem("kBuilder.uiState.".concat(t[e])):"object"===h(t[e])&&this.clearLocalUiStates(t[e])}},newBlock:function(t,e){var n=t._key,i=this.fieldsets[n];return{fields:i.fields?i.fields:null,tabs:i.tabs?i.tabs:null,blockKey:n,content:t,label:i.label,uniqueKey:e,preview:i.preview,showPreview:!1}}}};if(typeof a==="function"){a=a.options}Object.assign(a,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("k-field",{staticClass:"kBuilder",class:_vm.classObject,attrs:{"label":_vm.label}},[_c("k-draggable",{staticClass:"kBuilder__blocks k-grid",attrs:{"list":_vm.value,"move":_vm.onMove,"options":_vm.draggableOptions},on:{"update":_vm.onBlockMoved,"add":_vm.onBlockAdded,"remove":_vm.onBlockRemoved,"start":_vm.onStartDrag,"end":_vm.onDragEnd}},[_vm._l(_vm.value,function(blockValue,index){return _c("k-column",{key:blockValue._uid,staticClass:"kBuilder__column",attrs:{"width":_vm.columnWidth}},[!_vm.max||_vm.blockCount<_vm.max?_c("div",{staticClass:"kBuilder__inlineAddButton",class:{"kBuilder__inlineAddButton--horizontal":_vm.columnsCount==1,"kBuilder__inlineAddButton--vertical":_vm.columnsCount>1},on:{"click":function($event){_vm.onClickAddBlock(index)}}}):_vm._e(),_vm._v(" "),_c("builder-block",{attrs:{"page-id":_vm.pageId,"page-uid":_vm.pageUid,"encoded-page-id":_vm.encodedPageId,"endpoints":_vm.endpoints,"block":_vm.newBlock(blockValue,blockValue._uid),"index":index,"columns-count":_vm.columnsCount,"styles":_vm.cssContents[blockValue._key],"script":_vm.jsContents[blockValue._key],"parentPath":_vm.path},on:{"input":_vm.onBlockInput,"clone":_vm.cloneBlock,"delete":_vm.deleteBlock}}),_vm._v(" "),_vm.columnsCount%index==0&&_vm.columnsCount>1&&(!_vm.max||_vm.blockCount<_vm.max)?_c("div",{staticClass:"kBuilder__inlineAddButton kBuilder__inlineAddButton--vertical kBuilder__inlineAddButton--after",on:{"click":function($event){_vm.onClickAddBlock(index+1)}}}):_vm._e()],1)}),_vm._v(" "),!_vm.max||_vm.blockCount<_vm.max?_c("k-column",{attrs:{"width":_vm.columnWidth}},[_c("k-button",{staticClass:"kBuilder__addButton",attrs:{"icon":"add"},on:{"click":function($event){_vm.onClickAddBlock()}}},[_vm._v(_vm._s(_vm.addBlockButtonLabel))])],1):_vm._e()],2),_vm._v(" "),_c("k-dialog",{ref:"dialog",staticClass:"kBuilder__dialog",on:{"open":_vm.onOpenDialog,"close":_vm.onCloseDialog}},[_c("k-list",_vm._l(_vm.fieldsets,function(value,key){return _c("k-list-item",{key:key,class:["kBuilder__addBlockButton","kBuilder__addBlockButton--"+key],attrs:{"text":value.label},on:{"click":function($event){_vm.addBlock(key)}}},[_c("template",{slot:"options"},[_c("k-icon",{staticClass:"kBuilder__addBlockButtonIcon",attrs:{"type":"add"}})],1)],2)}),1)],1)],1)};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());panel.plugin("timoetting/k-builder",{fields:{builder:a}});})();