import{aj as y,y as n,z as s}from"./index-Bb2UEb_P.js";const g=y("global",()=>{async function c(a){let t="ERROR",e=null;const r=await n.post(s.delete,{...a});return r?.data?.Status==="Exception"?e=r?.data?.Exception:t="SUCCESS",{result:t,error:e}}async function l(a){let t="ERROR",e=null;const r=await n.post(s.OrdersTransfer,{...a});return r?.data?.Status==="Exception"?e=r?.data?.Exception:t="SUCCESS",{result:t,error:e}}async function d(a){let t="ERROR",e=null;const r=await n.post(s.OrderManage,{...a});return r?.data?.Status==="Exception"?e=r?.data?.Exception:(t="SUCCESS",window.open(r?.data?.Url,"_blank")),{result:t,error:e}}async function u(a){let t="ERROR",e=null;return await n.post(s.OrderManage,{...a}).then(r=>{if(r?.data?.Status==="Ok"){const i=window.open("","_blank");let o=`<html>
                            <head><title>Управление заказом</title></head>
                            <body>
                              <form id="OrderManageForm" action="${r.data.Url}" method="post">`;Object.entries(r.data.Args||{}).forEach(([h,m])=>{o+=`<input type="hidden" name="${h}" value="${m}">`}),o+=`</form>
                          <script>
                            document.getElementById('OrderManageForm').submit();
                          <\/script>
                        </body>
                        </html>`,i.document.write(o),i.document.close(),t="SUCCESS"}else r?.data?.Status==="Exception"?e=r?.data?.Exception:e="Неизвестный статус ответа"}).catch(r=>{e=r}),{result:t,error:e}}async function S(a){let t="ERROR",e=null;return(await n.post(s.OrderChangePassword,{...a}))?.data?.Status==="Ok"&&(t="SUCCESS"),{result:t,error:e}}async function f(a){let t="ERROR",e=null;return await n.post(s.OrderRestore,{...a}).then(r=>{r?.data?.Status==="Ok"&&(t="SUCCESS")}),{result:t,error:e}}async function p(a){const{data:t}=await n.get(s.Discount+`?${a}`);return t}async function O(){let a="ERROR";const t=await n.get(s.Generator);return t.data&&(a=t.data),a}async function R(a){let t="ERROR";return await n.post(s.NoticeEdit,a).then(e=>{e?.data?.Status==="Ok"&&(t="SUCCESS")}),t}async function E(a){let t="ERROR";try{const e=await n.post(s.ordersPay,a);e?.data?.Status==="Url"&&e?.data?.Location==="/Basket"&&(t="Basket"),e?.data?.Status==="Ok"&&(t=e.data)}catch(e){console.error(e)}return t}async function w(a,t){const e=await n.get(s.charts,{params:{OrderID:a,Period:t}});return e.data?Object.values(e.data):[]}return{deleteItem:c,OrdersTransfer:l,OrderChangePassword:S,OrderRestore:f,OrderManage:d,fetchDiscount:p,NoticeEdit:R,OrderManageHosting:u,generatePassword:O,OrdersPay:E,fetchCharts:w}});export{g as u};
