@inploi/plugin-chatbot 4.0.4 → 4.1.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.
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-4fe4e036.cjs");require("@inploi/sdk");const ot=({condition:e,context:r,submissions:n,ifBlock:s})=>{const[i,...a]=e.compareKey.split(".");if(!i)return!1;const o=Ft({context:r,key:i,path:a,submissions:n});if(!o)return!1;switch(o.type){case"address":{const u=t.get(o.value,a.join("."));switch(e.compare){case"equals":return u===e.compareValue;case"contains":return u?u.includes(e.compareValue):!1;case"notEquals":return u!==e.compareValue;case"notContains":return u?!u.includes(e.compareValue):!0}break}case"integration":{if(typeof o.value!="object"||Array.isArray(o.value))return!1;const u=t.get(o.value,a.join(".")),d={...s,data:{...s.data,compareKey:"_temp"}};switch(typeof u){case"boolean":return be(d,{submissions:{_temp:{value:u,type:"boolean"}},context:r});case"string":return be(d,{submissions:{_temp:{value:u,type:"string"}},context:r});case"number":return be(d,{submissions:{_temp:{value:u,type:"number"}},context:r});case"object":return Array.isArray(u)&&u.every(t.isString)?be(d,{submissions:{_temp:{value:u,type:"enum"}},context:r}):!1}break}case"boolean":{const u=e.compareValue==="true";switch(e.compare){case"equals":return o.value===u;case"notEquals":return o.value!==u}break}case"phone":case"string":{const u=o.type==="phone"?Fe(o.value):o.value;switch(e.compare){case"equals":return u===e.compareValue;case"contains":return u?u.includes(e.compareValue):!1;case"notEquals":return u!==e.compareValue;case"notContains":return u?!u.includes(e.compareValue):!0}break}case"number":{try{const u=Number(e.compareValue);switch(e.compare){case"equals":return o.value===u;case"notEquals":return o.value!==u;case"greaterThan":return o.value>u;case"greaterThanOrEqualTo":return o.value>=u;case"lessThan":return o.value<u;case"lessThanOrEqualTo":return o.value<=u}}catch{return console.error(`Failed to parse number in if-block ${s.id}`,o.value),!1}break}case"enum":switch(e.compare){case"equals":return o.value.length===1&&o.value[0]===e.compareValue;case"notEquals":return o.value.length===1&&o.value[0]!==e.compareValue;case"contains":return o.value.includes(e.compareValue);case"notContains":return!o.value.includes(e.compareValue)}break}},be=(e,{context:r,submissions:n})=>{const s="combinator"in e.data?e.data.conditions:[e.data];if(("combinator"in e.data?e.data.combinator:"and")==="or"){for(const a of s)if(ot({condition:a,context:r,submissions:n,ifBlock:e}))return!0;return!1}else{for(const a of s)if(!ot({condition:a,context:r,submissions:n,ifBlock:e}))return!1;return!0}},Qt=/{{\s*([^}]+?)\s*(?:\|\s*([^}]+?)\s*)?}}/g,Z=(e,{context:r,submissions:n})=>e.replace(Qt,(s,i,a="")=>{const[o,...u]=i.trim().split("."),d=Ft({key:o,path:u,submissions:n,context:r});if(!d)return a;switch(d.type){case"boolean":return d.value===!0?"true":"false";case"file":return d.value.map(p=>`${p.name} (${t.kbToReadableSize(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():a;case"phone":return Fe(d.value);case"integration":{if(typeof d.value!="object"||Array.isArray(d.value))break;const p=t.get(d.value,u.join("."));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(t.isString))return p.join(", ")}break}}return a}),Vt=({node:e,nodes:r,stopWhen:n})=>{if((n==null?void 0:n(e))===!0)return e;const s=e.nextId?r.find(i=>i.id===e.nextId):void 0;if(s)return Vt({node:s,nodes:r,stopWhen:n})},er=({childNode:e,nodes:r})=>{const s=r.filter(i=>i.type==="if-block").find(i=>{if(!i.branchId)return!1;const a=r.find(u=>u.id===i.branchId);if(!a)return!1;const o=Vt({node:a,nodes:r,stopWhen:u=>u.id===e.id});return!(!o||o.id!==e.id)});if(s!=null&&s.nextId)return r.find(i=>i.id===s.nextId)},tr=({flow:e,analytics:r,logger:n,context:s,apiClient:i,getSubmissions:a,chatService:o,onFlowEnd:u,onInterpret:d,t:p})=>{let x=new AbortController;const v={...r.service,log:k=>r.service.log({...k,customProperties:{...k.customProperties,...r.customProperties}})},h=async(k,y)=>{const A=a();d==null||d(k,y);try{await rr({flow:e,analytics:v,logger:n,apiClient:i,context:s,node:k,submissions:A,t:p,chat:{sendMessage:async S=>o.send({groupId:k.id,message:S,signal:x.signal}),userInput:async S=>o.input({input:S,signal:x.signal}),addToSubmissions:o.addToSubmissions},next:S=>{const E=S?e.nodes.find(g=>g.id===S):er({childNode:k,nodes:e.nodes});return E?h(E,k):u==null?void 0:u(k)},end:()=>u==null?void 0:u(k)})}catch(S){if(S instanceof t.AbortedError)return;throw S}};return{interpret:async k=>{const y=e.nodes.find(A=>A.id===k)??t.getHeadOrThrow(e.nodes);return h(y)},undo:k=>{let y=1;const A=e.nodes.find(E=>E.id===k[k.length-1]);for(let E=k.length-2;E>0;E--){const g=k[E],F=e.nodes.find(O=>O.id===g);if(!F||(y++,F.type.startsWith("question-")))break}x.abort(),x=new AbortController;const S=e.nodes.find(E=>E.id===k[k.length-y]);return t.invariant(S,"Undo failed: new start node not found"),h(S,A),{removed:y}},abort:()=>{x.abort()}}},Fe=e=>`+${e.countryCode} ${e.phoneNumber}`;async function rr(e){const r=e.node;switch(r.type){case"text":return cr({...e,node:r});case"image":return dr({...e,node:r});case"question-text":return fr({...e,node:r});case"question-enum":return mr({...e,node:r});case"question-number":return hr({...e,node:r});case"question-phone":return pr({...e,node:r});case"question-boolean":return gr({...e,node:r});case"question-file":return yr({...e,node:r});case"question-address":return br({...e,node:r});case"end-flow":return vr({...e,node:r});case"if-block":return ur({...e,node:r});case"jump":return ar({...e,node:r});case"link":return lr({...e,node:r});case"integration-application-submit":return or({...e,node:r});case"add-submission":return ir({...e,node:r});case"integration-workflow-get":throw Error("Workflow should be unreachable");case"identify":return sr({...e,node:r});case"feedback":return nr({...e,node:r});default:throw new Error(`Unknown node: ${JSON.stringify(r)}`)}}const me=(e,r)=>{var s;const n=(s=e[r])==null?void 0:s.value;if(typeof n!="string"&&typeof n!="number")throw new Error(`Submission at “${r}” is not a string or number`);return n};async function nr({next:e,node:r}){e(r.nextId)}async function sr({next:e,node:r,analytics:n,submissions:s,logger:i}){if(!s)return e(r.nextId);try{n.log({event:"IDENTIFY",properties:{identifier:me(s,r.data.key).toString(),first_name:r.data.firstName?me(s,r.data.firstName).toString():void 0,last_name:r.data.lastName?me(s,r.data.lastName).toString():void 0,email:r.data.email?me(s,r.data.email).toString():void 0,phone_number:r.data.phoneNumber?me(s,r.data.phoneNumber).toString():void 0,custom_traits:r.data.customTraits?Object.fromEntries(r.data.customTraits.map(({key:a,value:o})=>{var u;return[a,(u=s[o])==null?void 0:u.value]})):void 0}})}catch(a){i.error(a)}finally{e(r.nextId)}}async function ar({next:e,node:r}){e(r.data.targetId)}async function ir({next:e,node:r,logger:n,submissions:s,context:i}){if(!s){n.error("Submissions not found");return}s[r.data.key]={type:"string",value:Z(r.data.value,{submissions:s,context:i})},e(r.nextId)}async function or({chat:e,next:r,node:n,logger:s,apiClient:i,submissions:a,analytics:o,flow:u,t:d}){const p=async x=>{x!==!0&&await e.userInput({type:"submit",key:void 0,config:{label:n.data.submitLabel}}),await e.sendMessage({type:"loading"});const{anonymous_id:v,session_id:h}=o.getSessionInfo(),k=await i.fetch("/flow/submit",{method:"POST",body:JSON.stringify({log_submit:!1,integration_id:n.data.integrationId,anonymous_id:v,session_id:h,job:u.job,submissions:t.getFlowSubmissionsPayload(a||{})})}).catch(y=>y);n.data.key&&e.addToSubmissions(n.data.key,{type:"integration",value:k}),t.N(k).with({integration_response:t._.select(t._.union({service:t._.optional(t._.string),status:t._.number,data:t._.any},{service:t._.optional(t._.string),status:t._.number,error:{message:t._.string,data:t._.any}}))},y=>{o.log({event:"FLOW_SUBMIT",properties:{flow_id:u.id,flow_version:u.version,flow_session_id:u.data.flowSessionId,flow_build:u.build,service:y.service??"INVALID_SERVICE",response:{status:y.status,payload:"data"in y?y.data:y.error.data??null},job:u.job}})}).otherwise(()=>{}),await t.N(k).with(t._.union({ats_data:t._.select("redirect",{redirect_url:t._.string,message:t._.optional(t._.union(t._.string,t._.nullish)),button_text:t._.optional(t._.union(t._.string,t._.nullish))})},{integration_response:{data:t._.select("redirect",{redirect_url:t._.string,message:t._.optional(t._.union(t._.string,t._.nullish)),button_text:t._.optional(t._.union(t._.string,t._.nullish))})}}),async y=>{if(y.redirect!==void 0){await e.sendMessage({type:"text",author:"bot",text:y.redirect.message??d("submission_redirect_message")});try{const A=new URL(y.redirect.redirect_url);v&&!A.searchParams.has("anonymous_id")&&A.searchParams.set("anonymous_id",v),await e.sendMessage({type:"link",href:A.toString(),text:y.redirect.button_text??d("complete_submission"),onClick:()=>{if(!h){s.error("session_id not set, cannot log FLOW_REDIRECT event");return}o.log({event:"FLOW_REDIRECT",properties:{flow_build:u.build,flow_id:u.id,flow_session_id:h,flow_version:u.version,href:A.toString(),job:u.job}})}})}catch(A){s.error(`Invalid redirect URL: ${y.redirect.redirect_url}`,A),e.sendMessage({type:"system",variant:"error",text:d("redirect_url_error")})}r(n.nextId)}}).with({success:!0},async()=>{n.data.skipConfirmation!==!0&&await e.sendMessage({type:"system",variant:"success",text:d("submission_completed")}),r(n.nextId)}).with(t._.union({success:!1,ats_data:t._.select("error",{message:t._.string})},{integration_response:{error:t._.select("error",{message:t._.string})}}),async y=>{var A;s.error(y.error),await e.sendMessage({type:"system",variant:"error",text:((A=y.error)==null?void 0:A.message)||d("submission_failed")}),await p(!1)}).otherwise(async y=>{s.error(y),await e.sendMessage({type:"system",variant:"error",text:d("submission_failed")}),await p(!1)})};await p(n.data.skipConfirmation)}async function lr({chat:e,next:r,node:n,submissions:s,context:i}){await e.sendMessage({type:"link",href:Z(n.data.href,{submissions:s,context:i}),text:Z(n.data.cta,{submissions:s,context:i})}),r(n.nextId)}async function ur({submissions:e,next:r,node:n,context:s}){r(be(n,{submissions:e,context:s})?n.branchId:n.nextId)}async function cr({chat:e,next:r,node:n,submissions:s,context:i}){await e.sendMessage({author:"bot",type:"text",text:Z(n.data.text,{submissions:s,context:i})}),r(n.nextId)}async function dr({chat:e,next:r,node:n}){await e.sendMessage({author:"bot",type:"image",url:n.data.url,height:n.data.height,width:n.data.width}),r(n.nextId)}async function fr({chat:e,next:r,node:n,submissions:s,context:i,t:a}){await e.sendMessage({author:"bot",type:"text",text:Z(n.data.question,{submissions:s,context:i})});const o=n.data.format==="phone"?await e.userInput({key:n.data.key,type:"phone",config:{optional:n.data.optional,placeholder:n.data.placeholder,minChars:n.data.minChars,submissionFormat:"text",defaultValue:{}}}):await e.userInput({key:n.data.key,type:"text",config:{optional:n.data.optional,placeholder:n.data.placeholder,format:n.data.format,maxChars:n.data.maxChars,minChars:n.data.minChars}});o===null?await e.sendMessage({type:"system",variant:"info",text:a("skipped")}):await e.sendMessage({author:"user",type:"text",text:o.type==="phone"?Fe(o.value):o.value}),r(n.nextId)}async function hr({chat:e,next:r,node:n,submissions:s,context:i,t:a}){await e.sendMessage({author:"bot",type:"text",text:Z(n.data.question,{submissions:s,context:i})});const o=await e.userInput({key:n.data.key,type:"number",config:{max:n.data.max,min:n.data.min,optional:n.data.optional,placeholder:n.data.placeholder,decimalCases:n.data.decimalCases}});o===null?await e.sendMessage({type:"system",variant:"info",text:a("skipped")}):await e.sendMessage({author:"user",type:"text",text:o.value.toString()}),r(n.nextId)}async function pr({chat:e,next:r,node:n,submissions:s,context:i}){await e.sendMessage({author:"bot",type:"text",text:Z(n.data.question,{submissions:s,context:i})});const a=await e.userInput({key:n.data.key,type:"phone",config:{minChars:n.data.minChars,defaultValue:{countryCode:n.data.defaultCountryCode},placeholder:n.data.placeholder,submissionFormat:"phone",optional:n.data.optional}});a===null?await e.sendMessage({type:"system",variant:"info",text:"Skipped"}):await e.sendMessage({author:"user",type:"text",text:a.type==="phone"?Fe(a.value):a.value}),r(n.nextId)}async function mr({chat:e,next:r,node:n,submissions:s,context:i,t:a}){await e.sendMessage({author:"bot",type:"text",text:Z(n.data.question,{submissions:s,context:i})});const o=await e.userInput({key:n.data.key,type:"multiple-choice",config:n.data});o.value.length===0?await e.sendMessage({type:"system",variant:"info",text:a("skipped")}):await e.sendMessage({author:"user",type:"text",text:n.data.options.filter(u=>o.value.includes(u.value)).map(u=>u.label).join(", ")}),r(n.nextId)}async function gr({chat:e,next:r,node:n,submissions:s,context:i,t:a}){await e.sendMessage({author:"bot",type:"text",text:Z(n.data.question,{submissions:s,context:i})});const o=await e.userInput({key:n.data.key,type:"boolean",config:{optional:n.data.optional,labels:{true:n.data.trueLabel,false:n.data.falseLabel}}});o===null?await e.sendMessage({type:"system",variant:"info",text:a("skipped")}):await e.sendMessage({author:"user",type:"text",text:o.value===!0?n.data.trueLabel:n.data.falseLabel}),r(n.nextId)}async function br({chat:e,next:r,node:n,t:s}){await e.sendMessage({author:"bot",type:"text",text:n.data.question});const i=await e.userInput({type:"address",key:n.data.key,config:{optional:n.data.optional,keys:n.data.keys,placeholder:n.data.placeholder}});if(i===null)await e.sendMessage({type:"system",variant:"info",text:s("skipped")});else{const a=Object.values(i.value).filter(o=>o&&o.trim().length>0).join(", ");await e.sendMessage({author:"user",type:"text",text:a})}return r(n.nextId)}async function yr({node:e,chat:r,next:n,submissions:s,context:i,t:a}){await r.sendMessage({author:"bot",type:"text",text:Z(e.data.question,{submissions:s,context:i})});const o=await r.userInput({key:e.data.key,type:"file",config:{optional:e.data.optional,extensions:e.data.extensions,fileSizeLimitKib:e.data.maxSizeKb??10*1024,allowMultiple:e.data.multiple===!0}});if(o===null)await r.sendMessage({type:"system",variant:"info",text:a("skipped")});else for(const u of o.value)await r.sendMessage({author:"user",type:"file",fileName:u.name,fileSizeKb:u.sizeKb});n(e.nextId)}async function vr({chat:e,end:r,node:n}){await e.sendMessage({type:"system",variant:"info",text:n.data.systemMessage}),r()}const Ft=({key:e,path:r,submissions:n,context:s})=>{if(e==="$context"){if(!r)return;const i=t.get(s,r.join("."));switch(typeof i){case"string":return{type:"string",value:i};case"number":return{type:"number",value:i};case"boolean":return{type:"boolean",value:i};default:console.warn(`Unexpected type for $context.${r.join(".")}`,i);return}}return n==null?void 0:n[e]};function qe(e,r,n){var s,i,a,o,u;r==null&&(r=100);function d(){var x=Date.now()-o;x<r&&x>=0?s=setTimeout(d,r-x):(s=null,n||(u=e.apply(a,i),a=i=null))}var p=function(){a=this,i=arguments,o=Date.now();var x=n&&!s;return s||(s=setTimeout(d,r)),x&&(u=e.apply(a,i),a=i=null),u};return p.clear=function(){s&&(clearTimeout(s),s=null)},p.flush=function(){s&&(u=e.apply(a,i),a=i=null,clearTimeout(s),s=null)},p}qe.debounce=qe;var xr=qe;const lt=t.getDefaultExportFromCjs(xr);function wr(e){let{debounce:r,scroll:n,polyfill:s,offsetSize:i}=e===void 0?{debounce:0,scroll:!1,offsetSize:!1}:e;const a=s||(typeof window>"u"?class{}:window.ResizeObserver);if(!a)throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");const[o,u]=t.h({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),d=t._$1({element:null,scrollContainers:null,resizeObserver:null,lastBounds:o}),p=r?typeof r=="number"?r:r.scroll:null,x=r?typeof r=="number"?r:r.resize:null,v=t._$1(!1);t.p(()=>(v.current=!0,()=>void(v.current=!1)));const[h,k,y]=t.F(()=>{const g=()=>{if(!d.current.element)return;const{left:F,top:O,width:L,height:se,bottom:te,right:he,x:U,y:X}=d.current.element.getBoundingClientRect(),$={left:F,top:O,width:L,height:se,bottom:te,right:he,x:U,y:X};d.current.element instanceof HTMLElement&&i&&($.height=d.current.element.offsetHeight,$.width=d.current.element.offsetWidth),Object.freeze($),v.current&&!Cr(d.current.lastBounds,$)&&u(d.current.lastBounds=$)};return[g,x?lt(g,x):g,p?lt(g,p):g]},[u,i,p,x]);function A(){d.current.scrollContainers&&(d.current.scrollContainers.forEach(g=>g.removeEventListener("scroll",y,!0)),d.current.scrollContainers=null),d.current.resizeObserver&&(d.current.resizeObserver.disconnect(),d.current.resizeObserver=null)}function S(){d.current.element&&(d.current.resizeObserver=new a(y),d.current.resizeObserver.observe(d.current.element),n&&d.current.scrollContainers&&d.current.scrollContainers.forEach(g=>g.addEventListener("scroll",y,{capture:!0,passive:!0})))}const E=g=>{!g||g===d.current.element||(A(),d.current.element=g,d.current.scrollContainers=It(g),S())};return kr(y,!!n),_r(k),t.p(()=>{A(),S()},[n,y,k]),t.p(()=>A,[]),[E,o,h]}function _r(e){t.p(()=>{const r=e;return window.addEventListener("resize",r),()=>void window.removeEventListener("resize",r)},[e])}function kr(e,r){t.p(()=>{if(r){const n=e;return window.addEventListener("scroll",n,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",n,!0)}},[e,r])}function It(e){const r=[];if(!e||e===document.body)return r;const{overflow:n,overflowX:s,overflowY:i}=window.getComputedStyle(e);return[n,s,i].some(a=>a==="auto"||a==="scroll")&&r.push(e),[...r,...It(e.parentElement)]}const Sr=["x","y","top","bottom","left","right","width","height"],Cr=(e,r)=>Sr.every(n=>e[n]===r[n]),oe=({class:e,...r})=>{const{t:n}=t.useTranslation();return t.o("button",{class:t.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:t.o("svg",{class:"block",width:"16",height:"16",viewBox:"0 0 16 16",fill:"transparent",stroke:"currentColor","stroke-linecap":"round","stroke-width":"2",children:[t.o("title",{children:n("send")}),t.o("path",{d:"M3.5 7.5L8 3L12.5 7.5"}),t.o("path",{d:"M8 4V13"})]})})},Er=25,Ue=t.a({instant:()=>{},smooth:()=>{}}),j={onSubmitSuccessFn$:t.a(()=>{}),isBotTyping$:t.a(!1),scrollToEnd:{instant:()=>Ue.value.instant(),smooth:()=>Ue.value.smooth()}},Ar=()=>{const e=t._$1(null);t.y(()=>{Ue.value={instant:()=>{var n;return(n=e.current)==null?void 0:n.scrollTo({top:e.current.scrollHeight,behavior:"instant"})},smooth:()=>{e.current&&e.current.scrollHeight-e.current.scrollTop<=e.current.clientHeight*2&&e.current.scrollTo({top:e.current.scrollHeight,behavior:"smooth"})}}},[e]);const r=t.F(()=>({addToSubmissions:(s,i)=>t.store.setSubmission(s,i),send:async({message:s,signal:i,groupId:a})=>{if(await t.N(s).with({author:"bot",type:"text"},async o=>{if(i!=null&&i.aborted)throw new t.AbortedError;j.isBotTyping$.value=!0;const u=Math.min(Math.max(20,o.text.length),100)*Er;await new Promise(d=>setTimeout(d,u,{signal:i})),j.isBotTyping$.value=!1}).otherwise(async()=>{}),i!=null&&i.aborted)throw new t.AbortedError;t.store.addMessage(s,a)},input:({input:s,signal:i})=>{if(i!=null&&i.aborted)throw new t.AbortedError;return t.store.setInput(s),new Promise(a=>{const o=u=>{if(i!=null&&i.aborted)throw new t.AbortedError;t.store.setInput(void 0),s.key&&t.store.setSubmission(s.key,u),a(u)};j.onSubmitSuccessFn$.value=o})}}),[]);return{chatRef:e,chatService:r}},fe=({error:e})=>!e||!e.message?null:t.o("div",{role:"alert",class:"text-error-11 flex max-w-full items-center gap-1 overflow-hidden rounded-full px-2 py-2",children:[t.o("svg",{class:"text-error-9 h-4 w-4",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.o("circle",{cx:"8",cy:"8",r:"6.3",stroke:"currentColor","stroke-width":"1.4"}),t.o("rect",{x:"7",y:"4",width:"2",height:"5",fill:"currentColor"}),t.o("rect",{x:"7",y:"10",width:"2",height:"2",fill:"currentColor"})]}),t.o("p",{class:"truncate pr-1 text-sm",children:e.message})]}),le=({class:e,...r})=>{const{t:n}=t.useTranslation();return t.o("button",{type:"button",class:t.clsx("fr text-neutral-9 flex flex-shrink-0 items-center justify-center gap-1 rounded-full py-[6px] pl-2 pr-3 text-sm underline-offset-2 transition-all",e),...r,children:[t.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:[t.o("title",{children:n("skip")}),t.o("path",{d:"M3.25 11.25A5 5 0 0 1 12 7"}),t.o("path",{d:"M13.25 4.5V8.25H9.5"})]}),n("skip")]})},Ke={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"},ye=t.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}}),Tr="https://api.mapbox.com/search/searchbox/v1/suggest",Vr="ZzRDWFU0dTZ3SF9aWk9RNGl6QzZaWS5RZmlFak13a0hPbGxXZXlNSGN5RUhObUJ6TXpSV08yUW5OdE5tSTZJU1lpd2lJb1JYYXRObmJ2Tm5iaGhHZWx4V1lpb2pJMUp5ZS5rcA==",Fr=e=>atob(e).split("").reverse().join(""),Y=t.object({name:t.string()}),Ir=t.object({suggestions:t.array(t.object({full_address:t.optional(t.string()),place_formatted:t.optional(t.string()),name:t.optional(t.string()),mapbox_id:t.string(),context:t.partial(t.object({address:Y,street:Y,neighborhood:Y,locality:Y,district:Y,place:Y,region:Y,postcode:Y,country:Y}))}))}),Mr=({logger:e,t:r})=>t.F(()=>{var s;const n=(s=t.store.current$.peek().flow)==null?void 0:s.data.flowSessionId;return n?{enabled:!0,getPredictions:async i=>{const a=new URL(Tr);a.searchParams.set("q",i),a.searchParams.set("session_token",n),a.searchParams.set("access_token",Fr(Vr));const o=await fetch(a);if(!o.ok)return e.error("Failed to get address details",o),{ok:!1,error:r("address_error")};const u=t.safeParse(Ir,await o.json());if(u.success===!1)return e.error("Failed to parse address details",u.issues),{ok:!1,error:r("address_error")};const{suggestions:d}=u.output;return{ok:!0,data:d.map(p=>{var x,v,h,k,y,A,S,E,g;return{label:p.full_address??p.place_formatted??p.name??p.mapbox_id,id:p.mapbox_id,address:{line1:((x=p.context.address)==null?void 0:x.name)??((v=p.context.street)==null?void 0:v.name),line2:void 0,line3:((h=p.context.neighborhood)==null?void 0:h.name)??((k=p.context.locality)==null?void 0:k.name),city:((y=p.context.place)==null?void 0:y.name)??((A=p.context.district)==null?void 0:A.name),state:(S=p.context.region)==null?void 0:S.name,postcode:(E=p.context.postcode)==null?void 0:E.name,country:(g=p.context.country)==null?void 0:g.name}}})}}}:{enabled:!1}},[e,r]),ut=e=>{const{t:r}=t.useTranslation();return t.o("button",{type:"button",class:"text-neutral-10 hover:bg-neutral-4 hover:text-neutral-12 hover:border-neutral-5 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:[t.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:t.o("path",{d:"M10 3L5 8L10 13"})}),t.o("span",{children:r("back")})]})},Lr=({input:e,onSubmitSuccess:r,logger:n})=>{const{t:s}=t.useTranslation(),[i,a]=t.h(),[o,u]=t.h([]),{enabled:d,getPredictions:p}=Mr({logger:n,t:s}),[x,v]=t.h(d?"query":"manual"),[h,k]=t.h(""),[y,A]=t.h(),S=E=>{t.invariant(d,"Query state should not be enabled"),E=E.trim(),E!==(h==null?void 0:h.trim())&&(k(E),E===""&&u([]),A(void 0),p(E).then(g=>{if(g.ok===!1){u([]),A(g.error);return}u(g.data)}))};switch(x){case"query":return t.invariant(d,"Query state should not be enabled"),t.o(Nr,{input:e,onSkip:()=>r(null),onAddressSelect:E=>{if(E===""){a(void 0),v("manual");return}const g=o.find(F=>F.id===E);g&&(a(g.address),v("details"))},onAddressSearch:E=>{S(E)},suggestions:o,query:h,error:y});case"details":return t.invariant(i!==void 0),t.o(dt,{input:e,logger:n,onSubmitSuccess:r,addressFields:i,actions:t.o(ut,{onClick:()=>{v("query")}})});case"manual":return t.o(dt,{logger:n,input:e,onSubmitSuccess:r,addressFields:{},actions:d?t.o(ut,{onClick:()=>{v("query")}}):void 0})}},Nr=({input:e,onSkip:r,suggestions:n,onAddressSelect:s,query:i,onAddressSearch:a,error:o})=>{const{t:u}=t.useTranslation(),d=t._$1(null);return t.y(()=>{d.current&&(d.current.focus(),d.current.select())},[]),t.o(t.k,{children:[t.o("form",{noValidate:!0,onSubmit:p=>{p.preventDefault();const v=new FormData(p.currentTarget).get("address");typeof v=="string"&&a(v)},class:"flex gap-1 p-2.5",children:[t.o("div",{class:"group relative flex-1",children:[t.o("input",{ref:d,name:"address",id:"chat-address",autocomplete:"address-line1 country-name postal-code",autoFocus:!0,placeholder:e.config.placeholder||u("address_search"),defaultValue:i,class:ye({optional:!!e.config.optional,className:"w-full rounded-full"})}),t.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:t.o("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.o("g",{id:"inploi",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round",strokeWidth:"1.5",children:[t.o("circle",{cx:"7",cy:"7",r:"4"}),t.o("path",{d:"M10 10L13 13"})]}),t.o("span",{class:"sr-only",children:u("search")})]})})]}),e.config.optional&&t.o(le,{class:"",onClick:r})]}),o?t.o(fe,{error:{message:o}}):null,t.o("ul",{children:[n.map(p=>t.o("li",{children:t.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(p.id)},children:[t.o("span",{class:"flex-grow",children:p.label}),t.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:t.o("path",{d:"M6 3L11 8L6 13"})})]})},p.id)),t.o("li",{children:t.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:t.o("span",{class:"flex-grow",children:u("address_manual")})})},"")]})]})},ct=["line1","line2","line3","city","state","postcode","country"],dt=({addressFields:e,onSubmitSuccess:r,actions:n,input:s})=>{const i=t._$1(null);t.y(()=>{if(i.current){const u=i.current.querySelector("input");u&&(u.focus(),u.select())}},[]);const a=Object.keys(Ke),{t:o}=t.useTranslation();return t.o("form",{class:"bg-neutral-1/90 flex flex-col justify-end gap-2 p-2",onSubmit:u=>{const d=new FormData(u.currentTarget),p=Object.fromEntries(d.entries());r({type:"address",value:p})},children:[t.o("div",{class:"bg-neutral-3 border-neutral-5 grid items-center gap-1.5 rounded-2xl border pb-2 pl-4 pr-3 pt-3 [grid-template-columns:min-content_1fr]",ref:i,children:ct.map((u,d)=>{const p=`isdk_${u}`,x=s.config.keys[u];return x?t.o(t.k,{children:[t.o("label",{for:p,class:"text-neutral-9 [&:has(+*>input:focus)]:text-neutral-11 w-24 pb-2 text-xs uppercase leading-3 tracking-widest transition-colors",children:o(u)}),t.o("div",{class:"flex flex-col items-stretch gap-1.5",children:[u==="country"?t.o("div",{class:"relative",children:[t.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:p,defaultValue:e[u],required:!0,children:[e.country&&!a.includes(e.country)?t.o("option",{value:e[u],children:e[u]}):t.o("option",{value:"",children:o("select_country")}),a.map(v=>t.o("option",{value:v,children:v},v))]}),t.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:t.o("path",{d:"M4 6.5L8 10.5L12 6.5"})})]}):t.o("input",{autoFocus:d===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:p,defaultValue:e[u],required:!0}),d===ct.length-1?t.o("hr",{class:"m-0 w-full border-b border-b-transparent"}):t.o("hr",{class:"border-b-neutral-5 m-0 w-full border-b border-solid"})]})]}):null})}),t.o("div",{class:"flex w-full flex-1 ",children:[t.o("div",{class:"flex-grow",children:n}),t.o(oe,{class:"flex items-center justify-center"})]})]})},Ge=()=>{const e=t._$1(null);return t.p(()=>{var r;(r=e.current)==null||r.focus()},[]),e},Mt=["true","false"],Rr=t.picklist(Mt),Dr="answer",Lt="flex items-center gap-2 p-2.5",Nt=t.k$1(({label:e,...r},n)=>t.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.5 py-2.5 ring-2 transition-all selection:bg-transparent",...r,ref:n,children:t.o("p",{class:"truncate text-center text-base",children:e})})),Or=({input:e,onSubmitSuccess:r})=>{const n=Ge();return t.o("form",{noValidate:!0,class:"",onSubmit:s=>{s.preventDefault();const i=t.getFormSubmitter(s).value,a=t.parse(Rr,i);r({type:"boolean",value:a==="true"})},children:[t.o("ul",{class:Lt,children:Mt.map((s,i)=>t.o("li",{class:"flex-1",children:t.o(Nt,{ref:i===0?n:null,type:"submit",name:Dr,value:s,label:e.config.labels[s]},s)}))}),e.config.optional&&t.o("div",{class:"px-2 pb-2",children:t.o(le,{class:"w-full",type:"button",onClick:()=>r(null)})})]})},Br=e=>new Promise((r,n)=>{const s=new FileReader;s.readAsDataURL(e),s.onload=()=>s.result?r(s.result.toString()):n("No result from reader"),s.onerror=n}),Pr=e=>e.reduce((r,n)=>r+n.sizeKb,0),jr=t.isSubmissionOfType("file"),ft=3,$r=({file:e,class:r,...n})=>{const s=e.name.split(".").pop(),i=e.name.replace(new RegExp(`.${s}$`),"");return t.o("div",{class:t.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),...n,children:[t.o("p",{"aria-label":"File name",class:"text-accent-12 flex flex-grow overflow-hidden",children:[t.o("span",{class:"block truncate",children:i}),t.o("span",{children:[".",s]})]}),t.o("p",{"aria-label":"File size",class:"text-accent-11",children:t.kbToReadableSize(e.sizeKb)})]})},ht=({class:e,...r})=>t.o("li",{class:t.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}),Rt=e=>{const r=e.split(".").pop();if(!r)throw new Error("No file extension found");return r?"."+r:""},zr=({allowedExtensions:e,files:r})=>{const n=e.map(s=>s.toLowerCase());return r.every(s=>n.includes(Rt(s.name).toLowerCase()))},qr=(e,r)=>{const n=Rt(e);return`${e.replace(new RegExp(`${n}$`),"").slice(0,r)}${n}`},Ur=({input:e,onSubmitSuccess:r})=>{var v;const n=(v=t.store.current$.value.flow)==null?void 0:v.data.submissions[e.key],[s,i]=t.h(jr(n)?n.value:[]),[a,o]=t.h(),u=s.length-ft,d=Pr(s),p=Ge(),{t:x}=t.useTranslation();return t.o("form",{class:"flex flex-col gap-1 p-2.5",onSubmit:h=>(h.preventDefault(),o(void 0),s.length===0?o({type:"required",message:x("validation_file")}):e.config.extensions.length>0&&!zr({allowedExtensions:e.config.extensions,files:s})?o({type:"validate",message:`${x("validation_file_ext",{ext:e.config.extensions.join(", ")})}`}):e.config.fileSizeLimitKib&&d>e.config.fileSizeLimitKib?o({type:"max",message:`File size exceeds limit of ${t.kbToReadableSize(e.config.fileSizeLimitKib)}`}):e.config.allowMultiple===!1&&s.length>1?o({type:"invalid",message:x("validation_file_max",{count:1})}):r({type:"file",value:s})),children:[t.o("div",{class:"flex items-center gap-2",children:[t.o("label",{ref:p,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:[s.length>0?t.o(t.k,{children:[t.o("ul",{class:"flex max-w-full flex-wrap justify-center gap-1 overflow-hidden p-1",children:[s.slice(0,ft).map(h=>{const k=h.name.split(".").pop(),y=h.name.replace(new RegExp(`.${k}$`),"");return t.o(ht,{class:"flex overflow-hidden",children:[t.o("span",{class:"block truncate",children:y}),t.o("span",{children:[".",k]})]})}),u>0?t.o(ht,{children:["+",u," file",u!==1?"s":""]}):null]}),t.o("p",{class:"text-neutral-11 text-xs",children:[t.kbToReadableSize(d)," ",s.length>1?"total":""]})]}):t.o("div",{class:"flex flex-col justify-center gap-4 pb-6 pt-5",children:[t.o("header",{class:"flex flex-col items-center gap-0",children:[t.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:t.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"})}),t.o("p",{class:"text-neutral-12 tracking-[-0.01em]",children:x("upload_file",{count:e.config.allowMultiple?2:1})}),e.config.fileSizeLimitKib?t.o("p",{class:"text-neutral-10 text-xs",children:["(",x("file_max_size",{size:t.kbToReadableSize(e.config.fileSizeLimitKib)}),")"]}):null]}),t.o("aside",{class:"flex flex-col items-center gap-2",children:[t.o("p",{id:"accepted-filetypes",class:"sr-only",children:x("file_extensions")}),t.o("ul",{"aria-describedby":"accepted-filetypes",class:"flex flex-wrap justify-center gap-2",children:e.config.extensions.map(h=>t.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:h.replace(".","")}))})]})]}),t.o("input",{id:"dropzone-file",onInput:async h=>{t.invariant(h.target instanceof HTMLInputElement);const k=h.target.files?Array.from(h.target.files):[],y=await Promise.allSettled(k.map(async S=>{const E=await Br(S);return{name:qr(S.name,42),data:E,sizeKb:S.size/1e3}}));if(y.some(({status:S})=>S==="rejected"))return o({type:"invalid",message:"Invalid file"});const A=y.map(S=>S.status==="fulfilled"?S.value:null).filter(Boolean);i(A)},multiple:e.config.allowMultiple,type:"file",class:"sr-only"})]}),t.o("div",{class:"flex h-full flex-col items-center gap-2",children:[t.o(oe,{disabled:s.length===0}),e.config.optional&&t.o(le,{onClick:()=>r(null)})]})]}),t.o(fe,{error:a})]})};var ve=e=>e.type==="checkbox",de=e=>e instanceof Date,z=e=>e==null;const Dt=e=>typeof e=="object";var B=e=>!z(e)&&!Array.isArray(e)&&Dt(e)&&!de(e),Kr=e=>B(e)&&e.target?ve(e.target)?e.target.checked:e.target.value:e,Gr=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,Hr=(e,r)=>e.has(Gr(r)),Wr=e=>{const r=e.constructor&&e.constructor.prototype;return B(r)&&r.hasOwnProperty("isPrototypeOf")},He=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function ee(e){let r;const n=Array.isArray(e);if(e instanceof Date)r=new Date(e);else if(e instanceof Set)r=new Set(e);else if(!(He&&(e instanceof Blob||e instanceof FileList))&&(n||B(e)))if(r=n?[]:{},!n&&!Wr(e))r=e;else for(const s in e)e.hasOwnProperty(s)&&(r[s]=ee(e[s]));else return e;return r}var xe=e=>Array.isArray(e)?e.filter(Boolean):[],R=e=>e===void 0,w=(e,r,n)=>{if(!r||!B(e))return n;const s=xe(r.split(/[,[\].]+?/)).reduce((i,a)=>z(i)?i:i[a],e);return R(s)||s===e?R(e[r])?n:e[r]:s},re=e=>typeof e=="boolean";const pt={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},H={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Q={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"};t.Cn.createContext(null);var Jr=(e,r,n,s=!0)=>{const i={defaultValues:r._defaultValues};for(const a in e)Object.defineProperty(i,a,{get:()=>{const o=a;return r._proxyFormState[o]!==H.all&&(r._proxyFormState[o]=!s||H.all),n&&(n[o]=!0),e[o]}});return i},G=e=>B(e)&&!Object.keys(e).length,Zr=(e,r,n,s)=>{n(e);const{name:i,...a}=e;return G(a)||Object.keys(a).length>=Object.keys(r).length||Object.keys(a).find(o=>r[o]===(!s||H.all))},Be=e=>Array.isArray(e)?e:[e];function Xr(e){const r=t.Cn.useRef(e);r.current=e,t.Cn.useEffect(()=>{const n=!e.disabled&&r.current.subject&&r.current.subject.subscribe({next:r.current.next});return()=>{n&&n.unsubscribe()}},[e.disabled])}var J=e=>typeof e=="string",Yr=(e,r,n,s,i)=>J(e)?(s&&r.watch.add(e),w(n,e,i)):Array.isArray(e)?e.map(a=>(s&&r.watch.add(a),w(n,a))):(s&&(r.watchAll=!0),n),We=e=>/^\w*$/.test(e),Ot=e=>xe(e.replace(/["|']|\]/g,"").split(/\.|\[/));function I(e,r,n){let s=-1;const i=We(r)?[r]:Ot(r),a=i.length,o=a-1;for(;++s<a;){const u=i[s];let d=n;if(s!==o){const p=e[u];d=B(p)||Array.isArray(p)?p:isNaN(+i[s+1])?{}:[]}e[u]=d,e=e[u]}return e}var Bt=(e,r,n,s,i)=>r?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[s]:i||!0}}:{},mt=e=>({isOnSubmit:!e||e===H.onSubmit,isOnBlur:e===H.onBlur,isOnChange:e===H.onChange,isOnAll:e===H.all,isOnTouch:e===H.onTouched}),gt=(e,r,n)=>!n&&(r.watchAll||r.watch.has(e)||[...r.watch].some(s=>e.startsWith(s)&&/^\.\w+/.test(e.slice(s.length))));const Se=(e,r,n,s)=>{for(const i of n||Object.keys(e)){const a=w(e,i);if(a){const{_f:o,...u}=a;if(o){if(o.refs&&o.refs[0]&&r(o.refs[0],i)&&!s)break;if(o.ref&&r(o.ref,o.name)&&!s)break}else B(u)&&Se(u,r)}}};var Qr=(e,r,n)=>{const s=xe(w(e,n));return I(s,"root",r[n]),I(e,n,s),e},Je=e=>e.type==="file",ne=e=>typeof e=="function",Ee=e=>{if(!He)return!1;const r=e?e.ownerDocument:0;return e instanceof(r&&r.defaultView?r.defaultView.HTMLElement:HTMLElement)},Ce=e=>J(e),Ze=e=>e.type==="radio",Ae=e=>e instanceof RegExp;const bt={value:!1,isValid:!1},yt={value:!0,isValid:!0};var Pt=e=>{if(Array.isArray(e)){if(e.length>1){const r=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:r,isValid:!!r.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!R(e[0].attributes.value)?R(e[0].value)||e[0].value===""?yt:{value:e[0].value,isValid:!0}:yt:bt}return bt};const vt={isValid:!1,value:null};var jt=e=>Array.isArray(e)?e.reduce((r,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:r,vt):vt;function xt(e,r,n="validate"){if(Ce(e)||Array.isArray(e)&&e.every(Ce)||re(e)&&!e)return{type:n,message:Ce(e)?e:"",ref:r}}var ce=e=>B(e)&&!Ae(e)?e:{value:e,message:""},wt=async(e,r,n,s,i)=>{const{ref:a,refs:o,required:u,maxLength:d,minLength:p,min:x,max:v,pattern:h,validate:k,name:y,valueAsNumber:A,mount:S,disabled:E}=e._f,g=w(r,y);if(!S||E)return{};const F=o?o[0]:a,O=V=>{s&&F.reportValidity&&(F.setCustomValidity(re(V)?"":V||""),F.reportValidity())},L={},se=Ze(a),te=ve(a),he=se||te,U=(A||Je(a))&&R(a.value)&&R(g)||Ee(a)&&a.value===""||g===""||Array.isArray(g)&&!g.length,X=Bt.bind(null,y,n,L),$=(V,T,N,q=Q.maxLength,K=Q.minLength)=>{const W=V?T:N;L[y]={type:V?q:K,message:W,ref:a,...X(V?q:K,W)}};if(i?!Array.isArray(g)||!g.length:u&&(!he&&(U||z(g))||re(g)&&!g||te&&!Pt(o).isValid||se&&!jt(o).isValid)){const{value:V,message:T}=Ce(u)?{value:!!u,message:u}:ce(u);if(V&&(L[y]={type:Q.required,message:T,ref:F,...X(Q.required,T)},!n))return O(T),L}if(!U&&(!z(x)||!z(v))){let V,T;const N=ce(v),q=ce(x);if(!z(g)&&!isNaN(g)){const K=a.valueAsNumber||g&&+g;z(N.value)||(V=K>N.value),z(q.value)||(T=K<q.value)}else{const K=a.valueAsDate||new Date(g),W=we=>new Date(new Date().toDateString()+" "+we),ae=a.type=="time",pe=a.type=="week";J(N.value)&&g&&(V=ae?W(g)>W(N.value):pe?g>N.value:K>new Date(N.value)),J(q.value)&&g&&(T=ae?W(g)<W(q.value):pe?g<q.value:K<new Date(q.value))}if((V||T)&&($(!!V,N.message,q.message,Q.max,Q.min),!n))return O(L[y].message),L}if((d||p)&&!U&&(J(g)||i&&Array.isArray(g))){const V=ce(d),T=ce(p),N=!z(V.value)&&g.length>+V.value,q=!z(T.value)&&g.length<+T.value;if((N||q)&&($(N,V.message,T.message),!n))return O(L[y].message),L}if(h&&!U&&J(g)){const{value:V,message:T}=ce(h);if(Ae(V)&&!g.match(V)&&(L[y]={type:Q.pattern,message:T,ref:a,...X(Q.pattern,T)},!n))return O(T),L}if(k){if(ne(k)){const V=await k(g,r),T=xt(V,F);if(T&&(L[y]={...T,...X(Q.validate,T.message)},!n))return O(T.message),L}else if(B(k)){let V={};for(const T in k){if(!G(V)&&!n)break;const N=xt(await k[T](g,r),F,T);N&&(V={...N,...X(T,N.message)},O(N.message),n&&(L[y]=V))}if(!G(V)&&(L[y]={ref:F,...V},!n))return L}}return O(!0),L};function en(e,r){const n=r.slice(0,-1).length;let s=0;for(;s<n;)e=R(e)?s++:e[r[s++]];return e}function tn(e){for(const r in e)if(e.hasOwnProperty(r)&&!R(e[r]))return!1;return!0}function P(e,r){const n=Array.isArray(r)?r:We(r)?[r]:Ot(r),s=n.length===1?e:en(e,n),i=n.length-1,a=n[i];return s&&delete s[a],i!==0&&(B(s)&&G(s)||Array.isArray(s)&&tn(s))&&P(e,n.slice(0,-1)),e}function Pe(){let e=[];return{get observers(){return e},next:i=>{for(const a of e)a.next&&a.next(i)},subscribe:i=>(e.push(i),{unsubscribe:()=>{e=e.filter(a=>a!==i)}}),unsubscribe:()=>{e=[]}}}var Te=e=>z(e)||!Dt(e);function ie(e,r){if(Te(e)||Te(r))return e===r;if(de(e)&&de(r))return e.getTime()===r.getTime();const n=Object.keys(e),s=Object.keys(r);if(n.length!==s.length)return!1;for(const i of n){const a=e[i];if(!s.includes(i))return!1;if(i!=="ref"){const o=r[i];if(de(a)&&de(o)||B(a)&&B(o)||Array.isArray(a)&&Array.isArray(o)?!ie(a,o):a!==o)return!1}}return!0}var $t=e=>e.type==="select-multiple",rn=e=>Ze(e)||ve(e),je=e=>Ee(e)&&e.isConnected,zt=e=>{for(const r in e)if(ne(e[r]))return!0;return!1};function Ve(e,r={}){const n=Array.isArray(e);if(B(e)||n)for(const s in e)Array.isArray(e[s])||B(e[s])&&!zt(e[s])?(r[s]=Array.isArray(e[s])?[]:{},Ve(e[s],r[s])):z(e[s])||(r[s]=!0);return r}function qt(e,r,n){const s=Array.isArray(e);if(B(e)||s)for(const i in e)Array.isArray(e[i])||B(e[i])&&!zt(e[i])?R(r)||Te(n[i])?n[i]=Array.isArray(e[i])?Ve(e[i],[]):{...Ve(e[i])}:qt(e[i],z(r)?{}:r[i],n[i]):n[i]=!ie(e[i],r[i]);return n}var $e=(e,r)=>qt(e,r,Ve(r)),Ut=(e,{valueAsNumber:r,valueAsDate:n,setValueAs:s})=>R(e)?e:r?e===""?NaN:e&&+e:n&&J(e)?new Date(e):s?s(e):e;function ze(e){const r=e.ref;if(!(e.refs?e.refs.every(n=>n.disabled):r.disabled))return Je(r)?r.files:Ze(r)?jt(e.refs).value:$t(r)?[...r.selectedOptions].map(({value:n})=>n):ve(r)?Pt(e.refs).value:Ut(R(r.value)?e.ref.value:r.value,e)}var nn=(e,r,n,s)=>{const i={};for(const a of e){const o=w(r,a);o&&I(i,a,o._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:s}},ge=e=>R(e)?e:Ae(e)?e.source:B(e)?Ae(e.value)?e.value.source:e.value:e,sn=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function _t(e,r,n){const s=w(e,n);if(s||We(n))return{error:s,name:n};const i=n.split(".");for(;i.length;){const a=i.join("."),o=w(r,a),u=w(e,a);if(o&&!Array.isArray(o)&&n!==a)return{name:n};if(u&&u.type)return{name:a,error:u};i.pop()}return{name:n}}var an=(e,r,n,s,i)=>i.isOnAll?!1:!n&&i.isOnTouch?!(r||e):(n?s.isOnBlur:i.isOnBlur)?!e:(n?s.isOnChange:i.isOnChange)?e:!0,on=(e,r)=>!xe(w(e,r)).length&&P(e,r);const ln={mode:H.onSubmit,reValidateMode:H.onChange,shouldFocusError:!0};function un(e={},r){let n={...ln,...e},s={submitCount:0,isDirty:!1,isLoading:ne(n.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},errors:{},disabled:!1},i={},a=B(n.defaultValues)||B(n.values)?ee(n.defaultValues||n.values)||{}:{},o=n.shouldUnregister?{}:ee(a),u={action:!1,mount:!1,watch:!1},d={mount:new Set,unMount:new Set,array:new Set,watch:new Set},p,x=0;const v={isDirty:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},h={values:Pe(),array:Pe(),state:Pe()},k=e.resetOptions&&e.resetOptions.keepDirtyValues,y=mt(n.mode),A=mt(n.reValidateMode),S=n.criteriaMode===H.all,E=l=>c=>{clearTimeout(x),x=setTimeout(l,c)},g=async l=>{if(v.isValid||l){const c=n.resolver?G((await U()).errors):await $(i,!0);c!==s.isValid&&h.state.next({isValid:c})}},F=l=>v.isValidating&&h.state.next({isValidating:l}),O=(l,c=[],f,_,b=!0,m=!0)=>{if(_&&f){if(u.action=!0,m&&Array.isArray(w(i,l))){const C=f(w(i,l),_.argA,_.argB);b&&I(i,l,C)}if(m&&Array.isArray(w(s.errors,l))){const C=f(w(s.errors,l),_.argA,_.argB);b&&I(s.errors,l,C),on(s.errors,l)}if(v.touchedFields&&m&&Array.isArray(w(s.touchedFields,l))){const C=f(w(s.touchedFields,l),_.argA,_.argB);b&&I(s.touchedFields,l,C)}v.dirtyFields&&(s.dirtyFields=$e(a,o)),h.state.next({name:l,isDirty:T(l,c),dirtyFields:s.dirtyFields,errors:s.errors,isValid:s.isValid})}else I(o,l,c)},L=(l,c)=>{I(s.errors,l,c),h.state.next({errors:s.errors})},se=(l,c,f,_)=>{const b=w(i,l);if(b){const m=w(o,l,R(f)?w(a,l):f);R(m)||_&&_.defaultChecked||c?I(o,l,c?m:ze(b._f)):K(l,m),u.mount&&g()}},te=(l,c,f,_,b)=>{let m=!1,C=!1;const M={name:l};if(!f||_){v.isDirty&&(C=s.isDirty,s.isDirty=M.isDirty=T(),m=C!==M.isDirty);const D=ie(w(a,l),c);C=w(s.dirtyFields,l),D?P(s.dirtyFields,l):I(s.dirtyFields,l,!0),M.dirtyFields=s.dirtyFields,m=m||v.dirtyFields&&C!==!D}if(f){const D=w(s.touchedFields,l);D||(I(s.touchedFields,l,f),M.touchedFields=s.touchedFields,m=m||v.touchedFields&&D!==f)}return m&&b&&h.state.next(M),m?M:{}},he=(l,c,f,_)=>{const b=w(s.errors,l),m=v.isValid&&re(c)&&s.isValid!==c;if(e.delayError&&f?(p=E(()=>L(l,f)),p(e.delayError)):(clearTimeout(x),p=null,f?I(s.errors,l,f):P(s.errors,l)),(f?!ie(b,f):b)||!G(_)||m){const C={..._,...m&&re(c)?{isValid:c}:{},errors:s.errors,name:l};s={...s,...C},h.state.next(C)}F(!1)},U=async l=>n.resolver(o,n.context,nn(l||d.mount,i,n.criteriaMode,n.shouldUseNativeValidation)),X=async l=>{const{errors:c}=await U(l);if(l)for(const f of l){const _=w(c,f);_?I(s.errors,f,_):P(s.errors,f)}else s.errors=c;return c},$=async(l,c,f={valid:!0})=>{for(const _ in l){const b=l[_];if(b){const{_f:m,...C}=b;if(m){const M=d.array.has(m.name),D=await wt(b,o,S,n.shouldUseNativeValidation&&!c,M);if(D[m.name]&&(f.valid=!1,c))break;!c&&(w(D,m.name)?M?Qr(s.errors,D,m.name):I(s.errors,m.name,D[m.name]):P(s.errors,m.name))}C&&await $(C,c,f)}}return f.valid},V=()=>{for(const l of d.unMount){const c=w(i,l);c&&(c._f.refs?c._f.refs.every(f=>!je(f)):!je(c._f.ref))&&Ne(l)}d.unMount=new Set},T=(l,c)=>(l&&c&&I(o,l,c),!ie(Xe(),a)),N=(l,c,f)=>Yr(l,d,{...u.mount?o:R(c)?a:J(l)?{[l]:c}:c},f,c),q=l=>xe(w(u.mount?o:a,l,e.shouldUnregister?w(a,l,[]):[])),K=(l,c,f={})=>{const _=w(i,l);let b=c;if(_){const m=_._f;m&&(!m.disabled&&I(o,l,Ut(c,m)),b=Ee(m.ref)&&z(c)?"":c,$t(m.ref)?[...m.ref.options].forEach(C=>C.selected=b.includes(C.value)):m.refs?ve(m.ref)?m.refs.length>1?m.refs.forEach(C=>(!C.defaultChecked||!C.disabled)&&(C.checked=Array.isArray(b)?!!b.find(M=>M===C.value):b===C.value)):m.refs[0]&&(m.refs[0].checked=!!b):m.refs.forEach(C=>C.checked=C.value===b):Je(m.ref)?m.ref.value="":(m.ref.value=b,m.ref.type||h.values.next({name:l,values:{...o}})))}(f.shouldDirty||f.shouldTouch)&&te(l,b,f.shouldTouch,f.shouldDirty,!0),f.shouldValidate&&Le(l)},W=(l,c,f)=>{for(const _ in c){const b=c[_],m=`${l}.${_}`,C=w(i,m);(d.array.has(l)||!Te(b)||C&&!C._f)&&!de(b)?W(m,b,f):K(m,b,f)}},ae=(l,c,f={})=>{const _=w(i,l),b=d.array.has(l),m=ee(c);I(o,l,m),b?(h.array.next({name:l,values:{...o}}),(v.isDirty||v.dirtyFields)&&f.shouldDirty&&h.state.next({name:l,dirtyFields:$e(a,o),isDirty:T(l,m)})):_&&!_._f&&!z(m)?W(l,m,f):K(l,m,f),gt(l,d)&&h.state.next({...s}),h.values.next({name:l,values:{...o}}),!u.mount&&r()},pe=async l=>{const c=l.target;let f=c.name,_=!0;const b=w(i,f),m=()=>c.type?ze(b._f):Kr(l),C=M=>{_=Number.isNaN(M)||M===w(o,f,M)};if(b){let M,D;const _e=m(),ue=l.type===pt.BLUR||l.type===pt.FOCUS_OUT,Zt=!sn(b._f)&&!n.resolver&&!w(s.errors,f)&&!b._f.deps||an(ue,w(s.touchedFields,f),s.isSubmitted,A,y),De=gt(f,d,ue);I(o,f,_e),ue?(b._f.onBlur&&b._f.onBlur(l),p&&p(0)):b._f.onChange&&b._f.onChange(l);const Oe=te(f,_e,ue,!1),Xt=!G(Oe)||De;if(!ue&&h.values.next({name:f,type:l.type,values:{...o}}),Zt)return v.isValid&&g(),Xt&&h.state.next({name:f,...De?{}:Oe});if(!ue&&De&&h.state.next({...s}),F(!0),n.resolver){const{errors:at}=await U([f]);if(C(_e),_){const Yt=_t(s.errors,i,f),it=_t(at,i,Yt.name||f);M=it.error,f=it.name,D=G(at)}}else M=(await wt(b,o,S,n.shouldUseNativeValidation))[f],C(_e),_&&(M?D=!1:v.isValid&&(D=await $(i,!0)));_&&(b._f.deps&&Le(b._f.deps),he(f,D,M,Oe))}},we=(l,c)=>{if(w(s.errors,c)&&l.focus)return l.focus(),1},Le=async(l,c={})=>{let f,_;const b=Be(l);if(F(!0),n.resolver){const m=await X(R(l)?l:b);f=G(m),_=l?!b.some(C=>w(m,C)):f}else l?(_=(await Promise.all(b.map(async m=>{const C=w(i,m);return await $(C&&C._f?{[m]:C}:C)}))).every(Boolean),!(!_&&!s.isValid)&&g()):_=f=await $(i);return h.state.next({...!J(l)||v.isValid&&f!==s.isValid?{}:{name:l},...n.resolver||!l?{isValid:f}:{},errors:s.errors,isValidating:!1}),c.shouldFocus&&!_&&Se(i,we,l?b:d.mount),_},Xe=l=>{const c={...a,...u.mount?o:{}};return R(l)?c:J(l)?w(c,l):l.map(f=>w(c,f))},Ye=(l,c)=>({invalid:!!w((c||s).errors,l),isDirty:!!w((c||s).dirtyFields,l),isTouched:!!w((c||s).touchedFields,l),error:w((c||s).errors,l)}),Gt=l=>{l&&Be(l).forEach(c=>P(s.errors,c)),h.state.next({errors:l?s.errors:{}})},Qe=(l,c,f)=>{const _=(w(i,l,{_f:{}})._f||{}).ref;I(s.errors,l,{...c,ref:_}),h.state.next({name:l,errors:s.errors,isValid:!1}),f&&f.shouldFocus&&_&&_.focus&&_.focus()},Ht=(l,c)=>ne(l)?h.values.subscribe({next:f=>l(N(void 0,c),f)}):N(l,c,!0),Ne=(l,c={})=>{for(const f of l?Be(l):d.mount)d.mount.delete(f),d.array.delete(f),c.keepValue||(P(i,f),P(o,f)),!c.keepError&&P(s.errors,f),!c.keepDirty&&P(s.dirtyFields,f),!c.keepTouched&&P(s.touchedFields,f),!n.shouldUnregister&&!c.keepDefaultValue&&P(a,f);h.values.next({values:{...o}}),h.state.next({...s,...c.keepDirty?{isDirty:T()}:{}}),!c.keepIsValid&&g()},et=({disabled:l,name:c,field:f,fields:_,value:b})=>{if(re(l)){const m=l?void 0:R(b)?ze(f?f._f:w(_,c)._f):b;I(o,c,m),te(c,m,!1,!1,!0)}},Re=(l,c={})=>{let f=w(i,l);const _=re(c.disabled);return I(i,l,{...f||{},_f:{...f&&f._f?f._f:{ref:{name:l}},name:l,mount:!0,...c}}),d.mount.add(l),f?et({field:f,disabled:c.disabled,name:l}):se(l,!0,c.value),{..._?{disabled:c.disabled}:{},...n.progressive?{required:!!c.required,min:ge(c.min),max:ge(c.max),minLength:ge(c.minLength),maxLength:ge(c.maxLength),pattern:ge(c.pattern)}:{},name:l,onChange:pe,onBlur:pe,ref:b=>{if(b){Re(l,c),f=w(i,l);const m=R(b.value)&&b.querySelectorAll&&b.querySelectorAll("input,select,textarea")[0]||b,C=rn(m),M=f._f.refs||[];if(C?M.find(D=>D===m):m===f._f.ref)return;I(i,l,{_f:{...f._f,...C?{refs:[...M.filter(je),m,...Array.isArray(w(a,l))?[{}]:[]],ref:{type:m.type,name:l}}:{ref:m}}}),se(l,!1,void 0,m)}else f=w(i,l,{}),f._f&&(f._f.mount=!1),(n.shouldUnregister||c.shouldUnregister)&&!(Hr(d.array,l)&&u.action)&&d.unMount.add(l)}}},tt=()=>n.shouldFocusError&&Se(i,we,d.mount),Wt=l=>{re(l)&&(h.state.next({disabled:l}),Se(i,c=>{c.disabled=l},0,!1))},rt=(l,c)=>async f=>{f&&(f.preventDefault&&f.preventDefault(),f.persist&&f.persist());let _=ee(o);if(h.state.next({isSubmitting:!0}),n.resolver){const{errors:b,values:m}=await U();s.errors=b,_=m}else await $(i);P(s.errors,"root"),G(s.errors)?(h.state.next({errors:{}}),await l(_,f)):(c&&await c({...s.errors},f),tt(),setTimeout(tt)),h.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:G(s.errors),submitCount:s.submitCount+1,errors:s.errors})},Jt=(l,c={})=>{w(i,l)&&(R(c.defaultValue)?ae(l,w(a,l)):(ae(l,c.defaultValue),I(a,l,c.defaultValue)),c.keepTouched||P(s.touchedFields,l),c.keepDirty||(P(s.dirtyFields,l),s.isDirty=c.defaultValue?T(l,w(a,l)):T()),c.keepError||(P(s.errors,l),v.isValid&&g()),h.state.next({...s}))},nt=(l,c={})=>{const f=l?ee(l):a,_=ee(f),b=l&&!G(l)?_:a;if(c.keepDefaultValues||(a=f),!c.keepValues){if(c.keepDirtyValues||k)for(const m of d.mount)w(s.dirtyFields,m)?I(b,m,w(o,m)):ae(m,w(b,m));else{if(He&&R(l))for(const m of d.mount){const C=w(i,m);if(C&&C._f){const M=Array.isArray(C._f.refs)?C._f.refs[0]:C._f.ref;if(Ee(M)){const D=M.closest("form");if(D){D.reset();break}}}}i={}}o=e.shouldUnregister?c.keepDefaultValues?ee(a):{}:ee(b),h.array.next({values:{...b}}),h.values.next({values:{...b}})}d={mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},!u.mount&&r(),u.mount=!v.isValid||!!c.keepIsValid,u.watch=!!e.shouldUnregister,h.state.next({submitCount:c.keepSubmitCount?s.submitCount:0,isDirty:c.keepDirty?s.isDirty:!!(c.keepDefaultValues&&!ie(l,a)),isSubmitted:c.keepIsSubmitted?s.isSubmitted:!1,dirtyFields:c.keepDirtyValues?s.dirtyFields:c.keepDefaultValues&&l?$e(a,l):{},touchedFields:c.keepTouched?s.touchedFields:{},errors:c.keepErrors?s.errors:{},isSubmitSuccessful:c.keepIsSubmitSuccessful?s.isSubmitSuccessful:!1,isSubmitting:!1})},st=(l,c)=>nt(ne(l)?l(o):l,c);return{control:{register:Re,unregister:Ne,getFieldState:Ye,handleSubmit:rt,setError:Qe,_executeSchema:U,_getWatch:N,_getDirty:T,_updateValid:g,_removeUnmounted:V,_updateFieldArray:O,_updateDisabledField:et,_getFieldArray:q,_reset:nt,_resetDefaultValues:()=>ne(n.defaultValues)&&n.defaultValues().then(l=>{st(l,n.resetOptions),h.state.next({isLoading:!1})}),_updateFormState:l=>{s={...s,...l}},_disableForm:Wt,_subjects:h,_proxyFormState:v,get _fields(){return i},get _formValues(){return o},get _state(){return u},set _state(l){u=l},get _defaultValues(){return a},get _names(){return d},set _names(l){d=l},get _formState(){return s},set _formState(l){s=l},get _options(){return n},set _options(l){n={...n,...l}}},trigger:Le,register:Re,handleSubmit:rt,watch:Ht,setValue:ae,getValues:Xe,reset:st,resetField:Jt,clearErrors:Gt,unregister:Ne,setError:Qe,setFocus:(l,c={})=>{const f=w(i,l),_=f&&f._f;if(_){const b=_.refs?_.refs[0]:_.ref;b.focus&&(b.focus(),c.shouldSelect&&b.select())}},getFieldState:Ye}}function Ie(e={}){const r=t.Cn.useRef(),n=t.Cn.useRef(),[s,i]=t.Cn.useState({isDirty:!1,isValidating:!1,isLoading:ne(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},errors:{},disabled:!1,defaultValues:ne(e.defaultValues)?void 0:e.defaultValues});r.current||(r.current={...un(e,()=>i(o=>({...o}))),formState:s});const a=r.current.control;return a._options=e,Xr({subject:a._subjects.state,next:o=>{Zr(o,a._proxyFormState,a._updateFormState,!0)&&i({...a._formState})}}),t.Cn.useEffect(()=>a._disableForm(e.disabled),[a,e.disabled]),t.Cn.useEffect(()=>{if(a._proxyFormState.isDirty){const o=a._getDirty();o!==s.isDirty&&a._subjects.state.next({isDirty:o})}},[a,s.isDirty]),t.Cn.useEffect(()=>{e.values&&!ie(e.values,n.current)?(a._reset(e.values,a._options.resetOptions),n.current=e.values):a._resetDefaultValues()},[e.values,a]),t.Cn.useEffect(()=>{a._state.mount||(a._updateValid(),a._state.mount=!0),a._state.watch&&(a._state.watch=!1,a._subjects.state.next({...a._formState})),a._removeUnmounted()}),r.current.formState=Jr(s,a),r.current}var kt=function(e,r,n){if(e&&"reportValidity"in e){var s=w(n,r);e.setCustomValidity(s&&s.message||""),e.reportValidity()}},cn=function(e,r){var n=function(i){var a=r.fields[i];a&&a.ref&&"reportValidity"in a.ref?kt(a.ref,i,e):a.refs&&a.refs.forEach(function(o){return kt(o,i,e)})};for(var s in r.fields)n(s)},dn=function(e,r){r.shouldUseNativeValidation&&cn(e,r);var n={};for(var s in e){var i=w(r.fields,s),a=Object.assign(e[s]||{},{ref:i&&i.ref});if(hn(r.names||Object.keys(e),s)){var o=Object.assign({},fn(w(n,s)));I(o,"root",a),I(n,s,o)}else I(n,s,a)}return n},fn=function(e){return Array.isArray(e)?e.filter(Boolean):[]},hn=function(e,r){return e.some(function(n){return n.startsWith(r+".")})},pn=function(e,r){for(var n={};e.issues.length;){var s=e.issues[0];if(s.path){var i=s.path.map(function(u){return u.key}).join(".");if(n[i]||(n[i]={message:s.message,type:s.validation}),r){var a=n[i].types,o=a&&a[s.validation];n[i]=Bt(i,r,n,s.validation,o?[].concat(o,s.message):s.message)}e.issues.shift()}}return n},Me=function(e,r,n){return n===void 0&&(n={}),function(s,i,a){try{return Promise.resolve(function(o,u){try{var d=function(){function p(v){return{values:n.raw?s:v,errors:{}}}var x=Object.assign({},{abortEarly:!1,abortPipeEarly:!1},r);return n.mode==="sync"?p(t.parse(e,s,x)):Promise.resolve(t.parseAsync(e,s,x)).then(p)}()}catch(p){return u(p)}return d&&d.then?d.then(void 0,u):d}(0,function(o){if(o instanceof t.ValiError)return{values:{},errors:dn(pn(o,!a.shouldUseNativeValidation&&a.criteriaMode==="all"),a)};throw o}))}catch(o){return Promise.reject(o)}}};const St=27,Ct=12,Et=10,mn=t.isSubmissionOfType("enum"),gn=(e,r)=>{const n={min:e.minSelected??0,max:e.maxSelected??e.options.length};return Me(t.object({checked:t.transform(t.record(t.boolean()),s=>Object.entries(s).filter(([i,a])=>a).map(([i,a])=>i),[t.maxLength(n.max,r("validation_multiple_choice_max",{count:n.max})),t.minLength(n.min,r("validation_multiple_choice_min",{count:n.min}))])}))},bn=t.k$1(({option:e,...r},n)=>t.o(t.k,{children:[t.o("input",{class:"peer sr-only h-full",type:"checkbox",...r,ref:n}),t.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})]})),At=t.cva("gutter-stable flex w-full flex-1 flex-wrap gap-3 overflow-y-auto rounded-xl p-2.5 pr-4",{variants:{variant:{singleOption:"justify-center",booleanLike:Lt}}}),yn=({input:e,onSubmitSuccess:r})=>{var x,v;const n=e.key?(x=t.store.current$.value.flow)==null?void 0:x.data.submissions[e.key]:void 0,s=(e.config.minSelected===1||e.config.minSelected===void 0)&&e.config.maxSelected===1,i=s&&e.config.options.length===2,{t:a}=t.useTranslation(),{register:o,handleSubmit:u,formState:{errors:d}}=Ie({defaultValues:{checked:s?{}:mn(n)?Object.fromEntries(n.value.map(h=>[h,!0])):{}},resolver:gn(e.config,a)}),p=Ge();return i?t.o("ul",{style:{maxHeight:6.5*St+5*Ct+2*Et},class:At({variant:"booleanLike"}),children:e.config.options.map((h,k)=>t.o("li",{class:"flex-1",children:t.o(Nt,{type:"submit",ref:y=>{y&&k===0&&(p.current=y)},label:h.label,value:"true",onClick:()=>r({type:"enum",value:[h.value]})})},h.value))}):t.o("form",{noValidate:!0,onSubmit:h=>u(k=>{const y=k.checked;r({type:"enum",value:y})})(h),children:[t.o("div",{class:"flex items-center gap-1",children:[t.o("ul",{style:{maxHeight:6.5*St+5*Ct+2*Et},class:At({variant:e.config.options.length===1?"singleOption":void 0}),children:e.config.options.map((h,k)=>{const y=`checked.${h.value}`,{ref:A,...S}=o(y);return t.o("li",{class:"relative",children:t.o(bn,{option:h,autoFocus:k===0,ref:E=>{E&&k===0&&(p.current=E),A(E)},id:y,...S,onClick:s?()=>r({type:"enum",value:[h.value]}):void 0})},h.value)})}),t.o("div",{class:"flex flex-col items-center gap-2 pr-2.5 pt-2.5",children:[s?null:t.o(oe,{}),e.config.minSelected===0&&t.o(le,{type:"button",onClick:()=>r({type:"enum",value:[]})})]})]}),t.o("div",{class:"px-1",children:t.o(fe,{error:(v=d.checked)==null?void 0:v.root})})]})},vn=t.isSubmissionOfType("number"),xn=(e,r)=>{const n=e.min??Number.MIN_SAFE_INTEGER,s=e.max??Number.MAX_SAFE_INTEGER,i=e.decimalCases??0;return Me(t.object({number:t.number(r("validation_number"),[t.minValue(n,r("validation_number_min",{min:n})),t.maxValue(s,r("validation_number_max",{max:s})),t.custom(a=>a===Number(a.toFixed(i)),r("validation_number_decimal_cases",{count:i}))])}))},wn=({input:e,onSubmitSuccess:r})=>{var v;const n=e.config.defaultValue,s=e.key?(v=t.store.current$.value.flow)==null?void 0:v.data.submissions[e.key]:void 0,{t:i}=t.useTranslation(),{register:a,handleSubmit:o,formState:{errors:u}}=Ie({defaultValues:{number:n?Number(n):vn(s)?s.value:void 0},resolver:xn(e.config,i)}),{ref:d,...p}=a("number",{required:!e.config.optional,valueAsNumber:!0}),x=t._$1();return t.y(()=>{x.current&&(x.current.focus(),x.current.select())},[]),t.o("form",{class:"flex flex-col gap-1 p-2.5",onSubmit:o(h=>{h.number!==void 0&&r({type:"number",value:h.number})}),children:[t.o("div",{class:"flex items-center gap-2",children:[t.o("div",{class:"relative min-w-0 flex-grow",children:[t.o("input",{...p,id:"chat-input",autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:h=>{h&&(x.current=h),d(h)},type:"text",min:e.config.min,max:e.config.max,class:ye({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&&t.o(le,{class:"absolute right-0 top-0",onClick:()=>r(null)})]}),t.o(oe,{})]}),t.o(fe,{error:u.number})]})},_n=e=>{if(e==="")return{countryCode:"",phoneNumber:""};const r=Object.entries(Ke).find(i=>e.startsWith(i[1])),n=r?r[1]:"",s=e.replace(n,"");return/^\d+$/.test(s)?{countryCode:n,phoneNumber:s}:{countryCode:"",phoneNumber:""}},kn="44",Sn=/^[0-9 ]+$/,Cn=t.isSubmissionOfType("string"),En=t.isSubmissionOfType("phone"),An=e=>{const r=t.string(e("validation_country_code"),[t.regex(Sn,e("validation_country_code"))]),n=t.transform(t.string(e("validation_phone"),[t.minLength(1,e("validation_phone"))]),s=>s.replace(/[^0-9]/g,""),[]);return Me(t.object({countryCode:r,phoneNumber:n}))},Tn=({input:e,onSubmitSuccess:r})=>{var A;const n=e.key?(A=t.store.current$.value.flow)==null?void 0:A.data.submissions[e.key]:void 0,{t:s}=t.useTranslation(),[i,a]=t.h(),o=Cn(n)?_n(n.value):En(n)?n.value:void 0,{register:u,handleSubmit:d,formState:{errors:p},watch:x}=Ie({defaultValues:{countryCode:(o==null?void 0:o.countryCode)??e.config.defaultValue.countryCode??kn,phoneNumber:(o==null?void 0:o.phoneNumber)??e.config.defaultValue.phoneNumber??""},resolver:An(s)}),{ref:v,...h}=u("phoneNumber",{required:!e.config.optional}),k=t._$1(),y=x("countryCode");return t.y(()=>{k.current&&(k.current.focus(),k.current.select())},[]),t.o("form",{noValidate:!0,class:"flex flex-col gap-1 p-2.5",onSubmit:d(S=>{const E=S.phoneNumber.replace(/[^0-9]/g,""),g=S.countryCode.replace(/[^0-9]/g,"");a(void 0);const F=e.config.minChars??7;if(E.length+g.length<F)return a(s("validation_phone_min_chars",{count:F}));e.config.submissionFormat==="phone"?r({type:"phone",value:{countryCode:g,phoneNumber:E}}):r({type:"string",value:y+S.phoneNumber})}),children:[t.o("div",{class:"flex items-center gap-2",children:[t.o("div",{class:"relative flex min-w-0 flex-1 flex-grow gap-2",children:[t.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:[t.o("span",{children:["+",y]}),t.o("select",{...u("countryCode",{}),id:`isdk_phone_${e.key}`,class:"absolute inset-0 opacity-0",children:Object.entries(Ke).map(([S,E])=>t.o("option",{value:E,children:[S," (+",E,")"]},S))})]}),t.o("input",{...h,id:"chat-input",type:"tel",inputMode:"tel",autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:S=>{S&&(k.current=S),v(S)},class:ye({optional:e.config.optional,className:"min-w-0 flex-1 rounded-r-full"}),placeholder:e.config.placeholder}),e.config.optional&&t.o(le,{class:"absolute bottom-0 right-0 top-0",onClick:()=>r(null)})]}),t.o(oe,{})]}),t.o(fe,{error:p.countryCode||p.phoneNumber||{message:i}})]})},Vn=({input:e,onSubmitSuccess:r})=>t.o("div",{class:"flex flex-col items-center py-3",children:t.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:t.o("span",{class:"flex items-center gap-1.5",children:[t.o("span",{class:"inline-flex items-center text-sm font-medium",children:e.config.label||"Submit"}),t.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:[t.o("path",{d:"M4 8L8 4L12 8"}),t.o("path",{d:"M8 4V13"})]})]})})}),Fn={email:{type:"email",inputMode:"email",formNoValidate:!0},text:{type:"text",inputMode:"text"},url:{type:"url",inputMode:"url",formNoValidate:!0}},In=t.isSubmissionOfType("string"),Mn=(e,r)=>{const n={maxLength:r("validation_max_chars",{count:e.maxChars??999}),minLength:r("validation_min_chars",{count:e.minChars??1})};return Me(t.object({text:{email:t.string(r("validation_email"),[t.email(r("validation_email")),t.minLength(e.minChars??1,n.minLength),t.maxLength(e.maxChars??1/0,n.maxLength)]),text:t.string([t.minLength(e.minChars??1,n.minLength),t.maxLength(e.maxChars??1/0,n.maxLength)]),url:t.string([t.url(r("validation_url")),t.minLength(e.minChars??1,n.minLength),t.maxLength(e.maxChars??1/0,n.maxLength)])}[e.format]}))},Ln=({input:e,onSubmitSuccess:r})=>{var v;const{t:n}=t.useTranslation(),s=e.key?(v=t.store.current$.value.flow)==null?void 0:v.data.submissions[e.key]:void 0,i=e.config.defaultValue,{register:a,handleSubmit:o,formState:{errors:u}}=Ie({defaultValues:{text:i||(In(s)?s.value:"")},resolver:Mn(e.config,n)}),{ref:d,...p}=a("text",{required:!e.config.optional}),x=t._$1();return t.y(()=>{x.current&&(x.current.focus(),x.current.select())},[]),t.o("form",{noValidate:!0,class:"flex flex-col gap-1 p-2.5",onSubmit:o(h=>{r({type:"string",value:h.text})}),children:[t.o("div",{class:"flex items-center gap-2",children:[t.o("div",{class:"relative min-w-0 flex-1",children:[t.o("input",{id:"chat-input",...p,...Fn[e.config.format],autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:h=>{h&&(x.current=h),d(h)},placeholder:e.config.placeholder,class:ye({optional:!!e.config.optional,className:"w-full rounded-full"})}),e.config.optional&&t.o(le,{class:"absolute right-0 top-0",onClick:()=>r(null)})]}),t.o(oe,{})]}),t.o(fe,{error:u.text})]})},Nn={text:Ln,phone:Tn,"multiple-choice":yn,boolean:Or,file:Ur,submit:Vn,address:Lr,number:wn},Rn=({logger:e})=>{var a;const r=(a=t.store.current$.value.flow)==null?void 0:a.data.currentInput,[n,s]=wr(),i=t._$1(null);return t.store.inputHeight$.value=s.height,t.p(()=>{const o=i.current;if(o)return o.addEventListener("transitionstart",j.scrollToEnd.smooth),o.addEventListener("transitioncancel",j.scrollToEnd.smooth),o.addEventListener("transitionend",j.scrollToEnd.smooth),()=>{o.removeEventListener("transitionstart",j.scrollToEnd.smooth),o.removeEventListener("transitioncancel",j.scrollToEnd.smooth),o.removeEventListener("transitionend",j.scrollToEnd.smooth)}},[]),t.o("div",{ref:i,class:"ease-expo-out absolute bottom-0 w-full overflow-hidden rounded-b-3xl backdrop-blur-xl transition-all duration-700 will-change-[height]",style:{height:s.height},children:t.o("div",{ref:n,class:"border-divider flex flex-col justify-end border-t",children:r?(()=>{const o=Nn[r.type];return t.o(o,{logger:e,onSubmitSuccess:j.onSubmitSuccessFn$.value,input:r})})():t.o("div",{class:"flex items-center gap-2 p-2.5",children:[t.o("input",{"aria-hidden":"true",id:"chat-input",class:ye({optional:!1,className:"flex-grow rounded-full"}),disabled:!0}),t.o(oe,{disabled:!0,"aria-hidden":"true",tabIndex:-1})]})})})};var Dn=function(e){return e instanceof RegExp},On=function(r){var n=/[\\^$.*+?()[\]{}|]/g,s=RegExp(n.source);return r&&s.test(r)?r.replace(n,"\\$&"):r},Kt=function(e){return typeof e=="string"},Bn=function(e){var r=[];return e.forEach(function(n){Array.isArray(n)?r=r.concat(n):r.push(n)}),r};function Pn(e,r,n){var s=0,i=0;if(e==="")return e;if(!e||!Kt(e))throw new TypeError("First argument to react-string-replace#replaceString must be a string");var a=r;Dn(a)||(a=new RegExp("("+On(a)+")","gi"));for(var o=e.split(a),u=1,d=o.length;u<d;u+=2){if(o[u]===void 0||o[u-1]===void 0){console.warn("reactStringReplace: Encountered undefined value during string replacement. Your RegExp may not be working the way you expect.");continue}i=o[u].length,s+=o[u-1].length,o[u]=n(o[u],u,s),s+=i}return o}var jn=function(r,n,s){return Array.isArray(r)||(r=[r]),Bn(r.map(function(i){return Kt(i)?Pn(i,n,s):i}))};const ke=t.getDefaultExportFromCjs(jn),$n=/(\[[^\]]+\]\([^)]+\))/g,zn=/\[([^\]]+)\]\(([^)]+)\)/,qn=/(https?:\/\/[^\s]+)/g,Un=/_(.*?)_/g,Kn=/\*\*(.*?)\*\*/g,Tt="text-accent-10 hover:text-accent-11 no-underline underline-offset-2 hover:underline",Gn=e=>{const r=ke(e,$n,(a,o)=>{const[,u,d]=a.match(zn)??[];return d?t.o("a",{class:Tt,href:d,children:u??d},d+o):t.o("span",{children:"INVALID LINK"})}),n=ke(r,qn,(a,o)=>t.o("a",{class:Tt,href:a,children:a},a+o)),s=ke(n,Un,(a,o)=>t.o("em",{children:a},a+o));return ke(s,Kn,(a,o)=>t.o("strong",{children:a},a+o))},Hn=t.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"}}),Wn=({children:e,className:r,animate:n,side:s,...i})=>t.o("p",{style:{transformOrigin:s==="left"?"0% 50%":"100% 50%"},class:Hn({className:r,side:s,animate:n}),...i,children:e}),Jn=({message:e})=>t.o("div",{class:"bg-accent-3 flex w-full items-center justify-center overflow-hidden rounded-xl px-2 py-2",children:t.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,t.o("svg",{class:"flex-none",width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:t.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"})})]})}),Zn=({className:e,...r})=>(t.p(()=>{j.scrollToEnd.smooth()}),t.o("div",{"aria-hidden":!0,children:j.isBotTyping$.value===!0?t.o("div",{"aria-label":"Typing…",class:t.clsx("flex gap-1 p-4",e),...r,children:Array.from({length:3},(n,s)=>t.o("div",{class:"bg-accent-9 h-1.5 w-1.5 animate-bounce rounded-full",style:{animationDelay:`${-s*200}ms`}}))}):void 0})),Xn={bot:"left",user:"right"},Yn=t.cva("w-full select-none py-2 text-wrap-balance text-center text-[10px] uppercase tracking-widest drop-shadow-[0_1.5px_var(--i-color-n-1)]",{variants:{variant:{info:"text-neutral-8",warning:"text-[#FFC107]",error:"text-error-9",success:"text-[#4CAF50]"}}}),Qn=({lastSentMessageFooter:e})=>{var n;const r=((n=t.store.current$.value.flow)==null?void 0:n.data.messages)??[];return t.p(()=>{j.scrollToEnd.smooth()},[r.length]),t.o("ol",{"aria-label":"Chat messages",class:"mt-auto flex flex-col justify-end gap-2 p-2 pt-[calc(var(--header-height)+1rem)]",children:[r.map((s,i)=>t.o(t.k,{children:t.o("li",{class:"flex",children:t.N(s).with({type:"system"},a=>t.o("p",{class:Yn({variant:a.variant}),children:a.text})).with({type:"text",author:t._.union("bot","user")},a=>{const o=a.author==="user"&&!r.slice(i+1).some(p=>p.type==="text"&&p.author==="user"),u=i===r.length-1,d=a.author==="bot"?Gn(a.text):a.text;return t.o(Wn,{animate:u,side:Xn[a.author],children:[d,o?e:null]},i)}).with({type:"link"},a=>t.o(Jn,{message:a})).with({type:"image"},a=>t.o("img",{class:"shadow-surface-md w-full max-w-[min(100%,24rem)] rounded-2xl",src:a.url,style:{aspectRatio:a.width/a.height}})).with({type:"file"},a=>t.o($r,{class:a.author==="bot"?void 0:"ml-auto",file:{name:a.fileName,sizeKb:a.fileSizeKb}})).with({type:"loading"},a=>{const o=r[r.length-1];return!(a===o)||j.isBotTyping$.value?null:t.o("div",{class:"flex flex-grow flex-col items-center justify-center",children:t.o(t.LoadingIndicator,{class:"text-neutral-6 h-8 w-8"})})}).exhaustive()})},i)),t.o(Zn,{},"typing")]})},es=({logger:e,apiClient:r,analytics:n})=>{const{flow:s}=t.store.current$.value;t.invariant(s,"Flow is required to exist to show chatbot body");const i=t.store.viewState$.value,{chatRef:a,chatService:o}=Ar(),{t:u}=t.useTranslation(),[d,p]=t.h();return t.y(()=>{i==="maximised"&&j.scrollToEnd.instant()},[i]),t.y(()=>{var S,E;const{state:x,flow:v}=t.store.current$.peek();if(x!=="loaded")throw new Error(u("invalid_state"));let h=v.data.nodeHistory.at(-1);if(j.scrollToEnd.instant(),t.store.setInput(void 0),v.data.isFinished)return;h===void 0?(h=t.getHeadOrThrow(s.nodes).id,t.store.setCurrentNodeId(h),n.log({event:"FLOW_START",properties:{flow_id:s.id,flow_version:s.version,flow_session_id:v.data.flowSessionId,flow_build:s.build,job:s.job},customProperties:(S=s.analytics)==null?void 0:S.customProperties})):t.store.removeMessagesSentByNodeIds([h]);const{interpret:k,abort:y,undo:A}=tr({context:s.context,analytics:{service:n,customProperties:(E=s.analytics)==null?void 0:E.customProperties},apiClient:r,logger:e,flow:s,chatService:o,t:u,getSubmissions:()=>{var g;return(g=t.store.current$.peek().flow)==null?void 0:g.data.submissions},onInterpret:(g,F)=>{var L;const O=t.store.current$.peek().flow;t.invariant(O),F&&(O.data.sequence=O.data.sequence+1,n.log({event:"FLOW_NODE",properties:{flow_id:s.id,flow_version:s.version,from_node_id:F.id,flow_build:s.build,to_node_id:g.id,sequence:O.data.sequence,flow_session_id:O.data.flowSessionId,job:s.job},customProperties:(L=s.analytics)==null?void 0:L.customProperties})),t.store.setCurrentNodeId(g.id)},onFlowEnd:async()=>{var F;t.store.markAsFinished();const g=t.store.current$.peek().flow;t.invariant(g),n.log({event:"FLOW_END",properties:{flow_id:s.id,flow_version:s.version,flow_session_id:g.data.flowSessionId,flow_build:s.build,job:s.job},customProperties:(F=s.analytics)==null?void 0:F.customProperties})}});return p(()=>A),k(h),y},[n,r,o,e,s,u]),t.o(t.k,{children:[t.o("div",{ref:a,className:"hide-scrollbars relative flex w-full max-w-full flex-grow flex-col overflow-y-scroll",style:{WebkitOverflowScrolling:"touch",paddingBottom:t.store.inputHeight$.value},children:t.o(Qn,{lastSentMessageFooter:s.data.isFinished||!d?null:t.o(rs,{undoFn:d})})}),t.o(Rn,{logger:e})]})},ts=e=>"key"in e.data&&e.data.key?[e.data.key]:"keys"in e.data?Object.values(e.data.keys).filter(r=>typeof r=="string"):[],rs=({undoFn:e})=>{const{t:r}=t.useTranslation();return t.o("div",{class:"absolute bottom-0 right-0 flex w-full translate-y-full justify-end",children:t.o("button",{class:"fr touch-hitbox text-neutral-9 hover:text-neutral-12 rounded-full p-1 text-right text-xs transition-all",onClick:async()=>{const{flow:n}=t.store.current$.peek();t.invariant(n);const{removed:s}=e(n.data.nodeHistory),i=n.data.nodeHistory.splice(-s);i.length!==0&&(t.store.removeMessagesSentByNodeIds(i),t.store.setInput(void 0),i.pop(),i.map(a=>n.nodes.find(o=>o.id===a)).filter(Boolean).flatMap(ts).forEach(a=>delete n.data.submissions[a]),t.store.current$.value={...t.store.current$.value})},children:r("undo")})})};exports.ChatbotBody=es;
@@ -112,7 +112,6 @@ export declare const FlowSchema: import("valibot").ObjectSchema<{
112
112
  question: string;
113
113
  optional: boolean;
114
114
  placeholder: string;
115
- maxChars: number;
116
115
  minChars: number;
117
116
  defaultCountryCode: string;
118
117
  };
@@ -337,7 +336,6 @@ export declare const FlowSchema: import("valibot").ObjectSchema<{
337
336
  question: string;
338
337
  optional: boolean;
339
338
  placeholder: string;
340
- maxChars: number;
341
339
  minChars: number;
342
340
  defaultCountryCode: string;
343
341
  };
@@ -589,7 +587,6 @@ export declare const FlowSchema: import("valibot").ObjectSchema<{
589
587
  question: string;
590
588
  optional: boolean;
591
589
  placeholder: string;
592
- maxChars: number;
593
590
  minChars: number;
594
591
  defaultCountryCode: string;
595
592
  };
@@ -828,7 +825,6 @@ export declare const FlowByIdPayloadSchema: import("valibot").ObjectSchema<{
828
825
  question: string;
829
826
  optional: boolean;
830
827
  placeholder: string;
831
- maxChars: number;
832
828
  minChars: number;
833
829
  defaultCountryCode: string;
834
830
  };
@@ -1053,7 +1049,6 @@ export declare const FlowByIdPayloadSchema: import("valibot").ObjectSchema<{
1053
1049
  question: string;
1054
1050
  optional: boolean;
1055
1051
  placeholder: string;
1056
- maxChars: number;
1057
1052
  minChars: number;
1058
1053
  defaultCountryCode: string;
1059
1054
  };
@@ -1305,7 +1300,6 @@ export declare const FlowByIdPayloadSchema: import("valibot").ObjectSchema<{
1305
1300
  question: string;
1306
1301
  optional: boolean;
1307
1302
  placeholder: string;
1308
- maxChars: number;
1309
1303
  minChars: number;
1310
1304
  defaultCountryCode: string;
1311
1305
  };
@@ -1543,7 +1537,6 @@ export declare const FlowByIdPayloadSchema: import("valibot").ObjectSchema<{
1543
1537
  question: string;
1544
1538
  optional: boolean;
1545
1539
  placeholder: string;
1546
- maxChars: number;
1547
1540
  minChars: number;
1548
1541
  defaultCountryCode: string;
1549
1542
  };
@@ -1787,7 +1780,6 @@ export declare const FlowByJobPayloadSchema: import("valibot").ObjectSchema<{
1787
1780
  question: string;
1788
1781
  optional: boolean;
1789
1782
  placeholder: string;
1790
- maxChars: number;
1791
1783
  minChars: number;
1792
1784
  defaultCountryCode: string;
1793
1785
  };
@@ -2012,7 +2004,6 @@ export declare const FlowByJobPayloadSchema: import("valibot").ObjectSchema<{
2012
2004
  question: string;
2013
2005
  optional: boolean;
2014
2006
  placeholder: string;
2015
- maxChars: number;
2016
2007
  minChars: number;
2017
2008
  defaultCountryCode: string;
2018
2009
  };
@@ -2264,7 +2255,6 @@ export declare const FlowByJobPayloadSchema: import("valibot").ObjectSchema<{
2264
2255
  question: string;
2265
2256
  optional: boolean;
2266
2257
  placeholder: string;
2267
- maxChars: number;
2268
2258
  minChars: number;
2269
2259
  defaultCountryCode: string;
2270
2260
  };
@@ -2509,7 +2499,6 @@ export declare const FlowByJobPayloadSchema: import("valibot").ObjectSchema<{
2509
2499
  question: string;
2510
2500
  optional: boolean;
2511
2501
  placeholder: string;
2512
- maxChars: number;
2513
2502
  minChars: number;
2514
2503
  defaultCountryCode: string;
2515
2504
  };
@@ -103,7 +103,6 @@ export declare const getHeadOrThrow: (nodes: FlowNode[]) => {
103
103
  question: string;
104
104
  optional: boolean;
105
105
  placeholder: string;
106
- maxChars: number;
107
106
  minChars: number;
108
107
  defaultCountryCode: string;
109
108
  };
@@ -12,7 +12,6 @@ export type PhonePayload = {
12
12
  phoneNumber?: string;
13
13
  };
14
14
  minChars?: number;
15
- maxChars?: number;
16
15
  };
17
16
  submission: FlowSubmissionPhone | FlowSubmissionString | null;
18
17
  };
package/dist/i18n.d.ts CHANGED
@@ -39,6 +39,7 @@ export declare const TranslationProvider: (props: {
39
39
  readonly validation_max_chars: "Please enter no more than {{count}} characters";
40
40
  readonly validation_min_chars: "Please enter {{count}} or more characters";
41
41
  readonly validation_phone: "Please enter a valid phone number";
42
+ readonly validation_phone_min_chars: "Your phone number must be at least {{count}} digits long";
42
43
  readonly validation_country_code: "Please select a country code";
43
44
  readonly validation_number: "Please enter a valid number";
44
45
  readonly validation_number_min: "Please enter a number greater than or equal to {{min}}";
@@ -52,6 +53,14 @@ export declare const TranslationProvider: (props: {
52
53
  };
53
54
  readonly validation_email: "That doesn’t look like a valid email address";
54
55
  readonly validation_url: "That doesn’t look like a valid URL";
56
+ readonly validation_multiple_choice_min: {
57
+ readonly one: "Please select at least {{count}} option";
58
+ readonly other: "Please select at least {{count}} options";
59
+ };
60
+ readonly validation_multiple_choice_max: {
61
+ readonly one: "Please select at most {{count}} option";
62
+ readonly other: "Please select at most {{count}} options";
63
+ };
55
64
  }>> | undefined;
56
65
  locale: string | undefined;
57
66
  children?: import("preact").ComponentChildren;
@@ -95,6 +104,7 @@ export declare const TranslationProvider: (props: {
95
104
  readonly validation_max_chars: "Please enter no more than {{count}} characters";
96
105
  readonly validation_min_chars: "Please enter {{count}} or more characters";
97
106
  readonly validation_phone: "Please enter a valid phone number";
107
+ readonly validation_phone_min_chars: "Your phone number must be at least {{count}} digits long";
98
108
  readonly validation_country_code: "Please select a country code";
99
109
  readonly validation_number: "Please enter a valid number";
100
110
  readonly validation_number_min: "Please enter a number greater than or equal to {{min}}";
@@ -108,6 +118,14 @@ export declare const TranslationProvider: (props: {
108
118
  };
109
119
  readonly validation_email: "That doesn’t look like a valid email address";
110
120
  readonly validation_url: "That doesn’t look like a valid URL";
121
+ readonly validation_multiple_choice_min: {
122
+ readonly one: "Please select at least {{count}} option";
123
+ readonly other: "Please select at least {{count}} options";
124
+ };
125
+ readonly validation_multiple_choice_max: {
126
+ readonly one: "Please select at most {{count}} option";
127
+ readonly other: "Please select at most {{count}} options";
128
+ };
111
129
  } = {
112
130
  readonly error_heading: "Something unexpected happened";
113
131
  readonly undo: "Undo";
@@ -148,6 +166,7 @@ export declare const TranslationProvider: (props: {
148
166
  readonly validation_max_chars: "Please enter no more than {{count}} characters";
149
167
  readonly validation_min_chars: "Please enter {{count}} or more characters";
150
168
  readonly validation_phone: "Please enter a valid phone number";
169
+ readonly validation_phone_min_chars: "Your phone number must be at least {{count}} digits long";
151
170
  readonly validation_country_code: "Please select a country code";
152
171
  readonly validation_number: "Please enter a valid number";
153
172
  readonly validation_number_min: "Please enter a number greater than or equal to {{min}}";
@@ -161,6 +180,14 @@ export declare const TranslationProvider: (props: {
161
180
  };
162
181
  readonly validation_email: "That doesn’t look like a valid email address";
163
182
  readonly validation_url: "That doesn’t look like a valid URL";
183
+ readonly validation_multiple_choice_min: {
184
+ readonly one: "Please select at least {{count}} option";
185
+ readonly other: "Please select at least {{count}} options";
186
+ };
187
+ readonly validation_multiple_choice_max: {
188
+ readonly one: "Please select at most {{count}} option";
189
+ readonly other: "Please select at most {{count}} options";
190
+ };
164
191
  }>() => {
165
192
  t: import("@inploi/i18n/translation").TFn<T>;
166
193
  locale: string | undefined;
@@ -204,6 +231,7 @@ export declare const TranslationProvider: (props: {
204
231
  readonly validation_max_chars: "Please enter no more than {{count}} characters";
205
232
  readonly validation_min_chars: "Please enter {{count}} or more characters";
206
233
  readonly validation_phone: "Please enter a valid phone number";
234
+ readonly validation_phone_min_chars: "Your phone number must be at least {{count}} digits long";
207
235
  readonly validation_country_code: "Please select a country code";
208
236
  readonly validation_number: "Please enter a valid number";
209
237
  readonly validation_number_min: "Please enter a number greater than or equal to {{min}}";
@@ -217,6 +245,14 @@ export declare const TranslationProvider: (props: {
217
245
  };
218
246
  readonly validation_email: "That doesn’t look like a valid email address";
219
247
  readonly validation_url: "That doesn’t look like a valid URL";
248
+ readonly validation_multiple_choice_min: {
249
+ readonly one: "Please select at least {{count}} option";
250
+ readonly other: "Please select at least {{count}} options";
251
+ };
252
+ readonly validation_multiple_choice_max: {
253
+ readonly one: "Please select at most {{count}} option";
254
+ readonly other: "Please select at most {{count}} options";
255
+ };
220
256
  } = {
221
257
  readonly error_heading: "Something unexpected happened";
222
258
  readonly undo: "Undo";
@@ -257,6 +293,7 @@ export declare const TranslationProvider: (props: {
257
293
  readonly validation_max_chars: "Please enter no more than {{count}} characters";
258
294
  readonly validation_min_chars: "Please enter {{count}} or more characters";
259
295
  readonly validation_phone: "Please enter a valid phone number";
296
+ readonly validation_phone_min_chars: "Your phone number must be at least {{count}} digits long";
260
297
  readonly validation_country_code: "Please select a country code";
261
298
  readonly validation_number: "Please enter a valid number";
262
299
  readonly validation_number_min: "Please enter a number greater than or equal to {{min}}";
@@ -270,6 +307,14 @@ export declare const TranslationProvider: (props: {
270
307
  };
271
308
  readonly validation_email: "That doesn’t look like a valid email address";
272
309
  readonly validation_url: "That doesn’t look like a valid URL";
310
+ readonly validation_multiple_choice_min: {
311
+ readonly one: "Please select at least {{count}} option";
312
+ readonly other: "Please select at least {{count}} options";
313
+ };
314
+ readonly validation_multiple_choice_max: {
315
+ readonly one: "Please select at most {{count}} option";
316
+ readonly other: "Please select at most {{count}} options";
317
+ };
273
318
  }>(options: {
274
319
  overrides: Partial<import("@inploi/i18n/translation").TranslationDict<{
275
320
  readonly error_heading: "Something unexpected happened";
@@ -311,6 +356,7 @@ export declare const TranslationProvider: (props: {
311
356
  readonly validation_max_chars: "Please enter no more than {{count}} characters";
312
357
  readonly validation_min_chars: "Please enter {{count}} or more characters";
313
358
  readonly validation_phone: "Please enter a valid phone number";
359
+ readonly validation_phone_min_chars: "Your phone number must be at least {{count}} digits long";
314
360
  readonly validation_country_code: "Please select a country code";
315
361
  readonly validation_number: "Please enter a valid number";
316
362
  readonly validation_number_min: "Please enter a number greater than or equal to {{min}}";
@@ -324,6 +370,14 @@ export declare const TranslationProvider: (props: {
324
370
  };
325
371
  readonly validation_email: "That doesn’t look like a valid email address";
326
372
  readonly validation_url: "That doesn’t look like a valid URL";
373
+ readonly validation_multiple_choice_min: {
374
+ readonly one: "Please select at least {{count}} option";
375
+ readonly other: "Please select at least {{count}} options";
376
+ };
377
+ readonly validation_multiple_choice_max: {
378
+ readonly one: "Please select at most {{count}} option";
379
+ readonly other: "Please select at most {{count}} options";
380
+ };
327
381
  }>>;
328
382
  locale: string | undefined;
329
383
  }) => import("@inploi/i18n/translation").TFn<T>;
@@ -2015,6 +2015,7 @@ const {
2015
2015
  validation_max_chars: "Please enter no more than {{count}} characters",
2016
2016
  validation_min_chars: "Please enter {{count}} or more characters",
2017
2017
  validation_phone: "Please enter a valid phone number",
2018
+ validation_phone_min_chars: "Your phone number must be at least {{count}} digits long",
2018
2019
  validation_country_code: "Please select a country code",
2019
2020
  validation_number: "Please enter a valid number",
2020
2021
  validation_number_min: "Please enter a number greater than or equal to {{min}}",
@@ -2027,7 +2028,15 @@ const {
2027
2028
  other: "Please only upload up to {{count}} files"
2028
2029
  },
2029
2030
  validation_email: "That doesn’t look like a valid email address",
2030
- validation_url: "That doesn’t look like a valid URL"
2031
+ validation_url: "That doesn’t look like a valid URL",
2032
+ validation_multiple_choice_min: {
2033
+ one: "Please select at least {{count}} option",
2034
+ other: "Please select at least {{count}} options"
2035
+ },
2036
+ validation_multiple_choice_max: {
2037
+ one: "Please select at most {{count}} option",
2038
+ other: "Please select at most {{count}} options"
2039
+ }
2031
2040
  });
2032
2041
  function Er(t, e) {
2033
2042
  if (!t)
@@ -2984,7 +2993,7 @@ const Kl = (t) => typeof t == "string", el = () => typeof crypto < "u" && "rando
2984
2993
  };
2985
2994
  function oe() {
2986
2995
  }
2987
- const cl = _r(() => import("./chatbot-body-4157a64b.js").then((t) => t.ChatbotBody)), ja = Fs("selection:bg-accent-4 selection:text-accent-12 fixed bottom-2 left-2 right-2 isolate mx-auto max-h-full max-w-[450px] focus:outline-none [&:has(.view-switch:active)]:scale-[0.98] transition-all duration-1000 ease-expo-out", {
2996
+ const cl = _r(() => import("./chatbot-body-38907c4e.js").then((t) => t.ChatbotBody)), ja = Fs("selection:bg-accent-4 selection:text-accent-12 fixed bottom-2 left-2 right-2 isolate mx-auto max-h-full max-w-[450px] focus:outline-none [&:has(.view-switch:active)]:scale-[0.98] transition-all duration-1000 ease-expo-out", {
2988
2997
  variants: {
2989
2998
  view: {
2990
2999
  closed: "hidden",