import{X as a,Y as t,H as e}from"./auth-e5508dcf.js";import{at as r}from"./app-eaa32a4a.js";const s=()=>!!navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i),i=()=>window.location,n=(a,t)=>{for(let e=0;e<a.length;e++){const r=a[e];if("string"==typeof t[r]&&!t[r])return!1;if(Array.isArray(t[r])&&!t[r].length)return!1}return!0},o=a=>{const t={};for(const e in a)""!==a[e]&&null!==a[e]&&void 0!==a[e]&&(t[e]=a[e]);return t},l=(a,t)=>{const e={};for(const r in a)t.includes(r)||(e[r]=a[r]);return e},c=()=>r.get("/admin-api/api/contract/assets",{headers:a()}),p=t=>r.get("/admin-api/api/contract/position",{params:t,headers:a()}),d=t=>r.get("/admin-api/api/contract/entrust",{params:t,headers:a()}),u=t=>r.get("/admin-api/api/contract/history",{params:t,headers:a()}),g=t=>r.post("/admin-api/api/contract/close",t,{headers:a()}),m=()=>r.get("/admin-api/api/contract/strategy",{headers:a()}),h=t=>r.post("/admin-api/api/contract/operation",t,{headers:a()}),f=t=>r.post("/admin-api/api/contract/cancel",t,{headers:a()}),w=t=>r.get("/admin-api/api/spot/assets",{params:t,headers:a()}),S=()=>r.get("/admin-api/api/spot/strategy",{headers:a()}),y=t=>r.post("/admin-api/api/spot/operation",t,{headers:a()}),v=t=>r.get("/admin-api/api/spot/entrust",{params:t,headers:a()}),I=t=>r.post("/admin-api/api/spot/cancel",t,{headers:a()}),O=t=>r.get("/admin-api/api/spot/history",{params:t,headers:a()}),b="trade_user",N="contract_help",_="spot_help",J="symbol_list",A="contract_record",x="spot_record",j=(a,t,e)=>{"local"===e?window.localStorage.setItem(a,JSON.stringify(t)):window.sessionStorage.setItem(a,JSON.stringify(t))},D=(a,t)=>{let e=null;if("local"===t){let t=window.localStorage.getItem(a);t&&(e=JSON.parse(t))}else{let t=window.sessionStorage.getItem(a);t&&(e=JSON.parse(t))}return e},P=(a,t)=>{let e=window.localStorage.getItem(a);if(!e)return!0;{e=JSON.parse(e);const a=e.time;if((new Date).valueOf()-a>t)return!0}return!1},k=(a,t)=>{let e={time:(new Date).valueOf(),list:t};window.localStorage.setItem(a,JSON.stringify(e))},q=a=>{let t=window.localStorage.getItem(b);if(t){t=JSON.parse(t);let e=t.list.find((t=>t.id==a));if(e)return e.name}return"Null"},z=(a=!0,t=!0)=>{let e=window.localStorage.getItem(b);if(e){e=JSON.parse(e);const r=e.list;if(r&&r.length){if(a){let a=r.map((a=>({label:a.name,value:a.id})));return t&&a.unshift({label:"全部",value:""}),a}return r}}return[]},B=async()=>{if(P(b,36e5))try{const a=await e();0==a.code&&k(b,a.data.data)}catch(a){}},C=async(t=!1)=>{if(window.localStorage.setItem(N,""),P(N,864e5)||t)try{const t=await r.get("/admin-api/api/helper/contracts",{headers:a()});if(0==t.code)return k(N,t.data),t.data}catch(e){}return null},E=a=>{let t=window.localStorage.getItem(N);if(t){t=JSON.parse(t);const e=t.list;let r=[];return"order_type"==a?r=e.order_type:"position_side"==a?r=e.position_side:"side"==a?r=e.side:"exchange"==a&&(r=e.exchange),r}return[]},F=(a,t)=>{const e=E(a);if(e.length){const a=e.find((a=>a.value==t));return a?a.label:"error"}},H=(a,t=!0)=>{const e=E(a);if(e.length){let a=e.map((a=>({label:a.label,value:a.value})));return t&&a.unshift({label:"全部",value:""}),a}return[]},X=async(t,e=!1)=>{if(window.localStorage.setItem(_,""),P(_,864e5)||e)try{const t=await r.get("/admin-api/api/helper/spots",{headers:a()});if(0==t.code)return k(_,t.data),t.data}catch(s){}return null},Y=a=>{let t=window.localStorage.getItem(_);if(t){t=JSON.parse(t);const e=t.list;let r=[];return"direction"==a?r=e.direction:"order_type"==a?r=e.order_type:"status"==a&&(r=e.status),r}return[]},G=(a,t)=>{const e=Y(a);if(e.length){const a=e.find((a=>a.value==t));return a?a.label:t}return t},K=(a,t=!0)=>{const e=Y(a);if(e.length){let a=e.map((a=>({label:a.label,value:a.value})));return t&&a.unshift({label:"全部",value:""}),a}return[]},L=async(a=!0)=>{if(a){let a=window.localStorage.getItem(J);if(a&&!P(J,3e5)){const t=JSON.parse(a);return M(t.list)}}try{const a=await t();return 0==a.code?(k(J,a.data),M(a.data)):[]}catch(e){return[]}},M=a=>a;export{f as A,I as B,h as C,O as D,w as E,x as F,y as S,m as a,H as b,q as c,c as d,B as e,n as f,z as g,C as h,s as i,F as j,d as k,u as l,p as m,L as n,l as o,o as p,A as q,D as r,j as s,S as t,K as u,i as v,X as w,G as x,v as y,g as z};
