@inploi/plugin-chatbot 3.5.0 → 3.5.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 CHANGED
@@ -54,4 +54,4 @@ var $y=Object.defineProperty;var Sy=(Pt,Pe,V)=>Pe in Pt?$y(Pt,Pe,{enumerable:!0,
54
54
  ${e.flatMap(n=>Object.entries(n.colors).map(([r,o])=>`--i-${n.name}-${r}: ${o1(o)};`).join(`
55
55
  `)).join(`
56
56
  `)}
57
- }`,s1=({_internal_domManager:e=fg(),theme:t})=>Pt(({apiClient:n,logger:r,analytics:o})=>{let i=!1;const s=()=>{if(typeof window>"u")return;const a=e.getOrCreateChatbotElement();e.addStyle(dg,"inploi-chatbot-style");const c=i1([{name:"a",colors:_d(t)},{name:"n",colors:_d({hue:t.hue,chroma:.1})}]);e.addStyle(c,"inploi-chatbot-theme"),Qt(N(jv,{apiClient:n,logger:r,analytics:o}),a),i=!0};return{prepare:async()=>{if(!(typeof window>"u"))try{if(i)return;s(),r.info("Chatbot plugin prepared")}catch(a){console.error(a),r.error("Error preparing chatbot plugin",a)}},startApplication:async({jobId:a})=>{if(!(typeof window>"u"))try{ne.cancel(),hf(()=>{nt.value="maximised",ne.current$.value={state:"loading"}}),ug({jobId:a,apiClient:n,logger:r}).then(async c=>{c.ok?(await o.log({event:"APPLY_START",properties:{job_id:a},customProperties:{flow_id:c.value.flow.id}}).catch(r.error),ne.start(c.value)):ne.current$.value={state:"error",error:c.error}}),i||s()}catch(c){console.error(c),r.error("Error starting application",c)}},closeApplication:async()=>{typeof window>"u"||(r.info("Closing application from an external source"),ne.cancel())}}});if(!window.inploi)throw new Error("Please insert the SDK script tag above the plugins.");window.inploi.chatbotPlugin=s1;const xd=({node:e,nodes:t,stopWhen:n})=>{if((n==null?void 0:n(e))===!0)return e;const r=e.nextId?t.find(o=>o.id===e.nextId):void 0;if(r)return xd({node:r,nodes:t,stopWhen:n})},a1=({childNode:e,nodes:t})=>{const r=t.filter(o=>o.type==="if-block").find(o=>{if(!o.branchId)return!1;const i=t.find(a=>a.id===o.branchId);if(!i)return!1;const s=xd({node:i,nodes:t,stopWhen:a=>a.id===e.id});return!(!s||s.id!==e.id)});if(r!=null&&r.nextId)return t.find(o=>o.id===r.nextId)},c1=({flow:e,analytics:t,logger:n,context:r,apiClient:o,getSubmissions:i,chatService:s,onFlowEnd:a,onInterpret:c})=>{const u=new AbortController,d=async(l,f)=>{const h=i();c==null||c(l,f);try{await l1({analytics:t,logger:n,apiClient:o,context:r,node:l,submissions:h,chat:{sendMessage:async p=>s.send({groupId:l.id,message:p,signal:u.signal}),userInput:async p=>s.input({input:p,signal:u.signal})},next:p=>{const m=p?e.find(y=>y.id===p):a1({childNode:l,nodes:e});return m?d(m,l):a==null?void 0:a(l)},end:()=>a==null?void 0:a(l)})}catch(p){if(p instanceof Gn)return;throw p}};return{interpret:async l=>{const f=e.find(h=>h.id===l)??mu(e);return d(f)},abort:()=>{u.abort()}}};async function l1(e){return await tt(e).with({node:{type:"text"}},h1).with({node:{type:"image"}},p1).with({node:{type:"question-text"}},m1).with({node:{type:"question-enum"}},g1).with({node:{type:"question-number"}},v1).with({node:{type:"question-boolean"}},b1).with({node:{type:"question-file"}},w1).with({node:{type:"question-address"}},y1).with({node:{type:"end-flow"}},_1).with({node:{type:"if-block"}},f1).with({node:{type:"jump"}},({node:t,next:n})=>n(t.data.targetId)).with({node:{type:"link"}},d1).with({node:{type:"integration-application-submit"}},u1).with({node:{type:"integration-workflow-get"}},()=>Error("Unreachable")).exhaustive()}async function u1({chat:e,next:t,node:n,logger:r,apiClient:o,submissions:i,context:s,analytics:a}){await e.userInput({type:"multiple-choice",key:void 0,config:{options:[{label:"Submit my application",value:"submit"}],maxSelected:1,minSelected:1}});const c=()=>{const d=typeof s.jobId=="string"?s.jobId:void 0;d&&a.log({event:"APPLY_COMPLETE",properties:{job_id:d}})};await e.sendMessage({type:"system",variant:"info",text:"Submitting your application…"});const u=await o.fetch("/flow/apply",{method:"POST",body:JSON.stringify({...s,type:n.data.type,ats:n.data.ats,integration_id:n.data.integrationId,submissions:Lv(i||{})})}).catch(d=>d);await tt(u).with({ats_data:{redirect_url:Ae.string}},async d=>{await e.sendMessage({type:"text",author:"bot",text:"Almost there! Please finalise your application on our partner’s website."});const l=a.getAnonymousId(),f=new URL(d.ats_data.redirect_url);l&&!f.searchParams.has("anonymous_id")&&f.searchParams.set("anonymous_id",l),c(),await e.sendMessage({type:"link",href:f.toString(),text:"Finalise application on partner"})}).with({success:!0},async()=>{c(),await e.sendMessage({type:"system",variant:"success",text:"Application submitted"}),t(n.nextId)}).otherwise(async d=>{r.error(d),await e.sendMessage({type:"system",variant:"error",text:"Failed to submit application"}),t(n.id)})}async function d1({chat:e,next:t,node:n}){await e.sendMessage({type:"link",href:n.data.href,text:n.data.cta}),t(n.nextId)}async function f1({submissions:e,next:t,node:n}){const r=x1(n,e)?n.branchId:n.nextId;t(r)}async function h1({chat:e,next:t,node:n}){await e.sendMessage({author:"bot",type:"text",text:n.data.text}),t(n.nextId)}async function p1({chat:e,next:t,node:n}){await e.sendMessage({author:"bot",type:"image",url:n.data.url,height:n.data.height,width:n.data.width}),t(n.nextId)}async function m1({chat:e,next:t,node:n}){await e.sendMessage({author:"bot",type:"text",text:n.data.question});const r=await e.userInput({key:n.data.key,type:"text",config:{placeholder:n.data.placeholder,format:n.data.format}});await e.sendMessage({author:"user",type:"text",text:r.value}),t(n.nextId)}async function v1({chat:e,next:t,node:n}){await e.sendMessage({author:"bot",type:"text",text:n.data.question});const r=await e.userInput({key:n.data.key,type:"text",config:{placeholder:n.data.placeholder,format:"text"}});await e.sendMessage({author:"user",type:"text",text:r.value}),t(n.nextId)}async function g1({chat:e,next:t,node:n}){await e.sendMessage({author:"bot",type:"text",text:n.data.question});const r=await e.userInput({key:n.data.key,type:"multiple-choice",config:n.data});await e.sendMessage({author:"user",type:"text",text:n.data.options.filter(o=>r.value.includes(o.value)).map(o=>o.label).join(", ")}),t(n.nextId)}async function b1({chat:e,next:t,node:n}){await e.sendMessage({author:"bot",type:"text",text:n.data.question});const o=(await e.userInput({key:n.data.key,type:"boolean",config:{labels:{true:n.data.trueLabel,false:n.data.falseLabel}}})).value,i={true:n.data.trueLabel,false:n.data.falseLabel};await e.sendMessage({author:"user",type:"text",text:i[o]}),t(n.nextId)}async function y1({chat:e,next:t,node:n}){await e.sendMessage({author:"bot",type:"text",text:"Address questions are not implemented yet"}),t(n.nextId)}async function w1({node:e,chat:t,next:n}){await t.sendMessage({author:"bot",type:"text",text:e.data.question});const r=await t.userInput({key:e.data.key,type:"file",config:{extensions:e.data.extensions,fileSizeLimitKib:e.data.maxSizeKb,allowMultiple:e.data.multiple===!0}});for await(const o of r.value)await t.sendMessage({author:"user",type:"file",fileName:o.name,fileSizeKb:o.sizeKb});n(e.nextId)}async function _1({chat:e,end:t,next:n,node:r}){await e.sendMessage({type:"system",variant:"info",text:r.data.systemMessage||"Conversation finished"}),t()}const kd=Ae.union(Ae.string,Ae.array(Ae.string)),x1=(e,t)=>{const n=t==null?void 0:t[e.data.compareKey];return n?tt({...e.data,answer:n}).with({compare:"equals"},({compareValue:r})=>typeof n.value=="string"||typeof n.value=="boolean"?r===n.value.toString():!1).with({compare:"notEquals"},({compareValue:r})=>typeof n.value=="string"||typeof n.value=="boolean"?r!==n.value.toString():!1).with({compare:"contains",answer:{value:kd}},({compareValue:r,answer:o})=>o.value.includes(r)).with({compare:"notContains",answer:{value:kd}},({compareValue:r,answer:o})=>!o.value.includes(r)).with({answer:{type:"file"}},()=>!1).exhaustive():!1},xo=({class:e,...t})=>b("button",{class:Ut("bg-accent-7 active:bg-accent-10 active:text-accent-2 text-lowest pointer-coarse:touch-hitbox focus-visible:ring-accent-7/50 flex-shrink-0 rounded-full p-2 transition-all focus:outline-none focus-visible:ring-4 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:b("svg",{class:"block",width:"16",height:"16",viewBox:"0 0 16 16",fill:"transparent",stroke:"currentColor","stroke-linecap":"round","stroke-width":"2",children:[b("title",{children:"Send"}),b("path",{d:"M3.5 7.5L8 3L12.5 7.5"}),b("path",{d:"M8 4V13"})]})}),Ns=()=>{const e=U(null);return G(()=>{var t;(t=e.current)==null||t.focus()},[]),e},$d=["true","false"],k1=Qv($d),$1="answer",S1=({input:e,onSubmitSuccess:t,onHeightChange:n})=>{const r=Ns();return n(),b("form",{noValidate:!0,class:"flex items-center gap-2",onSubmit:o=>{o.preventDefault();const i=tt(o).with({nativeEvent:{submitter:Ae.select(Ae.union(Ae.instanceOf(HTMLButtonElement),Ae.instanceOf(HTMLInputElement)))}},a=>a.value).otherwise(()=>{throw new Error("invalid form")}),s=ns(k1,i);t(s)},children:$d.map((o,i)=>b("button",{ref:i===0?r:null,type:"submit",name:$1,value:o,class:"bg-lowest ease-expo-out ring-neutral-12/5 text-neutral-12 active:ring-accent-7 active:bg-accent-2 active:text-accent-11 fr block flex-1 overflow-hidden rounded-2xl px-2.5 py-2.5 ring-2 transition-all duration-300 selection:bg-transparent",children:b("p",{class:"truncate text-center text-base",children:e.config.labels[o]})}))})},Is=({error:e,onAnimationComplete:t})=>b(eo,{children:e&&b(qn.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},onAnimationComplete:t,role:"alert",class:"text-error-11 flex max-w-full items-center gap-1 overflow-hidden rounded-full p-0.5 px-1 opacity-0",children:[b("svg",{class:"text-error-10",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b("circle",{cx:"8",cy:"8",r:"6.3",stroke:"currentColor","stroke-width":"1.4"}),b("rect",{x:"7",y:"4",width:"2",height:"5",fill:"currentColor"}),b("rect",{x:"7",y:"10",width:"2",height:"2",fill:"currentColor"})]}),b("p",{class:"truncate pr-1 text-sm",children:e.message})]})}),M1=e=>new Promise((t,n)=>{const r=new FileReader;r.readAsDataURL(e),r.onload=()=>r.result?t(r.result.toString()):n("No result from reader"),r.onerror=n}),ko=e=>tt(e).with(Ae.number.lte(1e3),()=>`${Math.round(e)}KB`).with(Ae.number.lt(1e3*10),()=>`${(e/1e3).toFixed(1)}MB`).otherwise(()=>`${Math.round(e/1e3)}MB`),T1=e=>e.reduce((t,n)=>t+n.sizeKb,0),C1=es("file"),Sd=3,A1=({file:e,class:t,...n})=>{const r=e.name.split(".").pop(),o=e.name.replace(new RegExp(`.${r}$`),"");return b("div",{class:Ut("bg-accent-1 outline-neutral-4 flex max-w-full gap-2 overflow-hidden rounded-lg px-3 py-2 text-sm outline",t),...n,children:[b("p",{"aria-label":"File name",class:"text-accent-12 flex flex-grow overflow-hidden",children:[b("span",{class:"block truncate",children:o}),b("span",{children:[".",r]})]}),b("p",{"aria-label":"File size",class:"text-neutral-10",children:ko(e.sizeKb)})]})},Md=({class:e,...t})=>b("li",{class:Ut("outline-neutral-6 text-neutral-11 bg-neutral-1 block rounded-md px-1 py-0.5 text-xs outline outline-1",e),...t}),P1=({input:e,onSubmitSuccess:t,onHeightChange:n})=>{var l;const r=(l=ne.current$.value.application)==null?void 0:l.data.submissions[e.key],[o,i]=ae(C1(r)?r.value:[]),[s,a]=ae(),c=o.length-Sd,u=T1(o),d=Ns();return b("form",{class:"flex flex-col gap-1",onSubmit:f=>(f.preventDefault(),a(void 0),o.length===0&&a({type:"required",message:"Please select a file"}),e.config.fileSizeLimitKib&&u>e.config.fileSizeLimitKib&&a({type:"max",message:`File size exceeds limit of ${ko(e.config.fileSizeLimitKib)}`}),t(o)),children:[b("div",{class:"flex items-center gap-2",children:[b("label",{ref:d,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:[o.length>0?b(ue,{children:[b("ul",{class:"flex max-w-full flex-wrap justify-center gap-1 overflow-hidden p-1",children:[o.slice(0,Sd).map(f=>{const h=f.name.split(".").pop(),p=f.name.replace(new RegExp(`.${h}$`),"");return b(Md,{class:"flex overflow-hidden",children:[b("span",{class:"block truncate",children:p}),b("span",{children:[".",h]})]})}),c>0?b(Md,{children:["+",c," file",c!==1?"s":""]}):null]}),b("p",{class:"text-neutral-11 text-xs",children:[ko(u)," ",o.length>1?"total":""]})]}):b("div",{class:"flex flex-col justify-center gap-4 pb-6 pt-5",children:[b("header",{class:"flex flex-col items-center gap-0",children:[b("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:b("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"})}),b("p",{class:"text-neutral-12 tracking-[-0.01em] dark:text-gray-400",children:[e.config.allowMultiple?"Select files":"Select a file"," to upload"]}),e.config.fileSizeLimitKib?b("p",{class:"text-neutral-10 text-xs",children:["(max ",ko(e.config.fileSizeLimitKib),")"]}):null]}),b("aside",{class:"flex flex-col items-center gap-2",children:[b("p",{id:"accepted-filetypes",class:"sr-only",children:"Accepted file extensions"}),b("ul",{"aria-describedby":"accepted-filetypes",class:"flex flex-wrap justify-center gap-2",children:e.config.extensions.map(f=>b("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:f.replace(".","")}))})]})]}),b("input",{id:"dropzone-file",onInput:async f=>{kr(f.target instanceof HTMLInputElement);const h=f.target.files?Array.from(f.target.files):[],p=await Promise.allSettled(h.map(async y=>{const x=await M1(y);return{name:y.name,data:x,sizeKb:y.size/1e3}}));if(p.some(({status:y})=>y==="rejected"))return a({type:"invalid",message:"Invalid file"});const m=p.map(y=>y.status==="fulfilled"?y.value:null).filter(Boolean);i(m)},multiple:e.config.allowMultiple,type:"file",class:"sr-only"})]}),b(xo,{disabled:o.length===0})]}),s&&b(Is,{onAnimationComplete:n,error:s})]})};var ar=e=>e.type==="checkbox",$n=e=>e instanceof Date,Me=e=>e==null;const Td=e=>typeof e=="object";var fe=e=>!Me(e)&&!Array.isArray(e)&&Td(e)&&!$n(e),E1=e=>fe(e)&&e.target?ar(e.target)?e.target.checked:e.target.value:e,V1=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,O1=(e,t)=>e.has(V1(t)),L1=e=>{const t=e.constructor&&e.constructor.prototype;return fe(t)&&t.hasOwnProperty("isPrototypeOf")},Ds=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function at(e){let t;const n=Array.isArray(e);if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else if(!(Ds&&(e instanceof Blob||e instanceof FileList))&&(n||fe(e)))if(t=n?[]:{},!n&&!L1(e))t=e;else for(const r in e)e.hasOwnProperty(r)&&(t[r]=at(e[r]));else return e;return t}var cr=e=>Array.isArray(e)?e.filter(Boolean):[],ie=e=>e===void 0,O=(e,t,n)=>{if(!t||!fe(e))return n;const r=cr(t.split(/[,[\].]+?/)).reduce((o,i)=>Me(o)?o:o[i],e);return ie(r)||r===e?ie(e[t])?n:e[t]:r},Mt=e=>typeof e=="boolean";const Cd={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},ze={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},ct={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"};Fe.createContext(null);var R1=(e,t,n,r=!0)=>{const o={defaultValues:t._defaultValues};for(const i in e)Object.defineProperty(o,i,{get:()=>{const s=i;return t._proxyFormState[s]!==ze.all&&(t._proxyFormState[s]=!r||ze.all),n&&(n[s]=!0),e[s]}});return o},Le=e=>fe(e)&&!Object.keys(e).length,N1=(e,t,n,r)=>{n(e);const{name:o,...i}=e;return Le(i)||Object.keys(i).length>=Object.keys(t).length||Object.keys(i).find(s=>t[s]===(!r||ze.all))},Fs=e=>Array.isArray(e)?e:[e];function I1(e){const t=Fe.useRef(e);t.current=e,Fe.useEffect(()=>{const n=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{n&&n.unsubscribe()}},[e.disabled])}var Ye=e=>typeof e=="string",D1=(e,t,n,r,o)=>Ye(e)?(r&&t.watch.add(e),O(n,e,o)):Array.isArray(e)?e.map(i=>(r&&t.watch.add(i),O(n,i))):(r&&(t.watchAll=!0),n),zs=e=>/^\w*$/.test(e),Ad=e=>cr(e.replace(/["|']|\]/g,"").split(/\.|\[/));function Q(e,t,n){let r=-1;const o=zs(t)?[t]:Ad(t),i=o.length,s=i-1;for(;++r<i;){const a=o[r];let c=n;if(r!==s){const u=e[a];c=fe(u)||Array.isArray(u)?u:isNaN(+o[r+1])?{}:[]}e[a]=c,e=e[a]}return e}var Pd=(e,t,n,r,o)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:o||!0}}:{},Ed=e=>({isOnSubmit:!e||e===ze.onSubmit,isOnBlur:e===ze.onBlur,isOnChange:e===ze.onChange,isOnAll:e===ze.all,isOnTouch:e===ze.onTouched}),Vd=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const $o=(e,t,n,r)=>{for(const o of n||Object.keys(e)){const i=O(e,o);if(i){const{_f:s,...a}=i;if(s){if(s.refs&&s.refs[0]&&t(s.refs[0],o)&&!r)break;if(s.ref&&t(s.ref,s.name)&&!r)break}else fe(a)&&$o(a,t)}}};var F1=(e,t,n)=>{const r=cr(O(e,n));return Q(r,"root",t[n]),Q(e,n,r),e},Bs=e=>e.type==="file",Tt=e=>typeof e=="function",So=e=>{if(!Ds)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Mo=e=>Ye(e),js=e=>e.type==="radio",To=e=>e instanceof RegExp;const Od={value:!1,isValid:!1},Ld={value:!0,isValid:!0};var Rd=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!ie(e[0].attributes.value)?ie(e[0].value)||e[0].value===""?Ld:{value:e[0].value,isValid:!0}:Ld:Od}return Od};const Nd={isValid:!1,value:null};var Id=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,Nd):Nd;function Dd(e,t,n="validate"){if(Mo(e)||Array.isArray(e)&&e.every(Mo)||Mt(e)&&!e)return{type:n,message:Mo(e)?e:"",ref:t}}var Sn=e=>fe(e)&&!To(e)?e:{value:e,message:""},Fd=async(e,t,n,r,o)=>{const{ref:i,refs:s,required:a,maxLength:c,minLength:u,min:d,max:l,pattern:f,validate:h,name:p,valueAsNumber:m,mount:y,disabled:x}=e._f,g=O(t,p);if(!y||x)return{};const w=s?s[0]:i,M=j=>{r&&w.reportValidity&&(w.setCustomValidity(Mt(j)?"":j||""),w.reportValidity())},S={},I=js(i),R=ar(i),C=I||R,E=(m||Bs(i))&&ie(i.value)&&ie(g)||So(i)&&i.value===""||g===""||Array.isArray(g)&&!g.length,q=Pd.bind(null,p,n,S),K=(j,B,H,X=ct.maxLength,re=ct.minLength)=>{const se=j?B:H;S[p]={type:j?X:re,message:se,ref:i,...q(j?X:re,se)}};if(o?!Array.isArray(g)||!g.length:a&&(!C&&(E||Me(g))||Mt(g)&&!g||R&&!Rd(s).isValid||I&&!Id(s).isValid)){const{value:j,message:B}=Mo(a)?{value:!!a,message:a}:Sn(a);if(j&&(S[p]={type:ct.required,message:B,ref:w,...q(ct.required,B)},!n))return M(B),S}if(!E&&(!Me(d)||!Me(l))){let j,B;const H=Sn(l),X=Sn(d);if(!Me(g)&&!isNaN(g)){const re=i.valueAsNumber||g&&+g;Me(H.value)||(j=re>H.value),Me(X.value)||(B=re<X.value)}else{const re=i.valueAsDate||new Date(g),se=lt=>new Date(new Date().toDateString()+" "+lt),Re=i.type=="time",Ne=i.type=="week";Ye(H.value)&&g&&(j=Re?se(g)>se(H.value):Ne?g>H.value:re>new Date(H.value)),Ye(X.value)&&g&&(B=Re?se(g)<se(X.value):Ne?g<X.value:re<new Date(X.value))}if((j||B)&&(K(!!j,H.message,X.message,ct.max,ct.min),!n))return M(S[p].message),S}if((c||u)&&!E&&(Ye(g)||o&&Array.isArray(g))){const j=Sn(c),B=Sn(u),H=!Me(j.value)&&g.length>+j.value,X=!Me(B.value)&&g.length<+B.value;if((H||X)&&(K(H,j.message,B.message),!n))return M(S[p].message),S}if(f&&!E&&Ye(g)){const{value:j,message:B}=Sn(f);if(To(j)&&!g.match(j)&&(S[p]={type:ct.pattern,message:B,ref:i,...q(ct.pattern,B)},!n))return M(B),S}if(h){if(Tt(h)){const j=await h(g,t),B=Dd(j,w);if(B&&(S[p]={...B,...q(ct.validate,B.message)},!n))return M(B.message),S}else if(fe(h)){let j={};for(const B in h){if(!Le(j)&&!n)break;const H=Dd(await h[B](g,t),w,B);H&&(j={...H,...q(B,H.message)},M(H.message),n&&(S[p]=j))}if(!Le(j)&&(S[p]={ref:w,...j},!n))return S}}return M(!0),S};function z1(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=ie(e)?r++:e[t[r++]];return e}function B1(e){for(const t in e)if(e.hasOwnProperty(t)&&!ie(e[t]))return!1;return!0}function ye(e,t){const n=Array.isArray(t)?t:zs(t)?[t]:Ad(t),r=n.length===1?e:z1(e,n),o=n.length-1,i=n[o];return r&&delete r[i],o!==0&&(fe(r)&&Le(r)||Array.isArray(r)&&B1(r))&&ye(e,n.slice(0,-1)),e}function Hs(){let e=[];return{get observers(){return e},next:o=>{for(const i of e)i.next&&i.next(o)},subscribe:o=>(e.push(o),{unsubscribe:()=>{e=e.filter(i=>i!==o)}}),unsubscribe:()=>{e=[]}}}var Co=e=>Me(e)||!Td(e);function Kt(e,t){if(Co(e)||Co(t))return e===t;if($n(e)&&$n(t))return e.getTime()===t.getTime();const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n){const i=e[o];if(!r.includes(o))return!1;if(o!=="ref"){const s=t[o];if($n(i)&&$n(s)||fe(i)&&fe(s)||Array.isArray(i)&&Array.isArray(s)?!Kt(i,s):i!==s)return!1}}return!0}var zd=e=>e.type==="select-multiple",j1=e=>js(e)||ar(e),Us=e=>So(e)&&e.isConnected,Bd=e=>{for(const t in e)if(Tt(e[t]))return!0;return!1};function Ao(e,t={}){const n=Array.isArray(e);if(fe(e)||n)for(const r in e)Array.isArray(e[r])||fe(e[r])&&!Bd(e[r])?(t[r]=Array.isArray(e[r])?[]:{},Ao(e[r],t[r])):Me(e[r])||(t[r]=!0);return t}function jd(e,t,n){const r=Array.isArray(e);if(fe(e)||r)for(const o in e)Array.isArray(e[o])||fe(e[o])&&!Bd(e[o])?ie(t)||Co(n[o])?n[o]=Array.isArray(e[o])?Ao(e[o],[]):{...Ao(e[o])}:jd(e[o],Me(t)?{}:t[o],n[o]):n[o]=!Kt(e[o],t[o]);return n}var Xs=(e,t)=>jd(e,t,Ao(t)),Hd=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>ie(e)?e:t?e===""?NaN:e&&+e:n&&Ye(e)?new Date(e):r?r(e):e;function qs(e){const t=e.ref;if(!(e.refs?e.refs.every(n=>n.disabled):t.disabled))return Bs(t)?t.files:js(t)?Id(e.refs).value:zd(t)?[...t.selectedOptions].map(({value:n})=>n):ar(t)?Rd(e.refs).value:Hd(ie(t.value)?e.ref.value:t.value,e)}var H1=(e,t,n,r)=>{const o={};for(const i of e){const s=O(t,i);s&&Q(o,i,s._f)}return{criteriaMode:n,names:[...e],fields:o,shouldUseNativeValidation:r}},lr=e=>ie(e)?e:To(e)?e.source:fe(e)?To(e.value)?e.value.source:e.value:e,U1=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function Ud(e,t,n){const r=O(e,n);if(r||zs(n))return{error:r,name:n};const o=n.split(".");for(;o.length;){const i=o.join("."),s=O(t,i),a=O(e,i);if(s&&!Array.isArray(s)&&n!==i)return{name:n};if(a&&a.type)return{name:i,error:a};o.pop()}return{name:n}}var X1=(e,t,n,r,o)=>o.isOnAll?!1:!n&&o.isOnTouch?!(t||e):(n?r.isOnBlur:o.isOnBlur)?!e:(n?r.isOnChange:o.isOnChange)?e:!0,q1=(e,t)=>!cr(O(e,t)).length&&ye(e,t);const W1={mode:ze.onSubmit,reValidateMode:ze.onChange,shouldFocusError:!0};function K1(e={},t){let n={...W1,...e},r={submitCount:0,isDirty:!1,isLoading:Tt(n.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},errors:{},disabled:!1},o={},i=fe(n.defaultValues)||fe(n.values)?at(n.defaultValues||n.values)||{}:{},s=n.shouldUnregister?{}:at(i),a={action:!1,mount:!1,watch:!1},c={mount:new Set,unMount:new Set,array:new Set,watch:new Set},u,d=0;const l={isDirty:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},f={values:Hs(),array:Hs(),state:Hs()},h=e.resetOptions&&e.resetOptions.keepDirtyValues,p=Ed(n.mode),m=Ed(n.reValidateMode),y=n.criteriaMode===ze.all,x=v=>_=>{clearTimeout(d),d=setTimeout(v,_)},g=async v=>{if(l.isValid||v){const _=n.resolver?Le((await E()).errors):await K(o,!0);_!==r.isValid&&f.state.next({isValid:_})}},w=v=>l.isValidating&&f.state.next({isValidating:v}),M=(v,_=[],k,L,P=!0,T=!0)=>{if(L&&k){if(a.action=!0,T&&Array.isArray(O(o,v))){const D=k(O(o,v),L.argA,L.argB);P&&Q(o,v,D)}if(T&&Array.isArray(O(r.errors,v))){const D=k(O(r.errors,v),L.argA,L.argB);P&&Q(r.errors,v,D),q1(r.errors,v)}if(l.touchedFields&&T&&Array.isArray(O(r.touchedFields,v))){const D=k(O(r.touchedFields,v),L.argA,L.argB);P&&Q(r.touchedFields,v,D)}l.dirtyFields&&(r.dirtyFields=Xs(i,s)),f.state.next({name:v,isDirty:B(v,_),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else Q(s,v,_)},S=(v,_)=>{Q(r.errors,v,_),f.state.next({errors:r.errors})},I=(v,_,k,L)=>{const P=O(o,v);if(P){const T=O(s,v,ie(k)?O(i,v):k);ie(T)||L&&L.defaultChecked||_?Q(s,v,_?T:qs(P._f)):re(v,T),a.mount&&g()}},R=(v,_,k,L,P)=>{let T=!1,D=!1;const ee={name:v};if(!k||L){l.isDirty&&(D=r.isDirty,r.isDirty=ee.isDirty=B(),T=D!==ee.isDirty);const le=Kt(O(i,v),_);D=O(r.dirtyFields,v),le?ye(r.dirtyFields,v):Q(r.dirtyFields,v,!0),ee.dirtyFields=r.dirtyFields,T=T||l.dirtyFields&&D!==!le}if(k){const le=O(r.touchedFields,v);le||(Q(r.touchedFields,v,k),ee.touchedFields=r.touchedFields,T=T||l.touchedFields&&le!==k)}return T&&P&&f.state.next(ee),T?ee:{}},C=(v,_,k,L)=>{const P=O(r.errors,v),T=l.isValid&&Mt(_)&&r.isValid!==_;if(e.delayError&&k?(u=x(()=>S(v,k)),u(e.delayError)):(clearTimeout(d),u=null,k?Q(r.errors,v,k):ye(r.errors,v)),(k?!Kt(P,k):P)||!Le(L)||T){const D={...L,...T&&Mt(_)?{isValid:_}:{},errors:r.errors,name:v};r={...r,...D},f.state.next(D)}w(!1)},E=async v=>n.resolver(s,n.context,H1(v||c.mount,o,n.criteriaMode,n.shouldUseNativeValidation)),q=async v=>{const{errors:_}=await E(v);if(v)for(const k of v){const L=O(_,k);L?Q(r.errors,k,L):ye(r.errors,k)}else r.errors=_;return _},K=async(v,_,k={valid:!0})=>{for(const L in v){const P=v[L];if(P){const{_f:T,...D}=P;if(T){const ee=c.array.has(T.name),le=await Fd(P,s,y,n.shouldUseNativeValidation&&!_,ee);if(le[T.name]&&(k.valid=!1,_))break;!_&&(O(le,T.name)?ee?F1(r.errors,le,T.name):Q(r.errors,T.name,le[T.name]):ye(r.errors,T.name))}D&&await K(D,_,k)}}return k.valid},j=()=>{for(const v of c.unMount){const _=O(o,v);_&&(_._f.refs?_._f.refs.every(k=>!Us(k)):!Us(_._f.ref))&&Ze(v)}c.unMount=new Set},B=(v,_)=>(v&&_&&Q(s,v,_),!Kt(Ie(),i)),H=(v,_,k)=>D1(v,c,{...a.mount?s:ie(_)?i:Ye(v)?{[v]:_}:_},k,_),X=v=>cr(O(a.mount?s:i,v,e.shouldUnregister?O(i,v,[]):[])),re=(v,_,k={})=>{const L=O(o,v);let P=_;if(L){const T=L._f;T&&(!T.disabled&&Q(s,v,Hd(_,T)),P=So(T.ref)&&Me(_)?"":_,zd(T.ref)?[...T.ref.options].forEach(D=>D.selected=P.includes(D.value)):T.refs?ar(T.ref)?T.refs.length>1?T.refs.forEach(D=>(!D.defaultChecked||!D.disabled)&&(D.checked=Array.isArray(P)?!!P.find(ee=>ee===D.value):P===D.value)):T.refs[0]&&(T.refs[0].checked=!!P):T.refs.forEach(D=>D.checked=D.value===P):Bs(T.ref)?T.ref.value="":(T.ref.value=P,T.ref.type||f.values.next({name:v,values:{...s}})))}(k.shouldDirty||k.shouldTouch)&&R(v,P,k.shouldTouch,k.shouldDirty,!0),k.shouldValidate&&Y(v)},se=(v,_,k)=>{for(const L in _){const P=_[L],T=`${v}.${L}`,D=O(o,T);(c.array.has(v)||!Co(P)||D&&!D._f)&&!$n(P)?se(T,P,k):re(T,P,k)}},Re=(v,_,k={})=>{const L=O(o,v),P=c.array.has(v),T=at(_);Q(s,v,T),P?(f.array.next({name:v,values:{...s}}),(l.isDirty||l.dirtyFields)&&k.shouldDirty&&f.state.next({name:v,dirtyFields:Xs(i,s),isDirty:B(v,T)})):L&&!L._f&&!Me(T)?se(v,T,k):re(v,T,k),Vd(v,c)&&f.state.next({...r}),f.values.next({name:v,values:{...s}}),!a.mount&&t()},Ne=async v=>{const _=v.target;let k=_.name,L=!0;const P=O(o,k),T=()=>_.type?qs(P._f):E1(v),D=ee=>{L=Number.isNaN(ee)||ee===O(s,k,ee)};if(P){let ee,le;const Oo=T(),Mn=v.type===Cd.BLUR||v.type===Cd.FOCUS_OUT,_y=!U1(P._f)&&!n.resolver&&!O(r.errors,k)&&!P._f.deps||X1(Mn,O(r.touchedFields,k),r.isSubmitted,m,p),Ws=Vd(k,c,Mn);Q(s,k,Oo),Mn?(P._f.onBlur&&P._f.onBlur(v),u&&u(0)):P._f.onChange&&P._f.onChange(v);const Ks=R(k,Oo,Mn,!1),xy=!Le(Ks)||Ws;if(!Mn&&f.values.next({name:k,type:v.type,values:{...s}}),_y)return l.isValid&&g(),xy&&f.state.next({name:k,...Ws?{}:Ks});if(!Mn&&Ws&&f.state.next({...r}),w(!0),n.resolver){const{errors:Qd}=await E([k]);if(D(Oo),L){const ky=Ud(r.errors,o,k),ef=Ud(Qd,o,ky.name||k);ee=ef.error,k=ef.name,le=Le(Qd)}}else ee=(await Fd(P,s,y,n.shouldUseNativeValidation))[k],D(Oo),L&&(ee?le=!1:l.isValid&&(le=await K(o,!0)));L&&(P._f.deps&&Y(P._f.deps),C(k,le,ee,Ks))}},lt=(v,_)=>{if(O(r.errors,_)&&v.focus)return v.focus(),1},Y=async(v,_={})=>{let k,L;const P=Fs(v);if(w(!0),n.resolver){const T=await q(ie(v)?v:P);k=Le(T),L=v?!P.some(D=>O(T,D)):k}else v?(L=(await Promise.all(P.map(async T=>{const D=O(o,T);return await K(D&&D._f?{[T]:D}:D)}))).every(Boolean),!(!L&&!r.isValid)&&g()):L=k=await K(o);return f.state.next({...!Ye(v)||l.isValid&&k!==r.isValid?{}:{name:v},...n.resolver||!v?{isValid:k}:{},errors:r.errors,isValidating:!1}),_.shouldFocus&&!L&&$o(o,lt,v?P:c.mount),L},Ie=v=>{const _={...i,...a.mount?s:{}};return ie(v)?_:Ye(v)?O(_,v):v.map(k=>O(_,k))},Ct=(v,_)=>({invalid:!!O((_||r).errors,v),isDirty:!!O((_||r).dirtyFields,v),isTouched:!!O((_||r).touchedFields,v),error:O((_||r).errors,v)}),At=v=>{v&&Fs(v).forEach(_=>ye(r.errors,_)),f.state.next({errors:v?r.errors:{}})},Yt=(v,_,k)=>{const L=(O(o,v,{_f:{}})._f||{}).ref;Q(r.errors,v,{..._,ref:L}),f.state.next({name:v,errors:r.errors,isValid:!1}),k&&k.shouldFocus&&L&&L.focus&&L.focus()},Ge=(v,_)=>Tt(v)?f.values.subscribe({next:k=>v(H(void 0,_),k)}):H(v,_,!0),Ze=(v,_={})=>{for(const k of v?Fs(v):c.mount)c.mount.delete(k),c.array.delete(k),_.keepValue||(ye(o,k),ye(s,k)),!_.keepError&&ye(r.errors,k),!_.keepDirty&&ye(r.dirtyFields,k),!_.keepTouched&&ye(r.touchedFields,k),!n.shouldUnregister&&!_.keepDefaultValue&&ye(i,k);f.values.next({values:{...s}}),f.state.next({...r,..._.keepDirty?{isDirty:B()}:{}}),!_.keepIsValid&&g()},Eo=({disabled:v,name:_,field:k,fields:L,value:P})=>{if(Mt(v)){const T=v?void 0:ie(P)?qs(k?k._f:O(L,_)._f):P;Q(s,_,T),R(_,T,!1,!1,!0)}},Gt=(v,_={})=>{let k=O(o,v);const L=Mt(_.disabled);return Q(o,v,{...k||{},_f:{...k&&k._f?k._f:{ref:{name:v}},name:v,mount:!0,..._}}),c.mount.add(v),k?Eo({field:k,disabled:_.disabled,name:v}):I(v,!0,_.value),{...L?{disabled:_.disabled}:{},...n.progressive?{required:!!_.required,min:lr(_.min),max:lr(_.max),minLength:lr(_.minLength),maxLength:lr(_.maxLength),pattern:lr(_.pattern)}:{},name:v,onChange:Ne,onBlur:Ne,ref:P=>{if(P){Gt(v,_),k=O(o,v);const T=ie(P.value)&&P.querySelectorAll&&P.querySelectorAll("input,select,textarea")[0]||P,D=j1(T),ee=k._f.refs||[];if(D?ee.find(le=>le===T):T===k._f.ref)return;Q(o,v,{_f:{...k._f,...D?{refs:[...ee.filter(Us),T,...Array.isArray(O(i,v))?[{}]:[]],ref:{type:T.type,name:v}}:{ref:T}}}),I(v,!1,void 0,T)}else k=O(o,v,{}),k._f&&(k._f.mount=!1),(n.shouldUnregister||_.shouldUnregister)&&!(O1(c.array,v)&&a.action)&&c.unMount.add(v)}}},Zt=()=>n.shouldFocusError&&$o(o,lt,c.mount),ut=v=>{Mt(v)&&(f.state.next({disabled:v}),$o(o,_=>{_.disabled=v},0,!1))},ur=(v,_)=>async k=>{k&&(k.preventDefault&&k.preventDefault(),k.persist&&k.persist());let L=at(s);if(f.state.next({isSubmitting:!0}),n.resolver){const{errors:P,values:T}=await E();r.errors=P,L=T}else await K(o);ye(r.errors,"root"),Le(r.errors)?(f.state.next({errors:{}}),await v(L,k)):(_&&await _({...r.errors},k),Zt(),setTimeout(Zt)),f.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Le(r.errors),submitCount:r.submitCount+1,errors:r.errors})},Vo=(v,_={})=>{O(o,v)&&(ie(_.defaultValue)?Re(v,O(i,v)):(Re(v,_.defaultValue),Q(i,v,_.defaultValue)),_.keepTouched||ye(r.touchedFields,v),_.keepDirty||(ye(r.dirtyFields,v),r.isDirty=_.defaultValue?B(v,O(i,v)):B()),_.keepError||(ye(r.errors,v),l.isValid&&g()),f.state.next({...r}))},Zd=(v,_={})=>{const k=v?at(v):i,L=at(k),P=v&&!Le(v)?L:i;if(_.keepDefaultValues||(i=k),!_.keepValues){if(_.keepDirtyValues||h)for(const T of c.mount)O(r.dirtyFields,T)?Q(P,T,O(s,T)):Re(T,O(P,T));else{if(Ds&&ie(v))for(const T of c.mount){const D=O(o,T);if(D&&D._f){const ee=Array.isArray(D._f.refs)?D._f.refs[0]:D._f.ref;if(So(ee)){const le=ee.closest("form");if(le){le.reset();break}}}}o={}}s=e.shouldUnregister?_.keepDefaultValues?at(i):{}:at(P),f.array.next({values:{...P}}),f.values.next({values:{...P}})}c={mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},!a.mount&&t(),a.mount=!l.isValid||!!_.keepIsValid,a.watch=!!e.shouldUnregister,f.state.next({submitCount:_.keepSubmitCount?r.submitCount:0,isDirty:_.keepDirty?r.isDirty:!!(_.keepDefaultValues&&!Kt(v,i)),isSubmitted:_.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:_.keepDirtyValues?r.dirtyFields:_.keepDefaultValues&&v?Xs(i,v):{},touchedFields:_.keepTouched?r.touchedFields:{},errors:_.keepErrors?r.errors:{},isSubmitSuccessful:_.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1})},Jd=(v,_)=>Zd(Tt(v)?v(s):v,_);return{control:{register:Gt,unregister:Ze,getFieldState:Ct,handleSubmit:ur,setError:Yt,_executeSchema:E,_getWatch:H,_getDirty:B,_updateValid:g,_removeUnmounted:j,_updateFieldArray:M,_updateDisabledField:Eo,_getFieldArray:X,_reset:Zd,_resetDefaultValues:()=>Tt(n.defaultValues)&&n.defaultValues().then(v=>{Jd(v,n.resetOptions),f.state.next({isLoading:!1})}),_updateFormState:v=>{r={...r,...v}},_disableForm:ut,_subjects:f,_proxyFormState:l,get _fields(){return o},get _formValues(){return s},get _state(){return a},set _state(v){a=v},get _defaultValues(){return i},get _names(){return c},set _names(v){c=v},get _formState(){return r},set _formState(v){r=v},get _options(){return n},set _options(v){n={...n,...v}}},trigger:Y,register:Gt,handleSubmit:ur,watch:Ge,setValue:Re,getValues:Ie,reset:Jd,resetField:Vo,clearErrors:At,unregister:Ze,setError:Yt,setFocus:(v,_={})=>{const k=O(o,v),L=k&&k._f;if(L){const P=L.refs?L.refs[0]:L.ref;P.focus&&(P.focus(),_.shouldSelect&&P.select())}},getFieldState:Ct}}function Xd(e={}){const t=Fe.useRef(),n=Fe.useRef(),[r,o]=Fe.useState({isDirty:!1,isValidating:!1,isLoading:Tt(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},errors:{},disabled:!1,defaultValues:Tt(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...K1(e,()=>o(s=>({...s}))),formState:r});const i=t.current.control;return i._options=e,I1({subject:i._subjects.state,next:s=>{N1(s,i._proxyFormState,i._updateFormState,!0)&&o({...i._formState})}}),Fe.useEffect(()=>i._disableForm(e.disabled),[i,e.disabled]),Fe.useEffect(()=>{if(i._proxyFormState.isDirty){const s=i._getDirty();s!==r.isDirty&&i._subjects.state.next({isDirty:s})}},[i,r.isDirty]),Fe.useEffect(()=>{e.values&&!Kt(e.values,n.current)?(i._reset(e.values,i._options.resetOptions),n.current=e.values):i._resetDefaultValues()},[e.values,i]),Fe.useEffect(()=>{i._state.mount||(i._updateValid(),i._state.mount=!0),i._state.watch&&(i._state.watch=!1,i._subjects.state.next({...i._formState})),i._removeUnmounted()}),t.current.formState=R1(r,i),t.current}var qd=function(e,t,n){if(e&&"reportValidity"in e){var r=O(n,t);e.setCustomValidity(r&&r.message||""),e.reportValidity()}},Y1=function(e,t){var n=function(o){var i=t.fields[o];i&&i.ref&&"reportValidity"in i.ref?qd(i.ref,o,e):i.refs&&i.refs.forEach(function(s){return qd(s,o,e)})};for(var r in t.fields)n(r)},G1=function(e,t){t.shouldUseNativeValidation&&Y1(e,t);var n={};for(var r in e){var o=O(t.fields,r),i=Object.assign(e[r]||{},{ref:o&&o.ref});if(J1(t.names||Object.keys(e),r)){var s=Object.assign({},Z1(O(n,r)));Q(s,"root",i),Q(n,r,s)}else Q(n,r,i)}return n},Z1=function(e){return Array.isArray(e)?e.filter(Boolean):[]},J1=function(e,t){return e.some(function(n){return n.startsWith(t+".")})},Q1=function(e,t){for(var n={};e.issues.length;){var r=e.issues[0];if(r.path){var o=r.path.map(function(a){return a.key}).join(".");if(n[o]||(n[o]={message:r.message,type:r.validation}),t){var i=n[o].types,s=i&&i[r.validation];n[o]=Pd(o,t,n,r.validation,s?[].concat(s,r.message):r.message)}e.issues.shift()}}return n},Wd=function(e,t,n){return n===void 0&&(n={}),function(r,o,i){try{return Promise.resolve(function(s,a){try{var c=function(){function u(l){return{values:n.raw?r:l,errors:{}}}var d=Object.assign({},{abortEarly:!1,abortPipeEarly:!1},t);return n.mode==="sync"?u(ns(e,r,d)):Promise.resolve(rg(e,r,d)).then(u)}()}catch(u){return a(u)}return c&&c.then?c.then(void 0,a):c}(0,function(s){if(s instanceof io)return{values:{},errors:G1(Q1(s,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw s}))}catch(s){return Promise.reject(s)}}};const ey=e=>{const t=Object.fromEntries(new FormData(e).entries());Object.keys(t).length&&e.dispatchEvent(new Event("submit",{bubbles:!0}))},ty=es("multiple-choice"),ny=e=>{const t={min:e.minSelected??0,max:e.maxSelected??e.options.length};return Wd(vn({checked:xu(ng(Gv()),n=>Object.entries(n).filter(([r,o])=>o).map(([r,o])=>r),[sg(t.max,`Please select at most ${t.max} option${t.max!==1?"s":""}`),ku(t.min,`Please select at least ${t.min} option${t.min!==1?"s":""}`)])}))},ry=({input:e,onSubmitSuccess:t,onHeightChange:n})=>{var u,d;const r=e.key?(u=ne.current$.value.application)==null?void 0:u.data.submissions[e.key]:void 0,{register:o,handleSubmit:i,formState:{errors:s}}=Xd({defaultValues:{checked:ty(r)?Object.fromEntries(r.value.map(l=>[l,!0])):{}},resolver:ny(e.config)}),a=Ns(),c=e.config.minSelected===1&&e.config.maxSelected===1;return b("form",{noValidate:!0,class:"flex flex-col gap-1",onChange:l=>{c&&ey(l.currentTarget)},onSubmit:i(l=>{const f=l.checked;t(f)}),children:[b("div",{class:"flex items-center gap-2",children:[b("div",{class:Ut("flex w-full flex-1 flex-wrap gap-3 p-1",{"justify-center":e.config.options.length===1}),children:e.config.options.map((l,f)=>{const h=`checked.${l.value}`,{ref:p,...m}=o(h);return b("div",{children:[b("input",{autoFocus:f===0,ref:y=>{y&&f===0&&(a.current=y),p(y)},id:h,...m,class:"peer sr-only",type:"checkbox"}),b("label",{class:"bg-lowest peer-focus-visible:ring-accent-7 active:outline-neutral-10 ease-expo-out outline-neutral-12/5 text-neutral-11 peer-checked:outline-accent-7 peer-checked:bg-accent-2 peer-checked:text-accent-9 block rounded-2xl px-2.5 py-1 outline outline-2 ring-0 ring-transparent transition-all duration-300 selection:bg-transparent peer-focus-visible:ring-4 peer-focus-visible:ring-offset-2",htmlFor:h,children:l.label})]},l.value)})}),!c&&b(xo,{})]}),b(Is,{onAnimationComplete:n,error:(d=s.checked)==null?void 0:d.root})]})},Po={email:"That doesn’t look like a valid email address",phone:"That doesn’t look like a valid phone number"},oy=We(Po.phone,[ag(/^\+?[0-9 -]+$/,Po.phone)]),iy={email:We(Po.email,[ig(Po.email)]),phone:xu(oy,e=>e.replace(/[^0-9]/g,"")),text:We([ku(1,"Please enter some text")]),url:We([cg("That doesn’t look like a valid URL")])},sy={email:{type:"email",inputMode:"email",formNoValidate:!0},phone:{type:"tel",inputMode:"tel"},text:{type:"text",inputMode:"text"},url:{type:"url",inputMode:"url",formNoValidate:!0}},ay=es("text"),cy=e=>Wd(vn({text:iy[e.format]})),ly=({input:e,onSubmitSuccess:t,onHeightChange:n})=>{var d;const r=e.key?(d=ne.current$.value.application)==null?void 0:d.data.submissions[e.key]:void 0,{register:o,handleSubmit:i,formState:{errors:s}}=Xd({defaultValues:{text:ay(r)?r.value:""},resolver:cy(e.config)}),{ref:a,...c}=o("text",{required:!0}),u=U();return Be(()=>{u.current&&(u.current.focus(),u.current.select())},[]),b("form",{noValidate:!0,class:"flex flex-col gap-1",onSubmit:i(l=>{t(l.text)}),children:[b("div",{class:"flex items-center gap-2",children:[b("input",{id:"chat-input",...c,...sy[e.config.format],autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:l=>{l&&(u.current=l),a(l)},class:"outline-neutral-12/5 ease-expo-out placeholder:text-neutral-5 focus-visible:outline-accent-7 caret-accent-9 flex-grow rounded-full px-3 py-1 text-base outline outline-2 transition-all duration-300",placeholder:e.config.placeholder}),b(xo,{})]}),b(Is,{onAnimationComplete:n,error:s.text})]})},uy=({onSubmit:e,onInputChange:t,input:n})=>{const r=U(null),o=me(()=>{r.current&&(ts.value=r.current.getBoundingClientRect().height)},[]);G(()=>{o(),t(n==null?void 0:n.type)},[n==null?void 0:n.type,t,o]);const i=s=>a=>e({type:s,value:a});return b(qn.div,{initial:{height:0},animate:{height:ts.value},exit:{height:0,opacity:0},class:"bg-neutral-2/80 absolute bottom-0 w-full overflow-hidden rounded-b-3xl backdrop-blur-md backdrop-saturate-150",children:b("div",{ref:r,class:"border-neutral-12/5 border-t p-2.5",children:tt({application:ne,input:n,onHeightChange:o}).with({input:Ae.nullish},()=>b("div",{class:"flex items-center gap-2",children:[b("input",{"aria-hidden":"true",id:"chat-input",class:"outline-neutral-12/5 placeholder:text-neutral-4 focus-visible:outline-accent-9 caret-accent-9 flex-grow rounded-full px-3 py-1 text-base outline outline-2",disabled:!0}),b(xo,{disabled:!0,"aria-hidden":"true",tabIndex:-1})]})).with({input:{type:"text"}},s=>b(ly,{onSubmitSuccess:i(s.input.type),...s})).with({input:{type:"multiple-choice"}},s=>b(ry,{onSubmitSuccess:i(s.input.type),...s})).with({input:{type:"boolean"}},s=>b(S1,{onSubmitSuccess:i(s.input.type),...s})).with({input:{type:"file"}},s=>b(P1,{onSubmitSuccess:i(s.input.type),...s})).exhaustive()})})},Kd=e=>typeof e=="boolean"?"".concat(e):e===0?"0":e,Yd=Ut,Gd=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return Yd(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:i}=t,s=Object.keys(o).map(u=>{const d=n==null?void 0:n[u],l=i==null?void 0:i[u];if(d===null)return null;const f=Kd(d)||Kd(l);return o[u][f]}),a=n&&Object.entries(n).reduce((u,d)=>{let[l,f]=d;return f===void 0||(u[l]=f),u},{}),c=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((u,d)=>{let{class:l,className:f,...h}=d;return Object.entries(h).every(p=>{let[m,y]=p;return Array.isArray(y)?y.includes({...i,...a}[m]):{...i,...a}[m]===y})?[...u,l,f]:u},[]);return Yd(e,s,c,n==null?void 0:n.class,n==null?void 0:n.className)},dy=Gd("max-w-[min(100%,24rem)] [text-wrap:pretty] leading-snug flex-shrink-1 min-w-[2rem] text-md py-2 px-3 rounded-[18px] min-h-[36px] break-words",{variants:{side:{left:"bg-lowest text-neutral-12 shadow-surface-sm outline outline-1 outline-neutral-11/[.08] rounded-bl-md",right:"ml-auto bg-accent-7 text-lowest rounded-br-md bubble-right"},transitionState:{entering:"opacity-0 translate-y-8",entered:"opacity-100 translate-y-0",exiting:"opacity-0 scale-0",exited:""}},defaultVariants:{side:"left"}}),fy={hidden:{y:"100%",scale:.75},shown:{y:0,scale:1}},hy=({children:e,className:t,transitionState:n,side:r,...o})=>b(qn.p,{variants:fy,initial:"hidden",animate:"shown",transition:{type:"spring",damping:25,stiffness:500},"data-transition":n,style:{transformOrigin:r==="left"?"0% 50%":"100% 50%"},class:dy({className:t,side:r,transitionState:n}),...o,children:e}),py=({className:e,...t})=>b("div",{"aria-label":"Typing…",class:Ut("flex gap-1 p-4",e),...t,children:Array.from({length:3},(n,r)=>b("div",{class:"bg-accent-7 h-1.5 w-1.5 animate-bounce rounded-full",style:{animationDelay:`${-r*200}ms`}}))}),my={bot:"left",user:"right"},vy=Gd("w-full select-none py-2 text-center text-[10px] uppercase tracking-widest drop-shadow-[0_1.5px_white]",{variants:{variant:{info:"text-neutral-8",warning:"text-[#FFC107]",error:"text-error-9",success:"text-[#4CAF50]"}}}),gy=({messages:e,isBotTyping:t})=>b("ol",{"aria-label":"Chat messages",class:"flex flex-grow flex-col justify-end gap-2 p-2 pt-[calc(var(--header-height)+1rem)]",children:[b(eo,{initial:!1,children:e.map((n,r)=>b("li",{class:"flex",children:tt(n).with({type:"system"},o=>b("p",{class:vy({variant:o.variant}),children:o.text})).with({type:"text",author:Ae.union("bot","user")},o=>b(hy,{side:my[o.author],children:o.text},r)).with({type:"link"},o=>b("div",{class:"bg-accent-8/5 flex w-full items-center justify-center overflow-hidden rounded-xl py-2",children:b("a",{class:"bg-lowest shadow-surface-sm ring-accent-8/20 hover:ring-accent-8 active:bg-accent-2 active:text-accent-10 text-accent-9 focus-visible:ring-accent-7/50 flex items-center gap-1.5 truncate rounded-full py-2 pl-4 pr-2.5 no-underline ring-1 transition-all focus:outline-none focus-visible:ring-4 focus-visible:ring-offset-2",target:"_blank",href:o.href,children:[o.text,b("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:b("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"})})]})})).with({type:"image"},o=>b("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=>b(A1,{class:o.author==="bot"?"":"ml-auto",file:{name:o.fileName,sizeKb:o.fileSizeKb}})).exhaustive()},r))}),b("aside",{"aria-hidden":!0,children:t&&b(py,{})})]}),by=25,yy=()=>{const e=U(null),[t,n]=ae(!1),[r,o]=ae(()=>()=>{}),i=de(()=>a=>{var c;return(c=e.current)==null?void 0:c.scrollTo({top:e.current.scrollHeight,...a})},[e]),s=de(()=>({send:async({message:a,signal:c,groupId:u})=>{if(await tt(a).with({author:"bot",type:"text"},async d=>{if(c!=null&&c.aborted)throw new Gn;n(!0);const l=Math.min(Math.max(20,d.text.length),100)*by;await new Promise(f=>setTimeout(f,l,{signal:c})),n(!1)}).otherwise(async()=>{}),c!=null&&c.aborted)throw new Gn;ne.addMessage(a,u)},input:async({input:a,signal:c})=>{if(c!=null&&c.aborted)throw new Gn;return ne.setInput(a),await new Promise(u=>{const d=l=>{if(c!=null&&c.aborted)throw new Gn;ne.setInput(void 0),a.key&&ne.setSubmission(a.key,l),u(l)};o(()=>d)})}}),[]);return{chatRef:e,chatService:s,isBotTyping:t,onSubmitSuccessFn:r,scrollToEnd:i}},wy=Object.freeze(Object.defineProperty({__proto__:null,JobApplicationContent:({currentApplication:e,logger:t,apiClient:n,analytics:r})=>{const{chatRef:o,chatService:i,isBotTyping:s,onSubmitSuccessFn:a,scrollToEnd:c}=yy(),u=nt.value,d=e.flow,l=e.job;return Be(()=>{u==="maximised"&&c({behavior:"instant"})},[c,u]),G(()=>{c({behavior:"smooth"})},[e.data.messages,c]),Be(()=>{const{state:f,application:h}=ne.current$.peek();if(f!=="loaded")throw new Error(Ev.invalid_state);const p=h.data.currentNodeId;if(c({behavior:"instant"}),ne.setInput(void 0),h.data.isFinished)return;ne.removeLastGroupMessagesById(p);const{interpret:m,abort:y}=c1({context:{jobId:l.id,flowId:d.id},analytics:r,apiClient:n,logger:t,flow:d.nodes,chatService:i,getSubmissions:()=>{var x;return(x=ne.current$.peek().application)==null?void 0:x.data.submissions},onInterpret:(x,g)=>{const w=ne.current$.peek().application;kr(w),w.data.sequence=w.data.sequence+1,r.log({event:"FLOW_NODE",properties:{flow_id:d.id,flow_version:d.version,job_id:l.id,from_node_id:g?g.id:null,to_node_id:x.id,sequence:w.data.sequence,flow_session_id:w.data.flowSessionId}}),ne.setCurrentNodeId(x.id)},onFlowEnd:async()=>{ne.markAsFinished()}});return m(p),y},[r,n,i,t,c,d,l.id,e.startedAt]),b(ue,{children:[b("div",{ref:o,className:"hide-scrollbars relative flex max-w-full flex-grow flex-col overflow-y-scroll",style:{WebkitOverflowScrolling:"touch",paddingBottom:ts.value},children:b(eo,{children:b(gy,{isBotTyping:s,messages:e.data.messages})})}),b(uy,{input:e.data.currentInput,onInputChange:()=>c({behavior:"smooth"}),onSubmit:a})]})}},Symbol.toStringTag,{value:"Module"}))})();
57
+ }`,s1=({_internal_domManager:e=fg(),theme:t})=>Pt(({apiClient:n,logger:r,analytics:o})=>{let i=!1;const s=()=>{if(typeof window>"u")return;const a=e.getOrCreateChatbotElement();e.addStyle(dg,"inploi-chatbot-style");const c=i1([{name:"a",colors:_d(t)},{name:"n",colors:_d({hue:t.hue,chroma:.1})}]);e.addStyle(c,"inploi-chatbot-theme"),Qt(N(jv,{apiClient:n,logger:r,analytics:o}),a),i=!0};return{prepare:async()=>{if(!(typeof window>"u"))try{if(i)return;s(),r.info("Chatbot plugin prepared")}catch(a){console.error(a),r.error("Error preparing chatbot plugin",a)}},startApplication:async({jobId:a})=>{if(!(typeof window>"u"))try{ne.cancel(),hf(()=>{nt.value="maximised",ne.current$.value={state:"loading"}}),ug({jobId:a,apiClient:n,logger:r}).then(async c=>{c.ok?(await o.log({event:"APPLY_START",properties:{job_id:a},customProperties:{flow_id:c.value.flow.id}}).catch(r.error),ne.start(c.value)):ne.current$.value={state:"error",error:c.error}}),i||s()}catch(c){console.error(c),r.error("Error starting application",c)}},closeApplication:async()=>{typeof window>"u"||(r.info("Closing application from an external source"),ne.cancel())}}});if(!window.inploi)throw new Error("Please insert the SDK script tag above the plugins.");window.inploi.chatbotPlugin=s1;const xd=({node:e,nodes:t,stopWhen:n})=>{if((n==null?void 0:n(e))===!0)return e;const r=e.nextId?t.find(o=>o.id===e.nextId):void 0;if(r)return xd({node:r,nodes:t,stopWhen:n})},a1=({childNode:e,nodes:t})=>{const r=t.filter(o=>o.type==="if-block").find(o=>{if(!o.branchId)return!1;const i=t.find(a=>a.id===o.branchId);if(!i)return!1;const s=xd({node:i,nodes:t,stopWhen:a=>a.id===e.id});return!(!s||s.id!==e.id)});if(r!=null&&r.nextId)return t.find(o=>o.id===r.nextId)},c1=({flow:e,analytics:t,logger:n,context:r,apiClient:o,getSubmissions:i,chatService:s,onFlowEnd:a,onInterpret:c})=>{const u=new AbortController,d=async(l,f)=>{const h=i();c==null||c(l,f);try{await l1({analytics:t,logger:n,apiClient:o,context:r,node:l,submissions:h,chat:{sendMessage:async p=>s.send({groupId:l.id,message:p,signal:u.signal}),userInput:async p=>s.input({input:p,signal:u.signal})},next:p=>{const m=p?e.find(y=>y.id===p):a1({childNode:l,nodes:e});return m?d(m,l):a==null?void 0:a(l)},end:()=>a==null?void 0:a(l)})}catch(p){if(p instanceof Gn)return;throw p}};return{interpret:async l=>{const f=e.find(h=>h.id===l)??mu(e);return d(f)},abort:()=>{u.abort()}}};async function l1(e){return await tt(e).with({node:{type:"text"}},h1).with({node:{type:"image"}},p1).with({node:{type:"question-text"}},m1).with({node:{type:"question-enum"}},g1).with({node:{type:"question-number"}},v1).with({node:{type:"question-boolean"}},b1).with({node:{type:"question-file"}},w1).with({node:{type:"question-address"}},y1).with({node:{type:"end-flow"}},_1).with({node:{type:"if-block"}},f1).with({node:{type:"jump"}},({node:t,next:n})=>n(t.data.targetId)).with({node:{type:"link"}},d1).with({node:{type:"integration-application-submit"}},u1).with({node:{type:"integration-workflow-get"}},()=>Error("Unreachable")).exhaustive()}async function u1({chat:e,next:t,node:n,logger:r,apiClient:o,submissions:i,context:s,analytics:a}){await e.userInput({type:"multiple-choice",key:void 0,config:{options:[{label:"Submit my application",value:"submit"}],maxSelected:1,minSelected:1}});const c=()=>{const d=typeof s.jobId=="string"?s.jobId:void 0;d&&a.log({event:"APPLY_COMPLETE",properties:{job_id:d}})};await e.sendMessage({type:"system",variant:"info",text:"Submitting your application…"});const u=await o.fetch("/flow/apply",{method:"POST",body:JSON.stringify({...s,type:n.data.type,ats:n.data.ats,integration_id:n.data.integrationId,anonymous_id:a.getAnonymousId(),submissions:Lv(i||{})})}).catch(d=>d);await tt(u).with({ats_data:{redirect_url:Ae.string}},async d=>{await e.sendMessage({type:"text",author:"bot",text:"Almost there! Please finalise your application on our partner’s website."});const l=a.getAnonymousId(),f=new URL(d.ats_data.redirect_url);l&&!f.searchParams.has("anonymous_id")&&f.searchParams.set("anonymous_id",l),c(),await e.sendMessage({type:"link",href:f.toString(),text:"Finalise application on partner"})}).with({success:!0},async()=>{c(),await e.sendMessage({type:"system",variant:"success",text:"Application submitted"}),t(n.nextId)}).otherwise(async d=>{r.error(d),await e.sendMessage({type:"system",variant:"error",text:"Failed to submit application"}),t(n.id)})}async function d1({chat:e,next:t,node:n}){await e.sendMessage({type:"link",href:n.data.href,text:n.data.cta}),t(n.nextId)}async function f1({submissions:e,next:t,node:n}){const r=x1(n,e)?n.branchId:n.nextId;t(r)}async function h1({chat:e,next:t,node:n}){await e.sendMessage({author:"bot",type:"text",text:n.data.text}),t(n.nextId)}async function p1({chat:e,next:t,node:n}){await e.sendMessage({author:"bot",type:"image",url:n.data.url,height:n.data.height,width:n.data.width}),t(n.nextId)}async function m1({chat:e,next:t,node:n}){await e.sendMessage({author:"bot",type:"text",text:n.data.question});const r=await e.userInput({key:n.data.key,type:"text",config:{placeholder:n.data.placeholder,format:n.data.format}});await e.sendMessage({author:"user",type:"text",text:r.value}),t(n.nextId)}async function v1({chat:e,next:t,node:n}){await e.sendMessage({author:"bot",type:"text",text:n.data.question});const r=await e.userInput({key:n.data.key,type:"text",config:{placeholder:n.data.placeholder,format:"text"}});await e.sendMessage({author:"user",type:"text",text:r.value}),t(n.nextId)}async function g1({chat:e,next:t,node:n}){await e.sendMessage({author:"bot",type:"text",text:n.data.question});const r=await e.userInput({key:n.data.key,type:"multiple-choice",config:n.data});await e.sendMessage({author:"user",type:"text",text:n.data.options.filter(o=>r.value.includes(o.value)).map(o=>o.label).join(", ")}),t(n.nextId)}async function b1({chat:e,next:t,node:n}){await e.sendMessage({author:"bot",type:"text",text:n.data.question});const o=(await e.userInput({key:n.data.key,type:"boolean",config:{labels:{true:n.data.trueLabel,false:n.data.falseLabel}}})).value,i={true:n.data.trueLabel,false:n.data.falseLabel};await e.sendMessage({author:"user",type:"text",text:i[o]}),t(n.nextId)}async function y1({chat:e,next:t,node:n}){await e.sendMessage({author:"bot",type:"text",text:"Address questions are not implemented yet"}),t(n.nextId)}async function w1({node:e,chat:t,next:n}){await t.sendMessage({author:"bot",type:"text",text:e.data.question});const r=await t.userInput({key:e.data.key,type:"file",config:{extensions:e.data.extensions,fileSizeLimitKib:e.data.maxSizeKb,allowMultiple:e.data.multiple===!0}});for await(const o of r.value)await t.sendMessage({author:"user",type:"file",fileName:o.name,fileSizeKb:o.sizeKb});n(e.nextId)}async function _1({chat:e,end:t,next:n,node:r}){await e.sendMessage({type:"system",variant:"info",text:r.data.systemMessage||"Conversation finished"}),t()}const kd=Ae.union(Ae.string,Ae.array(Ae.string)),x1=(e,t)=>{const n=t==null?void 0:t[e.data.compareKey];return n?tt({...e.data,answer:n}).with({compare:"equals"},({compareValue:r})=>typeof n.value=="string"||typeof n.value=="boolean"?r===n.value.toString():!1).with({compare:"notEquals"},({compareValue:r})=>typeof n.value=="string"||typeof n.value=="boolean"?r!==n.value.toString():!1).with({compare:"contains",answer:{value:kd}},({compareValue:r,answer:o})=>o.value.includes(r)).with({compare:"notContains",answer:{value:kd}},({compareValue:r,answer:o})=>!o.value.includes(r)).with({answer:{type:"file"}},()=>!1).exhaustive():!1},xo=({class:e,...t})=>b("button",{class:Ut("bg-accent-7 active:bg-accent-10 active:text-accent-2 text-lowest pointer-coarse:touch-hitbox focus-visible:ring-accent-7/50 flex-shrink-0 rounded-full p-2 transition-all focus:outline-none focus-visible:ring-4 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:b("svg",{class:"block",width:"16",height:"16",viewBox:"0 0 16 16",fill:"transparent",stroke:"currentColor","stroke-linecap":"round","stroke-width":"2",children:[b("title",{children:"Send"}),b("path",{d:"M3.5 7.5L8 3L12.5 7.5"}),b("path",{d:"M8 4V13"})]})}),Ns=()=>{const e=U(null);return G(()=>{var t;(t=e.current)==null||t.focus()},[]),e},$d=["true","false"],k1=Qv($d),$1="answer",S1=({input:e,onSubmitSuccess:t,onHeightChange:n})=>{const r=Ns();return n(),b("form",{noValidate:!0,class:"flex items-center gap-2",onSubmit:o=>{o.preventDefault();const i=tt(o).with({nativeEvent:{submitter:Ae.select(Ae.union(Ae.instanceOf(HTMLButtonElement),Ae.instanceOf(HTMLInputElement)))}},a=>a.value).otherwise(()=>{throw new Error("invalid form")}),s=ns(k1,i);t(s)},children:$d.map((o,i)=>b("button",{ref:i===0?r:null,type:"submit",name:$1,value:o,class:"bg-lowest ease-expo-out ring-neutral-12/5 text-neutral-12 active:ring-accent-7 active:bg-accent-2 active:text-accent-11 fr block flex-1 overflow-hidden rounded-2xl px-2.5 py-2.5 ring-2 transition-all duration-300 selection:bg-transparent",children:b("p",{class:"truncate text-center text-base",children:e.config.labels[o]})}))})},Is=({error:e,onAnimationComplete:t})=>b(eo,{children:e&&b(qn.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},onAnimationComplete:t,role:"alert",class:"text-error-11 flex max-w-full items-center gap-1 overflow-hidden rounded-full p-0.5 px-1 opacity-0",children:[b("svg",{class:"text-error-10",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b("circle",{cx:"8",cy:"8",r:"6.3",stroke:"currentColor","stroke-width":"1.4"}),b("rect",{x:"7",y:"4",width:"2",height:"5",fill:"currentColor"}),b("rect",{x:"7",y:"10",width:"2",height:"2",fill:"currentColor"})]}),b("p",{class:"truncate pr-1 text-sm",children:e.message})]})}),M1=e=>new Promise((t,n)=>{const r=new FileReader;r.readAsDataURL(e),r.onload=()=>r.result?t(r.result.toString()):n("No result from reader"),r.onerror=n}),ko=e=>tt(e).with(Ae.number.lte(1e3),()=>`${Math.round(e)}KB`).with(Ae.number.lt(1e3*10),()=>`${(e/1e3).toFixed(1)}MB`).otherwise(()=>`${Math.round(e/1e3)}MB`),T1=e=>e.reduce((t,n)=>t+n.sizeKb,0),C1=es("file"),Sd=3,A1=({file:e,class:t,...n})=>{const r=e.name.split(".").pop(),o=e.name.replace(new RegExp(`.${r}$`),"");return b("div",{class:Ut("bg-accent-1 outline-neutral-4 flex max-w-full gap-2 overflow-hidden rounded-lg px-3 py-2 text-sm outline",t),...n,children:[b("p",{"aria-label":"File name",class:"text-accent-12 flex flex-grow overflow-hidden",children:[b("span",{class:"block truncate",children:o}),b("span",{children:[".",r]})]}),b("p",{"aria-label":"File size",class:"text-neutral-10",children:ko(e.sizeKb)})]})},Md=({class:e,...t})=>b("li",{class:Ut("outline-neutral-6 text-neutral-11 bg-neutral-1 block rounded-md px-1 py-0.5 text-xs outline outline-1",e),...t}),P1=({input:e,onSubmitSuccess:t,onHeightChange:n})=>{var l;const r=(l=ne.current$.value.application)==null?void 0:l.data.submissions[e.key],[o,i]=ae(C1(r)?r.value:[]),[s,a]=ae(),c=o.length-Sd,u=T1(o),d=Ns();return b("form",{class:"flex flex-col gap-1",onSubmit:f=>(f.preventDefault(),a(void 0),o.length===0&&a({type:"required",message:"Please select a file"}),e.config.fileSizeLimitKib&&u>e.config.fileSizeLimitKib&&a({type:"max",message:`File size exceeds limit of ${ko(e.config.fileSizeLimitKib)}`}),t(o)),children:[b("div",{class:"flex items-center gap-2",children:[b("label",{ref:d,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:[o.length>0?b(ue,{children:[b("ul",{class:"flex max-w-full flex-wrap justify-center gap-1 overflow-hidden p-1",children:[o.slice(0,Sd).map(f=>{const h=f.name.split(".").pop(),p=f.name.replace(new RegExp(`.${h}$`),"");return b(Md,{class:"flex overflow-hidden",children:[b("span",{class:"block truncate",children:p}),b("span",{children:[".",h]})]})}),c>0?b(Md,{children:["+",c," file",c!==1?"s":""]}):null]}),b("p",{class:"text-neutral-11 text-xs",children:[ko(u)," ",o.length>1?"total":""]})]}):b("div",{class:"flex flex-col justify-center gap-4 pb-6 pt-5",children:[b("header",{class:"flex flex-col items-center gap-0",children:[b("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:b("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"})}),b("p",{class:"text-neutral-12 tracking-[-0.01em] dark:text-gray-400",children:[e.config.allowMultiple?"Select files":"Select a file"," to upload"]}),e.config.fileSizeLimitKib?b("p",{class:"text-neutral-10 text-xs",children:["(max ",ko(e.config.fileSizeLimitKib),")"]}):null]}),b("aside",{class:"flex flex-col items-center gap-2",children:[b("p",{id:"accepted-filetypes",class:"sr-only",children:"Accepted file extensions"}),b("ul",{"aria-describedby":"accepted-filetypes",class:"flex flex-wrap justify-center gap-2",children:e.config.extensions.map(f=>b("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:f.replace(".","")}))})]})]}),b("input",{id:"dropzone-file",onInput:async f=>{kr(f.target instanceof HTMLInputElement);const h=f.target.files?Array.from(f.target.files):[],p=await Promise.allSettled(h.map(async y=>{const x=await M1(y);return{name:y.name,data:x,sizeKb:y.size/1e3}}));if(p.some(({status:y})=>y==="rejected"))return a({type:"invalid",message:"Invalid file"});const m=p.map(y=>y.status==="fulfilled"?y.value:null).filter(Boolean);i(m)},multiple:e.config.allowMultiple,type:"file",class:"sr-only"})]}),b(xo,{disabled:o.length===0})]}),s&&b(Is,{onAnimationComplete:n,error:s})]})};var ar=e=>e.type==="checkbox",$n=e=>e instanceof Date,Me=e=>e==null;const Td=e=>typeof e=="object";var fe=e=>!Me(e)&&!Array.isArray(e)&&Td(e)&&!$n(e),E1=e=>fe(e)&&e.target?ar(e.target)?e.target.checked:e.target.value:e,V1=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,O1=(e,t)=>e.has(V1(t)),L1=e=>{const t=e.constructor&&e.constructor.prototype;return fe(t)&&t.hasOwnProperty("isPrototypeOf")},Ds=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function at(e){let t;const n=Array.isArray(e);if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else if(!(Ds&&(e instanceof Blob||e instanceof FileList))&&(n||fe(e)))if(t=n?[]:{},!n&&!L1(e))t=e;else for(const r in e)e.hasOwnProperty(r)&&(t[r]=at(e[r]));else return e;return t}var cr=e=>Array.isArray(e)?e.filter(Boolean):[],ie=e=>e===void 0,O=(e,t,n)=>{if(!t||!fe(e))return n;const r=cr(t.split(/[,[\].]+?/)).reduce((o,i)=>Me(o)?o:o[i],e);return ie(r)||r===e?ie(e[t])?n:e[t]:r},Mt=e=>typeof e=="boolean";const Cd={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},ze={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},ct={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"};Fe.createContext(null);var R1=(e,t,n,r=!0)=>{const o={defaultValues:t._defaultValues};for(const i in e)Object.defineProperty(o,i,{get:()=>{const s=i;return t._proxyFormState[s]!==ze.all&&(t._proxyFormState[s]=!r||ze.all),n&&(n[s]=!0),e[s]}});return o},Le=e=>fe(e)&&!Object.keys(e).length,N1=(e,t,n,r)=>{n(e);const{name:o,...i}=e;return Le(i)||Object.keys(i).length>=Object.keys(t).length||Object.keys(i).find(s=>t[s]===(!r||ze.all))},Fs=e=>Array.isArray(e)?e:[e];function I1(e){const t=Fe.useRef(e);t.current=e,Fe.useEffect(()=>{const n=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{n&&n.unsubscribe()}},[e.disabled])}var Ye=e=>typeof e=="string",D1=(e,t,n,r,o)=>Ye(e)?(r&&t.watch.add(e),O(n,e,o)):Array.isArray(e)?e.map(i=>(r&&t.watch.add(i),O(n,i))):(r&&(t.watchAll=!0),n),zs=e=>/^\w*$/.test(e),Ad=e=>cr(e.replace(/["|']|\]/g,"").split(/\.|\[/));function Q(e,t,n){let r=-1;const o=zs(t)?[t]:Ad(t),i=o.length,s=i-1;for(;++r<i;){const a=o[r];let c=n;if(r!==s){const u=e[a];c=fe(u)||Array.isArray(u)?u:isNaN(+o[r+1])?{}:[]}e[a]=c,e=e[a]}return e}var Pd=(e,t,n,r,o)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:o||!0}}:{},Ed=e=>({isOnSubmit:!e||e===ze.onSubmit,isOnBlur:e===ze.onBlur,isOnChange:e===ze.onChange,isOnAll:e===ze.all,isOnTouch:e===ze.onTouched}),Vd=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const $o=(e,t,n,r)=>{for(const o of n||Object.keys(e)){const i=O(e,o);if(i){const{_f:s,...a}=i;if(s){if(s.refs&&s.refs[0]&&t(s.refs[0],o)&&!r)break;if(s.ref&&t(s.ref,s.name)&&!r)break}else fe(a)&&$o(a,t)}}};var F1=(e,t,n)=>{const r=cr(O(e,n));return Q(r,"root",t[n]),Q(e,n,r),e},Bs=e=>e.type==="file",Tt=e=>typeof e=="function",So=e=>{if(!Ds)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Mo=e=>Ye(e),js=e=>e.type==="radio",To=e=>e instanceof RegExp;const Od={value:!1,isValid:!1},Ld={value:!0,isValid:!0};var Rd=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!ie(e[0].attributes.value)?ie(e[0].value)||e[0].value===""?Ld:{value:e[0].value,isValid:!0}:Ld:Od}return Od};const Nd={isValid:!1,value:null};var Id=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,Nd):Nd;function Dd(e,t,n="validate"){if(Mo(e)||Array.isArray(e)&&e.every(Mo)||Mt(e)&&!e)return{type:n,message:Mo(e)?e:"",ref:t}}var Sn=e=>fe(e)&&!To(e)?e:{value:e,message:""},Fd=async(e,t,n,r,o)=>{const{ref:i,refs:s,required:a,maxLength:c,minLength:u,min:d,max:l,pattern:f,validate:h,name:p,valueAsNumber:m,mount:y,disabled:x}=e._f,g=O(t,p);if(!y||x)return{};const w=s?s[0]:i,M=j=>{r&&w.reportValidity&&(w.setCustomValidity(Mt(j)?"":j||""),w.reportValidity())},S={},I=js(i),R=ar(i),C=I||R,E=(m||Bs(i))&&ie(i.value)&&ie(g)||So(i)&&i.value===""||g===""||Array.isArray(g)&&!g.length,q=Pd.bind(null,p,n,S),K=(j,B,H,X=ct.maxLength,re=ct.minLength)=>{const se=j?B:H;S[p]={type:j?X:re,message:se,ref:i,...q(j?X:re,se)}};if(o?!Array.isArray(g)||!g.length:a&&(!C&&(E||Me(g))||Mt(g)&&!g||R&&!Rd(s).isValid||I&&!Id(s).isValid)){const{value:j,message:B}=Mo(a)?{value:!!a,message:a}:Sn(a);if(j&&(S[p]={type:ct.required,message:B,ref:w,...q(ct.required,B)},!n))return M(B),S}if(!E&&(!Me(d)||!Me(l))){let j,B;const H=Sn(l),X=Sn(d);if(!Me(g)&&!isNaN(g)){const re=i.valueAsNumber||g&&+g;Me(H.value)||(j=re>H.value),Me(X.value)||(B=re<X.value)}else{const re=i.valueAsDate||new Date(g),se=lt=>new Date(new Date().toDateString()+" "+lt),Re=i.type=="time",Ne=i.type=="week";Ye(H.value)&&g&&(j=Re?se(g)>se(H.value):Ne?g>H.value:re>new Date(H.value)),Ye(X.value)&&g&&(B=Re?se(g)<se(X.value):Ne?g<X.value:re<new Date(X.value))}if((j||B)&&(K(!!j,H.message,X.message,ct.max,ct.min),!n))return M(S[p].message),S}if((c||u)&&!E&&(Ye(g)||o&&Array.isArray(g))){const j=Sn(c),B=Sn(u),H=!Me(j.value)&&g.length>+j.value,X=!Me(B.value)&&g.length<+B.value;if((H||X)&&(K(H,j.message,B.message),!n))return M(S[p].message),S}if(f&&!E&&Ye(g)){const{value:j,message:B}=Sn(f);if(To(j)&&!g.match(j)&&(S[p]={type:ct.pattern,message:B,ref:i,...q(ct.pattern,B)},!n))return M(B),S}if(h){if(Tt(h)){const j=await h(g,t),B=Dd(j,w);if(B&&(S[p]={...B,...q(ct.validate,B.message)},!n))return M(B.message),S}else if(fe(h)){let j={};for(const B in h){if(!Le(j)&&!n)break;const H=Dd(await h[B](g,t),w,B);H&&(j={...H,...q(B,H.message)},M(H.message),n&&(S[p]=j))}if(!Le(j)&&(S[p]={ref:w,...j},!n))return S}}return M(!0),S};function z1(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=ie(e)?r++:e[t[r++]];return e}function B1(e){for(const t in e)if(e.hasOwnProperty(t)&&!ie(e[t]))return!1;return!0}function ye(e,t){const n=Array.isArray(t)?t:zs(t)?[t]:Ad(t),r=n.length===1?e:z1(e,n),o=n.length-1,i=n[o];return r&&delete r[i],o!==0&&(fe(r)&&Le(r)||Array.isArray(r)&&B1(r))&&ye(e,n.slice(0,-1)),e}function Hs(){let e=[];return{get observers(){return e},next:o=>{for(const i of e)i.next&&i.next(o)},subscribe:o=>(e.push(o),{unsubscribe:()=>{e=e.filter(i=>i!==o)}}),unsubscribe:()=>{e=[]}}}var Co=e=>Me(e)||!Td(e);function Kt(e,t){if(Co(e)||Co(t))return e===t;if($n(e)&&$n(t))return e.getTime()===t.getTime();const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n){const i=e[o];if(!r.includes(o))return!1;if(o!=="ref"){const s=t[o];if($n(i)&&$n(s)||fe(i)&&fe(s)||Array.isArray(i)&&Array.isArray(s)?!Kt(i,s):i!==s)return!1}}return!0}var zd=e=>e.type==="select-multiple",j1=e=>js(e)||ar(e),Us=e=>So(e)&&e.isConnected,Bd=e=>{for(const t in e)if(Tt(e[t]))return!0;return!1};function Ao(e,t={}){const n=Array.isArray(e);if(fe(e)||n)for(const r in e)Array.isArray(e[r])||fe(e[r])&&!Bd(e[r])?(t[r]=Array.isArray(e[r])?[]:{},Ao(e[r],t[r])):Me(e[r])||(t[r]=!0);return t}function jd(e,t,n){const r=Array.isArray(e);if(fe(e)||r)for(const o in e)Array.isArray(e[o])||fe(e[o])&&!Bd(e[o])?ie(t)||Co(n[o])?n[o]=Array.isArray(e[o])?Ao(e[o],[]):{...Ao(e[o])}:jd(e[o],Me(t)?{}:t[o],n[o]):n[o]=!Kt(e[o],t[o]);return n}var Xs=(e,t)=>jd(e,t,Ao(t)),Hd=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>ie(e)?e:t?e===""?NaN:e&&+e:n&&Ye(e)?new Date(e):r?r(e):e;function qs(e){const t=e.ref;if(!(e.refs?e.refs.every(n=>n.disabled):t.disabled))return Bs(t)?t.files:js(t)?Id(e.refs).value:zd(t)?[...t.selectedOptions].map(({value:n})=>n):ar(t)?Rd(e.refs).value:Hd(ie(t.value)?e.ref.value:t.value,e)}var H1=(e,t,n,r)=>{const o={};for(const i of e){const s=O(t,i);s&&Q(o,i,s._f)}return{criteriaMode:n,names:[...e],fields:o,shouldUseNativeValidation:r}},lr=e=>ie(e)?e:To(e)?e.source:fe(e)?To(e.value)?e.value.source:e.value:e,U1=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function Ud(e,t,n){const r=O(e,n);if(r||zs(n))return{error:r,name:n};const o=n.split(".");for(;o.length;){const i=o.join("."),s=O(t,i),a=O(e,i);if(s&&!Array.isArray(s)&&n!==i)return{name:n};if(a&&a.type)return{name:i,error:a};o.pop()}return{name:n}}var X1=(e,t,n,r,o)=>o.isOnAll?!1:!n&&o.isOnTouch?!(t||e):(n?r.isOnBlur:o.isOnBlur)?!e:(n?r.isOnChange:o.isOnChange)?e:!0,q1=(e,t)=>!cr(O(e,t)).length&&ye(e,t);const W1={mode:ze.onSubmit,reValidateMode:ze.onChange,shouldFocusError:!0};function K1(e={},t){let n={...W1,...e},r={submitCount:0,isDirty:!1,isLoading:Tt(n.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},errors:{},disabled:!1},o={},i=fe(n.defaultValues)||fe(n.values)?at(n.defaultValues||n.values)||{}:{},s=n.shouldUnregister?{}:at(i),a={action:!1,mount:!1,watch:!1},c={mount:new Set,unMount:new Set,array:new Set,watch:new Set},u,d=0;const l={isDirty:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},f={values:Hs(),array:Hs(),state:Hs()},h=e.resetOptions&&e.resetOptions.keepDirtyValues,p=Ed(n.mode),m=Ed(n.reValidateMode),y=n.criteriaMode===ze.all,x=v=>_=>{clearTimeout(d),d=setTimeout(v,_)},g=async v=>{if(l.isValid||v){const _=n.resolver?Le((await E()).errors):await K(o,!0);_!==r.isValid&&f.state.next({isValid:_})}},w=v=>l.isValidating&&f.state.next({isValidating:v}),M=(v,_=[],k,L,P=!0,T=!0)=>{if(L&&k){if(a.action=!0,T&&Array.isArray(O(o,v))){const D=k(O(o,v),L.argA,L.argB);P&&Q(o,v,D)}if(T&&Array.isArray(O(r.errors,v))){const D=k(O(r.errors,v),L.argA,L.argB);P&&Q(r.errors,v,D),q1(r.errors,v)}if(l.touchedFields&&T&&Array.isArray(O(r.touchedFields,v))){const D=k(O(r.touchedFields,v),L.argA,L.argB);P&&Q(r.touchedFields,v,D)}l.dirtyFields&&(r.dirtyFields=Xs(i,s)),f.state.next({name:v,isDirty:B(v,_),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else Q(s,v,_)},S=(v,_)=>{Q(r.errors,v,_),f.state.next({errors:r.errors})},I=(v,_,k,L)=>{const P=O(o,v);if(P){const T=O(s,v,ie(k)?O(i,v):k);ie(T)||L&&L.defaultChecked||_?Q(s,v,_?T:qs(P._f)):re(v,T),a.mount&&g()}},R=(v,_,k,L,P)=>{let T=!1,D=!1;const ee={name:v};if(!k||L){l.isDirty&&(D=r.isDirty,r.isDirty=ee.isDirty=B(),T=D!==ee.isDirty);const le=Kt(O(i,v),_);D=O(r.dirtyFields,v),le?ye(r.dirtyFields,v):Q(r.dirtyFields,v,!0),ee.dirtyFields=r.dirtyFields,T=T||l.dirtyFields&&D!==!le}if(k){const le=O(r.touchedFields,v);le||(Q(r.touchedFields,v,k),ee.touchedFields=r.touchedFields,T=T||l.touchedFields&&le!==k)}return T&&P&&f.state.next(ee),T?ee:{}},C=(v,_,k,L)=>{const P=O(r.errors,v),T=l.isValid&&Mt(_)&&r.isValid!==_;if(e.delayError&&k?(u=x(()=>S(v,k)),u(e.delayError)):(clearTimeout(d),u=null,k?Q(r.errors,v,k):ye(r.errors,v)),(k?!Kt(P,k):P)||!Le(L)||T){const D={...L,...T&&Mt(_)?{isValid:_}:{},errors:r.errors,name:v};r={...r,...D},f.state.next(D)}w(!1)},E=async v=>n.resolver(s,n.context,H1(v||c.mount,o,n.criteriaMode,n.shouldUseNativeValidation)),q=async v=>{const{errors:_}=await E(v);if(v)for(const k of v){const L=O(_,k);L?Q(r.errors,k,L):ye(r.errors,k)}else r.errors=_;return _},K=async(v,_,k={valid:!0})=>{for(const L in v){const P=v[L];if(P){const{_f:T,...D}=P;if(T){const ee=c.array.has(T.name),le=await Fd(P,s,y,n.shouldUseNativeValidation&&!_,ee);if(le[T.name]&&(k.valid=!1,_))break;!_&&(O(le,T.name)?ee?F1(r.errors,le,T.name):Q(r.errors,T.name,le[T.name]):ye(r.errors,T.name))}D&&await K(D,_,k)}}return k.valid},j=()=>{for(const v of c.unMount){const _=O(o,v);_&&(_._f.refs?_._f.refs.every(k=>!Us(k)):!Us(_._f.ref))&&Ze(v)}c.unMount=new Set},B=(v,_)=>(v&&_&&Q(s,v,_),!Kt(Ie(),i)),H=(v,_,k)=>D1(v,c,{...a.mount?s:ie(_)?i:Ye(v)?{[v]:_}:_},k,_),X=v=>cr(O(a.mount?s:i,v,e.shouldUnregister?O(i,v,[]):[])),re=(v,_,k={})=>{const L=O(o,v);let P=_;if(L){const T=L._f;T&&(!T.disabled&&Q(s,v,Hd(_,T)),P=So(T.ref)&&Me(_)?"":_,zd(T.ref)?[...T.ref.options].forEach(D=>D.selected=P.includes(D.value)):T.refs?ar(T.ref)?T.refs.length>1?T.refs.forEach(D=>(!D.defaultChecked||!D.disabled)&&(D.checked=Array.isArray(P)?!!P.find(ee=>ee===D.value):P===D.value)):T.refs[0]&&(T.refs[0].checked=!!P):T.refs.forEach(D=>D.checked=D.value===P):Bs(T.ref)?T.ref.value="":(T.ref.value=P,T.ref.type||f.values.next({name:v,values:{...s}})))}(k.shouldDirty||k.shouldTouch)&&R(v,P,k.shouldTouch,k.shouldDirty,!0),k.shouldValidate&&Y(v)},se=(v,_,k)=>{for(const L in _){const P=_[L],T=`${v}.${L}`,D=O(o,T);(c.array.has(v)||!Co(P)||D&&!D._f)&&!$n(P)?se(T,P,k):re(T,P,k)}},Re=(v,_,k={})=>{const L=O(o,v),P=c.array.has(v),T=at(_);Q(s,v,T),P?(f.array.next({name:v,values:{...s}}),(l.isDirty||l.dirtyFields)&&k.shouldDirty&&f.state.next({name:v,dirtyFields:Xs(i,s),isDirty:B(v,T)})):L&&!L._f&&!Me(T)?se(v,T,k):re(v,T,k),Vd(v,c)&&f.state.next({...r}),f.values.next({name:v,values:{...s}}),!a.mount&&t()},Ne=async v=>{const _=v.target;let k=_.name,L=!0;const P=O(o,k),T=()=>_.type?qs(P._f):E1(v),D=ee=>{L=Number.isNaN(ee)||ee===O(s,k,ee)};if(P){let ee,le;const Oo=T(),Mn=v.type===Cd.BLUR||v.type===Cd.FOCUS_OUT,_y=!U1(P._f)&&!n.resolver&&!O(r.errors,k)&&!P._f.deps||X1(Mn,O(r.touchedFields,k),r.isSubmitted,m,p),Ws=Vd(k,c,Mn);Q(s,k,Oo),Mn?(P._f.onBlur&&P._f.onBlur(v),u&&u(0)):P._f.onChange&&P._f.onChange(v);const Ks=R(k,Oo,Mn,!1),xy=!Le(Ks)||Ws;if(!Mn&&f.values.next({name:k,type:v.type,values:{...s}}),_y)return l.isValid&&g(),xy&&f.state.next({name:k,...Ws?{}:Ks});if(!Mn&&Ws&&f.state.next({...r}),w(!0),n.resolver){const{errors:Qd}=await E([k]);if(D(Oo),L){const ky=Ud(r.errors,o,k),ef=Ud(Qd,o,ky.name||k);ee=ef.error,k=ef.name,le=Le(Qd)}}else ee=(await Fd(P,s,y,n.shouldUseNativeValidation))[k],D(Oo),L&&(ee?le=!1:l.isValid&&(le=await K(o,!0)));L&&(P._f.deps&&Y(P._f.deps),C(k,le,ee,Ks))}},lt=(v,_)=>{if(O(r.errors,_)&&v.focus)return v.focus(),1},Y=async(v,_={})=>{let k,L;const P=Fs(v);if(w(!0),n.resolver){const T=await q(ie(v)?v:P);k=Le(T),L=v?!P.some(D=>O(T,D)):k}else v?(L=(await Promise.all(P.map(async T=>{const D=O(o,T);return await K(D&&D._f?{[T]:D}:D)}))).every(Boolean),!(!L&&!r.isValid)&&g()):L=k=await K(o);return f.state.next({...!Ye(v)||l.isValid&&k!==r.isValid?{}:{name:v},...n.resolver||!v?{isValid:k}:{},errors:r.errors,isValidating:!1}),_.shouldFocus&&!L&&$o(o,lt,v?P:c.mount),L},Ie=v=>{const _={...i,...a.mount?s:{}};return ie(v)?_:Ye(v)?O(_,v):v.map(k=>O(_,k))},Ct=(v,_)=>({invalid:!!O((_||r).errors,v),isDirty:!!O((_||r).dirtyFields,v),isTouched:!!O((_||r).touchedFields,v),error:O((_||r).errors,v)}),At=v=>{v&&Fs(v).forEach(_=>ye(r.errors,_)),f.state.next({errors:v?r.errors:{}})},Yt=(v,_,k)=>{const L=(O(o,v,{_f:{}})._f||{}).ref;Q(r.errors,v,{..._,ref:L}),f.state.next({name:v,errors:r.errors,isValid:!1}),k&&k.shouldFocus&&L&&L.focus&&L.focus()},Ge=(v,_)=>Tt(v)?f.values.subscribe({next:k=>v(H(void 0,_),k)}):H(v,_,!0),Ze=(v,_={})=>{for(const k of v?Fs(v):c.mount)c.mount.delete(k),c.array.delete(k),_.keepValue||(ye(o,k),ye(s,k)),!_.keepError&&ye(r.errors,k),!_.keepDirty&&ye(r.dirtyFields,k),!_.keepTouched&&ye(r.touchedFields,k),!n.shouldUnregister&&!_.keepDefaultValue&&ye(i,k);f.values.next({values:{...s}}),f.state.next({...r,..._.keepDirty?{isDirty:B()}:{}}),!_.keepIsValid&&g()},Eo=({disabled:v,name:_,field:k,fields:L,value:P})=>{if(Mt(v)){const T=v?void 0:ie(P)?qs(k?k._f:O(L,_)._f):P;Q(s,_,T),R(_,T,!1,!1,!0)}},Gt=(v,_={})=>{let k=O(o,v);const L=Mt(_.disabled);return Q(o,v,{...k||{},_f:{...k&&k._f?k._f:{ref:{name:v}},name:v,mount:!0,..._}}),c.mount.add(v),k?Eo({field:k,disabled:_.disabled,name:v}):I(v,!0,_.value),{...L?{disabled:_.disabled}:{},...n.progressive?{required:!!_.required,min:lr(_.min),max:lr(_.max),minLength:lr(_.minLength),maxLength:lr(_.maxLength),pattern:lr(_.pattern)}:{},name:v,onChange:Ne,onBlur:Ne,ref:P=>{if(P){Gt(v,_),k=O(o,v);const T=ie(P.value)&&P.querySelectorAll&&P.querySelectorAll("input,select,textarea")[0]||P,D=j1(T),ee=k._f.refs||[];if(D?ee.find(le=>le===T):T===k._f.ref)return;Q(o,v,{_f:{...k._f,...D?{refs:[...ee.filter(Us),T,...Array.isArray(O(i,v))?[{}]:[]],ref:{type:T.type,name:v}}:{ref:T}}}),I(v,!1,void 0,T)}else k=O(o,v,{}),k._f&&(k._f.mount=!1),(n.shouldUnregister||_.shouldUnregister)&&!(O1(c.array,v)&&a.action)&&c.unMount.add(v)}}},Zt=()=>n.shouldFocusError&&$o(o,lt,c.mount),ut=v=>{Mt(v)&&(f.state.next({disabled:v}),$o(o,_=>{_.disabled=v},0,!1))},ur=(v,_)=>async k=>{k&&(k.preventDefault&&k.preventDefault(),k.persist&&k.persist());let L=at(s);if(f.state.next({isSubmitting:!0}),n.resolver){const{errors:P,values:T}=await E();r.errors=P,L=T}else await K(o);ye(r.errors,"root"),Le(r.errors)?(f.state.next({errors:{}}),await v(L,k)):(_&&await _({...r.errors},k),Zt(),setTimeout(Zt)),f.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Le(r.errors),submitCount:r.submitCount+1,errors:r.errors})},Vo=(v,_={})=>{O(o,v)&&(ie(_.defaultValue)?Re(v,O(i,v)):(Re(v,_.defaultValue),Q(i,v,_.defaultValue)),_.keepTouched||ye(r.touchedFields,v),_.keepDirty||(ye(r.dirtyFields,v),r.isDirty=_.defaultValue?B(v,O(i,v)):B()),_.keepError||(ye(r.errors,v),l.isValid&&g()),f.state.next({...r}))},Zd=(v,_={})=>{const k=v?at(v):i,L=at(k),P=v&&!Le(v)?L:i;if(_.keepDefaultValues||(i=k),!_.keepValues){if(_.keepDirtyValues||h)for(const T of c.mount)O(r.dirtyFields,T)?Q(P,T,O(s,T)):Re(T,O(P,T));else{if(Ds&&ie(v))for(const T of c.mount){const D=O(o,T);if(D&&D._f){const ee=Array.isArray(D._f.refs)?D._f.refs[0]:D._f.ref;if(So(ee)){const le=ee.closest("form");if(le){le.reset();break}}}}o={}}s=e.shouldUnregister?_.keepDefaultValues?at(i):{}:at(P),f.array.next({values:{...P}}),f.values.next({values:{...P}})}c={mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},!a.mount&&t(),a.mount=!l.isValid||!!_.keepIsValid,a.watch=!!e.shouldUnregister,f.state.next({submitCount:_.keepSubmitCount?r.submitCount:0,isDirty:_.keepDirty?r.isDirty:!!(_.keepDefaultValues&&!Kt(v,i)),isSubmitted:_.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:_.keepDirtyValues?r.dirtyFields:_.keepDefaultValues&&v?Xs(i,v):{},touchedFields:_.keepTouched?r.touchedFields:{},errors:_.keepErrors?r.errors:{},isSubmitSuccessful:_.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1})},Jd=(v,_)=>Zd(Tt(v)?v(s):v,_);return{control:{register:Gt,unregister:Ze,getFieldState:Ct,handleSubmit:ur,setError:Yt,_executeSchema:E,_getWatch:H,_getDirty:B,_updateValid:g,_removeUnmounted:j,_updateFieldArray:M,_updateDisabledField:Eo,_getFieldArray:X,_reset:Zd,_resetDefaultValues:()=>Tt(n.defaultValues)&&n.defaultValues().then(v=>{Jd(v,n.resetOptions),f.state.next({isLoading:!1})}),_updateFormState:v=>{r={...r,...v}},_disableForm:ut,_subjects:f,_proxyFormState:l,get _fields(){return o},get _formValues(){return s},get _state(){return a},set _state(v){a=v},get _defaultValues(){return i},get _names(){return c},set _names(v){c=v},get _formState(){return r},set _formState(v){r=v},get _options(){return n},set _options(v){n={...n,...v}}},trigger:Y,register:Gt,handleSubmit:ur,watch:Ge,setValue:Re,getValues:Ie,reset:Jd,resetField:Vo,clearErrors:At,unregister:Ze,setError:Yt,setFocus:(v,_={})=>{const k=O(o,v),L=k&&k._f;if(L){const P=L.refs?L.refs[0]:L.ref;P.focus&&(P.focus(),_.shouldSelect&&P.select())}},getFieldState:Ct}}function Xd(e={}){const t=Fe.useRef(),n=Fe.useRef(),[r,o]=Fe.useState({isDirty:!1,isValidating:!1,isLoading:Tt(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},errors:{},disabled:!1,defaultValues:Tt(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...K1(e,()=>o(s=>({...s}))),formState:r});const i=t.current.control;return i._options=e,I1({subject:i._subjects.state,next:s=>{N1(s,i._proxyFormState,i._updateFormState,!0)&&o({...i._formState})}}),Fe.useEffect(()=>i._disableForm(e.disabled),[i,e.disabled]),Fe.useEffect(()=>{if(i._proxyFormState.isDirty){const s=i._getDirty();s!==r.isDirty&&i._subjects.state.next({isDirty:s})}},[i,r.isDirty]),Fe.useEffect(()=>{e.values&&!Kt(e.values,n.current)?(i._reset(e.values,i._options.resetOptions),n.current=e.values):i._resetDefaultValues()},[e.values,i]),Fe.useEffect(()=>{i._state.mount||(i._updateValid(),i._state.mount=!0),i._state.watch&&(i._state.watch=!1,i._subjects.state.next({...i._formState})),i._removeUnmounted()}),t.current.formState=R1(r,i),t.current}var qd=function(e,t,n){if(e&&"reportValidity"in e){var r=O(n,t);e.setCustomValidity(r&&r.message||""),e.reportValidity()}},Y1=function(e,t){var n=function(o){var i=t.fields[o];i&&i.ref&&"reportValidity"in i.ref?qd(i.ref,o,e):i.refs&&i.refs.forEach(function(s){return qd(s,o,e)})};for(var r in t.fields)n(r)},G1=function(e,t){t.shouldUseNativeValidation&&Y1(e,t);var n={};for(var r in e){var o=O(t.fields,r),i=Object.assign(e[r]||{},{ref:o&&o.ref});if(J1(t.names||Object.keys(e),r)){var s=Object.assign({},Z1(O(n,r)));Q(s,"root",i),Q(n,r,s)}else Q(n,r,i)}return n},Z1=function(e){return Array.isArray(e)?e.filter(Boolean):[]},J1=function(e,t){return e.some(function(n){return n.startsWith(t+".")})},Q1=function(e,t){for(var n={};e.issues.length;){var r=e.issues[0];if(r.path){var o=r.path.map(function(a){return a.key}).join(".");if(n[o]||(n[o]={message:r.message,type:r.validation}),t){var i=n[o].types,s=i&&i[r.validation];n[o]=Pd(o,t,n,r.validation,s?[].concat(s,r.message):r.message)}e.issues.shift()}}return n},Wd=function(e,t,n){return n===void 0&&(n={}),function(r,o,i){try{return Promise.resolve(function(s,a){try{var c=function(){function u(l){return{values:n.raw?r:l,errors:{}}}var d=Object.assign({},{abortEarly:!1,abortPipeEarly:!1},t);return n.mode==="sync"?u(ns(e,r,d)):Promise.resolve(rg(e,r,d)).then(u)}()}catch(u){return a(u)}return c&&c.then?c.then(void 0,a):c}(0,function(s){if(s instanceof io)return{values:{},errors:G1(Q1(s,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw s}))}catch(s){return Promise.reject(s)}}};const ey=e=>{const t=Object.fromEntries(new FormData(e).entries());Object.keys(t).length&&e.dispatchEvent(new Event("submit",{bubbles:!0}))},ty=es("multiple-choice"),ny=e=>{const t={min:e.minSelected??0,max:e.maxSelected??e.options.length};return Wd(vn({checked:xu(ng(Gv()),n=>Object.entries(n).filter(([r,o])=>o).map(([r,o])=>r),[sg(t.max,`Please select at most ${t.max} option${t.max!==1?"s":""}`),ku(t.min,`Please select at least ${t.min} option${t.min!==1?"s":""}`)])}))},ry=({input:e,onSubmitSuccess:t,onHeightChange:n})=>{var u,d;const r=e.key?(u=ne.current$.value.application)==null?void 0:u.data.submissions[e.key]:void 0,{register:o,handleSubmit:i,formState:{errors:s}}=Xd({defaultValues:{checked:ty(r)?Object.fromEntries(r.value.map(l=>[l,!0])):{}},resolver:ny(e.config)}),a=Ns(),c=e.config.minSelected===1&&e.config.maxSelected===1;return b("form",{noValidate:!0,class:"flex flex-col gap-1",onChange:l=>{c&&ey(l.currentTarget)},onSubmit:i(l=>{const f=l.checked;t(f)}),children:[b("div",{class:"flex items-center gap-2",children:[b("div",{class:Ut("flex w-full flex-1 flex-wrap gap-3 p-1",{"justify-center":e.config.options.length===1}),children:e.config.options.map((l,f)=>{const h=`checked.${l.value}`,{ref:p,...m}=o(h);return b("div",{children:[b("input",{autoFocus:f===0,ref:y=>{y&&f===0&&(a.current=y),p(y)},id:h,...m,class:"peer sr-only",type:"checkbox"}),b("label",{class:"bg-lowest peer-focus-visible:ring-accent-7 active:outline-neutral-10 ease-expo-out outline-neutral-12/5 text-neutral-11 peer-checked:outline-accent-7 peer-checked:bg-accent-2 peer-checked:text-accent-9 block rounded-2xl px-2.5 py-1 outline outline-2 ring-0 ring-transparent transition-all duration-300 selection:bg-transparent peer-focus-visible:ring-4 peer-focus-visible:ring-offset-2",htmlFor:h,children:l.label})]},l.value)})}),!c&&b(xo,{})]}),b(Is,{onAnimationComplete:n,error:(d=s.checked)==null?void 0:d.root})]})},Po={email:"That doesn’t look like a valid email address",phone:"That doesn’t look like a valid phone number"},oy=We(Po.phone,[ag(/^\+?[0-9 -]+$/,Po.phone)]),iy={email:We(Po.email,[ig(Po.email)]),phone:xu(oy,e=>e.replace(/[^0-9]/g,"")),text:We([ku(1,"Please enter some text")]),url:We([cg("That doesn’t look like a valid URL")])},sy={email:{type:"email",inputMode:"email",formNoValidate:!0},phone:{type:"tel",inputMode:"tel"},text:{type:"text",inputMode:"text"},url:{type:"url",inputMode:"url",formNoValidate:!0}},ay=es("text"),cy=e=>Wd(vn({text:iy[e.format]})),ly=({input:e,onSubmitSuccess:t,onHeightChange:n})=>{var d;const r=e.key?(d=ne.current$.value.application)==null?void 0:d.data.submissions[e.key]:void 0,{register:o,handleSubmit:i,formState:{errors:s}}=Xd({defaultValues:{text:ay(r)?r.value:""},resolver:cy(e.config)}),{ref:a,...c}=o("text",{required:!0}),u=U();return Be(()=>{u.current&&(u.current.focus(),u.current.select())},[]),b("form",{noValidate:!0,class:"flex flex-col gap-1",onSubmit:i(l=>{t(l.text)}),children:[b("div",{class:"flex items-center gap-2",children:[b("input",{id:"chat-input",...c,...sy[e.config.format],autocomplete:"off",autoCapitalize:"off",autoCorrect:"off",autoFocus:!0,ref:l=>{l&&(u.current=l),a(l)},class:"outline-neutral-12/5 ease-expo-out placeholder:text-neutral-5 focus-visible:outline-accent-7 caret-accent-9 flex-grow rounded-full px-3 py-1 text-base outline outline-2 transition-all duration-300",placeholder:e.config.placeholder}),b(xo,{})]}),b(Is,{onAnimationComplete:n,error:s.text})]})},uy=({onSubmit:e,onInputChange:t,input:n})=>{const r=U(null),o=me(()=>{r.current&&(ts.value=r.current.getBoundingClientRect().height)},[]);G(()=>{o(),t(n==null?void 0:n.type)},[n==null?void 0:n.type,t,o]);const i=s=>a=>e({type:s,value:a});return b(qn.div,{initial:{height:0},animate:{height:ts.value},exit:{height:0,opacity:0},class:"bg-neutral-2/80 absolute bottom-0 w-full overflow-hidden rounded-b-3xl backdrop-blur-md backdrop-saturate-150",children:b("div",{ref:r,class:"border-neutral-12/5 border-t p-2.5",children:tt({application:ne,input:n,onHeightChange:o}).with({input:Ae.nullish},()=>b("div",{class:"flex items-center gap-2",children:[b("input",{"aria-hidden":"true",id:"chat-input",class:"outline-neutral-12/5 placeholder:text-neutral-4 focus-visible:outline-accent-9 caret-accent-9 flex-grow rounded-full px-3 py-1 text-base outline outline-2",disabled:!0}),b(xo,{disabled:!0,"aria-hidden":"true",tabIndex:-1})]})).with({input:{type:"text"}},s=>b(ly,{onSubmitSuccess:i(s.input.type),...s})).with({input:{type:"multiple-choice"}},s=>b(ry,{onSubmitSuccess:i(s.input.type),...s})).with({input:{type:"boolean"}},s=>b(S1,{onSubmitSuccess:i(s.input.type),...s})).with({input:{type:"file"}},s=>b(P1,{onSubmitSuccess:i(s.input.type),...s})).exhaustive()})})},Kd=e=>typeof e=="boolean"?"".concat(e):e===0?"0":e,Yd=Ut,Gd=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return Yd(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:i}=t,s=Object.keys(o).map(u=>{const d=n==null?void 0:n[u],l=i==null?void 0:i[u];if(d===null)return null;const f=Kd(d)||Kd(l);return o[u][f]}),a=n&&Object.entries(n).reduce((u,d)=>{let[l,f]=d;return f===void 0||(u[l]=f),u},{}),c=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((u,d)=>{let{class:l,className:f,...h}=d;return Object.entries(h).every(p=>{let[m,y]=p;return Array.isArray(y)?y.includes({...i,...a}[m]):{...i,...a}[m]===y})?[...u,l,f]:u},[]);return Yd(e,s,c,n==null?void 0:n.class,n==null?void 0:n.className)},dy=Gd("max-w-[min(100%,24rem)] [text-wrap:pretty] leading-snug flex-shrink-1 min-w-[2rem] text-md py-2 px-3 rounded-[18px] min-h-[36px] break-words",{variants:{side:{left:"bg-lowest text-neutral-12 shadow-surface-sm outline outline-1 outline-neutral-11/[.08] rounded-bl-md",right:"ml-auto bg-accent-7 text-lowest rounded-br-md bubble-right"},transitionState:{entering:"opacity-0 translate-y-8",entered:"opacity-100 translate-y-0",exiting:"opacity-0 scale-0",exited:""}},defaultVariants:{side:"left"}}),fy={hidden:{y:"100%",scale:.75},shown:{y:0,scale:1}},hy=({children:e,className:t,transitionState:n,side:r,...o})=>b(qn.p,{variants:fy,initial:"hidden",animate:"shown",transition:{type:"spring",damping:25,stiffness:500},"data-transition":n,style:{transformOrigin:r==="left"?"0% 50%":"100% 50%"},class:dy({className:t,side:r,transitionState:n}),...o,children:e}),py=({className:e,...t})=>b("div",{"aria-label":"Typing…",class:Ut("flex gap-1 p-4",e),...t,children:Array.from({length:3},(n,r)=>b("div",{class:"bg-accent-7 h-1.5 w-1.5 animate-bounce rounded-full",style:{animationDelay:`${-r*200}ms`}}))}),my={bot:"left",user:"right"},vy=Gd("w-full select-none py-2 text-center text-[10px] uppercase tracking-widest drop-shadow-[0_1.5px_white]",{variants:{variant:{info:"text-neutral-8",warning:"text-[#FFC107]",error:"text-error-9",success:"text-[#4CAF50]"}}}),gy=({messages:e,isBotTyping:t})=>b("ol",{"aria-label":"Chat messages",class:"flex flex-grow flex-col justify-end gap-2 p-2 pt-[calc(var(--header-height)+1rem)]",children:[b(eo,{initial:!1,children:e.map((n,r)=>b("li",{class:"flex",children:tt(n).with({type:"system"},o=>b("p",{class:vy({variant:o.variant}),children:o.text})).with({type:"text",author:Ae.union("bot","user")},o=>b(hy,{side:my[o.author],children:o.text},r)).with({type:"link"},o=>b("div",{class:"bg-accent-8/5 flex w-full items-center justify-center overflow-hidden rounded-xl py-2",children:b("a",{class:"bg-lowest shadow-surface-sm ring-accent-8/20 hover:ring-accent-8 active:bg-accent-2 active:text-accent-10 text-accent-9 focus-visible:ring-accent-7/50 flex items-center gap-1.5 truncate rounded-full py-2 pl-4 pr-2.5 no-underline ring-1 transition-all focus:outline-none focus-visible:ring-4 focus-visible:ring-offset-2",target:"_blank",href:o.href,children:[o.text,b("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:b("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"})})]})})).with({type:"image"},o=>b("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=>b(A1,{class:o.author==="bot"?"":"ml-auto",file:{name:o.fileName,sizeKb:o.fileSizeKb}})).exhaustive()},r))}),b("aside",{"aria-hidden":!0,children:t&&b(py,{})})]}),by=25,yy=()=>{const e=U(null),[t,n]=ae(!1),[r,o]=ae(()=>()=>{}),i=de(()=>a=>{var c;return(c=e.current)==null?void 0:c.scrollTo({top:e.current.scrollHeight,...a})},[e]),s=de(()=>({send:async({message:a,signal:c,groupId:u})=>{if(await tt(a).with({author:"bot",type:"text"},async d=>{if(c!=null&&c.aborted)throw new Gn;n(!0);const l=Math.min(Math.max(20,d.text.length),100)*by;await new Promise(f=>setTimeout(f,l,{signal:c})),n(!1)}).otherwise(async()=>{}),c!=null&&c.aborted)throw new Gn;ne.addMessage(a,u)},input:async({input:a,signal:c})=>{if(c!=null&&c.aborted)throw new Gn;return ne.setInput(a),await new Promise(u=>{const d=l=>{if(c!=null&&c.aborted)throw new Gn;ne.setInput(void 0),a.key&&ne.setSubmission(a.key,l),u(l)};o(()=>d)})}}),[]);return{chatRef:e,chatService:s,isBotTyping:t,onSubmitSuccessFn:r,scrollToEnd:i}},wy=Object.freeze(Object.defineProperty({__proto__:null,JobApplicationContent:({currentApplication:e,logger:t,apiClient:n,analytics:r})=>{const{chatRef:o,chatService:i,isBotTyping:s,onSubmitSuccessFn:a,scrollToEnd:c}=yy(),u=nt.value,d=e.flow,l=e.job;return Be(()=>{u==="maximised"&&c({behavior:"instant"})},[c,u]),G(()=>{c({behavior:"smooth"})},[e.data.messages,c]),Be(()=>{const{state:f,application:h}=ne.current$.peek();if(f!=="loaded")throw new Error(Ev.invalid_state);const p=h.data.currentNodeId;if(c({behavior:"instant"}),ne.setInput(void 0),h.data.isFinished)return;ne.removeLastGroupMessagesById(p);const{interpret:m,abort:y}=c1({context:{jobId:l.id,flowId:d.id},analytics:r,apiClient:n,logger:t,flow:d.nodes,chatService:i,getSubmissions:()=>{var x;return(x=ne.current$.peek().application)==null?void 0:x.data.submissions},onInterpret:(x,g)=>{const w=ne.current$.peek().application;kr(w),w.data.sequence=w.data.sequence+1,r.log({event:"FLOW_NODE",properties:{flow_id:d.id,flow_version:d.version,job_id:l.id,from_node_id:g?g.id:null,to_node_id:x.id,sequence:w.data.sequence,flow_session_id:w.data.flowSessionId}}),ne.setCurrentNodeId(x.id)},onFlowEnd:async()=>{ne.markAsFinished()}});return m(p),y},[r,n,i,t,c,d,l.id,e.startedAt]),b(ue,{children:[b("div",{ref:o,className:"hide-scrollbars relative flex max-w-full flex-grow flex-col overflow-y-scroll",style:{WebkitOverflowScrolling:"touch",paddingBottom:ts.value},children:b(eo,{children:b(gy,{isBotTyping:s,messages:e.data.messages})})}),b(uy,{input:e.data.currentInput,onInputChange:()=>c({behavior:"smooth"}),onSubmit:a})]})}},Symbol.toStringTag,{value:"Module"}))})();
@@ -8297,7 +8297,7 @@ const ChatbotHeader = ({
8297
8297
  })]
8298
8298
  });
8299
8299
  };
8300
- const JobApplicationContent = M$1(() => import("./job-application-content-8a7522d6.js").then((module) => module.JobApplicationContent));
8300
+ const JobApplicationContent = M$1(() => import("./job-application-content-4255d386.js").then((module) => module.JobApplicationContent));
8301
8301
  const MotionProvider = ({
8302
8302
  children
8303
8303
  }) => {
@@ -8298,7 +8298,7 @@ const ChatbotHeader = ({
8298
8298
  })]
8299
8299
  });
8300
8300
  };
8301
- const JobApplicationContent = M$1(() => Promise.resolve().then(() => require("./job-application-content-a6726978.cjs")).then((module2) => module2.JobApplicationContent));
8301
+ const JobApplicationContent = M$1(() => Promise.resolve().then(() => require("./job-application-content-1812c3f4.cjs")).then((module2) => module2.JobApplicationContent));
8302
8302
  const MotionProvider = ({
8303
8303
  children
8304
8304
  }) => {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./index-430323a2.cjs");
3
+ const index = require("./index-da99deb7.cjs");
4
4
  require("@inploi/sdk");
5
5
  const followNodes = ({
6
6
  node,
@@ -210,6 +210,7 @@ async function interpretSubmitNode({
210
210
  type: node.data.type,
211
211
  ats: node.data.ats,
212
212
  integration_id: node.data.integrationId,
213
+ anonymous_id: analytics.getAnonymousId(),
213
214
  submissions: index.getApplicationSubmissionsPayload(submissions || {})
214
215
  })
215
216
  }).catch((e) => e);
@@ -1,4 +1,4 @@
1
- import { _, g as getHeadOrThrow, A as AbortedError, N, a as getApplicationSubmissionsPayload, o as o$1, c as clsx, b as _$1, p, d as parse, e as picklist, m, f as AnimatePresence, h as application, i as h, k, j as invariant, l as isSubmissionOfType, C as Cn, n as parseAsync, V as ValiError, q as object, t as transform, r as maxLength, s as minLength, u as record, v as boolean, w as string, x as email, y as url, z as regex, B as y, T, D as inputHeight, F, E as viewState, G as ERROR_MESSAGES } from "./index-670c0945.js";
1
+ import { _, g as getHeadOrThrow, A as AbortedError, N, a as getApplicationSubmissionsPayload, o as o$1, c as clsx, b as _$1, p, d as parse, e as picklist, m, f as AnimatePresence, h as application, i as h, k, j as invariant, l as isSubmissionOfType, C as Cn, n as parseAsync, V as ValiError, q as object, t as transform, r as maxLength, s as minLength, u as record, v as boolean, w as string, x as email, y as url, z as regex, B as y, T, D as inputHeight, F, E as viewState, G as ERROR_MESSAGES } from "./index-6321b293.js";
2
2
  import "@inploi/sdk";
3
3
  const followNodes = ({
4
4
  node,
@@ -208,6 +208,7 @@ async function interpretSubmitNode({
208
208
  type: node.data.type,
209
209
  ats: node.data.ats,
210
210
  integration_id: node.data.integrationId,
211
+ anonymous_id: analytics.getAnonymousId(),
211
212
  submissions: getApplicationSubmissionsPayload(submissions || {})
212
213
  })
213
214
  }).catch((e) => e);
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./index-430323a2.cjs");
3
+ const index = require("./index-da99deb7.cjs");
4
4
  require("@inploi/sdk");
5
5
  exports.chatbotPlugin = index.chatbotPlugin;
@@ -1,4 +1,4 @@
1
- import { H } from "./index-670c0945.js";
1
+ import { H } from "./index-6321b293.js";
2
2
  import "@inploi/sdk";
3
3
  export {
4
4
  H as chatbotPlugin
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inploi/plugin-chatbot",
3
- "version": "3.5.0",
3
+ "version": "3.5.1",
4
4
  "type": "module",
5
5
  "main": "dist/plugin-chatbot.js",
6
6
  "types": "dist/index.d.ts",
@@ -63,10 +63,10 @@
63
63
  "vite": "^4.4.5",
64
64
  "vite-plugin-dts": "^3.7.0",
65
65
  "vite-tsconfig-paths": "^4.2.1",
66
- "@inploi/core": "1.11.1",
67
66
  "@inploi/sdk": "1.10.0",
68
67
  "eslint-config-custom": "0.1.0",
69
- "tsconfig": "0.1.0"
68
+ "tsconfig": "0.1.0",
69
+ "@inploi/core": "1.11.1"
70
70
  },
71
71
  "msw": {
72
72
  "workerDirectory": "public"