@getnexorai/sdk 0.1.1 → 0.1.3
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.
- package/README.md +15 -0
- package/dist/chat.cjs +1630 -108
- package/dist/chat.cjs.map +1 -1
- package/dist/chat.d.cts +2 -2
- package/dist/chat.d.ts +2 -2
- package/dist/chat.js +1 -1
- package/dist/chunk-WUUXZIQN.js +2483 -0
- package/dist/chunk-WUUXZIQN.js.map +1 -0
- package/dist/{config-eTstZgSV.d.cts → config-C39P5Aax.d.cts} +207 -4
- package/dist/{config-eTstZgSV.d.ts → config-C39P5Aax.d.ts} +207 -4
- package/dist/index.cjs +1677 -114
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +47 -6
- package/dist/index.js.map +1 -1
- package/dist/nexor.iife.js +490 -24
- package/dist/nexor.iife.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-YDWD2Q5S.js +0 -961
- package/dist/chunk-YDWD2Q5S.js.map +0 -1
package/dist/nexor.iife.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Nexor=(function(exports){'use strict';var P=class extends Error{constructor(t){super(t),this.name="NexorError";}},w=class extends P{constructor(t){var n;super(t.message),this.name="NexorAPIError",this.status=t.status,this.code=(n=t.code)!=null?n:we(t.status),this.body=t.body,this.requestId=t.requestId;}},S=class extends w{constructor(t){super({status:401,code:"unauthorized",...t}),this.name="NexorAuthError";}},O=class extends w{constructor(t){super({status:400,code:"validation_error",...t}),this.name="NexorValidationError";}},M=class extends P{constructor(t,n){super(t),this.name="NexorNetworkError",this.cause=n;}};function we(e){return e===400?"validation_error":e===401?"unauthorized":e===403?"forbidden":e===404?"not_found":e===409?"conflict":e===422?"unprocessable_entity":e===429?"rate_limited":e>=500?"server_error":"http_error"}var Ce="https://api.getnexor.ai",ve=3e4,Le=2,Te="0.1.0";function oe(e){var r,o,c,l;if(!e||typeof e.apiKey!="string"||e.apiKey.trim()==="")throw new Error("Nexor SDK: `apiKey` is required. Get one in the dashboard at https://app.getnexor.ai");let t=(r=e.fetch)!=null?r:typeof globalThis!="undefined"&&typeof globalThis.fetch=="function"?globalThis.fetch.bind(globalThis):void 0;if(!t)throw new Error("Nexor SDK: no global fetch found. Pass a `fetch` implementation via init() or upgrade to Node 18+.");let n=`nexor-sdk-js/${Te}${e.userAgentSuffix?` ${e.userAgentSuffix}`:""}`;return {apiKey:e.apiKey.trim(),baseUrl:Me((o=e.baseUrl)!=null?o:Ce),timeoutMs:(c=e.timeoutMs)!=null?c:ve,maxRetries:(l=e.maxRetries)!=null?l:Le,fetchImpl:t,userAgent:n}}async function g(e,t){var i,a,y,f,C,I,R;let n=Ne(e.baseUrl,t.path,t.query),r={"X-API-Key":e.apiKey,Accept:"application/json","User-Agent":e.userAgent};(i=t.options)!=null&&i.idempotencyKey&&(r["Idempotency-Key"]=t.options.idempotencyKey);let o;t.body!==void 0&&(r["Content-Type"]="application/json",o=JSON.stringify(t.body));let c=(y=(a=t.options)==null?void 0:a.timeoutMs)!=null?y:e.timeoutMs,l;for(let d=0;d<=e.maxRetries;d++){let v=new AbortController,h=(f=t.options)==null?void 0:f.signal,L=()=>v.abort();h&&(h.aborted?v.abort():h.addEventListener("abort",L));let k=setTimeout(()=>v.abort(),c);try{let u=await e.fetchImpl(n,{method:t.method,headers:r,body:o,signal:v.signal});clearTimeout(k),h==null||h.removeEventListener("abort",L);let T=(C=u.headers.get("x-request-id"))!=null?C:void 0;if(u.ok){if(u.status===204)return;let E=await u.text();if(!E)return;try{return JSON.parse(E)}catch(Y){throw new w({status:u.status,message:"Failed to parse JSON response",body:E,requestId:T})}}let A=await Re(u),K=(I=Ee(A))!=null?I:`HTTP ${u.status}`,U=Ie(u.status,K,A,T);if(ke(u.status)&&d<e.maxRetries){await re(ne(d,u)),l=U;continue}throw U}catch(u){if(clearTimeout(k),h==null||h.removeEventListener("abort",L),u instanceof w)throw u;let T=u instanceof Error&&(u.name==="AbortError"||/abort/i.test(u.message));if(T&&(h!=null&&h.aborted))throw u;if(l=u,d<e.maxRetries){await re(ne(d));continue}throw new M(T?`Request timed out after ${c}ms`:`Network error: ${(R=u==null?void 0:u.message)!=null?R:String(u)}`,u)}}throw l!=null?l:new M("Request failed")}function Ie(e,t,n,r){return e===401||e===403?new S({message:t,body:n,requestId:r}):e===400||e===422?new O({message:t,body:n,requestId:r}):new w({status:e,message:t,body:n,requestId:r})}function Ee(e){if(!e||typeof e!="object")return;let t=e;if(typeof t.message=="string")return t.message;if(typeof t.error=="string")return t.error}async function Re(e){try{let t=await e.text();if(!t)return null;try{return JSON.parse(t)}catch(n){return t}}catch(t){return null}}function ke(e){return e===429||e>=500&&e<=599}function ne(e,t){if(t){let r=t.headers.get("retry-after");if(r){let o=Number(r);if(!Number.isNaN(o)&&o>0)return Math.min(o*1e3,1e4)}}return 300*2**e+Math.floor(Math.random()*200)}function re(e){return new Promise(t=>setTimeout(t,e))}function Me(e){return e.endsWith("/")?e.slice(0,-1):e}function Ne(e,t,n){let r=t.startsWith("/")?t:`/${t}`,o=Pe(n);return `${e}${r}${o?`?${o}`:""}`}function Pe(e){if(!e)return "";let t=[];for(let[n,r]of Object.entries(e))if(r!=null)if(Array.isArray(r)){if(r.length===0)continue;t.push(`${encodeURIComponent(n)}=${encodeURIComponent(r.join(","))}`);}else t.push(`${encodeURIComponent(n)}=${encodeURIComponent(String(r))}`);return t.join("&")}var b="/api/public",N=class{constructor(t){this.cfg=oe(t);}createLead(t,n){return g(this.cfg,{method:"POST",path:`${b}/leads`,body:t,options:n})}createLeadsBulk(t,n){return g(this.cfg,{method:"POST",path:`${b}/leads`,body:t,options:n})}updateLead(t,n,r){return g(this.cfg,{method:"PUT",path:`${b}/leads/${encodeURIComponent(t)}`,body:n,options:r})}getLead(t,n){return g(this.cfg,{method:"GET",path:`${b}/leads/${encodeURIComponent(t)}`,options:n})}getLeadHistory(t,n={},r){let o=Array.isArray(n.channel)?n.channel:n.channel?[n.channel]:void 0;return g(this.cfg,{method:"GET",path:`${b}/leads/${encodeURIComponent(t)}/history`,query:{channel:o,limit:n.limit,offset:n.offset},options:r})}isLeadPaused(t,n={},r){return g(this.cfg,{method:"GET",path:`${b}/leads/${encodeURIComponent(t)}/is_paused`,query:{workflow_id:n.workflow_id},options:r})}stopAutomation(t,n,r){return g(this.cfg,{method:"POST",path:`${b}/leads/${encodeURIComponent(t)}/automation/stop`,body:n,options:r})}resumeAutomation(t,n,r){return g(this.cfg,{method:"POST",path:`${b}/leads/${encodeURIComponent(t)}/automation/resume`,body:n,options:r})}syncLeadTags(t,n){return g(this.cfg,{method:"POST",path:`${b}/leads/tags`,body:t,options:n})}listLeadMeetings(t,n={},r){let o=Array.isArray(n.status)?n.status.join(","):n.status;return g(this.cfg,{method:"GET",path:`${b}/leads/${encodeURIComponent(t)}/meetings`,query:{status:o},options:r})}listWorkflows(t){return g(this.cfg,{method:"GET",path:`${b}/workflows`,options:t})}listCampaigns(t){return g(this.cfg,{method:"GET",path:`${b}/campaigns`,options:t})}listTemplates(t={},n){return g(this.cfg,{method:"GET",path:`${b}/templates`,query:{status:t.status,category:t.category},options:n})}sendMessage(t,n){return g(this.cfg,{method:"POST",path:`${b}/messages`,body:t,options:n})}createMeeting(t,n){return g(this.cfg,{method:"POST",path:`${b}/meetings`,body:t,options:n})}createMeetingNotes(t,n){return g(this.cfg,{method:"POST",path:`${b}/meeting-notes`,body:t,options:n})}chat(t,n){return g(this.cfg,{method:"POST",path:`${b}/chat`,body:t,options:n})}};function se(e){var t,n,r,o,c,l,i,a,y,f,C,I,R,d,v,h,L,k,u;return {workflowId:e.workflowId,title:(t=e.title)!=null?t:"Chat with us",subtitle:(n=e.subtitle)!=null?n:"We typically reply in a few minutes",greeting:(r=e.greeting)!=null?r:"Hi there! \u{1F44B} How can we help?",errorText:(o=e.errorText)!=null?o:"Sorry, something went wrong. Please try again in a moment.",locale:(c=e.locale)!=null?c:typeof navigator!="undefined"?navigator.language:void 0,accentColor:(l=e.accentColor)!=null?l:"#111827",accentTextColor:(i=e.accentTextColor)!=null?i:"#ffffff",showBranding:(a=e.showBranding)!=null?a:true,position:(y=e.position)!=null?y:"bottom-right",openOnLoad:(f=e.openOnLoad)!=null?f:false,debounceMs:(C=e.debounceMs)!=null?C:700,container:e.container,systemPrompt:e.systemPrompt,clientPrompt:e.clientPrompt,lead:e.lead,capture:{fields:(R=(I=e.capture)==null?void 0:I.fields)!=null?R:["first_name","email"],mode:(v=(d=e.capture)==null?void 0:d.mode)!=null?v:"before",label:(L=(h=e.capture)==null?void 0:h.label)!=null?L:"Tell us a bit about you to get started:",submitLabel:(u=(k=e.capture)==null?void 0:k.submitLabel)!=null?u:"Start chat"},metadata:e.metadata,onOpen:e.onOpen,onClose:e.onClose,onMessage:e.onMessage,onLeadCaptured:e.onLeadCaptured,onError:e.onError}}function F(e){if(e.capture.mode==="skip")return false;if(e.lead){let t=e.lead;return e.capture.fields.some(n=>!t[n])}return true}var ie="nexor.chat.session_id";function ae(){let e=Date.now();try{let n=le();if(n&&e-n.ts<2592e6)return j(n.id,e),n.id}catch(n){}let t=`sess_${Se(16)}`;try{j(t,e);}catch(n){}return t}function de(){try{let e=le();e&&j(e.id,Date.now());}catch(e){}}function le(){let e=window.localStorage.getItem(ie);if(!e)return null;try{let t=JSON.parse(e);if(t&&typeof t.id=="string"&&typeof t.ts=="number")return t}catch(t){}return e.startsWith("sess_")?{id:e,ts:Date.now()}:null}function j(e,t){window.localStorage.setItem(ie,JSON.stringify({id:e,ts:t}));}function Se(e){let t=new Uint8Array(e);if(typeof crypto!="undefined"&&crypto.getRandomValues)crypto.getRandomValues(t);else for(let n=0;n<e;n++)t[n]=Math.floor(Math.random()*256);return Array.from(t,n=>n.toString(16).padStart(2,"0")).join("")}var ce=(e,t)=>`
|
|
1
|
+
var Nexor=(function(exports){'use strict';var te=class extends Error{constructor(n){super(n),this.name="NexorError";}},U=class extends te{constructor(n){var t;super(n.message),this.name="NexorAPIError",this.status=n.status,this.code=(t=n.code)!=null?t:Ht(n.status),this.body=n.body,this.requestId=n.requestId;}},ne=class extends U{constructor(n){super({status:401,code:"unauthorized",...n}),this.name="NexorAuthError";}},re=class extends U{constructor(n){super({status:400,code:"validation_error",...n}),this.name="NexorValidationError";}},X=class extends te{constructor(n,t){super(n),this.name="NexorNetworkError",this.cause=t;}};function Ht(e){return e===400?"validation_error":e===401?"unauthorized":e===403?"forbidden":e===404?"not_found":e===409?"conflict":e===422?"unprocessable_entity":e===429?"rate_limited":e>=500?"server_error":"http_error"}var Pt="https://api.getnexor.ai",At=3e4,Ot=2,qt="0.1.0";function rt(e){var i,l,u,c;if(!e||typeof e.apiKey!="string"||e.apiKey.trim()==="")throw new Error("Nexor SDK: `apiKey` is required. Get one in the dashboard at https://app.getnexor.ai");let n=(i=e.fetch)!=null?i:typeof globalThis!="undefined"&&typeof globalThis.fetch=="function"?globalThis.fetch.bind(globalThis):void 0;if(!n)throw new Error("Nexor SDK: no global fetch found. Pass a `fetch` implementation via init() or upgrade to Node 18+.");let t=`nexor-sdk-js/${qt}${e.userAgentSuffix?` ${e.userAgentSuffix}`:""}`;return {apiKey:e.apiKey.trim(),baseUrl:Ft((l=e.baseUrl)!=null?l:Pt),timeoutMs:(u=e.timeoutMs)!=null?u:At,maxRetries:(c=e.maxRetries)!=null?c:Ot,fetchImpl:n,userAgent:t}}async function E(e,n){var m,a,x,p,f,I,L,H,M;let t=Kt(e.baseUrl,n.path,n.query),i={"X-API-Key":e.apiKey,Accept:"application/json","User-Agent":e.userAgent};(m=n.options)!=null&&m.idempotencyKey&&(i["Idempotency-Key"]=n.options.idempotencyKey);let l;n.body!==void 0&&(i["Content-Type"]="application/json",l=JSON.stringify(n.body));let u=(x=(a=n.options)==null?void 0:a.timeoutMs)!=null?x:e.timeoutMs,c=(f=(p=n.options)==null?void 0:p.maxRetries)!=null?f:e.maxRetries,o;for(let N=0;N<=c;N++){let S=new AbortController,b=(I=n.options)==null?void 0:I.signal,P=()=>S.abort();b&&(b.aborted?S.abort():b.addEventListener("abort",P));let q=setTimeout(()=>S.abort(),u);try{let w=await e.fetchImpl(t,{method:n.method,headers:i,body:l,signal:S.signal});clearTimeout(q),b==null||b.removeEventListener("abort",P);let O=(L=w.headers.get("x-request-id"))!=null?L:void 0;if(w.ok){if(w.status===204)return;let F=await w.text();if(!F)return;try{return JSON.parse(F)}catch(K){throw new U({status:w.status,message:"Failed to parse JSON response",body:F,requestId:O})}}let j=await Ut(w),Q=(H=Bt(j))!=null?H:`HTTP ${w.status}`,$=Dt(w.status,Q,j,O);if($t(w.status)&&N<c){await nt(tt(N,w)),o=$;continue}throw $}catch(w){if(clearTimeout(q),b==null||b.removeEventListener("abort",P),w instanceof U)throw w;let O=w instanceof Error&&(w.name==="AbortError"||/abort/i.test(w.message));if(O&&(b!=null&&b.aborted))throw w;if(o=w,N<c){await nt(tt(N));continue}throw new X(O?`Request timed out after ${u}ms`:`Network error: ${(M=w==null?void 0:w.message)!=null?M:String(w)}`,w)}}throw o!=null?o:new X("Request failed")}function Dt(e,n,t,i){return e===401||e===403?new ne({message:n,body:t,requestId:i}):e===400||e===422?new re({message:n,body:t,requestId:i}):new U({status:e,message:n,body:t,requestId:i})}function Bt(e){if(!e||typeof e!="object")return;let n=e;if(typeof n.message=="string")return n.message;if(typeof n.error=="string")return n.error}async function Ut(e){try{let n=await e.text();if(!n)return null;try{return JSON.parse(n)}catch(t){return n}}catch(n){return null}}function $t(e){return e===429||e>=500&&e<=599}function tt(e,n){if(n){let i=n.headers.get("retry-after");if(i){let l=Number(i);if(!Number.isNaN(l)&&l>0)return Math.min(l*1e3,1e4)}}return 300*2**e+Math.floor(Math.random()*200)}function nt(e){return new Promise(n=>setTimeout(n,e))}function Ft(e){return e.endsWith("/")?e.slice(0,-1):e}function Kt(e,n,t){let i=n.startsWith("/")?n:`/${n}`,l=zt(t);return `${e}${i}${l?`?${l}`:""}`}function zt(e){if(!e)return "";let n=[];for(let[t,i]of Object.entries(e))if(i!=null)if(Array.isArray(i)){if(i.length===0)continue;n.push(`${encodeURIComponent(t)}=${encodeURIComponent(i.join(","))}`);}else n.push(`${encodeURIComponent(t)}=${encodeURIComponent(String(i))}`);return n.join("&")}var R="/api/public",Z=class{constructor(n){this.cfg=rt(n);}createLead(n,t){return E(this.cfg,{method:"POST",path:`${R}/leads`,body:{...n,skip_first_message:true},options:t})}createLeadsBulk(n,t){return E(this.cfg,{method:"POST",path:`${R}/leads`,body:n.map(i=>({...i,skip_first_message:true})),options:t})}updateLead(n,t,i){return E(this.cfg,{method:"PUT",path:`${R}/leads/${encodeURIComponent(n)}`,body:t,options:i})}getLead(n,t){return E(this.cfg,{method:"GET",path:`${R}/leads/${encodeURIComponent(n)}`,options:t})}getLeadHistory(n,t={},i){let l=Array.isArray(t.channel)?t.channel:t.channel?[t.channel]:void 0;return E(this.cfg,{method:"GET",path:`${R}/leads/${encodeURIComponent(n)}/history`,query:{channel:l,limit:t.limit,offset:t.offset},options:i})}isLeadPaused(n,t={},i){return E(this.cfg,{method:"GET",path:`${R}/leads/${encodeURIComponent(n)}/is_paused`,query:{workflow_id:t.workflow_id},options:i})}stopAutomation(n,t,i){return E(this.cfg,{method:"POST",path:`${R}/leads/${encodeURIComponent(n)}/automation/stop`,body:t,options:i})}resumeAutomation(n,t,i){return E(this.cfg,{method:"POST",path:`${R}/leads/${encodeURIComponent(n)}/automation/resume`,body:t,options:i})}syncLeadTags(n,t){return E(this.cfg,{method:"POST",path:`${R}/leads/tags`,body:n,options:t})}listLeadMeetings(n,t={},i){let l=Array.isArray(t.status)?t.status.join(","):t.status;return E(this.cfg,{method:"GET",path:`${R}/leads/${encodeURIComponent(n)}/meetings`,query:{status:l},options:i})}listWorkflows(n){return E(this.cfg,{method:"GET",path:`${R}/workflows`,options:n})}listCampaigns(n){return E(this.cfg,{method:"GET",path:`${R}/campaigns`,options:n})}listTemplates(n={},t){return E(this.cfg,{method:"GET",path:`${R}/templates`,query:{status:n.status,category:n.category},options:t})}sendMessage(n,t){return E(this.cfg,{method:"POST",path:`${R}/messages`,body:n,options:t})}createMeeting(n,t){return E(this.cfg,{method:"POST",path:`${R}/meetings`,body:n,options:t})}createMeetingNotes(n,t){return E(this.cfg,{method:"POST",path:`${R}/meeting-notes`,body:n,options:t})}getChatConfig(n,t){return E(this.cfg,{method:"GET",path:`${R}/chat/config`,query:{workflow_id:n},options:t})}chat(n,t){return E(this.cfg,{method:"POST",path:`${R}/chat`,body:n,options:t})}requestContact(n,t){return E(this.cfg,{method:"POST",path:`${R}/leads`,body:n,options:t})}};function at(e){var n,t,i,l,u,c,o,m,a,x,p,f,I,L,H,M,N,S,b,P,q,w,O,j,Q,$,F,K,ie,ge,xe,be,Ce,V,le,G,D,_e,ye,ce,de,we,ue,pe,he,ve,ee;return {workflowId:e.workflowId,title:(n=e.title)!=null?n:"Chat with us",subtitle:(t=e.subtitle)!=null?t:"We typically reply in a few minutes",openingMessage:e.openingMessage,greeting:(i=e.greeting)!=null?i:"Hi there! \u{1F44B} How can we help?",errorText:(l=e.errorText)!=null?l:"Sorry, something went wrong. Please try again in a moment.",disabledText:(u=e.disabledText)!=null?u:"Chat isn't available right now. Please reach us on another channel.",locale:(c=e.locale)!=null?c:typeof navigator!="undefined"?navigator.language:void 0,accentColor:(o=e.accentColor)!=null?o:"#111827",accentTextColor:(m=e.accentTextColor)!=null?m:"#ffffff",showBranding:(a=e.showBranding)!=null?a:true,inputPlaceholder:(x=e.inputPlaceholder)!=null?x:"Type a message\u2026",showRestart:(p=e.showRestart)!=null?p:true,restartLabel:(f=e.restartLabel)!=null?f:"Start over",position:(I=e.position)!=null?I:"bottom-right",openOnLoad:(L=e.openOnLoad)!=null?L:false,channels:Vt(e.channels),requestContact:Jt((H=e.channels)==null?void 0:H.requestContact),debounceMs:(M=e.debounceMs)!=null?M:700,splitReplies:(N=e.splitReplies)!=null?N:true,splitDelayMs:(S=e.splitDelayMs)!=null?S:0,requestTimeoutMs:(b=e.requestTimeoutMs)!=null?b:6e4,container:e.container,systemPrompt:e.systemPrompt,clientPrompt:e.clientPrompt,lead:e.lead,capture:{fields:(q=(P=e.capture)==null?void 0:P.fields)!=null?q:["first_name","email"],mode:(O=(w=e.capture)==null?void 0:w.mode)!=null?O:"before",createLeadOnSubmit:(Q=(j=e.capture)==null?void 0:j.createLeadOnSubmit)!=null?Q:false,label:(F=($=e.capture)==null?void 0:$.label)!=null?F:"Tell us a bit about you to get started:",submitLabel:(ie=(K=e.capture)==null?void 0:K.submitLabel)!=null?ie:"Start chat",placeholders:(xe=(ge=e.capture)==null?void 0:ge.placeholders)!=null?xe:{},phoneCountryCode:(Ce=(be=e.capture)==null?void 0:be.phoneCountryCode)!=null?Ce:"",phoneCountries:(le=(V=e.capture)==null?void 0:V.phoneCountries)!=null?le:[],errorMessages:{required:(_e=(D=(G=e.capture)==null?void 0:G.errorMessages)==null?void 0:D.required)!=null?_e:"Please complete this field.",email:(de=(ce=(ye=e.capture)==null?void 0:ye.errorMessages)==null?void 0:ce.email)!=null?de:"Enter a valid email address.",phone:(pe=(ue=(we=e.capture)==null?void 0:we.errorMessages)==null?void 0:ue.phone)!=null?pe:"Enter a valid phone number, including the country code."}},metadata:e.metadata,resumeText:(he=e.resumeText)!=null?he:"Continuing your conversation",resumeWithNameText:(ve=e.resumeWithNameText)!=null?ve:"Continuing as {name}",startOverText:(ee=e.startOverText)!=null?ee:"Start over",onOpen:e.onOpen,onClose:e.onClose,onMessage:e.onMessage,onLeadCaptured:e.onLeadCaptured,onError:e.onError}}var Wt=["whatsapp","call","email","instagram","chat"],jt={whatsapp:"WhatsApp",call:"Call",email:"Email",instagram:"Instagram",chat:"Chat"};function Vt(e){var o,m;if(!e)return [];let n=(o=e.order)!=null?o:Wt,t=a=>{var x,p;return (p=(x=e.labels)==null?void 0:x[a])!=null?p:jt[a]},i=new Set(e.requestContact?(m=e.requestContact.channels)!=null?m:["call","email"]:[]),l=a=>({key:a,href:null,external:false,action:"contact",label:t(a)}),u=new Set,c=[];for(let a of n)if(!u.has(a))switch(u.add(a),a){case "whatsapp":{if(i.has("whatsapp")){c.push(l(a));break}if(!e.whatsapp)break;let x=e.whatsapp.replace(/[^\d]/g,"");if(!x)break;let p=e.whatsappText?`?text=${encodeURIComponent(e.whatsappText)}`:"";c.push({key:a,href:`https://wa.me/${x}${p}`,external:true,label:t(a)});break}case "call":{if(i.has("call")){c.push(l(a));break}if(!e.call)break;let x=e.call.replace(/[^\d+]/g,"");if(!x)break;c.push({key:a,href:`tel:${x}`,external:false,label:t(a)});break}case "email":{if(i.has("email")){c.push(l(a));break}if(!e.email)break;c.push({key:a,href:`mailto:${e.email}`,external:false,label:t(a)});break}case "instagram":{if(!e.instagram)break;let x=/^https?:\/\//i.test(e.instagram)?e.instagram:`https://instagram.com/${e.instagram.replace(/^@/,"")}`;c.push({key:a,href:x,external:true,label:t(a)});break}case "chat":{if(e.chat===false)break;c.push({key:a,href:null,external:false,label:t(a)});break}}return c.every(a=>a.key==="chat")?[]:c}var Gt={call:"Request a call",email:"Request an email",whatsapp:"Request a message"},Yt={call:"Leave your details and we'll call you. We need this to reach you.",email:"Leave your details and we'll email you. We need this to reach you.",whatsapp:"Leave your details and we'll message you. We need this to reach you."},Xt={call:"Request call",email:"Request email",whatsapp:"Request message"},Zt={call:"Thanks! We'll call you shortly.",email:"Thanks! We'll email you shortly.",whatsapp:"Thanks! We'll message you shortly."};function Jt(e){var i,l;if(!e)return;let n=e.channels&&e.channels.length?e.channels:["call","email"],t=(u,c)=>{var m;let o={};for(let a of n)o[a]=(m=u==null?void 0:u[a])!=null?m:c[a];return o};return {channels:n,title:t(e.title,Gt),subtitle:t(e.subtitle,Yt),submitLabel:t(e.submitLabel,Xt),successText:t(e.successText,Zt),doneLabel:(i=e.doneLabel)!=null?i:"Done",errorText:(l=e.errorText)!=null?l:"Something went wrong. Please try again."}}function ke(e){if(e.capture.mode==="skip")return false;if(e.lead){let n=e.lead;return e.capture.fields.some(t=>!n[t])}return true}var ot="nexor.chat.session_id";function st(){let e=Date.now();try{let t=lt();if(t&&e-t.ts<2592e6)return Ae(t.id,e),t.id}catch(t){}let n=`sess_${Qt(16)}`;try{Ae(n,e);}catch(t){}return n}function it(){try{let e=lt();e&&Ae(e.id,Date.now());}catch(e){}}function lt(){let e=window.localStorage.getItem(ot);if(!e)return null;try{let n=JSON.parse(e);if(n&&typeof n.id=="string"&&typeof n.ts=="number")return n}catch(n){}return e.startsWith("sess_")?{id:e,ts:Date.now()}:null}function Ae(e,n){window.localStorage.setItem(ot,JSON.stringify({id:e,ts:n}));}function Qt(e){let n=new Uint8Array(e);if(typeof crypto!="undefined"&&crypto.getRandomValues)crypto.getRandomValues(n);else for(let t=0;t<e;t++)n[t]=Math.floor(Math.random()*256);return Array.from(n,t=>t.toString(16).padStart(2,"0")).join("")}function Oe(e){let n=(e||"").trim();return n.length<6||n.length>254?false:/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(n)}var en={first_name:"first_name",name:"first_name",lead_first_name:"first_name",last_name:"last_name",lastname:"last_name",lead_last_name:"last_name",full_name:"full_name",fullname:"full_name",email:"email",phone:"phone"};function ae(e){return e==null?"":String(e).trim()}function tn(e,n){if(!e)return "";switch(n){case "first_name":return ae(e.first_name);case "last_name":return ae(e.last_name);case "full_name":return [ae(e.first_name),ae(e.last_name)].filter(Boolean).join(" ");case "email":return ae(e.email);case "phone":return ae(e.phone);default:return ""}}function ct(e,n){return typeof e!="string"||!e?"":e.replace(/\{\{\s*([a-zA-Z_]+)\s*\}\}/g,(i,l)=>{let u=en[l.toLowerCase()];return u?tn(n,u):i}).replace(/[ \t]+([,.!?;:])/g,"$1").replace(/[ \t]{2,}/g," ").replace(/^[ \t]*[,;:][ \t]*/gm,"").replace(/[ \t]+$/gm,"").trim()}var dt={iso:"CL",name:"Chile",dial:"+56",flag:"\u{1F1E8}\u{1F1F1}",nsn:[9,9]},me=[dt,{iso:"MX",name:"M\xE9xico",dial:"+52",flag:"\u{1F1F2}\u{1F1FD}",nsn:[10,10]},{iso:"AR",name:"Argentina",dial:"+54",flag:"\u{1F1E6}\u{1F1F7}",nsn:[10,11]},{iso:"CO",name:"Colombia",dial:"+57",flag:"\u{1F1E8}\u{1F1F4}",nsn:[10,10]},{iso:"PE",name:"Per\xFA",dial:"+51",flag:"\u{1F1F5}\u{1F1EA}",nsn:[9,9]},{iso:"BR",name:"Brasil",dial:"+55",flag:"\u{1F1E7}\u{1F1F7}",nsn:[10,11]},{iso:"EC",name:"Ecuador",dial:"+593",flag:"\u{1F1EA}\u{1F1E8}",nsn:[8,9]},{iso:"UY",name:"Uruguay",dial:"+598",flag:"\u{1F1FA}\u{1F1FE}",nsn:[8,8]},{iso:"US",name:"United States",dial:"+1",flag:"\u{1F1FA}\u{1F1F8}",nsn:[10,10]},{iso:"ES",name:"Espa\xF1a",dial:"+34",flag:"\u{1F1EA}\u{1F1F8}",nsn:[9,9]},{iso:"GB",name:"United Kingdom",dial:"+44",flag:"\u{1F1EC}\u{1F1E7}",nsn:[10,10]}];function W(e){return e.nsn[1]}function J(e){if(!e)return;let n=e.toUpperCase();return me.find(t=>t.iso===n)}function nn(e){if(!e)return;let n=e.startsWith("+")?e:`+${e.replace(/^\+?/,"")}`;return me.find(t=>t.dial===n)}function fe(e){let n=(e||"").trim();return nn(n)||J(n)||dt}var ut=(e,n)=>`
|
|
2
2
|
.nexor-chat,
|
|
3
3
|
.nexor-chat * {
|
|
4
4
|
box-sizing: border-box;
|
|
@@ -20,13 +20,19 @@ var Nexor=(function(exports){'use strict';var P=class extends Error{constructor(
|
|
|
20
20
|
left: 20px;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
/* \u2500\u2500 Launcher wrapper (anchors the optional speed-dial fan) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
24
|
+
.nexor-chat__launcher-wrap {
|
|
25
|
+
position: relative;
|
|
26
|
+
display: inline-flex;
|
|
27
|
+
}
|
|
28
|
+
|
|
23
29
|
/* \u2500\u2500 Launcher bubble \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
24
30
|
.nexor-chat__launcher {
|
|
25
31
|
width: 56px;
|
|
26
32
|
height: 56px;
|
|
27
33
|
border-radius: 9999px;
|
|
28
34
|
background: ${e};
|
|
29
|
-
color: ${
|
|
35
|
+
color: ${n};
|
|
30
36
|
border: none;
|
|
31
37
|
cursor: pointer;
|
|
32
38
|
display: flex;
|
|
@@ -56,6 +62,12 @@ var Nexor=(function(exports){'use strict';var P=class extends Error{constructor(
|
|
|
56
62
|
transform: scale(0.85);
|
|
57
63
|
opacity: 0.75;
|
|
58
64
|
}
|
|
65
|
+
/* While the chat panel is open the launcher is dormant: no hover fan, no
|
|
66
|
+
clicks. The visitor closes the chat (header \u2715) to reach the channels again.
|
|
67
|
+
pointer-events:none also stops the CSS :hover that would reveal the fan. */
|
|
68
|
+
.nexor-chat[data-open="true"] .nexor-chat__launcher-wrap {
|
|
69
|
+
pointer-events: none;
|
|
70
|
+
}
|
|
59
71
|
.nexor-chat__launcher svg { width: 24px; height: 24px; transition: transform 200ms ease; }
|
|
60
72
|
.nexor-chat[data-open="true"] .nexor-chat__launcher svg { transform: rotate(8deg); }
|
|
61
73
|
|
|
@@ -87,6 +99,118 @@ var Nexor=(function(exports){'use strict';var P=class extends Error{constructor(
|
|
|
87
99
|
to { transform: scale(1); }
|
|
88
100
|
}
|
|
89
101
|
|
|
102
|
+
/* \u2500\u2500 Speed-dial channel fan \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
103
|
+
/* Sits above the launcher, out of normal flow so it never shifts the bubble.
|
|
104
|
+
Hidden until the wrapper is hovered (pointer devices) or tapped open
|
|
105
|
+
(data-expanded, set by JS \u2014 the only path on touch). */
|
|
106
|
+
.nexor-chat__channels {
|
|
107
|
+
position: absolute;
|
|
108
|
+
/* Anchor the fan's box to the top of the launcher and push the buttons up
|
|
109
|
+
with padding instead of a gap. This keeps the launcher + fan a single,
|
|
110
|
+
continuous hover surface \u2014 moving the cursor from the bubble up to the
|
|
111
|
+
buttons never crosses dead space, so the drawer no longer snaps shut. */
|
|
112
|
+
bottom: 100%;
|
|
113
|
+
right: 0;
|
|
114
|
+
padding-bottom: 14px;
|
|
115
|
+
display: flex;
|
|
116
|
+
flex-direction: column;
|
|
117
|
+
gap: 12px;
|
|
118
|
+
align-items: flex-end;
|
|
119
|
+
opacity: 0;
|
|
120
|
+
visibility: hidden;
|
|
121
|
+
pointer-events: none;
|
|
122
|
+
transform: translateY(10px);
|
|
123
|
+
transition: opacity 180ms ease, transform 180ms ease, visibility 180ms;
|
|
124
|
+
}
|
|
125
|
+
.nexor-chat[data-position="bottom-left"] .nexor-chat__channels {
|
|
126
|
+
right: auto;
|
|
127
|
+
left: 0;
|
|
128
|
+
align-items: flex-start;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
@media (hover: hover) and (pointer: fine) {
|
|
132
|
+
.nexor-chat__launcher-wrap:hover .nexor-chat__channels {
|
|
133
|
+
opacity: 1;
|
|
134
|
+
visibility: visible;
|
|
135
|
+
pointer-events: auto;
|
|
136
|
+
transform: translateY(0);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
.nexor-chat__launcher-wrap[data-expanded="true"] .nexor-chat__channels {
|
|
140
|
+
opacity: 1;
|
|
141
|
+
visibility: visible;
|
|
142
|
+
pointer-events: auto;
|
|
143
|
+
transform: translateY(0);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/* Subtle rise-and-stagger as each item appears (nearest the launcher first). */
|
|
147
|
+
.nexor-chat__channel-item {
|
|
148
|
+
display: flex;
|
|
149
|
+
align-items: center;
|
|
150
|
+
gap: 10px;
|
|
151
|
+
transform: translateY(8px);
|
|
152
|
+
opacity: 0;
|
|
153
|
+
transition: transform 200ms cubic-bezier(.2,.7,.2,1.1), opacity 200ms ease;
|
|
154
|
+
}
|
|
155
|
+
.nexor-chat[data-position="bottom-left"] .nexor-chat__channel-item {
|
|
156
|
+
flex-direction: row-reverse;
|
|
157
|
+
}
|
|
158
|
+
.nexor-chat__launcher-wrap[data-expanded="true"] .nexor-chat__channel-item,
|
|
159
|
+
.nexor-chat__launcher-wrap:hover .nexor-chat__channel-item {
|
|
160
|
+
transform: translateY(0);
|
|
161
|
+
opacity: 1;
|
|
162
|
+
}
|
|
163
|
+
.nexor-chat__channel-item:nth-last-child(1) { transition-delay: 0ms; }
|
|
164
|
+
.nexor-chat__channel-item:nth-last-child(2) { transition-delay: 40ms; }
|
|
165
|
+
.nexor-chat__channel-item:nth-last-child(3) { transition-delay: 80ms; }
|
|
166
|
+
.nexor-chat__channel-item:nth-last-child(4) { transition-delay: 120ms; }
|
|
167
|
+
.nexor-chat__channel-item:nth-last-child(5) { transition-delay: 160ms; }
|
|
168
|
+
|
|
169
|
+
/* The round mini-button for each channel. */
|
|
170
|
+
.nexor-chat__channel {
|
|
171
|
+
width: 46px;
|
|
172
|
+
height: 46px;
|
|
173
|
+
border-radius: 9999px;
|
|
174
|
+
border: none;
|
|
175
|
+
cursor: pointer;
|
|
176
|
+
display: flex;
|
|
177
|
+
align-items: center;
|
|
178
|
+
justify-content: center;
|
|
179
|
+
padding: 0;
|
|
180
|
+
background: ${e};
|
|
181
|
+
color: ${n};
|
|
182
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
|
|
183
|
+
text-decoration: none;
|
|
184
|
+
transition: transform 140ms cubic-bezier(.2,.7,.2,1.1), box-shadow 140ms ease, filter 140ms ease;
|
|
185
|
+
}
|
|
186
|
+
.nexor-chat__channel:hover {
|
|
187
|
+
transform: scale(1.08);
|
|
188
|
+
box-shadow: 0 8px 18px rgba(0, 0, 0, 0.26);
|
|
189
|
+
filter: brightness(1.05);
|
|
190
|
+
}
|
|
191
|
+
.nexor-chat__channel:active { transform: scale(0.94); }
|
|
192
|
+
.nexor-chat__channel:focus-visible { outline: 2px solid ${e}; outline-offset: 2px; }
|
|
193
|
+
.nexor-chat__channel svg { width: 24px; height: 24px; display: block; }
|
|
194
|
+
|
|
195
|
+
/* Brand colours win over the accent where a channel has a recognisable hue. */
|
|
196
|
+
.nexor-chat__channel--whatsapp { background: #25d366; color: #fff; }
|
|
197
|
+
.nexor-chat__channel--instagram {
|
|
198
|
+
background: radial-gradient(circle at 30% 110%, #fdf497 0%, #fd5949 45%, #d6249f 70%, #285aeb 100%);
|
|
199
|
+
color: #fff;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/* Label pill beside each button. */
|
|
203
|
+
.nexor-chat__channel-label {
|
|
204
|
+
background: #fff;
|
|
205
|
+
color: #111;
|
|
206
|
+
font-size: 12px;
|
|
207
|
+
font-weight: 600;
|
|
208
|
+
padding: 5px 10px;
|
|
209
|
+
border-radius: 8px;
|
|
210
|
+
white-space: nowrap;
|
|
211
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
|
|
212
|
+
}
|
|
213
|
+
|
|
90
214
|
/* \u2500\u2500 Panel \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
91
215
|
.nexor-chat__panel {
|
|
92
216
|
position: absolute;
|
|
@@ -124,7 +248,7 @@ var Nexor=(function(exports){'use strict';var P=class extends Error{constructor(
|
|
|
124
248
|
|
|
125
249
|
.nexor-chat__header {
|
|
126
250
|
background: ${e};
|
|
127
|
-
color: ${
|
|
251
|
+
color: ${n};
|
|
128
252
|
padding: 14px 16px;
|
|
129
253
|
display: flex;
|
|
130
254
|
align-items: center;
|
|
@@ -140,6 +264,7 @@ var Nexor=(function(exports){'use strict';var P=class extends Error{constructor(
|
|
|
140
264
|
font-size: 12px;
|
|
141
265
|
opacity: 0.85;
|
|
142
266
|
margin: 2px 0 0;
|
|
267
|
+
line-height: 1.4;
|
|
143
268
|
}
|
|
144
269
|
.nexor-chat__status-dot {
|
|
145
270
|
display: inline-block;
|
|
@@ -169,6 +294,23 @@ var Nexor=(function(exports){'use strict';var P=class extends Error{constructor(
|
|
|
169
294
|
.nexor-chat__close:hover { background: rgba(255,255,255,0.18); opacity: 1; }
|
|
170
295
|
.nexor-chat__close:active { transform: scale(0.92); }
|
|
171
296
|
.nexor-chat__close svg { width: 18px; height: 18px; display: block; }
|
|
297
|
+
/* Keep the title left and group the action buttons on the right. */
|
|
298
|
+
.nexor-chat__header > div { margin-right: auto; min-width: 0; }
|
|
299
|
+
.nexor-chat__restart {
|
|
300
|
+
background: transparent;
|
|
301
|
+
border: none;
|
|
302
|
+
color: inherit;
|
|
303
|
+
cursor: pointer;
|
|
304
|
+
padding: 4px;
|
|
305
|
+
border-radius: 6px;
|
|
306
|
+
opacity: 0.7;
|
|
307
|
+
transition: background 140ms ease, transform 200ms ease, opacity 140ms ease;
|
|
308
|
+
}
|
|
309
|
+
.nexor-chat__restart:hover { background: rgba(255,255,255,0.18); opacity: 1; }
|
|
310
|
+
.nexor-chat__restart:active { transform: rotate(-90deg) scale(0.9); }
|
|
311
|
+
.nexor-chat__restart svg { width: 17px; height: 17px; display: block; }
|
|
312
|
+
/* Nothing to reset on the capture screen \u2014 hide it there. */
|
|
313
|
+
.nexor-chat__panel[data-view="capture"] .nexor-chat__restart { display: none; }
|
|
172
314
|
|
|
173
315
|
/* \u2500\u2500 Body / messages \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
174
316
|
.nexor-chat__body {
|
|
@@ -207,7 +349,7 @@ var Nexor=(function(exports){'use strict';var P=class extends Error{constructor(
|
|
|
207
349
|
}
|
|
208
350
|
.nexor-chat__msg--user {
|
|
209
351
|
background: ${e};
|
|
210
|
-
color: ${
|
|
352
|
+
color: ${n};
|
|
211
353
|
align-self: flex-end;
|
|
212
354
|
border-bottom-right-radius: 4px;
|
|
213
355
|
animation-name: nexor-msg-in-user;
|
|
@@ -268,6 +410,72 @@ var Nexor=(function(exports){'use strict';var P=class extends Error{constructor(
|
|
|
268
410
|
30% { opacity: 1; transform: translateY(-3px); }
|
|
269
411
|
}
|
|
270
412
|
|
|
413
|
+
/* \u2500\u2500 Resume banner (returning visitor) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
414
|
+
.nexor-chat__resume {
|
|
415
|
+
display: flex;
|
|
416
|
+
align-items: center;
|
|
417
|
+
justify-content: space-between;
|
|
418
|
+
gap: 10px;
|
|
419
|
+
background: #fff;
|
|
420
|
+
border: 1px solid rgba(0,0,0,0.06);
|
|
421
|
+
border-radius: 10px;
|
|
422
|
+
padding: 8px 12px;
|
|
423
|
+
margin-bottom: 4px;
|
|
424
|
+
box-shadow: 0 1px 2px rgba(0,0,0,0.04);
|
|
425
|
+
animation: nexor-fade-in 240ms ease both;
|
|
426
|
+
}
|
|
427
|
+
.nexor-chat__resume-text {
|
|
428
|
+
font-size: 12px;
|
|
429
|
+
color: #6b7280;
|
|
430
|
+
min-width: 0;
|
|
431
|
+
overflow: hidden;
|
|
432
|
+
text-overflow: ellipsis;
|
|
433
|
+
white-space: nowrap;
|
|
434
|
+
}
|
|
435
|
+
.nexor-chat__resume-reset {
|
|
436
|
+
flex: none;
|
|
437
|
+
background: transparent;
|
|
438
|
+
border: none;
|
|
439
|
+
color: ${e};
|
|
440
|
+
font: inherit;
|
|
441
|
+
font-size: 12px;
|
|
442
|
+
font-weight: 600;
|
|
443
|
+
cursor: pointer;
|
|
444
|
+
padding: 2px 4px;
|
|
445
|
+
border-radius: 6px;
|
|
446
|
+
text-decoration: underline;
|
|
447
|
+
text-underline-offset: 2px;
|
|
448
|
+
transition: opacity 140ms ease;
|
|
449
|
+
}
|
|
450
|
+
.nexor-chat__resume-reset:hover { opacity: 0.7; }
|
|
451
|
+
.nexor-chat__resume-reset:active { opacity: 0.5; }
|
|
452
|
+
|
|
453
|
+
/* \u2500\u2500 Capture as its own full-panel view \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
454
|
+
/* The form is a distinct screen, not a card wedged into the message list.
|
|
455
|
+
data-view swaps between the capture screen and the chat (body + composer). */
|
|
456
|
+
.nexor-chat__capture-view {
|
|
457
|
+
min-height: 0;
|
|
458
|
+
overflow-y: auto;
|
|
459
|
+
padding: 16px;
|
|
460
|
+
background: #f6f7f9;
|
|
461
|
+
display: flex;
|
|
462
|
+
flex-direction: column;
|
|
463
|
+
animation: nexor-fade-in 200ms ease both;
|
|
464
|
+
}
|
|
465
|
+
/* In the form view the panel hugs the form \u2014 no fixed 540px height leaving
|
|
466
|
+
empty gaps above and below the card. It still can't exceed max-height. */
|
|
467
|
+
.nexor-chat__panel[data-view="capture"] {
|
|
468
|
+
height: auto;
|
|
469
|
+
}
|
|
470
|
+
.nexor-chat__panel[data-view="chat"] .nexor-chat__capture-view { display: none; }
|
|
471
|
+
.nexor-chat__panel[data-view="capture"] .nexor-chat__body,
|
|
472
|
+
.nexor-chat__panel[data-view="capture"] .nexor-chat__composer { display: none; }
|
|
473
|
+
.nexor-chat__capture-view .nexor-chat__capture-label {
|
|
474
|
+
font-size: 13px;
|
|
475
|
+
font-weight: 600;
|
|
476
|
+
color: #374151;
|
|
477
|
+
}
|
|
478
|
+
|
|
271
479
|
/* \u2500\u2500 Lead capture form \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
272
480
|
.nexor-chat__capture {
|
|
273
481
|
background: #fff;
|
|
@@ -303,14 +511,75 @@ var Nexor=(function(exports){'use strict';var P=class extends Error{constructor(
|
|
|
303
511
|
width: 100%;
|
|
304
512
|
transition: border-color 140ms ease, box-shadow 140ms ease;
|
|
305
513
|
}
|
|
514
|
+
/* Composer textarea: auto-grows (height managed in JS) up to ~4 lines, then
|
|
515
|
+
scrolls. resize:none disables the manual drag handle. */
|
|
516
|
+
textarea.nexor-chat__input {
|
|
517
|
+
display: block;
|
|
518
|
+
resize: none;
|
|
519
|
+
overflow-y: auto;
|
|
520
|
+
line-height: 20px;
|
|
521
|
+
max-height: 98px; /* 4 lines (20\xD74) + 16 padding + 2 border */
|
|
522
|
+
white-space: pre-wrap;
|
|
523
|
+
word-break: break-word;
|
|
524
|
+
}
|
|
306
525
|
.nexor-chat__input:focus,
|
|
307
526
|
.nexor-chat__capture input:focus {
|
|
308
527
|
border-color: ${e};
|
|
309
528
|
box-shadow: 0 0 0 3px ${e}33;
|
|
310
529
|
}
|
|
530
|
+
.nexor-chat__input--error,
|
|
531
|
+
.nexor-chat__capture input.nexor-chat__input--error {
|
|
532
|
+
border-color: #ef4444;
|
|
533
|
+
box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.16);
|
|
534
|
+
}
|
|
535
|
+
.nexor-chat__capture-error {
|
|
536
|
+
font-size: 12px;
|
|
537
|
+
color: #ef4444;
|
|
538
|
+
margin: 0;
|
|
539
|
+
}
|
|
540
|
+
.nexor-chat__capture-error[hidden] { display: none; }
|
|
541
|
+
|
|
542
|
+
/* \u2500\u2500 Phone field (flag + dial code selector joined to a digit input) \u2500\u2500 */
|
|
543
|
+
.nexor-chat__phone {
|
|
544
|
+
display: flex;
|
|
545
|
+
align-items: stretch;
|
|
546
|
+
width: 100%;
|
|
547
|
+
border: 1px solid #d1d5db;
|
|
548
|
+
border-radius: 8px;
|
|
549
|
+
background: #fff;
|
|
550
|
+
overflow: hidden;
|
|
551
|
+
transition: border-color 140ms ease, box-shadow 140ms ease;
|
|
552
|
+
}
|
|
553
|
+
.nexor-chat__phone:focus-within {
|
|
554
|
+
border-color: ${e};
|
|
555
|
+
box-shadow: 0 0 0 3px ${e}33;
|
|
556
|
+
}
|
|
557
|
+
.nexor-chat__phone.nexor-chat__input--error {
|
|
558
|
+
border-color: #ef4444;
|
|
559
|
+
box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.16);
|
|
560
|
+
}
|
|
561
|
+
.nexor-chat__phone-country {
|
|
562
|
+
flex: none;
|
|
563
|
+
border: none;
|
|
564
|
+
border-right: 1px solid #e5e7eb;
|
|
565
|
+
background: #f9fafb;
|
|
566
|
+
color: #111;
|
|
567
|
+
font: inherit;
|
|
568
|
+
padding: 0 12px 0 10px;
|
|
569
|
+
cursor: pointer;
|
|
570
|
+
outline: none;
|
|
571
|
+
}
|
|
572
|
+
.nexor-chat__phone-number.nexor-chat__input {
|
|
573
|
+
border: none;
|
|
574
|
+
border-radius: 0;
|
|
575
|
+
box-shadow: none;
|
|
576
|
+
flex: 1;
|
|
577
|
+
min-width: 0;
|
|
578
|
+
}
|
|
579
|
+
|
|
311
580
|
.nexor-chat__capture-submit {
|
|
312
581
|
background: ${e};
|
|
313
|
-
color: ${
|
|
582
|
+
color: ${n};
|
|
314
583
|
border: none;
|
|
315
584
|
border-radius: 8px;
|
|
316
585
|
padding: 8px 12px;
|
|
@@ -323,6 +592,66 @@ var Nexor=(function(exports){'use strict';var P=class extends Error{constructor(
|
|
|
323
592
|
.nexor-chat__capture-submit:active { transform: scale(0.97); }
|
|
324
593
|
.nexor-chat__capture-submit[disabled] { opacity: 0.6; cursor: not-allowed; }
|
|
325
594
|
|
|
595
|
+
/* \u2500\u2500 Contact-request view (call me / email me) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
596
|
+
/* Its own full-panel screen, opened from a "call"/"email" fan button. Reuses
|
|
597
|
+
the capture form styling (.nexor-chat__capture) for the fields. */
|
|
598
|
+
.nexor-chat__contact-view {
|
|
599
|
+
min-height: 0;
|
|
600
|
+
overflow-y: auto;
|
|
601
|
+
padding: 16px;
|
|
602
|
+
background: #f6f7f9;
|
|
603
|
+
display: flex;
|
|
604
|
+
flex-direction: column;
|
|
605
|
+
animation: nexor-fade-in 200ms ease both;
|
|
606
|
+
}
|
|
607
|
+
/* Show the contact view only in its own data-view; hug the form (no fixed
|
|
608
|
+
height leaving gaps), but never exceed the panel's max-height. */
|
|
609
|
+
.nexor-chat__panel[data-view="contact"] { height: auto; }
|
|
610
|
+
.nexor-chat__panel:not([data-view="contact"]) .nexor-chat__contact-view { display: none; }
|
|
611
|
+
.nexor-chat__panel[data-view="contact"] .nexor-chat__capture-view,
|
|
612
|
+
.nexor-chat__panel[data-view="contact"] .nexor-chat__body,
|
|
613
|
+
.nexor-chat__panel[data-view="contact"] .nexor-chat__composer { display: none; }
|
|
614
|
+
.nexor-chat__panel[data-view="contact"] .nexor-chat__restart { display: none; }
|
|
615
|
+
|
|
616
|
+
/* The contact form lives under the header, which carries its title/explainer;
|
|
617
|
+
the live-status dot ("we're listening") makes no sense for a form. */
|
|
618
|
+
.nexor-chat__panel[data-view="contact"] .nexor-chat__status-dot { display: none; }
|
|
619
|
+
|
|
620
|
+
/* form \u2194 success swap, driven by the view's data-state */
|
|
621
|
+
.nexor-chat__contact-view[data-state="sent"] .nexor-chat__contact-form { display: none; }
|
|
622
|
+
.nexor-chat__contact-view:not([data-state="sent"]) .nexor-chat__contact-success { display: none; }
|
|
623
|
+
|
|
624
|
+
.nexor-chat__contact-success {
|
|
625
|
+
display: flex;
|
|
626
|
+
flex-direction: column;
|
|
627
|
+
align-items: center;
|
|
628
|
+
text-align: center;
|
|
629
|
+
gap: 12px;
|
|
630
|
+
padding: 28px 12px 12px;
|
|
631
|
+
animation: nexor-msg-in 280ms cubic-bezier(.2,.7,.2,1.1) both;
|
|
632
|
+
}
|
|
633
|
+
.nexor-chat__contact-success-icon {
|
|
634
|
+
width: 48px;
|
|
635
|
+
height: 48px;
|
|
636
|
+
display: flex;
|
|
637
|
+
align-items: center;
|
|
638
|
+
justify-content: center;
|
|
639
|
+
border-radius: 50%;
|
|
640
|
+
background: ${e};
|
|
641
|
+
color: ${n};
|
|
642
|
+
}
|
|
643
|
+
.nexor-chat__contact-success-icon svg { width: 26px; height: 26px; }
|
|
644
|
+
.nexor-chat__contact-success-text {
|
|
645
|
+
font-size: 14px;
|
|
646
|
+
color: #374151;
|
|
647
|
+
margin: 0;
|
|
648
|
+
line-height: 1.5;
|
|
649
|
+
}
|
|
650
|
+
.nexor-chat__contact-success .nexor-chat__capture-submit {
|
|
651
|
+
margin-top: 4px;
|
|
652
|
+
align-self: stretch;
|
|
653
|
+
}
|
|
654
|
+
|
|
326
655
|
/* \u2500\u2500 Composer \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
327
656
|
.nexor-chat__composer {
|
|
328
657
|
display: flex;
|
|
@@ -330,11 +659,12 @@ var Nexor=(function(exports){'use strict';var P=class extends Error{constructor(
|
|
|
330
659
|
padding: 10px;
|
|
331
660
|
background: #fff;
|
|
332
661
|
border-top: 1px solid rgba(0,0,0,0.06);
|
|
333
|
-
|
|
662
|
+
/* Pin the send button to the bottom so it stays put as the textarea grows. */
|
|
663
|
+
align-items: flex-end;
|
|
334
664
|
}
|
|
335
665
|
.nexor-chat__send {
|
|
336
666
|
background: ${e};
|
|
337
|
-
color: ${
|
|
667
|
+
color: ${n};
|
|
338
668
|
border: none;
|
|
339
669
|
border-radius: 8px;
|
|
340
670
|
padding: 0 14px;
|
|
@@ -342,6 +672,8 @@ var Nexor=(function(exports){'use strict';var P=class extends Error{constructor(
|
|
|
342
672
|
font-weight: 600;
|
|
343
673
|
cursor: pointer;
|
|
344
674
|
min-width: 44px;
|
|
675
|
+
height: 38px; /* matches the one-line textarea height */
|
|
676
|
+
flex: none;
|
|
345
677
|
display: flex;
|
|
346
678
|
align-items: center;
|
|
347
679
|
justify-content: center;
|
|
@@ -377,7 +709,10 @@ var Nexor=(function(exports){'use strict';var P=class extends Error{constructor(
|
|
|
377
709
|
}
|
|
378
710
|
|
|
379
711
|
.nexor-chat__footer {
|
|
380
|
-
|
|
712
|
+
display: flex;
|
|
713
|
+
align-items: center;
|
|
714
|
+
justify-content: center;
|
|
715
|
+
gap: 5px;
|
|
381
716
|
font-size: 11px;
|
|
382
717
|
color: #9ca3af;
|
|
383
718
|
padding: 6px;
|
|
@@ -389,7 +724,111 @@ var Nexor=(function(exports){'use strict';var P=class extends Error{constructor(
|
|
|
389
724
|
text-decoration: none;
|
|
390
725
|
font-weight: 600;
|
|
391
726
|
}
|
|
392
|
-
|
|
727
|
+
/* "Powered by" + the Nexor wordmark (same mark as the site navbar). Plain
|
|
728
|
+
attribution \u2014 not a link, but hovering shows a getnexor.ai tooltip. */
|
|
729
|
+
.nexor-chat__brand {
|
|
730
|
+
position: relative;
|
|
731
|
+
display: inline-flex;
|
|
732
|
+
align-items: center;
|
|
733
|
+
cursor: help; /* hover reveals the getnexor.ai tooltip; not a link */
|
|
734
|
+
}
|
|
735
|
+
.nexor-chat__brand-logo {
|
|
736
|
+
height: 13px;
|
|
737
|
+
width: auto;
|
|
738
|
+
display: block;
|
|
739
|
+
}
|
|
740
|
+
/* Custom tooltip (instant + reliable across browsers, unlike a native SVG
|
|
741
|
+
<title>). Sits above the logo and fades in on hover/focus. */
|
|
742
|
+
.nexor-chat__brand-tip {
|
|
743
|
+
position: absolute;
|
|
744
|
+
bottom: calc(100% + 7px);
|
|
745
|
+
left: 50%;
|
|
746
|
+
transform: translateX(-50%) translateY(4px);
|
|
747
|
+
background: #111827;
|
|
748
|
+
color: #fff;
|
|
749
|
+
font-size: 11px;
|
|
750
|
+
font-weight: 500;
|
|
751
|
+
line-height: 1;
|
|
752
|
+
letter-spacing: 0.01em;
|
|
753
|
+
padding: 5px 8px;
|
|
754
|
+
border-radius: 6px;
|
|
755
|
+
white-space: nowrap;
|
|
756
|
+
opacity: 0;
|
|
757
|
+
pointer-events: none;
|
|
758
|
+
box-shadow: 0 4px 12px rgba(0,0,0,0.18);
|
|
759
|
+
transition: opacity 140ms ease, transform 140ms ease;
|
|
760
|
+
z-index: 5;
|
|
761
|
+
}
|
|
762
|
+
.nexor-chat__brand-tip::after {
|
|
763
|
+
content: "";
|
|
764
|
+
position: absolute;
|
|
765
|
+
top: 100%;
|
|
766
|
+
left: 50%;
|
|
767
|
+
transform: translateX(-50%);
|
|
768
|
+
border: 4px solid transparent;
|
|
769
|
+
border-top-color: #111827;
|
|
770
|
+
}
|
|
771
|
+
.nexor-chat__brand:hover .nexor-chat__brand-tip {
|
|
772
|
+
opacity: 1;
|
|
773
|
+
transform: translateX(-50%) translateY(0);
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
/* \u2500\u2500 Mobile: full-screen panel with an obvious close affordance \u2500\u2500\u2500\u2500\u2500 */
|
|
777
|
+
@media (max-width: 480px) {
|
|
778
|
+
/* The panel takes over the whole viewport so the keyboard + messages have
|
|
779
|
+
room. 100dvh tracks the dynamic viewport as mobile browser chrome shows/
|
|
780
|
+
hides, avoiding a cut-off composer. */
|
|
781
|
+
.nexor-chat__panel {
|
|
782
|
+
position: fixed;
|
|
783
|
+
inset: 0;
|
|
784
|
+
top: 0;
|
|
785
|
+
left: 0;
|
|
786
|
+
right: 0;
|
|
787
|
+
bottom: 0;
|
|
788
|
+
width: 100%;
|
|
789
|
+
max-width: 100%;
|
|
790
|
+
height: 100vh;
|
|
791
|
+
height: 100dvh;
|
|
792
|
+
max-height: none;
|
|
793
|
+
border-radius: 0;
|
|
794
|
+
border: none;
|
|
795
|
+
transform: translateY(100%);
|
|
796
|
+
}
|
|
797
|
+
.nexor-chat[data-position="bottom-left"] .nexor-chat__panel { left: 0; }
|
|
798
|
+
.nexor-chat[data-open="true"] .nexor-chat__panel { transform: translateY(0); }
|
|
799
|
+
/* Keep the form view full-screen on phones too (overrides the desktop
|
|
800
|
+
hug-the-form height). */
|
|
801
|
+
.nexor-chat__panel[data-view="capture"] {
|
|
802
|
+
height: 100vh;
|
|
803
|
+
height: 100dvh;
|
|
804
|
+
}
|
|
805
|
+
.nexor-chat__panel[data-view="capture"] .nexor-chat__capture-view {
|
|
806
|
+
justify-content: center;
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
/* Hide the launcher (and any open fan) while the full-screen panel is up \u2014
|
|
810
|
+
the in-header close button is the way back out. */
|
|
811
|
+
.nexor-chat[data-open="true"] .nexor-chat__launcher-wrap {
|
|
812
|
+
opacity: 0;
|
|
813
|
+
pointer-events: none;
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
/* Roomier header + a bigger, unmistakable close target on touch. */
|
|
817
|
+
.nexor-chat__header {
|
|
818
|
+
padding: 16px 14px 16px 18px;
|
|
819
|
+
padding-top: max(16px, env(safe-area-inset-top));
|
|
820
|
+
}
|
|
821
|
+
.nexor-chat__close {
|
|
822
|
+
padding: 10px;
|
|
823
|
+
background: rgba(255, 255, 255, 0.16);
|
|
824
|
+
}
|
|
825
|
+
.nexor-chat__close svg { width: 24px; height: 24px; }
|
|
826
|
+
|
|
827
|
+
/* Keep the composer clear of the home-indicator / gesture bar. */
|
|
828
|
+
.nexor-chat__composer {
|
|
829
|
+
padding-bottom: max(10px, env(safe-area-inset-bottom));
|
|
830
|
+
}
|
|
831
|
+
}
|
|
393
832
|
|
|
394
833
|
/* Respect users who request reduced motion. */
|
|
395
834
|
@media (prefers-reduced-motion: reduce) {
|
|
@@ -400,27 +839,54 @@ var Nexor=(function(exports){'use strict';var P=class extends Error{constructor(
|
|
|
400
839
|
}
|
|
401
840
|
.nexor-chat__status-dot { animation: none; }
|
|
402
841
|
}
|
|
403
|
-
`;var
|
|
842
|
+
`;var pt="data-nexor-chat-styles";function ht(e,n){if(document.querySelector(`style[${pt}]`))return;let t=document.createElement("style");t.setAttribute(pt,"1"),t.textContent=ut(e,n),document.head.appendChild(t);}var mt=`
|
|
843
|
+
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
844
|
+
<path d="M4 5.5C4 4.67 4.67 4 5.5 4h13c.83 0 1.5.67 1.5 1.5v9c0 .83-.67 1.5-1.5 1.5H9l-4 4V5.5Z"
|
|
845
|
+
stroke="currentColor" stroke-width="1.8" stroke-linejoin="round"/>
|
|
846
|
+
</svg>`,rn={whatsapp:`
|
|
847
|
+
<svg viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
848
|
+
<path d="M.057 24l1.687-6.163a11.867 11.867 0 0 1-1.587-5.946C.16 5.335 5.495 0 12.05 0a11.817 11.817 0 0 1 8.413 3.488 11.824 11.824 0 0 1 3.48 8.414c-.003 6.557-5.338 11.892-11.893 11.892a11.9 11.9 0 0 1-5.688-1.448L.057 24zm6.597-3.807c1.676.995 3.276 1.591 5.392 1.592 5.448 0 9.886-4.434 9.889-9.885.002-5.462-4.415-9.89-9.881-9.892-5.452 0-9.887 4.434-9.889 9.884a9.82 9.82 0 0 0 1.5 5.245l-.999 3.648 3.738-.981zm11.387-5.464c-.074-.124-.272-.198-.57-.347-.297-.149-1.758-.868-2.031-.967-.272-.099-.47-.149-.669.149-.198.297-.768.967-.941 1.165-.173.198-.347.223-.644.074-.297-.149-1.255-.462-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.297-.347.446-.521.151-.172.2-.296.3-.495.099-.198.05-.372-.025-.521-.075-.148-.669-1.611-.916-2.206-.242-.579-.487-.501-.669-.51l-.57-.01c-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.263.489 1.694.626.712.226 1.36.194 1.872.118.571-.085 1.758-.719 2.006-1.413.248-.695.248-1.29.173-1.414z"/>
|
|
849
|
+
</svg>`,call:`
|
|
850
|
+
<svg viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
851
|
+
<path d="M6.6 10.8c1.4 2.8 3.8 5.1 6.6 6.6l2.2-2.2c.3-.3.7-.4 1-.2 1.1.4 2.3.6 3.5.6.6 0 1 .4 1 1V20c0 .6-.4 1-1 1C10.5 21 3 13.5 3 4.5c0-.6.4-1 1-1h3.5c.6 0 1 .4 1 1 0 1.2.2 2.4.6 3.5.1.4 0 .8-.2 1L6.6 10.8Z"/>
|
|
852
|
+
</svg>`,email:`
|
|
404
853
|
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
405
|
-
<
|
|
406
|
-
|
|
407
|
-
</svg
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
854
|
+
<rect x="3" y="5" width="18" height="14" rx="2" stroke="currentColor" stroke-width="1.8"/>
|
|
855
|
+
<path d="m4 7 8 6 8-6" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round"/>
|
|
856
|
+
</svg>`,instagram:`
|
|
857
|
+
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
858
|
+
<rect x="3.5" y="3.5" width="17" height="17" rx="5" stroke="currentColor" stroke-width="1.8"/>
|
|
859
|
+
<circle cx="12" cy="12" r="4" stroke="currentColor" stroke-width="1.8"/>
|
|
860
|
+
<circle cx="17.2" cy="6.8" r="1.2" fill="currentColor"/>
|
|
861
|
+
</svg>`,chat:mt};function ft(e){let n=document.createElement("div");n.className="nexor-chat__launcher-wrap";let t=e.channels.length>0,{fan:i,channelButtons:l}=t?an(e.channels):{fan:null,channelButtons:[]};i&&n.appendChild(i);let u=document.createElement("button");u.type="button",u.className="nexor-chat__launcher",u.setAttribute("aria-label",t?"Contact us":"Open chat"),t&&(u.setAttribute("aria-haspopup","true"),u.setAttribute("aria-expanded","false")),u.innerHTML=mt;let c=document.createElement("span");return c.className="nexor-chat__unread",c.style.display="none",u.appendChild(c),n.appendChild(u),{wrap:n,el:u,badge:c,fan:i,channelButtons:l}}function an(e){let n=document.createElement("div");n.className="nexor-chat__channels",n.setAttribute("role","menu");let t=[];for(let i of e){let l=document.createElement("div");l.className="nexor-chat__channel-item";let u=document.createElement("span");u.className="nexor-chat__channel-label",u.textContent=i.label;let c;if(i.href===null){let o=document.createElement("button");o.type="button",c=o;}else {let o=document.createElement("a");o.href=i.href,i.external&&(o.target="_blank",o.rel="noopener noreferrer"),c=o;}c.className=`nexor-chat__channel nexor-chat__channel--${i.key}`,c.setAttribute("role","menuitem"),c.setAttribute("aria-label",i.label),c.innerHTML=rn[i.key],l.appendChild(u),l.appendChild(c),n.appendChild(l),t.push({key:i.key,el:c,action:i.action});}return {fan:n,channelButtons:t}}function gt(e){let n=document.createElement("div");n.className="nexor-chat__panel",n.setAttribute("role","dialog"),n.setAttribute("aria-label",e.title);let{header:t,closeBtn:i,restartBtn:l,titleEl:u,subtitleEl:c,subtitleTextEl:o}=on(e),m=sn(),{form:a,input:x,send:p}=hn(e),f=e.showBranding?fn():null,I={},L=null,H=null,M=null,N=null;if(ke(e)){let b=ln(e,I);L=b.view,H=b.form,M=b.error,N=b.phoneCountry;}let S=e.requestContact?pn(e):null;return n.setAttribute("data-view",L?"capture":"chat"),n.appendChild(t),L&&n.appendChild(L),S&&n.appendChild(S.view),n.appendChild(m),n.appendChild(a),f&&n.appendChild(f),{el:n,closeBtn:i,restartBtn:l,headerTitle:u,headerSubtitle:c,headerSubtitleText:o,body:m,form:a,input:x,send:p,captureView:L,captureForm:H,captureError:M,phoneCountry:N,captureInputs:I,contact:S}}function on(e){var a;let n=document.createElement("div");n.className="nexor-chat__header";let t=document.createElement("div"),i=document.createElement("p");i.className="nexor-chat__title",i.textContent=e.title,t.appendChild(i);let l=document.createElement("p");l.className="nexor-chat__subtitle";let u=document.createElement("span");u.className="nexor-chat__status-dot",u.setAttribute("aria-hidden","true");let c=document.createElement("span");c.className="nexor-chat__subtitle-text",c.textContent=(a=e.subtitle)!=null?a:"",l.appendChild(u),l.appendChild(c),e.subtitle||(l.hidden=true),t.appendChild(l),n.appendChild(t);let o=null;e.showRestart&&(o=document.createElement("button"),o.type="button",o.className="nexor-chat__restart",o.setAttribute("aria-label",e.restartLabel),o.title=e.restartLabel,o.innerHTML=`
|
|
862
|
+
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
863
|
+
<path d="M4 5v5h5M20 19v-5h-5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
864
|
+
<path d="M19 10a7 7 0 0 0-12-3L4 10M5 14a7 7 0 0 0 12 3l3-3" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
865
|
+
</svg>
|
|
866
|
+
`,n.appendChild(o));let m=document.createElement("button");return m.type="button",m.className="nexor-chat__close",m.setAttribute("aria-label","Close chat"),m.innerHTML=`
|
|
416
867
|
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
417
868
|
<path d="M6 6l12 12M6 18L18 6" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
|
|
418
869
|
</svg>
|
|
419
|
-
`,
|
|
870
|
+
`,n.appendChild(m),{header:n,closeBtn:m,restartBtn:o,titleEl:i,subtitleEl:l,subtitleTextEl:c}}function sn(){let e=document.createElement("div");return e.className="nexor-chat__body",e}function ln(e,n){let t=document.createElement("div");t.className="nexor-chat__capture-view";let{form:i,error:l,phoneCountry:u}=cn(e,n);return t.appendChild(i),{view:t,form:i,error:l,phoneCountry:u}}var xt={first_name:"First name",last_name:"Last name",email:"Email",phone:"Phone"};function cn(e,n){var a,x,p;let t=document.createElement("form");t.className="nexor-chat__capture",t.noValidate=true;let i=null,l=document.createElement("p");l.className="nexor-chat__capture-label",l.textContent=e.capture.label,t.appendChild(l);let u=e.capture.fields,c=f=>{var I;return (I=e.capture.placeholders[f])!=null?I:xt[f]};if(u.includes("first_name")||u.includes("last_name")){let f=document.createElement("div");f.className="nexor-chat__capture-row",u.includes("first_name")&&(n.first_name=oe("first_name",c("first_name"),"text",(a=e.lead)==null?void 0:a.first_name),f.appendChild(n.first_name)),u.includes("last_name")&&(n.last_name=oe("last_name",c("last_name"),"text",(x=e.lead)==null?void 0:x.last_name),f.appendChild(n.last_name)),f.childElementCount>0&&t.appendChild(f);}if(u.includes("email")&&(n.email=oe("email",c("email"),"email",(p=e.lead)==null?void 0:p.email),t.appendChild(n.email)),u.includes("phone")){let f=bt(e,c("phone"));n.phone=f.input,i=f.select,t.appendChild(f.wrap);}let o=document.createElement("p");o.className="nexor-chat__capture-error",o.setAttribute("role","alert"),o.hidden=true,t.appendChild(o);let m=document.createElement("button");return m.type="submit",m.className="nexor-chat__capture-submit",m.textContent=e.capture.submitLabel,t.appendChild(m),{form:t,error:o,phoneCountry:i}}function dn(e){if(!e.length)return me;let n=e.map(t=>J(t)).filter(t=>!!t);return n.length?n:me}function bt(e,n){var o;let t=document.createElement("div");t.className="nexor-chat__phone";let i=dn(e.capture.phoneCountries),l=fe(e.capture.phoneCountryCode),u=document.createElement("select");u.className="nexor-chat__phone-country",u.name="phone_country",u.setAttribute("aria-label","Country code");for(let m of i){let a=document.createElement("option");a.value=m.iso,a.textContent=`${m.flag} ${m.dial}`,m.iso===l.iso&&(a.selected=true),u.appendChild(a);}let c=document.createElement("input");if(c.name="phone",c.type="tel",c.inputMode="numeric",c.autocomplete="tel-national",c.placeholder=n,c.className="nexor-chat__input nexor-chat__phone-number",c.maxLength=W(l),(o=e.lead)!=null&&o.phone){let m=String(e.lead.phone).replace(/\D/g,""),a=l.dial.replace(/\D/g,""),x=m.startsWith(a)?m.slice(a.length):m;c.value=x.slice(0,c.maxLength);}return t.appendChild(u),t.appendChild(c),{wrap:t,select:u,input:c}}function pn(e){var H,M,N,S;let n=e.requestContact,t=document.createElement("div");t.className="nexor-chat__contact-view",t.setAttribute("data-state","form");let i=document.createElement("form");i.className="nexor-chat__capture nexor-chat__contact-form",i.noValidate=true;let l={},u=b=>{var P;return (P=e.capture.placeholders[b])!=null?P:xt[b]},c=document.createElement("div");c.className="nexor-chat__capture-row",l.first_name=oe("first_name",u("first_name"),"text",(H=e.lead)==null?void 0:H.first_name),l.last_name=oe("last_name",u("last_name"),"text",(M=e.lead)==null?void 0:M.last_name),c.appendChild(l.first_name),c.appendChild(l.last_name),i.appendChild(c),l.email=oe("email",u("email"),"email",(N=e.lead)==null?void 0:N.email),i.appendChild(l.email);let o=bt(e,u("phone"));l.phone=o.input;let m=o.select;i.appendChild(o.wrap);let a=document.createElement("p");a.className="nexor-chat__capture-error",a.setAttribute("role","alert"),a.hidden=true,i.appendChild(a);let x=document.createElement("button");x.type="submit",x.className="nexor-chat__capture-submit",i.appendChild(x),t.appendChild(i);let p=document.createElement("div");p.className="nexor-chat__contact-success";let f=document.createElement("div");f.className="nexor-chat__contact-success-icon",f.innerHTML=`
|
|
871
|
+
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
872
|
+
<path d="M5 13l4 4L19 7" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"/>
|
|
873
|
+
</svg>`;let I=document.createElement("p");I.className="nexor-chat__contact-success-text";let L=document.createElement("button");return L.type="button",L.className="nexor-chat__capture-submit",L.textContent=(S=n==null?void 0:n.doneLabel)!=null?S:"Done",p.appendChild(f),p.appendChild(I),p.appendChild(L),t.appendChild(p),{view:t,form:i,inputs:l,error:a,phoneCountry:m,submitBtn:x,success:p,successText:I,successBtn:L}}function hn(e){let n=document.createElement("form");n.className="nexor-chat__composer";let t=document.createElement("textarea");t.className="nexor-chat__input",t.placeholder=e.inputPlaceholder,t.rows=1,t.setAttribute("autocomplete","off");let i=document.createElement("button");return i.type="submit",i.className="nexor-chat__send",i.setAttribute("aria-label","Send message"),i.innerHTML=`
|
|
420
874
|
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
421
875
|
<path d="M3.4 11.2 20.5 4.3c.7-.3 1.4.4 1.1 1.1l-6.9 17.1c-.3.8-1.4.8-1.8 0L10 14l-7.5-3c-.8-.3-.8-1.5 0-1.8Z"
|
|
422
876
|
stroke="currentColor" stroke-width="1.6" stroke-linejoin="round" fill="currentColor"/>
|
|
423
877
|
</svg>
|
|
424
|
-
`,
|
|
425
|
-
|
|
878
|
+
`,n.appendChild(t),n.appendChild(i),{form:n,input:t,send:i}}var mn=`
|
|
879
|
+
<svg viewBox="0 0 1722 505" fill="none" xmlns="http://www.w3.org/2000/svg" class="nexor-chat__brand-logo" role="img" aria-label="Nexor">
|
|
880
|
+
<defs>
|
|
881
|
+
<linearGradient id="nexorChatBrandGrad" x1="1195.44" y1="21.3423" x2="1195.44" y2="504.454" gradientUnits="userSpaceOnUse">
|
|
882
|
+
<stop stop-color="#232522"/>
|
|
883
|
+
<stop offset="1" stop-color="#A1A1A1"/>
|
|
884
|
+
</linearGradient>
|
|
885
|
+
</defs>
|
|
886
|
+
<path d="M31.824 416.676V103.332H67.32L82.008 147.396C92.412 125.976 125.46 99.0477 196.452 99.0477C299.268 99.0477 319.464 159.024 319.464 247.764V416.676H254.592V242.256C254.592 186.564 244.8 153.516 178.092 153.516C111.384 153.516 97.308 185.952 97.308 242.256V416.676H31.824ZM506.373 420.96C380.301 420.96 349.089 343.236 349.089 259.392C349.089 175.548 380.913 99.0477 505.761 99.0477C621.429 99.0477 653.865 187.176 645.909 285.708H417.021C420.693 339.564 447.621 370.776 503.925 370.776C555.945 370.776 572.469 345.684 578.589 320.592H647.133C641.625 373.836 604.905 420.96 506.373 420.96ZM417.633 233.688H578.589V232.464C579.201 189.624 559.005 149.844 499.641 149.844C438.441 149.844 420.693 187.788 417.633 233.688ZM622.452 416.676L747.912 254.496L631.02 103.332H706.296L788.916 217.164L872.76 103.332H946.2L829.92 254.496L955.38 416.676H876.432L789.528 290.604L702.012 416.676H622.452Z" fill="#232522"/>
|
|
887
|
+
<path d="M1195.22 21.3423C1199.01 21.3424 1202.55 23.2768 1205.81 26.6265C1209.06 29.9743 1212.14 34.8402 1215.03 40.9858C1220.81 53.2843 1225.98 70.9957 1230.31 92.7749C1236.49 123.842 1240.99 163.329 1243.06 207.497C1245.04 168.74 1249.06 134.088 1254.51 106.604C1258.48 86.5946 1263.23 70.315 1268.53 59.0063C1271.18 53.3557 1274 48.8741 1277 45.7866C1279.99 42.6974 1283.27 40.8979 1286.78 40.8979C1290.29 40.8981 1293.56 42.6975 1296.56 45.7866C1299.55 48.8741 1302.37 53.3556 1305.03 59.0063C1310.33 70.315 1315.07 86.5945 1319.04 106.604C1324.73 135.304 1328.87 171.821 1330.75 212.666C1332.39 186.451 1335.28 162.981 1339.08 144C1342.12 128.775 1345.76 116.368 1349.84 107.735C1351.88 103.422 1354.07 99.9788 1356.4 97.5962C1358.73 95.2117 1361.31 93.7866 1364.11 93.7866C1366.91 93.7866 1369.5 95.2116 1371.83 97.5962C1374.16 99.9788 1376.34 103.422 1378.38 107.735C1382.46 116.368 1386.1 128.775 1389.15 144C1393.72 166.881 1396.98 196.283 1398.32 229.154C1399.23 221.906 1400.42 215.317 1401.84 209.621C1403.54 202.788 1405.59 197.165 1407.92 193.217C1410.19 189.36 1412.99 186.675 1416.33 186.675C1419.68 186.676 1422.47 189.36 1424.75 193.217C1427.07 197.165 1429.12 202.788 1430.83 209.621C1434.24 223.306 1436.33 242.142 1436.33 262.898C1436.33 283.654 1434.24 302.489 1430.83 316.174C1429.12 323.007 1427.07 328.631 1424.75 332.579C1422.47 336.436 1419.68 339.119 1416.33 339.12C1412.99 339.12 1410.19 336.436 1407.92 332.579C1405.59 328.631 1403.54 323.007 1401.84 316.174C1400.42 310.478 1399.23 303.889 1398.32 296.641C1396.98 329.512 1393.72 358.915 1389.15 381.796C1386.1 397.021 1382.46 409.428 1378.38 418.061C1376.34 422.374 1374.16 425.816 1371.83 428.199C1369.5 430.583 1366.91 432.009 1364.11 432.009C1361.31 432.009 1358.73 430.584 1356.4 428.199C1354.07 425.816 1351.88 422.374 1349.84 418.061C1345.76 409.428 1342.12 397.021 1339.08 381.796C1335.28 362.814 1332.39 339.344 1330.75 313.129C1328.87 353.974 1324.73 390.492 1319.04 419.192C1315.07 439.201 1310.33 455.481 1305.03 466.79C1302.37 472.44 1299.55 476.922 1296.56 480.009C1293.56 483.098 1290.29 484.898 1286.78 484.898C1283.27 484.898 1279.99 483.098 1277 480.009C1274 476.922 1271.18 472.44 1268.53 466.79C1263.23 455.481 1258.48 439.201 1254.51 419.192C1249.06 391.708 1245.04 357.055 1243.06 318.298C1240.99 362.466 1236.49 401.953 1230.31 433.021C1225.98 454.8 1220.81 472.512 1215.03 484.81C1212.14 490.956 1209.06 495.822 1205.81 499.169C1202.55 502.519 1199.01 504.454 1195.22 504.454C1191.44 504.454 1187.89 502.519 1184.64 499.169C1181.38 495.822 1178.31 490.956 1175.42 484.81C1169.64 472.512 1164.46 454.8 1160.13 433.021C1153.95 401.956 1149.46 362.472 1147.39 318.308C1145.4 357.061 1141.38 391.71 1135.93 419.192C1131.96 439.202 1127.22 455.481 1121.91 466.79C1119.26 472.44 1116.44 476.922 1113.45 480.009C1110.45 483.098 1107.18 484.898 1103.67 484.898C1100.16 484.898 1096.88 483.098 1093.89 480.009C1090.89 476.922 1088.07 472.44 1085.42 466.79C1080.12 455.481 1075.37 439.202 1071.4 419.192C1065.71 390.491 1061.58 353.973 1059.69 313.128C1058.05 339.344 1055.16 362.814 1051.37 381.796C1048.32 397.021 1044.68 409.428 1040.6 418.061C1038.56 422.374 1036.38 425.816 1034.05 428.199C1031.72 430.583 1029.14 432.009 1026.33 432.009C1023.53 432.009 1020.95 430.584 1018.62 428.199C1016.29 425.816 1014.11 422.374 1012.07 418.061C1007.99 409.428 1004.34 397.021 1001.3 381.796C996.723 358.916 993.462 329.514 992.122 296.645C991.214 303.891 990.024 310.479 988.604 316.174C986.901 323.007 984.852 328.631 982.525 332.579C980.252 336.436 977.453 339.12 974.111 339.12C970.77 339.12 967.97 336.436 965.697 332.579C963.371 328.631 961.321 323.007 959.618 316.174C956.207 302.489 954.111 283.654 954.111 262.898C954.111 242.142 956.207 223.306 959.618 209.621C961.321 202.788 963.371 197.165 965.697 193.217C967.97 189.36 970.77 186.675 974.111 186.675C977.453 186.675 980.252 189.36 982.525 193.217C984.852 197.165 986.901 202.788 988.604 209.621C990.024 215.316 991.214 221.904 992.122 229.15C993.462 196.281 996.723 166.88 1001.3 144C1004.34 128.775 1007.99 116.368 1012.07 107.735C1014.11 103.422 1016.29 99.9787 1018.62 97.5962C1020.95 95.2115 1023.53 93.7866 1026.33 93.7866C1029.14 93.7868 1031.72 95.2116 1034.05 97.5962C1036.38 99.9787 1038.56 103.422 1040.6 107.735C1044.68 116.368 1048.32 128.775 1051.37 144C1055.16 162.981 1058.05 186.451 1059.69 212.666C1061.58 171.821 1065.71 135.304 1071.4 106.604C1075.37 86.5944 1080.12 70.315 1085.42 59.0063C1088.07 53.3558 1090.89 48.8741 1093.89 45.7866C1096.88 42.6974 1100.16 40.8979 1103.67 40.8979C1107.18 40.898 1110.45 42.6975 1113.45 45.7866C1116.44 48.8741 1119.26 53.3558 1121.91 59.0063C1127.22 70.315 1131.96 86.5945 1135.93 106.604C1141.38 134.086 1145.4 168.735 1147.39 207.487C1149.46 163.323 1153.95 123.84 1160.13 92.7749C1164.46 70.9957 1169.64 53.2843 1175.42 40.9858C1178.31 34.8403 1181.38 29.9743 1184.64 26.6265C1187.89 23.2769 1191.44 21.3423 1195.22 21.3423Z" fill="url(#nexorChatBrandGrad)"/>
|
|
888
|
+
<path d="M1490.82 416.676V103.332H1525.71L1541.01 146.784C1559.98 106.392 1596.7 95.3758 1652.39 99.0477V155.964C1588.13 146.784 1556.31 177.996 1556.31 251.436V416.676H1490.82Z" fill="#232522"/>
|
|
889
|
+
<path d="M1681.68 78.9118C1650.58 78.9118 1642.32 61.0558 1642.32 39.3598C1642.32 17.9518 1650.86 -0.000219345 1681.68 -0.000219345C1712.88 -0.000219345 1721.04 17.9518 1721.04 39.4558C1721.04 61.0558 1712.88 78.9118 1681.68 78.9118ZM1651.82 39.4558C1651.82 57.3118 1658.26 70.7518 1681.68 70.7518C1705.2 70.7518 1711.54 57.3118 1711.54 39.4558C1711.54 21.5998 1705.2 8.15978 1681.68 8.15978C1658.35 8.15978 1651.82 21.6958 1651.82 39.4558ZM1662.1 39.8398C1662.1 28.2238 1666.9 18.3358 1681.87 18.3358C1693.87 18.3358 1700.11 25.0558 1700.11 36.1918H1691.28C1690.7 29.2798 1687.82 26.3998 1681.78 26.3998C1674.1 26.3998 1671.02 31.2958 1671.02 39.5518C1671.02 47.9038 1674.1 52.8958 1681.78 52.8958C1687.82 52.8958 1690.8 50.0158 1691.28 43.3918H1700.11C1700.11 54.6238 1694.16 61.0558 1682.16 61.0558C1666.9 61.0558 1662.1 51.2638 1662.1 39.8398Z" fill="#232522"/>
|
|
890
|
+
</svg>`;function fn(){let e=document.createElement("div");return e.className="nexor-chat__footer",e.innerHTML=`<span>Powered by</span><span class="nexor-chat__brand" aria-label="Nexor"><span class="nexor-chat__brand-tip" role="tooltip">getnexor.ai</span>${mn}</span>`,e}function Ct(e,n,t,i){let l=document.createElement("div");l.className=`nexor-chat__msg nexor-chat__msg--${e}`;let u=document.createElement("span");if(u.className="nexor-chat__msg-text",u.textContent=n,l.appendChild(u),e!=="system"&&t){let c=document.createElement("time");c.className="nexor-chat__msg-time",c.dataset.ts=String(t),c.textContent=qe(t,i),l.appendChild(c);}return l}function qe(e,n,t=Date.now()){try{let i=Math.max(0,t-e),l=Math.round(i/6e4),u=Math.round(i/36e5),c=Math.round(i/864e5),o=new Intl.RelativeTimeFormat(n,{numeric:"auto"});return i<45e3?o.format(0,"second"):l<60?o.format(-l,"minute"):u<24?o.format(-u,"hour"):c<7?o.format(-c,"day"):new Date(e).toLocaleDateString(n,{day:"numeric",month:"short"})}catch(i){try{return new Date(e).toLocaleTimeString(n,{hour:"2-digit",minute:"2-digit"})}catch(l){return ""}}}function _t(e,n){let t=document.createElement("div");t.className="nexor-chat__resume";let i=document.createElement("span");i.className="nexor-chat__resume-text",i.textContent=e;let l=document.createElement("button");return l.type="button",l.className="nexor-chat__resume-reset",l.textContent=n,t.appendChild(i),t.appendChild(l),{el:t,resetBtn:l}}function yt(){let e=document.createElement("div");return e.className="nexor-chat__typing",e.innerHTML="<span></span><span></span><span></span>",e}function oe(e,n,t,i){let l=document.createElement("input");return l.name=e,l.type=t,l.placeholder=n,i&&(l.value=i),l}function wt(e,n){var Ke,ze,We,je;if(xn(),!n||!n.workflowId)throw new Error("Nexor SDK: initChat() requires `workflowId`.");let t=at(n);ht(t.accentColor,t.accentTextColor);let i=st(),l=`nexor.chat.history.${i}`,u=bn(t),c=ft(t),o=gt(t);u.appendChild(c.wrap),u.appendChild(o.el),((Ke=t.container)!=null?Ke:document.body).appendChild(u);let m=c.channelButtons.length>0,a={isOpen:false,expanded:false,unread:0,leadId:void 0,captured:!ke(t),pendingLead:{...(ze=t.lead)!=null?ze:{}},history:[],webchatEnabled:true,serverInitialMessage:null,configResolved:false,disabledShown:false,shownOpening:null,resetEpisode:false,freshLocalSession:false,episodeChoiceOffered:false,contactChannel:null,leadCreating:null},x,p={pending:[],timer:0,inFlight:false,typing:null,splitTimer:0},f={pending:false,timer:0},I=2e3;c.el.addEventListener("click",m?N:O),o.closeBtn.addEventListener("click",q),(We=o.restartBtn)==null||We.addEventListener("click",de),o.form.addEventListener("submit",ue),o.input.addEventListener("input",pe),o.input.addEventListener("keydown",r=>{r.key==="Enter"&&!r.shiftKey&&!r.isComposing&&(r.preventDefault(),ue(r));}),(je=o.captureForm)==null||je.addEventListener("submit",j);for(let r of Object.values(o.captureInputs))r==null||r.addEventListener("input",K);if(o.phoneCountry&&o.captureInputs.phone&&ie(o.phoneCountry,o.captureInputs.phone,K),o.contact){let r=o.contact;r.form.addEventListener("submit",be);for(let s of Object.values(r.inputs))s==null||s.addEventListener("input",G);r.phoneCountry&&r.inputs.phone&&ie(r.phoneCountry,r.inputs.phone,G),r.successBtn.addEventListener("click",q);}let L=null;if(m){for(let r of c.channelButtons)r.el.addEventListener("click",()=>{r.key==="chat"?(b(),P()):r.action==="contact"?(b(),ge(r.key)):b();});L=r=>{a.expanded&&!c.wrap.contains(r.target)&&b();},document.addEventListener("pointerdown",L);}let H=null,M=It();if(a.freshLocalSession=M.history.length===0,M.history.length){a.history=M.history,M.lead&&(a.pendingLead={...a.pendingLead,...M.lead}),a.captured=true,D("chat"),ce();for(let r of M.history)Ee(r.role==="user"?"user":"bot",r.text,r.ts);Pe();}Re(),x=vt(),t.openOnLoad&&P();function N(){a.expanded?b():S();}function S(){a.expanded=true,c.wrap.setAttribute("data-expanded","true"),c.el.setAttribute("aria-expanded","true");}function b(){a.expanded&&(a.expanded=false,c.wrap.setAttribute("data-expanded","false"),c.el.setAttribute("aria-expanded","false"));}function P(){var r,s;if(b(),!a.isOpen){if(a.isOpen=true,u.setAttribute("data-open","true"),Fe(),!a.webchatEnabled){De(),(r=t.onOpen)==null||r.call(t);return}if(a.history.length===0&&a.captured&&ee()&&Ie(),a.captured)o.input.focus();else {let d=t.capture.fields[0];(d&&o.captureInputs[d]||o.input).focus();}(s=t.onOpen)==null||s.call(t);}}function q(){var r;a.isOpen&&(a.isOpen=false,u.setAttribute("data-open","false"),o.el.getAttribute("data-view")==="contact"&&(a.contactChannel=null,D(_e()),w()),(r=t.onClose)==null||r.call(t));}function w(){var r;o.headerTitle.textContent=t.title,o.headerSubtitleText.textContent=(r=t.subtitle)!=null?r:"",o.headerSubtitle.hidden=!t.subtitle;}function O(){a.isOpen?q():P();}function j(r){var g,C,_;r.preventDefault(),K();let s=Cn(o),d=t.capture.fields,h=t.capture.errorMessages;for(let y of d)if(!s[y])return $(y,h.required);if(d.includes("email")&&!Oe((g=s.email)!=null?g:""))return $("email",h.email);if(d.includes("phone")){let y=J((C=o.phoneCountry)==null?void 0:C.value),v=((_=s.phone)!=null?_:"").replace(/\D/g,"");if(!y||v.length<y.nsn[0]||v.length>y.nsn[1])return $("phone",h.phone);s.phone=`${y.dial}${v}`;}a.pendingLead={...a.pendingLead,...s},a.captured=true,Q(),D("chat"),Re(),o.input.focus(),a.history.length===0&&ee()&&Ie();}function Q(){if(!t.capture.createLeadOnSubmit||a.leadId)return;let r=a.pendingLead;if(!r.first_name&&!r.email&&!r.phone)return;let s=typeof t.metadata=="function"?t.metadata():t.metadata;a.leadCreating=e.createLead({first_name:r.first_name||"Web visitor",last_name:r.last_name,email:r.email,phone:r.phone,source:"web-chat",metadata:{...s,web_chat_session_id:i}}).then(d=>{var h,g;(h=d==null?void 0:d.lead)!=null&&h.id&&!a.leadId&&(a.leadId=d.lead.id,(g=t.onLeadCaptured)==null||g.call(t,d.lead.id)),d&&!d.existed&&(a.episodeChoiceOffered=true);}).catch(d=>{var h;(h=t.onError)==null||h.call(t,d);}).finally(()=>{a.leadCreating=null;});}function $(r,s){F(s);let d=o.captureInputs[r],h=(d==null?void 0:d.closest(".nexor-chat__phone"))||d;h==null||h.classList.add("nexor-chat__input--error"),d==null||d.focus();}function F(r){o.captureError&&(o.captureError.textContent=r,o.captureError.hidden=false);}function K(){var r;o.captureError&&(o.captureError.textContent="",o.captureError.hidden=true),(r=o.captureForm)==null||r.querySelectorAll(".nexor-chat__input--error").forEach(s=>s.classList.remove("nexor-chat__input--error"));}function ie(r,s,d){let h=()=>{let g=J(r.value),C=g?W(g):15;s.maxLength=C;let _=s.value.replace(/\D/g,"").slice(0,C);s.value!==_&&(s.value=_);};s.addEventListener("input",h),r.addEventListener("change",()=>{h(),d==null||d();});}function ge(r){var g,C,_,y,v,B,z;let s=o.contact,d=t.requestContact;if(!s||!d)return;a.contactChannel=r,o.headerTitle.textContent=(g=d.title[r])!=null?g:t.title,o.headerSubtitleText.textContent=(C=d.subtitle[r])!=null?C:"",o.headerSubtitle.hidden=!d.subtitle[r],s.submitBtn.textContent=(_=d.submitLabel[r])!=null?_:"",s.successText.textContent=(y=d.successText[r])!=null?y:"",s.view.setAttribute("data-state","form"),s.submitBtn.disabled=false,G(),xe(),Le(),a.isOpen=true,u.setAttribute("data-open","true"),Fe(),D("contact");let h=[s.inputs.first_name,s.inputs.email,s.inputs.phone].find(A=>A&&!A.value);(B=(v=h!=null?h:s.inputs.first_name)!=null?v:null)==null||B.focus(),(z=t.onOpen)==null||z.call(t);}function xe(){var h,g,C;let r=o.contact;if(!r)return;let s=a.pendingLead;r.inputs.first_name&&(r.inputs.first_name.value=(h=s.first_name)!=null?h:""),r.inputs.last_name&&(r.inputs.last_name.value=(g=s.last_name)!=null?g:""),r.inputs.email&&(r.inputs.email.value=(C=s.email)!=null?C:"");let d=fe(t.capture.phoneCountryCode);if(r.phoneCountry&&(r.phoneCountry.value=d.iso),r.inputs.phone){let _="";if(s.phone){let y=String(s.phone).replace(/\D/g,""),v=d.dial.replace(/\D/g,"");_=(y.startsWith(v)?y.slice(v.length):y).slice(0,W(d));}r.inputs.phone.maxLength=W(d),r.inputs.phone.value=_;}}function be(r){var A,Ve,Ge,Ye,Xe,Ze,Je,Qe,et;r.preventDefault();let s=o.contact,d=a.contactChannel;if(!s||!d)return;G();let h=t.capture.errorMessages,g=(Ve=(A=s.inputs.first_name)==null?void 0:A.value.trim())!=null?Ve:"",C=(Ye=(Ge=s.inputs.last_name)==null?void 0:Ge.value.trim())!=null?Ye:"",_=(Ze=(Xe=s.inputs.email)==null?void 0:Xe.value.trim())!=null?Ze:"",y=((Qe=(Je=s.inputs.phone)==null?void 0:Je.value)!=null?Qe:"").replace(/\D/g,"");if(!g)return V("first_name",h.required);if(d==="email"&&!_)return V("email",h.required);if(_&&!Oe(_))return V("email",h.email);let B=d==="call"||d==="whatsapp",z;if(B||y){let Me=J((et=s.phoneCountry)==null?void 0:et.value);if(!Me||y.length<Me.nsn[0]||y.length>Me.nsn[1])return V("phone",h.phone);z=`${Me.dial}${y}`;}Ce(d,{first:g,last:C,email:_,phone:z});}async function Ce(r,s){var y,v,B,z;let d=o.contact,h=t.requestContact;if(!d||!h)return;d.submitBtn.disabled=true;let g=typeof t.metadata=="function"?t.metadata():t.metadata,C=g!=null?g:void 0,_=C&&C.page_url||(typeof window!="undefined"?window.location.href:void 0);try{let A=await e.requestContact({workflow_id:t.workflowId,first_name:s.first,last_name:s.last||void 0,email:s.email||void 0,phone:s.phone,force_first_channel:r,source:"web-chat",metadata:{...C!=null?C:{},contact_request:!0,requested_channel:r,requested_at:new Date().toISOString(),context_note:`Website visitor asked to be contacted via ${r}${_?` from ${_}`:""}.`}},{timeoutMs:t.requestTimeoutMs,maxRetries:0});(y=A==null?void 0:A.lead)!=null&&y.id&&!a.leadId&&(a.leadId=A.lead.id,(v=t.onLeadCaptured)==null||v.call(t,A.lead.id)),d.successText.textContent=(B=h.successText[r])!=null?B:"",o.headerSubtitle.hidden=!0,d.view.setAttribute("data-state","sent");}catch(A){d.submitBtn.disabled=false,le(h.errorText),(z=t.onError)==null||z.call(t,A);}}function V(r,s){let d=o.contact;if(!d)return;le(s);let h=d.inputs[r],g=(h==null?void 0:h.closest(".nexor-chat__phone"))||h;g==null||g.classList.add("nexor-chat__input--error"),h==null||h.focus();}function le(r){let s=o.contact;s&&(s.error.textContent=r,s.error.hidden=false);}function G(){let r=o.contact;r&&(r.error.textContent="",r.error.hidden=true,r.form.querySelectorAll(".nexor-chat__input--error").forEach(s=>s.classList.remove("nexor-chat__input--error")));}function D(r){o.el.setAttribute("data-view",r);}function _e(){return a.captured?"chat":"capture"}function ye(){let r=a.pendingLead,s=(r.first_name||r.email||r.phone||"").trim();return s?t.resumeWithNameText.replace("{name}",s):t.resumeText}function ce(r=false){if(H)return;let s=_t(ye(),t.startOverText);s.resetBtn.addEventListener("click",de),r&&o.body.firstChild?o.body.insertBefore(s.el,o.body.firstChild):o.body.appendChild(s.el),H=s.el;}function de(){var r;Le(),p.timer&&(window.clearTimeout(p.timer),p.timer=0),p.splitTimer&&(window.clearTimeout(p.splitTimer),p.splitTimer=0),p.pending=[],Y();try{window.localStorage.removeItem(l);}catch(s){}if(a.history=[],a.shownOpening=null,H=null,o.body.replaceChildren(),o.captureView){a.pendingLead={...(r=t.lead)!=null?r:{}},a.captured=false,a.leadId=void 0,a.episodeChoiceOffered=false,a.resetEpisode=true,we(),D("capture"),Re();let s=t.capture.fields[0];(s&&o.captureInputs[s]||o.input).focus();return}a.resetEpisode=true,D("chat"),Re(),a.captured&&ee()&&Ie(),o.input.focus();}function we(){var d,h,g;let r=a.pendingLead;o.captureInputs.first_name&&(o.captureInputs.first_name.value=(d=r.first_name)!=null?d:""),o.captureInputs.last_name&&(o.captureInputs.last_name.value=(h=r.last_name)!=null?h:""),o.captureInputs.email&&(o.captureInputs.email.value=(g=r.email)!=null?g:"");let s=fe(t.capture.phoneCountryCode);if(o.phoneCountry&&(o.phoneCountry.value=s.iso),o.captureInputs.phone){let C="";if(r.phone){let _=String(r.phone).replace(/\D/g,""),y=s.dial.replace(/\D/g,"");C=(_.startsWith(y)?_.slice(y.length):_).slice(0,W(s));}o.captureInputs.phone.maxLength=W(s),o.captureInputs.phone.value=C;}K();}function ue(r){r.preventDefault();let s=o.input.value.trim();s&&(o.input.value="",pe(),he(s));}function pe(){let r=o.input;r.style.height="auto",r.style.height=`${r.scrollHeight+2}px`;}function he(r){if(!a.captured){let s=t.capture.fields[0];(s&&o.captureInputs[s]||o.input).focus();return}Le(),Et(r),p.pending.push(r),Be();}function ve(){var s;let r=t.openingMessage||a.serverInitialMessage;return r?ct(r,a.pendingLead):(s=t.greeting)!=null?s:""}function ee(){return a.webchatEnabled?t.openingMessage||!a.configResolved?true:!!a.serverInitialMessage||!!t.greeting:false}function Ie(){f.pending||(f.pending=true,Se(),f.timer=window.setTimeout(async()=>{if(t.openingMessage||await x,!f.pending)return;f.pending=false,f.timer=0,Y();let r=ve();r&&(a.shownOpening=r,Te(r));},I));}function Le(){f.pending&&(f.timer&&window.clearTimeout(f.timer),f.timer=0,f.pending=false,Y());}async function vt(){var r;try{let s=await e.getChatConfig(t.workflowId,{timeoutMs:1e4,maxRetries:1});Ne(s.enabled!==!1,(r=s.initial_message)!=null?r:null);}catch(s){Ne(true,null);}}function Ne(r,s){a.configResolved=true,a.serverInitialMessage=s,a.webchatEnabled=r,r||(Lt(),Le(),a.isOpen&&De());}function De(){D("chat"),a.disabledShown||(He(t.disabledText),a.disabledShown=true),o.input.disabled=true,o.send.disabled=true,o.input.placeholder=t.disabledText;}function Lt(){for(let r of c.channelButtons){if(r.key!=="chat")continue;let s=r.el.closest(".nexor-chat__channel-item");s instanceof HTMLElement&&(s.style.display="none");}}function Se(){if(p.typing){o.body.appendChild(p.typing),Pe();return}p.typing=$e(yt());}function Y(){var r;(r=p.typing)==null||r.remove(),p.typing=null;}function Be(){Se(),p.timer&&window.clearTimeout(p.timer),p.timer=window.setTimeout(()=>{Tt();},t.debounceMs);}async function Tt(){var h,g,C,_,y;if(p.inFlight||p.pending.length===0)return;let s=p.pending.splice(0,p.pending.length).join(`
|
|
891
|
+
`);if(p.inFlight=true,a.leadCreating)try{await a.leadCreating;}catch(v){}let d=a.resetEpisode;try{let v=await e.chat({workflow_id:t.workflowId,session_id:i,message:s,system_prompt:t.systemPrompt,client_prompt:t.clientPrompt,opening_shown:(h=a.shownOpening)!=null?h:void 0,reset_episode:d||void 0,lead:Object.keys(a.pendingLead).length?a.pendingLead:void 0,metadata:typeof t.metadata=="function"?t.metadata():t.metadata},{timeoutMs:t.requestTimeoutMs,maxRetries:0});d&&(a.resetEpisode=!1),v.lead_id&&!a.leadId&&(a.leadId=v.lead_id,(g=t.onLeadCaptured)==null||g.call(t,a.leadId)),v.matched_existing&&a.freshLocalSession&&!a.episodeChoiceOffered&&!d&&(a.episodeChoiceOffered=!0,ce(!0));let B=((C=v.reply)!=null?C:"").trim();Y(),B?Rt(B):(He(t.errorText),(_=t.onError)==null||_.call(t,new Error("Nexor SDK: empty reply from server")));}catch(v){Y(),/web chat is not enabled/i.test((v==null?void 0:v.message)||"")?Ne(false,a.serverInitialMessage):He(t.errorText),(y=t.onError)==null||y.call(t,v);}finally{p.splitTimer||Y(),p.inFlight=false,o.input.focus(),p.pending.length&&Be();}}function Et(r){var d;let s=Date.now();Ee("user",r,s),a.history.push({role:"user",text:r,ts:s}),Ue(),(d=t.onMessage)==null||d.call(t,{role:"user",text:r});}function Te(r,s=true){var h;let d=s?Date.now():void 0;Ee("bot",r,d),a.history.push({role:"bot",text:r,ts:d}),Ue(),a.isOpen||St(),(h=t.onMessage)==null||h.call(t,{role:"bot",text:r});}function Rt(r){let s=t.splitReplies?Mt(r):[r];if(s.length<=1){Te(r);return}let[d,...h]=s;Te(d!=null?d:r,false);let g=0,C=()=>{let _=h[g];if(_===void 0)return;let y=g===h.length-1;g++,Se();let v=t.splitDelayMs>0?t.splitDelayMs:kt(_);p.splitTimer=window.setTimeout(()=>{p.splitTimer=0,Y(),Te(_,y),C();},v);};C();}function Mt(r){let s=r.split(/\n[ \t]*\n+/).map(d=>d.trim()).filter(Boolean);return s.length?s:[r]}function kt(r){let g=3e3+Math.min(r.length,180)*11.11111111111111,C=Math.random()*300-150;return Math.round(Math.max(3e3,Math.min(5e3,g+C)))}function Ue(){try{window.localStorage.setItem(l,JSON.stringify({ts:Date.now(),history:a.history,lead:a.pendingLead})),it();}catch(r){}}function It(){let r={history:[],lead:void 0};try{let s=window.localStorage.getItem(l);if(!s)return r;let d=JSON.parse(s);return !d||!Array.isArray(d.history)?r:Date.now()-(d.ts||0)>2592e6?(window.localStorage.removeItem(l),r):{history:d.history,lead:d.lead&&typeof d.lead=="object"?d.lead:void 0}}catch(s){return r}}function He(r){Ee("system",r);}function Ee(r,s,d){return $e(Ct(r,s,d,t.locale))}let Nt=window.setInterval(()=>{o.body.querySelectorAll(".nexor-chat__msg-time[data-ts]").forEach(r=>{let s=Number(r.dataset.ts);s&&(r.textContent=qe(s,t.locale));});},6e4);function $e(r){return o.body.appendChild(r),p.typing&&p.typing!==r&&o.body.appendChild(p.typing),Pe(),r}function Pe(){o.body.scrollTop=o.body.scrollHeight;}function St(){a.unread++,c.badge.textContent=String(a.unread),c.badge.style.display="flex";}function Fe(){a.unread=0,c.badge.style.display="none";}function Re(){let r=!a.captured;o.input.disabled=r,o.send.disabled=r,o.input.placeholder=r?"Complete the form above to start\u2026":t.inputPlaceholder;}return {open:P,close:q,toggle:O,send:r=>(he(r),Promise.resolve()),destroy:()=>{p.timer&&window.clearTimeout(p.timer),p.splitTimer&&window.clearTimeout(p.splitTimer),f.timer&&window.clearTimeout(f.timer),window.clearInterval(Nt),L&&document.removeEventListener("pointerdown",L),u.remove();},getSessionId:()=>i}}function xn(){if(typeof window=="undefined"||typeof document=="undefined")throw new Error("Nexor SDK: initChat() requires a browser environment.")}function bn(e){let n=document.createElement("div");return n.className="nexor-chat",n.setAttribute("data-position",e.position),n.setAttribute("data-open","false"),n}function Cn(e){let n={},t=e.captureInputs;return t.first_name&&(n.first_name=t.first_name.value.trim()),t.last_name&&(n.last_name=t.last_name.value.trim()),t.email&&(n.email=t.email.value.trim()),t.phone&&(n.phone=t.phone.value.replace(/\D/g,"")),n}function _n(e){return new Z(e)}var se=null;function k(){if(!se)throw new Error("Nexor SDK: call `nexor.init({ apiKey })` before using the API.");return se}function yn(e){return se=new Z(e),se}function wn(){return se!==null}function vn(){se=null;}var T={init:yn,isInitialized:wn,reset:vn,createLead:((...e)=>k().createLead(...e)),createLeadsBulk:((...e)=>k().createLeadsBulk(...e)),updateLead:((...e)=>k().updateLead(...e)),getLead:((...e)=>k().getLead(...e)),getLeadHistory:((...e)=>k().getLeadHistory(...e)),isLeadPaused:((...e)=>k().isLeadPaused(...e)),stopAutomation:((...e)=>k().stopAutomation(...e)),resumeAutomation:((...e)=>k().resumeAutomation(...e)),syncLeadTags:((...e)=>k().syncLeadTags(...e)),listLeadMeetings:((...e)=>k().listLeadMeetings(...e)),listWorkflows:((...e)=>k().listWorkflows(...e)),listCampaigns:((...e)=>k().listCampaigns(...e)),listTemplates:((...e)=>k().listTemplates(...e)),sendMessage:((...e)=>k().sendMessage(...e)),createMeeting:((...e)=>k().createMeeting(...e)),createMeetingNotes:((...e)=>k().createMeetingNotes(...e)),initChat:e=>wt(k(),e)};var Qn=T.init,er=T.isInitialized,tr=T.reset,nr=T.initChat,rr=T.createLead,ar=T.createLeadsBulk,or=T.updateLead,sr=T.getLead,ir=T.getLeadHistory,lr=T.isLeadPaused,cr=T.stopAutomation,dr=T.resumeAutomation,ur=T.syncLeadTags,pr=T.listLeadMeetings,hr=T.listWorkflows,mr=T.listCampaigns,fr=T.listTemplates,gr=T.sendMessage,xr=T.createMeeting,br=T.createMeetingNotes;exports.NexorAPIError=U;exports.NexorAuthError=ne;exports.NexorClient=Z;exports.NexorError=te;exports.NexorNetworkError=X;exports.NexorValidationError=re;exports.createClient=_n;exports.createLead=rr;exports.createLeadsBulk=ar;exports.createMeeting=xr;exports.createMeetingNotes=br;exports.getLead=sr;exports.getLeadHistory=ir;exports.init=Qn;exports.initChat=nr;exports.isInitialized=er;exports.isLeadPaused=lr;exports.listCampaigns=mr;exports.listLeadMeetings=pr;exports.listTemplates=fr;exports.listWorkflows=hr;exports.reset=tr;exports.resumeAutomation=dr;exports.sendMessage=gr;exports.stopAutomation=cr;exports.syncLeadTags=ur;exports.updateLead=or;return exports;})({});//# sourceMappingURL=nexor.iife.js.map
|
|
426
892
|
//# sourceMappingURL=nexor.iife.js.map
|