@inploi/plugin-chatbot 4.0.1 → 4.0.2

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-8ae8589d.cjs");require("@inploi/sdk");const lt=({condition:e,context:r,submissions:n,ifBlock:s})=>{const[a,...o]=e.compareKey.split(".");if(!a)return!1;const i=Ft({context:r,key:a,path:o,submissions:n});if(!i)return!1;switch(i.type){case"address":{const u=t.get(i.value,o.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 i.value!="object"||Array.isArray(i.value))return!1;const u=t.get(i.value,o.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 i.value===u;case"notEquals":return i.value!==u}break}case"phone":case"string":{const u=i.type==="phone"?Ve(i.value):i.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 i.value===u;case"notEquals":return i.value!==u;case"greaterThan":return i.value>u;case"greaterThanOrEqualTo":return i.value>=u;case"lessThan":return i.value<u;case"lessThanOrEqualTo":return i.value<=u}}catch{return console.error(`Failed to parse number in if-block ${s.id}`,i.value),!1}break}case"enum":switch(e.compare){case"equals":return i.value.length===1&&i.value[0]===e.compareValue;case"notEquals":return i.value.length===1&&i.value[0]!==e.compareValue;case"contains":return i.value.includes(e.compareValue);case"notContains":return!i.value.includes(e.compareValue)}break}},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 o of s)if(lt({condition:o,context:r,submissions:n,ifBlock:e}))return!0;return!1}else{for(const o of s)if(!lt({condition:o,context:r,submissions:n,ifBlock:e}))return!1;return!0}},er=/{{\s*([^}]+?)\s*(?:\|\s*([^}]+?)\s*)?}}/g,Z=(e,{context:r,submissions:n})=>e.replace(er,(s,a,o="")=>{const[i,...u]=a.trim().split("."),d=Ft({key:i,path:u,submissions:n,context:r});if(!d)return o;switch(d.type){case"boolean":return d.value===!0?"true":"false";case"file":return d.value.map(h=>`${h.name} (${t.kbToReadableSize(h.sizeKb)})`).join(", ");case"enum":return d.value.join(", ");case"address":return Object.values(d.value).filter(h=>h&&h.trim().length>0).join(", ");case"number":case"string":return d.value?d.value.toString():o;case"phone":return Ve(d.value);case"integration":{if(typeof d.value!="object"||Array.isArray(d.value))break;const h=t.get(d.value,u.join("."));switch(typeof h){case"boolean":return h===!0?"true":"false";case"string":return h;case"number":return h.toString();case"object":if(Array.isArray(h)&&h.every(t.isString))return h.join(", ")}break}}return o}),Vt=({node:e,nodes:r,stopWhen:n})=>{if((n==null?void 0:n(e))===!0)return e;const s=e.nextId?r.find(a=>a.id===e.nextId):void 0;if(s)return Vt({node:s,nodes:r,stopWhen:n})},tr=({childNode:e,nodes:r})=>{const s=r.filter(a=>a.type==="if-block").find(a=>{if(!a.branchId)return!1;const o=r.find(u=>u.id===a.branchId);if(!o)return!1;const i=Vt({node:o,nodes:r,stopWhen:u=>u.id===e.id});return!(!i||i.id!==e.id)});if(s!=null&&s.nextId)return r.find(a=>a.id===s.nextId)},rr=({flow:e,analytics:r,logger:n,context:s,apiClient:a,getSubmissions:o,chatService:i,onFlowEnd:u,onInterpret:d,t:h})=>{let x=new AbortController;const b={...r.service,log:_=>r.service.log({..._,customProperties:{..._.customProperties,...r.customProperties}})},p=async(_,v)=>{const A=o();d==null||d(_,v);try{await nr({flow:e,analytics:b,logger:n,apiClient:a,context:s,node:_,submissions:A,t:h,chat:{sendMessage:async S=>i.send({groupId:_.id,message:S,signal:x.signal}),userInput:async S=>i.input({input:S,signal:x.signal}),addToSubmissions:i.addToSubmissions},next:S=>{const E=S?e.nodes.find(g=>g.id===S):tr({childNode:_,nodes:e.nodes});return E?p(E,_):u==null?void 0:u(_)},end:()=>u==null?void 0:u(_)})}catch(S){if(S instanceof t.AbortedError)return;throw S}};return{interpret:async _=>{const v=e.nodes.find(A=>A.id===_)??t.getHeadOrThrow(e.nodes);return p(v)},undo:_=>{let v=1;const A=e.nodes.find(E=>E.id===_[_.length-1]);for(let E=_.length-2;E>0;E--){const g=_[E],M=e.nodes.find(O=>O.id===g);if(!M||(v++,M.type.startsWith("question-")))break}x.abort(),x=new AbortController;const S=e.nodes.find(E=>E.id===_[_.length-v]);return t.invariant(S,"Undo failed: new start node not found"),p(S,A),{removed:v}},abort:()=>{x.abort()}}},Ve=e=>`+${e.countryCode} ${e.phoneNumber}`;async function nr(e){const r=e.node;switch(r.type){case"text":return dr({...e,node:r});case"image":return fr({...e,node:r});case"question-text":return hr({...e,node:r});case"question-enum":return gr({...e,node:r});case"question-number":return pr({...e,node:r});case"question-phone":return mr({...e,node:r});case"question-boolean":return br({...e,node:r});case"question-file":return vr({...e,node:r});case"question-address":return yr({...e,node:r});case"end-flow":return xr({...e,node:r});case"if-block":return cr({...e,node:r});case"jump":return or({...e,node:r});case"link":return ur({...e,node:r});case"integration-application-submit":return lr({...e,node:r});case"add-submission":return ir({...e,node:r});case"integration-workflow-get":throw Error("Workflow should be unreachable");case"identify":return ar({...e,node:r});case"feedback":return sr({...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 sr({next:e,node:r}){e(r.nextId)}async function ar({next:e,node:r,analytics:n,submissions:s,logger:a}){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:o,value:i})=>{var u;return[o,(u=s[i])==null?void 0:u.value]})):void 0}})}catch(o){a.error(o)}finally{e(r.nextId)}}async function or({next:e,node:r}){e(r.data.targetId)}async function ir({next:e,node:r,logger:n,submissions:s,context:a}){if(!s){n.error("Submissions not found");return}s[r.data.key]={type:"string",value:Z(r.data.value,{submissions:s,context:a})},e(r.nextId)}async function lr({chat:e,next:r,node:n,logger:s,apiClient:a,submissions:o,analytics:i,flow:u,t:d}){const h=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:b,session_id:p}=i.getSessionInfo(),_=await a.fetch("/flow/submit",{method:"POST",body:JSON.stringify({log_submit:!1,integration_id:n.data.integrationId,anonymous_id:b,session_id:p,job:u.job,submissions:t.getFlowSubmissionsPayload(o||{})})}).catch(v=>v);n.data.key&&e.addToSubmissions(n.data.key,{type:"integration",value:_}),t.N(_).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}}))},v=>{i.log({event:"FLOW_SUBMIT",properties:{flow_id:u.id,flow_version:u.version,flow_session_id:u.data.flowSessionId,flow_build:u.build,service:v.service??"INVALID_SERVICE",response:{status:v.status,payload:"data"in v?v.data:v.error.data??null},job:u.job}})}).otherwise(()=>{}),await t.N(_).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 v=>{if(v.redirect!==void 0){await e.sendMessage({type:"text",author:"bot",text:v.redirect.message??d("submission_redirect_message")});try{const A=new URL(v.redirect.redirect_url);b&&!A.searchParams.has("anonymous_id")&&A.searchParams.set("anonymous_id",b),await e.sendMessage({type:"link",href:A.toString(),text:v.redirect.button_text??d("complete_submission"),onClick:()=>{if(!p){s.error("session_id not set, cannot log FLOW_REDIRECT event");return}i.log({event:"FLOW_REDIRECT",properties:{flow_build:u.build,flow_id:u.id,flow_session_id:p,flow_version:u.version,href:A.toString(),job:u.job}})}})}catch(A){s.error(`Invalid redirect URL: ${v.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 v=>{var A;s.error(v.error),await e.sendMessage({type:"system",variant:"error",text:((A=v.error)==null?void 0:A.message)||d("submission_failed")}),await h(!1)}).otherwise(async v=>{s.error(v),await e.sendMessage({type:"system",variant:"error",text:d("submission_failed")}),await h(!1)})};await h(n.data.skipConfirmation)}async function ur({chat:e,next:r,node:n,submissions:s,context:a}){await e.sendMessage({type:"link",href:Z(n.data.href,{submissions:s,context:a}),text:Z(n.data.cta,{submissions:s,context:a})}),r(n.nextId)}async function cr({submissions:e,next:r,node:n,context:s}){r(be(n,{submissions:e,context:s})?n.branchId:n.nextId)}async function dr({chat:e,next:r,node:n,submissions:s,context:a}){await e.sendMessage({author:"bot",type:"text",text:Z(n.data.text,{submissions:s,context:a})}),r(n.nextId)}async function fr({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 hr({chat:e,next:r,node:n,submissions:s,context:a,t:o}){await e.sendMessage({author:"bot",type:"text",text:Z(n.data.question,{submissions:s,context:a})});const i=n.data.format==="phone"?await e.userInput({key:n.data.key,type:"phone",config:{optional:n.data.optional,placeholder:n.data.placeholder,maxChars:n.data.maxChars,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}});i===null?await e.sendMessage({type:"system",variant:"info",text:o("skipped")}):await e.sendMessage({author:"user",type:"text",text:i.type==="phone"?Ve(i.value):i.value}),r(n.nextId)}async function pr({chat:e,next:r,node:n,submissions:s,context:a,t:o}){await e.sendMessage({author:"bot",type:"text",text:Z(n.data.question,{submissions:s,context:a})});const i=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}});i===null?await e.sendMessage({type:"system",variant:"info",text:o("skipped")}):await e.sendMessage({author:"user",type:"text",text:i.value.toString()}),r(n.nextId)}async function mr({chat:e,next:r,node:n,submissions:s,context:a}){await e.sendMessage({author:"bot",type:"text",text:Z(n.data.question,{submissions:s,context:a})});const o=await e.userInput({key:n.data.key,type:"phone",config:{minChars:n.data.minChars,maxChars:n.data.maxChars,defaultValue:{countryCode:n.data.defaultCountryCode},placeholder:n.data.placeholder,submissionFormat:"phone",optional:n.data.optional}});o===null?await e.sendMessage({type:"system",variant:"info",text:"Skipped"}):await e.sendMessage({author:"user",type:"text",text:o.type==="phone"?Ve(o.value):o.value}),r(n.nextId)}async function gr({chat:e,next:r,node:n,submissions:s,context:a,t:o}){await e.sendMessage({author:"bot",type:"text",text:Z(n.data.question,{submissions:s,context:a})});const i=await e.userInput({key:n.data.key,type:"multiple-choice",config:n.data});i.value.length===0?await e.sendMessage({type:"system",variant:"info",text:o("skipped")}):await e.sendMessage({author:"user",type:"text",text:n.data.options.filter(u=>i.value.includes(u.value)).map(u=>u.label).join(", ")}),r(n.nextId)}async function br({chat:e,next:r,node:n,submissions:s,context:a,t:o}){await e.sendMessage({author:"bot",type:"text",text:Z(n.data.question,{submissions:s,context:a})});const i=await e.userInput({key:n.data.key,type:"boolean",config:{optional:n.data.optional,labels:{true:n.data.trueLabel,false:n.data.falseLabel}}});i===null?await e.sendMessage({type:"system",variant:"info",text:o("skipped")}):await e.sendMessage({author:"user",type:"text",text:i.value===!0?n.data.trueLabel:n.data.falseLabel}),r(n.nextId)}async function yr({chat:e,next:r,node:n,t:s}){await e.sendMessage({author:"bot",type:"text",text:n.data.question});const a=await e.userInput({type:"address",key:n.data.key,config:{optional:n.data.optional,keys:n.data.keys,placeholder:n.data.placeholder}});if(a===null)await e.sendMessage({type:"system",variant:"info",text:s("skipped")});else{const o=Object.values(a.value).filter(i=>i&&i.trim().length>0).join(", ");await e.sendMessage({author:"user",type:"text",text:o})}return r(n.nextId)}async function vr({node:e,chat:r,next:n,submissions:s,context:a,t:o}){await r.sendMessage({author:"bot",type:"text",text:Z(e.data.question,{submissions:s,context:a})});const i=await r.userInput({key:e.data.key,type:"file",config:{optional:e.data.optional,extensions:e.data.extensions,fileSizeLimitKib:e.data.maxSizeKb??10*1024,allowMultiple:e.data.multiple===!0}});if(i===null)await r.sendMessage({type:"system",variant:"info",text:o("skipped")});else for(const u of i.value)await r.sendMessage({author:"user",type:"file",fileName:u.name,fileSizeKb:u.sizeKb});n(e.nextId)}async function xr({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 a=t.get(s,r.join("."));switch(typeof a){case"string":return{type:"string",value:a};case"number":return{type:"number",value:a};case"boolean":return{type:"boolean",value:a};default:console.warn(`Unexpected type for $context.${r.join(".")}`,a);return}}return n==null?void 0:n[e]};function Ue(e,r,n){var s,a,o,i,u;r==null&&(r=100);function d(){var x=Date.now()-i;x<r&&x>=0?s=setTimeout(d,r-x):(s=null,n||(u=e.apply(o,a),o=a=null))}var h=function(){o=this,a=arguments,i=Date.now();var x=n&&!s;return s||(s=setTimeout(d,r)),x&&(u=e.apply(o,a),o=a=null),u};return h.clear=function(){s&&(clearTimeout(s),s=null)},h.flush=function(){s&&(u=e.apply(o,a),o=a=null,clearTimeout(s),s=null)},h}Ue.debounce=Ue;var wr=Ue;const ut=t.getDefaultExportFromCjs(wr);function _r(e){let{debounce:r,scroll:n,polyfill:s,offsetSize:a}=e===void 0?{debounce:0,scroll:!1,offsetSize:!1}:e;const o=s||(typeof window>"u"?class{}:window.ResizeObserver);if(!o)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[i,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:i}),h=r?typeof r=="number"?r:r.scroll:null,x=r?typeof r=="number"?r:r.resize:null,b=t._$1(!1);t.p(()=>(b.current=!0,()=>void(b.current=!1)));const[p,_,v]=t.F(()=>{const g=()=>{if(!d.current.element)return;const{left:M,top:O,width:L,height:se,bottom:te,right:he,x:U,y:X}=d.current.element.getBoundingClientRect(),j={left:M,top:O,width:L,height:se,bottom:te,right:he,x:U,y:X};d.current.element instanceof HTMLElement&&a&&(j.height=d.current.element.offsetHeight,j.width=d.current.element.offsetWidth),Object.freeze(j),b.current&&!Er(d.current.lastBounds,j)&&u(d.current.lastBounds=j)};return[g,x?ut(g,x):g,h?ut(g,h):g]},[u,a,h,x]);function A(){d.current.scrollContainers&&(d.current.scrollContainers.forEach(g=>g.removeEventListener("scroll",v,!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 o(v),d.current.resizeObserver.observe(d.current.element),n&&d.current.scrollContainers&&d.current.scrollContainers.forEach(g=>g.addEventListener("scroll",v,{capture:!0,passive:!0})))}const E=g=>{!g||g===d.current.element||(A(),d.current.element=g,d.current.scrollContainers=Mt(g),S())};return Sr(v,!!n),kr(_),t.p(()=>{A(),S()},[n,v,_]),t.p(()=>A,[]),[E,i,p]}function kr(e){t.p(()=>{const r=e;return window.addEventListener("resize",r),()=>void window.removeEventListener("resize",r)},[e])}function Sr(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 Mt(e){const r=[];if(!e||e===document.body)return r;const{overflow:n,overflowX:s,overflowY:a}=window.getComputedStyle(e);return[n,s,a].some(o=>o==="auto"||o==="scroll")&&r.push(e),[...r,...Mt(e.parentElement)]}const Cr=["x","y","top","bottom","left","right","width","height"],Er=(e,r)=>Cr.every(n=>e[n]===r[n]),ie=({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"})]})})},Ar=25,Ke=t.a({instant:()=>{},smooth:()=>{}}),P={onSubmitSuccessFn$:t.a(()=>{}),isBotTyping$:t.a(!1),scrollToEnd:{instant:()=>Ke.value.instant(),smooth:()=>Ke.value.smooth()}},Tr=()=>{const e=t._$1(null);t.y(()=>{Ke.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,a)=>t.store.setSubmission(s,a),send:async({message:s,signal:a,groupId:o})=>{if(await t.N(s).with({author:"bot",type:"text"},async i=>{if(a!=null&&a.aborted)throw new t.AbortedError;P.isBotTyping$.value=!0;const u=Math.min(Math.max(20,i.text.length),100)*Ar;await new Promise(d=>setTimeout(d,u,{signal:a})),P.isBotTyping$.value=!1}).otherwise(async()=>{}),a!=null&&a.aborted)throw new t.AbortedError;t.store.addMessage(s,o)},input:({input:s,signal:a})=>{if(a!=null&&a.aborted)throw new t.AbortedError;return t.store.setInput(s),new Promise(o=>{const i=u=>{if(a!=null&&a.aborted)throw new t.AbortedError;t.store.setInput(void 0),s.key&&t.store.setSubmission(s.key,u),o(u)};P.onSubmitSuccessFn$.value=i})}}),[]);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")]})},Ge={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}}),Ir="https://api.mapbox.com/search/searchbox/v1/suggest",Vr="ZzRDWFU0dTZ3SF9aWk9RNGl6QzZaWS5RZmlFak13a0hPbGxXZXlNSGN5RUhObUJ6TXpSV08yUW5OdE5tSTZJU1lpd2lJb1JYYXRObmJ2Tm5iaGhHZWx4V1lpb2pJMUp5ZS5rcA==",Fr=e=>atob(e).split("").reverse().join(""),Y=t.object({name:t.string()}),Mr=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}))}))}),Lr=({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 a=>{const o=new URL(Ir);o.searchParams.set("q",a),o.searchParams.set("session_token",n),o.searchParams.set("access_token",Fr(Vr));const i=await fetch(o);if(!i.ok)return e.error("Failed to get address details",i),{ok:!1,error:r("address_error")};const u=t.safeParse(Mr,await i.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(h=>{var x,b,p,_,v,A,S,E,g;return{label:h.full_address??h.place_formatted??h.name??h.mapbox_id,id:h.mapbox_id,address:{line1:((x=h.context.address)==null?void 0:x.name)??((b=h.context.street)==null?void 0:b.name),line2:void 0,line3:((p=h.context.neighborhood)==null?void 0:p.name)??((_=h.context.locality)==null?void 0:_.name),city:((v=h.context.place)==null?void 0:v.name)??((A=h.context.district)==null?void 0:A.name),state:(S=h.context.region)==null?void 0:S.name,postcode:(E=h.context.postcode)==null?void 0:E.name,country:(g=h.context.country)==null?void 0:g.name}}})}}}:{enabled:!1}},[e,r]),ct=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")})]})},Nr=({input:e,onSubmitSuccess:r,logger:n})=>{const{t:s}=t.useTranslation(),[a,o]=t.h(),[i,u]=t.h([]),{enabled:d,getPredictions:h}=Lr({logger:n,t:s}),[x,b]=t.h(d?"query":"manual"),[p,_]=t.h(""),[v,A]=t.h(),S=E=>{t.invariant(d,"Query state should not be enabled"),E=E.trim(),E!==(p==null?void 0:p.trim())&&(_(E),E===""&&u([]),A(void 0),h(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(Rr,{input:e,onSkip:()=>r(null),onAddressSelect:E=>{if(E===""){o(void 0),b("manual");return}const g=i.find(M=>M.id===E);g&&(o(g.address),b("details"))},onAddressSearch:E=>{S(E)},suggestions:i,query:p,error:v});case"details":return t.invariant(a!==void 0),t.o(ft,{input:e,logger:n,onSubmitSuccess:r,addressFields:a,actions:t.o(ct,{onClick:()=>{b("query")}})});case"manual":return t.o(ft,{logger:n,input:e,onSubmitSuccess:r,addressFields:{},actions:d?t.o(ct,{onClick:()=>{b("query")}}):void 0})}},Rr=({input:e,onSkip:r,suggestions:n,onAddressSelect:s,query:a,onAddressSearch:o,error:i})=>{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:h=>{h.preventDefault();const b=new FormData(h.currentTarget).get("address");typeof b=="string"&&o(b)},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:a,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})]}),i?t.o(fe,{error:{message:i}}):null,t.o("ul",{children:[n.map(h=>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(h.id)},children:[t.o("span",{class:"flex-grow",children:h.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"})})]})},h.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")})})},"")]})]})},dt=["line1","line2","line3","city","state","postcode","country"],ft=({addressFields:e,onSubmitSuccess:r,actions:n,input:s})=>{const a=t._$1(null);t.y(()=>{if(a.current){const u=a.current.querySelector("input");u&&(u.focus(),u.select())}},[]);const o=Object.keys(Ge),{t:i}=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),h=Object.fromEntries(d.entries());r({type:"address",value:h})},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:a,children:dt.map((u,d)=>{const h=`isdk_${u}`,x=s.config.keys[u];return x?t.o(t.k,{children:[t.o("label",{for:h,class:"text-neutral-9 [&:has(+*>input:focus)]:text-neutral-11 w-24 pb-2 text-xs uppercase leading-3 tracking-widest transition-colors",children:i(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:h,defaultValue:e[u],required:!0,children:[e.country&&!o.includes(e.country)?t.o("option",{value:e[u],children:e[u]}):t.o("option",{value:"",children:i("select_country")}),o.map(b=>t.o("option",{value:b,children:b},b))]}),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:h,defaultValue:e[u],required:!0}),d===dt.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(ie,{class:"flex items-center justify-center"})]})]})},He=()=>{const e=t._$1(null);return t.p(()=>{var r;(r=e.current)==null||r.focus()},[]),e},Lt=["true","false"],Dr=t.picklist(Lt),Or="answer",Nt="flex items-center gap-2 p-2.5",Rt=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})})),Br=({input:e,onSubmitSuccess:r})=>{const n=He();return t.o("form",{noValidate:!0,class:"",onSubmit:s=>{s.preventDefault();const a=t.getFormSubmitter(s).value,o=t.parse(Dr,a);r({type:"boolean",value:o==="true"})},children:[t.o("ul",{class:Nt,children:Lt.map((s,a)=>t.o("li",{class:"flex-1",children:t.o(Rt,{ref:a===0?n:null,type:"submit",name:Or,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)})})]})},$r=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"),ht=3,zr=({file:e,class:r,...n})=>{const s=e.name.split(".").pop(),a=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:a}),t.o("span",{children:[".",s]})]}),t.o("p",{"aria-label":"File size",class:"text-accent-11",children:t.kbToReadableSize(e.sizeKb)})]})},pt=({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}),Dt=e=>{const r=e.split(".").pop();if(!r)throw new Error("No file extension found");return r?"."+r:""},qr=({allowedExtensions:e,files:r})=>{const n=e.map(s=>s.toLowerCase());return r.every(s=>n.includes(Dt(s.name).toLowerCase()))},Ur=(e,r)=>{const n=Dt(e);return`${e.replace(new RegExp(`${n}$`),"").slice(0,r)}${n}`},Kr=({input:e,onSubmitSuccess:r})=>{var b;const n=(b=t.store.current$.value.flow)==null?void 0:b.data.submissions[e.key],[s,a]=t.h(jr(n)?n.value:[]),[o,i]=t.h(),u=s.length-ht,d=Pr(s),h=He(),{t:x}=t.useTranslation();return t.o("form",{class:"flex flex-col gap-1 p-2.5",onSubmit:p=>(p.preventDefault(),i(void 0),s.length===0?i({type:"required",message:x("validation_file")}):e.config.extensions.length>0&&!qr({allowedExtensions:e.config.extensions,files:s})?i({type:"validate",message:`${x("validation_file_ext",{ext:e.config.extensions.join(", ")})}`}):e.config.fileSizeLimitKib&&d>e.config.fileSizeLimitKib?i({type:"max",message:`File size exceeds limit of ${t.kbToReadableSize(e.config.fileSizeLimitKib)}`}):e.config.allowMultiple===!1&&s.length>1?i({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:h,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,ht).map(p=>{const _=p.name.split(".").pop(),v=p.name.replace(new RegExp(`.${_}$`),"");return t.o(pt,{class:"flex overflow-hidden",children:[t.o("span",{class:"block truncate",children:v}),t.o("span",{children:[".",_]})]})}),u>0?t.o(pt,{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(p=>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:p.replace(".","")}))})]})]}),t.o("input",{id:"dropzone-file",onInput:async p=>{t.invariant(p.target instanceof HTMLInputElement);const _=p.target.files?Array.from(p.target.files):[],v=await Promise.allSettled(_.map(async S=>{const E=await $r(S);return{name:Ur(S.name,42),data:E,sizeKb:S.size/1e3}}));if(v.some(({status:S})=>S==="rejected"))return i({type:"invalid",message:"Invalid file"});const A=v.map(S=>S.status==="fulfilled"?S.value:null).filter(Boolean);a(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(ie,{disabled:s.length===0}),e.config.optional&&t.o(le,{onClick:()=>r(null)})]})]}),t.o(fe,{error:o})]})};var ve=e=>e.type==="checkbox",de=e=>e instanceof Date,z=e=>e==null;const Ot=e=>typeof e=="object";var B=e=>!z(e)&&!Array.isArray(e)&&Ot(e)&&!de(e),Gr=e=>B(e)&&e.target?ve(e.target)?e.target.checked:e.target.value:e,Hr=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,Wr=(e,r)=>e.has(Hr(r)),Jr=e=>{const r=e.constructor&&e.constructor.prototype;return B(r)&&r.hasOwnProperty("isPrototypeOf")},We=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(!(We&&(e instanceof Blob||e instanceof FileList))&&(n||B(e)))if(r=n?[]:{},!n&&!Jr(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((a,o)=>z(a)?a:a[o],e);return R(s)||s===e?R(e[r])?n:e[r]:s},re=e=>typeof e=="boolean";const mt={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 Zr=(e,r,n,s=!0)=>{const a={defaultValues:r._defaultValues};for(const o in e)Object.defineProperty(a,o,{get:()=>{const i=o;return r._proxyFormState[i]!==H.all&&(r._proxyFormState[i]=!s||H.all),n&&(n[i]=!0),e[i]}});return a},G=e=>B(e)&&!Object.keys(e).length,Xr=(e,r,n,s)=>{n(e);const{name:a,...o}=e;return G(o)||Object.keys(o).length>=Object.keys(r).length||Object.keys(o).find(i=>r[i]===(!s||H.all))},Be=e=>Array.isArray(e)?e:[e];function Yr(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",Qr=(e,r,n,s,a)=>J(e)?(s&&r.watch.add(e),w(n,e,a)):Array.isArray(e)?e.map(o=>(s&&r.watch.add(o),w(n,o))):(s&&(r.watchAll=!0),n),Je=e=>/^\w*$/.test(e),Bt=e=>xe(e.replace(/["|']|\]/g,"").split(/\.|\[/));function V(e,r,n){let s=-1;const a=Je(r)?[r]:Bt(r),o=a.length,i=o-1;for(;++s<o;){const u=a[s];let d=n;if(s!==i){const h=e[u];d=B(h)||Array.isArray(h)?h:isNaN(+a[s+1])?{}:[]}e[u]=d,e=e[u]}return e}var $t=(e,r,n,s,a)=>r?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[s]:a||!0}}:{},gt=e=>({isOnSubmit:!e||e===H.onSubmit,isOnBlur:e===H.onBlur,isOnChange:e===H.onChange,isOnAll:e===H.all,isOnTouch:e===H.onTouched}),bt=(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 a of n||Object.keys(e)){const o=w(e,a);if(o){const{_f:i,...u}=o;if(i){if(i.refs&&i.refs[0]&&r(i.refs[0],a)&&!s)break;if(i.ref&&r(i.ref,i.name)&&!s)break}else B(u)&&Se(u,r)}}};var en=(e,r,n)=>{const s=xe(w(e,n));return V(s,"root",r[n]),V(e,n,s),e},Ze=e=>e.type==="file",ne=e=>typeof e=="function",Ee=e=>{if(!We)return!1;const r=e?e.ownerDocument:0;return e instanceof(r&&r.defaultView?r.defaultView.HTMLElement:HTMLElement)},Ce=e=>J(e),Xe=e=>e.type==="radio",Ae=e=>e instanceof RegExp;const yt={value:!1,isValid:!1},vt={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===""?vt:{value:e[0].value,isValid:!0}:vt:yt}return yt};const xt={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,xt):xt;function wt(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:""},_t=async(e,r,n,s,a)=>{const{ref:o,refs:i,required:u,maxLength:d,minLength:h,min:x,max:b,pattern:p,validate:_,name:v,valueAsNumber:A,mount:S,disabled:E}=e._f,g=w(r,v);if(!S||E)return{};const M=i?i[0]:o,O=I=>{s&&M.reportValidity&&(M.setCustomValidity(re(I)?"":I||""),M.reportValidity())},L={},se=Xe(o),te=ve(o),he=se||te,U=(A||Ze(o))&&R(o.value)&&R(g)||Ee(o)&&o.value===""||g===""||Array.isArray(g)&&!g.length,X=$t.bind(null,v,n,L),j=(I,T,N,q=Q.maxLength,K=Q.minLength)=>{const W=I?T:N;L[v]={type:I?q:K,message:W,ref:o,...X(I?q:K,W)}};if(a?!Array.isArray(g)||!g.length:u&&(!he&&(U||z(g))||re(g)&&!g||te&&!Pt(i).isValid||se&&!jt(i).isValid)){const{value:I,message:T}=Ce(u)?{value:!!u,message:u}:ce(u);if(I&&(L[v]={type:Q.required,message:T,ref:M,...X(Q.required,T)},!n))return O(T),L}if(!U&&(!z(x)||!z(b))){let I,T;const N=ce(b),q=ce(x);if(!z(g)&&!isNaN(g)){const K=o.valueAsNumber||g&&+g;z(N.value)||(I=K>N.value),z(q.value)||(T=K<q.value)}else{const K=o.valueAsDate||new Date(g),W=we=>new Date(new Date().toDateString()+" "+we),ae=o.type=="time",pe=o.type=="week";J(N.value)&&g&&(I=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((I||T)&&(j(!!I,N.message,q.message,Q.max,Q.min),!n))return O(L[v].message),L}if((d||h)&&!U&&(J(g)||a&&Array.isArray(g))){const I=ce(d),T=ce(h),N=!z(I.value)&&g.length>+I.value,q=!z(T.value)&&g.length<+T.value;if((N||q)&&(j(N,I.message,T.message),!n))return O(L[v].message),L}if(p&&!U&&J(g)){const{value:I,message:T}=ce(p);if(Ae(I)&&!g.match(I)&&(L[v]={type:Q.pattern,message:T,ref:o,...X(Q.pattern,T)},!n))return O(T),L}if(_){if(ne(_)){const I=await _(g,r),T=wt(I,M);if(T&&(L[v]={...T,...X(Q.validate,T.message)},!n))return O(T.message),L}else if(B(_)){let I={};for(const T in _){if(!G(I)&&!n)break;const N=wt(await _[T](g,r),M,T);N&&(I={...N,...X(T,N.message)},O(N.message),n&&(L[v]=I))}if(!G(I)&&(L[v]={ref:M,...I},!n))return L}}return O(!0),L};function tn(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 rn(e){for(const r in e)if(e.hasOwnProperty(r)&&!R(e[r]))return!1;return!0}function $(e,r){const n=Array.isArray(r)?r:Je(r)?[r]:Bt(r),s=n.length===1?e:tn(e,n),a=n.length-1,o=n[a];return s&&delete s[o],a!==0&&(B(s)&&G(s)||Array.isArray(s)&&rn(s))&&$(e,n.slice(0,-1)),e}function $e(){let e=[];return{get observers(){return e},next:a=>{for(const o of e)o.next&&o.next(a)},subscribe:a=>(e.push(a),{unsubscribe:()=>{e=e.filter(o=>o!==a)}}),unsubscribe:()=>{e=[]}}}var Te=e=>z(e)||!Ot(e);function oe(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 a of n){const o=e[a];if(!s.includes(a))return!1;if(a!=="ref"){const i=r[a];if(de(o)&&de(i)||B(o)&&B(i)||Array.isArray(o)&&Array.isArray(i)?!oe(o,i):o!==i)return!1}}return!0}var zt=e=>e.type==="select-multiple",nn=e=>Xe(e)||ve(e),Pe=e=>Ee(e)&&e.isConnected,qt=e=>{for(const r in e)if(ne(e[r]))return!0;return!1};function Ie(e,r={}){const n=Array.isArray(e);if(B(e)||n)for(const s in e)Array.isArray(e[s])||B(e[s])&&!qt(e[s])?(r[s]=Array.isArray(e[s])?[]:{},Ie(e[s],r[s])):z(e[s])||(r[s]=!0);return r}function Ut(e,r,n){const s=Array.isArray(e);if(B(e)||s)for(const a in e)Array.isArray(e[a])||B(e[a])&&!qt(e[a])?R(r)||Te(n[a])?n[a]=Array.isArray(e[a])?Ie(e[a],[]):{...Ie(e[a])}:Ut(e[a],z(r)?{}:r[a],n[a]):n[a]=!oe(e[a],r[a]);return n}var je=(e,r)=>Ut(e,r,Ie(r)),Kt=(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 Ze(r)?r.files:Xe(r)?jt(e.refs).value:zt(r)?[...r.selectedOptions].map(({value:n})=>n):ve(r)?Pt(e.refs).value:Kt(R(r.value)?e.ref.value:r.value,e)}var sn=(e,r,n,s)=>{const a={};for(const o of e){const i=w(r,o);i&&V(a,o,i._f)}return{criteriaMode:n,names:[...e],fields:a,shouldUseNativeValidation:s}},ge=e=>R(e)?e:Ae(e)?e.source:B(e)?Ae(e.value)?e.value.source:e.value:e,an=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function kt(e,r,n){const s=w(e,n);if(s||Je(n))return{error:s,name:n};const a=n.split(".");for(;a.length;){const o=a.join("."),i=w(r,o),u=w(e,o);if(i&&!Array.isArray(i)&&n!==o)return{name:n};if(u&&u.type)return{name:o,error:u};a.pop()}return{name:n}}var on=(e,r,n,s,a)=>a.isOnAll?!1:!n&&a.isOnTouch?!(r||e):(n?s.isOnBlur:a.isOnBlur)?!e:(n?s.isOnChange:a.isOnChange)?e:!0,ln=(e,r)=>!xe(w(e,r)).length&&$(e,r);const un={mode:H.onSubmit,reValidateMode:H.onChange,shouldFocusError:!0};function cn(e={},r){let n={...un,...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},a={},o=B(n.defaultValues)||B(n.values)?ee(n.defaultValues||n.values)||{}:{},i=n.shouldUnregister?{}:ee(o),u={action:!1,mount:!1,watch:!1},d={mount:new Set,unMount:new Set,array:new Set,watch:new Set},h,x=0;const b={isDirty:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},p={values:$e(),array:$e(),state:$e()},_=e.resetOptions&&e.resetOptions.keepDirtyValues,v=gt(n.mode),A=gt(n.reValidateMode),S=n.criteriaMode===H.all,E=l=>c=>{clearTimeout(x),x=setTimeout(l,c)},g=async l=>{if(b.isValid||l){const c=n.resolver?G((await U()).errors):await j(a,!0);c!==s.isValid&&p.state.next({isValid:c})}},M=l=>b.isValidating&&p.state.next({isValidating:l}),O=(l,c=[],f,k,y=!0,m=!0)=>{if(k&&f){if(u.action=!0,m&&Array.isArray(w(a,l))){const C=f(w(a,l),k.argA,k.argB);y&&V(a,l,C)}if(m&&Array.isArray(w(s.errors,l))){const C=f(w(s.errors,l),k.argA,k.argB);y&&V(s.errors,l,C),ln(s.errors,l)}if(b.touchedFields&&m&&Array.isArray(w(s.touchedFields,l))){const C=f(w(s.touchedFields,l),k.argA,k.argB);y&&V(s.touchedFields,l,C)}b.dirtyFields&&(s.dirtyFields=je(o,i)),p.state.next({name:l,isDirty:T(l,c),dirtyFields:s.dirtyFields,errors:s.errors,isValid:s.isValid})}else V(i,l,c)},L=(l,c)=>{V(s.errors,l,c),p.state.next({errors:s.errors})},se=(l,c,f,k)=>{const y=w(a,l);if(y){const m=w(i,l,R(f)?w(o,l):f);R(m)||k&&k.defaultChecked||c?V(i,l,c?m:ze(y._f)):K(l,m),u.mount&&g()}},te=(l,c,f,k,y)=>{let m=!1,C=!1;const F={name:l};if(!f||k){b.isDirty&&(C=s.isDirty,s.isDirty=F.isDirty=T(),m=C!==F.isDirty);const D=oe(w(o,l),c);C=w(s.dirtyFields,l),D?$(s.dirtyFields,l):V(s.dirtyFields,l,!0),F.dirtyFields=s.dirtyFields,m=m||b.dirtyFields&&C!==!D}if(f){const D=w(s.touchedFields,l);D||(V(s.touchedFields,l,f),F.touchedFields=s.touchedFields,m=m||b.touchedFields&&D!==f)}return m&&y&&p.state.next(F),m?F:{}},he=(l,c,f,k)=>{const y=w(s.errors,l),m=b.isValid&&re(c)&&s.isValid!==c;if(e.delayError&&f?(h=E(()=>L(l,f)),h(e.delayError)):(clearTimeout(x),h=null,f?V(s.errors,l,f):$(s.errors,l)),(f?!oe(y,f):y)||!G(k)||m){const C={...k,...m&&re(c)?{isValid:c}:{},errors:s.errors,name:l};s={...s,...C},p.state.next(C)}M(!1)},U=async l=>n.resolver(i,n.context,sn(l||d.mount,a,n.criteriaMode,n.shouldUseNativeValidation)),X=async l=>{const{errors:c}=await U(l);if(l)for(const f of l){const k=w(c,f);k?V(s.errors,f,k):$(s.errors,f)}else s.errors=c;return c},j=async(l,c,f={valid:!0})=>{for(const k in l){const y=l[k];if(y){const{_f:m,...C}=y;if(m){const F=d.array.has(m.name),D=await _t(y,i,S,n.shouldUseNativeValidation&&!c,F);if(D[m.name]&&(f.valid=!1,c))break;!c&&(w(D,m.name)?F?en(s.errors,D,m.name):V(s.errors,m.name,D[m.name]):$(s.errors,m.name))}C&&await j(C,c,f)}}return f.valid},I=()=>{for(const l of d.unMount){const c=w(a,l);c&&(c._f.refs?c._f.refs.every(f=>!Pe(f)):!Pe(c._f.ref))&&Ne(l)}d.unMount=new Set},T=(l,c)=>(l&&c&&V(i,l,c),!oe(Ye(),o)),N=(l,c,f)=>Qr(l,d,{...u.mount?i:R(c)?o:J(l)?{[l]:c}:c},f,c),q=l=>xe(w(u.mount?i:o,l,e.shouldUnregister?w(o,l,[]):[])),K=(l,c,f={})=>{const k=w(a,l);let y=c;if(k){const m=k._f;m&&(!m.disabled&&V(i,l,Kt(c,m)),y=Ee(m.ref)&&z(c)?"":c,zt(m.ref)?[...m.ref.options].forEach(C=>C.selected=y.includes(C.value)):m.refs?ve(m.ref)?m.refs.length>1?m.refs.forEach(C=>(!C.defaultChecked||!C.disabled)&&(C.checked=Array.isArray(y)?!!y.find(F=>F===C.value):y===C.value)):m.refs[0]&&(m.refs[0].checked=!!y):m.refs.forEach(C=>C.checked=C.value===y):Ze(m.ref)?m.ref.value="":(m.ref.value=y,m.ref.type||p.values.next({name:l,values:{...i}})))}(f.shouldDirty||f.shouldTouch)&&te(l,y,f.shouldTouch,f.shouldDirty,!0),f.shouldValidate&&Le(l)},W=(l,c,f)=>{for(const k in c){const y=c[k],m=`${l}.${k}`,C=w(a,m);(d.array.has(l)||!Te(y)||C&&!C._f)&&!de(y)?W(m,y,f):K(m,y,f)}},ae=(l,c,f={})=>{const k=w(a,l),y=d.array.has(l),m=ee(c);V(i,l,m),y?(p.array.next({name:l,values:{...i}}),(b.isDirty||b.dirtyFields)&&f.shouldDirty&&p.state.next({name:l,dirtyFields:je(o,i),isDirty:T(l,m)})):k&&!k._f&&!z(m)?W(l,m,f):K(l,m,f),bt(l,d)&&p.state.next({...s}),p.values.next({name:l,values:{...i}}),!u.mount&&r()},pe=async l=>{const c=l.target;let f=c.name,k=!0;const y=w(a,f),m=()=>c.type?ze(y._f):Gr(l),C=F=>{k=Number.isNaN(F)||F===w(i,f,F)};if(y){let F,D;const _e=m(),ue=l.type===mt.BLUR||l.type===mt.FOCUS_OUT,Xt=!an(y._f)&&!n.resolver&&!w(s.errors,f)&&!y._f.deps||on(ue,w(s.touchedFields,f),s.isSubmitted,A,v),De=bt(f,d,ue);V(i,f,_e),ue?(y._f.onBlur&&y._f.onBlur(l),h&&h(0)):y._f.onChange&&y._f.onChange(l);const Oe=te(f,_e,ue,!1),Yt=!G(Oe)||De;if(!ue&&p.values.next({name:f,type:l.type,values:{...i}}),Xt)return b.isValid&&g(),Yt&&p.state.next({name:f,...De?{}:Oe});if(!ue&&De&&p.state.next({...s}),M(!0),n.resolver){const{errors:ot}=await U([f]);if(C(_e),k){const Qt=kt(s.errors,a,f),it=kt(ot,a,Qt.name||f);F=it.error,f=it.name,D=G(ot)}}else F=(await _t(y,i,S,n.shouldUseNativeValidation))[f],C(_e),k&&(F?D=!1:b.isValid&&(D=await j(a,!0)));k&&(y._f.deps&&Le(y._f.deps),he(f,D,F,Oe))}},we=(l,c)=>{if(w(s.errors,c)&&l.focus)return l.focus(),1},Le=async(l,c={})=>{let f,k;const y=Be(l);if(M(!0),n.resolver){const m=await X(R(l)?l:y);f=G(m),k=l?!y.some(C=>w(m,C)):f}else l?(k=(await Promise.all(y.map(async m=>{const C=w(a,m);return await j(C&&C._f?{[m]:C}:C)}))).every(Boolean),!(!k&&!s.isValid)&&g()):k=f=await j(a);return p.state.next({...!J(l)||b.isValid&&f!==s.isValid?{}:{name:l},...n.resolver||!l?{isValid:f}:{},errors:s.errors,isValidating:!1}),c.shouldFocus&&!k&&Se(a,we,l?y:d.mount),k},Ye=l=>{const c={...o,...u.mount?i:{}};return R(l)?c:J(l)?w(c,l):l.map(f=>w(c,f))},Qe=(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)}),Ht=l=>{l&&Be(l).forEach(c=>$(s.errors,c)),p.state.next({errors:l?s.errors:{}})},et=(l,c,f)=>{const k=(w(a,l,{_f:{}})._f||{}).ref;V(s.errors,l,{...c,ref:k}),p.state.next({name:l,errors:s.errors,isValid:!1}),f&&f.shouldFocus&&k&&k.focus&&k.focus()},Wt=(l,c)=>ne(l)?p.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||($(a,f),$(i,f)),!c.keepError&&$(s.errors,f),!c.keepDirty&&$(s.dirtyFields,f),!c.keepTouched&&$(s.touchedFields,f),!n.shouldUnregister&&!c.keepDefaultValue&&$(o,f);p.values.next({values:{...i}}),p.state.next({...s,...c.keepDirty?{isDirty:T()}:{}}),!c.keepIsValid&&g()},tt=({disabled:l,name:c,field:f,fields:k,value:y})=>{if(re(l)){const m=l?void 0:R(y)?ze(f?f._f:w(k,c)._f):y;V(i,c,m),te(c,m,!1,!1,!0)}},Re=(l,c={})=>{let f=w(a,l);const k=re(c.disabled);return V(a,l,{...f||{},_f:{...f&&f._f?f._f:{ref:{name:l}},name:l,mount:!0,...c}}),d.mount.add(l),f?tt({field:f,disabled:c.disabled,name:l}):se(l,!0,c.value),{...k?{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:y=>{if(y){Re(l,c),f=w(a,l);const m=R(y.value)&&y.querySelectorAll&&y.querySelectorAll("input,select,textarea")[0]||y,C=nn(m),F=f._f.refs||[];if(C?F.find(D=>D===m):m===f._f.ref)return;V(a,l,{_f:{...f._f,...C?{refs:[...F.filter(Pe),m,...Array.isArray(w(o,l))?[{}]:[]],ref:{type:m.type,name:l}}:{ref:m}}}),se(l,!1,void 0,m)}else f=w(a,l,{}),f._f&&(f._f.mount=!1),(n.shouldUnregister||c.shouldUnregister)&&!(Wr(d.array,l)&&u.action)&&d.unMount.add(l)}}},rt=()=>n.shouldFocusError&&Se(a,we,d.mount),Jt=l=>{re(l)&&(p.state.next({disabled:l}),Se(a,c=>{c.disabled=l},0,!1))},nt=(l,c)=>async f=>{f&&(f.preventDefault&&f.preventDefault(),f.persist&&f.persist());let k=ee(i);if(p.state.next({isSubmitting:!0}),n.resolver){const{errors:y,values:m}=await U();s.errors=y,k=m}else await j(a);$(s.errors,"root"),G(s.errors)?(p.state.next({errors:{}}),await l(k,f)):(c&&await c({...s.errors},f),rt(),setTimeout(rt)),p.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:G(s.errors),submitCount:s.submitCount+1,errors:s.errors})},Zt=(l,c={})=>{w(a,l)&&(R(c.defaultValue)?ae(l,w(o,l)):(ae(l,c.defaultValue),V(o,l,c.defaultValue)),c.keepTouched||$(s.touchedFields,l),c.keepDirty||($(s.dirtyFields,l),s.isDirty=c.defaultValue?T(l,w(o,l)):T()),c.keepError||($(s.errors,l),b.isValid&&g()),p.state.next({...s}))},st=(l,c={})=>{const f=l?ee(l):o,k=ee(f),y=l&&!G(l)?k:o;if(c.keepDefaultValues||(o=f),!c.keepValues){if(c.keepDirtyValues||_)for(const m of d.mount)w(s.dirtyFields,m)?V(y,m,w(i,m)):ae(m,w(y,m));else{if(We&&R(l))for(const m of d.mount){const C=w(a,m);if(C&&C._f){const F=Array.isArray(C._f.refs)?C._f.refs[0]:C._f.ref;if(Ee(F)){const D=F.closest("form");if(D){D.reset();break}}}}a={}}i=e.shouldUnregister?c.keepDefaultValues?ee(o):{}:ee(y),p.array.next({values:{...y}}),p.values.next({values:{...y}})}d={mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},!u.mount&&r(),u.mount=!b.isValid||!!c.keepIsValid,u.watch=!!e.shouldUnregister,p.state.next({submitCount:c.keepSubmitCount?s.submitCount:0,isDirty:c.keepDirty?s.isDirty:!!(c.keepDefaultValues&&!oe(l,o)),isSubmitted:c.keepIsSubmitted?s.isSubmitted:!1,dirtyFields:c.keepDirtyValues?s.dirtyFields:c.keepDefaultValues&&l?je(o,l):{},touchedFields:c.keepTouched?s.touchedFields:{},errors:c.keepErrors?s.errors:{},isSubmitSuccessful:c.keepIsSubmitSuccessful?s.isSubmitSuccessful:!1,isSubmitting:!1})},at=(l,c)=>st(ne(l)?l(i):l,c);return{control:{register:Re,unregister:Ne,getFieldState:Qe,handleSubmit:nt,setError:et,_executeSchema:U,_getWatch:N,_getDirty:T,_updateValid:g,_removeUnmounted:I,_updateFieldArray:O,_updateDisabledField:tt,_getFieldArray:q,_reset:st,_resetDefaultValues:()=>ne(n.defaultValues)&&n.defaultValues().then(l=>{at(l,n.resetOptions),p.state.next({isLoading:!1})}),_updateFormState:l=>{s={...s,...l}},_disableForm:Jt,_subjects:p,_proxyFormState:b,get _fields(){return a},get _formValues(){return i},get _state(){return u},set _state(l){u=l},get _defaultValues(){return o},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:nt,watch:Wt,setValue:ae,getValues:Ye,reset:at,resetField:Zt,clearErrors:Ht,unregister:Ne,setError:et,setFocus:(l,c={})=>{const f=w(a,l),k=f&&f._f;if(k){const y=k.refs?k.refs[0]:k.ref;y.focus&&(y.focus(),c.shouldSelect&&y.select())}},getFieldState:Qe}}function Fe(e={}){const r=t.Cn.useRef(),n=t.Cn.useRef(),[s,a]=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={...cn(e,()=>a(i=>({...i}))),formState:s});const o=r.current.control;return o._options=e,Yr({subject:o._subjects.state,next:i=>{Xr(i,o._proxyFormState,o._updateFormState,!0)&&a({...o._formState})}}),t.Cn.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),t.Cn.useEffect(()=>{if(o._proxyFormState.isDirty){const i=o._getDirty();i!==s.isDirty&&o._subjects.state.next({isDirty:i})}},[o,s.isDirty]),t.Cn.useEffect(()=>{e.values&&!oe(e.values,n.current)?(o._reset(e.values,o._options.resetOptions),n.current=e.values):o._resetDefaultValues()},[e.values,o]),t.Cn.useEffect(()=>{o._state.mount||(o._updateValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),r.current.formState=Zr(s,o),r.current}var St=function(e,r,n){if(e&&"reportValidity"in e){var s=w(n,r);e.setCustomValidity(s&&s.message||""),e.reportValidity()}},dn=function(e,r){var n=function(a){var o=r.fields[a];o&&o.ref&&"reportValidity"in o.ref?St(o.ref,a,e):o.refs&&o.refs.forEach(function(i){return St(i,a,e)})};for(var s in r.fields)n(s)},fn=function(e,r){r.shouldUseNativeValidation&&dn(e,r);var n={};for(var s in e){var a=w(r.fields,s),o=Object.assign(e[s]||{},{ref:a&&a.ref});if(pn(r.names||Object.keys(e),s)){var i=Object.assign({},hn(w(n,s)));V(i,"root",o),V(n,s,i)}else V(n,s,o)}return n},hn=function(e){return Array.isArray(e)?e.filter(Boolean):[]},pn=function(e,r){return e.some(function(n){return n.startsWith(r+".")})},mn=function(e,r){for(var n={};e.issues.length;){var s=e.issues[0];if(s.path){var a=s.path.map(function(u){return u.key}).join(".");if(n[a]||(n[a]={message:s.message,type:s.validation}),r){var o=n[a].types,i=o&&o[s.validation];n[a]=$t(a,r,n,s.validation,i?[].concat(i,s.message):s.message)}e.issues.shift()}}return n},Me=function(e,r,n){return n===void 0&&(n={}),function(s,a,o){try{return Promise.resolve(function(i,u){try{var d=function(){function h(b){return{values:n.raw?s:b,errors:{}}}var x=Object.assign({},{abortEarly:!1,abortPipeEarly:!1},r);return n.mode==="sync"?h(t.parse(e,s,x)):Promise.resolve(t.parseAsync(e,s,x)).then(h)}()}catch(h){return u(h)}return d&&d.then?d.then(void 0,u):d}(0,function(i){if(i instanceof t.ValiError)return{values:{},errors:fn(mn(i,!o.shouldUseNativeValidation&&o.criteriaMode==="all"),o)};throw i}))}catch(i){return Promise.reject(i)}}};const Ct=27,Et=12,At=10,gn=t.isSubmissionOfType("enum"),bn=e=>{const r={min:e.minSelected??0,max:e.maxSelected??e.options.length};return Me(t.object({checked:t.transform(t.record(t.boolean()),n=>Object.entries(n).filter(([s,a])=>a).map(([s,a])=>s),[t.maxLength(r.max,`Please select at most ${r.max} option${r.max!==1?"s":""}`),t.minLength(r.min,`Please select at least ${r.min} option${r.min!==1?"s":""}`)])}))},yn=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})]})),Tt=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:Nt}}}),vn=({input:e,onSubmitSuccess:r})=>{var h,x;const n=e.key?(h=t.store.current$.value.flow)==null?void 0:h.data.submissions[e.key]:void 0,s=(e.config.minSelected===1||e.config.minSelected===void 0)&&e.config.maxSelected===1,a=s&&e.config.options.length===2,{register:o,handleSubmit:i,formState:{errors:u}}=Fe({defaultValues:{checked:s?{}:gn(n)?Object.fromEntries(n.value.map(b=>[b,!0])):{}},resolver:bn(e.config)}),d=He();return a?t.o("ul",{style:{maxHeight:6.5*Ct+5*Et+2*At},class:Tt({variant:"booleanLike"}),children:e.config.options.map((b,p)=>t.o("li",{class:"flex-1",children:t.o(Rt,{type:"submit",ref:_=>{_&&p===0&&(d.current=_)},label:b.label,value:"true",onClick:()=>r({type:"enum",value:[b.value]})})},b.value))}):t.o("form",{noValidate:!0,onSubmit:b=>i(p=>{const _=p.checked;r({type:"enum",value:_})})(b),children:[t.o("div",{class:"flex items-center gap-1",children:[t.o("ul",{style:{maxHeight:6.5*Ct+5*Et+2*At},class:Tt({variant:e.config.options.length===1?"singleOption":void 0}),children:e.config.options.map((b,p)=>{const _=`checked.${b.value}`,{ref:v,...A}=o(_);return t.o("li",{class:"relative",children:t.o(yn,{option:b,autoFocus:p===0,ref:S=>{S&&p===0&&(d.current=S),v(S)},id:_,...A,onClick:s?()=>r({type:"enum",value:[b.value]}):void 0})},b.value)})}),t.o("div",{class:"flex flex-col items-center gap-2 pr-2.5 pt-2.5",children:[s?null:t.o(ie,{}),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:(x=u.checked)==null?void 0:x.root})})]})},xn=t.isSubmissionOfType("number"),wn=(e,r)=>{const n=e.min??Number.MIN_SAFE_INTEGER,s=e.max??Number.MAX_SAFE_INTEGER,a=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(o=>o===Number(o.toFixed(a)),r("validation_number_decimal_cases",{count:a}))])}))},_n=({input:e,onSubmitSuccess:r})=>{var b;const n=e.config.defaultValue,s=e.key?(b=t.store.current$.value.flow)==null?void 0:b.data.submissions[e.key]:void 0,{t:a}=t.useTranslation(),{register:o,handleSubmit:i,formState:{errors:u}}=Fe({defaultValues:{number:n?Number(n):xn(s)?s.value:void 0},resolver:wn(e.config,a)}),{ref:d,...h}=o("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:i(p=>{p.number!==void 0&&r({type:"number",value:p.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",{...h,id:"chat-input",autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:p=>{p&&(x.current=p),d(p)},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(ie,{})]}),t.o(fe,{error:u.number})]})},kn=e=>{if(e==="")return{countryCode:"",phoneNumber:""};const r=Object.entries(Ge).find(a=>e.startsWith(a[1])),n=r?r[1]:"",s=e.replace(n,"");return/^\d+$/.test(s)?{countryCode:n,phoneNumber:s}:{countryCode:"",phoneNumber:""}},Sn="44",Cn=t.isSubmissionOfType("string"),En=t.isSubmissionOfType("phone"),An=e=>{const r=t.string(e("validation_country_code"),[t.regex(/^\+?[0-9 -]+$/,e("validation_country_code"))]);return Me(t.object({countryCode:r,phoneNumber:t.transform(t.string(e("validation_phone"),[t.regex(/^\+?[0-9 -]+$/,e("validation_phone"))]),n=>n.replace(/[^0-9]/g,""),[])}))},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(),[a,o]=t.h(),i=Cn(n)?kn(n.value):En(n)?n.value:void 0,{register:u,handleSubmit:d,formState:{errors:h},watch:x}=Fe({defaultValues:{countryCode:(i==null?void 0:i.countryCode)??e.config.defaultValue.countryCode??Sn,phoneNumber:(i==null?void 0:i.phoneNumber)??e.config.defaultValue.phoneNumber??""},resolver:An(s)}),{ref:b,...p}=u("phoneNumber",{required:!e.config.optional}),_=t._$1(),v=x("countryCode");return t.y(()=>{_.current&&(_.current.focus(),_.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,"");if(o(void 0),E.length+g.length>(e.config.maxChars||Number.POSITIVE_INFINITY))return o(s("validation_max_chars",{count:e.config.maxChars??999}));if(E.length+g.length<(e.config.minChars||0))return o(s("validation_min_chars",{count:e.config.minChars??1}));e.config.submissionFormat==="phone"?r({type:"phone",value:{countryCode:g,phoneNumber:E}}):r({type:"string",value:v+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:["+",v]}),t.o("select",{...u("countryCode",{}),id:`isdk_phone_${e.key}`,class:"absolute inset-0 opacity-0",children:Object.entries(Ge).map(([S,E])=>t.o("option",{value:E,children:[S," (+",E,")"]},S))})]}),t.o("input",{...p,id:"chat-input",type:"tel",inputMode:"tel",autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:S=>{S&&(_.current=S),b(S)},class:ye({optional:e.config.optional,className:"flex-1 rounded-r-full"}),placeholder:e.config.placeholder}),e.config.optional&&t.o(le,{class:"absolute right-0 top-0",onClick:()=>r(null)})]}),t.o(ie,{})]}),t.o(fe,{error:h.countryCode||h.phoneNumber||{message:a}})]})},In=({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"})]})]})})}),qe={empty:"Please enter some text",email:"That doesn’t look like a valid email address",phone:"That doesn’t look like a valid phone number",url:"That doesn’t look like a valid URL"},Vn={email:{type:"email",inputMode:"email",formNoValidate:!0},text:{type:"text",inputMode:"text"},url:{type:"url",inputMode:"url",formNoValidate:!0}},Fn=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(qe.email,[t.email(qe.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(qe.url),t.minLength(e.minChars??1,n.minLength),t.maxLength(e.maxChars??1/0,n.maxLength)])}[e.format]}))},Ln=({input:e,onSubmitSuccess:r})=>{var b;const{t:n}=t.useTranslation(),s=e.key?(b=t.store.current$.value.flow)==null?void 0:b.data.submissions[e.key]:void 0,a=e.config.defaultValue,{register:o,handleSubmit:i,formState:{errors:u}}=Fe({defaultValues:{text:a||(Fn(s)?s.value:"")},resolver:Mn(e.config,n)}),{ref:d,...h}=o("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:i(p=>{r({type:"string",value:p.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",...h,...Vn[e.config.format],autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:p=>{p&&(x.current=p),d(p)},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(ie,{})]}),t.o(fe,{error:u.text})]})},Nn={text:Ln,phone:Tn,"multiple-choice":vn,boolean:Br,file:Kr,submit:In,address:Nr,number:_n},Rn=({logger:e})=>{var o;const r=(o=t.store.current$.value.flow)==null?void 0:o.data.currentInput,[n,s]=_r(),a=t._$1(null);return t.store.inputHeight$.value=s.height,t.p(()=>{const i=a.current;if(i)return i.addEventListener("transitionstart",P.scrollToEnd.smooth),i.addEventListener("transitioncancel",P.scrollToEnd.smooth),i.addEventListener("transitionend",P.scrollToEnd.smooth),()=>{i.removeEventListener("transitionstart",P.scrollToEnd.smooth),i.removeEventListener("transitioncancel",P.scrollToEnd.smooth),i.removeEventListener("transitionend",P.scrollToEnd.smooth)}},[]),t.o("div",{ref:a,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 i=Nn[r.type];return t.o(i,{logger:e,onSubmitSuccess:P.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(ie,{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},Gt=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 $n(e,r,n){var s=0,a=0;if(e==="")return e;if(!e||!Gt(e))throw new TypeError("First argument to react-string-replace#replaceString must be a string");var o=r;Dn(o)||(o=new RegExp("("+On(o)+")","gi"));for(var i=e.split(o),u=1,d=i.length;u<d;u+=2){if(i[u]===void 0||i[u-1]===void 0){console.warn("reactStringReplace: Encountered undefined value during string replacement. Your RegExp may not be working the way you expect.");continue}a=i[u].length,s+=i[u-1].length,i[u]=n(i[u],u,s),s+=a}return i}var Pn=function(r,n,s){return Array.isArray(r)||(r=[r]),Bn(r.map(function(a){return Gt(a)?$n(a,n,s):a}))};const ke=t.getDefaultExportFromCjs(Pn),jn=/(\[[^\]]+\]\([^)]+\))/g,zn=/\[([^\]]+)\]\(([^)]+)\)/,qn=/(https?:\/\/[^\s]+)/g,Un=/_(.*?)_/g,Kn=/\*\*(.*?)\*\*/g,It="text-accent-10 hover:text-accent-11 no-underline underline-offset-2 hover:underline",Gn=e=>{const r=ke(e,jn,(o,i)=>{const[,u,d]=o.match(zn)??[];return d?t.o("a",{class:It,href:d,children:u??d},d+i):t.o("span",{children:"INVALID LINK"})}),n=ke(r,qn,(o,i)=>t.o("a",{class:It,href:o,children:o},o+i)),s=ke(n,Un,(o,i)=>t.o("em",{children:o},o+i));return ke(s,Kn,(o,i)=>t.o("strong",{children:o},o+i))},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,...a})=>t.o("p",{style:{transformOrigin:s==="left"?"0% 50%":"100% 50%"},class:Hn({className:r,side:s,animate:n}),...a,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(()=>{P.scrollToEnd.smooth()}),t.o("div",{"aria-hidden":!0,children:P.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(()=>{P.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,a)=>t.o(t.k,{children:t.o("li",{class:"flex",children:t.N(s).with({type:"system"},o=>t.o("p",{class:Yn({variant:o.variant}),children:o.text})).with({type:"text",author:t._.union("bot","user")},o=>{const i=o.author==="user"&&!r.slice(a+1).some(h=>h.type==="text"&&h.author==="user"),u=a===r.length-1,d=o.author==="bot"?Gn(o.text):o.text;return t.o(Wn,{animate:u,side:Xn[o.author],children:[d,i?e:null]},a)}).with({type:"link"},o=>t.o(Jn,{message:o})).with({type:"image"},o=>t.o("img",{class:"shadow-surface-md w-full max-w-[min(100%,24rem)] rounded-2xl",src:o.url,style:{aspectRatio:o.width/o.height}})).with({type:"file"},o=>t.o(zr,{class:o.author==="bot"?void 0:"ml-auto",file:{name:o.fileName,sizeKb:o.fileSizeKb}})).with({type:"loading"},o=>{const i=r[r.length-1];return!(o===i)||P.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()})},a)),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 a=t.store.viewState$.value,{chatRef:o,chatService:i}=Tr(),{t:u}=t.useTranslation(),[d,h]=t.h();return t.y(()=>{a==="maximised"&&P.scrollToEnd.instant()},[a]),t.y(()=>{var S,E;const{state:x,flow:b}=t.store.current$.peek();if(x!=="loaded")throw new Error(u("invalid_state"));let p=b.data.nodeHistory.at(-1);if(P.scrollToEnd.instant(),t.store.setInput(void 0),b.data.isFinished)return;p===void 0?(p=t.getHeadOrThrow(s.nodes).id,t.store.setCurrentNodeId(p),n.log({event:"FLOW_START",properties:{flow_id:s.id,flow_version:s.version,flow_session_id:b.data.flowSessionId,flow_build:s.build,job:s.job},customProperties:(S=s.analytics)==null?void 0:S.customProperties})):t.store.removeMessagesSentByNodeIds([p]);const{interpret:_,abort:v,undo:A}=rr({context:s.context,analytics:{service:n,customProperties:(E=s.analytics)==null?void 0:E.customProperties},apiClient:r,logger:e,flow:s,chatService:i,t:u,getSubmissions:()=>{var g;return(g=t.store.current$.peek().flow)==null?void 0:g.data.submissions},onInterpret:(g,M)=>{var L;const O=t.store.current$.peek().flow;t.invariant(O),M&&(O.data.sequence=O.data.sequence+1,n.log({event:"FLOW_NODE",properties:{flow_id:s.id,flow_version:s.version,from_node_id:M.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 M;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:(M=s.analytics)==null?void 0:M.customProperties})}});return h(()=>A),_(p),v},[n,r,i,e,s,u]),t.o(t.k,{children:[t.o("div",{ref:o,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),a=n.data.nodeHistory.splice(-s);a.length!==0&&(t.store.removeMessagesSentByNodeIds(a),t.store.setInput(void 0),a.pop(),a.map(o=>n.nodes.find(i=>i.id===o)).filter(Boolean).flatMap(ts).forEach(o=>delete n.data.submissions[o]),t.store.current$.value={...t.store.current$.value})},children:r("undo")})})};exports.ChatbotBody=es;
package/dist/i18n.d.ts CHANGED
@@ -28,6 +28,14 @@ export declare const TranslationProvider: (props: {
28
28
  readonly back: "Back";
29
29
  readonly search: "Search";
30
30
  readonly unknown_error: "An error occurred";
31
+ readonly line1: "Line 1";
32
+ readonly line2: "Line 2";
33
+ readonly line3: "Line 3";
34
+ readonly city: "City";
35
+ readonly state: "State";
36
+ readonly postcode: "Postcode";
37
+ readonly country: "Country";
38
+ readonly select_country: "Select a country";
31
39
  readonly validation_max_chars: "Please enter no more than {{count}} characters";
32
40
  readonly validation_min_chars: "Please enter {{count}} or more characters";
33
41
  readonly validation_phone: "Please enter a valid phone number";
@@ -74,6 +82,14 @@ export declare const TranslationProvider: (props: {
74
82
  readonly back: "Back";
75
83
  readonly search: "Search";
76
84
  readonly unknown_error: "An error occurred";
85
+ readonly line1: "Line 1";
86
+ readonly line2: "Line 2";
87
+ readonly line3: "Line 3";
88
+ readonly city: "City";
89
+ readonly state: "State";
90
+ readonly postcode: "Postcode";
91
+ readonly country: "Country";
92
+ readonly select_country: "Select a country";
77
93
  readonly validation_max_chars: "Please enter no more than {{count}} characters";
78
94
  readonly validation_min_chars: "Please enter {{count}} or more characters";
79
95
  readonly validation_phone: "Please enter a valid phone number";
@@ -117,6 +133,14 @@ export declare const TranslationProvider: (props: {
117
133
  readonly back: "Back";
118
134
  readonly search: "Search";
119
135
  readonly unknown_error: "An error occurred";
136
+ readonly line1: "Line 1";
137
+ readonly line2: "Line 2";
138
+ readonly line3: "Line 3";
139
+ readonly city: "City";
140
+ readonly state: "State";
141
+ readonly postcode: "Postcode";
142
+ readonly country: "Country";
143
+ readonly select_country: "Select a country";
120
144
  readonly validation_max_chars: "Please enter no more than {{count}} characters";
121
145
  readonly validation_min_chars: "Please enter {{count}} or more characters";
122
146
  readonly validation_phone: "Please enter a valid phone number";
@@ -163,6 +187,14 @@ export declare const TranslationProvider: (props: {
163
187
  readonly back: "Back";
164
188
  readonly search: "Search";
165
189
  readonly unknown_error: "An error occurred";
190
+ readonly line1: "Line 1";
191
+ readonly line2: "Line 2";
192
+ readonly line3: "Line 3";
193
+ readonly city: "City";
194
+ readonly state: "State";
195
+ readonly postcode: "Postcode";
196
+ readonly country: "Country";
197
+ readonly select_country: "Select a country";
166
198
  readonly validation_max_chars: "Please enter no more than {{count}} characters";
167
199
  readonly validation_min_chars: "Please enter {{count}} or more characters";
168
200
  readonly validation_phone: "Please enter a valid phone number";
@@ -206,6 +238,14 @@ export declare const TranslationProvider: (props: {
206
238
  readonly back: "Back";
207
239
  readonly search: "Search";
208
240
  readonly unknown_error: "An error occurred";
241
+ readonly line1: "Line 1";
242
+ readonly line2: "Line 2";
243
+ readonly line3: "Line 3";
244
+ readonly city: "City";
245
+ readonly state: "State";
246
+ readonly postcode: "Postcode";
247
+ readonly country: "Country";
248
+ readonly select_country: "Select a country";
209
249
  readonly validation_max_chars: "Please enter no more than {{count}} characters";
210
250
  readonly validation_min_chars: "Please enter {{count}} or more characters";
211
251
  readonly validation_phone: "Please enter a valid phone number";
@@ -250,6 +290,14 @@ export declare const TranslationProvider: (props: {
250
290
  readonly back: "Back";
251
291
  readonly search: "Search";
252
292
  readonly unknown_error: "An error occurred";
293
+ readonly line1: "Line 1";
294
+ readonly line2: "Line 2";
295
+ readonly line3: "Line 3";
296
+ readonly city: "City";
297
+ readonly state: "State";
298
+ readonly postcode: "Postcode";
299
+ readonly country: "Country";
300
+ readonly select_country: "Select a country";
253
301
  readonly validation_max_chars: "Please enter no more than {{count}} characters";
254
302
  readonly validation_min_chars: "Please enter {{count}} or more characters";
255
303
  readonly validation_phone: "Please enter a valid phone number";