"use strict";const t=require("../../../../common/vendor.js"),e=require("./test.js"),r=require("./digit.js"),n=require("../config/config.js");function o(r,n=!1){return e.number(r)?n?`${r}px`:Number(r):/(rpx|upx)$/.test(r)?n?`${t.index.upx2px(parseInt(r))}px`:Number(t.index.upx2px(parseInt(r))):n?`${parseInt(r)}px`:parseInt(r)}function i(t=30){return new Promise((e=>{setTimeout((()=>{e()}),t)}))}function s(){return t.index.getSystemInfoSync().platform.toLowerCase()}function c(){return t.index.getSystemInfoSync()}function a(t){let e=this.$parent;for(;e;){if(!e.$options||e.$options.name===t)return e;e=e.$parent}return!1}function u(t,r="object"){if(e.empty(t)||"object"==typeof t&&"object"===r||"string"===r&&"string"==typeof t)return t;if("object"===r){const e=(t=d(t)).split(";"),r={};for(let t=0;t<e.length;t++)if(e[t]){const n=e[t].split(":");r[d(n[0])]=d(n[1])}return r}let n="";return"object"==typeof t&&t.forEach(((t,e)=>{const r=e.replace(/([A-Z])/g,"-$1").toLowerCase();n+=`${r}:${t};`})),d(n)}function p(t="auto",r=""){return r||(r=n.config.unit||"px"),"rpx"==r&&e.number(String(t))&&(t*=2),t=String(t),e.number(t)?`${t}${r}`:t}function f(t){if([null,void 0,NaN,!1].includes(t))return t;if("object"!=typeof t&&"function"!=typeof t)return t;const r=e.array(t)?[]:{};for(const e in t)t.hasOwnProperty(e)&&(r[e]="object"==typeof t[e]?f(t[e]):t[e]);return r}function l(t={},e={}){let r=f(t);if("object"!=typeof r||"object"!=typeof e)return!1;for(const n in e)e.hasOwnProperty(n)&&(n in r?null==e[n]||"object"!=typeof r[n]||"object"!=typeof e[n]?r[n]=e[n]:r[n].concat&&e[n].concat?r[n]=r[n].concat(e[n]):r[n]=l(r[n],e[n]):r[n]=e[n]);return r}function g(t=null,e="yyyy-mm-dd"){let r;r=t?/^\d{10}$/.test(t.toString().trim())?new Date(1e3*t):"string"==typeof t&&/^\d+$/.test(t.trim())?new Date(Number(t)):new Date("string"==typeof t?t.replace(/-/g,"/"):t):new Date;const n={y:r.getFullYear().toString(),m:(r.getMonth()+1).toString().padStart(2,"0"),d:r.getDate().toString().padStart(2,"0"),h:r.getHours().toString().padStart(2,"0"),M:r.getMinutes().toString().padStart(2,"0"),s:r.getSeconds().toString().padStart(2,"0")};for(const o in n){const[t]=new RegExp(`${o}+`).exec(e)||[];if(t){const r="y"===o&&2===t.length?2:0;e=e.replace(t,n[o].slice(r))}}return e}function d(t,e="both"){return t=String(t),"both"==e?t.replace(/^\s+|\s+$/g,""):"left"==e?t.replace(/^\s*/,""):"right"==e?t.replace(/(\s*$)/g,""):"all"==e?t.replace(/\s+/g,""):t}function y(t={},e=!0,r="brackets"){const n=e?"?":"",o=[];-1==["indices","brackets","repeat","comma"].indexOf(r)&&(r="brackets");for(const i in t){const e=t[i];if(!(["",void 0,null].indexOf(e)>=0))if(e.constructor===Array)switch(r){case"indices":for(let r=0;r<e.length;r++)o.push(`${i}[${r}]=${e[r]}`);break;case"brackets":default:e.forEach((t=>{o.push(`${i}[]=${t}`)}));break;case"repeat":e.forEach((t=>{o.push(`${i}=${t}`)}));break;case"comma":let t="";e.forEach((e=>{t+=(t?",":"")+e})),o.push(`${i}=${t}`)}else o.push(`${i}=${e}`)}return o.length?n+o.join("&"):""}function m(e,r=2e3){t.index.showToast({title:String(e),icon:"none",duration:r})}function h(t,e){const r=a.call(t,"u-form-item"),n=a.call(t,"u-form");r&&n&&n.validateField(r.prop,(()=>{}),e)}function $(t,e){if("object"!=typeof t||null==t)return"";if("string"!=typeof e||""===e)return"";if(-1!==e.indexOf(".")){const r=e.split(".");let n=t[r[0]]||{};for(let t=1;t<r.length;t++)n&&(n=n[r[t]]);return n}return t[e]}function b(t,e,r){if("object"!=typeof t||null==t)return;const n=function(t,e,r){if(1!==e.length)for(;e.length>1;){const o=e[0];t[o]&&"object"==typeof t[o]||(t[o]={}),e.shift(),n(t[o],e,r)}else t[e[0]]=r};if("string"!=typeof e||""===e);else if(-1!==e.indexOf(".")){const o=e.split(".");n(t,o,r)}else t[e]=r}function x(){const t=getCurrentPages();return`/${t[t.length-1].route||""}`}String.prototype.padStart||(String.prototype.padStart=function(t,e=" "){if("[object String]"!==Object.prototype.toString.call(e))throw new TypeError("fillString must be String");const r=this;if(r.length>=t)return String(r);const n=t-r.length;let o=Math.ceil(n/e.length);for(;o>>=1;)e+=e,1===o&&(e+=e);return e.slice(0,n)+r});const S={range:function(t=0,e=0,r=0){return Math.max(t,Math.min(e,Number(r)))},getPx:o,sleep:i,os:s,sys:c,random:function(t,e){if(t>=0&&e>0&&e>=t){const r=e-t+1;return Math.floor(Math.random()*r+t)}return 0},guid:function(t=32,e=!0,r=null){const n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),o=[];if(r=r||n.length,t)for(let i=0;i<t;i++)o[i]=n[0|Math.random()*r];else{let t;o[8]=o[13]=o[18]=o[23]="-",o[14]="4";for(let e=0;e<36;e++)o[e]||(t=0|16*Math.random(),o[e]=n[19==e?3&t|8:t])}return e?(o.shift(),`u${o.join("")}`):o.join("")},$parent:a,addStyle:u,addUnit:p,deepClone:f,deepMerge:l,shallowMerge:function t(e,r={}){if("object"!=typeof e||"object"!=typeof r)return!1;for(const n in r)r.hasOwnProperty(n)&&(n in e?null==r[n]||"object"!=typeof e[n]||"object"!=typeof r[n]?e[n]=r[n]:e[n].concat&&r[n].concat?e[n]=e[n].concat(r[n]):e[n]=t(e[n],r[n]):e[n]=r[n]);return e},error:function(t){},randomArray:function(t=[]){return t.sort((()=>Math.random()-.5))},timeFormat:g,timeFrom:function(t=null,e="yyyy-mm-dd"){null==t&&(t=Number(new Date)),10==(t=parseInt(t)).toString().length&&(t*=1e3);let r=(new Date).getTime()-t;r=parseInt(r/1e3);let n="";switch(!0){case r<300:n="刚刚";break;case r>=300&&r<3600:n=`${parseInt(r/60)}分钟前`;break;case r>=3600&&r<86400:n=`${parseInt(r/3600)}小时前`;break;case r>=86400&&r<2592e3:n=`${parseInt(r/86400)}天前`;break;default:n=!1===e?r>=2592e3&&r<31536e3?`${parseInt(r/2592e3)}个月前`:`${parseInt(r/31536e3)}年前`:g(t,e)}return n},trim:d,queryParams:y,toast:m,type2icon:function(t="success",e=!1){-1==["primary","info","error","warning","success"].indexOf(t)&&(t="success");let r="";switch(t){case"primary":case"info":r="info-circle";break;case"error":r="close-circle";break;case"warning":r="error-circle";break;default:r="checkmark-circle"}return e&&(r+="-fill"),r},priceFormat:function(t,e=0,n=".",o=","){t=`${t}`.replace(/[^0-9+-Ee.]/g,"");const i=isFinite(+t)?+t:0,s=isFinite(+e)?Math.abs(e):0,c=void 0===o?",":o,a=void 0===n?".":n;let u="";u=(s?r.round(i,s)+"":`${Math.round(i)}`).split(".");const p=/(-?\d+)(\d{3})/;for(;p.test(u[0]);)u[0]=u[0].replace(p,`$1${c}$2`);return(u[1]||"").length<s&&(u[1]=u[1]||"",u[1]+=new Array(s-u[1].length+1).join("0")),u.join(a)},getDuration:function(t,e=!0){const r=parseInt(t);return e?/s$/.test(t)?t:t>30?`${t}ms`:`${t}s`:/ms$/.test(t)?r:/s$/.test(t)?r>30?r:1e3*r:r},padZero:function(t){return`00${t}`.slice(-2)},formValidate:h,getProperty:$,setProperty:b,page:x,pages:function(){return getCurrentPages()}};exports.$parent=a,exports.addStyle=u,exports.addUnit=p,exports.deepClone=f,exports.deepMerge=l,exports.formValidate=h,exports.getProperty=$,exports.getPx=o,exports.index=S,exports.os=s,exports.page=x,exports.queryParams=y,exports.setProperty=b,exports.sleep=i,exports.sys=c,exports.toast=m;