1import{Tt as e,bt as t,f as n,jt as r,st as i}from"./82eqqkYy.js";import{t as a}from"./CuyTkb7v.js";import{r as o}from"./xTfQ6LWd.js";import"./CLD1paPK.js";import{t as s}from"./D9n7Oern.js";import{n as c}from"./CL7Uu-9A.js";import{a as l,i as u,n as d,r as f,t as p}from"./Ch6BsKUL.js";import{i as m,n as h}from"./DXLrD4t_.js";import{a as g}from"./CiIoPtQ7.js";var _=p({id:`formStatusMachine`,types:{},initial:`poll`,context:{formId:`uninitialized`,formName:`uninitialized`,status:`UNKNOWN`,waitDelay:2e3,pollCount:0},entry:f(({event:e})=>e.type===`xstate.init`?e.input:{}),states:{poll:{tags:`polling`,invoke:{id:`poll`,input:({context:{formName:e,formId:t}})=>({formName:e,formId:t}),src:u(async({input:{formId:e}})=>await h({id:e}).then(e=>e?.formSubmissionCheck.status??`UNKNOWN`).catch(e=>{throw e})),onDone:`parse`,onError:`error`}},parse:{tags:`polling`,on:{WAIT:{target:`wait`,actions:f({waitDelay:({context:e})=>(e.pollCount||0)<5?2e3:Math.min(e.waitDelay+1e3,3e4),pollCount:({context:e})=>(e.pollCount||0)+1})},DONE:`done`},entry:[f(({context:e,event:t})=>({status:t.type===`xstate.done.actor.poll`?t.output:e.status})),d(({event:e,context:t,enqueue:n})=>{switch(e.type===`xstate.done.actor.poll`?e.output:t.status){case`DONE`:case`REJECTED`:n.raise({type:`DONE`});break;default:n.raise({type:`WAIT`})}})]},wait:{tags:`waiting`,after:{POLL_DELAY:`poll`}},error:{type:`final`,tags:`error`,entry:f(({event:e})=>({error:e.type===`xstate.error.actor.poll`?e.error:`Unknown error`}))},done:{type:`final`,tags:`done`}}},{delays:{POLL_DELAY:({context:e})=>e.waitDelay}}),v=e=>{let t=e.createdAt?new Date(e.createdAt):new Date,{formName:n,id:r,status:i}=e;return{formName:n,id:r,status:i??null,createdAt:t}},y=c(`formService`,()=>{let i=e({}),a=t({}),o=n(()=>Object.keys(i.value)),c=(e,n=!1)=>{let{formName:r,id:o,status:s,createdAt:c}=v(e);if(i.value[r]){let{createdAt:e,id:t}=a[r];if(o===t||e.getTime()>c.getTime())return;i.value[r].stop()}let u=l(_,{input:{formName:r,formId:o,status:s??`UNKNOWN`,waitDelay:n?15e3:2e3,pollCount:n?6:0}});a[r]||(a[r]=t({id:o,formName:r,status:s,createdAt:c})),u.subscribe(e=>{a[r].status=e.context.status}),u.start(),i.value={...i.value,[r]:u}};return{requestMachines:i,requestStatus:a,activeRequests:o,submitForm:async e=>{let{data:t,error:n,status:i}=m(e);if(await g(i),i.value!==`success`){if(s.error(`Failed to submit form with status: ${i.value}`),i.value===`error`)throw Error(n.value?.message??`Error not defined`);return{status:`UNKNOWN`,id:`x`}}let{id:a,status:o}=t.value.formSubmissionCreate,{formName:l}=r(e);return c({id:a,status:o,formName:l,createdAt:new Date},!1),t.value.formSubmissionCreate},initRequests:e=>{e.forEach(e=>c(e,!0))},addRequest:c,status:e=>{if(!a[e]){let n=new Date;n.setTime(0),a[e]=t({formName:e,status:null,createdAt:n,id:``})}return a[e]}}},{persist:!1,share:{enable:!1}});function b(){return!1}var x={clearBeforeFetch:!1,forceReload:!1,shouldThrowOnTimeout:!0},S=new Map;function C(){S.forEach(e=>e()),S.clear()}function w({store:e,options:t}){let n=e.$id,r=t?.formServiceDependencies;if(!r||Array.isArray(r)&&!r?.length||!a(r)||a(r)&&!Object.keys(r).length)return;if(typeof e.$updateOnFormServiceStatusChange!=`function`)throw Error(`Store ${n} is missing $updateOnFormServiceStatusChange function.`);let o=Array.isArray(r)?r:Object.keys(r),s=async t=>e.$updateOnFormServiceStatusChange(t),c=y(),l=o.map(e=>c.status(e)),u=()=>{d(),S.delete(n)},d=i(l,e=>{if(e.some(e=>e.status===`DONE`)){let n=``;Array.isArray(t.formServiceDependencies)||(n=e.find(e=>e.status===`DONE`)?.formName??``),s(n)}},{deep:!0});S.set(n,u)}var T=o(e=>{b()||e.$pinia.use(w)});export{y as a,b as i,T as n,C as r,x as t};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.