ray-template/js/utils-XwSDXJUe.js

2 lines
8.6 KiB
JavaScript

import{o as A,c as _}from"./lodash-es@4.17.21-Dos9GOhk.js";import{u as x,a as C,b as I,L as $,S as v,A as h,c as R}from"./hooks-DxjADXf2.js";import{c as l}from"./currency.js@2.0.4-9OAR_aOO.js";import"./dayjs@1.11.10-BYZwCyGy.js";import"./awesome-qr@2.1.5-rc.0-Ds7AaOTE.js";import"./vue-hooks-plus@1.9.0_vue@3.4.26-C_BRgauB.js";import"./lodash@4.17.21-CM7ROh5r.js";import"./js-cookie@3.0.5-Z_8Sd105.js";import"./screenfull@5.2.0-DuGDi0R7.js";import"./print-js@1.6.0-C3lAJnMa.js";const G=(e,r)=>{var i;const{domToImageOptions:t,printOptions:s}=r??{},{create:n}=x(e,{...t,beforeCreate:o=>{var a,c;(a=t==null?void 0:t.beforeCreate)==null||a.call(t,o),(c=window.$loadingBar)==null||c.start()},created(o,a){var c,f;(c=t==null?void 0:t.created)==null||c.call(t,o,a),(f=window.$loadingBar)==null||f.finish()},createdError(o){var a,c;(a=t==null?void 0:t.createdError)==null||a.call(t,o),(c=window.$loadingBar)==null||c.error()}});(i=n("jpeg"))==null||i.then(o=>{const{print:a}=C(o,{type:"image",base64:!0,targetStyles:["*"],...A(s,["type","base64"])});a()})},L=".n-menu-item-content--selected",P="n-menu-item",H=()=>{const e=d($),r=e==null?void 0:e.querySelector(L),t=d(v);let s=0;const n=e==null?void 0:e.querySelector(P);if(t){const{height:i}=t.getBoundingClientRect();s=i}if(r&&e){const i=I(),{top:o}=e.getBoundingClientRect(),{top:a}=r.getBoundingClientRect(),c=e.scrollTop,f=n?parseInt(window.getComputedStyle(n).marginTop):6;i({top:a-o+c-s-f,left:0,behavior:"smooth"})}};var m=(e=>(e.Windows="Windows",e.MacOS="MacOS",e.Linux="Linux",e.Android="Android",e.IOS="IOS",e.Unknown="Unknown",e))(m||{}),k={VITE_APP_URL:"/",VITE_APP_OFFICE_PROXY_URL:"https://office.yka.one/",VITE_APP_OFFICE_SCRIPT_URL:"https://office.yka.one/web-apps/apps/api/documents/api.js",BASE_URL:"/ray-template/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const J=()=>k,U=(e,r)=>{const t=document.createElement("a");t.href=e,t.download=r,t.style.display="none",document.body.appendChild(t),t.click(),document.body.removeChild(t)},S=(e,r)=>Object.prototype.toString.call(e).includes(r),Q=(e=16,r=62)=>{const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),s=[],n=window.crypto||window.msCrypto;let i=0;for(i=0;i<e;i++){const o=new Uint32Array(1);n.getRandomValues(o);const a=o[0]%r;s.push(t[a])}return s.join("")},Z=(e,r)=>new Promise((t,s)=>{let n;try{if(typeof e=="string")return U(e,r),t();if(e instanceof ArrayBuffer)n=new Blob([new Uint8Array(e)],{type:"application/octet-stream"});else if(e instanceof File||e instanceof Blob)n=e;else return s(new Error("downloadAnyFile: Unsupported data type."));const i=URL.createObjectURL(n),o=document.createElement("a");o.href=i,o.download=r,o.style.display="none";const a=()=>{URL.revokeObjectURL(i),document.body.removeChild(o)};return o.addEventListener("load",()=>(a(),t())),o.addEventListener("error",c=>(a(),s(c))),document.body.appendChild(o),o.click(),t()}catch(i){return s(i)}}),N=()=>{const e=navigator.userAgent;return/windows/i.test(e)?m.Windows:/macintosh|mac os x/i.test(e)?m.MacOS:/linux/i.test(e)?m.Linux:/android/i.test(e)?m.Android:/iphone|ipad|ipod/i.test(e)?m.IOS:m.Unknown},z=(e,r)=>{const t=e.split("?").filter(Boolean)[0],s=r.split("?").filter(Boolean)[0],n=/\/$/;return t.replace(n,"")===s.replace(n,"")};function ee(e,r="sessionStorage",t){const{prefix:s,prefixKey:n}=t??{},i=s?n||h:"",o=r==="localStorage"?window.localStorage:window.sessionStorage;return!!Object.keys(o).find(a=>a===i+e)}function te(e,r,t="sessionStorage",s){if(!e){console.error(`[setStorage]: Failed to set stored data: key ${e} is empty`);return}const{prefix:n,prefixKey:i}=s??{},o=n?i||h:"";try{const a=JSON.stringify(r);t==="localStorage"?window.localStorage.setItem(o+e,a):window.sessionStorage.setItem(o+e,a)}catch(a){console.error(`[setStorage]: Failed to set stored data for key '${e}'`,a)}}function re(e,r="sessionStorage",t){const{prefix:s,prefixKey:n,defaultValue:i}=t??{},o=s?n||h:"";try{const a=r==="localStorage"?window.localStorage.getItem(o+e):window.sessionStorage.getItem(o+e);return a===null?i??null:JSON.parse(a)}catch(a){return console.error(`[getStorage]: Failed to get stored data for key '${e}'`,a),i??null}}const ne=(e,r,t)=>{if(!e){console.error(`[removeStorage]: Failed to remove stored data: key ${e} is empty or undefined`);return}const{prefix:s,prefixKey:n}=t??{},i=s?n||h:"",o=Object.keys(window.localStorage),a=Object.keys(window.sessionStorage),c=(f,w)=>{(f?[...a,...o]:w==="localStorage"?o:a).forEach(p=>{e==="__all__"?(window.sessionStorage.removeItem(i+p),window.localStorage.removeItem(i+p)):w==="localStorage"?window.localStorage.removeItem(i+p):window.sessionStorage.removeItem(i+p)})};switch(e){case"__all__":c(!0);break;case"__all_sessionStorage__":c(!1,"sessionStorage");break;case"__all_localStorage__":c(!1,"localStorage");break;default:r==="localStorage"?window.localStorage.removeItem(i+e):window.sessionStorage.removeItem(i+e);break}},oe=(e,r)=>{const t=()=>{const n=d(e);n&&(typeof r=="string"?r.trim().split(" "):r).forEach(o=>{o&&n.classList.add(o)})},s=Vue.watch(()=>d(e),t,{immediate:!0});g(s)},se=(e,r)=>{const t=()=>{const n=d(e);if(n)if(r==="removeAllClass"){const i=n.classList;i.forEach(o=>i.remove(o))}else(typeof r=="string"?r.trim().split(" "):r).forEach(o=>{o&&n.classList.remove(o)})},s=Vue.watch(()=>d(e),t,{immediate:!0});g(s)},ie=(e,r)=>{const t=Vue.ref(!1),s=()=>{const i=d(e);if(!i)t.value=!1;else{const o=i.className,a=typeof r=="string"?r.trim().split(" ").filter(c=>c!==""):r;t.value=a.some(c=>o.includes(c))}},n=Vue.watch(()=>d(e),s,{immediate:!0});return g(n),t},V=e=>{const r=["webkit","moz","ms","o"],t={};return r.forEach(s=>{t[`${s}${e.charAt(0).toUpperCase()}${e.slice(1)}`]=e}),t[e]=e,t},ae=(e,r)=>{const t=(i,o)=>{i.split(";").forEach(a=>{const[c,f]=a.split(":");if(c&&f){const w=c.trim(),E=f.trim();if(c.startsWith("--"))o.style.setProperty(w,E);else if(c.startsWith("-"))o.style[c]=f;else{const p=V(w);Object.keys(p).forEach(b=>{o.style[b]=p[b]}),o.style[w]=E}}})},s=()=>{const i=d(e);i&&(S(r,"String")?t(r,i):S(r,"Array")?r.forEach(o=>{t(o,i)}):Object.keys(r).forEach(a=>{t(`${a}: ${r[a]}`,i)}))},n=Vue.watch(()=>d(e),s,{immediate:!0});g(n)},ce=(e,r=1)=>{if(e.includes("rgba"))return e;if(e.includes("rgb"))return e.replace("rgb","rgba").replace(")",`, ${r})`);if(e.includes("#")){const t=e.replace("#","");switch(t.length){case 3:return`rgba(${parseInt(t[0]+t[0],16)}, ${parseInt(t[1]+t[1],16)}, ${parseInt(t[2]+t[2],16)}, ${r})`;case 6:return`rgba(${parseInt(t.slice(0,2),16)}, ${parseInt(t.slice(2,4),16)}, ${parseInt(t.slice(4,6),16)}, ${r})`;case 8:return`rgba(${parseInt(t.slice(0,2),16)}, ${parseInt(t.slice(2,4),16)}, ${parseInt(t.slice(4,6),16)}, ${(parseInt(t.slice(6,8),16)/255).toFixed(2)})`;default:return e}}return e},le=(e,r)=>{const{defaultElement:t}=r||{};if(!e)return t?[t]:null;const s=e.startsWith("attr:")?`[${e.replace("attr:","")}]`:e;try{const n=Array.from(document.querySelectorAll(s));return!n.length&&t?[t]:n}catch(n){return console.error(`[queryElements]: Failed to get elements for selector '${e}'`,n),t?[t]:null}},ue=(e,r="px")=>e==="auto"?e:typeof e=="number"?e.toString()+r:S(e,"String")&&R.cssUnit.test(e)?e:e+r,u={precision:8,decimal:"."},y=(e,r,t)=>e!=null&&e.length?e.length===1?l(e[0],u):e.reduce((n,i,o,a)=>(n=t==null?void 0:t(n,i,o,a),n),r):0,B=(e,r)=>{const t=Object.assign({},u,r),s=l(e,t),{type:n="number"}=t;return n==="number"?s.value:s.toString()},fe=(...e)=>e.length===1?l(e[0],u).add(0):y(e,0,(r,t)=>l(r,u).add(t)),de=(...e)=>{if(e.length===1)return l(e[0],u).subtract(0);if(e.length===2){const[s,n]=e;return l(s,u).subtract(n)}const r=_(e),t=r.shift();return r.length?y(r,t,(s,n)=>l(s,u).subtract(n)):t},pe=(...e)=>e.length===1?l(e[0],u).multiply(1):y(e,1,(r,t)=>l(r,u).multiply(t)),me=(...e)=>{if(e.length===1)return l(e[0],u).divide(1);if(e.length===2){const[s,n]=e;return l(s,u).divide(n)}const r=_(e),t=r.shift();return y(r,t,(s,n)=>l(s,u).divide(n))},we=(e,r,t)=>{if(r<=1)return[e||0];if(!e)return new Array(r).fill(0);const s=Object.assign({},u,t);return l(e,s).distribute(r).map(i=>B(i,s))};function F(e,...r){if(Array.isArray(e))e.forEach(t=>F(t,...r));else return e(...r)}function d(e,r){var s;if(!e)return r;let t;return typeof e=="function"?t=e():Vue.isRef(e)?t=((s=e.value)==null?void 0:s.$el)??e.value:t=e,t}function ge(e,r){if(!e){const{defaultElement:t=null}=r??{};return typeof t=="function"?t:()=>t}if(typeof e=="string"||S(e,"Object"))return()=>e;if(typeof e=="function")return e}function g(e){return Vue.getCurrentScope()?(Vue.onScopeDispose(e),!0):!1}function Se(e,r){const t=Vue.watchEffect(e,r);g(t)}export{we as A,fe as B,de as C,pe as D,me as E,J as a,ue as b,ce as c,F as d,U as e,ae as f,re as g,oe as h,S as i,Z as j,g as k,z as l,ne as m,H as n,se as o,G as p,le as q,ge as r,te as s,N as t,Q as u,ie as v,Se as w,d as x,ee as y,B as z};