@expedite-commerce/expedite-components 0.2.104 → 0.2.105

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -38175,6 +38175,11 @@ const tE = ["innerHTML"], nE = {
38175
38175
  height: "100vh"
38176
38176
  }),
38177
38177
  validator: (e) => typeof (e == null ? void 0 : e.height) == "string"
38178
+ },
38179
+ resources: {
38180
+ type: Object,
38181
+ required: !1,
38182
+ default: () => ({})
38178
38183
  }
38179
38184
  },
38180
38185
  emits: [
@@ -38217,6 +38222,7 @@ const tE = ["innerHTML"], nE = {
38217
38222
  };
38218
38223
  });
38219
38224
  nn(async () => {
38225
+ var D;
38220
38226
  console.log("security", C), console.log("apiKey", S), n.updateConfig({
38221
38227
  userId: v == null ? void 0 : v.userId,
38222
38228
  organizationId: v == null ? void 0 : v.organizationId,
@@ -38233,7 +38239,8 @@ const tE = ["innerHTML"], nE = {
38233
38239
  graphqlEndpoint: M,
38234
38240
  apiKey: (C == null ? void 0 : C.apiKey) || S,
38235
38241
  cid: v == null ? void 0 : v.contactId,
38236
- isPreview: k
38242
+ isPreview: k,
38243
+ siteUrl: (D = b.resources) == null ? void 0 : D.siteUrl
38237
38244
  });
38238
38245
  }), yt(async () => {
38239
38246
  var U, K, W, ee;
@@ -38455,7 +38462,7 @@ const tE = ["innerHTML"], nE = {
38455
38462
  ]);
38456
38463
  };
38457
38464
  }
