import{r as t,c as i,h as e,g as s,H as o}from"./p-78e3ebb9.js";import{d as n}from"./p-d3c7f87d.js";import{c as r}from"./p-2fad2a65.js";function a(t){if(t){const i=/([\w-]*)\s*:\s*([^;]*)/g;const e={};let s;while(s=i.exec(t))e[`${s[1]}`]=s[2].trim();return e}}const c=".taro-picker-view-column-container{display:-ms-flexbox;display:flex;overflow:scroll;overflow-x:hidden;position:relative;-ms-flex-direction:column;flex-direction:column;-ms-flex:1;flex:1;text-align:center}.taro-picker-view-column-container::-webkit-scrollbar{display:none}";const l=class{constructor(e){t(this,e);this.onChange=i(this,"onselect",7);this.onSelectStart=i(this,"onselectstart",7);this.onSelectEnd=i(this,"onselectend",7);this.handleSelected=n((()=>{const t=this.el.childNodes;let i=0;let e="0";for(const s in t){const o=t[s];const n=o.offsetHeight;if(i+n/2>this.el.scrollTop){e=s;break}i+=n}this.el.scrollTo({top:i,behavior:"smooth"});this.onChange.emit({curIndex:this.col,selectedIndex:e});this.onSelectEnd.emit()}),500);this.col=undefined;this.initialPosition="0";this.paddingVertical=0;this.isInit=false;this.isMove=false}onScroll(t){if(!this.isMove){this.isMove=true;this.onSelectStart.emit()}this.handleSelected()}onMouseEnd(){if(!this.isMove)return;this.isMove=false;this.handleSelected()}onTouchEnd(){this.isMove=false;this.handleSelected()}componentDidUpdate(){if(!this.isInit){this.isInit=true;const t=this.el.childNodes;let i=0;let e=0;for(const s in t){const o=t[s];if(this.initialPosition===s||!o||typeof o.offsetHeight!=="number"){break}e+=o.offsetHeight;i++}this.el.scrollTo({top:e});if(i>=t.length){this.onChange.emit({curIndex:this.col,selectedIndex:i-1})}}}render(){const{paddingVertical:t=0}=this;return e(o,{class:"taro-picker-view-column-container",style:{"padding-top":`${t}px`,"padding-bottom":`${t}px`}})}get el(){return s(this)}};l.style=c;const d=".taro-picker-view-container{display:-ms-flexbox;display:flex;position:relative}.taro-picker-view-mask-container{display:-ms-flexbox;display:flex;position:absolute;left:0;right:0;top:0;bottom:0;-ms-flex-direction:column;flex-direction:column;pointer-events:none}.taro-picker-view-mask-indicator{display:-ms-flexbox;display:flex;border-top:1px solid #ddd;border-bottom:1px solid #ddd;height:50px}.taro-picker-view-mask-top{-ms-flex:1;flex:1;background-image:-webkit-gradient(linear, left top, left bottom, from(rgba(255, 255, 255, 0.95)), to(rgba(255, 255, 255, 0.6)));background-image:linear-gradient(to bottom, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.6))}.taro-picker-view-mask-bottom{-ms-flex:1;flex:1;background:-webkit-gradient(linear, left bottom, left top, from(rgba(255, 255, 255, 0.95)), to(rgba(255, 255, 255, 0.6)));background:linear-gradient(to top, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.6))}";const h=class{constructor(e){t(this,e);this.onChange=i(this,"change",7);this.onPickStart=i(this,"pickstart",7);this.onPickEnd=i(this,"pickend",7);this.indicatorStyle=undefined;this.indicatorClass=undefined;this.value=undefined;this.maskStyle=undefined;this.maskClass=undefined}onSelect(t){t.stopPropagation();if(t.target.tagName!=="TARO-PICKER-VIEW-COLUMN-CORE")return;let i=+t.detail.curIndex;let e=+t.detail.selectedIndex;this.value[i]=e;this.onChange.emit({value:this.value})}onSelectStart(t){t.stopPropagation();if(t.target.tagName!=="TARO-PICKER-VIEW-COLUMN-CORE")return;this.onPickStart.emit()}onPickerColEnd(t){t.stopPropagation();if(t.target.tagName!=="TARO-PICKER-VIEW-COLUMN-CORE")return;this.onPickEnd.emit()}componentDidLoad(){const t=this.el.querySelectorAll("taro-picker-view-column-core");t.forEach(((t,i)=>{var e;t.setAttribute("col",`${i}`);let s="0";if(!!this.value&&this.value.length>i){s=`${this.value[i]}`}const o=this.el.getBoundingClientRect().height;const n=((e=this.indicator)===null||e===void 0?void 0:e.offsetHeight)||0;const r=(o-n)/2;t.setAttribute("initial-position",`${s}`);t.setAttribute("padding-vertical",`${r}`)}))}componentDidRender(){this.el.childNodes.forEach((t=>{const i=t;if("TARO-PICKER-VIEW-COLUMN-CORE"!==i.tagName&&i.className!=="taro-picker-view-mask-container"){this.el.removeChild(t)}}))}render(){const t=r("taro-picker-view-mask-indicator",this.indicatorClass);const i=r("taro-picker-view-mask-top",this.maskClass);const s=r("taro-picker-view-mask-bottom",this.maskClass);const n=a(this.indicatorStyle);const c=a(this.maskStyle);const l=a(this.maskStyle);return e(o,{class:"taro-picker-view-container"},e("slot",null),e("div",{class:"taro-picker-view-mask-container"},e("div",{class:i,style:c}),e("div",{class:t,style:n,ref:t=>this.indicator=t}),e("div",{class:s,style:l})))}get el(){return s(this)}};h.style=d;export{l as taro_picker_view_column_core,h as taro_picker_view_core};
//# sourceMappingURL=p-0c60e4f5.entry.js.map