@ecodrix/erix-api 4.0.0 → 4.0.2

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
- import{a as u,b as T,c as w,d as i,e as Vt,f as Dt,g as Mt,h as _t,i as nn,j as f,k as R,l as Ut,m as Te,n as A}from"./chunk-XPXDFZWU.js";import en from"axios";import qt from"axios-retry";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=u({},e);return e.idempotencyKey&&(t.headers=T(u({},t.headers),{"Idempotency-Key":e.idempotencyKey})),t}handleError(e){throw A(e)}};var $=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 v=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 I="/product/flow/conversations",m=(n,e="")=>`${I}/${encodeURIComponent(n)}${e}`,O=class extends s{async list(e={}){return this.get(I,{params:e})}async create(e){return this.post(I,e)}async retrieve(e){return this.get(m(e))}async update(e,t){return this.patch(m(e),t)}async duplicate(e){return this.post(m(e,"/duplicate"),{})}async archive(e){return this.deleteRequest(m(e))}async publish(e,t={}){return this.post(m(e,"/publish"),t)}async versions(e){return this.get(m(e,"/versions"))}async version(e,t){return this.get(m(e,`/versions/${t}`))}async rollback(e,t){return this.post(m(e,"/rollback"),{version:t})}async try(e,t){return this.post(m(e,"/try"),t)}async tests(e){return this.get(m(e,"/tests"))}async addTest(e,t){return this.post(m(e,"/tests"),t)}async deleteTest(e,t){return this.deleteRequest(m(e,`/tests/${encodeURIComponent(t)}`))}async runTests(e,t={}){return this.post(m(e,"/tests/run"),t)}async deployments(e){return this.get(m(e,"/deployments"))}async allDeployments(){return this.get(`${I}/deployments`)}async deploy(e,t){return this.post(m(e,"/deployments"),t)}async updateDeployment(e,t){return this.patch(`${I}/deployments/${encodeURIComponent(e)}`,t)}async removeDeployment(e){return this.deleteRequest(`${I}/deployments/${encodeURIComponent(e)}`)}async checks(e){return this.get(m(e,"/checks"))}};var V=class extends s{async get(){return super.get("/product/flow/home")}async nav(){return super.get("/product/flow/home/nav")}},D=class extends s{async create(e){return this.post("/product/flow/drafts",e)}},M=class extends s{async status(){return this.get("/product/flow/first-run")}async installPack(e){return this.post(`/product/flow/first-run/packs/${e}`)}},_=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){return this.get(`/product/flow/audiences/${encodeURIComponent(e)}/preview`)}async previewRules(e){return this.post("/product/flow/audiences/preview",e)}};var y="/product/erix/commerce/checkout",x="/product/erix/public/checkout",h=encodeURIComponent,gt=class extends s{async getProduct(e,t){return this.get(`${x}/products/${h(t)}`,{params:{c:e}})}async viewSession(e,t){return this.get(`${x}/sessions/view`,{params:{c:e,t}})}async updateItems(e){let o=e,{sessionId:t}=o,r=w(o,["sessionId"]);return this.post(`${x}/sessions/${h(t)}/items`,r)}async startSession(e){return this.post(`${x}/sessions`,e)}async applyCoupon(e){let o=e,{sessionId:t}=o,r=w(o,["sessionId"]);return this.post(`${x}/sessions/${h(t)}/coupon`,r)}async verify(e){let o=e,{sessionId:t}=o,r=w(o,["sessionId"]);return this.post(`${x}/sessions/${h(t)}/verify`,r)}async placeOrder(e){let o=e,{sessionId:t}=o,r=w(o,["sessionId"]);return this.post(`${x}/sessions/${h(t)}/order`,r)}async verifyRazorpay(e){let a=e,{sessionId:t,orderId:r}=a,o=w(a,["sessionId","orderId"]);return this.post(`${x}/sessions/${h(t)}/order/${h(r)}/razorpay`,o)}async orderStatus(e,t){return this.get(`${x}/orders/status`,{params:{c:e,t}})}async confirmCod(e,t){return this.post(`${x}/cod/confirm`,{clientCode:e,token:t})}},dt=class extends s{async create(e){return this.post(`${y}/sessions`,e)}},ve=class extends s{constructor(t){super(t);i(this,"buyer");i(this,"sessions");this.buyer=new gt(t),this.sessions=new dt(t)}async listProducts(){return this.get(`${y}/products`)}async createProduct(t){return this.post(`${y}/products`,t)}async updateProduct(t,r){return this.patch(`${y}/products/${h(t)}`,r)}async deleteProduct(t){return this.deleteRequest(`${y}/products/${h(t)}`)}async listCoupons(){return this.get(`${y}/coupons`)}async createCoupon(t){return this.post(`${y}/coupons`,t)}async updateCoupon(t,r){return this.patch(`${y}/coupons/${h(t)}`,r)}async deleteCoupon(t){return this.deleteRequest(`${y}/coupons/${h(t)}`)}async listOrders(t){return this.get(`${y}/orders`,{params:t})}async getOrder(t){return this.get(`${y}/orders/${h(t)}`)}async updateOrderStatus(t,r){return this.patch(`${y}/orders/${h(t)}/status`,r)}async getSettings(){return this.get(`${y}/settings`)}async updateSettings(t){return this.put(`${y}/settings`,t)}async createProductLink(t){return this.post(`${y}/links`,t)}};var mt=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}`)}},Ce=class extends s{constructor(t){super(t);i(this,"notes");this.notes=new mt(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:u({},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 Se=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 Re=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 Ae=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 Ft=["open","won","lost","archived"],Ie=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:Ft.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 l=e.slice(o,o+t).map(g=>this.create(g)),d=await Promise.allSettled(l);for(let g of d)if(g.status==="fulfilled")r.push(g.value);else throw g.reason}return r}async import(e,t={}){return this.post("/product/erix/crm/leads/import",u({leads:e},t))}async bulkUpsert(e){return this.import(e)}async list(e){let t=u({},e);return Array.isArray(t.tags)&&(t.tags=t.tags.join(",")),this.get("/product/erix/crm/leads",{params:t})}listAutoPaging(e){return Dt(this,null,function*(){let t=(e==null?void 0:e.page)||1,r=!0;for(;r;){let o=yield new Vt(this.list(T(u({},e),{page:t}))),a=Array.isArray(o.data)?o.data:o||[];if(a.length===0){r=!1;break}for(let l of a)yield l;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 Pe=class extends s{async capture(e){return this.post("/product/erix/crm/payments/capture",e)}};var Le=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(l=>({key:l._id,label:l.name,type:"string",required:!0,options:[{label:l.name,value:l._id}],group:"Stages",uiHints:{color:l.color||"#cbd5e1",probability:l.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 Ee=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 $e=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 Oe=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 Ve=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 De=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 Me=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 P=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 S,k,E;let r=(k=(S=t.fileName)!=null?S:e.name)!=null?k:"file",o=e.type||"application/octet-stream",a=await this.post("/infra/storage/files/upload-url",{folder:(E=t.folder)!=null?E:"inbox",filename:r,contentType:o}),{uploadUrl:l,key:d}=a.data,g=await fetch(l,{method:"PUT",headers:{"Content-Type":o},body:e});if(!g.ok)throw new Error(`upload failed (${g.status})`);return await this.post("/infra/storage/files/confirm-upload",{key:d,sizeBytes:e.size}),{key:d,mimeType:o,fileName:r}}};var _e=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 createPaymentLink(e){return this.post("/infra/connect/connections/payments/payment-link",e)}};var Ue=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 Fe=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 Ne=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 qe=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,l;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 g=d.text.match(/{{(\d+)}}/g);if(g)for(let S of g){let k=S.replace(/{{|}}/g,"");o.push({key:`var_${k}`,label:`${d.type} Var {{${k}}}`,type:"string",required:!0,group:d.type,description:`Variable placeholder in template ${d.type}`})}}return{name:`Template variables: ${((l=t.data)==null?void 0:l.name)||e}`,fields:o,uiHints:{icon:"Variables",primaryColor:"#059669"}}}};var jt=n=>"queued"in n&&n.queued===!0,Gt={runProgress:"laie:run:progress",importComplete:"laie:import:complete"},p=encodeURIComponent,c="/product/laie",U=class extends s{async list(){return this.get(`${c}/packs`)}async byId(e){return this.get(`${c}/packs/${p(e)}`)}},F=class extends s{async catalog(e={}){return this.get(`${c}/signals/catalog`,{params:e})}async list(e={}){return this.get(`${c}/signals`,{params:e})}},N=class extends s{async find(e){return this.post(`${c}/tools/find`,e)}async collect(e){return this.post(`${c}/tools/collect`,e)}async enrich(e){return this.post(`${c}/tools/enrich`,e)}async verify(e){return this.post(`${c}/tools/verify`,e)}async qualify(e){return this.post(`${c}/tools/qualify`,e)}async store(e){return this.post(`${c}/tools/store`,e)}async use(e){return this.post(`${c}/tools/use`,e)}async verifyEmail(e){return this.post(`${c}/tools/verify-email`,{emails:e})}async websiteLookup(e){return this.post(`${c}/tools/website-lookup`,{url:e})}},q=class extends s{async list(){return this.get(`${c}/campaigns`)}async create(e){return this.post(`${c}/campaigns`,e)}async byId(e){return this.get(`${c}/flows/${p(e)}`)}async settings(e){return this.get(`${c}/campaigns/${p(e)}/settings`)}async updateSettings(e,t){return this.patch(`${c}/campaigns/${p(e)}/settings`,t)}async signals(e){return this.get(`${c}/campaigns/${p(e)}/signals`)}async setSignals(e,t){return this.put(`${c}/campaigns/${p(e)}/signals`,t)}},B=class extends s{async start(e){return this.post(`${c}/campaigns/${p(e)}/runs`)}async list(e,t={}){return this.get(`${c}/campaigns/${p(e)}/runs`,{params:t})}async byId(e,t){return this.get(`${c}/campaigns/${p(e)}/runs/${p(t)}`)}async changes(e,t,r={}){return this.get(`${c}/campaigns/${p(e)}/runs/${p(t)}/changes`,{params:r})}async cancel(e,t){return this.post(`${c}/campaigns/${p(e)}/runs/${p(t)}/cancel`)}async quality(e){return this.get(`${c}/jobs/${p(e)}/quality`)}},K=class extends s{async list(e={}){let o=e,{importedToCrm:t}=o,r=w(o,["importedToCrm"]);return this.get(`${c}/leads`,{params:u(u({},r),t!==void 0&&{importedToCrm:String(t)})})}async byId(e){return this.get(`${c}/leads/${p(e)}`)}async update(e,t){return this.patch(`${c}/leads/${p(e)}`,t)}async notes(e){return this.get(`${c}/leads/${p(e)}/notes`)}async addNote(e,t){return this.post(`${c}/leads/${p(e)}/notes`,t)}async generateKit(e){return this.post(`${c}/leads/${p(e)}/generate-kit`)}async pipelineSummary(){return this.get(`${c}/leads/pipeline-summary`)}async bulkContacted(e,t){return this.post(`${c}/leads/bulk/contacted`,{leadIds:e,channel:t})}async bulkTag(e,t){return this.post(`${c}/leads/bulk/tag`,{leadIds:e,tags:t})}async bulkDelete(e){return this.post(`${c}/leads/bulk/delete`,{leadIds:e})}async bulkExport(e,t="json"){return t==="csv"?this.post(`${c}/leads/bulk/export`,{leadIds:e,format:t},{responseType:"text"}):this.post(`${c}/leads/bulk/export`,{leadIds:e,format:t})}},j=class extends s{async pipelines(){return this.get(`${c}/import/pipelines`)}async crm(e){return this.post(`${c}/import/crm`,e)}},G=class extends s{async enrich(e){return this.post(`${c}/lists/enrich`,e)}},H=class extends s{async dsr(e){return this.post(`${c}/compliance/dsr`,e)}async report(e={}){return this.get(`${c}/compliance/report`,{params:e})}},W=class extends s{async map(e={}){return this.get(`${c}/market-map`,{params:e})}async forCampaign(e){return this.get(`${c}/campaigns/${p(e)}/market-map`)}async refresh(e={}){return this.post(`${c}/market-map/refresh`,e)}},Q=class extends s{async weights(e={}){return this.get(`${c}/learning/weights`,{params:e})}async outcomes(e={}){return this.get(`${c}/learning/outcomes`,{params:e})}},z=class extends s{async preview(e){return this.post(`${c}/lookalikes/preview`,e)}async create(e){return this.post(`${c}/lookalikes`,e)}async list(e={}){return this.get(`${c}/lookalikes`,{params:e})}async byId(e){return this.get(`${c}/lookalikes/${p(e)}`)}async rank(e,t={}){return this.get(`${c}/lookalikes/${p(e)}/rank`,{params:t})}},Y=class extends s{async status(){return this.get(`${c}/freshness`)}},J=class extends s{async start(e){return this.post(`${c}/audit`,e)}async byId(e){return this.get(`${c}/audit/${p(e)}`)}};import Ht from"axios";var Be=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 Ht.put(o,e,{headers:{"Content-Type":t.contentType}});let l=e.size||e.byteLength||0;return this.post("/infra/storage/files/confirm-upload",{key:a,sizeBytes:l})}};var Wt={callChanged:"voice_call_changed"},Qt=["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 zt(n){let e=n instanceof f?n.code:void 0;return e&&Qt.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."};function Yt(n){var e;return(e=Nt[n])!=null?e:n}var X=encodeURIComponent,Ke=class extends s{get flow(){return new v(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/${X(e)}/voice-preview`)}counters(e){return this.get(`/infra/connect/voice/campaigns/${X(e)}/counters`)}approval(e){return this.get(`/infra/connect/voice/campaigns/${X(e)}/approval`)}requestApproval(e){return this.post(`/infra/connect/voice/campaigns/${X(e)}/approval/request`,{})}},Z=class extends s{constructor(t){super(t);i(this,"campaigns");this.campaigns=new Ke(t)}status(){return this.get("/infra/connect/voice/status")}agent(){return this.get("/infra/connect/voice/agent")}skills(){return this.get("/infra/connect/voice/skills")}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(l){o.response.data=void 0}throw A(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/${X(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 ee=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})}},te=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"})}},ne=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)}`)}},re=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})}},se=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`,u({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`)}},ie=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})}},oe=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`)}},ae=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 ce=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})}},le=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})}},ue=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:u({projectId:e},t)})}};var Jt=35e3,pe=class extends s{async claim(e,t){var o;let r=await this.post("/infra/serp/collector/claim",{collectorId:e,kinds:t},{timeout:Jt});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",u({collectorId:e},t))}};var je=class extends s{async create(e){return this.post("/infra/storage/files/folders",{name:e})}},Ge=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 ge=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)}`,u({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`,u({decision:t},r&&{nodeId:r}))}};var He=class extends s{async system(){return(await this.get("/health")).data}};var We=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 de=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 me=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 yt=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"}},Qe=class{constructor(e){i(this,"copilot");this.copilot=new yt(e)}};var ze=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 ht=class extends s{async get(){return super.get("/platform/billing/entitlements/entitlements")}async usage(){return super.get("/platform/billing/entitlements/usage")}},bt=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)}async purchaseAddon(e){return this.post("/platform/billing/subscriptions/addons/purchase",e)}async cancelAddon(e){return this.post("/platform/billing/subscriptions/addons/cancel",e)}},ft=class extends s{async listPublic(){return this.get("/platform/billing/plans/public")}},xt=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)}},kt=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")}},wt=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)}},Ye=class{constructor(e){i(this,"entitlements");i(this,"subscriptions");i(this,"plans");i(this,"checkout");i(this,"user");i(this,"credits");this.entitlements=new ht(e),this.subscriptions=new bt(e),this.plans=new ft(e),this.checkout=new xt(e),this.user=new kt(e),this.credits=new wt(e)}};var ye=class extends s{async list(){return this.get("/platform/public/catalog",{ignoreClientCode:!0})}};var Xt=["application/pdf","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/plain","text/markdown","text/csv","text/html","image/png","image/jpeg","image/webp"],he=class extends s{async list(){return this.get("/platform/knowledge/sources")}async addText(e){return this.post("/platform/knowledge/sources",u({kind:"text"},e))}async addUrl(e){return this.post("/platform/knowledge/sources",u({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 P(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",u({query:e},t?{limit:t}:{}))}};var Je=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 Xe=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",{})}},Ze=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)}`)}},et=class extends s{async list(){return this.get("/platform/auth/sessions")}async revoke(e){return this.deleteRequest(`/platform/auth/sessions/${e}`)}};var tt=class{constructor(e){i(this,"messages");i(this,"conversations");this.messages=new P(e),this.conversations=new Me(e)}},nt=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 Ie(e),this.pipelines=new Le(e),this.activities=new Ce(e),this.analytics=new Se(e),this.scoring=new Ee(e),this.payments=new Pe(e),this.chat=new tt(e),this.events=new $e(e),this.invoices=new Oe(e),this.checkout=new ve(e),this.projects=new De(e),this.niche=new Ve(e),this.documents=new Re(e),this.invoiceExport=new Ae(e),this.ai=new ge(e)}},rt=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 $(e),this.campaigns=new v(e),this.conversations=new O(e),this.home=new V(e),this.drafts=new D(e),this.firstRun=new M(e),this.audiences=new _(e)}},st=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 ee(e),this.audits=new te(e),this.insights=new ne(e),this.searchConsole=new re(e),this.ranks=new se(e),this.local=new ie(e),this.reports=new oe(e),this.backlinks=new ce(e),this.performance=new le(e),this.briefs=new ue(e),this.research=new ae(e)}},it=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 U(e),this.signals=new F(e),this.tools=new N(e),this.campaigns=new q(e),this.runs=new B(e),this.leads=new K(e),this.import=new j(e),this.lists=new G(e),this.compliance=new H(e),this.market=new W(e),this.learning=new Q(e),this.lookalikes=new z(e),this.freshness=new Y(e),this.audit=new J(e)}},be=class{constructor(e){i(this,"erix");i(this,"flow");i(this,"seo");i(this,"laie");this.erix=new nt(e),this.flow=new rt(e),this.seo=new st(e),this.laie=new it(e)}},ot=class{constructor(e){i(this,"config");i(this,"templates");this.config=new Ne(e),this.templates=new Ue(e)}},at=class{constructor(e){i(this,"templates");this.templates=new qe(e)}},ct=class{constructor(e){i(this,"email");i(this,"whatsapp");i(this,"meet");i(this,"connections");i(this,"voice");this.email=new ot(e),this.whatsapp=new at(e),this.meet=new Fe(e),this.connections=new _e(e),this.voice=new Z(e)}},lt=class{constructor(e){i(this,"files");i(this,"folders");i(this,"media");this.files=new Ge(e),this.folders=new je(e),this.media=new Be(e)}},Tt=class{constructor(e){i(this,"collector");this.collector=new pe(e)}},fe=class{constructor(e){i(this,"connect");i(this,"storage");i(this,"serp");this.connect=new ct(e),this.storage=new lt(e),this.serp=new Tt(e)}},ut=class{constructor(e){i(this,"onboarding");i(this,"persona");this.onboarding=new de(e),this.persona=new me(e)}},pt=class{constructor(e){i(this,"me");i(this,"members");i(this,"sessions");i(this,"notifications");this.me=new Xe(e),this.members=new Ze(e),this.sessions=new et(e),this.notifications=new We(e)}},xe=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 ze(e),this.users=new pt(e),this.tenants=new ut(e),this.billing=new Ye(e),this.support=new Je(e),this.ai=new Qe(e),this.knowledge=new he(e),this.health=new He(e),this.catalog=new ye(e)}};var C=class extends f{constructor(e){super(e,400,"invalid_signature"),this.name="WebhookSignatureError"}},ke=class{async constructEvent(e,t,r){if(!t)throw new C("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 C("Invalid webhook signature provided");return JSON.parse(e.toString("utf8"))}catch(a){throw a instanceof C?a:new C(`Webhook payload parsing failed: ${a.message}`)}}};var vt=typeof process!="undefined"&&"4.0.0"||"3.1.1";var Bt,Ct=(Bt=qt.default)!=null?Bt:qt,L=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 k,E,St,Rt,At,It,Pt,Lt;let t=e.proxy;if(!e.apiKey&&!t)throw new R("API Key is required");this.clientCode=(k=e.clientCode)==null?void 0:k.toUpperCase(),this.apiVersion=(E=e.version)!=null?E:"v1";let r=(St=e.baseUrl)!=null?St:Mt,o=_t(this.apiVersion,(Rt=t==null?void 0:t.url)!=null?Rt:r),a=e.socketUrl||r,l=typeof window!="undefined"&&typeof window.document!="undefined",d=l?"browser":typeof process!="undefined"?`node ${process.version}`:"unknown",g=l?((At=globalThis.navigator)==null?void 0:At.userAgent)||"browser":typeof process!="undefined"?process.platform:"unknown",S=T(u({},t?{}:{"x-api-key":e.apiKey,"x-client-code":((It=e.clientCode)==null?void 0:It.toUpperCase())||""}),{"Content-Type":"application/json","x-ecodrix-client-agent":JSON.stringify({sdk_version:vt,runtime:d,os:g})});if(this.client=en.create({baseURL:o,headers:S,timeout:(Pt=e.timeout)!=null?Pt:3e4}),Ct(this.client,{retries:3,retryDelay:Ct.exponentialDelay,retryCondition:b=>{var we;return Ct.isNetworkOrIdempotentRequestError(b)||((we=b.response)==null?void 0:we.status)===429},onRetry:(b,we,Et)=>{var $t,Ot;typeof process!="undefined"&&(($t=process.env)==null?void 0:$t.NODE_ENV)==="development"&&console.warn(`[ECODrIx SDK] Retrying request (${b}/3): ${(Ot=Et.method)==null?void 0:Ot.toUpperCase()} ${Et.url}. Reason: ${we.message}`)}}),this.platform=new xe(this.client),this.product=new be(this.client),this.infra=new fe(this.client),this.webhooks=new ke,t){if(t.ticket){let b=t.ticket;this.startSocket=()=>this.initSocket(a,async()=>({ticket:await b()}))}}else{let b={apiKey:e.apiKey,clientCode:((Lt=e.clientCode)==null?void 0:Lt.toUpperCase())||""};this.startSocket=()=>this.initSocket(a,async()=>b,{"x-api-key":b.apiKey,"x-client-code":b.clientCode})}if(l){let b={version:vt,clientCode:e.clientCode,initializedAt:new Date().toISOString()};window.__ECODRIX_SDK__=b}}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(l=>a(T(u({},l),{lastSeq:this.lastSeq})),()=>a({lastSeq:this.lastSeq}))},extraHeaders:r}),this.setupSocket();for(let{type:a,args:l}of this.socketQueue)a==="joinRoom"?this.socket.emit("join-room",l[0]):a==="leaveRoom"?this.socket.emit("leave-room",l[0]):a==="on"?this.socket.on(l[0],l[1]):a==="off"?this.socket.off(l[0],l[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,l,d;try{return(await this.client.request({method:e,url:t,data:r,params:o})).data}catch(g){throw g.response?new f(((a=g.response.data)==null?void 0:a.message)||((l=g.response.data)==null?void 0:l.error)||"Raw Execution Failed",g.response.status,(d=g.response.data)==null?void 0:d.code):new f(g.message||"Network Error")}}};var ci={401:R,403:Ut,429:Te};function li(n){throw A(n)}function ui(n,e){return n instanceof e}function pi(n){return n instanceof R?{message:n.message,status:n.status,code:n.code,type:"AuthenticationError"}:n instanceof Te?{message:n.message,status:n.status,code:n.code,type:"RateLimitError"}:n instanceof f?{message:n.message,status:n.status,code:n.code,type:"APIError"}:{message:n.message||"Unknown error",type:"UnknownError"}}var Kt={[R.name]:{shouldRetry:!1,reason:"Authentication errors require fixing credentials, not retrying"},[Te.name]:{shouldRetry:!0,maxRetries:3,baseDelay:1e3,backoffMultiplier:2,reason:"Rate limit errors can be retried with exponential backoff"},[f.name]:{shouldRetry:!0,maxRetries:2,baseDelay:500,backoffMultiplier:1.5,reason:"Generic API errors may be transient and worth retrying"}};function gi(n){let e=n.constructor.name;return Kt[e]||Kt[f.name]}var yi=L;export{f as APIError,s as APIResource,ge as AiAgent,R as AuthenticationError,v as Campaigns,ye as Catalog,pe as Collector,ct as ConnectInfra,L as ECODrIx,L as ECODrIxAPI,Kt as ERROR_RETRY_CONFIG,nn as EcodrixError,ot as EmailConnect,tt as ErixChat,nt as ErixProduct,_ as FlowAudiences,$ as FlowAutomations,O as FlowConversations,D as FlowDrafts,M as FlowFirstRunResource,V as FlowHome,rt as FlowProduct,ci as HTTP_STATUS_ERROR_MAP,fe as InfraDomain,Xt as KNOWLEDGE_FILE_TYPES,he as Knowledge,Gt as LAIE_EVENTS,Ft as LEAD_STATUS_VALUES,J as LaieAudits,q as LaieCampaigns,H as LaieCompliance,Y as LaieFreshness,j as LaieImport,K as LaieLeads,Q as LaieLearning,G as LaieLists,z as LaieLookalikes,W as LaieMarket,U as LaiePacks,it as LaieProduct,B as LaieRuns,F as LaieSignals,N as LaieTools,de as Onboarding,Ut as PermissionError,me as Persona,xe as PlatformDomain,ut as PlatformTenants,pt as PlatformUsers,be as ProductDomain,Te as RateLimitError,te as SeoAudits,ce as SeoBacklinks,ue as SeoBriefs,ne as SeoInsights,ie as SeoLocal,le as SeoPerformance,st as SeoProduct,ee as SeoProjects,se as SeoRanks,oe as SeoReports,ae as SeoResearch,re as SeoSearchConsole,lt as StorageInfra,Wt as VOICE_EVENTS,Nt as VOICE_REFUSAL_REASONS,Z as Voice,Ke as VoiceCampaigns,C as WebhookSignatureError,ke as Webhooks,at as WhatsAppConnect,yi as default,pi as getErrorDetails,gi as getRetryConfig,li as handleAPIError,ui as isAPIError,jt as laieStageQueued,A as toAPIError,zt as voiceErrorCode,Yt as voiceRefusalReason};
1
+ import{a as u,b as v,c as w,d as i,e as Ut,f as Ft,g as Nt,h as qt,i as an,j as f,k as R,l as Bt,m as ve,n as A}from"./chunk-XPXDFZWU.js";import sn from"axios";import Gt from"axios-retry";var r=class{constructor(e){i(this,"client",e)}async post(e,t,s){try{let o=this.buildConfig(s);return(await this.client.post(e,t,o)).data}catch(o){this.handleError(o)}}async get(e,t){try{let s=this.buildConfig(t);return(await this.client.get(e,s)).data}catch(s){this.handleError(s)}}async patch(e,t,s){try{let o=this.buildConfig(s);return(await this.client.patch(e,t,o)).data}catch(o){this.handleError(o)}}async put(e,t,s){try{let o=this.buildConfig(s);return(await this.client.put(e,t,o)).data}catch(o){this.handleError(o)}}async deleteRequest(e,t){try{let s=this.buildConfig(t);return(await this.client.delete(e,s)).data}catch(s){this.handleError(s)}}buildConfig(e){if(!e)return;let t=u({},e);return e.idempotencyKey&&(t.headers=v(u({},t.headers),{"Idempotency-Key":e.idempotencyKey})),t}handleError(e){throw A(e)}};var $=class extends r{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 T=class extends r{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 I="/product/flow/conversations",m=(n,e="")=>`${I}/${encodeURIComponent(n)}${e}`,V=class extends r{async list(e={}){return this.get(I,{params:e})}async create(e){return this.post(I,e)}async retrieve(e){return this.get(m(e))}async update(e,t){return this.patch(m(e),t)}async duplicate(e){return this.post(m(e,"/duplicate"),{})}async archive(e){return this.deleteRequest(m(e))}async publish(e,t={}){return this.post(m(e,"/publish"),t)}async versions(e){return this.get(m(e,"/versions"))}async version(e,t){return this.get(m(e,`/versions/${t}`))}async rollback(e,t){return this.post(m(e,"/rollback"),{version:t})}async try(e,t){return this.post(m(e,"/try"),t)}async tests(e){return this.get(m(e,"/tests"))}async addTest(e,t){return this.post(m(e,"/tests"),t)}async deleteTest(e,t){return this.deleteRequest(m(e,`/tests/${encodeURIComponent(t)}`))}async runTests(e,t={}){return this.post(m(e,"/tests/run"),t)}async deployments(e){return this.get(m(e,"/deployments"))}async allDeployments(){return this.get(`${I}/deployments`)}async deploy(e,t){return this.post(m(e,"/deployments"),t)}async updateDeployment(e,t){return this.patch(`${I}/deployments/${encodeURIComponent(e)}`,t)}async removeDeployment(e){return this.deleteRequest(`${I}/deployments/${encodeURIComponent(e)}`)}async checks(e){return this.get(m(e,"/checks"))}};var O=class extends r{async get(){return super.get("/product/flow/home")}async nav(){return super.get("/product/flow/home/nav")}},D=class extends r{async create(e){return this.post("/product/flow/drafts",e)}},_=class extends r{async status(){return this.get("/product/flow/first-run")}async installPack(e){return this.post(`/product/flow/first-run/packs/${e}`)}},M=class extends r{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 y="/product/erix/commerce/checkout",x="/product/erix/public/checkout",h=encodeURIComponent,mt=class extends r{async getProduct(e,t){return this.get(`${x}/products/${h(t)}`,{params:{c:e}})}async viewSession(e,t){return this.get(`${x}/sessions/view`,{params:{c:e,t}})}async updateItems(e){let o=e,{sessionId:t}=o,s=w(o,["sessionId"]);return this.post(`${x}/sessions/${h(t)}/items`,s)}async startSession(e){return this.post(`${x}/sessions`,e)}async applyCoupon(e){let o=e,{sessionId:t}=o,s=w(o,["sessionId"]);return this.post(`${x}/sessions/${h(t)}/coupon`,s)}async verify(e){let o=e,{sessionId:t}=o,s=w(o,["sessionId"]);return this.post(`${x}/sessions/${h(t)}/verify`,s)}async placeOrder(e){let o=e,{sessionId:t}=o,s=w(o,["sessionId"]);return this.post(`${x}/sessions/${h(t)}/order`,s)}async verifyRazorpay(e){let a=e,{sessionId:t,orderId:s}=a,o=w(a,["sessionId","orderId"]);return this.post(`${x}/sessions/${h(t)}/order/${h(s)}/razorpay`,o)}async orderStatus(e,t){return this.get(`${x}/orders/status`,{params:{c:e,t}})}async confirmCod(e,t){return this.post(`${x}/cod/confirm`,{clientCode:e,token:t})}},yt=class extends r{async create(e){return this.post(`${y}/sessions`,e)}},Te=class extends r{constructor(t){super(t);i(this,"buyer");i(this,"sessions");this.buyer=new mt(t),this.sessions=new yt(t)}async listProducts(){return this.get(`${y}/products`)}async createProduct(t){return this.post(`${y}/products`,t)}async updateProduct(t,s){return this.patch(`${y}/products/${h(t)}`,s)}async deleteProduct(t){return this.deleteRequest(`${y}/products/${h(t)}`)}async listCoupons(){return this.get(`${y}/coupons`)}async createCoupon(t){return this.post(`${y}/coupons`,t)}async updateCoupon(t,s){return this.patch(`${y}/coupons/${h(t)}`,s)}async deleteCoupon(t){return this.deleteRequest(`${y}/coupons/${h(t)}`)}async listOrders(t){return this.get(`${y}/orders`,{params:t})}async getOrder(t){return this.get(`${y}/orders/${h(t)}`)}async updateOrderStatus(t,s){return this.patch(`${y}/orders/${h(t)}/status`,s)}async getSettings(){return this.get(`${y}/settings`)}async updateSettings(t){return this.put(`${y}/settings`,t)}async createProductLink(t){return this.post(`${y}/links`,t)}};var ht=class extends r{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}`)}},Se=class extends r{constructor(t){super(t);i(this,"notes");this.notes=new ht(t)}async timeline(t,s){return this.get(`/product/erix/crm/leads/${t}/timeline`,{params:s})}async list(t,s){return this.get(`/product/erix/crm/leads/${t}/activities`,{params:u({},s)})}async log(t){return this.post(`/product/erix/crm/leads/${t.leadId}/activities`,t)}async logCall(t,s){return this.post(`/product/erix/crm/leads/${t}/calls`,s)}};var Ce=class extends r{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 Re=class extends r{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,s){return this.patch(`/product/erix/crm/documents/checklist/${e}/${t}`,s?{fileUrl:s}:{})}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 Ae=class extends r{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 Kt=["open","won","lost","archived"],Ie=class extends r{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:[],s=[{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:Kt.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:[...s,...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 s=[];for(let o=0;o<e.length;o+=t){let l=e.slice(o,o+t).map(g=>this.create(g)),d=await Promise.allSettled(l);for(let g of d)if(g.status==="fulfilled")s.push(g.value);else throw g.reason}return s}async import(e,t={}){return this.post("/product/erix/crm/leads/import",u({leads:e},t))}async bulkUpsert(e){return this.import(e)}async list(e){let t=u({},e);return Array.isArray(t.tags)&&(t.tags=t.tags.join(",")),this.get("/product/erix/crm/leads",{params:t})}listAutoPaging(e){return Ft(this,null,function*(){let t=(e==null?void 0:e.page)||1,s=!0;for(;s;){let o=yield new Ut(this.list(v(u({},e),{page:t}))),a=Array.isArray(o.data)?o.data:o||[];if(a.length===0){s=!1;break}for(let l of a)yield l;o.pagination&&t<o.pagination.pages||!o.pagination&&a.length>0?t++:s=!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,s={}){return this.get(`/product/erix/crm/pipelines/${e}/stages/${t}/leads`,{params:s})}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,s){return this.patch(`/product/erix/crm/leads/${e}`,{nextFollowUpAt:t,nextFollowUpNote:t&&s!=null?s:null})}async move(e,t){return this.patch(`/product/erix/crm/leads/${e}/move`,{stageId:t})}async convert(e,t,s){return this.post(`/product/erix/crm/leads/${e}/convert`,{outcome:t,reason:s})}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,s){return this.patch(`/product/erix/crm/notes/${t}`,s)}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 Pe=class extends r{async capture(e){return this.post("/product/erix/crm/payments/capture",e)}};var Le=class extends r{async list(){return this.get("/product/erix/crm/pipelines")}async getStageManifest(e){var o,a;let t=await this.retrieve(e),s=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:s.map(l=>({key:l._id,label:l.name,type:"string",required:!0,options:[{label:l.name,value:l._id}],group:"Stages",uiHints:{color:l.color||"#cbd5e1",probability:l.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 Ee=class extends r{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 $e=class extends r{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 Ve=class extends r{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 Oe=class extends r{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 De=class extends r{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,s){return this.patch(`/product/erix/commerce/projects/${e}/documents/${t}/signature`,{required:s})}async addSigner(e,t,s){return this.post(`/product/erix/commerce/projects/${e}/documents/${t}/signers`,s)}async decline(e,t){return this.post(`/product/erix/commerce/projects/${e}/documents/${t}/decline`,{})}async stampSign(e,t,s){return this.post(`/product/erix/commerce/projects/${e}/documents/${t}/stamp-sign`,s)}};var _e=class extends r{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 P=class extends r{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 C,k,E;let s=(k=(C=t.fileName)!=null?C:e.name)!=null?k:"file",o=e.type||"application/octet-stream",a=await this.post("/infra/storage/files/upload-url",{folder:(E=t.folder)!=null?E:"inbox",filename:s,contentType:o}),{uploadUrl:l,key:d}=a.data,g=await fetch(l,{method:"PUT",headers:{"Content-Type":o},body:e});if(!g.ok)throw new Error(`upload failed (${g.status})`);return await this.post("/infra/storage/files/confirm-upload",{key:d,sizeBytes:e.size}),{key:d,mimeType:o,fileName:s}}};var Me=class extends r{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 Ue=class extends r{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 Fe=class extends r{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 Ne=class extends r{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 qe=class extends r{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 s=`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}/validate`;return t?this.post(s,t):this.get(s)}async preview(e,t,s,o){return this.post(`/infra/connect/whatsapp/templates/${encodeURIComponent(e)}/preview`,{context:t,mappings:s,onEmptyVariable:o})}async getVariableManifest(e){var a,l;let t=await this.retrieve(e),s=Array.isArray((a=t.data)==null?void 0:a.components)?t.data.components:[],o=[];for(let d of s)if(d.text){let g=d.text.match(/{{(\d+)}}/g);if(g)for(let C of g){let k=C.replace(/{{|}}/g,"");o.push({key:`var_${k}`,label:`${d.type} Var {{${k}}}`,type:"string",required:!0,group:d.type,description:`Variable placeholder in template ${d.type}`})}}return{name:`Template variables: ${((l=t.data)==null?void 0:l.name)||e}`,fields:o,uiHints:{icon:"Variables",primaryColor:"#059669"}}}};var Qt=n=>"queued"in n&&n.queued===!0,zt={runProgress:"laie:run:progress",importComplete:"laie:import:complete"},p=encodeURIComponent,c="/product/laie",U=class extends r{async list(){return this.get(`${c}/packs`)}async byId(e){return this.get(`${c}/packs/${p(e)}`)}},F=class extends r{async catalog(e={}){return this.get(`${c}/signals/catalog`,{params:e})}async list(e={}){return this.get(`${c}/signals`,{params:e})}},N=class extends r{async find(e){return this.post(`${c}/tools/find`,e)}async collect(e){return this.post(`${c}/tools/collect`,e)}async enrich(e){return this.post(`${c}/tools/enrich`,e)}async verify(e){return this.post(`${c}/tools/verify`,e)}async qualify(e){return this.post(`${c}/tools/qualify`,e)}async store(e){return this.post(`${c}/tools/store`,e)}async use(e){return this.post(`${c}/tools/use`,e)}async verifyEmail(e){return this.post(`${c}/tools/verify-email`,{emails:e})}async websiteLookup(e){return this.post(`${c}/tools/website-lookup`,{url:e})}},q=class extends r{async list(){return this.get(`${c}/campaigns`)}async create(e){return this.post(`${c}/campaigns`,e)}async byId(e){return this.get(`${c}/flows/${p(e)}`)}async settings(e){return this.get(`${c}/campaigns/${p(e)}/settings`)}async updateSettings(e,t){return this.patch(`${c}/campaigns/${p(e)}/settings`,t)}async signals(e){return this.get(`${c}/campaigns/${p(e)}/signals`)}async setSignals(e,t){return this.put(`${c}/campaigns/${p(e)}/signals`,t)}},B=class extends r{async start(e){return this.post(`${c}/campaigns/${p(e)}/runs`)}async list(e,t={}){return this.get(`${c}/campaigns/${p(e)}/runs`,{params:t})}async byId(e,t){return this.get(`${c}/campaigns/${p(e)}/runs/${p(t)}`)}async changes(e,t,s={}){return this.get(`${c}/campaigns/${p(e)}/runs/${p(t)}/changes`,{params:s})}async cancel(e,t){return this.post(`${c}/campaigns/${p(e)}/runs/${p(t)}/cancel`)}async quality(e){return this.get(`${c}/jobs/${p(e)}/quality`)}},K=class extends r{async list(e={}){let o=e,{importedToCrm:t}=o,s=w(o,["importedToCrm"]);return this.get(`${c}/leads`,{params:u(u({},s),t!==void 0&&{importedToCrm:String(t)})})}async byId(e){return this.get(`${c}/leads/${p(e)}`)}async update(e,t){return this.patch(`${c}/leads/${p(e)}`,t)}async notes(e){return this.get(`${c}/leads/${p(e)}/notes`)}async addNote(e,t){return this.post(`${c}/leads/${p(e)}/notes`,t)}async generateKit(e){return this.post(`${c}/leads/${p(e)}/generate-kit`)}async pipelineSummary(){return this.get(`${c}/leads/pipeline-summary`)}async bulkContacted(e,t){return this.post(`${c}/leads/bulk/contacted`,{leadIds:e,channel:t})}async bulkTag(e,t){return this.post(`${c}/leads/bulk/tag`,{leadIds:e,tags:t})}async bulkDelete(e){return this.post(`${c}/leads/bulk/delete`,{leadIds:e})}async bulkExport(e,t="json"){return t==="csv"?this.post(`${c}/leads/bulk/export`,{leadIds:e,format:t},{responseType:"text"}):this.post(`${c}/leads/bulk/export`,{leadIds:e,format:t})}},j=class extends r{async pipelines(){return this.get(`${c}/import/pipelines`)}async crm(e){return this.post(`${c}/import/crm`,e)}},G=class extends r{async enrich(e){return this.post(`${c}/lists/enrich`,e)}},H=class extends r{async dsr(e){return this.post(`${c}/compliance/dsr`,e)}async report(e={}){return this.get(`${c}/compliance/report`,{params:e})}},W=class extends r{async map(e={}){return this.get(`${c}/market-map`,{params:e})}async forCampaign(e){return this.get(`${c}/campaigns/${p(e)}/market-map`)}async refresh(e={}){return this.post(`${c}/market-map/refresh`,e)}},Q=class extends r{async weights(e={}){return this.get(`${c}/learning/weights`,{params:e})}async outcomes(e={}){return this.get(`${c}/learning/outcomes`,{params:e})}},z=class extends r{async preview(e){return this.post(`${c}/lookalikes/preview`,e)}async create(e){return this.post(`${c}/lookalikes`,e)}async list(e={}){return this.get(`${c}/lookalikes`,{params:e})}async byId(e){return this.get(`${c}/lookalikes/${p(e)}`)}async rank(e,t={}){return this.get(`${c}/lookalikes/${p(e)}/rank`,{params:t})}},Y=class extends r{async status(){return this.get(`${c}/freshness`)}},J=class extends r{async start(e){return this.post(`${c}/audit`,e)}async byId(e){return this.get(`${c}/audit/${p(e)}`)}};import Yt from"axios";var Be=class extends r{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 s=await this.post("/infra/storage/files/upload-url",t),{uploadUrl:o,key:a}=s.data;await Yt.put(o,e,{headers:{"Content-Type":t.contentType}});let l=e.size||e.byteLength||0;return this.post("/infra/storage/files/confirm-upload",{key:a,sizeBytes:l})}};var Ke=class extends r{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 Jt={callChanged:"voice_call_changed"},Xt=["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 Zt(n){let e=n instanceof f?n.code:void 0;return e&&Xt.includes(e)?e:void 0}var jt={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 en(n){var e;return(e=jt[n])!=null?e:n}var X=encodeURIComponent,je=class extends r{get flow(){return new T(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/${X(e)}/voice-preview`)}counters(e){return this.get(`/infra/connect/voice/campaigns/${X(e)}/counters`)}approval(e){return this.get(`/infra/connect/voice/campaigns/${X(e)}/approval`)}requestApproval(e){return this.post(`/infra/connect/voice/campaigns/${X(e)}/approval/request`,{})}},Z=class extends r{constructor(t){super(t);i(this,"campaigns");this.campaigns=new je(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 s;try{return(await this.client.post("/infra/connect/voice/preview",t,{responseType:"arraybuffer"})).data}catch(o){let a=(s=o==null?void 0:o.response)==null?void 0:s.data;if(a instanceof ArrayBuffer||ArrayBuffer.isView(a))try{o.response.data=JSON.parse(new TextDecoder().decode(a))}catch(l){o.response.data=void 0}throw A(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/${X(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 ee=class extends r{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})}},te=class extends r{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"})}},ne=class extends r{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)}`)}},re=class extends r{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})}},se=class extends r{async keywords(e){return this.get(`/product/seo/ranks/${e}/keywords`)}async add(e,t,s={}){return this.post(`/product/seo/ranks/${e}/keywords`,u({queries:t},s))}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,s={}){return this.get(`/product/seo/ranks/${e}/keywords/${t}/history`,{params:s})}async changes(e){return this.get(`/product/seo/ranks/${e}/changes`)}},ie=class extends r{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})}},oe=class extends r{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`)}},ae=class extends r{async seed(e,t,s="en"){return this.post(`/product/seo/research/${e}/seed`,{seed:t,lang:s})}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 ce=class extends r{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})}},le=class extends r{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})}},ue=class extends r{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:u({projectId:e},t)})}};var tn=35e3,pe=class extends r{async claim(e,t){var o;let s=await this.post("/infra/serp/collector/claim",{collectorId:e,kinds:t},{timeout:tn});return(o=s&&typeof s=="object"?s.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",u({collectorId:e},t))}};var Ge=class extends r{async create(e){return this.post("/infra/storage/files/folders",{name:e})}},He=class extends r{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 ge=class extends r{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,s){return this.post(`/product/erix/ai/reviews/${encodeURIComponent(e)}`,u({verdict:t},s?{note:s}:{}))}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,s){return this.post(`/product/erix/ai/suggestion/${e}/send`,{text:t,confidence:s})}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,s){return this.post(`/product/flow/runs/${encodeURIComponent(e)}/approve`,u({decision:t},s&&{nodeId:s}))}};var We=class extends r{async system(){return(await this.get("/health")).data}};var Qe=class extends r{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 de=class extends r{async global(e){return this.post("/platform/tenants/onboarding/global",e)}async complete(e){return this.post("/platform/tenants/onboarding/complete",e)}};var me=class extends r{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 s=await super.get(`/platform/tenants/persona/${e}/timeline`,{params:t});return(o=s==null?void 0:s.data)!=null?o:{entries:[],hasMore:!1}}async followups(e){var s,o;let t=await super.get(`/platform/tenants/persona/${e}/followups`);return(o=(s=t==null?void 0:t.data)==null?void 0:s.entries)!=null?o:[]}};var bt=class extends r{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"}},ze=class{constructor(e){i(this,"copilot");this.copilot=new bt(e)}};var Ye=class extends r{async list(e){return this.get("/platform/tenants/audit",{params:e})}};var Je=class extends r{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 ft=class extends r{async get(){return super.get("/platform/billing/entitlements/entitlements")}async usage(){return super.get("/platform/billing/entitlements/usage")}},xt=class extends r{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)}},kt=class extends r{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)}},wt=class extends r{async listPublic(){return this.get("/platform/billing/plans/public")}},vt=class extends r{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)}},Tt=class extends r{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")}},St=class extends r{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)}},Xe=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 ft(e),this.subscriptions=new xt(e),this.plans=new wt(e),this.checkout=new vt(e),this.user=new Tt(e),this.credits=new St(e),this.addOns=new kt(e)}};var ye=class extends r{async list(){return this.get("/platform/public/catalog",{ignoreClientCode:!0})}};var nn=["application/pdf","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/plain","text/markdown","text/csv","text/html","image/png","image/jpeg","image/webp"],he=class extends r{async list(){return this.get("/platform/knowledge/sources")}async addText(e){return this.post("/platform/knowledge/sources",u({kind:"text"},e))}async addUrl(e){return this.post("/platform/knowledge/sources",u({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 s=await new P(this.client).upload(e,{folder:"knowledge"});return this.post("/platform/knowledge/sources",{kind:"file",key:s.key,mimeType:s.mimeType,title:(a=(o=t.title)!=null?o:s.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",u({query:e},t?{limit:t}:{}))}};var Ze=class extends r{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 et=class extends r{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",{})}},tt=class extends r{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)}`)}},nt=class extends r{async list(){return this.get("/platform/auth/sessions")}async revoke(e){return this.deleteRequest(`/platform/auth/sessions/${e}`)}};var rt=class{constructor(e){i(this,"messages");i(this,"conversations");this.messages=new P(e),this.conversations=new _e(e)}},st=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 Ie(e),this.pipelines=new Le(e),this.activities=new Se(e),this.analytics=new Ce(e),this.scoring=new Ee(e),this.payments=new Pe(e),this.chat=new rt(e),this.events=new $e(e),this.invoices=new Ve(e),this.checkout=new Te(e),this.projects=new De(e),this.niche=new Oe(e),this.documents=new Re(e),this.invoiceExport=new Ae(e),this.ai=new ge(e)}},it=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 $(e),this.campaigns=new T(e),this.conversations=new V(e),this.home=new O(e),this.drafts=new D(e),this.firstRun=new _(e),this.audiences=new M(e)}},ot=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 ee(e),this.audits=new te(e),this.insights=new ne(e),this.searchConsole=new re(e),this.ranks=new se(e),this.local=new ie(e),this.reports=new oe(e),this.backlinks=new ce(e),this.performance=new le(e),this.briefs=new ue(e),this.research=new ae(e)}},at=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 U(e),this.signals=new F(e),this.tools=new N(e),this.campaigns=new q(e),this.runs=new B(e),this.leads=new K(e),this.import=new j(e),this.lists=new G(e),this.compliance=new H(e),this.market=new W(e),this.learning=new Q(e),this.lookalikes=new z(e),this.freshness=new Y(e),this.audit=new J(e)}},be=class{constructor(e){i(this,"erix");i(this,"flow");i(this,"seo");i(this,"laie");this.erix=new st(e),this.flow=new it(e),this.seo=new ot(e),this.laie=new at(e)}},ct=class{constructor(e){i(this,"config");i(this,"templates");this.config=new Ne(e),this.templates=new Ue(e)}},lt=class{constructor(e){i(this,"templates");this.templates=new qe(e)}},Ct=class{constructor(e){i(this,"leadForms");this.leadForms=new Ke(e)}},ut=class{constructor(e){i(this,"email");i(this,"whatsapp");i(this,"facebook");i(this,"meet");i(this,"connections");i(this,"voice");this.email=new ct(e),this.whatsapp=new lt(e),this.facebook=new Ct(e),this.meet=new Fe(e),this.connections=new Me(e),this.voice=new Z(e)}},pt=class{constructor(e){i(this,"files");i(this,"folders");i(this,"media");this.files=new He(e),this.folders=new Ge(e),this.media=new Be(e)}},Rt=class{constructor(e){i(this,"collector");this.collector=new pe(e)}},fe=class{constructor(e){i(this,"connect");i(this,"storage");i(this,"serp");this.connect=new ut(e),this.storage=new pt(e),this.serp=new Rt(e)}},gt=class{constructor(e){i(this,"onboarding");i(this,"persona");i(this,"audit");this.onboarding=new de(e),this.persona=new me(e),this.audit=new Ye(e)}},dt=class{constructor(e){i(this,"me");i(this,"members");i(this,"sessions");i(this,"notifications");this.me=new et(e),this.members=new tt(e),this.sessions=new nt(e),this.notifications=new Qe(e)}},xe=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 Je(e),this.users=new dt(e),this.tenants=new gt(e),this.billing=new Xe(e),this.support=new Ze(e),this.ai=new ze(e),this.knowledge=new he(e),this.health=new We(e),this.catalog=new ye(e)}};var S=class extends f{constructor(e){super(e,400,"invalid_signature"),this.name="WebhookSignatureError"}},ke=class{async constructEvent(e,t,s){if(!t)throw new S("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",s).update(e).digest("hex");if(!a.timingSafeEqual(Buffer.from(d),Buffer.from(o)))throw new S("Invalid webhook signature provided");return JSON.parse(e.toString("utf8"))}catch(a){throw a instanceof S?a:new S(`Webhook payload parsing failed: ${a.message}`)}}};var At=typeof process!="undefined"&&"4.0.2"||"3.1.1";var Ht,It=(Ht=Gt.default)!=null?Ht:Gt,L=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 k,E,Pt,Lt,Et,$t,Vt,Ot;let t=e.proxy;if(!e.apiKey&&!t)throw new R("API Key is required");this.clientCode=(k=e.clientCode)==null?void 0:k.toUpperCase(),this.apiVersion=(E=e.version)!=null?E:"v1";let s=(Pt=e.baseUrl)!=null?Pt:Nt,o=qt(this.apiVersion,(Lt=t==null?void 0:t.url)!=null?Lt:s),a=e.socketUrl||s,l=typeof window!="undefined"&&typeof window.document!="undefined",d=l?"browser":typeof process!="undefined"?`node ${process.version}`:"unknown",g=l?((Et=globalThis.navigator)==null?void 0:Et.userAgent)||"browser":typeof process!="undefined"?process.platform:"unknown",C=v(u({},t?{}:{"x-api-key":e.apiKey,"x-client-code":(($t=e.clientCode)==null?void 0:$t.toUpperCase())||""}),{"Content-Type":"application/json","x-ecodrix-client-agent":JSON.stringify({sdk_version:At,runtime:d,os:g})});if(this.client=sn.create({baseURL:o,headers:C,timeout:(Vt=e.timeout)!=null?Vt:3e4}),It(this.client,{retries:3,retryDelay:It.exponentialDelay,retryCondition:b=>{var we;return It.isNetworkOrIdempotentRequestError(b)||((we=b.response)==null?void 0:we.status)===429},onRetry:(b,we,Dt)=>{var _t,Mt;typeof process!="undefined"&&((_t=process.env)==null?void 0:_t.NODE_ENV)==="development"&&console.warn(`[ECODrIx SDK] Retrying request (${b}/3): ${(Mt=Dt.method)==null?void 0:Mt.toUpperCase()} ${Dt.url}. Reason: ${we.message}`)}}),this.platform=new xe(this.client),this.product=new be(this.client),this.infra=new fe(this.client),this.webhooks=new ke,t){if(t.ticket){let b=t.ticket;this.startSocket=()=>this.initSocket(a,async()=>({ticket:await b()}))}}else{let b={apiKey:e.apiKey,clientCode:((Ot=e.clientCode)==null?void 0:Ot.toUpperCase())||""};this.startSocket=()=>this.initSocket(a,async()=>b,{"x-api-key":b.apiKey,"x-client-code":b.clientCode})}if(l){let b={version:At,clientCode:e.clientCode,initializedAt:new Date().toISOString()};window.__ECODRIX_SDK__=b}}initSocket(e,t,s){return this.socketPromise?this.socketPromise:(this.socketPromise=import("socket.io-client").then(({io:o})=>{this.socket=o(e,{auth:a=>{t().then(l=>a(v(u({},l),{lastSeq:this.lastSeq})),()=>a({lastSeq:this.lastSeq}))},extraHeaders:s}),this.setupSocket();for(let{type:a,args:l}of this.socketQueue)a==="joinRoom"?this.socket.emit("join-room",l[0]):a==="leaveRoom"?this.socket.emit("leave-room",l[0]):a==="on"?this.socket.on(l[0],l[1]):a==="off"?this.socket.off(l[0],l[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 s,o;let t=(s=e.at(-1))==null?void 0:s.seq;typeof t=="number"&&t>((o=this.lastSeq)!=null?o:0)&&(this.lastSeq=t)}))}on(e,t){var s;return this.closed||(s=this.startSocket)==null||s.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,s,o){var a,l,d;try{return(await this.client.request({method:e,url:t,data:s,params:o})).data}catch(g){throw g.response?new f(((a=g.response.data)==null?void 0:a.message)||((l=g.response.data)==null?void 0:l.error)||"Raw Execution Failed",g.response.status,(d=g.response.data)==null?void 0:d.code):new f(g.message||"Network Error")}}};var fi={401:R,403:Bt,429:ve};function xi(n){throw A(n)}function ki(n,e){return n instanceof e}function wi(n){return n instanceof R?{message:n.message,status:n.status,code:n.code,type:"AuthenticationError"}:n instanceof ve?{message:n.message,status:n.status,code:n.code,type:"RateLimitError"}:n instanceof f?{message:n.message,status:n.status,code:n.code,type:"APIError"}:{message:n.message||"Unknown error",type:"UnknownError"}}var Wt={[R.name]:{shouldRetry:!1,reason:"Authentication errors require fixing credentials, not retrying"},[ve.name]:{shouldRetry:!0,maxRetries:3,baseDelay:1e3,backoffMultiplier:2,reason:"Rate limit errors can be retried with exponential backoff"},[f.name]:{shouldRetry:!0,maxRetries:2,baseDelay:500,backoffMultiplier:1.5,reason:"Generic API errors may be transient and worth retrying"}};function vi(n){let e=n.constructor.name;return Wt[e]||Wt[f.name]}var Ci=L;export{f as APIError,r as APIResource,ge as AiAgent,R as AuthenticationError,T as Campaigns,ye as Catalog,pe as Collector,ut as ConnectInfra,L as ECODrIx,L as ECODrIxAPI,Wt as ERROR_RETRY_CONFIG,an as EcodrixError,ct as EmailConnect,rt as ErixChat,st as ErixProduct,M as FlowAudiences,$ as FlowAutomations,V as FlowConversations,D as FlowDrafts,_ as FlowFirstRunResource,O as FlowHome,it as FlowProduct,fi as HTTP_STATUS_ERROR_MAP,fe as InfraDomain,nn as KNOWLEDGE_FILE_TYPES,he as Knowledge,zt as LAIE_EVENTS,Kt as LEAD_STATUS_VALUES,J as LaieAudits,q as LaieCampaigns,H as LaieCompliance,Y as LaieFreshness,j as LaieImport,K as LaieLeads,Q as LaieLearning,G as LaieLists,z as LaieLookalikes,W as LaieMarket,U as LaiePacks,at as LaieProduct,B as LaieRuns,F as LaieSignals,N as LaieTools,de as Onboarding,Bt as PermissionError,me as Persona,xe as PlatformDomain,gt as PlatformTenants,dt as PlatformUsers,be as ProductDomain,ve as RateLimitError,te as SeoAudits,ce as SeoBacklinks,ue as SeoBriefs,ne as SeoInsights,ie as SeoLocal,le as SeoPerformance,ot as SeoProduct,ee as SeoProjects,se as SeoRanks,oe as SeoReports,ae as SeoResearch,re as SeoSearchConsole,pt as StorageInfra,Jt as VOICE_EVENTS,jt as VOICE_REFUSAL_REASONS,Z as Voice,je as VoiceCampaigns,S as WebhookSignatureError,ke as Webhooks,lt as WhatsAppConnect,Ci as default,wi as getErrorDetails,vi as getRetryConfig,xi as handleAPIError,ki as isAPIError,Qt as laieStageQueued,A as toAPIError,Zt as voiceErrorCode,en as voiceRefusalReason};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecodrix/erix-api",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "author": "ECODrIx Team <contact@ecodrix.com>",
5
5
  "license": "MIT",
6
6
  "description": "Official TypeScript SDK for the ERIX API by ECODrIx: CRM, Flow automations, one inbox across WhatsApp, Instagram and email, GST invoices and payments. Node and browser (proxy mode).",