38458
- }, j0 = /* @__PURE__ */ De(yk, [["__scopeId", "data-v-40bb4f79"]]), vk = {
38465
+ }, j0 = /* @__PURE__ */ De(yk, [["__scopeId", "data-v-920099b8"]]), vk = {
38459
38466
  ExpediteConfigurator: Dl,
38460
38467
  ExpediteGPT: Zc,
38461
38468
  ExpediteCatalog: Ml,
@@ -161,4 +161,4 @@
161
161
  `+it),oe&&Lr([N,I,L],Pt=>{it=Ro(it,Pt," ")}),x&&Y?x.createHTML(it):it},r.setConfig=function(){let Ce=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Yt(Ce),ue=!0},r.clearConfig=function(){Et=null,ue=!1},r.isValidAttribute=function(Ce,ce,ye){Et||Yt({});const be=$e(Ce),Le=$e(ce);return io(be,Le,ye)},r.addHook=function(Ce,ce){typeof ce=="function"&&Mo(v[Ce],ce)},r.removeHook=function(Ce,ce){if(ce!==void 0){const ye=b_(v[Ce],ce);return ye===-1?void 0:x_(v[Ce],ye,1)[0]}return Hu(v[Ce])},r.removeHooks=function(Ce){v[Ce]=[]},r.removeAllHooks=function(){v=e0()},r}var M_=t0();const R_=["innerHTML"],n0=xe({__name:"MarkdownRenderer",props:{source:{type:String,default:""},wrapperClass:{type:[String,Array,Object],default:""}},setup(t){const r=t,n=new Ut({html:!1,linkify:!0,breaks:!0}),o=e.computed(()=>{const a=n.render(r.source||"");return M_.sanitize(a)});return(a,i)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["markdown-renderer",t.wrapperClass]),innerHTML:o.value},null,10,R_))}},[["__scopeId","data-v-ecacea26"]]),L_={class:"message-content"},P_={key:0,class:"message-name"},q_={class:"ect-w-full"},$_={class:"message-content"},U_={class:"message-text ect-relative"},z_={class:"ect-pr-1"},j_={class:"loading-message-skeleton"},H_={key:1,class:"buttons-wrapper ect-mt-[-8px]"},G_=xe({__name:"chatMessages",props:{undoId:{type:String,default:""},strikethroughIds:{type:Array,default:()=>[]},messages:{type:Array,required:!0,default:()=>[]},chatIndex:{type:Number,default:0},dataChanged:{type:Boolean,default:!1},loadingMessage:{type:String,default:""},buttonLinks:{type:Array,default:()=>[]}},setup(t){const r=vl(),n=e.ref(null),o=e.ref(null);$n();const a=qn(),i=Jn(),l=t,s=e.computed(()=>!(i!=null&&i.activeComponentKey)),c=()=>{n.value&&n.value.scrollTo({top:n.value.scrollHeight,behavior:"smooth"})};e.watchEffect(()=>{l.messages.length>0&&e.nextTick(()=>{c()})}),e.watchEffect(()=>{l.loadingMessage&&e.nextTick(()=>{c(),o.value&&(o.value.scrollTop=o.value.scrollHeight)})});const u=e.computed(()=>{var d;return(d=a.chatStyles)==null?void 0:d.bgColor}),f=e.computed(()=>`linear-gradient(180deg, ${u.value} 0%, transparent 100%)`),g=e.computed(()=>{var d;return(d=a.chatStyles)==null?void 0:d.textColor}),h=(d,_,p=!1)=>{if(typeof d=="string"&&d.startsWith("playbookNavigate:")){const C=d.slice(17);i.navigateToBean(C);return}d==="addProducts"?i.loadComponent("catalog"):d==="quoteDocument"?r.openQuoteDocument(_.requestId):d==="quoteItem"?i.loadComponent("cart"):d==="Undo"&&a.undoAction(_.requestId)},m=d=>{if(!d)return"";let _=d.replace(/\\r\\n/g,`
162
162
  `).replace(/\\n/g,`
163
163
  `).replace(/\\r/g,`
164
- `);return _=_.replace(/^[ \t]*•[ \t]+/gm,"- "),_};return(d,_)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["chat-messages",{"root-path":s.value}])},[e.createElementVNode("div",{class:"chat-gradient",style:e.normalizeStyle({background:f.value})},null,4),e.createElementVNode("div",{ref_key:"chatMessagesRef",ref:n,class:"messages-wrapper"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList([...t.messages],(p,C)=>{var y;return e.openBlock(),e.createElementBlock("div",{key:C,class:e.normalizeClass(["message",{"user-message":p.type==="user"}])},[e.createElementVNode("div",L_,[p.name?(e.openBlock(),e.createElementBlock("div",P_,e.toDisplayString(p.name),1)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["message-text ect-relative",{"error-message":p.error,strikethrough:p.undone}]),style:e.normalizeStyle(p.type==="user"?{color:g.value,backgroundColor:u.value}:{})},[e.createElementVNode("div",q_,[e.createVNode(n0,{source:m(p.message)},null,8,["source"])]),((y=p==null?void 0:p.filesData)==null?void 0:y.length)>0?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(p==null?void 0:p.filesData,b=>(e.openBlock(),e.createBlock(P7,{key:b.name,info:{iconUrl:(b==null?void 0:b.type)==="csv"?e.unref(Zc):e.unref(Jc),fileName:b==null?void 0:b.name,fileSize:b==null?void 0:b.size},background:p.type=="user"?"#fff":"#f8f8f8","encoded-string":b==null?void 0:b.encodedString},null,8,["info","background","encoded-string"]))),128)):e.createCommentVNode("",!0)],6)])],2)}),128)),t.loadingMessage?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["loading-message",{"thinking-message":e.unref(a).isThinkingMessage}])},[e.createElementVNode("div",{class:e.normalizeClass(["ect-flex ect-gap-3",{"ect-w-full":e.unref(a).isThinkingMessage}])},[e.createElementVNode("div",$_,[e.createElementVNode("div",U_,[e.createElementVNode("div",{ref_key:"loadingWindowRef",ref:o,class:"loading-window"},[e.createElementVNode("div",z_,[e.createVNode(n0,{source:m(t.loadingMessage)},null,8,["source"])])],512)]),e.createElementVNode("div",j_,[e.createVNode(wo,{style:{height:"100%",width:"100%"}})])])],2)],2)):t.buttonLinks.length>0?(e.openBlock(),e.createElementBlock("div",H_,[e.createVNode(V7,{links:t.buttonLinks,onPerformAction:h},null,8,["links"])])):e.createCommentVNode("",!0)],512)],2))}},[["__scopeId","data-v-d6e07984"]]),K_={class:"ai-upload ect-flex-inline ect-items-center"},X_=xe({__name:"FileUpload",props:{resetFileInput:{type:Boolean,default:!1}},emits:["upload-status","error"],setup(t,{emit:r}){const n=t,o=r,a=e.ref(null),i=e.ref(""),l=e.ref(""),s=e.ref(!1);e.watch(()=>n.resetFileInput,g=>{g&&a.value&&(a.value.value="",i.value="",l.value="")});const c=g=>{const m=a.value.accept.split(",").map(_=>_.trim().toLowerCase()),d="."+g.name.split(".").pop().toLowerCase();return m.includes(d)||m.includes(g.type.toLowerCase())?!0:m.some(_=>{if(_.includes("*")){const p=_.split("*")[0];return g.type.toLowerCase().startsWith(p)}return!1})},u=async g=>{const h=g.target.files[0];if(console.info("File = ",h),h){if(!c(h)){a.value&&(a.value.value="");const d={message:"Invalid file type. Please upload a valid file type.",fileName:h.name,fileType:h.type};window&&window.$toast&&window.$toast.add({severity:"error",summary:"File Upload Error",detail:d.message,life:5e3}),o("error",d);return}i.value=h.name,l.value=h.type.split("/").pop(),o("upload-status",{status:"uploading",fileName:i.value,fileType:l.value});const m=new FileReader;m.onload=async d=>{const _=new Blob([d.target.result],{type:h.type});console.info("Blob data:",_);try{const p=await j0(_),C={attachment:{name:h.name,data:p}};console.info("AIRequestPayload = ",C),o("upload-status",{status:"uploaded",fileName:i.value,fileType:l.value,size:El(h.size),fileData:C}),a.value&&(a.value.value="")}catch(p){console.info("[ERROR]: File upload error:",p),window&&window.$toast&&window.$toast.add({severity:"error",summary:"File Processing Error",detail:"Error processing file: "+(p.message||"Unknown error"),life:5e3}),o("error",{message:"Error processing file",fileName:i.value,fileType:l.value,error:p.message}),o("upload-status",{status:"error",fileName:i.value,fileType:l.value})}},m.onerror=d=>{console.info("[ERROR]: FileReader error:",d),window&&window.$toast&&window.$toast.add({severity:"error",summary:"File Reading Error",detail:"Could not read the selected file",life:5e3}),o("error",{message:"Error reading file",fileName:h.name,fileType:h.type,error:d})},setTimeout(()=>{m.readAsText(h)},100)}},f=()=>{a.value.click()};return(g,h)=>(e.openBlock(),e.createElementBlock("div",K_,[e.createElementVNode("input",{ref_key:"fileInput",ref:a,type:"file",accept:".csv, .xls, .xlsx, text/csv, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",class:"ect-opacity-0 ect-h-0 ect-w-0 ect-absolute",onChange:u},null,544),e.createElementVNode("button",{class:"attachment-button",onClick:f,onMouseenter:h[0]||(h[0]=m=>s.value=!0),onMouseleave:h[1]||(h[1]=m=>s.value=!1)},[e.createVNode(we,{icon:"attachment",size:"11",height:"17",color:s.value?"#198708":"#828282"},null,8,["color"])],32)]))}},[["__scopeId","data-v-7fbbb7c9"]]),W_={key:0,class:"suggestions-container"},Q_={key:0,class:"logo-section"},Z_={class:"help-text-section"},J_={key:0,class:"help-text"},Y_={key:1,class:"sub-help-text"},eC=["onClick"],tC={key:2,class:"suggestions-list"},nC=["onClick"],oC=xe({__name:"AISuggestionsDropdown",props:{options:{type:Array,required:!0},helpText:{type:String,default:""},subHelpText:{type:String,default:""},showSuggestions:{type:Boolean,default:!1}},emits:["select","preview"],setup(t,{emit:r}){const n=t,o=r,a=e.ref(0),i=e.ref(0),l=e.ref(null),s=e.ref(null),c=h=>{l.value=h,i.value=0},u=()=>{l.value=null,a.value=0},f=h=>{o("select",h)},g=h=>{if(n.showSuggestions)switch(h.key){case"ArrowDown":h.preventDefault(),l.value?(i.value=(i.value+1)%l.value.subOptions.length,o("preview",l.value.subOptions[i.value])):(a.value=(a.value+1)%n.options.length,o("preview",n.options[a.value].title));break;case"ArrowUp":h.preventDefault(),l.value?(i.value=i.value-1<0?l.value.subOptions.length-1:i.value-1,o("preview",l.value.subOptions[i.value])):(a.value=a.value-1<0?n.options.length-1:a.value-1,o("preview",n.options[a.value].title));break;case"Enter":h.preventDefault(),l.value?f(l.value.subOptions[i.value]):c(n.options[a.value]);break;case"Escape":case"ArrowLeft":case"Backspace":l.value&&(h.preventDefault(),u());break}};return e.watch(()=>n.showSuggestions,h=>{h?(window.addEventListener("keydown",g),l.value=null,a.value=0,i.value=0):window.removeEventListener("keydown",g)}),(h,m)=>t.showSuggestions?(e.openBlock(),e.createElementBlock("div",W_,[l.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Q_,[e.createVNode(t3)])),e.createElementVNode("div",Z_,[t.helpText&&!l.value?(e.openBlock(),e.createElementBlock("div",J_,e.toDisplayString(t.helpText),1)):e.createCommentVNode("",!0),t.subHelpText?(e.openBlock(),e.createElementBlock("div",Y_,e.toDisplayString(t.subHelpText),1)):e.createCommentVNode("",!0)]),l.value?(e.openBlock(),e.createElementBlock("div",tC,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value.subOptions,(d,_)=>(e.openBlock(),e.createElementBlock("div",{key:_,class:e.normalizeClass(["sub-option",{"sub-active":i.value===_}]),onClick:p=>f(d)},e.toDisplayString(d),11,nC))),128))])):(e.openBlock(),e.createElementBlock("div",{key:1,ref_key:"suggestionsList",ref:s,class:"suggestions-list"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.options,(d,_)=>(e.openBlock(),e.createElementBlock("div",{key:_,class:e.normalizeClass(["suggestion-item",{active:a.value===_}]),onClick:p=>c(d)},e.toDisplayString(d.title),11,eC))),128))],512))])):e.createCommentVNode("",!0)}},[["__scopeId","data-v-bbb514b3"]]),rC={class:"chat-file-info"},aC={class:"ect-flex ect-gap-2 ect-items-center ect-self-stretch ect-my-auto ect-text-xs ect-font-medium ect-text-black"},iC=["src"],lC={class:"ect-self-stretch ect-my-auto"},sC={key:0,class:"ect-flex ect-gap-2 ect-justify-center ect-items-center ect-self-stretch ect-my-auto ect-w-4 ect-h-4"},cC=xe({__name:"ChatInputFileInfo",props:{fileInfo:{type:Object,required:!0}},emits:["cancel"],setup(t,{emit:r}){const n=r,o=()=>{n("cancel")};return(a,i)=>(e.openBlock(),e.createElementBlock("div",rC,[e.createElementVNode("div",aC,[e.createElementVNode("img",{loading:"lazy",src:t.fileInfo.fileType==="csv"?e.unref(Zc):e.unref(Jc),class:"ect-object-contain ect-shrink-0 ect-self-stretch ect-my-auto ect-w-7 ect-aspect-square",alt:""},null,8,iC),e.createElementVNode("div",lC,e.toDisplayString(t.fileInfo.fileName),1)]),t.fileInfo.status==="uploading"?(e.openBlock(),e.createElementBlock("div",sC,[e.createVNode(ui,{size:18})])):e.createCommentVNode("",!0),t.fileInfo.status==="uploaded"?(e.openBlock(),e.createElementBlock("button",{key:1,class:"ect-flex ect-gap-2 ect-justify-center ect-items-center ect-self-stretch ect-my-auto ect-w-4 ect-h-4",onClick:o},[e.createVNode(we,{icon:"close",size:"8"})])):e.createCommentVNode("",!0)]))}},[["__scopeId","data-v-24d881bd"]]),uC={class:"chat-input-wrapper"},dC={class:"chat-input-inner"},fC={class:"input-row"},hC=["disabled","placeholder","onKeydown"],pC={key:1,class:"icon-wrapper"},mC={class:"icon-wrapper"},yC=xe({__name:"chatInput",props:{modelValue:{type:String,default:""},loading:{type:Boolean,default:!1},placeholder:{type:String,default:"Ask Genesis AI"},helpText:{type:String,default:"Here are few areas where I can help"},subHelpText:{type:String,default:"Suggestions by Genesis (Click to Apply)"},showFile:{type:Boolean,default:!1},showMic:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},emits:["update:modelValue","submit","speak","file-upload-status"],setup(t,{emit:r}){const n=t,o=r;qn();const a=Vt(),i=Jn(),l=e.ref({}),s=e.ref(!1),c=e.ref(!1),u=e.ref(n.modelValue),f=e.ref(null),g=e.computed(()=>{const k=i.currentStep||null;return(Array.isArray(k==null?void 0:k.promptGuidance)?k.promptGuidance:[]).slice().sort((S,v)=>Number((S==null?void 0:S.sequenceNumber)??0)-Number((v==null?void 0:v.sequenceNumber)??0)).map(S=>{const N=(Array.isArray(S==null?void 0:S.relatedPG)?S.relatedPG:[]).slice().sort((I,L)=>Number((I==null?void 0:I.sequenceNumber)??0)-Number((L==null?void 0:L.sequenceNumber)??0)).map(I=>I.pgName);return{title:S.pgName,subOptions:N}})}),h=e.computed(()=>{var k;return(k=g.value)!=null&&k.length?g.value:[]}),m=e.computed(()=>{var k;return(k=g.value)!=null&&k.length?"Prompt Guidance":n.helpText});e.watch(()=>n.loading,async(k,B)=>{!k&&B&&(await e.nextTick(),f.value.focus())}),e.watch(u,k=>{o("update:modelValue",k),e.nextTick(()=>x())}),e.watch(()=>n.modelValue,k=>{u.value=k});const d=k=>{console.info("[ERROR]: File upload error:",k),a.handleError(k,"ChatInput")},_=()=>{u.value.trim()&&(c.value=!1,o("submit",u.value),u.value="",f.value&&(f.value.style.height="32px"),l.value=null)},p=k=>{u.value=k,c.value=!1,e.nextTick(()=>{x(),f.value&&(f.value.focus(),f.value.selectionStart=f.value.selectionEnd=u.value.length)})},C=k=>{u.value=k,e.nextTick(()=>x())},y=()=>{c.value=!1},b=k=>{console.info("handleFileUploadStatus event = ",k),k!=null&&k.fileName?(l.value=k,o("file-upload-status",k)):(l.value=null,s.value=!0,o("file-upload-status",null),setTimeout(()=>{s.value=!1},3e3))},x=()=>{const k=f.value;if(!k)return;k.style.height="auto";const S=Math.max(32,Math.min(k.scrollHeight,120));k.style.height=`${S}px`},E=()=>{console.info("removeFile"),l.value=null,s.value=!0,o("file-upload-status",null),setTimeout(()=>{s.value=!1},100)},A=()=>{c.value=!1,x()};return(k,B)=>{var S,v,N,I,L;const D=e.resolveDirective("click-outside");return e.withDirectives((e.openBlock(),e.createElementBlock("div",uC,[e.createVNode(oC,{options:h.value,"help-text":m.value,"sub-help-text":t.subHelpText,"show-suggestions":c.value,onSelect:p,onPreview:C},null,8,["options","help-text","sub-help-text","show-suggestions"]),e.createElementVNode("div",dC,[e.createElementVNode("div",fC,[e.createElementVNode("div",{class:e.normalizeClass(["icon-wrapper",{"active-suggestions":c.value,disabled:((S=h.value)==null?void 0:S.length)<=0}])},[e.createVNode(we,{disabled:((v=h.value)==null?void 0:v.length)<=0||t.loading,color:((N=h.value)==null?void 0:N.length)<=0?"#DEDEDE":c.value?"#198708":"#828282",icon:"suggestions",size:"13",height:15,onClick:B[0]||(B[0]=z=>c.value=!c.value)},null,8,["disabled","color"])],2),e.withDirectives(e.createElementVNode("textarea",{ref_key:"textareaRef",ref:f,"onUpdate:modelValue":B[1]||(B[1]=z=>u.value=z),disabled:t.loading,placeholder:t.placeholder,rows:"1",onKeydown:e.withKeys(e.withModifiers(_,["exact","prevent"]),["enter"]),onInput:A},null,40,hC),[[e.vModelText,u.value]]),t.showFile?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["icon-wrapper",{"file-upload-disabled":t.loading}])},[e.createVNode(X_,{"reset-file-input":s.value,onUploadStatus:b,onError:d},null,8,["reset-file-input"])],2)):e.createCommentVNode("",!0),t.showMic?(e.openBlock(),e.createElementBlock("div",pC,[e.createVNode(we,{color:"#828282",disabled:t.loading,icon:"mic",size:"13",height:15,onClick:B[2]||(B[2]=z=>k.$emit("speak"))},null,8,["disabled"])])):e.createCommentVNode("",!0),e.createElementVNode("div",mC,[(e.openBlock(),e.createBlock(we,{key:1,disabled:t.loading,icon:"send",size:"20",onClick:_},null,8,["disabled"]))])]),((I=l.value)==null?void 0:I.status)==="uploading"||((L=l.value)==null?void 0:L.status)==="uploaded"?(e.openBlock(),e.createBlock(cC,{key:0,class:"ect-mt-3 ect-mb-0.5","file-info":l.value,onCancel:E},null,8,["file-info"])):e.createCommentVNode("",!0)])])),[[D,y]])}}},[["__scopeId","data-v-e205d71c"]]),gC=["data-test-id"],bC=["data-test-id"],xC=["data-test-id"],_C=xe({__name:"aiChat",props:{dataTestId:{type:String,required:!0},isExternalGuidance:{type:Boolean,required:!1,default:!1},styles:{type:Object,required:!1,default:()=>({}),validator:t=>typeof(t==null?void 0:t.height)=="string"}},setup(t){const r=Jn(),n=qn(),o=e.ref(null),a=e.computed(()=>{var c;return((c=r.getCurrentStepLinks)==null?void 0:c.call(r))||[]}),i=e.computed(()=>!0),l=c=>{console.info("[aiChat] handleSubmit",{hasFileData:!!o.value,messageLength:(c||"").length}),o.value?(console.info("[aiChat] sending with file attachment"),n.sendMessage(c,!0,o.value)):(console.info("[aiChat] sending without attachment"),n.sendMessage(c))},s=c=>{console.info("ChatScreen handleFileUploadStatus event = ",c),c!=null&&c.fileData?(o.value=c.fileData,n.attachmentData={size:c.size,type:c.fileType,name:c.fileName}):(o.value=null,n.attachmentData=null)};return(c,u)=>(e.openBlock(),e.createElementBlock("div",{class:"chat-screen","data-test-id":t.dataTestId},[e.createElementVNode("div",{class:e.normalizeClass(["messages-container",{"playbook-steps-mode-hybrid":e.unref(r).playbookStepsMode==="hybrid","playbook-steps-mode-full":e.unref(r).playbookStepsMode==="full","dxp-guiddance":t.isExternalGuidance}]),style:e.normalizeStyle({maxHeight:`calc(${t.styles.height} - 72px)`,height:`calc(${t.styles.height} - 72px)`}),"data-test-id":`${t.dataTestId}-messages-container`},[e.createVNode(G_,{messages:e.unref(n).chatHistory,"loading-message":e.unref(n).loadingMessage,"undo-id":e.unref(n).latestDMLRequest,"button-links":a.value,"strikethrough-ids":e.unref(n).strikethroughHistory,"data-changed":e.unref(n).dataManuallyChanged,"data-test-id":`${t.dataTestId}-messages`},null,8,["messages","loading-message","undo-id","button-links","strikethrough-ids","data-changed","data-test-id"])],14,bC),e.createElementVNode("div",{class:"input-container","data-test-id":`${t.dataTestId}-input-container`},[e.createVNode(yC,{modelValue:e.unref(n).promptMessage,"onUpdate:modelValue":u[0]||(u[0]=f=>e.unref(n).promptMessage=f),disabled:!i.value,"file-info":o.value,loading:!!e.unref(n).loadingMessage,"data-test-id":`${t.dataTestId}-input`,onSubmit:l,onFileUploadStatus:s},null,8,["modelValue","disabled","file-info","loading","data-test-id"])],8,xC)],8,gC))}},[["__scopeId","data-v-99005673"]]),CC={class:"ect-h-full ect-w-full ect-flex ect-items-center ect-justify-center","data-test-id":"configurator-not-found"},EC={class:"ect-max-w-[720px] ect-p-[50px] ect-border ect-rounded-lg ect-bg-white ect-shadow-sm"},kC={class:"ect-text-[40px] ect-leading-none ect-mb-3"},vC=e.createElementVNode("div",{class:"ect-text-[22px] ect-font-normal ect-leading-normal ect-mb-[12px] ect-capitalize ect-text-[#5F5F5F]","data-test-id":"configurator-not-found-title"}," Product Configurator Not Found ",-1),AC=e.createElementVNode("div",{class:"ect-text-sm ect-text-gray-500","data-test-id":"configurator-not-found-subtitle"}," Linked composable product configurator UI component for this screen is not found OR the composable product configurator UI component does not exist. Please create / connect one and try again. ",-1),wC={class:"ect-mt-4 ect-flex ect-items-center ect-justify-between ect-gap-6"},NC={__name:"MoleculeConfiguratorNotFound",emits:["return","go-cart"],setup(t){return(r,n)=>(e.openBlock(),e.createElementBlock("div",CC,[e.createElementVNode("div",EC,[e.createElementVNode("div",kC,[e.createVNode(we,{icon:"error",size:48})]),vC,AC,e.createElementVNode("div",wC,[e.createElementVNode("button",{type:"button",class:"ect-text-green-600 ect-text-sm ect-font-medium",onClick:n[0]||(n[0]=o=>r.$emit("return")),"data-test-id":"configurator-not-found-return"}," RETURN TO PRODUCT RESULTS "),e.createElementVNode("button",{type:"button",class:"ect-text-green-600 ect-text-sm ect-font-medium",onClick:n[1]||(n[1]=o=>r.$emit("go-cart")),"data-test-id":"configurator-not-found-go-to-cart"}," GO TO CART ")])])]))}},o0=t=>(e.pushScopeId("data-v-3c362460"),t=t(),e.popScopeId(),t),SC={class:"ect-h-full ect-w-full ect-bg-white","data-test-id":"aiComponentLoader-wrapper"},BC={key:2,class:"ect-h-full ect-w-full ect-flex ect-items-center ect-justify-center","data-test-id":"aiComponentLoader-cart-error"},IC=[o0(()=>e.createElementVNode("div",{class:"ect-text-center"},[e.createElementVNode("div",{class:"ect-text-base ect-font-medium ect-text-red-600","data-test-id":"aiComponentLoader-cart-error-title"}," Quote Required "),e.createElementVNode("div",{class:"ect-text-sm ect-text-gray-500 ect-mt-2","data-test-id":"aiComponentLoader-cart-error-message"}," A quote is required for the cart component to work. Please ensure a quoteId is provided in the session prop. ")],-1))],OC={key:5,class:"ect-h-full ect-w-full ect-flex ect-items-center ect-justify-center"},TC={class:"ect-text-center"},DC=o0(()=>e.createElementVNode("div",{class:"ect-text-base ect-font-medium","data-test-id":"aiComponentLoader-fallback-title"}," No component to display for this step ",-1)),VC={class:"ect-text-sm ect-text-gray-500 ect-mt-2","data-test-id":"aiComponentLoader-fallback-subtitle"},FC=xe({__name:"aiComponentLoader",props:{stepComponent:{type:String,default:null},identity:{type:Object,default:()=>({})},session:{type:Object,default:()=>({})},security:{type:Object,default:()=>({})},packageVersion:{type:String,default:""},composablesOrgType:{type:String,default:""},composablesApiKey:{type:String,default:""},templateId:{type:String,default:""},hostName:{type:String,default:""},graphqlEndpoint:{type:String,default:""},apiKey:{type:String,default:""},isPreview:{type:Boolean,default:!1},sections:{type:Array,default:()=>[]},theme:{type:Object,default:()=>({})},catalogPreviewData:{type:Object,default:()=>({})},catalogInitialData:{type:Array,default:()=>[]},catalogSearchTerm:{type:String,default:""},onCatalogCountUpdate:{type:Function,default:null},cartSections:{type:String,default:""},configItemId:{type:String,default:""},configQliId:{type:String,default:""},configApiKey:{type:String,default:""},functions:{type:Object,default:()=>({})}},emits:["expeditecart-clicked","ai-guidance:error","catalog-quote-created","catalog-quote-updated","catalog-items-loaded","catalog-item-added","catalog-item-qty-updated","catalog-line-deleted","catalog-items-fetched","catalog-item-configure"],setup(t,{emit:r}){const n=r,o=t,a=Jn(),i=ai(),l=lt(),s=e.computed(()=>{var j,G,Z,oe,ae;const P=((j=o.session)==null?void 0:j.quoteId)||((G=l.quoteId)==null?void 0:G.value)||((Z=a==null?void 0:a.activeComponentData)==null?void 0:Z.contextObjectId)||((ae=(oe=a==null?void 0:a.activeComponentData)==null?void 0:oe.payload)==null?void 0:ae.contextObjectId);return{...o.session,...P&&{quoteId:P},qliId:p.value||o.configQliId||void 0,itemId:_.value}}),c=e.computed(()=>{const P=o.functions||{},j=P.createQuote;return typeof j!="function"?P:{...P,createQuote:async(...G)=>{const Z=await j(...G);return Z&&l.updateConfig({quoteId:Z}),Z}}}),u=e.computed(()=>{const P=a==null?void 0:a.activeComponentKey,j=o.stepComponent;return(P||j||"").toString().trim().toLowerCase().replace(/[^a-z0-9]+/g,"_")}),f=e.computed(()=>{var oe,ae;const P=!!o.templateId,j=!!((oe=o.identity)!=null&&oe.organizationId),G=!!((ae=o.identity)!=null&&ae.accountId),Z=typeof o.cartSections=="string"&&o.cartSections.length>0;return P&&j&&G&&Z}),g=e.computed(()=>{var Z,oe,ae,ee,ue;const P=(Z=o.session)==null?void 0:Z.quoteId,j=(oe=l.quoteId)==null?void 0:oe.value,G=((ae=a==null?void 0:a.activeComponentData)==null?void 0:ae.contextObjectId)||((ue=(ee=a==null?void 0:a.activeComponentData)==null?void 0:ee.payload)==null?void 0:ue.contextObjectId);return!!(P||j||G)}),h=e.computed(()=>{var j,G,Z,oe,ae;const P=((j=o.session)==null?void 0:j.quoteId)||((G=l.quoteId)==null?void 0:G.value)||((Z=a==null?void 0:a.activeComponentData)==null?void 0:Z.contextObjectId)||((ae=(oe=a==null?void 0:a.activeComponentData)==null?void 0:oe.payload)==null?void 0:ae.contextObjectId);return{...o.session,...P&&{quoteId:P}}}),m=e.computed(()=>{var j;if(Array.isArray(o.catalogInitialData)&&o.catalogInitialData.length>0)return o.catalogInitialData;const P=((j=a==null?void 0:a.activeComponentData)==null?void 0:j.payload)||{};if(P.catalog&&typeof P.catalog=="object")try{const Z=Object.values(P.catalog).map(oe=>{var ae;return(ae=oe==null?void 0:oe.catalogResponse)==null?void 0:ae.productInfo}).filter(Boolean);if(Z.length>0)return Z}catch{}return Array.isArray(P.initialData)&&P.initialData.length>0?P.initialData:Array.isArray(P.catalogInitialData)&&P.catalogInitialData.length>0?P.catalogInitialData:Array.isArray(P.items)&&P.items.length>0?P.items:[]}),d=e.computed(()=>{var j;const P=((j=a==null?void 0:a.activeComponentData)==null?void 0:j.payload)||{};return o.catalogSearchTerm||P.searchTerm||""}),_=e.computed(()=>{var j,G,Z,oe,ae,ee;const P=((oe=(Z=(G=(j=a==null?void 0:a.activeComponentData)==null?void 0:j.payload)==null?void 0:G.savedProducts)==null?void 0:Z[0])==null?void 0:oe.itemId)||((ae=a==null?void 0:a.activeComponentData)==null?void 0:ae.payload)&&Object.keys(((ee=a.activeComponentData.payload)==null?void 0:ee.quoteConfiguration)||{})[0]||"";return o.configItemId||P||""}),p=e.computed(()=>{var j,G,Z,oe,ae,ee,ue,de;const P=(oe=(Z=(G=(j=a==null?void 0:a.activeComponentData)==null?void 0:j.payload)==null?void 0:G.savedProducts)==null?void 0:Z[0])==null?void 0:oe.qliId;if(!P){console.log("[aiComponentLoader] configQliIdComputed: No qliId from savedProducts");const Q=(ee=(ae=a==null?void 0:a.activeComponentData)==null?void 0:ae.payload)==null?void 0:ee.quoteConfiguration;if(console.log("[aiComponentLoader] configQliIdComputed: quoteConfiguration:",Q),Q&&typeof Q=="object"){const X=Object.keys(Q)[0];if(console.log("[aiComponentLoader] configQliIdComputed: firstItemId:",X),X){const Y=(ue=Q[X])==null?void 0:ue.product;if(console.log("[aiComponentLoader] configQliIdComputed: productObj:",Y),Y&&Y.qliId)return console.log("[aiComponentLoader] configQliIdComputed: found qliId in productObj:",Y.qliId),Y.qliId;if((de=Q[X])!=null&&de.qliId)return console.log("[aiComponentLoader] configQliIdComputed: found qliId directly under itemId:",Q[X].qliId),Q[X].qliId}}}return P||""}),C=e.computed(()=>!!_.value),y=e.computed(()=>u.value==="configurator"&&!C.value?"Configurator requires an itemId (and optional qliId). Provide via playbook payload or props.":u.value==="catalog"?"Catalog step is active. Provide templateId/sections/theme when available.":u.value==="cart"?"Cart step is active.":"Awaiting playbook step selection."),b=e.computed(()=>{try{return JSON.stringify((a==null?void 0:a.activeComponentData)||{})}catch{return""}}),x=e.computed(()=>`catalog::${b.value}`),E=e.computed(()=>`cart::${b.value}`),A=e.computed(()=>{var P;try{return(((P=a==null?void 0:a.activeComponentData)==null?void 0:P.actionFunction)||"")==="Reload"}catch{return!1}}),k=e.computed(()=>{var j;const P=`configurator::${_.value||""}::${p.value||""}`;if(A.value){const G=((j=a==null?void 0:a.activeComponentData)==null?void 0:j.requestId)||"";return`${P}::${G}`}return P}),{emitError:B,emitErrors:D}=Qc(n,"aiComponentLoader"),S=()=>{const P=h1(a,u.value);D(P)},v=e.ref([]),N=e.ref(null),I=P=>{const j=Array.isArray(P)?P:Array.isArray(P==null?void 0:P.items)?P.items:[];if(!Array.isArray(j))return;const G={"Needs Configuration":1,"Suggests Configuration":2,"Fully Configured":3},Z=ee=>(ee==null?void 0:ee.requiresConfiguration)||"",oe=ee=>!!ee&&ee in G,ae=j.filter(ee=>oe(Z(ee)));ae.sort((ee,ue)=>{const de=Z(ee),Q=Z(ue);return(G[de]||99)-(G[Q]||99)}),v.value=ae,N.value=ae.length?ae[0]:null},L=P=>{console.log("onQuoteCreated",P),n("catalog-quote-created",P)},z=P=>{console.log("onQuoteUpdated",P),n("catalog-quote-updated",P)},q=P=>{console.log("onItemAdded",P),n("catalog-item-added",P)},W=P=>{console.log("onItemQtyUpdated",P),n("catalog-item-qty-updated",P)},te=P=>{console.log("onLineDeleted",P),n("catalog-line-deleted",P)},K=P=>{console.log("onQuoteItemsFetched",P),n("catalog-items-fetched",P)};e.watch(()=>u.value,(P,j)=>{var G,Z,oe,ae,ee,ue,de,Q,X,Y,J;if(P==="configurator"){const ne=!!((oe=(Z=(G=a==null?void 0:a.activeComponentData)==null?void 0:G.payload)==null?void 0:Z.savedProducts)!=null&&oe.length),le=!!((ee=(ae=a==null?void 0:a.activeComponentData)==null?void 0:ae.payload)!=null&&ee.quoteConfiguration&&Object.keys(((de=(ue=a==null?void 0:a.activeComponentData)==null?void 0:ue.payload)==null?void 0:de.quoteConfiguration)||{}).length>0);if(!ne&&!le&&N.value&&!_.value){const re=((Q=N.value)==null?void 0:Q.itemId)||"";if(re){const se=((X=a==null?void 0:a.currentPlaybook)==null?void 0:X.playBookSteps)||[],he=Ne=>String(Ne||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_");let me=null;const _e=se.findIndex(Ne=>Ne.stepName===(a==null?void 0:a.currentStepName));if(_e>=0&&se[_e+1]&&he((Y=se[_e+1])==null?void 0:Y.stepComponent)==="configurator")me=se[_e+1].stepName;else{const Ne=se.findIndex(ge=>he(ge==null?void 0:ge.stepComponent)==="configurator");me=Ne>=0?(J=se[Ne])==null?void 0:J.stepName:null}const Ee={payload:{savedProducts:[{itemId:re}]}};me?a.navigateToStep({stepName:me,data:Ee}):a.loadComponent("configurator",Ee)}}}});const R=()=>{var Z,oe;const P=((Z=a==null?void 0:a.currentPlaybook)==null?void 0:Z.playBookSteps)||[],j=ae=>String(ae||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_"),G=P.findIndex(ae=>j(ae==null?void 0:ae.stepComponent)==="catalog"||j(ae==null?void 0:ae.stepName).includes("catalog"));if(G>=0){const ae=(oe=P[G])==null?void 0:oe.stepName;a.navigateToStep({stepName:ae})}else a.loadComponent("catalog")},w=()=>{var Z,oe;const P=((Z=a==null?void 0:a.currentPlaybook)==null?void 0:Z.playBookSteps)||[],j=ae=>String(ae||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_"),G=P.findIndex(ae=>j(ae==null?void 0:ae.stepComponent)==="cart"||j(ae==null?void 0:ae.stepName).includes("cart"));if(G>=0){const ae=(oe=P[G])==null?void 0:oe.stepName;a.navigateToStep({stepName:ae})}else a.loadComponent("cart")},T=P=>{var j,G;console.log("onItemConfigureClicked",P),n("catalog-item-configure",P);try{const Z=(P==null?void 0:P.itemId)||"",oe=(P==null?void 0:P.qliId)||(P==null?void 0:P.QliId)||"",ae=[];if(Z){const X={itemId:Z};oe&&(X.qliId=oe),ae.push(X)}const ee={payload:{savedProducts:ae}},ue=((j=a==null?void 0:a.currentPlaybook)==null?void 0:j.playBookSteps)||[],de=X=>String(X||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_"),Q=ue.findIndex(X=>{const Y=de(X==null?void 0:X.stepComponent),J=de(X==null?void 0:X.stepName);return Y==="configurator"||J.includes("configure")});if(Q>=0){const X=(G=ue[Q])==null?void 0:G.stepName;a.navigateToStep({stepName:X,data:ee})}else a.loadComponent("configurator",ee)}catch(Z){console.warn("[aiComponentLoader] Failed to navigate to configurator from configure click:",Z),a.loadComponent("configurator",{payload:{}})}},O=P=>{console.log("onCartClicked",P),n("expeditecart-clicked",P)},M=P=>{var j,G;try{const Z=(P==null?void 0:P.itemId)||"",oe=(P==null?void 0:P.lineItemId)||(P==null?void 0:P.qliId)||"",ae=[];if(Z){const X={itemId:Z};oe&&(X.qliId=oe),ae.push(X)}const ee={payload:{savedProducts:ae}},ue=((j=a==null?void 0:a.currentPlaybook)==null?void 0:j.playBookSteps)||[],de=X=>String(X||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_"),Q=ue.findIndex(X=>{const Y=de(X==null?void 0:X.stepComponent),J=de(X==null?void 0:X.stepName);return Y==="configurator"||J.includes("configure")});if(Q>=0){const X=(G=ue[Q])==null?void 0:G.stepName;a.navigateToStep({stepName:X,data:ee})}else a.loadComponent("configurator",ee)}catch(Z){console.warn("[aiComponentLoader] Failed to navigate to configurator from cart configure click:",Z),a.loadComponent("configurator",{payload:{}})}},$=P=>{console.log("onCatalogIdReceived",P),l.updateConfig({eCatalogId:P})},F=P=>{console.log("Action",P),P.event==="add-to-quote"?n("configurator:add-to-quote",P.data):P.event==="save"&&n("configurator:save",P.data)},U=e.ref("");return e.watch(()=>a==null?void 0:a.activeComponentData,async P=>{var G,Z,oe;if(!P)return;console.log("activeComponentData Changed",P);const j=(P==null?void 0:P.requestId)||"";if(console.log("requestId",j),console.log("lastReloadRequestId",U.value),j&&j!==U.value)if(U.value=j,await e.nextTick(),(G=P==null?void 0:P.payload)!=null&&G.quoteConfiguration&&Object.keys(((Z=P==null?void 0:P.payload)==null?void 0:Z.quoteConfiguration)??{}).length>0){const ae=Object.keys(((oe=P==null?void 0:P.payload)==null?void 0:oe.quoteConfiguration)??{})[0];i.setPreConfigData(P==null?void 0:P.payload,ae)}else(P==null?void 0:P.actionFunction)==="Reload"&&(console.log("Reloading configurator 1"),i.refresh())},{deep:!0}),e.onMounted(()=>{e.nextTick(()=>{S()})}),(P,j)=>(e.openBlock(),e.createElementBlock("div",SC,[u.value==="catalog"?(e.openBlock(),e.createBlock(Nr,{key:x.value,"data-test-id":"aiComponentLoader-catalog",class:"ect-h-full ect-w-full","template-id":t.templateId,identity:t.identity,session:t.session,security:t.security,"search-term":d.value,"on-catalog-count-update":t.onCatalogCountUpdate,"preview-data":t.catalogPreviewData,"initial-data":m.value,sections:t.sections,theme:t.theme,"composables-org-type":t.composablesOrgType,onCatalogQuoteCreated:L,onCatalogQuoteUpdated:z,onCatalogItemsLoaded:I,onCatalogItemAdded:q,onCatalogItemQtyUpdated:W,onCatalogLineDeleted:te,onCatalogItemsFetched:K,onCatalogItemConfigure:T,"onCatalog:id":$},null,8,["template-id","identity","session","security","search-term","on-catalog-count-update","preview-data","initial-data","sections","theme","composables-org-type"])):u.value==="cart"&&f.value&&g.value?(e.openBlock(),e.createBlock(Sr,{key:E.value,"data-test-id":"aiComponentLoader-cart",class:"ect-h-full ect-w-full","template-id":t.templateId,"host-name":t.hostName,"composables-org-type":t.composablesOrgType,security:t.security,identity:t.identity,session:h.value,onExpeditecartItemConfigure:M,onExpeditecartClicked:O},null,8,["template-id","host-name","composables-org-type","security","identity","session"])):u.value==="cart"&&f.value&&!g.value?(e.openBlock(),e.createElementBlock("div",BC,IC)):u.value==="configurator"&&C.value?(e.openBlock(),e.createBlock(Cr,{key:k.value,"data-test-id":"aiComponentLoader-configurator",class:"ect-h-full ect-w-full",security:t.security,identity:t.identity,"user-locale":P.userLocale,cart:!0,"composables-org-type":t.composablesOrgType,session:s.value,functions:c.value,onReady:e.unref(i).setExpediteConfigComp,onAction:F},null,8,["security","identity","user-locale","composables-org-type","session","functions","onReady"])):u.value==="configurator"&&!C.value?(e.openBlock(),e.createBlock(NC,{key:4,onReturn:R,onGoCart:w})):(e.openBlock(),e.createElementBlock("div",OC,[e.createElementVNode("div",TC,[DC,e.createElementVNode("div",VC,e.toDisplayString(y.value),1)])]))]))}},[["__scopeId","data-v-3c362460"]]),MC={class:"ai-guidance-loader","data-test-id":"aiGuidance-loader-container"},RC={"data-test-id":"aiGuidance-loader-text"},LC={class:"aig-button","data-test-id":"aiGuidance-loader-button"},PC={class:"aig-input-box","data-test-id":"aiGuidance-loader-input"},qC=xe({__name:"AiGuidanceLoader",props:{errors:{type:Array,required:!1,default:()=>[]},chatBgColor:{type:String,required:!1,default:""}},setup(t){const r=t,n=e.computed(()=>`linear-gradient(180deg, ${r.chatBgColor} 0%, transparent 100%)`);return(o,a)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{class:"chat-gradient",style:e.normalizeStyle({background:n.value})},null,4),e.createElementVNode("div",MC,[e.createElementVNode("div",RC,[e.createVNode(wo,{style:{width:"100%",height:"16px","margin-bottom":"8px"}}),e.createVNode(wo,{style:{width:"100%",height:"16px","margin-bottom":"32px","max-width":"481px"}})]),e.createElementVNode("div",LC,[e.createVNode(wo,{style:{width:"100%",height:"24px"}})]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.errors,i=>(e.openBlock(),e.createElementBlock("div",{key:i,class:"aig-message-error","data-test-id":"aiGuidance-loader-error"},e.toDisplayString(i),1))),128)),e.createElementVNode("div",PC,[e.createVNode(wo,{style:{height:"36px",width:"100%"}})])])],64))}},[["__scopeId","data-v-5e4a9913"]]),$C={class:"ai-guidance-wrapper","data-test-id":"aiGuidance-wrapper"},Qi=xe({__name:"aiGuidance",props:{templateId:{type:String,required:!1},playbookData:{type:Object,required:!1},composablesOrgType:{type:String,required:!0},identity:{type:Object,required:!1,default:()=>({})},session:{type:Object,required:!1,default:()=>({})},security:{type:Object,required:!1,default:()=>({})},functions:{type:Object,required:!1,default:()=>({})},websocketUrl:{type:String,required:!0},packageVersion:{type:String,required:!0},hostName:{type:String,required:!1},graphqlEndpoint:{type:String,required:!1},apiKey:{type:String,required:!1},isPreview:{type:Boolean,required:!1,default:!1},catalogSections:{type:Array,required:!1,default:()=>[]},cartSections:{type:String,required:!1,default:""},theme:{type:Object,required:!1,default:()=>({})},styles:{type:Object,required:!1,default:()=>({height:"100vh"}),validator:t=>typeof(t==null?void 0:t.height)=="string"}},emits:["expeditecart-item-configure","expeditecart-clicked","component-action","ai-response:success","quote-id:updated","ai-guidance:error"],setup(t,{emit:r}){const n=Jn(),o=lt(),a=qn(),i=go(),l=r,s=e.ref(!0),c=e.ref(!1),u=e.ref(!0),f=e.ref(!0),g=e.ref(!1),h=e.ref([]),{emitError:m,emitErrors:d}=Qc(l,"aiGuidance"),_=t,{composablesOrgType:p,websocketUrl:C,packageVersion:y,identity:b,session:x,security:E,functions:A,templateId:k,hostName:B,graphqlEndpoint:D,apiKey:S,isPreview:v,catalogSections:N,cartSections:I,theme:L}=_,z=e.computed(()=>{var O,M,$;return{..._.session||{},quoteId:((O=_.session)==null?void 0:O.quoteId)||(((M=o.quoteId)==null?void 0:M.value)??""),eCatalogId:($=o.eCatalogId)==null?void 0:$.value}});e.onBeforeMount(async()=>{console.log("security",E),console.log("apiKey",S),o.updateConfig({userId:b==null?void 0:b.userId,organizationId:b==null?void 0:b.organizationId,accessToken:E==null?void 0:E.accessToken,composablesApiUrl:E==null?void 0:E.baseUrl,composablesOrgType:p,websocketUrl:C,quoteId:x==null?void 0:x.quoteId,packageVersion:y,accountId:b==null?void 0:b.accountId,templateId:k,hostName:B,graphqlEndpoint:D,apiKey:(E==null?void 0:E.apiKey)||S,cid:b==null?void 0:b.contactId,isPreview:v})}),e.onMounted(async()=>{var P,j,G,Z;const O=d1(_,b,E);d(O);const M=dc(C);if(M&&m(M),O.length>0||M){s.value=!1;return}n.setSecretKey(E==null?void 0:E.accessToken);let $=null,F,U;try{$=await n.getPlaybookInfoFromQuote(),F=($==null?void 0:$.XX_ORD1__Completed_PB_Step_Number_EX__c)??void 0,U=($==null?void 0:$.XX_ORD1__Playbook_Current_Step_Meta_EX__c)??void 0}catch(oe){console.error("[aiGuidance] Failed to get playbook info from quote:",oe),m("AI_GUIDANCE_PLAYBOOK_INFO_FETCH_FAILED",{error:oe.message})}if(U)try{U=JSON.parse(U)}catch(oe){console.error("[aiGuidance] Failed to parse currentStepMetaServer:",oe),m("AI_GUIDANCE_JSON_PARSE_ERROR",{error:oe.message,data:"currentStepMetaServer"}),U=void 0}if(console.info("sequenceNumberServer = ",F),_.templateId){s.value=!0;try{const ae=await n.getCatalogInContext();console.log("catalogInContext = ",ae),ae&&o.updateConfig({eCatalogId:ae})}catch(ae){console.error("[aiGuidance] Failed to get catalog in context:",ae),m("AI_GUIDANCE_CATALOG_FETCH_FAILED",{error:ae.message})}let oe=null;try{await i.fetchBlockInformationREST({templateId:_.templateId});const ae=f1(i.pageBlocks);oe=ae.playbookId,ae.error&&m(ae.error,{error:"Block structure validation failed"}),oe||m("AI_GUIDANCE_BLOCK_PLAYBOOK_ID_MISSING",{pageBlocks:i.pageBlocks})}catch(ae){console.error("[aiGuidance] Failed to fetch block information:",ae),m("AI_GUIDANCE_BLOCK_FETCH_FAILED",{error:ae.message})}if(console.log("playbookID",oe),oe?c.value=!0:h.value.push("No playbook ID found in template"),n.setEmbeddedMode(!0),oe)try{n.currentPlaybook=oe,await n.getPlaybookByKey(oe),n.showPlaybookSteps=!0}catch(ae){console.error("[aiGuidance] Failed to get playbook by key:",ae),m("AI_GUIDANCE_PLAYBOOK_FETCH_FAILED",{error:ae.message,playbookID:oe})}n.playbookStepsMode="full",a.setInitialPayload();try{await a.connectSocket()}catch(ae){console.error("[aiGuidance] Failed to connect socket:",ae),m("WEBSOCKET_CONNECTION_FAILED",{error:ae.message})}if(F!==void 0){n.navigateToStep({stepName:(j=(P=n.currentPlaybook)==null?void 0:P.playBookSteps[Number(F)])==null?void 0:j.stepName,data:U}),s.value=!1;return}(Z=(G=n.currentPlaybook)==null?void 0:G.playBookSteps)!=null&&Z.length&&n.setCurrentStepName(n.currentPlaybook.playBookSteps[0].stepName),s.value=!1}else h.value.push("templateId is required")});const q=e.computed(()=>{var $;const O=(($=n.currentPlaybook)==null?void 0:$.playBookSteps)||[],M=n.currentStepName;return O.find(F=>F.stepName===M)||O[0]||null}),W=e.computed(()=>{var O;return((O=q.value)==null?void 0:O.stepComponent)||null});e.watch(()=>n.activeComponentKey,O=>{O&&(u.value=!1)});const te=[];e.onMounted(()=>{te.push(Ft("expeditecart:configure-clicked",O=>{l("expeditecart-item-configure",O)})),te.push(Ft("expeditecart:clicked",O=>{l("expeditecart-clicked",O)})),te.push(Ft("ai-response:success",O=>{try{l("ai-response:success",O)}catch{}})),te.push(Ft("quote-id:updated",O=>{try{l("quote-id:updated",O)}catch(M){console.info("[aiGuidance] Error emitting quote-id:updated event:",M)}})),te.push(Ft("websocket:error",O=>{try{O!=null&&O.isInitialization&&m(O.errorCode||"WEBSOCKET_CONNECTION_FAILED",O)}catch(M){console.info("[aiGuidance] Error handling websocket error event:",M)}}))});const K=O=>{console.log("[aiGuidance] Received error from aiComponentLoader:",O),l("ai-guidance:error",O)},R=O=>{console.log("onExpediteCartClicked",O),l("component-action",{component:"cart",details:O})},w=(O,M)=>{var F;l("component-action",{component:"catalog",action:O,details:M});const $=(M==null?void 0:M.quoteId)??((F=M==null?void 0:M.response)==null?void 0:F.quoteId);if($&&(O==="item-added"||O==="items-fetched"))try{l("quote-id:updated",{quoteId:$})}catch(U){console.info("[aiGuidance] Error emitting quote-id:updated from catalog event:",U)}},T=(O,M)=>{l("component-action",{component:"configurator",action:O,details:M})};return e.onBeforeUnmount(()=>{try{a.cancelRequest()}catch{}try{a.disconnectSocket()}catch{}try{a.resetState()}catch{}try{n.setEmbeddedMode(!1),n.currentPlaybook=null,n.currentStepName=null,n.activeComponentKey=null,n.activeComponentData=null,n.showPlaybookSteps=!1,n.playbookStepsMode="full"}catch{}s.value=!1,c.value=!1,u.value=!0,f.value=!0,g.value=!1,h.value=[],te.forEach(O=>{try{O()}catch{}})}),(O,M)=>{var $;return e.openBlock(),e.createElementBlock("div",$C,[e.createVNode(ci,{icon:"logo",color:"#000000",size:"18.75",height:"16.25"}),s.value||e.unref(a).isFetchingHistory?(e.openBlock(),e.createBlock(qC,{key:0,errors:h.value,"data-test-id":"aiGuidance-loader"},null,8,["errors"])):(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["ai-app",{"root-path":u.value,"playbook-steps-mode-full":e.unref(n).playbookStepsMode==="full","dxp-guiddance":c.value}]),style:e.normalizeStyle(t.styles)},[e.createElementVNode("div",{class:"ai-app-chat-wrapper",style:e.normalizeStyle({height:t.styles.height})},[e.createVNode(_C,{"data-test-id":"chat-screen","is-external-guidance":c.value,styles:t.styles},null,8,["is-external-guidance","styles"])],4),!u.value&&f.value&&!g.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"component-loader-wrapper",style:e.normalizeStyle({height:t.styles.height,maxHeight:t.styles.height})},[e.unref(n).currentPlaybook?(e.openBlock(),e.createBlock(FC,{key:0,"template-id":(($=q.value)==null?void 0:$.templateId)||e.unref(k),"step-component":W.value,identity:e.unref(b),session:z.value,security:e.unref(E),functions:e.unref(A),"composables-org-type":e.unref(p),"package-version":e.unref(y),"host-name":e.unref(B),"graphql-endpoint":e.unref(D),"api-key":e.unref(S),"is-preview":e.unref(v),sections:e.unref(N),"cart-sections":e.unref(I),theme:e.unref(L),"data-test-id":"aiComponentLoader-mounted",onExpeditecartClicked:R,onCatalogQuoteCreated:M[0]||(M[0]=F=>w("quote-created",F)),onCatalogQuoteUpdated:M[1]||(M[1]=F=>w("quote-updated",F)),onCatalogItemsLoaded:M[2]||(M[2]=F=>w("items-loaded",F)),onCatalogItemAdded:M[3]||(M[3]=F=>w("item-added",F)),onCatalogItemQtyUpdated:M[4]||(M[4]=F=>w("item-qty-updated",F)),onCatalogLineDeleted:M[5]||(M[5]=F=>w("line-deleted",F)),onCatalogItemsFetched:M[6]||(M[6]=F=>w("items-fetched",F)),onCatalogItemConfigure:M[7]||(M[7]=F=>w("item-configure",F)),"onConfigurator:addToQuote":M[8]||(M[8]=F=>T("add-to-quote",F)),"onConfigurator:save":M[9]||(M[9]=F=>T("save",F)),"onAiGuidance:error":K},null,8,["template-id","step-component","identity","session","security","functions","composables-org-type","package-version","host-name","graphql-endpoint","api-key","is-preview","sections","cart-sections","theme"])):e.createCommentVNode("",!0)],4)):e.createCommentVNode("",!0)],6))])}}},[["__scopeId","data-v-40bb4f79"]]),r0={ExpediteConfigurator:Cr,ExpediteGPT:xi,ExpediteCatalog:Nr,ExpediteCart:Sr,ExpediteAIGuidance:Qi},UC={install(t,r={}){t.component("ExpediteConfigurator",Cr),t.component("ExpediteGPT",xi),t.component("ExpediteCatalog",Nr),t.component("ExpediteCart",Sr),t.component("ExpediteAIGuidance",Qi)},...r0};mt.Components=r0,mt.ExpediteAIGuidance=Qi,mt.ExpediteCart=Sr,mt.ExpediteCatalog=Nr,mt.ExpediteConfigurator=Cr,mt.ExpediteGPT=xi,mt.default=UC,mt.useComRootStore=Eo,Object.defineProperties(mt,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
164
+ `);return _=_.replace(/^[ \t]*•[ \t]+/gm,"- "),_};return(d,_)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["chat-messages",{"root-path":s.value}])},[e.createElementVNode("div",{class:"chat-gradient",style:e.normalizeStyle({background:f.value})},null,4),e.createElementVNode("div",{ref_key:"chatMessagesRef",ref:n,class:"messages-wrapper"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList([...t.messages],(p,C)=>{var y;return e.openBlock(),e.createElementBlock("div",{key:C,class:e.normalizeClass(["message",{"user-message":p.type==="user"}])},[e.createElementVNode("div",L_,[p.name?(e.openBlock(),e.createElementBlock("div",P_,e.toDisplayString(p.name),1)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["message-text ect-relative",{"error-message":p.error,strikethrough:p.undone}]),style:e.normalizeStyle(p.type==="user"?{color:g.value,backgroundColor:u.value}:{})},[e.createElementVNode("div",q_,[e.createVNode(n0,{source:m(p.message)},null,8,["source"])]),((y=p==null?void 0:p.filesData)==null?void 0:y.length)>0?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(p==null?void 0:p.filesData,b=>(e.openBlock(),e.createBlock(P7,{key:b.name,info:{iconUrl:(b==null?void 0:b.type)==="csv"?e.unref(Zc):e.unref(Jc),fileName:b==null?void 0:b.name,fileSize:b==null?void 0:b.size},background:p.type=="user"?"#fff":"#f8f8f8","encoded-string":b==null?void 0:b.encodedString},null,8,["info","background","encoded-string"]))),128)):e.createCommentVNode("",!0)],6)])],2)}),128)),t.loadingMessage?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["loading-message",{"thinking-message":e.unref(a).isThinkingMessage}])},[e.createElementVNode("div",{class:e.normalizeClass(["ect-flex ect-gap-3",{"ect-w-full":e.unref(a).isThinkingMessage}])},[e.createElementVNode("div",$_,[e.createElementVNode("div",U_,[e.createElementVNode("div",{ref_key:"loadingWindowRef",ref:o,class:"loading-window"},[e.createElementVNode("div",z_,[e.createVNode(n0,{source:m(t.loadingMessage)},null,8,["source"])])],512)]),e.createElementVNode("div",j_,[e.createVNode(wo,{style:{height:"100%",width:"100%"}})])])],2)],2)):t.buttonLinks.length>0?(e.openBlock(),e.createElementBlock("div",H_,[e.createVNode(V7,{links:t.buttonLinks,onPerformAction:h},null,8,["links"])])):e.createCommentVNode("",!0)],512)],2))}},[["__scopeId","data-v-d6e07984"]]),K_={class:"ai-upload ect-flex-inline ect-items-center"},X_=xe({__name:"FileUpload",props:{resetFileInput:{type:Boolean,default:!1}},emits:["upload-status","error"],setup(t,{emit:r}){const n=t,o=r,a=e.ref(null),i=e.ref(""),l=e.ref(""),s=e.ref(!1);e.watch(()=>n.resetFileInput,g=>{g&&a.value&&(a.value.value="",i.value="",l.value="")});const c=g=>{const m=a.value.accept.split(",").map(_=>_.trim().toLowerCase()),d="."+g.name.split(".").pop().toLowerCase();return m.includes(d)||m.includes(g.type.toLowerCase())?!0:m.some(_=>{if(_.includes("*")){const p=_.split("*")[0];return g.type.toLowerCase().startsWith(p)}return!1})},u=async g=>{const h=g.target.files[0];if(console.info("File = ",h),h){if(!c(h)){a.value&&(a.value.value="");const d={message:"Invalid file type. Please upload a valid file type.",fileName:h.name,fileType:h.type};window&&window.$toast&&window.$toast.add({severity:"error",summary:"File Upload Error",detail:d.message,life:5e3}),o("error",d);return}i.value=h.name,l.value=h.type.split("/").pop(),o("upload-status",{status:"uploading",fileName:i.value,fileType:l.value});const m=new FileReader;m.onload=async d=>{const _=new Blob([d.target.result],{type:h.type});console.info("Blob data:",_);try{const p=await j0(_),C={attachment:{name:h.name,data:p}};console.info("AIRequestPayload = ",C),o("upload-status",{status:"uploaded",fileName:i.value,fileType:l.value,size:El(h.size),fileData:C}),a.value&&(a.value.value="")}catch(p){console.info("[ERROR]: File upload error:",p),window&&window.$toast&&window.$toast.add({severity:"error",summary:"File Processing Error",detail:"Error processing file: "+(p.message||"Unknown error"),life:5e3}),o("error",{message:"Error processing file",fileName:i.value,fileType:l.value,error:p.message}),o("upload-status",{status:"error",fileName:i.value,fileType:l.value})}},m.onerror=d=>{console.info("[ERROR]: FileReader error:",d),window&&window.$toast&&window.$toast.add({severity:"error",summary:"File Reading Error",detail:"Could not read the selected file",life:5e3}),o("error",{message:"Error reading file",fileName:h.name,fileType:h.type,error:d})},setTimeout(()=>{m.readAsText(h)},100)}},f=()=>{a.value.click()};return(g,h)=>(e.openBlock(),e.createElementBlock("div",K_,[e.createElementVNode("input",{ref_key:"fileInput",ref:a,type:"file",accept:".csv, .xls, .xlsx, text/csv, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",class:"ect-opacity-0 ect-h-0 ect-w-0 ect-absolute",onChange:u},null,544),e.createElementVNode("button",{class:"attachment-button",onClick:f,onMouseenter:h[0]||(h[0]=m=>s.value=!0),onMouseleave:h[1]||(h[1]=m=>s.value=!1)},[e.createVNode(we,{icon:"attachment",size:"11",height:"17",color:s.value?"#198708":"#828282"},null,8,["color"])],32)]))}},[["__scopeId","data-v-7fbbb7c9"]]),W_={key:0,class:"suggestions-container"},Q_={key:0,class:"logo-section"},Z_={class:"help-text-section"},J_={key:0,class:"help-text"},Y_={key:1,class:"sub-help-text"},eC=["onClick"],tC={key:2,class:"suggestions-list"},nC=["onClick"],oC=xe({__name:"AISuggestionsDropdown",props:{options:{type:Array,required:!0},helpText:{type:String,default:""},subHelpText:{type:String,default:""},showSuggestions:{type:Boolean,default:!1}},emits:["select","preview"],setup(t,{emit:r}){const n=t,o=r,a=e.ref(0),i=e.ref(0),l=e.ref(null),s=e.ref(null),c=h=>{l.value=h,i.value=0},u=()=>{l.value=null,a.value=0},f=h=>{o("select",h)},g=h=>{if(n.showSuggestions)switch(h.key){case"ArrowDown":h.preventDefault(),l.value?(i.value=(i.value+1)%l.value.subOptions.length,o("preview",l.value.subOptions[i.value])):(a.value=(a.value+1)%n.options.length,o("preview",n.options[a.value].title));break;case"ArrowUp":h.preventDefault(),l.value?(i.value=i.value-1<0?l.value.subOptions.length-1:i.value-1,o("preview",l.value.subOptions[i.value])):(a.value=a.value-1<0?n.options.length-1:a.value-1,o("preview",n.options[a.value].title));break;case"Enter":h.preventDefault(),l.value?f(l.value.subOptions[i.value]):c(n.options[a.value]);break;case"Escape":case"ArrowLeft":case"Backspace":l.value&&(h.preventDefault(),u());break}};return e.watch(()=>n.showSuggestions,h=>{h?(window.addEventListener("keydown",g),l.value=null,a.value=0,i.value=0):window.removeEventListener("keydown",g)}),(h,m)=>t.showSuggestions?(e.openBlock(),e.createElementBlock("div",W_,[l.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Q_,[e.createVNode(t3)])),e.createElementVNode("div",Z_,[t.helpText&&!l.value?(e.openBlock(),e.createElementBlock("div",J_,e.toDisplayString(t.helpText),1)):e.createCommentVNode("",!0),t.subHelpText?(e.openBlock(),e.createElementBlock("div",Y_,e.toDisplayString(t.subHelpText),1)):e.createCommentVNode("",!0)]),l.value?(e.openBlock(),e.createElementBlock("div",tC,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value.subOptions,(d,_)=>(e.openBlock(),e.createElementBlock("div",{key:_,class:e.normalizeClass(["sub-option",{"sub-active":i.value===_}]),onClick:p=>f(d)},e.toDisplayString(d),11,nC))),128))])):(e.openBlock(),e.createElementBlock("div",{key:1,ref_key:"suggestionsList",ref:s,class:"suggestions-list"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.options,(d,_)=>(e.openBlock(),e.createElementBlock("div",{key:_,class:e.normalizeClass(["suggestion-item",{active:a.value===_}]),onClick:p=>c(d)},e.toDisplayString(d.title),11,eC))),128))],512))])):e.createCommentVNode("",!0)}},[["__scopeId","data-v-bbb514b3"]]),rC={class:"chat-file-info"},aC={class:"ect-flex ect-gap-2 ect-items-center ect-self-stretch ect-my-auto ect-text-xs ect-font-medium ect-text-black"},iC=["src"],lC={class:"ect-self-stretch ect-my-auto"},sC={key:0,class:"ect-flex ect-gap-2 ect-justify-center ect-items-center ect-self-stretch ect-my-auto ect-w-4 ect-h-4"},cC=xe({__name:"ChatInputFileInfo",props:{fileInfo:{type:Object,required:!0}},emits:["cancel"],setup(t,{emit:r}){const n=r,o=()=>{n("cancel")};return(a,i)=>(e.openBlock(),e.createElementBlock("div",rC,[e.createElementVNode("div",aC,[e.createElementVNode("img",{loading:"lazy",src:t.fileInfo.fileType==="csv"?e.unref(Zc):e.unref(Jc),class:"ect-object-contain ect-shrink-0 ect-self-stretch ect-my-auto ect-w-7 ect-aspect-square",alt:""},null,8,iC),e.createElementVNode("div",lC,e.toDisplayString(t.fileInfo.fileName),1)]),t.fileInfo.status==="uploading"?(e.openBlock(),e.createElementBlock("div",sC,[e.createVNode(ui,{size:18})])):e.createCommentVNode("",!0),t.fileInfo.status==="uploaded"?(e.openBlock(),e.createElementBlock("button",{key:1,class:"ect-flex ect-gap-2 ect-justify-center ect-items-center ect-self-stretch ect-my-auto ect-w-4 ect-h-4",onClick:o},[e.createVNode(we,{icon:"close",size:"8"})])):e.createCommentVNode("",!0)]))}},[["__scopeId","data-v-24d881bd"]]),uC={class:"chat-input-wrapper"},dC={class:"chat-input-inner"},fC={class:"input-row"},hC=["disabled","placeholder","onKeydown"],pC={key:1,class:"icon-wrapper"},mC={class:"icon-wrapper"},yC=xe({__name:"chatInput",props:{modelValue:{type:String,default:""},loading:{type:Boolean,default:!1},placeholder:{type:String,default:"Ask Genesis AI"},helpText:{type:String,default:"Here are few areas where I can help"},subHelpText:{type:String,default:"Suggestions by Genesis (Click to Apply)"},showFile:{type:Boolean,default:!1},showMic:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},emits:["update:modelValue","submit","speak","file-upload-status"],setup(t,{emit:r}){const n=t,o=r;qn();const a=Vt(),i=Jn(),l=e.ref({}),s=e.ref(!1),c=e.ref(!1),u=e.ref(n.modelValue),f=e.ref(null),g=e.computed(()=>{const k=i.currentStep||null;return(Array.isArray(k==null?void 0:k.promptGuidance)?k.promptGuidance:[]).slice().sort((S,v)=>Number((S==null?void 0:S.sequenceNumber)??0)-Number((v==null?void 0:v.sequenceNumber)??0)).map(S=>{const N=(Array.isArray(S==null?void 0:S.relatedPG)?S.relatedPG:[]).slice().sort((I,L)=>Number((I==null?void 0:I.sequenceNumber)??0)-Number((L==null?void 0:L.sequenceNumber)??0)).map(I=>I.pgName);return{title:S.pgName,subOptions:N}})}),h=e.computed(()=>{var k;return(k=g.value)!=null&&k.length?g.value:[]}),m=e.computed(()=>{var k;return(k=g.value)!=null&&k.length?"Prompt Guidance":n.helpText});e.watch(()=>n.loading,async(k,B)=>{!k&&B&&(await e.nextTick(),f.value.focus())}),e.watch(u,k=>{o("update:modelValue",k),e.nextTick(()=>x())}),e.watch(()=>n.modelValue,k=>{u.value=k});const d=k=>{console.info("[ERROR]: File upload error:",k),a.handleError(k,"ChatInput")},_=()=>{u.value.trim()&&(c.value=!1,o("submit",u.value),u.value="",f.value&&(f.value.style.height="32px"),l.value=null)},p=k=>{u.value=k,c.value=!1,e.nextTick(()=>{x(),f.value&&(f.value.focus(),f.value.selectionStart=f.value.selectionEnd=u.value.length)})},C=k=>{u.value=k,e.nextTick(()=>x())},y=()=>{c.value=!1},b=k=>{console.info("handleFileUploadStatus event = ",k),k!=null&&k.fileName?(l.value=k,o("file-upload-status",k)):(l.value=null,s.value=!0,o("file-upload-status",null),setTimeout(()=>{s.value=!1},3e3))},x=()=>{const k=f.value;if(!k)return;k.style.height="auto";const S=Math.max(32,Math.min(k.scrollHeight,120));k.style.height=`${S}px`},E=()=>{console.info("removeFile"),l.value=null,s.value=!0,o("file-upload-status",null),setTimeout(()=>{s.value=!1},100)},A=()=>{c.value=!1,x()};return(k,B)=>{var S,v,N,I,L;const D=e.resolveDirective("click-outside");return e.withDirectives((e.openBlock(),e.createElementBlock("div",uC,[e.createVNode(oC,{options:h.value,"help-text":m.value,"sub-help-text":t.subHelpText,"show-suggestions":c.value,onSelect:p,onPreview:C},null,8,["options","help-text","sub-help-text","show-suggestions"]),e.createElementVNode("div",dC,[e.createElementVNode("div",fC,[e.createElementVNode("div",{class:e.normalizeClass(["icon-wrapper",{"active-suggestions":c.value,disabled:((S=h.value)==null?void 0:S.length)<=0}])},[e.createVNode(we,{disabled:((v=h.value)==null?void 0:v.length)<=0||t.loading,color:((N=h.value)==null?void 0:N.length)<=0?"#DEDEDE":c.value?"#198708":"#828282",icon:"suggestions",size:"13",height:15,onClick:B[0]||(B[0]=z=>c.value=!c.value)},null,8,["disabled","color"])],2),e.withDirectives(e.createElementVNode("textarea",{ref_key:"textareaRef",ref:f,"onUpdate:modelValue":B[1]||(B[1]=z=>u.value=z),disabled:t.loading,placeholder:t.placeholder,rows:"1",onKeydown:e.withKeys(e.withModifiers(_,["exact","prevent"]),["enter"]),onInput:A},null,40,hC),[[e.vModelText,u.value]]),t.showFile?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["icon-wrapper",{"file-upload-disabled":t.loading}])},[e.createVNode(X_,{"reset-file-input":s.value,onUploadStatus:b,onError:d},null,8,["reset-file-input"])],2)):e.createCommentVNode("",!0),t.showMic?(e.openBlock(),e.createElementBlock("div",pC,[e.createVNode(we,{color:"#828282",disabled:t.loading,icon:"mic",size:"13",height:15,onClick:B[2]||(B[2]=z=>k.$emit("speak"))},null,8,["disabled"])])):e.createCommentVNode("",!0),e.createElementVNode("div",mC,[(e.openBlock(),e.createBlock(we,{key:1,disabled:t.loading,icon:"send",size:"20",onClick:_},null,8,["disabled"]))])]),((I=l.value)==null?void 0:I.status)==="uploading"||((L=l.value)==null?void 0:L.status)==="uploaded"?(e.openBlock(),e.createBlock(cC,{key:0,class:"ect-mt-3 ect-mb-0.5","file-info":l.value,onCancel:E},null,8,["file-info"])):e.createCommentVNode("",!0)])])),[[D,y]])}}},[["__scopeId","data-v-e205d71c"]]),gC=["data-test-id"],bC=["data-test-id"],xC=["data-test-id"],_C=xe({__name:"aiChat",props:{dataTestId:{type:String,required:!0},isExternalGuidance:{type:Boolean,required:!1,default:!1},styles:{type:Object,required:!1,default:()=>({}),validator:t=>typeof(t==null?void 0:t.height)=="string"}},setup(t){const r=Jn(),n=qn(),o=e.ref(null),a=e.computed(()=>{var c;return((c=r.getCurrentStepLinks)==null?void 0:c.call(r))||[]}),i=e.computed(()=>!0),l=c=>{console.info("[aiChat] handleSubmit",{hasFileData:!!o.value,messageLength:(c||"").length}),o.value?(console.info("[aiChat] sending with file attachment"),n.sendMessage(c,!0,o.value)):(console.info("[aiChat] sending without attachment"),n.sendMessage(c))},s=c=>{console.info("ChatScreen handleFileUploadStatus event = ",c),c!=null&&c.fileData?(o.value=c.fileData,n.attachmentData={size:c.size,type:c.fileType,name:c.fileName}):(o.value=null,n.attachmentData=null)};return(c,u)=>(e.openBlock(),e.createElementBlock("div",{class:"chat-screen","data-test-id":t.dataTestId},[e.createElementVNode("div",{class:e.normalizeClass(["messages-container",{"playbook-steps-mode-hybrid":e.unref(r).playbookStepsMode==="hybrid","playbook-steps-mode-full":e.unref(r).playbookStepsMode==="full","dxp-guiddance":t.isExternalGuidance}]),style:e.normalizeStyle({maxHeight:`calc(${t.styles.height} - 72px)`,height:`calc(${t.styles.height} - 72px)`}),"data-test-id":`${t.dataTestId}-messages-container`},[e.createVNode(G_,{messages:e.unref(n).chatHistory,"loading-message":e.unref(n).loadingMessage,"undo-id":e.unref(n).latestDMLRequest,"button-links":a.value,"strikethrough-ids":e.unref(n).strikethroughHistory,"data-changed":e.unref(n).dataManuallyChanged,"data-test-id":`${t.dataTestId}-messages`},null,8,["messages","loading-message","undo-id","button-links","strikethrough-ids","data-changed","data-test-id"])],14,bC),e.createElementVNode("div",{class:"input-container","data-test-id":`${t.dataTestId}-input-container`},[e.createVNode(yC,{modelValue:e.unref(n).promptMessage,"onUpdate:modelValue":u[0]||(u[0]=f=>e.unref(n).promptMessage=f),disabled:!i.value,"file-info":o.value,loading:!!e.unref(n).loadingMessage,"data-test-id":`${t.dataTestId}-input`,onSubmit:l,onFileUploadStatus:s},null,8,["modelValue","disabled","file-info","loading","data-test-id"])],8,xC)],8,gC))}},[["__scopeId","data-v-99005673"]]),CC={class:"ect-h-full ect-w-full ect-flex ect-items-center ect-justify-center","data-test-id":"configurator-not-found"},EC={class:"ect-max-w-[720px] ect-p-[50px] ect-border ect-rounded-lg ect-bg-white ect-shadow-sm"},kC={class:"ect-text-[40px] ect-leading-none ect-mb-3"},vC=e.createElementVNode("div",{class:"ect-text-[22px] ect-font-normal ect-leading-normal ect-mb-[12px] ect-capitalize ect-text-[#5F5F5F]","data-test-id":"configurator-not-found-title"}," Product Configurator Not Found ",-1),AC=e.createElementVNode("div",{class:"ect-text-sm ect-text-gray-500","data-test-id":"configurator-not-found-subtitle"}," Linked composable product configurator UI component for this screen is not found OR the composable product configurator UI component does not exist. Please create / connect one and try again. ",-1),wC={class:"ect-mt-4 ect-flex ect-items-center ect-justify-between ect-gap-6"},NC={__name:"MoleculeConfiguratorNotFound",emits:["return","go-cart"],setup(t){return(r,n)=>(e.openBlock(),e.createElementBlock("div",CC,[e.createElementVNode("div",EC,[e.createElementVNode("div",kC,[e.createVNode(we,{icon:"error",size:48})]),vC,AC,e.createElementVNode("div",wC,[e.createElementVNode("button",{type:"button",class:"ect-text-green-600 ect-text-sm ect-font-medium",onClick:n[0]||(n[0]=o=>r.$emit("return")),"data-test-id":"configurator-not-found-return"}," RETURN TO PRODUCT RESULTS "),e.createElementVNode("button",{type:"button",class:"ect-text-green-600 ect-text-sm ect-font-medium",onClick:n[1]||(n[1]=o=>r.$emit("go-cart")),"data-test-id":"configurator-not-found-go-to-cart"}," GO TO CART ")])])]))}},o0=t=>(e.pushScopeId("data-v-3c362460"),t=t(),e.popScopeId(),t),SC={class:"ect-h-full ect-w-full ect-bg-white","data-test-id":"aiComponentLoader-wrapper"},BC={key:2,class:"ect-h-full ect-w-full ect-flex ect-items-center ect-justify-center","data-test-id":"aiComponentLoader-cart-error"},IC=[o0(()=>e.createElementVNode("div",{class:"ect-text-center"},[e.createElementVNode("div",{class:"ect-text-base ect-font-medium ect-text-red-600","data-test-id":"aiComponentLoader-cart-error-title"}," Quote Required "),e.createElementVNode("div",{class:"ect-text-sm ect-text-gray-500 ect-mt-2","data-test-id":"aiComponentLoader-cart-error-message"}," A quote is required for the cart component to work. Please ensure a quoteId is provided in the session prop. ")],-1))],OC={key:5,class:"ect-h-full ect-w-full ect-flex ect-items-center ect-justify-center"},TC={class:"ect-text-center"},DC=o0(()=>e.createElementVNode("div",{class:"ect-text-base ect-font-medium","data-test-id":"aiComponentLoader-fallback-title"}," No component to display for this step ",-1)),VC={class:"ect-text-sm ect-text-gray-500 ect-mt-2","data-test-id":"aiComponentLoader-fallback-subtitle"},FC=xe({__name:"aiComponentLoader",props:{stepComponent:{type:String,default:null},identity:{type:Object,default:()=>({})},session:{type:Object,default:()=>({})},security:{type:Object,default:()=>({})},packageVersion:{type:String,default:""},composablesOrgType:{type:String,default:""},composablesApiKey:{type:String,default:""},templateId:{type:String,default:""},hostName:{type:String,default:""},graphqlEndpoint:{type:String,default:""},apiKey:{type:String,default:""},isPreview:{type:Boolean,default:!1},sections:{type:Array,default:()=>[]},theme:{type:Object,default:()=>({})},catalogPreviewData:{type:Object,default:()=>({})},catalogInitialData:{type:Array,default:()=>[]},catalogSearchTerm:{type:String,default:""},onCatalogCountUpdate:{type:Function,default:null},cartSections:{type:String,default:""},configItemId:{type:String,default:""},configQliId:{type:String,default:""},configApiKey:{type:String,default:""},functions:{type:Object,default:()=>({})}},emits:["expeditecart-clicked","ai-guidance:error","catalog-quote-created","catalog-quote-updated","catalog-items-loaded","catalog-item-added","catalog-item-qty-updated","catalog-line-deleted","catalog-items-fetched","catalog-item-configure"],setup(t,{emit:r}){const n=r,o=t,a=Jn(),i=ai(),l=lt(),s=e.computed(()=>{var j,G,Z,oe,ae;const P=((j=o.session)==null?void 0:j.quoteId)||((G=l.quoteId)==null?void 0:G.value)||((Z=a==null?void 0:a.activeComponentData)==null?void 0:Z.contextObjectId)||((ae=(oe=a==null?void 0:a.activeComponentData)==null?void 0:oe.payload)==null?void 0:ae.contextObjectId);return{...o.session,...P&&{quoteId:P},qliId:p.value||o.configQliId||void 0,itemId:_.value}}),c=e.computed(()=>{const P=o.functions||{},j=P.createQuote;return typeof j!="function"?P:{...P,createQuote:async(...G)=>{const Z=await j(...G);return Z&&l.updateConfig({quoteId:Z}),Z}}}),u=e.computed(()=>{const P=a==null?void 0:a.activeComponentKey,j=o.stepComponent;return(P||j||"").toString().trim().toLowerCase().replace(/[^a-z0-9]+/g,"_")}),f=e.computed(()=>{var oe,ae;const P=!!o.templateId,j=!!((oe=o.identity)!=null&&oe.organizationId),G=!!((ae=o.identity)!=null&&ae.accountId),Z=typeof o.cartSections=="string"&&o.cartSections.length>0;return P&&j&&G&&Z}),g=e.computed(()=>{var Z,oe,ae,ee,ue;const P=(Z=o.session)==null?void 0:Z.quoteId,j=(oe=l.quoteId)==null?void 0:oe.value,G=((ae=a==null?void 0:a.activeComponentData)==null?void 0:ae.contextObjectId)||((ue=(ee=a==null?void 0:a.activeComponentData)==null?void 0:ee.payload)==null?void 0:ue.contextObjectId);return!!(P||j||G)}),h=e.computed(()=>{var j,G,Z,oe,ae;const P=((j=o.session)==null?void 0:j.quoteId)||((G=l.quoteId)==null?void 0:G.value)||((Z=a==null?void 0:a.activeComponentData)==null?void 0:Z.contextObjectId)||((ae=(oe=a==null?void 0:a.activeComponentData)==null?void 0:oe.payload)==null?void 0:ae.contextObjectId);return{...o.session,...P&&{quoteId:P}}}),m=e.computed(()=>{var j;if(Array.isArray(o.catalogInitialData)&&o.catalogInitialData.length>0)return o.catalogInitialData;const P=((j=a==null?void 0:a.activeComponentData)==null?void 0:j.payload)||{};if(P.catalog&&typeof P.catalog=="object")try{const Z=Object.values(P.catalog).map(oe=>{var ae;return(ae=oe==null?void 0:oe.catalogResponse)==null?void 0:ae.productInfo}).filter(Boolean);if(Z.length>0)return Z}catch{}return Array.isArray(P.initialData)&&P.initialData.length>0?P.initialData:Array.isArray(P.catalogInitialData)&&P.catalogInitialData.length>0?P.catalogInitialData:Array.isArray(P.items)&&P.items.length>0?P.items:[]}),d=e.computed(()=>{var j;const P=((j=a==null?void 0:a.activeComponentData)==null?void 0:j.payload)||{};return o.catalogSearchTerm||P.searchTerm||""}),_=e.computed(()=>{var j,G,Z,oe,ae,ee;const P=((oe=(Z=(G=(j=a==null?void 0:a.activeComponentData)==null?void 0:j.payload)==null?void 0:G.savedProducts)==null?void 0:Z[0])==null?void 0:oe.itemId)||((ae=a==null?void 0:a.activeComponentData)==null?void 0:ae.payload)&&Object.keys(((ee=a.activeComponentData.payload)==null?void 0:ee.quoteConfiguration)||{})[0]||"";return o.configItemId||P||""}),p=e.computed(()=>{var j,G,Z,oe,ae,ee,ue,de;const P=(oe=(Z=(G=(j=a==null?void 0:a.activeComponentData)==null?void 0:j.payload)==null?void 0:G.savedProducts)==null?void 0:Z[0])==null?void 0:oe.qliId;if(!P){console.log("[aiComponentLoader] configQliIdComputed: No qliId from savedProducts");const Q=(ee=(ae=a==null?void 0:a.activeComponentData)==null?void 0:ae.payload)==null?void 0:ee.quoteConfiguration;if(console.log("[aiComponentLoader] configQliIdComputed: quoteConfiguration:",Q),Q&&typeof Q=="object"){const X=Object.keys(Q)[0];if(console.log("[aiComponentLoader] configQliIdComputed: firstItemId:",X),X){const Y=(ue=Q[X])==null?void 0:ue.product;if(console.log("[aiComponentLoader] configQliIdComputed: productObj:",Y),Y&&Y.qliId)return console.log("[aiComponentLoader] configQliIdComputed: found qliId in productObj:",Y.qliId),Y.qliId;if((de=Q[X])!=null&&de.qliId)return console.log("[aiComponentLoader] configQliIdComputed: found qliId directly under itemId:",Q[X].qliId),Q[X].qliId}}}return P||""}),C=e.computed(()=>!!_.value),y=e.computed(()=>u.value==="configurator"&&!C.value?"Configurator requires an itemId (and optional qliId). Provide via playbook payload or props.":u.value==="catalog"?"Catalog step is active. Provide templateId/sections/theme when available.":u.value==="cart"?"Cart step is active.":"Awaiting playbook step selection."),b=e.computed(()=>{try{return JSON.stringify((a==null?void 0:a.activeComponentData)||{})}catch{return""}}),x=e.computed(()=>`catalog::${b.value}`),E=e.computed(()=>`cart::${b.value}`),A=e.computed(()=>{var P;try{return(((P=a==null?void 0:a.activeComponentData)==null?void 0:P.actionFunction)||"")==="Reload"}catch{return!1}}),k=e.computed(()=>{var j;const P=`configurator::${_.value||""}::${p.value||""}`;if(A.value){const G=((j=a==null?void 0:a.activeComponentData)==null?void 0:j.requestId)||"";return`${P}::${G}`}return P}),{emitError:B,emitErrors:D}=Qc(n,"aiComponentLoader"),S=()=>{const P=h1(a,u.value);D(P)},v=e.ref([]),N=e.ref(null),I=P=>{const j=Array.isArray(P)?P:Array.isArray(P==null?void 0:P.items)?P.items:[];if(!Array.isArray(j))return;const G={"Needs Configuration":1,"Suggests Configuration":2,"Fully Configured":3},Z=ee=>(ee==null?void 0:ee.requiresConfiguration)||"",oe=ee=>!!ee&&ee in G,ae=j.filter(ee=>oe(Z(ee)));ae.sort((ee,ue)=>{const de=Z(ee),Q=Z(ue);return(G[de]||99)-(G[Q]||99)}),v.value=ae,N.value=ae.length?ae[0]:null},L=P=>{console.log("onQuoteCreated",P),n("catalog-quote-created",P)},z=P=>{console.log("onQuoteUpdated",P),n("catalog-quote-updated",P)},q=P=>{console.log("onItemAdded",P),n("catalog-item-added",P)},W=P=>{console.log("onItemQtyUpdated",P),n("catalog-item-qty-updated",P)},te=P=>{console.log("onLineDeleted",P),n("catalog-line-deleted",P)},K=P=>{console.log("onQuoteItemsFetched",P),n("catalog-items-fetched",P)};e.watch(()=>u.value,(P,j)=>{var G,Z,oe,ae,ee,ue,de,Q,X,Y,J;if(P==="configurator"){const ne=!!((oe=(Z=(G=a==null?void 0:a.activeComponentData)==null?void 0:G.payload)==null?void 0:Z.savedProducts)!=null&&oe.length),le=!!((ee=(ae=a==null?void 0:a.activeComponentData)==null?void 0:ae.payload)!=null&&ee.quoteConfiguration&&Object.keys(((de=(ue=a==null?void 0:a.activeComponentData)==null?void 0:ue.payload)==null?void 0:de.quoteConfiguration)||{}).length>0);if(!ne&&!le&&N.value&&!_.value){const re=((Q=N.value)==null?void 0:Q.itemId)||"";if(re){const se=((X=a==null?void 0:a.currentPlaybook)==null?void 0:X.playBookSteps)||[],he=Ne=>String(Ne||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_");let me=null;const _e=se.findIndex(Ne=>Ne.stepName===(a==null?void 0:a.currentStepName));if(_e>=0&&se[_e+1]&&he((Y=se[_e+1])==null?void 0:Y.stepComponent)==="configurator")me=se[_e+1].stepName;else{const Ne=se.findIndex(ge=>he(ge==null?void 0:ge.stepComponent)==="configurator");me=Ne>=0?(J=se[Ne])==null?void 0:J.stepName:null}const Ee={payload:{savedProducts:[{itemId:re}]}};me?a.navigateToStep({stepName:me,data:Ee}):a.loadComponent("configurator",Ee)}}}});const R=()=>{var Z,oe;const P=((Z=a==null?void 0:a.currentPlaybook)==null?void 0:Z.playBookSteps)||[],j=ae=>String(ae||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_"),G=P.findIndex(ae=>j(ae==null?void 0:ae.stepComponent)==="catalog"||j(ae==null?void 0:ae.stepName).includes("catalog"));if(G>=0){const ae=(oe=P[G])==null?void 0:oe.stepName;a.navigateToStep({stepName:ae})}else a.loadComponent("catalog")},w=()=>{var Z,oe;const P=((Z=a==null?void 0:a.currentPlaybook)==null?void 0:Z.playBookSteps)||[],j=ae=>String(ae||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_"),G=P.findIndex(ae=>j(ae==null?void 0:ae.stepComponent)==="cart"||j(ae==null?void 0:ae.stepName).includes("cart"));if(G>=0){const ae=(oe=P[G])==null?void 0:oe.stepName;a.navigateToStep({stepName:ae})}else a.loadComponent("cart")},T=P=>{var j,G;console.log("onItemConfigureClicked",P),n("catalog-item-configure",P);try{const Z=(P==null?void 0:P.itemId)||"",oe=(P==null?void 0:P.qliId)||(P==null?void 0:P.QliId)||"",ae=[];if(Z){const X={itemId:Z};oe&&(X.qliId=oe),ae.push(X)}const ee={payload:{savedProducts:ae}},ue=((j=a==null?void 0:a.currentPlaybook)==null?void 0:j.playBookSteps)||[],de=X=>String(X||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_"),Q=ue.findIndex(X=>{const Y=de(X==null?void 0:X.stepComponent),J=de(X==null?void 0:X.stepName);return Y==="configurator"||J.includes("configure")});if(Q>=0){const X=(G=ue[Q])==null?void 0:G.stepName;a.navigateToStep({stepName:X,data:ee})}else a.loadComponent("configurator",ee)}catch(Z){console.warn("[aiComponentLoader] Failed to navigate to configurator from configure click:",Z),a.loadComponent("configurator",{payload:{}})}},O=P=>{console.log("onCartClicked",P),n("expeditecart-clicked",P)},M=P=>{var j,G;try{const Z=(P==null?void 0:P.itemId)||"",oe=(P==null?void 0:P.lineItemId)||(P==null?void 0:P.qliId)||"",ae=[];if(Z){const X={itemId:Z};oe&&(X.qliId=oe),ae.push(X)}const ee={payload:{savedProducts:ae}},ue=((j=a==null?void 0:a.currentPlaybook)==null?void 0:j.playBookSteps)||[],de=X=>String(X||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_"),Q=ue.findIndex(X=>{const Y=de(X==null?void 0:X.stepComponent),J=de(X==null?void 0:X.stepName);return Y==="configurator"||J.includes("configure")});if(Q>=0){const X=(G=ue[Q])==null?void 0:G.stepName;a.navigateToStep({stepName:X,data:ee})}else a.loadComponent("configurator",ee)}catch(Z){console.warn("[aiComponentLoader] Failed to navigate to configurator from cart configure click:",Z),a.loadComponent("configurator",{payload:{}})}},$=P=>{console.log("onCatalogIdReceived",P),l.updateConfig({eCatalogId:P})},F=P=>{console.log("Action",P),P.event==="add-to-quote"?n("configurator:add-to-quote",P.data):P.event==="save"&&n("configurator:save",P.data)},U=e.ref("");return e.watch(()=>a==null?void 0:a.activeComponentData,async P=>{var G,Z,oe;if(!P)return;console.log("activeComponentData Changed",P);const j=(P==null?void 0:P.requestId)||"";if(console.log("requestId",j),console.log("lastReloadRequestId",U.value),j&&j!==U.value)if(U.value=j,await e.nextTick(),(G=P==null?void 0:P.payload)!=null&&G.quoteConfiguration&&Object.keys(((Z=P==null?void 0:P.payload)==null?void 0:Z.quoteConfiguration)??{}).length>0){const ae=Object.keys(((oe=P==null?void 0:P.payload)==null?void 0:oe.quoteConfiguration)??{})[0];i.setPreConfigData(P==null?void 0:P.payload,ae)}else(P==null?void 0:P.actionFunction)==="Reload"&&(console.log("Reloading configurator 1"),i.refresh())},{deep:!0}),e.onMounted(()=>{e.nextTick(()=>{S()})}),(P,j)=>(e.openBlock(),e.createElementBlock("div",SC,[u.value==="catalog"?(e.openBlock(),e.createBlock(Nr,{key:x.value,"data-test-id":"aiComponentLoader-catalog",class:"ect-h-full ect-w-full","template-id":t.templateId,identity:t.identity,session:t.session,security:t.security,"search-term":d.value,"on-catalog-count-update":t.onCatalogCountUpdate,"preview-data":t.catalogPreviewData,"initial-data":m.value,sections:t.sections,theme:t.theme,"composables-org-type":t.composablesOrgType,onCatalogQuoteCreated:L,onCatalogQuoteUpdated:z,onCatalogItemsLoaded:I,onCatalogItemAdded:q,onCatalogItemQtyUpdated:W,onCatalogLineDeleted:te,onCatalogItemsFetched:K,onCatalogItemConfigure:T,"onCatalog:id":$},null,8,["template-id","identity","session","security","search-term","on-catalog-count-update","preview-data","initial-data","sections","theme","composables-org-type"])):u.value==="cart"&&f.value&&g.value?(e.openBlock(),e.createBlock(Sr,{key:E.value,"data-test-id":"aiComponentLoader-cart",class:"ect-h-full ect-w-full","template-id":t.templateId,"host-name":t.hostName,"composables-org-type":t.composablesOrgType,security:t.security,identity:t.identity,session:h.value,onExpeditecartItemConfigure:M,onExpeditecartClicked:O},null,8,["template-id","host-name","composables-org-type","security","identity","session"])):u.value==="cart"&&f.value&&!g.value?(e.openBlock(),e.createElementBlock("div",BC,IC)):u.value==="configurator"&&C.value?(e.openBlock(),e.createBlock(Cr,{key:k.value,"data-test-id":"aiComponentLoader-configurator",class:"ect-h-full ect-w-full",security:t.security,identity:t.identity,"user-locale":P.userLocale,cart:!0,"composables-org-type":t.composablesOrgType,session:s.value,functions:c.value,onReady:e.unref(i).setExpediteConfigComp,onAction:F},null,8,["security","identity","user-locale","composables-org-type","session","functions","onReady"])):u.value==="configurator"&&!C.value?(e.openBlock(),e.createBlock(NC,{key:4,onReturn:R,onGoCart:w})):(e.openBlock(),e.createElementBlock("div",OC,[e.createElementVNode("div",TC,[DC,e.createElementVNode("div",VC,e.toDisplayString(y.value),1)])]))]))}},[["__scopeId","data-v-3c362460"]]),MC={class:"ai-guidance-loader","data-test-id":"aiGuidance-loader-container"},RC={"data-test-id":"aiGuidance-loader-text"},LC={class:"aig-button","data-test-id":"aiGuidance-loader-button"},PC={class:"aig-input-box","data-test-id":"aiGuidance-loader-input"},qC=xe({__name:"AiGuidanceLoader",props:{errors:{type:Array,required:!1,default:()=>[]},chatBgColor:{type:String,required:!1,default:""}},setup(t){const r=t,n=e.computed(()=>`linear-gradient(180deg, ${r.chatBgColor} 0%, transparent 100%)`);return(o,a)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{class:"chat-gradient",style:e.normalizeStyle({background:n.value})},null,4),e.createElementVNode("div",MC,[e.createElementVNode("div",RC,[e.createVNode(wo,{style:{width:"100%",height:"16px","margin-bottom":"8px"}}),e.createVNode(wo,{style:{width:"100%",height:"16px","margin-bottom":"32px","max-width":"481px"}})]),e.createElementVNode("div",LC,[e.createVNode(wo,{style:{width:"100%",height:"24px"}})]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.errors,i=>(e.openBlock(),e.createElementBlock("div",{key:i,class:"aig-message-error","data-test-id":"aiGuidance-loader-error"},e.toDisplayString(i),1))),128)),e.createElementVNode("div",PC,[e.createVNode(wo,{style:{height:"36px",width:"100%"}})])])],64))}},[["__scopeId","data-v-5e4a9913"]]),$C={class:"ai-guidance-wrapper","data-test-id":"aiGuidance-wrapper"},Qi=xe({__name:"aiGuidance",props:{templateId:{type:String,required:!1},playbookData:{type:Object,required:!1},composablesOrgType:{type:String,required:!0},identity:{type:Object,required:!1,default:()=>({})},session:{type:Object,required:!1,default:()=>({})},security:{type:Object,required:!1,default:()=>({})},functions:{type:Object,required:!1,default:()=>({})},websocketUrl:{type:String,required:!0},packageVersion:{type:String,required:!0},hostName:{type:String,required:!1},graphqlEndpoint:{type:String,required:!1},apiKey:{type:String,required:!1},isPreview:{type:Boolean,required:!1,default:!1},catalogSections:{type:Array,required:!1,default:()=>[]},cartSections:{type:String,required:!1,default:""},theme:{type:Object,required:!1,default:()=>({})},styles:{type:Object,required:!1,default:()=>({height:"100vh"}),validator:t=>typeof(t==null?void 0:t.height)=="string"},resources:{type:Object,required:!1,default:()=>({})}},emits:["expeditecart-item-configure","expeditecart-clicked","component-action","ai-response:success","quote-id:updated","ai-guidance:error"],setup(t,{emit:r}){const n=Jn(),o=lt(),a=qn(),i=go(),l=r,s=e.ref(!0),c=e.ref(!1),u=e.ref(!0),f=e.ref(!0),g=e.ref(!1),h=e.ref([]),{emitError:m,emitErrors:d}=Qc(l,"aiGuidance"),_=t,{composablesOrgType:p,websocketUrl:C,packageVersion:y,identity:b,session:x,security:E,functions:A,templateId:k,hostName:B,graphqlEndpoint:D,apiKey:S,isPreview:v,catalogSections:N,cartSections:I,theme:L}=_,z=e.computed(()=>{var O,M,$;return{..._.session||{},quoteId:((O=_.session)==null?void 0:O.quoteId)||(((M=o.quoteId)==null?void 0:M.value)??""),eCatalogId:($=o.eCatalogId)==null?void 0:$.value}});e.onBeforeMount(async()=>{var O;console.log("security",E),console.log("apiKey",S),o.updateConfig({userId:b==null?void 0:b.userId,organizationId:b==null?void 0:b.organizationId,accessToken:E==null?void 0:E.accessToken,composablesApiUrl:E==null?void 0:E.baseUrl,composablesOrgType:p,websocketUrl:C,quoteId:x==null?void 0:x.quoteId,packageVersion:y,accountId:b==null?void 0:b.accountId,templateId:k,hostName:B,graphqlEndpoint:D,apiKey:(E==null?void 0:E.apiKey)||S,cid:b==null?void 0:b.contactId,isPreview:v,siteUrl:(O=_.resources)==null?void 0:O.siteUrl})}),e.onMounted(async()=>{var P,j,G,Z;const O=d1(_,b,E);d(O);const M=dc(C);if(M&&m(M),O.length>0||M){s.value=!1;return}n.setSecretKey(E==null?void 0:E.accessToken);let $=null,F,U;try{$=await n.getPlaybookInfoFromQuote(),F=($==null?void 0:$.XX_ORD1__Completed_PB_Step_Number_EX__c)??void 0,U=($==null?void 0:$.XX_ORD1__Playbook_Current_Step_Meta_EX__c)??void 0}catch(oe){console.error("[aiGuidance] Failed to get playbook info from quote:",oe),m("AI_GUIDANCE_PLAYBOOK_INFO_FETCH_FAILED",{error:oe.message})}if(U)try{U=JSON.parse(U)}catch(oe){console.error("[aiGuidance] Failed to parse currentStepMetaServer:",oe),m("AI_GUIDANCE_JSON_PARSE_ERROR",{error:oe.message,data:"currentStepMetaServer"}),U=void 0}if(console.info("sequenceNumberServer = ",F),_.templateId){s.value=!0;try{const ae=await n.getCatalogInContext();console.log("catalogInContext = ",ae),ae&&o.updateConfig({eCatalogId:ae})}catch(ae){console.error("[aiGuidance] Failed to get catalog in context:",ae),m("AI_GUIDANCE_CATALOG_FETCH_FAILED",{error:ae.message})}let oe=null;try{await i.fetchBlockInformationREST({templateId:_.templateId});const ae=f1(i.pageBlocks);oe=ae.playbookId,ae.error&&m(ae.error,{error:"Block structure validation failed"}),oe||m("AI_GUIDANCE_BLOCK_PLAYBOOK_ID_MISSING",{pageBlocks:i.pageBlocks})}catch(ae){console.error("[aiGuidance] Failed to fetch block information:",ae),m("AI_GUIDANCE_BLOCK_FETCH_FAILED",{error:ae.message})}if(console.log("playbookID",oe),oe?c.value=!0:h.value.push("No playbook ID found in template"),n.setEmbeddedMode(!0),oe)try{n.currentPlaybook=oe,await n.getPlaybookByKey(oe),n.showPlaybookSteps=!0}catch(ae){console.error("[aiGuidance] Failed to get playbook by key:",ae),m("AI_GUIDANCE_PLAYBOOK_FETCH_FAILED",{error:ae.message,playbookID:oe})}n.playbookStepsMode="full",a.setInitialPayload();try{await a.connectSocket()}catch(ae){console.error("[aiGuidance] Failed to connect socket:",ae),m("WEBSOCKET_CONNECTION_FAILED",{error:ae.message})}if(F!==void 0){n.navigateToStep({stepName:(j=(P=n.currentPlaybook)==null?void 0:P.playBookSteps[Number(F)])==null?void 0:j.stepName,data:U}),s.value=!1;return}(Z=(G=n.currentPlaybook)==null?void 0:G.playBookSteps)!=null&&Z.length&&n.setCurrentStepName(n.currentPlaybook.playBookSteps[0].stepName),s.value=!1}else h.value.push("templateId is required")});const q=e.computed(()=>{var $;const O=(($=n.currentPlaybook)==null?void 0:$.playBookSteps)||[],M=n.currentStepName;return O.find(F=>F.stepName===M)||O[0]||null}),W=e.computed(()=>{var O;return((O=q.value)==null?void 0:O.stepComponent)||null});e.watch(()=>n.activeComponentKey,O=>{O&&(u.value=!1)});const te=[];e.onMounted(()=>{te.push(Ft("expeditecart:configure-clicked",O=>{l("expeditecart-item-configure",O)})),te.push(Ft("expeditecart:clicked",O=>{l("expeditecart-clicked",O)})),te.push(Ft("ai-response:success",O=>{try{l("ai-response:success",O)}catch{}})),te.push(Ft("quote-id:updated",O=>{try{l("quote-id:updated",O)}catch(M){console.info("[aiGuidance] Error emitting quote-id:updated event:",M)}})),te.push(Ft("websocket:error",O=>{try{O!=null&&O.isInitialization&&m(O.errorCode||"WEBSOCKET_CONNECTION_FAILED",O)}catch(M){console.info("[aiGuidance] Error handling websocket error event:",M)}}))});const K=O=>{console.log("[aiGuidance] Received error from aiComponentLoader:",O),l("ai-guidance:error",O)},R=O=>{console.log("onExpediteCartClicked",O),l("component-action",{component:"cart",details:O})},w=(O,M)=>{var F;l("component-action",{component:"catalog",action:O,details:M});const $=(M==null?void 0:M.quoteId)??((F=M==null?void 0:M.response)==null?void 0:F.quoteId);if($&&(O==="item-added"||O==="items-fetched"))try{l("quote-id:updated",{quoteId:$})}catch(U){console.info("[aiGuidance] Error emitting quote-id:updated from catalog event:",U)}},T=(O,M)=>{l("component-action",{component:"configurator",action:O,details:M})};return e.onBeforeUnmount(()=>{try{a.cancelRequest()}catch{}try{a.disconnectSocket()}catch{}try{a.resetState()}catch{}try{n.setEmbeddedMode(!1),n.currentPlaybook=null,n.currentStepName=null,n.activeComponentKey=null,n.activeComponentData=null,n.showPlaybookSteps=!1,n.playbookStepsMode="full"}catch{}s.value=!1,c.value=!1,u.value=!0,f.value=!0,g.value=!1,h.value=[],te.forEach(O=>{try{O()}catch{}})}),(O,M)=>{var $;return e.openBlock(),e.createElementBlock("div",$C,[e.createVNode(ci,{icon:"logo",color:"#000000",size:"18.75",height:"16.25"}),s.value||e.unref(a).isFetchingHistory?(e.openBlock(),e.createBlock(qC,{key:0,errors:h.value,"data-test-id":"aiGuidance-loader"},null,8,["errors"])):(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["ai-app",{"root-path":u.value,"playbook-steps-mode-full":e.unref(n).playbookStepsMode==="full","dxp-guiddance":c.value}]),style:e.normalizeStyle(t.styles)},[e.createElementVNode("div",{class:"ai-app-chat-wrapper",style:e.normalizeStyle({height:t.styles.height})},[e.createVNode(_C,{"data-test-id":"chat-screen","is-external-guidance":c.value,styles:t.styles},null,8,["is-external-guidance","styles"])],4),!u.value&&f.value&&!g.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"component-loader-wrapper",style:e.normalizeStyle({height:t.styles.height,maxHeight:t.styles.height})},[e.unref(n).currentPlaybook?(e.openBlock(),e.createBlock(FC,{key:0,"template-id":(($=q.value)==null?void 0:$.templateId)||e.unref(k),"step-component":W.value,identity:e.unref(b),session:z.value,security:e.unref(E),functions:e.unref(A),"composables-org-type":e.unref(p),"package-version":e.unref(y),"host-name":e.unref(B),"graphql-endpoint":e.unref(D),"api-key":e.unref(S),"is-preview":e.unref(v),sections:e.unref(N),"cart-sections":e.unref(I),theme:e.unref(L),"data-test-id":"aiComponentLoader-mounted",onExpeditecartClicked:R,onCatalogQuoteCreated:M[0]||(M[0]=F=>w("quote-created",F)),onCatalogQuoteUpdated:M[1]||(M[1]=F=>w("quote-updated",F)),onCatalogItemsLoaded:M[2]||(M[2]=F=>w("items-loaded",F)),onCatalogItemAdded:M[3]||(M[3]=F=>w("item-added",F)),onCatalogItemQtyUpdated:M[4]||(M[4]=F=>w("item-qty-updated",F)),onCatalogLineDeleted:M[5]||(M[5]=F=>w("line-deleted",F)),onCatalogItemsFetched:M[6]||(M[6]=F=>w("items-fetched",F)),onCatalogItemConfigure:M[7]||(M[7]=F=>w("item-configure",F)),"onConfigurator:addToQuote":M[8]||(M[8]=F=>T("add-to-quote",F)),"onConfigurator:save":M[9]||(M[9]=F=>T("save",F)),"onAiGuidance:error":K},null,8,["template-id","step-component","identity","session","security","functions","composables-org-type","package-version","host-name","graphql-endpoint","api-key","is-preview","sections","cart-sections","theme"])):e.createCommentVNode("",!0)],4)):e.createCommentVNode("",!0)],6))])}}},[["__scopeId","data-v-920099b8"]]),r0={ExpediteConfigurator:Cr,ExpediteGPT:xi,ExpediteCatalog:Nr,ExpediteCart:Sr,ExpediteAIGuidance:Qi},UC={install(t,r={}){t.component("ExpediteConfigurator",Cr),t.component("ExpediteGPT",xi),t.component("ExpediteCatalog",Nr),t.component("ExpediteCart",Sr),t.component("ExpediteAIGuidance",Qi)},...r0};mt.Components=r0,mt.ExpediteAIGuidance=Qi,mt.ExpediteCart=Sr,mt.ExpediteCatalog=Nr,mt.ExpediteConfigurator=Cr,mt.ExpediteGPT=xi,mt.default=UC,mt.useComRootStore=Eo,Object.defineProperties(mt,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});