import"./drag_and_drop.js";import{w as n}from"./dom.js";const s={data(){return{draggedContainerClass:"drag-and-drop-dragged-container",draggedContainerClassDrop:"drag-and-drop-dragged-container_drop",draggedContainerTrashClass:"drag-and-drop-dragged-container__trash",draggedContainerItemClass:"drag-and-drop-dragged-container__item",draggedWrapperClass:"drag-and-drop-dragged-container__item-wrapper",pointerPosition:{y:null,x:null},isEnterDropContainer:!1}},mounted(){document.addEventListener("dragstart",this._onDragStart,!1),document.addEventListener("dragend",this.onDragEnd,!1),this.createDraggedContainerElement(),n(()=>{this.$el.querySelectorAll("[drag-container]").forEach(e=>{window.GamefaceDnD.enableDrag(e)})})},unmounted(){document.removeEventListener("dragstart",this._onDragStart,!1),document.removeEventListener("dragend",this.onDragEnd,!1),this.removeDraggedContainerElement()},methods:{createDraggedContainerElement(){const e=document.createElement("div"),r=document.createElement("div"),t=document.createElement("div");e.classList.add(this.draggedContainerClass),r.classList.add(this.draggedContainerTrashClass),t.classList.add(this.draggedWrapperClass),document.body.appendChild(e),e.appendChild(r),e.appendChild(t),n(()=>{this.draggedContainerElement=document.querySelector(`.${this.draggedContainerClass}`),this.draggedWrapper=document.querySelector(`.${this.draggedWrapperClass}`)})},removeDraggedContainerElement(){this.draggedContainerElement&&this.draggedContainerElement.remove()},showDragged(e){this.draggedContainerElement&&(e.classList.add(this.draggedContainerItemClass),this.draggedWrapper.appendChild(e),this.draggedContainerElement.style.opacity="1")},hideDragged(){this.draggedContainerElement&&(this.draggedContainerElement.style.opacity="0",this.draggedWrapper.innerHTML="")},_onDragStart(e){this.onDragStart(e.target)}},watch:{pointerPosition:{handler(e){if(!this.draggedContainerElement)return;const{x:r,y:t}=e,a={x:`${r}px`,y:`${t}px`};(r===null||t===null)&&(a.x="-100%",a.y="-100%"),this.draggedContainerElement.style.left=a.x,this.draggedContainerElement.style.top=a.y},deep:!0},isEnterDropContainer(e){this.draggedContainerElement&&(e?this.draggedContainerElement.classList.add(this.draggedContainerClassDrop):this.draggedContainerElement.classList.remove(this.draggedContainerClassDrop))}}};export{s as _};
