import{t as e}from"./notification.store-EczSZ_VB.js";import{a as t,t as n}from"./local-storage-DuQCXLd0.js";import{n as r,r as i}from"./error-handling-S7N4FACK.js";import{n as a}from"./vue-i18n-DhldrKy8.js";import{t as o}from"./constants-BCQekKde.js";var s=`X-Install-Wizard`,c=t.create({withCredentials:!0,headers:{common:{"X-Requested-With":`XMLHttpRequest`,[s]:`1`}}});c.interceptors.request.use(e=>{let t=n(o.INSTALL_AUTH_TOKEN),r=n(o.INSTALL_SELECTED_COMPANY);return e.headers[s]=`1`,t&&(e.headers.Authorization=t),r!=null&&String(r)!==``&&(e.headers.company=String(r)),e});function l(){let{t}=a(),n=e();function o(e){return!!e?.success&&!e?.error&&!e?.error_message}function s(e){let t=typeof e?.error_message==`string`&&e.error_message.trim()?e.error_message:typeof e?.error==`string`&&e.error.trim()?e.error:typeof e?.message==`string`&&e.message.trim()?e.message:``;n.showNotification({type:`error`,message:l(t)})}function c(e){if(e instanceof Error&&!(`response`in e)&&e.message.trim()){n.showNotification({type:`error`,message:l(e.message)});return}let t=i(e);n.showNotification({type:`error`,message:l(t.message)})}function l(e){let n=e.trim();if(!n)return`validation.something_went_wrong`;let i=`wizard.errors.${n}`;return t(i)===i?r(n)??n:i}return{isSuccessfulResponse:o,showRequestError:c,showResponseError:s}}export{c as n,l as t};