@opencxh/domain 1.130.0 → 1.131.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,4 @@
1
1
  export * from './types';
2
2
  export * from './preview';
3
3
  export * from './seen';
4
+ export * from './timestamp';
@@ -0,0 +1,15 @@
1
+ import { Activity } from './types';
2
+ /**
3
+ * The epoch-ms an activity happened at.
4
+ *
5
+ * `Activity.createdAt` is optional because the same type describes an activity
6
+ * that has not been written yet (`Omit<Activity, "id">` on the way into a create
7
+ * call). Everything reading a *persisted* activity — sorting a feed, formatting a
8
+ * timestamp — needs a number, and reaching for `createdAt` directly there means
9
+ * every call site either repeats a fallback or quietly passes `undefined` into
10
+ * `new Date()` (which yields an Invalid Date, not an error).
11
+ *
12
+ * Falls back to 0 (epoch) so ordering stays deterministic: an activity with no
13
+ * timestamp sorts oldest rather than to a random place.
14
+ */
15
+ export declare function activityTimestamp(activity: Pick<Activity, "createdAt">): number;
package/dist/index.cjs CHANGED
@@ -1,10 +1,10 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=140;function T(e){return e.replace(/<style[\s\S]*?<\/style>/gi," ").replace(/<script[\s\S]*?<\/script>/gi," ").replace(/<[^>]+>/g," ").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/\s+/g," ").trim()}function Y(e){const n=e.trim();return n.length<=m?n:n.slice(0,m-1).trimEnd()+"…"}function d(e){if(!e||e<0)return"";const n=Math.floor(e/60),t=Math.floor(e%60);return`${n}:${t.toString().padStart(2,"0")}`}function j(e){switch(e.type){case"EMAIL_RECEIVED":case"EMAIL_SENT":{const n=e.payload,t=n.bodySnippet?.trim()||T(n.body??"");return n.subject?`${n.subject} — ${t}`:t}case"CHAT_MESSAGE_SENT":case"CHAT_MESSAGE_RECEIVED":return e.payload.text??"";case"CHAT_RENAMED":return`Hernoemd naar "${e.payload.newName}"`;case"CHAT_MEMBER_JOINED":return`${e.payload.members.map(n=>n.name).join(", ")} toegevoegd`;case"CHAT_MEMBER_LEFT":return`${e.payload.members.map(n=>n.name).join(", ")} verlaten`;case"CHAT_CALL_STARTED":return"Gesprek gestart";case"CHAT_CALL_ENDED":return`Gesprek beëindigd${e.payload.duration?` (${d(e.payload.duration)})`:""}`;case"CHAT_EVENT":return e.payload.text??e.payload.eventType;case"VOICE_CALL_STARTED":case"VIDEO_CALL_STARTED":return"Gesprek gestart";case"VOICE_CALL_ANSWERED":case"VIDEO_CALL_ANSWERED":return"Gesprek aangenomen";case"VOICE_CALL_HOLD":case"VIDEO_CALL_HOLD":return"In de wacht";case"VOICE_CALL_UNHOLD":case"VIDEO_CALL_UNHOLD":return"Hervat";case"VOICE_CALL_ENDED":case"VIDEO_CALL_ENDED":return`Gesprek beëindigd${e.payload.duration?` (${d(e.payload.duration)})`:""}`;case"VOICE_CALL_MISSED":case"VIDEO_CALL_MISSED":return"Gemiste oproep";case"VOICE_CALL_FAILED":case"VIDEO_CALL_FAILED":return"Gesprek mislukt";case"VOICE_CALL_VOICEMAIL":return e.payload.transcription?.trim()?e.payload.transcription:"Voicemail ontvangen";case"TRANSCRIPT_ADDED":return(e.payload.segments??[]).map(n=>n.text).join(" ");case"AI_MESSAGE_ADDED":return e.payload.output?.text??e.payload.input?.text??"";case"AI_ACTION_PROPOSED":return`Voorstel wacht op goedkeuring (${e.payload.actions?.length??0} actie(s))`;case"PLAYBOOK_STARTED":return`Playbook gestart${e.payload.playbookName?`: ${e.payload.playbookName}`:""}`;case"PLAYBOOK_COMPLETED":return"Playbook afgerond";case"PLAYBOOK_ESCALATED":return"Playbook geëscaleerd naar een mens";case"MEETING_SCHEDULED":return`Vergadering gepland: ${e.payload.title}`;case"MEETING_STARTED":return`Vergadering gestart: ${e.payload.title}`;case"MEETING_ENDED":return`Vergadering beëindigd${e.payload.duration?` (${d(e.payload.duration)})`:""}`;case"MEETING_PARTICIPANT_JOINED":return`${e.payload.name} deelgenomen`;case"MEETING_PARTICIPANT_LEFT":return`${e.payload.name} verlaten`;case"COMMENT_ADDED":return e.payload.text??"";case"FILE_UPLOADED":return`Bestand: ${e.payload.fileName}`;case"INTERACTION_CREATED":return"Interactie aangemaakt";case"INTERACTION_STATUS_CHANGED":return`Status: ${e.payload.fromStatus} → ${e.payload.toStatus}`;case"INTERACTION_ASSIGNED":return"Interactie toegewezen";default:return""}}function K(e){return{activityId:e.id,type:e.type,snippet:Y(j(e)),authorName:e.author?.name??"",direction:e.direction,createdAt:e.createdAt??Date.now()}}function z(e,n,t=[]){const r=e.createdAt;if(!r)return[];const a=new Set(t);return e.author.type==="user"&&e.author.id&&a.add(e.author.id),Object.entries(n).filter(([i,o])=>o>=r&&!a.has(i)).map(([i])=>i)}const q=[{id:"agent",label:"Agent",labelSource:"user"},{id:"team",label:"Team",labelSource:"team"},{id:"inbox",label:"Inbox",labelSource:"inbox"},{id:"channel",label:"Kanaal",labelSource:"channel"},{id:"provider",label:"Provider",labelSource:"raw"},{id:"status",label:"Status",labelSource:"raw"},{id:"handledBy",label:"Afhandelaar",labelSource:"raw"},{id:"time",label:"Tijd",labelSource:"raw"}];function X(e){const n=[];for(const t of Object.keys(e))for(const r of Object.keys(e[t]))n.push({lang:t,key:r,value:e[t][r]});return n}function p(e){return e<10?`0${e}`:`${e}`}function D(e,n){const t=new Date(e),r=`${t.getUTCFullYear()}-${p(t.getUTCMonth()+1)}-${p(t.getUTCDate())}`;return n==="day"?r:`${r}T${p(t.getUTCHours())}`}function h(e,n){const t=new Date(e);return t.setUTCMinutes(0,0,0),n==="day"&&t.setUTCHours(0),t.getTime()}const J=36e5,Q=864e5;function Z(e,n,t){const r=t==="hour"?J:Q,a=[];for(let i=h(e,t);i<=n;i+=r)a.push(D(i,t));return a}const N=[{id:"resource",label:"Resource",labelSource:"raw"},{id:"origin",label:"Herkomst",labelSource:"raw"}],R=N.map(e=>e.id);function O(e,n){return`${e}.usage.${n}`}function ee(e,n){return n.map(t=>({id:O(e,t.unit),label:t.label,category:"Verbruik",valueType:t.valueType??"count",aggregation:"sum",supportedDimensions:["provider",...R,...t.extraDimensions??[],"time"]}))}function ne(e){return(e.startsWith("tool:")?e.slice(5):e).replace(/__/g," · ").replace(/\./g," · ").replace(/_/g," ")}const te=[{name:"text",type:"string"},{name:"subject",type:"string"},{name:"from",type:"string"},{name:"type",type:"string"},{name:"direction",type:"string"},{name:"channelId",type:"string"},{name:"interactionId",type:"string"},{name:"activityId",type:"string"},{name:"authorType",type:"string"},{name:"authorName",type:"string"},{name:"textRaw",type:"string"},{name:"fromStatus",type:"string"},{name:"toStatus",type:"string"},{name:"contactId",type:"string"},{name:"companyId",type:"string"}],re={topics:[{name:"topic",type:"string"},{name:"confidence",type:"number"}],question:[{name:"answer",type:"boolean"},{name:"confidence",type:"number"}],extract:[]};function C(e){switch(e.kind){case"user":return`user:${e.userId}`;case"team":return`team:${e.teamId}`;case"org":return"org"}}function ae(e){if(typeof e!="string")return;const n=e.trim();if(n==="org")return{kind:"org"};const t=n.indexOf(":");if(t<=0)return;const r=n.slice(0,t),a=n.slice(t+1).trim();if(a){if(r==="user")return{kind:"user",userId:a};if(r==="team")return{kind:"team",teamId:a}}}function L(e){return C(e)}function ie(e){switch(e.kind){case"personal":return{kind:"user",userId:e.userId};case"team":return{kind:"team",teamId:e.teamId};case"org":return{kind:"org"}}}function oe(e){return L(e)}const y=["done","escalated","failed","timed_out","stopped"],U=["awaiting_approval","awaiting_reply"];function P(e){return y.includes(e)}function se(e){return P(e)}function le(e){return U.includes(e)}const f=[{id:"openai",label:"OpenAI",capabilities:["chat","transcription","embedding"],defaultModel:"gpt-5-mini",baseUrl:"https://api.openai.com/v1"},{id:"gemini",label:"Google Gemini",capabilities:["chat","transcription","embedding"],defaultModel:"gemini-3.5-flash",baseUrl:"https://generativelanguage.googleapis.com/v1beta"},{id:"anthropic",label:"Anthropic",capabilities:["chat"],defaultModel:"claude-haiku-4-5",baseUrl:"https://api.anthropic.com/v1"},{id:"elevenlabs",label:"ElevenLabs",capabilities:["transcription"],baseUrl:"https://api.elevenlabs.io/v1"},{id:"moonshot",label:"Moonshot (Kimi)",capabilities:["chat"],defaultModel:"kimi-k3",baseUrl:"https://api.moonshot.ai/v1"},{id:"deepseek",label:"DeepSeek",capabilities:["chat"],defaultModel:"deepseek-v4-flash",baseUrl:"https://api.deepseek.com/v1"},{id:"groq",label:"Groq",capabilities:["chat"],defaultModel:"openai/gpt-oss-120b",baseUrl:"https://api.groq.com/openai/v1"},{id:"mistral",label:"Mistral",capabilities:["chat"],defaultModel:"mistral-large-latest",baseUrl:"https://api.mistral.ai/v1"},{id:"openrouter",label:"OpenRouter",capabilities:["chat"],defaultModel:"openrouter/auto",baseUrl:"https://openrouter.ai/api/v1"},{id:"ollama",label:"Ollama (self-hosted)",capabilities:["chat"],defaultModel:"llama3.3"},{id:"openai-compatible",label:"OpenAI-compatible (eigen endpoint)",capabilities:["chat"],defaultModel:"default"}];function c(e){return f.find(n=>n.id===e)}function ce(e){return c(e)?.label??e}function ue(e,n="gpt-5-mini"){return c(e)?.defaultModel??n}function de(e){return f.filter(n=>n.capabilities.includes(e))}function pe(e){const n=c(e);return!!n&&!n.baseUrl}const Ee=new Set(["mail","message"]);function k(e,n){const t=e.settings?.signatures?.[n];return!t||!t.enabled||!t.body||t.body.trim()===""?null:t}function fe(e,n,t,r="html"){if(!e)return t;const a=k(e,n);return a?`${t}${r==="text"?`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=140;function T(e){return e.replace(/<style[\s\S]*?<\/style>/gi," ").replace(/<script[\s\S]*?<\/script>/gi," ").replace(/<[^>]+>/g," ").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/\s+/g," ").trim()}function Y(e){const n=e.trim();return n.length<=m?n:n.slice(0,m-1).trimEnd()+"…"}function d(e){if(!e||e<0)return"";const n=Math.floor(e/60),t=Math.floor(e%60);return`${n}:${t.toString().padStart(2,"0")}`}function j(e){switch(e.type){case"EMAIL_RECEIVED":case"EMAIL_SENT":{const n=e.payload,t=n.bodySnippet?.trim()||T(n.body??"");return n.subject?`${n.subject} — ${t}`:t}case"CHAT_MESSAGE_SENT":case"CHAT_MESSAGE_RECEIVED":return e.payload.text??"";case"CHAT_RENAMED":return`Hernoemd naar "${e.payload.newName}"`;case"CHAT_MEMBER_JOINED":return`${e.payload.members.map(n=>n.name).join(", ")} toegevoegd`;case"CHAT_MEMBER_LEFT":return`${e.payload.members.map(n=>n.name).join(", ")} verlaten`;case"CHAT_CALL_STARTED":return"Gesprek gestart";case"CHAT_CALL_ENDED":return`Gesprek beëindigd${e.payload.duration?` (${d(e.payload.duration)})`:""}`;case"CHAT_EVENT":return e.payload.text??e.payload.eventType;case"VOICE_CALL_STARTED":case"VIDEO_CALL_STARTED":return"Gesprek gestart";case"VOICE_CALL_ANSWERED":case"VIDEO_CALL_ANSWERED":return"Gesprek aangenomen";case"VOICE_CALL_HOLD":case"VIDEO_CALL_HOLD":return"In de wacht";case"VOICE_CALL_UNHOLD":case"VIDEO_CALL_UNHOLD":return"Hervat";case"VOICE_CALL_ENDED":case"VIDEO_CALL_ENDED":return`Gesprek beëindigd${e.payload.duration?` (${d(e.payload.duration)})`:""}`;case"VOICE_CALL_MISSED":case"VIDEO_CALL_MISSED":return"Gemiste oproep";case"VOICE_CALL_FAILED":case"VIDEO_CALL_FAILED":return"Gesprek mislukt";case"VOICE_CALL_VOICEMAIL":return e.payload.transcription?.trim()?e.payload.transcription:"Voicemail ontvangen";case"TRANSCRIPT_ADDED":return(e.payload.segments??[]).map(n=>n.text).join(" ");case"AI_MESSAGE_ADDED":return e.payload.output?.text??e.payload.input?.text??"";case"AI_ACTION_PROPOSED":return`Voorstel wacht op goedkeuring (${e.payload.actions?.length??0} actie(s))`;case"PLAYBOOK_STARTED":return`Playbook gestart${e.payload.playbookName?`: ${e.payload.playbookName}`:""}`;case"PLAYBOOK_COMPLETED":return"Playbook afgerond";case"PLAYBOOK_ESCALATED":return"Playbook geëscaleerd naar een mens";case"MEETING_SCHEDULED":return`Vergadering gepland: ${e.payload.title}`;case"MEETING_STARTED":return`Vergadering gestart: ${e.payload.title}`;case"MEETING_ENDED":return`Vergadering beëindigd${e.payload.duration?` (${d(e.payload.duration)})`:""}`;case"MEETING_PARTICIPANT_JOINED":return`${e.payload.name} deelgenomen`;case"MEETING_PARTICIPANT_LEFT":return`${e.payload.name} verlaten`;case"COMMENT_ADDED":return e.payload.text??"";case"FILE_UPLOADED":return`Bestand: ${e.payload.fileName}`;case"INTERACTION_CREATED":return"Interactie aangemaakt";case"INTERACTION_STATUS_CHANGED":return`Status: ${e.payload.fromStatus} → ${e.payload.toStatus}`;case"INTERACTION_ASSIGNED":return"Interactie toegewezen";default:return""}}function K(e){return{activityId:e.id,type:e.type,snippet:Y(j(e)),authorName:e.author?.name??"",direction:e.direction,createdAt:e.createdAt??Date.now()}}function z(e,n,t=[]){const r=e.createdAt;if(!r)return[];const a=new Set(t);return e.author.type==="user"&&e.author.id&&a.add(e.author.id),Object.entries(n).filter(([i,o])=>o>=r&&!a.has(i)).map(([i])=>i)}function q(e){return e.createdAt??0}const X=[{id:"agent",label:"Agent",labelSource:"user"},{id:"team",label:"Team",labelSource:"team"},{id:"inbox",label:"Inbox",labelSource:"inbox"},{id:"channel",label:"Kanaal",labelSource:"channel"},{id:"provider",label:"Provider",labelSource:"raw"},{id:"status",label:"Status",labelSource:"raw"},{id:"handledBy",label:"Afhandelaar",labelSource:"raw"},{id:"time",label:"Tijd",labelSource:"raw"}];function J(e){const n=[];for(const t of Object.keys(e))for(const r of Object.keys(e[t]))n.push({lang:t,key:r,value:e[t][r]});return n}function p(e){return e<10?`0${e}`:`${e}`}function D(e,n){const t=new Date(e),r=`${t.getUTCFullYear()}-${p(t.getUTCMonth()+1)}-${p(t.getUTCDate())}`;return n==="day"?r:`${r}T${p(t.getUTCHours())}`}function h(e,n){const t=new Date(e);return t.setUTCMinutes(0,0,0),n==="day"&&t.setUTCHours(0),t.getTime()}const Q=36e5,Z=864e5;function ee(e,n,t){const r=t==="hour"?Q:Z,a=[];for(let i=h(e,t);i<=n;i+=r)a.push(D(i,t));return a}const N=[{id:"resource",label:"Resource",labelSource:"raw"},{id:"origin",label:"Herkomst",labelSource:"raw"}],R=N.map(e=>e.id);function O(e,n){return`${e}.usage.${n}`}function ne(e,n){return n.map(t=>({id:O(e,t.unit),label:t.label,category:"Verbruik",valueType:t.valueType??"count",aggregation:"sum",supportedDimensions:["provider",...R,...t.extraDimensions??[],"time"]}))}function te(e){return(e.startsWith("tool:")?e.slice(5):e).replace(/__/g," · ").replace(/\./g," · ").replace(/_/g," ")}const re=[{name:"text",type:"string"},{name:"subject",type:"string"},{name:"from",type:"string"},{name:"type",type:"string"},{name:"direction",type:"string"},{name:"channelId",type:"string"},{name:"interactionId",type:"string"},{name:"activityId",type:"string"},{name:"authorType",type:"string"},{name:"authorName",type:"string"},{name:"textRaw",type:"string"},{name:"fromStatus",type:"string"},{name:"toStatus",type:"string"},{name:"contactId",type:"string"},{name:"companyId",type:"string"}],ae={topics:[{name:"topic",type:"string"},{name:"confidence",type:"number"}],question:[{name:"answer",type:"boolean"},{name:"confidence",type:"number"}],extract:[]};function C(e){switch(e.kind){case"user":return`user:${e.userId}`;case"team":return`team:${e.teamId}`;case"org":return"org"}}function ie(e){if(typeof e!="string")return;const n=e.trim();if(n==="org")return{kind:"org"};const t=n.indexOf(":");if(t<=0)return;const r=n.slice(0,t),a=n.slice(t+1).trim();if(a){if(r==="user")return{kind:"user",userId:a};if(r==="team")return{kind:"team",teamId:a}}}function L(e){return C(e)}function oe(e){switch(e.kind){case"personal":return{kind:"user",userId:e.userId};case"team":return{kind:"team",teamId:e.teamId};case"org":return{kind:"org"}}}function se(e){return L(e)}const y=["done","escalated","failed","timed_out","stopped"],U=["awaiting_approval","awaiting_reply"];function P(e){return y.includes(e)}function le(e){return P(e)}function ce(e){return U.includes(e)}const f=[{id:"openai",label:"OpenAI",capabilities:["chat","transcription","embedding"],defaultModel:"gpt-5-mini",baseUrl:"https://api.openai.com/v1"},{id:"gemini",label:"Google Gemini",capabilities:["chat","transcription","embedding"],defaultModel:"gemini-3.5-flash",baseUrl:"https://generativelanguage.googleapis.com/v1beta"},{id:"anthropic",label:"Anthropic",capabilities:["chat"],defaultModel:"claude-haiku-4-5",baseUrl:"https://api.anthropic.com/v1"},{id:"elevenlabs",label:"ElevenLabs",capabilities:["transcription"],baseUrl:"https://api.elevenlabs.io/v1"},{id:"moonshot",label:"Moonshot (Kimi)",capabilities:["chat"],defaultModel:"kimi-k3",baseUrl:"https://api.moonshot.ai/v1"},{id:"deepseek",label:"DeepSeek",capabilities:["chat"],defaultModel:"deepseek-v4-flash",baseUrl:"https://api.deepseek.com/v1"},{id:"groq",label:"Groq",capabilities:["chat"],defaultModel:"openai/gpt-oss-120b",baseUrl:"https://api.groq.com/openai/v1"},{id:"mistral",label:"Mistral",capabilities:["chat"],defaultModel:"mistral-large-latest",baseUrl:"https://api.mistral.ai/v1"},{id:"openrouter",label:"OpenRouter",capabilities:["chat"],defaultModel:"openrouter/auto",baseUrl:"https://openrouter.ai/api/v1"},{id:"ollama",label:"Ollama (self-hosted)",capabilities:["chat"],defaultModel:"llama3.3"},{id:"openai-compatible",label:"OpenAI-compatible (eigen endpoint)",capabilities:["chat"],defaultModel:"default"}];function c(e){return f.find(n=>n.id===e)}function ue(e){return c(e)?.label??e}function de(e,n="gpt-5-mini"){return c(e)?.defaultModel??n}function pe(e){return f.filter(n=>n.capabilities.includes(e))}function Ee(e){const n=c(e);return!!n&&!n.baseUrl}const fe=new Set(["mail","message"]);function k(e,n){const t=e.settings?.signatures?.[n];return!t||!t.enabled||!t.body||t.body.trim()===""?null:t}function ge(e,n,t,r="html"){if(!e)return t;const a=k(e,n);return a?`${t}${r==="text"?`
2
2
 
3
- `:n==="mail"?"<br><br>-- <br>":"<br><br>"}${a.body}`:t}function ge(e){return e.endpoints??[]}const me=e=>!!e.assignedUserId||!!e.assignedInboxId,Ae=e=>e.status==="closed",Ie=e=>({urgent:10,high:5,normal:2,low:1})[e.priority]||0,_e=(e,n=30)=>e.title?.length<=n?e.title:`${e.title.substring(0,n)}...`;function Se(e,n){return e.lastActivityAt?!(e.seenBy??[]).includes(n):!1}const Me=2e3,be=500,Te=12e3,De=4e3,x=["contact","company"];function he(e){if(!e)return!1;const n=e.slice(0,e.indexOf(":"));return x.includes(n)}const u={NL:{callingCode:"31",trunkPrefix:"0",nsnMin:7,nsnMax:9},BE:{callingCode:"32",trunkPrefix:"0",nsnMin:8,nsnMax:9},LU:{callingCode:"352",nsnMin:6,nsnMax:9},DE:{callingCode:"49",trunkPrefix:"0",nsnMin:6,nsnMax:13},FR:{callingCode:"33",trunkPrefix:"0",nsnMin:9,nsnMax:9},GB:{callingCode:"44",trunkPrefix:"0",nsnMin:9,nsnMax:10},IE:{callingCode:"353",trunkPrefix:"0",nsnMin:7,nsnMax:9},ES:{callingCode:"34",nsnMin:9,nsnMax:9},PT:{callingCode:"351",nsnMin:9,nsnMax:9},IT:{callingCode:"39",nsnMin:6,nsnMax:11},AT:{callingCode:"43",trunkPrefix:"0",nsnMin:7,nsnMax:13},CH:{callingCode:"41",trunkPrefix:"0",nsnMin:9,nsnMax:9},DK:{callingCode:"45",nsnMin:8,nsnMax:8},SE:{callingCode:"46",trunkPrefix:"0",nsnMin:7,nsnMax:13},NO:{callingCode:"47",nsnMin:8,nsnMax:8},FI:{callingCode:"358",trunkPrefix:"0",nsnMin:5,nsnMax:12},PL:{callingCode:"48",nsnMin:9,nsnMax:9},US:{callingCode:"1",nsnMin:10,nsnMax:10},CA:{callingCode:"1",nsnMin:10,nsnMax:10}},$="NL",Ne=15,Re=8,Oe=Array.from(new Set(Object.values(u).map(e=>e.callingCode))).sort((e,n)=>n.length-e.length);function A(e){if(e)return u[e.trim().toUpperCase()]}function l(e,n){return e.length>=n.nsnMin&&e.length<=n.nsnMax}function I(e){if(e.length>Ne)return null;for(const n of Oe){if(!e.startsWith(n))continue;const t=e.slice(n.length);for(const r of Object.values(u)){if(r.callingCode!==n)continue;const a=r.trunkPrefix,i=a&&t.startsWith(a)?t.slice(a.length):t;if(l(i,r))return`+${n}${i}`}return null}return e.length<Re?null:`+${e}`}function Ce(e){let n=e.trim();const t=n.match(/^(sips?|tel|whatsapp):/i);t&&(n=n.slice(t[0].length));const r=n.indexOf("@");return r>=0&&(n=n.slice(0,r)),n.trim()}function Le(e){if(!e)return!1;const n=e.indexOf("@");if(n<=0)return!1;const t=e.slice(0,n).trim();return!/^[+\d\s().-]+$/.test(t)}function E(e,n){if(!e)return null;const t=Ce(e);if(!t)return null;const r=t.startsWith("+"),a=t.replace(/\D/g,"");if(!a)return null;if(r)return I(a);if(a.startsWith("00"))return I(a.slice(2));const i=A(n)??A($);if(!i)return null;const o=i.trunkPrefix;if(o&&a.startsWith(o)){const s=a.slice(o.length);return l(s,i)?`+${i.callingCode}${s}`:null}if(a.startsWith(i.callingCode)){const s=a.slice(i.callingCode.length);if(l(s,i))return`+${i.callingCode}${s}`}return!o&&l(a,i)?`+${i.callingCode}${a}`:null}function ye(e,n=9){const t=(e??"").replace(/\D/g,"");return t.length<n?null:t.slice(-n)}function g(e){if(!e)return null;const n=e.trim().toLowerCase(),t=n.lastIndexOf("@");if(t<=0||t===n.length-1)return null;const r=n.slice(0,t).split("+")[0],a=n.slice(t+1);return!r||!a.includes(".")?null:`${r}@${a}`}function Ue(e){const n=g(e);return n?n.slice(n.lastIndexOf("@")+1):null}const Pe=new Set(["co.uk","org.uk","gov.uk","ac.uk","com.au","co.nz","com.br","co.za"]);function G(e){if(!e)return null;const n=e.trim().toLowerCase().replace(/\.$/,"").split(".").filter(Boolean);if(n.length<2)return null;const t=n.slice(-2).join(".");return Pe.has(t)&&n.length>=3?n.slice(-3).join("."):t}const V=new Set(["gmail.com","googlemail.com","outlook.com","hotmail.com","hotmail.nl","hotmail.be","hotmail.co.uk","live.com","live.nl","live.be","msn.com","yahoo.com","yahoo.co.uk","ymail.com","icloud.com","me.com","mac.com","aol.com","gmx.net","gmx.de","web.de","protonmail.com","proton.me","pm.me","tutanota.com","zoho.com","mail.com","ziggo.nl","kpnmail.nl","planet.nl","home.nl","casema.nl","chello.nl","xs4all.nl","telfort.nl","hetnet.nl","zonnet.nl","upcmail.nl","quicknet.nl","telenet.be","skynet.be","proximus.be","scarlet.be"]);function ke(e){const n=G(e);return n?V.has(n):!1}function xe(e){if(!e)return!1;const n=e.trim().toLowerCase();return n==="tel"||n==="sms"||n==="whatsapp"||n==="fax"}function $e(e,n,t){if(!e||!n)return null;const r=e.trim().toLowerCase();if(r==="tel"||r==="sms"||r==="whatsapp"){const i=E(n,t);return i?`tel:${i}`:null}if(r==="fax"){const i=E(n,t);return i?`fax:${i}`:null}if(r==="mailto"||r==="email"){const i=g(n);return i?`mailto:${i}`:null}const a=n.trim().toLowerCase();return a?`${r}:${a}`:null}const Ge=[/<blockquote/i,/class="?gmail_quote/i,/id="?[^"]*divRplyFwdMsg/i,/id="?[^"]*mail-editor-reference-message-container/i,/-{3,}\s*Original Message\s*-{3,}/i,/\n_{5,}\s*\n/,/\bOn\b[\s\S]{0,200}?\bwrote:/i],_=/^\s*(?:>+\s*)?(?:from|van|sent|verzonden|to|aan|cc|subject|onderwerp|date|datum)\s*:/i,Ve=/^\s*(?:on|op)\b.{0,200}?\b(?:wrote|schreef|geschreven)\s*:?\s*$/i;function we(e){const n=e.split(`
4
- `);for(let t=0;t<n.length;t++)if(Ve.test(n[t])||_.test(n[t])&&n.slice(t+1,t+4).some(r=>_.test(r)))return n.slice(0,t).join(`
3
+ `:n==="mail"?"<br><br>-- <br>":"<br><br>"}${a.body}`:t}function me(e){return e.endpoints??[]}const Ae=e=>!!e.assignedUserId||!!e.assignedInboxId,Ie=e=>e.status==="closed",_e=e=>({urgent:10,high:5,normal:2,low:1})[e.priority]||0,Se=(e,n=30)=>e.title?.length<=n?e.title:`${e.title.substring(0,n)}...`;function Me(e,n){return e.lastActivityAt?!(e.seenBy??[]).includes(n):!1}const be=2e3,Te=500,De=12e3,he=4e3,x=["contact","company"];function Ne(e){if(!e)return!1;const n=e.slice(0,e.indexOf(":"));return x.includes(n)}const u={NL:{callingCode:"31",trunkPrefix:"0",nsnMin:7,nsnMax:9},BE:{callingCode:"32",trunkPrefix:"0",nsnMin:8,nsnMax:9},LU:{callingCode:"352",nsnMin:6,nsnMax:9},DE:{callingCode:"49",trunkPrefix:"0",nsnMin:6,nsnMax:13},FR:{callingCode:"33",trunkPrefix:"0",nsnMin:9,nsnMax:9},GB:{callingCode:"44",trunkPrefix:"0",nsnMin:9,nsnMax:10},IE:{callingCode:"353",trunkPrefix:"0",nsnMin:7,nsnMax:9},ES:{callingCode:"34",nsnMin:9,nsnMax:9},PT:{callingCode:"351",nsnMin:9,nsnMax:9},IT:{callingCode:"39",nsnMin:6,nsnMax:11},AT:{callingCode:"43",trunkPrefix:"0",nsnMin:7,nsnMax:13},CH:{callingCode:"41",trunkPrefix:"0",nsnMin:9,nsnMax:9},DK:{callingCode:"45",nsnMin:8,nsnMax:8},SE:{callingCode:"46",trunkPrefix:"0",nsnMin:7,nsnMax:13},NO:{callingCode:"47",nsnMin:8,nsnMax:8},FI:{callingCode:"358",trunkPrefix:"0",nsnMin:5,nsnMax:12},PL:{callingCode:"48",nsnMin:9,nsnMax:9},US:{callingCode:"1",nsnMin:10,nsnMax:10},CA:{callingCode:"1",nsnMin:10,nsnMax:10}},$="NL",Re=15,Oe=8,Ce=Array.from(new Set(Object.values(u).map(e=>e.callingCode))).sort((e,n)=>n.length-e.length);function A(e){if(e)return u[e.trim().toUpperCase()]}function l(e,n){return e.length>=n.nsnMin&&e.length<=n.nsnMax}function I(e){if(e.length>Re)return null;for(const n of Ce){if(!e.startsWith(n))continue;const t=e.slice(n.length);for(const r of Object.values(u)){if(r.callingCode!==n)continue;const a=r.trunkPrefix,i=a&&t.startsWith(a)?t.slice(a.length):t;if(l(i,r))return`+${n}${i}`}return null}return e.length<Oe?null:`+${e}`}function Le(e){let n=e.trim();const t=n.match(/^(sips?|tel|whatsapp):/i);t&&(n=n.slice(t[0].length));const r=n.indexOf("@");return r>=0&&(n=n.slice(0,r)),n.trim()}function ye(e){if(!e)return!1;const n=e.indexOf("@");if(n<=0)return!1;const t=e.slice(0,n).trim();return!/^[+\d\s().-]+$/.test(t)}function E(e,n){if(!e)return null;const t=Le(e);if(!t)return null;const r=t.startsWith("+"),a=t.replace(/\D/g,"");if(!a)return null;if(r)return I(a);if(a.startsWith("00"))return I(a.slice(2));const i=A(n)??A($);if(!i)return null;const o=i.trunkPrefix;if(o&&a.startsWith(o)){const s=a.slice(o.length);return l(s,i)?`+${i.callingCode}${s}`:null}if(a.startsWith(i.callingCode)){const s=a.slice(i.callingCode.length);if(l(s,i))return`+${i.callingCode}${s}`}return!o&&l(a,i)?`+${i.callingCode}${a}`:null}function Ue(e,n=9){const t=(e??"").replace(/\D/g,"");return t.length<n?null:t.slice(-n)}function g(e){if(!e)return null;const n=e.trim().toLowerCase(),t=n.lastIndexOf("@");if(t<=0||t===n.length-1)return null;const r=n.slice(0,t).split("+")[0],a=n.slice(t+1);return!r||!a.includes(".")?null:`${r}@${a}`}function Pe(e){const n=g(e);return n?n.slice(n.lastIndexOf("@")+1):null}const ke=new Set(["co.uk","org.uk","gov.uk","ac.uk","com.au","co.nz","com.br","co.za"]);function G(e){if(!e)return null;const n=e.trim().toLowerCase().replace(/\.$/,"").split(".").filter(Boolean);if(n.length<2)return null;const t=n.slice(-2).join(".");return ke.has(t)&&n.length>=3?n.slice(-3).join("."):t}const V=new Set(["gmail.com","googlemail.com","outlook.com","hotmail.com","hotmail.nl","hotmail.be","hotmail.co.uk","live.com","live.nl","live.be","msn.com","yahoo.com","yahoo.co.uk","ymail.com","icloud.com","me.com","mac.com","aol.com","gmx.net","gmx.de","web.de","protonmail.com","proton.me","pm.me","tutanota.com","zoho.com","mail.com","ziggo.nl","kpnmail.nl","planet.nl","home.nl","casema.nl","chello.nl","xs4all.nl","telfort.nl","hetnet.nl","zonnet.nl","upcmail.nl","quicknet.nl","telenet.be","skynet.be","proximus.be","scarlet.be"]);function xe(e){const n=G(e);return n?V.has(n):!1}function $e(e){if(!e)return!1;const n=e.trim().toLowerCase();return n==="tel"||n==="sms"||n==="whatsapp"||n==="fax"}function Ge(e,n,t){if(!e||!n)return null;const r=e.trim().toLowerCase();if(r==="tel"||r==="sms"||r==="whatsapp"){const i=E(n,t);return i?`tel:${i}`:null}if(r==="fax"){const i=E(n,t);return i?`fax:${i}`:null}if(r==="mailto"||r==="email"){const i=g(n);return i?`mailto:${i}`:null}const a=n.trim().toLowerCase();return a?`${r}:${a}`:null}const Ve=[/<blockquote/i,/class="?gmail_quote/i,/id="?[^"]*divRplyFwdMsg/i,/id="?[^"]*mail-editor-reference-message-container/i,/-{3,}\s*Original Message\s*-{3,}/i,/\n_{5,}\s*\n/,/\bOn\b[\s\S]{0,200}?\bwrote:/i],_=/^\s*(?:>+\s*)?(?:from|van|sent|verzonden|to|aan|cc|subject|onderwerp|date|datum)\s*:/i,we=/^\s*(?:on|op)\b.{0,200}?\b(?:wrote|schreef|geschreven)\s*:?\s*$/i;function Be(e){const n=e.split(`
4
+ `);for(let t=0;t<n.length;t++)if(we.test(n[t])||_.test(n[t])&&n.slice(t+1,t+4).some(r=>_.test(r)))return n.slice(0,t).join(`
5
5
  `).trim();return e}function S(e){let n=e;return n=n.replace(/<(script|style)[\s\S]*?<\/\1>/gi,""),n=n.replace(/<br\s*\/?>/gi,`
6
6
  `),n=n.replace(/<\/(p|div|li|tr|h[1-6]|ul|ol|table)>/gi,`
7
7
  `),n=n.replace(/<[^>]+>/g,""),n=n.replace(/<[^>]*$/,""),n}function M(e){return e.replace(/&nbsp;/gi," ").replace(/&lt;/gi,"<").replace(/&gt;/gi,">").replace(/&quot;/gi,'"').replace(/&#39;/gi,"'").replace(/&#(\d+);/g,(n,t)=>String.fromCharCode(Number(t))).replace(/&amp;/gi,"&")}function b(e){return e.replace(/\r/g,"").replace(/[ \t]+/g," ").replace(/ *\n */g,`
8
8
  `).replace(/\n{3,}/g,`
9
9
 
10
- `).trim()}function Be(e){if(typeof e!="string"||!e)return"";let n=e.length;for(const i of Ge){const o=e.search(i);o>=0&&o<n&&(n=o)}const t=e.slice(0,n);let r=b(M(S(t)));return r||(r=b(M(S(e)))),we(r)||r}const He=/(^|[._+-])(no-?reply|noreply|donotreply|do-not-reply|newsletter|nieuwsbrief|mailer|mailing|notifications?|bounce|postmaster|marketing)@/i,Fe=/\b(unsubscribe|afmelden|uitschrijven|opt[\s-]?out|manage (your )?preferences|geen (e-?mails?|nieuwsbrief|berichten) meer)\b/i;function ve(e,n){return!!(e&&He.test(e)||n&&Fe.test(n))}const w=3,B=600;function We(e,n){return e>=w||n>=B}function H(e,n){const t=new Set(e.disabledIntents??[]),r=e.intentOverrides??{},a=n.intents.filter(o=>!t.has(o.intent)).map(o=>je(o,r[o.intent]));if(!e.extraIntents||e.extraIntents.length===0)return a;const i=new Set(a.map(o=>o.intent));for(const o of e.extraIntents)i.has(o.intent)||(a.push(o),i.add(o.intent));return a}function F(e,n){const t={};for(const r of e.intents){if(!r.togglable)continue;const a=n?.[r.intent];t[r.intent]=a??r.defaultEnabled??!0}return t}function Ye(e,n){const t=F(e,n);return Object.entries(t).filter(([,r])=>!r).map(([r])=>r)}function je(e,n){return n?{intent:n.intent??e.intent,targetSchemes:n.targetSchemes??e.targetSchemes,transport:n.transport??e.transport}:e}function Ke(e,n){const t=[];for(const r of e){if(!r.enabled)continue;const a=n[r.providerId];if(a)for(const i of H(r,a))t.push({channel:r,description:a,capability:i})}return t}function ze(e,n){return n.filter(t=>t.capability.intent===e)}function v(e,n){return n.filter(t=>t.capability.targetSchemes.includes(e))}function qe(e,n){return v(e.scheme,n)}function Xe(e,n,t){const r=[];for(const a of e)for(const i of t)i.capability.intent===n&&i.capability.targetSchemes.includes(a.scheme)&&r.push({channelIntent:i,endpoint:a});return r}var W=(e=>(e.MAILTO="mailto",e.SIP="sip",e.TEL="tel",e.WEBHOOK="webhook",e.USERNAME="username",e.ID="id",e.CUSTOM="custom",e.URL="url",e.TELEGRAM="telegram",e.WHATSAPP="whatsapp",e.MESSENGER="messenger",e.INSTAGRAM="instagram",e.VIBER="viber",e.SMS="sms",e.FAX="fax",e.TEAMS="teams",e.CALENDAR="calendar",e))(W||{});const Je="message_window",Qe="message_templates",Ze={FROM:"from",TO:"to",CC:"cc",BCC:"bcc",ORGANIZER:"organizer",PRESENTER:"presenter",ATTENDEE:"attendee",OWNER:"owner",MEMBER:"member",GUEST:"guest",HOST:"host",PARTICIPANT:"participant"},en=(e,n)=>({intent:e,...n}),nn="folder_management",tn="remote_search",rn={ok:!1,code:"UNSUPPORTED",message:"Provider does not support this op"},an=9e4,on="installation-id";exports.AI_VENDORS=f;exports.CLASSIFY_VARS=re;exports.CORE_DIMENSIONS=q;exports.CommunicationScheme=W;exports.DEFAULT_MEMORY_BUDGET=De;exports.DEFAULT_PHONE_REGION=$;exports.FEATURE_FOLDER_MANAGEMENT=nn;exports.FEATURE_REMOTE_SEARCH=tn;exports.INSTALLATION_HEADER=on;exports.InteractionParticipantRole=Ze;exports.MAX_MEMORY_BUDGET=Te;exports.MAX_MEMORY_CHARS=Me;exports.MIN_MEMORY_BUDGET=be;exports.PAUSED_RUN_STATUSES=U;exports.PHONE_REGIONS=u;exports.PRESENCE_ONLINE_WINDOW_MS=an;exports.PROVIDER_FEATURE_MESSAGE_TEMPLATES=Qe;exports.PROVIDER_FEATURE_MESSAGE_WINDOW=Je;exports.PUBLIC_EMAIL_DOMAINS=V;exports.RELATED_SUBJECT_KINDS=x;exports.SIGNATURE_INTENTS=Ee;exports.SUMMARY_MIN_LAST_CHARS=B;exports.SUMMARY_MIN_MESSAGES=w;exports.TERMINAL_RUN_STATUSES=y;exports.TRIGGER_VARS=te;exports.UNSUPPORTED=rn;exports.USAGE_DIMENSIONS=N;exports.USAGE_DIMENSION_IDS=R;exports.actingIdentityKey=L;exports.actorKey=oe;exports.aiVendorDefaultModel=ue;exports.aiVendorLabel=ce;exports.aiVendorNeedsBaseUrl=pe;exports.aiVendorsWith=de;exports.applySignature=fe;exports.buildActivityPreview=K;exports.buildChannelIntents=Ke;exports.cleanMessageText=Be;exports.defineIntent=en;exports.disabledIntentsFromCapabilities=Ye;exports.emailDomain=Ue;exports.endpointKey=$e;exports.filterByEndpoint=qe;exports.filterByIntent=ze;exports.filterByTargetScheme=v;exports.findAiVendor=c;exports.flattenLocales=X;exports.floorToPeriod=h;exports.formatActingIdentity=C;exports.formatPeriod=D;exports.getActivitySeenUserIds=z;exports.getContactEndpoints=ge;exports.getShortTitle=_e;exports.getUrgencyScore=Ie;exports.humanizeAction=ne;exports.isAssigned=me;exports.isClosed=Ae;exports.isInteractionUnseen=Se;exports.isLikelyBulk=ve;exports.isPaused=le;exports.isPublicEmailDomain=ke;exports.isRetryable=se;exports.isTerminal=P;exports.isThreadLongEnough=We;exports.looksLikeEmail=Le;exports.matchContactToIntents=Xe;exports.needsPhoneRegion=xe;exports.normalizeEmail=g;exports.parseActingIdentity=ae;exports.periodsInRange=Z;exports.phoneSuffix=ye;exports.playbookActor=ie;exports.registrableDomain=G;exports.relatedByDefault=he;exports.resolveAccountCapabilities=F;exports.resolveChannelIntents=H;exports.resolveSignature=k;exports.stripHtml=T;exports.toE164=E;exports.usageMetricId=O;exports.usageMetrics=ee;
10
+ `).trim()}function He(e){if(typeof e!="string"||!e)return"";let n=e.length;for(const i of Ve){const o=e.search(i);o>=0&&o<n&&(n=o)}const t=e.slice(0,n);let r=b(M(S(t)));return r||(r=b(M(S(e)))),Be(r)||r}const Fe=/(^|[._+-])(no-?reply|noreply|donotreply|do-not-reply|newsletter|nieuwsbrief|mailer|mailing|notifications?|bounce|postmaster|marketing)@/i,ve=/\b(unsubscribe|afmelden|uitschrijven|opt[\s-]?out|manage (your )?preferences|geen (e-?mails?|nieuwsbrief|berichten) meer)\b/i;function We(e,n){return!!(e&&Fe.test(e)||n&&ve.test(n))}const w=3,B=600;function Ye(e,n){return e>=w||n>=B}function H(e,n){const t=new Set(e.disabledIntents??[]),r=e.intentOverrides??{},a=n.intents.filter(o=>!t.has(o.intent)).map(o=>Ke(o,r[o.intent]));if(!e.extraIntents||e.extraIntents.length===0)return a;const i=new Set(a.map(o=>o.intent));for(const o of e.extraIntents)i.has(o.intent)||(a.push(o),i.add(o.intent));return a}function F(e,n){const t={};for(const r of e.intents){if(!r.togglable)continue;const a=n?.[r.intent];t[r.intent]=a??r.defaultEnabled??!0}return t}function je(e,n){const t=F(e,n);return Object.entries(t).filter(([,r])=>!r).map(([r])=>r)}function Ke(e,n){return n?{intent:n.intent??e.intent,targetSchemes:n.targetSchemes??e.targetSchemes,transport:n.transport??e.transport}:e}function ze(e,n){const t=[];for(const r of e){if(!r.enabled)continue;const a=n[r.providerId];if(a)for(const i of H(r,a))t.push({channel:r,description:a,capability:i})}return t}function qe(e,n){return n.filter(t=>t.capability.intent===e)}function v(e,n){return n.filter(t=>t.capability.targetSchemes.includes(e))}function Xe(e,n){return v(e.scheme,n)}function Je(e,n,t){const r=[];for(const a of e)for(const i of t)i.capability.intent===n&&i.capability.targetSchemes.includes(a.scheme)&&r.push({channelIntent:i,endpoint:a});return r}var W=(e=>(e.MAILTO="mailto",e.SIP="sip",e.TEL="tel",e.WEBHOOK="webhook",e.USERNAME="username",e.ID="id",e.CUSTOM="custom",e.URL="url",e.TELEGRAM="telegram",e.WHATSAPP="whatsapp",e.MESSENGER="messenger",e.INSTAGRAM="instagram",e.VIBER="viber",e.SMS="sms",e.FAX="fax",e.TEAMS="teams",e.CALENDAR="calendar",e))(W||{});const Qe="message_window",Ze="message_templates",en={FROM:"from",TO:"to",CC:"cc",BCC:"bcc",ORGANIZER:"organizer",PRESENTER:"presenter",ATTENDEE:"attendee",OWNER:"owner",MEMBER:"member",GUEST:"guest",HOST:"host",PARTICIPANT:"participant"},nn=(e,n)=>({intent:e,...n}),tn="folder_management",rn="remote_search",an={ok:!1,code:"UNSUPPORTED",message:"Provider does not support this op"},on=9e4,sn="installation-id";exports.AI_VENDORS=f;exports.CLASSIFY_VARS=ae;exports.CORE_DIMENSIONS=X;exports.CommunicationScheme=W;exports.DEFAULT_MEMORY_BUDGET=he;exports.DEFAULT_PHONE_REGION=$;exports.FEATURE_FOLDER_MANAGEMENT=tn;exports.FEATURE_REMOTE_SEARCH=rn;exports.INSTALLATION_HEADER=sn;exports.InteractionParticipantRole=en;exports.MAX_MEMORY_BUDGET=De;exports.MAX_MEMORY_CHARS=be;exports.MIN_MEMORY_BUDGET=Te;exports.PAUSED_RUN_STATUSES=U;exports.PHONE_REGIONS=u;exports.PRESENCE_ONLINE_WINDOW_MS=on;exports.PROVIDER_FEATURE_MESSAGE_TEMPLATES=Ze;exports.PROVIDER_FEATURE_MESSAGE_WINDOW=Qe;exports.PUBLIC_EMAIL_DOMAINS=V;exports.RELATED_SUBJECT_KINDS=x;exports.SIGNATURE_INTENTS=fe;exports.SUMMARY_MIN_LAST_CHARS=B;exports.SUMMARY_MIN_MESSAGES=w;exports.TERMINAL_RUN_STATUSES=y;exports.TRIGGER_VARS=re;exports.UNSUPPORTED=an;exports.USAGE_DIMENSIONS=N;exports.USAGE_DIMENSION_IDS=R;exports.actingIdentityKey=L;exports.activityTimestamp=q;exports.actorKey=se;exports.aiVendorDefaultModel=de;exports.aiVendorLabel=ue;exports.aiVendorNeedsBaseUrl=Ee;exports.aiVendorsWith=pe;exports.applySignature=ge;exports.buildActivityPreview=K;exports.buildChannelIntents=ze;exports.cleanMessageText=He;exports.defineIntent=nn;exports.disabledIntentsFromCapabilities=je;exports.emailDomain=Pe;exports.endpointKey=Ge;exports.filterByEndpoint=Xe;exports.filterByIntent=qe;exports.filterByTargetScheme=v;exports.findAiVendor=c;exports.flattenLocales=J;exports.floorToPeriod=h;exports.formatActingIdentity=C;exports.formatPeriod=D;exports.getActivitySeenUserIds=z;exports.getContactEndpoints=me;exports.getShortTitle=Se;exports.getUrgencyScore=_e;exports.humanizeAction=te;exports.isAssigned=Ae;exports.isClosed=Ie;exports.isInteractionUnseen=Me;exports.isLikelyBulk=We;exports.isPaused=ce;exports.isPublicEmailDomain=xe;exports.isRetryable=le;exports.isTerminal=P;exports.isThreadLongEnough=Ye;exports.looksLikeEmail=ye;exports.matchContactToIntents=Je;exports.needsPhoneRegion=$e;exports.normalizeEmail=g;exports.parseActingIdentity=ie;exports.periodsInRange=ee;exports.phoneSuffix=Ue;exports.playbookActor=oe;exports.registrableDomain=G;exports.relatedByDefault=Ne;exports.resolveAccountCapabilities=F;exports.resolveChannelIntents=H;exports.resolveSignature=k;exports.stripHtml=T;exports.toE164=E;exports.usageMetricId=O;exports.usageMetrics=ne;
package/dist/index.js CHANGED
@@ -107,7 +107,10 @@ function se(e, n, t = []) {
107
107
  const a = new Set(t);
108
108
  return e.author.type === "user" && e.author.id && a.add(e.author.id), Object.entries(n).filter(([i, s]) => s >= r && !a.has(i)).map(([i]) => i);
109
109
  }
110
- const oe = [
110
+ function oe(e) {
111
+ return e.createdAt ?? 0;
112
+ }
113
+ const le = [
111
114
  { id: "agent", label: "Agent", labelSource: "user" },
112
115
  { id: "team", label: "Team", labelSource: "team" },
113
116
  { id: "inbox", label: "Inbox", labelSource: "inbox" },
@@ -117,7 +120,7 @@ const oe = [
117
120
  { id: "handledBy", label: "Afhandelaar", labelSource: "raw" },
118
121
  { id: "time", label: "Tijd", labelSource: "raw" }
119
122
  ];
120
- function le(e) {
123
+ function ce(e) {
121
124
  const n = [];
122
125
  for (const t of Object.keys(e))
123
126
  for (const r of Object.keys(e[t]))
@@ -136,7 +139,7 @@ function C(e, n) {
136
139
  return t.setUTCMinutes(0, 0, 0), n === "day" && t.setUTCHours(0), t.getTime();
137
140
  }
138
141
  const O = 36e5, N = 864e5;
139
- function ce(e, n, t) {
142
+ function ue(e, n, t) {
140
143
  const r = t === "hour" ? O : N, a = [];
141
144
  for (let i = C(e, t); i <= n; i += r)
142
145
  a.push(D(i, t));
@@ -149,7 +152,7 @@ const L = [
149
152
  function y(e, n) {
150
153
  return `${e}.usage.${n}`;
151
154
  }
152
- function ue(e, n) {
155
+ function de(e, n) {
153
156
  return n.map((t) => ({
154
157
  id: y(e, t.unit),
155
158
  label: t.label,
@@ -164,10 +167,10 @@ function ue(e, n) {
164
167
  ]
165
168
  }));
166
169
  }
167
- function de(e) {
170
+ function pe(e) {
168
171
  return (e.startsWith("tool:") ? e.slice(5) : e).replace(/__/g, " · ").replace(/\./g, " · ").replace(/_/g, " ");
169
172
  }
170
- const pe = [
173
+ const fe = [
171
174
  { name: "text", type: "string" },
172
175
  { name: "subject", type: "string" },
173
176
  { name: "from", type: "string" },
@@ -190,7 +193,7 @@ const pe = [
190
193
  // een nieuw adres) — een stap die hierop leunt hoort dus een `condition` te hebben.
191
194
  { name: "contactId", type: "string" },
192
195
  { name: "companyId", type: "string" }
193
- ], fe = {
196
+ ], ge = {
194
197
  topics: [
195
198
  { name: "topic", type: "string" },
196
199
  { name: "confidence", type: "number" }
@@ -211,7 +214,7 @@ function k(e) {
211
214
  return "org";
212
215
  }
213
216
  }
214
- function ge(e) {
217
+ function Ee(e) {
215
218
  if (typeof e != "string") return;
216
219
  const n = e.trim();
217
220
  if (n === "org") return { kind: "org" };
@@ -226,7 +229,7 @@ function ge(e) {
226
229
  function x(e) {
227
230
  return k(e);
228
231
  }
229
- function Ee(e) {
232
+ function me(e) {
230
233
  switch (e.kind) {
231
234
  case "personal":
232
235
  return { kind: "user", userId: e.userId };
@@ -236,14 +239,14 @@ function Ee(e) {
236
239
  return { kind: "org" };
237
240
  }
238
241
  }
239
- function me(e) {
242
+ function be(e) {
240
243
  return x(e);
241
244
  }
242
245
  const U = ["done", "escalated", "failed", "timed_out", "stopped"], P = ["awaiting_approval", "awaiting_reply"];
243
246
  function $(e) {
244
247
  return U.includes(e);
245
248
  }
246
- function be(e) {
249
+ function Ae(e) {
247
250
  return $(e);
248
251
  }
249
252
  function Ie(e) {
@@ -340,45 +343,45 @@ const _ = [
340
343
  function d(e) {
341
344
  return _.find((n) => n.id === e);
342
345
  }
343
- function Ae(e) {
346
+ function _e(e) {
344
347
  return d(e)?.label ?? e;
345
348
  }
346
- function _e(e, n = "gpt-5-mini") {
349
+ function Me(e, n = "gpt-5-mini") {
347
350
  return d(e)?.defaultModel ?? n;
348
351
  }
349
- function Me(e) {
352
+ function Se(e) {
350
353
  return _.filter((n) => n.capabilities.includes(e));
351
354
  }
352
- function Se(e) {
355
+ function Te(e) {
353
356
  const n = d(e);
354
357
  return !!n && !n.baseUrl;
355
358
  }
356
- const Te = /* @__PURE__ */ new Set(["mail", "message"]);
359
+ const he = /* @__PURE__ */ new Set(["mail", "message"]);
357
360
  function w(e, n) {
358
361
  const t = e.settings?.signatures?.[n];
359
362
  return !t || !t.enabled || !t.body || t.body.trim() === "" ? null : t;
360
363
  }
361
- function he(e, n, t, r = "html") {
364
+ function De(e, n, t, r = "html") {
362
365
  if (!e) return t;
363
366
  const a = w(e, n);
364
367
  return a ? `${t}${r === "text" ? `
365
368
 
366
369
  ` : n === "mail" ? "<br><br>-- <br>" : "<br><br>"}${a.body}` : t;
367
370
  }
368
- function De(e) {
371
+ function Ce(e) {
369
372
  return e.endpoints ?? [];
370
373
  }
371
- const Ce = (e) => !!e.assignedUserId || !!e.assignedInboxId, Oe = (e) => e.status === "closed", Ne = (e) => ({
374
+ const Oe = (e) => !!e.assignedUserId || !!e.assignedInboxId, Ne = (e) => e.status === "closed", Le = (e) => ({
372
375
  urgent: 10,
373
376
  high: 5,
374
377
  normal: 2,
375
378
  low: 1
376
- })[e.priority] || 0, Le = (e, n = 30) => e.title?.length <= n ? e.title : `${e.title.substring(0, n)}...`;
377
- function Re(e, n) {
379
+ })[e.priority] || 0, Re = (e, n = 30) => e.title?.length <= n ? e.title : `${e.title.substring(0, n)}...`;
380
+ function ye(e, n) {
378
381
  return e.lastActivityAt ? !(e.seenBy ?? []).includes(n) : !1;
379
382
  }
380
- const ye = 2e3, ke = 500, xe = 12e3, Ue = 4e3, G = ["contact", "company"];
381
- function Pe(e) {
383
+ const ke = 2e3, xe = 500, Ue = 12e3, Pe = 4e3, G = ["contact", "company"];
384
+ function $e(e) {
382
385
  if (!e) return !1;
383
386
  const n = e.slice(0, e.indexOf(":"));
384
387
  return G.includes(n);
@@ -437,7 +440,7 @@ function v(e) {
437
440
  const r = n.indexOf("@");
438
441
  return r >= 0 && (n = n.slice(0, r)), n.trim();
439
442
  }
440
- function $e(e) {
443
+ function we(e) {
441
444
  if (!e) return !1;
442
445
  const n = e.indexOf("@");
443
446
  if (n <= 0) return !1;
@@ -465,7 +468,7 @@ function E(e, n) {
465
468
  }
466
469
  return !s && l(a, i) ? `+${i.callingCode}${a}` : null;
467
470
  }
468
- function we(e, n = 9) {
471
+ function Ge(e, n = 9) {
469
472
  const t = (e ?? "").replace(/\D/g, "");
470
473
  return t.length < n ? null : t.slice(-n);
471
474
  }
@@ -476,7 +479,7 @@ function M(e) {
476
479
  const r = n.slice(0, t).split("+")[0], a = n.slice(t + 1);
477
480
  return !r || !a.includes(".") ? null : `${r}@${a}`;
478
481
  }
479
- function Ge(e) {
482
+ function Ve(e) {
480
483
  const n = M(e);
481
484
  return n ? n.slice(n.lastIndexOf("@") + 1) : null;
482
485
  }
@@ -542,16 +545,16 @@ const K = /* @__PURE__ */ new Set([
542
545
  "proximus.be",
543
546
  "scarlet.be"
544
547
  ]);
545
- function Ve(e) {
548
+ function He(e) {
546
549
  const n = j(e);
547
550
  return n ? K.has(n) : !1;
548
551
  }
549
- function He(e) {
552
+ function Be(e) {
550
553
  if (!e) return !1;
551
554
  const n = e.trim().toLowerCase();
552
555
  return n === "tel" || n === "sms" || n === "whatsapp" || n === "fax";
553
556
  }
554
- function Be(e, n, t) {
557
+ function Fe(e, n, t) {
555
558
  if (!e || !n) return null;
556
559
  const r = e.trim().toLowerCase();
557
560
  if (r === "tel" || r === "sms" || r === "whatsapp") {
@@ -598,16 +601,16 @@ function b(e) {
598
601
  `), n = n.replace(/<\/(p|div|li|tr|h[1-6]|ul|ol|table)>/gi, `
599
602
  `), n = n.replace(/<[^>]+>/g, ""), n = n.replace(/<[^>]*$/, ""), n;
600
603
  }
601
- function I(e) {
604
+ function A(e) {
602
605
  return e.replace(/&nbsp;/gi, " ").replace(/&lt;/gi, "<").replace(/&gt;/gi, ">").replace(/&quot;/gi, '"').replace(/&#39;/gi, "'").replace(/&#(\d+);/g, (n, t) => String.fromCharCode(Number(t))).replace(/&amp;/gi, "&");
603
606
  }
604
- function A(e) {
607
+ function I(e) {
605
608
  return e.replace(/\r/g, "").replace(/[ \t]+/g, " ").replace(/ *\n */g, `
606
609
  `).replace(/\n{3,}/g, `
607
610
 
608
611
  `).trim();
609
612
  }
610
- function Fe(e) {
613
+ function ve(e) {
611
614
  if (typeof e != "string" || !e) return "";
612
615
  let n = e.length;
613
616
  for (const i of Y) {
@@ -615,15 +618,15 @@ function Fe(e) {
615
618
  s >= 0 && s < n && (n = s);
616
619
  }
617
620
  const t = e.slice(0, n);
618
- let r = A(I(b(t)));
619
- return r || (r = A(I(b(e)))), q(r) || r;
621
+ let r = I(A(b(t)));
622
+ return r || (r = I(A(b(e)))), q(r) || r;
620
623
  }
621
624
  const X = /(^|[._+-])(no-?reply|noreply|donotreply|do-not-reply|newsletter|nieuwsbrief|mailer|mailing|notifications?|bounce|postmaster|marketing)@/i, J = /\b(unsubscribe|afmelden|uitschrijven|opt[\s-]?out|manage (your )?preferences|geen (e-?mails?|nieuwsbrief|berichten) meer)\b/i;
622
- function ve(e, n) {
625
+ function We(e, n) {
623
626
  return !!(e && X.test(e) || n && J.test(n));
624
627
  }
625
628
  const Q = 3, Z = 600;
626
- function We(e, n) {
629
+ function je(e, n) {
627
630
  return e >= Q || n >= Z;
628
631
  }
629
632
  function ee(e, n) {
@@ -643,7 +646,7 @@ function ne(e, n) {
643
646
  }
644
647
  return t;
645
648
  }
646
- function je(e, n) {
649
+ function Ke(e, n) {
647
650
  const t = ne(e, n);
648
651
  return Object.entries(t).filter(([, r]) => !r).map(([r]) => r);
649
652
  }
@@ -654,7 +657,7 @@ function te(e, n) {
654
657
  transport: n.transport ?? e.transport
655
658
  } : e;
656
659
  }
657
- function Ke(e, n) {
660
+ function Ye(e, n) {
658
661
  const t = [];
659
662
  for (const r of e) {
660
663
  if (!r.enabled) continue;
@@ -665,16 +668,16 @@ function Ke(e, n) {
665
668
  }
666
669
  return t;
667
670
  }
668
- function Ye(e, n) {
671
+ function ze(e, n) {
669
672
  return n.filter((t) => t.capability.intent === e);
670
673
  }
671
674
  function re(e, n) {
672
675
  return n.filter((t) => t.capability.targetSchemes.includes(e));
673
676
  }
674
- function ze(e, n) {
677
+ function qe(e, n) {
675
678
  return re(e.scheme, n);
676
679
  }
677
- function qe(e, n, t) {
680
+ function Xe(e, n, t) {
678
681
  const r = [];
679
682
  for (const a of e)
680
683
  for (const i of t)
@@ -682,7 +685,7 @@ function qe(e, n, t) {
682
685
  return r;
683
686
  }
684
687
  var ae = /* @__PURE__ */ ((e) => (e.MAILTO = "mailto", e.SIP = "sip", e.TEL = "tel", e.WEBHOOK = "webhook", e.USERNAME = "username", e.ID = "id", e.CUSTOM = "custom", e.URL = "url", e.TELEGRAM = "telegram", e.WHATSAPP = "whatsapp", e.MESSENGER = "messenger", e.INSTAGRAM = "instagram", e.VIBER = "viber", e.SMS = "sms", e.FAX = "fax", e.TEAMS = "teams", e.CALENDAR = "calendar", e))(ae || {});
685
- const Xe = "message_window", Je = "message_templates", Qe = {
688
+ const Je = "message_window", Qe = "message_templates", Ze = {
686
689
  // E-mail
687
690
  FROM: "from",
688
691
  TO: "to",
@@ -699,87 +702,88 @@ const Xe = "message_window", Je = "message_templates", Qe = {
699
702
  // Voice/conference
700
703
  HOST: "host",
701
704
  PARTICIPANT: "participant"
702
- }, Ze = (e, n) => ({ intent: e, ...n }), en = "folder_management", nn = "remote_search", tn = { ok: !1, code: "UNSUPPORTED", message: "Provider does not support this op" }, rn = 9e4, an = "installation-id";
705
+ }, en = (e, n) => ({ intent: e, ...n }), nn = "folder_management", tn = "remote_search", rn = { ok: !1, code: "UNSUPPORTED", message: "Provider does not support this op" }, an = 9e4, sn = "installation-id";
703
706
  export {
704
707
  _ as AI_VENDORS,
705
- fe as CLASSIFY_VARS,
706
- oe as CORE_DIMENSIONS,
708
+ ge as CLASSIFY_VARS,
709
+ le as CORE_DIMENSIONS,
707
710
  ae as CommunicationScheme,
708
- Ue as DEFAULT_MEMORY_BUDGET,
711
+ Pe as DEFAULT_MEMORY_BUDGET,
709
712
  V as DEFAULT_PHONE_REGION,
710
- en as FEATURE_FOLDER_MANAGEMENT,
711
- nn as FEATURE_REMOTE_SEARCH,
712
- an as INSTALLATION_HEADER,
713
- Qe as InteractionParticipantRole,
714
- xe as MAX_MEMORY_BUDGET,
715
- ye as MAX_MEMORY_CHARS,
716
- ke as MIN_MEMORY_BUDGET,
713
+ nn as FEATURE_FOLDER_MANAGEMENT,
714
+ tn as FEATURE_REMOTE_SEARCH,
715
+ sn as INSTALLATION_HEADER,
716
+ Ze as InteractionParticipantRole,
717
+ Ue as MAX_MEMORY_BUDGET,
718
+ ke as MAX_MEMORY_CHARS,
719
+ xe as MIN_MEMORY_BUDGET,
717
720
  P as PAUSED_RUN_STATUSES,
718
721
  p as PHONE_REGIONS,
719
- rn as PRESENCE_ONLINE_WINDOW_MS,
720
- Je as PROVIDER_FEATURE_MESSAGE_TEMPLATES,
721
- Xe as PROVIDER_FEATURE_MESSAGE_WINDOW,
722
+ an as PRESENCE_ONLINE_WINDOW_MS,
723
+ Qe as PROVIDER_FEATURE_MESSAGE_TEMPLATES,
724
+ Je as PROVIDER_FEATURE_MESSAGE_WINDOW,
722
725
  K as PUBLIC_EMAIL_DOMAINS,
723
726
  G as RELATED_SUBJECT_KINDS,
724
- Te as SIGNATURE_INTENTS,
727
+ he as SIGNATURE_INTENTS,
725
728
  Z as SUMMARY_MIN_LAST_CHARS,
726
729
  Q as SUMMARY_MIN_MESSAGES,
727
730
  U as TERMINAL_RUN_STATUSES,
728
- pe as TRIGGER_VARS,
729
- tn as UNSUPPORTED,
731
+ fe as TRIGGER_VARS,
732
+ rn as UNSUPPORTED,
730
733
  L as USAGE_DIMENSIONS,
731
734
  R as USAGE_DIMENSION_IDS,
732
735
  x as actingIdentityKey,
733
- me as actorKey,
734
- _e as aiVendorDefaultModel,
735
- Ae as aiVendorLabel,
736
- Se as aiVendorNeedsBaseUrl,
737
- Me as aiVendorsWith,
738
- he as applySignature,
736
+ oe as activityTimestamp,
737
+ be as actorKey,
738
+ Me as aiVendorDefaultModel,
739
+ _e as aiVendorLabel,
740
+ Te as aiVendorNeedsBaseUrl,
741
+ Se as aiVendorsWith,
742
+ De as applySignature,
739
743
  ie as buildActivityPreview,
740
- Ke as buildChannelIntents,
741
- Fe as cleanMessageText,
742
- Ze as defineIntent,
743
- je as disabledIntentsFromCapabilities,
744
- Ge as emailDomain,
745
- Be as endpointKey,
746
- ze as filterByEndpoint,
747
- Ye as filterByIntent,
744
+ Ye as buildChannelIntents,
745
+ ve as cleanMessageText,
746
+ en as defineIntent,
747
+ Ke as disabledIntentsFromCapabilities,
748
+ Ve as emailDomain,
749
+ Fe as endpointKey,
750
+ qe as filterByEndpoint,
751
+ ze as filterByIntent,
748
752
  re as filterByTargetScheme,
749
753
  d as findAiVendor,
750
- le as flattenLocales,
754
+ ce as flattenLocales,
751
755
  C as floorToPeriod,
752
756
  k as formatActingIdentity,
753
757
  D as formatPeriod,
754
758
  se as getActivitySeenUserIds,
755
- De as getContactEndpoints,
756
- Le as getShortTitle,
757
- Ne as getUrgencyScore,
758
- de as humanizeAction,
759
- Ce as isAssigned,
760
- Oe as isClosed,
761
- Re as isInteractionUnseen,
762
- ve as isLikelyBulk,
759
+ Ce as getContactEndpoints,
760
+ Re as getShortTitle,
761
+ Le as getUrgencyScore,
762
+ pe as humanizeAction,
763
+ Oe as isAssigned,
764
+ Ne as isClosed,
765
+ ye as isInteractionUnseen,
766
+ We as isLikelyBulk,
763
767
  Ie as isPaused,
764
- Ve as isPublicEmailDomain,
765
- be as isRetryable,
768
+ He as isPublicEmailDomain,
769
+ Ae as isRetryable,
766
770
  $ as isTerminal,
767
- We as isThreadLongEnough,
768
- $e as looksLikeEmail,
769
- qe as matchContactToIntents,
770
- He as needsPhoneRegion,
771
+ je as isThreadLongEnough,
772
+ we as looksLikeEmail,
773
+ Xe as matchContactToIntents,
774
+ Be as needsPhoneRegion,
771
775
  M as normalizeEmail,
772
- ge as parseActingIdentity,
773
- ce as periodsInRange,
774
- we as phoneSuffix,
775
- Ee as playbookActor,
776
+ Ee as parseActingIdentity,
777
+ ue as periodsInRange,
778
+ Ge as phoneSuffix,
779
+ me as playbookActor,
776
780
  j as registrableDomain,
777
- Pe as relatedByDefault,
781
+ $e as relatedByDefault,
778
782
  ne as resolveAccountCapabilities,
779
783
  ee as resolveChannelIntents,
780
784
  w as resolveSignature,
781
785
  S as stripHtml,
782
786
  E as toE164,
783
787
  y as usageMetricId,
784
- ue as usageMetrics
788
+ de as usageMetrics
785
789
  };
@@ -36,7 +36,13 @@ export type ServiceHandlerMetadata<P = any, T = any, R = any> = {
36
36
  appId: string;
37
37
  fn: ServiceHandlerFn<P, T, R>;
38
38
  };
39
- export type ServiceCallOptions<P, T> = {
39
+ /**
40
+ * `T` defaults to `unknown` because most handlers only care about `params`.
41
+ * Spelling it `never` instead makes the handler unassignable to
42
+ * {@link ServiceHandlerFn} (whose `payload` is `any`), which is a confusing error
43
+ * for a service that simply takes no payload.
44
+ */
45
+ export type ServiceCallOptions<P, T = unknown> = {
40
46
  params?: P;
41
47
  payload?: T;
42
48
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencxh/domain",
3
- "version": "1.130.0",
3
+ "version": "1.131.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -19,9 +19,9 @@
19
19
  "rxjs": "^7.8.2"
20
20
  },
21
21
  "devDependencies": {
22
- "typescript": "^5.2.2",
22
+ "typescript": "6.0.3",
23
23
  "vite": "7.1.7",
24
- "vite-plugin-dts": "^4.5.4",
24
+ "vite-plugin-dts": "^5.0.3",
25
25
  "vitest": "^4.0.18"
26
26
  }
27
27
  }