@inploi/plugin-chatbot 14.17.3 → 14.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -1
- package/cdn/index.js +34 -6
- package/cdn/style.css +1 -1
- package/dist/chatbot-body-DjE1hhPI.js +4309 -0
- package/dist/chatbot-body-Y8XV3f3-.cjs +5 -0
- package/dist/common.geo-transport-CJGUJXTA-BsgnqoTX.js +41 -0
- package/dist/common.geo-transport-CJGUJXTA-DQyNyTXw.cjs +1 -0
- package/dist/index-C8Gr0Ijn.js +3198 -0
- package/dist/index-DSa7ZKqt.cjs +21 -0
- package/dist/index.d.cts +547 -0
- package/dist/index.d.ts +547 -2
- package/dist/plugin-chatbot.cjs +1 -1
- package/dist/plugin-chatbot.js +2 -3
- package/dist/style.css +1 -1
- package/package.json +18 -13
- package/dist/accessible-labels.test.d.ts +0 -1
- package/dist/chatbot-body-2942441d.cjs +0 -5
- package/dist/chatbot-body-73450740.js +0 -4523
- package/dist/chatbot.analytics.d.ts +0 -37
- package/dist/chatbot.analytics.test.d.ts +0 -1
- package/dist/chatbot.api.d.ts +0 -26
- package/dist/chatbot.constants.d.ts +0 -2
- package/dist/chatbot.context.test.d.ts +0 -1
- package/dist/chatbot.d.ts +0 -104
- package/dist/chatbot.dom.d.ts +0 -5
- package/dist/chatbot.idb.d.ts +0 -73
- package/dist/chatbot.lifecycle.test.d.ts +0 -1
- package/dist/chatbot.resume.d.ts +0 -15
- package/dist/chatbot.resume.test.d.ts +0 -1
- package/dist/chatbot.state.d.ts +0 -78
- package/dist/chatbot.state.test.d.ts +0 -1
- package/dist/chatbot.storage.test.d.ts +0 -1
- package/dist/chatbot.utils.d.ts +0 -8
- package/dist/components/chat-bubble.d.ts +0 -11
- package/dist/components/chat-error.d.ts +0 -3
- package/dist/components/chat-input/chat-input.address-countries.test.d.ts +0 -1
- package/dist/components/chat-input/chat-input.address.d.ts +0 -5
- package/dist/components/chat-input/chat-input.address.test.d.ts +0 -1
- package/dist/components/chat-input/chat-input.boolean.d.ts +0 -11
- package/dist/components/chat-input/chat-input.constants.d.ts +0 -1
- package/dist/components/chat-input/chat-input.d.ts +0 -12
- package/dist/components/chat-input/chat-input.file.d.ts +0 -8
- package/dist/components/chat-input/chat-input.file.test.d.ts +0 -1
- package/dist/components/chat-input/chat-input.multiple-choice.d.ts +0 -4
- package/dist/components/chat-input/chat-input.multiple-choice.test.d.ts +0 -1
- package/dist/components/chat-input/chat-input.number.d.ts +0 -4
- package/dist/components/chat-input/chat-input.phone-number.d.ts +0 -4
- package/dist/components/chat-input/chat-input.submit.d.ts +0 -4
- package/dist/components/chat-input/chat-input.submit.test.d.ts +0 -1
- package/dist/components/chat-input/chat-input.text.d.ts +0 -5
- package/dist/components/chat-input/chat-input.text.test.d.ts +0 -1
- package/dist/components/chat-input/input-style.d.ts +0 -3
- package/dist/components/chat-loading.d.ts +0 -1
- package/dist/components/chatbot-body.d.ts +0 -12
- package/dist/components/chatbot-body.lifecycle.test.d.ts +0 -1
- package/dist/components/chatbot.d.ts +0 -17
- package/dist/components/conversation.d.ts +0 -8
- package/dist/components/correction.test.d.ts +0 -1
- package/dist/components/input-error.d.ts +0 -5
- package/dist/components/job-alerts-offer.d.ts +0 -13
- package/dist/components/job-alerts-offer.test.d.ts +0 -1
- package/dist/components/job-alerts-privacy-line.test.d.ts +0 -1
- package/dist/components/loading-indicator.d.ts +0 -3
- package/dist/components/message.link.d.ts +0 -5
- package/dist/components/palette-debugger.d.ts +0 -1
- package/dist/components/send-button.d.ts +0 -3
- package/dist/components/skip-button.d.ts +0 -3
- package/dist/components/status-bar.d.ts +0 -22
- package/dist/components/status-bar.test.d.ts +0 -1
- package/dist/components/transition.d.ts +0 -1
- package/dist/components/typing-indicator.d.ts +0 -3
- package/dist/components/useChatService.d.ts +0 -17
- package/dist/components/useChatService.test.d.ts +0 -1
- package/dist/components/useFocus.d.ts +0 -1
- package/dist/i18n.d.ts +0 -776
- package/dist/index-0685e04a.cjs +0 -5
- package/dist/index-8df73cbc.js +0 -3530
- package/dist/index.cdn.d.ts +0 -9
- package/dist/index.dev.d.ts +0 -8
- package/dist/interpreter.test.d.ts +0 -1
- package/dist/md.d.ts +0 -1
- package/dist/md.test.d.ts +0 -1
- package/dist/mocks/browser.d.ts +0 -1
- package/dist/mocks/flows.mocks.d.ts +0 -77
- package/dist/mocks/handlers.d.ts +0 -14
- package/dist/mocks/mocks.utils.d.ts +0 -5
- package/dist/mocks/pre-apply.mock.d.ts +0 -296
- package/dist/phone.test.d.ts +0 -1
- package/dist/progress.d.ts +0 -12
- package/dist/progress.test.d.ts +0 -1
- package/dist/rpc.d.ts +0 -1
- package/dist/style/theme.d.ts +0 -3
- package/dist/style/theme.utils.d.ts +0 -6
- package/dist/style/tokens.d.ts +0 -86
- package/dist/widget-version.d.ts +0 -7
- package/dist/widget-version.test.d.ts +0 -1
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";var on=Object.defineProperty;var ln=(e,r,t)=>r in e?on(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var Y=(e,r,t)=>(ln(e,typeof r!="symbol"?r+"":r,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index-0685e04a.cjs"),at=require("@inploi/sdk");var cn="https://maps.inploi.com/address",it=/\b(?:GIR\s*0AA|[a-z]{1,2}\d[\da-z]?\s*\d[a-z]{2}|[a-z](?:\d{2}|\d[a-z])\s*[\da-z]{4})\b/i,Sr=/^(?:GIR0AA|[A-Z]{1,2}\d[\dA-Z]?\d[A-Z]{2})$/,Ar=/^[A-Z](?:\d{2}|\d[A-Z])[\dA-Z]{4}$/,kt=e=>e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/\s+/g," ").trim(),zt=e=>e.split(",").map(r=>kt(r).replace(/^\d+[a-z]?(?:\s*[-/]\s*\d+[a-z]?)?(?:\s+|$)/,"").trim()),Wt=e=>Sr.test(e)?`gb:${e.slice(0,-3)}`:Ar.test(e)?`ie:${e.slice(0,3)}`:null,un=(e,r,t)=>{const[n="",a=""]=zt(e),i=Wt(r),o=a.replace(it,"").trim(),l=o&&!["united kingdom","ireland","england","scotland","wales","northern ireland"].includes(o);if(!n||!i&&!l)return null;const c=t.slice(0,3).findIndex(f=>{var y;const h=zt(f);if(!h.includes(n))return!1;const g=((y=f.match(it))==null?void 0:y[0].replace(/\s/g,"").toUpperCase())??"",m=Wt(g);return i&&m?i===m:!!(l&&h.some(k=>k.replace(it,"").trim()===o))});return c===-1?null:c+1},dn=async({query:e,country:r,pickedLabel:t,pickedPostcode:n,pickedCountry:a,pickedState:i,log:o})=>{var c,f,h,g,m;if(!r||!r.split(",").every(y=>/^(gb|ie)$/i.test(y.trim())))return;let l;try{const y=new AbortController;l=setTimeout(()=>y.abort(),1500);const k=new URL(cn);k.search=new URLSearchParams({q:e,country:r,limit:"5"}).toString();const _=await fetch(k.href,{signal:y.signal});if(!_.ok)return;const w=await _.json();if(typeof w!="object"||w===null||!("results"in w)||!Array.isArray(w.results)||!("source"in w)||w.source!=="photon"&&w.source!=="mapbox")return;const S=w.results,x=[];for(const T of S){if(typeof T!="object"||T===null||!("label"in T)||typeof T.label!="string")return;x.push(T.label)}const N=((n==null?void 0:n.trim())||((c=t.match(it))==null?void 0:c[0])||"").replace(/\s/g,"").toUpperCase(),R=un(t,N,x),A=(h=(f=_.headers.get("Server-Timing"))==null?void 0:f.match(/(?:^|,)\s*lookup\s*;\s*dur=([\d.]+)/))==null?void 0:h[1],q=A===void 0?null:Number(A),O=_.headers.get("X-Geo-Fallback"),V=(m=(a==null?void 0:a.trim())||((g=t.split(",").at(-1))==null?void 0:g.trim()))==null?void 0:m.toLowerCase();let M=null;Sr.test(N)?M=N.startsWith("BT")?"ni":"gb":Ar.test(N)?M="ie":kt(i??"")==="northern ireland"||t.split(",").some(T=>kt(T)==="northern ireland")?M="ni":V==="united kingdom"||V==="gb"?M="gb":(V==="ireland"||V==="ie")&&(M="ie"),await o({hit:R!==null,rank:R,results:x.length,source:w.source,fallback:O&&/^[a-z0-9_-]{1,64}$/i.test(O)?O:null,ms:q!==null&&Number.isFinite(q)?q:null,region:M})}catch{}finally{clearTimeout(l)}},fn="9.12.0",Er=`https://sdk.inploi.com/@inploi/flows@${fn}/cdn/captcha/index.html`,hn=new URL(Er).origin,Ht=3e4,pn=5*6e4,mn=e=>typeof e=="object"&&e!==null&&e.source==="inploi-captcha",yt=new WeakMap,yn=e=>{let r=yt.get(e);return r||(r=e.fetch("/flow/captcha").then(t=>{let n=t==null?void 0:t.site_key;return typeof n=="string"&&n!==""?n:void 0}).catch(t=>{throw yt.delete(e),t}),yt.set(e,r)),r},bn=(e,r={})=>new Promise((t,n)=>{let{signal:a,container:i=null,theme:o,onInteractive:l}=r instanceof AbortSignal?{signal:r}:r,c=!1,f=()=>{},h=_=>{c||(c=!0,clearTimeout(y),a==null||a.removeEventListener("abort",m),f(),_())},g=_=>h(()=>n(new Error(_))),m=()=>g("Captcha aborted"),y,k=_=>{clearTimeout(y),y=setTimeout(()=>g("Captcha timed out"),_)};if(k(Ht),a==null?void 0:a.aborted)return m();a==null||a.addEventListener("abort",m),(async()=>{let _=await yn(e);if(_===void 0)return h(()=>t(void 0));if(c)return;let w=document.createElement("iframe");w.src=`${Er}?${new URLSearchParams({sitekey:_,origin:window.location.origin,...o&&{theme:o}}).toString()}`,w.title="Cloudflare security check",w.style.cssText=`display:block;border:0;width:${i?"100%":"300px"};height:0;color-scheme:normal`,i?i.appendChild(w):(w.style.cssText+=";position:fixed;bottom:16px;right:16px;z-index:2147483647",document.body.appendChild(w));let S=!1,x=N=>{if(!w.contentWindow||N.source!==w.contentWindow||N.origin!==hn||!mn(N.data))return;let R=N.data;switch(R.type){case"token":return h(()=>t(R.token));case"resize":w.style.height=`${Math.max(0,Math.ceil(R.height))}px`;return;case"before-interactive":return S=!0,k(pn),l==null?void 0:l();case"after-interactive":return S=!1,k(Ht);case"error":!S&&!R.interactive&&g("Captcha failed");return;case"expired":return g("Captcha expired");case"timeout":return g("Captcha timed out")}};window.addEventListener("message",x),f=()=>{window.removeEventListener("message",x),w.remove()}})().catch(_=>h(()=>n(_)))}),Kt=({condition:e,context:r,submissions:t,ifBlock:n})=>{let[a,...i]=e.compareKey.split(".");if(!a)return!1;let o=s.pe({context:r,key:a,path:i,submissions:t});if(!o)return!1;switch(o.type){case"address":{let l=s.L(o.value,i);switch(e.compare){case"equals":return l===e.compareValue;case"contains":return typeof l!="string"?!1:l.includes(e.compareValue);case"notEquals":return l!==e.compareValue;case"notContains":return typeof l!="string"?!0:!l.includes(e.compareValue)}break}case"integration":{if(typeof o.value!="object"||Array.isArray(o.value))return!1;let l=s.L(o.value,i),c={...n,data:{compareKey:"_temp",compare:e.compare,compareValue:e.compareValue}};switch(typeof l){case"boolean":return Ze(c,{submissions:{_temp:{value:l,type:"boolean"}},context:r});case"string":return Ze(c,{submissions:{_temp:{value:l,type:"string"}},context:r});case"number":return Ze(c,{submissions:{_temp:{value:l,type:"number"}},context:r});case"object":return Array.isArray(l)&&l.every(f=>typeof f=="string")?Ze(c,{submissions:{_temp:{value:l,type:"enum"}},context:r}):!1}break}case"boolean":{let l=e.compareValue==="true";switch(e.compare){case"equals":return o.value===l;case"notEquals":return o.value!==l}break}case"phone":case"string":{let l=o.type==="phone"?s.fe(o.value):o.value;switch(e.compare){case"equals":return l===e.compareValue;case"contains":return l?l.includes(e.compareValue):!1;case"notEquals":return l!==e.compareValue;case"notContains":return l?!l.includes(e.compareValue):!0}break}case"number":{try{let l=Number(e.compareValue);switch(e.compare){case"equals":return o.value===l;case"notEquals":return o.value!==l;case"greaterThan":return o.value>l;case"greaterThanOrEqualTo":return o.value>=l;case"lessThan":return o.value<l;case"lessThanOrEqualTo":return o.value<=l}}catch{return console.error(`Failed to parse number in if-block ${n.id}`,o.value),!1}break}case"enum":switch(e.compare){case"equals":return o.value.length===1&&o.value[0]===e.compareValue;case"notEquals":return o.value.length===1&&o.value[0]!==e.compareValue;case"contains":return o.value.includes(e.compareValue);case"notContains":return!o.value.includes(e.compareValue)}break}},Ze=(e,{context:r,submissions:t})=>{let n="combinator"in e.data?e.data.conditions:[e.data];if(("combinator"in e.data?e.data.combinator:"and")==="or"){for(let a of n)if(Kt({condition:a,context:r,submissions:t,ifBlock:e}))return!0;return!1}else{for(let a of n)if(!Kt({condition:a,context:r,submissions:t,ifBlock:e}))return!1;return!0}},gn=/{{\s*([^}]+?)\s*(?:\|\s*([^}]+?)\s*)?}}/g,vn=(e,{context:r,submissions:t})=>e.replace(gn,(n,a,i="")=>{let[o,...l]=a.trim().split("."),c=s.pe({key:o,path:l,submissions:t,context:r});if(!c)return i;switch(c.type){case"boolean":return c.value===!0?"true":"false";case"file":return c.value.map(f=>`${f.name} (${s.me(f.sizeKb)})`).join(", ");case"enum":return c.value.join(", ");case"address":return Object.values(c.value).filter(f=>f&&f.trim().length>0).join(", ");case"number":case"string":return c.value?c.value.toString():i;case"phone":return s.fe(c.value);case"integration":{if(typeof c.value!="object"||Array.isArray(c.value))break;let f=s.L(c.value,l);switch(typeof f){case"boolean":return f===!0?"true":"false";case"string":return f;case"number":return f.toString();case"object":if(Array.isArray(f)&&f.every(h=>typeof h=="string"))return f.join(", ")}break}}return i});/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function xn(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Vt(e,r,t=""){const n=xn(e),a=e==null?void 0:e.length,i=r!==void 0;if(!n||i&&a!==r){const o=t&&`"${t}" `,l=i?` of length ${r}`:"",c=n?`length=${a}`:`type=${typeof e}`;throw new Error(o+"expected Uint8Array"+l+", got "+c)}return e}function Gt(e,r=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(r&&e.finished)throw new Error("Hash#digest() has already been called")}function wn(e,r){Vt(e,void 0,"digestInto() output");const t=r.outputLen;if(e.length<t)throw new Error('"digestInto() output" expected to be of length >='+t)}function Ct(...e){for(let r=0;r<e.length;r++)e[r].fill(0)}function bt(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ue(e,r){return e<<32-r|e>>>r}const _n=(()=>typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function")(),kn=Array.from({length:256},(e,r)=>r.toString(16).padStart(2,"0"));function Cn(e){if(Vt(e),_n)return e.toHex();let r="";for(let t=0;t<e.length;t++)r+=kn[e[t]];return r}function Sn(e,r={}){const t=(a,i)=>e(i).update(a).digest(),n=e(void 0);return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=a=>e(a),Object.assign(t,r),Object.freeze(t)}const An=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function En(e,r,t){return e&r^~e&t}function In(e,r,t){return e&r^e&t^r&t}class Fn{constructor(r,t,n,a){Y(this,"blockLen");Y(this,"outputLen");Y(this,"padOffset");Y(this,"isLE");Y(this,"buffer");Y(this,"view");Y(this,"finished",!1);Y(this,"length",0);Y(this,"pos",0);Y(this,"destroyed",!1);this.blockLen=r,this.outputLen=t,this.padOffset=n,this.isLE=a,this.buffer=new Uint8Array(r),this.view=bt(this.buffer)}update(r){Gt(this),Vt(r);const{view:t,buffer:n,blockLen:a}=this,i=r.length;for(let o=0;o<i;){const l=Math.min(a-this.pos,i-o);if(l===a){const c=bt(r);for(;a<=i-o;o+=a)this.process(c,o);continue}n.set(r.subarray(o,o+l),this.pos),this.pos+=l,o+=l,this.pos===a&&(this.process(t,0),this.pos=0)}return this.length+=r.length,this.roundClean(),this}digestInto(r){Gt(this),wn(r,this),this.finished=!0;const{buffer:t,view:n,blockLen:a,isLE:i}=this;let{pos:o}=this;t[o++]=128,Ct(this.buffer.subarray(o)),this.padOffset>a-o&&(this.process(n,0),o=0);for(let g=o;g<a;g++)t[g]=0;n.setBigUint64(a-8,BigInt(this.length*8),i),this.process(n,0);const l=bt(r),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen must be aligned to 32bit");const f=c/4,h=this.get();if(f>h.length)throw new Error("_sha2: outputLen bigger than state");for(let g=0;g<f;g++)l.setUint32(4*g,h[g],i)}digest(){const{buffer:r,outputLen:t}=this;this.digestInto(r);const n=r.slice(0,t);return this.destroy(),n}_cloneInto(r){r||(r=new this.constructor),r.set(...this.get());const{blockLen:t,buffer:n,length:a,finished:i,destroyed:o,pos:l}=this;return r.destroyed=o,r.finished=i,r.length=a,r.pos=l,a%t&&r.buffer.set(n),r}clone(){return this._cloneInto()}}const we=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Vn=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),_e=new Uint32Array(64);class Ln extends Fn{constructor(r){super(64,r,8,!1)}get(){const{A:r,B:t,C:n,D:a,E:i,F:o,G:l,H:c}=this;return[r,t,n,a,i,o,l,c]}set(r,t,n,a,i,o,l,c){this.A=r|0,this.B=t|0,this.C=n|0,this.D=a|0,this.E=i|0,this.F=o|0,this.G=l|0,this.H=c|0}process(r,t){for(let g=0;g<16;g++,t+=4)_e[g]=r.getUint32(t,!1);for(let g=16;g<64;g++){const m=_e[g-15],y=_e[g-2],k=ue(m,7)^ue(m,18)^m>>>3,_=ue(y,17)^ue(y,19)^y>>>10;_e[g]=_+_e[g-7]+k+_e[g-16]|0}let{A:n,B:a,C:i,D:o,E:l,F:c,G:f,H:h}=this;for(let g=0;g<64;g++){const m=ue(l,6)^ue(l,11)^ue(l,25),y=h+m+En(l,c,f)+Vn[g]+_e[g]|0,_=(ue(n,2)^ue(n,13)^ue(n,22))+In(n,a,i)|0;h=f,f=c,c=l,l=o+y|0,o=i,i=a,a=n,n=y+_|0}n=n+this.A|0,a=a+this.B|0,i=i+this.C|0,o=o+this.D|0,l=l+this.E|0,c=c+this.F|0,f=f+this.G|0,h=h+this.H|0,this.set(n,a,i,o,l,c,f,h)}roundClean(){Ct(_e)}destroy(){this.set(0,0,0,0,0,0,0,0),Ct(this.buffer)}}class Mn extends Ln{constructor(){super(32);Y(this,"A",we[0]|0);Y(this,"B",we[1]|0);Y(this,"C",we[2]|0);Y(this,"D",we[3]|0);Y(this,"E",we[4]|0);Y(this,"F",we[5]|0);Y(this,"G",we[6]|0);Y(this,"H",we[7]|0)}}const Tn=Sn(()=>new Mn,An(1));var Ir=e=>{let r=e.find(t=>t.isHead);if(!r)throw new Error("No head node found");return r},Lt=e=>{var r,t;if(!(e.data.isFinished||(r=e.data.startedWriteNodeIds)!=null&&r.length))return(t=[...e.data.messages].reverse().find(n=>n.groupId&&e.nodes.some(a=>a.id===n.groupId&&a.type.startsWith("question-"))&&(n.type==="system"||"author"in n&&n.author==="user")))==null?void 0:t.groupId},St=e=>Array.isArray(e)?e.map(St):e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).sort(([r],[t])=>r.localeCompare(t)).map(([r,t])=>[r,St(t)])):typeof e=="function"?void 0:e,Rn=e=>Cn(Tn(new TextEncoder().encode(JSON.stringify(St(e)))));function Dn(e,r,t,n){var a;if(n!=null&&n.aborted)return;let i=Rn(t),o=(a=e.data).preApplyFingerprints??(a.preApplyFingerprints=[]);if(o.includes(i))return;o.push(i);let l=new AbortController,c=setTimeout(()=>l.abort(),5e3);r.fetch("/flow/pre-apply",{method:"POST",signal:l.signal,body:JSON.stringify(t)}).catch(()=>{let f=o.indexOf(i);f!==-1&&o.splice(f,1)}).finally(()=>{clearTimeout(c)})}var Fr=({context:e,submissions:r})=>({context:e,submissions:r??{}}),ce=(e,r)=>vn(e,Fr(r)),Nn=(e,r)=>Ze(e,Fr(r)),Vr=({node:e,nodes:r,stopWhen:t})=>{if((t==null?void 0:t(e))===!0)return e;let n=e.nextId?r.find(a=>a.id===e.nextId):void 0;if(n)return Vr({node:n,nodes:r,stopWhen:t})},On=({childNode:e,nodes:r})=>{let t=r.filter(n=>n.type==="if-block").find(n=>{if(!n.branchId)return!1;let a=r.find(o=>o.id===n.branchId);if(!a)return!1;let i=Vr({node:a,nodes:r,stopWhen:o=>o.id===e.id});return!(!i||i.id!==e.id)});if(t!=null&&t.nextId)return r.find(n=>n.id===t.nextId)},jn=3,Bn=({flow:e,analytics:r,logger:t,talentBankClient:n,context:a,apiClient:i,getSubmissions:o,getApplicationRecovery:l,setApplicationRecovery:c,chatService:f,persistWriteBarrier:h,onSubmitNetworkError:g,closedRoleBehaviour:m,settledOutcomes:y=m,dateEchoLocale:k,onFlowEnd:_,onInterpret:w,forceSubmitConfirmation:S,flowType:x,t:N})=>{var R;let A=new AbortController,q={submitAccepted:!1};(R=e.data).startedWriteNodeIds??(R.startedWriteNodeIds=e.nodes.flatMap(M=>{var B,F;if(M.type!=="integration-application-submit"||!e.data.nodeHistory.includes(M.id))return[];let T=M.data.key?(B=o())==null?void 0:B[M.data.key]:void 0;return(T==null?void 0:T.type)==="integration"&&((F=s.ve(T.value))==null?void 0:F.verdict)==="not_submitted"?[]:[M.id]}));let O={...r.service,log:M=>r.service.log({...M,customProperties:{...M.customProperties,...r.customProperties}})},V=async(M,T)=>{let B=A.signal;if(B.aborted)return;let F=o(),L=l(),P=(L==null?void 0:L.submitNodeId)===M.id?e.nodes.find(D=>{var W;return D.id===L.fileQuestionNodeId&&D.type==="question-file"&&((W=F==null?void 0:F[D.data.key])==null?void 0:W.type)!=="file"}):void 0;if(P)return V(P,T);w==null||w(M,T);try{await $n({flow:e,analytics:O,logger:t,talentBankClient:n,apiClient:i,context:a,node:M,submissions:F,applicationRecovery:L,setApplicationRecovery:async D=>{if(!B.aborted)try{await c(D)}catch(W){t.error("Failed to persist application recovery",W)}},forceSubmitConfirmation:S||(L==null?void 0:L.submitNodeId)===M.id,run:q,persistWriteBarrier:h,onSubmitNetworkError:g,settledOutcomes:y,dateEchoLocale:k,flowType:x,signal:B,t:N,chat:{sendMessage:async D=>f.send({groupId:M.id,message:D,signal:B}),userInput:async D=>f.input({input:D,signal:B}),setSubmission:(D,W)=>{B.aborted||f.setSubmission(D,W)},captcha:f.captcha},next:D=>{if(B.aborted)return;let W=(L==null?void 0:L.fileQuestionNodeId)===M.id?L.submitNodeId:D,z=W?e.nodes.find(ee=>ee.id===W):On({childNode:M,nodes:e.nodes});return z?V(z,M):_==null?void 0:_(M)},end:()=>{B.aborted||(_==null||_(M))}})}catch(D){if(D instanceof s.O)return;throw D}};return{interpret:async M=>{let T=e.nodes.find(B=>B.id===M)??Ir(e.nodes);return V(T)},undo:M=>{var W;if(delete e.data.reviewReplay,((W=e.data.startedWriteNodeIds)==null?void 0:W.length)||e.data.isFinished)return{removed:0};let T=Lt(e),B=T?M.lastIndexOf(T):-1,F=e.nodes.find(z=>z.id===T);if(B===-1||!F)return{removed:0};let L=e.nodes.find(z=>z.id===M[M.length-1]);A.abort();let P=M.splice(B);e.data.messages=e.data.messages.filter(z=>!z.groupId||!P.includes(z.groupId)),e.data.currentInput=null;let D=o();for(let z of P.slice(1)){let ee=e.nodes.find(X=>X.id===z);if(!(!ee||!D||ee.id===T)&&("key"in ee.data&&ee.data.key&&delete D[ee.data.key],"keys"in ee.data))for(let X of Object.values(ee.data.keys))typeof X=="string"&&delete D[X]}return A=new AbortController,V(F,L),{removed:P.length}},abort:()=>{A.abort()}}};async function $n(e){let r=e.node;switch(r.type){case"flow-section":return await e.chat.sendMessage({type:"system",variant:"info",text:r.data.title}),e.next(r.nextId);case"pre-apply-result":return ds({...e,node:r});case"text":return ts({...e,node:r});case"image":return rs({...e,node:r});case"question-text":return ns({...e,node:r});case"question-enum":return is({...e,node:r});case"question-number":return ss({...e,node:r});case"question-phone":return as({...e,node:r});case"question-boolean":return os({...e,node:r});case"question-file":return cs({...e,node:r});case"question-address":return ls({...e,node:r});case"end-flow":return us({...e,node:r});case"if-block":return es({...e,node:r});case"jump":return qn({...e,node:r});case"link":return Qn({...e,node:r});case"integration-application-submit":return Zn({...e,node:r});case"add-submission":return zn({...e,node:r});case"integration-workflow-get":throw Error("Workflow should be unreachable");case"check-duplicate":return Un({...e,node:r});case"feedback":return Pn({...e,node:r});default:throw new Error(`Unknown node: ${JSON.stringify(r)}`)}}async function Pn({next:e,node:r}){e(r.nextId)}async function Un({next:e,node:r,talentBankClient:t,submissions:n,flow:a,logger:i,chat:o}){var c;let l={isDuplicate:!1};if(n&&t){let f=r.data.scope==="job"?(c=a.job)==null?void 0:c.id:void 0;if(r.data.scope==="company"||f!=null)try{l=await t.checkDuplicate({email:s.le({key:r.data.email,submissions:n}).toString(),jobId:f,scope:r.data.scope})}catch(h){i.error("[check-duplicate]",h)}}o.setSubmission(r.data.key,{type:"integration",value:l}),e(r.nextId)}async function qn({next:e,node:r}){e(r.data.targetId)}async function zn({next:e,node:r,logger:t,submissions:n,context:a}){if(!n){t.error("Submissions not found");return}n[r.data.key]={type:"string",value:ce(r.data.value,{submissions:n,context:a})},e(r.nextId)}var Wn=5e3,Hn=(e,r)=>r?`${e}@${r.id_type}:${r.id}`:e,Kn=(e,r=Date.now())=>Math.min(e.until,r+(e.maintenance?s.Q:e.throttles?s.J:s.Z)),Gn=(e,r,t)=>{let{waitMs:n,throttles:a,maintenance:i}=s._e(r==null?void 0:r.throttles,t);return{key:e,until:Date.now()+n,...a!==void 0&&{throttles:a},...i&&{maintenance:i}}},Jn=["ApiError","NotFoundError","UnauthorisedError","SchemaValidationError","ParsingError"],At=e=>e instanceof Error&&Jn.includes(e.name)?e:void 0,Jt=e=>{let r=At(e);return(r==null?void 0:r.name)==="ApiError"?r:void 0};async function Zn({chat:e,next:r,end:t,node:n,logger:a,apiClient:i,submissions:o,analytics:l,flow:c,applicationRecovery:f,setApplicationRecovery:h,forceSubmitConfirmation:g,flowType:m,run:y,persistWriteBarrier:k,signal:_,onSubmitNetworkError:w,settledOutcomes:S,t:x}){var V,M;let N=async({redirect_url:T,message:B,button_text:F})=>{let{anonymous_id:L,session_id:P}=l.getSessionInfo();await e.sendMessage({type:"text",author:"bot",text:B??x("submission_redirect_message")});try{let D=new URL(T);L&&!D.searchParams.has("anonymous_id")&&D.searchParams.set("anonymous_id",L),await e.sendMessage({type:"link",href:D.toString(),text:F??x("complete_submission"),onClick:()=>{if(!P){a.error("session_id not set, cannot log FLOW_REDIRECT event");return}l.log({event:"FLOW_REDIRECT",properties:{flow_build:c.build,flow_id:c.id,flow_session_id:P,flow_version:c.version,href:D.toString(),job:c.job}})}})}catch(D){a.error(`Invalid redirect URL: ${T}`,D),e.sendMessage({type:"system",variant:"error",text:x("redirect_url_error")})}};if((V=c.data.startedWriteNodeIds)!=null&&V.includes(n.id)&&(f==null?void 0:f.submitNodeId)!==n.id){let T=(M=c.data.submitRedirects)==null?void 0:M[n.id];return T?(await N(T),r(n.nextId)):(await e.sendMessage({type:"system",variant:"warning",text:x("submission_unknown")}),t())}let R=Hn(n.id,c.job),A=0,q=y.submitAccepted&&n.data.skipConfirmation===!0&&(f==null?void 0:f.submitNodeId)!==n.id,O=async T=>{var He,rt,nt,ht,Ke,u,d,p,C;let B=((He=c.data.submitCooldown)==null?void 0:He.key)===R?c.data.submitCooldown:void 0;B&&(B.until=Kn(B));let F=B==null?void 0:B.until;(c.data.reviewRequiresSend===!0&&!q||T!==!0||F!==void 0&&F>Date.now())&&await e.userInput({type:"submit",key:void 0,config:{label:n.data.submitLabel,...F!==void 0&&{availableAt:F}}}),q=!1;let L;if(n.data.captcha){let b=e.captcha,v=!0;try{L=await bn(i,{signal:_,container:(b==null?void 0:b.container())??null,theme:b==null?void 0:b.theme,onInteractive:()=>{e.sendMessage({type:"text",author:"bot",text:x("captcha_check")}).catch(()=>{}).then(()=>{v&&(b==null||b.reveal(!0))})}})}catch(I){if(a.error("Captcha check failed",I),_.aborted)return}finally{v=!1,b==null||b.reveal(!1)}}await e.sendMessage({type:"loading",text:x("submitting")});let{anonymous_id:P,session_id:D}=l.getSessionInfo();if(_.aborted)return;let W=((rt=c.data.startedWriteNodeIds)==null?void 0:rt.includes(n.id))===!0;if((f==null?void 0:f.submitNodeId)===n.id&&await h(void 0),W||(c.data.startedWriteNodeIds=[...c.data.startedWriteNodeIds??[],n.id]),await k().catch(b=>a.error("Failed to persist application write barrier",b)),_.aborted)return;let z,ee=setTimeout(()=>{z=e.sendMessage({type:"loading",semantic:"submission-still-working",text:x("submission_still_working")}).catch(b=>a.error("Failed to send submission progress message",b))},Wn),X,H=await i.fetch("/flow/submit",{method:"POST",body:JSON.stringify({log_submit:!1,integration_id:n.data.integrationId,anonymous_id:P,session_id:D,job:c.job,flow_build:c.build,...L!==void 0&&{captcha_token:L},submissions:s.P(c.nodes,s.ue(o||{},n.data.submitKeys)),pre_apply:s.j(c.nodes,o||{},c.data.flowSessionId)})}).catch(b=>{X=b;let v=Jt(b);return(v==null?void 0:v.data)!==void 0?v.data:b});if(clearTimeout(ee),await z,_.aborted)return;if(X!==void 0&&!At(X)&&w)return await w(X,_),O(!0);c.data.stagingDestination=s.ye(H),n.data.key&&e.setSubmission(n.data.key,{type:"integration",value:H});let ze=(nt=Jt(X))==null?void 0:nt.status,Ve=typeof ze=="number"?ze:void 0,j=s.ve(H,Ve),Le=j===void 0&&Ve===429,Me=S==="terminal"&&((j==null?void 0:j.outcome)==="closed"||(j==null?void 0:j.outcome)==="duplicate"),ve=c.data.failedAttemptAt,Se=ve==null?void 0:ve[R];ve&&Se!==void 0&&Se>Date.now()&&(Se=ve[R]=Date.now());let Te=Se!==void 0&&Date.now()-Se<s.we||((ht=c.data.unconfirmedAttemptKeys)==null?void 0:ht.includes(R))===!0,We=(Ke=At(X))==null?void 0:Ke.status,he=s.Fe(H,typeof We=="number"?We:void 0);he&&l.log({event:"FLOW_SUBMIT",properties:{flow_id:c.id,flow_version:c.version,flow_session_id:c.data.flowSessionId,flow_build:c.build,service:he.service,response:he.response,captured:(H==null?void 0:H.captured)===!0,flow_type:(m==null?void 0:m())??"CHATBOT_DRAWER",job:c.job,...(j==null?void 0:j.outcome)==="duplicate"&&{outcome:Te?"duplicate_after_own_attempt":"duplicate"},...he.outcome&&{outcome:he.outcome}}});let Re=s.V(H)||(H==null?void 0:H.success)===!0;if((Re||s.W(H))&&(y.submitAccepted=!0),Re&&((u=c.data.submitCooldown)==null?void 0:u.throttles)!==void 0&&(delete c.data.submitCooldown.throttles,await k().catch(b=>a.error("Failed to persist submit cooldown reset",b))),s.V(H)){let{redirect_url:b,message:v,button_text:I}=H.integration_response.data,$={redirect_url:b,message:v,button_text:I};return _.aborted?void 0:(c.data.submitRedirects={...c.data.submitRedirects,[n.id]:$},await k().catch(U=>a.error("Failed to persist submit redirect",U)),await N($),r(n.nextId))}let tt=s.W(H);if(tt)return await e.sendMessage({type:"system",variant:"success",text:tt.message??x("submission_pending")}),r(n.nextId);if((H==null?void 0:H.success)===!0)return n.data.skipConfirmation!==!0&&await e.sendMessage({type:"system",variant:"success",text:x("submission_completed")}),r(n.nextId);let De=s.Ae(j),Ne=De!==void 0&&((d=o==null?void 0:o[De])==null?void 0:d.type)==="file"?De:void 0,Ae=Ne===void 0?void 0:c.nodes.find(b=>b.type==="question-file"&&b.data.key===Ne);if(!Ae&&!Me&&!s.ke(j)&&(c.data.submitCooldown=Gn(R,B,j)),(j==null?void 0:j.outcome)!=="duplicate"&&!Le&&(c.data.failedAttemptAt={...c.data.failedAttemptAt,[R]:Date.now()},(p=c.data.unconfirmedAttemptKeys)!=null&&p.includes(R)&&(c.data.unconfirmedAttemptKeys=c.data.unconfirmedAttemptKeys.filter(b=>b!==R))),(j==null?void 0:j.verdict)==="not_submitted"||(j==null?void 0:j.outcome)==="duplicate"||(j==null?void 0:j.outcome)==="closed"||Le||s.be(H,Ve)?(W||(c.data.startedWriteNodeIds=(C=c.data.startedWriteNodeIds)==null?void 0:C.filter(b=>b!==n.id)),(f==null?void 0:f.submitNodeId)===n.id&&await h(f),await k().catch(b=>a.error("Failed to persist application write barrier release",b))):await k().catch(b=>a.error("Failed to persist submit cooldown",b)),j){if(a.error(X??j.message),Ae&&Ne!==void 0)return e.setSubmission(Ne,null),await h({fileQuestionNodeId:Ae.id,submitNodeId:n.id}),await e.sendMessage({type:"system",variant:"error",text:x("submission_unreadable_document")}),r(Ae.id);if(j.outcome==="duplicate")return await e.sendMessage({type:"system",variant:Me?"success":"info",semantic:"submission-duplicate",text:x(Te?"submission_duplicate_earlier_attempt":"submission_duplicate")}),Me?(delete c.data.submitCooldown,t()):O(!1);if(j.outcome==="closed")return await e.sendMessage({type:"system",variant:"info",semantic:"submission-closed",text:x("submission_closed")}),Me?(delete c.data.submitCooldown,t()):O(!1);let b=s.xe(j);return b?(await e.sendMessage({type:"system",variant:"warning",text:b.until===void 0?x("submission_provider_maintenance_later"):x("submission_provider_maintenance",{time:s.he(b.until,void 0)})}),O(!1)):j.outcome==="unknown"?(await e.sendMessage({type:"system",variant:"warning",text:x(s.Ee(j)?"submission_unknown_do_not_resubmit":"submission_unknown")}),O(!1)):s.ke(j)?s.Se(H)?(await e.sendMessage({type:"text",author:"bot",text:j.message}),O(!1)):(A===0&&await e.sendMessage({type:"system",variant:"warning",text:x("captcha_failed")}),A++,O(A<=jn)):s.Re(j)?(await e.sendMessage({type:"system",variant:"error",text:x("submission_retryable")}),O(!1)):(await e.sendMessage({type:"system",variant:"error",text:x("submission_failed")}),t())}return a.error(X??H),Le?(await e.sendMessage({type:"system",variant:"error",text:x("submission_retryable")}),O(!1)):(await e.sendMessage({type:"system",variant:"error",text:x("submission_failed")}),t())};await O(g===!0&&!q?!1:n.data.skipConfirmation)}var Xn=/{{\s*\$context\.job\.apply_url\s*(?:\|[^}]*)?}}/,Yn=(e,r)=>{if(!Xn.test(e))return!1;try{let{protocol:t}=new URL(r);return t==="https:"||t==="http:"}catch{return!1}};async function Qn({chat:e,next:r,node:t,submissions:n,context:a,analytics:i,flow:o}){let l=ce(t.data.href,{submissions:n,context:a}),{flowSessionId:c}=o.data;await e.sendMessage({type:"link",href:l,text:ce(t.data.cta,{submissions:n,context:a}),...Yn(t.data.href,l)&&{onClick:()=>{i.log({event:"FLOW_REDIRECT",properties:{flow_build:o.build,flow_id:o.id,flow_session_id:c,flow_version:o.version,href:l,job:o.job}})}}}),r(t.nextId)}async function es({submissions:e,next:r,node:t,context:n}){r(Nn(t,{submissions:e,context:n})?t.branchId:t.nextId)}async function ts({chat:e,next:r,node:t,submissions:n,context:a}){await e.sendMessage({author:"bot",type:"text",text:ce(t.data.text,{submissions:n,context:a})}),r(t.nextId)}async function rs({chat:e,next:r,node:t}){await e.sendMessage({author:"bot",type:"image",url:t.data.url,height:t.data.height,width:t.data.width}),r(t.nextId)}async function ns({chat:e,next:r,node:t,submissions:n,context:a,t:i,dateEchoLocale:o}){await e.sendMessage({author:"bot",type:"text",text:ce(t.data.question,{submissions:n,context:a})});let l=t.data.format==="phone"?await e.userInput({key:t.data.key,type:"phone",config:{optional:t.data.optional,placeholder:t.data.placeholder,minChars:t.data.minChars,maxChars:t.data.maxChars,submissionFormat:"text",defaultValue:{}}}):await e.userInput({key:t.data.key,type:"text",config:{optional:t.data.optional,placeholder:t.data.placeholder,format:t.data.format,maxChars:t.data.maxChars,minChars:t.data.minChars,multiline:t.data.format==="text"&&t.data.multiline===!0}});l===null?await e.sendMessage({type:"system",variant:"info",semantic:"question-skipped",text:i("skipped")}):await e.sendMessage({author:"user",type:"text",text:l.type==="phone"?s.fe(l.value):t.data.format==="date"&&o!==void 0?s.Ie(l.value,o):l.value}),r(t.nextId)}async function ss({chat:e,next:r,node:t,submissions:n,context:a,t:i}){await e.sendMessage({author:"bot",type:"text",text:ce(t.data.question,{submissions:n,context:a})});let o=await e.userInput({key:t.data.key,type:"number",config:{max:t.data.max,min:t.data.min,optional:t.data.optional,placeholder:t.data.placeholder,decimalCases:t.data.decimalCases}});o===null?await e.sendMessage({type:"system",variant:"info",semantic:"question-skipped",text:i("skipped")}):await e.sendMessage({author:"user",type:"text",text:o.value.toString()}),r(t.nextId)}async function as({chat:e,next:r,node:t,submissions:n,context:a,t:i}){await e.sendMessage({author:"bot",type:"text",text:ce(t.data.question,{submissions:n,context:a})});let o=await e.userInput({key:t.data.key,type:"phone",config:{minChars:t.data.minChars,defaultValue:{countryCode:t.data.defaultCountryCode},placeholder:t.data.placeholder,submissionFormat:"phone",optional:t.data.optional}});o===null?await e.sendMessage({type:"system",variant:"info",semantic:"question-skipped",text:i("skipped")}):await e.sendMessage({author:"user",type:"text",text:o.type==="phone"?s.fe(o.value):o.value}),r(t.nextId)}async function is({chat:e,next:r,node:t,submissions:n,context:a,t:i}){await e.sendMessage({author:"bot",type:"text",text:ce(t.data.question,{submissions:n,context:a})});let o=await e.userInput({key:t.data.key,type:"multiple-choice",config:t.data});o.value.length===0?await e.sendMessage({type:"system",variant:"info",semantic:"question-skipped",text:i("skipped")}):await e.sendMessage({author:"user",type:"text",text:t.data.options.filter(l=>o.value.includes(l.value)).map(l=>l.label).join(", ")}),r(t.nextId)}async function os({chat:e,next:r,node:t,submissions:n,context:a,t:i}){await e.sendMessage({author:"bot",type:"text",text:ce(t.data.question,{submissions:n,context:a})});let o=await e.userInput({key:t.data.key,type:"boolean",config:{optional:t.data.optional,labels:{true:t.data.trueLabel,false:t.data.falseLabel}}});o===null?await e.sendMessage({type:"system",variant:"info",semantic:"question-skipped",text:i("skipped")}):await e.sendMessage({author:"user",type:"text",text:o.value===!0?t.data.trueLabel:t.data.falseLabel}),r(t.nextId)}async function ls({chat:e,next:r,node:t,t:n}){await e.sendMessage({author:"bot",type:"text",text:t.data.question});let a=await e.userInput({type:"address",key:t.data.key,config:{optional:t.data.optional,keys:t.data.keys,line2Required:t.data.line2Required,placeholder:t.data.placeholder}});if(a===null)await e.sendMessage({type:"system",variant:"info",semantic:"question-skipped",text:n("skipped")});else{let i=Object.values(a.value).filter(o=>o&&o.trim().length>0).join(", ");await e.sendMessage({author:"user",type:"text",text:i})}return r(t.nextId)}async function cs({node:e,chat:r,next:t,submissions:n,context:a,t:i}){await r.sendMessage({author:"bot",type:"text",text:ce(e.data.question,{submissions:n,context:a})});let o=await r.userInput({key:e.data.key,type:"file",config:{optional:e.data.optional,extensions:e.data.extensions,fileSizeLimitKib:e.data.maxSizeKb??10*1024,allowMultiple:e.data.multiple===!0}});if(o===null)await r.sendMessage({type:"system",variant:"info",semantic:"question-skipped",text:i("skipped")});else for(let l of o.value)await r.sendMessage({author:"user",type:"file",fileName:l.name,fileSizeKb:l.sizeKb});return t(e.nextId)}async function us({chat:e,end:r,node:t}){await e.sendMessage({type:"system",variant:"info",text:t.data.systemMessage}),r()}async function ds({node:e,flow:r,submissions:t,chat:n,next:a,apiClient:i,analytics:o,signal:l,context:c}){let f=s.C(r.nodes,t||{}),{answers:h,...g}=f;if(n.setSubmission(e.data.key,{type:"integration",value:g}),Dn(r,i,{...o.getSessionInfo(),job:r.job,flow_build:r.build,pre_apply:s.j(r.nodes,t||{},r.data.flowSessionId)},l),f.status!=="skipped"){let m=[f.status==="unavailable"?"We could not prepare your pre-apply summary. You can still continue to your application.":f.hasHardConcerns?e.data.messages.hard:f.hasAdvisoryConcerns?e.data.messages.advisory:e.data.messages.matched];for(let y of["hard","advisory"]){let k=h.filter(_=>!_.matched&&_.severity===y);k.length&&m.push((y==="hard"?"Role requirements":"Other things to consider")+`
|
|
2
|
-
`+k.map(_=>`• ${_.message}`).join(`
|
|
3
|
-
`))}await n.sendMessage({type:"text",author:"bot",text:m.join(`
|
|
4
|
-
|
|
5
|
-
`)}),f.hasHardConcerns&&e.data.alternativeLink&&await n.sendMessage({type:"link",href:e.data.alternativeLink.href,text:e.data.alternativeLink.label}),await n.userInput({type:"submit",key:void 0,config:{label:ce(e.data.continueLabel,{submissions:t,context:c})}})}return a(e.nextId)}const Zt=(e,r,t)=>{var n;return e.log({event:t,properties:{flow_id:r.id,flow_version:r.version,flow_session_id:r.data.flowSessionId,flow_build:r.build,flow_type:"CHATBOT_DRAWER",job:r.job},customProperties:(n=r.analytics)==null?void 0:n.customProperties})},Et="resume-prompt",fs=async({chatService:e,t:r,signal:t})=>{await e.send({message:{type:"text",author:"bot",text:r("resume_prompt")},groupId:Et,signal:t});const n=await e.input({input:{type:"boolean",key:void 0,config:{labels:{true:r("resume_continue"),false:r("resume_start_again")},optional:!1}},signal:t});return s.store.removeMessagesSentByNodeIds([Et]),(n==null?void 0:n.value)!==!1},Fe=({class:e,...r})=>{const{t}=s.useTranslation();return s.o("button",{class:s.clsx("bg-accent-9 active:bg-accent-10 pointer-coarse:touch-hitbox fr flex-shrink-0 rounded-full p-2 text-white transition-all disabled:cursor-not-allowed disabled:opacity-50",e),type:"submit",...r,children:s.o("svg",{class:"block",width:"16",height:"16",viewBox:"0 0 16 16",fill:"transparent",stroke:"currentColor","stroke-linecap":"round","stroke-width":"2",children:[s.o("title",{children:t("send")}),s.o("path",{d:"M3.5 7.5L8 3L12.5 7.5"}),s.o("path",{d:"M8 4V13"})]})})};var pe;function Mt(e){return{lang:(e==null?void 0:e.lang)??(pe==null?void 0:pe.lang),message:e==null?void 0:e.message,abortEarly:(e==null?void 0:e.abortEarly)??(pe==null?void 0:pe.abortEarly),abortPipeEarly:(e==null?void 0:e.abortPipeEarly)??(pe==null?void 0:pe.abortPipeEarly)}}var gt;function hs(e){return gt==null?void 0:gt.get(e)}var vt;function ps(e){return vt==null?void 0:vt.get(e)}var xt;function ms(e,r){var t;return(t=xt==null?void 0:xt.get(e))==null?void 0:t.get(r)}function Pe(e){var t,n;const r=typeof e;return r==="string"?`"${e}"`:r==="number"||r==="bigint"||r==="boolean"?`${e}`:r==="object"||r==="function"?(e&&((n=(t=Object.getPrototypeOf(e))==null?void 0:t.constructor)==null?void 0:n.name))??"null":r}function te(e,r,t,n,a){const i=a&&"input"in a?a.input:t.value,o=(a==null?void 0:a.expected)??e.expects??null,l=(a==null?void 0:a.received)??Pe(i),c={kind:e.kind,type:e.type,input:i,expected:o,received:l,message:`Invalid ${r}: ${o?`Expected ${o} but r`:"R"}eceived ${l}`,requirement:e.requirement,path:a==null?void 0:a.path,issues:a==null?void 0:a.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},f=e.kind==="schema",h=(a==null?void 0:a.message)??e.message??ms(e.reference,c.lang)??(f?ps(c.lang):null)??n.message??hs(c.lang);h!==void 0&&(c.message=typeof h=="function"?h(c):h),f&&(t.typed=!1),t.issues?t.issues.push(c):t.issues=[c]}function fe(e){return{version:1,vendor:"valibot",validate(r){return e["~run"]({value:r},Mt())}}}function ys(e,r){return Object.hasOwn(e,r)&&r!=="__proto__"&&r!=="prototype"&&r!=="constructor"}function bs(e,r){const t=[...new Set(e)];return t.length>1?`(${t.join(` ${r} `)})`:t[0]??"never"}function gs(e){if(e.path){let r="";for(const t of e.path)if(typeof t.key=="string"||typeof t.key=="number")r?r+=`.${t.key}`:r+=t.key;else return null;return r}return null}var Lr=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}},vs=/^[\w+-]+(?:\.[\w+-]+)*@[\da-z]+(?:[.-][\da-z]+)*\.[a-z]{2,}$/iu;function Mr(e,r){return{kind:"validation",type:"check",reference:Mr,async:!1,expects:null,requirement:e,message:r,"~run"(t,n){return t.typed&&!this.requirement(t.value)&&te(this,"input",t,n),t}}}function Tr(e){return{kind:"validation",type:"email",reference:Tr,expects:null,async:!1,requirement:vs,message:e,"~run"(r,t){return r.typed&&!this.requirement.test(r.value)&&te(this,"email",r,t),r}}}function Xe(e,r){return{kind:"validation",type:"max_length",reference:Xe,async:!1,expects:`<=${e}`,requirement:e,message:r,"~run"(t,n){return t.typed&&t.value.length>this.requirement&&te(this,"length",t,n,{received:`${t.value.length}`}),t}}}function Rr(e,r){return{kind:"validation",type:"max_value",reference:Rr,async:!1,expects:`<=${e instanceof Date?e.toJSON():Pe(e)}`,requirement:e,message:r,"~run"(t,n){return t.typed&&!(t.value<=this.requirement)&&te(this,"value",t,n,{received:t.value instanceof Date?t.value.toJSON():Pe(t.value)}),t}}}function $e(e,r){return{kind:"validation",type:"min_length",reference:$e,async:!1,expects:`>=${e}`,requirement:e,message:r,"~run"(t,n){return t.typed&&t.value.length<this.requirement&&te(this,"length",t,n,{received:`${t.value.length}`}),t}}}function Dr(e,r){return{kind:"validation",type:"min_value",reference:Dr,async:!1,expects:`>=${e instanceof Date?e.toJSON():Pe(e)}`,requirement:e,message:r,"~run"(t,n){return t.typed&&!(t.value>=this.requirement)&&te(this,"value",t,n,{received:t.value instanceof Date?t.value.toJSON():Pe(t.value)}),t}}}function Tt(e,r){return{kind:"validation",type:"regex",reference:Tt,async:!1,expects:`${e}`,requirement:e,message:r,"~run"(t,n){return t.typed&&!this.requirement.test(t.value)&&te(this,"format",t,n),t}}}function Rt(e){return{kind:"transformation",type:"transform",reference:Rt,async:!1,operation:e,"~run"(r){return r.value=this.operation(r.value),r}}}function Nr(e){return{kind:"validation",type:"url",reference:Nr,async:!1,expects:null,requirement(r){try{return new URL(r),!0}catch{return!1}},message:e,"~run"(r,t){return r.typed&&!this.requirement(r.value)&&te(this,"URL",r,t),r}}}function xs(e,r,t){return typeof e.fallback=="function"?e.fallback(r,t):e.fallback}function Or(e,r,t){return typeof e.default=="function"?e.default(r,t):e.default}function jr(e,r){return{kind:"schema",type:"array",reference:jr,expects:"Array",async:!1,item:e,message:r,get"~standard"(){return fe(this)},"~run"(t,n){var i;const a=t.value;if(Array.isArray(a)){t.typed=!0,t.value=[];for(let o=0;o<a.length;o++){const l=a[o],c=this.item["~run"]({value:l},n);if(c.issues){const f={type:"array",origin:"value",input:a,key:o,value:l};for(const h of c.issues)h.path?h.path.unshift(f):h.path=[f],(i=t.issues)==null||i.push(h);if(t.issues||(t.issues=c.issues),n.abortEarly){t.typed=!1;break}}c.typed||(t.typed=!1),t.value.push(c.value)}}else te(this,"type",t,n);return t}}}function Br(e){return{kind:"schema",type:"boolean",reference:Br,expects:"boolean",async:!1,message:e,get"~standard"(){return fe(this)},"~run"(r,t){return typeof r.value=="boolean"?r.typed=!0:te(this,"type",r,t),r}}}function $r(e){return{kind:"schema",type:"number",reference:$r,expects:"number",async:!1,message:e,get"~standard"(){return fe(this)},"~run"(r,t){return typeof r.value=="number"&&!isNaN(r.value)?r.typed=!0:te(this,"type",r,t),r}}}function be(e,r){return{kind:"schema",type:"object",reference:be,expects:"Object",async:!1,entries:e,message:r,get"~standard"(){return fe(this)},"~run"(t,n){var i;const a=t.value;if(a&&typeof a=="object"){t.typed=!0,t.value={};for(const o in this.entries){const l=this.entries[o];if(o in a||(l.type==="exact_optional"||l.type==="optional"||l.type==="nullish")&&l.default!==void 0){const c=o in a?a[o]:Or(l),f=l["~run"]({value:c},n);if(f.issues){const h={type:"object",origin:"value",input:a,key:o,value:c};for(const g of f.issues)g.path?g.path.unshift(h):g.path=[h],(i=t.issues)==null||i.push(g);if(t.issues||(t.issues=f.issues),n.abortEarly){t.typed=!1;break}}f.typed||(t.typed=!1),t.value[o]=f.value}else if(l.fallback!==void 0)t.value[o]=xs(l);else if(l.type!=="exact_optional"&&l.type!=="optional"&&l.type!=="nullish"&&(te(this,"key",t,n,{input:void 0,expected:`"${o}"`,path:[{type:"object",origin:"key",input:a,key:o,value:a[o]}]}),n.abortEarly))break}}else te(this,"type",t,n);return t}}}function Be(e,r){return{kind:"schema",type:"optional",reference:Be,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:r,get"~standard"(){return fe(this)},"~run"(t,n){return t.value===void 0&&(this.default!==void 0&&(t.value=Or(this,t,n)),t.value===void 0)?(t.typed=!0,t):this.wrapped["~run"](t,n)}}}function Pr(e,r){return{kind:"schema",type:"picklist",reference:Pr,expects:bs(e.map(Pe),"|"),async:!1,options:e,message:r,get"~standard"(){return fe(this)},"~run"(t,n){return this.options.includes(t.value)?t.typed=!0:te(this,"type",t,n),t}}}function Ur(e,r,t){return{kind:"schema",type:"record",reference:Ur,expects:"Object",async:!1,key:e,value:r,message:t,get"~standard"(){return fe(this)},"~run"(n,a){var o,l;const i=n.value;if(i&&typeof i=="object"){n.typed=!0,n.value={};for(const c in i)if(ys(i,c)){const f=i[c],h=this.key["~run"]({value:c},a);if(h.issues){const m={type:"object",origin:"key",input:i,key:c,value:f};for(const y of h.issues)y.path=[m],(o=n.issues)==null||o.push(y);if(n.issues||(n.issues=h.issues),a.abortEarly){n.typed=!1;break}}const g=this.value["~run"]({value:f},a);if(g.issues){const m={type:"object",origin:"value",input:i,key:c,value:f};for(const y of g.issues)y.path?y.path.unshift(m):y.path=[m],(l=n.issues)==null||l.push(y);if(n.issues||(n.issues=g.issues),a.abortEarly){n.typed=!1;break}}(!h.typed||!g.typed)&&(n.typed=!1),h.typed&&(n.value[h.value]=g.value)}}else te(this,"type",n,a);return n}}}function ae(e){return{kind:"schema",type:"string",reference:ae,expects:"string",async:!1,message:e,get"~standard"(){return fe(this)},"~run"(r,t){return typeof r.value=="string"?r.typed=!0:te(this,"type",r,t),r}}}function qr(e,r,t){const n=e["~run"]({value:r},Mt(t));if(n.issues)throw new Lr(n.issues);return n.value}function ws(e,r){const t={};for(const n in e.entries)t[n]=!r||r.includes(n)?Be(e.entries[n]):e.entries[n];return{...e,entries:t,get"~standard"(){return fe(this)}}}function Ce(...e){return{...e[0],pipe:e,get"~standard"(){return fe(this)},"~run"(r,t){for(const n of e)if(n.kind!=="metadata"){if(r.issues&&(n.kind==="schema"||n.kind==="transformation")){r.typed=!1;break}(!r.issues||!t.abortEarly&&!t.abortPipeEarly)&&(r=n["~run"](r,t))}return r}}}async function _s(e,r,t){const n=await e["~run"]({value:r},Mt(t));return{typed:n.typed,success:!n.issues,output:n.value,issues:n.issues}}const qe=({error:e})=>!e||!e.message?null:s.o("div",{role:"alert",class:"text-error-11 flex max-w-full items-start gap-1 overflow-hidden rounded-2xl px-2 py-2",children:[s.o("svg",{class:"text-error-9 mt-0.5 h-4 w-4 shrink-0",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.o("circle",{cx:"8",cy:"8",r:"6.3",stroke:"currentColor","stroke-width":"1.4"}),s.o("rect",{x:"7",y:"4",width:"2",height:"5",fill:"currentColor"}),s.o("rect",{x:"7",y:"10",width:"2",height:"2",fill:"currentColor"})]}),s.o("p",{class:"break-words pr-1 text-sm",children:e.message})]}),ge=({class:e,...r})=>{const{t}=s.useTranslation();return s.o("button",{type:"button",class:s.clsx("fr touch-hitbox text-neutral-11 bg-neutral-1 ring-divider hover:ring-divider active:ring-interactive-bg-hover hover:text-neutral-12 active:text-neutral-12 hover:bg-divider active:bg-interactive-bg-hover flex flex-shrink-0 items-center justify-center gap-1 self-center rounded-full py-1 pl-2 pr-2.5 text-sm ring-1 transition-all",e),...r,children:[s.o("svg",{"aria-hidden":!0,class:"block",width:"16",height:"16",viewBox:"0 0 16 16",fill:"transparent",stroke:"currentColor","stroke-linecap":"round","stroke-width":"1.5",children:[s.o("title",{children:t("skip")}),s.o("path",{d:"M3.25 11.25A5 5 0 0 1 12 7"}),s.o("path",{d:"M13.25 4.5V8.25H9.5"})]}),t("skip")]})};var Dt={Afghanistan:"93",Albania:"355",Algeria:"213","American Samoa":"1 684",Andorra:"376",Angola:"244",Anguilla:"1 264",Antarctica:"672","Antigua and Barbuda":"1 268",Argentina:"54",Armenia:"374",Aruba:"297",Australia:"61",Austria:"43",Azerbaijan:"994",Bahrain:"973",Bangladesh:"880",Barbados:"1 246",Belarus:"375",Belgium:"32",Belize:"501",Benin:"229",Bermuda:"1 441",Bhutan:"975",Bolivia:"591","Bosnia and Herzegovina":"387",Botswana:"267","Bouvet Island":"47",Brazil:"55","British Indian Ocean Territory":"246","British Virgin Islands":"1 284",Brunei:"673",Bulgaria:"359","Burkina Faso":"226",Burundi:"257","Cabo Verde":"238",Cambodia:"855",Cameroon:"237",Canada:"1","Caribbean Netherlands":"599","Cayman Islands":"1 345","Central African Republic":"236",Chad:"235",Chile:"56",China:"86","Christmas Island":"61","Cocos (Keeling) Islands":"61",Colombia:"57",Comoros:"269","Cook Islands":"682","Costa Rica":"506",Croatia:"385",Cuba:"53",Curaçao:"599",Cyprus:"357",Czechia:"420","Côte d'Ivoire":"225","Democratic Republic of the Congo":"243",Denmark:"45",Djibouti:"253","Dominican Republic":"1 809",Ecuador:"593",Egypt:"20","El Salvador":"503","Equatorial Guinea":"240",Eritrea:"291",Estonia:"372",Eswatini:"268",Ethiopia:"251","Falkland Islands (Islas Malvinas)":"500","Faroe Islands":"298",Fiji:"679",Finland:"358",France:"33","French Guiana":"594","French Polynesia":"689","French Southern and Antarctic Lands":"262",Gabon:"241",Georgia:"995",Germany:"49",Ghana:"233",Gibraltar:"350",Greece:"30",Greenland:"299",Grenada:"1 473",Guadeloupe:"590",Guam:"1 671",Guatemala:"502",Guernsey:"44",Guinea:"224","Guinea-Bissau":"245",Guyana:"592",Haiti:"509",Honduras:"504","Hong Kong":"852",Hungary:"36",Iceland:"354",India:"91",Indonesia:"62",Iran:"98",Iraq:"964",Ireland:"353","Isle of Man":"44",Israel:"972",Italy:"39",Jamaica:"1 876",Japan:"81",Jersey:"44",Jordan:"962",Kazakhstan:"7",Kenya:"254",Kiribati:"686",Kosovo:"383",Kuwait:"965",Kyrgyzstan:"996",Laos:"856",Latvia:"371",Lebanon:"961",Lesotho:"266",Liberia:"231",Libya:"218",Liechtenstein:"423",Lithuania:"370",Luxembourg:"352",Macao:"853",Madagascar:"261",Malawi:"265",Malaysia:"60",Maldives:"960",Mali:"223",Malta:"356","Marshall Islands":"692",Martinique:"596",Mauritania:"222",Mauritius:"230",Mayotte:"262",Mexico:"52",Micronesia:"691",Moldova:"373",Monaco:"377",Mongolia:"976",Montenegro:"382",Montserrat:"1 664",Morocco:"212",Mozambique:"258","Myanmar (Burma)":"95",Namibia:"264",Nauru:"674",Nepal:"977",Netherlands:"31","New Caledonia":"687","New Zealand":"64",Nicaragua:"505",Niger:"227",Nigeria:"234",Niue:"683","Norfolk Island":"672","North Korea":"850","North Macedonia":"389","Northern Mariana Islands":"1 670",Norway:"47",Oman:"968",Pakistan:"92",Palau:"680",Palestine:"970",Panama:"507","Papua New Guinea":"675",Paraguay:"595",Peru:"51",Philippines:"63","Pitcairn Islands":"64",Poland:"48",Portugal:"351","Puerto Rico":"1 787",Qatar:"974",Romania:"40",Russia:"7",Rwanda:"250",Réunion:"262","Saint Barthélemy":"590","Saint Helena, Ascension and Tristan da Cunha":"290","Saint Kitts and Nevis":"1 869","Saint Lucia":"1 758","Saint Martin":"590","Saint Pierre and Miquelon":"508","Saint Vincent and the Grenadines":"1 784",Samoa:"685","San Marino":"378","Saudi Arabia":"966",Senegal:"221",Serbia:"381",Seychelles:"248","Sierra Leone":"232",Singapore:"65","Sint Maarten":"1 721",Slovakia:"421",Slovenia:"386","Solomon Islands":"677",Somalia:"252","South Africa":"27","South Georgia and the South Sandwich Islands":"500","South Korea":"82","South Sudan":"211",Spain:"34","Sri Lanka":"94",Sudan:"249",Suriname:"597","Svalbard and Jan Mayen":"47",Sweden:"46",Switzerland:"41",Syria:"963","São Tomé and Príncipe":"239",Taiwan:"886",Tajikistan:"992",Tanzania:"255",Thailand:"66","The Bahamas":"1 242","The Gambia":"220","Timor-Leste":"670",Togo:"228",Tokelau:"690",Tonga:"676","Trinidad and Tobago":"1 868",Tunisia:"216",Turkmenistan:"993","Turks and Caicos Islands":"1 649",Tuvalu:"688",Türkiye:"90","U.S. Virgin Islands":"1 340",Uganda:"256",Ukraine:"380","United Arab Emirates":"971","United Kingdom":"44","United States":"1","United States Minor Outlying Islands":"1",Uruguay:"598",Uzbekistan:"998",Vanuatu:"678","Vatican City":"379",Venezuela:"58",Vietnam:"84","Wallis and Futuna":"681","Western Sahara":"212",Yemen:"967",Zambia:"260",Zimbabwe:"263","Åland Islands":"358"},ks=e=>{if(e==="")return{countryCode:"",phoneNumber:""};let r=Object.values(Dt).find(n=>e.startsWith(n))??"",t=e.replace(r,"");return/^\d+$/.test(t)?{countryCode:r,phoneNumber:t}:{countryCode:"",phoneNumber:""}};const Ue=s.cva("outline-divider ease-expo-out placeholder:text-neutral-10 text-neutral-12 focus-visible:outline-accent-7 caret-accent-9 bg-lowest py-1 text-base outline outline-2 transition-all",{variants:{optional:{true:"pr-16 pl-3",false:"pl-3 pr-3"}},defaultVariants:{optional:!1}}),Cs="https://api.mapbox.com/search/searchbox/v1/suggest",Ss="ZzRDWFU0dTZ3SF9aWk9RNGl6QzZaWS5RZmlFak13a0hPbGxXZXlNSGN5RUhObUJ6TXpSV08yUW5OdE5tSTZJU1lpd2lJb1JYYXRObmJ2Tm5iaGhHZWx4V1lpb2pJMUp5ZS5rcA==",As=e=>atob(e).split("").reverse().join(""),me=be({name:ae()}),Es=be({suggestions:jr(be({feature_type:Be(ae()),full_address:Be(ae()),place_formatted:Be(ae()),name:Be(ae()),mapbox_id:ae(),context:ws(be({address:me,street:me,neighborhood:me,locality:me,district:me,place:me,region:me,postcode:me,country:me}))}))}),Is=e=>(s.p(()=>{e&&at.addressSearchCountry(e)},[e]),s.F(()=>{var t;const r=(t=s.store.current$.peek().flow)==null?void 0:t.data.flowSessionId;return r?{enabled:!0,getPredictions:async(n,a)=>{var g;const i=new URL(Cs);i.searchParams.set("q",n),i.searchParams.set("session_token",r);const o=e&&at.addressSearchCountry(e);i.searchParams.set("limit","5");const l=(g=s.store.current$.peek().flow)==null?void 0:g.locationOrigin;l&&l.lat!==void 0&&l.lng!==void 0&&l.lat>=-90&&l.lat<=90&&l.lng>=-180&&l.lng<=180&&i.searchParams.set("proximity",`${l.lng},${l.lat}`),i.searchParams.set("access_token",As(Ss));const f=async m=>{const y=new URL(i);m&&y.searchParams.set("country",m);const k=await fetch(y.href,{signal:a});if(!k.ok)throw new Error(`Address lookup failed with ${k.status}`);return qr(Es,await k.json()).suggestions};return(await at.searchAddressSuggestions(f,o,a)).map(m=>{var y,k,_,w,S,x,N,R,A;return{country:o,label:m.full_address??([m.name,m.place_formatted].filter(Boolean).join(", ")||m.mapbox_id),id:m.mapbox_id,address:{line1:((y=m.context.address)==null?void 0:y.name)??((k=m.context.street)==null?void 0:k.name),line2:void 0,line3:((_=m.context.neighborhood)==null?void 0:_.name)??((w=m.context.locality)==null?void 0:w.name),city:((S=m.context.place)==null?void 0:S.name)??((x=m.context.district)==null?void 0:x.name),state:(N=m.context.region)==null?void 0:N.name,postcode:((R=m.context.postcode)==null?void 0:R.name)??(m.feature_type==="postcode"?m.name:void 0),country:(A=m.context.country)==null?void 0:A.name}}})}}:{enabled:!1}},[e])),Xt=e=>{const{t:r}=s.useTranslation();return s.o("button",{type:"button",class:"touch-hitbox text-neutral-11 hover:bg-neutral-4 hover:text-neutral-12 hover:border-neutral-5 relative flex items-center gap-1 rounded-[18px] border border-solid border-transparent px-3 py-1 pl-1.5 text-sm transition-colors",...e,children:[s.o("svg",{width:"16",height:"16",viewBox:"0 0 16 16",stroke:"currentColor","stroke-width":"1.5",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.o("path",{d:"M10 3L5 8L10 13"})}),s.o("span",{children:r("back")})]})},Fs=({input:e,onSubmitSuccess:r,logger:t,analytics:n,rpcClient:a})=>{const{t:i}=s.useTranslation(),[o,l]=s.h(),{enabled:c,getPredictions:f}=Is(a),[h,g]=s.h(c?"query":"manual"),[m,y]=s.h(""),[k,_]=s.h(),w=s._(),S=()=>{var A;(A=w.current)==null||A.controller.abort(),w.current=void 0};s.p(()=>S,[]);const x=s._(),N=A=>{var O;if(s.invariant(c,"Query state should not be enabled"),A=A.trim(),A===((O=w.current)==null?void 0:O.query)||A===(k==null?void 0:k.query)&&k.status==="done")return;if(S(),y(A),A===""){_(void 0);return}const q=w.current={query:A,controller:new AbortController};_({query:A,status:"pending"}),f(A,q.controller.signal).then(V=>{w.current===q&&(w.current=void 0,_({query:A,status:"done",items:V}))},V=>{w.current===q&&(w.current=void 0,t.error("Failed to get address details",V instanceof Lr?"Unexpected response":V),_({query:A,status:"failed",error:i("address_error")}))})},R=(A,q)=>{l(O=>({...O,[A]:q}))};switch(h){case"query":return s.invariant(c,"Query state should not be enabled"),s.o(Vs,{input:e,onSkip:()=>r(null),onAddressSelect:(A,q)=>{if(A===""){w.current&&(S(),_(void 0)),g("manual");return}const O=(k==null?void 0:k.status)==="done"?k.items.find(V=>V.id===A):void 0;O&&(dn({query:q,country:O.country,pickedLabel:O.label,pickedPostcode:O.address.postcode,pickedCountry:O.address.country,pickedState:O.address.state,log:V=>n.log({event:"ADDRESS_SHADOW_COMPARED",properties:V})}),x.current!==A&&l(O.address),x.current=A,g("details"))},onAddressSearch:N,lookup:k,query:m});case"details":return s.invariant(o!==void 0),s.o(Yt,{input:e,logger:t,onSubmitSuccess:r,addressFields:o,onFieldChange:R,actions:s.o(Xt,{onClick:()=>{g("query")}})});case"manual":return s.o(Yt,{logger:t,input:e,onSubmitSuccess:r,addressFields:o??{},onFieldChange:R,actions:c?s.o(Xt,{onClick:()=>{g("query")}}):e.config.optional?s.o(ge,{onClick:()=>r(null)}):void 0})}},Vs=({input:e,onSkip:r,lookup:t,onAddressSelect:n,query:a,onAddressSearch:i})=>{const{t:o}=s.useTranslation(),l=s._(null);return s.y(()=>{l.current&&(l.current.focus(),l.current.select())},[]),s.o(s.k,{children:[s.o("form",{noValidate:!0,onSubmit:c=>{c.preventDefault();const h=new FormData(c.currentTarget).get("address");typeof h=="string"&&i(h)},class:"flex gap-2 p-2.5",children:[s.o("div",{class:"group relative flex-1",children:[s.o("input",{ref:l,name:"address",id:"chat-address",autocomplete:"address-line1",autoFocus:!0,placeholder:e.config.placeholder||o("address_search"),defaultValue:a,class:Ue({optional:!!e.config.optional,className:"w-full rounded-full"})}),s.o("button",{type:"submit",class:"touch-hitbox text-neutral-12 hover:bg-neutral-3 fr absolute bottom-0 right-0 top-0 flex cursor-pointer items-center gap-1 rounded-full px-3 transition-all",children:[s.o("svg",{"aria-hidden":"true",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.o("g",{id:"inploi",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round",strokeWidth:"1.5",children:[s.o("circle",{cx:"7",cy:"7",r:"4"}),s.o("path",{d:"M10 10L13 13"})]})}),s.o("span",{class:"sr-only",children:o("search")})]})]}),e.config.optional&&s.o(ge,{class:"relative",onClick:r})]}),(t==null?void 0:t.status)==="failed"?s.o(qe,{error:{message:t.error}}):null,s.o("p",{role:"status",class:(t==null?void 0:t.status)==="pending"||(t==null?void 0:t.status)==="done"&&t.items.length===0?"text-neutral-11 flex items-center gap-2 px-4 py-2 text-sm":"sr-only",children:(t==null?void 0:t.status)==="pending"?s.o(s.k,{children:[s.o(s.LoadingIndicator,{"aria-hidden":"true",class:"h-4 w-4 shrink-0"}),o("address_searching")]}):(t==null?void 0:t.status)==="done"&&t.items.length===0?o("address_no_results"):null}),s.o("ul",{children:[((t==null?void 0:t.status)==="done"?t.items:[]).map(c=>s.o("li",{children:s.o("button",{class:"text-neutral-11 fr hover:bg-neutral-3 focus-visible:bg-neutral-3 hover:text-neutral-12 border-b-neutral-3 flex w-full items-center border border-b border-solid border-transparent px-4 py-3 text-sm transition-colors duration-100",onClick:()=>{var f;n(c.id,((f=l.current)==null?void 0:f.value)??a??"")},children:[s.o("span",{class:"flex-grow",children:c.label}),s.o("svg",{class:"flex-none",width:"16",height:"16",viewBox:"0 0 16 16",stroke:"currentColor","stroke-width":"1.5",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.o("path",{d:"M6 3L11 8L6 13"})})]})},c.id)),s.o("li",{children:s.o("button",{class:"text-neutral-11 fr hover:bg-neutral-3 focus-visible:bg-neutral-3 hover:text-neutral-12 border-b-neutral-3 flex w-full items-center border border-b border-solid border-transparent px-4 py-3 text-sm transition-colors duration-100",onClick:()=>{var c;n("",((c=l.current)==null?void 0:c.value)??a??"")},children:s.o("span",{class:"flex-grow",children:o("address_manual")})})},"")]})]})},wt=["line1","line2","line3","city","state","postcode","country"],Yt=({addressFields:e,onFieldChange:r,onSubmitSuccess:t,actions:n,input:a})=>{const i=s._(null);s.y(()=>{if(i.current){const c=i.current.querySelector("input");c&&(c.focus(),c.select())}},[]);const o=Object.keys(Dt),{t:l}=s.useTranslation();return s.o("form",{class:"flex flex-col px-2 pt-2",onSubmit:c=>{c.preventDefault();const f=c.currentTarget,h=[...f.querySelectorAll("input")].filter(y=>y.value!==""&&!y.value.trim());for(const y of h){y.value="";const k=wt.find(_=>a.config.keys[_]===y.name);k&&r(k,"")}if(h.length>0&&!f.checkValidity()){f.reportValidity();return}const g=new FormData(f),m=Object.fromEntries(g.entries());t({type:"address",value:m})},children:[s.o("div",{class:"bg-neutral-3 border-neutral-5 grid items-center gap-1.5 rounded-2xl border pb-2 pl-4 pr-3 pt-3 [grid-template-columns:min-content_1fr]",ref:i,children:wt.map((c,f)=>{const h=`isdk_${c}`,g=a.config.keys[c];return g?s.o(s.k,{children:[s.o("label",{for:h,class:"text-neutral-11 [&:has(+*>input:focus)]:text-neutral-12 w-24 pb-2 text-xs uppercase leading-3 tracking-widest transition-colors",children:l(c)}),s.o("div",{class:"flex flex-col items-stretch gap-1.5",children:[c==="country"?s.o("div",{class:"relative",children:[s.o("select",{class:"text-neutral-12 hover:bg-neutral-4 placeholder:text-neutral-8 focus:bg-neutral-5 w-full flex-1 appearance-none rounded-lg border-solid bg-transparent bg-none px-3 py-1.5 text-base transition-colors focus:outline-none",name:g,id:h,defaultValue:e[c],onChange:m=>r(c,m.currentTarget.value),required:!0,children:[e.country&&!o.includes(e.country)?s.o("option",{value:e[c],children:e[c]}):s.o("option",{value:"",children:l("select_country")}),o.map(m=>s.o("option",{value:m,children:m},m))]}),s.o("svg",{class:"text-neutral-12 absolute bottom-2.5 right-2 flex items-center justify-center",width:"16",height:"16",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.o("path",{d:"M4 6.5L8 10.5L12 6.5"})})]}):s.o("input",{autoFocus:f===0?!0:void 0,class:"text-neutral-12 hover:bg-neutral-4 placeholder:text-neutral-8 focus:bg-neutral-5 flex-1 rounded-lg border-solid bg-transparent px-3 py-1.5 text-base transition-colors autofill:shadow-[inset_0_0_0_1000px_hsl(210_16.7%_97.6%)] focus:outline-none",name:g,id:h,defaultValue:e[c],onInput:m=>r(c,m.currentTarget.value),required:c==="line2"?a.config.line2Required===!0:c!=="line3"}),f===wt.length-1?s.o("hr",{class:"m-0 w-full border-b border-b-transparent"}):s.o("hr",{class:"border-b-neutral-5 m-0 w-full border-b border-solid"})]})]}):null})}),s.o("div",{class:"bg-neutral-1 sticky bottom-0 flex items-center py-2",children:[n,s.o(Fe,{class:"ml-auto"})]})]})},Nt=()=>{const e=s._(null);return s.p(()=>{var r;(r=e.current)==null||r.focus()},[]),e},zr=["true","false"],Ls=Pr(zr),Ms="answer",Wr="flex items-center flex-wrap gap-2 p-2.5",Hr="min-w-0 max-w-full flex-auto",Kr=s.k$1(({label:e,...r},t)=>s.o("button",{class:"bg-lowest ease-expo-out ring-divider text-neutral-12 active:ring-accent-7 active:bg-accent-2 active:text-accent-11 fr block w-full overflow-hidden rounded-2xl px-2 py-2.5 ring-2 transition-all selection:bg-transparent",...r,ref:t,children:s.o("p",{class:"text-center text-base",children:e})})),Ts=({input:e,onSubmitSuccess:r})=>{const t=Nt();return s.o("form",{noValidate:!0,class:"",onSubmit:n=>{n.preventDefault();const a=s.getFormSubmitter(n).value,i=qr(Ls,a);r({type:"boolean",value:i==="true"})},children:[s.o("ul",{class:Wr,children:zr.map((n,a)=>s.o("li",{class:Hr,children:s.o(Kr,{ref:a===0?t:null,type:"submit",name:Ms,value:n,label:e.config.labels[n]},n)}))}),e.config.optional&&s.o("div",{class:"px-2 pb-2",children:s.o(ge,{class:"relative w-full",type:"button",onClick:()=>r(null)})})]})},Qt=e=>e.reduce((r,t)=>r+t.sizeKb,0),Rs=s.isSubmissionOfType("file"),er=3,ct=e=>{const r=e.lastIndexOf(".");return r===-1?[e,""]:[e.slice(0,r),e.slice(r)]},Ds=({file:e,class:r,...t})=>{const{t:n}=s.useTranslation(),[a,i]=ct(e.name);return s.o("div",{class:s.clsx("bg-accent-1 outline-accent-4 flex max-w-full gap-2 overflow-hidden rounded-lg px-3 py-2 text-sm outline",r),...t,children:[s.o("p",{class:"text-accent-12 flex flex-grow overflow-hidden",children:[s.o("span",{class:"sr-only",children:[n("file_name"),": "]}),s.o("span",{class:"block truncate",children:a}),s.o("span",{children:i})]}),s.o("p",{class:"text-accent-11",children:[s.o("span",{class:"sr-only",children:[n("file_size"),": "]}),s.me(e.sizeKb)]})]})},tr=({class:e,...r})=>s.o("li",{class:s.clsx("outline-neutral-6 text-neutral-11 bg-neutral-1 block rounded-md px-1 py-0.5 text-xs outline outline-1",e),...r}),Ns=(e,r)=>{const[t,n]=ct(e);return`${t.slice(0,r)}${n}`},rr=e=>({name:Ns(e.name,42),sizeKb:e.size/1e3}),Os=[".heic",".heif",".jpg",".jpeg",".png",".gif",".webp",".txt",".rtf",".odt",".pages",".zip"],js=(e,r,t)=>{const n=ct(r.name)[1].toLowerCase(),a=[...t.map(o=>o.toLowerCase()),...Os],i=n===""?"none":a.includes(n)?n:"other";return`chatbot-file-refused:${e}:${i}`},Bs=({input:e,onSubmitSuccess:r,analytics:t})=>{var w;const n=(w=s.store.current$.value.flow)==null?void 0:w.data.submissions[e.key],[a,i]=s.h(Rs(n)&&n.value.length?{status:"ready",files:n.value}:{status:"empty"}),o=s._(0),l=a.status==="ready"?a.files:[],c=a.status==="ready"||a.status==="pending"?a.files:[],f=a.status==="error"?a.error:void 0,h=c.length-er,g=Qt(c),m=Nt(),{t:y}=s.useTranslation(),k=S=>{if(!S.length)return{reason:"required",error:{type:"required",message:y("validation_file")}};if(!s.de(S,e.config.extensions))return{reason:"type",file:S.find(x=>!s.de([x],e.config.extensions)),error:{type:"validate",message:y("validation_file_ext",{ext:e.config.extensions.join(", ")})}};if(S.some(x=>x.sizeKb===0))return{reason:"empty",file:S.find(x=>x.sizeKb===0),error:{type:"validate",message:y("validation_file_empty")}};if(e.config.fileSizeLimitKib&&Qt(S)>e.config.fileSizeLimitKib)return{reason:"size",error:{type:"max",message:y("validation_file_size",{size:s.me(e.config.fileSizeLimitKib)})}};if(!e.config.allowMultiple&&S.length>1)return{reason:"count",error:{type:"invalid",message:y("validation_file_max",{count:1})}}},_=(S,x)=>{var N,R;return t.log({event:"INTERACTION",properties:{tag:js(S,x,e.config.extensions)},customProperties:(R=(N=s.store.current$.peek().flow)==null?void 0:N.analytics)==null?void 0:R.customProperties})};return s.o("form",{class:"flex flex-col gap-1 p-2.5",onSubmit:S=>{if(S.preventDefault(),a.status==="pending"||a.status==="error")return;const x=k(l);x?i({status:"error",error:x.error}):r({type:"file",value:l})},children:[s.o("div",{class:"flex items-center gap-2",children:[s.o("label",{ref:m,for:"dropzone-file",class:"border-neutral-8 bg-neutral-2 flex h-48 w-full cursor-pointer flex-col items-center justify-center overflow-hidden rounded-2xl border border-dashed p-4",children:[c.length>0?s.o("ul",{class:"flex max-w-full flex-wrap justify-center gap-1 overflow-hidden p-1",children:[c.slice(0,er).map(S=>{const[x,N]=ct(S.name);return s.o(tr,{class:"flex overflow-hidden",children:[s.o("span",{class:"block truncate",children:x}),s.o("span",{children:N})]})}),h>0?s.o(tr,{children:y("file_more",{count:h})}):null]}):s.o("div",{class:"flex flex-col justify-center gap-4 pb-6 pt-5",children:[s.o("header",{class:"flex flex-col items-center gap-0",children:[s.o("svg",{class:"text-neutral-11 mb-1 h-8 w-8","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 20 16",children:s.o("path",{stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M13 13h3a3 3 0 0 0 0-6h-.025A5.56 5.56 0 0 0 16 6.5 5.5 5.5 0 0 0 5.207 5.021C5.137 5.017 5.071 5 5 5a4 4 0 0 0 0 8h2.167M10 15V6m0 0L8 8m2-2 2 2"})}),s.o("p",{class:"text-neutral-12 tracking-[-0.01em]",children:y("upload_file",{count:e.config.allowMultiple?2:1})}),e.config.fileSizeLimitKib?s.o("p",{class:"text-neutral-11 text-xs",children:["(",y("file_max_size",{size:s.me(e.config.fileSizeLimitKib)}),")"]}):null]}),s.o("aside",{class:"flex flex-col items-center gap-2",children:[s.o("p",{id:"accepted-filetypes",class:"sr-only",children:y("file_extensions")}),s.o("ul",{"aria-describedby":"accepted-filetypes",class:"flex flex-wrap justify-center gap-2",children:e.config.extensions.map(S=>s.o("li",{class:"ring-lowest outline-neutral-6 text-neutral-11 bg-neutral-1 rounded-md px-1 py-0.5 text-[11px] uppercase tracking-wide outline outline-1 ring-2",children:S.replace(".","")}))})]})]}),s.o("p",{role:"status",class:s.clsx("text-neutral-11 flex items-center gap-1.5 text-xs",c.length===0&&"sr-only"),children:a.status==="pending"?s.o(s.k,{children:[s.o(s.LoadingIndicator,{"aria-hidden":"true",class:"h-4 w-4"}),y("file_preparing",{count:c.length})]}):a.status==="ready"?s.o(s.k,{children:[l.length>1?y("file_total_size",{size:s.me(g)}):s.me(g),s.o("span",{class:"sr-only",children:[". ",y("file_ready",{count:l.length})]})]}):null}),s.o("input",{id:"dropzone-file","aria-label":y("upload_file",{count:e.config.allowMultiple?2:1}),onInput:async S=>{s.invariant(S.target instanceof HTMLInputElement);const x=S.target.files?Array.from(S.target.files):[];S.target.value="";const[N]=x;if(!N)return;const R=++o.current,A=a.status==="ready",q=x.map(rr),O=k(q);if(O)return _(O.reason,O.file??N),i({status:"error",error:O.error});i({status:"pending",files:q});let V;try{const M=await Promise.all(x.map(async T=>{try{return{...rr(T),data:await s.je(T)}}catch(B){throw V??(V=T),B}}));o.current===R&&i({status:"ready",files:M})}catch{if(o.current!==R)return;_("unreadable",V??N),i({status:"error",error:{type:"invalid",message:y(A?"file_read_error_replacement":"file_read_error")}})}},multiple:e.config.allowMultiple,accept:e.config.extensions.join(","),type:"file",class:"sr-only"})]}),s.o("div",{class:"flex h-full flex-col items-center gap-2",children:[s.o(Fe,{disabled:l.length===0}),e.config.optional&&s.o(ge,{class:"relative",onClick:()=>r(null)})]})]}),s.o(qe,{error:f})]})};var et=e=>e.type==="checkbox",Ie=e=>e instanceof Date,se=e=>e==null;const Gr=e=>typeof e=="object";var Z=e=>!se(e)&&!Array.isArray(e)&&Gr(e)&&!Ie(e),$s=e=>Z(e)&&e.target?et(e.target)?e.target.checked:e.target.value:e,Ps=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,Us=(e,r)=>e.has(Ps(r)),qs=e=>{const r=e.constructor&&e.constructor.prototype;return Z(r)&&r.hasOwnProperty("isPrototypeOf")},Ot=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Q(e){if(e instanceof Date)return new Date(e);const r=typeof FileList<"u"&&e instanceof FileList;if(Ot&&(e instanceof Blob||r))return e;const t=Array.isArray(e);if(!t&&!(Z(e)&&qs(e)))return e;const n=t?[]:Object.create(Object.getPrototypeOf(e));for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=Q(e[a]));return n}var ut=e=>/^\w*$/.test(e),G=e=>e===void 0,jt=e=>Array.isArray(e)?e.filter(Boolean):[],Bt=e=>jt(e.replace(/["|']|\]/g,"").split(/\.|\[/)),E=(e,r,t)=>{if(!r||!Z(e))return t;const n=(ut(r)?[r]:Bt(r)).reduce((a,i)=>se(a)?a:a[i],e);return G(n)||n===e?G(e[r])?t:e[r]:n},de=e=>typeof e=="boolean",oe=e=>typeof e=="function",K=(e,r,t)=>{let n=-1;const a=ut(r)?[r]:Bt(r),i=a.length,o=i-1;for(;++n<i;){const l=a[n];let c=t;if(n!==o){const f=e[l];c=Z(f)||Array.isArray(f)?f:isNaN(+a[n+1])?{}:[]}if(l==="__proto__"||l==="constructor"||l==="prototype")return;e[l]=c,e=e[l]}};const nr={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},le={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},ye={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},zs=s.Cn.createContext(null);zs.displayName="HookFormControlContext";var Ws=(e,r,t,n=!0)=>{const a={defaultValues:r._defaultValues};for(const i in e)Object.defineProperty(a,i,{get:()=>{const o=i;return r._proxyFormState[o]!==le.all&&(r._proxyFormState[o]=!n||le.all),t&&(t[o]=!0),e[o]}});return a};const Hs=typeof window<"u"?s.Cn.useLayoutEffect:s.Cn.useEffect;var ie=e=>typeof e=="string",Ks=(e,r,t,n,a)=>ie(e)?(n&&r.watch.add(e),E(t,e,a)):Array.isArray(e)?e.map(i=>(n&&r.watch.add(i),E(t,i))):(n&&(r.watchAll=!0),t),It=e=>se(e)||!Gr(e);function ke(e,r,t=new WeakSet){if(It(e)||It(r))return Object.is(e,r);if(Ie(e)&&Ie(r))return Object.is(e.getTime(),r.getTime());const n=Object.keys(e),a=Object.keys(r);if(n.length!==a.length)return!1;if(t.has(e)||t.has(r))return!0;t.add(e),t.add(r);for(const i of n){const o=e[i];if(!a.includes(i))return!1;if(i!=="ref"){const l=r[i];if(Ie(o)&&Ie(l)||Z(o)&&Z(l)||Array.isArray(o)&&Array.isArray(l)?!ke(o,l,t):!Object.is(o,l))return!1}}return!0}const Gs=s.Cn.createContext(null);Gs.displayName="HookFormContext";var Jr=(e,r,t,n,a)=>r?{...t[e],types:{...t[e]&&t[e].types?t[e].types:{},[n]:a||!0}}:{},Ye=e=>Array.isArray(e)?e:[e],sr=()=>{let e=[];return{get observers(){return e},next:a=>{for(const i of e)i.next&&i.next(a)},subscribe:a=>(e.push(a),{unsubscribe:()=>{e=e.filter(i=>i!==a)}}),unsubscribe:()=>{e=[]}}};function Zr(e,r){const t={};for(const n in e)if(e.hasOwnProperty(n)){const a=e[n],i=r[n];if(a&&Z(a)&&i){const o=Zr(a,i);Z(o)&&(t[n]=o)}else e[n]&&(t[n]=i)}return t}var ne=e=>Z(e)&&!Object.keys(e).length,$t=e=>e.type==="file",ot=e=>{if(!Ot)return!1;const r=e?e.ownerDocument:0;return e instanceof(r&&r.defaultView?r.defaultView.HTMLElement:HTMLElement)},Xr=e=>e.type==="select-multiple",Pt=e=>e.type==="radio",Js=e=>Pt(e)||et(e),_t=e=>ot(e)&&e.isConnected;function Zs(e,r){const t=r.slice(0,-1).length;let n=0;for(;n<t;)e=G(e)?n++:e[r[n++]];return e}function Xs(e){for(const r in e)if(e.hasOwnProperty(r)&&!G(e[r]))return!1;return!0}function J(e,r){const t=Array.isArray(r)?r:ut(r)?[r]:Bt(r),n=t.length===1?e:Zs(e,t),a=t.length-1,i=t[a];return n&&delete n[i],a!==0&&(Z(n)&&ne(n)||Array.isArray(n)&&Xs(n))&&J(e,t.slice(0,-1)),e}var Ys=e=>{for(const r in e)if(oe(e[r]))return!0;return!1};function Yr(e){return Array.isArray(e)||Z(e)&&!Ys(e)}function Ft(e,r={}){for(const t in e){const n=e[t];Yr(n)?(r[t]=Array.isArray(n)?[]:{},Ft(n,r[t])):G(n)||(r[t]=!0)}return r}function je(e,r,t){t||(t=Ft(r));for(const n in e){const a=e[n];if(Yr(a))G(r)||It(t[n])?t[n]=Ft(a,Array.isArray(a)?[]:{}):je(a,se(r)?{}:r[n],t[n]);else{const i=r[n];t[n]=!ke(a,i)}}return t}const ar={value:!1,isValid:!1},ir={value:!0,isValid:!0};var Qr=e=>{if(Array.isArray(e)){if(e.length>1){const r=e.filter(t=>t&&t.checked&&!t.disabled).map(t=>t.value);return{value:r,isValid:!!r.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!G(e[0].attributes.value)?G(e[0].value)||e[0].value===""?ir:{value:e[0].value,isValid:!0}:ir:ar}return ar},en=(e,{valueAsNumber:r,valueAsDate:t,setValueAs:n})=>G(e)?e:r?e===""?NaN:e&&+e:t&&ie(e)?new Date(e):n?n(e):e;const or={isValid:!1,value:null};var tn=e=>Array.isArray(e)?e.reduce((r,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:r,or):or;function lr(e){const r=e.ref;return $t(r)?r.files:Pt(r)?tn(e.refs).value:Xr(r)?[...r.selectedOptions].map(({value:t})=>t):et(r)?Qr(e.refs).value:en(G(r.value)?e.ref.value:r.value,e)}var Qs=(e,r,t,n)=>{const a={};for(const i of e){const o=E(r,i);o&&K(a,i,o._f)}return{criteriaMode:t,names:[...e],fields:a,shouldUseNativeValidation:n}},lt=e=>e instanceof RegExp,Ge=e=>G(e)?e:lt(e)?e.source:Z(e)?lt(e.value)?e.value.source:e.value:e,cr=e=>({isOnSubmit:!e||e===le.onSubmit,isOnBlur:e===le.onBlur,isOnChange:e===le.onChange,isOnAll:e===le.all,isOnTouch:e===le.onTouched});const ur="AsyncFunction";var ea=e=>!!e&&!!e.validate&&!!(oe(e.validate)&&e.validate.constructor.name===ur||Z(e.validate)&&Object.values(e.validate).find(r=>r.constructor.name===ur)),ta=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),dr=(e,r,t)=>!t&&(r.watchAll||r.watch.has(e)||[...r.watch].some(n=>e.startsWith(n)&&/^\.\w+/.test(e.slice(n.length))));const Qe=(e,r,t,n)=>{for(const a of t||Object.keys(e)){const i=E(e,a);if(i){const{_f:o,...l}=i;if(o){if(o.refs&&o.refs[0]&&r(o.refs[0],a)&&!n)return!0;if(o.ref&&r(o.ref,o.name)&&!n)return!0;if(Qe(l,r))break}else if(Z(l)&&Qe(l,r))break}}};function fr(e,r,t){const n=E(e,t);if(n||ut(t))return{error:n,name:t};const a=t.split(".");for(;a.length;){const i=a.join("."),o=E(r,i),l=E(e,i);if(o&&!Array.isArray(o)&&t!==i)return{name:t};if(l&&l.type)return{name:i,error:l};if(l&&l.root&&l.root.type)return{name:`${i}.root`,error:l.root};a.pop()}return{name:t}}var ra=(e,r,t,n)=>{t(e);const{name:a,...i}=e;return ne(i)||Object.keys(i).length>=Object.keys(r).length||Object.keys(i).find(o=>r[o]===(!n||le.all))},na=(e,r,t)=>!e||!r||e===r||Ye(e).some(n=>n&&(t?n===r:n.startsWith(r)||r.startsWith(n))),sa=(e,r,t,n,a)=>a.isOnAll?!1:!t&&a.isOnTouch?!(r||e):(t?n.isOnBlur:a.isOnBlur)?!e:(t?n.isOnChange:a.isOnChange)?e:!0,aa=(e,r)=>!jt(E(e,r)).length&&J(e,r),ia=(e,r,t)=>{const n=Ye(E(e,t));return K(n,"root",r[t]),K(e,t,n),e};function hr(e,r,t="validate"){if(ie(e)||Array.isArray(e)&&e.every(ie)||de(e)&&!e)return{type:t,message:ie(e)?e:"",ref:r}}var Oe=e=>Z(e)&&!lt(e)?e:{value:e,message:""},pr=async(e,r,t,n,a,i)=>{const{ref:o,refs:l,required:c,maxLength:f,minLength:h,min:g,max:m,pattern:y,validate:k,name:_,valueAsNumber:w,mount:S}=e._f,x=E(t,_);if(!S||r.has(_))return{};const N=l?l[0]:o,R=F=>{a&&N.reportValidity&&(N.setCustomValidity(de(F)?"":F||""),N.reportValidity())},A={},q=Pt(o),O=et(o),V=q||O,M=(w||$t(o))&&G(o.value)&&G(x)||ot(o)&&o.value===""||x===""||Array.isArray(x)&&!x.length,T=Jr.bind(null,_,n,A),B=(F,L,P,D=ye.maxLength,W=ye.minLength)=>{const z=F?L:P;A[_]={type:F?D:W,message:z,ref:o,...T(F?D:W,z)}};if(i?!Array.isArray(x)||!x.length:c&&(!V&&(M||se(x))||de(x)&&!x||O&&!Qr(l).isValid||q&&!tn(l).isValid)){const{value:F,message:L}=ie(c)?{value:!!c,message:c}:Oe(c);if(F&&(A[_]={type:ye.required,message:L,ref:N,...T(ye.required,L)},!n))return R(L),A}if(!M&&(!se(g)||!se(m))){let F,L;const P=Oe(m),D=Oe(g);if(!se(x)&&!isNaN(x)){const W=o.valueAsNumber||x&&+x;se(P.value)||(F=W>P.value),se(D.value)||(L=W<D.value)}else{const W=o.valueAsDate||new Date(x),z=H=>new Date(new Date().toDateString()+" "+H),ee=o.type=="time",X=o.type=="week";ie(P.value)&&x&&(F=ee?z(x)>z(P.value):X?x>P.value:W>new Date(P.value)),ie(D.value)&&x&&(L=ee?z(x)<z(D.value):X?x<D.value:W<new Date(D.value))}if((F||L)&&(B(!!F,P.message,D.message,ye.max,ye.min),!n))return R(A[_].message),A}if((f||h)&&!M&&(ie(x)||i&&Array.isArray(x))){const F=Oe(f),L=Oe(h),P=!se(F.value)&&x.length>+F.value,D=!se(L.value)&&x.length<+L.value;if((P||D)&&(B(P,F.message,L.message),!n))return R(A[_].message),A}if(y&&!M&&ie(x)){const{value:F,message:L}=Oe(y);if(lt(F)&&!x.match(F)&&(A[_]={type:ye.pattern,message:L,ref:o,...T(ye.pattern,L)},!n))return R(L),A}if(k){if(oe(k)){const F=await k(x,t),L=hr(F,N);if(L&&(A[_]={...L,...T(ye.validate,L.message)},!n))return R(L.message),A}else if(Z(k)){let F={};for(const L in k){if(!ne(F)&&!n)break;const P=hr(await k[L](x,t),N,L);P&&(F={...P,...T(L,P.message)},R(P.message),n&&(A[_]=F))}if(!ne(F)&&(A[_]={ref:N,...F},!n))return A}}return R(!0),A};const oa={mode:le.onSubmit,reValidateMode:le.onChange,shouldFocusError:!0};function la(e={}){let r={...oa,...e},t={submitCount:0,isDirty:!1,isReady:!1,isLoading:oe(r.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:r.errors||{},disabled:r.disabled||!1},n={},a=Z(r.defaultValues)||Z(r.values)?Q(r.defaultValues||r.values)||{}:{},i=r.shouldUnregister?{}:Q(a),o={action:!1,mount:!1,watch:!1,keepIsValid:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},c,f=0;const h={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},g={...h};let m={...g};const y={array:sr(),state:sr()},k=r.criteriaMode===le.all,_=u=>d=>{clearTimeout(f),f=setTimeout(u,d)},w=async u=>{if(!o.keepIsValid&&!r.disabled&&(g.isValid||m.isValid||u)){let d;r.resolver?(d=ne((await V()).errors),S()):d=await T(n,!0),d!==t.isValid&&y.state.next({isValid:d})}},S=(u,d)=>{!r.disabled&&(g.isValidating||g.validatingFields||m.isValidating||m.validatingFields)&&((u||Array.from(l.mount)).forEach(p=>{p&&(d?K(t.validatingFields,p,d):J(t.validatingFields,p))}),y.state.next({validatingFields:t.validatingFields,isValidating:!ne(t.validatingFields)}))},x=(u,d=[],p,C,b=!0,v=!0)=>{if(C&&p&&!r.disabled){if(o.action=!0,v&&Array.isArray(E(n,u))){const I=p(E(n,u),C.argA,C.argB);b&&K(n,u,I)}if(v&&Array.isArray(E(t.errors,u))){const I=p(E(t.errors,u),C.argA,C.argB);b&&K(t.errors,u,I),aa(t.errors,u)}if((g.touchedFields||m.touchedFields)&&v&&Array.isArray(E(t.touchedFields,u))){const I=p(E(t.touchedFields,u),C.argA,C.argB);b&&K(t.touchedFields,u,I)}(g.dirtyFields||m.dirtyFields)&&(t.dirtyFields=je(a,i)),y.state.next({name:u,isDirty:F(u,d),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else K(i,u,d)},N=(u,d)=>{K(t.errors,u,d),y.state.next({errors:t.errors})},R=u=>{t.errors=u,y.state.next({errors:t.errors,isValid:!1})},A=(u,d,p,C)=>{const b=E(n,u);if(b){const v=E(i,u,G(p)?E(a,u):p);G(v)||C&&C.defaultChecked||d?K(i,u,d?v:lr(b._f)):D(u,v),o.mount&&!o.action&&w()}},q=(u,d,p,C,b)=>{let v=!1,I=!1;const $={name:u};if(!r.disabled){if(!p||C){(g.isDirty||m.isDirty)&&(I=t.isDirty,t.isDirty=$.isDirty=F(),v=I!==$.isDirty);const U=ke(E(a,u),d);I=!!E(t.dirtyFields,u),U?J(t.dirtyFields,u):K(t.dirtyFields,u,!0),$.dirtyFields=t.dirtyFields,v=v||(g.dirtyFields||m.dirtyFields)&&I!==!U}if(p){const U=E(t.touchedFields,u);U||(K(t.touchedFields,u,p),$.touchedFields=t.touchedFields,v=v||(g.touchedFields||m.touchedFields)&&U!==p)}v&&b&&y.state.next($)}return v?$:{}},O=(u,d,p,C)=>{const b=E(t.errors,u),v=(g.isValid||m.isValid)&&de(d)&&t.isValid!==d;if(r.delayError&&p?(c=_(()=>N(u,p)),c(r.delayError)):(clearTimeout(f),c=null,p?K(t.errors,u,p):J(t.errors,u)),(p?!ke(b,p):b)||!ne(C)||v){const I={...C,...v&&de(d)?{isValid:d}:{},errors:t.errors,name:u};t={...t,...I},y.state.next(I)}},V=async u=>(S(u,!0),await r.resolver(i,r.context,Qs(u||l.mount,n,r.criteriaMode,r.shouldUseNativeValidation))),M=async u=>{const{errors:d}=await V(u);if(S(u),u)for(const p of u){const C=E(d,p);C?K(t.errors,p,C):J(t.errors,p)}else t.errors=d;return d},T=async(u,d,p={valid:!0})=>{for(const C in u){const b=u[C];if(b){const{_f:v,...I}=b;if(v){const $=l.array.has(v.name),U=b._f&&ea(b._f);U&&g.validatingFields&&S([v.name],!0);const re=await pr(b,l.disabled,i,k,r.shouldUseNativeValidation&&!d,$);if(U&&g.validatingFields&&S([v.name]),re[v.name]&&(p.valid=!1,d||e.shouldUseNativeValidation))break;!d&&(E(re,v.name)?$?ia(t.errors,re,v.name):K(t.errors,v.name,re[v.name]):J(t.errors,v.name))}!ne(I)&&await T(I,d,p)}}return p.valid},B=()=>{for(const u of l.unMount){const d=E(n,u);d&&(d._f.refs?d._f.refs.every(p=>!_t(p)):!_t(d._f.ref))&&Te(u)}l.unMount=new Set},F=(u,d)=>!r.disabled&&(u&&d&&K(i,u,d),!ke(ze(),a)),L=(u,d,p)=>Ks(u,l,{...o.mount?i:G(d)?a:ie(u)?{[u]:d}:d},p,d),P=u=>jt(E(o.mount?i:a,u,r.shouldUnregister?E(a,u,[]):[])),D=(u,d,p={})=>{const C=E(n,u);let b=d;if(C){const v=C._f;v&&(!v.disabled&&K(i,u,en(d,v)),b=ot(v.ref)&&se(d)?"":d,Xr(v.ref)?[...v.ref.options].forEach(I=>I.selected=b.includes(I.value)):v.refs?et(v.ref)?v.refs.forEach(I=>{(!I.defaultChecked||!I.disabled)&&(Array.isArray(b)?I.checked=!!b.find($=>$===I.value):I.checked=b===I.value||!!b)}):v.refs.forEach(I=>I.checked=I.value===b):$t(v.ref)?v.ref.value="":(v.ref.value=b,v.ref.type||y.state.next({name:u,values:Q(i)})))}(p.shouldDirty||p.shouldTouch)&&q(u,b,p.shouldTouch,p.shouldDirty,!0),p.shouldValidate&&H(u)},W=(u,d,p)=>{for(const C in d){if(!d.hasOwnProperty(C))return;const b=d[C],v=u+"."+C,I=E(n,v);(l.array.has(u)||Z(b)||I&&!I._f)&&!Ie(b)?W(v,b,p):D(v,b,p)}},z=(u,d,p={})=>{const C=E(n,u),b=l.array.has(u),v=Q(d);K(i,u,v),b?(y.array.next({name:u,values:Q(i)}),(g.isDirty||g.dirtyFields||m.isDirty||m.dirtyFields)&&p.shouldDirty&&y.state.next({name:u,dirtyFields:je(a,i),isDirty:F(u,v)})):C&&!C._f&&!se(v)?W(u,v,p):D(u,v,p),dr(u,l)?y.state.next({...t,name:u,values:Q(i)}):y.state.next({name:o.mount?u:void 0,values:Q(i)})},ee=async u=>{o.mount=!0;const d=u.target;let p=d.name,C=!0;const b=E(n,p),v=U=>{C=Number.isNaN(U)||Ie(U)&&isNaN(U.getTime())||ke(U,E(i,p,U))},I=cr(r.mode),$=cr(r.reValidateMode);if(b){let U,re;const Ee=d.type?lr(b._f):$s(u),xe=u.type===nr.BLUR||u.type===nr.FOCUS_OUT,nn=!ta(b._f)&&!r.resolver&&!E(t.errors,p)&&!b._f.deps||sa(xe,E(t.touchedFields,p),t.isSubmitted,$,I),pt=dr(p,l,xe);K(i,p,Ee),xe?(!d||!d.readOnly)&&(b._f.onBlur&&b._f.onBlur(u),c&&c(0)):b._f.onChange&&b._f.onChange(u);const mt=q(p,Ee,xe),sn=!ne(mt)||pt;if(!xe&&y.state.next({name:p,type:u.type,values:Q(i)}),nn)return(g.isValid||m.isValid)&&(r.mode==="onBlur"?xe&&w():xe||w()),sn&&y.state.next({name:p,...pt?{}:mt});if(!xe&&pt&&y.state.next({...t}),r.resolver){const{errors:Ut}=await V([p]);if(S([p]),v(Ee),C){const an=fr(t.errors,n,p),qt=fr(Ut,n,an.name||p);U=qt.error,p=qt.name,re=ne(Ut)}}else S([p],!0),U=(await pr(b,l.disabled,i,k,r.shouldUseNativeValidation))[p],S([p]),v(Ee),C&&(U?re=!1:(g.isValid||m.isValid)&&(re=await T(n,!0)));C&&(b._f.deps&&(!Array.isArray(b._f.deps)||b._f.deps.length>0)&&H(b._f.deps),O(p,re,U,mt))}},X=(u,d)=>{if(E(t.errors,d)&&u.focus)return u.focus(),1},H=async(u,d={})=>{let p,C;const b=Ye(u);if(r.resolver){const v=await M(G(u)?u:b);p=ne(v),C=u?!b.some(I=>E(v,I)):p}else u?(C=(await Promise.all(b.map(async v=>{const I=E(n,v);return await T(I&&I._f?{[v]:I}:I)}))).every(Boolean),!(!C&&!t.isValid)&&w()):C=p=await T(n);return y.state.next({...!ie(u)||(g.isValid||m.isValid)&&p!==t.isValid?{}:{name:u},...r.resolver||!u?{isValid:p}:{},errors:t.errors}),d.shouldFocus&&!C&&Qe(n,X,u?b:l.mount),C},ze=(u,d)=>{let p={...o.mount?i:a};return d&&(p=Zr(d.dirtyFields?t.dirtyFields:t.touchedFields,p)),G(u)?p:ie(u)?E(p,u):u.map(C=>E(p,C))},Ve=(u,d)=>({invalid:!!E((d||t).errors,u),isDirty:!!E((d||t).dirtyFields,u),error:E((d||t).errors,u),isValidating:!!E(t.validatingFields,u),isTouched:!!E((d||t).touchedFields,u)}),j=u=>{const d=u?Ye(u):void 0;d==null||d.forEach(p=>J(t.errors,p)),d?d.forEach(p=>{y.state.next({name:p,errors:t.errors})}):y.state.next({errors:{}})},Le=(u,d,p)=>{const C=(E(n,u,{_f:{}})._f||{}).ref,b=E(t.errors,u)||{},{ref:v,message:I,type:$,...U}=b;K(t.errors,u,{...U,...d,ref:C}),y.state.next({name:u,errors:t.errors,isValid:!1}),p&&p.shouldFocus&&C&&C.focus&&C.focus()},Me=(u,d)=>oe(u)?y.state.subscribe({next:p=>"values"in p&&u(L(void 0,d),p)}):L(u,d,!0),ve=u=>y.state.subscribe({next:d=>{na(u.name,d.name,u.exact)&&ra(d,u.formState||g,nt,u.reRenderRoot)&&u.callback({values:{...i},...t,...d,defaultValues:a})}}).unsubscribe,Se=u=>(o.mount=!0,m={...m,...u.formState},ve({...u,formState:{...h,...u.formState}})),Te=(u,d={})=>{for(const p of u?Ye(u):l.mount)l.mount.delete(p),l.array.delete(p),d.keepValue||(J(n,p),J(i,p)),!d.keepError&&J(t.errors,p),!d.keepDirty&&J(t.dirtyFields,p),!d.keepTouched&&J(t.touchedFields,p),!d.keepIsValidating&&J(t.validatingFields,p),!r.shouldUnregister&&!d.keepDefaultValue&&J(a,p);y.state.next({values:Q(i)}),y.state.next({...t,...d.keepDirty?{isDirty:F()}:{}}),!d.keepIsValid&&w()},We=({disabled:u,name:d})=>{if(de(u)&&o.mount||u||l.disabled.has(d)){const b=l.disabled.has(d)!==!!u;u?l.disabled.add(d):l.disabled.delete(d),b&&o.mount&&!o.action&&w()}},he=(u,d={})=>{let p=E(n,u);const C=de(d.disabled)||de(r.disabled);return K(n,u,{...p||{},_f:{...p&&p._f?p._f:{ref:{name:u}},name:u,mount:!0,...d}}),l.mount.add(u),p?We({disabled:de(d.disabled)?d.disabled:r.disabled,name:u}):A(u,!0,d.value),{...C?{disabled:d.disabled||r.disabled}:{},...r.progressive?{required:!!d.required,min:Ge(d.min),max:Ge(d.max),minLength:Ge(d.minLength),maxLength:Ge(d.maxLength),pattern:Ge(d.pattern)}:{},name:u,onChange:ee,onBlur:ee,ref:b=>{if(b){he(u,d),p=E(n,u);const v=G(b.value)&&b.querySelectorAll&&b.querySelectorAll("input,select,textarea")[0]||b,I=Js(v),$=p._f.refs||[];if(I?$.find(U=>U===v):v===p._f.ref)return;K(n,u,{_f:{...p._f,...I?{refs:[...$.filter(_t),v,...Array.isArray(E(a,u))?[{}]:[]],ref:{type:v.type,name:u}}:{ref:v}}}),A(u,!1,void 0,v)}else p=E(n,u,{}),p._f&&(p._f.mount=!1),(r.shouldUnregister||d.shouldUnregister)&&!(Us(l.array,u)&&o.action)&&l.unMount.add(u)}}},Re=()=>r.shouldFocusError&&Qe(n,X,l.mount),tt=u=>{de(u)&&(y.state.next({disabled:u}),Qe(n,(d,p)=>{const C=E(n,p);C&&(d.disabled=C._f.disabled||u,Array.isArray(C._f.refs)&&C._f.refs.forEach(b=>{b.disabled=C._f.disabled||u}))},0,!1))},De=(u,d)=>async p=>{let C;p&&(p.preventDefault&&p.preventDefault(),p.persist&&p.persist());let b=Q(i);if(y.state.next({isSubmitting:!0}),r.resolver){const{errors:v,values:I}=await V();S(),t.errors=v,b=Q(I)}else await T(n);if(l.disabled.size)for(const v of l.disabled)J(b,v);if(J(t.errors,"root"),ne(t.errors)){y.state.next({errors:{}});try{await u(b,p)}catch(v){C=v}}else d&&await d({...t.errors},p),Re(),setTimeout(Re);if(y.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:ne(t.errors)&&!C,submitCount:t.submitCount+1,errors:t.errors}),C)throw C},Ne=(u,d={})=>{E(n,u)&&(G(d.defaultValue)?z(u,Q(E(a,u))):(z(u,d.defaultValue),K(a,u,Q(d.defaultValue))),d.keepTouched||J(t.touchedFields,u),d.keepDirty||(J(t.dirtyFields,u),t.isDirty=d.defaultValue?F(u,Q(E(a,u))):F()),d.keepError||(J(t.errors,u),g.isValid&&w()),y.state.next({...t}))},Ae=(u,d={})=>{const p=u?Q(u):a,C=Q(p),b=ne(u),v=b?a:C;if(d.keepDefaultValues||(a=p),!d.keepValues){if(d.keepDirtyValues){const I=new Set([...l.mount,...Object.keys(je(a,i))]);for(const $ of Array.from(I)){const U=E(t.dirtyFields,$),re=E(i,$),Ee=E(v,$);U&&!G(re)?K(v,$,re):!U&&!G(Ee)&&z($,Ee)}}else{if(Ot&&G(u))for(const I of l.mount){const $=E(n,I);if($&&$._f){const U=Array.isArray($._f.refs)?$._f.refs[0]:$._f.ref;if(ot(U)){const re=U.closest("form");if(re){re.reset();break}}}}if(d.keepFieldsRef)for(const I of l.mount)z(I,E(v,I));else n={}}i=r.shouldUnregister?d.keepDefaultValues?Q(a):{}:Q(v),y.array.next({values:{...v}}),y.state.next({values:{...v}})}l={mount:d.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!g.isValid||!!d.keepIsValid||!!d.keepDirtyValues||!r.shouldUnregister&&!ne(v),o.watch=!!r.shouldUnregister,o.keepIsValid=!!d.keepIsValid,o.action=!1,d.keepErrors||(t.errors={}),y.state.next({submitCount:d.keepSubmitCount?t.submitCount:0,isDirty:b?!1:d.keepDirty?t.isDirty:!!(d.keepDefaultValues&&!ke(u,a)),isSubmitted:d.keepIsSubmitted?t.isSubmitted:!1,dirtyFields:b?{}:d.keepDirtyValues?d.keepDefaultValues&&i?je(a,i):t.dirtyFields:d.keepDefaultValues&&u?je(a,u):d.keepDirty?t.dirtyFields:{},touchedFields:d.keepTouched?t.touchedFields:{},errors:d.keepErrors?t.errors:{},isSubmitSuccessful:d.keepIsSubmitSuccessful?t.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:a})},He=(u,d)=>Ae(oe(u)?u(i):u,{...r.resetOptions,...d}),rt=(u,d={})=>{const p=E(n,u),C=p&&p._f;if(C){const b=C.refs?C.refs[0]:C.ref;b.focus&&setTimeout(()=>{b.focus(),d.shouldSelect&&oe(b.select)&&b.select()})}},nt=u=>{t={...t,...u}},Ke={control:{register:he,unregister:Te,getFieldState:Ve,handleSubmit:De,setError:Le,_subscribe:ve,_runSchema:V,_updateIsValidating:S,_focusError:Re,_getWatch:L,_getDirty:F,_setValid:w,_setFieldArray:x,_setDisabledField:We,_setErrors:R,_getFieldArray:P,_reset:Ae,_resetDefaultValues:()=>oe(r.defaultValues)&&r.defaultValues().then(u=>{He(u,r.resetOptions),y.state.next({isLoading:!1})}),_removeUnmounted:B,_disableForm:tt,_subjects:y,_proxyFormState:g,get _fields(){return n},get _formValues(){return i},get _state(){return o},set _state(u){o=u},get _defaultValues(){return a},get _names(){return l},set _names(u){l=u},get _formState(){return t},get _options(){return r},set _options(u){r={...r,...u}}},subscribe:Se,trigger:H,register:he,handleSubmit:De,watch:Me,setValue:z,getValues:ze,reset:He,resetField:Ne,clearErrors:j,unregister:Te,setError:Le,setFocus:rt,getFieldState:Ve};return{...Ke,formControl:Ke}}function dt(e={}){const r=s.Cn.useRef(void 0),t=s.Cn.useRef(void 0),[n,a]=s.Cn.useState({isDirty:!1,isValidating:!1,isLoading:oe(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:oe(e.defaultValues)?void 0:e.defaultValues});if(!r.current)if(e.formControl)r.current={...e.formControl,formState:n},e.defaultValues&&!oe(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:o,...l}=la(e);r.current={...l,formState:n}}const i=r.current.control;return i._options=e,Hs(()=>{const o=i._subscribe({formState:i._proxyFormState,callback:()=>a({...i._formState}),reRenderRoot:!0});return a(l=>({...l,isReady:!0})),i._formState.isReady=!0,o},[i]),s.Cn.useEffect(()=>i._disableForm(e.disabled),[i,e.disabled]),s.Cn.useEffect(()=>{e.mode&&(i._options.mode=e.mode),e.reValidateMode&&(i._options.reValidateMode=e.reValidateMode)},[i,e.mode,e.reValidateMode]),s.Cn.useEffect(()=>{e.errors&&(i._setErrors(e.errors),i._focusError())},[i,e.errors]),s.Cn.useEffect(()=>{e.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,e.shouldUnregister]),s.Cn.useEffect(()=>{if(i._proxyFormState.isDirty){const o=i._getDirty();o!==n.isDirty&&i._subjects.state.next({isDirty:o})}},[i,n.isDirty]),s.Cn.useEffect(()=>{var o;e.values&&!ke(e.values,t.current)?(i._reset(e.values,{keepFieldsRef:!0,...i._options.resetOptions}),!((o=i._options.resetOptions)===null||o===void 0)&&o.keepIsValid||i._setValid(),t.current=e.values,a(l=>({...l}))):i._resetDefaultValues()},[i,e.values]),s.Cn.useEffect(()=>{i._state.mount||(i._setValid(),i._state.mount=!0),i._state.watch&&(i._state.watch=!1,i._subjects.state.next({...i._formState})),i._removeUnmounted()}),r.current.formState=s.Cn.useMemo(()=>Ws(n,i),[i,n]),r.current}const mr=(e,r,t)=>{if(e&&"reportValidity"in e){const n=E(t,r);e.setCustomValidity(n&&n.message||""),e.reportValidity()}},ca=(e,r)=>{for(const t in r.fields){const n=r.fields[t];n&&n.ref&&"reportValidity"in n.ref?mr(n.ref,t,e):n.refs&&n.refs.forEach(a=>mr(a,t,e))}},ua=(e,r)=>{r.shouldUseNativeValidation&&ca(e,r);const t={};for(const n in e){const a=E(r.fields,n),i=Object.assign(e[n]||{},{ref:a&&a.ref});if(da(r.names||Object.keys(e),n)){const o=Object.assign({},E(t,n));K(o,"root",i),K(t,n,o)}else K(t,n,i)}return t},da=(e,r)=>e.some(t=>t.startsWith(r+"."));var ft=function(e,r,t){return t===void 0&&(t={}),function(n,a,i){try{var o=!i.shouldUseNativeValidation&&i.criteriaMode==="all";return Promise.resolve(_s(e,n,Object.assign({},r,{abortPipeEarly:!o}))).then(function(l){if(l.issues){for(var c={};l.issues.length;){var f=l.issues[0],h=gs(f);if(h&&(c[h]||(c[h]={message:f.message,type:f.type}),o)){var g=c[h].types,m=g&&g[f.type];c[h]=Jr(h,o,c,f.type,m?[].concat(m,f.message):f.message)}l.issues.shift()}return{values:{},errors:ua(c,i)}}return{values:t.raw?n:l.output,errors:{}}})}catch(l){return Promise.reject(l)}}};const yr=27,br=12,gr=10,fa=s.isSubmissionOfType("enum"),ha=(e,r)=>{const t={min:e.minSelected??0,max:e.maxSelected??e.options.length};return ft(be({checked:Ce(Ur(ae(),Br()),Rt(n=>Object.entries(n).filter(([a,i])=>i).map(([a,i])=>a)),Xe(t.max,r("validation_multiple_choice_max",{count:t.max})),$e(t.min,r("validation_multiple_choice_min",{count:t.min})))}))},pa=s.k$1(({option:e,...r},t)=>s.o(s.k,{children:[s.o("input",{class:"peer sr-only h-full",type:"checkbox",...r,ref:t}),s.o("label",{class:"bg-lowest hover:bg-neutral-2 active:outline-neutral-8 ease-expo-out outline-divider text-neutral-11 peer-checked:outline-accent-7 peer-checked:bg-accent-2 peer-checked:text-accent-9 peer-focus-visible:ring-accent-9 peer-focus-visible:ring-offset-accent-7 block cursor-pointer select-none rounded-2xl px-3 py-1.5 outline outline-1 ring-0 ring-transparent transition-all selection:bg-transparent peer-focus-visible:ring-4",htmlFor:r.id,children:e.label})]})),vr=s.cva("gutter-stable flex w-full flex-1 flex-wrap gap-2 overflow-y-auto rounded-xl p-2.5 pr-4",{variants:{variant:{singleOption:"justify-center",booleanLike:Wr}}}),ma=({input:e,onSubmitSuccess:r})=>{var h,g;const t=e.key?(h=s.store.current$.value.flow)==null?void 0:h.data.submissions[e.key]:void 0,n=e.config.maxSelected===1,a=n&&e.config.options.length===2,{t:i}=s.useTranslation(),{register:o,handleSubmit:l,formState:{errors:c}}=dt({defaultValues:{checked:n?{}:fa(t)?Object.fromEntries(t.value.map(m=>[m,!0])):{}},resolver:ha(e.config,i)}),f=Nt();return a?s.o(s.k,{children:[s.o("ul",{style:{maxHeight:6.5*yr+5*br+2*gr},class:vr({variant:"booleanLike"}),children:e.config.options.map((m,y)=>s.o("li",{class:Hr,children:s.o(Kr,{type:"submit",ref:k=>{k&&y===0&&(f.current=k)},label:m.label,value:"true",onClick:()=>r({type:"enum",value:[m.value]})})},m.value))}),e.config.minSelected===0&&s.o("div",{class:"px-2 pb-2",children:s.o(ge,{class:"relative w-full",type:"button",onClick:()=>r({type:"enum",value:[]})})})]}):s.o("form",{noValidate:!0,onSubmit:m=>l(y=>{const k=y.checked;r({type:"enum",value:k})})(m),children:[s.o("div",{class:"flex items-center gap-1",children:[s.o("ul",{style:{maxHeight:6.5*yr+5*br+2*gr},class:vr({variant:e.config.options.length===1?"singleOption":void 0}),children:e.config.options.map((m,y)=>{const k=`checked.${m.value}`,{ref:_,...w}=o(k);return s.o("li",{class:"relative",children:s.o(pa,{option:m,autoFocus:y===0,ref:S=>{S&&y===0&&(f.current=S),_(S)},id:k,...w,onClick:n?()=>r({type:"enum",value:[m.value]}):void 0})},m.value)})}),s.o("div",{class:"flex flex-col items-center gap-2 pr-2.5 pt-2.5",children:[n?null:s.o(Fe,{}),e.config.minSelected===0&&s.o(ge,{class:"relative",type:"button",onClick:()=>r({type:"enum",value:[]})})]})]}),s.o("div",{class:"px-1",children:s.o(qe,{error:(g=c.checked)==null?void 0:g.root})})]})},ya=s.isSubmissionOfType("number"),ba=(e,r)=>{const t=e.min??Number.MIN_SAFE_INTEGER,n=e.max??Number.MAX_SAFE_INTEGER,a=e.decimalCases??0;return ft(be({number:Ce($r(r("validation_number")),Dr(t,r("validation_number_min",{min:t})),Rr(n,r("validation_number_max",{max:n})),Mr(i=>i===Number(i.toFixed(a)),r("validation_number_decimal_cases",{count:a})))}))},ga=({input:e,onSubmitSuccess:r})=>{var g;const t=e.config.defaultValue,n=e.key?(g=s.store.current$.value.flow)==null?void 0:g.data.submissions[e.key]:void 0,{t:a}=s.useTranslation(),{register:i,handleSubmit:o,formState:{errors:l}}=dt({defaultValues:{number:ya(n)?n.value:t?Number(t):void 0},resolver:ba(e.config,a)}),{ref:c,...f}=i("number",{required:!e.config.optional,valueAsNumber:!0}),h=s._();return s.y(()=>{h.current&&(h.current.focus(),h.current.select())},[]),s.o("form",{class:"flex flex-col gap-1 p-2.5",onSubmit:o(m=>{m.number!==void 0&&r({type:"number",value:m.number})}),children:[s.o("div",{class:"flex items-center gap-2",children:[s.o("div",{class:"relative min-w-0 flex-grow",children:[s.o("input",{...f,id:"chat-input",autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:m=>{m&&(h.current=m),c(m)},type:"text",min:e.config.min,max:e.config.max,class:Ue({optional:e.config.optional,className:"[type=number:-webkit-inner-spin-button] w-full rounded-full [-webkit-outer-spin-button:none]"}),placeholder:e.config.placeholder}),e.config.optional&&s.o(ge,{class:"absolute bottom-0 right-0.5 top-0",onClick:()=>r(null)})]}),s.o(Fe,{})]}),s.o(qe,{error:l.number})]})},va="44",xa=/^[0-9 ]+$/,wa=s.isSubmissionOfType("string"),_a=s.isSubmissionOfType("phone"),ka=e=>{const r=Ce(ae(e("validation_country_code")),Tt(xa,e("validation_country_code"))),t=Ce(ae(e("validation_phone")),$e(1,e("validation_phone")),Rt(n=>n.replace(/[^0-9]/g,"")));return ft(be({countryCode:r,phoneNumber:t}))},Ca=({input:e,onSubmitSuccess:r})=>{var _;const t=e.key?(_=s.store.current$.value.flow)==null?void 0:_.data.submissions[e.key]:void 0,{t:n}=s.useTranslation(),[a,i]=s.h(),o=wa(t)?ks(t.value):_a(t)?t.value:void 0,{register:l,handleSubmit:c,formState:{errors:f},watch:h}=dt({defaultValues:{countryCode:(o==null?void 0:o.countryCode)??e.config.defaultValue.countryCode??va,phoneNumber:(o==null?void 0:o.phoneNumber)??e.config.defaultValue.phoneNumber??""},resolver:ka(n)}),{ref:g,...m}=l("phoneNumber",{required:!e.config.optional}),y=s._(),k=h("countryCode");return s.y(()=>{y.current&&(y.current.focus(),y.current.select())},[]),s.o("form",{noValidate:!0,class:"flex flex-col gap-1 p-2.5",onSubmit:c(w=>{const S=w.phoneNumber.replace(/[^0-9]/g,""),x=w.countryCode.replace(/[^0-9]/g,"");i(void 0);const N=e.config.minChars??7,R=S.length+x.length;if(R<N)return i(n("validation_phone_min_chars",{count:N}));const A=e.config.maxChars;if(A!=null&&R>A)return i(n("validation_max_chars",{count:A}));e.config.submissionFormat==="phone"?r({type:"phone",value:{countryCode:x,phoneNumber:S}}):r({type:"string",value:k+w.phoneNumber})}),children:[s.o("div",{class:"flex items-center gap-2",children:[s.o("div",{class:"relative flex min-w-0 flex-1 flex-grow gap-2",children:[s.o("label",{class:"text-neutral-12 bg-lowest hover:bg-neutral-5 placeholder:text-neutral-8 focus-visible:outline-accent-7 focus-within:bg-neutral-5 focus-within:outline-accent-7 outline-divider relative flex h-full cursor-pointer appearance-none items-center justify-center overflow-hidden text-ellipsis whitespace-nowrap rounded-l-full border-solid px-3 py-1.5 text-center text-base outline outline-2 transition-all focus-within:outline-none",htmlFor:`isdk_phone_${e.key}`,children:[s.o("span",{children:["+",k]}),s.o("select",{...l("countryCode",{}),id:`isdk_phone_${e.key}`,class:"absolute inset-0 opacity-0",children:Object.entries(Dt).map(([w,S])=>s.o("option",{value:S,children:[w," (+",S,")"]},w))})]}),s.o("input",{...m,id:"chat-input",type:"tel",inputMode:"tel",autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:w=>{w&&(y.current=w),g(w)},class:Ue({optional:e.config.optional,className:"min-w-0 flex-1 rounded-r-full"}),placeholder:e.config.placeholder}),e.config.optional&&s.o(ge,{class:"absolute bottom-0 right-1 top-0",onClick:()=>r(null)})]}),s.o(Fe,{})]}),s.o(qe,{error:f.countryCode||f.phoneNumber||{message:a}})]})},st=e=>e===void 0?0:Math.max(0,Math.ceil((e-Date.now())/1e3)),xr=(e,r,t,n)=>t!==void 0&&n*1e3>s.J?e("submission_available_at",{time:s.he(t,r)}):e("submission_cooldown",{count:n}),Sa=(e,r)=>{const t=e==null?void 0:e.trim();return t&&t!=="Submit"?t:r("submit")},Aa=({input:e,onSubmitSuccess:r})=>{const{t,locale:n}=s.useTranslation(),{availableAt:a}=e.config,[i,o]=s.h(()=>st(a)),[l,c]=s.h("");s.p(()=>{const h=st(a);if(o(h),h===0)return;c(xr(t,n,a,h));const g=setInterval(()=>{const m=st(a);o(m),!(m>0)&&(clearInterval(g),c(t("submission_cooldown_ready")))},250);return()=>clearInterval(g)},[a,n,t]);const f=i>0;return s.o("div",{class:"flex flex-col items-center gap-2 py-3",children:[s.o("button",{class:"bg-accent-9 hover:bg-accent-10 active:bg-submit-bg-active hover:border-accent-10 active:border-submit-bg-active border-accent-9 ring-accent-6 focus-visible:outline-accent-8 ring-offset-neutral-1 aria-disabled:hover:bg-accent-9 aria-disabled:hover:border-accent-9 flex cursor-pointer rounded-full border border-solid px-5 py-3 pr-4 text-white outline-none ring-1 ring-offset-[1.5px] transition-all duration-300 focus-visible:outline-2 active:ring-2 active:ring-offset-2 aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:active:ring-1 aria-disabled:active:ring-offset-[1.5px]",name:e.key,"aria-disabled":f,"aria-describedby":f?"submit-cooldown":void 0,onClick:()=>{st(a)>0||r(null)},children:s.o("span",{class:"flex items-center gap-1.5",children:[s.o("span",{class:"inline-flex items-center text-sm font-medium",children:Sa(e.config.label,t)}),s.o("svg",{stroke:"currentColor","stroke-width":"1.5",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.o("path",{d:"M4 8L8 4L12 8"}),s.o("path",{d:"M8 4V13"})]})]})}),f&&s.o("p",{id:"submit-cooldown","aria-hidden":"true",class:"text-neutral-11 text-xs",children:xr(t,n,a,i)}),s.o("p",{role:"status",class:"sr-only",children:l})]})},Ea=160,wr=e=>{e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,Ea)}px`},Ia={date:{type:"date",inputMode:"text"},email:{type:"email",inputMode:"email",formNoValidate:!0},text:{type:"text",inputMode:"text"},url:{type:"url",inputMode:"url",formNoValidate:!0}},Fa=s.isSubmissionOfType("string"),Va=(e,r)=>{const t={maxLength:r("validation_max_chars",{count:e.maxChars??999}),minLength:r("validation_min_chars",{count:e.minChars??1})};return ft(be({text:{date:Ce(ae(r("validation_date")),Tt(/^\d{4}-\d{2}-\d{2}$/,r("validation_date"))),email:Ce(ae(r("validation_email")),Tr(r("validation_email")),$e(e.minChars??1,t.minLength),Xe(e.maxChars??1/0,t.maxLength)),text:Ce(ae(),$e(e.minChars??1,t.minLength),Xe(e.maxChars??1/0,t.maxLength)),url:Ce(ae(r("validation_url")),Nr(r("validation_url")),$e(e.minChars??1,t.minLength),Xe(e.maxChars??1/0,t.maxLength))}[e.format]}))},La=({input:e,onSubmitSuccess:r})=>{var _;const{t}=s.useTranslation(),n=e.key?(_=s.store.current$.value.flow)==null?void 0:_.data.submissions[e.key]:void 0,a=e.config.defaultValue,i=e.config.multiline===!0&&e.config.format==="text",{register:o,handleSubmit:l,watch:c,formState:{errors:f}}=dt({defaultValues:{text:Fa(n)?n.value:a??""},resolver:Va(e.config,t)}),{ref:h,...g}=o("text",{required:!e.config.optional}),m=s._();s.y(()=>{m.current&&(m.current instanceof HTMLTextAreaElement&&wr(m.current),m.current.focus(),m.current.select())},[]);const y=e.config.maxChars,k=i&&y!==void 0?c("text").length:void 0;return s.o("form",{noValidate:!0,class:"flex flex-col gap-1 p-2.5",onSubmit:l(w=>{r({type:"string",value:w.text})}),children:[s.o("div",{class:i?"flex items-end gap-2":"flex items-center gap-2",children:[s.o("div",{class:"relative min-w-0 flex-1",children:[i?s.o("textarea",{id:"chat-input",...g,rows:2,maxLength:y,autoFocus:!0,"aria-describedby":k!==void 0?"chat-input-count":void 0,onInput:w=>wr(w.currentTarget),onKeyDown:w=>{var S;w.key==="Enter"&&(w.ctrlKey||w.metaKey)&&(w.preventDefault(),(S=w.currentTarget.form)==null||S.requestSubmit())},ref:w=>{w&&(m.current=w),h(w)},placeholder:e.config.placeholder,class:Ue({optional:!!e.config.optional,className:"block w-full resize-none overflow-y-auto rounded-2xl"})}):s.o("input",{id:"chat-input",...g,...Ia[e.config.format],autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:w=>{w&&(m.current=w),h(w)},placeholder:e.config.placeholder,class:Ue({optional:!!e.config.optional,className:"w-full rounded-full"})}),e.config.optional&&s.o(ge,{class:i?"absolute bottom-1 right-0.5":"absolute bottom-0 right-0.5 top-0",onClick:()=>r(null)})]}),s.o(Fe,{})]}),k!==void 0&&y!==void 0&&s.o("p",{id:"chat-input-count",class:"text-neutral-10 px-3 text-right text-xs",children:[k,"/",y]}),s.o(qe,{error:f.text})]})},Ma={text:La,phone:Ca,"multiple-choice":ma,boolean:Ts,file:Bs,submit:Aa,address:Fs,number:ga},Ta=({logger:e,analytics:r,rpcClient:t})=>{var o;const n=(o=s.store.current$.value.flow)==null?void 0:o.data.currentInput,a=s._(null),i=()=>s.chatStore.onInteractionFn$.value();return s.y(()=>{var l;(l=a.current)==null||l.scrollTo({top:0})},[n]),s.o("div",{ref:a,class:"border-divider max-h-[calc(100%-var(--header-height)-4rem)] w-full shrink-0 scroll-pb-12 overflow-y-auto overscroll-contain border-t",children:s.o("div",{class:"flex flex-col",onPointerDownCapture:n?i:void 0,onKeyDownCapture:n?i:void 0,children:n?(()=>{const l=Ma[n.type];return s.o(l,{logger:e,analytics:r,rpcClient:t,onSubmitSuccess:s.chatStore.onSubmitSuccessFn$.value,input:n})})():s.o("div",{class:"flex items-center gap-2 p-2.5",children:[s.o("input",{"aria-hidden":"true",id:"chat-input",class:Ue({optional:!1,className:"flex-grow rounded-full"}),disabled:!0}),s.o(Fe,{disabled:!0,"aria-hidden":"true",tabIndex:-1})]})})})};function Ra(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Da=function(e){return e instanceof RegExp},Na=function(r){var t=/[\\^$.*+?()[\]{}|]/g,n=RegExp(t.source);return r&&n.test(r)?r.replace(t,"\\$&"):r},rn=function(e){return typeof e=="string"},Oa=function(e){var r=[];return e.forEach(function(t){Array.isArray(t)?r=r.concat(t):r.push(t)}),r};function ja(e,r,t){var n=0,a=0;if(e==="")return e;if(!e||!rn(e))throw new TypeError("First argument to react-string-replace#replaceString must be a string");var i=r;Da(i)||(i=new RegExp("("+Na(i)+")","gi"));for(var o=e.split(i),l=1,c=o.length;l<c;l+=2){if(o[l]===void 0||o[l-1]===void 0){console.warn("reactStringReplace: Encountered undefined value during string replacement. Your RegExp may not be working the way you expect.");continue}a=o[l].length,n+=o[l-1].length,o[l]=t(o[l],l,n),n+=a}return o}var Ba=function(r,t,n){return Array.isArray(r)||(r=[r]),Oa(r.map(function(a){return rn(a)?ja(a,t,n):a}))};const Je=Ra(Ba),$a=/(\[[^\]]+\]\([^)]+\))/g,Pa=/\[([^\]]+)\]\(([^)]+)\)/,Ua=/(https?:\/\/[^\s]+)/g,qa=/_(.*?)_/g,za=/\*\*(.*?)\*\*/g,Wa=/(\\n|\n)/g,_r="text-accent-10 hover:text-accent-11 no-underline underline-offset-2 hover:underline",Ha=e=>{const r=Je(e,$a,(l,c)=>{const[,f,h]=l.match(Pa)??[];return h?s.o("a",{class:_r,href:h,children:f??h},h+c):s.o("span",{children:"INVALID LINK"})}),t=Je(r,Ua,(l,c)=>s.o("a",{class:_r,href:l,children:l},l+c)),n=Je(t,qa,(l,c)=>s.o("em",{children:l},l+c)),a=Je(n,za,(l,c)=>s.o("strong",{children:l},l+c));let i=0;return Je(a,Wa,()=>s.o("br",{},`br-${i++}`))},Ka=s.cva("select-text max-w-[min(100%,24rem)] [text-wrap:pretty] leading-snug flex-shrink min-w-[2rem] py-2 px-3 rounded-[18px] min-h-[36px] break-words relative",{variants:{side:{left:"bg-bubble-weak-bg text-neutral-12 shadow-surface-sm outline outline-1 outline-bubble-weak rounded-bl-md",right:"ml-auto bg-accent-9 text-white rounded-br-md shadow-surface-sm shadow-bubble-strong-shadow"},animate:{true:"animate-bubble-in",false:""}},defaultVariants:{side:"left"}}),Ga=({children:e,className:r,animate:t,side:n,...a})=>s.o("p",{style:{transformOrigin:n==="left"?"0% 50%":"100% 50%"},class:Ka({className:r,side:n,animate:t}),...a,children:e}),kr=new Map,Cr=s.createTFunction({overrides:{},locale:void 0}),Ja=(e,r)=>{const t=r==null?void 0:r.trim();if(!t)return e("job_alerts_privacy");const n=e("job_alerts_privacy_sender",{employer:t});return e("job_alerts_privacy")!==Cr("job_alerts_privacy")&&n===Cr("job_alerts_privacy_sender",{employer:t})?e("job_alerts_privacy"):n},Za=({flow:e,rpcClient:r})=>{const{t}=s.useTranslation(),n=e.data.flowSessionId,a=kr.get(n)??s.d("offer");kr.set(n,a);const i=c=>{const f=e.data.submissions[c];return(f==null?void 0:f.type)==="string"?f.value.trim():void 0},o=i("email")||e.nodes.flatMap(c=>c.type==="question-text"&&c.data.format==="email"?[i(c.data.key)]:[]).find(c=>!!c);if(!o||a.value==="declined")return null;if(a.value==="success")return s.o("p",{role:"status",children:t("job_alerts_success")});const l=async()=>{if(!(a.value!=="offer"&&a.value!=="error")){a.value="saving";try{await at.saveClosedRoleJobAlerts(r,{contact:{email:o,first_name:i("first_name"),last_name:i("last_name")},job:e.job}),a.value="success"}catch{a.value="error"}}};return s.o("div",{class:"bg-neutral-2 flex flex-col gap-2 rounded-xl p-3 text-sm",children:[s.o("p",{children:t("job_alerts_offer",{email:o})}),a.value==="error"?s.o("p",{role:"alert",children:t("job_alerts_error")}):null,s.o("div",{class:"flex gap-2",children:[s.o("button",{type:"button",class:"bg-accent-9 min-h-[44px] rounded-lg px-3 py-2 text-white",disabled:a.value==="saving",onClick:l,children:t("job_alerts_accept")}),s.o("button",{type:"button",class:"min-h-[44px] rounded-lg px-3 py-2",disabled:a.value==="saving",onClick:()=>{a.value!=="offer"&&a.value!=="error"||(a.value="declined")},children:t("job_alerts_decline")})]}),s.o("p",{class:"text-xs",children:Ja(t,e.employer)})]})},Xa=({message:e})=>s.o("div",{class:"bg-accent-3 flex w-full items-center justify-center overflow-hidden rounded-xl px-2 py-2",children:s.o("a",{onClick:e.onClick,class:"bg-lowest shadow-surface-sm ring-accent-6 hover:ring-accent-8 active:bg-accent-2 active:text-accent-10 text-accent-9 focus-visible:ring-accent-7/50 text-wrap-balance flex items-center gap-1.5 rounded-full py-2 pl-4 pr-2.5 text-center no-underline ring-1 transition-all focus:outline-none focus-visible:ring-4 focus-visible:ring-offset-2",target:"_blank",href:e.href,children:[e.text,s.o("svg",{class:"flex-none",width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.o("path",{d:"M3.64645 11.3536C3.45118 11.1583 3.45118 10.8417 3.64645 10.6465L10.2929 4L6 4C5.72386 4 5.5 3.77614 5.5 3.5C5.5 3.22386 5.72386 3 6 3L11.5 3C11.6326 3 11.7598 3.05268 11.8536 3.14645C11.9473 3.24022 12 3.36739 12 3.5L12 9.00001C12 9.27615 11.7761 9.50001 11.5 9.50001C11.2239 9.50001 11 9.27615 11 9.00001V4.70711L4.35355 11.3536C4.15829 11.5488 3.84171 11.5488 3.64645 11.3536Z",fill:"currentColor","fill-rule":"evenodd","clip-rule":"evenodd"})})]})}),Ya=({className:e,...r})=>s.o("div",{"aria-hidden":!0,children:s.chatStore.isBotTyping$.value===!0?s.o("div",{"data-testid":"typing-indicator",class:s.clsx("flex gap-1 p-4",e),...r,children:Array.from({length:3},(t,n)=>s.o("div",{class:"bg-accent-9 h-1.5 w-1.5 animate-bounce rounded-full",style:{animationDelay:`${-n*200}ms`}}))}):void 0}),Qa={bot:"left",user:"right"},ei=s.cva("w-full select-none py-2 text-wrap-balance text-center text-[10px] uppercase tracking-widest drop-shadow-[0_1.5px_var(--i-color-n-1)]",{variants:{variant:{info:"text-neutral-11",warning:"text-system-warning",error:"text-error-11",success:"text-system-success"}}}),ti=({env:e,lastSentMessageFooter:r,rpcClient:t})=>{const{t:n}=s.useTranslation(),a=s.store.current$.value.flow,i=(a==null?void 0:a.data.messages)??[],o=i.findIndex(c=>c.type==="system"&&c.semantic==="submission-closed"),l=a?Lt(a):void 0;return s.o("ol",{"aria-label":n("chat_messages"),"aria-live":"polite",class:"mt-auto flex flex-col justify-end gap-2 p-2 pt-[calc(var(--header-height)+1rem)]",children:[i.map((c,f)=>s.o(s.k,{children:[s.o("li",{class:"flex",tabIndex:f===i.length-1?-1:void 0,children:[l&&c.groupId===l&&!i.slice(f+1).some(h=>h.groupId===l)?r:null,s.M(c).with({type:"system"},h=>s.o("p",{class:ei({variant:h.variant}),children:h.text})).with({type:"text",author:s.z.union("bot","user")},h=>{const g=f===i.length-1,m=h.author==="bot"?Ha(h.text):h.text;return s.o(s.k,{children:s.o(Ga,{animate:g,side:Qa[h.author],children:m},f)})}).with({type:"link"},h=>s.o(Xa,{message:h})).with({type:"image"},h=>s.o("img",{class:"shadow-surface-md w-full max-w-[min(100%,24rem)] rounded-2xl",src:h.url,style:{aspectRatio:h.width/h.height}})).with({type:"file"},h=>s.o(Ds,{class:h.author==="bot"?void 0:"ml-auto",file:{name:h.fileName,sizeKb:h.fileSizeKb}})).with({type:"loading"},h=>{const g=i[i.length-1];return!(h===g)||s.chatStore.isBotTyping$.value||a!=null&&a.data.isFinished?null:s.o("div",{class:"flex flex-grow flex-col items-center justify-center gap-2",children:[s.o(s.LoadingIndicator,{"aria-hidden":h.text?"true":void 0,class:"text-neutral-6 h-8 w-8"}),h.text?s.o("p",{role:"status",class:"text-neutral-11 text-sm",children:h.text}):null]})}).exhaustive()]}),f===o&&(a!=null&&a.jobAlerts)&&t?s.o("li",{children:s.o(Za,{flow:a,rpcClient:t},a.data.flowSessionId)}):null]},f)),e&&e!=="production"&&(a==null?void 0:a.data.isFinished)&&a.data.stagingDestination&&s.o("li",{class:"text-neutral-11 text-center text-xs",children:a.data.stagingDestination}),s.o("li",{class:s.chatStore.captchaVisible$.value?"flex":"hidden",children:s.o("div",{"data-captcha-slot":!0,tabIndex:-1,role:"group","aria-label":n("captcha_check"),class:"w-full max-w-[min(100%,24rem)] rounded-md"})},"captcha"),s.o(Ya,{},"typing")]})},ri=({logger:e,apiClient:r,rpcClient:t,analytics:n,talentBankClient:a,env:i})=>{const{flow:o}=s.store.current$.value;s.invariant(o,"Flow is required to exist to show chatbot body");const l=s.store.viewState$.value,{chatRef:c,chatService:f}=s.useChatService(),{t:h}=s.useTranslation(),[g,m]=s.h();return s.y(()=>{l==="maximised"&&s.chatStore.scrollToEnd()},[l]),s.y(()=>{var O;const{state:y,flow:k}=s.store.current$.peek();if(y!=="loaded")throw new Error(h("invalid_state"));let _=k.data.nodeHistory.at(-1);if(s.chatStore.scrollToEnd(),s.store.setInput(void 0),k.data.isFinished)return;const w=()=>{const V=s.store.current$.peek().flow;!V||V.data.hasInteracted||(s.store.markAsInteracted(),Zt(n,V,"FLOW_INTERACT"))};s.chatStore.onInteractionFn$.value=w,_===void 0?(_=Ir(o.nodes).id,s.store.setCurrentNodeId(_),Zt(n,k,"FLOW_START")):s.store.removeMessagesSentByNodeIds([_,Et]);const{interpret:S,abort:x,undo:N}=Bn({context:o.context,analytics:{service:n,customProperties:(O=o.analytics)==null?void 0:O.customProperties},apiClient:r,logger:e,talentBankClient:a,flow:o,chatService:f,t:h,getApplicationRecovery:()=>{var V;return(V=s.store.current$.peek().flow)==null?void 0:V.data.applicationRecovery},setApplicationRecovery:s.store.setApplicationRecovery,persistWriteBarrier:()=>s.store.persistWriteBarrier(k),getSubmissions:()=>{var V;return(V=s.store.current$.peek().flow)==null?void 0:V.data.submissions},onInterpret:V=>s.store.setCurrentNodeId(V.id),onFlowEnd:async()=>{var M;s.store.markAsFinished();const V=s.store.current$.peek().flow;s.invariant(V),n.log({event:"FLOW_END",properties:{flow_id:o.id,flow_version:o.version,flow_session_id:V.data.flowSessionId,flow_build:o.build,job:o.job},customProperties:(M=o.analytics)==null?void 0:M.customProperties})}}),R=_,A=()=>{m(()=>N),S(R)},q=new AbortController;return k.offerResume?fs({chatService:f,t:h,signal:q.signal}).then(V=>(s.store.settleResume(k),V?A():(s.store.restart(),s.idb.flushStateData()))).catch(V=>{V instanceof s.O||e.error("Resume prompt failed",V)}):A(),()=>{q.abort(),s.chatStore.onInteractionFn$.value===w&&(s.chatStore.onInteractionFn$.value=()=>{}),x()}},[n,r,f,e,o,a,h]),s.o(s.k,{children:[s.o("div",{class:"relative flex min-h-0 w-full max-w-full flex-grow flex-col",children:[s.o("div",{ref:c,role:"region","aria-label":h("conversation_history"),tabIndex:0,className:"hide-scrollbars fr flex min-h-0 w-full max-w-full flex-grow flex-col overflow-y-auto ring-inset",style:{WebkitOverflowScrolling:"touch"},children:s.o(ti,{env:i,rpcClient:t,lastSentMessageFooter:!Lt(o)||!g?null:s.o(ni,{undoFn:g})})}),s.chatStore.isReadingHistory$.value&&!o.data.isFinished&&!s.chatStore.isBotTyping$.value&&s.o("div",{class:"absolute bottom-2 left-1/2 -translate-x-1/2",children:s.o(s.SvgIconButton,{class:"bg-neutral-1 ring-divider shadow-surface-md ring-1","aria-label":h("jump_to_current"),onClick:()=>{var k,_;s.chatStore.scrollToEnd(),(_=((k=c.current)==null?void 0:k.querySelector('li[tabindex="-1"]'))??c.current)==null||_.focus({preventScroll:!0})},children:s.o(s.ChevronDown,{})})})]}),s.o(Ta,{logger:e,analytics:n,rpcClient:t})]})},ni=({undoFn:e})=>{const{t:r}=s.useTranslation();return s.o("div",{class:"flex flex-1 items-center justify-end px-1",children:s.o(s.SvgIconButton,{"aria-label":r("undo"),onClick:async()=>{const{flow:t}=s.store.current$.peek();s.invariant(t),e(t.data.nodeHistory)},children:s.o("path",{d:"M3 13h2.67l6.66-6.67a1.9 1.9 0 0 0 0-2.66 1.91 1.91 0 0 0-2.66 0L3 10.33V13Zm4.6-7.25 2.67 2.67"})})})};exports.ChatbotBody=ri;
|