@ukhomeoffice/cop-react-form-renderer 8.0.5 → 8.0.6-alpha

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/dist/index.cjs CHANGED
@@ -1,12 +1,12 @@
1
1
  "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require('./index.css');const d=require("react/jsx-runtime"),S=require("@ukhomeoffice/cop-react-components"),R=require("react"),_t=require("uuid"),K=require("dayjs"),Be=require("dayjs/plugin/customParseFormat"),fn=require("dayjs/plugin/isToday"),Xr=require("dayjs/plugin/isLeapYear"),$e={add:"Add another",remove:"Remove",change:"Change",item:"Item ${index}"},Qr="alert",Zr="autocomplete",eo="calculation",to="checkboxes",no="collection",so="collection-summary",ro="container",oo="date",io="details",lo="email",ao="file",co="heading",uo="html",fo="inset-text",ho="list",mo="multifile",po="paragraph",Eo="phone-number",Ao="radios",yo="select",To="text",So="textarea",Co="time",go="warning",_={ALERT:Qr,AUTOCOMPLETE:Zr,CALCULATION:eo,CHECKBOXES:to,COLLECTION:no,COLLECTION_SUMMARY:so,CONTAINER:ro,DATE:oo,DETAILS:io,EMAIL:lo,FILE:ao,HEADING:co,HTML:uo,INSET_TEXT:fo,LIST:ho,MULTI_FILE:mo,PARAGRAPH:po,PHONE_NUMBER:Eo,RADIOS:Ao,SELECT:yo,TEXT:To,TEXT_AREA:So,TIME:Co,WARNING:go},bo="blur",wo="submit",_o="cancel",we={BLUR:bo,SUBMIT:wo,CANCEL:_o},Io="cya",Po="hub",xo="partial-cya",re={CYA:Io,HUB:Po,PARTIAL_CYA:xo},Oo="cya",Ro="form",No="form-with-task-list",Lo="hub-and-spoke",Do="task-list",vo="task-list-cya",Fo="wizard",ne={CYA:Oo,FORM:Ro,FORM_WITH_TASK:No,HUB:Lo,TASK:Do,TASK_CYA:vo,WIZARD:Fo},jo="CYA",Uo="TASK",ye={CYA:jo,TASK:Uo},Gt="cancel",ps="collectionAdd",Es="collectionDuplicate",As="collectionRemove",ys="navigate",Kt="saveAndContinue",Wt="saveAndNavigate",zt="saveAndReturn",Jt="submit",mt={CANCEL:Gt,COLLECTION_ADD:ps,COLLECTION_DUPLICATE:Es,COLLECTION_REMOVE:As,NAVIGATE:ys,SAVE_AND_CONTINUE:Kt,SAVE_AND_NAVIGATE:Wt,SAVE_AND_RETURN:zt,SUBMIT:Jt},Mo={[Gt]:{type:Gt,validate:!1,label:"Cancel",classModifiers:"secondary"},[ps]:void 0,[Es]:void 0,[As]:void 0,[ys]:void 0,[Kt]:{type:Kt,validate:!0,label:"Save and continue"},[Wt]:{type:Wt,validate:!0,label:"Save and continue"},[zt]:{type:zt,validate:!1,label:"Save and return later",classModifiers:"secondary"},[Jt]:{type:Jt,validate:!0}},W={TYPES:mt,DEFAULTS:Mo},Ts="complete",Ss="inProgress",Cs="notStarted",gs="cannotStartYet",bs="skipped",ko={COMPLETE:Ts,IN_PROGRESS:Ss,NOT_STARTED:Cs,CANNOT_START_YET:gs,SKIPPED:bs},Bo={[Ts]:{label:"Completed",colour:"dark-blue"},[Ss]:{label:"In Progress",colour:"white"},[Cs]:{label:"Not Started",colour:"dark-grey"},[gs]:{label:"Cannot Start Yet",colour:"dark-grey"},[bs]:{label:"Skipped",colour:"dark-grey"}},H={TYPES:ko,DETAILS:Bo},$o={CollectionLabels:$e,ComponentTypes:_,EventTypes:we,FormPages:re,FormTypes:ne,HubFormats:ye,PageAction:W,TaskStates:H},ws=e=>{try{const t=Yo(e);return!t&&t!==0?"":t}catch(t){console.error(t.message)}return""},Yo=e=>{if(!e||!e.formula)throw new Error("Missing 'formula' definition");const{name:t}={...e.formula};switch(t){case"multiply":return at(e,(n,s)=>n*s);case"divide":return at(e,(n,s)=>n/s);case"plus":return at(e,(n,s)=>n+s);case"minus":return at(e,(n,s)=>n-s);default:throw new Error(t?`Unsupported operation '${t}'`:"Calculation formula 'name' cannot be empty")}},at=(e,t)=>{const{args:n}={...e.formula};if(n.length<2)throw new Error("Requires more than one argument for calculation");return Ho(n.map(s=>Vo(s,e.formData)).reduce((s,r,o)=>o===0?r:t(s,r),0),e)},Ho=(e,t)=>{const n=t.formula.round;if(!n&&n!==0||!e)return e;if(n===0)return parseInt(e,10);const s=Math.pow(10,n);return Math.round((e+Number.EPSILON)*s)/s},Vo=(e,t)=>{const n=Object.keys(e);if(n.length===1){const s=n[0],r=e[s];switch(s){case"field":{const o=qo(r,t);return!o&&o!==0?NaN:parseFloat(o)}case"value":return parseFloat(r);case"formula":return ws({...e,formData:t});default:throw new Error("Only accept following as argument field: {field, value, or formula}")}}else throw new Error("Argument cannot have more than one reference")},qo=(e,t)=>S.Utils.interpolateString("${"+e+"}",t),Go=(e,t)=>{if(["in","nin","includesAllOf","!includesAllOf"].includes(e.op))return e.values;if(typeof e.value=="string"&&e.value?.startsWith("field::")){const n=e.value.replace("field::","");return de.getSource(t,n)}return e.value},ct=e=>{if(Array.isArray(e))return e.length;if(typeof e=="string"){const t=e.replace(/,/g,"");return Number.isNaN(t)?null:parseFloat(t)}return typeof e=="number"?e:null},hn=(e,t,n)=>{if(e&&typeof e=="object"){const s=Go(e,n);switch(e.op){case"=":case"eq":return s===t;case"!=":case"<>":case"ne":case"neq":return s!==t;case"in":return Array.isArray(s)?s.includes(t):!1;case"nin":return Array.isArray(s)?s.includes(t)===!1:!0;case"<":{const r=ct(t),o=ct(s);return r!=null&&o!=null&&r<o}case">":{const r=ct(t),o=ct(s);return r!=null&&o!=null&&r>o}case"contains":return t?.toString().toLowerCase().includes(s);case"!contains":return!t?.toString().toLowerCase().includes(s);case"includes":return Array.isArray(t)?t.includes(s):!1;case"!includes":return Array.isArray(t)?!t.includes(s):!0;case"includesObjectProp":return Array.isArray(t)?t.some(r=>r[e.key]===s):!1;case"!includesObjectProp":return Array.isArray(t)?!t.some(r=>r[e.key]===s):!0;case"includesAllOf":return Array.isArray(t)?s.every(r=>t.includes(r)):!1;case"!includesAllOf":return Array.isArray(t)?!s.every(r=>t.includes(r)):!0;default:return!1}}return!0},Ko=e=>{if(e.show_when){let t=e.show_when.type?e.show_when.conditions:e.show_when;const n=e.full_path;return t=Array.isArray(t)?t:[t],t.map(s=>{const r=de.getDataPath(s.field,n);return{...s,field:r}})}},Wo=e=>Array.isArray(e)||!!(e.field&&e.op),_s=e=>e&&!Wo(e)?Ko(e):e,Is=(e,t,n="and")=>{const s=Array.isArray(e)?e:[e],r=o=>{if(Array.isArray(o.conditions))return Is(o.conditions,t,o.type);const i=o.field.startsWith("interpolate::")?S.Utils.interpolateString(o.field,t).replace("interpolate::",""):o.field,l=de.getSource(t,i);return hn(o,l,t)};return n==="and"?s.every(r):s.some(r)},Ue=(e,t)=>{const n=_s(e);return n?Is(n,t):!0},zo=(e,t)=>{const n=_s(e);return n?(Array.isArray(n)?n:[n]).some(r=>{const o=de.getSource(t,r.field);return hn(r,o,t)}):!0},ae={meetsOne:zo,meetsAll:Ue,met:hn},Jo=(e,t)=>{const n=e;return t.forEach((s,r)=>{if(s.refdata_match){const o=s.refdata_match,i=Object.keys(o)[0],l=e.findIndex(a=>a[i]===o[i]);l>=0&&(n[l]={...e[l],nested:s.nested})}s.combineWithRefdata&&!n.includes(s)&&(r>0&&typeof t[r-1]=="string"&&n.push(t[r-1]),n.push(s))}),n},ut=(e,t)=>t.map(n=>n.show_when&&!(n.show_when.type==="or"?ae.meetsOne(n,e.formData):ae.meetsAll(n,e.formData))?null:typeof n=="string"?n:n.value?(e.alternativeHintField&&(n.hint=n[e.alternativeHintField]),{...n,value:S.Utils.interpolateString(n.value,e.formData),label:S.Utils.interpolateString(n.label,e.formData),hint:S.Utils.interpolateString(n.hint,e.formData)}):n.label).filter(n=>n),Xo=(e,t)=>{const n=e.formData[t].map(s=>({value:S.Utils.interpolateString(e.item.value,s),label:S.Utils.interpolateString(e.item.label,s),hint:S.Utils.interpolateString(e.item.hint,s)}));return e.data.options?[...n,...e.data.options]:n},Ps=(e,t)=>{if(e){if(e?.data?.collection&&e?.item){const n=Xo(e,e?.data?.collection);return t(ut(e,n))}if(e.options&&e?.data?.options&&e?.data?.url){const n=Jo(e.options,e.data.options);return t(ut(e,n))}if(e.options)return t(ut(e,e.options));if(e.data&&e.data.options)return t(ut(e,e.data.options))}return t([])},Qo=6e3,Zo=(e,t)=>{const n=e===0;let s=0;return n&&(s=1),n||(s=t.substring(e-1).startsWith(" ")?2:3),s},jn=e=>e===0,xs=(e,t)=>typeof e!="string"?!1:e.toLowerCase().includes(t),ei=(e,t)=>{let n=0;return e.synonyms.some(r=>xs(r,t))&&(n=4),n},ti=(e,t,n)=>{let s=0;return e.item.extraFieldsToSearch.some(o=>{const i=t[o];return xs(i,n)})&&(s=5),s},ni=(e,t,n,s)=>{const r=n?n(e).toLowerCase():e.label.toLowerCase()||"";let o=0;const i=r.indexOf(t);return i!==-1&&(o=Zo(i,r)),jn(o)&&e.synonyms&&(o=ei(e,t)),jn(o)&&s.item?.extraFieldsToSearch&&(o=ti(s,e,t)),{score:o,label:r,option:e}},si=(e,t,n)=>(s,r)=>{const o=ni(r,e,t,n);return o.score>0&&s.push(o),s},ri=(e,t)=>(e.score-t.score)*16+e.label.localeCompare(t.label),oi=e=>{let t=[];Ps(e,s=>{t=s});const n=e?.item?S.Utils.itemLabel(e.item):null;return(s,r)=>{const o=typeof s=="string"?s.toLowerCase():"",i=t.reduce(si(o,n,e),[]).sort(ri).slice(0,Qo).map(l=>l.option);r(i)}},Ne=".",mn="/",Os=`${Ne}${Ne}`,Un=`${Ne}${mn}`,Xt=e=>e.join(Ne),Qt=(e,t=Ne)=>e.split(t),ii=e=>e===Os,li=e=>[Ne,Os].indexOf(e)>-1,ai=e=>e&&e.indexOf(Ne)===0,ci=e=>e.indexOf(Un)===0?e:`${Un}${e}`,ui=(e,t)=>{const n=ci(t),s=Qt(n,mn).filter(ii).length+1,r=e?Qt(e):[];return s>=r.length?"":Xt(r.slice(0,-s))},di=(e,t)=>{const n=Qt(t,mn).filter(s=>!li(s));return e?`${e}.${Xt(n)}`:Xt(n)},fi=(e,t)=>ai(e)?di(ui(t,e),e):e,hi=(e,t)=>{if(Array.isArray(e))return e[parseInt(t,10)]},mi=e=>e.includes("["),pi=e=>e.replace("]","").split("["),se=(e,t)=>{if(t)return t.split(".").reduce((n,s)=>{if(n&&mi(s)){const[r,o]=pi(s);return hi(n[r],o)}return n?n[s]:void 0},e)},Ei=(e,t)=>{let n=e.value||e.id,s=e.label||e.name;return t&&(n=e[t.value]||n,s=e[t.label]||s),{value:n?.toString(),label:s}},Ai=(e,t)=>Array.isArray(e)?e.map(n=>typeof n=="string"?n:{...n,...Ei(n,t)}):[],yi=(e,t)=>{const n=Object.keys(e).filter(r=>!(r in t)),s=e;n.forEach(r=>delete s[r])},Rs=(e,t,n,s=!1)=>{if(t&&e){const r=s?t.replace(/\[/g,".").replace(/\]/g,"").split("."):t.split("."),o=r.pop();let i=e;r.forEach(l=>{(!i[l]||typeof i[l]!="object")&&(i[l]={}),i=i[l]}),i[o]=n}return e},Ns=(e,t)=>{const n=t;e.source&&(n[e.fieldId]=se(n,e.source.field))},Ti=(e,t)=>{e.forEach(n=>Ns(n,t))},Si=(e,t)=>{e.forEach(n=>{n.components.filter(s=>!s.use).forEach(s=>Ns(s,t))})},Ci=(e,t,n)=>{const s={...n};return Ti(t,s),Si(e,s),s},gi=(e,t)=>({...e,components:Ls(e.components,t)}),bi=(e,t)=>({...e,item:Ls(e.item,t)}),Ls=(e,t)=>e.map(n=>Ds(n,t)),Ds=(e,t)=>{if(e){if(e.type===_.CONTAINER)return gi(e,t);if(e.type===_.COLLECTION)return bi(e,t);if(e.type===_.SELECT)return e;if(e.data?.url&&!e.data?.skipUrlInterpolation)return{...e,data:{...e.data,url:S.Utils.interpolateString(e.data.url,t)}}}return e},de={applyFormula:ws,getAutocompleteSource:oi,getDataPath:fi,getOptions:Ps,getSource:se,refData:{setupUrl:Ds,toOptions:Ai},deleteValues:yi,setDataItem:Rs,setupForm:Ci},Ze=(e,t)=>Array.isArray(e)?t.refdata_match?e.some(n=>n.id===t.refdata_match.id):e.includes(t.value):e===t.value,Ie=(e,t)=>!e||e.hidden&&e.disabled?!1:e.show_when?.type==="or"?ae.meetsOne(e,t):ae.meetsAll(e,t),et=(e,t)=>{let n=[];return e?.forEach(s=>{n.push(s),Ie(s,t)&&s.data?.options?.forEach(r=>{const o=t?.[s.id]||de.getSource(t,s.full_path);Array.isArray(r.nested)&&Ze(o,r)&&Ie(r,t)&&(n=n.concat(r.nested))})}),n},Mn=["source","use","show_when","options","additionalValidation","full_path","fullPath","formData"],te=(e,t)=>{const n=Array.isArray(t)?[...Mn,...t]:Mn;return e&&typeof e=="object"?Object.keys(e).reduce((s,r)=>n.includes(r)?s:{...s,[r]:e[r]},{}):{}};function vs(e,t){return function(){return e.apply(t,arguments)}}const{toString:wi}=Object.prototype,{getPrototypeOf:It}=Object,{iterator:Pt,toStringTag:Fs}=Symbol,xt=(e=>t=>{const n=wi.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Ce=e=>(e=e.toLowerCase(),t=>xt(t)===e),Ot=e=>t=>typeof t===e,{isArray:Le}=Array,Me=Ot("undefined");function Ye(e){return e!==null&&!Me(e)&&e.constructor!==null&&!Me(e.constructor)&&me(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const js=Ce("ArrayBuffer");function _i(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&js(e.buffer),t}const Ii=Ot("string"),me=Ot("function"),Us=Ot("number"),tt=e=>e!==null&&typeof e=="object",Pi=e=>e===!0||e===!1,pt=e=>{if(xt(e)!=="object")return!1;const t=It(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Fs in e)&&!(Pt in e)},xi=e=>{if(!tt(e)||Ye(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Oi=Ce("Date"),Ri=Ce("File"),Ni=e=>!!(e&&typeof e.uri<"u"),Li=e=>e&&typeof e.getParts<"u",Di=Ce("Blob"),vi=Ce("FileList"),Fi=e=>tt(e)&&me(e.pipe);function ji(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const kn=ji(),Bn=typeof kn.FormData<"u"?kn.FormData:void 0,Ui=e=>{if(!e)return!1;if(Bn&&e instanceof Bn)return!0;const t=It(e);if(!t||t===Object.prototype||!me(e.append))return!1;const n=xt(e);return n==="formdata"||n==="object"&&me(e.toString)&&e.toString()==="[object FormData]"},Mi=Ce("URLSearchParams"),[ki,Bi,$i,Yi]=["ReadableStream","Request","Response","Headers"].map(Ce),Hi=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function nt(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let s,r;if(typeof e!="object"&&(e=[e]),Le(e))for(s=0,r=e.length;s<r;s++)t.call(null,e[s],s,e);else{if(Ye(e))return;const o=n?Object.getOwnPropertyNames(e):Object.keys(e),i=o.length;let l;for(s=0;s<i;s++)l=o[s],t.call(null,e[l],l,e)}}function Ms(e,t){if(Ye(e))return null;t=t.toLowerCase();const n=Object.keys(e);let s=n.length,r;for(;s-- >0;)if(r=n[s],t===r.toLowerCase())return r;return null}const Oe=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,ks=e=>!Me(e)&&e!==Oe;function Zt(...e){const{caseless:t,skipUndefined:n}=ks(this)&&this||{},s={},r=(o,i)=>{if(i==="__proto__"||i==="constructor"||i==="prototype")return;const l=t&&typeof i=="string"&&Ms(s,i)||i,a=en(s,l)?s[l]:void 0;pt(a)&&pt(o)?s[l]=Zt(a,o):pt(o)?s[l]=Zt({},o):Le(o)?s[l]=o.slice():(!n||!Me(o))&&(s[l]=o)};for(let o=0,i=e.length;o<i;o++){const l=e[o];if(!l||Ye(l)||(nt(l,r),typeof l!="object"||Le(l)))continue;const a=Object.getOwnPropertySymbols(l);for(let c=0;c<a.length;c++){const u=a[c];tl.call(l,u)&&r(l[u],u)}}return s}const Vi=(e,t,n,{allOwnKeys:s}={})=>(nt(t,(r,o)=>{n&&me(r)?Object.defineProperty(e,o,{__proto__:null,value:vs(r,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,o,{__proto__:null,value:r,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:s}),e),qi=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Gi=(e,t,n,s)=>{e.prototype=Object.create(t.prototype,s),Object.defineProperty(e.prototype,"constructor",{__proto__:null,value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{__proto__:null,value:t.prototype}),n&&Object.assign(e.prototype,n)},Ki=(e,t,n,s)=>{let r,o,i;const l={};if(t=t||{},e==null)return t;do{for(r=Object.getOwnPropertyNames(e),o=r.length;o-- >0;)i=r[o],(!s||s(i,e,t))&&!l[i]&&(t[i]=e[i],l[i]=!0);e=n!==!1&&It(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Wi=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const s=e.indexOf(t,n);return s!==-1&&s===n},zi=e=>{if(!e)return null;if(Le(e))return e;let t=e.length;if(!Us(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Ji=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&It(Uint8Array)),Xi=(e,t)=>{const s=(e&&e[Pt]).call(e);let r;for(;(r=s.next())&&!r.done;){const o=r.value;t.call(e,o[0],o[1])}},Qi=(e,t)=>{let n;const s=[];for(;(n=e.exec(t))!==null;)s.push(n);return s},Zi=Ce("HTMLFormElement"),el=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,s,r){return s.toUpperCase()+r}),en=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),{propertyIsEnumerable:tl}=Object.prototype,nl=Ce("RegExp"),Bs=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),s={};nt(n,(r,o)=>{let i;(i=t(r,o,e))!==!1&&(s[o]=i||r)}),Object.defineProperties(e,s)},sl=e=>{Bs(e,(t,n)=>{if(me(e)&&["arguments","caller","callee"].includes(n))return!1;const s=e[n];if(me(s)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},rl=(e,t)=>{const n={},s=r=>{r.forEach(o=>{n[o]=!0})};return Le(e)?s(e):s(String(e).split(t)),n},ol=()=>{},il=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function ll(e){return!!(e&&me(e.append)&&e[Fs]==="FormData"&&e[Pt])}const al=e=>{const t=new WeakSet,n=s=>{if(tt(s)){if(t.has(s))return;if(Ye(s))return s;if(!("toJSON"in s)){t.add(s);const r=Le(s)?[]:{};return nt(s,(o,i)=>{const l=n(o);!Me(l)&&(r[i]=l)}),t.delete(s),r}}return s};return n(e)},cl=Ce("AsyncFunction"),ul=e=>e&&(tt(e)||me(e))&&me(e.then)&&me(e.catch),$s=((e,t)=>e?setImmediate:t?((n,s)=>(Oe.addEventListener("message",({source:r,data:o})=>{r===Oe&&o===n&&s.length&&s.shift()()},!1),r=>{s.push(r),Oe.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",me(Oe.postMessage)),dl=typeof queueMicrotask<"u"?queueMicrotask.bind(Oe):typeof process<"u"&&process.nextTick||$s,fl=e=>e!=null&&me(e[Pt]),m={isArray:Le,isArrayBuffer:js,isBuffer:Ye,isFormData:Ui,isArrayBufferView:_i,isString:Ii,isNumber:Us,isBoolean:Pi,isObject:tt,isPlainObject:pt,isEmptyObject:xi,isReadableStream:ki,isRequest:Bi,isResponse:$i,isHeaders:Yi,isUndefined:Me,isDate:Oi,isFile:Ri,isReactNativeBlob:Ni,isReactNative:Li,isBlob:Di,isRegExp:nl,isFunction:me,isStream:Fi,isURLSearchParams:Mi,isTypedArray:Ji,isFileList:vi,forEach:nt,merge:Zt,extend:Vi,trim:Hi,stripBOM:qi,inherits:Gi,toFlatObject:Ki,kindOf:xt,kindOfTest:Ce,endsWith:Wi,toArray:zi,forEachEntry:Xi,matchAll:Qi,isHTMLForm:Zi,hasOwnProperty:en,hasOwnProp:en,reduceDescriptors:Bs,freezeMethods:sl,toObjectSet:rl,toCamelCase:el,noop:ol,toFiniteNumber:il,findKey:Ms,global:Oe,isContextDefined:ks,isSpecCompliantForm:ll,toJSONObject:al,isAsyncFn:cl,isThenable:ul,setImmediate:$s,asap:dl,isIterable:fl},hl=m.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),ml=e=>{const t={};let n,s,r;return e&&e.split(`
2
2
  `).forEach(function(i){r=i.indexOf(":"),n=i.substring(0,r).trim().toLowerCase(),s=i.substring(r+1).trim(),!(!n||t[n]&&hl[n])&&(n==="set-cookie"?t[n]?t[n].push(s):t[n]=[s]:t[n]=t[n]?t[n]+", "+s:s)}),t};function pl(e){let t=0,n=e.length;for(;t<n;){const s=e.charCodeAt(t);if(s!==9&&s!==32)break;t+=1}for(;n>t;){const s=e.charCodeAt(n-1);if(s!==9&&s!==32)break;n-=1}return t===0&&n===e.length?e:e.slice(t,n)}const El=new RegExp("[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+","g"),Al=new RegExp("[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+","g");function pn(e,t){return m.isArray(e)?e.map(n=>pn(n,t)):pl(String(e).replace(t,""))}const yl=e=>pn(e,El),Tl=e=>pn(e,Al);function Ys(e){const t=Object.create(null);return m.forEach(e.toJSON(),(n,s)=>{t[s]=Tl(n)}),t}const $n=Symbol("internals");function ze(e){return e&&String(e).trim().toLowerCase()}function Et(e){return e===!1||e==null?e:m.isArray(e)?e.map(Et):yl(String(e))}function Sl(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let s;for(;s=n.exec(e);)t[s[1]]=s[2];return t}const Cl=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Mt(e,t,n,s,r){if(m.isFunction(s))return s.call(this,t,n);if(r&&(t=n),!!m.isString(t)){if(m.isString(s))return t.indexOf(s)!==-1;if(m.isRegExp(s))return s.test(t)}}function gl(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,s)=>n.toUpperCase()+s)}function bl(e,t){const n=m.toCamelCase(" "+t);["get","set","has"].forEach(s=>{Object.defineProperty(e,s+n,{__proto__:null,value:function(r,o,i){return this[s].call(this,t,r,o,i)},configurable:!0})})}let ue=class{constructor(t){t&&this.set(t)}set(t,n,s){const r=this;function o(l,a,c){const u=ze(a);if(!u)return;const h=m.findKey(r,u);(!h||r[h]===void 0||c===!0||c===void 0&&r[h]!==!1)&&(r[h||a]=Et(l))}const i=(l,a)=>m.forEach(l,(c,u)=>o(c,u,a));if(m.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(m.isString(t)&&(t=t.trim())&&!Cl(t))i(ml(t),n);else if(m.isObject(t)&&m.isIterable(t)){let l={},a,c;for(const u of t){if(!m.isArray(u))throw new TypeError("Object iterator must return a key-value pair");l[c=u[0]]=(a=l[c])?m.isArray(a)?[...a,u[1]]:[a,u[1]]:u[1]}i(l,n)}else t!=null&&o(n,t,s);return this}get(t,n){if(t=ze(t),t){const s=m.findKey(this,t);if(s){const r=this[s];if(!n)return r;if(n===!0)return Sl(r);if(m.isFunction(n))return n.call(this,r,s);if(m.isRegExp(n))return n.exec(r);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=ze(t),t){const s=m.findKey(this,t);return!!(s&&this[s]!==void 0&&(!n||Mt(this,this[s],s,n)))}return!1}delete(t,n){const s=this;let r=!1;function o(i){if(i=ze(i),i){const l=m.findKey(s,i);l&&(!n||Mt(s,s[l],l,n))&&(delete s[l],r=!0)}}return m.isArray(t)?t.forEach(o):o(t),r}clear(t){const n=Object.keys(this);let s=n.length,r=!1;for(;s--;){const o=n[s];(!t||Mt(this,this[o],o,t,!0))&&(delete this[o],r=!0)}return r}normalize(t){const n=this,s={};return m.forEach(this,(r,o)=>{const i=m.findKey(s,o);if(i){n[i]=Et(r),delete n[o];return}const l=t?gl(o):String(o).trim();l!==o&&delete n[o],n[l]=Et(r),s[l]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return m.forEach(this,(s,r)=>{s!=null&&s!==!1&&(n[r]=t&&m.isArray(s)?s.join(", "):s)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
3
- `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const s=new this(t);return n.forEach(r=>s.set(r)),s}static accessor(t){const s=(this[$n]=this[$n]={accessors:{}}).accessors,r=this.prototype;function o(i){const l=ze(i);s[l]||(bl(r,i),s[l]=!0)}return m.isArray(t)?t.forEach(o):o(t),this}};ue.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);m.reduceDescriptors(ue.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(s){this[n]=s}}});m.freezeMethods(ue);const wl="[REDACTED ****]";function _l(e){if(m.hasOwnProp(e,"toJSON"))return!0;let t=Object.getPrototypeOf(e);for(;t&&t!==Object.prototype;){if(m.hasOwnProp(t,"toJSON"))return!0;t=Object.getPrototypeOf(t)}return!1}function Il(e,t){const n=new Set(t.map(o=>String(o).toLowerCase())),s=[],r=o=>{if(o===null||typeof o!="object"||m.isBuffer(o))return o;if(s.indexOf(o)!==-1)return;o instanceof ue&&(o=o.toJSON()),s.push(o);let i;if(m.isArray(o))i=[],o.forEach((l,a)=>{const c=r(l);m.isUndefined(c)||(i[a]=c)});else{if(!m.isPlainObject(o)&&_l(o))return s.pop(),o;i=Object.create(null);for(const[l,a]of Object.entries(o)){const c=n.has(l.toLowerCase())?wl:r(a);m.isUndefined(c)||(i[l]=c)}}return s.pop(),i};return r(e)}let D=class Hs extends Error{static from(t,n,s,r,o,i){const l=new Hs(t.message,n||t.code,s,r,o);return l.cause=t,l.name=t.name,t.status!=null&&l.status==null&&(l.status=t.status),i&&Object.assign(l,i),l}constructor(t,n,s,r,o){super(t),Object.defineProperty(this,"message",{__proto__:null,value:t,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,n&&(this.code=n),s&&(this.config=s),r&&(this.request=r),o&&(this.response=o,this.status=o.status)}toJSON(){const t=this.config,n=t&&m.hasOwnProp(t,"redact")?t.redact:void 0,s=m.isArray(n)&&n.length>0?Il(t,n):m.toJSONObject(t);return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:s,code:this.code,status:this.status}}};D.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";D.ERR_BAD_OPTION="ERR_BAD_OPTION";D.ECONNABORTED="ECONNABORTED";D.ETIMEDOUT="ETIMEDOUT";D.ECONNREFUSED="ECONNREFUSED";D.ERR_NETWORK="ERR_NETWORK";D.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";D.ERR_DEPRECATED="ERR_DEPRECATED";D.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";D.ERR_BAD_REQUEST="ERR_BAD_REQUEST";D.ERR_CANCELED="ERR_CANCELED";D.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";D.ERR_INVALID_URL="ERR_INVALID_URL";D.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";const Pl=null;function tn(e){return m.isPlainObject(e)||m.isArray(e)}function Vs(e){return m.endsWith(e,"[]")?e.slice(0,-2):e}function kt(e,t,n){return e?e.concat(t).map(function(r,o){return r=Vs(r),!n&&o?"["+r+"]":r}).join(n?".":""):t}function xl(e){return m.isArray(e)&&!e.some(tn)}const Ol=m.toFlatObject(m,{},null,function(t){return/^is[A-Z]/.test(t)});function Rt(e,t,n){if(!m.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=m.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(A,T){return!m.isUndefined(T[A])});const s=n.metaTokens,r=n.visitor||h,o=n.dots,i=n.indexes,l=n.Blob||typeof Blob<"u"&&Blob,a=n.maxDepth===void 0?100:n.maxDepth,c=l&&m.isSpecCompliantForm(t);if(!m.isFunction(r))throw new TypeError("visitor must be a function");function u(p){if(p===null)return"";if(m.isDate(p))return p.toISOString();if(m.isBoolean(p))return p.toString();if(!c&&m.isBlob(p))throw new D("Blob is not supported. Use a Buffer instead.");return m.isArrayBuffer(p)||m.isTypedArray(p)?c&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function h(p,A,T){let N=p;if(m.isReactNative(t)&&m.isReactNativeBlob(p))return t.append(kt(T,A,o),u(p)),!1;if(p&&!T&&typeof p=="object"){if(m.endsWith(A,"{}"))A=s?A:A.slice(0,-2),p=JSON.stringify(p);else if(m.isArray(p)&&xl(p)||(m.isFileList(p)||m.endsWith(A,"[]"))&&(N=m.toArray(p)))return A=Vs(A),N.forEach(function(b,P){!(m.isUndefined(b)||b===null)&&t.append(i===!0?kt([A],P,o):i===null?A:A+"[]",u(b))}),!1}return tn(p)?!0:(t.append(kt(T,A,o),u(p)),!1)}const f=[],E=Object.assign(Ol,{defaultVisitor:h,convertValue:u,isVisitable:tn});function y(p,A,T=0){if(!m.isUndefined(p)){if(T>a)throw new D("Object is too deeply nested ("+T+" levels). Max depth: "+a,D.ERR_FORM_DATA_DEPTH_EXCEEDED);if(f.indexOf(p)!==-1)throw new Error("Circular reference detected in "+A.join("."));f.push(p),m.forEach(p,function(C,b){(!(m.isUndefined(C)||C===null)&&r.call(t,C,m.isString(b)?b.trim():b,A,E))===!0&&y(C,A?A.concat(b):[b],T+1)}),f.pop()}}if(!m.isObject(e))throw new TypeError("data must be an object");return y(e),t}function Yn(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(e).replace(/[!'()~]|%20/g,function(s){return t[s]})}function En(e,t){this._pairs=[],e&&Rt(e,this,t)}const qs=En.prototype;qs.append=function(t,n){this._pairs.push([t,n])};qs.toString=function(t){const n=t?function(s){return t.call(this,s,Yn)}:Yn;return this._pairs.map(function(r){return n(r[0])+"="+n(r[1])},"").join("&")};function Rl(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Gs(e,t,n){if(!t)return e;const s=n&&n.encode||Rl,r=m.isFunction(n)?{serialize:n}:n,o=r&&r.serialize;let i;if(o?i=o(t,r):i=m.isURLSearchParams(t)?t.toString():new En(t,r).toString(s),i){const l=e.indexOf("#");l!==-1&&(e=e.slice(0,l)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class Hn{constructor(){this.handlers=[]}use(t,n,s){return this.handlers.push({fulfilled:t,rejected:n,synchronous:s?s.synchronous:!1,runWhen:s?s.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){m.forEach(this.handlers,function(s){s!==null&&t(s)})}}const An={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0,advertiseZstdAcceptEncoding:!1},Nl=typeof URLSearchParams<"u"?URLSearchParams:En,Ll=typeof FormData<"u"?FormData:null,Dl=typeof Blob<"u"?Blob:null,vl={isBrowser:!0,classes:{URLSearchParams:Nl,FormData:Ll,Blob:Dl},protocols:["http","https","file","blob","url","data"]},yn=typeof window<"u"&&typeof document<"u",nn=typeof navigator=="object"&&navigator||void 0,Fl=yn&&(!nn||["ReactNative","NativeScript","NS"].indexOf(nn.product)<0),jl=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Ul=yn&&window.location.href||"http://localhost",Ml=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:yn,hasStandardBrowserEnv:Fl,hasStandardBrowserWebWorkerEnv:jl,navigator:nn,origin:Ul},Symbol.toStringTag,{value:"Module"})),le={...Ml,...vl};function kl(e,t){return Rt(e,new le.classes.URLSearchParams,{visitor:function(n,s,r,o){return le.isNode&&m.isBuffer(n)?(this.append(s,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...t})}function Bl(e){return m.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function $l(e){const t={},n=Object.keys(e);let s;const r=n.length;let o;for(s=0;s<r;s++)o=n[s],t[o]=e[o];return t}function Ks(e){function t(n,s,r,o){let i=n[o++];if(i==="__proto__")return!0;const l=Number.isFinite(+i),a=o>=n.length;return i=!i&&m.isArray(r)?r.length:i,a?(m.hasOwnProp(r,i)?r[i]=m.isArray(r[i])?r[i].concat(s):[r[i],s]:r[i]=s,!l):((!m.hasOwnProp(r,i)||!m.isObject(r[i]))&&(r[i]=[]),t(n,s,r[i],o)&&m.isArray(r[i])&&(r[i]=$l(r[i])),!l)}if(m.isFormData(e)&&m.isFunction(e.entries)){const n={};return m.forEachEntry(e,(s,r)=>{t(Bl(s),r,n,0)}),n}return null}const je=(e,t)=>e!=null&&m.hasOwnProp(e,t)?e[t]:void 0;function Yl(e,t,n){if(m.isString(e))try{return(t||JSON.parse)(e),m.trim(e)}catch(s){if(s.name!=="SyntaxError")throw s}return(n||JSON.stringify)(e)}const st={transitional:An,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const s=n.getContentType()||"",r=s.indexOf("application/json")>-1,o=m.isObject(t);if(o&&m.isHTMLForm(t)&&(t=new FormData(t)),m.isFormData(t))return r?JSON.stringify(Ks(t)):t;if(m.isArrayBuffer(t)||m.isBuffer(t)||m.isStream(t)||m.isFile(t)||m.isBlob(t)||m.isReadableStream(t))return t;if(m.isArrayBufferView(t))return t.buffer;if(m.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(o){const a=je(this,"formSerializer");if(s.indexOf("application/x-www-form-urlencoded")>-1)return kl(t,a).toString();if((l=m.isFileList(t))||s.indexOf("multipart/form-data")>-1){const c=je(this,"env"),u=c&&c.FormData;return Rt(l?{"files[]":t}:t,u&&new u,a)}}return o||r?(n.setContentType("application/json",!1),Yl(t)):t}],transformResponse:[function(t){const n=je(this,"transitional")||st.transitional,s=n&&n.forcedJSONParsing,r=je(this,"responseType"),o=r==="json";if(m.isResponse(t)||m.isReadableStream(t))return t;if(t&&m.isString(t)&&(s&&!r||o)){const l=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,je(this,"parseReviver"))}catch(a){if(l)throw a.name==="SyntaxError"?D.from(a,D.ERR_BAD_RESPONSE,this,null,je(this,"response")):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:le.classes.FormData,Blob:le.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};m.forEach(["delete","get","head","post","put","patch","query"],e=>{st.headers[e]={}});function Bt(e,t){const n=this||st,s=t||n,r=ue.from(s.headers);let o=s.data;return m.forEach(e,function(l){o=l.call(n,o,r.normalize(),t?t.status:void 0)}),r.normalize(),o}function Ws(e){return!!(e&&e.__CANCEL__)}let rt=class extends D{constructor(t,n,s){super(t??"canceled",D.ERR_CANCELED,n,s),this.name="CanceledError",this.__CANCEL__=!0}};function zs(e,t,n){const s=n.config.validateStatus;!n.status||!s||s(n.status)?e(n):t(new D("Request failed with status code "+n.status,n.status>=400&&n.status<500?D.ERR_BAD_REQUEST:D.ERR_BAD_RESPONSE,n.config,n.request,n))}function Hl(e){const t=/^([-+\w]{1,25}):(?:\/\/)?/.exec(e);return t&&t[1]||""}function Vl(e,t){e=e||10;const n=new Array(e),s=new Array(e);let r=0,o=0,i;return t=t!==void 0?t:1e3,function(a){const c=Date.now(),u=s[o];i||(i=c),n[r]=a,s[r]=c;let h=o,f=0;for(;h!==r;)f+=n[h++],h=h%e;if(r=(r+1)%e,r===o&&(o=(o+1)%e),c-i<t)return;const E=u&&c-u;return E?Math.round(f*1e3/E):void 0}}function ql(e,t){let n=0,s=1e3/t,r,o;const i=(c,u=Date.now())=>{n=u,r=null,o&&(clearTimeout(o),o=null),e(...c)};return[(...c)=>{const u=Date.now(),h=u-n;h>=s?i(c,u):(r=c,o||(o=setTimeout(()=>{o=null,i(r)},s-h)))},()=>r&&i(r)]}const St=(e,t,n=3)=>{let s=0;const r=Vl(50,250);return ql(o=>{if(!o||typeof o.loaded!="number")return;const i=o.loaded,l=o.lengthComputable?o.total:void 0,a=l!=null?Math.min(i,l):i,c=Math.max(0,a-s),u=r(c);s=Math.max(s,a);const h={loaded:a,total:l,progress:l?a/l:void 0,bytes:c,rate:u||void 0,estimated:u&&l?(l-a)/u:void 0,event:o,lengthComputable:l!=null,[t?"download":"upload"]:!0};e(h)},n)},Vn=(e,t)=>{const n=e!=null;return[s=>t[0]({lengthComputable:n,total:e,loaded:s}),t[1]]},qn=e=>(...t)=>m.asap(()=>e(...t)),Gl=le.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,le.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(le.origin),le.navigator&&/(msie|trident)/i.test(le.navigator.userAgent)):()=>!0,Kl=le.hasStandardBrowserEnv?{write(e,t,n,s,r,o,i){if(typeof document>"u")return;const l=[`${e}=${encodeURIComponent(t)}`];m.isNumber(n)&&l.push(`expires=${new Date(n).toUTCString()}`),m.isString(s)&&l.push(`path=${s}`),m.isString(r)&&l.push(`domain=${r}`),o===!0&&l.push("secure"),m.isString(i)&&l.push(`SameSite=${i}`),document.cookie=l.join("; ")},read(e){if(typeof document>"u")return null;const t=document.cookie.split(";");for(let n=0;n<t.length;n++){const s=t[n].replace(/^\s+/,""),r=s.indexOf("=");if(r!==-1&&s.slice(0,r)===e)return decodeURIComponent(s.slice(r+1))}return null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Wl(e){return typeof e!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function zl(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Js(e,t,n){let s=!Wl(t);return e&&(s||n===!1)?zl(e,t):t}const Gn=e=>e instanceof ue?{...e}:e;function De(e,t){t=t||{};const n=Object.create(null);Object.defineProperty(n,"hasOwnProperty",{__proto__:null,value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function s(c,u,h,f){return m.isPlainObject(c)&&m.isPlainObject(u)?m.merge.call({caseless:f},c,u):m.isPlainObject(u)?m.merge({},u):m.isArray(u)?u.slice():u}function r(c,u,h,f){if(m.isUndefined(u)){if(!m.isUndefined(c))return s(void 0,c,h,f)}else return s(c,u,h,f)}function o(c,u){if(!m.isUndefined(u))return s(void 0,u)}function i(c,u){if(m.isUndefined(u)){if(!m.isUndefined(c))return s(void 0,c)}else return s(void 0,u)}function l(c,u,h){if(m.hasOwnProp(t,h))return s(c,u);if(m.hasOwnProp(e,h))return s(void 0,c)}const a={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,allowedSocketPaths:i,responseEncoding:i,validateStatus:l,headers:(c,u,h)=>r(Gn(c),Gn(u),h,!0)};return m.forEach(Object.keys({...e,...t}),function(u){if(u==="__proto__"||u==="constructor"||u==="prototype")return;const h=m.hasOwnProp(a,u)?a[u]:r,f=m.hasOwnProp(e,u)?e[u]:void 0,E=m.hasOwnProp(t,u)?t[u]:void 0,y=h(f,E,u);m.isUndefined(y)&&h!==l||(n[u]=y)}),n}const Jl=["content-type","content-length"];function Xl(e,t,n){if(n!=="content-only"){e.set(t);return}Object.entries(t).forEach(([s,r])=>{Jl.includes(s.toLowerCase())&&e.set(s,r)})}const Ql=e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(t,n)=>String.fromCharCode(parseInt(n,16)));function Xs(e){const t=De({},e),n=f=>m.hasOwnProp(t,f)?t[f]:void 0,s=n("data");let r=n("withXSRFToken");const o=n("xsrfHeaderName"),i=n("xsrfCookieName");let l=n("headers");const a=n("auth"),c=n("baseURL"),u=n("allowAbsoluteUrls"),h=n("url");if(t.headers=l=ue.from(l),t.url=Gs(Js(c,h,u),n("params"),n("paramsSerializer")),a&&l.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?Ql(a.password):""))),m.isFormData(s)&&(le.hasStandardBrowserEnv||le.hasStandardBrowserWebWorkerEnv||m.isReactNative(s)?l.setContentType(void 0):m.isFunction(s.getHeaders)&&Xl(l,s.getHeaders(),n("formDataHeaderPolicy"))),le.hasStandardBrowserEnv&&(m.isFunction(r)&&(r=r(t)),r===!0||r==null&&Gl(t.url))){const E=o&&i&&Kl.read(i);E&&l.set(o,E)}return t}const Zl=typeof XMLHttpRequest<"u",ea=Zl&&function(e){return new Promise(function(n,s){const r=Xs(e);let o=r.data;const i=ue.from(r.headers).normalize();let{responseType:l,onUploadProgress:a,onDownloadProgress:c}=r,u,h,f,E,y;function p(){E&&E(),y&&y(),r.cancelToken&&r.cancelToken.unsubscribe(u),r.signal&&r.signal.removeEventListener("abort",u)}let A=new XMLHttpRequest;A.open(r.method.toUpperCase(),r.url,!0),A.timeout=r.timeout;function T(){if(!A)return;const C=ue.from("getAllResponseHeaders"in A&&A.getAllResponseHeaders()),P={data:!l||l==="text"||l==="json"?A.responseText:A.response,status:A.status,statusText:A.statusText,headers:C,config:e,request:A};zs(function(g){n(g),p()},function(g){s(g),p()},P),A=null}"onloadend"in A?A.onloadend=T:A.onreadystatechange=function(){!A||A.readyState!==4||A.status===0&&!(A.responseURL&&A.responseURL.startsWith("file:"))||setTimeout(T)},A.onabort=function(){A&&(s(new D("Request aborted",D.ECONNABORTED,e,A)),p(),A=null)},A.onerror=function(b){const P=b&&b.message?b.message:"Network Error",U=new D(P,D.ERR_NETWORK,e,A);U.event=b||null,s(U),p(),A=null},A.ontimeout=function(){let b=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const P=r.transitional||An;r.timeoutErrorMessage&&(b=r.timeoutErrorMessage),s(new D(b,P.clarifyTimeoutError?D.ETIMEDOUT:D.ECONNABORTED,e,A)),p(),A=null},o===void 0&&i.setContentType(null),"setRequestHeader"in A&&m.forEach(Ys(i),function(b,P){A.setRequestHeader(P,b)}),m.isUndefined(r.withCredentials)||(A.withCredentials=!!r.withCredentials),l&&l!=="json"&&(A.responseType=r.responseType),c&&([f,y]=St(c,!0),A.addEventListener("progress",f)),a&&A.upload&&([h,E]=St(a),A.upload.addEventListener("progress",h),A.upload.addEventListener("loadend",E)),(r.cancelToken||r.signal)&&(u=C=>{A&&(s(!C||C.type?new rt(null,e,A):C),A.abort(),p(),A=null)},r.cancelToken&&r.cancelToken.subscribe(u),r.signal&&(r.signal.aborted?u():r.signal.addEventListener("abort",u)));const N=Hl(r.url);if(N&&!le.protocols.includes(N)){s(new D("Unsupported protocol "+N+":",D.ERR_BAD_REQUEST,e));return}A.send(o||null)})},ta=(e,t)=>{if(e=e?e.filter(Boolean):[],!t&&!e.length)return;const n=new AbortController;let s=!1;const r=function(a){if(!s){s=!0,i();const c=a instanceof Error?a:this.reason;n.abort(c instanceof D?c:new rt(c instanceof Error?c.message:c))}};let o=t&&setTimeout(()=>{o=null,r(new D(`timeout of ${t}ms exceeded`,D.ETIMEDOUT))},t);const i=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(a=>{a.unsubscribe?a.unsubscribe(r):a.removeEventListener("abort",r)}),e=null)};e.forEach(a=>a.addEventListener("abort",r));const{signal:l}=n;return l.unsubscribe=()=>m.asap(i),l},na=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let s=0,r;for(;s<n;)r=s+t,yield e.slice(s,r),s=r},sa=async function*(e,t){for await(const n of ra(e))yield*na(n,t)},ra=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:s}=await t.read();if(n)break;yield s}}finally{await t.cancel()}},Kn=(e,t,n,s)=>{const r=sa(e,t);let o=0,i,l=a=>{i||(i=!0,s&&s(a))};return new ReadableStream({async pull(a){try{const{done:c,value:u}=await r.next();if(c){l(),a.close();return}let h=u.byteLength;if(n){let f=o+=h;n(f)}a.enqueue(new Uint8Array(u))}catch(c){throw l(c),c}},cancel(a){return l(a),r.return()}},{highWaterMark:2})};function oa(e){if(!e||typeof e!="string"||!e.startsWith("data:"))return 0;const t=e.indexOf(",");if(t<0)return 0;const n=e.slice(5,t),s=e.slice(t+1);if(/;base64/i.test(n)){let i=s.length;const l=s.length;for(let E=0;E<l;E++)if(s.charCodeAt(E)===37&&E+2<l){const y=s.charCodeAt(E+1),p=s.charCodeAt(E+2);(y>=48&&y<=57||y>=65&&y<=70||y>=97&&y<=102)&&(p>=48&&p<=57||p>=65&&p<=70||p>=97&&p<=102)&&(i-=2,E+=2)}let a=0,c=l-1;const u=E=>E>=2&&s.charCodeAt(E-2)===37&&s.charCodeAt(E-1)===51&&(s.charCodeAt(E)===68||s.charCodeAt(E)===100);c>=0&&(s.charCodeAt(c)===61?(a++,c--):u(c)&&(a++,c-=3)),a===1&&c>=0&&(s.charCodeAt(c)===61||u(c))&&a++;const f=Math.floor(i/4)*3-(a||0);return f>0?f:0}if(typeof Buffer<"u"&&typeof Buffer.byteLength=="function")return Buffer.byteLength(s,"utf8");let o=0;for(let i=0,l=s.length;i<l;i++){const a=s.charCodeAt(i);if(a<128)o+=1;else if(a<2048)o+=2;else if(a>=55296&&a<=56319&&i+1<l){const c=s.charCodeAt(i+1);c>=56320&&c<=57343?(o+=4,i++):o+=3}else o+=3}return o}const Tn="1.17.0",Wn=64*1024,{isFunction:dt}=m,ia=e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(t,n)=>String.fromCharCode(parseInt(n,16))),zn=e=>{if(!m.isString(e))return e;try{return decodeURIComponent(e)}catch{return e}},Jn=(e,...t)=>{try{return!!e(...t)}catch{return!1}},la=e=>{const t=e.indexOf("://");let n=e;return t!==-1&&(n=n.slice(t+3)),n.includes("@")||n.includes(":")},aa=e=>{const t=m.global!==void 0&&m.global!==null?m.global:globalThis,{ReadableStream:n,TextEncoder:s}=t;e=m.merge.call({skipUndefined:!0},{Request:t.Request,Response:t.Response},e);const{fetch:r,Request:o,Response:i}=e,l=r?dt(r):typeof fetch=="function",a=dt(o),c=dt(i);if(!l)return!1;const u=l&&dt(n),h=l&&(typeof s=="function"?(T=>N=>T.encode(N))(new s):async T=>new Uint8Array(await new o(T).arrayBuffer())),f=a&&u&&Jn(()=>{let T=!1;const N=new o(le.origin,{body:new n,method:"POST",get duplex(){return T=!0,"half"}}),C=N.headers.has("Content-Type");return N.body!=null&&N.body.cancel(),T&&!C}),E=c&&u&&Jn(()=>m.isReadableStream(new i("").body)),y={stream:E&&(T=>T.body)};l&&["text","arrayBuffer","blob","formData","stream"].forEach(T=>{!y[T]&&(y[T]=(N,C)=>{let b=N&&N[T];if(b)return b.call(N);throw new D(`Response type '${T}' is not supported`,D.ERR_NOT_SUPPORT,C)})});const p=async T=>{if(T==null)return 0;if(m.isBlob(T))return T.size;if(m.isSpecCompliantForm(T))return(await new o(le.origin,{method:"POST",body:T}).arrayBuffer()).byteLength;if(m.isArrayBufferView(T)||m.isArrayBuffer(T))return T.byteLength;if(m.isURLSearchParams(T)&&(T=T+""),m.isString(T))return(await h(T)).byteLength},A=async(T,N)=>{const C=m.toFiniteNumber(T.getContentLength());return C??p(N)};return async T=>{let{url:N,method:C,data:b,signal:P,cancelToken:U,timeout:g,onDownloadProgress:L,onUploadProgress:v,responseType:F,headers:I,withCredentials:k="same-origin",fetchOptions:O,maxContentLength:x,maxBodyLength:j}=Xs(T);const $=m.isNumber(x)&&x>-1,q=m.isNumber(j)&&j>-1,X=Y=>m.hasOwnProp(T,Y)?T[Y]:void 0;let G=r||fetch;F=F?(F+"").toLowerCase():"text";let V=ta([P,U&&U.toAbortSignal()],g),z=null;const fe=V&&V.unsubscribe&&(()=>{V.unsubscribe()});let pe;try{let Y;const J=X("auth");if(J){const M=J.username||"",oe=J.password||"";Y={username:M,password:oe}}if(la(N)){const M=new URL(N,le.origin);if(!Y&&(M.username||M.password)){const oe=zn(M.username),be=zn(M.password);Y={username:oe,password:be}}(M.username||M.password)&&(M.username="",M.password="",N=M.href)}if(Y&&(I.delete("authorization"),I.set("Authorization","Basic "+btoa(ia((Y.username||"")+":"+(Y.password||""))))),$&&typeof N=="string"&&N.startsWith("data:")&&oa(N)>x)throw new D("maxContentLength size of "+x+" exceeded",D.ERR_BAD_RESPONSE,T,z);if(q&&C!=="get"&&C!=="head"){const M=await A(I,b);if(typeof M=="number"&&isFinite(M)&&M>j)throw new D("Request body larger than maxBodyLength limit",D.ERR_BAD_REQUEST,T,z)}if(v&&f&&C!=="get"&&C!=="head"&&(pe=await A(I,b))!==0){let M=new o(N,{method:"POST",body:b,duplex:"half"}),oe;if(m.isFormData(b)&&(oe=M.headers.get("content-type"))&&I.setContentType(oe),M.body){const[be,ve]=Vn(pe,St(qn(v)));b=Kn(M.body,Wn,be,ve)}}m.isString(k)||(k=k?"include":"omit");const Ke=a&&"credentials"in o.prototype;if(m.isFormData(b)){const M=I.getContentType();M&&/^multipart\/form-data/i.test(M)&&!/boundary=/i.test(M)&&I.delete("content-type")}I.set("User-Agent","axios/"+Tn,!1);const We={...O,signal:V,method:C.toUpperCase(),headers:Ys(I.normalize()),body:b,duplex:"half",credentials:Ke?k:void 0};z=a&&new o(N,We);let Ee=await(a?G(z,O):G(N,We));if($){const M=m.toFiniteNumber(Ee.headers.get("content-length"));if(M!=null&&M>x)throw new D("maxContentLength size of "+x+" exceeded",D.ERR_BAD_RESPONSE,T,z)}const xe=E&&(F==="stream"||F==="response");if(E&&Ee.body&&(L||$||xe&&fe)){const M={};["status","statusText","headers"].forEach(Fe=>{M[Fe]=Ee[Fe]});const oe=m.toFiniteNumber(Ee.headers.get("content-length")),[be,ve]=L&&Vn(oe,St(qn(L),!0))||[];let lt=0;const vn=Fe=>{if($&&(lt=Fe,lt>x))throw new D("maxContentLength size of "+x+" exceeded",D.ERR_BAD_RESPONSE,T,z);be&&be(Fe)};Ee=new i(Kn(Ee.body,Wn,vn,()=>{ve&&ve(),fe&&fe()}),M)}F=F||"text";let Ae=await y[m.findKey(y,F)||"text"](Ee,T);if($&&!E&&!xe){let M;if(Ae!=null&&(typeof Ae.byteLength=="number"?M=Ae.byteLength:typeof Ae.size=="number"?M=Ae.size:typeof Ae=="string"&&(M=typeof s=="function"?new s().encode(Ae).byteLength:Ae.length)),typeof M=="number"&&M>x)throw new D("maxContentLength size of "+x+" exceeded",D.ERR_BAD_RESPONSE,T,z)}return!xe&&fe&&fe(),await new Promise((M,oe)=>{zs(M,oe,{data:Ae,headers:ue.from(Ee.headers),status:Ee.status,statusText:Ee.statusText,config:T,request:z})})}catch(Y){if(fe&&fe(),V&&V.aborted&&V.reason instanceof D){const J=V.reason;throw J.config=T,z&&(J.request=z),Y!==J&&(J.cause=Y),J}throw Y&&Y.name==="TypeError"&&/Load failed|fetch/i.test(Y.message)?Object.assign(new D("Network Error",D.ERR_NETWORK,T,z,Y&&Y.response),{cause:Y.cause||Y}):D.from(Y,Y&&Y.code,T,z,Y&&Y.response)}}},ca=new Map,Qs=e=>{let t=e&&e.env||{};const{fetch:n,Request:s,Response:r}=t,o=[s,r,n];let i=o.length,l=i,a,c,u=ca;for(;l--;)a=o[l],c=u.get(a),c===void 0&&u.set(a,c=l?new Map:aa(t)),u=c;return c};Qs();const Sn={http:Pl,xhr:ea,fetch:{get:Qs}};m.forEach(Sn,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{__proto__:null,value:t})}catch{}Object.defineProperty(e,"adapterName",{__proto__:null,value:t})}});const Xn=e=>`- ${e}`,ua=e=>m.isFunction(e)||e===null||e===!1;function da(e,t){e=m.isArray(e)?e:[e];const{length:n}=e;let s,r;const o={};for(let i=0;i<n;i++){s=e[i];let l;if(r=s,!ua(s)&&(r=Sn[(l=String(s)).toLowerCase()],r===void 0))throw new D(`Unknown adapter '${l}'`);if(r&&(m.isFunction(r)||(r=r.get(t))))break;o[l||"#"+i]=r}if(!r){const i=Object.entries(o).map(([a,c])=>`adapter ${a} `+(c===!1?"is not supported by the environment":"is not available in the build"));let l=n?i.length>1?`since :
3
+ `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const s=new this(t);return n.forEach(r=>s.set(r)),s}static accessor(t){const s=(this[$n]=this[$n]={accessors:{}}).accessors,r=this.prototype;function o(i){const l=ze(i);s[l]||(bl(r,i),s[l]=!0)}return m.isArray(t)?t.forEach(o):o(t),this}};ue.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);m.reduceDescriptors(ue.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(s){this[n]=s}}});m.freezeMethods(ue);const wl="[REDACTED ****]";function _l(e){if(m.hasOwnProp(e,"toJSON"))return!0;let t=Object.getPrototypeOf(e);for(;t&&t!==Object.prototype;){if(m.hasOwnProp(t,"toJSON"))return!0;t=Object.getPrototypeOf(t)}return!1}function Il(e,t){const n=new Set(t.map(o=>String(o).toLowerCase())),s=[],r=o=>{if(o===null||typeof o!="object"||m.isBuffer(o))return o;if(s.indexOf(o)!==-1)return;o instanceof ue&&(o=o.toJSON()),s.push(o);let i;if(m.isArray(o))i=[],o.forEach((l,a)=>{const c=r(l);m.isUndefined(c)||(i[a]=c)});else{if(!m.isPlainObject(o)&&_l(o))return s.pop(),o;i=Object.create(null);for(const[l,a]of Object.entries(o)){const c=n.has(l.toLowerCase())?wl:r(a);m.isUndefined(c)||(i[l]=c)}}return s.pop(),i};return r(e)}let D=class Hs extends Error{static from(t,n,s,r,o,i){const l=new Hs(t.message,n||t.code,s,r,o);return l.cause=t,l.name=t.name,t.status!=null&&l.status==null&&(l.status=t.status),i&&Object.assign(l,i),l}constructor(t,n,s,r,o){super(t),Object.defineProperty(this,"message",{__proto__:null,value:t,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,n&&(this.code=n),s&&(this.config=s),r&&(this.request=r),o&&(this.response=o,this.status=o.status)}toJSON(){const t=this.config,n=t&&m.hasOwnProp(t,"redact")?t.redact:void 0,s=m.isArray(n)&&n.length>0?Il(t,n):m.toJSONObject(t);return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:s,code:this.code,status:this.status}}};D.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";D.ERR_BAD_OPTION="ERR_BAD_OPTION";D.ECONNABORTED="ECONNABORTED";D.ETIMEDOUT="ETIMEDOUT";D.ECONNREFUSED="ECONNREFUSED";D.ERR_NETWORK="ERR_NETWORK";D.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";D.ERR_DEPRECATED="ERR_DEPRECATED";D.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";D.ERR_BAD_REQUEST="ERR_BAD_REQUEST";D.ERR_CANCELED="ERR_CANCELED";D.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";D.ERR_INVALID_URL="ERR_INVALID_URL";D.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";const Pl=null;function tn(e){return m.isPlainObject(e)||m.isArray(e)}function Vs(e){return m.endsWith(e,"[]")?e.slice(0,-2):e}function kt(e,t,n){return e?e.concat(t).map(function(r,o){return r=Vs(r),!n&&o?"["+r+"]":r}).join(n?".":""):t}function xl(e){return m.isArray(e)&&!e.some(tn)}const Ol=m.toFlatObject(m,{},null,function(t){return/^is[A-Z]/.test(t)});function Rt(e,t,n){if(!m.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=m.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(A,T){return!m.isUndefined(T[A])});const s=n.metaTokens,r=n.visitor||h,o=n.dots,i=n.indexes,l=n.Blob||typeof Blob<"u"&&Blob,a=n.maxDepth===void 0?100:n.maxDepth,c=l&&m.isSpecCompliantForm(t);if(!m.isFunction(r))throw new TypeError("visitor must be a function");function u(p){if(p===null)return"";if(m.isDate(p))return p.toISOString();if(m.isBoolean(p))return p.toString();if(!c&&m.isBlob(p))throw new D("Blob is not supported. Use a Buffer instead.");return m.isArrayBuffer(p)||m.isTypedArray(p)?c&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function h(p,A,T){let N=p;if(m.isReactNative(t)&&m.isReactNativeBlob(p))return t.append(kt(T,A,o),u(p)),!1;if(p&&!T&&typeof p=="object"){if(m.endsWith(A,"{}"))A=s?A:A.slice(0,-2),p=JSON.stringify(p);else if(m.isArray(p)&&xl(p)||(m.isFileList(p)||m.endsWith(A,"[]"))&&(N=m.toArray(p)))return A=Vs(A),N.forEach(function(b,I){!(m.isUndefined(b)||b===null)&&t.append(i===!0?kt([A],I,o):i===null?A:A+"[]",u(b))}),!1}return tn(p)?!0:(t.append(kt(T,A,o),u(p)),!1)}const f=[],E=Object.assign(Ol,{defaultVisitor:h,convertValue:u,isVisitable:tn});function y(p,A,T=0){if(!m.isUndefined(p)){if(T>a)throw new D("Object is too deeply nested ("+T+" levels). Max depth: "+a,D.ERR_FORM_DATA_DEPTH_EXCEEDED);if(f.indexOf(p)!==-1)throw new Error("Circular reference detected in "+A.join("."));f.push(p),m.forEach(p,function(C,b){(!(m.isUndefined(C)||C===null)&&r.call(t,C,m.isString(b)?b.trim():b,A,E))===!0&&y(C,A?A.concat(b):[b],T+1)}),f.pop()}}if(!m.isObject(e))throw new TypeError("data must be an object");return y(e),t}function Yn(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(e).replace(/[!'()~]|%20/g,function(s){return t[s]})}function En(e,t){this._pairs=[],e&&Rt(e,this,t)}const qs=En.prototype;qs.append=function(t,n){this._pairs.push([t,n])};qs.toString=function(t){const n=t?function(s){return t.call(this,s,Yn)}:Yn;return this._pairs.map(function(r){return n(r[0])+"="+n(r[1])},"").join("&")};function Rl(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Gs(e,t,n){if(!t)return e;const s=n&&n.encode||Rl,r=m.isFunction(n)?{serialize:n}:n,o=r&&r.serialize;let i;if(o?i=o(t,r):i=m.isURLSearchParams(t)?t.toString():new En(t,r).toString(s),i){const l=e.indexOf("#");l!==-1&&(e=e.slice(0,l)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class Hn{constructor(){this.handlers=[]}use(t,n,s){return this.handlers.push({fulfilled:t,rejected:n,synchronous:s?s.synchronous:!1,runWhen:s?s.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){m.forEach(this.handlers,function(s){s!==null&&t(s)})}}const An={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0,advertiseZstdAcceptEncoding:!1},Nl=typeof URLSearchParams<"u"?URLSearchParams:En,Ll=typeof FormData<"u"?FormData:null,Dl=typeof Blob<"u"?Blob:null,vl={isBrowser:!0,classes:{URLSearchParams:Nl,FormData:Ll,Blob:Dl},protocols:["http","https","file","blob","url","data"]},yn=typeof window<"u"&&typeof document<"u",nn=typeof navigator=="object"&&navigator||void 0,Fl=yn&&(!nn||["ReactNative","NativeScript","NS"].indexOf(nn.product)<0),jl=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Ul=yn&&window.location.href||"http://localhost",Ml=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:yn,hasStandardBrowserEnv:Fl,hasStandardBrowserWebWorkerEnv:jl,navigator:nn,origin:Ul},Symbol.toStringTag,{value:"Module"})),le={...Ml,...vl};function kl(e,t){return Rt(e,new le.classes.URLSearchParams,{visitor:function(n,s,r,o){return le.isNode&&m.isBuffer(n)?(this.append(s,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...t})}function Bl(e){return m.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function $l(e){const t={},n=Object.keys(e);let s;const r=n.length;let o;for(s=0;s<r;s++)o=n[s],t[o]=e[o];return t}function Ks(e){function t(n,s,r,o){let i=n[o++];if(i==="__proto__")return!0;const l=Number.isFinite(+i),a=o>=n.length;return i=!i&&m.isArray(r)?r.length:i,a?(m.hasOwnProp(r,i)?r[i]=m.isArray(r[i])?r[i].concat(s):[r[i],s]:r[i]=s,!l):((!m.hasOwnProp(r,i)||!m.isObject(r[i]))&&(r[i]=[]),t(n,s,r[i],o)&&m.isArray(r[i])&&(r[i]=$l(r[i])),!l)}if(m.isFormData(e)&&m.isFunction(e.entries)){const n={};return m.forEachEntry(e,(s,r)=>{t(Bl(s),r,n,0)}),n}return null}const je=(e,t)=>e!=null&&m.hasOwnProp(e,t)?e[t]:void 0;function Yl(e,t,n){if(m.isString(e))try{return(t||JSON.parse)(e),m.trim(e)}catch(s){if(s.name!=="SyntaxError")throw s}return(n||JSON.stringify)(e)}const st={transitional:An,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const s=n.getContentType()||"",r=s.indexOf("application/json")>-1,o=m.isObject(t);if(o&&m.isHTMLForm(t)&&(t=new FormData(t)),m.isFormData(t))return r?JSON.stringify(Ks(t)):t;if(m.isArrayBuffer(t)||m.isBuffer(t)||m.isStream(t)||m.isFile(t)||m.isBlob(t)||m.isReadableStream(t))return t;if(m.isArrayBufferView(t))return t.buffer;if(m.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(o){const a=je(this,"formSerializer");if(s.indexOf("application/x-www-form-urlencoded")>-1)return kl(t,a).toString();if((l=m.isFileList(t))||s.indexOf("multipart/form-data")>-1){const c=je(this,"env"),u=c&&c.FormData;return Rt(l?{"files[]":t}:t,u&&new u,a)}}return o||r?(n.setContentType("application/json",!1),Yl(t)):t}],transformResponse:[function(t){const n=je(this,"transitional")||st.transitional,s=n&&n.forcedJSONParsing,r=je(this,"responseType"),o=r==="json";if(m.isResponse(t)||m.isReadableStream(t))return t;if(t&&m.isString(t)&&(s&&!r||o)){const l=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,je(this,"parseReviver"))}catch(a){if(l)throw a.name==="SyntaxError"?D.from(a,D.ERR_BAD_RESPONSE,this,null,je(this,"response")):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:le.classes.FormData,Blob:le.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};m.forEach(["delete","get","head","post","put","patch","query"],e=>{st.headers[e]={}});function Bt(e,t){const n=this||st,s=t||n,r=ue.from(s.headers);let o=s.data;return m.forEach(e,function(l){o=l.call(n,o,r.normalize(),t?t.status:void 0)}),r.normalize(),o}function Ws(e){return!!(e&&e.__CANCEL__)}let rt=class extends D{constructor(t,n,s){super(t??"canceled",D.ERR_CANCELED,n,s),this.name="CanceledError",this.__CANCEL__=!0}};function zs(e,t,n){const s=n.config.validateStatus;!n.status||!s||s(n.status)?e(n):t(new D("Request failed with status code "+n.status,n.status>=400&&n.status<500?D.ERR_BAD_REQUEST:D.ERR_BAD_RESPONSE,n.config,n.request,n))}function Hl(e){const t=/^([-+\w]{1,25}):(?:\/\/)?/.exec(e);return t&&t[1]||""}function Vl(e,t){e=e||10;const n=new Array(e),s=new Array(e);let r=0,o=0,i;return t=t!==void 0?t:1e3,function(a){const c=Date.now(),u=s[o];i||(i=c),n[r]=a,s[r]=c;let h=o,f=0;for(;h!==r;)f+=n[h++],h=h%e;if(r=(r+1)%e,r===o&&(o=(o+1)%e),c-i<t)return;const E=u&&c-u;return E?Math.round(f*1e3/E):void 0}}function ql(e,t){let n=0,s=1e3/t,r,o;const i=(c,u=Date.now())=>{n=u,r=null,o&&(clearTimeout(o),o=null),e(...c)};return[(...c)=>{const u=Date.now(),h=u-n;h>=s?i(c,u):(r=c,o||(o=setTimeout(()=>{o=null,i(r)},s-h)))},()=>r&&i(r)]}const St=(e,t,n=3)=>{let s=0;const r=Vl(50,250);return ql(o=>{if(!o||typeof o.loaded!="number")return;const i=o.loaded,l=o.lengthComputable?o.total:void 0,a=l!=null?Math.min(i,l):i,c=Math.max(0,a-s),u=r(c);s=Math.max(s,a);const h={loaded:a,total:l,progress:l?a/l:void 0,bytes:c,rate:u||void 0,estimated:u&&l?(l-a)/u:void 0,event:o,lengthComputable:l!=null,[t?"download":"upload"]:!0};e(h)},n)},Vn=(e,t)=>{const n=e!=null;return[s=>t[0]({lengthComputable:n,total:e,loaded:s}),t[1]]},qn=e=>(...t)=>m.asap(()=>e(...t)),Gl=le.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,le.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(le.origin),le.navigator&&/(msie|trident)/i.test(le.navigator.userAgent)):()=>!0,Kl=le.hasStandardBrowserEnv?{write(e,t,n,s,r,o,i){if(typeof document>"u")return;const l=[`${e}=${encodeURIComponent(t)}`];m.isNumber(n)&&l.push(`expires=${new Date(n).toUTCString()}`),m.isString(s)&&l.push(`path=${s}`),m.isString(r)&&l.push(`domain=${r}`),o===!0&&l.push("secure"),m.isString(i)&&l.push(`SameSite=${i}`),document.cookie=l.join("; ")},read(e){if(typeof document>"u")return null;const t=document.cookie.split(";");for(let n=0;n<t.length;n++){const s=t[n].replace(/^\s+/,""),r=s.indexOf("=");if(r!==-1&&s.slice(0,r)===e)return decodeURIComponent(s.slice(r+1))}return null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Wl(e){return typeof e!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function zl(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Js(e,t,n){let s=!Wl(t);return e&&(s||n===!1)?zl(e,t):t}const Gn=e=>e instanceof ue?{...e}:e;function De(e,t){t=t||{};const n=Object.create(null);Object.defineProperty(n,"hasOwnProperty",{__proto__:null,value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function s(c,u,h,f){return m.isPlainObject(c)&&m.isPlainObject(u)?m.merge.call({caseless:f},c,u):m.isPlainObject(u)?m.merge({},u):m.isArray(u)?u.slice():u}function r(c,u,h,f){if(m.isUndefined(u)){if(!m.isUndefined(c))return s(void 0,c,h,f)}else return s(c,u,h,f)}function o(c,u){if(!m.isUndefined(u))return s(void 0,u)}function i(c,u){if(m.isUndefined(u)){if(!m.isUndefined(c))return s(void 0,c)}else return s(void 0,u)}function l(c,u,h){if(m.hasOwnProp(t,h))return s(c,u);if(m.hasOwnProp(e,h))return s(void 0,c)}const a={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,allowedSocketPaths:i,responseEncoding:i,validateStatus:l,headers:(c,u,h)=>r(Gn(c),Gn(u),h,!0)};return m.forEach(Object.keys({...e,...t}),function(u){if(u==="__proto__"||u==="constructor"||u==="prototype")return;const h=m.hasOwnProp(a,u)?a[u]:r,f=m.hasOwnProp(e,u)?e[u]:void 0,E=m.hasOwnProp(t,u)?t[u]:void 0,y=h(f,E,u);m.isUndefined(y)&&h!==l||(n[u]=y)}),n}const Jl=["content-type","content-length"];function Xl(e,t,n){if(n!=="content-only"){e.set(t);return}Object.entries(t).forEach(([s,r])=>{Jl.includes(s.toLowerCase())&&e.set(s,r)})}const Ql=e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(t,n)=>String.fromCharCode(parseInt(n,16)));function Xs(e){const t=De({},e),n=f=>m.hasOwnProp(t,f)?t[f]:void 0,s=n("data");let r=n("withXSRFToken");const o=n("xsrfHeaderName"),i=n("xsrfCookieName");let l=n("headers");const a=n("auth"),c=n("baseURL"),u=n("allowAbsoluteUrls"),h=n("url");if(t.headers=l=ue.from(l),t.url=Gs(Js(c,h,u),n("params"),n("paramsSerializer")),a&&l.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?Ql(a.password):""))),m.isFormData(s)&&(le.hasStandardBrowserEnv||le.hasStandardBrowserWebWorkerEnv||m.isReactNative(s)?l.setContentType(void 0):m.isFunction(s.getHeaders)&&Xl(l,s.getHeaders(),n("formDataHeaderPolicy"))),le.hasStandardBrowserEnv&&(m.isFunction(r)&&(r=r(t)),r===!0||r==null&&Gl(t.url))){const E=o&&i&&Kl.read(i);E&&l.set(o,E)}return t}const Zl=typeof XMLHttpRequest<"u",ea=Zl&&function(e){return new Promise(function(n,s){const r=Xs(e);let o=r.data;const i=ue.from(r.headers).normalize();let{responseType:l,onUploadProgress:a,onDownloadProgress:c}=r,u,h,f,E,y;function p(){E&&E(),y&&y(),r.cancelToken&&r.cancelToken.unsubscribe(u),r.signal&&r.signal.removeEventListener("abort",u)}let A=new XMLHttpRequest;A.open(r.method.toUpperCase(),r.url,!0),A.timeout=r.timeout;function T(){if(!A)return;const C=ue.from("getAllResponseHeaders"in A&&A.getAllResponseHeaders()),I={data:!l||l==="text"||l==="json"?A.responseText:A.response,status:A.status,statusText:A.statusText,headers:C,config:e,request:A};zs(function(g){n(g),p()},function(g){s(g),p()},I),A=null}"onloadend"in A?A.onloadend=T:A.onreadystatechange=function(){!A||A.readyState!==4||A.status===0&&!(A.responseURL&&A.responseURL.startsWith("file:"))||setTimeout(T)},A.onabort=function(){A&&(s(new D("Request aborted",D.ECONNABORTED,e,A)),p(),A=null)},A.onerror=function(b){const I=b&&b.message?b.message:"Network Error",U=new D(I,D.ERR_NETWORK,e,A);U.event=b||null,s(U),p(),A=null},A.ontimeout=function(){let b=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const I=r.transitional||An;r.timeoutErrorMessage&&(b=r.timeoutErrorMessage),s(new D(b,I.clarifyTimeoutError?D.ETIMEDOUT:D.ECONNABORTED,e,A)),p(),A=null},o===void 0&&i.setContentType(null),"setRequestHeader"in A&&m.forEach(Ys(i),function(b,I){A.setRequestHeader(I,b)}),m.isUndefined(r.withCredentials)||(A.withCredentials=!!r.withCredentials),l&&l!=="json"&&(A.responseType=r.responseType),c&&([f,y]=St(c,!0),A.addEventListener("progress",f)),a&&A.upload&&([h,E]=St(a),A.upload.addEventListener("progress",h),A.upload.addEventListener("loadend",E)),(r.cancelToken||r.signal)&&(u=C=>{A&&(s(!C||C.type?new rt(null,e,A):C),A.abort(),p(),A=null)},r.cancelToken&&r.cancelToken.subscribe(u),r.signal&&(r.signal.aborted?u():r.signal.addEventListener("abort",u)));const N=Hl(r.url);if(N&&!le.protocols.includes(N)){s(new D("Unsupported protocol "+N+":",D.ERR_BAD_REQUEST,e));return}A.send(o||null)})},ta=(e,t)=>{if(e=e?e.filter(Boolean):[],!t&&!e.length)return;const n=new AbortController;let s=!1;const r=function(a){if(!s){s=!0,i();const c=a instanceof Error?a:this.reason;n.abort(c instanceof D?c:new rt(c instanceof Error?c.message:c))}};let o=t&&setTimeout(()=>{o=null,r(new D(`timeout of ${t}ms exceeded`,D.ETIMEDOUT))},t);const i=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(a=>{a.unsubscribe?a.unsubscribe(r):a.removeEventListener("abort",r)}),e=null)};e.forEach(a=>a.addEventListener("abort",r));const{signal:l}=n;return l.unsubscribe=()=>m.asap(i),l},na=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let s=0,r;for(;s<n;)r=s+t,yield e.slice(s,r),s=r},sa=async function*(e,t){for await(const n of ra(e))yield*na(n,t)},ra=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:s}=await t.read();if(n)break;yield s}}finally{await t.cancel()}},Kn=(e,t,n,s)=>{const r=sa(e,t);let o=0,i,l=a=>{i||(i=!0,s&&s(a))};return new ReadableStream({async pull(a){try{const{done:c,value:u}=await r.next();if(c){l(),a.close();return}let h=u.byteLength;if(n){let f=o+=h;n(f)}a.enqueue(new Uint8Array(u))}catch(c){throw l(c),c}},cancel(a){return l(a),r.return()}},{highWaterMark:2})};function oa(e){if(!e||typeof e!="string"||!e.startsWith("data:"))return 0;const t=e.indexOf(",");if(t<0)return 0;const n=e.slice(5,t),s=e.slice(t+1);if(/;base64/i.test(n)){let i=s.length;const l=s.length;for(let E=0;E<l;E++)if(s.charCodeAt(E)===37&&E+2<l){const y=s.charCodeAt(E+1),p=s.charCodeAt(E+2);(y>=48&&y<=57||y>=65&&y<=70||y>=97&&y<=102)&&(p>=48&&p<=57||p>=65&&p<=70||p>=97&&p<=102)&&(i-=2,E+=2)}let a=0,c=l-1;const u=E=>E>=2&&s.charCodeAt(E-2)===37&&s.charCodeAt(E-1)===51&&(s.charCodeAt(E)===68||s.charCodeAt(E)===100);c>=0&&(s.charCodeAt(c)===61?(a++,c--):u(c)&&(a++,c-=3)),a===1&&c>=0&&(s.charCodeAt(c)===61||u(c))&&a++;const f=Math.floor(i/4)*3-(a||0);return f>0?f:0}if(typeof Buffer<"u"&&typeof Buffer.byteLength=="function")return Buffer.byteLength(s,"utf8");let o=0;for(let i=0,l=s.length;i<l;i++){const a=s.charCodeAt(i);if(a<128)o+=1;else if(a<2048)o+=2;else if(a>=55296&&a<=56319&&i+1<l){const c=s.charCodeAt(i+1);c>=56320&&c<=57343?(o+=4,i++):o+=3}else o+=3}return o}const Tn="1.17.0",Wn=64*1024,{isFunction:dt}=m,ia=e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(t,n)=>String.fromCharCode(parseInt(n,16))),zn=e=>{if(!m.isString(e))return e;try{return decodeURIComponent(e)}catch{return e}},Jn=(e,...t)=>{try{return!!e(...t)}catch{return!1}},la=e=>{const t=e.indexOf("://");let n=e;return t!==-1&&(n=n.slice(t+3)),n.includes("@")||n.includes(":")},aa=e=>{const t=m.global!==void 0&&m.global!==null?m.global:globalThis,{ReadableStream:n,TextEncoder:s}=t;e=m.merge.call({skipUndefined:!0},{Request:t.Request,Response:t.Response},e);const{fetch:r,Request:o,Response:i}=e,l=r?dt(r):typeof fetch=="function",a=dt(o),c=dt(i);if(!l)return!1;const u=l&&dt(n),h=l&&(typeof s=="function"?(T=>N=>T.encode(N))(new s):async T=>new Uint8Array(await new o(T).arrayBuffer())),f=a&&u&&Jn(()=>{let T=!1;const N=new o(le.origin,{body:new n,method:"POST",get duplex(){return T=!0,"half"}}),C=N.headers.has("Content-Type");return N.body!=null&&N.body.cancel(),T&&!C}),E=c&&u&&Jn(()=>m.isReadableStream(new i("").body)),y={stream:E&&(T=>T.body)};l&&["text","arrayBuffer","blob","formData","stream"].forEach(T=>{!y[T]&&(y[T]=(N,C)=>{let b=N&&N[T];if(b)return b.call(N);throw new D(`Response type '${T}' is not supported`,D.ERR_NOT_SUPPORT,C)})});const p=async T=>{if(T==null)return 0;if(m.isBlob(T))return T.size;if(m.isSpecCompliantForm(T))return(await new o(le.origin,{method:"POST",body:T}).arrayBuffer()).byteLength;if(m.isArrayBufferView(T)||m.isArrayBuffer(T))return T.byteLength;if(m.isURLSearchParams(T)&&(T=T+""),m.isString(T))return(await h(T)).byteLength},A=async(T,N)=>{const C=m.toFiniteNumber(T.getContentLength());return C??p(N)};return async T=>{let{url:N,method:C,data:b,signal:I,cancelToken:U,timeout:g,onDownloadProgress:L,onUploadProgress:v,responseType:F,headers:P,withCredentials:k="same-origin",fetchOptions:O,maxContentLength:x,maxBodyLength:j}=Xs(T);const $=m.isNumber(x)&&x>-1,q=m.isNumber(j)&&j>-1,X=Y=>m.hasOwnProp(T,Y)?T[Y]:void 0;let G=r||fetch;F=F?(F+"").toLowerCase():"text";let V=ta([I,U&&U.toAbortSignal()],g),z=null;const fe=V&&V.unsubscribe&&(()=>{V.unsubscribe()});let pe;try{let Y;const J=X("auth");if(J){const M=J.username||"",oe=J.password||"";Y={username:M,password:oe}}if(la(N)){const M=new URL(N,le.origin);if(!Y&&(M.username||M.password)){const oe=zn(M.username),be=zn(M.password);Y={username:oe,password:be}}(M.username||M.password)&&(M.username="",M.password="",N=M.href)}if(Y&&(P.delete("authorization"),P.set("Authorization","Basic "+btoa(ia((Y.username||"")+":"+(Y.password||""))))),$&&typeof N=="string"&&N.startsWith("data:")&&oa(N)>x)throw new D("maxContentLength size of "+x+" exceeded",D.ERR_BAD_RESPONSE,T,z);if(q&&C!=="get"&&C!=="head"){const M=await A(P,b);if(typeof M=="number"&&isFinite(M)&&M>j)throw new D("Request body larger than maxBodyLength limit",D.ERR_BAD_REQUEST,T,z)}if(v&&f&&C!=="get"&&C!=="head"&&(pe=await A(P,b))!==0){let M=new o(N,{method:"POST",body:b,duplex:"half"}),oe;if(m.isFormData(b)&&(oe=M.headers.get("content-type"))&&P.setContentType(oe),M.body){const[be,ve]=Vn(pe,St(qn(v)));b=Kn(M.body,Wn,be,ve)}}m.isString(k)||(k=k?"include":"omit");const Ke=a&&"credentials"in o.prototype;if(m.isFormData(b)){const M=P.getContentType();M&&/^multipart\/form-data/i.test(M)&&!/boundary=/i.test(M)&&P.delete("content-type")}P.set("User-Agent","axios/"+Tn,!1);const We={...O,signal:V,method:C.toUpperCase(),headers:Ys(P.normalize()),body:b,duplex:"half",credentials:Ke?k:void 0};z=a&&new o(N,We);let Ee=await(a?G(z,O):G(N,We));if($){const M=m.toFiniteNumber(Ee.headers.get("content-length"));if(M!=null&&M>x)throw new D("maxContentLength size of "+x+" exceeded",D.ERR_BAD_RESPONSE,T,z)}const xe=E&&(F==="stream"||F==="response");if(E&&Ee.body&&(L||$||xe&&fe)){const M={};["status","statusText","headers"].forEach(Fe=>{M[Fe]=Ee[Fe]});const oe=m.toFiniteNumber(Ee.headers.get("content-length")),[be,ve]=L&&Vn(oe,St(qn(L),!0))||[];let lt=0;const vn=Fe=>{if($&&(lt=Fe,lt>x))throw new D("maxContentLength size of "+x+" exceeded",D.ERR_BAD_RESPONSE,T,z);be&&be(Fe)};Ee=new i(Kn(Ee.body,Wn,vn,()=>{ve&&ve(),fe&&fe()}),M)}F=F||"text";let Ae=await y[m.findKey(y,F)||"text"](Ee,T);if($&&!E&&!xe){let M;if(Ae!=null&&(typeof Ae.byteLength=="number"?M=Ae.byteLength:typeof Ae.size=="number"?M=Ae.size:typeof Ae=="string"&&(M=typeof s=="function"?new s().encode(Ae).byteLength:Ae.length)),typeof M=="number"&&M>x)throw new D("maxContentLength size of "+x+" exceeded",D.ERR_BAD_RESPONSE,T,z)}return!xe&&fe&&fe(),await new Promise((M,oe)=>{zs(M,oe,{data:Ae,headers:ue.from(Ee.headers),status:Ee.status,statusText:Ee.statusText,config:T,request:z})})}catch(Y){if(fe&&fe(),V&&V.aborted&&V.reason instanceof D){const J=V.reason;throw J.config=T,z&&(J.request=z),Y!==J&&(J.cause=Y),J}throw Y&&Y.name==="TypeError"&&/Load failed|fetch/i.test(Y.message)?Object.assign(new D("Network Error",D.ERR_NETWORK,T,z,Y&&Y.response),{cause:Y.cause||Y}):D.from(Y,Y&&Y.code,T,z,Y&&Y.response)}}},ca=new Map,Qs=e=>{let t=e&&e.env||{};const{fetch:n,Request:s,Response:r}=t,o=[s,r,n];let i=o.length,l=i,a,c,u=ca;for(;l--;)a=o[l],c=u.get(a),c===void 0&&u.set(a,c=l?new Map:aa(t)),u=c;return c};Qs();const Sn={http:Pl,xhr:ea,fetch:{get:Qs}};m.forEach(Sn,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{__proto__:null,value:t})}catch{}Object.defineProperty(e,"adapterName",{__proto__:null,value:t})}});const Xn=e=>`- ${e}`,ua=e=>m.isFunction(e)||e===null||e===!1;function da(e,t){e=m.isArray(e)?e:[e];const{length:n}=e;let s,r;const o={};for(let i=0;i<n;i++){s=e[i];let l;if(r=s,!ua(s)&&(r=Sn[(l=String(s)).toLowerCase()],r===void 0))throw new D(`Unknown adapter '${l}'`);if(r&&(m.isFunction(r)||(r=r.get(t))))break;o[l||"#"+i]=r}if(!r){const i=Object.entries(o).map(([a,c])=>`adapter ${a} `+(c===!1?"is not supported by the environment":"is not available in the build"));let l=n?i.length>1?`since :
4
4
  `+i.map(Xn).join(`
5
5
  `):" "+Xn(i[0]):"as no adapter specified";throw new D("There is no suitable adapter to dispatch the request "+l,"ERR_NOT_SUPPORT")}return r}const Zs={getAdapter:da,adapters:Sn};function $t(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new rt(null,e)}function Qn(e){return $t(e),e.headers=ue.from(e.headers),e.data=Bt.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Zs.getAdapter(e.adapter||st.adapter,e)(e).then(function(s){$t(e),e.response=s;try{s.data=Bt.call(e,e.transformResponse,s)}finally{delete e.response}return s.headers=ue.from(s.headers),s},function(s){if(!Ws(s)&&($t(e),s&&s.response)){e.response=s.response;try{s.response.data=Bt.call(e,e.transformResponse,s.response)}finally{delete e.response}s.response.headers=ue.from(s.response.headers)}return Promise.reject(s)})}const Nt={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Nt[e]=function(s){return typeof s===e||"a"+(t<1?"n ":" ")+e}});const Zn={};Nt.transitional=function(t,n,s){function r(o,i){return"[Axios v"+Tn+"] Transitional option '"+o+"'"+i+(s?". "+s:"")}return(o,i,l)=>{if(t===!1)throw new D(r(i," has been removed"+(n?" in "+n:"")),D.ERR_DEPRECATED);return n&&!Zn[i]&&(Zn[i]=!0,console.warn(r(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,l):!0}};Nt.spelling=function(t){return(n,s)=>(console.warn(`${s} is likely a misspelling of ${t}`),!0)};function fa(e,t,n){if(typeof e!="object")throw new D("options must be an object",D.ERR_BAD_OPTION_VALUE);const s=Object.keys(e);let r=s.length;for(;r-- >0;){const o=s[r],i=Object.prototype.hasOwnProperty.call(t,o)?t[o]:void 0;if(i){const l=e[o],a=l===void 0||i(l,o,e);if(a!==!0)throw new D("option "+o+" must be "+a,D.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new D("Unknown option "+o,D.ERR_BAD_OPTION)}}const At={assertOptions:fa,validators:Nt},he=At.validators;let Re=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Hn,response:new Hn}}async request(t,n){try{return await this._request(t,n)}catch(s){if(s instanceof Error){let r={};Error.captureStackTrace?Error.captureStackTrace(r):r=new Error;const o=(()=>{if(!r.stack)return"";const i=r.stack.indexOf(`
6
6
  `);return i===-1?"":r.stack.slice(i+1)})();try{if(!s.stack)s.stack=o;else if(o){const i=o.indexOf(`
7
7
  `),l=i===-1?-1:o.indexOf(`
8
8
  `,i+1),a=l===-1?"":o.slice(l+1);String(s.stack).endsWith(a)||(s.stack+=`
9
- `+o)}}catch{}}throw s}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=De(this.defaults,n);const{transitional:s,paramsSerializer:r,headers:o}=n;s!==void 0&&At.assertOptions(s,{silentJSONParsing:he.transitional(he.boolean),forcedJSONParsing:he.transitional(he.boolean),clarifyTimeoutError:he.transitional(he.boolean),legacyInterceptorReqResOrdering:he.transitional(he.boolean),advertiseZstdAcceptEncoding:he.transitional(he.boolean)},!1),r!=null&&(m.isFunction(r)?n.paramsSerializer={serialize:r}:At.assertOptions(r,{encode:he.function,serialize:he.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),At.assertOptions(n,{baseUrl:he.spelling("baseURL"),withXsrfToken:he.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=o&&m.merge(o.common,o[n.method]);o&&m.forEach(["delete","get","head","post","put","patch","query","common"],y=>{delete o[y]}),n.headers=ue.concat(i,o);const l=[];let a=!0;this.interceptors.request.forEach(function(p){if(typeof p.runWhen=="function"&&p.runWhen(n)===!1)return;a=a&&p.synchronous;const A=n.transitional||An;A&&A.legacyInterceptorReqResOrdering?l.unshift(p.fulfilled,p.rejected):l.push(p.fulfilled,p.rejected)});const c=[];this.interceptors.response.forEach(function(p){c.push(p.fulfilled,p.rejected)});let u,h=0,f;if(!a){const y=[Qn.bind(this),void 0];for(y.unshift(...l),y.push(...c),f=y.length,u=Promise.resolve(n);h<f;)u=u.then(y[h++],y[h++]);return u}f=l.length;let E=n;for(;h<f;){const y=l[h++],p=l[h++];try{E=y(E)}catch(A){p.call(this,A);break}}try{u=Qn.call(this,E)}catch(y){return Promise.reject(y)}for(h=0,f=c.length;h<f;)u=u.then(c[h++],c[h++]);return u}getUri(t){t=De(this.defaults,t);const n=Js(t.baseURL,t.url,t.allowAbsoluteUrls);return Gs(n,t.params,t.paramsSerializer)}};m.forEach(["delete","get","head","options"],function(t){Re.prototype[t]=function(n,s){return this.request(De(s||{},{method:t,url:n,data:(s||{}).data}))}});m.forEach(["post","put","patch","query"],function(t){function n(s){return function(o,i,l){return this.request(De(l||{},{method:t,headers:s?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}Re.prototype[t]=n(),t!=="query"&&(Re.prototype[t+"Form"]=n(!0))});let ha=class er{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(o){n=o});const s=this;this.promise.then(r=>{if(!s._listeners)return;let o=s._listeners.length;for(;o-- >0;)s._listeners[o](r);s._listeners=null}),this.promise.then=r=>{let o;const i=new Promise(l=>{s.subscribe(l),o=l}).then(r);return i.cancel=function(){s.unsubscribe(o)},i},t(function(o,i,l){s.reason||(s.reason=new rt(o,i,l),n(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=s=>{t.abort(s)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new er(function(r){t=r}),cancel:t}}};function ma(e){return function(n){return e.apply(null,n)}}function pa(e){return m.isObject(e)&&e.isAxiosError===!0}const sn={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(sn).forEach(([e,t])=>{sn[t]=e});function tr(e){const t=new Re(e),n=vs(Re.prototype.request,t);return m.extend(n,Re.prototype,t,{allOwnKeys:!0}),m.extend(n,t,null,{allOwnKeys:!0}),n.create=function(r){return tr(De(e,r))},n}const Z=tr(st);Z.Axios=Re;Z.CanceledError=rt;Z.CancelToken=ha;Z.isCancel=Ws;Z.VERSION=Tn;Z.toFormData=Rt;Z.AxiosError=D;Z.Cancel=Z.CanceledError;Z.all=function(t){return Promise.all(t)};Z.spread=ma;Z.isAxiosError=pa;Z.mergeConfig=De;Z.AxiosHeaders=ue;Z.formToJSON=e=>Ks(m.isHTMLForm(e)?new FormData(e):e);Z.getAdapter=Zs.getAdapter;Z.HttpStatusCode=sn;Z.default=Z;const{Axios:af,AxiosError:cf,CanceledError:uf,isCancel:df,CancelToken:ff,VERSION:hf,all:mf,Cancel:pf,isAxiosError:Ef,spread:Af,toFormData:yf,AxiosHeaders:Tf,HttpStatusCode:Sf,formToJSON:Cf,getAdapter:gf,mergeConfig:bf,create:wf}=Z,ce={onAction:(e,t)=>({formData:e,patch:t}),onChange:e=>{},onFormComplete:()=>{},onFormLoad:e=>{},onGetComponent:(e,t)=>null,onGetCYA:e=>null,onGetCYARows:(e,t,n)=>null,onGoingBack:()=>{},onPageChange:(e,t)=>e,onRequest:e=>e,onSubmit:(e,t,n,s)=>{typeof n=="function"&&n()},onValidate:(e,t)=>t,onCancel:e=>{}},es=Object.keys(ce),nr=R.createContext(),sr=({overrides:e={onAction:void 0,onCancel:void 0,onChange:void 0,onFormComplete:void 0,onFormLoad:void 0,onGetComponent:void 0,onGetCYA:void 0,onGetCYARows:void 0,onGoingBack:void 0,onPageChange:void 0,onRequest:void 0,onSubmit:void 0,onValidate:void 0},children:t=null})=>{const[n,s]=R.useState({onAction:e?.onAction||ce.onAction,onChange:e?.onChange||ce.onChange,onFormComplete:e?.onFormComplete||ce.onFormComplete,onFormLoad:e?.onFormLoad||ce.onFormLoad,onGetComponent:e?.onGetComponent||ce.onGetComponent,onGetCYA:e?.onGetCYA||ce.onGetCYA,onGetCYARows:e?.onGetCYARows||ce.onGetCYARows,onGoingBack:e?.onGoingBack||ce.onGoingBack,onPageChange:e?.onPageChange||ce.onPageChange,onRequest:e?.onRequest||ce.onRequest,onSubmit:e?.onSubmit||ce.onSubmit,onValidate:e?.onValidate||ce.onValidate,onCancel:e?.onCancel||ce.onCancel}),r=(i,l)=>{es.includes(i)&&s(a=>({...a,[i]:l||ce[i]}))},o=i=>{es.includes(i)&&s(l=>({...l,[i]:ce[i]}))};return d.jsx(nr.Provider,{value:{hooks:n,addHook:r,removeHook:o},children:t})},Pe=()=>R.useContext(nr),Ea=()=>{const{hooks:e}=Pe(),[t,n]=R.useState({});return R.useEffect(()=>{const s=Z.create({baseURL:"/"});return s.interceptors.request.use(e.onRequest),s.interceptors.response.use(r=>r,async r=>Promise.reject(r)),n({instance:s}),()=>{n({})}},[e]),t.instance},Cn=R.createContext(),rr=({children:e=null})=>{const{hooks:t}=Pe(),[n,s]=R.useState([]),[r,o]=R.useState([]),i=f=>{f!==void 0&&o(E=>[...E,...f].filter(y=>!!y))},l=f=>{typeof f=="function"&&o(E=>E.filter(y=>!f(y)))},a=()=>{r.length&&o([])},c=f=>{f!==void 0&&s(E=>[...E,...f].filter(y=>!!y))},u=()=>{o([]),s([])},h={page:f=>{const E=w.Validate.page(f,r),y=t.onValidate(f,E);return s(y),y},pages:f=>{const E=f.map(p=>w.Validate.page(p,r)),y=f.flatMap((p,A)=>t.onValidate(p,E[A]));return s(y),y}};return d.jsx(Cn.Provider,{value:{errors:n,addErrors:c,clearErrors:u,queuedErrors:r,enqueueErrors:i,dequeueErrors:l,clearQueuedErrors:a,validate:h},children:e})},He=()=>R.useContext(Cn),Yt={},Ht={},Aa="idle",ya="fetching",or="fetched",ir="error",Ta=(e,t=!0)=>{const n=Ea(),s=R.useRef(Z.CancelToken.source()),[r,o]=R.useState(Aa),[i,l]=R.useState(null),[a,c]=R.useState(null),u=()=>{s.current&&s.current.cancel()};return R.useEffect(()=>{if(!e||!n)return;(async()=>{try{l(null),o(ya);let f;if(t&&Yt[e])f=Yt[e];else{if(t&&Ht[e])throw Ht[e];f=(await n.get(e,{cancelToken:s.current.token}).catch(y=>{throw l(y),y})).data,t&&(Yt[e]=f)}c(f),o(or)}catch(f){t&&(Ht[e]=f),l(f),c(null),o(ir)}})()},[n,e,t]),{status:r,error:i,data:a,cancelRequests:u}},Sa="loading",yt="complete",Ca=e=>{const t=e.data;if(t&&!t.options||t?.url)return S.Utils.interpolateString(t.url,e.formData)},ga=(e,t)=>{const n=Ca({...e,formData:t}),{status:s,data:r}=Ta(n,e?.data?.useCache),[o,i]=R.useState([]),[l,a]=R.useState(Sa);return R.useEffect(()=>{n?s===or?(r&&i(de.refData.toOptions(r.data||r,e.item)),a(yt)):s===ir&&(i([]),a(yt)):(e.data&&e.data.options&&i(de.refData.toOptions(e.data.options,e.item)),a(yt))},[e.id,s,r,n]),{data:o,status:l}},Xe=(e,t)=>{const n=te(e,["fieldId","displayMenu","showCharacterCount","readonly"]);return d.jsx(S.FormGroup,{...n,onChange:null,children:t})},gn=(e,t,n,s,r={})=>{if(!t)return[];const o=w.CollectionPage.getData(t.collection.name,t.formData)||[];let i=[];return o.forEach(l=>{r={...r,[`${t.collection.name.split(".").pop()}ActiveId`]:l.id};const a=t.childPages?.flatMap(c=>{const u={...c,formData:{...n,...r}};if(c.childPages)return gn(e,u,n,s,r);const h=w.Validate.page(u);return s.onValidate(u,h)});i=i.concat(a.map(c=>({...c,entryId:l.id,showFor:e.id,raisedBy:e.id})))}),i},bn=({value:e,component:t,formData:n,placeholder:s})=>e?t?d.jsx(Ve,{component:{...t,readonly:!0},wrap:!1,value:e,formData:n}):Object.prototype.hasOwnProperty.call(e,"label")?e.label:e:(Object.prototype.hasOwnProperty.call(t||{},"cyaPlaceholder")?t?.cyaPlaceholder:s)||d.jsx(S.VisuallyHidden,{children:"No answer"}),ba="Continue",rn=({action:e,onAction:t,...n})=>{const s=typeof e=="string"?W.DEFAULTS[e]:e,r=W.DEFAULTS[e.type];return s?d.jsx(S.Button,{...n,className:s.className,classModifiers:s.classModifiers,start:s.start||!1,name:s.label,onClick:s.disabled?()=>{}:()=>t(s),children:s.label||r?.label||ba}):null},wa="hods-form-confirmation",_a="Are you sure?",Ia="Confirm",Pa=({id:e,message:t,confirmLabel:n,children:s,onConfirm:r,onCancel:o,classModifiers:i=[]})=>{const l=S.Utils.classBuilder(wa,i,"");return d.jsxs("div",{id:e,className:l(),role:"alert",children:[d.jsx("h2",{children:t||_a}),s,d.jsx(S.Button,{classModifiers:"warning",onClick:r,autoFocus:!0,children:n||Ia}),d.jsx(S.Button,{classModifiers:"secondary",onClick:o,children:"Cancel"})]})},wn=e=>e&&Array.isArray(e.components)?e.components.flatMap(t=>t.type===_.CONTAINER?wn(t):ot.editable(t)?t:null).filter(t=>!!t):[],xa=e=>{const t=e.full_path||e.fieldId;return e.components.map(n=>{const s=t?`${t}.${n.fieldId}`:n.fieldId,r={...n,full_path:s};return n.type===_.CONTAINER?on(r):(n.type===_.RADIOS&&r.data?.options?.forEach((o,i)=>{o.nested?.forEach((l,a)=>{l.type===_.CONTAINER&&(r.data.options[i].nested[a]=on(l))})}),r)})},on=e=>{if(e){const t=xa(e);return{...e,components:t}}return e},Oa=(e,t)=>e.some(n=>ot.show(n,t)),Ra=(e,t)=>{if(!e)return!1;if(e.show_when)return e.show_when.type==="or"?ae.meetsOne(e,t):ae.meetsAll(e,t);const n=wn(e);return n.length>0?Oa(n,t):!0},Lt={editableComponents:wn,setup:on,show:Ra},Na=(e,t)=>e.some(n=>Ie(n,t)),Dt=(e,t)=>{if(!e)return!1;if(e.show_when)return e.show_when.type==="or"?ae.meetsOne(e,t):ae.meetsAll(e,t);const n=Lt.editableComponents(e);return n.length>0?Na(n,t):!0},La=(e,t,n)=>{if(!e)return null;const s=[];e.childPages.forEach(l=>{!l.summaryQuickEdit||!Dt(l,{...t,...n})||l.summaryQuickEdit.forEach(a=>{if(typeof a=="string"){s.push({...l.components.find(h=>h.id===a)});return}const c=l.components.find(h=>h.id===a.use);if(!c)return;const u={...c,...a};if(a.show_when){Ue(a.show_when,{...t,...n})&&s.push({...u,show_when:c.show_when||[]});return}s.push(u)})});const r={...e.childPages[0],formData:t};r.components=s,r.actions=[{type:"save",label:"Save",validate:!0,classModifiers:"primary"},{type:"cancel",label:"Cancel",classModifiers:"secondary"}];const{id:o,...i}=n;return r.formData={...r.formData,...i,[`${e.collection?.name?.split(".").pop()}ActiveId`]:n.id},delete r.title,delete r.collection,r},_n=({actions:e,onAction:t})=>!e||e.length===0?null:d.jsx(S.ButtonGroup,{children:e.map((n,s)=>d.jsx(rn,{action:n,onAction:t},s))}),Da=e=>{if(!e?.customValidation)return!1;const t=e?.customValidation.find(n=>n.runWhen?.onLoad===!0);return t&&t.runWhen?.constraint?ae.meetsOne(t.runWhen?.constraint,e.formData):!1},lr="hods-form__page",In=({page:e,pages:t=[],onAction:n,onWrapperChange:s=void 0,onTopLevelChange:r=void 0,onChange:o=void 0,hashLink:i=!1,classBlock:l=lr,classModifiers:a=[],className:c="",submitting:u=!1,pageId:h})=>{const[f,E]=R.useState({}),{errors:y,validate:p}=He(),[A,T]=R.useState({}),[N,C]=R.useState(!1),b=R.useMemo(()=>Da(e),[e]);R.useEffect(()=>{C(!0)},[]),R.useEffect(()=>{N&&b&&p.page(e)},[h,N]);const P=({target:I})=>{const k=e,{value:O}=I;O?(k.formData[I.name]=O,E(x=>({...x,[I.name]:O})),T(x=>({...x,[I.component]:I.label}))):(delete k.formData[I.name],E(x=>{const{[I.name]:j,...$}=x;return $}),T(x=>{const{[I.component]:j,...$}=x;return $})),typeof o=="function"&&o(e.formData)};R.useEffect(()=>{const I=document.title.replace("Error: ","");document.title=y.length>0?"Error: "+I:I},[y]);const U=w.classBuilder(l,a,c),g=e;g.actions=g.actions?.map(I=>I.label?{...I,label:w.interpolateString(I.label,g.formData)}:I),g.formData=w.Operate.runPageOperations(g,{...g.formData,...f},s||P);const L=e.title?d.jsx(S.Heading,{size:e.titleSize,children:w.FormPage.getTitle(e.title,e.formData)}):d.jsx(S.Label,{id:e.id,required:e.required,hideOptionalSuffix:e.hideOptionalSuffix,children:e.label}),v=e.components.filter(I=>w.Component.show(I,e.formData)).map((I,k)=>d.jsx(Ve,{component:I,onAction:O=>n(O,f,A),onChange:s||P,onTopLevelChange:r||P,value:e.formData[I.fieldId]||f[I.fieldId],formData:e.formData,pages:t,submitting:u},k));let F=null;return b&&y?.length>0?F=[{error:e?.customValidation?.[0]?.message}]:y?.length>0&&!b&&(F=y),d.jsxs("div",{className:U(),children:[F&&d.jsx(S.ErrorSummary,{errors:F,hashLink:i}),e.fieldset&&d.jsxs("fieldset",{className:"govuk-fieldset",children:[d.jsx("legend",{className:"govuk-fieldset__legend",children:L}),v]}),!e.fieldset&&d.jsxs(d.Fragment,{children:[L,v]}),d.jsx(_n,{actions:e.actions?.filter(I=>w.Component.show(I,e.formData)),onAction:I=>n(I,f,A)})]},e.id)},ts="hods-form-banner-strip",ar=({id:e,banners:t=[],formData:n,classModifiers:s})=>{const r=w.classBuilder(ts,s,""),o=t.filter(i=>w.Component.show(i,n));return d.jsx("div",{id:e,className:r(),children:o.map((i,l)=>{const a=`${e}-banner-${l}`;if(typeof i=="string"||i.type==="plain"){const c=typeof i=="string"?i:i.text;return d.jsx("div",{id:a,className:r("banner"),children:d.jsx(S.Markup,{content:w.interpolateString(c,n)})},a)}return d.jsx(S.Tag,{classBlock:`${ts}__tag`,classModifiers:i.classModifiers,text:w.interpolateString(i.text,n)},a)})})},va=e=>{if(e&&e.action){if(typeof e.action.onAction=="function")return{onClick:()=>e.action.onAction(e),onKeyPress:t=>{t.key==="Enter"&&e.action.onAction(e)},tabIndex:"0"};if(e.action.page)return{href:`/${e.action.page}`}}return{}},Pn=({row:e})=>{const[t,n]=R.useState({});return R.useEffect(()=>{n(va(e))},[e,n]),e.action?d.jsxs(S.Link,{...t,children:[e.action.label,e.action.aria_suffix&&d.jsxs(S.VisuallyHidden,{children:[" ",e.action.aria_suffix]})]}):null},cr=({row:e,classes:t,showAction:n=!1})=>d.jsxs("dl",{className:t("row"),role:"listitem",children:[d.jsxs("dt",{className:t("key"),children:[e.key,!e.required&&" (optional)"]}),d.jsx("dd",{className:t("value"),children:e.value}),n&&d.jsx("dd",{className:t("actions"),children:e.action&&d.jsx(Pn,{row:e})})]}),ur=({title:e,classes:t})=>d.jsx("div",{className:`${t("row")} ${t("title")}`,role:"listitem",children:d.jsx(S.SmallHeading,{children:e})}),Tt=(e,t,n,s,r)=>{const o={...e,formData:{...e.formData,...s}},i=jt(o,t);return t.type==="title"?d.jsx(ur,{title:t.key,classes:n}):d.jsx(cr,{row:{key:i.key,value:d.jsx(bn,{value:i.value||t.value,component:i.component,formData:o.formData,placeholder:r}),required:i.required},classes:n},`${i.fieldId}`)},Fa="govuk-summary-card",ja="govuk-summary-list",ft="Item",ht="Change",ns="Delete",Ua="warning",Ma=({id:e,entryData:t,config:n,onFullEdit:s,onDelete:r,masterPage:o,classModifiers:i=null,optionalFieldPlaceholder:l=null})=>{const a=S.Utils.classBuilder(Fa,i,n.className),c=S.Utils.classBuilder(ja,[]);return d.jsxs("div",{className:a(),id:e,children:[d.jsxs("div",{className:a("title-wrapper",[],"dark"),children:[d.jsxs("div",{className:a("title-content"),children:[d.jsx("h2",{className:a("title"),children:S.Utils.interpolateString(n.title||ft,{...t,index:t.index+1})}),n.banners&&d.jsx(ar,{id:`BannerStrip${t.id}`,banners:n.banners,formData:t})]}),d.jsxs("ul",{className:a("actions"),children:[d.jsx("li",{className:a("action"),children:n.changeAction&&typeof s=="function"&&n.changeAction.classModifiers?d.jsx(S.Button,{id:`${e}.changeButton`,onClick:()=>s(n.changeAction.page,t.id),classModifiers:n.changeAction.classModifiers,"aria-label":S.Utils.interpolateString(`${n.changeAction?.label||ht} ${n.title||ft}`,{...t,index:t.index+1}),children:n.changeAction?.label||ht}):d.jsx("button",{type:"button",className:"govuk-link govuk-link-button",onClick:()=>s(n.changeAction.page,t.id),"aria-label":S.Utils.interpolateString(`${n.changeAction?.label||ht} ${n.title||ft}`,{...t,index:t.index+1}),children:n.changeAction?.label||ht})}),d.jsx("li",{className:a("action"),children:n.deleteAction&&typeof r=="function"&&d.jsx(S.Button,{id:`${e}.deleteButton`,onClick:()=>r(t),classModifiers:n.deleteAction.classModifiers||Ua,"aria-label":S.Utils.interpolateString(`${n.deleteAction?.label||ns} ${n.title||ft}`,{...t,index:t.index+1}),children:n.deleteAction.label||ns})})]})]}),d.jsx("div",{className:a("content"),children:d.jsx("dl",{className:c(),role:"list",children:o?.childPages?.flatMap(u=>{const h=u.components.map(f=>w.Component.elevateNested([f],t)).flat().filter(Boolean);return u.summaryLayout?.sections?.flatMap(f=>{const y=f.columns.filter(p=>ae.meetsAll(p,{...u.formData,...t})).flatMap(p=>p.fields||[]);return y.length?y.flatMap(p=>{const A=h.find(T=>T.fieldId===p);return A?Tt(u,A,c,t,l):null}):null})})})})]})},ka=({id:e,"data-testid":t,actions:n,onFullEdit:s=null,entryData:r,formData:o,name:i,autoFocus:l})=>Array.isArray(n)?d.jsx(d.Fragment,{children:n.filter(a=>w.Component.show(a,o)).map(a=>d.jsx(S.Button,{id:e,"data-testid":t,onClick:()=>s(a?.page,r.id),classModifiers:a?.classModifiers||rs,"aria-label":w.FormPage.getConditionalText(a?.aria_label,r),name:i,autoFocus:l,children:a?.label||ss},e))}):d.jsx(S.Button,{id:e,"data-testid":t,onClick:()=>s(n?.page,r.id),classModifiers:n?.classModifiers||rs,"aria-label":w.FormPage.getConditionalText(n?.aria_label,r),name:i,autoFocus:l,children:n?.label||ss}),Ba=e=>{if(e.page)return e.page;const t=e.href||e.url;if(t)return t.split("/").pop()},vt=(e,t,n)=>{const s=t?.cya_link;return e!==!0&&s?{page:Ba(s)||t.id||"#",label:s.label||"Change",aria_suffix:s.aria_suffix,onAction:n}:null},dr=[_.ALERT,_.COLLECTION_SUMMARY,_.DETAILS,_.HEADING,_.HTML,_.INSET_TEXT],Ct=(e,t)=>{if(!e||dr.includes(e.type)||Object.prototype.hasOwnProperty.call(e,"show_on_cya")&&!e.show_on_cya)return!1;if(e.hideOnCyaWhenEmpty)if(e.type===_.COLLECTION){if(!se(t,e.full_path||e.fieldId)?.length)return!1}else{const n=se(t,e.fieldId);if(!n&&n!==!1&&n!==0)return!1}return e.type===_.CONTAINER?Lt.show(e,t):ot.show(e,t)},fr=e=>({...e,components:e.components.map(t=>Array.isArray(t.components)?{...t,components:t.components.map(n=>dr.includes(n.type)?null:{...n,...!n.full_path&&{full_path:`${t.full_path||`${e.full_path}.${t.fieldId}`}.${n.fieldId}`}}).filter(n=>!!n)}:{...t,...!t.full_path&&{full_path:`${e.full_path||e.fieldId}.${t.fieldId}`}})}),$a=(e,t)=>[{pageId:e.id,key:e.components[0].labels?.empty||"Nothing entered",required:e.required,action:vt(!1,e,t)}],Ya=(e,t,n,s)=>({id:t.id,fieldId:t.id,type:_.CONTAINER,required:e.required,full_path:s,components:e.item.map(r=>({...r,label:S.Utils.interpolateString(r.label,{...t,index:n}),full_path:`${s}.${r.fieldId}`}))}),Ha=(e,t,n,s,r)=>{const o={...$e,...e.labels};return o.item?{pageId:n,fieldId:e.fieldId,full_path:r,key:S.Utils.interpolateString(o.item,{...t,index:s}),type:"title",action:null}:null},xn=(e,t,n,s,r)=>Array.isArray(n)&&n.length&&Ct(t,e.formData)?n.flatMap((o,i)=>{const l=(t.countOffset||0)+i+1,a=`${t.full_path||t.fieldId}[${i}]`;let c=Ya(t,o,l,a);return c=fr(c),[Ha(t,o,e.id,l,a),...qe(e,c,o,s,r)??[]]}).filter(o=>!!o):$a(e,s),Va="hods-form-summary-card-details",hr=({masterPage:e,childCollections:t=[],formData:n,entryData:s,classModifiers:r,hideChildSectionTitles:o=!1,optionalFieldPlaceholder:i})=>{const l=w.classBuilder(Va,r),a=R.useMemo(()=>t.map(u=>e.childPages.find(h=>h.collection?.name===u)).filter(u=>!!u),[e,t]),c=(u,h,f)=>{let E=0;return u.flatMap((y,p)=>{let A=0;const T=y.fields?.flatMap(C=>h.filter(P=>P.fieldId===C).map(P=>{if(!P||!Ie(P,{...f.formData,...s}))return null;if(P.type===_.CONTAINER){const U=qe(f,P,s);return A+=1,d.jsx("div",{className:l("field"),style:{"--column":E+1,"--row":A},role:"list",children:U.map(g=>{const L={...s,[g.fieldId]:s[P.fieldId]?.[g.fieldId]};return Tt(f,{...g,label:g.key},l,L,i)})},C)}if(P.type===_.COLLECTION){const U=xn({...f,formData:{...f.formData,...s}},P,s[P.id]);A+=1;let g=0;return d.jsx("div",{className:l("field"),style:{"--column":E+1,"--row":A},role:"list",children:U.map(L=>{const v={...s,[L.fieldId]:s[P.fieldId]?.[L.fieldId]},F=Tt(f,{...L,label:L.key},l,v,i);return L.type==="title"&&(g+=1,g>1)?d.jsx("div",{style:{marginTop:"40px"},children:F}):F})},C)}return A+=1,d.jsx("div",{className:l("field"),style:{"--column":E+1,"--row":A},role:"list",children:Tt(f,P,l,s,i)},C)})).filter(C=>!!C);return!(p===u.length-1)&&T.length!==0?(E+=2,[...T,d.jsx("div",{className:l("divider"),style:{"--column":E}},`divider${E}`)]):T}).filter(y=>!!y)};return e?.childPages?.filter(u=>w.FormPage.show(u,{...n,...s})).map(u=>{const h=w.Component.elevateNested(u?.components,s);return u.summaryLayout?.sections.map(f=>{if(f.show_when&&!w.Condition.meetsAll(f.show_when,{...n,...s}))return null;if(f.type==="childCollection"){const y=a.find(A=>A.collection.name===f.collectionName),p=s[f.collectionName.split(".").pop()]||[];return y&&p.length>0?d.jsxs(d.Fragment,{children:[d.jsx("h3",{className:l("section-title"),children:f.title}),p.map(A=>d.jsx(hr,{masterPage:y,childMasterPages:[],formData:{...n,...s,...A},entryData:A,hideChildSectionTitles:!0,optionalFieldPlaceholder:i}))]}):null}const E=f.columns.filter(y=>ae.meetsAll(y,{...u.formData,...s}));return d.jsxs("div",{className:l("section"),children:[!o&&d.jsx("h3",{className:l("section-title"),children:w.FormPage.getConditionalText(f.title,{...u.formData,...s})}),d.jsx("dl",{className:l("section-content"),style:{"--dividers":E.length-1},children:c(E,h,u)})]},f.title)})}).filter(u=>!!u)||null},qa="hods-form-summary-card",ss="Change",Ga="Delete",Ka="Quick Edit",Wa="Duplicate",za="Full details",rs="secondary",os=({id:e,entryData:t,config:n,classModifiers:s,onFullEdit:r,onDelete:o,onDuplicate:i,onQuickEdit:l,parentCollectionName:a,childCollections:c=[],formData:u,masterPage:h,hideDetails:f=!1})=>{const[E,y]=R.useState(!1),p=S.Utils.classBuilder(qa,s,n.className),A=R.useMemo(()=>n.quickEdit?La(h,u,t):null,[h,n,u,t,E]),{addErrors:T,resetQuickEditErrors:N,clearTopLevelErrorsForCard:C,validate:b}=He(),{hooks:P}=Pe(),U=async(g,L)=>{if(g.type==="cancel"&&(y(v=>!v),N?.()),g.type==="save"&&typeof l=="function"){const v={...A.formData,...L,[`${a}ActiveId`]:t.id},F=b.page({...A,formData:v});if(F.length)return;let I;await P.onSubmit("quickEdit",v,()=>{},O=>{I=O}),I&&T(I);const k=F.concat(I);if(k.length===0||k.length===1&&k[0]===void 0){C();const O=w.CollectionPage.getData(a,u),{isDuplicate:x,...j}=O[t.index];O[t.index]={...j,...L},l({target:{name:a,value:O}}),y($=>!$)}}};return n.listView?d.jsx(Ma,{id:e,entryData:t,config:n,onFullEdit:r,onDelete:o,masterPage:h,classModifiers:s,optionalFieldPlaceholder:n.fullDetails?.optionalFieldPlaceholder}):d.jsxs("div",{className:p(),id:e,children:[d.jsxs("div",{className:p("header"),children:[d.jsxs("div",{className:p("header-content"),children:[n.banners&&d.jsx(ar,{id:`BannerStrip${t.id}`,banners:n.banners,formData:t}),d.jsx("h2",{id:`${e}.titleText`,className:p("header-content-title"),children:w.FormPage.getTitle(n.title,t)}),n.details&&d.jsx("div",{id:`${e}.titleDetail`,className:p("header-content-detail"),children:w.FormPage.getConditionalText(n.details,t)})]}),d.jsxs("div",{className:p("header-actions"),children:[n.quickEdit&&d.jsx(S.Button,{"data-testid":"quickedit-button",id:`${e}.quickEditButton`,onClick:()=>y(g=>!g),classModifiers:"primary",disabled:E,name:"QuickEdit",autoFocus:n.focusOn,children:Ka}),n.changeAction&&typeof r=="function"&&d.jsx(ka,{id:`${e}.changeButton`,"data-testid":"change-button",actions:n.changeAction,onFullEdit:r,entryData:t,formData:u,name:"Change",autoFocus:n.focusOn}),n.deleteAction&&typeof o=="function"&&d.jsx(S.Button,{id:`${e}.deleteButton`,onClick:()=>o(t),classModifiers:"secondary","aria-label":w.FormPage.getConditionalText(n.deleteAction?.aria_label,t),name:"Delete",children:n.deleteAction?.label||Ga}),n.duplicateAction&&typeof i=="function"&&d.jsx(S.Button,{"data-testid":"duplicate-button",id:`${e}.duplicateButton`,onClick:()=>{i(t)},classModifiers:"secondary","aria-label":w.FormPage.getConditionalText(n.duplicateAction?.aria_label,t),name:"Duplicate",autoFocus:n.focusOn,children:n.duplicateAction?.label||Wa})]})]}),E&&A&&d.jsx(In,{page:A,onAction:(g,L)=>U(g,L),className:p("editpage")}),d.jsx("div",{className:p("body"),children:!f&&d.jsx(S.Details,{summary:n.detailsTitle||za,className:"details",children:d.jsx(hr,{masterPage:h,childCollections:c,formData:u,entryData:t,optionalFieldPlaceholder:n.fullDetails?.optionalFieldPlaceholder})})})]})},Ja=({entryId:e,topLevelErrors:t=[],clearTopLevelErrorsForCard:n,children:s})=>{const{hooks:r}=Pe(),o=t.filter(h=>h.entryId===e)||[],[i,l]=R.useState(null),a=()=>{l(null)},c=h=>{l(f=>(f??[]).concat(h))},u={page:h=>{const f=w.Validate.page(h),E=r.onValidate(h,f);return l(E),E}};return d.jsx(Cn.Provider,{value:{addErrors:c,errors:i===null?[...o]:i,resetQuickEditErrors:a,clearTopLevelErrorsForCard:n,validate:u},children:s})},is="Add",Xa=({config:e,formData:t,onAction:n,onChange:s,onTopLevelChange:r,pages:o=[]})=>{const{hooks:i}=Pe(),{errors:l,addErrors:a,clearErrors:c,queuedErrors:u,enqueueErrors:h,dequeueErrors:f}=He(),[E,y]=R.useState(null),p=R.useMemo(()=>w.CollectionPage.getData(e.collectionName,t)||[],[t]),A=Array.isArray(p)&&p.length>0?p.reduce((L,v)=>v.isDuplicate&&(!L||v.id>L.id)?v:L,null):null,T=R.useMemo(()=>{const L=e.collectionName.split(".");let v=w.CollectionPage.mergePages(o||[])||[];return L.reduce((F,I,k)=>{const O=k===0?`${F}${I}`:`${F}.${I}`;return k===L.length-1?v?.find(x=>x.collection?.name===O)||null:(v=v.find(x=>x.collection?.name===O)?.childPages||null,O)},"")},[o]),N=R.useMemo(()=>e.card.listView?T.childPages?.reduce((v,F)=>{const I=et(F.components,{...t,...E});return v.concat(I)},[])||[]:[],[T,t,E,e.card.listView]),C=()=>{u.length>0&&f(v=>v.raisedBy===e.id);const L=gn(e,T,t,i);L.length>0&&h(L)};R.useEffect(()=>{Array.isArray(p)&&p.length>0&&C()},[p]);const b=(L,v)=>{if(typeof n=="function"){const F=[...p],I=p.findIndex(x=>x.id===v),{isDuplicate:k,...O}=p[I];F[I]={...O},n({type:mt.SAVE_AND_NAVIGATE,page:L,addToFormData:[{field:`${e.collectionName.split(".").pop()}ActiveId`,value:v},{field:e.collectionName,value:F,isCollection:!0}]})}},P=L=>{w.CollectionPage.duplicateEntry(e.collectionName,t,L.id,e.card?.duplicateAction?.fieldsToIgnore||[],{isDuplicate:!0});const v=e.collectionName.split(".").shift();typeof r=="function"&&(r({target:{name:v,value:w.CollectionPage.getData(v,t)}}),C())},U=()=>{if(!E)return;w.CollectionPage.removeEntry(e.collectionName,t,E.id);const L=e.collectionName.split(".").shift();typeof r=="function"&&r({target:{name:L,value:w.CollectionPage.getData(L,t)}}),y(null),C()},g=L=>{const v=N.find(I=>I.fieldId===L);if(!v)return null;const F=jt({...T,formData:{...t,...E}},v);return d.jsx("div",{className:"confirmation-field-value",children:d.jsx(bn,{value:F.value,component:F.component,formData:F.formData})},L)};return d.jsxs("div",{id:e.fieldId,children:[E&&d.jsx(Pa,{id:`${e.fieldId}.confirmation`,message:w.interpolateString(e.confirmation?.message,{...E,index:E.index+1})||null,confirmLabel:w.interpolateString(e.confirmation?.label,E)||null,onConfirm:U,onCancel:()=>y(null),children:e.card.listView?d.jsx("div",{className:"confirmation-content",children:e.confirmation?.displayFields.map(g)}):d.jsx(os,{id:`${e.fieldId}.confirmationChild`,entryData:E,config:e.card?{...e.card,quickEdit:null}:{},masterPage:T,classModifiers:"nested",hideDetails:!0})}),!e.card.listView&&e.addButton&&d.jsx(rn,{id:`${e.fieldId}.addButton`,action:{collection:e.collectionName,label:w.interpolateString(e.addButton.label||is,{documents:p}),page:e.addButton.page,type:mt.COLLECTION_ADD,classModifiers:["secondary"]},onAction:n}),d.jsx("ul",{className:"collection-summary-card-list",children:p.map((L,v)=>{const F=l.filter(O=>O.entryId===L.id).length>0,I={...e.card,...L.isDuplicate&&e.duplicatedCard?e.duplicatedCard:{},...F&&e.errorCard?e.errorCard:{},focusOn:A?.id===L.id},k=`${e.fieldId}.summaryCard${L.id}`;return d.jsx("li",{children:d.jsx(Ja,{entryId:L.id,topLevelErrors:l,clearTopLevelErrorsForCard:()=>{const O=l.filter(x=>x.entryId!==L.id);c(),a(O)},children:d.jsx(os,{id:k,entryData:{...L,index:v},masterPage:T,config:I||{},onFullEdit:b,onDuplicate:P,onDelete:()=>y({...L,index:v}),onQuickEdit:O=>(C(),s(O)),parentCollectionName:e.collectionName.split(".").shift(),childCollections:e.childCollections||[],formData:t,classModifiers:L.id===E?.id?["deleting-summary-card"]:[""],inError:l.filter(O=>O.entryId===L.id).length>0},k)})})})}),e.card.listView&&e.addButton&&d.jsx(rn,{id:`${e.fieldId}.addButton`,action:{collection:e.collectionName,label:w.interpolateString(e.addButton.label||is,{documents:p}),page:e.addButton.page,type:mt.COLLECTION_ADD,classModifiers:["secondary"],customAction:{type:e.addButton.customAction}},onAction:n})]})},Qa="hods-form-collection",Za=({config:e,value:t,formData:n,onChange:s=void 0,onTopLevelChange:r=void 0,wrap:o=!1})=>{const[i,l]=R.useState(t),a=p=>{l(p),typeof s=="function"&&s({target:{name:e.fieldId,value:p}})},c=({target:p})=>{if(typeof s=="function")if(p.name===w.Meta.name)s({target:p});else{const A=i.findIndex(T=>T.id===p.name);a([...i.slice(0,A),p.value,...i.slice(A+1)])}},u=async()=>{a([...i,{id:_t.v4()}])},h=async p=>{a(i.filter(A=>A.id!==p.id))},f=p=>p.initial&&!i.length?p.initial:p.add;R.useEffect(()=>{if(e.focusOnAdd&&Array.isArray(i)&&i.length&&(i.length>e.minimumEntries||!e.minimumEntries)){const p=i[i.length-1]?.id,T=document.getElementById(p)?.childNodes[0]?.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');T&&T.length>0&&T[0].focus()}},[i.length,e.focusOnAdd,e.minimumEntries]),R.useEffect(()=>{e.minimumEntries&&!i.length&&u()},[e.minimumEntries,i.length]);const E={...$e,...e.labels},y=w.classBuilder(Qa,[],e.className);return d.jsxs("div",{className:y(),id:e.id,children:[e.label&&d.jsx(S.Label,{id:e.id,required:e.required,className:y("title"),children:e.label}),Array.isArray(i)&&i.map((p,A)=>{const T=`${e.full_path||e.fieldId}[${A}]`,N=(e.countOffset||0)+A+1,C=w.interpolateString(E.item,{...p,index:N}),b=w.interpolateString(E.remove,{...p,index:N}),P=e.disableAddAndRemove||A===0&&e.minimumEntries?"":e.removeLocation??"start",U=A!==0&&e.subsequentItemStyle?e.subsequentItemStyle:{};return d.jsxs("div",{className:`${y("item")}`,style:U,children:[d.jsxs(S.Label,{id:p.id,required:!0,className:y("item-title"),children:[C,P==="start"&&d.jsx(S.Button,{onClick:()=>h(p),classModifiers:"secondary",children:b})]}),d.jsx(Ln,{container:{id:p.id,fieldId:p.id,type:"container",required:e.required,full_path:T,components:e.item.map(g=>{const{firstOnlyLabel:L,...v}=g;let{hint:F}=g;e.restrictHint&&A>0&&(F=void 0);let{label:I}=g;return A===0&&(I=g.firstOnlyLabel??g.label),{...v,hint:F,readonly:!!(e?.readonly||g.readonly),label:w.interpolateString(I,{...p,index:N}),full_path:`${T}.${g.fieldId}`}})},value:p,formData:n,onChange:c,onTopLevelChange:r,wrap:o}),P==="end"&&d.jsx(S.ButtonGroup,{className:"govuk-!-margin-top-2",children:d.jsx(S.Button,{onClick:()=>h(p),classModifiers:"secondary",children:b})})]},p.id)}),!e.disableAddAndRemove&&d.jsx(S.ButtonGroup,{children:d.jsx(S.Button,{onClick:u,classModifiers:"secondary",children:f(E)})})]})},ec=(e,t,n)=>{const s=e,r=typeof s.value=="object"?s.value?.value:s.value,o=n.find(i=>String(i.id)===r);return s.label=o===void 0?s.value||"":o.label,s.component=t.cya_label,s},tc=(e,t)=>typeof e=="string"?!!S.Utils.interpolateString(e,t):!!e,Vt=(e,t)=>{if(Array.isArray(t)){const n=t.find(s=>s.id===(e.full_path||e.id));if(n){const s={error:n.error};return n.properties&&(s.propsInError=n.properties),s}}},nc=[_.RADIOS,_.CHECKBOXES,_.DATE,_.TIME],sc=e=>e.fieldset||nc.includes(e.type),Ve=({component:e,value:t=null,formData:n=null,wrap:s=!0,onAction:r,onChange:o,onTopLevelChange:i,pages:l=[],submitting:a=!1,...c})=>{const{hooks:u}=Pe(),h=He(),{data:f,status:E}=ga(e,n),[y,p]=R.useState([]);R.useEffect(()=>{E===yt&&p(f)},[e,f,E]);const A=({target:C})=>typeof o=="function"?(e.type===_.EMAIL&&(C.value=C.value.trim()),e.type===_.CHECKBOXES&&Array.isArray(C.value)&&C.value.forEach(b=>{b.children&&b.nested&&(delete b.children,delete b.nested)}),C=ec(C,e,f),e.type===_.SELECT&&C.value===""&&(C.value=null,C.label=null),o({target:C}),!0):!1;if(R.useEffect(()=>{const C=w.Component.defaultValue(e,n);!t&&!n?.[e.fieldId]&&C&&typeof A=="function"&&A({target:{name:e.fieldId,value:C}})},[]),e.type===_.CONTAINER){let C=d.jsx(Ln,{...c,container:e,wrap:s,onChange:A,onTopLevelChange:i,value:t||w.Component.defaultValue(e,n),formData:n});return e.fieldset&&(C=Xe(e,C)),e.additionalValidation&&(C=Xe({...e,...Vt(e,h?.errors)},C)),C}if(e.type===_.COLLECTION)return d.jsx(Za,{...c,config:e,wrap:s,onChange:A,onTopLevelChange:i,value:t||w.Component.defaultValue(e,n),formData:n});if(e.type===_.COLLECTION_SUMMARY)return Xe({...e,...Vt(e,h?.errors)},d.jsx(Xa,{...c,config:e,formData:n,onAction:r,onChange:o,onTopLevelChange:i,pages:l}));const T=C=>{let b=e.full_path||e.fieldId;if(e.pageCollection){const P=w.CollectionPage.getActiveIndex(e.pageCollection.name,n);b=`${`${e.pageCollection.name}[${P}]`}.${b}`}i({target:{name:w.Meta.name,value:w.Meta.documents.setForField(C,n,b,e.allowMultiple)}})},N=({target:C})=>{if(A({target:C})){if(e.type===_.FILE)T([C.value]);else if(e.type===_.MULTI_FILE){const b=C.value.map((P,U)=>({...P,indexInField:U}));T(b)}}};return w.Component.get({...c,...e,id:e.full_path||e.id,...Vt(e,h?.errors),fieldset:sc(e),disabled:tc(e.disabled,n),label:w.interpolateString(e.label,n),content:w.interpolateString(e.content,n),hint:w.interpolateString(e.hint,n),cya_label:w.interpolateString(e.cya_label,n),suffix:w.interpolateString(e.suffix,n),options:y,value:t,onChange:N,onTopLevelChange:i,formData:n,onAction:r,submitting:a},s,u.onGetComponent)},rc=[_.AUTOCOMPLETE,_.CALCULATION,_.CHECKBOXES,_.COLLECTION_SUMMARY,_.DATE,_.EMAIL,_.FILE,_.MULTI_FILE,_.PHONE_NUMBER,_.RADIOS,_.SELECT,_.TEXT,_.TEXT_AREA,_.TIME],mr=e=>rc.includes(e?.type)||e?.isEditable||!1,oc="govuk-list",ic="govuk-body",lc=e=>{const t=te(e),n=S.Utils.interpolateString(e.heading,e.formData),s=S.Utils.interpolateString(e.text,e.formData);return d.jsx(S.Alert,{...t,heading:n,children:s})},ac=e=>{const t=te(e),n=de.getAutocompleteSource(e);return d.jsx(S.Autocomplete,{...t,source:n})},cc=e=>{let t=[];de.getOptions(e,s=>{t=s}),t=t.map(s=>Array.isArray(s.nested)?{...s,children:pr(e,s.nested)}:s);const n=te(e);return d.jsx(S.Checkboxes,{...n,options:t})},uc=e=>{const t=de.applyFormula(e);typeof e.onChange=="function"&&t!==e.value&&e.onChange({target:{name:e.fieldId,value:t}});const n=te(e,["formula"]);return d.jsx(S.TextInput,{...n,readonly:!0})},dc=e=>{const t=te(e);return d.jsx(S.DateInput,{...t})},fc=e=>{const t=te(e,["tagName"]),n=Ft(e);return d.jsx(S.Details,{...t,children:n})},hc=e=>{const t=te(e);return d.jsx(S.FileUpload,{...t})},mc=e=>{const t=te(e);return d.jsx(S.MultiFileUpload,{...t})},pc=e=>{const t=te(e);return d.jsx(S.Heading,{...t,children:e.content})},Ft=e=>{const t=te(e);return d.jsx(S.Markup,{...t})},Ec=e=>{const t=te(e);return d.jsx(S.InsetText,{...t,children:e.content})},Ac=e=>{const t=te(e,["ordered"]),n=e.ordered?"ol":"ul",s=e.ordered?"number":"bullet",r=S.Utils.classBuilder(oc,s),o=t.items?.map(i=>`<li>${i}</li>`).join("");return Ft({...t,className:r(),tagName:n,content:o,type:_.HTML})},yc=e=>{const t=te(e);return Ft({className:ic,...t,tagName:"p",type:_.HTML})},Tc=e=>{let t=[];de.getOptions(e,s=>{t=s}),t=t.map(s=>Array.isArray(s.nested)?{...s,children:pr(e,s.nested)}:s);const n=te(e);return d.jsx(S.Radios,{...n,options:t})},Sc=e=>{const t=te(e);return d.jsx(S.TextArea,{...t})},Cc=e=>{const t=te(e);return d.jsx(S.TextInput,{...t})},gc=e=>{const t=te(e);return d.jsx(S.TimeInput,{...t})},bc=e=>{let t=[];de.getOptions(e,s=>{t=s});const n=te(e);return d.jsx(S.Select,{...n,options:t})},wc=e=>{const t=te(e);return d.jsx(S.WarningText,{...t,children:e.content})},_c=e=>{switch(e.type){case _.HTML:return Ft(e);case _.HEADING:return pc(e);case _.INSET_TEXT:return Ec(e);case _.TEXT:case _.EMAIL:case _.PHONE_NUMBER:return Cc(e);case _.TEXT_AREA:return Sc(e);case _.AUTOCOMPLETE:return ac(e);case _.RADIOS:return Tc(e);case _.CHECKBOXES:return cc(e);case _.DATE:return dc(e);case _.TIME:return gc(e);case _.FILE:return hc(e);case _.MULTI_FILE:return mc(e);case _.WARNING:return wc(e);case _.SELECT:return bc(e);case _.DETAILS:return fc(e);case _.CALCULATION:return uc(e);case _.ALERT:return lc(e);case _.PARAGRAPH:return yc(e);case _.LIST:return Ac(e);default:return null}},Ic=(e,t)=>{const n={...t};if(e.full_path){const s=e.full_path.split(".");s.pop(),s.push(n.fieldId),n.full_path=s.join(".")}return e.formData&&(n.value=e.formData[n.fieldId]||de.getSource(e.formData,n.full_path)||""),"readonly"in n&&delete n.readonly,e.readonly?(n.readonly=e.readonly,d.jsx("div",{children:Er(n,!1)})):d.jsx(Ve,{component:n,value:n.value,onChange:e.onChange,onTopLevelChange:e.onChange,formData:e.formData},n.key)},pr=(e,t)=>{const n=t.filter(s=>!(s.show_when&&!ae.meetsAll(s.show_when,e.formData))).map(s=>d.jsx(d.Fragment,{children:Ic(e,s)},s.id));return n.length>0?n:null},Er=(e,t=!0,n=void 0)=>{if(typeof n=="function"){const r=n(e,t);if(r)return r}const s=_c(e);return s&&t&&mr(e)?Xe(e,s):s},Pc=e=>e.defaultValue||e.defaultObjectValue,xc=e=>{const n=/^(\d{1,2})-\d{1,2}-(\d{4})$/.test(e.defaultValue)?e.defaultValue:null;return e.defaultValue==="today"?K().format("DD-MM-YYYY"):n},Oc=(e,t)=>{const n={...e};let s=null;return!n.literal&&!n.sourced&&(n.sourced={...n}),n.literal&&(s={...n.literal}),n.sourced&&(s=s??{},Object.keys(n.sourced).every(r=>{const o=typeof n.sourced[r]=="string"&&se(t,n.sourced[r]);return o===void 0&&n.skipIfSourceInvalid?(s=null,!1):(s[r]=o||n.sourced[r],!0)})),s},Ar=(e,t)=>Pc(e)?e.type===_.DATE?xc(e):(e.defaultObjectValue?Oc(e.defaultObjectValue,t):null)||e.defaultValue||null:null,Rc={[_.COLLECTION]:[],[_.CONTAINER]:{}},Nc=(e,t)=>e&&(Ar(e,t)||Rc[e.type])||"",ot={clean:te,defaultValue:Nc,defaultValueFromConfig:Ar,editable:mr,elevateNested:et,get:Er,setupContainerPaths:fr,show:Ie,wrap:Xe},Lc=(e,t)=>{e.data?.options?.forEach(n=>{Array.isArray(n.nested)&&Ze(t.formData[e.id],n)&&n.nested.forEach(s=>{const r=s;r.value=t.formData[r.id]})})},jt=(e,t,n)=>{let s="";return e.formData&&t.fieldId&&(s=e.formData[t.fieldId],Lc(t,e)),{pageId:e.id,id:t.id,fieldId:t.fieldId,full_path:t.full_path,key:S.Utils.interpolateString(t.cya_label||t.label,e.formData),required:t.required,component:ot.editable(t)?t:void 0,value:s||"",action:e.cya_link?.singleChangeLink?null:vt(t.readonly,e,n)}},qe=(e,t,n,s,r)=>Ct(t,{...e.formData,...n})?et(t.components.filter(i=>i.show_on_cya===void 0||i.show_on_cya),n).filter(i=>Ct(i,{...e.formData,...n})).flatMap(i=>{const l=n?n[i.fieldId]:void 0;if(typeof r=="function"){const a=r({...e,formData:n},i,s);if(a)return a}return i.type===_.CONTAINER?qe(e,i,{...l,...n},s,r):i.type===_.COLLECTION?xn(e,i,l,s,r):jt({...e,formData:n},i,s)}):null,Dc=e=>{if(!e.conditionalProperties)return e;let t={...e};return e.conditionalProperties.forEach(n=>{w.Condition.met(n.condition,e.formData[n.condition.field])&&(t=Object.assign(t,n.properties))}),t},ls=(e,t,n="text")=>{if(typeof e=="string")return S.Utils.interpolateString(e,t);if(!Array.isArray(e)||Object.keys(t).length===0)return null;const s=e.find(r=>typeof r=="string"?!0:Ue(r.show_when,t));return typeof s=="string"?S.Utils.interpolateString(s,t):S.Utils.interpolateString(s[n],t)},vc=e=>{const t={...e};return t.page||(t.href?t.page=t.href.split("/").pop():t.url&&(t.page=t.url.split("/").pop())),t},Fc=e=>{if(e&&Array.isArray(e.actions))return e.actions.map(t=>{if(typeof t=="string")return W.DEFAULTS[t];if(t&&typeof t=="object"){const n=t;return W.DEFAULTS[n.type]?.validate&&!n.hasOwnProperty("validate")&&(n.validate=!0),vc(n)}}).filter(t=>!!t)},jc=e=>({type:_.HTML,tagName:"p",content:e}),Uc=(e,t)=>{const n=e.use.split("."),s=n.shift();let r=JSON.parse(JSON.stringify({...t.find(l=>l.id===s)})),o=r,i=r;for(;o&&n.length>0;){const l=n.shift();Array.isArray(o.components)?(i=o,i.components=i.components.filter(a=>a.id===l),i.components.length>0?o=i.components[0]:o=void 0):o=void 0}if(o)return o={cya_label:o.label,...o,...e},i&&i.id!==o.id?i.components=[o]:r=o,o.item&&Array.isArray(o.item)&&(o.item=o.item.map(l=>l.use?ln(l,t):l)),r},ln=(e,t)=>{if(e){const n=Uc(e,t);if(n)return n}return{...e}},yr=(e,t,n)=>{if(!e)return null;const s=e.components.map(o=>{if(typeof o=="string")return jc(o);let i;return o.type===_.CONTAINER&&(o.components=o.components.map(l=>l.use?ln(l,t):l)),o.use?i=ln(o,t):i={...o},n?de.refData.setupUrl(i,n):i}),r=Fc(e);return Lt.setup({...e,formData:n,components:s,actions:r})},Mc=(e,t,n)=>Array.isArray(e)?e.map((s,r)=>({...yr(s,t,n),index:r})):[],Tr=(e,t)=>e?.hasOwnProperty("show_on_cya")&&!e.show_on_cya?!1:Dt(e,t),it={applyConditionalProperties:Dc,getConditionalText:ls,get:yr,getAll:Mc,getTitle:(e,t)=>ls(e,t,"title"),show:Dt,showCYA:Tr},kc=(e,t)=>{if(!e)return null;if(!t)return e;const n={...e};return n.show_when?Array.isArray(t)?n.show_when=Array.isArray(n.show_when)?[...t,...n.show_when]:[...t,n.show_when]:n.show_when=Array.isArray(n.show_when)?[...n.show_when,t]:[n.show_when,t]:n.show_when=t,n},Bc=(e,t)=>{const n=e.split(".").pop();t[`${n}ActiveId`]=null},Ut=(e,t)=>{const n=e.split(".").pop();return t[`${n}ActiveId`]||null},$c=e=>typeof e=="number"&&e>=0,Sr=(e,t,n)=>{const s=e[0];if(e.length===1)return t[s]||null;const r=n?.[`${s}ActiveId`]||null;if(!r)return null;const o=t[s]?.findIndex(i=>i.id===r);return $c(o)?(e.shift(),Sr(e,t[s][o],n)):null},Ge=(e,t)=>{const n=e.split(".");return Sr(n,t,t)},Cr=(e,t,n,s=[],r={})=>{const o=Ge(e,t),i=o?.find(u=>u.id===n);if(!i)return null;const l=_t.v4(),a={...i,...r,id:l};s.forEach(u=>delete a[u]);const c=o.findIndex(u=>u.id===n)+1;return c===-1?o.push(a):o.splice(c,0,a),t[`${e.split(".").pop()}ActiveId`]=a.id,l},Yc=(e,t)=>{const n=Ut(e,t);return Cr(e,t,n)},Hc=e=>typeof e=="number"&&e>=0,gr=(e,t,n)=>{const s=e[0],r=n?.[`${s}ActiveId`]||null;if(!r)return null;const o=t[s]?.findIndex(i=>i.id===r);return Hc(o)?e.length===1?o:(e.shift(),gr(e,t[s][o],n)):null},br=(e,t)=>{const n=e.split(".");return gr(n,t,t)},Vc=e=>({id:e.id,name:e.name,...e.collection.show_when&&{show_when:e.collection.show_when},orderInForm:e.orderInForm,deleteCollectionWhenHidden:e.deleteCollectionWhenHidden,collection:{masterPage:!0,...e.collection},formData:{...e.formData},childPages:[e]}),qc=(e,t)=>{t.collection={...t.collection,...e.collection},t.formData={...t.formData,...e.formData},t.childPages=[...t.childPages,e]},Gc=(e,t)=>{const n=e.collection.name.split(".");if(n.length===1)return!1;n.pop();const s=n.join("."),r=t[s]||null;return r?(r.childPages.push(e),r.childPages.sort((o,i)=>o.orderInForm-i.orderInForm),!0):!1},wr=e=>{const t={};return e.map((s,r)=>{if(s.orderInForm=r,s?.collection?.name){if(!t[s.collection.name]){const o=Vc(s);return t[s.collection.name]=o,o}return qc(s,t[s.collection.name]),null}return s}).filter(s=>!!s).map(s=>s.collection?.masterPage&&Gc(s,t)?null:s).filter(s=>!!s)},Kc=(e,t,n)=>{const s=Ge(e,t);if(!s)return null;const r=s.findIndex(l=>l.id===n);if(r===-1)return null;const o=s[r];s.splice(r,1);const i=t;return i[`${e}ActiveId`]=s.length>0?s[0].id:null,o},Wc=e=>typeof e=="number"&&e>=0,On=(e,t,n)=>{const s=e.split("."),r=s[s.length-1];let o=n;s.some(i=>{if(o[i]||(o[i]=[]),!o[i].find(c=>c.id===n[`${i}ActiveId`])){const c=_t.v4();n[`${i}ActiveId`]=n[`${i}ActiveId`]||c,o[i].push({id:n[`${i}ActiveId`]})}if(i===r)return o[r]=t,!0;const l=n[`${i}ActiveId`],a=o[i]?.findIndex(c=>c.id===l);return Wc(a)?(o=o[i][a],!1):!0})},gt={addEntry:Bc,duplicateActiveEntry:Yc,duplicateEntry:Cr,getActiveId:Ut,getActiveIndex:br,getData:Ge,getErrorsForCollection:gn,mergePages:wr,removeEntry:Kc,setData:On},zc=e=>typeof e=="number"&&e>=0,Jc=(e,t,n,s,r,o)=>{const i=r?.label||$e.remove;return{pageId:e.id,fieldId:`delete${s}`,key:`delete${s}`,type:"action",action:{onAction:()=>{n(null,a=>{const c=a;if(!o)return c;Object.entries(o).forEach(f=>{const[E,y]=f;c[E]=y});const u=gt.getData(e.collection.name,c),h=u?.findIndex(f=>f.id===t.id);return zc(h)&&u.splice(h,1),c})},label:S.Utils.interpolateString(i,{...t,index:s})}}},Xc=(e,t,n,s,r,o={})=>{const i=r?.label||$e.change;return{pageId:e.id,fieldId:`change${s}${r.page}`,key:`change${s}${r.page}`,type:"action",action:{onAction:l=>{const a=c=>{const u=c;return Object.entries(o).forEach(h=>{const[f,E]=h;u[f]=E}),u};n(r.page?{pageId:r.page}:l,a)},label:S.Utils.interpolateString(i,{...t,index:s})}}},Qc=(e,t)=>t.show_when?Ue(t.show_when,e):!0,Zc=(e,t,n,s)=>({id:t.id,fieldId:t.id,type:_.CONTAINER,required:!0,full_path:s,components:e.components.map(r=>({...r,label:S.Utils.interpolateString(r.label,{...t,index:n}),full_path:`${s}.${r.fieldId}`}))}),eu=(e,t,n,s,r)=>{const o={...$e,...e.collection.labels};return{pageId:n,fieldId:"Title",full_path:`${r}.Title`,key:S.Utils.interpolateString(o.item,{...t,index:s}),type:"heading",size:e.collection.titleSize||"s"}},tu=(e,t,n,s,r)=>e.text===""?null:{pageId:t,fieldId:`heading${n}`,full_path:`heading${n}`,key:S.Utils.interpolateString(e.text,r),type:s===null?"heading":"headingWithAction",size:e.size||"s",action:s===null?null:{onAction:s,label:"Change"}},nu=(e,t,n,s)=>({pageId:e.id,fieldId:`${e.collection.name}Title`,full_path:`${e.collection.name}Title`,key:n?.text||t.charAt(0).toUpperCase()+t.slice(1),type:s==null?"heading":"headingWithAction",size:n?.size||"m",action:s===null?null:{onAction:s,label:"Change"}}),su=(e,t,n,s,r,o={})=>e.collection?.actions?.filter(i=>Qc(r,i)).map(i=>i.type==="remove"?Jc(e,t,n,s,i,o):i.type==="change"?Xc(e,t,n,s,i,o):null).filter(i=>!!i),_r=(e,t,n={})=>()=>{const s=r=>{const o=r;return Object.entries(n).forEach(i=>{const[l,a]=i;o[l]=a}),o};t({pageId:e.id},s)},ru=(e,t,n,s,r,o,i)=>{let l=[];return e.forEach(a=>{let c=a;if(c.collection.masterPage)l=l.concat(Ir(c,n,s,t,i));else if(c.collection.route&&(c=kc(c,c.collection.route)||c),Tr(c,{...c.formData,...t})){const u=_r(c,n,i);if(c.collection.heading){const E=c.collection.heading.changeLink?u:null,y=tu(c.collection.heading,c.id,r,E,t);l=l.concat(y)}const h=Zc(c,t,r,o),f=qe({...c,formData:{...c.formData,...t}},h,{...c.formData,...t},u,s);l=l.concat(f)}}),l},Ir=(e,t,n,s,r={})=>{const o=e.collection.name.split(".").pop();let i=s[o]||null;const l=s[`${o}ActiveId`];if(!i||i.length===0)return[];let a=[];if(!e.collection.hideNameFromCYA){const f=e.collection.collectionHeading?.changeLinkPage?_r({id:e.collection.collectionHeading.changeLinkPage},t,r):null;a.push(nu(e,o,e.collection.collectionHeading,f))}let c=0;const u=Array.isArray(e.collection.hideItemTitles)?Ue(e.collection.hideItemTitles,s):e.collection.hideItemTitles;return(Array.isArray(e.collection.onlyShowActiveEntryOnCYA)?Ue(e.collection.onlyShowActiveEntryOnCYA,s):e.collection.onlyShowActiveEntryOnCYA)&&(i=[i.find((E,y)=>(c=y,E.id===l))]),i.forEach(f=>{if(!f)return;r={...r,[`${o}ActiveId`]:f.id};const E=c+1,y=e.collection?.actionPosition||"top",p=`${e.collection.name}[${c}]`,A=su(e,f,t,E,s,r);if(!u){const T=eu(e,f,e.id,E,p);a=a.concat(T)}y==="top"&&(a=a.concat(A)),a=a.concat(ru(e.childPages,f,t,n,E,p,r)),y==="bottom"&&(a=a.concat(A)),c+=1}),a.filter(f=>!!f)},ou=e=>e.value?e.component?d.jsx("div",{children:d.jsx(Ve,{component:{...e.component,readonly:!0},wrap:!1,value:e.value})},e.id):e.value:null,iu=(e,t)=>{let n=-1;return{value:d.jsx(d.Fragment,{children:e.components.map(r=>{const o=t.findIndex(i=>i.id===r);return n<0&&(n=o),o>-1?ou(t[o]):null})}),firstComponentIndex:n}},lu=(e,t,n,s)=>{const{value:r,firstComponentIndex:o}=iu(t,n);return{row:{pageId:e.id,fieldId:t.id,key:t.label,required:t.required,value:r,action:vt(!1,e,s)},insertAt:o}},au=(e,t,n=null)=>{if(it.showCYA(e,e.formData)){if(e.collection)return Ir(e,t,n,e.formData);const r=et(e.components,e.formData).filter(o=>Ct(o,e.formData)).flatMap(o=>{if(typeof n=="function"){const i=n(e,o,t);if(i)return i}switch(o.type){case _.CONTAINER:return qe(e,o,e.formData[o.fieldId],t,n);case _.COLLECTION:return xn(e,o,e.formData[o.fieldId],t,n);default:return jt(e,o,t)}});if(e.groups?.length>0){e.groups.forEach(i=>{const{row:l,insertAt:a}=lu(e,i,r,t);a>-1?r.splice(a,0,l):r.push(l)});const o=e.groups.flatMap(i=>i.components);return r.filter(i=>!o.includes(i.id))}return r}return[]},cu={getRows:au,getCYARowsForContainer:qe},Pr=(e,t)=>{if(e&&t)switch(e.type){case"lowercase":return t.toLowerCase();case"uppercase":return t.toUpperCase();default:return t}return t},xr=(e,t,n)=>{const s=t;e.format&&e.format.on===n&&(s[e.fieldId]=Pr(e.format,s[e.fieldId]))},Or=(e,t,n)=>{e.forEach(s=>xr(s,t,n))},Rr=(e,t,n)=>{Or(e.components,t,n)},uu=(e,t,n)=>{e.forEach(s=>Rr(s,t,n))},du=(e,t,n)=>{const s={...t};return Or(e.components,s,n),uu(e.pages,s,n),s},fu={component:xr,data:Pr,form:du,page:Rr},hu=(e,t,n,s)=>{if(e===ne.HUB&&t){if(t.format===ye.CYA)return ye.CYA;if(t.components)return it.get(t,n,s)}if(e===ne.TASK||e===ne.FORM_WITH_TASK)return ye.TASK},mu={get:hu},Rn="meta",Nn="documents",an=e=>e?.[Rn]?.[Nn]||[],pu=(e,t,n,s)=>{const r=s?an(t):an(t).filter(i=>i.field!==n);return Array.isArray(e)&&e.forEach(i=>{r.push({...i,field:n})}),{...t?t[Rn]:void 0,[Nn]:r}},Eu={setForField:pu,get:an,name:Nn},Au={documents:Eu,name:Rn},yu=(e,t)=>{if(e?.field){const n=S.Utils.interpolateString(e.field,t);return!!se(t,n)}return!1},qt=(e,t)=>{if(e?.value)return e.value;const n=S.Utils.interpolateString(e?.field,t);return se(t,n)},Tu=(e,t)=>{if(!e||!t)return null;const n=S.Utils.interpolateString(e.target,t),s=se(t,n),r=qt(e,t),o=qt(e.cutoff,t),i=qt(e.ignore,t);let l=null;return s&&r&&Array.isArray(s)&&s.every((a,c)=>c===o?!1:c===i?!0:a===r||e.key&&se(a,e.key)===r?(l=c,!1):!0),typeof l=="number"?l.toString():l},Su=(e,t,n)=>{let s;if(e?.field){const r=S.Utils.interpolateString(e.field,t);s=se(t,r)}else s=e?.value;s!=null&&e.name&&t[e.name]!==s&&n({target:{name:e.name,value:s}})},Cu=(e,t)=>{if(e?.field){const n=S.Utils.interpolateString(e.field,t);return se(t,n)||null}return e?.value||null},gu=(e,t,n)=>{const s=t;e?.field&&e?.component&&(delete s[e.field],n({target:{name:e.field,value:null,component:e.component}}))},bu=(e,t)=>{if(e?.condition){const n=e,s=S.Utils.interpolateString(n.field,t),r=se(t,s);switch(n.condition){case"changes":{const o=`${s}LastValue`,i=n[o]||null;return i===null?(n[o]=r,!1):r!==i?(n[o]=r,!0):!1}case"isTruthy":return!!r;case"isFalsy":return!r;default:return!1}}return!0},wu=(e,t)=>{if(e?.fields){let n;return e.fields.find(s=>{const r=S.Utils.interpolateString(s,t),o=se(t,r);return o?(n=o,!0):!1}),n||(e.fallback?S.Utils.interpolateString(e.fallback,t):"")}return e?.value||null},_u=(e,t)=>{if(!e||!t)return null;const n=e.target.split(".");let s="";n.forEach(i=>{if(s!==""&&(s+="."),i.slice(-2)==="[]"){const l=i.slice(0,-2),a=br(l,t);s+=`${l}[${a}]`}else s+=i});const r=S.Utils.interpolateString(s,t);return se(t,r)?.length||0},Iu=(e,t)=>{const n=S.Utils.interpolateString(e.target,t),s=se(t,n);return s&&Array.isArray(s)?s.some(r=>e.key?se(r,e.key)===e.value:r===e.value):s&&typeof s=="object"?se(s,e.key)===e.value:!1},Pu={checkValueIsTruthy:yu,getIndexOfMatchingValueIn:Tu,doesContainValue:Iu,persistValueInFormData:Su,setValueInFormData:Cu,deleteValueInFormData:gu,getLength:_u,getFirstOf:wu},xu=(e,t,n)=>{const s=Pu[e.function];if(typeof s=="function")return s(e,t,n)},Ou=(e,t,n)=>(e?.operations&&t&&e.operations.forEach(s=>{if(bu(s.run_when,t)){const r=xu(s,t,n);if(s.output){const o=S.Utils.interpolateString(s.output,t).replace("[",".").replace("]","");Rs(t,o,r)}}}),t),Ru={runPageOperations:Ou},Nu=(e,t,n,s)=>!(e!==t.base&&s[t.check]),Lu=(e,t,n)=>{const s=e[n.id]?.[t.base],r=e[n.id]?.[t.check],o=r&&r?.length>0;return!!(s||o)},Du=e=>/^-?\d+$/.test(e),bt=e=>Du(e)?e.padStart(2,"0"):"",ge=e=>{const[t,n,s]=e.split("-");return`${bt(t)}-${bt(n)}-${s}`},Nr=e=>{const[t,n]=e.split(":");return`${bt(t)}:${bt(n)}`},Se="DD-MM-YYYY";K.extend(Be);const vu=(e,t)=>{const n=t.date?K(ge(t.date),Se):K().add(t.value,t.unit);return K(ge(e),Se).isAfter(n)};K.extend(Be);const Fu=(e,t)=>{const n=t.date?K(ge(t.date),Se):K().add(t.value,t.unit);return K(ge(e),Se).isBefore(n)};K.extend(Be);const ju=(e,t,n)=>{const s=n.components?.find(c=>c.fieldId===t.date),r=n.components?.find(c=>c.fieldId===t.time);if(!s||!r||!e)return!1;const o=e[n.fieldId]?.[t.date],i=e[n.fieldId]?.[t.time];if(!o||!i||Qe(s,e[n.fieldId],e[n.fieldId])||Qe(r,e[n.fieldId],e[n.fieldId]))return!0;const l=ge(e[n.fieldId]?.[t.date]),a=Nr(e[n.fieldId]?.[t.time]);return K(`${l} ${a}`,`${Se} HH:mm`).isBefore(K())};K.extend(Be);K.extend(fn);const Uu=(e,t)=>{const n=K(ge(e),Se).isBefore(K()),s=K(ge(e),Se).isToday();return n&&!s?!0:s&&!!t?.todayAllowed};K.extend(Be);K.extend(fn);const Mu=(e,t)=>K(ge(e),Se).isAfter(K())?!0:!!t?.todayAllowed&&K(ge(e),Se).isToday(),ku=(e,t)=>e?e.length>t.value:!0,Bu=(e,t)=>e?e.length<t.value:!0,$u=(e,t)=>{if(!e)return!0;const n=typeof e=="string"?e.replace(/,/g,""):e;return parseFloat(n)>t.value},Yu=(e,t)=>{if(!e)return!0;const n=typeof e=="string"?e.replace(/,/g,""):e;return parseFloat(n)<t.value},Hu=(e,t)=>e?(t?.allowCommas?/^[0-9,]*\.?[0-9]*$/:/^[0-9]*\.?[0-9]*$/).test(e):!0,Vu=(e,t)=>e?t.array.includes(e):!0,qu=(e,t,n,s)=>{if(!e||!s)return!0;const r=Ut(t.collectionPath,s);return!Ge(t.collectionPath,s)?.some(l=>l.id===r?!1:t.caseInsensitive&&typeof e=="string"&&typeof l[n.id]=="string"?l[n.id].toUpperCase()===e.toUpperCase():l[n.id]===e)},Gu=(e,t,n)=>n.components?.some(s=>!!e[n.id]?.[s.id]),Ku=(e,t)=>!e||!e.includes(".")?!0:e.split(".")[1].length<t.maxDecimals,Wu=/(%27)|(')|(--)|(%23)|(#)|((%3D)|(=))[^\n]*((%27)|(')|(--)|(%3B)|(;))|w*((%27)|('))((%6F)|o|(%4F))((%72)|r|(%52))|((%27)|('))union/i,zu=e=>{if(e){const t=typeof e=="object"?JSON.stringify(e):String(e);return!Wu.test(t)}return!1},Ju=(e,t,n)=>n.components?.reduce((r,o)=>e[n.id]?.[o.id]?Array.isArray(e[n.id][o.id])&&e[n.id][o.id].length===0?r:r+1:r,0)<2,Xu={conditionallyPermittedChange:Nu,conditionallyRequired:Lu,mustBeAfter:vu,mustBeBefore:Fu,mustBeEarlierDateTime:ju,mustBeGreaterThan:$u,mustBeInTheFuture:Mu,mustBeInThePast:Uu,mustBeLessThan:Yu,mustBeLongerThan:ku,mustBeNumbersOnly:Hu,mustBeOneOf:Vu,mustBeShorterThan:Bu,mustBeUniqueInCollection:qu,mustEnterAtLeastOne:Gu,mustHaveLessThanDecimalPlaces:Ku,mustNotContainSql:zu,mustSelectOnlyOne:Ju},Qu=(e,t,n,s)=>{const r=Xu[t.function],o=t.objectValueToUse?e[t.objectValueToUse]:e;if(typeof r=="function")return r(o,t,n,s)?void 0:t.message},Lr=(e,t,n)=>{if(t&&Array.isArray(e.additionalValidation)){let s;return e.additionalValidation.forEach(r=>{s||(s=Qu(t,r,e,n))}),s}},wt=(e,t,n)=>{if(!e)return[];const s=n||t,r=Lr(e,s);if(r)return{id:e.id,error:r};const o=[];if(Array.isArray(e.components)){const i=t&&e.fieldId?t[e.fieldId]:t;et(e.components,i).forEach(a=>{const c=e.full_path||e.fieldId?`${e.full_path||e.fieldId}.${a.fieldId}`:a.fieldId;o.push(Qe({...a,full_path:c},i,s))})}return o.flat(1).filter(i=>!!i)},Zu=(e,t,n)=>{const s=[];return e&&Array.isArray(e.item)&&Array.isArray(t)&&t.forEach((r,o)=>{const i=(e.countOffset||0)+o+1,l=`${e.full_path||e.fieldId}[${o}]`,a={full_path:l,components:e.item.map(c=>{const u={...c,full_path:`${l}.${c.fieldId}`};return c.custom_errors&&Array.isArray(c.custom_errors)&&(u.custom_errors=c.custom_errors.map(h=>({...h,message:S.Utils.interpolateString(o===0&&h.firstOnlyMessage?h.firstOnlyMessage:h.message,{index:i})}))),u})};s.push(wt(a,r,n))}),s.filter(r=>!!r).flat()};K.extend(Be);K.extend(fn);K.extend(Xr);const ed=(e,t)=>e==="02"?K().year(t).isLeapYear()?29:28:["04","06","09","11"].includes(e)?30:31,Dr=e=>{if(!e)return{message:void 0,propsInError:void 0};const t=ge(e),[n,s,r]=t.split("-"),o=parseInt(n,10),i=parseInt(s,10),l=[],a=[];if(r.length===0?(l.push("year"),a.push("Date must include a year")):r.length!==4&&(l.push("year"),a.push("Year must be 4 numbers")),s.length===0?(l.push("month"),a.push("Date must include a month")):(i>12||i<1)&&(l.push("month"),a.push("Month must be between 1 and 12")),n.length===0)l.push("day"),a.push("Date must include a day");else{const c=ed(s,r);(o>c||o<1)&&(l.push("day"),a.push(`Day must be between 1 and ${c}`))}if(l.length>0){const c={};return l.includes("day")&&(c.day=!0),l.includes("month")&&(c.month=!0),l.includes("year")&&(c.year=!0),{message:l.length===1?a[0]:"Enter a valid date",propsInError:c}}return K(t,Se).format(Se)!==t?{message:"Enter a valid date",propsInError:{day:!0,month:!0,year:!0}}:{message:void 0,propsInError:void 0}},td=/^[a-z0-9._\-']+@(digital\.)?homeoffice.gov.uk$/i,nd=/^[a-z0-9._\-']+@jmsc.gov.uk$/i,vr=(e,t="",n=[])=>{if(e){const s=t?t.toLowerCase():"email address";if(typeof e=="string"&&(td.test(e)||nd.test(e)))return;if(Array.isArray(n)){const r=n.filter(o=>o.type==="format");if(r&&r.length>0&&r[0].message)return r[0].message}return`Enter ${s} in the correct format, like jane.doe@homeoffice.gov.uk`}},sd="Invalid files must be deleted",Fr=(e,t)=>{if(!e)return;let n=!1;if(e.every(s=>(n=s.error,!n)),n){if(Array.isArray(t)){const s=t.filter(r=>r.type==="invalidFile");if(s&&s.length>0&&s[0].message)return s[0].message}return sd}},jr=(e,t,n,s)=>{if(e){if(typeof e=="string"){if(new RegExp(n).test(e))return;if(Array.isArray(s)){const o=s.filter(i=>i.type==="pattern");if(o?.[0]?.message)return o[0].message}}return t?`${t} failed regex validation`:"Component failed regex validation"}},Ur=(e,t,n)=>{let s=!1;if((e||e===!1||e===0)&&(s=!0,typeof e=="string"?s=e.trim().length>0:Array.isArray(e)&&(s=e.length>0)),!s){if(Array.isArray(n)){const o=n.filter(i=>i.type==="required");if(o&&o.length>0&&o[0].message)return o[0].message}return`${t||"Field"} is required`}},Mr=(e,t,n,s,r,o=1e3)=>{if(!n||!r&&!t)return;if(r&&!t||t.length>o){if(Array.isArray(s)){const l=s.filter(a=>a.type==="length");if(l&&l.length>0&&l[0].message)return l[0].message}return`${e} must be ${o} characters or less`}},kr=e=>{if(!e)return{message:void 0,propsInError:void 0};const t=Nr(e),[n,s]=t.split(":"),r=parseInt(n,10),o=parseInt(s,10),i=[],l=[];if(/^\d{0,2}:\d{0,2}$/.test(e)||(i.push("invalid"),l.push("Enter a valid time")),n.length===0?(i.push("hour"),l.push("Time must include a hour")):(r>23||r<0)&&(i.push("hour"),l.push("Hour must be between 0 and 23")),s.length===0?(i.push("minute"),l.push("Time must include a minute")):(o>59||o<0)&&(i.push("minute"),l.push("Minute must be between 0 and 59")),i.length>0){const c={};return i.includes("hour")&&(c.hour=!0),i.includes("minute")&&(c.minute=!0),i.includes("invalid")&&(c.invalid=!0),{message:i.length>1?"Enter a valid time":l[0],propsInError:c}}return{message:void 0,propsInError:void 0}},rd=(e,t)=>e?.type==="or"?ae.meetsOne(e.conditions,t):ae.meetsAll(e.conditions,t),Qe=(e,t,n)=>{const s=n||t;if(!Ie(e,{...s,...t}))return;if(e.type===_.CONTAINER)return wt(e,t,s);let r,o,l=(t&&typeof t=="object"?t:{})[e.fieldId];if(e.type===_.COLLECTION_SUMMARY&&(l=Ge(e.collectionName,s)),e.required&&(!e.requiredOverrideConditions||!rd(e.requiredOverrideConditions,s))&&(r=Ur(l,e.label,e.custom_errors)),!r){switch(e.type){case _.COLLECTION:return Zu(e,l,s);case _.EMAIL:r=vr(l,e.label,e.custom_errors);break;case _.DATE:case _.TIME:{const a=e.type===_.DATE?Dr:kr,{message:c,propsInError:u}=a(l);o=u,r=c;break}case _.CHECKBOXES:case _.RADIOS:{let a=[];if(e.data.options?.forEach(c=>{c.nested&&Ze(n[e.id],c)&&(a=a.concat(wt({components:c.nested},n)))}),a.length>0)return a;break}case _.MULTI_FILE:r=Fr(l,e.custom_errors);break;case _.TEXT_AREA:r=Mr(e.label,l,e.showCharacterCount,e.custom_errors,e.required,e.maxLength);break}!r&&e.pattern&&(r=jr(l,e.label,e.pattern,e.custom_errors)),!r&&e.additionalValidation&&(r=Lr(e,l,n),e.type===_.DATE&&r&&(o={day:!0,month:!0,year:!0}))}if(r)return{id:e.full_path||e.id,error:r,properties:o}},od=(e,t=[])=>{let n=e.formData;if(e.collection){const s=gt.getActiveIndex(e.collection.name,e.formData);s!==null&&(n={...e.formData,...gt.getData(e.collection.name,e.formData)?.[s]})}return Dt(e,n)&&Array.isArray(e.components)?e.components.reduce((r,o)=>{if(!Ie(o,n))return r;const l=(t.length>0?t.filter(a=>a.showFor?a.showFor===o.id:a.id===o.id):[]).concat(Qe(o,n,n));return r.concat(l).flat().map(a=>a&&{...a,error:S.Utils.interpolateString(a.error,n)})},[]).filter(r=>!!r).flat():[]},id={component:Qe,container:wt,email:vr,date:Dr,multifile:Fr,page:od,regex:jr,required:Ur,textarea:Mr,time:kr},w={CheckYourAnswers:cu,CollectionPage:gt,Component:ot,Condition:ae,Container:Lt,Data:de,Format:fu,FormPage:it,Hub:mu,Meta:Au,Operate:Ru,Validate:id,...S.Utils},ld="hods-form-container",Ln=({container:e,value:t=void 0,formData:n,onChange:s=void 0,wrap:r=!0,onTopLevelChange:o=void 0,...i})=>{const l=({target:h})=>{if(typeof s=="function")if(h.name===w.Meta.name)s({target:h});else{const f={...t,[h.name]:h.value};s({target:{name:e.fieldId,value:f}})}},a=h=>{const f=`${e.full_path||e.fieldId}.${h.fieldId}`;return h.type===_.CONTAINER?w.Container.show({...h,full_path:f},n):w.Component.show({...h,full_path:f},{...n,...se(n,e.full_path)})},c=w.classBuilder(ld,[],e.className),u=S.Utils.cleanHtmlAttributes(i);return d.jsxs("div",{...u,className:c(),id:e.id,children:[e.title&&d.jsx(S.MediumHeading,{children:e.title}),e.components&&e.components.filter(a).map((h,f)=>{const E=h.type===_.FILE?{}:"",y=t?t[h.fieldId]:E,p=`${e.full_path||e.fieldId}.${h.fieldId}`;return d.jsx(Ve,{...i,component:{...h,full_path:p,readonly:!!(e.readonly||h.readonly)},formData:n,value:y||E,wrap:r,onChange:l,onTopLevelChange:o},f)})]})},ad=e=>{if(e&&Object.prototype.hasOwnProperty.call(e,"action")){if(typeof e.action.onAction=="function")return{onClick:()=>e.action.onAction(e),onKeyPress:t=>{t.key==="Enter"&&e.action.onAction(e)},tabIndex:"0"};if(e.action.page)return{href:`/${e.action.page}`}}return{}},as=({group:e})=>{const[t,n]=R.useState({});return R.useEffect(()=>{n(ad(e))},[e,n]),e?.action?d.jsxs(S.Link,{...t,"aria-label":`${e.action.label} ${e.action.aria_suffix}`,children:[e.action.label,e.action.aria_suffix&&d.jsxs("span",{className:"mobile-text govuk-link",children:[" ",`${e.action.aria_suffix}`]})]}):null},cd=({title:e,size:t="m",classes:n})=>d.jsxs("div",{className:`${n("heading")}`,role:"listitem",children:[t==="s"&&d.jsx(S.SmallHeading,{children:e}),t==="m"&&d.jsx(S.MediumHeading,{children:e})]}),ud=({row:e,classes:t,noChangeAction:n=!1})=>d.jsxs("div",{className:t("headingWithAction"),role:"listitem",children:[d.jsxs("td",{className:"heading-text",colSpan:"2",children:[e.size==="s"&&d.jsx(S.SmallHeading,{children:e.key}),e.size==="m"&&d.jsx(S.MediumHeading,{children:e.key})]}),d.jsx("td",{className:"heading-action",children:!n&&d.jsx(Pn,{row:{action:e.action}})})]}),dd="govuk-summary-list",cn=({rows:e,noChangeAction:t=!1,noGroupAction:n=!1,isGroup:s=!1,classBlock:r=dd,classModifiers:o=[],className:i="",showGroupAction:l=!0,...a})=>{const c=S.Utils.classBuilder(r,o,i),u=S.Utils.cleanHtmlAttributes(a);let h=null;if(s){const f=e.filter(E=>!!E.action);h=f?.length?f[0]:null}return d.jsx("div",{className:"group-of-rows",children:d.jsxs("div",{...u,className:c(),role:"list",children:[e.map(f=>{const E=`${f.pageId}_${f.full_path||f.fieldId}`;return f.type==="title"?d.jsx(ur,{title:f.key,classes:c},E):f.type==="heading"?d.jsx(cd,{title:f.key,size:f.size||"s",classes:c},E):f.type==="headingWithAction"?d.jsx(ud,{row:f,classes:c,noChangeAction:t},E):f.type==="action"?t?null:d.jsx("div",{children:d.jsx(as,{group:f})},`${E}-actions`):d.jsx(cr,{row:f,classes:c,showAction:!t},E)}).filter(f=>!!f),l&&s&&!n&&d.jsx("div",{className:"change-group-button",children:d.jsx(as,{group:h})})]})})},fd="hods-check-your-answers",hd="Check your answers",cs=9,md=({title:e=hd,titleSize:t="l",pages:n,actions:s=[],onAction:r,onRowAction:o,hide_page_titles:i=!1,hide_actions:l=!1,hide_title:a=!1,summaryListClassModifiers:c,noChangeAction:u,noGroupAction:h,groups:f,sections:E=[],type:y,hideBlankRows:p=!1,optionalFieldPlaceholder:A})=>{const[T,N]=R.useState([]),[C,b]=R.useState([]),{errors:P}=He(),{hooks:U}=Pe();R.useEffect(()=>{const x=(q,X)=>w.CheckYourAnswers.getRows(q,o,U.onGetCYARows).map((V,z)=>({...V,value:d.jsx(bn,{value:V.value,component:V.component,formData:q.formData,placeholder:A},`${X}_${z}`)})),$=w.CollectionPage.mergePages(n).map((q,X)=>{const G=x(q,X);return G?.length?{...q,rows:G}:null}).filter(q=>!!q);N($)},[n,o,N]);const g=i?0:cs,L=x=>x===T.length-1;R.useEffect(()=>{(()=>{const j=Array.isArray(f)?f.map($=>$.pageId):[];b(j)})()},[b,f]);const v=U.onGetCYA({title:e,pages:n,actions:s,onAction:r,onRowAction:o,hidePageTitles:i,hideActions:l,hideTitle:a,summaryListClassModifiers:c,noChangeAction:u,noGroupAction:h,groups:f,errors:P,sections:E,type:y});if(v)return v;const F=x=>C.includes(x),I=x=>f?.find(j=>j.pageId===x),k=(x,j)=>{if(!x.cya_link?.singleChangeLink||u)return d.jsxs(d.Fragment,{children:[j==="s"&&d.jsx(S.SmallHeading,{children:w.FormPage.getTitle(x.title,x.formData)}),j==="m"&&d.jsx(S.MediumHeading,{children:w.FormPage.getTitle(x.title,x.formData)})]});const $=vt(!1,x,o);return d.jsxs("div",{className:"heading-with-action",children:[d.jsxs("div",{className:"heading-text",children:[j==="s"&&d.jsx(S.SmallHeading,{children:w.FormPage.getTitle(x.title,x.formData)}),j==="m"&&d.jsx(S.MediumHeading,{children:w.FormPage.getTitle(x.title,x.formData)})]}),d.jsx("div",{className:"heading-action",children:d.jsx(Pn,{row:{action:$}})})]})},O=()=>Array.from(new Set(P.map(j=>j.id))).map(j=>P.find($=>$.id===j));return d.jsxs("div",{className:fd,children:[e&&!a&&d.jsx(S.Heading,{size:t,children:e},"heading"),P&&P.length>0&&d.jsx(S.ErrorSummary,{errors:O()}),y===ne.TASK_CYA&&T.length>0&&E&&E.map(x=>x.tasks.filter(j=>j.state!==H.TYPES.SKIPPED).map((j,$)=>{const q=T.filter(X=>j.pages.some(G=>G===X.name));return d.jsxs(R.Fragment,{children:[d.jsx(S.MediumHeading,{children:q.length>0&&(j.displayName||j.name)}),q.map((X,G)=>{const V=F(X.id)||u,z=!i&&X.title&&!F(X.id);return d.jsxs(R.Fragment,{children:[z&&k(X,"s"),d.jsx(cn,{rows:X.rows,classModifiers:c,noChangeAction:V,noGroupAction:h,isGroup:F(X.id)})]},G)})]},$)})),y!==ne.TASK_CYA&&T&&T.map((x,j,$)=>{const q=!p||x.collection?x.rows:x.rows.filter(pe=>pe?.value?.props?.value);if(q.length===0)return null;const X=!i&&x.title&&!F(x.id),G=L(j)||F($[j].id)||$.length>j+1&&F($[j+1].id)?cs:g,V=F(x.id)?I(x.id):void 0,z=`govuk-!-margin-bottom-${G}`,fe=F(x.id)||u;return d.jsxs(R.Fragment,{children:[X&&k(x,"m"),V&&d.jsx("div",{className:"group-title",children:d.jsx(S.MediumHeading,{children:V.title||w.FormPage.getTitle(x.title,x.formData)})}),d.jsx(cn,{className:z,rows:q,classModifiers:c,noChangeAction:fe,noGroupAction:h,isGroup:F(x.id)})]},j)}),!l&&d.jsx(_n,{actions:s?.filter(x=>w.Component.show(x,n[n.length-1].formData)),onAction:x=>r(x)})]})},pd=lr,Ed=({page:e,pages:t,onCollectionChange:n=void 0,onAction:s,hashLink:r=!1,classBlock:o=pd,classModifiers:i=[],className:l="",submitting:a=!1})=>{const[c,u]=R.useState({});let h=w.CollectionPage.getData(e.collection.name,e.formData)||[];const f=e.collection.name.split(".").pop();let E=w.CollectionPage.getActiveIndex(e.collection.name,e.formData);const y=e,p=({target:P})=>{w.CollectionPage.setData(y.collection.name,P.value,e.formData),h=P.value;const U=e.collection.name.split(".").shift();u(g=>({...g,[U]:w.CollectionPage.getData(U,e.formData)}))},A=({target:P})=>{y.formData[P.name]=P.value,u(U=>({...U,[P.name]:P.value}))},T=P=>{p({target:{value:P}}),typeof n=="function"&&n(e.formData)},N=P=>{E=h.length,A({target:{name:`${f}ActiveId`,value:P}})},C=P=>{s(P,c,{})},b=({target:P})=>{if(E===null){const U=_t.v4();N(U),T([...h,{id:U,[P.name]:P.value}])}else T([...h.slice(0,E),{...h[E],[P.name]:P.value},...h.slice(E+1)])};return e.collection?.waitForFormData&&e.formData&&Object.keys(e.formData).length===0?null:d.jsx(In,{page:{...e,formData:{...e.formData,...h[E],[`${f}ActiveIndex`]:E,[`${f}NumberedIndex`]:typeof E=="number"?E+1:null},components:e.components.map(P=>({...P,pageCollection:{...e.collection}}))},pages:t,onAction:C,onWrapperChange:b,onTopLevelChange:A,hashLink:r,classBlock:o,classModifiers:i,className:l,submitting:a})},Ad="hods-task-list",yd=({state:e=H.TYPES.CANNOT_START_YET})=>{const t=S.Utils.classBuilder(Ad,void 0,void 0),n=H.DETAILS[e]||H.DETAILS.cannotStartYet;return d.jsx(S.Tag,{classModifiers:n.colour,className:t("tag"),children:n.label})},Td="hods-task-list",Sd=({task:e,onClick:t})=>{const n=S.Utils.classBuilder(Td,void 0,void 0),[s,r]=R.useState(e.state!==H.TYPES.CANNOT_START_YET),[o,i]=R.useState(e.state);R.useEffect(()=>{r(e.state!==H.TYPES.CANNOT_START_YET),i(e.state)},[e.state,r,i]);const l=e.displayName||e.name;return d.jsxs("li",{className:n("item"),children:[d.jsx("span",{className:n("task-name"),children:s?d.jsx(S.Link,{onClick:()=>t(e),onKeyPress:a=>{a.key==="Enter"&&t(e)},tabIndex:0,children:l}):l}),d.jsx(yd,{state:o})]})},Cd="hods-task-list",gd="Incomplete form",bd=({id:e="",refTitle:t,refNumber:n,notes:s={},incompleteTitle:r=gd,showCompletionOverview:o=!0,sections:i,fieldId:l="",onTaskAction:a,classBlock:c=Cd,classModifiers:u=[],className:h="",formData:f={},annotations:E=[],...y})=>{const p=S.Utils.classBuilder(c,u,h),A=S.Utils.cleanHtmlAttributes(y),[T,N]=i.filter(g=>!g.skipped).reduce((g,L)=>[g[0]+(L.tasks?.filter(v=>v.state===H.TYPES.COMPLETE).length??0),g[1]+(L.tasks?.filter(v=>v.state!==H.TYPES.SKIPPED).length??0)],[0,0]),C=`${e}Notes`,{title:b,text:P}=s&&s||{},U=g=>{typeof a=="function"&&a(g)};return d.jsxs("div",{...A,id:e,className:p(),children:[n&&t&&d.jsxs(d.Fragment,{children:[d.jsx("p",{className:"govuk-body govuk-!-margin-bottom-0",children:d.jsx("strong",{className:"tasklist-summary",children:`${t}`})}),d.jsx("p",{className:"govuk-body govuk-!-font-weight-regular",children:`${n}`})]}),E.length>0&&E.map(g=>d.jsxs("div",{className:p("annotation"),children:[d.jsx("p",{className:`${p("annotation-key")} govuk-body`,children:S.Utils.interpolateString(g.key,f)}),d.jsx("p",{className:`${p("annotation-value")} govuk-body`,children:S.Utils.interpolateString(g.value,f)})]},g.key)),o&&N!==T&&d.jsx("p",{className:"govuk-body govuk-!-margin-bottom-0",children:d.jsx("strong",{className:"tasklist-summary",children:r})}),o&&d.jsx("p",{className:"govuk-body govuk-!-margin-bottom-7",children:`You have completed ${T} of ${N} sections`}),b&&P&&Ie(s,f)&&d.jsxs(d.Fragment,{children:[d.jsx("p",{className:"govuk-body govuk-!-margin-bottom-0",children:d.jsx("strong",{className:"tasklist-summary",children:S.Utils.interpolateString(b,f)})}),d.jsx(S.TextArea,{id:C,fieldId:C,readOnly:!0,value:S.Utils.interpolateString(P,f)})]}),i.filter(g=>!g.skipped).map((g,L)=>d.jsxs(R.Fragment,{children:[d.jsxs("h2",{className:p("section"),children:[i.length>1?`${L+1}. `:" ",g.name]}),g.label&&d.jsx(S.Hint,{children:g.label}),d.jsx("ol",{className:p("items"),children:g.tasks.filter(v=>v.state!==H.TYPES.SKIPPED).map(v=>d.jsx(Sd,{task:v,onClick:U},`${g.name}-${v.name}`))})]},`${g.name}`))]})},Br=(e,t)=>e?.page||t,wd=(e,t,n)=>{const s=Br(e.action,e.pageId);s!==t&&n(s)},_d=(e,t,n,s=void 0)=>{const r=Br(e,t);r!==t&&n(r,s)},Id=(e,t)=>{t(e)},Te={cyaAction:wd,navigate:_d,submissionError:Id},Pd=(e,t,n,s)=>e.validate?e.checkPreexistingErrors&&s.length!==0?!1:n(t).length===0:!0,xd=(e,t)=>t(e).length===0,Od=["radios","checkboxes"],Rd=(e,t)=>{const n=e.split("."),s={};return n.forEach(r=>{s[`${r}ActiveId`]=t[`${r}ActiveId`]}),s};function Nd(e,t){const n=[];return e?.data?.options?.forEach(s=>{!Ze(t,s)&&s.nested&&s.nested.forEach(r=>{n.push(r.id)})}),n}const $r=(e,t)=>{let n=e;if(t.components.forEach(s=>{if(!Od.includes(s.type))return;Nd(s,n[s.id]).forEach(o=>{delete n[o]})}),t.collection){n={...Rd(t.collection.name,t.formData),...n};const s=Ge(t.collection.name,n);if(s){const r=Ut(t.collection.name,n),o=s.map(i=>i.id===r?$r(i,{...t,collection:void 0}):i);On(t.collection.name,o,n)}}return n},Ld=(e,t,n)=>{if(e===re.HUB&&n===ye.CYA)return{title:""};if(e===re.CYA)return{};const s=t?.find(r=>r.id===e);if(s?.type===re.PARTIAL_CYA){const r=w.FormPage.applyConditionalProperties(s);return{title:r.title,hideChangeActions:r.hideChangeActions,hideGroupActions:r.hideGroupActions}}},Yr=(e,t,n)=>{if(e)return e===re.HUB?n===ye.CYA||n===ye.TASK?void 0:n:t.find(s=>s.id===e)},Dd=(e,t,n)=>({pageId:e,cya:Ld(e,t,n),page:Yr(e,t,n)}),us=(e,t)=>e.slice(0,e.findIndex(n=>n?.id===t)),vd=(e,t,n)=>e.page?.type===re.PARTIAL_CYA?us(n||t,e.pageId):n||t,ds=(e,t,n,s,r)=>{if(!t&&r===ne.FORM_WITH_TASK){if(s?.formStatus?.taskPage){const i=n.find(l=>l.id===s.formStatus.taskPage);return i?.type==="pre-task-list"?i.id:re.HUB}return n.length>0?n[0].id:void 0}let o;return e?.pages?.forEach(i=>{it.show({show_when:i.show_when},s)&&(o=i.pageId)}),o||e?.page||re.HUB},Hr=(e,t,n)=>{let s=e.findIndex(o=>o.id===t)+1,r=e[s];for(;r&&!it.show(r,n);)s+=1,r=e[s];return r?.id||void 0},Fd=(e,t,n)=>Hr(e,t,n)||re.CYA,jd=e=>e.length>0?e[0].id:void 0,un=(e,t,n,s,r)=>{if(s){if(s.type===W.TYPES.NAVIGATE)return t.find(o=>o.id===s.page)?s.page:void 0;if(s.type===W.TYPES.SAVE_AND_RETURN)return e===ne.HUB?re.HUB:void 0}switch(e){case ne.HUB:return ds(s);case ne.CYA:return Fd(t,n,r);case ne.FORM_WITH_TASK:case ne.TASK:return ds(s,n,t,r,e);case ne.WIZARD:return Hr(t,n,r);default:return jd(t)}},Ud=(e,t,n,s,r,o,i,l)=>{if(e===ne.TASK||e===ne.FORM_WITH_TASK){const a=r.formStatus||{};return a.tasks=a.tasks||{},a.tasks[o.name]=a.tasks[o.name]||{},n===(re.CYA||"submitForm")&&i?a.tasks[o.name].complete=!0:o.name?s?.type===W.TYPES.SAVE_AND_NAVIGATE?a.tasks[o.name]={complete:!1,currentPage:un(e,t,n,s,r)}:o.pages?.includes(n)&&(a.tasks[o.name]={complete:!!s?.complete,currentPage:n}):l&&l.forEach(c=>{c.tasks.forEach(u=>{const h=u.pages[u.pages.length-1];(h===n||h.id===n)&&i&&u?.type==="pre-task-list"?a.tasks[u.name]={complete:i,currentPage:n}:u.pages.includes(n)&&u?.type==="pre-task-list"&&(a.tasks[u.name]={complete:!1,currentPage:n})})}),a.taskPage=a.tasks[o.name].currentPage,a}return s?.type===W.TYPES.SAVE_AND_RETURN?{page:n}:{page:un(e,t,n,s,r)}},Md=({complete:e,currentPage:t},n=H.TYPES.NOT_STARTED)=>e?H.TYPES.COMPLETE:t||e!==void 0&&!e&&t===void 0?H.TYPES.IN_PROGRESS:n,kd=(e,t,n=!1)=>t.reduce((s,r)=>{const o=e[r];return n&&o?.state===H.TYPES.SKIPPED?s:s&&o?.complete},!0),Vr=(e,t)=>{const n=e[t-1].state;return n===H.TYPES.COMPLETE?!0:n===H.TYPES.SKIPPED?t-1===0?!0:Vr(e,t-1):!1},Bd=(e,t,n,s,r=!1,o=!0)=>{if(s[e.name])return Md(s[e.name],e.state);if(r)return e.depends_on&&!kd(s,e.depends_on,e.ignoreSkipped)?H.TYPES.CANNOT_START_YET:H.TYPES.NOT_STARTED;let i=o;return t&&(i=Vr(n,t)),i?H.TYPES.NOT_STARTED:H.TYPES.CANNOT_START_YET},$d=(e,t,n,s)=>{const r=e.tasks.map(o=>({...o}));return r.filter(o=>o.state!==H.TYPES.SKIPPED).forEach((o,i)=>{const l=o;l.state=Bd(l,i,r,t,n,s)}),r},qr=(e,t)=>{const n=e[t-1]?.tasks.slice(-1)[0]?.state;return n===H.TYPES.COMPLETE?!0:n===H.TYPES.SKIPPED?t-1===0?!0:qr(e,t-1):!1},Yd=(e,t,n=!1,s=null)=>{const r=e.map(i=>{const l=i.show_when?[i.show_when].flat():[];return s&&!w.Condition.meetsAll(l,s)?{...i,skipped:!0,tasks:i.tasks.map(a=>({...a,state:H.TYPES.SKIPPED}))}:{...i}});r.forEach(i=>{const l=i;l.tasks=l.tasks.map(a=>{const c=a.show_when?[a.show_when].flat():[];return s&&!w.Condition.meetsAll(c,s)?{...a,state:H.TYPES.SKIPPED}:{...a}})});const o={...t};return r.forEach(i=>{i.tasks.filter(l=>l.state===H.TYPES.SKIPPED).forEach(l=>{o[l.name]={...o[l.name],state:H.TYPES.SKIPPED}})}),r.forEach((i,l)=>{const a=i,c=l===0||qr(r,l);a.tasks=$d(a,o,n,c)}),r},Hd=(e,t,n)=>{n.has(e)||n.set(e,[]),n.get(e).push(t)},ke=(e,t)=>{if(Array.isArray(e))for(let r=0;r<e.length;r+=1)ke(e[r],t);const n=t.split(".");let s=e;for(let r=0;r<n.length-1;r+=1)if(s=s[n[r]],s===void 0)return;s[n[n.length-1]]&&delete s[n[n.length-1]]},Gr=e=>{if(typeof e!="string"||!e.includes("."))return null;const t=e.split(".");return t.pop(),t.join(".")},Dn=(e,t)=>{const n=Gr(e);return n?`${n}.${t}`:t},Vd=e=>{for(let t=e.length-1;t>=0;t-=1){const n=e[t];Object.keys(n).length===1&&Object.keys(n)[0]==="id"&&e.splice(t,1)}},qd=e=>{const t=(n,s)=>(typeof n=="object"&&n!==null&&(Array.isArray(n)?n.forEach(r=>{t(r,s)}):Object.keys(n).forEach(r=>{r==="field"&&s.push(n[r]),t(n[r],s)})),s);return e.show_when?new Set(t(e.show_when,[])||[]):null},Gd=(e,t)=>{const n=e.split(".");for(let s=n.length;s>0;s-=1){const r=n.slice(0,s).join("."),o=t.get(r);if(o)return o}return null},Je=(e,t)=>e.show_when?e.show_when?.type==="or"?ae.meetsOne(e,t):ae.meetsAll(e,t):!0,Kr=(e,t,n)=>{const s=t.get(e.use)??n.get(e.use)??e,r=JSON.parse(JSON.stringify(s));return e.use&&e.show_when&&(r.show_when=e.show_when),r},Kd=(e,t,n)=>{const{meta:{documents:s}}=n,r=t[e.fieldId];if(!s||!r)return;const o=Array.isArray(r)?r:[r];for(let i=o.length-1;i>=0;i-=1){const l=s.findIndex(a=>a.url===o[i].url);l!==-1&&s.splice(l,1)}},dn=e=>{if(Array.isArray(e))for(let t=e.length-1;t>=0;t-=1)Array.isArray(e[t])&&e[t].length===0?e.splice(t,1):dn(e[t]),typeof e[t]=="object"&&Object.keys(e[t]).length===0&&e.splice(t,1);else e!==null&&typeof e=="object"&&Object.keys(e).forEach(t=>{Array.isArray(e[t])&&e[t].length===0?(e[`${t}ActiveId`]&&delete e[`${t}ActiveId`],delete e[`${t}ActiveId`],e[t]&&delete e[t]):dn(e[t])})},Wr=(e,t)=>{e?.data?.options&&e?.data?.options?.forEach(n=>{n.nested?.forEach(t)})},Wd=(e,t,n,s)=>{if(s[t]>1)s[t]-=1;else{if(n.preserveInPayload)return;ke(e,t),Wr(n,r=>{const o=Dn(t,r.fieldId);s[o]>1?s[o]-=1:ke(e,o)})}},zd=(e,t,n,s)=>{t.forEach(r=>{if(!e.has(r.fieldId)){if(r.type==="multifile"&&Kd(r,n,s),r.preserveInPayload)return;ke(n,r.fieldId),Wr(r,o=>{const i=Dn(r.fieldId,o.fieldId);e.has(i)||ke(n,i)})}})},fs=e=>Array.isArray(e)?e:[e],Jd=(e,t,n,s)=>{const r=new Map,o={},i=[],l=new Map,a=(c,u,h)=>{u.fieldId&&(h=h?`${h}.${u.fieldId}`:u.fieldId,o[h]=(o[h]||0)+1,u.path=h,c.show_when&&(u.show_when=u.show_when?[...fs(c.show_when),...fs(u.show_when)]:c.show_when),Hd(h,u,r),u.components?u.components.forEach(f=>{a(c,f,h)}):u?.data?.options&&u?.data?.options?.forEach(f=>{if(f.nested){const E=!Ze(se(s,h),f),y=f.show_when;f.nested.forEach(p=>{E&&i.push(Dn(h,p.fieldId)),y&&(p.show_when=y),a(c,p,Gr(h))})}}))};return e?.forEach(c=>{c.childPages?l.set(c.collection.name,c):c.components?.forEach(u=>{const h=Kr(u,t,n);a(c,h,null)})}),i.forEach(c=>{o[c]>1?o[c]-=1:ke(s,c)}),{allComponents:r,componentsToKeep:o,allCollections:l}},Xd=e=>{const t=new Map;return e?.forEach(n=>{n?.forEach(s=>{if(!s.fieldId)return;const r=qd(s);if(r)if(t.has(s.path)){const o=t.get(s.path);r.forEach(i=>o.add(i))}else t.set(s.path,new Set(r))})}),t},Qd=(e,t,n,s,r,o)=>{const i=(a,c,u)=>{if(a.has(c))return;a.add(c),u.get(c.path)?.forEach(f=>{const E=Gd(f,t);if(E)E.forEach(y=>{a.has(y)||i(a,y,u)});else{const y=/([a-zA-Z_$][\w$]*)\[\d+\]/,p=f.match(y);if(p){const A=p[1],T=s.get(A);T&&T.childPages?.forEach(N=>{if(N.show_when){const C=JSON.stringify(N.show_when),b=`It is not possible to reliably clean hidden data when a component is dependent on a
9
+ `+o)}}catch{}}throw s}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=De(this.defaults,n);const{transitional:s,paramsSerializer:r,headers:o}=n;s!==void 0&&At.assertOptions(s,{silentJSONParsing:he.transitional(he.boolean),forcedJSONParsing:he.transitional(he.boolean),clarifyTimeoutError:he.transitional(he.boolean),legacyInterceptorReqResOrdering:he.transitional(he.boolean),advertiseZstdAcceptEncoding:he.transitional(he.boolean)},!1),r!=null&&(m.isFunction(r)?n.paramsSerializer={serialize:r}:At.assertOptions(r,{encode:he.function,serialize:he.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),At.assertOptions(n,{baseUrl:he.spelling("baseURL"),withXsrfToken:he.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=o&&m.merge(o.common,o[n.method]);o&&m.forEach(["delete","get","head","post","put","patch","query","common"],y=>{delete o[y]}),n.headers=ue.concat(i,o);const l=[];let a=!0;this.interceptors.request.forEach(function(p){if(typeof p.runWhen=="function"&&p.runWhen(n)===!1)return;a=a&&p.synchronous;const A=n.transitional||An;A&&A.legacyInterceptorReqResOrdering?l.unshift(p.fulfilled,p.rejected):l.push(p.fulfilled,p.rejected)});const c=[];this.interceptors.response.forEach(function(p){c.push(p.fulfilled,p.rejected)});let u,h=0,f;if(!a){const y=[Qn.bind(this),void 0];for(y.unshift(...l),y.push(...c),f=y.length,u=Promise.resolve(n);h<f;)u=u.then(y[h++],y[h++]);return u}f=l.length;let E=n;for(;h<f;){const y=l[h++],p=l[h++];try{E=y(E)}catch(A){p.call(this,A);break}}try{u=Qn.call(this,E)}catch(y){return Promise.reject(y)}for(h=0,f=c.length;h<f;)u=u.then(c[h++],c[h++]);return u}getUri(t){t=De(this.defaults,t);const n=Js(t.baseURL,t.url,t.allowAbsoluteUrls);return Gs(n,t.params,t.paramsSerializer)}};m.forEach(["delete","get","head","options"],function(t){Re.prototype[t]=function(n,s){return this.request(De(s||{},{method:t,url:n,data:(s||{}).data}))}});m.forEach(["post","put","patch","query"],function(t){function n(s){return function(o,i,l){return this.request(De(l||{},{method:t,headers:s?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}Re.prototype[t]=n(),t!=="query"&&(Re.prototype[t+"Form"]=n(!0))});let ha=class er{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(o){n=o});const s=this;this.promise.then(r=>{if(!s._listeners)return;let o=s._listeners.length;for(;o-- >0;)s._listeners[o](r);s._listeners=null}),this.promise.then=r=>{let o;const i=new Promise(l=>{s.subscribe(l),o=l}).then(r);return i.cancel=function(){s.unsubscribe(o)},i},t(function(o,i,l){s.reason||(s.reason=new rt(o,i,l),n(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=s=>{t.abort(s)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new er(function(r){t=r}),cancel:t}}};function ma(e){return function(n){return e.apply(null,n)}}function pa(e){return m.isObject(e)&&e.isAxiosError===!0}const sn={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(sn).forEach(([e,t])=>{sn[t]=e});function tr(e){const t=new Re(e),n=vs(Re.prototype.request,t);return m.extend(n,Re.prototype,t,{allOwnKeys:!0}),m.extend(n,t,null,{allOwnKeys:!0}),n.create=function(r){return tr(De(e,r))},n}const Z=tr(st);Z.Axios=Re;Z.CanceledError=rt;Z.CancelToken=ha;Z.isCancel=Ws;Z.VERSION=Tn;Z.toFormData=Rt;Z.AxiosError=D;Z.Cancel=Z.CanceledError;Z.all=function(t){return Promise.all(t)};Z.spread=ma;Z.isAxiosError=pa;Z.mergeConfig=De;Z.AxiosHeaders=ue;Z.formToJSON=e=>Ks(m.isHTMLForm(e)?new FormData(e):e);Z.getAdapter=Zs.getAdapter;Z.HttpStatusCode=sn;Z.default=Z;const{Axios:af,AxiosError:cf,CanceledError:uf,isCancel:df,CancelToken:ff,VERSION:hf,all:mf,Cancel:pf,isAxiosError:Ef,spread:Af,toFormData:yf,AxiosHeaders:Tf,HttpStatusCode:Sf,formToJSON:Cf,getAdapter:gf,mergeConfig:bf,create:wf}=Z,ce={onAction:(e,t)=>({formData:e,patch:t}),onChange:e=>{},onFormComplete:()=>{},onFormLoad:e=>{},onGetComponent:(e,t)=>null,onGetCYA:e=>null,onGetCYARows:(e,t,n)=>null,onGoingBack:()=>{},onPageChange:(e,t)=>e,onRequest:e=>e,onSubmit:(e,t,n,s)=>{typeof n=="function"&&n()},onValidate:(e,t)=>t,onCancel:e=>{}},es=Object.keys(ce),nr=R.createContext(),sr=({overrides:e={onAction:void 0,onCancel:void 0,onChange:void 0,onFormComplete:void 0,onFormLoad:void 0,onGetComponent:void 0,onGetCYA:void 0,onGetCYARows:void 0,onGoingBack:void 0,onPageChange:void 0,onRequest:void 0,onSubmit:void 0,onValidate:void 0},children:t=null})=>{const[n,s]=R.useState({onAction:e?.onAction||ce.onAction,onChange:e?.onChange||ce.onChange,onFormComplete:e?.onFormComplete||ce.onFormComplete,onFormLoad:e?.onFormLoad||ce.onFormLoad,onGetComponent:e?.onGetComponent||ce.onGetComponent,onGetCYA:e?.onGetCYA||ce.onGetCYA,onGetCYARows:e?.onGetCYARows||ce.onGetCYARows,onGoingBack:e?.onGoingBack||ce.onGoingBack,onPageChange:e?.onPageChange||ce.onPageChange,onRequest:e?.onRequest||ce.onRequest,onSubmit:e?.onSubmit||ce.onSubmit,onValidate:e?.onValidate||ce.onValidate,onCancel:e?.onCancel||ce.onCancel}),r=(i,l)=>{es.includes(i)&&s(a=>({...a,[i]:l||ce[i]}))},o=i=>{es.includes(i)&&s(l=>({...l,[i]:ce[i]}))};return d.jsx(nr.Provider,{value:{hooks:n,addHook:r,removeHook:o},children:t})},Pe=()=>R.useContext(nr),Ea=()=>{const{hooks:e}=Pe(),[t,n]=R.useState({});return R.useEffect(()=>{const s=Z.create({baseURL:"/"});return s.interceptors.request.use(e.onRequest),s.interceptors.response.use(r=>r,async r=>Promise.reject(r)),n({instance:s}),()=>{n({})}},[e]),t.instance},Cn=R.createContext(),rr=({children:e=null})=>{const{hooks:t}=Pe(),[n,s]=R.useState([]),[r,o]=R.useState([]),i=f=>{f!==void 0&&o(E=>[...E,...f].filter(y=>!!y))},l=f=>{typeof f=="function"&&o(E=>E.filter(y=>!f(y)))},a=()=>{r.length&&o([])},c=f=>{f!==void 0&&s(E=>[...E,...f].filter(y=>!!y))},u=()=>{o([]),s([])},h={page:f=>{const E=w.Validate.page(f,r),y=t.onValidate(f,E);return s(y),y},pages:f=>{const E=f.map(p=>w.Validate.page(p,r)),y=f.flatMap((p,A)=>t.onValidate(p,E[A]));return s(y),y}};return d.jsx(Cn.Provider,{value:{errors:n,addErrors:c,clearErrors:u,queuedErrors:r,enqueueErrors:i,dequeueErrors:l,clearQueuedErrors:a,validate:h},children:e})},He=()=>R.useContext(Cn),Yt={},Ht={},Aa="idle",ya="fetching",or="fetched",ir="error",Ta=(e,t=!0)=>{const n=Ea(),s=R.useRef(Z.CancelToken.source()),[r,o]=R.useState(Aa),[i,l]=R.useState(null),[a,c]=R.useState(null),u=()=>{s.current&&s.current.cancel()};return R.useEffect(()=>{if(!e||!n)return;(async()=>{try{l(null),o(ya);let f;if(t&&Yt[e])f=Yt[e];else{if(t&&Ht[e])throw Ht[e];f=(await n.get(e,{cancelToken:s.current.token}).catch(y=>{throw l(y),y})).data,t&&(Yt[e]=f)}c(f),o(or)}catch(f){t&&(Ht[e]=f),l(f),c(null),o(ir)}})()},[n,e,t]),{status:r,error:i,data:a,cancelRequests:u}},Sa="loading",yt="complete",Ca=e=>{const t=e.data;if(t&&!t.options||t?.url)return S.Utils.interpolateString(t.url,e.formData)},ga=(e,t)=>{const n=Ca({...e,formData:t}),{status:s,data:r}=Ta(n,e?.data?.useCache),[o,i]=R.useState([]),[l,a]=R.useState(Sa);return R.useEffect(()=>{n?s===or?(r&&i(de.refData.toOptions(r.data||r,e.item)),a(yt)):s===ir&&(i([]),a(yt)):(e.data&&e.data.options&&i(de.refData.toOptions(e.data.options,e.item)),a(yt))},[e.id,s,r,n]),{data:o,status:l}},Xe=(e,t)=>{const n=te(e,["fieldId","displayMenu","showCharacterCount","readonly"]);return d.jsx(S.FormGroup,{...n,onChange:null,children:t})},gn=(e,t,n,s,r={})=>{if(!t)return[];const o=w.CollectionPage.getData(t.collection.name,t.formData)||[];let i=[];return o.forEach(l=>{r={...r,[`${t.collection.name.split(".").pop()}ActiveId`]:l.id};const a=t.childPages?.flatMap(c=>{const u={...c,formData:{...n,...r}};if(c.childPages)return gn(e,u,n,s,r);const h=w.Validate.page(u);return s.onValidate(u,h)});i=i.concat(a.map(c=>({...c,entryId:l.id,showFor:e.id,raisedBy:e.id})))}),i},bn=({value:e,component:t,formData:n,placeholder:s})=>e?t?d.jsx(Ve,{component:{...t,readonly:!0},wrap:!1,value:e,formData:n}):Object.prototype.hasOwnProperty.call(e,"label")?e.label:e:(Object.prototype.hasOwnProperty.call(t||{},"cyaPlaceholder")?t?.cyaPlaceholder:s)||d.jsx(S.VisuallyHidden,{children:"No answer"}),ba="Continue",rn=({action:e,onAction:t,...n})=>{const s=typeof e=="string"?W.DEFAULTS[e]:e,r=W.DEFAULTS[e.type];return s?d.jsx(S.Button,{...n,className:s.className,classModifiers:s.classModifiers,start:s.start||!1,name:s.label,onClick:s.disabled?()=>{}:()=>t(s),children:s.label||r?.label||ba}):null},wa="hods-form-confirmation",_a="Are you sure?",Ia="Confirm",Pa=({id:e,message:t,confirmLabel:n,children:s,onConfirm:r,onCancel:o,classModifiers:i=[]})=>{const l=S.Utils.classBuilder(wa,i,"");return d.jsxs("div",{id:e,className:l(),role:"alert",children:[d.jsx("h2",{children:t||_a}),s,d.jsx(S.Button,{classModifiers:"warning",onClick:r,autoFocus:!0,children:n||Ia}),d.jsx(S.Button,{classModifiers:"secondary",onClick:o,children:"Cancel"})]})},wn=e=>e&&Array.isArray(e.components)?e.components.flatMap(t=>t.type===_.CONTAINER?wn(t):ot.editable(t)?t:null).filter(t=>!!t):[],xa=e=>{const t=e.full_path||e.fieldId;return e.components.map(n=>{const s=t?`${t}.${n.fieldId}`:n.fieldId,r={...n,full_path:s};return n.type===_.CONTAINER?on(r):(n.type===_.RADIOS&&r.data?.options?.forEach((o,i)=>{o.nested?.forEach((l,a)=>{l.type===_.CONTAINER&&(r.data.options[i].nested[a]=on(l))})}),r)})},on=e=>{if(e){const t=xa(e);return{...e,components:t}}return e},Oa=(e,t)=>e.some(n=>ot.show(n,t)),Ra=(e,t)=>{if(!e)return!1;if(e.show_when)return e.show_when.type==="or"?ae.meetsOne(e,t):ae.meetsAll(e,t);const n=wn(e);return n.length>0?Oa(n,t):!0},Lt={editableComponents:wn,setup:on,show:Ra},Na=(e,t)=>e.some(n=>Ie(n,t)),Dt=(e,t)=>{if(!e)return!1;if(e.show_when)return e.show_when.type==="or"?ae.meetsOne(e,t):ae.meetsAll(e,t);const n=Lt.editableComponents(e);return n.length>0?Na(n,t):!0},La=(e,t,n)=>{if(!e)return null;const s=[];e.childPages.forEach(l=>{!l.summaryQuickEdit||!Dt(l,{...t,...n})||l.summaryQuickEdit.forEach(a=>{if(typeof a=="string"){s.push({...l.components.find(h=>h.id===a)});return}const c=l.components.find(h=>h.id===a.use);if(!c)return;const u={...c,...a};if(a.show_when){Ue(a.show_when,{...t,...n})&&s.push({...u,show_when:c.show_when||[]});return}s.push(u)})});const r={...e.childPages[0],formData:t};r.components=s,r.actions=[{type:"save",label:"Save",validate:!0,classModifiers:"primary"},{type:"cancel",label:"Cancel",classModifiers:"secondary"}];const{id:o,...i}=n;return r.formData={...r.formData,...i,[`${e.collection?.name?.split(".").pop()}ActiveId`]:n.id},delete r.title,delete r.collection,r},_n=({actions:e,onAction:t})=>!e||e.length===0?null:d.jsx(S.ButtonGroup,{children:e.map((n,s)=>d.jsx(rn,{action:n,onAction:t},s))}),Da=e=>{if(!e?.customValidation)return!1;const t=e?.customValidation.find(n=>n.runWhen?.onLoad===!0);return t&&t.runWhen?.constraint?ae.meetsOne(t.runWhen?.constraint,e.formData):!1},lr="hods-form__page",In=({page:e,pages:t=[],onAction:n,onWrapperChange:s=void 0,onTopLevelChange:r=void 0,onChange:o=void 0,hashLink:i=!1,classBlock:l=lr,classModifiers:a=[],className:c="",submitting:u=!1,pageId:h})=>{const[f,E]=R.useState({}),{errors:y,validate:p}=He(),[A,T]=R.useState({}),[N,C]=R.useState(!1),b=R.useMemo(()=>Da(e),[e]);R.useEffect(()=>{C(!0)},[]),R.useEffect(()=>{N&&b&&p.page(e)},[h,N]);const I=({target:P})=>{const k=e,{value:O}=P;O?(k.formData[P.name]=O,E(x=>({...x,[P.name]:O})),T(x=>({...x,[P.component]:P.label}))):(delete k.formData[P.name],E(x=>{const{[P.name]:j,...$}=x;return $}),T(x=>{const{[P.component]:j,...$}=x;return $})),typeof o=="function"&&o(e.formData)};R.useEffect(()=>{const P=document.title.replace("Error: ","");document.title=y.length>0?"Error: "+P:P},[y]);const U=w.classBuilder(l,a,c),g=e;g.actions=g.actions?.map(P=>P.label?{...P,label:w.interpolateString(P.label,g.formData)}:P),g.formData=w.Operate.runPageOperations(g,{...g.formData,...f},s||I);const L=e.title?d.jsx(S.Heading,{size:e.titleSize,children:w.FormPage.getTitle(e.title,e.formData)}):d.jsx(S.Label,{id:e.id,required:e.required,hideOptionalSuffix:e.hideOptionalSuffix,children:e.label}),v=e.components.filter(P=>w.Component.show(P,e.formData)).map((P,k)=>d.jsx(Ve,{component:P,onAction:O=>n(O,f,A),onChange:s||I,onTopLevelChange:r||I,value:e.formData[P.fieldId]||f[P.fieldId],formData:e.formData,pages:t,submitting:u},k));let F=null;return b&&y?.length>0?F=[{error:e?.customValidation?.[0]?.message}]:y?.length>0&&!b&&(F=y),d.jsxs("div",{className:U(),children:[F&&d.jsx(S.ErrorSummary,{errors:F,hashLink:i}),e.fieldset&&d.jsxs("fieldset",{className:"govuk-fieldset",children:[d.jsx("legend",{className:"govuk-fieldset__legend",children:L}),v]}),!e.fieldset&&d.jsxs(d.Fragment,{children:[L,v]}),d.jsx(_n,{actions:e.actions?.filter(P=>w.Component.show(P,e.formData)),onAction:P=>n(P,f,A)})]},e.id)},ts="hods-form-banner-strip",ar=({id:e,banners:t=[],formData:n,classModifiers:s})=>{const r=w.classBuilder(ts,s,""),o=t.filter(i=>w.Component.show(i,n));return d.jsx("div",{id:e,className:r(),children:o.map((i,l)=>{const a=`${e}-banner-${l}`;if(typeof i=="string"||i.type==="plain"){const c=typeof i=="string"?i:i.text;return d.jsx("div",{id:a,className:r("banner"),children:d.jsx(S.Markup,{content:w.interpolateString(c,n)})},a)}return d.jsx(S.Tag,{classBlock:`${ts}__tag`,classModifiers:i.classModifiers,text:w.interpolateString(i.text,n)},a)})})},va=e=>{if(e&&e.action){if(typeof e.action.onAction=="function")return{onClick:()=>e.action.onAction(e),onKeyPress:t=>{t.key==="Enter"&&e.action.onAction(e)},tabIndex:"0"};if(e.action.page)return{href:`/${e.action.page}`}}return{}},Pn=({row:e})=>{const[t,n]=R.useState({});return R.useEffect(()=>{n(va(e))},[e,n]),e.action?d.jsxs(S.Link,{...t,children:[e.action.label,e.action.aria_suffix&&d.jsxs(S.VisuallyHidden,{children:[" ",e.action.aria_suffix]})]}):null},cr=({row:e,classes:t,showAction:n=!1})=>d.jsxs("dl",{className:t("row"),role:"listitem",children:[d.jsxs("dt",{className:t("key"),children:[e.key,!e.required&&" (optional)"]}),d.jsx("dd",{className:t("value"),children:e.value}),n&&d.jsx("dd",{className:t("actions"),children:e.action&&d.jsx(Pn,{row:e})})]}),ur=({title:e,classes:t})=>d.jsx("div",{className:`${t("row")} ${t("title")}`,role:"listitem",children:d.jsx(S.SmallHeading,{children:e})}),Tt=(e,t,n,s,r)=>{const o={...e,formData:{...e.formData,...s}},i=jt(o,t);return t.type==="title"?d.jsx(ur,{title:t.key,classes:n}):d.jsx(cr,{row:{key:i.key,value:d.jsx(bn,{value:i.value||t.value,component:i.component,formData:o.formData,placeholder:r}),required:i.required},classes:n},`${i.fieldId}`)},Fa="govuk-summary-card",ja="govuk-summary-list",ft="Item",ht="Change",ns="Delete",Ua="warning",Ma=({id:e,entryData:t,config:n,onFullEdit:s,onDelete:r,masterPage:o,classModifiers:i=null,optionalFieldPlaceholder:l=null})=>{const a=S.Utils.classBuilder(Fa,i,n.className),c=S.Utils.classBuilder(ja,[]);return d.jsxs("div",{className:a(),id:e,children:[d.jsxs("div",{className:a("title-wrapper",[],"dark"),children:[d.jsxs("div",{className:a("title-content"),children:[d.jsx("h2",{className:a("title"),children:S.Utils.interpolateString(n.title||ft,{...t,index:t.index+1})}),n.banners&&d.jsx(ar,{id:`BannerStrip${t.id}`,banners:n.banners,formData:t})]}),d.jsxs("ul",{className:a("actions"),children:[d.jsx("li",{className:a("action"),children:n.changeAction&&typeof s=="function"&&n.changeAction.classModifiers?d.jsx(S.Button,{id:`${e}.changeButton`,onClick:()=>s(n.changeAction.page,t.id),classModifiers:n.changeAction.classModifiers,"aria-label":S.Utils.interpolateString(`${n.changeAction?.label||ht} ${n.title||ft}`,{...t,index:t.index+1}),children:n.changeAction?.label||ht}):d.jsx("button",{type:"button",className:"govuk-link govuk-link-button",onClick:()=>s(n.changeAction.page,t.id),"aria-label":S.Utils.interpolateString(`${n.changeAction?.label||ht} ${n.title||ft}`,{...t,index:t.index+1}),children:n.changeAction?.label||ht})}),d.jsx("li",{className:a("action"),children:n.deleteAction&&typeof r=="function"&&d.jsx(S.Button,{id:`${e}.deleteButton`,onClick:()=>r(t),classModifiers:n.deleteAction.classModifiers||Ua,"aria-label":S.Utils.interpolateString(`${n.deleteAction?.label||ns} ${n.title||ft}`,{...t,index:t.index+1}),children:n.deleteAction.label||ns})})]})]}),d.jsx("div",{className:a("content"),children:d.jsx("dl",{className:c(),role:"list",children:o?.childPages?.flatMap(u=>{const h=u.components.map(f=>w.Component.elevateNested([f],t)).flat().filter(Boolean);return u.summaryLayout?.sections?.flatMap(f=>{const y=f.columns.filter(p=>ae.meetsAll(p,{...u.formData,...t})).flatMap(p=>p.fields||[]);return y.length?y.flatMap(p=>{const A=h.find(T=>T.fieldId===p);return A?Tt(u,A,c,t,l):null}):null})})})})]})},ka=({id:e,"data-testid":t,actions:n,onFullEdit:s=null,entryData:r,formData:o,name:i,autoFocus:l})=>Array.isArray(n)?d.jsx(d.Fragment,{children:n.filter(a=>w.Component.show(a,o)).map(a=>d.jsx(S.Button,{id:e,"data-testid":t,onClick:()=>s(a?.page,r.id),classModifiers:a?.classModifiers||rs,"aria-label":w.FormPage.getConditionalText(a?.aria_label,r),name:i,autoFocus:l,children:a?.label||ss},e))}):d.jsx(S.Button,{id:e,"data-testid":t,onClick:()=>s(n?.page,r.id),classModifiers:n?.classModifiers||rs,"aria-label":w.FormPage.getConditionalText(n?.aria_label,r),name:i,autoFocus:l,children:n?.label||ss}),Ba=e=>{if(e.page)return e.page;const t=e.href||e.url;if(t)return t.split("/").pop()},vt=(e,t,n)=>{const s=t?.cya_link;return e!==!0&&s?{page:Ba(s)||t.id||"#",label:s.label||"Change",aria_suffix:s.aria_suffix,onAction:n}:null},dr=[_.ALERT,_.COLLECTION_SUMMARY,_.DETAILS,_.HEADING,_.HTML,_.INSET_TEXT],Ct=(e,t)=>{if(!e||dr.includes(e.type)||Object.prototype.hasOwnProperty.call(e,"show_on_cya")&&!e.show_on_cya)return!1;if(e.hideOnCyaWhenEmpty)if(e.type===_.COLLECTION){if(!se(t,e.full_path||e.fieldId)?.length)return!1}else{const n=se(t,e.fieldId);if(!n&&n!==!1&&n!==0)return!1}return e.type===_.CONTAINER?Lt.show(e,t):ot.show(e,t)},fr=e=>({...e,components:e.components.map(t=>Array.isArray(t.components)?{...t,components:t.components.map(n=>dr.includes(n.type)?null:{...n,...!n.full_path&&{full_path:`${t.full_path||`${e.full_path}.${t.fieldId}`}.${n.fieldId}`}}).filter(n=>!!n)}:{...t,...!t.full_path&&{full_path:`${e.full_path||e.fieldId}.${t.fieldId}`}})}),$a=(e,t)=>[{pageId:e.id,key:e.components[0].labels?.empty||"Nothing entered",required:e.required,action:vt(!1,e,t)}],Ya=(e,t,n,s)=>({id:t.id,fieldId:t.id,type:_.CONTAINER,required:e.required,full_path:s,components:e.item.map(r=>({...r,label:S.Utils.interpolateString(r.label,{...t,index:n}),full_path:`${s}.${r.fieldId}`}))}),Ha=(e,t,n,s,r)=>{const o={...$e,...e.labels};return o.item?{pageId:n,fieldId:e.fieldId,full_path:r,key:S.Utils.interpolateString(o.item,{...t,index:s}),type:"title",action:null}:null},xn=(e,t,n,s,r)=>Array.isArray(n)&&n.length&&Ct(t,e.formData)?n.flatMap((o,i)=>{const l=(t.countOffset||0)+i+1,a=`${t.full_path||t.fieldId}[${i}]`;let c=Ya(t,o,l,a);return c=fr(c),[Ha(t,o,e.id,l,a),...qe(e,c,o,s,r)??[]]}).filter(o=>!!o):$a(e,s),Va="hods-form-summary-card-details",hr=({masterPage:e,childCollections:t=[],formData:n,entryData:s,classModifiers:r,hideChildSectionTitles:o=!1,optionalFieldPlaceholder:i})=>{const l=w.classBuilder(Va,r),a=R.useMemo(()=>t.map(u=>e.childPages.find(h=>h.collection?.name===u)).filter(u=>!!u),[e,t]),c=(u,h,f)=>{let E=0;return u.flatMap((y,p)=>{let A=0;const T=y.fields?.flatMap(C=>h.filter(I=>I.fieldId===C).map(I=>{if(!I||!Ie(I,{...f.formData,...s}))return null;if(I.type===_.CONTAINER){const U=qe(f,I,s);return A+=1,d.jsx("div",{className:l("field"),style:{"--column":E+1,"--row":A},role:"list",children:U.map(g=>{const L={...s,[g.fieldId]:s[I.fieldId]?.[g.fieldId]};return Tt(f,{...g,label:g.key},l,L,i)})},C)}if(I.type===_.COLLECTION){const U=xn({...f,formData:{...f.formData,...s}},I,s[I.id]);A+=1;let g=0;return d.jsx("div",{className:l("field"),style:{"--column":E+1,"--row":A},role:"list",children:U.map(L=>{const v={...s,[L.fieldId]:s[I.fieldId]?.[L.fieldId]},F=Tt(f,{...L,label:L.key},l,v,i);return L.type==="title"&&(g+=1,g>1)?d.jsx("div",{style:{marginTop:"40px"},children:F}):F})},C)}return A+=1,d.jsx("div",{className:l("field"),style:{"--column":E+1,"--row":A},role:"list",children:Tt(f,I,l,s,i)},C)})).filter(C=>!!C);return!(p===u.length-1)&&T.length!==0?(E+=2,[...T,d.jsx("div",{className:l("divider"),style:{"--column":E}},`divider${E}`)]):T}).filter(y=>!!y)};return e?.childPages?.filter(u=>w.FormPage.show(u,{...n,...s})).map(u=>{const h=w.Component.elevateNested(u?.components,s);return u.summaryLayout?.sections.map(f=>{if(f.show_when&&!w.Condition.meetsAll(f.show_when,{...n,...s}))return null;if(f.type==="childCollection"){const y=a.find(A=>A.collection.name===f.collectionName),p=s[f.collectionName.split(".").pop()]||[];return y&&p.length>0?d.jsxs(d.Fragment,{children:[d.jsx("h3",{className:l("section-title"),children:f.title}),p.map(A=>d.jsx(hr,{masterPage:y,childMasterPages:[],formData:{...n,...s,...A},entryData:A,hideChildSectionTitles:!0,optionalFieldPlaceholder:i}))]}):null}const E=f.columns.filter(y=>ae.meetsAll(y,{...u.formData,...s}));return d.jsxs("div",{className:l("section"),children:[!o&&d.jsx("h3",{className:l("section-title"),children:w.FormPage.getConditionalText(f.title,{...u.formData,...s})}),d.jsx("dl",{className:l("section-content"),style:{"--dividers":E.length-1},children:c(E,h,u)})]},f.title)})}).filter(u=>!!u)||null},qa="hods-form-summary-card",ss="Change",Ga="Delete",Ka="Quick Edit",Wa="Duplicate",za="Full details",rs="secondary",os=({id:e,entryData:t,config:n,classModifiers:s,onFullEdit:r,onDelete:o,onDuplicate:i,onQuickEdit:l,parentCollectionName:a,childCollections:c=[],formData:u,masterPage:h,hideDetails:f=!1})=>{const[E,y]=R.useState(!1),p=S.Utils.classBuilder(qa,s,n.className),A=R.useMemo(()=>n.quickEdit?La(h,u,t):null,[h,n,u,t,E]),{addErrors:T,resetQuickEditErrors:N,clearTopLevelErrorsForCard:C,validate:b}=He(),{hooks:I}=Pe(),U=async(g,L)=>{if(g.type==="cancel"&&(y(v=>!v),N?.()),g.type==="save"&&typeof l=="function"){const v={...A.formData,...L,[`${a}ActiveId`]:t.id},F=b.page({...A,formData:v});if(F.length)return;let P;await I.onSubmit("quickEdit",v,()=>{},O=>{P=O}),P&&T(P);const k=F.concat(P);if(k.length===0||k.length===1&&k[0]===void 0){C();const O=w.CollectionPage.getData(a,u),{isDuplicate:x,...j}=O[t.index];O[t.index]={...j,...L},l({target:{name:a,value:O}}),y($=>!$)}}};return n.listView?d.jsx(Ma,{id:e,entryData:t,config:n,onFullEdit:r,onDelete:o,masterPage:h,classModifiers:s,optionalFieldPlaceholder:n.fullDetails?.optionalFieldPlaceholder}):d.jsxs("div",{className:p(),id:e,children:[d.jsxs("div",{className:p("header"),children:[d.jsxs("div",{className:p("header-content"),children:[n.banners&&d.jsx(ar,{id:`BannerStrip${t.id}`,banners:n.banners,formData:t}),d.jsx("h2",{id:`${e}.titleText`,className:p("header-content-title"),children:w.FormPage.getTitle(n.title,t)}),n.details&&d.jsx("div",{id:`${e}.titleDetail`,className:p("header-content-detail"),children:w.FormPage.getConditionalText(n.details,t)})]}),d.jsxs("div",{className:p("header-actions"),children:[n.quickEdit&&d.jsx(S.Button,{"data-testid":"quickedit-button",id:`${e}.quickEditButton`,onClick:()=>y(g=>!g),classModifiers:"primary",disabled:E,name:"QuickEdit",autoFocus:n.focusOn,children:Ka}),n.changeAction&&typeof r=="function"&&d.jsx(ka,{id:`${e}.changeButton`,"data-testid":"change-button",actions:n.changeAction,onFullEdit:r,entryData:t,formData:u,name:"Change",autoFocus:n.focusOn}),n.deleteAction&&typeof o=="function"&&d.jsx(S.Button,{id:`${e}.deleteButton`,onClick:()=>o(t),classModifiers:"secondary","aria-label":w.FormPage.getConditionalText(n.deleteAction?.aria_label,t),name:"Delete",children:n.deleteAction?.label||Ga}),n.duplicateAction&&typeof i=="function"&&d.jsx(S.Button,{"data-testid":"duplicate-button",id:`${e}.duplicateButton`,onClick:()=>{i(t)},classModifiers:"secondary","aria-label":w.FormPage.getConditionalText(n.duplicateAction?.aria_label,t),name:"Duplicate",autoFocus:n.focusOn,children:n.duplicateAction?.label||Wa})]})]}),E&&A&&d.jsx(In,{page:A,onAction:(g,L)=>U(g,L),className:p("editpage")}),d.jsx("div",{className:p("body"),children:!f&&d.jsx(S.Details,{summary:n.detailsTitle||za,className:"details",children:d.jsx(hr,{masterPage:h,childCollections:c,formData:u,entryData:t,optionalFieldPlaceholder:n.fullDetails?.optionalFieldPlaceholder})})})]})},Ja=({entryId:e,topLevelErrors:t=[],clearTopLevelErrorsForCard:n,children:s})=>{const{hooks:r}=Pe(),o=t.filter(h=>h.entryId===e)||[],[i,l]=R.useState(null),a=()=>{l(null)},c=h=>{l(f=>(f??[]).concat(h))},u={page:h=>{const f=w.Validate.page(h),E=r.onValidate(h,f);return l(E),E}};return d.jsx(Cn.Provider,{value:{addErrors:c,errors:i===null?[...o]:i,resetQuickEditErrors:a,clearTopLevelErrorsForCard:n,validate:u},children:s})},is="Add",Xa=({config:e,formData:t,onAction:n,onChange:s,onTopLevelChange:r,pages:o=[]})=>{const{hooks:i}=Pe(),{errors:l,addErrors:a,clearErrors:c,queuedErrors:u,enqueueErrors:h,dequeueErrors:f}=He(),[E,y]=R.useState(null),p=R.useMemo(()=>w.CollectionPage.getData(e.collectionName,t)||[],[t]),A=Array.isArray(p)&&p.length>0?p.reduce((L,v)=>v.isDuplicate&&(!L||v.id>L.id)?v:L,null):null,T=R.useMemo(()=>{const L=e.collectionName.split(".");let v=w.CollectionPage.mergePages(o||[])||[];return L.reduce((F,P,k)=>{const O=k===0?`${F}${P}`:`${F}.${P}`;return k===L.length-1?v?.find(x=>x.collection?.name===O)||null:(v=v.find(x=>x.collection?.name===O)?.childPages||null,O)},"")},[o]),N=R.useMemo(()=>e.card.listView?T.childPages?.reduce((v,F)=>{const P=et(F.components,{...t,...E});return v.concat(P)},[])||[]:[],[T,t,E,e.card.listView]),C=()=>{u.length>0&&f(v=>v.raisedBy===e.id);const L=gn(e,T,t,i);L.length>0&&h(L)};R.useEffect(()=>{Array.isArray(p)&&p.length>0&&C()},[p]);const b=(L,v)=>{if(typeof n=="function"){const F=[...p],P=p.findIndex(x=>x.id===v),{isDuplicate:k,...O}=p[P];F[P]={...O},n({type:mt.SAVE_AND_NAVIGATE,page:L,addToFormData:[{field:`${e.collectionName.split(".").pop()}ActiveId`,value:v},{field:e.collectionName,value:F,isCollection:!0}]})}},I=L=>{w.CollectionPage.duplicateEntry(e.collectionName,t,L.id,e.card?.duplicateAction?.fieldsToIgnore||[],{isDuplicate:!0});const v=e.collectionName.split(".").shift();typeof r=="function"&&(r({target:{name:v,value:w.CollectionPage.getData(v,t)}}),C())},U=()=>{if(!E)return;w.CollectionPage.removeEntry(e.collectionName,t,E.id);const L=e.collectionName.split(".").shift();typeof r=="function"&&r({target:{name:L,value:w.CollectionPage.getData(L,t)}}),y(null),C()},g=L=>{const v=N.find(P=>P.fieldId===L);if(!v)return null;const F=jt({...T,formData:{...t,...E}},v);return d.jsx("div",{className:"confirmation-field-value",children:d.jsx(bn,{value:F.value,component:F.component,formData:F.formData})},L)};return d.jsxs("div",{id:e.fieldId,children:[E&&d.jsx(Pa,{id:`${e.fieldId}.confirmation`,message:w.interpolateString(e.confirmation?.message,{...E,index:E.index+1})||null,confirmLabel:w.interpolateString(e.confirmation?.label,E)||null,onConfirm:U,onCancel:()=>y(null),children:e.card.listView?d.jsx("div",{className:"confirmation-content",children:e.confirmation?.displayFields.map(g)}):d.jsx(os,{id:`${e.fieldId}.confirmationChild`,entryData:E,config:e.card?{...e.card,quickEdit:null}:{},masterPage:T,classModifiers:"nested",hideDetails:!0})}),!e.card.listView&&e.addButton&&d.jsx(rn,{id:`${e.fieldId}.addButton`,action:{collection:e.collectionName,label:w.interpolateString(e.addButton.label||is,{documents:p}),page:e.addButton.page,type:mt.COLLECTION_ADD,classModifiers:["secondary"]},onAction:n}),d.jsx("ul",{className:"collection-summary-card-list",children:p.map((L,v)=>{const F=l.filter(O=>O.entryId===L.id).length>0,P={...e.card,...L.isDuplicate&&e.duplicatedCard?e.duplicatedCard:{},...F&&e.errorCard?e.errorCard:{},focusOn:A?.id===L.id},k=`${e.fieldId}.summaryCard${L.id}`;return d.jsx("li",{children:d.jsx(Ja,{entryId:L.id,topLevelErrors:l,clearTopLevelErrorsForCard:()=>{const O=l.filter(x=>x.entryId!==L.id);c(),a(O)},children:d.jsx(os,{id:k,entryData:{...L,index:v},masterPage:T,config:P||{},onFullEdit:b,onDuplicate:I,onDelete:()=>y({...L,index:v}),onQuickEdit:O=>(C(),s(O)),parentCollectionName:e.collectionName.split(".").shift(),childCollections:e.childCollections||[],formData:t,classModifiers:L.id===E?.id?["deleting-summary-card"]:[""],inError:l.filter(O=>O.entryId===L.id).length>0},k)})})})}),e.card.listView&&e.addButton&&d.jsx(rn,{id:`${e.fieldId}.addButton`,action:{collection:e.collectionName,label:w.interpolateString(e.addButton.label||is,{documents:p}),page:e.addButton.page,type:mt.COLLECTION_ADD,classModifiers:["secondary"],customAction:{type:e.addButton.customAction}},onAction:n})]})},Qa="hods-form-collection",Za=({config:e,value:t,formData:n,onChange:s=void 0,onTopLevelChange:r=void 0,wrap:o=!1})=>{const[i,l]=R.useState(t),a=p=>{l(p),typeof s=="function"&&s({target:{name:e.fieldId,value:p}})},c=({target:p})=>{if(typeof s=="function")if(p.name===w.Meta.name)s({target:p});else{const A=i.findIndex(T=>T.id===p.name);a([...i.slice(0,A),p.value,...i.slice(A+1)])}},u=async()=>{a([...i,{id:_t.v4()}])},h=async p=>{a(i.filter(A=>A.id!==p.id))},f=p=>p.initial&&!i.length?p.initial:p.add;R.useEffect(()=>{if(e.focusOnAdd&&Array.isArray(i)&&i.length&&(i.length>e.minimumEntries||!e.minimumEntries)){const p=i[i.length-1]?.id,T=document.getElementById(p)?.childNodes[0]?.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');T&&T.length>0&&T[0].focus()}},[i.length,e.focusOnAdd,e.minimumEntries]),R.useEffect(()=>{e.minimumEntries&&!i.length&&u()},[e.minimumEntries,i.length]);const E={...$e,...e.labels},y=w.classBuilder(Qa,[],e.className);return d.jsxs("div",{className:y(),id:e.id,children:[e.label&&d.jsx(S.Label,{id:e.id,required:e.required,className:y("title"),children:e.label}),Array.isArray(i)&&i.map((p,A)=>{const T=`${e.full_path||e.fieldId}[${A}]`,N=(e.countOffset||0)+A+1,C=w.interpolateString(E.item,{...p,index:N}),b=w.interpolateString(E.remove,{...p,index:N}),I=e.disableAddAndRemove||A===0&&e.minimumEntries?"":e.removeLocation??"start",U=A!==0&&e.subsequentItemStyle?e.subsequentItemStyle:{};return d.jsxs("div",{className:`${y("item")}`,style:U,children:[d.jsxs(S.Label,{id:p.id,required:!0,className:y("item-title"),children:[C,I==="start"&&d.jsx(S.Button,{onClick:()=>h(p),classModifiers:"secondary",children:b})]}),d.jsx(Ln,{container:{id:p.id,fieldId:p.id,type:"container",required:e.required,full_path:T,components:e.item.map(g=>{const{firstOnlyLabel:L,...v}=g;let{hint:F}=g;e.restrictHint&&A>0&&(F=void 0);let{label:P}=g;return A===0&&(P=g.firstOnlyLabel??g.label),{...v,hint:F,readonly:!!(e?.readonly||g.readonly),label:w.interpolateString(P,{...p,index:N}),full_path:`${T}.${g.fieldId}`}})},value:p,formData:n,onChange:c,onTopLevelChange:r,wrap:o}),I==="end"&&d.jsx(S.ButtonGroup,{className:"govuk-!-margin-top-2",children:d.jsx(S.Button,{onClick:()=>h(p),classModifiers:"secondary",children:b})})]},p.id)}),!e.disableAddAndRemove&&d.jsx(S.ButtonGroup,{children:d.jsx(S.Button,{onClick:u,classModifiers:"secondary",children:f(E)})})]})},ec=(e,t,n)=>{const s=e,r=typeof s.value=="object"?s.value?.value:s.value,o=n.find(i=>String(i.id)===r);return s.label=o===void 0?s.value||"":o.label,s.component=t.cya_label,s},tc=(e,t)=>typeof e=="string"?!!S.Utils.interpolateString(e,t):!!e,Vt=(e,t)=>{if(Array.isArray(t)){const n=t.find(s=>s.id===(e.full_path||e.id));if(n){const s={error:n.error};return n.properties&&(s.propsInError=n.properties),s}}},nc=[_.RADIOS,_.CHECKBOXES,_.DATE,_.TIME],sc=e=>e.fieldset||nc.includes(e.type),Ve=({component:e,value:t=null,formData:n=null,wrap:s=!0,onAction:r,onChange:o,onTopLevelChange:i,pages:l=[],submitting:a=!1,...c})=>{const{hooks:u}=Pe(),h=He(),{data:f,status:E}=ga(e,n),[y,p]=R.useState([]);R.useEffect(()=>{E===yt&&p(f)},[e,f,E]);const A=({target:C})=>typeof o=="function"?(e.type===_.EMAIL&&(C.value=C.value.trim()),e.type===_.CHECKBOXES&&Array.isArray(C.value)&&C.value.forEach(b=>{b.children&&b.nested&&(delete b.children,delete b.nested)}),C=ec(C,e,f),e.type===_.SELECT&&C.value===""&&(C.value=null,C.label=null),o({target:C}),!0):!1;if(R.useEffect(()=>{const C=w.Component.defaultValue(e,n);!t&&!n?.[e.fieldId]&&C&&typeof A=="function"&&A({target:{name:e.fieldId,value:C}})},[]),e.type===_.CONTAINER){let C=d.jsx(Ln,{...c,container:e,wrap:s,onChange:A,onTopLevelChange:i,value:t||w.Component.defaultValue(e,n),formData:n});return e.fieldset&&(C=Xe(e,C)),e.additionalValidation&&(C=Xe({...e,...Vt(e,h?.errors)},C)),C}if(e.type===_.COLLECTION)return d.jsx(Za,{...c,config:e,wrap:s,onChange:A,onTopLevelChange:i,value:t||w.Component.defaultValue(e,n),formData:n});if(e.type===_.COLLECTION_SUMMARY)return Xe({...e,...Vt(e,h?.errors)},d.jsx(Xa,{...c,config:e,formData:n,onAction:r,onChange:o,onTopLevelChange:i,pages:l}));const T=C=>{let b=e.full_path||e.fieldId;if(e.pageCollection){const I=w.CollectionPage.getActiveIndex(e.pageCollection.name,n);b=`${`${e.pageCollection.name}[${I}]`}.${b}`}i({target:{name:w.Meta.name,value:w.Meta.documents.setForField(C,n,b,e.allowMultiple)}})},N=({target:C})=>{if(A({target:C})){if(e.type===_.FILE)T([C.value]);else if(e.type===_.MULTI_FILE){const b=C.value.map((I,U)=>({...I,indexInField:U}));T(b)}}};return w.Component.get({...c,...e,id:e.full_path||e.id,...Vt(e,h?.errors),fieldset:sc(e),disabled:tc(e.disabled,n),label:w.interpolateString(e.label,n),content:w.interpolateString(e.content,n),hint:w.interpolateString(e.hint,n),cya_label:w.interpolateString(e.cya_label,n),suffix:w.interpolateString(e.suffix,n),options:y,value:t,onChange:N,onTopLevelChange:i,formData:n,onAction:r,submitting:a},s,u.onGetComponent)},rc=[_.AUTOCOMPLETE,_.CALCULATION,_.CHECKBOXES,_.COLLECTION_SUMMARY,_.DATE,_.EMAIL,_.FILE,_.MULTI_FILE,_.PHONE_NUMBER,_.RADIOS,_.SELECT,_.TEXT,_.TEXT_AREA,_.TIME],mr=e=>rc.includes(e?.type)||e?.isEditable||!1,oc="govuk-list",ic="govuk-body",lc=e=>{const t=te(e),n=S.Utils.interpolateString(e.heading,e.formData),s=S.Utils.interpolateString(e.text,e.formData);return d.jsx(S.Alert,{...t,heading:n,children:s})},ac=e=>{const t=te(e),n=de.getAutocompleteSource(e);return d.jsx(S.Autocomplete,{...t,source:n})},cc=e=>{let t=[];de.getOptions(e,s=>{t=s}),t=t.map(s=>Array.isArray(s.nested)?{...s,children:pr(e,s.nested)}:s);const n=te(e);return d.jsx(S.Checkboxes,{...n,options:t})},uc=e=>{const t=de.applyFormula(e);typeof e.onChange=="function"&&t!==e.value&&e.onChange({target:{name:e.fieldId,value:t}});const n=te(e,["formula"]);return d.jsx(S.TextInput,{...n,readonly:!0})},dc=e=>{const t=te(e);return d.jsx(S.DateInput,{...t})},fc=e=>{const t=te(e,["tagName"]),n=Ft(e);return d.jsx(S.Details,{...t,children:n})},hc=e=>{const t=te(e);return d.jsx(S.FileUpload,{...t})},mc=e=>{const t=te(e);return d.jsx(S.MultiFileUpload,{...t})},pc=e=>{const t=te(e);return d.jsx(S.Heading,{...t,children:e.content})},Ft=e=>{const t=te(e);return d.jsx(S.Markup,{...t})},Ec=e=>{const t=te(e);return d.jsx(S.InsetText,{...t,children:e.content})},Ac=e=>{const t=te(e,["ordered"]),n=e.ordered?"ol":"ul",s=e.ordered?"number":"bullet",r=S.Utils.classBuilder(oc,s),o=t.items?.map(i=>`<li>${i}</li>`).join("");return Ft({...t,className:r(),tagName:n,content:o,type:_.HTML})},yc=e=>{const t=te(e);return Ft({className:ic,...t,tagName:"p",type:_.HTML})},Tc=e=>{let t=[];de.getOptions(e,s=>{t=s}),t=t.map(s=>Array.isArray(s.nested)?{...s,children:pr(e,s.nested)}:s);const n=te(e);return d.jsx(S.Radios,{...n,options:t})},Sc=e=>{const t=te(e);return d.jsx(S.TextArea,{...t})},Cc=e=>{const t=te(e);return d.jsx(S.TextInput,{...t})},gc=e=>{const t=te(e);return d.jsx(S.TimeInput,{...t})},bc=e=>{let t=[];de.getOptions(e,s=>{t=s});const n=te(e);return d.jsx(S.Select,{...n,options:t})},wc=e=>{const t=te(e);return d.jsx(S.WarningText,{...t,children:e.content})},_c=e=>{switch(e.type){case _.HTML:return Ft(e);case _.HEADING:return pc(e);case _.INSET_TEXT:return Ec(e);case _.TEXT:case _.EMAIL:case _.PHONE_NUMBER:return Cc(e);case _.TEXT_AREA:return Sc(e);case _.AUTOCOMPLETE:return ac(e);case _.RADIOS:return Tc(e);case _.CHECKBOXES:return cc(e);case _.DATE:return dc(e);case _.TIME:return gc(e);case _.FILE:return hc(e);case _.MULTI_FILE:return mc(e);case _.WARNING:return wc(e);case _.SELECT:return bc(e);case _.DETAILS:return fc(e);case _.CALCULATION:return uc(e);case _.ALERT:return lc(e);case _.PARAGRAPH:return yc(e);case _.LIST:return Ac(e);default:return null}},Ic=(e,t)=>{const n={...t};if(e.full_path){const s=e.full_path.split(".");s.pop(),s.push(n.fieldId),n.full_path=s.join(".")}return e.formData&&(n.value=e.formData[n.fieldId]||de.getSource(e.formData,n.full_path)||""),"readonly"in n&&delete n.readonly,e.readonly?(n.readonly=e.readonly,d.jsx("div",{children:Er(n,!1)})):d.jsx(Ve,{component:n,value:n.value,onChange:e.onChange,onTopLevelChange:e.onChange,formData:e.formData},n.key)},pr=(e,t)=>{const n=t.filter(s=>!(s.show_when&&!ae.meetsAll(s.show_when,e.formData))).map(s=>d.jsx(d.Fragment,{children:Ic(e,s)},s.id));return n.length>0?n:null},Er=(e,t=!0,n=void 0)=>{if(typeof n=="function"){const r=n(e,t);if(r)return r}const s=_c(e);return s&&t&&mr(e)?Xe(e,s):s},Pc=e=>e.defaultValue||e.defaultObjectValue,xc=e=>{const n=/^(\d{1,2})-\d{1,2}-(\d{4})$/.test(e.defaultValue)?e.defaultValue:null;return e.defaultValue==="today"?K().format("DD-MM-YYYY"):n},Oc=(e,t)=>{const n={...e};let s=null;return!n.literal&&!n.sourced&&(n.sourced={...n}),n.literal&&(s={...n.literal}),n.sourced&&(s=s??{},Object.keys(n.sourced).every(r=>{const o=typeof n.sourced[r]=="string"&&se(t,n.sourced[r]);return o===void 0&&n.skipIfSourceInvalid?(s=null,!1):(s[r]=o||n.sourced[r],!0)})),s},Ar=(e,t)=>Pc(e)?e.type===_.DATE?xc(e):(e.defaultObjectValue?Oc(e.defaultObjectValue,t):null)||e.defaultValue||null:null,Rc={[_.COLLECTION]:[],[_.CONTAINER]:{}},Nc=(e,t)=>e&&(Ar(e,t)||Rc[e.type])||"",ot={clean:te,defaultValue:Nc,defaultValueFromConfig:Ar,editable:mr,elevateNested:et,get:Er,setupContainerPaths:fr,show:Ie,wrap:Xe},Lc=(e,t)=>{e.data?.options?.forEach(n=>{Array.isArray(n.nested)&&Ze(t.formData[e.id],n)&&n.nested.forEach(s=>{const r=s;r.value=t.formData[r.id]})})},jt=(e,t,n)=>{let s="";return e.formData&&t.fieldId&&(s=e.formData[t.fieldId],Lc(t,e)),{pageId:e.id,id:t.id,fieldId:t.fieldId,full_path:t.full_path,key:S.Utils.interpolateString(t.cya_label||t.label,e.formData),required:t.required,component:ot.editable(t)?t:void 0,value:s||"",action:e.cya_link?.singleChangeLink?null:vt(t.readonly,e,n)}},qe=(e,t,n,s,r)=>Ct(t,{...e.formData,...n})?et(t.components.filter(i=>i.show_on_cya===void 0||i.show_on_cya),n).filter(i=>Ct(i,{...e.formData,...n})).flatMap(i=>{const l=n?n[i.fieldId]:void 0;if(typeof r=="function"){const a=r({...e,formData:n},i,s);if(a)return a}return i.type===_.CONTAINER?qe(e,i,{...l,...n},s,r):i.type===_.COLLECTION?xn(e,i,l,s,r):jt({...e,formData:n},i,s)}):null,Dc=e=>{if(!e.conditionalProperties)return e;let t={...e};return e.conditionalProperties.forEach(n=>{w.Condition.met(n.condition,e.formData[n.condition.field])&&(t=Object.assign(t,n.properties))}),t},ls=(e,t,n="text")=>{if(typeof e=="string")return S.Utils.interpolateString(e,t);if(!Array.isArray(e)||Object.keys(t).length===0)return null;const s=e.find(r=>typeof r=="string"?!0:Ue(r.show_when,t));return typeof s=="string"?S.Utils.interpolateString(s,t):S.Utils.interpolateString(s[n],t)},vc=e=>{const t={...e};return t.page||(t.href?t.page=t.href.split("/").pop():t.url&&(t.page=t.url.split("/").pop())),t},Fc=e=>{if(e&&Array.isArray(e.actions))return e.actions.map(t=>{if(typeof t=="string")return W.DEFAULTS[t];if(t&&typeof t=="object"){const n=t;return W.DEFAULTS[n.type]?.validate&&!n.hasOwnProperty("validate")&&(n.validate=!0),vc(n)}}).filter(t=>!!t)},jc=e=>({type:_.HTML,tagName:"p",content:e}),Uc=(e,t)=>{const n=e.use.split("."),s=n.shift();let r=JSON.parse(JSON.stringify({...t.find(l=>l.id===s)})),o=r,i=r;for(;o&&n.length>0;){const l=n.shift();Array.isArray(o.components)?(i=o,i.components=i.components.filter(a=>a.id===l),i.components.length>0?o=i.components[0]:o=void 0):o=void 0}if(o)return o={cya_label:o.label,...o,...e},i&&i.id!==o.id?i.components=[o]:r=o,o.item&&Array.isArray(o.item)&&(o.item=o.item.map(l=>l.use?ln(l,t):l)),r},ln=(e,t)=>{if(e){const n=Uc(e,t);if(n)return n}return{...e}},yr=(e,t,n)=>{if(!e)return null;const s=e.components.map(o=>{if(typeof o=="string")return jc(o);let i;return o.type===_.CONTAINER&&(o.components=o.components.map(l=>l.use?ln(l,t):l)),o.use?i=ln(o,t):i={...o},n?de.refData.setupUrl(i,n):i}),r=Fc(e);return Lt.setup({...e,formData:n,components:s,actions:r})},Mc=(e,t,n)=>Array.isArray(e)?e.map((s,r)=>({...yr(s,t,n),index:r})):[],Tr=(e,t)=>e?.hasOwnProperty("show_on_cya")&&!e.show_on_cya?!1:Dt(e,t),it={applyConditionalProperties:Dc,getConditionalText:ls,get:yr,getAll:Mc,getTitle:(e,t)=>ls(e,t,"title"),show:Dt,showCYA:Tr},kc=(e,t)=>{if(!e)return null;if(!t)return e;const n={...e};return n.show_when?Array.isArray(t)?n.show_when=Array.isArray(n.show_when)?[...t,...n.show_when]:[...t,n.show_when]:n.show_when=Array.isArray(n.show_when)?[...n.show_when,t]:[n.show_when,t]:n.show_when=t,n},Bc=(e,t)=>{const n=e.split(".").pop();t[`${n}ActiveId`]=null},Ut=(e,t)=>{const n=e.split(".").pop();return t[`${n}ActiveId`]||null},$c=e=>typeof e=="number"&&e>=0,Sr=(e,t,n)=>{const s=e[0];if(e.length===1)return t[s]||null;const r=n?.[`${s}ActiveId`]||null;if(!r)return null;const o=t[s]?.findIndex(i=>i.id===r);return $c(o)?(e.shift(),Sr(e,t[s][o],n)):null},Ge=(e,t)=>{const n=e.split(".");return Sr(n,t,t)},Cr=(e,t,n,s=[],r={})=>{const o=Ge(e,t),i=o?.find(u=>u.id===n);if(!i)return null;const l=_t.v4(),a={...i,...r,id:l};s.forEach(u=>delete a[u]);const c=o.findIndex(u=>u.id===n)+1;return c===-1?o.push(a):o.splice(c,0,a),t[`${e.split(".").pop()}ActiveId`]=a.id,l},Yc=(e,t)=>{const n=Ut(e,t);return Cr(e,t,n)},Hc=e=>typeof e=="number"&&e>=0,gr=(e,t,n)=>{const s=e[0],r=n?.[`${s}ActiveId`]||null;if(!r)return null;const o=t[s]?.findIndex(i=>i.id===r);return Hc(o)?e.length===1?o:(e.shift(),gr(e,t[s][o],n)):null},br=(e,t)=>{const n=e.split(".");return gr(n,t,t)},Vc=e=>({id:e.id,name:e.name,...e.collection.show_when&&{show_when:e.collection.show_when},orderInForm:e.orderInForm,deleteCollectionWhenHidden:e.deleteCollectionWhenHidden,collection:{masterPage:!0,...e.collection},formData:{...e.formData},childPages:[e]}),qc=(e,t)=>{t.collection={...t.collection,...e.collection},t.formData={...t.formData,...e.formData},t.childPages=[...t.childPages,e]},Gc=(e,t)=>{const n=e.collection.name.split(".");if(n.length===1)return!1;n.pop();const s=n.join("."),r=t[s]||null;return r?(r.childPages.push(e),r.childPages.sort((o,i)=>o.orderInForm-i.orderInForm),!0):!1},wr=e=>{const t={};return e.map((s,r)=>{if(s.orderInForm=r,s?.collection?.name){if(!t[s.collection.name]){const o=Vc(s);return t[s.collection.name]=o,o}return qc(s,t[s.collection.name]),null}return s}).filter(s=>!!s).map(s=>s.collection?.masterPage&&Gc(s,t)?null:s).filter(s=>!!s)},Kc=(e,t,n)=>{const s=Ge(e,t);if(!s)return null;const r=s.findIndex(l=>l.id===n);if(r===-1)return null;const o=s[r];s.splice(r,1);const i=t;return i[`${e}ActiveId`]=s.length>0?s[0].id:null,o},Wc=e=>typeof e=="number"&&e>=0,On=(e,t,n)=>{const s=e.split("."),r=s[s.length-1];let o=n;s.some(i=>{if(o[i]||(o[i]=[]),!o[i].find(c=>c.id===n[`${i}ActiveId`])){const c=_t.v4();n[`${i}ActiveId`]=n[`${i}ActiveId`]||c,o[i].push({id:n[`${i}ActiveId`]})}if(i===r)return o[r]=t,!0;const l=n[`${i}ActiveId`],a=o[i]?.findIndex(c=>c.id===l);return Wc(a)?(o=o[i][a],!1):!0})},gt={addEntry:Bc,duplicateActiveEntry:Yc,duplicateEntry:Cr,getActiveId:Ut,getActiveIndex:br,getData:Ge,getErrorsForCollection:gn,mergePages:wr,removeEntry:Kc,setData:On},zc=e=>typeof e=="number"&&e>=0,Jc=(e,t,n,s,r,o)=>{const i=r?.label||$e.remove;return{pageId:e.id,fieldId:`delete${s}`,key:`delete${s}`,type:"action",action:{onAction:()=>{n(null,a=>{const c=a;if(!o)return c;Object.entries(o).forEach(f=>{const[E,y]=f;c[E]=y});const u=gt.getData(e.collection.name,c),h=u?.findIndex(f=>f.id===t.id);return zc(h)&&u.splice(h,1),c})},label:S.Utils.interpolateString(i,{...t,index:s})}}},Xc=(e,t,n,s,r,o={})=>{const i=r?.label||$e.change;return{pageId:e.id,fieldId:`change${s}${r.page}`,key:`change${s}${r.page}`,type:"action",action:{onAction:l=>{const a=c=>{const u=c;return Object.entries(o).forEach(h=>{const[f,E]=h;u[f]=E}),u};n(r.page?{pageId:r.page}:l,a)},label:S.Utils.interpolateString(i,{...t,index:s})}}},Qc=(e,t)=>t.show_when?Ue(t.show_when,e):!0,Zc=(e,t,n,s)=>({id:t.id,fieldId:t.id,type:_.CONTAINER,required:!0,full_path:s,components:e.components.map(r=>({...r,label:S.Utils.interpolateString(r.label,{...t,index:n}),full_path:`${s}.${r.fieldId}`}))}),eu=(e,t,n,s,r)=>{const o={...$e,...e.collection.labels};return{pageId:n,fieldId:"Title",full_path:`${r}.Title`,key:S.Utils.interpolateString(o.item,{...t,index:s}),type:"heading",size:e.collection.titleSize||"s"}},tu=(e,t,n,s,r)=>e.text===""?null:{pageId:t,fieldId:`heading${n}`,full_path:`heading${n}`,key:S.Utils.interpolateString(e.text,r),type:s===null?"heading":"headingWithAction",size:e.size||"s",action:s===null?null:{onAction:s,label:"Change"}},nu=(e,t,n,s)=>({pageId:e.id,fieldId:`${e.collection.name}Title`,full_path:`${e.collection.name}Title`,key:n?.text||t.charAt(0).toUpperCase()+t.slice(1),type:s==null?"heading":"headingWithAction",size:n?.size||"m",action:s===null?null:{onAction:s,label:"Change"}}),su=(e,t,n,s,r,o={})=>e.collection?.actions?.filter(i=>Qc(r,i)).map(i=>i.type==="remove"?Jc(e,t,n,s,i,o):i.type==="change"?Xc(e,t,n,s,i,o):null).filter(i=>!!i),_r=(e,t,n={})=>()=>{const s=r=>{const o=r;return Object.entries(n).forEach(i=>{const[l,a]=i;o[l]=a}),o};t({pageId:e.id},s)},ru=(e,t,n,s,r,o,i)=>{let l=[];return e.forEach(a=>{let c=a;if(c.collection.masterPage)l=l.concat(Ir(c,n,s,t,i));else if(c.collection.route&&(c=kc(c,c.collection.route)||c),Tr(c,{...c.formData,...t})){const u=_r(c,n,i);if(c.collection.heading){const E=c.collection.heading.changeLink?u:null,y=tu(c.collection.heading,c.id,r,E,t);l=l.concat(y)}const h=Zc(c,t,r,o),f=qe({...c,formData:{...c.formData,...t}},h,{...c.formData,...t},u,s);l=l.concat(f)}}),l},Ir=(e,t,n,s,r={})=>{const o=e.collection.name.split(".").pop();let i=s[o]||null;const l=s[`${o}ActiveId`];if(!i||i.length===0)return[];let a=[];if(!e.collection.hideNameFromCYA){const f=e.collection.collectionHeading?.changeLinkPage?_r({id:e.collection.collectionHeading.changeLinkPage},t,r):null;a.push(nu(e,o,e.collection.collectionHeading,f))}let c=0;const u=Array.isArray(e.collection.hideItemTitles)?Ue(e.collection.hideItemTitles,s):e.collection.hideItemTitles;return(Array.isArray(e.collection.onlyShowActiveEntryOnCYA)?Ue(e.collection.onlyShowActiveEntryOnCYA,s):e.collection.onlyShowActiveEntryOnCYA)&&(i=[i.find((E,y)=>(c=y,E.id===l))]),i.forEach(f=>{if(!f)return;r={...r,[`${o}ActiveId`]:f.id};const E=c+1,y=e.collection?.actionPosition||"top",p=`${e.collection.name}[${c}]`,A=su(e,f,t,E,s,r);if(!u){const T=eu(e,f,e.id,E,p);a=a.concat(T)}y==="top"&&(a=a.concat(A)),a=a.concat(ru(e.childPages,f,t,n,E,p,r)),y==="bottom"&&(a=a.concat(A)),c+=1}),a.filter(f=>!!f)},ou=e=>e.value?e.component?d.jsx("div",{children:d.jsx(Ve,{component:{...e.component,readonly:!0},wrap:!1,value:e.value})},e.id):e.value:null,iu=(e,t)=>{let n=-1;return{value:d.jsx(d.Fragment,{children:e.components.map(r=>{const o=t.findIndex(i=>i.id===r);return n<0&&(n=o),o>-1?ou(t[o]):null})}),firstComponentIndex:n}},lu=(e,t,n,s)=>{const{value:r,firstComponentIndex:o}=iu(t,n);return{row:{pageId:e.id,fieldId:t.id,key:t.label,required:t.required,value:r,action:vt(!1,e,s)},insertAt:o}},au=(e,t,n=null)=>{if(it.showCYA(e,e.formData)){if(e.collection)return Ir(e,t,n,e.formData);const r=et(e.components,e.formData).filter(o=>Ct(o,e.formData)).flatMap(o=>{if(typeof n=="function"){const i=n(e,o,t);if(i)return i}switch(o.type){case _.CONTAINER:return qe(e,o,e.formData[o.fieldId],t,n);case _.COLLECTION:return xn(e,o,e.formData[o.fieldId],t,n);default:return jt(e,o,t)}});if(e.groups?.length>0){e.groups.forEach(i=>{const{row:l,insertAt:a}=lu(e,i,r,t);a>-1?r.splice(a,0,l):r.push(l)});const o=e.groups.flatMap(i=>i.components);return r.filter(i=>!o.includes(i.id))}return r}return[]},cu={getRows:au,getCYARowsForContainer:qe},Pr=(e,t)=>{if(e&&t)switch(e.type){case"lowercase":return t.toLowerCase();case"uppercase":return t.toUpperCase();default:return t}return t},xr=(e,t,n)=>{const s=t;e.format&&e.format.on===n&&(s[e.fieldId]=Pr(e.format,s[e.fieldId]))},Or=(e,t,n)=>{e.forEach(s=>xr(s,t,n))},Rr=(e,t,n)=>{Or(e.components,t,n)},uu=(e,t,n)=>{e.forEach(s=>Rr(s,t,n))},du=(e,t,n)=>{const s={...t};return Or(e.components,s,n),uu(e.pages,s,n),s},fu={component:xr,data:Pr,form:du,page:Rr},hu=(e,t,n,s)=>{if(e===ne.HUB&&t){if(t.format===ye.CYA)return ye.CYA;if(t.components)return it.get(t,n,s)}if(e===ne.TASK||e===ne.FORM_WITH_TASK)return ye.TASK},mu={get:hu},Rn="meta",Nn="documents",an=e=>e?.[Rn]?.[Nn]||[],pu=(e,t,n,s)=>{const r=s?an(t):an(t).filter(i=>i.field!==n);return Array.isArray(e)&&e.forEach(i=>{r.push({...i,field:n})}),{...t?t[Rn]:void 0,[Nn]:r}},Eu={setForField:pu,get:an,name:Nn},Au={documents:Eu,name:Rn},yu=(e,t)=>{if(e?.field){const n=S.Utils.interpolateString(e.field,t);return!!se(t,n)}return!1},qt=(e,t)=>{if(e?.value)return e.value;const n=S.Utils.interpolateString(e?.field,t);return se(t,n)},Tu=(e,t)=>{if(!e||!t)return null;const n=S.Utils.interpolateString(e.target,t),s=se(t,n),r=qt(e,t),o=qt(e.cutoff,t),i=qt(e.ignore,t);let l=null;return s&&r&&Array.isArray(s)&&s.every((a,c)=>c===o?!1:c===i?!0:a===r||e.key&&se(a,e.key)===r?(l=c,!1):!0),typeof l=="number"?l.toString():l},Su=(e,t,n)=>{let s;if(e?.field){const r=S.Utils.interpolateString(e.field,t);s=se(t,r)}else s=e?.value;s!=null&&e.name&&t[e.name]!==s&&n({target:{name:e.name,value:s}})},Cu=(e,t)=>{if(e?.field){const n=S.Utils.interpolateString(e.field,t);return se(t,n)||null}return e?.value||null},gu=(e,t,n)=>{const s=t;e?.field&&e?.component&&(delete s[e.field],n({target:{name:e.field,value:null,component:e.component}}))},bu=(e,t)=>{if(e?.condition){const n=e,s=S.Utils.interpolateString(n.field,t),r=se(t,s);switch(n.condition){case"changes":{const o=`${s}LastValue`,i=n[o]||null;return i===null?(n[o]=r,!1):r!==i?(n[o]=r,!0):!1}case"isTruthy":return!!r;case"isFalsy":return!r;default:return!1}}return!0},wu=(e,t)=>{if(e?.fields){let n;return e.fields.find(s=>{const r=S.Utils.interpolateString(s,t),o=se(t,r);return o?(n=o,!0):!1}),n||(e.fallback?S.Utils.interpolateString(e.fallback,t):"")}return e?.value||null},_u=(e,t)=>{if(!e||!t)return null;const n=e.target.split(".");let s="";n.forEach(i=>{if(s!==""&&(s+="."),i.slice(-2)==="[]"){const l=i.slice(0,-2),a=br(l,t);s+=`${l}[${a}]`}else s+=i});const r=S.Utils.interpolateString(s,t);return se(t,r)?.length||0},Iu=(e,t)=>{const n=S.Utils.interpolateString(e.target,t),s=se(t,n);return s&&Array.isArray(s)?s.some(r=>e.key?se(r,e.key)===e.value:r===e.value):s&&typeof s=="object"?se(s,e.key)===e.value:!1},Pu={checkValueIsTruthy:yu,getIndexOfMatchingValueIn:Tu,doesContainValue:Iu,persistValueInFormData:Su,setValueInFormData:Cu,deleteValueInFormData:gu,getLength:_u,getFirstOf:wu},xu=(e,t,n)=>{const s=Pu[e.function];if(typeof s=="function")return s(e,t,n)},Ou=(e,t,n)=>(e?.operations&&t&&e.operations.forEach(s=>{if(bu(s.run_when,t)){const r=xu(s,t,n);if(s.output){const o=S.Utils.interpolateString(s.output,t).replace("[",".").replace("]","");Rs(t,o,r)}}}),t),Ru={runPageOperations:Ou},Nu=(e,t,n,s)=>!(e!==t.base&&s[t.check]),Lu=(e,t,n)=>{const s=e[n.id]?.[t.base],r=e[n.id]?.[t.check],o=r&&r?.length>0;return!!(s||o)},Du=e=>/^-?\d+$/.test(e),bt=e=>Du(e)?e.padStart(2,"0"):"",ge=e=>{const[t,n,s]=e.split("-");return`${bt(t)}-${bt(n)}-${s}`},Nr=e=>{const[t,n]=e.split(":");return`${bt(t)}:${bt(n)}`},Se="DD-MM-YYYY";K.extend(Be);const vu=(e,t)=>{const n=t.date?K(ge(t.date),Se):K().add(t.value,t.unit);return K(ge(e),Se).isAfter(n)};K.extend(Be);const Fu=(e,t)=>{const n=t.date?K(ge(t.date),Se):K().add(t.value,t.unit);return K(ge(e),Se).isBefore(n)};K.extend(Be);const ju=(e,t,n)=>{const s=n.components?.find(c=>c.fieldId===t.date),r=n.components?.find(c=>c.fieldId===t.time);if(!s||!r||!e)return!1;const o=e[n.fieldId]?.[t.date],i=e[n.fieldId]?.[t.time];if(!o||!i||Qe(s,e[n.fieldId],e[n.fieldId])||Qe(r,e[n.fieldId],e[n.fieldId]))return!0;const l=ge(e[n.fieldId]?.[t.date]),a=Nr(e[n.fieldId]?.[t.time]);return K(`${l} ${a}`,`${Se} HH:mm`).isBefore(K())};K.extend(Be);K.extend(fn);const Uu=(e,t)=>{const n=K(ge(e),Se).isBefore(K()),s=K(ge(e),Se).isToday();return n&&!s?!0:s&&!!t?.todayAllowed};K.extend(Be);K.extend(fn);const Mu=(e,t)=>K(ge(e),Se).isAfter(K())?!0:!!t?.todayAllowed&&K(ge(e),Se).isToday(),ku=(e,t)=>e?e.length>t.value:!0,Bu=(e,t)=>e?e.length<t.value:!0,$u=(e,t)=>{if(!e)return!0;const n=typeof e=="string"?e.replace(/,/g,""):e;return parseFloat(n)>t.value},Yu=(e,t)=>{if(!e)return!0;const n=typeof e=="string"?e.replace(/,/g,""):e;return parseFloat(n)<t.value},Hu=(e,t)=>e?(t?.allowCommas?/^[0-9,]*\.?[0-9]*$/:/^[0-9]*\.?[0-9]*$/).test(e):!0,Vu=(e,t)=>e?t.array.includes(e):!0,qu=(e,t,n,s)=>{if(!e||!s)return!0;const r=Ut(t.collectionPath,s);return!Ge(t.collectionPath,s)?.some(l=>l.id===r?!1:t.caseInsensitive&&typeof e=="string"&&typeof l[n.id]=="string"?l[n.id].toUpperCase()===e.toUpperCase():l[n.id]===e)},Gu=(e,t,n)=>n.components?.some(s=>!!e[n.id]?.[s.id]),Ku=(e,t)=>!e||!e.includes(".")?!0:e.split(".")[1].length<t.maxDecimals,Wu=/(%27)|(')|(--)|(%23)|(#)|((%3D)|(=))[^\n]*((%27)|(')|(--)|(%3B)|(;))|w*((%27)|('))((%6F)|o|(%4F))((%72)|r|(%52))|((%27)|('))union/i,zu=e=>{if(e){const t=typeof e=="object"?JSON.stringify(e):String(e);return!Wu.test(t)}return!1},Ju=(e,t,n)=>n.components?.reduce((r,o)=>e[n.id]?.[o.id]?Array.isArray(e[n.id][o.id])&&e[n.id][o.id].length===0?r:r+1:r,0)<2,Xu={conditionallyPermittedChange:Nu,conditionallyRequired:Lu,mustBeAfter:vu,mustBeBefore:Fu,mustBeEarlierDateTime:ju,mustBeGreaterThan:$u,mustBeInTheFuture:Mu,mustBeInThePast:Uu,mustBeLessThan:Yu,mustBeLongerThan:ku,mustBeNumbersOnly:Hu,mustBeOneOf:Vu,mustBeShorterThan:Bu,mustBeUniqueInCollection:qu,mustEnterAtLeastOne:Gu,mustHaveLessThanDecimalPlaces:Ku,mustNotContainSql:zu,mustSelectOnlyOne:Ju},Qu=(e,t,n,s)=>{const r=Xu[t.function],o=t.objectValueToUse?e[t.objectValueToUse]:e;if(typeof r=="function")return r(o,t,n,s)?void 0:t.message},Lr=(e,t,n)=>{if(t&&Array.isArray(e.additionalValidation)){let s;return e.additionalValidation.forEach(r=>{s||(s=Qu(t,r,e,n))}),s}},wt=(e,t,n)=>{if(!e)return[];const s=n||t,r=Lr(e,s);if(r)return{id:e.id,error:r};const o=[];if(Array.isArray(e.components)){const i=t&&e.fieldId?t[e.fieldId]:t;et(e.components,i).forEach(a=>{const c=e.full_path||e.fieldId?`${e.full_path||e.fieldId}.${a.fieldId}`:a.fieldId;o.push(Qe({...a,full_path:c},i,s))})}return o.flat(1).filter(i=>!!i)},Zu=(e,t,n)=>{const s=[];return e&&Array.isArray(e.item)&&Array.isArray(t)&&t.forEach((r,o)=>{const i=(e.countOffset||0)+o+1,l=`${e.full_path||e.fieldId}[${o}]`,a={full_path:l,components:e.item.map(c=>{const u={...c,full_path:`${l}.${c.fieldId}`};return c.custom_errors&&Array.isArray(c.custom_errors)&&(u.custom_errors=c.custom_errors.map(h=>({...h,message:S.Utils.interpolateString(o===0&&h.firstOnlyMessage?h.firstOnlyMessage:h.message,{index:i})}))),u})};s.push(wt(a,r,n))}),s.filter(r=>!!r).flat()};K.extend(Be);K.extend(fn);K.extend(Xr);const ed=(e,t)=>e==="02"?K().year(t).isLeapYear()?29:28:["04","06","09","11"].includes(e)?30:31,Dr=e=>{if(!e)return{message:void 0,propsInError:void 0};const t=ge(e),[n,s,r]=t.split("-"),o=parseInt(n,10),i=parseInt(s,10),l=[],a=[];if(r.length===0?(l.push("year"),a.push("Date must include a year")):r.length!==4&&(l.push("year"),a.push("Year must be 4 numbers")),s.length===0?(l.push("month"),a.push("Date must include a month")):(i>12||i<1)&&(l.push("month"),a.push("Month must be between 1 and 12")),n.length===0)l.push("day"),a.push("Date must include a day");else{const c=ed(s,r);(o>c||o<1)&&(l.push("day"),a.push(`Day must be between 1 and ${c}`))}if(l.length>0){const c={};return l.includes("day")&&(c.day=!0),l.includes("month")&&(c.month=!0),l.includes("year")&&(c.year=!0),{message:l.length===1?a[0]:"Enter a valid date",propsInError:c}}return K(t,Se).format(Se)!==t?{message:"Enter a valid date",propsInError:{day:!0,month:!0,year:!0}}:{message:void 0,propsInError:void 0}},td=/^[a-z0-9._\-']+@(digital\.)?homeoffice.gov.uk$/i,nd=/^[a-z0-9._\-']+@jmsc.gov.uk$/i,vr=(e,t="",n=[])=>{if(e){const s=t?t.toLowerCase():"email address";if(typeof e=="string"&&(td.test(e)||nd.test(e)))return;if(Array.isArray(n)){const r=n.filter(o=>o.type==="format");if(r&&r.length>0&&r[0].message)return r[0].message}return`Enter ${s} in the correct format, like jane.doe@homeoffice.gov.uk`}},sd="Invalid files must be deleted",Fr=(e,t)=>{if(!e)return;let n=!1;if(e.every(s=>(n=s.error,!n)),n){if(Array.isArray(t)){const s=t.filter(r=>r.type==="invalidFile");if(s&&s.length>0&&s[0].message)return s[0].message}return sd}},jr=(e,t,n,s)=>{if(e){if(typeof e=="string"){if(new RegExp(n).test(e))return;if(Array.isArray(s)){const o=s.filter(i=>i.type==="pattern");if(o?.[0]?.message)return o[0].message}}return t?`${t} failed regex validation`:"Component failed regex validation"}},Ur=(e,t,n)=>{let s=!1;if((e||e===!1||e===0)&&(s=!0,typeof e=="string"?s=e.trim().length>0:Array.isArray(e)&&(s=e.length>0)),!s){if(Array.isArray(n)){const o=n.filter(i=>i.type==="required");if(o&&o.length>0&&o[0].message)return o[0].message}return`${t||"Field"} is required`}},Mr=(e,t,n,s,r,o=1e3)=>{if(!n||!r&&!t)return;if(r&&!t||t.length>o){if(Array.isArray(s)){const l=s.filter(a=>a.type==="length");if(l&&l.length>0&&l[0].message)return l[0].message}return`${e} must be ${o} characters or less`}},kr=e=>{if(!e)return{message:void 0,propsInError:void 0};const t=Nr(e),[n,s]=t.split(":"),r=parseInt(n,10),o=parseInt(s,10),i=[],l=[];if(/^\d{0,2}:\d{0,2}$/.test(e)||(i.push("invalid"),l.push("Enter a valid time")),n.length===0?(i.push("hour"),l.push("Time must include a hour")):(r>23||r<0)&&(i.push("hour"),l.push("Hour must be between 0 and 23")),s.length===0?(i.push("minute"),l.push("Time must include a minute")):(o>59||o<0)&&(i.push("minute"),l.push("Minute must be between 0 and 59")),i.length>0){const c={};return i.includes("hour")&&(c.hour=!0),i.includes("minute")&&(c.minute=!0),i.includes("invalid")&&(c.invalid=!0),{message:i.length>1?"Enter a valid time":l[0],propsInError:c}}return{message:void 0,propsInError:void 0}},rd=(e,t)=>e?.type==="or"?ae.meetsOne(e.conditions,t):ae.meetsAll(e.conditions,t),Qe=(e,t,n)=>{const s=n||t;if(!Ie(e,{...s,...t}))return;if(e.type===_.CONTAINER)return wt(e,t,s);let r,o,l=(t&&typeof t=="object"?t:{})[e.fieldId];if(e.type===_.COLLECTION_SUMMARY&&(l=Ge(e.collectionName,s)),e.required&&(!e.requiredOverrideConditions||!rd(e.requiredOverrideConditions,s))&&(r=Ur(l,e.label,e.custom_errors)),!r){switch(e.type){case _.COLLECTION:return Zu(e,l,s);case _.EMAIL:r=vr(l,e.label,e.custom_errors);break;case _.DATE:case _.TIME:{const a=e.type===_.DATE?Dr:kr,{message:c,propsInError:u}=a(l);o=u,r=c;break}case _.CHECKBOXES:case _.RADIOS:{let a=[];if(e.data.options?.forEach(c=>{c.nested&&Ze(n[e.id],c)&&(a=a.concat(wt({components:c.nested},n)))}),a.length>0)return a;break}case _.MULTI_FILE:r=Fr(l,e.custom_errors);break;case _.TEXT_AREA:r=Mr(e.label,l,e.showCharacterCount,e.custom_errors,e.required,e.maxLength);break}!r&&e.pattern&&(r=jr(l,e.label,e.pattern,e.custom_errors)),!r&&e.additionalValidation&&(r=Lr(e,l,n),e.type===_.DATE&&r&&(o={day:!0,month:!0,year:!0}))}if(r)return{id:e.full_path||e.id,error:r,properties:o}},od=(e,t=[])=>{let n=e.formData;if(e.collection){const s=gt.getActiveIndex(e.collection.name,e.formData);s!==null&&(n={...e.formData,...gt.getData(e.collection.name,e.formData)?.[s]})}return Dt(e,n)&&Array.isArray(e.components)?e.components.reduce((r,o)=>{if(!Ie(o,n))return r;const l=(t.length>0?t.filter(a=>a.showFor?a.showFor===o.id:a.id===o.id):[]).concat(Qe(o,n,n));return r.concat(l).flat().map(a=>a&&{...a,error:S.Utils.interpolateString(a.error,n)})},[]).filter(r=>!!r).flat():[]},id={component:Qe,container:wt,email:vr,date:Dr,multifile:Fr,page:od,regex:jr,required:Ur,textarea:Mr,time:kr},w={CheckYourAnswers:cu,CollectionPage:gt,Component:ot,Condition:ae,Container:Lt,Data:de,Format:fu,FormPage:it,Hub:mu,Meta:Au,Operate:Ru,Validate:id,...S.Utils},ld="hods-form-container",Ln=({container:e,value:t=void 0,formData:n,onChange:s=void 0,wrap:r=!0,onTopLevelChange:o=void 0,...i})=>{const l=({target:h})=>{if(typeof s=="function")if(h.name===w.Meta.name)s({target:h});else{const f={...t,[h.name]:h.value};s({target:{name:e.fieldId,value:f}})}},a=h=>{const f=`${e.full_path||e.fieldId}.${h.fieldId}`;return h.type===_.CONTAINER?w.Container.show({...h,full_path:f},n):w.Component.show({...h,full_path:f},{...n,...se(n,e.full_path)})},c=w.classBuilder(ld,[],e.className),u=S.Utils.cleanHtmlAttributes(i);return d.jsxs("div",{...u,className:c(),id:e.id,children:[e.title&&d.jsx(S.MediumHeading,{children:e.title}),e.components&&e.components.filter(a).map((h,f)=>{const E=h.type===_.FILE?{}:"",y=t?t[h.fieldId]:E,p=`${e.full_path||e.fieldId}.${h.fieldId}`;return d.jsx(Ve,{...i,component:{...h,full_path:p,readonly:!!(e.readonly||h.readonly)},formData:n,value:y||E,wrap:r,onChange:l,onTopLevelChange:o},f)})]})},ad=e=>{if(e&&Object.prototype.hasOwnProperty.call(e,"action")){if(typeof e.action.onAction=="function")return{onClick:()=>e.action.onAction(e),onKeyPress:t=>{t.key==="Enter"&&e.action.onAction(e)},tabIndex:"0"};if(e.action.page)return{href:`/${e.action.page}`}}return{}},as=({group:e})=>{const[t,n]=R.useState({});return R.useEffect(()=>{n(ad(e))},[e,n]),e?.action?d.jsxs(S.Link,{...t,"aria-label":`${e.action.label} ${e.action.aria_suffix}`,children:[e.action.label,e.action.aria_suffix&&d.jsxs("span",{className:"mobile-text govuk-link",children:[" ",`${e.action.aria_suffix}`]})]}):null},cd=({title:e,size:t="m",classes:n})=>d.jsxs("div",{className:`${n("heading")}`,role:"listitem",children:[t==="s"&&d.jsx(S.SmallHeading,{children:e}),t==="m"&&d.jsx(S.MediumHeading,{children:e})]}),ud=({row:e,classes:t,noChangeAction:n=!1})=>d.jsxs("div",{className:t("headingWithAction"),role:"listitem",children:[d.jsxs("td",{className:"heading-text",colSpan:"2",children:[e.size==="s"&&d.jsx(S.SmallHeading,{children:e.key}),e.size==="m"&&d.jsx(S.MediumHeading,{children:e.key})]}),d.jsx("td",{className:"heading-action",children:!n&&d.jsx(Pn,{row:{action:e.action}})})]}),dd="govuk-summary-list",cn=({rows:e,noChangeAction:t=!1,noGroupAction:n=!1,isGroup:s=!1,classBlock:r=dd,classModifiers:o=[],className:i="",showGroupAction:l=!0,...a})=>{const c=S.Utils.classBuilder(r,o,i),u=S.Utils.cleanHtmlAttributes(a);let h=null;if(s){const f=e.filter(E=>!!E.action);h=f?.length?f[0]:null}return d.jsx("div",{className:"group-of-rows",children:d.jsxs("div",{...u,className:c(),role:"list",children:[e.map(f=>{const E=`${f.pageId}_${f.full_path||f.fieldId}`;return f.type==="title"?d.jsx(ur,{title:f.key,classes:c},E):f.type==="heading"?d.jsx(cd,{title:f.key,size:f.size||"s",classes:c},E):f.type==="headingWithAction"?d.jsx(ud,{row:f,classes:c,noChangeAction:t},E):f.type==="action"?t?null:d.jsx("div",{children:d.jsx(as,{group:f})},`${E}-actions`):d.jsx(cr,{row:f,classes:c,showAction:!t},E)}).filter(f=>!!f),l&&s&&!n&&d.jsx("div",{className:"change-group-button",children:d.jsx(as,{group:h})})]})})},fd="hods-check-your-answers",hd="Check your answers",cs=9,md=({title:e=hd,titleSize:t="l",pages:n,actions:s=[],onAction:r,onRowAction:o,hide_page_titles:i=!1,hide_actions:l=!1,hide_title:a=!1,summaryListClassModifiers:c,noChangeAction:u,noGroupAction:h,groups:f,sections:E=[],type:y,hideBlankRows:p=!1,optionalFieldPlaceholder:A})=>{const[T,N]=R.useState([]),[C,b]=R.useState([]),{errors:I}=He(),{hooks:U}=Pe();R.useEffect(()=>{const x=(q,X)=>w.CheckYourAnswers.getRows(q,o,U.onGetCYARows).map((V,z)=>({...V,value:d.jsx(bn,{value:V.value,component:V.component,formData:q.formData,placeholder:A},`${X}_${z}`)})),$=w.CollectionPage.mergePages(n).map((q,X)=>{const G=x(q,X);return G?.length?{...q,rows:G}:null}).filter(q=>!!q);N($)},[n,o,N]);const g=i?0:cs,L=x=>x===T.length-1;R.useEffect(()=>{(()=>{const j=Array.isArray(f)?f.map($=>$.pageId):[];b(j)})()},[b,f]);const v=U.onGetCYA({title:e,pages:n,actions:s,onAction:r,onRowAction:o,hidePageTitles:i,hideActions:l,hideTitle:a,summaryListClassModifiers:c,noChangeAction:u,noGroupAction:h,groups:f,errors:I,sections:E,type:y});if(v)return v;const F=x=>C.includes(x),P=x=>f?.find(j=>j.pageId===x),k=(x,j)=>{if(!x.cya_link?.singleChangeLink||u)return d.jsxs(d.Fragment,{children:[j==="s"&&d.jsx(S.SmallHeading,{children:w.FormPage.getTitle(x.title,x.formData)}),j==="m"&&d.jsx(S.MediumHeading,{children:w.FormPage.getTitle(x.title,x.formData)})]});const $=vt(!1,x,o);return d.jsxs("div",{className:"heading-with-action",children:[d.jsxs("div",{className:"heading-text",children:[j==="s"&&d.jsx(S.SmallHeading,{children:w.FormPage.getTitle(x.title,x.formData)}),j==="m"&&d.jsx(S.MediumHeading,{children:w.FormPage.getTitle(x.title,x.formData)})]}),d.jsx("div",{className:"heading-action",children:d.jsx(Pn,{row:{action:$}})})]})},O=()=>Array.from(new Set(I.map(j=>j.id))).map(j=>I.find($=>$.id===j));return d.jsxs("div",{className:fd,children:[e&&!a&&d.jsx(S.Heading,{size:t,children:e},"heading"),I&&I.length>0&&d.jsx(S.ErrorSummary,{errors:O()}),y===ne.TASK_CYA&&T.length>0&&E&&E.map(x=>x.tasks.filter(j=>j.state!==H.TYPES.SKIPPED).map((j,$)=>{const q=T.filter(X=>j.pages.some(G=>G===X.name));return d.jsxs(R.Fragment,{children:[d.jsx(S.MediumHeading,{children:q.length>0&&(j.displayName||j.name)}),q.map((X,G)=>{const V=F(X.id)||u,z=!i&&X.title&&!F(X.id);return d.jsxs(R.Fragment,{children:[z&&k(X,"s"),d.jsx(cn,{rows:X.rows,classModifiers:c,noChangeAction:V,noGroupAction:h,isGroup:F(X.id)})]},G)})]},$)})),y!==ne.TASK_CYA&&T&&T.map((x,j,$)=>{const q=!p||x.collection?x.rows:x.rows.filter(pe=>pe?.value?.props?.value);if(q.length===0)return null;const X=!i&&x.title&&!F(x.id),G=L(j)||F($[j].id)||$.length>j+1&&F($[j+1].id)?cs:g,V=F(x.id)?P(x.id):void 0,z=`govuk-!-margin-bottom-${G}`,fe=F(x.id)||u;return d.jsxs(R.Fragment,{children:[X&&k(x,"m"),V&&d.jsx("div",{className:"group-title",children:d.jsx(S.MediumHeading,{children:V.title||w.FormPage.getTitle(x.title,x.formData)})}),d.jsx(cn,{className:z,rows:q,classModifiers:c,noChangeAction:fe,noGroupAction:h,isGroup:F(x.id)})]},j)}),!l&&d.jsx(_n,{actions:s?.filter(x=>w.Component.show(x,n[n.length-1].formData)),onAction:x=>r(x)})]})},pd=lr,Ed=({page:e,pages:t,onCollectionChange:n=void 0,onAction:s,hashLink:r=!1,classBlock:o=pd,classModifiers:i=[],className:l="",submitting:a=!1})=>{const[c,u]=R.useState({});let h=w.CollectionPage.getData(e.collection.name,e.formData)||[];const f=e.collection.name.split(".").pop();let E=w.CollectionPage.getActiveIndex(e.collection.name,e.formData);const y=e,p=({target:I})=>{w.CollectionPage.setData(y.collection.name,I.value,e.formData),h=I.value;const U=e.collection.name.split(".").shift();u(g=>({...g,[U]:w.CollectionPage.getData(U,e.formData)}))},A=({target:I})=>{y.formData[I.name]=I.value,u(U=>({...U,[I.name]:I.value}))},T=I=>{p({target:{value:I}}),typeof n=="function"&&n(e.formData)},N=I=>{E=h.length,A({target:{name:`${f}ActiveId`,value:I}})},C=I=>{s(I,c,{})},b=({target:I})=>{if(E===null){const U=_t.v4();N(U),T([...h,{id:U,[I.name]:I.value}])}else I.value&&(!Array.isArray(I.value)||(Array.isArray(I.value)&&I.value.length)>0)&&T([...h.slice(0,E),{...h[E],[I.name]:I.value},...h.slice(E+1)])};return e.collection?.waitForFormData&&e.formData&&Object.keys(e.formData).length===0?null:d.jsx(In,{page:{...e,formData:{...e.formData,...h[E],[`${f}ActiveIndex`]:E,[`${f}NumberedIndex`]:typeof E=="number"?E+1:null},components:e.components.map(I=>({...I,pageCollection:{...e.collection}}))},pages:t,onAction:C,onWrapperChange:b,onTopLevelChange:A,hashLink:r,classBlock:o,classModifiers:i,className:l,submitting:a})},Ad="hods-task-list",yd=({state:e=H.TYPES.CANNOT_START_YET})=>{const t=S.Utils.classBuilder(Ad,void 0,void 0),n=H.DETAILS[e]||H.DETAILS.cannotStartYet;return d.jsx(S.Tag,{classModifiers:n.colour,className:t("tag"),children:n.label})},Td="hods-task-list",Sd=({task:e,onClick:t})=>{const n=S.Utils.classBuilder(Td,void 0,void 0),[s,r]=R.useState(e.state!==H.TYPES.CANNOT_START_YET),[o,i]=R.useState(e.state);R.useEffect(()=>{r(e.state!==H.TYPES.CANNOT_START_YET),i(e.state)},[e.state,r,i]);const l=e.displayName||e.name;return d.jsxs("li",{className:n("item"),children:[d.jsx("span",{className:n("task-name"),children:s?d.jsx(S.Link,{onClick:()=>t(e),onKeyPress:a=>{a.key==="Enter"&&t(e)},tabIndex:0,children:l}):l}),d.jsx(yd,{state:o})]})},Cd="hods-task-list",gd="Incomplete form",bd=({id:e="",refTitle:t,refNumber:n,notes:s={},incompleteTitle:r=gd,showCompletionOverview:o=!0,sections:i,fieldId:l="",onTaskAction:a,classBlock:c=Cd,classModifiers:u=[],className:h="",formData:f={},annotations:E=[],...y})=>{const p=S.Utils.classBuilder(c,u,h),A=S.Utils.cleanHtmlAttributes(y),[T,N]=i.filter(g=>!g.skipped).reduce((g,L)=>[g[0]+(L.tasks?.filter(v=>v.state===H.TYPES.COMPLETE).length??0),g[1]+(L.tasks?.filter(v=>v.state!==H.TYPES.SKIPPED).length??0)],[0,0]),C=`${e}Notes`,{title:b,text:I}=s&&s||{},U=g=>{typeof a=="function"&&a(g)};return d.jsxs("div",{...A,id:e,className:p(),children:[n&&t&&d.jsxs(d.Fragment,{children:[d.jsx("p",{className:"govuk-body govuk-!-margin-bottom-0",children:d.jsx("strong",{className:"tasklist-summary",children:`${t}`})}),d.jsx("p",{className:"govuk-body govuk-!-font-weight-regular",children:`${n}`})]}),E.length>0&&E.map(g=>d.jsxs("div",{className:p("annotation"),children:[d.jsx("p",{className:`${p("annotation-key")} govuk-body`,children:S.Utils.interpolateString(g.key,f)}),d.jsx("p",{className:`${p("annotation-value")} govuk-body`,children:S.Utils.interpolateString(g.value,f)})]},g.key)),o&&N!==T&&d.jsx("p",{className:"govuk-body govuk-!-margin-bottom-0",children:d.jsx("strong",{className:"tasklist-summary",children:r})}),o&&d.jsx("p",{className:"govuk-body govuk-!-margin-bottom-7",children:`You have completed ${T} of ${N} sections`}),b&&I&&Ie(s,f)&&d.jsxs(d.Fragment,{children:[d.jsx("p",{className:"govuk-body govuk-!-margin-bottom-0",children:d.jsx("strong",{className:"tasklist-summary",children:S.Utils.interpolateString(b,f)})}),d.jsx(S.TextArea,{id:C,fieldId:C,readOnly:!0,value:S.Utils.interpolateString(I,f)})]}),i.filter(g=>!g.skipped).map((g,L)=>d.jsxs(R.Fragment,{children:[d.jsxs("h2",{className:p("section"),children:[i.length>1?`${L+1}. `:" ",g.name]}),g.label&&d.jsx(S.Hint,{children:g.label}),d.jsx("ol",{className:p("items"),children:g.tasks.filter(v=>v.state!==H.TYPES.SKIPPED).map(v=>d.jsx(Sd,{task:v,onClick:U},`${g.name}-${v.name}`))})]},`${g.name}`))]})},Br=(e,t)=>e?.page||t,wd=(e,t,n)=>{const s=Br(e.action,e.pageId);s!==t&&n(s)},_d=(e,t,n,s=void 0)=>{const r=Br(e,t);r!==t&&n(r,s)},Id=(e,t)=>{t(e)},Te={cyaAction:wd,navigate:_d,submissionError:Id},Pd=(e,t,n,s)=>e.validate?e.checkPreexistingErrors&&s.length!==0?!1:n(t).length===0:!0,xd=(e,t)=>t(e).length===0,Od=["radios","checkboxes"],Rd=(e,t)=>{const n=e.split("."),s={};return n.forEach(r=>{s[`${r}ActiveId`]=t[`${r}ActiveId`]}),s};function Nd(e,t){const n=[];return e?.data?.options?.forEach(s=>{!Ze(t,s)&&s.nested&&s.nested.forEach(r=>{n.push(r.id)})}),n}const $r=(e,t)=>{let n=e;if(t.components.forEach(s=>{if(!Od.includes(s.type))return;Nd(s,n[s.id]).forEach(o=>{delete n[o]})}),t.collection){n={...Rd(t.collection.name,t.formData),...n};const s=Ge(t.collection.name,n);if(s){const r=Ut(t.collection.name,n),o=s.map(i=>i.id===r?$r(i,{...t,collection:void 0}):i);On(t.collection.name,o,n)}}return n},Ld=(e,t,n)=>{if(e===re.HUB&&n===ye.CYA)return{title:""};if(e===re.CYA)return{};const s=t?.find(r=>r.id===e);if(s?.type===re.PARTIAL_CYA){const r=w.FormPage.applyConditionalProperties(s);return{title:r.title,hideChangeActions:r.hideChangeActions,hideGroupActions:r.hideGroupActions}}},Yr=(e,t,n)=>{if(e)return e===re.HUB?n===ye.CYA||n===ye.TASK?void 0:n:t.find(s=>s.id===e)},Dd=(e,t,n)=>({pageId:e,cya:Ld(e,t,n),page:Yr(e,t,n)}),us=(e,t)=>e.slice(0,e.findIndex(n=>n?.id===t)),vd=(e,t,n)=>e.page?.type===re.PARTIAL_CYA?us(n||t,e.pageId):n||t,ds=(e,t,n,s,r)=>{if(!t&&r===ne.FORM_WITH_TASK){if(s?.formStatus?.taskPage){const i=n.find(l=>l.id===s.formStatus.taskPage);return i?.type==="pre-task-list"?i.id:re.HUB}return n.length>0?n[0].id:void 0}let o;return e?.pages?.forEach(i=>{it.show({show_when:i.show_when},s)&&(o=i.pageId)}),o||e?.page||re.HUB},Hr=(e,t,n)=>{let s=e.findIndex(o=>o.id===t)+1,r=e[s];for(;r&&!it.show(r,n);)s+=1,r=e[s];return r?.id||void 0},Fd=(e,t,n)=>Hr(e,t,n)||re.CYA,jd=e=>e.length>0?e[0].id:void 0,un=(e,t,n,s,r)=>{if(s){if(s.type===W.TYPES.NAVIGATE)return t.find(o=>o.id===s.page)?s.page:void 0;if(s.type===W.TYPES.SAVE_AND_RETURN)return e===ne.HUB?re.HUB:void 0}switch(e){case ne.HUB:return ds(s);case ne.CYA:return Fd(t,n,r);case ne.FORM_WITH_TASK:case ne.TASK:return ds(s,n,t,r,e);case ne.WIZARD:return Hr(t,n,r);default:return jd(t)}},Ud=(e,t,n,s,r,o,i,l)=>{if(e===ne.TASK||e===ne.FORM_WITH_TASK){const a=r.formStatus||{};return a.tasks=a.tasks||{},a.tasks[o.name]=a.tasks[o.name]||{},n===(re.CYA||"submitForm")&&i?a.tasks[o.name].complete=!0:o.name?s?.type===W.TYPES.SAVE_AND_NAVIGATE?a.tasks[o.name]={complete:!1,currentPage:un(e,t,n,s,r)}:o.pages?.includes(n)&&(a.tasks[o.name]={complete:!!s?.complete,currentPage:n}):l&&l.forEach(c=>{c.tasks.forEach(u=>{const h=u.pages[u.pages.length-1];(h===n||h.id===n)&&i&&u?.type==="pre-task-list"?a.tasks[u.name]={complete:i,currentPage:n}:u.pages.includes(n)&&u?.type==="pre-task-list"&&(a.tasks[u.name]={complete:!1,currentPage:n})})}),a.taskPage=a.tasks[o.name].currentPage,a}return s?.type===W.TYPES.SAVE_AND_RETURN?{page:n}:{page:un(e,t,n,s,r)}},Md=({complete:e,currentPage:t},n=H.TYPES.NOT_STARTED)=>e?H.TYPES.COMPLETE:t||e!==void 0&&!e&&t===void 0?H.TYPES.IN_PROGRESS:n,kd=(e,t,n=!1)=>t.reduce((s,r)=>{const o=e[r];return n&&o?.state===H.TYPES.SKIPPED?s:s&&o?.complete},!0),Vr=(e,t)=>{const n=e[t-1].state;return n===H.TYPES.COMPLETE?!0:n===H.TYPES.SKIPPED?t-1===0?!0:Vr(e,t-1):!1},Bd=(e,t,n,s,r=!1,o=!0)=>{if(s[e.name])return Md(s[e.name],e.state);if(r)return e.depends_on&&!kd(s,e.depends_on,e.ignoreSkipped)?H.TYPES.CANNOT_START_YET:H.TYPES.NOT_STARTED;let i=o;return t&&(i=Vr(n,t)),i?H.TYPES.NOT_STARTED:H.TYPES.CANNOT_START_YET},$d=(e,t,n,s)=>{const r=e.tasks.map(o=>({...o}));return r.filter(o=>o.state!==H.TYPES.SKIPPED).forEach((o,i)=>{const l=o;l.state=Bd(l,i,r,t,n,s)}),r},qr=(e,t)=>{const n=e[t-1]?.tasks.slice(-1)[0]?.state;return n===H.TYPES.COMPLETE?!0:n===H.TYPES.SKIPPED?t-1===0?!0:qr(e,t-1):!1},Yd=(e,t,n=!1,s=null)=>{const r=e.map(i=>{const l=i.show_when?[i.show_when].flat():[];return s&&!w.Condition.meetsAll(l,s)?{...i,skipped:!0,tasks:i.tasks.map(a=>({...a,state:H.TYPES.SKIPPED}))}:{...i}});r.forEach(i=>{const l=i;l.tasks=l.tasks.map(a=>{const c=a.show_when?[a.show_when].flat():[];return s&&!w.Condition.meetsAll(c,s)?{...a,state:H.TYPES.SKIPPED}:{...a}})});const o={...t};return r.forEach(i=>{i.tasks.filter(l=>l.state===H.TYPES.SKIPPED).forEach(l=>{o[l.name]={...o[l.name],state:H.TYPES.SKIPPED}})}),r.forEach((i,l)=>{const a=i,c=l===0||qr(r,l);a.tasks=$d(a,o,n,c)}),r},Hd=(e,t,n)=>{n.has(e)||n.set(e,[]),n.get(e).push(t)},ke=(e,t)=>{if(Array.isArray(e))for(let r=0;r<e.length;r+=1)ke(e[r],t);const n=t.split(".");let s=e;for(let r=0;r<n.length-1;r+=1)if(s=s[n[r]],s===void 0)return;s[n[n.length-1]]&&delete s[n[n.length-1]]},Gr=e=>{if(typeof e!="string"||!e.includes("."))return null;const t=e.split(".");return t.pop(),t.join(".")},Dn=(e,t)=>{const n=Gr(e);return n?`${n}.${t}`:t},Vd=e=>{for(let t=e.length-1;t>=0;t-=1){const n=e[t];Object.keys(n).length===1&&Object.keys(n)[0]==="id"&&e.splice(t,1)}},qd=e=>{const t=(n,s)=>(typeof n=="object"&&n!==null&&(Array.isArray(n)?n.forEach(r=>{t(r,s)}):Object.keys(n).forEach(r=>{r==="field"&&s.push(n[r]),t(n[r],s)})),s);return e.show_when?new Set(t(e.show_when,[])||[]):null},Gd=(e,t)=>{const n=e.split(".");for(let s=n.length;s>0;s-=1){const r=n.slice(0,s).join("."),o=t.get(r);if(o)return o}return null},Je=(e,t)=>e.show_when?e.show_when?.type==="or"?ae.meetsOne(e,t):ae.meetsAll(e,t):!0,Kr=(e,t,n)=>{const s=t.get(e.use)??n.get(e.use)??e,r=JSON.parse(JSON.stringify(s));return e.use&&e.show_when&&(r.show_when=e.show_when),r},Kd=(e,t,n)=>{const{meta:{documents:s}}=n,r=t[e.fieldId];if(!s||!r)return;const o=Array.isArray(r)?r:[r];for(let i=o.length-1;i>=0;i-=1){const l=s.findIndex(a=>a.url===o[i].url);l!==-1&&s.splice(l,1)}},dn=e=>{if(Array.isArray(e))for(let t=e.length-1;t>=0;t-=1)Array.isArray(e[t])&&e[t].length===0?e.splice(t,1):dn(e[t]),typeof e[t]=="object"&&Object.keys(e[t]).length===0&&e.splice(t,1);else e!==null&&typeof e=="object"&&Object.keys(e).forEach(t=>{Array.isArray(e[t])&&e[t].length===0?(e[`${t}ActiveId`]&&delete e[`${t}ActiveId`],delete e[`${t}ActiveId`],e[t]&&delete e[t]):dn(e[t])})},Wr=(e,t)=>{e?.data?.options&&e?.data?.options?.forEach(n=>{n.nested?.forEach(t)})},Wd=(e,t,n,s)=>{if(s[t]>1)s[t]-=1;else{if(n.preserveInPayload)return;ke(e,t),Wr(n,r=>{const o=Dn(t,r.fieldId);s[o]>1?s[o]-=1:ke(e,o)})}},zd=(e,t,n,s)=>{t.forEach(r=>{if(!e.has(r.fieldId)){if(r.type==="multifile"&&Kd(r,n,s),r.preserveInPayload)return;ke(n,r.fieldId),Wr(r,o=>{const i=Dn(r.fieldId,o.fieldId);e.has(i)||ke(n,i)})}})},fs=e=>Array.isArray(e)?e:[e],Jd=(e,t,n,s)=>{const r=new Map,o={},i=[],l=new Map,a=(c,u,h)=>{u.fieldId&&(h=h?`${h}.${u.fieldId}`:u.fieldId,o[h]=(o[h]||0)+1,u.path=h,c.show_when&&(u.show_when=u.show_when?[...fs(c.show_when),...fs(u.show_when)]:c.show_when),Hd(h,u,r),u.components?u.components.forEach(f=>{a(c,f,h)}):u?.data?.options&&u?.data?.options?.forEach(f=>{if(f.nested){const E=!Ze(se(s,h),f),y=f.show_when;f.nested.forEach(p=>{E&&i.push(Dn(h,p.fieldId)),y&&(p.show_when=y),a(c,p,Gr(h))})}}))};return e?.forEach(c=>{c.childPages?l.set(c.collection.name,c):c.components?.forEach(u=>{const h=Kr(u,t,n);a(c,h,null)})}),i.forEach(c=>{o[c]>1?o[c]-=1:ke(s,c)}),{allComponents:r,componentsToKeep:o,allCollections:l}},Xd=e=>{const t=new Map;return e?.forEach(n=>{n?.forEach(s=>{if(!s.fieldId)return;const r=qd(s);if(r)if(t.has(s.path)){const o=t.get(s.path);r.forEach(i=>o.add(i))}else t.set(s.path,new Set(r))})}),t},Qd=(e,t,n,s,r,o)=>{const i=(a,c,u)=>{if(a.has(c))return;a.add(c),u.get(c.path)?.forEach(f=>{const E=Gd(f,t);if(E)E.forEach(y=>{a.has(y)||i(a,y,u)});else{const y=/([a-zA-Z_$][\w$]*)\[\d+\]/,p=f.match(y);if(p){const A=p[1],T=s.get(A);T&&T.childPages?.forEach(N=>{if(N.show_when){const C=JSON.stringify(N.show_when),b=`It is not possible to reliably clean hidden data when a component is dependent on a
10
10
  collection's data, and that collection is itself dependent on data elsewhere in the form.
11
11
  The dependency path is ${f}, and the chained show_when is ${C}.
12
- The form will need to be changed to break this chained dependency`;throw new Error(b)}})}}}),Je(c,o)||Wd(o,c.path,c,n)},l=new Set;e?.forEach((a,c)=>{t.get(c)?.forEach(h=>{l.has(h)||i(l,h,e)})})},Zd=(e,t,n,s)=>{e?.forEach((r,o)=>{Je(r,t)||(delete t[o],delete t[`${o}ActiveId`]);const i=t[o];i?.forEach(l=>{const a={...t,...l},c=new Set,u=new Map;r.childPages?.forEach(h=>{const f=Je(h,a);h.components?.forEach(E=>{const y=Kr(E,n,s);if(!y.fieldId)return;const p=Je(E,a);f&&p&&Je(y,a)?c.add(y.fieldId):u.set(y.id,y)})}),zd(c,u,l,t)}),i&&Vd(i)})},ef=(e,t,n)=>{if(!e)return n;const s=new Map(t.components.map(u=>[u.id,u])),r=new Map(t.components.map(u=>[u.fieldId,u])),o=wr(t.pages),{allComponents:i,componentsToKeep:l,allCollections:a}=Jd(o,s,r,n),c=Xd(i);return Qd(c,i,l,a,t,n),Zd(a,n,s,r),dn(n),n},Q={canActionProceed:Pd,canCYASubmit:xd,cleanHiddenNestedData:$r,getFormState:Dd,getRelevantPages:vd,getNextPageId:un,getPage:Yr,getSubmissionStatus:Ud,getUpdatedSectionStates:Yd,clearOutUncompletedRoutes:ef},tf=(e,t,n,s,r,o,i,l,a,c,u,h,f,E,y,p,A,T)=>{if(t.type===W.TYPES.SUBMIT&&E!==ye.TASK){if(e("submit"),Q.canCYASubmit(n,s.pages)&&!A){T(!0);const N=w.Format.form({pages:n,components:o},{...i},we.SUBMIT),C={pages:n,components:o};Q.clearOutUncompletedRoutes(r,C,N),N.formStatus=Q.getSubmissionStatus(a,n,c,t,N,u,!0),l(N),h.onSubmit(t.type,N,()=>{h.onFormComplete(),T(!1)},b=>{T(!1),Te.submissionError(b,f)})}}else{const C=!(Object.prototype.hasOwnProperty.call(t,"validate")&&!t.validate)?Q.canCYASubmit(u.fullPages,s.pages):!0;if(t.type===W.TYPES.SAVE_AND_CONTINUE&&E===ye.TASK&&C){const b=w.Format.form({pages:n,components:o},{...i},we.SUBMIT);b.formStatus=Q.getSubmissionStatus(a,n,c,t,b,u,!0),l(b),h.onSubmit(t.type,b,()=>{T(!1),y(re.HUB)},P=>{T(!1),Te.submissionError(P,f)})}if(t.type===W.TYPES.SUBMIT&&E===ye.TASK&&(e("submit"),C)){const b=w.Format.form({pages:n,components:o},{...i},we.SUBMIT),P={pages:n,components:o};Q.clearOutUncompletedRoutes(r,P,b),b.formStatus=Q.getSubmissionStatus(a,n,c,t,b,u,!0),l(b),h.onSubmit(t.type,b,()=>{h.onFormComplete(),T(!1)},U=>{T(!1),Te.submissionError(U,f)})}if(t.type===W.TYPES.SAVE_AND_NAVIGATE&&C){const b=w.Format.form({pages:n,components:o},{...i},we.SUBMIT);b.formStatus=Q.getSubmissionStatus(a,n,c,t,b,u,!0),l(b),h.onSubmit(t.type,b,()=>{T(!1),y(t.page)},P=>{T(!1),Te.submissionError(P,f)})}if(t.type===W.TYPES.SAVE_AND_RETURN&&C){const b=w.Format.form({pages:n,components:o},{...i},we.SUBMIT);b.formStatus=Q.getSubmissionStatus(a,n,c,t,b,u,!1),l(b),h.onSubmit(t.type,b,()=>{a===ne.TASK?y(void 0):y(re.HUB),T(!1)},P=>{T(!1),Te.submissionError(P,f)})}if(t.type===W.TYPES.NAVIGATE&&(y(Q.getNextPageId(a,n,c,t,p.page?.formData)),T(!1)),t.type===W.TYPES.CANCEL){const b=w.Format.form({pages:n,components:o},{...i},we.CANCEL);h.onCancel(b),T(!1)}}},hs=(e,t,n,s,r,o,i,l,a,c,u,h,f,E,y,p,A,T,N,C,b,P)=>{const U={...r},g=o,L=s.onAction(g.page.formData,t,r,e.customAction);g.page.formData=L.formData;let v=L.patch;if(g.page.formData={...g.page.formData,...v},e.type===W.TYPES.CANCEL){s.onCancel(g.page.formData),b(!1);return}if(Q.canActionProceed(e,g.page,i.page,P)&&(!C||e.ignoreSubmittingFlag))if(v=Q.cleanHiddenNestedData(v,g.page),b(!0),e.addToFormData&&((Array.isArray(e.addToFormData)?e.addToFormData:[e.addToFormData]).forEach(I=>{I.isCollection?On(I.field,I.value,o.page.formData):w.Data.setDataItem(o.page.formData,I.field,I.value)}),g.page.formData[e.addToFormData.field]=e.addToFormData.value),e.type===W.TYPES.NAVIGATE)Te.navigate(e,f,l),b(!1);else{let F=G=>l(Q.getNextPageId(a,u,f,e,G)),I,k;e.collection&&(I=e.collection,k=`addAnother${I.charAt(0).toUpperCase()+I.slice(1)}`.slice(0,-1));let O,x;switch(I&&(O=g.page.formData[I],O&&O.length>0&&g.page.formData[`${I}ActiveId`]&&(x=O.findIndex(G=>G.id===g.page.formData[`${I}ActiveId`]))),e.type){case W.TYPES.SUBMIT:E("submit");break;case W.TYPES.SAVE_AND_NAVIGATE:const G={...y};O&&O.length>0&&e.resetActiveId&&(g.page.formData[`${I}ActiveId`]=O[0].id),O&&O.length>0&&!e.resetActiveId&&(x!==void 0&&x+1<g.page.formData[I].length&&(g.page.formData[k]="Yes"),x!==void 0&&x+1===g.page.formData[I].length&&g.page.formData[k]&&(g.page.formData[k]="No")),F=()=>Te.navigate(e,f,l,G);break;case W.TYPES.COLLECTION_ADD:if(x===void 0||O.length===0||x+1===g.page.formData[I].length?w.CollectionPage.addEntry(e.collection,g.page.formData):g.page.formData[`${e.collection}ActiveId`]=O[x+1].id,g.page.formData[`${e.collection}`]&&g.page.formData[`${e.collection}`].length>0){const pe=g.page.formData[`${e.collection}`].length-1;Object.keys(g.page.formData[`${e.collection}`][pe]).filter(J=>J in g.page.formData&&J!=="id").forEach(J=>delete g.page.formData[J])}F=()=>Te.navigate(e,f,l);break;case W.TYPES.COLLECTION_DUPLICATE:w.CollectionPage.duplicateActiveEntry(e.collection,o.page.formData)&&(F=()=>Te.navigate(e,f,l));break;case W.TYPES.COLLECTION_REMOVE:const V=e.targetId||g.page.formData[`${e.collection.split(".").pop()}ActiveId`],z=w.CollectionPage.removeEntry(e.collection,o.page.formData,V);e.recordRemoval&&(g.page.formData[`${e.collection.split(".").pop()}LastRemoved`]={...z});const fe=g.page.formData.id;z!==null&&Object.keys(z).filter(Y=>Y in g.page.formData).forEach(Y=>delete g.page.formData[Y]),Object.assign(g.page.formData,O[O.length-1]),g.page.formData.id=fe,O.length>0?g.page.formData[`${e.collection}ActiveId`]=O[O.length-1].id:(delete g.page.formData[`${e.collection}ActiveId`],delete g.page.formData[e.collection]),F=()=>Te.navigate(e,f,l);break}w.Data.deleteValues(r,o.page.formData);const j=w.Format.form({pages:u,components:h},{...r,...t,...o.page.formData},we.SUBMIT);j.formStatus=Q.getSubmissionStatus(a,u,f,e,j,y,!0,A?.sections),v&&p(j);const $={pages:u,components:h};e.type===W.TYPES.SUBMIT&&Q.clearOutUncompletedRoutes(c,$,j);let q,X;a===ne.HUB&&Object.keys(n).length>0&&(q=Object.keys(n)[0],X=Object.values(n)[0]),s.onSubmit(e.type,j,G=>{const V={...j,...G};T({data:V}),F(V),b(!1)},(G,V=!0)=>{Te.submissionError(G,N),V&&p({...U}),b(!1)},q,X,f)}},ms=(e,t,n,s,r,o)=>{if(e){const i=e;i.fullPages=[],i.pages.forEach(a=>{i.fullPages.push(Q.getPage(a,t))}),n(e);const l={...i};if(i.state===H.TYPES.COMPLETE&&!i.alwaysShowFirstPage)if(s?.noTaskCYAs){const a=r.formStatus.tasks[e.name].currentPage;o(i.pages[0]||a)}else i.customCYA?o(i.customCYA):o(re.CYA,l);else if(i.state===H.TYPES.IN_PROGRESS&&!i.alwaysShowFirstPage){const a=r.formStatus.tasks[e.name].currentPage;o(a||e.pages[0],l)}else i.firstPage?o(i.firstPage,l):o(i.pages[0],l)}},zr=({title:e,titleSize:t,type:n,cleanseHiddenData:s=!1,components:r,pages:o,hub:i={nonSequential:!1,sections:[]},cya:l={actions:[],disableTaskSwitch:!1},data:a,hashLink:c=!1,hooks:u,classBlock:h=nf,classModifiers:f=[],className:E="",hide_title:y,summaryListClassModifiers:p=[],noChangeAction:A=!1,newPageId:T="",viewOnly:N=!0,hideBlankRows:C=!1})=>d.jsx(sr,{overrides:u,children:d.jsx(rr,{children:d.jsx(sf,{title:e,titleSize:t,type:n,cleanseHiddenData:s,components:r,pages:o,hub:i,cya:l,data:a,classBlock:h,classModifiers:f,className:E,hashLink:c,hide_title:y,summaryListClassModifiers:p,noChangeAction:A,newPageId:T,viewOnly:N,hideBlankRows:C})})}),nf="hods-form",sf=({title:e,titleSize:t,type:n,cleanseHiddenData:s,components:r,pages:o,hub:i,cya:l,data:a,classBlock:c,classModifiers:u,className:h,hashLink:f,hide_title:E,summaryListClassModifiers:y,noChangeAction:p,newPageId:A,viewOnly:T,hideBlankRows:N})=>{const[C,b]=R.useState({}),[P,U]=R.useState(),[g,L]=R.useState([]),[v,F]=R.useState(void 0),[I,k]=R.useState(Q.getNextPageId(n,o,null,null,a)),[O,x]=R.useState(Q.getFormState(I,g,v)),[j,$]=R.useState({}),[q,X]=R.useState({}),[G,V]=R.useState("load"),[z,fe]=R.useState(!1),[pe,Y]=R.useState(!1),{hooks:J}=Pe(),{addErrors:Ke,clearErrors:We,errors:Ee,validate:xe}=He();window.onpopstate=B=>{if(!document.location.hash&&(B.state&&B.state.fullPages!==void 0&&$(ee=>({...ee,fullPages:B.state?.fullPages})),We(),fe(!0),J.onGoingBack(B.state?B.state:null,O.page?.formData),r&&g&&C&&O.page?.formData&&G===void 0)){const ee=w.Format.form({pages:g,components:r},{...C,...O.page.formData},we.SUBMIT);if(ee?.formStatus?.taskPage){const ie=ee.formStatus.tasks;Object.keys(ie).forEach(_e=>{const Fn=ie[_e];Fn.currentPage&&!Fn.complete&&delete ie[_e].currentPage}),delete ee.formStatus.taskPage}b(ee)}},R.useEffect(()=>{r&&o&&a&&(G==="load"||T)&&(b(w.Data.setupForm(o,r,a)),a.formStatus?.page&&k(a.formStatus.page))},[r,o,a,b,G,T]),R.useEffect(()=>{L(w.FormPage.getAll(o,r,{...C}))},[r,o,C,L]),R.useEffect(()=>{k(B=>B||Q.getNextPageId(n,g))},[n,g,k]),R.useEffect(()=>{F(w.Hub.get(n,i,r,{...C}))},[n,i,C,r,F]),R.useEffect(()=>{n===ne.HUB&&z&&C&&O.page?.formData&&(O.page.formData={...C}),fe(!1),x(Q.getFormState(I,g,v))},[g,v,I,x,n,z,C,O.page]),R.useEffect(()=>{V(void 0),J.onFormLoad(B=>{$(B)})},[J]),R.useEffect(()=>{X(i)},[i]),R.useEffect(()=>{P?.data&&(b(P.data),U(void 0))},[P,b,U]);const Ae=i?.sections,M=i?.nonSequential;R.useEffect(()=>{const B=j.fullPages;if(B&&(B.forEach(ee=>{const ie=ee;ie&&(ie.formData=C)}),$(ee=>({...ee,fullPages:B}))),Ae){const ee=C?.formStatus?.tasks||{},ie=Q.getUpdatedSectionStates(Ae,ee,M,C);X(_e=>({..._e,sections:[...ie]}))}},[j.fullPages,C,Ae,M]);const oe=(B,ee={})=>{We(),k(B),J.onPageChange(B,ee)};R.useEffect(()=>{A!==void 0&&k(A)},[A]);const be=B=>{J.onChange(B)},ve=(B,ee)=>{if(typeof ee=="function"){const ie=ee({...C});ie&&b(ie)}O.page?.type===re.PARTIAL_CYA&&!l.disableTaskSwitch&&q.sections.every(ie=>ie.tasks.every(_e=>_e.pages.includes(B.pageId)&&_e.name!==j.name?(ms(_e,g,$,q,C,oe),!1):!0)),B&&Te.cyaAction(B,I,oe)},lt=w.classBuilder(c,u,h);if(v===ye.TASK){const B=l;B.actions=[W.TYPES.SAVE_AND_CONTINUE,W.TYPES.SAVE_AND_RETURN]}const{noTaskCYAs:vn,nonSequential:Fe,...Jr}=q;return d.jsxs("div",{className:lt(),children:[e&&!E&&I===re.HUB&&d.jsx(S.Heading,{size:t,children:e}),O.cya&&d.jsx(md,{pages:Q.getRelevantPages(O,g,j.fullPages),...l,...O.page?.type===re.PARTIAL_CYA&&{actions:O.page.actions?.filter(B=>w.Component.show(B,C))},...O.cya,onAction:B=>{tf(V,B,g,xe,s,r,C,b,n,I,j,J,Ke,v,oe,O,pe,Y)},onRowAction:ve,summaryListClassModifiers:y,hide_title:E,noChangeAction:O.cya.hideChangeActions??p,noGroupAction:O.cya.hideGroupActions??!1,sections:typeof q<"u"?q.sections:[],type:n,hideBlankRows:N}),v===ye.TASK&&O.pageId===re.HUB&&d.jsx(bd,{...Jr,refNumber:C.businessKey,onTaskAction:B=>{ms(B,g,$,q,C,oe)},annotations:q?.taskListAnnotations||[],formData:C}),O.page&&!O.cya&&!O.page.collection&&d.jsx(In,{page:O.page,pages:[...g],onAction:(B,ee,ie)=>{hs(B,ee,ie,J,C,O,xe,oe,n,s,g,r,I,V,j,b,q,U,Ke,pe,Y,Ee)},onChange:be,hashLink:f,classModifiers:O.page.classModifiers,className:O.page.className,submitting:pe,pageId:I}),O.page&&!O.cya&&O.page.collection&&d.jsx(Ed,{page:O.page,pages:g,onCollectionChange:be,onAction:(B,ee,ie)=>{hs(B,ee,ie,J,C,O,xe,oe,n,s,g,r,I,V,j,b,q,U,Ke,pe,Y,Ee)},hashLink:f,classModifiers:O.page.classModifiers,className:O.page.className,submitting:pe})]})};exports.Container=Ln;exports.FormComponent=Ve;exports.FormRenderer=zr;exports.FormTypes=ne;exports.HooksContextProvider=sr;exports.HubFormats=ye;exports.Models=$o;exports.PageActions=_n;exports.SummaryList=cn;exports.Utils=w;exports.ValidationContextProvider=rr;exports.default=zr;
12
+ The form will need to be changed to break this chained dependency`;throw new Error(b)}})}}}),Je(c,o)||Wd(o,c.path,c,n)},l=new Set;e?.forEach((a,c)=>{t.get(c)?.forEach(h=>{l.has(h)||i(l,h,e)})})},Zd=(e,t,n,s)=>{e?.forEach((r,o)=>{Je(r,t)||(delete t[o],delete t[`${o}ActiveId`]);const i=t[o];i?.forEach(l=>{const a={...t,...l},c=new Set,u=new Map;r.childPages?.forEach(h=>{const f=Je(h,a);h.components?.forEach(E=>{const y=Kr(E,n,s);if(!y.fieldId)return;const p=Je(E,a);f&&p&&Je(y,a)?c.add(y.fieldId):u.set(y.id,y)})}),zd(c,u,l,t)}),i&&Vd(i)})},ef=(e,t,n)=>{if(!e)return n;const s=new Map(t.components.map(u=>[u.id,u])),r=new Map(t.components.map(u=>[u.fieldId,u])),o=wr(t.pages),{allComponents:i,componentsToKeep:l,allCollections:a}=Jd(o,s,r,n),c=Xd(i);return Qd(c,i,l,a,t,n),Zd(a,n,s,r),dn(n),n},Q={canActionProceed:Pd,canCYASubmit:xd,cleanHiddenNestedData:$r,getFormState:Dd,getRelevantPages:vd,getNextPageId:un,getPage:Yr,getSubmissionStatus:Ud,getUpdatedSectionStates:Yd,clearOutUncompletedRoutes:ef},tf=(e,t,n,s,r,o,i,l,a,c,u,h,f,E,y,p,A,T)=>{if(t.type===W.TYPES.SUBMIT&&E!==ye.TASK){if(e("submit"),Q.canCYASubmit(n,s.pages)&&!A){T(!0);const N=w.Format.form({pages:n,components:o},{...i},we.SUBMIT),C={pages:n,components:o};Q.clearOutUncompletedRoutes(r,C,N),N.formStatus=Q.getSubmissionStatus(a,n,c,t,N,u,!0),l(N),h.onSubmit(t.type,N,()=>{h.onFormComplete(),T(!1)},b=>{T(!1),Te.submissionError(b,f)})}}else{const C=!(Object.prototype.hasOwnProperty.call(t,"validate")&&!t.validate)?Q.canCYASubmit(u.fullPages,s.pages):!0;if(t.type===W.TYPES.SAVE_AND_CONTINUE&&E===ye.TASK&&C){const b=w.Format.form({pages:n,components:o},{...i},we.SUBMIT);b.formStatus=Q.getSubmissionStatus(a,n,c,t,b,u,!0),l(b),h.onSubmit(t.type,b,()=>{T(!1),y(re.HUB)},I=>{T(!1),Te.submissionError(I,f)})}if(t.type===W.TYPES.SUBMIT&&E===ye.TASK&&(e("submit"),C)){const b=w.Format.form({pages:n,components:o},{...i},we.SUBMIT),I={pages:n,components:o};Q.clearOutUncompletedRoutes(r,I,b),b.formStatus=Q.getSubmissionStatus(a,n,c,t,b,u,!0),l(b),h.onSubmit(t.type,b,()=>{h.onFormComplete(),T(!1)},U=>{T(!1),Te.submissionError(U,f)})}if(t.type===W.TYPES.SAVE_AND_NAVIGATE&&C){const b=w.Format.form({pages:n,components:o},{...i},we.SUBMIT);b.formStatus=Q.getSubmissionStatus(a,n,c,t,b,u,!0),l(b),h.onSubmit(t.type,b,()=>{T(!1),y(t.page)},I=>{T(!1),Te.submissionError(I,f)})}if(t.type===W.TYPES.SAVE_AND_RETURN&&C){const b=w.Format.form({pages:n,components:o},{...i},we.SUBMIT);b.formStatus=Q.getSubmissionStatus(a,n,c,t,b,u,!1),l(b),h.onSubmit(t.type,b,()=>{a===ne.TASK?y(void 0):y(re.HUB),T(!1)},I=>{T(!1),Te.submissionError(I,f)})}if(t.type===W.TYPES.NAVIGATE&&(y(Q.getNextPageId(a,n,c,t,p.page?.formData)),T(!1)),t.type===W.TYPES.CANCEL){const b=w.Format.form({pages:n,components:o},{...i},we.CANCEL);h.onCancel(b),T(!1)}}},hs=(e,t,n,s,r,o,i,l,a,c,u,h,f,E,y,p,A,T,N,C,b,I)=>{const U={...r},g=o,L=s.onAction(g.page.formData,t,r,e.customAction);g.page.formData=L.formData;let v=L.patch;if(g.page.formData={...g.page.formData,...v},e.type===W.TYPES.CANCEL){s.onCancel(g.page.formData),b(!1);return}if(Q.canActionProceed(e,g.page,i.page,I)&&(!C||e.ignoreSubmittingFlag))if(v=Q.cleanHiddenNestedData(v,g.page),b(!0),e.addToFormData&&((Array.isArray(e.addToFormData)?e.addToFormData:[e.addToFormData]).forEach(P=>{P.isCollection?On(P.field,P.value,o.page.formData):w.Data.setDataItem(o.page.formData,P.field,P.value)}),g.page.formData[e.addToFormData.field]=e.addToFormData.value),e.type===W.TYPES.NAVIGATE)Te.navigate(e,f,l),b(!1);else{let F=G=>l(Q.getNextPageId(a,u,f,e,G)),P,k;e.collection&&(P=e.collection,k=`addAnother${P.charAt(0).toUpperCase()+P.slice(1)}`.slice(0,-1));let O,x;switch(P&&(O=g.page.formData[P],O&&O.length>0&&g.page.formData[`${P}ActiveId`]&&(x=O.findIndex(G=>G.id===g.page.formData[`${P}ActiveId`]))),e.type){case W.TYPES.SUBMIT:E("submit");break;case W.TYPES.SAVE_AND_NAVIGATE:const G={...y};O&&O.length>0&&e.resetActiveId&&(g.page.formData[`${P}ActiveId`]=O[0].id),O&&O.length>0&&!e.resetActiveId&&(x!==void 0&&x+1<g.page.formData[P].length&&(g.page.formData[k]="Yes"),x!==void 0&&x+1===g.page.formData[P].length&&g.page.formData[k]&&(g.page.formData[k]="No")),F=()=>Te.navigate(e,f,l,G);break;case W.TYPES.COLLECTION_ADD:if(x===void 0||O.length===0||x+1===g.page.formData[P].length?w.CollectionPage.addEntry(e.collection,g.page.formData):g.page.formData[`${e.collection}ActiveId`]=O[x+1].id,g.page.formData[`${e.collection}`]&&g.page.formData[`${e.collection}`].length>0){const pe=g.page.formData[`${e.collection}`].length-1;Object.keys(g.page.formData[`${e.collection}`][pe]).filter(J=>J in g.page.formData&&J!=="id").forEach(J=>delete g.page.formData[J])}F=()=>Te.navigate(e,f,l);break;case W.TYPES.COLLECTION_DUPLICATE:w.CollectionPage.duplicateActiveEntry(e.collection,o.page.formData)&&(F=()=>Te.navigate(e,f,l));break;case W.TYPES.COLLECTION_REMOVE:const V=e.targetId||g.page.formData[`${e.collection.split(".").pop()}ActiveId`],z=w.CollectionPage.removeEntry(e.collection,o.page.formData,V);e.recordRemoval&&(g.page.formData[`${e.collection.split(".").pop()}LastRemoved`]={...z});const fe=g.page.formData.id;z!==null&&Object.keys(z).filter(Y=>Y in g.page.formData).forEach(Y=>delete g.page.formData[Y]),Object.assign(g.page.formData,O[O.length-1]),g.page.formData.id=fe,O.length>0?g.page.formData[`${e.collection}ActiveId`]=O[O.length-1].id:(delete g.page.formData[`${e.collection}ActiveId`],delete g.page.formData[e.collection]),F=()=>Te.navigate(e,f,l);break}w.Data.deleteValues(r,o.page.formData);const j=w.Format.form({pages:u,components:h},{...r,...t,...o.page.formData},we.SUBMIT);j.formStatus=Q.getSubmissionStatus(a,u,f,e,j,y,!0,A?.sections),v&&p(j);const $={pages:u,components:h};e.type===W.TYPES.SUBMIT&&Q.clearOutUncompletedRoutes(c,$,j);let q,X;a===ne.HUB&&Object.keys(n).length>0&&(q=Object.keys(n)[0],X=Object.values(n)[0]),s.onSubmit(e.type,j,G=>{const V={...j,...G};T({data:V}),F(V),b(!1)},(G,V=!0)=>{Te.submissionError(G,N),V&&p({...U}),b(!1)},q,X,f)}},ms=(e,t,n,s,r,o)=>{if(e){const i=e;i.fullPages=[],i.pages.forEach(a=>{i.fullPages.push(Q.getPage(a,t))}),n(e);const l={...i};if(i.state===H.TYPES.COMPLETE&&!i.alwaysShowFirstPage)if(s?.noTaskCYAs){const a=r.formStatus.tasks[e.name].currentPage;o(i.pages[0]||a)}else i.customCYA?o(i.customCYA):o(re.CYA,l);else if(i.state===H.TYPES.IN_PROGRESS&&!i.alwaysShowFirstPage){const a=r.formStatus.tasks[e.name].currentPage;o(a||e.pages[0],l)}else i.firstPage?o(i.firstPage,l):o(i.pages[0],l)}},zr=({title:e,titleSize:t,type:n,cleanseHiddenData:s=!1,components:r,pages:o,hub:i={nonSequential:!1,sections:[]},cya:l={actions:[],disableTaskSwitch:!1},data:a,hashLink:c=!1,hooks:u,classBlock:h=nf,classModifiers:f=[],className:E="",hide_title:y,summaryListClassModifiers:p=[],noChangeAction:A=!1,newPageId:T="",viewOnly:N=!0,hideBlankRows:C=!1})=>d.jsx(sr,{overrides:u,children:d.jsx(rr,{children:d.jsx(sf,{title:e,titleSize:t,type:n,cleanseHiddenData:s,components:r,pages:o,hub:i,cya:l,data:a,classBlock:h,classModifiers:f,className:E,hashLink:c,hide_title:y,summaryListClassModifiers:p,noChangeAction:A,newPageId:T,viewOnly:N,hideBlankRows:C})})}),nf="hods-form",sf=({title:e,titleSize:t,type:n,cleanseHiddenData:s,components:r,pages:o,hub:i,cya:l,data:a,classBlock:c,classModifiers:u,className:h,hashLink:f,hide_title:E,summaryListClassModifiers:y,noChangeAction:p,newPageId:A,viewOnly:T,hideBlankRows:N})=>{const[C,b]=R.useState({}),[I,U]=R.useState(),[g,L]=R.useState([]),[v,F]=R.useState(void 0),[P,k]=R.useState(Q.getNextPageId(n,o,null,null,a)),[O,x]=R.useState(Q.getFormState(P,g,v)),[j,$]=R.useState({}),[q,X]=R.useState({}),[G,V]=R.useState("load"),[z,fe]=R.useState(!1),[pe,Y]=R.useState(!1),{hooks:J}=Pe(),{addErrors:Ke,clearErrors:We,errors:Ee,validate:xe}=He();window.onpopstate=B=>{if(!document.location.hash&&(B.state&&B.state.fullPages!==void 0&&$(ee=>({...ee,fullPages:B.state?.fullPages})),We(),fe(!0),J.onGoingBack(B.state?B.state:null,O.page?.formData),r&&g&&C&&O.page?.formData&&G===void 0)){const ee=w.Format.form({pages:g,components:r},{...C,...O.page.formData},we.SUBMIT);if(ee?.formStatus?.taskPage){const ie=ee.formStatus.tasks;Object.keys(ie).forEach(_e=>{const Fn=ie[_e];Fn.currentPage&&!Fn.complete&&delete ie[_e].currentPage}),delete ee.formStatus.taskPage}b(ee)}},R.useEffect(()=>{r&&o&&a&&(G==="load"||T)&&(b(w.Data.setupForm(o,r,a)),a.formStatus?.page&&k(a.formStatus.page))},[r,o,a,b,G,T]),R.useEffect(()=>{L(w.FormPage.getAll(o,r,{...C}))},[r,o,C,L]),R.useEffect(()=>{k(B=>B||Q.getNextPageId(n,g))},[n,g,k]),R.useEffect(()=>{F(w.Hub.get(n,i,r,{...C}))},[n,i,C,r,F]),R.useEffect(()=>{n===ne.HUB&&z&&C&&O.page?.formData&&(O.page.formData={...C}),fe(!1),x(Q.getFormState(P,g,v))},[g,v,P,x,n,z,C,O.page]),R.useEffect(()=>{V(void 0),J.onFormLoad(B=>{$(B)})},[J]),R.useEffect(()=>{X(i)},[i]),R.useEffect(()=>{I?.data&&(b(I.data),U(void 0))},[I,b,U]);const Ae=i?.sections,M=i?.nonSequential;R.useEffect(()=>{const B=j.fullPages;if(B&&(B.forEach(ee=>{const ie=ee;ie&&(ie.formData=C)}),$(ee=>({...ee,fullPages:B}))),Ae){const ee=C?.formStatus?.tasks||{},ie=Q.getUpdatedSectionStates(Ae,ee,M,C);X(_e=>({..._e,sections:[...ie]}))}},[j.fullPages,C,Ae,M]);const oe=(B,ee={})=>{We(),k(B),J.onPageChange(B,ee)};R.useEffect(()=>{A!==void 0&&k(A)},[A]);const be=B=>{J.onChange(B)},ve=(B,ee)=>{if(typeof ee=="function"){const ie=ee({...C});ie&&b(ie)}O.page?.type===re.PARTIAL_CYA&&!l.disableTaskSwitch&&q.sections.every(ie=>ie.tasks.every(_e=>_e.pages.includes(B.pageId)&&_e.name!==j.name?(ms(_e,g,$,q,C,oe),!1):!0)),B&&Te.cyaAction(B,P,oe)},lt=w.classBuilder(c,u,h);if(v===ye.TASK){const B=l;B.actions=[W.TYPES.SAVE_AND_CONTINUE,W.TYPES.SAVE_AND_RETURN]}const{noTaskCYAs:vn,nonSequential:Fe,...Jr}=q;return d.jsxs("div",{className:lt(),children:[e&&!E&&P===re.HUB&&d.jsx(S.Heading,{size:t,children:e}),O.cya&&d.jsx(md,{pages:Q.getRelevantPages(O,g,j.fullPages),...l,...O.page?.type===re.PARTIAL_CYA&&{actions:O.page.actions?.filter(B=>w.Component.show(B,C))},...O.cya,onAction:B=>{tf(V,B,g,xe,s,r,C,b,n,P,j,J,Ke,v,oe,O,pe,Y)},onRowAction:ve,summaryListClassModifiers:y,hide_title:E,noChangeAction:O.cya.hideChangeActions??p,noGroupAction:O.cya.hideGroupActions??!1,sections:typeof q<"u"?q.sections:[],type:n,hideBlankRows:N}),v===ye.TASK&&O.pageId===re.HUB&&d.jsx(bd,{...Jr,refNumber:C.businessKey,onTaskAction:B=>{ms(B,g,$,q,C,oe)},annotations:q?.taskListAnnotations||[],formData:C}),O.page&&!O.cya&&!O.page.collection&&d.jsx(In,{page:O.page,pages:[...g],onAction:(B,ee,ie)=>{hs(B,ee,ie,J,C,O,xe,oe,n,s,g,r,P,V,j,b,q,U,Ke,pe,Y,Ee)},onChange:be,hashLink:f,classModifiers:O.page.classModifiers,className:O.page.className,submitting:pe,pageId:P}),O.page&&!O.cya&&O.page.collection&&d.jsx(Ed,{page:O.page,pages:g,onCollectionChange:be,onAction:(B,ee,ie)=>{hs(B,ee,ie,J,C,O,xe,oe,n,s,g,r,P,V,j,b,q,U,Ke,pe,Y,Ee)},hashLink:f,classModifiers:O.page.classModifiers,className:O.page.className,submitting:pe})]})};exports.Container=Ln;exports.FormComponent=Ve;exports.FormRenderer=zr;exports.FormTypes=ne;exports.HooksContextProvider=sr;exports.HubFormats=ye;exports.Models=$o;exports.PageActions=_n;exports.SummaryList=cn;exports.Utils=w;exports.ValidationContextProvider=rr;exports.default=zr;