"use strict";const e=require("../../../../../common/vendor.js"),t=require("../config/index.js"),n=require("./z-paging-constant.js"),r="Z-PAGING-REFRESHER-TIME-STORAGE-KEY";let o=null,c=!1,i=null;const u={};function a(){return e.index.getStorageSync(r)}function s(t){return e.index.upx2px(t)}function l(){return(new Date).getTime()}function f(e){return 1===(e=e.toString()).length?"0"+e:e}const g={gc:function(n,r){return()=>{if(function(){if(c)return;t.zLocalConfig&&Object.keys(t.zLocalConfig).length&&(o=t.zLocalConfig);!o&&e.index.$zp&&(o=e.index.$zp.config);o=o?Object.keys(o).reduce(((e,t)=>(e[function(e){return e.replace(/-([a-z])/g,((e,t)=>t.toUpperCase()))}(t)]=o[t],e)),{}):null,c=!0}(),!o)return r;const i=o[n];return void 0===i?r:i}},setRefesrherTime:function(t,n){const o=a()||{};o[n]=t,e.index.setStorageSync(r,o)},getRefesrherFormatTimeByKey:function(e,t){const n=function(e){const t=a();return t&&t[e]?t[e]:null}(e),r=n?function(e,t){const n=new Date(e),r=new Date,o=new Date(e).setHours(0,0,0,0),c=(new Date).setHours(0,0,0,0),i=o-c;let u="";const a=function(e){const t=e.getHours(),n=e.getMinutes();return`${f(t)}:${f(n)}`}(n);u=0===i?t.today:-864e5===i?t.yesterday:function(e,t=!0){const n=e.getFullYear(),r=e.getMonth()+1,o=e.getDate();return t?`${n}-${f(r)}-${f(o)}`:`${f(r)}-${f(o)}`}(n,n.getFullYear()!==r.getFullYear());return`${u} ${a}`}(n,t):t.none;return`${t.title}${r}`},getTouch:function(e){let t=null;if(e.touches&&e.touches.length)t=e.touches[0];else if(e.changedTouches&&e.changedTouches.length)t=e.changedTouches[0];else{if(!e.datail||e.datail=={})return{touchX:0,touchY:0};t=e.datail}return{touchX:t.clientX,touchY:t.clientY}},getTouchFromZPaging:function e(t){if(t&&t.tagName&&"BODY"!==t.tagName&&"UNI-PAGE-BODY"!==t.tagName){const n=t.classList;return n&&n.contains("z-paging-content")?{isFromZp:!0,isPageScroll:n.contains("z-paging-content-page"),isReachedTop:n.contains("z-paging-reached-top"),isUseChatRecordMode:n.contains("z-paging-use-chat-record-mode")}:e(t.parentNode)}return{isFromZp:!1}},getParent:function e(t){return t?t.$refs.paging?t:e(t.$parent):null},convertToPx:function(e){if("[object Number]"===Object.prototype.toString.call(e))return e;let t=!1;return-1!==e.indexOf("rpx")||-1!==e.indexOf("upx")?(e=e.replace("rpx","").replace("upx",""),t=!0):-1!==e.indexOf("px")&&(e=e.replace("px","")),isNaN(e)?0:Number(t?s(e):e)},getTime:l,getInstanceId:function(){const e=[];for(let t=0;t<10;t++)e[t]="0123456789abcdef".substr(Math.floor(16*Math.random()),1);return e.join("")+l()},consoleErr:function(e){console.error(`[z-paging]${e}`)},delay:function(e,t=n.c.delayTime,r){const o=setTimeout(e,t);return r&&(u[r]&&clearTimeout(u[r]),u[r]=o),o},wait:function(e){return new Promise((t=>{setTimeout(t,e)}))},isPromise:function(e){return"[object Promise]"===Object.prototype.toString.call(e)},addUnit:function(e,t){if("[object String]"===Object.prototype.toString.call(e)){let t=e;t=t.replace("rpx","").replace("upx","").replace("px",""),-1===e.indexOf("rpx")&&-1===e.indexOf("upx")&&-1!==e.indexOf("px")&&(t=2*parseFloat(t)),e=t}return"rpx"===t?e+"rpx":e/2+"px"},deepCopy:function e(t){if("object"!=typeof t||null===t)return t;let n=Array.isArray(t)?[]:{};for(let r in t)t.hasOwnProperty(r)&&(n[r]=e(t[r]));return n},rpx2px:s,getSystemInfoSync:function(t=!1){if(t&&i)return i;const{deviceInfo:n,appBaseInfo:r,windowInfo:o}=["DeviceInfo","AppBaseInfo","WindowInfo"].reduce(((t,n)=>{const r=`get${n}`;return e.index[r]&&e.index.canIUse(r)&&(t[n.charAt(0).toLowerCase()+n.slice(1)]=e.index[r]()),t}),{});return i=n&&r&&o?{...n,...r,...o}:e.index.getSystemInfoSync(),i},useBufferedInsert:function(e,t=50){let n=[],r=null,o=[];return function(c,...i){const u="[object Array]"!==Object.prototype.toString.call(c)?[c]:c;n.push(...u),o=i,r||(r=setTimeout((()=>{e(1===n.length?n[0]:n,...o),n=[],r=null}),1===n.length?10:t))}}};exports.u=g;
