import{m as e}from"./vendor.js?ver=3.1.0";function t(e,n=""){let s={};return Object.keys(e).forEach(r=>{"object"==typeof e[r]?s=Object.assign(s,t(e[r],`${n}[${r}]`)):s[`${n}[${r}]`]=e[r]}),s}const n=function(e,n,s={}){const r=`${window.fcAdmin.rest.url}/${n}`,o={"X-WP-Nonce":window.fcAdmin.rest.nonce};return-1!==["PUT","PATCH","DELETE"].indexOf(e.toUpperCase())&&(o["X-HTTP-Method-Override"]=e,e="POST"),s.query_timestamp=Date.now(),new Promise((n,i)=>{const a=new XMLHttpRequest;let c=r;if("GET"===e.toUpperCase()){const e=new URLSearchParams;Object.keys(s).forEach(n=>{if(null!==s[n]&&!1!==s[n]&&void 0!==s[n])if(Array.isArray(s[n]))s[n].forEach(t=>{null!==t&&"object"==typeof t?e.append(n+"[]",JSON.stringify(t)):e.append(n+"[]",t)});else if("object"==typeof s[n]){const r=t(s[n],n);Object.keys(r).forEach(t=>{e.append(t,r[t])})}else e.append(n,s[n])});let n=e.toString();-1!==c.indexOf("?")?c+="&"+n:c+="?"+n}a.open(e,c,!0),Object.keys(o).forEach(e=>{a.setRequestHeader(e,o[e])}),a.onload=function(){let t;try{t=JSON.parse(a.responseText)}catch(l){t=null}!function(e,t,n,s,r){window.fluentApiLogger&&(n.query_timestamp&&delete n.query_timestamp,window.fluentApiLogger.logRequest({url:e,method:t,payload:JSON.parse(JSON.stringify(n)),response:s,status:r}))}(r,o["X-HTTP-Method-Override"]?o["X-HTTP-Method-Override"]:e,s,t,a.status),this.status>=200&&this.status<300&&t?n(t):t?("object"==typeof t&&(t.xhr_status=a.status),"rest_cookie_invalid_nonce"==t.code&&document.dispatchEvent(new CustomEvent("fluent_renew_rest_nonce",{detail:t})),i(t)):(window.FLUENTCRM.instance.$notify({message:'Unexpected error from server. Please check browser console. ',type:"error",dangerouslyUseHTMLString:!0,customClass:"fc_bottom-right",position:window.fcAdmin&&window.fcAdmin.is_rtl?"bottom-left":"bottom-right",onClick:()=>{window.FLUENTCRM.instance.$messageBox.alert(a.responseText+"\nURL: "+c+"\nMethod: "+e,"Error Details",{customStyle:{maxWidth:"60%"}})},duration:1e4}),console.info("Your server firewall blocked the request or it's a plugin conflict. Please check the detailed error."),console.log({status:a.status,statusText:a.statusText,responseText:a.responseText}))},a.onerror=function(){console.info("Your server firewall blocked the request or it's a plugin conflict. Please check the detailed error."),console.log({status:a.status,statusText:a.statusText,responseText:a.responseText}),i({status:a.status,statusText:a.statusText})},"GET"===e.toUpperCase()?a.send():(a.setRequestHeader("Content-Type","application/json;charset=UTF-8"),a.send(JSON.stringify(s)))})},s={get:(e,t={})=>n("GET",e,t),post:(e,t={})=>n("POST",e,t),delete:(e,t={})=>n("DELETE",e,t),del:(e,t={})=>n("DELETE",e,t),put:(e,t={})=>n("PUT",e,t),patch:(e,t={})=>n("PATCH",e,t),uploadFile(e,t={}){const n=`${window.fcAdmin.rest.url}/${e}`,s={"X-WP-Nonce":window.fcAdmin.rest.nonce};return new Promise((e,r)=>{const o=new XMLHttpRequest;o.open("POST",n,!0),Object.keys(s).forEach(e=>{o.setRequestHeader(e,s[e])}),o.onload=function(){this.status>=200&&this.status<300?e(JSON.parse(o.responseText)):r(JSON.parse(o.responseText))},o.onerror=function(){r({status:o.status,statusText:o.statusText})},o.send(t)})},ajax:(e,n,s={})=>function(e,n,s={}){const r=window.fcAdmin.ajaxurl;return s.query_timestamp=Date.now(),s.action=n,new Promise((n,o)=>{const i=new XMLHttpRequest;let a=r;if("GET"===e.toUpperCase()){let e={};Object.keys(s).forEach(n=>{null===s[n]||!1===s[n]?delete s[n]:"object"==typeof s[n]?e=Object.assign(e,t(s[n],n)):e[n]=s[n]});let n=new URLSearchParams(e).toString();-1!==a.indexOf("?")?a+="&"+n:a+="?"+n}i.open(e,a,!0),i.onload=function(){if(this.status>=200&&this.status<300)n(JSON.parse(i.responseText));else{let t;try{t=JSON.parse(i.responseText)}catch(e){t=null}o(t)}},i.onerror=function(){o({status:i.status,statusText:i.statusText})},"GET"===e.toUpperCase()?i.send():(i.setRequestHeader("Content-Type","application/json;charset=UTF-8"),i.send(JSON.stringify(s)))})}(e,n,s)},r="fcrm_pref";class o{static get(e,t=""){const n=localStorage.getItem(r);if(!n)return t;const s=JSON.parse(n);return s&&s[e]?s[e]:t}static set(e,t){let n=localStorage.getItem(r);n?(n=JSON.parse(n),"object"!=typeof n&&(n={})):n={},n[e]=t,localStorage.setItem(r,JSON.stringify(n))}static remove(e){const t=JSON.parse(localStorage.getItem(r));t&&t[e]&&(delete t[e],localStorage.setItem(r,JSON.stringify(t)))}static clear(){localStorage.removeItem(r)}}const i={install:(t,n)=>{t.config.globalProperties.$bus=e()}},a={},c=function(e,t,n){let s=Promise.resolve();if(t&&t.length>0){const e=document.getElementsByTagName("link"),r=document.querySelector("meta[property=csp-nonce]"),o=(null==r?void 0:r.nonce)||(null==r?void 0:r.getAttribute("nonce"));s=Promise.allSettled(t.map(t=>{if(t=function(e,t){return new URL(e,t).href}(t,n),t in a)return;a[t]=!0;const s=t.endsWith(".css"),r=s?'[rel="stylesheet"]':"";if(!!n)for(let n=e.length-1;n>=0;n--){const r=e[n];if(r.href===t&&(!s||"stylesheet"===r.rel))return}else if(document.querySelector(`link[href="${t}"]${r}`))return;const i=document.createElement("link");return i.rel=s?"stylesheet":"modulepreload",s||(i.as="script"),i.crossOrigin="",i.href=t,o&&i.setAttribute("nonce",o),document.head.appendChild(i),s?new Promise((e,n)=>{i.addEventListener("load",e),i.addEventListener("error",()=>n(new Error(`Unable to preload CSS for ${t}`)))}):void 0}))}function r(e){const t=new Event("vite:preloadError",{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return s.then(t=>{for(const e of t||[])"rejected"===e.status&&r(e.reason);return e().catch(r)})};function l(e){e=window.fcAdmin.trans[e]||e;const t=Array.prototype.slice.call(arguments,1);if(0===t.length)return e;let n=0;return e=e.replace(/%(\d*)\$?s|%d/g,(e,s)=>{if(s){const n=parseInt(s,10)-1;return n")},$t:l,trans:function(e){return l(e)},$_n:function(e,t,n){return l(parseInt(n.toString().replace(/,/g,""),10)>1?t:e,n)},percent:function(e,t){if(!t||!e)return"--";const n=e/t*100;return Number.isInteger(n)?n+"%":n.toFixed(2)+"%"},nsDateFormat:function(e,t=null){const n=void 0===e?null:e;if(!n)return"";null===t&&(t=window.dayjs(e).isSame(dayjs(),"year")?"D MMM":"D MMM, YYYY");const s=window.dayjs(n);return s.isValid()?s.format(t):null},smartDate:function(e,t=!1){if(!e)return"";let n="D MMM, YYYY";if(window.dayjs(e).isSame(window.dayjs(),"year")&&(n="D MMM",t)){Math.abs(dayjs(e).diff(dayjs(),"days"))<=5&&(n=0==window.dayjs(e).minute()?"D MMM, ha":"D MMM, hh:mma")}const s=window.dayjs(e);return s.isValid()?s.format(n):null},humanDiffTime:function(e){const t=void 0===e?null:e;if(!t)return"";if(window.fcAdmin.disable_time_diff){return window.dayjs(t).format(window.fcAdmin.wp_date_time_format)}const n=new Date-this.appStartTime,s=window.dayjs(t),r=window.dayjs(window.fcAdmin.server_time).add(n,"milliseconds");return s.from(r)},hasPermission:function(e){return-1!==window.fcAdmin.auth.permissions.indexOf(e)},formatMoney:function(e,t=2,n=".",s=","){try{t=Math.abs(t),t=isNaN(t)?2:t,parseInt(e)==e&&(t=0);const r=e<0?"-":"",o=parseInt(e=Math.abs(Number(e)||0).toFixed(t)).toString(),i=o.length>3?o.length%3:0;return r+(i?o.substr(0,i)+s:"")+o.substr(i).replace(/(\d{3})(?=\d)/g,"$1"+s)+(t?n+Math.abs(e-o).toFixed(t).slice(2):"")}catch(r){return""}}};class d{constructor(){this.errors={}}get(e){if(this.errors[e])return Object.values(this.errors[e])[0]}has(e){return!!this.errors[e]}record(e){this.errors=e}clear(){this.errors={}}}export{u as C,d as E,s as R,o as S,c as _,i as e};