"use strict";const e=require("../../common/vendor.js"),l=require("./processChain.js");exports.useProcessChainScroll=function(t,o){const n=e.getCurrentInstance(),u=(null==n?void 0:n.proxy)||n,r=e.ref([]),c=e.ref(0),s=e.ref([0]),i=e.ref(0),a=e.ref(""),v=e.ref(""),d=e.ref(!0),f=e.ref(!1);let h=null;const p=()=>{clearTimeout(h),h=setTimeout((()=>{r.value.length&&e.nextTick$1((()=>{const l=e.index.createSelectorQuery().in(u);l.select(".content-scroll").boundingClientRect(),l.select(".content-scroll").scrollOffset(),l.selectAll(".node-section").boundingClientRect(),l.exec((e=>{const l=null==e?void 0:e[0],t=null==e?void 0:e[1],o=(null==e?void 0:e[2])||[];if(!l||!o.length)return;i.value=l.height||0;const n=(null==t?void 0:t.scrollTop)||0;s.value=o.map((e=>e.top-l.top+n))}))}))}),80)};return e.watch((()=>"function"==typeof o?o():null==o?void 0:o.value),(e=>{e||(p(),setTimeout(p,300))})),e.watch((()=>"function"==typeof t?t():null==t?void 0:t.value),(e=>(e=>{const t=(null==e?void 0:e.nodes)||[];r.value=l.mapProcessChainNodes(t),c.value=0,a.value="",p(),setTimeout(p,300)})(e)),{immediate:!0,deep:!0}),e.watch(c,(e=>{v.value="process-step-"+e,setTimeout((()=>{v.value=""}),300)})),e.watch((()=>r.value.length),(()=>p())),e.onReady((()=>{p(),setTimeout(p,300)})),{historyList:r,activeIndex:c,contentScrollIntoView:a,stepScrollIntoView:v,scrollWithAnimation:d,onContentScroll:e=>{if(f.value)return;const{scrollTop:l=0,scrollHeight:t=0}=e.detail||{};((e,l=0)=>{const t=r.value.length;if(!t)return;if(l>0&&i.value>0&&e+i.value>=l-60)return void(c.value!==t-1&&(c.value=t-1));const o=s.value;if(!o.length)return;let n=0;for(let u=o.length-1;u>=0;u--)if(e>=o[u]-80){n=u;break}n!==c.value&&(c.value=n)})(l,t),p()},onScrollToLower:()=>{const e=r.value.length;e>0&&c.value!==e-1&&(c.value=e-1)},scrollToNode:e=>{e<0||e>=r.value.length||(f.value=!0,d.value=!0,c.value=e,a.value="process-node-"+e,setTimeout((()=>{a.value="",f.value=!1,p()}),350))},scheduleMeasureLayout:p}};