1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3191],{72461:(e,t,r)=>{r.d(t,{H_:()=>o,mH:()=>n,mm:()=>a});let a={male:{english:{provider:"11labs",voiceId:"uju3wxzG5OhpWcoi3SMy"},spanish:{provider:"azure",voiceId:"es-ES-NilNeural"},french:{provider:"azure",voiceId:"fr-FR-ClaudeNeural"},portuguese:{provider:"azure",voiceId:"pt-BR-AntonioNeural"},polish:{provider:"11labs",voiceId:"zzBTsLBFM6AOJtkr1e9b"},chinese:{provider:"azure",voiceId:"zh-CN-henan-YundengNeural"}},female:{english:{provider:"11labs",voiceId:"YY7fzZmDizFQQv8XPAIY"},spanish:{provider:"azure",voiceId:"es-ES-ElviraNeural"},french:{provider:"azure",voiceId:"fr-FR-CoralieNeural"},portuguese:{provider:"azure",voiceId:"pt-BR-LeticiaNeural"},polish:{provider:"11labs",voiceId:"Pid5DJleNF2sxsuF6YKD"},chinese:{provider:"azure",voiceId:"zh-CN-XiaoyiNeural"}}},o={male:"male",female:"female"},n={english:"english",spanish:"spanish",french:"french",portuguese:"portuguese",polish:"polish",chinese:"chinese"}},72847:(e,t,r)=>{r.d(t,{O:()=>a});let a="outbound"},45353:(e,t,r)=>{r.d(t,{d:()=>c,z:()=>l});var a=r(57437),o=r(2265),n=r(23951),i=r(70131),s=r(52497);let c=(0,i.j)("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),l=o.forwardRef((e,t)=>{let{className:r,variant:o,size:i,asChild:l=!1,...d}=e,u=l?n.g7:"button";return(0,a.jsx)(u,{className:(0,s.cn)(c({variant:o,size:i,className:r})),ref:t,...d})});l.displayName="Button"},7702:(e,t,r)=>{r.d(t,{Ol:()=>s,SZ:()=>l,Zb:()=>i,aY:()=>d,eW:()=>u,ll:()=>c});var a=r(57437),o=r(2265),n=r(52497);let i=o.forwardRef((e,t)=>{let{className:r,...o}=e;return(0,a.jsx)("div",{ref:t,className:(0,n.cn)("rounded-lg border bg-card text-card-foreground shadow-sm",r),...o})});i.displayName="Card";let s=o.forwardRef((e,t)=>{let{className:r,...o}=e;return(0,a.jsx)("div",{ref:t,className:(0,n.cn)("flex flex-col space-y-1.5 p-6",r),...o})});s.displayName="CardHeader";let c=o.forwardRef((e,t)=>{let{className:r,...o}=e;return(0,a.jsx)("h3",{ref:t,className:(0,n.cn)("text-2xl font-semibold leading-none tracking-tight",r),...o})});c.displayName="CardTitle";let l=o.forwardRef((e,t)=>{let{className:r,...o}=e;return(0,a.jsx)("p",{ref:t,className:(0,n.cn)("text-sm text-muted-foreground",r),...o})});l.displayName="CardDescription";let d=o.forwardRef((e,t)=>{let{className:r,...o}=e;return(0,a.jsx)("div",{ref:t,className:(0,n.cn)("p-6 pt-0",r),...o})});d.displayName="CardContent";let u=o.forwardRef((e,t)=>{let{className:r,...o}=e;return(0,a.jsx)("div",{ref:t,className:(0,n.cn)("flex items-center p-6 pt-0",r),...o})});u.displayName="CardFooter"},97149:(e,t,r)=>{r.d(t,{I:()=>i});var a=r(57437),o=r(2265),n=r(52497);let i=o.forwardRef((e,t)=>{let{className:r,type:o,...i}=e;return(0,a.jsx)("input",{type:o,className:(0,n.cn)("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm r
1ing-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",r),ref:t,...i})});i.displayName="Input"},35639:(e,t,r)=>{r.d(t,{QA:()=>l,T$:()=>s,cM:()=>u,hf:()=>c,jW:()=>d,pY:()=>i,sr:()=>p,wY:()=>n,xH:()=>o});var a=r(82855);let o=e=>{try{if(!e)return 0;let t=e.indexOf("{");if(-1===t)return 0;let r=e.substring(t,e.lastIndexOf("}")+1),a=JSON.parse(r);if(!a.evaluation||!a.evaluation.criteria_scores||!Array.isArray(a.evaluation.criteria_scores))return 0;let o=a.evaluation.criteria_scores,n=o.reduce((e,t)=>e+(t.score||0),0),i=5*o.length;return n/i*100}catch(e){return 0}},n=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"30d",r=e.map(e=>({...e,normalizedScore:o(e.successEvaluation)})).reduce((e,t)=>{let r=new Date(t.endedAt).toISOString().split("T")[0];return e[r]||(e[r]={totalScore:0,count:0}),e[r].totalScore+=t.normalizedScore,e[r].count+=1,e},{});return(function(e){let t=new Date,r=90;"30d"===e?r=30:"7d"===e&&(r=7);let a=new Date(t);a.setDate(t.getDate()-r);let o=[],n=new Date(a);for(;n<=t;)o.push(n.toISOString().split("T")[0]),n.setDate(n.getDate()+1);return o}
1)(t).map(e=>{let t=new Date(e).getTime(),a=r[e];return{date:t,normalizedScore:a?Math.round(a.totalScore/a.count):0,callCount:a?a.count:0}})},i=(e,t)=>t?e.filter(e=>e.userId===t):e,s=(e,t)=>t?e.filter(e=>t.includes(e.userId)):e,c=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"30d",r=e.map(e=>({...e,normalizedScore:o(e.successEvaluation)})).reduce((e,t)=>{let r=new Date(t.endedAt),{year:o,week:n}=(0,a.uW)(r),i="".concat(o,"-W").concat(n.toString().padStart(2,"0"));return e[i]||(e[i]={totalScore:0,count:0}),e[i].totalScore+=t.normalizedScore,e[i].count+=1,e},{});return(function(e){let t=new Date,r=90;"30d"===e?r=30:"7d"===e&&(r=7);let o=new Date(t);o.setDate(t.getDate()-r);let n=[],i=new Date(o);for(;i<=t;){let{year:e,week:t}=(0,a.uW)(i),r="".concat(e,"-W").concat(t.toString().padStart(2,"0"));n.includes(r)||n.push(r),i.setDate(i.getDate()+1)}return n.sort()})(t).map(e=>{var t;return{week:e,normalizedScore:r[e]?Math.round(r[e].totalScore/r[e].count):0,callCount:(null===(t=r[e])||void 0===t?void 0:t.count)||0}})},l=(e,t,r)=>{if(!e.length)return[];let a=t.filter(e=>{var t;return null===(t=e.publicUserData)||void 0===t?void 0:t.userId}).map(t=>{var r,a,n;let i=null===(r=t.publicUserData)||void 0===r?void 0:r.userId,s="".concat((null===(a=t.publicUserData)||void 0===a?void 0:a.firstName)||""," ").concat((null===(n=t.publicUserData)||void 0===n?void 0:n.lastName)||"").trim()||"Unknown Member",c=e.filter(e=>e.userId===i).map(e=>o(e.successEvaluation)).filter(e=>!isNaN(e)),l=c.length>0?c.reduce((e,t)=>e+t,0)/c.length:0;return{label:s,value:i,score:isFinite(l)?l:0,type:"member"}}).sort((e,t)=>e.score-t.score),n=e.map(e=>o(e.successEvaluation)).filter(e=>!isNaN(e)),i=n.length>0?n.reduce((e,t)=>e+t,0)/n.length:0;return[...a,{label:"".concat(r," Average"),score:isFinite(i)?i:0,type:"org-average"}]},d=(e,t,r,a,n)=>{if(!e.length)return[];let i=t.map(t=>{let n=r.filter(e=>a.some(r=>{var a;return r.group_id===t.group_id&&r.user_id===(null===(a=e.publicUserData)||void 0===a?void 0:a.userId)})).map(e=>{var t;return null===(t=e.publicUserData)||void 0===t?void 0:t.userId}).filter(Boolean),i=e.filter(e=>n.includes(e.userId)).map(e=>o(e.successEvaluation)).filter(e=>!isNaN(e)),s=i.length>0?i.reduce((e,t)=>e+t,0)/i.length:0;return{label:t.groupName||"Unknown Group",value:t.group_id,score:isFinite(s)?s:0,type:"group"}}).sort((e,t)=>e.score-t.score),s=e.map(e=>o(e.successEvaluation)).filter(e=>!isNaN(e)),c=s.length>0?s.reduce((e,t)=>e+t,0)/s.length:0;return[...i,{label:"".concat(n," Average"),score:isFinite(c)?c:0,type:"org-average"}]},u=e=>{let t=new Date,r=new Date(t.getFullYear(),t.getMonth(),t.getDate()),a=new Date(r);switch(e){case"7d":a.setDate(a.getDate()-6);break;case"30d":a.setDate(a.getDate()-29);break;case"90d":a.setDate(a.getDate()-89)}let o=a.getTime(),n=r.getTime();if(isNaN(o)||isNaN(n)){let e=new Date,t=new Date(e);return t.setDate(t.getDate()-30),[t.getTime(),e.getTime()]}return[o,n]},p=e=>{if(!e.length)return 0;let t=e.map(e=>o(e.successEvaluation)).filter(e=>!isNaN(e)),r=t.length>0?t.reduce((e,t)=>e+t,0)/t.length:0;return isFinite(r)?r:0}},82855:(e,t,r)=>{function a(e,t){return e.filter(e=>{let r=new Date(e.endedAt),a=new Date,o=90;"30d"===t?o=30:"7d"===t&&(o=7);let n=new Date(a);return n.setDate(a.getDate()-o),Date.UTC(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate())>=Date.UTC(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate())})}function o(e,t){if(e.length<=t)return[e];let r=e.split(" "),a=[],o="";for(let e of r)if((o+(o?" ":"")+e).length<=t)o+=(o?" ":"")+e;else if(o&&a.push(o),e.length>t){for(let r=0;r<e.length;r+=t)a.push(e.substring(r,r+t));o=""}else o=e;return o&&a.push(o),a}function n(e,t,r,a){let o="for";return("Number of Calls Completed"===e&&(o="by"),t&&r)?"".concat(e," ").concat(o," ").concat(r):a?"".concat(e," ").concat(o," ").concat(a):e}function i(e,t,r,a,o){let n=(()=>{switch(e){case"Number of Calls Completed":return"Total calls completed per day";case"Number of Calls Completed vs Organization":return"Total calls completed vs. other members";case"Average Score":return"Average score by day";case"Average Score by Scorecard Assignment":return"Average score for each scorecard assignment";case"Average Score vs Organization":return"Average score vs. other members";default:return e}})();return"".concat(n).concat(o&&"all"!==o?" for the selected scenario":" for all calls")}function s(e){let t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())),r=t.getUTCDay();t.setUTCDate(t.getUTCDate()-r);let a=new Date(Date.UTC(t.getUTCFullYear(),0,1)),o=Math.ceil(((t.getTime()-a.getTime())/864e5+1)/7);return{year:t.getUTCFullYear(),week:o}}r.d(t,{G7:()=>a,IK:()=>n,_X:()=>o,gd:()=>i,uW:()=>s})},45645:(e,t,r)=>{r.d(t,{k:()=>a});let a="https://persona-difficulty-hotfix.syrenn.pages.dev"},9225:(e,t,r)=>{r.d(t,{d:()=>o,s:()=>a});let a={COMPANY_SCRAPER_PERSONA_DATA:"companyScraperPersonaData",COMPANY_SCRAPER_PRODUCT_DATA:"companyScraperProductData",PREVIEW_SCENARIO:"previewScenario",SMART_SCENARIO_INPUT:"smartSce
1narioInput",GENERATED_SCENARIO_INPUT:"generatedScenarioInput",VAPI_CALL_ID:"vapi_call_id"},o={COMPANY_SCRAPER_GENERATIONS:"company-scraper-generations"}},18497:(e,t,r)=>{r.d(t,{J:()=>a});let a="org_2qP6J8Au9LQ2QFkkDTUCnaiuK2e"},28126:(e,t,r)=>{r.d(t,{cr:()=>o});let a={"gemini-eval":{name:"gemini-eval",enabled:!0},"live-call":{name:"live-call",enabled:!0}};function o(e,t,r){let o=a[e],n=t&&""!==t.trim()?t:void 0,i=r&&""!==r.trim()?r:void 0;return!!o&&!!o.enabled&&!!(!o.userIds&&!o.orgIds||o.userIds&&n&&o.userIds.includes(n)||o.orgIds&&i&&o.orgIds.includes(i))}},75078:(e,t,r)=>{r.d(t,{l:()=>a});let a=()=>Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)},22535:(e,t,r)=>{r.d(t,{e:()=>i});var a=r(24162),o=r(36397);let n=["user_2q8G9z1zRvbB9TXuJWzitpQ4CwK","user_2q8HG0iSQxuT3PmY3mwHx5Hema1","user_2ozSPknPPRsZHYfuKsFPaR0AvaM","user_2otGFMAy98ulkl7sZg8TyxpZ8om","user_2xK3dFoDyD4RveJRRgNM9n87drF","user_2xPTnUGZ05O3LuInGWdjgtmQxDd"],i=()=>{let{guestId:e,orgRole:t,hasFreeTrial:r}=(0,a.H)(),{hasBusinessPlan:i,hasPersonalPlan:s,hasPaidPlan:c,hasPilotPlan:l,isLicensed:d,billingAdminHasBusinessPlan:u}=(0,o.Z)(),p=()=>n.includes(e||""),g=()=>!e,m=()=>!g()&&!0===d,h=()=>!g()&&"org:member"===t,f=()=>h()||"org:admin"===t?!g()&&(!0===u||l):!g()&&(i||l);return{isVisitor:g,isFreeTrial:()=>!g()&&r&&!c&&!l,isExpiredFreeTrial:()=>!g()&&!c&&!r&&!h()&&!l&&!f(),isFreeTrialOrPersonalPlan:()=>!g()&&(s||r)&&!i&&!l&&!h(),isPersonalPlan:()=>!g()&&s&&!i&&!l,isBusinessPlan:f,isBusinessMember:()=>f()&&h()&&m(),isNonLicensedBusinessMember:()=>f()&&h()&&!m(),isBusinessAdmin:()=>f()&&"org:admin"===t&&m()||p(),isNonLicensedBusinessAdmin:()=>f()&&"org:admin"===t&&!m(),isBusinessPersonal:()=>f()&&"personal"===t&&m(),isNonLicensedBusinessPersonal:()=>f()&&"personal"===t&&!m(),isFreeLoadingOrgMember:()=>!g()&&h()&&!f()&&!l,isOrgMember:h,hasActiveLicense:m,isPersonal:()=>!g()&&s&&!i&&!l,isSuperAdmin:p}}},83898:(e,t,r)=>{r.d(t,{D0:()=>d,P8:()=>n,R6:()=>s,Zj:()=>i,ty:()=>l,v_:()=>u,xj:()=>c});var a=r(35639),o=r(12769);let n=[{value:"website-email-content",label:"Website/Email/Content Engagement"},{value:"event-follow-up",label:"Event Follow-Up"},{value:"referral",label:"Referral"},{value:"past-customer",label:"Past Customer"}],i=function(e,t,r,a,o){let n=arguments.length>5&&void 0!==arguments[5]?arguments[5]:void 0,i=arguments.length>6&&void 0!==arguments[6]?arguments[6]:"",s=arguments.length>7&&void 0!==arguments[7]?arguments[7]:void 0,c=(arguments.length>8&&void 0!==arguments[8]&&arguments[8],arguments.length>9&&void 0!==arguments[9]?arguments[9]:""),l=arguments.length>10?arguments[10]:void 0,d=arguments.length>11&&void 0!==arguments[11]?arguments[11]:void 0,u=(arguments.length>12&&void 0!==arguments[12]&&arguments[12],arguments.length>13&&void 0!==arguments[13]?arguments[13]:[]),p=arguments.length>14&&void 0!==arguments[14]?arguments[14]:void 0,g=arguments.length>15&&void 0!==arguments[15]?arguments[15]:void 0,m=arguments.length>16?arguments[16]:void 0;return{callPurpose:{callPurposeId:(null==s?void 0:s.callPurposeId)||"",name:(null==s?void 0:s.name)||"",description:(null==s?void 0:s.description)||"",prompt:(null==s?void 0:s.prompt)||""},warmLeadSource:c,persona:{persona_id:(null==r?void 0:r.persona_id)||"",name:(null==r?void 0:r.name)||"",jobTitle:(null==r?void 0:r.jobTitle)||"",companyName:(null==r?void 0:r.companyName)||"",description:(null==r?void 0:r.description)||"",disposition:(null==r?void 0:r.disposition)||"",voiceLanguage:(null==r?void 0:r.voiceLanguage)||"",voiceGender:(null==r?void 0:r.voiceGender)||""},decisionMaker:{persona_id:(null==l?void 0:l.persona_id)||"",name:(null==l?void 0:l.name)||"",jobTitle:(null==l?void 0:l.jobTitle)||"",companyName:(null==l?void 0:l.companyName)||"",description:(null==l?void 0:l.description)||"",disposition:(null==l?void 0:l.disposition)||"",voiceLanguage:(null==l?void 0:l.voiceLanguage)||"",voiceGender:(null==l?void 0:l.voiceGender)||""},scorecard:{scorecard_id:(null==n?void 0:n.scorecard_id)||"",name:(null==n?void 0:n.name)||i,scorecardAssignments:(null==n?void 0:n.scorecardAssignments)||"[]"},product:{productId:(null==d?void 0:d.productId)||"",productName:(null==d?void 0:d.productName)||"",description:(null==d?void 0:d.description)||"",value:(null==d?void 0:d.value)||"",differentiator:(null==d?void 0:d.differentiator)||""},productToUpsell:p?{productId:p.productId||"",productName:p.productName||"",description:p.description||"",value:p.value||"",differentiator:p.differentiator||""}
1:void 0,learnerRole:t,scenarioDescription:o||"",objections:"string"==typeof u?JSON.parse(u):u,agent:g?{agentId:g.agentId||"",name:g.name||"",jobTitle:g.jobTitle||"",companyName:g.companyName||"",description:g.description||"",disposition:g.disposition||"",voiceLanguage:g.voiceLanguage||"",voiceGender:g.voiceGender||""}:void 0,salesScript:m}},s=e=>({error:e,scenarioID:"",org_id:null,created_at:"",updated_at:"",name:"",description:"",information:"",ai_configuration:null,success_criteria:{criteria:null},persona_id:null,scorecardId:null,callPurposeId:null,productId:null,objections:null,upsellProductId:null,warmLeadSourceId:null,decisionMakerPersonaId:null,agentId:null});async function c(e,t,r){if(!t)throw Error("Organization ID is required");let o=new URLSearchParams({userId:null!=e?e:"",orgId:null!=t?t:"",role:null!=r?r:""}).toString(),n=await fetch("/api/vapi/getEndOfCallReportsByUserId?".concat(o));if(!n.ok)throw Error("Failed to get feedback data");let i=(await n.json()).message,s={},c={},l={},d={},u={},p={};return i.forEach(e=>{if(e.scenarioId){if(s[e.scenarioId]=(s[e.scenarioId]||0)+1,e.endedAt)try{let t=new Date(e.endedAt);if(!isNaN(t.getTime())){let r=c[e.scenarioId];(!r||t>r)&&(c[e.scenarioId]=t)}}catch(t){console.warn("Invalid date format in feedback:",e.endedAt)}if(e.successEvaluation){let t=(0,a.xH)(e.successEvaluation);t>0&&(u[e.scenarioId]=(u[e.scenarioId]||0)+t,p[e.scenarioId]=(p[e.scenarioId]||0)+1,l[e.scenarioId]=u[e.scenarioId]/p[e.scenarioId],t>(d[e.scenarioId]||0)&&(d[e.scenarioId]=t))}}}),{completions:s,lastUsedDates:c,averageScores:l,bestScores:d}}function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:60,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:70,a=0;for(let t=0;t<e.length;t++)a=e.charCodeAt(t)+((a<<5)-a);let o=a%360;return"hsl(".concat(o,", ").concat(t,"%, ").concat(r,"%)")}function d(e,t,r,a,n,s,c,l){let d=arguments.length>8&&void 0!==arguments[8]?arguments[8]:[],u=arguments.length>9?arguments[9]:void 0,p=arguments.length>10?arguments[10]:void 0,g=arguments.length>11?arguments[11]:void 0,m=arguments.length>12?arguments[12]:void 0,h=arguments.length>13?arguments[13]:void 0,{getSelectedPersonaDetails:f,getSelectedProductDetails:v}=o.p.getState(),y=[];for(let o of t){let t=f(o);for(let f of r){let r=v(f);y.push(i(!0,n,t,o,s,c,a,l,e,u,g,r,f,d,p,m,h))}}return y}async function u(e){try{let t=await fetch("/api/roleplay_scenarios/getScenario/".concat(e));if(!t.ok)return!1;let r=await t.json();return r.success&&r.message&&r.message.length>0}catch(e){return console.error("Error checking if scenario exists:",e),!1}}},55496:(e,t,r)=>{r.d(t,{v:()=>a}),r(45645);let a="https://syrenn.co"},52497:(e,t,r)=>{r.d(t,{cn:()=>n});var a=r(73466),o=r(34256);function n(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return(0,o.m6)((0,a.W)(t))}},6126:(e,t,r)=>{r.d(t,{Z:()=>s});var a=r(72461),o=r(45645),n=r(72847);o.k;let i={name:"",model:{provider:"openai",model:"gpt-4o",emotionRecognitionEnabled:!0,temperature:.3,maxTokens:5e3,knowledgeBase:{provider:"canonical",fileIds:[],topK:1},messages:[]},voice:{voiceId:a.mm.male.english.voiceId,provider:a.mm.male.english.provider,fillerInjectionEnabled:!1,chunkPlan:{enabled:!0,minCharacters:15,punctuationBoundaries:[".","!","?",";",",",":"],formatPlan:{enabled:!0,numberToDigitsCutoff:2025}}},transcriber:{provider:"assembly-ai",language:"en"},firstMessageMode:"assistant-speaks-first",firstMessage:"Hello, can you help me with something?",firstMessageInterruptionsEnabled:!0,hipaaEnabled:!1,clientMessages:[],serverMessages:["end-of-call-report"],customerJoinTimeoutSeconds:60,silenceTimeoutSeconds:30,maxDurationSeconds:1800,backgroundSound:"off",backchannelingEnabled:!0,backgroundDenoisingEnabled:!0,modelOutputInMessagesEnabled:!1,startSpeakingPlan:{waitSeconds:2,smartEndpointingPlan:{provider:"vapi"}},stopSpeakingPlan:{numWords:0,voiceSeconds:.2,backoffSeconds:1,acknowledgementPhrases:["i understand","i see","i got it","i hear you","im listening","im with you","right","okay","ok","sure","alright","got it","understood","yeah","yes","uh-huh","mm-hmm","gotcha","mhmm","ah","yeah okay","yeah sure"],interruptionPhrases:["stop","shut","enough","quiet","silence","but","dont","no","hold","wait","pause","nope","nevermind","never","bad","actually"]},endCallPhrases:["goodbye","bye","see you later","talk to you later","end call","Have a great day","Have a good evening","Have a good night","Take care","Good night","I'll be speaking to HR about this, goodbye","I appreciate your guidance, goodbye"],monitorPlan:{listenEnabled:!1,controlEnabled:!1},analysisPlan:{summaryPlan:{messages:[],enabled:!0,timeoutSeconds:60},structuredDataPlan:{messages:[],enabled:!1,schema:{type:"object"},timeoutSeconds:60},successEvaluationPlan:{rubric:"Checklist",messages:[],enabled:!0,timeoutSeconds:60}},server:{url:"https://syrenn.pages.dev/api/vapi/endOfCallReport",secret:"JB
1Fg0pl8jo0V4ABAEeaX4RwealroKCytquHbqPd0IEe5RkLV7hU8sqIOdHPUh7187r"}};class s{withName(e){return e.length>40?this.config.name=e.slice(0,40):this.config.name=e,this}withFirstMessageMode(e){return this.config.firstMessageMode=e,this}withFirstMessage(e){return this.config.firstMessage=e,this}withEndCallPhrases(e){return this.config.endCallPhrases=e,this}withModel(e){return this.config.model={...this.config.model,...e},this}withVoice(e){return this.config.voice={...this.config.voice,...e},this}withAnalysisPlan(e){return this.config.analysisPlan=e,this}withArtifactPlan(e){return this.config.artifactPlan=e,this}withMetadata(e){return this.config.metadata={...this.config.metadata,...e},this}withVoicemailMessage(e){return this.config.voicemailMessage=e,this}withVoicemailDetection(e,t){var r;return(null===(r=e.name)||void 0===r?void 0:r.toLowerCase().includes(n.O))&&(this.config.voicemailDetection=t),this}withStartSpeakingPlan(e,t){var r;return(null===(r=e.name)||void 0===r?void 0:r.toLowerCase().includes(n.O))&&(this.config.startSpeakingPlan=t),this}build(){return this.config}constructor(e={}){this.config={...i,...e}}}},22440:(e,t,r)=>{r.d(t,{bP:()=>i,sY:()=>n,xM:()=>o});var a=r(72847);class o{withCallPurpose(e,t){return e.callPurposeId&&(this.callPurpose="\n The following defines the purpose of the call.\n \n **Call Purpose:**\n - Name: ".concat(e.name,"\n - Description: ").concat(e.description,"\n ").concat(e.name.toLowerCase().includes("warm")&&t?"- Warm Lead Source: ".concat(t):"","\n \n This call purpose defines the primary context of this conversation. You must:\n 1. Adapt your responses to align with this specific call purpose\n 2. Respond with the depth and tone a real customer would use during this call purpose")),this}withPersona(e,t){var r;let a=(r=e.difficulty||(null==t?void 0:t.difficulty)||null)&&({easy:"- Difficulty Level: Easy. This persona should be friendly, open to conversation, and provide helpful responses. They should be receptive to the caller's pitch and ask straightforward questions.",medium:"- Difficulty Level: Medium. This persona should be professional but somewhat cautious. They may raise common objections and require more persuasion. They should be realistic but not overly difficult.",hard:"- Difficulty Level: Hard. This persona should be skeptical, time-constrained, or have strong objections. They should challenge the caller with difficult questions and require advanced sales techniques to win over."})[r.toLowerCase()]||"";return this.persona="\n The following defines your persona for this roleplay interaction.\n You must must maintain this persona for the entirety of the roleplay interaction. If you ever break character, revert to the persona immediately.\n Create uniquely tailored conversation patterns and responses that authentically reflect the [[buyer_persona.disposition]], ensuring the AI buyer's emotional state and personality traits are consistently maintained throughout the interaction.\n **Persona:**\n - AI Name: ".concat(e.aiName,"\n - Core Identity: ").concat(t?"".concat(t.jobTitle," at ").concat(t.companyName):e.coreIdentity,"\n - Description: ").concat(t?" ".concat(t.description):e.context,"\n - Disposition: ").concat(e.disposition,"\n ").concat(a,"\n - Language: ").concat(t?t.voiceLanguage:e.language),this}withProduct(e,t){return!e.productId||t&&this.isColdCall(t)||(this.product="\n The following defines the product that the caller is selling.\n **Product Information:**\n - Name: ".concat(e.productName,"\n - Description: ").concat(e.description,"\n - Value Proposition: ").concat(e.value,"\n - Key Differentiators: ").concat(e.differentiator)),this}formatNode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=" ".repeat(t);if("EndCall"===e.type)return"".concat(r,'- Then say exactly "').concat(e.content,'" and execute the end call function');if("ScheduleCall"===e.type){let a="".concat(r,"\n - Wait for the user to initiate the scheduling conversation\n - If the user brings up scheduling or follow-up, respond naturally and support their scheduling efforts\n - ").concat(r,"Let the user take the lead in asking about availability, duration, and purpose\n - ").concat(r,'Provide helpful responses when the user asks about your availability or preferences\n - If the user does not initiate the follow-up scheduling conversation, you can suggest it with a statement such as "
1Let\'s schedule a follow-up call."');return e.children.length>0&&(a+="\n"+e.children.map(e=>this.formatNode(e,t+1)).join("\n")),a}let a="".concat(r,"- If ").concat(e.condition,",");return e.content&&(a+="\n".concat(r," Respond coherently to what the seller has said and then ").concat(e.isVerbatim?'say exactly: "'+e.content+'"':"express this naturally: "+e.content)),e.children.length>0&&(a+="\n"+e.children.map(e=>this.formatNode(e,t+1)).join("\n")),a}withMessages(e){return this.messages=e,this}withInstructions(e){if(!e||!e.rootNodes)return this;let t=e.rootNodes.map(e=>this.formatNode(e)).join("\n");return this.instructions="**Instructions:**\n".concat(t),this}withOutboundInstruction(e){var t;return(null===(t=e.name)||void 0===t?void 0:t.toLowerCase().includes(a.O))&&(this.outboundCallInstruction="\n **Outbound Call Instructions:**\n - You are a professional sales representative calling prospects about a product. Be friendly, concise, and respect their time.\n - If you reach voicemail, you should speak the voicemail message provided in the {{voicemailMessage}} field."),this}isColdCall(e){return e.name.toLowerCase().includes("cold call")}build(){return{role:"assistant",content:[this.outboundCallInstruction,this.callPurpose,this.persona,this.product,this.instructions,this.systemPrompt].filter(Boolean).join("\n\n")}}constructor(){this.callPurpose="",this.persona="",this.product="",this.instructions="",this.messages=null,this.outboundCallInstruction="",this.systemPrompt='\n - you can never say "Executing end call function" or "End call" or "End the call"\n - you can never say "How can I assist you?" or "How can I assist you today?" or "How can I help you?" or "How can I help you today?"\n - If you have already said your first message, NEVER say your first message again.\n - If you have already greeted the learner, NEVER greet the learner again.\n \n **Major Mode of Interaction:**\n - you primarily interact through audio, simulating a real world experience.\n - you adapt your communication style and emotional intensity based on the user\'s responses, creating dynamic and challenging scenarios that mirror the real-world.\n - you must always remain as concise as possible while still portraying a humanlike interaction\n - you must not speak more than 2 sentences at a time.\n '.trim()}}class n{build(e){return{messages:[{role:"system",content:this.systemPrompt},{role:"user",content:"Here is the transcript:\n\n{{transcript}}\n\n"}],enabled:!e,timeoutSeconds:60}}constructor(){this.systemPrompt="\nYou are an expert note taker. Please return a summary of the call transcript. Do not include the words 'Here's a summary of the call transcript'"}}class i{formatCriterion(e){return"- ".concat(e.text)}withCriteria(e){let t=e.map(e=>this.formatCriterion(e)).join("\n");return this.criteria="\n **Criteria:**\n ".concat(t),this}withScorecardAssignments(e,t){let r="";if(!e||0===e.length)return this.criteria="\n **Criteria:**\n ".concat(r),this;for(let a of e)"Product Knowledge"===a.name&&(null==t?void 0:t.productId)?r+="- ".concat(a.name,": ").concat(a.function,"\n")+"\n-- Product Name: ".concat(t.productName,"\n-- Product Description: ").concat(t.description,"\n-- Product Value Proposition: ").concat(t.value,"\n-- Product Differentiator: ").concat(t.differentiator):r+="\n\n- ".concat(a.name,": ").concat(a.function,"\n");return this.criteria="\n **Criteria:**\n ".concat(r),this}build(e,t,r,o){if(t&&"live-call"===r){let t=this.liveCallSystemPrompt.replace(/\{\{learnerName\}\}/g,o||"the learner");return{messages:[{role:"system",content:"".concat(t,"\n\n").concat(this.criteria)}],enabled:!e,timeoutSeconds:60,rubric:"Checklist"}}return r===a.O?{messages:[{role:"system",content:"".concat(this.outboundCallEvaluationSystemPrompt,"\n\n").concat(this.criteria)},{role:"user",content:"Here is the transcript:\n\n{{messages}}\n\n"}],enabled:!e,timeoutSeconds:60,rubric:"Checklist"}:{messages:[{role:"system",content:"".concat(this.systemPrompt,"\n\n").concat(this.criteria)},{role:"user",content:"Here is the transcript:\n\n{{messages}}\n\n"}],enabled:!e,timeoutSeconds:60,rubric:"Checklist"}}constructor(){this.systemPrompt='\nYou are an expert call evaluator. You will be given a transcript of a call and the system prompt of the AI participant. Your role is to evaluate both the call success and provide detailed feedback on the human participant\'s performance based on relevant criteria for that specific interaction.\n\nFor each evaluation, provide:\n1. A quantitative assessment for each top-level criterion\n2. Qualitative feedback highlighting specific strengths and areas for improvement related to the criteria\n\nExample output format:\n{\n "evaluation": {\n "criteria_scores": [\n {\n "criterion": "Emotional Support",\n "criterion
1Function": "Recognizes, validates, and empathizes with the caller\'s emotional state",\n "score": 4,\n "justification": "Demonstrated strong empathy and understanding",\n }\n ],\n "summary": "The call successfully addressed immediate concerns while maintaining professionalism"\n },\n "feedback": {\n "strengths": [\n {\n "criterion": "Emotional Support",\n "criterionFunction": "Recognizes, validates, and empathizes with the caller\'s emotional state",\n "behavior": "Empathetic response",\n "example": "Validated caller\'s emotional state",\n "impact": "Built trust and rapport",\n "timestamps": [15.39]\n }\n ],\n "improvements": [\n {\n "criterion": "Emotional Support",\n "criterionFunction": "Recognizes, validates, and empathizes with the caller\'s emotional state",\n "area": "Active listening",\n "example": "Could have asked more follow-up questions",\n "recommendation": "Use reflective listening techniques to show understanding",\n "timestamps": [90.18]\n }\n ]\n }\n}\n\nScore each criterion on a scale of 1-5, where:\n1 = Failed to meet any expectations\n2 = Below expectations\n3 = Meets basic expectations\n4 = Exceeds expectations\n5 = Exceptional performance\n\nAlways refer to the user as \'you\' in your feedback. Never use the phrase \'the user\' or \'the participant\'.\n\nAlways evaluate the call based on the user\'s performance, not the AI\'s performance. Never evaluate the AI\'s performance.\n\nFor each criterion:\n1. Provide a score and justification\n2. List specific examples from the transcript\n3. Provide targeted feedback on strengths and areas for improvement related to that criterion\n\nIn the feedback section, include timestamps for each strength and improvement. Always round timestamps to exactly 2 decimal places (e.g., if secondsFromStart is 277.82108, use 277.82). These timestamps help pinpoint when specific behaviors occurred.\nWhen referencing quotes from the transcript in any part of the evaluation or feedback, use single quotes.\nEnsure that the output object is valid JSON.\n\nDo your best to evaluate the call based on the criteria listed below even if the call is short.\n\nIf there is truly not enough information to evaluate the call (e.g. the transcript is empty):\n- Ensure each evaluation criteria is scored 1\n- Ensure the summary is "The call transcript does not provide enough information to evaluate the call".\n- Ensure the feedback strengths is empty\n- Ensure each improvement criterion provides a recommendation for future interactions based on the criterionFunction\n- Ensure the timestamps are empty\n\nCRITICAL:\n- You can ONLY evaluate the call based on the criteria listed below. Do not evaluate any other criteria or make assumptions about what should be evaluated.\n- Evaluate the call based on the following top-level criteria only. Do not evaluate sub-criteria.\n- Never include timestamps in any part of the evaluation section.\n- Never include timestamps in the feedback.strengths.example or feedback.improvements.example.\n- ALWAYS round timestamps to exactly 2 decimal places (e.g., 277.82108 becomes 277.82).\n \n\n',this.outboundCallEvaluationSystemPrompt='\n You are an expert call evaluator. You will be given a transcript of an outbound call and your goal is to evaluate the call success and provide detailed feedback on the agent\'s (caller) performance to the prospect (the person on the other end of the call) based on relevant criteria for that specific interaction.\n\n For each evaluation, provide:\n 1. A quantitative assessment for each top-level criterion\n 2. Qualitative feedback highlighting specific strengths and areas for improvement related to the criteria\n\n Example output format:\n {\n "evaluation": {\n "criteria_scores": [\n {\n "criterion": "Emotional Support",\n "criterion
1Function": "Recognizes, validates, and empathizes with the caller\'s emotional state",\n "score": 4,\n "justification": "Demonstrated strong empathy and understanding",\n }\n ],\n "summary": "The call successfully addressed immediate concerns while maintaining professionalism"\n },\n "feedback": {\n "strengths": [\n {\n "criterion": "Emotional Support",\n "criterionFunction": "Recognizes, validates, and empathizes with the caller\'s emotional state",\n "behavior": "Empathetic response",\n "example": "Validated caller\'s emotional state",\n "impact": "Built trust and rapport",\n "timestamps": [15.39]\n }\n ],\n "improvements": [\n {\n "criterion": "Emotional Support",\n "criterionFunction": "Recognizes, validates, and empathizes with the caller\'s emotional state",\n "area": "Active listening",\n "example": "Could have asked more follow-up questions",\n "recommendation": "Use reflective listening techniques to show understanding",\n "timestamps": [90.18]\n }\n ]\n }\n }\n\n Score each criterion on a scale of 1-5, where:\n 1 = Failed to meet any expectations\n 2 = Below expectations\n 3 = Meets basic expectations\n 4 = Exceeds expectations\n 5 = Exceptional performance\n \n Always refer to the user as \'the agent\' in your feedback. Never use the phrase \'you\' or \'the customer\'.\n \n Always evaluate the call based on the agent\'s performance, not the prospect\'s performance. Never evaluate the prospect\'s performance.\n \n For each criterion:\n 1. Provide a score and justification\n 2. List specific examples from the transcript\n 3. Provide targeted feedback on strengths and areas for improvement related to that criterion\n\n In the feedback section, include timestamps for each strength and improvement. Always round timestamps to exactly 2 decimal places (e.g., if secondsFromStart is 277.82108, use 277.82). These timestamps help pinpoint when specific behaviors occurred.\n When referencing quotes from the transcript in any part of the evaluation or feedback, use single quotes.\n Ensure that the output object is valid JSON.\n\n Do your best to evaluate the call based on the criteria listed below even if the call is short.\n\n If there is truly not enough information to evaluate the call (e.g. the transcript is empty):\n - Ensure each evaluation criteria is scored 1\n - Ensure the summary is "The call transcript does not provide enough information to evaluate the call".\n - Ensure the feedback strengths is empty\n - Ensure each improvement criterion provides a recommendation for future interactions based on the criterionFunction\n - Ensure the timestamps are empty\n\n CRITICAL:\n - You can ONLY evaluate the call based on the criteria listed below. Do not evaluate any other criteria or make assumptions about what should be evaluated.\n - Evaluate the call based on the following top-level criteria only. Do not evaluate sub-criteria.\n - Never include timestamps in any part of the evaluation section.\n - Never include timestamps in the feedback.strengths.example or feedback.improvements.example.\n - ALWAYS round timestamps to exactly 2 decimal places (e.g., 277.82108 becomes 277.82).\n \n\n',this.liveCallSystemPrompt='\n You are an expert call evaluator. You will be given a transcript of a call and your goal is to evaluate both the call success and provide detailed feedback on {{learnerName}}\'s performance based on relevant criteria for that specific interaction.\n\n IMPORTANT: To identify {{learnerName}}\'s messages in the transcript, look for messages where the "role" field exactly matches "user". Note that some messages in the transcript have role="participant", but you should ONLY evaluate the performance of the participant whose role field matches "user".\n\n For each evaluation, provide:\n1. A quantitative assessment for each top-level criterion\n2. Qualitative feedback highlighting specific strengths and areas for improvement related to the criteria\n\nExample output format:\n{\n "evaluation": {\n "criteria_scores": [\n {\n "criterion": "Emotional Support",\n "criterion
1Function": "Recognizes, validates, and empathizes with the caller\'s emotional state",\n "score": 4,\n "justification": "Demonstrated strong empathy and understanding",\n }\n ],\n "summary": "The call successfully addressed immediate concerns while maintaining professionalism"\n },\n "feedback": {\n "strengths": [\n {\n "criterion": "Emotional Support",\n "criterionFunction": "Recognizes, validates, and empathizes with the caller\'s emotional state",\n "behavior": "Empathetic response",\n "example": "Validated caller\'s emotional state",\n "impact": "Built trust and rapport",\n "timestamps": [15.39]\n }\n ],\n "improvements": [\n {\n "criterion": "Emotional Support",\n "criterionFunction": "Recognizes, validates, and empathizes with the caller\'s emotional state",\n "area": "Active listening",\n "example": "Could have asked more follow-up questions",\n "recommendation": "Use reflective listening techniques to show understanding",\n "timestamps": [90.18]\n }\n ]\n }\n}\n\nScore each criterion on a scale of 1-5, where:\n1 = Failed to meet any expectations\n2 = Below expectations\n3 = Meets basic expectations\n4 = Exceeds expectations\n5 = Exceptional performance\n\nFor each criterion:\n1. Provide a score and justification\n2. List specific examples from the transcript\n3. Provide targeted feedback on strengths and areas for improvement related to that criterion\n\nIn the feedback section, include timestamps for each strength and improvement. Always round timestamps to exactly 2 decimal places (e.g., if secondsFromStart is 277.82108, use 277.82). These timestamps help pinpoint when specific behaviors occurred.\nWhen referencing quotes from the transcript in any part of the evaluation or feedback, use single quotes.\nEnsure that the output object is valid JSON.\n\nDo your best to evaluate the call based on the criteria listed below even if the call is short.\n\nIf there is truly not enough information to evaluate the call (e.g. the transcript is empty):\n- Ensure each evaluation criteria is scored 1\n- Ensure the summary is "The call transcript does not provide enough information to evaluate the call".\n- Ensure the feedback strengths is empty\n- Ensure each improvement criterion provides a recommendation for future interactions based on the criterionFunction\n- Ensure the timestamps are empty\n\nCRITICAL:\n- ONLY evaluate the call based on {{learnerName}}\'s performance ({{learnerName}} is the name of the learner). Never evaluate other participants in the call.\n- Always refer to the user as \'you\' in your feedback. Never use the phrase \'the user\', \'the participant\', or \'the learner\'.\n- You can ONLY evaluate the call based on the criteria listed below. Do not evaluate any other criteria or make assumptions about what should be evaluated.\n- Evaluate the call based on the following top-level criteria only. Do not evaluate sub-criteria.\n- NEVER include timestamps in any part of the evaluation section.\n- NEVER include timestamps in the feedback.strengths.example or feedback.improvements.example.\n- ALWAYS round timestamps to exactly 2 decimal places (e.g., 277.82108 becomes 277.82).\n ',this.criteria=""}}},2334:(e,t,r)=>{r.d(t,{k$:()=>n,uP:()=>o});var a=r(72461);async function o(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"male",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"english",o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";try{let n=await fetch("".concat(o,"/api/personas/getPersonaWithVoiceAssignment?personaId=").concat(e),{method:"GET"}),i=await n.json();if(i.success&&i.message){let e=i.message;if(e.voiceId){try{let t=await fetch("".concat(o,"/api/voiceAssignments/getVoiceAssignmentByVoiceId?voiceId=").concat(e.voiceId),{method:"GET"});if(t.ok){let r=await t.json();if(r.message)return{voiceId:e.voiceId,provider:r.message.provider,gender:r.message.gender,language:r.message.language}}else if(404===t.status)console.log("[getPersonaVoiceConfig] Voice assignment not found for voiceId ".concat(e.voiceId,", using fallback"));else{let e=await t.text().catch(()=>"Unknown error");console.warn("[getPersonaVoiceConfig] Failed to get voice assignment by voiceId (".concat(t.status,"):"),e)}}catch(e){console.warn("[getPersonaVoiceConfig] Failed to get voice assignment by voiceId:",e)}let n=e.voiceGender||t,i=e.voiceLanguage||r,s=a.mm[n][i];return{voiceId:e.voiceId,provider:s.provider,gender:n,language:i}}}}catch(e){console.warn("[getPersonaVoiceConfig] Failed to get persona:",e)}try{let e=await fetch("".concat(o,"/api/voiceAssignments/getVoiceIdAndProviderByGenderAndLanguage?gender=").concat(t,"&language=").concat(r),{method:"GET"}),a=await e.json();if(a.message)return{voiceId:a.message.voiceId,provider:a.message.provider,gender:a.message.gender,language:a.message.language}}catch(e){console.warn("[getPersonaVoiceConfig] Failed to get voice assignment from API:",e)}let n=a.mm[t][r];return{voiceId:n.voiceId,provider:n.provider,gender:t,language:r}}async function n(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"male",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"english",o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";try{let n=await fetch("".concat(o,"/api/agents/getAgentWithVoiceAssignment?agentId=").concat(e),{method:"GET"}),i=await n.json();if(i.success&&i.message){let e=i.message;if(e.voiceId){try{let t=await fetch("".concat(o,"/api/voiceAssignments/getVoiceAssignmentByVoiceId?voiceId=").concat(e.voiceId),{method:"GET"});if(t.ok){let r=await t.json();if(r.message)return{voiceId:e.voiceId,provider:r.message.provider,gender:r.message.gender,language:r.message.language}}else if(404===t.status)console.log("[getAgentVoiceConfig] Voice assignment not found for voiceId ".concat(e.voiceId,", using fallback"));else{let e=await t.text().catch(()=>"Unknown error");console.warn("[getAgentVoiceConfig] Failed to get voice assignment by voiceId (".concat(t.status,"):"),e)}}catch(e){console.warn("[getAgentVoiceConfig] Failed to get voice assignment by voiceId:",e)}let n=e.voiceGender||t,i=e.voiceLanguage||r,s=a.mm[n][i];return{voiceId:e.voiceId,provider:s.provider,gender:n,language:i}}let n=e.voiceGender||t,s=e.voiceLanguage||r;try{let e=await fetch("".concat(o,"/api/voiceAssignments/getVoiceIdAndProviderByGenderAndLanguage?gender=").concat(n,"&language=").concat(s),{method:"GET"}),t=await e.json();if(t.message)return{voiceId:t.message.voiceId,provider:t.message.provider,gender:t.message.gender,language:t.message.language}}catch(e){console.warn("[getAgentVoiceConfig] Failed to get voice assignment from API:",e)}}}catch(e){console.warn("[getAgentVoiceConfig] Failed to get agent:",e)}try{let e=await fetch("".concat(o,"/api/voiceAssignments/getVoiceIdAndProviderByGenderAndLanguage?gender=").concat(t,"&language=").concat(r),{method:"GET"}),a=await e.json();if(a.message)return{voiceId:a.message.voiceId,provider:a.message.provider,gender:a.message.gender,language:a.message.language}}catch(e){console.warn("[getAgentVoiceConfig] Failed to get voice assignment from API:",e)}let n=a.mm[t][r];return{voiceId:n.voiceId,provider:n.provider,gender:t,language:r}}},23195:(e,t,r)=>{function a(e){if(!e||"string"!=typeof e)return"";let t=e.trim();return t.startsWith("http://")||t.startsWith("https://")||(t="https://".concat(t)),t=t.replace(/\/+$/,"")}async function o(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{context:r="Website Scraper"}=t,o=a(e);try{let e;let t=await fetch("/api/company-scraper/scrape",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:o})}),a=await t.text();if(422===t.status)try{var n,i;let e=JSON.parse(a);console.log("[".concat(r,"] 422 Validation error response:"),e);let t="Invalid URL format. Please enter a valid website URL (e.g., https://example.com)";if((null===(n=e.error)||void 0===n?void 0:n.issues)&&Array.isArray(e.error.issues)&&e.error.issues.length>0)t=e.error.issues[0].message||t;else if(null===(i=e.error)||void 0===i?void 0:i.message)t=e.error.message;else if(e.message)t=e.message;else if("string"==typeof e.error)t=e.error;else if(e.error&&"object"==typeof e.error){let r=JSON.stringify(e.error);(r.includes("Invalid URL")||r.includes("url"))&&(t="Invalid URL format. Please enter a valid website URL (e.g., https://example.com)")}return{success:!1,error:t,technicalError:"Validation error (422): ".concat(a)}}catch(e){return console.error("[".concat(r,"] Failed to parse 422 error response:"),e,"Response:",a),{success:!1,error:"Invalid URL format. Please enter a valid website URL (e.g., https://example.com)",technicalError:"Validation error (422): ".concat(a)}}try{e=JSON.parse(a)}catch(o){let e="Invalid response from server (".concat(t.status,"): ").concat(t.statusText,". Response: ").concat(a.substring(0,200));return console.error("[".concat(r,"] Parse error:"),e),{success:!1,error:"We received an invali
1d response from the server. Please try again.",technicalError:e}}if(!t.ok||!e.success){e.technicalError&&console.error("[".concat(r,"] Technical error:"),e.technicalError),console.log("[".concat(r,"] Error response data:"),e);let t=e.error||"We're having trouble accessing this website. Please try again in a moment.";return{success:!1,error:t,technicalError:e.technicalError}}return{success:!0,html:e.html,productDetails:e.productDetails,buyerPersona:e.buyerPersona}}catch(t){let e=t instanceof Error?t.message:"Unknown error occurred";return console.error("[".concat(r,"] Unexpected error:"),e),{success:!1,error:"We're having trouble processing your request. Please try again.",technicalError:e}}}async function n(e){var t,r;let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=await o(e,a);if(!n.success)return{success:!1,error:n.error};let i=null===(t=n.productDetails)||void 0===t?void 0:t.productDetails;return i?{success:!0,productData:{productName:i.productName||"",description:i.description||"",value:i.value||"",differentiator:i.differentiator||""}}:{success:!1,error:(null===(r=n.productDetails)||void 0===r?void 0:r.error)||"We couldn't extract product information from this website. Please try a different URL or create the product manually."}}r.d(t,{$h:()=>o,D5:()=>a,ZX:()=>n})},87227:(e,t,r)=>{r.d(t,{E:()=>l});var a=r(61170),o=r(24162),n=r(17190);let i=n.z.object({name:n.z.string().min(1,"Name is required"),jobTitle:n.z.string().min(1,"Job title is required"),companyName:n.z.string().min(1,"Company name is required"),description:n.z.string().min(1,"Description is required"),disposition:n.z.string().min(1,"Disposition is required"),voiceLanguage:n.z.string().min(1,"Voice language is required"),voiceGender:n.z.string().min(1,"Voice gender is required"),voiceId:n.z.string().optional()}),s={name:"",jobTitle:"",companyName:"",description:"",disposition:"",voiceLanguage:"",voiceGender:"",voiceId:""},c={name:null,jobTitle:null,companyName:null,description:null,disposition:null,voiceLanguage:null,voiceGender:null,voiceId:null},l=(0,a.U)((e,t)=>({agents:[],isLoading:!1,error:null,nameFilter:"",isDialogOpen:!1,showDeleteDialog:!1,showEditDialog:!1,agentToDelete:"",agentToEdit:null,formData:s,formErrors:c,setNameFilter:t=>e({nameFilter:t}),setDialogOpen:t=>e({isDialogOpen:t}),setShowDeleteDialog:t=>e({showDeleteDialog:t}),setShowEditDialog:t=>e({showEditDialog:t}),setAgentToDelete:t=>e({agentToDelete:t}),setAgentToEdit:t=>e({agentToEdit:t}),setFormData:t=>e(e=>({formData:{...e.formData,...t},formErrors:c})),clearFormData:()=>e({formData:s,formErrors:c}),validateFormData:()=>{let{formData:r}=t();try{return i.parse(r),e({formErrors:c}),!0}catch(t){if(t instanceof n.z.ZodError){let r={...c};t.errors.forEach(e=>{let t=e.path;1===t.length?r[t[0]]=e.message:2===t.length&&"voiceLanguage"===t[0]?(t[1],r.voiceLanguage=e.message):2===t.length&&"voiceGender"===t[0]&&(t[1],r.voiceGender=e.message)}),e({formErrors:r})}return!1}},fetchAgents:async()=>{let{orgId:t}=o.H.getState();if(!t){e({error:"Organization ID is required to fetch agents"});return}e({isLoading:!0,error:null});try{let r=await fetch("/api/agents/getAgentsWithVoiceAssignmentsByOrgId?".concat("orgId=".concat(t)),{method:"GET",headers:{"Content-Type":"application/json"}});if(!r.ok)throw Error("Failed to get agents");let a=await r.json();e({agents:a.message})}catch(t){console.error("Error getting agents:",t),e({error:t instanceof Error?t.message:"Failed to fetch agents"})}finally{e({isLoading:!1})}},getAgentsByOrgId:async e=>{if(!e)return console.error("Organization ID is required to get agents"),[];try{let t=await fetch("/api/agents/getAgentsByOrgId?".concat("orgId=".concat(e)),{method:"GET",headers:{"Content-Type":"application/json"}});if(!t.ok)throw Error("Failed to get agents");return(await t.json()).message}catch(e){return console.error("Error getting agents:",e),[]}},createAgent:async()=>{let{orgId:r}=o.H.getState(),{formData:a,validateFormData:n}=t();if(!r){e({error:"Organization ID is required to create agent"});return}if(n())try{if(!(await fetch("/api/agents/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,orgId:r,updated_at:new Date().toISOString()})})).ok)throw Error("Failed to create agent");await t().fetchAgents(),e({isDialogOpen:!1}),t().clearFormData()}catch(t){console.error("Error creating agent:",t),e({error:t instanceof Error?t.message:"Failed to create agent"})}},updateAgent:async()=>{let{agentToEdit:r,formData:a,validateFormData:o}=t();if(!r){e({error:"No agent selected for editing"});return}
1if(o())try{if(!(await fetch("/api/agents/update",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentId:r.agentId,...a,updated_at:new Date().toISOString()})})).ok)throw Error("Failed to update agent");await t().fetchAgents(),e({showEditDialog:!1,agentToEdit:null}),t().clearFormData()}catch(t){console.error("Error updating agent:",t),e({error:t instanceof Error?t.message:"Failed to update agent"})}},deleteAgent:async r=>{try{if(!(await fetch("/api/agents/delete",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentId:r})})).ok)throw Error("Failed to delete agent");await t().fetchAgents(),e({showDeleteDialog:!1})}catch(t){console.error("Error deleting agent:",t),e({error:t instanceof Error?t.message:"Failed to delete agent"})}},duplicateAgent:async(r,a,o,n)=>{try{if(!(await fetch("/api/agents/duplicate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentId:r,destinationOrgId:a,newAgentId:o})})).ok)throw Error("Failed to duplicate agent");await t().fetchAgents(),n({title:"Success",description:"Agent duplicated successfully",variant:"default"})}catch(t){console.error("Error duplicating agent:",t),n({title:"Error",description:t instanceof Error?t.message:"Failed to duplicate agent",variant:"destructive"}),e({error:t instanceof Error?t.message:"Failed to duplicate agent"})}},getSelectedAgentDetails:e=>{let{agents:r}=t();return r.find(t=>t.agentId===e)}}))},80975:(e,t,r)=>{r.d(t,{M:()=>d});var a=r(61170),o=r(24162),n=r(17190),i=r(18497);let s=n.z.object({name:n.z.string().min(1,"Call purpose name is required"),description:n.z.string().min(1,"Description is required"),prompt:n.z.string().optional(),default_scorecard_id:n.z.string().optional()}),c={name:"",description:"",prompt:"",default_scorecard_id:""},l={name:null,description:null,prompt:null,default_scorecard_id:null},d=(0,a.U)((e,t)=>({callPurposes:[],isLoading:!1,error:null,isDialogOpen:!1,showDeleteDialog:!1,showEditDialog:!1,callPurposeToDelete:"",callPurposeToEdit:null,formData:c,formErrors:l,setDialogOpen:t=>e({isDialogOpen:t}),setShowDeleteDialog:t=>e({showDeleteDialog:t}),setShowEditDialog:t=>e({showEditDialog:t}),setCallPurposeToDelete:t=>e({callPurposeToDelete:t}),setCallPurposeToEdit:t=>e({callPurposeToEdit:t,formData:t?{name:t.name,description:t.description,prompt:t.prompt,default_scorecard_id:t.default_scorecard_id||""}:c}),setFormData:t=>e(e=>({formData:{...e.formData,...t},formErrors:l})),clearFormData:()=>e({formData:c,formErrors:l}),validateFormData:()=>{let{formData:r}=t();try{return s.parse(r),e({formErrors:l}),!0}catch(t){if(t instanceof n.z.ZodError){let r={...l};t.errors.forEach(e=>{r[e.path[0]]=e.message}),e({formErrors:r})}return!1}},fetchCallPurposes:async()=>{if(!i.J){e({error:"Organization ID is required to fetch call purposes"});return}e({isLoading:!0,error:null});try{let t="orgId=".concat(i.J),r=await fetch("/api/callPurposes/getCallPurposesByOrgId?".concat(t),{method:"GET",headers:{"Content-Type":"application/json"}});if(!r.ok)throw Error("Failed to get call purposes");let a=await r.json();e({callPurposes:a.message})}catch(t){console.error("Error getting call purposes:",t),e({error:t instanceof Error?t.message:"Failed to fetch call purposes"})}finally{e({isLoading:!1})}},createCallPurpose:async()=>{let{orgId:r}=o.H.getState(),{formData:a,validateFormData:n}=t();if(!r){e({error:"Organization ID is required to create call purpose"});return}if(n())try{if(!(await fetch("/api/callPurposes/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a.name,orgId:r,description:a.description,prompt:a.prompt,default_scorecard_id:a.default_scorecard_id||void 0})})).ok)throw Error("Failed to create call purpose");await t().fetchCallPurposes(),e({isDialogOpen:!1}),t().clearFormData()}catch(t){console.error("Error creating call purpose:",t),e({error:t instanceof Error?t.message:"Failed to create call purpose"})}},updateCallPurpose:async()=>{let{callPurposeToEdit:r,formData:a,validateFormData:o}=t();if(!r){e({error:"No call purpose selected for editing"});return}
1if(o())try{if(!(await fetch("/api/callPurposes/update",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({callPurposeId:r.callPurposeId,name:a.name,description:a.description,prompt:a.prompt,default_scorecard_id:a.default_scorecard_id||void 0})})).ok)throw Error("Failed to update call purpose");await t().fetchCallPurposes(),e({showEditDialog:!1,callPurposeToEdit:null}),t().clearFormData()}catch(t){console.error("Error updating call purpose:",t),e({error:t instanceof Error?t.message:"Failed to update call purpose"})}},deleteCallPurpose:async r=>{try{if(!(await fetch("/api/callPurposes/delete",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({callPurposeId:r})})).ok)throw Error("Failed to delete call purpose");await t().fetchCallPurposes(),e({showDeleteDialog:!1})}catch(t){console.error("Error deleting call purpose:",t),e({error:t instanceof Error?t.message:"Failed to delete call purpose"})}},getSelectedCallPurposeDetails:e=>{let{callPurposes:r}=t();return r.find(t=>t.callPurposeId===e)},getCallPurposeById:async t=>{e({isLoading:!0,error:null});try{let e=await fetch("/api/callPurposes/getCallPurposeById?".concat("callPurposeId=".concat(t)),{method:"GET",headers:{"Content-Type":"application/json"}});if(!e.ok)throw Error("Failed to get call purpose");return(await e.json()).message}catch(t){return console.error("Error getting call purpose by ID:",t),e({error:t instanceof Error?t.message:"Failed to fetch call purpose"}),null}finally{e({isLoading:!1})}}}))},24162:(e,t,r)=>{r.d(t,{H:()=>n});var a=r(61170);let o={isLoaded:!0,guestId:void 0,orgId:void 0,orgRole:void 0,isSignedIn:void 0,hasFreeTrial:void 0,trialDaysLeft:void 0,isFreeTrialOrPaidGuest:!0,workshopRequested:!1,onboardingCompleted:void 0},n=(0,a.U)(e=>({...o,setAuthState:t=>{e(e=>({...e,...t}))},setTrialState:t=>{e(e=>({...e,...t}))},resetGuestStore:()=>{e(o)},setIsFreeTrialOrPaidGuest:t=>{e(e=>({...e,isFreeTrialOrPaidGuest:t}))},setWorkshopRequested:t=>{e(e=>({...e,workshopRequested:t}))},setOnboardingCompleted:t=>{e(e=>({...e,onboardingCompleted:t}))}}))},71920:(e,t,r)=>{r.d(t,{G:()=>l});var a=r(61170),o=r(24162),n=r(17190);let i=n.z.object({name:n.z.string().min(1,"Name is required"),jobTitle:n.z.string().min(1,"Job title is required"),companyName:n.z.string().min(1,"Company name is required"),description:n.z.string().min(1,"Description is required"),disposition:n.z.string().min(1,"Disposition is required"),difficulty:n.z.enum(["easy","medium","hard"]).optional().nullable(),voiceLanguage:n.z.string().min(1,"Voice language is required"),voiceGender:n.z.string().min(1,"Voice gender is required"),voiceId:n.z.string().optional()}),s={name:"",jobTitle:"",companyName:"",description:"",disposition:"",difficulty:null,voiceLanguage:"",voiceGender:"",voiceId:""},c={name:null,jobTitle:null,companyName:null,description:null,disposition:null,difficulty:null,voiceLanguage:null,voiceGender:null,voiceId:null},l=(0,a.U)((e,t)=>({personas:[],isLoading:!1,error:null,nameFilter:"",isDialogOpen:!1,showDeleteDialog:!1,showEditDialog:!1,personaToDelete:"",personaToEdit:null,formData:s,formErrors:c,setNameFilter:t=>e({nameFilter:t}),setDialogOpen:t=>e({isDialogOpen:t}),setShowDeleteDialog:t=>e({showDeleteDialog:t}),setShowEditDialog:t=>e({showEditDialog:t}),setPersonaToDelete:t=>e({personaToDelete:t}),setPersonaToEdit:t=>e({personaToEdit:t}),setFormData:t=>e(e=>({formData:{...e.formData,...t},formErrors:c})),clearFormData:()=>e({formData:s,formErrors:c}),validateFormData:()=>{let{formData:r}=t();try{return i.parse(r),e({formErrors:c}),!0}catch(t){if(t instanceof n.z.ZodError){let r={...c};t.errors.forEach(e=>{let t=e.path;1===t.length?r[t[0]]=e.message:2===t.length&&"voiceLanguage"===t[0]?(t[1],r.voiceLanguage=e.message):2===t.length&&"voiceGender"===t[0]&&(t[1],r.voiceGender=e.message)}),e({formErrors:r})}return!1}},fetchPersonas:async()=>{let{orgId:t}=o.H.getState();if(!t){e({error:"Organization ID is required to fetch personas"});return}e({isLoading:!0,error:null});try{let r=await fetch("/api/personas/getPersonasWithVoiceAssignmentsByOrgId?".concat("orgId=".concat(t)),{method:"GET",headers:{"Content-Type":"application/json"}});if(!r.ok)throw Error("Failed to get personas");let a=await r.json();e({personas:a.message})}catch(t){console.error("Error getting personas:",t),e({error:t instanceof Error?t.message:"Failed to fetch personas"})}finally{e({isLoading:!1})}},getPersonasByOrgId:async e=>{if(!e)return console.error("Organization ID is required to get personas"),[];try{let t=await fetch("/api/personas/getPersonasByOrgId?".concat("orgId=".concat(e)),{method:"GET",headers:{"Content-Type":"application/json"}});if(!t.ok)throw Error("Failed to get personas");return(await t.json()).message}catch(e){return console.error("Error getting personas:",e),[]}},createPersona:async()=>{let{orgId:r}=o.H.getState(),{formData:a,validateFormData:n}=t();if(!r){e({error:"Organization ID is required to create persona"});return}
1if(n())try{if(!(await fetch("/api/personas/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,orgId:r,updated_at:new Date().toISOString()})})).ok)throw Error("Failed to create persona");await t().fetchPersonas(),e({isDialogOpen:!1}),t().clearFormData()}catch(t){console.error("Error creating persona:",t),e({error:t instanceof Error?t.message:"Failed to create persona"})}},updatePersona:async()=>{let{personaToEdit:r,formData:a,validateFormData:o}=t();if(!r){e({error:"No persona selected for editing"});return}if(o())try{if(!(await fetch("/api/personas/update",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({personaId:r.persona_id,...a,updated_at:new Date().toISOString()})})).ok)throw Error("Failed to update persona");await t().fetchPersonas(),e({showEditDialog:!1,personaToEdit:null}),t().clearFormData()}catch(t){console.error("Error updating persona:",t),e({error:t instanceof Error?t.message:"Failed to update persona"})}},deletePersona:async r=>{try{if(!(await fetch("/api/personas/delete",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({personaId:r})})).ok)throw Error("Failed to delete persona");await t().fetchPersonas(),e({showDeleteDialog:!1})}catch(t){console.error("Error deleting persona:",t),e({error:t instanceof Error?t.message:"Failed to delete persona"})}},duplicatePersona:async(r,a,o,n)=>{try{if(!(await fetch("/api/personas/duplicate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({personaId:r,destinationOrgId:a,newPersonaId:o})})).ok)throw Error("Failed to duplicate persona");await t().fetchPersonas(),n({title:"Success",description:"Persona duplicated successfully",variant:"default"})}catch(t){console.error("Error duplicating persona:",t),n({title:"Error",description:t instanceof Error?t.message:"Failed to duplicate persona",variant:"destructive"}),e({error:t instanceof Error?t.message:"Failed to duplicate persona"})}},getSelectedPersonaDetails:e=>{let{personas:r}=t();return r.find(t=>t.persona_id===e)}}))},41362:(e,t,r)=>{r.d(t,{a:()=>d});var a=r(61170),o=r(24162),n=r(17190),i=r(23195);let s=n.z.object({productName:n.z.string().min(1,"Product name is required"),description:n.z.string().min(1,"Description is required"),value:n.z.string().min(1,"Value is required"),differentiator:n.z.string().min(1,"Differentiator is required"),url:n.z.union([n.z.string().refine(e=>{if(!e||""===e.trim())return!0;try{let t=(0,i.D5)(e);return new URL(t),!0}catch(e){return!1}},{message:"Must be a valid URL"}),n.z.literal(""),n.z.undefined()]).optional()}),c={productName:"",description:"",value:"",differentiator:"",url:""},l={productName:null,description:null,value:null,differentiator:null,url:null},d=(0,a.U)((e,t)=>({products:[],isLoading:!1,error:null,nameFilter:"",isDialogOpen:!1,showDeleteDialog:!1,showEditDialog:!1,productToDelete:"",productToEdit:null,formData:c,formErrors:l,setNameFilter:t=>e({nameFilter:t}),setDialogOpen:t=>e({isDialogOpen:t}),setShowDeleteDialog:t=>e({showDeleteDialog:t}),setShowEditDialog:t=>e({showEditDialog:t}),setProductToDelete:t=>e({productToDelete:t}),setProductToEdit:t=>e({productToEdit:t}),setFormData:t=>e(e=>({formData:{...e.formData,...t},formErrors:l})),clearFormData:()=>e({formData:c,formErrors:l}),validateFormData:()=>{let{formData:r}=t();try{return s.parse(r),e({formErrors:l}),!0}catch(t){if(t instanceof n.z.ZodError){let r={...l};t.errors.forEach(e=>{r[e.path[0]]=e.message}),e({formErrors:r})}return!1}},fetchProducts:async()=>{let{orgId:t}=o.H.getState();if(!t){e({error:"Organization ID is required to fetch products"});return}e({isLoading:!0,error:null});try{let r=await fetch("/api/products/getProductsByOrgId?".concat("orgId=".concat(t)),{method:"GET",headers:{"Content-Type":"application/json"}});if(!r.ok)throw Error("Failed to get products");let a=await r.json();e({products:a.message})}catch(t){console.error("Error getting products:",t),e({error:t instanceof Error?t.message:"Failed to fetch products"})}finally{e({isLoading:!1})}},getProductsByOrgId:async e=>{if(!e)return console.error("Organization ID is required to get products"),[];try{let t=await fetch("/api/products/getProductsByOrgId?".concat("orgId=".concat(e)),{method:"GET",headers:{"Content-Type":"application/json"}});if(!t.ok)throw Error("Failed to get products");return(await t.json()).message}catch(e){return console.error("Error getting products:",e),[]}},createProduct:async()=>{let{orgId:r}=o.H.getState(),{formData:a,validateFormData:n}=t();if(!r)return e({error:"Organization ID is required to create product"}),null;if(!n())return null;if(a.url&&""!==a.url.trim()){let t=(0,i.D5)(a.url);try{let a=await fetch("/api/products/checkDuplicate?url=".concat(encodeURIComponent(t),"&orgId=").concat(encodeURIComponent(r)),{method:"GET",headers:{"Content-Type":"application/json"}});if(a.ok){let t=await a.json();if(t.message){let r=t.message;return e({productToEdit:r,formData:{productName:r.productName,description:r.description,value:r.value,differentiator:r.differentiator,url:r.url||""},isDialogOpen:!1,showEditDialog:!0}),null}}}catch(e){console.error("Error checking for duplicate:",e)}}try{let o={...{...a,url:a.url&&""!==a.url.trim()?(0,i.D5)(a.url):a.url},orgId:r,updated_at:new Date().toISOString()},n=await fetch("/api/products/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!n.ok)throw Error("Failed to create product: ".concat(n.status," ").concat(n.statusText));let s=(await n.json()).message;if(!s)return e({error:"Product was created but could not be retrieved"}),null;return await t().fetchProducts(),e({isDialogOpen:!1}),t().clearFormData(),s}catch(t){return console.error("Error creating product:",t),e({error:t instanceof Error?t.message:"Failed to create product"}),null}},updateProduct:async()=>{let{productToEdit:r,formData:a,validateFormData:o}=t();if(!r){e({error:"No product selected for editing"});return}
1if(o())try{if(!(await fetch("/api/products/update",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({productId:r.productId,...a,updated_at:new Date().toISOString()})})).ok)throw Error("Failed to update product");await t().fetchProducts(),e({showEditDialog:!1,productToEdit:null}),t().clearFormData()}catch(t){console.error("Error updating product:",t),e({error:t instanceof Error?t.message:"Failed to update product"})}},deleteProduct:async r=>{try{if(!(await fetch("/api/products/delete",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({productId:r})})).ok)throw Error("Failed to delete product");await t().fetchProducts(),e({showDeleteDialog:!1})}catch(t){console.error("Error deleting product:",t),e({error:t instanceof Error?t.message:"Failed to delete product"})}},duplicateProduct:async(r,a,o,n)=>{try{if(!(await fetch("/api/products/duplicate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({productId:r,destinationOrgId:a,newProductId:o})})).ok)throw Error("Failed to duplicate product");await t().fetchProducts(),n({title:"Success",description:"Product duplicated successfully",variant:"default"})}catch(t){console.error("Error duplicating product:",t),n({title:"Error",description:t instanceof Error?t.message:"Failed to duplicate product",variant:"destructive"}),e({error:t instanceof Error?t.message:"Failed to duplicate product"})}},getSelectedProductDetails:e=>{let{products:r}=t();return r.find(t=>t.productId===e)}}))},79374:(e,t,r)=>{r.d(t,{Q:()=>d});var a=r(61170),o=r(24162),n=r(17190),i=r(55496);let s=n.z.object({name:n.z.string().min(1,"Assignment name is required"),function:n.z.string().min(1,"Function is required")}),c={name:"",function:""},l={name:null,function:null},d=(0,a.U)((e,t)=>({assignments:[],isLoading:!1,error:null,isDialogOpen:!1,showDeleteDialog:!1,showEditDialog:!1,assignmentToDelete:"",assignmentToEdit:null,formData:c,formErrors:l,setDialogOpen:t=>e({isDialogOpen:t}),setShowDeleteDialog:t=>e({showDeleteDialog:t}),setShowEditDialog:t=>e({showEditDialog:t}),setAssignmentToDelete:t=>e({assignmentToDelete:t}),setAssignmentToEdit:t=>e({assignmentToEdit:t}),setFormData:t=>e(e=>({formData:{...e.formData,...t},formErrors:l})),clearFormData:()=>e({formData:c,formErrors:l}),validateFormData:()=>{let{formData:r}=t();try{return s.parse(r),e({formErrors:l}),!0}catch(t){if(t instanceof n.z.ZodError){let r={...l};t.errors.forEach(e=>{r[e.path[0]]=e.message}),e({formErrors:r})}return!1}},fetchAssignments:async()=>{let{orgId:t}=o.H.getState();if(!t){e({error:"Organization ID is required to fetch assignments"});return}e({isLoading:!0,error:null});try{let r=await fetch("/api/scorecardsAssignments/getScorecardAssignmentsByOrgId?".concat("orgId=".concat(t)),{method:"GET",headers:{"Content-Type":"application/json"}});if(!r.ok)throw Error("Failed to get assignments");let a=await r.json();e({assignments:a.message})}catch(t){console.error("Error getting assignments:",t),e({error:t instanceof Error?t.message:"Failed to fetch assignments"})}finally{e({isLoading:!1})}},createAssignment:async()=>{let{orgId:r}=o.H.getState(),{formData:a,validateFormData:n}=t();if(!r){e({error:"Organization ID is required to create assignment"});return}if(n())try{if(!(await fetch("/api/scorecardsAssignments/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,orgId:r})})).ok)throw Error("Failed to create assignment");await t().fetchAssignments(),e({isDialogOpen:!1}),t().clearFormData()}catch(t){console.error("Error creating assignment:",t),e({error:t instanceof Error?t.message:"Failed to create assignment"})}},updateAssignment:async()=>{let{assignmentToEdit:r,formData:a,validateFormData:o}=t();if(!r){e({error:"No assignment selected for editing"});return}if(o())try{if(!(await fetch("/api/scorecardsAssignments/update",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({scorecardsAssignmentsId:r.scorecardsAssignmentsId,...a})})).ok)throw Error("Failed to update assignment");await t().fetchAssignments(),e({showEditDialog:!1,assignmentToEdit:null}),t().clearFormData()}catch(t){console.error("Error updating assignment:",t),e({error:t instanceof Error?t.message:"Failed to update assignment"})}},deleteAssignment:async r=>
1{try{if(!(await fetch("/api/scorecardsAssignments/delete",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({scorecardsAssignmentsId:r})})).ok)throw Error("Failed to delete assignment");await t().fetchAssignments(),e({showDeleteDialog:!1})}catch(t){console.error("Error deleting assignment:",t),e({error:t instanceof Error?t.message:"Failed to delete assignment"})}},getSelectedAssignmentDetails:e=>{let{assignments:r}=t();return r.find(t=>t.scorecardsAssignmentsId===e)},getSelectedScorecardAssignments:async e=>{let t=await fetch("".concat(i.v,"/api/scorecardsAssignments/getScorecardAssignmentsByScorecardId?scorecardId=").concat(e),{method:"GET",headers:{"Content-Type":"application/json"}});if(!t.ok)throw Error("Failed to get assignments");return(await t.json()).message},getScorecardAssignmentById:async e=>{try{let t=await fetch("/api/scorecardsAssignments/getScorecardAssignmentById?scorecardsAssignmentsId=".concat(e),{method:"GET",headers:{"Content-Type":"application/json"}});if(!t.ok)throw Error("Failed to get scorecard assignment");return(await t.json()).message}catch(e){return console.error("Error getting scorecard assignment by ID:",e),null}}}))},35653:(e,t,r)=>{r.d(t,{H:()=>l});var a=r(61170),o=r(24162),n=r(17190);let i=n.z.object({name:n.z.string().min(1,"Scorecard name is required"),assignments:n.z.array(n.z.string()).default([])}),s={name:"",assignments:[]},c={name:null,assignments:null},l=(0,a.U)((e,t)=>({scorecards:[],isLoading:!1,error:null,nameFilter:"",isDialogOpen:!1,showDeleteDialog:!1,showEditDialog:!1,scorecardToDelete:"",scorecardToEdit:null,formData:s,formErrors:c,selectedScorecard:null,setNameFilter:t=>e({nameFilter:t}),setDialogOpen:t=>e({isDialogOpen:t}),setShowDeleteDialog:t=>e({showDeleteDialog:t}),setShowEditDialog:t=>e({showEditDialog:t}),setScorecardToDelete:t=>e({scorecardToDelete:t}),setScorecardToEdit:t=>e({scorecardToEdit:t,formData:t?{name:t.name,assignments:JSON.parse(t.scorecardAssignments||"[]")}:s}),setFormData:t=>e(e=>({formData:{...e.formData,...t},formErrors:c})),clearFormData:()=>e({formData:s,formErrors:c}),validateFormData:()=>{let{formData:r}=t();try{return i.parse(r),e({formErrors:c}),!0}catch(t){if(t instanceof n.z.ZodError){let r={...c};t.errors.forEach(e=>{r[e.path[0]]=e.message}),e({formErrors:r})}return!1}},fetchScorecards:async()=>{let{orgId:t}=o.H.getState();if(!t){e({error:"Organization ID is required to fetch scorecards"});return}e({isLoading:!0,error:null});try{let r=await fetch("/api/scorecards/getScorecardsByOrgId?".concat("orgId=".concat(t)),{method:"GET",headers:{"Content-Type":"application/json"}});if(!r.ok)throw Error("Failed to get scorecards");let a=await r.json();e({scorecards:a.message})}catch(t){console.error("Error getting scorecards:",t),e({error:t instanceof Error?t.message:"Failed to fetch scorecards"})}finally{e({isLoading:!1})}},fetchScorecardById:async t=>{e({isLoading:!0,error:null});try{let r=await fetch("/api/scorecards/getScorecardById?".concat("scorecardId=".concat(t)),{method:"GET",headers:{"Content-Type":"application/json"}});if(!r.ok)throw Error("Failed to get scorecard");let a=await r.json();return e({selectedScorecard:a.message}),a.message}catch(t){return console.error("Error getting scorecard by ID:",t),e({error:t instanceof Error?t.message:"Failed to fetch scorecard"}),null}finally{e({isLoading:!1})}},getScorecardsByOrgId:async e=>{if(!e)return console.error("Organization ID is required to get scorecards"),[];try{let t=await fetch("/api/scorecards/getScorecardsByOrgId?".concat("orgId=".concat(e)),{method:"GET",headers:{"Content-Type":"application/json"}});if(!t.ok)throw Error("Failed to get scorecards");return(await t.json()).message}catch(e){return console.error("Error getting scorecards:",e),[]}},createScorecard:async()=>{let{orgId:r}=o.H.getState(),{formData:a,validateFormData:n}=t();if(!r){e({error:"Organization ID is required to create scorecard"});return}if(n())try{if(!(await fetch("/api/scorecards/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,orgId:r,scorecardAssignments:JSON.stringify(a.assignments||[]),updated_at:new Date().toISOString()})})).ok)throw Error("Failed to create scorecard");await t().fetchScorecards(),e({isDialogOpen:!1}),t().clearFormData()}catch(t){console.error("Error creating scorecard:",t),e({error:t instanceof Error?t.message:"Failed to create scorecard"})}},updateScorecard:async()=>{let{scorecardToEdit:r,formData:a,validateFormData:o}=t();if(!r){e({error:"No scorecard selected for editing"});return}
1if(o())try{if(!(await fetch("/api/scorecards/update",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({scorecardId:r.scorecard_id,name:a.name,scorecardAssignments:JSON.stringify(a.assignments||[]),updated_at:new Date().toISOString()})})).ok)throw Error("Failed to update scorecard");await t().fetchScorecards(),e({showEditDialog:!1,scorecardToEdit:null}),t().clearFormData()}catch(t){console.error("Error updating scorecard:",t),e({error:t instanceof Error?t.message:"Failed to update scorecard"})}},deleteScorecard:async r=>{try{if(!(await fetch("/api/scorecards/delete",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({scorecardId:r})})).ok)throw Error("Failed to delete scorecard");await t().fetchScorecards(),e({showDeleteDialog:!1})}catch(t){console.error("Error deleting scorecard:",t),e({error:t instanceof Error?t.message:"Failed to delete scorecard"})}},duplicateScorecard:async(r,a,o)=>{try{if(!(await fetch("/api/scorecards/duplicate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scorecardId:r,destinationOrgId:a})})).ok)throw Error("Failed to duplicate scorecard");await t().fetchScorecards(),o({title:"Success",description:"Scorecard duplicated successfully",variant:"default"})}catch(t){console.error("Error duplicating scorecard:",t),o({title:"Error",description:t instanceof Error?t.message:"Failed to duplicate scorecard",variant:"destructive"}),e({error:t instanceof Error?t.message:"Failed to duplicate scorecard"})}},getSelectedScorecardDetails:e=>{let{scorecards:r}=t();return r.find(t=>t.scorecard_id===e)}}))},12769:(e,t,r)=>{r.d(t,{p:()=>C});var a=r(61170),o=r(72847),n=r(6126),i=r(22440),s=r(75078);r(13179);var c=(0,r(58152).$)("2059660674ac9c9f99b2c56168bea2994e45d14e"),l=r(24162),d=r(72461),u=r(71920),p=r(83898),g=r(40299),m=r(79374),h=r(28126),f=r(55496),v=r(2334);class y{getStore(){return C.getState()}getGuestStore(){return l.H.getState()}async generateScenario(e,t){try{let N=await c(e,t);if(N.error)return console.error("[SmartScenarioGenerator.generateScenario] Error during scenario creation:",N.error),(0,p.R6)(N.error);t.isPrescriptive||(this.getStore().setLLMRequest(N.generatedPromptMessage),this.getStore().setLLMResponse(N.generatedScenarioMessage));let C=N.generatedScenarioMessage;if(!C||0===C.trim().length)return console.error("[SmartScenarioGenerator.generateScenario] Empty scenario content received from API"),(0,p.R6)("Empty response from scenario generation API. This may be due to a timeout or API error on Cloudflare Pages.");let A=await this.parseScenario(C);if(A.error)return console.error("[SmartScenarioGenerator.generateScenario] Error parsing scenario:",A.error),(0,p.R6)(A.error);let F=A.data;try{var r,a,n,i,l,d,u,g,m,h,y,S,w,E,I,D,b,P,T;if(F.ai_configuration){let e;let r=t.callPurpose;if(null!==(h=null==r?void 0:null===(g=r.name)||void 0===g?void 0:g.toLowerCase().includes(o.O))&&void 0!==h&&h&&(null===(m=t.agent)||void 0===m?void 0:m.agentId)){let r=t.agent;e=await (0,v.k$)(r.agentId,r.voiceGender||"male",r.voiceLanguage||"english",f.v)}else{let r=t.persona;e=await (0,v.uP)(r.persona_id,r.voiceGender,r.voiceLanguage,f.v)}F.ai_configuration.voice.voiceId=e.voiceId,F.ai_configuration.voice.provider=e.provider,F.ai_configuration.voice.gender=e.gender,F.ai_configuration.voice.language=e.language}let c=(0,s.l)();t.isPrescriptive||this.getStore().setScenarioID(c);let p=await this.createInformationField(e,F.ai_configuration,F,c,t);return{scenarioID:c,org_id:null,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),name:F.scenario_name,description:F.scenario_description,information:p,ai_configuration:F.ai_configuration,success_criteria:F.success_criteria?{criteria:F.success_criteria.criteria}:{criteria:null},persona_id:e&&null!==(y=null===(r=t.persona)||void 0===r?void 0:r.persona_id)&&void 0!==y?y:null,scorecardId:e&&null!==(S=null===(a=t.scorecard)||void 0===a?void 0:a.scorecard_id)&&void 0!==S?S:null,callPurposeId:e&&null!==(w=null===(n=t.callPurpose)||void 0===n?void 0:n.callPurposeId)&&void 0!==w?w:null,productId:e&&null!==(E=null===(i=t.product)||void 0===i?void 0:i.productId)&&void 0!==E?E:null,objections:e&&null!==(I=t.objections)&&void 0!==I?I:null,upsellProductId:e&&null!==(D=null===(l=t.productToUpsell)||void 0===l?void 0:l.productId)&&void 0!==D?D:null,warmLeadSourceId:e&&null!==(b=t.warmLeadSource)&&void 0!==b?b:null,decisionMakerPersonaId:e&&null!==(P=null===(d=t.decisionMaker)||void 0===d?void 0:d.persona_id)&&void 0!==P?P:null,agentId:e&&null!==(T=null===(u=t.agent)||void 0===u?void 0:u.agentId)&&void 0!==T?T:null}}
1catch(e){return console.error("[SmartScenarioGenerator.generateScenario] Error processing scenario:",e),(0,p.R6)(e instanceof Error?e.message:"Failed to process generated scenario")}}catch(e){return console.error("[SmartScenarioGenerator.generateScenario] Unexpected error:",e),(0,p.R6)(e instanceof Error?e.message:"An unexpected error occurred")}}async parseScenario(e){try{let r;if(!e||"string"!=typeof e)return{data:{},error:"Empty or invalid scenario response from API"};try{r=JSON.parse(e)}catch(e){return console.error("[SmartScenarioGenerator.parseScenario] JSON parse error: ",e),{data:{},error:e instanceof Error?e.message:"Failed to parse scenario JSON"}}if(r.ai_configuration&&r.ai_configuration.instructions){var t;if(r.ai_configuration.instructions.id=(0,g.v4)(),r.ai_configuration.instructions.rootNodes&&Array.isArray(r.ai_configuration.instructions.rootNodes)&&this.assignNodeUUIDs(r.ai_configuration.instructions.rootNodes),null===(t=r.ai_configuration.messages)||void 0===t?void 0:t.endCallPhrases){let e=new Set(r.ai_configuration.messages.endCallPhrases.split("\n").filter(Boolean));this.validateAndAddEndCallPhrases(r.ai_configuration.instructions.rootNodes,e),r.ai_configuration.messages.endCallPhrases=Array.from(e).join("\n")}}return{data:r}}catch(e){return console.error("[SmartScenarioGenerator.parseScenario] Unexpected error: ",e),{data:{},error:e instanceof Error?e.message:"Unexpected error in parse scenario"}}}assignNodeUUIDs(e){if(e&&Array.isArray(e))for(let t of e)t.id=(0,g.v4)(),("If"===t.type||"ScheduleCall"===t.type)&&t.children&&Array.isArray(t.children)&&this.assignNodeUUIDs(t.children)}async generateCallContext(e,t){try{let r=await fetch("".concat(f.v,"/api/smart_scenarios/generateCallContext"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenarioSpec:{callPurpose:e.callPurpose,persona:e.persona,product:e.product,agent:e.agent},scenarioDescription:t})});if(!r.ok)return console.error("[SmartScenarioGenerator.generateCallContext] API call failed:",r.statusText),"";let a=await r.json();if(!a.success)return console.error("[SmartScenarioGenerator.generateCallContext] API returned error:",a.message),"";return a.message}catch(e){return console.error("[SmartScenarioGenerator.generateCallContext] error: ",e),""}}async createInformationField(e,t,r,a,s){try{var c,l,p,g,f,v;if(!t||!r)return console.error("[SmartScenarioGenerator.createInformationField] aiConfiguration or createdScenario is missing"),"";let y=await this.generateCallContext(s,r.scenario_description||"");y&&(r.scenario_description=y);let S=s.callPurpose||{callPurposeId:"",name:"",description:""},w=null===(c=s.persona)||void 0===c?void 0:c.persona_id;if(w&&t.persona&&!t.persona.difficulty){let e=u.G.getState().getSelectedPersonaDetails(w);(null==e?void 0:e.difficulty)&&(t.persona.difficulty=e.difficulty.toLowerCase())}let E=new i.xM().withCallPurpose(S,null!==(f=s.warmLeadSource)&&void 0!==f?f:"").withPersona(t.persona||"default",(null===(l=t.persona)||void 0===l?void 0:l.persona_id)?u.G.getState().getSelectedPersonaDetails(t.persona.persona_id):void 0).withProduct(s.product||{productName:"",description:"",value:"",differentiator:""},s.callPurpose).withMessages(t.messages).withInstructions(t.instructions).withOutboundInstruction(S).build(),I=(0,h.cr)("gemini-eval",this.getGuestStore().guestId,this.getGuestStore().orgId),D=(0,h.cr)("live-call",this.getGuestStore().guestId,this.getGuestStore().orgId),b=new i.sY().build(I),P=new i.bP;if(e){let e=s.isPrescriptive?s.product:this.getStore().getSelectedProductDetails(),{getSelectedScorecardAssignments:t}=m.Q.getState(),r=await t(s.scorecard.scorecard_id);P.withScorecardAssignments(r,e)}else P.withCriteria((null===(v=r.success_criteria)||void 0===v?void 0:v.criteria)&&"object"==typeof r.success_criteria.criteria?r.success_criteria.criteria.rootCriteria:[]);let T=(null===(p=S.name)||void 0===p?void 0:p.toLowerCase().includes(o.O))?o.O:"",N=P.build(I,D,T,""),C=new n.Z().withName(r.scenario_name||"").withFirstMessageMode((null===(g=S.name)||void 0===g?void 0:g.toLowerCase().includes(o.O))?"assistant-waits-for-user":t.messages.firstMessageMode).withFirstMessage(t.messages.firstMessage).withEndCallPhrases(t.messages.endCallPhrases.split("\n").filter(
1Boolean)).withVoice({voiceId:t.voice.voiceId||d.mm.male.english.voiceId,provider:t.voice.provider||d.mm.male.english.provider}).withModel({messages:[E]}).withAnalysisPlan({summaryPlan:b,successEvaluationPlan:N}).withVoicemailDetection(S,{provider:"vapi",backoffPlan:{maxRetries:5,startAtSeconds:2,frequencySeconds:2.5},beepMaxAwaitSeconds:30}).withVoicemailMessage(t.voicemailMessage||"").withStartSpeakingPlan(S,{waitSeconds:.5,smartEndpointingEnabled:!1,smartEndpointingPlan:{provider:"vapi"}}).withMetadata({aiName:t.persona.aiName,userId:s.isPrescriptive?s.userId:s.userId||this.getGuestStore().guestId,orgId:s.isPrescriptive?s.orgId:s.orgId||this.getGuestStore().orgId,scenarioId:a,scenarioName:r.scenario_name,firstMessageMode:t.messages.firstMessageMode,scorecardId:e?s.scorecard.scorecard_id:null,playlistId:s.playlistId||null,callType:s.callType||null}).build();return JSON.stringify(C)}catch(e){return console.error("[SmartScenarioGenerator.createInformationField] error: ",e),""}}categorizeError(e){return e instanceof Error?e instanceof SyntaxError?"formatting":e.message.includes("missing")?"missing_data":"other":"other"}validateAndAddEndCallPhrases(e,t){if(e&&Array.isArray(e))for(let r of e)"EndCall"===r.type&&r.content&&t.add(r.content),("If"===r.type||"ScheduleCall"===r.type)&&r.children&&Array.isArray(r.children)&&this.validateAndAddEndCallPhrases(r.children,t)}}var S=r(35653),w=r(41362),E=r(80975),I=r(87227),D=r(9225);let b=sessionStorage.getItem(D.s.SMART_SCENARIO_INPUT),P=b?JSON.parse(b):null,T=sessionStorage.getItem(D.s.GENERATED_SCENARIO_INPUT),N=T?JSON.parse(T):null,C=(0,a.U)((e,t)=>({isSaved:!1,error:null,learnerRole:"Salesperson",scenarioDescription:(null==P?void 0:P.scenarioDescription)||"",isGenerating:!1,previewScenario:null,generatedScenario:N||null,activeTab:"create",llmRequest:"",llmResponse:"",scenarioID:"",salesmode:!0,persona:"",scorecard:"",product:"",productToUpsell:"",callPurpose:"",industry:"",warmLeadSource:"",selectedPersonas:[],selectedProducts:[],isMultiScenario:!1,generatedScenarios:[],scenarioReport:null,includePresetObjections:!1,selectedObjection:"",decisionMaker:"",agent:"",setS
1alesmode:t=>e({salesmode:t}),setCallPurpose:t=>e({callPurpose:t}),setPersona:t=>e({persona:t}),setScorecard:t=>e({scorecard:t}),setProduct:t=>e({product:t}),setProductToUpsell:t=>e({productToUpsell:t}),setIndustry:t=>e({industry:t}),setWarmLeadSource:t=>e({warmLeadSource:t}),setSelectedPersonas:t=>e({selectedPersonas:t}),setSelectedProducts:t=>e({selectedProducts:t}),setIncludePresetObjections:t=>e({includePresetObjections:t}),setSelectedObjection:t=>e({selectedObjection:t}),setDecisionMaker:t=>e({decisionMaker:t}),setAgent:t=>e({agent:t}),setScenarioID:t=>{e({scenarioID:t})},setIsSaved:t=>e({isSaved:t}),setLearnerRole:t=>e({learnerRole:t}),setScenarioDescription:t=>e({scenarioDescription:t}),setIsGenerating:t=>e({isGenerating:t}),setGeneratedScenario:t=>e({previewScenario:t}),setActiveTab:t=>e({activeTab:t}),setMultiScenario:t=>e({isMultiScenario:t}),setGeneratedScenarios:t=>e({generatedScenarios:t}),setScenarioReport:t=>e({scenarioReport:t}),generateScenario:async(r,a)=>{let o=t(),n=null!=a&&a;n||e({isGenerating:!0,error:null});let i=new y,s=1;for(;s<=2;)try{var c,l;let t=await i.generateScenario(o.salesmode,r);if(t.error){if(console.error("[generateScenario] Attempt ".concat(s," failed with error:"),t.error),2===s)return n||e({isGenerating:!1,error:t.error}),{success:!1,error:t.error};s++;continue}let{name:a,description:d,information:u,ai_configuration:p}=t,g=null;if(u)try{g=JSON.parse(u)}catch(e){console.error("Error parsing assistant config: ",e)}let m={scenarioName:a,scenarioDescription:d,assistantConfig:g,gender:null!==(l=null==p?void 0:null===(c=p.voice)||void 0===c?void 0:c.gender)&&void 0!==l?l:"male"};if(!n){e({previewScenario:m}),sessionStorage.setItem(D.s.PREVIEW_SCENARIO,JSON.stringify(m));let r={learnerRole:o.learnerRole,scenarioDescription:o.scenarioDescription};sessionStorage.setItem(D.s.SMART_SCENARIO_INPUT,JSON.stringify(r)),e({generatedScenario:t}),sessionStorage.setItem(D.s.GENERATED_SCENARIO_INPUT,JSON.stringify(t)),o.saveSmartScenarioData(),e({isGenerating:!1,activeTab:"preview",error:null})}return{success:!0,generatedScenario:t,previewScenario:m}}catch(t){if(console.error("[generateScenario] Unexpected error in attempt ".concat(s,":"),t),2===s){let r=t instanceof Error?t.message:"Failed to generate scenario. Please try again.";return n||e({isGenerating:!1,error:r}),{success:!1,error:r}}s++}let d="Failed to generate scenario after all attempts";return n||e({isGenerating:!1,error:d}),{success:!1,error:d}},generateScenarios:async(r,a)=>{t(),e({isGenerating:!0,error:null,isMultiScenario:!0,generatedScenarios:[],scenarioReport:null});let o=[],n=[],i=r.length;a&&a({completed:0,total:i});for(let h=0;h<r.length;h++){var s,c,l,d,u,p,g,m;let f=r[h];if(a){let e="Scenario ".concat(h+1," of ").concat(i);if(f.persona&&f.callPurpose){let t="string"==typeof f.persona?f.persona:(null===(s=f.persona)||void 0===s?void 0:s.name)||(null===(c=f.persona)||void 0===c?void 0:c.persona_id)||"Unknown Persona",r="string"==typeof f.callPurpose?f.callPurpose:(null===(l=f.callPurpose)||void 0===l?void 0:l.name)||(null===(d=f.callPurpose)||void 0===d?void 0:d.callPurposeId)||"Unknown Call Purpose";e="Generating scenario ".concat(h+1," of ").concat(i,": ").concat(t," \xd7 ").concat(r)}a({completed:h,total:i,current:e})}let v=t(),y=await v.generateScenario(f,!0);if(y.success&&y.previewScenario&&y.generatedScenario){console.log("Generated scenario:",y.generatedScenario),console.log("Persona:",f.persona),console.log("Product:",f.product),o.push({previewScenario:y.previewScenario,generatedScenario:y.generatedScenario,persona:f.persona,product:f.product});try{let r="string"==typeof f.persona?f.persona:(null===(u=f.persona)||void 0===u?void 0:u.persona_id)||"",a="string"==typeof f.product?f.product:(null===(p=f.product)||void 0===p?void 0:p.productId)||"",o="string"==typeof f.scorecard?f.scorecard:(null===(g=f.scorecard)||void 0===g?void 0:g.scorecard_id)||"",n="string"==typeof f.callPurpose?f.callPurpose:(null===(m=f.callPurpose)||void 0===m?void 0:m.callPurposeId)||"";if(y.generatedScenario.scenarioID){let i=t().scorecard,s=t().callPurpose,c=t().product,l=t().persona;e({scorecard:o,callPurpose:n,product:a,persona:r});let d={...y.generatedScenario,persona_id:r||y.generatedScenario.persona_id||null,productId:a||y.generatedScenario.productId||null,scorecardId:o||y.generatedScenario.scorecardId||null,callPurposeId:n||y.generatedScenario.callPurposeId||null},u=await t().saveToMyScenarios({generatedScenario:d,persona:r,product:a});
1e({scorecard:i,callPurpose:s,product:c,persona:l}),u||console.warn("[generateScenarios] â Failed to save scenario: ".concat(y.generatedScenario.name," (ID: ").concat(y.generatedScenario.scenarioID,")"))}else console.warn("[generateScenarios] Generated scenario missing scenarioID, skipping save")}catch(e){console.error('[generateScenarios] Error saving scenario "'.concat(y.generatedScenario.name,'":'),e)}}else n.push({persona:f.persona,product:f.product,error:y.error||"Failed to generate scenario"});a&&a({completed:h+1,total:i})}let h={totalScenarios:r.length,successfulScenarios:o.length,failedScenarios:n.length,scenarios:o.map(e=>{var t;return{name:e.previewScenario.scenarioName,description:e.previewScenario.scenarioDescription,persona:e.persona,product:e.product,gender:null!==(t=e.previewScenario.gender)&&void 0!==t?t:"male"}}),failedScenariosDetails:n,generatedAt:new Date().toISOString()};e({generatedScenarios:o,scenarioReport:h,isGenerating:!1,activeTab:"preview",error:n.length>0?"Failed to generate ".concat(n.length," scenario(s)"):null})},clearFields:()=>{sessionStorage.removeItem(D.s.PREVIEW_SCENARIO),sessionStorage.removeItem(D.s.GENERATED_SCENARIO_INPUT),sessionStorage.removeItem(D.s.SMART_SCENARIO_INPUT),e({sce
1narioDescription:"",generatedScenario:null,isSaved:!1,error:"",isGenerating:!1,previewScenario:null,activeTab:"create",persona:"",scorecard:"",product:"",productToUpsell:"",callPurpose:"",industry:"",warmLeadSource:"",selectedPersonas:[],selectedProducts:[],selectedObjection:"",agent:"",isMultiScenario:!1,generatedScenarios:[],scenarioReport:null})},saveToMyScenarios:async r=>{console.log("Save to my scenarios:",r);let{orgId:a}=l.H.getState(),n=t(),i=(null==r?void 0:r.generatedScenario)||n.generatedScenario;if(!i)return console.error("No generated scenario to save"),e({error:"No generated scenario to save"}),!1;let s=(null==r?void 0:r.persona)?n.getSelectedPersonaDetails(r.persona):n.getSelectedPersonaDetails(),c=(null==s?void 0:s.persona_id)||i.persona_id||"",d=(null==r?void 0:r.product)?n.getSelectedProductDetails(r.product):n.getSelectedProductDetails(),u=(null==d?void 0:d.productId)||i.productId||"";c.startsWith("generated_")&&console.warn('[saveToMyScenarios] Persona ID starts with "generated_". Persona should have been saved before scenario generation.'),u.startsWith("generated_")&&console.warn('[saveToMyScenarios] Product ID starts with "generated_". Product should have been saved before scenario generation.');let p=n.getSelectedCallPurposeDetails(),g=(null==p?void 0:p.callPurposeId)||i.callPurposeId||"",{scorecard:m}=t(),{industry:h}=t(),f={name:i.name,description:i.description,scenarioID:i.scenarioID,org_id:a,information:i.information,ai_configuration:JSON.stringify(i.ai_configuration),success_criteria:JSON.stringify(i.success_criteria),created_at:new Date().toISOString(),updated_at:new Date().toISOString(),persona_id:c,scorecardId:m,productId:u,callPurposeId:g,industry_id:h,upsellProductId:i.upsellProductId||"",warmLeadSourceId:i.warmLeadSourceId||"",decisionMakerPersonaId:i.decisionMakerPersonaId||"",objections:JSON.stringify((i.objections||[]).map(e=>e.objectionId)),agentId:i.agentId||"",scenarioType:i.agentId?o.O:null};try{let e=await fetch("/api/roleplay_scenarios/createScenario",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)});if(!e.ok){let t=await e.json();throw Error(t.message||"Failed to save scenario")}return!0}catch(t){return console.error("Save error:",t),e({error:t instanceof Error?t.message:"Failed to save scenario"}),!1}},setError:t=>e({error:t}
1),setLLMRequest:t=>{e({llmRequest:t})},setLLMResponse:t=>{e({llmResponse:t})},saveSmartScenarioData:async()=>{let r=t(),a='"<s>[INST] <<SYS>>'.concat(r.llmRequest,"<</SYS>>Generate a complete role-play scenario configuration object using the provided information in the system message. ONLY provide the JSON object and DO NOT include any additional information.[/INST] ").concat(r.llmResponse,'</s>"\n'),o={useCase:"Smart Scenario",learnerRole:r.learnerRole,scenarioDescription:r.scenarioDescription,request:r.llmRequest,response:r.llmResponse,fineTuneRecord:a};try{let e=await fetch("/api/smart_scenarios/saveSmartScenarioData",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!e.ok){let t=await e.json();throw Error(t.message||"Failed to save smart scenario data")}}catch(t){console.error("[saveSmartScenarioData] Failed to save smart scenario data:",t),e({error:t instanceof Error?t.message:"Failed to save scenario"})}},getSelectedPersonaDetails:e=>{let{persona:r}=t(),{personas:a}=u.G.getState(),o=e||r;return a.find(e=>e.persona_id===o)||void 0},getSelectedScorecardDetails:e=>{let{scorecard:r}=t(),{scorecards:a}=S.H.getState(),{getSelectedAssignmentDetails:o,assignments:n}=m.Q.getState(),i=e||r,s=a.find(e=>e.scorecard_id===i);if(s&&s.scorecardAssignments){let e=JSON.parse(s.scorecardAssignments);if(!e||0===e.length||0===n.length)return{...s,scorecardAssignments:[]};let t=e.map(e=>o(e));return{...s,scorecardAssignments:t}}return s},getSelectedProductDetails:e=>{let{product:r}=t(),{products:a}=w.a.getState(),o=e||r;return a.find(e=>e.productId===o)||{productId:"",productName:"",description:"",org_id:"",value:"",differentiator:""}},getSelectedCallPurposeDetails:e=>{let{callPurpose:r}=t(),{callPurposes:a}=E.M.getState(),o=e||r;return a.find(e=>e.callPurposeId===o)||{callPurposeId:"",name:"",org_id:"",description:"",prompt:""}},getSelectedAgentDetails:e=>{let{agent:r}=t(),{getSelectedAgentDetails:a}=I.E.getState();return a(e||r)},doesScorecardRequireProduct:e=>{let{scorecards:r}=S.H.getState(),a=t().getSelectedScorecardDetails();if(!a||!a.scorecardAssignments)return!1;try{return("string"==typeof a.scorecardAssignments?JSON.parse(a.scorecardAssignments):a.scorecardAssignments).some(e=>"Product Knowledge"===e.name)}catch(e){return console.error("Error checking scorecard assignments:",e),!1}}}))},36397:(e,t,r)=>{r.d(t,{Z:()=>n});var a=r(61170);let o={stripeId:void 0,stripeProductId:void 0,paidPlan:void 0,title:void 0,price:void 0,isAnnual:void 0,hasPaidPlan:!1,hasPersonalPlan:!1,hasBusinessPlan:!1,hasPilotPlan:!1,isLicensed:void 0,billingAdminHasBusinessPlan:void 0},n=(0,a.U)(e=>({...o,setSubscriptionState:t=>{e(e=>({...e,...t}))},resetSubscriptionStore:()=>{e(o)}}))}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.