@ecodrix/erix-api 4.0.2 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";var gn=Object.create;var Re=Object.defineProperty,dn=Object.defineProperties,mn=Object.getOwnPropertyDescriptor,yn=Object.getOwnPropertyDescriptors,fn=Object.getOwnPropertyNames,qe=Object.getOwnPropertySymbols,bn=Object.getPrototypeOf,Tt=Object.prototype.hasOwnProperty,Xt=Object.prototype.propertyIsEnumerable;var hn=(n,e)=>(e=Symbol[n])?e:Symbol.for("Symbol."+n);var vt=(n,e,t)=>e in n?Re(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,g=(n,e)=>{for(var t in e||(e={}))Tt.call(e,t)&&vt(n,t,e[t]);if(qe)for(var t of qe(e))Xt.call(e,t)&&vt(n,t,e[t]);return n},E=(n,e)=>dn(n,yn(e));var R=(n,e)=>{var t={};for(var r in n)Tt.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&qe)for(var r of qe(n))e.indexOf(r)<0&&Xt.call(n,r)&&(t[r]=n[r]);return t};var xn=(n,e)=>{for(var t in e)Re(n,t,{get:e[t],enumerable:!0})},Zt=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of fn(e))!Tt.call(n,o)&&o!==t&&Re(n,o,{get:()=>e[o],enumerable:!(r=mn(e,o))||r.enumerable});return n};var Ae=(n,e,t)=>(t=n!=null?gn(bn(n)):{},Zt(e||!n||!n.__esModule?Re(t,"default",{value:n,enumerable:!0}):t,n)),kn=n=>Zt(Re({},"__esModule",{value:!0}),n);var i=(n,e,t)=>vt(n,typeof e!="symbol"?e+"":e,t);var St=function(n,e){this[0]=n,this[1]=e},en=(n,e,t)=>{var r=(d,p,k,f)=>{try{var T=t[d](p),L=(p=T.value)instanceof St,V=T.done;Promise.resolve(L?p[0]:p).then(h=>L?r(d==="return"?d:"next",p[1]?{done:h.done,value:h.value}:h,k,f):k({value:h,done:V})).catch(h=>r("throw",h,k,f))}catch(h){f(h)}},o=(d,p,k,f)=>u[d]=T=>(p=new Promise((L,V,h)=>(h=()=>r(d,T,L,V),a?a.then(h):h())),f=()=>a===k&&(a=0),a=k=p.then(f,f),p),a,u={};return t=t.apply(n,e),u[hn("asyncIterator")]=()=>u,o("next"),o("throw"),o("return"),u};var Ln={};xn(Ln,{APIError:()=>y,APIResource:()=>s,AiAgent:()=>be,AuthenticationError:()=>v,Campaigns:()=>I,Catalog:()=>ke,Collector:()=>fe,ConnectInfra:()=>Me,ECODrIx:()=>O,ECODrIxAPI:()=>O,ERROR_RETRY_CONFIG:()=>Wt,EcodrixError:()=>Ke,EmailConnect:()=>De,ErixChat:()=>Le,ErixProduct:()=>Ee,FlowAudiences:()=>q,FlowAutomations:()=>F,FlowConversations:()=>_,FlowDrafts:()=>N,FlowFirstRunResource:()=>B,FlowHome:()=>U,FlowProduct:()=>$e,HTTP_STATUS_ERROR_MAP:()=>Tn,InfraDomain:()=>ve,KNOWLEDGE_FILE_TYPES:()=>ln,Knowledge:()=>Ce,LAIE_EVENTS:()=>rn,LEAD_STATUS_VALUES:()=>Lt,LaieAudits:()=>re,LaieCampaigns:()=>H,LaieCompliance:()=>X,LaieFreshness:()=>ne,LaieImport:()=>Y,LaieLeads:()=>Q,LaieLearning:()=>ee,LaieLists:()=>J,LaieLookalikes:()=>te,LaieMarket:()=>Z,LaiePacks:()=>j,LaieProduct:()=>Ve,LaieRuns:()=>z,LaieSignals:()=>W,LaieTools:()=>G,Onboarding:()=>he,PermissionError:()=>D,Persona:()=>xe,PlatformDomain:()=>Te,PlatformTenants:()=>Ue,PlatformUsers:()=>Ne,ProductDomain:()=>we,RateLimitError:()=>A,SeoAudits:()=>oe,SeoBacklinks:()=>de,SeoBriefs:()=>ye,SeoInsights:()=>ae,SeoLocal:()=>ue,SeoPerformance:()=>me,SeoProduct:()=>Oe,SeoProjects:()=>ie,SeoRanks:()=>le,SeoReports:()=>pe,SeoResearch:()=>ge,SeoSearchConsole:()=>ce,StorageInfra:()=>_e,VOICE_EVENTS:()=>on,VOICE_REFUSAL_REASONS:()=>Et,Voice:()=>se,VoiceCampaigns:()=>Pe,WebhookSignatureError:()=>P,Webhooks:()=>Se,WhatsAppConnect:()=>Fe,default:()=>Pn,getErrorDetails:()=>An,getRetryConfig:()=>In,handleAPIError:()=>Sn,isAPIError:()=>Rn,laieStageQueued:()=>nn,toAPIError:()=>$,voiceErrorCode:()=>an,voiceRefusalReason:()=>cn});module.exports=kn(Ln);var pn=Ae(require("axios"),1),jt=Ae(require("axios-retry"),1);var Rt="https://api.ecodrix.com";function tn(n="v1",e=Rt){return`${e.replace(/\/+$/,"")}/${n}/api`}var Ke=class extends Error{constructor(e){super(e),this.name="EcodrixError"}},y=class extends Ke{constructor(t,r,o){super(t);i(this,"status");i(this,"code");i(this,"issues");i(this,"field");this.name="APIError",this.status=r,this.code=o}},v=class extends y{constructor(e="Invalid API Key or Client Code",t="AUTH_FAILED",r=401){super(e,r,t),this.name="AuthenticationError"}},D=class extends v{constructor(e="You don't have permission to do this.",t="FORBIDDEN"){super(e,t,403),this.name="PermissionError"}},A=class extends y{constructor(e="Too many requests. Please slow down."){super(e,429,"RATE_LIMIT_EXCEEDED"),this.name="RateLimitError"}};function $(n){var a;if(!(n!=null&&n.response))return new y((n==null?void 0:n.message)||"Network Error");let{status:e,data:t}=n.response,r=(t==null?void 0:t.message)||(t==null?void 0:t.error)||"API Request Failed",o=(a=t==null?void 0:t.code)!=null?a:typeof(t==null?void 0:t.error)=="string"&&/^[A-Z][A-Z0-9_]*$/.test(t.error)?t.error:void 0;switch(e){case 401:return new v(r,o);case 403:return new D(r,o);case 429:return new A(r);default:{let u=new y(r,e,o);return Array.isArray(t==null?void 0:t.issues)&&(u.issues=t.issues),typeof(t==null?void 0:t.field)=="string"&&(u.field=t.field),u}}}var s=class{constructor(e){i(this,"client",e)}async post(e,t,r){try{let o=this.buildConfig(r);return(await this.client.post(e,t,o)).data}catch(o){this.handleError(o)}}async get(e,t){try{let r=this.buildConfig(t);return(await this.client.get(e,r)).data}catch(r){this.handleError(r)}}async patch(e,t,r){try{let o=this.buildConfig(r);return(await this.client.patch(e,t,o)).data}catch(o){this.handleError(o)}}async put(e,t,r){try{let o=this.buildConfig(r);return(await this.client.put(e,t,o)).data}catch(o){this.handleError(o)}}async deleteRequest(e,t){try{let r=this.buildConfig(t);return(await this.client.delete(e,r)).data}catch(r){this.handleError(r)}}buildConfig(e){if(!e)return;let t=g({},e);return e.idempotencyKey&&(t.headers=E(g({},t.headers),{"Idempotency-Key":e.idempotencyKey})),t}handleError(e){throw $(e)}};var F=class extends s{path(e,t=""){return`/product/flow/workflows/${encodeURIComponent(e)}${t}`}async versions(e){return this.get(this.path(e,"/versions"))}async version(e,t){return this.get(this.path(e,`/versions/${encodeURIComponent(t)}`))}async restoreVersion(e,t){return this.post(this.path(e,`/versions/${encodeURIComponent(t)}/restore`))}async testData(e){return this.get(this.path(e,"/test-data"))}async pinTestData(e,t){return this.put(this.path(e,"/test-data"),{runId:t})}async unpinTestData(e){return this.deleteRequest(this.path(e,"/test-data"))}async testRun(e,t={}){return this.post(this.path(e,"/test-run"),t)}async testRunProgress(e,t){return this.get(this.path(e,"/test-run"),{params:{runIds:t.join(",")}})}async copilot(e,t){return this.post(this.path(e,"/copilot"),t)}async live(e){return this.get(this.path(e,"/live"))}async week(e){return this.get(this.path(e,"/week"))}async deleteImpact(e){return this.get(this.path(e,"/delete-impact"))}async remove(e,t={}){return this.deleteRequest(this.path(e,t.stop?"?stop=true":""))}async duplicate(e){return this.post(this.path(e,"/duplicate"))}async retryFailed(e,t={}){return this.post(this.path(e,"/retry-failed"),t)}};var I=class extends s{async list(e={}){return this.get("/product/flow/campaigns",{params:e})}async create(e){return this.post("/product/flow/campaigns",e)}async launch(e,t={}){return this.post(`/product/flow/campaigns/${encodeURIComponent(e)}/launch`,t)}async retrieve(e){return this.get(`/product/flow/campaigns/${encodeURIComponent(e)}`)}async update(e,t){return this.patch(`/product/flow/campaigns/${encodeURIComponent(e)}`,t)}async test(e){return this.post(`/product/flow/campaigns/${encodeURIComponent(e)}/test`,{})}async start(e,t={}){return this.post(`/product/flow/campaigns/${encodeURIComponent(e)}/start`,t)}async pause(e){return this.post(`/product/flow/campaigns/${encodeURIComponent(e)}/pause`,{})}async resume(e){return this.post(`/product/flow/campaigns/${encodeURIComponent(e)}/resume`,{})}async stop(e){return this.post(`/product/flow/campaigns/${encodeURIComponent(e)}/stop`,{})}async remove(e){return this.deleteRequest(`/product/flow/campaigns/${encodeURIComponent(e)}`)}async duplicate(e){return this.post(`/product/flow/campaigns/${encodeURIComponent(e)}/duplicate`,{})}async followUp(e,t={}){return this.post(`/product/flow/campaigns/${encodeURIComponent(e)}/follow-up`,t)}async checks(e){return this.get(`/product/flow/campaigns/${encodeURIComponent(e)}/checks`)}async results(e){return this.get(`/product/flow/campaigns/${encodeURIComponent(e)}/results`)}async people(e,t={}){return this.get(`/product/flow/campaigns/${encodeURIComponent(e)}/people`,{params:t})}};var M="/product/flow/conversations",b=(n,e="")=>`${M}/${encodeURIComponent(n)}${e}`,_=class extends s{async list(e={}){return this.get(M,{params:e})}async create(e){return this.post(M,e)}async retrieve(e){return this.get(b(e))}async update(e,t){return this.patch(b(e),t)}async duplicate(e){return this.post(b(e,"/duplicate"),{})}async archive(e){return this.deleteRequest(b(e))}async publish(e,t={}){return this.post(b(e,"/publish"),t)}async versions(e){return this.get(b(e,"/versions"))}async version(e,t){return this.get(b(e,`/versions/${t}`))}async rollback(e,t){return this.post(b(e,"/rollback"),{version:t})}async try(e,t){return this.post(b(e,"/try"),t)}async tests(e){return this.get(b(e,"/tests"))}async addTest(e,t){return this.post(b(e,"/tests"),t)}async deleteTest(e,t){return this.deleteRequest(b(e,`/tests/${encodeURIComponent(t)}`))}async runTests(e,t={}){return this.post(b(e,"/tests/run"),t)}async deployments(e){return this.get(b(e,"/deployments"))}async allDeployments(){return this.get(`${M}/deployments`)}async deploy(e,t){return this.post(b(e,"/deployments"),t)}async updateDeployment(e,t){return this.patch(`${M}/deployments/${encodeURIComponent(e)}`,t)}async removeDeployment(e){return this.deleteRequest(`${M}/deployments/${encodeURIComponent(e)}`)}async checks(e){return this.get(b(e,"/checks"))}};var U=class extends s{async get(){return super.get("/product/flow/home")}async nav(){return super.get("/product/flow/home/nav")}},N=class extends s{async create(e){return this.post("/product/flow/drafts",e)}},B=class extends s{async status(){return this.get("/product/flow/first-run")}async installPack(e){return this.post(`/product/flow/first-run/packs/${e}`)}},q=class extends s{async list(){return this.get("/product/flow/audiences")}async byId(e){return this.get(`/product/flow/audiences/${encodeURIComponent(e)}`)}async create(e){return this.post("/product/flow/audiences",e)}async update(e,t){return this.patch(`/product/flow/audiences/${encodeURIComponent(e)}`,t)}async remove(e){return this.deleteRequest(`/product/flow/audiences/${encodeURIComponent(e)}`)}async preview(e,t){return this.get(`/product/flow/audiences/${encodeURIComponent(e)}/preview${t?`?channel=${t}`:""}`)}async previewRules(e){return this.post("/product/flow/audiences/preview",e)}};var x="/product/erix/commerce/checkout",S="/product/erix/public/checkout",C=encodeURIComponent,At=class extends s{async getProduct(e,t){return this.get(`${S}/products/${C(t)}`,{params:{c:e}})}async viewSession(e,t){return this.get(`${S}/sessions/view`,{params:{c:e,t}})}async updateItems(e){let o=e,{sessionId:t}=o,r=R(o,["sessionId"]);return this.post(`${S}/sessions/${C(t)}/items`,r)}async startSession(e){return this.post(`${S}/sessions`,e)}async applyCoupon(e){let o=e,{sessionId:t}=o,r=R(o,["sessionId"]);return this.post(`${S}/sessions/${C(t)}/coupon`,r)}async verify(e){let o=e,{sessionId:t}=o,r=R(o,["sessionId"]);return this.post(`${S}/sessions/${C(t)}/verify`,r)}async placeOrder(e){let o=e,{sessionId:t}=o,r=R(o,["sessionId"]);return this.post(`${S}/sessions/${C(t)}/order`,r)}async verifyRazorpay(e){let a=e,{sessionId:t,orderId:r}=a,o=R(a,["sessionId","orderId"]);return this.post(`${S}/sessions/${C(t)}/order/${C(r)}/razorpay`,o)}async orderStatus(e,t){return this.get(`${S}/orders/status`,{params:{c:e,t}})}async confirmCod(e,t){return this.post(`${S}/cod/confirm`,{clientCode:e,token:t})}},It=class extends s{async create(e){return this.post(`${x}/sessions`,e)}},je=class extends s{constructor(t){super(t);i(this,"buyer");i(this,"sessions");this.buyer=new At(t),this.sessions=new It(t)}async listProducts(){return this.get(`${x}/products`)}async createProduct(t){return this.post(`${x}/products`,t)}async updateProduct(t,r){return this.patch(`${x}/products/${C(t)}`,r)}async deleteProduct(t){return this.deleteRequest(`${x}/products/${C(t)}`)}async listCoupons(){return this.get(`${x}/coupons`)}async createCoupon(t){return this.post(`${x}/coupons`,t)}async updateCoupon(t,r){return this.patch(`${x}/coupons/${C(t)}`,r)}async deleteCoupon(t){return this.deleteRequest(`${x}/coupons/${C(t)}`)}async listOrders(t){return this.get(`${x}/orders`,{params:t})}async getOrder(t){return this.get(`${x}/orders/${C(t)}`)}async updateOrderStatus(t,r){return this.patch(`${x}/orders/${C(t)}/status`,r)}async getSettings(){return this.get(`${x}/settings`)}async updateSettings(t){return this.put(`${x}/settings`,t)}async createProductLink(t){return this.post(`${x}/links`,t)}};var Pt=class extends s{async list(e){return this.get(`/product/erix/crm/leads/${e}/notes`)}async create(e,t){return this.post(`/product/erix/crm/leads/${e}/notes`,t)}async update(e,t){return this.patch(`/product/erix/crm/notes/${e}`,{content:t})}async pin(e,t=!0){return this.patch(`/product/erix/crm/notes/${e}/pin`,{isPinned:t})}async delete(e){return this.deleteRequest(`/product/erix/crm/notes/${e}`)}},We=class extends s{constructor(t){super(t);i(this,"notes");this.notes=new Pt(t)}async timeline(t,r){return this.get(`/product/erix/crm/leads/${t}/timeline`,{params:r})}async list(t,r){return this.get(`/product/erix/crm/leads/${t}/activities`,{params:g({},r)})}async log(t){return this.post(`/product/erix/crm/leads/${t.leadId}/activities`,t)}async logCall(t,r){return this.post(`/product/erix/crm/leads/${t}/calls`,r)}};var Ge=class extends s{async overview(e){return this.get("/product/erix/crm/analytics/overview",{params:e})}async funnel(e){return this.get("/product/erix/crm/analytics/funnel",{params:{pipelineId:e}})}async forecast(e){return this.get("/product/erix/crm/analytics/forecast",{params:{pipelineId:e}})}async sources(e){return this.get("/product/erix/crm/analytics/sources",{params:e})}async team(e){return this.get("/product/erix/crm/analytics/team",{params:e})}async heatmap(e){return this.get("/product/erix/crm/analytics/heatmap",{params:e})}async scores(){return this.get("/product/erix/crm/analytics/scores")}async stageTime(e){return this.get("/product/erix/crm/analytics/stage-time",{params:{pipelineId:e}})}async tiered(e){return this.get("/product/erix/crm/analytics/tiered",{params:e})}async summary(e){return this.get("/product/erix/crm/analytics/summary",{params:e})}async whatsapp(e){return this.get("/product/erix/crm/analytics/whatsapp",{params:e})}async revenue(){return this.get("/product/erix/crm/analytics/revenue")}async health(){return this.get("/product/erix/crm/analytics/health")}async payments(){return this.get("/product/erix/crm/analytics/payments")}async reviews(){return this.get("/product/erix/crm/analytics/reviews")}async retention(){return this.get("/product/erix/crm/analytics/retention")}};var He=class extends s{async getChecklist(e){return this.get(`/product/erix/crm/documents/checklist/${e}`)}async createChecklist(e,t){return this.post(`/product/erix/crm/documents/checklist/${e}`,{templateNiche:t})}async markReceived(e,t,r){return this.patch(`/product/erix/crm/documents/checklist/${e}/${t}`,r?{fileUrl:r}:{})}async sendReminder(e){return this.post(`/product/erix/crm/documents/checklist/${e}/remind`)}async listIncomplete(){return this.get("/product/erix/crm/documents/checklist/incomplete")}async listTemplates(){return this.get("/product/erix/crm/documents/templates")}};var ze=class extends s{async csv(e){return this.get("/product/erix/commerce/invoices/export/csv",{params:e})}async tally(e){return this.get("/product/erix/commerce/invoices/export/tally",{params:e})}async zoho(e){return this.get("/product/erix/commerce/invoices/export/zoho",{params:e})}};var Lt=["open","won","lost","archived"],Qe=class extends s{async create(e){return this.post("/product/erix/crm/leads",e)}async describe(){let e=await this.fields(),t=Array.isArray(e.data)?e.data:[],r=[{key:"firstName",label:"First Name",type:"string",required:!0,group:"Basic Info"},{key:"lastName",label:"Last Name",type:"string",required:!1,group:"Basic Info"},{key:"phone",label:"Phone Number",type:"phone",required:!0,group:"Contact"},{key:"email",label:"Email Address",type:"email",required:!1,group:"Contact"},{key:"status",label:"Status",type:"select",required:!0,options:Lt.map(a=>({label:`${a.charAt(0).toUpperCase()}${a.slice(1)}`,value:a}))},{key:"value",label:"Lead Value",type:"currency",required:!1},{key:"source",label:"Source",type:"string",required:!1}],o=t.map(a=>({key:`metadata.extra.${a.name}`,label:a.label||a.name,type:a.type||"string",required:!!a.required,options:a.options,group:"Custom Fields"}));return{name:"Lead",fields:[...r,...o],uiHints:{icon:"User",primaryColor:"#3b82f6",defaultSort:{field:"createdAt",direction:"desc"},summaryFields:["firstName","lastName","phone","status"]}}}async upsert(e){return this.post("/product/erix/crm/leads/upsert",e)}async createMany(e,t=50){let r=[];for(let o=0;o<e.length;o+=t){let u=e.slice(o,o+t).map(p=>this.create(p)),d=await Promise.allSettled(u);for(let p of d)if(p.status==="fulfilled")r.push(p.value);else throw p.reason}return r}async import(e,t={}){return this.post("/product/erix/crm/leads/import",g({leads:e},t))}async bulkUpsert(e){return this.import(e)}async list(e){let t=g({},e);return Array.isArray(t.tags)&&(t.tags=t.tags.join(",")),this.get("/product/erix/crm/leads",{params:t})}listAutoPaging(e){return en(this,null,function*(){let t=(e==null?void 0:e.page)||1,r=!0;for(;r;){let o=yield new St(this.list(E(g({},e),{page:t}))),a=Array.isArray(o.data)?o.data:o||[];if(a.length===0){r=!1;break}for(let u of a)yield u;o.pagination&&t<o.pagination.pages||!o.pagination&&a.length>0?t++:r=!1}})}async retrieve(e){return this.get(`/product/erix/crm/leads/${e}`)}async retrieveByPhone(e){return this.get(`/product/erix/crm/leads/phone/${encodeURIComponent(e)}`)}async byStage(e,t,r={}){return this.get(`/product/erix/crm/pipelines/${e}/stages/${t}/leads`,{params:r})}async retrieveByRef(e,t){return this.get(`/product/erix/crm/leads/ref/${encodeURIComponent(e)}/${encodeURIComponent(t)}`)}async update(e,t){return this.patch(`/product/erix/crm/leads/${e}`,t)}async setFollowUp(e,t,r){return this.patch(`/product/erix/crm/leads/${e}`,{nextFollowUpAt:t,nextFollowUpNote:t&&r!=null?r:null})}async move(e,t){return this.patch(`/product/erix/crm/leads/${e}/move`,{stageId:t})}async convert(e,t,r){return this.post(`/product/erix/crm/leads/${e}/convert`,{outcome:t,reason:r})}async tags(e,t){return this.patch(`/product/erix/crm/leads/${e}/tags`,t)}async recalculateScore(e){return this.post(`/product/erix/crm/leads/${e}/score`,{})}async updateMetadata(e,t){return this.patch(`/product/erix/crm/leads/${e}/metadata`,t)}async fields(){return this.get("/product/erix/crm/fields")}async notes(e){return this.get(`/product/erix/crm/leads/${e}/notes`)}async activities(e,t){return this.get(`/product/erix/crm/leads/${e}/timeline`,{params:t})}async createNote(e,t){return this.post(`/product/erix/crm/leads/${e}/notes`,t)}async updateNote(e,t,r){return this.patch(`/product/erix/crm/notes/${t}`,r)}async deleteNote(e,t){return this.deleteRequest(`/product/erix/crm/notes/${t}`)}async delete(e){return this.deleteRequest(`/product/erix/crm/leads/${e}`)}async export(e){return this.get(`/product/erix/crm/leads/${encodeURIComponent(e)}/export`)}async erase(e){return this.post(`/product/erix/crm/leads/${encodeURIComponent(e)}/erase`,{confirm:"ERASE"})}async bulkArchive(e){return this.patch("/product/erix/crm/leads/bulk-archive",{ids:e})}async bulkDelete(e){return this.deleteRequest("/product/erix/crm/leads",{data:{ids:e}})}async archive(e){return this.deleteRequest(`/product/erix/crm/leads/${e}`)}async profile(e){return this.get(`/product/erix/crm/leads/${e}/profile`)}async invoices(e){return this.get(`/product/erix/crm/leads/${e}/invoices`)}async projects(e){return this.get(`/product/erix/crm/leads/${e}/projects`)}async conversations(e){return this.get(`/product/erix/crm/leads/${e}/conversations`)}async meetings(e){return this.get(`/product/erix/crm/leads/${e}/meetings`)}async flowRuns(e){return this.get(`/product/erix/crm/leads/${e}/flow-runs`)}async merge(e,t){return this.post("/product/erix/crm/leads/merge",{primaryId:e,secondaryId:t})}async duplicates(e){return this.get(`/product/erix/crm/leads/${encodeURIComponent(e)}/duplicates`)}};var Ye=class extends s{async capture(e){return this.post("/product/erix/crm/payments/capture",e)}};var Je=class extends s{async list(){return this.get("/product/erix/crm/pipelines")}async getStageManifest(e){var o,a;let t=await this.retrieve(e),r=Array.isArray((o=t.data)==null?void 0:o.stages)?t.data.stages:[];return{name:`Pipeline: ${((a=t.data)==null?void 0:a.name)||e}`,fields:r.map(u=>({key:u._id,label:u.name,type:"string",required:!0,options:[{label:u.name,value:u._id}],group:"Stages",uiHints:{color:u.color||"#cbd5e1",probability:u.probability}})),uiHints:{icon:"Columns",primaryColor:"#6366f1"}}}async create(e){return this.post("/product/erix/crm/pipelines",e)}async retrieve(e){return this.get(`/product/erix/crm/pipelines/${e}`)}async update(e,t){return this.patch(`/product/erix/crm/pipelines/${e}`,t)}async setDefault(e){return this.patch(`/product/erix/crm/pipelines/${e}/default`,{})}async duplicate(e,t){return this.post(`/product/erix/crm/pipelines/${e}/duplicate`,{name:t})}async archive(e){return this.patch(`/product/erix/crm/pipelines/${e}/archive`,{})}async delete(e){return this.deleteRequest(`/product/erix/crm/pipelines/${e}`)}async checkInUse(e){return this.get(`/product/erix/crm/pipelines/${e}/in-use`)}async board(e){return this.get(`/product/erix/crm/pipelines/${e}/board`)}async forecast(e){return this.get(`/product/erix/crm/pipelines/${e}/forecast`)}async addStage(e,t){return this.post(`/product/erix/crm/pipelines/${e}/stages`,t)}async reorderStages(e,t){return this.patch(`/product/erix/crm/pipelines/${e}/stages/reorder`,{order:t})}async updateStage(e,t){return this.patch(`/product/erix/crm/stages/${e}`,t)}async deleteStage(e,t){return this.deleteRequest(`/product/erix/crm/stages/${e}`,{data:t?{moveLeadsToStageId:t}:void 0})}};var Xe=class extends s{async getConfig(){return this.get("/product/erix/crm/scoring")}async updateConfig(e){return this.patch("/product/erix/crm/scoring",e)}async recalculate(e){return this.post(`/product/erix/crm/scoring/${e}/recalculate`,{})}async preview(e){return this.get(`/product/erix/crm/scoring/preview/${e}`)}};var Ze=class extends s{async trigger(e){return this.post("/product/erix/events/trigger",e)}async listCustomEvents(){return this.get("/product/flow/config/triggers")}async createCustomEvent(e){return this.post("/product/flow/config/triggers",e)}async deleteCustomEvent(e){return this.deleteRequest(`/product/flow/config/triggers/${e}`)}};var et=class extends s{async list(e){return this.get("/product/erix/commerce/invoices",{params:e})}async getInvoice(e){return this.get(`/product/erix/commerce/invoices/${e}`)}async create(e){return this.post("/product/erix/commerce/invoices",e)}async update(e,t){return this.patch(`/product/erix/commerce/invoices/${e}`,t)}async void(e){return this.post(`/product/erix/commerce/invoices/${e}/void`,{})}async sendViaWhatsApp(e){return this.post(`/product/erix/commerce/invoices/${e}/send-whatsapp`,{})}async getSettings(){return this.get("/product/erix/commerce/settings")}async updateSettings(e){return this.put("/product/erix/commerce/settings",e)}async paymentLink(e){return this.post(`/product/erix/commerce/invoices/${encodeURIComponent(e)}/payment-link`,{})}async recordPayment(e,t){return this.post(`/product/erix/commerce/invoices/${encodeURIComponent(e)}/payments`,t)}async sendWhatsApp(e){return this.post(`/product/erix/commerce/invoices/${encodeURIComponent(e)}/send-whatsapp`,{})}async sendEmail(e){return this.post(`/product/erix/commerce/invoices/${encodeURIComponent(e)}/send-email`,{})}};var tt=class extends s{async workflowPacks(){return this.get("/product/erix/crm/niche/workflow-packs")}async workflowPackDetail(e){return this.get(`/product/erix/crm/niche/workflow-packs/${e}`)}async installWorkflowPack(e){return this.post(`/product/erix/crm/niche/workflow-packs/${e}/install`)}async templateSuggestions(){return this.get("/product/erix/crm/niche/template-suggestions")}};var nt=class extends s{async list(e){return this.get(`/product/erix/commerce/projects/${e}/documents`)}async upload(e,t){return this.post(`/product/erix/commerce/projects/${e}/documents`,t)}async toggleSignature(e,t,r){return this.patch(`/product/erix/commerce/projects/${e}/documents/${t}/signature`,{required:r})}async addSigner(e,t,r){return this.post(`/product/erix/commerce/projects/${e}/documents/${t}/signers`,r)}async decline(e,t){return this.post(`/product/erix/commerce/projects/${e}/documents/${t}/decline`,{})}async stampSign(e,t,r){return this.post(`/product/erix/commerce/projects/${e}/documents/${t}/stamp-sign`,r)}};var rt=class extends s{async list(e){return this.get("/platform/inbox/conversations",{params:e})}async create(e){var t;return this.post("/platform/inbox/conversations",{address:e.phone,channel:(t=e.channel)!=null?t:"whatsapp",userName:e.name})}async linkLead(e,t){return this.patch(`/platform/inbox/conversations/${e}/lead`,{leadId:t})}async retrieve(e){return this.get(`/platform/inbox/conversations/${e}`)}async messages(e,t){return this.get(`/platform/inbox/conversations/${e}/messages`,{params:t})}async markRead(e){return this.post(`/platform/inbox/conversations/${e}/read`,{})}async delete(e){return this.deleteRequest(`/platform/inbox/conversations/${e}`)}async bulkDelete(e){return this.post("/platform/inbox/conversations/bulk-delete",{ids:e})}};var K=class extends s{async send(e){if(e.conversationId)return this.post(`/platform/inbox/conversations/${e.conversationId}/messages`,{text:e.text,media:e.media});if(!e.to)throw new Error("send: conversationId or to is required");if(e.media)throw new Error("send: media goes to an inbox thread (conversationId)");return this.post("/infra/connect/send/whatsapp",{phone:e.to,text:e.text})}async sendTemplate(e){return this.post("/infra/connect/send/whatsapp",{phone:e.to,templateName:e.templateName,language:e.language,variables:e.variables})}async star(e,t){return this.post(`/platform/inbox/messages/${e}/star`,{starred:t})}async markRead(e){return this.post(`/platform/inbox/conversations/${e}/read`,{})}async upload(e,t={}){var k,f,T;let r=(f=(k=t.fileName)!=null?k:e.name)!=null?f:"file",o=e.type||"application/octet-stream",a=await this.post("/infra/storage/files/upload-url",{folder:(T=t.folder)!=null?T:"inbox",filename:r,contentType:o}),{uploadUrl:u,key:d}=a.data,p=await fetch(u,{method:"PUT",headers:{"Content-Type":o},body:e});if(!p.ok)throw new Error(`upload failed (${p.status})`);return await this.post("/infra/storage/files/confirm-upload",{key:d,sizeBytes:e.size}),{key:d,mimeType:o,fileName:r}}};var st=class extends s{async providers(){return this.get("/infra/connect/providers")}async list(){return this.get("/infra/connect/connections")}async get_(e){return this.get(`/infra/connect/connections/${e}`)}async connect(e,t){return this.post(`/infra/connect/connections/${e}/connect`,t)}async configure(e,t){return this.put(`/infra/connect/connections/${e}/configure`,t)}async configureWebchat(e){return this.configure("webchat",{method:"domain",config:e})}async webchatSettings(){return this.get("/infra/connect/connections/webchat/settings")}async removeWebchatDomain(e){return this.deleteRequest(`/infra/connect/connections/webchat/domains/${encodeURIComponent(e)}`)}async disconnect(e){return this.post(`/infra/connect/connections/${e}/disconnect`,{})}async reveal(e){return this.post(`/infra/connect/connections/${e}/reveal`,{})}async test(e){return this.post(`/infra/connect/connections/${e}/test`,{})}async checkNow(e){return this.post(`/infra/connect/connections/${e}/health/check`,{})}async googleConnectUrl(){return this.post("/infra/connect/google/connect-url",{})}async moveChannel(e,t){return this.post(`/infra/connect/${e}/move`,{ticket:t})}async requestChannelRelease(e,t){return this.post(`/infra/connect/${e}/release-request`,{ticket:t})}async channelReleaseRequest(e){return this.get(`/infra/connect/${e}/release-request`)}async cancelChannelRelease(e){return this.deleteRequest(`/infra/connect/${e}/release-request`)}async createPaymentLink(e){return this.post("/infra/connect/connections/payments/payment-link",e)}};var it=class extends s{async sendTest(e){return this.post("/infra/connect/email/test",{to:e})}async listTemplates(e){return this.get("/infra/connect/email/templates",{params:e})}async getTemplate(e){return this.get(`/infra/connect/email/templates/${e}`)}async createTemplate(e){return this.post("/infra/connect/email/templates",e)}async updateTemplate(e,t){return this.put(`/infra/connect/email/templates/${e}`,t)}async deleteTemplate(e,t=!1){return this.deleteRequest(`/infra/connect/email/templates/${e}`,{params:{force:t}})}async previewTemplate(e,t){return this.post(`/infra/connect/email/templates/${e}/preview`,t)}};var ot=class extends s{async create(e){return this.post("/infra/connect/meet",e)}async list(e){return this.get("/infra/connect/meet",{params:e})}async retrieve(e){return this.get(`/infra/connect/meet/${e}`)}async update(e,t){return this.patch(`/infra/connect/meet/${e}`,t)}async reschedule(e,t){return this.patch(`/infra/connect/meet/${e}`,t)}async delete(e){return this.update(e,{status:"cancelled"})}};var at=class extends s{async getConfig(){return this.get("/infra/connect/email/config")}async initDomainVerification(e){return this.post("/infra/connect/email/config/ses/domain",{domain:e})}async saveEmailConfig(e){return this.post("/infra/connect/email/config/ses/config",e)}async checkSesVerification(){return this.get("/infra/connect/email/config/ses/verify")}async removeSesIdentity(){return this.deleteRequest("/infra/connect/email/config/ses/domain")}async sendTest(e){return this.post("/infra/connect/email/config/test",{toEmail:e})}async saveAdvancedConfig(e){return this.post("/infra/connect/email/config/advanced",e)}async getHealth(){return this.get("/infra/connect/email/config/health")}async fixDmarc(){return this.post("/infra/connect/email/config/ses/fix-dmarc",{})}async listProviders(){return this.get("/infra/connect/email/config/providers")}};var ct=class extends s{async list(e){return this.get("/infra/connect/whatsapp/templates",{params:e})}async sync(){return this.post("/infra/connect/whatsapp/templates/sync",{})}async retrieve(e){return this.get(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}`)}async create(e){return this.post("/infra/connect/whatsapp/templates",e)}async update(e,t){return this.put(`/infra/connect/whatsapp/templates/${e}`,t)}async fix(e){return this.post(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}/fix`,{})}async resubmit(e,t){return this.post(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}/resubmit`,t)}async deleteTemplate(e,t){return this.deleteRequest(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}${t?"?force=true":""}`)}async mappingConfig(){return this.get("/infra/connect/whatsapp/templates/mapping/config")}async mappingSources(){return this.get("/infra/connect/whatsapp/templates/mapping/sources")}async collections(){return this.get("/infra/connect/whatsapp/templates/collections")}async collectionFields(e){return this.get(`/infra/connect/whatsapp/templates/collections/${encodeURIComponent(e)}/fields`)}async updateMapping(e,t){return this.put(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}/mapping`,t)}async validate(e,t){let r=`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}/validate`;return t?this.post(r,t):this.get(r)}async preview(e,t,r,o){return this.post(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}/preview`,{context:t,mappings:r,onEmptyVariable:o})}async getVariableManifest(e){var a,u;let t=await this.retrieve(e),r=Array.isArray((a=t.data)==null?void 0:a.components)?t.data.components:[],o=[];for(let d of r)if(d.text){let p=d.text.match(/{{(\d+)}}/g);if(p)for(let k of p){let f=k.replace(/{{|}}/g,"");o.push({key:`var_${f}`,label:`${d.type} Var {{${f}}}`,type:"string",required:!0,group:d.type,description:`Variable placeholder in template ${d.type}`})}}return{name:`Template variables: ${((u=t.data)==null?void 0:u.name)||e}`,fields:o,uiHints:{icon:"Variables",primaryColor:"#059669"}}}};var nn=n=>"queued"in n&&n.queued===!0,rn={runProgress:"laie:run:progress",importComplete:"laie:import:complete"},m=encodeURIComponent,l="/product/laie",j=class extends s{async list(){return this.get(`${l}/packs`)}async byId(e){return this.get(`${l}/packs/${m(e)}`)}},W=class extends s{async catalog(e={}){return this.get(`${l}/signals/catalog`,{params:e})}async list(e={}){return this.get(`${l}/signals`,{params:e})}},G=class extends s{async find(e){return this.post(`${l}/tools/find`,e)}async collect(e){return this.post(`${l}/tools/collect`,e)}async enrich(e){return this.post(`${l}/tools/enrich`,e)}async verify(e){return this.post(`${l}/tools/verify`,e)}async qualify(e){return this.post(`${l}/tools/qualify`,e)}async store(e){return this.post(`${l}/tools/store`,e)}async use(e){return this.post(`${l}/tools/use`,e)}async verifyEmail(e){return this.post(`${l}/tools/verify-email`,{emails:e})}async websiteLookup(e){return this.post(`${l}/tools/website-lookup`,{url:e})}},H=class extends s{async list(){return this.get(`${l}/campaigns`)}async create(e){return this.post(`${l}/campaigns`,e)}async byId(e){return this.get(`${l}/flows/${m(e)}`)}async settings(e){return this.get(`${l}/campaigns/${m(e)}/settings`)}async updateSettings(e,t){return this.patch(`${l}/campaigns/${m(e)}/settings`,t)}async signals(e){return this.get(`${l}/campaigns/${m(e)}/signals`)}async setSignals(e,t){return this.put(`${l}/campaigns/${m(e)}/signals`,t)}},z=class extends s{async start(e){return this.post(`${l}/campaigns/${m(e)}/runs`)}async list(e,t={}){return this.get(`${l}/campaigns/${m(e)}/runs`,{params:t})}async byId(e,t){return this.get(`${l}/campaigns/${m(e)}/runs/${m(t)}`)}async changes(e,t,r={}){return this.get(`${l}/campaigns/${m(e)}/runs/${m(t)}/changes`,{params:r})}async cancel(e,t){return this.post(`${l}/campaigns/${m(e)}/runs/${m(t)}/cancel`)}async quality(e){return this.get(`${l}/jobs/${m(e)}/quality`)}},Q=class extends s{async list(e={}){let o=e,{importedToCrm:t}=o,r=R(o,["importedToCrm"]);return this.get(`${l}/leads`,{params:g(g({},r),t!==void 0&&{importedToCrm:String(t)})})}async byId(e){return this.get(`${l}/leads/${m(e)}`)}async update(e,t){return this.patch(`${l}/leads/${m(e)}`,t)}async notes(e){return this.get(`${l}/leads/${m(e)}/notes`)}async addNote(e,t){return this.post(`${l}/leads/${m(e)}/notes`,t)}async generateKit(e){return this.post(`${l}/leads/${m(e)}/generate-kit`)}async pipelineSummary(){return this.get(`${l}/leads/pipeline-summary`)}async bulkContacted(e,t){return this.post(`${l}/leads/bulk/contacted`,{leadIds:e,channel:t})}async bulkTag(e,t){return this.post(`${l}/leads/bulk/tag`,{leadIds:e,tags:t})}async bulkDelete(e){return this.post(`${l}/leads/bulk/delete`,{leadIds:e})}async bulkExport(e,t="json"){return t==="csv"?this.post(`${l}/leads/bulk/export`,{leadIds:e,format:t},{responseType:"text"}):this.post(`${l}/leads/bulk/export`,{leadIds:e,format:t})}},Y=class extends s{async pipelines(){return this.get(`${l}/import/pipelines`)}async crm(e){return this.post(`${l}/import/crm`,e)}},J=class extends s{async enrich(e){return this.post(`${l}/lists/enrich`,e)}},X=class extends s{async dsr(e){return this.post(`${l}/compliance/dsr`,e)}async report(e={}){return this.get(`${l}/compliance/report`,{params:e})}},Z=class extends s{async map(e={}){return this.get(`${l}/market-map`,{params:e})}async forCampaign(e){return this.get(`${l}/campaigns/${m(e)}/market-map`)}async refresh(e={}){return this.post(`${l}/market-map/refresh`,e)}},ee=class extends s{async weights(e={}){return this.get(`${l}/learning/weights`,{params:e})}async outcomes(e={}){return this.get(`${l}/learning/outcomes`,{params:e})}},te=class extends s{async preview(e){return this.post(`${l}/lookalikes/preview`,e)}async create(e){return this.post(`${l}/lookalikes`,e)}async list(e={}){return this.get(`${l}/lookalikes`,{params:e})}async byId(e){return this.get(`${l}/lookalikes/${m(e)}`)}async rank(e,t={}){return this.get(`${l}/lookalikes/${m(e)}/rank`,{params:t})}},ne=class extends s{async status(){return this.get(`${l}/freshness`)}},re=class extends s{async start(e){return this.post(`${l}/audit`,e)}async byId(e){return this.get(`${l}/audit/${m(e)}`)}};var sn=Ae(require("axios"),1);var lt=class extends s{async getUsage(){return this.get("/infra/storage/files/usage")}async createFolder(e){return this.post("/infra/storage/files/folders",{name:e})}async list(e,t){return this.get(`/infra/storage/files/files/${e}`,{params:t})}async delete(e){return this.deleteRequest("/infra/storage/files/files",{params:{key:e}})}async getDownloadUrl(e){return this.post("/infra/storage/files/download-url",{key:e})}async aiDescribe(e){return this.post("/infra/storage/files/ai/describe",{key:e})}async upload(e,t){let r=await this.post("/infra/storage/files/upload-url",t),{uploadUrl:o,key:a}=r.data;await sn.default.put(o,e,{headers:{"Content-Type":t.contentType}});let u=e.size||e.byteLength||0;return this.post("/infra/storage/files/confirm-upload",{key:a,sizeBytes:u})}};var ut=class extends s{async list(){return this.get("/infra/connect/facebook/lead-forms")}async subscribe(){return this.post("/infra/connect/facebook/lead-forms/subscribe",{})}async setEnabled(e,t){return this.put(`/infra/connect/facebook/lead-forms/${encodeURIComponent(e)}`,{enabled:t})}async importLast24Hours(e){return this.post(`/infra/connect/facebook/lead-forms/${encodeURIComponent(e)}/import-last-24h`,{})}};var on={callChanged:"voice_call_changed"},Cn=["NOT_FOUND","VOICE_CALL_REFUSED","VOICE_NOT_SET_UP","VOICE_CAMPAIGN_NOT_APPROVED","VOICE_NOT_ENABLED","VOICE_AGENT_UNAVAILABLE","VOICE_RUNTIME_UNAVAILABLE","VOICE_PREVIEW_FAILED","VOICE_NOT_CONFIGURED","LEAD_NOT_FOUND","INSUFFICIENT_CREDITS"];function an(n){let e=n instanceof y?n.code:void 0;return e&&Cn.includes(e)?e:void 0}var Et={gate:"Voice calling isn't switched on for this workspace.",bad_number:"That phone number isn't a number we can call.",do_not_call:"They asked not to be called again.",dnd:"Their number is on the Do Not Disturb register.",hours:"No calling hours are open for this step.",recently_called:"They were called recently.",promotional:"Promotional calls aren't offered. Calls are for service, reminders, callbacks and demo follow-ups.",no_consent:"No record that they agreed to a phone call, or asked for one. They are not called.",campaign_stopped:"This campaign was stopped.",test_limit:"You can ring your own phone 3 times a day. Try again tomorrow.",not_on_plan:"Voice isn't on your plan. Upgrade your plan to use voice calls.",minutes_used_up:"You've used this month's included voice minutes. Your plan has no extra minutes.",low_balance:"Your balance is below \u20B910. Add credits to place voice calls."};function cn(n){var e;return(e=Et[n])!=null?e:n}var Ie=encodeURIComponent,Pe=class extends s{get flow(){return new I(this.client)}list(e={}){return this.flow.list(e)}retrieve(e){return this.flow.retrieve(e)}create(e){return this.flow.create(e)}launch(e,t={}){return this.flow.launch(e,t)}start(e,t={}){return this.flow.start(e,t)}pause(e){return this.flow.pause(e)}resume(e){return this.flow.resume(e)}stop(e){return this.flow.stop(e)}costPreview(e){return this.get(`/product/flow/campaigns/${Ie(e)}/voice-preview`)}counters(e){return this.get(`/infra/connect/voice/campaigns/${Ie(e)}/counters`)}approval(e){return this.get(`/infra/connect/voice/campaigns/${Ie(e)}/approval`)}requestApproval(e){return this.post(`/infra/connect/voice/campaigns/${Ie(e)}/approval/request`,{})}},se=class extends s{constructor(t){super(t);i(this,"campaigns");this.campaigns=new Pe(t)}status(){return this.get("/infra/connect/voice/status")}setup(){return this.get("/infra/connect/voice/setup")}setupNumbers(){return this.get("/infra/connect/voice/setup/numbers")}kycUploadUrl(t){return this.post("/infra/connect/voice/setup/kyc/upload-url",t)}submitKyc(t){return this.post("/infra/connect/voice/setup/kyc",t)}pickNumber(t){return this.post("/infra/connect/voice/setup/number",{number:t})}askForNumber(){return this.post("/infra/connect/voice/setup/number/request",{})}goLive(){return this.post("/infra/connect/voice/setup/go-live",{})}agent(){return this.get("/infra/connect/voice/agent")}skills(){return this.get("/infra/connect/voice/skills")}voices(t){return this.get(`/infra/connect/voice/voices?language=${encodeURIComponent(t)}`)}saveAgent(t){return this.put("/infra/connect/voice/agent",t)}async preview(t={}){var r;try{return(await this.client.post("/infra/connect/voice/preview",t,{responseType:"arraybuffer"})).data}catch(o){let a=(r=o==null?void 0:o.response)==null?void 0:r.data;if(a instanceof ArrayBuffer||ArrayBuffer.isView(a))try{o.response.data=JSON.parse(new TextDecoder().decode(a))}catch(u){o.response.data=void 0}throw $(o)}}lines(){return this.get("/infra/connect/voice/lines")}activity(){return this.get("/infra/connect/voice/activity")}calls(t={}){return this.get("/infra/connect/voice/calls",{params:t})}call(t){return this.get(`/infra/connect/voice/calls/${Ie(t)}`)}callWithAI(t){return this.post("/infra/connect/voice/calls",t)}checkCallWithAI(t){return this.post("/infra/connect/voice/calls/check",t)}callMyPhone(t={}){return this.post("/infra/connect/voice/calls/my-phone",t)}testCall(t={}){return this.post("/infra/connect/voice/test-call",t)}};var ie=class extends s{async list(){return this.get("/product/seo/projects")}async create(e){return this.post("/product/seo/projects",e)}async byId(e){return this.get(`/product/seo/projects/${e}`)}async update(e,t){return this.patch(`/product/seo/projects/${e}`,t)}async remove(e){return this.deleteRequest(`/product/seo/projects/${e}`)}async crawl(e){return this.post(`/product/seo/projects/${e}/crawl`)}async crawlCompetitor(e,t){return this.post(`/product/seo/projects/${e}/competitors/crawl`,{domain:t})}},oe=class extends s{async start(e){return this.post("/product/seo/audits",e)}async list(e={}){return this.get("/product/seo/audits",{params:e})}async compare(e){return this.post("/product/seo/audits/compare",e)}async byId(e){return this.get(`/product/seo/audits/${e}`)}async resume(e){return this.post(`/product/seo/audits/${e}/resume`)}async pages(e,t={}){return this.get(`/product/seo/audits/${e}/pages`,{params:t})}async issues(e){return this.get(`/product/seo/audits/${e}/issues`)}async links(e){return this.get(`/product/seo/audits/${e}/links`)}async export(e,t="json"){return this.get(`/product/seo/audits/${e}/export`,{params:{format:t},responseType:"text"})}},ae=class extends s{async keywords(e,t={}){return this.get(`/product/seo/audits/${e}/keywords`,{params:t})}async contentGap(e){return this.post("/product/seo/audits/content-gap",e)}async search(e){return this.post("/product/seo/audits/search",e)}async backlinks(e){return this.get("/product/seo/audits/backlinks",{params:e})}async domain(e){return this.get(`/product/seo/audits/domains/${encodeURIComponent(e)}`)}},ce=class extends s{async check(e){return this.post(`/product/seo/search-console/${e}/check`)}async importNow(e){return this.post(`/product/seo/search-console/${e}/import`)}async status(e){return this.get(`/product/seo/search-console/${e}/status`)}async queries(e,t={}){return this.get(`/product/seo/search-console/${e}/queries`,{params:t})}async pages(e,t={}){return this.get(`/product/seo/search-console/${e}/pages`,{params:t})}async trend(e,t={}){return this.get(`/product/seo/search-console/${e}/trend`,{params:t})}},le=class extends s{async keywords(e){return this.get(`/product/seo/ranks/${e}/keywords`)}async add(e,t,r={}){return this.post(`/product/seo/ranks/${e}/keywords`,g({queries:t},r))}async visibility(e,t={}){return this.get(`/product/seo/ranks/${e}/visibility`,{params:t})}async competitors(e){return this.get(`/product/seo/ranks/${e}/competitors`)}async gap(e,t={}){return this.get(`/product/seo/ranks/${e}/gap`,{params:t})}async remove(e,t){return this.deleteRequest(`/product/seo/ranks/${e}/keywords/${t}`)}async checkNow(e,t){return this.post(`/product/seo/ranks/${e}/keywords/${t}/check`)}async history(e,t,r={}){return this.get(`/product/seo/ranks/${e}/keywords/${t}/history`,{params:r})}async changes(e){return this.get(`/product/seo/ranks/${e}/changes`)}},ue=class extends s{async checkNow(e){return this.post(`/product/seo/local/${e}/check`)}async latest(e){return this.get(`/product/seo/local/${e}`)}async history(e,t={}){return this.get(`/product/seo/local/${e}/history`,{params:t})}async startGrid(e,t={}){return this.post(`/product/seo/local/${e}/grid`,t)}async grid(e){return this.get(`/product/seo/local/${e}/grid`)}async grids(e,t={}){return this.get(`/product/seo/local/${e}/grids`,{params:t})}},pe=class extends s{async byProject(e){return this.get(`/product/seo/reports/${e}`)}async export(e,t="csv"){return this.get(`/product/seo/reports/${e}/export`,{params:{format:t},responseType:"text"})}async pdf(e,t={}){return this.get(`/product/seo/reports/${e}/pdf`,{params:t,responseType:"arraybuffer"})}async generate(e,t={}){return this.post(`/product/seo/reports/${e}/generate`,t)}async history(e,t={}){return this.get(`/product/seo/reports/${e}/history`,{params:t})}async changes(e){return this.get(`/product/seo/reports/${e}/changes`)}},ge=class extends s{async seed(e,t,r="en"){return this.post(`/product/seo/research/${e}/seed`,{seed:t,lang:r})}async fromSearchConsole(e){return this.post(`/product/seo/research/${e}/from-search-console`)}async ideas(e,t={}){return this.get(`/product/seo/research/${e}/ideas`,{params:t})}async analyze(e,t){return this.post(`/product/seo/research/${e}/ideas/${t}/analyze`)}};var de=class extends s{async releases(){return this.get("/product/seo/backlinks/releases")}async strength(e){return this.get("/product/seo/backlinks/strength",{params:{domains:e.join(",")}})}async overview(e){return this.get(`/product/seo/backlinks/${e}`)}async referring(e,t){return this.get(`/product/seo/backlinks/${e}/referring`,{params:t})}async changes(e,t){return this.get(`/product/seo/backlinks/${e}/changes`,{params:t})}},me=class extends s{async checkNow(e){return this.post(`/product/seo/performance/${e}/check`)}async latest(e){return this.get(`/product/seo/performance/${e}`)}async history(e,t={}){return this.get(`/product/seo/performance/${e}/history`,{params:t})}},ye=class extends s{async create(e){return this.post("/product/seo/briefs",e)}async byId(e){return this.get(`/product/seo/briefs/${e}`)}async list(e,t={}){return this.get("/product/seo/briefs",{params:g({projectId:e},t)})}};var wn=35e3,fe=class extends s{async claim(e,t){var o;let r=await this.post("/infra/serp/collector/claim",{collectorId:e,kinds:t},{timeout:wn});return(o=r&&typeof r=="object"?r.data:null)!=null?o:null}async result(e){return this.post("/infra/serp/collector/result",e)}async heartbeat(e,t){return this.post("/infra/serp/collector/heartbeat",g({collectorId:e},t))}};var pt=class extends s{async create(e){return this.post("/infra/storage/files/folders",{name:e})}},gt=class extends s{async list(e,t){return this.get(`/infra/storage/files/files/${e}`,{params:t})}async getUploadUrl(e){return this.post("/infra/storage/files/upload-url",e)}async confirmUpload(e){return this.post("/infra/storage/files/confirm-upload",e)}async getDownloadUrl(e){return this.post("/infra/storage/files/download-url",{key:e})}async delete(e){return this.deleteRequest("/infra/storage/files/files",{params:{key:e}})}};var be=class extends s{async settings(){return this.get("/product/erix/ai/settings")}async updateSettings(e){return this.patch("/product/erix/ai/settings",e)}async outcomes(e={}){return this.get("/product/erix/ai/outcomes",{params:e})}async reviews(e){return this.get(`/product/erix/ai/reviews${e?`?status=${e}`:""}`)}async review(e,t,r){return this.post(`/product/erix/ai/reviews/${encodeURIComponent(e)}`,g({verdict:t},r?{note:r}:{}))}async suggestion(e){return this.get(`/product/erix/ai/suggestion/${e}`)}async approveAction(e){return this.post(`/product/erix/ai/suggestion/${e}/approve-action`,{})}async markSent(e,t,r){return this.post(`/product/erix/ai/suggestion/${e}/send`,{text:t,confidence:r})}async dismiss(e){return this.post(`/product/erix/ai/suggestion/${e}/dismiss`,{})}async approvals(){return this.get("/product/flow/approvals")}async agents(){return this.get("/product/flow/agents")}async agent(e){return this.get(`/product/flow/agents/${encodeURIComponent(e)}`)}async tryAgent(e,t){return this.post(`/product/flow/agents/${encodeURIComponent(e)}/try`,t)}async agentTemplates(){return this.get("/product/flow/agents/templates")}async createAgent(e){return this.post("/product/flow/agents",e)}async updateAgent(e,t){return this.patch(`/product/flow/agents/${encodeURIComponent(e)}`,t)}async deleteAgent(e){return this.deleteRequest(`/product/flow/agents/${encodeURIComponent(e)}`)}async agentAutomation(e,t){return this.post(`/product/flow/agents/${encodeURIComponent(e)}/automation`,{trigger:t})}async decideRun(e,t,r){return this.post(`/product/flow/runs/${encodeURIComponent(e)}/approve`,g({decision:t},r&&{nodeId:r}))}};var dt=class extends s{async system(){return(await this.get("/health")).data}};var mt=class extends s{async listAlerts(e){return this.get("/platform/users/notifications",{params:e})}async dismissAlert(e){return this.patch(`/platform/users/notifications/${e}/dismiss`)}async clearAllAlerts(){return this.deleteRequest("/platform/users/notifications/dismiss-all")}};var he=class extends s{async global(e){return this.post("/platform/tenants/onboarding/global",e)}async complete(e){return this.post("/platform/tenants/onboarding/complete",e)}};var xe=class extends s{async get(e){return super.get(`/platform/tenants/persona/${e}`)}async reinforce(e){return this.post(`/platform/tenants/persona/${e.productId}/reinforce`,e)}async confidence(e){return super.get(`/platform/tenants/persona/${e}/confidence`,{params:{productId:e}})}async timeline(e,t){var o;let r=await super.get(`/platform/tenants/persona/${e}/timeline`,{params:t});return(o=r==null?void 0:r.data)!=null?o:{entries:[],hasMore:!1}}async followups(e){var r,o;let t=await super.get(`/platform/tenants/persona/${e}/followups`);return(o=(r=t==null?void 0:t.data)==null?void 0:r.entries)!=null?o:[]}};var $t=class extends s{async chatSync(e){return this.post("/platform/ai/copilot/chat/sync",e)}async confirm(e){return this.post("/platform/ai/copilot/confirm",e)}async listSessions(){return this.get("/platform/ai/copilot/sessions")}async getSession(e){return this.get(`/platform/ai/copilot/sessions/${e}`)}async deleteSession(e){return this.deleteRequest(`/platform/ai/copilot/sessions/${e}`)}chatStreamUrl(){return"/platform/ai/copilot/chat"}},yt=class{constructor(e){i(this,"copilot");this.copilot=new $t(e)}};var ft=class extends s{async list(e){return this.get("/platform/tenants/audit",{params:e})}};var bt=class extends s{async register(e){return this.post("/platform/auth/register",e)}async login(e){return this.post("/platform/auth/login",e)}async logout(e){return this.post("/platform/auth/logout",e)}async logoutAll(e){return this.post("/platform/auth/logout-all",e)}async validateSession(e){return this.post("/platform/auth/session/validate",e)}async listSessions(){return this.get("/platform/auth/sessions")}async revokeSession(e){return this.deleteRequest(`/platform/auth/sessions/${e}`)}async requestPasswordOtp(e){return this.post("/platform/auth/password/request-otp",e)}async setPassword(e){return this.post("/platform/auth/password/set",e)}async changePassword(e){return this.post("/platform/auth/password/change",e)}async forgotPassword(e){return this.post("/platform/auth/forgot",e)}async resetPassword(e){return this.post("/platform/auth/reset",e)}async linkOAuth(e){return this.post("/platform/auth/oauth-link",e)}async getInvitation(e){return this.get(`/platform/auth/invitations/${e}`)}async acceptInvitation(e,t){return this.post(`/platform/auth/invitations/${e}/accept`,t)}};var Ot=class extends s{async get(){return super.get("/platform/billing/entitlements/entitlements")}async usage(){return super.get("/platform/billing/entitlements/usage")}},Vt=class extends s{async upgrade(e){return this.post("/platform/billing/subscriptions/subscriptions/upgrade",e)}async downgrade(e){return this.post("/platform/billing/subscriptions/subscriptions/downgrade",e)}async cancel(e){return this.post("/platform/billing/subscriptions/subscriptions/cancel",e)}},Dt=class extends s{list(){return this.get("/platform/billing/addons")}add(e,t){return this.post(`/platform/billing/addons/${encodeURIComponent(e)}/add`,t===void 0?{}:{quantity:t})}remove(e){return this.post(`/platform/billing/addons/${encodeURIComponent(e)}/remove`)}overage(){return this.get("/platform/billing/overage")}setOverage(e){return this.put("/platform/billing/overage",e)}},Ft=class extends s{async listPublic(){return this.get("/platform/billing/plans/public")}},Mt=class extends s{async plans(){return this.get("/platform/billing/checkout/plans")}async proration(e,t){return this.get("/platform/billing/checkout/proration",{params:{planId:e,billingCycle:t}})}async subscribe(e){return this.post("/platform/billing/checkout/subscribe",e)}async verify(e){return this.post("/platform/billing/checkout/verify",e)}async cancel(e){return this.post("/platform/billing/checkout/cancel",e)}async status(){return this.get("/platform/billing/checkout/status")}async syncPlan(e){return this.post("/platform/billing/checkout/sync-plan",e)}},_t=class extends s{async transactions(){return this.get("/platform/billing/user/transactions")}async transactionInvoice(e){return this.get(`/platform/billing/user/transactions/${encodeURIComponent(e)}/invoice`)}async subscription(){return this.get("/platform/billing/user/subscription")}async raiseDispute(e){return this.post("/platform/billing/user/dispute",e)}async disputes(){return this.get("/platform/billing/user/disputes")}},Ut=class extends s{async balance(){return this.get("/platform/billing/credits/balance")}async transactions(){return this.get("/platform/billing/credits/transactions")}async packs(){return this.get("/platform/billing/credits/packs")}async topupOrder(e){return this.post("/platform/billing/credits/topup/order",e)}async verifyTopup(e){return this.post("/platform/billing/credits/topup/verify",e)}async setAutoTopup(e){return this.patch("/platform/billing/credits/auto-topup",e)}async setSpendCap(e){return this.patch("/platform/billing/credits/spend-cap",e)}},ht=class{constructor(e){i(this,"entitlements");i(this,"subscriptions");i(this,"plans");i(this,"checkout");i(this,"user");i(this,"credits");i(this,"addOns");this.entitlements=new Ot(e),this.subscriptions=new Vt(e),this.plans=new Ft(e),this.checkout=new Mt(e),this.user=new _t(e),this.credits=new Ut(e),this.addOns=new Dt(e)}};var ke=class extends s{async list(){return this.get("/platform/public/catalog",{ignoreClientCode:!0})}};var ln=["application/pdf","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/plain","text/markdown","text/csv","text/html","image/png","image/jpeg","image/webp"],Ce=class extends s{async list(){return this.get("/platform/knowledge/sources")}async addText(e){return this.post("/platform/knowledge/sources",g({kind:"text"},e))}async addUrl(e){return this.post("/platform/knowledge/sources",g({kind:"url"},e))}async addWebsite(e){return this.post("/platform/knowledge/sources",{type:"website",url:e.url})}async addFile(e,t={}){var o,a;let r=await new K(this.client).upload(e,{folder:"knowledge"});return this.post("/platform/knowledge/sources",{kind:"file",key:r.key,mimeType:r.mimeType,title:(a=(o=t.title)!=null?o:r.fileName)!=null?a:"Document"})}async remove(e){return this.deleteRequest(`/platform/knowledge/sources/${e}`)}async reindex(e){return this.post(`/platform/knowledge/sources/${e}/reindex`,{})}async search(e,t){return this.post("/platform/knowledge/search",g({query:e},t?{limit:t}:{}))}};var xt=class extends s{async categories(){return this.get("/platform/support/categories")}async listTickets(e){return this.get("/platform/support/tickets",{params:e})}async createTicket(e){return this.post("/platform/support/tickets",e)}async getTicket(e){return this.get(`/platform/support/tickets/${e}`)}async reply(e,t){return this.post(`/platform/support/tickets/${e}/reply`,t)}async close(e){return this.patch(`/platform/support/tickets/${e}/close`,{})}async channelSetup(e){return this.get(`/platform/support/channel-requests/${encodeURIComponent(e)}/setup`)}};var kt=class extends s{async get(){return super.get("/platform/users/me")}async update(e){return this.patch("/platform/users/me",e)}async updateOrganization(e){return this.patch("/platform/users/me/organization",e)}async toggleModules(e){return this.post("/platform/users/me/modules",e)}async workspaces(){return super.get("/platform/users/me/workspaces")}async setActiveOrg(e){return this.post("/platform/users/me/active-org",e)}async dismissWorkspaceSetup(){return this.post("/platform/users/me/workspace/dismiss-setup",{})}},Ct=class extends s{async list(){return this.get("/platform/users/members")}async access(){return this.get("/platform/users/members/access")}async invite(e){return this.post("/platform/users/members/invite",e)}async updateAccess(e,t){return this.patch(`/platform/users/members/${encodeURIComponent(e)}`,t)}async updateRole(e,t){return this.updateAccess(e,{role:t})}async remove(e){return this.deleteRequest(`/platform/users/members/${encodeURIComponent(e)}`)}async invitations(){return this.get("/platform/users/members/invitations")}async resendInvitation(e){return this.post(`/platform/users/members/invitations/${encodeURIComponent(e)}/resend`,{})}async revokeInvitation(e){return this.deleteRequest(`/platform/users/members/invitations/${encodeURIComponent(e)}`)}},wt=class extends s{async list(){return this.get("/platform/auth/sessions")}async revoke(e){return this.deleteRequest(`/platform/auth/sessions/${e}`)}};var Le=class{constructor(e){i(this,"messages");i(this,"conversations");this.messages=new K(e),this.conversations=new rt(e)}},Ee=class{constructor(e){i(this,"leads");i(this,"pipelines");i(this,"activities");i(this,"analytics");i(this,"scoring");i(this,"payments");i(this,"chat");i(this,"events");i(this,"invoices");i(this,"checkout");i(this,"projects");i(this,"niche");i(this,"documents");i(this,"invoiceExport");i(this,"ai");this.leads=new Qe(e),this.pipelines=new Je(e),this.activities=new We(e),this.analytics=new Ge(e),this.scoring=new Xe(e),this.payments=new Ye(e),this.chat=new Le(e),this.events=new Ze(e),this.invoices=new et(e),this.checkout=new je(e),this.projects=new nt(e),this.niche=new tt(e),this.documents=new He(e),this.invoiceExport=new ze(e),this.ai=new be(e)}},$e=class{constructor(e){i(this,"automations");i(this,"campaigns");i(this,"conversations");i(this,"home");i(this,"drafts");i(this,"firstRun");i(this,"audiences");this.automations=new F(e),this.campaigns=new I(e),this.conversations=new _(e),this.home=new U(e),this.drafts=new N(e),this.firstRun=new B(e),this.audiences=new q(e)}},Oe=class{constructor(e){i(this,"projects");i(this,"audits");i(this,"insights");i(this,"searchConsole");i(this,"ranks");i(this,"local");i(this,"reports");i(this,"backlinks");i(this,"performance");i(this,"briefs");i(this,"research");this.projects=new ie(e),this.audits=new oe(e),this.insights=new ae(e),this.searchConsole=new ce(e),this.ranks=new le(e),this.local=new ue(e),this.reports=new pe(e),this.backlinks=new de(e),this.performance=new me(e),this.briefs=new ye(e),this.research=new ge(e)}},Ve=class{constructor(e){i(this,"packs");i(this,"signals");i(this,"tools");i(this,"campaigns");i(this,"runs");i(this,"leads");i(this,"import");i(this,"lists");i(this,"compliance");i(this,"market");i(this,"learning");i(this,"lookalikes");i(this,"freshness");i(this,"audit");this.packs=new j(e),this.signals=new W(e),this.tools=new G(e),this.campaigns=new H(e),this.runs=new z(e),this.leads=new Q(e),this.import=new Y(e),this.lists=new J(e),this.compliance=new X(e),this.market=new Z(e),this.learning=new ee(e),this.lookalikes=new te(e),this.freshness=new ne(e),this.audit=new re(e)}},we=class{constructor(e){i(this,"erix");i(this,"flow");i(this,"seo");i(this,"laie");this.erix=new Ee(e),this.flow=new $e(e),this.seo=new Oe(e),this.laie=new Ve(e)}},De=class{constructor(e){i(this,"config");i(this,"templates");this.config=new at(e),this.templates=new it(e)}},Fe=class{constructor(e){i(this,"templates");this.templates=new ct(e)}},Nt=class{constructor(e){i(this,"leadForms");this.leadForms=new ut(e)}},Me=class{constructor(e){i(this,"email");i(this,"whatsapp");i(this,"facebook");i(this,"meet");i(this,"connections");i(this,"voice");this.email=new De(e),this.whatsapp=new Fe(e),this.facebook=new Nt(e),this.meet=new ot(e),this.connections=new st(e),this.voice=new se(e)}},_e=class{constructor(e){i(this,"files");i(this,"folders");i(this,"media");this.files=new gt(e),this.folders=new pt(e),this.media=new lt(e)}},Bt=class{constructor(e){i(this,"collector");this.collector=new fe(e)}},ve=class{constructor(e){i(this,"connect");i(this,"storage");i(this,"serp");this.connect=new Me(e),this.storage=new _e(e),this.serp=new Bt(e)}},Ue=class{constructor(e){i(this,"onboarding");i(this,"persona");i(this,"audit");this.onboarding=new he(e),this.persona=new xe(e),this.audit=new ft(e)}},Ne=class{constructor(e){i(this,"me");i(this,"members");i(this,"sessions");i(this,"notifications");this.me=new kt(e),this.members=new Ct(e),this.sessions=new wt(e),this.notifications=new mt(e)}},Te=class{constructor(e){i(this,"auth");i(this,"users");i(this,"tenants");i(this,"billing");i(this,"support");i(this,"ai");i(this,"knowledge");i(this,"health");i(this,"catalog");this.auth=new bt(e),this.users=new Ne(e),this.tenants=new Ue(e),this.billing=new ht(e),this.support=new xt(e),this.ai=new yt(e),this.knowledge=new Ce(e),this.health=new dt(e),this.catalog=new ke(e)}};var P=class extends y{constructor(e){super(e,400,"invalid_signature"),this.name="WebhookSignatureError"}},Se=class{async constructEvent(e,t,r){if(!t)throw new P("No webhook signature provided");let o=Array.isArray(t)?t[0]:t;o.startsWith("sha256=")&&(o=o.slice(7));try{let a=await import("crypto"),d=a.createHmac("sha256",r).update(e).digest("hex");if(!a.timingSafeEqual(Buffer.from(d),Buffer.from(o)))throw new P("Invalid webhook signature provided");return JSON.parse(e.toString("utf8"))}catch(a){throw a instanceof P?a:new P(`Webhook payload parsing failed: ${a.message}`)}}};var qt=typeof process!="undefined"&&"4.0.2"||"3.1.1";var un,Kt=(un=jt.default.default)!=null?un:jt.default,O=class{constructor(e){i(this,"client");i(this,"socket",null);i(this,"startSocket",null);i(this,"socketPromise",null);i(this,"socketQueue",[]);i(this,"clientCode");i(this,"apiVersion");i(this,"platform");i(this,"product");i(this,"infra");i(this,"webhooks");i(this,"lastSeq");i(this,"closed",!1);var f,T,L,V,h,Gt,Ht,zt;let t=e.proxy;if(!e.apiKey&&!t)throw new v("API Key is required");this.clientCode=(f=e.clientCode)==null?void 0:f.toUpperCase(),this.apiVersion=(T=e.version)!=null?T:"v1";let r=(L=e.baseUrl)!=null?L:Rt,o=tn(this.apiVersion,(V=t==null?void 0:t.url)!=null?V:r),a=e.socketUrl||r,u=typeof window!="undefined"&&typeof window.document!="undefined",d=u?"browser":typeof process!="undefined"?`node ${process.version}`:"unknown",p=u?((h=globalThis.navigator)==null?void 0:h.userAgent)||"browser":typeof process!="undefined"?process.platform:"unknown",k=E(g({},t?{}:{"x-api-key":e.apiKey,"x-client-code":((Gt=e.clientCode)==null?void 0:Gt.toUpperCase())||""}),{"Content-Type":"application/json","x-ecodrix-client-agent":JSON.stringify({sdk_version:qt,runtime:d,os:p})});if(this.client=pn.default.create({baseURL:o,headers:k,timeout:(Ht=e.timeout)!=null?Ht:3e4}),Kt(this.client,{retries:3,retryDelay:Kt.exponentialDelay,retryCondition:w=>{var Be;return Kt.isNetworkOrIdempotentRequestError(w)||((Be=w.response)==null?void 0:Be.status)===429},onRetry:(w,Be,Qt)=>{var Yt,Jt;typeof process!="undefined"&&((Yt=process.env)==null?void 0:Yt.NODE_ENV)==="development"&&console.warn(`[ECODrIx SDK] Retrying request (${w}/3): ${(Jt=Qt.method)==null?void 0:Jt.toUpperCase()} ${Qt.url}. Reason: ${Be.message}`)}}),this.platform=new Te(this.client),this.product=new we(this.client),this.infra=new ve(this.client),this.webhooks=new Se,t){if(t.ticket){let w=t.ticket;this.startSocket=()=>this.initSocket(a,async()=>({ticket:await w()}))}}else{let w={apiKey:e.apiKey,clientCode:((zt=e.clientCode)==null?void 0:zt.toUpperCase())||""};this.startSocket=()=>this.initSocket(a,async()=>w,{"x-api-key":w.apiKey,"x-client-code":w.clientCode})}if(u){let w={version:qt,clientCode:e.clientCode,initializedAt:new Date().toISOString()};window.__ECODRIX_SDK__=w}}initSocket(e,t,r){return this.socketPromise?this.socketPromise:(this.socketPromise=import("socket.io-client").then(({io:o})=>{this.socket=o(e,{auth:a=>{t().then(u=>a(E(g({},u),{lastSeq:this.lastSeq})),()=>a({lastSeq:this.lastSeq}))},extraHeaders:r}),this.setupSocket();for(let{type:a,args:u}of this.socketQueue)a==="joinRoom"?this.socket.emit("join-room",u[0]):a==="leaveRoom"?this.socket.emit("leave-room",u[0]):a==="on"?this.socket.on(u[0],u[1]):a==="off"?this.socket.off(u[0],u[1]):a==="disconnect"&&this.socket.disconnect();this.socketQueue=[]}),this.socketPromise)}joinRoom(e){var t;this.closed||(t=this.startSocket)==null||t.call(this),this.socket?this.socket.emit("join-room",e):this.socketQueue.push({type:"joinRoom",args:[e]})}leaveRoom(e){this.socket?this.socket.emit("leave-room",e):this.socketQueue.push({type:"leaveRoom",args:[e]})}setupSocket(){this.socket&&(this.socket.on("connect_error",()=>{var e;(e=this.socket)!=null&&e.active||setTimeout(()=>{var t;this.closed||(t=this.socket)==null||t.connect()},5e3)}),this.socket.onAny((...e)=>{var r,o;let t=(r=e.at(-1))==null?void 0:r.seq;typeof t=="number"&&t>((o=this.lastSeq)!=null?o:0)&&(this.lastSeq=t)}))}on(e,t){var r;return this.closed||(r=this.startSocket)==null||r.call(this),this.socket?this.socket.on(e,t):this.socketQueue.push({type:"on",args:[e,t]}),this}disconnect(){this.closed=!0,this.socket?this.socket.disconnect():this.socketPromise&&this.socketQueue.push({type:"disconnect",args:[]})}off(e,t){return this.socket?this.socket.off(e,t):this.socketQueue.push({type:"off",args:[e,t]}),this}async request(e,t,r,o){var a,u,d;try{return(await this.client.request({method:e,url:t,data:r,params:o})).data}catch(p){throw p.response?new y(((a=p.response.data)==null?void 0:a.message)||((u=p.response.data)==null?void 0:u.error)||"Raw Execution Failed",p.response.status,(d=p.response.data)==null?void 0:d.code):new y(p.message||"Network Error")}}};var Tn={401:v,403:D,429:A};function Sn(n){throw $(n)}function Rn(n,e){return n instanceof e}function An(n){return n instanceof v?{message:n.message,status:n.status,code:n.code,type:"AuthenticationError"}:n instanceof A?{message:n.message,status:n.status,code:n.code,type:"RateLimitError"}:n instanceof y?{message:n.message,status:n.status,code:n.code,type:"APIError"}:{message:n.message||"Unknown error",type:"UnknownError"}}var Wt={[v.name]:{shouldRetry:!1,reason:"Authentication errors require fixing credentials, not retrying"},[A.name]:{shouldRetry:!0,maxRetries:3,baseDelay:1e3,backoffMultiplier:2,reason:"Rate limit errors can be retried with exponential backoff"},[y.name]:{shouldRetry:!0,maxRetries:2,baseDelay:500,backoffMultiplier:1.5,reason:"Generic API errors may be transient and worth retrying"}};function In(n){let e=n.constructor.name;return Wt[e]||Wt[y.name]}var Pn=O;0&&(module.exports={APIError,APIResource,AiAgent,AuthenticationError,Campaigns,Catalog,Collector,ConnectInfra,ECODrIx,ECODrIxAPI,ERROR_RETRY_CONFIG,EcodrixError,EmailConnect,ErixChat,ErixProduct,FlowAudiences,FlowAutomations,FlowConversations,FlowDrafts,FlowFirstRunResource,FlowHome,FlowProduct,HTTP_STATUS_ERROR_MAP,InfraDomain,KNOWLEDGE_FILE_TYPES,Knowledge,LAIE_EVENTS,LEAD_STATUS_VALUES,LaieAudits,LaieCampaigns,LaieCompliance,LaieFreshness,LaieImport,LaieLeads,LaieLearning,LaieLists,LaieLookalikes,LaieMarket,LaiePacks,LaieProduct,LaieRuns,LaieSignals,LaieTools,Onboarding,PermissionError,Persona,PlatformDomain,PlatformTenants,PlatformUsers,ProductDomain,RateLimitError,SeoAudits,SeoBacklinks,SeoBriefs,SeoInsights,SeoLocal,SeoPerformance,SeoProduct,SeoProjects,SeoRanks,SeoReports,SeoResearch,SeoSearchConsole,StorageInfra,VOICE_EVENTS,VOICE_REFUSAL_REASONS,Voice,VoiceCampaigns,WebhookSignatureError,Webhooks,WhatsAppConnect,getErrorDetails,getRetryConfig,handleAPIError,isAPIError,laieStageQueued,toAPIError,voiceErrorCode,voiceRefusalReason});
1
+ "use strict";var dn=Object.create;var Re=Object.defineProperty,mn=Object.defineProperties,yn=Object.getOwnPropertyDescriptor,fn=Object.getOwnPropertyDescriptors,bn=Object.getOwnPropertyNames,Ke=Object.getOwnPropertySymbols,hn=Object.getPrototypeOf,St=Object.prototype.hasOwnProperty,Zt=Object.prototype.propertyIsEnumerable;var xn=(n,e)=>(e=Symbol[n])?e:Symbol.for("Symbol."+n);var Tt=(n,e,t)=>e in n?Re(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,g=(n,e)=>{for(var t in e||(e={}))St.call(e,t)&&Tt(n,t,e[t]);if(Ke)for(var t of Ke(e))Zt.call(e,t)&&Tt(n,t,e[t]);return n},E=(n,e)=>mn(n,fn(e));var A=(n,e)=>{var t={};for(var r in n)St.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&Ke)for(var r of Ke(n))e.indexOf(r)<0&&Zt.call(n,r)&&(t[r]=n[r]);return t};var kn=(n,e)=>{for(var t in e)Re(n,t,{get:e[t],enumerable:!0})},en=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of bn(e))!St.call(n,o)&&o!==t&&Re(n,o,{get:()=>e[o],enumerable:!(r=yn(e,o))||r.enumerable});return n};var Ie=(n,e,t)=>(t=n!=null?dn(hn(n)):{},en(e||!n||!n.__esModule?Re(t,"default",{value:n,enumerable:!0}):t,n)),Cn=n=>en(Re({},"__esModule",{value:!0}),n);var i=(n,e,t)=>Tt(n,typeof e!="symbol"?e+"":e,t);var At=function(n,e){this[0]=n,this[1]=e},tn=(n,e,t)=>{var r=(d,p,k,f)=>{try{var T=t[d](p),L=(p=T.value)instanceof At,V=T.done;Promise.resolve(L?p[0]:p).then(h=>L?r(d==="return"?d:"next",p[1]?{done:h.done,value:h.value}:h,k,f):k({value:h,done:V})).catch(h=>r("throw",h,k,f))}catch(h){f(h)}},o=(d,p,k,f)=>u[d]=T=>(p=new Promise((L,V,h)=>(h=()=>r(d,T,L,V),a?a.then(h):h())),f=()=>a===k&&(a=0),a=k=p.then(f,f),p),a,u={};return t=t.apply(n,e),u[xn("asyncIterator")]=()=>u,o("next"),o("throw"),o("return"),u};var En={};kn(En,{APIError:()=>y,APIResource:()=>s,AiAgent:()=>F,AuthenticationError:()=>v,Campaigns:()=>I,Catalog:()=>ae,Collector:()=>Ce,ConnectAccounts:()=>U,ConnectInfra:()=>Me,ECODrIx:()=>O,ECODrIxAPI:()=>O,ERROR_RETRY_CONFIG:()=>Gt,EcodrixError:()=>je,EmailConnect:()=>Fe,ErixChat:()=>Ee,ErixProduct:()=>$e,FlowAudiences:()=>j,FlowAutomations:()=>M,FlowConversations:()=>N,FlowDrafts:()=>q,FlowFirstRunResource:()=>K,FlowHome:()=>B,FlowProduct:()=>Oe,HTTP_STATUS_ERROR_MAP:()=>Sn,InfraDomain:()=>Te,KNOWLEDGE_FILE_TYPES:()=>an,Knowledge:()=>le,LAIE_EVENTS:()=>sn,LEAD_STATUS_VALUES:()=>Et,LaieAudits:()=>se,LaieCampaigns:()=>Q,LaieCompliance:()=>Z,LaieFreshness:()=>re,LaieImport:()=>J,LaieLeads:()=>Y,LaieLearning:()=>te,LaieLists:()=>X,LaieLookalikes:()=>ne,LaieMarket:()=>ee,LaiePacks:()=>W,LaieProduct:()=>De,LaieRuns:()=>z,LaieSignals:()=>G,LaieTools:()=>H,Onboarding:()=>ie,PermissionError:()=>D,Persona:()=>oe,PlatformDomain:()=>Se,PlatformTenants:()=>Ne,PlatformUsers:()=>Be,ProductDomain:()=>ve,RateLimitError:()=>R,SeoAudits:()=>pe,SeoBacklinks:()=>he,SeoBriefs:()=>ke,SeoInsights:()=>ge,SeoLocal:()=>ye,SeoPerformance:()=>xe,SeoProduct:()=>Ve,SeoProjects:()=>ue,SeoRanks:()=>me,SeoReports:()=>fe,SeoResearch:()=>be,SeoSearchConsole:()=>de,StorageInfra:()=>_e,VOICE_EVENTS:()=>cn,VOICE_REFUSAL_REASONS:()=>Nt,Voice:()=>we,VoiceCampaigns:()=>Le,WebhookSignatureError:()=>P,Webhooks:()=>Ae,WhatsAppConnect:()=>Ue,default:()=>Ln,getErrorDetails:()=>In,getRetryConfig:()=>Pn,handleAPIError:()=>An,isAPIError:()=>Rn,laieStageQueued:()=>rn,toAPIError:()=>$,voiceErrorCode:()=>ln,voiceRefusalReason:()=>un});module.exports=Cn(En);var gn=Ie(require("axios"),1),Wt=Ie(require("axios-retry"),1);var Rt="https://api.ecodrix.com";function nn(n="v1",e=Rt){return`${e.replace(/\/+$/,"")}/${n}/api`}var je=class extends Error{constructor(e){super(e),this.name="EcodrixError"}},y=class extends je{constructor(t,r,o){super(t);i(this,"status");i(this,"code");i(this,"issues");i(this,"field");this.name="APIError",this.status=r,this.code=o}},v=class extends y{constructor(e="Invalid API Key or Client Code",t="AUTH_FAILED",r=401){super(e,r,t),this.name="AuthenticationError"}},D=class extends v{constructor(e="You don't have permission to do this.",t="FORBIDDEN"){super(e,t,403),this.name="PermissionError"}},R=class extends y{constructor(e="Too many requests. Please slow down."){super(e,429,"RATE_LIMIT_EXCEEDED"),this.name="RateLimitError"}};function $(n){var a;if(!(n!=null&&n.response))return new y((n==null?void 0:n.message)||"Network Error");let{status:e,data:t}=n.response,r=(t==null?void 0:t.message)||(t==null?void 0:t.error)||"API Request Failed",o=(a=t==null?void 0:t.code)!=null?a:typeof(t==null?void 0:t.error)=="string"&&/^[A-Z][A-Z0-9_]*$/.test(t.error)?t.error:void 0;switch(e){case 401:return new v(r,o);case 403:return new D(r,o);case 429:return new R(r);default:{let u=new y(r,e,o);return Array.isArray(t==null?void 0:t.issues)&&(u.issues=t.issues),typeof(t==null?void 0:t.field)=="string"&&(u.field=t.field),u}}}var s=class{constructor(e){i(this,"client",e)}async post(e,t,r){try{let o=this.buildConfig(r);return(await this.client.post(e,t,o)).data}catch(o){this.handleError(o)}}async get(e,t){try{let r=this.buildConfig(t);return(await this.client.get(e,r)).data}catch(r){this.handleError(r)}}async patch(e,t,r){try{let o=this.buildConfig(r);return(await this.client.patch(e,t,o)).data}catch(o){this.handleError(o)}}async put(e,t,r){try{let o=this.buildConfig(r);return(await this.client.put(e,t,o)).data}catch(o){this.handleError(o)}}async deleteRequest(e,t){try{let r=this.buildConfig(t);return(await this.client.delete(e,r)).data}catch(r){this.handleError(r)}}buildConfig(e){if(!e)return;let t=g({},e);return e.idempotencyKey&&(t.headers=E(g({},t.headers),{"Idempotency-Key":e.idempotencyKey})),t}handleError(e){throw $(e)}};var F=class extends s{async settings(){return this.get("/product/erix/ai/settings")}async updateSettings(e){return this.patch("/product/erix/ai/settings",e)}async outcomes(e={}){return this.get("/product/erix/ai/outcomes",{params:e})}async reviews(e){return this.get(`/product/erix/ai/reviews${e?`?status=${e}`:""}`)}async review(e,t,r){return this.post(`/product/erix/ai/reviews/${encodeURIComponent(e)}`,g({verdict:t},r?{note:r}:{}))}async suggestion(e){return this.get(`/product/erix/ai/suggestion/${e}`)}async approveAction(e){return this.post(`/product/erix/ai/suggestion/${e}/approve-action`,{})}async markSent(e,t,r){return this.post(`/product/erix/ai/suggestion/${e}/send`,{text:t,confidence:r})}async dismiss(e){return this.post(`/product/erix/ai/suggestion/${e}/dismiss`,{})}async approvals(){return this.get("/product/flow/approvals")}async agents(){return this.get("/product/flow/agents")}async agent(e){return this.get(`/product/flow/agents/${encodeURIComponent(e)}`)}async tryAgent(e,t){return this.post(`/product/flow/agents/${encodeURIComponent(e)}/try`,t)}async proposeAgentChange(e,t){return this.post(`/product/flow/agents/${encodeURIComponent(e)}/propose`,t)}async buildAgent(e){return this.post("/product/flow/agents/build",e)}async unansweredQuestions(){return this.get("/product/flow/agents/unanswered")}async markQuestionHandled(e){return this.post("/product/flow/agents/unanswered/handled",{question:e})}async agentTemplates(){return this.get("/product/flow/agents/templates")}async createAgent(e){return this.post("/product/flow/agents",e)}async updateAgent(e,t){return this.patch(`/product/flow/agents/${encodeURIComponent(e)}`,t)}async deleteAgent(e){return this.deleteRequest(`/product/flow/agents/${encodeURIComponent(e)}`)}async agentAutomation(e,t){return this.post(`/product/flow/agents/${encodeURIComponent(e)}/automation`,{trigger:t})}async decideRun(e,t,r){return this.post(`/product/flow/runs/${encodeURIComponent(e)}/approve`,g({decision:t},r&&{nodeId:r}))}};var x="/product/erix/commerce/checkout",S="/product/erix/public/checkout",C=encodeURIComponent,It=class extends s{async getProduct(e,t){return this.get(`${S}/products/${C(t)}`,{params:{c:e}})}async viewSession(e,t){return this.get(`${S}/sessions/view`,{params:{c:e,t}})}async updateItems(e){let o=e,{sessionId:t}=o,r=A(o,["sessionId"]);return this.post(`${S}/sessions/${C(t)}/items`,r)}async startSession(e){return this.post(`${S}/sessions`,e)}async applyCoupon(e){let o=e,{sessionId:t}=o,r=A(o,["sessionId"]);return this.post(`${S}/sessions/${C(t)}/coupon`,r)}async verify(e){let o=e,{sessionId:t}=o,r=A(o,["sessionId"]);return this.post(`${S}/sessions/${C(t)}/verify`,r)}async placeOrder(e){let o=e,{sessionId:t}=o,r=A(o,["sessionId"]);return this.post(`${S}/sessions/${C(t)}/order`,r)}async verifyRazorpay(e){let a=e,{sessionId:t,orderId:r}=a,o=A(a,["sessionId","orderId"]);return this.post(`${S}/sessions/${C(t)}/order/${C(r)}/razorpay`,o)}async orderStatus(e,t){return this.get(`${S}/orders/status`,{params:{c:e,t}})}async confirmCod(e,t){return this.post(`${S}/cod/confirm`,{clientCode:e,token:t})}},Pt=class extends s{async create(e){return this.post(`${x}/sessions`,e)}},We=class extends s{constructor(t){super(t);i(this,"buyer");i(this,"sessions");this.buyer=new It(t),this.sessions=new Pt(t)}async listProducts(){return this.get(`${x}/products`)}async createProduct(t){return this.post(`${x}/products`,t)}async updateProduct(t,r){return this.patch(`${x}/products/${C(t)}`,r)}async deleteProduct(t){return this.deleteRequest(`${x}/products/${C(t)}`)}async listCoupons(){return this.get(`${x}/coupons`)}async createCoupon(t){return this.post(`${x}/coupons`,t)}async updateCoupon(t,r){return this.patch(`${x}/coupons/${C(t)}`,r)}async deleteCoupon(t){return this.deleteRequest(`${x}/coupons/${C(t)}`)}async listOrders(t){return this.get(`${x}/orders`,{params:t})}async getOrder(t){return this.get(`${x}/orders/${C(t)}`)}async updateOrderStatus(t,r){return this.patch(`${x}/orders/${C(t)}/status`,r)}async getSettings(){return this.get(`${x}/settings`)}async updateSettings(t){return this.put(`${x}/settings`,t)}async createProductLink(t){return this.post(`${x}/links`,t)}};var Ge=class extends s{async providers(){return this.get("/infra/connect/providers")}async list(){return this.get("/infra/connect/connections")}async get_(e){return this.get(`/infra/connect/connections/${e}`)}async connect(e,t){return this.post(`/infra/connect/connections/${e}/connect`,t)}async configure(e,t){return this.put(`/infra/connect/connections/${e}/configure`,t)}async configureWebchat(e){return this.configure("webchat",{method:"domain",config:e})}async webchatSettings(){return this.get("/infra/connect/connections/webchat/settings")}async removeWebchatDomain(e){return this.deleteRequest(`/infra/connect/connections/webchat/domains/${encodeURIComponent(e)}`)}async disconnect(e){return this.post(`/infra/connect/connections/${e}/disconnect`,{})}async reveal(e){return this.post(`/infra/connect/connections/${e}/reveal`,{})}async test(e){return this.post(`/infra/connect/connections/${e}/test`,{})}async checkNow(e){return this.post(`/infra/connect/connections/${e}/health/check`,{})}async googleConnectUrl(){return this.post("/infra/connect/google/connect-url",{})}async moveChannel(e,t){return this.post(`/infra/connect/${e}/move`,{ticket:t})}async requestChannelRelease(e,t){return this.post(`/infra/connect/${e}/release-request`,{ticket:t})}async channelReleaseRequest(e){return this.get(`/infra/connect/${e}/release-request`)}async cancelChannelRelease(e){return this.deleteRequest(`/infra/connect/${e}/release-request`)}async createPaymentLink(e){return this.post("/infra/connect/connections/payments/payment-link",e)}};var U=class extends s{async list(e){return this.get("/infra/connect/accounts",e?{params:{providerId:e}}:void 0)}async retrieve(e){return this.get(`/infra/connect/accounts/${encodeURIComponent(e)}`)}async update(e,t){return this.patch(`/infra/connect/accounts/${encodeURIComponent(e)}`,t)}async remove(e,t={}){return this.deleteRequest(`/infra/connect/accounts/${encodeURIComponent(e)}`,t.newDefaultId?{params:{newDefaultId:t.newDefaultId}}:void 0)}};var Lt=class extends s{async list(e){return this.get(`/product/erix/crm/leads/${e}/notes`)}async create(e,t){return this.post(`/product/erix/crm/leads/${e}/notes`,t)}async update(e,t){return this.patch(`/product/erix/crm/notes/${e}`,{content:t})}async pin(e,t=!0){return this.patch(`/product/erix/crm/notes/${e}/pin`,{isPinned:t})}async delete(e){return this.deleteRequest(`/product/erix/crm/notes/${e}`)}},He=class extends s{constructor(t){super(t);i(this,"notes");this.notes=new Lt(t)}async timeline(t,r){return this.get(`/product/erix/crm/leads/${t}/timeline`,{params:r})}async list(t,r){return this.get(`/product/erix/crm/leads/${t}/activities`,{params:g({},r)})}async log(t){return this.post(`/product/erix/crm/leads/${t.leadId}/activities`,t)}async logCall(t,r){return this.post(`/product/erix/crm/leads/${t}/calls`,r)}};var Qe=class extends s{async overview(e){return this.get("/product/erix/crm/analytics/overview",{params:e})}async funnel(e){return this.get("/product/erix/crm/analytics/funnel",{params:{pipelineId:e}})}async forecast(e){return this.get("/product/erix/crm/analytics/forecast",{params:{pipelineId:e}})}async sources(e){return this.get("/product/erix/crm/analytics/sources",{params:e})}async team(e){return this.get("/product/erix/crm/analytics/team",{params:e})}async heatmap(e){return this.get("/product/erix/crm/analytics/heatmap",{params:e})}async scores(){return this.get("/product/erix/crm/analytics/scores")}async stageTime(e){return this.get("/product/erix/crm/analytics/stage-time",{params:{pipelineId:e}})}async tiered(e){return this.get("/product/erix/crm/analytics/tiered",{params:e})}async summary(e){return this.get("/product/erix/crm/analytics/summary",{params:e})}async whatsapp(e){return this.get("/product/erix/crm/analytics/whatsapp",{params:e})}async revenue(){return this.get("/product/erix/crm/analytics/revenue")}async health(){return this.get("/product/erix/crm/analytics/health")}async payments(){return this.get("/product/erix/crm/analytics/payments")}async reviews(){return this.get("/product/erix/crm/analytics/reviews")}async retention(){return this.get("/product/erix/crm/analytics/retention")}};var ze=class extends s{async getChecklist(e){return this.get(`/product/erix/crm/documents/checklist/${e}`)}async createChecklist(e,t){return this.post(`/product/erix/crm/documents/checklist/${e}`,{templateNiche:t})}async markReceived(e,t,r){return this.patch(`/product/erix/crm/documents/checklist/${e}/${t}`,r?{fileUrl:r}:{})}async sendReminder(e){return this.post(`/product/erix/crm/documents/checklist/${e}/remind`)}async listIncomplete(){return this.get("/product/erix/crm/documents/checklist/incomplete")}async listTemplates(){return this.get("/product/erix/crm/documents/templates")}};var Ye=class extends s{async csv(e){return this.get("/product/erix/commerce/invoices/export/csv",{params:e})}async tally(e){return this.get("/product/erix/commerce/invoices/export/tally",{params:e})}async zoho(e){return this.get("/product/erix/commerce/invoices/export/zoho",{params:e})}};var Et=["open","won","lost","archived"],Je=class extends s{async create(e){return this.post("/product/erix/crm/leads",e)}async describe(){let e=await this.fields(),t=Array.isArray(e.data)?e.data:[],r=[{key:"firstName",label:"First Name",type:"string",required:!0,group:"Basic Info"},{key:"lastName",label:"Last Name",type:"string",required:!1,group:"Basic Info"},{key:"phone",label:"Phone Number",type:"phone",required:!0,group:"Contact"},{key:"email",label:"Email Address",type:"email",required:!1,group:"Contact"},{key:"status",label:"Status",type:"select",required:!0,options:Et.map(a=>({label:`${a.charAt(0).toUpperCase()}${a.slice(1)}`,value:a}))},{key:"value",label:"Lead Value",type:"currency",required:!1},{key:"source",label:"Source",type:"string",required:!1}],o=t.map(a=>({key:`metadata.extra.${a.name}`,label:a.label||a.name,type:a.type||"string",required:!!a.required,options:a.options,group:"Custom Fields"}));return{name:"Lead",fields:[...r,...o],uiHints:{icon:"User",primaryColor:"#3b82f6",defaultSort:{field:"createdAt",direction:"desc"},summaryFields:["firstName","lastName","phone","status"]}}}async upsert(e){return this.post("/product/erix/crm/leads/upsert",e)}async createMany(e,t=50){let r=[];for(let o=0;o<e.length;o+=t){let u=e.slice(o,o+t).map(p=>this.create(p)),d=await Promise.allSettled(u);for(let p of d)if(p.status==="fulfilled")r.push(p.value);else throw p.reason}return r}async import(e,t={}){return this.post("/product/erix/crm/leads/import",g({leads:e},t))}async bulkUpsert(e){return this.import(e)}async list(e){let t=g({},e);return Array.isArray(t.tags)&&(t.tags=t.tags.join(",")),this.get("/product/erix/crm/leads",{params:t})}listAutoPaging(e){return tn(this,null,function*(){let t=(e==null?void 0:e.page)||1,r=!0;for(;r;){let o=yield new At(this.list(E(g({},e),{page:t}))),a=Array.isArray(o.data)?o.data:o||[];if(a.length===0){r=!1;break}for(let u of a)yield u;o.pagination&&t<o.pagination.pages||!o.pagination&&a.length>0?t++:r=!1}})}async retrieve(e){return this.get(`/product/erix/crm/leads/${e}`)}async retrieveByPhone(e){return this.get(`/product/erix/crm/leads/phone/${encodeURIComponent(e)}`)}async byStage(e,t,r={}){return this.get(`/product/erix/crm/pipelines/${e}/stages/${t}/leads`,{params:r})}async retrieveByRef(e,t){return this.get(`/product/erix/crm/leads/ref/${encodeURIComponent(e)}/${encodeURIComponent(t)}`)}async update(e,t){return this.patch(`/product/erix/crm/leads/${e}`,t)}async setFollowUp(e,t,r){return this.patch(`/product/erix/crm/leads/${e}`,{nextFollowUpAt:t,nextFollowUpNote:t&&r!=null?r:null})}async move(e,t){return this.patch(`/product/erix/crm/leads/${e}/move`,{stageId:t})}async convert(e,t,r){return this.post(`/product/erix/crm/leads/${e}/convert`,{outcome:t,reason:r})}async tags(e,t){return this.patch(`/product/erix/crm/leads/${e}/tags`,t)}async recalculateScore(e){return this.post(`/product/erix/crm/leads/${e}/score`,{})}async updateMetadata(e,t){return this.patch(`/product/erix/crm/leads/${e}/metadata`,t)}async fields(){return this.get("/product/erix/crm/fields")}async notes(e){return this.get(`/product/erix/crm/leads/${e}/notes`)}async activities(e,t){return this.get(`/product/erix/crm/leads/${e}/timeline`,{params:t})}async createNote(e,t){return this.post(`/product/erix/crm/leads/${e}/notes`,t)}async updateNote(e,t,r){return this.patch(`/product/erix/crm/notes/${t}`,r)}async deleteNote(e,t){return this.deleteRequest(`/product/erix/crm/notes/${t}`)}async delete(e){return this.deleteRequest(`/product/erix/crm/leads/${e}`)}async export(e){return this.get(`/product/erix/crm/leads/${encodeURIComponent(e)}/export`)}async erase(e){return this.post(`/product/erix/crm/leads/${encodeURIComponent(e)}/erase`,{confirm:"ERASE"})}async bulkArchive(e){return this.patch("/product/erix/crm/leads/bulk-archive",{ids:e})}async bulkDelete(e){return this.deleteRequest("/product/erix/crm/leads",{data:{ids:e}})}async archive(e){return this.deleteRequest(`/product/erix/crm/leads/${e}`)}async profile(e){return this.get(`/product/erix/crm/leads/${e}/profile`)}async invoices(e){return this.get(`/product/erix/crm/leads/${e}/invoices`)}async projects(e){return this.get(`/product/erix/crm/leads/${e}/projects`)}async conversations(e){return this.get(`/product/erix/crm/leads/${e}/conversations`)}async meetings(e){return this.get(`/product/erix/crm/leads/${e}/meetings`)}async flowRuns(e){return this.get(`/product/erix/crm/leads/${e}/flow-runs`)}async merge(e,t){return this.post("/product/erix/crm/leads/merge",{primaryId:e,secondaryId:t})}async duplicates(e){return this.get(`/product/erix/crm/leads/${encodeURIComponent(e)}/duplicates`)}};var Xe=class extends s{async capture(e){return this.post("/product/erix/crm/payments/capture",e)}};var Ze=class extends s{async list(){return this.get("/product/erix/crm/pipelines")}async getStageManifest(e){var o,a;let t=await this.retrieve(e),r=Array.isArray((o=t.data)==null?void 0:o.stages)?t.data.stages:[];return{name:`Pipeline: ${((a=t.data)==null?void 0:a.name)||e}`,fields:r.map(u=>({key:u._id,label:u.name,type:"string",required:!0,options:[{label:u.name,value:u._id}],group:"Stages",uiHints:{color:u.color||"#cbd5e1",probability:u.probability}})),uiHints:{icon:"Columns",primaryColor:"#6366f1"}}}async create(e){return this.post("/product/erix/crm/pipelines",e)}async retrieve(e){return this.get(`/product/erix/crm/pipelines/${e}`)}async update(e,t){return this.patch(`/product/erix/crm/pipelines/${e}`,t)}async setDefault(e){return this.patch(`/product/erix/crm/pipelines/${e}/default`,{})}async duplicate(e,t){return this.post(`/product/erix/crm/pipelines/${e}/duplicate`,{name:t})}async archive(e){return this.patch(`/product/erix/crm/pipelines/${e}/archive`,{})}async delete(e){return this.deleteRequest(`/product/erix/crm/pipelines/${e}`)}async checkInUse(e){return this.get(`/product/erix/crm/pipelines/${e}/in-use`)}async board(e){return this.get(`/product/erix/crm/pipelines/${e}/board`)}async forecast(e){return this.get(`/product/erix/crm/pipelines/${e}/forecast`)}async addStage(e,t){return this.post(`/product/erix/crm/pipelines/${e}/stages`,t)}async reorderStages(e,t){return this.patch(`/product/erix/crm/pipelines/${e}/stages/reorder`,{order:t})}async updateStage(e,t){return this.patch(`/product/erix/crm/stages/${e}`,t)}async deleteStage(e,t){return this.deleteRequest(`/product/erix/crm/stages/${e}`,{data:t?{moveLeadsToStageId:t}:void 0})}};var et=class extends s{async getConfig(){return this.get("/product/erix/crm/scoring")}async updateConfig(e){return this.patch("/product/erix/crm/scoring",e)}async recalculate(e){return this.post(`/product/erix/crm/scoring/${e}/recalculate`,{})}async preview(e){return this.get(`/product/erix/crm/scoring/preview/${e}`)}};var tt=class extends s{async sendTest(e){return this.post("/infra/connect/email/test",{to:e})}async listTemplates(e){return this.get("/infra/connect/email/templates",{params:e})}async getTemplate(e){return this.get(`/infra/connect/email/templates/${e}`)}async createTemplate(e){return this.post("/infra/connect/email/templates",e)}async updateTemplate(e,t){return this.put(`/infra/connect/email/templates/${e}`,t)}async deleteTemplate(e,t=!1){return this.deleteRequest(`/infra/connect/email/templates/${e}`,{params:{force:t}})}async previewTemplate(e,t){return this.post(`/infra/connect/email/templates/${e}/preview`,t)}};var nt=class extends s{async trigger(e){return this.post("/product/erix/events/trigger",e)}async listCustomEvents(){return this.get("/product/flow/config/triggers")}async createCustomEvent(e){return this.post("/product/flow/config/triggers",e)}async deleteCustomEvent(e){return this.deleteRequest(`/product/flow/config/triggers/${e}`)}};var rt=class extends s{async list(){return this.get("/infra/connect/facebook/lead-forms")}async subscribe(){return this.post("/infra/connect/facebook/lead-forms/subscribe",{})}async setEnabled(e,t){return this.put(`/infra/connect/facebook/lead-forms/${encodeURIComponent(e)}`,{enabled:t})}async importLast24Hours(e){return this.post(`/infra/connect/facebook/lead-forms/${encodeURIComponent(e)}/import-last-24h`,{})}};var M=class extends s{path(e,t=""){return`/product/flow/workflows/${encodeURIComponent(e)}${t}`}async versions(e){return this.get(this.path(e,"/versions"))}async version(e,t){return this.get(this.path(e,`/versions/${encodeURIComponent(t)}`))}async restoreVersion(e,t){return this.post(this.path(e,`/versions/${encodeURIComponent(t)}/restore`))}async testData(e){return this.get(this.path(e,"/test-data"))}async pinTestData(e,t){return this.put(this.path(e,"/test-data"),{runId:t})}async unpinTestData(e){return this.deleteRequest(this.path(e,"/test-data"))}async testRun(e,t={}){return this.post(this.path(e,"/test-run"),t)}async testRunProgress(e,t){return this.get(this.path(e,"/test-run"),{params:{runIds:t.join(",")}})}async copilot(e,t){return this.post(this.path(e,"/copilot"),t)}async live(e){return this.get(this.path(e,"/live"))}async week(e){return this.get(this.path(e,"/week"))}async deleteImpact(e){return this.get(this.path(e,"/delete-impact"))}async remove(e,t={}){return this.deleteRequest(this.path(e,t.stop?"?stop=true":""))}async duplicate(e){return this.post(this.path(e,"/duplicate"))}async retryFailed(e,t={}){return this.post(this.path(e,"/retry-failed"),t)}};var I=class extends s{async list(e={}){return this.get("/product/flow/campaigns",{params:e})}async create(e){return this.post("/product/flow/campaigns",e)}async launch(e,t={}){return this.post(`/product/flow/campaigns/${encodeURIComponent(e)}/launch`,t)}async retrieve(e){return this.get(`/product/flow/campaigns/${encodeURIComponent(e)}`)}async update(e,t){return this.patch(`/product/flow/campaigns/${encodeURIComponent(e)}`,t)}async test(e){return this.post(`/product/flow/campaigns/${encodeURIComponent(e)}/test`,{})}async start(e,t={}){return this.post(`/product/flow/campaigns/${encodeURIComponent(e)}/start`,t)}async pause(e){return this.post(`/product/flow/campaigns/${encodeURIComponent(e)}/pause`,{})}async resume(e){return this.post(`/product/flow/campaigns/${encodeURIComponent(e)}/resume`,{})}async stop(e){return this.post(`/product/flow/campaigns/${encodeURIComponent(e)}/stop`,{})}async remove(e){return this.deleteRequest(`/product/flow/campaigns/${encodeURIComponent(e)}`)}async duplicate(e){return this.post(`/product/flow/campaigns/${encodeURIComponent(e)}/duplicate`,{})}async followUp(e,t={}){return this.post(`/product/flow/campaigns/${encodeURIComponent(e)}/follow-up`,t)}async checks(e){return this.get(`/product/flow/campaigns/${encodeURIComponent(e)}/checks`)}async results(e){return this.get(`/product/flow/campaigns/${encodeURIComponent(e)}/results`)}async people(e,t={}){return this.get(`/product/flow/campaigns/${encodeURIComponent(e)}/people`,{params:t})}};var _="/product/flow/conversations",b=(n,e="")=>`${_}/${encodeURIComponent(n)}${e}`,N=class extends s{async list(e={}){return this.get(_,{params:e})}async create(e){return this.post(_,e)}async retrieve(e){return this.get(b(e))}async update(e,t){return this.patch(b(e),t)}async duplicate(e){return this.post(b(e,"/duplicate"),{})}async archive(e){return this.deleteRequest(b(e))}async publish(e,t={}){return this.post(b(e,"/publish"),t)}async versions(e){return this.get(b(e,"/versions"))}async version(e,t){return this.get(b(e,`/versions/${t}`))}async rollback(e,t){return this.post(b(e,"/rollback"),{version:t})}async try(e,t){return this.post(b(e,"/try"),t)}async tests(e){return this.get(b(e,"/tests"))}async addTest(e,t){return this.post(b(e,"/tests"),t)}async deleteTest(e,t){return this.deleteRequest(b(e,`/tests/${encodeURIComponent(t)}`))}async runTests(e,t={}){return this.post(b(e,"/tests/run"),t)}async deployments(e){return this.get(b(e,"/deployments"))}async allDeployments(){return this.get(`${_}/deployments`)}async deploy(e,t){return this.post(b(e,"/deployments"),t)}async updateDeployment(e,t){return this.patch(`${_}/deployments/${encodeURIComponent(e)}`,t)}async removeDeployment(e){return this.deleteRequest(`${_}/deployments/${encodeURIComponent(e)}`)}async checks(e){return this.get(b(e,"/checks"))}};var B=class extends s{async get(){return super.get("/product/flow/home")}async nav(){return super.get("/product/flow/home/nav")}},q=class extends s{async create(e){return this.post("/product/flow/drafts",e)}async plan(e){return this.post("/product/flow/drafts/plan",e)}},K=class extends s{async status(){return this.get("/product/flow/first-run")}async installPack(e){return this.post(`/product/flow/first-run/packs/${e}`)}},j=class extends s{async list(){return this.get("/product/flow/audiences")}async byId(e){return this.get(`/product/flow/audiences/${encodeURIComponent(e)}`)}async create(e){return this.post("/product/flow/audiences",e)}async update(e,t){return this.patch(`/product/flow/audiences/${encodeURIComponent(e)}`,t)}async remove(e){return this.deleteRequest(`/product/flow/audiences/${encodeURIComponent(e)}`)}async preview(e,t){return this.get(`/product/flow/audiences/${encodeURIComponent(e)}/preview${t?`?channel=${t}`:""}`)}async previewRules(e){return this.post("/product/flow/audiences/preview",e)}};var st=class extends s{async system(){return(await this.get("/health")).data}};var it=class extends s{async list(e){return this.get("/product/erix/commerce/invoices",{params:e})}async getInvoice(e){return this.get(`/product/erix/commerce/invoices/${e}`)}async create(e){return this.post("/product/erix/commerce/invoices",e)}async update(e,t){return this.patch(`/product/erix/commerce/invoices/${e}`,t)}async void(e){return this.post(`/product/erix/commerce/invoices/${e}/void`,{})}async sendViaWhatsApp(e){return this.post(`/product/erix/commerce/invoices/${e}/send-whatsapp`,{})}async getSettings(){return this.get("/product/erix/commerce/settings")}async updateSettings(e){return this.put("/product/erix/commerce/settings",e)}async paymentLink(e){return this.post(`/product/erix/commerce/invoices/${encodeURIComponent(e)}/payment-link`,{})}async recordPayment(e,t){return this.post(`/product/erix/commerce/invoices/${encodeURIComponent(e)}/payments`,t)}async sendWhatsApp(e){return this.post(`/product/erix/commerce/invoices/${encodeURIComponent(e)}/send-whatsapp`,{})}async sendEmail(e){return this.post(`/product/erix/commerce/invoices/${encodeURIComponent(e)}/send-email`,{})}};var rn=n=>"queued"in n&&n.queued===!0,sn={runProgress:"laie:run:progress",importComplete:"laie:import:complete"},m=encodeURIComponent,l="/product/laie",W=class extends s{async list(){return this.get(`${l}/packs`)}async byId(e){return this.get(`${l}/packs/${m(e)}`)}},G=class extends s{async catalog(e={}){return this.get(`${l}/signals/catalog`,{params:e})}async list(e={}){return this.get(`${l}/signals`,{params:e})}},H=class extends s{async find(e){return this.post(`${l}/tools/find`,e)}async collect(e){return this.post(`${l}/tools/collect`,e)}async enrich(e){return this.post(`${l}/tools/enrich`,e)}async verify(e){return this.post(`${l}/tools/verify`,e)}async qualify(e){return this.post(`${l}/tools/qualify`,e)}async store(e){return this.post(`${l}/tools/store`,e)}async use(e){return this.post(`${l}/tools/use`,e)}async verifyEmail(e){return this.post(`${l}/tools/verify-email`,{emails:e})}async websiteLookup(e){return this.post(`${l}/tools/website-lookup`,{url:e})}},Q=class extends s{async list(){return this.get(`${l}/campaigns`)}async create(e){return this.post(`${l}/campaigns`,e)}async byId(e){return this.get(`${l}/flows/${m(e)}`)}async settings(e){return this.get(`${l}/campaigns/${m(e)}/settings`)}async updateSettings(e,t){return this.patch(`${l}/campaigns/${m(e)}/settings`,t)}async signals(e){return this.get(`${l}/campaigns/${m(e)}/signals`)}async setSignals(e,t){return this.put(`${l}/campaigns/${m(e)}/signals`,t)}},z=class extends s{async start(e){return this.post(`${l}/campaigns/${m(e)}/runs`)}async list(e,t={}){return this.get(`${l}/campaigns/${m(e)}/runs`,{params:t})}async byId(e,t){return this.get(`${l}/campaigns/${m(e)}/runs/${m(t)}`)}async changes(e,t,r={}){return this.get(`${l}/campaigns/${m(e)}/runs/${m(t)}/changes`,{params:r})}async cancel(e,t){return this.post(`${l}/campaigns/${m(e)}/runs/${m(t)}/cancel`)}async quality(e){return this.get(`${l}/jobs/${m(e)}/quality`)}},Y=class extends s{async list(e={}){let o=e,{importedToCrm:t}=o,r=A(o,["importedToCrm"]);return this.get(`${l}/leads`,{params:g(g({},r),t!==void 0&&{importedToCrm:String(t)})})}async byId(e){return this.get(`${l}/leads/${m(e)}`)}async update(e,t){return this.patch(`${l}/leads/${m(e)}`,t)}async notes(e){return this.get(`${l}/leads/${m(e)}/notes`)}async addNote(e,t){return this.post(`${l}/leads/${m(e)}/notes`,t)}async generateKit(e){return this.post(`${l}/leads/${m(e)}/generate-kit`)}async pipelineSummary(){return this.get(`${l}/leads/pipeline-summary`)}async bulkContacted(e,t){return this.post(`${l}/leads/bulk/contacted`,{leadIds:e,channel:t})}async bulkTag(e,t){return this.post(`${l}/leads/bulk/tag`,{leadIds:e,tags:t})}async bulkDelete(e){return this.post(`${l}/leads/bulk/delete`,{leadIds:e})}async bulkExport(e,t="json"){return t==="csv"?this.post(`${l}/leads/bulk/export`,{leadIds:e,format:t},{responseType:"text"}):this.post(`${l}/leads/bulk/export`,{leadIds:e,format:t})}},J=class extends s{async pipelines(){return this.get(`${l}/import/pipelines`)}async crm(e){return this.post(`${l}/import/crm`,e)}},X=class extends s{async enrich(e){return this.post(`${l}/lists/enrich`,e)}},Z=class extends s{async dsr(e){return this.post(`${l}/compliance/dsr`,e)}async report(e={}){return this.get(`${l}/compliance/report`,{params:e})}},ee=class extends s{async map(e={}){return this.get(`${l}/market-map`,{params:e})}async forCampaign(e){return this.get(`${l}/campaigns/${m(e)}/market-map`)}async refresh(e={}){return this.post(`${l}/market-map/refresh`,e)}},te=class extends s{async weights(e={}){return this.get(`${l}/learning/weights`,{params:e})}async outcomes(e={}){return this.get(`${l}/learning/outcomes`,{params:e})}},ne=class extends s{async preview(e){return this.post(`${l}/lookalikes/preview`,e)}async create(e){return this.post(`${l}/lookalikes`,e)}async list(e={}){return this.get(`${l}/lookalikes`,{params:e})}async byId(e){return this.get(`${l}/lookalikes/${m(e)}`)}async rank(e,t={}){return this.get(`${l}/lookalikes/${m(e)}/rank`,{params:t})}},re=class extends s{async status(){return this.get(`${l}/freshness`)}},se=class extends s{async start(e){return this.post(`${l}/audit`,e)}async byId(e){return this.get(`${l}/audit/${m(e)}`)}};var on=Ie(require("axios"),1);var ot=class extends s{async getUsage(){return this.get("/infra/storage/files/usage")}async createFolder(e){return this.post("/infra/storage/files/folders",{name:e})}async list(e,t){return this.get(`/infra/storage/files/files/${e}`,{params:t})}async delete(e){return this.deleteRequest("/infra/storage/files/files",{params:{key:e}})}async getDownloadUrl(e){return this.post("/infra/storage/files/download-url",{key:e})}async aiDescribe(e){return this.post("/infra/storage/files/ai/describe",{key:e})}async upload(e,t){let r=await this.post("/infra/storage/files/upload-url",t),{uploadUrl:o,key:a}=r.data;await on.default.put(o,e,{headers:{"Content-Type":t.contentType}});let u=e.size||e.byteLength||0;return this.post("/infra/storage/files/confirm-upload",{key:a,sizeBytes:u})}};var at=class extends s{async create(e){return this.post("/infra/connect/meet",e)}async list(e){return this.get("/infra/connect/meet",{params:e})}async retrieve(e){return this.get(`/infra/connect/meet/${e}`)}async update(e,t){return this.patch(`/infra/connect/meet/${e}`,t)}async reschedule(e,t){return this.patch(`/infra/connect/meet/${e}`,t)}async delete(e){return this.update(e,{status:"cancelled"})}};var ct=class extends s{async workflowPacks(){return this.get("/product/erix/crm/niche/workflow-packs")}async workflowPackDetail(e){return this.get(`/product/erix/crm/niche/workflow-packs/${e}`)}async installWorkflowPack(e){return this.post(`/product/erix/crm/niche/workflow-packs/${e}/install`)}async templateSuggestions(){return this.get("/product/erix/crm/niche/template-suggestions")}};var lt=class extends s{async listAlerts(e){return this.get("/platform/users/notifications",{params:e})}async dismissAlert(e){return this.patch(`/platform/users/notifications/${e}/dismiss`)}async clearAllAlerts(){return this.deleteRequest("/platform/users/notifications/dismiss-all")}};var ie=class extends s{async global(e){return this.post("/platform/tenants/onboarding/global",e)}async complete(e){return this.post("/platform/tenants/onboarding/complete",e)}};var oe=class extends s{async get(e){return super.get(`/platform/tenants/persona/${e}`)}async reinforce(e){return this.post(`/platform/tenants/persona/${e.productId}/reinforce`,e)}async confidence(e){return super.get(`/platform/tenants/persona/${e}/confidence`,{params:{productId:e}})}async timeline(e,t){var o;let r=await super.get(`/platform/tenants/persona/${e}/timeline`,{params:t});return(o=r==null?void 0:r.data)!=null?o:{entries:[],hasMore:!1}}async followups(e){var r,o;let t=await super.get(`/platform/tenants/persona/${e}/followups`);return(o=(r=t==null?void 0:t.data)==null?void 0:r.entries)!=null?o:[]}};var $t=class extends s{async chatSync(e){return this.post("/platform/ai/copilot/chat/sync",e)}async confirm(e){return this.post("/platform/ai/copilot/confirm",e)}async listSessions(){return this.get("/platform/ai/copilot/sessions")}async getSession(e){return this.get(`/platform/ai/copilot/sessions/${e}`)}async deleteSession(e){return this.deleteRequest(`/platform/ai/copilot/sessions/${e}`)}chatStreamUrl(){return"/platform/ai/copilot/chat"}},ut=class{constructor(e){i(this,"copilot");this.copilot=new $t(e)}};var pt=class extends s{async list(e){return this.get("/platform/tenants/audit",{params:e})}};var gt=class extends s{async register(e){return this.post("/platform/auth/register",e)}async login(e){return this.post("/platform/auth/login",e)}async logout(e){return this.post("/platform/auth/logout",e)}async logoutAll(e){return this.post("/platform/auth/logout-all",e)}async validateSession(e){return this.post("/platform/auth/session/validate",e)}async listSessions(){return this.get("/platform/auth/sessions")}async revokeSession(e){return this.deleteRequest(`/platform/auth/sessions/${e}`)}async requestPasswordOtp(e){return this.post("/platform/auth/password/request-otp",e)}async setPassword(e){return this.post("/platform/auth/password/set",e)}async changePassword(e){return this.post("/platform/auth/password/change",e)}async forgotPassword(e){return this.post("/platform/auth/forgot",e)}async resetPassword(e){return this.post("/platform/auth/reset",e)}async linkOAuth(e){return this.post("/platform/auth/oauth-link",e)}async getInvitation(e){return this.get(`/platform/auth/invitations/${e}`)}async acceptInvitation(e,t){return this.post(`/platform/auth/invitations/${e}/accept`,t)}};var Ot=class extends s{async get(){return super.get("/platform/billing/entitlements/entitlements")}async usage(){return super.get("/platform/billing/entitlements/usage")}},Vt=class extends s{async upgrade(e){return this.post("/platform/billing/subscriptions/subscriptions/upgrade",e)}async downgrade(e){return this.post("/platform/billing/subscriptions/subscriptions/downgrade",e)}async cancel(e){return this.post("/platform/billing/subscriptions/subscriptions/cancel",e)}},Dt=class extends s{list(){return this.get("/platform/billing/addons")}add(e,t){return this.post(`/platform/billing/addons/${encodeURIComponent(e)}/add`,t===void 0?{}:{quantity:t})}remove(e){return this.post(`/platform/billing/addons/${encodeURIComponent(e)}/remove`)}overage(){return this.get("/platform/billing/overage")}setOverage(e){return this.put("/platform/billing/overage",e)}},Ft=class extends s{async listPublic(){return this.get("/platform/billing/plans/public")}},Ut=class extends s{async plans(){return this.get("/platform/billing/checkout/plans")}async proration(e,t){return this.get("/platform/billing/checkout/proration",{params:{planId:e,billingCycle:t}})}async subscribe(e){return this.post("/platform/billing/checkout/subscribe",e)}async verify(e){return this.post("/platform/billing/checkout/verify",e)}async cancel(e){return this.post("/platform/billing/checkout/cancel",e)}async status(){return this.get("/platform/billing/checkout/status")}async syncPlan(e){return this.post("/platform/billing/checkout/sync-plan",e)}},Mt=class extends s{async transactions(){return this.get("/platform/billing/user/transactions")}async transactionInvoice(e){return this.get(`/platform/billing/user/transactions/${encodeURIComponent(e)}/invoice`)}async subscription(){return this.get("/platform/billing/user/subscription")}async raiseDispute(e){return this.post("/platform/billing/user/dispute",e)}async disputes(){return this.get("/platform/billing/user/disputes")}},_t=class extends s{async balance(){return this.get("/platform/billing/credits/balance")}async transactions(){return this.get("/platform/billing/credits/transactions")}async packs(){return this.get("/platform/billing/credits/packs")}async topupOrder(e){return this.post("/platform/billing/credits/topup/order",e)}async verifyTopup(e){return this.post("/platform/billing/credits/topup/verify",e)}async setAutoTopup(e){return this.patch("/platform/billing/credits/auto-topup",e)}async setSpendCap(e){return this.patch("/platform/billing/credits/spend-cap",e)}},dt=class{constructor(e){i(this,"entitlements");i(this,"subscriptions");i(this,"plans");i(this,"checkout");i(this,"user");i(this,"credits");i(this,"addOns");this.entitlements=new Ot(e),this.subscriptions=new Vt(e),this.plans=new Ft(e),this.checkout=new Ut(e),this.user=new Mt(e),this.credits=new _t(e),this.addOns=new Dt(e)}};var ae=class extends s{async list(){return this.get("/platform/public/catalog",{ignoreClientCode:!0})}};var ce=class extends s{async send(e){if(e.conversationId)return this.post(`/platform/inbox/conversations/${e.conversationId}/messages`,{text:e.text,media:e.media});if(!e.to)throw new Error("send: conversationId or to is required");if(e.media)throw new Error("send: media goes to an inbox thread (conversationId)");return this.post("/infra/connect/send/whatsapp",g({phone:e.to,text:e.text},e.accountId?{accountId:e.accountId}:{}))}async sendTemplate(e){return this.post("/infra/connect/send/whatsapp",g({phone:e.to,templateName:e.templateName,language:e.language,variables:e.variables},e.accountId?{accountId:e.accountId}:{}))}async star(e,t){return this.post(`/platform/inbox/messages/${e}/star`,{starred:t})}async translate(e){return this.post(`/platform/inbox/messages/${encodeURIComponent(e)}/translate`,{})}async markRead(e){return this.post(`/platform/inbox/conversations/${e}/read`,{})}async upload(e,t={}){var k,f,T;let r=(f=(k=t.fileName)!=null?k:e.name)!=null?f:"file",o=e.type||"application/octet-stream",a=await this.post("/infra/storage/files/upload-url",{folder:(T=t.folder)!=null?T:"inbox",filename:r,contentType:o}),{uploadUrl:u,key:d}=a.data,p=await fetch(u,{method:"PUT",headers:{"Content-Type":o},body:e});if(!p.ok)throw new Error(`upload failed (${p.status})`);return await this.post("/infra/storage/files/confirm-upload",{key:d,sizeBytes:e.size}),{key:d,mimeType:o,fileName:r}}};var an=["application/pdf","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/plain","text/markdown","text/csv","text/html","image/png","image/jpeg","image/webp"],le=class extends s{async list(){return this.get("/platform/knowledge/sources")}async addText(e){return this.post("/platform/knowledge/sources",g({kind:"text"},e))}async addUrl(e){return this.post("/platform/knowledge/sources",g({kind:"url"},e))}async addWebsite(e){return this.post("/platform/knowledge/sources",{type:"website",url:e.url})}async addFile(e,t={}){var o,a;let r=await new ce(this.client).upload(e,{folder:"knowledge"});return this.post("/platform/knowledge/sources",{kind:"file",key:r.key,mimeType:r.mimeType,title:(a=(o=t.title)!=null?o:r.fileName)!=null?a:"Document"})}async remove(e){return this.deleteRequest(`/platform/knowledge/sources/${e}`)}async reindex(e){return this.post(`/platform/knowledge/sources/${e}/reindex`,{})}async search(e,t){return this.post("/platform/knowledge/search",g({query:e},t?{limit:t}:{}))}};var mt=class extends s{async categories(){return this.get("/platform/support/categories")}async listTickets(e){return this.get("/platform/support/tickets",{params:e})}async createTicket(e){return this.post("/platform/support/tickets",e)}async getTicket(e){return this.get(`/platform/support/tickets/${e}`)}async reply(e,t){return this.post(`/platform/support/tickets/${e}/reply`,t)}async close(e){return this.patch(`/platform/support/tickets/${e}/close`,{})}async channelSetup(e){return this.get(`/platform/support/channel-requests/${encodeURIComponent(e)}/setup`)}};var yt=class extends s{async get(){return super.get("/platform/users/me")}async update(e){return this.patch("/platform/users/me",e)}async updateOrganization(e){return this.patch("/platform/users/me/organization",e)}async toggleModules(e){return this.post("/platform/users/me/modules",e)}async workspaces(){return super.get("/platform/users/me/workspaces")}async setActiveOrg(e){return this.post("/platform/users/me/active-org",e)}async dismissWorkspaceSetup(){return this.post("/platform/users/me/workspace/dismiss-setup",{})}},ft=class extends s{async list(){return this.get("/platform/users/members")}async access(){return this.get("/platform/users/members/access")}async invite(e){return this.post("/platform/users/members/invite",e)}async updateAccess(e,t){return this.patch(`/platform/users/members/${encodeURIComponent(e)}`,t)}async updateRole(e,t){return this.updateAccess(e,{role:t})}async remove(e){return this.deleteRequest(`/platform/users/members/${encodeURIComponent(e)}`)}async invitations(){return this.get("/platform/users/members/invitations")}async resendInvitation(e){return this.post(`/platform/users/members/invitations/${encodeURIComponent(e)}/resend`,{})}async revokeInvitation(e){return this.deleteRequest(`/platform/users/members/invitations/${encodeURIComponent(e)}`)}},bt=class extends s{async list(){return this.get("/platform/auth/sessions")}async revoke(e){return this.deleteRequest(`/platform/auth/sessions/${e}`)}};var ht=class extends s{async list(e){return this.get(`/product/erix/commerce/projects/${e}/documents`)}async upload(e,t){return this.post(`/product/erix/commerce/projects/${e}/documents`,t)}async toggleSignature(e,t,r){return this.patch(`/product/erix/commerce/projects/${e}/documents/${t}/signature`,{required:r})}async addSigner(e,t,r){return this.post(`/product/erix/commerce/projects/${e}/documents/${t}/signers`,r)}async decline(e,t){return this.post(`/product/erix/commerce/projects/${e}/documents/${t}/decline`,{})}async stampSign(e,t,r){return this.post(`/product/erix/commerce/projects/${e}/documents/${t}/stamp-sign`,r)}};var ue=class extends s{async list(){return this.get("/product/seo/projects")}async create(e){return this.post("/product/seo/projects",e)}async byId(e){return this.get(`/product/seo/projects/${e}`)}async update(e,t){return this.patch(`/product/seo/projects/${e}`,t)}async remove(e){return this.deleteRequest(`/product/seo/projects/${e}`)}async crawl(e){return this.post(`/product/seo/projects/${e}/crawl`)}async crawlCompetitor(e,t){return this.post(`/product/seo/projects/${e}/competitors/crawl`,{domain:t})}},pe=class extends s{async start(e){return this.post("/product/seo/audits",e)}async list(e={}){return this.get("/product/seo/audits",{params:e})}async compare(e){return this.post("/product/seo/audits/compare",e)}async byId(e){return this.get(`/product/seo/audits/${e}`)}async resume(e){return this.post(`/product/seo/audits/${e}/resume`)}async pages(e,t={}){return this.get(`/product/seo/audits/${e}/pages`,{params:t})}async issues(e){return this.get(`/product/seo/audits/${e}/issues`)}async links(e){return this.get(`/product/seo/audits/${e}/links`)}async export(e,t="json"){return this.get(`/product/seo/audits/${e}/export`,{params:{format:t},responseType:"text"})}},ge=class extends s{async keywords(e,t={}){return this.get(`/product/seo/audits/${e}/keywords`,{params:t})}async contentGap(e){return this.post("/product/seo/audits/content-gap",e)}async search(e){return this.post("/product/seo/audits/search",e)}async backlinks(e){return this.get("/product/seo/audits/backlinks",{params:e})}async domain(e){return this.get(`/product/seo/audits/domains/${encodeURIComponent(e)}`)}},de=class extends s{async check(e){return this.post(`/product/seo/search-console/${e}/check`)}async importNow(e){return this.post(`/product/seo/search-console/${e}/import`)}async status(e){return this.get(`/product/seo/search-console/${e}/status`)}async queries(e,t={}){return this.get(`/product/seo/search-console/${e}/queries`,{params:t})}async pages(e,t={}){return this.get(`/product/seo/search-console/${e}/pages`,{params:t})}async trend(e,t={}){return this.get(`/product/seo/search-console/${e}/trend`,{params:t})}},me=class extends s{async keywords(e){return this.get(`/product/seo/ranks/${e}/keywords`)}async add(e,t,r={}){return this.post(`/product/seo/ranks/${e}/keywords`,g({queries:t},r))}async visibility(e,t={}){return this.get(`/product/seo/ranks/${e}/visibility`,{params:t})}async competitors(e){return this.get(`/product/seo/ranks/${e}/competitors`)}async gap(e,t={}){return this.get(`/product/seo/ranks/${e}/gap`,{params:t})}async remove(e,t){return this.deleteRequest(`/product/seo/ranks/${e}/keywords/${t}`)}async checkNow(e,t){return this.post(`/product/seo/ranks/${e}/keywords/${t}/check`)}async history(e,t,r={}){return this.get(`/product/seo/ranks/${e}/keywords/${t}/history`,{params:r})}async changes(e){return this.get(`/product/seo/ranks/${e}/changes`)}},ye=class extends s{async checkNow(e){return this.post(`/product/seo/local/${e}/check`)}async latest(e){return this.get(`/product/seo/local/${e}`)}async history(e,t={}){return this.get(`/product/seo/local/${e}/history`,{params:t})}async startGrid(e,t={}){return this.post(`/product/seo/local/${e}/grid`,t)}async grid(e){return this.get(`/product/seo/local/${e}/grid`)}async grids(e,t={}){return this.get(`/product/seo/local/${e}/grids`,{params:t})}},fe=class extends s{async byProject(e){return this.get(`/product/seo/reports/${e}`)}async export(e,t="csv"){return this.get(`/product/seo/reports/${e}/export`,{params:{format:t},responseType:"text"})}async pdf(e,t={}){return this.get(`/product/seo/reports/${e}/pdf`,{params:t,responseType:"arraybuffer"})}async generate(e,t={}){return this.post(`/product/seo/reports/${e}/generate`,t)}async history(e,t={}){return this.get(`/product/seo/reports/${e}/history`,{params:t})}async changes(e){return this.get(`/product/seo/reports/${e}/changes`)}},be=class extends s{async seed(e,t,r="en"){return this.post(`/product/seo/research/${e}/seed`,{seed:t,lang:r})}async fromSearchConsole(e){return this.post(`/product/seo/research/${e}/from-search-console`)}async ideas(e,t={}){return this.get(`/product/seo/research/${e}/ideas`,{params:t})}async analyze(e,t){return this.post(`/product/seo/research/${e}/ideas/${t}/analyze`)}};var he=class extends s{async releases(){return this.get("/product/seo/backlinks/releases")}async strength(e){return this.get("/product/seo/backlinks/strength",{params:{domains:e.join(",")}})}async overview(e){return this.get(`/product/seo/backlinks/${e}`)}async referring(e,t){return this.get(`/product/seo/backlinks/${e}/referring`,{params:t})}async changes(e,t){return this.get(`/product/seo/backlinks/${e}/changes`,{params:t})}},xe=class extends s{async checkNow(e){return this.post(`/product/seo/performance/${e}/check`)}async latest(e){return this.get(`/product/seo/performance/${e}`)}async history(e,t={}){return this.get(`/product/seo/performance/${e}/history`,{params:t})}},ke=class extends s{async create(e){return this.post("/product/seo/briefs",e)}async byId(e){return this.get(`/product/seo/briefs/${e}`)}async list(e,t={}){return this.get("/product/seo/briefs",{params:g({projectId:e},t)})}};var wn=35e3,Ce=class extends s{async claim(e,t){var o;let r=await this.post("/infra/serp/collector/claim",{collectorId:e,kinds:t},{timeout:wn});return(o=r&&typeof r=="object"?r.data:null)!=null?o:null}async result(e){return this.post("/infra/serp/collector/result",e)}async heartbeat(e,t){return this.post("/infra/serp/collector/heartbeat",g({collectorId:e},t))}};var xt=class extends s{async getConfig(){return this.get("/infra/connect/email/config")}async initDomainVerification(e){return this.post("/infra/connect/email/config/ses/domain",{domain:e})}async saveEmailConfig(e){return this.post("/infra/connect/email/config/ses/config",e)}async checkSesVerification(){return this.get("/infra/connect/email/config/ses/verify")}async removeSesIdentity(){return this.deleteRequest("/infra/connect/email/config/ses/domain")}async sendTest(e){return this.post("/infra/connect/email/config/test",{toEmail:e})}async saveAdvancedConfig(e){return this.post("/infra/connect/email/config/advanced",e)}async getHealth(){return this.get("/infra/connect/email/config/health")}async fixDmarc(){return this.post("/infra/connect/email/config/ses/fix-dmarc",{})}async listProviders(){return this.get("/infra/connect/email/config/providers")}};var kt=class extends s{async create(e){return this.post("/infra/storage/files/folders",{name:e})}},Ct=class extends s{async list(e,t){return this.get(`/infra/storage/files/files/${e}`,{params:t})}async getUploadUrl(e){return this.post("/infra/storage/files/upload-url",e)}async confirmUpload(e){return this.post("/infra/storage/files/confirm-upload",e)}async getDownloadUrl(e){return this.post("/infra/storage/files/download-url",{key:e})}async delete(e){return this.deleteRequest("/infra/storage/files/files",{params:{key:e}})}};var cn={callChanged:"voice_call_changed"},vn=["NOT_FOUND","VOICE_CALL_REFUSED","VOICE_NOT_SET_UP","VOICE_CAMPAIGN_NOT_APPROVED","VOICE_NOT_ENABLED","VOICE_AGENT_UNAVAILABLE","VOICE_RUNTIME_UNAVAILABLE","VOICE_PREVIEW_FAILED","VOICE_NOT_CONFIGURED","LEAD_NOT_FOUND","INSUFFICIENT_CREDITS"];function ln(n){let e=n instanceof y?n.code:void 0;return e&&vn.includes(e)?e:void 0}var Nt={gate:"Voice calling isn't switched on for this workspace.",bad_number:"That phone number isn't a number we can call.",do_not_call:"They asked not to be called again.",dnd:"Their number is on the Do Not Disturb register.",hours:"No calling hours are open for this step.",recently_called:"They were called recently.",promotional:"Promotional calls aren't offered. Calls are for service, reminders, callbacks and demo follow-ups.",no_consent:"No record that they agreed to a phone call, or asked for one. They are not called.",campaign_stopped:"This campaign was stopped.",test_limit:"You can ring your own phone 3 times a day. Try again tomorrow.",not_on_plan:"Voice isn't on your plan. Upgrade your plan to use voice calls.",minutes_used_up:"You've used this month's included voice minutes. Your plan has no extra minutes.",low_balance:"Your balance is below \u20B910. Add credits to place voice calls."};function un(n){var e;return(e=Nt[n])!=null?e:n}var Pe=encodeURIComponent,Le=class extends s{get flow(){return new I(this.client)}list(e={}){return this.flow.list(e)}retrieve(e){return this.flow.retrieve(e)}create(e){return this.flow.create(e)}launch(e,t={}){return this.flow.launch(e,t)}start(e,t={}){return this.flow.start(e,t)}pause(e){return this.flow.pause(e)}resume(e){return this.flow.resume(e)}stop(e){return this.flow.stop(e)}costPreview(e){return this.get(`/product/flow/campaigns/${Pe(e)}/voice-preview`)}counters(e){return this.get(`/infra/connect/voice/campaigns/${Pe(e)}/counters`)}approval(e){return this.get(`/infra/connect/voice/campaigns/${Pe(e)}/approval`)}requestApproval(e){return this.post(`/infra/connect/voice/campaigns/${Pe(e)}/approval/request`,{})}},we=class extends s{constructor(t){super(t);i(this,"campaigns");this.campaigns=new Le(t)}status(){return this.get("/infra/connect/voice/status")}setup(){return this.get("/infra/connect/voice/setup")}setupNumbers(){return this.get("/infra/connect/voice/setup/numbers")}kycUploadUrl(t){return this.post("/infra/connect/voice/setup/kyc/upload-url",t)}submitKyc(t){return this.post("/infra/connect/voice/setup/kyc",t)}pickNumber(t){return this.post("/infra/connect/voice/setup/number",{number:t})}askForNumber(){return this.post("/infra/connect/voice/setup/number/request",{})}goLive(){return this.post("/infra/connect/voice/setup/go-live",{})}agent(){return this.get("/infra/connect/voice/agent")}skills(){return this.get("/infra/connect/voice/skills")}voices(t){return this.get(`/infra/connect/voice/voices?language=${encodeURIComponent(t)}`)}saveAgent(t){return this.put("/infra/connect/voice/agent",t)}agents(){return this.get("/infra/connect/voice/agents")}createAgent(t){return this.post("/infra/connect/voice/agents",t)}getAgent(t){return this.get(`/infra/connect/voice/agents/${encodeURIComponent(t)}`)}updateAgent(t,r){return this.put(`/infra/connect/voice/agents/${encodeURIComponent(t)}`,r)}setAgentLead(t,r){return this.put(`/infra/connect/voice/agents/${encodeURIComponent(t)}/lead`,{customAgentId:r})}deleteAgent(t){return this.deleteRequest(`/infra/connect/voice/agents/${encodeURIComponent(t)}`)}numbers(){return this.get("/infra/connect/voice/numbers")}updateNumber(t,r){return this.patch(`/infra/connect/voice/numbers/${encodeURIComponent(t)}`,r)}async preview(t={}){var r;try{return(await this.client.post("/infra/connect/voice/preview",t,{responseType:"arraybuffer"})).data}catch(o){let a=(r=o==null?void 0:o.response)==null?void 0:r.data;if(a instanceof ArrayBuffer||ArrayBuffer.isView(a))try{o.response.data=JSON.parse(new TextDecoder().decode(a))}catch(u){o.response.data=void 0}throw $(o)}}lines(){return this.get("/infra/connect/voice/lines")}activity(){return this.get("/infra/connect/voice/activity")}calls(t={}){return this.get("/infra/connect/voice/calls",{params:t})}call(t){return this.get(`/infra/connect/voice/calls/${Pe(t)}`)}callWithAI(t){return this.post("/infra/connect/voice/calls",t)}checkCallWithAI(t){return this.post("/infra/connect/voice/calls/check",t)}callMyPhone(t={}){return this.post("/infra/connect/voice/calls/my-phone",t)}testCall(t={}){return this.post("/infra/connect/voice/test-call",t)}};var wt=class extends s{async list(e){return this.get("/platform/inbox/conversations",{params:e})}async create(e){var t;return this.post("/platform/inbox/conversations",{address:e.phone,channel:(t=e.channel)!=null?t:"whatsapp",userName:e.name})}async linkLead(e,t){return this.patch(`/platform/inbox/conversations/${e}/lead`,{leadId:t})}async retrieve(e){return this.get(`/platform/inbox/conversations/${e}`)}async messages(e,t){return this.get(`/platform/inbox/conversations/${e}/messages`,{params:t})}async markRead(e){return this.post(`/platform/inbox/conversations/${e}/read`,{})}async delete(e){return this.deleteRequest(`/platform/inbox/conversations/${e}`)}async bulkDelete(e){return this.post("/platform/inbox/conversations/bulk-delete",{ids:e})}};var vt=class extends s{async list(e){return this.get("/infra/connect/whatsapp/templates",{params:e})}async sync(e={}){return this.post("/infra/connect/whatsapp/templates/sync",e.accountId?{accountId:e.accountId}:{})}async retrieve(e){return this.get(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}`)}async create(e){return this.post("/infra/connect/whatsapp/templates",e)}async update(e,t){return this.put(`/infra/connect/whatsapp/templates/${e}`,t)}async fix(e){return this.post(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}/fix`,{})}async resubmit(e,t){return this.post(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}/resubmit`,t)}async deleteTemplate(e,t,r){let o=new URLSearchParams;t&&o.set("force","true"),r&&o.set("accountId",r);let a=o.toString();return this.deleteRequest(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}${a?`?${a}`:""}`)}async mappingConfig(){return this.get("/infra/connect/whatsapp/templates/mapping/config")}async mappingSources(){return this.get("/infra/connect/whatsapp/templates/mapping/sources")}async collections(){return this.get("/infra/connect/whatsapp/templates/collections")}async collectionFields(e){return this.get(`/infra/connect/whatsapp/templates/collections/${encodeURIComponent(e)}/fields`)}async updateMapping(e,t){return this.put(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}/mapping`,t)}async validate(e,t){let r=`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}/validate`;return t?this.post(r,t):this.get(r)}async preview(e,t,r,o){return this.post(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}/preview`,{context:t,mappings:r,onEmptyVariable:o})}async getVariableManifest(e){var a,u;let t=await this.retrieve(e),r=Array.isArray((a=t.data)==null?void 0:a.components)?t.data.components:[],o=[];for(let d of r)if(d.text){let p=d.text.match(/{{(\d+)}}/g);if(p)for(let k of p){let f=k.replace(/{{|}}/g,"");o.push({key:`var_${f}`,label:`${d.type} Var {{${f}}}`,type:"string",required:!0,group:d.type,description:`Variable placeholder in template ${d.type}`})}}return{name:`Template variables: ${((u=t.data)==null?void 0:u.name)||e}`,fields:o,uiHints:{icon:"Variables",primaryColor:"#059669"}}}};var Ee=class{constructor(e){i(this,"messages");i(this,"conversations");this.messages=new ce(e),this.conversations=new wt(e)}},$e=class{constructor(e){i(this,"leads");i(this,"pipelines");i(this,"activities");i(this,"analytics");i(this,"scoring");i(this,"payments");i(this,"chat");i(this,"events");i(this,"invoices");i(this,"checkout");i(this,"projects");i(this,"niche");i(this,"documents");i(this,"invoiceExport");i(this,"ai");this.leads=new Je(e),this.pipelines=new Ze(e),this.activities=new He(e),this.analytics=new Qe(e),this.scoring=new et(e),this.payments=new Xe(e),this.chat=new Ee(e),this.events=new nt(e),this.invoices=new it(e),this.checkout=new We(e),this.projects=new ht(e),this.niche=new ct(e),this.documents=new ze(e),this.invoiceExport=new Ye(e),this.ai=new F(e)}},Oe=class{constructor(e){i(this,"automations");i(this,"campaigns");i(this,"conversations");i(this,"home");i(this,"drafts");i(this,"firstRun");i(this,"audiences");this.automations=new M(e),this.campaigns=new I(e),this.conversations=new N(e),this.home=new B(e),this.drafts=new q(e),this.firstRun=new K(e),this.audiences=new j(e)}},Ve=class{constructor(e){i(this,"projects");i(this,"audits");i(this,"insights");i(this,"searchConsole");i(this,"ranks");i(this,"local");i(this,"reports");i(this,"backlinks");i(this,"performance");i(this,"briefs");i(this,"research");this.projects=new ue(e),this.audits=new pe(e),this.insights=new ge(e),this.searchConsole=new de(e),this.ranks=new me(e),this.local=new ye(e),this.reports=new fe(e),this.backlinks=new he(e),this.performance=new xe(e),this.briefs=new ke(e),this.research=new be(e)}},De=class{constructor(e){i(this,"packs");i(this,"signals");i(this,"tools");i(this,"campaigns");i(this,"runs");i(this,"leads");i(this,"import");i(this,"lists");i(this,"compliance");i(this,"market");i(this,"learning");i(this,"lookalikes");i(this,"freshness");i(this,"audit");this.packs=new W(e),this.signals=new G(e),this.tools=new H(e),this.campaigns=new Q(e),this.runs=new z(e),this.leads=new Y(e),this.import=new J(e),this.lists=new X(e),this.compliance=new Z(e),this.market=new ee(e),this.learning=new te(e),this.lookalikes=new ne(e),this.freshness=new re(e),this.audit=new se(e)}},ve=class{constructor(e){i(this,"erix");i(this,"flow");i(this,"seo");i(this,"laie");this.erix=new $e(e),this.flow=new Oe(e),this.seo=new Ve(e),this.laie=new De(e)}},Fe=class{constructor(e){i(this,"config");i(this,"templates");this.config=new xt(e),this.templates=new tt(e)}},Ue=class{constructor(e){i(this,"templates");this.templates=new vt(e)}},Bt=class{constructor(e){i(this,"leadForms");this.leadForms=new rt(e)}},Me=class{constructor(e){i(this,"email");i(this,"whatsapp");i(this,"facebook");i(this,"meet");i(this,"connections");i(this,"accounts");i(this,"voice");this.email=new Fe(e),this.whatsapp=new Ue(e),this.facebook=new Bt(e),this.meet=new at(e),this.connections=new Ge(e),this.accounts=new U(e),this.voice=new we(e)}},_e=class{constructor(e){i(this,"files");i(this,"folders");i(this,"media");this.files=new Ct(e),this.folders=new kt(e),this.media=new ot(e)}},qt=class{constructor(e){i(this,"collector");this.collector=new Ce(e)}},Te=class{constructor(e){i(this,"connect");i(this,"storage");i(this,"serp");this.connect=new Me(e),this.storage=new _e(e),this.serp=new qt(e)}},Ne=class{constructor(e){i(this,"onboarding");i(this,"persona");i(this,"audit");this.onboarding=new ie(e),this.persona=new oe(e),this.audit=new pt(e)}},Be=class{constructor(e){i(this,"me");i(this,"members");i(this,"sessions");i(this,"notifications");this.me=new yt(e),this.members=new ft(e),this.sessions=new bt(e),this.notifications=new lt(e)}},Se=class{constructor(e){i(this,"auth");i(this,"users");i(this,"tenants");i(this,"billing");i(this,"support");i(this,"ai");i(this,"knowledge");i(this,"health");i(this,"catalog");this.auth=new gt(e),this.users=new Be(e),this.tenants=new Ne(e),this.billing=new dt(e),this.support=new mt(e),this.ai=new ut(e),this.knowledge=new le(e),this.health=new st(e),this.catalog=new ae(e)}};var P=class extends y{constructor(e){super(e,400,"invalid_signature"),this.name="WebhookSignatureError"}},Ae=class{async constructEvent(e,t,r){if(!t)throw new P("No webhook signature provided");let o=Array.isArray(t)?t[0]:t;o.startsWith("sha256=")&&(o=o.slice(7));try{let a=await import("crypto"),d=a.createHmac("sha256",r).update(e).digest("hex");if(!a.timingSafeEqual(Buffer.from(d),Buffer.from(o)))throw new P("Invalid webhook signature provided");return JSON.parse(e.toString("utf8"))}catch(a){throw a instanceof P?a:new P(`Webhook payload parsing failed: ${a.message}`)}}};var Kt=typeof process!="undefined"&&"4.1.0"||"3.1.1";var pn,jt=(pn=Wt.default.default)!=null?pn:Wt.default,O=class{constructor(e){i(this,"client");i(this,"socket",null);i(this,"startSocket",null);i(this,"socketPromise",null);i(this,"socketQueue",[]);i(this,"clientCode");i(this,"apiVersion");i(this,"platform");i(this,"product");i(this,"infra");i(this,"webhooks");i(this,"lastSeq");i(this,"closed",!1);var f,T,L,V,h,Ht,Qt,zt;let t=e.proxy;if(!e.apiKey&&!t)throw new v("API Key is required");this.clientCode=(f=e.clientCode)==null?void 0:f.toUpperCase(),this.apiVersion=(T=e.version)!=null?T:"v1";let r=(L=e.baseUrl)!=null?L:Rt,o=nn(this.apiVersion,(V=t==null?void 0:t.url)!=null?V:r),a=e.socketUrl||r,u=typeof window!="undefined"&&typeof window.document!="undefined",d=u?"browser":typeof process!="undefined"?`node ${process.version}`:"unknown",p=u?((h=globalThis.navigator)==null?void 0:h.userAgent)||"browser":typeof process!="undefined"?process.platform:"unknown",k=E(g({},t?{}:{"x-api-key":e.apiKey,"x-client-code":((Ht=e.clientCode)==null?void 0:Ht.toUpperCase())||""}),{"Content-Type":"application/json","x-ecodrix-client-agent":JSON.stringify({sdk_version:Kt,runtime:d,os:p})});if(this.client=gn.default.create({baseURL:o,headers:k,timeout:(Qt=e.timeout)!=null?Qt:3e4}),jt(this.client,{retries:3,retryDelay:jt.exponentialDelay,retryCondition:w=>{var qe;return jt.isNetworkOrIdempotentRequestError(w)||((qe=w.response)==null?void 0:qe.status)===429},onRetry:(w,qe,Yt)=>{var Jt,Xt;typeof process!="undefined"&&((Jt=process.env)==null?void 0:Jt.NODE_ENV)==="development"&&console.warn(`[ECODrIx SDK] Retrying request (${w}/3): ${(Xt=Yt.method)==null?void 0:Xt.toUpperCase()} ${Yt.url}. Reason: ${qe.message}`)}}),this.platform=new Se(this.client),this.product=new ve(this.client),this.infra=new Te(this.client),this.webhooks=new Ae,t){if(t.ticket){let w=t.ticket;this.startSocket=()=>this.initSocket(a,async()=>({ticket:await w()}))}}else{let w={apiKey:e.apiKey,clientCode:((zt=e.clientCode)==null?void 0:zt.toUpperCase())||""};this.startSocket=()=>this.initSocket(a,async()=>w,{"x-api-key":w.apiKey,"x-client-code":w.clientCode})}if(u){let w={version:Kt,clientCode:e.clientCode,initializedAt:new Date().toISOString()};window.__ECODRIX_SDK__=w}}initSocket(e,t,r){return this.socketPromise?this.socketPromise:(this.socketPromise=import("socket.io-client").then(({io:o})=>{this.socket=o(e,{auth:a=>{t().then(u=>a(E(g({},u),{lastSeq:this.lastSeq})),()=>a({lastSeq:this.lastSeq}))},extraHeaders:r,transports:["websocket","polling"],tryAllTransports:!0}),this.setupSocket();for(let{type:a,args:u}of this.socketQueue)a==="joinRoom"?this.socket.emit("join-room",u[0]):a==="leaveRoom"?this.socket.emit("leave-room",u[0]):a==="on"?this.socket.on(u[0],u[1]):a==="off"?this.socket.off(u[0],u[1]):a==="disconnect"&&this.socket.disconnect();this.socketQueue=[]}),this.socketPromise)}joinRoom(e){var t;this.closed||(t=this.startSocket)==null||t.call(this),this.socket?this.socket.emit("join-room",e):this.socketQueue.push({type:"joinRoom",args:[e]})}leaveRoom(e){this.socket?this.socket.emit("leave-room",e):this.socketQueue.push({type:"leaveRoom",args:[e]})}setupSocket(){this.socket&&(this.socket.on("connect_error",()=>{var e;(e=this.socket)!=null&&e.active||setTimeout(()=>{var t;this.closed||(t=this.socket)==null||t.connect()},5e3)}),this.socket.onAny((...e)=>{var r,o;let t=(r=e.at(-1))==null?void 0:r.seq;typeof t=="number"&&t>((o=this.lastSeq)!=null?o:0)&&(this.lastSeq=t)}))}on(e,t){var r;return this.closed||(r=this.startSocket)==null||r.call(this),this.socket?this.socket.on(e,t):this.socketQueue.push({type:"on",args:[e,t]}),this}disconnect(){this.closed=!0,this.socket?this.socket.disconnect():this.socketPromise&&this.socketQueue.push({type:"disconnect",args:[]})}off(e,t){return this.socket?this.socket.off(e,t):this.socketQueue.push({type:"off",args:[e,t]}),this}async request(e,t,r,o){var a,u,d;try{return(await this.client.request({method:e,url:t,data:r,params:o})).data}catch(p){throw p.response?new y(((a=p.response.data)==null?void 0:a.message)||((u=p.response.data)==null?void 0:u.error)||"Raw Execution Failed",p.response.status,(d=p.response.data)==null?void 0:d.code):new y(p.message||"Network Error")}}};var Sn={401:v,403:D,429:R};function An(n){throw $(n)}function Rn(n,e){return n instanceof e}function In(n){return n instanceof v?{message:n.message,status:n.status,code:n.code,type:"AuthenticationError"}:n instanceof R?{message:n.message,status:n.status,code:n.code,type:"RateLimitError"}:n instanceof y?{message:n.message,status:n.status,code:n.code,type:"APIError"}:{message:n.message||"Unknown error",type:"UnknownError"}}var Gt={[v.name]:{shouldRetry:!1,reason:"Authentication errors require fixing credentials, not retrying"},[R.name]:{shouldRetry:!0,maxRetries:3,baseDelay:1e3,backoffMultiplier:2,reason:"Rate limit errors can be retried with exponential backoff"},[y.name]:{shouldRetry:!0,maxRetries:2,baseDelay:500,backoffMultiplier:1.5,reason:"Generic API errors may be transient and worth retrying"}};function Pn(n){let e=n.constructor.name;return Gt[e]||Gt[y.name]}var Ln=O;0&&(module.exports={APIError,APIResource,AiAgent,AuthenticationError,Campaigns,Catalog,Collector,ConnectAccounts,ConnectInfra,ECODrIx,ECODrIxAPI,ERROR_RETRY_CONFIG,EcodrixError,EmailConnect,ErixChat,ErixProduct,FlowAudiences,FlowAutomations,FlowConversations,FlowDrafts,FlowFirstRunResource,FlowHome,FlowProduct,HTTP_STATUS_ERROR_MAP,InfraDomain,KNOWLEDGE_FILE_TYPES,Knowledge,LAIE_EVENTS,LEAD_STATUS_VALUES,LaieAudits,LaieCampaigns,LaieCompliance,LaieFreshness,LaieImport,LaieLeads,LaieLearning,LaieLists,LaieLookalikes,LaieMarket,LaiePacks,LaieProduct,LaieRuns,LaieSignals,LaieTools,Onboarding,PermissionError,Persona,PlatformDomain,PlatformTenants,PlatformUsers,ProductDomain,RateLimitError,SeoAudits,SeoBacklinks,SeoBriefs,SeoInsights,SeoLocal,SeoPerformance,SeoProduct,SeoProjects,SeoRanks,SeoReports,SeoResearch,SeoSearchConsole,StorageInfra,VOICE_EVENTS,VOICE_REFUSAL_REASONS,Voice,VoiceCampaigns,WebhookSignatureError,Webhooks,WhatsAppConnect,getErrorDetails,getRetryConfig,handleAPIError,isAPIError,laieStageQueued,toAPIError,voiceErrorCode,voiceRefusalReason});