File: /www/wwwroot/www.cytocare.cn/wp-content/plugins/blocksy-companion/static/bundle/sticky.js
!function(){"use strict";var t={n:function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,{a:r}),r},d:function(e,r){for(var i in r)t.o(r,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:r[i]})},o:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}},e=window.ctEvents,r=t.n(e),i=window.ctFrontend;function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=Array(e);r<e;r++)i[r]=t[r];return i}function o(t){return function(t){if(Array.isArray(t))return n(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return n(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var a=function(t,e,r){return Math.max(t,Math.min(e,r))},c=function(t,e,r){return e[0]+(e[1]-e[0])/(t[1]-t[0])*(r-t[0])},s=function(t){var e=getComputedStyle(t),r=getComputedStyle(t.firstElementChild),i=parseFloat(e.borderTopWidth)+parseFloat(e.borderBottomWidth)+parseFloat(r.borderTopWidth)+parseFloat(r.borderBottomWidth),n=parseFloat(e.getPropertyValue("--height"));if(t.querySelector('[data-items] > [data-id="logo"]')){var o=getComputedStyle(t.querySelector('[data-items] > [data-id="logo"]')),a=parseFloat(o.height);if(a+=parseFloat(o.marginTop)+parseFloat(o.marginBottom),t.querySelector(".site-logo-container")){var c=getComputedStyle(t.querySelector(".site-logo-container")),s=parseFloat(c.getPropertyValue("--logo-shrink-height")||0);s>0&&(a=a-s+parseFloat(c.getPropertyValue("--logo-max-height")||50))}a>n&&(n=a)}var l=['[data-items] > [data-id*="widget-area"]','[data-items] > [data-id*="content-block"]','[data-items] > [data-id*="text"]'].concat(['[data-items] > [data-id*="menu"]']).reduce((function(e,r){if(t.querySelector(r)){var i=getComputedStyle(t.querySelector(r)),n=parseFloat(i.height);if(n>e)return n}return e}),0);return l>n&&(n=l),n+i},l=function(t){if(t.blcInitialHeight)return t.blcInitialHeight;var e=t.firstElementChild;t.firstElementChild.firstElementChild&&(e=t.firstElementChild.firstElementChild);var r=e.getBoundingClientRect().height;return t.blcInitialHeight=r,r},d=function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t.blcStickyHeight)return t.blcStickyHeight;var r=l(t),i=getComputedStyle(t),n=getComputedStyle(t.firstElementChild);if(t.closest('[data-sticky*="yes"]')){var o=parseFloat(i.borderTopWidth)+parseFloat(i.borderBottomWidth)+parseFloat(n.borderTopWidth)+parseFloat(n.borderBottomWidth);e||(o=0);var a=t.getBoundingClientRect().height-o,c=s(t);if(!(t.querySelector(".site-logo-container")&&parseFloat(getComputedStyle(t.querySelector(".site-logo-container")).getPropertyValue("--logo-sticky-shrink")||1)<1)&&(Math.round(a)!==Math.round(r)||Math.round(r)>Math.round(c)))return t.blcStickyHeight=t.getBoundingClientRect().height,a}var d=100;t.dataset.row.includes("middle")&&(d=i.getPropertyValue("--sticky-shrink"));return d&&(r*=parseFloat(d)/100),r},u=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){return 0},e=document.querySelector(".ct-floating-bar");e&&e.style.setProperty("--header-sticky-height-animated",t())},y=null,f=function(t){var e=t.stickyContainer,r=t.startPosition;o(e.querySelectorAll('[data-row*="middle"]')).map((function(t){if(t.querySelector('[data-id="logo"] .site-logo-container')){var e=t.querySelector('[data-id="logo"] .site-logo-container'),i=function(t){var e=t.logo,r=t.row;if(y)return y;var i=parseFloat(getComputedStyle(e).getPropertyValue("--logo-max-height")||50),n=parseFloat(getComputedStyle(e).getPropertyValue("--logo-sticky-shrink").toString().replace(",",".")||1),o=l(r),a=d(r);return y={initialHeight:i,stickyShrink:n,rowInitialHeight:o,rowStickyHeight:a}}({logo:e,row:t}),n=i.initialHeight,o=i.stickyShrink,s=i.rowInitialHeight,u=i.rowStickyHeight,f=n*o;1!==o&&e.style.setProperty("--logo-shrink-height","".concat(c([r,r+Math.abs(s===u?n-f:s-u)],[1,o],a(r,r+Math.abs(s===u?n-f:s-u),scrollY))*n,"px"))}}))},h=null,g=function(t){var e=t.stickyContainer,r=(t.containerInitialHeight,t.startPosition);e.querySelector('[data-row*="middle"]')&&[e.querySelector('[data-row*="middle"]')].map((function(t){var e=function(t){var e=t.row;if(h)return h;var r=l(e),i=d(e);return h={rowInitialHeight:r,rowStickyHeight:i}}({row:t}),i=e.rowInitialHeight,n=e.rowStickyHeight;if(i!==n){var o=n;o=c([r,r+Math.abs(i-n)],[i,n],a(r,r+Math.abs(i-n),scrollY)),t.style.setProperty("--shrink-height","".concat(Math.round(o),"px"))}}))},m=function(t){var e=t.stickyContainer,r=o(e.querySelectorAll("[data-row]")).reduce((function(t,e){return t+d(e,!1)}),0);return{stickyContainerHeight:r,stickyContainerHeightAbsolute:r+parseFloat(getComputedStyle(e).top)}},p=null,k=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"yes";Array.from(t.querySelectorAll("[data-row][data-transparent-row]")).map((function(t){t.dataset.transparentRow=e}))},v=null,w={},S=null,C=null,b=!1,x=function(){h=null,y=null,v=null,S=null,C=null,q=null,b=!1};if(r().on("blocksy:sticky:compute",(function(){setTimeout((function(){x(),P()}),100)})),window.wp&&wp.customize&&wp.customize.selectiveRefresh){var A=!1;wp.customize.selectiveRefresh.bind("partial-content-rendered",(function(t){A||(A=!0,setTimeout((function(){x(),b=!0,P(),A=!1}),500))}))}var H=function(t){-1===t.dataset.sticky.indexOf("shrink")&&t.dataset.sticky.indexOf("auto-hide");var e=t.closest("header").getBoundingClientRect().top+scrollY;if(e>0){var r=document.elementFromPoint(0,3);r&&function(t){for(var e=[];t&&t!==document;t=t.parentNode)e.push(t);return e}(r).map((function(t){return getComputedStyle(t).position})).indexOf("fixed")>-1&&(e-=r.getBoundingClientRect().height)}-1===t.dataset.sticky.indexOf("shrink")&&-1===t.dataset.sticky.indexOf("auto-hide")&&(e+=200);var i=t.parentNode,n=getComputedStyle(document.body),a=parseFloat(n.getPropertyValue("--header-sticky-offset")||0);if(a+=parseFloat(n.getPropertyValue("--theme-frame-size"))||0,1===i.parentNode.children.length||i.parentNode.children[0].classList.contains("ct-sticky-container"))return e>0?e-a:e;var c=Array.from(i.parentNode.children).reduce((function(t,e,r){return t.indexOf(0)>-1||!e.dataset.row?[].concat(o(t),[0]):[].concat(o(t),[e.classList.contains("ct-sticky-container")?0:e.getBoundingClientRect().height])}),[]).reduce((function(t,e){return t+e}),e);return c>0?c-a:c},q=null,P=function(){if(q!==scrollY){var t=document.querySelector('[data-device="'.concat((0,i.getCurrentScreen)(),'"] [data-sticky]'));if(t){var e=(0,i.getCurrentScreen)({withTablet:!0}),r=w[e],n=!r||b;r&&!b||(w[e]=o(t.querySelectorAll("[data-row]")).reduce((function(t,e){return t+s(e)}),0),r=w[e]),n&&(b=!1,t.parentNode.style.height="".concat(r,"px"));var c=v;null===c&&(c=H(t),v=c);var l=S;if(null===l)l=t.closest("[data-device]").getBoundingClientRect().height,S=l;var y=C,h=t.dataset.sticky.split(":").filter((function(t){return"yes"!==t&&"no"!==t&&"fixed"!==t}));y||(y=o(t.querySelectorAll("[data-row]")).reduce((function(t,e){return t+d(e)}),0),C=parseInt(y),u((function(){return-1===h.indexOf("auto-hide")?y>o(t.querySelectorAll("[data-row]")).reduce((function(t,e){return t+s(e)}),0)?"".concat(y,"px"):"".concat(o(t.querySelectorAll("[data-row]")).reduce((function(t,e){return t+d(e)}),0),"px"):"0px"})));var x=c>0&&Math.abs(window.scrollY-c)<5||window.scrollY>c;h.indexOf("shrink")>-1&&(x=c>0?window.scrollY>=c:window.scrollY>0),setTimeout((function(){x&&-1===document.body.dataset.header.indexOf("shrink")&&(document.body.dataset.header="".concat(document.body.dataset.header,":shrink")),!x&&document.body.dataset.header.indexOf("shrink")>-1&&(document.body.dataset.header=document.body.dataset.header.replace(":shrink",""))}),300);var A=scrollY;h.indexOf("shrink")>-1&&function(t){var e=t.containerInitialHeight,r=t.stickyContainer,i=(t.stickyContainerHeight,t.isSticky),n=t.startPosition,a=t.stickyComponents;if(0===n&&0===window.scrollY&&(r.dataset.sticky=["fixed"].concat(o(a)).join(":")),i){if(a.indexOf("yes")>-1)return;-1===r.dataset.sticky.indexOf("yes")&&(k(r,"no"),r.dataset.sticky=["yes"].concat(o(a)).join(":")),f({stickyContainer:r,startPosition:n}),g({stickyContainer:r,containerInitialHeight:e,startPosition:n})}else Array.from(r.querySelectorAll("[data-row]")).map((function(t){return t.removeAttribute("style")})),Array.from(r.querySelectorAll('[data-row*="middle"] .site-logo-container')).map((function(t){return t.removeAttribute("style")})),k(r,"yes"),0===n&&window.scrollY<=0?r.dataset.sticky=["fixed"].concat(o(a)).join(":"):r.dataset.sticky=a.join(":")}({stickyContainer:t,stickyContainerHeight:y,containerInitialHeight:r,isSticky:x,startPosition:c,stickyComponents:h}),h.indexOf("auto-hide")>-1&&function(t){var e=t.currentScrollY,r=t.stickyContainer,i=t.containerInitialHeight,n=t.headerInitialHeight,c=t.startPosition,s=t.isSticky,l=t.stickyComponents;s&&e-t.prevScrollY==0&&u((function(){return"0px"})),s?-1===r.dataset.sticky.indexOf("yes")&&e>2*n+c&&(r.dataset.sticky=["yes"].concat(o(l)).join(":"),f({stickyContainer:r,startPosition:c}),g({stickyContainer:r,containerInitialHeight:i,startPosition:c}),k(r,"no"),document.body.removeAttribute("style")):(Array.from(r.querySelectorAll("[data-row]")).map((function(t){return t.removeAttribute("style")})),Array.from(r.querySelectorAll('[data-row*="middle"] .site-logo-container')).map((function(t){return t.removeAttribute("style")})),r.dataset.sticky=o(l).join(":"),k(r,"yes"),u((function(){return"0px"})),p=null),null===p&&(p=1e3);var d=p+t.prevScrollY-e,y=0;if(e>2*n+c||r.dataset.sticky.indexOf("yes")>-1){if(e<=c)y=0;else if(e>t.prevScrollY){var h=m({stickyContainer:r}).stickyContainerHeightAbsolute;y=Math.abs(d)>h?-h:d}else y=d>0?0:d;r.style.transform="translateY(".concat(y,"px)"),p=y}else r.removeAttribute("style");r.dataset.sticky.indexOf("yes")>-1&&(e<=c||e>t.prevScrollY||(f({stickyContainer:r,startPosition:c}),g({stickyContainer:r,containerInitialHeight:i,startPosition:c}))),u((function(){var t=m({stickyContainer:r}).stickyContainerHeight,e=a(0,t-Math.abs(y),t);return-1===r.dataset.sticky.indexOf("yes")&&(e=0),"".concat(e,"px")}))}({stickyContainer:t,isSticky:x,startPosition:c,stickyComponents:h,containerInitialHeight:r,stickyContainerHeight:y,headerInitialHeight:l,currentScrollY:A,prevScrollY:q}),(h.indexOf("slide")>-1||h.indexOf("fade")>-1)&&function(t){var e=t.stickyContainer,r=t.isSticky,i=t.startPosition,n=t.stickyComponents;r?(-1===e.dataset.sticky.indexOf("yes")&&(e.dataset.sticky=["yes-start"].concat(o(n)).join(":"),setTimeout((function(){e.dataset.sticky=e.dataset.sticky.replace("yes-start","yes-end"),setTimeout((function(){e.dataset.sticky=e.dataset.sticky.replace("yes-end","yes")}),200)}),1)),k(e,"no")):-1===e.dataset.sticky.indexOf("yes-hide")&&e.dataset.sticky.indexOf("yes:")>-1&&(Math.abs(window.scrollY-i)>10?(e.dataset.sticky=n.join(":"),setTimeout((function(){Array.from(e.querySelectorAll("[data-row]")).map((function(t){return t.removeAttribute("style")}))}),300),k(e,"yes")):(e.dataset.sticky=["yes-hide-start"].concat(o(n)).join(":"),requestAnimationFrame((function(){e.dataset.sticky=e.dataset.sticky.replace("yes-hide-start","yes-hide-end"),setTimeout((function(){e.dataset.sticky=n.join(":"),setTimeout((function(){Array.from(e.querySelectorAll("[data-row]")).map((function(t){return t.removeAttribute("style")}))}),300),k(e,"yes")}),200)}))))}({stickyContainer:t,isSticky:x,startPosition:c,stickyComponents:h}),q=A}}},O=function(){if(document.querySelector("header [data-sticky]")){var t=window.width;window.addEventListener("resize",(function(e){window.width!==t&&(t=window.width,x(),P(e),r().trigger("ct:header:update"))}),!1),window.addEventListener("orientationchange",(function(t){x(),P(t),r().trigger("ct:header:update")})),window.addEventListener("scroll",P,!1),window.addEventListener("load",P,!1),P()}};document.body.className.indexOf("e-preview")>-1?setTimeout((function(){O()}),500):O(),(0,i.registerDynamicChunk)("blocksy_sticky_header",{mount:function(t){}})}();