@inploi/plugin-chatbot 14.0.0 → 14.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cdn/index.js +5 -5
- package/dist/{chatbot-body-bb8289cb.js → chatbot-body-4bed3e94.js} +1374 -1320
- package/dist/chatbot-body-9328c4b7.cjs +5 -0
- package/dist/chatbot.idb.d.ts +1 -0
- package/dist/chatbot.state.d.ts +11 -0
- package/dist/components/correction.test.d.ts +1 -0
- package/dist/i18n.d.ts +30 -18
- package/dist/index-56ea6372.cjs +5 -0
- package/dist/{index-3a093ba1.js → index-b60fcc82.js} +198 -183
- package/dist/interpreter.d.ts +4 -1
- package/dist/plugin-chatbot.cjs +1 -1
- package/dist/plugin-chatbot.js +1 -1
- package/dist/style/tokens.d.ts +4 -4
- package/package.json +4 -4
- package/dist/chatbot-body-90cadbb9.cjs +0 -5
- package/dist/index-7aaddd89.cjs +0 -5
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./index-56ea6372.cjs"),Kt=require("@inploi/sdk"),vt=(e,r,t)=>{var s;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:(s=r.analytics)==null?void 0:s.customProperties})};var xt=({condition:e,context:r,submissions:t,ifBlock:s})=>{let[a,...o]=e.compareKey.split(".");if(!a)return!1;let i=n.D({context:r,key:a,path:o,submissions:t});if(!i)return!1;switch(i.type){case"address":{let l=n.S(i.value,o);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 i.value!="object"||Array.isArray(i.value))return!1;let l=n.S(i.value,o),d={...s,data:{compareKey:"_temp",compare:e.compare,compareValue:e.compareValue}};switch(typeof l){case"boolean":return Fe(d,{submissions:{_temp:{value:l,type:"boolean"}},context:r});case"string":return Fe(d,{submissions:{_temp:{value:l,type:"string"}},context:r});case"number":return Fe(d,{submissions:{_temp:{value:l,type:"number"}},context:r});case"object":return Array.isArray(l)&&l.every(p=>typeof p=="string")?Fe(d,{submissions:{_temp:{value:l,type:"enum"}},context:r}):!1}break}case"boolean":{let l=e.compareValue==="true";switch(e.compare){case"equals":return i.value===l;case"notEquals":return i.value!==l}break}case"phone":case"string":{let l=i.type==="phone"?n.B(i.value):i.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 i.value===l;case"notEquals":return i.value!==l;case"greaterThan":return i.value>l;case"greaterThanOrEqualTo":return i.value>=l;case"lessThan":return i.value<l;case"lessThanOrEqualTo":return i.value<=l}}catch{return console.error(`Failed to parse number in if-block ${s.id}`,i.value),!1}break}case"enum":switch(e.compare){case"equals":return i.value.length===1&&i.value[0]===e.compareValue;case"notEquals":return i.value.length===1&&i.value[0]!==e.compareValue;case"contains":return i.value.includes(e.compareValue);case"notContains":return!i.value.includes(e.compareValue)}break}},Fe=(e,{context:r,submissions:t})=>{let s="combinator"in e.data?e.data.conditions:[e.data];if(("combinator"in e.data?e.data.combinator:"and")==="or"){for(let a of s)if(xt({condition:a,context:r,submissions:t,ifBlock:e}))return!0;return!1}else{for(let a of s)if(!xt({condition:a,context:r,submissions:t,ifBlock:e}))return!1;return!0}},Er=/{{\s*([^}]+?)\s*(?:\|\s*([^}]+?)\s*)?}}/g,Mr=(e,{context:r,submissions:t})=>e.replace(Er,(s,a,o="")=>{let[i,...l]=a.trim().split("."),d=n.D({key:i,path:l,submissions:t,context:r});if(!d)return o;switch(d.type){case"boolean":return d.value===!0?"true":"false";case"file":return d.value.map(p=>`${p.name} (${n.V(p.sizeKb)})`).join(", ");case"enum":return d.value.join(", ");case"address":return Object.values(d.value).filter(p=>p&&p.trim().length>0).join(", ");case"number":case"string":return d.value?d.value.toString():o;case"phone":return n.B(d.value);case"integration":{if(typeof d.value!="object"||Array.isArray(d.value))break;let p=n.S(d.value,l);switch(typeof p){case"boolean":return p===!0?"true":"false";case"string":return p;case"number":return p.toString();case"object":if(Array.isArray(p)&&p.every(v=>typeof v=="string"))return p.join(", ")}break}}return o});const Gt=({context:e,submissions:r})=>({context:e,submissions:r??{}}),ie=(e,r)=>Mr(e,Gt(r)),Nr=(e,r)=>Fe(e,Gt(r)),Ht=({node:e,nodes:r,stopWhen:t})=>{if((t==null?void 0:t(e))===!0)return e;const s=e.nextId?r.find(a=>a.id===e.nextId):void 0;if(s)return Ht({node:s,nodes:r,stopWhen:t})},Tr=({childNode:e,nodes:r})=>{const s=r.filter(a=>a.type==="if-block").find(a=>{if(!a.branchId)return!1;const o=r.find(l=>l.id===a.branchId);if(!o)return!1;const i=Ht({node:o,nodes:r,stopWhen:l=>l.id===e.id});return!(!i||i.id!==e.id)});if(s!=null&&s.nextId)return r.find(a=>a.id===s.nextId)},Lr=({flow:e,analytics:r,logger:t,talentBankClient:s,context:a,apiClient:o,getSubmissions:i,getApplicationRecovery:l,setApplicationRecovery:d,chatService:p,persistWriteBarrier:v,onFlowEnd:x,onInterpret:h,t:m})=>{var N;let k=new AbortController;(N=e.data).startedWriteNodeIds??(N.startedWriteNodeIds=e.nodes.flatMap(y=>{var A,R;if(y.type!=="integration-application-submit"||!e.data.nodeHistory.includes(y.id))return[];const C=y.data.key?(A=i())==null?void 0:A[y.data.key]:void 0;return(C==null?void 0:C.type)==="integration"&&((R=Jt(C.value,void 0))==null?void 0:R.verdict)==="not_submitted"?[]:[y.id]}));const V={...r.service,log:y=>r.service.log({...y,customProperties:{...y.customProperties,...r.customProperties}})},I=async(y,C)=>{const E=k.signal;if(E.aborted)return;const A=i(),R=l(),H=(R==null?void 0:R.submitNodeId)===y.id?e.nodes.find(L=>{var $;return L.id===R.fileQuestionNodeId&&L.type==="question-file"&&(($=A==null?void 0:A[L.data.key])==null?void 0:$.type)!=="file"}):void 0;if(H)return I(H,C);h==null||h(y,C);try{await Dr({flow:e,analytics:V,logger:t,talentBankClient:s,apiClient:o,context:a,node:y,submissions:A,applicationRecovery:R,setApplicationRecovery:async L=>{if(!E.aborted)try{await d(L)}catch($){t.error("Failed to persist application recovery",$)}},forceSubmitConfirmation:(R==null?void 0:R.submitNodeId)===y.id,persistWriteBarrier:v,signal:E,t:m,chat:{sendMessage:async L=>p.send({groupId:y.id,message:L,signal:E}),userInput:async L=>p.input({input:L,signal:E}),setSubmission:(L,$)=>{E.aborted||p.setSubmission(L,$)}},next:L=>{if(E.aborted)return;const $=(R==null?void 0:R.fileQuestionNodeId)===y.id?R.submitNodeId:L,F=$?e.nodes.find(G=>G.id===$):Tr({childNode:y,nodes:e.nodes});return F?I(F,y):x==null?void 0:x(y)},end:()=>{E.aborted||x==null||x(y)}})}catch(L){if(L instanceof n.AbortedError)return;throw L}};return{interpret:async y=>{const C=e.nodes.find(E=>E.id===y)??n.getHeadOrThrow(e.nodes);return I(C)},undo:y=>{var $;if(($=e.data.startedWriteNodeIds)!=null&&$.length||e.data.isFinished)return{removed:0};const C=n.getCorrectionNodeId(e),E=C?y.lastIndexOf(C):-1,A=e.nodes.find(F=>F.id===C);if(E===-1||!A)return{removed:0};const R=e.nodes.find(F=>F.id===y[y.length-1]);k.abort();const H=y.splice(E);e.data.messages=e.data.messages.filter(F=>!F.groupId||!H.includes(F.groupId)),e.data.currentInput=null;const L=i();for(const F of H.slice(1)){const G=e.nodes.find(M=>M.id===F);if(!(!G||!L||G.id===C)&&("key"in G.data&&G.data.key&&delete L[G.data.key],"keys"in G.data))for(const M of Object.values(G.data.keys))typeof M=="string"&&delete L[M]}return k=new AbortController,I(A,R),{removed:H.length}},abort:()=>{k.abort()}}};async function Dr(e){const 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 es({...e,node:r});case"text":return zr({...e,node:r});case"image":return Wr({...e,node:r});case"question-text":return Kr({...e,node:r});case"question-enum":return Jr({...e,node:r});case"question-number":return Gr({...e,node:r});case"question-phone":return Hr({...e,node:r});case"question-boolean":return Zr({...e,node:r});case"question-file":return Yr({...e,node:r});case"question-address":return Xr({...e,node:r});case"end-flow":return Qr({...e,node:r});case"if-block":return Ur({...e,node:r});case"jump":return Rr({...e,node:r});case"link":return qr({...e,node:r});case"integration-application-submit":return jr({...e,node:r});case"add-submission":return Pr({...e,node:r});case"integration-workflow-get":throw Error("Workflow should be unreachable");case"check-duplicate":return Br({...e,node:r});case"feedback":return Or({...e,node:r});default:throw new Error(`Unknown node: ${JSON.stringify(r)}`)}}async function Or({next:e,node:r}){e(r.nextId)}async function Br({next:e,node:r,talentBankClient:t,submissions:s,flow:a,logger:o,chat:i}){var d;let l={isDuplicate:!1};if(s&&t){const p=r.data.scope==="job"?(d=a.job)==null?void 0:d.id:void 0;if(r.data.scope==="company"||p!=null)try{l=await t.checkDuplicate({email:n.M({key:r.data.email,submissions:s}).toString(),jobId:p,scope:r.data.scope})}catch(v){o.error("[check-duplicate]",v)}}i.setSubmission(r.data.key,{type:"integration",value:l}),e(r.nextId)}async function Rr({next:e,node:r}){e(r.data.targetId)}async function Pr({next:e,node:r,logger:t,submissions:s,context:a}){if(!s){t.error("Submissions not found");return}s[r.data.key]={type:"string",value:ie(r.data.value,{submissions:s,context:a})},e(r.nextId)}const $r=5e3;async function jr({chat:e,next:r,end:t,node:s,logger:a,apiClient:o,submissions:i,analytics:l,flow:d,applicationRecovery:p,setApplicationRecovery:v,forceSubmitConfirmation:x,persistWriteBarrier:h,signal:m,t:k}){var I;if((I=d.data.startedWriteNodeIds)!=null&&I.includes(s.id)&&(p==null?void 0:p.submitNodeId)!==s.id)return await e.sendMessage({type:"system",variant:"warning",text:k("submission_unknown")}),t();const V=async N=>{var G,M,D;N!==!0&&await e.userInput({type:"submit",key:void 0,config:{label:s.data.submitLabel}}),await e.sendMessage({type:"loading",text:k("submitting")});const{anonymous_id:y,session_id:C}=l.getSessionInfo();if(m.aborted)return;const E=((G=d.data.startedWriteNodeIds)==null?void 0:G.includes(s.id))===!0;if((p==null?void 0:p.submitNodeId)===s.id&&await v(void 0),E||(d.data.startedWriteNodeIds=[...d.data.startedWriteNodeIds??[],s.id]),await h().catch(T=>a.error("Failed to persist application write barrier",T)),m.aborted)return;let A;const R=setTimeout(()=>{A=(async()=>{await e.sendMessage({type:"text",author:"bot",text:k("submission_still_working")}),await e.sendMessage({type:"loading",text:k("submitting")})})().catch(T=>a.error("Failed to send submission progress message",T))},$r);let H;const L=await o.fetch("/flow/submit",{method:"POST",body:JSON.stringify({log_submit:!1,integration_id:s.data.integrationId,anonymous_id:y,session_id:C,job:d.job,flow_build:d.build,submissions:n.E(d.nodes,n.$(i||{},s.data.submitKeys)),pre_apply:n.k(d.nodes,i||{},d.data.flowSessionId)})}).catch(T=>(H=T,Kt.isApiErrorWithData(T)?T.data:T));if(clearTimeout(R),await A,m.aborted)return;s.data.key&&e.setSubmission(s.data.key,{type:"integration",value:L});const $=n.H(L);if($&&l.log({event:"FLOW_SUBMIT",properties:{flow_id:d.id,flow_version:d.version,flow_session_id:d.data.flowSessionId,flow_build:d.build,service:$.service,response:$.response,flow_type:"CHATBOT_DRAWER",job:d.job}}),n.K(L)){const{redirect_url:T,message:q,button_text:J}=L.integration_response.data;await e.sendMessage({type:"text",author:"bot",text:q??k("submission_redirect_message")});try{const U=new URL(T);y&&!U.searchParams.has("anonymous_id")&&U.searchParams.set("anonymous_id",y),await e.sendMessage({type:"link",href:U.toString(),text:J??k("complete_submission"),onClick:()=>{if(!C){a.error("session_id not set, cannot log FLOW_REDIRECT event");return}l.log({event:"FLOW_REDIRECT",properties:{flow_build:d.build,flow_id:d.id,flow_session_id:C,flow_version:d.version,href:U.toString(),job:d.job}})}})}catch(U){a.error(`Invalid redirect URL: ${T}`,U),e.sendMessage({type:"system",variant:"error",text:k("redirect_url_error")})}return r(s.nextId)}if((L==null?void 0:L.success)===!0)return s.data.skipConfirmation!==!0&&await e.sendMessage({type:"system",variant:"success",text:k("submission_completed")}),r(s.nextId);const F=Jt(L,H);if((F==null?void 0:F.verdict)==="not_submitted"&&(E||(d.data.startedWriteNodeIds=(M=d.data.startedWriteNodeIds)==null?void 0:M.filter(T=>T!==s.id)),(p==null?void 0:p.submitNodeId)===s.id&&await v(p),await h().catch(T=>a.error("Failed to persist application write barrier release",T))),F){a.error(H??F.message);const T=F.phase==="submit"&&F.verdict==="confirmed"&&F.code==="unreadable_document"&&typeof F.field=="string"&&F.status!==void 0&&F.status>=400&&F.status<500&&((D=i==null?void 0:i[F.field])==null?void 0:D.type)==="file"?F.field:void 0,q=T===void 0?void 0:d.nodes.find(J=>J.type==="question-file"&&J.data.key===T);return q&&T!==void 0?(e.setSubmission(T,null),await v({fileQuestionNodeId:q.id,submitNodeId:s.id}),await e.sendMessage({type:"system",variant:"error",text:k("submission_unreadable_document")}),r(q.id)):F.status===409&&F.phase==="submit"&&F.verdict==="confirmed"?(await e.sendMessage({type:"system",variant:"info",text:k("submission_duplicate")}),t()):F.status===410&&F.code==="job_closed"?(await e.sendMessage({type:"system",variant:"info",text:k("submission_closed")}),t()):F.phase==="submit"&&F.verdict==="unknown"?(await e.sendMessage({type:"system",variant:"warning",text:k("submission_unknown")}),t()):F.phase==="workflow"&&F.retryable===!0&&F.verdict==="not_submitted"?(await e.sendMessage({type:"system",variant:"error",text:k("submission_retryable")}),V(!1)):(await e.sendMessage({type:"system",variant:"error",text:k("submission_failed")}),t())}return a.error(H??L),await e.sendMessage({type:"system",variant:"error",text:k("submission_failed")}),t()};await V(x===!0?!1:s.data.skipConfirmation)}const Jt=(e,r)=>{if(!n.z(e))return;const t=e.integration_response;if(typeof t!="object"||t===null)return;const s=t.error;if(typeof s!="object"||s===null)return;const a=s.data,o=typeof a=="object"&&a!==null?a:{},i=p=>typeof o[p]=="string"?o[p]:void 0,l=p=>typeof o[p]=="boolean"?o[p]:void 0,d=t.status;return{message:e.integration_response.error.message,status:typeof d=="number"?d:r instanceof Kt.ApiError?r.status:void 0,phase:i("phase"),retryable:l("retryable"),verdict:i("verdict"),code:i("code"),field:i("field")}};async function qr({chat:e,next:r,node:t,submissions:s,context:a}){await e.sendMessage({type:"link",href:ie(t.data.href,{submissions:s,context:a}),text:ie(t.data.cta,{submissions:s,context:a})}),r(t.nextId)}async function Ur({submissions:e,next:r,node:t,context:s}){r(Nr(t,{submissions:e,context:s})?t.branchId:t.nextId)}async function zr({chat:e,next:r,node:t,submissions:s,context:a}){await e.sendMessage({author:"bot",type:"text",text:ie(t.data.text,{submissions:s,context:a})}),r(t.nextId)}async function Wr({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 Kr({chat:e,next:r,node:t,submissions:s,context:a,t:o}){await e.sendMessage({author:"bot",type:"text",text:ie(t.data.question,{submissions:s,context:a})});const i=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}});i===null?await e.sendMessage({type:"system",variant:"info",text:o("skipped")}):await e.sendMessage({author:"user",type:"text",text:i.type==="phone"?n.B(i.value):i.value}),r(t.nextId)}async function Gr({chat:e,next:r,node:t,submissions:s,context:a,t:o}){await e.sendMessage({author:"bot",type:"text",text:ie(t.data.question,{submissions:s,context:a})});const i=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}});i===null?await e.sendMessage({type:"system",variant:"info",text:o("skipped")}):await e.sendMessage({author:"user",type:"text",text:i.value.toString()}),r(t.nextId)}async function Hr({chat:e,next:r,node:t,submissions:s,context:a,t:o}){await e.sendMessage({author:"bot",type:"text",text:ie(t.data.question,{submissions:s,context:a})});const i=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}});i===null?await e.sendMessage({type:"system",variant:"info",text:o("skipped")}):await e.sendMessage({author:"user",type:"text",text:i.type==="phone"?n.B(i.value):i.value}),r(t.nextId)}async function Jr({chat:e,next:r,node:t,submissions:s,context:a,t:o}){await e.sendMessage({author:"bot",type:"text",text:ie(t.data.question,{submissions:s,context:a})});const i=await e.userInput({key:t.data.key,type:"multiple-choice",config:t.data});i.value.length===0?await e.sendMessage({type:"system",variant:"info",text:o("skipped")}):await e.sendMessage({author:"user",type:"text",text:t.data.options.filter(l=>i.value.includes(l.value)).map(l=>l.label).join(", ")}),r(t.nextId)}async function Zr({chat:e,next:r,node:t,submissions:s,context:a,t:o}){await e.sendMessage({author:"bot",type:"text",text:ie(t.data.question,{submissions:s,context:a})});const i=await e.userInput({key:t.data.key,type:"boolean",config:{optional:t.data.optional,labels:{true:t.data.trueLabel,false:t.data.falseLabel}}});i===null?await e.sendMessage({type:"system",variant:"info",text:o("skipped")}):await e.sendMessage({author:"user",type:"text",text:i.value===!0?t.data.trueLabel:t.data.falseLabel}),r(t.nextId)}async function Xr({chat:e,next:r,node:t,t:s}){await e.sendMessage({author:"bot",type:"text",text:t.data.question});const a=await e.userInput({type:"address",key:t.data.key,config:{optional:t.data.optional,keys:t.data.keys,placeholder:t.data.placeholder}});if(a===null)await e.sendMessage({type:"system",variant:"info",text:s("skipped")});else{const o=Object.values(a.value).filter(i=>i&&i.trim().length>0).join(", ");await e.sendMessage({author:"user",type:"text",text:o})}return r(t.nextId)}async function Yr({node:e,chat:r,next:t,submissions:s,context:a,t:o}){await r.sendMessage({author:"bot",type:"text",text:ie(e.data.question,{submissions:s,context:a})});const i=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(i===null)await r.sendMessage({type:"system",variant:"info",text:o("skipped")});else for(const l of i.value)await r.sendMessage({author:"user",type:"file",fileName:l.name,fileSizeKb:l.sizeKb});return t(e.nextId)}async function Qr({chat:e,end:r,node:t}){await e.sendMessage({type:"system",variant:"info",text:t.data.systemMessage}),r()}async function es({node:e,flow:r,submissions:t,chat:s,next:a,apiClient:o,analytics:i}){const l=n.R(r.nodes,t||{}),{answers:d,...p}=l;s.setSubmission(e.data.key,{type:"integration",value:p});const v=new AbortController,x=setTimeout(()=>v.abort(),5e3);if(o.fetch("/flow/pre-apply",{method:"POST",signal:v.signal,body:JSON.stringify({...i.getSessionInfo(),job:r.job,flow_build:r.build,pre_apply:n.k(r.nodes,t||{},r.data.flowSessionId)})}).catch(()=>{}).finally(()=>clearTimeout(x)),l.status!=="skipped"){const m=[l.status==="unavailable"?"We could not prepare your pre-apply summary. You can still continue to your application.":l.hasHardConcerns?e.data.messages.hard:l.hasAdvisoryConcerns?e.data.messages.advisory:e.data.messages.matched];for(const k of["hard","advisory"]){const V=d.filter(I=>!I.matched&&I.severity===k);V.length&&m.push((k==="hard"?"Role requirements":"Other things to consider")+`
|
|
2
|
+
`+V.map(I=>`• ${I.message}`).join(`
|
|
3
|
+
`))}await s.sendMessage({type:"text",author:"bot",text:m.join(`
|
|
4
|
+
|
|
5
|
+
`)}),l.hasHardConcerns&&e.data.alternativeLink&&await s.sendMessage({type:"link",href:e.data.alternativeLink.href,text:e.data.alternativeLink.label}),await s.userInput({type:"submit",key:void 0,config:{label:e.data.continueLabel}})}return a(e.nextId)}const me=({class:e,...r})=>{const{t}=n.useTranslation();return n.o("button",{class:n.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:n.o("svg",{class:"block",width:"16",height:"16",viewBox:"0 0 16 16",fill:"transparent",stroke:"currentColor","stroke-linecap":"round","stroke-width":"2",children:[n.o("title",{children:t("send")}),n.o("path",{d:"M3.5 7.5L8 3L12.5 7.5"}),n.o("path",{d:"M8 4V13"})]})})};var oe;function Be(e){return{lang:(e==null?void 0:e.lang)??(oe==null?void 0:oe.lang),message:e==null?void 0:e.message,abortEarly:(e==null?void 0:e.abortEarly)??(oe==null?void 0:oe.abortEarly),abortPipeEarly:(e==null?void 0:e.abortPipeEarly)??(oe==null?void 0:oe.abortPipeEarly)}}var Ke;function ts(e){return Ke==null?void 0:Ke.get(e)}var Ge;function rs(e){return Ge==null?void 0:Ge.get(e)}var He;function ss(e,r){var t;return(t=He==null?void 0:He.get(e))==null?void 0:t.get(r)}function we(e){var t,s;const r=typeof e;return r==="string"?`"${e}"`:r==="number"||r==="bigint"||r==="boolean"?`${e}`:r==="object"||r==="function"?(e&&((s=(t=Object.getPrototypeOf(e))==null?void 0:t.constructor)==null?void 0:s.name))??"null":r}function Z(e,r,t,s,a){const o=a&&"input"in a?a.input:t.value,i=(a==null?void 0:a.expected)??e.expects??null,l=(a==null?void 0:a.received)??we(o),d={kind:e.kind,type:e.type,input:o,expected:i,received:l,message:`Invalid ${r}: ${i?`Expected ${i} but r`:"R"}eceived ${l}`,requirement:e.requirement,path:a==null?void 0:a.path,issues:a==null?void 0:a.issues,lang:s.lang,abortEarly:s.abortEarly,abortPipeEarly:s.abortPipeEarly},p=e.kind==="schema",v=(a==null?void 0:a.message)??e.message??ss(e.reference,d.lang)??(p?rs(d.lang):null)??s.message??ts(d.lang);v!==void 0&&(d.message=typeof v=="function"?v(d):v),p&&(t.typed=!1),t.issues?t.issues.push(d):t.issues=[d]}function ae(e){return{version:1,vendor:"valibot",validate(r){return e["~run"]({value:r},Be())}}}function ns(e,r){return Object.hasOwn(e,r)&&r!=="__proto__"&&r!=="prototype"&&r!=="constructor"}function is(e,r){const t=[...new Set(e)];return t.length>1?`(${t.join(` ${r} `)})`:t[0]??"never"}function as(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 os=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}},ls=/^[\w+-]+(?:\.[\w+-]+)*@[\da-z]+(?:[.-][\da-z]+)*\.[a-z]{2,}$/iu;function Zt(e,r){return{kind:"validation",type:"check",reference:Zt,async:!1,expects:null,requirement:e,message:r,"~run"(t,s){return t.typed&&!this.requirement(t.value)&&Z(this,"input",t,s),t}}}function Xt(e){return{kind:"validation",type:"email",reference:Xt,expects:null,async:!1,requirement:ls,message:e,"~run"(r,t){return r.typed&&!this.requirement.test(r.value)&&Z(this,"email",r,t),r}}}function Ae(e,r){return{kind:"validation",type:"max_length",reference:Ae,async:!1,expects:`<=${e}`,requirement:e,message:r,"~run"(t,s){return t.typed&&t.value.length>this.requirement&&Z(this,"length",t,s,{received:`${t.value.length}`}),t}}}function Yt(e,r){return{kind:"validation",type:"max_value",reference:Yt,async:!1,expects:`<=${e instanceof Date?e.toJSON():we(e)}`,requirement:e,message:r,"~run"(t,s){return t.typed&&!(t.value<=this.requirement)&&Z(this,"value",t,s,{received:t.value instanceof Date?t.value.toJSON():we(t.value)}),t}}}function xe(e,r){return{kind:"validation",type:"min_length",reference:xe,async:!1,expects:`>=${e}`,requirement:e,message:r,"~run"(t,s){return t.typed&&t.value.length<this.requirement&&Z(this,"length",t,s,{received:`${t.value.length}`}),t}}}function Qt(e,r){return{kind:"validation",type:"min_value",reference:Qt,async:!1,expects:`>=${e instanceof Date?e.toJSON():we(e)}`,requirement:e,message:r,"~run"(t,s){return t.typed&&!(t.value>=this.requirement)&&Z(this,"value",t,s,{received:t.value instanceof Date?t.value.toJSON():we(t.value)}),t}}}function Ye(e,r){return{kind:"validation",type:"regex",reference:Ye,async:!1,expects:`${e}`,requirement:e,message:r,"~run"(t,s){return t.typed&&!this.requirement.test(t.value)&&Z(this,"format",t,s),t}}}function Qe(e){return{kind:"transformation",type:"transform",reference:Qe,async:!1,operation:e,"~run"(r){return r.value=this.operation(r.value),r}}}function er(e){return{kind:"validation",type:"url",reference:er,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)&&Z(this,"URL",r,t),r}}}function us(e,r,t){return typeof e.fallback=="function"?e.fallback(r,t):e.fallback}function tr(e,r,t){return typeof e.default=="function"?e.default(r,t):e.default}function rr(e,r){return{kind:"schema",type:"array",reference:rr,expects:"Array",async:!1,item:e,message:r,get"~standard"(){return ae(this)},"~run"(t,s){var o;const a=t.value;if(Array.isArray(a)){t.typed=!0,t.value=[];for(let i=0;i<a.length;i++){const l=a[i],d=this.item["~run"]({value:l},s);if(d.issues){const p={type:"array",origin:"value",input:a,key:i,value:l};for(const v of d.issues)v.path?v.path.unshift(p):v.path=[p],(o=t.issues)==null||o.push(v);if(t.issues||(t.issues=d.issues),s.abortEarly){t.typed=!1;break}}d.typed||(t.typed=!1),t.value.push(d.value)}}else Z(this,"type",t,s);return t}}}function sr(e){return{kind:"schema",type:"boolean",reference:sr,expects:"boolean",async:!1,message:e,get"~standard"(){return ae(this)},"~run"(r,t){return typeof r.value=="boolean"?r.typed=!0:Z(this,"type",r,t),r}}}function nr(e){return{kind:"schema",type:"number",reference:nr,expects:"number",async:!1,message:e,get"~standard"(){return ae(this)},"~run"(r,t){return typeof r.value=="number"&&!isNaN(r.value)?r.typed=!0:Z(this,"type",r,t),r}}}function ce(e,r){return{kind:"schema",type:"object",reference:ce,expects:"Object",async:!1,entries:e,message:r,get"~standard"(){return ae(this)},"~run"(t,s){var o;const a=t.value;if(a&&typeof a=="object"){t.typed=!0,t.value={};for(const i in this.entries){const l=this.entries[i];if(i in a||(l.type==="exact_optional"||l.type==="optional"||l.type==="nullish")&&l.default!==void 0){const d=i in a?a[i]:tr(l),p=l["~run"]({value:d},s);if(p.issues){const v={type:"object",origin:"value",input:a,key:i,value:d};for(const x of p.issues)x.path?x.path.unshift(v):x.path=[v],(o=t.issues)==null||o.push(x);if(t.issues||(t.issues=p.issues),s.abortEarly){t.typed=!1;break}}p.typed||(t.typed=!1),t.value[i]=p.value}else if(l.fallback!==void 0)t.value[i]=us(l);else if(l.type!=="exact_optional"&&l.type!=="optional"&&l.type!=="nullish"&&(Z(this,"key",t,s,{input:void 0,expected:`"${i}"`,path:[{type:"object",origin:"key",input:a,key:i,value:a[i]}]}),s.abortEarly))break}}else Z(this,"type",t,s);return t}}}function Ee(e,r){return{kind:"schema",type:"optional",reference:Ee,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:r,get"~standard"(){return ae(this)},"~run"(t,s){return t.value===void 0&&(this.default!==void 0&&(t.value=tr(this,t,s)),t.value===void 0)?(t.typed=!0,t):this.wrapped["~run"](t,s)}}}function ir(e,r){return{kind:"schema",type:"picklist",reference:ir,expects:is(e.map(we),"|"),async:!1,options:e,message:r,get"~standard"(){return ae(this)},"~run"(t,s){return this.options.includes(t.value)?t.typed=!0:Z(this,"type",t,s),t}}}function ar(e,r,t){return{kind:"schema",type:"record",reference:ar,expects:"Object",async:!1,key:e,value:r,message:t,get"~standard"(){return ae(this)},"~run"(s,a){var i,l;const o=s.value;if(o&&typeof o=="object"){s.typed=!0,s.value={};for(const d in o)if(ns(o,d)){const p=o[d],v=this.key["~run"]({value:d},a);if(v.issues){const h={type:"object",origin:"key",input:o,key:d,value:p};for(const m of v.issues)m.path=[h],(i=s.issues)==null||i.push(m);if(s.issues||(s.issues=v.issues),a.abortEarly){s.typed=!1;break}}const x=this.value["~run"]({value:p},a);if(x.issues){const h={type:"object",origin:"value",input:o,key:d,value:p};for(const m of x.issues)m.path?m.path.unshift(h):m.path=[h],(l=s.issues)==null||l.push(m);if(s.issues||(s.issues=x.issues),a.abortEarly){s.typed=!1;break}}(!v.typed||!x.typed)&&(s.typed=!1),v.typed&&(s.value[v.value]=x.value)}}else Z(this,"type",s,a);return s}}}function te(e){return{kind:"schema",type:"string",reference:te,expects:"string",async:!1,message:e,get"~standard"(){return ae(this)},"~run"(r,t){return typeof r.value=="string"?r.typed=!0:Z(this,"type",r,t),r}}}function cs(e,r,t){const s=e["~run"]({value:r},Be(t));if(s.issues)throw new os(s.issues);return s.value}function ds(e,r){const t={};for(const s in e.entries)t[s]=!r||r.includes(s)?Ee(e.entries[s]):e.entries[s];return{...e,entries:t,get"~standard"(){return ae(this)}}}function he(...e){return{...e[0],pipe:e,get"~standard"(){return ae(this)},"~run"(r,t){for(const s of e)if(s.kind!=="metadata"){if(r.issues&&(s.kind==="schema"||s.kind==="transformation")){r.typed=!1;break}(!r.issues||!t.abortEarly&&!t.abortPipeEarly)&&(r=s["~run"](r,t))}return r}}}function fs(e,r,t){const s=e["~run"]({value:r},Be(t));return{typed:s.typed,success:!s.issues,output:s.value,issues:s.issues}}async function hs(e,r,t){const s=await e["~run"]({value:r},Be(t));return{typed:s.typed,success:!s.issues,output:s.value,issues:s.issues}}const _e=({error:e})=>!e||!e.message?null:n.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:[n.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:[n.o("circle",{cx:"8",cy:"8",r:"6.3",stroke:"currentColor","stroke-width":"1.4"}),n.o("rect",{x:"7",y:"4",width:"2",height:"5",fill:"currentColor"}),n.o("rect",{x:"7",y:"10",width:"2",height:"2",fill:"currentColor"})]}),n.o("p",{class:"break-words pr-1 text-sm",children:e.message})]}),ge=({class:e,...r})=>{const{t}=n.useTranslation();return n.o("button",{type:"button",class:n.clsx("fr touch-hitbox text-neutral-10 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:[n.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:[n.o("title",{children:t("skip")}),n.o("path",{d:"M3.25 11.25A5 5 0 0 1 12 7"}),n.o("path",{d:"M13.25 4.5V8.25H9.5"})]}),t("skip")]})};var et={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"};const Te=n.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}}),ps="https://api.mapbox.com/search/searchbox/v1/suggest",ys="ZzRDWFU0dTZ3SF9aWk9RNGl6QzZaWS5RZmlFak13a0hPbGxXZXlNSGN5RUhObUJ6TXpSV08yUW5OdE5tSTZJU1lpd2lJb1JYYXRObmJ2Tm5iaGhHZWx4V1lpb2pJMUp5ZS5rcA==",ms=e=>atob(e).split("").reverse().join(""),le=ce({name:te()}),gs=ce({suggestions:rr(ce({full_address:Ee(te()),place_formatted:Ee(te()),name:Ee(te()),mapbox_id:te(),context:ds(ce({address:le,street:le,neighborhood:le,locality:le,district:le,place:le,region:le,postcode:le,country:le}))}))}),bs=({logger:e,t:r})=>n.F(()=>{var s;const t=(s=n.store.current$.peek().flow)==null?void 0:s.data.flowSessionId;return t?{enabled:!0,getPredictions:async a=>{var x;const o=new URL(ps);o.searchParams.set("q",a),o.searchParams.set("session_token",t);const i=(x=n.store.current$.peek().flow)==null?void 0:x.locationOrigin;i&&i.lat!==void 0&&i.lng!==void 0&&i.lat>=-90&&i.lat<=90&&i.lng>=-180&&i.lng<=180&&o.searchParams.set("proximity",`${i.lng},${i.lat}`),o.searchParams.set("access_token",ms(ys));const d=await fetch(o);if(!d.ok)return e.error("Failed to get address details",d),{ok:!1,error:r("address_error")};const p=fs(gs,await d.json());if(p.success===!1)return e.error("Failed to parse address details",p.issues),{ok:!1,error:r("address_error")};const{suggestions:v}=p.output;return{ok:!0,data:v.map(h=>{var m,k,V,I,N,y,C,E,A;return{label:h.full_address??h.place_formatted??h.name??h.mapbox_id,id:h.mapbox_id,address:{line1:((m=h.context.address)==null?void 0:m.name)??((k=h.context.street)==null?void 0:k.name),line2:void 0,line3:((V=h.context.neighborhood)==null?void 0:V.name)??((I=h.context.locality)==null?void 0:I.name),city:((N=h.context.place)==null?void 0:N.name)??((y=h.context.district)==null?void 0:y.name),state:(C=h.context.region)==null?void 0:C.name,postcode:(E=h.context.postcode)==null?void 0:E.name,country:(A=h.context.country)==null?void 0:A.name}}})}}}:{enabled:!1}},[e,r]),wt=e=>{const{t:r}=n.useTranslation();return n.o("button",{type:"button",class:"touch-hitbox text-neutral-10 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:[n.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:n.o("path",{d:"M10 3L5 8L10 13"})}),n.o("span",{children:r("back")})]})},vs=({input:e,onSubmitSuccess:r,logger:t})=>{const{t:s}=n.useTranslation(),[a,o]=n.h(),{enabled:i,getPredictions:l}=bs({logger:t,t:s}),[d,p]=n.h(i?"query":"manual"),[v,x]=n.h(""),[h,m]=n.h(),k=n._(),V=n._(),I=y=>{var E;if(n.invariant(i,"Query state should not be enabled"),y=y.trim(),y===((E=k.current)==null?void 0:E.query)||y===(h==null?void 0:h.query)&&h.status==="done")return;if(x(y),y===""){k.current=void 0,m(void 0);return}const C=k.current={query:y};m({query:y,status:"pending"}),l(y).then(A=>{k.current===C&&(k.current=void 0,m(A.ok?{query:y,status:"done",items:A.data}:{query:y,status:"failed",error:A.error}))},A=>{k.current===C&&(k.current=void 0,t.error("Failed to get address details",A),m({query:y,status:"failed",error:s("address_error")}))})},N=(y,C)=>{o(E=>({...E,[y]:C}))};switch(d){case"query":return n.invariant(i,"Query state should not be enabled"),n.o(xs,{input:e,onSkip:()=>r(null),onAddressSelect:y=>{if(y===""){k.current&&(k.current=void 0,m(void 0)),p("manual");return}const C=(h==null?void 0:h.status)==="done"?h.items.find(E=>E.id===y):void 0;C&&(V.current!==y&&o(C.address),V.current=y,p("details"))},onAddressSearch:I,lookup:h,query:v});case"details":return n.invariant(a!==void 0),n.o(kt,{input:e,logger:t,onSubmitSuccess:r,addressFields:a,onFieldChange:N,actions:n.o(wt,{onClick:()=>{p("query")}})});case"manual":return n.o(kt,{logger:t,input:e,onSubmitSuccess:r,addressFields:a??{},onFieldChange:N,actions:i?n.o(wt,{onClick:()=>{p("query")}}):void 0})}},xs=({input:e,onSkip:r,lookup:t,onAddressSelect:s,query:a,onAddressSearch:o})=>{const{t:i}=n.useTranslation(),l=n._(null);return n.y(()=>{l.current&&(l.current.focus(),l.current.select())},[]),n.o(n.k$1,{children:[n.o("form",{noValidate:!0,onSubmit:d=>{d.preventDefault();const v=new FormData(d.currentTarget).get("address");typeof v=="string"&&o(v)},class:"flex gap-2 p-2.5",children:[n.o("div",{class:"group relative flex-1",children:[n.o("input",{ref:l,name:"address",id:"chat-address",autocomplete:"address-line1 country-name postal-code",autoFocus:!0,placeholder:e.config.placeholder||i("address_search"),defaultValue:a,class:Te({optional:!!e.config.optional,className:"w-full rounded-full"})}),n.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:[n.o("svg",{"aria-hidden":"true",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:n.o("g",{id:"inploi",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round",strokeWidth:"1.5",children:[n.o("circle",{cx:"7",cy:"7",r:"4"}),n.o("path",{d:"M10 10L13 13"})]})}),n.o("span",{class:"sr-only",children:i("search")})]})]}),e.config.optional&&n.o(ge,{class:"relative",onClick:r})]}),(t==null?void 0:t.status)==="failed"?n.o(_e,{error:{message:t.error}}):null,n.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-10 flex items-center gap-2 px-4 py-2 text-sm":"sr-only",children:(t==null?void 0:t.status)==="pending"?n.o(n.k$1,{children:[n.o(n.LoadingIndicator,{"aria-hidden":"true",class:"h-4 w-4 shrink-0"}),i("address_searching")]}):(t==null?void 0:t.status)==="done"&&t.items.length===0?i("address_no_results"):null}),n.o("ul",{children:[((t==null?void 0:t.status)==="done"?t.items:[]).map(d=>n.o("li",{children:n.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:()=>{s(d.id)},children:[n.o("span",{class:"flex-grow",children:d.label}),n.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:n.o("path",{d:"M6 3L11 8L6 13"})})]})},d.id)),n.o("li",{children:n.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:()=>{s("")},children:n.o("span",{class:"flex-grow",children:i("address_manual")})})},"")]})]})},_t=["line1","line2","line3","city","state","postcode","country"],kt=({addressFields:e,onFieldChange:r,onSubmitSuccess:t,actions:s,input:a})=>{const o=n._(null);n.y(()=>{if(o.current){const d=o.current.querySelector("input");d&&(d.focus(),d.select())}},[]);const i=Object.keys(et),{t:l}=n.useTranslation();return n.o("form",{class:"flex flex-col px-2 pt-2",onSubmit:d=>{const p=new FormData(d.currentTarget),v=Object.fromEntries(p.entries());t({type:"address",value:v})},children:[n.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:o,children:_t.map((d,p)=>{const v=`isdk_${d}`,x=a.config.keys[d];return x?n.o(n.k$1,{children:[n.o("label",{for:v,class:"text-neutral-9 [&:has(+*>input:focus)]:text-neutral-11 w-24 pb-2 text-xs uppercase leading-3 tracking-widest transition-colors",children:l(d)}),n.o("div",{class:"flex flex-col items-stretch gap-1.5",children:[d==="country"?n.o("div",{class:"relative",children:[n.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:x,id:v,defaultValue:e[d],onChange:h=>r(d,h.currentTarget.value),required:!0,children:[e.country&&!i.includes(e.country)?n.o("option",{value:e[d],children:e[d]}):n.o("option",{value:"",children:l("select_country")}),i.map(h=>n.o("option",{value:h,children:h},h))]}),n.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:n.o("path",{d:"M4 6.5L8 10.5L12 6.5"})})]}):n.o("input",{autoFocus:p===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:x,id:v,defaultValue:e[d],onInput:h=>r(d,h.currentTarget.value),required:!0}),p===_t.length-1?n.o("hr",{class:"m-0 w-full border-b border-b-transparent"}):n.o("hr",{class:"border-b-neutral-5 m-0 w-full border-b border-solid"})]})]}):null})}),n.o("div",{class:"bg-neutral-1 sticky bottom-0 flex items-center py-2",children:[s,n.o(me,{class:"ml-auto"})]})]})},tt=()=>{const e=n._(null);return n.p(()=>{var r;(r=e.current)==null||r.focus()},[]),e},or=["true","false"],ws=ir(or),_s="answer",lr="flex items-center flex-wrap gap-2 p-2.5",ur="min-w-0 max-w-full flex-auto",cr=n.k$2(({label:e,...r},t)=>n.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:n.o("p",{class:"text-center text-base",children:e})})),ks=({input:e,onSubmitSuccess:r})=>{const t=tt();return n.o("form",{noValidate:!0,class:"",onSubmit:s=>{s.preventDefault();const a=n.getFormSubmitter(s).value,o=cs(ws,a);r({type:"boolean",value:o==="true"})},children:[n.o("ul",{class:lr,children:or.map((s,a)=>n.o("li",{class:ur,children:n.o(cr,{ref:a===0?t:null,type:"submit",name:_s,value:s,label:e.config.labels[s]},s)}))}),e.config.optional&&n.o("div",{class:"px-2 pb-2",children:n.o(ge,{class:"relative w-full",type:"button",onClick:()=>r(null)})})]})},Cs=e=>new Promise((r,t)=>{const s=new FileReader;s.onload=()=>{if(typeof s.result!="string"||!s.result)return t(new Error("Invalid file"));r(s.result)},s.onerror=t,s.readAsDataURL(e)}),Ct=e=>e.reduce((r,t)=>r+t.sizeKb,0),Ss=n.isSubmissionOfType("file"),St=3,rt=e=>{const r=e.lastIndexOf(".");return r===-1?[e,""]:[e.slice(0,r),e.slice(r)]},Is=({file:e,class:r,...t})=>{const[s,a]=rt(e.name);return n.o("div",{class:n.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:[n.o("p",{"aria-label":"File name",class:"text-accent-12 flex flex-grow overflow-hidden",children:[n.o("span",{class:"block truncate",children:s}),n.o("span",{children:a})]}),n.o("p",{"aria-label":"File size",class:"text-accent-11",children:n.V(e.sizeKb)})]})},It=({class:e,...r})=>n.o("li",{class:n.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}),Vs=(e,r)=>{const[t,s]=rt(e);return`${t.slice(0,r)}${s}`},Vt=e=>({name:Vs(e.name,42),sizeKb:e.size/1e3}),Fs=({input:e,onSubmitSuccess:r})=>{var k;const t=(k=n.store.current$.value.flow)==null?void 0:k.data.submissions[e.key],[s,a]=n.h(Ss(t)&&t.value.length?{status:"ready",files:t.value}:{status:"empty"}),o=n._(0),i=s.status==="ready"?s.files:[],l=s.status==="ready"||s.status==="pending"?s.files:[],d=s.status==="error"?s.error:void 0,p=l.length-St,v=Ct(l),x=tt(),{t:h}=n.useTranslation(),m=V=>{if(!V.length)return{type:"required",message:h("validation_file")};if(!n.U(V,e.config.extensions))return{type:"validate",message:h("validation_file_ext",{ext:e.config.extensions.join(", ")})};if(e.config.fileSizeLimitKib&&Ct(V)>e.config.fileSizeLimitKib)return{type:"max",message:h("validation_file_size",{size:n.V(e.config.fileSizeLimitKib)})};if(!e.config.allowMultiple&&V.length>1)return{type:"invalid",message:h("validation_file_max",{count:1})}};return n.o("form",{class:"flex flex-col gap-1 p-2.5",onSubmit:V=>{if(V.preventDefault(),s.status==="pending"||s.status==="error")return;const I=m(i);I?a({status:"error",error:I}):r({type:"file",value:i})},children:[n.o("div",{class:"flex items-center gap-2",children:[n.o("label",{ref:x,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:[l.length>0?n.o("ul",{class:"flex max-w-full flex-wrap justify-center gap-1 overflow-hidden p-1",children:[l.slice(0,St).map(V=>{const[I,N]=rt(V.name);return n.o(It,{class:"flex overflow-hidden",children:[n.o("span",{class:"block truncate",children:I}),n.o("span",{children:N})]})}),p>0?n.o(It,{children:["+",p," file",p!==1?"s":""]}):null]}):n.o("div",{class:"flex flex-col justify-center gap-4 pb-6 pt-5",children:[n.o("header",{class:"flex flex-col items-center gap-0",children:[n.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:n.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"})}),n.o("p",{class:"text-neutral-12 tracking-[-0.01em]",children:h("upload_file",{count:e.config.allowMultiple?2:1})}),e.config.fileSizeLimitKib?n.o("p",{class:"text-neutral-10 text-xs",children:["(",h("file_max_size",{size:n.V(e.config.fileSizeLimitKib)}),")"]}):null]}),n.o("aside",{class:"flex flex-col items-center gap-2",children:[n.o("p",{id:"accepted-filetypes",class:"sr-only",children:h("file_extensions")}),n.o("ul",{"aria-describedby":"accepted-filetypes",class:"flex flex-wrap justify-center gap-2",children:e.config.extensions.map(V=>n.o("li",{class:"ring-lowest outline-neutral-6 text-neutral-9 bg-neutral-1 rounded-md px-1 py-0.5 text-[11px] uppercase tracking-wide outline outline-1 ring-2",children:V.replace(".","")}))})]})]}),n.o("p",{role:"status",class:n.clsx("text-neutral-11 flex items-center gap-1.5 text-xs",l.length===0&&"sr-only"),children:s.status==="pending"?n.o(n.k$1,{children:[n.o(n.LoadingIndicator,{"aria-hidden":"true",class:"h-4 w-4"}),h("file_preparing",{count:l.length})]}):s.status==="ready"?n.o(n.k$1,{children:[n.V(v)," ",i.length>1?"total":"",n.o("span",{class:"sr-only",children:[". ",h("file_ready",{count:i.length})]})]}):null}),n.o("input",{id:"dropzone-file",onInput:async V=>{n.invariant(V.target instanceof HTMLInputElement);const I=V.target.files?Array.from(V.target.files):[];if(V.target.value="",!I.length)return;const N=++o.current,y=s.status==="ready",C=I.map(Vt),E=m(C);if(E)return a({status:"error",error:E});a({status:"pending",files:C});try{const A=await Promise.all(I.map(async R=>({...Vt(R),data:await Cs(R)})));o.current===N&&a({status:"ready",files:A})}catch{o.current===N&&a({status:"error",error:{type:"invalid",message:h(y?"file_read_error_replacement":"file_read_error")}})}},multiple:e.config.allowMultiple,type:"file",class:"sr-only"})]}),n.o("div",{class:"flex h-full flex-col items-center gap-2",children:[n.o(me,{disabled:i.length===0}),e.config.optional&&n.o(ge,{class:"relative",onClick:()=>r(null)})]})]}),n.o(_e,{error:d})]})};var Le=e=>e.type==="checkbox",ye=e=>e instanceof Date,Q=e=>e==null;const dr=e=>typeof e=="object";var W=e=>!Q(e)&&!Array.isArray(e)&&dr(e)&&!ye(e),As=e=>W(e)&&e.target?Le(e.target)?e.target.checked:e.target.value:e,Es=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,Ms=(e,r)=>e.has(Es(r)),Ns=e=>{const r=e.constructor&&e.constructor.prototype;return W(r)&&r.hasOwnProperty("isPrototypeOf")},st=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function K(e){if(e instanceof Date)return new Date(e);const r=typeof FileList<"u"&&e instanceof FileList;if(st&&(e instanceof Blob||r))return e;const t=Array.isArray(e);if(!t&&!(W(e)&&Ns(e)))return e;const s=t?[]:Object.create(Object.getPrototypeOf(e));for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(s[a]=K(e[a]));return s}var Re=e=>/^\w*$/.test(e),j=e=>e===void 0,nt=e=>Array.isArray(e)?e.filter(Boolean):[],it=e=>nt(e.replace(/["|']|\]/g,"").split(/\.|\[/)),_=(e,r,t)=>{if(!r||!W(e))return t;const s=(Re(r)?[r]:it(r)).reduce((a,o)=>Q(a)?a:a[o],e);return j(s)||s===e?j(e[r])?t:e[r]:s},ne=e=>typeof e=="boolean",re=e=>typeof e=="function",P=(e,r,t)=>{let s=-1;const a=Re(r)?[r]:it(r),o=a.length,i=o-1;for(;++s<o;){const l=a[s];let d=t;if(s!==i){const p=e[l];d=W(p)||Array.isArray(p)?p:isNaN(+a[s+1])?{}:[]}if(l==="__proto__"||l==="constructor"||l==="prototype")return;e[l]=d,e=e[l]}};const Ft={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},se={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},ue={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Ts=n.Cn.createContext(null);Ts.displayName="HookFormControlContext";var Ls=(e,r,t,s=!0)=>{const a={defaultValues:r._defaultValues};for(const o in e)Object.defineProperty(a,o,{get:()=>{const i=o;return r._proxyFormState[i]!==se.all&&(r._proxyFormState[i]=!s||se.all),t&&(t[i]=!0),e[i]}});return a};const Ds=typeof window<"u"?n.Cn.useLayoutEffect:n.Cn.useEffect;var ee=e=>typeof e=="string",Os=(e,r,t,s,a)=>ee(e)?(s&&r.watch.add(e),_(t,e,a)):Array.isArray(e)?e.map(o=>(s&&r.watch.add(o),_(t,o))):(s&&(r.watchAll=!0),t),Ze=e=>Q(e)||!dr(e);function fe(e,r,t=new WeakSet){if(Ze(e)||Ze(r))return Object.is(e,r);if(ye(e)&&ye(r))return Object.is(e.getTime(),r.getTime());const s=Object.keys(e),a=Object.keys(r);if(s.length!==a.length)return!1;if(t.has(e)||t.has(r))return!0;t.add(e),t.add(r);for(const o of s){const i=e[o];if(!a.includes(o))return!1;if(o!=="ref"){const l=r[o];if(ye(i)&&ye(l)||W(i)&&W(l)||Array.isArray(i)&&Array.isArray(l)?!fe(i,l,t):!Object.is(i,l))return!1}}return!0}const Bs=n.Cn.createContext(null);Bs.displayName="HookFormContext";var fr=(e,r,t,s,a)=>r?{...t[e],types:{...t[e]&&t[e].types?t[e].types:{},[s]:a||!0}}:{},Me=e=>Array.isArray(e)?e:[e],At=()=>{let e=[];return{get observers(){return e},next:a=>{for(const o of e)o.next&&o.next(a)},subscribe:a=>(e.push(a),{unsubscribe:()=>{e=e.filter(o=>o!==a)}}),unsubscribe:()=>{e=[]}}};function hr(e,r){const t={};for(const s in e)if(e.hasOwnProperty(s)){const a=e[s],o=r[s];if(a&&W(a)&&o){const i=hr(a,o);W(i)&&(t[s]=i)}else e[s]&&(t[s]=o)}return t}var Y=e=>W(e)&&!Object.keys(e).length,at=e=>e.type==="file",De=e=>{if(!st)return!1;const r=e?e.ownerDocument:0;return e instanceof(r&&r.defaultView?r.defaultView.HTMLElement:HTMLElement)},pr=e=>e.type==="select-multiple",ot=e=>e.type==="radio",Rs=e=>ot(e)||Le(e),Je=e=>De(e)&&e.isConnected;function Ps(e,r){const t=r.slice(0,-1).length;let s=0;for(;s<t;)e=j(e)?s++:e[r[s++]];return e}function $s(e){for(const r in e)if(e.hasOwnProperty(r)&&!j(e[r]))return!1;return!0}function z(e,r){const t=Array.isArray(r)?r:Re(r)?[r]:it(r),s=t.length===1?e:Ps(e,t),a=t.length-1,o=t[a];return s&&delete s[o],a!==0&&(W(s)&&Y(s)||Array.isArray(s)&&$s(s))&&z(e,t.slice(0,-1)),e}var js=e=>{for(const r in e)if(re(e[r]))return!0;return!1};function yr(e){return Array.isArray(e)||W(e)&&!js(e)}function Xe(e,r={}){for(const t in e){const s=e[t];yr(s)?(r[t]=Array.isArray(s)?[]:{},Xe(s,r[t])):j(s)||(r[t]=!0)}return r}function ve(e,r,t){t||(t=Xe(r));for(const s in e){const a=e[s];if(yr(a))j(r)||Ze(t[s])?t[s]=Xe(a,Array.isArray(a)?[]:{}):ve(a,Q(r)?{}:r[s],t[s]);else{const o=r[s];t[s]=!fe(a,o)}}return t}const Et={value:!1,isValid:!1},Mt={value:!0,isValid:!0};var mr=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&&!j(e[0].attributes.value)?j(e[0].value)||e[0].value===""?Mt:{value:e[0].value,isValid:!0}:Mt:Et}return Et},gr=(e,{valueAsNumber:r,valueAsDate:t,setValueAs:s})=>j(e)?e:r?e===""?NaN:e&&+e:t&&ee(e)?new Date(e):s?s(e):e;const Nt={isValid:!1,value:null};var br=e=>Array.isArray(e)?e.reduce((r,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:r,Nt):Nt;function Tt(e){const r=e.ref;return at(r)?r.files:ot(r)?br(e.refs).value:pr(r)?[...r.selectedOptions].map(({value:t})=>t):Le(r)?mr(e.refs).value:gr(j(r.value)?e.ref.value:r.value,e)}var qs=(e,r,t,s)=>{const a={};for(const o of e){const i=_(r,o);i&&P(a,o,i._f)}return{criteriaMode:t,names:[...e],fields:a,shouldUseNativeValidation:s}},Oe=e=>e instanceof RegExp,Ie=e=>j(e)?e:Oe(e)?e.source:W(e)?Oe(e.value)?e.value.source:e.value:e,Lt=e=>({isOnSubmit:!e||e===se.onSubmit,isOnBlur:e===se.onBlur,isOnChange:e===se.onChange,isOnAll:e===se.all,isOnTouch:e===se.onTouched});const Dt="AsyncFunction";var Us=e=>!!e&&!!e.validate&&!!(re(e.validate)&&e.validate.constructor.name===Dt||W(e.validate)&&Object.values(e.validate).find(r=>r.constructor.name===Dt)),zs=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),Ot=(e,r,t)=>!t&&(r.watchAll||r.watch.has(e)||[...r.watch].some(s=>e.startsWith(s)&&/^\.\w+/.test(e.slice(s.length))));const Ne=(e,r,t,s)=>{for(const a of t||Object.keys(e)){const o=_(e,a);if(o){const{_f:i,...l}=o;if(i){if(i.refs&&i.refs[0]&&r(i.refs[0],a)&&!s)return!0;if(i.ref&&r(i.ref,i.name)&&!s)return!0;if(Ne(l,r))break}else if(W(l)&&Ne(l,r))break}}};function Bt(e,r,t){const s=_(e,t);if(s||Re(t))return{error:s,name:t};const a=t.split(".");for(;a.length;){const o=a.join("."),i=_(r,o),l=_(e,o);if(i&&!Array.isArray(i)&&t!==o)return{name:t};if(l&&l.type)return{name:o,error:l};if(l&&l.root&&l.root.type)return{name:`${o}.root`,error:l.root};a.pop()}return{name:t}}var Ws=(e,r,t,s)=>{t(e);const{name:a,...o}=e;return Y(o)||Object.keys(o).length>=Object.keys(r).length||Object.keys(o).find(i=>r[i]===(!s||se.all))},Ks=(e,r,t)=>!e||!r||e===r||Me(e).some(s=>s&&(t?s===r:s.startsWith(r)||r.startsWith(s))),Gs=(e,r,t,s,a)=>a.isOnAll?!1:!t&&a.isOnTouch?!(r||e):(t?s.isOnBlur:a.isOnBlur)?!e:(t?s.isOnChange:a.isOnChange)?e:!0,Hs=(e,r)=>!nt(_(e,r)).length&&z(e,r),Js=(e,r,t)=>{const s=Me(_(e,t));return P(s,"root",r[t]),P(e,t,s),e};function Rt(e,r,t="validate"){if(ee(e)||Array.isArray(e)&&e.every(ee)||ne(e)&&!e)return{type:t,message:ee(e)?e:"",ref:r}}var be=e=>W(e)&&!Oe(e)?e:{value:e,message:""},Pt=async(e,r,t,s,a,o)=>{const{ref:i,refs:l,required:d,maxLength:p,minLength:v,min:x,max:h,pattern:m,validate:k,name:V,valueAsNumber:I,mount:N}=e._f,y=_(t,V);if(!N||r.has(V))return{};const C=l?l[0]:i,E=M=>{a&&C.reportValidity&&(C.setCustomValidity(ne(M)?"":M||""),C.reportValidity())},A={},R=ot(i),H=Le(i),L=R||H,$=(I||at(i))&&j(i.value)&&j(y)||De(i)&&i.value===""||y===""||Array.isArray(y)&&!y.length,F=fr.bind(null,V,s,A),G=(M,D,T,q=ue.maxLength,J=ue.minLength)=>{const U=M?D:T;A[V]={type:M?q:J,message:U,ref:i,...F(M?q:J,U)}};if(o?!Array.isArray(y)||!y.length:d&&(!L&&($||Q(y))||ne(y)&&!y||H&&!mr(l).isValid||R&&!br(l).isValid)){const{value:M,message:D}=ee(d)?{value:!!d,message:d}:be(d);if(M&&(A[V]={type:ue.required,message:D,ref:C,...F(ue.required,D)},!s))return E(D),A}if(!$&&(!Q(x)||!Q(h))){let M,D;const T=be(h),q=be(x);if(!Q(y)&&!isNaN(y)){const J=i.valueAsNumber||y&&+y;Q(T.value)||(M=J>T.value),Q(q.value)||(D=J<q.value)}else{const J=i.valueAsDate||new Date(y),U=Se=>new Date(new Date().toDateString()+" "+Se),ke=i.type=="time",Ce=i.type=="week";ee(T.value)&&y&&(M=ke?U(y)>U(T.value):Ce?y>T.value:J>new Date(T.value)),ee(q.value)&&y&&(D=ke?U(y)<U(q.value):Ce?y<q.value:J<new Date(q.value))}if((M||D)&&(G(!!M,T.message,q.message,ue.max,ue.min),!s))return E(A[V].message),A}if((p||v)&&!$&&(ee(y)||o&&Array.isArray(y))){const M=be(p),D=be(v),T=!Q(M.value)&&y.length>+M.value,q=!Q(D.value)&&y.length<+D.value;if((T||q)&&(G(T,M.message,D.message),!s))return E(A[V].message),A}if(m&&!$&&ee(y)){const{value:M,message:D}=be(m);if(Oe(M)&&!y.match(M)&&(A[V]={type:ue.pattern,message:D,ref:i,...F(ue.pattern,D)},!s))return E(D),A}if(k){if(re(k)){const M=await k(y,t),D=Rt(M,C);if(D&&(A[V]={...D,...F(ue.validate,D.message)},!s))return E(D.message),A}else if(W(k)){let M={};for(const D in k){if(!Y(M)&&!s)break;const T=Rt(await k[D](y,t),C,D);T&&(M={...T,...F(D,T.message)},E(T.message),s&&(A[V]=M))}if(!Y(M)&&(A[V]={ref:C,...M},!s))return A}}return E(!0),A};const Zs={mode:se.onSubmit,reValidateMode:se.onChange,shouldFocusError:!0};function Xs(e={}){let r={...Zs,...e},t={submitCount:0,isDirty:!1,isReady:!1,isLoading:re(r.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:r.errors||{},disabled:r.disabled||!1},s={},a=W(r.defaultValues)||W(r.values)?K(r.defaultValues||r.values)||{}:{},o=r.shouldUnregister?{}:K(a),i={action:!1,mount:!1,watch:!1,keepIsValid:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},d,p=0;const v={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},x={...v};let h={...x};const m={array:At(),state:At()},k=r.criteriaMode===se.all,V=u=>c=>{clearTimeout(p),p=setTimeout(u,c)},I=async u=>{if(!i.keepIsValid&&!r.disabled&&(x.isValid||h.isValid||u)){let c;r.resolver?(c=Y((await L()).errors),N()):c=await F(s,!0),c!==t.isValid&&m.state.next({isValid:c})}},N=(u,c)=>{!r.disabled&&(x.isValidating||x.validatingFields||h.isValidating||h.validatingFields)&&((u||Array.from(l.mount)).forEach(f=>{f&&(c?P(t.validatingFields,f,c):z(t.validatingFields,f))}),m.state.next({validatingFields:t.validatingFields,isValidating:!Y(t.validatingFields)}))},y=(u,c=[],f,w,b=!0,g=!0)=>{if(w&&f&&!r.disabled){if(i.action=!0,g&&Array.isArray(_(s,u))){const S=f(_(s,u),w.argA,w.argB);b&&P(s,u,S)}if(g&&Array.isArray(_(t.errors,u))){const S=f(_(t.errors,u),w.argA,w.argB);b&&P(t.errors,u,S),Hs(t.errors,u)}if((x.touchedFields||h.touchedFields)&&g&&Array.isArray(_(t.touchedFields,u))){const S=f(_(t.touchedFields,u),w.argA,w.argB);b&&P(t.touchedFields,u,S)}(x.dirtyFields||h.dirtyFields)&&(t.dirtyFields=ve(a,o)),m.state.next({name:u,isDirty:M(u,c),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else P(o,u,c)},C=(u,c)=>{P(t.errors,u,c),m.state.next({errors:t.errors})},E=u=>{t.errors=u,m.state.next({errors:t.errors,isValid:!1})},A=(u,c,f,w)=>{const b=_(s,u);if(b){const g=_(o,u,j(f)?_(a,u):f);j(g)||w&&w.defaultChecked||c?P(o,u,c?g:Tt(b._f)):q(u,g),i.mount&&!i.action&&I()}},R=(u,c,f,w,b)=>{let g=!1,S=!1;const O={name:u};if(!r.disabled){if(!f||w){(x.isDirty||h.isDirty)&&(S=t.isDirty,t.isDirty=O.isDirty=M(),g=S!==O.isDirty);const B=fe(_(a,u),c);S=!!_(t.dirtyFields,u),B?z(t.dirtyFields,u):P(t.dirtyFields,u,!0),O.dirtyFields=t.dirtyFields,g=g||(x.dirtyFields||h.dirtyFields)&&S!==!B}if(f){const B=_(t.touchedFields,u);B||(P(t.touchedFields,u,f),O.touchedFields=t.touchedFields,g=g||(x.touchedFields||h.touchedFields)&&B!==f)}g&&b&&m.state.next(O)}return g?O:{}},H=(u,c,f,w)=>{const b=_(t.errors,u),g=(x.isValid||h.isValid)&&ne(c)&&t.isValid!==c;if(r.delayError&&f?(d=V(()=>C(u,f)),d(r.delayError)):(clearTimeout(p),d=null,f?P(t.errors,u,f):z(t.errors,u)),(f?!fe(b,f):b)||!Y(w)||g){const S={...w,...g&&ne(c)?{isValid:c}:{},errors:t.errors,name:u};t={...t,...S},m.state.next(S)}},L=async u=>(N(u,!0),await r.resolver(o,r.context,qs(u||l.mount,s,r.criteriaMode,r.shouldUseNativeValidation))),$=async u=>{const{errors:c}=await L(u);if(N(u),u)for(const f of u){const w=_(c,f);w?P(t.errors,f,w):z(t.errors,f)}else t.errors=c;return c},F=async(u,c,f={valid:!0})=>{for(const w in u){const b=u[w];if(b){const{_f:g,...S}=b;if(g){const O=l.array.has(g.name),B=b._f&&Us(b._f);B&&x.validatingFields&&N([g.name],!0);const X=await Pt(b,l.disabled,o,k,r.shouldUseNativeValidation&&!c,O);if(B&&x.validatingFields&&N([g.name]),X[g.name]&&(f.valid=!1,c||e.shouldUseNativeValidation))break;!c&&(_(X,g.name)?O?Js(t.errors,X,g.name):P(t.errors,g.name,X[g.name]):z(t.errors,g.name))}!Y(S)&&await F(S,c,f)}}return f.valid},G=()=>{for(const u of l.unMount){const c=_(s,u);c&&(c._f.refs?c._f.refs.every(f=>!Je(f)):!Je(c._f.ref))&&je(u)}l.unMount=new Set},M=(u,c)=>!r.disabled&&(u&&c&&P(o,u,c),!fe(lt(),a)),D=(u,c,f)=>Os(u,l,{...i.mount?o:j(c)?a:ee(u)?{[u]:c}:c},f,c),T=u=>nt(_(i.mount?o:a,u,r.shouldUnregister?_(a,u,[]):[])),q=(u,c,f={})=>{const w=_(s,u);let b=c;if(w){const g=w._f;g&&(!g.disabled&&P(o,u,gr(c,g)),b=De(g.ref)&&Q(c)?"":c,pr(g.ref)?[...g.ref.options].forEach(S=>S.selected=b.includes(S.value)):g.refs?Le(g.ref)?g.refs.forEach(S=>{(!S.defaultChecked||!S.disabled)&&(Array.isArray(b)?S.checked=!!b.find(O=>O===S.value):S.checked=b===S.value||!!b)}):g.refs.forEach(S=>S.checked=S.value===b):at(g.ref)?g.ref.value="":(g.ref.value=b,g.ref.type||m.state.next({name:u,values:K(o)})))}(f.shouldDirty||f.shouldTouch)&&R(u,b,f.shouldTouch,f.shouldDirty,!0),f.shouldValidate&&Se(u)},J=(u,c,f)=>{for(const w in c){if(!c.hasOwnProperty(w))return;const b=c[w],g=u+"."+w,S=_(s,g);(l.array.has(u)||W(b)||S&&!S._f)&&!ye(b)?J(g,b,f):q(g,b,f)}},U=(u,c,f={})=>{const w=_(s,u),b=l.array.has(u),g=K(c);P(o,u,g),b?(m.array.next({name:u,values:K(o)}),(x.isDirty||x.dirtyFields||h.isDirty||h.dirtyFields)&&f.shouldDirty&&m.state.next({name:u,dirtyFields:ve(a,o),isDirty:M(u,g)})):w&&!w._f&&!Q(g)?J(u,g,f):q(u,g,f),Ot(u,l)?m.state.next({...t,name:u,values:K(o)}):m.state.next({name:i.mount?u:void 0,values:K(o)})},ke=async u=>{i.mount=!0;const c=u.target;let f=c.name,w=!0;const b=_(s,f),g=B=>{w=Number.isNaN(B)||ye(B)&&isNaN(B.getTime())||fe(B,_(o,f,B))},S=Lt(r.mode),O=Lt(r.reValidateMode);if(b){let B,X;const pe=c.type?Tt(b._f):As(u),de=u.type===Ft.BLUR||u.type===Ft.FOCUS_OUT,Vr=!zs(b._f)&&!r.resolver&&!_(t.errors,f)&&!b._f.deps||Gs(de,_(t.touchedFields,f),t.isSubmitted,O,S),ze=Ot(f,l,de);P(o,f,pe),de?(!c||!c.readOnly)&&(b._f.onBlur&&b._f.onBlur(u),d&&d(0)):b._f.onChange&&b._f.onChange(u);const We=R(f,pe,de),Fr=!Y(We)||ze;if(!de&&m.state.next({name:f,type:u.type,values:K(o)}),Vr)return(x.isValid||h.isValid)&&(r.mode==="onBlur"?de&&I():de||I()),Fr&&m.state.next({name:f,...ze?{}:We});if(!de&&ze&&m.state.next({...t}),r.resolver){const{errors:gt}=await L([f]);if(N([f]),g(pe),w){const Ar=Bt(t.errors,s,f),bt=Bt(gt,s,Ar.name||f);B=bt.error,f=bt.name,X=Y(gt)}}else N([f],!0),B=(await Pt(b,l.disabled,o,k,r.shouldUseNativeValidation))[f],N([f]),g(pe),w&&(B?X=!1:(x.isValid||h.isValid)&&(X=await F(s,!0)));w&&(b._f.deps&&(!Array.isArray(b._f.deps)||b._f.deps.length>0)&&Se(b._f.deps),H(f,X,B,We))}},Ce=(u,c)=>{if(_(t.errors,c)&&u.focus)return u.focus(),1},Se=async(u,c={})=>{let f,w;const b=Me(u);if(r.resolver){const g=await $(j(u)?u:b);f=Y(g),w=u?!b.some(S=>_(g,S)):f}else u?(w=(await Promise.all(b.map(async g=>{const S=_(s,g);return await F(S&&S._f?{[g]:S}:S)}))).every(Boolean),!(!w&&!t.isValid)&&I()):w=f=await F(s);return m.state.next({...!ee(u)||(x.isValid||h.isValid)&&f!==t.isValid?{}:{name:u},...r.resolver||!u?{isValid:f}:{},errors:t.errors}),c.shouldFocus&&!w&&Ne(s,Ce,u?b:l.mount),w},lt=(u,c)=>{let f={...i.mount?o:a};return c&&(f=hr(c.dirtyFields?t.dirtyFields:t.touchedFields,f)),j(u)?f:ee(u)?_(f,u):u.map(w=>_(f,w))},ut=(u,c)=>({invalid:!!_((c||t).errors,u),isDirty:!!_((c||t).dirtyFields,u),error:_((c||t).errors,u),isValidating:!!_(t.validatingFields,u),isTouched:!!_((c||t).touchedFields,u)}),xr=u=>{const c=u?Me(u):void 0;c==null||c.forEach(f=>z(t.errors,f)),c?c.forEach(f=>{m.state.next({name:f,errors:t.errors})}):m.state.next({errors:{}})},ct=(u,c,f)=>{const w=(_(s,u,{_f:{}})._f||{}).ref,b=_(t.errors,u)||{},{ref:g,message:S,type:O,...B}=b;P(t.errors,u,{...B,...c,ref:w}),m.state.next({name:u,errors:t.errors,isValid:!1}),f&&f.shouldFocus&&w&&w.focus&&w.focus()},wr=(u,c)=>re(u)?m.state.subscribe({next:f=>"values"in f&&u(D(void 0,c),f)}):D(u,c,!0),dt=u=>m.state.subscribe({next:c=>{Ks(u.name,c.name,u.exact)&&Ws(c,u.formState||x,Ir,u.reRenderRoot)&&u.callback({values:{...o},...t,...c,defaultValues:a})}}).unsubscribe,_r=u=>(i.mount=!0,h={...h,...u.formState},dt({...u,formState:{...v,...u.formState}})),je=(u,c={})=>{for(const f of u?Me(u):l.mount)l.mount.delete(f),l.array.delete(f),c.keepValue||(z(s,f),z(o,f)),!c.keepError&&z(t.errors,f),!c.keepDirty&&z(t.dirtyFields,f),!c.keepTouched&&z(t.touchedFields,f),!c.keepIsValidating&&z(t.validatingFields,f),!r.shouldUnregister&&!c.keepDefaultValue&&z(a,f);m.state.next({values:K(o)}),m.state.next({...t,...c.keepDirty?{isDirty:M()}:{}}),!c.keepIsValid&&I()},ft=({disabled:u,name:c})=>{if(ne(u)&&i.mount||u||l.disabled.has(c)){const b=l.disabled.has(c)!==!!u;u?l.disabled.add(c):l.disabled.delete(c),b&&i.mount&&!i.action&&I()}},qe=(u,c={})=>{let f=_(s,u);const w=ne(c.disabled)||ne(r.disabled);return P(s,u,{...f||{},_f:{...f&&f._f?f._f:{ref:{name:u}},name:u,mount:!0,...c}}),l.mount.add(u),f?ft({disabled:ne(c.disabled)?c.disabled:r.disabled,name:u}):A(u,!0,c.value),{...w?{disabled:c.disabled||r.disabled}:{},...r.progressive?{required:!!c.required,min:Ie(c.min),max:Ie(c.max),minLength:Ie(c.minLength),maxLength:Ie(c.maxLength),pattern:Ie(c.pattern)}:{},name:u,onChange:ke,onBlur:ke,ref:b=>{if(b){qe(u,c),f=_(s,u);const g=j(b.value)&&b.querySelectorAll&&b.querySelectorAll("input,select,textarea")[0]||b,S=Rs(g),O=f._f.refs||[];if(S?O.find(B=>B===g):g===f._f.ref)return;P(s,u,{_f:{...f._f,...S?{refs:[...O.filter(Je),g,...Array.isArray(_(a,u))?[{}]:[]],ref:{type:g.type,name:u}}:{ref:g}}}),A(u,!1,void 0,g)}else f=_(s,u,{}),f._f&&(f._f.mount=!1),(r.shouldUnregister||c.shouldUnregister)&&!(Ms(l.array,u)&&i.action)&&l.unMount.add(u)}}},Ue=()=>r.shouldFocusError&&Ne(s,Ce,l.mount),kr=u=>{ne(u)&&(m.state.next({disabled:u}),Ne(s,(c,f)=>{const w=_(s,f);w&&(c.disabled=w._f.disabled||u,Array.isArray(w._f.refs)&&w._f.refs.forEach(b=>{b.disabled=w._f.disabled||u}))},0,!1))},ht=(u,c)=>async f=>{let w;f&&(f.preventDefault&&f.preventDefault(),f.persist&&f.persist());let b=K(o);if(m.state.next({isSubmitting:!0}),r.resolver){const{errors:g,values:S}=await L();N(),t.errors=g,b=K(S)}else await F(s);if(l.disabled.size)for(const g of l.disabled)z(b,g);if(z(t.errors,"root"),Y(t.errors)){m.state.next({errors:{}});try{await u(b,f)}catch(g){w=g}}else c&&await c({...t.errors},f),Ue(),setTimeout(Ue);if(m.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Y(t.errors)&&!w,submitCount:t.submitCount+1,errors:t.errors}),w)throw w},Cr=(u,c={})=>{_(s,u)&&(j(c.defaultValue)?U(u,K(_(a,u))):(U(u,c.defaultValue),P(a,u,K(c.defaultValue))),c.keepTouched||z(t.touchedFields,u),c.keepDirty||(z(t.dirtyFields,u),t.isDirty=c.defaultValue?M(u,K(_(a,u))):M()),c.keepError||(z(t.errors,u),x.isValid&&I()),m.state.next({...t}))},pt=(u,c={})=>{const f=u?K(u):a,w=K(f),b=Y(u),g=b?a:w;if(c.keepDefaultValues||(a=f),!c.keepValues){if(c.keepDirtyValues){const S=new Set([...l.mount,...Object.keys(ve(a,o))]);for(const O of Array.from(S)){const B=_(t.dirtyFields,O),X=_(o,O),pe=_(g,O);B&&!j(X)?P(g,O,X):!B&&!j(pe)&&U(O,pe)}}else{if(st&&j(u))for(const S of l.mount){const O=_(s,S);if(O&&O._f){const B=Array.isArray(O._f.refs)?O._f.refs[0]:O._f.ref;if(De(B)){const X=B.closest("form");if(X){X.reset();break}}}}if(c.keepFieldsRef)for(const S of l.mount)U(S,_(g,S));else s={}}o=r.shouldUnregister?c.keepDefaultValues?K(a):{}:K(g),m.array.next({values:{...g}}),m.state.next({values:{...g}})}l={mount:c.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},i.mount=!x.isValid||!!c.keepIsValid||!!c.keepDirtyValues||!r.shouldUnregister&&!Y(g),i.watch=!!r.shouldUnregister,i.keepIsValid=!!c.keepIsValid,i.action=!1,c.keepErrors||(t.errors={}),m.state.next({submitCount:c.keepSubmitCount?t.submitCount:0,isDirty:b?!1:c.keepDirty?t.isDirty:!!(c.keepDefaultValues&&!fe(u,a)),isSubmitted:c.keepIsSubmitted?t.isSubmitted:!1,dirtyFields:b?{}:c.keepDirtyValues?c.keepDefaultValues&&o?ve(a,o):t.dirtyFields:c.keepDefaultValues&&u?ve(a,u):c.keepDirty?t.dirtyFields:{},touchedFields:c.keepTouched?t.touchedFields:{},errors:c.keepErrors?t.errors:{},isSubmitSuccessful:c.keepIsSubmitSuccessful?t.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:a})},yt=(u,c)=>pt(re(u)?u(o):u,{...r.resetOptions,...c}),Sr=(u,c={})=>{const f=_(s,u),w=f&&f._f;if(w){const b=w.refs?w.refs[0]:w.ref;b.focus&&setTimeout(()=>{b.focus(),c.shouldSelect&&re(b.select)&&b.select()})}},Ir=u=>{t={...t,...u}},mt={control:{register:qe,unregister:je,getFieldState:ut,handleSubmit:ht,setError:ct,_subscribe:dt,_runSchema:L,_updateIsValidating:N,_focusError:Ue,_getWatch:D,_getDirty:M,_setValid:I,_setFieldArray:y,_setDisabledField:ft,_setErrors:E,_getFieldArray:T,_reset:pt,_resetDefaultValues:()=>re(r.defaultValues)&&r.defaultValues().then(u=>{yt(u,r.resetOptions),m.state.next({isLoading:!1})}),_removeUnmounted:G,_disableForm:kr,_subjects:m,_proxyFormState:x,get _fields(){return s},get _formValues(){return o},get _state(){return i},set _state(u){i=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:_r,trigger:Se,register:qe,handleSubmit:ht,watch:wr,setValue:U,getValues:lt,reset:yt,resetField:Cr,clearErrors:xr,unregister:je,setError:ct,setFocus:Sr,getFieldState:ut};return{...mt,formControl:mt}}function Pe(e={}){const r=n.Cn.useRef(void 0),t=n.Cn.useRef(void 0),[s,a]=n.Cn.useState({isDirty:!1,isValidating:!1,isLoading:re(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:re(e.defaultValues)?void 0:e.defaultValues});if(!r.current)if(e.formControl)r.current={...e.formControl,formState:s},e.defaultValues&&!re(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:i,...l}=Xs(e);r.current={...l,formState:s}}const o=r.current.control;return o._options=e,Ds(()=>{const i=o._subscribe({formState:o._proxyFormState,callback:()=>a({...o._formState}),reRenderRoot:!0});return a(l=>({...l,isReady:!0})),o._formState.isReady=!0,i},[o]),n.Cn.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),n.Cn.useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),n.Cn.useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),n.Cn.useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),n.Cn.useEffect(()=>{if(o._proxyFormState.isDirty){const i=o._getDirty();i!==s.isDirty&&o._subjects.state.next({isDirty:i})}},[o,s.isDirty]),n.Cn.useEffect(()=>{var i;e.values&&!fe(e.values,t.current)?(o._reset(e.values,{keepFieldsRef:!0,...o._options.resetOptions}),!((i=o._options.resetOptions)===null||i===void 0)&&i.keepIsValid||o._setValid(),t.current=e.values,a(l=>({...l}))):o._resetDefaultValues()},[o,e.values]),n.Cn.useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),r.current.formState=n.Cn.useMemo(()=>Ls(s,o),[o,s]),r.current}const $t=(e,r,t)=>{if(e&&"reportValidity"in e){const s=_(t,r);e.setCustomValidity(s&&s.message||""),e.reportValidity()}},Ys=(e,r)=>{for(const t in r.fields){const s=r.fields[t];s&&s.ref&&"reportValidity"in s.ref?$t(s.ref,t,e):s.refs&&s.refs.forEach(a=>$t(a,t,e))}},Qs=(e,r)=>{r.shouldUseNativeValidation&&Ys(e,r);const t={};for(const s in e){const a=_(r.fields,s),o=Object.assign(e[s]||{},{ref:a&&a.ref});if(en(r.names||Object.keys(e),s)){const i=Object.assign({},_(t,s));P(i,"root",o),P(t,s,i)}else P(t,s,o)}return t},en=(e,r)=>e.some(t=>t.startsWith(r+"."));var $e=function(e,r,t){return t===void 0&&(t={}),function(s,a,o){try{var i=!o.shouldUseNativeValidation&&o.criteriaMode==="all";return Promise.resolve(hs(e,s,Object.assign({},r,{abortPipeEarly:!i}))).then(function(l){if(l.issues){for(var d={};l.issues.length;){var p=l.issues[0],v=as(p);if(v&&(d[v]||(d[v]={message:p.message,type:p.type}),i)){var x=d[v].types,h=x&&x[p.type];d[v]=fr(v,i,d,p.type,h?[].concat(h,p.message):p.message)}l.issues.shift()}return{values:{},errors:Qs(d,o)}}return{values:t.raw?s:l.output,errors:{}}})}catch(l){return Promise.reject(l)}}};const jt=27,qt=12,Ut=10,tn=n.isSubmissionOfType("enum"),rn=(e,r)=>{const t={min:e.minSelected??0,max:e.maxSelected??e.options.length};return $e(ce({checked:he(ar(te(),sr()),Qe(s=>Object.entries(s).filter(([a,o])=>o).map(([a,o])=>a)),Ae(t.max,r("validation_multiple_choice_max",{count:t.max})),xe(t.min,r("validation_multiple_choice_min",{count:t.min})))}))},sn=n.k$2(({option:e,...r},t)=>n.o(n.k$1,{children:[n.o("input",{class:"peer sr-only h-full",type:"checkbox",...r,ref:t}),n.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})]})),zt=n.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:lr}}}),nn=({input:e,onSubmitSuccess:r})=>{var v,x;const t=e.key?(v=n.store.current$.value.flow)==null?void 0:v.data.submissions[e.key]:void 0,s=(e.config.minSelected===1||e.config.minSelected===void 0)&&e.config.maxSelected===1,a=s&&e.config.options.length===2,{t:o}=n.useTranslation(),{register:i,handleSubmit:l,formState:{errors:d}}=Pe({defaultValues:{checked:s?{}:tn(t)?Object.fromEntries(t.value.map(h=>[h,!0])):{}},resolver:rn(e.config,o)}),p=tt();return a?n.o("ul",{style:{maxHeight:6.5*jt+5*qt+2*Ut},class:zt({variant:"booleanLike"}),children:e.config.options.map((h,m)=>n.o("li",{class:ur,children:n.o(cr,{type:"submit",ref:k=>{k&&m===0&&(p.current=k)},label:h.label,value:"true",onClick:()=>r({type:"enum",value:[h.value]})})},h.value))}):n.o("form",{noValidate:!0,onSubmit:h=>l(m=>{const k=m.checked;r({type:"enum",value:k})})(h),children:[n.o("div",{class:"flex items-center gap-1",children:[n.o("ul",{style:{maxHeight:6.5*jt+5*qt+2*Ut},class:zt({variant:e.config.options.length===1?"singleOption":void 0}),children:e.config.options.map((h,m)=>{const k=`checked.${h.value}`,{ref:V,...I}=i(k);return n.o("li",{class:"relative",children:n.o(sn,{option:h,autoFocus:m===0,ref:N=>{N&&m===0&&(p.current=N),V(N)},id:k,...I,onClick:s?()=>r({type:"enum",value:[h.value]}):void 0})},h.value)})}),n.o("div",{class:"flex flex-col items-center gap-2 pr-2.5 pt-2.5",children:[s?null:n.o(me,{}),e.config.minSelected===0&&n.o(ge,{class:"relative",type:"button",onClick:()=>r({type:"enum",value:[]})})]})]}),n.o("div",{class:"px-1",children:n.o(_e,{error:(x=d.checked)==null?void 0:x.root})})]})},an=n.isSubmissionOfType("number"),on=(e,r)=>{const t=e.min??Number.MIN_SAFE_INTEGER,s=e.max??Number.MAX_SAFE_INTEGER,a=e.decimalCases??0;return $e(ce({number:he(nr(r("validation_number")),Qt(t,r("validation_number_min",{min:t})),Yt(s,r("validation_number_max",{max:s})),Zt(o=>o===Number(o.toFixed(a)),r("validation_number_decimal_cases",{count:a})))}))},ln=({input:e,onSubmitSuccess:r})=>{var x;const t=e.config.defaultValue,s=e.key?(x=n.store.current$.value.flow)==null?void 0:x.data.submissions[e.key]:void 0,{t:a}=n.useTranslation(),{register:o,handleSubmit:i,formState:{errors:l}}=Pe({defaultValues:{number:an(s)?s.value:t?Number(t):void 0},resolver:on(e.config,a)}),{ref:d,...p}=o("number",{required:!e.config.optional,valueAsNumber:!0}),v=n._();return n.y(()=>{v.current&&(v.current.focus(),v.current.select())},[]),n.o("form",{class:"flex flex-col gap-1 p-2.5",onSubmit:i(h=>{h.number!==void 0&&r({type:"number",value:h.number})}),children:[n.o("div",{class:"flex items-center gap-2",children:[n.o("div",{class:"relative min-w-0 flex-grow",children:[n.o("input",{...p,id:"chat-input",autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:h=>{h&&(v.current=h),d(h)},type:"text",min:e.config.min,max:e.config.max,class:Te({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&&n.o(ge,{class:"absolute bottom-0 right-0.5 top-0",onClick:()=>r(null)})]}),n.o(me,{})]}),n.o(_e,{error:l.number})]})},un=e=>{if(e==="")return{countryCode:"",phoneNumber:""};const r=Object.entries(et).find(a=>e.startsWith(a[1])),t=r?r[1]:"",s=e.replace(t,"");return/^\d+$/.test(s)?{countryCode:t,phoneNumber:s}:{countryCode:"",phoneNumber:""}},cn="44",dn=/^[0-9 ]+$/,fn=n.isSubmissionOfType("string"),hn=n.isSubmissionOfType("phone"),pn=e=>{const r=he(te(e("validation_country_code")),Ye(dn,e("validation_country_code"))),t=he(te(e("validation_phone")),xe(1,e("validation_phone")),Qe(s=>s.replace(/[^0-9]/g,"")));return $e(ce({countryCode:r,phoneNumber:t}))},yn=({input:e,onSubmitSuccess:r})=>{var V;const t=e.key?(V=n.store.current$.value.flow)==null?void 0:V.data.submissions[e.key]:void 0,{t:s}=n.useTranslation(),[a,o]=n.h(),i=fn(t)?un(t.value):hn(t)?t.value:void 0,{register:l,handleSubmit:d,formState:{errors:p},watch:v}=Pe({defaultValues:{countryCode:(i==null?void 0:i.countryCode)??e.config.defaultValue.countryCode??cn,phoneNumber:(i==null?void 0:i.phoneNumber)??e.config.defaultValue.phoneNumber??""},resolver:pn(s)}),{ref:x,...h}=l("phoneNumber",{required:!e.config.optional}),m=n._(),k=v("countryCode");return n.y(()=>{m.current&&(m.current.focus(),m.current.select())},[]),n.o("form",{noValidate:!0,class:"flex flex-col gap-1 p-2.5",onSubmit:d(I=>{const N=I.phoneNumber.replace(/[^0-9]/g,""),y=I.countryCode.replace(/[^0-9]/g,"");o(void 0);const C=e.config.minChars??7,E=N.length+y.length;if(E<C)return o(s("validation_phone_min_chars",{count:C}));const A=e.config.maxChars;if(A!=null&&E>A)return o(s("validation_max_chars",{count:A}));e.config.submissionFormat==="phone"?r({type:"phone",value:{countryCode:y,phoneNumber:N}}):r({type:"string",value:k+I.phoneNumber})}),children:[n.o("div",{class:"flex items-center gap-2",children:[n.o("div",{class:"relative flex min-w-0 flex-1 flex-grow gap-2",children:[n.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:[n.o("span",{children:["+",k]}),n.o("select",{...l("countryCode",{}),id:`isdk_phone_${e.key}`,class:"absolute inset-0 opacity-0",children:Object.entries(et).map(([I,N])=>n.o("option",{value:N,children:[I," (+",N,")"]},I))})]}),n.o("input",{...h,id:"chat-input",type:"tel",inputMode:"tel",autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:I=>{I&&(m.current=I),x(I)},class:Te({optional:e.config.optional,className:"min-w-0 flex-1 rounded-r-full"}),placeholder:e.config.placeholder}),e.config.optional&&n.o(ge,{class:"absolute bottom-0 right-1 top-0",onClick:()=>r(null)})]}),n.o(me,{})]}),n.o(_e,{error:p.countryCode||p.phoneNumber||{message:a}})]})},mn=({input:e,onSubmitSuccess:r})=>n.o("div",{class:"flex flex-col items-center py-3",children:n.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 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",name:e.key,onClick:()=>{r(null)},children:n.o("span",{class:"flex items-center gap-1.5",children:[n.o("span",{class:"inline-flex items-center text-sm font-medium",children:e.config.label||"Submit"}),n.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:[n.o("path",{d:"M4 8L8 4L12 8"}),n.o("path",{d:"M8 4V13"})]})]})})}),gn={date:{type:"date",inputMode:"text"},email:{type:"email",inputMode:"email",formNoValidate:!0},text:{type:"text",inputMode:"text"},url:{type:"url",inputMode:"url",formNoValidate:!0}},bn=n.isSubmissionOfType("string"),vn=(e,r)=>{const t={maxLength:r("validation_max_chars",{count:e.maxChars??999}),minLength:r("validation_min_chars",{count:e.minChars??1})};return $e(ce({text:{date:he(te(r("validation_date")),Ye(/^\d{4}-\d{2}-\d{2}$/,r("validation_date"))),email:he(te(r("validation_email")),Xt(r("validation_email")),xe(e.minChars??1,t.minLength),Ae(e.maxChars??1/0,t.maxLength)),text:he(te(),xe(e.minChars??1,t.minLength),Ae(e.maxChars??1/0,t.maxLength)),url:he(te(r("validation_url")),er(r("validation_url")),xe(e.minChars??1,t.minLength),Ae(e.maxChars??1/0,t.maxLength))}[e.format]}))},xn=({input:e,onSubmitSuccess:r})=>{var x;const{t}=n.useTranslation(),s=e.key?(x=n.store.current$.value.flow)==null?void 0:x.data.submissions[e.key]:void 0,a=e.config.defaultValue,{register:o,handleSubmit:i,formState:{errors:l}}=Pe({defaultValues:{text:bn(s)?s.value:a??""},resolver:vn(e.config,t)}),{ref:d,...p}=o("text",{required:!e.config.optional}),v=n._();return n.y(()=>{v.current&&(v.current.focus(),v.current.select())},[]),n.o("form",{noValidate:!0,class:"flex flex-col gap-1 p-2.5",onSubmit:i(h=>{r({type:"string",value:h.text})}),children:[n.o("div",{class:"flex items-center gap-2",children:[n.o("div",{class:"relative min-w-0 flex-1",children:[n.o("input",{id:"chat-input",...p,...gn[e.config.format],autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:h=>{h&&(v.current=h),d(h)},placeholder:e.config.placeholder,class:Te({optional:!!e.config.optional,className:"w-full rounded-full"})}),e.config.optional&&n.o(ge,{class:"absolute bottom-0 right-0.5 top-0",onClick:()=>r(null)})]}),n.o(me,{})]}),n.o(_e,{error:l.text})]})},wn={text:xn,phone:yn,"multiple-choice":nn,boolean:ks,file:Fs,submit:mn,address:vs,number:ln},_n=({logger:e})=>{var a;const r=(a=n.store.current$.value.flow)==null?void 0:a.data.currentInput,t=n._(null),s=()=>n.chatStore.onInteractionFn$.value();return n.y(()=>{var o;(o=t.current)==null||o.scrollTo({top:0})},[r]),n.o("div",{ref:t,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:n.o("div",{class:"flex flex-col",onPointerDownCapture:r?s:void 0,onKeyDownCapture:r?s:void 0,children:r?(()=>{const o=wn[r.type];return n.o(o,{logger:e,onSubmitSuccess:n.chatStore.onSubmitSuccessFn$.value,input:r})})():n.o("div",{class:"flex items-center gap-2 p-2.5",children:[n.o("input",{"aria-hidden":"true",id:"chat-input",class:Te({optional:!1,className:"flex-grow rounded-full"}),disabled:!0}),n.o(me,{disabled:!0,"aria-hidden":"true",tabIndex:-1})]})})})};function kn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Cn=function(e){return e instanceof RegExp},Sn=function(r){var t=/[\\^$.*+?()[\]{}|]/g,s=RegExp(t.source);return r&&s.test(r)?r.replace(t,"\\$&"):r},vr=function(e){return typeof e=="string"},In=function(e){var r=[];return e.forEach(function(t){Array.isArray(t)?r=r.concat(t):r.push(t)}),r};function Vn(e,r,t){var s=0,a=0;if(e==="")return e;if(!e||!vr(e))throw new TypeError("First argument to react-string-replace#replaceString must be a string");var o=r;Cn(o)||(o=new RegExp("("+Sn(o)+")","gi"));for(var i=e.split(o),l=1,d=i.length;l<d;l+=2){if(i[l]===void 0||i[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=i[l].length,s+=i[l-1].length,i[l]=t(i[l],l,s),s+=a}return i}var Fn=function(r,t,s){return Array.isArray(r)||(r=[r]),In(r.map(function(a){return vr(a)?Vn(a,t,s):a}))};const Ve=kn(Fn),An=/(\[[^\]]+\]\([^)]+\))/g,En=/\[([^\]]+)\]\(([^)]+)\)/,Mn=/(https?:\/\/[^\s]+)/g,Nn=/_(.*?)_/g,Tn=/\*\*(.*?)\*\*/g,Ln=/\\n|\n/g,Wt="text-accent-10 hover:text-accent-11 no-underline underline-offset-2 hover:underline",Dn=e=>{const r=Ve(e,An,(i,l)=>{const[,d,p]=i.match(En)??[];return p?n.o("a",{class:Wt,href:p,children:d??p},p+l):n.o("span",{children:"INVALID LINK"})}),t=Ve(r,Mn,(i,l)=>n.o("a",{class:Wt,href:i,children:i},i+l)),s=Ve(t,Nn,(i,l)=>n.o("em",{children:i},i+l)),a=Ve(s,Tn,(i,l)=>n.o("strong",{children:i},i+l));return Ve(a,Ln,(i,l)=>n.o("br",{},`br-${l}`))},On=n.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"}}),Bn=({children:e,className:r,animate:t,side:s,...a})=>n.o("p",{style:{transformOrigin:s==="left"?"0% 50%":"100% 50%"},class:On({className:r,side:s,animate:t}),...a,children:e}),Rn=({message:e})=>n.o("div",{class:"bg-accent-3 flex w-full items-center justify-center overflow-hidden rounded-xl px-2 py-2",children:n.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,n.o("svg",{class:"flex-none",width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:n.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"})})]})}),Pn=({className:e,...r})=>n.o("div",{"aria-hidden":!0,children:n.chatStore.isBotTyping$.value===!0?n.o("div",{"aria-label":"Typing…",class:n.clsx("flex gap-1 p-4",e),...r,children:Array.from({length:3},(t,s)=>n.o("div",{class:"bg-accent-9 h-1.5 w-1.5 animate-bounce rounded-full",style:{animationDelay:`${-s*200}ms`}}))}):void 0}),$n={bot:"left",user:"right"},jn=n.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-8",warning:"text-[#FFC107]",error:"text-error-9",success:"text-[#4CAF50]"}}}),qn=({lastSentMessageFooter:e})=>{const r=n.store.current$.value.flow,t=(r==null?void 0:r.data.messages)??[],s=r?n.getCorrectionNodeId(r):void 0;return n.o("ol",{"aria-label":"Chat messages","aria-live":"polite",class:"mt-auto flex flex-col justify-end gap-2 p-2 pt-[calc(var(--header-height)+1rem)]",children:[t.map((a,o)=>n.o(n.k$1,{children:n.o("li",{class:"flex",tabIndex:o===t.length-1?-1:void 0,children:[s&&a.groupId===s&&!t.slice(o+1).some(i=>i.groupId===s)?e:null,n.M$1(a).with({type:"system"},i=>n.o("p",{class:jn({variant:i.variant}),children:i.text})).with({type:"text",author:n.z$1.union("bot","user")},i=>{const l=o===t.length-1,d=i.author==="bot"?Dn(i.text):i.text;return n.o(n.k$1,{children:n.o(Bn,{animate:l,side:$n[i.author],children:d},o)})}).with({type:"link"},i=>n.o(Rn,{message:i})).with({type:"image"},i=>n.o("img",{class:"shadow-surface-md w-full max-w-[min(100%,24rem)] rounded-2xl",src:i.url,style:{aspectRatio:i.width/i.height}})).with({type:"file"},i=>n.o(Is,{class:i.author==="bot"?void 0:"ml-auto",file:{name:i.fileName,sizeKb:i.fileSizeKb}})).with({type:"loading"},i=>{const l=t[t.length-1];return!(i===l)||n.chatStore.isBotTyping$.value?null:n.o("div",{class:"flex flex-grow flex-col items-center justify-center gap-2",children:[n.o(n.LoadingIndicator,{"aria-hidden":i.text?"true":void 0,class:"text-neutral-6 h-8 w-8"}),i.text?n.o("p",{role:"status",class:"text-neutral-11 text-sm",children:i.text}):null]})}).exhaustive()]})},o)),n.o(Pn,{},"typing")]})},Un=({logger:e,apiClient:r,analytics:t,talentBankClient:s})=>{const{flow:a}=n.store.current$.value;n.invariant(a,"Flow is required to exist to show chatbot body");const o=n.store.viewState$.value,{chatRef:i,chatService:l}=n.useChatService(),{t:d}=n.useTranslation(),[p,v]=n.h();return n.y(()=>{o==="maximised"&&n.chatStore.scrollToEnd()},[o]),n.y(()=>{var y;const{state:x,flow:h}=n.store.current$.peek();if(x!=="loaded")throw new Error(d("invalid_state"));let m=h.data.nodeHistory.at(-1);if(n.chatStore.scrollToEnd(),n.store.setInput(void 0),h.data.isFinished)return;const k=()=>{const C=n.store.current$.peek().flow;!C||C.data.hasInteracted||(n.store.markAsInteracted(),vt(t,C,"FLOW_INTERACT"))};n.chatStore.onInteractionFn$.value=k,m===void 0?(m=n.getHeadOrThrow(a.nodes).id,n.store.setCurrentNodeId(m),vt(t,h,"FLOW_START")):n.store.removeMessagesSentByNodeIds([m]);const{interpret:V,abort:I,undo:N}=Lr({context:a.context,analytics:{service:t,customProperties:(y=a.analytics)==null?void 0:y.customProperties},apiClient:r,logger:e,talentBankClient:s,flow:a,chatService:l,t:d,getApplicationRecovery:()=>{var C;return(C=n.store.current$.peek().flow)==null?void 0:C.data.applicationRecovery},setApplicationRecovery:n.store.setApplicationRecovery,persistWriteBarrier:()=>n.store.persistWriteBarrier(h),getSubmissions:()=>{var C;return(C=n.store.current$.peek().flow)==null?void 0:C.data.submissions},onInterpret:C=>n.store.setCurrentNodeId(C.id),onFlowEnd:async()=>{var E;n.store.markAsFinished();const C=n.store.current$.peek().flow;n.invariant(C),t.log({event:"FLOW_END",properties:{flow_id:a.id,flow_version:a.version,flow_session_id:C.data.flowSessionId,flow_build:a.build,job:a.job},customProperties:(E=a.analytics)==null?void 0:E.customProperties})}});return v(()=>N),V(m),()=>{n.chatStore.onInteractionFn$.value===k&&(n.chatStore.onInteractionFn$.value=()=>{}),I()}},[t,r,l,e,a,s,d]),n.o(n.k$1,{children:[n.o("div",{class:"relative flex min-h-0 w-full max-w-full flex-grow flex-col",children:[n.o("div",{ref:i,role:"region","aria-label":d("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:n.o(qn,{lastSentMessageFooter:!n.getCorrectionNodeId(a)||!p?null:n.o(zn,{undoFn:p})})}),n.chatStore.isReadingHistory$.value&&!a.data.isFinished&&!n.chatStore.isBotTyping$.value&&n.o("div",{class:"absolute bottom-2 left-1/2 -translate-x-1/2",children:n.o(n.SvgIconButton,{class:"bg-neutral-1 ring-divider shadow-surface-md ring-1","aria-label":d("jump_to_current"),onClick:()=>{var h,m;n.chatStore.scrollToEnd(),(m=((h=i.current)==null?void 0:h.querySelector('li[tabindex="-1"]'))??i.current)==null||m.focus({preventScroll:!0})},children:n.o(n.ChevronDown,{})})})]}),n.o(_n,{logger:e})]})},zn=({undoFn:e})=>{const{t:r}=n.useTranslation();return n.o("div",{class:"flex flex-1 items-center justify-end px-1",children:n.o(n.SvgIconButton,{"aria-label":r("undo"),onClick:async()=>{const{flow:t}=n.store.current$.peek();n.invariant(t),e(t.data.nodeHistory)},children:n.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=Un;
|
package/dist/chatbot.idb.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export declare const idb: {
|
|
|
6
6
|
getStateData: (flow: Flow, flowKeys: string[], context: Record<string, unknown>) => Promise<{
|
|
7
7
|
currentInput: ChatInput | null;
|
|
8
8
|
nodeHistory: string[];
|
|
9
|
+
startedWriteNodeIds?: string[];
|
|
9
10
|
applicationRecovery?: ApplicationRecovery;
|
|
10
11
|
flowSessionId: string;
|
|
11
12
|
isFinished: boolean;
|
package/dist/chatbot.state.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export type StartedFlow = Flow & {
|
|
|
15
15
|
nodeIdToProgress: Record<string, ChatbotFlowProgress>;
|
|
16
16
|
analytics: OpenChatbotParams['analytics'];
|
|
17
17
|
};
|
|
18
|
+
export declare const getCorrectionNodeId: (flow: StartedFlow) => string | undefined;
|
|
18
19
|
type CurrentFlow = {
|
|
19
20
|
state: 'idle';
|
|
20
21
|
flow?: never;
|
|
@@ -315,6 +316,7 @@ export declare const store: {
|
|
|
315
316
|
removeMessagesSentByNodeIds: (nodeIds: string[]) => void;
|
|
316
317
|
setSubmission: (fieldKey: string, submission: FlowSubmission | null) => void;
|
|
317
318
|
setInput: (input: ChatInput | undefined) => void;
|
|
319
|
+
persistWriteBarrier: (flow: StartedFlow) => Promise<void>;
|
|
318
320
|
};
|
|
319
321
|
export type MessageAuthor = 'bot' | 'user';
|
|
320
322
|
type SystemMessage = {
|
|
@@ -348,6 +350,7 @@ type FileMessage = {
|
|
|
348
350
|
};
|
|
349
351
|
export type LoadingMessage = {
|
|
350
352
|
type: 'loading';
|
|
353
|
+
/** Shown beside the indicator and announced to screen readers. */ text?: string;
|
|
351
354
|
};
|
|
352
355
|
export type ChatMessage = TextMessage | ImageMessage | SystemMessage | FileMessage | LinkMessage | LoadingMessage;
|
|
353
356
|
export type FileToUpload = {
|
|
@@ -406,6 +409,14 @@ export type FlowStateData = {
|
|
|
406
409
|
})[];
|
|
407
410
|
submissions: KeyToSubmissionMap;
|
|
408
411
|
nodeHistory: string[];
|
|
412
|
+
/**
|
|
413
|
+
* Browser replay barrier: submit nodes whose write has started, flushed to the flow cache before the POST so
|
|
414
|
+
* Undo and reload cannot resend a pending, accepted or unknown attempt. It is not proof that the provider
|
|
415
|
+
* accepted the application and not server idempotency: independent tabs, cleared storage and the memory-only
|
|
416
|
+
* fallback are not coordinated. An explicit not_submitted result releases only the attempt that added the
|
|
417
|
+
* entry. Caches from before this field infer it conservatively from visited submit nodes.
|
|
418
|
+
*/
|
|
419
|
+
startedWriteNodeIds?: string[];
|
|
409
420
|
applicationRecovery?: ApplicationRecovery;
|
|
410
421
|
/** Needs to be separate because a node can have many inputs */
|
|
411
422
|
currentInput: ChatInput | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/i18n.d.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
export declare const TranslationProvider: (props: {
|
|
2
2
|
terms?: Partial<import('@inploi/i18n/translation').TranslationDict<{
|
|
3
3
|
readonly error_heading: "Something unexpected happened";
|
|
4
|
-
readonly undo: "
|
|
4
|
+
readonly undo: "Change answer";
|
|
5
5
|
readonly conversation_history: "Conversation history";
|
|
6
6
|
readonly jump_to_current: "Jump to current question";
|
|
7
7
|
readonly send: "Send";
|
|
8
|
+
readonly submitting: "Sending your application…";
|
|
8
9
|
readonly skip: "Skip";
|
|
9
10
|
readonly skipped: "Skipped";
|
|
10
11
|
readonly submission_closed: "This role is no longer accepting applications.";
|
|
11
12
|
readonly submission_duplicate: "It looks like you've already applied for this role.";
|
|
12
13
|
readonly submission_retryable: "We couldn't submit your application. Please try again.";
|
|
13
|
-
readonly
|
|
14
|
+
readonly submission_failed: "We couldn't submit your application. Choose Restart to try again.";
|
|
15
|
+
readonly submission_unknown: "We couldn't confirm whether your application was sent. Please check your email for a confirmation. If nothing arrives, choose Restart to apply again.";
|
|
14
16
|
readonly submission_unreadable_document: "We couldn't read that file. Please upload a different one.";
|
|
17
|
+
readonly submission_still_working: "Still working — the employer's application system is taking a little longer than usual. Please keep this window open.";
|
|
15
18
|
readonly file_preparing: {
|
|
16
19
|
readonly one: "Preparing your file…";
|
|
17
20
|
readonly other: "Preparing your files…";
|
|
@@ -30,7 +33,6 @@ export declare const TranslationProvider: (props: {
|
|
|
30
33
|
readonly submission_redirect_message: "Almost there! Please complete your submission here:";
|
|
31
34
|
readonly complete_submission: "Complete submission";
|
|
32
35
|
readonly submission_completed: "Submission completed!";
|
|
33
|
-
readonly submission_failed: "Failed to submit";
|
|
34
36
|
readonly close_application: "Close application";
|
|
35
37
|
readonly invalid_state: "Invalid application state";
|
|
36
38
|
readonly redirect_url_error: "Couldn\u2019t get the redirect URL.";
|
|
@@ -92,17 +94,20 @@ export declare const TranslationProvider: (props: {
|
|
|
92
94
|
children?: import('preact').ComponentChildren;
|
|
93
95
|
}) => import("preact").JSX.Element, useTranslation: <T extends {
|
|
94
96
|
readonly error_heading: "Something unexpected happened";
|
|
95
|
-
readonly undo: "
|
|
97
|
+
readonly undo: "Change answer";
|
|
96
98
|
readonly conversation_history: "Conversation history";
|
|
97
99
|
readonly jump_to_current: "Jump to current question";
|
|
98
100
|
readonly send: "Send";
|
|
101
|
+
readonly submitting: "Sending your application…";
|
|
99
102
|
readonly skip: "Skip";
|
|
100
103
|
readonly skipped: "Skipped";
|
|
101
104
|
readonly submission_closed: "This role is no longer accepting applications.";
|
|
102
105
|
readonly submission_duplicate: "It looks like you've already applied for this role.";
|
|
103
106
|
readonly submission_retryable: "We couldn't submit your application. Please try again.";
|
|
104
|
-
readonly
|
|
107
|
+
readonly submission_failed: "We couldn't submit your application. Choose Restart to try again.";
|
|
108
|
+
readonly submission_unknown: "We couldn't confirm whether your application was sent. Please check your email for a confirmation. If nothing arrives, choose Restart to apply again.";
|
|
105
109
|
readonly submission_unreadable_document: "We couldn't read that file. Please upload a different one.";
|
|
110
|
+
readonly submission_still_working: "Still working — the employer's application system is taking a little longer than usual. Please keep this window open.";
|
|
106
111
|
readonly file_preparing: {
|
|
107
112
|
readonly one: "Preparing your file…";
|
|
108
113
|
readonly other: "Preparing your files…";
|
|
@@ -121,7 +126,6 @@ export declare const TranslationProvider: (props: {
|
|
|
121
126
|
readonly submission_redirect_message: "Almost there! Please complete your submission here:";
|
|
122
127
|
readonly complete_submission: "Complete submission";
|
|
123
128
|
readonly submission_completed: "Submission completed!";
|
|
124
|
-
readonly submission_failed: "Failed to submit";
|
|
125
129
|
readonly close_application: "Close application";
|
|
126
130
|
readonly invalid_state: "Invalid application state";
|
|
127
131
|
readonly redirect_url_error: "Couldn\u2019t get the redirect URL.";
|
|
@@ -180,17 +184,20 @@ export declare const TranslationProvider: (props: {
|
|
|
180
184
|
readonly optional: "optional";
|
|
181
185
|
} = {
|
|
182
186
|
readonly error_heading: "Something unexpected happened";
|
|
183
|
-
readonly undo: "
|
|
187
|
+
readonly undo: "Change answer";
|
|
184
188
|
readonly conversation_history: "Conversation history";
|
|
185
189
|
readonly jump_to_current: "Jump to current question";
|
|
186
190
|
readonly send: "Send";
|
|
191
|
+
readonly submitting: "Sending your application…";
|
|
187
192
|
readonly skip: "Skip";
|
|
188
193
|
readonly skipped: "Skipped";
|
|
189
194
|
readonly submission_closed: "This role is no longer accepting applications.";
|
|
190
195
|
readonly submission_duplicate: "It looks like you've already applied for this role.";
|
|
191
196
|
readonly submission_retryable: "We couldn't submit your application. Please try again.";
|
|
192
|
-
readonly
|
|
197
|
+
readonly submission_failed: "We couldn't submit your application. Choose Restart to try again.";
|
|
198
|
+
readonly submission_unknown: "We couldn't confirm whether your application was sent. Please check your email for a confirmation. If nothing arrives, choose Restart to apply again.";
|
|
193
199
|
readonly submission_unreadable_document: "We couldn't read that file. Please upload a different one.";
|
|
200
|
+
readonly submission_still_working: "Still working — the employer's application system is taking a little longer than usual. Please keep this window open.";
|
|
194
201
|
readonly file_preparing: {
|
|
195
202
|
readonly one: "Preparing your file…";
|
|
196
203
|
readonly other: "Preparing your files…";
|
|
@@ -209,7 +216,6 @@ export declare const TranslationProvider: (props: {
|
|
|
209
216
|
readonly submission_redirect_message: "Almost there! Please complete your submission here:";
|
|
210
217
|
readonly complete_submission: "Complete submission";
|
|
211
218
|
readonly submission_completed: "Submission completed!";
|
|
212
|
-
readonly submission_failed: "Failed to submit";
|
|
213
219
|
readonly close_application: "Close application";
|
|
214
220
|
readonly invalid_state: "Invalid application state";
|
|
215
221
|
readonly redirect_url_error: "Couldn\u2019t get the redirect URL.";
|
|
@@ -271,17 +277,20 @@ export declare const TranslationProvider: (props: {
|
|
|
271
277
|
locale: string | undefined;
|
|
272
278
|
}, createTFunction: <T extends {
|
|
273
279
|
readonly error_heading: "Something unexpected happened";
|
|
274
|
-
readonly undo: "
|
|
280
|
+
readonly undo: "Change answer";
|
|
275
281
|
readonly conversation_history: "Conversation history";
|
|
276
282
|
readonly jump_to_current: "Jump to current question";
|
|
277
283
|
readonly send: "Send";
|
|
284
|
+
readonly submitting: "Sending your application…";
|
|
278
285
|
readonly skip: "Skip";
|
|
279
286
|
readonly skipped: "Skipped";
|
|
280
287
|
readonly submission_closed: "This role is no longer accepting applications.";
|
|
281
288
|
readonly submission_duplicate: "It looks like you've already applied for this role.";
|
|
282
289
|
readonly submission_retryable: "We couldn't submit your application. Please try again.";
|
|
283
|
-
readonly
|
|
290
|
+
readonly submission_failed: "We couldn't submit your application. Choose Restart to try again.";
|
|
291
|
+
readonly submission_unknown: "We couldn't confirm whether your application was sent. Please check your email for a confirmation. If nothing arrives, choose Restart to apply again.";
|
|
284
292
|
readonly submission_unreadable_document: "We couldn't read that file. Please upload a different one.";
|
|
293
|
+
readonly submission_still_working: "Still working — the employer's application system is taking a little longer than usual. Please keep this window open.";
|
|
285
294
|
readonly file_preparing: {
|
|
286
295
|
readonly one: "Preparing your file…";
|
|
287
296
|
readonly other: "Preparing your files…";
|
|
@@ -300,7 +309,6 @@ export declare const TranslationProvider: (props: {
|
|
|
300
309
|
readonly submission_redirect_message: "Almost there! Please complete your submission here:";
|
|
301
310
|
readonly complete_submission: "Complete submission";
|
|
302
311
|
readonly submission_completed: "Submission completed!";
|
|
303
|
-
readonly submission_failed: "Failed to submit";
|
|
304
312
|
readonly close_application: "Close application";
|
|
305
313
|
readonly invalid_state: "Invalid application state";
|
|
306
314
|
readonly redirect_url_error: "Couldn\u2019t get the redirect URL.";
|
|
@@ -359,17 +367,20 @@ export declare const TranslationProvider: (props: {
|
|
|
359
367
|
readonly optional: "optional";
|
|
360
368
|
} = {
|
|
361
369
|
readonly error_heading: "Something unexpected happened";
|
|
362
|
-
readonly undo: "
|
|
370
|
+
readonly undo: "Change answer";
|
|
363
371
|
readonly conversation_history: "Conversation history";
|
|
364
372
|
readonly jump_to_current: "Jump to current question";
|
|
365
373
|
readonly send: "Send";
|
|
374
|
+
readonly submitting: "Sending your application…";
|
|
366
375
|
readonly skip: "Skip";
|
|
367
376
|
readonly skipped: "Skipped";
|
|
368
377
|
readonly submission_closed: "This role is no longer accepting applications.";
|
|
369
378
|
readonly submission_duplicate: "It looks like you've already applied for this role.";
|
|
370
379
|
readonly submission_retryable: "We couldn't submit your application. Please try again.";
|
|
371
|
-
readonly
|
|
380
|
+
readonly submission_failed: "We couldn't submit your application. Choose Restart to try again.";
|
|
381
|
+
readonly submission_unknown: "We couldn't confirm whether your application was sent. Please check your email for a confirmation. If nothing arrives, choose Restart to apply again.";
|
|
372
382
|
readonly submission_unreadable_document: "We couldn't read that file. Please upload a different one.";
|
|
383
|
+
readonly submission_still_working: "Still working — the employer's application system is taking a little longer than usual. Please keep this window open.";
|
|
373
384
|
readonly file_preparing: {
|
|
374
385
|
readonly one: "Preparing your file…";
|
|
375
386
|
readonly other: "Preparing your files…";
|
|
@@ -388,7 +399,6 @@ export declare const TranslationProvider: (props: {
|
|
|
388
399
|
readonly submission_redirect_message: "Almost there! Please complete your submission here:";
|
|
389
400
|
readonly complete_submission: "Complete submission";
|
|
390
401
|
readonly submission_completed: "Submission completed!";
|
|
391
|
-
readonly submission_failed: "Failed to submit";
|
|
392
402
|
readonly close_application: "Close application";
|
|
393
403
|
readonly invalid_state: "Invalid application state";
|
|
394
404
|
readonly redirect_url_error: "Couldn\u2019t get the redirect URL.";
|
|
@@ -448,17 +458,20 @@ export declare const TranslationProvider: (props: {
|
|
|
448
458
|
}>(options: {
|
|
449
459
|
overrides: Partial<import('@inploi/i18n/translation').TranslationDict<{
|
|
450
460
|
readonly error_heading: "Something unexpected happened";
|
|
451
|
-
readonly undo: "
|
|
461
|
+
readonly undo: "Change answer";
|
|
452
462
|
readonly conversation_history: "Conversation history";
|
|
453
463
|
readonly jump_to_current: "Jump to current question";
|
|
454
464
|
readonly send: "Send";
|
|
465
|
+
readonly submitting: "Sending your application…";
|
|
455
466
|
readonly skip: "Skip";
|
|
456
467
|
readonly skipped: "Skipped";
|
|
457
468
|
readonly submission_closed: "This role is no longer accepting applications.";
|
|
458
469
|
readonly submission_duplicate: "It looks like you've already applied for this role.";
|
|
459
470
|
readonly submission_retryable: "We couldn't submit your application. Please try again.";
|
|
460
|
-
readonly
|
|
471
|
+
readonly submission_failed: "We couldn't submit your application. Choose Restart to try again.";
|
|
472
|
+
readonly submission_unknown: "We couldn't confirm whether your application was sent. Please check your email for a confirmation. If nothing arrives, choose Restart to apply again.";
|
|
461
473
|
readonly submission_unreadable_document: "We couldn't read that file. Please upload a different one.";
|
|
474
|
+
readonly submission_still_working: "Still working — the employer's application system is taking a little longer than usual. Please keep this window open.";
|
|
462
475
|
readonly file_preparing: {
|
|
463
476
|
readonly one: "Preparing your file…";
|
|
464
477
|
readonly other: "Preparing your files…";
|
|
@@ -477,7 +490,6 @@ export declare const TranslationProvider: (props: {
|
|
|
477
490
|
readonly submission_redirect_message: "Almost there! Please complete your submission here:";
|
|
478
491
|
readonly complete_submission: "Complete submission";
|
|
479
492
|
readonly submission_completed: "Submission completed!";
|
|
480
|
-
readonly submission_failed: "Failed to submit";
|
|
481
493
|
readonly close_application: "Close application";
|
|
482
494
|
readonly invalid_state: "Invalid application state";
|
|
483
495
|
readonly redirect_url_error: "Couldn\u2019t get the redirect URL.";
|