@inploi/plugin-chatbot 7.0.3 → 7.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.
- package/cdn/index.js +3 -3
- package/dist/chatbot-body-4fc6a204.js +4077 -0
- package/dist/chatbot-body-b0bae6c4.cjs +1 -0
- package/dist/chatbot.api.d.ts +30 -0
- package/dist/chatbot.d.ts +2 -1
- package/dist/chatbot.utils.d.ts +10 -0
- package/dist/components/chatbot-body.d.ts +3 -2
- package/dist/components/chatbot.d.ts +3 -2
- package/dist/{index-94ac185f.js → index-086aae7d.js} +751 -742
- package/dist/index-5d6165c2.cjs +5 -0
- package/dist/interpreter.d.ts +3 -2
- package/dist/mocks/flows.mocks.d.ts +1 -0
- package/dist/plugin-chatbot.cjs +1 -1
- package/dist/plugin-chatbot.js +1 -1
- package/dist/rpc.d.ts +20 -0
- package/package.json +5 -5
- package/dist/chatbot-body-23ad6c41.cjs +0 -1
- package/dist/chatbot-body-b0e15a28.js +0 -4036
- package/dist/index-5220abff.cjs +0 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./index-5d6165c2.cjs");require("@inploi/sdk");const it=({condition:e,context:t,submissions:r,ifBlock:s})=>{const[i,...a]=e.compareKey.split(".");if(!i)return!1;const l=Mt({context:t,key:i,path:a,submissions:r});if(!l)return!1;switch(l.type){case"address":{const o=n.get(l.value,a.join("."));switch(e.compare){case"equals":return o===e.compareValue;case"contains":return o?o.includes(e.compareValue):!1;case"notEquals":return o!==e.compareValue;case"notContains":return o?!o.includes(e.compareValue):!0}break}case"integration":{if(typeof l.value!="object"||Array.isArray(l.value))return!1;const o=n.get(l.value,a.join(".")),f={...s,data:{compareKey:"_temp",compare:e.compare,compareValue:e.compareValue}};switch(typeof o){case"boolean":return we(f,{submissions:{_temp:{value:o,type:"boolean"}},context:t});case"string":return we(f,{submissions:{_temp:{value:o,type:"string"}},context:t});case"number":return we(f,{submissions:{_temp:{value:o,type:"number"}},context:t});case"object":return Array.isArray(o)&&o.every(n.isString)?we(f,{submissions:{_temp:{value:o,type:"enum"}},context:t}):!1}break}case"boolean":{const o=e.compareValue==="true";switch(e.compare){case"equals":return l.value===o;case"notEquals":return l.value!==o}break}case"phone":case"string":{const o=l.type==="phone"?Ae(l.value):l.value;switch(e.compare){case"equals":return o===e.compareValue;case"contains":return o?o.includes(e.compareValue):!1;case"notEquals":return o!==e.compareValue;case"notContains":return o?!o.includes(e.compareValue):!0}break}case"number":{try{const o=Number(e.compareValue);switch(e.compare){case"equals":return l.value===o;case"notEquals":return l.value!==o;case"greaterThan":return l.value>o;case"greaterThanOrEqualTo":return l.value>=o;case"lessThan":return l.value<o;case"lessThanOrEqualTo":return l.value<=o}}catch{return console.error(`Failed to parse number in if-block ${s.id}`,l.value),!1}break}case"enum":switch(e.compare){case"equals":return l.value.length===1&&l.value[0]===e.compareValue;case"notEquals":return l.value.length===1&&l.value[0]!==e.compareValue;case"contains":return l.value.includes(e.compareValue);case"notContains":return!l.value.includes(e.compareValue)}break}},we=(e,{context:t,submissions:r})=>{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(it({condition:a,context:t,submissions:r,ifBlock:e}))return!0;return!1}else{for(const a of s)if(!it({condition:a,context:t,submissions:r,ifBlock:e}))return!1;return!0}},sr=/{{\s*([^}]+?)\s*(?:\|\s*([^}]+?)\s*)?}}/g,Q=(e,{context:t,submissions:r})=>e.replace(sr,(s,i,a="")=>{const[l,...o]=i.trim().split("."),f=Mt({key:l,path:o,submissions:r,context:t});if(!f)return a;switch(f.type){case"boolean":return f.value===!0?"true":"false";case"file":return f.value.map(p=>`${p.name} (${n.kbToReadableSize(p.sizeKb)})`).join(", ");case"enum":return f.value.join(", ");case"address":return Object.values(f.value).filter(p=>p&&p.trim().length>0).join(", ");case"number":case"string":return f.value?f.value.toString():a;case"phone":return Ae(f.value);case"integration":{if(typeof f.value!="object"||Array.isArray(f.value))break;const p=n.get(f.value,o.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(n.isString))return p.join(", ")}break}}return a}),It=({node:e,nodes:t,stopWhen:r})=>{if((r==null?void 0:r(e))===!0)return e;const s=e.nextId?t.find(i=>i.id===e.nextId):void 0;if(s)return It({node:s,nodes:t,stopWhen:r})},ar=({childNode:e,nodes:t})=>{const s=t.filter(i=>i.type==="if-block").find(i=>{if(!i.branchId)return!1;const a=t.find(o=>o.id===i.branchId);if(!a)return!1;const l=It({node:a,nodes:t,stopWhen:o=>o.id===e.id});return!(!l||l.id!==e.id)});if(s!=null&&s.nextId)return t.find(i=>i.id===s.nextId)},ir=({flow:e,analytics:t,logger:r,platformClient:s,context:i,apiClient:a,getSubmissions:l,chatService:o,onFlowEnd:f,onInterpret:p,t:C})=>{let v=new AbortController;const h={...t.service,log:y=>t.service.log({...y,customProperties:{...y.customProperties,...t.customProperties}})},b=async(y,V)=>{const E=l();p==null||p(y,V);try{await or({flow:e,analytics:h,logger:r,platformClient:s,apiClient:a,context:i,node:y,submissions:E,t:C,chat:{sendMessage:async x=>o.send({groupId:y.id,message:x,signal:v.signal}),userInput:async x=>o.input({input:x,signal:v.signal}),addToSubmissions:o.addToSubmissions},next:x=>{const _=x?e.nodes.find(A=>A.id===x):ar({childNode:y,nodes:e.nodes});return _?b(_,y):f==null?void 0:f(y)},end:()=>f==null?void 0:f(y)})}catch(x){if(x instanceof n.AbortedError)return;throw x}};return{interpret:async y=>{const V=e.nodes.find(E=>E.id===y)??n.getHeadOrThrow(e.nodes);return b(V)},undo:y=>{let V=1;const E=e.nodes.find(_=>_.id===y[y.length-1]);for(let _=y.length-2;_>0;_--){const A=y[_],R=e.nodes.find(T=>T.id===A);if(!R||(V++,R.type.startsWith("question-")))break}v.abort(),v=new AbortController;const x=e.nodes.find(_=>_.id===y[y.length-V]);return n.invariant(x,"Undo failed: new start node not found"),b(x,E),{removed:V}},abort:()=>{v.abort()}}},Ae=e=>`+${e.countryCode} ${e.phoneNumber}`;async function or(e){const t=e.node;switch(t.type){case"text":return gr({...e,node:t});case"image":return br({...e,node:t});case"question-text":return yr({...e,node:t});case"question-enum":return wr({...e,node:t});case"question-number":return vr({...e,node:t});case"question-phone":return xr({...e,node:t});case"question-boolean":return kr({...e,node:t});case"question-file":return Cr({...e,node:t});case"question-address":return _r({...e,node:t});case"end-flow":return Sr({...e,node:t});case"if-block":return mr({...e,node:t});case"jump":return dr({...e,node:t});case"link":return pr({...e,node:t});case"integration-application-submit":return hr({...e,node:t});case"add-submission":return fr({...e,node:t});case"integration-workflow-get":throw Error("Workflow should be unreachable");case"identify":return ur({...e,node:t});case"check-duplicate":return cr({...e,node:t});case"feedback":return lr({...e,node:t});default:throw new Error(`Unknown node: ${JSON.stringify(t)}`)}}const he=(e,t)=>{var s;const r=(s=e[t])==null?void 0:s.value;if(typeof r!="string"&&typeof r!="number")throw new Error(`Submission at “${t}” is not a string or number`);return r};async function lr({next:e,node:t}){e(t.nextId)}async function ur({next:e,node:t,analytics:r,submissions:s,logger:i}){if(!s)return e(t.nextId);try{r.log({event:"IDENTIFY",properties:{identifier:he(s,t.data.key).toString(),first_name:t.data.firstName?he(s,t.data.firstName).toString():void 0,last_name:t.data.lastName?he(s,t.data.lastName).toString():void 0,email:t.data.email?he(s,t.data.email).toString():void 0,phone_number:t.data.phoneNumber?he(s,t.data.phoneNumber).toString():void 0,custom_traits:t.data.customTraits?Object.fromEntries(t.data.customTraits.map(({key:a,value:l})=>{var o;return[a,(o=s[l])==null?void 0:o.value]})):void 0}})}catch(a){i.error(a)}finally{e(t.nextId)}}async function cr({next:e,node:t,platformClient:r,submissions:s,flow:i,logger:a,chat:l}){var f;let o={isDuplicate:!1};if(s&&r){const p=t.data.scope==="job"?(f=i.job)==null?void 0:f.id:void 0;if(t.data.scope==="company"||p!=null)try{o=await r.checkDuplicate({email:he(s,t.data.email).toString(),jobId:p,scope:t.data.scope})}catch(C){a.error("[check-duplicate]",C)}}l.addToSubmissions(t.data.key,{type:"integration",value:o}),e(t.nextId)}async function dr({next:e,node:t}){e(t.data.targetId)}async function fr({next:e,node:t,logger:r,submissions:s,context:i}){if(!s){r.error("Submissions not found");return}s[t.data.key]={type:"string",value:Q(t.data.value,{submissions:s,context:i})},e(t.nextId)}async function hr({chat:e,next:t,node:r,logger:s,apiClient:i,submissions:a,analytics:l,flow:o,t:f}){const p=async C=>{C!==!0&&await e.userInput({type:"submit",key:void 0,config:{label:r.data.submitLabel}}),await e.sendMessage({type:"loading"});const{anonymous_id:v,session_id:h}=l.getSessionInfo(),b=await i.fetch("/flow/submit",{method:"POST",body:JSON.stringify({log_submit:!1,integration_id:r.data.integrationId,anonymous_id:v,session_id:h,job:o.job,submissions:n.getFlowSubmissionsPayload(a||{})})}).catch(y=>y);r.data.key&&e.addToSubmissions(r.data.key,{type:"integration",value:b}),n.M(b).with({integration_response:n.z.select(n.z.union({service:n.z.optional(n.z.string),status:n.z.number,data:n.z.any},{service:n.z.optional(n.z.string),status:n.z.number,error:{message:n.z.string,data:n.z.any}}))},y=>{l.log({event:"FLOW_SUBMIT",properties:{flow_id:o.id,flow_version:o.version,flow_session_id:o.data.flowSessionId,flow_build:o.build,service:y.service??"INVALID_SERVICE",response:{status:y.status,payload:"data"in y?y.data:y.error.data??null},job:o.job}})}).otherwise(()=>{}),await n.M(b).with({integration_response:{data:n.z.select("redirect",{redirect_url:n.z.string,message:n.z.optional(n.z.union(n.z.string,n.z.nullish)),button_text:n.z.optional(n.z.union(n.z.string,n.z.nullish))})}},async y=>{await e.sendMessage({type:"text",author:"bot",text:y.redirect.message??f("submission_redirect_message")});try{const V=new URL(y.redirect.redirect_url);v&&!V.searchParams.has("anonymous_id")&&V.searchParams.set("anonymous_id",v),await e.sendMessage({type:"link",href:V.toString(),text:y.redirect.button_text??f("complete_submission"),onClick:()=>{if(!h){s.error("session_id not set, cannot log FLOW_REDIRECT event");return}l.log({event:"FLOW_REDIRECT",properties:{flow_build:o.build,flow_id:o.id,flow_session_id:h,flow_version:o.version,href:V.toString(),job:o.job}})}})}catch(V){s.error(`Invalid redirect URL: ${y.redirect.redirect_url}`,V),e.sendMessage({type:"system",variant:"error",text:f("redirect_url_error")})}t(r.nextId)}).with({success:!0},async()=>{r.data.skipConfirmation!==!0&&await e.sendMessage({type:"system",variant:"success",text:f("submission_completed")}),t(r.nextId)}).with({integration_response:{error:n.z.select("error",{message:n.z.string})}},async y=>{s.error(y.error),await e.sendMessage({type:"system",variant:"error",text:y.error.message||f("submission_failed")}),await p(!1)}).otherwise(async y=>{s.error(y),await e.sendMessage({type:"system",variant:"error",text:f("submission_failed")}),await p(!1)})};await p(r.data.skipConfirmation)}async function pr({chat:e,next:t,node:r,submissions:s,context:i}){await e.sendMessage({type:"link",href:Q(r.data.href,{submissions:s,context:i}),text:Q(r.data.cta,{submissions:s,context:i})}),t(r.nextId)}async function mr({submissions:e,next:t,node:r,context:s}){t(we(r,{submissions:e,context:s})?r.branchId:r.nextId)}async function gr({chat:e,next:t,node:r,submissions:s,context:i}){await e.sendMessage({author:"bot",type:"text",text:Q(r.data.text,{submissions:s,context:i})}),t(r.nextId)}async function br({chat:e,next:t,node:r}){await e.sendMessage({author:"bot",type:"image",url:r.data.url,height:r.data.height,width:r.data.width}),t(r.nextId)}async function yr({chat:e,next:t,node:r,submissions:s,context:i,t:a}){await e.sendMessage({author:"bot",type:"text",text:Q(r.data.question,{submissions:s,context:i})});const l=r.data.format==="phone"?await e.userInput({key:r.data.key,type:"phone",config:{optional:r.data.optional,placeholder:r.data.placeholder,minChars:r.data.minChars,maxChars:r.data.maxChars,submissionFormat:"text",defaultValue:{}}}):await e.userInput({key:r.data.key,type:"text",config:{optional:r.data.optional,placeholder:r.data.placeholder,format:r.data.format,maxChars:r.data.maxChars,minChars:r.data.minChars}});l===null?await e.sendMessage({type:"system",variant:"info",text:a("skipped")}):await e.sendMessage({author:"user",type:"text",text:l.type==="phone"?Ae(l.value):l.value}),t(r.nextId)}async function vr({chat:e,next:t,node:r,submissions:s,context:i,t:a}){await e.sendMessage({author:"bot",type:"text",text:Q(r.data.question,{submissions:s,context:i})});const l=await e.userInput({key:r.data.key,type:"number",config:{max:r.data.max,min:r.data.min,optional:r.data.optional,placeholder:r.data.placeholder,decimalCases:r.data.decimalCases}});l===null?await e.sendMessage({type:"system",variant:"info",text:a("skipped")}):await e.sendMessage({author:"user",type:"text",text:l.value.toString()}),t(r.nextId)}async function xr({chat:e,next:t,node:r,submissions:s,context:i}){await e.sendMessage({author:"bot",type:"text",text:Q(r.data.question,{submissions:s,context:i})});const a=await e.userInput({key:r.data.key,type:"phone",config:{minChars:r.data.minChars,defaultValue:{countryCode:r.data.defaultCountryCode},placeholder:r.data.placeholder,submissionFormat:"phone",optional:r.data.optional}});a===null?await e.sendMessage({type:"system",variant:"info",text:"Skipped"}):await e.sendMessage({author:"user",type:"text",text:a.type==="phone"?Ae(a.value):a.value}),t(r.nextId)}async function wr({chat:e,next:t,node:r,submissions:s,context:i,t:a}){await e.sendMessage({author:"bot",type:"text",text:Q(r.data.question,{submissions:s,context:i})});const l=await e.userInput({key:r.data.key,type:"multiple-choice",config:r.data});l.value.length===0?await e.sendMessage({type:"system",variant:"info",text:a("skipped")}):await e.sendMessage({author:"user",type:"text",text:r.data.options.filter(o=>l.value.includes(o.value)).map(o=>o.label).join(", ")}),t(r.nextId)}async function kr({chat:e,next:t,node:r,submissions:s,context:i,t:a}){await e.sendMessage({author:"bot",type:"text",text:Q(r.data.question,{submissions:s,context:i})});const l=await e.userInput({key:r.data.key,type:"boolean",config:{optional:r.data.optional,labels:{true:r.data.trueLabel,false:r.data.falseLabel}}});l===null?await e.sendMessage({type:"system",variant:"info",text:a("skipped")}):await e.sendMessage({author:"user",type:"text",text:l.value===!0?r.data.trueLabel:r.data.falseLabel}),t(r.nextId)}async function _r({chat:e,next:t,node:r,t:s}){await e.sendMessage({author:"bot",type:"text",text:r.data.question});const i=await e.userInput({type:"address",key:r.data.key,config:{optional:r.data.optional,keys:r.data.keys,placeholder:r.data.placeholder}});if(i===null)await e.sendMessage({type:"system",variant:"info",text:s("skipped")});else{const a=Object.values(i.value).filter(l=>l&&l.trim().length>0).join(", ");await e.sendMessage({author:"user",type:"text",text:a})}return t(r.nextId)}async function Cr({node:e,chat:t,next:r,submissions:s,context:i,t:a}){await t.sendMessage({author:"bot",type:"text",text:Q(e.data.question,{submissions:s,context:i})});const l=await t.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(l===null)await t.sendMessage({type:"system",variant:"info",text:a("skipped")});else for(const o of l.value)await t.sendMessage({author:"user",type:"file",fileName:o.name,fileSizeKb:o.sizeKb});r(e.nextId)}async function Sr({chat:e,end:t,node:r}){await e.sendMessage({type:"system",variant:"info",text:r.data.systemMessage}),t()}const Mt=({key:e,path:t,submissions:r,context:s})=>{if(e==="$context"){if(!t)return;const i=n.get(s,t.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.${t.join(".")}`,i);return}}return r==null?void 0:r[e]};function ot(e,t){let r;return(...s)=>{window.clearTimeout(r),r=window.setTimeout(()=>e(...s),t)}}function Er({debounce:e,scroll:t,polyfill:r,offsetSize:s}={debounce:0,scroll:!1,offsetSize:!1}){const i=r||(typeof window>"u"?class{}:window.ResizeObserver);if(!i)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[a,l]=n.h({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),o=n._({element:null,scrollContainers:null,resizeObserver:null,lastBounds:a,orientationHandler:null}),f=e?typeof e=="number"?e:e.scroll:null,p=e?typeof e=="number"?e:e.resize:null,C=n._(!1);n.p(()=>(C.current=!0,()=>void(C.current=!1)));const[v,h,b]=n.F(()=>{const x=()=>{if(!o.current.element)return;const{left:_,top:A,width:R,height:T,bottom:ie,right:de,x:ee,y:ne}=o.current.element.getBoundingClientRect(),j={left:_,top:A,width:R,height:T,bottom:ie,right:de,x:ee,y:ne};o.current.element instanceof HTMLElement&&s&&(j.height=o.current.element.offsetHeight,j.width=o.current.element.offsetWidth),Object.freeze(j),C.current&&!Tr(o.current.lastBounds,j)&&l(o.current.lastBounds=j)};return[x,p?ot(x,p):x,f?ot(x,f):x]},[l,s,f,p]);function y(){o.current.scrollContainers&&(o.current.scrollContainers.forEach(x=>x.removeEventListener("scroll",b,!0)),o.current.scrollContainers=null),o.current.resizeObserver&&(o.current.resizeObserver.disconnect(),o.current.resizeObserver=null),o.current.orientationHandler&&("orientation"in screen&&"removeEventListener"in screen.orientation?screen.orientation.removeEventListener("change",o.current.orientationHandler):"onorientationchange"in window&&window.removeEventListener("orientationchange",o.current.orientationHandler))}function V(){o.current.element&&(o.current.resizeObserver=new i(b),o.current.resizeObserver.observe(o.current.element),t&&o.current.scrollContainers&&o.current.scrollContainers.forEach(x=>x.addEventListener("scroll",b,{capture:!0,passive:!0})),o.current.orientationHandler=()=>{b()},"orientation"in screen&&"addEventListener"in screen.orientation?screen.orientation.addEventListener("change",o.current.orientationHandler):"onorientationchange"in window&&window.addEventListener("orientationchange",o.current.orientationHandler))}const E=x=>{!x||x===o.current.element||(y(),o.current.element=x,o.current.scrollContainers=Lt(x),V())};return Fr(b,!!t),Vr(h),n.p(()=>{y(),V()},[t,b,h]),n.p(()=>y,[]),[E,a,v]}function Vr(e){n.p(()=>{const t=e;return window.addEventListener("resize",t),()=>void window.removeEventListener("resize",t)},[e])}function Fr(e,t){n.p(()=>{if(t){const r=e;return window.addEventListener("scroll",r,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",r,!0)}},[e,t])}function Lt(e){const t=[];if(!e||e===document.body)return t;const{overflow:r,overflowX:s,overflowY:i}=window.getComputedStyle(e);return[r,s,i].some(a=>a==="auto"||a==="scroll")&&t.push(e),[...t,...Lt(e.parentElement)]}const Ar=["x","y","top","bottom","left","right","width","height"],Tr=(e,t)=>Ar.every(r=>e[r]===t[r]),ue=({class:e,...t})=>{const{t:r}=n.useTranslation();return n.o("button",{class:n.clsx("bg-accent-9 active:bg-accent-10 pointer-coarse:touch-hitbox fr flex-shrink-0 rounded-full p-2 text-white transition-all disabled:cursor-not-allowed disabled:opacity-50",e),type:"submit",...t,children:n.o("svg",{class:"block",width:"16",height:"16",viewBox:"0 0 16 16",fill:"transparent",stroke:"currentColor","stroke-linecap":"round","stroke-width":"2",children:[n.o("title",{children:r("send")}),n.o("path",{d:"M3.5 7.5L8 3L12.5 7.5"}),n.o("path",{d:"M8 4V13"})]})})},Ir=25,ze=n.d({instant:()=>{},smooth:()=>{}}),U={onSubmitSuccessFn$:n.d(()=>{}),isBotTyping$:n.d(!1),scrollToEnd:{instant:()=>ze.value.instant(),smooth:()=>ze.value.smooth()}},Mr=()=>{const e=n._(null);n.y(()=>{ze.value={instant:()=>{var r;return(r=e.current)==null?void 0:r.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 t=n.F(()=>({addToSubmissions:(s,i)=>n.store.setSubmission(s,i),send:async({message:s,signal:i,groupId:a})=>{if(await n.M(s).with({author:"bot",type:"text"},async l=>{if(i!=null&&i.aborted)throw new n.AbortedError;U.isBotTyping$.value=!0;const o=Math.min(Math.max(20,l.text.length),100)*Ir;await new Promise(f=>setTimeout(f,o,{signal:i})),U.isBotTyping$.value=!1}).otherwise(async()=>{}),i!=null&&i.aborted)throw new n.AbortedError;n.store.addMessage(s,a)},input:({input:s,signal:i})=>{if(i!=null&&i.aborted)throw new n.AbortedError;return n.store.setInput(s),new Promise(a=>{const l=o=>{if(i!=null&&i.aborted)throw new n.AbortedError;n.store.setInput(void 0),s.key&&n.store.setSubmission(s.key,o),a(o)};U.onSubmitSuccessFn$.value=l})}}),[]);return{chatRef:e,chatService:t}},me=({error:e})=>!e||!e.message?null:n.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:[n.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:[n.o("circle",{cx:"8",cy:"8",r:"6.3",stroke:"currentColor","stroke-width":"1.4"}),n.o("rect",{x:"7",y:"4",width:"2",height:"5",fill:"currentColor"}),n.o("rect",{x:"7",y:"10",width:"2",height:"2",fill:"currentColor"})]}),n.o("p",{class:"truncate pr-1 text-sm",children:e.message})]}),ce=({class:e,...t})=>{const{t:r}=n.useTranslation();return n.o("button",{type:"button",class:n.clsx("fr touch-hitbox text-neutral-10 bg-neutral-1 ring-divider hover:ring-divider active:ring-interactive-bg-hover hover:text-neutral-12 active:text-neutral-12 hover:bg-divider active:bg-interactive-bg-hover flex flex-shrink-0 items-center justify-center gap-1 self-center rounded-full py-1 pl-2 pr-2.5 text-sm ring-1 transition-all",e),...t,children:[n.o("svg",{"aria-hidden":!0,class:"block",width:"16",height:"16",viewBox:"0 0 16 16",fill:"transparent",stroke:"currentColor","stroke-linecap":"round","stroke-width":"1.5",children:[n.o("title",{children:r("skip")}),n.o("path",{d:"M3.25 11.25A5 5 0 0 1 12 7"}),n.o("path",{d:"M13.25 4.5V8.25H9.5"})]}),r("skip")]})},$e={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"},Ce=n.cva("outline-divider ease-expo-out placeholder:text-neutral-10 text-neutral-12 focus-visible:outline-accent-7 caret-accent-9 bg-lowest py-1 text-base outline outline-2 transition-all",{variants:{optional:{true:"pr-16 pl-3",false:"pl-3 pr-3"}},defaultVariants:{optional:!1}}),Lr="https://api.mapbox.com/search/searchbox/v1/suggest",Nr="ZzRDWFU0dTZ3SF9aWk9RNGl6QzZaWS5RZmlFak13a0hPbGxXZXlNSGN5RUhObUJ6TXpSV08yUW5OdE5tSTZJU1lpd2lJb1JYYXRObmJ2Tm5iaGhHZWx4V1lpb2pJMUp5ZS5rcA==",Rr=e=>atob(e).split("").reverse().join(""),te=n.object({name:n.string()}),Dr=n.object({suggestions:n.array(n.object({full_address:n.optional(n.string()),place_formatted:n.optional(n.string()),name:n.optional(n.string()),mapbox_id:n.string(),context:n.partial(n.object({address:te,street:te,neighborhood:te,locality:te,district:te,place:te,region:te,postcode:te,country:te}))}))}),Or=({logger:e,t})=>n.F(()=>{var s;const r=(s=n.store.current$.peek().flow)==null?void 0:s.data.flowSessionId;return r?{enabled:!0,getPredictions:async i=>{var v;const a=new URL(Lr);a.searchParams.set("q",i),a.searchParams.set("session_token",r);const l=(v=n.store.current$.peek().flow)==null?void 0:v.locationOrigin;l&&l.lat!==void 0&&l.lng!==void 0&&l.lat>=-90&&l.lat<=90&&l.lng>=-180&&l.lng<=180&&a.searchParams.set("proximity",`${l.lng},${l.lat}`),a.searchParams.set("access_token",Rr(Nr));const f=await fetch(a);if(!f.ok)return e.error("Failed to get address details",f),{ok:!1,error:t("address_error")};const p=n.safeParse(Dr,await f.json());if(p.success===!1)return e.error("Failed to parse address details",p.issues),{ok:!1,error:t("address_error")};const{suggestions:C}=p.output;return{ok:!0,data:C.map(h=>{var b,y,V,E,x,_,A,R,T;return{label:h.full_address??h.place_formatted??h.name??h.mapbox_id,id:h.mapbox_id,address:{line1:((b=h.context.address)==null?void 0:b.name)??((y=h.context.street)==null?void 0:y.name),line2:void 0,line3:((V=h.context.neighborhood)==null?void 0:V.name)??((E=h.context.locality)==null?void 0:E.name),city:((x=h.context.place)==null?void 0:x.name)??((_=h.context.district)==null?void 0:_.name),state:(A=h.context.region)==null?void 0:A.name,postcode:(R=h.context.postcode)==null?void 0:R.name,country:(T=h.context.country)==null?void 0:T.name}}})}}}:{enabled:!1}},[e,t]),lt=e=>{const{t}=n.useTranslation();return n.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:[n.o("svg",{width:"16",height:"16",viewBox:"0 0 16 16",stroke:"currentColor","stroke-width":"1.5",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:n.o("path",{d:"M10 3L5 8L10 13"})}),n.o("span",{children:t("back")})]})},Br=({input:e,onSubmitSuccess:t,logger:r})=>{const{t:s}=n.useTranslation(),[i,a]=n.h(),[l,o]=n.h([]),{enabled:f,getPredictions:p}=Or({logger:r,t:s}),[C,v]=n.h(f?"query":"manual"),[h,b]=n.h(""),[y,V]=n.h(),E=x=>{n.invariant(f,"Query state should not be enabled"),x=x.trim(),x!==(h==null?void 0:h.trim())&&(b(x),x===""&&o([]),V(void 0),p(x).then(_=>{if(_.ok===!1){o([]),V(_.error);return}o(_.data)}))};switch(C){case"query":return n.invariant(f,"Query state should not be enabled"),n.o(zr,{input:e,onSkip:()=>t(null),onAddressSelect:x=>{if(x===""){a(void 0),v("manual");return}const _=l.find(A=>A.id===x);_&&(a(_.address),v("details"))},onAddressSearch:x=>{E(x)},suggestions:l,query:h,error:y});case"details":return n.invariant(i!==void 0),n.o(ct,{input:e,logger:r,onSubmitSuccess:t,addressFields:i,actions:n.o(lt,{onClick:()=>{v("query")}})});case"manual":return n.o(ct,{logger:r,input:e,onSubmitSuccess:t,addressFields:{},actions:f?n.o(lt,{onClick:()=>{v("query")}}):void 0})}},zr=({input:e,onSkip:t,suggestions:r,onAddressSelect:s,query:i,onAddressSearch:a,error:l})=>{const{t:o}=n.useTranslation(),f=n._(null);return n.y(()=>{f.current&&(f.current.focus(),f.current.select())},[]),n.o(n.k,{children:[n.o("form",{noValidate:!0,onSubmit:p=>{p.preventDefault();const v=new FormData(p.currentTarget).get("address");typeof v=="string"&&a(v)},class:"flex gap-2 p-2.5",children:[n.o("div",{class:"group relative flex-1",children:[n.o("input",{ref:f,name:"address",id:"chat-address",autocomplete:"address-line1 country-name postal-code",autoFocus:!0,placeholder:e.config.placeholder||o("address_search"),defaultValue:i,class:Ce({optional:!!e.config.optional,className:"w-full rounded-full"})}),n.o("button",{type:"submit",class:"touch-hitbox text-neutral-12 hover:bg-neutral-3 fr absolute bottom-0 right-0 top-0 flex cursor-pointer items-center gap-1 rounded-full px-3 transition-all",children:n.o("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.o("g",{id:"inploi",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round",strokeWidth:"1.5",children:[n.o("circle",{cx:"7",cy:"7",r:"4"}),n.o("path",{d:"M10 10L13 13"})]}),n.o("span",{class:"sr-only",children:o("search")})]})})]}),e.config.optional&&n.o(ce,{class:"relative",onClick:t})]}),l?n.o(me,{error:{message:l}}):null,n.o("ul",{children:[r.map(p=>n.o("li",{children:n.o("button",{class:"text-neutral-11 fr hover:bg-neutral-3 focus-visible:bg-neutral-3 hover:text-neutral-12 border-b-neutral-3 flex w-full items-center border border-b border-solid border-transparent px-4 py-3 text-sm transition-colors duration-100",onClick:()=>{s(p.id)},children:[n.o("span",{class:"flex-grow",children:p.label}),n.o("svg",{class:"flex-none",width:"16",height:"16",viewBox:"0 0 16 16",stroke:"currentColor","stroke-width":"1.5",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:n.o("path",{d:"M6 3L11 8L6 13"})})]})},p.id)),n.o("li",{children:n.o("button",{class:"text-neutral-11 fr hover:bg-neutral-3 focus-visible:bg-neutral-3 hover:text-neutral-12 border-b-neutral-3 flex w-full items-center border border-b border-solid border-transparent px-4 py-3 text-sm transition-colors duration-100",onClick:()=>{s("")},children:n.o("span",{class:"flex-grow",children:o("address_manual")})})},"")]})]})},ut=["line1","line2","line3","city","state","postcode","country"],ct=({addressFields:e,onSubmitSuccess:t,actions:r,input:s})=>{const i=n._(null);n.y(()=>{if(i.current){const o=i.current.querySelector("input");o&&(o.focus(),o.select())}},[]);const a=Object.keys($e),{t:l}=n.useTranslation();return n.o("form",{class:"bg-neutral-1/90 flex flex-col justify-end gap-2 p-2",onSubmit:o=>{const f=new FormData(o.currentTarget),p=Object.fromEntries(f.entries());t({type:"address",value:p})},children:[n.o("div",{class:"bg-neutral-3 border-neutral-5 grid items-center gap-1.5 rounded-2xl border pb-2 pl-4 pr-3 pt-3 [grid-template-columns:min-content_1fr]",ref:i,children:ut.map((o,f)=>{const p=`isdk_${o}`,C=s.config.keys[o];return C?n.o(n.k,{children:[n.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:l(o)}),n.o("div",{class:"flex flex-col items-stretch gap-1.5",children:[o==="country"?n.o("div",{class:"relative",children:[n.o("select",{class:"text-neutral-12 hover:bg-neutral-4 placeholder:text-neutral-8 focus:bg-neutral-5 w-full flex-1 appearance-none rounded-lg border-solid bg-transparent bg-none px-3 py-1.5 text-base transition-colors focus:outline-none",name:C,id:p,defaultValue:e[o],required:!0,children:[e.country&&!a.includes(e.country)?n.o("option",{value:e[o],children:e[o]}):n.o("option",{value:"",children:l("select_country")}),a.map(v=>n.o("option",{value:v,children:v},v))]}),n.o("svg",{class:"text-neutral-12 absolute bottom-2.5 right-2 flex items-center justify-center",width:"16",height:"16",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:n.o("path",{d:"M4 6.5L8 10.5L12 6.5"})})]}):n.o("input",{autoFocus:f===0?!0:void 0,class:"text-neutral-12 hover:bg-neutral-4 placeholder:text-neutral-8 focus:bg-neutral-5 flex-1 rounded-lg border-solid bg-transparent px-3 py-1.5 text-base transition-colors autofill:shadow-[inset_0_0_0_1000px_hsl(210_16.7%_97.6%)] focus:outline-none",name:C,id:p,defaultValue:e[o],required:!0}),f===ut.length-1?n.o("hr",{class:"m-0 w-full border-b border-b-transparent"}):n.o("hr",{class:"border-b-neutral-5 m-0 w-full border-b border-solid"})]})]}):null})}),n.o("div",{class:"flex w-full flex-1 ",children:[n.o("div",{class:"flex-grow",children:r}),n.o(ue,{class:"flex items-center justify-center"})]})]})},Ue=()=>{const e=n._(null);return n.p(()=>{var t;(t=e.current)==null||t.focus()},[]),e},Nt=["true","false"],Pr=n.picklist(Nt),jr="answer",Rt="flex items-center flex-wrap gap-2 p-2.5",Dt="min-w-0 max-w-full flex-auto",Ot=n.k$1(({label:e,...t},r)=>n.o("button",{class:"bg-lowest ease-expo-out ring-divider text-neutral-12 active:ring-accent-7 active:bg-accent-2 active:text-accent-11 fr block w-full overflow-hidden rounded-2xl px-2 py-2.5 ring-2 transition-all selection:bg-transparent",...t,ref:r,children:n.o("p",{class:"text-center text-base",children:e})})),$r=({input:e,onSubmitSuccess:t})=>{const r=Ue();return n.o("form",{noValidate:!0,class:"",onSubmit:s=>{s.preventDefault();const i=n.getFormSubmitter(s).value,a=n.parse(Pr,i);t({type:"boolean",value:a==="true"})},children:[n.o("ul",{class:Rt,children:Nt.map((s,i)=>n.o("li",{class:Dt,children:n.o(Ot,{ref:i===0?r:null,type:"submit",name:jr,value:s,label:e.config.labels[s]},s)}))}),e.config.optional&&n.o("div",{class:"px-2 pb-2",children:n.o(ce,{class:"relative w-full",type:"button",onClick:()=>t(null)})})]})},Ur=e=>new Promise((t,r)=>{const s=new FileReader;s.readAsDataURL(e),s.onload=()=>s.result?t(s.result.toString()):r("No result from reader"),s.onerror=r}),qr=e=>e.reduce((t,r)=>t+r.sizeKb,0),Hr=n.isSubmissionOfType("file"),dt=3,Kr=({file:e,class:t,...r})=>{const s=e.name.split(".").pop(),i=e.name.replace(new RegExp(`.${s}$`),"");return n.o("div",{class:n.clsx("bg-accent-1 outline-accent-4 flex max-w-full gap-2 overflow-hidden rounded-lg px-3 py-2 text-sm outline",t),...r,children:[n.o("p",{"aria-label":"File name",class:"text-accent-12 flex flex-grow overflow-hidden",children:[n.o("span",{class:"block truncate",children:i}),n.o("span",{children:[".",s]})]}),n.o("p",{"aria-label":"File size",class:"text-accent-11",children:n.kbToReadableSize(e.sizeKb)})]})},ft=({class:e,...t})=>n.o("li",{class:n.clsx("outline-neutral-6 text-neutral-11 bg-neutral-1 block rounded-md px-1 py-0.5 text-xs outline outline-1",e),...t}),Bt=e=>{const t=e.split(".").pop();if(!t)throw new Error("No file extension found");return t?"."+t:""},Gr=({allowedExtensions:e,files:t})=>{const r=e.map(s=>s.toLowerCase());return t.every(s=>r.includes(Bt(s.name).toLowerCase()))},Wr=(e,t)=>{const r=Bt(e);return`${e.replace(new RegExp(`${r}$`),"").slice(0,t)}${r}`},Jr=({input:e,onSubmitSuccess:t})=>{var v;const r=(v=n.store.current$.value.flow)==null?void 0:v.data.submissions[e.key],[s,i]=n.h(Hr(r)?r.value:[]),[a,l]=n.h(),o=s.length-dt,f=qr(s),p=Ue(),{t:C}=n.useTranslation();return n.o("form",{class:"flex flex-col gap-1 p-2.5",onSubmit:h=>(h.preventDefault(),l(void 0),s.length===0?l({type:"required",message:C("validation_file")}):e.config.extensions.length>0&&!Gr({allowedExtensions:e.config.extensions,files:s})?l({type:"validate",message:`${C("validation_file_ext",{ext:e.config.extensions.join(", ")})}`}):e.config.fileSizeLimitKib&&f>e.config.fileSizeLimitKib?l({type:"max",message:`File size exceeds limit of ${n.kbToReadableSize(e.config.fileSizeLimitKib)}`}):e.config.allowMultiple===!1&&s.length>1?l({type:"invalid",message:C("validation_file_max",{count:1})}):t({type:"file",value:s})),children:[n.o("div",{class:"flex items-center gap-2",children:[n.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?n.o(n.k,{children:[n.o("ul",{class:"flex max-w-full flex-wrap justify-center gap-1 overflow-hidden p-1",children:[s.slice(0,dt).map(h=>{const b=h.name.split(".").pop(),y=h.name.replace(new RegExp(`.${b}$`),"");return n.o(ft,{class:"flex overflow-hidden",children:[n.o("span",{class:"block truncate",children:y}),n.o("span",{children:[".",b]})]})}),o>0?n.o(ft,{children:["+",o," file",o!==1?"s":""]}):null]}),n.o("p",{class:"text-neutral-11 text-xs",children:[n.kbToReadableSize(f)," ",s.length>1?"total":""]})]}):n.o("div",{class:"flex flex-col justify-center gap-4 pb-6 pt-5",children:[n.o("header",{class:"flex flex-col items-center gap-0",children:[n.o("svg",{class:"text-neutral-11 mb-1 h-8 w-8","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 20 16",children:n.o("path",{stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M13 13h3a3 3 0 0 0 0-6h-.025A5.56 5.56 0 0 0 16 6.5 5.5 5.5 0 0 0 5.207 5.021C5.137 5.017 5.071 5 5 5a4 4 0 0 0 0 8h2.167M10 15V6m0 0L8 8m2-2 2 2"})}),n.o("p",{class:"text-neutral-12 tracking-[-0.01em]",children:C("upload_file",{count:e.config.allowMultiple?2:1})}),e.config.fileSizeLimitKib?n.o("p",{class:"text-neutral-10 text-xs",children:["(",C("file_max_size",{size:n.kbToReadableSize(e.config.fileSizeLimitKib)}),")"]}):null]}),n.o("aside",{class:"flex flex-col items-center gap-2",children:[n.o("p",{id:"accepted-filetypes",class:"sr-only",children:C("file_extensions")}),n.o("ul",{"aria-describedby":"accepted-filetypes",class:"flex flex-wrap justify-center gap-2",children:e.config.extensions.map(h=>n.o("li",{class:"ring-lowest outline-neutral-6 text-neutral-9 bg-neutral-1 rounded-md px-1 py-0.5 text-[11px] uppercase tracking-wide outline outline-1 ring-2",children:h.replace(".","")}))})]})]}),n.o("input",{id:"dropzone-file",onInput:async h=>{n.invariant(h.target instanceof HTMLInputElement);const b=h.target.files?Array.from(h.target.files):[],y=await Promise.allSettled(b.map(async E=>{const x=await Ur(E);return{name:Wr(E.name,42),data:x,sizeKb:E.size/1e3}}));if(y.some(({status:E})=>E==="rejected"))return l({type:"invalid",message:"Invalid file"});const V=y.map(E=>E.status==="fulfilled"?E.value:null).filter(Boolean);i(V)},multiple:e.config.allowMultiple,type:"file",class:"sr-only"})]}),n.o("div",{class:"flex h-full flex-col items-center gap-2",children:[n.o(ue,{disabled:s.length===0}),e.config.optional&&n.o(ce,{class:"relative",onClick:()=>t(null)})]})]}),n.o(me,{error:a})]})};var Se=e=>e.type==="checkbox",le=e=>e instanceof Date,K=e=>e==null;const zt=e=>typeof e=="object";var B=e=>!K(e)&&!Array.isArray(e)&&zt(e)&&!le(e),Zr=e=>B(e)&&e.target?Se(e.target)?e.target.checked:e.target.value:e,Xr=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,Yr=(e,t)=>e.has(Xr(t)),Qr=e=>{const t=e.constructor&&e.constructor.prototype;return B(t)&&t.hasOwnProperty("isPrototypeOf")},qe=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function P(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(qe&&(e instanceof Blob||t))return e;const r=Array.isArray(e);if(!r&&!(B(e)&&Qr(e)))return e;const s=r?[]:Object.create(Object.getPrototypeOf(e));for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&(s[i]=P(e[i]));return s}var Te=e=>/^\w*$/.test(e),D=e=>e===void 0,He=e=>Array.isArray(e)?e.filter(Boolean):[],Ke=e=>He(e.replace(/["|']|\]/g,"").split(/\.|\[/)),k=(e,t,r)=>{if(!t||!B(e))return r;const s=(Te(t)?[t]:Ke(t)).reduce((i,a)=>K(i)?i:i[a],e);return D(s)||s===e?D(e[t])?r:e[t]:s},Y=e=>typeof e=="boolean",Z=e=>typeof e=="function",N=(e,t,r)=>{let s=-1;const i=Te(t)?[t]:Ke(t),a=i.length,l=a-1;for(;++s<a;){const o=i[s];let f=r;if(s!==l){const p=e[o];f=B(p)||Array.isArray(p)?p:isNaN(+i[s+1])?{}:[]}if(o==="__proto__"||o==="constructor"||o==="prototype")return;e[o]=f,e=e[o]}};const ht={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},X={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},re={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},en=n.Cn.createContext(null);en.displayName="HookFormControlContext";var tn=(e,t,r,s=!0)=>{const i={defaultValues:t._defaultValues};for(const a in e)Object.defineProperty(i,a,{get:()=>{const l=a;return t._proxyFormState[l]!==X.all&&(t._proxyFormState[l]=!s||X.all),r&&(r[l]=!0),e[l]}});return i};const rn=typeof window<"u"?n.Cn.useLayoutEffect:n.Cn.useEffect;var W=e=>typeof e=="string",nn=(e,t,r,s,i)=>W(e)?(s&&t.watch.add(e),k(r,e,i)):Array.isArray(e)?e.map(a=>(s&&t.watch.add(a),k(r,a))):(s&&(t.watchAll=!0),r),Pe=e=>K(e)||!zt(e);function ae(e,t,r=new WeakSet){if(Pe(e)||Pe(t))return Object.is(e,t);if(le(e)&&le(t))return Object.is(e.getTime(),t.getTime());const s=Object.keys(e),i=Object.keys(t);if(s.length!==i.length)return!1;if(r.has(e)||r.has(t))return!0;r.add(e),r.add(t);for(const a of s){const l=e[a];if(!i.includes(a))return!1;if(a!=="ref"){const o=t[a];if(le(l)&&le(o)||B(l)&&B(o)||Array.isArray(l)&&Array.isArray(o)?!ae(l,o,r):!Object.is(l,o))return!1}}return!0}const sn=n.Cn.createContext(null);sn.displayName="HookFormContext";var Pt=(e,t,r,s,i)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[s]:i||!0}}:{},ke=e=>Array.isArray(e)?e:[e],pt=()=>{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=[]}}};function jt(e,t){const r={};for(const s in e)if(e.hasOwnProperty(s)){const i=e[s],a=t[s];if(i&&B(i)&&a){const l=jt(i,a);B(l)&&(r[s]=l)}else e[s]&&(r[s]=a)}return r}var H=e=>B(e)&&!Object.keys(e).length,Ge=e=>e.type==="file",Ve=e=>{if(!qe)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},$t=e=>e.type==="select-multiple",We=e=>e.type==="radio",an=e=>We(e)||Se(e),Be=e=>Ve(e)&&e.isConnected;function on(e,t){const r=t.slice(0,-1).length;let s=0;for(;s<r;)e=D(e)?s++:e[t[s++]];return e}function ln(e){for(const t in e)if(e.hasOwnProperty(t)&&!D(e[t]))return!1;return!0}function O(e,t){const r=Array.isArray(t)?t:Te(t)?[t]:Ke(t),s=r.length===1?e:on(e,r),i=r.length-1,a=r[i];return s&&delete s[a],i!==0&&(B(s)&&H(s)||Array.isArray(s)&&ln(s))&&O(e,r.slice(0,-1)),e}var un=e=>{for(const t in e)if(Z(e[t]))return!0;return!1};function Ut(e){return Array.isArray(e)||B(e)&&!un(e)}function je(e,t={}){for(const r in e){const s=e[r];Ut(s)?(t[r]=Array.isArray(s)?[]:{},je(s,t[r])):D(s)||(t[r]=!0)}return t}function pe(e,t,r){r||(r=je(t));for(const s in e){const i=e[s];if(Ut(i))D(t)||Pe(r[s])?r[s]=je(i,Array.isArray(i)?[]:{}):pe(i,K(t)?{}:t[s],r[s]);else{const a=t[s];r[s]=!ae(i,a)}}return r}const mt={value:!1,isValid:!1},gt={value:!0,isValid:!0};var qt=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(r=>r&&r.checked&&!r.disabled).map(r=>r.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!D(e[0].attributes.value)?D(e[0].value)||e[0].value===""?gt:{value:e[0].value,isValid:!0}:gt:mt}return mt},Ht=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:s})=>D(e)?e:t?e===""?NaN:e&&+e:r&&W(e)?new Date(e):s?s(e):e;const bt={isValid:!1,value:null};var Kt=e=>Array.isArray(e)?e.reduce((t,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:t,bt):bt;function yt(e){const t=e.ref;return Ge(t)?t.files:We(t)?Kt(e.refs).value:$t(t)?[...t.selectedOptions].map(({value:r})=>r):Se(t)?qt(e.refs).value:Ht(D(t.value)?e.ref.value:t.value,e)}var cn=(e,t,r,s)=>{const i={};for(const a of e){const l=k(t,a);l&&N(i,a,l._f)}return{criteriaMode:r,names:[...e],fields:i,shouldUseNativeValidation:s}},Fe=e=>e instanceof RegExp,ve=e=>D(e)?e:Fe(e)?e.source:B(e)?Fe(e.value)?e.value.source:e.value:e,vt=e=>({isOnSubmit:!e||e===X.onSubmit,isOnBlur:e===X.onBlur,isOnChange:e===X.onChange,isOnAll:e===X.all,isOnTouch:e===X.onTouched});const xt="AsyncFunction";var dn=e=>!!e&&!!e.validate&&!!(Z(e.validate)&&e.validate.constructor.name===xt||B(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===xt)),fn=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),wt=(e,t,r)=>!r&&(t.watchAll||t.watch.has(e)||[...t.watch].some(s=>e.startsWith(s)&&/^\.\w+/.test(e.slice(s.length))));const _e=(e,t,r,s)=>{for(const i of r||Object.keys(e)){const a=k(e,i);if(a){const{_f:l,...o}=a;if(l){if(l.refs&&l.refs[0]&&t(l.refs[0],i)&&!s)return!0;if(l.ref&&t(l.ref,l.name)&&!s)return!0;if(_e(o,t))break}else if(B(o)&&_e(o,t))break}}};function kt(e,t,r){const s=k(e,r);if(s||Te(r))return{error:s,name:r};const i=r.split(".");for(;i.length;){const a=i.join("."),l=k(t,a),o=k(e,a);if(l&&!Array.isArray(l)&&r!==a)return{name:r};if(o&&o.type)return{name:a,error:o};if(o&&o.root&&o.root.type)return{name:`${a}.root`,error:o.root};i.pop()}return{name:r}}var hn=(e,t,r,s)=>{r(e);const{name:i,...a}=e;return H(a)||Object.keys(a).length>=Object.keys(t).length||Object.keys(a).find(l=>t[l]===(!s||X.all))},pn=(e,t,r)=>!e||!t||e===t||ke(e).some(s=>s&&(r?s===t:s.startsWith(t)||t.startsWith(s))),mn=(e,t,r,s,i)=>i.isOnAll?!1:!r&&i.isOnTouch?!(t||e):(r?s.isOnBlur:i.isOnBlur)?!e:(r?s.isOnChange:i.isOnChange)?e:!0,gn=(e,t)=>!He(k(e,t)).length&&O(e,t),bn=(e,t,r)=>{const s=ke(k(e,r));return N(s,"root",t[r]),N(e,r,s),e};function _t(e,t,r="validate"){if(W(e)||Array.isArray(e)&&e.every(W)||Y(e)&&!e)return{type:r,message:W(e)?e:"",ref:t}}var fe=e=>B(e)&&!Fe(e)?e:{value:e,message:""},Ct=async(e,t,r,s,i,a)=>{const{ref:l,refs:o,required:f,maxLength:p,minLength:C,min:v,max:h,pattern:b,validate:y,name:V,valueAsNumber:E,mount:x}=e._f,_=k(r,V);if(!x||t.has(V))return{};const A=o?o[0]:l,R=F=>{i&&A.reportValidity&&(A.setCustomValidity(Y(F)?"":F||""),A.reportValidity())},T={},ie=We(l),de=Se(l),ee=ie||de,ne=(E||Ge(l))&&D(l.value)&&D(_)||Ve(l)&&l.value===""||_===""||Array.isArray(_)&&!_.length,j=Pt.bind(null,V,s,T),Ee=(F,I,z,$=re.maxLength,J=re.minLength)=>{const G=F?I:z;T[V]={type:F?$:J,message:G,ref:l,...j(F?$:J,G)}};if(a?!Array.isArray(_)||!_.length:f&&(!ee&&(ne||K(_))||Y(_)&&!_||de&&!qt(o).isValid||ie&&!Kt(o).isValid)){const{value:F,message:I}=W(f)?{value:!!f,message:f}:fe(f);if(F&&(T[V]={type:re.required,message:I,ref:A,...j(re.required,I)},!s))return R(I),T}if(!ne&&(!K(v)||!K(h))){let F,I;const z=fe(h),$=fe(v);if(!K(_)&&!isNaN(_)){const J=l.valueAsNumber||_&&+_;K(z.value)||(F=J>z.value),K($.value)||(I=J<$.value)}else{const J=l.valueAsDate||new Date(_),G=ye=>new Date(new Date().toDateString()+" "+ye),ge=l.type=="time",be=l.type=="week";W(z.value)&&_&&(F=ge?G(_)>G(z.value):be?_>z.value:J>new Date(z.value)),W($.value)&&_&&(I=ge?G(_)<G($.value):be?_<$.value:J<new Date($.value))}if((F||I)&&(Ee(!!F,z.message,$.message,re.max,re.min),!s))return R(T[V].message),T}if((p||C)&&!ne&&(W(_)||a&&Array.isArray(_))){const F=fe(p),I=fe(C),z=!K(F.value)&&_.length>+F.value,$=!K(I.value)&&_.length<+I.value;if((z||$)&&(Ee(z,F.message,I.message),!s))return R(T[V].message),T}if(b&&!ne&&W(_)){const{value:F,message:I}=fe(b);if(Fe(F)&&!_.match(F)&&(T[V]={type:re.pattern,message:I,ref:l,...j(re.pattern,I)},!s))return R(I),T}if(y){if(Z(y)){const F=await y(_,r),I=_t(F,A);if(I&&(T[V]={...I,...j(re.validate,I.message)},!s))return R(I.message),T}else if(B(y)){let F={};for(const I in y){if(!H(F)&&!s)break;const z=_t(await y[I](_,r),A,I);z&&(F={...z,...j(I,z.message)},R(z.message),s&&(T[V]=F))}if(!H(F)&&(T[V]={ref:A,...F},!s))return T}}return R(!0),T};const yn={mode:X.onSubmit,reValidateMode:X.onChange,shouldFocusError:!0};function vn(e={}){let t={...yn,...e},r={submitCount:0,isDirty:!1,isReady:!1,isLoading:Z(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},s={},i=B(t.defaultValues)||B(t.values)?P(t.defaultValues||t.values)||{}:{},a=t.shouldUnregister?{}:P(i),l={action:!1,mount:!1,watch:!1,keepIsValid:!1},o={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},f,p=0;const C={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},v={...C};let h={...v};const b={array:pt(),state:pt()},y=t.criteriaMode===X.all,V=u=>c=>{clearTimeout(p),p=setTimeout(u,c)},E=async u=>{if(!l.keepIsValid&&!t.disabled&&(v.isValid||h.isValid||u)){let c;t.resolver?(c=H((await ee()).errors),x()):c=await j(s,!0),c!==r.isValid&&b.state.next({isValid:c})}},x=(u,c)=>{!t.disabled&&(v.isValidating||v.validatingFields||h.isValidating||h.validatingFields)&&((u||Array.from(o.mount)).forEach(d=>{d&&(c?N(r.validatingFields,d,c):O(r.validatingFields,d))}),b.state.next({validatingFields:r.validatingFields,isValidating:!H(r.validatingFields)}))},_=(u,c=[],d,w,g=!0,m=!0)=>{if(w&&d&&!t.disabled){if(l.action=!0,m&&Array.isArray(k(s,u))){const S=d(k(s,u),w.argA,w.argB);g&&N(s,u,S)}if(m&&Array.isArray(k(r.errors,u))){const S=d(k(r.errors,u),w.argA,w.argB);g&&N(r.errors,u,S),gn(r.errors,u)}if((v.touchedFields||h.touchedFields)&&m&&Array.isArray(k(r.touchedFields,u))){const S=d(k(r.touchedFields,u),w.argA,w.argB);g&&N(r.touchedFields,u,S)}(v.dirtyFields||h.dirtyFields)&&(r.dirtyFields=pe(i,a)),b.state.next({name:u,isDirty:F(u,c),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else N(a,u,c)},A=(u,c)=>{N(r.errors,u,c),b.state.next({errors:r.errors})},R=u=>{r.errors=u,b.state.next({errors:r.errors,isValid:!1})},T=(u,c,d,w)=>{const g=k(s,u);if(g){const m=k(a,u,D(d)?k(i,u):d);D(m)||w&&w.defaultChecked||c?N(a,u,c?m:yt(g._f)):$(u,m),l.mount&&!l.action&&E()}},ie=(u,c,d,w,g)=>{let m=!1,S=!1;const M={name:u};if(!t.disabled){if(!d||w){(v.isDirty||h.isDirty)&&(S=r.isDirty,r.isDirty=M.isDirty=F(),m=S!==M.isDirty);const L=ae(k(i,u),c);S=!!k(r.dirtyFields,u),L?O(r.dirtyFields,u):N(r.dirtyFields,u,!0),M.dirtyFields=r.dirtyFields,m=m||(v.dirtyFields||h.dirtyFields)&&S!==!L}if(d){const L=k(r.touchedFields,u);L||(N(r.touchedFields,u,d),M.touchedFields=r.touchedFields,m=m||(v.touchedFields||h.touchedFields)&&L!==d)}m&&g&&b.state.next(M)}return m?M:{}},de=(u,c,d,w)=>{const g=k(r.errors,u),m=(v.isValid||h.isValid)&&Y(c)&&r.isValid!==c;if(t.delayError&&d?(f=V(()=>A(u,d)),f(t.delayError)):(clearTimeout(p),f=null,d?N(r.errors,u,d):O(r.errors,u)),(d?!ae(g,d):g)||!H(w)||m){const S={...w,...m&&Y(c)?{isValid:c}:{},errors:r.errors,name:u};r={...r,...S},b.state.next(S)}},ee=async u=>(x(u,!0),await t.resolver(a,t.context,cn(u||o.mount,s,t.criteriaMode,t.shouldUseNativeValidation))),ne=async u=>{const{errors:c}=await ee(u);if(x(u),u)for(const d of u){const w=k(c,d);w?N(r.errors,d,w):O(r.errors,d)}else r.errors=c;return c},j=async(u,c,d={valid:!0})=>{for(const w in u){const g=u[w];if(g){const{_f:m,...S}=g;if(m){const M=o.array.has(m.name),L=g._f&&dn(g._f);L&&v.validatingFields&&x([m.name],!0);const q=await Ct(g,o.disabled,a,y,t.shouldUseNativeValidation&&!c,M);if(L&&v.validatingFields&&x([m.name]),q[m.name]&&(d.valid=!1,c||e.shouldUseNativeValidation))break;!c&&(k(q,m.name)?M?bn(r.errors,q,m.name):N(r.errors,m.name,q[m.name]):O(r.errors,m.name))}!H(S)&&await j(S,c,d)}}return d.valid},Ee=()=>{for(const u of o.unMount){const c=k(s,u);c&&(c._f.refs?c._f.refs.every(d=>!Be(d)):!Be(c._f.ref))&&Le(u)}o.unMount=new Set},F=(u,c)=>!t.disabled&&(u&&c&&N(a,u,c),!ae(Je(),i)),I=(u,c,d)=>nn(u,o,{...l.mount?a:D(c)?i:W(u)?{[u]:c}:c},d,c),z=u=>He(k(l.mount?a:i,u,t.shouldUnregister?k(i,u,[]):[])),$=(u,c,d={})=>{const w=k(s,u);let g=c;if(w){const m=w._f;m&&(!m.disabled&&N(a,u,Ht(c,m)),g=Ve(m.ref)&&K(c)?"":c,$t(m.ref)?[...m.ref.options].forEach(S=>S.selected=g.includes(S.value)):m.refs?Se(m.ref)?m.refs.forEach(S=>{(!S.defaultChecked||!S.disabled)&&(Array.isArray(g)?S.checked=!!g.find(M=>M===S.value):S.checked=g===S.value||!!g)}):m.refs.forEach(S=>S.checked=S.value===g):Ge(m.ref)?m.ref.value="":(m.ref.value=g,m.ref.type||b.state.next({name:u,values:P(a)})))}(d.shouldDirty||d.shouldTouch)&&ie(u,g,d.shouldTouch,d.shouldDirty,!0),d.shouldValidate&&ye(u)},J=(u,c,d)=>{for(const w in c){if(!c.hasOwnProperty(w))return;const g=c[w],m=u+"."+w,S=k(s,m);(o.array.has(u)||B(g)||S&&!S._f)&&!le(g)?J(m,g,d):$(m,g,d)}},G=(u,c,d={})=>{const w=k(s,u),g=o.array.has(u),m=P(c);N(a,u,m),g?(b.array.next({name:u,values:P(a)}),(v.isDirty||v.dirtyFields||h.isDirty||h.dirtyFields)&&d.shouldDirty&&b.state.next({name:u,dirtyFields:pe(i,a),isDirty:F(u,m)})):w&&!w._f&&!K(m)?J(u,m,d):$(u,m,d),wt(u,o)?b.state.next({...r,name:u,values:P(a)}):b.state.next({name:l.mount?u:void 0,values:P(a)})},ge=async u=>{l.mount=!0;const c=u.target;let d=c.name,w=!0;const g=k(s,d),m=L=>{w=Number.isNaN(L)||le(L)&&isNaN(L.getTime())||ae(L,k(a,d,L))},S=vt(t.mode),M=vt(t.reValidateMode);if(g){let L,q;const oe=c.type?yt(g._f):Zr(u),se=u.type===ht.BLUR||u.type===ht.FOCUS_OUT,tr=!fn(g._f)&&!t.resolver&&!k(r.errors,d)&&!g._f.deps||mn(se,k(r.touchedFields,d),r.isSubmitted,M,S),De=wt(d,o,se);N(a,d,oe),se?(!c||!c.readOnly)&&(g._f.onBlur&&g._f.onBlur(u),f&&f(0)):g._f.onChange&&g._f.onChange(u);const Oe=ie(d,oe,se),rr=!H(Oe)||De;if(!se&&b.state.next({name:d,type:u.type,values:P(a)}),tr)return(v.isValid||h.isValid)&&(t.mode==="onBlur"?se&&E():se||E()),rr&&b.state.next({name:d,...De?{}:Oe});if(!se&&De&&b.state.next({...r}),t.resolver){const{errors:st}=await ee([d]);if(x([d]),m(oe),w){const nr=kt(r.errors,s,d),at=kt(st,s,nr.name||d);L=at.error,d=at.name,q=H(st)}}else x([d],!0),L=(await Ct(g,o.disabled,a,y,t.shouldUseNativeValidation))[d],x([d]),m(oe),w&&(L?q=!1:(v.isValid||h.isValid)&&(q=await j(s,!0)));w&&(g._f.deps&&(!Array.isArray(g._f.deps)||g._f.deps.length>0)&&ye(g._f.deps),de(d,q,L,Oe))}},be=(u,c)=>{if(k(r.errors,c)&&u.focus)return u.focus(),1},ye=async(u,c={})=>{let d,w;const g=ke(u);if(t.resolver){const m=await ne(D(u)?u:g);d=H(m),w=u?!g.some(S=>k(m,S)):d}else u?(w=(await Promise.all(g.map(async m=>{const S=k(s,m);return await j(S&&S._f?{[m]:S}:S)}))).every(Boolean),!(!w&&!r.isValid)&&E()):w=d=await j(s);return b.state.next({...!W(u)||(v.isValid||h.isValid)&&d!==r.isValid?{}:{name:u},...t.resolver||!u?{isValid:d}:{},errors:r.errors}),c.shouldFocus&&!w&&_e(s,be,u?g:o.mount),w},Je=(u,c)=>{let d={...l.mount?a:i};return c&&(d=jt(c.dirtyFields?r.dirtyFields:r.touchedFields,d)),D(u)?d:W(u)?k(d,u):u.map(w=>k(d,w))},Ze=(u,c)=>({invalid:!!k((c||r).errors,u),isDirty:!!k((c||r).dirtyFields,u),error:k((c||r).errors,u),isValidating:!!k(r.validatingFields,u),isTouched:!!k((c||r).touchedFields,u)}),Wt=u=>{const c=u?ke(u):void 0;c==null||c.forEach(d=>O(r.errors,d)),c?c.forEach(d=>{b.state.next({name:d,errors:r.errors})}):b.state.next({errors:{}})},Xe=(u,c,d)=>{const w=(k(s,u,{_f:{}})._f||{}).ref,g=k(r.errors,u)||{},{ref:m,message:S,type:M,...L}=g;N(r.errors,u,{...L,...c,ref:w}),b.state.next({name:u,errors:r.errors,isValid:!1}),d&&d.shouldFocus&&w&&w.focus&&w.focus()},Jt=(u,c)=>Z(u)?b.state.subscribe({next:d=>"values"in d&&u(I(void 0,c),d)}):I(u,c,!0),Ye=u=>b.state.subscribe({next:c=>{pn(u.name,c.name,u.exact)&&hn(c,u.formState||v,er,u.reRenderRoot)&&u.callback({values:{...a},...r,...c,defaultValues:i})}}).unsubscribe,Zt=u=>(l.mount=!0,h={...h,...u.formState},Ye({...u,formState:{...C,...u.formState}})),Le=(u,c={})=>{for(const d of u?ke(u):o.mount)o.mount.delete(d),o.array.delete(d),c.keepValue||(O(s,d),O(a,d)),!c.keepError&&O(r.errors,d),!c.keepDirty&&O(r.dirtyFields,d),!c.keepTouched&&O(r.touchedFields,d),!c.keepIsValidating&&O(r.validatingFields,d),!t.shouldUnregister&&!c.keepDefaultValue&&O(i,d);b.state.next({values:P(a)}),b.state.next({...r,...c.keepDirty?{isDirty:F()}:{}}),!c.keepIsValid&&E()},Qe=({disabled:u,name:c})=>{if(Y(u)&&l.mount||u||o.disabled.has(c)){const g=o.disabled.has(c)!==!!u;u?o.disabled.add(c):o.disabled.delete(c),g&&l.mount&&!l.action&&E()}},Ne=(u,c={})=>{let d=k(s,u);const w=Y(c.disabled)||Y(t.disabled);return N(s,u,{...d||{},_f:{...d&&d._f?d._f:{ref:{name:u}},name:u,mount:!0,...c}}),o.mount.add(u),d?Qe({disabled:Y(c.disabled)?c.disabled:t.disabled,name:u}):T(u,!0,c.value),{...w?{disabled:c.disabled||t.disabled}:{},...t.progressive?{required:!!c.required,min:ve(c.min),max:ve(c.max),minLength:ve(c.minLength),maxLength:ve(c.maxLength),pattern:ve(c.pattern)}:{},name:u,onChange:ge,onBlur:ge,ref:g=>{if(g){Ne(u,c),d=k(s,u);const m=D(g.value)&&g.querySelectorAll&&g.querySelectorAll("input,select,textarea")[0]||g,S=an(m),M=d._f.refs||[];if(S?M.find(L=>L===m):m===d._f.ref)return;N(s,u,{_f:{...d._f,...S?{refs:[...M.filter(Be),m,...Array.isArray(k(i,u))?[{}]:[]],ref:{type:m.type,name:u}}:{ref:m}}}),T(u,!1,void 0,m)}else d=k(s,u,{}),d._f&&(d._f.mount=!1),(t.shouldUnregister||c.shouldUnregister)&&!(Yr(o.array,u)&&l.action)&&o.unMount.add(u)}}},Re=()=>t.shouldFocusError&&_e(s,be,o.mount),Xt=u=>{Y(u)&&(b.state.next({disabled:u}),_e(s,(c,d)=>{const w=k(s,d);w&&(c.disabled=w._f.disabled||u,Array.isArray(w._f.refs)&&w._f.refs.forEach(g=>{g.disabled=w._f.disabled||u}))},0,!1))},et=(u,c)=>async d=>{let w;d&&(d.preventDefault&&d.preventDefault(),d.persist&&d.persist());let g=P(a);if(b.state.next({isSubmitting:!0}),t.resolver){const{errors:m,values:S}=await ee();x(),r.errors=m,g=P(S)}else await j(s);if(o.disabled.size)for(const m of o.disabled)O(g,m);if(O(r.errors,"root"),H(r.errors)){b.state.next({errors:{}});try{await u(g,d)}catch(m){w=m}}else c&&await c({...r.errors},d),Re(),setTimeout(Re);if(b.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:H(r.errors)&&!w,submitCount:r.submitCount+1,errors:r.errors}),w)throw w},Yt=(u,c={})=>{k(s,u)&&(D(c.defaultValue)?G(u,P(k(i,u))):(G(u,c.defaultValue),N(i,u,P(c.defaultValue))),c.keepTouched||O(r.touchedFields,u),c.keepDirty||(O(r.dirtyFields,u),r.isDirty=c.defaultValue?F(u,P(k(i,u))):F()),c.keepError||(O(r.errors,u),v.isValid&&E()),b.state.next({...r}))},tt=(u,c={})=>{const d=u?P(u):i,w=P(d),g=H(u),m=g?i:w;if(c.keepDefaultValues||(i=d),!c.keepValues){if(c.keepDirtyValues){const S=new Set([...o.mount,...Object.keys(pe(i,a))]);for(const M of Array.from(S)){const L=k(r.dirtyFields,M),q=k(a,M),oe=k(m,M);L&&!D(q)?N(m,M,q):!L&&!D(oe)&&G(M,oe)}}else{if(qe&&D(u))for(const S of o.mount){const M=k(s,S);if(M&&M._f){const L=Array.isArray(M._f.refs)?M._f.refs[0]:M._f.ref;if(Ve(L)){const q=L.closest("form");if(q){q.reset();break}}}}if(c.keepFieldsRef)for(const S of o.mount)G(S,k(m,S));else s={}}a=t.shouldUnregister?c.keepDefaultValues?P(i):{}:P(m),b.array.next({values:{...m}}),b.state.next({values:{...m}})}o={mount:c.keepDirtyValues?o.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},l.mount=!v.isValid||!!c.keepIsValid||!!c.keepDirtyValues||!t.shouldUnregister&&!H(m),l.watch=!!t.shouldUnregister,l.keepIsValid=!!c.keepIsValid,l.action=!1,c.keepErrors||(r.errors={}),b.state.next({submitCount:c.keepSubmitCount?r.submitCount:0,isDirty:g?!1:c.keepDirty?r.isDirty:!!(c.keepDefaultValues&&!ae(u,i)),isSubmitted:c.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:g?{}:c.keepDirtyValues?c.keepDefaultValues&&a?pe(i,a):r.dirtyFields:c.keepDefaultValues&&u?pe(i,u):c.keepDirty?r.dirtyFields:{},touchedFields:c.keepTouched?r.touchedFields:{},errors:c.keepErrors?r.errors:{},isSubmitSuccessful:c.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:i})},rt=(u,c)=>tt(Z(u)?u(a):u,{...t.resetOptions,...c}),Qt=(u,c={})=>{const d=k(s,u),w=d&&d._f;if(w){const g=w.refs?w.refs[0]:w.ref;g.focus&&setTimeout(()=>{g.focus(),c.shouldSelect&&Z(g.select)&&g.select()})}},er=u=>{r={...r,...u}},nt={control:{register:Ne,unregister:Le,getFieldState:Ze,handleSubmit:et,setError:Xe,_subscribe:Ye,_runSchema:ee,_updateIsValidating:x,_focusError:Re,_getWatch:I,_getDirty:F,_setValid:E,_setFieldArray:_,_setDisabledField:Qe,_setErrors:R,_getFieldArray:z,_reset:tt,_resetDefaultValues:()=>Z(t.defaultValues)&&t.defaultValues().then(u=>{rt(u,t.resetOptions),b.state.next({isLoading:!1})}),_removeUnmounted:Ee,_disableForm:Xt,_subjects:b,_proxyFormState:v,get _fields(){return s},get _formValues(){return a},get _state(){return l},set _state(u){l=u},get _defaultValues(){return i},get _names(){return o},set _names(u){o=u},get _formState(){return r},get _options(){return t},set _options(u){t={...t,...u}}},subscribe:Zt,trigger:ye,register:Ne,handleSubmit:et,watch:Jt,setValue:G,getValues:Je,reset:rt,resetField:Yt,clearErrors:Wt,unregister:Le,setError:Xe,setFocus:Qt,getFieldState:Ze};return{...nt,formControl:nt}}function Ie(e={}){const t=n.Cn.useRef(void 0),r=n.Cn.useRef(void 0),[s,i]=n.Cn.useState({isDirty:!1,isValidating:!1,isLoading:Z(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:Z(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:s},e.defaultValues&&!Z(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:l,...o}=vn(e);t.current={...o,formState:s}}const a=t.current.control;return a._options=e,rn(()=>{const l=a._subscribe({formState:a._proxyFormState,callback:()=>i({...a._formState}),reRenderRoot:!0});return i(o=>({...o,isReady:!0})),a._formState.isReady=!0,l},[a]),n.Cn.useEffect(()=>a._disableForm(e.disabled),[a,e.disabled]),n.Cn.useEffect(()=>{e.mode&&(a._options.mode=e.mode),e.reValidateMode&&(a._options.reValidateMode=e.reValidateMode)},[a,e.mode,e.reValidateMode]),n.Cn.useEffect(()=>{e.errors&&(a._setErrors(e.errors),a._focusError())},[a,e.errors]),n.Cn.useEffect(()=>{e.shouldUnregister&&a._subjects.state.next({values:a._getWatch()})},[a,e.shouldUnregister]),n.Cn.useEffect(()=>{if(a._proxyFormState.isDirty){const l=a._getDirty();l!==s.isDirty&&a._subjects.state.next({isDirty:l})}},[a,s.isDirty]),n.Cn.useEffect(()=>{var l;e.values&&!ae(e.values,r.current)?(a._reset(e.values,{keepFieldsRef:!0,...a._options.resetOptions}),!((l=a._options.resetOptions)===null||l===void 0)&&l.keepIsValid||a._setValid(),r.current=e.values,i(o=>({...o}))):a._resetDefaultValues()},[a,e.values]),n.Cn.useEffect(()=>{a._state.mount||(a._setValid(),a._state.mount=!0),a._state.watch&&(a._state.watch=!1,a._subjects.state.next({...a._formState})),a._removeUnmounted()}),t.current.formState=n.Cn.useMemo(()=>tn(s,a),[a,s]),t.current}const St=(e,t,r)=>{if(e&&"reportValidity"in e){const s=k(r,t);e.setCustomValidity(s&&s.message||""),e.reportValidity()}},xn=(e,t)=>{for(const r in t.fields){const s=t.fields[r];s&&s.ref&&"reportValidity"in s.ref?St(s.ref,r,e):s.refs&&s.refs.forEach(i=>St(i,r,e))}},wn=(e,t)=>{t.shouldUseNativeValidation&&xn(e,t);const r={};for(const s in e){const i=k(t.fields,s),a=Object.assign(e[s]||{},{ref:i&&i.ref});if(kn(t.names||Object.keys(e),s)){const l=Object.assign({},k(r,s));N(l,"root",a),N(r,s,l)}else N(r,s,a)}return r},kn=(e,t)=>e.some(r=>r.startsWith(t+"."));var Me=function(e,t,r){return r===void 0&&(r={}),function(s,i,a){try{var l=!a.shouldUseNativeValidation&&a.criteriaMode==="all";return Promise.resolve(n.safeParseAsync(e,s,Object.assign({},t,{abortPipeEarly:!l}))).then(function(o){if(o.issues){for(var f={};o.issues.length;){var p=o.issues[0],C=n.getDotPath(p);if(C&&(f[C]||(f[C]={message:p.message,type:p.type}),l)){var v=f[C].types,h=v&&v[p.type];f[C]=Pt(C,l,f,p.type,h?[].concat(h,p.message):p.message)}o.issues.shift()}return{values:{},errors:wn(f,a)}}return{values:r.raw?s:o.output,errors:{}}})}catch(o){return Promise.reject(o)}}};const Et=27,Vt=12,Ft=10,_n=n.isSubmissionOfType("enum"),Cn=(e,t)=>{const r={min:e.minSelected??0,max:e.maxSelected??e.options.length};return Me(n.object({checked:n.pipe(n.record(n.string(),n.boolean()),n.transform(s=>Object.entries(s).filter(([i,a])=>a).map(([i,a])=>i)),n.maxLength(r.max,t("validation_multiple_choice_max",{count:r.max})),n.minLength(r.min,t("validation_multiple_choice_min",{count:r.min})))}))},Sn=n.k$1(({option:e,...t},r)=>n.o(n.k,{children:[n.o("input",{class:"peer sr-only h-full",type:"checkbox",...t,ref:r}),n.o("label",{class:"bg-lowest hover:bg-neutral-2 active:outline-neutral-8 ease-expo-out outline-divider text-neutral-11 peer-checked:outline-accent-7 peer-checked:bg-accent-2 peer-checked:text-accent-9 peer-focus-visible:ring-accent-9 peer-focus-visible:ring-offset-accent-7 block cursor-pointer select-none rounded-2xl px-3 py-1.5 outline outline-1 ring-0 ring-transparent transition-all selection:bg-transparent peer-focus-visible:ring-4",htmlFor:t.id,children:e.label})]})),At=n.cva("gutter-stable flex w-full flex-1 flex-wrap gap-2 overflow-y-auto rounded-xl p-2.5 pr-4",{variants:{variant:{singleOption:"justify-center",booleanLike:Rt}}}),En=({input:e,onSubmitSuccess:t})=>{var C,v;const r=e.key?(C=n.store.current$.value.flow)==null?void 0:C.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}=n.useTranslation(),{register:l,handleSubmit:o,formState:{errors:f}}=Ie({defaultValues:{checked:s?{}:_n(r)?Object.fromEntries(r.value.map(h=>[h,!0])):{}},resolver:Cn(e.config,a)}),p=Ue();return i?n.o("ul",{style:{maxHeight:6.5*Et+5*Vt+2*Ft},class:At({variant:"booleanLike"}),children:e.config.options.map((h,b)=>n.o("li",{class:Dt,children:n.o(Ot,{type:"submit",ref:y=>{y&&b===0&&(p.current=y)},label:h.label,value:"true",onClick:()=>t({type:"enum",value:[h.value]})})},h.value))}):n.o("form",{noValidate:!0,onSubmit:h=>o(b=>{const y=b.checked;t({type:"enum",value:y})})(h),children:[n.o("div",{class:"flex items-center gap-1",children:[n.o("ul",{style:{maxHeight:6.5*Et+5*Vt+2*Ft},class:At({variant:e.config.options.length===1?"singleOption":void 0}),children:e.config.options.map((h,b)=>{const y=`checked.${h.value}`,{ref:V,...E}=l(y);return n.o("li",{class:"relative",children:n.o(Sn,{option:h,autoFocus:b===0,ref:x=>{x&&b===0&&(p.current=x),V(x)},id:y,...E,onClick:s?()=>t({type:"enum",value:[h.value]}):void 0})},h.value)})}),n.o("div",{class:"flex flex-col items-center gap-2 pr-2.5 pt-2.5",children:[s?null:n.o(ue,{}),e.config.minSelected===0&&n.o(ce,{class:"relative",type:"button",onClick:()=>t({type:"enum",value:[]})})]})]}),n.o("div",{class:"px-1",children:n.o(me,{error:(v=f.checked)==null?void 0:v.root})})]})},Vn=n.isSubmissionOfType("number"),Fn=(e,t)=>{const r=e.min??Number.MIN_SAFE_INTEGER,s=e.max??Number.MAX_SAFE_INTEGER,i=e.decimalCases??0;return Me(n.object({number:n.pipe(n.number(t("validation_number")),n.minValue(r,t("validation_number_min",{min:r})),n.maxValue(s,t("validation_number_max",{max:s})),n.check(a=>a===Number(a.toFixed(i)),t("validation_number_decimal_cases",{count:i})))}))},An=({input:e,onSubmitSuccess:t})=>{var v;const r=e.config.defaultValue,s=e.key?(v=n.store.current$.value.flow)==null?void 0:v.data.submissions[e.key]:void 0,{t:i}=n.useTranslation(),{register:a,handleSubmit:l,formState:{errors:o}}=Ie({defaultValues:{number:r?Number(r):Vn(s)?s.value:void 0},resolver:Fn(e.config,i)}),{ref:f,...p}=a("number",{required:!e.config.optional,valueAsNumber:!0}),C=n._();return n.y(()=>{C.current&&(C.current.focus(),C.current.select())},[]),n.o("form",{class:"flex flex-col gap-1 p-2.5",onSubmit:l(h=>{h.number!==void 0&&t({type:"number",value:h.number})}),children:[n.o("div",{class:"flex items-center gap-2",children:[n.o("div",{class:"relative min-w-0 flex-grow",children:[n.o("input",{...p,id:"chat-input",autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:h=>{h&&(C.current=h),f(h)},type:"text",min:e.config.min,max:e.config.max,class:Ce({optional:e.config.optional,className:"[type=number:-webkit-inner-spin-button] w-full rounded-full [-webkit-outer-spin-button:none]"}),placeholder:e.config.placeholder}),e.config.optional&&n.o(ce,{class:"absolute bottom-0 right-0.5 top-0",onClick:()=>t(null)})]}),n.o(ue,{})]}),n.o(me,{error:o.number})]})},Tn=e=>{if(e==="")return{countryCode:"",phoneNumber:""};const t=Object.entries($e).find(i=>e.startsWith(i[1])),r=t?t[1]:"",s=e.replace(r,"");return/^\d+$/.test(s)?{countryCode:r,phoneNumber:s}:{countryCode:"",phoneNumber:""}},In="44",Mn=/^[0-9 ]+$/,Ln=n.isSubmissionOfType("string"),Nn=n.isSubmissionOfType("phone"),Rn=e=>{const t=n.pipe(n.string(e("validation_country_code")),n.regex(Mn,e("validation_country_code"))),r=n.pipe(n.string(e("validation_phone")),n.minLength(1,e("validation_phone")),n.transform(s=>s.replace(/[^0-9]/g,"")));return Me(n.object({countryCode:t,phoneNumber:r}))},Dn=({input:e,onSubmitSuccess:t})=>{var V;const r=e.key?(V=n.store.current$.value.flow)==null?void 0:V.data.submissions[e.key]:void 0,{t:s}=n.useTranslation(),[i,a]=n.h(),l=Ln(r)?Tn(r.value):Nn(r)?r.value:void 0,{register:o,handleSubmit:f,formState:{errors:p},watch:C}=Ie({defaultValues:{countryCode:(l==null?void 0:l.countryCode)??e.config.defaultValue.countryCode??In,phoneNumber:(l==null?void 0:l.phoneNumber)??e.config.defaultValue.phoneNumber??""},resolver:Rn(s)}),{ref:v,...h}=o("phoneNumber",{required:!e.config.optional}),b=n._(),y=C("countryCode");return n.y(()=>{b.current&&(b.current.focus(),b.current.select())},[]),n.o("form",{noValidate:!0,class:"flex flex-col gap-1 p-2.5",onSubmit:f(E=>{const x=E.phoneNumber.replace(/[^0-9]/g,""),_=E.countryCode.replace(/[^0-9]/g,"");a(void 0);const A=e.config.minChars??7,R=x.length+_.length;if(R<A)return a(s("validation_phone_min_chars",{count:A}));const T=e.config.maxChars;if(T!=null&&R>T)return a(s("validation_max_chars",{count:T}));e.config.submissionFormat==="phone"?t({type:"phone",value:{countryCode:_,phoneNumber:x}}):t({type:"string",value:y+E.phoneNumber})}),children:[n.o("div",{class:"flex items-center gap-2",children:[n.o("div",{class:"relative flex min-w-0 flex-1 flex-grow gap-2",children:[n.o("label",{class:"text-neutral-12 bg-lowest hover:bg-neutral-5 placeholder:text-neutral-8 focus-visible:outline-accent-7 focus-within:bg-neutral-5 focus-within:outline-accent-7 outline-divider relative flex h-full cursor-pointer appearance-none items-center justify-center overflow-hidden text-ellipsis whitespace-nowrap rounded-l-full border-solid px-3 py-1.5 text-center text-base outline outline-2 transition-all focus-within:outline-none",htmlFor:`isdk_phone_${e.key}`,children:[n.o("span",{children:["+",y]}),n.o("select",{...o("countryCode",{}),id:`isdk_phone_${e.key}`,class:"absolute inset-0 opacity-0",children:Object.entries($e).map(([E,x])=>n.o("option",{value:x,children:[E," (+",x,")"]},E))})]}),n.o("input",{...h,id:"chat-input",type:"tel",inputMode:"tel",autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:E=>{E&&(b.current=E),v(E)},class:Ce({optional:e.config.optional,className:"min-w-0 flex-1 rounded-r-full"}),placeholder:e.config.placeholder}),e.config.optional&&n.o(ce,{class:"absolute bottom-0 right-1 top-0",onClick:()=>t(null)})]}),n.o(ue,{})]}),n.o(me,{error:p.countryCode||p.phoneNumber||{message:i}})]})},On=({input:e,onSubmitSuccess:t})=>n.o("div",{class:"flex flex-col items-center py-3",children:n.o("button",{class:"bg-accent-9 hover:bg-accent-10 active:bg-submit-bg-active hover:border-accent-10 active:border-submit-bg-active border-accent-9 ring-accent-6 focus-visible:outline-accent-8 ring-offset-neutral-1 flex cursor-pointer rounded-full border border-solid px-5 py-3 pr-4 text-white outline-none ring-1 ring-offset-[1.5px] transition-all duration-300 focus-visible:outline-2 active:ring-2 active:ring-offset-2",name:e.key,onClick:()=>{t(null)},children:n.o("span",{class:"flex items-center gap-1.5",children:[n.o("span",{class:"inline-flex items-center text-sm font-medium",children:e.config.label||"Submit"}),n.o("svg",{stroke:"currentColor","stroke-width":"1.5",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.o("path",{d:"M4 8L8 4L12 8"}),n.o("path",{d:"M8 4V13"})]})]})})}),Bn={date:{type:"date",inputMode:"text"},email:{type:"email",inputMode:"email",formNoValidate:!0},text:{type:"text",inputMode:"text"},url:{type:"url",inputMode:"url",formNoValidate:!0}},zn=n.isSubmissionOfType("string"),Pn=(e,t)=>{const r={maxLength:t("validation_max_chars",{count:e.maxChars??999}),minLength:t("validation_min_chars",{count:e.minChars??1})};return Me(n.object({text:{date:n.pipe(n.string(t("validation_date")),n.regex(/^\d{4}-\d{2}-\d{2}$/,t("validation_date"))),email:n.pipe(n.string(t("validation_email")),n.email(t("validation_email")),n.minLength(e.minChars??1,r.minLength),n.maxLength(e.maxChars??1/0,r.maxLength)),text:n.pipe(n.string(),n.minLength(e.minChars??1,r.minLength),n.maxLength(e.maxChars??1/0,r.maxLength)),url:n.pipe(n.string(t("validation_url")),n.url(t("validation_url")),n.minLength(e.minChars??1,r.minLength),n.maxLength(e.maxChars??1/0,r.maxLength))}[e.format]}))},jn=({input:e,onSubmitSuccess:t})=>{var v;const{t:r}=n.useTranslation(),s=e.key?(v=n.store.current$.value.flow)==null?void 0:v.data.submissions[e.key]:void 0,i=e.config.defaultValue,{register:a,handleSubmit:l,formState:{errors:o}}=Ie({defaultValues:{text:i||(zn(s)?s.value:"")},resolver:Pn(e.config,r)}),{ref:f,...p}=a("text",{required:!e.config.optional}),C=n._();return n.y(()=>{C.current&&(C.current.focus(),C.current.select())},[]),n.o("form",{noValidate:!0,class:"flex flex-col gap-1 p-2.5",onSubmit:l(h=>{t({type:"string",value:h.text})}),children:[n.o("div",{class:"flex items-center gap-2",children:[n.o("div",{class:"relative min-w-0 flex-1",children:[n.o("input",{id:"chat-input",...p,...Bn[e.config.format],autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:h=>{h&&(C.current=h),f(h)},placeholder:e.config.placeholder,class:Ce({optional:!!e.config.optional,className:"w-full rounded-full"})}),e.config.optional&&n.o(ce,{class:"absolute bottom-0 right-0.5 top-0",onClick:()=>t(null)})]}),n.o(ue,{})]}),n.o(me,{error:o.text})]})},$n={text:jn,phone:Dn,"multiple-choice":En,boolean:$r,file:Jr,submit:On,address:Br,number:An},Un=({logger:e})=>{var a;const t=(a=n.store.current$.value.flow)==null?void 0:a.data.currentInput,[r,s]=Er(),i=n._(null);return n.store.inputHeight$.value=s.height,n.p(()=>{const l=i.current;if(l)return l.addEventListener("transitionstart",U.scrollToEnd.smooth),l.addEventListener("transitioncancel",U.scrollToEnd.smooth),l.addEventListener("transitionend",U.scrollToEnd.smooth),()=>{l.removeEventListener("transitionstart",U.scrollToEnd.smooth),l.removeEventListener("transitioncancel",U.scrollToEnd.smooth),l.removeEventListener("transitionend",U.scrollToEnd.smooth)}},[]),n.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:n.o("div",{ref:r,class:"border-divider flex flex-col justify-end border-t",children:t?(()=>{const l=$n[t.type];return n.o(l,{logger:e,onSubmitSuccess:U.onSubmitSuccessFn$.value,input:t})})():n.o("div",{class:"flex items-center gap-2 p-2.5",children:[n.o("input",{"aria-hidden":"true",id:"chat-input",class:Ce({optional:!1,className:"flex-grow rounded-full"}),disabled:!0}),n.o(ue,{disabled:!0,"aria-hidden":"true",tabIndex:-1})]})})})};var qn=function(e){return e instanceof RegExp},Hn=function(t){var r=/[\\^$.*+?()[\]{}|]/g,s=RegExp(r.source);return t&&s.test(t)?t.replace(r,"\\$&"):t},Gt=function(e){return typeof e=="string"},Kn=function(e){var t=[];return e.forEach(function(r){Array.isArray(r)?t=t.concat(r):t.push(r)}),t};function Gn(e,t,r){var s=0,i=0;if(e==="")return e;if(!e||!Gt(e))throw new TypeError("First argument to react-string-replace#replaceString must be a string");var a=t;qn(a)||(a=new RegExp("("+Hn(a)+")","gi"));for(var l=e.split(a),o=1,f=l.length;o<f;o+=2){if(l[o]===void 0||l[o-1]===void 0){console.warn("reactStringReplace: Encountered undefined value during string replacement. Your RegExp may not be working the way you expect.");continue}i=l[o].length,s+=l[o-1].length,l[o]=r(l[o],o,s),s+=i}return l}var Wn=function(t,r,s){return Array.isArray(t)||(t=[t]),Kn(t.map(function(i){return Gt(i)?Gn(i,r,s):i}))};const xe=n.getDefaultExportFromCjs(Wn),Jn=/(\[[^\]]+\]\([^)]+\))/g,Zn=/\[([^\]]+)\]\(([^)]+)\)/,Xn=/(https?:\/\/[^\s]+)/g,Yn=/_(.*?)_/g,Qn=/\*\*(.*?)\*\*/g,es=/\\n|\n/g,Tt="text-accent-10 hover:text-accent-11 no-underline underline-offset-2 hover:underline",ts=e=>{const t=xe(e,Jn,(l,o)=>{const[,f,p]=l.match(Zn)??[];return p?n.o("a",{class:Tt,href:p,children:f??p},p+o):n.o("span",{children:"INVALID LINK"})}),r=xe(t,Xn,(l,o)=>n.o("a",{class:Tt,href:l,children:l},l+o)),s=xe(r,Yn,(l,o)=>n.o("em",{children:l},l+o)),i=xe(s,Qn,(l,o)=>n.o("strong",{children:l},l+o));return xe(i,es,(l,o)=>n.o("br",{},`br-${o}`))},rs=n.cva("select-text max-w-[min(100%,24rem)] [text-wrap:pretty] leading-snug flex-shrink min-w-[2rem] py-2 px-3 rounded-[18px] min-h-[36px] break-words relative",{variants:{side:{left:"bg-bubble-weak-bg text-neutral-12 shadow-surface-sm outline outline-1 outline-bubble-weak rounded-bl-md",right:"ml-auto bg-accent-9 text-white rounded-br-md shadow-surface-sm shadow-bubble-strong-shadow"},animate:{true:"animate-bubble-in",false:""}},defaultVariants:{side:"left"}}),ns=({children:e,className:t,animate:r,side:s,...i})=>n.o("p",{style:{transformOrigin:s==="left"?"0% 50%":"100% 50%"},class:rs({className:t,side:s,animate:r}),...i,children:e}),ss=({message:e})=>n.o("div",{class:"bg-accent-3 flex w-full items-center justify-center overflow-hidden rounded-xl px-2 py-2",children:n.o("a",{onClick:e.onClick,class:"bg-lowest shadow-surface-sm ring-accent-6 hover:ring-accent-8 active:bg-accent-2 active:text-accent-10 text-accent-9 focus-visible:ring-accent-7/50 text-wrap-balance flex items-center gap-1.5 rounded-full py-2 pl-4 pr-2.5 text-center no-underline ring-1 transition-all focus:outline-none focus-visible:ring-4 focus-visible:ring-offset-2",target:"_blank",href:e.href,children:[e.text,n.o("svg",{class:"flex-none",width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:n.o("path",{d:"M3.64645 11.3536C3.45118 11.1583 3.45118 10.8417 3.64645 10.6465L10.2929 4L6 4C5.72386 4 5.5 3.77614 5.5 3.5C5.5 3.22386 5.72386 3 6 3L11.5 3C11.6326 3 11.7598 3.05268 11.8536 3.14645C11.9473 3.24022 12 3.36739 12 3.5L12 9.00001C12 9.27615 11.7761 9.50001 11.5 9.50001C11.2239 9.50001 11 9.27615 11 9.00001V4.70711L4.35355 11.3536C4.15829 11.5488 3.84171 11.5488 3.64645 11.3536Z",fill:"currentColor","fill-rule":"evenodd","clip-rule":"evenodd"})})]})}),as=({className:e,...t})=>(n.p(()=>{U.scrollToEnd.smooth()}),n.o("div",{"aria-hidden":!0,children:U.isBotTyping$.value===!0?n.o("div",{"aria-label":"Typing…",class:n.clsx("flex gap-1 p-4",e),...t,children:Array.from({length:3},(r,s)=>n.o("div",{class:"bg-accent-9 h-1.5 w-1.5 animate-bounce rounded-full",style:{animationDelay:`${-s*200}ms`}}))}):void 0})),is={bot:"left",user:"right"},os=n.cva("w-full select-none py-2 text-wrap-balance text-center text-[10px] uppercase tracking-widest drop-shadow-[0_1.5px_var(--i-color-n-1)]",{variants:{variant:{info:"text-neutral-8",warning:"text-[#FFC107]",error:"text-error-9",success:"text-[#4CAF50]"}}}),ls=({lastSentMessageFooter:e})=>{var r;const t=((r=n.store.current$.value.flow)==null?void 0:r.data.messages)??[];return n.p(()=>{U.scrollToEnd.smooth()},[t.length]),n.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:[t.map((s,i)=>n.o(n.k,{children:n.o("li",{class:"flex",children:n.M(s).with({type:"system"},a=>n.o("p",{class:os({variant:a.variant}),children:a.text})).with({type:"text",author:n.z.union("bot","user")},a=>{const l=a.author==="user"&&!t.slice(i+1).some(p=>p.type==="text"&&p.author==="user"),o=i===t.length-1,f=a.author==="bot"?ts(a.text):a.text;return n.o(n.k,{children:[l?e:null,n.o(ns,{animate:o,side:is[a.author],children:f},i)]})}).with({type:"link"},a=>n.o(ss,{message:a})).with({type:"image"},a=>n.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=>n.o(Kr,{class:a.author==="bot"?void 0:"ml-auto",file:{name:a.fileName,sizeKb:a.fileSizeKb}})).with({type:"loading"},a=>{const l=t[t.length-1];return!(a===l)||U.isBotTyping$.value?null:n.o("div",{class:"flex flex-grow flex-col items-center justify-center",children:n.o(n.LoadingIndicator,{class:"text-neutral-6 h-8 w-8"})})}).exhaustive()})},i)),n.o(as,{},"typing")]})},us=({logger:e,apiClient:t,analytics:r,platformClient:s})=>{const{flow:i}=n.store.current$.value;n.invariant(i,"Flow is required to exist to show chatbot body");const a=n.store.viewState$.value,{chatRef:l,chatService:o}=Mr(),{t:f}=n.useTranslation(),[p,C]=n.h();return n.y(()=>{a==="maximised"&&U.scrollToEnd.instant()},[a]),n.y(()=>{var x,_;const{state:v,flow:h}=n.store.current$.peek();if(v!=="loaded")throw new Error(f("invalid_state"));let b=h.data.nodeHistory.at(-1);if(U.scrollToEnd.instant(),n.store.setInput(void 0),h.data.isFinished)return;b===void 0?(b=n.getHeadOrThrow(i.nodes).id,n.store.setCurrentNodeId(b),r.log({event:"FLOW_START",properties:{flow_id:i.id,flow_version:i.version,flow_session_id:h.data.flowSessionId,flow_build:i.build,job:i.job},customProperties:(x=i.analytics)==null?void 0:x.customProperties})):n.store.removeMessagesSentByNodeIds([b]);const{interpret:y,abort:V,undo:E}=ir({context:i.context,analytics:{service:r,customProperties:(_=i.analytics)==null?void 0:_.customProperties},apiClient:t,logger:e,platformClient:s,flow:i,chatService:o,t:f,getSubmissions:()=>{var A;return(A=n.store.current$.peek().flow)==null?void 0:A.data.submissions},onInterpret:A=>n.store.setCurrentNodeId(A.id),onFlowEnd:async()=>{var R;n.store.markAsFinished();const A=n.store.current$.peek().flow;n.invariant(A),r.log({event:"FLOW_END",properties:{flow_id:i.id,flow_version:i.version,flow_session_id:A.data.flowSessionId,flow_build:i.build,job:i.job},customProperties:(R=i.analytics)==null?void 0:R.customProperties})}});return C(()=>E),y(b),V},[r,t,o,e,i,s,f]),n.o(n.k,{children:[n.o("div",{ref:l,className:"hide-scrollbars relative flex w-full max-w-full flex-grow flex-col overflow-y-scroll",style:{WebkitOverflowScrolling:"touch",paddingBottom:n.store.inputHeight$.value},children:n.o(ls,{lastSentMessageFooter:i.data.isFinished||!p?null:n.o(ds,{undoFn:p})})}),n.o(Un,{logger:e})]})},cs=e=>e.type==="identify"?[]:"key"in e.data&&e.data.key?[e.data.key]:"keys"in e.data?Object.values(e.data.keys).filter(t=>typeof t=="string"):[],ds=({undoFn:e})=>{const{t}=n.useTranslation();return n.o(n.SvgIconButton,{onClick:async()=>{const{flow:r}=n.store.current$.peek();n.invariant(r);const{removed:s}=e(r.data.nodeHistory),i=r.data.nodeHistory.splice(-s);i.length!==0&&(n.store.removeMessagesSentByNodeIds(i),n.store.setInput(void 0),i.pop(),i.map(a=>r.nodes.find(l=>l.id===a)).filter(Boolean).flatMap(cs).forEach(a=>delete r.data.submissions[a]),n.store.current$.value={...n.store.current$.value})},children:[n.o("title",{children:t("undo")}),n.o("path",{d:"M3 13h2.67l6.66-6.67a1.9 1.9 0 0 0 0-2.66 1.91 1.91 0 0 0-2.66 0L3 10.33V13Zm4.6-7.25 2.67 2.67"})]})};exports.ChatbotBody=us;
|
package/dist/chatbot.api.d.ts
CHANGED
|
@@ -219,6 +219,16 @@ export declare const FlowSchema: import('valibot').ObjectSchema<{
|
|
|
219
219
|
};
|
|
220
220
|
isHead?: boolean | undefined;
|
|
221
221
|
nextId?: string | undefined;
|
|
222
|
+
} | {
|
|
223
|
+
type: "check-duplicate";
|
|
224
|
+
id: string;
|
|
225
|
+
data: {
|
|
226
|
+
key: string;
|
|
227
|
+
email: string;
|
|
228
|
+
scope: "job" | "company";
|
|
229
|
+
};
|
|
230
|
+
isHead?: boolean | undefined;
|
|
231
|
+
nextId?: string | undefined;
|
|
222
232
|
} | {
|
|
223
233
|
type: "feedback";
|
|
224
234
|
id: string;
|
|
@@ -444,6 +454,16 @@ export declare const FlowByIdPayloadSchema: import('valibot').ObjectSchema<{
|
|
|
444
454
|
};
|
|
445
455
|
isHead?: boolean | undefined;
|
|
446
456
|
nextId?: string | undefined;
|
|
457
|
+
} | {
|
|
458
|
+
type: "check-duplicate";
|
|
459
|
+
id: string;
|
|
460
|
+
data: {
|
|
461
|
+
key: string;
|
|
462
|
+
email: string;
|
|
463
|
+
scope: "job" | "company";
|
|
464
|
+
};
|
|
465
|
+
isHead?: boolean | undefined;
|
|
466
|
+
nextId?: string | undefined;
|
|
447
467
|
} | {
|
|
448
468
|
type: "feedback";
|
|
449
469
|
id: string;
|
|
@@ -672,6 +692,16 @@ export declare const FlowByJobPayloadSchema: import('valibot').ObjectSchema<{
|
|
|
672
692
|
};
|
|
673
693
|
isHead?: boolean | undefined;
|
|
674
694
|
nextId?: string | undefined;
|
|
695
|
+
} | {
|
|
696
|
+
type: "check-duplicate";
|
|
697
|
+
id: string;
|
|
698
|
+
data: {
|
|
699
|
+
key: string;
|
|
700
|
+
email: string;
|
|
701
|
+
scope: "job" | "company";
|
|
702
|
+
};
|
|
703
|
+
isHead?: boolean | undefined;
|
|
704
|
+
nextId?: string | undefined;
|
|
675
705
|
} | {
|
|
676
706
|
type: "feedback";
|
|
677
707
|
id: string;
|
package/dist/chatbot.d.ts
CHANGED
|
@@ -63,12 +63,13 @@ export type FetchFlowByJobIdAdditionalProperties = Partial<OpenChatbotParams & {
|
|
|
63
63
|
idType: 'inploi' | 'ats';
|
|
64
64
|
}>;
|
|
65
65
|
export type FetchFlowByIdAdditionalProperties = Partial<OpenChatbotParams>;
|
|
66
|
-
export declare const chatbotPlugin: ({ _internal_domManager: dom, theme, terms, feedback, }: InternalChatbotPluginParams) => ({ apiClient, rpcClient, logger, analytics }: {
|
|
66
|
+
export declare const chatbotPlugin: ({ _internal_domManager: dom, theme, terms, feedback, }: InternalChatbotPluginParams) => ({ apiClient, rpcClient, logger, analytics, publishableKey, env }: {
|
|
67
67
|
apiClient: import('@inploi/sdk').ApiClient;
|
|
68
68
|
rpcClient: import('@inploi/sdk').InploiRpcClient;
|
|
69
69
|
logger: Logger;
|
|
70
70
|
analytics: import('@inploi/sdk').AnalyticsService;
|
|
71
71
|
publishableKey?: string;
|
|
72
|
+
env?: import('@inploi/sdk').InploiSdkEnvironment;
|
|
72
73
|
}) => {
|
|
73
74
|
/** Optionally eagerly renders the interface ahead of needing the chatbot. */
|
|
74
75
|
prepare: () => Promise<void>;
|
package/dist/chatbot.utils.d.ts
CHANGED
|
@@ -210,6 +210,16 @@ export declare const getHeadOrThrow: (nodes: FlowNode[]) => {
|
|
|
210
210
|
};
|
|
211
211
|
isHead?: boolean | undefined;
|
|
212
212
|
nextId?: string | undefined;
|
|
213
|
+
} | {
|
|
214
|
+
type: "check-duplicate";
|
|
215
|
+
id: string;
|
|
216
|
+
data: {
|
|
217
|
+
key: string;
|
|
218
|
+
email: string;
|
|
219
|
+
scope: "job" | "company";
|
|
220
|
+
};
|
|
221
|
+
isHead?: boolean | undefined;
|
|
222
|
+
nextId?: string | undefined;
|
|
213
223
|
} | {
|
|
214
224
|
type: "feedback";
|
|
215
225
|
id: string;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { AnalyticsService, ApiClient, Logger } from '@inploi/sdk';
|
|
1
|
+
import { AnalyticsService, ApiClient, Logger, PlatformClient } from '@inploi/sdk';
|
|
2
2
|
|
|
3
3
|
type ChatbotBodyProps = {
|
|
4
4
|
apiClient: ApiClient;
|
|
5
5
|
logger: Logger;
|
|
6
6
|
analytics: AnalyticsService;
|
|
7
|
+
platformClient?: PlatformClient;
|
|
7
8
|
};
|
|
8
|
-
export declare const ChatbotBody: ({ logger, apiClient, analytics }: ChatbotBodyProps) => import("preact").JSX.Element;
|
|
9
|
+
export declare const ChatbotBody: ({ logger, apiClient, analytics, platformClient }: ChatbotBodyProps) => import("preact").JSX.Element;
|
|
9
10
|
export {};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { AnalyticsService, ApiClient, Logger } from '@inploi/sdk';
|
|
1
|
+
import { AnalyticsService, ApiClient, Logger, PlatformClient } from '@inploi/sdk';
|
|
2
2
|
import { ChatbotPluginParams } from '..';
|
|
3
3
|
|
|
4
4
|
type ChatbotProps = {
|
|
5
5
|
apiClient: ApiClient;
|
|
6
6
|
logger: Logger;
|
|
7
7
|
analytics: AnalyticsService;
|
|
8
|
+
platformClient?: PlatformClient;
|
|
8
9
|
params: ChatbotPluginParams;
|
|
9
10
|
};
|
|
10
|
-
export declare const Chatbot: ({ logger, apiClient, analytics, params }: ChatbotProps) => import("preact").JSX.Element;
|
|
11
|
+
export declare const Chatbot: ({ logger, apiClient, analytics, platformClient, params }: ChatbotProps) => import("preact").JSX.Element;
|
|
11
12
|
export {};
|