import{b8 as a,b9 as t,ba as e,am as r}from"./auth-db23b820.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.get("/admin-api/api/contract/assets",{headers:t()}),c=e=>a.get("/admin-api/api/contract/position",{params:e,headers:t()}),d=e=>a.get("/admin-api/api/contract/entrust",{params:e,headers:t()}),p=e=>a.get("/admin-api/api/contract/history",{params:e,headers:t()}),u=e=>a.post("/admin-api/api/contract/close",e,{headers:t()}),g=()=>a.get("/admin-api/api/contract/strategy",{headers:t()}),m=e=>a.post("/admin-api/api/contract/operation",e,{headers:t()}),h=e=>a.post("/admin-api/api/contract/cancel",e,{headers:t()}),f=()=>a.get("/admin-api/api/spot/assets",{headers:t()}),w=()=>a.get("/admin-api/api/spot/strategy",{headers:t()}),S=e=>a.post("/admin-api/api/spot/operation",e,{headers:t()}),y=e=>a.get("/admin-api/api/spot/entrust",{params:e,headers:t()}),b=e=>a.post("/admin-api/api/spot/cancel",e,{headers:t()}),v=e=>a.get("/admin-api/api/spot/history",{params:e,headers:t()}),I="trade_user",O="contract_help",N="spot_help",_="symbol_list",J="contract_record",A="spot_record",x=(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},j=(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},P=(a,t)=>{let e={time:(new Date).valueOf(),list:t};window.localStorage.setItem(a,JSON.stringify(e))},k=a=>{let t=window.localStorage.getItem(I);if(t){t=JSON.parse(t);let e=t.list.find((t=>t.id==a));if(e)return e.name}return"Null"},q=(a=!0,t=!0)=>{let e=window.localStorage.getItem(I);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[]},z=async()=>{if(j(I,36e5))try{const a=await r();0==a.code&&P(I,a.data.data)}catch(a){}},B=async(e=!1)=>{if(window.localStorage.setItem(O,""),j(O,864e5)||e)try{const e=await a.get("/admin-api/api/helper/contracts",{headers:t()});if(0==e.code)return P(O,e.data),e.data}catch(r){}return null},C=a=>{let t=window.localStorage.getItem(O);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[]},E=(a,t)=>{const e=C(a);if(e.length){const a=e.find((a=>a.value==t));return a?a.label:"error"}},F=(a,t=!0)=>{const e=C(a);if(e.length){let a=e.map((a=>({label:a.label,value:a.value})));return t&&a.unshift({label:"全部",value:""}),a}return[]},G=async(e,r=!1)=>{if(window.localStorage.setItem(N,""),j(N,864e5)||r)try{const e=await a.get("/admin-api/api/helper/spots",{headers:t()});if(0==e.code)return P(N,e.data),e.data}catch(s){}return null},H=a=>{let t=window.localStorage.getItem(N);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[]},K=(a,t)=>{const e=H(a);if(e.length){const a=e.find((a=>a.value==t));return a?a.label:t}return t},L=(a,t=!0)=>{const e=H(a);if(e.length){let a=e.map((a=>({label:a.label,value:a.value})));return t&&a.unshift({label:"全部",value:""}),a}return[]},M=async(a=!0)=>{if(a){let a=window.localStorage.getItem(_);if(a&&!j(_,3e5)){return JSON.parse(a).list}}try{const a=await e();return 0==a.code?(P(_,a.data),a.data):[]}catch(t){return[]}};export{b as A,v as B,m as C,f as D,A as E,S,g as a,F as b,k as c,l as d,z as e,n as f,q as g,B as h,s as i,E as j,d as k,p as l,c as m,o as n,J as o,D as p,w as q,M as r,x as s,L as t,i as u,G as v,K as w,y as x,u as y,h as z};
