import{r as t,d as s,h as r,c as e,H as i}from"./p-38dcedc4.js";import{g as o}from"./p-202e7480.js";import{a as h,b as n,h as a}from"./p-c563b4de.js";const c=class{constructor(r){t(this,r),this.ionItemReorder=s(this,"ionItemReorder",7),this.lastToIndex=-1,this.cachedHeights=[],this.scrollElTop=0,this.scrollElBottom=0,this.scrollElInitial=0,this.containerTop=0,this.containerBottom=0,this.state=0,this.disabled=!0}disabledChanged(){this.gesture&&this.gesture.enable(!this.disabled)}async connectedCallback(){const t=this.el.closest("ion-content");t&&(this.scrollEl=await t.getScrollElement()),this.gesture=(await import("./p-101feae9.js")).createGesture({el:this.el,gestureName:"reorder",gesturePriority:110,threshold:0,direction:"y",passive:!1,canStart:t=>this.canStart(t),onStart:t=>this.onStart(t),onMove:t=>this.onMove(t),onEnd:()=>this.onEnd()}),this.disabledChanged()}disconnectedCallback(){this.onEnd(),this.gesture&&(this.gesture.destroy(),this.gesture=void 0)}complete(t){return Promise.resolve(this.completeSync(t))}canStart(t){if(this.selectedItemEl||0!==this.state)return!1;const s=t.event.target.closest("ion-reorder");if(!s)return!1;const r=l(s,this.el);return!!r&&(t.data=r,!0)}onStart(t){t.event.preventDefault();const s=this.selectedItemEl=t.data,r=this.cachedHeights;r.length=0;const e=this.el,i=e.children;if(!i||0===i.length)return;let o=0;for(let t=0;tt);r++);return r}reorderMove(t,s){const r=this.selectedItemHeight,e=this.el.children;for(let i=0;it&&i<=s?o=`translateY(${-r}px)`:i=s&&(o=`translateY(${r}px)`),e[i].style.transform=o}}autoscroll(t){if(!this.scrollEl)return 0;let s=0;return tthis.scrollElBottom&&(s=p),0!==s&&this.scrollEl.scrollBy(0,s),this.scrollEl.scrollTop-this.scrollElInitial}render(){const t=o(this);return r(i,{class:{[t]:!0,"reorder-enabled":!this.disabled,"reorder-list-active":0!==this.state}})}get el(){return e(this)}static get watchers(){return{disabled:["disabledChanged"]}}},d=t=>t.$ionIndex,l=(t,s)=>{let r;for(;t;){if(r=t.parentElement,r===s)return t;t=r}},u=60,p=10,f="reorder-selected",m=(t,s,r)=>{const e=t[s];return t.splice(s,1),t.splice(r,0,e),t.slice()};c.style=".reorder-list-active>*{transition:transform 300ms;will-change:transform}.reorder-enabled{user-select:none}.reorder-enabled ion-reorder{display:block;cursor:grab;pointer-events:all;touch-action:none}.reorder-selected,.reorder-selected ion-reorder{cursor:grabbing}.reorder-selected{position:relative;transition:none !important;box-shadow:0 0 10px rgba(0, 0, 0, 0.4);opacity:0.8;z-index:100}.reorder-visible ion-reorder .reorder-icon{transform:translate3d(0, 0, 0)}";export{c as ion_reorder_group}