@inploi/plugin-chatbot 14.0.0 → 14.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cdn/index.js +5 -5
- package/dist/{chatbot-body-bb8289cb.js → chatbot-body-77c91e40.js} +1449 -1409
- package/dist/chatbot-body-a078e4eb.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 +24 -18
- package/dist/{index-3a093ba1.js → index-21fc767e.js} +197 -183
- package/dist/index-bc9b2b2e.cjs +5 -0
- package/dist/interpreter.d.ts +2 -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 +3 -3
- 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-bc9b2b2e.cjs"),Wt=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 E,T;if(y.type!=="integration-application-submit"||!e.data.nodeHistory.includes(y.id))return[];const C=y.data.key?(E=i())==null?void 0:E[y.data.key]:void 0;return(C==null?void 0:C.type)==="integration"&&((T=Jt(C.value,void 0))==null?void 0:T.verdict)==="not_submitted"?[]:[y.id]}));const A={...r.service,log:y=>r.service.log({...y,customProperties:{...y.customProperties,...r.customProperties}})},F=async(y,C)=>{const M=k.signal;if(M.aborted)return;const E=i(),T=l(),H=(T==null?void 0:T.submitNodeId)===y.id?e.nodes.find(V=>{var q;return V.id===T.fileQuestionNodeId&&V.type==="question-file"&&((q=E==null?void 0:E[V.data.key])==null?void 0:q.type)!=="file"}):void 0;if(H)return F(H,C);h==null||h(y,C);try{await Dr({flow:e,analytics:A,logger:t,talentBankClient:s,apiClient:o,context:a,node:y,submissions:E,applicationRecovery:T,setApplicationRecovery:async V=>{if(!M.aborted)try{await d(V)}catch(q){t.error("Failed to persist application recovery",q)}},forceSubmitConfirmation:(T==null?void 0:T.submitNodeId)===y.id,persistWriteBarrier:v,signal:M,t:m,chat:{sendMessage:async V=>p.send({groupId:y.id,message:V,signal:M}),userInput:async V=>p.input({input:V,signal:M}),setSubmission:(V,q)=>{M.aborted||p.setSubmission(V,q)}},next:V=>{if(M.aborted)return;const q=(T==null?void 0:T.fileQuestionNodeId)===y.id?T.submitNodeId:V,B=q?e.nodes.find(W=>W.id===q):Tr({childNode:y,nodes:e.nodes});return B?F(B,y):x==null?void 0:x(y)},end:()=>{M.aborted||x==null||x(y)}})}catch(V){if(V instanceof n.AbortedError)return;throw V}};return{interpret:async y=>{const C=e.nodes.find(M=>M.id===y)??n.getHeadOrThrow(e.nodes);return F(C)},undo:y=>{var q;if((q=e.data.startedWriteNodeIds)!=null&&q.length||e.data.isFinished)return{removed:0};const C=n.getCorrectionNodeId(e),M=C?y.lastIndexOf(C):-1,E=e.nodes.find(B=>B.id===C);if(M===-1||!E)return{removed:0};const T=e.nodes.find(B=>B.id===y[y.length-1]);k.abort();const H=y.splice(M);e.data.messages=e.data.messages.filter(B=>!B.groupId||!H.includes(B.groupId)),e.data.currentInput=null;const V=i();for(const B of H.slice(1)){const W=e.nodes.find(S=>S.id===B);if(!(!W||!V||W.id===C)&&("key"in W.data&&W.data.key&&delete V[W.data.key],"keys"in W.data))for(const S of Object.values(W.data.keys))typeof S=="string"&&delete V[S]}return k=new AbortController,F(E,T),{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 Qr({...e,node:r});case"text":return Ur({...e,node:r});case"image":return zr({...e,node:r});case"question-text":return Kr({...e,node:r});case"question-enum":return Hr({...e,node:r});case"question-number":return Wr({...e,node:r});case"question-phone":return Gr({...e,node:r});case"question-boolean":return Jr({...e,node:r});case"question-file":return Xr({...e,node:r});case"question-address":return Zr({...e,node:r});case"end-flow":return Yr({...e,node:r});case"if-block":return qr({...e,node:r});case"jump":return Rr({...e,node:r});case"link":return jr({...e,node:r});case"integration-application-submit":return $r({...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)}async function $r({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 F;if((F=d.data.startedWriteNodeIds)!=null&&F.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 A=async N=>{var q,B,W;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 M=((q=d.data.startedWriteNodeIds)==null?void 0:q.includes(s.id))===!0;if((p==null?void 0:p.submitNodeId)===s.id&&await v(void 0),M||(d.data.startedWriteNodeIds=[...d.data.startedWriteNodeIds??[],s.id]),await h().catch(S=>a.error("Failed to persist application write barrier",S)),m.aborted)return;let E;const T=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(S=>(E=S,Wt.isApiErrorWithData(S)?S.data:S));if(m.aborted)return;s.data.key&&e.setSubmission(s.data.key,{type:"integration",value:T});const H=n.H(T);if(H&&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:H.service,response:H.response,flow_type:"CHATBOT_DRAWER",job:d.job}}),n.K(T)){const{redirect_url:S,message:L,button_text:P}=T.integration_response.data;await e.sendMessage({type:"text",author:"bot",text:L??k("submission_redirect_message")});try{const $=new URL(S);y&&!$.searchParams.has("anonymous_id")&&$.searchParams.set("anonymous_id",y),await e.sendMessage({type:"link",href:$.toString(),text:P??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:$.toString(),job:d.job}})}})}catch($){a.error(`Invalid redirect URL: ${S}`,$),e.sendMessage({type:"system",variant:"error",text:k("redirect_url_error")})}return r(s.nextId)}if((T==null?void 0:T.success)===!0)return s.data.skipConfirmation!==!0&&await e.sendMessage({type:"system",variant:"success",text:k("submission_completed")}),r(s.nextId);const V=Jt(T,E);if((V==null?void 0:V.verdict)==="not_submitted"&&(M||(d.data.startedWriteNodeIds=(B=d.data.startedWriteNodeIds)==null?void 0:B.filter(S=>S!==s.id)),(p==null?void 0:p.submitNodeId)===s.id&&await v(p),await h().catch(S=>a.error("Failed to persist application write barrier release",S))),V){a.error(E??V.message);const S=V.phase==="submit"&&V.verdict==="confirmed"&&V.code==="unreadable_document"&&typeof V.field=="string"&&V.status!==void 0&&V.status>=400&&V.status<500&&((W=i==null?void 0:i[V.field])==null?void 0:W.type)==="file"?V.field:void 0,L=S===void 0?void 0:d.nodes.find(P=>P.type==="question-file"&&P.data.key===S);return L&&S!==void 0?(e.setSubmission(S,null),await v({fileQuestionNodeId:L.id,submitNodeId:s.id}),await e.sendMessage({type:"system",variant:"error",text:k("submission_unreadable_document")}),r(L.id)):V.status===409&&V.phase==="submit"&&V.verdict==="confirmed"?(await e.sendMessage({type:"system",variant:"info",text:k("submission_duplicate")}),t()):V.status===410&&V.code==="job_closed"?(await e.sendMessage({type:"system",variant:"info",text:k("submission_closed")}),t()):V.phase==="submit"&&V.verdict==="unknown"?(await e.sendMessage({type:"system",variant:"warning",text:k("submission_unknown")}),t()):V.phase==="workflow"&&V.retryable===!0&&V.verdict==="not_submitted"?(await e.sendMessage({type:"system",variant:"error",text:k("submission_retryable")}),A(!1)):(await e.sendMessage({type:"system",variant:"error",text:k("submission_failed")}),t())}return a.error(E??T),await e.sendMessage({type:"system",variant:"error",text:k("submission_failed")}),t()};await A(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 Wt.ApiError?r.status:void 0,phase:i("phase"),retryable:l("retryable"),verdict:i("verdict"),code:i("code"),field:i("field")}};async function jr({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 qr({submissions:e,next:r,node:t,context:s}){r(Nr(t,{submissions:e,context:s})?t.branchId:t.nextId)}async function Ur({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 zr({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 Wr({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 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:"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 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:"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 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:"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 Zr({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 Xr({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 Yr({chat:e,end:r,node:t}){await e.sendMessage({type:"system",variant:"info",text:t.data.systemMessage}),r()}async function Qr({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 A=d.filter(F=>!F.matched&&F.severity===k);A.length&&m.push((k==="hard"?"Role requirements":"Other things to consider")+`
|
|
2
|
+
`+A.map(F=>`• ${F.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 We;function es(e){return We==null?void 0:We.get(e)}var Ge;function ts(e){return Ge==null?void 0:Ge.get(e)}var He;function rs(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 G(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??rs(e.reference,d.lang)??(p?ts(d.lang):null)??s.message??es(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 ss(e,r){return Object.hasOwn(e,r)&&r!=="__proto__"&&r!=="prototype"&&r!=="constructor"}function ns(e,r){const t=[...new Set(e)];return t.length>1?`(${t.join(` ${r} `)})`:t[0]??"never"}function is(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 as=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}},os=/^[\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)&&G(this,"input",t,s),t}}}function Xt(e){return{kind:"validation",type:"email",reference:Xt,expects:null,async:!1,requirement:os,message:e,"~run"(r,t){return r.typed&&!this.requirement.test(r.value)&&G(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&&G(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)&&G(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&&G(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)&&G(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)&&G(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)&&G(this,"URL",r,t),r}}}function ls(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 G(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:G(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:G(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]=ls(l);else if(l.type!=="exact_optional"&&l.type!=="optional"&&l.type!=="nullish"&&(G(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 G(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:ns(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:G(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(ss(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 G(this,"type",s,a);return s}}}function ee(e){return{kind:"schema",type:"string",reference:ee,expects:"string",async:!1,message:e,get"~standard"(){return ae(this)},"~run"(r,t){return typeof r.value=="string"?r.typed=!0:G(this,"type",r,t),r}}}function us(e,r,t){const s=e["~run"]({value:r},Be(t));if(s.issues)throw new as(s.issues);return s.value}function cs(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 ds(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 fs(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}}),hs="https://api.mapbox.com/search/searchbox/v1/suggest",ps="ZzRDWFU0dTZ3SF9aWk9RNGl6QzZaWS5RZmlFak13a0hPbGxXZXlNSGN5RUhObUJ6TXpSV08yUW5OdE5tSTZJU1lpd2lJb1JYYXRObmJ2Tm5iaGhHZWx4V1lpb2pJMUp5ZS5rcA==",ys=e=>atob(e).split("").reverse().join(""),le=ce({name:ee()}),ms=ce({suggestions:rr(ce({full_address:Ee(ee()),place_formatted:Ee(ee()),name:Ee(ee()),mapbox_id:ee(),context:cs(ce({address:le,street:le,neighborhood:le,locality:le,district:le,place:le,region:le,postcode:le,country:le}))}))}),gs=({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(hs);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",ys(ps));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=ds(ms,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,A,F,N,y,C,M,E;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:((A=h.context.neighborhood)==null?void 0:A.name)??((F=h.context.locality)==null?void 0:F.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:(M=h.context.postcode)==null?void 0:M.name,country:(E=h.context.country)==null?void 0:E.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")})]})},bs=({input:e,onSubmitSuccess:r,logger:t})=>{const{t:s}=n.useTranslation(),[a,o]=n.h(),{enabled:i,getPredictions:l}=gs({logger:t,t:s}),[d,p]=n.h(i?"query":"manual"),[v,x]=n.h(""),[h,m]=n.h(),k=n._(),A=n._(),F=y=>{var M;if(n.invariant(i,"Query state should not be enabled"),y=y.trim(),y===((M=k.current)==null?void 0:M.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(E=>{k.current===C&&(k.current=void 0,m(E.ok?{query:y,status:"done",items:E.data}:{query:y,status:"failed",error:E.error}))},E=>{k.current===C&&(k.current=void 0,t.error("Failed to get address details",E),m({query:y,status:"failed",error:s("address_error")}))})},N=(y,C)=>{o(M=>({...M,[y]:C}))};switch(d){case"query":return n.invariant(i,"Query state should not be enabled"),n.o(vs,{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(M=>M.id===y):void 0;C&&(A.current!==y&&o(C.address),A.current=y,p("details"))},onAddressSearch:F,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})}},vs=({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"],xs=ir(or),ws="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})})),_s=({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=us(xs,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:ws,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)})})]})},ks=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),Cs=n.isSubmissionOfType("file"),St=3,rt=e=>{const r=e.lastIndexOf(".");return r===-1?[e,""]:[e.slice(0,r),e.slice(r)]},Ss=({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}),Is=(e,r)=>{const[t,s]=rt(e);return`${t.slice(0,r)}${s}`},Vt=e=>({name:Is(e.name,42),sizeKb:e.size/1e3}),Vs=({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(Cs(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=A=>{if(!A.length)return{type:"required",message:h("validation_file")};if(!n.U(A,e.config.extensions))return{type:"validate",message:h("validation_file_ext",{ext:e.config.extensions.join(", ")})};if(e.config.fileSizeLimitKib&&Ct(A)>e.config.fileSizeLimitKib)return{type:"max",message:h("validation_file_size",{size:n.V(e.config.fileSizeLimitKib)})};if(!e.config.allowMultiple&&A.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:A=>{if(A.preventDefault(),s.status==="pending"||s.status==="error")return;const F=m(i);F?a({status:"error",error:F}):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(A=>{const[F,N]=rt(A.name);return n.o(It,{class:"flex overflow-hidden",children:[n.o("span",{class:"block truncate",children:F}),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(A=>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:A.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 A=>{n.invariant(A.target instanceof HTMLInputElement);const F=A.target.files?Array.from(A.target.files):[];if(A.target.value="",!F.length)return;const N=++o.current,y=s.status==="ready",C=F.map(Vt),M=m(C);if(M)return a({status:"error",error:M});a({status:"pending",files:C});try{const E=await Promise.all(F.map(async T=>({...Vt(T),data:await ks(T)})));o.current===N&&a({status:"ready",files:E})}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,X=e=>e==null;const dr=e=>typeof e=="object";var z=e=>!X(e)&&!Array.isArray(e)&&dr(e)&&!ye(e),Fs=e=>z(e)&&e.target?Le(e.target)?e.target.checked:e.target.value:e,As=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,Es=(e,r)=>e.has(As(r)),Ms=e=>{const r=e.constructor&&e.constructor.prototype;return z(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&&!(z(e)&&Ms(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||!z(e))return t;const s=(Re(r)?[r]:it(r)).reduce((a,o)=>X(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",R=(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=z(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"},Ns=n.Cn.createContext(null);Ns.displayName="HookFormControlContext";var Ts=(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 Ls=typeof window<"u"?n.Cn.useLayoutEffect:n.Cn.useEffect;var Q=e=>typeof e=="string",Ds=(e,r,t,s,a)=>Q(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=>X(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)||z(i)&&z(l)||Array.isArray(i)&&Array.isArray(l)?!fe(i,l,t):!Object.is(i,l))return!1}}return!0}const Os=n.Cn.createContext(null);Os.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&&z(a)&&o){const i=hr(a,o);z(i)&&(t[s]=i)}else e[s]&&(t[s]=o)}return t}var Z=e=>z(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",Bs=e=>ot(e)||Le(e),Je=e=>De(e)&&e.isConnected;function Rs(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 Ps(e){for(const r in e)if(e.hasOwnProperty(r)&&!j(e[r]))return!1;return!0}function U(e,r){const t=Array.isArray(r)?r:Re(r)?[r]:it(r),s=t.length===1?e:Rs(e,t),a=t.length-1,o=t[a];return s&&delete s[o],a!==0&&(z(s)&&Z(s)||Array.isArray(s)&&Ps(s))&&U(e,t.slice(0,-1)),e}var $s=e=>{for(const r in e)if(re(e[r]))return!0;return!1};function yr(e){return Array.isArray(e)||z(e)&&!$s(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,X(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&&Q(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 js=(e,r,t,s)=>{const a={};for(const o of e){const i=_(r,o);i&&R(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:z(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 qs=e=>!!e&&!!e.validate&&!!(re(e.validate)&&e.validate.constructor.name===Dt||z(e.validate)&&Object.values(e.validate).find(r=>r.constructor.name===Dt)),Us=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(z(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 zs=(e,r,t,s)=>{t(e);const{name:a,...o}=e;return Z(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))),Ws=(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,Gs=(e,r)=>!nt(_(e,r)).length&&U(e,r),Hs=(e,r,t)=>{const s=Me(_(e,t));return R(s,"root",r[t]),R(e,t,s),e};function Rt(e,r,t="validate"){if(Q(e)||Array.isArray(e)&&e.every(Q)||ne(e)&&!e)return{type:t,message:Q(e)?e:"",ref:r}}var be=e=>z(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:A,valueAsNumber:F,mount:N}=e._f,y=_(t,A);if(!N||r.has(A))return{};const C=l?l[0]:i,M=S=>{a&&C.reportValidity&&(C.setCustomValidity(ne(S)?"":S||""),C.reportValidity())},E={},T=ot(i),H=Le(i),V=T||H,q=(F||at(i))&&j(i.value)&&j(y)||De(i)&&i.value===""||y===""||Array.isArray(y)&&!y.length,B=fr.bind(null,A,s,E),W=(S,L,P,$=ue.maxLength,te=ue.minLength)=>{const Y=S?L:P;E[A]={type:S?$:te,message:Y,ref:i,...B(S?$:te,Y)}};if(o?!Array.isArray(y)||!y.length:d&&(!V&&(q||X(y))||ne(y)&&!y||H&&!mr(l).isValid||T&&!br(l).isValid)){const{value:S,message:L}=Q(d)?{value:!!d,message:d}:be(d);if(S&&(E[A]={type:ue.required,message:L,ref:C,...B(ue.required,L)},!s))return M(L),E}if(!q&&(!X(x)||!X(h))){let S,L;const P=be(h),$=be(x);if(!X(y)&&!isNaN(y)){const te=i.valueAsNumber||y&&+y;X(P.value)||(S=te>P.value),X($.value)||(L=te<$.value)}else{const te=i.valueAsDate||new Date(y),Y=Se=>new Date(new Date().toDateString()+" "+Se),ke=i.type=="time",Ce=i.type=="week";Q(P.value)&&y&&(S=ke?Y(y)>Y(P.value):Ce?y>P.value:te>new Date(P.value)),Q($.value)&&y&&(L=ke?Y(y)<Y($.value):Ce?y<$.value:te<new Date($.value))}if((S||L)&&(W(!!S,P.message,$.message,ue.max,ue.min),!s))return M(E[A].message),E}if((p||v)&&!q&&(Q(y)||o&&Array.isArray(y))){const S=be(p),L=be(v),P=!X(S.value)&&y.length>+S.value,$=!X(L.value)&&y.length<+L.value;if((P||$)&&(W(P,S.message,L.message),!s))return M(E[A].message),E}if(m&&!q&&Q(y)){const{value:S,message:L}=be(m);if(Oe(S)&&!y.match(S)&&(E[A]={type:ue.pattern,message:L,ref:i,...B(ue.pattern,L)},!s))return M(L),E}if(k){if(re(k)){const S=await k(y,t),L=Rt(S,C);if(L&&(E[A]={...L,...B(ue.validate,L.message)},!s))return M(L.message),E}else if(z(k)){let S={};for(const L in k){if(!Z(S)&&!s)break;const P=Rt(await k[L](y,t),C,L);P&&(S={...P,...B(L,P.message)},M(P.message),s&&(E[A]=S))}if(!Z(S)&&(E[A]={ref:C,...S},!s))return E}}return M(!0),E};const Js={mode:se.onSubmit,reValidateMode:se.onChange,shouldFocusError:!0};function Zs(e={}){let r={...Js,...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=z(r.defaultValues)||z(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,A=u=>c=>{clearTimeout(p),p=setTimeout(u,c)},F=async u=>{if(!i.keepIsValid&&!r.disabled&&(x.isValid||h.isValid||u)){let c;r.resolver?(c=Z((await V()).errors),N()):c=await B(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?R(t.validatingFields,f,c):U(t.validatingFields,f))}),m.state.next({validatingFields:t.validatingFields,isValidating:!Z(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 I=f(_(s,u),w.argA,w.argB);b&&R(s,u,I)}if(g&&Array.isArray(_(t.errors,u))){const I=f(_(t.errors,u),w.argA,w.argB);b&&R(t.errors,u,I),Gs(t.errors,u)}if((x.touchedFields||h.touchedFields)&&g&&Array.isArray(_(t.touchedFields,u))){const I=f(_(t.touchedFields,u),w.argA,w.argB);b&&R(t.touchedFields,u,I)}(x.dirtyFields||h.dirtyFields)&&(t.dirtyFields=ve(a,o)),m.state.next({name:u,isDirty:S(u,c),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else R(o,u,c)},C=(u,c)=>{R(t.errors,u,c),m.state.next({errors:t.errors})},M=u=>{t.errors=u,m.state.next({errors:t.errors,isValid:!1})},E=(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?R(o,u,c?g:Tt(b._f)):$(u,g),i.mount&&!i.action&&F()}},T=(u,c,f,w,b)=>{let g=!1,I=!1;const D={name:u};if(!r.disabled){if(!f||w){(x.isDirty||h.isDirty)&&(I=t.isDirty,t.isDirty=D.isDirty=S(),g=I!==D.isDirty);const O=fe(_(a,u),c);I=!!_(t.dirtyFields,u),O?U(t.dirtyFields,u):R(t.dirtyFields,u,!0),D.dirtyFields=t.dirtyFields,g=g||(x.dirtyFields||h.dirtyFields)&&I!==!O}if(f){const O=_(t.touchedFields,u);O||(R(t.touchedFields,u,f),D.touchedFields=t.touchedFields,g=g||(x.touchedFields||h.touchedFields)&&O!==f)}g&&b&&m.state.next(D)}return g?D:{}},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=A(()=>C(u,f)),d(r.delayError)):(clearTimeout(p),d=null,f?R(t.errors,u,f):U(t.errors,u)),(f?!fe(b,f):b)||!Z(w)||g){const I={...w,...g&&ne(c)?{isValid:c}:{},errors:t.errors,name:u};t={...t,...I},m.state.next(I)}},V=async u=>(N(u,!0),await r.resolver(o,r.context,js(u||l.mount,s,r.criteriaMode,r.shouldUseNativeValidation))),q=async u=>{const{errors:c}=await V(u);if(N(u),u)for(const f of u){const w=_(c,f);w?R(t.errors,f,w):U(t.errors,f)}else t.errors=c;return c},B=async(u,c,f={valid:!0})=>{for(const w in u){const b=u[w];if(b){const{_f:g,...I}=b;if(g){const D=l.array.has(g.name),O=b._f&&qs(b._f);O&&x.validatingFields&&N([g.name],!0);const J=await Pt(b,l.disabled,o,k,r.shouldUseNativeValidation&&!c,D);if(O&&x.validatingFields&&N([g.name]),J[g.name]&&(f.valid=!1,c||e.shouldUseNativeValidation))break;!c&&(_(J,g.name)?D?Hs(t.errors,J,g.name):R(t.errors,g.name,J[g.name]):U(t.errors,g.name))}!Z(I)&&await B(I,c,f)}}return f.valid},W=()=>{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},S=(u,c)=>!r.disabled&&(u&&c&&R(o,u,c),!fe(lt(),a)),L=(u,c,f)=>Ds(u,l,{...i.mount?o:j(c)?a:Q(u)?{[u]:c}:c},f,c),P=u=>nt(_(i.mount?o:a,u,r.shouldUnregister?_(a,u,[]):[])),$=(u,c,f={})=>{const w=_(s,u);let b=c;if(w){const g=w._f;g&&(!g.disabled&&R(o,u,gr(c,g)),b=De(g.ref)&&X(c)?"":c,pr(g.ref)?[...g.ref.options].forEach(I=>I.selected=b.includes(I.value)):g.refs?Le(g.ref)?g.refs.forEach(I=>{(!I.defaultChecked||!I.disabled)&&(Array.isArray(b)?I.checked=!!b.find(D=>D===I.value):I.checked=b===I.value||!!b)}):g.refs.forEach(I=>I.checked=I.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)&&T(u,b,f.shouldTouch,f.shouldDirty,!0),f.shouldValidate&&Se(u)},te=(u,c,f)=>{for(const w in c){if(!c.hasOwnProperty(w))return;const b=c[w],g=u+"."+w,I=_(s,g);(l.array.has(u)||z(b)||I&&!I._f)&&!ye(b)?te(g,b,f):$(g,b,f)}},Y=(u,c,f={})=>{const w=_(s,u),b=l.array.has(u),g=K(c);R(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:S(u,g)})):w&&!w._f&&!X(g)?te(u,g,f):$(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=O=>{w=Number.isNaN(O)||ye(O)&&isNaN(O.getTime())||fe(O,_(o,f,O))},I=Lt(r.mode),D=Lt(r.reValidateMode);if(b){let O,J;const pe=c.type?Tt(b._f):Fs(u),de=u.type===Ft.BLUR||u.type===Ft.FOCUS_OUT,Vr=!Us(b._f)&&!r.resolver&&!_(t.errors,f)&&!b._f.deps||Ws(de,_(t.touchedFields,f),t.isSubmitted,D,I),ze=Ot(f,l,de);R(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 Ke=T(f,pe,de),Fr=!Z(Ke)||ze;if(!de&&m.state.next({name:f,type:u.type,values:K(o)}),Vr)return(x.isValid||h.isValid)&&(r.mode==="onBlur"?de&&F():de||F()),Fr&&m.state.next({name:f,...ze?{}:Ke});if(!de&&ze&&m.state.next({...t}),r.resolver){const{errors:gt}=await V([f]);if(N([f]),g(pe),w){const Ar=Bt(t.errors,s,f),bt=Bt(gt,s,Ar.name||f);O=bt.error,f=bt.name,J=Z(gt)}}else N([f],!0),O=(await Pt(b,l.disabled,o,k,r.shouldUseNativeValidation))[f],N([f]),g(pe),w&&(O?J=!1:(x.isValid||h.isValid)&&(J=await B(s,!0)));w&&(b._f.deps&&(!Array.isArray(b._f.deps)||b._f.deps.length>0)&&Se(b._f.deps),H(f,J,O,Ke))}},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 q(j(u)?u:b);f=Z(g),w=u?!b.some(I=>_(g,I)):f}else u?(w=(await Promise.all(b.map(async g=>{const I=_(s,g);return await B(I&&I._f?{[g]:I}:I)}))).every(Boolean),!(!w&&!t.isValid)&&F()):w=f=await B(s);return m.state.next({...!Q(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:Q(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=>U(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:I,type:D,...O}=b;R(t.errors,u,{...O,...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(L(void 0,c),f)}):L(u,c,!0),dt=u=>m.state.subscribe({next:c=>{Ks(u.name,c.name,u.exact)&&zs(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||(U(s,f),U(o,f)),!c.keepError&&U(t.errors,f),!c.keepDirty&&U(t.dirtyFields,f),!c.keepTouched&&U(t.touchedFields,f),!c.keepIsValidating&&U(t.validatingFields,f),!r.shouldUnregister&&!c.keepDefaultValue&&U(a,f);m.state.next({values:K(o)}),m.state.next({...t,...c.keepDirty?{isDirty:S()}:{}}),!c.keepIsValid&&F()},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&&F()}},qe=(u,c={})=>{let f=_(s,u);const w=ne(c.disabled)||ne(r.disabled);return R(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}):E(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,I=Bs(g),D=f._f.refs||[];if(I?D.find(O=>O===g):g===f._f.ref)return;R(s,u,{_f:{...f._f,...I?{refs:[...D.filter(Je),g,...Array.isArray(_(a,u))?[{}]:[]],ref:{type:g.type,name:u}}:{ref:g}}}),E(u,!1,void 0,g)}else f=_(s,u,{}),f._f&&(f._f.mount=!1),(r.shouldUnregister||c.shouldUnregister)&&!(Es(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:I}=await V();N(),t.errors=g,b=K(I)}else await B(s);if(l.disabled.size)for(const g of l.disabled)U(b,g);if(U(t.errors,"root"),Z(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:Z(t.errors)&&!w,submitCount:t.submitCount+1,errors:t.errors}),w)throw w},Cr=(u,c={})=>{_(s,u)&&(j(c.defaultValue)?Y(u,K(_(a,u))):(Y(u,c.defaultValue),R(a,u,K(c.defaultValue))),c.keepTouched||U(t.touchedFields,u),c.keepDirty||(U(t.dirtyFields,u),t.isDirty=c.defaultValue?S(u,K(_(a,u))):S()),c.keepError||(U(t.errors,u),x.isValid&&F()),m.state.next({...t}))},pt=(u,c={})=>{const f=u?K(u):a,w=K(f),b=Z(u),g=b?a:w;if(c.keepDefaultValues||(a=f),!c.keepValues){if(c.keepDirtyValues){const I=new Set([...l.mount,...Object.keys(ve(a,o))]);for(const D of Array.from(I)){const O=_(t.dirtyFields,D),J=_(o,D),pe=_(g,D);O&&!j(J)?R(g,D,J):!O&&!j(pe)&&Y(D,pe)}}else{if(st&&j(u))for(const I of l.mount){const D=_(s,I);if(D&&D._f){const O=Array.isArray(D._f.refs)?D._f.refs[0]:D._f.ref;if(De(O)){const J=O.closest("form");if(J){J.reset();break}}}}if(c.keepFieldsRef)for(const I of l.mount)Y(I,_(g,I));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&&!Z(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:V,_updateIsValidating:N,_focusError:Ue,_getWatch:L,_getDirty:S,_setValid:F,_setFieldArray:y,_setDisabledField:ft,_setErrors:M,_getFieldArray:P,_reset:pt,_resetDefaultValues:()=>re(r.defaultValues)&&r.defaultValues().then(u=>{yt(u,r.resetOptions),m.state.next({isLoading:!1})}),_removeUnmounted:W,_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:Y,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}=Zs(e);r.current={...l,formState:s}}const o=r.current.control;return o._options=e,Ls(()=>{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(()=>Ts(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()}},Xs=(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))}},Ys=(e,r)=>{r.shouldUseNativeValidation&&Xs(e,r);const t={};for(const s in e){const a=_(r.fields,s),o=Object.assign(e[s]||{},{ref:a&&a.ref});if(Qs(r.names||Object.keys(e),s)){const i=Object.assign({},_(t,s));R(i,"root",o),R(t,s,i)}else R(t,s,o)}return t},Qs=(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(fs(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=is(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:Ys(d,o)}}return{values:t.raw?s:l.output,errors:{}}})}catch(l){return Promise.reject(l)}}};const jt=27,qt=12,Ut=10,en=n.isSubmissionOfType("enum"),tn=(e,r)=>{const t={min:e.minSelected??0,max:e.maxSelected??e.options.length};return $e(ce({checked:he(ar(ee(),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})))}))},rn=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}}}),sn=({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?{}:en(t)?Object.fromEntries(t.value.map(h=>[h,!0])):{}},resolver:tn(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:A,...F}=i(k);return n.o("li",{class:"relative",children:n.o(rn,{option:h,autoFocus:m===0,ref:N=>{N&&m===0&&(p.current=N),A(N)},id:k,...F,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})})]})},nn=n.isSubmissionOfType("number"),an=(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})))}))},on=({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:nn(s)?s.value:t?Number(t):void 0},resolver:an(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})]})},ln=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:""}},un="44",cn=/^[0-9 ]+$/,dn=n.isSubmissionOfType("string"),fn=n.isSubmissionOfType("phone"),hn=e=>{const r=he(ee(e("validation_country_code")),Ye(cn,e("validation_country_code"))),t=he(ee(e("validation_phone")),xe(1,e("validation_phone")),Qe(s=>s.replace(/[^0-9]/g,"")));return $e(ce({countryCode:r,phoneNumber:t}))},pn=({input:e,onSubmitSuccess:r})=>{var A;const t=e.key?(A=n.store.current$.value.flow)==null?void 0:A.data.submissions[e.key]:void 0,{t:s}=n.useTranslation(),[a,o]=n.h(),i=dn(t)?ln(t.value):fn(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??un,phoneNumber:(i==null?void 0:i.phoneNumber)??e.config.defaultValue.phoneNumber??""},resolver:hn(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(F=>{const N=F.phoneNumber.replace(/[^0-9]/g,""),y=F.countryCode.replace(/[^0-9]/g,"");o(void 0);const C=e.config.minChars??7,M=N.length+y.length;if(M<C)return o(s("validation_phone_min_chars",{count:C}));const E=e.config.maxChars;if(E!=null&&M>E)return o(s("validation_max_chars",{count:E}));e.config.submissionFormat==="phone"?r({type:"phone",value:{countryCode:y,phoneNumber:N}}):r({type:"string",value:k+F.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(([F,N])=>n.o("option",{value:N,children:[F," (+",N,")"]},F))})]}),n.o("input",{...h,id:"chat-input",type:"tel",inputMode:"tel",autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:F=>{F&&(m.current=F),x(F)},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}})]})},yn=({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"})]})]})})}),mn={date:{type:"date",inputMode:"text"},email:{type:"email",inputMode:"email",formNoValidate:!0},text:{type:"text",inputMode:"text"},url:{type:"url",inputMode:"url",formNoValidate:!0}},gn=n.isSubmissionOfType("string"),bn=(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(ee(r("validation_date")),Ye(/^\d{4}-\d{2}-\d{2}$/,r("validation_date"))),email:he(ee(r("validation_email")),Xt(r("validation_email")),xe(e.minChars??1,t.minLength),Ae(e.maxChars??1/0,t.maxLength)),text:he(ee(),xe(e.minChars??1,t.minLength),Ae(e.maxChars??1/0,t.maxLength)),url:he(ee(r("validation_url")),er(r("validation_url")),xe(e.minChars??1,t.minLength),Ae(e.maxChars??1/0,t.maxLength))}[e.format]}))},vn=({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:gn(s)?s.value:a??""},resolver:bn(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,...mn[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})]})},xn={text:vn,phone:pn,"multiple-choice":sn,boolean:_s,file:Vs,submit:yn,address:bs,number:on},wn=({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=xn[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 _n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var kn=function(e){return e instanceof RegExp},Cn=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"},Sn=function(e){var r=[];return e.forEach(function(t){Array.isArray(t)?r=r.concat(t):r.push(t)}),r};function In(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;kn(o)||(o=new RegExp("("+Cn(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 Vn=function(r,t,s){return Array.isArray(r)||(r=[r]),Sn(r.map(function(a){return vr(a)?In(a,t,s):a}))};const Ve=_n(Vn),Fn=/(\[[^\]]+\]\([^)]+\))/g,An=/\[([^\]]+)\]\(([^)]+)\)/,En=/(https?:\/\/[^\s]+)/g,Mn=/_(.*?)_/g,Nn=/\*\*(.*?)\*\*/g,Tn=/\\n|\n/g,Kt="text-accent-10 hover:text-accent-11 no-underline underline-offset-2 hover:underline",Ln=e=>{const r=Ve(e,Fn,(i,l)=>{const[,d,p]=i.match(An)??[];return p?n.o("a",{class:Kt,href:p,children:d??p},p+l):n.o("span",{children:"INVALID LINK"})}),t=Ve(r,En,(i,l)=>n.o("a",{class:Kt,href:i,children:i},i+l)),s=Ve(t,Mn,(i,l)=>n.o("em",{children:i},i+l)),a=Ve(s,Nn,(i,l)=>n.o("strong",{children:i},i+l));return Ve(a,Tn,(i,l)=>n.o("br",{},`br-${l}`))},Dn=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"}}),On=({children:e,className:r,animate:t,side:s,...a})=>n.o("p",{style:{transformOrigin:s==="left"?"0% 50%":"100% 50%"},class:Dn({className:r,side:s,animate:t}),...a,children:e}),Bn=({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"})})]})}),Rn=({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}),Pn={bot:"left",user:"right"},$n=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]"}}}),jn=({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:$n({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"?Ln(i.text):i.text;return n.o(n.k$1,{children:n.o(On,{animate:l,side:Pn[i.author],children:d},o)})}).with({type:"link"},i=>n.o(Bn,{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(Ss,{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(Rn,{},"typing")]})},qn=({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:A,abort:F,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 M;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:(M=a.analytics)==null?void 0:M.customProperties})}});return v(()=>N),A(m),()=>{n.chatStore.onInteractionFn$.value===k&&(n.chatStore.onInteractionFn$.value=()=>{}),F()}},[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(jn,{lastSentMessageFooter:!n.getCorrectionNodeId(a)||!p?null:n.o(Un,{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(wn,{logger:e})]})},Un=({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=qn;
|
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,16 +1,18 @@
|
|
|
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.";
|
|
15
17
|
readonly file_preparing: {
|
|
16
18
|
readonly one: "Preparing your file…";
|
|
@@ -30,7 +32,6 @@ export declare const TranslationProvider: (props: {
|
|
|
30
32
|
readonly submission_redirect_message: "Almost there! Please complete your submission here:";
|
|
31
33
|
readonly complete_submission: "Complete submission";
|
|
32
34
|
readonly submission_completed: "Submission completed!";
|
|
33
|
-
readonly submission_failed: "Failed to submit";
|
|
34
35
|
readonly close_application: "Close application";
|
|
35
36
|
readonly invalid_state: "Invalid application state";
|
|
36
37
|
readonly redirect_url_error: "Couldn\u2019t get the redirect URL.";
|
|
@@ -92,16 +93,18 @@ export declare const TranslationProvider: (props: {
|
|
|
92
93
|
children?: import('preact').ComponentChildren;
|
|
93
94
|
}) => import("preact").JSX.Element, useTranslation: <T extends {
|
|
94
95
|
readonly error_heading: "Something unexpected happened";
|
|
95
|
-
readonly undo: "
|
|
96
|
+
readonly undo: "Change answer";
|
|
96
97
|
readonly conversation_history: "Conversation history";
|
|
97
98
|
readonly jump_to_current: "Jump to current question";
|
|
98
99
|
readonly send: "Send";
|
|
100
|
+
readonly submitting: "Sending your application…";
|
|
99
101
|
readonly skip: "Skip";
|
|
100
102
|
readonly skipped: "Skipped";
|
|
101
103
|
readonly submission_closed: "This role is no longer accepting applications.";
|
|
102
104
|
readonly submission_duplicate: "It looks like you've already applied for this role.";
|
|
103
105
|
readonly submission_retryable: "We couldn't submit your application. Please try again.";
|
|
104
|
-
readonly
|
|
106
|
+
readonly submission_failed: "We couldn't submit your application. Choose Restart to try again.";
|
|
107
|
+
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
108
|
readonly submission_unreadable_document: "We couldn't read that file. Please upload a different one.";
|
|
106
109
|
readonly file_preparing: {
|
|
107
110
|
readonly one: "Preparing your file…";
|
|
@@ -121,7 +124,6 @@ export declare const TranslationProvider: (props: {
|
|
|
121
124
|
readonly submission_redirect_message: "Almost there! Please complete your submission here:";
|
|
122
125
|
readonly complete_submission: "Complete submission";
|
|
123
126
|
readonly submission_completed: "Submission completed!";
|
|
124
|
-
readonly submission_failed: "Failed to submit";
|
|
125
127
|
readonly close_application: "Close application";
|
|
126
128
|
readonly invalid_state: "Invalid application state";
|
|
127
129
|
readonly redirect_url_error: "Couldn\u2019t get the redirect URL.";
|
|
@@ -180,16 +182,18 @@ export declare const TranslationProvider: (props: {
|
|
|
180
182
|
readonly optional: "optional";
|
|
181
183
|
} = {
|
|
182
184
|
readonly error_heading: "Something unexpected happened";
|
|
183
|
-
readonly undo: "
|
|
185
|
+
readonly undo: "Change answer";
|
|
184
186
|
readonly conversation_history: "Conversation history";
|
|
185
187
|
readonly jump_to_current: "Jump to current question";
|
|
186
188
|
readonly send: "Send";
|
|
189
|
+
readonly submitting: "Sending your application…";
|
|
187
190
|
readonly skip: "Skip";
|
|
188
191
|
readonly skipped: "Skipped";
|
|
189
192
|
readonly submission_closed: "This role is no longer accepting applications.";
|
|
190
193
|
readonly submission_duplicate: "It looks like you've already applied for this role.";
|
|
191
194
|
readonly submission_retryable: "We couldn't submit your application. Please try again.";
|
|
192
|
-
readonly
|
|
195
|
+
readonly submission_failed: "We couldn't submit your application. Choose Restart to try again.";
|
|
196
|
+
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
197
|
readonly submission_unreadable_document: "We couldn't read that file. Please upload a different one.";
|
|
194
198
|
readonly file_preparing: {
|
|
195
199
|
readonly one: "Preparing your file…";
|
|
@@ -209,7 +213,6 @@ export declare const TranslationProvider: (props: {
|
|
|
209
213
|
readonly submission_redirect_message: "Almost there! Please complete your submission here:";
|
|
210
214
|
readonly complete_submission: "Complete submission";
|
|
211
215
|
readonly submission_completed: "Submission completed!";
|
|
212
|
-
readonly submission_failed: "Failed to submit";
|
|
213
216
|
readonly close_application: "Close application";
|
|
214
217
|
readonly invalid_state: "Invalid application state";
|
|
215
218
|
readonly redirect_url_error: "Couldn\u2019t get the redirect URL.";
|
|
@@ -271,16 +274,18 @@ export declare const TranslationProvider: (props: {
|
|
|
271
274
|
locale: string | undefined;
|
|
272
275
|
}, createTFunction: <T extends {
|
|
273
276
|
readonly error_heading: "Something unexpected happened";
|
|
274
|
-
readonly undo: "
|
|
277
|
+
readonly undo: "Change answer";
|
|
275
278
|
readonly conversation_history: "Conversation history";
|
|
276
279
|
readonly jump_to_current: "Jump to current question";
|
|
277
280
|
readonly send: "Send";
|
|
281
|
+
readonly submitting: "Sending your application…";
|
|
278
282
|
readonly skip: "Skip";
|
|
279
283
|
readonly skipped: "Skipped";
|
|
280
284
|
readonly submission_closed: "This role is no longer accepting applications.";
|
|
281
285
|
readonly submission_duplicate: "It looks like you've already applied for this role.";
|
|
282
286
|
readonly submission_retryable: "We couldn't submit your application. Please try again.";
|
|
283
|
-
readonly
|
|
287
|
+
readonly submission_failed: "We couldn't submit your application. Choose Restart to try again.";
|
|
288
|
+
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
289
|
readonly submission_unreadable_document: "We couldn't read that file. Please upload a different one.";
|
|
285
290
|
readonly file_preparing: {
|
|
286
291
|
readonly one: "Preparing your file…";
|
|
@@ -300,7 +305,6 @@ export declare const TranslationProvider: (props: {
|
|
|
300
305
|
readonly submission_redirect_message: "Almost there! Please complete your submission here:";
|
|
301
306
|
readonly complete_submission: "Complete submission";
|
|
302
307
|
readonly submission_completed: "Submission completed!";
|
|
303
|
-
readonly submission_failed: "Failed to submit";
|
|
304
308
|
readonly close_application: "Close application";
|
|
305
309
|
readonly invalid_state: "Invalid application state";
|
|
306
310
|
readonly redirect_url_error: "Couldn\u2019t get the redirect URL.";
|
|
@@ -359,16 +363,18 @@ export declare const TranslationProvider: (props: {
|
|
|
359
363
|
readonly optional: "optional";
|
|
360
364
|
} = {
|
|
361
365
|
readonly error_heading: "Something unexpected happened";
|
|
362
|
-
readonly undo: "
|
|
366
|
+
readonly undo: "Change answer";
|
|
363
367
|
readonly conversation_history: "Conversation history";
|
|
364
368
|
readonly jump_to_current: "Jump to current question";
|
|
365
369
|
readonly send: "Send";
|
|
370
|
+
readonly submitting: "Sending your application…";
|
|
366
371
|
readonly skip: "Skip";
|
|
367
372
|
readonly skipped: "Skipped";
|
|
368
373
|
readonly submission_closed: "This role is no longer accepting applications.";
|
|
369
374
|
readonly submission_duplicate: "It looks like you've already applied for this role.";
|
|
370
375
|
readonly submission_retryable: "We couldn't submit your application. Please try again.";
|
|
371
|
-
readonly
|
|
376
|
+
readonly submission_failed: "We couldn't submit your application. Choose Restart to try again.";
|
|
377
|
+
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
378
|
readonly submission_unreadable_document: "We couldn't read that file. Please upload a different one.";
|
|
373
379
|
readonly file_preparing: {
|
|
374
380
|
readonly one: "Preparing your file…";
|
|
@@ -388,7 +394,6 @@ export declare const TranslationProvider: (props: {
|
|
|
388
394
|
readonly submission_redirect_message: "Almost there! Please complete your submission here:";
|
|
389
395
|
readonly complete_submission: "Complete submission";
|
|
390
396
|
readonly submission_completed: "Submission completed!";
|
|
391
|
-
readonly submission_failed: "Failed to submit";
|
|
392
397
|
readonly close_application: "Close application";
|
|
393
398
|
readonly invalid_state: "Invalid application state";
|
|
394
399
|
readonly redirect_url_error: "Couldn\u2019t get the redirect URL.";
|
|
@@ -448,16 +453,18 @@ export declare const TranslationProvider: (props: {
|
|
|
448
453
|
}>(options: {
|
|
449
454
|
overrides: Partial<import('@inploi/i18n/translation').TranslationDict<{
|
|
450
455
|
readonly error_heading: "Something unexpected happened";
|
|
451
|
-
readonly undo: "
|
|
456
|
+
readonly undo: "Change answer";
|
|
452
457
|
readonly conversation_history: "Conversation history";
|
|
453
458
|
readonly jump_to_current: "Jump to current question";
|
|
454
459
|
readonly send: "Send";
|
|
460
|
+
readonly submitting: "Sending your application…";
|
|
455
461
|
readonly skip: "Skip";
|
|
456
462
|
readonly skipped: "Skipped";
|
|
457
463
|
readonly submission_closed: "This role is no longer accepting applications.";
|
|
458
464
|
readonly submission_duplicate: "It looks like you've already applied for this role.";
|
|
459
465
|
readonly submission_retryable: "We couldn't submit your application. Please try again.";
|
|
460
|
-
readonly
|
|
466
|
+
readonly submission_failed: "We couldn't submit your application. Choose Restart to try again.";
|
|
467
|
+
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
468
|
readonly submission_unreadable_document: "We couldn't read that file. Please upload a different one.";
|
|
462
469
|
readonly file_preparing: {
|
|
463
470
|
readonly one: "Preparing your file…";
|
|
@@ -477,7 +484,6 @@ export declare const TranslationProvider: (props: {
|
|
|
477
484
|
readonly submission_redirect_message: "Almost there! Please complete your submission here:";
|
|
478
485
|
readonly complete_submission: "Complete submission";
|
|
479
486
|
readonly submission_completed: "Submission completed!";
|
|
480
|
-
readonly submission_failed: "Failed to submit";
|
|
481
487
|
readonly close_application: "Close application";
|
|
482
488
|
readonly invalid_state: "Invalid application state";
|
|
483
489
|
readonly redirect_url_error: "Couldn\u2019t get the redirect URL.";
|