arcy.js 0.1.4 → 0.1.5

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.
@@ -1288,5 +1288,5 @@ ${t}`,!0;let r=e.host.ownerDocument.createElement("style");return Re(r),r.setAtt
1288
1288
  transition: none;
1289
1289
  }
1290
1290
  }
1291
- `+Zt+Wt+pn,Fn="http://www.w3.org/2000/svg";function te(e,t,n=17){let r=e.createElementNS(Fn,"svg");r.setAttribute("viewBox","0 0 24 24"),r.setAttribute("aria-hidden","true"),r.setAttribute("width",String(n)),r.setAttribute("height",String(n));for(let o of typeof t=="string"?[t]:t){let a=e.createElementNS(Fn,"path");a.setAttribute("d",o),a.setAttribute("fill","none"),a.setAttribute("stroke","currentColor"),a.setAttribute("stroke-width","2"),a.setAttribute("stroke-linecap","round"),a.setAttribute("stroke-linejoin","round"),r.appendChild(a);}return r}var _o="M12 21a9 9 0 100-18 9 9 0 000 18zM12 7v5l3 2",Pn="M13 3L5 14h6l-1 7 8-11h-6l1-7z",So="M6 9l6 6 6-6",Lo="M18 6L6 18M6 6l12 12",Io=["M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z","M9 12a3 3 0 1 0 6 0 3 3 0 1 0-6 0"],Ro=["M19 13V19H13","M5 5L19 19"],$n=["M5 8h10","M9 4v4","M12 20l4-9 4 9","M13.5 17h5","M13 8a10 10 0 0 1-8 8","M8 11a10 10 0 0 0 5 5"],Mo="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z";function Ue(e,t){let n=e.style,r=t.bar.getMetrics(),o=t.getMaxHeightPercent?.()??Ao,a=r.bottomOffset+r.keyboardOffset+r.height+8;if(n.setProperty("bottom",`${a}px`),n.setProperty("left","50%"),n.setProperty("translate","-50%"),n.setProperty("transform",xe(r.offset)),r.isMobile){e.setAttribute("data-sheet",""),n.setProperty("width",`calc(100% - ${24}px)`),n.setProperty("max-width","none"),n.setProperty("height",`calc(100% - ${a+12}px)`),n.setProperty("max-height","none");return}e.removeAttribute("data-sheet");let s=Oe(r.widthPercent,{width:r.viewportWidth,height:r.viewportHeight});n.setProperty("width",`${s}px`),n.setProperty("max-width",`calc(100vw - ${32}px)`),n.setProperty("transform",xe({x:De(r.offset.x,s,r.viewportWidth),y:r.offset.y}));let h=a-r.offset.y,C=un(o,r.viewportHeight,h);n.setProperty("height",`${C}px`),n.setProperty("max-height",`${C}px`);}function Fo(e){try{let ee=function(){try{for(;Q.firstChild;)Q.removeChild(Q.firstChild);Q.style.setProperty("display",P.length>0?"flex":"none");let i=d().removeImage;for(let p of P){let f=c.createElement("div");if(f.className=J,f.setAttribute("data-state",p.attachment?"ready":"uploading"),p.previewUrl){let _=c.createElement("img");_.src=p.previewUrl,_.alt="",f.appendChild(_);}let b=c.createElement("button");b.type="button",b.setAttribute("aria-label",i),b.setAttribute("data-tip",i),b.appendChild(te(c,Lo,12)),b.addEventListener("click",()=>{P=P.filter(_=>_!==p),bt(p),ee();}),f.appendChild(b),Q.appendChild(f);}e.bar.setAttachmentCount(P.length);}catch{}},vt=function(){e.setConversationId?.(null),M.clear(),yt(),X();},he=function(i){let p=ie;p&&(ie=null,oe.hide(),e.bar.setAwaitingInput?.(!1),e.bar.setDisabled(_e),e.bar.setPlaceholder(w()?.inputPlaceholder??null),p.resolve(i));},je=function(i){let p=ie;if(!p)return;let f=p.request,b=f.kind==="select"||f.kind==="radio"?gn(i,f.options):f.kind==="password"?i:i.trim(),_=mn(b,f);if(_!==null){oe.setError(_);return}he(b);},At=function(i){if(_e)return;let p=P.filter(f=>f.attachment!==null);P=P.filter(f=>f.attachment===null),ee(),M.addMessage("user",i,{images:p.length,imageUrls:p.map(f=>f.previewUrl).filter(f=>f!==null)}),X(),_e=!0,e.bar.setDisabled(!0),M.setPending(!0),wn({apiBase:e.apiBase??D,publicKey:e.publicKey??"",sessionId:e.getSessionId?.()??"",sessionToken:e.getSessionToken?.()??"",query:i,route:e.getRoute?.()??l?.location?.pathname??"",conversationId:e.getConversationId?.()??"",attachments:p.map(f=>({objectKey:f.attachment.objectKey}))}).then(f=>{let b=d();if(f.ok){M.addMessage("assistant",f.message,{messageId:f.messageId,citedSources:f.citedSources,flowOffers:f.flowsOffered}),e.touchConversation?.(),f.isFallback&&e.track?.("fallback_triggered",{},{question:i});for(let _ of f.flowsOffered)e.track?.("flow_suggested",{},{flowCvid:_.flowCvid});return}if(f.reason==="cap_denied"){ko.has(f.capReason)?e.onOrgCapExceeded?.():M.addMessage("system",b.userCapReached);return}M.addMessage("system",b.genericError);}).finally(()=>{_e=!1,M.setPending(!1),e.bar.setDisabled(!1);});},ge=function(){if(!u.hasAttribute("data-open")){Ke(),st(e.host,c,e.apiBase),e.bar.setMode("open"),Ue(u,e),u.setAttribute("data-open","");try{let i=e.isolated?e.root:c,p=e.isolated?i.activeElement:c.activeElement;Le=(e.isolated?p!==null:!!(p&&e.host.contains(p)))?null:c.activeElement,e.bar.focusInput();}catch{}}},Ke=function(){let i=w(),p=d();N(),W(),ie||e.bar.setPlaceholder(i?.inputPlaceholder??null),e.bar.setAttachEnabled(i?.allowImageUpload===!0),e.bar.setDisclaimer(j());for(let[f,b]of [[x,p.historyTitle],[A,p.flowsTitle],[$,p.settingsTitle],[U,p.collapse]])f.setAttribute("aria-label",b),f.setAttribute("data-tip",b);for(let f of [O,G,B])f.setTexts({backLabel:p.back,closeLabel:p.closeSheet});X();},_t=function(){if(u.hasAttribute("data-open")){u.removeAttribute("data-open"),O.close(),G.close(),B.close(),Z="root",e.bar.setMode("idle"),e.bar.setDisclaimer(null);try{let i=Le;Le=null;let p=u.getRootNode();(p instanceof ShadowRoot?p.activeElement:document.activeElement!==null&&document.activeElement!==document.body)&&i&&i.isConnected&&typeof i.focus=="function"&&i.focus();}catch{}}};var t=ee,n=vt,r=he,o=je,a=At,s=ge,h=Ke,C=_t;let g={host:e.host,root:e.root,isolated:e.isolated,destroy(){}};Xe(g,To),Xe(g,fn);let c=e.host.ownerDocument,l=c.defaultView,w=()=>{try{return e.getWidget?.()??null}catch{return null}},d=()=>w()?.chrome??Ft,u=c.createElement("div");u.className=de,u.setAttribute("role","dialog"),u.setAttribute("aria-label","ARCY chat"),u.tabIndex=-1,u.style.setProperty("position","absolute","important"),u.style.setProperty("pointer-events","auto","important"),u.style.setProperty("box-sizing","border-box");let v=c.createElement("div");v.className=dt;let m=(i,p,f)=>{let b=c.createElement("button");return b.type="button",b.className=ze,b.setAttribute("aria-label",i),b.setAttribute("data-tip",i),b.setAttribute("data-tip-placement","below"),b.setAttribute("data-tip-align",f),b.appendChild(te(c,p)),b},x=m(d().historyTitle,_o,"start"),A=m(d().flowsTitle,Pn,"start");A.style.setProperty("display","none");let E=c.createElement("div");E.className="arcy-chat-identity";let L=c.createElement("span"),H=c.createElement("span");H.className=On,E.appendChild(L),E.appendChild(H);let $=m(d().settingsTitle,Io,"end");e.bar.dock||$.style.setProperty("display","none");let U=m(d().collapse,So,"end");v.appendChild(x),v.appendChild(A),v.appendChild(E),v.appendChild($),v.appendChild(U);let N=()=>{let i=w(),p=at(i?.logoUrl,e.apiBase);if(H.textContent=p?"":i?.name??"",H.style.setProperty("display",p?"none":"block"),p&&L.getAttribute("data-src")===p)return;let f=p?c.createElement("img"):c.createElement("span");if(f.className=p?Nn:"",p){let b=f;b.alt=i?.name??"",b.decoding="async",b.onerror=()=>{try{let _=c.createElement("span");b.replaceWith(_),L=_,H.textContent=i?.name??"",H.style.setProperty("display","block");}catch{}},b.setAttribute("data-src",p),b.src=p;}L.replaceWith(f),L=f;},y=c.createElement("div");y.className=ne;let k=c.createElement("div");k.className=Dn;let T=c.createElement("a");T.className=Ae,T.href=Co,T.target="_blank",T.rel="noopener noreferrer";let I=c.createElement("span"),q=Ln(c);q&&q.setAttribute("class",ke),T.appendChild(I),q&&T.appendChild(q),k.appendChild(T);let W=()=>{let i=d();I.textContent=i.poweredBy.replace(/\s*ARCY\s*$/i,""),T.setAttribute("aria-label",i.poweredBy);},j=()=>{let i=w(),p=d(),f=i?.privacyPolicyUrl,b=i?.name?p.aiDisclaimer.replace("{app}",i.name):p.aiDisclaimer;if(typeof f=="string"&&/^https:\/\//i.test(f)){let _=p.consentWithPolicy.indexOf("{policy}"),Y=_>=0?p.consentWithPolicy.slice(0,_):`${p.consentWithPolicy} `,R=_>=0?p.consentWithPolicy.slice(_+8):"";return {before:`${b}${p.disclaimerJoin}${Y}`,linkLabel:p.privacyPolicy,linkHref:f,after:R}}return b},ue=c.createElement("div");ue.className=Bn,ue.appendChild(y),u.appendChild(v),u.appendChild(ue),u.appendChild(k),e.root.appendChild(u),st(e.host,c,e.apiBase),Ue(u,e);let M=en(y,c,{labels:{likeAnswer:d().likeAnswer,dislikeAnswer:d().dislikeAnswer},answeringLabel:()=>d().answering,searchedSourcesLabel:d().searchedSourcesLabel,sourcesLabel:d().sourcesLabel,flowOfferHint:()=>d().flowOfferHint,onStartFlow:i=>{e.track?.("flow_pill_clicked",{},{flowCvid:i}),e.onStartFlow?.(i);},onFeedback:(i,p)=>{e.track?.("answer_feedback",{},{value:i});let f=e.getSessionToken?.()??"",b=e.getConversationId?.()??"";!p||!f||!b||Sn({apiBase:e.apiBase,sessionToken:f,conversationId:b,messageId:p,value:i,visitorId:e.getVisitorId?.()??void 0});}}),z=c.createElement("div");z.className=re,y.insertBefore(z,y.firstChild);let ft=[],fe=!0,ht=null,X=()=>{try{for(;z.firstChild;)z.removeChild(z.firstChild);if(!M.isEmpty()){z.style.setProperty("display","none");return}z.style.setProperty("display","flex");let i=w(),p=c.createElement("div");p.className="arcy-chat-welcome-icon";let f=at(i?.welcomeIconUrl,e.apiBase);if(f&&f!==ht){let R=c.createElement("img");R.src=f,R.alt="",R.addEventListener("error",()=>{ht=f,X();},{once:!0}),p.appendChild(R);}else p.appendChild(te(c,Mo,18));z.appendChild(p);let b=i?.welcomeHeadline?.trim()??"",_=i?.welcomeMessage?.trim()??"";if(b){let R=c.createElement("div");R.className="arcy-chat-headline",R.textContent=b,z.appendChild(R);}if(_){let R=c.createElement("div");R.className="arcy-chat-greeting",R.textContent=_,z.appendChild(R);}let Y=c.createElement("div");Y.className=pt,fe&&Y.setAttribute("data-pending","");for(let R of ft){let K=c.createElement("button");K.type="button",K.className=pe,K.textContent=R.publicName,K.addEventListener("click",()=>{e.track?.("starter_flow_clicked",{},{flowCvid:R.cvid}),e.onStartFlow?.(R.cvid);}),Y.appendChild(K);}z.appendChild(Y);}catch{}},Q=c.createElement("div");Q.className=ut,Q.style.setProperty("display","none");let mt=e.bar.attachmentSlot?.()??null;mt?mt.appendChild(Q):y.insertBefore(Q,y.firstChild);let P=[],gt=In(c),Hn=gt.fetchImpl??(typeof fetch<"u"?fetch.bind(globalThis):null),Un=i=>{try{return l?.URL?.createObjectURL?.(i)??URL.createObjectURL(i)}catch{return null}},Ve=i=>{if(i.previewUrl){try{(l?.URL??URL).revokeObjectURL(i.previewUrl);}catch{}i.previewUrl=null;}},bt=i=>{Ve(i);let p=i.attachment?.objectKey;p&&Mn(p,{apiBase:e.apiBase,sessionToken:e.getSessionToken?.()??"",fetchImpl:Hn});},yt=()=>{let i=P;P=[];for(let p of i)bt(p);ee();},Ee=Promise.resolve(),wt=i=>{Ee=Ee.then(async()=>{for(let p of i){let f=e.getSessionToken?.()??"",b=K=>{let Ie=d();M.addMessage("system",K==="type"?Ie.imageWrongType:K==="size"?Ie.imageTooLarge:K==="count"?Ie.imageTooMany:Ie.imageFailed);},_=ct(p,P.length);if(!_.ok){b(_.reason),X();continue}let Y={previewUrl:Un(p),attachment:null};P=[...P,Y],ee();let R=await Rn(p,P.length-1,{apiBase:e.apiBase,sessionToken:f,env:gt});if(R.ok){Y.attachment=R.attachment,ee();continue}P=P.filter(K=>K!==Y),Ve(Y),ee(),b(R.reason),X();}}),Ee=Ee.catch(()=>{});},We=[],O=$e(u,c,{title:d().historyTitle,emptyText:d().historyEmpty,actionLabel:d().newChat,subtitleTips:!1,backLabel:d().back,closeLabel:d().closeSheet,onBack:()=>O.close(),onAction:()=>{vt(),O.close();},onSelect:i=>{if((e.getConversationId?.()??"")===i&&!M.isEmpty()){O.close();return}e.setConversationId?.(i),M.clear(),yt(),X(),O.close(),zn(i);}});async function zn(i){let p=e.getSessionToken?.()??"";if(!p)return;let f=await _n({apiBase:e.apiBase,sessionToken:p,conversationId:i,visitorId:e.getVisitorId?.()??void 0});if(f.ok&&(e.getConversationId?.()??"")===i){M.clear();for(let b of f.messages)M.addMessage(Tn(b.role),b.text,{images:b.images,at:b.occurredAt?new Date(b.occurredAt):void 0,messageId:b.id,feedback:b.feedback});X(),M.scrollToEnd();}}let G=$e(u,c,{title:d().flowsTitle,emptyText:d().flowsEmpty,actionLabel:null,backLabel:d().back,closeLabel:d().closeSheet,itemIcon:i=>te(i,Pn,16),onBack:()=>G.close(),onSelect:i=>{G.close(),e.onStartFlow?.(i);}}),Z="root",B=$e(u,c,{title:d().settingsTitle,side:"right",actionLabel:null,backLabel:d().back,closeLabel:d().closeSheet,onBack:()=>{if(Z==="language"){Z="root",Te();return}B.close();},onSelect:i=>{if(Z==="language"){B.close(),Z="root",e.onSelectLocale?.(i);return}if(i==="language"){Z="language",Te();return}i==="dock"&&(B.close(),e.onRequestClose(),e.bar.dock?.());}}),Vn=()=>{if(!e.onSelectLocale)return [];let i=w()?.locales??[];return i.length>=2?i:[]},Te=()=>{let i=d(),p=Vn();if(Z==="language"){B.setTitle(i.language),B.setItems(p.map(b=>({id:b.code,title:b.label,active:b.code===w()?.activeLocale,icon:_=>te(_,$n,16)})));return}B.setTitle(i.settingsTitle);let f=p.find(b=>b.code===w()?.activeLocale);B.setItems([...p.length?[{id:"language",title:i.language,subtitle:f?.label??null,icon:b=>te(b,$n,16)}]:[],{id:"dock",title:i.dockChat,subtitle:i.dockChatHint,icon:b=>te(b,Ro,16)}]);},xt=()=>{let i=d();O.setTitle(i.historyTitle),O.setTexts({emptyText:i.historyEmpty,actionLabel:i.newChat}),O.setItems(lt(We,i.imageConversation,e.getConversationId?.())),O.open(),Wn();};async function Wn(){let i=e.getSessionToken?.()??"",p=e.getVisitorId?.()??"";if(!i||!p)return;let f=await En({apiBase:e.apiBase,sessionToken:i,visitorId:p});f.ok&&(We=f.conversations,O.isOpen()&&O.setItems(lt(We,d().imageConversation,e.getConversationId?.())));}x.addEventListener("click",xt),A.addEventListener("click",()=>{let i=d();G.setTitle(i.flowsTitle),G.setTexts({emptyText:i.flowsEmpty}),G.open();});let Ct=()=>{Z="root",Te(),B.open();};$.addEventListener("click",Ct);let kt=()=>e.onRequestClose();U.addEventListener("click",kt);let oe=hn(e,()=>d()),ie=null,_e=!1;e.bar.onSubmit(i=>{if(ie){je(i);return}ge(),At(i);}),e.bar.onFiles?.(i=>{ge(),wt(i);});let jn=()=>w()?.allowImageUpload===!0,Gn=i=>{qe(i)&&i.preventDefault();},Yn=i=>{if(!qe(i)||(i.preventDefault(),!jn()))return;let p=Pt(i);p.length>0&&wt(p);};u.addEventListener("dragover",Gn),u.addEventListener("drop",Yn);let me=i=>{ft=i,fe=!1,X();},Se=!1,Ge=null,Ye=()=>{if(Se)return !0;let i=e.getSessionToken?.();return i?(Se=!0,Ge=w()?.audience||null,bn({apiBase:e.apiBase,sessionToken:i,sessionId:e.getSessionId?.()}).then(p=>{if(!p.ok){me([]);return}let f=yn(p.flows);me(p.starterFlows),f.length!==0&&(A.style.setProperty("display","flex"),G.setItems(f.map(b=>({id:b.cvid,title:b.publicName,subtitle:b.summary}))));}).catch(()=>{me([]);}),!0):!1};if(!Ye())try{l?.setTimeout(()=>{!Ye()&&fe&&me([]);},Eo);}catch{}let Et=i=>{if(i.key==="Escape"){if(i.stopPropagation(),O.isOpen()){O.close();return}if(G.isOpen()){G.close();return}if(B.isOpen()){B.close();return}e.onRequestClose();}};u.addEventListener("keydown",Et);let Tt=()=>{u.hasAttribute("data-open")&&Ue(u,e),oe.reposition();};l?.addEventListener("resize",Tt);let Le=null;return {open:ge,close:_t,reposition(){u.hasAttribute("data-open")&&Ue(u,e),oe.reposition();},refreshChrome(){let i=w()?.audience||null;Se&&i!==null&&Ge!==null&&i!==Ge&&M.isEmpty()&&(Se=!1,fe=!0),!Ye()&&fe&&me([]),u.hasAttribute("data-open")&&(Ke(),B.isOpen()&&Te());},destroy(){x.removeEventListener("click",xt),$.removeEventListener("click",Ct),U.removeEventListener("click",kt),u.removeEventListener("keydown",Et),l?.removeEventListener("resize",Tt),Le=null,he(null),oe.destroy(),O.destroy(),G.destroy(),B.destroy(),M.destroy();for(let i of P)Ve(i);P=[],Q.remove(),e.bar.setAttachmentCount(0),u.remove();},promptFill(i){return new Promise(p=>{he(null),e.onRequestClose(),oe.show(i,{onAnswer:f=>je(f)}),e.bar.setAwaitingInput?.(!0),i.kind==="password"?e.bar.setDisabled(!0):(e.bar.setPlaceholder(i.question),e.bar.focusInput()),ie={resolve:p,request:i};})},cancelFill(){he(null);},showFlowFailure(){ge(),M.addMessage("assistant",d().flowFailed),X();}}}catch{return null}}var Po={contract:4,mount:Fo};if(typeof window<"u")try{window[St]=Po;}catch{}
1291
+ `+Zt+Wt+pn,Fn="http://www.w3.org/2000/svg";function te(e,t,n=17){let r=e.createElementNS(Fn,"svg");r.setAttribute("viewBox","0 0 24 24"),r.setAttribute("aria-hidden","true"),r.setAttribute("width",String(n)),r.setAttribute("height",String(n));for(let o of typeof t=="string"?[t]:t){let a=e.createElementNS(Fn,"path");a.setAttribute("d",o),a.setAttribute("fill","none"),a.setAttribute("stroke","currentColor"),a.setAttribute("stroke-width","2"),a.setAttribute("stroke-linecap","round"),a.setAttribute("stroke-linejoin","round"),r.appendChild(a);}return r}var _o="M12 21a9 9 0 100-18 9 9 0 000 18zM12 7v5l3 2",Pn="M13 3L5 14h6l-1 7 8-11h-6l1-7z",So="M6 9l6 6 6-6",Lo="M18 6L6 18M6 6l12 12",Io=["M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z","M9 12a3 3 0 1 0 6 0 3 3 0 1 0-6 0"],Ro=["M19 13V19H13","M5 5L19 19"],$n=["M5 8h10","M9 4v4","M12 20l4-9 4 9","M13.5 17h5","M13 8a10 10 0 0 1-8 8","M8 11a10 10 0 0 0 5 5"],Mo="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z";function Ue(e,t){let n=e.style,r=t.bar.getMetrics(),o=t.getMaxHeightPercent?.()??Ao,a=r.bottomOffset+r.keyboardOffset+r.height+8;if(n.setProperty("bottom",`${a}px`),n.setProperty("left","50%"),n.setProperty("translate","-50%"),n.setProperty("transform",xe(r.offset)),r.isMobile){e.setAttribute("data-sheet",""),n.setProperty("width",`calc(100% - ${24}px)`),n.setProperty("max-width","none"),n.setProperty("height",`calc(100% - ${a+12}px)`),n.setProperty("max-height","none");return}e.removeAttribute("data-sheet");let s=Oe(r.widthPercent,{width:r.viewportWidth,height:r.viewportHeight});n.setProperty("width",`${s}px`),n.setProperty("max-width",`calc(100vw - ${32}px)`),n.setProperty("transform",xe({x:De(r.offset.x,s,r.viewportWidth),y:r.offset.y}));let h=a-r.offset.y,C=un(o,r.viewportHeight,h);n.setProperty("height",`${C}px`),n.setProperty("max-height",`${C}px`);}function Fo(e){try{let ee=function(){try{for(;Q.firstChild;)Q.removeChild(Q.firstChild);Q.style.setProperty("display",P.length>0?"flex":"none");let i=d().removeImage;for(let p of P){let f=c.createElement("div");if(f.className=J,f.setAttribute("data-state",p.attachment?"ready":"uploading"),p.previewUrl){let _=c.createElement("img");_.src=p.previewUrl,_.alt="",f.appendChild(_);}let b=c.createElement("button");b.type="button",b.setAttribute("aria-label",i),b.setAttribute("data-tip",i),b.appendChild(te(c,Lo,12)),b.addEventListener("click",()=>{P=P.filter(_=>_!==p),bt(p),ee();}),f.appendChild(b),Q.appendChild(f);}e.bar.setAttachmentCount(P.length);}catch{}},vt=function(){e.setConversationId?.(null),M.clear(),yt(),X();},he=function(i){let p=ie;p&&(ie=null,oe.hide(),e.bar.setAwaitingInput?.(!1),e.bar.setDisabled(_e),e.bar.setPlaceholder(w()?.inputPlaceholder??null),p.resolve(i));},je=function(i){let p=ie;if(!p)return;let f=p.request,b=f.kind==="select"||f.kind==="radio"?gn(i,f.options):f.kind==="password"?i:i.trim(),_=mn(b,f);if(_!==null){oe.setError(_);return}he(b);},At=function(i){if(_e)return;let p=P.filter(f=>f.attachment!==null);P=P.filter(f=>f.attachment===null),ee(),M.addMessage("user",i,{images:p.length,imageUrls:p.map(f=>f.previewUrl).filter(f=>f!==null)}),X(),_e=!0,e.bar.setDisabled(!0),M.setPending(!0),wn({apiBase:e.apiBase??D,publicKey:e.publicKey??"",sessionId:e.getSessionId?.()??"",sessionToken:e.getSessionToken?.()??"",query:i,route:e.getRoute?.()??l?.location?.pathname??"",conversationId:e.getConversationId?.()??"",attachments:p.map(f=>({objectKey:f.attachment.objectKey}))}).then(f=>{let b=d();if(f.ok){M.addMessage("assistant",f.message,{messageId:f.messageId,citedSources:f.citedSources,flowOffers:f.flowsOffered}),e.touchConversation?.();for(let _ of f.flowsOffered)e.track?.("flow_suggested",{},{flowCvid:_.flowCvid});return}if(f.reason==="cap_denied"){ko.has(f.capReason)?e.onOrgCapExceeded?.():M.addMessage("system",b.userCapReached);return}M.addMessage("system",b.genericError);}).finally(()=>{_e=!1,M.setPending(!1),e.bar.setDisabled(!1);});},ge=function(){if(!u.hasAttribute("data-open")){Ke(),st(e.host,c,e.apiBase),e.bar.setMode("open"),Ue(u,e),u.setAttribute("data-open","");try{let i=e.isolated?e.root:c,p=e.isolated?i.activeElement:c.activeElement;Le=(e.isolated?p!==null:!!(p&&e.host.contains(p)))?null:c.activeElement,e.bar.focusInput();}catch{}}},Ke=function(){let i=w(),p=d();N(),W(),ie||e.bar.setPlaceholder(i?.inputPlaceholder??null),e.bar.setAttachEnabled(i?.allowImageUpload===!0),e.bar.setDisclaimer(j());for(let[f,b]of [[x,p.historyTitle],[A,p.flowsTitle],[$,p.settingsTitle],[U,p.collapse]])f.setAttribute("aria-label",b),f.setAttribute("data-tip",b);for(let f of [O,G,B])f.setTexts({backLabel:p.back,closeLabel:p.closeSheet});X();},_t=function(){if(u.hasAttribute("data-open")){u.removeAttribute("data-open"),O.close(),G.close(),B.close(),Z="root",e.bar.setMode("idle"),e.bar.setDisclaimer(null);try{let i=Le;Le=null;let p=u.getRootNode();(p instanceof ShadowRoot?p.activeElement:document.activeElement!==null&&document.activeElement!==document.body)&&i&&i.isConnected&&typeof i.focus=="function"&&i.focus();}catch{}}};var t=ee,n=vt,r=he,o=je,a=At,s=ge,h=Ke,C=_t;let g={host:e.host,root:e.root,isolated:e.isolated,destroy(){}};Xe(g,To),Xe(g,fn);let c=e.host.ownerDocument,l=c.defaultView,w=()=>{try{return e.getWidget?.()??null}catch{return null}},d=()=>w()?.chrome??Ft,u=c.createElement("div");u.className=de,u.setAttribute("role","dialog"),u.setAttribute("aria-label","ARCY chat"),u.tabIndex=-1,u.style.setProperty("position","absolute","important"),u.style.setProperty("pointer-events","auto","important"),u.style.setProperty("box-sizing","border-box");let v=c.createElement("div");v.className=dt;let m=(i,p,f)=>{let b=c.createElement("button");return b.type="button",b.className=ze,b.setAttribute("aria-label",i),b.setAttribute("data-tip",i),b.setAttribute("data-tip-placement","below"),b.setAttribute("data-tip-align",f),b.appendChild(te(c,p)),b},x=m(d().historyTitle,_o,"start"),A=m(d().flowsTitle,Pn,"start");A.style.setProperty("display","none");let E=c.createElement("div");E.className="arcy-chat-identity";let L=c.createElement("span"),H=c.createElement("span");H.className=On,E.appendChild(L),E.appendChild(H);let $=m(d().settingsTitle,Io,"end");e.bar.dock||$.style.setProperty("display","none");let U=m(d().collapse,So,"end");v.appendChild(x),v.appendChild(A),v.appendChild(E),v.appendChild($),v.appendChild(U);let N=()=>{let i=w(),p=at(i?.logoUrl,e.apiBase);if(H.textContent=p?"":i?.name??"",H.style.setProperty("display",p?"none":"block"),p&&L.getAttribute("data-src")===p)return;let f=p?c.createElement("img"):c.createElement("span");if(f.className=p?Nn:"",p){let b=f;b.alt=i?.name??"",b.decoding="async",b.onerror=()=>{try{let _=c.createElement("span");b.replaceWith(_),L=_,H.textContent=i?.name??"",H.style.setProperty("display","block");}catch{}},b.setAttribute("data-src",p),b.src=p;}L.replaceWith(f),L=f;},y=c.createElement("div");y.className=ne;let k=c.createElement("div");k.className=Dn;let T=c.createElement("a");T.className=Ae,T.href=Co,T.target="_blank",T.rel="noopener noreferrer";let I=c.createElement("span"),q=Ln(c);q&&q.setAttribute("class",ke),T.appendChild(I),q&&T.appendChild(q),k.appendChild(T);let W=()=>{let i=d();I.textContent=i.poweredBy.replace(/\s*ARCY\s*$/i,""),T.setAttribute("aria-label",i.poweredBy);},j=()=>{let i=w(),p=d(),f=i?.privacyPolicyUrl,b=i?.name?p.aiDisclaimer.replace("{app}",i.name):p.aiDisclaimer;if(typeof f=="string"&&/^https:\/\//i.test(f)){let _=p.consentWithPolicy.indexOf("{policy}"),Y=_>=0?p.consentWithPolicy.slice(0,_):`${p.consentWithPolicy} `,R=_>=0?p.consentWithPolicy.slice(_+8):"";return {before:`${b}${p.disclaimerJoin}${Y}`,linkLabel:p.privacyPolicy,linkHref:f,after:R}}return b},ue=c.createElement("div");ue.className=Bn,ue.appendChild(y),u.appendChild(v),u.appendChild(ue),u.appendChild(k),e.root.appendChild(u),st(e.host,c,e.apiBase),Ue(u,e);let M=en(y,c,{labels:{likeAnswer:d().likeAnswer,dislikeAnswer:d().dislikeAnswer},answeringLabel:()=>d().answering,searchedSourcesLabel:d().searchedSourcesLabel,sourcesLabel:d().sourcesLabel,flowOfferHint:()=>d().flowOfferHint,onStartFlow:i=>{e.track?.("flow_pill_clicked",{},{flowCvid:i}),e.onStartFlow?.(i);},onFeedback:(i,p)=>{e.track?.("answer_feedback",{},{value:i});let f=e.getSessionToken?.()??"",b=e.getConversationId?.()??"";!p||!f||!b||Sn({apiBase:e.apiBase,sessionToken:f,conversationId:b,messageId:p,value:i,visitorId:e.getVisitorId?.()??void 0});}}),z=c.createElement("div");z.className=re,y.insertBefore(z,y.firstChild);let ft=[],fe=!0,ht=null,X=()=>{try{for(;z.firstChild;)z.removeChild(z.firstChild);if(!M.isEmpty()){z.style.setProperty("display","none");return}z.style.setProperty("display","flex");let i=w(),p=c.createElement("div");p.className="arcy-chat-welcome-icon";let f=at(i?.welcomeIconUrl,e.apiBase);if(f&&f!==ht){let R=c.createElement("img");R.src=f,R.alt="",R.addEventListener("error",()=>{ht=f,X();},{once:!0}),p.appendChild(R);}else p.appendChild(te(c,Mo,18));z.appendChild(p);let b=i?.welcomeHeadline?.trim()??"",_=i?.welcomeMessage?.trim()??"";if(b){let R=c.createElement("div");R.className="arcy-chat-headline",R.textContent=b,z.appendChild(R);}if(_){let R=c.createElement("div");R.className="arcy-chat-greeting",R.textContent=_,z.appendChild(R);}let Y=c.createElement("div");Y.className=pt,fe&&Y.setAttribute("data-pending","");for(let R of ft){let K=c.createElement("button");K.type="button",K.className=pe,K.textContent=R.publicName,K.addEventListener("click",()=>{e.track?.("starter_flow_clicked",{},{flowCvid:R.cvid}),e.onStartFlow?.(R.cvid);}),Y.appendChild(K);}z.appendChild(Y);}catch{}},Q=c.createElement("div");Q.className=ut,Q.style.setProperty("display","none");let mt=e.bar.attachmentSlot?.()??null;mt?mt.appendChild(Q):y.insertBefore(Q,y.firstChild);let P=[],gt=In(c),Hn=gt.fetchImpl??(typeof fetch<"u"?fetch.bind(globalThis):null),Un=i=>{try{return l?.URL?.createObjectURL?.(i)??URL.createObjectURL(i)}catch{return null}},Ve=i=>{if(i.previewUrl){try{(l?.URL??URL).revokeObjectURL(i.previewUrl);}catch{}i.previewUrl=null;}},bt=i=>{Ve(i);let p=i.attachment?.objectKey;p&&Mn(p,{apiBase:e.apiBase,sessionToken:e.getSessionToken?.()??"",fetchImpl:Hn});},yt=()=>{let i=P;P=[];for(let p of i)bt(p);ee();},Ee=Promise.resolve(),wt=i=>{Ee=Ee.then(async()=>{for(let p of i){let f=e.getSessionToken?.()??"",b=K=>{let Ie=d();M.addMessage("system",K==="type"?Ie.imageWrongType:K==="size"?Ie.imageTooLarge:K==="count"?Ie.imageTooMany:Ie.imageFailed);},_=ct(p,P.length);if(!_.ok){b(_.reason),X();continue}let Y={previewUrl:Un(p),attachment:null};P=[...P,Y],ee();let R=await Rn(p,P.length-1,{apiBase:e.apiBase,sessionToken:f,env:gt});if(R.ok){Y.attachment=R.attachment,ee();continue}P=P.filter(K=>K!==Y),Ve(Y),ee(),b(R.reason),X();}}),Ee=Ee.catch(()=>{});},We=[],O=$e(u,c,{title:d().historyTitle,emptyText:d().historyEmpty,actionLabel:d().newChat,subtitleTips:!1,backLabel:d().back,closeLabel:d().closeSheet,onBack:()=>O.close(),onAction:()=>{vt(),O.close();},onSelect:i=>{if((e.getConversationId?.()??"")===i&&!M.isEmpty()){O.close();return}e.setConversationId?.(i),M.clear(),yt(),X(),O.close(),zn(i);}});async function zn(i){let p=e.getSessionToken?.()??"";if(!p)return;let f=await _n({apiBase:e.apiBase,sessionToken:p,conversationId:i,visitorId:e.getVisitorId?.()??void 0});if(f.ok&&(e.getConversationId?.()??"")===i){M.clear();for(let b of f.messages)M.addMessage(Tn(b.role),b.text,{images:b.images,at:b.occurredAt?new Date(b.occurredAt):void 0,messageId:b.id,feedback:b.feedback});X(),M.scrollToEnd();}}let G=$e(u,c,{title:d().flowsTitle,emptyText:d().flowsEmpty,actionLabel:null,backLabel:d().back,closeLabel:d().closeSheet,itemIcon:i=>te(i,Pn,16),onBack:()=>G.close(),onSelect:i=>{G.close(),e.onStartFlow?.(i);}}),Z="root",B=$e(u,c,{title:d().settingsTitle,side:"right",actionLabel:null,backLabel:d().back,closeLabel:d().closeSheet,onBack:()=>{if(Z==="language"){Z="root",Te();return}B.close();},onSelect:i=>{if(Z==="language"){B.close(),Z="root",e.onSelectLocale?.(i);return}if(i==="language"){Z="language",Te();return}i==="dock"&&(B.close(),e.onRequestClose(),e.bar.dock?.());}}),Vn=()=>{if(!e.onSelectLocale)return [];let i=w()?.locales??[];return i.length>=2?i:[]},Te=()=>{let i=d(),p=Vn();if(Z==="language"){B.setTitle(i.language),B.setItems(p.map(b=>({id:b.code,title:b.label,active:b.code===w()?.activeLocale,icon:_=>te(_,$n,16)})));return}B.setTitle(i.settingsTitle);let f=p.find(b=>b.code===w()?.activeLocale);B.setItems([...p.length?[{id:"language",title:i.language,subtitle:f?.label??null,icon:b=>te(b,$n,16)}]:[],{id:"dock",title:i.dockChat,subtitle:i.dockChatHint,icon:b=>te(b,Ro,16)}]);},xt=()=>{let i=d();O.setTitle(i.historyTitle),O.setTexts({emptyText:i.historyEmpty,actionLabel:i.newChat}),O.setItems(lt(We,i.imageConversation,e.getConversationId?.())),O.open(),Wn();};async function Wn(){let i=e.getSessionToken?.()??"",p=e.getVisitorId?.()??"";if(!i||!p)return;let f=await En({apiBase:e.apiBase,sessionToken:i,visitorId:p});f.ok&&(We=f.conversations,O.isOpen()&&O.setItems(lt(We,d().imageConversation,e.getConversationId?.())));}x.addEventListener("click",xt),A.addEventListener("click",()=>{let i=d();G.setTitle(i.flowsTitle),G.setTexts({emptyText:i.flowsEmpty}),G.open();});let Ct=()=>{Z="root",Te(),B.open();};$.addEventListener("click",Ct);let kt=()=>e.onRequestClose();U.addEventListener("click",kt);let oe=hn(e,()=>d()),ie=null,_e=!1;e.bar.onSubmit(i=>{if(ie){je(i);return}ge(),At(i);}),e.bar.onFiles?.(i=>{ge(),wt(i);});let jn=()=>w()?.allowImageUpload===!0,Gn=i=>{qe(i)&&i.preventDefault();},Yn=i=>{if(!qe(i)||(i.preventDefault(),!jn()))return;let p=Pt(i);p.length>0&&wt(p);};u.addEventListener("dragover",Gn),u.addEventListener("drop",Yn);let me=i=>{ft=i,fe=!1,X();},Se=!1,Ge=null,Ye=()=>{if(Se)return !0;let i=e.getSessionToken?.();return i?(Se=!0,Ge=w()?.audience||null,bn({apiBase:e.apiBase,sessionToken:i,sessionId:e.getSessionId?.()}).then(p=>{if(!p.ok){me([]);return}let f=yn(p.flows);me(p.starterFlows),f.length!==0&&(A.style.setProperty("display","flex"),G.setItems(f.map(b=>({id:b.cvid,title:b.publicName,subtitle:b.summary}))));}).catch(()=>{me([]);}),!0):!1};if(!Ye())try{l?.setTimeout(()=>{!Ye()&&fe&&me([]);},Eo);}catch{}let Et=i=>{if(i.key==="Escape"){if(i.stopPropagation(),O.isOpen()){O.close();return}if(G.isOpen()){G.close();return}if(B.isOpen()){B.close();return}e.onRequestClose();}};u.addEventListener("keydown",Et);let Tt=()=>{u.hasAttribute("data-open")&&Ue(u,e),oe.reposition();};l?.addEventListener("resize",Tt);let Le=null;return {open:ge,close:_t,reposition(){u.hasAttribute("data-open")&&Ue(u,e),oe.reposition();},refreshChrome(){let i=w()?.audience||null;Se&&i!==null&&Ge!==null&&i!==Ge&&M.isEmpty()&&(Se=!1,fe=!0),!Ye()&&fe&&me([]),u.hasAttribute("data-open")&&(Ke(),B.isOpen()&&Te());},destroy(){x.removeEventListener("click",xt),$.removeEventListener("click",Ct),U.removeEventListener("click",kt),u.removeEventListener("keydown",Et),l?.removeEventListener("resize",Tt),Le=null,he(null),oe.destroy(),O.destroy(),G.destroy(),B.destroy(),M.destroy();for(let i of P)Ve(i);P=[],Q.remove(),e.bar.setAttachmentCount(0),u.remove();},promptFill(i){return new Promise(p=>{he(null),e.onRequestClose(),oe.show(i,{onAnswer:f=>je(f)}),e.bar.setAwaitingInput?.(!0),i.kind==="password"?e.bar.setDisabled(!0):(e.bar.setPlaceholder(i.question),e.bar.focusInput()),ie={resolve:p,request:i};})},cancelFill(){he(null);},showFlowFailure(){ge(),M.addMessage("assistant",d().flowFailed),X();}}}catch{return null}}var Po={contract:4,mount:Fo};if(typeof window<"u")try{window[St]=Po;}catch{}
1292
1292
  exports.ARCY_HOME_URL=Co;exports.BODY_CLASS=ne;exports.CATALOG_RETRY_MS=Eo;exports.CHAT_CSS=To;exports.CHIPS_CLASS=ut;exports.CHIP_CLASS=J;exports.HEADER_BUTTON_CLASS=ze;exports.HEADER_CLASS=dt;exports.HEADER_ICON_CLASS=Nn;exports.HEADER_NAME_CLASS=On;exports.MAIN_CLASS=Bn;exports.MARK_CLASS=ke;exports.MARK_LINK_CLASS=Ae;exports.PANEL_CLASS=de;exports.POLICY_CLASS=Oi;exports.STARTER_CLASS=pe;exports.STARTER_ROW_CLASS=pt;exports.STRIP_CLASS=Dn;exports.WELCOME_CLASS=re;exports.mount=Fo;exports.resolveImageUrl=at;return exports;})({});
@@ -0,0 +1,3 @@
1
+ (function(){'use strict';/* arcy.js — https://arcyai.com */
2
+ function I(t){if(t.parentElement!==null)return t.parentElement;let e=t.parentNode;return e!==null&&"host"in e?e.host:null}function nt(t,e){let n=e;for(;n!==null;){if(n===t)return true;n=I(n);}return false}var rt=100;function b(t,e=0){let n=[],r=t.querySelectorAll("*");for(let o=0;o<r.length;o+=1){let i=r[o];n.push(i),i.shadowRoot!==null&&e<rt&&n.push(...b(i.shadowRoot,e+1));}return n}function H(t,e,n=0){let r=Array.from(t.querySelectorAll(e)),o=t.querySelectorAll("*");for(let i=0;i<o.length;i+=1){let s=o[i];s.shadowRoot!==null&&n<rt&&r.push(...H(s.shadowRoot,e,n+1));}return r}var ot=[/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,/\b\d{3}-\d{2}-\d{4}\b/g,/\b\d(?:[ -]?\d){12,18}\b/g],x="[masked]";function W(t){return ot.some(e=>(e.lastIndex=0,e.test(t)))}var V=4096,Ct=100,At=64;function k(t){if(!t)return;let e=t.slice(0,V);if(t.length>V){let r=e.search(/\s\S*$/);e=r===-1?e.slice(0,V-Ct):e.slice(0,r);}let n=e.replace(/\s+/g," ").trim();if(n){for(let r of ot)n=n.replace(r,x);return n.slice(0,80)}}function it(t){return !(t.length===0||t.length>64||t.includes(":")||t.startsWith("radix-")||/^\d+$/.test(t)||/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t))}var Lt=new Set(["button","input","select","textarea","label","summary"]),Mt=new Set(["button","link","menuitem","tab","option"]);function R(t){let e=t.tagName.toLowerCase();if(Lt.has(e)||e==="a"&&t.hasAttribute("href"))return true;let n=t.getAttribute("role");if(n!==null&&Mt.has(n))return true;let r=t.getAttribute("contenteditable");return r===""||r==="true"}var Nt=["data-testid","data-test","data-cy","id","name","aria-label"],Pt=["data-testid","data-test","data-cy"],Ot=64;function Dt(t){for(let e of Pt){let n=t.getAttribute(e);if(n===null)continue;let r=n.trim();if(!(r===""||r.length>Ot)&&!W(r))return r}}var Ht=new Set(["navigation","main","banner","contentinfo","search","form","region","dialog"]);function Vt(t){let e=I(t);for(;e!==null;){let n=e.tagName.toLowerCase();if(n==="body"||n==="html")return;for(let o of Nt){let i=e.getAttribute(o);if(i===null||o==="id"&&!it(i))continue;let s=k(i);if(s!==void 0)return {tag:n,attr:o,value:s}}let r=e.getAttribute("role");if(r!==null&&Ht.has(r))return {tag:n,attr:"role",value:r};e=I(e);}}function Wt(t){let e=0,n=t.previousElementSibling;for(;n!==null;)n.tagName===t.tagName&&(e+=1),n=n.previousElementSibling;return e}function C(t){let e={tag:t.tagName.toLowerCase(),siblingIndex:Wt(t)},n=k(t.textContent);n!==void 0&&(e.text=n);let r=k(t.getAttribute("aria-label"));r!==void 0&&(e.ariaLabel=r);let o=k(t.getAttribute("placeholder"));o!==void 0&&(e.placeholder=o);let i=t.getAttribute("id");i!==null&&it(i)&&!W(i)&&(e.id=i);let s=t.getAttribute("role");if(s!==null){let u=s.trim();u!==""&&u.length<=At&&!W(u)&&(e.role=u);}let l=Dt(t);l!==void 0&&(e.testId=l);let a=Vt(t);return a!==void 0&&(e.ancestorTag=a.tag,e.ancestorAttr=a.attr,e.ancestorValue=a.value),e}function Kt(t){return t.getClientRects().length>0}var $t=50,Bt=40,Ut=10,jt=15,Gt=15,Xt=10,Jt=10,Yt=10,zt=5,qt=5,Zt=.6,Qt=.7,te={1:.3,2:.45,3:.6,4:.75,5:.9};function A(t){return t.split(x).join(" ").replace(/\s+/g," ").trim()}function ee(t,e){if(e===void 0)return 0;let n=A(t),r=A(e);return n===""||r===""?0:r===n?1:r.includes(n)||n.includes(r)?Zt:0}function T(t,e){return e===t?1:0}function K(t){return t.includes(x)&&A(t)===""}function ne(t,e,n){let r=0,o=0,i=(s,l)=>{r+=s,o+=s*l;};if(t.testId!==void 0&&i($t,T(t.testId,e.testId)),t.text!==void 0&&A(t.text)!==""&&i(n?Ut:Bt,ee(t.text,e.text)),t.ariaLabel!==void 0&&!K(t.ariaLabel)&&i(jt,T(t.ariaLabel,e.ariaLabel)),t.placeholder!==void 0&&!K(t.placeholder)&&i(Jt,T(t.placeholder,e.placeholder)),t.id!==void 0&&i(Gt,T(t.id,e.id)),t.role!==void 0&&i(zt,T(t.role,e.role)),i(Xt,e.tag===t.tag?1:0),i(qt,e.siblingIndex===t.siblingIndex?1:0),t.ancestorAttr!==void 0&&t.ancestorValue!==void 0&&!K(t.ancestorValue)){let s=0;e.ancestorAttr===t.ancestorAttr&&e.ancestorValue===t.ancestorValue&&(s=e.ancestorTag===t.ancestorTag?1:Qt),i(Yt,s);}return r===0?0:o/r}function re(t,e){if(t.selector===null)return null;try{return H(e,t.selector)}catch{return null}}function oe(t,e){let n=t.core.tag,r=[];for(let o of b(e))(o.tagName.toLowerCase()===n||R(o))&&r.push(o);return r}function st(t,e){if(e.length===0)return {status:"not_found",reason:"no_candidates",matchCount:0};let n=te[t.precision],r=false,o=[];for(let s of e){if(!Kt(s))continue;r=true;let l=ne(t.core,C(s),t.dynamicText);l>=n&&o.push({element:s,score:l});}if(o=o.filter((s,l)=>{let a=o[l+1];return a===void 0?true:!(nt(s.element,a.element)&&s.score<=a.score)}),o.length===0)return {status:"not_found",reason:r?"below_threshold":"not_visible",matchCount:0};let i=t.ordinal>=1?o[t.ordinal-1]:void 0;return i===void 0?{status:"not_found",reason:"ordinal_out_of_range",matchCount:o.length}:{status:"matched",element:i.element,score:i.score,matchCount:o.length}}function g(t,e){try{let n=re(t,e);if(n!==null&&n.length>0){let r=st(t,n);if(r.status==="matched"||r.reason==="ordinal_out_of_range")return r}return st(t,oe(t,e))}catch{return {status:"not_found",reason:"error",matchCount:0}}}var ie=40;function lt(t=document){try{let e=b(t),n=[];for(let r of e){if(n.length>=ie)break;R(r)&&n.push(C(r));}return n}catch{return []}}var $={getItem:()=>null,setItem:()=>{},removeItem:()=>{}};function y(t){return t?{getItem(e){try{return t.getItem(e)}catch{return null}},setItem(e,n){try{t.setItem(e,n);}catch{}},removeItem(e){try{t.removeItem(e);}catch{}}}:$}function at(){try{let t=globalThis.localStorage;return y(t)}catch{return $}}function ut(){try{let t=globalThis.sessionStorage;return y(t)}catch{return $}}function L(t,e){let n=t.getItem(e);if(!n)return null;try{let r=JSON.parse(n);return !r||typeof r!="object"||Array.isArray(r)?null:r}catch{return null}}function M(t,e,n){try{t.setItem(e,JSON.stringify(n));}catch{}}var se=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function B(t){let e=typeof globalThis<"u"?globalThis.crypto:void 0;if(e&&typeof e.randomUUID=="function")try{let o=e.randomUUID();if(se.test(o))return o}catch{}let n=new Uint8Array(16);if(e&&typeof e.getRandomValues=="function")e.getRandomValues(n);else for(let o=0;o<n.length;o++)n[o]=Math.floor(Math.random()*256);n[6]=(n[6]??0)&15|64,n[8]=(n[8]??0)&63|128;let r="";for(let o=0;o<n.length;o++)r+=(n[o]??0).toString(16).padStart(2,"0");return `${r.slice(0,8)}-${r.slice(8,12)}-${r.slice(12,16)}-${r.slice(16,20)}-${r.slice(20)}`}var le=3,ae=["attribute","current_page","element","text_input","user_fills_input","current_time","user_idle","visitor","always_true","group"];function v(t){if(!t||typeof t!="object")return false;let e=t;return e.v===1&&!!e.core&&typeof e.core=="object"&&typeof e.core.tag=="string"&&(e.selector===null||typeof e.selector=="string")&&typeof e.ordinal=="number"&&typeof e.precision=="number"}function pt(t,e){if(e>le||!t||typeof t!="object")return null;let n=t,r=n.type;if(typeof r!="string"||!ae.includes(r))return null;switch(r){case "attribute":return typeof n.codeName!="string"||typeof n.operator!="string"?null:{type:"attribute",codeName:n.codeName,operator:n.operator,value:n.value};case "current_page":return !Array.isArray(n.matches)||!Array.isArray(n.doesNotMatch)?null:{type:"current_page",matches:n.matches.filter(o=>typeof o=="string"),doesNotMatch:n.doesNotMatch.filter(o=>typeof o=="string")};case "element":return !v(n.target)||typeof n.state!="string"?null:{type:"element",target:n.target,state:n.state};case "text_input":return !v(n.target)||typeof n.operator!="string"||typeof n.value!="string"?null:{type:"text_input",target:n.target,operator:n.operator,value:n.value};case "user_fills_input":return v(n.target)?{type:"user_fills_input",target:n.target}:null;case "current_time":{let o=n.from,i=n.to;return o!==null&&typeof o!="string"||i!==null&&typeof i!="string"?null:{type:"current_time",from:o??null,to:i??null}}case "user_idle":{let o=n.seconds;return typeof o!="number"||!Number.isFinite(o)||o<1||o>600?null:{type:"user_idle",seconds:o}}case "visitor":return n.state!=="first_visit"&&n.state!=="returning"?null:{type:"visitor",state:n.state};case "always_true":return {type:"always_true"};case "group":{if(!Array.isArray(n.children)||n.operator!=="and"&&n.operator!=="or")return null;let o=[];for(let i of n.children){let s=pt(i,e+1);s&&o.push(s);}return {type:"group",operator:n.operator,children:o}}default:return null}}function mt(t){if(!t||typeof t!="object")return null;let e=t;if(e.v!==1)return null;let n=pt(e.node,0);return n?{v:1,node:n}:null}function ct(t){let e=/^(\d{2}):(\d{2})$/.exec(t);if(!e)return null;let n=Number(e[1]),r=Number(e[2]);return n>23||r>59?null:n*60+r}function ue(t,e){if(t.from===null&&t.to===null)return true;let n=e.getHours()*60+e.getMinutes(),r=t.from!==null?ct(t.from):null,o=t.to!==null?ct(t.to):null;return t.from!==null&&r===null||t.to!==null&&o===null?false:r!==null&&o===null?n>=r:r===null&&o!==null?n<=o:r!==null&&o!==null?r<=o?n>=r&&n<=o:n>=r||n<=o:true}function U(t,e){let n=t.split("*").map(r=>r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*");try{return new RegExp(`^${n}$`).test(e)}catch{return false}}function ce(t,e){return t.doesNotMatch.some(n=>U(n,e))?false:t.matches.length===0?true:t.matches.some(n=>U(n,e))}function ht(t,e,n){if(e===void 0)return false;switch(t){case "is":return e===n;case "is_not":return e!==n;case "contains":return e.includes(n);case "does_not_contain":return !e.includes(n);case "starts_with":return e.startsWith(n);case "ends_with":return e.endsWith(n);case "is_empty":return e==="";case "is_not_empty":return e!=="";case "greater_than":case "less_than":{let r=Number(e),o=Number(n);return e.trim()===""||!Number.isFinite(r)||!Number.isFinite(o)?false:t==="greater_than"?r>o:r<o}case "matches_pattern":return U(n,e);default:return false}}function dt(t,e){try{if(t.getClientRects().length===0)return !1}catch{return false}try{let n=e.defaultView?.getComputedStyle(t);if(n&&n.visibility==="hidden")return !1}catch{}return true}function ft(t,e){try{let n=e.activeElement;for(;n;){if(n===t||t.contains(n))return !0;n=n.shadowRoot?.activeElement??null;}}catch{}return false}function de(t,e){let n=g(t.target,e.doc);switch(t.state){case "is_present":return n.status==="matched";case "is_not_present":return n.status==="not_found";case "is_disabled":case "is_not_disabled":{if(n.status!=="matched")return false;let r="disabled"in n.element&&n.element.disabled===true;return t.state==="is_disabled"?r:!r}case "is_clicked":return e.wasClicked(t.target);case "is_not_clicked":return !e.wasClicked(t.target);case "is_visible":return n.status==="matched"&&dt(n.element,e.doc);case "is_not_visible":return n.status!=="matched"||!dt(n.element,e.doc);case "is_checked":case "is_not_checked":{if(n.status!=="matched")return false;let r="checked"in n.element&&n.element.checked===true;return t.state==="is_checked"?r:!r}case "is_focused":return n.status==="matched"&&ft(n.element,e.doc);case "is_not_focused":return n.status!=="matched"||!ft(n.element,e.doc);default:return false}}function fe(t,e){let n=e.getTrait?.(t.codeName);switch(t.operator){case "has_any_value":return n!=null&&n!=="";case "is_empty":return n==null||n==="";}if(n===void 0)return false;let r=String(n),o=t.value===void 0?"":String(t.value);return ht(t.operator,r,o)}function N(t,e){switch(t.type){case "always_true":return true;case "current_time":return ue(t,e.now());case "current_page":return ce(t,e.href());case "element":return de(t,e);case "attribute":return fe(t,e);case "text_input":{let n=e.readInputValue(t.target);return ht(t.operator,n,t.value)}case "user_fills_input":{let n=e.readInputValue(t.target),r=e.initialInputValue(t.target);return n!==void 0&&n!==""&&n!==r}case "user_idle":{let n=e.idleSeconds?.();return n!==void 0&&n>=t.seconds}case "visitor":{let n=e.isFirstVisit?.();return n===void 0?false:t.state==="first_visit"?n:!n}case "group":return t.children.length===0?false:t.operator==="and"?t.children.every(n=>N(n,e)):t.children.some(n=>N(n,e));default:return false}}function j(t){return t.type==="current_time"||t.type==="user_idle"?true:t.type==="group"?t.children.some(j):false}function G(t){return t.type==="user_idle"?true:t.type==="group"?t.children.some(G):false}var pe="https://api.arcyai.com";var me="/api/v1/sdk/flows";function he(t){return t!==void 0?t:typeof fetch<"u"?fetch.bind(globalThis):null}function ge(t,e,n,r){return new Promise(o=>{let i=false,s=l=>{i||(i=true,o(l));};t.then(s,()=>s(r));try{n(()=>s(r),e);}catch{}})}function we(t){return !t||typeof t!="object"||Array.isArray(t)?null:P(t.flow)}function P(t){if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t;return typeof e.cvid!="string"||!Array.isArray(e.steps)?null:t}function ye(t){return {"Content-Type":"application/json",Authorization:`Bearer ${t}`}}async function gt(t,e){let{apiBase:n=pe,sessionToken:r,sessionId:o,setTimeoutImpl:i=(u,p)=>setTimeout(u,p),timeoutMs:s=8e3}=e,l=he(e.fetchImpl);if(!l)return {ok:false,reason:"unusable"};let a=(async()=>{let u;try{u=await l(`${n}${me}/${encodeURIComponent(t)}/run`,{method:"POST",headers:ye(r),body:JSON.stringify(o?{sessionId:o}:{}),credentials:"omit"});}catch{return {ok:false,reason:"network"}}if(u.status===404)return {ok:false,reason:"not_found"};if(!u.ok)return {ok:false,reason:"rejected"};let p;try{p=await u.json();}catch{return {ok:false,reason:"unusable"}}let f=we(p);return f?{ok:true,flow:f}:{ok:false,reason:"unusable"}})();return ge(a,s,i,{ok:false,reason:"network"})}var ve="arcy.flow.";function Se(t){return typeof t.flowId=="string"&&t.flowId.length>0&&typeof t.currentStepCvid=="string"&&t.currentStepCvid.length>0&&typeof t.flowSessionId=="string"&&t.flowSessionId.length>0&&typeof t.startedAt=="number"}function wt(t,{store:e=at()}={}){let n=y(e),r=ve+t;return {read(){let o=L(n,r);return !o||!Se(o)?null:{flowId:o.flowId,currentStepCvid:o.currentStepCvid,flowSessionId:o.flowSessionId,startedAt:o.startedAt}},save(o){M(n,r,o);},clear(){n.removeItem(r);}}}var be="arcy.preview.";function Te(t){return typeof t.flowId=="string"&&t.flowId.length>0&&typeof t.currentStepCvid=="string"&&t.currentStepCvid.length>0&&typeof t.flowSessionId=="string"&&t.flowSessionId.length>0&&typeof t.startedAt=="number"&&t.flow!==void 0&&t.flow!==null}function X(t,{store:e=ut()}={}){let n=y(e),r=be+t;return {read(){let o=L(n,r);return !o||!Te(o)?null:o},save(o){M(n,r,o);},clear(){n.removeItem(r);}}}var Ee=250,_e=15e3,Fe=1e3,Ie=["pointerdown","pointermove","keydown","wheel","scroll","touchstart"],J=250,ke=3e3,xe=250,Y=()=>{},Re=()=>Promise.resolve({status:"wait"});function z(t,e){return t.steps.findIndex(n=>n.cvid===e)}function vt(t){return t?t.type==="element"?[t.target]:t.type==="group"?t.children.flatMap(e=>vt(e)):[]:[]}var q=class{constructor(e,n,r,o,i,s,l,a,u,p,f,w,h,D,S,d){this.flow=e;this.stepIndex=n;this.startedAt=r;this.flowSessionId=o;this.doc=i;this.win=s;this.runState=l;this.executor=a;this.getTrait=u;this.isFirstVisit=p;this.track=f;this.now=w;this.setTimeoutImpl=h;this.clearTimeoutImpl=D;this.setIntervalImpl=S;this.clearIntervalImpl=d;this.stopped=false;this.dwellTimer=null;this.observer=null;this.intervalHandle=null;this.throttleHandle=null;this.lastCheck=0;this.trueSince=new Map;this.clicked=new Set;this.initialValues=new Map;this.clickListener=null;this.lastActivityAt=0;this.activityListeners=[];this.inputPending=false;this.actionPending=false;this.inputListeners=[];this.parsedTriggers=new Map;this.lastStopReason=null;this.onStatus=null;this.onFailure=null;this.onCancelFill=null;}resolveElement(e,n=0){return g(e,this.doc)}waitForElement(e){let n=()=>{let l=g(e,this.doc),a=l.status==="matched"&&l.element.isConnected;return {result:l,found:a}},r=n(),o=Math.max(0,this.flow.waitSeconds*1e3);if(r.found||o===0)return Promise.resolve(r.result);let i=this.stepIndex,s=this.now()+o;return new Promise(l=>{let a=()=>{let u=n();if(u.found||this.stopped||this.stepIndex!==i||this.now()>=s){l(u.result);return}this.setTimeoutImpl(a,J);};this.setTimeoutImpl(a,J);})}conditionContext(){return {doc:this.doc,now:()=>new Date(this.now()),href:()=>this.win.location?.href??"",getTrait:this.getTrait,idleSeconds:()=>Math.max(0,(this.now()-this.lastActivityAt)/1e3),isFirstVisit:this.isFirstVisit,wasClicked:e=>this.clicked.has(e),readInputValue:e=>{let n=g(e,this.doc);if(n.status!=="matched")return;let r=n.element;return typeof r.value=="string"?r.value:void 0},initialInputValue:e=>{if(!this.initialValues.has(e)){let n=g(e,this.doc),r=n.status==="matched"?n.element:null;this.initialValues.set(e,r&&typeof r.value=="string"?r.value:void 0);}return this.initialValues.get(e)}}}currentStep(){return this.flow.steps[this.stepIndex]}persist(){let e=this.currentStep();e&&this.runState.save({flowId:this.flow.cvid,currentStepCvid:e.cvid,flowSessionId:this.flowSessionId,startedAt:this.startedAt});}teardownWatch(){if(this.observer?.disconnect(),this.observer=null,this.intervalHandle!==null&&(this.clearIntervalImpl(this.intervalHandle),this.intervalHandle=null),this.throttleHandle!==null&&(this.clearTimeoutImpl(this.throttleHandle),this.throttleHandle=null),this.dwellTimer!==null&&(this.clearTimeoutImpl(this.dwellTimer),this.dwellTimer=null),this.clickListener){try{this.doc.removeEventListener("click",this.clickListener,!0);}catch{}this.clickListener=null;}for(let[e,n]of this.inputListeners)try{this.doc.removeEventListener(e,n,!0);}catch{}this.inputListeners=[];for(let[e,n]of this.activityListeners)try{this.doc.removeEventListener(e,n,!0);}catch{}this.activityListeners=[],this.inputPending=false,this.actionPending=false,this.trueSince.clear(),this.clicked.clear(),this.initialValues.clear();}jumpTo(e){let n=z(this.flow,e);if(n===-1){this.finish("error",{reason:"step_not_found"});return}this.stopStep(),this.stepIndex=n,this.persist(),this.enterStep();}emitStatus(e){try{this.onStatus?.(e);}catch{}}dismiss(){this.stopped||this.finish("dismissed");}emit(e,n){try{this.track(e,{flowId:this.flow.cvid,flowSessionId:this.flowSessionId,stepCvid:this.currentStep()?.cvid},n);}catch{}}finish(e,n){this.lastStopReason=e;let r=e==="completed"?"flow_completed":e==="dismissed"?"flow_abandoned":"flow_error";this.emit(r,n);try{this.onCancelFill?.();}catch{}if(this.stopStep(),this.stopped=true,this.runState.clear(),e==="completed"&&this.emitStatus({name:this.flow.publicName??this.flow.name,step:this.flow.steps.length,total:this.flow.steps.length,phase:"done"}),this.emitStatus(null),e==="error")try{this.onFailure?.();}catch{}}stopStep(){this.teardownWatch();}fireTrigger(e){if(e.actionType==="dismiss_flow"){this.finish("dismissed");return}e.actionType==="go_to_step"&&e.targetStepCvid&&this.jumpTo(e.targetStepCvid);}parsedTrigger(e){return this.parsedTriggers.has(e.cvid)||this.parsedTriggers.set(e.cvid,mt(e.condition)),this.parsedTriggers.get(e.cvid)??null}checkTriggers(e,n){if(this.stopped)return;let r=!this.inputPending&&!this.actionPending,o=this.now();for(let i of [...e.triggers].sort((s,l)=>s.position-l.position)){let s=this.parsedTrigger(i);if(!s)continue;let l=N(s.node,n),a=i.cvid;if(!l){this.trueSince.delete(a);continue}let u=this.trueSince.get(a)??o;this.trueSince.has(a)||this.trueSince.set(a,u);let p=(i.waitSeconds??0)*1e3;if(o-u>=p&&r){this.fireTrigger(i);return}}}scheduleCheck(e){if(this.stopped||this.throttleHandle!==null)return;let n=Math.max(0,Ee-(this.now()-this.lastCheck));this.throttleHandle=this.setTimeoutImpl(()=>{this.throttleHandle=null,this.lastCheck=this.now(),this.checkTriggers(e,this.conditionContext());},n);}startWatch(e){let n=e.triggers.some(o=>{let i=this.parsedTrigger(o);return i?j(i.node):false}),r=e.triggers.some(o=>{let i=this.parsedTrigger(o);return i?G(i.node):false});if(this.lastActivityAt=this.now(),typeof MutationObserver=="function")try{this.observer=new MutationObserver(()=>this.scheduleCheck(e)),this.observer.observe(this.doc.documentElement,{childList:!0,subtree:!0,attributes:!0,characterData:!0});}catch{}if(n)try{this.intervalHandle=this.setIntervalImpl(()=>this.scheduleCheck(e),r?Fe:_e);}catch{}if(r)for(let o of Ie){let i=()=>{this.lastActivityAt=this.now();};try{this.doc.addEventListener(o,i,{capture:!0,passive:!0}),this.activityListeners.push([o,i]);}catch{}}this.clickListener=o=>{for(let i of e.triggers){let s=this.parsedTrigger(i),l=vt(s?.node);for(let a of l){let u=g(a,this.doc);u.status==="matched"&&o.target instanceof Node&&(u.element===o.target||u.element.contains(o.target))&&this.clicked.add(a);}}this.scheduleCheck(e);};try{this.doc.addEventListener("click",this.clickListener,!0);}catch{this.clickListener=null;}for(let o of ["input","change","focusin","focusout"]){let i=()=>this.scheduleCheck(e);try{this.doc.addEventListener(o,i,!0),this.inputListeners.push([o,i]);}catch{}}this.checkTriggers(e,this.conditionContext());}async runExecutor(e,n){try{let r=await this.executor(e,{doc:this.doc,win:this.win,resolveElement:(o,i)=>this.resolveElement(o,i),waitForElement:o=>this.waitForElement(o),setInputPending:o=>{this.inputPending=o;}});if(this.stopped||this.stepIndex!==n)return;if(this.actionPending=!1,r.status==="advance"){if(this.emit("flow_step_completed"),e.isCompletion){this.finish("completed");return}let o=this.stepIndex+1;if(o>=this.flow.steps.length){this.finish("completed");return}this.stopStep(),this.stepIndex=o,this.persist(),this.enterStep();return}if(r.status==="navigated"){if(this.emit("flow_step_completed"),r.navigateTarget==="new_tab"){this.finish("completed");return}if(this.stopStep(),e.isCompletion){this.finish("completed");return}let o=this.stepIndex+1;if(o>=this.flow.steps.length){this.finish("completed");return}this.stepIndex=o,this.persist();return}if(r.status==="error"){this.finish("error",r.reason==="element_not_found"?{reason:r.reason,liveManifest:lt(this.doc)}:{reason:r.reason});return}this.scheduleCheck(e);}catch{this.actionPending=false;}}enterStep(){let e=this.currentStep(),n=this.stepIndex;if(!e||this.stopped){this.finish(e?"completed":"error",e?void 0:{reason:"missing_step"});return}this.persist(),this.emit("flow_step_entered"),this.emitStatus({name:this.flow.publicName??this.flow.name,step:this.stepIndex+1,total:this.flow.steps.length,phase:"running"});let r=()=>{this.stopped||(this.actionPending=true,this.startWatch(e),this.runExecutor(e,n));};this.waitForPageReady(r);}waitForPageReady(e){let n=this.now()+ke,r=()=>{this.dwellTimer=this.setTimeoutImpl(()=>{this.dwellTimer=null,e();},xe);},o=()=>{if(!this.stopped){if(this.doc.readyState!=="loading"||this.now()>=n){r();return}this.dwellTimer=this.setTimeoutImpl(()=>{this.dwellTimer=null,o();},J);}};o();}begin(){this.enterStep();}stop(){if(!this.stopped){try{this.onCancelFill?.();}catch{}this.stopStep(),this.stopped=true;}}};function St(t){let{context:e,executor:n=Re,track:r=e.track??Y,now:o=()=>Date.now(),setTimeoutImpl:i=(d,c)=>setTimeout(d,c),clearTimeoutImpl:s=d=>clearTimeout(d),setIntervalImpl:l=(d,c)=>setInterval(d,c),clearIntervalImpl:a=d=>clearInterval(d)}=t,u=e.doc??document,p=e.win??window,f=wt(e.token),w={apiBase:e.apiBase,sessionToken:e.sessionToken,sessionId:e.sessionId},h=null;async function D(d){let c=await gt(d,w);return c.ok?c.flow:null}function S(d,c,m,F,et={}){h?.stop(),h=new q(d,c,m,F,u,p,et.runState??f,n,e.getTrait,e.isFirstVisit,et.track??r,o,i,s,l,a),h.onStatus=Rt=>e.onStatus?.(Rt),h.onFailure=()=>e.onFailure?.(),h.onCancelFill=()=>e.cancelFill?.(),h.begin();}return {async start(d){let c=await D(d);if(!c||c.steps.length===0)return;let m=B();try{r("flow_started",{flowId:c.cvid,flowSessionId:m});}catch{}S(c,0,o(),m);},async resume(){let d=f.read();if(!d)return false;let c=await D(d.flowId);if(!c||c.steps.length===0)return f.clear(),false;let m=z(c,d.currentStepCvid);return m===-1?(f.clear(),false):(S(c,m,d.startedAt,d.flowSessionId),true)},stop(){h?.dismiss(),h=null;},async startPreview(d){let c=P(d);if(!c||c.steps.length===0)return;let m=X(e.token);S(c,0,o(),B(),{runState:yt(m,d),track:Y});},async resumePreview(){let d=X(e.token),c=d.read();if(!c)return false;let m=P(c.flow);if(!m||m.steps.length===0)return d.clear(),false;let F=z(m,c.currentStepCvid);return F===-1?(d.clear(),false):(S(m,F,c.startedAt,c.flowSessionId,{runState:yt(d,c.flow),track:Y}),true)},destroy(){h?.stop(),h=null;}}}function yt(t,e){return {read:()=>null,save:n=>t.save({...n,flow:e}),clear:()=>t.clear()}}var Ce=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Ae=/^\d{4}-\d{2}-\d{2}$/,Le=/^([01]\d|2[0-3]):[0-5]\d(:[0-5]\d)?$/,Me=/^\d{4}-\d{2}-\d{2}T([01]\d|2[0-3]):[0-5]\d(:[0-5]\d)?$/,Ne=/^\d{4}-\d{2}$/,Pe=/^\d{4}-W\d{2}$/,Oe=/^\+?[\d\s().-]{3,}$/;function De(t){let e=Date.parse(t);return Number.isFinite(e)}function He(t,e){if(e.min!==null){let n=Number(e.min);if(Number.isFinite(n)&&t<n)return "number_too_small"}if(e.max!==null){let n=Number(e.max);if(Number.isFinite(n)&&t>n)return "number_too_large"}return null}function Z(t){return /^\d:/.test(t)?`0${t}`:t}function E(t,e){return e.min!==null&&e.min.length>0&&t<e.min?"date_too_early":e.max!==null&&e.max.length>0&&t>e.max?"date_too_late":null}function bt(t,e){let n=e.kind==="password"?t:t.trim();if(n.length===0)return e.required?"required":null;if(e.maxLength!==null&&n.length>e.maxLength)return "too_long";switch(e.kind){case "number":case "range":{let r=Number(n);return Number.isFinite(r)?He(r,e):"invalid_number"}case "email":return Ce.test(n)?null:"invalid_email";case "url":try{let r=new URL(n);return r.protocol==="http:"||r.protocol==="https:"?null:"invalid_url"}catch{return "invalid_url"}case "tel":return Oe.test(n)?null:"invalid";case "date":return !Ae.test(n)||!De(n)?"invalid_date":E(n,e);case "datetime":return Me.test(n)?E(n,e):"invalid_date";case "month":return Ne.test(n)?E(n,e):"invalid_date";case "week":return Pe.test(n)?E(n,e):"invalid_date";case "time":return Le.test(n)?E(Z(n),{...e,min:e.min!==null?Z(e.min):null,max:e.max!==null?Z(e.max):null}):"invalid_time";case "select":case "radio":return (e.options??[]).some(o=>o.value===n)?null:"invalid_option";case "checkbox":return n==="true"||n==="false"?null:"invalid_option";default:{if(e.pattern)try{if(!new RegExp(`^(?:${e.pattern})$`).test(n))return "invalid"}catch{}return null}}}function Tt(t,e){if(!e||e.length===0)return t;let n=t.trim();if(e.some(i=>i.value===n))return n;let r=n.toLowerCase(),o=e.find(i=>i.label.trim().toLowerCase()===r);return o?o.value:t}var Q=24;function Ve(t,e,n){let r=e-Math.max(0,n);if(!(e>0)||r<=0)return 0;if(t.bottom>r){let o=t.bottom-r+Q,i=Math.max(0,t.top-Q);return Math.min(o,i)}return t.top<0?t.top-Q:0}function Ft(t,e,n){try{let r=n.getBottomOcclusion?.()??0,o=t.getBoundingClientRect(),i=e.doc.documentElement?.clientHeight||e.win.innerHeight||0,s=Ve(o,i,r);if(s===0)return;e.win.scrollBy({top:s,behavior:"smooth"});}catch{}}function tt(t,e){let r=e.defaultView?.PointerEvent,o=(()=>{try{return t.getBoundingClientRect()}catch{return null}})(),i={bubbles:true,cancelable:true,clientX:o?o.left+o.width/2:0,clientY:o?o.top+o.height/2:0},s=a=>{try{typeof r=="function"&&t.dispatchEvent(new r(a,{...i,pointerType:"mouse"}));}catch{}},l=a=>{try{t.dispatchEvent(new MouseEvent(a,i));}catch{}};s("pointerover"),s("pointerenter"),s("pointerdown"),l("mousedown");try{typeof t.focus=="function"&&t.focus();}catch{}s("pointerup"),l("mouseup"),l("click");}function We(t,e){let n=t instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:t instanceof HTMLInputElement?HTMLInputElement.prototype:t instanceof HTMLSelectElement?HTMLSelectElement.prototype:null;if(!n)return false;let o=Object.getOwnPropertyDescriptor(n,"value")?.set;if(!o)return false;try{return o.call(t,e),!0}catch{return false}}function O(t,e){let n=e.defaultView;try{t.dispatchEvent(new(n?.Event??Event)("input",{bubbles:!0}));}catch{}try{t.dispatchEvent(new(n?.Event??Event)("change",{bubbles:!0}));}catch{}}async function Ke(t,e,n){if(!v(t.target))return {status:"error",reason:"invalid_target"};let r=await e.waitForElement(t.target);if(r.status!=="matched"||!r.element.isConnected)return {status:"error",reason:"element_not_found"};Ft(r.element,e,n);try{tt(r.element,e.doc);}catch{return {status:"error",reason:"dispatch_failed"}}return {status:"advance"}}var $e=["text","number","email","date","url","tel"];function Et(t){return $e.includes(t)?t:null}var Be={text:"text",search:"text",number:"number",email:"email",url:"url",tel:"tel",password:"password",date:"date",time:"time","datetime-local":"datetime",month:"month",week:"week",checkbox:"checkbox",radio:"radio",range:"range"};function _(t,e){try{let n=t.getAttribute(e);return n===null||n===""?null:n}catch{return null}}function Ue(t){let e=[];for(let n=0;n<t.options.length;n+=1){let r=t.options[n];if(!r||r.disabled)continue;let o=(r.label||r.textContent||"").trim();r.value!==""&&e.push({value:r.value,label:o||r.value});}return e}function je(t,e){let n=t.getAttribute("name"),r=t.form??e,o=[];if(n)try{let i=`input[type="radio"][name="${CSS.escape(n)}"]`;r.querySelectorAll(i).forEach(s=>{s instanceof HTMLInputElement&&o.push(s);});}catch{}return o.length===0&&o.push(t),o.map(i=>({value:i.value,label:Ge(i)||i.value}))}function It(t){try{let e=t.labels;if(e&&e.length>0)return (e[0]?.textContent??"").trim()}catch{}try{let e=t.closest("label");if(e)return (e.textContent??"").trim()}catch{}return ""}function Ge(t){return It(t)}function _t(t,e,n){let r="custom",o=null,i=false,s=null,l=null,a=null,u=null,p=null;if(t instanceof HTMLSelectElement)r="select",o=Ue(t),i=t.required||!t.querySelector('option[value=""]');else if(t instanceof HTMLTextAreaElement)r="textarea",i=t.required,t.maxLength>0&&(u=t.maxLength);else if(t instanceof HTMLInputElement){let f=(_(t,"type")??"text").toLowerCase();r=Be[f]??"text",i=t.required,s=_(t,"min"),l=_(t,"max"),a=_(t,"step"),p=_(t,"pattern"),t.maxLength>0&&(u=t.maxLength),r==="radio"&&(o=je(t,n)),r==="checkbox"&&(o=[{value:"true",label:It(t)}]);}return e&&e!=="text"&&(r==="text"||r==="custom"||r==="textarea")&&(r=e),{kind:r,required:i,options:o,min:s,max:l,step:a,maxLength:u,pattern:p}}function Xe(t){if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement||t instanceof HTMLElement&&t.isContentEditable)return t;try{let e=t.querySelector('input:not([type="hidden"]), textarea, select, [contenteditable="true"], [contenteditable=""]');return e instanceof HTMLElement?e:null}catch{return null}}function Je(t,e){let r=e.defaultView?.KeyboardEvent;if(typeof r=="function")for(let o of ["keydown","keyup"])try{t.dispatchEvent(new r(o,{bubbles:!0,cancelable:!0}));}catch{}}function Ye(t,e,n,r){if(n==="checkbox"&&t instanceof HTMLInputElement){let i=e==="true";return t.checked!==i&&tt(t,r),t.checked!==i&&(t.checked=i,O(t,r)),true}if(n==="radio"&&t instanceof HTMLInputElement){let i=t.form??r,s=t.getAttribute("name"),l=null;if(s)try{let p=`input[type="radio"][name="${CSS.escape(s)}"]`;i.querySelectorAll(p).forEach(f=>{f instanceof HTMLInputElement&&f.value===e&&(l=f);});}catch{}let a=l??(t.value===e?t:null);if(!a)return false;tt(a,r);let u=a;return u.checked||(u.checked=true,O(u,r)),true}let o=Xe(t);if(!o)return false;if(o instanceof HTMLElement&&o.isContentEditable){try{o.focus();}catch{}try{o.textContent=e;}catch{return false}return O(o,r),true}try{o.focus();}catch{}return We(o,e)?(Je(o,r),O(o,r),true):false}async function ze(t,e,n){if(!v(t.target))return {status:"error",reason:"invalid_target"};if(!n.promptFill)return {status:"wait"};let r=await e.waitForElement(t.target);if(r.status!=="matched"||!r.element.isConnected)return {status:"error",reason:"element_not_found"};let o=_t(r.element,Et(t.fillInputType),e.doc),i=(t.fillDescription??"").trim()||t.label||"",s=null,l=null,a;for(;;){let f;e.setInputPending(true);try{f=await n.promptFill({...o,question:i,errorCode:s});}catch{return {status:"error",reason:"prompt_failed"}}finally{e.setInputPending(false);}if(f===null)return {status:"error",reason:"fill_cancelled"};let w=o.kind==="select"||o.kind==="radio"?Tt(f,o.options):o.kind==="password"?f:f.trim();if(s=bt(w,{...o,question:i,errorCode:null}),s===null){a=w;break}if(l!==null&&l===w)return {status:"error",reason:"fill_invalid"};l=w;}let u=await e.waitForElement(t.target);if(u.status!=="matched"||!u.element.isConnected)return {status:"error",reason:"element_not_found"};let p=_t(u.element,Et(t.fillInputType),e.doc);return p.kind!==o.kind?{status:"error",reason:"unfillable_target"}:(Ft(u.element,e,n),Ye(u.element,a,p.kind,e.doc)?{status:"advance"}:{status:"error",reason:"unfillable_target"})}function qe(t){if(t.startsWith("/")&&!t.startsWith("//"))return true;try{let e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"}catch{return false}}async function Ze(t,e){if(!t.navigateUrl||!t.navigateTarget)return {status:"error",reason:"invalid_navigate_step"};if(!qe(t.navigateUrl))return {status:"error",reason:"invalid_navigate_step"};try{t.navigateTarget==="new_tab"?e.win.open(t.navigateUrl,"_blank","noopener,noreferrer"):e.win.location.assign(t.navigateUrl);}catch{return {status:"error",reason:"navigate_failed"}}return {status:"navigated",navigateTarget:t.navigateTarget}}function kt(t={}){return async(e,n)=>{try{switch(e.type){case "click":return await Ke(e,n,t);case "fill":return await ze(e,n,t);case "navigate":return await Ze(e,n);default:return {status:"error",reason:"unknown_step_type"}}}catch{return {status:"error",reason:"executor_threw"}}}}var xt="__arcyFlow";function tn(t){try{let e=kt({promptFill:t.promptFill,getBottomOcclusion:t.getBottomOcclusion});return St({context:t,executor:e})}catch{return null}}var en={contract:2,mount:tn};if(typeof window<"u")try{window[xt]=en;}catch{}
3
+ })();
@@ -1,5 +1,5 @@
1
1
  (function(){'use strict';/* arcy.js — https://arcyai.com */
2
- var qr=Object.defineProperty,Jr=Object.defineProperties;var Qr=Object.getOwnPropertyDescriptors;var dn=Object.getOwnPropertySymbols;var Zr=Object.prototype.hasOwnProperty,eo=Object.prototype.propertyIsEnumerable;var fn=(e,t,n)=>t in e?qr(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n,$=(e,t)=>{for(var n in t||(t={}))Zr.call(t,n)&&fn(e,n,t[n]);if(dn)for(var n of dn(t))eo.call(t,n)&&fn(e,n,t[n]);return e},ae=(e,t)=>Jr(e,Qr(t));var H=(e,t,n)=>new Promise((r,s)=>{var l=o=>{try{f(n.next(o));}catch(i){s(i);}},a=o=>{try{f(n.throw(o));}catch(i){s(i);}},f=o=>o.done?r(o.value):Promise.resolve(o.value).then(l,a);f((n=n.apply(e,t)).next());});function w(e){typeof console!="undefined"&&console.warn&&console.warn(`[arcy] ${e}`);}function pn(){let e=new Map;function t(r,s){if(typeof s!="function")return w(`on("${r}") needs a function. Ignoring.`),()=>{};let l=e.get(r);return l||(l=new Set,e.set(r,l)),l.add(s),()=>{l.delete(s);}}function n(r){let s=e.get(r);if(s)for(let l of [...s])try{l();}catch(a){w(`A "${r}" handler threw. ${String(a)}`);}}return {on:t,emit:n}}function kt(e){if(e.parentElement!==null)return e.parentElement;let t=e.parentNode;return t!==null&&"host"in t?t.host:null}var mn=[/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,/\b\d{3}-\d{2}-\d{4}\b/g,/\b\d(?:[ -]?\d){12,18}\b/g],to="[masked]";function Xe(e){return mn.some(t=>(t.lastIndex=0,t.test(e)))}var At=4096,no=100,ro=64;function ot(e){if(!e)return;let t=e.slice(0,At);if(e.length>At){let r=t.search(/\s\S*$/);t=r===-1?t.slice(0,At-no):t.slice(0,r);}let n=t.replace(/\s+/g," ").trim();if(n){for(let r of mn)n=n.replace(r,to);return n.slice(0,80)}}function gn(e){return !(e.length===0||e.length>64||e.includes(":")||e.startsWith("radix-")||/^\d+$/.test(e)||/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e))}var oo=["data-testid","data-test","data-cy","id","name","aria-label"],io=["data-testid","data-test","data-cy"],so=64;function ao(e){for(let t of io){let n=e.getAttribute(t);if(n===null)continue;let r=n.trim();if(!(r===""||r.length>so)&&!Xe(r))return r}}var lo=new Set(["navigation","main","banner","contentinfo","search","form","region","dialog"]);function co(e){let t=kt(e);for(;t!==null;){let n=t.tagName.toLowerCase();if(n==="body"||n==="html")return;for(let s of oo){let l=t.getAttribute(s);if(l===null||s==="id"&&!gn(l))continue;let a=ot(l);if(a!==void 0)return {tag:n,attr:s,value:a}}let r=t.getAttribute("role");if(r!==null&&lo.has(r))return {tag:n,attr:"role",value:r};t=kt(t);}}function uo(e){let t=0,n=e.previousElementSibling;for(;n!==null;)n.tagName===e.tagName&&(t+=1),n=n.previousElementSibling;return t}function hn(e){let t={tag:e.tagName.toLowerCase(),siblingIndex:uo(e)},n=ot(e.textContent);n!==void 0&&(t.text=n);let r=ot(e.getAttribute("aria-label"));r!==void 0&&(t.ariaLabel=r);let s=ot(e.getAttribute("placeholder"));s!==void 0&&(t.placeholder=s);let l=e.getAttribute("id");l!==null&&gn(l)&&!Xe(l)&&(t.id=l);let a=e.getAttribute("role");if(a!==null){let i=a.trim();i!==""&&i.length<=ro&&!Xe(i)&&(t.role=i);}let f=ao(e);f!==void 0&&(t.testId=f);let o=co(e);return o!==void 0&&(t.ancestorTag=o.tag,t.ancestorAttr=o.attr,t.ancestorValue=o.value),t}var yn="arcy.picker.b7e531503cf2.js",bn="arcy.chat.f698fce59921.js",wn="arcy.flow.fef131718e42.js";var fo=/^(?:\d+|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|[0-9a-f]{12,})$/i,po=/^[^@\s/]+@[^@\s/]+\.[^@\s/]+$/;function mo(e){if(e.indexOf("%")===-1)return e;try{return decodeURIComponent(e)}catch(t){return e}}function vn(e){return e.length===0?false:fo.test(e)?true:po.test(mo(e))}function Be(e){let n=e.split("/").map(r=>vn(r)?":id":r).join("/");for(;n.length>1&&n.charAt(n.length-1)==="/";)n=n.slice(0,-1);return n.length===0?"/":n}function go(e){if(e.length===0)return "";let t=[];for(let n of e.split("&")){if(n.length===0)continue;let r=n.indexOf("="),s=r===-1?n:n.slice(0,r);if(s.length===0)continue;let l=vn(s)?":id":s;t.indexOf(l)===-1&&t.push(l);}return t.length===0?"":(t.sort(),`?${t.join("&")}`)}function ho(e,t){var n;try{let r=new URL(e,t!=null?t:void 0);return {path:r.pathname,query:r.search.slice(1)}}catch(r){let s=(n=e.split("#")[0])!=null?n:"";if(!s.startsWith("/"))return null;let l=s.indexOf("?");return l===-1?{path:s,query:""}:{path:s.slice(0,l),query:s.slice(l+1)}}}function je(e,t){if(typeof e!="string"||e.length===0)return null;let n=ho(e,t);if(n===null)return null;let r=Be(n.path);if(!r)return null;if(r.length>=2048)return r.slice(0,2048);let s=go(n.query);return s.length===0||r.length+s.length>2048?r:r+s}function yo(e){try{let t=e.currentScript,n=t==null?void 0:t.nonce;if(typeof n=="string"&&n.length>0)return n;let r=e.getElementsByTagName("script");for(let s=0;s<r.length;s++){let l=r[s].nonce;if(typeof l=="string"&&l.length>0)return l}return null}catch(t){return null}}var bo=typeof document!="undefined"?yo(document):null;function wo(){return bo}function Le(e){let t=wo();if(t)try{e.nonce=t,e.setAttribute("nonce",t);}catch(n){}}var vo="https://docs.arcyai.com/troubleshooting#content-security-policy";function _t(e){try{let{origin:t}=new URL(e);return t&&t!=="null"?t:null}catch(t){return null}}function So(e){var s;let t=_t(e.apiBase),n=e.cdnBase?_t(e.cdnBase):null,r=["This page's Content-Security-Policy is blocking part of the ARCY widget.","Add these to the policy your app sends:",""];return n&&r.push(` script-src ${n}`),t&&(r.push(` connect-src ${t}`),r.push(` font-src ${t}`),r.push(` img-src ${t} blob:`)),r.push(" style-src 'unsafe-inline', or a nonce on the script that loads ARCY"),r.push(""),r.push("To allow none of them, proxy a path on your own domain to the API and pass it as arcy.init(token, { apiBase })."),r.push((s=e.docsUrl)!=null?s:vo),r.join(`
2
+ var qr=Object.defineProperty,Jr=Object.defineProperties;var Qr=Object.getOwnPropertyDescriptors;var dn=Object.getOwnPropertySymbols;var Zr=Object.prototype.hasOwnProperty,eo=Object.prototype.propertyIsEnumerable;var fn=(e,t,n)=>t in e?qr(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n,$=(e,t)=>{for(var n in t||(t={}))Zr.call(t,n)&&fn(e,n,t[n]);if(dn)for(var n of dn(t))eo.call(t,n)&&fn(e,n,t[n]);return e},ae=(e,t)=>Jr(e,Qr(t));var H=(e,t,n)=>new Promise((r,s)=>{var l=o=>{try{f(n.next(o));}catch(i){s(i);}},a=o=>{try{f(n.throw(o));}catch(i){s(i);}},f=o=>o.done?r(o.value):Promise.resolve(o.value).then(l,a);f((n=n.apply(e,t)).next());});function w(e){typeof console!="undefined"&&console.warn&&console.warn(`[arcy] ${e}`);}function pn(){let e=new Map;function t(r,s){if(typeof s!="function")return w(`on("${r}") needs a function. Ignoring.`),()=>{};let l=e.get(r);return l||(l=new Set,e.set(r,l)),l.add(s),()=>{l.delete(s);}}function n(r){let s=e.get(r);if(s)for(let l of [...s])try{l();}catch(a){w(`A "${r}" handler threw. ${String(a)}`);}}return {on:t,emit:n}}function kt(e){if(e.parentElement!==null)return e.parentElement;let t=e.parentNode;return t!==null&&"host"in t?t.host:null}var mn=[/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,/\b\d{3}-\d{2}-\d{4}\b/g,/\b\d(?:[ -]?\d){12,18}\b/g],to="[masked]";function Xe(e){return mn.some(t=>(t.lastIndex=0,t.test(e)))}var At=4096,no=100,ro=64;function ot(e){if(!e)return;let t=e.slice(0,At);if(e.length>At){let r=t.search(/\s\S*$/);t=r===-1?t.slice(0,At-no):t.slice(0,r);}let n=t.replace(/\s+/g," ").trim();if(n){for(let r of mn)n=n.replace(r,to);return n.slice(0,80)}}function gn(e){return !(e.length===0||e.length>64||e.includes(":")||e.startsWith("radix-")||/^\d+$/.test(e)||/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e))}var oo=["data-testid","data-test","data-cy","id","name","aria-label"],io=["data-testid","data-test","data-cy"],so=64;function ao(e){for(let t of io){let n=e.getAttribute(t);if(n===null)continue;let r=n.trim();if(!(r===""||r.length>so)&&!Xe(r))return r}}var lo=new Set(["navigation","main","banner","contentinfo","search","form","region","dialog"]);function co(e){let t=kt(e);for(;t!==null;){let n=t.tagName.toLowerCase();if(n==="body"||n==="html")return;for(let s of oo){let l=t.getAttribute(s);if(l===null||s==="id"&&!gn(l))continue;let a=ot(l);if(a!==void 0)return {tag:n,attr:s,value:a}}let r=t.getAttribute("role");if(r!==null&&lo.has(r))return {tag:n,attr:"role",value:r};t=kt(t);}}function uo(e){let t=0,n=e.previousElementSibling;for(;n!==null;)n.tagName===e.tagName&&(t+=1),n=n.previousElementSibling;return t}function hn(e){let t={tag:e.tagName.toLowerCase(),siblingIndex:uo(e)},n=ot(e.textContent);n!==void 0&&(t.text=n);let r=ot(e.getAttribute("aria-label"));r!==void 0&&(t.ariaLabel=r);let s=ot(e.getAttribute("placeholder"));s!==void 0&&(t.placeholder=s);let l=e.getAttribute("id");l!==null&&gn(l)&&!Xe(l)&&(t.id=l);let a=e.getAttribute("role");if(a!==null){let i=a.trim();i!==""&&i.length<=ro&&!Xe(i)&&(t.role=i);}let f=ao(e);f!==void 0&&(t.testId=f);let o=co(e);return o!==void 0&&(t.ancestorTag=o.tag,t.ancestorAttr=o.attr,t.ancestorValue=o.value),t}var yn="arcy.picker.b7e531503cf2.js",bn="arcy.chat.27fabef680f1.js",wn="arcy.flow.bc28949c2a72.js";var fo=/^(?:\d+|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|[0-9a-f]{12,})$/i,po=/^[^@\s/]+@[^@\s/]+\.[^@\s/]+$/;function mo(e){if(e.indexOf("%")===-1)return e;try{return decodeURIComponent(e)}catch(t){return e}}function vn(e){return e.length===0?false:fo.test(e)?true:po.test(mo(e))}function Be(e){let n=e.split("/").map(r=>vn(r)?":id":r).join("/");for(;n.length>1&&n.charAt(n.length-1)==="/";)n=n.slice(0,-1);return n.length===0?"/":n}function go(e){if(e.length===0)return "";let t=[];for(let n of e.split("&")){if(n.length===0)continue;let r=n.indexOf("="),s=r===-1?n:n.slice(0,r);if(s.length===0)continue;let l=vn(s)?":id":s;t.indexOf(l)===-1&&t.push(l);}return t.length===0?"":(t.sort(),`?${t.join("&")}`)}function ho(e,t){var n;try{let r=new URL(e,t!=null?t:void 0);return {path:r.pathname,query:r.search.slice(1)}}catch(r){let s=(n=e.split("#")[0])!=null?n:"";if(!s.startsWith("/"))return null;let l=s.indexOf("?");return l===-1?{path:s,query:""}:{path:s.slice(0,l),query:s.slice(l+1)}}}function je(e,t){if(typeof e!="string"||e.length===0)return null;let n=ho(e,t);if(n===null)return null;let r=Be(n.path);if(!r)return null;if(r.length>=2048)return r.slice(0,2048);let s=go(n.query);return s.length===0||r.length+s.length>2048?r:r+s}function yo(e){try{let t=e.currentScript,n=t==null?void 0:t.nonce;if(typeof n=="string"&&n.length>0)return n;let r=e.getElementsByTagName("script");for(let s=0;s<r.length;s++){let l=r[s].nonce;if(typeof l=="string"&&l.length>0)return l}return null}catch(t){return null}}var bo=typeof document!="undefined"?yo(document):null;function wo(){return bo}function Le(e){let t=wo();if(t)try{e.nonce=t,e.setAttribute("nonce",t);}catch(n){}}var vo="https://docs.arcyai.com/troubleshooting#content-security-policy";function _t(e){try{let{origin:t}=new URL(e);return t&&t!=="null"?t:null}catch(t){return null}}function So(e){var s;let t=_t(e.apiBase),n=e.cdnBase?_t(e.cdnBase):null,r=["This page's Content-Security-Policy is blocking part of the ARCY widget.","Add these to the policy your app sends:",""];return n&&r.push(` script-src ${n}`),t&&(r.push(` connect-src ${t}`),r.push(` font-src ${t}`),r.push(` img-src ${t} blob:`)),r.push(" style-src 'unsafe-inline', or a nonce on the script that loads ARCY"),r.push(""),r.push("To allow none of them, proxy a path on your own domain to the API and pass it as arcy.init(token, { apiBase })."),r.push((s=e.docsUrl)!=null?s:vo),r.join(`
3
3
  `)}function Sn(e,t){let n=[t.apiBase,t.cdnBase].filter(s=>typeof s=="string"&&s.length>0).map(_t).filter(s=>s!==null),r=()=>{};try{let s=l=>{let a=l.blockedURI;(a==="inline"||n.some(o=>a==null?void 0:a.startsWith(o)))&&(r(),w(So(t)));};e.document.addEventListener("securitypolicyviolation",s),r=()=>{try{e.document.removeEventListener("securitypolicyviolation",s);}catch(l){}};}catch(s){}return ()=>r()}var It="__arcyPicker";var qe=2,En="arcy:design-mode:ready",Tn="arcy:design-mode:pick",xn="arcy:design-mode:exit",kn="arcy:design-mode:screenshot";var _n="arcy-widget",An="data-arcy",Rt="2147483000",Eo=[["position","fixed"],["inset","0"],["z-index",Rt],["pointer-events","none"],["background","transparent"],["border","0"],["box-shadow","none"],["outline","0"]],To=[["margin","0"],["padding","0"]],Cn="data-arcy-style",Je=new Map;function xo(e=_n){let t=Je.get(e);return t!==void 0&&t.host.isConnected}function it(e={}){var s,l,a;if(typeof document=="undefined")return null;let t=(s=e.id)!=null?s:_n,n=e.container;if(xo(t))return w("This ARCY surface is already on this page. Ignoring the second mount."),null;Je.delete(t);let r=(l=n!=null?n:document.body)!=null?l:document.documentElement;if(!r)return w("The page has no <body> to mount into yet. The widget will not render."),null;if(!n){let f=document.querySelectorAll(`[${An}]`);for(let o=0;o<f.length;o+=1)if(((a=f[o])==null?void 0:a.id)===t)return w("Another copy of ARCY is already on this page. Ignoring this one."),null}try{let f=document.createElement("div");f.id=t,f.setAttribute(An,"");for(let[h,v]of Eo)f.style.setProperty(h,v,"important");for(let[h,v]of To)f.style.setProperty(h,v);let o=f,i=!1;try{f.attachShadow&&(o=f.attachShadow({mode:"closed"}),i=!0);}catch(h){}r.appendChild(f),Ao(f);let u={host:f,root:o,isolated:i,destroy(){try{f.parentNode&&f.parentNode.removeChild(f);}catch(h){}Je.get(t)===u&&Je.delete(t);}};return Je.set(t,u),u}catch(f){return w(`The widget could not mount. ${String(f)}`),null}}var ko=["pointerdown","pointerup","pointercancel","mousedown","mouseup","click","dblclick","auxclick","contextmenu","touchstart","touchend","touchcancel","focusin","focusout","keydown","keyup","keypress","beforeinput","input","change","compositionstart","compositionupdate","compositionend","cut","copy","paste"];function Ao(e){let t=n=>{try{n.stopPropagation();}catch(r){}};for(let n of ko)try{e.addEventListener(n,t);}catch(r){}try{e.addEventListener("mousedown",n=>{n.defaultPrevented||Pt(e.ownerDocument,e);});}catch(n){}}function Pt(e,t){try{let n=e.activeElement;if(!n||n===t||t.contains(n)||n===e.body||n===e.documentElement)return;let r=n.blur;typeof r=="function"&&r.call(n);}catch(n){}}function In(e,t){var n;if(!e.isolated)return false;try{let r=e.root.querySelector(`[${Cn}]`);if(r)return r.textContent=`${(n=r.textContent)!=null?n:""}
4
4
  ${t}`,!0;let s=e.host.ownerDocument.createElement("style");return Le(s),s.setAttribute(Cn,""),s.textContent=t,e.root.appendChild(s),!0}catch(r){return w(`The widget could not apply its styles. ${String(r)}`),false}}var Co="arcy-picker-notice",_o=[["left","50%"],["bottom","24px"]],Io=[["transform","translateX(-50%)"],["box-sizing","border-box"],["max-width","min(520px, calc(100vw - 32px))"],["padding","14px 16px"],["border-radius","12px"],["background","#101828"],["color","#ffffff"],["font",'13px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'],["box-shadow","0 8px 24px rgba(16, 24, 40, 0.28)"]],Ro=[["font-weight","600"],["margin-bottom","4px"]],Po=[["color","#d0d5dd"]],Lo=[["appearance","none"],["margin-top","10px"],["border","1px solid rgba(255, 255, 255, 0.25)"],["border-radius","999px"],["background","transparent"],["color","#ffffff"],["font","inherit"],["padding","4px 12px"],["cursor","pointer"]];function st(e,t){for(let[n,r]of t)e.style.setProperty(n,r);}var Rn=false;function at(e){if(Rn)return;let t=null;try{if(t=it({id:Co}),!t)return;Rn=!0;let n=t.host.ownerDocument,r=n.createElement("div");r.style.setProperty("position","absolute","important"),r.style.setProperty("pointer-events","auto","important");for(let[o,i]of _o)r.style.setProperty(o,i,"important");st(r,Io);let s=n.createElement("div");st(s,Ro),s.textContent="ARCY element picker did not start";let l=n.createElement("div");st(l,Po),l.textContent=e;let a=n.createElement("button");a.type="button",st(a,Lo),a.textContent="Dismiss";let f=t;a.addEventListener("click",()=>{try{f.destroy();}catch(o){}}),r.append(s,l,a),t.root.appendChild(r);}catch(n){try{t==null||t.destroy();}catch(r){}}}function Se(e){w(e),at(e);}var Lt="arcy_picker",Oo="/api/v1/sdk/tagging/verify",Ln="https://cdn.arcyai.com";var Mo=15e3,Fo=1e4;function No(e,t){var n;return (n=Ot(e))!=null?n:Ot(t)}function Ot(e){if(!e)return null;try{let t=new URLSearchParams(e.charAt(0)==="#"?e.slice(1):e).get(Lt);return t&&t.length>0?t:null}catch(t){return null}}function Do(e){try{let t=new URL(e.location.href),n=t.searchParams.has(Lt),r=Ot(t.hash)!==null;if(!n&&!r)return;n&&t.searchParams.delete(Lt),r&&(t.hash=""),e.history.replaceState(e.history.state,"",t.toString());}catch(t){}}function Bo(e){return H(this,null,function*(){let{apiBase:t,token:n,nonce:r,fetchImpl:s,timeoutMs:l=Fo,setTimeoutImpl:a=(i,u)=>setTimeout(i,u)}=e;if(!s)return null;let f=()=>H(null,null,function*(){try{let i=yield s(`${t}${Oo}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({token:r}),credentials:"omit"});if(!i.ok)return null;let u=yield i.json();if((u==null?void 0:u.ok)!==!0)return null;let h=Ho(u.returnOrigin);return h?{returnOrigin:h,screenshotsEnabled:u.elementScreenshotsEnabled!==!1}:(Se("This ARCY server has not been told where its dashboard lives, so a pick would have nowhere to go. Set FRONTEND_DASHBOARD_URL and try again."),null)}catch(i){return null}}),o=new Promise(i=>{try{a(()=>i(null),l);}catch(u){}});return Promise.race([f(),o])})}function Ho(e){if(typeof e!="string"||e.length===0)return null;try{let{origin:t}=new URL(e);return t&&t!=="null"?t:null}catch(t){return null}}function On(e,t,n,r){return new Promise(s=>{let l=false,a=null,f=p=>{l||(l=true,a&&(a.onload=null,a.onerror=null),s(p));},o=false,i=p=>{o||(o=true,Se(p));},u=()=>{let p;try{p=e[It];}catch(k){return i("The element picker registration could not be read. Design mode is off."),null}if(!p)return null;if(typeof p.mount!="function")return i("The element picker registered something unusable. Design mode is off."),null;let b;try{b=p.contract;}catch(k){b=void 0;}return b!==2?(i(`The element picker on the CDN speaks contract ${typeof b=="number"?b:"unknown"}, this arcy.js speaks ${2}. Update arcy.js to use design mode.`),null):p},h=p=>{try{let b=u();!b&&!o&&p(),f(b);}catch(b){f(null);}},v=false;try{v=e[It]!==void 0;}catch(p){v=true;}if(v){h(()=>{});return}try{let p=e.document;a=p.createElement("script"),Le(a),a.async=!0,a.src=`${t}/${yn}`;let b=a.src;a.onload=()=>h(()=>Se("The element picker loaded but did not register. Design mode is off.")),a.onerror=()=>{try{Se(`Failed to load ${b}. Design mode is off. If this page sets a Content-Security-Policy, it must allow scripts from ${t}.`);}catch(k){}f(null);},(p.head||p.documentElement).appendChild(a);}catch(p){Se(`The element picker could not load. ${String(p)}`),f(null);return}try{r(()=>{l||Se("The element picker did not load in time. Design mode is off."),f(null);},n);}catch(p){}})}function Uo(e){try{let t=e.location.pathname;return typeof t!="string"||!t.startsWith("/")?"/":Be(t)}catch(t){return "/"}}function Vo(e){try{let t=e.opener;return !!t&&!t.closed}catch(t){return false}}function lt(e,t,n){try{let r=e.opener;if(!r||r.closed){w("The ARCY dashboard window is gone, so that pick could not be sent.");return}r.postMessage(n,t);}catch(r){w(`That pick could not be sent to the ARCY dashboard. ${String(r)}`);}}function Mn(e){return H(this,null,function*(){try{let{win:t,token:n,apiBase:r,fetchImpl:s,onVerified:l,loadChunk:a,loadTimeoutMs:f=Mo,setTimeoutImpl:o=(k,D)=>setTimeout(k,D)}=e,i=No(t.location.search,t.location.hash);if(!i)return "no_nonce";if(Do(t),!Vo(t))return Se("This page was not opened by the ARCY dashboard, so a picked element would have nowhere to go. If you did start it from the flow builder, this site is severing the link back: a Cross-Origin-Opener-Policy header on this page (helmet sets one by default) does exactly that. Serve this page with Cross-Origin-Opener-Policy: unsafe-none while you author."),"no_opener";let u=yield Bo({apiBase:r,token:n,nonce:i,fetchImpl:s,setTimeoutImpl:o});if(!u)return Se("The design-mode link is invalid, expired, or could not be verified. It is single-use and short-lived, so a reload spends it. Check that this page carries the same environment Token as the flow you are editing, then open the picker again from the dashboard."),"rejected";try{l();}catch(k){}let h=yield a(t,f,o);if(!h)return "load_failed";let{returnOrigin:v,screenshotsEnabled:p}=u;return h.mount({screenshotsEnabled:p,onPick:(k,D)=>{lt(t,v,{type:Tn,protocol:qe,target:k,route:Uo(t),matchCount:D});},onScreenshot:k=>{lt(t,v,{type:kn,protocol:qe,screenshot:k});},onExit:()=>{lt(t,v,{type:xn,protocol:qe});}})?(lt(t,v,{type:En,protocol:qe}),"active"):(Se("The element picker could not start. Design mode is off."),"mount_failed")}catch(t){return Se(`Design mode could not start. ${String(t)}`),"load_failed"}})}var Mt={getItem:()=>null,setItem:()=>{},removeItem:()=>{}};function oe(e){return e?{getItem(t){try{return e.getItem(t)}catch(n){return null}},setItem(t,n){try{e.setItem(t,n);}catch(r){}},removeItem(t){try{e.removeItem(t);}catch(n){}}}:Mt}function Ee(){try{let e=globalThis.localStorage;return oe(e)}catch(e){return Mt}}function Ve(){try{let e=globalThis.sessionStorage;return oe(e)}catch(e){return Mt}}function ie(e,t){let n=e.getItem(t);if(!n)return null;try{let r=JSON.parse(n);return !r||typeof r!="object"||Array.isArray(r)?null:r}catch(r){return null}}function ne(e,t,n){try{e.setItem(t,JSON.stringify(n));}catch(r){}}var Wo="arcy.preview.";function ct(e,t=Ve()){try{return oe(t).getItem(Wo+e)!==null}catch(n){return false}}var Ft="arcy_preview",$o=1,Ko="/api/v1/sdk/flows/preview/verify",Go=1e4;function Yo(e,t){var n;return (n=Nt(e))!=null?n:Nt(t)}function Nt(e){if(!e)return null;try{let t=new URLSearchParams(e.charAt(0)==="#"?e.slice(1):e).get(Ft);return t&&t.length>0?t:null}catch(t){return null}}function zo(e){try{let t=new URL(e.location.href),n=t.searchParams.has(Ft),r=Nt(t.hash)!==null;if(!n&&!r)return;n&&t.searchParams.delete(Ft),r&&(t.hash=""),e.history.replaceState(e.history.state,"",t.toString());}catch(t){}}function Fn(e,t){try{let n=Yo(e.location.search,e.location.hash);return n?(zo(e),{kind:"nonce",nonce:n}):ct(t)?{kind:"pending"}:null}catch(n){return null}}function Nn(e){return H(this,null,function*(){let{apiBase:t,token:n,nonce:r,sessionToken:s,userTraits:l,fetchImpl:a,timeoutMs:f=Go,setTimeoutImpl:o=(k,D)=>setTimeout(k,D)}=e;if(!a)return null;let i=k=>{w(k);try{at(k);}catch(D){}return null},u=()=>H(null,null,function*(){try{let k=yield a(`${t}${Ko}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify($($({token:r},s?{sessionToken:s}:{}),l&&Object.keys(l).length>0?{userTraits:l}:{})),credentials:"omit"});if(!k.ok)return i("ARCY could not verify this preview link. Close this tab and press Preview in the dashboard again.");let D=yield k.json();return (D==null?void 0:D.ok)!==!0||D.flow===void 0||D.flow===null?i("ARCY could not verify this preview link. Close this tab and press Preview in the dashboard again."):D.protocol!==$o?i("This page runs an older version of arcy.js than the dashboard expects. The preview cannot run until the script updates."):D.flow}catch(k){return i("ARCY could not reach its server to start this preview. Check the connection and press Preview again.")}}),h=false,v,p=new Promise(k=>{try{v=o(()=>{h||(h=!0,k(i("ARCY took too long to verify this preview link. Close this tab and press Preview in the dashboard again.")));},f);}catch(D){}}),b=yield Promise.race([u().then(k=>(h=true,k)),p]);try{v!==void 0&&clearTimeout(v);}catch(k){}return b})}var Dt="https://api.arcyai.com",Xo="/api/v1/sdk/session/init";var jo=["ON","REQUIRE_CONSENT","OFF"];function qo(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,n=t.behavioralTelemetry,r=t.effectiveCustomization,s=t.widget,l=t.identity,a=l&&typeof l=="object"&&!Array.isArray(l)?l.accepted:void 0;return {sessionToken:typeof t.sessionToken=="string"?t.sessionToken:null,behavioralTelemetry:typeof n=="string"&&jo.indexOf(n)!==-1?n:null,customization:r&&typeof r=="object"&&!Array.isArray(r)?r:null,widget:s&&typeof s=="object"&&!Array.isArray(s)?s:null,identityAccepted:typeof a=="boolean"?a:null}}function Dn(e){let{token:t,apiBase:n=Dt,setTimeoutImpl:r=(S,E)=>setTimeout(S,E),now:s=()=>Date.now(),retryDelayMs:l=2e3,attemptTimeoutMs:a=5e3,failureCooldownMs:f=3e4}=e,o=e.fetchImpl!==void 0?e.fetchImpl:typeof fetch!="undefined"?fetch.bind(globalThis):null,i=`${n}${Xo}`,u=null,h=null,v=null,p=null,b=0;function k(S){let E={publicKey:t,sessionId:S.sessionId};return S.visitorId!==void 0&&(E.visitorId=S.visitorId),S.userId!==void 0&&(E.userId=S.userId),S.userHash!==void 0&&(E.userHash=S.userHash),S.userTraits!==void 0&&(E.userTraits=S.userTraits),S.uiLanguage!==void 0&&(E.uiLanguage=S.uiLanguage),S.contentLocale!==void 0&&(E.contentLocale=S.contentLocale),S.viewerLocale!==void 0&&(E.viewerLocale=S.viewerLocale),S.route!==void 0&&(E.route=S.route),S.sessionContext!==void 0&&(E.sessionContext=S.sessionContext),JSON.stringify(E)}function D(S){return H(this,null,function*(){if(!o)return {ok:false,reason:"unusable"};let E;try{E=yield o(i,{method:"POST",headers:{"Content-Type":"application/json"},body:S,credentials:"omit"});}catch(M){return null}if(E.status>=500)return null;if(!E.ok)return {ok:false,reason:"rejected"};let F;try{F=yield E.json();}catch(M){return {ok:false,reason:"unusable"}}let A=qo(F);return A?{ok:true,config:A}:{ok:false,reason:"unusable"}})}function I(S){return new Promise(E=>{try{r(()=>E(),S);}catch(F){E();}})}function V(S){return Promise.race([D(S),I(a).then(()=>null)])}function P(S){return H(this,null,function*(){let E=yield V(S);if(E)return E;yield I(l);let F=yield V(S);return F!=null?F:{ok:false,reason:"network"}})}return {sync(S){return H(this,null,function*(){let E=k(S);if(p&&E===h)return p;if(!p&&E===h&&u)return {ok:true,config:u};if(v&&v.json===E&&s()-v.at<f)return {ok:false,reason:"network"};h=E;let F=++b,A=P(E).then(M=>(F===b&&(M.ok?(u=M.config,v=null):(v={json:E,at:s()},h===E&&(h=null))),p===A&&(p=null),M));return p=A,A})},config:()=>u}}var Bt="__arcyChat";var Bn=["image/png","image/jpeg","image/webp"],Ht="--_arcy-font-key",Hn="arcy-chat-policy",Un="arcy-bar-tray",ut={historyTitle:"Recent chats",historyEmpty:"No conversations yet.",newChat:"New chat",flowsTitle:"What I can do",flowsEmpty:"Nothing to run yet.",collapse:"Collapse",back:"Back",closeSheet:"Close",settingsTitle:"Settings",dockChat:"Dock to the corner",dockChatHint:"Shrink ARCY to a button in the bottom-right corner.",language:"Language",openChat:"Open chat",moveBar:"Move the chat bar",send:"Send",flowRunning:"Running",flowStep:"Step {step} of {total}",flowStop:"Stop",flowFailed:"Sorry, I could not finish that for you this time. You can ask me here and I will help you do it.",attachMenu:"Add",attachImage:"Attach an image",removeImage:"Remove image",imageTooLarge:"That image is too large. Each image must be under 5 MB.",imageWrongType:"That file type is not supported. Use PNG, JPEG or WEBP.",imageTooMany:"You can attach up to 3 images.",imageFailed:"That image could not be uploaded. Please try again.",likeAnswer:"Good answer",dislikeAnswer:"Bad answer",answering:"Answering",aiDisclaimer:"{app} is AI and can make mistakes",consentNotice:"Your messages are processed to answer your question.",consentWithPolicy:"{policy}",disclaimerJoin:" \xB7 ",privacyPolicy:"Privacy Policy",poweredBy:"Powered by ARCY",genericError:"Something went wrong. Please try again.",userCapReached:"You've reached today's limit for questions. Please try again tomorrow.",imageConversation:"Image",searchedSourcesLabel:"Searched {count} sources",sourcesLabel:"Sources:",flowOfferHint:"You can do this in one click with the Quick Flow below.",fillConfirm:"Confirm",fillYes:"Yes",fillNo:"No",fillRequired:"This field needs an answer.",fillInvalidNumber:"Please enter a number.",fillNumberTooSmall:"Please enter {min} or more.",fillNumberTooLarge:"Please enter {max} or less.",fillInvalidEmail:"Please enter a valid email address.",fillInvalidUrl:"Please enter a valid link.",fillInvalidDate:"Please enter a valid date.",fillInvalidTime:"Please enter a valid time.",fillDateTooEarly:"Please pick {min} or later.",fillDateTooLate:"Please pick {max} or earlier.",fillTooLong:"Please keep it under {max} characters.",fillInvalidOption:"Please pick one of the options.",fillInvalid:"That does not look right. Please try again."};var Ut="https://cdn.arcyai.com";var Jo=15e3;function Wn(e,t,n,r){return new Promise(s=>{let l=false,a=null,f=p=>{l||(l=true,a&&(a.onload=null,a.onerror=null),s(p));},o=false,i=p=>{o||(o=true,w(p));},u=()=>{let p;try{p=e[Bt];}catch(k){return i("The chat panel registration could not be read. The panel will not open."),null}if(!p)return null;if(typeof p.mount!="function")return i("The chat panel registered something unusable. The panel will not open."),null;let b;try{b=p.contract;}catch(k){b=void 0;}return b!==4?(i(`The chat panel on the CDN speaks contract ${typeof b=="number"?b:"unknown"}, this arcy.js speaks ${4}. Update arcy.js to open the chat panel.`),null):p},h=p=>{try{let b=u();!b&&!o&&p(),f(b);}catch(b){f(null);}},v=false;try{v=e[Bt]!==void 0;}catch(p){v=true;}if(v){h(()=>{});return}try{let p=e.document;a=p.createElement("script"),Le(a),a.async=!0,a.src=`${t}/${bn}`;let b=a.src;a.onload=()=>h(()=>w("The chat panel loaded but did not register. The panel will not open.")),a.onerror=()=>{try{w(`Failed to load ${b}. The chat panel will not open. If this page sets a Content-Security-Policy, it must allow scripts from ${t}.`);}catch(k){}f(null);},(p.head||p.documentElement).appendChild(a);}catch(p){w(`The chat panel could not load. ${String(p)}`),f(null);return}try{r(()=>{l||w("The chat panel did not load in time."),f(null);},n);}catch(p){}})}function $n(e){let{root:t,host:n,win:r=typeof window!="undefined"?window:void 0,loadChunk:s,loadTimeoutMs:l=Jo,setTimeoutImpl:a=(L,j)=>setTimeout(L,j),onRequestClose:f,bar:o,apiBase:i,getSessionToken:u,getSessionId:h,getRoute:v,getMaxHeightPercent:p,onStartFlow:b,publicKey:k,getConversationId:D,setConversationId:I,touchConversation:V,getVisitorId:P,onOrgCapExceeded:X,onStopFlow:S,track:E,getWidget:F,onSelectLocale:A}=e,M=t!==n,C=null,G=null,U=false,K=false;function J(){return H(this,null,function*(){if(!(C||U))return G||(G=H(null,null,function*(){if(r)try{let L=yield s(r,l,a);if(!L||U)return;let j={root:t,host:n,isolated:M,onRequestClose:f,bar:o,apiBase:i,getSessionToken:u,getSessionId:h,getRoute:v,getMaxHeightPercent:p,onStartFlow:b,publicKey:k,getConversationId:D,setConversationId:I,touchConversation:V,getVisitorId:P,onOrgCapExceeded:X,onStopFlow:S,track:E,getWidget:F,onSelectLocale:A};C=L.mount(j),C||w("The chat panel could not start.");}catch(L){w(`The chat panel could not load. ${String(L)}`);}finally{G=null;}}),G)})}return {open(){return H(this,null,function*(){if(!U&&(K=true,yield J(),!(!K||U)))try{C==null||C.open();}catch(L){w(`The chat panel could not open. ${String(L)}`);}})},close(){K=false;try{C==null||C.close();}catch(L){w(`The chat panel could not close. ${String(L)}`);}},destroy(){U=true,K=false;let L=C;C=null;try{L==null||L.destroy();}catch(j){w(`The chat panel could not be removed. ${String(j)}`);}},reposition(){var L;try{(L=C==null?void 0:C.reposition)==null||L.call(C);}catch(j){w(`The chat panel could not move. ${String(j)}`);}},refreshChrome(){var L;try{(L=C==null?void 0:C.refreshChrome)==null||L.call(C);}catch(j){w(`The chat panel could not apply its texts. ${String(j)}`);}},promptFill(L){return H(this,null,function*(){if(U||(yield J(),U||!(C!=null&&C.promptFill)))return null;try{return yield C.promptFill(L)}catch(j){return w(`The flow's question could not be shown. ${String(j)}`),null}})},cancelFill(){var L;try{(L=C==null?void 0:C.cancelFill)==null||L.call(C);}catch(j){w(`The flow's question could not be withdrawn. ${String(j)}`);}},showFlowFailure(){return H(this,null,function*(){if(!U&&(K=true,yield J(),!(!K||U||!(C!=null&&C.showFlowFailure))))try{C.showFlowFailure();}catch(L){w(`The flow's failure notice could not be shown. ${String(L)}`);}})}}}var Vt="__arcyFlow";var Qo="arcy.flow.";function Zo(e){return typeof e.flowId=="string"&&e.flowId.length>0&&typeof e.currentStepCvid=="string"&&e.currentStepCvid.length>0&&typeof e.flowSessionId=="string"&&e.flowSessionId.length>0&&typeof e.startedAt=="number"}function Kn(e,{store:t=Ee()}={}){let n=oe(t),r=Qo+e;return {read(){let s=ie(n,r);return !s||!Zo(s)?null:{flowId:s.flowId,currentStepCvid:s.currentStepCvid,flowSessionId:s.flowSessionId,startedAt:s.startedAt}},save(s){ne(n,r,s);},clear(){n.removeItem(r);}}}var Yn="https://cdn.arcyai.com";var ei=15e3;function zn(e,t,n,r){return new Promise(s=>{let l=false,a=null,f=p=>{l||(l=true,a&&(a.onload=null,a.onerror=null),s(p));},o=false,i=p=>{o||(o=true,w(p));},u=()=>{let p;try{p=e[Vt];}catch(k){return i("The flow engine registration could not be read. The flow will not start."),null}if(!p)return null;if(typeof p.mount!="function")return i("The flow engine registered something unusable. The flow will not start."),null;let b;try{b=p.contract;}catch(k){b=void 0;}return b!==2?(i(`The flow engine on the CDN speaks contract ${typeof b=="number"?b:"unknown"}, this arcy.js speaks ${2}. Update arcy.js to run flows.`),null):p},h=p=>{try{let b=u();!b&&!o&&p(),f(b);}catch(b){f(null);}},v=false;try{v=e[Vt]!==void 0;}catch(p){v=true;}if(v){h(()=>{});return}try{let p=e.document;a=p.createElement("script"),Le(a),a.async=!0,a.src=`${t}/${wn}`;let b=a.src;a.onload=()=>h(()=>w("The flow engine loaded but did not register. The flow will not start.")),a.onerror=()=>{try{w(`Failed to load ${b}. The flow will not start. If this page sets a Content-Security-Policy, it must allow scripts from ${t}.`);}catch(k){}f(null);},(p.head||p.documentElement).appendChild(a);}catch(p){w(`The flow engine could not load. ${String(p)}`),f(null);return}try{r(()=>{l||w("The flow engine did not load in time."),f(null);},n);}catch(p){}})}function Xn(e){let{win:t=typeof window!="undefined"?window:void 0,loadChunk:n,loadTimeoutMs:r=ei,setTimeoutImpl:s=(h,v)=>setTimeout(h,v),context:l}=e,a=null,f=null,o=false;function i(){return H(this,null,function*(){if(!(a||o))return f||(f=H(null,null,function*(){if(t)try{let h=yield n(t,r,s);if(!h||o)return;a=h.mount(ae($({},l),{doc:t.document,win:t})),a||w("The flow engine could not start.");}catch(h){w(`The flow engine could not load. ${String(h)}`);}finally{f=null;}}),f)})}return {start(h){return H(this,null,function*(){if(!o&&(yield i(),!o))try{yield a==null?void 0:a.start(h);}catch(v){w(`The flow could not start. ${String(v)}`);}})},resume(){return H(this,null,function*(){if(o||!Kn(l.token).read()||(yield i(),o||!a))return false;try{return yield a.resume()}catch(v){return w(`The flow could not resume. ${String(v)}`),false}})},startPreview(h){return H(this,null,function*(){var v;if(!o&&(yield i(),!o))try{yield (v=a==null?void 0:a.startPreview)==null?void 0:v.call(a,h);}catch(p){w(`The preview could not start. ${String(p)}`);}})},resumePreview(){return H(this,null,function*(){if(o||!ct(l.token)||(yield i(),o||!(a!=null&&a.resumePreview)))return false;try{return yield a.resumePreview()}catch(h){return w(`The preview could not resume. ${String(h)}`),false}})},stop(){var h;if(!o)try{(h=a==null?void 0:a.stop)==null||h.call(a);}catch(v){w(`The flow could not be stopped. ${String(v)}`);}},destroy(){o=true;let h=a;a=null;try{h==null||h.destroy();}catch(v){w(`The flow engine could not be removed. ${String(v)}`);}}}}function Wt(e){let t=e.dataTransfer;if(!t)return false;let n=t.types;if(!n)return false;for(let r=0;r<n.length;r+=1)if(n[r]==="Files")return true;return false}function jn(e){var n;let t=e.dataTransfer;return Array.from((n=t==null?void 0:t.files)!=null?n:[])}var qn=`
5
5
  [data-tip] {
@@ -1,2 +1,2 @@
1
1
  (function(exports){'use strict';/* arcy.js — https://arcyai.com */
2
- var c="arcy.modern.d30bb13c138a.js",i="arcy.legacy.061d3b544569.js";function a(){return typeof HTMLScriptElement!="undefined"&&"noModule"in HTMLScriptElement.prototype}function p(r){let e=r.currentScript;return !e||!e.src?"":e.src.replace(/\/[^/]*$/,"")}function l(r,e){var s;let u=p(e),d=a()?c:i,t=e.createElement("script"),o=(s=e.currentScript)==null?void 0:s.nonce;o&&(t.nonce=o,t.setAttribute("nonce",o)),t.async=true,t.src=`${u}/${d}`,t.onerror=()=>{typeof console!="undefined"&&console.warn&&console.warn(`[arcy] Failed to load ${t.src}. ARCY is disabled.`);};let n=e.getElementsByTagName("script")[0];n&&n.parentNode?n.parentNode.insertBefore(t,n):(e.head||e.documentElement).appendChild(t);}typeof window!="undefined"&&typeof document!="undefined"&&l(window,document);exports.currentScriptBase=p;exports.loadCore=l;return exports;})({});
2
+ var c="arcy.modern.9d6d23d21370.js",i="arcy.legacy.ba7330cb1ce9.js";function a(){return typeof HTMLScriptElement!="undefined"&&"noModule"in HTMLScriptElement.prototype}function p(r){let e=r.currentScript;return !e||!e.src?"":e.src.replace(/\/[^/]*$/,"")}function l(r,e){var s;let u=p(e),d=a()?c:i,t=e.createElement("script"),o=(s=e.currentScript)==null?void 0:s.nonce;o&&(t.nonce=o,t.setAttribute("nonce",o)),t.async=true,t.src=`${u}/${d}`,t.onerror=()=>{typeof console!="undefined"&&console.warn&&console.warn(`[arcy] Failed to load ${t.src}. ARCY is disabled.`);};let n=e.getElementsByTagName("script")[0];n&&n.parentNode?n.parentNode.insertBefore(t,n):(e.head||e.documentElement).appendChild(t);}typeof window!="undefined"&&typeof document!="undefined"&&l(window,document);exports.currentScriptBase=p;exports.loadCore=l;return exports;})({});
@@ -1,5 +1,5 @@
1
1
  (function(){'use strict';/* arcy.js — https://arcyai.com */
2
- function h(e){typeof console<"u"&&console.warn&&console.warn(`[arcy] ${e}`);}function zt(){let e=new Map;function t(r,o){if(typeof o!="function")return h(`on("${r}") needs a function. Ignoring.`),()=>{};let i=e.get(r);return i||(i=new Set,e.set(r,i)),i.add(o),()=>{i.delete(o);}}function n(r){let o=e.get(r);if(o)for(let i of [...o])try{i();}catch(s){h(`A "${r}" handler threw. ${String(s)}`);}}return {on:t,emit:n}}function gt(e){if(e.parentElement!==null)return e.parentElement;let t=e.parentNode;return t!==null&&"host"in t?t.host:null}var Xt=[/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,/\b\d{3}-\d{2}-\d{4}\b/g,/\b\d(?:[ -]?\d){12,18}\b/g],Pr="[masked]";function Me(e){return Xt.some(t=>(t.lastIndex=0,t.test(e)))}var yt=4096,Lr=100,Or=64;function ze(e){if(!e)return;let t=e.slice(0,yt);if(e.length>yt){let r=t.search(/\s\S*$/);t=r===-1?t.slice(0,yt-Lr):t.slice(0,r);}let n=t.replace(/\s+/g," ").trim();if(n){for(let r of Xt)n=n.replace(r,Pr);return n.slice(0,80)}}function jt(e){return !(e.length===0||e.length>64||e.includes(":")||e.startsWith("radix-")||/^\d+$/.test(e)||/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e))}var Mr=["data-testid","data-test","data-cy","id","name","aria-label"],Fr=["data-testid","data-test","data-cy"],Nr=64;function Dr(e){for(let t of Fr){let n=e.getAttribute(t);if(n===null)continue;let r=n.trim();if(!(r===""||r.length>Nr)&&!Me(r))return r}}var Br=new Set(["navigation","main","banner","contentinfo","search","form","region","dialog"]);function Hr(e){let t=gt(e);for(;t!==null;){let n=t.tagName.toLowerCase();if(n==="body"||n==="html")return;for(let o of Mr){let i=t.getAttribute(o);if(i===null||o==="id"&&!jt(i))continue;let s=ze(i);if(s!==void 0)return {tag:n,attr:o,value:s}}let r=t.getAttribute("role");if(r!==null&&Br.has(r))return {tag:n,attr:"role",value:r};t=gt(t);}}function Ur(e){let t=0,n=e.previousElementSibling;for(;n!==null;)n.tagName===e.tagName&&(t+=1),n=n.previousElementSibling;return t}function qt(e){let t={tag:e.tagName.toLowerCase(),siblingIndex:Ur(e)},n=ze(e.textContent);n!==void 0&&(t.text=n);let r=ze(e.getAttribute("aria-label"));r!==void 0&&(t.ariaLabel=r);let o=ze(e.getAttribute("placeholder"));o!==void 0&&(t.placeholder=o);let i=e.getAttribute("id");i!==null&&jt(i)&&!Me(i)&&(t.id=i);let s=e.getAttribute("role");if(s!==null){let l=s.trim();l!==""&&l.length<=Or&&!Me(l)&&(t.role=l);}let f=Dr(e);f!==void 0&&(t.testId=f);let a=Hr(e);return a!==void 0&&(t.ancestorTag=a.tag,t.ancestorAttr=a.attr,t.ancestorValue=a.value),t}var Jt="arcy.picker.b7e531503cf2.js",Qt="arcy.chat.f698fce59921.js",Zt="arcy.flow.fef131718e42.js";var Vr=/^(?:\d+|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|[0-9a-f]{12,})$/i,Wr=/^[^@\s/]+@[^@\s/]+\.[^@\s/]+$/;function $r(e){if(e.indexOf("%")===-1)return e;try{return decodeURIComponent(e)}catch{return e}}function en(e){return e.length===0?false:Vr.test(e)?true:Wr.test($r(e))}function ke(e){let n=e.split("/").map(r=>en(r)?":id":r).join("/");for(;n.length>1&&n.charAt(n.length-1)==="/";)n=n.slice(0,-1);return n.length===0?"/":n}function Kr(e){if(e.length===0)return "";let t=[];for(let n of e.split("&")){if(n.length===0)continue;let r=n.indexOf("="),o=r===-1?n:n.slice(0,r);if(o.length===0)continue;let i=en(o)?":id":o;t.indexOf(i)===-1&&t.push(i);}return t.length===0?"":(t.sort(),`?${t.join("&")}`)}function Gr(e,t){try{let n=new URL(e,t??void 0);return {path:n.pathname,query:n.search.slice(1)}}catch{let n=e.split("#")[0]??"";if(!n.startsWith("/"))return null;let r=n.indexOf("?");return r===-1?{path:n,query:""}:{path:n.slice(0,r),query:n.slice(r+1)}}}function Fe(e,t){if(typeof e!="string"||e.length===0)return null;let n=Gr(e,t);if(n===null)return null;let r=ke(n.path);if(!r)return null;if(r.length>=2048)return r.slice(0,2048);let o=Kr(n.query);return o.length===0||r.length+o.length>2048?r:r+o}function Yr(e){try{let n=e.currentScript?.nonce;if(typeof n=="string"&&n.length>0)return n;let r=e.getElementsByTagName("script");for(let o=0;o<r.length;o++){let i=r[o].nonce;if(typeof i=="string"&&i.length>0)return i}return null}catch{return null}}var zr=typeof document<"u"?Yr(document):null;function jr(){return zr}function ve(e){let t=jr();if(t)try{e.nonce=t,e.setAttribute("nonce",t);}catch{}}var qr="https://docs.arcyai.com/troubleshooting#content-security-policy";function bt(e){try{let{origin:t}=new URL(e);return t&&t!=="null"?t:null}catch{return null}}function Jr(e){let t=bt(e.apiBase),n=e.cdnBase?bt(e.cdnBase):null,r=["This page's Content-Security-Policy is blocking part of the ARCY widget.","Add these to the policy your app sends:",""];return n&&r.push(` script-src ${n}`),t&&(r.push(` connect-src ${t}`),r.push(` font-src ${t}`),r.push(` img-src ${t} blob:`)),r.push(" style-src 'unsafe-inline', or a nonce on the script that loads ARCY"),r.push(""),r.push("To allow none of them, proxy a path on your own domain to the API and pass it as arcy.init(token, { apiBase })."),r.push(e.docsUrl??qr),r.join(`
2
+ function h(e){typeof console<"u"&&console.warn&&console.warn(`[arcy] ${e}`);}function zt(){let e=new Map;function t(r,o){if(typeof o!="function")return h(`on("${r}") needs a function. Ignoring.`),()=>{};let i=e.get(r);return i||(i=new Set,e.set(r,i)),i.add(o),()=>{i.delete(o);}}function n(r){let o=e.get(r);if(o)for(let i of [...o])try{i();}catch(s){h(`A "${r}" handler threw. ${String(s)}`);}}return {on:t,emit:n}}function gt(e){if(e.parentElement!==null)return e.parentElement;let t=e.parentNode;return t!==null&&"host"in t?t.host:null}var Xt=[/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,/\b\d{3}-\d{2}-\d{4}\b/g,/\b\d(?:[ -]?\d){12,18}\b/g],Pr="[masked]";function Me(e){return Xt.some(t=>(t.lastIndex=0,t.test(e)))}var yt=4096,Lr=100,Or=64;function ze(e){if(!e)return;let t=e.slice(0,yt);if(e.length>yt){let r=t.search(/\s\S*$/);t=r===-1?t.slice(0,yt-Lr):t.slice(0,r);}let n=t.replace(/\s+/g," ").trim();if(n){for(let r of Xt)n=n.replace(r,Pr);return n.slice(0,80)}}function jt(e){return !(e.length===0||e.length>64||e.includes(":")||e.startsWith("radix-")||/^\d+$/.test(e)||/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e))}var Mr=["data-testid","data-test","data-cy","id","name","aria-label"],Fr=["data-testid","data-test","data-cy"],Nr=64;function Dr(e){for(let t of Fr){let n=e.getAttribute(t);if(n===null)continue;let r=n.trim();if(!(r===""||r.length>Nr)&&!Me(r))return r}}var Br=new Set(["navigation","main","banner","contentinfo","search","form","region","dialog"]);function Hr(e){let t=gt(e);for(;t!==null;){let n=t.tagName.toLowerCase();if(n==="body"||n==="html")return;for(let o of Mr){let i=t.getAttribute(o);if(i===null||o==="id"&&!jt(i))continue;let s=ze(i);if(s!==void 0)return {tag:n,attr:o,value:s}}let r=t.getAttribute("role");if(r!==null&&Br.has(r))return {tag:n,attr:"role",value:r};t=gt(t);}}function Ur(e){let t=0,n=e.previousElementSibling;for(;n!==null;)n.tagName===e.tagName&&(t+=1),n=n.previousElementSibling;return t}function qt(e){let t={tag:e.tagName.toLowerCase(),siblingIndex:Ur(e)},n=ze(e.textContent);n!==void 0&&(t.text=n);let r=ze(e.getAttribute("aria-label"));r!==void 0&&(t.ariaLabel=r);let o=ze(e.getAttribute("placeholder"));o!==void 0&&(t.placeholder=o);let i=e.getAttribute("id");i!==null&&jt(i)&&!Me(i)&&(t.id=i);let s=e.getAttribute("role");if(s!==null){let l=s.trim();l!==""&&l.length<=Or&&!Me(l)&&(t.role=l);}let f=Dr(e);f!==void 0&&(t.testId=f);let a=Hr(e);return a!==void 0&&(t.ancestorTag=a.tag,t.ancestorAttr=a.attr,t.ancestorValue=a.value),t}var Jt="arcy.picker.b7e531503cf2.js",Qt="arcy.chat.27fabef680f1.js",Zt="arcy.flow.bc28949c2a72.js";var Vr=/^(?:\d+|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|[0-9a-f]{12,})$/i,Wr=/^[^@\s/]+@[^@\s/]+\.[^@\s/]+$/;function $r(e){if(e.indexOf("%")===-1)return e;try{return decodeURIComponent(e)}catch{return e}}function en(e){return e.length===0?false:Vr.test(e)?true:Wr.test($r(e))}function ke(e){let n=e.split("/").map(r=>en(r)?":id":r).join("/");for(;n.length>1&&n.charAt(n.length-1)==="/";)n=n.slice(0,-1);return n.length===0?"/":n}function Kr(e){if(e.length===0)return "";let t=[];for(let n of e.split("&")){if(n.length===0)continue;let r=n.indexOf("="),o=r===-1?n:n.slice(0,r);if(o.length===0)continue;let i=en(o)?":id":o;t.indexOf(i)===-1&&t.push(i);}return t.length===0?"":(t.sort(),`?${t.join("&")}`)}function Gr(e,t){try{let n=new URL(e,t??void 0);return {path:n.pathname,query:n.search.slice(1)}}catch{let n=e.split("#")[0]??"";if(!n.startsWith("/"))return null;let r=n.indexOf("?");return r===-1?{path:n,query:""}:{path:n.slice(0,r),query:n.slice(r+1)}}}function Fe(e,t){if(typeof e!="string"||e.length===0)return null;let n=Gr(e,t);if(n===null)return null;let r=ke(n.path);if(!r)return null;if(r.length>=2048)return r.slice(0,2048);let o=Kr(n.query);return o.length===0||r.length+o.length>2048?r:r+o}function Yr(e){try{let n=e.currentScript?.nonce;if(typeof n=="string"&&n.length>0)return n;let r=e.getElementsByTagName("script");for(let o=0;o<r.length;o++){let i=r[o].nonce;if(typeof i=="string"&&i.length>0)return i}return null}catch{return null}}var zr=typeof document<"u"?Yr(document):null;function jr(){return zr}function ve(e){let t=jr();if(t)try{e.nonce=t,e.setAttribute("nonce",t);}catch{}}var qr="https://docs.arcyai.com/troubleshooting#content-security-policy";function bt(e){try{let{origin:t}=new URL(e);return t&&t!=="null"?t:null}catch{return null}}function Jr(e){let t=bt(e.apiBase),n=e.cdnBase?bt(e.cdnBase):null,r=["This page's Content-Security-Policy is blocking part of the ARCY widget.","Add these to the policy your app sends:",""];return n&&r.push(` script-src ${n}`),t&&(r.push(` connect-src ${t}`),r.push(` font-src ${t}`),r.push(` img-src ${t} blob:`)),r.push(" style-src 'unsafe-inline', or a nonce on the script that loads ARCY"),r.push(""),r.push("To allow none of them, proxy a path on your own domain to the API and pass it as arcy.init(token, { apiBase })."),r.push(e.docsUrl??qr),r.join(`
3
3
  `)}function tn(e,t){let n=[t.apiBase,t.cdnBase].filter(o=>typeof o=="string"&&o.length>0).map(bt).filter(o=>o!==null),r=()=>{};try{let o=i=>{let s=i.blockedURI;(s==="inline"||n.some(a=>s?.startsWith(a)))&&(r(),h(Jr(t)));};e.document.addEventListener("securitypolicyviolation",o),r=()=>{try{e.document.removeEventListener("securitypolicyviolation",o);}catch{}};}catch{}return ()=>r()}var wt="__arcyPicker";var Ne=2,nn="arcy:design-mode:ready",rn="arcy:design-mode:pick",on="arcy:design-mode:exit",sn="arcy:design-mode:screenshot";var cn="arcy-widget",an="data-arcy",vt="2147483000",Qr=[["position","fixed"],["inset","0"],["z-index",vt],["pointer-events","none"],["background","transparent"],["border","0"],["box-shadow","none"],["outline","0"]],Zr=[["margin","0"],["padding","0"]],ln="data-arcy-style",De=new Map;function eo(e=cn){let t=De.get(e);return t!==void 0&&t.host.isConnected}function Xe(e={}){if(typeof document>"u")return null;let t=e.id??cn,n=e.container;if(eo(t))return h("This ARCY surface is already on this page. Ignoring the second mount."),null;De.delete(t);let r=n??document.body??document.documentElement;if(!r)return h("The page has no <body> to mount into yet. The widget will not render."),null;if(!n){let o=document.querySelectorAll(`[${an}]`);for(let i=0;i<o.length;i+=1)if(o[i]?.id===t)return h("Another copy of ARCY is already on this page. Ignoring this one."),null}try{let o=document.createElement("div");o.id=t,o.setAttribute(an,"");for(let[a,l]of Qr)o.style.setProperty(a,l,"important");for(let[a,l]of Zr)o.style.setProperty(a,l);let i=o,s=!1;try{o.attachShadow&&(i=o.attachShadow({mode:"closed"}),s=!0);}catch{}r.appendChild(o),no(o);let f={host:o,root:i,isolated:s,destroy(){try{o.parentNode&&o.parentNode.removeChild(o);}catch{}De.get(t)===f&&De.delete(t);}};return De.set(t,f),f}catch(o){return h(`The widget could not mount. ${String(o)}`),null}}var to=["pointerdown","pointerup","pointercancel","mousedown","mouseup","click","dblclick","auxclick","contextmenu","touchstart","touchend","touchcancel","focusin","focusout","keydown","keyup","keypress","beforeinput","input","change","compositionstart","compositionupdate","compositionend","cut","copy","paste"];function no(e){let t=n=>{try{n.stopPropagation();}catch{}};for(let n of to)try{e.addEventListener(n,t);}catch{}try{e.addEventListener("mousedown",n=>{n.defaultPrevented||St(e.ownerDocument,e);});}catch{}}function St(e,t){try{let n=e.activeElement;if(!n||n===t||t.contains(n)||n===e.body||n===e.documentElement)return;let r=n.blur;typeof r=="function"&&r.call(n);}catch{}}function un(e,t){if(!e.isolated)return false;try{let n=e.root.querySelector(`[${ln}]`);if(n)return n.textContent=`${n.textContent??""}
4
4
  ${t}`,!0;let r=e.host.ownerDocument.createElement("style");return ve(r),r.setAttribute(ln,""),r.textContent=t,e.root.appendChild(r),!0}catch(n){return h(`The widget could not apply its styles. ${String(n)}`),false}}var ro="arcy-picker-notice",oo=[["left","50%"],["bottom","24px"]],io=[["transform","translateX(-50%)"],["box-sizing","border-box"],["max-width","min(520px, calc(100vw - 32px))"],["padding","14px 16px"],["border-radius","12px"],["background","#101828"],["color","#ffffff"],["font",'13px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'],["box-shadow","0 8px 24px rgba(16, 24, 40, 0.28)"]],so=[["font-weight","600"],["margin-bottom","4px"]],ao=[["color","#d0d5dd"]],lo=[["appearance","none"],["margin-top","10px"],["border","1px solid rgba(255, 255, 255, 0.25)"],["border-radius","999px"],["background","transparent"],["color","#ffffff"],["font","inherit"],["padding","4px 12px"],["cursor","pointer"]];function je(e,t){for(let[n,r]of t)e.style.setProperty(n,r);}var dn=false;function qe(e){if(dn)return;let t=null;try{if(t=Xe({id:ro}),!t)return;dn=!0;let n=t.host.ownerDocument,r=n.createElement("div");r.style.setProperty("position","absolute","important"),r.style.setProperty("pointer-events","auto","important");for(let[a,l]of oo)r.style.setProperty(a,l,"important");je(r,io);let o=n.createElement("div");je(o,so),o.textContent="ARCY element picker did not start";let i=n.createElement("div");je(i,ao),i.textContent=e;let s=n.createElement("button");s.type="button",je(s,lo),s.textContent="Dismiss";let f=t;s.addEventListener("click",()=>{try{f.destroy();}catch{}}),r.append(o,i,s),t.root.appendChild(r);}catch{try{t?.destroy();}catch{}}}function ce(e){h(e),qe(e);}var Et="arcy_picker",co="/api/v1/sdk/tagging/verify",pn="https://cdn.arcyai.com";var uo=15e3,fo=1e4;function po(e,t){return Tt(e)??Tt(t)}function Tt(e){if(!e)return null;try{let t=new URLSearchParams(e.charAt(0)==="#"?e.slice(1):e).get(Et);return t&&t.length>0?t:null}catch{return null}}function mo(e){try{let t=new URL(e.location.href),n=t.searchParams.has(Et),r=Tt(t.hash)!==null;if(!n&&!r)return;n&&t.searchParams.delete(Et),r&&(t.hash=""),e.history.replaceState(e.history.state,"",t.toString());}catch{}}async function ho(e){let{apiBase:t,token:n,nonce:r,fetchImpl:o,timeoutMs:i=fo,setTimeoutImpl:s=(l,d)=>setTimeout(l,d)}=e;if(!o)return null;let f=async()=>{try{let l=await o(`${t}${co}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({token:r}),credentials:"omit"});if(!l.ok)return null;let d=await l.json();if(d?.ok!==!0)return null;let b=go(d.returnOrigin);return b?{returnOrigin:b,screenshotsEnabled:d.elementScreenshotsEnabled!==!1}:(ce("This ARCY server has not been told where its dashboard lives, so a pick would have nowhere to go. Set FRONTEND_DASHBOARD_URL and try again."),null)}catch{return null}},a=new Promise(l=>{try{s(()=>l(null),i);}catch{}});return Promise.race([f(),a])}function go(e){if(typeof e!="string"||e.length===0)return null;try{let{origin:t}=new URL(e);return t&&t!=="null"?t:null}catch{return null}}function mn(e,t,n,r){return new Promise(o=>{let i=false,s=null,f=p=>{i||(i=true,s&&(s.onload=null,s.onerror=null),o(p));},a=false,l=p=>{a||(a=true,ce(p));},d=()=>{let p;try{p=e[wt];}catch{return l("The element picker registration could not be read. Design mode is off."),null}if(!p)return null;if(typeof p.mount!="function")return l("The element picker registered something unusable. Design mode is off."),null;let g;try{g=p.contract;}catch{g=void 0;}return g!==2?(l(`The element picker on the CDN speaks contract ${typeof g=="number"?g:"unknown"}, this arcy.js speaks ${2}. Update arcy.js to use design mode.`),null):p},b=p=>{try{let g=d();!g&&!a&&p(),f(g);}catch{f(null);}},v=false;try{v=e[wt]!==void 0;}catch{v=true;}if(v){b(()=>{});return}try{let p=e.document;s=p.createElement("script"),ve(s),s.async=!0,s.src=`${t}/${Jt}`;let g=s.src;s.onload=()=>b(()=>ce("The element picker loaded but did not register. Design mode is off.")),s.onerror=()=>{try{ce(`Failed to load ${g}. Design mode is off. If this page sets a Content-Security-Policy, it must allow scripts from ${t}.`);}catch{}f(null);},(p.head||p.documentElement).appendChild(s);}catch(p){ce(`The element picker could not load. ${String(p)}`),f(null);return}try{r(()=>{i||ce("The element picker did not load in time. Design mode is off."),f(null);},n);}catch{}})}function yo(e){try{let t=e.location.pathname;return typeof t!="string"||!t.startsWith("/")?"/":ke(t)}catch{return "/"}}function bo(e){try{let t=e.opener;return !!t&&!t.closed}catch{return false}}function Je(e,t,n){try{let r=e.opener;if(!r||r.closed){h("The ARCY dashboard window is gone, so that pick could not be sent.");return}r.postMessage(n,t);}catch(r){h(`That pick could not be sent to the ARCY dashboard. ${String(r)}`);}}async function hn(e){try{let{win:t,token:n,apiBase:r,fetchImpl:o,onVerified:i,loadChunk:s,loadTimeoutMs:f=uo,setTimeoutImpl:a=(C,O)=>setTimeout(C,O)}=e,l=po(t.location.search,t.location.hash);if(!l)return "no_nonce";if(mo(t),!bo(t))return ce("This page was not opened by the ARCY dashboard, so a picked element would have nowhere to go. If you did start it from the flow builder, this site is severing the link back: a Cross-Origin-Opener-Policy header on this page (helmet sets one by default) does exactly that. Serve this page with Cross-Origin-Opener-Policy: unsafe-none while you author."),"no_opener";let d=await ho({apiBase:r,token:n,nonce:l,fetchImpl:o,setTimeoutImpl:a});if(!d)return ce("The design-mode link is invalid, expired, or could not be verified. It is single-use and short-lived, so a reload spends it. Check that this page carries the same environment Token as the flow you are editing, then open the picker again from the dashboard."),"rejected";try{i();}catch{}let b=await s(t,f,a);if(!b)return "load_failed";let{returnOrigin:v,screenshotsEnabled:p}=d;return b.mount({screenshotsEnabled:p,onPick:(C,O)=>{Je(t,v,{type:rn,protocol:Ne,target:C,route:yo(t),matchCount:O});},onScreenshot:C=>{Je(t,v,{type:sn,protocol:Ne,screenshot:C});},onExit:()=>{Je(t,v,{type:on,protocol:Ne});}})?(Je(t,v,{type:nn,protocol:Ne}),"active"):(ce("The element picker could not start. Design mode is off."),"mount_failed")}catch(t){return ce(`Design mode could not start. ${String(t)}`),"load_failed"}}var xt={getItem:()=>null,setItem:()=>{},removeItem:()=>{}};function Q(e){return e?{getItem(t){try{return e.getItem(t)}catch{return null}},setItem(t,n){try{e.setItem(t,n);}catch{}},removeItem(t){try{e.removeItem(t);}catch{}}}:xt}function ue(){try{let e=globalThis.localStorage;return Q(e)}catch{return xt}}function _e(){try{let e=globalThis.sessionStorage;return Q(e)}catch{return xt}}function Z(e,t){let n=e.getItem(t);if(!n)return null;try{let r=JSON.parse(n);return !r||typeof r!="object"||Array.isArray(r)?null:r}catch{return null}}function J(e,t,n){try{e.setItem(t,JSON.stringify(n));}catch{}}var wo="arcy.preview.";function Qe(e,t=_e()){try{return Q(t).getItem(wo+e)!==null}catch{return false}}var kt="arcy_preview",vo=1,So="/api/v1/sdk/flows/preview/verify",Eo=1e4;function To(e,t){return Ct(e)??Ct(t)}function Ct(e){if(!e)return null;try{let t=new URLSearchParams(e.charAt(0)==="#"?e.slice(1):e).get(kt);return t&&t.length>0?t:null}catch{return null}}function xo(e){try{let t=new URL(e.location.href),n=t.searchParams.has(kt),r=Ct(t.hash)!==null;if(!n&&!r)return;n&&t.searchParams.delete(kt),r&&(t.hash=""),e.history.replaceState(e.history.state,"",t.toString());}catch{}}function gn(e,t){try{let n=To(e.location.search,e.location.hash);return n?(xo(e),{kind:"nonce",nonce:n}):Qe(t)?{kind:"pending"}:null}catch{return null}}async function yn(e){let{apiBase:t,token:n,nonce:r,sessionToken:o,userTraits:i,fetchImpl:s,timeoutMs:f=Eo,setTimeoutImpl:a=(C,O)=>setTimeout(C,O)}=e;if(!s)return null;let l=C=>{h(C);try{qe(C);}catch{}return null},d=async()=>{try{let C=await s(`${t}${So}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({token:r,...o?{sessionToken:o}:{},...i&&Object.keys(i).length>0?{userTraits:i}:{}}),credentials:"omit"});if(!C.ok)return l("ARCY could not verify this preview link. Close this tab and press Preview in the dashboard again.");let O=await C.json();return O?.ok!==!0||O.flow===void 0||O.flow===null?l("ARCY could not verify this preview link. Close this tab and press Preview in the dashboard again."):O.protocol!==vo?l("This page runs an older version of arcy.js than the dashboard expects. The preview cannot run until the script updates."):O.flow}catch{return l("ARCY could not reach its server to start this preview. Check the connection and press Preview again.")}},b=false,v,p=new Promise(C=>{try{v=a(()=>{b||(b=!0,C(l("ARCY took too long to verify this preview link. Close this tab and press Preview in the dashboard again.")));},f);}catch{}}),g=await Promise.race([d().then(C=>(b=true,C)),p]);try{v!==void 0&&clearTimeout(v);}catch{}return g}var At="https://api.arcyai.com",ko="/api/v1/sdk/session/init";var Co=["ON","REQUIRE_CONSENT","OFF"];function Ao(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,n=t.behavioralTelemetry,r=t.effectiveCustomization,o=t.widget,i=t.identity,s=i&&typeof i=="object"&&!Array.isArray(i)?i.accepted:void 0;return {sessionToken:typeof t.sessionToken=="string"?t.sessionToken:null,behavioralTelemetry:typeof n=="string"&&Co.indexOf(n)!==-1?n:null,customization:r&&typeof r=="object"&&!Array.isArray(r)?r:null,widget:o&&typeof o=="object"&&!Array.isArray(o)?o:null,identityAccepted:typeof s=="boolean"?s:null}}function bn(e){let{token:t,apiBase:n=At,setTimeoutImpl:r=(T,w)=>setTimeout(T,w),now:o=()=>Date.now(),retryDelayMs:i=2e3,attemptTimeoutMs:s=5e3,failureCooldownMs:f=3e4}=e,a=e.fetchImpl!==void 0?e.fetchImpl:typeof fetch<"u"?fetch.bind(globalThis):null,l=`${n}${ko}`,d=null,b=null,v=null,p=null,g=0;function C(T){let w={publicKey:t,sessionId:T.sessionId};return T.visitorId!==void 0&&(w.visitorId=T.visitorId),T.userId!==void 0&&(w.userId=T.userId),T.userHash!==void 0&&(w.userHash=T.userHash),T.userTraits!==void 0&&(w.userTraits=T.userTraits),T.uiLanguage!==void 0&&(w.uiLanguage=T.uiLanguage),T.contentLocale!==void 0&&(w.contentLocale=T.contentLocale),T.viewerLocale!==void 0&&(w.viewerLocale=T.viewerLocale),T.route!==void 0&&(w.route=T.route),T.sessionContext!==void 0&&(w.sessionContext=T.sessionContext),JSON.stringify(w)}async function O(T){if(!a)return {ok:false,reason:"unusable"};let w;try{w=await a(l,{method:"POST",headers:{"Content-Type":"application/json"},body:T,credentials:"omit"});}catch{return null}if(w.status>=500)return null;if(!w.ok)return {ok:false,reason:"rejected"};let _;try{_=await w.json();}catch{return {ok:false,reason:"unusable"}}let M=Ao(_);return M?{ok:true,config:M}:{ok:false,reason:"unusable"}}function k(T){return new Promise(w=>{try{r(()=>w(),T);}catch{w();}})}function Y(T){return Promise.race([O(T),k(s).then(()=>null)])}async function N(T){let w=await Y(T);return w||(await k(i),await Y(T)??{ok:false,reason:"network"})}return {async sync(T){let w=C(T);if(p&&w===b)return p;if(!p&&w===b&&d)return {ok:true,config:d};if(v&&v.json===w&&o()-v.at<f)return {ok:false,reason:"network"};b=w;let _=++g,M=N(w).then(S=>(_===g&&(S.ok?(d=S.config,v=null):(v={json:w,at:o()},b===w&&(b=null))),p===M&&(p=null),S));return p=M,M},config:()=>d}}var _t="__arcyChat";var wn=["image/png","image/jpeg","image/webp"],It="--_arcy-font-key",vn="arcy-chat-policy",Sn="arcy-bar-tray",Ze={historyTitle:"Recent chats",historyEmpty:"No conversations yet.",newChat:"New chat",flowsTitle:"What I can do",flowsEmpty:"Nothing to run yet.",collapse:"Collapse",back:"Back",closeSheet:"Close",settingsTitle:"Settings",dockChat:"Dock to the corner",dockChatHint:"Shrink ARCY to a button in the bottom-right corner.",language:"Language",openChat:"Open chat",moveBar:"Move the chat bar",send:"Send",flowRunning:"Running",flowStep:"Step {step} of {total}",flowStop:"Stop",flowFailed:"Sorry, I could not finish that for you this time. You can ask me here and I will help you do it.",attachMenu:"Add",attachImage:"Attach an image",removeImage:"Remove image",imageTooLarge:"That image is too large. Each image must be under 5 MB.",imageWrongType:"That file type is not supported. Use PNG, JPEG or WEBP.",imageTooMany:"You can attach up to 3 images.",imageFailed:"That image could not be uploaded. Please try again.",likeAnswer:"Good answer",dislikeAnswer:"Bad answer",answering:"Answering",aiDisclaimer:"{app} is AI and can make mistakes",consentNotice:"Your messages are processed to answer your question.",consentWithPolicy:"{policy}",disclaimerJoin:" \xB7 ",privacyPolicy:"Privacy Policy",poweredBy:"Powered by ARCY",genericError:"Something went wrong. Please try again.",userCapReached:"You've reached today's limit for questions. Please try again tomorrow.",imageConversation:"Image",searchedSourcesLabel:"Searched {count} sources",sourcesLabel:"Sources:",flowOfferHint:"You can do this in one click with the Quick Flow below.",fillConfirm:"Confirm",fillYes:"Yes",fillNo:"No",fillRequired:"This field needs an answer.",fillInvalidNumber:"Please enter a number.",fillNumberTooSmall:"Please enter {min} or more.",fillNumberTooLarge:"Please enter {max} or less.",fillInvalidEmail:"Please enter a valid email address.",fillInvalidUrl:"Please enter a valid link.",fillInvalidDate:"Please enter a valid date.",fillInvalidTime:"Please enter a valid time.",fillDateTooEarly:"Please pick {min} or later.",fillDateTooLate:"Please pick {max} or earlier.",fillTooLong:"Please keep it under {max} characters.",fillInvalidOption:"Please pick one of the options.",fillInvalid:"That does not look right. Please try again."};var Rt="https://cdn.arcyai.com";var _o=15e3;function Tn(e,t,n,r){return new Promise(o=>{let i=false,s=null,f=p=>{i||(i=true,s&&(s.onload=null,s.onerror=null),o(p));},a=false,l=p=>{a||(a=true,h(p));},d=()=>{let p;try{p=e[_t];}catch{return l("The chat panel registration could not be read. The panel will not open."),null}if(!p)return null;if(typeof p.mount!="function")return l("The chat panel registered something unusable. The panel will not open."),null;let g;try{g=p.contract;}catch{g=void 0;}return g!==4?(l(`The chat panel on the CDN speaks contract ${typeof g=="number"?g:"unknown"}, this arcy.js speaks ${4}. Update arcy.js to open the chat panel.`),null):p},b=p=>{try{let g=d();!g&&!a&&p(),f(g);}catch{f(null);}},v=false;try{v=e[_t]!==void 0;}catch{v=true;}if(v){b(()=>{});return}try{let p=e.document;s=p.createElement("script"),ve(s),s.async=!0,s.src=`${t}/${Qt}`;let g=s.src;s.onload=()=>b(()=>h("The chat panel loaded but did not register. The panel will not open.")),s.onerror=()=>{try{h(`Failed to load ${g}. The chat panel will not open. If this page sets a Content-Security-Policy, it must allow scripts from ${t}.`);}catch{}f(null);},(p.head||p.documentElement).appendChild(s);}catch(p){h(`The chat panel could not load. ${String(p)}`),f(null);return}try{r(()=>{i||h("The chat panel did not load in time."),f(null);},n);}catch{}})}function xn(e){let{root:t,host:n,win:r=typeof window<"u"?window:void 0,loadChunk:o,loadTimeoutMs:i=_o,setTimeoutImpl:s=(L,B)=>setTimeout(L,B),onRequestClose:f,bar:a,apiBase:l,getSessionToken:d,getSessionId:b,getRoute:v,getMaxHeightPercent:p,onStartFlow:g,publicKey:C,getConversationId:O,setConversationId:k,touchConversation:Y,getVisitorId:N,onOrgCapExceeded:T,onStopFlow:w,track:_,getWidget:M,onSelectLocale:S}=e,I=t!==n,P=null,V=null,D=false,U=false;async function K(){if(!(P||D))return V||(V=(async()=>{if(r)try{let L=await o(r,i,s);if(!L||D)return;let B={root:t,host:n,isolated:I,onRequestClose:f,bar:a,apiBase:l,getSessionToken:d,getSessionId:b,getRoute:v,getMaxHeightPercent:p,onStartFlow:g,publicKey:C,getConversationId:O,setConversationId:k,touchConversation:Y,getVisitorId:N,onOrgCapExceeded:T,onStopFlow:w,track:_,getWidget:M,onSelectLocale:S};P=L.mount(B),P||h("The chat panel could not start.");}catch(L){h(`The chat panel could not load. ${String(L)}`);}finally{V=null;}})(),V)}return {async open(){if(!D&&(U=true,await K(),!(!U||D)))try{P?.open();}catch(L){h(`The chat panel could not open. ${String(L)}`);}},close(){U=false;try{P?.close();}catch(L){h(`The chat panel could not close. ${String(L)}`);}},destroy(){D=true,U=false;let L=P;P=null;try{L?.destroy();}catch(B){h(`The chat panel could not be removed. ${String(B)}`);}},reposition(){try{P?.reposition?.();}catch(L){h(`The chat panel could not move. ${String(L)}`);}},refreshChrome(){try{P?.refreshChrome?.();}catch(L){h(`The chat panel could not apply its texts. ${String(L)}`);}},async promptFill(L){if(D||(await K(),D||!P?.promptFill))return null;try{return await P.promptFill(L)}catch(B){return h(`The flow's question could not be shown. ${String(B)}`),null}},cancelFill(){try{P?.cancelFill?.();}catch(L){h(`The flow's question could not be withdrawn. ${String(L)}`);}},async showFlowFailure(){if(!D&&(U=true,await K(),!(!U||D||!P?.showFlowFailure)))try{P.showFlowFailure();}catch(L){h(`The flow's failure notice could not be shown. ${String(L)}`);}}}}var Pt="__arcyFlow";var Io="arcy.flow.";function Ro(e){return typeof e.flowId=="string"&&e.flowId.length>0&&typeof e.currentStepCvid=="string"&&e.currentStepCvid.length>0&&typeof e.flowSessionId=="string"&&e.flowSessionId.length>0&&typeof e.startedAt=="number"}function kn(e,{store:t=ue()}={}){let n=Q(t),r=Io+e;return {read(){let o=Z(n,r);return !o||!Ro(o)?null:{flowId:o.flowId,currentStepCvid:o.currentStepCvid,flowSessionId:o.flowSessionId,startedAt:o.startedAt}},save(o){J(n,r,o);},clear(){n.removeItem(r);}}}var An="https://cdn.arcyai.com";var Po=15e3;function _n(e,t,n,r){return new Promise(o=>{let i=false,s=null,f=p=>{i||(i=true,s&&(s.onload=null,s.onerror=null),o(p));},a=false,l=p=>{a||(a=true,h(p));},d=()=>{let p;try{p=e[Pt];}catch{return l("The flow engine registration could not be read. The flow will not start."),null}if(!p)return null;if(typeof p.mount!="function")return l("The flow engine registered something unusable. The flow will not start."),null;let g;try{g=p.contract;}catch{g=void 0;}return g!==2?(l(`The flow engine on the CDN speaks contract ${typeof g=="number"?g:"unknown"}, this arcy.js speaks ${2}. Update arcy.js to run flows.`),null):p},b=p=>{try{let g=d();!g&&!a&&p(),f(g);}catch{f(null);}},v=false;try{v=e[Pt]!==void 0;}catch{v=true;}if(v){b(()=>{});return}try{let p=e.document;s=p.createElement("script"),ve(s),s.async=!0,s.src=`${t}/${Zt}`;let g=s.src;s.onload=()=>b(()=>h("The flow engine loaded but did not register. The flow will not start.")),s.onerror=()=>{try{h(`Failed to load ${g}. The flow will not start. If this page sets a Content-Security-Policy, it must allow scripts from ${t}.`);}catch{}f(null);},(p.head||p.documentElement).appendChild(s);}catch(p){h(`The flow engine could not load. ${String(p)}`),f(null);return}try{r(()=>{i||h("The flow engine did not load in time."),f(null);},n);}catch{}})}function In(e){let{win:t=typeof window<"u"?window:void 0,loadChunk:n,loadTimeoutMs:r=Po,setTimeoutImpl:o=(d,b)=>setTimeout(d,b),context:i}=e,s=null,f=null,a=false;async function l(){if(!(s||a))return f||(f=(async()=>{if(t)try{let d=await n(t,r,o);if(!d||a)return;s=d.mount({...i,doc:t.document,win:t}),s||h("The flow engine could not start.");}catch(d){h(`The flow engine could not load. ${String(d)}`);}finally{f=null;}})(),f)}return {async start(d){if(!a&&(await l(),!a))try{await s?.start(d);}catch(b){h(`The flow could not start. ${String(b)}`);}},async resume(){if(a||!kn(i.token).read()||(await l(),a||!s))return false;try{return await s.resume()}catch(b){return h(`The flow could not resume. ${String(b)}`),false}},async startPreview(d){if(!a&&(await l(),!a))try{await s?.startPreview?.(d);}catch(b){h(`The preview could not start. ${String(b)}`);}},async resumePreview(){if(a||!Qe(i.token)||(await l(),a||!s?.resumePreview))return false;try{return await s.resumePreview()}catch(d){return h(`The preview could not resume. ${String(d)}`),false}},stop(){if(!a)try{s?.stop?.();}catch(d){h(`The flow could not be stopped. ${String(d)}`);}},destroy(){a=true;let d=s;s=null;try{d?.destroy();}catch(b){h(`The flow engine could not be removed. ${String(b)}`);}}}}function Lt(e){let t=e.dataTransfer;if(!t)return false;let n=t.types;if(!n)return false;for(let r=0;r<n.length;r+=1)if(n[r]==="Files")return true;return false}function Rn(e){let t=e.dataTransfer;return Array.from(t?.files??[])}var Pn=`
5
5
  [data-tip] {
@@ -3075,9 +3075,6 @@ function mount(context) {
3075
3075
  flowOffers: result.flowsOffered
3076
3076
  });
3077
3077
  context.touchConversation?.();
3078
- if (result.isFallback) {
3079
- context.track?.("fallback_triggered", {}, { question: text });
3080
- }
3081
3078
  for (const offer of result.flowsOffered) {
3082
3079
  context.track?.(
3083
3080
  "flow_suggested",
@@ -398,6 +398,21 @@ var ActiveRun = class {
398
398
  /** ADR 0166: true while a fill question is awaiting the end user's
399
399
  * answer. Suspends trigger evaluation for the duration. */
400
400
  this.inputPending = false;
401
+ /**
402
+ * True from the moment a step is entered until its own action has
403
+ * settled. Suspends trigger evaluation for exactly that window, the same
404
+ * posture `inputPending` takes around a fill question.
405
+ *
406
+ * **This is what makes a step's type mean anything.** The builder's
407
+ * default condition for a new trigger is `always_true` with no wait
408
+ * (`flow-draft.ts`'s `newTrigger`), so the ordinary way to say "then go to
409
+ * step 2" is a trigger that is true the instant the step mounts. Without
410
+ * this flag `startWatch`'s initial pass fired that trigger before the step
411
+ * had clicked, filled or navigated anything, and the action never ran at
412
+ * all: a two-step flow counted to step 2 and quietly ended, having done
413
+ * nothing. A step acts first; its triggers are how it is left.
414
+ */
415
+ this.actionPending = false;
401
416
  /** Extra capture-phase listeners `startWatch` installs alongside the
402
417
  * click listener (D1297): typing, focus moves and checkbox flips change
403
418
  * nothing a MutationObserver can see, yet `text_input`, `is_focused`
@@ -534,6 +549,7 @@ var ActiveRun = class {
534
549
  }
535
550
  this.activityListeners = [];
536
551
  this.inputPending = false;
552
+ this.actionPending = false;
537
553
  this.trueSince.clear();
538
554
  this.clicked.clear();
539
555
  this.initialValues.clear();
@@ -623,7 +639,7 @@ var ActiveRun = class {
623
639
  }
624
640
  checkTriggers(step, ctx) {
625
641
  if (this.stopped) return;
626
- if (this.inputPending) return;
642
+ const mayFire = !this.inputPending && !this.actionPending;
627
643
  const now = this.now();
628
644
  for (const trigger of [...step.triggers].sort((a, b) => a.position - b.position)) {
629
645
  const parsed = this.parsedTrigger(trigger);
@@ -637,7 +653,7 @@ var ActiveRun = class {
637
653
  const since = this.trueSince.get(key) ?? now;
638
654
  if (!this.trueSince.has(key)) this.trueSince.set(key, since);
639
655
  const waitMs = (trigger.waitSeconds ?? 0) * 1e3;
640
- if (now - since >= waitMs) {
656
+ if (now - since >= waitMs && mayFire) {
641
657
  this.fireTrigger(trigger);
642
658
  return;
643
659
  }
@@ -723,8 +739,7 @@ var ActiveRun = class {
723
739
  }
724
740
  this.checkTriggers(step, this.conditionContext());
725
741
  }
726
- async runExecutor(step) {
727
- const startIndex = this.stepIndex;
742
+ async runExecutor(step, startIndex) {
728
743
  try {
729
744
  const outcome = await this.executor(step, {
730
745
  doc: this.doc,
@@ -736,6 +751,7 @@ var ActiveRun = class {
736
751
  }
737
752
  });
738
753
  if (this.stopped || this.stepIndex !== startIndex) return;
754
+ this.actionPending = false;
739
755
  if (outcome.status === "advance") {
740
756
  this.emit("flow_step_completed");
741
757
  if (step.isCompletion) {
@@ -780,11 +796,14 @@ var ActiveRun = class {
780
796
  );
781
797
  return;
782
798
  }
799
+ this.scheduleCheck(step);
783
800
  } catch {
801
+ this.actionPending = false;
784
802
  }
785
803
  }
786
804
  enterStep() {
787
805
  const step = this.currentStep();
806
+ const stepIndex = this.stepIndex;
788
807
  if (!step || this.stopped) {
789
808
  this.finish(step ? "completed" : "error", step ? void 0 : { reason: "missing_step" });
790
809
  return;
@@ -799,8 +818,9 @@ var ActiveRun = class {
799
818
  });
800
819
  const begin = () => {
801
820
  if (this.stopped) return;
821
+ this.actionPending = true;
802
822
  this.startWatch(step);
803
- void this.runExecutor(step);
823
+ void this.runExecutor(step, stepIndex);
804
824
  };
805
825
  this.waitForPageReady(begin);
806
826
  }
package/dist/index.cjs CHANGED
@@ -3992,9 +3992,6 @@ function mount(context) {
3992
3992
  flowOffers: result.flowsOffered
3993
3993
  });
3994
3994
  context.touchConversation?.();
3995
- if (result.isFallback) {
3996
- context.track?.("fallback_triggered", {}, { question: text });
3997
- }
3998
3995
  for (const offer of result.flowsOffered) {
3999
3996
  context.track?.(
4000
3997
  "flow_suggested",
@@ -6027,6 +6024,21 @@ var init_runtime = __esm({
6027
6024
  /** ADR 0166: true while a fill question is awaiting the end user's
6028
6025
  * answer. Suspends trigger evaluation for the duration. */
6029
6026
  this.inputPending = false;
6027
+ /**
6028
+ * True from the moment a step is entered until its own action has
6029
+ * settled. Suspends trigger evaluation for exactly that window, the same
6030
+ * posture `inputPending` takes around a fill question.
6031
+ *
6032
+ * **This is what makes a step's type mean anything.** The builder's
6033
+ * default condition for a new trigger is `always_true` with no wait
6034
+ * (`flow-draft.ts`'s `newTrigger`), so the ordinary way to say "then go to
6035
+ * step 2" is a trigger that is true the instant the step mounts. Without
6036
+ * this flag `startWatch`'s initial pass fired that trigger before the step
6037
+ * had clicked, filled or navigated anything, and the action never ran at
6038
+ * all: a two-step flow counted to step 2 and quietly ended, having done
6039
+ * nothing. A step acts first; its triggers are how it is left.
6040
+ */
6041
+ this.actionPending = false;
6030
6042
  /** Extra capture-phase listeners `startWatch` installs alongside the
6031
6043
  * click listener (D1297): typing, focus moves and checkbox flips change
6032
6044
  * nothing a MutationObserver can see, yet `text_input`, `is_focused`
@@ -6163,6 +6175,7 @@ var init_runtime = __esm({
6163
6175
  }
6164
6176
  this.activityListeners = [];
6165
6177
  this.inputPending = false;
6178
+ this.actionPending = false;
6166
6179
  this.trueSince.clear();
6167
6180
  this.clicked.clear();
6168
6181
  this.initialValues.clear();
@@ -6252,7 +6265,7 @@ var init_runtime = __esm({
6252
6265
  }
6253
6266
  checkTriggers(step, ctx) {
6254
6267
  if (this.stopped) return;
6255
- if (this.inputPending) return;
6268
+ const mayFire = !this.inputPending && !this.actionPending;
6256
6269
  const now = this.now();
6257
6270
  for (const trigger of [...step.triggers].sort((a, b) => a.position - b.position)) {
6258
6271
  const parsed = this.parsedTrigger(trigger);
@@ -6266,7 +6279,7 @@ var init_runtime = __esm({
6266
6279
  const since = this.trueSince.get(key) ?? now;
6267
6280
  if (!this.trueSince.has(key)) this.trueSince.set(key, since);
6268
6281
  const waitMs = (trigger.waitSeconds ?? 0) * 1e3;
6269
- if (now - since >= waitMs) {
6282
+ if (now - since >= waitMs && mayFire) {
6270
6283
  this.fireTrigger(trigger);
6271
6284
  return;
6272
6285
  }
@@ -6352,8 +6365,7 @@ var init_runtime = __esm({
6352
6365
  }
6353
6366
  this.checkTriggers(step, this.conditionContext());
6354
6367
  }
6355
- async runExecutor(step) {
6356
- const startIndex = this.stepIndex;
6368
+ async runExecutor(step, startIndex) {
6357
6369
  try {
6358
6370
  const outcome = await this.executor(step, {
6359
6371
  doc: this.doc,
@@ -6365,6 +6377,7 @@ var init_runtime = __esm({
6365
6377
  }
6366
6378
  });
6367
6379
  if (this.stopped || this.stepIndex !== startIndex) return;
6380
+ this.actionPending = false;
6368
6381
  if (outcome.status === "advance") {
6369
6382
  this.emit("flow_step_completed");
6370
6383
  if (step.isCompletion) {
@@ -6409,11 +6422,14 @@ var init_runtime = __esm({
6409
6422
  );
6410
6423
  return;
6411
6424
  }
6425
+ this.scheduleCheck(step);
6412
6426
  } catch {
6427
+ this.actionPending = false;
6413
6428
  }
6414
6429
  }
6415
6430
  enterStep() {
6416
6431
  const step = this.currentStep();
6432
+ const stepIndex = this.stepIndex;
6417
6433
  if (!step || this.stopped) {
6418
6434
  this.finish(step ? "completed" : "error", step ? void 0 : { reason: "missing_step" });
6419
6435
  return;
@@ -6428,8 +6444,9 @@ var init_runtime = __esm({
6428
6444
  });
6429
6445
  const begin = () => {
6430
6446
  if (this.stopped) return;
6447
+ this.actionPending = true;
6431
6448
  this.startWatch(step);
6432
- void this.runExecutor(step);
6449
+ void this.runExecutor(step, stepIndex);
6433
6450
  };
6434
6451
  this.waitForPageReady(begin);
6435
6452
  }
package/dist/index.js CHANGED
@@ -4722,7 +4722,7 @@ var bundledChunks = {
4722
4722
  cdnBase: null,
4723
4723
  loadChat: (win, timeoutMs, setTimeoutImpl) => importChunk(
4724
4724
  win,
4725
- () => import('./chat-VOYR3S25.js'),
4725
+ () => import('./chat-NCTVDXR5.js'),
4726
4726
  CHAT_GLOBAL,
4727
4727
  CHAT_CONTRACT,
4728
4728
  "chat panel",
@@ -4731,7 +4731,7 @@ var bundledChunks = {
4731
4731
  ),
4732
4732
  loadFlow: (win, timeoutMs, setTimeoutImpl) => importChunk(
4733
4733
  win,
4734
- () => import('./flow-M7W3H3C5.js'),
4734
+ () => import('./flow-GATJGDCR.js'),
4735
4735
  FLOW_GLOBAL,
4736
4736
  FLOW_CONTRACT,
4737
4737
  "flow engine",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arcy.js",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "ARCY — the universal JavaScript utility for embedding an AI agent that talks to, learns from, and acts on behalf of your users.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,3 +0,0 @@
1
- (function(){'use strict';/* arcy.js — https://arcyai.com */
2
- function I(t){if(t.parentElement!==null)return t.parentElement;let e=t.parentNode;return e!==null&&"host"in e?e.host:null}function nt(t,e){let n=e;for(;n!==null;){if(n===t)return true;n=I(n);}return false}var rt=100;function b(t,e=0){let n=[],r=t.querySelectorAll("*");for(let o=0;o<r.length;o+=1){let i=r[o];n.push(i),i.shadowRoot!==null&&e<rt&&n.push(...b(i.shadowRoot,e+1));}return n}function H(t,e,n=0){let r=Array.from(t.querySelectorAll(e)),o=t.querySelectorAll("*");for(let i=0;i<o.length;i+=1){let s=o[i];s.shadowRoot!==null&&n<rt&&r.push(...H(s.shadowRoot,e,n+1));}return r}var ot=[/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,/\b\d{3}-\d{2}-\d{4}\b/g,/\b\d(?:[ -]?\d){12,18}\b/g],x="[masked]";function W(t){return ot.some(e=>(e.lastIndex=0,e.test(t)))}var V=4096,Ct=100,At=64;function k(t){if(!t)return;let e=t.slice(0,V);if(t.length>V){let r=e.search(/\s\S*$/);e=r===-1?e.slice(0,V-Ct):e.slice(0,r);}let n=e.replace(/\s+/g," ").trim();if(n){for(let r of ot)n=n.replace(r,x);return n.slice(0,80)}}function it(t){return !(t.length===0||t.length>64||t.includes(":")||t.startsWith("radix-")||/^\d+$/.test(t)||/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t))}var Lt=new Set(["button","input","select","textarea","label","summary"]),Mt=new Set(["button","link","menuitem","tab","option"]);function R(t){let e=t.tagName.toLowerCase();if(Lt.has(e)||e==="a"&&t.hasAttribute("href"))return true;let n=t.getAttribute("role");if(n!==null&&Mt.has(n))return true;let r=t.getAttribute("contenteditable");return r===""||r==="true"}var Nt=["data-testid","data-test","data-cy","id","name","aria-label"],Ot=["data-testid","data-test","data-cy"],Pt=64;function Dt(t){for(let e of Ot){let n=t.getAttribute(e);if(n===null)continue;let r=n.trim();if(!(r===""||r.length>Pt)&&!W(r))return r}}var Ht=new Set(["navigation","main","banner","contentinfo","search","form","region","dialog"]);function Vt(t){let e=I(t);for(;e!==null;){let n=e.tagName.toLowerCase();if(n==="body"||n==="html")return;for(let o of Nt){let i=e.getAttribute(o);if(i===null||o==="id"&&!it(i))continue;let s=k(i);if(s!==void 0)return {tag:n,attr:o,value:s}}let r=e.getAttribute("role");if(r!==null&&Ht.has(r))return {tag:n,attr:"role",value:r};e=I(e);}}function Wt(t){let e=0,n=t.previousElementSibling;for(;n!==null;)n.tagName===t.tagName&&(e+=1),n=n.previousElementSibling;return e}function C(t){let e={tag:t.tagName.toLowerCase(),siblingIndex:Wt(t)},n=k(t.textContent);n!==void 0&&(e.text=n);let r=k(t.getAttribute("aria-label"));r!==void 0&&(e.ariaLabel=r);let o=k(t.getAttribute("placeholder"));o!==void 0&&(e.placeholder=o);let i=t.getAttribute("id");i!==null&&it(i)&&!W(i)&&(e.id=i);let s=t.getAttribute("role");if(s!==null){let u=s.trim();u!==""&&u.length<=At&&!W(u)&&(e.role=u);}let l=Dt(t);l!==void 0&&(e.testId=l);let a=Vt(t);return a!==void 0&&(e.ancestorTag=a.tag,e.ancestorAttr=a.attr,e.ancestorValue=a.value),e}function Kt(t){return t.getClientRects().length>0}var $t=50,Bt=40,Ut=10,jt=15,Gt=15,Xt=10,Jt=10,Yt=10,zt=5,qt=5,Zt=.6,Qt=.7,te={1:.3,2:.45,3:.6,4:.75,5:.9};function A(t){return t.split(x).join(" ").replace(/\s+/g," ").trim()}function ee(t,e){if(e===void 0)return 0;let n=A(t),r=A(e);return n===""||r===""?0:r===n?1:r.includes(n)||n.includes(r)?Zt:0}function T(t,e){return e===t?1:0}function K(t){return t.includes(x)&&A(t)===""}function ne(t,e,n){let r=0,o=0,i=(s,l)=>{r+=s,o+=s*l;};if(t.testId!==void 0&&i($t,T(t.testId,e.testId)),t.text!==void 0&&A(t.text)!==""&&i(n?Ut:Bt,ee(t.text,e.text)),t.ariaLabel!==void 0&&!K(t.ariaLabel)&&i(jt,T(t.ariaLabel,e.ariaLabel)),t.placeholder!==void 0&&!K(t.placeholder)&&i(Jt,T(t.placeholder,e.placeholder)),t.id!==void 0&&i(Gt,T(t.id,e.id)),t.role!==void 0&&i(zt,T(t.role,e.role)),i(Xt,e.tag===t.tag?1:0),i(qt,e.siblingIndex===t.siblingIndex?1:0),t.ancestorAttr!==void 0&&t.ancestorValue!==void 0&&!K(t.ancestorValue)){let s=0;e.ancestorAttr===t.ancestorAttr&&e.ancestorValue===t.ancestorValue&&(s=e.ancestorTag===t.ancestorTag?1:Qt),i(Yt,s);}return r===0?0:o/r}function re(t,e){if(t.selector===null)return null;try{return H(e,t.selector)}catch{return null}}function oe(t,e){let n=t.core.tag,r=[];for(let o of b(e))(o.tagName.toLowerCase()===n||R(o))&&r.push(o);return r}function st(t,e){if(e.length===0)return {status:"not_found",reason:"no_candidates",matchCount:0};let n=te[t.precision],r=false,o=[];for(let s of e){if(!Kt(s))continue;r=true;let l=ne(t.core,C(s),t.dynamicText);l>=n&&o.push({element:s,score:l});}if(o=o.filter((s,l)=>{let a=o[l+1];return a===void 0?true:!(nt(s.element,a.element)&&s.score<=a.score)}),o.length===0)return {status:"not_found",reason:r?"below_threshold":"not_visible",matchCount:0};let i=t.ordinal>=1?o[t.ordinal-1]:void 0;return i===void 0?{status:"not_found",reason:"ordinal_out_of_range",matchCount:o.length}:{status:"matched",element:i.element,score:i.score,matchCount:o.length}}function g(t,e){try{let n=re(t,e);if(n!==null&&n.length>0){let r=st(t,n);if(r.status==="matched"||r.reason==="ordinal_out_of_range")return r}return st(t,oe(t,e))}catch{return {status:"not_found",reason:"error",matchCount:0}}}var ie=40;function lt(t=document){try{let e=b(t),n=[];for(let r of e){if(n.length>=ie)break;R(r)&&n.push(C(r));}return n}catch{return []}}var $={getItem:()=>null,setItem:()=>{},removeItem:()=>{}};function y(t){return t?{getItem(e){try{return t.getItem(e)}catch{return null}},setItem(e,n){try{t.setItem(e,n);}catch{}},removeItem(e){try{t.removeItem(e);}catch{}}}:$}function at(){try{let t=globalThis.localStorage;return y(t)}catch{return $}}function ut(){try{let t=globalThis.sessionStorage;return y(t)}catch{return $}}function L(t,e){let n=t.getItem(e);if(!n)return null;try{let r=JSON.parse(n);return !r||typeof r!="object"||Array.isArray(r)?null:r}catch{return null}}function M(t,e,n){try{t.setItem(e,JSON.stringify(n));}catch{}}var se=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function B(t){let e=typeof globalThis<"u"?globalThis.crypto:void 0;if(e&&typeof e.randomUUID=="function")try{let o=e.randomUUID();if(se.test(o))return o}catch{}let n=new Uint8Array(16);if(e&&typeof e.getRandomValues=="function")e.getRandomValues(n);else for(let o=0;o<n.length;o++)n[o]=Math.floor(Math.random()*256);n[6]=(n[6]??0)&15|64,n[8]=(n[8]??0)&63|128;let r="";for(let o=0;o<n.length;o++)r+=(n[o]??0).toString(16).padStart(2,"0");return `${r.slice(0,8)}-${r.slice(8,12)}-${r.slice(12,16)}-${r.slice(16,20)}-${r.slice(20)}`}var le=3,ae=["attribute","current_page","element","text_input","user_fills_input","current_time","user_idle","visitor","always_true","group"];function v(t){if(!t||typeof t!="object")return false;let e=t;return e.v===1&&!!e.core&&typeof e.core=="object"&&typeof e.core.tag=="string"&&(e.selector===null||typeof e.selector=="string")&&typeof e.ordinal=="number"&&typeof e.precision=="number"}function pt(t,e){if(e>le||!t||typeof t!="object")return null;let n=t,r=n.type;if(typeof r!="string"||!ae.includes(r))return null;switch(r){case "attribute":return typeof n.codeName!="string"||typeof n.operator!="string"?null:{type:"attribute",codeName:n.codeName,operator:n.operator,value:n.value};case "current_page":return !Array.isArray(n.matches)||!Array.isArray(n.doesNotMatch)?null:{type:"current_page",matches:n.matches.filter(o=>typeof o=="string"),doesNotMatch:n.doesNotMatch.filter(o=>typeof o=="string")};case "element":return !v(n.target)||typeof n.state!="string"?null:{type:"element",target:n.target,state:n.state};case "text_input":return !v(n.target)||typeof n.operator!="string"||typeof n.value!="string"?null:{type:"text_input",target:n.target,operator:n.operator,value:n.value};case "user_fills_input":return v(n.target)?{type:"user_fills_input",target:n.target}:null;case "current_time":{let o=n.from,i=n.to;return o!==null&&typeof o!="string"||i!==null&&typeof i!="string"?null:{type:"current_time",from:o??null,to:i??null}}case "user_idle":{let o=n.seconds;return typeof o!="number"||!Number.isFinite(o)||o<1||o>600?null:{type:"user_idle",seconds:o}}case "visitor":return n.state!=="first_visit"&&n.state!=="returning"?null:{type:"visitor",state:n.state};case "always_true":return {type:"always_true"};case "group":{if(!Array.isArray(n.children)||n.operator!=="and"&&n.operator!=="or")return null;let o=[];for(let i of n.children){let s=pt(i,e+1);s&&o.push(s);}return {type:"group",operator:n.operator,children:o}}default:return null}}function mt(t){if(!t||typeof t!="object")return null;let e=t;if(e.v!==1)return null;let n=pt(e.node,0);return n?{v:1,node:n}:null}function ct(t){let e=/^(\d{2}):(\d{2})$/.exec(t);if(!e)return null;let n=Number(e[1]),r=Number(e[2]);return n>23||r>59?null:n*60+r}function ue(t,e){if(t.from===null&&t.to===null)return true;let n=e.getHours()*60+e.getMinutes(),r=t.from!==null?ct(t.from):null,o=t.to!==null?ct(t.to):null;return t.from!==null&&r===null||t.to!==null&&o===null?false:r!==null&&o===null?n>=r:r===null&&o!==null?n<=o:r!==null&&o!==null?r<=o?n>=r&&n<=o:n>=r||n<=o:true}function U(t,e){let n=t.split("*").map(r=>r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*");try{return new RegExp(`^${n}$`).test(e)}catch{return false}}function ce(t,e){return t.doesNotMatch.some(n=>U(n,e))?false:t.matches.length===0?true:t.matches.some(n=>U(n,e))}function ht(t,e,n){if(e===void 0)return false;switch(t){case "is":return e===n;case "is_not":return e!==n;case "contains":return e.includes(n);case "does_not_contain":return !e.includes(n);case "starts_with":return e.startsWith(n);case "ends_with":return e.endsWith(n);case "is_empty":return e==="";case "is_not_empty":return e!=="";case "greater_than":case "less_than":{let r=Number(e),o=Number(n);return e.trim()===""||!Number.isFinite(r)||!Number.isFinite(o)?false:t==="greater_than"?r>o:r<o}case "matches_pattern":return U(n,e);default:return false}}function dt(t,e){try{if(t.getClientRects().length===0)return !1}catch{return false}try{let n=e.defaultView?.getComputedStyle(t);if(n&&n.visibility==="hidden")return !1}catch{}return true}function ft(t,e){try{let n=e.activeElement;for(;n;){if(n===t||t.contains(n))return !0;n=n.shadowRoot?.activeElement??null;}}catch{}return false}function de(t,e){let n=g(t.target,e.doc);switch(t.state){case "is_present":return n.status==="matched";case "is_not_present":return n.status==="not_found";case "is_disabled":case "is_not_disabled":{if(n.status!=="matched")return false;let r="disabled"in n.element&&n.element.disabled===true;return t.state==="is_disabled"?r:!r}case "is_clicked":return e.wasClicked(t.target);case "is_not_clicked":return !e.wasClicked(t.target);case "is_visible":return n.status==="matched"&&dt(n.element,e.doc);case "is_not_visible":return n.status!=="matched"||!dt(n.element,e.doc);case "is_checked":case "is_not_checked":{if(n.status!=="matched")return false;let r="checked"in n.element&&n.element.checked===true;return t.state==="is_checked"?r:!r}case "is_focused":return n.status==="matched"&&ft(n.element,e.doc);case "is_not_focused":return n.status!=="matched"||!ft(n.element,e.doc);default:return false}}function fe(t,e){let n=e.getTrait?.(t.codeName);switch(t.operator){case "has_any_value":return n!=null&&n!=="";case "is_empty":return n==null||n==="";}if(n===void 0)return false;let r=String(n),o=t.value===void 0?"":String(t.value);return ht(t.operator,r,o)}function N(t,e){switch(t.type){case "always_true":return true;case "current_time":return ue(t,e.now());case "current_page":return ce(t,e.href());case "element":return de(t,e);case "attribute":return fe(t,e);case "text_input":{let n=e.readInputValue(t.target);return ht(t.operator,n,t.value)}case "user_fills_input":{let n=e.readInputValue(t.target),r=e.initialInputValue(t.target);return n!==void 0&&n!==""&&n!==r}case "user_idle":{let n=e.idleSeconds?.();return n!==void 0&&n>=t.seconds}case "visitor":{let n=e.isFirstVisit?.();return n===void 0?false:t.state==="first_visit"?n:!n}case "group":return t.children.length===0?false:t.operator==="and"?t.children.every(n=>N(n,e)):t.children.some(n=>N(n,e));default:return false}}function j(t){return t.type==="current_time"||t.type==="user_idle"?true:t.type==="group"?t.children.some(j):false}function G(t){return t.type==="user_idle"?true:t.type==="group"?t.children.some(G):false}var pe="https://api.arcyai.com";var me="/api/v1/sdk/flows";function he(t){return t!==void 0?t:typeof fetch<"u"?fetch.bind(globalThis):null}function ge(t,e,n,r){return new Promise(o=>{let i=false,s=l=>{i||(i=true,o(l));};t.then(s,()=>s(r));try{n(()=>s(r),e);}catch{}})}function we(t){return !t||typeof t!="object"||Array.isArray(t)?null:O(t.flow)}function O(t){if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t;return typeof e.cvid!="string"||!Array.isArray(e.steps)?null:t}function ye(t){return {"Content-Type":"application/json",Authorization:`Bearer ${t}`}}async function gt(t,e){let{apiBase:n=pe,sessionToken:r,sessionId:o,setTimeoutImpl:i=(u,p)=>setTimeout(u,p),timeoutMs:s=8e3}=e,l=he(e.fetchImpl);if(!l)return {ok:false,reason:"unusable"};let a=(async()=>{let u;try{u=await l(`${n}${me}/${encodeURIComponent(t)}/run`,{method:"POST",headers:ye(r),body:JSON.stringify(o?{sessionId:o}:{}),credentials:"omit"});}catch{return {ok:false,reason:"network"}}if(u.status===404)return {ok:false,reason:"not_found"};if(!u.ok)return {ok:false,reason:"rejected"};let p;try{p=await u.json();}catch{return {ok:false,reason:"unusable"}}let f=we(p);return f?{ok:true,flow:f}:{ok:false,reason:"unusable"}})();return ge(a,s,i,{ok:false,reason:"network"})}var ve="arcy.flow.";function Se(t){return typeof t.flowId=="string"&&t.flowId.length>0&&typeof t.currentStepCvid=="string"&&t.currentStepCvid.length>0&&typeof t.flowSessionId=="string"&&t.flowSessionId.length>0&&typeof t.startedAt=="number"}function wt(t,{store:e=at()}={}){let n=y(e),r=ve+t;return {read(){let o=L(n,r);return !o||!Se(o)?null:{flowId:o.flowId,currentStepCvid:o.currentStepCvid,flowSessionId:o.flowSessionId,startedAt:o.startedAt}},save(o){M(n,r,o);},clear(){n.removeItem(r);}}}var be="arcy.preview.";function Te(t){return typeof t.flowId=="string"&&t.flowId.length>0&&typeof t.currentStepCvid=="string"&&t.currentStepCvid.length>0&&typeof t.flowSessionId=="string"&&t.flowSessionId.length>0&&typeof t.startedAt=="number"&&t.flow!==void 0&&t.flow!==null}function X(t,{store:e=ut()}={}){let n=y(e),r=be+t;return {read(){let o=L(n,r);return !o||!Te(o)?null:o},save(o){M(n,r,o);},clear(){n.removeItem(r);}}}var Ee=250,_e=15e3,Fe=1e3,Ie=["pointerdown","pointermove","keydown","wheel","scroll","touchstart"],J=250,ke=3e3,xe=250,Y=()=>{},Re=()=>Promise.resolve({status:"wait"});function z(t,e){return t.steps.findIndex(n=>n.cvid===e)}function vt(t){return t?t.type==="element"?[t.target]:t.type==="group"?t.children.flatMap(e=>vt(e)):[]:[]}var q=class{constructor(e,n,r,o,i,s,l,a,u,p,f,w,h,D,S,d){this.flow=e;this.stepIndex=n;this.startedAt=r;this.flowSessionId=o;this.doc=i;this.win=s;this.runState=l;this.executor=a;this.getTrait=u;this.isFirstVisit=p;this.track=f;this.now=w;this.setTimeoutImpl=h;this.clearTimeoutImpl=D;this.setIntervalImpl=S;this.clearIntervalImpl=d;this.stopped=false;this.dwellTimer=null;this.observer=null;this.intervalHandle=null;this.throttleHandle=null;this.lastCheck=0;this.trueSince=new Map;this.clicked=new Set;this.initialValues=new Map;this.clickListener=null;this.lastActivityAt=0;this.activityListeners=[];this.inputPending=false;this.inputListeners=[];this.parsedTriggers=new Map;this.lastStopReason=null;this.onStatus=null;this.onFailure=null;this.onCancelFill=null;}resolveElement(e,n=0){return g(e,this.doc)}waitForElement(e){let n=()=>{let l=g(e,this.doc),a=l.status==="matched"&&l.element.isConnected;return {result:l,found:a}},r=n(),o=Math.max(0,this.flow.waitSeconds*1e3);if(r.found||o===0)return Promise.resolve(r.result);let i=this.stepIndex,s=this.now()+o;return new Promise(l=>{let a=()=>{let u=n();if(u.found||this.stopped||this.stepIndex!==i||this.now()>=s){l(u.result);return}this.setTimeoutImpl(a,J);};this.setTimeoutImpl(a,J);})}conditionContext(){return {doc:this.doc,now:()=>new Date(this.now()),href:()=>this.win.location?.href??"",getTrait:this.getTrait,idleSeconds:()=>Math.max(0,(this.now()-this.lastActivityAt)/1e3),isFirstVisit:this.isFirstVisit,wasClicked:e=>this.clicked.has(e),readInputValue:e=>{let n=g(e,this.doc);if(n.status!=="matched")return;let r=n.element;return typeof r.value=="string"?r.value:void 0},initialInputValue:e=>{if(!this.initialValues.has(e)){let n=g(e,this.doc),r=n.status==="matched"?n.element:null;this.initialValues.set(e,r&&typeof r.value=="string"?r.value:void 0);}return this.initialValues.get(e)}}}currentStep(){return this.flow.steps[this.stepIndex]}persist(){let e=this.currentStep();e&&this.runState.save({flowId:this.flow.cvid,currentStepCvid:e.cvid,flowSessionId:this.flowSessionId,startedAt:this.startedAt});}teardownWatch(){if(this.observer?.disconnect(),this.observer=null,this.intervalHandle!==null&&(this.clearIntervalImpl(this.intervalHandle),this.intervalHandle=null),this.throttleHandle!==null&&(this.clearTimeoutImpl(this.throttleHandle),this.throttleHandle=null),this.dwellTimer!==null&&(this.clearTimeoutImpl(this.dwellTimer),this.dwellTimer=null),this.clickListener){try{this.doc.removeEventListener("click",this.clickListener,!0);}catch{}this.clickListener=null;}for(let[e,n]of this.inputListeners)try{this.doc.removeEventListener(e,n,!0);}catch{}this.inputListeners=[];for(let[e,n]of this.activityListeners)try{this.doc.removeEventListener(e,n,!0);}catch{}this.activityListeners=[],this.inputPending=false,this.trueSince.clear(),this.clicked.clear(),this.initialValues.clear();}jumpTo(e){let n=z(this.flow,e);if(n===-1){this.finish("error",{reason:"step_not_found"});return}this.stopStep(),this.stepIndex=n,this.persist(),this.enterStep();}emitStatus(e){try{this.onStatus?.(e);}catch{}}dismiss(){this.stopped||this.finish("dismissed");}emit(e,n){try{this.track(e,{flowId:this.flow.cvid,flowSessionId:this.flowSessionId,stepCvid:this.currentStep()?.cvid},n);}catch{}}finish(e,n){this.lastStopReason=e;let r=e==="completed"?"flow_completed":e==="dismissed"?"flow_abandoned":"flow_error";this.emit(r,n);try{this.onCancelFill?.();}catch{}if(this.stopStep(),this.stopped=true,this.runState.clear(),e==="completed"&&this.emitStatus({name:this.flow.publicName??this.flow.name,step:this.flow.steps.length,total:this.flow.steps.length,phase:"done"}),this.emitStatus(null),e==="error")try{this.onFailure?.();}catch{}}stopStep(){this.teardownWatch();}fireTrigger(e){if(e.actionType==="dismiss_flow"){this.finish("dismissed");return}e.actionType==="go_to_step"&&e.targetStepCvid&&this.jumpTo(e.targetStepCvid);}parsedTrigger(e){return this.parsedTriggers.has(e.cvid)||this.parsedTriggers.set(e.cvid,mt(e.condition)),this.parsedTriggers.get(e.cvid)??null}checkTriggers(e,n){if(this.stopped||this.inputPending)return;let r=this.now();for(let o of [...e.triggers].sort((i,s)=>i.position-s.position)){let i=this.parsedTrigger(o);if(!i)continue;let s=N(i.node,n),l=o.cvid;if(!s){this.trueSince.delete(l);continue}let a=this.trueSince.get(l)??r;this.trueSince.has(l)||this.trueSince.set(l,a);let u=(o.waitSeconds??0)*1e3;if(r-a>=u){this.fireTrigger(o);return}}}scheduleCheck(e){if(this.stopped||this.throttleHandle!==null)return;let n=Math.max(0,Ee-(this.now()-this.lastCheck));this.throttleHandle=this.setTimeoutImpl(()=>{this.throttleHandle=null,this.lastCheck=this.now(),this.checkTriggers(e,this.conditionContext());},n);}startWatch(e){let n=e.triggers.some(o=>{let i=this.parsedTrigger(o);return i?j(i.node):false}),r=e.triggers.some(o=>{let i=this.parsedTrigger(o);return i?G(i.node):false});if(this.lastActivityAt=this.now(),typeof MutationObserver=="function")try{this.observer=new MutationObserver(()=>this.scheduleCheck(e)),this.observer.observe(this.doc.documentElement,{childList:!0,subtree:!0,attributes:!0,characterData:!0});}catch{}if(n)try{this.intervalHandle=this.setIntervalImpl(()=>this.scheduleCheck(e),r?Fe:_e);}catch{}if(r)for(let o of Ie){let i=()=>{this.lastActivityAt=this.now();};try{this.doc.addEventListener(o,i,{capture:!0,passive:!0}),this.activityListeners.push([o,i]);}catch{}}this.clickListener=o=>{for(let i of e.triggers){let s=this.parsedTrigger(i),l=vt(s?.node);for(let a of l){let u=g(a,this.doc);u.status==="matched"&&o.target instanceof Node&&(u.element===o.target||u.element.contains(o.target))&&this.clicked.add(a);}}this.scheduleCheck(e);};try{this.doc.addEventListener("click",this.clickListener,!0);}catch{this.clickListener=null;}for(let o of ["input","change","focusin","focusout"]){let i=()=>this.scheduleCheck(e);try{this.doc.addEventListener(o,i,!0),this.inputListeners.push([o,i]);}catch{}}this.checkTriggers(e,this.conditionContext());}async runExecutor(e){let n=this.stepIndex;try{let r=await this.executor(e,{doc:this.doc,win:this.win,resolveElement:(o,i)=>this.resolveElement(o,i),waitForElement:o=>this.waitForElement(o),setInputPending:o=>{this.inputPending=o;}});if(this.stopped||this.stepIndex!==n)return;if(r.status==="advance"){if(this.emit("flow_step_completed"),e.isCompletion){this.finish("completed");return}let o=this.stepIndex+1;if(o>=this.flow.steps.length){this.finish("completed");return}this.stopStep(),this.stepIndex=o,this.persist(),this.enterStep();return}if(r.status==="navigated"){if(this.emit("flow_step_completed"),r.navigateTarget==="new_tab"){this.finish("completed");return}if(this.stopStep(),e.isCompletion){this.finish("completed");return}let o=this.stepIndex+1;if(o>=this.flow.steps.length){this.finish("completed");return}this.stepIndex=o,this.persist();return}if(r.status==="error"){this.finish("error",r.reason==="element_not_found"?{reason:r.reason,liveManifest:lt(this.doc)}:{reason:r.reason});return}}catch{}}enterStep(){let e=this.currentStep();if(!e||this.stopped){this.finish(e?"completed":"error",e?void 0:{reason:"missing_step"});return}this.persist(),this.emit("flow_step_entered"),this.emitStatus({name:this.flow.publicName??this.flow.name,step:this.stepIndex+1,total:this.flow.steps.length,phase:"running"});let n=()=>{this.stopped||(this.startWatch(e),this.runExecutor(e));};this.waitForPageReady(n);}waitForPageReady(e){let n=this.now()+ke,r=()=>{this.dwellTimer=this.setTimeoutImpl(()=>{this.dwellTimer=null,e();},xe);},o=()=>{if(!this.stopped){if(this.doc.readyState!=="loading"||this.now()>=n){r();return}this.dwellTimer=this.setTimeoutImpl(()=>{this.dwellTimer=null,o();},J);}};o();}begin(){this.enterStep();}stop(){if(!this.stopped){try{this.onCancelFill?.();}catch{}this.stopStep(),this.stopped=true;}}};function St(t){let{context:e,executor:n=Re,track:r=e.track??Y,now:o=()=>Date.now(),setTimeoutImpl:i=(d,c)=>setTimeout(d,c),clearTimeoutImpl:s=d=>clearTimeout(d),setIntervalImpl:l=(d,c)=>setInterval(d,c),clearIntervalImpl:a=d=>clearInterval(d)}=t,u=e.doc??document,p=e.win??window,f=wt(e.token),w={apiBase:e.apiBase,sessionToken:e.sessionToken,sessionId:e.sessionId},h=null;async function D(d){let c=await gt(d,w);return c.ok?c.flow:null}function S(d,c,m,F,et={}){h?.stop(),h=new q(d,c,m,F,u,p,et.runState??f,n,e.getTrait,e.isFirstVisit,et.track??r,o,i,s,l,a),h.onStatus=Rt=>e.onStatus?.(Rt),h.onFailure=()=>e.onFailure?.(),h.onCancelFill=()=>e.cancelFill?.(),h.begin();}return {async start(d){let c=await D(d);if(!c||c.steps.length===0)return;let m=B();try{r("flow_started",{flowId:c.cvid,flowSessionId:m});}catch{}S(c,0,o(),m);},async resume(){let d=f.read();if(!d)return false;let c=await D(d.flowId);if(!c||c.steps.length===0)return f.clear(),false;let m=z(c,d.currentStepCvid);return m===-1?(f.clear(),false):(S(c,m,d.startedAt,d.flowSessionId),true)},stop(){h?.dismiss(),h=null;},async startPreview(d){let c=O(d);if(!c||c.steps.length===0)return;let m=X(e.token);S(c,0,o(),B(),{runState:yt(m,d),track:Y});},async resumePreview(){let d=X(e.token),c=d.read();if(!c)return false;let m=O(c.flow);if(!m||m.steps.length===0)return d.clear(),false;let F=z(m,c.currentStepCvid);return F===-1?(d.clear(),false):(S(m,F,c.startedAt,c.flowSessionId,{runState:yt(d,c.flow),track:Y}),true)},destroy(){h?.stop(),h=null;}}}function yt(t,e){return {read:()=>null,save:n=>t.save({...n,flow:e}),clear:()=>t.clear()}}var Ce=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Ae=/^\d{4}-\d{2}-\d{2}$/,Le=/^([01]\d|2[0-3]):[0-5]\d(:[0-5]\d)?$/,Me=/^\d{4}-\d{2}-\d{2}T([01]\d|2[0-3]):[0-5]\d(:[0-5]\d)?$/,Ne=/^\d{4}-\d{2}$/,Oe=/^\d{4}-W\d{2}$/,Pe=/^\+?[\d\s().-]{3,}$/;function De(t){let e=Date.parse(t);return Number.isFinite(e)}function He(t,e){if(e.min!==null){let n=Number(e.min);if(Number.isFinite(n)&&t<n)return "number_too_small"}if(e.max!==null){let n=Number(e.max);if(Number.isFinite(n)&&t>n)return "number_too_large"}return null}function Z(t){return /^\d:/.test(t)?`0${t}`:t}function E(t,e){return e.min!==null&&e.min.length>0&&t<e.min?"date_too_early":e.max!==null&&e.max.length>0&&t>e.max?"date_too_late":null}function bt(t,e){let n=e.kind==="password"?t:t.trim();if(n.length===0)return e.required?"required":null;if(e.maxLength!==null&&n.length>e.maxLength)return "too_long";switch(e.kind){case "number":case "range":{let r=Number(n);return Number.isFinite(r)?He(r,e):"invalid_number"}case "email":return Ce.test(n)?null:"invalid_email";case "url":try{let r=new URL(n);return r.protocol==="http:"||r.protocol==="https:"?null:"invalid_url"}catch{return "invalid_url"}case "tel":return Pe.test(n)?null:"invalid";case "date":return !Ae.test(n)||!De(n)?"invalid_date":E(n,e);case "datetime":return Me.test(n)?E(n,e):"invalid_date";case "month":return Ne.test(n)?E(n,e):"invalid_date";case "week":return Oe.test(n)?E(n,e):"invalid_date";case "time":return Le.test(n)?E(Z(n),{...e,min:e.min!==null?Z(e.min):null,max:e.max!==null?Z(e.max):null}):"invalid_time";case "select":case "radio":return (e.options??[]).some(o=>o.value===n)?null:"invalid_option";case "checkbox":return n==="true"||n==="false"?null:"invalid_option";default:{if(e.pattern)try{if(!new RegExp(`^(?:${e.pattern})$`).test(n))return "invalid"}catch{}return null}}}function Tt(t,e){if(!e||e.length===0)return t;let n=t.trim();if(e.some(i=>i.value===n))return n;let r=n.toLowerCase(),o=e.find(i=>i.label.trim().toLowerCase()===r);return o?o.value:t}var Q=24;function Ve(t,e,n){let r=e-Math.max(0,n);if(!(e>0)||r<=0)return 0;if(t.bottom>r){let o=t.bottom-r+Q,i=Math.max(0,t.top-Q);return Math.min(o,i)}return t.top<0?t.top-Q:0}function Ft(t,e,n){try{let r=n.getBottomOcclusion?.()??0,o=t.getBoundingClientRect(),i=e.doc.documentElement?.clientHeight||e.win.innerHeight||0,s=Ve(o,i,r);if(s===0)return;e.win.scrollBy({top:s,behavior:"smooth"});}catch{}}function tt(t,e){let r=e.defaultView?.PointerEvent,o=(()=>{try{return t.getBoundingClientRect()}catch{return null}})(),i={bubbles:true,cancelable:true,clientX:o?o.left+o.width/2:0,clientY:o?o.top+o.height/2:0},s=a=>{try{typeof r=="function"&&t.dispatchEvent(new r(a,{...i,pointerType:"mouse"}));}catch{}},l=a=>{try{t.dispatchEvent(new MouseEvent(a,i));}catch{}};s("pointerover"),s("pointerenter"),s("pointerdown"),l("mousedown");try{typeof t.focus=="function"&&t.focus();}catch{}s("pointerup"),l("mouseup"),l("click");}function We(t,e){let n=t instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:t instanceof HTMLInputElement?HTMLInputElement.prototype:t instanceof HTMLSelectElement?HTMLSelectElement.prototype:null;if(!n)return false;let o=Object.getOwnPropertyDescriptor(n,"value")?.set;if(!o)return false;try{return o.call(t,e),!0}catch{return false}}function P(t,e){let n=e.defaultView;try{t.dispatchEvent(new(n?.Event??Event)("input",{bubbles:!0}));}catch{}try{t.dispatchEvent(new(n?.Event??Event)("change",{bubbles:!0}));}catch{}}async function Ke(t,e,n){if(!v(t.target))return {status:"error",reason:"invalid_target"};let r=await e.waitForElement(t.target);if(r.status!=="matched"||!r.element.isConnected)return {status:"error",reason:"element_not_found"};Ft(r.element,e,n);try{tt(r.element,e.doc);}catch{return {status:"error",reason:"dispatch_failed"}}return {status:"advance"}}var $e=["text","number","email","date","url","tel"];function Et(t){return $e.includes(t)?t:null}var Be={text:"text",search:"text",number:"number",email:"email",url:"url",tel:"tel",password:"password",date:"date",time:"time","datetime-local":"datetime",month:"month",week:"week",checkbox:"checkbox",radio:"radio",range:"range"};function _(t,e){try{let n=t.getAttribute(e);return n===null||n===""?null:n}catch{return null}}function Ue(t){let e=[];for(let n=0;n<t.options.length;n+=1){let r=t.options[n];if(!r||r.disabled)continue;let o=(r.label||r.textContent||"").trim();r.value!==""&&e.push({value:r.value,label:o||r.value});}return e}function je(t,e){let n=t.getAttribute("name"),r=t.form??e,o=[];if(n)try{let i=`input[type="radio"][name="${CSS.escape(n)}"]`;r.querySelectorAll(i).forEach(s=>{s instanceof HTMLInputElement&&o.push(s);});}catch{}return o.length===0&&o.push(t),o.map(i=>({value:i.value,label:Ge(i)||i.value}))}function It(t){try{let e=t.labels;if(e&&e.length>0)return (e[0]?.textContent??"").trim()}catch{}try{let e=t.closest("label");if(e)return (e.textContent??"").trim()}catch{}return ""}function Ge(t){return It(t)}function _t(t,e,n){let r="custom",o=null,i=false,s=null,l=null,a=null,u=null,p=null;if(t instanceof HTMLSelectElement)r="select",o=Ue(t),i=t.required||!t.querySelector('option[value=""]');else if(t instanceof HTMLTextAreaElement)r="textarea",i=t.required,t.maxLength>0&&(u=t.maxLength);else if(t instanceof HTMLInputElement){let f=(_(t,"type")??"text").toLowerCase();r=Be[f]??"text",i=t.required,s=_(t,"min"),l=_(t,"max"),a=_(t,"step"),p=_(t,"pattern"),t.maxLength>0&&(u=t.maxLength),r==="radio"&&(o=je(t,n)),r==="checkbox"&&(o=[{value:"true",label:It(t)}]);}return e&&e!=="text"&&(r==="text"||r==="custom"||r==="textarea")&&(r=e),{kind:r,required:i,options:o,min:s,max:l,step:a,maxLength:u,pattern:p}}function Xe(t){if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement||t instanceof HTMLElement&&t.isContentEditable)return t;try{let e=t.querySelector('input:not([type="hidden"]), textarea, select, [contenteditable="true"], [contenteditable=""]');return e instanceof HTMLElement?e:null}catch{return null}}function Je(t,e){let r=e.defaultView?.KeyboardEvent;if(typeof r=="function")for(let o of ["keydown","keyup"])try{t.dispatchEvent(new r(o,{bubbles:!0,cancelable:!0}));}catch{}}function Ye(t,e,n,r){if(n==="checkbox"&&t instanceof HTMLInputElement){let i=e==="true";return t.checked!==i&&tt(t,r),t.checked!==i&&(t.checked=i,P(t,r)),true}if(n==="radio"&&t instanceof HTMLInputElement){let i=t.form??r,s=t.getAttribute("name"),l=null;if(s)try{let p=`input[type="radio"][name="${CSS.escape(s)}"]`;i.querySelectorAll(p).forEach(f=>{f instanceof HTMLInputElement&&f.value===e&&(l=f);});}catch{}let a=l??(t.value===e?t:null);if(!a)return false;tt(a,r);let u=a;return u.checked||(u.checked=true,P(u,r)),true}let o=Xe(t);if(!o)return false;if(o instanceof HTMLElement&&o.isContentEditable){try{o.focus();}catch{}try{o.textContent=e;}catch{return false}return P(o,r),true}try{o.focus();}catch{}return We(o,e)?(Je(o,r),P(o,r),true):false}async function ze(t,e,n){if(!v(t.target))return {status:"error",reason:"invalid_target"};if(!n.promptFill)return {status:"wait"};let r=await e.waitForElement(t.target);if(r.status!=="matched"||!r.element.isConnected)return {status:"error",reason:"element_not_found"};let o=_t(r.element,Et(t.fillInputType),e.doc),i=(t.fillDescription??"").trim()||t.label||"",s=null,l=null,a;for(;;){let f;e.setInputPending(true);try{f=await n.promptFill({...o,question:i,errorCode:s});}catch{return {status:"error",reason:"prompt_failed"}}finally{e.setInputPending(false);}if(f===null)return {status:"error",reason:"fill_cancelled"};let w=o.kind==="select"||o.kind==="radio"?Tt(f,o.options):o.kind==="password"?f:f.trim();if(s=bt(w,{...o,question:i,errorCode:null}),s===null){a=w;break}if(l!==null&&l===w)return {status:"error",reason:"fill_invalid"};l=w;}let u=await e.waitForElement(t.target);if(u.status!=="matched"||!u.element.isConnected)return {status:"error",reason:"element_not_found"};let p=_t(u.element,Et(t.fillInputType),e.doc);return p.kind!==o.kind?{status:"error",reason:"unfillable_target"}:(Ft(u.element,e,n),Ye(u.element,a,p.kind,e.doc)?{status:"advance"}:{status:"error",reason:"unfillable_target"})}function qe(t){if(t.startsWith("/")&&!t.startsWith("//"))return true;try{let e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"}catch{return false}}async function Ze(t,e){if(!t.navigateUrl||!t.navigateTarget)return {status:"error",reason:"invalid_navigate_step"};if(!qe(t.navigateUrl))return {status:"error",reason:"invalid_navigate_step"};try{t.navigateTarget==="new_tab"?e.win.open(t.navigateUrl,"_blank","noopener,noreferrer"):e.win.location.assign(t.navigateUrl);}catch{return {status:"error",reason:"navigate_failed"}}return {status:"navigated",navigateTarget:t.navigateTarget}}function kt(t={}){return async(e,n)=>{try{switch(e.type){case "click":return await Ke(e,n,t);case "fill":return await ze(e,n,t);case "navigate":return await Ze(e,n);default:return {status:"error",reason:"unknown_step_type"}}}catch{return {status:"error",reason:"executor_threw"}}}}var xt="__arcyFlow";function tn(t){try{let e=kt({promptFill:t.promptFill,getBottomOcclusion:t.getBottomOcclusion});return St({context:t,executor:e})}catch{return null}}var en={contract:2,mount:tn};if(typeof window<"u")try{window[xt]=en;}catch{}
3
- })();